@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.
Files changed (233) hide show
  1. package/_code-generator/form-code-generator.d.ts +16 -0
  2. package/_code-generator/form-code-generator.js +69 -0
  3. package/avatar-file-input/avatar-file-input.d.ts +14 -0
  4. package/avatar-file-input/avatar-file-input.js +42 -0
  5. package/avatar-file-input/avatar-file-input.stories.d.ts +8 -0
  6. package/avatar-file-input/avatar-file-input.stories.js +23 -0
  7. package/avatar-file-input/index.d.ts +1 -0
  8. package/avatar-file-input/index.js +17 -0
  9. package/avatar-file-input/translations.d.ts +13 -0
  10. package/avatar-file-input/translations.js +14 -0
  11. package/bin/form-code-generator.d.ts +2 -0
  12. package/bin/form-code-generator.js +55 -0
  13. package/checkbox-button/checkbox-button.d.ts +14 -0
  14. package/checkbox-button/checkbox-button.js +42 -0
  15. package/checkbox-button/checkbox-button.stories.d.ts +8 -0
  16. package/checkbox-button/checkbox-button.stories.js +24 -0
  17. package/checkbox-button/index.d.ts +1 -0
  18. package/checkbox-button/index.js +17 -0
  19. package/checkbox-button/translations.d.ts +13 -0
  20. package/checkbox-button/translations.js +14 -0
  21. package/checkbox-input/checkbox-input.d.ts +14 -0
  22. package/checkbox-input/checkbox-input.js +42 -0
  23. package/checkbox-input/checkbox-input.stories.d.ts +8 -0
  24. package/checkbox-input/checkbox-input.stories.js +24 -0
  25. package/checkbox-input/index.d.ts +1 -0
  26. package/checkbox-input/index.js +17 -0
  27. package/checkbox-input/translations.d.ts +13 -0
  28. package/checkbox-input/translations.js +14 -0
  29. package/checkbox-list/checkbox-list.d.ts +19 -0
  30. package/checkbox-list/checkbox-list.js +40 -0
  31. package/checkbox-list/checkbox-list.stories.d.ts +2 -0
  32. package/checkbox-list/checkbox-list.stories.js +22 -0
  33. package/checkbox-list/index.d.ts +1 -0
  34. package/checkbox-list/index.js +17 -0
  35. package/checkbox-list/translations.d.ts +13 -0
  36. package/checkbox-list/translations.js +14 -0
  37. package/color-radio-group/color-radio-group.d.ts +13 -0
  38. package/color-radio-group/color-radio-group.js +42 -0
  39. package/color-radio-group/color-radio-group.stories.d.ts +8 -0
  40. package/color-radio-group/color-radio-group.stories.js +62 -0
  41. package/color-radio-group/index.d.ts +1 -0
  42. package/color-radio-group/index.js +17 -0
  43. package/color-radio-group/translations.d.ts +13 -0
  44. package/color-radio-group/translations.js +14 -0
  45. package/combobox/combobox.d.ts +13 -0
  46. package/combobox/combobox.js +48 -0
  47. package/combobox/combobox.stories.d.ts +8 -0
  48. package/combobox/combobox.stories.js +30 -0
  49. package/combobox/index.d.ts +1 -0
  50. package/combobox/index.js +17 -0
  51. package/combobox/translations.d.ts +13 -0
  52. package/combobox/translations.js +14 -0
  53. package/components.d.ts +127 -0
  54. package/components.js +154 -0
  55. package/date-picker-input/date-picker-input.d.ts +15 -0
  56. package/date-picker-input/date-picker-input.js +102 -0
  57. package/date-picker-input/date-picker-input.stories.d.ts +8 -0
  58. package/date-picker-input/date-picker-input.stories.js +31 -0
  59. package/date-picker-input/index.d.ts +1 -0
  60. package/date-picker-input/index.js +17 -0
  61. package/date-picker-input/translations.d.ts +31 -0
  62. package/date-picker-input/translations.js +32 -0
  63. package/date-range-picker-input/date-range-picker-input.d.ts +12 -0
  64. package/date-range-picker-input/date-range-picker-input.js +115 -0
  65. package/date-range-picker-input/date-range-picker-input.stories.d.ts +8 -0
  66. package/date-range-picker-input/date-range-picker-input.stories.js +25 -0
  67. package/date-range-picker-input/index.d.ts +1 -0
  68. package/date-range-picker-input/index.js +17 -0
  69. package/date-range-picker-input/translations.d.ts +25 -0
  70. package/date-range-picker-input/translations.js +26 -0
  71. package/datetime-picker-input/datetime-picker-input.d.ts +15 -0
  72. package/datetime-picker-input/datetime-picker-input.js +103 -0
  73. package/datetime-picker-input/datetime-picker-input.stories.d.ts +2 -0
  74. package/datetime-picker-input/datetime-picker-input.stories.js +28 -0
  75. package/datetime-picker-input/index.d.ts +1 -0
  76. package/datetime-picker-input/index.js +17 -0
  77. package/datetime-picker-input/translations.d.ts +31 -0
  78. package/datetime-picker-input/translations.js +32 -0
  79. package/dropzone/dropzone-input.d.ts +13 -0
  80. package/dropzone/dropzone-input.js +67 -0
  81. package/dropzone/dropzone-list.d.ts +11 -0
  82. package/dropzone/dropzone-list.js +23 -0
  83. package/dropzone/dropzone.stories.d.ts +2 -0
  84. package/dropzone/dropzone.stories.js +50 -0
  85. package/dropzone/index.d.ts +9 -0
  86. package/dropzone/index.js +6 -0
  87. package/dropzone/translations.d.ts +31 -0
  88. package/dropzone/translations.js +32 -0
  89. package/file-input/file-input.d.ts +14 -0
  90. package/file-input/file-input.js +42 -0
  91. package/file-input/file-input.stories.d.ts +8 -0
  92. package/file-input/file-input.stories.js +31 -0
  93. package/file-input/index.d.ts +1 -0
  94. package/file-input/index.js +17 -0
  95. package/file-input/translations.d.ts +13 -0
  96. package/file-input/translations.js +14 -0
  97. package/form/form.d.ts +19 -0
  98. package/form/form.js +25 -0
  99. package/form/form.stories.d.ts +8 -0
  100. package/form/form.stories.js +24 -0
  101. package/form/index.d.ts +1 -0
  102. package/form/index.js +17 -0
  103. package/form-id-context/form-context.d.ts +7 -0
  104. package/form-id-context/form-context.js +12 -0
  105. package/form-id-context/form-id-context.d.ts +2 -0
  106. package/form-id-context/form-id-context.js +7 -0
  107. package/form-id-context/index.d.ts +1 -0
  108. package/form-id-context/index.js +17 -0
  109. package/form-renderer/big-test-schema.d.ts +33 -0
  110. package/form-renderer/big-test-schema.js +295 -0
  111. package/form-renderer/field/base-field.d.ts +4 -0
  112. package/form-renderer/field/base-field.js +72 -0
  113. package/form-renderer/field/embedded.d.ts +4 -0
  114. package/form-renderer/field/embedded.js +19 -0
  115. package/form-renderer/field/one-to-many.d.ts +4 -0
  116. package/form-renderer/field/one-to-many.js +52 -0
  117. package/form-renderer/form-renderer.d.ts +16 -0
  118. package/form-renderer/form-renderer.js +28 -0
  119. package/form-renderer/form-renderer.stories.d.ts +2 -0
  120. package/form-renderer/form-renderer.stories.js +23 -0
  121. package/form-renderer/index.d.ts +2 -0
  122. package/form-renderer/index.js +18 -0
  123. package/form-renderer/mapper.d.ts +2 -0
  124. package/form-renderer/mapper.js +30 -0
  125. package/form-renderer/translations.d.ts +33 -0
  126. package/form-renderer/translations.js +34 -0
  127. package/form-renderer/types.d.ts +39 -0
  128. package/form-renderer/types.js +2 -0
  129. package/gps-input/gps-input.d.ts +20 -0
  130. package/gps-input/gps-input.js +156 -0
  131. package/gps-input/gps-input.stories.d.ts +8 -0
  132. package/gps-input/gps-input.stories.js +22 -0
  133. package/gps-input/index.d.ts +1 -0
  134. package/gps-input/index.js +17 -0
  135. package/gps-input/translations.d.ts +31 -0
  136. package/gps-input/translations.js +32 -0
  137. package/money-input/index.d.ts +1 -0
  138. package/money-input/index.js +17 -0
  139. package/money-input/money-input.d.ts +24 -0
  140. package/money-input/money-input.js +112 -0
  141. package/money-input/money-input.stories.d.ts +2 -0
  142. package/money-input/money-input.stories.js +15 -0
  143. package/money-input/translations.d.ts +13 -0
  144. package/money-input/translations.js +14 -0
  145. package/multi-combobox/index.d.ts +1 -0
  146. package/multi-combobox/index.js +17 -0
  147. package/multi-combobox/multi-combobox.d.ts +13 -0
  148. package/multi-combobox/multi-combobox.js +48 -0
  149. package/multi-combobox/multi-combobox.stories.d.ts +8 -0
  150. package/multi-combobox/multi-combobox.stories.js +54 -0
  151. package/multi-combobox/translations.d.ts +13 -0
  152. package/multi-combobox/translations.js +14 -0
  153. package/multi-select/index.d.ts +1 -0
  154. package/multi-select/index.js +17 -0
  155. package/multi-select/multi-select.d.ts +13 -0
  156. package/multi-select/multi-select.js +43 -0
  157. package/multi-select/multi-select.stories.d.ts +8 -0
  158. package/multi-select/multi-select.stories.js +47 -0
  159. package/multi-select/translations.d.ts +13 -0
  160. package/multi-select/translations.js +14 -0
  161. package/number-input/index.d.ts +1 -0
  162. package/number-input/index.js +17 -0
  163. package/number-input/number-input.d.ts +17 -0
  164. package/number-input/number-input.js +87 -0
  165. package/number-input/number-input.stories.d.ts +8 -0
  166. package/number-input/number-input.stories.js +24 -0
  167. package/number-input/translations.d.ts +25 -0
  168. package/number-input/translations.js +26 -0
  169. package/package.json +3 -3
  170. package/password-input/index.d.ts +1 -0
  171. package/password-input/index.js +17 -0
  172. package/password-input/password-input.d.ts +15 -0
  173. package/password-input/password-input.js +108 -0
  174. package/password-input/password-input.stories.d.ts +8 -0
  175. package/password-input/password-input.stories.js +23 -0
  176. package/password-input/translations.d.ts +19 -0
  177. package/password-input/translations.js +20 -0
  178. package/radio-group/index.d.ts +1 -0
  179. package/radio-group/index.js +17 -0
  180. package/radio-group/radio-group.d.ts +13 -0
  181. package/radio-group/radio-group.js +42 -0
  182. package/radio-group/radio-group.stories.d.ts +8 -0
  183. package/radio-group/radio-group.stories.js +38 -0
  184. package/radio-group/translations.d.ts +13 -0
  185. package/radio-group/translations.js +14 -0
  186. package/readmes.d.ts +28 -0
  187. package/readmes.js +59 -0
  188. package/select/index.d.ts +1 -0
  189. package/select/index.js +17 -0
  190. package/select/select.d.ts +13 -0
  191. package/select/select.js +41 -0
  192. package/select/select.stories.d.ts +8 -0
  193. package/select/select.stories.js +44 -0
  194. package/select/translations.d.ts +13 -0
  195. package/select/translations.js +14 -0
  196. package/storybook/form-data-printer.d.ts +6 -0
  197. package/storybook/form-data-printer.js +12 -0
  198. package/storybook/storybook-form.d.ts +8 -0
  199. package/storybook/storybook-form.js +42 -0
  200. package/text-input/index.d.ts +1 -0
  201. package/text-input/index.js +17 -0
  202. package/text-input/text-input.d.ts +33 -0
  203. package/text-input/text-input.js +75 -0
  204. package/text-input/text-input.stories.d.ts +8 -0
  205. package/text-input/text-input.stories.js +26 -0
  206. package/text-input/translations.d.ts +31 -0
  207. package/text-input/translations.js +32 -0
  208. package/textarea/index.d.ts +1 -0
  209. package/textarea/index.js +17 -0
  210. package/textarea/textarea.d.ts +13 -0
  211. package/textarea/textarea.js +62 -0
  212. package/textarea/textarea.stories.d.ts +8 -0
  213. package/textarea/textarea.stories.js +22 -0
  214. package/textarea/translations.d.ts +13 -0
  215. package/textarea/translations.js +14 -0
  216. package/time-picker-input/index.d.ts +1 -0
  217. package/time-picker-input/index.js +17 -0
  218. package/time-picker-input/time-picker-input.d.ts +14 -0
  219. package/time-picker-input/time-picker-input.js +84 -0
  220. package/time-picker-input/time-picker-input.stories.d.ts +8 -0
  221. package/time-picker-input/time-picker-input.stories.js +25 -0
  222. package/time-picker-input/translations.d.ts +19 -0
  223. package/time-picker-input/translations.js +20 -0
  224. package/toggle/index.d.ts +1 -0
  225. package/toggle/index.js +17 -0
  226. package/toggle/toggle.d.ts +14 -0
  227. package/toggle/toggle.js +40 -0
  228. package/toggle/toggle.stories.d.ts +8 -0
  229. package/toggle/toggle.stories.js +23 -0
  230. package/toggle/translations.d.ts +13 -0
  231. package/toggle/translations.js +14 -0
  232. package/types.d.ts +4 -0
  233. package/types.js +2 -0
