@egose/shadcn-theme 0.1.11 → 0.1.12

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 (52) hide show
  1. package/{chunk-OURAYOOM.mjs → chunk-3NMW42UR.mjs} +2 -2
  2. package/{chunk-AQWVA6TL.js → chunk-BIO4TVNT.js} +3 -3
  3. package/{chunk-XF75HZNV.js → chunk-NDH24NNQ.js} +2 -2
  4. package/{chunk-DL6HJ3OB.mjs → chunk-OZF3JOG4.mjs} +2 -2
  5. package/chunk-VYBFV2QD.js +31 -0
  6. package/chunk-WJKG5MUH.mjs +30 -0
  7. package/components/form/date-picker.js +3 -3
  8. package/components/form/date-picker.mjs +2 -2
  9. package/components/form/date-range-picker.js +2 -2
  10. package/components/form/date-range-picker.mjs +1 -1
  11. package/components/form/hook-checkbox.d.mts +7 -5
  12. package/components/form/hook-checkbox.d.ts +7 -5
  13. package/components/form/hook-checkbox.js +11 -3
  14. package/components/form/hook-checkbox.js.map +1 -1
  15. package/components/form/hook-checkbox.mjs +11 -3
  16. package/components/form/hook-checkbox.mjs.map +1 -1
  17. package/components/form/hook-date-picker.js +3 -3
  18. package/components/form/hook-date-picker.mjs +2 -2
  19. package/components/form/hook-native-select.d.mts +7 -4
  20. package/components/form/hook-native-select.d.ts +7 -4
  21. package/components/form/hook-native-select.js +13 -6
  22. package/components/form/hook-native-select.js.map +1 -1
  23. package/components/form/hook-native-select.mjs +13 -6
  24. package/components/form/hook-native-select.mjs.map +1 -1
  25. package/components/form/hook-text-input.d.mts +7 -4
  26. package/components/form/hook-text-input.d.ts +7 -4
  27. package/components/form/hook-text-input.js +26 -6
  28. package/components/form/hook-text-input.js.map +1 -1
  29. package/components/form/hook-text-input.mjs +26 -6
  30. package/components/form/hook-text-input.mjs.map +1 -1
  31. package/components/form/hook-textarea.d.mts +7 -4
  32. package/components/form/hook-textarea.d.ts +7 -4
  33. package/components/form/hook-textarea.js +20 -6
  34. package/components/form/hook-textarea.js.map +1 -1
  35. package/components/form/hook-textarea.mjs +20 -6
  36. package/components/form/hook-textarea.mjs.map +1 -1
  37. package/components/form/hook-time-input.d.mts +7 -5
  38. package/components/form/hook-time-input.d.ts +7 -5
  39. package/components/form/hook-time-input.js +24 -3
  40. package/components/form/hook-time-input.js.map +1 -1
  41. package/components/form/hook-time-input.mjs +24 -3
  42. package/components/form/hook-time-input.mjs.map +1 -1
  43. package/components/form/types.d.mts +12 -2
  44. package/components/form/types.d.ts +12 -2
  45. package/components/form/types.js +12 -1
  46. package/components/form/types.js.map +1 -1
  47. package/components/form/types.mjs +11 -0
  48. package/components/ui/calendar.js +2 -2
  49. package/components/ui/calendar.mjs +1 -1
  50. package/components/ui/multi-select.d.mts +1 -1
  51. package/components/ui/multi-select.d.ts +1 -1
  52. package/package.json +13 -13
@@ -1,11 +1,14 @@
1
1
  import React__default from 'react';
2
- import { FieldValues, Path, RegisterOptions } from 'react-hook-form';
2
+ import { FieldValues, Path } from 'react-hook-form';
3
3
  import { FormTextInputProps } from './text-input.mjs';
4
+ import { HookFormValidationAttributes, HookFormRules } from './types.mjs';
4
5
 
5
- declare function HookFormTextInput<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, ...rest }: Omit<FormTextInputProps, 'name' | 'inputProps'> & {
6
+ type HookFormTextInputValidationAttributes = Pick<HookFormValidationAttributes, 'required' | 'min' | 'max' | 'maxLength' | 'minLength'>;
7
+ type HookFormTextInputProps<T extends FieldValues> = Omit<FormTextInputProps, 'name' | 'inputProps' | keyof HookFormTextInputValidationAttributes> & {
6
8
  name: Path<T>;
7
- rules?: RegisterOptions<T, Path<T>> | undefined;
9
+ rules?: HookFormRules<T>;
8
10
  error?: string;
9
- }): React__default.JSX.Element | null;
11
+ } & HookFormTextInputValidationAttributes;
12
+ declare function HookFormTextInput<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, required, min, max, maxLength, minLength, ...rest }: HookFormTextInputProps<T>): React__default.JSX.Element | null;
10
13
 
11
14
  export { HookFormTextInput };
@@ -1,11 +1,14 @@
1
1
  import React__default from 'react';
2
- import { FieldValues, Path, RegisterOptions } from 'react-hook-form';
2
+ import { FieldValues, Path } from 'react-hook-form';
3
3
  import { FormTextInputProps } from './text-input.js';
4
+ import { HookFormValidationAttributes, HookFormRules } from './types.js';
4
5
 
5
- declare function HookFormTextInput<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, ...rest }: Omit<FormTextInputProps, 'name' | 'inputProps'> & {
6
+ type HookFormTextInputValidationAttributes = Pick<HookFormValidationAttributes, 'required' | 'min' | 'max' | 'maxLength' | 'minLength'>;
7
+ type HookFormTextInputProps<T extends FieldValues> = Omit<FormTextInputProps, 'name' | 'inputProps' | keyof HookFormTextInputValidationAttributes> & {
6
8
  name: Path<T>;
7
- rules?: RegisterOptions<T, Path<T>> | undefined;
9
+ rules?: HookFormRules<T>;
8
10
  error?: string;
9
- }): React__default.JSX.Element | null;
11
+ } & HookFormTextInputValidationAttributes;
12
+ declare function HookFormTextInput<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, required, min, max, maxLength, minLength, ...rest }: HookFormTextInputProps<T>): React__default.JSX.Element | null;
10
13
 
11
14
  export { HookFormTextInput };
@@ -3,6 +3,11 @@
3
3
 
4
4
 
5
5
  var _chunkWEZTFUORjs = require('../../chunk-WEZTFUOR.js');
6
+
7
+
8
+
9
+
10
+ var _chunkVYBFV2QDjs = require('../../chunk-VYBFV2QD.js');
6
11
  require('../../chunk-CRBQL2FG.js');
7
12
 
8
13
 
