@tomny-dev/uzi 0.14.0-pr.111.381.1.1f0abc3 → 0.14.0

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 (130) hide show
  1. package/dist/index.cjs +14 -18
  2. package/dist/index.d.ts +0 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +15 -16
  5. package/dist/index57.js +10 -21
  6. package/dist/index57.js.map +1 -1
  7. package/dist/index58.cjs +11 -30
  8. package/dist/index58.cjs.map +1 -1
  9. package/dist/index58.js +14 -101
  10. package/dist/index58.js.map +1 -1
  11. package/dist/index59.cjs +13 -104
  12. package/dist/index59.cjs.map +1 -1
  13. package/dist/index59.js +11 -10
  14. package/dist/index59.js.map +1 -1
  15. package/dist/index60.cjs +13 -11
  16. package/dist/index60.cjs.map +1 -1
  17. package/dist/index60.js +16 -13
  18. package/dist/index60.js.map +1 -1
  19. package/dist/index61.cjs +16 -13
  20. package/dist/index61.cjs.map +1 -1
  21. package/dist/index61.js +8 -10
  22. package/dist/index61.js.map +1 -1
  23. package/dist/index62.cjs +10 -11
  24. package/dist/index62.cjs.map +1 -1
  25. package/dist/index62.js +87 -15
  26. package/dist/index62.js.map +1 -1
  27. package/dist/index63.cjs +89 -15
  28. package/dist/index63.cjs.map +1 -1
  29. package/dist/index63.js +23 -9
  30. package/dist/index63.js.map +1 -1
  31. package/dist/index64.cjs +33 -12
  32. package/dist/index64.cjs.map +1 -1
  33. package/dist/index64.js +43 -89
  34. package/dist/index64.js.map +1 -1
  35. package/dist/index65.cjs +42 -88
  36. package/dist/index65.cjs.map +1 -1
  37. package/dist/index65.js +15 -23
  38. package/dist/index65.js.map +1 -1
  39. package/dist/index66.cjs +21 -33
  40. package/dist/index66.cjs.map +1 -1
  41. package/dist/index66.js +51 -44
  42. package/dist/index66.js.map +1 -1
  43. package/dist/index67.cjs +52 -43
  44. package/dist/index67.cjs.map +1 -1
  45. package/dist/index67.js +14 -14
  46. package/dist/index67.js.map +1 -1
  47. package/dist/index68.cjs +19 -19
  48. package/dist/index68.cjs.map +1 -1
  49. package/dist/index68.js +290 -49
  50. package/dist/index68.js.map +1 -1
  51. package/dist/index69.cjs +290 -51
  52. package/dist/index69.cjs.map +1 -1
  53. package/dist/index69.js +57 -15
  54. package/dist/index69.js.map +1 -1
  55. package/dist/index70.cjs +83 -20
  56. package/dist/index70.cjs.map +1 -1
  57. package/dist/index70.js +418 -276
  58. package/dist/index70.js.map +1 -1
  59. package/dist/index71.cjs +419 -275
  60. package/dist/index71.cjs.map +1 -1
  61. package/dist/index71.js +58 -56
  62. package/dist/index71.js.map +1 -1
  63. package/dist/index72.cjs +85 -82
  64. package/dist/index72.cjs.map +1 -1
  65. package/dist/index72.js +226 -420
  66. package/dist/index72.js.map +1 -1
  67. package/dist/index73.cjs +225 -421
  68. package/dist/index73.cjs.map +1 -1
  69. package/dist/index73.js +42 -58
  70. package/dist/index73.js.map +1 -1
  71. package/dist/index74.cjs +61 -85
  72. package/dist/index74.cjs.map +1 -1
  73. package/dist/index74.js +76 -236
  74. package/dist/index74.js.map +1 -1
  75. package/dist/index75.cjs +75 -235
  76. package/dist/index75.cjs.map +1 -1
  77. package/dist/index75.js +20 -42
  78. package/dist/index75.js.map +1 -1
  79. package/dist/index76.cjs +27 -60
  80. package/dist/index76.cjs.map +1 -1
  81. package/dist/index76.js +88 -73
  82. package/dist/index76.js.map +1 -1
  83. package/dist/index77.cjs +90 -73
  84. package/dist/index77.cjs.map +1 -1
  85. package/dist/index77.js +15 -17
  86. package/dist/index77.js.map +1 -1
  87. package/dist/index78.cjs +19 -22
  88. package/dist/index78.cjs.map +1 -1
  89. package/dist/index78.js +143 -85
  90. package/dist/index78.js.map +1 -1
  91. package/dist/index79.cjs +143 -87
  92. package/dist/index79.cjs.map +1 -1
  93. package/dist/index79.js +91 -19
  94. package/dist/index79.js.map +1 -1
  95. package/dist/index80.cjs +135 -27
  96. package/dist/index80.cjs.map +1 -1
  97. package/dist/index80.js +673 -140
  98. package/dist/index80.js.map +1 -1
  99. package/dist/index81.cjs +673 -140
  100. package/dist/index81.cjs.map +1 -1
  101. package/dist/index81.js +31 -91
  102. package/dist/index81.js.map +1 -1
  103. package/dist/index82.cjs +45 -135
  104. package/dist/index82.cjs.map +1 -1
  105. package/dist/index82.js +206 -667
  106. package/dist/index82.js.map +1 -1
  107. package/dist/index83.cjs +204 -667
  108. package/dist/index83.cjs.map +1 -1
  109. package/dist/index83.js +15 -31
  110. package/dist/index83.js.map +1 -1
  111. package/dist/index84.cjs +21 -45
  112. package/dist/index84.cjs.map +1 -1
  113. package/dist/index84.js +29 -224
  114. package/dist/index84.js.map +1 -1
  115. package/dist/index85.cjs +30 -224
  116. package/dist/index85.cjs.map +1 -1
  117. package/dist/style.css +0 -53
  118. package/package.json +1 -1
  119. package/dist/components/filter-workspace/FilterWorkspace.d.ts +0 -40
  120. package/dist/components/filter-workspace/FilterWorkspace.d.ts.map +0 -1
  121. package/dist/components/filter-workspace/FilterWorkspace.test.d.ts +0 -2
  122. package/dist/components/filter-workspace/FilterWorkspace.test.d.ts.map +0 -1
  123. package/dist/index85.js +0 -19
  124. package/dist/index85.js.map +0 -1
  125. package/dist/index86.cjs +0 -25
  126. package/dist/index86.cjs.map +0 -1
  127. package/dist/index86.js +0 -36
  128. package/dist/index86.js.map +0 -1
  129. package/dist/index87.cjs +0 -37
  130. package/dist/index87.cjs.map +0 -1
