@uxf/form 1.0.0-beta.159 → 1.0.0-beta.161
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/avatar-file-input/avatar-file-input.js +6 -3
- package/avatar-file-input/avatar-file-input.stories.js +2 -2
- package/checkbox-button/checkbox-button.js +6 -3
- package/checkbox-button/checkbox-button.stories.js +2 -2
- package/checkbox-input/checkbox-input.js +6 -3
- package/checkbox-input/checkbox-input.stories.js +2 -2
- package/color-radio-group/color-radio-group.js +6 -3
- package/color-radio-group/color-radio-group.stories.js +2 -2
- package/combobox/combobox.js +6 -3
- package/combobox/combobox.stories.js +2 -2
- package/date-picker-input/date-picker-input.js +8 -5
- package/date-picker-input/date-picker-input.stories.js +2 -2
- package/dropzone/dropzone-input.js +7 -4
- package/dropzone/dropzone.stories.js +2 -2
- package/file-input/file-input.js +6 -3
- package/file-input/file-input.stories.js +2 -2
- package/form/form.d.ts +9 -12
- package/form/form.js +9 -39
- package/form/form.stories.js +10 -7
- package/form-id-context/form-id-context.d.ts +3 -0
- package/form-id-context/form-id-context.js +8 -0
- package/form-id-context/index.d.ts +1 -0
- package/form-id-context/index.js +17 -0
- package/gps-input/gps-input.js +7 -4
- package/gps-input/gps-input.stories.js +2 -2
- package/multi-combobox/multi-combobox.js +6 -3
- package/multi-combobox/multi-combobox.stories.js +2 -2
- package/multi-select/multi-select.js +6 -3
- package/multi-select/multi-select.stories.js +2 -2
- package/number-input/number-input.js +6 -3
- package/number-input/number-input.stories.js +2 -2
- package/package.json +2 -2
- package/radio-group/radio-group.js +6 -3
- package/radio-group/radio-group.stories.js +2 -2
- package/select/select.js +6 -3
- package/select/select.stories.js +2 -2
- package/storybook/{form.d.ts → storybook-form.d.ts} +1 -1
- package/storybook/{form.js → storybook-form.js} +5 -4
- package/text-input/text-input.js +8 -5
- package/text-input/text-input.stories.js +2 -2
- package/textarea/textarea.js +6 -3
- package/textarea/textarea.stories.js +2 -2
- package/time-picker-input/time-picker-input.js +8 -5
- package/time-picker-input/time-picker-input.stories.js +2 -2
- package/toggle/toggle.js +6 -3
- package/toggle/toggle.stories.js +2 -2
package/gps-input/gps-input.js
CHANGED
|
@@ -32,6 +32,7 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
32
32
|
const react_1 = __importStar(require("react"));
|
|
33
33
|
const coordinate_parser_1 = __importDefault(require("coordinate-parser"));
|
|
34
34
|
const tooltip_1 = require("@uxf/ui/tooltip");
|
|
35
|
+
const form_id_context_1 = require("../form-id-context");
|
|
35
36
|
const SUPPORTED_FORMATS = (react_1.default.createElement("div", null,
|
|
36
37
|
"40.123, -74.123",
|
|
37
38
|
react_1.default.createElement("br", null),
|
|
@@ -85,7 +86,9 @@ const SUPPORTED_FORMATS_TOOLTIP = (react_1.default.createElement("span", { class
|
|
|
85
86
|
const EMPTY_HELPER_TEXT = "Zadejte souřadnice.";
|
|
86
87
|
const NOT_VALID_HELPER_TEXT = "Souřadnice nejsou validní";
|
|
87
88
|
function GpsInput(props) {
|
|
88
|
-
var _a, _b, _c;
|
|
89
|
+
var _a, _b, _c, _d;
|
|
90
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
91
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
89
92
|
const [visualValue, setVisualValue] = (0, react_1.useState)("");
|
|
90
93
|
const [coordsFormatError, setCoordsFormatError] = (0, react_1.useState)(false);
|
|
91
94
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
@@ -93,9 +96,9 @@ function GpsInput(props) {
|
|
|
93
96
|
defaultValue: props.defaultValue,
|
|
94
97
|
name: props.name,
|
|
95
98
|
rules: {
|
|
96
|
-
...((
|
|
99
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
97
100
|
validate: {
|
|
98
|
-
...((
|
|
101
|
+
...((_d = (_c = props.rules) === null || _c === void 0 ? void 0 : _c.validate) !== null && _d !== void 0 ? _d : {}),
|
|
99
102
|
req: (value) => {
|
|
100
103
|
var _a;
|
|
101
104
|
return props.isRequired && value === undefined
|
|
@@ -144,7 +147,7 @@ function GpsInput(props) {
|
|
|
144
147
|
: EMPTY_HELPER_TEXT,
|
|
145
148
|
" ",
|
|
146
149
|
SUPPORTED_FORMATS_TOOLTIP));
|
|
147
|
-
return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, className: props.className, enterKeyHint: props.enterKeyHint, form: props.form, helperText: composedHelperText, hiddenLabel: props.hiddenLabel, id:
|
|
150
|
+
return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, className: props.className, enterKeyHint: props.enterKeyHint, form: props.form, helperText: composedHelperText, hiddenLabel: props.hiddenLabel, id: id, inputMode: props.inputMode, isDisabled: props.isDisabled, isInvalid: (!!fieldState.error && !field.value) || coordsFormatError, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, maxLength: props.maxLength, minLength: props.minLength, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, onKeyDown: props.onKeyDown, placeholder: props.placeholder, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, type: "text", value: visualValue, variant: props.variant }));
|
|
148
151
|
}
|
|
149
152
|
exports.GpsInput = GpsInput;
|
|
150
153
|
GpsInput.displayName = "UxfFormGpsInput";
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Default = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const gps_input_1 = require("./gps-input");
|
|
9
|
-
const
|
|
9
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
10
10
|
const button_1 = require("@uxf/ui/button");
|
|
11
11
|
exports.default = {
|
|
12
12
|
title: "Form/GpsInput",
|
|
@@ -17,7 +17,7 @@ function Default() {
|
|
|
17
17
|
react_1.default.createElement(gps_input_1.GpsInput, { placeholder: "Zadejte sou\u0159adnice...", label: "GPS", name: "gps", control: control }),
|
|
18
18
|
react_1.default.createElement(gps_input_1.GpsInput, { placeholder: "Zadejte sou\u0159adnice...", label: "GPS", name: "gps-required", control: control, isRequired: true }),
|
|
19
19
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
20
|
-
return (react_1.default.createElement(
|
|
20
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
21
21
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormGpsInputs(control)),
|
|
22
22
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormGpsInputs(control))))));
|
|
23
23
|
}
|
|
@@ -7,15 +7,18 @@ exports.MultiCombobox = void 0;
|
|
|
7
7
|
const multi_combobox_1 = require("@uxf/ui/multi-combobox");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
|
+
const form_id_context_1 = require("../form-id-context");
|
|
10
11
|
function MultiCombobox(props) {
|
|
11
|
-
var _a, _b, _c, _d;
|
|
12
|
+
var _a, _b, _c, _d, _e;
|
|
13
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
14
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
12
15
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
13
16
|
control: props.control,
|
|
14
17
|
defaultValue: props.defaultValue,
|
|
15
18
|
name: props.name,
|
|
16
19
|
rules: {
|
|
17
20
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
18
|
-
...((
|
|
21
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
19
22
|
},
|
|
20
23
|
shouldUnregister: props.shouldUnregister,
|
|
21
24
|
});
|
|
@@ -29,7 +32,7 @@ function MultiCombobox(props) {
|
|
|
29
32
|
field.onChange(value);
|
|
30
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
31
34
|
};
|
|
32
|
-
return (react_1.default.createElement(multi_combobox_1.MultiCombobox, { className: props.className, dropdownPlacement: props.dropdownPlacement, helperText: (
|
|
35
|
+
return (react_1.default.createElement(multi_combobox_1.MultiCombobox, { className: props.className, dropdownPlacement: props.dropdownPlacement, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isDisabled: ((_e = props.options) === null || _e === void 0 ? void 0 : _e.length) === 0 || props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, loadOptions: props.loadOptions, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, placeholder: props.placeholder, ref: field.ref, value: field.value, withCheckboxes: props.withCheckboxes }));
|
|
33
36
|
}
|
|
34
37
|
exports.MultiCombobox = MultiCombobox;
|
|
35
38
|
MultiCombobox.displayName = "UxfFormMultiCombobox";
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Default = void 0;
|
|
7
7
|
const button_1 = require("@uxf/ui/button");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const
|
|
9
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
10
10
|
const multi_combobox_1 = require("./multi-combobox");
|
|
11
11
|
exports.default = {
|
|
12
12
|
title: "Form/MultiCombobox",
|
|
@@ -30,7 +30,7 @@ function Default() {
|
|
|
30
30
|
react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, dropdownPlacement: "top", id: "form-combobox", label: "Combobox async", name: "select-dropdown-async", loadOptions: (query) => Promise.resolve(options.filter((option) => !query || option.label.toLowerCase().includes(query.toLowerCase()))), placeholder: "Vyberte..." }),
|
|
31
31
|
react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, dropdownPlacement: "top", id: "form-combobox", label: "Combobox async with default values", name: "select-dropdown-async-default", loadOptions: (query) => Promise.resolve(options.filter((option) => !query || option.label.toLowerCase().includes(query.toLowerCase()))), placeholder: "Vyberte..." }),
|
|
32
32
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
33
|
-
return (react_1.default.createElement(
|
|
33
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, { defaultValues: {
|
|
34
34
|
combobox1: [
|
|
35
35
|
{ id: "one", label: "Option one" },
|
|
36
36
|
{ id: "two", label: "Option two" },
|
|
@@ -7,15 +7,18 @@ exports.MultiSelect = void 0;
|
|
|
7
7
|
const multi_select_1 = require("@uxf/ui/multi-select");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
|
+
const form_id_context_1 = require("../form-id-context");
|
|
10
11
|
function MultiSelect(props) {
|
|
11
|
-
var _a, _b, _c;
|
|
12
|
+
var _a, _b, _c, _d;
|
|
13
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
14
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
12
15
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
13
16
|
control: props.control,
|
|
14
17
|
defaultValue: props.defaultValue,
|
|
15
18
|
name: props.name,
|
|
16
19
|
rules: {
|
|
17
20
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
18
|
-
...((
|
|
21
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
19
22
|
},
|
|
20
23
|
shouldUnregister: props.shouldUnregister,
|
|
21
24
|
});
|
|
@@ -29,7 +32,7 @@ function MultiSelect(props) {
|
|
|
29
32
|
field.onChange(value);
|
|
30
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
31
34
|
};
|
|
32
|
-
return (react_1.default.createElement(multi_select_1.MultiSelect, { className: props.className, dropdownPlacement: props.dropdownPlacement, helperText: (
|
|
35
|
+
return (react_1.default.createElement(multi_select_1.MultiSelect, { className: props.className, dropdownPlacement: props.dropdownPlacement, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isDisabled: props.options.length === 0 || props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, placeholder: props.placeholder, ref: field.ref, value: field.value, withPopover: props.withPopover }));
|
|
33
36
|
}
|
|
34
37
|
exports.MultiSelect = MultiSelect;
|
|
35
38
|
MultiSelect.displayName = "UxfFormMultiSelect";
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Default = void 0;
|
|
7
7
|
const button_1 = require("@uxf/ui/button");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const
|
|
9
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
10
10
|
const multi_select_1 = require("./multi-select");
|
|
11
11
|
exports.default = {
|
|
12
12
|
title: "Form/MultiSelect",
|
|
@@ -25,7 +25,7 @@ function Default() {
|
|
|
25
25
|
react_1.default.createElement(multi_select_1.MultiSelect, { control: control, helperText: "Vyberte pros\u00EDm jednu nebo v\u00EDce mo\u017Enost\u00ED", id: "form-multi-select", label: "MultiSelect form", name: "multi-select", options: options, placeholder: "Vyberte..." }),
|
|
26
26
|
react_1.default.createElement(multi_select_1.MultiSelect, { control: control, id: "form-multi-select", label: "MultiSelect with popover", name: "multi-select-with-popover", options: options, placeholder: "Vyberte...", withPopover: true }),
|
|
27
27
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
28
|
-
return (react_1.default.createElement(
|
|
28
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, { defaultValues: {
|
|
29
29
|
"multi-select": [
|
|
30
30
|
{ id: "one", label: "Option one" },
|
|
31
31
|
{ id: "two", label: "Option two" },
|
|
@@ -7,8 +7,11 @@ exports.NumberInput = void 0;
|
|
|
7
7
|
const text_input_1 = require("@uxf/ui/text-input");
|
|
8
8
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const form_id_context_1 = require("../form-id-context");
|
|
10
11
|
function NumberInput(props) {
|
|
11
|
-
var _a, _b, _c, _d;
|
|
12
|
+
var _a, _b, _c, _d, _e;
|
|
13
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
14
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
12
15
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
13
16
|
control: props.control,
|
|
14
17
|
defaultValue: props.defaultValue,
|
|
@@ -27,7 +30,7 @@ function NumberInput(props) {
|
|
|
27
30
|
}
|
|
28
31
|
: undefined,
|
|
29
32
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
30
|
-
...((
|
|
33
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
31
34
|
},
|
|
32
35
|
shouldUnregister: props.shouldUnregister,
|
|
33
36
|
});
|
|
@@ -48,7 +51,7 @@ function NumberInput(props) {
|
|
|
48
51
|
field.onChange(value);
|
|
49
52
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
50
53
|
};
|
|
51
|
-
return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, className: props.className, enterKeyHint: props.enterKeyHint, form: props.form, helperText: (
|
|
54
|
+
return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, className: props.className, enterKeyHint: props.enterKeyHint, form: props.form, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, hiddenLabel: props.hiddenLabel, id: id, inputMode: props.decimalPlaces ? "decimal" : "numeric", isDisabled: props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, onKeyDown: onKeyDown, pattern: props.pattern, placeholder: props.placeholder, step: props.decimalPlaces ? Number(0).toFixed(props.decimalPlaces - 1) + "1" : props.step, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, type: "number", value: (_e = field.value) !== null && _e !== void 0 ? _e : "", variant: props.variant }));
|
|
52
55
|
}
|
|
53
56
|
exports.NumberInput = NumberInput;
|
|
54
57
|
NumberInput.displayName = "UxfFormNumberInput";
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Default = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const number_input_1 = require("./number-input");
|
|
9
|
-
const
|
|
9
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
10
10
|
const button_1 = require("@uxf/ui/button");
|
|
11
11
|
exports.default = {
|
|
12
12
|
title: "Form/NumberInput",
|
|
@@ -19,7 +19,7 @@ function Default() {
|
|
|
19
19
|
react_1.default.createElement(number_input_1.NumberInput, { label: "Dec\u00EDmal input", name: "decimal", decimalPlaces: 3, control: control }),
|
|
20
20
|
react_1.default.createElement(number_input_1.NumberInput, { label: "max50 input", name: "max50", max: 50, control: control }),
|
|
21
21
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
22
|
-
return (react_1.default.createElement(
|
|
22
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
23
23
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormNumberInputs(control)),
|
|
24
24
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormNumberInputs(control))))));
|
|
25
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/form",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.161",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "UX Fans s.r.o",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@uxf/ui": "^1.0.0-beta.
|
|
16
|
+
"@uxf/ui": "^1.0.0-beta.161",
|
|
17
17
|
"react-hook-form": "^7.43.9",
|
|
18
18
|
"coordinate-parser": "^1.0.7"
|
|
19
19
|
}
|
|
@@ -7,15 +7,18 @@ exports.RadioGroup = void 0;
|
|
|
7
7
|
const radio_group_1 = require("@uxf/ui/radio-group");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
|
+
const form_id_context_1 = require("../form-id-context");
|
|
10
11
|
function RadioGroup(props) {
|
|
11
|
-
var _a, _b, _c, _d;
|
|
12
|
+
var _a, _b, _c, _d, _e;
|
|
13
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
14
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
12
15
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
13
16
|
control: props.control,
|
|
14
17
|
defaultValue: props.defaultValue,
|
|
15
18
|
name: props.name,
|
|
16
19
|
rules: {
|
|
17
20
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
18
|
-
...((
|
|
21
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
19
22
|
},
|
|
20
23
|
shouldUnregister: props.shouldUnregister,
|
|
21
24
|
});
|
|
@@ -29,7 +32,7 @@ function RadioGroup(props) {
|
|
|
29
32
|
field.onChange(value);
|
|
30
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
31
34
|
};
|
|
32
|
-
return (react_1.default.createElement(radio_group_1.RadioGroup, { className: props.className, forceColumn: props.forceColumn, helperText: (
|
|
35
|
+
return (react_1.default.createElement(radio_group_1.RadioGroup, { className: props.className, forceColumn: props.forceColumn, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isDisabled: props.options.length === 0 || props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, ref: field.ref, style: props.style, value: (_e = field.value) !== null && _e !== void 0 ? _e : null, variant: props.variant }));
|
|
33
36
|
}
|
|
34
37
|
exports.RadioGroup = RadioGroup;
|
|
35
38
|
RadioGroup.displayName = "UxfFormRadioGroup";
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Default = void 0;
|
|
7
7
|
const button_1 = require("@uxf/ui/button");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const
|
|
9
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
10
10
|
const index_1 = require("./index");
|
|
11
11
|
exports.default = {
|
|
12
12
|
title: "Form/RadioGroup",
|
|
@@ -33,7 +33,7 @@ function Default() {
|
|
|
33
33
|
react_1.default.createElement(index_1.RadioGroup, { control: control, helperText: "Choose one option", id: "radio-group", label: "Radio group form with helper text", name: "radio-group-helper-text", options: options }),
|
|
34
34
|
react_1.default.createElement(index_1.RadioGroup, { control: control, id: "radio-group", label: "Radio group form with variant button", name: "radio-group-button", options: options, variant: "radioButton" }),
|
|
35
35
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
36
|
-
return (react_1.default.createElement(
|
|
36
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
37
37
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormRadioGroup(control)),
|
|
38
38
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormRadioGroup(control))))));
|
|
39
39
|
}
|
package/select/select.js
CHANGED
|
@@ -7,15 +7,18 @@ exports.Select = void 0;
|
|
|
7
7
|
const select_1 = require("@uxf/ui/select");
|
|
8
8
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const form_id_context_1 = require("../form-id-context");
|
|
10
11
|
function Select(props) {
|
|
11
|
-
var _a, _b, _c;
|
|
12
|
+
var _a, _b, _c, _d;
|
|
13
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
14
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
12
15
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
13
16
|
control: props.control,
|
|
14
17
|
defaultValue: props.defaultValue,
|
|
15
18
|
name: props.name,
|
|
16
19
|
rules: {
|
|
17
20
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
18
|
-
...((
|
|
21
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
19
22
|
},
|
|
20
23
|
shouldUnregister: props.shouldUnregister,
|
|
21
24
|
});
|
|
@@ -29,7 +32,7 @@ function Select(props) {
|
|
|
29
32
|
field.onChange(value);
|
|
30
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
31
34
|
};
|
|
32
|
-
return (react_1.default.createElement(select_1.Select, { className: props.className, dropdownPlacement: props.dropdownPlacement, forwardRef: field.ref, helperText: (
|
|
35
|
+
return (react_1.default.createElement(select_1.Select, { className: props.className, dropdownPlacement: props.dropdownPlacement, forwardRef: field.ref, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isClearable: props.isClearable, isDisabled: props.options.length === 0 || props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, placeholder: props.placeholder, value: field.value }));
|
|
33
36
|
}
|
|
34
37
|
exports.Select = Select;
|
|
35
38
|
Select.displayName = "UxfFormSelect";
|
package/select/select.stories.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Default = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const select_1 = require("./select");
|
|
9
|
-
const
|
|
9
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
10
10
|
const button_1 = require("@uxf/ui/button");
|
|
11
11
|
exports.default = {
|
|
12
12
|
title: "Form/Select",
|
|
@@ -31,7 +31,7 @@ function Default() {
|
|
|
31
31
|
react_1.default.createElement(select_1.Select, { label: "Select form clearable", name: "select-dropdown-clearable", control: control, placeholder: "placeholder", options: options, id: "form-select", isClearable: true }),
|
|
32
32
|
react_1.default.createElement(select_1.Select, { label: "Select form with number options", name: "select-dropdown-number", control: control, placeholder: "placeholder", options: numberOptions, id: "form-select", isClearable: true }),
|
|
33
33
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
34
|
-
return (react_1.default.createElement(
|
|
34
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
35
35
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormSelects(control)),
|
|
36
36
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormSelects(control))))));
|
|
37
37
|
}
|
|
@@ -3,5 +3,5 @@ import { UseFormProps, UseFormReturn } from "react-hook-form";
|
|
|
3
3
|
interface FormProps extends UseFormProps {
|
|
4
4
|
children: (form: UseFormReturn) => ReactNode;
|
|
5
5
|
}
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function StorybookForm(props: FormProps): JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -3,19 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.StorybookForm = void 0;
|
|
7
7
|
const button_1 = require("@uxf/ui/button");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
10
|
const form_data_printer_1 = require("./form-data-printer");
|
|
11
|
-
|
|
11
|
+
const form_1 = require("../form");
|
|
12
|
+
function StorybookForm(props) {
|
|
12
13
|
const form = (0, react_hook_form_1.useForm)(props);
|
|
13
14
|
return (
|
|
14
15
|
// eslint-disable-next-line no-console
|
|
15
|
-
react_1.default.createElement("form",
|
|
16
|
+
react_1.default.createElement(form_1.Form, { formApi: form, id: "storybook-form", onSubmit: console.log },
|
|
16
17
|
props.children(form),
|
|
17
18
|
react_1.default.createElement("div", { className: "my-4" },
|
|
18
19
|
react_1.default.createElement(form_data_printer_1.FormDataPrinter, { control: form.control })),
|
|
19
20
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
20
21
|
}
|
|
21
|
-
exports.
|
|
22
|
+
exports.StorybookForm = StorybookForm;
|
package/text-input/text-input.js
CHANGED
|
@@ -7,10 +7,13 @@ exports.TextInput = void 0;
|
|
|
7
7
|
const text_input_1 = require("@uxf/ui/text-input");
|
|
8
8
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const form_id_context_1 = require("../form-id-context");
|
|
10
11
|
const EMAIL_REGEXP = /^(([^<>()[\]\\.,;:\s@À-ÖÙ-öù-ÿĀ-žḀ-ỿ"]+(\.[^<>()[\]\\.,;:\s@À-ÖÙ-öù-ÿĀ-žḀ-ỿ"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
11
12
|
const PHONE_REGEXP = /^(\+)?[\d\s]*$/;
|
|
12
13
|
function TextInput(props) {
|
|
13
|
-
var _a, _b, _c, _d, _e, _f;
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
15
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
16
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
14
17
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
15
18
|
control: props.control,
|
|
16
19
|
defaultValue: props.defaultValue,
|
|
@@ -20,15 +23,15 @@ function TextInput(props) {
|
|
|
20
23
|
pattern: props.type === "email"
|
|
21
24
|
? {
|
|
22
25
|
value: EMAIL_REGEXP,
|
|
23
|
-
message: (
|
|
26
|
+
message: (_b = props.invalidEmailMessage) !== null && _b !== void 0 ? _b : "E-mail by měl být ve\xa0formátu: info@email.cz",
|
|
24
27
|
}
|
|
25
28
|
: props.type === "tel"
|
|
26
29
|
? {
|
|
27
30
|
value: PHONE_REGEXP,
|
|
28
|
-
message: (
|
|
31
|
+
message: (_c = props.invalidPhoneMessage) !== null && _c !== void 0 ? _c : "Zadaný telefon není ve správném formátu",
|
|
29
32
|
}
|
|
30
33
|
: undefined,
|
|
31
|
-
...((
|
|
34
|
+
...((_d = props.rules) !== null && _d !== void 0 ? _d : {}),
|
|
32
35
|
},
|
|
33
36
|
shouldUnregister: props.shouldUnregister,
|
|
34
37
|
});
|
|
@@ -42,7 +45,7 @@ function TextInput(props) {
|
|
|
42
45
|
field.onChange(value);
|
|
43
46
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
44
47
|
};
|
|
45
|
-
return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, className: props.className, enterKeyHint: props.enterKeyHint, form: props.form, helperText: (
|
|
48
|
+
return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, className: props.className, enterKeyHint: props.enterKeyHint, form: props.form, helperText: (_f = (_e = fieldState.error) === null || _e === void 0 ? void 0 : _e.message) !== null && _f !== void 0 ? _f : props.helperText, hiddenLabel: props.hiddenLabel, id: id, inputMode: props.inputMode, isDisabled: props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, maxLength: props.maxLength, minLength: props.minLength, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, onKeyDown: props.onKeyDown, placeholder: props.placeholder, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, type: props.type, value: (_g = field.value) !== null && _g !== void 0 ? _g : "", variant: props.variant }));
|
|
46
49
|
}
|
|
47
50
|
exports.TextInput = TextInput;
|
|
48
51
|
TextInput.displayName = "UxfFormTextInput";
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Default = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const text_input_1 = require("./text-input");
|
|
9
|
-
const
|
|
9
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
10
10
|
const button_1 = require("@uxf/ui/button");
|
|
11
11
|
exports.default = {
|
|
12
12
|
title: "Form/TextInput",
|
|
@@ -20,7 +20,7 @@ function Default() {
|
|
|
20
20
|
react_1.default.createElement(text_input_1.TextInput, { placeholder: "Zadejte...", label: "Phone required input", name: "phone", type: "tel", control: control, isRequired: true }),
|
|
21
21
|
react_1.default.createElement(text_input_1.TextInput, { placeholder: "Zadejte...", label: "Password input", name: "password", type: "password", control: control }),
|
|
22
22
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
23
|
-
return (react_1.default.createElement(
|
|
23
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
24
24
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormTextInputs(control)),
|
|
25
25
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormTextInputs(control))))));
|
|
26
26
|
}
|
package/textarea/textarea.js
CHANGED
|
@@ -27,15 +27,18 @@ exports.Textarea = void 0;
|
|
|
27
27
|
const textarea_1 = require("@uxf/ui/textarea");
|
|
28
28
|
const react_hook_form_1 = require("react-hook-form");
|
|
29
29
|
const react_1 = __importStar(require("react"));
|
|
30
|
+
const form_id_context_1 = require("../form-id-context");
|
|
30
31
|
function Textarea(props) {
|
|
31
|
-
var _a, _b, _c;
|
|
32
|
+
var _a, _b, _c, _d;
|
|
33
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
34
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
32
35
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
33
36
|
control: props.control,
|
|
34
37
|
defaultValue: props.defaultValue,
|
|
35
38
|
name: props.name,
|
|
36
39
|
rules: {
|
|
37
40
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
38
|
-
...((
|
|
41
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
39
42
|
},
|
|
40
43
|
shouldUnregister: props.shouldUnregister,
|
|
41
44
|
});
|
|
@@ -49,7 +52,7 @@ function Textarea(props) {
|
|
|
49
52
|
field.onChange(value);
|
|
50
53
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
51
54
|
};
|
|
52
|
-
return (react_1.default.createElement(textarea_1.Textarea, { autoComplete: props.autoComplete, className: props.className, disableAutoHeight: props.disableAutoHeight, form: props.form, helperText: (
|
|
55
|
+
return (react_1.default.createElement(textarea_1.Textarea, { autoComplete: props.autoComplete, className: props.className, disableAutoHeight: props.disableAutoHeight, form: props.form, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isDisabled: props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, maxLength: props.maxLength, minLength: props.minLength, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, placeholder: props.placeholder, ref: field.ref, rows: props.rows, value: field.value || "" }));
|
|
53
56
|
}
|
|
54
57
|
exports.Textarea = Textarea;
|
|
55
58
|
Textarea.displayName = "UxfFormTextarea";
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Default = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const
|
|
8
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
9
9
|
const textarea_1 = require("./textarea");
|
|
10
10
|
const button_1 = require("@uxf/ui/button");
|
|
11
11
|
exports.default = {
|
|
@@ -17,7 +17,7 @@ function Default() {
|
|
|
17
17
|
react_1.default.createElement(textarea_1.Textarea, { label: "Textarea", name: "textarea", control: control, placeholder: "placeholder", form: "form-textarea" }),
|
|
18
18
|
react_1.default.createElement(textarea_1.Textarea, { label: "Textarea required", name: "textarea-required", control: control, placeholder: "placeholder", form: "form-textarea", isRequired: true }),
|
|
19
19
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
20
|
-
return (react_1.default.createElement(
|
|
20
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
21
21
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormTextAreas(control)),
|
|
22
22
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormTextAreas(control))))));
|
|
23
23
|
}
|
|
@@ -33,17 +33,20 @@ const react_1 = __importDefault(require("react"));
|
|
|
33
33
|
const dayjs_1 = __importStar(require("dayjs"));
|
|
34
34
|
const time_picker_input_2 = require("@uxf/ui/time-picker-input/time-picker-input");
|
|
35
35
|
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
36
|
+
const form_id_context_1 = require("../form-id-context");
|
|
36
37
|
(0, dayjs_1.extend)(customParseFormat_1.default);
|
|
37
38
|
const OUTPUT_TIME_FORMAT = "HH:mm:ss";
|
|
38
39
|
function TimePickerInput(props) {
|
|
39
|
-
var _a, _b, _c, _d, _e, _f;
|
|
40
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
41
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
42
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
40
43
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
41
44
|
control: props.control,
|
|
42
45
|
defaultValue: props.defaultValue,
|
|
43
46
|
name: props.name,
|
|
44
47
|
rules: {
|
|
45
48
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
46
|
-
...((
|
|
49
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
47
50
|
validate: {
|
|
48
51
|
validTime: (value) => {
|
|
49
52
|
if (!value) {
|
|
@@ -53,9 +56,9 @@ function TimePickerInput(props) {
|
|
|
53
56
|
return "Čas musí být ve formátu H:mm.";
|
|
54
57
|
}
|
|
55
58
|
},
|
|
56
|
-
...(typeof ((
|
|
59
|
+
...(typeof ((_c = props.rules) === null || _c === void 0 ? void 0 : _c.validate) === "function"
|
|
57
60
|
? { custom: props.rules.validate }
|
|
58
|
-
: (
|
|
61
|
+
: (_e = (_d = props.rules) === null || _d === void 0 ? void 0 : _d.validate) !== null && _e !== void 0 ? _e : {}),
|
|
59
62
|
},
|
|
60
63
|
},
|
|
61
64
|
shouldUnregister: props.shouldUnregister,
|
|
@@ -77,7 +80,7 @@ function TimePickerInput(props) {
|
|
|
77
80
|
};
|
|
78
81
|
const parsedTime = (0, dayjs_1.default)(field.value, OUTPUT_TIME_FORMAT, true);
|
|
79
82
|
const value = field.value ? (parsedTime.isValid() ? parsedTime.format(time_picker_input_2.DISPLAY_TIME_FORMAT) : field.value) : null;
|
|
80
|
-
return (react_1.default.createElement(time_picker_input_1.TimePickerInput, { className: props.className, form: props.form, helperText: (
|
|
83
|
+
return (react_1.default.createElement(time_picker_input_1.TimePickerInput, { className: props.className, form: props.form, helperText: (_g = (_f = fieldState.error) === null || _f === void 0 ? void 0 : _f.message) !== null && _g !== void 0 ? _g : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isClearable: props.isClearable, isDisabled: props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, placeholder: props.placeholder, popoverPlacement: props.popoverPlacement, popoverStrategy: props.popoverStrategy, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, triggerElement: props.triggerElement, value: value !== null && value !== void 0 ? value : null, variant: props.variant }));
|
|
81
84
|
}
|
|
82
85
|
exports.TimePickerInput = TimePickerInput;
|
|
83
86
|
TimePickerInput.displayName = "UxfFormTimePickerInput";
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Default = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const time_picker_input_1 = require("./time-picker-input");
|
|
9
|
-
const
|
|
9
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
10
10
|
const button_1 = require("@uxf/ui/button");
|
|
11
11
|
exports.default = {
|
|
12
12
|
title: "Form/TimePickerInput",
|
|
@@ -16,7 +16,7 @@ function Default() {
|
|
|
16
16
|
const storyFormDatePickers = (control) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
17
17
|
react_1.default.createElement(time_picker_input_1.TimePickerInput, { label: "Default time picker", name: "default", control: control, isClearable: true }),
|
|
18
18
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
19
|
-
return (react_1.default.createElement(
|
|
19
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
20
20
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormDatePickers(control)),
|
|
21
21
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 text-white lg:w-1/2" }, storyFormDatePickers(control))))));
|
|
22
22
|
}
|
package/toggle/toggle.js
CHANGED
|
@@ -7,15 +7,18 @@ exports.Toggle = void 0;
|
|
|
7
7
|
const toggle_1 = require("@uxf/ui/toggle");
|
|
8
8
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const form_id_context_1 = require("../form-id-context");
|
|
10
11
|
function Toggle(props) {
|
|
11
|
-
var _a, _b;
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
14
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
12
15
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
13
16
|
control: props.control,
|
|
14
17
|
defaultValue: props.defaultValue,
|
|
15
18
|
name: props.name,
|
|
16
19
|
rules: {
|
|
17
20
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
18
|
-
...((
|
|
21
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
19
22
|
},
|
|
20
23
|
shouldUnregister: props.shouldUnregister,
|
|
21
24
|
});
|
|
@@ -29,7 +32,7 @@ function Toggle(props) {
|
|
|
29
32
|
field.onChange(value);
|
|
30
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
31
34
|
};
|
|
32
|
-
return (react_1.default.createElement(toggle_1.Toggle, { className: props.className, hiddenLabel: props.hiddenLabel, isDisabled: props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, ref: field.ref, value: (
|
|
35
|
+
return (react_1.default.createElement(toggle_1.Toggle, { className: props.className, hiddenLabel: props.hiddenLabel, id: id, isDisabled: props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, ref: field.ref, value: (_c = field.value) !== null && _c !== void 0 ? _c : (!props.nullable ? false : undefined) }));
|
|
33
36
|
}
|
|
34
37
|
exports.Toggle = Toggle;
|
|
35
38
|
Toggle.displayName = "UxfFormToggle";
|
package/toggle/toggle.stories.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Default = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const
|
|
8
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
9
9
|
const toggle_1 = require("./toggle");
|
|
10
10
|
const button_1 = require("@uxf/ui/button");
|
|
11
11
|
exports.default = {
|
|
@@ -18,7 +18,7 @@ function Default() {
|
|
|
18
18
|
react_1.default.createElement(toggle_1.Toggle, { label: "Toggle form required", name: "toggle-required", control: control, isRequired: true }),
|
|
19
19
|
react_1.default.createElement(toggle_1.Toggle, { label: "Toggle form disabled", name: "toggle-disabled", control: control, isDisabled: true }),
|
|
20
20
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
21
|
-
return (react_1.default.createElement(
|
|
21
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
22
22
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormToggles(control)),
|
|
23
23
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormToggles(control))))));
|
|
24
24
|
}
|