@kumix/ui 0.3.2 → 0.3.4

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 (70) hide show
  1. package/README.md +4 -6
  2. package/dist/components/motion/animated-toast-stack.js +3 -3
  3. package/dist/components/motion/animated-toast-stack.js.map +1 -1
  4. package/dist/components/motion/button/base.d.ts +8 -1
  5. package/dist/components/motion/button/base.d.ts.map +1 -1
  6. package/dist/components/motion/button/base.js +14 -1
  7. package/dist/components/motion/button/base.js.map +1 -1
  8. package/dist/components/motion/button/index.d.ts +2 -2
  9. package/dist/components/motion/button/index.js +2 -2
  10. package/dist/components/motion/checkbox.d.ts +3 -1
  11. package/dist/components/motion/checkbox.d.ts.map +1 -1
  12. package/dist/components/motion/checkbox.js +2 -1
  13. package/dist/components/motion/checkbox.js.map +1 -1
  14. package/dist/components/motion/morphing-tabs.d.ts +36 -0
  15. package/dist/components/motion/morphing-tabs.d.ts.map +1 -0
  16. package/dist/components/motion/morphing-tabs.js +518 -0
  17. package/dist/components/motion/morphing-tabs.js.map +1 -0
  18. package/dist/components/motion/signup-form.d.ts +56 -0
  19. package/dist/components/motion/signup-form.d.ts.map +1 -0
  20. package/dist/components/motion/signup-form.js +337 -0
  21. package/dist/components/motion/signup-form.js.map +1 -0
  22. package/dist/components/reui/alert.d.ts +1 -1
  23. package/dist/components/reui/autocomplete.d.ts +1 -1
  24. package/dist/components/reui/badge.d.ts +2 -2
  25. package/dist/components/reui/data-grid/data-grid-column-filter.js +2 -2
  26. package/dist/components/reui/data-grid/data-grid.d.ts +4 -0
  27. package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
  28. package/dist/components/reui/data-grid/data-grid.js +6 -2
  29. package/dist/components/reui/data-grid/data-grid.js.map +1 -1
  30. package/dist/components/reui/date-selector.js +1 -1
  31. package/dist/components/reui/event-calendar/event-calendar-event.d.ts +32 -1
  32. package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -1
  33. package/dist/components/reui/event-calendar/event-calendar-event.js +32 -1
  34. package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
  35. package/dist/components/reui/event-calendar/event-calendar-month-view.d.ts.map +1 -1
  36. package/dist/components/reui/event-calendar/event-calendar-month-view.js +19 -4
  37. package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -1
  38. package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
  39. package/dist/components/reui/event-calendar/event-calendar-resource-view.d.ts.map +1 -1
  40. package/dist/components/reui/event-calendar/event-calendar-resource-view.js +16 -4
  41. package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -1
  42. package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts.map +1 -1
  43. package/dist/components/reui/event-calendar/event-calendar-time-grid.js +33 -5
  44. package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
  45. package/dist/components/reui/filters.js +3 -3
  46. package/dist/components/reui/frame.d.ts +1 -1
  47. package/dist/components/reui/gantt/gantt-bar.js +1 -1
  48. package/dist/components/reui/gantt/gantt-nav.js +1 -1
  49. package/dist/components/reui/gantt/gantt-view.js +3 -3
  50. package/dist/components/reui/icon-tile.d.ts +1 -1
  51. package/dist/components/reui/number-field.d.ts +3 -3
  52. package/dist/components/reui/phone-input.js +1 -1
  53. package/dist/components/reui/rating.d.ts +1 -1
  54. package/dist/components/ui/attachment.d.ts +3 -3
  55. package/dist/components/ui/badge.d.ts +1 -1
  56. package/dist/components/ui/bubble.d.ts +1 -1
  57. package/dist/components/ui/button-group.d.ts +1 -1
  58. package/dist/components/ui/button.d.ts +2 -2
  59. package/dist/components/ui/empty.d.ts +1 -1
  60. package/dist/components/ui/field.d.ts +1 -1
  61. package/dist/components/ui/item.d.ts +2 -2
  62. package/dist/components/ui/marker.d.ts +1 -1
  63. package/dist/components/ui/questionnaire.d.ts +2 -1
  64. package/dist/components/ui/questionnaire.d.ts.map +1 -1
  65. package/dist/components/ui/questionnaire.js +11 -4
  66. package/dist/components/ui/questionnaire.js.map +1 -1
  67. package/dist/components/ui/sidebar.d.ts +1 -1
  68. package/dist/components/ui/sidebar.js +2 -2
  69. package/dist/components/ui/toggle.d.ts +1 -1
  70. package/package.json +74 -9
