Skip to content

Commit

Permalink
Move files a bit and remove control word from filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
Matushl committed Mar 29, 2024
1 parent b40de34 commit 36a494f
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Meta, StoryObj } from '@storybook/react';

import { CheckboxControl } from './CheckboxControl';
import { Form } from '..';
import { Checkbox } from './Checkbox';
import { Form } from '../..';

const meta: Meta<typeof CheckboxControl> = {
component: CheckboxControl,
const meta: Meta<typeof Checkbox> = {
component: Checkbox,
tags: ['autodocs'],
title: 'Controls/CheckboxControl',
args: {
Expand All @@ -25,7 +25,7 @@ const meta: Meta<typeof CheckboxControl> = {

export default meta;

type Story = StoryObj<typeof CheckboxControl>;
type Story = StoryObj<typeof Checkbox>;

export const Basic: Story = {
args: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Checkbox } from '@utima/ui';
import { Checkbox as CheckboxUI } from '@utima/ui';

Check warning on line 1 in packages/ui-informed/src/controls/checkbox/Checkbox.tsx

View workflow job for this annotation

GitHub Actions / CI

Unable to resolve path to module '@utima/ui'
import type { ComponentProps } from 'react';

import { FormControl } from './formControl/FormControl';
import { FormControl } from '../../formControl/FormControl';

type CheckboxControlProps = Omit<ComponentProps<typeof FormControl>, 'render'>;
type CheckboxProps = Omit<ComponentProps<typeof FormControl>, 'render'>;

/**
* CheckboxControl component that is controlled by Informed. It is a wrapped in the
* `FormControl` component, which provides the necessary props for Informed to
* work along with label and error message handling.
*/
export function CheckboxControl({ ...restProps }: CheckboxControlProps) {
export function Checkbox({ ...restProps }: CheckboxProps) {
return (
<FormControl
{...restProps}
render={({ field: { ref, userProps, fieldApi, fieldState } }) => (
<Checkbox
<CheckboxUI
ref={ref}
value={fieldState.value as any} // TODO: correct type

Check warning on line 20 in packages/ui-informed/src/controls/checkbox/Checkbox.tsx

View workflow job for this annotation

GitHub Actions / CI

Unexpected any. Specify a different type
onCheckedChange={value => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Meta, StoryObj } from '@storybook/react';

import { InputControl } from './InputControl';
import { Form } from '..';
import { Input } from './Input';
import { Form } from '../..';

const meta: Meta<typeof InputControl> = {
component: InputControl,
const meta: Meta<typeof Input> = {
component: Input,
tags: ['autodocs'],
title: 'Controls/InputControl',
args: {
Expand All @@ -26,7 +26,7 @@ const meta: Meta<typeof InputControl> = {

export default meta;

type Story = StoryObj<typeof InputControl>;
type Story = StoryObj<typeof Input>;

export const Basic: Story = {
args: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Input } from '@utima/ui';
import { Input as InputUI } from '@utima/ui';

Check warning on line 1 in packages/ui-informed/src/controls/input/Input.tsx

View workflow job for this annotation

GitHub Actions / CI

Unable to resolve path to module '@utima/ui'
import type { ComponentProps } from 'react';

import { FormControl } from './formControl/FormControl';
import { FormControl } from '../../formControl/FormControl';

type InputControlProps = Omit<ComponentProps<typeof FormControl>, 'render'>;

Expand All @@ -10,16 +10,13 @@ type InputControlProps = Omit<ComponentProps<typeof FormControl>, 'render'>;
* `FormControl` component, which provides the necessary props for Informed to
* work along with label and error message handling.
*/
export function InputControl({
type = 'text',
...restProps
}: InputControlProps) {
export function Input({ type = 'text', ...restProps }: InputControlProps) {
return (
<FormControl
{...restProps}
type={type}
render={({ field: { ref, userProps, informed, fieldState } }) => (
<Input
<InputUI
ref={ref}
variant={fieldState.showError ? 'danger' : 'default'}
type={type}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Meta, StoryObj } from '@storybook/react';
import { SelectItem } from '@utima/ui';

Check warning on line 2 in packages/ui-informed/src/controls/select/Select.stories.tsx

View workflow job for this annotation

GitHub Actions / CI

Unable to resolve path to module '@utima/ui'

import { SelectControl } from './SelectControl';
import { Form } from '..';
import { Select } from './Select';
import { Form } from '../..';

function SelectItems() {
const items = [
Expand All @@ -22,8 +22,8 @@ function SelectItems() {
);
}

const meta: Meta<typeof SelectControl> = {
component: SelectControl,
const meta: Meta<typeof Select> = {
component: Select,
tags: ['autodocs'],
title: 'Controls/SelectControl',
args: {
Expand All @@ -46,7 +46,7 @@ const meta: Meta<typeof SelectControl> = {

export default meta;

type Story = StoryObj<typeof SelectControl>;
type Story = StoryObj<typeof Select>;

export const Basic: Story = {
args: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Select } from '@utima/ui';
import { Select as SelectUI } from '@utima/ui';

Check warning on line 1 in packages/ui-informed/src/controls/select/Select.tsx

View workflow job for this annotation

GitHub Actions / CI

Unable to resolve path to module '@utima/ui'
import type { ComponentProps } from 'react';

import { FormControl } from './formControl/FormControl';
import { FormControl } from '../../formControl/FormControl';

type SelectControlProps = Omit<ComponentProps<typeof FormControl>, 'render'>;

Expand All @@ -10,7 +10,7 @@ type SelectControlProps = Omit<ComponentProps<typeof FormControl>, 'render'>;
* `FormControl` component, which provides the necessary props for Informed to
* work along with label and error message handling.
*/
export function SelectControl({
export function Select({
type = 'text',
children,
...restProps
Expand All @@ -23,7 +23,7 @@ export function SelectControl({
const { type, disabled, readOnly, ...restProps } = userProps;

return (
<Select
<SelectUI
ref={ref}
size='md'
value={fieldState.value as string}
Expand All @@ -35,7 +35,7 @@ export function SelectControl({
{...restProps}
>
{children}
</Select>
</SelectUI>
);
}}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Meta, StoryObj } from '@storybook/react';

import { TextAreaControl } from './TextAreaControl';
import { Form } from '..';
import { TextArea } from './TextArea';
import { Form } from '../..';

const meta: Meta<typeof TextAreaControl> = {
component: TextAreaControl,
const meta: Meta<typeof TextArea> = {
component: TextArea,
tags: ['autodocs'],
title: 'Controls/TextAreaControl',
args: {
Expand All @@ -26,7 +26,7 @@ const meta: Meta<typeof TextAreaControl> = {

export default meta;

type Story = StoryObj<typeof TextAreaControl>;
type Story = StoryObj<typeof TextArea>;

export const Basic: Story = {
args: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TextArea } from '@utima/ui';
import { TextArea as TextAreaUI } from '@utima/ui';

Check warning on line 1 in packages/ui-informed/src/controls/textArea/TextArea.tsx

View workflow job for this annotation

GitHub Actions / CI

Unable to resolve path to module '@utima/ui'
import type { ComponentProps } from 'react';

import { FormControl } from './formControl/FormControl';
import { FormControl } from '../../formControl/FormControl';

export type TextAreaControlProps = Omit<
ComponentProps<typeof FormControl>,
Expand All @@ -13,16 +13,13 @@ export type TextAreaControlProps = Omit<
* `FormControl` component, which provides the necessary props for Informed to
* work along with label and error message handling.
*/
export function TextAreaControl({
rows = 4,
...restProps
}: TextAreaControlProps) {
export function TextArea({ rows = 4, ...restProps }: TextAreaControlProps) {
return (
<FormControl
type='text'
{...restProps}
render={({ field: { ref, userProps, informed, fieldState } }) => (
<TextArea
<TextAreaUI
ref={ref}
rows={rows}
variant={fieldState.showError ? 'danger' : 'default'}
Expand Down
10 changes: 5 additions & 5 deletions packages/ui-informed/src/form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* to allow for dot notation imports.
*/
export { Form as Root } from './Form';
export { CheckboxControl as Checkbox } from '../controls/CheckboxControl';
export { InputControl as Input } from '../controls/InputControl';
export { SelectControl as Select } from '../controls/SelectControl';
export { SelectItem as SelectItem } from '@utima/ui';
export { TextAreaControl as TextArea } from '../controls/TextAreaControl';
export { Checkbox } from '../controls/checkbox/Checkbox';
export { Input } from '../controls/input/Input';
export { Select } from '../controls/select/Select';
export { SelectItem } from '@utima/ui';

Check warning on line 9 in packages/ui-informed/src/form/index.ts

View workflow job for this annotation

GitHub Actions / CI

Unable to resolve path to module '@utima/ui'
export { TextArea } from '../controls/textArea/TextArea';
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type { ZodType } from 'zod';

import { FormInfo } from './FormInfo';
import { FormMessage } from './FormMessage';
import { useFormContext } from '../../form/useFormContext';
import { zodResolver, getFieldZodObject } from '../../zodUtils';
import { useFormContext } from '../form/useFormContext';
import { zodResolver, getFieldZodObject } from '../zodUtils';

const formItemStyles = cva('flex flex-1 gap-2', {
variants: {
Expand Down
15 changes: 10 additions & 5 deletions packages/ui-informed/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ export * as FormWithControls from './form';
/**
* FormControl
*/
export { FormControl } from './controls/formControl/FormControl';
export { FormControl } from './formControl/FormControl';

/**
* Controls
*/
export { CheckboxControl } from './controls/CheckboxControl';
export { InputControl } from './controls/InputControl';
export { SelectControl } from './controls/SelectControl';
export { TextAreaControl } from './controls/TextAreaControl';
export { Checkbox } from './controls/checkbox/Checkbox';
export { Input } from './controls/input/Input';
export { Select } from './controls/select/Select';
export { TextArea } from './controls/textArea/TextArea';

/**
* Form
Expand All @@ -29,3 +29,8 @@ export {
useDefaultSubmitActions,
type TypedFormState,
} from './form/useDefaultSubmitActions';

/**
* ZodUtils
*/
export { isZodError, zodResolver, getFieldZodObject } from './zodUtils';

0 comments on commit 36a494f

Please sign in to comment.