@uxf/form 10.0.0-beta.7 → 10.0.0-beta.74
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 +1 -1
- package/checkbox-input/checkbox-input.js +1 -1
- package/combobox/combobox.js +1 -1
- package/date-picker-input/date-picker-input.js +1 -1
- package/date-range-picker-input/date-range-picker-input.d.ts +11 -0
- package/date-range-picker-input/date-range-picker-input.js +104 -0
- package/date-range-picker-input/date-range-picker-input.stories.d.ts +8 -0
- package/date-range-picker-input/date-range-picker-input.stories.js +24 -0
- package/date-range-picker-input/index.d.ts +1 -0
- package/date-range-picker-input/index.js +17 -0
- package/datetime-picker-input/datetime-picker-input.js +1 -1
- package/file-input/file-input.js +1 -1
- package/file-input/file-input.stories.js +1 -1
- package/multi-combobox/multi-combobox.js +1 -1
- package/multi-combobox/multi-combobox.stories.js +6 -2
- package/multi-select/multi-select.js +1 -1
- package/multi-select/multi-select.stories.js +1 -1
- package/number-input/number-input.d.ts +1 -3
- package/number-input/number-input.js +16 -4
- package/package.json +2 -2
- package/radio-group/radio-group.d.ts +2 -2
- package/radio-group/radio-group.js +1 -1
- package/radio-group/radio-group.stories.js +3 -3
- package/select/select.js +1 -1
|
@@ -32,7 +32,7 @@ function AvatarFileInput(props) {
|
|
|
32
32
|
field.onChange(value);
|
|
33
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
34
34
|
};
|
|
35
|
-
return (react_1.default.createElement(avatar_file_input_1.AvatarFileInput, { accept: props.accept, className: props.className, form: props.form, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, 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, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, ref: field.ref, value: field.value }));
|
|
35
|
+
return (react_1.default.createElement(avatar_file_input_1.AvatarFileInput, { accept: props.accept, className: props.className, form: props.form, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, 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, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, ref: field.ref, value: field.value, variant: props.variant }));
|
|
36
36
|
}
|
|
37
37
|
exports.AvatarFileInput = AvatarFileInput;
|
|
38
38
|
AvatarFileInput.displayName = "UxfFormAvatarFileInput";
|
|
@@ -32,7 +32,7 @@ function CheckboxInput(props) {
|
|
|
32
32
|
field.onChange(value);
|
|
33
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
34
34
|
};
|
|
35
|
-
return (react_1.default.createElement(checkbox_input_1.CheckboxInput, { className: props.className, 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) }));
|
|
35
|
+
return (react_1.default.createElement(checkbox_input_1.CheckboxInput, { className: props.className, 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, size: props.size, value: (_c = field.value) !== null && _c !== void 0 ? _c : (!props.nullable ? false : undefined) }));
|
|
36
36
|
}
|
|
37
37
|
exports.CheckboxInput = CheckboxInput;
|
|
38
38
|
CheckboxInput.displayName = "UxfFormCheckboxInput";
|
package/combobox/combobox.js
CHANGED
|
@@ -32,7 +32,7 @@ function Combobox(props) {
|
|
|
32
32
|
field.onChange(value);
|
|
33
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
34
34
|
};
|
|
35
|
-
return (react_1.default.createElement(combobox_1.Combobox, { 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: ((_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, value: (_f = field.value) !== null && _f !== void 0 ? _f : null }));
|
|
35
|
+
return (react_1.default.createElement(combobox_1.Combobox, { 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, iconName: props.iconName, id: id, isClearable: props.isClearable, 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, leftAddon: props.leftAddon, leftElement: props.leftElement, loadOptions: props.loadOptions, name: field.name, noQueryMessage: props.noQueryMessage, notFoundMessage: props.notFoundMessage, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, placeholder: props.placeholder, renderOption: props.renderOption, rightAddon: props.rightAddon, rightElement: props.rightElement, value: (_f = field.value) !== null && _f !== void 0 ? _f : null }));
|
|
36
36
|
}
|
|
37
37
|
exports.Combobox = Combobox;
|
|
38
38
|
Combobox.displayName = "UxfFormCombobox";
|
|
@@ -82,7 +82,7 @@ function DatePickerInput(props) {
|
|
|
82
82
|
field.onChange(value);
|
|
83
83
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
84
84
|
};
|
|
85
|
-
return (react_1.default.createElement(date_picker_input_1.DatePickerInput, { minDate: props.minDate, maxDate: props.maxDate, 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: field.value, variant: props.variant }));
|
|
85
|
+
return (react_1.default.createElement(date_picker_input_1.DatePickerInput, { minDate: props.minDate, maxDate: props.maxDate, 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, unavailableDates: props.unavailableDates, value: field.value, variant: props.variant }));
|
|
86
86
|
}
|
|
87
87
|
exports.DatePickerInput = DatePickerInput;
|
|
88
88
|
DatePickerInput.displayName = "UxfFormDatePickerInput";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DateRangePickerInputProps as UIDateRangePickerInputProps } from "@uxf/ui/date-range-picker-input";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
|
+
export type DateRangePickerInputProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UIDateRangePickerInputProps, "isInvalid" | "max" | "min" | "pattern" | "step" | "name" | "onChange" | "value"> & {
|
|
5
|
+
onChange?: UIDateRangePickerInputProps["onChange"];
|
|
6
|
+
requiredMessage?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function DateRangePickerInput<FormData extends FieldValues>(props: DateRangePickerInputProps<FormData>): React.JSX.Element;
|
|
9
|
+
export declare namespace DateRangePickerInput {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.DateRangePickerInput = void 0;
|
|
30
|
+
const date_range_picker_input_1 = require("@uxf/ui/date-range-picker-input");
|
|
31
|
+
const dayjs_1 = __importStar(require("dayjs"));
|
|
32
|
+
const react_1 = __importDefault(require("react"));
|
|
33
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
34
|
+
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
35
|
+
const date_range_picker_input_2 = require("@uxf/ui/date-range-picker-input/date-range-picker-input");
|
|
36
|
+
(0, dayjs_1.extend)(customParseFormat_1.default);
|
|
37
|
+
const OUTPUT_DATE_FORMAT = "YYYY-MM-DD";
|
|
38
|
+
function DateRangePickerInput(props) {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f;
|
|
40
|
+
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
41
|
+
control: props.control,
|
|
42
|
+
defaultValue: props.defaultValue,
|
|
43
|
+
name: props.name,
|
|
44
|
+
rules: {
|
|
45
|
+
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
46
|
+
...((_a = props.rules) !== null && _a !== void 0 ? _a : {}),
|
|
47
|
+
validate: {
|
|
48
|
+
validDate: (value) => {
|
|
49
|
+
if (!value) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const { from, to } = (0, date_range_picker_input_2.splitValueToRange)(value);
|
|
53
|
+
const fromIsValid = (0, dayjs_1.default)(from, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
|
|
54
|
+
const toIsValid = (0, dayjs_1.default)(to, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
|
|
55
|
+
if (!fromIsValid || !toIsValid) {
|
|
56
|
+
return "Rozsah musí být ve formátu D. M. YYYY. - D. M. YYYY.";
|
|
57
|
+
}
|
|
58
|
+
if ((0, dayjs_1.default)(from).isAfter((0, dayjs_1.default)(to), "day")) {
|
|
59
|
+
return "Koncové datum nemůže předcházet počátečnímu datu.";
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
...(typeof ((_b = props.rules) === null || _b === void 0 ? void 0 : _b.validate) === "function"
|
|
63
|
+
? { custom: props.rules.validate }
|
|
64
|
+
: (_d = (_c = props.rules) === null || _c === void 0 ? void 0 : _c.validate) !== null && _d !== void 0 ? _d : {}),
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
shouldUnregister: props.shouldUnregister,
|
|
68
|
+
});
|
|
69
|
+
const onBlur = (event) => {
|
|
70
|
+
var _a;
|
|
71
|
+
field.onBlur();
|
|
72
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
73
|
+
};
|
|
74
|
+
const onChange = (value, event) => {
|
|
75
|
+
var _a;
|
|
76
|
+
if (value) {
|
|
77
|
+
const { from, to } = (0, date_range_picker_input_2.splitValueToRange)(value);
|
|
78
|
+
const fromIsValid = (0, dayjs_1.default)(from, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
|
|
79
|
+
const toIsValid = (0, dayjs_1.default)(to, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
|
|
80
|
+
if (fromIsValid || toIsValid) {
|
|
81
|
+
field.onChange((fromIsValid ? (0, dayjs_1.default)(from, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).format(OUTPUT_DATE_FORMAT) : from) +
|
|
82
|
+
date_range_picker_input_2.SEPARATOR +
|
|
83
|
+
(toIsValid ? (0, dayjs_1.default)(to, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).format(OUTPUT_DATE_FORMAT) : to));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
field.onChange(value);
|
|
88
|
+
}
|
|
89
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
90
|
+
};
|
|
91
|
+
const { from: fieldFrom, to: fieldTo } = (0, date_range_picker_input_2.splitValueToRange)(field.value);
|
|
92
|
+
const parsedFrom = (0, dayjs_1.default)(fieldFrom, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true);
|
|
93
|
+
const parsedTo = (0, dayjs_1.default)(fieldTo, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true);
|
|
94
|
+
const value = field.value
|
|
95
|
+
? parsedFrom.isValid() || parsedTo.isValid()
|
|
96
|
+
? (parsedFrom.isValid() ? parsedFrom.format(date_range_picker_input_2.DISPLAY_DATE_FORMAT) : fieldFrom) +
|
|
97
|
+
date_range_picker_input_2.SEPARATOR +
|
|
98
|
+
(parsedTo.isValid() ? parsedTo.format(date_range_picker_input_2.DISPLAY_DATE_FORMAT) : fieldTo)
|
|
99
|
+
: field.value
|
|
100
|
+
: null;
|
|
101
|
+
return (react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { className: props.className, 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: props.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, numberOfMonths: props.numberOfMonths, 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, unavailableDates: props.unavailableDates, value: value, variant: props.variant }));
|
|
102
|
+
}
|
|
103
|
+
exports.DateRangePickerInput = DateRangePickerInput;
|
|
104
|
+
DateRangePickerInput.displayName = "UxfFormDateRangePickerInput";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DateRangePickerInput } from "./date-range-picker-input";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof DateRangePickerInput;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
export declare function Default(): React.JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Default = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const date_range_picker_input_1 = require("./date-range-picker-input");
|
|
9
|
+
const button_1 = require("@uxf/ui/button");
|
|
10
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
11
|
+
exports.default = {
|
|
12
|
+
title: "Form/DateRangePickerInput",
|
|
13
|
+
component: date_range_picker_input_1.DateRangePickerInput,
|
|
14
|
+
};
|
|
15
|
+
function Default() {
|
|
16
|
+
const storyFormDatePickers = (control) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
17
|
+
react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { label: "Default date range picker", name: "default", control: control, isClearable: true, isRequired: true }),
|
|
18
|
+
react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { label: "Date range picker with two months", name: "twomonths", numberOfMonths: 2, control: control, isClearable: true, isRequired: true }),
|
|
19
|
+
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
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
|
+
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormDatePickers(control)),
|
|
22
|
+
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 text-white lg:w-1/2" }, storyFormDatePickers(control))))));
|
|
23
|
+
}
|
|
24
|
+
exports.Default = Default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./date-range-picker-input";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./date-range-picker-input"), exports);
|
|
@@ -84,7 +84,7 @@ function DatetimePickerInput(props) {
|
|
|
84
84
|
field.onChange(value);
|
|
85
85
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
86
86
|
};
|
|
87
|
-
return (react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { minDate: props.minDate, maxDate: props.maxDate, 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: field.value, variant: props.variant }));
|
|
87
|
+
return (react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { minDate: props.minDate, maxDate: props.maxDate, 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, unavailableDates: props.unavailableDates, value: field.value, variant: props.variant }));
|
|
88
88
|
}
|
|
89
89
|
exports.DatetimePickerInput = DatetimePickerInput;
|
|
90
90
|
DatetimePickerInput.displayName = "UxfFormDatePickerInput";
|
package/file-input/file-input.js
CHANGED
|
@@ -32,7 +32,7 @@ function FileInput(props) {
|
|
|
32
32
|
field.onChange(value);
|
|
33
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
34
34
|
};
|
|
35
|
-
return (react_1.default.createElement(file_input_1.FileInput, { accept: props.accept, className: props.className, form: props.form, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, id: id, isClearable: props.isClearable, 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, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, ref: field.ref, size: props.size, value: field.value, variant: props.variant }));
|
|
35
|
+
return (react_1.default.createElement(file_input_1.FileInput, { accept: props.accept, className: props.className, form: props.form, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, id: id, isClearable: props.isClearable, isDisabled: props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: props.isReadOnly, isRequired: props.isRequired, label: props.label, hiddenLabel: props.hiddenLabel, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, placeholder: props.placeholder, ref: field.ref, size: props.size, value: field.value, variant: props.variant, uploadButtonLabel: props.uploadButtonLabel }));
|
|
36
36
|
}
|
|
37
37
|
exports.FileInput = FileInput;
|
|
38
38
|
FileInput.displayName = "FileInput";
|
|
@@ -21,7 +21,7 @@ const DUMMY_FILE = {
|
|
|
21
21
|
};
|
|
22
22
|
function Default() {
|
|
23
23
|
const storyFormFileInputs = (control, mode) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
24
|
-
react_1.default.createElement(file_input_1.FileInput, { control: control, label: "Default file input", name: `default-${mode}`, onUploadFile: uploadFIle_mock_1.uploadFile, isClearable: true }),
|
|
24
|
+
react_1.default.createElement(file_input_1.FileInput, { control: control, label: "Default file input", name: `default-${mode}`, onUploadFile: uploadFIle_mock_1.uploadFile, isClearable: true, placeholder: "Nahraj soubor" }),
|
|
25
25
|
react_1.default.createElement(file_input_1.FileInput, { control: control, id: `required-${mode}`, isRequired: true, label: "Required file input", name: `required-${mode}`, onUploadFile: uploadFIle_mock_1.uploadFile }),
|
|
26
26
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
27
27
|
return (react_1.default.createElement(storybook_form_1.StorybookForm, { defaultValues: { "default-light": DUMMY_FILE } }, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
@@ -32,7 +32,7 @@ function MultiCombobox(props) {
|
|
|
32
32
|
field.onChange(value);
|
|
33
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
34
34
|
};
|
|
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 }));
|
|
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, iconName: props.iconName, 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, leftAddon: props.leftAddon, leftElement: props.leftElement, loadOptions: props.loadOptions, name: field.name, noQueryMessage: props.noQueryMessage, notFoundMessage: props.notFoundMessage, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, placeholder: props.placeholder, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, value: field.value, withCheckboxes: props.withCheckboxes }));
|
|
36
36
|
}
|
|
37
37
|
exports.MultiCombobox = MultiCombobox;
|
|
38
38
|
MultiCombobox.displayName = "UxfFormMultiCombobox";
|
|
@@ -14,9 +14,9 @@ exports.default = {
|
|
|
14
14
|
};
|
|
15
15
|
const options = [
|
|
16
16
|
{ id: "one", label: "Option one", color: "red" },
|
|
17
|
-
{ id: "two", label: "Option two", color: "blue" },
|
|
17
|
+
{ id: "two", label: "Option two", color: "blue", disabled: true },
|
|
18
18
|
{ id: "three", label: "Option three", color: "green" },
|
|
19
|
-
{ id: "four", label: "Option four" },
|
|
19
|
+
{ id: "four", label: "Option four disabled", disabled: true },
|
|
20
20
|
{ id: "five", label: "Option five" },
|
|
21
21
|
{ id: "six", label: "Option six" },
|
|
22
22
|
];
|
|
@@ -35,6 +35,10 @@ function Default() {
|
|
|
35
35
|
{ id: "one", label: "Option one" },
|
|
36
36
|
{ id: "two", label: "Option two" },
|
|
37
37
|
],
|
|
38
|
+
"combobox-with-checkboxes": [
|
|
39
|
+
{ id: "one", label: "Option one" },
|
|
40
|
+
{ id: "two", label: "Option two", disabled: true },
|
|
41
|
+
],
|
|
38
42
|
"select-dropdown-async-default": [
|
|
39
43
|
{ id: "one", label: "Option one" },
|
|
40
44
|
{ id: "two", label: "Option two" },
|
|
@@ -32,7 +32,7 @@ function MultiSelect(props) {
|
|
|
32
32
|
field.onChange(value);
|
|
33
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
34
34
|
};
|
|
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 }));
|
|
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, iconName: props.iconName, 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 }));
|
|
36
36
|
}
|
|
37
37
|
exports.MultiSelect = MultiSelect;
|
|
38
38
|
MultiSelect.displayName = "UxfFormMultiSelect";
|
|
@@ -17,7 +17,7 @@ const options = [
|
|
|
17
17
|
{ id: "two", label: "Option two", color: "blue" },
|
|
18
18
|
{ id: "three", label: "Option three", color: "green" },
|
|
19
19
|
{ id: "four", label: "Option four" },
|
|
20
|
-
{ id: "five", label: "Option five" },
|
|
20
|
+
{ id: "five", label: "Option five disabled", disabled: true },
|
|
21
21
|
{ id: "six", label: "Option six" },
|
|
22
22
|
];
|
|
23
23
|
function Default() {
|
|
@@ -2,14 +2,12 @@ import { TextInputProps as UITextInputProps } from "@uxf/ui/text-input";
|
|
|
2
2
|
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { FormControlProps } from "@uxf/ui/types";
|
|
5
|
-
type OnChangeHandler = FormControlProps<string>["onChange"];
|
|
6
5
|
export type NumberInputProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UITextInputProps, "inputMode" | "isInvalid" | "maxLength" | "minLength" | "name" | "onChange" | "value" | "type"> & {
|
|
7
6
|
decimalPlaces?: number;
|
|
8
|
-
onChange?:
|
|
7
|
+
onChange?: FormControlProps<number>["onChange"];
|
|
9
8
|
requiredMessage?: string;
|
|
10
9
|
};
|
|
11
10
|
export declare function NumberInput<FormData extends FieldValues>(props: NumberInputProps<FormData>): React.JSX.Element;
|
|
12
11
|
export declare namespace NumberInput {
|
|
13
12
|
var displayName: string;
|
|
14
13
|
}
|
|
15
|
-
export {};
|
|
@@ -41,15 +41,27 @@ function NumberInput(props) {
|
|
|
41
41
|
};
|
|
42
42
|
const onKeyDown = (event) => {
|
|
43
43
|
var _a;
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// Allow special keys
|
|
45
|
+
const specialKeys = ["Backspace", "Delete", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
|
|
46
|
+
// Allow keys for copy/paste/select/cut
|
|
47
|
+
const controlKeys = ["v", "V", "c", "C", "x", "X", "a", "A"];
|
|
48
|
+
// Allow digits and decimal point (.,)
|
|
49
|
+
const allowedDigits = /[0-9+\-.,]/;
|
|
50
|
+
const key = event.key;
|
|
51
|
+
// Check if the key is allowed
|
|
52
|
+
if (!specialKeys.includes(key) && !allowedDigits.test(key)) {
|
|
53
|
+
// Check if Ctrl or Command key is pressed along with control key
|
|
54
|
+
if (!(event.ctrlKey || event.metaKey) || !controlKeys.includes(key)) {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
(_a = props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
48
59
|
};
|
|
49
60
|
const onChange = (value, event) => {
|
|
50
61
|
var _a;
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
const parsedValue = props.decimalPlaces ? parseFloat(value) : parseInt(value, 10);
|
|
63
|
+
field.onChange(parsedValue);
|
|
64
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, parsedValue, event);
|
|
53
65
|
};
|
|
54
66
|
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 }));
|
|
55
67
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/form",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.74",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"author": "UX Fans s.r.o",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@uxf/ui": "10.0.0-beta.
|
|
15
|
+
"@uxf/ui": "10.0.0-beta.74",
|
|
16
16
|
"react-hook-form": "7.44.3",
|
|
17
17
|
"coordinate-parser": "1.0.7"
|
|
18
18
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RadioGroupOptionValueId, RadioGroupProps as UIRadioGroupProps } from "@uxf/ui/radio-group";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
4
|
import { FormControlProps } from "@uxf/ui/types";
|
|
5
|
-
type OnChangeHandler = FormControlProps<
|
|
5
|
+
type OnChangeHandler = FormControlProps<RadioGroupOptionValueId | null>["onChange"];
|
|
6
6
|
export type RadioGroupProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UIRadioGroupProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
7
7
|
onChange?: OnChangeHandler;
|
|
8
8
|
requiredMessage?: string;
|
|
@@ -32,7 +32,7 @@ function RadioGroup(props) {
|
|
|
32
32
|
field.onChange(value);
|
|
33
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
34
34
|
};
|
|
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 }));
|
|
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, isFocused: props.isFocused, 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, radioSize: props.radioSize, ref: field.ref, style: props.style, value: (_e = field.value) !== null && _e !== void 0 ? _e : null, variant: props.variant }));
|
|
36
36
|
}
|
|
37
37
|
exports.RadioGroup = RadioGroup;
|
|
38
38
|
RadioGroup.displayName = "UxfFormRadioGroup";
|
|
@@ -14,15 +14,15 @@ exports.default = {
|
|
|
14
14
|
};
|
|
15
15
|
const options = [
|
|
16
16
|
{
|
|
17
|
-
|
|
17
|
+
id: "1",
|
|
18
18
|
label: "Radio one",
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
|
|
21
|
+
id: "2",
|
|
22
22
|
label: "Radio two",
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
|
|
25
|
+
id: "3",
|
|
26
26
|
label: "Radio three-sixty",
|
|
27
27
|
},
|
|
28
28
|
];
|
package/select/select.js
CHANGED
|
@@ -32,7 +32,7 @@ function Select(props) {
|
|
|
32
32
|
field.onChange(value);
|
|
33
33
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
34
34
|
};
|
|
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 }));
|
|
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, iconName: props.iconName, 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, renderOption: props.renderOption, renderSelectedOption: props.renderSelectedOption, value: field.value }));
|
|
36
36
|
}
|
|
37
37
|
exports.Select = Select;
|
|
38
38
|
Select.displayName = "UxfFormSelect";
|