@photon-ai/pho-ui 4.14.0 → 4.15.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/dist/chunks/{basic-page-6dDfY33L.js → basic-page-BHK781ky.js} +85 -82
- package/dist/chunks/basic-page-BHK781ky.js.map +1 -0
- package/dist/chunks/filter-bar-yEcG2pBm.js +287 -0
- package/dist/chunks/filter-bar-yEcG2pBm.js.map +1 -0
- package/dist/components/command.js +222 -3
- package/dist/components/command.js.map +1 -0
- package/dist/components/filter-bar.js +1 -1
- package/dist/index.js +2 -2
- package/dist/sections/basic-page.js +1 -1
- package/dist/src/components/filter-bar/filter-bar.d.ts +10 -6
- package/package.json +1 -1
- package/dist/chunks/basic-page-6dDfY33L.js.map +0 -1
- package/dist/chunks/command-kB5bMvM1.js +0 -225
- package/dist/chunks/command-kB5bMvM1.js.map +0 -1
- package/dist/chunks/filter-bar-DuZXXvdm.js +0 -258
- package/dist/chunks/filter-bar-DuZXXvdm.js.map +0 -1
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { t as s } from "./cn-ChIgwEl3.js";
|
|
3
|
-
import { t as m } from "./resolve-variant-CcD8iG5l.js";
|
|
4
|
-
import { SPRING_SETTLE as P } from "../motion.js";
|
|
5
|
-
import { t as j } from "./IconArrowUpRight-DGgKzQwV.js";
|
|
6
|
-
import { t as V } from "./IconChevronLeft-CSWMKQ4C.js";
|
|
7
|
-
import { t as Z } from "./animated-height-zr7BmFY1.js";
|
|
8
|
-
import { t as u } from "./dialog-12foDiQb.js";
|
|
9
|
-
import { useEffect as $, useId as z, useLayoutEffect as A, useRef as F } from "react";
|
|
10
|
-
import { Fragment as E, jsx as t, jsxs as d } from "react/jsx-runtime";
|
|
11
|
-
import { LayoutGroup as H, motion as g, useReducedMotion as B } from "motion/react";
|
|
12
|
-
import { Command as c, useCommandState as R } from "cmdk";
|
|
13
|
-
var U = P;
|
|
14
|
-
function k({ shouldFilter: r = !1, className: e, children: n, ...o }) {
|
|
15
|
-
const i = z();
|
|
16
|
-
return /* @__PURE__ */ t(c, {
|
|
17
|
-
className: s("bg-pho-primary text-pho-primary flex w-full flex-col overflow-hidden outline-none", e),
|
|
18
|
-
shouldFilter: r,
|
|
19
|
-
...o,
|
|
20
|
-
children: /* @__PURE__ */ t(H, {
|
|
21
|
-
id: i,
|
|
22
|
-
children: n
|
|
23
|
-
})
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function W({ className: r, ...e }) {
|
|
27
|
-
return /* @__PURE__ */ t("div", {
|
|
28
|
-
className: s("border-pho-secondary relative flex items-center border-b", r),
|
|
29
|
-
...e
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
var q = typeof window > "u" ? $ : A;
|
|
33
|
-
function J(r, e) {
|
|
34
|
-
typeof r == "function" ? r(e) : r && (r.current = e);
|
|
35
|
-
}
|
|
36
|
-
function K({ className: r, value: e, ref: n, ...o }) {
|
|
37
|
-
const i = F(null), l = R((a) => a.search);
|
|
38
|
-
return q(() => {
|
|
39
|
-
const a = i.current;
|
|
40
|
-
e == null || a == null || e === l || (Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(a, e), a.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
41
|
-
}, [e, l]), /* @__PURE__ */ t(c.Input, {
|
|
42
|
-
className: s("text-pho-primary placeholder:text-pho-placeholder text-display-xs w-full bg-transparent px-3 py-3 outline-none disabled:cursor-not-allowed disabled:opacity-50", r),
|
|
43
|
-
...o,
|
|
44
|
-
ref: (a) => {
|
|
45
|
-
i.current = a, J(n, a);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function Q({ className: r, children: e, ...n }) {
|
|
50
|
-
return /* @__PURE__ */ t(Z, { children: /* @__PURE__ */ t(g.div, {
|
|
51
|
-
layoutScroll: !0,
|
|
52
|
-
className: "max-h-[min(24rem,60vh)] scroll-py-1 overflow-y-auto overscroll-contain",
|
|
53
|
-
children: /* @__PURE__ */ t(c.List, {
|
|
54
|
-
className: s("relative isolate p-1", r),
|
|
55
|
-
...n,
|
|
56
|
-
children: e
|
|
57
|
-
})
|
|
58
|
-
}) });
|
|
59
|
-
}
|
|
60
|
-
function X({ className: r, ...e }) {
|
|
61
|
-
return /* @__PURE__ */ t(c.Empty, {
|
|
62
|
-
className: s("text-pho-description px-2.5 py-6 text-center text-base", r),
|
|
63
|
-
...e
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function Y({ className: r, ...e }) {
|
|
67
|
-
return /* @__PURE__ */ t(c.Group, {
|
|
68
|
-
className: s("[&_[cmdk-group-heading]]:text-pho-secondary [&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs", r),
|
|
69
|
-
...e
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
var ee = {
|
|
73
|
-
sm: {
|
|
74
|
-
classes: "gap-1.5 py-1 pr-2 text-sm",
|
|
75
|
-
description: "Compact rows for filter lists and dense pickers"
|
|
76
|
-
},
|
|
77
|
-
md: {
|
|
78
|
-
classes: "gap-2 py-2 pr-2.5 text-base",
|
|
79
|
-
description: "Default palette row"
|
|
80
|
-
}
|
|
81
|
-
}, _ = {
|
|
82
|
-
sm: {
|
|
83
|
-
classes: "text-sm",
|
|
84
|
-
description: "Compact row title"
|
|
85
|
-
},
|
|
86
|
-
md: {
|
|
87
|
-
classes: "text-md",
|
|
88
|
-
description: "Default row title"
|
|
89
|
-
}
|
|
90
|
-
}, te = {
|
|
91
|
-
sm: {
|
|
92
|
-
classes: "size-3.5 [&>svg]:size-3.5",
|
|
93
|
-
description: "Compact leading glyph"
|
|
94
|
-
},
|
|
95
|
-
md: {
|
|
96
|
-
classes: "size-4 [&>svg]:size-4",
|
|
97
|
-
description: "Default leading glyph"
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
function y({ className: r, size: e = "md", ...n }) {
|
|
101
|
-
return /* @__PURE__ */ t("span", {
|
|
102
|
-
className: s("text-pho-secondary flex shrink-0 items-center justify-center", m(te, e), r),
|
|
103
|
-
...n
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function L({ className: r, level: e = "item", size: n = "md", ...o }) {
|
|
107
|
-
return /* @__PURE__ */ t("span", {
|
|
108
|
-
className: s("block truncate", m(_, n), e === "item" && "text-pho-primary", r),
|
|
109
|
-
...o
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
function S() {
|
|
113
|
-
return /* @__PURE__ */ t(j, {
|
|
114
|
-
"aria-hidden": !0,
|
|
115
|
-
className: "text-pho-description size-4 shrink-0"
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function re({ className: r, level: e = "item", size: n = "md", icon: o, iconSlot: i, title: l, path: a, scope: h, external: I, children: f, value: p, ...T }) {
|
|
119
|
-
const C = B(), v = typeof p == "string" ? p.trim() : "", G = R((x) => x.value), M = v !== "" && G === v, N = l != null, b = e === "result", D = b && (o != null || i), w = /* @__PURE__ */ t(c.Item, {
|
|
120
|
-
"data-level": e,
|
|
121
|
-
"data-size": n,
|
|
122
|
-
value: p,
|
|
123
|
-
className: s("text-pho-secondary flex cursor-pointer items-center rounded-[calc(var(--radius-base)-4px)] outline-none select-none", m(ee, n), e === "subsubitem" ? "pl-6" : "pl-2", "data-[selected=true]:text-pho-primary data-[selected=true]:bg-pho-ghost-hover", "data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50", r),
|
|
124
|
-
...T,
|
|
125
|
-
children: N && b ? /* @__PURE__ */ d(E, { children: [
|
|
126
|
-
D ? /* @__PURE__ */ t(y, {
|
|
127
|
-
size: n,
|
|
128
|
-
"aria-hidden": o == null ? !0 : void 0,
|
|
129
|
-
children: o ?? null
|
|
130
|
-
}) : null,
|
|
131
|
-
/* @__PURE__ */ d("span", {
|
|
132
|
-
className: s("flex min-w-0 flex-1 items-center gap-1 overflow-hidden", m(_, n)),
|
|
133
|
-
children: [/* @__PURE__ */ t("span", {
|
|
134
|
-
className: "text-pho-primary truncate",
|
|
135
|
-
children: l
|
|
136
|
-
}), (a ?? []).map((x, O) => /* @__PURE__ */ d("span", {
|
|
137
|
-
className: "text-pho-description flex shrink-0 items-center gap-0.5",
|
|
138
|
-
children: [/* @__PURE__ */ t(V, {
|
|
139
|
-
"aria-hidden": !0,
|
|
140
|
-
className: "size-4 shrink-0"
|
|
141
|
-
}), x]
|
|
142
|
-
}, O))]
|
|
143
|
-
}),
|
|
144
|
-
h != null && h !== "" ? /* @__PURE__ */ t("span", {
|
|
145
|
-
className: "text-pho-description shrink-0 text-xs",
|
|
146
|
-
children: h
|
|
147
|
-
}) : null,
|
|
148
|
-
I ? /* @__PURE__ */ t(S, {}) : null,
|
|
149
|
-
f
|
|
150
|
-
] }) : N ? /* @__PURE__ */ d(E, { children: [
|
|
151
|
-
/* @__PURE__ */ t(y, {
|
|
152
|
-
size: n,
|
|
153
|
-
"aria-hidden": o == null ? !0 : void 0,
|
|
154
|
-
children: o ?? null
|
|
155
|
-
}),
|
|
156
|
-
/* @__PURE__ */ t("span", {
|
|
157
|
-
className: "min-w-0 flex-1",
|
|
158
|
-
children: /* @__PURE__ */ t(L, {
|
|
159
|
-
level: e,
|
|
160
|
-
size: n,
|
|
161
|
-
children: l
|
|
162
|
-
})
|
|
163
|
-
}),
|
|
164
|
-
I ? /* @__PURE__ */ t(S, {}) : null,
|
|
165
|
-
f
|
|
166
|
-
] }) : f
|
|
167
|
-
});
|
|
168
|
-
return C ? w : /* @__PURE__ */ t(g.div, {
|
|
169
|
-
layout: "position",
|
|
170
|
-
layoutId: typeof p == "string" ? p : void 0,
|
|
171
|
-
initial: !1,
|
|
172
|
-
transition: M ? { duration: 0 } : U,
|
|
173
|
-
children: w
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
function ne({ className: r, ...e }) {
|
|
177
|
-
return /* @__PURE__ */ t(c.Separator, {
|
|
178
|
-
className: s("-mx-1 my-1 h-px bg-[var(--border-color-pho-secondary)]", r),
|
|
179
|
-
...e
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
function oe({ className: r, ...e }) {
|
|
183
|
-
return /* @__PURE__ */ t(c.Loading, {
|
|
184
|
-
className: s("text-pho-description px-2.5 py-1.5 text-base", r),
|
|
185
|
-
...e
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
function se({ open: r, onOpenChange: e, label: n, className: o, children: i, ...l }) {
|
|
189
|
-
return /* @__PURE__ */ t(u.Root, {
|
|
190
|
-
open: r,
|
|
191
|
-
onOpenChange: e,
|
|
192
|
-
children: /* @__PURE__ */ d(u.Portal, { children: [/* @__PURE__ */ t(u.Backdrop, {}), /* @__PURE__ */ t(u.Popup, {
|
|
193
|
-
"aria-label": n,
|
|
194
|
-
className: s("top-[max(4rem,18vh)] max-w-xl translate-y-0 overflow-hidden p-0", o),
|
|
195
|
-
children: /* @__PURE__ */ t(g.div, {
|
|
196
|
-
layoutRoot: !0,
|
|
197
|
-
children: /* @__PURE__ */ t(k, {
|
|
198
|
-
label: n,
|
|
199
|
-
...l,
|
|
200
|
-
children: i
|
|
201
|
-
})
|
|
202
|
-
})
|
|
203
|
-
})] })
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
var ye = {
|
|
207
|
-
Root: k,
|
|
208
|
-
InputGroup: W,
|
|
209
|
-
Input: K,
|
|
210
|
-
List: Q,
|
|
211
|
-
Empty: X,
|
|
212
|
-
Group: Y,
|
|
213
|
-
Item: re,
|
|
214
|
-
ItemIcon: y,
|
|
215
|
-
ItemTitle: L,
|
|
216
|
-
Separator: ne,
|
|
217
|
-
Loading: oe,
|
|
218
|
-
Dialog: se
|
|
219
|
-
};
|
|
220
|
-
export {
|
|
221
|
-
R as n,
|
|
222
|
-
ye as t
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
//# sourceMappingURL=command-kB5bMvM1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command-kB5bMvM1.js","names":[],"sources":["../../src/components/command/command.tsx"],"sourcesContent":["import {\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n type ComponentProps,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport { IconArrowUpRight, IconChevronLeft } from \"@tabler/icons-react\";\nimport { SPRING_SETTLE } from \"../../motion\";\nimport { Command as CommandPrimitive, useCommandState } from \"cmdk\";\nimport { LayoutGroup, motion, useReducedMotion } from \"motion/react\";\nimport { AnimatedHeight } from \"../../utils/animated-height\";\nimport { cn } from \"../../utils/cn\";\nimport { resolveVariant, type VariantMap } from \"../../utils/resolve-variant\";\nimport { Dialog as PhoDialog } from \"../dialog\";\n\n/**\n * Spring for row moves (FLIP / shared-layout) — same feel as\n * `AnimatedHeight`: quick and critically damped, so rows glide to their new\n * slot without overshooting into neighbours.\n */\nconst ROW_MOVE_SPRING = SPRING_SETTLE;\n\nfunction Root({\n // Filtering is yours by default: filter in render (state above the\n // palette) so the rows' FLIP diff can glide survivors to their slots.\n // cmdk's built-in matcher reorders DOM imperatively — invisible to the\n // layout pass — so it is opt-in: pass `shouldFilter` to hand matching\n // and ranking back to cmdk at the cost of the animation.\n shouldFilter = false,\n className,\n children,\n ...props\n}: ComponentProps<typeof CommandPrimitive>) {\n // Namespace row layoutIds per palette instance — the docs page mounts the\n // inline demo and the dialog demo at once, with identical item values.\n const layoutNamespace = useId();\n return (\n <CommandPrimitive\n className={cn(\n \"bg-pho-primary text-pho-primary flex w-full flex-col overflow-hidden outline-none\",\n className,\n )}\n shouldFilter={shouldFilter}\n {...props}\n >\n <LayoutGroup id={layoutNamespace}>{children}</LayoutGroup>\n </CommandPrimitive>\n );\n}\n\n/**\n * The input row — a bottom hairline separates it from the list. Position\n * leading icons absolutely and pad the input (`pl-9`), mirroring\n * `Autocomplete.InputGroup`.\n */\nfunction InputGroup({ className, ...props }: ComponentProps<\"div\">) {\n return (\n <div\n className={cn(\n \"border-pho-secondary relative flex items-center border-b\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/** SSR-safe layout effect (same pattern cmdk uses internally). */\nconst useIsomorphicLayoutEffect =\n typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\nfunction assignRef<T>(ref: Ref<T> | undefined, value: T | null) {\n if (typeof ref === \"function\") ref(value);\n else if (ref) ref.current = value;\n}\n\nfunction Input({\n className,\n value,\n ref: consumerRef,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Input>) {\n const inputRef = useRef<HTMLInputElement>(null);\n const search = useCommandState((state) => state.search);\n\n // cmdk stays uncontrolled here on purpose. Its controlled path syncs the\n // `value` prop into the search store through a passive effect — one painted\n // frame late — so on that stale frame the old row is still \"selected\" while\n // the list has already reflowed, and the selection pill visibly rides it\n // before snapping to the re-selected first row. Uncontrolled keystrokes\n // update search + first-row selection synchronously (pre-paint), killing\n // that frame in both directions (typing and clearing).\n //\n // The consumer-facing API is still controlled: external `value` changes\n // (programmatic reset, initial query) are replayed through the native input\n // path below so store, display, and selection take the same sync route.\n useIsomorphicLayoutEffect(() => {\n const input = inputRef.current;\n if (value == null || input == null || value === search) return;\n const setNativeValue = Object.getOwnPropertyDescriptor(\n HTMLInputElement.prototype,\n \"value\",\n )?.set;\n setNativeValue?.call(input, value);\n input.dispatchEvent(new Event(\"input\", { bubbles: true }));\n }, [value, search]);\n\n return (\n <CommandPrimitive.Input\n className={cn(\n // Borderless inside the palette surface — the InputGroup hairline\n // carries the edge. display-xs (18px) keeps iOS from zooming in.\n \"text-pho-primary placeholder:text-pho-placeholder text-display-xs w-full bg-transparent px-3 py-3 outline-none disabled:cursor-not-allowed disabled:opacity-50\",\n className,\n )}\n {...props}\n ref={(node) => {\n inputRef.current = node;\n assignRef(consumerRef, node);\n }}\n />\n );\n}\n\nfunction List({\n className,\n children,\n ...props\n}: ComponentProps<typeof CommandPrimitive.List>) {\n return (\n // Same spring as the onboarding / invite Card shell — list height glides\n // when idle ↔ search (or filter) changes instead of jumping.\n <AnimatedHeight>\n {/* The scroller is a motion element with layoutScroll so the rows'\n FLIP projections account for its scroll offset — without it,\n scrolling reads as a layout change and every row glides to\n compensate. scroll-py keeps a breath above and below the row\n being scrolled into view. */}\n <motion.div\n layoutScroll\n className=\"max-h-[min(24rem,60vh)] scroll-py-1 overflow-y-auto overscroll-contain\"\n >\n <CommandPrimitive.List\n className={cn(\"relative isolate p-1\", className)}\n {...props}\n >\n {children}\n </CommandPrimitive.List>\n </motion.div>\n </AnimatedHeight>\n );\n}\n\nfunction Empty({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Empty>) {\n return (\n <CommandPrimitive.Empty\n className={cn(\n \"text-pho-description px-2.5 py-6 text-center text-base\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction Group({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Group>) {\n return (\n <CommandPrimitive.Group\n className={cn(\n // cmdk renders the `heading` prop in a [cmdk-group-heading] wrapper —\n // typography mirrors `Autocomplete.GroupLabel`.\n \"[&_[cmdk-group-heading]]:text-pho-secondary [&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/**\n * Row layout mode:\n * - `item` / `subitem` / `subsubitem` — idle hierarchy (icon column + indent)\n * - `result` — flat search hit (breadcrumb + trailing scope)\n */\nexport type CommandItemLevel = \"item\" | \"subitem\" | \"subsubitem\" | \"result\";\nexport type CommandItemSize = \"sm\" | \"md\";\n\nconst ITEM_SIZES = {\n sm: {\n classes: \"gap-1.5 py-1 pr-2 text-sm\",\n description: \"Compact rows for filter lists and dense pickers\",\n },\n md: {\n classes: \"gap-2 py-2 pr-2.5 text-base\",\n description: \"Default palette row\",\n },\n} as const satisfies VariantMap;\n\nconst ITEM_TITLE_SIZES = {\n sm: { classes: \"text-sm\", description: \"Compact row title\" },\n md: { classes: \"text-md\", description: \"Default row title\" },\n} as const satisfies VariantMap;\n\nconst ITEM_ICON_SIZES = {\n sm: {\n classes: \"size-3.5 [&>svg]:size-3.5\",\n description: \"Compact leading glyph\",\n },\n md: {\n classes: \"size-4 [&>svg]:size-4\",\n description: \"Default leading glyph\",\n },\n} as const satisfies VariantMap;\n\ntype ItemPrimitiveProps = ComponentProps<typeof CommandPrimitive.Item>;\n\nexport interface CommandItemProps extends Omit<\n ItemPrimitiveProps,\n \"children\" | \"title\"\n> {\n /**\n * Row depth / mode in the palette:\n * - `item` — page / top destination (icon + title)\n * - `subitem` — section under an item (label aligns with the item title)\n * - `subsubitem` — row under a section (one step deeper)\n * - `result` — flat search hit (`title` + `path` crumbs + `scope`)\n */\n level?: CommandItemLevel;\n /**\n * Leading glyph. On idle `item` rows (and reserved for sub-levels). On\n * `result` rows, pass the resolved icon (self → parent → grandparent).\n */\n icon?: ReactNode;\n /**\n * When `level=\"result\"`, force the icon column so labels align across the\n * list even if this row's `icon` is empty. Set true when any sibling result\n * has an icon; omit when the whole result set is icon-less.\n */\n iconSlot?: boolean;\n /**\n * Row density. `sm` tightens padding and type for chip popovers\n * (Filter Bar options). Palette destinations stay `md`.\n * @default \"md\"\n */\n size?: CommandItemSize;\n /** Primary label. Prefer this over free-form children for the shared layout. */\n title?: ReactNode;\n /**\n * Ancestors after `title` for `level=\"result\"` — parent → page\n * (e.g. `[\"Agent profile\", \"Settings\"]` → `Name < Agent profile < Settings`).\n */\n path?: ReactNode[];\n /**\n * Trailing scope for `level=\"result\"` — `Project` vs `Personal`, not a nav group.\n */\n scope?: ReactNode;\n /** Shows a trailing external-link glyph (opens outside the app). */\n external?: boolean;\n /**\n * Free-form content. When `title` is set, rendered after the label stack.\n * When `title` is omitted, becomes the row body (legacy / simple items).\n */\n children?: ReactNode;\n}\n\n/** Leading icon column — `size-4` at `md`, tighter at `sm`. */\nfunction ItemIcon({\n className,\n size = \"md\",\n ...props\n}: ComponentProps<\"span\"> & { size?: CommandItemSize }) {\n return (\n <span\n className={cn(\n \"text-pho-secondary flex shrink-0 items-center justify-center\",\n resolveVariant(ITEM_ICON_SIZES, size),\n className,\n )}\n {...props}\n />\n );\n}\n\n/** Primary label — medium + primary ink on `item` rows. */\nfunction ItemTitle({\n className,\n level = \"item\",\n size = \"md\",\n ...props\n}: ComponentProps<\"span\"> & {\n level?: CommandItemLevel;\n size?: CommandItemSize;\n}) {\n return (\n <span\n className={cn(\n \"block truncate\",\n resolveVariant(ITEM_TITLE_SIZES, size),\n level === \"item\" && \"text-pho-primary\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/**\n * One selectable row. Idle palettes use `level` + `icon` / `title`\n * (item → subitem → subsubitem). Searching uses `level=\"result\"` with `path`\n * crumbs and a trailing `scope` (Project / Personal). No description line —\n * match via `keywords` / aliases instead.\n */\nfunction ExternalGlyph() {\n return (\n <IconArrowUpRight\n aria-hidden\n className=\"text-pho-description size-4 shrink-0\"\n />\n );\n}\n\nfunction Item({\n className,\n level = \"item\",\n size = \"md\",\n icon,\n iconSlot,\n title,\n path,\n scope,\n external,\n children,\n value,\n ...props\n}: CommandItemProps) {\n const reduceMotion = useReducedMotion();\n // cmdk registers `value.trim()` and exposes the selected one as\n // `state.value` — mirrors cmdk's own `data-selected` computation.\n const trimmedValue = typeof value === \"string\" ? value.trim() : \"\";\n const selectedValue = useCommandState((state) => state.value);\n const isSelected = trimmedValue !== \"\" && selectedValue === trimmedValue;\n const structured = title != null;\n const isResult = level === \"result\";\n // Reserve the icon column when the row has an icon, or when the list asks\n // for alignment (`iconSlot`) even if this row's glyph is empty.\n const showResultIcon = isResult && (icon != null || iconSlot);\n\n const row = (\n <CommandPrimitive.Item\n data-level={level}\n data-size={size}\n value={value}\n className={cn(\n \"text-pho-secondary flex cursor-pointer items-center rounded-[calc(var(--radius-base)-4px)] outline-none select-none\",\n resolveVariant(ITEM_SIZES, size),\n // subsubitem steps in; item/subitem share the base gutter.\n level === \"subsubitem\" ? \"pl-6\" : \"pl-2\",\n // Secondary at rest; selection lifts to primary ink (Menu idiom).\n // The wash lands with it instantly — stepping through rows is a\n // snap, not a flight.\n \"data-[selected=true]:text-pho-primary data-[selected=true]:bg-pho-ghost-hover\",\n \"data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50\",\n className,\n )}\n {...props}\n >\n {structured && isResult ? (\n <>\n {showResultIcon ? (\n <ItemIcon size={size} aria-hidden={icon == null ? true : undefined}>\n {icon ?? null}\n </ItemIcon>\n ) : null}\n {/* Same title size as idle ItemTitle so row height matches. */}\n <span\n className={cn(\n \"flex min-w-0 flex-1 items-center gap-1 overflow-hidden\",\n resolveVariant(ITEM_TITLE_SIZES, size),\n )}\n >\n <span className=\"text-pho-primary truncate\">{title}</span>\n {(path ?? []).map((segment, index) => (\n <span\n key={index}\n className=\"text-pho-description flex shrink-0 items-center gap-0.5\"\n >\n <IconChevronLeft aria-hidden className=\"size-4 shrink-0\" />\n {segment}\n </span>\n ))}\n </span>\n {scope != null && scope !== \"\" ? (\n <span className=\"text-pho-description shrink-0 text-xs\">\n {scope}\n </span>\n ) : null}\n {external ? <ExternalGlyph /> : null}\n {children}\n </>\n ) : structured ? (\n <>\n {/* Icon column always reserved so subitem labels share the item title edge. */}\n <ItemIcon size={size} aria-hidden={icon == null ? true : undefined}>\n {icon ?? null}\n </ItemIcon>\n <span className=\"min-w-0 flex-1\">\n <ItemTitle level={level} size={size}>\n {title}\n </ItemTitle>\n </span>\n {external ? <ExternalGlyph /> : null}\n {children}\n </>\n ) : (\n children\n )}\n </CommandPrimitive.Item>\n );\n\n if (reduceMotion) return row;\n\n return (\n // FLIP wrapper: rows that stay mounted glide when neighbours enter or\n // leave, and a row remounting elsewhere with the same `value` (idle group\n // ↔ flat search result) inherits the old bounds via its layoutId and\n // slides to the new slot — the iOS list-diff feel. Rows without a match\n // simply appear / disappear so the whole list never swarms.\n //\n // The selected row is the exception: it skips the travel and appears at\n // its final slot immediately, so the selection wash is never sitting on\n // empty space waiting for its row to fly in.\n <motion.div\n layout=\"position\"\n layoutId={typeof value === \"string\" ? value : undefined}\n initial={false}\n transition={isSelected ? { duration: 0 } : ROW_MOVE_SPRING}\n >\n {row}\n </motion.div>\n );\n}\n\nfunction Separator({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Separator>) {\n return (\n <CommandPrimitive.Separator\n className={cn(\n \"-mx-1 my-1 h-px bg-[var(--border-color-pho-secondary)]\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction Loading({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Loading>) {\n return (\n <CommandPrimitive.Loading\n className={cn(\"text-pho-description px-2.5 py-1.5 text-base\", className)}\n {...props}\n />\n );\n}\n\ntype DialogRootProps = ComponentProps<typeof PhoDialog.Root>;\n\ninterface CommandDialogProps extends ComponentProps<typeof CommandPrimitive> {\n /** Controlled dialog state — pass straight through to `Dialog.Root`. */\n open?: DialogRootProps[\"open\"];\n onOpenChange?: DialogRootProps[\"onOpenChange\"];\n /** Accessible name for the palette (dialog and command menu). */\n label?: string;\n /** Extra classes for the dialog panel (not the command root). */\n className?: string;\n}\n\n/**\n * A command palette in a modal — Pho's `Dialog` overlay (Base UI) around a\n * `Command.Root`, raised above center. We deliberately skip cmdk's own\n * `Command.Dialog` (Radix) so overlays stay on one primitive stack.\n *\n * List height springs via `AnimatedHeight` (same feel as the Card shell on\n * onboarding / invite) — the input row stays put while results resize.\n */\nfunction Dialog({\n open,\n onOpenChange,\n label,\n className,\n children,\n ...props\n}: CommandDialogProps) {\n return (\n <PhoDialog.Root open={open} onOpenChange={onOpenChange}>\n <PhoDialog.Portal>\n <PhoDialog.Backdrop />\n <PhoDialog.Popup\n aria-label={label}\n // Palette sits above center so the list grows downward from a\n // stable top edge instead of jumping around it.\n className={cn(\n \"top-[max(4rem,18vh)] max-w-xl translate-y-0 overflow-hidden p-0\",\n className,\n )}\n >\n {/* The popup is position: fixed; layout animations inside a fixed\n element need a layoutRoot to project against, or their\n measurements drift with the page scroll. */}\n <motion.div layoutRoot>\n <Root label={label} {...props}>\n {children}\n </Root>\n </motion.div>\n </PhoDialog.Popup>\n </PhoDialog.Portal>\n </PhoDialog.Root>\n );\n}\n\n/**\n * Command menu built on `cmdk` — a filterable list of actions driven from a\n * single input, keyboard-first. Compose inline (`Command.Root`) or as a\n * ⌘K-style modal palette (`Command.Dialog`, which owns the overlay).\n * Filtering is yours by default — filter in render so the rows' diff can\n * glide; pass `shouldFilter` to hand matching and ranking to cmdk (its\n * imperative reorder skips the animation).\n *\n * Rows share one layout via `Command.Item` `level` — idle\n * `item` → `subitem` → `subsubitem`, or flat `result` while searching.\n */\nexport const Command = {\n Root,\n InputGroup,\n Input,\n List,\n Empty,\n Group,\n Item,\n ItemIcon,\n ItemTitle,\n Separator,\n Loading,\n Dialog,\n};\n\n/** Re-export of cmdk's state selector hook (search, value, filtered counts). */\nexport { useCommandState };\n"],"mappings":";;;;;;;;;;;;AAuBA,IAAM,IAAkB;AAExB,SAAS,EAAK,EAMZ,cAAA,IAAe,IACf,WAAA,GACA,UAAA,GACA,GAAG,EAAA,GACuC;AAG1C,QAAM,IAAkB,EAAM;AAC9B,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,WAAW,EACT,qFACA,CACF;AAAA,IACc,cAAA;AAAA,IACd,GAAI;AAAA,IAEJ,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAa,IAAI;AAAA,MAAkB,UAAA;AAAA,IAAsB,CAAA;AAAA,EACzC,CAAA;AAEtB;AAOA,SAAS,EAAW,EAAE,WAAA,GAAW,GAAG,EAAA,GAAgC;AAClE,SACE,gBAAA,EAAC,OAAD;AAAA,IACE,WAAW,EACT,4DACA,CACF;AAAA,IACA,GAAI;AAAA,EACL,CAAA;AAEL;AAGA,IAAM,IACJ,OAAO,SAAW,MAAc,IAAY;AAE9C,SAAS,EAAa,GAAyB,GAAiB;AAC9D,EAAI,OAAO,KAAQ,aAAY,EAAI,CAAK,IAC/B,MAAK,EAAI,UAAU;AAC9B;AAEA,SAAS,EAAM,EACb,WAAA,GACA,OAAA,GACA,KAAK,G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CAAA,GACrB,gBAAA,EAAC,EAAU,OAAX;AAAA,MACE,cAAY;AAAA,MAGZ,WAAW,EACT,mEACA,CACF;AAAA,MAKA,UAAA,gBAAA,EAAC,EAAO,KAAR;AAAA,QAAY,YAAA;AAAA,QACV,UAAA,gBAAA,EAAC,GAAD;AAAA,UAAa,OAAA;AAAA,UAAO,GAAI;AAAA,UACrB,UAAA;AAAA,QACG,CAAA;AAAA,MACI,CAAA;AAAA,IACG,CAAA,CACD,EAAA,CAAA;AAAA,EACJ,CAAA;AAEpB;AAaA,IAAa,KAAU;AAAA,EACrB,MAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AACF"}
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { t as y } from "./cn-ChIgwEl3.js";
|
|
3
|
-
import { a as T } from "./button-C9VqBBIr.js";
|
|
4
|
-
import { t as A } from "./createReactComponent-BqCmnqfX.js";
|
|
5
|
-
import { t as S } from "./IconCheck-D2WuculQ.js";
|
|
6
|
-
import { t as P } from "./IconSearch-BKAHkLyX.js";
|
|
7
|
-
import { t as $ } from "./IconX-pZ9vrtSr.js";
|
|
8
|
-
import { t as g } from "./popover-BhBJO346.js";
|
|
9
|
-
import { t as D } from "./box-search-C9EVZgcb.js";
|
|
10
|
-
import { t as d } from "./command-kB5bMvM1.js";
|
|
11
|
-
import { useRef as E, useState as I } from "react";
|
|
12
|
-
import { jsx as a, jsxs as p } from "react/jsx-runtime";
|
|
13
|
-
var R = [["path", {
|
|
14
|
-
d: "M12 5l0 14",
|
|
15
|
-
key: "svg-0"
|
|
16
|
-
}], ["path", {
|
|
17
|
-
d: "M5 12l14 0",
|
|
18
|
-
key: "svg-1"
|
|
19
|
-
}]], F = A("outline", "plus", "Plus", R), O = [
|
|
20
|
-
{
|
|
21
|
-
label: "Last hour",
|
|
22
|
-
hours: 1
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
label: "Last 24 hours",
|
|
26
|
-
hours: 24
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: "Last 7 days",
|
|
30
|
-
hours: 168
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
label: "Last 30 days",
|
|
34
|
-
hours: 720
|
|
35
|
-
}
|
|
36
|
-
], _ = 8;
|
|
37
|
-
function w(e) {
|
|
38
|
-
return e == null ? !1 : typeof e == "string" ? e !== "" : Array.isArray(e) ? e.length > 0 : e.from != null || e.to != null;
|
|
39
|
-
}
|
|
40
|
-
var L = /^\d{4}-\d{2}-\d{2}$/;
|
|
41
|
-
function x(e) {
|
|
42
|
-
const r = L.test(e), n = new Date(r ? `${e}T00:00:00Z` : e);
|
|
43
|
-
return Number.isNaN(n.getTime()) ? e : new Intl.DateTimeFormat("en-US", {
|
|
44
|
-
month: "short",
|
|
45
|
-
day: "numeric",
|
|
46
|
-
...r ? { timeZone: "UTC" } : {}
|
|
47
|
-
}).format(n);
|
|
48
|
-
}
|
|
49
|
-
function z(e, r) {
|
|
50
|
-
if (!w(r) || r == null) return "";
|
|
51
|
-
if (e.type === "date-range") {
|
|
52
|
-
const l = r;
|
|
53
|
-
return l.preset ? l.preset : l.from && l.to ? `${x(l.from)} to ${x(l.to)}` : l.from ? `From ${x(l.from)}` : l.to ? `Until ${x(l.to)}` : "";
|
|
54
|
-
}
|
|
55
|
-
const n = (l) => e.options.find((i) => i.value === l)?.label ?? l;
|
|
56
|
-
return Array.isArray(r) ? r.map(n).join(", ") : typeof r == "string" ? n(r) : "";
|
|
57
|
-
}
|
|
58
|
-
var k = "outline-pho-brand flex h-8 min-w-0 cursor-pointer items-center gap-1.5 rounded-full text-base transition-[color,background-color] duration-100 ease-linear focus-visible:outline-2 focus-visible:-outline-offset-2 [&>svg]:size-4 [&>svg]:shrink-0";
|
|
59
|
-
function B({ definition: e, value: r, onChange: n }) {
|
|
60
|
-
const [l, i] = I(!1), u = E(null), c = w(r), t = z(e, r);
|
|
61
|
-
return /* @__PURE__ */ p(g.Root, {
|
|
62
|
-
open: l,
|
|
63
|
-
onOpenChange: i,
|
|
64
|
-
children: [/* @__PURE__ */ p("span", {
|
|
65
|
-
"data-filter-chip": e.key,
|
|
66
|
-
"data-set": c || void 0,
|
|
67
|
-
className: y("ring-pho-primary inline-flex max-w-full shrink-0 items-stretch rounded-full ring-1 ring-inset", c ? "bg-pho-secondary" : "bg-transparent"),
|
|
68
|
-
children: [/* @__PURE__ */ p(g.Trigger, {
|
|
69
|
-
"aria-label": c ? void 0 : `${e.label} filter`,
|
|
70
|
-
className: y(k, "hover:bg-pho-ghost-hover", c ? "pr-1.5 pl-3" : "pr-3 pl-2.5", c ? "rounded-r-none" : ""),
|
|
71
|
-
children: [c ? null : /* @__PURE__ */ a(F, { "aria-hidden": !0 }), c ? /* @__PURE__ */ p("span", {
|
|
72
|
-
className: "flex min-w-0 items-baseline gap-1",
|
|
73
|
-
children: [/* @__PURE__ */ p("span", {
|
|
74
|
-
className: "text-pho-description shrink-0",
|
|
75
|
-
children: [e.label, ":"]
|
|
76
|
-
}), /* @__PURE__ */ a("span", {
|
|
77
|
-
className: "text-pho-primary max-w-56 truncate font-medium",
|
|
78
|
-
children: t
|
|
79
|
-
})]
|
|
80
|
-
}) : /* @__PURE__ */ a("span", {
|
|
81
|
-
className: "text-pho-secondary",
|
|
82
|
-
children: e.label
|
|
83
|
-
})]
|
|
84
|
-
}), c ? /* @__PURE__ */ a("button", {
|
|
85
|
-
type: "button",
|
|
86
|
-
"aria-label": `Clear ${e.label.toLowerCase()} filter`,
|
|
87
|
-
onClick: () => n(void 0),
|
|
88
|
-
className: y(k, "text-pho-secondary hover:bg-pho-ghost-hover hover:text-pho-secondary-hover rounded-l-none pr-2.5 pl-1 [&>svg]:size-3.5"),
|
|
89
|
-
children: /* @__PURE__ */ a($, { "aria-hidden": !0 })
|
|
90
|
-
}) : null]
|
|
91
|
-
}), /* @__PURE__ */ a(g.Portal, { children: /* @__PURE__ */ a(g.Positioner, {
|
|
92
|
-
align: "start",
|
|
93
|
-
sideOffset: 6,
|
|
94
|
-
children: /* @__PURE__ */ a(g.Popup, {
|
|
95
|
-
"aria-label": `${e.label} filter`,
|
|
96
|
-
initialFocus: u,
|
|
97
|
-
className: y("w-64 p-0", e.type === "date-range" && "w-72"),
|
|
98
|
-
children: e.type === "date-range" ? /* @__PURE__ */ a(j, {
|
|
99
|
-
definition: e,
|
|
100
|
-
value: r,
|
|
101
|
-
focusRef: u,
|
|
102
|
-
onChange: (m) => {
|
|
103
|
-
n(m), m?.preset && i(!1);
|
|
104
|
-
}
|
|
105
|
-
}) : /* @__PURE__ */ a(U, {
|
|
106
|
-
definition: e,
|
|
107
|
-
value: r,
|
|
108
|
-
focusRef: u,
|
|
109
|
-
onChange: (m) => {
|
|
110
|
-
n(m), e.multiple || i(!1);
|
|
111
|
-
}
|
|
112
|
-
})
|
|
113
|
-
})
|
|
114
|
-
}) })]
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function U({ definition: e, value: r, focusRef: n, onChange: l }) {
|
|
118
|
-
const [i, u] = I(""), c = e.searchable ?? e.options.length > _, t = new Set(r == null ? [] : Array.isArray(r) ? r : [r]), m = i.trim().toLowerCase(), f = m ? e.options.filter((s) => s.label.toLowerCase().includes(m) || s.value.toLowerCase().includes(m)) : e.options, v = (s) => {
|
|
119
|
-
if (e.multiple) {
|
|
120
|
-
const b = new Set(t);
|
|
121
|
-
b.has(s.value) ? b.delete(s.value) : b.add(s.value);
|
|
122
|
-
const o = e.options.map((h) => h.value).filter((h) => b.has(h));
|
|
123
|
-
l(o.length > 0 ? o : void 0);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
l(t.has(s.value) ? void 0 : s.value);
|
|
127
|
-
};
|
|
128
|
-
return /* @__PURE__ */ p(d.Root, {
|
|
129
|
-
label: `${e.label} options`,
|
|
130
|
-
ref: (s) => {
|
|
131
|
-
c || (n.current = s);
|
|
132
|
-
},
|
|
133
|
-
className: "rounded-base",
|
|
134
|
-
children: [c ? /* @__PURE__ */ p(d.InputGroup, { children: [/* @__PURE__ */ a(P, {
|
|
135
|
-
"aria-hidden": !0,
|
|
136
|
-
className: "text-pho-description pointer-events-none absolute left-3 size-4"
|
|
137
|
-
}), /* @__PURE__ */ a(d.Input, {
|
|
138
|
-
ref: (s) => {
|
|
139
|
-
n.current = s;
|
|
140
|
-
},
|
|
141
|
-
value: i,
|
|
142
|
-
onValueChange: u,
|
|
143
|
-
placeholder: e.searchPlaceholder ?? "Search",
|
|
144
|
-
"aria-label": `Search ${e.label.toLowerCase()} options`,
|
|
145
|
-
className: "py-2 pr-3 pl-9 text-base"
|
|
146
|
-
})] }) : null, /* @__PURE__ */ p(d.List, { children: [/* @__PURE__ */ a(d.Empty, { children: "Nothing matches." }), f.map((s) => /* @__PURE__ */ a(d.Item, {
|
|
147
|
-
value: s.value,
|
|
148
|
-
size: "sm",
|
|
149
|
-
title: s.title ?? s.label,
|
|
150
|
-
"aria-checked": t.has(s.value),
|
|
151
|
-
icon: t.has(s.value) ? /* @__PURE__ */ a(S, { "aria-hidden": !0 }) : null,
|
|
152
|
-
onSelect: () => v(s)
|
|
153
|
-
}, s.value))] })]
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
var C = "bg-pho-primary ring-pho-primary text-pho-primary focus-visible:ring-pho-brand w-full min-w-0 rounded-sm px-2 py-1 text-base ring-1 transition-shadow duration-100 ease-linear outline-none ring-inset focus-visible:ring-2";
|
|
157
|
-
function j({ definition: e, value: r, focusRef: n, onChange: l }) {
|
|
158
|
-
const i = e.presets ?? O, u = (t) => t == null ? "" : L.test(t) ? t : t.slice(0, 10), c = (t, m) => {
|
|
159
|
-
const f = {
|
|
160
|
-
from: u(r?.from) || null,
|
|
161
|
-
to: u(r?.to) || null,
|
|
162
|
-
[t]: m || null
|
|
163
|
-
};
|
|
164
|
-
l(f.from == null && f.to == null ? void 0 : f);
|
|
165
|
-
};
|
|
166
|
-
return /* @__PURE__ */ p("div", {
|
|
167
|
-
className: "flex flex-col",
|
|
168
|
-
children: [/* @__PURE__ */ a(d.Root, {
|
|
169
|
-
label: `${e.label} presets`,
|
|
170
|
-
ref: (t) => {
|
|
171
|
-
n.current = t;
|
|
172
|
-
},
|
|
173
|
-
className: "rounded-t-[inherit]",
|
|
174
|
-
children: /* @__PURE__ */ a(d.List, { children: i.map((t) => /* @__PURE__ */ a(d.Item, {
|
|
175
|
-
value: t.label,
|
|
176
|
-
size: "sm",
|
|
177
|
-
title: t.label,
|
|
178
|
-
"aria-checked": r?.preset === t.label,
|
|
179
|
-
icon: r?.preset === t.label ? /* @__PURE__ */ a(S, { "aria-hidden": !0 }) : null,
|
|
180
|
-
onSelect: () => l({
|
|
181
|
-
from: (/* @__PURE__ */ new Date(Date.now() - t.hours * 60 * 60 * 1e3)).toISOString(),
|
|
182
|
-
to: null,
|
|
183
|
-
preset: t.label
|
|
184
|
-
})
|
|
185
|
-
}, t.label)) })
|
|
186
|
-
}), /* @__PURE__ */ p("div", {
|
|
187
|
-
className: "border-pho-secondary grid grid-cols-2 gap-2 border-t p-2",
|
|
188
|
-
children: [/* @__PURE__ */ p("label", {
|
|
189
|
-
className: "text-pho-description flex min-w-0 flex-col gap-1 text-xs",
|
|
190
|
-
children: ["From", /* @__PURE__ */ a("input", {
|
|
191
|
-
type: "date",
|
|
192
|
-
value: u(r?.from),
|
|
193
|
-
max: u(r?.to) || void 0,
|
|
194
|
-
onChange: (t) => c("from", t.target.value),
|
|
195
|
-
className: C
|
|
196
|
-
})]
|
|
197
|
-
}), /* @__PURE__ */ p("label", {
|
|
198
|
-
className: "text-pho-description flex min-w-0 flex-col gap-1 text-xs",
|
|
199
|
-
children: ["To", /* @__PURE__ */ a("input", {
|
|
200
|
-
type: "date",
|
|
201
|
-
value: u(r?.to),
|
|
202
|
-
min: u(r?.from) || void 0,
|
|
203
|
-
onChange: (t) => c("to", t.target.value),
|
|
204
|
-
className: C
|
|
205
|
-
})]
|
|
206
|
-
})]
|
|
207
|
-
})]
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
function G({ definitions: e, filters: r, onFiltersChange: n, search: l, onSearchChange: i, searchPlaceholder: u = "Search", searchLabel: c, sticky: t, className: m, children: f, ...v }) {
|
|
211
|
-
const s = e.filter((o) => w(r[o.key])).length, b = (o, h) => {
|
|
212
|
-
const N = { ...r };
|
|
213
|
-
h === void 0 ? delete N[o] : N[o] = h, n(N);
|
|
214
|
-
};
|
|
215
|
-
return /* @__PURE__ */ p("div", {
|
|
216
|
-
"data-filter-bar": "",
|
|
217
|
-
className: y("flex min-w-0 flex-wrap items-center gap-2", t && "sticky top-0 z-10 bg-[var(--pho-surface,var(--background-color-pho-page))] py-3", m),
|
|
218
|
-
...v,
|
|
219
|
-
children: [
|
|
220
|
-
i != null ? /* @__PURE__ */ a(D, {
|
|
221
|
-
value: l ?? "",
|
|
222
|
-
onChange: (o) => i(o.target.value),
|
|
223
|
-
onClear: () => i(""),
|
|
224
|
-
onKeyDown: (o) => {
|
|
225
|
-
o.key === "Escape" && (o.preventDefault(), i(""));
|
|
226
|
-
},
|
|
227
|
-
placeholder: u,
|
|
228
|
-
"aria-label": c ?? u,
|
|
229
|
-
className: "w-64 max-w-full"
|
|
230
|
-
}) : null,
|
|
231
|
-
e.map((o) => /* @__PURE__ */ a(B, {
|
|
232
|
-
definition: o,
|
|
233
|
-
value: r[o.key],
|
|
234
|
-
onChange: (h) => b(o.key, h)
|
|
235
|
-
}, o.key)),
|
|
236
|
-
s > 1 ? /* @__PURE__ */ a(T, {
|
|
237
|
-
variant: "ghost",
|
|
238
|
-
size: "sm",
|
|
239
|
-
onClick: () => {
|
|
240
|
-
const o = { ...r };
|
|
241
|
-
for (const h of e) delete o[h.key];
|
|
242
|
-
n(o);
|
|
243
|
-
},
|
|
244
|
-
children: "Clear filters"
|
|
245
|
-
}) : null,
|
|
246
|
-
f
|
|
247
|
-
]
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
G.displayName = "FilterBar";
|
|
251
|
-
export {
|
|
252
|
-
w as i,
|
|
253
|
-
G as n,
|
|
254
|
-
z as r,
|
|
255
|
-
O as t
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
//# sourceMappingURL=filter-bar-DuZXXvdm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter-bar-DuZXXvdm.js","names":[],"sources":["../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.mjs","../../src/components/filter-bar/filter-bar.tsx"],"sourcesContent":["/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M12 5l0 14\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M5 12l14 0\", \"key\": \"svg-1\" }]];\nconst IconPlus = createReactComponent(\"outline\", \"plus\", \"Plus\", __iconNode);\n\nexport { __iconNode, IconPlus as default };\n//# sourceMappingURL=IconPlus.mjs.map\n","import {\n useRef,\n useState,\n type ComponentProps,\n type ReactNode,\n type Ref,\n type RefObject,\n} from \"react\";\nimport { IconCheck, IconPlus, IconSearch, IconX } from \"@tabler/icons-react\";\nimport { Button } from \"../button\";\nimport { Command } from \"../command\";\nimport { BoxSearch } from \"../input-group/box-search\";\nimport { Popover } from \"../popover\";\nimport { cn } from \"../../utils/cn\";\n\n/**\n * Filter Bar — the row that pins above a log list: a search field for an\n * id, then one chip per filter. A chip with nothing chosen reads\n * `+ Status`; with a value it reads `Status: Failed` and carries its own\n * clear. Each chip opens a small popover: a keyboard-first list of\n * options (with a search field past eight of them), or presets and a\n * from / to pair for a date range.\n *\n * Design notes:\n * - Fully controlled. The page owns `filters` and `search` and hands\n * them back changed; the bar keeps no state but which popover is open.\n * That keeps the query in one place (the URL, a store) and lets the\n * list refetch from it.\n * - Chips are real buttons (the trigger, and the clear beside it), so\n * the bar is one tab stop per control and Escape closes a popover\n * back onto its chip.\n * - No scroll container of its own: chips wrap. `sticky` pins it to the\n * top of the nearest scroll pane on the surface it sits on.\n */\n\nexport interface FilterOption {\n value: string;\n label: string;\n /**\n * Rich option row (a badge, mono path). Search and the set chip still\n * use `label` and `value` strings.\n */\n title?: ReactNode;\n}\n\ninterface FilterDefinitionBase {\n /** The key in `filters` this chip reads and writes. */\n key: string;\n /** The chip's word — \"Status\", \"Event type\". Sentence case. */\n label: string;\n}\n\nexport interface SelectFilterDefinition extends FilterDefinitionBase {\n type?: \"select\";\n options: readonly FilterOption[];\n /** Several values at once (`string[]`); one at a time by default. */\n multiple?: boolean;\n /**\n * A search field above the options. On by default past eight options,\n * off below; say so to override.\n */\n searchable?: boolean;\n /** The search field's placeholder. @default \"Search\" */\n searchPlaceholder?: string;\n}\n\n/** A relative preset for a date-range filter — \"Last 7 days\" is 168 hours. */\nexport interface DateRangePreset {\n label: string;\n hours: number;\n}\n\nexport interface DateRangeFilterDefinition extends FilterDefinitionBase {\n type: \"date-range\";\n /** The relative presets listed above the from / to pair. */\n presets?: readonly DateRangePreset[];\n}\n\nexport type FilterDefinition =\n SelectFilterDefinition | DateRangeFilterDefinition;\n\n/**\n * A date-range value. A preset stores an absolute ISO timestamp in `from`\n * (computed when chosen) and its label in `preset`; the from / to pair\n * stores plain `YYYY-MM-DD` dates. Either side may be open (`null`).\n */\nexport interface DateRangeValue {\n from: string | null;\n to: string | null;\n preset?: string;\n}\n\nexport type FilterValue = string | string[] | DateRangeValue;\n\n/** The page's filter state — one entry per definition key that is set. */\nexport type FilterValues = Record<string, FilterValue | undefined>;\n\n/** The relative presets a date-range chip lists when given none. */\nexport const FILTER_DATE_PRESETS: readonly DateRangePreset[] = [\n { label: \"Last hour\", hours: 1 },\n { label: \"Last 24 hours\", hours: 24 },\n { label: \"Last 7 days\", hours: 24 * 7 },\n { label: \"Last 30 days\", hours: 24 * 30 },\n];\n\n/** Past this many options a select chip shows a search field. */\nconst SEARCHABLE_PAST = 8;\n\n/** Whether a filter value counts as set — an empty string or list does not. */\nexport function isFilterSet(value: FilterValue | undefined): boolean {\n if (value == null) return false;\n if (typeof value === \"string\") return value !== \"\";\n if (Array.isArray(value)) return value.length > 0;\n return value.from != null || value.to != null;\n}\n\nconst DATE_ONLY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nfunction formatDay(value: string): string {\n // A plain date is a calendar day: format it in UTC so the day survives\n // every viewer timezone. A timestamp is a moment: format it locally.\n const dateOnly = DATE_ONLY.test(value);\n const date = new Date(dateOnly ? `${value}T00:00:00Z` : value);\n if (Number.isNaN(date.getTime())) return value;\n return new Intl.DateTimeFormat(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n ...(dateOnly ? { timeZone: \"UTC\" } : {}),\n }).format(date);\n}\n\n/** The words a set chip shows after its label. */\nexport function formatFilterValue(\n definition: FilterDefinition,\n value: FilterValue | undefined,\n): string {\n if (!isFilterSet(value) || value == null) return \"\";\n if (definition.type === \"date-range\") {\n const range = value as DateRangeValue;\n if (range.preset) return range.preset;\n if (range.from && range.to) {\n return `${formatDay(range.from)} to ${formatDay(range.to)}`;\n }\n if (range.from) return `From ${formatDay(range.from)}`;\n if (range.to) return `Until ${formatDay(range.to)}`;\n return \"\";\n }\n const labelOf = (item: string) =>\n definition.options.find((option) => option.value === item)?.label ?? item;\n if (Array.isArray(value)) return value.map(labelOf).join(\", \");\n return typeof value === \"string\" ? labelOf(value) : \"\";\n}\n\n/* --------------------------------- chips -------------------------------- */\n\nconst CHIP_TRIGGER =\n \"outline-pho-brand flex h-8 min-w-0 cursor-pointer items-center gap-1.5 rounded-full text-base transition-[color,background-color] duration-100 ease-linear focus-visible:outline-2 focus-visible:-outline-offset-2 [&>svg]:size-4 [&>svg]:shrink-0\";\n\nfunction FilterChip({\n definition,\n value,\n onChange,\n}: {\n definition: FilterDefinition;\n value: FilterValue | undefined;\n onChange: (next: FilterValue | undefined) => void;\n}) {\n const [open, setOpen] = useState(false);\n const focusRef = useRef<HTMLElement | null>(null);\n const set = isFilterSet(value);\n const display = formatFilterValue(definition, value);\n return (\n <Popover.Root open={open} onOpenChange={setOpen}>\n <span\n data-filter-chip={definition.key}\n data-set={set || undefined}\n className={cn(\n \"ring-pho-primary inline-flex max-w-full shrink-0 items-stretch rounded-full ring-1 ring-inset\",\n set ? \"bg-pho-secondary\" : \"bg-transparent\",\n )}\n >\n <Popover.Trigger\n aria-label={set ? undefined : `${definition.label} filter`}\n className={cn(\n CHIP_TRIGGER,\n \"hover:bg-pho-ghost-hover\",\n set ? \"pr-1.5 pl-3\" : \"pr-3 pl-2.5\",\n set ? \"rounded-r-none\" : \"\",\n )}\n >\n {set ? null : <IconPlus aria-hidden />}\n {set ? (\n <span className=\"flex min-w-0 items-baseline gap-1\">\n <span className=\"text-pho-description shrink-0\">\n {definition.label}:\n </span>\n <span className=\"text-pho-primary max-w-56 truncate font-medium\">\n {display}\n </span>\n </span>\n ) : (\n <span className=\"text-pho-secondary\">{definition.label}</span>\n )}\n </Popover.Trigger>\n {set ? (\n <button\n type=\"button\"\n aria-label={`Clear ${definition.label.toLowerCase()} filter`}\n onClick={() => onChange(undefined)}\n className={cn(\n CHIP_TRIGGER,\n \"text-pho-secondary hover:bg-pho-ghost-hover hover:text-pho-secondary-hover rounded-l-none pr-2.5 pl-1 [&>svg]:size-3.5\",\n )}\n >\n <IconX aria-hidden />\n </button>\n ) : null}\n </span>\n <Popover.Portal>\n <Popover.Positioner align=\"start\" sideOffset={6}>\n <Popover.Popup\n aria-label={`${definition.label} filter`}\n initialFocus={focusRef}\n className={cn(\n \"w-64 p-0\",\n definition.type === \"date-range\" && \"w-72\",\n )}\n >\n {definition.type === \"date-range\" ? (\n <DateRangePanel\n definition={definition}\n value={value as DateRangeValue | undefined}\n focusRef={focusRef}\n onChange={(next) => {\n onChange(next);\n if (next?.preset) setOpen(false);\n }}\n />\n ) : (\n <OptionsPanel\n definition={definition}\n value={value as string | string[] | undefined}\n focusRef={focusRef}\n onChange={(next) => {\n onChange(next);\n if (!definition.multiple) setOpen(false);\n }}\n />\n )}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n\nfunction OptionsPanel({\n definition,\n value,\n focusRef,\n onChange,\n}: {\n definition: SelectFilterDefinition;\n value: string | string[] | undefined;\n focusRef: RefObject<HTMLElement | null>;\n onChange: (next: string | string[] | undefined) => void;\n}) {\n const [query, setQuery] = useState(\"\");\n const searchable =\n definition.searchable ?? definition.options.length > SEARCHABLE_PAST;\n const chosen = new Set(\n value == null ? [] : Array.isArray(value) ? value : [value],\n );\n const needle = query.trim().toLowerCase();\n const options = needle\n ? definition.options.filter(\n (option) =>\n option.label.toLowerCase().includes(needle) ||\n option.value.toLowerCase().includes(needle),\n )\n : definition.options;\n const pick = (option: FilterOption) => {\n if (definition.multiple) {\n const next = new Set(chosen);\n if (next.has(option.value)) next.delete(option.value);\n else next.add(option.value);\n // Keep the definition's order, so the chip reads the same way\n // whatever order the values were chosen in.\n const ordered = definition.options\n .map((item) => item.value)\n .filter((item) => next.has(item));\n onChange(ordered.length > 0 ? ordered : undefined);\n return;\n }\n onChange(chosen.has(option.value) ? undefined : option.value);\n };\n return (\n <Command.Root\n label={`${definition.label} options`}\n // Without a search field the list itself takes focus, so the arrow\n // keys work from the first frame.\n ref={(node: HTMLDivElement | null) => {\n if (!searchable) focusRef.current = node;\n }}\n className=\"rounded-base\"\n >\n {searchable ? (\n <Command.InputGroup>\n <IconSearch\n aria-hidden\n className=\"text-pho-description pointer-events-none absolute left-3 size-4\"\n />\n <Command.Input\n ref={(node: HTMLInputElement | null) => {\n focusRef.current = node;\n }}\n value={query}\n onValueChange={setQuery}\n placeholder={definition.searchPlaceholder ?? \"Search\"}\n aria-label={`Search ${definition.label.toLowerCase()} options`}\n className=\"py-2 pr-3 pl-9 text-base\"\n />\n </Command.InputGroup>\n ) : null}\n <Command.List>\n <Command.Empty>Nothing matches.</Command.Empty>\n {options.map((option) => (\n <Command.Item\n key={option.value}\n value={option.value}\n size=\"sm\"\n title={option.title ?? option.label}\n aria-checked={chosen.has(option.value)}\n icon={chosen.has(option.value) ? <IconCheck aria-hidden /> : null}\n onSelect={() => pick(option)}\n />\n ))}\n </Command.List>\n </Command.Root>\n );\n}\n\nconst DATE_INPUT =\n \"bg-pho-primary ring-pho-primary text-pho-primary focus-visible:ring-pho-brand w-full min-w-0 rounded-sm px-2 py-1 text-base ring-1 transition-shadow duration-100 ease-linear outline-none ring-inset focus-visible:ring-2\";\n\nfunction DateRangePanel({\n definition,\n value,\n focusRef,\n onChange,\n}: {\n definition: DateRangeFilterDefinition;\n value: DateRangeValue | undefined;\n focusRef: RefObject<HTMLElement | null>;\n onChange: (next: DateRangeValue | undefined) => void;\n}) {\n const presets = definition.presets ?? FILTER_DATE_PRESETS;\n // A preset's `from` is a timestamp; the day field shows its date.\n const day = (side: string | null | undefined) =>\n side == null ? \"\" : DATE_ONLY.test(side) ? side : side.slice(0, 10);\n const setSide = (side: \"from\" | \"to\", next: string) => {\n // Editing either day leaves a preset behind: the pair is the value now,\n // and a preset's timestamp becomes the day it fell on.\n const range: DateRangeValue = {\n from: day(value?.from) || null,\n to: day(value?.to) || null,\n [side]: next || null,\n };\n onChange(range.from == null && range.to == null ? undefined : range);\n };\n return (\n <div className=\"flex flex-col\">\n <Command.Root\n label={`${definition.label} presets`}\n ref={(node: HTMLDivElement | null) => {\n focusRef.current = node;\n }}\n className=\"rounded-t-[inherit]\"\n >\n <Command.List>\n {presets.map((preset) => (\n <Command.Item\n key={preset.label}\n value={preset.label}\n size=\"sm\"\n title={preset.label}\n aria-checked={value?.preset === preset.label}\n icon={\n value?.preset === preset.label ? (\n <IconCheck aria-hidden />\n ) : null\n }\n onSelect={() =>\n onChange({\n from: new Date(\n Date.now() - preset.hours * 60 * 60 * 1000,\n ).toISOString(),\n to: null,\n preset: preset.label,\n })\n }\n />\n ))}\n </Command.List>\n </Command.Root>\n {/* The day fields stand outside the command list: its arrow-key\n handling would otherwise swallow the native date stepping. */}\n <div className=\"border-pho-secondary grid grid-cols-2 gap-2 border-t p-2\">\n <label className=\"text-pho-description flex min-w-0 flex-col gap-1 text-xs\">\n From\n <input\n type=\"date\"\n value={day(value?.from)}\n max={day(value?.to) || undefined}\n onChange={(event) => setSide(\"from\", event.target.value)}\n className={DATE_INPUT}\n />\n </label>\n <label className=\"text-pho-description flex min-w-0 flex-col gap-1 text-xs\">\n To\n <input\n type=\"date\"\n value={day(value?.to)}\n min={day(value?.from) || undefined}\n onChange={(event) => setSide(\"to\", event.target.value)}\n className={DATE_INPUT}\n />\n </label>\n </div>\n </div>\n );\n}\n\n/* ---------------------------------- bar --------------------------------- */\n\nexport interface FilterBarProps extends Omit<\n ComponentProps<\"div\">,\n \"children\"\n> {\n /** One chip per definition, in this order. */\n definitions: readonly FilterDefinition[];\n /** The values, keyed by definition key. Absent or empty means unset. */\n filters: FilterValues;\n /** The whole map, changed — set, cleared, or cleared all. */\n onFiltersChange: (next: FilterValues) => void;\n /** The search field's text. The field renders only with `onSearchChange`. */\n search?: string;\n onSearchChange?: (value: string) => void;\n /** A teaching phrase — \"Find an event by id\". @default \"Search\" */\n searchPlaceholder?: string;\n /** The field's accessible name when the placeholder is too short to be one. */\n searchLabel?: string;\n /**\n * Pin the bar to the top of the nearest scroll pane. It paints the\n * surface it sits on (`--pho-surface`) so rows scroll under it.\n */\n sticky?: boolean;\n /** Controls after the chips — a range picker, an export button. */\n children?: ReactNode;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport function FilterBar({\n definitions,\n filters,\n onFiltersChange,\n search,\n onSearchChange,\n searchPlaceholder = \"Search\",\n searchLabel,\n sticky,\n className,\n children,\n ...props\n}: FilterBarProps) {\n const setCount = definitions.filter((definition) =>\n isFilterSet(filters[definition.key]),\n ).length;\n const change = (key: string, next: FilterValue | undefined) => {\n const rest = { ...filters };\n if (next === undefined) delete rest[key];\n else rest[key] = next;\n onFiltersChange(rest);\n };\n return (\n <div\n data-filter-bar=\"\"\n className={cn(\n \"flex min-w-0 flex-wrap items-center gap-2\",\n sticky &&\n \"sticky top-0 z-10 bg-[var(--pho-surface,var(--background-color-pho-page))] py-3\",\n className,\n )}\n {...props}\n >\n {onSearchChange != null ? (\n <BoxSearch\n value={search ?? \"\"}\n onChange={(event) => onSearchChange(event.target.value)}\n onClear={() => onSearchChange(\"\")}\n onKeyDown={(event) => {\n if (event.key !== \"Escape\") return;\n event.preventDefault();\n onSearchChange(\"\");\n }}\n placeholder={searchPlaceholder}\n aria-label={searchLabel ?? searchPlaceholder}\n className=\"w-64 max-w-full\"\n />\n ) : null}\n {definitions.map((definition) => (\n <FilterChip\n key={definition.key}\n definition={definition}\n value={filters[definition.key]}\n onChange={(next) => change(definition.key, next)}\n />\n ))}\n {setCount > 1 ? (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => {\n const rest = { ...filters };\n for (const definition of definitions) delete rest[definition.key];\n onFiltersChange(rest);\n }}\n >\n Clear filters\n </Button>\n ) : null}\n {children}\n </div>\n );\n}\n\nFilterBar.displayName = \"FilterBar\";\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;AASA,IAAM,IAAa,CAAC,CAAC,QAAQ;AAAA,EAAE,GAAK;AAAA,EAAc,KAAO;AAAQ,CAAC,GAAG,CAAC,QAAQ;AAAA,EAAE,GAAK;AAAA,EAAc,KAAO;AAAQ,CAAC,CAAC,GAC9G,IAAW,EAAqB,WAAW,QAAQ,QAAQ,CAAU,GCwF9D,IAAkD;AAAA,EAC7D;AAAA,IAAE,OAAO;AAAA,IAAa,OAAO;AAAA,EAAE;AAAA,EAC/B;AAAA,IAAE,OAAO;AAAA,IAAiB,OAAO;AAAA,EAAG;AAAA,EACpC;AAAA,IAA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