@uxf/form 11.74.0 → 11.74.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/_code-generator/form-code-generator.d.ts +16 -0
- package/_code-generator/form-code-generator.js +69 -0
- package/avatar-file-input/avatar-file-input.d.ts +14 -0
- package/avatar-file-input/avatar-file-input.js +42 -0
- package/avatar-file-input/avatar-file-input.stories.d.ts +8 -0
- package/avatar-file-input/avatar-file-input.stories.js +23 -0
- package/avatar-file-input/index.d.ts +1 -0
- package/avatar-file-input/index.js +17 -0
- package/avatar-file-input/translations.d.ts +13 -0
- package/avatar-file-input/translations.js +14 -0
- package/bin/form-code-generator.d.ts +2 -0
- package/bin/form-code-generator.js +55 -0
- package/checkbox-button/checkbox-button.d.ts +14 -0
- package/checkbox-button/checkbox-button.js +42 -0
- package/checkbox-button/checkbox-button.stories.d.ts +8 -0
- package/checkbox-button/checkbox-button.stories.js +24 -0
- package/checkbox-button/index.d.ts +1 -0
- package/checkbox-button/index.js +17 -0
- package/checkbox-button/translations.d.ts +13 -0
- package/checkbox-button/translations.js +14 -0
- package/checkbox-input/checkbox-input.d.ts +14 -0
- package/checkbox-input/checkbox-input.js +42 -0
- package/checkbox-input/checkbox-input.stories.d.ts +8 -0
- package/checkbox-input/checkbox-input.stories.js +24 -0
- package/checkbox-input/index.d.ts +1 -0
- package/checkbox-input/index.js +17 -0
- package/checkbox-input/translations.d.ts +13 -0
- package/checkbox-input/translations.js +14 -0
- package/checkbox-list/checkbox-list.d.ts +19 -0
- package/checkbox-list/checkbox-list.js +40 -0
- package/checkbox-list/checkbox-list.stories.d.ts +2 -0
- package/checkbox-list/checkbox-list.stories.js +22 -0
- package/checkbox-list/index.d.ts +1 -0
- package/checkbox-list/index.js +17 -0
- package/checkbox-list/translations.d.ts +13 -0
- package/checkbox-list/translations.js +14 -0
- package/color-radio-group/color-radio-group.d.ts +13 -0
- package/color-radio-group/color-radio-group.js +42 -0
- package/color-radio-group/color-radio-group.stories.d.ts +8 -0
- package/color-radio-group/color-radio-group.stories.js +62 -0
- package/color-radio-group/index.d.ts +1 -0
- package/color-radio-group/index.js +17 -0
- package/color-radio-group/translations.d.ts +13 -0
- package/color-radio-group/translations.js +14 -0
- package/combobox/combobox.d.ts +13 -0
- package/combobox/combobox.js +48 -0
- package/combobox/combobox.stories.d.ts +8 -0
- package/combobox/combobox.stories.js +30 -0
- package/combobox/index.d.ts +1 -0
- package/combobox/index.js +17 -0
- package/combobox/translations.d.ts +13 -0
- package/combobox/translations.js +14 -0
- package/components.d.ts +127 -0
- package/components.js +154 -0
- package/date-picker-input/date-picker-input.d.ts +15 -0
- package/date-picker-input/date-picker-input.js +102 -0
- package/date-picker-input/date-picker-input.stories.d.ts +8 -0
- package/date-picker-input/date-picker-input.stories.js +31 -0
- package/date-picker-input/index.d.ts +1 -0
- package/date-picker-input/index.js +17 -0
- package/date-picker-input/translations.d.ts +31 -0
- package/date-picker-input/translations.js +32 -0
- package/date-range-picker-input/date-range-picker-input.d.ts +12 -0
- package/date-range-picker-input/date-range-picker-input.js +115 -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 +25 -0
- package/date-range-picker-input/index.d.ts +1 -0
- package/date-range-picker-input/index.js +17 -0
- package/date-range-picker-input/translations.d.ts +25 -0
- package/date-range-picker-input/translations.js +26 -0
- package/datetime-picker-input/datetime-picker-input.d.ts +15 -0
- package/datetime-picker-input/datetime-picker-input.js +103 -0
- package/datetime-picker-input/datetime-picker-input.stories.d.ts +2 -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/datetime-picker-input/translations.d.ts +31 -0
- package/datetime-picker-input/translations.js +32 -0
- package/dropzone/dropzone-input.d.ts +13 -0
- package/dropzone/dropzone-input.js +67 -0
- package/dropzone/dropzone-list.d.ts +11 -0
- package/dropzone/dropzone-list.js +23 -0
- package/dropzone/dropzone.stories.d.ts +2 -0
- package/dropzone/dropzone.stories.js +50 -0
- package/dropzone/index.d.ts +9 -0
- package/dropzone/index.js +6 -0
- package/dropzone/translations.d.ts +31 -0
- package/dropzone/translations.js +32 -0
- package/file-input/file-input.d.ts +14 -0
- package/file-input/file-input.js +42 -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/file-input/translations.d.ts +13 -0
- package/file-input/translations.js +14 -0
- package/form/form.d.ts +19 -0
- package/form/form.js +25 -0
- package/form/form.stories.d.ts +8 -0
- package/form/form.stories.js +24 -0
- package/form/index.d.ts +1 -0
- package/form/index.js +17 -0
- package/form-id-context/form-context.d.ts +7 -0
- package/form-id-context/form-context.js +12 -0
- package/form-id-context/form-id-context.d.ts +2 -0
- package/form-id-context/form-id-context.js +7 -0
- package/form-id-context/index.d.ts +1 -0
- package/form-id-context/index.js +17 -0
- package/form-renderer/big-test-schema.d.ts +33 -0
- package/form-renderer/big-test-schema.js +295 -0
- package/form-renderer/field/base-field.d.ts +4 -0
- package/form-renderer/field/base-field.js +72 -0
- package/form-renderer/field/embedded.d.ts +4 -0
- package/form-renderer/field/embedded.js +19 -0
- package/form-renderer/field/one-to-many.d.ts +4 -0
- package/form-renderer/field/one-to-many.js +52 -0
- package/form-renderer/form-renderer.d.ts +16 -0
- package/form-renderer/form-renderer.js +28 -0
- package/form-renderer/form-renderer.stories.d.ts +2 -0
- package/form-renderer/form-renderer.stories.js +23 -0
- package/form-renderer/index.d.ts +2 -0
- package/form-renderer/index.js +18 -0
- package/form-renderer/mapper.d.ts +2 -0
- package/form-renderer/mapper.js +30 -0
- package/form-renderer/translations.d.ts +33 -0
- package/form-renderer/translations.js +34 -0
- package/form-renderer/types.d.ts +39 -0
- package/form-renderer/types.js +2 -0
- package/gps-input/gps-input.d.ts +20 -0
- package/gps-input/gps-input.js +156 -0
- package/gps-input/gps-input.stories.d.ts +8 -0
- package/gps-input/gps-input.stories.js +22 -0
- package/gps-input/index.d.ts +1 -0
- package/gps-input/index.js +17 -0
- package/gps-input/translations.d.ts +31 -0
- package/gps-input/translations.js +32 -0
- package/money-input/index.d.ts +1 -0
- package/money-input/index.js +17 -0
- package/money-input/money-input.d.ts +24 -0
- package/money-input/money-input.js +112 -0
- package/money-input/money-input.stories.d.ts +2 -0
- package/money-input/money-input.stories.js +15 -0
- package/money-input/translations.d.ts +13 -0
- package/money-input/translations.js +14 -0
- package/multi-combobox/index.d.ts +1 -0
- package/multi-combobox/index.js +17 -0
- package/multi-combobox/multi-combobox.d.ts +13 -0
- package/multi-combobox/multi-combobox.js +48 -0
- package/multi-combobox/multi-combobox.stories.d.ts +8 -0
- package/multi-combobox/multi-combobox.stories.js +54 -0
- package/multi-combobox/translations.d.ts +13 -0
- package/multi-combobox/translations.js +14 -0
- package/multi-select/index.d.ts +1 -0
- package/multi-select/index.js +17 -0
- package/multi-select/multi-select.d.ts +13 -0
- package/multi-select/multi-select.js +43 -0
- package/multi-select/multi-select.stories.d.ts +8 -0
- package/multi-select/multi-select.stories.js +47 -0
- package/multi-select/translations.d.ts +13 -0
- package/multi-select/translations.js +14 -0
- package/number-input/index.d.ts +1 -0
- package/number-input/index.js +17 -0
- package/number-input/number-input.d.ts +17 -0
- package/number-input/number-input.js +87 -0
- package/number-input/number-input.stories.d.ts +8 -0
- package/number-input/number-input.stories.js +24 -0
- package/number-input/translations.d.ts +25 -0
- package/number-input/translations.js +26 -0
- package/package.json +3 -3
- package/password-input/index.d.ts +1 -0
- package/password-input/index.js +17 -0
- package/password-input/password-input.d.ts +15 -0
- package/password-input/password-input.js +108 -0
- package/password-input/password-input.stories.d.ts +8 -0
- package/password-input/password-input.stories.js +23 -0
- package/password-input/translations.d.ts +19 -0
- package/password-input/translations.js +20 -0
- package/radio-group/index.d.ts +1 -0
- package/radio-group/index.js +17 -0
- package/radio-group/radio-group.d.ts +13 -0
- package/radio-group/radio-group.js +42 -0
- package/radio-group/radio-group.stories.d.ts +8 -0
- package/radio-group/radio-group.stories.js +38 -0
- package/radio-group/translations.d.ts +13 -0
- package/radio-group/translations.js +14 -0
- package/readmes.d.ts +28 -0
- package/readmes.js +59 -0
- package/select/index.d.ts +1 -0
- package/select/index.js +17 -0
- package/select/select.d.ts +13 -0
- package/select/select.js +41 -0
- package/select/select.stories.d.ts +8 -0
- package/select/select.stories.js +44 -0
- package/select/translations.d.ts +13 -0
- package/select/translations.js +14 -0
- package/storybook/form-data-printer.d.ts +6 -0
- package/storybook/form-data-printer.js +12 -0
- package/storybook/storybook-form.d.ts +8 -0
- package/storybook/storybook-form.js +42 -0
- package/text-input/index.d.ts +1 -0
- package/text-input/index.js +17 -0
- package/text-input/text-input.d.ts +33 -0
- package/text-input/text-input.js +75 -0
- package/text-input/text-input.stories.d.ts +8 -0
- package/text-input/text-input.stories.js +26 -0
- package/text-input/translations.d.ts +31 -0
- package/text-input/translations.js +32 -0
- package/textarea/index.d.ts +1 -0
- package/textarea/index.js +17 -0
- package/textarea/textarea.d.ts +13 -0
- package/textarea/textarea.js +62 -0
- package/textarea/textarea.stories.d.ts +8 -0
- package/textarea/textarea.stories.js +22 -0
- package/textarea/translations.d.ts +13 -0
- package/textarea/translations.js +14 -0
- package/time-picker-input/index.d.ts +1 -0
- package/time-picker-input/index.js +17 -0
- package/time-picker-input/time-picker-input.d.ts +14 -0
- package/time-picker-input/time-picker-input.js +84 -0
- package/time-picker-input/time-picker-input.stories.d.ts +8 -0
- package/time-picker-input/time-picker-input.stories.js +25 -0
- package/time-picker-input/translations.d.ts +19 -0
- package/time-picker-input/translations.js +20 -0
- package/toggle/index.d.ts +1 -0
- package/toggle/index.js +17 -0
- package/toggle/toggle.d.ts +14 -0
- package/toggle/toggle.js +40 -0
- package/toggle/toggle.stories.d.ts +8 -0
- package/toggle/toggle.stories.js +23 -0
- package/toggle/translations.d.ts +13 -0
- package/toggle/translations.js +14 -0
- package/types.d.ts +4 -0
- package/types.js +2 -0
|
@@ -0,0 +1,22 @@
|
|
|
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 = Default;
|
|
7
|
+
const button_1 = require("@uxf/ui/button");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
10
|
+
const textarea_1 = require("./textarea");
|
|
11
|
+
exports.default = {
|
|
12
|
+
title: "Form/Textarea",
|
|
13
|
+
component: textarea_1.Textarea,
|
|
14
|
+
};
|
|
15
|
+
function Default() {
|
|
16
|
+
const storyFormTextAreas = (control) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
17
|
+
react_1.default.createElement(textarea_1.Textarea, { control: control, form: "form-textarea", label: "Textarea", name: "textarea", placeholder: "placeholder" }),
|
|
18
|
+
react_1.default.createElement(textarea_1.Textarea, { control: control, form: "form-textarea", isRequired: true, label: "Textarea required", name: "textarea-required", placeholder: "placeholder" }),
|
|
19
|
+
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: "space-y-2 p-20 lg:w-1/2" }, storyFormTextAreas(control))))));
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
"uxf-form-textarea": {
|
|
5
|
+
validation: {
|
|
6
|
+
required: {
|
|
7
|
+
cs: "Toto pole je povinné",
|
|
8
|
+
en: "This field is required",
|
|
9
|
+
sk: "Toto pole je povinné",
|
|
10
|
+
de: "Dieses Feld ist erforderlich",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./time-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("./time-picker-input"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DatePickerInputProps as UIDatePickerInputProps } from "@uxf/ui/date-picker-input";
|
|
2
|
+
import { TimePickerInputProps as UITimePickerInputProps } from "@uxf/ui/time-picker-input";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { FieldValues } from "react-hook-form";
|
|
5
|
+
import { ControlProps } from "../types";
|
|
6
|
+
export type TimePickerInputProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UITimePickerInputProps, "isFocused" | "isInvalid" | "max" | "min" | "name" | "onChange" | "pattern" | "step" | "value"> & {
|
|
7
|
+
onChange?: UIDatePickerInputProps["onChange"];
|
|
8
|
+
requiredMessage?: string;
|
|
9
|
+
};
|
|
10
|
+
export type TimePickerInputValue = string | null;
|
|
11
|
+
export declare function TimePickerInput<FormData extends FieldValues>(props: TimePickerInputProps<FormData>): React.JSX.Element;
|
|
12
|
+
export declare namespace TimePickerInput {
|
|
13
|
+
var displayName: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.TimePickerInput = TimePickerInput;
|
|
31
|
+
const translations_1 = require("@uxf/core-react/translations");
|
|
32
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
33
|
+
const time_picker_input_1 = require("@uxf/ui/time-picker-input");
|
|
34
|
+
const dayjs_1 = __importStar(require("dayjs"));
|
|
35
|
+
const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
36
|
+
const react_1 = __importDefault(require("react"));
|
|
37
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
38
|
+
const form_context_1 = require("../form-id-context/form-context");
|
|
39
|
+
(0, dayjs_1.extend)(customParseFormat_1.default);
|
|
40
|
+
function TimePickerInput(props) {
|
|
41
|
+
var _a, _b, _c, _d, _e;
|
|
42
|
+
const formContext = (0, form_context_1.useFormContext)();
|
|
43
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
44
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
|
|
45
|
+
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
46
|
+
control: props.control,
|
|
47
|
+
name: props.name,
|
|
48
|
+
rules: {
|
|
49
|
+
required: props.isRequired
|
|
50
|
+
? props.requiredMessage || t("uxf-form-time-picker-input:validation.required")
|
|
51
|
+
: undefined,
|
|
52
|
+
...props.rules,
|
|
53
|
+
validate: {
|
|
54
|
+
validTime: (value) => {
|
|
55
|
+
if (!value) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!(0, dayjs_1.default)(value, time_picker_input_1.OUTPUT_TIME_FORMAT, true).isValid()) {
|
|
59
|
+
return t("uxf-form-time-picker-input:validation.invalid-time-format", {
|
|
60
|
+
format: time_picker_input_1.DISPLAY_TIME_FORMAT,
|
|
61
|
+
value: value,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
...(typeof ((_b = props.rules) === null || _b === void 0 ? void 0 : _b.validate) === "function"
|
|
66
|
+
? { custom: props.rules.validate }
|
|
67
|
+
: (_c = props.rules) === null || _c === void 0 ? void 0 : _c.validate),
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
shouldUnregister: props.shouldUnregister,
|
|
71
|
+
});
|
|
72
|
+
const onBlur = (event) => {
|
|
73
|
+
var _a;
|
|
74
|
+
field.onBlur();
|
|
75
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
76
|
+
};
|
|
77
|
+
const onChange = (value, event) => {
|
|
78
|
+
var _a;
|
|
79
|
+
field.onChange(value);
|
|
80
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
81
|
+
};
|
|
82
|
+
return (react_1.default.createElement(time_picker_input_1.TimePickerInput, { CustomTimePicker: props.CustomTimePicker, autoFocus: props.autoFocus, className: props.className, form: props.form, helperText: (_e = (_d = fieldState.error) === null || _d === void 0 ? void 0 : _d.message) !== null && _e !== void 0 ? _e : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isClearable: props.isClearable, isDisabled: formContext.isFormDisabled || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || 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 }));
|
|
83
|
+
}
|
|
84
|
+
TimePickerInput.displayName = "UxfFormTimePickerInput";
|
|
@@ -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 = Default;
|
|
7
|
+
const button_1 = require("@uxf/ui/button");
|
|
8
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
11
|
+
const time_picker_input_1 = require("./time-picker-input");
|
|
12
|
+
exports.default = {
|
|
13
|
+
title: "Form/TimePickerInput",
|
|
14
|
+
component: time_picker_input_1.TimePickerInput,
|
|
15
|
+
};
|
|
16
|
+
function Default() {
|
|
17
|
+
const storyFormDatePickers = (control) => (react_1.default.createElement("div", { className: "space-y-4" },
|
|
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: "" }),
|
|
20
|
+
react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
|
|
21
|
+
return (react_1.default.createElement(storybook_form_1.StorybookForm, { defaultValues: {
|
|
22
|
+
withDefaultValue: (0, dayjs_1.default)("2023-10-20T14:32:10.511").format("HH:mm:ss"),
|
|
23
|
+
} }, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
24
|
+
react_1.default.createElement("div", { className: "space-y-2 p-20 lg:w-1/2" }, storyFormDatePickers(control))))));
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
"uxf-form-time-picker-input": {
|
|
3
|
+
validation: {
|
|
4
|
+
required: {
|
|
5
|
+
cs: string;
|
|
6
|
+
en: string;
|
|
7
|
+
sk: string;
|
|
8
|
+
de: string;
|
|
9
|
+
};
|
|
10
|
+
"invalid-time-format": {
|
|
11
|
+
cs: string;
|
|
12
|
+
en: string;
|
|
13
|
+
sk: string;
|
|
14
|
+
de: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
"uxf-form-time-picker-input": {
|
|
5
|
+
validation: {
|
|
6
|
+
required: {
|
|
7
|
+
cs: "Toto pole je povinné",
|
|
8
|
+
en: "This field is required",
|
|
9
|
+
sk: "Toto pole je povinné",
|
|
10
|
+
de: "Dieses Feld ist erforderlich",
|
|
11
|
+
},
|
|
12
|
+
"invalid-time-format": {
|
|
13
|
+
cs: "Čas musí být ve formátu {{format}}.",
|
|
14
|
+
en: "Time must be in format {{format}}.",
|
|
15
|
+
sk: "Čas musí byť vo formáte {{format}}.",
|
|
16
|
+
de: "Uhrzeit muss im Format {{format}} sein.",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./toggle";
|
package/toggle/index.js
ADDED
|
@@ -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("./toggle"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ToggleProps as UIToggleProps } from "@uxf/ui/toggle";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { FieldValues } from "react-hook-form";
|
|
4
|
+
import { ControlProps } from "../types";
|
|
5
|
+
export type ComboProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIToggleProps, "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
|
|
6
|
+
nullable?: boolean;
|
|
7
|
+
onChange?: UIToggleProps["onChange"];
|
|
8
|
+
requiredMessage?: string;
|
|
9
|
+
};
|
|
10
|
+
export type ToggleValue = boolean | undefined;
|
|
11
|
+
export declare function Toggle<FormData extends Record<string, any>>(props: ComboProps<FormData>): React.JSX.Element;
|
|
12
|
+
export declare namespace Toggle {
|
|
13
|
+
var displayName: string;
|
|
14
|
+
}
|
package/toggle/toggle.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Toggle = Toggle;
|
|
8
|
+
const translations_1 = require("@uxf/core-react/translations");
|
|
9
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
10
|
+
const toggle_1 = require("@uxf/ui/toggle");
|
|
11
|
+
const react_1 = __importDefault(require("react"));
|
|
12
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
13
|
+
const form_context_1 = require("../form-id-context/form-context");
|
|
14
|
+
function Toggle(props) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const formContext = (0, form_context_1.useFormContext)();
|
|
17
|
+
const t = (0, translations_1.useUxfTranslation)();
|
|
18
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
|
|
19
|
+
const { field, fieldState } = (0, react_hook_form_1.useController)({
|
|
20
|
+
control: props.control,
|
|
21
|
+
name: props.name,
|
|
22
|
+
rules: {
|
|
23
|
+
required: props.isRequired ? props.requiredMessage || t("uxf-form-toggle:validation.required") : undefined,
|
|
24
|
+
...props.rules,
|
|
25
|
+
},
|
|
26
|
+
shouldUnregister: props.shouldUnregister,
|
|
27
|
+
});
|
|
28
|
+
const onBlur = (event) => {
|
|
29
|
+
var _a;
|
|
30
|
+
field.onBlur();
|
|
31
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
32
|
+
};
|
|
33
|
+
const onChange = (value, event) => {
|
|
34
|
+
var _a;
|
|
35
|
+
field.onChange(value);
|
|
36
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
|
|
37
|
+
};
|
|
38
|
+
return (react_1.default.createElement(toggle_1.Toggle, { className: props.className, hiddenLabel: props.hiddenLabel, id: id, isDisabled: formContext.isFormDisabled || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, ref: field.ref, style: props.style, value: (_b = field.value) !== null && _b !== void 0 ? _b : (!props.nullable ? false : undefined), variant: props.variant }));
|
|
39
|
+
}
|
|
40
|
+
Toggle.displayName = "UxfFormToggle";
|
|
@@ -0,0 +1,23 @@
|
|
|
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 = Default;
|
|
7
|
+
const button_1 = require("@uxf/ui/button");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const storybook_form_1 = require("../storybook/storybook-form");
|
|
10
|
+
const toggle_1 = require("./toggle");
|
|
11
|
+
exports.default = {
|
|
12
|
+
title: "Form/Toggle",
|
|
13
|
+
component: toggle_1.Toggle,
|
|
14
|
+
};
|
|
15
|
+
function Default() {
|
|
16
|
+
const storyFormToggles = (control) => (react_1.default.createElement("div", { className: "space-y-2" },
|
|
17
|
+
react_1.default.createElement(toggle_1.Toggle, { control: control, label: "Toggle form", name: "toggle1" }),
|
|
18
|
+
react_1.default.createElement(toggle_1.Toggle, { control: control, isRequired: true, label: "Toggle form required", name: "toggle-required" }),
|
|
19
|
+
react_1.default.createElement(toggle_1.Toggle, { control: control, isDisabled: true, label: "Toggle form disabled", name: "toggle-disabled" }),
|
|
20
|
+
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: "space-y-2 p-20 lg:w-1/2" }, storyFormToggles(control))))));
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
"uxf-form-toggle": {
|
|
5
|
+
validation: {
|
|
6
|
+
required: {
|
|
7
|
+
cs: "Toto pole je povinné",
|
|
8
|
+
en: "This field is required",
|
|
9
|
+
sk: "Toto pole je povinné",
|
|
10
|
+
de: "Dieses Feld ist erforderlich",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
package/types.d.ts
ADDED
package/types.js
ADDED