@@ -29,7 +34,12 @@ function HookFormTextInput(_a) {
29
34
  label,
30
35
  error,
31
36
  classNames,
32
- disabled
37
+ disabled,
38
+ required,
39
+ min,
40
+ max,
41
+ maxLength,
42
+ minLength
33
43
  } = _b, rest = _chunk2NMEKWO5js.__objRest.call(void 0, _b, [
34
44
  "id",
35
45
  "name",
@@ -37,7 +47,12 @@ function HookFormTextInput(_a) {
37
47
  "label",
38
48
  "error",
39
49
  "classNames",
40
- "disabled"
50
+ "disabled",
51
+ "required",
52
+ "min",
53
+ "max",
54
+ "maxLength",
55
+ "minLength"
41
56
  ]);
42
57
  const methods = _reacthookform.useFormContext.call(void 0, );
43
58
  if (!methods) return null;
@@ -48,14 +63,19 @@ function HookFormTextInput(_a) {
48
63
  const fieldError = _get3.default.call(void 0, errors, name);
49
64
  const errorMessage = error != null ? error : fieldError && String(fieldError == null ? void 0 : fieldError.message);
50
65
  const showError = !!fieldError && !disabled;
66
+ const mergedRules = _chunkVYBFV2QDjs.mergeHookFormRules.call(void 0, rules, { required, min, max, maxLength, minLength });
51
67
  return /* @__PURE__ */ _react2.default.createElement("div", { className: _chunkNBQEF4JDjs.cn.call(void 0, "$hook-form-text-input", classNames == null ? void 0 : classNames.wrapper) }, /* @__PURE__ */ _react2.default.createElement(
52
68
  _chunkWEZTFUORjs.FormTextInput,
53
- _chunk2NMEKWO5js.__spreadProps.call(void 0, _chunk2NMEKWO5js.__spreadValues.call(void 0, {
69
+ _chunk2NMEKWO5js.__spreadProps.call(void 0, _chunk2NMEKWO5js.__spreadValues.call(void 0, {}, rest), {
54
70
  id,
55
71
  name,
56
72
  label,
57
- disabled
58
- }, rest), {
73
+ disabled,
74
+ required: _chunkVYBFV2QDjs.isValidationRuleEnabled.call(void 0, mergedRules == null ? void 0 : mergedRules.required),
75
+ min: _chunkVYBFV2QDjs.getValidationRuleValue.call(void 0, mergedRules == null ? void 0 : mergedRules.min),
76
+ max: _chunkVYBFV2QDjs.getValidationRuleValue.call(void 0, mergedRules == null ? void 0 : mergedRules.max),
77
+ maxLength: _chunkVYBFV2QDjs.getValidationRuleValue.call(void 0, mergedRules == null ? void 0 : mergedRules.maxLength),
78
+ minLength: _chunkVYBFV2QDjs.getValidationRuleValue.call(void 0, mergedRules == null ? void 0 : mergedRules.minLength),
59
79
  classNames: {
60
80
  label: _chunkNBQEF4JDjs.cn.call(void 0, classNames == null ? void 0 : classNames.label, {
61
81
  "text-danger": showError
@@ -64,7 +84,7 @@ function HookFormTextInput(_a) {
64
84
  "ring-danger text-danger": showError
65
85
  })
66
86
  },
67
- inputProps: register(name, rules)
87
+ inputProps: register(name, mergedRules)
68
88
  })
69
89
  ), showError && /* @__PURE__ */ _react2.default.createElement(_chunkHDO7OG7Ijs.FormError, { field: name, className: "mt-1", message: errorMessage }));
70
90
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-text-input.js","../../../components/form/hook-text-input.tsx"],"names":[],"mappings":"AAAA,qLAAY;AACZ;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACA;ACjBA,4EAAkB;AAClB,gFAAiB;AACjB,gDAAmE;AAM5D,SAAS,iBAAA,CAAyC,EAAA,EAatD;AAbsD,EAAA,IAAA,GAAA,EAAA,EAAA,EACvD;AAAA,IAAA,EAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EAhBF,EAAA,EASyD,EAAA,EAQpD,KAAA,EAAA,wCAAA,EARoD,EAQpD;AAAA,IAPH,IAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,EAAA,CAAA,CAAA;AAOA,EAAA,MAAM,QAAA,EAAU,2CAAA,CAAkB;AAClC,EAAA,GAAA,CAAI,CAAC,OAAA,EAAS,OAAO,IAAA;AAErB,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA,EAAW,EAAE,OAAO;AAAA,EACtB,EAAA,EAAI,OAAA;AAEJ,EAAA,MAAM,WAAA,EAAa,2BAAA,MAAK,EAAQ,IAAI,CAAA;AACpC,EAAA,MAAM,aAAA,EAAe,MAAA,GAAA,KAAA,EAAA,MAAA,EAAU,WAAA,GAAc,MAAA,CAAO,WAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,OAAO,CAAA;AACvE,EAAA,MAAM,UAAA,EAAY,CAAC,CAAC,WAAA,GAAc,CAAC,QAAA;AAEnC,EAAA,uBACE,eAAA,CAAA,aAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAW,iCAAA,uBAAG,EAAyB,WAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,OAAO,EAAA,CAAA,kBAC7D,eAAA,CAAA,aAAA;AAAA,IAAC,8BAAA;AAAA,IAAA,4CAAA,6CAAA;AAAA,MACC,EAAA;AAAA,MACA,IAAA;AAAA,MACA,KAAA;AAAA,MACA;AAAA,IAAA,CAAA,EACI,IAAA,CAAA,EALL;AAAA,MAMC,UAAA,EAAY;AAAA,QACV,KAAA,EAAO,iCAAA,WAAG,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,KAAA,EAAO;AAAA,UAC3B,aAAA,EAAe;AAAA,QACjB,CAAC,CAAA;AAAA,QACD,KAAA,EAAO,iCAAA,WAAG,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,KAAA,EAAO;AAAA,UAC3B,yBAAA,EAA2B;AAAA,QAC7B,CAAC;AAAA,MACH,CAAA;AAAA,MACA,UAAA,EAAY,QAAA,CAAS,IAAA,EAAM,KAAK;AAAA,IAAA,CAAA;AAAA,EAClC,CAAA,EACC,UAAA,mBAAa,eAAA,CAAA,aAAA,CAAC,0BAAA,EAAA,EAAU,KAAA,EAAO,IAAA,EAAM,SAAA,EAAU,MAAA,EAAO,OAAA,EAAS,aAAA,CAAc,CAChF,CAAA;AAEJ;ADaA;AACE;AACF,8CAAC","file":"/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-text-input.js","sourcesContent":[null,"\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues, RegisterOptions, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTextInput } from './text-input';\nimport type { FormTextInputProps } from './text-input';\n\nexport function HookFormTextInput<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n ...rest\n}: Omit<FormTextInputProps, 'name' | 'inputProps'> & {\n name: Path<T>;\n rules?: RegisterOptions<T, Path<T>> | undefined;\n error?: string;\n}) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n register,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError && String(fieldError?.message));\n const showError = !!fieldError && !disabled;\n\n return (\n <div className={cn('$hook-form-text-input', classNames?.wrapper)}>\n <FormTextInput\n id={id}\n name={name}\n label={label}\n disabled={disabled}\n {...rest}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n inputProps={register(name, rules)}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-text-input.js","../../../components/form/hook-text-input.tsx"],"names":[],"mappings":"AAAA,qLAAY;AACZ;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACA;ACtBA,4EAAkB;AAClB,gFAAiB;AACjB,gDAAkD;AAsB3C,SAAS,iBAAA,CAAyC,EAAA,EAc3B;AAd2B,EAAA,IAAA,GAAA,EAAA,EAAA,EACvD;AAAA,IAAA,EAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AA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ook-text-input.js","sourcesContent":[null,"\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTextInput } from './text-input';\nimport type { FormTextInputProps } from './text-input';\nimport { getValidationRuleValue, isValidationRuleEnabled, mergeHookFormRules } from './types';\nimport type { HookFormRules, HookFormValidationAttributes } from './types';\n\ntype HookFormTextInputValidationAttributes = Pick<\n HookFormValidationAttributes,\n 'required' | 'min' | 'max' | 'maxLength' | 'minLength'\n>;\n\ntype HookFormTextInputProps<T extends FieldValues> = Omit<\n FormTextInputProps,\n 'name' | 'inputProps' | keyof HookFormTextInputValidationAttributes\n> & {\n name: Path<T>;\n rules?: HookFormRules<T>;\n error?: string;\n} & HookFormTextInputValidationAttributes;\n\nexport function HookFormTextInput<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n required,\n min,\n max,\n maxLength,\n minLength,\n ...rest\n}: HookFormTextInputProps<T>) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n register,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError && String(fieldError?.message));\n const showError = !!fieldError && !disabled;\n const mergedRules = mergeHookFormRules(rules, { required, min, max, maxLength, minLength });\n\n return (\n <div className={cn('$hook-form-text-input', classNames?.wrapper)}>\n <FormTextInput\n {...rest}\n id={id}\n name={name}\n label={label}\n disabled={disabled}\n required={isValidationRuleEnabled(mergedRules?.required)}\n min={getValidationRuleValue(mergedRules?.min)}\n max={getValidationRuleValue(mergedRules?.max)}\n maxLength={getValidationRuleValue(mergedRules?.maxLength)}\n minLength={getValidationRuleValue(mergedRules?.minLength)}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n inputProps={register(name, mergedRules)}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"]}
@@ -2,6 +2,11 @@
2
2
  import {
3
3
  FormTextInput
4
4
  } from "../../chunk-S7HB64F7.mjs";
5
+ import {
6
+ getValidationRuleValue,
7
+ isValidationRuleEnabled,
8
+ mergeHookFormRules
9
+ } from "../../chunk-WJKG5MUH.mjs";
5
10
  import "../../chunk-OXUVPYJE.mjs";
6
11
  import {
7
12
  FormError
@@ -28,7 +33,12 @@ function HookFormTextInput(_a) {
28
33
  label,
29
34
  error,
30
35
  classNames,
31
- disabled
36
+ disabled,
37
+ required,
38
+ min,
39
+ max,
40
+ maxLength,
41
+ minLength
32
42
  } = _b, rest = __objRest(_b, [
33
43
  "id",
34
44
  "name",
@@ -36,7 +46,12 @@ function HookFormTextInput(_a) {
36
46
  "label",
37
47
  "error",
38
48
  "classNames",
39
- "disabled"
49
+ "disabled",
50
+ "required",
51
+ "min",
52
+ "max",
53
+ "maxLength",
54
+ "minLength"
40
55
  ]);
41
56
  const methods = useFormContext();
42
57
  if (!methods) return null;
@@ -47,14 +62,19 @@ function HookFormTextInput(_a) {
47
62
  const fieldError = _get(errors, name);
48
63
  const errorMessage = error != null ? error : fieldError && String(fieldError == null ? void 0 : fieldError.message);
49
64
  const showError = !!fieldError && !disabled;
65
+ const mergedRules = mergeHookFormRules(rules, { required, min, max, maxLength, minLength });
50
66
  return /* @__PURE__ */ React.createElement("div", { className: cn("$hook-form-text-input", classNames == null ? void 0 : classNames.wrapper) }, /* @__PURE__ */ React.createElement(
51
67
  FormTextInput,
52
- __spreadProps(__spreadValues({
68
+ __spreadProps(__spreadValues({}, rest), {
53
69
  id,
54
70
  name,
55
71
  label,
56
- disabled
57
- }, rest), {
72
+ disabled,
73
+ required: isValidationRuleEnabled(mergedRules == null ? void 0 : mergedRules.required),
74
+ min: getValidationRuleValue(mergedRules == null ? void 0 : mergedRules.min),
75
+ max: getValidationRuleValue(mergedRules == null ? void 0 : mergedRules.max),
76
+ maxLength: getValidationRuleValue(mergedRules == null ? void 0 : mergedRules.maxLength),
77
+ minLength: getValidationRuleValue(mergedRules == null ? void 0 : mergedRules.minLength),
58
78
  classNames: {
59
79
  label: cn(classNames == null ? void 0 : classNames.label, {
60
80
  "text-danger": showError
@@ -63,7 +83,7 @@ function HookFormTextInput(_a) {
63
83
  "ring-danger text-danger": showError
64
84
  })
65
85
  },
66
- inputProps: register(name, rules)
86
+ inputProps: register(name, mergedRules)
67
87
  })
68
88
  ), showError && /* @__PURE__ */ React.createElement(FormError, { field: name, className: "mt-1", message: errorMessage }));
69
89
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../components/form/hook-text-input.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues, RegisterOptions, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTextInput } from './text-input';\nimport type { FormTextInputProps } from './text-input';\n\nexport function HookFormTextInput<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n ...rest\n}: Omit<FormTextInputProps, 'name' | 'inputProps'> & {\n name: Path<T>;\n rules?: RegisterOptions<T, Path<T>> | undefined;\n error?: string;\n}) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n register,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError && String(fieldError?.message));\n const showError = !!fieldError && !disabled;\n\n return (\n <div className={cn('$hook-form-text-input', classNames?.wrapper)}>\n <FormTextInput\n id={id}\n name={name}\n label={label}\n disabled={disabled}\n {...rest}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n inputProps={register(name, rules)}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAA6C,sBAAsB;AAM5D,SAAS,kBAAyC,IAatD;AAbsD,eACvD;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAhBF,IASyD,IAQpD,iBARoD,IAQpD;AAAA,IAPH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAOA,QAAM,UAAU,eAAkB;AAClC,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM;AAAA,IACJ;AAAA,IACA,WAAW,EAAE,OAAO;AAAA,EACtB,IAAI;AAEJ,QAAM,aAAa,KAAK,QAAQ,IAAI;AACpC,QAAM,eAAe,wBAAU,cAAc,OAAO,yCAAY,OAAO;AACvE,QAAM,YAAY,CAAC,CAAC,cAAc,CAAC;AAEnC,SACE,oCAAC,SAAI,WAAW,GAAG,yBAAyB,yCAAY,OAAO,KAC7D;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,OACI,OALL;AAAA,MAMC,YAAY;AAAA,QACV,OAAO,GAAG,yCAAY,OAAO;AAAA,UAC3B,eAAe;AAAA,QACjB,CAAC;AAAA,QACD,OAAO,GAAG,yCAAY,OAAO;AAAA,UAC3B,2BAA2B;AAAA,QAC7B,CAAC;AAAA,MACH;AAAA,MACA,YAAY,SAAS,MAAM,KAAK;AAAA;AAAA,EAClC,GACC,aAAa,oCAAC,aAAU,OAAO,MAAM,WAAU,QAAO,SAAS,cAAc,CAChF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../components/form/hook-text-input.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTextInput } from './text-input';\nimport type { FormTextInputProps } from './text-input';\nimport { getValidationRuleValue, isValidationRuleEnabled, mergeHookFormRules } from './types';\nimport type { HookFormRules, HookFormValidationAttributes } from './types';\n\ntype HookFormTextInputValidationAttributes = Pick<\n HookFormValidationAttributes,\n 'required' | 'min' | 'max' | 'maxLength' | 'minLength'\n>;\n\ntype HookFormTextInputProps<T extends FieldValues> = Omit<\n FormTextInputProps,\n 'name' | 'inputProps' | keyof HookFormTextInputValidationAttributes\n> & {\n name: Path<T>;\n rules?: HookFormRules<T>;\n error?: string;\n} & HookFormTextInputValidationAttributes;\n\nexport function HookFormTextInput<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n required,\n min,\n max,\n maxLength,\n minLength,\n ...rest\n}: HookFormTextInputProps<T>) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n register,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError && String(fieldError?.message));\n const showError = !!fieldError && !disabled;\n const mergedRules = mergeHookFormRules(rules, { required, min, max, maxLength, minLength });\n\n return (\n <div className={cn('$hook-form-text-input', classNames?.wrapper)}>\n <FormTextInput\n {...rest}\n id={id}\n name={name}\n label={label}\n disabled={disabled}\n required={isValidationRuleEnabled(mergedRules?.required)}\n min={getValidationRuleValue(mergedRules?.min)}\n max={getValidationRuleValue(mergedRules?.max)}\n maxLength={getValidationRuleValue(mergedRules?.maxLength)}\n minLength={getValidationRuleValue(mergedRules?.minLength)}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n inputProps={register(name, mergedRules)}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAA4B,sBAAsB;AAsB3C,SAAS,kBAAyC,IAc3B;AAd2B,eACvD;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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}
@@ -1,11 +1,14 @@
1
1
  import React__default from 'react';