package/dist/index73.cjs CHANGED
@@ -1,444 +1,248 @@
1
+ "use client";
1
2
  const require_runtime = require("./index2.cjs");
2
3
  const require_cx = require("./index4.cjs");
3
- const require_auth_pages_module = require("./index72.cjs");
4
+ const require_data_table_module = require("./index72.cjs");
4
5
  let react = require("react");
5
6
  react = require_runtime.__toESM(react, 1);
6
7
  let react_jsx_runtime = require("react/jsx-runtime");
7
- //#region src/components/auth-pages/AuthPages.tsx
8
- function EyeIcon({ open }) {
9
- if (open) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
10
- viewBox: "0 0 24 24",
11
- fill: "none",
12
- "aria-hidden": "true",
13
- className: require_auth_pages_module.default.eyeIcon,
14
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
15
- d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z",
16
- stroke: "currentColor",
17
- strokeWidth: "2"
18
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
19
- cx: "12",
20
- cy: "12",
21
- r: "3",
22
- stroke: "currentColor",
23
- strokeWidth: "2"
24
- })]
25
- });
26
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
27
- viewBox: "0 0 24 24",
28
- fill: "none",
29
- "aria-hidden": "true",
30
- className: require_auth_pages_module.default.eyeIcon,
31
- children: [
32
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
33
- d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94",
34
- stroke: "currentColor",
35
- strokeWidth: "2"
36
- }),
37
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
38
- d: "M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19",
39
- stroke: "currentColor",
40
- strokeWidth: "2"
41
- }),
42
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
43
- x1: "1",
44
- y1: "1",
45
- x2: "23",
46
- y2: "23",
47
- stroke: "currentColor",
48
- strokeWidth: "2"
49
- })
50
- ]
51
- });
52
- }
53
- function Field({ label, id, children, error }) {
54
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
55
- className: require_auth_pages_module.default.field,
56
- children: [
57
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
58
- htmlFor: id,
59
- className: require_auth_pages_module.default.label,
60
- children: label
61
- }),
62
- children,
63
- error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
64
- className: require_auth_pages_module.default.error,
65
- children: error
66
- })
67
- ]
68
- });
69
- }
70
- function PasswordField({ id, label, placeholder, value, onChange, error }) {
71
- const [show, setShow] = react.useState(false);
72
- const toggleRef = react.useRef(null);
73
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
74
- label: label ?? "Password",
75
- id,
76
- error,
77
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
78
- className: require_auth_pages_module.default.passwordWrapper,
79
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
80
- id,
81
- type: show ? "text" : "password",
82
- placeholder,
83
- value,
84
- onChange,
85
- className: require_auth_pages_module.default.input,
86
- autoComplete: "current-password"
87
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
88
- ref: toggleRef,
89
- type: "button",
90
- onClick: () => setShow((s) => !s),
91
- className: require_auth_pages_module.default.toggle,
92
- "aria-label": show ? "Hide password" : "Show password",
93
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EyeIcon, { open: show })
94
- })]
95
- })
96
- });
97
- }
98
- function CheckboxRow({ label, linkText, linkHref, checked, onChange }) {
99
- if (!label) return null;
100
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
101
- className: require_auth_pages_module.default.checkboxRow,
102
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
103
- className: require_auth_pages_module.default.checkboxLabel,
104
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
105
- type: "checkbox",
106
- className: require_auth_pages_module.default.checkbox,
107
- checked,
108
- onChange: (e) => onChange?.(e.target.checked)
109
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label })]
110
- }), linkHref && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
111
- href: linkHref,
112
- className: require_auth_pages_module.default.forgotLink,
113
- children: linkText
114
- })]
115
- });
116
- }
117
- function SignInPage({ title = "Sign in", subtitle, footer, onSubmit, loading = false, brand, className, emailPlaceholder = "Email address", passwordPlaceholder = "Password", rememberLabel = "Remember me", forgotLinkText = "Forgot password?", forgotLinkHref }) {
118
- const id = react.useId();
119
- const [email, setEmail] = react.useState("");
120
- const [password, setPassword] = react.useState("");
121
- const [rememberMe, setRememberMe] = react.useState(false);
122
- const [errors, setErrors] = react.useState({});
123
- const [submitted, setSubmitted] = react.useState(false);
124
- const validate = () => {
125
- const newErrors = {};
126
- if (!email.trim()) newErrors.email = "Email is required";
127
- else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) newErrors.email = "Enter a valid email";
128
- if (!password) newErrors.password = "Password is required";
129
- setErrors(newErrors);
130
- return Object.keys(newErrors).length === 0;
8
+ //#region src/components/data-table/DataTable.tsx
9
+ function DataTable({ data, columns, onRowAction, onSelectionChange, loading = false, emptyMessage = "No data found", pageSize = 10, selectable = false, rowKey = (row) => String(row.id ?? ""), className }) {
10
+ const [sortKey, setSortKey] = react.useState(null);
11
+ const [sortDir, setSortDir] = react.useState("asc");
12
+ const [page, setPage] = react.useState(1);
13
+ const [selected, setSelected] = react.useState(/* @__PURE__ */ new Set());
14
+ const handleSort = (key) => {
15
+ if (key === sortKey) setSortDir((d) => d === "asc" ? "desc" : "asc");
16
+ else {
17
+ setSortKey(key);
18
+ setSortDir("asc");
19
+ }
131
20
  };
132
- const handleSubmit = (e) => {
133
- e.preventDefault();
134
- setSubmitted(true);
135
- if (!validate()) return;
136
- onSubmit?.({
137
- email,
138
- password,
139
- rememberMe
140
- });
21
+ const toggleRow = (id) => {
22
+ const next = new Set(selected);
23
+ if (next.has(id)) next.delete(id);
24
+ else next.add(id);
25
+ setSelected(next);
26
+ onSelectionChange?.(Array.from(next));
141
27
  };
142
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
143
- className: require_cx.cx(require_auth_pages_module.default.authLayout, className),
144
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
145
- className: require_auth_pages_module.default.authCard,
146
- children: [
147
- brand && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
148
- className: require_auth_pages_module.default.authBrand,
149
- children: brand
150
- }),
151
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
152
- className: require_auth_pages_module.default.authHeader,
153
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
154
- className: require_auth_pages_module.default.authTitle,
155
- children: title
156
- }), subtitle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
157
- className: require_auth_pages_module.default.authSubtitle,
158
- children: subtitle
159
- })]
160
- }),
161
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
162
- onSubmit: handleSubmit,
163
- className: require_auth_pages_module.default.authForm,
164
- children: [
165
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
166
- label: emailPlaceholder,
167
- id: id + "-email",
168
- error: submitted ? errors.email : void 0,
169
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
170
- id: id + "-email",
171
- type: "email",
172
- placeholder: "you@example.com",
173
- value: email,
174
- onChange: (e) => setEmail(e.target.value),
175
- className: require_auth_pages_module.default.input,
176
- autoComplete: "email",
177
- autoFocus: true
178
- })
179
- }),
180
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordField, {
181
- label: passwordPlaceholder,
182
- id: id + "-password",
183
- placeholder: passwordPlaceholder,
184
- value: password,
185
- onChange: (e) => {
186
- setPassword(e.target.value);
187
- if (submitted) setSubmitted(false);
188
- },
189
- error: submitted ? errors.password : void 0
190
- }),
191
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckboxRow, {
192
- label: rememberLabel,
193
- linkText: forgotLinkText,
194
- linkHref: forgotLinkHref,
195
- checked: rememberMe,
196
- onChange: (c) => {
197
- setRememberMe(c);
198
- if (submitted) setSubmitted(false);
199
- }
200
- }),
201
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
202
- type: "submit",
203
- disabled: loading,
204
- className: require_auth_pages_module.default.submitButton,
205
- children: loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: require_auth_pages_module.default.spinner }), "Signing in..."] }) : "Sign in"
206
- })
207
- ]
208
- }),
209
- footer && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", { className: require_auth_pages_module.default.divider }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
210
- className: require_auth_pages_module.default.authFooter,
211
- children: footer
212
- })] })
213
- ]
214
- })
215
- });
216
- }
217
- function SignUpPage({ title = "Create an account", subtitle, footer, onSubmit, loading = false, brand, className, emailPlaceholder = "Email address", passwordPlaceholder = "Password", confirmPasswordPlaceholder = "Confirm password", checkboxLabel, checkboxLinkText, checkboxLinkHref }) {
218
- const id = react.useId();
219
- const [email, setEmail] = react.useState("");
220
- const [password, setPassword] = react.useState("");
221
- const [confirmPassword, setConfirmPassword] = react.useState("");
222
- const [agreed, setAgreed] = react.useState(false);
223
- const [errors, setErrors] = react.useState({});
224
- const [submitted, setSubmitted] = react.useState(false);
225
- const validate = () => {
226
- const newErrors = {};
227
- if (!email.trim()) newErrors.email = "Email is required";
228
- else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) newErrors.email = "Enter a valid email";
229
- if (!password) newErrors.password = "Password is required";
230
- else if (password.length < 8) newErrors.password = "At least 8 characters";
231
- if (password !== confirmPassword) newErrors.confirmPassword = "Passwords do not match";
232
- if (checkboxLabel && !agreed) newErrors.agreed = "You must agree to continue";
233
- setErrors(newErrors);
234
- return Object.keys(newErrors).length === 0;
28
+ const toggleAll = () => {
29
+ const allKeys = displayedData.map((r) => rowKey(r));
30
+ const allSelected = allKeys.every((k) => selected.has(k));
31
+ const next = new Set(selected);
32
+ if (allSelected) allKeys.forEach((k) => next.delete(k));
33
+ else allKeys.forEach((k) => next.add(k));
34
+ setSelected(next);
35
+ onSelectionChange?.(Array.from(next));
235
36
  };
236
- const handleSubmit = (e) => {
237
- e.preventDefault();
238
- setSubmitted(true);
239
- if (!validate()) return;
240
- onSubmit?.({
241
- email,
242
- password,
243
- agreed
37
+ const totalPages = Math.max(1, Math.ceil(data.length / pageSize));
38
+ const safePage = Math.min(page, totalPages);
39
+ const columnSpan = columns.length + (selectable ? 1 : 0) + (onRowAction && onRowAction.length > 0 ? 1 : 0);
40
+ react.useEffect(() => {
41
+ if (page > totalPages) setPage(totalPages);
42
+ }, [
43
+ data.length,
44
+ page,
45
+ totalPages
46
+ ]);
47
+ const sortedData = react.useMemo(() => {
48
+ if (!sortKey) return data;
49
+ const sortColumn = columns.find((column) => column.key === sortKey);
50
+ const getSortValue = (row) => {
51
+ if (sortColumn?.accessor) {
52
+ const accessed = sortColumn.accessor(row);
53
+ if (typeof accessed === "string" || typeof accessed === "number") return accessed;
54
+ }
55
+ return row[sortKey];
56
+ };
57
+ return [...data].sort((a, b) => {
58
+ const aVal = getSortValue(a);
59
+ const bVal = getSortValue(b);
60
+ if (aVal == null) return 1;
61
+ if (bVal == null) return -1;
62
+ let cmp = 0;
63
+ if (typeof aVal === "number" && typeof bVal === "number") cmp = aVal - bVal;
64
+ else cmp = String(aVal).localeCompare(String(bVal));
65
+ return sortDir === "asc" ? cmp : -cmp;
244
66
  });
245
- };
246
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
247
- className: require_cx.cx(require_auth_pages_module.default.authLayout, className),
248
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
249
- className: require_auth_pages_module.default.authCard,
250
- children: [
251
- brand && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
252
- className: require_auth_pages_module.default.authBrand,
253
- children: brand
254
- }),
255
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
256
- className: require_auth_pages_module.default.authHeader,
257
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
258
- className: require_auth_pages_module.default.authTitle,
259
- children: title
260
- }), subtitle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
261
- className: require_auth_pages_module.default.authSubtitle,
262
- children: subtitle
263
- })]
264
- }),
265
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
266
- onSubmit: handleSubmit,
267
- className: require_auth_pages_module.default.authForm,
268
- children: [
269
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
270
- label: emailPlaceholder,
271
- id: id + "-email",
272
- error: submitted ? errors.email : void 0,
67
+ }, [
68
+ columns,
69
+ data,
70
+ sortKey,
71
+ sortDir
72
+ ]);
73
+ const displayedData = react.useMemo(() => {
74
+ const start = (safePage - 1) * pageSize;
75
+ return sortedData.slice(start, start + pageSize);
76
+ }, [
77
+ sortedData,
78
+ safePage,
79
+ pageSize
80
+ ]);
81
+ const displayedKeys = react.useMemo(() => displayedData.map(rowKey), [displayedData, rowKey]);
82
+ const allPageSelected = displayedKeys.length > 0 && displayedKeys.every((k) => selected.has(k));
83
+ const somePageSelected = displayedKeys.length > 0 && displayedKeys.some((k) => selected.has(k));
84
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
85
+ className: require_cx.cx(require_data_table_module.default.wrapper, className),
86
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
87
+ className: require_data_table_module.default.tableContainer,
88
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
89
+ className: require_data_table_module.default.table,
90
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", {
91
+ className: require_data_table_module.default.thead,
92
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
93
+ selectable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
94
+ className: require_data_table_module.default.headerCell,
95
+ "aria-label": "Select all",
273
96
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
274
- id: id + "-email",
275
- type: "email",
276
- placeholder: "you@example.com",
277
- value: email,
278
- onChange: (e) => {
279
- setEmail(e.target.value);
280
- if (submitted) setSubmitted(false);
97
+ type: "checkbox",
98
+ checked: allPageSelected,
99
+ ref: (el) => {
100
+ if (el) el.indeterminate = somePageSelected && !allPageSelected;
281
101
  },
282
- className: require_auth_pages_module.default.input,
283
- autoComplete: "email",
284
- autoFocus: true
102
+ onChange: toggleAll,
103
+ className: require_data_table_module.default.checkbox,
104
+ "aria-label": "Select all rows on this page"
285
105
  })
