@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,15 @@
1
+ import { DatetimePickerInputProps as UIDatetimePickerInputProps } from "@uxf/ui/datetime-picker-input";
2
+ import React from "react";
3
+ import { FieldValues } from "react-hook-form";
4
+ import { ControlProps } from "../types";
5
+ export type DatetimePickerInputProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIDatetimePickerInputProps, "isFocused" | "isInvalid" | "max" | "min" | "name" | "onChange" | "pattern" | "step" | "value"> & {
6
+ onChange?: UIDatetimePickerInputProps["onChange"];
7
+ requiredMessage?: string;
8
+ minDate?: string;
9
+ maxDate?: string;
10
+ };
11
+ export type DatetimePickerInputValue = string | null;
12
+ export declare function DatetimePickerInput<FormData extends FieldValues>(props: DatetimePickerInputProps<FormData>): React.JSX.Element;
13
+ export declare namespace DatetimePickerInput {
14
+ var displayName: string;
15
+ }
@@ -0,0 +1,103 @@
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.DatetimePickerInput = DatetimePickerInput;
31
+ const translations_1 = require("@uxf/core-react/translations");
32
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
33
+ const date_picker_input_1 = require("@uxf/ui/date-picker-input");
34
+ const datetime_picker_1 = require("@uxf/ui/datetime-picker");
35
+ const datetime_picker_input_1 = require("@uxf/ui/datetime-picker-input");
36
+ const dayjs_1 = __importStar(require("dayjs"));
37
+ const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
38
+ const react_1 = __importDefault(require("react"));
39
+ const react_hook_form_1 = require("react-hook-form");
40
+ const form_context_1 = require("../form-id-context/form-context");
41
+ (0, dayjs_1.extend)(customParseFormat_1.default);
42
+ function DatetimePickerInput(props) {
43
+ var _a, _b, _c, _d, _e;
44
+ const formContext = (0, form_context_1.useFormContext)();
45
+ const t = (0, translations_1.useUxfTranslation)();
46
+ const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
47
+ const { field, fieldState } = (0, react_hook_form_1.useController)({
48
+ control: props.control,
49
+ name: props.name,
50
+ rules: {
51
+ required: props.isRequired
52
+ ? props.requiredMessage || t("uxf-form-datetime-picker-input:validation.required")
53
+ : undefined,
54
+ ...props.rules,
55
+ validate: {
56
+ validDate: (value) => {
57
+ if (!value) {
58
+ return;
59
+ }
60
+ if (!(0, datetime_picker_1.getStrictParsedDatetime)(value).isValid()) {
61
+ return t("uxf-form-datetime-picker-input:validation.invalid-datetime-format", {
62
+ format: datetime_picker_input_1.DISPLAY_DATETIME_FORMAT,
63
+ value: value,
64
+ });
65
+ }
66
+ },
67
+ validDateRange: (value) => {
68
+ if (!value) {
69
+ return;
70
+ }
71
+ if (props.minDate && (0, dayjs_1.default)(value, date_picker_input_1.OUTPUT_DATE_FORMAT, true).isBefore(props.minDate, "date")) {
72
+ return t("uxf-form-datetime-picker-input:validation.min-date", {
73
+ minDate: (0, dayjs_1.default)(props.minDate).format(date_picker_input_1.DISPLAY_DATE_FORMAT),
74
+ value: value,
75
+ });
76
+ }
77
+ if (props.maxDate && (0, dayjs_1.default)(value, date_picker_input_1.OUTPUT_DATE_FORMAT, true).isAfter(props.maxDate, "date")) {
78
+ return t("uxf-form-datetime-picker-input:validation.max-date", {
79
+ maxDate: (0, dayjs_1.default)(props.maxDate).format(date_picker_input_1.DISPLAY_DATE_FORMAT),
80
+ value: value,
81
+ });
82
+ }
83
+ },
84
+ ...(typeof ((_b = props.rules) === null || _b === void 0 ? void 0 : _b.validate) === "function"
85
+ ? { custom: props.rules.validate }
86
+ : (_c = props.rules) === null || _c === void 0 ? void 0 : _c.validate),
87
+ },
88
+ },
89
+ shouldUnregister: props.shouldUnregister,
90
+ });
91
+ const onBlur = (event) => {
92
+ var _a;
93
+ field.onBlur();
94
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
95
+ };
96
+ const onChange = (value, event) => {
97
+ var _a;
98
+ field.onChange(value);
99
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
100
+ };
101
+ return (react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { CustomDatetimePicker: props.CustomDatetimePicker, autoFocus: props.autoFocus, bottomContent: props.bottomContent, 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, maxDate: props.maxDate, minDate: props.minDate, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, placeholder: props.placeholder, popoverPlacement: props.popoverPlacement, popoverStrategy: props.popoverStrategy, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, triggerElement: props.triggerElement, unavailableDates: props.unavailableDates, value: field.value, variant: props.variant }));
102
+ }
103
+ DatetimePickerInput.displayName = "UxfFormDatePickerInput";
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare function Default(): React.JSX.Element;
@@ -0,0 +1,28 @@
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 date_picker_input_1 = require("@uxf/ui/date-picker-input");
9
+ const dayjs_1 = __importDefault(require("dayjs"));
10
+ const react_1 = __importDefault(require("react"));
11
+ const storybook_form_1 = require("../storybook/storybook-form");
12
+ const datetime_picker_input_1 = require("./datetime-picker-input");
13
+ function Default() {
14
+ return (react_1.default.createElement(storybook_form_1.StorybookForm, { className: "space-y-4 p-4", defaultValues: { withDefaultValue: (0, dayjs_1.default)("2023-10-20T14:32:10.511").toISOString() } }, ({ control }) => (react_1.default.createElement(react_1.default.Fragment, null,
15
+ react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { control: control, isClearable: true, isRequired: true, label: "Default datetime picker", name: "default" }),
16
+ react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { control: control, isClearable: true, isRequired: true, label: "Default datetime picker with default value", name: "withDefaultValue" }),
17
+ react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { control: control, isClearable: true, isRequired: true, label: "Date time picker with input min/max validation - only next 7 days", maxDate: (0, dayjs_1.default)().add(6, "days").format(date_picker_input_1.OUTPUT_DATE_FORMAT), minDate: (0, dayjs_1.default)().format(date_picker_input_1.OUTPUT_DATE_FORMAT), name: "withMinMaxValidation" }),
18
+ react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { bottomContent: react_1.default.createElement("div", null,
19
+ "Bottom content",
20
+ react_1.default.createElement("p", null, "Here can goes anything")), control: control, isClearable: true, isRequired: true, label: "With bottom content", name: "default" }),
21
+ react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { CustomDatetimePicker: (props) => (react_1.default.createElement(button_1.Button, { onClick: () => {
22
+ props.onChange((0, dayjs_1.default)()
23
+ .add(1, "day")
24
+ .startOf("day")
25
+ .format("YYYY-MM-DD[T]HH:mm:ssZ"));
26
+ props.onClose();
27
+ } }, "Z\u00EDtra")), control: control, isClearable: true, label: "With custom datetime picker", name: "withCustomDatetimePicker" })))));
28
+ }
@@ -0,0 +1 @@
1
+ export * from "./datetime-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("./datetime-picker-input"), exports);
@@ -0,0 +1,31 @@
1
+ declare const _default: {
2
+ "uxf-form-datetime-picker-input": {
3
+ validation: {
4
+ required: {
5
+ cs: string;
6
+ en: string;
7
+ sk: string;
8
+ de: string;
9
+ };
10
+ "invalid-datetime-format": {
11
+ cs: string;
12
+ en: string;
13
+ sk: string;
14
+ de: string;
15
+ };
16
+ "min-date": {
17
+ cs: string;
18
+ en: string;
19
+ sk: string;
20
+ de: string;
21
+ };
22
+ "max-date": {
23
+ cs: string;
24
+ en: string;
25
+ sk: string;
26
+ de: string;
27
+ };
28
+ };
29
+ };
30
+ };
31
+ export default _default;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ "uxf-form-datetime-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-datetime-format": {
13
+ cs: "Datum a čas musí být ve formátu {{format}}.",
14
+ en: "Date and time must be in format {{format}}.",
15
+ sk: "Dátum a čas musí byť vo formáte {{format}}.",
16
+ de: "Datum und Uhrzeit müssen im Format {{format}} sein.",
17
+ },
18
+ "min-date": {
19
+ cs: "Minimální datum, který je možné zadat, je: {{minDate}}",
20
+ en: "The minimum date that can be entered is: {{minDate}}",
21
+ sk: "Minimálny dátum, ktorý je možné zadať, je: {{minDate}}",
22
+ de: "Das minimale Datum, das eingegeben werden kann, ist: {{minDate}}",
23
+ },
24
+ "max-date": {
25
+ cs: "Maximální datum, který je možné zadat, je: {{maxDate}}",
26
+ en: "The maximum date that can be entered is: {{maxDate}}",
27
+ sk: "Maximálny dátum, ktorý je možné zadať, je: {{maxDate}}",
28
+ de: "Das maximale Datum, das eingegeben werden kann, ist: {{maxDate}}",
29
+ },
30
+ },
31
+ },
32
+ };
@@ -0,0 +1,13 @@
1
+ import { DropzoneInputProps as UIDropzoneProps } from "@uxf/ui/dropzone";
2
+ import React from "react";
3
+ import { FieldValues } from "react-hook-form";
4
+ import { ControlProps } from "../types";
5
+ export type DropzoneProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIDropzoneProps, "isFocused" | "isInvalid" | "onChange" | "value"> & {
6
+ minFilesCount?: number;
7
+ onChange?: UIDropzoneProps["onChange"];
8
+ requiredMessage?: string;
9
+ };
10
+ export declare function DropzoneInput<FormData extends FieldValues>(props: DropzoneProps<FormData>): React.JSX.Element;
11
+ export declare namespace DropzoneInput {
12
+ var displayName: string;
13
+ }
@@ -0,0 +1,67 @@
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.DropzoneInput = DropzoneInput;
8
+ const translations_1 = require("@uxf/core-react/translations");
9
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
10
+ const dropzone_1 = require("@uxf/ui/dropzone");
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 DropzoneInput(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
+ disabled: props.isDisabled,
22
+ name: props.name,
23
+ rules: {
24
+ ...props.rules,
25
+ validate: {
26
+ default: (value) => {
27
+ var _a;
28
+ if (props.isRequired &&
29
+ props.minFilesCount !== 0 &&
30
+ (!value || value.length < ((_a = props.minFilesCount) !== null && _a !== void 0 ? _a : 1))) {
31
+ return props.requiredMessage || t("uxf-form-dropzone:validation.required");
32
+ }
33
+ if (props.maxFilesCount && value && value.length > props.maxFilesCount) {
34
+ return t("uxf-form-dropzone:validation.max-files-count", {
35
+ maxFilesCount: props.maxFilesCount,
36
+ value: value,
37
+ });
38
+ }
39
+ if (props.minFilesCount && value && value.length < props.minFilesCount) {
40
+ return t("uxf-form-dropzone:validation.min-files-count", {
41
+ minFilesCount: props.minFilesCount,
42
+ value: value,
43
+ });
44
+ }
45
+ // TODO – validate this only on submit
46
+ // if (value?.some((file) => file.id < 0)) {
47
+ // return "Nahrávání souborů ještě nebylo dokončeno";
48
+ // }
49
+ return true;
50
+ },
51
+ ...(((_b = props.rules) === null || _b === void 0 ? void 0 : _b.validate)
52
+ ? typeof props.rules.validate === "function"
53
+ ? { custom: props.rules.validate }
54
+ : props.rules.validate
55
+ : {}),
56
+ },
57
+ },
58
+ shouldUnregister: props.shouldUnregister,
59
+ });
60
+ const onChange = (value, event) => {
61
+ var _a;
62
+ field.onChange(value);
63
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
64
+ };
65
+ return (react_1.default.createElement(dropzone_1.Dropzone, { accept: props.accept, className: props.className, helperText: ((_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) || props.helperText, icon: props.icon, id: id, isDisabled: formContext.isFormDisabled || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isNotClickable: props.isNotClickable, isNotDraggable: props.isNotDraggable, isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, label: props.label, maxFileSize: props.maxFileSize, maxFilesCount: props.maxFilesCount, minFileSize: props.minFileSize, name: props.name, onChange: onChange, onDropRejected: props.onDropRejected, onUploadComplete: props.onUploadComplete, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, ref: field.ref, style: props.style, value: field.value }));
66
+ }
67
+ DropzoneInput.displayName = "UxfFormDropzoneInput";
@@ -0,0 +1,11 @@
1
+ import { DropzoneListProps as UIDropzoneListProps } from "@uxf/ui/dropzone";
2
+ import React from "react";
3
+ import { FieldValues } from "react-hook-form";
4
+ import { ControlProps } from "../types";
5
+ export interface DropzoneListProps<FormData extends FieldValues> extends Pick<ControlProps<FormData>, "control" | "name">, Pick<UIDropzoneListProps, "className" | "errorText" | "isDownloadableOnClick" | "onRemoveConfirm" | "renderItem" | "style"> {
6
+ onChange?: UIDropzoneListProps["onChange"];
7
+ }
8
+ export declare function DropzoneList<FormData extends FieldValues>(props: DropzoneListProps<FormData>): React.JSX.Element;
9
+ export declare namespace DropzoneList {
10
+ var displayName: string;
11
+ }
@@ -0,0 +1,23 @@
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.DropzoneList = DropzoneList;
8
+ const dropzone_1 = require("@uxf/ui/dropzone");
9
+ const react_1 = __importDefault(require("react"));
10
+ const react_hook_form_1 = require("react-hook-form");
11
+ function DropzoneList(props) {
12
+ const { field } = (0, react_hook_form_1.useController)({
13
+ control: props.control,
14
+ name: props.name,
15
+ });
16
+ const onChange = (value, event) => {
17
+ var _a;
18
+ field.onChange(value);
19
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
20
+ };
21
+ return (react_1.default.createElement(dropzone_1.Dropzone.List, { className: props.className, errorText: props.errorText, isDownloadableOnClick: props.isDownloadableOnClick, name: props.name, onChange: onChange, onRemoveConfirm: props.onRemoveConfirm, renderItem: props.renderItem, style: props.style, value: field.value }));
22
+ }
23
+ DropzoneList.displayName = "UxfFormDropzoneList";
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare function Default(): React.JSX.Element;
@@ -0,0 +1,50 @@
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 handle_rejected_files_1 = require("@uxf/ui/dropzone/handle-rejected-files");
9
+ const get_dropzone_state_1 = require("@uxf/ui/utils/get-dropzone-state");
10
+ const upload_file_mock_1 = require("@uxf/ui/utils/mocks/upload-file.mock");
11
+ const validator_exceptions_1 = require("@uxf/ui/utils/validator/validator-exceptions");
12
+ const react_1 = __importDefault(require("react"));
13
+ const storybook_form_1 = require("../storybook/storybook-form");
14
+ const index_1 = require("./index");
15
+ const DUMMY_FILES = [
16
+ {
17
+ id: 1,
18
+ uuid: "1",
19
+ name: "file1",
20
+ extension: "jpg",
21
+ namespace: null,
22
+ progress: null,
23
+ },
24
+ {
25
+ id: 2,
26
+ uuid: "2",
27
+ name: "file2",
28
+ extension: "pdf",
29
+ namespace: null,
30
+ progress: null,
31
+ },
32
+ ];
33
+ function Default() {
34
+ const onRemoveConfirm = () => Promise.resolve(confirm("Do you want to delete the file?"));
35
+ const onUploadError = async (e) => {
36
+ if (e === validator_exceptions_1.ValidatorExceptions.MaxFileSize) {
37
+ // eslint-disable-next-line no-alert
38
+ alert("Maximální velikost souboru je 1\xa0MB.");
39
+ }
40
+ };
41
+ return (react_1.default.createElement(storybook_form_1.StorybookForm, { defaultValues: { dropzone: DUMMY_FILES } }, ({ control, watch }) => {
42
+ const { status } = (0, get_dropzone_state_1.getDropzoneState)(watch("dropzone"));
43
+ return (react_1.default.createElement("div", { className: "space-y-8 p-20 lg:w-1/2" },
44
+ react_1.default.createElement(index_1.Dropzone, { accept: {
45
+ "image/png": [".png"],
46
+ }, control: control, helperText: "Allow multiple files, 1MB max file size, only .png", isDisabled: status === "UPLOADING", isRequired: true, label: "Use drag and drop or click to upload", maxFileSize: 1024 * 1024, name: "dropzone", onDropRejected: handle_rejected_files_1.handleRejectedFiles, onUploadError: onUploadError, onUploadFile: upload_file_mock_1.uploadFile }),
47
+ react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit"),
48
+ react_1.default.createElement(index_1.Dropzone.List, { control: control, errorText: "Oops, n\u011Bco se pokazilo", name: "dropzone", onRemoveConfirm: onRemoveConfirm })));
49
+ }));
50
+ }
@@ -0,0 +1,9 @@
1
+ import { DropzoneFile } from "@uxf/ui/dropzone/types";
2
+ import { DropzoneInput } from "./dropzone-input";
3
+ import { DropzoneList } from "./dropzone-list";
4
+ export type { DropzoneProps } from "./dropzone-input";
5
+ export type { DropzoneListProps } from "./dropzone-list";
6
+ export type DropzoneValue = DropzoneFile[] | undefined;
7
+ export declare const Dropzone: typeof DropzoneInput & {
8
+ List: typeof DropzoneList;
9
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dropzone = void 0;
4
+ const dropzone_input_1 = require("./dropzone-input");
5
+ const dropzone_list_1 = require("./dropzone-list");
6
+ exports.Dropzone = Object.assign(dropzone_input_1.DropzoneInput, { List: dropzone_list_1.DropzoneList });
@@ -0,0 +1,31 @@
1
+ declare const _default: {
2
+ "uxf-form-dropzone": {
3
+ validation: {
4
+ required: {
5
+ cs: string;
6
+ en: string;
7
+ sk: string;
8
+ de: string;
9
+ };
10
+ "max-files-count": {
11
+ cs: string;
12
+ en: string;
13
+ sk: string;
14
+ de: string;
15
+ };
16
+ "min-files-count": {
17
+ cs: string;
18
+ en: string;
19
+ sk: string;
20
+ de: string;
21
+ };
22
+ "upload-not-completed": {
23
+ cs: string;
24
+ en: string;
25
+ sk: string;
26
+ de: string;
27
+ };
28
+ };
29
+ };
30
+ };
31
+ export default _default;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ "uxf-form-dropzone": {
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
+ "max-files-count": {
13
+ cs: "Maximální počet souborů je {{maxFilesCount}}",
14
+ en: "Maximum number of files is {{maxFilesCount}}",
15
+ sk: "Maximálny počet súborov je {{maxFilesCount}}",
16
+ de: "Maximale Anzahl der Dateien ist {{maxFilesCount}}",
17
+ },
18
+ "min-files-count": {
19
+ cs: "Minimální počet souborů je {{minFilesCount}}",
20
+ en: "Minimum number of files is {{minFilesCount}}",
21
+ sk: "Minimálny počet súborov je {{minFilesCount}}",
22
+ de: "Minimale Anzahl der Dateien ist {{minFilesCount}}",
23
+ },
24
+ "upload-not-completed": {
25
+ cs: "Nahrávání souborů ještě nebylo dokončeno",
26
+ en: "File upload has not been completed yet",
27
+ sk: "Nahrávanie súborov ešte nebolo dokončené",
28
+ de: "Datei-Upload wurde noch nicht abgeschlossen",
29
+ },
30
+ },
31
+ },
32
+ };
@@ -0,0 +1,14 @@
1
+ import { FileResponse } from "@uxf/core/types";
2
+ import { FileInputProps as UIFileInputProps } from "@uxf/ui/file-input";
3
+ import React from "react";
4
+ import { FieldValues } from "react-hook-form";
5
+ import { ControlProps } from "../types";
6
+ export type FileInputProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIFileInputProps, "isFocused" | "isInvalid" | "onChange" | "value"> & {
7
+ onChange?: UIFileInputProps["onChange"];
8
+ requiredMessage?: string;
9
+ };
10
+ export type FileInputValue = FileResponse | null;
11
+ export declare function FileInput<FormData extends FieldValues>(props: FileInputProps<FormData>): React.JSX.Element;
12
+ export declare namespace FileInput {
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.FileInput = FileInput;
8
+ const translations_1 = require("@uxf/core-react/translations");
9
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
10
+ const file_input_1 = require("@uxf/ui/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 FileInput(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-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(file_input_1.FileInput, { accept: props.accept, className: props.className, 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, 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, maxFileSize: props.maxFileSize, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, onUploadError: props.onUploadError, onUploadFile: props.onUploadFile, placeholder: props.placeholder, ref: field.ref, size: props.size, uploadButtonLabel: props.uploadButtonLabel, value: field.value, variant: props.variant }));
41
+ }
42
+ FileInput.displayName = "FileInput";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { FileInput } from "./file-input";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof FileInput;
6
+ };
7
+ export default _default;
8
+ export declare function Default(): React.JSX.Element;
@@ -0,0 +1,31 @@
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 file_input_1 = require("./file-input");
12
+ exports.default = {
13
+ title: "Form/FileInput",
14
+ component: file_input_1.FileInput,
15
+ };
16
+ const DUMMY_FILE = {
17
+ id: 1,
18
+ uuid: "1",
19
+ name: "file1",
20
+ namespace: null,
21
+ extension: "jpg",
22
+ };
23
+ function Default() {
24
+ const storyFormFileInputs = (control, mode) => (react_1.default.createElement("div", { className: "space-y-4" },
25
+ react_1.default.createElement(file_input_1.FileInput, { control: control, isClearable: true, label: "Default file input", name: `default-${mode}`, onUploadFile: upload_file_mock_1.uploadFile, placeholder: "Nahraj soubor" }),
26
+ react_1.default.createElement(file_input_1.FileInput, { control: control, id: `required-${mode}`, isRequired: true, label: "Required file input", name: `required-${mode}`, onUploadFile: upload_file_mock_1.uploadFile }),
27
+ react_1.default.createElement(file_input_1.FileInput, { control: control, isClearable: true, label: "Custom button label", name: `default-${mode}`, onUploadFile: upload_file_mock_1.uploadFile, placeholder: "Nahrajte soubor", uploadButtonLabel: "Nahrajte dokument" }),
28
+ react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
29
+ return (react_1.default.createElement(storybook_form_1.StorybookForm, { defaultValues: { "default-light": DUMMY_FILE } }, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
30
+ react_1.default.createElement("div", { className: "space-y-2 p-20 lg:w-1/2" }, storyFormFileInputs(control, "light"))))));
31
+ }
@@ -0,0 +1 @@
1
+ export * from "./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("./file-input"), exports);
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ "uxf-form-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;