2
- import { FieldValues, Path, RegisterOptions } from 'react-hook-form';
2
+ import { FieldValues, Path } from 'react-hook-form';
3
3
  import { FormTextareaProps } from './textarea.mjs';
4
+ import { HookFormValidationAttributes, HookFormRules } from './types.mjs';
4
5
 
5
- declare function HookFormTextarea<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, ...rest }: Omit<FormTextareaProps, 'name' | 'inputProps'> & {
6
+ type HookFormTextareaValidationAttributes = Pick<HookFormValidationAttributes, 'required' | 'maxLength' | 'minLength'>;
7
+ type HookFormTextareaProps<T extends FieldValues> = Omit<FormTextareaProps, 'name' | 'inputProps' | keyof HookFormTextareaValidationAttributes> & {
6
8
  name: Path<T>;
7
- rules?: RegisterOptions<T, Path<T>> | undefined;
9
+ rules?: HookFormRules<T>;
8
10
  error?: string;
9
- }): React__default.JSX.Element | null;
11
+ } & HookFormTextareaValidationAttributes;
12
+ declare function HookFormTextarea<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, required, maxLength, minLength, ...rest }: HookFormTextareaProps<T>): React__default.JSX.Element | null;
10
13
 
11
14
  export { HookFormTextarea };
