@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,87 @@
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.NumberInput = NumberInput;
8
+ const translations_1 = require("@uxf/core-react/translations");
9
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
10
+ const text_input_1 = require("@uxf/ui/text-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 NumberInput(props) {
15
+ var _a, _b, _c, _d, _e, _f;
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-number-input:validation.required")
25
+ : undefined,
26
+ ...props.rules,
27
+ validate: {
28
+ validMinNumber: (value) => {
29
+ if (!value) {
30
+ return;
31
+ }
32
+ if (typeof props.min === "number" && !isNaN(props.min) && value < props.min) {
33
+ return (props.minMessage ||
34
+ t("uxf-form-number-input:validation.min-value", { min: props.min, value: value }));
35
+ }
36
+ },
37
+ validMaxNumber: (value) => {
38
+ if (!value) {
39
+ return;
40
+ }
41
+ if (typeof props.max === "number" && !isNaN(props.max) && value > props.max) {
42
+ return (props.maxMessage ||
43
+ t("uxf-form-number-input:validation.max-value", { max: props.max, value: value }));
44
+ }
45
+ },
46
+ ...(typeof ((_b = props.rules) === null || _b === void 0 ? void 0 : _b.validate) === "function"
47
+ ? { custom: props.rules.validate }
48
+ : (_c = props.rules) === null || _c === void 0 ? void 0 : _c.validate),
49
+ },
50
+ },
51
+ shouldUnregister: props.shouldUnregister,
52
+ });
53
+ const onBlur = (event) => {
54
+ var _a;
55
+ field.onBlur();
56
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
57
+ };
58
+ const onKeyDown = (event) => {
59
+ var _a;
60
+ // Allow special keys
61
+ const specialKeys = ["Backspace", "Delete", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Tab"];
62
+ // Allow keys for copy/paste/select/cut
63
+ const controlKeys = ["v", "V", "c", "C", "x", "X", "a", "A"];
64
+ // Allow digits and decimal point (.,)
65
+ const allowedDigits = /[0-9+\-.,]/;
66
+ const key = event.key;
67
+ // Check if the key is allowed
68
+ if (!specialKeys.includes(key) && !allowedDigits.test(key)) {
69
+ // Check if Ctrl or Command key is pressed along with control key
70
+ if (!(event.ctrlKey || event.metaKey) || !controlKeys.includes(key)) {
71
+ event.preventDefault();
72
+ }
73
+ }
74
+ (_a = props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, event);
75
+ };
76
+ const onChange = (value, event) => {
77
+ var _a;
78
+ const parsedValue = props.decimalPlaces
79
+ ? parseFloat(value.replace(" ", ""))
80
+ : parseInt(value.replace(" ", ""), 10);
81
+ const returnValue = isNaN(parsedValue) ? null : parsedValue;
82
+ field.onChange(returnValue);
83
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, returnValue, event);
84
+ };
85
+ return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, autoFocus: props.autoFocus, className: props.className, enterKeyHint: props.enterKeyHint, 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, inputMode: props.decimalPlaces ? "decimal" : "numeric", 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, max: props.max, min: props.min, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, onKeyDown: onKeyDown, pattern: props.pattern, placeholder: props.placeholder, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, step: props.decimalPlaces ? Number(0).toFixed(props.decimalPlaces - 1) + "1" : props.step, style: props.style, type: "number", value: (_f = field.value) !== null && _f !== void 0 ? _f : "", variant: props.variant }));
86
+ }
87
+ NumberInput.displayName = "UxfFormNumberInput";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { NumberInput } from "./number-input";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof NumberInput;
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 number_input_1 = require("./number-input");
11
+ exports.default = {
12
+ title: "Form/NumberInput",
13
+ component: number_input_1.NumberInput,
14
+ };
15
+ function Default() {
16
+ const storyFormNumberInputs = (control) => (react_1.default.createElement("div", { className: "light mb-4 space-y-4 p-4" },
17
+ react_1.default.createElement(number_input_1.NumberInput, { control: control, label: "Default input", name: "default" }),
18
+ react_1.default.createElement(number_input_1.NumberInput, { control: control, isRequired: true, label: "Required input", name: "required" }),
19
+ react_1.default.createElement(number_input_1.NumberInput, { control: control, decimalPlaces: 3, label: "Dec\u00EDmal input", name: "decimal" }),
20
+ react_1.default.createElement(number_input_1.NumberInput, { control: control, label: "max50 input", max: 50, name: "max50" }),
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" }, storyFormNumberInputs(control))))));
24
+ }
@@ -0,0 +1,25 @@
1
+ declare const _default: {
2
+ "uxf-form-number-input": {
3
+ validation: {
4
+ required: {
5
+ cs: string;
6
+ en: string;
7
+ sk: string;
8
+ de: string;
9
+ };
10
+ "max-value": {
11
+ cs: string;
12
+ en: string;
13
+ sk: string;
14
+ de: string;
15
+ };
16
+ "min-value": {
17
+ cs: string;
18
+ en: string;
19
+ sk: string;
20
+ de: string;
21
+ };
22
+ };
23
+ };
24
+ };
25
+ export default _default;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ "uxf-form-number-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
+ "max-value": {
13
+ cs: "Hodnota musí být menší nebo rovna {{max}}.",
14
+ en: "Value must be less than or equal to {{max}}.",
15
+ sk: "Hodnota musí byť menšia alebo rovná ako {{max}}.",
16
+ de: "Wert muss kleiner oder gleich {{max}} sein.",
17
+ },
18
+ "min-value": {
19
+ cs: "Hodnota musí být větší nebo rovna {{min}}.",
20
+ en: "Value must be greater than or equal to {{min}}.",
21
+ sk: "Hodnota musí byť väčšia alebo rovná ako {{min}}.",
22
+ de: "Wert muss größer oder gleich {{min}} sein.",
23
+ },
24
+ },
25
+ },
26
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/form",
3
- "version": "11.74.0",
3
+ "version": "11.74.1",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,8 +17,8 @@
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
19
  "@uxf/core": "11.72.3",