286
106
  }),
287
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordField, {
288
- label: passwordPlaceholder,
289
- id: id + "-password",
290
- placeholder: passwordPlaceholder,
291
- value: password,
292
- onChange: (e) => {
293
- setPassword(e.target.value);
294
- if (submitted) setSubmitted(false);
295
- },
296
- error: submitted ? errors.password : void 0
107
+ columns.map((col) => {
108
+ const ariaSort = col.sortable ? sortKey === col.key ? sortDir === "asc" ? "ascending" : "descending" : "none" : void 0;
109
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
110
+ className: require_cx.cx(require_data_table_module.default.headerCell, col.width && require_data_table_module.default.headerCellFixed, col.align && require_data_table_module.default[`align${col.align.charAt(0).toUpperCase() + col.align.slice(1)}`]),
111
+ style: col.width ? { width: col.width } : void 0,
112
+ "aria-sort": ariaSort,
113
+ children: col.sortable ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
114
+ type: "button",
115
+ className: require_cx.cx(require_data_table_module.default.sortableHeader, require_data_table_module.default.clickableHeader),
116
+ onClick: () => handleSort(col.key),
117
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
118
+ className: require_data_table_module.default.headerLabel,
119
+ children: col.label
120
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
121
+ className: require_data_table_module.default.sortIcon,
122
+ "aria-hidden": "true",
123
+ children: sortKey === col.key ? sortDir === "asc" ? "▲" : "▼" : "▲▼"
124
+ })]
125
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
126
+ className: require_data_table_module.default.headerLabel,
127
+ children: col.label
128
+ })
129
+ }, col.key);
297
130
  }),