@@ -1,11 +1,14 @@
1
1
  import React__default from 'react';
2
- import { FieldValues, Path, RegisterOptions } from 'react-hook-form';
2
+ import { FieldValues, Path } from 'react-hook-form';
3
3
  import { FormTextareaProps } from './textarea.js';
4
+ import { HookFormValidationAttributes, HookFormRules } from './types.js';
4
5
 
5
- declare function HookFormTextarea<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, ...rest }: Omit<FormTextareaProps, 'name' | 'inputProps'> & {
6
+ type HookFormTextareaValidationAttributes = Pick<HookFormValidationAttributes, 'required' | 'maxLength' | 'minLength'>;
7
+ type HookFormTextareaProps<T extends FieldValues> = Omit<FormTextareaProps, 'name' | 'inputProps' | keyof HookFormTextareaValidationAttributes> & {
6
8
  name: Path<T>;
7
- rules?: RegisterOptions<T, Path<T>> | undefined;
9
+ rules?: HookFormRules<T>;
8
10
  error?: string;
9
- }): React__default.JSX.Element | null;
11
+ } & HookFormTextareaValidationAttributes;
12
+ declare function HookFormTextarea<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, required, maxLength, minLength, ...rest }: HookFormTextareaProps<T>): React__default.JSX.Element | null;
10
13
 
11
14
  export { HookFormTextarea };
@@ -3,6 +3,11 @@
3
3
 
4
4
 
5
5
  var _chunkDYYTK4BPjs = require('../../chunk-DYYTK4BP.js');
6
+
7
+
8
+
9
+
10
+ var _chunkVYBFV2QDjs = require('../../chunk-VYBFV2QD.js');
6
11
  require('../../chunk-YMBEAV7N.js');
7
12
 
8
13
 