20
- "@uxf/core-react": "11.74.0",
21
- "@uxf/ui": "11.74.0",
20
+ "@uxf/core-react": "11.74.1",
21
+ "@uxf/ui": "11.74.1",
22
22
  "coordinate-parser": "1.0.7",
23
23
  "dayjs": "1.11.13",
24
24
  "react-hook-form": "7.53.0"
@@ -0,0 +1 @@
1
+ export * from "./password-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("./password-input"), exports);
@@ -0,0 +1,15 @@
1
+ import { TextInputProps as UITextInputProps } from "@uxf/ui/text-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
+ export type PasswordInputProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UITextInputProps, "isFocused" | "isInvalid" | "max" | "min" | "name" | "onChange" | "value" | "type"> & {
7
+ minLengthMessage?: string;
8
+ onChange?: FormControlProps<string | null>["onChange"];
9
+ renderVisibilitySetter?: (isVisible: boolean, onToggle: () => void) => ReactNode;
10
+ requiredMessage?: string;
11
+ };
12
+ export declare function PasswordInput<FormData extends FieldValues>(props: PasswordInputProps<FormData>): React.JSX.Element;
13
+ export declare namespace PasswordInput {
14
+ var displayName: string;
15
+ }
@@ -0,0 +1,108 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.PasswordInput = PasswordInput;
28
+ const use_on_unmount_1 = require("@uxf/core-react/hooks/use-on-unmount");
29
+ const translations_1 = require("@uxf/core-react/translations");
30
+ const compose_refs_1 = require("@uxf/core-react/utils/compose-refs");
31
+ const is_nil_1 = require("@uxf/core/utils/is-nil");
32
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
33
+ const button_1 = require("@uxf/ui/button");
34
+ const icon_1 = require("@uxf/ui/icon");
35
+ const text_input_1 = require("@uxf/ui/text-input");
36
+ const react_1 = __importStar(require("react"));
37
+ const react_hook_form_1 = require("react-hook-form");
38
+ const form_context_1 = require("../form-id-context/form-context");
39
+ function usePasswordVisibility() {
40
+ const inputRef = (0, react_1.useRef)(null);
41
+ const [isVisible, setIsVisible] = (0, react_1.useState)(false);
42
+ const timer = (0, react_1.useRef)();
43
+ const visibilityChangeHandler = () => {
44
+ if ((0, is_nil_1.isNil)(inputRef.current)) {
45
+ return;
46
+ }
47
+ setIsVisible((prev) => !prev);
48
+ timer.current = window.setTimeout(() => {
49
+ if ((0, is_nil_1.isNil)(inputRef.current)) {
50
+ return;
51
+ }
52
+ const newCursorPosition = inputRef.current.value.length;
53
+ inputRef.current.selectionStart = newCursorPosition;
54
+ inputRef.current.selectionEnd = newCursorPosition;
55
+ }, 0);
56
+ };
57
+ (0, use_on_unmount_1.useOnUnmount)(() => clearTimeout(timer.current));
58
+ return { isVisible, inputRef, onToggle: visibilityChangeHandler };
59
+ }
60
+ function PasswordInput(props) {
61
+ var _a, _b, _c, _d, _e, _f, _g, _h;
62
+ const formContext = (0, form_context_1.useFormContext)();
63
+ const t = (0, translations_1.useUxfTranslation)();
64
+ const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
65
+ const { field, fieldState } = (0, react_hook_form_1.useController)({
66
+ control: props.control,
67
+ name: props.name,
68
+ shouldUnregister: props.shouldUnregister,
69
+ rules: {
70
+ required: props.isRequired
71
+ ? props.requiredMessage || t("uxf-form-password-input:validation.required")
72
+ : undefined,
73
+ ...props.rules,
74
+ validate: {
75
+ minLength: (value) => {
76
+ if (!value) {
77
+ return;
78
+ }
79
+ if (typeof props.minLength === "number" &&
80
+ !isNaN(props.minLength) &&
81
+ value.length < props.minLength) {
82
+ return (props.minLengthMessage ||
83
+ t("uxf-form-password-input:validation.min-length", {
84
+ minLength: props.minLength,
85
+ value: value,
86
+ }));
87
+ }
88
+ },
89
+ },
90
+ ...(typeof ((_b = props.rules) === null || _b === void 0 ? void 0 : _b.validate) === "function" ? { custom: props.rules.validate } : (_c = props.rules) === null || _c === void 0 ? void 0 : _c.validate),
91
+ },
92
+ });
93
+ const passwordVisibility = usePasswordVisibility();
94
+ const inputRef = (0, compose_refs_1.composeRefs)(field.ref, passwordVisibility.inputRef);
95
+ const onBlur = (event) => {
96
+ var _a;
97
+ field.onBlur();
98
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
99
+ };
100
+ const onChange = (value, event) => {
101
+ var _a;
102
+ field.onChange(value);
103
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
104
+ };
105
+ return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, autoFocus: props.autoFocus, className: props.className, enterKeyHint: props.enterKeyHint, 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, inputMode: props.inputMode, 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, maxLength: props.maxLength, minLength: props.minLength, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, onKeyDown: props.onKeyDown, pattern: props.pattern, placeholder: props.placeholder, ref: inputRef, rightAddon: props.rightAddon, rightElement: (_g = (_f = props.renderVisibilitySetter) === null || _f === void 0 ? void 0 : _f.call(props, passwordVisibility.isVisible, passwordVisibility.onToggle)) !== null && _g !== void 0 ? _g : (react_1.default.createElement(button_1.Button, { onClick: passwordVisibility.onToggle, size: "sm", variant: "text" },
106
+ react_1.default.createElement(icon_1.Icon, { name: passwordVisibility.isVisible ? "eye-slash" : "eye", size: 20 }))), size: props.size, style: props.style, type: passwordVisibility.isVisible ? "text" : "password", value: (_h = field.value) !== null && _h !== void 0 ? _h : "", variant: props.variant }));
107
+ }
108
+ PasswordInput.displayName = "UxfFormPasswordInput";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { PasswordInput } from "./password-input";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof PasswordInput;
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 react_1 = __importDefault(require("react"));
9
+ const storybook_form_1 = require("../storybook/storybook-form");
10
+ const password_input_1 = require("./password-input");
11
+ exports.default = {
12
+ title: "Form/PasswordInput",
13
+ component: password_input_1.PasswordInput,
14
+ };
15
+ function Default() {
16
+ const storyFormPasswordInputs = (control) => (react_1.default.createElement("div", { className: "mb-4 space-y-4 p-4" },
17
+ react_1.default.createElement(password_input_1.PasswordInput, { control: control, label: "Default input", name: "default" }),
18
+ react_1.default.createElement(password_input_1.PasswordInput, { control: control, isRequired: true, label: "Min length 8", minLength: 12, name: "minLength" }),
19
+ react_1.default.createElement(password_input_1.PasswordInput, { control: control, isRequired: true, label: "Required input", name: "required" }),
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" }, storyFormPasswordInputs(control))))));
23
+ }
@@ -0,0 +1,19 @@
1
+ declare const _default: {
2
+ "uxf-form-password-input": {
3
+ validation: {
4
+ required: {
5
+ cs: string;
6
+ en: string;
7
+ sk: string;
8
+ de: string;
9
+ };
10
+ "min-length": {
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-password-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
+ "min-length": {
13
+ cs: "Heslo musí být nejméně {{minLength}} znaků dlouhé.",
14
+ en: "Password must be at least {{minLength}} characters long.",
15
+ sk: "Heslo musí mať aspoň {{minLength}} znakov.",
16
+ de: "Passwort muss mindestens {{minLength}} Zeichen lang sein.",
17
+ },
18
+ },
19
+ },
20
+ };
@@ -0,0 +1 @@
1
+ export * from "./radio-group";
@@ -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("./radio-group"), exports);
@@ -0,0 +1,13 @@
1
+ import { RadioGroupOptionValueId, RadioGroupProps as UIRadioGroupProps } from "@uxf/ui/radio-group";
2
+ import React from "react";
3
+ import { FieldValues } from "react-hook-form";
4
+ import { ControlProps } from "../types";
5
+ export type RadioGroupProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIRadioGroupProps, "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
6
+ onChange?: UIRadioGroupProps["onChange"];
7
+ requiredMessage?: string;
8
+ };
9
+ export type RadioGroupValue<T extends RadioGroupOptionValueId> = T | null;
10
+ export declare function RadioGroup<FormData extends Record<string, any>>(props: RadioGroupProps<FormData>): React.JSX.Element;
11
+ export declare namespace RadioGroup {
12
+ var displayName: string;
13
+ }
@@ -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.RadioGroup = RadioGroup;
8
+ const translations_1 = require("@uxf/core-react/translations");
9
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
10
+ const radio_group_1 = require("@uxf/ui/radio-group");
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 RadioGroup(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-radio-group: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(radio_group_1.RadioGroup, { className: props.className, forceColumn: props.forceColumn, 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: props.options.length === 0 || 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, options: props.options, radioSize: props.radioSize, ref: field.ref, style: props.style, value: (_d = field.value) !== null && _d !== void 0 ? _d : null, variant: props.variant }));
41
+ }
42
+ RadioGroup.displayName = "UxfFormRadioGroup";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { RadioGroup } from "./index";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof RadioGroup;
6
+ };
7
+ export default _default;
8
+ export declare function Default(): React.JSX.Element;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.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 index_1 = require("./index");
11
+ exports.default = {
12
+ title: "Form/RadioGroup",
13
+ component: index_1.RadioGroup,
14
+ };
15
+ const options = [
16
+ {
17
+ id: "1",
18
+ label: "Radio one",
19
+ },
20
+ {
21
+ id: "2",
22
+ label: "Radio two",
23
+ },
24
+ {
25
+ id: "3",
26
+ label: "Radio three-sixty",
27
+ },
28
+ ];
29
+ function Default() {
30
+ const storyFormRadioGroup = (control) => (react_1.default.createElement("div", { className: "space-y-4" },
31
+ react_1.default.createElement(index_1.RadioGroup, { control: control, id: "radio-group", label: "Radio group form", name: "radio-group", options: options }),
32
+ react_1.default.createElement(index_1.RadioGroup, { control: control, id: "radio-group", isDisabled: true, label: "Radio group form disabled", name: "radio-group-disabled", options: options }),
33
+ react_1.default.createElement(index_1.RadioGroup, { control: control, helperText: "Choose one option", id: "radio-group", label: "Radio group form with helper text", name: "radio-group-helper-text", options: options }),
34
+ react_1.default.createElement(index_1.RadioGroup, { control: control, id: "radio-group", label: "Radio group form with variant button", name: "radio-group-button", options: options, variant: "radioButton" }),
35
+ react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")));
36
+ return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
37
+ react_1.default.createElement("div", { className: "space-y-2 p-20 lg:w-1/2" }, storyFormRadioGroup(control))))));
38
+ }
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ "uxf-form-radio-group": {
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-radio-group": {
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/readmes.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import avatarFileInputReadme from "./avatar-file-input/README.md";
2
+ export declare const readmes: {
3
+ readonly "avatar-file-input": typeof avatarFileInputReadme;
4
+ readonly "checkbox-button": typeof avatarFileInputReadme;
5
+ readonly "checkbox-input": typeof avatarFileInputReadme;
6
+ readonly "checkbox-list": typeof avatarFileInputReadme;
7
+ readonly "color-radio-group": typeof avatarFileInputReadme;
8
+ readonly combobox: typeof avatarFileInputReadme;
9
+ readonly "date-picker-input": typeof avatarFileInputReadme;
10
+ readonly "date-range-picker-input": typeof avatarFileInputReadme;
11
+ readonly "datetime-picker-input": typeof avatarFileInputReadme;
12
+ readonly dropzone: typeof avatarFileInputReadme;
13
+ readonly "file-input": typeof avatarFileInputReadme;
14
+ readonly form: typeof avatarFileInputReadme;
15
+ readonly "form-renderer": typeof avatarFileInputReadme;
16
+ readonly "gps-input": typeof avatarFileInputReadme;
17
+ readonly "money-input": typeof avatarFileInputReadme;
18
+ readonly "multi-combobox": typeof avatarFileInputReadme;
19
+ readonly "multi-select": typeof avatarFileInputReadme;
20
+ readonly "number-input": typeof avatarFileInputReadme;
21
+ readonly "password-input": typeof avatarFileInputReadme;
22
+ readonly "radio-group": typeof avatarFileInputReadme;
23
+ readonly select: typeof avatarFileInputReadme;
24
+ readonly "text-input": typeof avatarFileInputReadme;
25
+ readonly textarea: typeof avatarFileInputReadme;
26
+ readonly "time-picker-input": typeof avatarFileInputReadme;
27
+ readonly toggle: typeof avatarFileInputReadme;
28
+ };