@uxf/form 1.0.0-beta.99 → 1.0.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.d.ts +14 -0
- package/avatar-file-input/avatar-file-input.js +38 -0
- package/avatar-file-input/avatar-file-input.stories.d.ts +8 -0
- package/avatar-file-input/avatar-file-input.stories.js +25 -0
- package/avatar-file-input/index.d.ts +1 -0
- package/avatar-file-input/index.js +17 -0
- package/checkbox-button/checkbox-button.d.ts +11 -3
- package/checkbox-button/checkbox-button.js +12 -3
- package/checkbox-button/checkbox-button.stories.d.ts +2 -2
- package/checkbox-button/checkbox-button.stories.js +2 -2
- package/checkbox-input/checkbox-input.d.ts +15 -0
- package/checkbox-input/checkbox-input.js +38 -0
- package/checkbox-input/checkbox-input.stories.d.ts +8 -0
- package/checkbox-input/checkbox-input.stories.js +26 -0
- package/checkbox-input/index.d.ts +1 -0
- package/checkbox-input/index.js +17 -0
- package/color-radio-group/color-radio-group.d.ts +11 -4
- package/color-radio-group/color-radio-group.js +12 -3
- package/color-radio-group/color-radio-group.stories.d.ts +2 -2
- package/color-radio-group/color-radio-group.stories.js +2 -2
- package/combobox/combobox.d.ts +11 -4
- package/combobox/combobox.js +12 -3
- package/combobox/combobox.stories.d.ts +2 -2
- package/combobox/combobox.stories.js +4 -3
- package/date-picker-input/date-picker-input.d.ts +9 -3
- package/date-picker-input/date-picker-input.js +63 -4
- package/date-picker-input/date-picker-input.stories.d.ts +2 -2
- package/date-picker-input/date-picker-input.stories.js +8 -3
- package/datetime-picker-input/datetime-picker-input.d.ts +13 -0
- package/datetime-picker-input/datetime-picker-input.js +90 -0
- package/datetime-picker-input/datetime-picker-input.stories.d.ts +8 -0
- package/datetime-picker-input/datetime-picker-input.stories.js +28 -0
- package/datetime-picker-input/index.d.ts +1 -0
- package/datetime-picker-input/index.js +17 -0
- package/dropzone/dropzone-input.d.ts +16 -0
- package/dropzone/dropzone-input.js +58 -0
- package/dropzone/dropzone-list.d.ts +14 -0
- package/dropzone/dropzone-list.js +23 -0
- package/dropzone/dropzone.stories.d.ts +9 -0
- package/dropzone/dropzone.stories.js +42 -0
- package/dropzone/index.d.ts +7 -0
- package/dropzone/index.js +6 -0
- package/file-input/file-input.d.ts +14 -0
- package/file-input/file-input.js +38 -0
- package/file-input/file-input.stories.d.ts +8 -0
- package/file-input/file-input.stories.js +31 -0
- package/file-input/index.d.ts +1 -0
- package/file-input/index.js +17 -0
- package/form/form.d.ts +13 -11
- package/form/form.js +10 -38
- package/form/form.stories.d.ts +2 -2
- 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.d.ts +18 -0
- package/gps-input/gps-input.js +153 -0
- package/gps-input/gps-input.stories.d.ts +8 -0
- package/gps-input/gps-input.stories.js +24 -0
- package/gps-input/index.d.ts +1 -0
- package/{checkbox → gps-input}/index.js +1 -1
- package/multi-combobox/multi-combobox.d.ts +11 -4
- package/multi-combobox/multi-combobox.js +13 -4
- package/multi-combobox/multi-combobox.stories.d.ts +2 -2
- package/multi-combobox/multi-combobox.stories.js +18 -7
- package/multi-select/index.d.ts +1 -0
- package/multi-select/index.js +17 -0
- package/multi-select/multi-select.d.ts +14 -0
- package/multi-select/multi-select.js +38 -0
- package/multi-select/multi-select.stories.d.ts +8 -0
- package/multi-select/multi-select.stories.js +41 -0
- package/number-input/number-input.d.ts +10 -3
- package/number-input/number-input.js +12 -3
- package/number-input/number-input.stories.d.ts +2 -2
- package/number-input/number-input.stories.js +2 -2
- package/package.json +6 -6
- package/radio-group/radio-group.d.ts +11 -4
- package/radio-group/radio-group.js +12 -3
- package/radio-group/radio-group.stories.d.ts +2 -2
- package/radio-group/radio-group.stories.js +2 -2
- package/select/select.d.ts +11 -4
- package/select/select.js +12 -3
- package/select/select.stories.d.ts +2 -2
- package/select/select.stories.js +10 -3
- package/storybook/form-data-printer.d.ts +2 -2
- package/storybook/storybook-form.d.ts +7 -0
- package/storybook/{form.js → storybook-form.js} +7 -6
- package/text-input/text-input.d.ts +11 -4
- package/text-input/text-input.js +14 -5
- package/text-input/text-input.stories.d.ts +2 -2
- package/text-input/text-input.stories.js +7 -7
- package/textarea/textarea.d.ts +10 -3
- package/textarea/textarea.js +12 -3
- package/textarea/textarea.stories.d.ts +2 -2
- package/textarea/textarea.stories.js +2 -2
- package/time-picker-input/time-picker-input.d.ts +8 -3
- package/time-picker-input/time-picker-input.js +51 -3
- package/time-picker-input/time-picker-input.stories.d.ts +2 -2
- package/time-picker-input/time-picker-input.stories.js +7 -3
- package/toggle/toggle.d.ts +11 -3
- package/toggle/toggle.js +12 -3
- package/toggle/toggle.stories.d.ts +2 -2
- package/toggle/toggle.stories.js +2 -2
- package/checkbox/checkbox.d.ts +0 -7
- package/checkbox/checkbox.js +0 -29
- package/checkbox/checkbox.stories.d.ts +0 -8
- package/checkbox/checkbox.stories.js +0 -26
- package/checkbox/index.d.ts +0 -1
- package/storybook/form.d.ts +0 -7
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/form",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "
|
|
10
|
-
"compile": "tsc -P tsconfig.json",
|
|
9
|
+
"build": "tsc -P tsconfig.json",
|
|
11
10
|
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
12
11
|
},
|
|
13
12
|
"author": "UX Fans s.r.o",
|
|
14
13
|
"license": "MIT",
|
|
15
14
|
"dependencies": {
|
|
16
|
-
"@uxf/ui": "
|
|
17
|
-
"react-hook-form": "
|
|
15
|
+
"@uxf/ui": "1.0.0",
|
|
16
|
+
"react-hook-form": "7.44.3",
|
|
17
|
+
"coordinate-parser": "1.0.7"
|
|
18
18
|
}
|
|
19
|
-
}
|
|
19
|
+
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import { RadioGroupOptionValue, RadioGroupProps as UIRadioGroupProps } from "@uxf/ui/radio-group";
|
|
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<RadioGroupOptionValue | null>["onChange"];
|
|
6
|
+
export type RadioGroupProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UIRadioGroupProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
7
|
+
onChange?: OnChangeHandler;
|
|
5
8
|
requiredMessage?: string;
|
|
6
9
|
};
|
|
7
|
-
export declare function RadioGroup<FormData extends Record<string, any>>(props: RadioGroupProps<FormData>): JSX.Element;
|
|
10
|
+
export declare function RadioGroup<FormData extends Record<string, any>>(props: RadioGroupProps<FormData>): React.JSX.Element;
|
|
11
|
+
export declare namespace RadioGroup {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -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;
|
|
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
|
});
|
|
@@ -24,6 +27,12 @@ function RadioGroup(props) {
|
|
|
24
27
|
field.onBlur();
|
|
25
28
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
26
29
|
};
|
|
27
|
-
|
|
30
|
+
const onChange = (value, event) => {
|
|
31
|
+
var _a;
|
|
32
|
+
field.onChange(value);
|
|
33
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
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 }));
|
|
28
36
|
}
|
|
29
37
|
exports.RadioGroup = RadioGroup;
|
|
38
|
+
RadioGroup.displayName = "UxfFormRadioGroup";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { RadioGroup } from "./index";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: typeof RadioGroup;
|
|
6
6
|
};
|
|
7
7
|
export default _default;
|
|
8
|
-
export declare function Default(): JSX.Element;
|
|
8
|
+
export declare function Default(): React.JSX.Element;
|
|
@@ -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.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { SelectProps as UISelectProps } from "@uxf/ui/select";
|
|
1
|
+
import { SelectProps as UISelectProps, SelectValue } from "@uxf/ui/select";
|
|
3
2
|
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
|
-
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { FormControlProps } from "@uxf/ui/types";
|
|
5
|
+
type OnChangeHandler = FormControlProps<SelectValue | null>["onChange"];
|
|
6
|
+
export type SelectProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UISelectProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
7
|
+
onChange?: OnChangeHandler;
|
|
5
8
|
requiredMessage?: string;
|
|
6
9
|
};
|
|
7
|
-
export declare function Select<FormData extends Record<string, any>>(props: SelectProps<FormData>): JSX.Element;
|
|
10
|
+
export declare function Select<FormData extends Record<string, any>>(props: SelectProps<FormData>): React.JSX.Element;
|
|
11
|
+
export declare namespace Select {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
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
|
});
|
|
@@ -24,6 +27,12 @@ function Select(props) {
|
|
|
24
27
|
field.onBlur();
|
|
25
28
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
26
29
|
};
|
|
27
|
-
|
|
30
|
+
const onChange = (value, event) => {
|
|
31
|
+
var _a;
|
|
32
|
+
field.onChange(value);
|
|
33
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
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 }));
|
|
28
36
|
}
|
|
29
37
|
exports.Select = Select;
|
|
38
|
+
Select.displayName = "UxfFormSelect";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { Select } from "./select";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: typeof Select;
|
|
6
6
|
};
|
|
7
7
|
export default _default;
|
|
8
|
-
export declare function Default(): JSX.Element;
|
|
8
|
+
export declare function Default(): React.JSX.Element;
|
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",
|
|
@@ -17,14 +17,21 @@ const options = [
|
|
|
17
17
|
{ id: "two", label: "Option two" },
|
|
18
18
|
{ id: "three", label: "Option three" },
|
|
19
19
|
];
|
|
20
|
+
const numberOptions = [
|
|
21
|
+
{ id: 0, label: "Option zero" },
|
|
22
|
+
{ id: 1, label: "Option one" },
|
|
23
|
+
{ id: 2, label: "Option two" },
|
|
24
|
+
];
|
|
20
25
|
function Default() {
|
|
21
26
|
const storyFormSelects = (control) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
22
|
-
react_1.default.createElement(select_1.Select, { label: "Select form", name: "select", control: control, placeholder: "placeholder", options: options, id: "form-select" }),
|
|
27
|
+
react_1.default.createElement(select_1.Select, { label: "Select form", name: "select", control: control, placeholder: "placeholder", options: options, id: "form-select", isClearable: true }),
|
|
23
28
|
react_1.default.createElement(select_1.Select, { label: "Select form disabled", name: "select-disabled", control: control, placeholder: "placeholder", options: options, id: "form-select", isDisabled: true }),
|
|
24
29
|
react_1.default.createElement(select_1.Select, { label: "Select form with helper text", name: "select-helper-text", control: control, placeholder: "placeholder", options: options, id: "form-select", helperText: "Choose one option" }),
|
|
25
30
|
react_1.default.createElement(select_1.Select, { label: "Select form with dropdown top", dropdownPlacement: "top", name: "select-dropdown-top", control: control, placeholder: "placeholder", options: options, id: "form-select" }),
|
|
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
|
+
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 }),
|
|
26
33
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
27
|
-
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" },
|
|
28
35
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormSelects(control)),
|
|
29
36
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormSelects(control))))));
|
|
30
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
interface FormDataPrinterProps {
|
|
3
3
|
control: any;
|
|
4
4
|
}
|
|
5
|
-
export declare function FormDataPrinter(props: FormDataPrinterProps): JSX.Element;
|
|
5
|
+
export declare function FormDataPrinter(props: FormDataPrinterProps): React.JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { UseFormProps, UseFormReturn } from "react-hook-form";
|
|
3
|
+
interface FormProps extends UseFormProps {
|
|
4
|
+
children: (form: UseFormReturn) => ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function StorybookForm(props: FormProps): React.JSX.Element;
|
|
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
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
9
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
10
10
|
const form_data_printer_1 = require("./form-data-printer");
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const form_1 = require("../form");
|
|
12
|
+
function StorybookForm(props) {
|
|
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;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TextInputProps as UITextInputProps } from "@uxf/ui/text-input";
|
|
3
2
|
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
|
-
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { FormControlProps } from "@uxf/ui/types";
|
|
5
|
+
type OnChangeHandler = FormControlProps<string>["onChange"];
|
|
6
|
+
export type TextInputProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UITextInputProps, "isInvalid" | "max" | "min" | "pattern" | "step" | "name" | "onChange" | "value" | "type"> & {
|
|
7
|
+
onChange?: OnChangeHandler;
|
|
5
8
|
requiredMessage?: string;
|
|
6
9
|
} & ({
|
|
7
10
|
type: "email";
|
|
@@ -12,8 +15,12 @@ export declare type TextInputProps<FormData extends FieldValues> = UseController
|
|
|
12
15
|
invalidEmailMessage?: never;
|
|
13
16
|
invalidPhoneMessage?: string;
|
|
14
17
|
} | {
|
|
15
|
-
type?: "password" | "search" | "text" | "url";
|
|
16
18
|
invalidEmailMessage?: never;
|
|
17
19
|
invalidPhoneMessage?: never;
|
|
20
|
+
type?: "password" | "search" | "text" | "url";
|
|
18
21
|
});
|
|
19
|
-
export declare function TextInput<FormData extends FieldValues>(props: TextInputProps<FormData>): JSX.Element;
|
|
22
|
+
export declare function TextInput<FormData extends FieldValues>(props: TextInputProps<FormData>): React.JSX.Element;
|
|
23
|
+
export declare namespace TextInput {
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
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
|
});
|
|
@@ -37,6 +40,12 @@ function TextInput(props) {
|
|
|
37
40
|
field.onBlur();
|
|
38
41
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
39
42
|
};
|
|
40
|
-
|
|
43
|
+
const onChange = (value, event) => {
|
|
44
|
+
var _a;
|
|
45
|
+
field.onChange(value);
|
|
46
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
47
|
+
};
|
|
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 }));
|
|
41
49
|
}
|
|
42
50
|
exports.TextInput = TextInput;
|
|
51
|
+
TextInput.displayName = "UxfFormTextInput";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { TextInput } from "./text-input";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: typeof TextInput;
|
|
6
6
|
};
|
|
7
7
|
export default _default;
|
|
8
|
-
export declare function Default(): JSX.Element;
|
|
8
|
+
export declare function Default(): React.JSX.Element;
|
|
@@ -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",
|
|
@@ -14,13 +14,13 @@ 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, { placeholder: "Zadejte
|
|
18
|
-
react_1.default.createElement(text_input_1.TextInput, { placeholder: "Zadejte
|
|
19
|
-
react_1.default.createElement(text_input_1.TextInput, { placeholder: "Zadejte
|
|
20
|
-
react_1.default.createElement(text_input_1.TextInput, { placeholder: "Zadejte
|
|
21
|
-
react_1.default.createElement(text_input_1.TextInput, { placeholder: "Zadejte
|
|
17
|
+
react_1.default.createElement(text_input_1.TextInput, { placeholder: "Zadejte...", label: "Default input", name: "default", control: control, autoComplete: "off" }),
|
|
18
|
+
react_1.default.createElement(text_input_1.TextInput, { placeholder: "Zadejte...", label: "Required input", name: "required", control: control, isRequired: true }),
|
|
19
|
+
react_1.default.createElement(text_input_1.TextInput, { placeholder: "Zadejte...", label: "E-mail required input", name: "email", type: "email", control: control, isRequired: true }),
|
|
20
|
+
react_1.default.createElement(text_input_1.TextInput, { placeholder: "Zadejte...", label: "Phone required input", name: "phone", type: "tel", control: control, isRequired: true }),
|
|
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.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TextareaProps as UITextareaProps } from "@uxf/ui/textarea";
|
|
3
2
|
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
|
-
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { FormControlProps } from "@uxf/ui/types";
|
|
5
|
+
type OnChangeHandler = FormControlProps<string, HTMLTextAreaElement>["onChange"];
|
|
6
|
+
export type TextareaProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UITextareaProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
7
|
+
onChange?: OnChangeHandler;
|
|
5
8
|
requiredMessage?: string;
|
|
6
9
|
};
|
|
7
|
-
export declare function Textarea<FormData extends Record<string, any>>(props: TextareaProps<FormData>): JSX.Element;
|
|
10
|
+
export declare function Textarea<FormData extends Record<string, any>>(props: TextareaProps<FormData>): React.JSX.Element;
|
|
11
|
+
export declare namespace Textarea {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
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
|
});
|
|
@@ -44,6 +47,12 @@ function Textarea(props) {
|
|
|
44
47
|
field.onBlur();
|
|
45
48
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
46
49
|
}, [field, props]);
|
|
47
|
-
|
|
50
|
+
const onChange = (value, event) => {
|
|
51
|
+
var _a;
|
|
52
|
+
field.onChange(value);
|
|
53
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
54
|
+
};
|
|
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 || "" }));
|
|
48
56
|
}
|
|
49
57
|
exports.Textarea = Textarea;
|
|
58
|
+
Textarea.displayName = "UxfFormTextarea";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { Textarea } from "./textarea";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: typeof Textarea;
|
|
6
6
|
};
|
|
7
7
|
export default _default;
|
|
8
|
-
export declare function Default(): JSX.Element;
|
|
8
|
+
export declare function Default(): React.JSX.Element;
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TimePickerInputProps as UITimePickerInputProps } from "@uxf/ui/time-picker-input";
|
|
3
2
|
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
|
-
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { DatePickerInputProps as UIDatePickerInputProps } from "@uxf/ui/date-picker-input";
|
|
5
|
+
export type TimePickerInputProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UITimePickerInputProps, "isInvalid" | "max" | "min" | "pattern" | "step" | "name" | "onChange" | "value"> & {
|
|
6
|
+
onChange?: UIDatePickerInputProps["onChange"];
|
|
5
7
|
requiredMessage?: string;
|
|
6
8
|
};
|
|
7
|
-
export declare function TimePickerInput<FormData extends FieldValues>(props: TimePickerInputProps<FormData>): JSX.Element;
|
|
9
|
+
export declare function TimePickerInput<FormData extends FieldValues>(props: TimePickerInputProps<FormData>): React.JSX.Element;
|
|
10
|
+
export declare namespace TimePickerInput {
|
|
11
|
+
var displayName: string;
|
|
12
|
+
}
|
|
@@ -1,4 +1,27 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
@@ -7,15 +30,34 @@ exports.TimePickerInput = void 0;
|
|
|
7
30
|
const time_picker_input_1 = require("@uxf/ui/time-picker-input");
|
|
8
31
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
32
|
const react_1 = __importDefault(require("react"));
|
|
33
|
+
const dayjs_1 = __importStar(require("dayjs"));
|
|
34
|
+
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
35
|
+
const form_id_context_1 = require("../form-id-context");
|
|
36
|
+
(0, dayjs_1.extend)(customParseFormat_1.default);
|
|
10
37
|
function TimePickerInput(props) {
|
|
11
|
-
var _a, _b, _c;
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
39
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
40
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
12
41
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
13
42
|
control: props.control,
|
|
14
43
|
defaultValue: props.defaultValue,
|
|
15
44
|
name: props.name,
|
|
16
45
|
rules: {
|
|
17
46
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
18
|
-
...((
|
|
47
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
48
|
+
validate: {
|
|
49
|
+
validTime: (value) => {
|
|
50
|
+
if (!value) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!(0, dayjs_1.default)(value, time_picker_input_1.OUTPUT_TIME_FORMAT, true).isValid()) {
|
|
54
|
+
return `Čas musí být ve formátu ${time_picker_input_1.DISPLAY_TIME_FORMAT}.`;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
...(typeof ((_c = props.rules) === null || _c === void 0 ? void 0 : _c.validate) === "function"
|
|
58
|
+
? { custom: props.rules.validate }
|
|
59
|
+
: (_e = (_d = props.rules) === null || _d === void 0 ? void 0 : _d.validate) !== null && _e !== void 0 ? _e : {}),
|
|
60
|
+
},
|
|
19
61
|
},
|
|
20
62
|
shouldUnregister: props.shouldUnregister,
|
|
21
63
|
});
|
|
@@ -24,6 +66,12 @@ function TimePickerInput(props) {
|
|
|
24
66
|
field.onBlur();
|
|
25
67
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
26
68
|
};
|
|
27
|
-
|
|
69
|
+
const onChange = (value, event) => {
|
|
70
|
+
var _a;
|
|
71
|
+
field.onChange(value);
|
|
72
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
73
|
+
};
|
|
74
|
+
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: field.value, variant: props.variant }));
|
|
28
75
|
}
|
|
29
76
|
exports.TimePickerInput = TimePickerInput;
|
|
77
|
+
TimePickerInput.displayName = "UxfFormTimePickerInput";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { TimePickerInput } from "./time-picker-input";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: typeof TimePickerInput;
|
|
6
6
|
};
|
|
7
7
|
export default _default;
|
|
8
|
-
export declare function Default(): JSX.Element;
|
|
8
|
+
export declare function Default(): React.JSX.Element;
|
|
@@ -6,17 +6,21 @@ 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
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
11
12
|
exports.default = {
|
|
12
13
|
title: "Form/TimePickerInput",
|
|
13
14
|
component: time_picker_input_1.TimePickerInput,
|
|
14
15
|
};
|
|
15
16
|
function Default() {
|
|
16
17
|
const storyFormDatePickers = (control) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
17
|
-
react_1.default.createElement(time_picker_input_1.TimePickerInput, { label: "Default
|
|
18
|
+
react_1.default.createElement(time_picker_input_1.TimePickerInput, { control: control, isClearable: true, label: "Default time picker", name: "default", placeholder: "" }),
|
|
19
|
+
react_1.default.createElement(time_picker_input_1.TimePickerInput, { control: control, isClearable: true, label: "Default time picker with default value", name: "withDefaultValue", placeholder: "" }),
|
|
18
20
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
19
|
-
return (react_1.default.createElement(
|
|
21
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, { defaultValues: {
|
|
22
|
+
withDefaultValue: (0, dayjs_1.default)().format("HH:mm:ss"),
|
|
23
|
+
} }, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
20
24
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormDatePickers(control)),
|
|
21
25
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 text-white lg:w-1/2" }, storyFormDatePickers(control))))));
|
|
22
26
|
}
|