@uxf/form 11.72.3 → 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 (78) hide show
  1. package/README.md +3 -1
  2. package/avatar-file-input/avatar-file-input.js +5 -1
  3. package/avatar-file-input/translations.d.ts +13 -0
  4. package/avatar-file-input/translations.js +14 -0
  5. package/checkbox-button/checkbox-button.js +5 -1
  6. package/checkbox-button/translations.d.ts +13 -0
  7. package/checkbox-button/translations.js +14 -0
  8. package/checkbox-input/checkbox-input.js +5 -1
  9. package/checkbox-input/translations.d.ts +13 -0
  10. package/checkbox-input/translations.js +14 -0
  11. package/checkbox-list/checkbox-list.js +5 -1
  12. package/checkbox-list/translations.d.ts +13 -0
  13. package/checkbox-list/translations.js +14 -0
  14. package/color-radio-group/color-radio-group.js +5 -1
  15. package/color-radio-group/translations.d.ts +13 -0
  16. package/color-radio-group/translations.js +14 -0
  17. package/combobox/combobox.js +5 -1
  18. package/combobox/translations.d.ts +13 -0
  19. package/combobox/translations.js +14 -0
  20. package/date-picker-input/date-picker-input.js +17 -4
  21. package/date-picker-input/translations.d.ts +31 -0
  22. package/date-picker-input/translations.js +32 -0
  23. package/date-range-picker-input/date-range-picker-input.js +12 -3
  24. package/date-range-picker-input/translations.d.ts +25 -0
  25. package/date-range-picker-input/translations.js +26 -0
  26. package/datetime-picker-input/datetime-picker-input.js +17 -4
  27. package/datetime-picker-input/translations.d.ts +31 -0
  28. package/datetime-picker-input/translations.js +32 -0
  29. package/dropzone/dropzone-input.js +11 -3
  30. package/dropzone/translations.d.ts +31 -0
  31. package/dropzone/translations.js +32 -0
  32. package/file-input/file-input.js +5 -1
  33. package/file-input/translations.d.ts +13 -0
  34. package/file-input/translations.js +14 -0
  35. package/form-renderer/field/base-field.js +3 -1
  36. package/form-renderer/field/one-to-many.js +4 -2
  37. package/form-renderer/form-renderer.js +3 -1
  38. package/form-renderer/translations.d.ts +33 -0
  39. package/form-renderer/translations.js +34 -0
  40. package/gps-input/gps-input.js +11 -9
  41. package/gps-input/translations.d.ts +31 -0
  42. package/gps-input/translations.js +32 -0
  43. package/money-input/money-input.js +5 -1
  44. package/money-input/translations.d.ts +13 -0
  45. package/money-input/translations.js +14 -0
  46. package/multi-combobox/multi-combobox.js +5 -1
  47. package/multi-combobox/translations.d.ts +13 -0
  48. package/multi-combobox/translations.js +14 -0
  49. package/multi-select/multi-select.js +5 -1
  50. package/multi-select/translations.d.ts +13 -0
  51. package/multi-select/translations.js +14 -0
  52. package/number-input/number-input.js +27 -12
  53. package/number-input/translations.d.ts +25 -0
  54. package/number-input/translations.js +26 -0
  55. package/package.json +4 -2
  56. package/password-input/password-input.js +24 -9
  57. package/password-input/translations.d.ts +19 -0
  58. package/password-input/translations.js +20 -0
  59. package/radio-group/radio-group.js +5 -1
  60. package/radio-group/translations.d.ts +13 -0
  61. package/radio-group/translations.js +14 -0
  62. package/select/select.js +3 -1
  63. package/select/translations.d.ts +13 -0
  64. package/select/translations.js +14 -0
  65. package/text-input/text-input.js +37 -19
  66. package/text-input/translations.d.ts +31 -0
  67. package/text-input/translations.js +32 -0
  68. package/textarea/textarea.js +5 -1
  69. package/textarea/translations.d.ts +13 -0
  70. package/textarea/translations.js +14 -0
  71. package/time-picker-input/time-picker-input.js +9 -2
  72. package/time-picker-input/translations.d.ts +19 -0
  73. package/time-picker-input/translations.js +20 -0
  74. package/toggle/toggle.js +3 -1
  75. package/toggle/translations.d.ts +13 -0
  76. package/toggle/translations.js +14 -0
  77. package/translations/translations.d.ts +389 -0
  78. package/translations/translations.js +55 -0
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.NumberInput = NumberInput;
8
+ const translations_1 = require("@uxf/core-react/translations");
8
9
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
9
10
  const text_input_1 = require("@uxf/ui/text-input");