298
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordField, {
299
- label: confirmPasswordPlaceholder,
300
- id: id + "-confirm",
301
- placeholder: confirmPasswordPlaceholder,
302
- value: confirmPassword,
303
- onChange: (e) => {
304
- setConfirmPassword(e.target.value);
305
- if (submitted) setSubmitted(false);
306
- },
307
- error: submitted ? errors.confirmPassword : void 0
308
- }),
309
- checkboxLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
310
- className: require_auth_pages_module.default.checkboxRow,
311
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
312
- className: require_auth_pages_module.default.checkboxLabel,
313
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
314
- id: id + "-agreed",
315
- type: "checkbox",
316
- checked: agreed,
317
- onChange: (e) => {
318
- setAgreed(e.target.checked);
319
- if (submitted) setSubmitted(false);
320
- },
321
- className: require_auth_pages_module.default.checkbox
322
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: checkboxLinkText ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
323
- "I agree to the",
324
- " ",
325
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
326
- href: checkboxLinkHref,
327
- className: require_auth_pages_module.default.checkboxLink,
328
- children: checkboxLinkText
329
- })
330
- ] }) : checkboxLabel })]
131
+ onRowAction && onRowAction.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
132
+ className: require_data_table_module.default.headerCell,
133
+ style: { width: "5rem" },
134
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
135
+ className: require_data_table_module.default.headerLabel,
136
+ children: "Actions"
331
137
  })
