@brett_lamy/ui 3.1.0 → 5.0.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.
- package/README.md +4 -4
- package/dist/components/animated-height.d.ts +3 -1
- package/dist/components/animated-height.d.ts.map +1 -1
- package/dist/components/animated-height.js +11 -11
- package/dist/components/artifact-chat-container.d.ts.map +1 -1
- package/dist/components/artifact-chat-container.js +81 -82
- package/dist/components/button.d.ts +4 -3
- package/dist/components/button.d.ts.map +1 -1
- package/dist/components/button.js +22 -9
- package/dist/components/canvas.d.ts +91 -0
- package/dist/components/canvas.d.ts.map +1 -0
- package/dist/components/canvas.js +296 -0
- package/dist/components/composer/composer-cards.d.ts +55 -0
- package/dist/components/composer/composer-cards.d.ts.map +1 -0
- package/dist/components/composer/composer-cards.js +351 -0
- package/dist/components/composer/composer.d.ts +9 -1
- package/dist/components/composer/composer.d.ts.map +1 -1
- package/dist/components/composer/composer.js +179 -154
- package/dist/components/context-menu.d.ts +25 -0
- package/dist/components/context-menu.d.ts.map +1 -0
- package/dist/components/context-menu.js +127 -0
- package/dist/components/credenza.d.ts.map +1 -1
- package/dist/components/credenza.js +52 -92
- package/dist/components/cron-editor.d.ts +47 -0
- package/dist/components/cron-editor.d.ts.map +1 -0
- package/dist/components/cron-editor.js +297 -0
- package/dist/components/dropdown-menu.d.ts +3 -1
- package/dist/components/dropdown-menu.d.ts.map +1 -1
- package/dist/components/dropdown-menu.js +5 -5
- package/dist/components/edge-drawer.d.ts.map +1 -1
- package/dist/components/edge-drawer.js +1 -0
- package/dist/components/file-upload.d.ts +121 -0
- package/dist/components/file-upload.d.ts.map +1 -0
- package/dist/components/file-upload.js +405 -0
- package/dist/components/filter-input.d.ts +22 -0
- package/dist/components/filter-input.d.ts.map +1 -0
- package/dist/components/filter-input.js +126 -0
- package/dist/components/filter.d.ts +154 -0
- package/dist/components/filter.d.ts.map +1 -0
- package/dist/components/filter.js +815 -0
- package/dist/components/floating-chat.d.ts.map +1 -1
- package/dist/components/floating-chat.js +71 -88
- package/dist/components/floating-sheet.d.ts +21 -5
- package/dist/components/floating-sheet.d.ts.map +1 -1
- package/dist/components/floating-sheet.js +113 -116
- package/dist/components/markdown-editor.d.ts +2 -0
- package/dist/components/markdown-editor.d.ts.map +1 -1
- package/dist/components/markdown-editor.js +46 -45
- package/dist/components/markdown-view.d.ts +6 -1
- package/dist/components/markdown-view.d.ts.map +1 -1
- package/dist/components/markdown-view.js +13 -11
- package/dist/components/navigation-stack.d.ts +3 -5
- package/dist/components/navigation-stack.d.ts.map +1 -1
- package/dist/components/navigation-stack.js +212 -382
- package/dist/components/passkey-enroll-dialog.d.ts +36 -0
- package/dist/components/passkey-enroll-dialog.d.ts.map +1 -0
- package/dist/components/passkey-enroll-dialog.js +234 -0
- package/dist/components/result-table.d.ts +38 -0
- package/dist/components/result-table.d.ts.map +1 -0
- package/dist/components/result-table.js +161 -0
- package/dist/components/schema-tree.d.ts +19 -0
- package/dist/components/schema-tree.d.ts.map +1 -0
- package/dist/components/schema-tree.js +172 -0
- package/dist/components/side-drawer.d.ts.map +1 -1
- package/dist/components/side-drawer.js +117 -143
- package/dist/components/slider.d.ts.map +1 -1
- package/dist/components/slider.js +4 -1
- package/dist/components/spinner-shapes.d.ts +263 -0
- package/dist/components/spinner-shapes.d.ts.map +1 -0
- package/dist/components/spinner-shapes.js +771 -0
- package/dist/components/spinner.d.ts +133 -3
- package/dist/components/spinner.d.ts.map +1 -1
- package/dist/components/spinner.js +445 -29
- package/dist/components/sql-console.d.ts +28 -0
- package/dist/components/sql-console.d.ts.map +1 -0
- package/dist/components/sql-console.js +348 -0
- package/dist/components/sql-editor.d.ts +47 -0
- package/dist/components/sql-editor.d.ts.map +1 -0
- package/dist/components/sql-editor.js +170 -0
- package/dist/components/tab-view.d.ts +2 -2
- package/dist/components/tab-view.d.ts.map +1 -1
- package/dist/components/tab-view.js +63 -49
- package/dist/components/tailscale-login-button.d.ts +53 -0
- package/dist/components/tailscale-login-button.d.ts.map +1 -0
- package/dist/components/tailscale-login-button.js +197 -0
- package/dist/components/time-input.d.ts +46 -0
- package/dist/components/time-input.d.ts.map +1 -0
- package/dist/components/time-input.js +258 -0
- package/dist/components/toast.d.ts +5 -2
- package/dist/components/toast.d.ts.map +1 -1
- package/dist/components/toast.js +249 -125
- package/dist/components/vault-gate.d.ts +60 -0
- package/dist/components/vault-gate.d.ts.map +1 -0
- package/dist/components/vault-gate.js +382 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +86 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +129 -85
- package/dist/lib/back-history.d.ts +5 -0
- package/dist/lib/back-history.d.ts.map +1 -0
- package/dist/lib/back-history.js +44 -0
- package/dist/lib/canvas-math.d.ts +82 -0
- package/dist/lib/canvas-math.d.ts.map +1 -0
- package/dist/lib/canvas-math.js +226 -0
- package/dist/lib/controllable-state.d.ts +4 -0
- package/dist/lib/controllable-state.d.ts.map +1 -0
- package/dist/lib/controllable-state.js +11 -0
- package/dist/lib/cron.d.ts +55 -0
- package/dist/lib/cron.d.ts.map +1 -0
- package/dist/lib/cron.js +269 -0
- package/dist/lib/edge-swipe.d.ts +36 -0
- package/dist/lib/edge-swipe.d.ts.map +1 -0
- package/dist/lib/edge-swipe.js +73 -0
- package/dist/lib/file-upload.d.ts +187 -0
- package/dist/lib/file-upload.d.ts.map +1 -0
- package/dist/lib/file-upload.js +349 -0
- package/dist/lib/filter-query.d.ts +90 -0
- package/dist/lib/filter-query.d.ts.map +1 -0
- package/dist/lib/filter-query.js +459 -0
- package/dist/lib/filter.d.ts +120 -0
- package/dist/lib/filter.d.ts.map +1 -0
- package/dist/lib/filter.js +399 -0
- package/dist/lib/format-bytes.d.ts +3 -0
- package/dist/lib/format-bytes.d.ts.map +1 -0
- package/dist/lib/format-bytes.js +16 -0
- package/dist/lib/gpu-cron.d.ts +51 -0
- package/dist/lib/gpu-cron.d.ts.map +1 -0
- package/dist/lib/gpu-cron.js +81 -0
- package/dist/lib/gpu-query/featurize.d.ts +19 -0
- package/dist/lib/gpu-query/featurize.d.ts.map +1 -0
- package/dist/lib/gpu-query/featurize.js +88 -0
- package/dist/lib/gpu-query/index.d.ts +73 -0
- package/dist/lib/gpu-query/index.d.ts.map +1 -0
- package/dist/lib/gpu-query/index.js +117 -0
- package/dist/lib/gpu-query/kernel.wgsl.d.ts +30 -0
- package/dist/lib/gpu-query/kernel.wgsl.d.ts.map +1 -0
- package/dist/lib/gpu-query/model.d.ts +8 -0
- package/dist/lib/gpu-query/model.d.ts.map +1 -0
- package/dist/lib/gpu-query/model.js +91 -0
- package/dist/lib/gpu-query/schema.d.ts +40 -0
- package/dist/lib/gpu-query/schema.d.ts.map +1 -0
- package/dist/lib/gpu-query/schema.js +0 -0
- package/dist/lib/gpu-query/webgpu.d.ts +12 -0
- package/dist/lib/gpu-query/webgpu.d.ts.map +1 -0
- package/dist/lib/gpu-query/weights.d.ts +17 -0
- package/dist/lib/gpu-query/weights.d.ts.map +1 -0
- package/dist/lib/gpu-query/weights.js +40 -0
- package/dist/lib/gpu-query/weights.json.d.ts +3 -0
- package/dist/lib/gpu-query/weights2.js +25 -0
- package/dist/lib/gpu-time.d.ts +77 -0
- package/dist/lib/gpu-time.d.ts.map +1 -0
- package/dist/lib/gpu-time.js +260 -0
- package/dist/lib/morph-path.d.ts +22 -0
- package/dist/lib/morph-path.d.ts.map +1 -0
- package/dist/lib/morph-path.js +42 -0
- package/dist/lib/passkey.d.ts +120 -0
- package/dist/lib/passkey.d.ts.map +1 -0
- package/dist/lib/passkey.js +186 -0
- package/dist/lib/persistent-state.d.ts +9 -0
- package/dist/lib/persistent-state.d.ts.map +1 -0
- package/dist/lib/persistent-state.js +37 -0
- package/dist/lib/pglite-core.d.ts +219 -0
- package/dist/lib/pglite-core.d.ts.map +1 -0
- package/dist/lib/pglite-core.js +273 -0
- package/dist/lib/pglite-files.d.ts +7 -0
- package/dist/lib/pglite-files.d.ts.map +1 -0
- package/dist/lib/pglite-files.js +17 -0
- package/dist/lib/pglite-schema.d.ts +58 -0
- package/dist/lib/pglite-schema.d.ts.map +1 -0
- package/dist/lib/pglite-schema.js +105 -0
- package/dist/lib/pglite-storage.d.ts +33 -0
- package/dist/lib/pglite-storage.d.ts.map +1 -0
- package/dist/lib/pglite-storage.js +55 -0
- package/dist/lib/pglite-transfer.d.ts +53 -0
- package/dist/lib/pglite-transfer.d.ts.map +1 -0
- package/dist/lib/pglite-transfer.js +126 -0
- package/dist/lib/pglite.d.ts +106 -0
- package/dist/lib/pglite.d.ts.map +1 -0
- package/dist/lib/pglite.js +298 -0
- package/dist/lib/pull-to-refresh.d.ts +24 -0
- package/dist/lib/pull-to-refresh.d.ts.map +1 -0
- package/dist/lib/pull-to-refresh.js +74 -0
- package/dist/lib/scroll-hidden.d.ts +6 -0
- package/dist/lib/scroll-hidden.d.ts.map +1 -0
- package/dist/lib/scroll-hidden.js +21 -0
- package/dist/lib/sheet-drag.d.ts +10 -2
- package/dist/lib/sheet-drag.d.ts.map +1 -1
- package/dist/lib/sheet-drag.js +72 -69
- package/dist/lib/sql-format.d.ts +62 -0
- package/dist/lib/sql-format.d.ts.map +1 -0
- package/dist/lib/sql-format.js +175 -0
- package/dist/lib/sql-lex.d.ts +25 -0
- package/dist/lib/sql-lex.d.ts.map +1 -0
- package/dist/lib/sql-lex.js +135 -0
- package/dist/lib/tab-lock.d.ts +28 -0
- package/dist/lib/tab-lock.d.ts.map +1 -0
- package/dist/lib/tab-lock.js +80 -0
- package/dist/lib/tailscale-connect.d.ts +56 -0
- package/dist/lib/tailscale-connect.d.ts.map +1 -0
- package/dist/lib/tailscale-connect.js +99 -0
- package/dist/lib/tailscale-fake.d.ts +33 -0
- package/dist/lib/tailscale-fake.d.ts.map +1 -0
- package/dist/lib/tailscale-fake.js +80 -0
- package/dist/lib/tailscale-policy.d.ts +71 -0
- package/dist/lib/tailscale-policy.d.ts.map +1 -0
- package/dist/lib/tailscale-policy.js +244 -0
- package/dist/lib/tailscale-react.d.ts +20 -0
- package/dist/lib/tailscale-react.d.ts.map +1 -0
- package/dist/lib/tailscale-react.js +37 -0
- package/dist/lib/tailscale-router/bridge.d.ts +60 -0
- package/dist/lib/tailscale-router/bridge.d.ts.map +1 -0
- package/dist/lib/tailscale-router/bridge.js +198 -0
- package/dist/lib/tailscale-router/react.d.ts +19 -0
- package/dist/lib/tailscale-router/react.d.ts.map +1 -0
- package/dist/lib/tailscale-router/react.js +52 -0
- package/dist/lib/tailscale.d.ts +204 -0
- package/dist/lib/tailscale.d.ts.map +1 -0
- package/dist/lib/tailscale.js +443 -0
- package/dist/lib/title-flight.d.ts +34 -0
- package/dist/lib/title-flight.d.ts.map +1 -0
- package/dist/lib/title-flight.js +123 -0
- package/dist/lib/vault-react.d.ts +49 -0
- package/dist/lib/vault-react.d.ts.map +1 -0
- package/dist/lib/vault-react.js +196 -0
- package/dist/lib/vault-storage.d.ts +30 -0
- package/dist/lib/vault-storage.d.ts.map +1 -0
- package/dist/lib/vault-storage.js +105 -0
- package/dist/lib/vault.d.ts +200 -0
- package/dist/lib/vault.d.ts.map +1 -0
- package/dist/lib/vault.js +641 -0
- package/dist/tailscale-sw.js +332 -0
- package/package.json +35 -5
- package/dist/components/icon-button.d.ts +0 -19
- package/dist/components/icon-button.d.ts.map +0 -1
- package/dist/components/icon-button.js +0 -31
- package/dist/components/measure-h.d.ts +0 -7
- package/dist/components/measure-h.d.ts.map +0 -1
- package/dist/components/measure-h.js +0 -20
- package/dist/components/snap-sheet.d.ts +0 -13
- package/dist/components/snap-sheet.d.ts.map +0 -1
- package/dist/components/snap-sheet.js +0 -100
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../lib/utils.js";
|
|
3
|
+
import { Icon as t } from "../lib/icon.js";
|
|
4
|
+
import { Segmented as n } from "./segmented.js";
|
|
5
|
+
import { selectableText as r } from "../lib/primitives.js";
|
|
6
|
+
import { checkboxVariants as i } from "./checkbox.js";
|
|
7
|
+
import { Popover as a, PopoverTrigger as o } from "./popover.js";
|
|
8
|
+
import { DropdownMenu as s, DropdownMenuContent as c, DropdownMenuItem as l } from "./dropdown-menu.js";
|
|
9
|
+
import { ListBox as u, listBoxItemVariants as d } from "./list-box.js";
|
|
10
|
+
import { DATE_PRESETS as f, RELATIVE_UNITS as p, createFilter as m, describeFilter as h, describeValue as g, isDateValue as _, isFilterComplete as v, operatorLabel as y, operatorsFor as b, withOperator as x, withValue as S } from "../lib/filter.js";
|
|
11
|
+
import { createContext as C, useCallback as w, useContext as T, useEffect as ee, useMemo as E, useRef as D, useState as O } from "react";
|
|
12
|
+
import { Fragment as k, jsx as A, jsxs as j } from "react/jsx-runtime";
|
|
13
|
+
import { Autocomplete as M, Button as N, Dialog as P, Input as F, ListBoxItem as I, SearchField as L, TextField as R, Toolbar as z, composeRenderProps as B } from "react-aria-components";
|
|
14
|
+
import { cva as V } from "class-variance-authority";
|
|
15
|
+
import { useFilter as H } from "react-aria";
|
|
16
|
+
//#region src/components/filter.tsx
|
|
17
|
+
function U(e, t, n) {
|
|
18
|
+
let [r, i] = O(t), a = e === void 0 ? r : e, o = D(a);
|
|
19
|
+
o.current = a;
|
|
20
|
+
let s = D(n);
|
|
21
|
+
s.current = n;
|
|
22
|
+
let c = e !== void 0;
|
|
23
|
+
return [a, w((e) => {
|
|
24
|
+
let t = typeof e == "function" ? e(o.current) : e;
|
|
25
|
+
Object.is(t, o.current) || (o.current = t, c || i(t), s.current?.(t));
|
|
26
|
+
}, [c])];
|
|
27
|
+
}
|
|
28
|
+
function W({ value: e, defaultValue: t, onValueChange: n, match: r, defaultMatch: i = "all", onMatchChange: a } = {}) {
|
|
29
|
+
let [o, s] = U(e, t ?? [], n), [c, l] = U(r, i, a);
|
|
30
|
+
return E(() => ({
|
|
31
|
+
filters: o,
|
|
32
|
+
match: c,
|
|
33
|
+
setFilters: s,
|
|
34
|
+
setMatch: l,
|
|
35
|
+
add: (e) => s((t) => [...t, e]),
|
|
36
|
+
update: (e, t) => s((n) => n.map((n) => n.id === e ? {
|
|
37
|
+
...n,
|
|
38
|
+
...t
|
|
39
|
+
} : n)),
|
|
40
|
+
remove: (e) => s((t) => t.filter((t) => t.id !== e)),
|
|
41
|
+
clear: () => s((e) => e.length ? [] : e)
|
|
42
|
+
}), [
|
|
43
|
+
o,
|
|
44
|
+
c,
|
|
45
|
+
s,
|
|
46
|
+
l
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
var G = C(null);
|
|
50
|
+
function K() {
|
|
51
|
+
return T(G);
|
|
52
|
+
}
|
|
53
|
+
function q() {
|
|
54
|
+
let e = T(G);
|
|
55
|
+
if (!e) throw Error("useFilterBar must be used inside <FilterBar>");
|
|
56
|
+
return e;
|
|
57
|
+
}
|
|
58
|
+
var te = V("flex min-w-0 flex-col gap-2"), ne = V("flex min-w-0 flex-wrap items-center gap-1.5"), re = V("box-border inline-flex max-w-full min-w-0 items-stretch overflow-hidden rounded-lg text-foreground", {
|
|
59
|
+
variants: {
|
|
60
|
+
size: {
|
|
61
|
+
default: "h-7 text-footnote",
|
|
62
|
+
sm: "h-6 text-caption"
|
|
63
|
+
},
|
|
64
|
+
tone: {
|
|
65
|
+
default: "bg-secondary shadow-hairline",
|
|
66
|
+
preview: "bg-primary/10 text-foreground shadow-hairline"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
size: "default",
|
|
71
|
+
tone: "default"
|
|
72
|
+
}
|
|
73
|
+
}), J = "bl-btn flex min-w-0 items-center gap-1.5 border-0 border-l border-border bg-transparent px-2 [font-family:inherit] text-inherit outline-none first:border-l-0", Y = "cursor-pointer data-hovered:bg-accent data-pressed:bg-secondary-strong data-focus-visible:ring-2 data-focus-visible:ring-inset data-focus-visible:ring-ring", X = "bl-btn box-border inline-flex h-7 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border-0 bg-transparent px-2 [font-family:inherit] text-footnote font-medium text-foreground/70 outline-none transition-[background-color] duration-spring-snappy ease-spring-snappy data-hovered:bg-accent data-pressed:bg-secondary-strong data-focus-visible:ring-2 data-focus-visible:ring-ring motion-reduce:transition-none", ie = (e) => ({ "--c": e });
|
|
74
|
+
function Z({ icon: e, color: n, size: r = 14 }) {
|
|
75
|
+
return e ? /* @__PURE__ */ A("span", {
|
|
76
|
+
className: "grid shrink-0 place-items-center text-foreground/70",
|
|
77
|
+
children: typeof e == "string" ? /* @__PURE__ */ A(t, {
|
|
78
|
+
name: e,
|
|
79
|
+
size: r,
|
|
80
|
+
sw: 2
|
|
81
|
+
}) : e
|
|
82
|
+
}) : n ? /* @__PURE__ */ A("span", {
|
|
83
|
+
"aria-hidden": "true",
|
|
84
|
+
className: "size-2 shrink-0 rounded-full bg-(--c)",
|
|
85
|
+
style: ie(n)
|
|
86
|
+
}) : null;
|
|
87
|
+
}
|
|
88
|
+
function ae({ field: e, size: t }) {
|
|
89
|
+
return /* @__PURE__ */ A(Z, {
|
|
90
|
+
icon: e.icon,
|
|
91
|
+
size: t
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function oe(e, t) {
|
|
95
|
+
return Array.isArray(e.value) ? e.value.map((e) => t.options?.find((t) => t.value === e) ?? {
|
|
96
|
+
value: e,
|
|
97
|
+
label: e
|
|
98
|
+
}) : [];
|
|
99
|
+
}
|
|
100
|
+
function se({ filter: e, field: t, locale: n }) {
|
|
101
|
+
if (!v(e)) return /* @__PURE__ */ A("span", {
|
|
102
|
+
className: "text-foreground/70",
|
|
103
|
+
children: "Select…"
|
|
104
|
+
});
|
|
105
|
+
if (Array.isArray(e.value)) {
|
|
106
|
+
let n = oe(e, t), r = n.filter((e) => e.icon || e.color).slice(0, 3);
|
|
107
|
+
return /* @__PURE__ */ j(k, { children: [r.length ? /* @__PURE__ */ A("span", {
|
|
108
|
+
className: "flex shrink-0 items-center -space-x-1",
|
|
109
|
+
children: r.map((e) => /* @__PURE__ */ A(Z, {
|
|
110
|
+
icon: e.icon,
|
|
111
|
+
color: e.color
|
|
112
|
+
}, e.value))
|
|
113
|
+
}) : null, /* @__PURE__ */ A("span", {
|
|
114
|
+
className: "truncate",
|
|
115
|
+
children: n.length <= 2 ? n.map((e) => e.label).join(", ") : `${n.length} selected`
|
|
116
|
+
})] });
|
|
117
|
+
}
|
|
118
|
+
return /* @__PURE__ */ A("span", {
|
|
119
|
+
className: "truncate",
|
|
120
|
+
children: g(e, t, n)
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function ce(e) {
|
|
124
|
+
let t = e.value, n = Array.isArray(t) ? "select" : typeof t == "boolean" ? "boolean" : typeof t == "number" ? "number" : typeof t == "string" ? "text" : "date";
|
|
125
|
+
return {
|
|
126
|
+
id: e.field,
|
|
127
|
+
label: e.field,
|
|
128
|
+
kind: n
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function le({ label: n, placeholder: i, autoFocus: a, onBack: o }) {
|
|
132
|
+
return /* @__PURE__ */ j(L, {
|
|
133
|
+
"data-slot": "filter-search",
|
|
134
|
+
"aria-label": n,
|
|
135
|
+
autoFocus: a,
|
|
136
|
+
onKeyDown: (e) => {
|
|
137
|
+
o && e.key === "Backspace" && e.target.value === "" && o();
|
|
138
|
+
},
|
|
139
|
+
className: "flex h-10 items-center gap-2 border-b border-border px-3 focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring/45",
|
|
140
|
+
children: [/* @__PURE__ */ A(t, {
|
|
141
|
+
name: "search",
|
|
142
|
+
size: 16,
|
|
143
|
+
sw: 2.2,
|
|
144
|
+
className: "shrink-0 text-foreground/70"
|
|
145
|
+
}), /* @__PURE__ */ A(F, {
|
|
146
|
+
placeholder: i,
|
|
147
|
+
className: e("min-w-0 flex-1 appearance-none border-0 bg-transparent p-0 [font-family:inherit] text-subhead text-foreground outline-none placeholder:text-tertiary-foreground [&::-webkit-search-cancel-button]:appearance-none", r)
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
var ue = ({ children: e }) => /* @__PURE__ */ A("div", {
|
|
152
|
+
className: "px-3 py-6 text-center text-footnote text-foreground/70",
|
|
153
|
+
children: e
|
|
154
|
+
});
|
|
155
|
+
function Q({ id: e, icon: n, checked: r, trailing: i, children: a, onAction: o, textValue: s }) {
|
|
156
|
+
return /* @__PURE__ */ j(I, {
|
|
157
|
+
id: e,
|
|
158
|
+
textValue: s,
|
|
159
|
+
onAction: o,
|
|
160
|
+
className: d({ variant: "popup" }),
|
|
161
|
+
children: [
|
|
162
|
+
n ? /* @__PURE__ */ A("span", {
|
|
163
|
+
className: "grid shrink-0 place-items-center text-foreground/70",
|
|
164
|
+
children: n
|
|
165
|
+
}) : null,
|
|
166
|
+
/* @__PURE__ */ A("span", {
|
|
167
|
+
className: "min-w-0 flex-1 truncate",
|
|
168
|
+
children: a
|
|
169
|
+
}),
|
|
170
|
+
i,
|
|
171
|
+
r ? /* @__PURE__ */ A(t, {
|
|
172
|
+
name: "check",
|
|
173
|
+
size: 16,
|
|
174
|
+
sw: 2.4,
|
|
175
|
+
className: "shrink-0 text-primary"
|
|
176
|
+
}) : null
|
|
177
|
+
]
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function de({ field: n, value: r, onChange: a, onBack: o }) {
|
|
181
|
+
let { contains: s } = H({ sensitivity: "base" }), c = n.options ?? [];
|
|
182
|
+
return /* @__PURE__ */ j(M, {
|
|
183
|
+
filter: (e, t) => s(e, t),
|
|
184
|
+
children: [/* @__PURE__ */ A(le, {
|
|
185
|
+
label: `Search ${n.label.toLowerCase()}`,
|
|
186
|
+
placeholder: `Search ${n.label.toLowerCase()}…`,
|
|
187
|
+
autoFocus: !0,
|
|
188
|
+
onBack: o
|
|
189
|
+
}), /* @__PURE__ */ A(u, {
|
|
190
|
+
variant: "popup",
|
|
191
|
+
"aria-label": n.label,
|
|
192
|
+
selectionMode: "multiple",
|
|
193
|
+
escapeKeyBehavior: "none",
|
|
194
|
+
selectedKeys: new Set(r),
|
|
195
|
+
onSelectionChange: (e) => {
|
|
196
|
+
let t = new Set(e === "all" ? c.map((e) => e.value) : [...e].map(String));
|
|
197
|
+
a([...c.map((e) => e.value).filter((e) => t.has(e)), ...[...t].filter((e) => !c.some((t) => t.value === e))]);
|
|
198
|
+
},
|
|
199
|
+
items: c.map((e) => ({
|
|
200
|
+
...e,
|
|
201
|
+
id: e.value
|
|
202
|
+
})),
|
|
203
|
+
className: "max-h-64",
|
|
204
|
+
renderEmptyState: () => /* @__PURE__ */ A(ue, { children: "No matches" }),
|
|
205
|
+
children: (n) => /* @__PURE__ */ j(I, {
|
|
206
|
+
id: n.value,
|
|
207
|
+
textValue: [n.label, ...n.keywords ?? []].join(" "),
|
|
208
|
+
className: e("group", d({ variant: "popup" })),
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ A("span", {
|
|
211
|
+
"aria-hidden": "true",
|
|
212
|
+
className: e(i({ shape: "square" }), "size-4.5"),
|
|
213
|
+
children: /* @__PURE__ */ A(t, {
|
|
214
|
+
name: "check",
|
|
215
|
+
size: 12,
|
|
216
|
+
sw: 3.2,
|
|
217
|
+
className: "opacity-0 group-data-selected:opacity-100"
|
|
218
|
+
})
|
|
219
|
+
}),
|
|
220
|
+
/* @__PURE__ */ A(Z, {
|
|
221
|
+
icon: n.icon,
|
|
222
|
+
color: n.color
|
|
223
|
+
}),
|
|
224
|
+
/* @__PURE__ */ A("span", {
|
|
225
|
+
className: "min-w-0 flex-1 truncate",
|
|
226
|
+
children: n.label
|
|
227
|
+
}),
|
|
228
|
+
n.count === void 0 ? null : /* @__PURE__ */ A("span", {
|
|
229
|
+
className: "shrink-0 text-caption text-foreground/70 tabular-nums",
|
|
230
|
+
children: n.count
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
})
|
|
234
|
+
})]
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function fe({ value: e, onChange: t, onDone: n }) {
|
|
238
|
+
let r = (e) => () => {
|
|
239
|
+
t(e), n?.();
|
|
240
|
+
};
|
|
241
|
+
return /* @__PURE__ */ j(u, {
|
|
242
|
+
variant: "popup",
|
|
243
|
+
"aria-label": "Value",
|
|
244
|
+
selectionMode: "none",
|
|
245
|
+
children: [/* @__PURE__ */ A(Q, {
|
|
246
|
+
id: "yes",
|
|
247
|
+
textValue: "Yes",
|
|
248
|
+
checked: e === !0,
|
|
249
|
+
onAction: r(!0),
|
|
250
|
+
children: "Yes"
|
|
251
|
+
}), /* @__PURE__ */ A(Q, {
|
|
252
|
+
id: "no",
|
|
253
|
+
textValue: "No",
|
|
254
|
+
checked: e === !1,
|
|
255
|
+
onAction: r(!1),
|
|
256
|
+
children: "No"
|
|
257
|
+
})]
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function pe({ field: t, value: n, onChange: i, onDone: a, onBack: o }) {
|
|
261
|
+
let s = t.kind === "number", c = typeof n == "number" || typeof n == "string" ? String(n) : "", [l, u] = O(c), d = D(c), f = (e) => {
|
|
262
|
+
let t = l.trim();
|
|
263
|
+
t === "" || s && !Number.isFinite(Number(t)) || (t !== d.current && (d.current = t, i(s ? Number(t) : t)), e && a?.());
|
|
264
|
+
};
|
|
265
|
+
return /* @__PURE__ */ j("div", {
|
|
266
|
+
className: "flex flex-col gap-2 p-2.5",
|
|
267
|
+
children: [/* @__PURE__ */ A(R, {
|
|
268
|
+
"aria-label": `${t.label} ${s ? "number" : "text"}`,
|
|
269
|
+
value: l,
|
|
270
|
+
onChange: u,
|
|
271
|
+
type: s ? "number" : "text",
|
|
272
|
+
inputMode: s ? "decimal" : void 0,
|
|
273
|
+
children: /* @__PURE__ */ A(F, {
|
|
274
|
+
autoFocus: !0,
|
|
275
|
+
placeholder: s ? "Enter a number…" : `${t.label} contains…`,
|
|
276
|
+
onKeyDown: (e) => {
|
|
277
|
+
e.key === "Enter" ? (e.preventDefault(), f(!0)) : e.key === "Backspace" && l === "" && o && o();
|
|
278
|
+
},
|
|
279
|
+
onBlur: () => f(!1),
|
|
280
|
+
className: e("box-border h-9 w-full rounded-lg border-0 bg-input px-3 [font-family:inherit] text-subhead text-foreground outline-none placeholder:text-tertiary-foreground data-focused:ring-2 data-focused:ring-ring/45", r)
|
|
281
|
+
})
|
|
282
|
+
}), /* @__PURE__ */ j("div", {
|
|
283
|
+
className: "flex items-center justify-between gap-2 text-caption text-foreground/70",
|
|
284
|
+
children: [/* @__PURE__ */ A("span", { children: "Press Enter to apply" }), /* @__PURE__ */ A(N, {
|
|
285
|
+
onPress: () => f(!0),
|
|
286
|
+
isDisabled: l.trim() === "",
|
|
287
|
+
className: "bl-btn h-7 cursor-pointer rounded-lg border-0 bg-primary px-3 [font-family:inherit] text-footnote font-semibold text-primary-foreground outline-none data-disabled:cursor-default data-disabled:opacity-40 data-focus-visible:ring-2 data-focus-visible:ring-ring data-focus-visible:ring-offset-2",
|
|
288
|
+
children: "Apply"
|
|
289
|
+
})]
|
|
290
|
+
})]
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
var me = /^\d{4}-\d{2}-\d{2}$/;
|
|
294
|
+
function he({ operator: t, value: i, onChange: a, onDone: o }) {
|
|
295
|
+
let s = _(i) ? i : void 0, c = s?.type === "relative" ? s : {
|
|
296
|
+
type: "relative",
|
|
297
|
+
amount: 7,
|
|
298
|
+
unit: "day"
|
|
299
|
+
}, [l, d] = O(String(c.amount)), [m, h] = O(s?.type === "date" ? s.date : ""), g = "rounded-lg border-0 bg-input px-3 [font-family:inherit] text-subhead text-foreground outline-none data-focused:ring-2 data-focused:ring-ring/45";
|
|
300
|
+
if (t === "in_the_last") {
|
|
301
|
+
let t = (e, t) => {
|
|
302
|
+
let n = Math.floor(Number(e));
|
|
303
|
+
Number.isFinite(n) && n > 0 && a({
|
|
304
|
+
type: "relative",
|
|
305
|
+
amount: n,
|
|
306
|
+
unit: t
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
return /* @__PURE__ */ j("div", {
|
|
310
|
+
className: "flex flex-col gap-2.5 p-2.5",
|
|
311
|
+
children: [/* @__PURE__ */ A(R, {
|
|
312
|
+
"aria-label": "How many",
|
|
313
|
+
value: l,
|
|
314
|
+
onChange: (e) => {
|
|
315
|
+
d(e), t(e, c.unit);
|
|
316
|
+
},
|
|
317
|
+
type: "number",
|
|
318
|
+
inputMode: "numeric",
|
|
319
|
+
children: /* @__PURE__ */ A(F, {
|
|
320
|
+
autoFocus: !0,
|
|
321
|
+
min: 1,
|
|
322
|
+
onKeyDown: (e) => {
|
|
323
|
+
e.key === "Enter" && (e.preventDefault(), t(l, c.unit), o?.());
|
|
324
|
+
},
|
|
325
|
+
className: e("box-border h-9 w-full tabular-nums", g, r)
|
|
326
|
+
})
|
|
327
|
+
}), /* @__PURE__ */ A(n, {
|
|
328
|
+
"aria-label": "Unit",
|
|
329
|
+
value: c.unit,
|
|
330
|
+
onChange: (e) => t(l, e),
|
|
331
|
+
options: p.map((e) => ({
|
|
332
|
+
id: e,
|
|
333
|
+
label: `${e}s`
|
|
334
|
+
}))
|
|
335
|
+
})]
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
let v = (e) => {
|
|
339
|
+
me.test(m) && (s?.type !== "date" || s.date !== m) && a({
|
|
340
|
+
type: "date",
|
|
341
|
+
date: m
|
|
342
|
+
}), e && me.test(m) && o?.();
|
|
343
|
+
};
|
|
344
|
+
return /* @__PURE__ */ j("div", { children: [/* @__PURE__ */ A(u, {
|
|
345
|
+
variant: "popup",
|
|
346
|
+
"aria-label": "Date",
|
|
347
|
+
selectionMode: "none",
|
|
348
|
+
className: "max-h-56",
|
|
349
|
+
children: f.map((e) => /* @__PURE__ */ A(Q, {
|
|
350
|
+
id: e.id,
|
|
351
|
+
textValue: e.label,
|
|
352
|
+
checked: s?.type === "preset" && s.preset === e.id,
|
|
353
|
+
onAction: () => {
|
|
354
|
+
a({
|
|
355
|
+
type: "preset",
|
|
356
|
+
preset: e.id
|
|
357
|
+
}), o?.();
|
|
358
|
+
},
|
|
359
|
+
children: e.label
|
|
360
|
+
}, e.id))
|
|
361
|
+
}), /* @__PURE__ */ A("div", {
|
|
362
|
+
className: "border-t border-border p-2.5",
|
|
363
|
+
children: /* @__PURE__ */ A(R, {
|
|
364
|
+
"aria-label": "Pick a date",
|
|
365
|
+
value: m,
|
|
366
|
+
onChange: h,
|
|
367
|
+
type: "date",
|
|
368
|
+
children: /* @__PURE__ */ A(F, {
|
|
369
|
+
onBlur: () => v(!1),
|
|
370
|
+
onKeyDown: (e) => {
|
|
371
|
+
e.key === "Enter" && (e.preventDefault(), v(!0));
|
|
372
|
+
},
|
|
373
|
+
className: e("box-border h-9 w-full", g, r)
|
|
374
|
+
})
|
|
375
|
+
})
|
|
376
|
+
})] });
|
|
377
|
+
}
|
|
378
|
+
function $({ field: e, operator: t, value: n, onChange: r, onDone: i, onBack: a }) {
|
|
379
|
+
switch (e.kind) {
|
|
380
|
+
case "select":
|
|
381
|
+
case "multiselect": return /* @__PURE__ */ A(de, {
|
|
382
|
+
field: e,
|
|
383
|
+
value: Array.isArray(n) ? n : [],
|
|
384
|
+
onChange: r,
|
|
385
|
+
onBack: a
|
|
386
|
+
});
|
|
387
|
+
case "boolean": return /* @__PURE__ */ A(fe, {
|
|
388
|
+
value: n,
|
|
389
|
+
onChange: r,
|
|
390
|
+
onDone: i
|
|
391
|
+
});
|
|
392
|
+
case "date": return /* @__PURE__ */ A(he, {
|
|
393
|
+
operator: t,
|
|
394
|
+
value: n,
|
|
395
|
+
onChange: r,
|
|
396
|
+
onDone: i
|
|
397
|
+
});
|
|
398
|
+
default: return /* @__PURE__ */ A(pe, {
|
|
399
|
+
field: e,
|
|
400
|
+
value: n,
|
|
401
|
+
onChange: r,
|
|
402
|
+
onDone: i,
|
|
403
|
+
onBack: a
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function ge(e) {
|
|
408
|
+
return e instanceof Element && !!e.closest("input, textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"], [role=\"textbox\"], [role=\"searchbox\"], [role=\"combobox\"]");
|
|
409
|
+
}
|
|
410
|
+
function _e({ fields: n, state: r, hotkey: i = null, children: s, label: c = "Filter", isOpen: l, defaultOpen: f = !1, onOpenChange: p, placement: h = "bottom start", className: g, popoverClassName: _, allowDuplicates: v }) {
|
|
411
|
+
let y = K(), b = n ?? y?.fields ?? [], x = y ?? r, C = v ?? y?.allowDuplicates ?? !1, [T, E] = O(f), D = l ?? T, [k, F] = O(null), [L, R] = O(null), { contains: z } = H({ sensitivity: "base" }), B = w((e) => {
|
|
412
|
+
e && (F(null), R(null)), E(e), p?.(e);
|
|
413
|
+
}, [p]);
|
|
414
|
+
if (ee(() => {
|
|
415
|
+
if (!i) return;
|
|
416
|
+
let e = i.toLowerCase(), t = (t) => {
|
|
417
|
+
t.defaultPrevented || t.metaKey || t.ctrlKey || t.altKey || t.key.toLowerCase() !== e || ge(t.target) || t.target instanceof Element && t.target.closest("[role=\"dialog\"], [role=\"alertdialog\"], [role=\"menu\"]") || (t.preventDefault(), B(!0));
|
|
418
|
+
};
|
|
419
|
+
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
420
|
+
}, [i, B]), !x) return null;
|
|
421
|
+
let V = L ? x.filters.find((e) => e.id === L) : void 0, U = new Set(x.filters.map((e) => e.field)), W = b.filter((e) => C || !U.has(e.id));
|
|
422
|
+
return /* @__PURE__ */ j(o, {
|
|
423
|
+
isOpen: D,
|
|
424
|
+
onOpenChange: B,
|
|
425
|
+
children: [s ?? /* @__PURE__ */ j(N, {
|
|
426
|
+
"data-slot": "filter-menu-trigger",
|
|
427
|
+
"aria-keyshortcuts": i ? i.toUpperCase() : void 0,
|
|
428
|
+
className: e(X, g),
|
|
429
|
+
children: [/* @__PURE__ */ A(t, {
|
|
430
|
+
name: "filter-circle",
|
|
431
|
+
size: 16,
|
|
432
|
+
sw: 2
|
|
433
|
+
}), c]
|
|
434
|
+
}), /* @__PURE__ */ A(a, {
|
|
435
|
+
"data-slot": "filter-menu",
|
|
436
|
+
placement: h,
|
|
437
|
+
className: e("w-64 min-w-0 overflow-hidden", _),
|
|
438
|
+
children: /* @__PURE__ */ A(P, {
|
|
439
|
+
"aria-label": k ? `${k.label} filter` : "Add filter",
|
|
440
|
+
className: "outline-none",
|
|
441
|
+
children: k ? /* @__PURE__ */ j("div", {
|
|
442
|
+
"data-slot": "filter-menu-value",
|
|
443
|
+
children: [/* @__PURE__ */ j("div", {
|
|
444
|
+
className: "flex items-center gap-1 border-b border-border px-1.5 py-1",
|
|
445
|
+
children: [
|
|
446
|
+
/* @__PURE__ */ A(N, {
|
|
447
|
+
"aria-label": "Back to fields",
|
|
448
|
+
onPress: () => {
|
|
449
|
+
F(null);
|
|
450
|
+
},
|
|
451
|
+
className: "bl-btn grid size-7 shrink-0 cursor-pointer place-items-center rounded-lg border-0 bg-transparent p-0 text-foreground/70 outline-none data-hovered:bg-accent data-pressed:bg-secondary-strong data-focus-visible:ring-2 data-focus-visible:ring-ring",
|
|
452
|
+
children: /* @__PURE__ */ A(t, {
|
|
453
|
+
name: "chevron-left",
|
|
454
|
+
size: 16,
|
|
455
|
+
sw: 2.4
|
|
456
|
+
})
|
|
457
|
+
}),
|
|
458
|
+
/* @__PURE__ */ A(ae, { field: k }),
|
|
459
|
+
/* @__PURE__ */ A("span", {
|
|
460
|
+
className: "truncate text-subhead font-semibold",
|
|
461
|
+
children: k.label
|
|
462
|
+
})
|
|
463
|
+
]
|
|
464
|
+
}), /* @__PURE__ */ A($, {
|
|
465
|
+
field: k,
|
|
466
|
+
operator: V?.operator,
|
|
467
|
+
value: V?.value,
|
|
468
|
+
onChange: (e) => {
|
|
469
|
+
if (k) {
|
|
470
|
+
if (V) {
|
|
471
|
+
if (Array.isArray(e) && e.length === 0) {
|
|
472
|
+
x.remove(V.id), R(null);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
let t = S(k, V, e);
|
|
476
|
+
x.update(V.id, {
|
|
477
|
+
operator: t.operator,
|
|
478
|
+
value: t.value
|
|
479
|
+
});
|
|
480
|
+
} else if (!(Array.isArray(e) && e.length === 0)) {
|
|
481
|
+
let t = m(k, e);
|
|
482
|
+
x.add(t), R(t.id);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
onDone: () => B(!1),
|
|
487
|
+
onBack: () => F(null)
|
|
488
|
+
})]
|
|
489
|
+
}) : /* @__PURE__ */ j(M, {
|
|
490
|
+
filter: (e, t) => z(e, t),
|
|
491
|
+
children: [/* @__PURE__ */ A(le, {
|
|
492
|
+
label: "Filter by",
|
|
493
|
+
placeholder: "Filter by…",
|
|
494
|
+
autoFocus: !0
|
|
495
|
+
}), /* @__PURE__ */ A(u, {
|
|
496
|
+
variant: "popup",
|
|
497
|
+
"aria-label": "Fields",
|
|
498
|
+
className: "max-h-72",
|
|
499
|
+
items: W,
|
|
500
|
+
renderEmptyState: () => /* @__PURE__ */ A(ue, { children: b.length && !W.length ? "Every field is already filtered" : "No matching fields" }),
|
|
501
|
+
children: (e) => /* @__PURE__ */ j(I, {
|
|
502
|
+
id: e.id,
|
|
503
|
+
textValue: e.label,
|
|
504
|
+
onAction: () => F(e),
|
|
505
|
+
className: d({ variant: "popup" }),
|
|
506
|
+
children: [/* @__PURE__ */ A(Z, { icon: e.icon }), /* @__PURE__ */ A("span", {
|
|
507
|
+
className: "min-w-0 flex-1 truncate",
|
|
508
|
+
children: e.label
|
|
509
|
+
})]
|
|
510
|
+
})
|
|
511
|
+
})]
|
|
512
|
+
})
|
|
513
|
+
})
|
|
514
|
+
})]
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
function ve({ filter: t, field: n, onChange: r }) {
|
|
518
|
+
let i = Array.isArray(t.value) ? t.value.length : 2, a = y(t.operator, i), o = b(n.kind);
|
|
519
|
+
return o.length < 2 ? /* @__PURE__ */ A("span", {
|
|
520
|
+
"data-slot": "filter-chip-operator",
|
|
521
|
+
className: e(J, "text-foreground/70"),
|
|
522
|
+
children: a
|
|
523
|
+
}) : /* @__PURE__ */ j(s, { children: [/* @__PURE__ */ A(N, {
|
|
524
|
+
"data-slot": "filter-chip-operator",
|
|
525
|
+
"data-part": "operator",
|
|
526
|
+
"aria-label": `${n.label} operator: ${a}`,
|
|
527
|
+
className: e(J, Y, "text-foreground/70"),
|
|
528
|
+
children: a
|
|
529
|
+
}), /* @__PURE__ */ A(c, {
|
|
530
|
+
placement: "bottom start",
|
|
531
|
+
"aria-label": `${n.label} operator`,
|
|
532
|
+
selectionMode: "single",
|
|
533
|
+
disallowEmptySelection: !0,
|
|
534
|
+
selectedKeys: [t.operator],
|
|
535
|
+
onSelectionChange: (e) => {
|
|
536
|
+
let i = [...e][0];
|
|
537
|
+
i && i !== t.operator && r(x(n, t, i));
|
|
538
|
+
},
|
|
539
|
+
popoverClassName: "min-w-44",
|
|
540
|
+
children: o.map((e) => /* @__PURE__ */ A(l, {
|
|
541
|
+
id: e,
|
|
542
|
+
textValue: y(e, 2),
|
|
543
|
+
className: "min-h-9 py-1.5 text-subhead",
|
|
544
|
+
children: y(e, 2)
|
|
545
|
+
}, e))
|
|
546
|
+
})] });
|
|
547
|
+
}
|
|
548
|
+
function ye({ filter: t, field: n, locale: r, onChange: i }) {
|
|
549
|
+
let [s, c] = O(!1), l = g(t, n, r);
|
|
550
|
+
return /* @__PURE__ */ j(o, {
|
|
551
|
+
isOpen: s,
|
|
552
|
+
onOpenChange: c,
|
|
553
|
+
children: [/* @__PURE__ */ A(N, {
|
|
554
|
+
"data-slot": "filter-chip-value",
|
|
555
|
+
"data-part": "value",
|
|
556
|
+
"aria-label": `${n.label} value: ${v(t) ? l : "none selected"}`,
|
|
557
|
+
className: e(J, Y, "max-w-56 font-medium"),
|
|
558
|
+
children: /* @__PURE__ */ A(se, {
|
|
559
|
+
filter: t,
|
|
560
|
+
field: n,
|
|
561
|
+
locale: r
|
|
562
|
+
})
|
|
563
|
+
}), /* @__PURE__ */ A(a, {
|
|
564
|
+
placement: "bottom start",
|
|
565
|
+
className: "w-64 min-w-0 overflow-hidden",
|
|
566
|
+
children: /* @__PURE__ */ A(P, {
|
|
567
|
+
"aria-label": `Edit ${n.label}`,
|
|
568
|
+
className: "outline-none",
|
|
569
|
+
children: /* @__PURE__ */ A($, {
|
|
570
|
+
field: n,
|
|
571
|
+
operator: t.operator,
|
|
572
|
+
value: t.value,
|
|
573
|
+
onChange: (e) => i(S(n, t, e)),
|
|
574
|
+
onDone: () => c(!1)
|
|
575
|
+
})
|
|
576
|
+
})
|
|
577
|
+
})]
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
function be({ filter: n, field: r, onChange: i, onRemove: a, readOnly: o, size: s, tone: c, locale: l, className: u, onKeyDown: d, ...f }) {
|
|
581
|
+
let p = K(), m = r ?? p?.fields.find((e) => e.id === n.field) ?? ce(n), g = l ?? p?.locale ?? "en-US", _ = h(n, [m], g), v = i ?? ((e) => p?.update(n.id, {
|
|
582
|
+
operator: e.operator,
|
|
583
|
+
value: e.value
|
|
584
|
+
})), b = a ?? (() => p?.removeAndFocus(n.id)), x = Array.isArray(n.value) ? n.value.length : 2;
|
|
585
|
+
return /* @__PURE__ */ j("div", {
|
|
586
|
+
"data-slot": "filter-chip",
|
|
587
|
+
"data-filter-id": n.id,
|
|
588
|
+
role: "group",
|
|
589
|
+
"aria-label": _,
|
|
590
|
+
onKeyDown: (e) => {
|
|
591
|
+
d?.(e), !o && !e.defaultPrevented && (e.key === "Backspace" || e.key === "Delete") && e.currentTarget.contains(e.target) && (e.preventDefault(), b());
|
|
592
|
+
},
|
|
593
|
+
className: e(re({
|
|
594
|
+
size: s,
|
|
595
|
+
tone: c
|
|
596
|
+
}), u),
|
|
597
|
+
...f,
|
|
598
|
+
children: [/* @__PURE__ */ j("span", {
|
|
599
|
+
"data-slot": "filter-chip-field",
|
|
600
|
+
className: e(J, "font-medium"),
|
|
601
|
+
children: [/* @__PURE__ */ A(ae, { field: m }), /* @__PURE__ */ A("span", {
|
|
602
|
+
className: "truncate",
|
|
603
|
+
children: m.label
|
|
604
|
+
})]
|
|
605
|
+
}), o ? /* @__PURE__ */ j(k, { children: [/* @__PURE__ */ A("span", {
|
|
606
|
+
"data-slot": "filter-chip-operator",
|
|
607
|
+
className: e(J, "text-foreground/70"),
|
|
608
|
+
children: y(n.operator, x)
|
|
609
|
+
}), /* @__PURE__ */ A("span", {
|
|
610
|
+
"data-slot": "filter-chip-value",
|
|
611
|
+
className: e(J, "max-w-56 font-medium"),
|
|
612
|
+
children: /* @__PURE__ */ A(se, {
|
|
613
|
+
filter: n,
|
|
614
|
+
field: m,
|
|
615
|
+
locale: g
|
|
616
|
+
})
|
|
617
|
+
})] }) : /* @__PURE__ */ j(k, { children: [
|
|
618
|
+
/* @__PURE__ */ A(ve, {
|
|
619
|
+
filter: n,
|
|
620
|
+
field: m,
|
|
621
|
+
onChange: v
|
|
622
|
+
}),
|
|
623
|
+
/* @__PURE__ */ A(ye, {
|
|
624
|
+
filter: n,
|
|
625
|
+
field: m,
|
|
626
|
+
locale: g,
|
|
627
|
+
onChange: v
|
|
628
|
+
}),
|
|
629
|
+
/* @__PURE__ */ A(N, {
|
|
630
|
+
"data-slot": "filter-chip-remove",
|
|
631
|
+
"data-part": "remove",
|
|
632
|
+
"aria-label": `Remove filter: ${_}`,
|
|
633
|
+
onPress: b,
|
|
634
|
+
className: e(J, Y, "px-1.5 text-foreground/70"),
|
|
635
|
+
children: /* @__PURE__ */ A(t, {
|
|
636
|
+
name: "xmark",
|
|
637
|
+
size: 12,
|
|
638
|
+
sw: 2.6
|
|
639
|
+
})
|
|
640
|
+
})
|
|
641
|
+
] })]
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function xe({ className: t, children: n, ...r }) {
|
|
645
|
+
let { filters: i } = q();
|
|
646
|
+
return i.length ? /* @__PURE__ */ A("ul", {
|
|
647
|
+
"data-slot": "filter-list",
|
|
648
|
+
"aria-label": "Active filters",
|
|
649
|
+
className: e("m-0 flex min-w-0 list-none flex-wrap items-center gap-1.5 p-0", t),
|
|
650
|
+
...r,
|
|
651
|
+
children: i.map((e) => /* @__PURE__ */ A("li", {
|
|
652
|
+
"data-slot": "filter-list-item",
|
|
653
|
+
className: "m-0 flex min-w-0 max-w-full p-0",
|
|
654
|
+
children: n ? n(e) : /* @__PURE__ */ A(be, { filter: e })
|
|
655
|
+
}, e.id))
|
|
656
|
+
}) : null;
|
|
657
|
+
}
|
|
658
|
+
function Se({ className: t, children: n = "Clear all", ...r }) {
|
|
659
|
+
let { filters: i, clear: a } = q();
|
|
660
|
+
return i.length ? /* @__PURE__ */ A(N, {
|
|
661
|
+
"data-slot": "filter-clear",
|
|
662
|
+
onPress: a,
|
|
663
|
+
className: B(t, (t) => e(X, t)),
|
|
664
|
+
...r,
|
|
665
|
+
children: n
|
|
666
|
+
}) : null;
|
|
667
|
+
}
|
|
668
|
+
function Ce({ className: n }) {
|
|
669
|
+
let { filters: r, match: i, setMatch: a, announce: o } = q();
|
|
670
|
+
return r.length < 2 ? null : /* @__PURE__ */ j(s, { children: [/* @__PURE__ */ j(N, {
|
|
671
|
+
"data-slot": "filter-match",
|
|
672
|
+
"aria-label": `Match mode: ${i === "all" ? "all filters" : "any filter"}`,
|
|
673
|
+
className: e(X, n),
|
|
674
|
+
children: [
|
|
675
|
+
"Match ",
|
|
676
|
+
i,
|
|
677
|
+
/* @__PURE__ */ A(t, {
|
|
678
|
+
name: "chevron-down",
|
|
679
|
+
size: 11,
|
|
680
|
+
sw: 2.4,
|
|
681
|
+
className: "opacity-60"
|
|
682
|
+
})
|
|
683
|
+
]
|
|
684
|
+
}), /* @__PURE__ */ j(c, {
|
|
685
|
+
placement: "bottom start",
|
|
686
|
+
"aria-label": "Match mode",
|
|
687
|
+
selectionMode: "single",
|
|
688
|
+
disallowEmptySelection: !0,
|
|
689
|
+
selectedKeys: [i],
|
|
690
|
+
onSelectionChange: (e) => {
|
|
691
|
+
let t = [...e][0];
|
|
692
|
+
t && t !== i && (a(t), o(t === "all" ? "Matching all filters" : "Matching any filter"));
|
|
693
|
+
},
|
|
694
|
+
popoverClassName: "min-w-48",
|
|
695
|
+
children: [/* @__PURE__ */ A(l, {
|
|
696
|
+
id: "all",
|
|
697
|
+
textValue: "Match all filters",
|
|
698
|
+
className: "min-h-9 py-1.5 text-subhead",
|
|
699
|
+
children: "Match all filters"
|
|
700
|
+
}), /* @__PURE__ */ A(l, {
|
|
701
|
+
id: "any",
|
|
702
|
+
textValue: "Match any filter",
|
|
703
|
+
className: "min-h-9 py-1.5 text-subhead",
|
|
704
|
+
children: "Match any filter"
|
|
705
|
+
})]
|
|
706
|
+
})] });
|
|
707
|
+
}
|
|
708
|
+
function we({ className: t, children: n, hotkey: r, showMatch: i = !1, ...a }) {
|
|
709
|
+
return /* @__PURE__ */ A(z, {
|
|
710
|
+
"data-slot": "filter-toolbar",
|
|
711
|
+
"aria-label": "Filters",
|
|
712
|
+
className: B(t, (t) => e(ne(), t)),
|
|
713
|
+
...a,
|
|
714
|
+
children: n ?? /* @__PURE__ */ j(k, { children: [
|
|
715
|
+
/* @__PURE__ */ A(_e, { hotkey: r }),
|
|
716
|
+
/* @__PURE__ */ A(xe, {}),
|
|
717
|
+
i ? /* @__PURE__ */ A(Ce, {}) : null,
|
|
718
|
+
/* @__PURE__ */ A(Se, {})
|
|
719
|
+
] })
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
function Te({ fields: t, value: n, defaultValue: r, onValueChange: i, match: a, defaultMatch: o, onMatchChange: s, allowDuplicates: c = !1, hotkey: l = null, showMatch: u = !1, locale: d = "en-US", className: f, children: p, ...m }) {
|
|
723
|
+
let g = W({
|
|
724
|
+
value: n,
|
|
725
|
+
defaultValue: r,
|
|
726
|
+
onValueChange: i,
|
|
727
|
+
match: a,
|
|
728
|
+
defaultMatch: o,
|
|
729
|
+
onMatchChange: s
|
|
730
|
+
}), _ = D(null), [v, y] = O(""), b = D(!1), x = w((e) => {
|
|
731
|
+
b.current = !b.current, y(b.current ? e : `${e}`);
|
|
732
|
+
}, []), S = D(null), { filters: C, setFilters: T } = g, k = E(() => {
|
|
733
|
+
let e = (e) => h(e, t, d);
|
|
734
|
+
return {
|
|
735
|
+
...g,
|
|
736
|
+
fields: t,
|
|
737
|
+
allowDuplicates: c,
|
|
738
|
+
locale: d,
|
|
739
|
+
announce: x,
|
|
740
|
+
add: (t) => {
|
|
741
|
+
g.add(t), x(`Filter added: ${e(t)}`);
|
|
742
|
+
},
|
|
743
|
+
update: (t, n) => {
|
|
744
|
+
let r = C.find((e) => e.id === t);
|
|
745
|
+
g.update(t, n), r && x(`Filter changed: ${e({
|
|
746
|
+
...r,
|
|
747
|
+
...n
|
|
748
|
+
})}`);
|
|
749
|
+
},
|
|
750
|
+
remove: (t) => {
|
|
751
|
+
let n = C.find((e) => e.id === t);
|
|
752
|
+
g.remove(t), n && x(`Filter removed: ${e(n)}`);
|
|
753
|
+
},
|
|
754
|
+
clear: () => {
|
|
755
|
+
C.length && (g.clear(), x(C.length === 1 ? "Filter cleared" : `All ${C.length} filters cleared`));
|
|
756
|
+
},
|
|
757
|
+
removeAndFocus: (t) => {
|
|
758
|
+
let n = C.findIndex((e) => e.id === t), r = C[n + 1] ?? C[n - 1];
|
|
759
|
+
S.current = r?.id ?? "";
|
|
760
|
+
let i = C[n];
|
|
761
|
+
g.remove(t), i && x(`Filter removed: ${e(i)}`);
|
|
762
|
+
},
|
|
763
|
+
apply: (t, n = "merge") => {
|
|
764
|
+
t.length && (T((e) => {
|
|
765
|
+
if (n === "replace") return t;
|
|
766
|
+
let r = [...e];
|
|
767
|
+
for (let e of t) {
|
|
768
|
+
let t = c ? -1 : r.findIndex((t) => t.field === e.field);
|
|
769
|
+
t >= 0 ? r[t] = {
|
|
770
|
+
...e,
|
|
771
|
+
id: r[t].id
|
|
772
|
+
} : r.push(e);
|
|
773
|
+
}
|
|
774
|
+
return r;
|
|
775
|
+
}), x(`${t.length === 1 ? "Filter" : `${t.length} filters`} applied: ${t.map(e).join("; ")}`));
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
}, [
|
|
779
|
+
g,
|
|
780
|
+
t,
|
|
781
|
+
c,
|
|
782
|
+
d,
|
|
783
|
+
x,
|
|
784
|
+
C,
|
|
785
|
+
T
|
|
786
|
+
]);
|
|
787
|
+
return ee(() => {
|
|
788
|
+
let e = S.current;
|
|
789
|
+
if (e === null) return;
|
|
790
|
+
S.current = null;
|
|
791
|
+
let t = _.current;
|
|
792
|
+
t && ([...t.querySelectorAll("[data-filter-id]")].find((t) => t.dataset.filterId === e)?.querySelector("button") ?? t.querySelector("[data-slot=\"filter-menu-trigger\"]"))?.focus();
|
|
793
|
+
}, [C]), /* @__PURE__ */ A(G.Provider, {
|
|
794
|
+
value: k,
|
|
795
|
+
children: /* @__PURE__ */ j("div", {
|
|
796
|
+
ref: _,
|
|
797
|
+
"data-slot": "filter-bar",
|
|
798
|
+
className: e(te(), f),
|
|
799
|
+
...m,
|
|
800
|
+
children: [p ?? /* @__PURE__ */ A(we, {
|
|
801
|
+
hotkey: l,
|
|
802
|
+
showMatch: u
|
|
803
|
+
}), /* @__PURE__ */ A("div", {
|
|
804
|
+
role: "status",
|
|
805
|
+
"aria-live": "polite",
|
|
806
|
+
"aria-atomic": "true",
|
|
807
|
+
"data-slot": "filter-announcer",
|
|
808
|
+
className: "sr-only",
|
|
809
|
+
children: v
|
|
810
|
+
})]
|
|
811
|
+
})
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
//#endregion
|
|
815
|
+
export { Te as FilterBar, be as FilterChip, Se as FilterClear, xe as FilterList, Ce as FilterMatch, _e as FilterMenu, we as FilterToolbar, $ as FilterValueEditor, te as filterBarVariants, re as filterChipVariants, ne as filterToolbarVariants, q as useFilterBar, W as useFilters, K as useOptionalFilterBar };
|