10
11
  const react_1 = __importDefault(require("react"));
@@ -13,25 +14,39 @@ const form_context_1 = require("../form-id-context/form-context");
13
14
  function NumberInput(props) {
14
15
  var _a, _b, _c, _d, _e, _f;
15
16
  const formContext = (0, form_context_1.useFormContext)();
17
+ const t = (0, translations_1.useUxfTranslation)();
16
18
  const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
17
19
  const { field, fieldState } = (0, react_hook_form_1.useController)({
18
20
  control: props.control,
19
21
  name: props.name,
20
22
  rules: {
21
- max: typeof props.max === "number" && !isNaN(props.max)
22
- ? {
23
- value: props.max,
24
- message: (_b = props.maxMessage) !== null && _b !== void 0 ? _b : `Hodnota musí být menší nebo rovna ${props.max}.`,
25
- }
23
+ required: props.isRequired
24
+ ? props.requiredMessage || t("uxf-form-number-input:validation.required")
26
25
  : undefined,
27
- min: typeof props.min === "number" && !isNaN(props.min)
28
- ? {
29
- value: props.min,
30
- message: (_c = props.minMessage) !== null && _c !== void 0 ? _c : `Hodnota musí být větší nebo rovna ${props.min}.`,
31
- }
32
- : undefined,
33
- required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
34
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
+ },
35
50
  },
36
51
  shouldUnregister: props.shouldUnregister,
37
52
  });
@@ -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.72.3",
3
+ "version": "11.74.1",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,7 +16,9 @@
16
16
  },
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@uxf/ui": "11.72.3",
19
+ "@uxf/core": "11.72.3",
20
+ "@uxf/core-react": "11.74.1",
21
+ "@uxf/ui": "11.74.1",
20
22
  "coordinate-parser": "1.0.7",
21
23
  "dayjs": "1.11.13",
22
24
  "react-hook-form": "7.53.0"
@@ -26,6 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.PasswordInput = PasswordInput;
28
28
  const use_on_unmount_1 = require("@uxf/core-react/hooks/use-on-unmount");
29
+ const translations_1 = require("@uxf/core-react/translations");
29
30
  const compose_refs_1 = require("@uxf/core-react/utils/compose-refs");
30
31
  const is_nil_1 = require("@uxf/core/utils/is-nil");
31
32
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
@@ -57,22 +58,36 @@ function usePasswordVisibility() {
57
58
  return { isVisible, inputRef, onToggle: visibilityChangeHandler };
58
59
  }
59
60
  function PasswordInput(props) {
60
- var _a, _b, _c, _d, _e, _f;
61
+ var _a, _b, _c, _d, _e, _f, _g, _h;
61
62
  const formContext = (0, form_context_1.useFormContext)();
63
+ const t = (0, translations_1.useUxfTranslation)();
62
64
  const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
63
65
  const { field, fieldState } = (0, react_hook_form_1.useController)({
64
66
  control: props.control,
65
67
  name: props.name,
66
68
  shouldUnregister: props.shouldUnregister,
67
69
  rules: {
68
- minLength: props.minLength
69
- ? {
70
- value: Number(props.minLength),
71
- message: props.minLengthMessage || `Heslo musí být nejméně ${props.minLength} znaků dlouhé.`,
72
- }
70
+ required: props.isRequired
71
+ ? props.requiredMessage || t("uxf-form-password-input:validation.required")
73
72
  : undefined,
74
- required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
75
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),
76
91
  },
77
92
  });
78
93
  const passwordVisibility = usePasswordVisibility();
@@ -87,7 +102,7 @@ function PasswordInput(props) {
87
102
  field.onChange(value);
88
103
  (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
89
104
  };
90
- 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: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : 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: (_e = (_d = props.renderVisibilitySetter) === null || _d === void 0 ? void 0 : _d.call(props, passwordVisibility.isVisible, passwordVisibility.onToggle)) !== null && _e !== void 0 ? _e : (react_1.default.createElement(button_1.Button, { onClick: passwordVisibility.onToggle, size: "sm", variant: "text" },
91
- 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: (_f = field.value) !== null && _f !== void 0 ? _f : "", variant: props.variant }));
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 }));
92
107
  }