@@ -0,0 +1,337 @@
1
+ "use client";
2
+ import { EASE_OUT, SPRING_LAYOUT } from "../../lib/ease.js";
3
+ import { StatefulButton } from "./button/stateful.js";
4
+ import "./button/index.js";
5
+ import { Checkbox } from "./checkbox.js";
6
+ import { Input } from "./input.js";
7
+ import { useCallback, useId, useMemo, useState } from "react";
8
+ import { cn } from "@kumix/utils";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
11
+ import { Eye, EyeOff, Lock, Mail, User } from "lucide-react";
12
+ //#region src/components/motion/signup-form.tsx
13
+ const EMPTY_VALUES = {
14
+ name: "",
15
+ email: "",
16
+ password: "",
17
+ confirmPassword: "",
18
+ terms: false
19
+ };
20
+ const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
21
+ const MIN_PASSWORD_LENGTH = 8;
22
+ const STRENGTH_LABELS = [
23
+ "Too short",
24
+ "Weak",
25
+ "Fair",
26
+ "Good",
27
+ "Strong"
28
+ ];
29
+ const STRENGTH_COLORS = [
30
+ "bg-destructive",
31
+ "bg-destructive",
32
+ "bg-amber-500",
33
+ "bg-amber-400",
34
+ "bg-(--color-success)"
35
+ ];
36
+ /**
37
+ * Length-weighted strength score, 0-4. NIST SP 800-63B advises against
38
+ * composition requirements and treats length as the dominant factor, so extra
39
+ * character classes only nudge the score — they can't rescue a short password.
40
+ * This is a heuristic for feedback, not entropy estimation; pair it with a
41
+ * breach-list check server-side for anything real.
42
+ */
43
+ function passwordStrength(password) {
44
+ if (password.length < MIN_PASSWORD_LENGTH) return 0;
45
+ let score = 1;
46
+ if (password.length >= 12) score += 1;
47
+ if (password.length >= 16) score += 1;
48
+ if ([
49
+ /[a-z]/,
50
+ /[A-Z]/,
51
+ /\d/,
52
+ /[^A-Za-z0-9]/
53
+ ].filter((pattern) => pattern.test(password)).length >= 3) score += 1;
54
+ return Math.min(score, 4);
55
+ }
56
+ function defaultValidate(values) {
57
+ const errors = {};
58
+ if (!values.name.trim()) errors.name = "Enter your name.";
59
+ if (!values.email.trim()) errors.email = "Enter your email.";
60
+ else if (!EMAIL_PATTERN.test(values.email)) errors.email = "That doesn't look like an email address.";
61
+ if (!values.password) errors.password = "Choose a password.";
62
+ else if (values.password.length < MIN_PASSWORD_LENGTH) errors.password = `Use at least ${MIN_PASSWORD_LENGTH} characters.`;
63
+ if (!values.confirmPassword) errors.confirmPassword = "Confirm your password.";
64
+ else if (values.confirmPassword !== values.password) errors.confirmPassword = "Passwords don't match.";
65
+ if (!values.terms) errors.terms = "Accept the terms to continue.";
66
+ return errors;
67
+ }
68
+ function SignUpForm({ values: valuesProp, defaultValues, onValuesChange, onSubmit, validate, status: statusProp, errorMessage, title = "Create your account", description = "Start building in under a minute.", submitLabel = "Create account", footer, strengthMeter = true, className, classNames }) {
69
+ const reduce = useReducedMotion();
70
+ const baseId = useId();
71
+ const controlled = valuesProp !== void 0;
72
+ const [internalValues, setInternalValues] = useState({
73
+ ...EMPTY_VALUES,
74
+ ...defaultValues
75
+ });
76
+ const values = controlled ? valuesProp : internalValues;
77
+ const [internalStatus, setInternalStatus] = useState("idle");
78
+ const status = statusProp ?? internalStatus;
79
+ const [revealPassword, setRevealPassword] = useState(false);
80
+ const [touched, setTouched] = useState({});
81
+ const errors = useMemo(() => (validate ?? defaultValidate)(values), [values, validate]);
82
+ const setValue = useCallback((key, next) => {
83
+ const nextValues = {
84
+ ...values,
85
+ [key]: next
86
+ };
87
+ if (!controlled) {
88
+ setInternalValues(nextValues);
89
+ if (statusProp === void 0) setInternalStatus((current) => current === "success" || current === "error" ? "idle" : current);
90
+ }
91
+ onValuesChange?.(nextValues);
92
+ }, [
93
+ controlled,
94
+ onValuesChange,
95
+ statusProp,
96
+ values
97
+ ]);
98
+ const touch = useCallback((key) => {
99
+ setTouched((prev) => prev[key] ? prev : {
100
+ ...prev,
101
+ [key]: true
102
+ });
103
+ }, []);
104
+ /** Error to render for a field — hidden until the field has been touched. */
105
+ const shownError = (key) => touched[key] ? errors[key] : void 0;
106
+ /** Success check draws only once a touched field is non-empty and valid. */
107
+ const isValid = (key) => Boolean(touched[key]) && !errors[key] && Boolean(values[key]);
108
+ const strength = passwordStrength(values.password);
109
+ const showStrength = strengthMeter && values.password.length > 0;
110
+ const isSubmitting = status === "loading";
111
+ const handleSubmit = async (event) => {
112
+ event.preventDefault();
113
+ setTouched({
114
+ name: true,
115
+ email: true,
116
+ password: true,
117
+ confirmPassword: true,
118
+ terms: true
119
+ });
120
+ if (Object.keys(errors).length > 0) return;
121
+ if (!onSubmit) return;
122
+ if (statusProp === void 0) setInternalStatus("loading");
123
+ try {
124
+ await onSubmit(values);
125
+ if (statusProp === void 0) setInternalStatus("success");
126
+ } catch {
127
+ if (statusProp === void 0) setInternalStatus("error");
128
+ }
129
+ };
130
+ const termsErrorId = `${baseId}-terms-error`;
131
+ const formErrorId = `${baseId}-form-error`;
132
+ return /* @__PURE__ */ jsxs("form", {
133
+ noValidate: true,
134
+ onSubmit: handleSubmit,
135
+ className: cn("flex w-full max-w-sm flex-col gap-5 rounded-3xl border border-border p-6", className, classNames?.root),
136
+ children: [
137
+ title || description ? /* @__PURE__ */ jsxs("div", {
138
+ className: cn("flex flex-col gap-1", classNames?.header),
139
+ children: [title ? /* @__PURE__ */ jsx("h2", {
140
+ className: cn("font-semibold text-foreground text-xl tracking-tight", classNames?.title),
141
+ children: title
142
+ }) : null, description ? /* @__PURE__ */ jsx("p", {
143
+ className: cn("text-muted-foreground text-sm", classNames?.description),
144
+ children: description
145
+ }) : null]
146
+ }) : null,
147
+ /* @__PURE__ */ jsxs("div", {
148
+ className: cn("flex flex-col gap-4", classNames?.fields),
149
+ children: [
150
+ /* @__PURE__ */ jsx(Input, {
151
+ label: "Name",
152
+ autoComplete: "name",
153
+ placeholder: "Ada Lovelace",
154
+ leftIcon: /* @__PURE__ */ jsx(User, {}),
155
+ disabled: isSubmitting,
156
+ value: values.name,
157
+ onChange: (next) => setValue("name", next),
158
+ onBlur: () => touch("name"),
159
+ error: shownError("name"),
160
+ success: isValid("name")
161
+ }),
162
+ /* @__PURE__ */ jsx(Input, {
163
+ label: "Email",
164
+ type: "email",
165
+ inputMode: "email",
166
+ autoComplete: "email",
167
+ placeholder: "you@example.com",
168
+ leftIcon: /* @__PURE__ */ jsx(Mail, {}),
169
+ disabled: isSubmitting,
170
+ value: values.email,
171
+ onChange: (next) => setValue("email", next),
172
+ onBlur: () => touch("email"),
173
+ error: shownError("email"),
174
+ success: isValid("email")
175
+ }),
176
+ /* @__PURE__ */ jsxs("div", {
177
+ className: "flex flex-col gap-2",
178
+ children: [/* @__PURE__ */ jsx(Input, {
179
+ label: "Password",
180
+ type: revealPassword ? "text" : "password",
181
+ autoComplete: "new-password",
182
+ placeholder: "At least 8 characters",
183
+ leftIcon: /* @__PURE__ */ jsx(Lock, {}),
184
+ rightIcon: /* @__PURE__ */ jsx("button", {
185
+ type: "button",
186
+ disabled: isSubmitting,
187
+ onClick: () => setRevealPassword((prev) => !prev),
188
+ "aria-label": revealPassword ? "Hide password" : "Show password",
189
+ className: "text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground",
190
+ children: revealPassword ? /* @__PURE__ */ jsx(EyeOff, {}) : /* @__PURE__ */ jsx(Eye, {})
191
+ }),
192
+ disabled: isSubmitting,
193
+ value: values.password,
194
+ onChange: (next) => setValue("password", next),
195
+ onBlur: () => touch("password"),
196
+ error: shownError("password")
197
+ }), /* @__PURE__ */ jsx(AnimatePresence, {
198
+ initial: false,
199
+ children: showStrength ? /* @__PURE__ */ jsxs(motion.div, {
200
+ initial: reduce ? { opacity: 0 } : {
201
+ opacity: 0,
202
+ y: -4
203
+ },
204
+ animate: {
205
+ opacity: 1,
206
+ y: 0
207
+ },
208
+ exit: reduce ? { opacity: 0 } : {
209
+ opacity: 0,
210
+ y: -4
211
+ },
212
+ transition: {
213
+ duration: .18,
214
+ ease: EASE_OUT
215
+ },
216
+ className: cn("flex flex-col gap-1.5 px-1", classNames?.strength),
217
+ children: [/* @__PURE__ */ jsx("div", {
218
+ className: "flex gap-1.5",
219
+ "aria-hidden": true,
220
+ children: [
221
+ 0,
222
+ 1,
223
+ 2,
224
+ 3
225
+ ].map((index) => /* @__PURE__ */ jsx("span", {
226
+ className: "h-1 flex-1 overflow-hidden rounded-full bg-muted-foreground/20",
227
+ children: /* @__PURE__ */ jsx(motion.span, {
228
+ initial: false,
229
+ animate: { scaleX: index < strength ? 1 : 0 },
230
+ transition: reduce ? { duration: 0 } : SPRING_LAYOUT,
231
+ className: cn("block h-full w-full origin-left rounded-full", STRENGTH_COLORS[strength])
232
+ })
233
+ }, index))
234
+ }), /* @__PURE__ */ jsxs("p", {
235
+ "aria-live": "polite",
236
+ className: "text-muted-foreground text-xs",
237
+ children: ["Password strength: ", STRENGTH_LABELS[strength]]
238
+ })]
239
+ }) : null
240
+ })]
241
+ }),
242
+ /* @__PURE__ */ jsx(Input, {
243
+ label: "Confirm password",
244
+ type: revealPassword ? "text" : "password",
245
+ autoComplete: "new-password",
246
+ placeholder: "Re-enter your password",
247
+ leftIcon: /* @__PURE__ */ jsx(Lock, {}),
248
+ disabled: isSubmitting,
249
+ value: values.confirmPassword,
250
+ onChange: (next) => setValue("confirmPassword", next),
251
+ onBlur: () => touch("confirmPassword"),
252
+ error: shownError("confirmPassword"),
253
+ success: isValid("confirmPassword")
254
+ })
255
+ ]
256
+ }),
257
+ /* @__PURE__ */ jsxs("div", {
258
+ className: cn("flex flex-col gap-1.5", classNames?.terms),
259
+ children: [/* @__PURE__ */ jsx(Checkbox, {
260
+ checked: values.terms,
261
+ disabled: isSubmitting,
262
+ onCheckedChange: (next) => {
263
+ setValue("terms", next);
264
+ touch("terms");
265
+ },
266
+ label: "I agree to the Terms and Privacy Policy",
267
+ "aria-describedby": shownError("terms") ? termsErrorId : void 0
268
+ }), /* @__PURE__ */ jsx(AnimatePresence, {
269
+ initial: false,
270
+ children: shownError("terms") ? /* @__PURE__ */ jsx(motion.p, {
271
+ id: termsErrorId,
272
+ role: "alert",
273
+ initial: reduce ? { opacity: 0 } : {
274
+ opacity: 0,
275
+ y: -4,
276
+ filter: "blur(4px)"
277
+ },
278
+ animate: {
279
+ opacity: 1,
280
+ y: 0,
281
+ filter: "blur(0px)"
282
+ },
283
+ exit: reduce ? { opacity: 0 } : {
284
+ opacity: 0,
285
+ y: -4,
286
+ filter: "blur(4px)"
287
+ },
288
+ transition: { duration: .2 },
289
+ className: "px-1 text-destructive text-xs",
290
+ children: shownError("terms")
291
+ }) : null
292
+ })]
293
+ }),
294
+ /* @__PURE__ */ jsx(AnimatePresence, {
295
+ initial: false,
296
+ children: errorMessage ? /* @__PURE__ */ jsx(motion.p, {
297
+ id: formErrorId,
298
+ role: "alert",
299
+ initial: reduce ? { opacity: 0 } : {
300
+ opacity: 0,
301
+ y: -4
302
+ },
303
+ animate: {
304
+ opacity: 1,
305
+ y: 0
306
+ },
307
+ exit: reduce ? { opacity: 0 } : {
308
+ opacity: 0,
309
+ y: -4
310
+ },
311
+ transition: { duration: .2 },
312
+ className: "rounded-2xl border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive text-xs",
313
+ children: errorMessage
314
+ }) : null
315
+ }),
316
+ /* @__PURE__ */ jsx(StatefulButton, {
317
+ type: "submit",
318
+ size: "lg",
319
+ state: status,
320
+ loadingText: "Creating account",
321
+ successText: "Account created",
322
+ errorText: "Try again",
323
+ "aria-describedby": errorMessage ? formErrorId : void 0,
324
+ className: cn("w-full", classNames?.submit),
325
+ children: submitLabel
326
+ }),
327
+ footer ? /* @__PURE__ */ jsx("div", {
328
+ className: cn("text-center text-muted-foreground text-sm", classNames?.footer),
329
+ children: footer
330
+ }) : null
331
+ ]
332
+ });
333
+ }
334
+ //#endregion
335
+ export { SignUpForm, passwordStrength };
336
+
337
+ //# sourceMappingURL=signup-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signup-form.js","names":[],"sources":["../../../src/components/motion/signup-form.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FormEvent, type ReactNode, useCallback, useId, useMemo, useState } from \"react\";\nimport { Eye, EyeOff, Lock, Mail, User } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT, SPRING_LAYOUT } from \"../../lib/ease\";\nimport { StatefulButton } from \"./button\";\nimport { Checkbox } from \"./checkbox\";\nimport { Input } from \"./input\";\n\nexport type SignUpStatus = \"idle\" | \"loading\" | \"success\" | \"error\";\n\nexport type SignUpValues = {\n name: string;\n email: string;\n password: string;\n confirmPassword: string;\n terms: boolean;\n};\n\nexport type SignUpErrors = Partial<Record<keyof SignUpValues, string>>;\n\nexport type SignUpFormClassNames = {\n root?: string;\n header?: string;\n title?: string;\n description?: string;\n fields?: string;\n strength?: string;\n terms?: string;\n submit?: string;\n footer?: string;\n};\n\nexport interface SignUpFormProps {\n /** Controlled values. Omit for uncontrolled. */\n values?: SignUpValues;\n defaultValues?: Partial<SignUpValues>;\n onValuesChange?: (values: SignUpValues) => void;\n /** Called with valid values only. Return a promise to drive the button state. */\n onSubmit?: (values: SignUpValues) => void | Promise<void>;\n /** Replace the built-in rules — return a message per invalid field. */\n validate?: (values: SignUpValues) => SignUpErrors;\n /** Controlled submit state. Omit to let the form track it. */\n status?: SignUpStatus;\n /** Form-level failure message, shown above the submit button. */\n errorMessage?: string;\n title?: ReactNode;\n description?: ReactNode;\n submitLabel?: string;\n footer?: ReactNode;\n /** Show the password strength meter. */\n strengthMeter?: boolean;\n className?: string;\n classNames?: SignUpFormClassNames;\n}\n\nconst EMPTY_VALUES: SignUpValues = {\n name: \"\",\n email: \"\",\n password: \"\",\n confirmPassword: \"\",\n terms: false,\n};\n\n// Deliberately permissive. Full RFC 5322 matching is impractical in a regex and\n// rejects addresses that deliver fine; the only real check is sending mail.\nconst EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nconst MIN_PASSWORD_LENGTH = 8;\n\nconst STRENGTH_LABELS = [\"Too short\", \"Weak\", \"Fair\", \"Good\", \"Strong\"] as const;\n\nconst STRENGTH_COLORS = [\n \"bg-destructive\",\n \"bg-destructive\",\n \"bg-amber-500\",\n \"bg-amber-400\",\n \"bg-(--color-success)\",\n] as const;\n\n/**\n * Length-weighted strength score, 0-4. NIST SP 800-63B advises against\n * composition requirements and treats length as the dominant factor, so extra\n * character classes only nudge the score — they can't rescue a short password.\n * This is a heuristic for feedback, not entropy estimation; pair it with a\n * breach-list check server-side for anything real.\n */\nexport function passwordStrength(password: string): number {\n if (password.length < MIN_PASSWORD_LENGTH) return 0;\n\n let score = 1;\n if (password.length >= 12) score += 1;\n if (password.length >= 16) score += 1;\n\n const classes = [/[a-z]/, /[A-Z]/, /\\d/, /[^A-Za-z0-9]/].filter((pattern) =>\n pattern.test(password),\n ).length;\n if (classes >= 3) score += 1;\n\n return Math.min(score, 4);\n}\n\nfunction defaultValidate(values: SignUpValues): SignUpErrors {\n const errors: SignUpErrors = {};\n\n if (!values.name.trim()) {\n errors.name = \"Enter your name.\";\n }\n\n if (!values.email.trim()) {\n errors.email = \"Enter your email.\";\n } else if (!EMAIL_PATTERN.test(values.email)) {\n errors.email = \"That doesn't look like an email address.\";\n }\n\n if (!values.password) {\n errors.password = \"Choose a password.\";\n } else if (values.password.length < MIN_PASSWORD_LENGTH) {\n errors.password = `Use at least ${MIN_PASSWORD_LENGTH} characters.`;\n }\n\n if (!values.confirmPassword) {\n errors.confirmPassword = \"Confirm your password.\";\n } else if (values.confirmPassword !== values.password) {\n errors.confirmPassword = \"Passwords don't match.\";\n }\n\n if (!values.terms) {\n errors.terms = \"Accept the terms to continue.\";\n }\n\n return errors;\n}\n\nexport function SignUpForm({\n values: valuesProp,\n defaultValues,\n onValuesChange,\n onSubmit,\n validate,\n status: statusProp,\n errorMessage,\n title = \"Create your account\",\n description = \"Start building in under a minute.\",\n submitLabel = \"Create account\",\n footer,\n strengthMeter = true,\n className,\n classNames,\n}: SignUpFormProps) {\n const reduce = useReducedMotion();\n const baseId = useId();\n\n const controlled = valuesProp !== undefined;\n const [internalValues, setInternalValues] = useState<SignUpValues>({\n ...EMPTY_VALUES,\n ...defaultValues,\n });\n const values = controlled ? valuesProp : internalValues;\n\n const [internalStatus, setInternalStatus] = useState<SignUpStatus>(\"idle\");\n const status = statusProp ?? internalStatus;\n\n const [revealPassword, setRevealPassword] = useState(false);\n\n // \"Reward early, punish late\": errors are computed on every change, but a\n // field only *shows* its error once it has been blurred (or submit touched\n // everything). So a first entry is never flagged mid-typing, while a field\n // already in error clears the moment it becomes valid.\n const [touched, setTouched] = useState<Partial<Record<keyof SignUpValues, boolean>>>({});\n\n const errors = useMemo(() => (validate ?? defaultValidate)(values), [values, validate]);\n\n const setValue = useCallback(\n <K extends keyof SignUpValues>(key: K, next: SignUpValues[K]) => {\n const nextValues = { ...values, [key]: next };\n if (!controlled) {\n setInternalValues(nextValues);\n if (statusProp === undefined) {\n setInternalStatus((current) =>\n current === \"success\" || current === \"error\" ? \"idle\" : current,\n );\n }\n }\n onValuesChange?.(nextValues);\n },\n [controlled, onValuesChange, statusProp, values],\n );\n\n const touch = useCallback((key: keyof SignUpValues) => {\n setTouched((prev) => (prev[key] ? prev : { ...prev, [key]: true }));\n }, []);\n\n /** Error to render for a field — hidden until the field has been touched. */\n const shownError = (key: keyof SignUpValues) => (touched[key] ? errors[key] : undefined);\n\n /** Success check draws only once a touched field is non-empty and valid. */\n const isValid = (key: keyof SignUpValues) =>\n Boolean(touched[key]) && !errors[key] && Boolean(values[key]);\n\n const strength = passwordStrength(values.password);\n const showStrength = strengthMeter && values.password.length > 0;\n const isSubmitting = status === \"loading\";\n\n const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n\n setTouched({\n name: true,\n email: true,\n password: true,\n confirmPassword: true,\n terms: true,\n });\n\n if (Object.keys(errors).length > 0) return;\n if (!onSubmit) return;\n\n if (statusProp === undefined) setInternalStatus(\"loading\");\n try {\n await onSubmit(values);\n if (statusProp === undefined) setInternalStatus(\"success\");\n } catch {\n if (statusProp === undefined) setInternalStatus(\"error\");\n }\n };\n\n const termsErrorId = `${baseId}-terms-error`;\n const formErrorId = `${baseId}-form-error`;\n\n return (\n <form\n noValidate\n onSubmit={handleSubmit}\n className={cn(\n \"flex w-full max-w-sm flex-col gap-5 rounded-3xl border border-border p-6\",\n className,\n classNames?.root,\n )}\n >\n {title || description ? (\n <div className={cn(\"flex flex-col gap-1\", classNames?.header)}>\n {title ? (\n <h2\n className={cn(\n \"font-semibold text-foreground text-xl tracking-tight\",\n classNames?.title,\n )}\n >\n {title}\n </h2>\n ) : null}\n {description ? (\n <p className={cn(\"text-muted-foreground text-sm\", classNames?.description)}>\n {description}\n </p>\n ) : null}\n </div>\n ) : null}\n\n <div className={cn(\"flex flex-col gap-4\", classNames?.fields)}>\n <Input\n label=\"Name\"\n autoComplete=\"name\"\n placeholder=\"Ada Lovelace\"\n leftIcon={<User />}\n disabled={isSubmitting}\n value={values.name}\n onChange={(next) => setValue(\"name\", next)}\n onBlur={() => touch(\"name\")}\n error={shownError(\"name\")}\n success={isValid(\"name\")}\n />\n\n <Input\n label=\"Email\"\n type=\"email\"\n inputMode=\"email\"\n autoComplete=\"email\"\n placeholder=\"you@example.com\"\n leftIcon={<Mail />}\n disabled={isSubmitting}\n value={values.email}\n onChange={(next) => setValue(\"email\", next)}\n onBlur={() => touch(\"email\")}\n error={shownError(\"email\")}\n success={isValid(\"email\")}\n />\n\n <div className=\"flex flex-col gap-2\">\n <Input\n label=\"Password\"\n type={revealPassword ? \"text\" : \"password\"}\n autoComplete=\"new-password\"\n placeholder=\"At least 8 characters\"\n leftIcon={<Lock />}\n rightIcon={\n <button\n type=\"button\"\n disabled={isSubmitting}\n onClick={() => setRevealPassword((prev) => !prev)}\n aria-label={revealPassword ? \"Hide password\" : \"Show password\"}\n className=\"text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground\"\n >\n {revealPassword ? <EyeOff /> : <Eye />}\n </button>\n }\n disabled={isSubmitting}\n value={values.password}\n onChange={(next) => setValue(\"password\", next)}\n onBlur={() => touch(\"password\")}\n error={shownError(\"password\")}\n />\n\n <AnimatePresence initial={false}>\n {showStrength ? (\n <motion.div\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n transition={{ duration: 0.18, ease: EASE_OUT }}\n className={cn(\"flex flex-col gap-1.5 px-1\", classNames?.strength)}\n >\n <div className=\"flex gap-1.5\" aria-hidden>\n {[0, 1, 2, 3].map((index) => (\n <span\n key={index}\n className=\"h-1 flex-1 overflow-hidden rounded-full bg-muted-foreground/20\"\n >\n {/* scaleX rather than width — transforms only, per the\n motion conventions, and it keeps the bar off layout. */}\n <motion.span\n initial={false}\n animate={{ scaleX: index < strength ? 1 : 0 }}\n transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n className={cn(\n \"block h-full w-full origin-left rounded-full\",\n STRENGTH_COLORS[strength],\n )}\n />\n </span>\n ))}\n </div>\n <p aria-live=\"polite\" className=\"text-muted-foreground text-xs\">\n Password strength: {STRENGTH_LABELS[strength]}\n </p>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </div>\n\n <Input\n label=\"Confirm password\"\n type={revealPassword ? \"text\" : \"password\"}\n autoComplete=\"new-password\"\n placeholder=\"Re-enter your password\"\n leftIcon={<Lock />}\n disabled={isSubmitting}\n value={values.confirmPassword}\n onChange={(next) => setValue(\"confirmPassword\", next)}\n onBlur={() => touch(\"confirmPassword\")}\n error={shownError(\"confirmPassword\")}\n success={isValid(\"confirmPassword\")}\n />\n </div>\n\n <div className={cn(\"flex flex-col gap-1.5\", classNames?.terms)}>\n <Checkbox\n checked={values.terms}\n disabled={isSubmitting}\n onCheckedChange={(next) => {\n setValue(\"terms\", next);\n touch(\"terms\");\n }}\n label=\"I agree to the Terms and Privacy Policy\"\n aria-describedby={shownError(\"terms\") ? termsErrorId : undefined}\n />\n <AnimatePresence initial={false}>\n {shownError(\"terms\") ? (\n <motion.p\n id={termsErrorId}\n role=\"alert\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4, filter: \"blur(4px)\" }}\n animate={{ opacity: 1, y: 0, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4, filter: \"blur(4px)\" }}\n transition={{ duration: 0.2 }}\n className=\"px-1 text-destructive text-xs\"\n >\n {shownError(\"terms\")}\n </motion.p>\n ) : null}\n </AnimatePresence>\n </div>\n\n <AnimatePresence initial={false}>\n {errorMessage ? (\n <motion.p\n id={formErrorId}\n role=\"alert\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n animate={{ opacity: 1, y: 0 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n transition={{ duration: 0.2 }}\n className=\"rounded-2xl border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive text-xs\"\n >\n {errorMessage}\n </motion.p>\n ) : null}\n </AnimatePresence>\n\n <StatefulButton\n type=\"submit\"\n size=\"lg\"\n state={status}\n loadingText=\"Creating account\"\n successText=\"Account created\"\n errorText=\"Try again\"\n aria-describedby={errorMessage ? formErrorId : undefined}\n className={cn(\"w-full\", classNames?.submit)}\n >\n {submitLabel}\n </StatefulButton>\n\n {footer ? (\n <div className={cn(\"text-center text-muted-foreground text-sm\", classNames?.footer)}>\n {footer}\n </div>\n ) : null}\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA2DA,MAAM,eAA6B;CACjC,MAAM;CACN,OAAO;CACP,UAAU;CACV,iBAAiB;CACjB,OAAO;AACT;AAIA,MAAM,gBAAgB;AAEtB,MAAM,sBAAsB;AAE5B,MAAM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AAG,GAAG;KAAG;KACpD,YAAY,EAAE,UAAU,GAAI;KAC5B,WAAU;KAET,UAAA;IACO,CAAA,IACR;GACW,CAAA;GAEjB,oBAAC,gBAAD;IACE,MAAK;IACL,MAAK;IACL,OAAO;IACP,aAAY;IACZ,aAAY;IACZ,WAAU;IACV,oBAAkB,eAAe,cAAc,KAAA;IAC/C,WAAW,GAAG,UAAU,YAAY,MAAM;IAEzC,UAAA;GACa,CAAA;GAEf,SACC,oBAAC,OAAD;IAAK,WAAW,GAAG,6CAA6C,YAAY,MAAM;IAC/E,UAAA;GACE,CAAA,IACH;EACA;;AAEV"}
@@ -1,7 +1,7 @@
1
1
  import { VariantProps } from "class-variance-authority";
