@zayne-labs/ui-react 0.8.19 → 0.9.2

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 (68) hide show
  1. package/css/animation.css +16 -0
  2. package/css/preset.css +2 -0
  3. package/dist/esm/chunk-ET4KZBFA.js +49 -0
  4. package/dist/esm/chunk-ET4KZBFA.js.map +1 -0
  5. package/dist/esm/chunk-IUEPHHGO.js +74 -0
  6. package/dist/esm/chunk-IUEPHHGO.js.map +1 -0
  7. package/dist/esm/{common/show/index.js → chunk-V5DSTESN.js} +5 -5
  8. package/dist/esm/chunk-V5DSTESN.js.map +1 -0
  9. package/dist/esm/{common → components/common}/await/index.d.ts +2 -2
  10. package/dist/esm/{common → components/common}/await/index.js +5 -6
  11. package/dist/esm/components/common/await/index.js.map +1 -0
  12. package/dist/esm/{common → components/common}/error-boundary/index.d.ts +2 -2
  13. package/dist/esm/components/common/error-boundary/index.js +4 -0
  14. package/dist/esm/components/common/for/index.js +4 -0
  15. package/dist/esm/components/common/show/index.js +5 -0
  16. package/dist/esm/components/common/slot/index.js +4 -0
  17. package/dist/esm/components/common/slot/index.js.map +1 -0
  18. package/dist/esm/{common → components/common}/suspense-with-boundary/index.d.ts +1 -1
  19. package/dist/esm/{common → components/common}/suspense-with-boundary/index.js +2 -2
  20. package/dist/esm/components/common/suspense-with-boundary/index.js.map +1 -0
  21. package/dist/esm/{common → components/common}/switch/index.js +2 -2
  22. package/dist/esm/components/common/switch/index.js.map +1 -0
  23. package/dist/esm/{common → components/common}/teleport/index.js +1 -1
  24. package/dist/esm/components/common/teleport/index.js.map +1 -0
  25. package/dist/esm/{ui → components/ui}/card/index.js +3 -3
  26. package/dist/esm/components/ui/card/index.js.map +1 -0
  27. package/dist/esm/{ui → components/ui}/carousel/index.d.ts +11 -9
  28. package/dist/esm/{ui → components/ui}/carousel/index.js +12 -10
  29. package/dist/esm/components/ui/carousel/index.js.map +1 -0
  30. package/dist/esm/{ui → components/ui}/drag-scroll/index.js +2 -2
  31. package/dist/esm/components/ui/drag-scroll/index.js.map +1 -0
  32. package/dist/esm/{ui → components/ui}/drop-zone/index.d.ts +31 -27
  33. package/dist/esm/{ui → components/ui}/drop-zone/index.js +59 -49
  34. package/dist/esm/components/ui/drop-zone/index.js.map +1 -0
  35. package/dist/esm/{ui → components/ui}/form/index.d.ts +29 -13
  36. package/dist/esm/{ui → components/ui}/form/index.js +208 -103
  37. package/dist/esm/components/ui/form/index.js.map +1 -0
  38. package/dist/esm/lib/utils/getSlot/index.d.ts +60 -0
  39. package/dist/esm/lib/utils/getSlot/index.js +4 -0
  40. package/dist/esm/lib/utils/getSlot/index.js.map +1 -0
  41. package/dist/esm/lib/utils/getSlotMap/index.d.ts +82 -0
  42. package/dist/esm/lib/utils/getSlotMap/index.js +4 -0
  43. package/dist/esm/lib/utils/getSlotMap/index.js.map +1 -0
  44. package/dist/style.css +19 -3
  45. package/package.json +10 -9
  46. package/dist/esm/common/await/index.js.map +0 -1
  47. package/dist/esm/common/error-boundary/index.js +0 -4
  48. package/dist/esm/common/for/index.js +0 -4
  49. package/dist/esm/common/show/index.js.map +0 -1
  50. package/dist/esm/common/slot/index.js +0 -4
  51. package/dist/esm/common/suspense-with-boundary/index.js.map +0 -1
  52. package/dist/esm/common/switch/index.js.map +0 -1
  53. package/dist/esm/common/teleport/index.js.map +0 -1
  54. package/dist/esm/ui/card/index.js.map +0 -1
  55. package/dist/esm/ui/carousel/index.js.map +0 -1
  56. package/dist/esm/ui/drag-scroll/index.js.map +0 -1
  57. package/dist/esm/ui/drop-zone/index.js.map +0 -1
  58. package/dist/esm/ui/form/index.js.map +0 -1
  59. /package/dist/esm/{common → components/common}/error-boundary/index.js.map +0 -0
  60. /package/dist/esm/{common → components/common}/for/index.d.ts +0 -0
  61. /package/dist/esm/{common → components/common}/for/index.js.map +0 -0
  62. /package/dist/esm/{common → components/common}/show/index.d.ts +0 -0
  63. /package/dist/esm/{common/slot → components/common/show}/index.js.map +0 -0
  64. /package/dist/esm/{common → components/common}/slot/index.d.ts +0 -0
  65. /package/dist/esm/{common → components/common}/switch/index.d.ts +0 -0
  66. /package/dist/esm/{common → components/common}/teleport/index.d.ts +0 -0
  67. /package/dist/esm/{ui → components/ui}/card/index.d.ts +0 -0
  68. /package/dist/esm/{ui → components/ui}/drag-scroll/index.d.ts +0 -0
@@ -1,18 +1,81 @@
1
- import { dataAttr } from '../../chunk-DNYM6XGW.js';
2
- import { cnMerge } from '../../chunk-OHG7GB7O.js';
3
- import { getElementList } from '../../chunk-DW3FXTFL.js';
4
- import { Slot } from '../../chunk-2P3P5AXH.js';
5
- import { __export } from '../../chunk-PZ5AY32C.js';
1
+ import { dataAttr } from '../../../chunk-DNYM6XGW.js';
2
+ import { cnMerge } from '../../../chunk-OHG7GB7O.js';
3
+ import { getElementList } from '../../../chunk-DW3FXTFL.js';
4
+ import { Slot } from '../../../chunk-2P3P5AXH.js';
5
+ import { getMultipleSlots } from '../../../chunk-IUEPHHGO.js';
6
+ import { __export } from '../../../chunk-PZ5AY32C.js';
6
7
  import * as React2 from 'react';
7
- import { Fragment, useId, useMemo, useRef, useEffect } from 'react';
8
- import { toArray } from '@zayne-labs/toolkit-core';
9
- import { createCustomContext, useToggle, ContextError } from '@zayne-labs/toolkit-react';
10
- import { getMultipleSlots, composeTwoEventHandlers, composeRefs } from '@zayne-labs/toolkit-react/utils';
11
- import { defineEnum } from '@zayne-labs/toolkit-type-helpers';
8
+ import { useMemo, Fragment, useId, useRef, useEffect, createElement } from 'react';
9
+ import { on, toArray } from '@zayne-labs/toolkit-core';
10
+ import { createCustomContext, useToggle, useCallbackRef, ContextError } from '@zayne-labs/toolkit-react';
11
+ import { composeTwoEventHandlers, composeRefs } from '@zayne-labs/toolkit-react/utils';
12
+ import { defineEnum, isString, isObject } from '@zayne-labs/toolkit-type-helpers';
12
13
  import { useFormState, useWatch, FormProvider, Controller, useFormContext } from 'react-hook-form';
13
14
  export { useFormContext as useFormRootContext } from 'react-hook-form';
14
15
 
