@ttoss/forms 0.36.6 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -398,6 +398,25 @@ const options = [
|
|
|
398
398
|
/>
|
|
399
399
|
```
|
|
400
400
|
|
|
401
|
+
### FormFieldSegmentedControl
|
|
402
|
+
|
|
403
|
+
Segmented control field wrapping the `SegmentedControl` from `@ttoss/ui`. Use this field when you want a compact set of mutually-exclusive options presented as segmented buttons.
|
|
404
|
+
|
|
405
|
+
Props are the common form field props plus any `SegmentedControl` props (except `value` and `className`). Notably, the `variant` prop is supported and defaults to `"secondary"` if not provided.
|
|
406
|
+
|
|
407
|
+
```tsx
|
|
408
|
+
<FormFieldSegmentedControl
|
|
409
|
+
name="viewMode"
|
|
410
|
+
label="View"
|
|
411
|
+
options={[
|
|
412
|
+
{ value: 'list', label: 'List' },
|
|
413
|
+
{ value: 'grid', label: 'Grid' },
|
|
414
|
+
]}
|
|
415
|
+
variant="primary" // optional, defaults to "secondary"
|
|
416
|
+
defaultValue="list"
|
|
417
|
+
/>
|
|
418
|
+
```
|
|
419
|
+
|
|
401
420
|
When using a `placeholder`, an empty option is automatically added if not present:
|
|
402
421
|
|
|
403
422
|
```tsx
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { Form, useForm, yupResolver } from "../chunk-
|
|
3
|
+
import { Form, useForm, yupResolver } from "../chunk-7SI2CKE4.js";
|
|
4
4
|
import { __name } from "../chunk-QJQFXN4B.js";
|
|
5
5
|
|
|
6
6
|
// src/MultistepForm/MultistepForm.tsx
|
|
@@ -626,6 +626,59 @@ var FormFieldRadioCardIcony = /* @__PURE__ */__name(({
|
|
|
626
626
|
});
|
|
627
627
|
}, "FormFieldRadioCardIcony");
|
|
628
628
|
|
|
629
|
+
// src/FormFieldSegmentedControl.tsx
|
|
630
|
+
import { SegmentedControl } from "@ttoss/ui";
|
|
631
|
+
var FormFieldSegmentedControl = /* @__PURE__ */__name(({
|
|
632
|
+
defaultValue = "",
|
|
633
|
+
disabled,
|
|
634
|
+
...props
|
|
635
|
+
}) => {
|
|
636
|
+
const {
|
|
637
|
+
label,
|
|
638
|
+
name,
|
|
639
|
+
labelTooltip,
|
|
640
|
+
warning,
|
|
641
|
+
sx: fieldSx,
|
|
642
|
+
css,
|
|
643
|
+
rules,
|
|
644
|
+
id,
|
|
645
|
+
auxiliaryCheckbox,
|
|
646
|
+
onChange,
|
|
647
|
+
variant = "secondary",
|
|
648
|
+
...segmentedProps
|
|
649
|
+
} = props;
|
|
650
|
+
return /* @__PURE__ */React.createElement(FormField, {
|
|
651
|
+
id,
|
|
652
|
+
label,
|
|
653
|
+
name,
|
|
654
|
+
labelTooltip,
|
|
655
|
+
warning,
|
|
656
|
+
sx: fieldSx,
|
|
657
|
+
css,
|
|
658
|
+
defaultValue,
|
|
659
|
+
rules,
|
|
660
|
+
disabled,
|
|
661
|
+
auxiliaryCheckbox,
|
|
662
|
+
render: /* @__PURE__ */__name(({
|
|
663
|
+
field,
|
|
664
|
+
fieldState
|
|
665
|
+
}) => {
|
|
666
|
+
return /* @__PURE__ */React.createElement(SegmentedControl, {
|
|
667
|
+
...segmentedProps,
|
|
668
|
+
...field,
|
|
669
|
+
variant,
|
|
670
|
+
value: field.value,
|
|
671
|
+
onChange: /* @__PURE__ */__name(v => {
|
|
672
|
+
field.onChange(v);
|
|
673
|
+
onChange?.(v);
|
|
674
|
+
}, "onChange"),
|
|
675
|
+
disabled: disabled ?? field.disabled,
|
|
676
|
+
"aria-invalid": fieldState.error ? "true" : void 0
|
|
677
|
+
});
|
|
678
|
+
}, "render")
|
|
679
|
+
});
|
|
680
|
+
}, "FormFieldSegmentedControl");
|
|
681
|
+
|
|
629
682
|
// src/FormFieldSelect.tsx
|
|
630
683
|
import { Select } from "@ttoss/ui";
|
|
631
684
|
var FormFieldSelect = /* @__PURE__ */__name(({
|
|
@@ -970,4 +1023,4 @@ import * as yup2 from "yup";
|
|
|
970
1023
|
import { yupResolver } from "@hookform/resolvers/yup";
|
|
971
1024
|
import { Controller, FormProvider as FormProvider2, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from "react-hook-form";
|
|
972
1025
|
export * from "react-hook-form";
|
|
973
|
-
export { Form, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldNumericFormat, FormFieldCurrencyInput, FormFieldDatePicker, FormFieldInput, FormFieldPassword, FormFieldRadio, FormFieldRadioCard, FormFieldRadioCardIcony, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, useFormGroup, FormGroup, yup2 as yup, yupResolver, Controller, FormProvider2 as FormProvider, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch };
|
|
1026
|
+
export { Form, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldNumericFormat, FormFieldCurrencyInput, FormFieldDatePicker, FormFieldInput, FormFieldPassword, FormFieldRadio, FormFieldRadioCard, FormFieldRadioCardIcony, FormFieldSegmentedControl, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, useFormGroup, FormGroup, yup2 as yup, yupResolver, Controller, FormProvider2 as FormProvider, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import { Controller, Form, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldDatePicker, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldRadio, FormFieldRadioCard, FormFieldRadioCardIcony, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, FormGroup, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormGroup, useFormState, useWatch, yup, yupResolver } from "./chunk-
|
|
2
|
+
import { Controller, Form, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldDatePicker, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldRadio, FormFieldRadioCard, FormFieldRadioCardIcony, FormFieldSegmentedControl, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, FormGroup, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormGroup, useFormState, useWatch, yup, yupResolver } from "./chunk-7SI2CKE4.js";
|
|
3
3
|
import { FormErrorMessage, FormField, FormFieldPatternFormat } from "./chunk-QJQFXN4B.js";
|
|
4
|
-
export { Controller, Form, FormErrorMessage, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldDatePicker, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldPatternFormat, FormFieldRadio, FormFieldRadioCard, FormFieldRadioCardIcony, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, FormGroup, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormGroup, useFormState, useWatch, yup, yupResolver };
|
|
4
|
+
export { Controller, Form, FormErrorMessage, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldDatePicker, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldPatternFormat, FormFieldRadio, FormFieldRadioCard, FormFieldRadioCardIcony, FormFieldSegmentedControl, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, FormGroup, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormGroup, useFormState, useWatch, yup, yupResolver };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { BoxProps, CheckboxProps, InputProps, InputPasswordProps, RadioProps, ThemeUIStyleObject, SelectProps, SwitchProps, TextareaProps } from '@ttoss/ui';
|
|
2
|
+
import { BoxProps, CheckboxProps, InputProps, InputPasswordProps, RadioProps, ThemeUIStyleObject, SegmentedControlProps, SelectProps, SwitchProps, TextareaProps } from '@ttoss/ui';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { FieldValues, FormProviderProps, FieldName, FieldPath } from 'react-hook-form';
|
|
5
5
|
export * from 'react-hook-form';
|
|
@@ -97,6 +97,9 @@ type FormFieldRadioCardIconyProps<TFieldValues extends FieldValues = FieldValues
|
|
|
97
97
|
};
|
|
98
98
|
declare const FormFieldRadioCardIcony: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ disabled, ...props }: FormFieldRadioCardIconyProps<TFieldValues, TName>) => react_jsx_runtime.JSX.Element;
|
|
99
99
|
|
|
100
|
+
type FormFieldSegmentedControlProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = FormFieldProps<TFieldValues, TName> & Omit<SegmentedControlProps, 'value' | 'className'>;
|
|
101
|
+
declare const FormFieldSegmentedControl: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ defaultValue, disabled, ...props }: FormFieldSegmentedControlProps<TFieldValues, TName>) => react_jsx_runtime.JSX.Element;
|
|
102
|
+
|
|
100
103
|
type FormFieldSelectProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = FormFieldProps<TFieldValues, TName> & Omit<SelectProps, 'name' | 'defaultValue'>;
|
|
101
104
|
declare const FormFieldSelect: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ disabled, ...props }: FormFieldSelectProps<TFieldValues, TName>) => react_jsx_runtime.JSX.Element;
|
|
102
105
|
|
|
@@ -117,4 +120,4 @@ type FormGroupProps = {
|
|
|
117
120
|
} & BoxProps;
|
|
118
121
|
declare const FormGroup: (props: FormGroupProps) => react_jsx_runtime.JSX.Element;
|
|
119
122
|
|
|
120
|
-
export { type DateRangePreset, Form, FormErrorMessage, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldDatePicker, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldProps, FormFieldRadio, FormFieldRadioCard, FormFieldRadioCardIcony, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, FormGroup, type FormRadioOption, useFormGroup };
|
|
123
|
+
export { type DateRangePreset, Form, FormErrorMessage, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldDatePicker, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldProps, FormFieldRadio, FormFieldRadioCard, FormFieldRadioCardIcony, FormFieldSegmentedControl, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, FormGroup, type FormRadioOption, useFormGroup };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/forms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=16.8.0",
|
|
42
|
-
"@ttoss/components": "^2.11.
|
|
42
|
+
"@ttoss/components": "^2.11.6",
|
|
43
43
|
"@ttoss/react-i18n": "^2.0.25",
|
|
44
|
-
"@ttoss/ui": "^6.
|
|
44
|
+
"@ttoss/ui": "^6.4.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/jest": "^30.0.0",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"react-error-boundary": "^6.0.0",
|
|
52
52
|
"tsup": "^8.5.1",
|
|
53
53
|
"yup": "^1.7.1",
|
|
54
|
-
"@ttoss/components": "^2.11.
|
|
55
|
-
"@ttoss/config": "^1.35.12",
|
|
56
|
-
"@ttoss/i18n-cli": "^0.7.38",
|
|
57
|
-
"@ttoss/react-i18n": "^2.0.25",
|
|
54
|
+
"@ttoss/components": "^2.11.6",
|
|
58
55
|
"@ttoss/react-icons": "^0.5.6",
|
|
59
|
-
"@ttoss/
|
|
60
|
-
"@ttoss/test-utils": "^4.0.2"
|
|
56
|
+
"@ttoss/react-i18n": "^2.0.25",
|
|
57
|
+
"@ttoss/test-utils": "^4.0.2",
|
|
58
|
+
"@ttoss/ui": "^6.4.0",
|
|
59
|
+
"@ttoss/config": "^1.35.12",
|
|
60
|
+
"@ttoss/i18n-cli": "^0.7.38"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public",
|