332
- }),
333
- submitted && errors.agreed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
334
- className: require_auth_pages_module.default.error,
335
- children: errors.agreed
336
- }),
337
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
338
- type: "submit",
339
- disabled: loading,
340
- className: require_auth_pages_module.default.submitButton,
341
- children: loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: require_auth_pages_module.default.spinner }), "Creating account..."] }) : "Create account"
342
138
  })
343
- ]
344
- }),
345
- footer && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", { className: require_auth_pages_module.default.divider }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
346
- className: require_auth_pages_module.default.authFooter,
347
- children: footer
348
- })] })
349
- ]
350
- })
351
- });
352
- }
353
- function ForgotPasswordPage({ title = "Reset password", subtitle = "Enter your email and we'll send a reset link", footer, onSubmit, loading = false, brand, className, emailPlaceholder = "Email address", buttonText = "Send reset link", backLinkText = "Back to sign in", backLinkHref = "/signin" }) {
354
- const id = react.useId();
355
- const [email, setEmail] = react.useState("");
356
- const [error, setError] = react.useState("");
357
- const [sent, setSent] = react.useState(false);
358
- const handleSubmit = (e) => {
359
- e.preventDefault();
360
- if (!email.trim()) {
361
- setError("Email is required");
362
- return;
363
- }
364
- if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
365
- setError("Enter a valid email");
366
- return;
367
- }
368
- onSubmit?.({ email });
369
- setSent(true);
370
- };
371
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
372
- className: require_cx.cx(require_auth_pages_module.default.authLayout, className),
373
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
374
- className: require_auth_pages_module.default.authCard,
375
- children: [
376
- brand && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
377
- className: require_auth_pages_module.default.authBrand,
378
- children: brand
379
- }),
380
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
381
- className: require_auth_pages_module.default.authHeader,
382
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
383
- className: require_auth_pages_module.default.authTitle,
384
- children: title
385
- }), subtitle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
386
- className: require_auth_pages_module.default.authSubtitle,
387
- children: subtitle
388
- })]
389
- }),
390
- sent ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
391
- className: require_auth_pages_module.default.sentMessage,
392
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
393
- className: require_auth_pages_module.default.sentText,
139
+ ] })
140
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", {
141
+ className: require_data_table_module.default.tbody,
142
+ children: loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
143
+ colSpan: columnSpan,
144
+ className: require_data_table_module.default.loadingCell,
394
145
  children: [
395
- "If an account exists for ",
396
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: email }),
397
- ", you'll receive a reset link shortly."
146
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
147
+ className: require_data_table_module.default.loadingRow,
148
+ "aria-busy": "true",
149
+ children: [
150
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: require_data_table_module.default.skeletonBar }),
151
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: require_data_table_module.default.skeletonBar }),
152
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: require_data_table_module.default.skeletonBar })
153
+ ]
154
+ }),
155
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
156
+ className: require_data_table_module.default.loadingRow,
157
+ "aria-busy": "true",
158
+ children: [
159
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: require_data_table_module.default.skeletonBar }),
160
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: require_data_table_module.default.skeletonBar }),
161
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: require_data_table_module.default.skeletonBar })
162
+ ]
163
+ }),
164
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
165
+ className: require_data_table_module.default.loadingRow,
166
+ "aria-busy": "true",
167
+ children: [
168
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: require_data_table_module.default.skeletonBar }),
169
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: require_data_table_module.default.skeletonBar }),
170
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: require_data_table_module.default.skeletonBar })
171
+ ]
172
+ })
398
173
  ]