@@ -29,7 +34,10 @@ function HookFormTextarea(_a) {
29
34
  label,
30
35
  error,
31
36
  classNames,
32
- disabled
37
+ disabled,
38
+ required,
39
+ maxLength,
40
+ minLength
33
41
  } = _b, rest = _chunk2NMEKWO5js.__objRest.call(void 0, _b, [
34
42
  "id",
35
43
  "name",
@@ -37,7 +45,10 @@ function HookFormTextarea(_a) {
37
45
  "label",
38
46
  "error",
39
47
  "classNames",
40
- "disabled"
48
+ "disabled",
49
+ "required",
50
+ "maxLength",
51
+ "minLength"
41
52
  ]);
42
53
  const methods = _reacthookform.useFormContext.call(void 0, );
43
54
  if (!methods) return null;
@@ -48,14 +59,17 @@ function HookFormTextarea(_a) {
48
59
  const fieldError = _get3.default.call(void 0, errors, name);
49
60
  const errorMessage = error != null ? error : fieldError && String(fieldError == null ? void 0 : fieldError.message);
50
61
  const showError = !!fieldError && !disabled;
62
+ const mergedRules = _chunkVYBFV2QDjs.mergeHookFormRules.call(void 0, rules, { required, maxLength, minLength });
51
63
  return /* @__PURE__ */ _react2.default.createElement("div", { className: _chunkNBQEF4JDjs.cn.call(void 0, "$hook-form-textarea", classNames == null ? void 0 : classNames.wrapper) }, /* @__PURE__ */ _react2.default.createElement(
52
64
  _chunkDYYTK4BPjs.FormTextarea,
53
- _chunk2NMEKWO5js.__spreadProps.call(void 0, _chunk2NMEKWO5js.__spreadValues.call(void 0, {
65
+ _chunk2NMEKWO5js.__spreadProps.call(void 0, _chunk2NMEKWO5js.__spreadValues.call(void 0, {}, rest), {
54
66
  id,
55
67
  name,
56
68
  label,
57
- disabled
58
- }, rest), {
69
+ disabled,
70
+ required: _chunkVYBFV2QDjs.isValidationRuleEnabled.call(void 0, mergedRules == null ? void 0 : mergedRules.required),
71
+ maxLength: _chunkVYBFV2QDjs.getValidationRuleValue.call(void 0, mergedRules == null ? void 0 : mergedRules.maxLength),
72
+ minLength: _chunkVYBFV2QDjs.getValidationRuleValue.call(void 0, mergedRules == null ? void 0 : mergedRules.minLength),
59
73
  classNames: {
60
74
  label: _chunkNBQEF4JDjs.cn.call(void 0, classNames == null ? void 0 : classNames.label, {
61
75
  "text-danger": showError
@@ -64,7 +78,7 @@ function HookFormTextarea(_a) {
64
78
  "ring-danger text-danger": showError
65
79
  })
66
80
  },
67
- inputProps: register(name, rules)
81
+ inputProps: register(name, mergedRules)
68
82
  })
69
83
  ), showError && /* @__PURE__ */ _react2.default.createElement(_chunkHDO7OG7Ijs.FormError, { field: name, className: "mt-1", message: errorMessage }));
70
84
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-textarea.js","../../../components/form/hook-textarea.tsx"],"names":[],"mappings":"AAAA,qLAAY;AACZ;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACA;ACjBA,4EAAkB;AAClB,gFAAiB;AACjB,gDAAmE;AAM5D,SAAS,gBAAA,CAAwC,EAAA,EAarD;AAbqD,EAAA,IAAA,GAAA,EAAA,EAAA,EACtD;AAAA,IAAA,EAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EAh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AAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,KAAA,EAAO;AAAA,UAC3B,yBAAA,EAA2B;AAAA,QAC7B,CAAC;AAAA,MACH,CAAA;AAAA,MACA,UAAA,EAAY,QAAA,CAAS,IAAA,EAAM,KAAK;AAAA,IAAA,CAAA;AAAA,EAClC,CAAA,EACC,UAAA,mBAAa,eAAA,CAAA,aAAA,CAAC,0BAAA,EAAA,EAAU,KAAA,EAAO,IAAA,EAAM,SAAA,EAAU,MAAA,EAAO,OAAA,EAAS,aAAA,CAAc,CAChF,CAAA;AAEJ;ADaA;AACE;AACF,4CAAC","file":"/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-textarea.js","sourcesContent":[null,"\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues, RegisterOptions, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTextarea } from './textarea';\nimport type { FormTextareaProps } from './textarea';\n\nexport function HookFormTextarea<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n ...rest\n}: Omit<FormTextareaProps, 'name' | 'inputProps'> & {\n name: Path<T>;\n rules?: RegisterOptions<T, Path<T>> | undefined;\n error?: string;\n}) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n register,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError && String(fieldError?.message));\n const showError = !!fieldError && !disabled;\n\n return (\n <div className={cn('$hook-form-textarea', classNames?.wrapper)}>\n <FormTextarea\n id={id}\n name={name}\n label={label}\n disabled={disabled}\n {...rest}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n inputProps={register(name, rules)}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-textarea.js","../../../components/form/hook-textarea.tsx"],"names":[],"mappings":"AAAA,qLAAY;AACZ;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACA;ACtBA,4EAAkB;AAClB,gFAAiB;AACjB,gDAAkD;AAmB3C,SAAS,gBAAA,CAAwC,EAAA,EAY3B;AAZ2B,EAAA,IAAA,GAAA,EAAA,EAAA,EACtD;AAAA,IAAA,EAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,EAhCF,EAAA,EAsBwD,EAAA,EAWnD,KAAA,EAAA,wCAAA,EAXmD,EAWnD;AAAA,IAVH,IAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,EAAA,CAAA,CAAA;AAGA,EAAA,MAAM,QAAA,EAAU,2CAAA,CAAkB;AAClC,EAAA,GAAA,CAAI,CAAC,OAAA,EAAS,OAAO,IAAA;AAErB,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA,EAAW,EAAE,OAAO;AAAA,EACtB,EAAA,EAAI,OAAA;AAEJ,EAAA,MAAM,WAAA,EAAa,2BAAA,MAAK,EAAQ,IAAI,CAAA;AACpC,EAAA,MAAM,aAAA,EAAe,MAAA,GAAA,KAAA,EAAA,MAAA,EAAU,WAAA,GAAc,MAAA,CAAO,WAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,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,CAAA,EACC,UAAA,mBAAa,eAAA,CAAA,aAAA,CAAC,0BAAA,EAAA,EAAU,KAAA,EAAO,IAAA,EAAM,SAAA,EAAU,MAAA,EAAO,OAAA,EAAS,aAAA,CAAc,CAChF,CAAA;AAEJ;ADWA;AACE;AACF,4CAAC","file":"/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-textarea.js","sourcesContent":[null,"\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTextarea } from './textarea';\nimport type { FormTextareaProps } from './textarea';\nimport { getValidationRuleValue, isValidationRuleEnabled, mergeHookFormRules } from './types';\nimport type { HookFormRules, HookFormValidationAttributes } from './types';\n\ntype HookFormTextareaValidationAttributes = Pick<HookFormValidationAttributes, 'required' | 'maxLength' | 'minLength'>;\n\ntype HookFormTextareaProps<T extends FieldValues> = Omit<\n FormTextareaProps,\n 'name' | 'inputProps' | keyof HookFormTextareaValidationAttributes\n> & {\n name: Path<T>;\n rules?: HookFormRules<T>;\n error?: string;\n} & HookFormTextareaValidationAttributes;\n\nexport function HookFormTextarea<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n required,\n maxLength,\n minLength,\n ...rest\n}: HookFormTextareaProps<T>) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n register,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError && String(fieldError?.message));\n const showError = !!fieldError && !disabled;\n const mergedRules = mergeHookFormRules(rules, { required, maxLength, minLength });\n\n return (\n <div className={cn('$hook-form-textarea', classNames?.wrapper)}>\n <FormTextarea\n {...rest}\n id={id}\n name={name}\n label={label}\n disabled={disabled}\n required={isValidationRuleEnabled(mergedRules?.required)}\n maxLength={getValidationRuleValue(mergedRules?.maxLength)}\n minLength={getValidationRuleValue(mergedRules?.minLength)}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n inputProps={register(name, mergedRules)}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"]}
@@ -2,6 +2,11 @@
2
2
  import {
3
3
  FormTextarea
4
4
  } from "../../chunk-ZSHUAH66.mjs";
5
+ import {
6
+ getValidationRuleValue,
7
+ isValidationRuleEnabled,
8
+ mergeHookFormRules
9
+ } from "../../chunk-WJKG5MUH.mjs";
5
10
  import "../../chunk-CHV7CG5L.mjs";
6
11
  import {
7
12
  FormError
@@ -28,7 +33,10 @@ function HookFormTextarea(_a) {
28
33
  label,
29
34
  error,
30
35
  classNames,
31
- disabled
36
+ disabled,
37
+ required,
38
+ maxLength,
39
+ minLength
32
40
  } = _b, rest = __objRest(_b, [
33
41
  "id",
34
42
  "name",
@@ -36,7 +44,10 @@ function HookFormTextarea(_a) {
36
44
  "label",
37
45
  "error",
38
46
  "classNames",
39
- "disabled"
47
+ "disabled",
48
+ "required",
49
+ "maxLength",
50
+ "minLength"
40
51
  ]);
41
52
  const methods = useFormContext();
42
53
  if (!methods) return null;
@@ -47,14 +58,17 @@ function HookFormTextarea(_a) {
47
58
  const fieldError = _get(errors, name);
48
59
  const errorMessage = error != null ? error : fieldError && String(fieldError == null ? void 0 : fieldError.message);
49
60
  const showError = !!fieldError && !disabled;
61
+ const mergedRules = mergeHookFormRules(rules, { required, maxLength, minLength });
50
62
  return /* @__PURE__ */ React.createElement("div", { className: cn("$hook-form-textarea", classNames == null ? void 0 : classNames.wrapper) }, /* @__PURE__ */ React.createElement(
51
63
  FormTextarea,
52
- __spreadProps(__spreadValues({
64
+ __spreadProps(__spreadValues({}, rest), {
53
65
  id,
54
66
  name,
55
67
  label,
56
- disabled
57
- }, rest), {
68
+ disabled,
69
+ required: isValidationRuleEnabled(mergedRules == null ? void 0 : mergedRules.required),
70
+ maxLength: getValidationRuleValue(mergedRules == null ? void 0 : mergedRules.maxLength),
71
+ minLength: getValidationRuleValue(mergedRules == null ? void 0 : mergedRules.minLength),
58
72
  classNames: {
59
73
  label: cn(classNames == null ? void 0 : classNames.label, {
60
74
  "text-danger": showError
@@ -63,7 +77,7 @@ function HookFormTextarea(_a) {
63
77
  "ring-danger text-danger": showError
64
78
  })
65
79
  },
66
- inputProps: register(name, rules)
80
+ inputProps: register(name, mergedRules)
67
81
  })
68
82
  ), showError && /* @__PURE__ */ React.createElement(FormError, { field: name, className: "mt-1", message: errorMessage }));
69
83
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../components/form/hook-textarea.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues, RegisterOptions, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTextarea } from './textarea';\nimport type { FormTextareaProps } from './textarea';\n\nexport function HookFormTextarea<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n ...rest\n}: Omit<FormTextareaProps, 'name' | 'inputProps'> & {\n name: Path<T>;\n rules?: RegisterOptions<T, Path<T>> | undefined;\n error?: string;\n}) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n register,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError && String(fieldError?.message));\n const showError = !!fieldError && !disabled;\n\n return (\n <div className={cn('$hook-form-textarea', classNames?.wrapper)}>\n <FormTextarea\n id={id}\n name={name}\n label={label}\n disabled={disabled}\n {...rest}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n inputProps={register(name, rules)}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAA6C,sBAAsB;AAM5D,SAAS,iBAAwC,IAarD;AAbqD,eACtD;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAhBF,IASwD,IAQnD,iBARmD,IAQnD;AAAA,IAPH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAOA,QAAM,UAAU,eAAkB;AAClC,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM;AAAA,IACJ;AAAA,IACA,WAAW,EAAE,OAAO;AAAA,EACtB,IAAI;AAEJ,QAAM,aAAa,KAAK,QAAQ,IAAI;AACpC,QAAM,eAAe,wBAAU,cAAc,OAAO,yCAAY,OAAO;AACvE,QAAM,YAAY,CAAC,CAAC,cAAc,CAAC;AAEnC,SACE,oCAAC,SAAI,WAAW,GAAG,uBAAuB,yCAAY,OAAO,KAC3D;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,OACI,OALL;AAAA,MAMC,YAAY;AAAA,QACV,OAAO,GAAG,yCAAY,OAAO;AAAA,UAC3B,eAAe;AAAA,QACjB,CAAC;AAAA,QACD,OAAO,GAAG,yCAAY,OAAO;AAAA,UAC3B,2BAA2B;AAAA,QAC7B,CAAC;AAAA,MACH;AAAA,MACA,YAAY,SAAS,MAAM,KAAK;AAAA;AAAA,EAClC,GACC,aAAa,oCAAC,aAAU,OAAO,MAAM,WAAU,QAAO,SAAS,cAAc,CAChF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../components/form/hook-textarea.tsx"],"sourcesContent":["\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { FieldValues, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTextarea } from './textarea';\nimport type { FormTextareaProps } from './textarea';\nimport { getValidationRuleValue, isValidationRuleEnabled, mergeHookFormRules } from './types';\nimport type { HookFormRules, HookFormValidationAttributes } from './types';\n\ntype HookFormTextareaValidationAttributes = Pick<HookFormValidationAttributes, 'required' | 'maxLength' | 'minLength'>;\n\ntype HookFormTextareaProps<T extends FieldValues> = Omit<\n FormTextareaProps,\n 'name' | 'inputProps' | keyof HookFormTextareaValidationAttributes\n> & {\n name: Path<T>;\n rules?: HookFormRules<T>;\n error?: string;\n} & HookFormTextareaValidationAttributes;\n\nexport function HookFormTextarea<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n required,\n maxLength,\n minLength,\n ...rest\n}: HookFormTextareaProps<T>) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n register,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError && String(fieldError?.message));\n const showError = !!fieldError && !disabled;\n const mergedRules = mergeHookFormRules(rules, { required, maxLength, minLength });\n\n return (\n <div className={cn('$hook-form-textarea', classNames?.wrapper)}>\n <FormTextarea\n {...rest}\n id={id}\n name={name}\n label={label}\n disabled={disabled}\n required={isValidationRuleEnabled(mergedRules?.required)}\n maxLength={getValidationRuleValue(mergedRules?.maxLength)}\n minLength={getValidationRuleValue(mergedRules?.minLength)}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n inputProps={register(name, mergedRules)}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,SAA4B,sBAAsB;AAmB3C,SAAS,iBAAwC,IAY3B;AAZ2B,eACtD;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAhCF,IAsBwD,IAWnD,iBAXmD,IAWnD;AAAA,IAVH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM,UAAU,eAAkB;AAClC,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM;AAAA,IACJ;AAAA,IACA,WAAW,EAAE,OAAO;AAAA,EACtB,IAAI;AAEJ,QAAM,aAAa,KAAK,QAAQ,IAAI;AACpC,QAAM,eAAe,wBAAU,cAAc,OAAO,yCAAY,OAAO;AACvE,QAAM,YAAY,CAAC,CAAC,cAAc,CAAC;AACnC,QAAM,cAAc,mBAAmB,OAAO,EAAE,UAAU,WAAW,UAAU,CAAC;AAEhF,SACE,oCAAC,SAAI,WAAW,GAAG,uBAAuB,yCAAY,OAAO,KAC3D;AAAA,IAAC;AAAA,qCACK,OADL;AAAA,MAEC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,wBAAwB,2CAAa,QAAQ;AAAA,MACvD,WAAW,uBAAuB,2CAAa,SAAS;AAAA,MACxD,WAAW,uBAAuB,2CAAa,SAAS;AAAA,MACxD,YAAY;AAAA,QACV,OAAO,GAAG,yCAAY,OAAO;AAAA,UAC3B,eAAe;AAAA,QACjB,CAAC;AAAA,QACD,OAAO,GAAG,yCAAY,OAAO;AAAA,UAC3B,2BAA2B;AAAA,QAC7B,CAAC;AAAA,MACH;AAAA,MACA,YAAY,SAAS,MAAM,WAAW;AAAA;AAAA,EACxC,GACC,aAAa,oCAAC,aAAU,OAAO,MAAM,WAAU,QAAO,SAAS,cAAc,CAChF;AAEJ;","names":[]}
@@ -1,13 +1,15 @@
1
1
  import React__default from 'react';
2
- import { FieldValues, Path, RegisterOptions } from 'react-hook-form';
2
+ import { FieldValues, Path } from 'react-hook-form';
3
3
  import { FormTimeInputProps } from './time-input.mjs';
4
+ import { HookFormValidationAttributes, HookFormRules } from './types.mjs';
4
5
  import './text-input.mjs';
5
6
 
6
- type HookFormTimeInputProps<T extends FieldValues> = Omit<FormTimeInputProps, 'name' | 'inputProps'> & {
7
+ type HookFormTimeInputValidationAttributes = Pick<HookFormValidationAttributes, 'required' | 'min' | 'max' | 'maxLength' | 'minLength'>;
8
+ type HookFormTimeInputProps<T extends FieldValues> = Omit<FormTimeInputProps, 'name' | 'inputProps' | keyof HookFormTimeInputValidationAttributes> & {
7
9
  name: Path<T>;
8
- rules?: RegisterOptions<T, Path<T>>;
10
+ rules?: HookFormRules<T>;
9
11
  error?: string;
10
- };
11
- declare function HookFormTimeInput<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, ...rest }: HookFormTimeInputProps<T>): React__default.JSX.Element | null;
12
+ } & HookFormTimeInputValidationAttributes;
13
+ declare function HookFormTimeInput<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, required, min, max, maxLength, minLength, ...rest }: HookFormTimeInputProps<T>): React__default.JSX.Element | null;
12
14
 