93
108
  PasswordInput.displayName = "UxfFormPasswordInput";
@@ -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
+ };
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.RadioGroup = RadioGroup;
8
+ const translations_1 = require("@uxf/core-react/translations");
8
9
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
9
10
  const radio_group_1 = require("@uxf/ui/radio-group");
10
11
  const react_1 = __importDefault(require("react"));
@@ -13,12 +14,15 @@ const form_context_1 = require("../form-id-context/form-context");
13
14
  function RadioGroup(props) {
14
15
  var _a, _b, _c, _d;
15
16
  const formContext = (0, form_context_1.useFormContext)();
17
+ const t = (0, translations_1.useUxfTranslation)();
16
18
  const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
17
19
  const { field, fieldState } = (0, react_hook_form_1.useController)({
18
20
  control: props.control,
19
21
  name: props.name,
20
22
  rules: {
21
- required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
23
+ required: props.isRequired
24
+ ? props.requiredMessage || t("uxf-form-radio-group:validation.required")
25
+ : undefined,
22
26
  ...props.rules,
23
27
  },
24
28
  shouldUnregister: props.shouldUnregister,
@@ -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/select/select.js CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.Select = Select;
8
+ const translations_1 = require("@uxf/core-react/translations");
8
9
  const is_empty_1 = require("@uxf/core/utils/is-empty");
9
10
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
10
11
  const select_1 = require("@uxf/ui/select");
@@ -14,12 +15,13 @@ const form_context_1 = require("../form-id-context/form-context");
14
15
  function Select(props) {
15
16
  var _a, _b, _c;
16
17
  const formContext = (0, form_context_1.useFormContext)();
18
+ const t = (0, translations_1.useUxfTranslation)();
17
19
  const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
18
20
  const { field, fieldState } = (0, react_hook_form_1.useController)({
19
21
  control: props.control,
20
22
  name: props.name,
21
23
  rules: {
22
- required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
24
+ required: props.isRequired ? props.requiredMessage || t("uxf-form-select:validation.required") : undefined,
23
25
  ...props.rules,
24
26
  },
25
27
  shouldUnregister: props.shouldUnregister,
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ "uxf-form-select": {
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-select": {
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
+ };
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.TextInput = TextInput;
8
+ const translations_1 = require("@uxf/core-react/translations");
8
9
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
9
10
  const text_input_1 = require("@uxf/ui/text-input");
10
11
  const react_1 = __importDefault(require("react"));
@@ -14,31 +15,48 @@ const EMAIL_REGEXP = /^(([^<>()[\]\\.,;:\s@À-ÖÙ-öù-ÿĀ-žḀ-ỿ"]+(\.[^<>
14
15
  const PHONE_REGEXP = /^(\+)?[\d\s]*$/;
15
16
  const URL_REGEXP = /^(https?:\/\/)?(www\.)?([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})(\/.*)?$/;
16
17
  function TextInput(props) {
17
- var _a, _b, _c, _d, _e, _f, _g;
18
+ var _a, _b, _c, _d, _e, _f;
18
19
  const formContext = (0, form_context_1.useFormContext)();
20
+ const t = (0, translations_1.useUxfTranslation)();
19
21
  const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
20
22
  const { field, fieldState } = (0, react_hook_form_1.useController)({
21
23
  control: props.control,
22
24
  name: props.name,
23
25
  rules: {
24
- required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
25
- pattern: props.type === "email"
26
- ? {
27
- value: EMAIL_REGEXP,
28
- message: (_b = props.invalidEmailMessage) !== null && _b !== void 0 ? _b : "E-mail by měl být ve\xa0formátu: info@email.cz",
29
- }
30
- : props.type === "tel"
31
- ? {
32
- value: PHONE_REGEXP,
33
- message: (_c = props.invalidPhoneMessage) !== null && _c !== void 0 ? _c : "Zadaný telefon není ve\xa0správném formátu",
26
+ required: props.isRequired
27
+ ? props.requiredMessage || t("uxf-form-text-input:validation.required")
28
+ : undefined,
29
+ validate: {
30
+ validEmail: (value) => {
31
+ if (!value) {
32
+ return;
34
33
  }
35
- : props.type === "url"
36
- ? {
37
- value: URL_REGEXP,
38
- message: (_d = props.invalidUrlMessage) !== null && _d !== void 0 ? _d : "Zadaný odkaz není ve\xa0správném formátu",
39
- }
40
- : undefined,
41
- ...props.rules,
34
+ if (props.type === "email" && value && !EMAIL_REGEXP.test(value)) {
35
+ return (props.invalidEmailMessage ||
36
+ t("uxf-form-text-input:validation.invalid-email", { value: value }));
37
+ }
38
+ },
39
+ validPhone: (value) => {
40
+ if (!value) {
41
+ return;
42
+ }
43
+ if (props.type === "tel" && value && !PHONE_REGEXP.test(value)) {
44
+ return (props.invalidPhoneMessage ||
45
+ t("uxf-form-text-input:validation.invalid-phone", { value: value }));
46
+ }
47
+ },
48
+ validUrl: (value) => {
49
+ if (!value) {
50
+ return;
51
+ }
52
+ if (props.type === "url" && value && !URL_REGEXP.test(value)) {
53
+ return (props.invalidUrlMessage || t("uxf-form-text-input:validation.invalid-url", { value: value }));
54
+ }
55
+ },
56
+ ...(typeof ((_b = props.rules) === null || _b === void 0 ? void 0 : _b.validate) === "function"
57
+ ? { custom: props.rules.validate }
58
+ : (_c = props.rules) === null || _c === void 0 ? void 0 : _c.validate),
59
+ },
42
60
  },
43
61
  shouldUnregister: props.shouldUnregister,
44
62
  });
@@ -52,6 +70,6 @@ function TextInput(props) {
52
70
  field.onChange(value);
53
71
  (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
54
72
  };
55
- 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: (_f = (_e = fieldState.error) === null || _e === void 0 ? void 0 : _e.message) !== null && _f !== void 0 ? _f : 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, placeholder: props.placeholder, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, style: props.style, type: props.type, value: (_g = field.value) !== null && _g !== void 0 ? _g : "", variant: props.variant }));
73
+ 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, placeholder: props.placeholder, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, style: props.style, type: props.type, value: (_f = field.value) !== null && _f !== void 0 ? _f : "", variant: props.variant }));
56
74
  }
57
75
  TextInput.displayName = "UxfFormTextInput";
@@ -0,0 +1,31 @@
1
+ declare const _default: {
2
+ "uxf-form-text-input": {
3
+ validation: {
4
+ required: {
5
+ cs: string;
6
+ en: string;
7
+ sk: string;
8
+ de: string;
9
+ };
10
+ "invalid-email": {
11
+ cs: string;
12
+ en: string;
13
+ sk: string;
14
+ de: string;
15
+ };
16
+ "invalid-phone": {
17
+ cs: string;
18
+ en: string;
19
+ sk: string;
20
+ de: string;
21
+ };
22
+ "invalid-url": {
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-text-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-email": {
13
+ cs: "E-mail by měl být ve\xa0formátu: info@email.cz",
14
+ en: "Email should be in format: info@email.cz",
15
+ sk: "E-mail by mal byť vo\xa0formáte: info@email.cz",
16
+ de: "E-Mail sollte im\xa0Format info@email.cz sein",
17
+ },
18
+ "invalid-phone": {
19
+ cs: "Zadaný telefon není ve\xa0správném formátu",
20
+ en: "The entered phone number is not in the correct format",
21
+ sk: "Zadaný telefón nie je v\xa0správnom formáte",
22
+ de: "Die eingegebene Telefonnummer ist nicht im\xa0richtigen Format",
23
+ },
24
+ "invalid-url": {
25
+ cs: "Zadaný odkaz není ve\xa0správném formátu",
26
+ en: "The entered URL is not in the correct format",
27
+ sk: "Zadaný odkaz nie je v\xa0správnom formáte",
28
+ de: "Die eingegebene URL ist nicht im\xa0richtigen Format",
29
+ },
30
+ },
31
+ },
32
+ };
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.Textarea = Textarea;
28
+ const translations_1 = require("@uxf/core-react/translations");
28
29
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
29
30
  const textarea_1 = require("@uxf/ui/textarea");
30
31
  const react_1 = __importStar(require("react"));
@@ -33,12 +34,15 @@ const form_context_1 = require("../form-id-context/form-context");
33
34
  function Textarea(props) {
34
35
  var _a, _b, _c;
35
36
  const formContext = (0, form_context_1.useFormContext)();
37
+ const t = (0, translations_1.useUxfTranslation)();
36
38
  const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
37
39
  const { field, fieldState } = (0, react_hook_form_1.useController)({
38
40
  control: props.control,
39
41
  name: props.name,
40
42
  rules: {
41
- required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
43
+ required: props.isRequired
44
+ ? props.requiredMessage || t("uxf-form-textarea:validation.required")
45
+ : undefined,
42
46
  ...props.rules,
43
47
  },
44
48
  shouldUnregister: props.shouldUnregister,
@@ -0,0 +1,13 @@
1
+ declare const _default: {
2
+ "uxf-form-textarea": {
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-textarea": {
5
+ validation: {
6
+ required: {
7
+ cs: "Toto pole je povinné",
8
+ en: "This field is required",
9
+ sk: "Toto pole je povinné",
10
+ de: "Dieses Feld ist erforderlich",
11
+ },
12
+ },
13
+ },
14
+ };
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.TimePickerInput = TimePickerInput;
31
+ const translations_1 = require("@uxf/core-react/translations");
31
32
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
32
33
  const time_picker_input_1 = require("@uxf/ui/time-picker-input");
33
34
  const dayjs_1 = __importStar(require("dayjs"));
@@ -39,12 +40,15 @@ const form_context_1 = require("../form-id-context/form-context");
39
40
  function TimePickerInput(props) {
40
41
  var _a, _b, _c, _d, _e;
41
42
  const formContext = (0, form_context_1.useFormContext)();
43
+ const t = (0, translations_1.useUxfTranslation)();
42
44
  const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${formContext.formId}__${props.name}`;
43
45
  const { field, fieldState } = (0, react_hook_form_1.useController)({
44
46
  control: props.control,
45
47
  name: props.name,
46
48
  rules: {
47
- required: props.isRequired ? props.requiredMessage || "Toto pole je povinné" : undefined,
49
+ required: props.isRequired
50
+ ? props.requiredMessage || t("uxf-form-time-picker-input:validation.required")
51
+ : undefined,
48
52
  ...props.rules,
49
53
  validate: {
50
54
  validTime: (value) => {
@@ -52,7 +56,10 @@ function TimePickerInput(props) {
52
56
  return;
53
57
  }
54
58
  if (!(0, dayjs_1.default)(value, time_picker_input_1.OUTPUT_TIME_FORMAT, true).isValid()) {
55
- return `Čas musí být ve formátu ${time_picker_input_1.DISPLAY_TIME_FORMAT}.`;
59
+ return t("uxf-form-time-picker-input:validation.invalid-time-format", {
60
+ format: time_picker_input_1.DISPLAY_TIME_FORMAT,
61
+ value: value,
62
+ });
56
63
  }
57
64
  },
58
65
  ...(typeof ((_b = props.rules) === null || _b === void 0 ? void 0 : _b.validate) === "function"
@@ -0,0 +1,19 @@
1
+ declare const _default: {
2
+ "uxf-form-time-picker-input": {
3
+ validation: {
4
+ required: {
5
+ cs: string;
6
+ en: string;
7
+ sk: string;
8
+ de: string;
9
+ };
10
+ "invalid-time-format": {
11
+ cs: string;
12
+ en: string;
13
+ sk: string;
14
+ de: string;
15
+ };
16
+ };
17
+ };
18
+ };
19
+ export default _default;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ "uxf-form-time-picker-input": {
5
+ validation: {
6
+ required: {
7
+ cs: "Toto pole je povinné",
8
+ en: "This field is required",
9
+ sk: "Toto pole je povinné",
10
+ de: "Dieses Feld ist erforderlich",
11
+ },
12
+ "invalid-time-format": {
13
+ cs: "Čas musí být ve formátu {{format}}.",
14
+ en: "Time must be in format {{format}}.",
15
+ sk: "Čas musí byť vo formáte {{format}}.",
16
+ de: "Uhrzeit muss im Format {{format}} sein.",
17
+ },
18
+ },
19
+ },
20
+ };