-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add dependencies and necessary translations * Add Form component with hooks * Add FormControl component with ZodUtils * Add translations to storybook previews * Add field Controls * Add Control stories, change file structure and add `index.ts` * Add changeset * Use memo instead of forwardRef * Small cleanup and improvements - move hooks to form folder - replace `type + &` with `interface + extends` - improve package.json and more * Move files a bit and remove `control` word from filenames * Create `FormTranslationContext` and use instead of `i18n` * Remove i18n dependencies and files * Remove export of alias `FormWithControls`
- Loading branch information
Showing
23 changed files
with
827 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@utima/ui-informed": minor | ||
--- | ||
|
||
Add Form component with `informed` and context | ||
Add multiple Controls tied with utima/ui components and stories for them | ||
Add Zod resolver | ||
Setup i18next with essential czech translations (so far without possibility to customize) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
packages/ui-informed/src/controls/InputControl.stories.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
packages/ui-informed/src/controls/checkbox/Checkbox.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Checkbox } from './Checkbox'; | ||
import { Form } from '../..'; | ||
|
||
const meta: Meta<typeof Checkbox> = { | ||
component: Checkbox, | ||
tags: ['autodocs'], | ||
title: 'Controls/CheckboxControl', | ||
args: { | ||
name: 'input', | ||
label: 'Checkbox', | ||
tooltip: 'Tooltip', | ||
}, | ||
decorators: [ | ||
Story => ( | ||
<Form initialValues={{ input: false }}> | ||
<div className='flex flex-col sm:col-span-3'> | ||
<Story /> | ||
</div> | ||
</Form> | ||
), | ||
], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Checkbox>; | ||
|
||
export const Basic: Story = { | ||
args: {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Checkbox as CheckboxUI } from '@utima/ui'; | ||
import type { ComponentProps } from 'react'; | ||
|
||
import { FormControl } from '../../formControl/FormControl'; | ||
|
||
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 Checkbox({ ...restProps }: CheckboxProps) { | ||
return ( | ||
<FormControl | ||
{...restProps} | ||
render={({ field: { ref, userProps, fieldApi, fieldState } }) => ( | ||
<CheckboxUI | ||
ref={ref} | ||
value={fieldState.value as any} // TODO: correct type | ||
onCheckedChange={value => { | ||
fieldApi.setValue(value); | ||
fieldApi.setTouched(true); | ||
fieldApi.setFocused(true); | ||
}} | ||
variant={fieldState.showError ? 'danger' : 'primary'} | ||
{...userProps} | ||
type='button' | ||
/> | ||
)} | ||
/> | ||
); | ||
} |
Oops, something went wrong.