@skiddph/prui 0.1.1 → 0.2.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.
@@ -6,12 +6,19 @@
6
6
  export declare const PRUI_THEMES: readonly ["control", "workshop", "ember", "daylight"];
7
7
  export type ThemeName = (typeof PRUI_THEMES)[number];
8
8
  export type ThemeMode = "light" | "dark";
9
+ /**
10
+ * A theme default may be a named theme or the shorthand 'dark' / 'light',
11
+ * which resolve to the default dark theme (control) and the default light
12
+ * theme (daylight).
13
+ */
14
+ export type ThemeDefault = ThemeName | "dark" | "light";
15
+ export declare function resolveThemeName(name: ThemeDefault): ThemeName;
9
16
  export declare function isDarkTheme(name: ThemeName): boolean;
10
17
  export declare function isLightTheme(name: ThemeName): boolean;
11
18
  export declare function themeMode(name: ThemeName): ThemeMode;
12
19
  export interface ApplyThemeOptions {
13
- /** Theme name, defaults to control. */
14
- theme?: ThemeName;
20
+ /** Theme name (or 'dark'/'light' shorthand), defaults to control. */
21
+ theme?: ThemeDefault;
15
22
  /** Force a mode; omit to use the theme's natural mode. */
16
23
  mode?: ThemeMode;
17
24
  /** Element to class, defaults to document.documentElement. */
@@ -33,7 +40,7 @@ export declare const themeMeta: {
33
40
  readonly description: "Apply a named PRUI theme and persist the choice.";
34
41
  readonly props: readonly [{
35
42
  readonly name: "theme";
36
- readonly type: "'control' | 'workshop' | 'ember' | 'daylight'";
43
+ readonly type: "'control' | 'workshop' | 'ember' | 'daylight' | 'dark' | 'light'";
37
44
  readonly default: "'control'";
38
45
  readonly control: "select";
39
46
  }, {
package/dist/theme.js CHANGED
@@ -1,51 +1,55 @@
1
- const l = ["control", "workshop", "ember", "daylight"], i = ["control", "workshop", "ember"], m = ["daylight"];
2
- function d(e) {
3
- return i.includes(e);
1
+ const l = ["control", "workshop", "ember", "daylight"];
2
+ function s(e) {
3
+ return e === "dark" ? "control" : e === "light" ? "daylight" : e;
4
+ }
5
+ const u = ["control", "workshop", "ember"], d = ["daylight"];
6
+ function m(e) {
7
+ return u.includes(e);
4
8
  }
5
9
  function p(e) {
6
- return m.includes(e);
10
+ return d.includes(e);
7
11
  }
8
12
  function c(e) {
9
- return d(e) ? "dark" : "light";
13
+ return m(e) ? "dark" : "light";
10
14
  }
11
- const s = "prui-theme-";
12
- function u(e, t) {
13
- return [`${s}${e}`, "prui-root", `prui-mode-${t}`];
15
+ const i = "prui-theme-";
16
+ function h(e, t) {
17
+ return [`${i}${e}`, "prui-root", `prui-mode-${t}`];
14
18
  }
15
- function h(e) {
19
+ function f(e) {
16
20
  const t = [...e.classList].filter(
17
- (n) => n.startsWith(s) || n === "prui-root" || n.startsWith("prui-mode-")
21
+ (r) => r.startsWith(i) || r === "prui-root" || r.startsWith("prui-mode-")
18
22
  );
19
23
  t.length && e.classList.remove(...t);
20
24
  }
21
- function f(e = {}) {
22
- const t = e.theme ?? "control", n = e.mode ?? c(t), o = e.target ?? (typeof document < "u" ? document.documentElement : null);
23
- o && (h(o), o.classList.add(...u(t, n)), o.dataset.pruiTheme = t, o.dataset.pruiMode = n, o.style.colorScheme = n);
24
- const r = e.storageKey === void 0 ? "prui:theme" : e.storageKey;
25
- return r && typeof localStorage < "u" && localStorage.setItem(r, JSON.stringify({ theme: t, mode: n })), { theme: t, mode: n };
25
+ function g(e = {}) {
26
+ const t = s(e.theme ?? "control"), r = e.mode ?? c(t), n = e.target ?? (typeof document < "u" ? document.documentElement : null);
27
+ n && (f(n), n.classList.add(...h(t, r)), n.dataset.pruiTheme = t, n.dataset.pruiMode = r, n.style.colorScheme = r);
28
+ const o = e.storageKey === void 0 ? "prui:theme" : e.storageKey;
29
+ return o && typeof localStorage < "u" && localStorage.setItem(o, JSON.stringify({ theme: t, mode: r })), { theme: t, mode: r };
26
30
  }
27
- function g(e = "prui:theme") {
31
+ function y(e = "prui:theme") {
28
32
  if (typeof localStorage > "u") return null;
29
33
  const t = localStorage.getItem(e);
30
34
  if (!t) return null;
31
35
  try {
32
- const n = JSON.parse(t), o = l.find((a) => a === n.theme);
33
- if (!o) return null;
34
- const r = n.mode === "light" || n.mode === "dark" ? n.mode : c(o);
35
- return { theme: o, mode: r };
36
+ const r = JSON.parse(t), n = l.find((a) => a === r.theme);
37
+ if (!n) return null;
38
+ const o = r.mode === "light" || r.mode === "dark" ? r.mode : c(n);
39
+ return { theme: n, mode: o };
36
40
  } catch {
37
41
  return null;
38
42
  }
39
43
  }
40
- function y(e) {
44
+ function T(e) {
41
45
  const t = l.indexOf(e);
42
46
  return l[(t + 1) % l.length] ?? "control";
43
47
  }
44
- const T = {
48
+ const E = {
45
49
  name: "applyTheme",
46
50
  description: "Apply a named PRUI theme and persist the choice.",
47
51
  props: [
48
- { name: "theme", type: "'control' | 'workshop' | 'ember' | 'daylight'", default: "'control'", control: "select" },
52
+ { name: "theme", type: "'control' | 'workshop' | 'ember' | 'daylight' | 'dark' | 'light'", default: "'control'", control: "select" },
49
53
  { name: "mode", type: "'light' | 'dark'", default: "theme natural mode", control: "select" },
50
54
  { name: "target", type: "HTMLElement", default: "document.documentElement", control: "none" },
51
55
  { name: "storageKey", type: "string | null", default: "'prui:theme'", control: "text" }
@@ -53,11 +57,12 @@ const T = {
53
57
  };
54
58
  export {
55
59
  l as PRUI_THEMES,
56
- f as applyTheme,
57
- d as isDarkTheme,
60
+ g as applyTheme,
61
+ m as isDarkTheme,
58
62
  p as isLightTheme,
59
- y as nextTheme,
60
- g as readPersistedTheme,
61
- T as themeMeta,
63
+ T as nextTheme,
64
+ y as readPersistedTheme,
65
+ s as resolveThemeName,
66
+ E as themeMeta,
62
67
  c as themeMode
63
68
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skiddph/prui",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "PRUI component system: primitives, app-layer super-components, pages, and themes",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -76,9 +76,10 @@
76
76
  "node": ">=18"
77
77
  },
78
78
  "scripts": {
79
- "build": "vite build && node scripts/bundle-css.mjs && mkdir -p dist/theme && cp src/theme/*.css dist/theme/",
79
+ "build": "vite build && node scripts/bundle-css.mjs",
80
80
  "test": "vitest run",
81
81
  "typecheck": "tsc --noEmit",
82
- "clean": "rm -rf dist"
82
+ "clean": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"",
83
+ "lint": "eslint ."
83
84
  }
84
85
  }
@@ -1,430 +0,0 @@
1
- import { jsx as e, jsxs as o, Fragment as M } from "react/jsx-runtime";
2
- import * as g from "react";
3
- import { ArrowUp as I, ArrowDown as L, ArrowUpDown as $, Inbox as A, ChevronLeft as z, ChevronRight as B, Check as Y, PlusCircle as q, Search as E } from "lucide-react";
4
- import { cn as N } from "../core/cn.js";
5
- import { Button as T } from "../core/button.js";
6
- import { Select as G, SelectTrigger as H, SelectValue as J, SelectContent as Q, SelectItem as W } from "../core/select.js";
7
- import { Input as S } from "../core/input.js";
8
- import { Badge as X } from "../core/card.js";
9
- import { Dropdown as Z } from "../core/dropdown.js";
10
- import { Label as D } from "../core/label.js";
11
- function ne({
12
- columns: a,
13
- rows: u,
14
- rowKey: f,
15
- sort: m,
16
- onSortChange: i,
17
- defaultSort: d = null,
18
- loading: h = !1,
19
- emptyMessage: b = "No results.",
20
- onRowClick: t,
21
- className: c
22
- }) {
23
- const [p, s] = g.useState(d), r = m !== void 0, n = r ? m : p, y = a.filter((l) => !l.hidden), j = g.useMemo(() => {
24
- if (!n) return u;
25
- const l = a.find((v) => v.key === n.key);
26
- if (!(l != null && l.sortable)) return u;
27
- const x = n.direction === "asc" ? 1 : -1;
28
- return [...u].sort((v, R) => {
29
- const k = v[n.key], w = R[n.key];
30
- return k == null && w == null ? 0 : k == null ? 1 : w == null ? -1 : typeof k == "number" && typeof w == "number" ? (k - w) * x : String(k).localeCompare(String(w)) * x;
31
- });
32
- }, [u, n, a]), U = (l) => {
33
- const x = a.find((R) => R.key === l);
34
- if (!(x != null && x.sortable)) return;
35
- const v = (n == null ? void 0 : n.key) === l ? n.direction === "asc" ? { key: l, direction: "desc" } : null : { key: l, direction: "asc" };
36
- r || s(v), i == null || i(v);
37
- };
38
- return /* @__PURE__ */ e("div", { className: N("prui-data-table w-full overflow-x-auto rounded-[var(--prui-radius)] border border-[var(--prui-line)]", c), children: /* @__PURE__ */ o("table", { className: "w-full text-sm", children: [
39
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { className: "border-b border-[var(--prui-line)] bg-[var(--prui-raise)]", children: y.map((l) => {
40
- const x = (n == null ? void 0 : n.key) === l.key, v = x ? (n == null ? void 0 : n.direction) === "asc" ? I : L : $;
41
- return /* @__PURE__ */ e(
42
- "th",
43
- {
44
- scope: "col",
45
- "aria-sort": x ? (n == null ? void 0 : n.direction) === "asc" ? "ascending" : "descending" : l.sortable ? "none" : void 0,
46
- style: l.width !== void 0 ? { width: l.width } : void 0,
47
- className: N(
48
- "px-3 py-2 text-xs font-medium uppercase tracking-wide text-[var(--prui-dim)]",
49
- l.align === "right" && "text-right",
50
- l.align === "center" && "text-center"
51
- ),
52
- children: l.sortable ? /* @__PURE__ */ o(
53
- "button",
54
- {
55
- type: "button",
56
- onClick: () => U(l.key),
57
- className: N(
58
- "inline-flex items-center gap-1 hover:text-[var(--prui-fg)] cursor-pointer uppercase",
59
- x && "text-[var(--prui-fg)]"
60
- ),
61
- children: [
62
- l.label,
63
- /* @__PURE__ */ e(v, { className: "h-3 w-3", "aria-hidden": !0 })
64
- ]
65
- }
66
- ) : l.label
67
- },
68
- l.key
69
- );
70
- }) }) }),
71
- /* @__PURE__ */ e("tbody", { children: h ? /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: y.length, className: "px-3 py-8 text-center text-[var(--prui-dim)]", "data-testid": "data-table-loading", children: "Loading..." }) }) : j.length === 0 ? /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: y.length, className: "px-3 py-8 text-center text-[var(--prui-dim)]", "data-testid": "data-table-empty", children: /* @__PURE__ */ o("span", { className: "inline-flex items-center gap-2", children: [
72
- /* @__PURE__ */ e(A, { className: "h-4 w-4", "aria-hidden": !0 }),
73
- b
74
- ] }) }) }) : j.map((l, x) => /* @__PURE__ */ e(
75
- "tr",
76
- {
77
- onClick: t ? () => t(l, x) : void 0,
78
- className: N(
79
- "border-b border-[var(--prui-line)] last:border-b-0 text-[var(--prui-fg)]",
80
- t && "cursor-pointer hover:bg-[var(--prui-raise)]"
81
- ),
82
- children: y.map((v) => /* @__PURE__ */ e(
83
- "td",
84
- {
85
- className: N(
86
- "px-3 py-2",
87
- v.align === "right" && "text-right",
88
- v.align === "center" && "text-center",
89
- v.className
90
- ),
91
- children: v.render ? v.render(l) : _(l[v.key])
92
- },
93
- v.key
94
- ))
95
- },
96
- f ? f(l, x) : x
97
- )) })
98
- ] }) });
99
- }
100
- function _(a) {
101
- return a == null || a === "" ? /* @__PURE__ */ e("span", { className: "text-[var(--prui-dim)]", children: "-" }) : a instanceof Date ? a.toLocaleDateString() : typeof a == "boolean" ? a ? "Yes" : "No" : String(a);
102
- }
103
- const se = {
104
- name: "DataTable",
105
- props: [
106
- { name: "columns", type: "Column<T>[]", default: null, control: "object" },
107
- { name: "rows", type: "T[]", default: "[]", control: "object" },
108
- { name: "sort", type: "{ key, direction } | null", default: "undefined", control: "none" },
109
- { name: "onSortChange", type: "(sort) => void", default: null, control: "none" },
110
- { name: "loading", type: "boolean", default: "false", control: "boolean" },
111
- { name: "emptyMessage", type: "ReactNode", default: "'No results.'", control: "text" },
112
- { name: "onRowClick", type: "(row, index) => void", default: null, control: "none" }
113
- ]
114
- };
115
- function oe({
116
- page: a,
117
- pageSize: u = 20,
118
- hasNextPage: f,
119
- hasPreviousPage: m,
120
- onPageChange: i,
121
- onPageSizeChange: d,
122
- pageSizeOptions: h = [10, 20, 50, 100],
123
- className: b
124
- }) {
125
- return /* @__PURE__ */ o("div", { className: b ?? "flex items-center justify-between gap-2 py-2", children: [
126
- /* @__PURE__ */ o("div", { className: "flex items-center gap-2 text-sm text-[var(--prui-dim)]", children: [
127
- /* @__PURE__ */ e("span", { children: "Rows per page" }),
128
- /* @__PURE__ */ e("div", { className: "w-20", children: /* @__PURE__ */ o(
129
- G,
130
- {
131
- value: String(u),
132
- onChange: (t) => d == null ? void 0 : d(Number(t)),
133
- options: h.map((t) => ({ label: String(t), value: String(t) })),
134
- children: [
135
- /* @__PURE__ */ e(H, { "aria-label": "Rows per page", className: "h-7", children: /* @__PURE__ */ e(J, {}) }),
136
- /* @__PURE__ */ e(Q, { children: h.map((t) => /* @__PURE__ */ e(W, { value: String(t), children: t }, t)) })
137
- ]
138
- }
139
- ) })
140
- ] }),
141
- /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
142
- /* @__PURE__ */ o("span", { className: "text-sm text-[var(--prui-dim)]", "data-testid": "pagination-page", children: [
143
- "Page ",
144
- a
145
- ] }),
146
- /* @__PURE__ */ e(
147
- T,
148
- {
149
- variant: "default",
150
- size: "icon",
151
- "aria-label": "Previous page",
152
- disabled: !m,
153
- onClick: () => i == null ? void 0 : i(a - 1, "prev"),
154
- children: /* @__PURE__ */ e(z, { className: "h-4 w-4", "aria-hidden": !0 })
155
- }
156
- ),
157
- /* @__PURE__ */ e(
158
- T,
159
- {
160
- variant: "default",
161
- size: "icon",
162
- "aria-label": "Next page",
163
- disabled: !f,
164
- onClick: () => i == null ? void 0 : i(a + 1, "next"),
165
- children: /* @__PURE__ */ e(B, { className: "h-4 w-4", "aria-hidden": !0 })
166
- }
167
- )
168
- ] })
169
- ] });
170
- }
171
- const de = {
172
- name: "DataTablePagination",
173
- props: [
174
- { name: "page", type: "number", default: null, control: "number" },
175
- { name: "pageSize", type: "number", default: "20", control: "select", options: ["10", "20", "50", "100"] },
176
- { name: "hasNextPage", type: "boolean", default: null, control: "boolean" },
177
- { name: "hasPreviousPage", type: "boolean", default: null, control: "boolean" },
178
- { name: "onPageChange", type: "(page, direction) => void", default: null, control: "none" },
179
- { name: "onPageSizeChange", type: "(size) => void", default: null, control: "none" }
180
- ]
181
- };
182
- function K({
183
- label: a,
184
- options: u,
185
- value: f,
186
- defaultValue: m,
187
- onChange: i,
188
- className: d
189
- }) {
190
- const [h, b] = g.useState(m ?? []), t = f !== void 0, c = t ? f : h, p = (s) => {
191
- const r = c.includes(s) ? c.filter((n) => n !== s) : [...c, s];
192
- t || b(r), i == null || i(r);
193
- };
194
- return /* @__PURE__ */ e(
195
- Z,
196
- {
197
- className: d,
198
- trigger: /* @__PURE__ */ o(
199
- "button",
200
- {
201
- type: "button",
202
- className: "prui-faceted-filter inline-flex h-8 items-center gap-1.5 rounded-[var(--prui-radius)] border border-[var(--prui-line)] bg-[var(--prui-background)] px-2.5 text-sm cursor-pointer hover:border-[var(--prui-dim)]",
203
- "data-testid": "faceted-filter",
204
- children: [
205
- /* @__PURE__ */ e(q, { className: "h-3.5 w-3.5 text-[var(--prui-dim)]", "aria-hidden": !0 }),
206
- a,
207
- c.length > 0 ? /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e("span", { className: "ml-1 rounded-[var(--prui-radius-full)] bg-[var(--prui-raise)] px-1.5 text-xs", children: c.length }) }) : null
208
- ]
209
- }
210
- ),
211
- children: /* @__PURE__ */ o("div", { role: "menu", className: "min-w-44", children: [
212
- u.length === 0 ? /* @__PURE__ */ e("div", { className: "px-2 py-1.5 text-sm text-[var(--prui-dim)]", children: "No options" }) : u.map((s) => {
213
- const r = c.includes(s.value);
214
- return /* @__PURE__ */ o(
215
- "button",
216
- {
217
- type: "button",
218
- role: "menuitemcheckbox",
219
- "aria-checked": r,
220
- onClick: () => p(s.value),
221
- "data-selected": r || void 0,
222
- className: "flex w-full cursor-pointer items-center gap-2 rounded-[calc(var(--prui-radius)-1px)] px-2 py-1.5 text-left text-sm text-[var(--prui-fg)] hover:bg-[var(--prui-raise)]",
223
- children: [
224
- /* @__PURE__ */ e(
225
- "span",
226
- {
227
- className: "flex h-4 w-4 items-center justify-center rounded-[var(--prui-radius-1)] border border-[var(--prui-line)]",
228
- style: r ? { backgroundColor: "var(--prui-brand)", borderColor: "var(--prui-brand)" } : void 0,
229
- children: r ? /* @__PURE__ */ e(Y, { className: "h-3 w-3 text-white", "aria-hidden": !0 }) : null
230
- }
231
- ),
232
- s.label,
233
- s.count !== void 0 ? /* @__PURE__ */ e(X, { variant: "outline", className: "ml-auto", children: s.count }) : null
234
- ]
235
- },
236
- s.value
237
- );
238
- }),
239
- c.length > 0 ? /* @__PURE__ */ o(
240
- "button",
241
- {
242
- type: "button",
243
- onClick: () => {
244
- t || b([]), i == null || i([]);
245
- },
246
- className: "mt-1 w-full cursor-pointer rounded-[calc(var(--prui-radius)-1px)] border-t border-[var(--prui-line)] px-2 py-1.5 text-left text-xs text-[var(--prui-dim)] hover:text-[var(--prui-fg)]",
247
- children: [
248
- "Clear (",
249
- c.length,
250
- ")"
251
- ]
252
- }
253
- ) : null
254
- ] })
255
- }
256
- );
257
- }
258
- function O({
259
- label: a = "Date range",
260
- value: u,
261
- defaultValue: f,
262
- onChange: m,
263
- className: i
264
- }) {
265
- const [d, h] = g.useState(f ?? {}), b = u !== void 0, t = b ? u : d, c = (p) => {
266
- b || h(p), m == null || m(p);
267
- };
268
- return /* @__PURE__ */ o("div", { className: i ?? "flex items-end gap-2", "data-testid": "daterange-filter", children: [
269
- /* @__PURE__ */ o("div", { className: "flex flex-col gap-1", children: [
270
- /* @__PURE__ */ o(D, { className: "text-xs text-[var(--prui-dim)]", children: [
271
- a,
272
- " from"
273
- ] }),
274
- /* @__PURE__ */ e(
275
- S,
276
- {
277
- type: "date",
278
- "aria-label": `${a} from`,
279
- className: "h-8 w-36",
280
- value: t.from ?? "",
281
- onChange: (p) => c({ ...t, from: p.target.value || void 0 })
282
- }
283
- )
284
- ] }),
285
- /* @__PURE__ */ o("div", { className: "flex flex-col gap-1", children: [
286
- /* @__PURE__ */ e(D, { className: "text-xs text-[var(--prui-dim)]", children: "to" }),
287
- /* @__PURE__ */ e(
288
- S,
289
- {
290
- type: "date",
291
- "aria-label": `${a} to`,
292
- className: "h-8 w-36",
293
- value: t.to ?? "",
294
- onChange: (p) => c({ ...t, to: p.target.value || void 0 })
295
- }
296
- )
297
- ] }),
298
- t.from || t.to ? /* @__PURE__ */ e(T, { variant: "ghost", size: "sm", onClick: () => c({}), children: "Clear" }) : null
299
- ] });
300
- }
301
- function V({
302
- label: a = "Range",
303
- value: u,
304
- defaultValue: f,
305
- onChange: m,
306
- className: i
307
- }) {
308
- const [d, h] = g.useState(f ?? {}), b = u !== void 0, t = b ? u : d, c = (s) => {
309
- b || h(s), m == null || m(s);
310
- }, p = (s) => {
311
- if (s === "") return;
312
- const r = Number(s);
313
- return Number.isNaN(r) ? void 0 : r;
314
- };
315
- return /* @__PURE__ */ o("div", { className: i ?? "flex items-end gap-2", "data-testid": "numberrange-filter", children: [
316
- /* @__PURE__ */ o("div", { className: "flex flex-col gap-1", children: [
317
- /* @__PURE__ */ o(D, { className: "text-xs text-[var(--prui-dim)]", children: [
318
- a,
319
- " min"
320
- ] }),
321
- /* @__PURE__ */ e(
322
- S,
323
- {
324
- type: "number",
325
- "aria-label": `${a} min`,
326
- className: "h-8 w-24",
327
- value: t.min ?? "",
328
- onChange: (s) => c({ ...t, min: p(s.target.value) })
329
- }
330
- )
331
- ] }),
332
- /* @__PURE__ */ o("div", { className: "flex flex-col gap-1", children: [
333
- /* @__PURE__ */ e(D, { className: "text-xs text-[var(--prui-dim)]", children: "max" }),
334
- /* @__PURE__ */ e(
335
- S,
336
- {
337
- type: "number",
338
- "aria-label": `${a} max`,
339
- className: "h-8 w-24",
340
- value: t.max ?? "",
341
- onChange: (s) => c({ ...t, max: p(s.target.value) })
342
- }
343
- )
344
- ] }),
345
- t.min !== void 0 || t.max !== void 0 ? /* @__PURE__ */ e(T, { variant: "ghost", size: "sm", onClick: () => c({}), children: "Clear" }) : null
346
- ] });
347
- }
348
- function ce({
349
- searchPlaceholder: a = "Search...",
350
- searchValue: u,
351
- onSearchChange: f,
352
- filters: m = [],
353
- filterValues: i,
354
- onFilterChange: d,
355
- actions: h,
356
- className: b
357
- }) {
358
- const [t, c] = g.useState(""), p = u !== void 0, s = p ? u : t;
359
- return /* @__PURE__ */ o("div", { className: N("prui-toolbar flex flex-wrap items-center gap-2 py-2", b), children: [
360
- /* @__PURE__ */ o("div", { className: "relative", children: [
361
- /* @__PURE__ */ e(E, { className: "absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-[var(--prui-dim)]", "aria-hidden": !0 }),
362
- /* @__PURE__ */ e(
363
- S,
364
- {
365
- type: "search",
366
- "aria-label": "Search",
367
- placeholder: a,
368
- className: "h-8 w-56 pl-8",
369
- value: s,
370
- onChange: (r) => {
371
- p || c(r.target.value), f == null || f(r.target.value);
372
- }
373
- }
374
- )
375
- ] }),
376
- m.map((r) => {
377
- const n = i == null ? void 0 : i[r.key];
378
- return r.type === "select" ? /* @__PURE__ */ e(
379
- K,
380
- {
381
- label: r.label,
382
- options: r.options ?? [],
383
- value: n ?? [],
384
- onChange: (y) => d == null ? void 0 : d(r.key, y)
385
- },
386
- r.key
387
- ) : r.type === "daterange" ? /* @__PURE__ */ e(
388
- O,
389
- {
390
- label: r.label,
391
- value: n ?? {},
392
- onChange: (y) => d == null ? void 0 : d(r.key, y)
393
- },
394
- r.key
395
- ) : /* @__PURE__ */ e(
396
- V,
397
- {
398
- label: r.label,
399
- value: n ?? {},
400
- onChange: (y) => d == null ? void 0 : d(r.key, y)
401
- },
402
- r.key
403
- );
404
- }),
405
- h ? /* @__PURE__ */ e("div", { className: "ml-auto flex items-center gap-2", children: h }) : null
406
- ] });
407
- }
408
- const ue = {
409
- name: "DataTableToolbar",
410
- props: [
411
- { name: "searchPlaceholder", type: "string", default: "'Search...'", control: "text" },
412
- { name: "searchValue", type: "string", default: "undefined", control: "text" },
413
- { name: "onSearchChange", type: "(value: string) => void", default: null, control: "none" },
414
- { name: "filters", type: "ToolbarFilterConfig[]", default: "[]", control: "object" },
415
- { name: "filterValues", type: "ToolbarFilterValues", default: "{}", control: "object" },
416
- { name: "onFilterChange", type: "(key, value) => void", default: null, control: "none" },
417
- { name: "actions", type: "ReactNode", default: null, control: "none" }
418
- ]
419
- };
420
- export {
421
- ne as D,
422
- K as F,
423
- V as N,
424
- oe as a,
425
- ce as b,
426
- O as c,
427
- de as d,
428
- se as e,
429
- ue as f
430
- };