@saas-ui/forms 1.0.0-rc.0 → 1.0.0-rc.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +52 -0
- package/dist/auto-form.d.ts +13 -1
- package/dist/auto-form.d.ts.map +1 -1
- package/dist/field.d.ts +2 -2
- package/dist/field.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.modern.mjs.map +1 -1
- package/dist/yup/index.js +1 -1
- package/dist/yup/index.js.map +1 -1
- package/dist/yup/index.modern.mjs +1 -1
- package/dist/yup/index.modern.mjs.map +1 -1
- package/dist/zod/index.js +1 -1
- package/dist/zod/index.js.map +1 -1
- package/dist/zod/index.modern.mjs +1 -1
- package/dist/zod/index.modern.mjs.map +1 -1
- package/package.json +15 -15
- package/src/auto-form.tsx +22 -3
- package/src/field-resolver.ts +2 -2
- package/src/field.tsx +19 -19
- package/src/object-field.tsx +3 -3
package/src/field.tsx
CHANGED
@@ -227,7 +227,7 @@ const createField = (
|
|
227
227
|
ref={ref}
|
228
228
|
id={id}
|
229
229
|
name={name}
|
230
|
-
label={label}
|
230
|
+
label={hideLabel ? label : undefined} // Only pass down the label when it should be inline.
|
231
231
|
rules={inputRules}
|
232
232
|
{...inputProps}
|
233
233
|
/>
|
@@ -292,7 +292,7 @@ export interface RegisterFieldTypeOptions {
|
|
292
292
|
* @param component The React component
|
293
293
|
* @param options
|
294
294
|
* @param options.isControlled Set this to true if this is a controlled field.
|
295
|
-
* @param options.hideLabel Hide the field label, for example for checkbox
|
295
|
+
* @param options.hideLabel Hide the field label, for example for the checkbox field.
|
296
296
|
*/
|
297
297
|
export const registerFieldType = (
|
298
298
|
type: string,
|
@@ -320,9 +320,12 @@ export const registerFieldType = (
|
|
320
320
|
return Field
|
321
321
|
}
|
322
322
|
|
323
|
-
|
324
|
-
|
325
|
-
|
323
|
+
export const InputField = registerFieldType(
|
324
|
+
'text',
|
325
|
+
forwardRef(({ type = 'text', ...rest }, ref) => {
|
326
|
+
return <Input type={type} {...rest} ref={ref} />
|
327
|
+
})
|
328
|
+
)
|
326
329
|
export const NumberInputField = registerFieldType('number', NumberInput, {
|
327
330
|
isControlled: true,
|
328
331
|
})
|
@@ -330,16 +333,11 @@ export const PasswordInputFIeld = registerFieldType('password', PasswordInput)
|
|
330
333
|
export const TextareaField = registerFieldType('textarea', Textarea)
|
331
334
|
export const SwitchField = registerFieldType(
|
332
335
|
'switch',
|
333
|
-
forwardRef(({
|
334
|
-
return
|
335
|
-
<Switch ref={ref} {...props}>
|
336
|
-
{label}
|
337
|
-
</Switch>
|
338
|
-
)
|
336
|
+
forwardRef(({ type, ...rest }, ref) => {
|
337
|
+
return <Switch {...rest} ref={ref} />
|
339
338
|
}),
|
340
339
|
{
|
341
340
|
isControlled: true,
|
342
|
-
hideLabel: true,
|
343
341
|
}
|
344
342
|
)
|
345
343
|
export const SelectField = registerFieldType('select', Select, {
|
@@ -347,13 +345,15 @@ export const SelectField = registerFieldType('select', Select, {
|
|
347
345
|
})
|
348
346
|
export const CheckboxField = registerFieldType(
|
349
347
|
'checkbox',
|
350
|
-
forwardRef(
|
351
|
-
|
352
|
-
|
353
|
-
{
|
354
|
-
|
355
|
-
|
356
|
-
|
348
|
+
forwardRef(
|
349
|
+
({ label, type, ...props }: { label?: string; type: string }, ref) => {
|
350
|
+
return (
|
351
|
+
<Checkbox ref={ref} {...props}>
|
352
|
+
{label}
|
353
|
+
</Checkbox>
|
354
|
+
)
|
355
|
+
}
|
356
|
+
),
|
357
357
|
{
|
358
358
|
hideLabel: true,
|
359
359
|
}
|
package/src/object-field.tsx
CHANGED
@@ -4,7 +4,7 @@ import {
|
|
4
4
|
FormLabel,
|
5
5
|
FormLabelProps,
|
6
6
|
ResponsiveValue,
|
7
|
-
|
7
|
+
useStyleConfig,
|
8
8
|
} from '@chakra-ui/react'
|
9
9
|
import { __DEV__ } from '@chakra-ui/utils'
|
10
10
|
|
@@ -21,8 +21,8 @@ export interface ObjectFieldProps extends FieldProps {
|
|
21
21
|
}
|
22
22
|
|
23
23
|
export const FormLegend = (props: FormLabelProps) => {
|
24
|
-
const styles =
|
25
|
-
return <FormLabel as="legend" sx={styles
|
24
|
+
const styles = useStyleConfig('FormLegend')
|
25
|
+
return <FormLabel as="legend" sx={styles} {...props} />
|
26
26
|
}
|
27
27
|
|
28
28
|
export const ObjectField: React.FC<ObjectFieldProps> = (props) => {
|