@douglasneuroinformatics/libui 2.4.4 → 2.5.1
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/dist/components/Form/BaseRadioField.d.ts +1 -1
- package/dist/components/Form/BaseRadioField.d.ts.map +1 -1
- package/dist/components/Form/BaseRadioField.js +3 -3
- package/dist/components/Form/BooleanField/BooleanFieldCheckbox.d.ts +1 -1
- package/dist/components/Form/BooleanField/BooleanFieldCheckbox.d.ts.map +1 -1
- package/dist/components/Form/BooleanField/BooleanFieldCheckbox.js +2 -2
- package/dist/components/Form/BooleanField/BooleanFieldRadio.d.ts +1 -1
- package/dist/components/Form/BooleanField/BooleanFieldRadio.d.ts.map +1 -1
- package/dist/components/Form/BooleanField/BooleanFieldRadio.js +4 -4
- package/dist/components/Form/DateField/DateField.d.ts +1 -1
- package/dist/components/Form/DateField/DateField.d.ts.map +1 -1
- package/dist/components/Form/DateField/DateField.js +2 -2
- package/dist/components/Form/DynamicField.d.ts +2 -1
- package/dist/components/Form/DynamicField.d.ts.map +1 -1
- package/dist/components/Form/DynamicField.js +2 -2
- package/dist/components/Form/FieldGroup/FieldGroupDescription.js +1 -1
- package/dist/components/Form/FieldsComponent.d.ts +1 -0
- package/dist/components/Form/FieldsComponent.d.ts.map +1 -1
- package/dist/components/Form/Form.d.ts +5 -2
- package/dist/components/Form/Form.d.ts.map +1 -1
- package/dist/components/Form/Form.js +28 -12
- package/dist/components/Form/NumberField/NumberFieldInput.d.ts +1 -1
- package/dist/components/Form/NumberField/NumberFieldInput.d.ts.map +1 -1
- package/dist/components/Form/NumberField/NumberFieldInput.js +2 -2
- package/dist/components/Form/NumberField/NumberFieldRadio.d.ts +1 -1
- package/dist/components/Form/NumberField/NumberFieldRadio.d.ts.map +1 -1
- package/dist/components/Form/NumberField/NumberFieldRadio.js +3 -3
- package/dist/components/Form/NumberField/NumberFieldSelect.d.ts +1 -1
- package/dist/components/Form/NumberField/NumberFieldSelect.d.ts.map +1 -1
- package/dist/components/Form/NumberField/NumberFieldSelect.js +2 -2
- package/dist/components/Form/NumberField/NumberFieldSlider.d.ts +1 -1
- package/dist/components/Form/NumberField/NumberFieldSlider.d.ts.map +1 -1
- package/dist/components/Form/NumberField/NumberFieldSlider.js +2 -2
- package/dist/components/Form/NumberRecordField.d.ts +1 -1
- package/dist/components/Form/NumberRecordField.d.ts.map +1 -1
- package/dist/components/Form/NumberRecordField.js +3 -3
- package/dist/components/Form/RecordArrayField.d.ts +1 -0
- package/dist/components/Form/RecordArrayField.d.ts.map +1 -1
- package/dist/components/Form/RecordArrayField.js +5 -5
- package/dist/components/Form/SetField/SetFieldListbox.d.ts +1 -1
- package/dist/components/Form/SetField/SetFieldListbox.d.ts.map +1 -1
- package/dist/components/Form/SetField/SetFieldListbox.js +2 -2
- package/dist/components/Form/SetField/SetFieldSelect.d.ts +1 -1
- package/dist/components/Form/SetField/SetFieldSelect.d.ts.map +1 -1
- package/dist/components/Form/SetField/SetFieldSelect.js +2 -2
- package/dist/components/Form/StaticField.d.ts +2 -1
- package/dist/components/Form/StaticField.d.ts.map +1 -1
- package/dist/components/Form/StaticField.js +4 -4
- package/dist/components/Form/StringField/StringFieldInput.d.ts +1 -1
- package/dist/components/Form/StringField/StringFieldInput.d.ts.map +1 -1
- package/dist/components/Form/StringField/StringFieldInput.js +2 -2
- package/dist/components/Form/StringField/StringFieldPassword.d.ts +1 -1
- package/dist/components/Form/StringField/StringFieldPassword.d.ts.map +1 -1
- package/dist/components/Form/StringField/StringFieldPassword.js +3 -3
- package/dist/components/Form/StringField/StringFieldSelect.d.ts +1 -1
- package/dist/components/Form/StringField/StringFieldSelect.d.ts.map +1 -1
- package/dist/components/Form/StringField/StringFieldSelect.js +2 -2
- package/dist/components/Form/StringField/StringFieldTextArea.d.ts +1 -1
- package/dist/components/Form/StringField/StringFieldTextArea.d.ts.map +1 -1
- package/dist/components/Form/StringField/StringFieldTextArea.js +2 -2
- package/dist/components/Form/types.d.ts +1 -0
- package/dist/components/Form/types.d.ts.map +1 -1
- package/dist/components/Heading/Heading.js +1 -1
- package/dist/components/Label/Label.js +1 -1
- package/dist/components/Slider/Slider.d.ts.map +1 -1
- package/dist/components/Slider/Slider.js +4 -4
- package/package.json +1 -1
- package/src/components/Form/BaseRadioField.tsx +3 -2
- package/src/components/Form/BooleanField/BooleanFieldCheckbox.tsx +2 -1
- package/src/components/Form/BooleanField/BooleanFieldRadio.tsx +12 -4
- package/src/components/Form/DateField/DateField.tsx +2 -1
- package/src/components/Form/DynamicField.tsx +5 -1
- package/src/components/Form/FieldGroup/FieldGroupDescription.tsx +1 -1
- package/src/components/Form/FieldsComponent.tsx +1 -0
- package/src/components/Form/Form.tsx +54 -10
- package/src/components/Form/NumberField/NumberFieldInput.tsx +10 -1
- package/src/components/Form/NumberField/NumberFieldRadio.tsx +3 -2
- package/src/components/Form/NumberField/NumberFieldSelect.tsx +2 -1
- package/src/components/Form/NumberField/NumberFieldSlider.tsx +9 -1
- package/src/components/Form/NumberRecordField.tsx +5 -1
- package/src/components/Form/RecordArrayField.tsx +7 -3
- package/src/components/Form/SetField/SetFieldListbox.tsx +2 -0
- package/src/components/Form/SetField/SetFieldSelect.tsx +2 -1
- package/src/components/Form/StaticField.tsx +5 -0
- package/src/components/Form/StringField/StringFieldInput.tsx +17 -2
- package/src/components/Form/StringField/StringFieldPassword.tsx +12 -1
- package/src/components/Form/StringField/StringFieldSelect.tsx +2 -1
- package/src/components/Form/StringField/StringFieldTextArea.tsx +17 -2
- package/src/components/Form/types.ts +1 -0
- package/src/components/Heading/Heading.tsx +1 -1
- package/src/components/Label/Label.tsx +1 -1
- package/src/components/Slider/Slider.tsx +10 -3
|
@@ -9,5 +9,5 @@ export type BaseRadioFieldProps<T extends string> = Simplify<{
|
|
|
9
9
|
};
|
|
10
10
|
orientation?: 'horizontal' | 'vertical';
|
|
11
11
|
} & BaseFieldComponentProps<T>>;
|
|
12
|
-
export declare const BaseRadioField: <T extends string>({ description, error, label, name, options, orientation, setValue, value }: BaseRadioFieldProps<T>) => React.JSX.Element;
|
|
12
|
+
export declare const BaseRadioField: <T extends string>({ description, error, label, name, options, orientation, readOnly, setValue, value }: BaseRadioFieldProps<T>) => React.JSX.Element;
|
|
13
13
|
//# sourceMappingURL=BaseRadioField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseRadioField.d.ts","sourceRoot":"","sources":["../../../src/components/Form/BaseRadioField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAc1D,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,IAAI,QAAQ,CAC1D;IACE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;SAAG,CAAC,IAAI,CAAC,GAAG,MAAM;KAAE,CAAC;IAC9B,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACzC,GAAG,uBAAuB,CAAC,CAAC,CAAC,CAC/B,CAAC;AAEF,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"BaseRadioField.d.ts","sourceRoot":"","sources":["../../../src/components/Form/BaseRadioField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAc1D,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,IAAI,QAAQ,CAC1D;IACE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;SAAG,CAAC,IAAI,CAAC,GAAG,MAAM;KAAE,CAAC;IAC9B,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACzC,GAAG,uBAAuB,CAAC,CAAC,CAAC,CAC/B,CAAC;AAEF,eAAO,MAAM,cAAc,2GAUxB,oBAAoB,CAAC,CAAC,sBA0BxB,CAAC"}
|
|
@@ -14,14 +14,14 @@ const baseRadioFieldVariants = cva('flex', {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
-
export const BaseRadioField = ({ description, error, label, name, options, orientation = 'vertical', setValue, value }) => {
|
|
17
|
+
export const BaseRadioField = ({ description, error, label, name, options, orientation = 'vertical', readOnly, setValue, value }) => {
|
|
18
18
|
const optionsCount = Object.keys(options).length;
|
|
19
19
|
return (React.createElement(FieldGroup, null,
|
|
20
20
|
React.createElement(FieldGroup.Row, null,
|
|
21
21
|
React.createElement(Label, null, label),
|
|
22
22
|
React.createElement(FieldGroup.Description, { description: description })),
|
|
23
23
|
React.createElement(RadioGroup, { className: baseRadioFieldVariants({ orientation: optionsCount > 5 ? 'vertical' : orientation }), name: name, value: value ?? '', onValueChange: (value) => setValue(value) }, Object.keys(options).map((option) => (React.createElement("div", { className: "flex items-center gap-2", key: option },
|
|
24
|
-
React.createElement(RadioGroup.Item, { id: `${name}-${option}`, value: option }),
|
|
25
|
-
React.createElement(Label, { className: "font-normal text-muted-foreground", htmlFor: `${name}-${option}` }, options[option]))))),
|
|
24
|
+
React.createElement(RadioGroup.Item, { disabled: readOnly, id: `${name}-${option}`, value: option }),
|
|
25
|
+
React.createElement(Label, { "aria-disabled": readOnly, className: "font-normal text-muted-foreground", htmlFor: `${name}-${option}` }, options[option]))))),
|
|
26
26
|
React.createElement(FieldGroup.Error, { error: error })));
|
|
27
27
|
};
|
|
@@ -5,5 +5,5 @@ import type { BaseFieldComponentProps } from '../types.js';
|
|
|
5
5
|
export type BooleanFieldCheckboxProps = Simplify<BaseFieldComponentProps<boolean> & Omit<Extract<BooleanFormField, {
|
|
6
6
|
variant: 'checkbox';
|
|
7
7
|
}>, 'kind'>>;
|
|
8
|
-
export declare const BooleanFieldCheckbox: ({ error, label, name, setValue, value }: BooleanFieldCheckboxProps) => React.JSX.Element;
|
|
8
|
+
export declare const BooleanFieldCheckbox: ({ error, label, name, readOnly, setValue, value }: BooleanFieldCheckboxProps) => React.JSX.Element;
|
|
9
9
|
//# sourceMappingURL=BooleanFieldCheckbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanFieldCheckbox.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/BooleanField/BooleanFieldCheckbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAC9C,uBAAuB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;IAAE,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC,EAAE,MAAM,CAAC,CACpG,CAAC;AAEF,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"BooleanFieldCheckbox.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/BooleanField/BooleanFieldCheckbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAC9C,uBAAuB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;IAAE,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC,EAAE,MAAM,CAAC,CACpG,CAAC;AAEF,eAAO,MAAM,oBAAoB,sDAAuD,yBAAyB,sBAoBhH,CAAC"}
|
|
@@ -2,10 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { Checkbox } from '../../Checkbox/Checkbox.js';
|
|
3
3
|
import { Label } from '../../Label/Label.js';
|
|
4
4
|
import { FieldGroup } from '../FieldGroup/FieldGroup.js';
|
|
5
|
-
export const BooleanFieldCheckbox = ({ error, label, name, setValue, value }) => {
|
|
5
|
+
export const BooleanFieldCheckbox = ({ error, label, name, readOnly, setValue, value }) => {
|
|
6
6
|
return (React.createElement(FieldGroup, null,
|
|
7
7
|
React.createElement(FieldGroup.Row, null,
|
|
8
|
-
React.createElement(Checkbox, { checked: value, id: name, name: name, onCheckedChange: (value) => {
|
|
8
|
+
React.createElement(Checkbox, { checked: value, disabled: readOnly, id: name, name: name, onCheckedChange: (value) => {
|
|
9
9
|
if (typeof value === 'boolean') {
|
|
10
10
|
setValue(value);
|
|
11
11
|
}
|
|
@@ -5,5 +5,5 @@ import type { BaseFieldComponentProps } from '../types.js';
|
|
|
5
5
|
export type BooleanFieldRadioProps = Simplify<BaseFieldComponentProps<boolean> & Omit<Extract<BooleanFormField, {
|
|
6
6
|
variant: 'radio';
|
|
7
7
|
}>, 'kind'>>;
|
|
8
|
-
export declare const BooleanFieldRadio: ({ error, label, name, options, setValue, value }: BooleanFieldRadioProps) => React.JSX.Element;
|
|
8
|
+
export declare const BooleanFieldRadio: ({ error, label, name, options, readOnly, setValue, value }: BooleanFieldRadioProps) => React.JSX.Element;
|
|
9
9
|
//# sourceMappingURL=BooleanFieldRadio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanFieldRadio.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/BooleanField/BooleanFieldRadio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAGlF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAS3D,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAC3C,uBAAuB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,MAAM,CAAC,CACjG,CAAC;AAEF,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"BooleanFieldRadio.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/BooleanField/BooleanFieldRadio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAGlF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAS3D,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAC3C,uBAAuB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,MAAM,CAAC,CACjG,CAAC;AAEF,eAAO,MAAM,iBAAiB,+DAQ3B,sBAAsB,sBAkCxB,CAAC"}
|
|
@@ -9,7 +9,7 @@ const stringifyBoolean = (value) => match(value)
|
|
|
9
9
|
.with(true, () => 'true')
|
|
10
10
|
.with(false, () => 'false')
|
|
11
11
|
.exhaustive();
|
|
12
|
-
export const BooleanFieldRadio = ({ error, label, name, options, setValue, value }) => {
|
|
12
|
+
export const BooleanFieldRadio = ({ error, label, name, options, readOnly, setValue, value }) => {
|
|
13
13
|
const { t } = useTranslation('libui');
|
|
14
14
|
const handleValueChange = useCallback((value) => {
|
|
15
15
|
match(value)
|
|
@@ -20,12 +20,12 @@ export const BooleanFieldRadio = ({ error, label, name, options, setValue, value
|
|
|
20
20
|
}, [match, setValue]);
|
|
21
21
|
return (React.createElement(FieldGroup, null,
|
|
22
22
|
React.createElement(Label, null, label),
|
|
23
|
-
React.createElement(RadioGroup, { name: name, value: stringifyBoolean(value), onValueChange: handleValueChange },
|
|
23
|
+
React.createElement(RadioGroup, { disabled: readOnly, name: name, value: stringifyBoolean(value), onValueChange: handleValueChange },
|
|
24
24
|
React.createElement(FieldGroup.Row, null,
|
|
25
25
|
React.createElement(RadioGroup.Item, { id: `${name}-true`, value: "true" }),
|
|
26
|
-
React.createElement(Label, { className: "font-normal text-muted-foreground", htmlFor: `${name}-true` }, options?.true ?? t('form.radioLabels.true'))),
|
|
26
|
+
React.createElement(Label, { "aria-disabled": readOnly, className: "font-normal text-muted-foreground", htmlFor: `${name}-true` }, options?.true ?? t('form.radioLabels.true'))),
|
|
27
27
|
React.createElement(FieldGroup.Row, null,
|
|
28
28
|
React.createElement(RadioGroup.Item, { id: `${name}-false`, value: "false" }),
|
|
29
|
-
React.createElement(Label, { className: "font-normal text-muted-foreground", htmlFor: `${name}-false` }, options?.false ?? t('form.radioLabels.false')))),
|
|
29
|
+
React.createElement(Label, { "aria-disabled": readOnly, className: "font-normal text-muted-foreground", htmlFor: `${name}-false` }, options?.false ?? t('form.radioLabels.false')))),
|
|
30
30
|
React.createElement(FieldGroup.Error, { error: error })));
|
|
31
31
|
};
|
|
@@ -3,5 +3,5 @@ import type { DateFormField } from '@douglasneuroinformatics/libui-form-types';
|
|
|
3
3
|
import type { Simplify } from 'type-fest';
|
|
4
4
|
import { type BaseFieldComponentProps } from '../types.js';
|
|
5
5
|
export type DateFieldProps = Simplify<BaseFieldComponentProps<Date> & Omit<DateFormField, 'kind'>>;
|
|
6
|
-
export declare const DateField: ({ error, label, name, setValue, value }: DateFieldProps) => React.JSX.Element;
|
|
6
|
+
export declare const DateField: ({ error, label, name, readOnly, setValue, value }: DateFieldProps) => React.JSX.Element;
|
|
7
7
|
//# sourceMappingURL=DateField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/DateField/DateField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAO1C,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAI3D,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnG,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/DateField/DateField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAO1C,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAI3D,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnG,eAAO,MAAM,SAAS,sDAAuD,cAAc,sBAmD1F,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { Popover } from '../../Popover/Popover.js';
|
|
|
7
7
|
import { FieldGroup } from '../FieldGroup/FieldGroup.js';
|
|
8
8
|
import {} from '../types.js';
|
|
9
9
|
const isValidDateString = (s) => /^(\d{4})-((0[1-9])|(1[0-2]))-((0[1-9])|([12])[0-9]|3[01])$/.test(s);
|
|
10
|
-
export const DateField = ({ error, label, name, setValue, value }) => {
|
|
10
|
+
export const DateField = ({ error, label, name, readOnly, setValue, value }) => {
|
|
11
11
|
const [isDatePickerOpen, setIsDatePickerOpen] = useState(false);
|
|
12
12
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
13
13
|
const [inputValue, setInputValue] = useState('');
|
|
@@ -30,7 +30,7 @@ export const DateField = ({ error, label, name, setValue, value }) => {
|
|
|
30
30
|
React.createElement(Label, { htmlFor: name }, label),
|
|
31
31
|
React.createElement(Popover, { open: isDatePickerOpen, onOpenChange: setIsDatePickerOpen },
|
|
32
32
|
React.createElement(Popover.Trigger, null,
|
|
33
|
-
React.createElement(Input, { autoComplete: "off", "data-cy": "date-input", "data-testid": "date-input", name: name, placeholder: "YYYY-MM-DD", type: "text", value: inputValue, onBlur: () => setIsInputFocused(false), onChange: (event) => setInputValue(event.target.value), onFocus: () => setIsInputFocused(true) })),
|
|
33
|
+
React.createElement(Input, { autoComplete: "off", "data-cy": "date-input", "data-testid": "date-input", disabled: readOnly, name: name, placeholder: "YYYY-MM-DD", type: "text", value: inputValue, onBlur: () => setIsInputFocused(false), onChange: (event) => setInputValue(event.target.value), onFocus: () => setIsInputFocused(true) })),
|
|
34
34
|
React.createElement(Popover.Content, { asChild: true, align: "start", autofocus: false, className: "w-auto" },
|
|
35
35
|
React.createElement(DatePicker, { onSelection: (value) => {
|
|
36
36
|
setInputValue(toBasicISOString(value));
|
|
@@ -5,9 +5,10 @@ export type DynamicFieldProps<TData extends FormDataType> = {
|
|
|
5
5
|
errors: FormErrors<TData>;
|
|
6
6
|
field: DynamicFormField<TData>;
|
|
7
7
|
name: string;
|
|
8
|
+
readOnly?: boolean;
|
|
8
9
|
setErrors: React.Dispatch<React.SetStateAction<FormErrors<TData>>>;
|
|
9
10
|
setValues: React.Dispatch<React.SetStateAction<PartialFormDataType<TData>>>;
|
|
10
11
|
values: PartialFormDataType<TData>;
|
|
11
12
|
};
|
|
12
|
-
export declare const DynamicField: <TData extends FormDataType>({ field, name, setValues, values, ...props }: DynamicFieldProps<TData>) => React.JSX.Element | null;
|
|
13
|
+
export declare const DynamicField: <TData extends FormDataType>({ field, name, readOnly, setValues, values, ...props }: DynamicFieldProps<TData>) => React.JSX.Element | null;
|
|
13
14
|
//# sourceMappingURL=DynamicField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicField.d.ts","sourceRoot":"","sources":["../../../src/components/Form/DynamicField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAKrH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,YAAY,IAAI;IAC1D,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnE,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5E,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"DynamicField.d.ts","sourceRoot":"","sources":["../../../src/components/Form/DynamicField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAKrH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,YAAY,IAAI;IAC1D,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnE,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5E,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,YAAY,uFAOtB,kBAAkB,KAAK,CAAC,6BA6B1B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { pick } from 'lodash-es';
|
|
3
3
|
import { StaticField } from './StaticField.js';
|
|
4
|
-
export const DynamicField = ({ field, name, setValues, values, ...props }) => {
|
|
4
|
+
export const DynamicField = ({ field, name, readOnly, setValues, values, ...props }) => {
|
|
5
5
|
const [dependentValues, setDependentValues] = useState(pick(values, field.deps));
|
|
6
6
|
const staticField = useMemo(() => {
|
|
7
7
|
return field.render.call(undefined, values);
|
|
@@ -22,5 +22,5 @@ export const DynamicField = ({ field, name, setValues, values, ...props }) => {
|
|
|
22
22
|
if (!staticField) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
return React.createElement(StaticField, { ...props, field: staticField, name: name, setValues: setValues, values: values });
|
|
25
|
+
return (React.createElement(StaticField, { ...props, field: staticField, name: name, readOnly: readOnly, setValues: setValues, values: values }));
|
|
26
26
|
};
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { CircleHelpIcon } from 'lucide-react';
|
|
3
3
|
import { Popover } from '../../Popover/Popover.js';
|
|
4
4
|
export const FieldGroupDescription = ({ description }) => description ? (React.createElement(Popover, null,
|
|
5
|
-
React.createElement(Popover.Trigger,
|
|
5
|
+
React.createElement(Popover.Trigger, { tabIndex: -1 },
|
|
6
6
|
React.createElement(CircleHelpIcon, { className: "text-muted-foreground" })),
|
|
7
7
|
React.createElement(Popover.Content, { className: "text-sm text-muted-foreground" },
|
|
8
8
|
React.createElement("p", null, description)))) : null;
|
|
@@ -4,6 +4,7 @@ import type { FormErrors } from './types.js';
|
|
|
4
4
|
export type FieldsComponentProps<T extends FormDataType> = {
|
|
5
5
|
errors: FormErrors<T>;
|
|
6
6
|
fields: FormFields<T>;
|
|
7
|
+
readOnly?: boolean;
|
|
7
8
|
setErrors: React.Dispatch<React.SetStateAction<FormErrors<T>>>;
|
|
8
9
|
setValues: React.Dispatch<React.SetStateAction<PartialFormDataType<T>>>;
|
|
9
10
|
values: PartialFormDataType<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldsComponent.d.ts","sourceRoot":"","sources":["../../../src/components/Form/FieldsComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAK/G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,YAAY,IAAI;IACzD,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACtB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;CAChC,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,eAAe,iDAAkD,qBAAqB,CAAC,CAAC,wBAQpG,CAAC"}
|
|
1
|
+
{"version":3,"file":"FieldsComponent.d.ts","sourceRoot":"","sources":["../../../src/components/Form/FieldsComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAK/G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,YAAY,IAAI;IACzD,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;CAChC,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,eAAe,iDAAkD,qBAAqB,CAAC,CAAC,wBAQpG,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { FormContent, FormDataType, PartialNullableFormDataType } from '@douglasneuroinformatics/libui-form-types';
|
|
3
|
+
import type { Promisable } from 'type-fest';
|
|
3
4
|
import { z } from 'zod';
|
|
4
5
|
type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<TSchema> = z.TypeOf<TSchema>> = {
|
|
5
6
|
[key: `data-${string}`]: unknown;
|
|
@@ -8,12 +9,14 @@ type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<T
|
|
|
8
9
|
id?: string;
|
|
9
10
|
initialValues?: PartialNullableFormDataType<TData>;
|
|
10
11
|
onError?: (error: z.ZodError<TData>) => void;
|
|
11
|
-
onSubmit: (data: TData) => void
|
|
12
|
+
onSubmit: (data: TData) => Promisable<void>;
|
|
12
13
|
preventResetValuesOnReset?: boolean;
|
|
14
|
+
readOnly?: boolean;
|
|
13
15
|
resetBtn?: boolean;
|
|
16
|
+
revalidateOnBlur?: boolean;
|
|
14
17
|
submitBtnLabel?: string;
|
|
15
18
|
validationSchema: z.ZodType<TData>;
|
|
16
19
|
};
|
|
17
|
-
declare const Form: <TSchema extends z.ZodType<FormDataType, z.ZodTypeDef, FormDataType>, TData extends z.TypeOf<TSchema> = z.TypeOf<TSchema>>({ className, content, id, initialValues, onError, onSubmit, preventResetValuesOnReset, resetBtn, submitBtnLabel, validationSchema, ...props }: FormProps<TSchema, TData>) => React.JSX.Element;
|
|
20
|
+
declare const Form: <TSchema extends z.ZodType<FormDataType, z.ZodTypeDef, FormDataType>, TData extends z.TypeOf<TSchema> = z.TypeOf<TSchema>>({ className, content, id, initialValues, onError, onSubmit, preventResetValuesOnReset, readOnly, resetBtn, revalidateOnBlur, submitBtnLabel, validationSchema, ...props }: FormProps<TSchema, TData>) => React.JSX.Element;
|
|
18
21
|
export { Form, type FormProps };
|
|
19
22
|
//# sourceMappingURL=Form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAGZ,2BAA2B,EAC5B,MAAM,2CAA2C,CAAC;AAInD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,KAAK,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI;IAC7G,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,2BAA2B,CAAC,KAAK,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC7C,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,UAAU,CAAC,IAAI,CAAC,CAAC;IAC5C,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;CACpC,CAAC;AAEF,QAAA,MAAM,IAAI,wSAcP,UAAU,OAAO,EAAE,KAAK,CAAC,sBAqI3B,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { set } from 'lodash-es';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -8,8 +8,8 @@ import { Heading } from '../Heading/Heading.js';
|
|
|
8
8
|
import { ErrorMessage } from './ErrorMessage.js';
|
|
9
9
|
import { FieldsComponent } from './FieldsComponent.js';
|
|
10
10
|
import { getInitialValues } from './utils.js';
|
|
11
|
-
const Form = ({ className, content, id, initialValues, onError, onSubmit, preventResetValuesOnReset, resetBtn, submitBtnLabel, validationSchema, ...props }) => {
|
|
12
|
-
const { t } = useTranslation('libui');
|
|
11
|
+
const Form = ({ className, content, id, initialValues, onError, onSubmit, preventResetValuesOnReset, readOnly, resetBtn, revalidateOnBlur, submitBtnLabel, validationSchema, ...props }) => {
|
|
12
|
+
const { i18n, t } = useTranslation('libui');
|
|
13
13
|
const [rootError, setRootError] = useState(null);
|
|
14
14
|
const [errors, setErrors] = useState({});
|
|
15
15
|
const [values, setValues] = useState(initialValues ? getInitialValues(initialValues) : {});
|
|
@@ -37,12 +37,12 @@ const Form = ({ className, content, id, initialValues, onError, onSubmit, preven
|
|
|
37
37
|
setValues({});
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
const handleSubmit = (event) => {
|
|
40
|
+
const handleSubmit = async (event) => {
|
|
41
41
|
event.preventDefault();
|
|
42
|
-
const result = validationSchema.
|
|
42
|
+
const result = await validationSchema.safeParseAsync(values);
|
|
43
43
|
if (result.success) {
|
|
44
44
|
reset();
|
|
45
|
-
onSubmit(result.data);
|
|
45
|
+
await onSubmit(result.data);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
console.error(result.error.issues);
|
|
@@ -50,17 +50,33 @@ const Form = ({ className, content, id, initialValues, onError, onSubmit, preven
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
const isGrouped = Array.isArray(content);
|
|
53
|
-
|
|
53
|
+
const revalidate = () => {
|
|
54
|
+
const hasErrors = Object.keys(errors).length > 0;
|
|
55
|
+
if (hasErrors) {
|
|
56
|
+
validationSchema
|
|
57
|
+
.safeParseAsync(values)
|
|
58
|
+
.then((result) => {
|
|
59
|
+
if (!result.success) {
|
|
60
|
+
handleError(result.error);
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
.catch(console.error);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
revalidate();
|
|
68
|
+
}, [i18n.resolvedLanguage]);
|
|
69
|
+
return (React.createElement("form", { autoComplete: "off", className: twMerge('w-full', isGrouped ? 'space-y-8 divide-y' : 'space-y-6', className), id: id, onBlur: revalidateOnBlur ? revalidate : undefined, onSubmit: (event) => void handleSubmit(event), ...props },
|
|
54
70
|
isGrouped ? (content.map((fieldGroup, i) => {
|
|
55
71
|
return (React.createElement("div", { className: "space-y-6 [&:not(:first-child)]:pt-8", key: i },
|
|
56
72
|
React.createElement("div", { className: "space-y-1" },
|
|
57
|
-
fieldGroup.title && React.createElement(Heading, { variant: "h4" }, fieldGroup.title),
|
|
73
|
+
fieldGroup.title && React.createElement(Heading, { className: "text-base", variant: "h4" }, fieldGroup.title),
|
|
58
74
|
fieldGroup.description && (React.createElement("p", { className: "text-sm italic leading-tight text-muted-foreground" }, fieldGroup.description))),
|
|
59
|
-
React.createElement(FieldsComponent, { errors: errors, fields: fieldGroup.fields, setErrors: setErrors, setValues: setValues, values: values })));
|
|
60
|
-
})) : (React.createElement(FieldsComponent, { errors: errors, fields: content, setErrors: setErrors, setValues: setValues, values: values })),
|
|
75
|
+
React.createElement(FieldsComponent, { errors: errors, fields: fieldGroup.fields, readOnly: readOnly, setErrors: setErrors, setValues: setValues, values: values })));
|
|
76
|
+
})) : (React.createElement(FieldsComponent, { errors: errors, fields: content, readOnly: readOnly, setErrors: setErrors, setValues: setValues, values: values })),
|
|
61
77
|
React.createElement("div", { className: "flex w-full gap-3" },
|
|
62
|
-
React.createElement(Button, { "aria-label": "Submit Button", className: "block w-full", "data-cy": "submit-form", type: "submit", variant: "primary" }, submitBtnLabel ?? t('form.submit')),
|
|
63
|
-
resetBtn && (React.createElement(Button, { "aria-label": "Reset Button", className: "block w-full", type: "button", variant: "secondary", onClick: reset }, t('form.reset')))),
|
|
78
|
+
React.createElement(Button, { "aria-label": "Submit Button", className: "block w-full", "data-cy": "submit-form", disabled: readOnly, type: "submit", variant: "primary" }, submitBtnLabel ?? t('form.submit')),
|
|
79
|
+
resetBtn && (React.createElement(Button, { "aria-label": "Reset Button", className: "block w-full", disabled: readOnly, type: "button", variant: "secondary", onClick: reset }, t('form.reset')))),
|
|
64
80
|
rootError && React.createElement(ErrorMessage, { error: rootError })));
|
|
65
81
|
};
|
|
66
82
|
export { Form };
|
|
@@ -5,5 +5,5 @@ import type { BaseFieldComponentProps } from '../types.js';
|
|
|
5
5
|
export type NumberFieldInputProps = Simplify<BaseFieldComponentProps<number> & Extract<NumberFormField, {
|
|
6
6
|
variant: 'input';
|
|
7
7
|
}>>;
|
|
8
|
-
export declare const NumberFieldInput: ({ description, error, label, max, min, name, setValue, value }: NumberFieldInputProps) => React.JSX.Element;
|
|
8
|
+
export declare const NumberFieldInput: ({ description, error, label, max, min, name, readOnly, setValue, value }: NumberFieldInputProps) => React.JSX.Element;
|
|
9
9
|
//# sourceMappingURL=NumberFieldInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberFieldInput.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/NumberField/NumberFieldInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAC1C,uBAAuB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CACjF,CAAC;AAEF,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"NumberFieldInput.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/NumberField/NumberFieldInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAC1C,uBAAuB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CACjF,CAAC;AAEF,eAAO,MAAM,gBAAgB,6EAU1B,qBAAqB,sBA2BvB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Input } from '../../Input/Input.js';
|
|
3
3
|
import { Label } from '../../Label/Label.js';
|
|
4
4
|
import { FieldGroup } from '../FieldGroup/FieldGroup.js';
|
|
5
|
-
export const NumberFieldInput = ({ description, error, label, max, min, name, setValue, value }) => {
|
|
5
|
+
export const NumberFieldInput = ({ description, error, label, max, min, name, readOnly, setValue, value }) => {
|
|
6
6
|
const handleChange = (event) => {
|
|
7
7
|
const newValue = parseFloat(event.target.value);
|
|
8
8
|
if (Number.isNaN(newValue)) {
|
|
@@ -16,6 +16,6 @@ export const NumberFieldInput = ({ description, error, label, max, min, name, se
|
|
|
16
16
|
React.createElement(FieldGroup.Row, null,
|
|
17
17
|
React.createElement(Label, null, label),
|
|
18
18
|
React.createElement(FieldGroup.Description, { description: description })),
|
|
19
|
-
React.createElement(Input, { max: max, min: min, name: name, type: "text", value: value ?? '', onChange: handleChange }),
|
|
19
|
+
React.createElement(Input, { disabled: readOnly, max: max, min: min, name: name, type: "text", value: value ?? '', onChange: handleChange }),
|
|
20
20
|
React.createElement(FieldGroup.Error, { error: error })));
|
|
21
21
|
};
|
|
@@ -5,5 +5,5 @@ import type { BaseFieldComponentProps } from '../types.js';
|
|
|
5
5
|
export type NumberFieldRadioProps = Simplify<BaseFieldComponentProps<number> & Extract<NumberFormField, {
|
|
6
6
|
options: object;
|
|
7
7
|
}>>;
|
|
8
|
-
export declare const NumberFieldRadio: ({ description, error, label, name, options, setValue, value }: NumberFieldRadioProps) => React.JSX.Element;
|
|
8
|
+
export declare const NumberFieldRadio: ({ description, error, label, name, options, readOnly, setValue, value }: NumberFieldRadioProps) => React.JSX.Element;
|
|
9
9
|
//# sourceMappingURL=NumberFieldRadio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberFieldRadio.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/NumberField/NumberFieldRadio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAO1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAC1C,uBAAuB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAChF,CAAC;AAEF,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"NumberFieldRadio.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/NumberField/NumberFieldRadio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAO1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAC1C,uBAAuB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAChF,CAAC;AAEF,eAAO,MAAM,gBAAgB,4EAS1B,qBAAqB,sBAiCvB,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { cn } from '../../../utils.js';
|
|
|
3
3
|
import { Label } from '../../Label/Label.js';
|
|
4
4
|
import { RadioGroup } from '../../RadioGroup/RadioGroup.js';
|
|
5
5
|
import { FieldGroup } from '../FieldGroup/FieldGroup.js';
|
|
6
|
-
export const NumberFieldRadio = ({ description, error, label, name, options, setValue, value }) => {
|
|
6
|
+
export const NumberFieldRadio = ({ description, error, label, name, options, readOnly, setValue, value }) => {
|
|
7
7
|
const optionsCount = Object.keys(options).length;
|
|
8
8
|
return (React.createElement(FieldGroup, null,
|
|
9
9
|
React.createElement(FieldGroup.Row, null,
|
|
@@ -13,7 +13,7 @@ export const NumberFieldRadio = ({ description, error, label, name, options, set
|
|
|
13
13
|
.map((val) => parseInt(val))
|
|
14
14
|
.toSorted((a, b) => a - b)
|
|
15
15
|
.map((val) => (React.createElement("div", { className: "flex items-center gap-2", key: val },
|
|
16
|
-
React.createElement(RadioGroup.Item, { id: `${name}-${val}`, value: val.toString() }),
|
|
17
|
-
React.createElement(Label, { className: "font-normal text-muted-foreground", htmlFor: `${name}-${val}` }, `${val} - ${options[val]}`))))),
|
|
16
|
+
React.createElement(RadioGroup.Item, { disabled: readOnly, id: `${name}-${val}`, value: val.toString() }),
|
|
17
|
+
React.createElement(Label, { "aria-disabled": readOnly, className: "font-normal text-muted-foreground", htmlFor: `${name}-${val}` }, `${val} - ${options[val]}`))))),
|
|
18
18
|
React.createElement(FieldGroup.Error, { error: error })));
|
|
19
19
|
};
|
|
@@ -5,5 +5,5 @@ import { type BaseFieldComponentProps } from '../types.js';
|
|
|
5
5
|
export type NumberFieldSelectProps<T extends number = number> = Simplify<BaseFieldComponentProps<T> & Extract<NumberFormField<T>, {
|
|
6
6
|
options: object;
|
|
7
7
|
}>>;
|
|
8
|
-
export declare const NumberFieldSelect: <T extends number = number>({ description, error, label, name, options, setValue, value }: NumberFieldSelectProps<T>) => React.JSX.Element;
|
|
8
|
+
export declare const NumberFieldSelect: <T extends number = number>({ description, error, label, name, options, readOnly, setValue, value }: NumberFieldSelectProps<T>) => React.JSX.Element;
|
|
9
9
|
//# sourceMappingURL=NumberFieldSelect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberFieldSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/NumberField/NumberFieldSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAK1C,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,CACtE,uBAAuB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAC9E,CAAC;AAEF,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"NumberFieldSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/NumberField/NumberFieldSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAK1C,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,CACtE,uBAAuB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAC9E,CAAC;AAEF,eAAO,MAAM,iBAAiB,uGAS3B,uBAAuB,CAAC,CAAC,sBAuB3B,CAAC"}
|
|
@@ -3,13 +3,13 @@ import { Label } from '../../Label/Label.js';
|
|
|
3
3
|
import { Select } from '../../Select/Select.js';
|
|
4
4
|
import { FieldGroup } from '../FieldGroup/FieldGroup.js';
|
|
5
5
|
import {} from '../types.js';
|
|
6
|
-
export const NumberFieldSelect = ({ description, error, label, name, options, setValue, value }) => {
|
|
6
|
+
export const NumberFieldSelect = ({ description, error, label, name, options, readOnly, setValue, value }) => {
|
|
7
7
|
return (React.createElement(FieldGroup, null,
|
|
8
8
|
React.createElement(FieldGroup.Row, null,
|
|
9
9
|
React.createElement(Label, null, label),
|
|
10
10
|
React.createElement(FieldGroup.Description, { description: description })),
|
|
11
11
|
React.createElement(Select, { name: name, value: value?.toString() ?? '', onValueChange: (value) => setValue(parseFloat(value)) },
|
|
12
|
-
React.createElement(Select.Trigger, { "data-cy": `${name}-select-trigger`, "data-testid": `${name}-select-trigger
|
|
12
|
+
React.createElement(Select.Trigger, { "data-cy": `${name}-select-trigger`, "data-testid": `${name}-select-trigger`, disabled: readOnly },
|
|
13
13
|
React.createElement(Select.Value, null)),
|
|
14
14
|
React.createElement(Select.Content, { "data-cy": `${name}-select-content`, "data-testid": `${name}-select-content` }, Object.keys(options).map((option) => (React.createElement(Select.Item, { key: option, value: option }, `${option} - ${options[option]}`))))),
|
|
15
15
|
React.createElement(FieldGroup.Error, { error: error })));
|
|
@@ -5,5 +5,5 @@ import type { BaseFieldComponentProps } from '../types.js';
|
|
|
5
5
|
export type NumberFieldSliderProps = Simplify<BaseFieldComponentProps<number> & Extract<NumberFormField, {
|
|
6
6
|
variant: 'slider';
|
|
7
7
|
}>>;
|
|
8
|
-
export declare const NumberFieldSlider: ({ description, error, label, max, min, name, setValue, value }: NumberFieldSliderProps) => React.JSX.Element;
|
|
8
|
+
export declare const NumberFieldSlider: ({ description, error, label, max, min, name, readOnly, setValue, value }: NumberFieldSliderProps) => React.JSX.Element;
|
|
9
9
|
//# sourceMappingURL=NumberFieldSlider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberFieldSlider.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/NumberField/NumberFieldSlider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAC3C,uBAAuB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC,CAClF,CAAC;AAEF,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"NumberFieldSlider.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/NumberField/NumberFieldSlider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAC3C,uBAAuB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC,CAClF,CAAC;AAEF,eAAO,MAAM,iBAAiB,6EAU3B,sBAAsB,sBAuBxB,CAAC"}
|
|
@@ -2,13 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { Label } from '../../Label/Label.js';
|
|
3
3
|
import { Slider } from '../../Slider/Slider.js';
|
|
4
4
|
import { FieldGroup } from '../FieldGroup/FieldGroup.js';
|
|
5
|
-
export const NumberFieldSlider = ({ description, error, label, max, min, name, setValue, value }) => {
|
|
5
|
+
export const NumberFieldSlider = ({ description, error, label, max, min, name, readOnly, setValue, value }) => {
|
|
6
6
|
return (React.createElement(FieldGroup, null,
|
|
7
7
|
React.createElement(FieldGroup.Row, null,
|
|
8
8
|
React.createElement(Label, null, label),
|
|
9
9
|
React.createElement(FieldGroup.Description, { description: description })),
|
|
10
10
|
React.createElement(FieldGroup.Row, null,
|
|
11
|
-
React.createElement(Slider, { max: max, min: min, name: name, value: [value ?? 0], onValueChange: ([value]) => setValue(value) }),
|
|
11
|
+
React.createElement(Slider, { disabled: readOnly, max: max, min: min, name: name, value: [value ?? 0], onValueChange: ([value]) => setValue(value) }),
|
|
12
12
|
React.createElement("span", { className: "flex h-full w-8 items-center justify-center text-sm text-muted-foreground" }, value ?? 'NA')),
|
|
13
13
|
React.createElement(FieldGroup.Error, { error: error })));
|
|
14
14
|
};
|
|
@@ -3,5 +3,5 @@ import type { NumberRecordFieldValue, NumberRecordFormField, RequiredFieldValue
|
|
|
3
3
|
import type { Simplify } from 'type-fest';
|
|
4
4
|
import type { BaseFieldComponentProps } from './types.js';
|
|
5
5
|
export type NumberRecordFieldProps<T extends NumberRecordFieldValue = NumberRecordFieldValue> = Simplify<BaseFieldComponentProps<NumberRecordFieldValue> & NumberRecordFormField<RequiredFieldValue<T>>>;
|
|
6
|
-
export declare const NumberRecordField: <T extends NumberRecordFieldValue = NumberRecordFieldValue>({ error: recordError, items, label, options, setError: setRecordError, setValue: setRecordValue, value: recordValue }: NumberRecordFieldProps<T>) => React.JSX.Element | null;
|
|
6
|
+
export declare const NumberRecordField: <T extends NumberRecordFieldValue = NumberRecordFieldValue>({ error: recordError, items, label, options, readOnly, setError: setRecordError, setValue: setRecordValue, value: recordValue }: NumberRecordFieldProps<T>) => React.JSX.Element | null;
|
|
7
7
|
//# sourceMappingURL=NumberRecordField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberRecordField.d.ts","sourceRoot":"","sources":["../../../src/components/Form/NumberRecordField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAK1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,sBAAsB,GAAG,sBAAsB,IAAI,QAAQ,CACtG,uBAAuB,CAAC,sBAAsB,CAAC,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAC/F,CAAC;AAEF,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"NumberRecordField.d.ts","sourceRoot":"","sources":["../../../src/components/Form/NumberRecordField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAK1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,sBAAsB,GAAG,sBAAsB,IAAI,QAAQ,CACtG,uBAAuB,CAAC,sBAAsB,CAAC,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAC/F,CAAC;AAEF,eAAO,MAAM,iBAAiB,+LAS3B,uBAAuB,CAAC,CAAC,6BAoC3B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { Heading } from '../Heading/Heading.js';
|
|
3
3
|
import { NumberField } from './NumberField/NumberField.js';
|
|
4
|
-
export const NumberRecordField = ({ error: recordError, items, label, options, setError: setRecordError, setValue: setRecordValue, value: recordValue }) => {
|
|
4
|
+
export const NumberRecordField = ({ error: recordError, items, label, options, readOnly, setError: setRecordError, setValue: setRecordValue, value: recordValue }) => {
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
setRecordValue({});
|
|
7
7
|
}, [options]);
|
|
@@ -9,9 +9,9 @@ export const NumberRecordField = ({ error: recordError, items, label, options, s
|
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
return (React.createElement("div", { className: "space-y-4" },
|
|
12
|
-
React.createElement(Heading, { variant: "h5" }, label),
|
|
12
|
+
React.createElement(Heading, { className: "font-medium", variant: "h5" }, label),
|
|
13
13
|
React.createElement("div", { className: "space-y-6" }, Object.keys(items).map((name) => {
|
|
14
14
|
const item = items[name];
|
|
15
|
-
return (React.createElement(NumberField, { error: recordError?.[name], key: name, kind: "number", name: name, options: options, setError: (error) => setRecordError({ ...recordError, [name]: error }), setValue: (value) => setRecordValue({ ...recordValue, [name]: value }), value: recordValue?.[name], variant: "radio", ...item }));
|
|
15
|
+
return (React.createElement(NumberField, { error: recordError?.[name], key: name, kind: "number", name: name, options: options, readOnly: readOnly, setError: (error) => setRecordError({ ...recordError, [name]: error }), setValue: (value) => setRecordValue({ ...recordValue, [name]: value }), value: recordValue?.[name], variant: "radio", ...item }));
|
|
16
16
|
}))));
|
|
17
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordArrayField.d.ts","sourceRoot":"","sources":["../../../src/components/Form/RecordArrayField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAG7G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAO1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,GAAG,oBAAoB,CAAC,CAAC;AAEpH,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"RecordArrayField.d.ts","sourceRoot":"","sources":["../../../src/components/Form/RecordArrayField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAG7G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAO1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,GAAG,oBAAoB,CAAC,CAAC;AAEpH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;EAsF3B,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { Button } from '../Button/Button.js';
|
|
|
5
5
|
import { Heading } from '../Heading/Heading.js';
|
|
6
6
|
import { Label } from '../Label/Label.js';
|
|
7
7
|
import { ScalarField } from './ScalarField.js';
|
|
8
|
-
export const RecordArrayField = memo(function RecordArrayField({ error: arrayError, fieldset, label, setError: setArrayError, setValue: setArrayValue, value: arrayValue }) {
|
|
8
|
+
export const RecordArrayField = memo(function RecordArrayField({ error: arrayError, fieldset, label, readOnly, setError: setArrayError, setValue: setArrayValue, value: arrayValue }) {
|
|
9
9
|
const { t } = useTranslation('libui');
|
|
10
10
|
const createNewRecord = () => Object.fromEntries(Object.keys(fieldset).map((fieldName) => [fieldName, undefined]));
|
|
11
11
|
useEffect(() => {
|
|
@@ -24,7 +24,7 @@ export const RecordArrayField = memo(function RecordArrayField({ error: arrayErr
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
return (React.createElement("div", { className: "space-y-4" },
|
|
27
|
-
React.createElement(Heading, { variant: "h5" }, label),
|
|
27
|
+
React.createElement(Heading, { className: "font-medium", variant: "h5" }, label),
|
|
28
28
|
React.createElement("div", { className: "space-y-6" }, arrayValue.map((fields, i) => (React.createElement("div", { className: "space-y-4", key: i },
|
|
29
29
|
React.createElement(Label, { className: "font-semibold italic" }, label + ' ' + (i + 1)),
|
|
30
30
|
Object.keys(fields).map((name) => {
|
|
@@ -33,7 +33,7 @@ export const RecordArrayField = memo(function RecordArrayField({ error: arrayErr
|
|
|
33
33
|
if (!fieldProps) {
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
|
-
return (React.createElement(ScalarField, { error: arrayError?.[i]?.[name], field: fieldProps, key: name, name: name, setError: (error) => {
|
|
36
|
+
return (React.createElement(ScalarField, { error: arrayError?.[i]?.[name], field: fieldProps, key: name, name: name, readOnly: readOnly, setError: (error) => {
|
|
37
37
|
const newArrayError = arrayError ? [...arrayError] : [];
|
|
38
38
|
if (!newArrayError[i]) {
|
|
39
39
|
newArrayError[i] = {};
|
|
@@ -47,10 +47,10 @@ export const RecordArrayField = memo(function RecordArrayField({ error: arrayErr
|
|
|
47
47
|
}, value: arrayValue?.[i]?.[name] }));
|
|
48
48
|
}))))),
|
|
49
49
|
React.createElement("div", { className: "flex gap-3" },
|
|
50
|
-
React.createElement(Button, { type: "button", variant: "outline", onClick: appendField },
|
|
50
|
+
React.createElement(Button, { disabled: readOnly, type: "button", variant: "outline", onClick: appendField },
|
|
51
51
|
t('form.append'),
|
|
52
52
|
React.createElement(PlusCircleIcon, { className: "ml-2" })),
|
|
53
|
-
React.createElement(Button, { type: "button", variant: "outline", onClick: removeField },
|
|
53
|
+
React.createElement(Button, { disabled: readOnly, type: "button", variant: "outline", onClick: removeField },
|
|
54
54
|
t('form.remove'),
|
|
55
55
|
React.createElement(MinusCircleIcon, { className: "ml-2" })))));
|
|
56
56
|
});
|
|
@@ -3,5 +3,5 @@ import type { SetFieldProps } from './SetField.js';
|
|
|
3
3
|
export type SetFieldListboxProps<T extends string = string> = {
|
|
4
4
|
onCheckedChange: (option: T, isChecked: boolean) => void;
|
|
5
5
|
} & SetFieldProps<T>;
|
|
6
|
-
export declare const SetFieldListbox: <T extends string = string>({ description, error, label, name, onCheckedChange, options, value }: SetFieldListboxProps<T>) => React.JSX.Element;
|
|
6
|
+
export declare const SetFieldListbox: <T extends string = string>({ description, error, label, name, onCheckedChange, options, readOnly, value }: SetFieldListboxProps<T>) => React.JSX.Element;
|
|
7
7
|
//# sourceMappingURL=SetFieldListbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetFieldListbox.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/SetField/SetFieldListbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAC5D,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1D,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAErB,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"SetFieldListbox.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/SetField/SetFieldListbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAC5D,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1D,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAErB,eAAO,MAAM,eAAe,8GASzB,qBAAqB,CAAC,CAAC,sBA2BzB,CAAC"}
|
|
@@ -2,13 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { Checkbox } from '../../Checkbox/Checkbox.js';
|
|
3
3
|
import { Label } from '../../Label/Label.js';
|
|
4
4
|
import { FieldGroup } from '../FieldGroup/FieldGroup.js';
|
|
5
|
-
export const SetFieldListbox = ({ description, error, label, name, onCheckedChange, options, value }) => {
|
|
5
|
+
export const SetFieldListbox = ({ description, error, label, name, onCheckedChange, options, readOnly, value }) => {
|
|
6
6
|
return (React.createElement(FieldGroup, null,
|
|
7
7
|
React.createElement(FieldGroup.Row, null,
|
|
8
8
|
React.createElement(Label, null, label),
|
|
9
9
|
React.createElement(FieldGroup.Description, { description: description })),
|
|
10
10
|
React.createElement("div", { className: "grid gap-2" }, Object.keys(options).map((option) => (React.createElement(FieldGroup.Row, { key: option },
|
|
11
|
-
React.createElement(Checkbox, { checked: value?.has(option) ?? false, id: `${name}-${option}`, onCheckedChange: (checked) => {
|
|
11
|
+
React.createElement(Checkbox, { checked: value?.has(option) ?? false, disabled: readOnly, id: `${name}-${option}`, onCheckedChange: (checked) => {
|
|
12
12
|
onCheckedChange(option, !checked);
|
|
13
13
|
} }),
|
|
14
14
|
React.createElement(Label, { className: "font-normal text-muted-foreground", htmlFor: `${name}-${option}` }, options[option]))))),
|
|
@@ -3,5 +3,5 @@ import type { SetFieldProps } from './SetField.js';
|
|
|
3
3
|
export type SetFieldSelectProps<T extends string = string> = {
|
|
4
4
|
onCheckedChange: (option: T, isChecked: boolean) => void;
|
|
5
5
|
} & SetFieldProps<T>;
|
|
6
|
-
export declare const SetFieldSelect: <T extends string = string>({ description, error, label, onCheckedChange, options, value }: SetFieldSelectProps<T>) => React.JSX.Element | null;
|
|
6
|
+
export declare const SetFieldSelect: <T extends string = string>({ description, error, label, onCheckedChange, options, readOnly, value }: SetFieldSelectProps<T>) => React.JSX.Element | null;
|
|
7
7
|
//# sourceMappingURL=SetFieldSelect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetFieldSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/SetField/SetFieldSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAC3D,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1D,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAErB,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"SetFieldSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/SetField/SetFieldSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAC3D,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1D,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAErB,eAAO,MAAM,cAAc,wGAQxB,oBAAoB,CAAC,CAAC,6BA0CxB,CAAC"}
|