@uxf/form 1.0.0-beta.84 → 1.0.0-beta.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/form",
3
- "version": "1.0.0-beta.84",
3
+ "version": "1.0.0-beta.86",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,7 +13,7 @@
13
13
  "author": "UX Fans s.r.o",
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@uxf/ui": "^1.0.0-beta.84",
16
+ "@uxf/ui": "^1.0.0-beta.86",
17
17
  "react-hook-form": "latest"
18
18
  }
19
19
  }
@@ -2,6 +2,7 @@
2
2
  import { TextInputProps as UITextInputProps } from "@uxf/ui/text-input";
3
3
  import { FieldValues, UseControllerProps } from "react-hook-form";
4
4
  export declare type TextInputProps<FormData extends FieldValues> = UseControllerProps<FormData> & Omit<UITextInputProps, "isInvalid" | "max" | "min" | "pattern" | "step" | "name" | "onChange" | "value" | "type"> & {
5
+ patternErrorMessage?: string;
5
6
  requiredMessage?: string;
6
7
  type?: "email" | "password" | "search" | "tel" | "text" | "url";
7
8
  };
@@ -10,7 +10,7 @@ const react_1 = __importDefault(require("react"));
10
10
  const EMAIL_REGEXP = /^(([^<>()[\]\\.,;:\s@À-ÖÙ-öù-ÿĀ-žḀ-ỿ"]+(\.[^<>()[\]\\.,;:\s@À-ÖÙ-öù-ÿĀ-žḀ-ỿ"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
11
11
  const PHONE_REGEXP = /^(\+)?[\d\s]*$/;
12
12
  function TextInput(props) {
13
- var _a, _b, _c, _d;
13
+ var _a, _b, _c, _d, _e, _f;
14
14
  const { field, fieldState } = (0, react_hook_form_1.useController)({
15
15
  control: props.control,
16
16
  defaultValue: props.defaultValue,
@@ -20,15 +20,15 @@ function TextInput(props) {
20
20
  pattern: props.type === "email"
21
21
  ? {
22
22
  value: EMAIL_REGEXP,
23
- message: "E-mail by měl být ve\xa0formátu: info@email.cz",
23
+ message: (_a = props.patternErrorMessage) !== null && _a !== void 0 ? _a : "E-mail by měl být ve\xa0formátu: info@email.cz",
24
24
  }
25
25
  : props.type === "tel"
26
26
  ? {
27
27
  value: PHONE_REGEXP,
28
- message: "Zadaný telefon není ve správném formátu",
28
+ message: (_b = props.patternErrorMessage) !== null && _b !== void 0 ? _b : "Zadaný telefon není ve správném formátu",
29
29
  }
30
30
  : undefined,
31
- ...((_a = props.rules) !== null && _a !== void 0 ? _a : {}),
31
+ ...((_c = props.rules) !== null && _c !== void 0 ? _c : {}),
32
32
  },
33
33
  shouldUnregister: props.shouldUnregister,
34
34
  });
@@ -37,6 +37,6 @@ function TextInput(props) {
37
37
  field.onBlur();
38
38
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
39
39
  };
40
- return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, 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: props.id, inputMode: props.inputMode, isDisabled: props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: 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: field.onChange, onFocus: props.onFocus, onKeyDown: props.onKeyDown, placeholder: props.placeholder, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, type: props.type, value: (_d = field.value) !== null && _d !== void 0 ? _d : "", variant: props.variant }));
40
+ return (react_1.default.createElement(text_input_1.TextInput, { autoComplete: props.autoComplete, 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: props.id, inputMode: props.inputMode, isDisabled: props.isDisabled, isInvalid: !!fieldState.error, isReadOnly: 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: field.onChange, onFocus: props.onFocus, onKeyDown: props.onKeyDown, placeholder: props.placeholder, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, type: props.type, value: (_f = field.value) !== null && _f !== void 0 ? _f : "", variant: props.variant }));
41
41
  }
42
42
  exports.TextInput = TextInput;