@uxf/form 11.31.1 → 11.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/avatar-file-input/avatar-file-input.js +5 -5
- package/avatar-file-input/avatar-file-input.stories.js +1 -2
- package/bin/form-code-generator.d.ts +1 -0
- package/bin/form-code-generator.js +6 -2
- package/checkbox-button/checkbox-button.js +5 -5
- package/checkbox-button/checkbox-button.stories.js +5 -6
- package/checkbox-input/checkbox-input.js +5 -5
- package/checkbox-input/checkbox-input.stories.js +5 -6
- package/color-radio-group/color-radio-group.js +5 -5
- package/color-radio-group/color-radio-group.stories.js +1 -2
- package/combobox/combobox.js +7 -5
- package/combobox/combobox.stories.js +6 -7
- package/date-picker-input/date-picker-input.js +7 -7
- package/date-picker-input/date-picker-input.stories.js +2 -3
- package/date-range-picker-input/date-range-picker-input.js +7 -7
- package/date-range-picker-input/date-range-picker-input.stories.js +4 -5
- package/datetime-picker-input/datetime-picker-input.js +7 -7
- package/datetime-picker-input/datetime-picker-input.stories.js +5 -6
- package/dropzone/dropzone-input.js +6 -6
- package/dropzone/dropzone-list.js +2 -3
- package/dropzone/dropzone.stories.js +9 -11
- package/file-input/file-input.js +5 -5
- package/file-input/file-input.stories.js +3 -4
- package/form/form.js +1 -2
- package/form/form.stories.js +4 -6
- package/form-id-context/form-id-context.d.ts +0 -1
- package/gps-input/gps-input.js +8 -7
- package/gps-input/gps-input.stories.js +3 -4
- package/multi-combobox/multi-combobox.js +7 -5
- package/multi-combobox/multi-combobox.stories.js +3 -4
- package/multi-select/multi-select.js +5 -5
- package/multi-select/multi-select.stories.js +2 -3
- package/number-input/number-input.js +5 -5
- package/number-input/number-input.stories.js +5 -6
- package/package.json +8 -8
- package/password-input/password-input.js +6 -6
- package/password-input/password-input.stories.js +3 -4
- package/radio-group/radio-group.js +5 -5
- package/radio-group/radio-group.stories.js +1 -2
- package/readmes.d.ts +0 -1
- package/select/select.js +5 -5
- package/select/select.stories.js +4 -5
- package/storybook/form-data-printer.js +1 -2
- package/storybook/storybook-form.js +2 -3
- package/text-input/text-input.js +5 -5
- package/text-input/text-input.stories.js +6 -7
- package/textarea/textarea.js +5 -5
- package/textarea/textarea.stories.js +3 -4
- package/time-picker-input/time-picker-input.js +7 -7
- package/time-picker-input/time-picker-input.stories.js +1 -2
- package/toggle/toggle.js +5 -5
- package/toggle/toggle.stories.js +4 -5
|
@@ -3,13 +3,14 @@ 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.RadioGroup =
|
|
6
|
+
exports.RadioGroup = RadioGroup;
|
|
7
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
7
8
|
const radio_group_1 = require("@uxf/ui/radio-group");
|
|
8
9
|
const react_1 = __importDefault(require("react"));
|
|
9
10
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
11
|
const form_id_context_1 = require("../form-id-context");
|
|
11
12
|
function RadioGroup(props) {
|
|
12
|
-
var _a, _b, _c, _d
|
|
13
|
+
var _a, _b, _c, _d;
|
|
13
14
|
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
14
15
|
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
15
16
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
@@ -17,7 +18,7 @@ function RadioGroup(props) {
|
|
|
17
18
|
name: props.name,
|
|
18
19
|
rules: {
|
|
19
20
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
20
|
-
...
|
|
21
|
+
...props.rules,
|
|
21
22
|
},
|
|
22
23
|
shouldUnregister: props.shouldUnregister,
|
|
23
24
|
});
|
|
@@ -31,7 +32,6 @@ function RadioGroup(props) {
|
|
|
31
32
|
field.onChange(value);
|
|
32
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
33
34
|
};
|
|
34
|
-
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: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isDisabled: props.options.length === 0 || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, radioSize: props.radioSize, ref: field.ref, style: props.style, value: (_d = field.value) !== null && _d !== void 0 ? _d : null, variant: props.variant }));
|
|
35
36
|
}
|
|
36
|
-
exports.RadioGroup = RadioGroup;
|
|
37
37
|
RadioGroup.displayName = "UxfFormRadioGroup";
|
|
@@ -3,7 +3,7 @@ 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.Default =
|
|
6
|
+
exports.Default = Default;
|
|
7
7
|
const button_1 = require("@uxf/ui/button");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const storybook_form_1 = require("../storybook/storybook-form");
|
|
@@ -36,4 +36,3 @@ function Default() {
|
|
|
36
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: "space-y-2 p-20 lg:w-1/2" }, storyFormRadioGroup(control))))));
|
|
38
38
|
}
|
|
39
|
-
exports.Default = Default;
|
package/readmes.d.ts
CHANGED
package/select/select.js
CHANGED
|
@@ -3,14 +3,15 @@ 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.Select =
|
|
6
|
+
exports.Select = Select;
|
|
7
7
|
const is_empty_1 = require("@uxf/core/utils/is-empty");
|
|
8
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
8
9
|
const select_1 = require("@uxf/ui/select");
|
|
9
10
|
const react_1 = __importDefault(require("react"));
|
|
10
11
|
const react_hook_form_1 = require("react-hook-form");
|
|
11
12
|
const form_id_context_1 = require("../form-id-context");
|
|
12
13
|
function Select(props) {
|
|
13
|
-
var _a, _b, _c
|
|
14
|
+
var _a, _b, _c;
|
|
14
15
|
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
15
16
|
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
16
17
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
@@ -18,7 +19,7 @@ function Select(props) {
|
|
|
18
19
|
name: props.name,
|
|
19
20
|
rules: {
|
|
20
21
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
21
|
-
...
|
|
22
|
+
...props.rules,
|
|
22
23
|
},
|
|
23
24
|
shouldUnregister: props.shouldUnregister,
|
|
24
25
|
});
|
|
@@ -32,7 +33,6 @@ function Select(props) {
|
|
|
32
33
|
field.onChange(value);
|
|
33
34
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
34
35
|
};
|
|
35
|
-
return (react_1.default.createElement(select_1.Select, { className: props.className, dropdownClassName: props.dropdownClassName, dropdownMatchesInputWidth: props.dropdownMatchesInputWidth, dropdownMaxHeight: props.dropdownMaxHeight, dropdownPlacement: props.dropdownPlacement, dropdownStrategy: props.dropdownStrategy, form: props.form, helperText: (
|
|
36
|
+
return (react_1.default.createElement(select_1.Select, { className: props.className, dropdownClassName: props.dropdownClassName, dropdownMatchesInputWidth: props.dropdownMatchesInputWidth, dropdownMaxHeight: props.dropdownMaxHeight, dropdownPlacement: props.dropdownPlacement, dropdownStrategy: props.dropdownStrategy, form: props.form, helperText: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : props.helperText, hiddenLabel: props.hiddenLabel, iconName: props.iconName, id: id, inputArrow: props.inputArrow, inputRef: field.ref, isClearable: props.isClearable, isDisabled: (0, is_empty_1.isEmpty)(props.options) || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: props.isReadOnly, isRequired: props.isRequired, keyExtractor: props.keyExtractor, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: field.name, noOptionsMessage: props.noOptionsMessage, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, placeholder: props.placeholder, renderOption: props.renderOption, renderSelectedOption: props.renderSelectedOption, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, style: props.style, value: field.value, variant: props.variant }));
|
|
36
37
|
}
|
|
37
|
-
exports.Select = Select;
|
|
38
38
|
Select.displayName = "UxfFormSelect";
|
package/select/select.stories.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.Default =
|
|
6
|
+
exports.Default = Default;
|
|
7
7
|
const button_1 = require("@uxf/ui/button");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const storybook_form_1 = require("../storybook/storybook-form");
|
|
@@ -31,9 +31,9 @@ const numberOptions = [
|
|
|
31
31
|
];
|
|
32
32
|
function Default() {
|
|
33
33
|
const storyFormSelects = (control) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
34
|
-
react_1.default.createElement(select_1.Select, { dropdownMaxHeight: 350,
|
|
35
|
-
react_1.default.createElement(select_1.Select, { label: "Select form disabled", name: "select-disabled",
|
|
36
|
-
react_1.default.createElement(select_1.Select, { label: "Select form with helper text", name: "select-helper-text",
|
|
34
|
+
react_1.default.createElement(select_1.Select, { control: control, dropdownMaxHeight: 350, id: "form-select", isClearable: true, label: "Select form", name: "select", options: options, placeholder: "placeholder" }),
|
|
35
|
+
react_1.default.createElement(select_1.Select, { control: control, id: "form-select", isDisabled: true, label: "Select form disabled", name: "select-disabled", options: options, placeholder: "placeholder" }),
|
|
36
|
+
react_1.default.createElement(select_1.Select, { control: control, helperText: "Choose one option", id: "form-select", label: "Select form with helper text", name: "select-helper-text", options: options, placeholder: "placeholder" }),
|
|
37
37
|
react_1.default.createElement(select_1.Select, { control: control, helperText: "Choose one option", id: "form-select", isRequired: true, label: "Select form required", name: "select-required", options: options, placeholder: "placeholder" }),
|
|
38
38
|
react_1.default.createElement(select_1.Select, { control: control, dropdownPlacement: "top", id: "form-select", label: "Select form with dropdown top", name: "select-dropdown-top", options: options, placeholder: "placeholder" }),
|
|
39
39
|
react_1.default.createElement(select_1.Select, { control: control, id: "form-select", isClearable: true, label: "Select form clearable", name: "select-dropdown-clearable", options: options, placeholder: "placeholder" }),
|
|
@@ -42,4 +42,3 @@ function Default() {
|
|
|
42
42
|
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
43
43
|
react_1.default.createElement("div", { className: "space-y-2 p-20 lg:w-1/2" }, storyFormSelects(control))))));
|
|
44
44
|
}
|
|
45
|
-
exports.Default = Default;
|
|
@@ -3,11 +3,10 @@ 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.FormDataPrinter =
|
|
6
|
+
exports.FormDataPrinter = FormDataPrinter;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
9
|
function FormDataPrinter(props) {
|
|
10
10
|
const data = (0, react_hook_form_1.useWatch)({ control: props.control });
|
|
11
11
|
return (react_1.default.createElement("pre", { className: "bg-slate-100 p-2 text-sm dark:bg-slate-800 dark:text-white" }, JSON.stringify(data, null, " ")));
|
|
12
12
|
}
|
|
13
|
-
exports.FormDataPrinter = FormDataPrinter;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.StorybookForm =
|
|
26
|
+
exports.StorybookForm = StorybookForm;
|
|
27
27
|
const button_1 = require("@uxf/ui/button");
|
|
28
28
|
const react_1 = __importStar(require("react"));
|
|
29
29
|
const react_hook_form_1 = require("react-hook-form");
|
|
@@ -34,10 +34,9 @@ function StorybookForm(props) {
|
|
|
34
34
|
const formId = (0, react_1.useId)();
|
|
35
35
|
return (
|
|
36
36
|
// eslint-disable-next-line no-console
|
|
37
|
-
react_1.default.createElement(form_1.Form, { formApi: form, id: formId, onSubmit: console.log
|
|
37
|
+
react_1.default.createElement(form_1.Form, { className: props.className, formApi: form, id: formId, onSubmit: console.log },
|
|
38
38
|
props.children(form),
|
|
39
39
|
react_1.default.createElement("div", { className: "my-4" },
|
|
40
40
|
react_1.default.createElement(form_data_printer_1.FormDataPrinter, { control: form.control })),
|
|
41
41
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
42
42
|
}
|
|
43
|
-
exports.StorybookForm = StorybookForm;
|
package/text-input/text-input.js
CHANGED
|
@@ -3,7 +3,8 @@ 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.TextInput =
|
|
6
|
+
exports.TextInput = TextInput;
|
|
7
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
7
8
|
const text_input_1 = require("@uxf/ui/text-input");
|
|
8
9
|
const react_1 = __importDefault(require("react"));
|
|
9
10
|
const react_hook_form_1 = require("react-hook-form");
|
|
@@ -11,7 +12,7 @@ const form_id_context_1 = require("../form-id-context");
|
|
|
11
12
|
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,}))$/;
|
|
12
13
|
const PHONE_REGEXP = /^(\+)?[\d\s]*$/;
|
|
13
14
|
function TextInput(props) {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f
|
|
15
|
+
var _a, _b, _c, _d, _e, _f;
|
|
15
16
|
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
16
17
|
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
17
18
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
@@ -30,7 +31,7 @@ function TextInput(props) {
|
|
|
30
31
|
message: (_c = props.invalidPhoneMessage) !== null && _c !== void 0 ? _c : "Zadaný telefon není ve správném formátu",
|
|
31
32
|
}
|
|
32
33
|
: undefined,
|
|
33
|
-
...
|
|
34
|
+
...props.rules,
|
|
34
35
|
},
|
|
35
36
|
shouldUnregister: props.shouldUnregister,
|
|
36
37
|
});
|
|
@@ -44,7 +45,6 @@ function TextInput(props) {
|
|
|
44
45
|
field.onChange(value);
|
|
45
46
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
46
47
|
};
|
|
47
|
-
return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, autoFocus: props.autoFocus, className: props.className, enterKeyHint: props.enterKeyHint, form: props.form, helperText: (
|
|
48
|
+
return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, autoFocus: props.autoFocus, className: props.className, enterKeyHint: props.enterKeyHint, form: props.form, helperText: (_e = (_d = fieldState.error) === null || _d === void 0 ? void 0 : _d.message) !== null && _e !== void 0 ? _e : props.helperText, hiddenLabel: props.hiddenLabel, id: id, inputMode: props.inputMode, isDisabled: props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(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, style: props.style, type: props.type, value: (_f = field.value) !== null && _f !== void 0 ? _f : "", variant: props.variant }));
|
|
48
49
|
}
|
|
49
|
-
exports.TextInput = TextInput;
|
|
50
50
|
TextInput.displayName = "UxfFormTextInput";
|
|
@@ -3,7 +3,7 @@ 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.Default =
|
|
6
|
+
exports.Default = Default;
|
|
7
7
|
const button_1 = require("@uxf/ui/button");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const storybook_form_1 = require("../storybook/storybook-form");
|
|
@@ -14,13 +14,12 @@ exports.default = {
|
|
|
14
14
|
};
|
|
15
15
|
function Default() {
|
|
16
16
|
const storyFormTextInputs = (control) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
17
|
-
react_1.default.createElement(text_input_1.TextInput, {
|
|
18
|
-
react_1.default.createElement(text_input_1.TextInput, {
|
|
19
|
-
react_1.default.createElement(text_input_1.TextInput, {
|
|
20
|
-
react_1.default.createElement(text_input_1.TextInput, {
|
|
21
|
-
react_1.default.createElement(text_input_1.TextInput, {
|
|
17
|
+
react_1.default.createElement(text_input_1.TextInput, { autoComplete: "off", control: control, label: "Default input", name: "default", placeholder: "Zadejte..." }),
|
|
18
|
+
react_1.default.createElement(text_input_1.TextInput, { control: control, isRequired: true, label: "Required input", name: "required", placeholder: "Zadejte..." }),
|
|
19
|
+
react_1.default.createElement(text_input_1.TextInput, { control: control, isRequired: true, label: "E-mail required input", name: "email", placeholder: "Zadejte...", type: "email" }),
|
|
20
|
+
react_1.default.createElement(text_input_1.TextInput, { control: control, isRequired: true, label: "Phone required input", name: "phone", placeholder: "Zadejte...", type: "tel" }),
|
|
21
|
+
react_1.default.createElement(text_input_1.TextInput, { control: control, label: "Password input", name: "password", placeholder: "Zadejte...", type: "password" }),
|
|
22
22
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
23
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: "space-y-2 p-20 lg:w-1/2" }, storyFormTextInputs(control))))));
|
|
25
25
|
}
|
|
26
|
-
exports.Default = Default;
|
package/textarea/textarea.js
CHANGED
|
@@ -23,13 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Textarea =
|
|
26
|
+
exports.Textarea = Textarea;
|
|
27
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
27
28
|
const textarea_1 = require("@uxf/ui/textarea");
|
|
28
29
|
const react_1 = __importStar(require("react"));
|
|
29
30
|
const react_hook_form_1 = require("react-hook-form");
|
|
30
31
|
const form_id_context_1 = require("../form-id-context");
|
|
31
32
|
function Textarea(props) {
|
|
32
|
-
var _a, _b, _c
|
|
33
|
+
var _a, _b, _c;
|
|
33
34
|
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
34
35
|
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
35
36
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
@@ -37,7 +38,7 @@ function Textarea(props) {
|
|
|
37
38
|
name: props.name,
|
|
38
39
|
rules: {
|
|
39
40
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
40
|
-
...
|
|
41
|
+
...props.rules,
|
|
41
42
|
},
|
|
42
43
|
shouldUnregister: props.shouldUnregister,
|
|
43
44
|
});
|
|
@@ -51,7 +52,6 @@ function Textarea(props) {
|
|
|
51
52
|
field.onChange(value);
|
|
52
53
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
53
54
|
};
|
|
54
|
-
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: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isDisabled: props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(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, style: props.style, value: field.value || "" }));
|
|
55
56
|
}
|
|
56
|
-
exports.Textarea = Textarea;
|
|
57
57
|
Textarea.displayName = "UxfFormTextarea";
|
|
@@ -3,7 +3,7 @@ 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.Default =
|
|
6
|
+
exports.Default = Default;
|
|
7
7
|
const button_1 = require("@uxf/ui/button");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const storybook_form_1 = require("../storybook/storybook-form");
|
|
@@ -14,10 +14,9 @@ exports.default = {
|
|
|
14
14
|
};
|
|
15
15
|
function Default() {
|
|
16
16
|
const storyFormTextAreas = (control) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
17
|
-
react_1.default.createElement(textarea_1.Textarea, {
|
|
18
|
-
react_1.default.createElement(textarea_1.Textarea, {
|
|
17
|
+
react_1.default.createElement(textarea_1.Textarea, { control: control, form: "form-textarea", label: "Textarea", name: "textarea", placeholder: "placeholder" }),
|
|
18
|
+
react_1.default.createElement(textarea_1.Textarea, { control: control, form: "form-textarea", isRequired: true, label: "Textarea required", name: "textarea-required", placeholder: "placeholder" }),
|
|
19
19
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
20
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: "space-y-2 p-20 lg:w-1/2" }, storyFormTextAreas(control))))));
|
|
22
22
|
}
|
|
23
|
-
exports.Default = Default;
|
|
@@ -26,7 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.TimePickerInput =
|
|
29
|
+
exports.TimePickerInput = TimePickerInput;
|
|
30
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
30
31
|
const time_picker_input_1 = require("@uxf/ui/time-picker-input");
|
|
31
32
|
const dayjs_1 = __importStar(require("dayjs"));
|
|
32
33
|
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
@@ -35,7 +36,7 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
35
36
|
const form_id_context_1 = require("../form-id-context");
|
|
36
37
|
(0, dayjs_1.extend)(customParseFormat_1.default);
|
|
37
38
|
function TimePickerInput(props) {
|
|
38
|
-
var _a, _b, _c, _d, _e
|
|
39
|
+
var _a, _b, _c, _d, _e;
|
|
39
40
|
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
40
41
|
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
41
42
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
@@ -43,7 +44,7 @@ function TimePickerInput(props) {
|
|
|
43
44
|
name: props.name,
|
|
44
45
|
rules: {
|
|
45
46
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
46
|
-
...
|
|
47
|
+
...props.rules,
|
|
47
48
|
validate: {
|
|
48
49
|
validTime: (value) => {
|
|
49
50
|
if (!value) {
|
|
@@ -53,9 +54,9 @@ function TimePickerInput(props) {
|
|
|
53
54
|
return `Čas musí být ve formátu ${time_picker_input_1.DISPLAY_TIME_FORMAT}.`;
|
|
54
55
|
}
|
|
55
56
|
},
|
|
56
|
-
...(typeof ((
|
|
57
|
+
...(typeof ((_b = props.rules) === null || _b === void 0 ? void 0 : _b.validate) === "function"
|
|
57
58
|
? { custom: props.rules.validate }
|
|
58
|
-
: (
|
|
59
|
+
: (_c = props.rules) === null || _c === void 0 ? void 0 : _c.validate),
|
|
59
60
|
},
|
|
60
61
|
},
|
|
61
62
|
shouldUnregister: props.shouldUnregister,
|
|
@@ -70,7 +71,6 @@ function TimePickerInput(props) {
|
|
|
70
71
|
field.onChange(value);
|
|
71
72
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
72
73
|
};
|
|
73
|
-
return (react_1.default.createElement(time_picker_input_1.TimePickerInput, { autoFocus: props.autoFocus, className: props.className, form: props.form, helperText: (
|
|
74
|
+
return (react_1.default.createElement(time_picker_input_1.TimePickerInput, { CustomTimePicker: props.CustomTimePicker, autoFocus: props.autoFocus, className: props.className, form: props.form, helperText: (_e = (_d = fieldState.error) === null || _d === void 0 ? void 0 : _d.message) !== null && _e !== void 0 ? _e : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isClearable: props.isClearable, isDisabled: props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(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: field.value, variant: props.variant }));
|
|
74
75
|
}
|
|
75
|
-
exports.TimePickerInput = TimePickerInput;
|
|
76
76
|
TimePickerInput.displayName = "UxfFormTimePickerInput";
|
|
@@ -3,7 +3,7 @@ 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.Default =
|
|
6
|
+
exports.Default = Default;
|
|
7
7
|
const button_1 = require("@uxf/ui/button");
|
|
8
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
@@ -23,4 +23,3 @@ function Default() {
|
|
|
23
23
|
} }, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
24
24
|
react_1.default.createElement("div", { className: "space-y-2 p-20 lg:w-1/2" }, storyFormDatePickers(control))))));
|
|
25
25
|
}
|
|
26
|
-
exports.Default = Default;
|
package/toggle/toggle.js
CHANGED
|
@@ -3,13 +3,14 @@ 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.Toggle =
|
|
6
|
+
exports.Toggle = Toggle;
|
|
7
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
7
8
|
const toggle_1 = require("@uxf/ui/toggle");
|
|
8
9
|
const react_1 = __importDefault(require("react"));
|
|
9
10
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
11
|
const form_id_context_1 = require("../form-id-context");
|
|
11
12
|
function Toggle(props) {
|
|
12
|
-
var _a, _b
|
|
13
|
+
var _a, _b;
|
|
13
14
|
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
14
15
|
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
15
16
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
@@ -17,7 +18,7 @@ function Toggle(props) {
|
|
|
17
18
|
name: props.name,
|
|
18
19
|
rules: {
|
|
19
20
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
20
|
-
...
|
|
21
|
+
...props.rules,
|
|
21
22
|
},
|
|
22
23
|
shouldUnregister: props.shouldUnregister,
|
|
23
24
|
});
|
|
@@ -31,7 +32,6 @@ function Toggle(props) {
|
|
|
31
32
|
field.onChange(value);
|
|
32
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
33
34
|
};
|
|
34
|
-
return (react_1.default.createElement(toggle_1.Toggle, { className: props.className, hiddenLabel: props.hiddenLabel, id: id, isDisabled: props.isDisabled, isInvalid:
|
|
35
|
+
return (react_1.default.createElement(toggle_1.Toggle, { className: props.className, hiddenLabel: props.hiddenLabel, id: id, isDisabled: props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, ref: field.ref, style: props.style, value: (_b = field.value) !== null && _b !== void 0 ? _b : (!props.nullable ? false : undefined), variant: props.variant }));
|
|
35
36
|
}
|
|
36
|
-
exports.Toggle = Toggle;
|
|
37
37
|
Toggle.displayName = "UxfFormToggle";
|
package/toggle/toggle.stories.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.Default =
|
|
6
|
+
exports.Default = Default;
|
|
7
7
|
const button_1 = require("@uxf/ui/button");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const storybook_form_1 = require("../storybook/storybook-form");
|
|
@@ -14,11 +14,10 @@ exports.default = {
|
|
|
14
14
|
};
|
|
15
15
|
function Default() {
|
|
16
16
|
const storyFormToggles = (control) => (react_1.default.createElement("div", { className: "space-y-2" },
|
|
17
|
-
react_1.default.createElement(toggle_1.Toggle, { label: "Toggle form", name: "toggle1"
|
|
18
|
-
react_1.default.createElement(toggle_1.Toggle, { label: "Toggle form required", name: "toggle-required"
|
|
19
|
-
react_1.default.createElement(toggle_1.Toggle, { label: "Toggle form disabled", name: "toggle-disabled"
|
|
17
|
+
react_1.default.createElement(toggle_1.Toggle, { control: control, label: "Toggle form", name: "toggle1" }),
|
|
18
|
+
react_1.default.createElement(toggle_1.Toggle, { control: control, isRequired: true, label: "Toggle form required", name: "toggle-required" }),
|
|
19
|
+
react_1.default.createElement(toggle_1.Toggle, { control: control, isDisabled: true, label: "Toggle form disabled", name: "toggle-disabled" }),
|
|
20
20
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
21
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: "space-y-2 p-20 lg:w-1/2" }, storyFormToggles(control))))));
|
|
23
23
|
}
|
|
24
|
-
exports.Default = Default;
|