2
2
  //#region src/components/reui/alert.d.ts
3
3
  declare const alertVariants: (props?: ({
4
- variant?: "default" | "destructive" | "info" | "success" | "warning" | "invert" | null | undefined;
4
+ variant?: "success" | "default" | "destructive" | "info" | "warning" | "invert" | null | undefined;
5
5
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
6
  declare function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): import("react").JSX.Element;
7
7
  declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
@@ -2,7 +2,7 @@ import { VariantProps } from "class-variance-authority";
2
2
  import { Autocomplete as Autocomplete$1 } from "@base-ui/react/autocomplete";
3
3
  //#region src/components/reui/autocomplete.d.ts
4
4
  declare const inputVariants: (props?: ({
5
- size?: "default" | "sm" | "lg" | null | undefined;
5
+ size?: "sm" | "default" | "lg" | null | undefined;
6
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
7
  declare const Autocomplete: typeof Autocomplete$1.Root;
8
8
  declare function AutocompleteValue({ ...props }: Autocomplete$1.Value.Props): import("react").JSX.Element;
@@ -2,8 +2,8 @@ import { VariantProps } from "class-variance-authority";
2
2
  import { useRender } from "@base-ui/react/use-render";
3
3
  //#region src/components/reui/badge.d.ts
4
4
  declare const badgeVariants: (props?: ({
5
- variant?: "default" | "destructive" | "info" | "success" | "warning" | "invert" | "outline" | "secondary" | "focus" | "primary-light" | "warning-light" | "success-light" | "info-light" | "destructive-light" | "invert-light" | "focus-light" | "primary-outline" | "warning-outline" | "success-outline" | "info-outline" | "destructive-outline" | "invert-outline" | "focus-outline" | null | undefined;
6
- size?: "default" | "sm" | "lg" | "xs" | "xl" | null | undefined;
5
+ variant?: "success" | "default" | "destructive" | "secondary" | "outline" | "info" | "warning" | "invert" | "focus" | "primary-light" | "warning-light" | "success-light" | "info-light" | "destructive-light" | "invert-light" | "focus-light" | "primary-outline" | "warning-outline" | "success-outline" | "info-outline" | "destructive-outline" | "invert-outline" | "focus-outline" | null | undefined;
6
+ size?: "sm" | "default" | "lg" | "xs" | "xl" | null | undefined;
7
7
  radius?: "default" | "full" | null | undefined;
8
8
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
9
9
  interface BadgeProps extends useRender.ComponentProps<"span"> {
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { Button } from "../../ui/button.js";
3
- import { Badge } from "../badge.js";
4
- import { Input } from "../../ui/input.js";
5
3
  import { Separator } from "../../ui/separator.js";
4
+ import { Input } from "../../ui/input.js";
6
5
  import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
6
+ import { Badge } from "../badge.js";
7
7
  import { useMemo, useState } from "react";
8
8
  import { cn } from "@kumix/utils";
9
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -65,8 +65,12 @@ declare const dataGridFeatures: {
65
65
  facetedRowModel: (table: Table<any, any>, columnId: string) => () => import("@tanstack/react-table").RowModel<any, any>;
66
66
  facetedUniqueValues: (table: Table<TableFeatures, any>, columnId: string) => () => Map<any, number>;
67
67
  sortFns: {
68
+ alphanumeric: import("@tanstack/react-table").CreatedSortFn<any, any>;
69
+ alphanumericCaseSensitive: import("@tanstack/react-table").CreatedSortFn<any, any>;
68
70
  basic: import("@tanstack/react-table").CreatedSortFn<any, any>;
71
+ datetime: import("@tanstack/react-table").CreatedSortFn<any, any>;
69
72
  text: import("@tanstack/react-table").CreatedSortFn<any, any>;
73
+ textCaseSensitive: import("@tanstack/react-table").CreatedSortFn<any, any>;
70
74
  };
71
75
  columnMeta: DataGridColumnMeta<any>;
72
76
  };
@@ -1 +1 @@
1
- {"version":3,"file":"data-grid.d.ts","names":[],"sources":["../../../../src/components/reui/data-grid/data-grid.tsx"],"mappings":";;;;;;;;;;;UAiDiB,mBAAmB;EAClC;EACA;EACA;EACA,WAAW;EACX,mBAAmB,KAAK,UAAU;EAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BW;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmCD,0BAA0B;;;;;;;;;;;KAY1B,sBAAsB,wBAAwB,WAAW,kBAAkB;;iBAGvE,qBAAqB,cAAc,SAAS,QAC1D,QAAQ,OAAO,kBAAkB,OAAO;KAS9B;EACV;EACA;EACA,UAAU;EACV,UAAU;EACV;;KAGU,oBAAoB;EAC9B,MAAM;EACN;EACA;IACE;IACA;;;;;;;;KASQ,oBAAoB,wBAAwB,KACtD,cAAc,eAAe;UAId,qBAAqB;EACpC,OAAO,oBAAoB;EAC3B,OAAO,sBAAsB;EAC7B;EACA;;;;;EAKA,WAAW;;KAGD;;;;;;EAMV,QAAQ;;KA8EE;EACV;EACA;EACA,UAAU;EACV,gBAAgB;;UAGD,cAAc,kBAAkB,eAAe;EAC9D;EACA,QAAQ,MAAM,WAAW;EACzB;EACA,WAAW;EACX,cAAc,KAAK;EACnB;EACA;EACA,iBAAiB;EACjB,sBAAsB;EACtB,uBAAuB;EACvB,eAAe;EACf;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEF;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;;;;;;;iBAeK,YAEP,+BACG,qBAAqB;iBAQjB,iBAAiB,wBACxB,UACA,UACG,SACF,oBAAoB;EACrB,OAAO,sBAAsB;EAC7B,WAAW;oBACZ,IAAA;iBAwEQ,SAAS,kBAAkB,eAAe,wBACjD,UACA,UACG,SACF,cAAc,WAAW,yBAAM,IAAA;iBAuEzB,oBACP,UACA;EAEA,UAAU;EACV;;EAEA;oBACD,IAAA"}
1
+ {"version":3,"file":"data-grid.d.ts","names":[],"sources":["../../../../src/components/reui/data-grid/data-grid.tsx"],"mappings":";;;;;;;;;;;UAqDiB,mBAAmB;EAClC;EACA;EACA;EACA,WAAW;EACX,mBAAmB,KAAK,UAAU;EAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2CD,0BAA0B;;;;;;;;;;;KAY1B,sBAAsB,wBAAwB,WAAW,kBAAkB;;iBAGvE,qBAAqB,cAAc,SAAS,QAC1D,QAAQ,OAAO,kBAAkB,OAAO;KAS9B;EACV;EACA;EACA,UAAU;EACV,UAAU;EACV;;KAGU,oBAAoB;EAC9B,MAAM;EACN;EACA;IACE;IACA;;;;;;;;KASQ,oBAAoB,wBAAwB,KACtD,cAAc,eAAe;UAId,qBAAqB;EACpC,OAAO,oBAAoB;EAC3B,OAAO,sBAAsB;EAC7B;EACA;;;;;EAKA,WAAW;;KAGD;;;;;;EAMV,QAAQ;;KA8EE;EACV;EACA;EACA,UAAU;EACV,gBAAgB;;UAGD,cAAc,kBAAkB,eAAe;EAC9D;EACA,QAAQ,MAAM,WAAW;EACzB;EACA,WAAW;EACX,cAAc,KAAK;EACnB;EACA;EACA,iBAAiB;EACjB,sBAAsB;EACtB,uBAAuB;EACvB,eAAe;EACf;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAEF;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;;;;;;;iBAeK,YAEP,+BACG,qBAAqB;iBAQjB,iBAAiB,wBACxB,UACA,UACG,SACF,oBAAoB;EACrB,OAAO,sBAAsB;EAC7B,WAAW;oBACZ,IAAA;iBAwEQ,SAAS,kBAAkB,eAAe,wBACjD,UACA,UACG,SACF,cAAc,WAAW,yBAAM,IAAA;iBAuEzB,oBACP,UACA;EAEA,UAAU;EACV;;EAEA;oBACD,IAAA"}
@@ -2,7 +2,7 @@
2
2
  import { createContext, useContext, useEffect, useMemo, useRef } from "react";
3
3
  import { cn } from "@kumix/utils";
4
4
  import { jsx } from "react/jsx-runtime";
5
- import { columnFacetingFeature, columnFilteringFeature, columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnSizingFeature, columnVisibilityFeature, createExpandedRowModel, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, globalFilteringFeature, metaHelper, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, sortFn_basic, sortFn_text, tableFeatures } from "@tanstack/react-table";
5
+ import { columnFacetingFeature, columnFilteringFeature, columnOrderingFeature, columnPinningFeature, columnResizingFeature, columnSizingFeature, columnVisibilityFeature, createExpandedRowModel, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, globalFilteringFeature, metaHelper, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, tableFeatures } from "@tanstack/react-table";
6
6
  //#region src/components/reui/data-grid/data-grid.tsx
7
7
  /**
8
8
  * The batteries-included feature bundle every ReUI data-grid example builds
@@ -52,8 +52,12 @@ const dataGridFeatures = tableFeatures({
52
52
  facetedRowModel: createFacetedRowModel(),
53
53
  facetedUniqueValues: createFacetedUniqueValues(),
54
54
  sortFns: {
55
+ alphanumeric: sortFn_alphanumeric,
56
+ alphanumericCaseSensitive: sortFn_alphanumericCaseSensitive,
55
57
  basic: sortFn_basic,
56
- text: sortFn_text
58
+ datetime: sortFn_datetime,
59
+ text: sortFn_text,
60
+ textCaseSensitive: sortFn_textCaseSensitive
57
61
  },
58
62
  columnMeta: metaHelper()
59
63
  });
@@ -1 +1 @@
1
- {"version":3,"file":"data-grid.js","names":["internalTable","internalProps"],"sources":["../../../../src/components/reui/data-grid/data-grid.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { createContext, useContext, useEffect, useMemo, useRef } from \"react\";\nimport type {\n Column,\n ColumnFiltersState,\n ReactTable,\n RowData,\n SortingState,\n Table,\n TableFeatures,\n} from \"@tanstack/react-table\";\nimport {\n columnFacetingFeature,\n columnFilteringFeature,\n columnOrderingFeature,\n columnPinningFeature,\n columnResizingFeature,\n columnSizingFeature,\n columnVisibilityFeature,\n createExpandedRowModel,\n createFacetedRowModel,\n createFacetedUniqueValues,\n createFilteredRowModel,\n createPaginatedRowModel,\n createSortedRowModel,\n globalFilteringFeature,\n metaHelper,\n rowExpandingFeature,\n rowPaginationFeature,\n rowPinningFeature,\n rowSelectionFeature,\n rowSortingFeature,\n sortFn_basic,\n sortFn_text,\n tableFeatures,\n} from \"@tanstack/react-table\";\n\nimport { cn } from \"@kumix/utils\";\n\n/**\n * Per-column extras the grid reads off `columnDef.meta`.\n *\n * TanStack v9 resolves this through the `columnMeta` slot on the feature\n * bundle below instead of a global `declare module` augmentation, so\n * installing the data grid no longer widens `ColumnMeta` for every other\n * table in the consuming app.\n */\nexport interface DataGridColumnMeta<TData> {\n headerTitle?: string;\n headerClassName?: string;\n cellClassName?: string;\n skeleton?: ReactNode;\n expandedContent?: (row: TData) => ReactNode;\n autoSize?: boolean;\n}\n\n/**\n * The batteries-included feature bundle every ReUI data-grid example builds\n * on. v9 requires each table to declare its features up front, and the grid's\n * render path needs the ones registered here: `columnVisibilityFeature` alone\n * gates `row.getVisibleCells()`, so even a grid that never hides a column\n * needs it to render at all.\n *\n * Pass it straight through for the full grid:\n *\n * ```tsx\n * const table = useTable({ features: dataGridFeatures, columns, data })\n * ```\n *\n * Extend it when a grid needs more, keeping each prerequisite feature ahead of\n * the slot that depends on it:\n *\n * ```tsx\n * const features = tableFeatures({\n * ...dataGridFeatures,\n * columnGroupingFeature,\n * groupedRowModel: createGroupedRowModel(),\n * })\n * ```\n *\n * Or drop it entirely and hand `<DataGrid>` a leaner table - the components\n * accept any bundle, so you keep full ownership of the TanStack core.\n */\nexport const dataGridFeatures = tableFeatures({\n columnVisibilityFeature,\n columnOrderingFeature,\n columnPinningFeature,\n columnSizingFeature,\n // columnResizingFeature requires columnSizingFeature, declared above.\n columnResizingFeature,\n columnFilteringFeature,\n // Powers DataGridColumnFilter's column.getFacetedUniqueValues(). On v8 an\n // unregistered facet silently returned an empty map; on v9 the method would\n // not exist at all, so the faceted row models below are required, not\n // optional.\n columnFacetingFeature,\n // globalFilteringFeature requires columnFilteringFeature, declared above.\n globalFilteringFeature,\n rowSortingFeature,\n rowPaginationFeature,\n rowSelectionFeature,\n rowExpandingFeature,\n rowPinningFeature,\n sortedRowModel: createSortedRowModel(),\n filteredRowModel: createFilteredRowModel(),\n paginatedRowModel: createPaginatedRowModel(),\n expandedRowModel: createExpandedRowModel(),\n facetedRowModel: createFacetedRowModel(),\n facetedUniqueValues: createFacetedUniqueValues(),\n // Only the built-ins the registry names by string. v9 resolves string\n // sortFn names against this map alone, and registering them one by one\n // keeps every other built-in out of the bundle.\n sortFns: { basic: sortFn_basic, text: sortFn_text },\n // biome-ignore lint/suspicious/noExplicitAny: <>\n columnMeta: metaHelper<DataGridColumnMeta<any>>(),\n});\n\n/** The feature set `dataGridFeatures` registers. */\nexport type DataGridFeatures = typeof dataGridFeatures;\n\n/**\n * The grid's internal view of the table.\n *\n * `TFeatures` is invariant in v9 and an unresolved generic one collapses to a\n * union that includes the bare core arm, so no generic signature can call\n * `getVisibleCells()`, `getStartVisibleLeafColumns()` and friends. The public\n * components stay generic so consumers can pass any bundle they like; the\n * table is widened to this concrete type exactly once, on the way into\n * context, and every internal component reads it from there.\n */\nexport type DataGridTableInstance<TData extends object> = ReactTable<DataGridFeatures, TData>;\n\n/** Label for headers / column visibility: `meta.headerTitle`, string `columnDef.header`, or `column.id`. */\nexport function getColumnHeaderLabel<TData extends RowData, TValue>(\n column: Column<DataGridFeatures, TData, TValue>,\n): string {\n const meta = column.columnDef.meta as { headerTitle?: string } | undefined;\n if (typeof meta?.headerTitle === \"string\") return meta.headerTitle;\n const defHeader = column.columnDef.header;\n if (typeof defHeader === \"string\") return defHeader;\n return String(column.id);\n}\n\nexport type DataGridApiFetchParams = {\n pageIndex: number;\n pageSize: number;\n sorting?: SortingState;\n filters?: ColumnFiltersState;\n searchQuery?: string;\n};\n\nexport type DataGridApiResponse<T> = {\n data: T[];\n empty: boolean;\n pagination: {\n total: number;\n page: number;\n };\n};\n\n/**\n * Everything `<DataGrid>` accepts except the two props the provider consumes\n * itself. Kept feature-agnostic: layout and messaging never depend on which\n * TanStack features the consumer registered.\n */\nexport type DataGridLayoutProps<TData extends object> = Omit<\n DataGridProps<TableFeatures, TData>,\n \"table\" | \"children\"\n>;\n\nexport interface DataGridContextProps<TData extends object> {\n props: DataGridLayoutProps<TData>;\n table: DataGridTableInstance<TData>;\n recordCount: number;\n isLoading: boolean;\n /**\n * Internal coordinator for `meta.autoSize` columns. Lives at the core level\n * so every table variant and viewport instance shares one application state.\n */\n autoSize?: DataGridAutoSizeController;\n}\n\nexport type DataGridAutoSizeController = {\n /**\n * Grows the first visible `meta.autoSize` column by the given free space.\n * Applies at most once per column id; safe to call from every viewport\n * measurement. Returns true when a sizing update was dispatched.\n */\n apply: (fillWidth: number) => boolean;\n};\n\nfunction createDataGridAutoSizeController<TData extends object>(\n /**\n * A getter, not the table itself.\n *\n * v8 handed back one stable table whose state mutated in place, so a\n * controller could close over it. v9 returns a NEW table wrapper on every\n * state change, and a captured one keeps reporting the state it was built\n * with - here that meant `columnSizing` looked permanently empty, the\n * applied-once guard re-armed on every measurement, and the fill overwrote\n * whatever width the user had just dragged the column to.\n */\n getTable: () => DataGridTableInstance<TData>,\n): DataGridAutoSizeController {\n let applied: { columnId: string; base: number; grown: number } | null = null;\n\n return {\n apply(fillWidth: number) {\n const table = getTable();\n const columnSizing = table.state.columnSizing;\n\n // Re-arm after reset flows (double-click resetSize, resetColumnSizing,\n // controlled state replacement) so the column re-fills instead of\n // leaving a dead blank strip.\n if (applied && columnSizing[applied.columnId] === undefined) {\n applied = null;\n }\n\n if (fillWidth <= 0) return false;\n\n const autoSizeColumn = table\n .getVisibleLeafColumns()\n .find((column) => column.columnDef.meta?.autoSize && column.getCanResize());\n\n if (!autoSizeColumn || applied?.columnId === autoSizeColumn.id) {\n return false;\n }\n\n // A width this coordinator did not write belongs to someone else -\n // almost always the user, who just dragged the column's resize handle.\n // Filling over it is what made a `meta.autoSize` column look\n // un-resizable: the drag committed, the next viewport measurement\n // stamped the fill back on top, and the column snapped to its old width.\n //\n // Deliberately keyed on observed state rather than on `applied`, which\n // is per-coordinator memory: anything that rebuilds the coordinator\n // (a remount, a new table store) forgets what it did, and the guard has\n // to survive that. An explicit reset clears the entry and re-arms the\n // fill, which is what makes double-click-to-reset still work.\n const currentSize = columnSizing[autoSizeColumn.id];\n if (currentSize !== undefined && currentSize !== applied?.grown) {\n return false;\n }\n\n // Candidate switched (e.g. the grown column was hidden and another\n // meta.autoSize column took over): revert the previous growth if the\n // user hasn't manually resized that column since, so visibility\n // toggles cannot ratchet the table wider than its container forever.\n const revert = applied && columnSizing[applied.columnId] === applied.grown ? applied : null;\n const base = columnSizing[autoSizeColumn.id] ?? autoSizeColumn.getSize();\n const grown = base + fillWidth;\n\n applied = { columnId: autoSizeColumn.id, base, grown };\n table.setColumnSizing((old) => {\n const next = { ...old, [autoSizeColumn.id]: grown };\n if (revert && next[revert.columnId] === revert.grown) {\n next[revert.columnId] = revert.base;\n }\n return next;\n });\n\n return true;\n },\n };\n}\n\nexport type DataGridRequestParams = {\n pageIndex: number;\n pageSize: number;\n sorting?: SortingState;\n columnFilters?: ColumnFiltersState;\n};\n\nexport interface DataGridProps<TFeatures extends TableFeatures, TData extends object> {\n className?: string;\n table?: Table<TFeatures, TData>;\n recordCount: number;\n children?: ReactNode;\n onRowClick?: (row: TData) => void;\n isLoading?: boolean;\n loadingMode?: \"skeleton\" | \"spinner\";\n loadingMessage?: ReactNode | string;\n fetchingMoreMessage?: ReactNode | string;\n allRowsLoadedMessage?: ReactNode | string;\n emptyMessage?: ReactNode | string;\n tableLayout?: {\n dense?: boolean;\n cellBorder?: boolean;\n rowBorder?: boolean;\n rowRounded?: boolean;\n stripped?: boolean;\n headerBackground?: boolean;\n footerBackground?: boolean;\n headerBorder?: boolean;\n headerSticky?: boolean;\n width?: \"auto\" | \"fixed\";\n columnsVisibility?: boolean;\n columnsResizable?: boolean;\n columnsResizeMode?: \"onChange\" | \"onEnd\";\n columnsPinnable?: boolean;\n columnsMovable?: boolean;\n columnsDraggable?: boolean;\n rowsDraggable?: boolean;\n rowsPinnable?: boolean;\n };\n tableClassNames?: {\n base?: string;\n header?: string;\n headerRow?: string;\n headerSticky?: string;\n body?: string;\n bodyRow?: string;\n footer?: string;\n edgeCell?: string;\n };\n}\n\nconst DataGridContext = createContext<\n // biome-ignore lint/suspicious/noExplicitAny: <>\n DataGridContextProps<any> | undefined\n>(undefined);\n\n/**\n * Reads the grid context. Pass `TData` from the calling component when the\n * table, a row or a cell is handed on to something typed against that row\n * shape: v9 declares `TData` invariant, so the default `any` no longer\n * unifies with a concrete row type the way it did on v8.\n */\nfunction useDataGrid<\n // biome-ignore lint/suspicious/noExplicitAny: <>\n TData extends object = any,\n>(): DataGridContextProps<TData> {\n const context = useContext(DataGridContext) as DataGridContextProps<TData> | undefined;\n if (!context) {\n throw new Error(\"useDataGrid must be used within a DataGridProvider\");\n }\n return context;\n}\n\nfunction DataGridProvider<TData extends object>({\n children,\n table,\n ...props\n}: DataGridLayoutProps<TData> & {\n table: DataGridTableInstance<TData>;\n children?: ReactNode;\n}) {\n // Latest-props ref: context reads always resolve fresh props through the\n // getter below without the memoized context value depending on unstable\n // ReactNode/function prop identities (inline emptyMessage/onRowClick would\n // otherwise publish a new context value on every consumer render - at\n // mousemove rate during a resize drag, piercing the body-rows memo).\n const propsRef = useRef(props);\n propsRef.current = props;\n\n // Same treatment for the table itself, which v9 - unlike v8 - re-creates on\n // every state change. Depending on it directly would republish the context\n // on each resize tick, which is exactly what the memo below exists to\n // prevent; the getter still hands every consumer the current instance.\n const tableRef = useRef(table);\n tableRef.current = table;\n\n // Re-assert an explicit tableLayout resize mode so consumer-level useTable\n // options cannot flip it back between drags. v9 makes `table.options`\n // readonly, so this goes through setOptions in an effect rather than a\n // render-phase mutation. Without an explicit mode, the consumer's own\n // tanstack columnResizeMode (default \"onEnd\") is honored.\n const resizeMode =\n props.tableLayout?.columnsResizable && props.tableLayout.columnsResizeMode\n ? props.tableLayout.columnsResizeMode\n : undefined;\n\n useEffect(() => {\n if (!resizeMode) return;\n if (table.options.columnResizeMode === resizeMode) return;\n table.setOptions((old) => ({ ...old, columnResizeMode: resizeMode }));\n }, [table, resizeMode]);\n\n // One autoSize coordinator per table instance so split header/body viewports\n // cannot apply the growth twice. Keyed on `table.store`, which v9 keeps\n // stable for the life of the table, rather than on `table` itself: the\n // wrapper is re-created on every state change, and re-creating the\n // controller with it would reset its applied-once bookkeeping mid-drag.\n const autoSize = useMemo(() => createDataGridAutoSizeController(() => tableRef.current), []);\n\n // Memoize context value so consumers don't re-render during column resize.\n // Column sizing state is intentionally excluded from deps -- CSS variables\n // on the <table> element handle width updates without React re-renders.\n // ReactNode/function props (messages, onRowClick) are also excluded: they\n // are served fresh through the props getter, so unstable inline identities\n // cannot invalidate the context value.\n const value = useMemo(\n () => ({\n get props() {\n return propsRef.current;\n },\n get table() {\n return tableRef.current;\n },\n recordCount: props.recordCount,\n isLoading: props.isLoading || false,\n autoSize,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [autoSize, props.recordCount, props.isLoading],\n );\n\n return (\n // One React context serves every TData, but v9 declares both TFeatures and\n // TData invariant, so a `DataGridContextProps<any>` context cannot accept a\n // `DataGridContextProps<TData>` value structurally. The erasure happens\n // here and is undone by the TData generic on each consumer component.\n <DataGridContext.Provider value={value as unknown as DataGridContextProps<TData>}>\n {children}\n </DataGridContext.Provider>\n );\n}\n\nfunction DataGrid<TFeatures extends TableFeatures, TData extends object>({\n children,\n table,\n ...props\n}: DataGridProps<TFeatures, TData>) {\n const defaultProps: Partial<DataGridProps<TFeatures, TData>> = {\n loadingMode: \"skeleton\",\n tableLayout: {\n dense: false,\n cellBorder: false,\n rowBorder: true,\n rowRounded: false,\n stripped: false,\n headerSticky: false,\n headerBackground: false,\n footerBackground: false,\n headerBorder: true,\n width: \"fixed\",\n columnsVisibility: false,\n columnsResizable: false,\n // columnsResizeMode has no default on purpose: when unset, the\n // consumer's tanstack columnResizeMode (default \"onEnd\") is honored.\n columnsPinnable: false,\n columnsMovable: false,\n columnsDraggable: false,\n rowsDraggable: false,\n rowsPinnable: false,\n },\n tableClassNames: {\n base: \"\",\n header: \"\",\n headerRow: \"\",\n // z-40 keeps the sticky header above pinned body cells (zIndex 30 in\n // getPinningStyles), which would otherwise paint over it while\n // scrolling vertically with columnsPinnable enabled.\n headerSticky: \"sticky top-0 z-40 bg-background/90 backdrop-blur-xs\",\n body: \"\",\n bodyRow: \"\",\n footer: \"\",\n edgeCell: \"\",\n },\n };\n\n const mergedProps: DataGridProps<TFeatures, TData> = {\n ...defaultProps,\n ...props,\n tableLayout: {\n ...defaultProps.tableLayout,\n ...(props.tableLayout || {}),\n },\n tableClassNames: {\n ...defaultProps.tableClassNames,\n ...(props.tableClassNames || {}),\n },\n };\n\n // Ensure table is provided\n if (!table) {\n throw new Error('DataGrid requires a \"table\" prop');\n }\n\n // The single widening point. Consumers own the TanStack core and may hand\n // over any feature bundle; internals need a concrete one to resolve the\n // feature-gated APIs they call, and v9's invariant TFeatures rules out\n // expressing that with a generic constraint.\n const internalTable = table as unknown as DataGridTableInstance<TData>;\n const internalProps = mergedProps as unknown as DataGridLayoutProps<TData>;\n\n return (\n <DataGridProvider table={internalTable} {...internalProps}>\n {children}\n </DataGridProvider>\n );\n}\n\nfunction DataGridContainer({\n children,\n className,\n}: {\n children: ReactNode;\n className?: string;\n /** Accepted for backwards compatibility; currently has no effect. */\n border?: boolean;\n}) {\n return (\n <div data-slot=\"data-grid\" className={cn(\"w-full overflow-hidden\", className)}>\n {children}\n </div>\n );\n}\n\nexport { DataGrid, DataGridContainer, DataGridProvider, useDataGrid };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,MAAa,mBAAmB,cAAc;CAC5C;CACA;CACA;CACA;CAEA;CACA;CAKA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA,gBAAgB,qBAAqB;CACrC,kBAAkB,uBAAuB;CACzC,mBAAmB,wBAAwB;CAC3C,kBAAkB,uBAAuB;CACzC,iBAAiB,sBAAsB;CACvC,qBAAqB,0BAA0B;CAI/C,SAAS;EAAE,OAAO;EAAc,MAAM;CAAY;CAElD,YAAY,WAAoC;AAClD,CAAC;;AAkBD,SAAgB,qBACd,QACQ;CACR,MAAM,OAAO,OAAO,UAAU;CAC9B,IAAI,OAAO,MAAM,gBAAgB,UAAU,OAAO,KAAK;CACvD,MAAM,YAAY,OAAO,UAAU;CACnC,IAAI,OAAO,cAAc,UAAU,OAAO;CAC1C,OAAO,OAAO,OAAO,EAAE;AACzB;AAkDA,SAAS,iCAWP,UAC4B;CAC5B,IAAI,UAAoE;CAExE,OAAO,EACL,MAAM,WAAmB;EACvB,MAAM,QAAQ,SAAS;EACvB,MAAM,eAAe,MAAM,MAAM;EAKjC,IAAI,WAAW,aAAa,QAAQ,cAAc,KAAA,GAChD,UAAU;EAGZ,IAAI,aAAa,GAAG,OAAO;EAE3B,MAAM,iBAAiB,MACpB,sBAAsB,CAAC,CACvB,MAAM,WAAW,OAAO,UAAU,MAAM,YAAY,OAAO,aAAa,CAAC;EAE5E,IAAI,C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;EACA,IAAI,QAAQ;GACV,OAAO,SAAS;EAClB;EACA,aAAa,MAAM;EACnB,WAAW,MAAM,aAAa;EAC9B;CACF,IAEA;EAAC;EAAU,MAAM;EAAa,MAAM;CAAS,CAC/C;CAEA,OAKE,oBAAC,gBAAgB,UAAjB;EAAiC;EAC9B;CACuB,CAAA;AAE9B;AAEA,SAAS,SAAgE,EACvE,UACA,OACA,GAAG,SAC+B;CAClC,MAAM,eAAyD;EAC7D,aAAa;EACb,aAAa;GACX,OAAO;GACP,YAAY;GACZ,WAAW;GACX,YAAY;GACZ,UAAU;GACV,cAAc;GACd,kBAAkB;GAClB,kBAAkB;GAClB,cAAc;GACd,OAAO;GACP,mBAAmB;GACnB,kBAAkB;GAGlB,iBAAiB;GACjB,gBAAgB;GAChB,kBAAkB;GAClB,eAAe;GACf,cAAc;EAChB;EACA,iBAAiB;GACf,MAAM;GACN,QAAQ;GACR,WAAW;GAIX,cAAc;GACd,MAAM;GACN,SAAS;GACT,QAAQ;GACR,UAAU;EACZ;CACF;CAEA,MAAM,cAA+C;EACnD,GAAG;EACH,GAAG;EACH,aAAa;GACX,GAAG,aAAa;GAChB,GAAI,MAAM,eAAe,CAAC;EAC5B;EACA,iBAAiB;GACf,GAAG,aAAa;GAChB,GAAI,MAAM,mBAAmB,CAAC;EAChC;CACF;CAGA,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,oCAAkC;CAUpD,OACE,oBAAC,kBAAD;EAAyBA;EAAe,GAAIC;EACzC;CACe,CAAA;AAEtB;AAEA,SAAS,kBAAkB,EACzB,UACA,aAMC;CACD,OACE,oBAAC,OAAD;EAAK,aAAU;EAAY,WAAW,GAAG,0BAA0B,SAAS;EACzE;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"data-grid.js","names":["internalTable","internalProps"],"sources":["../../../../src/components/reui/data-grid/data-grid.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { createContext, useContext, useEffect, useMemo, useRef } from \"react\";\nimport type {\n Column,\n ColumnFiltersState,\n ReactTable,\n RowData,\n SortingState,\n Table,\n TableFeatures,\n} from \"@tanstack/react-table\";\nimport {\n columnFacetingFeature,\n columnFilteringFeature,\n columnOrderingFeature,\n columnPinningFeature,\n columnResizingFeature,\n columnSizingFeature,\n columnVisibilityFeature,\n createExpandedRowModel,\n createFacetedRowModel,\n createFacetedUniqueValues,\n createFilteredRowModel,\n createPaginatedRowModel,\n createSortedRowModel,\n globalFilteringFeature,\n metaHelper,\n rowExpandingFeature,\n rowPaginationFeature,\n rowPinningFeature,\n rowSelectionFeature,\n rowSortingFeature,\n sortFn_alphanumeric,\n sortFn_alphanumericCaseSensitive,\n sortFn_basic,\n sortFn_datetime,\n sortFn_text,\n sortFn_textCaseSensitive,\n tableFeatures,\n} from \"@tanstack/react-table\";\n\nimport { cn } from \"@kumix/utils\";\n\n/**\n * Per-column extras the grid reads off `columnDef.meta`.\n *\n * TanStack v9 resolves this through the `columnMeta` slot on the feature\n * bundle below instead of a global `declare module` augmentation, so\n * installing the data grid no longer widens `ColumnMeta` for every other\n * table in the consuming app.\n */\nexport interface DataGridColumnMeta<TData> {\n headerTitle?: string;\n headerClassName?: string;\n cellClassName?: string;\n skeleton?: ReactNode;\n expandedContent?: (row: TData) => ReactNode;\n autoSize?: boolean;\n}\n\n/**\n * The batteries-included feature bundle every ReUI data-grid example builds\n * on. v9 requires each table to declare its features up front, and the grid's\n * render path needs the ones registered here: `columnVisibilityFeature` alone\n * gates `row.getVisibleCells()`, so even a grid that never hides a column\n * needs it to render at all.\n *\n * Pass it straight through for the full grid:\n *\n * ```tsx\n * const table = useTable({ features: dataGridFeatures, columns, data })\n * ```\n *\n * Extend it when a grid needs more, keeping each prerequisite feature ahead of\n * the slot that depends on it:\n *\n * ```tsx\n * const features = tableFeatures({\n * ...dataGridFeatures,\n * columnGroupingFeature,\n * groupedRowModel: createGroupedRowModel(),\n * })\n * ```\n *\n * Or drop it entirely and hand `<DataGrid>` a leaner table - the components\n * accept any bundle, so you keep full ownership of the TanStack core.\n */\nexport const dataGridFeatures = tableFeatures({\n columnVisibilityFeature,\n columnOrderingFeature,\n columnPinningFeature,\n columnSizingFeature,\n // columnResizingFeature requires columnSizingFeature, declared above.\n columnResizingFeature,\n columnFilteringFeature,\n // Powers DataGridColumnFilter's column.getFacetedUniqueValues(). On v8 an\n // unregistered facet silently returned an empty map; on v9 the method would\n // not exist at all, so the faceted row models below are required, not\n // optional.\n columnFacetingFeature,\n // globalFilteringFeature requires columnFilteringFeature, declared above.\n globalFilteringFeature,\n rowSortingFeature,\n rowPaginationFeature,\n rowSelectionFeature,\n rowExpandingFeature,\n rowPinningFeature,\n sortedRowModel: createSortedRowModel(),\n filteredRowModel: createFilteredRowModel(),\n paginatedRowModel: createPaginatedRowModel(),\n expandedRowModel: createExpandedRowModel(),\n facetedRowModel: createFacetedRowModel(),\n facetedUniqueValues: createFacetedUniqueValues(),\n // Every built-in v9 ships. A string `sortFn` resolves against this map\n // alone, and `sortFn: \"auto\"` infers a name (\"alphanumeric\", \"text\" or\n // \"datetime\") from the first row's value - so a partial map makes auto\n // sorting warn and silently fall back on ordinary string columns.\n sortFns: {\n alphanumeric: sortFn_alphanumeric,\n alphanumericCaseSensitive: sortFn_alphanumericCaseSensitive,\n basic: sortFn_basic,\n datetime: sortFn_datetime,\n text: sortFn_text,\n textCaseSensitive: sortFn_textCaseSensitive,\n },\n // biome-ignore lint/suspicious/noExplicitAny: <>\n columnMeta: metaHelper<DataGridColumnMeta<any>>(),\n});\n\n/** The feature set `dataGridFeatures` registers. */\nexport type DataGridFeatures = typeof dataGridFeatures;\n\n/**\n * The grid's internal view of the table.\n *\n * `TFeatures` is invariant in v9 and an unresolved generic one collapses to a\n * union that includes the bare core arm, so no generic signature can call\n * `getVisibleCells()`, `getStartVisibleLeafColumns()` and friends. The public\n * components stay generic so consumers can pass any bundle they like; the\n * table is widened to this concrete type exactly once, on the way into\n * context, and every internal component reads it from there.\n */\nexport type DataGridTableInstance<TData extends object> = ReactTable<DataGridFeatures, TData>;\n\n/** Label for headers / column visibility: `meta.headerTitle`, string `columnDef.header`, or `column.id`. */\nexport function getColumnHeaderLabel<TData extends RowData, TValue>(\n column: Column<DataGridFeatures, TData, TValue>,\n): string {\n const meta = column.columnDef.meta as { headerTitle?: string } | undefined;\n if (typeof meta?.headerTitle === \"string\") return meta.headerTitle;\n const defHeader = column.columnDef.header;\n if (typeof defHeader === \"string\") return defHeader;\n return String(column.id);\n}\n\nexport type DataGridApiFetchParams = {\n pageIndex: number;\n pageSize: number;\n sorting?: SortingState;\n filters?: ColumnFiltersState;\n searchQuery?: string;\n};\n\nexport type DataGridApiResponse<T> = {\n data: T[];\n empty: boolean;\n pagination: {\n total: number;\n page: number;\n };\n};\n\n/**\n * Everything `<DataGrid>` accepts except the two props the provider consumes\n * itself. Kept feature-agnostic: layout and messaging never depend on which\n * TanStack features the consumer registered.\n */\nexport type DataGridLayoutProps<TData extends object> = Omit<\n DataGridProps<TableFeatures, TData>,\n \"table\" | \"children\"\n>;\n\nexport interface DataGridContextProps<TData extends object> {\n props: DataGridLayoutProps<TData>;\n table: DataGridTableInstance<TData>;\n recordCount: number;\n isLoading: boolean;\n /**\n * Internal coordinator for `meta.autoSize` columns. Lives at the core level\n * so every table variant and viewport instance shares one application state.\n */\n autoSize?: DataGridAutoSizeController;\n}\n\nexport type DataGridAutoSizeController = {\n /**\n * Grows the first visible `meta.autoSize` column by the given free space.\n * Applies at most once per column id; safe to call from every viewport\n * measurement. Returns true when a sizing update was dispatched.\n */\n apply: (fillWidth: number) => boolean;\n};\n\nfunction createDataGridAutoSizeController<TData extends object>(\n /**\n * A getter, not the table itself.\n *\n * v8 handed back one stable table whose state mutated in place, so a\n * controller could close over it. v9 returns a NEW table wrapper on every\n * state change, and a captured one keeps reporting the state it was built\n * with - here that meant `columnSizing` looked permanently empty, the\n * applied-once guard re-armed on every measurement, and the fill overwrote\n * whatever width the user had just dragged the column to.\n */\n getTable: () => DataGridTableInstance<TData>,\n): DataGridAutoSizeController {\n let applied: { columnId: string; base: number; grown: number } | null = null;\n\n return {\n apply(fillWidth: number) {\n const table = getTable();\n const columnSizing = table.state.columnSizing;\n\n // Re-arm after reset flows (double-click resetSize, resetColumnSizing,\n // controlled state replacement) so the column re-fills instead of\n // leaving a dead blank strip.\n if (applied && columnSizing[applied.columnId] === undefined) {\n applied = null;\n }\n\n if (fillWidth <= 0) return false;\n\n const autoSizeColumn = table\n .getVisibleLeafColumns()\n .find((column) => column.columnDef.meta?.autoSize && column.getCanResize());\n\n if (!autoSizeColumn || applied?.columnId === autoSizeColumn.id) {\n return false;\n }\n\n // A width this coordinator did not write belongs to someone else -\n // almost always the user, who just dragged the column's resize handle.\n // Filling over it is what made a `meta.autoSize` column look\n // un-resizable: the drag committed, the next viewport measurement\n // stamped the fill back on top, and the column snapped to its old width.\n //\n // Deliberately keyed on observed state rather than on `applied`, which\n // is per-coordinator memory: anything that rebuilds the coordinator\n // (a remount, a new table store) forgets what it did, and the guard has\n // to survive that. An explicit reset clears the entry and re-arms the\n // fill, which is what makes double-click-to-reset still work.\n const currentSize = columnSizing[autoSizeColumn.id];\n if (currentSize !== undefined && currentSize !== applied?.grown) {\n return false;\n }\n\n // Candidate switched (e.g. the grown column was hidden and another\n // meta.autoSize column took over): revert the previous growth if the\n // user hasn't manually resized that column since, so visibility\n // toggles cannot ratchet the table wider than its container forever.\n const revert = applied && columnSizing[applied.columnId] === applied.grown ? applied : null;\n const base = columnSizing[autoSizeColumn.id] ?? autoSizeColumn.getSize();\n const grown = base + fillWidth;\n\n applied = { columnId: autoSizeColumn.id, base, grown };\n table.setColumnSizing((old) => {\n const next = { ...old, [autoSizeColumn.id]: grown };\n if (revert && next[revert.columnId] === revert.grown) {\n next[revert.columnId] = revert.base;\n }\n return next;\n });\n\n return true;\n },\n };\n}\n\nexport type DataGridRequestParams = {\n pageIndex: number;\n pageSize: number;\n sorting?: SortingState;\n columnFilters?: ColumnFiltersState;\n};\n\nexport interface DataGridProps<TFeatures extends TableFeatures, TData extends object> {\n className?: string;\n table?: Table<TFeatures, TData>;\n recordCount: number;\n children?: ReactNode;\n onRowClick?: (row: TData) => void;\n isLoading?: boolean;\n loadingMode?: \"skeleton\" | \"spinner\";\n loadingMessage?: ReactNode | string;\n fetchingMoreMessage?: ReactNode | string;\n allRowsLoadedMessage?: ReactNode | string;\n emptyMessage?: ReactNode | string;\n tableLayout?: {\n dense?: boolean;\n cellBorder?: boolean;\n rowBorder?: boolean;\n rowRounded?: boolean;\n stripped?: boolean;\n headerBackground?: boolean;\n footerBackground?: boolean;\n headerBorder?: boolean;\n headerSticky?: boolean;\n width?: \"auto\" | \"fixed\";\n columnsVisibility?: boolean;\n columnsResizable?: boolean;\n columnsResizeMode?: \"onChange\" | \"onEnd\";\n columnsPinnable?: boolean;\n columnsMovable?: boolean;\n columnsDraggable?: boolean;\n rowsDraggable?: boolean;\n rowsPinnable?: boolean;\n };\n tableClassNames?: {\n base?: string;\n header?: string;\n headerRow?: string;\n headerSticky?: string;\n body?: string;\n bodyRow?: string;\n footer?: string;\n edgeCell?: string;\n };\n}\n\nconst DataGridContext = createContext<\n // biome-ignore lint/suspicious/noExplicitAny: <>\n DataGridContextProps<any> | undefined\n>(undefined);\n\n/**\n * Reads the grid context. Pass `TData` from the calling component when the\n * table, a row or a cell is handed on to something typed against that row\n * shape: v9 declares `TData` invariant, so the default `any` no longer\n * unifies with a concrete row type the way it did on v8.\n */\nfunction useDataGrid<\n // biome-ignore lint/suspicious/noExplicitAny: <>\n TData extends object = any,\n>(): DataGridContextProps<TData> {\n const context = useContext(DataGridContext) as DataGridContextProps<TData> | undefined;\n if (!context) {\n throw new Error(\"useDataGrid must be used within a DataGridProvider\");\n }\n return context;\n}\n\nfunction DataGridProvider<TData extends object>({\n children,\n table,\n ...props\n}: DataGridLayoutProps<TData> & {\n table: DataGridTableInstance<TData>;\n children?: ReactNode;\n}) {\n // Latest-props ref: context reads always resolve fresh props through the\n // getter below without the memoized context value depending on unstable\n // ReactNode/function prop identities (inline emptyMessage/onRowClick would\n // otherwise publish a new context value on every consumer render - at\n // mousemove rate during a resize drag, piercing the body-rows memo).\n const propsRef = useRef(props);\n propsRef.current = props;\n\n // Same treatment for the table itself, which v9 - unlike v8 - re-creates on\n // every state change. Depending on it directly would republish the context\n // on each resize tick, which is exactly what the memo below exists to\n // prevent; the getter still hands every consumer the current instance.\n const tableRef = useRef(table);\n tableRef.current = table;\n\n // Re-assert an explicit tableLayout resize mode so consumer-level useTable\n // options cannot flip it back between drags. v9 makes `table.options`\n // readonly, so this goes through setOptions in an effect rather than a\n // render-phase mutation. Without an explicit mode, the consumer's own\n // tanstack columnResizeMode (default \"onEnd\") is honored.\n const resizeMode =\n props.tableLayout?.columnsResizable && props.tableLayout.columnsResizeMode\n ? props.tableLayout.columnsResizeMode\n : undefined;\n\n useEffect(() => {\n if (!resizeMode) return;\n if (table.options.columnResizeMode === resizeMode) return;\n table.setOptions((old) => ({ ...old, columnResizeMode: resizeMode }));\n }, [table, resizeMode]);\n\n // One autoSize coordinator per table instance so split header/body viewports\n // cannot apply the growth twice. Keyed on `table.store`, which v9 keeps\n // stable for the life of the table, rather than on `table` itself: the\n // wrapper is re-created on every state change, and re-creating the\n // controller with it would reset its applied-once bookkeeping mid-drag.\n const autoSize = useMemo(() => createDataGridAutoSizeController(() => tableRef.current), []);\n\n // Memoize context value so consumers don't re-render during column resize.\n // Column sizing state is intentionally excluded from deps -- CSS variables\n // on the <table> element handle width updates without React re-renders.\n // ReactNode/function props (messages, onRowClick) are also excluded: they\n // are served fresh through the props getter, so unstable inline identities\n // cannot invalidate the context value.\n const value = useMemo(\n () => ({\n get props() {\n return propsRef.current;\n },\n get table() {\n return tableRef.current;\n },\n recordCount: props.recordCount,\n isLoading: props.isLoading || false,\n autoSize,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [autoSize, props.recordCount, props.isLoading],\n );\n\n return (\n // One React context serves every TData, but v9 declares both TFeatures and\n // TData invariant, so a `DataGridContextProps<any>` context cannot accept a\n // `DataGridContextProps<TData>` value structurally. The erasure happens\n // here and is undone by the TData generic on each consumer component.\n <DataGridContext.Provider value={value as unknown as DataGridContextProps<TData>}>\n {children}\n </DataGridContext.Provider>\n );\n}\n\nfunction DataGrid<TFeatures extends TableFeatures, TData extends object>({\n children,\n table,\n ...props\n}: DataGridProps<TFeatures, TData>) {\n const defaultProps: Partial<DataGridProps<TFeatures, TData>> = {\n loadingMode: \"skeleton\",\n tableLayout: {\n dense: false,\n cellBorder: false,\n rowBorder: true,\n rowRounded: false,\n stripped: false,\n headerSticky: false,\n headerBackground: false,\n footerBackground: false,\n headerBorder: true,\n width: \"fixed\",\n columnsVisibility: false,\n columnsResizable: false,\n // columnsResizeMode has no default on purpose: when unset, the\n // consumer's tanstack columnResizeMode (default \"onEnd\") is honored.\n columnsPinnable: false,\n columnsMovable: false,\n columnsDraggable: false,\n rowsDraggable: false,\n rowsPinnable: false,\n },\n tableClassNames: {\n base: \"\",\n header: \"\",\n headerRow: \"\",\n // z-40 keeps the sticky header above pinned body cells (zIndex 30 in\n // getPinningStyles), which would otherwise paint over it while\n // scrolling vertically with columnsPinnable enabled.\n headerSticky: \"sticky top-0 z-40 bg-background/90 backdrop-blur-xs\",\n body: \"\",\n bodyRow: \"\",\n footer: \"\",\n edgeCell: \"\",\n },\n };\n\n const mergedProps: DataGridProps<TFeatures, TData> = {\n ...defaultProps,\n ...props,\n tableLayout: {\n ...defaultProps.tableLayout,\n ...(props.tableLayout || {}),\n },\n tableClassNames: {\n ...defaultProps.tableClassNames,\n ...(props.tableClassNames || {}),\n },\n };\n\n // Ensure table is provided\n if (!table) {\n throw new Error('DataGrid requires a \"table\" prop');\n }\n\n // The single widening point. Consumers own the TanStack core and may hand\n // over any feature bundle; internals need a concrete one to resolve the\n // feature-gated APIs they call, and v9's invariant TFeatures rules out\n // expressing that with a generic constraint.\n const internalTable = table as unknown as DataGridTableInstance<TData>;\n const internalProps = mergedProps as unknown as DataGridLayoutProps<TData>;\n\n return (\n <DataGridProvider table={internalTable} {...internalProps}>\n {children}\n </DataGridProvider>\n );\n}\n\nfunction DataGridContainer({\n children,\n className,\n}: {\n children: ReactNode;\n className?: string;\n /** Accepted for backwards compatibility; currently has no effect. */\n border?: boolean;\n}) {\n return (\n <div data-slot=\"data-grid\" className={cn(\"w-full overflow-hidden\", className)}>\n {children}\n </div>\n );\n}\n\nexport { DataGrid, DataGridContainer, DataGridProvider, useDataGrid };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFA,MAAa,mBAAmB,cAAc;CAC5C;CACA;CACA;CACA;CAEA;CACA;CAKA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA,gBAAgB,qBAAqB;CACrC,kBAAkB,uBAAuB;CACzC,mBAAmB,wBAAwB;CAC3C,kBAAkB,uBAAuB;CACzC,iBAAiB,sBAAsB;CACvC,qBAAqB,0BAA0B;CAK/C,SAAS;EACP,cAAc;EACd,2BAA2B;EAC3B,OAAO;EACP,UAAU;EACV,MAAM;EACN,mBAAmB;CACrB;CAEA,YAAY,WAAoC;AAClD,CAAC;;AAkBD,SAAgB,qBACd,QACQ;CACR,MAAM,OAAO,OAAO,UAAU;CAC9B,IAAI,OAAO,MAAM,gBAAgB,UAAU,OAAO,KAAK;CACvD,MAAM,YAAY,OAAO,UAAU;CACnC,IAAI,OAAO,cAAc,UAAU,OAAO;CAC1C,OAAO,OAAO,OAAO,EAAE;AACzB;AAkDA,SAAS,iCAWP,UAC4B;CAC5B,IAAI,UAAoE;CAExE,OAAO,EACL,MAAM,WAAmB;EACvB,MAAM,QAAQ,SAAS;EACvB,MAAM,eAAe,MAAM,MAAM;EAKjC,IAAI,WAAW,aAAa,QAAQ,cAAc,KAAA,GAChD,UAAU;EAGZ,IAAI,aAAa,GAAG,OAAO;EAE3B,MAAM,iBAAiB,MACpB,sBAAsB,CAAC,CACvB,MAAM,WAAW,OAAO,UAAU,MAAM,YAAY,OAAO,aAAa,CAAC;EAE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SAAS;EAClB;EACA,IAAI,QAAQ;GACV,OAAO,SAAS;EAClB;EACA,aAAa,MAAM;EACnB,WAAW,MAAM,aAAa;EAC9B;CACF,IAEA;EAAC;EAAU,MAAM;EAAa,MAAM;CAAS,CAC/C;CAEA,OAKE,oBAAC,gBAAgB,UAAjB;EAAiC;EAC9B;CACuB,CAAA;AAE9B;AAEA,SAAS,SAAgE,EACvE,UACA,OACA,GAAG,SAC+B;CAClC,MAAM,eAAyD;EAC7D,aAAa;EACb,aAAa;GACX,OAAO;GACP,YAAY;GACZ,WAAW;GACX,YAAY;GACZ,UAAU;GACV,cAAc;GACd,kBAAkB;GAClB,kBAAkB;GAClB,cAAc;GACd,OAAO;GACP,mBAAmB;GACnB,kBAAkB;GAGlB,iBAAiB;GACjB,gBAAgB;GAChB,kBAAkB;GAClB,eAAe;GACf,cAAc;EAChB;EACA,iBAAiB;GACf,MAAM;GACN,QAAQ;GACR,WAAW;GAIX,cAAc;GACd,MAAM;GACN,SAAS;GACT,QAAQ;GACR,UAAU;EACZ;CACF;CAEA,MAAM,cAA+C;EACnD,GAAG;EACH,GAAG;EACH,aAAa;GACX,GAAG,aAAa;GAChB,GAAI,MAAM,eAAe,CAAC;EAC5B;EACA,iBAAiB;GACf,GAAG,aAAa;GAChB,GAAI,MAAM,mBAAmB,CAAC;EAChC;CACF;CAGA,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,oCAAkC;CAUpD,OACE,oBAAC,kBAAD;EAAyBA;EAAe,GAAIC;EACzC;CACe,CAAA;AAEtB;AAEA,SAAS,kBAAkB,EACzB,UACA,aAMC;CACD,OACE,oBAAC,OAAD;EAAK,aAAU;EAAY,WAAW,GAAG,0BAA0B,SAAS;EACzE;CACE,CAAA;AAET"}
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { useIsMobile } from "../../hooks/use-mobile.js";
3
3
  import { Button } from "../ui/button.js";
4
- import { ScrollArea } from "../ui/scroll-area.js";
5
4
  import { Calendar, CalendarDayButton } from "../ui/calendar.js";
6
5
  import { Input } from "../ui/input.js";
6
+ import { ScrollArea } from "../ui/scroll-area.js";
7
7
  import { Tabs, TabsList, TabsTrigger } from "../ui/tabs.js";
8
8
  import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
9
9
  import { cn } from "@kumix/utils";