13
15
  export { HookFormTimeInput };
@@ -1,13 +1,15 @@
1
1
  import React__default from 'react';
2
- import { FieldValues, Path, RegisterOptions } from 'react-hook-form';
2
+ import { FieldValues, Path } from 'react-hook-form';
3
3
  import { FormTimeInputProps } from './time-input.js';
4
+ import { HookFormValidationAttributes, HookFormRules } from './types.js';
4
5
  import './text-input.js';
5
6
 
6
- type HookFormTimeInputProps<T extends FieldValues> = Omit<FormTimeInputProps, 'name' | 'inputProps'> & {
7
+ type HookFormTimeInputValidationAttributes = Pick<HookFormValidationAttributes, 'required' | 'min' | 'max' | 'maxLength' | 'minLength'>;
8
+ type HookFormTimeInputProps<T extends FieldValues> = Omit<FormTimeInputProps, 'name' | 'inputProps' | keyof HookFormTimeInputValidationAttributes> & {
7
9
  name: Path<T>;
8
- rules?: RegisterOptions<T, Path<T>>;
10
+ rules?: HookFormRules<T>;
9
11
  error?: string;
10
- };
11
- declare function HookFormTimeInput<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, ...rest }: HookFormTimeInputProps<T>): React__default.JSX.Element | null;
12
+ } & HookFormTimeInputValidationAttributes;
13
+ declare function HookFormTimeInput<T extends FieldValues>({ id, name, rules, label, error, classNames, disabled, required, min, max, maxLength, minLength, ...rest }: HookFormTimeInputProps<T>): React__default.JSX.Element | null;
12
14
 
