@uxf/form 1.0.0-beta.99 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- 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/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AvatarFileInputProps as UIAvatarFileInputProps } from "@uxf/ui/avatar-file-input";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
|
+
import { FileResponse, FormControlProps } from "@uxf/ui/types";
|
|
5
|
+
type OnChangeHandler = FormControlProps<FileResponse | null>["onChange"];
|
|
6
|
+
export type AvatarFileInputProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UIAvatarFileInputProps, "isInvalid" | "onChange" | "value"> & {
|
|
7
|
+
onChange?: OnChangeHandler;
|
|
8
|
+
requiredMessage?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function AvatarFileInput<FormData extends FieldValues>(props: AvatarFileInputProps<FormData>): React.JSX.Element;
|
|
11
|
+
export declare namespace AvatarFileInput {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
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.AvatarFileInput = void 0;
|
|
7
|
+
const avatar_file_input_1 = require("@uxf/ui/avatar-file-input");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
10
|
+
const form_id_context_1 = require("../form-id-context");
|
|
11
|
+
function AvatarFileInput(props) {
|
|
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}`;
|
|
15
|
+
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
16
|
+
control: props.control,
|
|
17
|
+
defaultValue: props.defaultValue,
|
|
18
|
+
name: props.name,
|
|
19
|
+
rules: {
|
|
20
|
+
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
21
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
22
|
+
},
|
|
23
|
+
shouldUnregister: props.shouldUnregister,
|
|
24
|
+
});
|
|
25
|
+
const onBlur = (event) => {
|
|
26
|
+
var _a;
|
|
27
|
+
field.onBlur();
|
|
28
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
29
|
+
};
|
|
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(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 }));
|
|
36
|
+
}
|
|
37
|
+
exports.AvatarFileInput = AvatarFileInput;
|
|
38
|
+
AvatarFileInput.displayName = "UxfFormAvatarFileInput";
|
|
@@ -0,0 +1,25 @@
|
|
|
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 button_1 = require("@uxf/ui/button");
|
|
8
|
+
const uploadFIle_mock_1 = require("@uxf/ui/utils/mocks/uploadFIle.mock");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
11
|
+
const avatar_file_input_1 = require("./avatar-file-input");
|
|
12
|
+
exports.default = {
|
|
13
|
+
title: "Form/AvatarFileInput",
|
|
14
|
+
component: avatar_file_input_1.AvatarFileInput,
|
|
15
|
+
};
|
|
16
|
+
function Default() {
|
|
17
|
+
const storyFormAvatarFileInputs = (control, mode) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
18
|
+
react_1.default.createElement(avatar_file_input_1.AvatarFileInput, { control: control, label: "Default file input", name: `default-${mode}`, onUploadFile: uploadFIle_mock_1.uploadFile }),
|
|
19
|
+
react_1.default.createElement(avatar_file_input_1.AvatarFileInput, { control: control, id: `required-${mode}`, isRequired: true, label: "Required file input", name: `required-${mode}`, onUploadFile: uploadFIle_mock_1.uploadFile }),
|
|
20
|
+
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
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
|
+
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormAvatarFileInputs(control, "light")),
|
|
23
|
+
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormAvatarFileInputs(control, "dark"))))));
|
|
24
|
+
}
|
|
25
|
+
exports.Default = Default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./avatar-file-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("./avatar-file-input"), exports);
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { CheckboxButtonProps as UICheckboxButtonProps } from "@uxf/ui/checkbox-button";
|
|
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<boolean | undefined>["onChange"];
|
|
6
|
+
export type ComboProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UICheckboxButtonProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
7
|
+
nullable?: boolean;
|
|
8
|
+
onChange?: OnChangeHandler;
|
|
5
9
|
requiredMessage?: string;
|
|
6
10
|
};
|
|
7
|
-
export declare function CheckboxButton<FormData extends Record<string, any>>(props: ComboProps<FormData>): JSX.Element;
|
|
11
|
+
export declare function CheckboxButton<FormData extends Record<string, any>>(props: ComboProps<FormData>): React.JSX.Element;
|
|
12
|
+
export declare namespace CheckboxButton {
|
|
13
|
+
var displayName: string;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -7,15 +7,18 @@ exports.CheckboxButton = void 0;
|
|
|
7
7
|
const checkbox_button_1 = require("@uxf/ui/checkbox-button");
|
|
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 CheckboxButton(props) {
|
|
11
|
-
var _a;
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
14
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
12
15
|
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
13
16
|
control: props.control,
|
|
14
17
|
defaultValue: props.defaultValue,
|
|
15
18
|
name: props.name,
|
|
16
19
|
rules: {
|
|
17
20
|
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
18
|
-
...((
|
|
21
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
19
22
|
},
|
|
20
23
|
shouldUnregister: props.shouldUnregister,
|
|
21
24
|
});
|
|
@@ -24,6 +27,12 @@ function CheckboxButton(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(checkbox_button_1.CheckboxButton, { 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) }));
|
|
28
36
|
}
|
|
29
37
|
exports.CheckboxButton = CheckboxButton;
|
|
38
|
+
CheckboxButton.displayName = "UxfFormCheckboxButton";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { CheckboxButton } from "./checkbox-button";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: typeof CheckboxButton;
|
|
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 checkbox_button_1 = require("./checkbox-button");
|
|
11
11
|
exports.default = {
|
|
12
12
|
title: "Form/CheckboxButton",
|
|
@@ -19,7 +19,7 @@ function Default() {
|
|
|
19
19
|
react_1.default.createElement(checkbox_button_1.CheckboxButton, { label: "CheckboxButton form disabled", name: "checkbox-button-disabled", control: control, isDisabled: true }),
|
|
20
20
|
react_1.default.createElement(checkbox_button_1.CheckboxButton, { label: "CheckboxButton form readOnly", name: "checkbox-button-read-only", control: control, isReadOnly: true }),
|
|
21
21
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
22
|
-
return (react_1.default.createElement(
|
|
22
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
23
23
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormCheckboxes(control)),
|
|
24
24
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormCheckboxes(control))))));
|
|
25
25
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CheckboxInputProps as UICheckboxInputProps } from "@uxf/ui/checkbox-input";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
|
+
import { FormControlProps } from "@uxf/ui/types";
|
|
5
|
+
type OnChangeHandler = FormControlProps<boolean | undefined>["onChange"];
|
|
6
|
+
export type ComboProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UICheckboxInputProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
7
|
+
nullable?: boolean;
|
|
8
|
+
onChange?: OnChangeHandler;
|
|
9
|
+
requiredMessage?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function CheckboxInput<FormData extends Record<string, any>>(props: ComboProps<FormData>): React.JSX.Element;
|
|
12
|
+
export declare namespace CheckboxInput {
|
|
13
|
+
var displayName: string;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
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.CheckboxInput = void 0;
|
|
7
|
+
const checkbox_input_1 = require("@uxf/ui/checkbox-input");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
10
|
+
const form_id_context_1 = require("../form-id-context");
|
|
11
|
+
function CheckboxInput(props) {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const formId = (0, form_id_context_1.useFormIdContext)();
|
|
14
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formId}__${props.name}`;
|
|
15
|
+
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
16
|
+
control: props.control,
|
|
17
|
+
defaultValue: props.defaultValue,
|
|
18
|
+
name: props.name,
|
|
19
|
+
rules: {
|
|
20
|
+
required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
|
|
21
|
+
...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
|
|
22
|
+
},
|
|
23
|
+
shouldUnregister: props.shouldUnregister,
|
|
24
|
+
});
|
|
25
|
+
const onBlur = (event) => {
|
|
26
|
+
var _a;
|
|
27
|
+
field.onBlur();
|
|
28
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
29
|
+
};
|
|
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(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) }));
|
|
36
|
+
}
|
|
37
|
+
exports.CheckboxInput = CheckboxInput;
|
|
38
|
+
CheckboxInput.displayName = "UxfFormCheckboxInput";
|
|
@@ -0,0 +1,26 @@
|
|
|
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 storybook_form_1 = require("../storybook/storybook-form");
|
|
9
|
+
const checkbox_input_1 = require("./checkbox-input");
|
|
10
|
+
const button_1 = require("@uxf/ui/button");
|
|
11
|
+
exports.default = {
|
|
12
|
+
title: "Form/CheckboxInput",
|
|
13
|
+
component: checkbox_input_1.CheckboxInput,
|
|
14
|
+
};
|
|
15
|
+
function Default() {
|
|
16
|
+
const storyFormCheckboxes = (control) => (react_1.default.createElement("div", { className: "space-y-2" },
|
|
17
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { label: "CheckboxInput form", name: "checkbox1", control: control }),
|
|
18
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { label: "CheckboxInput form required", name: "checkbox-required", control: control, isRequired: true }),
|
|
19
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { label: "CheckboxInput form disabled", name: "checkbox-disabled", control: control, isDisabled: true }),
|
|
20
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { label: "CheckboxInput form readOnly", name: "checkbox-readonly", control: control, isReadOnly: true }),
|
|
21
|
+
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
22
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
23
|
+
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormCheckboxes(control)),
|
|
24
|
+
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormCheckboxes(control))))));
|
|
25
|
+
}
|
|
26
|
+
exports.Default = Default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./checkbox-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("./checkbox-input"), exports);
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import { ColorRadioGroupOptionValue, ColorRadioGroupProps as UIColorRadioGroupProps } from "@uxf/ui/color-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<ColorRadioGroupOptionValue | null>["onChange"];
|
|
6
|
+
export type ColorRadioGroupProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UIColorRadioGroupProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
7
|
+
onChange?: OnChangeHandler;
|
|
5
8
|
requiredMessage?: string;
|
|
6
9
|
};
|
|
7
|
-
export declare function ColorRadioGroup<FormData extends Record<string, any>>(props: ColorRadioGroupProps<FormData>): JSX.Element;
|
|
10
|
+
export declare function ColorRadioGroup<FormData extends Record<string, any>>(props: ColorRadioGroupProps<FormData>): React.JSX.Element;
|
|
11
|
+
export declare namespace ColorRadioGroup {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -7,15 +7,18 @@ exports.ColorRadioGroup = void 0;
|
|
|
7
7
|
const color_radio_group_1 = require("@uxf/ui/color-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 ColorRadioGroup(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 ColorRadioGroup(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(color_radio_group_1.ColorRadioGroup, { className: props.className, 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 }));
|
|
28
36
|
}
|
|
29
37
|
exports.ColorRadioGroup = ColorRadioGroup;
|
|
38
|
+
ColorRadioGroup.displayName = "UxfFormColorRadioGroup";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { ColorRadioGroup } from "./index";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: typeof ColorRadioGroup;
|
|
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/ColorRadioGroup",
|
|
@@ -57,7 +57,7 @@ function Default() {
|
|
|
57
57
|
react_1.default.createElement(index_1.ColorRadioGroup, { control: control, helperText: "Choose one option", id: "color-radio-group", label: "Color radio group form with helper text", name: "color-radio-group-helper-text", options: options }),
|
|
58
58
|
react_1.default.createElement(index_1.ColorRadioGroup, { control: control, id: "color-radio-group", label: "Color radio group form with variant button", name: "color-radio-group-button", options: options }),
|
|
59
59
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
60
|
-
return (react_1.default.createElement(
|
|
60
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
61
61
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormColorRadioGroup(control)),
|
|
62
62
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormColorRadioGroup(control))))));
|
|
63
63
|
}
|
package/combobox/combobox.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { ComboboxProps as UIComboboxProps } from "@uxf/ui/combobox";
|
|
1
|
+
import { ComboboxProps as UIComboboxProps, ComboboxValue } from "@uxf/ui/combobox";
|
|
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<ComboboxValue | null>["onChange"];
|
|
6
|
+
export type ComboProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UIComboboxProps, "isInvalid" | "name" | "onChange" | "value"> & {
|
|
7
|
+
onChange?: OnChangeHandler;
|
|
5
8
|
requiredMessage?: string;
|
|
6
9
|
};
|
|
7
|
-
export declare function Combobox<FormData extends Record<string, any>>(props: ComboProps<FormData>): JSX.Element;
|
|
10
|
+
export declare function Combobox<FormData extends Record<string, any>>(props: ComboProps<FormData>): React.JSX.Element;
|
|
11
|
+
export declare namespace Combobox {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
package/combobox/combobox.js
CHANGED
|
@@ -7,15 +7,18 @@ exports.Combobox = void 0;
|
|
|
7
7
|
const combobox_1 = require("@uxf/ui/combobox");
|
|
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 Combobox(props) {
|
|
11
|
-
var _a, _b, _c;
|
|
12
|
+
var _a, _b, _c, _d, _e, _f;
|
|
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 Combobox(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(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 }));
|
|
28
36
|
}
|
|
29
37
|
exports.Combobox = Combobox;
|
|
38
|
+
Combobox.displayName = "UxfFormCombobox";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { Combobox } from "./combobox";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
5
|
component: typeof Combobox;
|
|
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 combobox_1 = require("./combobox");
|
|
10
10
|
const button_1 = require("@uxf/ui/button");
|
|
11
11
|
exports.default = {
|
|
@@ -19,12 +19,13 @@ const options = [
|
|
|
19
19
|
];
|
|
20
20
|
function Default() {
|
|
21
21
|
const storyFormComboboxes = (control) => (react_1.default.createElement("div", { className: "space-y-8" },
|
|
22
|
-
react_1.default.createElement(combobox_1.Combobox, { label: "Combobox form", name: "
|
|
22
|
+
react_1.default.createElement(combobox_1.Combobox, { label: "Combobox form", name: "firstname", control: control, placeholder: "Placeholder", options: options, id: "form-combobox", helperText: "Za\u010Dn\u011Bte ps\u00E1t pro vyhled\u00E1v\u00E1n\u00ED..." }),
|
|
23
23
|
react_1.default.createElement(combobox_1.Combobox, { label: "Combobox form required", name: "combobox-required", control: control, placeholder: "Placeholder", options: options, id: "form-combobox", isRequired: true, helperText: "Za\u010Dn\u011Bte ps\u00E1t pro vyhled\u00E1v\u00E1n\u00ED..." }),
|
|
24
24
|
react_1.default.createElement(combobox_1.Combobox, { label: "Combobox form disabled", name: "combobox-disabled", control: control, placeholder: "Placeholder", options: options, id: "form-combobox", isDisabled: true }),
|
|
25
25
|
react_1.default.createElement(combobox_1.Combobox, { label: "Combobox form with dropdown top", dropdownPlacement: "top", name: "select-dropdown-top", control: control, placeholder: "Placeholder", options: options, id: "form-combobox" }),
|
|
26
|
+
react_1.default.createElement(combobox_1.Combobox, { label: "Combobox async", dropdownPlacement: "top", name: "select-dropdown-async", control: control, placeholder: "Placeholder", loadOptions: (query) => Promise.resolve(options.filter((option) => !query || option.label.toLowerCase().includes(query.toLowerCase()))), id: "form-combobox", isClearable: true }),
|
|
26
27
|
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
27
|
-
return (react_1.default.createElement(
|
|
28
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, { defaultValues: { "select-dropdown-async": { id: "one", label: "Option one" } } }, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
28
29
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyFormComboboxes(control)),
|
|
29
30
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyFormComboboxes(control))))));
|
|
30
31
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { DatePickerInputProps as UIDatePickerInputProps } from "@uxf/ui/date-picker-input";
|
|
2
|
+
import React from "react";
|
|
3
3
|
import { FieldValues, UseControllerProps } from "react-hook-form";
|
|
4
|
-
export
|
|
4
|
+
export type DatePickerInputProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UIDatePickerInputProps, "isInvalid" | "max" | "min" | "pattern" | "step" | "name" | "onChange" | "value"> & {
|
|
5
|
+
onChange?: UIDatePickerInputProps["onChange"];
|
|
5
6
|
requiredMessage?: string;
|
|
7
|
+
minDate?: string;
|
|
8
|
+
maxDate?: string;
|
|
6
9
|
};
|
|
7
|
-
export declare function DatePickerInput<FormData extends FieldValues>(props: DatePickerInputProps<FormData>): JSX.Element;
|
|
10
|
+
export declare function DatePickerInput<FormData extends FieldValues>(props: DatePickerInputProps<FormData>): React.JSX.Element;
|
|
11
|
+
export declare namespace DatePickerInput {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|