399
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
400
- href: backLinkHref,
401
- className: require_auth_pages_module.default.backLink,
402
- children: backLinkText
403
- })]
404
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
405
- onSubmit: handleSubmit,
406
- className: require_auth_pages_module.default.authForm,
407
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
408
- label: emailPlaceholder,
409
- id: id + "-email",
410
- error,
411
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
412
- id: id + "-email",
413
- type: "email",
414
- placeholder: "you@example.com",
415
- value: email,
416
- onChange: (e) => {
417
- setEmail(e.target.value);
418
- setError("");
419
- },
420
- className: require_auth_pages_module.default.input,
421
- autoComplete: "email",
422
- autoFocus: true
423
- })
424
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
425
- type: "submit",
426
- disabled: loading,
427
- className: require_auth_pages_module.default.submitButton,
428
- children: loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: require_auth_pages_module.default.spinner }), "Sending..."] }) : buttonText
429
- })]
430
- }),
431
- footer && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", { className: require_auth_pages_module.default.divider }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
432
- className: require_auth_pages_module.default.authFooter,
433
- children: footer
434
- })] })
435
- ]
436
- })
174
+ }) }) : data.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
175
+ colSpan: columnSpan,
176
+ className: require_data_table_module.default.emptyCell,
177
+ children: emptyMessage
178
+ }) }) : displayedData.map((row) => {
179
+ const id = rowKey(row);
180
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
181
+ className: require_cx.cx(require_data_table_module.default.row, selected.has(id) && require_data_table_module.default.rowSelected),
182
+ children: [
183
+ selectable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
184
+ className: require_data_table_module.default.cell,
185
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
186
+ type: "checkbox",
187
+ checked: selected.has(id),
188
+ onChange: () => toggleRow(id),
189
+ className: require_data_table_module.default.checkbox,
190
+ "aria-label": `Select row ${id}`
191
+ })
192
+ }),
193
+ columns.map((col) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
194
+ className: require_cx.cx(require_data_table_module.default.cell, col.align && require_data_table_module.default[`align${col.align.charAt(0).toUpperCase() + col.align.slice(1)}`]),
195
+ children: col.accessor ? col.accessor(row) : String(row[col.key] ?? "")
196
+ }, `${id}-${col.key}`)),
197
+ onRowAction && onRowAction.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
198
+ className: require_data_table_module.default.cell,
199
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
200
+ className: require_data_table_module.default.rowActions,
201
+ children: onRowAction.map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
202
+ type: "button",
203
+ className: require_data_table_module.default.actionBtn,
204
+ onClick: () => action.onClick(row),
205
+ children: action.label
206
+ }, action.label))
207
+ })
208
+ })
209
+ ]
210
+ }, id);
211
+ })
212
+ })]
213
+ })
214
+ }), data.length > pageSize && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
215
+ className: require_data_table_module.default.pagination,
216
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
217
+ className: require_data_table_module.default.paginationInfo,
218
+ children: [
219
+ "Page ",
220
+ safePage,
221
+ " of ",
222
+ totalPages
223
+ ]
224
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
225
+ className: require_data_table_module.default.paginationButtons,
226
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
227
+ type: "button",
228
+ className: require_data_table_module.default.pageBtn,
229
+ disabled: safePage <= 1,
230
+ onClick: () => setPage((p) => Math.max(1, p - 1)),
231
+ "aria-label": "Previous page",
232
+ children: "←"
233
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
234
+ type: "button",
235
+ className: require_data_table_module.default.pageBtn,
236
+ disabled: safePage >= totalPages,
237
+ onClick: () => setPage((p) => Math.min(totalPages, p + 1)),
238
+ "aria-label": "Next page",
239
+ children: "→"
240
+ })]
241
+ })]
242
+ })]
437
243
  });
438
244
  }
439
245
  //#endregion
440
- exports.ForgotPasswordPage = ForgotPasswordPage;
441
- exports.SignInPage = SignInPage;
442
- exports.SignUpPage = SignUpPage;
246
+ exports.DataTable = DataTable;
443
247
 
444
248
  //# sourceMappingURL=index73.cjs.map