15
- var useFormRootContext = (options = {}) => {
16
+ var EyeIconClosed = (props) => /* @__PURE__ */ React2.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React2.createElement(
17
+ "path",
18
+ {
19
+ fill: "currentColor",
20
+ d: "M15.175 8.325q.725.725 1.063 1.65t.237 1.9q0 .375-.275.638t-.65.262t-.638-.262t-.262-.638q.125-.65-.075-1.25T13.95 9.6t-1.025-.65t-1.275-.1q-.375 0-.638-.275t-.262-.65t.263-.637t.637-.263q.95-.1 1.875.238t1.65 1.062M12 6q-.475 0-.925.037t-.9.138q-.425.075-.763-.125t-.462-.6t.088-.775t.612-.45q.575-.125 1.163-.175T12 4q3.425 0 6.263 1.8t4.337 4.85q.1.2.15.413t.05.437t-.038.438t-.137.412q-.45 1-1.112 1.875t-1.463 1.6q-.3.275-.7.225t-.65-.4t-.212-.763t.337-.687q.6-.575 1.1-1.25t.875-1.45q-1.25-2.525-3.613-4.012T12 6m0 13q-3.35 0-6.125-1.812T1.5 12.425q-.125-.2-.187-.437T1.25 11.5t.05-.475t.175-.45q.5-1 1.163-1.912T4.15 7L2.075 4.9q-.275-.3-.262-.712T2.1 3.5t.7-.275t.7.275l17 17q.275.275.288.688t-.288.712q-.275.275-.7.275t-.7-.275l-3.5-3.45q-.875.275-1.775.413T12 19M5.55 8.4q-.725.65-1.325 1.425T3.2 11.5q1.25 2.525 3.613 4.013T12 17q.5 0 .975-.062t.975-.138l-.9-.95q-.275.075-.525.113T12 16q-1.875 0-3.188-1.312T7.5 11.5q0-.275.038-.525t.112-.525zm4.2 4.2"
21
+ }
22
+ ));
23
+ var EyeIconOpen = (props) => /* @__PURE__ */ React2.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React2.createElement(
24
+ "path",
25
+ {
26
+ fill: "currentColor",
27
+ d: "M12 16q1.875 0 3.188-1.312T16.5 11.5t-1.312-3.187T12 7T8.813 8.313T7.5 11.5t1.313 3.188T12 16m0-1.8q-1.125 0-1.912-.788T9.3 11.5t.788-1.912T12 8.8t1.913.788t.787 1.912t-.787 1.913T12 14.2m0 4.8q-3.35 0-6.113-1.8t-4.362-4.75q-.125-.225-.187-.462t-.063-.488t.063-.488t.187-.462q1.6-2.95 4.363-4.75T12 4t6.113 1.8t4.362 4.75q.125.225.188.463t.062.487t-.062.488t-.188.462q-1.6 2.95-4.362 4.75T12 19m0-2q2.825 0 5.188-1.487T20.8 11.5q-1.25-2.525-3.613-4.012T12 6T6.813 7.488T3.2 11.5q1.25 2.525 3.613 4.013T12 17"
28
+ }
29
+ ));
30
+
31
+ // src/components/ui/form/utils.ts
32
+ var getFieldErrorMessage = (options) => {
33
+ const { errors, fieldName, type } = options;
34
+ if (!fieldName || !errors || Object.keys(errors).length === 0) return;
35
+ if (type === "root") {
36
+ return errors.root?.[fieldName]?.message;
37
+ }
38
+ const pathParts = fieldName.includes(".") ? fieldName.split(".") : null;
39
+ if (!pathParts) {
40
+ const errorMessage2 = errors[fieldName]?.message;
41
+ return isString(errorMessage2) ? errorMessage2 : null;
42
+ }
43
+ let extractedError = errors;
44
+ for (const part of pathParts) {
45
+ const currentError = extractedError[part];
46
+ if (!isObject(currentError)) break;
47
+ extractedError = currentError;
48
+ }
49
+ const errorMessage = isString(extractedError.message) ? extractedError.message : null;
50
+ return errorMessage;
51
+ };
52
+ var getEyeIcon = (options) => {
53
+ const { classNames, iconType, renderIconProps, withEyeIcon } = options;
54
+ if (!withEyeIcon) {
55
+ return null;
56
+ }
57
+ if (withEyeIcon === true) {
58
+ const defaultIconMap = {
59
+ closed: createElement(EyeIconClosed, {
60
+ className: cnMerge("size-full", classNames?.eyeIcon)
61
+ }),
62
+ open: createElement(EyeIconOpen, {
63
+ className: cnMerge("size-full", classNames?.eyeIcon)
64
+ })
65
+ };
66
+ return defaultIconMap[iconType];
67
+ }
68
+ if (withEyeIcon.renderIcon) {
69
+ return withEyeIcon.renderIcon(renderIconProps);
70
+ }
71
+ if (withEyeIcon[iconType]) {
72
+ return withEyeIcon[iconType];
73
+ }
74
+ return null;
75
+ };
76
+
77
+ // src/components/ui/form/form-context.ts
78
+ var useFormMethodsContext = (options = {}) => {
16
79
  const { strict = true } = options;
17
80
  const formContext = useFormContext();
18
81
  if (strict && !formContext) {
@@ -22,13 +85,12 @@ var useFormRootContext = (options = {}) => {
22
85
  }
23
86
  return formContext;
24
87
  };
25
- var useLaxFormFieldState = (options) => {
26
- const { control = options?.control } = useFormRootContext({ strict: false }) ?? {};
27
- const { name = options?.name } = useLaxFormFieldContext() ?? {};
28
- const getFormState = control ? useFormState : () => ({});
29
- const { disabled, errors } = getFormState({ control, name });
30
- return { errors, isDisabled: disabled, isInvalid: Boolean(options?.name && errors?.[options.name]) };
31
- };
88
+ var [LaxFormRootProvider, useLaxFormRootContext] = createCustomContext({
89
+ hookName: "useLaxFormRootContext",
90
+ name: "LaxFormRootContext",
91
+ providerName: "FormRoot",
92
+ strict: false
93
+ });
32
94
  var [StrictFormFieldProvider, useStrictFormFieldContext] = createCustomContext(
33
95
  {
34
96
  hookName: "useFormFieldContext",
@@ -42,25 +104,24 @@ var [LaxFormFieldProvider, useLaxFormFieldContext] = createCustomContext({
42
104
  providerName: "FormField",
43
105
  strict: false
44
106
  });
45
- var EyeIconInvisible = (props) => /* @__PURE__ */ React2.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React2.createElement(
46
- "path",
47
- {
48
- fill: "currentColor",
49
- d: "M15.175 8.325q.725.725 1.063 1.65t.237 1.9q0 .375-.275.638t-.65.262t-.638-.262t-.262-.638q.125-.65-.075-1.25T13.95 9.6t-1.025-.65t-1.275-.1q-.375 0-.638-.275t-.262-.65t.263-.637t.637-.263q.95-.1 1.875.238t1.65 1.062M12 6q-.475 0-.925.037t-.9.138q-.425.075-.763-.125t-.462-.6t.088-.775t.612-.45q.575-.125 1.163-.175T12 4q3.425 0 6.263 1.8t4.337 4.85q.1.2.15.413t.05.437t-.038.438t-.137.412q-.45 1-1.112 1.875t-1.463 1.6q-.3.275-.7.225t-.65-.4t-.212-.763t.337-.687q.6-.575 1.1-1.25t.875-1.45q-1.25-2.525-3.613-4.012T12 6m0 13q-3.35 0-6.125-1.812T1.5 12.425q-.125-.2-.187-.437T1.25 11.5t.05-.475t.175-.45q.5-1 1.163-1.912T4.15 7L2.075 4.9q-.275-.3-.262-.712T2.1 3.5t.7-.275t.7.275l17 17q.275.275.288.688t-.288.712q-.275.275-.7.275t-.7-.275l-3.5-3.45q-.875.275-1.775.413T12 19M5.55 8.4q-.725.65-1.325 1.425T3.2 11.5q1.25 2.525 3.613 4.013T12 17q.5 0 .975-.062t.975-.138l-.9-.95q-.275.075-.525.113T12 16q-1.875 0-3.188-1.312T7.5 11.5q0-.275.038-.525t.112-.525zm4.2 4.2"
50
- }
51
- ));
52
- var EyeIconVisible = (props) => /* @__PURE__ */ React2.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React2.createElement(
53
- "path",
54
- {
55
- fill: "currentColor",
56
- d: "M12 16q1.875 0 3.188-1.312T16.5 11.5t-1.312-3.187T12 7T8.813 8.313T7.5 11.5t1.313 3.188T12 16m0-1.8q-1.125 0-1.912-.788T9.3 11.5t.788-1.912T12 8.8t1.913.788t.787 1.912t-.787 1.913T12 14.2m0 4.8q-3.35 0-6.113-1.8t-4.362-4.75q-.125-.225-.187-.462t-.063-.488t.063-.488t.187-.462q1.6-2.95 4.363-4.75T12 4t6.113 1.8t4.362 4.75q.125.225.188.463t.062.487t-.062.488t-.188.462q-1.6 2.95-4.362 4.75T12 19m0-2q2.825 0 5.188-1.487T20.8 11.5q-1.25-2.525-3.613-4.012T12 6T6.813 7.488T3.2 11.5q1.25 2.525 3.613 4.013T12 17"
57
- }
58
- ));
107
+ var useLaxFormFieldState = (options) => {
108
+ const { control = options?.control } = useFormMethodsContext({ strict: false }) ?? {};
109
+ const { name = options?.name } = useLaxFormFieldContext() ?? {};
110
+ const getFormState = control ? useFormState : () => ({});
111
+ const { disabled, errors } = getFormState({ control, name });
112
+ const errorMessage = getFieldErrorMessage({ errors, fieldName: name, type: "regular" });
113
+ return {
114
+ errors,
115
+ isDisabled: disabled,
116
+ isInvalid: Boolean(errorMessage)
117
+ };
118
+ };
59
119
 
60
120
  // src/components/ui/form/form.tsx
61
121
  function FormRoot(props) {
62
- const { children, className, methods, ...restOfProps } = props;
63
- return /* @__PURE__ */ React2.createElement(FormProvider, { ...methods }, /* @__PURE__ */ React2.createElement(
122
+ const { children, className, methods, withEyeIcon, ...restOfProps } = props;
123
+ const formContextValue = useMemo(() => ({ withEyeIcon }), [withEyeIcon]);
124
+ return /* @__PURE__ */ React2.createElement(FormProvider, { ...methods }, /* @__PURE__ */ React2.createElement(LaxFormRootProvider, { value: formContextValue }, /* @__PURE__ */ React2.createElement(
64
125
  "form",
65
126
  {
66
127
  className: cnMerge("flex flex-col", className),
@@ -70,7 +131,7 @@ function FormRoot(props) {
70
131
  "data-slot": "form-root"
71
132
  },
72
133
  children
73
- ));
134
+ )));
74
135
  }
75
136
  function FormField(props) {
76
137
  const { children, className, name, withWrapper = true } = props;
@@ -98,7 +159,13 @@ function FormField(props) {
98
159
  };
99
160
  return /* @__PURE__ */ React2.createElement(StrictFormFieldProvider, { value: fieldContextValue }, /* @__PURE__ */ React2.createElement(LaxFormFieldProvider, { value: fieldContextValue }, /* @__PURE__ */ React2.createElement(WrapperElement, { ...wrapperElementProps }, children)));
100
161
  }
101
- function FormControlledField(props) {
162
+ function FormFieldController(props) {
163
+ const { control } = useFormMethodsContext();
164
+ const { name } = useStrictFormFieldContext();
165
+ const { render, ...restOfProps } = props;
166
+ return /* @__PURE__ */ React2.createElement(Controller, { name, control, render, ...restOfProps });
167
+ }
168
+ function FormFieldControlledField(props) {
102
169
  const { name } = props;
103
170
  const uniqueId = useId();
104
171
  const fieldContextValue = useMemo(
@@ -112,12 +179,6 @@ function FormControlledField(props) {
112
179
  );
113
180
  return /* @__PURE__ */ React2.createElement(StrictFormFieldProvider, { value: fieldContextValue }, /* @__PURE__ */ React2.createElement(LaxFormFieldProvider, { value: fieldContextValue }, /* @__PURE__ */ React2.createElement(Controller, { ...props })));
114
181
  }
115
- function FormFieldController(props) {
116
- const { control } = useFormRootContext();
117
- const { name } = useStrictFormFieldContext();
118
- const { render, ...restOfProps } = props;
119
- return /* @__PURE__ */ React2.createElement(Controller, { name, control, render, ...restOfProps });
120
- }
121
182
  function FormFieldContext(props) {
122
183
  const { children, render } = props;
123
184
  const fieldContextValues = useStrictFormFieldContext();
@@ -201,6 +262,7 @@ FormInputRightItem.slotSymbol = Symbol("input-right-item");
201
262
  var inputTypesWithoutFullWith = /* @__PURE__ */ new Set(["checkbox", "radio"]);
202
263
  function FormInputPrimitive(props) {
203
264
  const fieldContextValues = useLaxFormFieldContext();
265
+ const formRootContextValues = useLaxFormRootContext();
204
266
  const {
205
267
  className,
206
268
  classNames,
@@ -210,7 +272,7 @@ function FormInputPrimitive(props) {
210
272
  name = fieldContextValues?.name,
211
273
  rules,
212
274
  type = "text",
213
- withEyeIcon = true,
275
+ withEyeIcon = formRootContextValues?.withEyeIcon ?? true,
214
276
  ...restOfProps
215
277
  } = props;
216
278
  const fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });
@@ -221,7 +283,13 @@ function FormInputPrimitive(props) {
221
283
  const wrapperElementProps = shouldHaveEyeIcon && {
222
284
  className: cnMerge("w-full", classNames?.inputGroup, isInvalid && classNames?.error)
223
285
  };
224
- const { register } = useFormRootContext({ strict: false }) ?? {};
286
+ const { register } = useFormMethodsContext({ strict: false }) ?? {};
287
+ const eyeIcon = getEyeIcon({
288
+ classNames,
289
+ iconType: isPasswordVisible ? "closed" : "open",
290
+ renderIconProps: { isPasswordVisible },
291
+ withEyeIcon
292
+ });
225
293
  return /* @__PURE__ */ React2.createElement(WrapperElement, { ...wrapperElementProps }, /* @__PURE__ */ React2.createElement(
226
294
  "input",
227
295
  {
@@ -254,7 +322,7 @@ function FormInputPrimitive(props) {
254
322
  onClick: toggleVisibility,
255
323
  className: "size-5 shrink-0 lg:size-6"
256
324
  },
257
- isPasswordVisible ? /* @__PURE__ */ React2.createElement(EyeIconInvisible, { className: cnMerge("size-full", classNames?.eyeIcon) }) : /* @__PURE__ */ React2.createElement(EyeIconVisible, { className: cnMerge("size-full", classNames?.eyeIcon) })
325
+ eyeIcon
258
326
  ));
259
327
  }
260
328
  function FormTextAreaPrimitive(props) {
@@ -271,7 +339,7 @@ function FormTextAreaPrimitive(props) {
271
339
  } = props;
272
340
  const fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });
273
341
  const { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;
274
- const { register } = useFormRootContext({ strict: false }) ?? {};
342
+ const { register } = useFormMethodsContext({ strict: false }) ?? {};
275
343
  return /* @__PURE__ */ React2.createElement(
276
344
  "textarea",
277
345
  {
@@ -310,7 +378,7 @@ function FormSelectPrimitive(props) {
310
378
  } = props;
311
379
  const fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });
312
380
  const { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;
313
- const { register } = useFormRootContext({ strict: false }) ?? {};
381
+ const { register } = useFormMethodsContext({ strict: false }) ?? {};
314
382
  return /* @__PURE__ */ React2.createElement(
315
383
  "select",
316
384
  {
@@ -343,7 +411,7 @@ var InputTypeMap = defineEnum({
343
411
  function FormInput(props) {
344
412
  const { onBlur, onChange, ref, rules, type, ...restOfProps } = props;
345
413
  const { name } = useStrictFormFieldContext();
346
- const { register } = useFormRootContext();
414
+ const { register } = useFormMethodsContext();
347
415
  const SelectedInput = type === "textarea" || type === "select" ? InputTypeMap[type] : FormInputPrimitive;
348
416
  const registerProps = name ? register(name, rules) : null;
349
417
  return /* @__PURE__ */ React2.createElement(
@@ -372,7 +440,7 @@ function FormDescription(props) {
372
440
  }
373
441
  var FormErrorMessagePrimitive = (props) => {
374
442
  const fieldContextValues = useLaxFormFieldContext();
375
- const rootContextValues = useFormRootContext({ strict: false });
443
+ const rootContextValues = useFormMethodsContext({ strict: false });
376
444
  const {
377
445
  children,
378
446
  className,
@@ -380,88 +448,127 @@ var FormErrorMessagePrimitive = (props) => {
380
448
  control = rootContextValues?.control,
381
449
  disableErrorAnimation = false,
382
450
  disableScrollToErrorField = false,
383
- errorField = fieldContextValues?.name,
451
+ fieldName = fieldContextValues?.name,
384
452
  render,
385
453
  type = "regular"
386
454
  } = props;
387
- const { errors } = useLaxFormFieldState({ control, name: errorField });
455
+ const { errors } = useLaxFormFieldState({ control, name: fieldName });
388
456
  const { formMessageId } = useLaxFormFieldContext() ?? {};
457
+ const errorParagraphRef = useRef(null);
389
458
  const wrapperRef = useRef(null);
390
459
  const errorAnimationClass = classNames?.errorMessageAnimation ?? "animate-shake";
460
+ const getErrorElements = useCallbackRef(
461
+ () => wrapperRef.current?.children ?? [errorParagraphRef.current]
462
+ );
391
463
  useEffect(() => {
392
464
  if (disableErrorAnimation) return;
393
- const errorMessageElements = wrapperRef.current?.children ?? [];
465
+ if (!errors || Object.keys(errors).length === 0) return;
466
+ const errorMessageElements = getErrorElements();
467
+ if (errorMessageElements.length === 0) return;
394
468
  for (const element of errorMessageElements) {
469
+ if (!element) continue;
395
470
  element.classList.add(errorAnimationClass);
471
+ const onAnimationEnd = () => element.classList.remove(errorAnimationClass);
472
+ on("animationend", element, onAnimationEnd, { once: true });
396
473
  }
397
- }, [errorAnimationClass, disableErrorAnimation]);
474
+ }, [disableErrorAnimation, errorAnimationClass, errors, getErrorElements]);
398
475
  useEffect(() => {
399
476
  if (disableScrollToErrorField) return;
400
- const errorMessageElements = wrapperRef.current?.children;
401
- if (!errorMessageElements || !errors) return;
402
- if (Object.keys(errors).indexOf(errorField) === 0) {
403
- errorMessageElements[0]?.scrollIntoView({
477
+ if (!errors || Object.keys(errors).length === 0) return;
478
+ const errorMessageElements = getErrorElements();
479
+ const firstErrorElement = errorMessageElements[0];
480
+ if (!firstErrorElement) return;
481
+ const inputField = document.querySelector(`[name='${fieldName}']`);
482
+ const isFocusableInput = inputField?.matches(
483
+ ":is(input, select, textarea, [contenteditable='true'])"
484
+ );
485
+ if (isFocusableInput) return;
486
+ requestAnimationFrame(() => {
487
+ const rect = firstErrorElement.getBoundingClientRect();
488
+ const topWithOffset = rect.top - 100;
489
+ window.scrollTo({
404
490
  behavior: "smooth",
405
- block: "center"
491
+ top: window.scrollY + topWithOffset
406
492
  });
407
- window.scrollBy({ behavior: "smooth", top: -100 });
408
- }
409
- }, [disableScrollToErrorField, errorField, errors]);
410
- const message = type === "root" ? errors?.root?.[errorField]?.message : errors?.[errorField]?.message;
411
- if (!message) {
493
+ });
494
+ }, [disableScrollToErrorField, fieldName, errors, getErrorElements]);
495
+ const fieldErrorMessage = getFieldErrorMessage({ errors, fieldName, type });
496
+ if (!fieldErrorMessage) {
497
+ return null;
498
+ }
499
+ const errorMessageArray = toArray(fieldErrorMessage);
500
+ if (errorMessageArray.length === 0) {
412
501
  return null;
413
502
  }
414
- const errorMessageArray = toArray(message);
415
- const [ErrorMessageList] = getElementList();
416
- const onAnimationEnd = disableErrorAnimation ? (event) => event.currentTarget.classList.remove(errorAnimationClass) : void 0;
417
- const getRenderProps = ({ index }) => ({
418
- className: cnMerge(errorAnimationClass, className, classNames?.errorMessage),
419
- "data-index": index,
420
- "data-part": "error-message",
503
+ const getRenderProps = (options) => {
504
+ const { index } = options;
505
+ return {
506
+ className: cnMerge(className, classNames?.errorMessage),
507
+ "data-index": index,
508
+ "data-part": "error-message",
509
+ "data-scope": "form",
510
+ "data-slot": "form-error-message",
511
+ id: formMessageId,
512
+ ref: (node) => {
513
+ if (!node || errorParagraphRef.current) return;
514
+ errorParagraphRef.current = node;
515
+ }
516
+ };
517
+ };
518
+ const getRenderState = (options) => {
519
+ const { errorMessage, index } = options;
520
+ return {
521
+ errorMessage,
522
+ errorMessageArray,
523
+ index
524
+ };
525
+ };
526
+ const [ErrorMessageList] = getElementList("base");
527
+ const WrapperComponent = "div";
528
+ const wrapperComponentProps = errorMessageArray.length > 1 && {
529
+ className: cnMerge("flex flex-col", classNames?.container),
530
+ "data-part": "error-message-container",
421
531
  "data-scope": "form",
422
- "data-slot": "form-error-message",
423
- id: formMessageId,
424
- onAnimationEnd
425
- });
426
- const getRenderState = ({ errorMessage, index }) => ({
427
- errorMessage,
428
- errorMessageArray,
429
- index
430
- });
431
- const renderFn = typeof children === "function" ? children : render;
432
- return /* @__PURE__ */ React2.createElement(
532
+ "data-slot": "form-error-message-container",
533
+ ref: wrapperRef
534
+ };
535
+ const selectedChildren = typeof children === "function" ? children : render;
536
+ return /* @__PURE__ */ React2.createElement(WrapperComponent, { ...wrapperComponentProps }, /* @__PURE__ */ React2.createElement(
433
537
  ErrorMessageList,
434
538
  {
435
539
  each: errorMessageArray,
436
- ref: wrapperRef,
437
- className: cnMerge("flex flex-col", classNames?.container),
438
540
  render: (errorMessage, index) => {
439
- return renderFn({
541
+ return selectedChildren({
440
542
  props: getRenderProps({ index }),
441
543
  state: getRenderState({ errorMessage, index })
442
544
  });
443
545
  }
444
546
  }
445
- );
547
+ ));
446
548
  };
447
549
  function FormErrorMessage(props) {
448
550
  const fieldContextValues = useLaxFormFieldContext();
449
551
  const { className, errorField = fieldContextValues?.name, type = "regular" } = props;
450
- const { control } = useFormRootContext();
552
+ const { control } = useFormMethodsContext();
451
553
  return /* @__PURE__ */ React2.createElement(
452
554
  FormErrorMessagePrimitive,
453
555
  {
454
556
  control,
455
- errorField,
557
+ fieldName: errorField,
456
558
  type,
457
- render: ({ props: renderProps, state: { errorMessage } }) => /* @__PURE__ */ React2.createElement(
559
+ render: ({ props: renderProps, state }) => /* @__PURE__ */ React2.createElement(
458
560
  "p",
459
561
  {
460
- key: errorMessage,
562
+ key: state.errorMessage,
461
563
  ...renderProps,
462
- className: cnMerge("text-[13px]", "data-[index=0]:mt-1", renderProps.className, className)
564
+ className: cnMerge(
565
+ "text-[13px] text-red-600",
566
+ "data-[index=0]:mt-1",
567
+ renderProps.className,
568
+ className
569
+ )
463
570
  },
464
- errorMessage
571
+ state.errorMessage
465
572
  )
466
573
  }
467
574
  );
@@ -469,33 +576,31 @@ function FormErrorMessage(props) {
469
576
  function FormSubmit(props) {
470
577
  const { as: Element = "button", asChild, children, type = "submit", ...restOfProps } = props;
471
578
  const Component = asChild ? Slot : Element;
472
- return /* @__PURE__ */ React2.createElement(Component, { type, ...restOfProps }, children);
579
+ return /* @__PURE__ */ React2.createElement(Component, { "data-part": "submit", "data-scope": "form", "data-slot": "form-submit", type, ...restOfProps }, children);
473
580
  }
474
581
  function FormSubscribeToFieldValue(props) {
475
582
  const fieldContextValues = useLaxFormFieldContext();
476
583
  const { children, name = fieldContextValues?.name, render } = props;
477
- const { control } = useFormRootContext();
584
+ const { control } = useFormMethodsContext();
478
585
  const formValue = useWatch({ control, name });
479
586
  const fieldProps = { value: formValue };
480
- if (typeof children === "function") {
481
- return children(fieldProps);
482
- }
483
- return render(fieldProps);
587
+ const selectedChildren = typeof children === "function" ? children : render;
588
+ const resolvedChildren = selectedChildren(fieldProps);
589
+ return resolvedChildren;
484
590
  }
485
591
  function FormSubscribeToFormState(props) {
486
592
  const fieldContextValues = useLaxFormFieldContext();
487
593
  const { children, control, name = fieldContextValues?.name, render } = props;
488
594
  const formState = useFormState({ control, name });
489
- if (typeof children === "function") {
490
- return children(formState);
491
- }
492
- return render(formState);
595
+ const selectedChildren = typeof children === "function" ? children : render;
596
+ const resolvedChildren = selectedChildren(formState);
597
+ return resolvedChildren;
493
598
  }
494
599
 
495
600
  // src/components/ui/form/form-parts.ts
496
601
  var form_parts_exports = {};
497
602
  __export(form_parts_exports, {
498
- ControlledField: () => FormControlledField,
603
+ ControlledField: () => FormFieldControlledField,
499
604
  Description: () => FormDescription,
500
605
  ErrorMessage: () => FormErrorMessage,
501
606
  ErrorMessagePrimitive: () => FormErrorMessagePrimitive,
@@ -517,6 +622,6 @@ __export(form_parts_exports, {
517
622
  TextAreaPrimitive: () => FormTextAreaPrimitive
518
623
  });
519
624
 
520
- export { form_parts_exports as Form, FormControlledField, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldController, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormSelect, FormSelectPrimitive, FormSubmit, FormSubscribeToFieldValue, FormSubscribeToFormState, FormTextArea, FormTextAreaPrimitive, useStrictFormFieldContext as useFormFieldContext };
625
+ export { form_parts_exports as Form, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldControlledField, FormFieldController, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormSelect, FormSelectPrimitive, FormSubmit, FormSubscribeToFieldValue, FormSubscribeToFormState, FormTextArea, FormTextAreaPrimitive, useStrictFormFieldContext as useFormFieldContext };
521
626
  //# sourceMappingURL=index.js.map
522
627
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/components/ui/form/icons.tsx","../../../../../src/components/ui/form/utils.ts","../../../../../src/components/ui/form/form-context.ts","../../../../../src/components/ui/form/form.tsx","../../../../../src/components/ui/form/form-parts.ts"],"names":["React","errorMessage","createElement","useHookFormContext","HookFormProvider","ReactFragment","useFormState"],"mappings":";;;;;;;;;;;;;;;AAEO,IAAM,aAAgB,GAAA,CAAC,KAC7B,qBAAAA,MAAA,CAAA,aAAA,CAAC,SAAI,KAAM,EAAA,4BAAA,EAA6B,KAAM,EAAA,KAAA,EAAM,MAAO,EAAA,KAAA,EAAM,OAAQ,EAAA,WAAA,EAAa,GAAG,KACxF,EAAA,kBAAAA,MAAA,CAAA,aAAA;AAAA,EAAC,MAAA;AAAA,EAAA;AAAA,IACA,IAAK,EAAA,cAAA;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;AAAA,EAAA,YAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,KAAA,EAAA,MAAA,SAAA;AAAA,EAAA,YAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,eAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,KAAA,EAAA,MAAA,SAAA;AAAA,EAAA,UAAA,EAAA,MAAA,cAAA;AAAA,EAAA,aAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,cAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,cAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,KAAA,EAAA,MAAA,SAAA;AAAA,EAAA,IAAA,EAAA,MAAA,QAAA;AAAA,EAAA,MAAA,EAAA,MAAA,UAAA;AAAA,EAAA,MAAA,EAAA,MAAA,UAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,QAAA,EAAA,MAAA,YAAA;AAAA,EAAA,iBAAA,EAAA,MAAA;AAAA,CAAA,CAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\n\nexport const EyeIconClosed = (props: React.SVGProps<SVGSVGElement>) => (\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" {...props}>\n\t\t<path\n\t\t\tfill=\"currentColor\"\n\t\t\td=\"M15.175 8.325q.725.725 1.063 1.65t.237 1.9q0 .375-.275.638t-.65.262t-.638-.262t-.262-.638q.125-.65-.075-1.25T13.95 9.6t-1.025-.65t-1.275-.1q-.375 0-.638-.275t-.262-.65t.263-.637t.637-.263q.95-.1 1.875.238t1.65 1.062M12 6q-.475 0-.925.037t-.9.138q-.425.075-.763-.125t-.462-.6t.088-.775t.612-.45q.575-.125 1.163-.175T12 4q3.425 0 6.263 1.8t4.337 4.85q.1.2.15.413t.05.437t-.038.438t-.137.412q-.45 1-1.112 1.875t-1.463 1.6q-.3.275-.7.225t-.65-.4t-.212-.763t.337-.687q.6-.575 1.1-1.25t.875-1.45q-1.25-2.525-3.613-4.012T12 6m0 13q-3.35 0-6.125-1.812T1.5 12.425q-.125-.2-.187-.437T1.25 11.5t.05-.475t.175-.45q.5-1 1.163-1.912T4.15 7L2.075 4.9q-.275-.3-.262-.712T2.1 3.5t.7-.275t.7.275l17 17q.275.275.288.688t-.288.712q-.275.275-.7.275t-.7-.275l-3.5-3.45q-.875.275-1.775.413T12 19M5.55 8.4q-.725.65-1.325 1.425T3.2 11.5q1.25 2.525 3.613 4.013T12 17q.5 0 .975-.062t.975-.138l-.9-.95q-.275.075-.525.113T12 16q-1.875 0-3.188-1.312T7.5 11.5q0-.275.038-.525t.112-.525zm4.2 4.2\"\n\t\t/>\n\t</svg>\n);\n\nexport const EyeIconOpen = (props: React.SVGProps<SVGSVGElement>) => (\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" {...props}>\n\t\t<path\n\t\t\tfill=\"currentColor\"\n\t\t\td=\"M12 16q1.875 0 3.188-1.312T16.5 11.5t-1.312-3.187T12 7T8.813 8.313T7.5 11.5t1.313 3.188T12 16m0-1.8q-1.125 0-1.912-.788T9.3 11.5t.788-1.912T12 8.8t1.913.788t.787 1.912t-.787 1.913T12 14.2m0 4.8q-3.35 0-6.113-1.8t-4.362-4.75q-.125-.225-.187-.462t-.063-.488t.063-.488t.187-.462q1.6-2.95 4.363-4.75T12 4t6.113 1.8t4.362 4.75q.125.225.188.463t.062.487t-.062.488t-.188.462q-1.6 2.95-4.362 4.75T12 19m0-2q2.825 0 5.188-1.487T20.8 11.5q-1.25-2.525-3.613-4.012T12 6T6.813 7.488T3.2 11.5q1.25 2.525 3.613 4.013T12 17\"\n\t\t/>\n\t</svg>\n);\n","import { cnMerge } from \"@/lib/utils/cn\";\nimport { isObject, isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport type { FieldErrors, FieldValues } from \"react-hook-form\";\nimport type { FormErrorMessagePrimitiveProps, FormInputProps } from \"./form\";\nimport type { FormRootContext, RenderIconProps } from \"./form-context\";\nimport { EyeIconClosed, EyeIconOpen } from \"./icons\";\n\nexport const getFieldErrorMessage = (options: {\n\terrors: FieldErrors | undefined;\n\tfieldName: string | undefined;\n\ttype: FormErrorMessagePrimitiveProps<FieldValues>[\"type\"];\n}): string | string[] | null | undefined => {\n\tconst { errors, fieldName, type } = options;\n\n\tif (!fieldName || !errors || Object.keys(errors).length === 0) return;\n\n\tif (type === \"root\") {\n\t\treturn errors.root?.[fieldName]?.message;\n\t}\n\n\t// Handle nested paths like 'notifications.0'\n\tconst pathParts = fieldName.includes(\".\") ? fieldName.split(\".\") : null;\n\n\t// If there are no path parts, return the error message\n\tif (!pathParts) {\n\t\tconst errorMessage = errors[fieldName]?.message;\n\n\t\treturn isString(errorMessage) ? errorMessage : null;\n\t}\n\n\tlet extractedError = errors;\n\n\tfor (const part of pathParts) {\n\t\tconst currentError = extractedError[part];\n\n\t\tif (!isObject(currentError)) break;\n\n\t\textractedError = currentError as never;\n\t}\n\n\tconst errorMessage = isString(extractedError.message) ? extractedError.message : null;\n\n\treturn errorMessage;\n};\n\nexport const getEyeIcon = (options: {\n\tclassNames: FormInputProps[\"classNames\"];\n\ticonType: \"closed\" | \"open\";\n\trenderIconProps: RenderIconProps;\n\twithEyeIcon: FormRootContext[\"withEyeIcon\"];\n}) => {\n\tconst { classNames, iconType, renderIconProps, withEyeIcon } = options;\n\n\tif (!withEyeIcon) {\n\t\treturn null;\n\t}\n\n\tif (withEyeIcon === true) {\n\t\tconst defaultIconMap = {\n\t\t\tclosed: createElement(EyeIconClosed, {\n\t\t\t\tclassName: cnMerge(\"size-full\", classNames?.eyeIcon),\n\t\t\t}),\n\n\t\t\topen: createElement(EyeIconOpen, {\n\t\t\t\tclassName: cnMerge(\"size-full\", classNames?.eyeIcon),\n\t\t\t}),\n\t\t};\n\n\t\treturn defaultIconMap[iconType];\n\t}\n\n\tif (withEyeIcon.renderIcon) {\n\t\treturn withEyeIcon.renderIcon(renderIconProps);\n\t}\n\n\tif (withEyeIcon[iconType]) {\n\t\treturn withEyeIcon[iconType];\n\t}\n\n\treturn null;\n};\n","import { ContextError, createCustomContext } from \"@zayne-labs/toolkit-react\";\nimport type { DiscriminatedRenderProps } from \"@zayne-labs/toolkit-react/utils\";\nimport type { UnionDiscriminator } from \"@zayne-labs/toolkit-type-helpers\";\nimport {\n\ttype Control,\n\ttype UseFormReturn,\n\ttype UseFormStateReturn,\n\tuseFormState,\n\tuseFormContext as useHookFormContext,\n} from \"react-hook-form\";\nimport type { FieldValues, FormInputProps } from \"./form\";\nimport { getFieldErrorMessage } from \"./utils\";\n\ntype UseFormRootContextResult<TStrict extends boolean = true> = TStrict extends true\n\t? UseFormReturn<FieldValues> & { withEyeIcon?: FormInputProps[\"withEyeIcon\"] }\n\t: (UseFormReturn<FieldValues> & { withEyeIcon?: FormInputProps[\"withEyeIcon\"] }) | null;\n\nexport const useFormMethodsContext = <TStrict extends boolean = true>(\n\toptions: { strict?: TStrict } = {}\n): UseFormRootContextResult<TStrict> => {\n\tconst { strict = true } = options;\n\tconst formContext = useHookFormContext();\n\n\tif (strict && !(formContext as unknown)) {\n\t\tthrow new ContextError(\n\t\t\t`useFormRootContext returned \"null\". Did you forget to wrap the necessary components within FormRoot?`\n\t\t);\n\t}\n\n\treturn formContext;\n};\n\nexport type RenderIconProps = {\n\tisPasswordVisible: boolean;\n};\n\ntype EyeIconObject = UnionDiscriminator<\n\t[\n\t\t{ closed: React.ReactNode; open: React.ReactNode },\n\t\t{ renderIcon: (props: RenderIconProps) => React.ReactNode },\n\t]\n>;\n\nexport type FormRootContext = {\n\twithEyeIcon: boolean | EyeIconObject | undefined;\n};\n\nexport const [LaxFormRootProvider, useLaxFormRootContext] = createCustomContext<FormRootContext, false>({\n\thookName: \"useLaxFormRootContext\",\n\tname: \"LaxFormRootContext\",\n\tproviderName: \"FormRoot\",\n\tstrict: false,\n});\n\n// export const useStrictGetFieldState = () => {\n// \tconst { name } = useStrictFormFieldContext();\n\n// \tconst { getFieldState } = useFormRootContext();\n\n// \tconst fieldState = getFieldState(name);\n\n// \treturn fieldState;\n// };\n\nexport type FieldContextValue = {\n\tformDescriptionId: `${string}-(${string})-form-item-description`;\n\tformItemId: `${string}-(${string})-form-item`;\n\tformMessageId: `${string}-(${string})-form-item-message`;\n\tname: string;\n};\n\nexport type FormFieldContextProps = DiscriminatedRenderProps<\n\t(contextValue: FieldContextValue) => React.ReactNode\n>;\n\nexport const [StrictFormFieldProvider, useStrictFormFieldContext] = createCustomContext<FieldContextValue>(\n\t{\n\t\thookName: \"useFormFieldContext\",\n\t\tname: \"StrictFormFieldContext\",\n\t\tproviderName: \"FormField\",\n\t}\n);\n\nexport const [LaxFormFieldProvider, useLaxFormFieldContext] = createCustomContext<\n\tFieldContextValue,\n\tfalse\n>({\n\thookName: \"useLaxFormFieldContext\",\n\tname: \"LaxFormFieldContext\",\n\tproviderName: \"FormField\",\n\tstrict: false,\n});\n\nexport type FieldState = {\n\terrors?: UseFormStateReturn<FieldValues>[\"errors\"];\n\tisDisabled?: boolean;\n\tisInvalid?: boolean;\n};\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- any is used here for type compatibility\nexport type AnyControl = Control<any>;\n\ntype FieldStateOptions =\n\t| {\n\t\t\tcontrol: AnyControl | undefined;\n\t\t\tname?: string;\n\t }\n\t| {\n\t\t\tcontrol?: AnyControl;\n\t\t\tname: string | undefined;\n\t };\n\nexport const useLaxFormFieldState = (options?: FieldStateOptions): FieldState => {\n\tconst { control = options?.control } = useFormMethodsContext({ strict: false }) ?? {};\n\tconst { name = options?.name } = useLaxFormFieldContext() ?? {};\n\n\tconst getFormState = control ? useFormState : () => ({}) as Partial<ReturnType<typeof useFormState>>;\n\n\tconst { disabled, errors } = getFormState({ control, name });\n\n\tconst errorMessage = getFieldErrorMessage({ errors, fieldName: name, type: \"regular\" });\n\n\treturn {\n\t\terrors,\n\t\tisDisabled: disabled,\n\t\tisInvalid: Boolean(errorMessage),\n\t};\n};\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { getElementList } from \"@/components/common/for\";\nimport { Slot } from \"@/components/common/slot\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport { dataAttr } from \"@/lib/utils/common\";\nimport { getMultipleSlots } from \"@/lib/utils/getSlot\";\nimport { on, toArray } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useToggle } from \"@zayne-labs/toolkit-react\";\nimport {\n\ttype DiscriminatedRenderProps,\n\ttype InferProps,\n\ttype PolymorphicProps,\n\tcomposeRefs,\n\tcomposeTwoEventHandlers,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport { type AnyString, defineEnum } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, useEffect, useId, useMemo, useRef } from \"react\";\nimport {\n\ttype Control,\n\tController,\n\ttype ControllerFieldState,\n\ttype ControllerProps,\n\ttype ControllerRenderProps,\n\ttype FieldPath,\n\ttype FieldPathValue,\n\ttype FieldPathValues,\n\tFormProvider as HookFormProvider,\n\ttype RegisterOptions,\n\ttype UseFormReturn,\n\ttype UseFormStateReturn,\n\tuseFormState,\n\tuseWatch,\n} from \"react-hook-form\";\nimport {\n\ttype FieldContextValue,\n\ttype FieldState,\n\ttype FormFieldContextProps,\n\ttype FormRootContext,\n\tLaxFormFieldProvider,\n\tLaxFormRootProvider,\n\tStrictFormFieldProvider,\n\tuseFormMethodsContext,\n\tuseLaxFormFieldContext,\n\tuseLaxFormFieldState,\n\tuseLaxFormRootContext,\n\tuseStrictFormFieldContext,\n} from \"./form-context\";\nimport { getEyeIcon, getFieldErrorMessage } from \"./utils\";\n\nexport type FieldValues = Record<string, unknown>;\n\ntype FormRootProps<TFieldValues extends FieldValues> = Partial<FormRootContext>\n\t& React.ComponentPropsWithoutRef<\"form\"> & {\n\t\tchildren: React.ReactNode;\n\t\tmethods: UseFormReturn<TFieldValues>;\n\t};\n\nexport function FormRoot<TValues extends FieldValues>(props: FormRootProps<TValues>) {\n\tconst { children, className, methods, withEyeIcon, ...restOfProps } = props;\n\n\tconst formContextValue = useMemo(() => ({ withEyeIcon }), [withEyeIcon]);\n\n\treturn (\n\t\t<HookFormProvider {...methods}>\n\t\t\t<LaxFormRootProvider value={formContextValue}>\n\t\t\t\t<form\n\t\t\t\t\tclassName={cnMerge(\"flex flex-col\", className)}\n\t\t\t\t\t{...restOfProps}\n\t\t\t\t\tdata-scope=\"form\"\n\t\t\t\t\tdata-part=\"root\"\n\t\t\t\t\tdata-slot=\"form-root\"\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</form>\n\t\t\t</LaxFormRootProvider>\n\t\t</HookFormProvider>\n\t);\n}\n\ntype FormFieldProps<TControl, TFieldValues extends FieldValues> = (TControl extends Control<infer TValues>\n\t? {\n\t\t\tcontrol?: never;\n\t\t\tname: FieldPath<TValues>;\n\t\t}\n\t: {\n\t\t\tcontrol?: Control<TFieldValues>;\n\t\t\tname: FieldPath<TFieldValues>;\n\t\t})\n\t& (\n\t\t| (InferProps<\"div\"> & {\n\t\t\t\twithWrapper?: true;\n\t\t })\n\t\t| { children: React.ReactNode; className?: never; withWrapper: false }\n\t);\n\nexport function FormField<TControl, TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormFieldProps<TControl, TFieldValues>\n) {\n\tconst { children, className, name, withWrapper = true } = props;\n\n\tconst { isDisabled, isInvalid } = useLaxFormFieldState({ name });\n\n\tconst uniqueId = useId();\n\n\tconst fieldContextValue = useMemo(\n\t\t() =>\n\t\t\t({\n\t\t\t\tformDescriptionId: `${name}-(${uniqueId})-form-item-description`,\n\t\t\t\tformItemId: `${name}-(${uniqueId})-form-item`,\n\t\t\t\tformMessageId: `${name}-(${uniqueId})-form-item-message`,\n\t\t\t\tname,\n\t\t\t}) satisfies FieldContextValue,\n\t\t[name, uniqueId]\n\t);\n\n\tconst WrapperElement = withWrapper ? \"div\" : ReactFragment;\n\n\tconst wrapperElementProps = withWrapper && {\n\t\tclassName: cnMerge(\"flex flex-col\", className),\n\t\t\"data-part\": \"field\",\n\t\t\"data-scope\": \"form\",\n\t\t\"data-slot\": \"form-field\",\n\t\t/* eslint-disable perfectionist/sort-objects -- order of attributes does not matter */\n\t\t\"data-disabled\": dataAttr(isDisabled),\n\t\t\"data-invalid\": dataAttr(isInvalid),\n\t\t/* eslint-enable perfectionist/sort-objects -- order of attributes does not matter */\n\t};\n\treturn (\n\t\t<StrictFormFieldProvider value={fieldContextValue}>\n\t\t\t<LaxFormFieldProvider value={fieldContextValue}>\n\t\t\t\t<WrapperElement {...wrapperElementProps}>{children}</WrapperElement>\n\t\t\t</LaxFormFieldProvider>\n\t\t</StrictFormFieldProvider>\n\t);\n}\n\ntype FormFieldControllerRenderFn = (props: {\n\tfield: Omit<ControllerRenderProps, \"value\"> & {\n\t\tvalue: never;\n\t};\n\tfieldState: ControllerFieldState;\n\tformState: UseFormStateReturn<never>;\n}) => React.ReactElement;\n\ntype FormFieldControllerProps = Omit<\n\tControllerProps<FieldValues, FieldPath<FieldValues>>,\n\t\"control\" | \"name\" | \"render\"\n> & {\n\trender: FormFieldControllerRenderFn;\n};\n\nexport function FormFieldController(props: FormFieldControllerProps) {\n\tconst { control } = useFormMethodsContext();\n\tconst { name } = useStrictFormFieldContext();\n\tconst { render, ...restOfProps } = props;\n\n\treturn <Controller name={name} control={control} render={render as never} {...restOfProps} />;\n}\n\nexport function FormFieldControlledField<TFieldValues extends FieldValues>(\n\tprops: ControllerProps<TFieldValues>\n) {\n\tconst { name } = props;\n\n\tconst uniqueId = useId();\n\n\tconst fieldContextValue = useMemo(\n\t\t() =>\n\t\t\t({\n\t\t\t\tformDescriptionId: `${name}-(${uniqueId})-form-item-description`,\n\t\t\t\tformItemId: `${name}-(${uniqueId})-form-item`,\n\t\t\t\tformMessageId: `${name}-(${uniqueId})-form-item-message`,\n\t\t\t\tname,\n\t\t\t}) satisfies FieldContextValue,\n\t\t[name, uniqueId]\n\t);\n\n\treturn (\n\t\t<StrictFormFieldProvider value={fieldContextValue}>\n\t\t\t<LaxFormFieldProvider value={fieldContextValue}>\n\t\t\t\t<Controller {...props} />\n\t\t\t</LaxFormFieldProvider>\n\t\t</StrictFormFieldProvider>\n\t);\n}\n\nexport function FormFieldContext(props: FormFieldContextProps) {\n\tconst { children, render } = props;\n\tconst fieldContextValues = useStrictFormFieldContext();\n\n\tif (typeof children === \"function\") {\n\t\treturn children(fieldContextValues);\n\t}\n\n\treturn render(fieldContextValues);\n}\n\nexport function FormLabel(props: InferProps<\"label\">) {\n\tconst { formItemId, name } = useStrictFormFieldContext();\n\tconst { children, className, ...restOfProps } = props;\n\n\tconst { isDisabled, isInvalid } = useLaxFormFieldState({ name });\n\n\treturn (\n\t\t<label\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"label\"\n\t\t\tdata-slot=\"form-label\"\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\thtmlFor={formItemId}\n\t\t\tclassName={className}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</label>\n\t);\n}\n\nexport function FormInputGroup(props: InferProps<\"div\">) {\n\tconst { children, className, ...restOfProps } = props;\n\n\tconst { isDisabled, isInvalid } = useLaxFormFieldState();\n\n\tconst {\n\t\tregularChildren,\n\t\tslots: [leftItemSlot, rightItemSlot],\n\t} = getMultipleSlots(children, [FormInputLeftItem, FormInputRightItem]);\n\n\treturn (\n\t\t<div\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"input-group\"\n\t\t\tdata-slot=\"form-input-group\"\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tclassName={cnMerge(\"flex items-center justify-between gap-2\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{leftItemSlot}\n\t\t\t{regularChildren}\n\t\t\t{rightItemSlot}\n\t\t</div>\n\t);\n}\n\ntype FormSideItemProps = {\n\tchildren?: React.ReactNode;\n\tclassName?: string;\n};\n\nexport function FormInputLeftItem<TElement extends React.ElementType = \"span\">(\n\tprops: PolymorphicProps<TElement, FormSideItemProps>\n) {\n\tconst { as: Element = \"span\", children, className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"left-item\"\n\t\t\tdata-slot=\"form-left-item\"\n\t\t\tclassName={cnMerge(\"inline-flex items-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</Element>\n\t);\n}\nFormInputLeftItem.slotSymbol = Symbol(\"input-left-item\");\n\nexport function FormInputRightItem<TElement extends React.ElementType = \"span\">(\n\tprops: PolymorphicProps<TElement, FormSideItemProps>\n) {\n\tconst { as: Element = \"span\", children, className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"right-item\"\n\t\t\tdata-slot=\"form-right-item\"\n\t\t\tclassName={cnMerge(\"inline-flex items-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</Element>\n\t);\n}\nFormInputRightItem.slotSymbol = Symbol(\"input-right-item\");\n\ntype FormInputPrimitiveProps<TFieldValues extends FieldValues = FieldValues> = Omit<\n\tReact.ComponentPropsWithRef<\"input\">,\n\t\"children\"\n> & {\n\tclassNames?: { error?: string; eyeIcon?: string; input?: string; inputGroup?: string };\n\tcontrol?: Control<TFieldValues>;\n\tfieldState?: FieldState;\n\tname?: FieldPath<TFieldValues>;\n\twithEyeIcon?: FormRootContext[\"withEyeIcon\"];\n};\n\ntype FormTextAreaPrimitiveProps<TFieldValues extends FieldValues = FieldValues> =\n\tReact.ComponentPropsWithRef<\"textarea\"> & {\n\t\tclassNames?: { base?: string; error?: string };\n\t\tcontrol?: Control<TFieldValues>;\n\t\tfieldState?: FieldState;\n\t\tname?: FieldPath<TFieldValues>;\n\t};\n\ntype FormSelectPrimitiveProps<TFieldValues extends FieldValues = FieldValues> =\n\tReact.ComponentPropsWithRef<\"select\"> & {\n\t\tclassNames?: { base?: string; error?: string };\n\t\tcontrol?: Control<TFieldValues>;\n\t\tfieldState?: FieldState;\n\t\tname?: FieldPath<TFieldValues>;\n\t};\n\nconst inputTypesWithoutFullWith = new Set<React.HTMLInputTypeAttribute>([\"checkbox\", \"radio\"]);\n\nexport function FormInputPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormInputPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst formRootContextValues = useLaxFormRootContext();\n\n\tconst {\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\tfieldState,\n\t\tid = fieldContextValues?.formItemId,\n\t\tname = fieldContextValues?.name,\n\t\trules,\n\t\ttype = \"text\",\n\t\twithEyeIcon = formRootContextValues?.withEyeIcon ?? true,\n\t\t...restOfProps\n\t} = props;\n\n\tconst fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });\n\n\tconst { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;\n\n\tconst [isPasswordVisible, toggleVisibility] = useToggle(false);\n\n\tconst shouldHaveEyeIcon = withEyeIcon && type === \"password\";\n\n\tconst WrapperElement = shouldHaveEyeIcon ? FormInputGroup : ReactFragment;\n\n\tconst wrapperElementProps = shouldHaveEyeIcon && {\n\t\tclassName: cnMerge(\"w-full\", classNames?.inputGroup, isInvalid && classNames?.error),\n\t};\n\n\tconst { register } = useFormMethodsContext({ strict: false }) ?? {};\n\n\tconst eyeIcon = getEyeIcon({\n\t\tclassNames,\n\t\ticonType: isPasswordVisible ? \"closed\" : \"open\",\n\t\trenderIconProps: { isPasswordVisible },\n\t\twithEyeIcon,\n\t});\n\n\treturn (\n\t\t<WrapperElement {...wrapperElementProps}>\n\t\t\t<input\n\t\t\t\tdata-scope=\"form\"\n\t\t\t\tdata-part=\"input\"\n\t\t\t\tdata-slot=\"form-input\"\n\t\t\t\taria-describedby={\n\t\t\t\t\t!isInvalid\n\t\t\t\t\t\t? fieldContextValues?.formDescriptionId\n\t\t\t\t\t\t: `${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`\n\t\t\t\t}\n\t\t\t\taria-invalid={dataAttr(isInvalid)}\n\t\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\t\tid={id}\n\t\t\t\tname={name}\n\t\t\t\ttype={type === \"password\" && isPasswordVisible ? \"text\" : type}\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t!inputTypesWithoutFullWith.has(type) && \"flex w-full\",\n\t\t\t\t\t`focus-visible:outline-hidden placeholder:text-shadcn-muted-foreground bg-transparent\n\t\t\t\t\ttext-sm file:border-0 file:bg-transparent disabled:cursor-not-allowed disabled:opacity-50`,\n\t\t\t\t\tclassName,\n\t\t\t\t\tclassNames?.input,\n\t\t\t\t\ttype !== \"password\" && isInvalid && classNames?.error\n\t\t\t\t)}\n\t\t\t\t{...(Boolean(name) && register?.(name, rules))}\n\t\t\t\t{...restOfProps}\n\t\t\t/>\n\n\t\t\t{shouldHaveEyeIcon && (\n\t\t\t\t<FormInputRightItem\n\t\t\t\t\tas=\"button\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={toggleVisibility}\n\t\t\t\t\tclassName=\"size-5 shrink-0 lg:size-6\"\n\t\t\t\t>\n\t\t\t\t\t{eyeIcon}\n\t\t\t\t</FormInputRightItem>\n\t\t\t)}\n\t\t</WrapperElement>\n\t);\n}\n\nexport function FormTextAreaPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormTextAreaPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst {\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\tfieldState,\n\t\tid = fieldContextValues?.formItemId,\n\t\tname = fieldContextValues?.name,\n\t\trules,\n\t\t...restOfProps\n\t} = props;\n\n\tconst fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });\n\n\tconst { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;\n\n\tconst { register } = useFormMethodsContext({ strict: false }) ?? {};\n\n\treturn (\n\t\t<textarea\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"textarea\"\n\t\t\tdata-slot=\"form-textarea\"\n\t\t\taria-describedby={\n\t\t\t\t!isInvalid\n\t\t\t\t\t? fieldContextValues?.formDescriptionId\n\t\t\t\t\t: `${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`\n\t\t\t}\n\t\t\taria-invalid={dataAttr(isInvalid)}\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\tid={id}\n\t\t\tname={name}\n\t\t\tclassName={cnMerge(\n\t\t\t\t`placeholder:text-shadcn-muted-foreground focus-visible:outline-hidden w-full bg-transparent\n\t\t\t\ttext-sm disabled:cursor-not-allowed disabled:opacity-50`,\n\t\t\t\tclassName,\n\t\t\t\tclassNames?.base,\n\t\t\t\tisInvalid && classNames?.error\n\t\t\t)}\n\t\t\t{...(Boolean(name) && register?.(name, rules))}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\nexport function FormSelectPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormSelectPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst {\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\tfieldState,\n\t\tid = fieldContextValues?.formItemId,\n\t\tname = fieldContextValues?.name,\n\t\trules,\n\t\t...restOfProps\n\t} = props;\n\n\tconst fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });\n\n\tconst { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;\n\n\tconst { register } = useFormMethodsContext({ strict: false }) ?? {};\n\n\treturn (\n\t\t<select\n\t\t\tdefaultValue=\"\"\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"select\"\n\t\t\tdata-slot=\"form-select\"\n\t\t\taria-describedby={\n\t\t\t\t!isInvalid\n\t\t\t\t\t? fieldContextValues?.formDescriptionId\n\t\t\t\t\t: `${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`\n\t\t\t}\n\t\t\taria-invalid={dataAttr(isInvalid)}\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\tid={id}\n\t\t\tname={name}\n\t\t\tclassName={cnMerge(\n\t\t\t\t`placeholder:text-shadcn-muted-foreground focus-visible:outline-hidden w-full bg-transparent\n\t\t\t\ttext-sm disabled:cursor-not-allowed disabled:opacity-50`,\n\t\t\t\tclassName,\n\t\t\t\tclassNames?.base,\n\t\t\t\tisInvalid && classNames?.error\n\t\t\t)}\n\t\t\t{...(Boolean(name) && register?.(name, rules))}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\ntype PrimitivePropsToOmit = \"control\" | \"formState\" | \"name\";\n\nexport type FormInputProps = Omit<FormInputPrimitiveProps, PrimitivePropsToOmit> & {\n\trules?: RegisterOptions;\n};\n\nexport type FormTextAreaProps = Omit<FormTextAreaPrimitiveProps, PrimitivePropsToOmit> & {\n\trules?: RegisterOptions;\n};\n\nexport type FormSelectProps = Omit<FormSelectPrimitiveProps, PrimitivePropsToOmit> & {\n\trules?: RegisterOptions;\n};\n\ntype CombinedFormInputProps =\n\t| (FormSelectProps & { type: \"select\" })\n\t| (FormTextAreaProps & { type: \"textarea\" })\n\t| FormInputProps;\n\nconst InputTypeMap = defineEnum({\n\tselect: FormSelectPrimitive,\n\ttextarea: FormTextAreaPrimitive,\n});\n\nexport function FormInput(props: CombinedFormInputProps & { rules?: RegisterOptions }) {\n\tconst { onBlur, onChange, ref, rules, type, ...restOfProps } = props;\n\n\tconst { name } = useStrictFormFieldContext();\n\tconst { register } = useFormMethodsContext();\n\n\tconst SelectedInput =\n\t\ttype === \"textarea\" || type === \"select\"\n\t\t\t? InputTypeMap[type as Exclude<typeof type, AnyString>]\n\t\t\t: FormInputPrimitive;\n\n\tconst registerProps = name ? register(name, rules) : null;\n\n\treturn (\n\t\t<SelectedInput\n\t\t\ttype={type as never}\n\t\t\tname={name}\n\t\t\t{...registerProps}\n\t\t\t{...(restOfProps as NonNullable<unknown>)}\n\t\t\tref={composeRefs(registerProps?.ref, ref)}\n\t\t\tonChange={composeTwoEventHandlers(registerProps?.onChange, onChange)}\n\t\t\tonBlur={composeTwoEventHandlers(registerProps?.onBlur, onBlur)}\n\t\t/>\n\t);\n}\n\nexport function FormTextArea(props: FormTextAreaProps) {\n\treturn <FormInput {...props} type=\"textarea\" />;\n}\n\nexport function FormSelect(props: FormSelectProps) {\n\treturn <FormInput {...props} type=\"select\" />;\n}\n\nexport function FormDescription(props: InferProps<\"p\">) {\n\tconst { className, ...restOfProps } = props;\n\n\tconst { formDescriptionId } = useLaxFormFieldContext() ?? {};\n\n\treturn <p id={formDescriptionId} className={cnMerge(\"text-[12px]\", className)} {...restOfProps} />;\n}\n\ntype ErrorMessageRenderProps = {\n\tclassName: string;\n\t\"data-index\": number;\n\t\"data-part\": \"error-message\";\n\t\"data-scope\": \"form\";\n\t\"data-slot\": \"form-error-message\";\n\tid: string | undefined;\n\tref: React.RefCallback<HTMLElement>;\n};\n\ntype ErrorMessageRenderState = { errorMessage: string; errorMessageArray: string[]; index: number };\n\ntype ErrorMessageRenderFn = (context: {\n\tprops: ErrorMessageRenderProps;\n\tstate: ErrorMessageRenderState;\n}) => React.ReactNode;\n\nexport type FormErrorMessagePrimitiveProps<TFieldValues extends FieldValues> =\n\tDiscriminatedRenderProps<ErrorMessageRenderFn> & {\n\t\tclassName?: string;\n\t\tclassNames?: {\n\t\t\tcontainer?: string;\n\t\t\terrorMessage?: string;\n\t\t\terrorMessageAnimation?: string;\n\t\t};\n\t\tcontrol?: Control<TFieldValues>; // == Here for type inference of errorField prop\n\t\tdisableErrorAnimation?: boolean;\n\t\tdisableScrollToErrorField?: boolean;\n\t} & (\n\t\t\t| {\n\t\t\t\t\tfieldName: FieldPath<TFieldValues>;\n\t\t\t\t\ttype?: \"regular\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tfieldName: string;\n\t\t\t\t\ttype: \"root\";\n\t\t\t }\n\t\t);\n\ntype FormErrorMessagePrimitiveType = {\n\t<TFieldValues extends FieldValues>(\n\t\tprops: Extract<FormErrorMessagePrimitiveProps<TFieldValues>, { type?: \"regular\" }>\n\t): React.ReactNode;\n\t<TFieldValues extends FieldValues>(\n\t\t// eslint-disable-next-line ts-eslint/unified-signatures -- Using overloads are better because it gives better error messages\n\t\tprops: Extract<FormErrorMessagePrimitiveProps<TFieldValues>, { type: \"root\" }>\n\t): React.ReactNode;\n};\n\nexport const FormErrorMessagePrimitive: FormErrorMessagePrimitiveType = (props) => {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\tconst rootContextValues = useFormMethodsContext({ strict: false });\n\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol = rootContextValues?.control,\n\t\tdisableErrorAnimation = false,\n\t\tdisableScrollToErrorField = false,\n\t\tfieldName = fieldContextValues?.name,\n\t\trender,\n\t\ttype = \"regular\",\n\t} = props;\n\n\tconst { errors } = useLaxFormFieldState({ control, name: fieldName });\n\n\tconst { formMessageId } = useLaxFormFieldContext() ?? {};\n\n\tconst errorParagraphRef = useRef<HTMLElement>(null);\n\n\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\tconst errorAnimationClass = classNames?.errorMessageAnimation ?? \"animate-shake\";\n\n\tconst getErrorElements = useCallbackRef(\n\t\t() => wrapperRef.current?.children ?? [errorParagraphRef.current]\n\t);\n\n\tuseEffect(() => {\n\t\tif (disableErrorAnimation) return;\n\n\t\tif (!errors || Object.keys(errors).length === 0) return;\n\n\t\tconst errorMessageElements = getErrorElements();\n\n\t\tif (errorMessageElements.length === 0) return;\n\n\t\tfor (const element of errorMessageElements) {\n\t\t\tif (!element) continue;\n\n\t\t\telement.classList.add(errorAnimationClass);\n\n\t\t\tconst onAnimationEnd = () => element.classList.remove(errorAnimationClass);\n\n\t\t\ton(\"animationend\", element, onAnimationEnd, { once: true });\n\t\t}\n\t}, [disableErrorAnimation, errorAnimationClass, errors, getErrorElements]);\n\n\tuseEffect(() => {\n\t\tif (disableScrollToErrorField) return;\n\n\t\tif (!errors || Object.keys(errors).length === 0) return;\n\n\t\tconst errorMessageElements = getErrorElements();\n\n\t\tconst firstErrorElement = errorMessageElements[0];\n\n\t\tif (!firstErrorElement) return;\n\n\t\t// == Find the input field associated with this error\n\t\tconst inputField = document.querySelector(`[name='${fieldName}']`);\n\t\tconst isFocusableInput = inputField?.matches(\n\t\t\t\":is(input, select, textarea, [contenteditable='true'])\"\n\t\t);\n\n\t\t// == Return early if the input field is focusable (Only scrollIntoView for non-focusable fields)\n\t\tif (isFocusableInput) return;\n\n\t\t// == Schedule the scroll to next frame to ensure DOM is ready\n\t\trequestAnimationFrame(() => {\n\t\t\t// == Get the element's position and scroll in one frame\n\t\t\tconst rect = firstErrorElement.getBoundingClientRect();\n\t\t\tconst topWithOffset = rect.top - 100;\n\n\t\t\twindow.scrollTo({\n\t\t\t\tbehavior: \"smooth\",\n\t\t\t\ttop: window.scrollY + topWithOffset,\n\t\t\t});\n\t\t});\n\t}, [disableScrollToErrorField, fieldName, errors, getErrorElements]);\n\n\tconst fieldErrorMessage = getFieldErrorMessage({ errors, fieldName, type });\n\n\tif (!fieldErrorMessage) {\n\t\treturn null;\n\t}\n\n\tconst errorMessageArray = toArray(fieldErrorMessage);\n\n\tif (errorMessageArray.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst getRenderProps = (options: { index: number }): ErrorMessageRenderProps => {\n\t\tconst { index } = options;\n\n\t\treturn {\n\t\t\tclassName: cnMerge(className, classNames?.errorMessage),\n\t\t\t\"data-index\": index,\n\t\t\t\"data-part\": \"error-message\",\n\t\t\t\"data-scope\": \"form\",\n\t\t\t\"data-slot\": \"form-error-message\",\n\t\t\tid: formMessageId,\n\t\t\tref: (node) => {\n\t\t\t\tif (!node || errorParagraphRef.current) return;\n\n\t\t\t\terrorParagraphRef.current = node;\n\t\t\t},\n\t\t};\n\t};\n\n\tconst getRenderState = (options: { errorMessage: string; index: number }): ErrorMessageRenderState => {\n\t\tconst { errorMessage, index } = options;\n\n\t\treturn {\n\t\t\terrorMessage,\n\t\t\terrorMessageArray,\n\t\t\tindex,\n\t\t};\n\t};\n\n\tconst [ErrorMessageList] = getElementList(\"base\");\n\n\tconst WrapperComponent = \"div\";\n\n\tconst wrapperComponentProps = errorMessageArray.length > 1 && {\n\t\tclassName: cnMerge(\"flex flex-col\", classNames?.container),\n\t\t\"data-part\": \"error-message-container\",\n\t\t\"data-scope\": \"form\",\n\t\t\"data-slot\": \"form-error-message-container\",\n\t\tref: wrapperRef,\n\t};\n\n\tconst selectedChildren = typeof children === \"function\" ? children : render;\n\n\treturn (\n\t\t<WrapperComponent {...wrapperComponentProps}>\n\t\t\t<ErrorMessageList\n\t\t\t\teach={errorMessageArray}\n\t\t\t\trender={(errorMessage, index) => {\n\t\t\t\t\treturn selectedChildren({\n\t\t\t\t\t\tprops: getRenderProps({ index }),\n\t\t\t\t\t\tstate: getRenderState({ errorMessage, index }),\n\t\t\t\t\t});\n\t\t\t\t}}\n\t\t\t/>\n\t\t</WrapperComponent>\n\t);\n};\n\ntype FormErrorMessageProps<TControl, TFieldValues extends FieldValues> =\n\t| (TControl extends Control<infer TValues>\n\t\t\t? {\n\t\t\t\t\tclassName?: string;\n\t\t\t\t\tcontrol?: never;\n\t\t\t\t\terrorField?: FieldPath<TValues>;\n\t\t\t\t\ttype?: \"regular\";\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tclassName?: string;\n\t\t\t\t\tcontrol?: Control<TFieldValues>; // == Here for type inference of errorField prop\n\t\t\t\t\terrorField?: FieldPath<TFieldValues>;\n\t\t\t\t\ttype?: \"regular\";\n\t\t\t\t})\n\t| {\n\t\t\tclassName?: string;\n\t\t\tcontrol?: never;\n\t\t\terrorField: string;\n\t\t\ttype: \"root\";\n\t };\n\nexport function FormErrorMessage<TControl, TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormErrorMessageProps<TControl, TFieldValues>\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst { className, errorField = fieldContextValues?.name, type = \"regular\" } = props;\n\n\tconst { control } = useFormMethodsContext();\n\n\treturn (\n\t\t<FormErrorMessagePrimitive\n\t\t\tcontrol={control}\n\t\t\tfieldName={errorField as NonNullable<typeof errorField>}\n\t\t\ttype={type as \"root\"}\n\t\t\trender={({ props: renderProps, state }) => (\n\t\t\t\t<p\n\t\t\t\t\tkey={state.errorMessage}\n\t\t\t\t\t{...renderProps}\n\t\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\t\"text-[13px] text-red-600\",\n\t\t\t\t\t\t\"data-[index=0]:mt-1\",\n\t\t\t\t\t\trenderProps.className,\n\t\t\t\t\t\tclassName\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t{state.errorMessage}\n\t\t\t\t</p>\n\t\t\t)}\n\t\t/>\n\t);\n}\n\ntype FormSubmitProps = InferProps<\"button\"> & { asChild?: boolean };\n\nexport function FormSubmit<TElement extends React.ElementType = \"button\">(\n\tprops: PolymorphicProps<TElement, FormSubmitProps>\n) {\n\tconst { as: Element = \"button\", asChild, children, type = \"submit\", ...restOfProps } = props;\n\n\tconst Component = asChild ? Slot : Element;\n\n\treturn (\n\t\t<Component data-part=\"submit\" data-scope=\"form\" data-slot=\"form-submit\" type={type} {...restOfProps}>\n\t\t\t{children}\n\t\t</Component>\n\t);\n}\n\ntype GetFieldValue<TFieldPathOrPaths, TFieldValues extends FieldValues> =\n\tTFieldPathOrPaths extends Array<FieldPath<TFieldValues>>\n\t\t? FieldPathValues<TFieldValues, TFieldPathOrPaths>\n\t\t: TFieldPathOrPaths extends FieldPath<TFieldValues>\n\t\t\t? FieldPathValue<TFieldValues, TFieldPathOrPaths>\n\t\t\t: unknown;\n\ntype FormSubscribeToFieldValueRenderFn<TFieldValues extends FieldValues, TFieldPathOrPaths> = (props: {\n\tvalue: GetFieldValue<TFieldPathOrPaths, TFieldValues>;\n}) => React.ReactNode;\n\ntype FormSubscribeToFieldValueProps<\n\tTFieldValues extends FieldValues,\n\tTFieldPathOrPaths,\n> = DiscriminatedRenderProps<FormSubscribeToFieldValueRenderFn<TFieldValues, TFieldPathOrPaths>> & {\n\tcontrol: Control<TFieldValues>;\n\tname?: TFieldPathOrPaths;\n};\n\nexport function FormSubscribeToFieldValue<\n\tTFieldValues extends FieldValues,\n\tconst TFieldPathOrPaths extends Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues>,\n>(props: FormSubscribeToFieldValueProps<TFieldValues, TFieldPathOrPaths>) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst { children, name = fieldContextValues?.name, render } = props;\n\n\tconst { control } = useFormMethodsContext();\n\n\tconst formValue = useWatch({ control, name: name as string });\n\n\tconst fieldProps = { value: formValue };\n\n\tconst selectedChildren = typeof children === \"function\" ? children : render;\n\n\tconst resolvedChildren = selectedChildren(fieldProps as never);\n\n\treturn resolvedChildren;\n}\n\ntype FormSubscribeToFormStateRenderFn<TFieldValues extends FieldValues> = (\n\tprops: UseFormStateReturn<TFieldValues>\n) => React.ReactNode;\n\ntype FormSubscribeToFormStateProps<TFieldValues extends FieldValues> = DiscriminatedRenderProps<\n\tFormSubscribeToFormStateRenderFn<TFieldValues>\n> & {\n\tcontrol?: Control<TFieldValues>;\n\tname?: Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues>;\n};\n\nexport function FormSubscribeToFormState<TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormSubscribeToFormStateProps<TFieldValues>\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst { children, control, name = fieldContextValues?.name, render } = props;\n\n\tconst formState = useFormState({ control, name: name as FieldPath<TFieldValues> });\n\n\tconst selectedChildren = typeof children === \"function\" ? children : render;\n\n\tconst resolvedChildren = selectedChildren(formState as never);\n\n\treturn resolvedChildren;\n}\n","export {\n\tFormDescription as Description,\n\tFormErrorMessage as ErrorMessage,\n\tFormErrorMessagePrimitive as ErrorMessagePrimitive,\n\tFormField as Field,\n\tFormFieldContext as FieldContext,\n\tFormFieldController as FieldController,\n\tFormFieldControlledField as ControlledField,\n\tFormInput as Input,\n\tFormInputGroup as InputGroup,\n\tFormInputLeftItem as InputLeftItem,\n\tFormInputPrimitive as InputPrimitive,\n\tFormInputRightItem as InputRightItem,\n\tFormLabel as Label,\n\tFormRoot as Root,\n\tFormSelect as Select,\n\tFormSubmit as Submit,\n\tFormSubscribeToFieldValue as SubscribeToFieldValue,\n\tFormSubscribeToFormState as SubscribeToFormState,\n\tFormTextArea as TextArea,\n\tFormTextAreaPrimitive as TextAreaPrimitive,\n} from \"./form\";\n"]}