@dinofront/design_system 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DatePicker/DatePicker.types.d.ts +12 -0
- package/dist/components/FormField/FormField.types.d.ts +8 -1
- package/dist/components/Radio/Radio.types.d.ts +1 -0
- package/dist/components/Select/Select.types.d.ts +17 -0
- package/dist/components/Upload/Upload.types.d.ts +5 -1
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/useEscapeKey.d.ts +4 -0
- package/dist/hooks/useFormContext.d.ts +6 -0
- package/dist/hooks/useFormProps.d.ts +9 -0
- package/dist/hooks/useHideBodyScroll.d.ts +6 -0
- package/dist/hooks/useIsMobile.d.ts +9 -0
- package/dist/hooks/useOnOutsideClick.d.ts +6 -0
- package/dist/index.js +2138 -1774
- package/dist/index.js.map +1 -1
- package/dist/styles.css +20 -0
- package/package.json +1 -5
- package/dist/FormField-CwRAOtTN.js +0 -170
- package/dist/FormField-CwRAOtTN.js.map +0 -1
- package/dist/form/index.d.ts +0 -2
- package/dist/form.d.ts +0 -2
- package/dist/form.js +0 -2
package/dist/styles.css
CHANGED
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
--font-weight-medium: 500;
|
|
84
84
|
--font-weight-semibold: 600;
|
|
85
85
|
--font-weight-bold: 700;
|
|
86
|
+
--tracking-wide: 0.025em;
|
|
86
87
|
--tracking-wider: 0.05em;
|
|
87
88
|
--tracking-widest: 0.1em;
|
|
88
89
|
--leading-tight: 1.25;
|
|
@@ -443,6 +444,9 @@
|
|
|
443
444
|
.isolate {
|
|
444
445
|
isolation: isolate;
|
|
445
446
|
}
|
|
447
|
+
.z-1 {
|
|
448
|
+
z-index: 1;
|
|
449
|
+
}
|
|
446
450
|
.z-10 {
|
|
447
451
|
z-index: 10;
|
|
448
452
|
}
|
|
@@ -1061,6 +1065,9 @@
|
|
|
1061
1065
|
.cursor-text {
|
|
1062
1066
|
cursor: text;
|
|
1063
1067
|
}
|
|
1068
|
+
.cursor-wait {
|
|
1069
|
+
cursor: wait;
|
|
1070
|
+
}
|
|
1064
1071
|
.resize {
|
|
1065
1072
|
resize: both;
|
|
1066
1073
|
}
|
|
@@ -1675,6 +1682,9 @@
|
|
|
1675
1682
|
.py-20 {
|
|
1676
1683
|
padding-block: calc(var(--spacing) * 20);
|
|
1677
1684
|
}
|
|
1685
|
+
.pt-2 {
|
|
1686
|
+
padding-top: calc(var(--spacing) * 2);
|
|
1687
|
+
}
|
|
1678
1688
|
.pt-6 {
|
|
1679
1689
|
padding-top: calc(var(--spacing) * 6);
|
|
1680
1690
|
}
|
|
@@ -1699,6 +1709,9 @@
|
|
|
1699
1709
|
.pr-10 {
|
|
1700
1710
|
padding-right: calc(var(--spacing) * 10);
|
|
1701
1711
|
}
|
|
1712
|
+
.pb-1 {
|
|
1713
|
+
padding-bottom: var(--spacing);
|
|
1714
|
+
}
|
|
1702
1715
|
.pb-4 {
|
|
1703
1716
|
padding-bottom: calc(var(--spacing) * 4);
|
|
1704
1717
|
}
|
|
@@ -1847,6 +1860,10 @@
|
|
|
1847
1860
|
--tw-font-weight: var(--font-weight-semibold);
|
|
1848
1861
|
font-weight: var(--font-weight-semibold);
|
|
1849
1862
|
}
|
|
1863
|
+
.tracking-wide {
|
|
1864
|
+
--tw-tracking: var(--tracking-wide);
|
|
1865
|
+
letter-spacing: var(--tracking-wide);
|
|
1866
|
+
}
|
|
1850
1867
|
.tracking-wider {
|
|
1851
1868
|
--tw-tracking: var(--tracking-wider);
|
|
1852
1869
|
letter-spacing: var(--tracking-wider);
|
|
@@ -2222,6 +2239,9 @@
|
|
|
2222
2239
|
.peer-checked\:bg-brand-500:is(:where(.peer):checked ~ *) {
|
|
2223
2240
|
background-color: var(--color-brand-500);
|
|
2224
2241
|
}
|
|
2242
|
+
.peer-checked\:bg-gray-600:is(:where(.peer):checked ~ *) {
|
|
2243
|
+
background-color: var(--color-gray-600);
|
|
2244
|
+
}
|
|
2225
2245
|
.peer-checked\:bg-gray-700:is(:where(.peer):checked ~ *) {
|
|
2226
2246
|
background-color: var(--color-gray-700);
|
|
2227
2247
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dinofront/design_system",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Enterprise React component library and design system built on Tailwind CSS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
"types": "./dist/icons.d.ts",
|
|
24
24
|
"import": "./dist/icons.js"
|
|
25
25
|
},
|
|
26
|
-
"./form": {
|
|
27
|
-
"types": "./dist/form.d.ts",
|
|
28
|
-
"import": "./dist/form.js"
|
|
29
|
-
},
|
|
30
26
|
"./preset": {
|
|
31
27
|
"types": "./dist/tailwind/preset.d.ts",
|
|
32
28
|
"import": "./dist/tailwind/preset.js"
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { createContext as e, forwardRef as t, useContext as n } from "react";
|
|
2
|
-
import { Loader2 as r } from "lucide-react";
|
|
3
|
-
import { clsx as i } from "clsx";
|
|
4
|
-
import { extendTailwindMerge as a } from "tailwind-merge";
|
|
5
|
-
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
-
import { Controller as l, useForm as u } from "react-hook-form";
|
|
7
|
-
import { yupResolver as d } from "@hookform/resolvers/yup";
|
|
8
|
-
//#region src/lib/cn.ts
|
|
9
|
-
var f = a({ extend: { theme: { text: [
|
|
10
|
-
"h-xl",
|
|
11
|
-
"h-lg",
|
|
12
|
-
"h-md",
|
|
13
|
-
"h-std",
|
|
14
|
-
"h-sm",
|
|
15
|
-
"h-xs",
|
|
16
|
-
"p-lg",
|
|
17
|
-
"p-md",
|
|
18
|
-
"p-std",
|
|
19
|
-
"p-sm",
|
|
20
|
-
"p-xs",
|
|
21
|
-
"label-lg",
|
|
22
|
-
"label-md",
|
|
23
|
-
"label-std",
|
|
24
|
-
"label-sm",
|
|
25
|
-
"label-xs",
|
|
26
|
-
"label-xxs"
|
|
27
|
-
] } } });
|
|
28
|
-
function p(...e) {
|
|
29
|
-
return f(i(e));
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/components/Button/Button.tsx
|
|
33
|
-
var m = {
|
|
34
|
-
lg: "h-12 px-5 text-p-md gap-2 rounded-lg",
|
|
35
|
-
md: "h-10 px-4 text-p-std gap-2 rounded-lg",
|
|
36
|
-
sm: "h-8 px-3 text-p-sm gap-1.5 rounded-md"
|
|
37
|
-
}, h = {
|
|
38
|
-
lg: "h-12 w-12 rounded-lg",
|
|
39
|
-
md: "h-10 w-10 rounded-lg",
|
|
40
|
-
sm: "h-8 w-8 rounded-md"
|
|
41
|
-
}, g = {
|
|
42
|
-
primary: [
|
|
43
|
-
"bg-brand-500 text-white border border-transparent",
|
|
44
|
-
"hover:bg-brand-600 active:bg-brand-700",
|
|
45
|
-
"disabled:bg-bg-subtle disabled:text-fg-disabled disabled:cursor-not-allowed",
|
|
46
|
-
"focus-visible:ring-2 focus-visible:ring-brand-300 focus-visible:ring-offset-2"
|
|
47
|
-
].join(" "),
|
|
48
|
-
secondary: [
|
|
49
|
-
"bg-bg-default text-fg-default border border-border-default",
|
|
50
|
-
"hover:bg-bg-container active:bg-bg-subtle",
|
|
51
|
-
"disabled:bg-bg-container disabled:text-fg-disabled disabled:cursor-not-allowed",
|
|
52
|
-
"focus-visible:ring-2 focus-visible:ring-brand-300 focus-visible:ring-offset-2"
|
|
53
|
-
].join(" "),
|
|
54
|
-
tertiary: [
|
|
55
|
-
"bg-transparent text-fg-default border border-transparent",
|
|
56
|
-
"hover:bg-bg-subtle active:bg-bg-subtle",
|
|
57
|
-
"disabled:text-fg-disabled disabled:cursor-not-allowed",
|
|
58
|
-
"focus-visible:ring-2 focus-visible:ring-brand-300 focus-visible:ring-offset-2"
|
|
59
|
-
].join(" "),
|
|
60
|
-
danger: [
|
|
61
|
-
"bg-red-700 text-white border border-transparent",
|
|
62
|
-
"hover:bg-red-800 active:bg-red-900",
|
|
63
|
-
"disabled:bg-bg-subtle disabled:text-fg-disabled disabled:cursor-not-allowed",
|
|
64
|
-
"focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:ring-offset-2"
|
|
65
|
-
].join(" ")
|
|
66
|
-
}, _ = {
|
|
67
|
-
primary: "bg-brand-700",
|
|
68
|
-
secondary: "bg-bg-subtle",
|
|
69
|
-
tertiary: "bg-bg-subtle",
|
|
70
|
-
danger: "bg-red-900"
|
|
71
|
-
}, v = t(function({ variant: e = "primary", size: t = "md", leftIcon: n, rightIcon: i, loading: a = !1, iconOnly: l = !1, fullWidth: u = !1, pressed: d = !1, disabled: f, className: v, children: y, onClick: b, dataTestId: x, ...S }, C) {
|
|
72
|
-
return /* @__PURE__ */ s("button", {
|
|
73
|
-
ref: C,
|
|
74
|
-
disabled: f || a,
|
|
75
|
-
"aria-pressed": d,
|
|
76
|
-
"data-test-id": x,
|
|
77
|
-
onClick: (e) => {
|
|
78
|
-
if (d || f || a) {
|
|
79
|
-
e.preventDefault();
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
b?.(e);
|
|
83
|
-
},
|
|
84
|
-
className: p("inline-flex items-center justify-center font-medium transition-colors outline-none", l ? h[t] : m[t], g[e], d && _[e], u && "w-full", v),
|
|
85
|
-
...S,
|
|
86
|
-
children: a ? /* @__PURE__ */ s(r, {
|
|
87
|
-
className: "h-4 w-4 animate-spin",
|
|
88
|
-
"aria-hidden": !0
|
|
89
|
-
}) : /* @__PURE__ */ c(o, { children: [
|
|
90
|
-
n && /* @__PURE__ */ s("span", {
|
|
91
|
-
className: "inline-flex shrink-0",
|
|
92
|
-
children: n
|
|
93
|
-
}),
|
|
94
|
-
y,
|
|
95
|
-
i && /* @__PURE__ */ s("span", {
|
|
96
|
-
className: "inline-flex shrink-0",
|
|
97
|
-
children: i
|
|
98
|
-
})
|
|
99
|
-
] })
|
|
100
|
-
});
|
|
101
|
-
}), y = e(null), b = t(function({ children: e, className: t, validationSchema: n, defaultValues: r, buttons: i, mode: a = "onBlur", shouldUnregister: o, shouldFocusError: l = !0, formId: f, onSubmit: m, dataTestId: h, ...g }, _) {
|
|
102
|
-
let { handleSubmit: b, register: x, setValue: S, control: C, formState: w, getValues: T, watch: E, reset: D, clearErrors: O, setError: k, trigger: A, getFieldState: j, unregister: M } = u({
|
|
103
|
-
mode: a,
|
|
104
|
-
resolver: d(n),
|
|
105
|
-
defaultValues: r,
|
|
106
|
-
shouldFocusError: l,
|
|
107
|
-
shouldUnregister: o
|
|
108
|
-
}), { errors: N, isDirty: P, isSubmitted: F, isSubmitting: I, dirtyFields: L, isValid: R } = w, z = b((e) => {
|
|
109
|
-
m?.(e, w);
|
|
110
|
-
}), B = {
|
|
111
|
-
control: C,
|
|
112
|
-
register: x,
|
|
113
|
-
errors: N,
|
|
114
|
-
setValue: S,
|
|
115
|
-
getValues: T,
|
|
116
|
-
watch: E,
|
|
117
|
-
reset: D,
|
|
118
|
-
trigger: A,
|
|
119
|
-
clearErrors: O,
|
|
120
|
-
setError: k,
|
|
121
|
-
getFieldState: j,
|
|
122
|
-
unregister: M,
|
|
123
|
-
isDirty: P,
|
|
124
|
-
isSubmitted: F,
|
|
125
|
-
isSubmitting: I,
|
|
126
|
-
isValid: R,
|
|
127
|
-
dirtyFields: L,
|
|
128
|
-
submit: z
|
|
129
|
-
};
|
|
130
|
-
return /* @__PURE__ */ s("form", {
|
|
131
|
-
ref: _,
|
|
132
|
-
id: f,
|
|
133
|
-
onSubmit: z,
|
|
134
|
-
"data-test-id": h,
|
|
135
|
-
className: p("flex flex-col gap-4", t),
|
|
136
|
-
...g,
|
|
137
|
-
children: /* @__PURE__ */ c(y.Provider, {
|
|
138
|
-
value: B,
|
|
139
|
-
children: [e, i && i.length > 0 && /* @__PURE__ */ s("div", {
|
|
140
|
-
className: "flex items-center gap-3",
|
|
141
|
-
"data-test-id": h ? `${h}-buttons` : void 0,
|
|
142
|
-
children: i.map((e, t) => /* @__PURE__ */ s(v, { ...e }, t))
|
|
143
|
-
})]
|
|
144
|
-
})
|
|
145
|
-
});
|
|
146
|
-
}), x = t(function({ name: e, defaultValue: t, render: r, className: i, dataTestId: a, ...o }, c) {
|
|
147
|
-
let u = n(y);
|
|
148
|
-
if (!u) throw Error("FormField must be rendered inside a FormContainer.");
|
|
149
|
-
return /* @__PURE__ */ s("div", {
|
|
150
|
-
ref: c,
|
|
151
|
-
className: p(i),
|
|
152
|
-
"data-test-id": a,
|
|
153
|
-
...o,
|
|
154
|
-
children: /* @__PURE__ */ s(l, {
|
|
155
|
-
control: u.control,
|
|
156
|
-
name: e,
|
|
157
|
-
defaultValue: t,
|
|
158
|
-
render: ({ field: e, fieldState: t }) => r({
|
|
159
|
-
...e,
|
|
160
|
-
error: !!t.error,
|
|
161
|
-
errorText: t.error?.message,
|
|
162
|
-
dataTestId: a
|
|
163
|
-
})
|
|
164
|
-
})
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
//#endregion
|
|
168
|
-
export { p as i, b as n, v as r, x as t };
|
|
169
|
-
|
|
170
|
-
//# sourceMappingURL=FormField-CwRAOtTN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormField-CwRAOtTN.js","names":[],"sources":["../src/lib/cn.ts","../src/components/Button/Button.tsx","../src/lib/FormContext.ts","../src/components/FormContainer/FormContainer.tsx","../src/components/FormField/FormField.tsx"],"sourcesContent":["import { clsx, type ClassValue } from 'clsx';\nimport { extendTailwindMerge } from 'tailwind-merge';\n\n/**\n * The custom font-size scale declared in `src/styles/tokens.css`'s `@theme`\n * block (`--text-h-xl`, `--text-p-sm`, `--text-label-md`, ...). Mirrored\n * here by hand — same two-parallel-representations discipline as the token\n * pipeline itself — because tailwind-merge ships its own hardcoded default\n * theme and has no way to read this project's actual `@theme` CSS.\n *\n * Without this, tailwind-merge's default config only recognizes Tailwind's\n * built-in font-size keywords (`xs`, `sm`, `lg`, ...) as font sizes; any\n * `text-*` suffix it doesn't recognize as a font size instead falls through\n * to the *color* class group, whose theme scale is deliberately `isAny`\n * (Tailwind v4 allows arbitrary custom theme colors). That misclassifies\n * every `text-p-*`/`text-h-*`/`text-label-*` utility as a text color, so it\n * gets silently dropped as a \"conflict\" whenever it appears alongside an\n * actual `text-{color}` class in the same `cn()` call — which is nearly\n * every real usage, since components pair a typography variant with a\n * semantic text color.\n */\nconst FONT_SIZE_TOKENS = [\n 'h-xl',\n 'h-lg',\n 'h-md',\n 'h-std',\n 'h-sm',\n 'h-xs',\n 'p-lg',\n 'p-md',\n 'p-std',\n 'p-sm',\n 'p-xs',\n 'label-lg',\n 'label-md',\n 'label-std',\n 'label-sm',\n 'label-xs',\n 'label-xxs',\n];\n\nconst twMerge = extendTailwindMerge({\n extend: {\n theme: {\n text: FONT_SIZE_TOKENS,\n },\n },\n});\n\n/**\n * Merges class names, resolving conflicting Tailwind utilities in favor of\n * the last one specified (e.g. `cn('px-2', 'px-4')` -> `'px-4'`). This is\n * what lets consumers pass a `className` prop that overrides a component's\n * defaults instead of just appending to them.\n */\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n","import { forwardRef } from 'react';\nimport { Loader2 } from 'lucide-react';\nimport { cn } from '../../lib/cn';\nimport type { ButtonProps, ButtonSize, ButtonVariant } from './Button.types';\n\nconst sizeStyles: Record<ButtonSize, string> = {\n lg: 'h-12 px-5 text-p-md gap-2 rounded-lg',\n md: 'h-10 px-4 text-p-std gap-2 rounded-lg',\n sm: 'h-8 px-3 text-p-sm gap-1.5 rounded-md',\n};\n\nconst iconOnlySize: Record<ButtonSize, string> = {\n lg: 'h-12 w-12 rounded-lg',\n md: 'h-10 w-10 rounded-lg',\n sm: 'h-8 w-8 rounded-md',\n};\n\nconst variantStyles: Record<ButtonVariant, string> = {\n primary: [\n 'bg-brand-500 text-white border border-transparent',\n 'hover:bg-brand-600 active:bg-brand-700',\n 'disabled:bg-bg-subtle disabled:text-fg-disabled disabled:cursor-not-allowed',\n 'focus-visible:ring-2 focus-visible:ring-brand-300 focus-visible:ring-offset-2',\n ].join(' '),\n secondary: [\n 'bg-bg-default text-fg-default border border-border-default',\n 'hover:bg-bg-container active:bg-bg-subtle',\n 'disabled:bg-bg-container disabled:text-fg-disabled disabled:cursor-not-allowed',\n 'focus-visible:ring-2 focus-visible:ring-brand-300 focus-visible:ring-offset-2',\n ].join(' '),\n tertiary: [\n 'bg-transparent text-fg-default border border-transparent',\n 'hover:bg-bg-subtle active:bg-bg-subtle',\n 'disabled:text-fg-disabled disabled:cursor-not-allowed',\n 'focus-visible:ring-2 focus-visible:ring-brand-300 focus-visible:ring-offset-2',\n ].join(' '),\n danger: [\n 'bg-red-700 text-white border border-transparent',\n 'hover:bg-red-800 active:bg-red-900',\n 'disabled:bg-bg-subtle disabled:text-fg-disabled disabled:cursor-not-allowed',\n 'focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:ring-offset-2',\n ].join(' '),\n};\n\n// Same shade each variant already uses for `active:`, applied persistently\n// while `pressed` is true instead of only during the mousedown instant.\nconst pressedStyles: Record<ButtonVariant, string> = {\n primary: 'bg-brand-700',\n secondary: 'bg-bg-subtle',\n tertiary: 'bg-bg-subtle',\n danger: 'bg-red-900',\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant = 'primary',\n size = 'md',\n leftIcon,\n rightIcon,\n loading = false,\n iconOnly = false,\n fullWidth = false,\n pressed = false,\n disabled,\n className,\n children,\n onClick,\n dataTestId,\n ...rest\n },\n ref,\n) {\n return (\n <button\n ref={ref}\n disabled={disabled || loading}\n aria-pressed={pressed}\n data-test-id={dataTestId}\n onClick={(event) => {\n if (pressed || disabled || loading) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n }}\n className={cn(\n 'inline-flex items-center justify-center font-medium transition-colors outline-none',\n iconOnly ? iconOnlySize[size] : sizeStyles[size],\n variantStyles[variant],\n pressed && pressedStyles[variant],\n fullWidth && 'w-full',\n className,\n )}\n {...rest}\n >\n {loading ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" aria-hidden />\n ) : (\n <>\n {leftIcon && <span className=\"inline-flex shrink-0\">{leftIcon}</span>}\n {children}\n {rightIcon && <span className=\"inline-flex shrink-0\">{rightIcon}</span>}\n </>\n )}\n </button>\n );\n});\n","import { createContext } from 'react';\nimport type {\n Control,\n FieldErrors,\n FieldValues,\n UseFormClearErrors,\n UseFormGetFieldState,\n UseFormGetValues,\n UseFormRegister,\n UseFormReset,\n UseFormSetError,\n UseFormSetValue,\n UseFormTrigger,\n UseFormUnregister,\n UseFormWatch,\n} from 'react-hook-form';\n\nexport interface FormContextValue {\n control: Control<FieldValues>;\n register: UseFormRegister<FieldValues>;\n errors: FieldErrors<FieldValues>;\n setValue: UseFormSetValue<FieldValues>;\n getValues: UseFormGetValues<FieldValues>;\n watch: UseFormWatch<FieldValues>;\n reset: UseFormReset<FieldValues>;\n trigger: UseFormTrigger<FieldValues>;\n clearErrors: UseFormClearErrors<FieldValues>;\n setError: UseFormSetError<FieldValues>;\n getFieldState: UseFormGetFieldState<FieldValues>;\n unregister: UseFormUnregister<FieldValues>;\n isDirty: boolean;\n isSubmitted: boolean;\n isSubmitting: boolean;\n isValid: boolean;\n dirtyFields: Partial<Readonly<Record<string, boolean>>>;\n submit: () => void;\n}\n\nexport const FormContext = createContext<FormContextValue | null>(null);\n","import { forwardRef } from 'react';\nimport { useForm, type FieldValues } from 'react-hook-form';\nimport { yupResolver } from '@hookform/resolvers/yup';\nimport { cn } from '../../lib/cn';\nimport { FormContext, type FormContextValue } from '../../lib/FormContext';\nimport { Button } from '../Button';\nimport type { FormContainerProps } from './FormContainer.types';\n\nexport const FormContainer = forwardRef<HTMLFormElement, FormContainerProps>(function FormContainer(\n {\n children,\n className,\n validationSchema,\n defaultValues,\n buttons,\n mode = 'onBlur',\n shouldUnregister,\n shouldFocusError = true,\n formId,\n onSubmit,\n dataTestId,\n ...rest\n },\n ref,\n) {\n const {\n handleSubmit,\n register,\n setValue,\n control,\n formState,\n getValues,\n watch,\n reset,\n clearErrors,\n setError,\n trigger,\n getFieldState,\n unregister,\n } = useForm<FieldValues>({\n mode,\n resolver: yupResolver(validationSchema),\n defaultValues,\n shouldFocusError,\n shouldUnregister,\n });\n\n const { errors, isDirty, isSubmitted, isSubmitting, dirtyFields, isValid } = formState;\n\n const submit = handleSubmit((data) => {\n onSubmit?.(data, formState);\n });\n\n const contextValue: FormContextValue = {\n control,\n register,\n errors,\n setValue,\n getValues,\n watch,\n reset,\n trigger,\n clearErrors,\n setError,\n getFieldState,\n unregister,\n isDirty,\n isSubmitted,\n isSubmitting,\n isValid,\n dirtyFields,\n submit,\n };\n\n return (\n <form\n ref={ref}\n id={formId}\n onSubmit={submit}\n data-test-id={dataTestId}\n className={cn('flex flex-col gap-4', className)}\n {...rest}\n >\n <FormContext.Provider value={contextValue}>\n {children}\n {buttons && buttons.length > 0 && (\n <div className=\"flex items-center gap-3\" data-test-id={dataTestId ? `${dataTestId}-buttons` : undefined}>\n {buttons.map((buttonProps, index) => (\n <Button key={index} {...buttonProps} />\n ))}\n </div>\n )}\n </FormContext.Provider>\n </form>\n );\n});\n","import { forwardRef, useContext } from 'react';\nimport { Controller } from 'react-hook-form';\nimport { cn } from '../../lib/cn';\nimport { FormContext } from '../../lib/FormContext';\nimport type { FormFieldProps } from './FormField.types';\n\nexport const FormField = forwardRef<HTMLDivElement, FormFieldProps>(function FormField(\n { name, defaultValue, render, className, dataTestId, ...rest },\n ref,\n) {\n const context = useContext(FormContext);\n\n if (!context) {\n throw new Error('FormField must be rendered inside a FormContainer.');\n }\n\n return (\n <div ref={ref} className={cn(className)} data-test-id={dataTestId} {...rest}>\n <Controller\n control={context.control}\n name={name}\n defaultValue={defaultValue}\n render={({ field, fieldState }) =>\n render({\n ...field,\n error: !!fieldState.error,\n errorText: fieldState.error?.message,\n dataTestId,\n })\n }\n />\n </div>\n );\n});\n"],"mappings":"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"}
|
package/dist/form/index.d.ts
DELETED
package/dist/form.d.ts
DELETED
package/dist/form.js
DELETED