13
15
  export { HookFormTimeInput };
@@ -4,6 +4,11 @@
4
4
 
5
5
  var _chunkJYRR3NKHjs = require('../../chunk-JYRR3NKH.js');
6
6
  require('../../chunk-WEZTFUOR.js');
7
+
8
+
9
+
10
+
11
+ var _chunkVYBFV2QDjs = require('../../chunk-VYBFV2QD.js');
7
12
  require('../../chunk-CRBQL2FG.js');
8
13
 
9
14
 
@@ -31,7 +36,12 @@ function HookFormTimeInput(_a) {
31
36
  label,
32
37
  error,
33
38
  classNames,
34
- disabled
39
+ disabled,
40
+ required,
41
+ min,
42
+ max,
43
+ maxLength,
44
+ minLength
35
45
  } = _b, rest = _chunk2NMEKWO5js.__objRest.call(void 0, _b, [
36
46
  "id",
37
47
  "name",
@@ -39,7 +49,12 @@ function HookFormTimeInput(_a) {
39
49
  "label",
40
50
  "error",
41
51
  "classNames",
42
- "disabled"
52
+ "disabled",
53
+ "required",
54
+ "min",
55
+ "max",
56
+ "maxLength",
57
+ "minLength"
43
58
  ]);
44
59
  const methods = _reacthookform.useFormContext.call(void 0, );
45
60
  if (!methods) return null;
@@ -50,12 +65,13 @@ function HookFormTimeInput(_a) {
50
65
  const fieldError = _get3.default.call(void 0, errors, name);
51
66
  const errorMessage = error != null ? error : fieldError == null ? void 0 : fieldError.message;
52
67
  const showError = !!fieldError && !disabled;
68
+ const mergedRules = _chunkVYBFV2QDjs.mergeHookFormRules.call(void 0, rules, { required, min, max, maxLength, minLength });
53
69
  return /* @__PURE__ */ _react2.default.createElement("div", { className: _chunkNBQEF4JDjs.cn.call(void 0, "$hook-form-time-input", classNames == null ? void 0 : classNames.wrapper) }, /* @__PURE__ */ _react2.default.createElement(
54
70
  _reacthookform.Controller,
55
71
  {
56
72
  name,
57
73
  control,
58
- rules,
74
+ rules: mergedRules,
59
75
  render: ({ field: { onChange, onBlur, value } }) => /* @__PURE__ */ _react2.default.createElement(
60
76
  _chunkJYRR3NKHjs.FormTimeInput,
61
77
  _chunk2NMEKWO5js.__spreadProps.call(void 0, _chunk2NMEKWO5js.__spreadValues.call(void 0, {}, rest), {
@@ -65,6 +81,11 @@ function HookFormTimeInput(_a) {
65
81
  onChange,
66
82
  onBlur,
67
83
  disabled,
84
+ required: _chunkVYBFV2QDjs.isValidationRuleEnabled.call(void 0, mergedRules == null ? void 0 : mergedRules.required),
85
+ min: _chunkVYBFV2QDjs.getValidationRuleValue.call(void 0, mergedRules == null ? void 0 : mergedRules.min),
86
+ max: _chunkVYBFV2QDjs.getValidationRuleValue.call(void 0, mergedRules == null ? void 0 : mergedRules.max),
87
+ maxLength: _chunkVYBFV2QDjs.getValidationRuleValue.call(void 0, mergedRules == null ? void 0 : mergedRules.maxLength),
88
+ minLength: _chunkVYBFV2QDjs.getValidationRuleValue.call(void 0, mergedRules == null ? void 0 : mergedRules.minLength),
68
89
  classNames: {
69
90
  label: _chunkNBQEF4JDjs.cn.call(void 0, classNames == null ? void 0 : classNames.label, {
70
91
  "text-danger": showError
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-time-input.js","../../../components/form/hook-time-input.tsx"],"names":[],"mappings":"AAAA,qLAAY;AACZ;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACA;ACnBA,4EAAkB;AAClB,gFAAiB;AACjB,gDAA+E;AAYxE,SAAS,iBAAA,CAAyC,EAAA,EAS3B;AAT2B,EAAA,IAAA,GAAA,EAAA,EAAA,EACvD;AAAA,IAAA,EAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA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UACA,KAAA;AAAA,UACA,QAAA;AAAA,UACA,MAAA;AAAA,UACA,QAAA;AAAA,UACA,UAAA,EAAY;AAAA,YACV,KAAA,EAAO,iCAAA,WAAG,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,KAAA,EAAO;AAAA,cAC3B,aAAA,EAAe;AAAA,YACjB,CAAC,CAAA;AAAA,YACD,KAAA,EAAO,iCAAA,WAAG,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,KAAA,EAAO;AAAA,cAC3B,yBAAA,EAA2B;AAAA,YAC7B,CAAC;AAAA,UACH;AAAA,QAAA,CAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ,CAAA,EACC,UAAA,mBAAa,eAAA,CAAA,aAAA,CAAC,0BAAA,EAAA,EAAU,KAAA,EAAO,IAAA,EAAM,SAAA,EAAU,MAAA,EAAO,OAAA,EAAS,aAAA,CAAc,CAChF,CAAA;AAEJ;ADaA;AACE;AACF,8CAAC","file":"/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-time-input.js","sourcesContent":[null,"\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { Controller, FieldValues, RegisterOptions, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTimeInput } from './time-input';\nimport type { FormTimeInputProps } from './time-input';\n\ntype HookFormTimeInputProps<T extends FieldValues> = Omit<FormTimeInputProps, 'name' | 'inputProps'> & {\n name: Path<T>;\n rules?: RegisterOptions<T, Path<T>>;\n error?: string;\n};\n\nexport function HookFormTimeInput<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n ...rest\n}: HookFormTimeInputProps<T>) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n control,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError?.message as string);\n const showError = !!fieldError && !disabled;\n\n return (\n <div className={cn('$hook-form-time-input', classNames?.wrapper)}>\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ field: { onChange, onBlur, value } }) => (\n <FormTimeInput\n {...rest}\n name={name}\n label={label}\n value={value}\n onChange={onChange}\n onBlur={onBlur}\n disabled={disabled}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n />\n )}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-time-input.js","../../../components/form/hook-time-input.tsx"],"names":[],"mappings":"AAAA,qLAAY;AACZ;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACA;ACxBA,4EAAkB;AAClB,gFAAiB;AACjB,gDAA8D;AAsBvD,SAAS,iBAAA,CAAyC,EAAA,EAc3B;AAd2B,EAAA,IAAA,GAAA,EAAA,EAAA,EACvD;AAAA,IAAA,EAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAA;AAAA,IACA,GAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,EArCF,EAAA,EAyByD,EAAA,EAapD,KAAA,EAAA,wCAAA,EAboD,EAapD;AAAA,IAZH,IAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA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UACA,QAAA,EAAU,sDAAA,YAAwB,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,WAAA,CAAa,QAAQ,CAAA;AAAA,UACvD,GAAA,EAAK,qDAAA,YAAuB,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,WAAA,CAAa,GAAG,CAAA;AAAA,UAC5C,GAAA,EAAK,qDAAA,YAAuB,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,WAAA,CAAa,GAAG,CAAA;AAAA,UAC5C,SAAA,EAAW,qDAAA,YAAuB,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,WAAA,CAAa,SAAS,CAAA;AAAA,UACxD,SAAA,EAAW,qDAAA,YAAuB,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,WAAA,CAAa,SAAS,CAAA;AAAA,UACxD,UAAA,EAAY;AAAA,YACV,KAAA,EAAO,iCAAA,WAAG,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,KAAA,EAAO;AAAA,cAC3B,aAAA,EAAe;AAAA,YACjB,CAAC,CAAA;AAAA,YACD,KAAA,EAAO,iCAAA,WAAG,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,KAAA,EAAO;AAAA,cAC3B,yBAAA,EAA2B;AAAA,YAC7B,CAAC;AAAA,UACH;AAAA,QAAA,CAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ,CAAA,EACC,UAAA,mBAAa,eAAA,CAAA,aAAA,CAAC,0BAAA,EAAA,EAAU,KAAA,EAAO,IAAA,EAAM,SAAA,EAAU,MAAA,EAAO,OAAA,EAAS,aAAA,CAAc,CAChF,CAAA;AAEJ;ADaA;AACE;AACF,8CAAC","file":"/home/jahn/projects/shadcn-theme/packages/react/dist/components/form/hook-time-input.js","sourcesContent":[null,"\"use client\";\nimport React from 'react';\nimport _get from 'lodash-es/get';\nimport { Controller, FieldValues, Path, useFormContext } from 'react-hook-form';\nimport { cn } from '../../utils/ui';\nimport { FormError } from './error';\nimport { FormTimeInput } from './time-input';\nimport type { FormTimeInputProps } from './time-input';\nimport { getValidationRuleValue, isValidationRuleEnabled, mergeHookFormRules } from './types';\nimport type { HookFormRules, HookFormValidationAttributes } from './types';\n\ntype HookFormTimeInputValidationAttributes = Pick<\n HookFormValidationAttributes,\n 'required' | 'min' | 'max' | 'maxLength' | 'minLength'\n>;\n\ntype HookFormTimeInputProps<T extends FieldValues> = Omit<\n FormTimeInputProps,\n 'name' | 'inputProps' | keyof HookFormTimeInputValidationAttributes\n> & {\n name: Path<T>;\n rules?: HookFormRules<T>;\n error?: string;\n} & HookFormTimeInputValidationAttributes;\n\nexport function HookFormTimeInput<T extends FieldValues>({\n id,\n name,\n rules,\n label,\n error,\n classNames,\n disabled,\n required,\n min,\n max,\n maxLength,\n minLength,\n ...rest\n}: HookFormTimeInputProps<T>) {\n const methods = useFormContext<T>();\n if (!methods) return null;\n\n const {\n control,\n formState: { errors },\n } = methods;\n\n const fieldError = _get(errors, name);\n const errorMessage = error ?? (fieldError?.message as string);\n const showError = !!fieldError && !disabled;\n const mergedRules = mergeHookFormRules(rules, { required, min, max, maxLength, minLength });\n\n return (\n <div className={cn('$hook-form-time-input', classNames?.wrapper)}>\n <Controller\n name={name}\n control={control}\n rules={mergedRules}\n render={({ field: { onChange, onBlur, value } }) => (\n <FormTimeInput\n {...rest}\n name={name}\n label={label}\n value={value}\n onChange={onChange}\n onBlur={onBlur}\n disabled={disabled}\n required={isValidationRuleEnabled(mergedRules?.required)}\n min={getValidationRuleValue(mergedRules?.min)}\n max={getValidationRuleValue(mergedRules?.max)}\n maxLength={getValidationRuleValue(mergedRules?.maxLength)}\n minLength={getValidationRuleValue(mergedRules?.minLength)}\n classNames={{\n label: cn(classNames?.label, {\n 'text-danger': showError,\n }),\n input: cn(classNames?.input, {\n 'ring-danger text-danger': showError,\n }),\n }}\n />\n )}\n />\n {showError && <FormError field={name} className=\"mt-1\" message={errorMessage} />}\n </div>\n );\n}\n"]}