@@ -0,0 +1,16 @@
1
+ import { components } from "../components";
2
+ export interface FieldDefinition {
3
+ type: keyof typeof components;
4
+ name: string;
5
+ label: string;
6
+ isRequired?: boolean;
7
+ }
8
+ export declare class FormCodeGenerator {
9
+ private formName;
10
+ private fields;
11
+ constructor(formName: string);
12
+ getFieldsCount(): number;
13
+ add(field: FieldDefinition): this;
14
+ generateComponent(field: FieldDefinition): string | null;
15
+ generate(): string;
16
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormCodeGenerator = void 0;
4
+ function unique(value, index, array) {
5
+ return array.indexOf(value) === index;
6
+ }
7
+ function camelize(text) {
8
+ return text
9
+ .split(/[-_]+/)
10
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
11
+ .join("");
12
+ }
13
+ class FormCodeGenerator {
14
+ constructor(formName) {
15
+ this.fields = [];
16
+ this.formName = formName;
17
+ }
18
+ getFieldsCount() {
19
+ return this.fields.length;
20
+ }
21
+ add(field) {
22
+ this.fields.push(field);
23
+ return this;
24
+ }
25
+ generateComponent(field) {
26
+ return `<${camelize(field.type)} control={formApi.control} name="${field.name}" label="${field.label}" ${field.isRequired ? "isRequired " : ""}/>`;
27
+ }
28
+ generate() {
29
+ const componentName = camelize(this.formName);
30
+ return `import React from "react";
31
+ import { Form } from "@uxf/form/form";
32
+ import { useForm, SubmitHandler } from "react-hook-form";
33
+ ${this.fields
34
+ .map((field) => field.type)
35
+ .filter(unique)
36
+ .map((type) => `import { ${camelize(type)}, ${camelize(type)}Value } from "@uxf/form/${type}";`)
37
+ .join("\n")}
38
+
39
+ export interface ${componentName}Data {
40
+ ${this.fields.map((field) => ` ${field.name}: ${camelize(field.type)}Value;`).join("\n")}
41
+ }
42
+
43
+ export interface ${componentName}Props {
44
+ onSubmit: SubmitHandler<${componentName}Data>;
45
+ defaultValues: ${componentName}Data;
46
+ }
47
+
48
+ export function mapToFormData(values: any): ${componentName}Data {
49
+ return {
50
+ ${this.fields.map((field) => ` ${field.name}: values.TODO`).join(",\n")}
51
+ }
52
+ }
53
+
54
+ export function ${componentName}(props: ${componentName}Props)
55
+ {
56
+ const formApi = useForm({
57
+ defaultValues: props.defaultValues,
58
+ });
59
+
60
+ return (
61
+ <Form formApi={formApi} onSubmit={props.onSubmit} id="${this.formName}">
62
+ ${this.fields.map((field) => ` ${this.generateComponent(field)}`).join("\n")}
63
+ </Form>
64
+ );
65
+ }
66
+ `;
67
+ }
68
+ }
69
+ exports.FormCodeGenerator = FormCodeGenerator;
@@ -0,0 +1,14 @@
1
+ import { FileResponse } from "@uxf/core/types";
2
+ import { AvatarFileInputProps as UIAvatarFileInputProps } from "@uxf/ui/avatar-file-input";
3
+ import React from "react";
4
+ import { FieldValues } from "react-hook-form";
5
+ import { ControlProps } from "../types";
6
+ export type AvatarFileInputProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIAvatarFileInputProps, "isFocused" | "isInvalid" | "onChange" | "value"> & {
7
+ onChange?: UIAvatarFileInputProps["onChange"];
8
+ requiredMessage?: string;
9
+ };
10
+ export type AvatarFileInputValue = FileResponse | null;
11
+ export declare function AvatarFileInput<FormData extends FieldValues>(props: AvatarFileInputProps<FormData>): React.JSX.Element;
12
+ export declare namespace AvatarFileInput {
13
+ var displayName: string;
14
+ }
@@ -0,0 +1,42 @@
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.AvatarFileInput = AvatarFileInput;
8
+ const translations_1 = require("@uxf/core-react/translations");
9
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
10
+ const avatar_file_input_1 = require("@uxf/ui/avatar-file-input");
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 AvatarFileInput(props) {
15
+ var _a, _b, _c;
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
24
+ ? props.requiredMessage || t("uxf-form-avatar-file-input:validation.required")
25
+ : undefined,
26
+ ...props.rules,
27
+ },
28
+ shouldUnregister: props.shouldUnregister,
29
+ });
30
+ const onBlur = (event) => {
31
+ var _a;
32
+ field.onBlur();
33
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
34
+ };
35
+ const onChange = (value, event) => {
36
+ var _a;
37
+ field.onChange(value);
38
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
39
+ };
40
+ return (react_1.default.createElement(avatar_file_input_1.AvatarFileInput, { accept: props.accept, "aria-describedby": props["aria-describedby"], className: props.className, customControls: props.customControls, form: props.form, helperText: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : props.helperText, hiddenLabel: props.hiddenLabel, icon: props.icon, 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, maxFileSize: props.maxFileSize, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, ref: field.ref, removeFileLabel: props.removeFileLabel, selectFileLabel: props.selectFileLabel, value: field.value, variant: props.variant }));
41
+ }
42
+ AvatarFileInput.displayName = "UxfFormAvatarFileInput";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { AvatarFileInput } from "./avatar-file-input";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof AvatarFileInput;
6
+ };
7
+ export default _default;
8
+ export declare function Default(): React.JSX.Element;
@@ -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 upload_file_mock_1 = require("@uxf/ui/utils/mocks/upload-file.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: upload_file_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: upload_file_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: "space-y-2 p-20 lg:w-1/2" }, storyFormAvatarFileInputs(control, "light"))))));
23
+ }
@@ -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);
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ "uxf-form-avatar-file-input": {
3
+ validation: {
4
+ required: {
5
+ cs: string;
6
+ en: string;
7
+ sk: string;
8
+ de: string;
9
+ };
10
+ };
11
+ };
12
+ };
13
+ export default _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ "uxf-form-avatar-file-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
+ },
13
+ },
14
+ };
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ /* eslint-disable no-console */
5
+ const fs_1 = require("fs");
6
+ const node_readline_1 = require("node:readline");
7
+ const form_code_generator_1 = require("../_code-generator/form-code-generator");
8
+ const components_1 = require("../components");
9
+ const rl = (0, node_readline_1.createInterface)({ input: process.stdin, output: process.stdout });
10
+ function question(text) {
11
+ return new Promise((resolve) => rl.question(text, resolve));
12
+ }
13
+ async function run() {
14
+ const formName = await question("Zadejte název formuláře: ");
15
+ const formGenerator = new form_code_generator_1.FormCodeGenerator(formName);
16
+ const allowedComponents = Object.keys(components_1.components).filter((item) => item !== "form");
17
+ console.log();
18
+ console.log(allowedComponents.map((component, index) => `[${index}] ${component}`).join("\n"));
19
+ console.log();
20
+ let componentDefinition = null;
21
+ do {
22
+ // eslint-disable-next-line no-await-in-loop
23
+ componentDefinition = await question(`Komponenta ${formGenerator.getFieldsCount() + 1} [type, name, label, isRequired]: `);
24
+ if (componentDefinition) {
25
+ const [componentIndexString, name, label, required] = componentDefinition
26
+ .split(",")
27
+ .map((item) => item.trim());
28
+ const componentIndex = Number.parseInt(componentIndexString, 10);
29
+ const componentType = allowedComponents[componentIndex];
30
+ if (!name || !label) {
31
+ console.log("❗ Špatná definice. Komponenta nebyla přidána.\n");
32
+ continue;
33
+ }
34
+ const fieldDefinition = {
35
+ type: componentType,
36
+ name,
37
+ label,
38
+ isRequired: ["true", "1", "r", "required", "isRequired"].includes(required),
39
+ };
40
+ console.log(`✅ ${formGenerator.generateComponent(fieldDefinition)}\n`);
41
+ formGenerator.add(fieldDefinition);
42
+ }
43
+ } while (componentDefinition !== "");
44
+ const generatedFilename = `${process.cwd()}/${formName}.tsx`;
45
+ (0, fs_1.writeFileSync)(generatedFilename, formGenerator.generate());
46
+ console.log(`Generated file: ${generatedFilename}`);
47
+ }
48
+ run()
49
+ .then(() => {
50
+ process.exit(0);
51
+ })
52
+ .catch((err) => {
53
+ console.error(err);
54
+ process.exit(1);
55
+ });
@@ -0,0 +1,14 @@
1
+ import { CheckboxButtonProps as UICheckboxButtonProps } from "@uxf/ui/checkbox-button";
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<UICheckboxButtonProps, "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
6
+ nullable?: boolean;
7
+ onChange?: UICheckboxButtonProps["onChange"];
8
+ requiredMessage?: string;
9
+ };
10
+ export type CheckboxButtonValue = boolean | undefined;
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
+ }
@@ -0,0 +1,42 @@
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.CheckboxButton = CheckboxButton;
8
+ const translations_1 = require("@uxf/core-react/translations");
9
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
10
+ const checkbox_button_1 = require("@uxf/ui/checkbox-button");
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 CheckboxButton(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
24
+ ? props.requiredMessage || t("uxf-form-checkbox-button:validation.required")
25
+ : undefined,
26
+ ...props.rules,
27
+ },
28
+ shouldUnregister: props.shouldUnregister,
29
+ });
30
+ const onBlur = (event) => {
31
+ var _a;
32
+ field.onBlur();
33
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
34
+ };
35
+ const onChange = (value, event) => {
36
+ var _a;
37
+ field.onChange(value);
38
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
39
+ };
40
+ return (react_1.default.createElement(checkbox_button_1.CheckboxButton, { className: props.className, 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) }));
41
+ }
42
+ CheckboxButton.displayName = "UxfFormCheckboxButton";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { CheckboxButton } from "./checkbox-button";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof CheckboxButton;
6
+ };
7
+ export default _default;
8
+ export declare function Default(): React.JSX.Element;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Default = 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 checkbox_button_1 = require("./checkbox-button");
11
+ exports.default = {
12
+ title: "Form/CheckboxButton",
13
+ component: checkbox_button_1.CheckboxButton,
14
+ };
15
+ function Default() {
16
+ const storyFormCheckboxes = (control) => (react_1.default.createElement("div", { className: "flex flex-col space-y-2" },
17
+ react_1.default.createElement(checkbox_button_1.CheckboxButton, { control: control, label: "CheckboxButton form", name: "checkbox-button1" }),
18
+ react_1.default.createElement(checkbox_button_1.CheckboxButton, { control: control, isRequired: true, label: "CheckboxButton form required", name: "checkbox-button-required" }),
19
+ react_1.default.createElement(checkbox_button_1.CheckboxButton, { control: control, isDisabled: true, label: "CheckboxButton form disabled", name: "checkbox-button-disabled" }),
20
+ react_1.default.createElement(checkbox_button_1.CheckboxButton, { control: control, isReadOnly: true, label: "CheckboxButton form readOnly", name: "checkbox-button-read-only" }),
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: "space-y-2 p-20 lg:w-1/2" }, storyFormCheckboxes(control))))));
24
+ }
@@ -0,0 +1 @@
1
+ export * from "./checkbox-button";
@@ -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-button"), exports);
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ "uxf-form-checkbox-button": {
3
+ validation: {
4
+ required: {
5
+ cs: string;
6
+ en: string;
7
+ sk: string;
8
+ de: string;
9
+ };
10
+ };
11
+ };
12
+ };
13
+ export default _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ "uxf-form-checkbox-button": {
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,14 @@
1
+ import { CheckboxInputProps as UICheckboxInputProps } from "@uxf/ui/checkbox-input";
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<UICheckboxInputProps, "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
6
+ nullable?: boolean;
7
+ onChange?: UICheckboxInputProps["onChange"];
8
+ requiredMessage?: string;
9
+ };
10
+ export type CheckboxInputValue = boolean | undefined;
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
+ }
@@ -0,0 +1,42 @@
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.CheckboxInput = CheckboxInput;
8
+ const translations_1 = require("@uxf/core-react/translations");
9
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
10
+ const checkbox_input_1 = require("@uxf/ui/checkbox-input");
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 CheckboxInput(props) {
15
+ var _a, _b, _c, _d;
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
24
+ ? props.requiredMessage || t("uxf-form-checkbox-input:validation.required")
25
+ : undefined,
26
+ ...props.rules,
27
+ },
28
+ shouldUnregister: props.shouldUnregister,
29
+ });
30
+ const onBlur = (event) => {
31
+ var _a;
32
+ field.onBlur();
33
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
34
+ };
35
+ const onChange = (value, event) => {
36
+ var _a;
37
+ field.onChange(value);
38
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
39
+ };
40
+ return (react_1.default.createElement(checkbox_input_1.CheckboxInput, { className: props.className, helperText: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isDisabled: 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, size: props.size, style: props.style, value: (_d = field.value) !== null && _d !== void 0 ? _d : (!props.nullable ? false : undefined) }));
41
+ }
42
+ CheckboxInput.displayName = "UxfFormCheckboxInput";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { CheckboxInput } from "./checkbox-input";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof CheckboxInput;
6
+ };
7
+ export default _default;
8
+ export declare function Default(): React.JSX.Element;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Default = 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 checkbox_input_1 = require("./checkbox-input");
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, { control: control, label: "CheckboxInput form", name: "checkbox1" }),
18
+ react_1.default.createElement(checkbox_input_1.CheckboxInput, { control: control, isRequired: true, label: "CheckboxInput form required", name: "checkbox-required" }),
19
+ react_1.default.createElement(checkbox_input_1.CheckboxInput, { control: control, isDisabled: true, label: "CheckboxInput form disabled", name: "checkbox-disabled" }),
20
+ react_1.default.createElement(checkbox_input_1.CheckboxInput, { control: control, isReadOnly: true, label: "CheckboxInput form readOnly", name: "checkbox-readonly" }),
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: "space-y-2 p-20 lg:w-1/2" }, storyFormCheckboxes(control))))));
24
+ }
@@ -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);
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ "uxf-form-checkbox-input": {
3
+ validation: {
4
+ required: {
5
+ cs: string;
6
+ en: string;
7
+ sk: string;
8
+ de: string;
9
+ };
10
+ };
11
+ };
12
+ };
13
+ export default _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ "uxf-form-checkbox-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
+ },
13
+ },
14
+ };
@@ -0,0 +1,19 @@
1
+ import { CheckboxInputProps as UICheckboxInputProps } from "@uxf/ui/checkbox-input";
2
+ import { FormControlProps } from "@uxf/ui/types";
3
+ import React, { ReactNode } from "react";
4
+ import { FieldValues } from "react-hook-form";
5
+ import { ControlProps } from "../types";
6
+ type ValueType = string | number;
7
+ export type CheckboxListOption = {
8
+ id: ValueType;
9
+ label: ReactNode;
10
+ isDisabled?: boolean;
11
+ };
12
+ export type CheckboxListValue<T> = T[] | null;
13
+ type CheckboxListProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UICheckboxInputProps, "isInvalid" | "name" | "onChange" | "value"> & {
14
+ onChange?: FormControlProps<CheckboxListValue<string | number>>["onChange"];
15
+ options: CheckboxListOption[];
16
+ requiredMessage?: string;
17
+ };
18
+ export declare function CheckboxList<FormData extends FieldValues>(props: CheckboxListProps<FormData>): React.JSX.Element;
19
+ export {};
@@ -0,0 +1,40 @@
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.CheckboxList = CheckboxList;
7
+ const translations_1 = require("@uxf/core-react/translations");
8
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
9
+ const form_context_1 = require("@uxf/form/form-id-context/form-context");
10
+ const checkbox_list_1 = require("@uxf/ui/checkbox-list");
11
+ const react_1 = __importDefault(require("react"));
12
+ const react_hook_form_1 = require("react-hook-form");
13
+ function CheckboxList(props) {
14
+ var _a, _b, _c, _d;
15
+ const formContext = (0, form_context_1.useFormContext)();
16
+ const t = (0, translations_1.useUxfTranslation)();
17
+ const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
18
+ const { field, fieldState } = (0, react_hook_form_1.useController)({
19
+ control: props.control,
20
+ name: props.name,
21
+ rules: {
22
+ required: props.isRequired
23
+ ? props.requiredMessage || t("uxf-form-checkbox-list:validation.required")
24
+ : undefined,
25
+ ...((_b = props.rules) !== null && _b !== void 0 ? _b : {}),
26
+ },
27
+ shouldUnregister: props.shouldUnregister,
28
+ });
29
+ const onBlur = (event) => {
30
+ var _a;
31
+ field.onBlur();
32
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
33
+ };
34
+ const onChange = (value, event) => {
35
+ var _a;
36
+ field.onChange(value);
37
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
38
+ };
39
+ return (react_1.default.createElement(checkbox_list_1.CheckboxList, { className: props.className, hasHiddenLabel: props.hiddenLabel, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, id: id, isDisabled: formContext.isFormDisabled || props.isDisabled, isFocused: props.isFocused, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, label: props.label, name: props.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, value: field.value }));
40
+ }