@reopt-ai/opt-ui 1.5.0 → 1.7.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/COMPONENT_CATALOG.md +178 -50
- package/README.md +28 -7
- package/dist/app.css +170 -0
- package/dist/core/index.cjs +164 -324
- package/dist/core/index.d.cts +3 -6
- package/dist/core/index.d.ts +3 -6
- package/dist/core/index.js +3 -323
- package/dist/docs/01-getting-started.md +25 -5
- package/dist/docs/02-components/01-core.md +36 -28
- package/dist/docs/02-components/02-visuals.md +1 -1
- package/dist/docs/02-components/03-shells.md +144 -23
- package/dist/docs/02-components/04-surfaces.md +1 -1
- package/dist/docs/02-components/index.md +4 -4
- package/dist/docs/03-recipes/03-layouts.md +16 -12
- package/dist/docs/05-migration/01-breaking-changes.md +46 -1
- package/dist/field-sidebar-BTZCBviA.d.cts +1031 -0
- package/dist/field-sidebar-BTZCBviA.d.cts.map +1 -0
- package/dist/field-sidebar-CB8vjvUM.d.ts +1031 -0
- package/dist/field-sidebar-CB8vjvUM.d.ts.map +1 -0
- package/dist/field-sidebar-Cs-J-5VE.js +4233 -0
- package/dist/field-sidebar-Cs-J-5VE.js.map +1 -0
- package/dist/field-sidebar-CzIQX70-.cjs +4561 -0
- package/dist/id-registry.cjs +1939 -1872
- package/dist/id-registry.d.cts +14 -11
- package/dist/id-registry.d.cts.map +1 -0
- package/dist/id-registry.d.ts +14 -11
- package/dist/id-registry.d.ts.map +1 -0
- package/dist/id-registry.js +1937 -1871
- package/dist/id-registry.js.map +1 -0
- package/dist/id-registry.json +113 -28
- package/dist/index.cjs +8380 -9790
- package/dist/index.d.cts +1555 -1442
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +1555 -1442
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7996 -9778
- package/dist/index.js.map +1 -0
- package/dist/meta.cjs +7753 -6875
- package/dist/meta.d.cts.map +1 -0
- package/dist/meta.d.ts.map +1 -0
- package/dist/meta.js +7752 -6846
- package/dist/meta.js.map +1 -0
- package/dist/pagination-DWbvACuN.js +3850 -0
- package/dist/pagination-DWbvACuN.js.map +1 -0
- package/dist/pagination-DjfxBcjX.cjs +4739 -0
- package/dist/query.cjs +386 -0
- package/dist/query.d.cts +141 -0
- package/dist/query.d.cts.map +1 -0
- package/dist/query.d.ts +141 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +371 -0
- package/dist/query.js.map +1 -0
- package/dist/shader-surface-BUPZ0P-n.js +3654 -0
- package/dist/shader-surface-BUPZ0P-n.js.map +1 -0
- package/dist/shader-surface-BfTP9c1Q.d.ts +1788 -0
- package/dist/shader-surface-BfTP9c1Q.d.ts.map +1 -0
- package/dist/shader-surface-DRrcLrWf.d.cts +1788 -0
- package/dist/shader-surface-DRrcLrWf.d.cts.map +1 -0
- package/dist/shader-surface-Fav5K9UC.cjs +4041 -0
- package/dist/shells/index.cjs +58 -65
- package/dist/shells/index.d.cts +4 -5
- package/dist/shells/index.d.ts +4 -5
- package/dist/shells/index.js +4 -64
- package/dist/tailwind.css +49 -0
- package/dist/theme/presets/default.css +2 -2
- package/dist/theme/presets/minimal.css +2 -2
- package/dist/theme/presets/mono-dark.css +2 -2
- package/dist/theme/presets/natural.css +1 -1
- package/dist/theme/presets/pro.css +2 -2
- package/dist/theme/server.cjs +257 -228
- package/dist/theme/server.d.cts +48 -60
- package/dist/theme/server.d.cts.map +1 -0
- package/dist/theme/server.d.ts +48 -60
- package/dist/theme/server.d.ts.map +1 -0
- package/dist/theme/server.js +234 -189
- package/dist/theme/server.js.map +1 -0
- package/dist/types-D0FlcYnM.d.cts +301 -0
- package/dist/types-D0FlcYnM.d.cts.map +1 -0
- package/dist/types-D0FlcYnM.d.ts +301 -0
- package/dist/types-D0FlcYnM.d.ts.map +1 -0
- package/dist/visuals/index.cjs +10 -4
- package/dist/visuals/index.d.cts +2 -1
- package/dist/visuals/index.d.ts +2 -1
- package/dist/visuals/index.js +1 -2
- package/package.json +27 -11
- package/dist/chunk-3GWWZKX7.js +0 -38
- package/dist/chunk-3QFYBBL6.cjs +0 -4759
- package/dist/chunk-3XD4HIFL.js +0 -3241
- package/dist/chunk-AFF2HPE5.cjs +0 -5008
- package/dist/chunk-NXZJIHEZ.cjs +0 -3241
- package/dist/chunk-ONE3C5RV.cjs +0 -38
- package/dist/chunk-RBM2RNC2.js +0 -5008
- package/dist/chunk-VBGPEW45.js +0 -4759
- package/dist/index-BZ_lBlO1.d.ts +0 -474
- package/dist/index-BuvxoWHf.d.cts +0 -474
- package/dist/index-DWyqDIkH.d.cts +0 -1689
- package/dist/index-Uyijm14M.d.ts +0 -1689
- package/dist/types-D4-0lwaE.d.cts +0 -298
- package/dist/types-D4-0lwaE.d.ts +0 -298
|
@@ -0,0 +1,4233 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { $ as TooltipAnchor$1, A as FormSwitch$1, An as OPT_SURFACE_POPOVER, At as SelectPopover$1, Bn as _objectSpread2, Bt as Composite, C as FormRoot$1, Cn as OPT_FOCUS, Dt as DialogRoot$1, E as FormSelectPopover, En as OPT_INPUT, Et as DialogPanel$1, F as useFormStore, Fn as OPT_TEXT_LABEL, Ft as TabPanel$1, G as PopoverTrigger$1, Hn as Kbd, Ht as CompositeProvider, In as OPT_TEXT_PRIMARY, It as TabsRoot$1, J as ToolbarButton$1, Jt as Alert, Kt as Input, Ln as OPT_TEXT_SECONDARY, Lt as DisclosureContent$1, M as FormTextarea, Mn as OPT_TD, Mt as SelectTrigger$1, Nn as OPT_TD_MUTED, Nt as Tab$1, On as OPT_ITEM_BASE, Ot as SelectItem$1, Pt as TabList$1, Q as Tooltip$1, Qt as Button, R as TagInput, Rn as OPT_TEXT_TERTIARY, Rt as DisclosureRoot$1, Sn as OPT_DOT_YELLOW, T as FormSelectItem, Tt as DialogHeading$1, U as PopoverContent$1, Un as cn, Ut as CompositeRow, Vn as _objectWithoutProperties, Vt as CompositeItem, W as PopoverRoot$1, X as ToolbarRoot$1, Xt as Badge, Y as ToolbarContainer$1, Yt as Spinner, Z as ToolbarSeparator$1, Zt as EmptyState, _n as OPT_DISCLOSURE_TRIGGER, _t as ComboboxRoot$1, at as MenuPopover$1, b as FormRadioGroup$1, bn as OPT_DOT_GREEN, bt as DialogDescription$1, ct as MenuTrigger$1, dn as OPT_BADGE_GREEN, dt as ComboboxEmpty, et as TooltipProvider$1, fn as OPT_BADGE_NEUTRAL, gn as OPT_DISCLOSURE_CONTENT, gt as ComboboxPopover$1, h as FormLabel$1, hn as OPT_BORDER, ht as ComboboxItem$1, i as FormCheckbox$1, it as MenuItemRadio$1, jn as OPT_TABLE_ROW_ACTIVE, jt as SelectRoot$1, k as FormSubmit$1, kn as OPT_SURFACE, kt as SelectLabel$1, l as FormError$1, ln as OPT_ANIMATE_ENTER_EXIT, lt as MenubarContainer$1, m as FormInput$1, mn as OPT_BADGE_YELLOW, mt as ComboboxInput$1, n as Checkbox, nn as StatCard, nt as MenuItem$1, ot as MenuRoot$1, pn as OPT_BADGE_RED, rt as MenuItemCheckbox$1, sn as OPT_ACTIVE_ITEM, st as MenuSeparator$1, t as Pagination, tt as MenuButtonArrow$1, un as OPT_BADGE_BLUE, ut as MenubarRoot$1, vn as OPT_DIVIDER, w as FormSelect, wn as OPT_FOCUS_VISIBLE, xn as OPT_DOT_RED, y as FormRadio$1, zn as OPT_TH, zt as DisclosureTrigger$1 } from "./pagination-DWbvACuN.js";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { Fragment as Fragment$1, createContext, forwardRef, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
6
|
+
import { CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandRoot, CommandSeparator } from "@reopt-ai/opt-ui-primitives";
|
|
7
|
+
import { ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Clock, Columns3, Minus, Plus, RefreshCw, Search, SearchIcon, Undo2, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
8
|
+
import { TimeSeriesChart, formatCountUnit, formatDuration, formatInstant, isDateOnly, isExactMinutes, isRelativeToNow, measureTimeWindow, parseRelativeParts, parseTimeExpression, resolveTimeRange, shiftTimeRange, toAbsoluteRange, zoomTimeRange } from "@reopt-ai/opt-charts";
|
|
9
|
+
import { matchSorter } from "match-sorter";
|
|
10
|
+
import Link from "next/link";
|
|
11
|
+
import { usePathname } from "next/navigation";
|
|
12
|
+
//#region src/core/command.tsx
|
|
13
|
+
const _excluded = ["className"];
|
|
14
|
+
const _excluded2 = [
|
|
15
|
+
"className",
|
|
16
|
+
"trailing",
|
|
17
|
+
"wrapperClassName",
|
|
18
|
+
"placeholder",
|
|
19
|
+
"aria-label"
|
|
20
|
+
];
|
|
21
|
+
const _excluded3 = ["className", "aria-label"];
|
|
22
|
+
const _excluded4 = ["className"];
|
|
23
|
+
const _excluded5 = ["className", "heading"];
|
|
24
|
+
const _excluded6 = ["className"];
|
|
25
|
+
const _excluded7 = ["className"];
|
|
26
|
+
const _excluded8 = ["className"];
|
|
27
|
+
/** Renders the `Command` component. */
|
|
28
|
+
function Command(_ref) {
|
|
29
|
+
let { className } = _ref, props = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
return /* @__PURE__ */ jsx(CommandRoot, _objectSpread2(_objectSpread2({ className: cn("bg-surface text-text-primary flex w-full flex-col overflow-hidden rounded-xl", className) }, props), {}, {
|
|
31
|
+
"data-opt-id": "4FYBW",
|
|
32
|
+
"data-opt-slug": "command.Command"
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
/** Renders a Command in a dialog overlay, à la Cmd+K palette. */
|
|
36
|
+
function CommandDialog({ open, onOpenChange, title = "Command Palette", description = "검색 후 Enter 또는 클릭으로 명령을 실행하세요.", className, commandClassName, shouldFilter, filter, children }) {
|
|
37
|
+
return /* @__PURE__ */ jsx(DialogRoot$1, {
|
|
38
|
+
open,
|
|
39
|
+
onOpenChange,
|
|
40
|
+
"data-opt-id": "DVRSX",
|
|
41
|
+
"data-opt-slug": "command.CommandDialog",
|
|
42
|
+
children: /* @__PURE__ */ jsxs(DialogPanel$1, {
|
|
43
|
+
className: cn("top-[20%] left-1/2 -translate-x-1/2", "w-full max-w-lg overflow-hidden p-0 shadow-2xl", className),
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ jsx(DialogHeading$1, {
|
|
46
|
+
className: "sr-only",
|
|
47
|
+
children: title
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ jsx(DialogDescription$1, {
|
|
50
|
+
className: "sr-only",
|
|
51
|
+
children: description
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ jsx(Command, {
|
|
54
|
+
shouldFilter,
|
|
55
|
+
filter,
|
|
56
|
+
className: commandClassName,
|
|
57
|
+
children
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Renders the `CommandInput` component with a leading search icon. */
|
|
64
|
+
function CommandInput$1(_ref2) {
|
|
65
|
+
let { className, trailing, wrapperClassName, placeholder, "aria-label": ariaLabel } = _ref2, props = _objectWithoutProperties(_ref2, _excluded2);
|
|
66
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
67
|
+
"data-slot": "command-input-wrapper",
|
|
68
|
+
className: cn("border-border-subtle gap-element flex h-12 items-center border-b px-3", wrapperClassName),
|
|
69
|
+
"data-opt-id": "HB1K3",
|
|
70
|
+
"data-opt-slug": "command.CommandInput",
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx(SearchIcon, {
|
|
73
|
+
"aria-hidden": true,
|
|
74
|
+
className: "text-text-tertiary size-4 shrink-0"
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ jsx(CommandInput, _objectSpread2({
|
|
77
|
+
className: cn("text-text-primary placeholder:text-text-tertiary flex h-full w-full bg-transparent text-sm outline-none focus-visible:ring-0 focus-visible:outline-none", "disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
78
|
+
placeholder,
|
|
79
|
+
"aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : typeof placeholder === "string" ? placeholder : "Command search"
|
|
80
|
+
}, props)),
|
|
81
|
+
trailing
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** Renders the `CommandList` component. */
|
|
86
|
+
function CommandList$1(_ref3) {
|
|
87
|
+
let { className, "aria-label": ariaLabel } = _ref3, props = _objectWithoutProperties(_ref3, _excluded3);
|
|
88
|
+
return /* @__PURE__ */ jsx(CommandList, _objectSpread2(_objectSpread2({
|
|
89
|
+
className: cn("max-h-80 scroll-py-1 overflow-x-hidden overflow-y-auto p-1", className),
|
|
90
|
+
"aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : "Commands"
|
|
91
|
+
}, props), {}, {
|
|
92
|
+
"data-opt-id": "NPXC5",
|
|
93
|
+
"data-opt-slug": "command.CommandList"
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
/** Renders the `CommandEmpty` component. */
|
|
97
|
+
function CommandEmpty$1(_ref4) {
|
|
98
|
+
let { className } = _ref4, props = _objectWithoutProperties(_ref4, _excluded4);
|
|
99
|
+
return /* @__PURE__ */ jsx(CommandEmpty, _objectSpread2(_objectSpread2({ className: cn("text-text-tertiary py-6 text-center text-sm", className) }, props), {}, {
|
|
100
|
+
"data-opt-id": "A8BZM",
|
|
101
|
+
"data-opt-slug": "command.CommandEmpty"
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
/** Renders the `CommandGroup` component with an optional heading. */
|
|
105
|
+
function CommandGroup$1(_ref5) {
|
|
106
|
+
let { className, heading } = _ref5, props = _objectWithoutProperties(_ref5, _excluded5);
|
|
107
|
+
return /* @__PURE__ */ jsx(CommandGroup, _objectSpread2(_objectSpread2({
|
|
108
|
+
heading: heading != null ? /* @__PURE__ */ jsx("div", {
|
|
109
|
+
className: "text-text-tertiary px-2 py-1.5 text-xs font-medium",
|
|
110
|
+
children: heading
|
|
111
|
+
}) : void 0,
|
|
112
|
+
className: cn("py-1", className)
|
|
113
|
+
}, props), {}, {
|
|
114
|
+
"data-opt-id": "JPK1Y",
|
|
115
|
+
"data-opt-slug": "command.CommandGroup"
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
/** Renders the `CommandSeparator` component. */
|
|
119
|
+
function CommandSeparator$1(_ref6) {
|
|
120
|
+
let { className } = _ref6, props = _objectWithoutProperties(_ref6, _excluded6);
|
|
121
|
+
return /* @__PURE__ */ jsx(CommandSeparator, _objectSpread2(_objectSpread2({ className: cn("bg-border-subtle -mx-1 my-1 h-px", className) }, props), {}, {
|
|
122
|
+
"data-opt-id": "10P0E",
|
|
123
|
+
"data-opt-slug": "command.CommandSeparator"
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
/** Renders the `CommandItem` component. */
|
|
127
|
+
function CommandItem$1(_ref7) {
|
|
128
|
+
let { className } = _ref7, props = _objectWithoutProperties(_ref7, _excluded7);
|
|
129
|
+
return /* @__PURE__ */ jsx(CommandItem, _objectSpread2(_objectSpread2({ className: cn("text-text-primary flex cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-sm select-none", "data-[active-item]:bg-accent data-[active-item]:text-accent-fg", "data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className) }, props), {}, {
|
|
130
|
+
"data-opt-id": "K674W",
|
|
131
|
+
"data-opt-slug": "command.CommandItem"
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
/** Renders the `CommandShortcut` component (right-aligned hint). */
|
|
135
|
+
function CommandShortcut(_ref8) {
|
|
136
|
+
let { className } = _ref8, props = _objectWithoutProperties(_ref8, _excluded8);
|
|
137
|
+
return /* @__PURE__ */ jsx("span", _objectSpread2(_objectSpread2({
|
|
138
|
+
"data-slot": "command-shortcut",
|
|
139
|
+
className: cn("text-text-tertiary ml-auto text-xs tracking-widest", "data-[active-item]:text-accent-fg/80", className)
|
|
140
|
+
}, props), {}, {
|
|
141
|
+
"data-opt-id": "75CQK",
|
|
142
|
+
"data-opt-slug": "command.CommandShortcut"
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/shells/command-palette.tsx
|
|
147
|
+
const DEFAULT_LABELS = {
|
|
148
|
+
title: "Command Palette",
|
|
149
|
+
description: "검색 후 Enter 또는 클릭으로 명령을 실행하세요.",
|
|
150
|
+
input: "명령어 검색",
|
|
151
|
+
placeholder: "명령어를 검색하세요...",
|
|
152
|
+
list: "명령어 목록",
|
|
153
|
+
empty: "결과가 없습니다.",
|
|
154
|
+
escape: "ESC"
|
|
155
|
+
};
|
|
156
|
+
/** Renders the command palette component. */
|
|
157
|
+
function CommandPalette({ commands, open, onOpenChange, onSelect, inline = false, labels, footer, empty, inputTrailing, className }) {
|
|
158
|
+
const resolvedLabels = _objectSpread2(_objectSpread2({}, DEFAULT_LABELS), labels);
|
|
159
|
+
const hasCommands = commands.length > 0;
|
|
160
|
+
const grouped = useMemo(() => {
|
|
161
|
+
const map = /* @__PURE__ */ new Map();
|
|
162
|
+
for (const cmd of commands) {
|
|
163
|
+
var _map$get;
|
|
164
|
+
const list = (_map$get = map.get(cmd.group)) !== null && _map$get !== void 0 ? _map$get : [];
|
|
165
|
+
list.push(cmd);
|
|
166
|
+
map.set(cmd.group, list);
|
|
167
|
+
}
|
|
168
|
+
return map;
|
|
169
|
+
}, [commands]);
|
|
170
|
+
const handleSelect = (cmdId) => {
|
|
171
|
+
const cmd = commands.find((c) => c.id === cmdId);
|
|
172
|
+
if (!cmd) return;
|
|
173
|
+
onSelect === null || onSelect === void 0 || onSelect(cmd);
|
|
174
|
+
onOpenChange(false);
|
|
175
|
+
};
|
|
176
|
+
const handleInputKeyDown = (e) => {
|
|
177
|
+
if (e.key === "Escape" && !inline) {
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
onOpenChange(false);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
183
|
+
/* @__PURE__ */ jsx(CommandInput$1, {
|
|
184
|
+
"aria-label": resolvedLabels.input,
|
|
185
|
+
placeholder: resolvedLabels.placeholder,
|
|
186
|
+
onKeyDown: handleInputKeyDown,
|
|
187
|
+
trailing: inputTrailing !== null && inputTrailing !== void 0 ? inputTrailing : !inline ? /* @__PURE__ */ jsx(Kbd, { children: resolvedLabels.escape }) : void 0
|
|
188
|
+
}),
|
|
189
|
+
/* @__PURE__ */ jsxs(CommandList$1, {
|
|
190
|
+
"aria-label": resolvedLabels.list,
|
|
191
|
+
children: [/* @__PURE__ */ jsx(CommandEmpty$1, { children: empty !== null && empty !== void 0 ? empty : resolvedLabels.empty }), hasCommands ? Array.from(grouped.entries()).map(([group, items]) => /* @__PURE__ */ jsx(CommandGroup$1, {
|
|
192
|
+
heading: group,
|
|
193
|
+
children: items.map((cmd) => /* @__PURE__ */ jsxs(CommandItem$1, {
|
|
194
|
+
value: cmd.id,
|
|
195
|
+
keywords: [
|
|
196
|
+
cmd.label,
|
|
197
|
+
cmd.group,
|
|
198
|
+
...cmd.shortcut ? [cmd.shortcut] : []
|
|
199
|
+
],
|
|
200
|
+
onSelect: handleSelect,
|
|
201
|
+
children: [/* @__PURE__ */ jsx("span", { children: cmd.label }), cmd.shortcut && /* @__PURE__ */ jsx(CommandShortcut, { children: cmd.shortcut })]
|
|
202
|
+
}, cmd.id))
|
|
203
|
+
}, group)) : null]
|
|
204
|
+
}),
|
|
205
|
+
footer
|
|
206
|
+
] });
|
|
207
|
+
if (inline) {
|
|
208
|
+
if (!open) return null;
|
|
209
|
+
return /* @__PURE__ */ jsx(Command, {
|
|
210
|
+
className: cn("border-border bg-surface w-full max-w-lg border shadow-lg", className),
|
|
211
|
+
"data-opt-id": "ATTF5",
|
|
212
|
+
"data-opt-slug": "command-palette.CommandPalette",
|
|
213
|
+
children: body
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return /* @__PURE__ */ jsx(CommandDialog, {
|
|
217
|
+
open,
|
|
218
|
+
onOpenChange,
|
|
219
|
+
title: resolvedLabels.title,
|
|
220
|
+
description: resolvedLabels.description,
|
|
221
|
+
className,
|
|
222
|
+
"data-opt-id": "ATTF5",
|
|
223
|
+
"data-opt-slug": "command-palette.CommandPalette",
|
|
224
|
+
children: body
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/shells/command-palette-trigger.tsx
|
|
229
|
+
/** Renders the command palette trigger component. */
|
|
230
|
+
function CommandPaletteTrigger({ commands, onSelect, labels }) {
|
|
231
|
+
const [open, setOpen] = useState(false);
|
|
232
|
+
const handleKeyDown = useCallback((e) => {
|
|
233
|
+
if ((e.metaKey || e.ctrlKey) && e.key === "k") {
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
setOpen(true);
|
|
236
|
+
}
|
|
237
|
+
}, []);
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
if (commands.length === 0) return;
|
|
240
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
241
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
242
|
+
}, [commands.length, handleKeyDown]);
|
|
243
|
+
if (commands.length === 0) return null;
|
|
244
|
+
return /* @__PURE__ */ jsx(CommandPalette, {
|
|
245
|
+
commands,
|
|
246
|
+
open,
|
|
247
|
+
onOpenChange: setOpen,
|
|
248
|
+
onSelect,
|
|
249
|
+
labels,
|
|
250
|
+
"data-opt-id": "4FCDB",
|
|
251
|
+
"data-opt-slug": "command-palette-trigger.CommandPaletteTrigger"
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/shells/dashboard-grid.tsx
|
|
256
|
+
const defaultLabels$18 = { ariaLabel: "대시보드 통계" };
|
|
257
|
+
const MIN_DASHBOARD_COLUMNS = 1;
|
|
258
|
+
const MAX_DASHBOARD_COLUMNS = 12;
|
|
259
|
+
function normalizeDashboardColumns(columns) {
|
|
260
|
+
if (!Number.isFinite(columns)) return MIN_DASHBOARD_COLUMNS;
|
|
261
|
+
return Math.min(MAX_DASHBOARD_COLUMNS, Math.max(MIN_DASHBOARD_COLUMNS, Math.floor(columns)));
|
|
262
|
+
}
|
|
263
|
+
/** Renders the dashboard grid component. */
|
|
264
|
+
function DashboardGrid({ stats, columns = 3, labels: customLabels }) {
|
|
265
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$18), customLabels);
|
|
266
|
+
const columnCount = normalizeDashboardColumns(columns);
|
|
267
|
+
const rowStyle = { "--opt-dashboard-grid-columns": `repeat(${columnCount}, minmax(0, 1fr))` };
|
|
268
|
+
const rows = [];
|
|
269
|
+
for (let i = 0; i < stats.length; i += columnCount) rows.push(stats.slice(i, i + columnCount));
|
|
270
|
+
return /* @__PURE__ */ jsx(CompositeProvider, {
|
|
271
|
+
focusLoop: true,
|
|
272
|
+
focusWrap: true,
|
|
273
|
+
"data-opt-id": "BM7NA",
|
|
274
|
+
"data-opt-slug": "dashboard-grid.DashboardGrid",
|
|
275
|
+
children: /* @__PURE__ */ jsx(Composite, {
|
|
276
|
+
role: "grid",
|
|
277
|
+
"aria-label": labels.ariaLabel,
|
|
278
|
+
className: "gap-group flex flex-col",
|
|
279
|
+
children: rows.map((row, ri) => /* @__PURE__ */ jsx(CompositeRow, {
|
|
280
|
+
className: "gap-group grid grid-cols-1 sm:[grid-template-columns:var(--opt-dashboard-grid-columns)]",
|
|
281
|
+
style: rowStyle,
|
|
282
|
+
children: row.map((stat) => /* @__PURE__ */ jsx(CompositeItem, {
|
|
283
|
+
className: "data-[active-item]:ring-ring data-[active-item]:ring-offset-ring-offset data-[focus-visible]:ring-ring data-[focus-visible]:ring-offset-ring-offset rounded-xl outline-none data-[active-item]:ring-2 data-[active-item]:ring-offset-2 data-[focus-visible]:ring-2 data-[focus-visible]:ring-offset-2",
|
|
284
|
+
render: /* @__PURE__ */ jsx("div", { role: "gridcell" }),
|
|
285
|
+
children: /* @__PURE__ */ jsx(StatCard, _objectSpread2({}, stat))
|
|
286
|
+
}, stat.id))
|
|
287
|
+
}, ri))
|
|
288
|
+
})
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/shells/search-combobox.tsx
|
|
293
|
+
const defaultLabels$17 = {
|
|
294
|
+
noResults: "결과가 없습니다.",
|
|
295
|
+
loading: "Loading…"
|
|
296
|
+
};
|
|
297
|
+
/** Renders the search combobox component. */
|
|
298
|
+
function SearchCombobox({ items, placeholder = "검색...", label = "검색", onSelect, labels: customLabels, async: isAsync = false, onSearch, debounceMs = 300 }) {
|
|
299
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$17), customLabels);
|
|
300
|
+
const inputId = useId();
|
|
301
|
+
const [query, setQuery] = useState("");
|
|
302
|
+
const [asyncResults, setAsyncResults] = useState([]);
|
|
303
|
+
const [loading, setLoading] = useState(false);
|
|
304
|
+
const timerRef = useRef(void 0);
|
|
305
|
+
const searchGenerationRef = useRef(0);
|
|
306
|
+
const syncMatches = useMemo(() => {
|
|
307
|
+
if (isAsync) return [];
|
|
308
|
+
if (!query) return items;
|
|
309
|
+
return matchSorter(items, query);
|
|
310
|
+
}, [
|
|
311
|
+
query,
|
|
312
|
+
items,
|
|
313
|
+
isAsync
|
|
314
|
+
]);
|
|
315
|
+
const handleInput = (event) => {
|
|
316
|
+
searchGenerationRef.current += 1;
|
|
317
|
+
setQuery(event.currentTarget.value);
|
|
318
|
+
};
|
|
319
|
+
const handleValueChange = (item) => {
|
|
320
|
+
searchGenerationRef.current += 1;
|
|
321
|
+
setQuery(item);
|
|
322
|
+
onSelect === null || onSelect === void 0 || onSelect(item);
|
|
323
|
+
};
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
const generation = ++searchGenerationRef.current;
|
|
326
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
327
|
+
if (!isAsync || !onSearch) {
|
|
328
|
+
setLoading(false);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (!query) {
|
|
332
|
+
setAsyncResults([]);
|
|
333
|
+
setLoading(false);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
setLoading(true);
|
|
337
|
+
timerRef.current = setTimeout(async () => {
|
|
338
|
+
try {
|
|
339
|
+
const results = await onSearch(query);
|
|
340
|
+
if (searchGenerationRef.current !== generation) return;
|
|
341
|
+
setAsyncResults(results);
|
|
342
|
+
} finally {
|
|
343
|
+
if (searchGenerationRef.current === generation) setLoading(false);
|
|
344
|
+
}
|
|
345
|
+
}, debounceMs);
|
|
346
|
+
return () => {
|
|
347
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
348
|
+
};
|
|
349
|
+
}, [
|
|
350
|
+
query,
|
|
351
|
+
isAsync,
|
|
352
|
+
onSearch,
|
|
353
|
+
debounceMs
|
|
354
|
+
]);
|
|
355
|
+
const matches = isAsync ? asyncResults : syncMatches;
|
|
356
|
+
return /* @__PURE__ */ jsx("div", {
|
|
357
|
+
className: "gap-element flex flex-col",
|
|
358
|
+
"data-opt-id": "KH4TQ",
|
|
359
|
+
"data-opt-slug": "search-combobox.SearchCombobox",
|
|
360
|
+
children: /* @__PURE__ */ jsxs(ComboboxRoot$1, {
|
|
361
|
+
onValueChange: handleValueChange,
|
|
362
|
+
children: [
|
|
363
|
+
/* @__PURE__ */ jsx("label", {
|
|
364
|
+
htmlFor: inputId,
|
|
365
|
+
className: OPT_TEXT_LABEL,
|
|
366
|
+
children: label
|
|
367
|
+
}),
|
|
368
|
+
/* @__PURE__ */ jsx(ComboboxInput$1, {
|
|
369
|
+
id: inputId,
|
|
370
|
+
placeholder,
|
|
371
|
+
className: "max-w-xs",
|
|
372
|
+
"aria-busy": loading || void 0,
|
|
373
|
+
onInput: handleInput
|
|
374
|
+
}),
|
|
375
|
+
/* @__PURE__ */ jsx(ComboboxPopover$1, {
|
|
376
|
+
className: "max-w-xs",
|
|
377
|
+
children: isAsync && loading ? /* @__PURE__ */ jsxs("div", {
|
|
378
|
+
className: "text-text-secondary gap-element flex items-center px-3 py-2 text-sm",
|
|
379
|
+
role: "status",
|
|
380
|
+
"aria-live": "polite",
|
|
381
|
+
"aria-busy": "true",
|
|
382
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
383
|
+
size: "sm",
|
|
384
|
+
"aria-hidden": "true"
|
|
385
|
+
}), labels.loading]
|
|
386
|
+
}) : matches.length === 0 ? /* @__PURE__ */ jsx(ComboboxEmpty, { children: labels.noResults }) : matches.map((item) => /* @__PURE__ */ jsx(ComboboxItem$1, {
|
|
387
|
+
value: item,
|
|
388
|
+
children: item
|
|
389
|
+
}, item))
|
|
390
|
+
})
|
|
391
|
+
]
|
|
392
|
+
})
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/shells/status-select.tsx
|
|
397
|
+
const defaultLabels$16 = {
|
|
398
|
+
selectLabel: "상태",
|
|
399
|
+
emptyMessage: "사용 가능한 상태 옵션이 없습니다."
|
|
400
|
+
};
|
|
401
|
+
/** Renders the status select component. */
|
|
402
|
+
function StatusSelect({ options, value: controlledValue, onChange, label, labels: customLabels }) {
|
|
403
|
+
var _options$0$value, _options$;
|
|
404
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$16), customLabels);
|
|
405
|
+
const resolvedLabel = label !== null && label !== void 0 ? label : labels.selectLabel;
|
|
406
|
+
const [internalValue, setInternalValue] = useState((_options$0$value = (_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.value) !== null && _options$0$value !== void 0 ? _options$0$value : "");
|
|
407
|
+
const value = controlledValue !== null && controlledValue !== void 0 ? controlledValue : internalValue;
|
|
408
|
+
const selected = options.find((s) => s.value === value);
|
|
409
|
+
if (options.length === 0) return /* @__PURE__ */ jsxs("div", {
|
|
410
|
+
className: "gap-element flex flex-col",
|
|
411
|
+
"data-opt-id": "R46E6",
|
|
412
|
+
"data-opt-slug": "status-select.StatusSelect",
|
|
413
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
414
|
+
className: OPT_TEXT_LABEL,
|
|
415
|
+
children: resolvedLabel
|
|
416
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
417
|
+
className: "text-text-tertiary text-sm",
|
|
418
|
+
children: labels.emptyMessage
|
|
419
|
+
})]
|
|
420
|
+
});
|
|
421
|
+
const handleChange = (v) => {
|
|
422
|
+
var _v$;
|
|
423
|
+
const next = Array.isArray(v) ? (_v$ = v[0]) !== null && _v$ !== void 0 ? _v$ : "" : v;
|
|
424
|
+
if (onChange) onChange(next);
|
|
425
|
+
else setInternalValue(next);
|
|
426
|
+
};
|
|
427
|
+
return /* @__PURE__ */ jsx("div", {
|
|
428
|
+
className: "gap-element flex flex-col",
|
|
429
|
+
"data-opt-id": "R46E6",
|
|
430
|
+
"data-opt-slug": "status-select.StatusSelect",
|
|
431
|
+
children: /* @__PURE__ */ jsxs(SelectRoot$1, {
|
|
432
|
+
value,
|
|
433
|
+
onValueChange: handleChange,
|
|
434
|
+
children: [
|
|
435
|
+
/* @__PURE__ */ jsx(SelectLabel$1, {
|
|
436
|
+
className: OPT_TEXT_LABEL,
|
|
437
|
+
children: resolvedLabel
|
|
438
|
+
}),
|
|
439
|
+
/* @__PURE__ */ jsxs(SelectTrigger$1, {
|
|
440
|
+
className: `${OPT_INPUT} max-w-xs items-center justify-between ${OPT_FOCUS}`,
|
|
441
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
442
|
+
className: "gap-element flex items-center",
|
|
443
|
+
children: [(selected === null || selected === void 0 ? void 0 : selected.color) && /* @__PURE__ */ jsx("span", { className: `h-2 w-2 rounded-full ${selected.color}` }), selected === null || selected === void 0 ? void 0 : selected.label]
|
|
444
|
+
}), /* @__PURE__ */ jsx("svg", {
|
|
445
|
+
className: "text-text-tertiary h-4 w-4",
|
|
446
|
+
fill: "none",
|
|
447
|
+
viewBox: "0 0 24 24",
|
|
448
|
+
stroke: "currentColor",
|
|
449
|
+
strokeWidth: 2,
|
|
450
|
+
"aria-hidden": "true",
|
|
451
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
452
|
+
strokeLinecap: "round",
|
|
453
|
+
strokeLinejoin: "round",
|
|
454
|
+
d: "m19.5 8.25-7.5 7.5-7.5-7.5"
|
|
455
|
+
})
|
|
456
|
+
})]
|
|
457
|
+
}),
|
|
458
|
+
/* @__PURE__ */ jsx(SelectPopover$1, {
|
|
459
|
+
className: `${OPT_SURFACE_POPOVER} ${OPT_ANIMATE_ENTER_EXIT} max-w-xs`,
|
|
460
|
+
children: options.map((option) => /* @__PURE__ */ jsxs(SelectItem$1, {
|
|
461
|
+
value: option.value,
|
|
462
|
+
children: [option.color && /* @__PURE__ */ jsx("span", { className: `h-2 w-2 rounded-full ${option.color}` }), option.label]
|
|
463
|
+
}, option.value))
|
|
464
|
+
})
|
|
465
|
+
]
|
|
466
|
+
})
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/shells/app-menubar.tsx
|
|
471
|
+
const defaultLabels$15 = { ariaLabel: "Application menu" };
|
|
472
|
+
function MenuSection({ menu }) {
|
|
473
|
+
return /* @__PURE__ */ jsxs(MenuRoot$1, { children: [/* @__PURE__ */ jsxs(MenuTrigger$1, { children: [menu.label, /* @__PURE__ */ jsx(MenuButtonArrow$1, {})] }), /* @__PURE__ */ jsx(MenuPopover$1, { children: menu.items.map((item, i) => {
|
|
474
|
+
if (item.type === "separator") return /* @__PURE__ */ jsx(MenuSeparator$1, {}, `sep-${i}`);
|
|
475
|
+
if (item.type === "checkbox") {
|
|
476
|
+
var _item$name, _item$value;
|
|
477
|
+
return /* @__PURE__ */ jsx(MenuItemCheckbox$1, {
|
|
478
|
+
name: (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : item.id,
|
|
479
|
+
value: (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.id,
|
|
480
|
+
checked: item.checked,
|
|
481
|
+
onChange: item.onChange,
|
|
482
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
483
|
+
className: "gap-element flex items-center",
|
|
484
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
485
|
+
className: "w-4 text-center",
|
|
486
|
+
children: item.checked ? "✓" : ""
|
|
487
|
+
}), item.label]
|
|
488
|
+
})
|
|
489
|
+
}, item.id);
|
|
490
|
+
}
|
|
491
|
+
if (item.type === "radio") {
|
|
492
|
+
var _item$name2, _item$value2;
|
|
493
|
+
return /* @__PURE__ */ jsx(MenuItemRadio$1, {
|
|
494
|
+
name: (_item$name2 = item.name) !== null && _item$name2 !== void 0 ? _item$name2 : "",
|
|
495
|
+
value: (_item$value2 = item.value) !== null && _item$value2 !== void 0 ? _item$value2 : "",
|
|
496
|
+
checked: item.checked,
|
|
497
|
+
onChange: item.onChange,
|
|
498
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
499
|
+
className: "gap-element flex items-center",
|
|
500
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
501
|
+
className: "w-4 text-center",
|
|
502
|
+
children: item.checked ? "●" : ""
|
|
503
|
+
}), item.label]
|
|
504
|
+
})
|
|
505
|
+
}, item.id);
|
|
506
|
+
}
|
|
507
|
+
return /* @__PURE__ */ jsxs(MenuItem$1, {
|
|
508
|
+
onClick: item.onClick,
|
|
509
|
+
children: [/* @__PURE__ */ jsx("span", { children: item.label }), item.shortcut && /* @__PURE__ */ jsx(Kbd, { children: item.shortcut })]
|
|
510
|
+
}, item.id);
|
|
511
|
+
}) })] });
|
|
512
|
+
}
|
|
513
|
+
/** Renders the app menubar component. */
|
|
514
|
+
function AppMenubar({ menus, labels: customLabels }) {
|
|
515
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$15), customLabels);
|
|
516
|
+
if (menus.length === 0) return null;
|
|
517
|
+
return /* @__PURE__ */ jsx(MenubarRoot$1, {
|
|
518
|
+
"data-opt-id": "BGKHW",
|
|
519
|
+
"data-opt-slug": "app-menubar.AppMenubar",
|
|
520
|
+
children: /* @__PURE__ */ jsx(MenubarContainer$1, {
|
|
521
|
+
"aria-label": labels.ariaLabel,
|
|
522
|
+
children: menus.map((menu) => /* @__PURE__ */ jsx(MenuSection, { menu }, menu.id))
|
|
523
|
+
})
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
AppMenubar.displayName = "AppMenubar";
|
|
527
|
+
//#endregion
|
|
528
|
+
//#region src/shells/sidebar-nav.tsx
|
|
529
|
+
const NAV_ID_PREFIX = "sidebar-nav-";
|
|
530
|
+
function domId(id) {
|
|
531
|
+
return `${NAV_ID_PREFIX}${id}`;
|
|
532
|
+
}
|
|
533
|
+
const sectionStyles = {
|
|
534
|
+
시작하기: "text-accent",
|
|
535
|
+
"핵심 개념": "text-info-fg",
|
|
536
|
+
구축·운영: "text-success-fg",
|
|
537
|
+
도구: "text-warning-fg",
|
|
538
|
+
DataGrid: "text-accent",
|
|
539
|
+
"컴포넌트 · Core": "text-accent",
|
|
540
|
+
"컴포넌트 · Visuals": "text-success-fg",
|
|
541
|
+
"컴포넌트 · Shells": "text-warning-fg",
|
|
542
|
+
"컴포넌트 · Surfaces": "text-info-fg",
|
|
543
|
+
"기본 컴포넌트": "text-accent",
|
|
544
|
+
"블록 컴포넌트": "text-info-fg",
|
|
545
|
+
"조합 컴포넌트": "text-warning-fg",
|
|
546
|
+
템플릿: "text-text-tertiary",
|
|
547
|
+
릴리즈: "text-text-tertiary",
|
|
548
|
+
Primitives: "text-accent",
|
|
549
|
+
Blocks: "text-info-fg",
|
|
550
|
+
Compositions: "text-warning-fg",
|
|
551
|
+
Templates: "text-text-tertiary"
|
|
552
|
+
};
|
|
553
|
+
const defaultSectionStyle = "text-text-secondary";
|
|
554
|
+
const defaultLabels$14 = { ariaLabel: "문서 네비게이션" };
|
|
555
|
+
/** Renders the sidebar nav component. */
|
|
556
|
+
function SidebarNav({ items, labels: customLabels }) {
|
|
557
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$14), customLabels);
|
|
558
|
+
const pathname = usePathname();
|
|
559
|
+
const activeItem = items.find((item) => item.href === pathname);
|
|
560
|
+
const [activeId, setActiveId] = useState(activeItem ? domId(activeItem.id) : void 0);
|
|
561
|
+
useEffect(() => {
|
|
562
|
+
const match = items.find((item) => item.href === pathname);
|
|
563
|
+
if (match) setActiveId(domId(match.id));
|
|
564
|
+
}, [pathname, items]);
|
|
565
|
+
if (items.length === 0) return null;
|
|
566
|
+
return /* @__PURE__ */ jsx(CompositeProvider, {
|
|
567
|
+
focusLoop: true,
|
|
568
|
+
orientation: "vertical",
|
|
569
|
+
activeId,
|
|
570
|
+
onActiveIdChange: setActiveId,
|
|
571
|
+
"data-opt-id": "1FZNH",
|
|
572
|
+
"data-opt-slug": "sidebar-nav.SidebarNav",
|
|
573
|
+
children: /* @__PURE__ */ jsx(Composite, {
|
|
574
|
+
role: "navigation",
|
|
575
|
+
"aria-label": labels.ariaLabel,
|
|
576
|
+
className: "flex flex-col",
|
|
577
|
+
children: items.map((item, index) => {
|
|
578
|
+
var _sectionStyles$item$s, _item$sectionLabel;
|
|
579
|
+
const isSelected = pathname === item.href;
|
|
580
|
+
const isFirstItem = index === 0;
|
|
581
|
+
const sectionTextStyle = item.sectionLabel ? (_sectionStyles$item$s = sectionStyles[item.sectionLabel]) !== null && _sectionStyles$item$s !== void 0 ? _sectionStyles$item$s : defaultSectionStyle : defaultSectionStyle;
|
|
582
|
+
return /* @__PURE__ */ jsxs("div", { children: [item.separator && /* @__PURE__ */ jsx("div", {
|
|
583
|
+
className: cn("mb-2 pt-2", !isFirstItem && "mt-7"),
|
|
584
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
585
|
+
className: cn("px-2 text-[11px] font-semibold tracking-wider uppercase", sectionTextStyle),
|
|
586
|
+
children: (_item$sectionLabel = item.sectionLabel) !== null && _item$sectionLabel !== void 0 ? _item$sectionLabel : ""
|
|
587
|
+
})
|
|
588
|
+
}), /* @__PURE__ */ jsxs(CompositeItem, {
|
|
589
|
+
id: domId(item.id),
|
|
590
|
+
render: /* @__PURE__ */ jsx(Link, {
|
|
591
|
+
href: item.href,
|
|
592
|
+
className: cn("group relative block rounded-md px-2 py-1.5 text-[13px] leading-snug outline-none", "transition-all duration-150", !isSelected && ["text-text-secondary", "hover:bg-bg-subtle hover:text-text-primary"], isSelected && ["bg-bg-subtle text-text-primary font-medium"], "data-[active-item]:bg-accent-subtle data-[active-item]:text-accent", "data-[focus-visible]:ring-ring data-[focus-visible]:ring-2", "data-[focus-visible]:ring-offset-ring-offset data-[focus-visible]:ring-offset-2", isSelected && ["data-[active-item]:bg-accent-subtle data-[active-item]:text-accent"])
|
|
593
|
+
}),
|
|
594
|
+
children: [/* @__PURE__ */ jsx("span", { className: cn("absolute top-1/2 left-0 h-4 w-0.5 -translate-y-1/2 rounded-full transition-all duration-150", isSelected && "bg-accent", !isSelected && "group-data-[active-item]:bg-accent bg-transparent", "group-data-[focus-visible]:bg-accent") }), /* @__PURE__ */ jsx("span", {
|
|
595
|
+
className: "pl-2",
|
|
596
|
+
children: item.label
|
|
597
|
+
})]
|
|
598
|
+
})] }, item.id);
|
|
599
|
+
})
|
|
600
|
+
})
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
//#endregion
|
|
604
|
+
//#region src/shells/editor-toolbar.tsx
|
|
605
|
+
const defaultLabels$13 = { ariaLabel: "텍스트 편집기 툴바" };
|
|
606
|
+
function ToolbarButtonWithTooltip({ button, active, onAction }) {
|
|
607
|
+
return /* @__PURE__ */ jsxs(TooltipProvider$1, { children: [/* @__PURE__ */ jsx(TooltipAnchor$1, { children: /* @__PURE__ */ jsx(ToolbarButton$1, {
|
|
608
|
+
className: `text-text-primary data-[active-item]:bg-bg-subtle data-[focus-visible]:ring-ring rounded-md p-2 transition-colors outline-none data-[focus-visible]:ring-2 ${active ? "bg-bg-muted" : "hover:bg-bg-subtle"}`,
|
|
609
|
+
onClick: () => onAction === null || onAction === void 0 ? void 0 : onAction(button.id),
|
|
610
|
+
children: button.icon
|
|
611
|
+
}) }), /* @__PURE__ */ jsx(Tooltip$1, { children: button.label })] });
|
|
612
|
+
}
|
|
613
|
+
/** Renders the editor toolbar component. */
|
|
614
|
+
function EditorToolbar({ buttons, onAction, activeButtons = [], labels: customLabels }) {
|
|
615
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$13), customLabels);
|
|
616
|
+
const groups = [];
|
|
617
|
+
let current = [];
|
|
618
|
+
for (const btn of buttons) {
|
|
619
|
+
if (btn.separator) {
|
|
620
|
+
groups.push(current);
|
|
621
|
+
current = [];
|
|
622
|
+
}
|
|
623
|
+
current.push(btn);
|
|
624
|
+
}
|
|
625
|
+
if (current.length) groups.push(current);
|
|
626
|
+
return /* @__PURE__ */ jsx(ToolbarRoot$1, {
|
|
627
|
+
"data-opt-id": "Z73K6",
|
|
628
|
+
"data-opt-slug": "editor-toolbar.EditorToolbar",
|
|
629
|
+
children: /* @__PURE__ */ jsx(ToolbarContainer$1, {
|
|
630
|
+
"aria-label": labels.ariaLabel,
|
|
631
|
+
children: groups.map((group, gi) => /* @__PURE__ */ jsxs("span", {
|
|
632
|
+
className: "contents",
|
|
633
|
+
children: [gi > 0 && /* @__PURE__ */ jsx(ToolbarSeparator$1, {}), group.map((item) => {
|
|
634
|
+
if (item === "separator") return null;
|
|
635
|
+
const btn = item;
|
|
636
|
+
return /* @__PURE__ */ jsx(ToolbarButtonWithTooltip, {
|
|
637
|
+
button: btn,
|
|
638
|
+
active: activeButtons.includes(btn.id),
|
|
639
|
+
onAction
|
|
640
|
+
}, btn.id);
|
|
641
|
+
})]
|
|
642
|
+
}, gi))
|
|
643
|
+
})
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region src/shells/content-tabs.tsx
|
|
648
|
+
const defaultLabels$12 = {
|
|
649
|
+
ariaLabel: "콘텐츠 탭",
|
|
650
|
+
emptyMessage: "표시할 탭이 없습니다."
|
|
651
|
+
};
|
|
652
|
+
/** Renders the content tabs component. */
|
|
653
|
+
function ContentTabs({ tabs, defaultTabId, labels: customLabels }) {
|
|
654
|
+
var _tabs$, _tabs$find;
|
|
655
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$12), customLabels);
|
|
656
|
+
const [selectedTabId, setSelectedTabId] = useState(defaultTabId !== null && defaultTabId !== void 0 ? defaultTabId : (_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : _tabs$.id);
|
|
657
|
+
if (tabs.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
658
|
+
className: "text-text-secondary text-sm",
|
|
659
|
+
"data-opt-id": "9W97K",
|
|
660
|
+
"data-opt-slug": "content-tabs.ContentTabs",
|
|
661
|
+
children: labels.emptyMessage
|
|
662
|
+
});
|
|
663
|
+
const handleSelectedTabId = (nextId) => {
|
|
664
|
+
var _tabs$2;
|
|
665
|
+
setSelectedTabId(nextId !== null && nextId !== void 0 ? nextId : (_tabs$2 = tabs[0]) === null || _tabs$2 === void 0 ? void 0 : _tabs$2.id);
|
|
666
|
+
};
|
|
667
|
+
const activeTab = (_tabs$find = tabs.find((tab) => tab.id === selectedTabId)) !== null && _tabs$find !== void 0 ? _tabs$find : tabs[0];
|
|
668
|
+
return /* @__PURE__ */ jsxs(TabsRoot$1, {
|
|
669
|
+
selectedId: selectedTabId,
|
|
670
|
+
onSelectedIdChange: handleSelectedTabId,
|
|
671
|
+
"data-opt-id": "9W97K",
|
|
672
|
+
"data-opt-slug": "content-tabs.ContentTabs",
|
|
673
|
+
children: [/* @__PURE__ */ jsx(TabList$1, {
|
|
674
|
+
"aria-label": labels.ariaLabel,
|
|
675
|
+
children: tabs.map((tab) => /* @__PURE__ */ jsx(Tab$1, {
|
|
676
|
+
id: tab.id,
|
|
677
|
+
children: tab.label
|
|
678
|
+
}, tab.id))
|
|
679
|
+
}), activeTab && /* @__PURE__ */ jsx(TabPanel$1, {
|
|
680
|
+
tabId: activeTab.id,
|
|
681
|
+
children: activeTab.content
|
|
682
|
+
})]
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
//#endregion
|
|
686
|
+
//#region src/shells/faq-accordion.tsx
|
|
687
|
+
const defaultLabels$11 = {
|
|
688
|
+
ariaLabel: "자주 묻는 질문",
|
|
689
|
+
emptyMessage: "등록된 FAQ가 없습니다."
|
|
690
|
+
};
|
|
691
|
+
/** Renders the faq accordion component. */
|
|
692
|
+
function FaqAccordion({ items, labels: customLabels }) {
|
|
693
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$11), customLabels);
|
|
694
|
+
if (items.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
695
|
+
className: "text-text-secondary text-sm",
|
|
696
|
+
"data-opt-id": "QRBHV",
|
|
697
|
+
"data-opt-slug": "faq-accordion.FaqAccordion",
|
|
698
|
+
children: labels.emptyMessage
|
|
699
|
+
});
|
|
700
|
+
return /* @__PURE__ */ jsx(CompositeProvider, {
|
|
701
|
+
focusLoop: true,
|
|
702
|
+
orientation: "vertical",
|
|
703
|
+
"data-opt-id": "QRBHV",
|
|
704
|
+
"data-opt-slug": "faq-accordion.FaqAccordion",
|
|
705
|
+
children: /* @__PURE__ */ jsx(Composite, {
|
|
706
|
+
role: "region",
|
|
707
|
+
"aria-label": labels.ariaLabel,
|
|
708
|
+
className: "divide-border-subtle border-border divide-y rounded-lg border",
|
|
709
|
+
children: items.map((faq) => /* @__PURE__ */ jsx(DisclosureRoot$1, { children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs(CompositeItem, {
|
|
710
|
+
render: /* @__PURE__ */ jsx(DisclosureTrigger$1, {}),
|
|
711
|
+
children: [faq.question, /* @__PURE__ */ jsx("svg", {
|
|
712
|
+
className: "text-text-tertiary h-4 w-4 shrink-0 transition-transform [[data-open]>&]:rotate-180",
|
|
713
|
+
fill: "none",
|
|
714
|
+
viewBox: "0 0 24 24",
|
|
715
|
+
stroke: "currentColor",
|
|
716
|
+
strokeWidth: 2,
|
|
717
|
+
"aria-hidden": "true",
|
|
718
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
719
|
+
strokeLinecap: "round",
|
|
720
|
+
strokeLinejoin: "round",
|
|
721
|
+
d: "m19.5 8.25-7.5 7.5-7.5-7.5"
|
|
722
|
+
})
|
|
723
|
+
})]
|
|
724
|
+
}), /* @__PURE__ */ jsx(DisclosureContent$1, { children: /* @__PURE__ */ jsx("p", {
|
|
725
|
+
className: "text-text-secondary px-4 pt-2 pb-4 text-sm",
|
|
726
|
+
children: faq.answer
|
|
727
|
+
}) })] }) }, faq.id))
|
|
728
|
+
})
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
//#endregion
|
|
732
|
+
//#region src/shells/settings-form.tsx
|
|
733
|
+
const defaultLabels$10 = {
|
|
734
|
+
formAriaLabel: "설정 폼",
|
|
735
|
+
submitButton: "저장",
|
|
736
|
+
successMessage: "설정이 저장되었습니다."
|
|
737
|
+
};
|
|
738
|
+
/** Renders the settings form component. */
|
|
739
|
+
function SettingsForm({ fields, onSubmit, labels: customLabels }) {
|
|
740
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$10), customLabels);
|
|
741
|
+
const [submitted, setSubmitted] = useState(false);
|
|
742
|
+
const defaultValues = {};
|
|
743
|
+
for (const field of fields) {
|
|
744
|
+
var _field$defaultValue;
|
|
745
|
+
defaultValues[field.name] = (_field$defaultValue = field.defaultValue) !== null && _field$defaultValue !== void 0 ? _field$defaultValue : field.type === "switch" || field.type === "checkbox" ? false : field.type === "tags" ? [] : "";
|
|
746
|
+
}
|
|
747
|
+
const form = useFormStore({
|
|
748
|
+
defaultValues,
|
|
749
|
+
validate: (values) => {
|
|
750
|
+
const errors = {};
|
|
751
|
+
for (const field of fields) {
|
|
752
|
+
if (field.required) {
|
|
753
|
+
const value = values[field.name];
|
|
754
|
+
if (!value || typeof value === "string" && !value.trim()) {
|
|
755
|
+
var _field$requiredMessag;
|
|
756
|
+
errors[field.name] = (_field$requiredMessag = field.requiredMessage) !== null && _field$requiredMessag !== void 0 ? _field$requiredMessag : `${field.label}을(를) 입력해주세요.`;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
if (field.validate) {
|
|
760
|
+
const value = values[field.name];
|
|
761
|
+
const error = field.validate(value);
|
|
762
|
+
if (error) errors[field.name] = error;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return errors;
|
|
766
|
+
},
|
|
767
|
+
onSubmit: (values) => {
|
|
768
|
+
setSubmitted(true);
|
|
769
|
+
onSubmit === null || onSubmit === void 0 || onSubmit(values);
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
if (fields.length === 0) return /* @__PURE__ */ jsx(EmptyState, {
|
|
773
|
+
title: "설정 항목이 없습니다.",
|
|
774
|
+
description: "표시할 설정 필드를 추가하면 이 폼이 렌더링됩니다.",
|
|
775
|
+
"data-opt-id": "9TEEJ",
|
|
776
|
+
"data-opt-slug": "settings-form.SettingsForm"
|
|
777
|
+
});
|
|
778
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
779
|
+
className: "gap-group flex flex-col",
|
|
780
|
+
"data-opt-id": "9TEEJ",
|
|
781
|
+
"data-opt-slug": "settings-form.SettingsForm",
|
|
782
|
+
children: [/* @__PURE__ */ jsxs(FormRoot$1, {
|
|
783
|
+
store: form,
|
|
784
|
+
"aria-label": labels.formAriaLabel,
|
|
785
|
+
children: [fields.map((field) => {
|
|
786
|
+
var _field$type;
|
|
787
|
+
if (field.visible !== void 0) {
|
|
788
|
+
const currentValues = form.getValues();
|
|
789
|
+
if (!(typeof field.visible === "function" ? field.visible(currentValues) : field.visible)) return null;
|
|
790
|
+
}
|
|
791
|
+
if (field.type === "tags") {
|
|
792
|
+
const rawValue = form.getValue(field.name);
|
|
793
|
+
const tags = Array.isArray(rawValue) ? rawValue : [];
|
|
794
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
795
|
+
className: "gap-element flex flex-col",
|
|
796
|
+
children: [
|
|
797
|
+
/* @__PURE__ */ jsx(FormLabel$1, {
|
|
798
|
+
name: field.name,
|
|
799
|
+
children: field.label
|
|
800
|
+
}),
|
|
801
|
+
/* @__PURE__ */ jsx(TagInput, {
|
|
802
|
+
value: tags,
|
|
803
|
+
onChange: (next) => form.setValue(field.name, next),
|
|
804
|
+
placeholder: field.placeholder
|
|
805
|
+
}),
|
|
806
|
+
/* @__PURE__ */ jsx(FormError$1, { name: field.name })
|
|
807
|
+
]
|
|
808
|
+
}, field.name);
|
|
809
|
+
}
|
|
810
|
+
if (field.type === "radio") {
|
|
811
|
+
var _field$options;
|
|
812
|
+
return /* @__PURE__ */ jsxs("fieldset", {
|
|
813
|
+
className: "gap-element flex flex-col",
|
|
814
|
+
children: [
|
|
815
|
+
/* @__PURE__ */ jsx("legend", {
|
|
816
|
+
className: "text-text-primary text-sm font-medium",
|
|
817
|
+
children: field.label
|
|
818
|
+
}),
|
|
819
|
+
/* @__PURE__ */ jsx(FormRadioGroup$1, { children: /* @__PURE__ */ jsx("div", {
|
|
820
|
+
className: "gap-group flex",
|
|
821
|
+
children: (_field$options = field.options) === null || _field$options === void 0 ? void 0 : _field$options.map((option) => /* @__PURE__ */ jsxs("label", {
|
|
822
|
+
className: "text-text-primary gap-element flex items-center text-sm",
|
|
823
|
+
children: [/* @__PURE__ */ jsx(FormRadio$1, {
|
|
824
|
+
name: field.name,
|
|
825
|
+
value: option.value
|
|
826
|
+
}), option.label]
|
|
827
|
+
}, option.value))
|
|
828
|
+
}) }),
|
|
829
|
+
/* @__PURE__ */ jsx(FormError$1, { name: field.name })
|
|
830
|
+
]
|
|
831
|
+
}, field.name);
|
|
832
|
+
}
|
|
833
|
+
if (field.type === "checkbox") return /* @__PURE__ */ jsxs("div", {
|
|
834
|
+
className: "gap-element flex flex-col",
|
|
835
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
836
|
+
className: "text-text-primary gap-element flex items-center text-sm",
|
|
837
|
+
children: [/* @__PURE__ */ jsx(FormCheckbox$1, { name: field.name }), /* @__PURE__ */ jsx("span", { children: field.label })]
|
|
838
|
+
}), /* @__PURE__ */ jsx(FormError$1, { name: field.name })]
|
|
839
|
+
}, field.name);
|
|
840
|
+
if (field.type === "textarea") {
|
|
841
|
+
var _field$rows, _field$resize;
|
|
842
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
843
|
+
className: "gap-element flex flex-col",
|
|
844
|
+
children: [
|
|
845
|
+
/* @__PURE__ */ jsx(FormLabel$1, {
|
|
846
|
+
name: field.name,
|
|
847
|
+
children: field.label
|
|
848
|
+
}),
|
|
849
|
+
/* @__PURE__ */ jsx(FormTextarea, {
|
|
850
|
+
name: field.name,
|
|
851
|
+
placeholder: field.placeholder,
|
|
852
|
+
rows: (_field$rows = field.rows) !== null && _field$rows !== void 0 ? _field$rows : 4,
|
|
853
|
+
resize: (_field$resize = field.resize) !== null && _field$resize !== void 0 ? _field$resize : "vertical",
|
|
854
|
+
className: field.font === "mono" ? "font-mono text-sm" : void 0
|
|
855
|
+
}),
|
|
856
|
+
/* @__PURE__ */ jsx(FormError$1, { name: field.name })
|
|
857
|
+
]
|
|
858
|
+
}, field.name);
|
|
859
|
+
}
|
|
860
|
+
if (field.type === "select") {
|
|
861
|
+
var _field$options2;
|
|
862
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
863
|
+
className: "gap-element flex flex-col",
|
|
864
|
+
children: [
|
|
865
|
+
/* @__PURE__ */ jsx(FormLabel$1, {
|
|
866
|
+
name: field.name,
|
|
867
|
+
children: field.label
|
|
868
|
+
}),
|
|
869
|
+
/* @__PURE__ */ jsx(FormSelect, {
|
|
870
|
+
name: field.name,
|
|
871
|
+
placeholder: field.placeholder,
|
|
872
|
+
children: /* @__PURE__ */ jsx(FormSelectPopover, { children: (_field$options2 = field.options) === null || _field$options2 === void 0 ? void 0 : _field$options2.map((option) => /* @__PURE__ */ jsx(FormSelectItem, {
|
|
873
|
+
value: option.value,
|
|
874
|
+
children: option.label
|
|
875
|
+
}, option.value)) })
|
|
876
|
+
}),
|
|
877
|
+
/* @__PURE__ */ jsx(FormError$1, { name: field.name })
|
|
878
|
+
]
|
|
879
|
+
}, field.name);
|
|
880
|
+
}
|
|
881
|
+
if (field.type === "switch") return /* @__PURE__ */ jsxs("label", {
|
|
882
|
+
className: "gap-group flex items-center",
|
|
883
|
+
children: [/* @__PURE__ */ jsx(FormSwitch$1, { name: field.name }), /* @__PURE__ */ jsxs("div", {
|
|
884
|
+
className: "flex flex-col",
|
|
885
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
886
|
+
className: "text-text-primary text-sm font-medium",
|
|
887
|
+
children: field.label
|
|
888
|
+
}), field.description && /* @__PURE__ */ jsx("span", {
|
|
889
|
+
className: "text-text-secondary text-sm",
|
|
890
|
+
children: field.description
|
|
891
|
+
})]
|
|
892
|
+
})]
|
|
893
|
+
}, field.name);
|
|
894
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
895
|
+
className: "gap-element flex flex-col",
|
|
896
|
+
children: [
|
|
897
|
+
/* @__PURE__ */ jsx(FormLabel$1, {
|
|
898
|
+
name: field.name,
|
|
899
|
+
children: field.label
|
|
900
|
+
}),
|
|
901
|
+
/* @__PURE__ */ jsx(FormInput$1, {
|
|
902
|
+
name: field.name,
|
|
903
|
+
type: (_field$type = field.type) !== null && _field$type !== void 0 ? _field$type : "text",
|
|
904
|
+
placeholder: field.placeholder
|
|
905
|
+
}),
|
|
906
|
+
/* @__PURE__ */ jsx(FormError$1, { name: field.name })
|
|
907
|
+
]
|
|
908
|
+
}, field.name);
|
|
909
|
+
}), /* @__PURE__ */ jsx(FormSubmit$1, { children: labels.submitButton })]
|
|
910
|
+
}), submitted && /* @__PURE__ */ jsx("div", {
|
|
911
|
+
className: "border-success bg-success-subtle text-success-fg rounded-lg border p-3 text-sm",
|
|
912
|
+
children: labels.successMessage
|
|
913
|
+
})]
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
//#endregion
|
|
917
|
+
//#region src/shells/deployment-timeline.tsx
|
|
918
|
+
const statusIcon = {
|
|
919
|
+
success: "●",
|
|
920
|
+
pending: "◌",
|
|
921
|
+
running: "⟳",
|
|
922
|
+
error: "✗",
|
|
923
|
+
skipped: "○"
|
|
924
|
+
};
|
|
925
|
+
const statusColor = {
|
|
926
|
+
success: "text-success-fg",
|
|
927
|
+
pending: OPT_TEXT_TERTIARY,
|
|
928
|
+
running: "text-accent",
|
|
929
|
+
error: "text-danger-fg",
|
|
930
|
+
skipped: "text-text-tertiary"
|
|
931
|
+
};
|
|
932
|
+
const statusBadge$1 = {
|
|
933
|
+
success: OPT_BADGE_GREEN,
|
|
934
|
+
pending: OPT_BADGE_NEUTRAL,
|
|
935
|
+
running: "inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium bg-info-subtle text-info-fg",
|
|
936
|
+
error: OPT_BADGE_RED,
|
|
937
|
+
skipped: OPT_BADGE_NEUTRAL
|
|
938
|
+
};
|
|
939
|
+
const statusLabel$1 = {
|
|
940
|
+
success: "성공",
|
|
941
|
+
pending: "대기",
|
|
942
|
+
running: "실행 중",
|
|
943
|
+
error: "에러",
|
|
944
|
+
skipped: "건너뜀"
|
|
945
|
+
};
|
|
946
|
+
/** Renders the deployment timeline component. */
|
|
947
|
+
function DeploymentTimeline({ steps, title = "배포 타임라인" }) {
|
|
948
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
949
|
+
className: "gap-group flex flex-col",
|
|
950
|
+
"data-opt-id": "XXVQ2",
|
|
951
|
+
"data-opt-slug": "deployment-timeline.DeploymentTimeline",
|
|
952
|
+
children: [title && /* @__PURE__ */ jsx("h3", {
|
|
953
|
+
className: `text-sm font-semibold text-text-primary`,
|
|
954
|
+
children: title
|
|
955
|
+
}), /* @__PURE__ */ jsx(CompositeProvider, {
|
|
956
|
+
focusLoop: true,
|
|
957
|
+
orientation: "vertical",
|
|
958
|
+
children: /* @__PURE__ */ jsx(Composite, {
|
|
959
|
+
role: "list",
|
|
960
|
+
"aria-label": title,
|
|
961
|
+
className: "relative",
|
|
962
|
+
children: steps.map((step, i) => {
|
|
963
|
+
const isLast = i === steps.length - 1;
|
|
964
|
+
return /* @__PURE__ */ jsxs(CompositeItem, {
|
|
965
|
+
className: `group gap-group relative flex w-full scroll-m-2 rounded-lg px-3 py-2 ${OPT_FOCUS} data-[active-item]:bg-accent-subtle`,
|
|
966
|
+
role: "listitem",
|
|
967
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
968
|
+
className: "flex flex-col items-center",
|
|
969
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
970
|
+
className: `text-lg leading-none ${statusColor[step.status]}`,
|
|
971
|
+
"aria-label": statusLabel$1[step.status],
|
|
972
|
+
children: statusIcon[step.status]
|
|
973
|
+
}), !isLast && /* @__PURE__ */ jsx("div", { className: "bg-border-subtle mt-1 w-px flex-1" })]
|
|
974
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
975
|
+
className: "flex-1 pb-3",
|
|
976
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
977
|
+
className: "gap-element flex items-center",
|
|
978
|
+
children: [
|
|
979
|
+
/* @__PURE__ */ jsx("span", {
|
|
980
|
+
className: `text-sm font-medium ${OPT_TEXT_PRIMARY}`,
|
|
981
|
+
children: step.name
|
|
982
|
+
}),
|
|
983
|
+
/* @__PURE__ */ jsx("span", {
|
|
984
|
+
className: statusBadge$1[step.status],
|
|
985
|
+
children: statusLabel$1[step.status]
|
|
986
|
+
}),
|
|
987
|
+
step.duration && /* @__PURE__ */ jsx("span", {
|
|
988
|
+
className: `text-xs text-text-tertiary`,
|
|
989
|
+
children: step.duration
|
|
990
|
+
})
|
|
991
|
+
]
|
|
992
|
+
}), step.detail && /* @__PURE__ */ jsx("p", {
|
|
993
|
+
className: `mt-0.5 text-xs text-text-secondary`,
|
|
994
|
+
children: step.detail
|
|
995
|
+
})]
|
|
996
|
+
})]
|
|
997
|
+
}, step.id);
|
|
998
|
+
})
|
|
999
|
+
})
|
|
1000
|
+
})]
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
//#endregion
|
|
1004
|
+
//#region src/shells/project-switcher.tsx
|
|
1005
|
+
const statusDot = {
|
|
1006
|
+
active: OPT_DOT_GREEN,
|
|
1007
|
+
paused: OPT_DOT_YELLOW,
|
|
1008
|
+
error: OPT_DOT_RED
|
|
1009
|
+
};
|
|
1010
|
+
/** Renders the project switcher component. */
|
|
1011
|
+
function ProjectSwitcher({ projects, value, onChange, placeholder = "프로젝트 검색..." }) {
|
|
1012
|
+
const [search, setSearch] = useState("");
|
|
1013
|
+
const matches = useMemo(() => {
|
|
1014
|
+
if (!search) return projects;
|
|
1015
|
+
return matchSorter(projects, search, { keys: ["name", "framework"] });
|
|
1016
|
+
}, [search, projects]);
|
|
1017
|
+
const selected = projects.find((p) => p.id === value);
|
|
1018
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1019
|
+
className: "gap-element flex flex-col",
|
|
1020
|
+
"data-opt-id": "5R3AG",
|
|
1021
|
+
"data-opt-slug": "project-switcher.ProjectSwitcher",
|
|
1022
|
+
children: /* @__PURE__ */ jsxs(ComboboxRoot$1, {
|
|
1023
|
+
onValueChange: setSearch,
|
|
1024
|
+
children: [
|
|
1025
|
+
/* @__PURE__ */ jsx("label", {
|
|
1026
|
+
className: OPT_TEXT_LABEL,
|
|
1027
|
+
children: "프로젝트"
|
|
1028
|
+
}),
|
|
1029
|
+
/* @__PURE__ */ jsx(ComboboxInput$1, {
|
|
1030
|
+
placeholder: selected ? selected.name : placeholder,
|
|
1031
|
+
className: OPT_INPUT
|
|
1032
|
+
}),
|
|
1033
|
+
/* @__PURE__ */ jsxs(ComboboxPopover$1, {
|
|
1034
|
+
className: "max-h-72 overflow-y-auto",
|
|
1035
|
+
children: [matches.length === 0 && /* @__PURE__ */ jsx("p", {
|
|
1036
|
+
className: `py-6 text-center text-sm text-text-secondary`,
|
|
1037
|
+
children: "결과가 없습니다."
|
|
1038
|
+
}), matches.map((project) => /* @__PURE__ */ jsxs(ComboboxItem$1, {
|
|
1039
|
+
value: project.name,
|
|
1040
|
+
onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(project.id),
|
|
1041
|
+
className: `gap-element flex scroll-m-2 items-center ${OPT_ITEM_BASE} ${OPT_ACTIVE_ITEM}`,
|
|
1042
|
+
children: [
|
|
1043
|
+
/* @__PURE__ */ jsx("span", { className: `shrink-0 ${statusDot[project.status]}` }),
|
|
1044
|
+
/* @__PURE__ */ jsx("span", {
|
|
1045
|
+
className: "flex-1 truncate font-medium",
|
|
1046
|
+
children: project.name
|
|
1047
|
+
}),
|
|
1048
|
+
/* @__PURE__ */ jsx("span", {
|
|
1049
|
+
className: OPT_BADGE_NEUTRAL,
|
|
1050
|
+
children: project.framework
|
|
1051
|
+
}),
|
|
1052
|
+
project.domain && /* @__PURE__ */ jsx("span", {
|
|
1053
|
+
className: `truncate text-xs text-text-secondary data-[active-item]:text-accent-fg/70`,
|
|
1054
|
+
children: project.domain
|
|
1055
|
+
})
|
|
1056
|
+
]
|
|
1057
|
+
}, project.id))]
|
|
1058
|
+
})
|
|
1059
|
+
]
|
|
1060
|
+
})
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
ProjectSwitcher.displayName = "ProjectSwitcher";
|
|
1064
|
+
//#endregion
|
|
1065
|
+
//#region src/shells/env-panel.tsx
|
|
1066
|
+
const defaultLabels$9 = {
|
|
1067
|
+
varCount: (count) => `${count}개 변수`,
|
|
1068
|
+
envVarsLabel: (env) => `${env} 환경 변수`,
|
|
1069
|
+
secretBadge: "secret"
|
|
1070
|
+
};
|
|
1071
|
+
const envDot = {
|
|
1072
|
+
Production: OPT_DOT_RED,
|
|
1073
|
+
Preview: OPT_DOT_YELLOW,
|
|
1074
|
+
Development: OPT_DOT_GREEN
|
|
1075
|
+
};
|
|
1076
|
+
/** Renders the env panel component. */
|
|
1077
|
+
function EnvPanel({ groups, labels: customLabels }) {
|
|
1078
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$9), customLabels);
|
|
1079
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1080
|
+
className: `rounded-lg ${OPT_BORDER} divide-y ${OPT_DIVIDER} bg-surface`,
|
|
1081
|
+
"data-opt-id": "ZBDWK",
|
|
1082
|
+
"data-opt-slug": "env-panel.EnvPanel",
|
|
1083
|
+
children: groups.map((group) => {
|
|
1084
|
+
var _envDot$group$env;
|
|
1085
|
+
return /* @__PURE__ */ jsx(DisclosureRoot$1, {
|
|
1086
|
+
defaultOpen: group.env === "Production",
|
|
1087
|
+
children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs(DisclosureTrigger$1, {
|
|
1088
|
+
className: OPT_DISCLOSURE_TRIGGER,
|
|
1089
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
1090
|
+
className: "gap-element flex items-center",
|
|
1091
|
+
children: [
|
|
1092
|
+
/* @__PURE__ */ jsx("span", { className: (_envDot$group$env = envDot[group.env]) !== null && _envDot$group$env !== void 0 ? _envDot$group$env : "bg-bg-muted h-2 w-2 rounded-full" }),
|
|
1093
|
+
/* @__PURE__ */ jsx("span", {
|
|
1094
|
+
className: "font-medium",
|
|
1095
|
+
children: group.env
|
|
1096
|
+
}),
|
|
1097
|
+
/* @__PURE__ */ jsx("span", {
|
|
1098
|
+
className: `text-xs ${OPT_TEXT_TERTIARY}`,
|
|
1099
|
+
children: labels.varCount(group.vars.length)
|
|
1100
|
+
})
|
|
1101
|
+
]
|
|
1102
|
+
}), /* @__PURE__ */ jsx("svg", {
|
|
1103
|
+
className: "text-text-tertiary h-4 w-4 shrink-0 transition-transform [[data-open]>&]:rotate-180",
|
|
1104
|
+
fill: "none",
|
|
1105
|
+
viewBox: "0 0 24 24",
|
|
1106
|
+
stroke: "currentColor",
|
|
1107
|
+
strokeWidth: 2,
|
|
1108
|
+
"aria-hidden": "true",
|
|
1109
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
1110
|
+
strokeLinecap: "round",
|
|
1111
|
+
strokeLinejoin: "round",
|
|
1112
|
+
d: "m19.5 8.25-7.5 7.5-7.5-7.5"
|
|
1113
|
+
})
|
|
1114
|
+
})]
|
|
1115
|
+
}), /* @__PURE__ */ jsx(DisclosureContent$1, {
|
|
1116
|
+
className: OPT_DISCLOSURE_CONTENT,
|
|
1117
|
+
children: /* @__PURE__ */ jsx(CompositeProvider, {
|
|
1118
|
+
focusLoop: true,
|
|
1119
|
+
orientation: "vertical",
|
|
1120
|
+
children: /* @__PURE__ */ jsx(Composite, {
|
|
1121
|
+
role: "list",
|
|
1122
|
+
"aria-label": labels.envVarsLabel(group.env),
|
|
1123
|
+
className: "px-4 pb-3",
|
|
1124
|
+
children: group.vars.map((v) => /* @__PURE__ */ jsxs(CompositeItem, {
|
|
1125
|
+
role: "listitem",
|
|
1126
|
+
className: `gap-group flex scroll-m-2 items-center rounded px-2 py-1.5 text-sm ${OPT_FOCUS} data-[active-item]:bg-accent-subtle`,
|
|
1127
|
+
children: [
|
|
1128
|
+
/* @__PURE__ */ jsx("span", {
|
|
1129
|
+
className: `w-44 shrink-0 truncate font-mono text-xs font-medium ${OPT_TEXT_PRIMARY}`,
|
|
1130
|
+
children: v.key
|
|
1131
|
+
}),
|
|
1132
|
+
/* @__PURE__ */ jsx("span", {
|
|
1133
|
+
className: `flex-1 truncate font-mono text-xs ${OPT_TEXT_SECONDARY}`,
|
|
1134
|
+
children: v.isSecret ? "••••••••" : v.value
|
|
1135
|
+
}),
|
|
1136
|
+
v.isSecret && /* @__PURE__ */ jsx("span", {
|
|
1137
|
+
className: OPT_BADGE_NEUTRAL,
|
|
1138
|
+
children: labels.secretBadge
|
|
1139
|
+
})
|
|
1140
|
+
]
|
|
1141
|
+
}, v.key))
|
|
1142
|
+
})
|
|
1143
|
+
})
|
|
1144
|
+
})] })
|
|
1145
|
+
}, group.env);
|
|
1146
|
+
})
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
//#endregion
|
|
1150
|
+
//#region src/shells/branch-select.tsx
|
|
1151
|
+
const defaultLabels$8 = {
|
|
1152
|
+
selectLabel: "브랜치",
|
|
1153
|
+
emptySelectionLabel: "선택...",
|
|
1154
|
+
emptyMessage: "사용 가능한 브랜치가 없습니다.",
|
|
1155
|
+
defaultBadge: "default"
|
|
1156
|
+
};
|
|
1157
|
+
/** Renders the branch select component. */
|
|
1158
|
+
function BranchSelect({ branches, value: controlledValue, onChange, label, labels: customLabels }) {
|
|
1159
|
+
var _ref, _defaultBranch$name, _branches$, _selected$name;
|
|
1160
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$8), customLabels);
|
|
1161
|
+
const resolvedLabel = label !== null && label !== void 0 ? label : labels.selectLabel;
|
|
1162
|
+
const defaultBranch = branches.find((b) => b.isDefault);
|
|
1163
|
+
const [internalValue, setInternalValue] = useState((_ref = (_defaultBranch$name = defaultBranch === null || defaultBranch === void 0 ? void 0 : defaultBranch.name) !== null && _defaultBranch$name !== void 0 ? _defaultBranch$name : (_branches$ = branches[0]) === null || _branches$ === void 0 ? void 0 : _branches$.name) !== null && _ref !== void 0 ? _ref : "");
|
|
1164
|
+
const value = controlledValue !== null && controlledValue !== void 0 ? controlledValue : internalValue;
|
|
1165
|
+
const selected = branches.find((b) => b.name === value);
|
|
1166
|
+
if (branches.length === 0) return /* @__PURE__ */ jsxs("div", {
|
|
1167
|
+
className: "gap-element flex flex-col",
|
|
1168
|
+
"data-opt-id": "7EDEP",
|
|
1169
|
+
"data-opt-slug": "branch-select.BranchSelect",
|
|
1170
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1171
|
+
className: OPT_TEXT_LABEL,
|
|
1172
|
+
children: resolvedLabel
|
|
1173
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1174
|
+
className: OPT_TEXT_TERTIARY,
|
|
1175
|
+
children: labels.emptyMessage
|
|
1176
|
+
})]
|
|
1177
|
+
});
|
|
1178
|
+
const handleChange = (v) => {
|
|
1179
|
+
var _v$;
|
|
1180
|
+
const next = Array.isArray(v) ? (_v$ = v[0]) !== null && _v$ !== void 0 ? _v$ : "" : v;
|
|
1181
|
+
if (onChange) onChange(next);
|
|
1182
|
+
else setInternalValue(next);
|
|
1183
|
+
};
|
|
1184
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1185
|
+
className: "gap-element flex flex-col",
|
|
1186
|
+
"data-opt-id": "7EDEP",
|
|
1187
|
+
"data-opt-slug": "branch-select.BranchSelect",
|
|
1188
|
+
children: /* @__PURE__ */ jsxs(SelectRoot$1, {
|
|
1189
|
+
value,
|
|
1190
|
+
onValueChange: handleChange,
|
|
1191
|
+
children: [
|
|
1192
|
+
/* @__PURE__ */ jsx(SelectLabel$1, {
|
|
1193
|
+
className: OPT_TEXT_LABEL,
|
|
1194
|
+
children: resolvedLabel
|
|
1195
|
+
}),
|
|
1196
|
+
/* @__PURE__ */ jsxs(SelectTrigger$1, {
|
|
1197
|
+
className: `${OPT_INPUT} max-w-xs items-center justify-between gap-1`,
|
|
1198
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
1199
|
+
className: "gap-element flex items-center truncate",
|
|
1200
|
+
children: [
|
|
1201
|
+
/* @__PURE__ */ jsx("svg", {
|
|
1202
|
+
className: "text-text-tertiary h-4 w-4 shrink-0",
|
|
1203
|
+
fill: "none",
|
|
1204
|
+
viewBox: "0 0 24 24",
|
|
1205
|
+
stroke: "currentColor",
|
|
1206
|
+
strokeWidth: 2,
|
|
1207
|
+
"aria-hidden": "true",
|
|
1208
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
1209
|
+
strokeLinecap: "round",
|
|
1210
|
+
strokeLinejoin: "round",
|
|
1211
|
+
d: "M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"
|
|
1212
|
+
})
|
|
1213
|
+
}),
|
|
1214
|
+
/* @__PURE__ */ jsx("span", {
|
|
1215
|
+
className: "truncate",
|
|
1216
|
+
children: (_selected$name = selected === null || selected === void 0 ? void 0 : selected.name) !== null && _selected$name !== void 0 ? _selected$name : labels.emptySelectionLabel
|
|
1217
|
+
}),
|
|
1218
|
+
(selected === null || selected === void 0 ? void 0 : selected.isDefault) && /* @__PURE__ */ jsx("span", {
|
|
1219
|
+
className: OPT_BADGE_BLUE,
|
|
1220
|
+
children: labels.defaultBadge
|
|
1221
|
+
})
|
|
1222
|
+
]
|
|
1223
|
+
}), /* @__PURE__ */ jsx("svg", {
|
|
1224
|
+
className: "text-text-tertiary h-4 w-4 shrink-0",
|
|
1225
|
+
fill: "none",
|
|
1226
|
+
viewBox: "0 0 24 24",
|
|
1227
|
+
stroke: "currentColor",
|
|
1228
|
+
strokeWidth: 2,
|
|
1229
|
+
"aria-hidden": "true",
|
|
1230
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
1231
|
+
strokeLinecap: "round",
|
|
1232
|
+
strokeLinejoin: "round",
|
|
1233
|
+
d: "m19.5 8.25-7.5 7.5-7.5-7.5"
|
|
1234
|
+
})
|
|
1235
|
+
})]
|
|
1236
|
+
}),
|
|
1237
|
+
/* @__PURE__ */ jsx(SelectPopover$1, {
|
|
1238
|
+
className: "max-w-xs",
|
|
1239
|
+
children: branches.map((branch) => /* @__PURE__ */ jsxs(SelectItem$1, {
|
|
1240
|
+
value: branch.name,
|
|
1241
|
+
className: `gap-element flex scroll-m-2 items-center ${OPT_ITEM_BASE} ${OPT_ACTIVE_ITEM}`,
|
|
1242
|
+
children: [
|
|
1243
|
+
/* @__PURE__ */ jsx("span", {
|
|
1244
|
+
className: "flex-1 truncate",
|
|
1245
|
+
children: branch.name
|
|
1246
|
+
}),
|
|
1247
|
+
branch.isDefault && /* @__PURE__ */ jsx("span", {
|
|
1248
|
+
className: "bg-accent-subtle text-accent data-[active-item]:bg-accent-fg/20 data-[active-item]:text-accent-fg rounded-full px-2 py-0.5 text-[11px] font-medium",
|
|
1249
|
+
children: labels.defaultBadge
|
|
1250
|
+
}),
|
|
1251
|
+
branch.lastCommit && /* @__PURE__ */ jsx("span", {
|
|
1252
|
+
className: `font-mono text-xs text-text-tertiary data-[active-item]:text-accent-fg/60`,
|
|
1253
|
+
children: branch.lastCommit
|
|
1254
|
+
}),
|
|
1255
|
+
branch.author && /* @__PURE__ */ jsx("span", {
|
|
1256
|
+
className: `text-xs text-text-tertiary data-[active-item]:text-accent-fg/60`,
|
|
1257
|
+
children: branch.author
|
|
1258
|
+
})
|
|
1259
|
+
]
|
|
1260
|
+
}, branch.name))
|
|
1261
|
+
})
|
|
1262
|
+
]
|
|
1263
|
+
})
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
BranchSelect.displayName = "BranchSelect";
|
|
1267
|
+
//#endregion
|
|
1268
|
+
//#region src/shells/domain-table.tsx
|
|
1269
|
+
const defaultLabels$7 = {
|
|
1270
|
+
domain: "Domain",
|
|
1271
|
+
status: "Status",
|
|
1272
|
+
ssl: "SSL",
|
|
1273
|
+
redirect: "Redirect",
|
|
1274
|
+
added: "Added",
|
|
1275
|
+
emptyMessage: "No domains configured"
|
|
1276
|
+
};
|
|
1277
|
+
const statusBadge = {
|
|
1278
|
+
active: OPT_BADGE_GREEN,
|
|
1279
|
+
pending: OPT_BADGE_YELLOW,
|
|
1280
|
+
error: OPT_BADGE_RED
|
|
1281
|
+
};
|
|
1282
|
+
const sslBadge = {
|
|
1283
|
+
valid: OPT_BADGE_GREEN,
|
|
1284
|
+
pending: OPT_BADGE_YELLOW,
|
|
1285
|
+
expired: OPT_BADGE_RED
|
|
1286
|
+
};
|
|
1287
|
+
const statusLabel = {
|
|
1288
|
+
active: "Active",
|
|
1289
|
+
pending: "Pending",
|
|
1290
|
+
error: "Error"
|
|
1291
|
+
};
|
|
1292
|
+
const sslLabel = {
|
|
1293
|
+
valid: "Valid",
|
|
1294
|
+
pending: "Pending",
|
|
1295
|
+
expired: "Expired"
|
|
1296
|
+
};
|
|
1297
|
+
/** Renders the domain table component. */
|
|
1298
|
+
function DomainTable({ domains, title = "도메인", labels: customLabels }) {
|
|
1299
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$7), customLabels);
|
|
1300
|
+
if (domains.length === 0) return /* @__PURE__ */ jsxs("div", {
|
|
1301
|
+
className: "gap-group flex flex-col",
|
|
1302
|
+
"data-opt-id": "A7SRM",
|
|
1303
|
+
"data-opt-slug": "domain-table.DomainTable",
|
|
1304
|
+
children: [title && /* @__PURE__ */ jsx("h3", {
|
|
1305
|
+
className: `text-sm font-semibold text-text-primary`,
|
|
1306
|
+
children: title
|
|
1307
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1308
|
+
className: `rounded-lg px-4 py-6 text-sm ${OPT_BORDER} ${OPT_TEXT_SECONDARY} bg-surface`,
|
|
1309
|
+
children: labels.emptyMessage
|
|
1310
|
+
})]
|
|
1311
|
+
});
|
|
1312
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1313
|
+
className: "gap-group flex flex-col",
|
|
1314
|
+
"data-opt-id": "A7SRM",
|
|
1315
|
+
"data-opt-slug": "domain-table.DomainTable",
|
|
1316
|
+
children: [title && /* @__PURE__ */ jsx("h3", {
|
|
1317
|
+
className: `text-sm font-semibold text-text-primary`,
|
|
1318
|
+
children: title
|
|
1319
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1320
|
+
className: `overflow-x-auto rounded-lg ${OPT_BORDER} bg-surface`,
|
|
1321
|
+
children: /* @__PURE__ */ jsx(CompositeProvider, {
|
|
1322
|
+
focusLoop: true,
|
|
1323
|
+
focusWrap: true,
|
|
1324
|
+
children: /* @__PURE__ */ jsxs(Composite, {
|
|
1325
|
+
role: "grid",
|
|
1326
|
+
"aria-label": title,
|
|
1327
|
+
className: "w-full",
|
|
1328
|
+
render: /* @__PURE__ */ jsx("table", {}),
|
|
1329
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
1330
|
+
className: "border-border-subtle bg-surface-inset border-b",
|
|
1331
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1332
|
+
/* @__PURE__ */ jsx("th", {
|
|
1333
|
+
className: OPT_TH,
|
|
1334
|
+
children: labels.domain
|
|
1335
|
+
}),
|
|
1336
|
+
/* @__PURE__ */ jsx("th", {
|
|
1337
|
+
className: OPT_TH,
|
|
1338
|
+
children: labels.status
|
|
1339
|
+
}),
|
|
1340
|
+
/* @__PURE__ */ jsx("th", {
|
|
1341
|
+
className: OPT_TH,
|
|
1342
|
+
children: labels.ssl
|
|
1343
|
+
}),
|
|
1344
|
+
/* @__PURE__ */ jsx("th", {
|
|
1345
|
+
className: OPT_TH,
|
|
1346
|
+
children: labels.redirect
|
|
1347
|
+
}),
|
|
1348
|
+
/* @__PURE__ */ jsx("th", {
|
|
1349
|
+
className: OPT_TH,
|
|
1350
|
+
children: labels.added
|
|
1351
|
+
})
|
|
1352
|
+
] })
|
|
1353
|
+
}), /* @__PURE__ */ jsx("tbody", {
|
|
1354
|
+
className: `divide-y ${OPT_DIVIDER}`,
|
|
1355
|
+
children: domains.map((d) => {
|
|
1356
|
+
var _d$redirect, _d$addedAt;
|
|
1357
|
+
return /* @__PURE__ */ jsxs(CompositeRow, {
|
|
1358
|
+
render: /* @__PURE__ */ jsx("tr", {}),
|
|
1359
|
+
children: [
|
|
1360
|
+
/* @__PURE__ */ jsx(CompositeItem, {
|
|
1361
|
+
render: /* @__PURE__ */ jsx("td", {
|
|
1362
|
+
className: `${OPT_TD} font-mono font-medium`,
|
|
1363
|
+
role: "gridcell"
|
|
1364
|
+
}),
|
|
1365
|
+
className: OPT_TABLE_ROW_ACTIVE,
|
|
1366
|
+
children: d.domain
|
|
1367
|
+
}),
|
|
1368
|
+
/* @__PURE__ */ jsx(CompositeItem, {
|
|
1369
|
+
render: /* @__PURE__ */ jsx("td", {
|
|
1370
|
+
className: OPT_TD,
|
|
1371
|
+
role: "gridcell"
|
|
1372
|
+
}),
|
|
1373
|
+
className: OPT_TABLE_ROW_ACTIVE,
|
|
1374
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1375
|
+
className: statusBadge[d.status],
|
|
1376
|
+
children: statusLabel[d.status]
|
|
1377
|
+
})
|
|
1378
|
+
}),
|
|
1379
|
+
/* @__PURE__ */ jsx(CompositeItem, {
|
|
1380
|
+
render: /* @__PURE__ */ jsx("td", {
|
|
1381
|
+
className: OPT_TD,
|
|
1382
|
+
role: "gridcell"
|
|
1383
|
+
}),
|
|
1384
|
+
className: OPT_TABLE_ROW_ACTIVE,
|
|
1385
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1386
|
+
className: sslBadge[d.ssl],
|
|
1387
|
+
children: sslLabel[d.ssl]
|
|
1388
|
+
})
|
|
1389
|
+
}),
|
|
1390
|
+
/* @__PURE__ */ jsx(CompositeItem, {
|
|
1391
|
+
render: /* @__PURE__ */ jsx("td", {
|
|
1392
|
+
className: OPT_TD,
|
|
1393
|
+
role: "gridcell"
|
|
1394
|
+
}),
|
|
1395
|
+
className: OPT_TABLE_ROW_ACTIVE,
|
|
1396
|
+
children: (_d$redirect = d.redirect) !== null && _d$redirect !== void 0 ? _d$redirect : "—"
|
|
1397
|
+
}),
|
|
1398
|
+
/* @__PURE__ */ jsx(CompositeItem, {
|
|
1399
|
+
render: /* @__PURE__ */ jsx("td", {
|
|
1400
|
+
className: OPT_TD_MUTED,
|
|
1401
|
+
role: "gridcell"
|
|
1402
|
+
}),
|
|
1403
|
+
className: OPT_TABLE_ROW_ACTIVE,
|
|
1404
|
+
children: (_d$addedAt = d.addedAt) !== null && _d$addedAt !== void 0 ? _d$addedAt : "—"
|
|
1405
|
+
})
|
|
1406
|
+
]
|
|
1407
|
+
}, d.domain);
|
|
1408
|
+
})
|
|
1409
|
+
})]
|
|
1410
|
+
})
|
|
1411
|
+
})
|
|
1412
|
+
})]
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
//#endregion
|
|
1416
|
+
//#region src/shells/data-table.tsx
|
|
1417
|
+
const MIN_COLUMN_WIDTH = 40;
|
|
1418
|
+
const DEFAULT_COLUMN_RESIZE_MAX = 1200;
|
|
1419
|
+
const alignmentClass = {
|
|
1420
|
+
left: "text-left",
|
|
1421
|
+
center: "text-center",
|
|
1422
|
+
right: "text-right"
|
|
1423
|
+
};
|
|
1424
|
+
function getCellValue(row, accessor) {
|
|
1425
|
+
if (typeof accessor === "function") try {
|
|
1426
|
+
return accessor(row);
|
|
1427
|
+
} catch (_unused) {
|
|
1428
|
+
return "—";
|
|
1429
|
+
}
|
|
1430
|
+
const value = row[accessor];
|
|
1431
|
+
if (value === null || value === void 0 || typeof value === "number" && !Number.isFinite(value)) return "—";
|
|
1432
|
+
return String(value);
|
|
1433
|
+
}
|
|
1434
|
+
function getRawValue(row, accessor) {
|
|
1435
|
+
if (typeof accessor === "function") return accessor(row);
|
|
1436
|
+
return row[accessor];
|
|
1437
|
+
}
|
|
1438
|
+
function isMissingSortValue(value) {
|
|
1439
|
+
return value == null || typeof value === "number" && !Number.isFinite(value);
|
|
1440
|
+
}
|
|
1441
|
+
function compareSortValues(aVal, bVal, dir) {
|
|
1442
|
+
const aMissing = isMissingSortValue(aVal);
|
|
1443
|
+
const bMissing = isMissingSortValue(bVal);
|
|
1444
|
+
if (aMissing && bMissing) return 0;
|
|
1445
|
+
if (aMissing) return 1;
|
|
1446
|
+
if (bMissing) return -1;
|
|
1447
|
+
const cmp = typeof aVal === "number" && typeof bVal === "number" ? aVal - bVal : String(aVal).localeCompare(String(bVal));
|
|
1448
|
+
return dir === "desc" ? -cmp : cmp;
|
|
1449
|
+
}
|
|
1450
|
+
function clampPercent(ratio) {
|
|
1451
|
+
if (!Number.isFinite(ratio)) return 0;
|
|
1452
|
+
return Math.min(100, Math.max(0, Math.round(ratio * 100)));
|
|
1453
|
+
}
|
|
1454
|
+
function getResizeHandleValue(currentWidth, configuredWidth) {
|
|
1455
|
+
if (typeof currentWidth === "number" && Number.isFinite(currentWidth)) return Math.max(MIN_COLUMN_WIDTH, Math.round(currentWidth));
|
|
1456
|
+
const pxWidth = configuredWidth === null || configuredWidth === void 0 ? void 0 : configuredWidth.trim().match(/^(\d+(?:\.\d+)?)px$/);
|
|
1457
|
+
if (pxWidth) return Math.max(MIN_COLUMN_WIDTH, Math.round(Number(pxWidth[1])));
|
|
1458
|
+
return MIN_COLUMN_WIDTH;
|
|
1459
|
+
}
|
|
1460
|
+
function DataTableProgressBar({ value, barColor, label }) {
|
|
1461
|
+
const percent = clampPercent(value);
|
|
1462
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1463
|
+
className: "bg-bg-subtle mt-1 h-1.5 w-full overflow-hidden rounded-full",
|
|
1464
|
+
role: "progressbar",
|
|
1465
|
+
"aria-valuenow": percent,
|
|
1466
|
+
"aria-valuemin": 0,
|
|
1467
|
+
"aria-valuemax": 100,
|
|
1468
|
+
"aria-valuetext": `${percent}%`,
|
|
1469
|
+
"aria-label": label,
|
|
1470
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1471
|
+
className: cn("h-full rounded-full transition-all", barColor),
|
|
1472
|
+
style: { width: `${percent}%` }
|
|
1473
|
+
})
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
/** Renders the data table component. */
|
|
1477
|
+
function DataTable({ data, columns, keyExtractor, title = "Data Table", onRowClick, emptyMessage = "No data available", activeRowId, sortable = false, selectable = false, selectedKeys, onSelectionChange, expandable = false, renderExpanded, pageSize, stickyHeader = false, resizableColumns = false, onSort: onSortExternal, className }) {
|
|
1478
|
+
const [sortCol, setSortCol] = useState(null);
|
|
1479
|
+
const [sortDir, setSortDir] = useState(null);
|
|
1480
|
+
const [expandedKeys, setExpandedKeys] = useState(/* @__PURE__ */ new Set());
|
|
1481
|
+
const [page, setPage] = useState(0);
|
|
1482
|
+
const [colWidths, setColWidths] = useState({});
|
|
1483
|
+
const sortedData = useMemo(() => {
|
|
1484
|
+
if (!sortable || !sortCol || !sortDir) return data;
|
|
1485
|
+
const col = columns.find((c) => c.id === sortCol);
|
|
1486
|
+
if (!col) return data;
|
|
1487
|
+
return [...data].sort((a, b) => {
|
|
1488
|
+
return compareSortValues(getRawValue(a, col.accessor), getRawValue(b, col.accessor), sortDir);
|
|
1489
|
+
});
|
|
1490
|
+
}, [
|
|
1491
|
+
data,
|
|
1492
|
+
sortable,
|
|
1493
|
+
sortCol,
|
|
1494
|
+
sortDir,
|
|
1495
|
+
columns
|
|
1496
|
+
]);
|
|
1497
|
+
const totalPages = pageSize ? Math.ceil(sortedData.length / pageSize) : 1;
|
|
1498
|
+
const pagedData = pageSize ? sortedData.slice(page * pageSize, (page + 1) * pageSize) : sortedData;
|
|
1499
|
+
const handleSort = useCallback((colId) => {
|
|
1500
|
+
if (!sortable) return;
|
|
1501
|
+
let nextDir;
|
|
1502
|
+
if (sortCol === colId) {
|
|
1503
|
+
nextDir = sortDir === "asc" ? "desc" : sortDir === "desc" ? null : "asc";
|
|
1504
|
+
setSortDir(nextDir);
|
|
1505
|
+
if (nextDir === null) setSortCol(null);
|
|
1506
|
+
} else {
|
|
1507
|
+
setSortCol(colId);
|
|
1508
|
+
setSortDir("asc");
|
|
1509
|
+
nextDir = "asc";
|
|
1510
|
+
}
|
|
1511
|
+
setPage(0);
|
|
1512
|
+
if (onSortExternal) onSortExternal(colId, nextDir);
|
|
1513
|
+
}, [
|
|
1514
|
+
sortable,
|
|
1515
|
+
sortCol,
|
|
1516
|
+
sortDir,
|
|
1517
|
+
onSortExternal
|
|
1518
|
+
]);
|
|
1519
|
+
const toggleExpand = useCallback((key) => {
|
|
1520
|
+
setExpandedKeys((prev) => {
|
|
1521
|
+
const next = new Set(prev);
|
|
1522
|
+
if (next.has(key)) next.delete(key);
|
|
1523
|
+
else next.add(key);
|
|
1524
|
+
return next;
|
|
1525
|
+
});
|
|
1526
|
+
}, []);
|
|
1527
|
+
const selected = selectedKeys !== null && selectedKeys !== void 0 ? selectedKeys : [];
|
|
1528
|
+
const selectedSet = useMemo(() => new Set(selectedKeys !== null && selectedKeys !== void 0 ? selectedKeys : []), [selectedKeys]);
|
|
1529
|
+
const allKeys = data.map(keyExtractor);
|
|
1530
|
+
const allSelected = allKeys.length > 0 && allKeys.every((k) => selectedSet.has(k));
|
|
1531
|
+
const toggleSelectAll = useCallback(() => {
|
|
1532
|
+
if (!onSelectionChange) return;
|
|
1533
|
+
onSelectionChange(allSelected ? [] : allKeys);
|
|
1534
|
+
}, [
|
|
1535
|
+
allSelected,
|
|
1536
|
+
allKeys,
|
|
1537
|
+
onSelectionChange
|
|
1538
|
+
]);
|
|
1539
|
+
const toggleSelectRow = useCallback((key) => {
|
|
1540
|
+
if (!onSelectionChange) return;
|
|
1541
|
+
onSelectionChange(selectedSet.has(key) ? selected.filter((k) => k !== key) : [...selected, key]);
|
|
1542
|
+
}, [
|
|
1543
|
+
selected,
|
|
1544
|
+
selectedSet,
|
|
1545
|
+
onSelectionChange
|
|
1546
|
+
]);
|
|
1547
|
+
const sortIndicator = (colId) => {
|
|
1548
|
+
if (sortCol !== colId) return null;
|
|
1549
|
+
return sortDir === "asc" ? " ▲" : sortDir === "desc" ? " ▼" : null;
|
|
1550
|
+
};
|
|
1551
|
+
const colCount = columns.length + (selectable ? 1 : 0) + (expandable ? 1 : 0);
|
|
1552
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1553
|
+
className: cn("gap-group flex flex-col", className),
|
|
1554
|
+
"data-opt-id": "J1KN4",
|
|
1555
|
+
"data-opt-slug": "data-table.DataTable",
|
|
1556
|
+
children: [
|
|
1557
|
+
title && /* @__PURE__ */ jsx("h3", {
|
|
1558
|
+
className: cn("text-sm font-semibold", "text-text-primary"),
|
|
1559
|
+
children: title
|
|
1560
|
+
}),
|
|
1561
|
+
/* @__PURE__ */ jsx("div", {
|
|
1562
|
+
className: cn("overflow-x-auto rounded-lg", OPT_BORDER, "bg-surface"),
|
|
1563
|
+
children: data.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
1564
|
+
className: cn("px-4 py-8 text-center text-sm", OPT_TEXT_SECONDARY),
|
|
1565
|
+
children: emptyMessage
|
|
1566
|
+
}) : /* @__PURE__ */ jsx(CompositeProvider, {
|
|
1567
|
+
focusLoop: true,
|
|
1568
|
+
focusWrap: true,
|
|
1569
|
+
children: /* @__PURE__ */ jsxs(Composite, {
|
|
1570
|
+
role: "grid",
|
|
1571
|
+
"aria-label": title,
|
|
1572
|
+
className: "w-full",
|
|
1573
|
+
render: /* @__PURE__ */ jsx("table", {}),
|
|
1574
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
1575
|
+
className: cn("border-border-subtle bg-surface-inset border-b", stickyHeader && "sticky top-0 z-10"),
|
|
1576
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
1577
|
+
selectable && /* @__PURE__ */ jsx("th", {
|
|
1578
|
+
className: cn("px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-text-tertiary", "w-10"),
|
|
1579
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1580
|
+
checked: allSelected,
|
|
1581
|
+
onChange: toggleSelectAll,
|
|
1582
|
+
"aria-label": "Select all"
|
|
1583
|
+
})
|
|
1584
|
+
}),
|
|
1585
|
+
expandable && /* @__PURE__ */ jsx("th", { className: cn("px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-text-tertiary", "w-10") }),
|
|
1586
|
+
columns.map((col) => {
|
|
1587
|
+
var _col$align;
|
|
1588
|
+
const isSortable = sortable && col.sortable !== false;
|
|
1589
|
+
const resizeValue = getResizeHandleValue(colWidths[col.id], col.width);
|
|
1590
|
+
const resizeMax = Math.max(DEFAULT_COLUMN_RESIZE_MAX, resizeValue);
|
|
1591
|
+
return /* @__PURE__ */ jsxs("th", {
|
|
1592
|
+
className: cn(OPT_TH, "relative", alignmentClass[(_col$align = col.align) !== null && _col$align !== void 0 ? _col$align : "left"], isSortable && "hover:text-text-primary cursor-pointer select-none", isSortable && "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-ring-offset"),
|
|
1593
|
+
style: { width: colWidths[col.id] || col.width || void 0 },
|
|
1594
|
+
onClick: isSortable ? () => handleSort(col.id) : void 0,
|
|
1595
|
+
onKeyDown: (event) => {
|
|
1596
|
+
if (!isSortable || event.key !== "Enter" && event.key !== " ") return;
|
|
1597
|
+
event.preventDefault();
|
|
1598
|
+
handleSort(col.id);
|
|
1599
|
+
},
|
|
1600
|
+
tabIndex: isSortable ? 0 : void 0,
|
|
1601
|
+
"aria-sort": sortCol === col.id && sortDir ? sortDir === "asc" ? "ascending" : "descending" : void 0,
|
|
1602
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
1603
|
+
className: "flex items-center",
|
|
1604
|
+
children: [col.header, sortIndicator(col.id)]
|
|
1605
|
+
}), resizableColumns && /* @__PURE__ */ jsx("span", {
|
|
1606
|
+
role: "separator",
|
|
1607
|
+
"aria-orientation": "vertical",
|
|
1608
|
+
"aria-label": `Resize ${col.header}`,
|
|
1609
|
+
"aria-valuemin": MIN_COLUMN_WIDTH,
|
|
1610
|
+
"aria-valuemax": resizeMax,
|
|
1611
|
+
"aria-valuenow": resizeValue,
|
|
1612
|
+
"aria-valuetext": `${resizeValue} pixels`,
|
|
1613
|
+
tabIndex: 0,
|
|
1614
|
+
className: "bg-border absolute top-0 right-0 bottom-0 w-1 cursor-col-resize opacity-0 hover:opacity-100",
|
|
1615
|
+
onKeyDown: (e) => {
|
|
1616
|
+
if (e.key !== "ArrowLeft" && e.key !== "ArrowRight" && e.key !== "Home" && e.key !== "End") return;
|
|
1617
|
+
e.preventDefault();
|
|
1618
|
+
e.stopPropagation();
|
|
1619
|
+
if (e.key === "Home" || e.key === "End") {
|
|
1620
|
+
setColWidths((prev) => _objectSpread2(_objectSpread2({}, prev), {}, { [col.id]: e.key === "Home" ? MIN_COLUMN_WIDTH : resizeMax }));
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
const delta = e.shiftKey ? 40 : 10;
|
|
1624
|
+
const direction = e.key === "ArrowRight" ? 1 : -1;
|
|
1625
|
+
setColWidths((prev) => {
|
|
1626
|
+
const current = getResizeHandleValue(prev[col.id], col.width);
|
|
1627
|
+
return _objectSpread2(_objectSpread2({}, prev), {}, { [col.id]: Math.max(MIN_COLUMN_WIDTH, current + direction * delta) });
|
|
1628
|
+
});
|
|
1629
|
+
},
|
|
1630
|
+
onMouseDown: (e) => {
|
|
1631
|
+
e.preventDefault();
|
|
1632
|
+
e.stopPropagation();
|
|
1633
|
+
const startX = e.clientX;
|
|
1634
|
+
const startW = e.target.parentElement.offsetWidth;
|
|
1635
|
+
const onMove = (ev) => {
|
|
1636
|
+
const newW = Math.max(MIN_COLUMN_WIDTH, startW + ev.clientX - startX);
|
|
1637
|
+
setColWidths((prev) => _objectSpread2(_objectSpread2({}, prev), {}, { [col.id]: newW }));
|
|
1638
|
+
};
|
|
1639
|
+
const onUp = () => {
|
|
1640
|
+
document.removeEventListener("mousemove", onMove);
|
|
1641
|
+
document.removeEventListener("mouseup", onUp);
|
|
1642
|
+
};
|
|
1643
|
+
document.addEventListener("mousemove", onMove);
|
|
1644
|
+
document.addEventListener("mouseup", onUp);
|
|
1645
|
+
}
|
|
1646
|
+
})]
|
|
1647
|
+
}, col.id);
|
|
1648
|
+
})
|
|
1649
|
+
] })
|
|
1650
|
+
}), /* @__PURE__ */ jsx("tbody", {
|
|
1651
|
+
className: cn("divide-y", OPT_DIVIDER),
|
|
1652
|
+
children: pagedData.map((row) => {
|
|
1653
|
+
const key = keyExtractor(row);
|
|
1654
|
+
const isExpanded = expandedKeys.has(key);
|
|
1655
|
+
const isSelected = selectedSet.has(key);
|
|
1656
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(CompositeRow, {
|
|
1657
|
+
render: /* @__PURE__ */ jsx("tr", {
|
|
1658
|
+
className: cn(onRowClick ? "cursor-pointer" : void 0, (isSelected || activeRowId === key) && "bg-accent-subtle"),
|
|
1659
|
+
onClick: onRowClick ? () => onRowClick(row) : void 0
|
|
1660
|
+
}),
|
|
1661
|
+
children: [
|
|
1662
|
+
selectable && /* @__PURE__ */ jsx(CompositeItem, {
|
|
1663
|
+
render: /* @__PURE__ */ jsx("td", {
|
|
1664
|
+
className: cn("px-3 py-2.5 text-sm text-text-primary whitespace-nowrap", "w-10"),
|
|
1665
|
+
role: "gridcell"
|
|
1666
|
+
}),
|
|
1667
|
+
className: "outline-none data-[active-item]:bg-accent-subtle data-[focus-visible]:outline-2 data-[focus-visible]:outline-ring data-[focus-visible]:-outline-offset-1",
|
|
1668
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1669
|
+
checked: isSelected,
|
|
1670
|
+
onChange: () => toggleSelectRow(key),
|
|
1671
|
+
"aria-label": `Select row ${key}`
|
|
1672
|
+
})
|
|
1673
|
+
}),
|
|
1674
|
+
expandable && /* @__PURE__ */ jsx(CompositeItem, {
|
|
1675
|
+
render: /* @__PURE__ */ jsx("td", {
|
|
1676
|
+
className: cn("px-3 py-2.5 text-sm text-text-primary whitespace-nowrap", "w-10"),
|
|
1677
|
+
role: "gridcell"
|
|
1678
|
+
}),
|
|
1679
|
+
className: "outline-none data-[active-item]:bg-accent-subtle data-[focus-visible]:outline-2 data-[focus-visible]:outline-ring data-[focus-visible]:-outline-offset-1",
|
|
1680
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
1681
|
+
type: "button",
|
|
1682
|
+
onClick: (e) => {
|
|
1683
|
+
e.stopPropagation();
|
|
1684
|
+
toggleExpand(key);
|
|
1685
|
+
},
|
|
1686
|
+
className: cn("rounded p-0.5 text-sm transition-transform", "text-text-secondary", "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-ring-offset", isExpanded && "rotate-90"),
|
|
1687
|
+
"aria-expanded": isExpanded,
|
|
1688
|
+
"aria-label": `${isExpanded ? "Collapse" : "Expand"} row ${key}`,
|
|
1689
|
+
children: "▶"
|
|
1690
|
+
})
|
|
1691
|
+
}),
|
|
1692
|
+
columns.map((col, colIndex) => {
|
|
1693
|
+
var _col$align2, _col$barColor;
|
|
1694
|
+
return /* @__PURE__ */ jsxs(CompositeItem, {
|
|
1695
|
+
render: /* @__PURE__ */ jsx("td", {
|
|
1696
|
+
className: cn(OPT_TD, alignmentClass[(_col$align2 = col.align) !== null && _col$align2 !== void 0 ? _col$align2 : "left"], colIndex === 0 ? "font-medium" : ""),
|
|
1697
|
+
role: "gridcell"
|
|
1698
|
+
}),
|
|
1699
|
+
className: OPT_TABLE_ROW_ACTIVE,
|
|
1700
|
+
onKeyDown: (event) => {
|
|
1701
|
+
if (!onRowClick || event.target !== event.currentTarget || event.key !== "Enter" && event.key !== " ") return;
|
|
1702
|
+
event.preventDefault();
|
|
1703
|
+
onRowClick(row);
|
|
1704
|
+
},
|
|
1705
|
+
children: [getCellValue(row, col.accessor), col.bar && /* @__PURE__ */ jsx(DataTableProgressBar, {
|
|
1706
|
+
value: col.bar(row),
|
|
1707
|
+
barColor: (_col$barColor = col.barColor) !== null && _col$barColor !== void 0 ? _col$barColor : "bg-accent",
|
|
1708
|
+
label: col.header
|
|
1709
|
+
})]
|
|
1710
|
+
}, col.id);
|
|
1711
|
+
})
|
|
1712
|
+
]
|
|
1713
|
+
}), expandable && isExpanded && renderExpanded && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
|
|
1714
|
+
colSpan: colCount,
|
|
1715
|
+
className: "border-border-subtle bg-surface-inset border-t px-4 py-3",
|
|
1716
|
+
children: renderExpanded(row)
|
|
1717
|
+
}) })] }, key);
|
|
1718
|
+
})
|
|
1719
|
+
})]
|
|
1720
|
+
})
|
|
1721
|
+
})
|
|
1722
|
+
}),
|
|
1723
|
+
pageSize && totalPages > 1 && /* @__PURE__ */ jsx(Pagination, {
|
|
1724
|
+
totalItems: sortedData.length,
|
|
1725
|
+
pageSize,
|
|
1726
|
+
currentPage: page + 1,
|
|
1727
|
+
onPageChange: (p) => setPage(p - 1)
|
|
1728
|
+
})
|
|
1729
|
+
]
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
//#endregion
|
|
1733
|
+
//#region src/shells/notification-toast.tsx
|
|
1734
|
+
let toastCounter = 0;
|
|
1735
|
+
let toasts = [];
|
|
1736
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1737
|
+
function emitChange() {
|
|
1738
|
+
for (const l of listeners) l();
|
|
1739
|
+
}
|
|
1740
|
+
const toastStore = {
|
|
1741
|
+
subscribe(listener) {
|
|
1742
|
+
listeners.add(listener);
|
|
1743
|
+
return () => {
|
|
1744
|
+
listeners.delete(listener);
|
|
1745
|
+
};
|
|
1746
|
+
},
|
|
1747
|
+
getSnapshot() {
|
|
1748
|
+
return toasts;
|
|
1749
|
+
},
|
|
1750
|
+
add(input) {
|
|
1751
|
+
var _input$variant;
|
|
1752
|
+
const id = `toast-${++toastCounter}`;
|
|
1753
|
+
toasts = [...toasts, _objectSpread2({
|
|
1754
|
+
id,
|
|
1755
|
+
variant: (_input$variant = input.variant) !== null && _input$variant !== void 0 ? _input$variant : "info"
|
|
1756
|
+
}, input)];
|
|
1757
|
+
emitChange();
|
|
1758
|
+
return id;
|
|
1759
|
+
},
|
|
1760
|
+
dismiss(id) {
|
|
1761
|
+
const next = toasts.filter((t) => t.id !== id);
|
|
1762
|
+
if (next.length !== toasts.length) {
|
|
1763
|
+
toasts = next;
|
|
1764
|
+
emitChange();
|
|
1765
|
+
}
|
|
1766
|
+
},
|
|
1767
|
+
clear() {
|
|
1768
|
+
if (toasts.length) {
|
|
1769
|
+
toasts = [];
|
|
1770
|
+
emitChange();
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
};
|
|
1774
|
+
function makeVariant(variant) {
|
|
1775
|
+
return (message, options) => toastStore.add(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1776
|
+
message,
|
|
1777
|
+
variant
|
|
1778
|
+
}));
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1781
|
+
* Imperative toast API. Call from anywhere (no hook required):
|
|
1782
|
+
* `toast.success("Saved")`, `toast.error("Failed", { title: "Oops" })`,
|
|
1783
|
+
* `toast.dismiss(id)`, `toast.clear()`. Requires a mounted `ToastProvider`.
|
|
1784
|
+
*/
|
|
1785
|
+
const toast = Object.assign((options) => toastStore.add(options), {
|
|
1786
|
+
info: makeVariant("info"),
|
|
1787
|
+
success: makeVariant("success"),
|
|
1788
|
+
warning: makeVariant("warning"),
|
|
1789
|
+
error: makeVariant("error"),
|
|
1790
|
+
dismiss: (id) => toastStore.dismiss(id),
|
|
1791
|
+
clear: () => toastStore.clear()
|
|
1792
|
+
});
|
|
1793
|
+
const ToastContext = createContext(null);
|
|
1794
|
+
const positionStyles = {
|
|
1795
|
+
"top-right": "top-4 right-4",
|
|
1796
|
+
"top-left": "top-4 left-4",
|
|
1797
|
+
"bottom-right": "bottom-4 right-4",
|
|
1798
|
+
"bottom-left": "bottom-4 left-4"
|
|
1799
|
+
};
|
|
1800
|
+
/** Renders the toast provider component. */
|
|
1801
|
+
function ToastProvider({ children, position = "top-right", defaultDuration = 5e3, stackLimit = 5 }) {
|
|
1802
|
+
const allToasts = useSyncExternalStore(toastStore.subscribe, toastStore.getSnapshot, toastStore.getSnapshot);
|
|
1803
|
+
const visibleToasts = allToasts.length > stackLimit ? allToasts.slice(-stackLimit) : allToasts;
|
|
1804
|
+
const addToast = useCallback((t) => toastStore.add(t), []);
|
|
1805
|
+
const removeToast = useCallback((id) => toastStore.dismiss(id), []);
|
|
1806
|
+
return /* @__PURE__ */ jsxs(ToastContext.Provider, {
|
|
1807
|
+
value: {
|
|
1808
|
+
toasts: visibleToasts,
|
|
1809
|
+
addToast,
|
|
1810
|
+
removeToast
|
|
1811
|
+
},
|
|
1812
|
+
children: [children, /* @__PURE__ */ jsx("div", {
|
|
1813
|
+
className: cn("gap-element fixed z-50 flex flex-col", positionStyles[position]),
|
|
1814
|
+
role: "region",
|
|
1815
|
+
"aria-label": "Notifications",
|
|
1816
|
+
"data-opt-id": "M0KTS",
|
|
1817
|
+
"data-opt-slug": "notification-toast.ToastProvider",
|
|
1818
|
+
children: visibleToasts.map((t) => /* @__PURE__ */ jsx(NotificationToast, {
|
|
1819
|
+
toast: t,
|
|
1820
|
+
defaultDuration,
|
|
1821
|
+
onDismiss: () => toastStore.dismiss(t.id)
|
|
1822
|
+
}, t.id))
|
|
1823
|
+
})]
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
/** Provides toast. */
|
|
1827
|
+
function useToast() {
|
|
1828
|
+
const context = useContext(ToastContext);
|
|
1829
|
+
if (!context) throw new Error("useToast must be used within a ToastProvider");
|
|
1830
|
+
return context;
|
|
1831
|
+
}
|
|
1832
|
+
/** Renders the notification toast component. */
|
|
1833
|
+
function NotificationToast({ toast, onDismiss, defaultDuration = 5e3 }) {
|
|
1834
|
+
var _toast$duration;
|
|
1835
|
+
const duration = (_toast$duration = toast.duration) !== null && _toast$duration !== void 0 ? _toast$duration : defaultDuration;
|
|
1836
|
+
const isUrgent = toast.variant === "error" || toast.variant === "warning";
|
|
1837
|
+
const onDismissRef = useRef(onDismiss);
|
|
1838
|
+
const dismissedRef = useRef(false);
|
|
1839
|
+
const timerStartedAtRef = useRef(null);
|
|
1840
|
+
const remainingDurationRef = useRef(duration);
|
|
1841
|
+
const [paused, setPaused] = useState(false);
|
|
1842
|
+
useEffect(() => {
|
|
1843
|
+
onDismissRef.current = onDismiss;
|
|
1844
|
+
}, [onDismiss]);
|
|
1845
|
+
const dismissOnce = useCallback(() => {
|
|
1846
|
+
if (dismissedRef.current) return;
|
|
1847
|
+
dismissedRef.current = true;
|
|
1848
|
+
onDismissRef.current();
|
|
1849
|
+
}, []);
|
|
1850
|
+
useEffect(() => {
|
|
1851
|
+
dismissedRef.current = false;
|
|
1852
|
+
remainingDurationRef.current = duration;
|
|
1853
|
+
}, [toast.id, duration]);
|
|
1854
|
+
useEffect(() => {
|
|
1855
|
+
if (!duration || duration <= 0 || paused || dismissedRef.current) return;
|
|
1856
|
+
timerStartedAtRef.current = Date.now();
|
|
1857
|
+
const timer = setTimeout(() => {
|
|
1858
|
+
dismissOnce();
|
|
1859
|
+
}, remainingDurationRef.current);
|
|
1860
|
+
return () => {
|
|
1861
|
+
clearTimeout(timer);
|
|
1862
|
+
if (timerStartedAtRef.current !== null) {
|
|
1863
|
+
const elapsed = Date.now() - timerStartedAtRef.current;
|
|
1864
|
+
remainingDurationRef.current = Math.max(0, remainingDurationRef.current - elapsed);
|
|
1865
|
+
timerStartedAtRef.current = null;
|
|
1866
|
+
}
|
|
1867
|
+
};
|
|
1868
|
+
}, [
|
|
1869
|
+
dismissOnce,
|
|
1870
|
+
duration,
|
|
1871
|
+
paused
|
|
1872
|
+
]);
|
|
1873
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1874
|
+
className: "animate-in slide-in-from-right-full fade-in w-80 duration-200",
|
|
1875
|
+
role: isUrgent ? "alert" : "status",
|
|
1876
|
+
"aria-live": isUrgent ? "assertive" : "polite",
|
|
1877
|
+
"aria-atomic": "true",
|
|
1878
|
+
onMouseEnter: () => setPaused(true),
|
|
1879
|
+
onMouseLeave: () => setPaused(false),
|
|
1880
|
+
onFocus: () => setPaused(true),
|
|
1881
|
+
onBlur: (event) => {
|
|
1882
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setPaused(false);
|
|
1883
|
+
},
|
|
1884
|
+
"data-opt-id": "26YVM",
|
|
1885
|
+
"data-opt-slug": "notification-toast.NotificationToast",
|
|
1886
|
+
children: /* @__PURE__ */ jsxs(Alert, {
|
|
1887
|
+
variant: toast.variant,
|
|
1888
|
+
title: toast.title,
|
|
1889
|
+
dismissible: true,
|
|
1890
|
+
onDismiss: dismissOnce,
|
|
1891
|
+
children: [toast.message, toast.actions && toast.actions.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
1892
|
+
className: "gap-element mt-2 flex",
|
|
1893
|
+
children: toast.actions.map((action) => /* @__PURE__ */ jsx("button", {
|
|
1894
|
+
type: "button",
|
|
1895
|
+
onClick: action.onClick,
|
|
1896
|
+
className: "text-xs font-medium underline hover:no-underline",
|
|
1897
|
+
children: action.label
|
|
1898
|
+
}, action.label))
|
|
1899
|
+
})]
|
|
1900
|
+
})
|
|
1901
|
+
});
|
|
1902
|
+
}
|
|
1903
|
+
//#endregion
|
|
1904
|
+
//#region src/shells/failure-list.tsx
|
|
1905
|
+
const defaultLabels$6 = {
|
|
1906
|
+
title: "최근 실패",
|
|
1907
|
+
emptyMessage: "실패 항목이 없습니다",
|
|
1908
|
+
moreItems: "{count}개 더 보기",
|
|
1909
|
+
severityLabels: {
|
|
1910
|
+
critical: "심각",
|
|
1911
|
+
error: "오류",
|
|
1912
|
+
warning: "경고"
|
|
1913
|
+
},
|
|
1914
|
+
timeAgo: {
|
|
1915
|
+
justNow: "방금 전",
|
|
1916
|
+
minutesAgo: "{minutes}분 전",
|
|
1917
|
+
hoursAgo: "{hours}시간 전",
|
|
1918
|
+
daysAgo: "{days}일 전"
|
|
1919
|
+
}
|
|
1920
|
+
};
|
|
1921
|
+
const severityVariant = {
|
|
1922
|
+
critical: "error",
|
|
1923
|
+
error: "error",
|
|
1924
|
+
warning: "warning"
|
|
1925
|
+
};
|
|
1926
|
+
const severityBorder = {
|
|
1927
|
+
critical: "border-l-2 border-l-danger",
|
|
1928
|
+
error: "border-l-2 border-l-danger",
|
|
1929
|
+
warning: "border-l-2 border-l-warning"
|
|
1930
|
+
};
|
|
1931
|
+
function formatRelativeTime(timestamp, timeLabels, locale) {
|
|
1932
|
+
const now = /* @__PURE__ */ new Date();
|
|
1933
|
+
const date = new Date(timestamp);
|
|
1934
|
+
const diffMs = now.getTime() - date.getTime();
|
|
1935
|
+
const diffMins = Math.floor(diffMs / 6e4);
|
|
1936
|
+
const diffHours = Math.floor(diffMs / 36e5);
|
|
1937
|
+
const diffDays = Math.floor(diffMs / 864e5);
|
|
1938
|
+
if (diffMins < 1) return timeLabels.justNow;
|
|
1939
|
+
if (diffMins < 60) return timeLabels.minutesAgo.replace("{minutes}", String(diffMins));
|
|
1940
|
+
if (diffHours < 24) return timeLabels.hoursAgo.replace("{hours}", String(diffHours));
|
|
1941
|
+
if (diffDays < 7) return timeLabels.daysAgo.replace("{days}", String(diffDays));
|
|
1942
|
+
return date.toLocaleDateString(locale);
|
|
1943
|
+
}
|
|
1944
|
+
function groupBy(items, key) {
|
|
1945
|
+
const map = /* @__PURE__ */ new Map();
|
|
1946
|
+
for (const item of items) {
|
|
1947
|
+
const k = key(item);
|
|
1948
|
+
const existing = map.get(k);
|
|
1949
|
+
if (existing) existing.push(item);
|
|
1950
|
+
else map.set(k, [item]);
|
|
1951
|
+
}
|
|
1952
|
+
return map;
|
|
1953
|
+
}
|
|
1954
|
+
function FailureItemRow({ failure, isLast, onFailureClick, renderActions, mergedSeverityLabels, mergedTimeAgo, locale }) {
|
|
1955
|
+
const itemId = `failure-${failure.id}`;
|
|
1956
|
+
const handleKeyDown = (event) => {
|
|
1957
|
+
if (!onFailureClick) return;
|
|
1958
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
1959
|
+
event.preventDefault();
|
|
1960
|
+
onFailureClick(failure);
|
|
1961
|
+
};
|
|
1962
|
+
return /* @__PURE__ */ jsxs(CompositeItem, {
|
|
1963
|
+
render: /* @__PURE__ */ jsx("article", {}),
|
|
1964
|
+
role: "article",
|
|
1965
|
+
"aria-labelledby": itemId,
|
|
1966
|
+
className: cn("group gap-group relative flex w-full items-start p-3", OPT_FOCUS_VISIBLE, "data-[active-item]:bg-accent-subtle", onFailureClick && "cursor-pointer", !isLast && "border-border-subtle border-b", severityBorder[failure.severity]),
|
|
1967
|
+
onClick: () => onFailureClick === null || onFailureClick === void 0 ? void 0 : onFailureClick(failure),
|
|
1968
|
+
onKeyDown: handleKeyDown,
|
|
1969
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1970
|
+
className: "min-w-0 flex-1",
|
|
1971
|
+
children: [
|
|
1972
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1973
|
+
className: "gap-element flex items-center",
|
|
1974
|
+
children: [/* @__PURE__ */ jsx(Badge, {
|
|
1975
|
+
variant: severityVariant[failure.severity],
|
|
1976
|
+
size: "sm",
|
|
1977
|
+
children: mergedSeverityLabels[failure.severity]
|
|
1978
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1979
|
+
id: itemId,
|
|
1980
|
+
className: `text-sm font-medium ${OPT_TEXT_PRIMARY} truncate`,
|
|
1981
|
+
children: failure.title
|
|
1982
|
+
})]
|
|
1983
|
+
}),
|
|
1984
|
+
failure.message && /* @__PURE__ */ jsx("p", {
|
|
1985
|
+
className: `mt-1 text-xs text-text-secondary line-clamp-2`,
|
|
1986
|
+
children: failure.message
|
|
1987
|
+
}),
|
|
1988
|
+
/* @__PURE__ */ jsx("time", {
|
|
1989
|
+
dateTime: failure.timestamp,
|
|
1990
|
+
className: `mt-1 block text-xs ${OPT_TEXT_TERTIARY}`,
|
|
1991
|
+
children: formatRelativeTime(failure.timestamp, mergedTimeAgo, locale)
|
|
1992
|
+
})
|
|
1993
|
+
]
|
|
1994
|
+
}), renderActions && /* @__PURE__ */ jsx("div", {
|
|
1995
|
+
className: "flex shrink-0 items-center gap-1",
|
|
1996
|
+
children: renderActions(failure)
|
|
1997
|
+
})]
|
|
1998
|
+
}, failure.id);
|
|
1999
|
+
}
|
|
2000
|
+
/** Renders the failure list component. */
|
|
2001
|
+
function FailureList({ failures, title, maxItems, grouped = false, onFailureClick, onShowMore, labels: customLabels, locale = "ko-KR", loading = false, renderActions, className }) {
|
|
2002
|
+
var _customLabels$timeAgo, _customLabels$timeAgo2, _customLabels$timeAgo3, _customLabels$timeAgo4, _customLabels$timeAgo5, _customLabels$timeAgo6, _customLabels$timeAgo7, _customLabels$timeAgo8, _customLabels$severit, _customLabels$severit2, _customLabels$severit3, _customLabels$severit4, _customLabels$severit5, _customLabels$severit6, _customLabels$title, _customLabels$emptyMe, _customLabels$moreIte;
|
|
2003
|
+
const mergedTimeAgo = {
|
|
2004
|
+
justNow: (_customLabels$timeAgo = customLabels === null || customLabels === void 0 || (_customLabels$timeAgo2 = customLabels.timeAgo) === null || _customLabels$timeAgo2 === void 0 ? void 0 : _customLabels$timeAgo2.justNow) !== null && _customLabels$timeAgo !== void 0 ? _customLabels$timeAgo : defaultLabels$6.timeAgo.justNow,
|
|
2005
|
+
minutesAgo: (_customLabels$timeAgo3 = customLabels === null || customLabels === void 0 || (_customLabels$timeAgo4 = customLabels.timeAgo) === null || _customLabels$timeAgo4 === void 0 ? void 0 : _customLabels$timeAgo4.minutesAgo) !== null && _customLabels$timeAgo3 !== void 0 ? _customLabels$timeAgo3 : defaultLabels$6.timeAgo.minutesAgo,
|
|
2006
|
+
hoursAgo: (_customLabels$timeAgo5 = customLabels === null || customLabels === void 0 || (_customLabels$timeAgo6 = customLabels.timeAgo) === null || _customLabels$timeAgo6 === void 0 ? void 0 : _customLabels$timeAgo6.hoursAgo) !== null && _customLabels$timeAgo5 !== void 0 ? _customLabels$timeAgo5 : defaultLabels$6.timeAgo.hoursAgo,
|
|
2007
|
+
daysAgo: (_customLabels$timeAgo7 = customLabels === null || customLabels === void 0 || (_customLabels$timeAgo8 = customLabels.timeAgo) === null || _customLabels$timeAgo8 === void 0 ? void 0 : _customLabels$timeAgo8.daysAgo) !== null && _customLabels$timeAgo7 !== void 0 ? _customLabels$timeAgo7 : defaultLabels$6.timeAgo.daysAgo
|
|
2008
|
+
};
|
|
2009
|
+
const mergedSeverityLabels = {
|
|
2010
|
+
critical: (_customLabels$severit = customLabels === null || customLabels === void 0 || (_customLabels$severit2 = customLabels.severityLabels) === null || _customLabels$severit2 === void 0 ? void 0 : _customLabels$severit2.critical) !== null && _customLabels$severit !== void 0 ? _customLabels$severit : defaultLabels$6.severityLabels.critical,
|
|
2011
|
+
error: (_customLabels$severit3 = customLabels === null || customLabels === void 0 || (_customLabels$severit4 = customLabels.severityLabels) === null || _customLabels$severit4 === void 0 ? void 0 : _customLabels$severit4.error) !== null && _customLabels$severit3 !== void 0 ? _customLabels$severit3 : defaultLabels$6.severityLabels.error,
|
|
2012
|
+
warning: (_customLabels$severit5 = customLabels === null || customLabels === void 0 || (_customLabels$severit6 = customLabels.severityLabels) === null || _customLabels$severit6 === void 0 ? void 0 : _customLabels$severit6.warning) !== null && _customLabels$severit5 !== void 0 ? _customLabels$severit5 : defaultLabels$6.severityLabels.warning
|
|
2013
|
+
};
|
|
2014
|
+
const labels = {
|
|
2015
|
+
title: (_customLabels$title = customLabels === null || customLabels === void 0 ? void 0 : customLabels.title) !== null && _customLabels$title !== void 0 ? _customLabels$title : defaultLabels$6.title,
|
|
2016
|
+
emptyMessage: (_customLabels$emptyMe = customLabels === null || customLabels === void 0 ? void 0 : customLabels.emptyMessage) !== null && _customLabels$emptyMe !== void 0 ? _customLabels$emptyMe : defaultLabels$6.emptyMessage,
|
|
2017
|
+
moreItems: (_customLabels$moreIte = customLabels === null || customLabels === void 0 ? void 0 : customLabels.moreItems) !== null && _customLabels$moreIte !== void 0 ? _customLabels$moreIte : defaultLabels$6.moreItems
|
|
2018
|
+
};
|
|
2019
|
+
const displayTitle = title !== null && title !== void 0 ? title : labels.title;
|
|
2020
|
+
const allItems = maxItems ? failures.slice(0, maxItems) : failures;
|
|
2021
|
+
const remainingCount = maxItems ? Math.max(0, failures.length - maxItems) : 0;
|
|
2022
|
+
const rowProps = {
|
|
2023
|
+
onFailureClick,
|
|
2024
|
+
renderActions,
|
|
2025
|
+
mergedSeverityLabels,
|
|
2026
|
+
mergedTimeAgo,
|
|
2027
|
+
locale
|
|
2028
|
+
};
|
|
2029
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2030
|
+
className,
|
|
2031
|
+
"data-opt-id": "ZAM3R",
|
|
2032
|
+
"data-opt-slug": "failure-list.FailureList",
|
|
2033
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2034
|
+
className: "gap-group flex flex-col",
|
|
2035
|
+
children: [displayTitle && /* @__PURE__ */ jsx("h3", {
|
|
2036
|
+
className: `text-sm font-semibold text-text-primary`,
|
|
2037
|
+
children: displayTitle
|
|
2038
|
+
}), failures.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
2039
|
+
role: "status",
|
|
2040
|
+
className: `py-8 text-center text-sm ${OPT_TEXT_SECONDARY}`,
|
|
2041
|
+
children: labels.emptyMessage
|
|
2042
|
+
}) : /* @__PURE__ */ jsx(CompositeProvider, {
|
|
2043
|
+
focusLoop: true,
|
|
2044
|
+
orientation: "vertical",
|
|
2045
|
+
children: /* @__PURE__ */ jsx(Composite, {
|
|
2046
|
+
role: "feed",
|
|
2047
|
+
"aria-label": displayTitle,
|
|
2048
|
+
"aria-busy": loading,
|
|
2049
|
+
className: `rounded-lg ${OPT_BORDER} bg-surface`,
|
|
2050
|
+
children: grouped ? renderGrouped(allItems, remainingCount, rowProps, labels, onShowMore) : renderFlat(allItems, remainingCount, rowProps, labels, onShowMore)
|
|
2051
|
+
})
|
|
2052
|
+
})]
|
|
2053
|
+
})
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
2056
|
+
function renderFlat(items, remainingCount, rowProps, labels, onShowMore) {
|
|
2057
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [items.map((failure, index) => /* @__PURE__ */ jsx(FailureItemRow, _objectSpread2({
|
|
2058
|
+
failure,
|
|
2059
|
+
isLast: index === items.length - 1 && remainingCount === 0
|
|
2060
|
+
}, rowProps), failure.id)), remainingCount > 0 && /* @__PURE__ */ jsx(CompositeItem, {
|
|
2061
|
+
render: /* @__PURE__ */ jsx("button", { type: "button" }),
|
|
2062
|
+
onClick: onShowMore,
|
|
2063
|
+
className: `border-border-subtle w-full border-t p-3 text-center text-xs font-medium text-text-secondary outline-none data-[focus-visible]:outline-2 data-[focus-visible]:outline-ring data-[focus-visible]:-outline-offset-1 hover:text-accent data-[active-item]:bg-accent-subtle transition-colors`,
|
|
2064
|
+
"aria-label": `${remainingCount}개의 실패 더 보기`,
|
|
2065
|
+
children: labels.moreItems.replace("{count}", String(remainingCount))
|
|
2066
|
+
})] });
|
|
2067
|
+
}
|
|
2068
|
+
function renderGrouped(items, remainingCount, rowProps, labels, onShowMore) {
|
|
2069
|
+
const groups = groupBy(items, (f) => {
|
|
2070
|
+
var _f$group;
|
|
2071
|
+
return (_f$group = f.group) !== null && _f$group !== void 0 ? _f$group : "";
|
|
2072
|
+
});
|
|
2073
|
+
const groupEntries = Array.from(groups.entries());
|
|
2074
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [groupEntries.map(([groupName, groupItems], groupIndex) => {
|
|
2075
|
+
const isLastGroup = groupIndex === groupEntries.length - 1 && remainingCount === 0;
|
|
2076
|
+
return /* @__PURE__ */ jsxs("div", { children: [groupName && /* @__PURE__ */ jsx("div", {
|
|
2077
|
+
className: cn(`px-3 py-2 text-xs font-semibold text-text-tertiary tracking-wider uppercase`, groupIndex > 0 && "border-border-subtle border-t"),
|
|
2078
|
+
children: groupName
|
|
2079
|
+
}), groupItems.map((failure, index) => /* @__PURE__ */ jsx(FailureItemRow, _objectSpread2({
|
|
2080
|
+
failure,
|
|
2081
|
+
isLast: isLastGroup && index === groupItems.length - 1
|
|
2082
|
+
}, rowProps), failure.id))] }, groupName || "__ungrouped__");
|
|
2083
|
+
}), remainingCount > 0 && /* @__PURE__ */ jsx(CompositeItem, {
|
|
2084
|
+
render: /* @__PURE__ */ jsx("button", { type: "button" }),
|
|
2085
|
+
onClick: onShowMore,
|
|
2086
|
+
className: `border-border-subtle w-full border-t p-3 text-center text-xs font-medium text-text-secondary outline-none data-[focus-visible]:outline-2 data-[focus-visible]:outline-ring data-[focus-visible]:-outline-offset-1 hover:text-accent data-[active-item]:bg-accent-subtle transition-colors`,
|
|
2087
|
+
"aria-label": `${remainingCount}개의 실패 더 보기`,
|
|
2088
|
+
children: labels.moreItems.replace("{count}", String(remainingCount))
|
|
2089
|
+
})] });
|
|
2090
|
+
}
|
|
2091
|
+
//#endregion
|
|
2092
|
+
//#region src/shells/key-value-editor.tsx
|
|
2093
|
+
const defaultLabels$5 = {
|
|
2094
|
+
keyPlaceholder: "키",
|
|
2095
|
+
valuePlaceholder: "값",
|
|
2096
|
+
addButton: "추가",
|
|
2097
|
+
removeAriaLabel: "항목 삭제",
|
|
2098
|
+
toggleSecretAriaLabel: "비밀값 토글",
|
|
2099
|
+
emptyMessage: "항목이 없습니다. 추가 버튼을 눌러주세요."
|
|
2100
|
+
};
|
|
2101
|
+
let idCounter = 0;
|
|
2102
|
+
function generateId() {
|
|
2103
|
+
return `kv-${++idCounter}`;
|
|
2104
|
+
}
|
|
2105
|
+
/** Renders the key value editor component. */
|
|
2106
|
+
function KeyValueEditor({ value: controlledValue, defaultValue, onChange, showSecretToggle = false, maxEntries, readOnly = false, labels: customLabels, renderActions, validateKey, className }) {
|
|
2107
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$5), customLabels);
|
|
2108
|
+
const [internalEntries, setInternalEntries] = useState(() => defaultValue !== null && defaultValue !== void 0 ? defaultValue : []);
|
|
2109
|
+
const entries = controlledValue !== null && controlledValue !== void 0 ? controlledValue : internalEntries;
|
|
2110
|
+
const keyInputRef = useRef(null);
|
|
2111
|
+
const updateEntries = useCallback((next) => {
|
|
2112
|
+
if (!controlledValue) setInternalEntries(next);
|
|
2113
|
+
onChange === null || onChange === void 0 || onChange(next);
|
|
2114
|
+
}, [controlledValue, onChange]);
|
|
2115
|
+
const addEntry = useCallback(() => {
|
|
2116
|
+
if (maxEntries && entries.length >= maxEntries) return;
|
|
2117
|
+
const newEntry = {
|
|
2118
|
+
id: generateId(),
|
|
2119
|
+
key: "",
|
|
2120
|
+
value: "",
|
|
2121
|
+
isSecret: false
|
|
2122
|
+
};
|
|
2123
|
+
updateEntries([...entries, newEntry]);
|
|
2124
|
+
requestAnimationFrame(() => {
|
|
2125
|
+
var _keyInputRef$current;
|
|
2126
|
+
(_keyInputRef$current = keyInputRef.current) === null || _keyInputRef$current === void 0 || (_keyInputRef$current = _keyInputRef$current.closest("[data-kv-list]")) === null || _keyInputRef$current === void 0 || (_keyInputRef$current = _keyInputRef$current.querySelector(`[data-kv-id="${newEntry.id}"] [data-kv-key]`)) === null || _keyInputRef$current === void 0 || _keyInputRef$current.focus();
|
|
2127
|
+
});
|
|
2128
|
+
}, [
|
|
2129
|
+
entries,
|
|
2130
|
+
maxEntries,
|
|
2131
|
+
updateEntries
|
|
2132
|
+
]);
|
|
2133
|
+
const removeEntry = useCallback((id) => {
|
|
2134
|
+
updateEntries(entries.filter((e) => e.id !== id));
|
|
2135
|
+
}, [entries, updateEntries]);
|
|
2136
|
+
const updateEntry = useCallback((id, field, val) => {
|
|
2137
|
+
updateEntries(entries.map((e) => e.id === id ? _objectSpread2(_objectSpread2({}, e), {}, { [field]: val }) : e));
|
|
2138
|
+
}, [entries, updateEntries]);
|
|
2139
|
+
const toggleSecret = useCallback((id) => {
|
|
2140
|
+
updateEntries(entries.map((e) => e.id === id ? _objectSpread2(_objectSpread2({}, e), {}, { isSecret: !e.isSecret }) : e));
|
|
2141
|
+
}, [entries, updateEntries]);
|
|
2142
|
+
const canAdd = !readOnly && (!maxEntries || entries.length < maxEntries);
|
|
2143
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2144
|
+
className: cn("gap-group flex flex-col", className),
|
|
2145
|
+
"data-opt-id": "NCBWA",
|
|
2146
|
+
"data-opt-slug": "key-value-editor.KeyValueEditor",
|
|
2147
|
+
children: [entries.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
2148
|
+
className: "text-text-tertiary py-4 text-center text-sm",
|
|
2149
|
+
children: labels.emptyMessage
|
|
2150
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
2151
|
+
className: "gap-element flex flex-col",
|
|
2152
|
+
"data-kv-list": true,
|
|
2153
|
+
children: entries.map((entry, index) => {
|
|
2154
|
+
const keyError = validateKey === null || validateKey === void 0 ? void 0 : validateKey(entry.key, entries);
|
|
2155
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2156
|
+
"data-kv-id": entry.id,
|
|
2157
|
+
className: cn("gap-element flex items-start", "border-border rounded-lg border p-3", "bg-surface"),
|
|
2158
|
+
children: [
|
|
2159
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2160
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
2161
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
2162
|
+
"data-kv-key": true,
|
|
2163
|
+
ref: index === entries.length - 1 ? keyInputRef : void 0,
|
|
2164
|
+
type: "text",
|
|
2165
|
+
value: entry.key,
|
|
2166
|
+
onChange: (e) => updateEntry(entry.id, "key", e.target.value),
|
|
2167
|
+
placeholder: labels.keyPlaceholder,
|
|
2168
|
+
readOnly,
|
|
2169
|
+
"aria-label": `${labels.keyPlaceholder} ${index + 1}`,
|
|
2170
|
+
className: cn("border-border bg-bg-subtle text-text-primary placeholder:text-text-tertiary w-full rounded-md border px-3 py-1.5 font-mono text-sm", "focus:border-accent focus-visible:ring-ring focus-visible:ring-offset-ring-offset focus-visible:ring-2 focus-visible:ring-offset-1", readOnly && "cursor-default opacity-70", keyError && "border-error")
|
|
2171
|
+
}), keyError && /* @__PURE__ */ jsx("span", {
|
|
2172
|
+
className: "text-error text-xs",
|
|
2173
|
+
children: keyError
|
|
2174
|
+
})]
|
|
2175
|
+
}),
|
|
2176
|
+
/* @__PURE__ */ jsx("span", {
|
|
2177
|
+
className: "text-text-tertiary px-1 py-1.5",
|
|
2178
|
+
children: "="
|
|
2179
|
+
}),
|
|
2180
|
+
/* @__PURE__ */ jsx("div", {
|
|
2181
|
+
className: "min-w-0 flex-1",
|
|
2182
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
2183
|
+
type: entry.isSecret ? "password" : "text",
|
|
2184
|
+
value: entry.value,
|
|
2185
|
+
onChange: (e) => updateEntry(entry.id, "value", e.target.value),
|
|
2186
|
+
placeholder: labels.valuePlaceholder,
|
|
2187
|
+
readOnly,
|
|
2188
|
+
"aria-label": `${labels.valuePlaceholder} ${index + 1}`,
|
|
2189
|
+
className: cn("border-border bg-bg-subtle text-text-primary placeholder:text-text-tertiary w-full rounded-md border px-3 py-1.5 font-mono text-sm", "focus:border-accent focus-visible:ring-ring focus-visible:ring-offset-ring-offset focus-visible:ring-2 focus-visible:ring-offset-1", readOnly && "cursor-default opacity-70")
|
|
2190
|
+
})
|
|
2191
|
+
}),
|
|
2192
|
+
showSecretToggle && !readOnly && /* @__PURE__ */ jsx("button", {
|
|
2193
|
+
type: "button",
|
|
2194
|
+
onClick: () => toggleSecret(entry.id),
|
|
2195
|
+
"aria-label": labels.toggleSecretAriaLabel,
|
|
2196
|
+
"aria-pressed": entry.isSecret,
|
|
2197
|
+
className: "text-text-tertiary hover:text-text-primary shrink-0 rounded p-1.5 transition-colors",
|
|
2198
|
+
children: entry.isSecret ? /* @__PURE__ */ jsx("svg", {
|
|
2199
|
+
className: "size-4",
|
|
2200
|
+
fill: "none",
|
|
2201
|
+
viewBox: "0 0 24 24",
|
|
2202
|
+
stroke: "currentColor",
|
|
2203
|
+
strokeWidth: 2,
|
|
2204
|
+
"aria-hidden": "true",
|
|
2205
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
2206
|
+
strokeLinecap: "round",
|
|
2207
|
+
strokeLinejoin: "round",
|
|
2208
|
+
d: "M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"
|
|
2209
|
+
})
|
|
2210
|
+
}) : /* @__PURE__ */ jsxs("svg", {
|
|
2211
|
+
className: "size-4",
|
|
2212
|
+
fill: "none",
|
|
2213
|
+
viewBox: "0 0 24 24",
|
|
2214
|
+
stroke: "currentColor",
|
|
2215
|
+
strokeWidth: 2,
|
|
2216
|
+
"aria-hidden": "true",
|
|
2217
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
2218
|
+
strokeLinecap: "round",
|
|
2219
|
+
strokeLinejoin: "round",
|
|
2220
|
+
d: "M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"
|
|
2221
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
2222
|
+
strokeLinecap: "round",
|
|
2223
|
+
strokeLinejoin: "round",
|
|
2224
|
+
d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
|
2225
|
+
})]
|
|
2226
|
+
})
|
|
2227
|
+
}),
|
|
2228
|
+
renderActions === null || renderActions === void 0 ? void 0 : renderActions(entry, index),
|
|
2229
|
+
!readOnly && /* @__PURE__ */ jsx("button", {
|
|
2230
|
+
type: "button",
|
|
2231
|
+
onClick: () => removeEntry(entry.id),
|
|
2232
|
+
"aria-label": labels.removeAriaLabel,
|
|
2233
|
+
className: "text-text-tertiary hover:text-error shrink-0 rounded p-1.5 transition-colors",
|
|
2234
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
2235
|
+
className: "size-4",
|
|
2236
|
+
fill: "none",
|
|
2237
|
+
viewBox: "0 0 24 24",
|
|
2238
|
+
stroke: "currentColor",
|
|
2239
|
+
strokeWidth: 2,
|
|
2240
|
+
"aria-hidden": "true",
|
|
2241
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
2242
|
+
strokeLinecap: "round",
|
|
2243
|
+
strokeLinejoin: "round",
|
|
2244
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
2245
|
+
})
|
|
2246
|
+
})
|
|
2247
|
+
})
|
|
2248
|
+
]
|
|
2249
|
+
}, entry.id);
|
|
2250
|
+
})
|
|
2251
|
+
}), canAdd && /* @__PURE__ */ jsx("button", {
|
|
2252
|
+
type: "button",
|
|
2253
|
+
onClick: addEntry,
|
|
2254
|
+
className: cn("border-border text-text-secondary rounded-lg border border-dashed px-4 py-2 text-sm transition-colors", "hover:border-accent hover:text-accent"),
|
|
2255
|
+
children: labels.addButton
|
|
2256
|
+
})]
|
|
2257
|
+
});
|
|
2258
|
+
}
|
|
2259
|
+
//#endregion
|
|
2260
|
+
//#region src/shells/workflow-canvas.tsx
|
|
2261
|
+
const statusVariant = {
|
|
2262
|
+
idle: "default",
|
|
2263
|
+
running: "info",
|
|
2264
|
+
success: "success",
|
|
2265
|
+
error: "error"
|
|
2266
|
+
};
|
|
2267
|
+
function clamp(value, min, max) {
|
|
2268
|
+
return Math.max(min, Math.min(max, value));
|
|
2269
|
+
}
|
|
2270
|
+
/** Renders the workflow canvas component. */
|
|
2271
|
+
function WorkflowCanvas({ steps, connections = [], rows = 9, cols = 9, cellSize = 72, gap = 12, title = "Workflow Canvas", emptyMessage = "No workflow steps", selectedStepId, onSelectStep, onStepMove, renderStep, className }) {
|
|
2272
|
+
const stepMap = React.useMemo(() => new Map(steps.map((step) => [step.id, step])), [steps]);
|
|
2273
|
+
const width = cols * cellSize + (cols - 1) * gap;
|
|
2274
|
+
const height = rows * cellSize + (rows - 1) * gap;
|
|
2275
|
+
const renderDefaultStep = React.useCallback((step, selected) => /* @__PURE__ */ jsxs("button", {
|
|
2276
|
+
type: "button",
|
|
2277
|
+
onClick: () => onSelectStep === null || onSelectStep === void 0 ? void 0 : onSelectStep(step),
|
|
2278
|
+
className: cn("group absolute flex h-full w-full flex-col justify-between rounded-lg border p-2 text-left transition-colors", selected ? "border-accent bg-accent-subtle" : "border-border bg-surface hover:bg-bg-subtle"),
|
|
2279
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2280
|
+
className: "text-text-primary truncate text-xs font-medium",
|
|
2281
|
+
children: step.title
|
|
2282
|
+
}), step.status && /* @__PURE__ */ jsx(Badge, {
|
|
2283
|
+
variant: statusVariant[step.status],
|
|
2284
|
+
size: "sm",
|
|
2285
|
+
className: "w-fit",
|
|
2286
|
+
children: step.status
|
|
2287
|
+
})]
|
|
2288
|
+
}), [onSelectStep]);
|
|
2289
|
+
const handleStepKeyDown = React.useCallback((event, step) => {
|
|
2290
|
+
if (!onStepMove) return;
|
|
2291
|
+
let nextRow = step.row;
|
|
2292
|
+
let nextCol = step.col;
|
|
2293
|
+
switch (event.key) {
|
|
2294
|
+
case "ArrowUp":
|
|
2295
|
+
nextRow -= 1;
|
|
2296
|
+
break;
|
|
2297
|
+
case "ArrowDown":
|
|
2298
|
+
nextRow += 1;
|
|
2299
|
+
break;
|
|
2300
|
+
case "ArrowLeft":
|
|
2301
|
+
nextCol -= 1;
|
|
2302
|
+
break;
|
|
2303
|
+
case "ArrowRight":
|
|
2304
|
+
nextCol += 1;
|
|
2305
|
+
break;
|
|
2306
|
+
default: return;
|
|
2307
|
+
}
|
|
2308
|
+
event.preventDefault();
|
|
2309
|
+
onStepMove(step.id, clamp(nextRow, 0, rows - 1), clamp(nextCol, 0, cols - 1));
|
|
2310
|
+
}, [
|
|
2311
|
+
onStepMove,
|
|
2312
|
+
rows,
|
|
2313
|
+
cols
|
|
2314
|
+
]);
|
|
2315
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2316
|
+
className: cn("gap-group flex flex-col", className),
|
|
2317
|
+
"data-opt-id": "4TX11",
|
|
2318
|
+
"data-opt-slug": "workflow-canvas.WorkflowCanvas",
|
|
2319
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
2320
|
+
className: "text-text-primary text-sm font-semibold",
|
|
2321
|
+
children: title
|
|
2322
|
+
}), steps.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
2323
|
+
className: "text-text-secondary border-border rounded-lg border border-dashed p-8 text-center text-sm",
|
|
2324
|
+
children: emptyMessage
|
|
2325
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
2326
|
+
className: "border-border bg-bg-subtle relative overflow-auto rounded-lg border p-3",
|
|
2327
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2328
|
+
role: "grid",
|
|
2329
|
+
"aria-label": title,
|
|
2330
|
+
className: "relative",
|
|
2331
|
+
style: {
|
|
2332
|
+
width,
|
|
2333
|
+
height
|
|
2334
|
+
},
|
|
2335
|
+
children: [
|
|
2336
|
+
/* @__PURE__ */ jsx("div", {
|
|
2337
|
+
className: "grid",
|
|
2338
|
+
style: {
|
|
2339
|
+
gridTemplateColumns: `repeat(${cols}, ${cellSize}px)`,
|
|
2340
|
+
gridTemplateRows: `repeat(${rows}, ${cellSize}px)`,
|
|
2341
|
+
gap
|
|
2342
|
+
},
|
|
2343
|
+
children: Array.from({ length: rows * cols }, (_, i) => /* @__PURE__ */ jsx("div", {
|
|
2344
|
+
"aria-hidden": "true",
|
|
2345
|
+
className: "border-border-subtle bg-surface/30 rounded-md border border-dashed"
|
|
2346
|
+
}, i))
|
|
2347
|
+
}),
|
|
2348
|
+
/* @__PURE__ */ jsx("svg", {
|
|
2349
|
+
className: "pointer-events-none absolute inset-0",
|
|
2350
|
+
width,
|
|
2351
|
+
height,
|
|
2352
|
+
"aria-hidden": "true",
|
|
2353
|
+
children: connections.map((connection) => {
|
|
2354
|
+
const from = stepMap.get(connection.from);
|
|
2355
|
+
const to = stepMap.get(connection.to);
|
|
2356
|
+
if (!from || !to) return null;
|
|
2357
|
+
const x1 = from.col * (cellSize + gap) + cellSize / 2;
|
|
2358
|
+
const y1 = from.row * (cellSize + gap) + cellSize / 2;
|
|
2359
|
+
const x2 = to.col * (cellSize + gap) + cellSize / 2;
|
|
2360
|
+
const y2 = to.row * (cellSize + gap) + cellSize / 2;
|
|
2361
|
+
return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
2362
|
+
x1,
|
|
2363
|
+
y1,
|
|
2364
|
+
x2,
|
|
2365
|
+
y2,
|
|
2366
|
+
stroke: "currentColor",
|
|
2367
|
+
strokeOpacity: "0.35",
|
|
2368
|
+
strokeWidth: "2"
|
|
2369
|
+
}), connection.label && /* @__PURE__ */ jsx("text", {
|
|
2370
|
+
x: (x1 + x2) / 2,
|
|
2371
|
+
y: (y1 + y2) / 2 - 4,
|
|
2372
|
+
textAnchor: "middle",
|
|
2373
|
+
className: "fill-text-secondary text-[10px]",
|
|
2374
|
+
children: connection.label
|
|
2375
|
+
})] }, `${connection.from}-${connection.to}`);
|
|
2376
|
+
})
|
|
2377
|
+
}),
|
|
2378
|
+
steps.map((step) => {
|
|
2379
|
+
const selected = selectedStepId === step.id;
|
|
2380
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2381
|
+
role: "gridcell",
|
|
2382
|
+
tabIndex: 0,
|
|
2383
|
+
"aria-selected": selected,
|
|
2384
|
+
"aria-label": `${step.title} (${step.row + 1}, ${step.col + 1})`,
|
|
2385
|
+
onKeyDown: (event) => handleStepKeyDown(event, step),
|
|
2386
|
+
className: "focus-visible:ring-ring absolute focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-white focus-visible:outline-none",
|
|
2387
|
+
style: {
|
|
2388
|
+
width: cellSize,
|
|
2389
|
+
height: cellSize,
|
|
2390
|
+
left: step.col * (cellSize + gap),
|
|
2391
|
+
top: step.row * (cellSize + gap)
|
|
2392
|
+
},
|
|
2393
|
+
children: renderStep ? renderStep(step, selected) : renderDefaultStep(step, selected)
|
|
2394
|
+
}, step.id);
|
|
2395
|
+
})
|
|
2396
|
+
]
|
|
2397
|
+
})
|
|
2398
|
+
})]
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2401
|
+
WorkflowCanvas.displayName = "WorkflowCanvas";
|
|
2402
|
+
//#endregion
|
|
2403
|
+
//#region src/lib/use-auto-refresh.ts
|
|
2404
|
+
/**
|
|
2405
|
+
* A refresh timer that waits for its own work.
|
|
2406
|
+
*
|
|
2407
|
+
* A plain `setInterval` fires on a schedule regardless of whether the previous
|
|
2408
|
+
* query came back, so a five-second interval over a seven-second query stacks
|
|
2409
|
+
* requests until something gives. Chaining the next wait onto the settled
|
|
2410
|
+
* promise keeps exactly one refresh in flight, and a rejection stops the loop
|
|
2411
|
+
* instead of hammering an endpoint that is already failing.
|
|
2412
|
+
*/
|
|
2413
|
+
function useAutoRefresh({ interval, paused = false, onRefresh }) {
|
|
2414
|
+
const callbackRef = useRef(onRefresh);
|
|
2415
|
+
callbackRef.current = onRefresh;
|
|
2416
|
+
useEffect(() => {
|
|
2417
|
+
if (paused || interval <= 0 || !callbackRef.current) return;
|
|
2418
|
+
let cancelled = false;
|
|
2419
|
+
let timer;
|
|
2420
|
+
const schedule = () => {
|
|
2421
|
+
timer = setTimeout(async () => {
|
|
2422
|
+
if (cancelled) return;
|
|
2423
|
+
try {
|
|
2424
|
+
var _callbackRef$current;
|
|
2425
|
+
await ((_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef));
|
|
2426
|
+
} catch (_unused) {
|
|
2427
|
+
return;
|
|
2428
|
+
}
|
|
2429
|
+
if (!cancelled) schedule();
|
|
2430
|
+
}, interval);
|
|
2431
|
+
};
|
|
2432
|
+
schedule();
|
|
2433
|
+
return () => {
|
|
2434
|
+
cancelled = true;
|
|
2435
|
+
if (timer) clearTimeout(timer);
|
|
2436
|
+
};
|
|
2437
|
+
}, [interval, paused]);
|
|
2438
|
+
}
|
|
2439
|
+
//#endregion
|
|
2440
|
+
//#region src/shells/time-range-control.tsx
|
|
2441
|
+
const defaultLabels$4 = {
|
|
2442
|
+
trigger: "Select time range",
|
|
2443
|
+
invalid: "Invalid time range",
|
|
2444
|
+
last: (duration) => `Last ${duration}`,
|
|
2445
|
+
next: (duration) => `Next ${duration}`,
|
|
2446
|
+
quickSelect: "Quick select",
|
|
2447
|
+
apply: "Apply",
|
|
2448
|
+
update: "Update",
|
|
2449
|
+
refresh: "Refresh",
|
|
2450
|
+
commonlyUsed: "Commonly used",
|
|
2451
|
+
recentlyUsed: "Recently used",
|
|
2452
|
+
start: "Start",
|
|
2453
|
+
end: "End",
|
|
2454
|
+
startHint: "Absolute time or date math, e.g. now-7d",
|
|
2455
|
+
autoRefresh: "Auto refresh",
|
|
2456
|
+
autoRefreshOff: "Off",
|
|
2457
|
+
every: (duration) => `Every ${duration}`,
|
|
2458
|
+
previous: "Previous window",
|
|
2459
|
+
nextWindow: "Next window",
|
|
2460
|
+
zoomIn: "Zoom in",
|
|
2461
|
+
zoomOut: "Zoom out",
|
|
2462
|
+
thisUnit: (unit) => `This ${unit}`,
|
|
2463
|
+
units: {
|
|
2464
|
+
s: "seconds",
|
|
2465
|
+
m: "minutes",
|
|
2466
|
+
h: "hours",
|
|
2467
|
+
d: "days",
|
|
2468
|
+
w: "weeks",
|
|
2469
|
+
M: "months",
|
|
2470
|
+
y: "years"
|
|
2471
|
+
}
|
|
2472
|
+
};
|
|
2473
|
+
const QUICK_UNITS = [
|
|
2474
|
+
"m",
|
|
2475
|
+
"h",
|
|
2476
|
+
"d",
|
|
2477
|
+
"w",
|
|
2478
|
+
"M",
|
|
2479
|
+
"y"
|
|
2480
|
+
];
|
|
2481
|
+
const REFRESH_INTERVALS = [
|
|
2482
|
+
0,
|
|
2483
|
+
5e3,
|
|
2484
|
+
1e4,
|
|
2485
|
+
3e4,
|
|
2486
|
+
6e4,
|
|
2487
|
+
3e5
|
|
2488
|
+
];
|
|
2489
|
+
function selectValue(value) {
|
|
2490
|
+
var _value$;
|
|
2491
|
+
return Array.isArray(value) ? (_value$ = value[0]) !== null && _value$ !== void 0 ? _value$ : "" : value;
|
|
2492
|
+
}
|
|
2493
|
+
/**
|
|
2494
|
+
* What the trigger says.
|
|
2495
|
+
*
|
|
2496
|
+
* A window anchored to `now` deserves its intent ("Last 7 days"), not two
|
|
2497
|
+
* timestamps the reader has to subtract. Everything else gets both ends
|
|
2498
|
+
* spelled out. A duration that does not divide into whole minutes is prefixed
|
|
2499
|
+
* with `~` rather than rounded silently.
|
|
2500
|
+
*/
|
|
2501
|
+
function describeRange(range, labels, options) {
|
|
2502
|
+
const window = measureTimeWindow(range, {
|
|
2503
|
+
timeZone: options.timeZone,
|
|
2504
|
+
now: options.now
|
|
2505
|
+
});
|
|
2506
|
+
if (window.isInvalid) return {
|
|
2507
|
+
text: labels.invalid,
|
|
2508
|
+
isInvalid: true
|
|
2509
|
+
};
|
|
2510
|
+
const fromParts = parseRelativeParts(range.from);
|
|
2511
|
+
const toParts = parseRelativeParts(range.to);
|
|
2512
|
+
if ((fromParts === null || fromParts === void 0 ? void 0 : fromParts.roundUnit) && fromParts.count === 0 && (toParts === null || toParts === void 0 ? void 0 : toParts.roundUnit) === fromParts.roundUnit && toParts.count === 0) return {
|
|
2513
|
+
text: labels.thisUnit(formatCountUnit(1, fromParts.roundUnit, options.locale).replace(/^1\s*/, "")),
|
|
2514
|
+
isInvalid: false
|
|
2515
|
+
};
|
|
2516
|
+
if (isRelativeToNow(range)) {
|
|
2517
|
+
var _toParts$count;
|
|
2518
|
+
const anchoredAtEnd = ((_toParts$count = toParts === null || toParts === void 0 ? void 0 : toParts.count) !== null && _toParts$count !== void 0 ? _toParts$count : 0) === 0;
|
|
2519
|
+
const parts = anchoredAtEnd ? fromParts : toParts;
|
|
2520
|
+
const bothSnapped = (parts === null || parts === void 0 ? void 0 : parts.roundUnit) === (parts === null || parts === void 0 ? void 0 : parts.unit) && (toParts === null || toParts === void 0 ? void 0 : toParts.roundUnit) === (parts === null || parts === void 0 ? void 0 : parts.unit);
|
|
2521
|
+
const counted = parts && parts.count > 0 ? formatCountUnit(parts.roundUnit && bothSnapped ? parts.count + 1 : parts.count, parts.unit, options.locale) : null;
|
|
2522
|
+
const exact = counted !== null && (!(parts === null || parts === void 0 ? void 0 : parts.roundUnit) || bothSnapped);
|
|
2523
|
+
const duration = exact ? counted : formatDuration(window.duration, options.locale);
|
|
2524
|
+
const prefix = exact || isExactMinutes(window.duration) ? "" : "~";
|
|
2525
|
+
return {
|
|
2526
|
+
text: anchoredAtEnd ? labels.last(`${prefix}${duration}`) : labels.next(`${prefix}${duration}`),
|
|
2527
|
+
isInvalid: false
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
const dateOnly = isDateOnly(range.from) && isDateOnly(range.to);
|
|
2531
|
+
const from = formatInstant(window.from, _objectSpread2(_objectSpread2({}, options), {}, { dateOnly }));
|
|
2532
|
+
const to = formatInstant(window.to, _objectSpread2(_objectSpread2({}, options), {}, { dateOnly }));
|
|
2533
|
+
return {
|
|
2534
|
+
text: from === to ? from : `${from} – ${to}`,
|
|
2535
|
+
isInvalid: false
|
|
2536
|
+
};
|
|
2537
|
+
}
|
|
2538
|
+
/**
|
|
2539
|
+
* TimeRangeControl — the window as an expression, not two frozen instants.
|
|
2540
|
+
*
|
|
2541
|
+
* Holding `{ from: "now-7d", to: "now" }` instead of a resolved pair is what
|
|
2542
|
+
* makes a saved board, a shared link and an auto-refresh timer all mean the
|
|
2543
|
+
* same thing tomorrow that they mean today. Around that sit the moves people
|
|
2544
|
+
* actually make on a chart: jump to a named window, step the same width back
|
|
2545
|
+
* and forth to compare, widen when the interesting thing is just off screen,
|
|
2546
|
+
* and let it re-query on a timer while they watch.
|
|
2547
|
+
*
|
|
2548
|
+
* @example
|
|
2549
|
+
* ```tsx
|
|
2550
|
+
* const [range, setRange] = useState<TimeRange>({ from: "now-7d", to: "now" });
|
|
2551
|
+
*
|
|
2552
|
+
* <TimeRangeControl
|
|
2553
|
+
* value={range}
|
|
2554
|
+
* onChange={setRange}
|
|
2555
|
+
* timeZone="Asia/Seoul"
|
|
2556
|
+
* showWindowButtons
|
|
2557
|
+
* onRefresh={() => refetch()}
|
|
2558
|
+
* />
|
|
2559
|
+
* ```
|
|
2560
|
+
*/
|
|
2561
|
+
function TimeRangeControl({ value, onChange, presets, recentRanges, timeZone, locale, showUpdateButton = true, showWindowButtons = true, zoomFactor = .5, refresh, onRefreshChange, onRefresh, isLoading = false, disabled = false, className, labels: customLabels, "aria-label": ariaLabel }) {
|
|
2562
|
+
var _refresh$interval, _refresh$paused, _refresh$interval2;
|
|
2563
|
+
const labels = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultLabels$4), customLabels), {}, { units: _objectSpread2(_objectSpread2({}, defaultLabels$4.units), customLabels === null || customLabels === void 0 ? void 0 : customLabels.units) });
|
|
2564
|
+
const [open, setOpen] = useState(false);
|
|
2565
|
+
const [draft, setDraft] = useState(null);
|
|
2566
|
+
const [quickCount, setQuickCount] = useState("15");
|
|
2567
|
+
const [quickUnit, setQuickUnit] = useState("m");
|
|
2568
|
+
const editing = draft !== null && draft !== void 0 ? draft : value;
|
|
2569
|
+
const hasChanges = draft !== null && (draft.from !== value.from || draft.to !== value.to);
|
|
2570
|
+
const description = useMemo(() => describeRange(value, labels, {
|
|
2571
|
+
locale,
|
|
2572
|
+
timeZone
|
|
2573
|
+
}), [
|
|
2574
|
+
value,
|
|
2575
|
+
locale,
|
|
2576
|
+
timeZone,
|
|
2577
|
+
customLabels
|
|
2578
|
+
]);
|
|
2579
|
+
const boundState = useCallback((expression) => parseTimeExpression(expression, { timeZone }) === null ? labels.invalid : void 0, [timeZone, labels]);
|
|
2580
|
+
const commit = useCallback((range) => {
|
|
2581
|
+
setDraft(null);
|
|
2582
|
+
onChange(range);
|
|
2583
|
+
}, [onChange]);
|
|
2584
|
+
const apply = useCallback(() => {
|
|
2585
|
+
if (draft) commit(draft);
|
|
2586
|
+
else onRefresh === null || onRefresh === void 0 || onRefresh();
|
|
2587
|
+
}, [
|
|
2588
|
+
draft,
|
|
2589
|
+
commit,
|
|
2590
|
+
onRefresh
|
|
2591
|
+
]);
|
|
2592
|
+
const commitOnEnter = useCallback((event) => {
|
|
2593
|
+
if (event.key !== "Enter") return;
|
|
2594
|
+
apply();
|
|
2595
|
+
setOpen(false);
|
|
2596
|
+
}, [apply]);
|
|
2597
|
+
const applyQuick = useCallback(() => {
|
|
2598
|
+
const count = Number(quickCount);
|
|
2599
|
+
if (!Number.isFinite(count) || count <= 0) return;
|
|
2600
|
+
commit({
|
|
2601
|
+
from: `now-${Math.round(count)}${quickUnit}`,
|
|
2602
|
+
to: "now"
|
|
2603
|
+
});
|
|
2604
|
+
setOpen(false);
|
|
2605
|
+
}, [
|
|
2606
|
+
quickCount,
|
|
2607
|
+
quickUnit,
|
|
2608
|
+
commit
|
|
2609
|
+
]);
|
|
2610
|
+
const step = useCallback((direction) => {
|
|
2611
|
+
const next = shiftTimeRange(value, direction, { timeZone });
|
|
2612
|
+
if (next) commit(next);
|
|
2613
|
+
}, [
|
|
2614
|
+
value,
|
|
2615
|
+
timeZone,
|
|
2616
|
+
commit
|
|
2617
|
+
]);
|
|
2618
|
+
const zoom = useCallback((factor) => {
|
|
2619
|
+
const next = zoomTimeRange(value, factor, { timeZone });
|
|
2620
|
+
if (next) commit(next);
|
|
2621
|
+
}, [
|
|
2622
|
+
value,
|
|
2623
|
+
timeZone,
|
|
2624
|
+
commit
|
|
2625
|
+
]);
|
|
2626
|
+
useAutoRefresh({
|
|
2627
|
+
interval: (_refresh$interval = refresh === null || refresh === void 0 ? void 0 : refresh.interval) !== null && _refresh$interval !== void 0 ? _refresh$interval : 0,
|
|
2628
|
+
paused: (_refresh$paused = refresh === null || refresh === void 0 ? void 0 : refresh.paused) !== null && _refresh$paused !== void 0 ? _refresh$paused : true,
|
|
2629
|
+
onRefresh
|
|
2630
|
+
});
|
|
2631
|
+
const refreshLabel = !refresh || refresh.paused || refresh.interval === 0 ? labels.autoRefreshOff : labels.every(formatDuration(refresh.interval, locale));
|
|
2632
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2633
|
+
className: cn("bg-surface inline-flex items-center rounded-lg border", OPT_BORDER, className),
|
|
2634
|
+
role: "group",
|
|
2635
|
+
"aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : labels.trigger,
|
|
2636
|
+
"data-opt-id": "3WJ8H",
|
|
2637
|
+
"data-opt-slug": "time-range-control.TimeRangeControl",
|
|
2638
|
+
children: [
|
|
2639
|
+
/* @__PURE__ */ jsxs(PopoverRoot$1, {
|
|
2640
|
+
open,
|
|
2641
|
+
onOpenChange: setOpen,
|
|
2642
|
+
children: [/* @__PURE__ */ jsxs(PopoverTrigger$1, {
|
|
2643
|
+
className: cn("text-text-primary h-10 gap-2", description.isInvalid && "text-danger-fg"),
|
|
2644
|
+
disabled,
|
|
2645
|
+
children: [/* @__PURE__ */ jsx(Clock, {
|
|
2646
|
+
className: "text-text-tertiary h-4 w-4",
|
|
2647
|
+
"aria-hidden": "true"
|
|
2648
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2649
|
+
className: "truncate text-sm",
|
|
2650
|
+
children: description.text
|
|
2651
|
+
})]
|
|
2652
|
+
}), /* @__PURE__ */ jsxs(PopoverContent$1, {
|
|
2653
|
+
className: "gap-group flex w-80 flex-col",
|
|
2654
|
+
children: [
|
|
2655
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2656
|
+
className: "gap-element flex flex-col",
|
|
2657
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
2658
|
+
className: "text-text-primary text-xs font-medium",
|
|
2659
|
+
children: labels.quickSelect
|
|
2660
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2661
|
+
className: "flex items-end gap-2",
|
|
2662
|
+
children: [
|
|
2663
|
+
/* @__PURE__ */ jsx(Input, {
|
|
2664
|
+
"aria-label": labels.quickSelect,
|
|
2665
|
+
type: "number",
|
|
2666
|
+
min: 1,
|
|
2667
|
+
size: "sm",
|
|
2668
|
+
className: "w-20",
|
|
2669
|
+
value: quickCount,
|
|
2670
|
+
onChange: (event) => setQuickCount(event.target.value),
|
|
2671
|
+
onKeyDown: (event) => {
|
|
2672
|
+
if (event.key === "Enter") applyQuick();
|
|
2673
|
+
}
|
|
2674
|
+
}),
|
|
2675
|
+
/* @__PURE__ */ jsxs(SelectRoot$1, {
|
|
2676
|
+
value: quickUnit,
|
|
2677
|
+
setValue: (next) => setQuickUnit(selectValue(next)),
|
|
2678
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger$1, {
|
|
2679
|
+
minWidth: 110,
|
|
2680
|
+
"aria-label": labels.quickSelect
|
|
2681
|
+
}), /* @__PURE__ */ jsx(SelectPopover$1, { children: QUICK_UNITS.map((unit) => /* @__PURE__ */ jsx(SelectItem$1, {
|
|
2682
|
+
value: unit,
|
|
2683
|
+
children: labels.units[unit]
|
|
2684
|
+
}, unit)) })]
|
|
2685
|
+
}),
|
|
2686
|
+
/* @__PURE__ */ jsx(Button, {
|
|
2687
|
+
variant: "secondary",
|
|
2688
|
+
size: "sm",
|
|
2689
|
+
onClick: applyQuick,
|
|
2690
|
+
children: labels.apply
|
|
2691
|
+
})
|
|
2692
|
+
]
|
|
2693
|
+
})]
|
|
2694
|
+
}),
|
|
2695
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2696
|
+
className: "gap-element flex flex-col",
|
|
2697
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
2698
|
+
label: labels.start,
|
|
2699
|
+
size: "sm",
|
|
2700
|
+
value: editing.from,
|
|
2701
|
+
error: boundState(editing.from),
|
|
2702
|
+
hint: labels.startHint,
|
|
2703
|
+
onChange: (event) => setDraft(_objectSpread2(_objectSpread2({}, editing), {}, { from: event.target.value })),
|
|
2704
|
+
onKeyDown: commitOnEnter
|
|
2705
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
2706
|
+
label: labels.end,
|
|
2707
|
+
size: "sm",
|
|
2708
|
+
value: editing.to,
|
|
2709
|
+
error: boundState(editing.to),
|
|
2710
|
+
onChange: (event) => setDraft(_objectSpread2(_objectSpread2({}, editing), {}, { to: event.target.value })),
|
|
2711
|
+
onKeyDown: commitOnEnter
|
|
2712
|
+
})]
|
|
2713
|
+
}),
|
|
2714
|
+
presets && presets.length > 0 && /* @__PURE__ */ jsx(RangeList, {
|
|
2715
|
+
title: labels.commonlyUsed,
|
|
2716
|
+
items: presets,
|
|
2717
|
+
onPick: (range) => {
|
|
2718
|
+
commit(range);
|
|
2719
|
+
setOpen(false);
|
|
2720
|
+
}
|
|
2721
|
+
}),
|
|
2722
|
+
recentRanges && recentRanges.length > 0 && /* @__PURE__ */ jsx(RangeList, {
|
|
2723
|
+
title: labels.recentlyUsed,
|
|
2724
|
+
items: recentRanges.slice(0, 5),
|
|
2725
|
+
onPick: (range) => {
|
|
2726
|
+
commit(range);
|
|
2727
|
+
setOpen(false);
|
|
2728
|
+
}
|
|
2729
|
+
}),
|
|
2730
|
+
onRefreshChange && /* @__PURE__ */ jsxs("div", {
|
|
2731
|
+
className: "gap-element flex flex-col",
|
|
2732
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
2733
|
+
className: "text-text-primary text-xs font-medium",
|
|
2734
|
+
children: labels.autoRefresh
|
|
2735
|
+
}), /* @__PURE__ */ jsxs(SelectRoot$1, {
|
|
2736
|
+
value: String((refresh === null || refresh === void 0 ? void 0 : refresh.paused) ? 0 : (_refresh$interval2 = refresh === null || refresh === void 0 ? void 0 : refresh.interval) !== null && _refresh$interval2 !== void 0 ? _refresh$interval2 : 0),
|
|
2737
|
+
setValue: (next) => {
|
|
2738
|
+
const interval = Number(selectValue(next));
|
|
2739
|
+
onRefreshChange({
|
|
2740
|
+
interval,
|
|
2741
|
+
paused: interval === 0
|
|
2742
|
+
});
|
|
2743
|
+
},
|
|
2744
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger$1, {
|
|
2745
|
+
minWidth: 140,
|
|
2746
|
+
"aria-label": labels.autoRefresh
|
|
2747
|
+
}), /* @__PURE__ */ jsx(SelectPopover$1, { children: REFRESH_INTERVALS.map((interval) => /* @__PURE__ */ jsx(SelectItem$1, {
|
|
2748
|
+
value: String(interval),
|
|
2749
|
+
children: interval === 0 ? labels.autoRefreshOff : labels.every(formatDuration(interval, locale))
|
|
2750
|
+
}, interval)) })]
|
|
2751
|
+
})]
|
|
2752
|
+
})
|
|
2753
|
+
]
|
|
2754
|
+
})]
|
|
2755
|
+
}),
|
|
2756
|
+
showWindowButtons && /* @__PURE__ */ jsxs("div", {
|
|
2757
|
+
className: cn("flex items-center border-l", "border border-border"),
|
|
2758
|
+
role: "group",
|
|
2759
|
+
"aria-label": labels.previous,
|
|
2760
|
+
children: [
|
|
2761
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
2762
|
+
label: labels.previous,
|
|
2763
|
+
disabled: disabled || description.isInvalid,
|
|
2764
|
+
onClick: () => step(-1),
|
|
2765
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, {
|
|
2766
|
+
className: "h-4 w-4",
|
|
2767
|
+
"aria-hidden": "true"
|
|
2768
|
+
})
|
|
2769
|
+
}),
|
|
2770
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
2771
|
+
label: labels.zoomIn,
|
|
2772
|
+
disabled: disabled || description.isInvalid,
|
|
2773
|
+
onClick: () => zoom(-zoomFactor),
|
|
2774
|
+
children: /* @__PURE__ */ jsx(ZoomIn, {
|
|
2775
|
+
className: "h-4 w-4",
|
|
2776
|
+
"aria-hidden": "true"
|
|
2777
|
+
})
|
|
2778
|
+
}),
|
|
2779
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
2780
|
+
label: labels.zoomOut,
|
|
2781
|
+
disabled: disabled || description.isInvalid,
|
|
2782
|
+
onClick: () => zoom(zoomFactor),
|
|
2783
|
+
children: /* @__PURE__ */ jsx(ZoomOut, {
|
|
2784
|
+
className: "h-4 w-4",
|
|
2785
|
+
"aria-hidden": "true"
|
|
2786
|
+
})
|
|
2787
|
+
}),
|
|
2788
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
2789
|
+
label: labels.nextWindow,
|
|
2790
|
+
disabled: disabled || description.isInvalid,
|
|
2791
|
+
onClick: () => step(1),
|
|
2792
|
+
children: /* @__PURE__ */ jsx(ChevronRight, {
|
|
2793
|
+
className: "h-4 w-4",
|
|
2794
|
+
"aria-hidden": "true"
|
|
2795
|
+
})
|
|
2796
|
+
})
|
|
2797
|
+
]
|
|
2798
|
+
}),
|
|
2799
|
+
(onRefresh || showUpdateButton) && /* @__PURE__ */ jsx("div", {
|
|
2800
|
+
className: cn("border-l pl-2 pr-2", "border border-border"),
|
|
2801
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
2802
|
+
variant: hasChanges ? "primary" : "secondary",
|
|
2803
|
+
size: "sm",
|
|
2804
|
+
loading: isLoading,
|
|
2805
|
+
disabled: disabled || description.isInvalid,
|
|
2806
|
+
onClick: apply,
|
|
2807
|
+
leftIcon: hasChanges ? void 0 : /* @__PURE__ */ jsx(RefreshCw, {
|
|
2808
|
+
className: "h-3.5 w-3.5",
|
|
2809
|
+
"aria-hidden": "true"
|
|
2810
|
+
}),
|
|
2811
|
+
title: refreshLabel,
|
|
2812
|
+
children: hasChanges ? labels.update : labels.refresh
|
|
2813
|
+
})
|
|
2814
|
+
})
|
|
2815
|
+
]
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2818
|
+
TimeRangeControl.displayName = "TimeRangeControl";
|
|
2819
|
+
function IconButton({ label, disabled, onClick, children }) {
|
|
2820
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
2821
|
+
variant: "ghost",
|
|
2822
|
+
size: "sm",
|
|
2823
|
+
"aria-label": label,
|
|
2824
|
+
title: label,
|
|
2825
|
+
disabled,
|
|
2826
|
+
onClick,
|
|
2827
|
+
children
|
|
2828
|
+
});
|
|
2829
|
+
}
|
|
2830
|
+
function RangeList({ title, items, onPick }) {
|
|
2831
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2832
|
+
className: "gap-element flex flex-col",
|
|
2833
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
2834
|
+
className: "text-text-primary text-xs font-medium",
|
|
2835
|
+
children: title
|
|
2836
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
2837
|
+
className: "grid grid-cols-2 gap-1",
|
|
2838
|
+
children: items.map((item, index) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
2839
|
+
type: "button",
|
|
2840
|
+
className: cn("hover:bg-bg-subtle w-full cursor-pointer rounded px-2 py-1 text-left text-xs", OPT_TEXT_SECONDARY),
|
|
2841
|
+
onClick: () => onPick(item.range),
|
|
2842
|
+
children: item.label
|
|
2843
|
+
}) }, `${item.label}-${index}`))
|
|
2844
|
+
})]
|
|
2845
|
+
});
|
|
2846
|
+
}
|
|
2847
|
+
/**
|
|
2848
|
+
* The windows most analytics tools open with. Exported so a caller gets a
|
|
2849
|
+
* sensible list without inventing date math of their own.
|
|
2850
|
+
*/
|
|
2851
|
+
const DEFAULT_TIME_PRESETS = [
|
|
2852
|
+
{
|
|
2853
|
+
label: "Last 15 minutes",
|
|
2854
|
+
range: {
|
|
2855
|
+
from: "now-15m",
|
|
2856
|
+
to: "now"
|
|
2857
|
+
}
|
|
2858
|
+
},
|
|
2859
|
+
{
|
|
2860
|
+
label: "Last hour",
|
|
2861
|
+
range: {
|
|
2862
|
+
from: "now-1h",
|
|
2863
|
+
to: "now"
|
|
2864
|
+
}
|
|
2865
|
+
},
|
|
2866
|
+
{
|
|
2867
|
+
label: "Last 24 hours",
|
|
2868
|
+
range: {
|
|
2869
|
+
from: "now-24h",
|
|
2870
|
+
to: "now"
|
|
2871
|
+
}
|
|
2872
|
+
},
|
|
2873
|
+
{
|
|
2874
|
+
label: "Last 7 days",
|
|
2875
|
+
range: {
|
|
2876
|
+
from: "now-7d",
|
|
2877
|
+
to: "now"
|
|
2878
|
+
}
|
|
2879
|
+
},
|
|
2880
|
+
{
|
|
2881
|
+
label: "Last 30 days",
|
|
2882
|
+
range: {
|
|
2883
|
+
from: "now-30d",
|
|
2884
|
+
to: "now"
|
|
2885
|
+
}
|
|
2886
|
+
},
|
|
2887
|
+
{
|
|
2888
|
+
label: "Last 90 days",
|
|
2889
|
+
range: {
|
|
2890
|
+
from: "now-90d",
|
|
2891
|
+
to: "now"
|
|
2892
|
+
}
|
|
2893
|
+
},
|
|
2894
|
+
{
|
|
2895
|
+
label: "Today",
|
|
2896
|
+
range: {
|
|
2897
|
+
from: "now/d",
|
|
2898
|
+
to: "now/d"
|
|
2899
|
+
}
|
|
2900
|
+
},
|
|
2901
|
+
{
|
|
2902
|
+
label: "This week",
|
|
2903
|
+
range: {
|
|
2904
|
+
from: "now/w",
|
|
2905
|
+
to: "now/w"
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
];
|
|
2909
|
+
//#endregion
|
|
2910
|
+
//#region src/shells/time-series-panel.tsx
|
|
2911
|
+
const defaultLabels$3 = {
|
|
2912
|
+
back: "Back to previous range",
|
|
2913
|
+
legend: "Series"
|
|
2914
|
+
};
|
|
2915
|
+
/**
|
|
2916
|
+
* TimeSeriesPanel — a chart you can steer.
|
|
2917
|
+
*
|
|
2918
|
+
* The point of putting the control and the chart in one component is the
|
|
2919
|
+
* loop between them: drag across the plot and the window narrows to what you
|
|
2920
|
+
* dragged, which re-queries, which redraws the axis you just picked. That
|
|
2921
|
+
* only works if someone owns the step back out again — so zoom keeps a
|
|
2922
|
+
* history, and the header offers the way back rather than leaving the reader
|
|
2923
|
+
* to retype the range they came from.
|
|
2924
|
+
*
|
|
2925
|
+
* @example
|
|
2926
|
+
* ```tsx
|
|
2927
|
+
* const [range, setRange] = useState<TimeRange>({ from: "now-7d", to: "now" });
|
|
2928
|
+
*
|
|
2929
|
+
* <TimeSeriesPanel
|
|
2930
|
+
* title="Sessions"
|
|
2931
|
+
* data={points}
|
|
2932
|
+
* series={[{ dataKey: "sessions", name: "Sessions" }]}
|
|
2933
|
+
* range={range}
|
|
2934
|
+
* onRangeChange={setRange}
|
|
2935
|
+
* onRefresh={() => refetch()}
|
|
2936
|
+
* toggleableLegend
|
|
2937
|
+
* />
|
|
2938
|
+
* ```
|
|
2939
|
+
*/
|
|
2940
|
+
function TimeSeriesPanel({ title, description, actions, data, series, range, onRangeChange, granularity = "auto", timeZone, locale, showRangeControl = true, presets, recentRanges, refresh, onRefreshChange, onRefresh, toggleableLegend = false, annotations, isLoading = false, height = 280, className, chartProps, labels: customLabels, "aria-label": ariaLabel }) {
|
|
2941
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$3), customLabels);
|
|
2942
|
+
const [history, setHistory] = useState([]);
|
|
2943
|
+
const [hidden, setHidden] = useState([]);
|
|
2944
|
+
const resolved = useMemo(() => resolveTimeRange(range, { timeZone }), [range, timeZone]);
|
|
2945
|
+
const visibleSeries = useMemo(() => series.filter((def) => !hidden.includes(def.dataKey)), [series, hidden]);
|
|
2946
|
+
const handleRangeSelect = useCallback((selection) => {
|
|
2947
|
+
setHistory((current) => [...current, range].slice(-10));
|
|
2948
|
+
onRangeChange(toAbsoluteRange(selection));
|
|
2949
|
+
}, [range, onRangeChange]);
|
|
2950
|
+
const goBack = useCallback(() => {
|
|
2951
|
+
setHistory((current) => {
|
|
2952
|
+
const previous = current[current.length - 1];
|
|
2953
|
+
if (previous) onRangeChange(previous);
|
|
2954
|
+
return current.slice(0, -1);
|
|
2955
|
+
});
|
|
2956
|
+
}, [onRangeChange]);
|
|
2957
|
+
const setRange = useCallback((next) => {
|
|
2958
|
+
setHistory([]);
|
|
2959
|
+
onRangeChange(next);
|
|
2960
|
+
}, [onRangeChange]);
|
|
2961
|
+
const toggleSeries = useCallback((dataKey) => {
|
|
2962
|
+
setHidden((current) => current.includes(dataKey) ? current.filter((key) => key !== dataKey) : [...current, dataKey]);
|
|
2963
|
+
}, []);
|
|
2964
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
2965
|
+
className: cn(OPT_SURFACE, OPT_BORDER, "flex flex-col", className),
|
|
2966
|
+
"aria-label": ariaLabel,
|
|
2967
|
+
"data-opt-id": "Y0XCY",
|
|
2968
|
+
"data-opt-slug": "time-series-panel.TimeSeriesPanel",
|
|
2969
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
2970
|
+
className: "gap-group flex flex-wrap items-start justify-between px-5 pt-5 pb-3",
|
|
2971
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2972
|
+
className: "gap-element flex min-w-0 flex-col",
|
|
2973
|
+
children: [title && /* @__PURE__ */ jsx("h3", {
|
|
2974
|
+
className: "text-text-primary truncate text-base font-semibold",
|
|
2975
|
+
children: title
|
|
2976
|
+
}), description && /* @__PURE__ */ jsx("p", {
|
|
2977
|
+
className: cn("text-text-secondary", "truncate text-sm"),
|
|
2978
|
+
children: description
|
|
2979
|
+
})]
|
|
2980
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2981
|
+
className: "gap-element flex flex-wrap items-center",
|
|
2982
|
+
children: [
|
|
2983
|
+
history.length > 0 && /* @__PURE__ */ jsx(Button, {
|
|
2984
|
+
variant: "ghost",
|
|
2985
|
+
size: "sm",
|
|
2986
|
+
onClick: goBack,
|
|
2987
|
+
leftIcon: /* @__PURE__ */ jsx(Undo2, {
|
|
2988
|
+
className: "h-3.5 w-3.5",
|
|
2989
|
+
"aria-hidden": "true"
|
|
2990
|
+
}),
|
|
2991
|
+
children: labels.back
|
|
2992
|
+
}),
|
|
2993
|
+
actions,
|
|
2994
|
+
showRangeControl && /* @__PURE__ */ jsx(TimeRangeControl, {
|
|
2995
|
+
value: range,
|
|
2996
|
+
onChange: setRange,
|
|
2997
|
+
presets,
|
|
2998
|
+
recentRanges,
|
|
2999
|
+
timeZone,
|
|
3000
|
+
locale,
|
|
3001
|
+
refresh,
|
|
3002
|
+
onRefreshChange,
|
|
3003
|
+
onRefresh,
|
|
3004
|
+
isLoading,
|
|
3005
|
+
labels: customLabels === null || customLabels === void 0 ? void 0 : customLabels.control
|
|
3006
|
+
})
|
|
3007
|
+
]
|
|
3008
|
+
})]
|
|
3009
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3010
|
+
className: "px-2 pb-4",
|
|
3011
|
+
children: /* @__PURE__ */ jsx(TimeSeriesChart, _objectSpread2({
|
|
3012
|
+
data,
|
|
3013
|
+
series: visibleSeries,
|
|
3014
|
+
from: resolved === null || resolved === void 0 ? void 0 : resolved.from,
|
|
3015
|
+
to: resolved === null || resolved === void 0 ? void 0 : resolved.to,
|
|
3016
|
+
granularity,
|
|
3017
|
+
timeZone,
|
|
3018
|
+
locale,
|
|
3019
|
+
height,
|
|
3020
|
+
selectable: true,
|
|
3021
|
+
onRangeSelect: handleRangeSelect,
|
|
3022
|
+
annotations,
|
|
3023
|
+
showLegend: series.length > 1,
|
|
3024
|
+
legendOptions: toggleableLegend ? {
|
|
3025
|
+
onClick: toggleSeries,
|
|
3026
|
+
inactiveKeys: hidden
|
|
3027
|
+
} : void 0,
|
|
3028
|
+
"aria-label": typeof title === "string" ? `${title} time series` : ariaLabel
|
|
3029
|
+
}, chartProps))
|
|
3030
|
+
})]
|
|
3031
|
+
});
|
|
3032
|
+
}
|
|
3033
|
+
TimeSeriesPanel.displayName = "TimeSeriesPanel";
|
|
3034
|
+
//#endregion
|
|
3035
|
+
//#region src/shells/log-table.tsx
|
|
3036
|
+
const HIDE_BELOW = {
|
|
3037
|
+
always: "",
|
|
3038
|
+
sm: "hidden @[40rem]/log:flex",
|
|
3039
|
+
md: "hidden @[46rem]/log:flex",
|
|
3040
|
+
lg: "hidden @[58rem]/log:flex",
|
|
3041
|
+
xl: "hidden @[70rem]/log:flex"
|
|
3042
|
+
};
|
|
3043
|
+
const ROW_HEIGHT = {
|
|
3044
|
+
compact: 26,
|
|
3045
|
+
normal: 32,
|
|
3046
|
+
comfortable: 40
|
|
3047
|
+
};
|
|
3048
|
+
const DENSITY_TEXT = {
|
|
3049
|
+
compact: "text-[11px]",
|
|
3050
|
+
normal: "text-xs",
|
|
3051
|
+
comfortable: "text-sm"
|
|
3052
|
+
};
|
|
3053
|
+
const defaultLabels$2 = {
|
|
3054
|
+
listLabel: "Log",
|
|
3055
|
+
loadingMore: "Loading earlier entries…",
|
|
3056
|
+
endOfResults: "That is every entry in this range.",
|
|
3057
|
+
filterFor: (value) => `Filter for ${value}`,
|
|
3058
|
+
filterOut: (value) => `Filter out ${value}`,
|
|
3059
|
+
sortAscending: "Sort ascending",
|
|
3060
|
+
sortDescending: "Sort descending"
|
|
3061
|
+
};
|
|
3062
|
+
/** Rows rendered beyond the viewport on each side, so a fast scroll stays filled. */
|
|
3063
|
+
const OVERSCAN = 10;
|
|
3064
|
+
/**
|
|
3065
|
+
* A stable hue per value. Colour does real work in a log — the eye groups by it
|
|
3066
|
+
* long before it reads the text — so the same event name has to land on the
|
|
3067
|
+
* same hue on every render and in every session, which rules out an index into
|
|
3068
|
+
* a palette.
|
|
3069
|
+
*/
|
|
3070
|
+
function hueOf(value) {
|
|
3071
|
+
let hash = 0;
|
|
3072
|
+
for (let index = 0; index < value.length; index += 1) hash = hash * 31 + value.charCodeAt(index) | 0;
|
|
3073
|
+
return Math.abs(hash) % 360;
|
|
3074
|
+
}
|
|
3075
|
+
const EM_DASH = "—";
|
|
3076
|
+
/**
|
|
3077
|
+
* A column with nothing in it is a fact about the entry, not a value. Dimming
|
|
3078
|
+
* every absence the same way lets the eye skip the gaps while scanning, instead
|
|
3079
|
+
* of reading a dash as though it were data.
|
|
3080
|
+
*/
|
|
3081
|
+
const ABSENT = "text-text-tertiary/50";
|
|
3082
|
+
function columnStyle(column) {
|
|
3083
|
+
return column.width ? {
|
|
3084
|
+
width: column.width,
|
|
3085
|
+
flex: "0 0 auto"
|
|
3086
|
+
} : {
|
|
3087
|
+
flex: "1 1 0%",
|
|
3088
|
+
minWidth: 0
|
|
3089
|
+
};
|
|
3090
|
+
}
|
|
3091
|
+
/**
|
|
3092
|
+
* LogTable — a windowed table for entries that keep arriving.
|
|
3093
|
+
*
|
|
3094
|
+
* Written by hand rather than delegated to a data grid for the two things a log
|
|
3095
|
+
* needs that a grid does not: rows are inserted at the *top* while the reader
|
|
3096
|
+
* is partway down, which needs a scroll correction applied before paint, and
|
|
3097
|
+
* "am I at the newest row?" has to be answerable from the scroll container to
|
|
3098
|
+
* decide whether to follow the tail or hold position.
|
|
3099
|
+
*
|
|
3100
|
+
* What it takes from a data grid is the part readers actually reach for:
|
|
3101
|
+
* columns are data, so a caller can let people add, drop and reorder them; a
|
|
3102
|
+
* cell offers to filter for or against its own value; and density is a setting
|
|
3103
|
+
* rather than a constant.
|
|
3104
|
+
*
|
|
3105
|
+
* @example
|
|
3106
|
+
* ```tsx
|
|
3107
|
+
* <LogTable
|
|
3108
|
+
* rows={rows}
|
|
3109
|
+
* getRowId={(row) => row.id}
|
|
3110
|
+
* columns={[
|
|
3111
|
+
* { id: "time", header: "Time", width: "9rem", mono: true, value: (r) => r.time },
|
|
3112
|
+
* { id: "name", header: "Event", width: "14rem", field: "name", marker: true, value: (r) => r.name },
|
|
3113
|
+
* { id: "path", header: "Path", field: "path", value: (r) => r.path },
|
|
3114
|
+
* ]}
|
|
3115
|
+
* onCellAction={(action) => setQuery(applyCellAction(query, action))}
|
|
3116
|
+
* />
|
|
3117
|
+
* ```
|
|
3118
|
+
*/
|
|
3119
|
+
function LogTableInner({ rows, columns, getRowId, selectedId = null, onSelect, onLoadMore, hasMore = false, loadingMore = false, prepending = false, onFollowChange, isNew, sort = null, onSortChange, onCellAction, density = "normal", showHeader = true, emptyState, labels: customLabels, className }, ref) {
|
|
3120
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$2), customLabels);
|
|
3121
|
+
const rowHeight = ROW_HEIGHT[density];
|
|
3122
|
+
const scrollRef = useRef(null);
|
|
3123
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
3124
|
+
const [viewportHeight, setViewportHeight] = useState(0);
|
|
3125
|
+
const followingRef = useRef(true);
|
|
3126
|
+
const previousTopIdRef = useRef(null);
|
|
3127
|
+
const previousLengthRef = useRef(0);
|
|
3128
|
+
useImperativeHandle(ref, () => ({
|
|
3129
|
+
scrollToTop: () => {
|
|
3130
|
+
const container = scrollRef.current;
|
|
3131
|
+
if (!container) return;
|
|
3132
|
+
container.scrollTop = 0;
|
|
3133
|
+
setScrollTop(0);
|
|
3134
|
+
if (!followingRef.current) {
|
|
3135
|
+
followingRef.current = true;
|
|
3136
|
+
onFollowChange === null || onFollowChange === void 0 || onFollowChange(true);
|
|
3137
|
+
}
|
|
3138
|
+
},
|
|
3139
|
+
revealRow: (id) => {
|
|
3140
|
+
const index = rows.findIndex((row) => getRowId(row) === id);
|
|
3141
|
+
const container = scrollRef.current;
|
|
3142
|
+
if (index === -1 || !container) return;
|
|
3143
|
+
const top = index * rowHeight;
|
|
3144
|
+
const bottom = top + rowHeight;
|
|
3145
|
+
if (top < container.scrollTop) container.scrollTop = top;
|
|
3146
|
+
else if (bottom > container.scrollTop + container.clientHeight) container.scrollTop = bottom - container.clientHeight;
|
|
3147
|
+
}
|
|
3148
|
+
}), [
|
|
3149
|
+
onFollowChange,
|
|
3150
|
+
rows,
|
|
3151
|
+
getRowId,
|
|
3152
|
+
rowHeight
|
|
3153
|
+
]);
|
|
3154
|
+
useEffect(() => {
|
|
3155
|
+
const container = scrollRef.current;
|
|
3156
|
+
if (!container) return;
|
|
3157
|
+
const observer = new ResizeObserver(() => setViewportHeight(container.clientHeight));
|
|
3158
|
+
observer.observe(container);
|
|
3159
|
+
setViewportHeight(container.clientHeight);
|
|
3160
|
+
return () => observer.disconnect();
|
|
3161
|
+
}, []);
|
|
3162
|
+
/**
|
|
3163
|
+
* Report whether the list is pinned to the newest row.
|
|
3164
|
+
*
|
|
3165
|
+
* Called from more than the scroll handler on purpose: the list can arrive at
|
|
3166
|
+
* the top without a scroll event — a reset, a jump to newest, a shorter
|
|
3167
|
+
* result set — and a stale "not following" would silently divert every live
|
|
3168
|
+
* row into a held-back pile.
|
|
3169
|
+
*/
|
|
3170
|
+
const syncFollowing = useCallback((container) => {
|
|
3171
|
+
const following = container.scrollTop <= rowHeight;
|
|
3172
|
+
if (following === followingRef.current) return;
|
|
3173
|
+
followingRef.current = following;
|
|
3174
|
+
onFollowChange === null || onFollowChange === void 0 || onFollowChange(following);
|
|
3175
|
+
}, [onFollowChange, rowHeight]);
|
|
3176
|
+
/**
|
|
3177
|
+
* Hold the reader's place when rows arrive above them.
|
|
3178
|
+
*
|
|
3179
|
+
* Runs before paint: by the time the browser draws, the scroll offset has
|
|
3180
|
+
* already absorbed the inserted height, so the content under the cursor never
|
|
3181
|
+
* moves. Skipped while following, where the whole point is to stay at the top.
|
|
3182
|
+
*/
|
|
3183
|
+
useLayoutEffect(() => {
|
|
3184
|
+
const container = scrollRef.current;
|
|
3185
|
+
const previousTopId = previousTopIdRef.current;
|
|
3186
|
+
previousTopIdRef.current = rows.length ? getRowId(rows[0]) : null;
|
|
3187
|
+
const previousLength = previousLengthRef.current;
|
|
3188
|
+
previousLengthRef.current = rows.length;
|
|
3189
|
+
if (!container) return;
|
|
3190
|
+
syncFollowing(container);
|
|
3191
|
+
if (!prepending || followingRef.current || !previousTopId) return;
|
|
3192
|
+
if (rows.length <= previousLength) return;
|
|
3193
|
+
const prepended = rows.findIndex((row) => getRowId(row) === previousTopId);
|
|
3194
|
+
if (prepended <= 0) return;
|
|
3195
|
+
container.scrollTop += prepended * rowHeight;
|
|
3196
|
+
setScrollTop(container.scrollTop);
|
|
3197
|
+
}, [
|
|
3198
|
+
rows,
|
|
3199
|
+
getRowId,
|
|
3200
|
+
prepending,
|
|
3201
|
+
rowHeight,
|
|
3202
|
+
syncFollowing
|
|
3203
|
+
]);
|
|
3204
|
+
/**
|
|
3205
|
+
* Page forward when the rows do not reach the bottom of the viewport.
|
|
3206
|
+
*
|
|
3207
|
+
* Without this the list only advances on a scroll event, so a tall screen —
|
|
3208
|
+
* or a filter matching few rows per page — stops at the first page with no
|
|
3209
|
+
* way to ask for more.
|
|
3210
|
+
*/
|
|
3211
|
+
useEffect(() => {
|
|
3212
|
+
const container = scrollRef.current;
|
|
3213
|
+
if (!container || !hasMore || loadingMore || !onLoadMore) return;
|
|
3214
|
+
if (container.scrollHeight <= container.clientHeight) onLoadMore();
|
|
3215
|
+
}, [
|
|
3216
|
+
hasMore,
|
|
3217
|
+
loadingMore,
|
|
3218
|
+
onLoadMore,
|
|
3219
|
+
rows.length,
|
|
3220
|
+
viewportHeight
|
|
3221
|
+
]);
|
|
3222
|
+
const handleScroll = useCallback((event) => {
|
|
3223
|
+
const container = event.currentTarget;
|
|
3224
|
+
setScrollTop(container.scrollTop);
|
|
3225
|
+
syncFollowing(container);
|
|
3226
|
+
const remaining = container.scrollHeight - container.scrollTop - container.clientHeight;
|
|
3227
|
+
if (hasMore && !loadingMore && remaining < container.clientHeight) onLoadMore === null || onLoadMore === void 0 || onLoadMore();
|
|
3228
|
+
}, [
|
|
3229
|
+
hasMore,
|
|
3230
|
+
loadingMore,
|
|
3231
|
+
onLoadMore,
|
|
3232
|
+
syncFollowing
|
|
3233
|
+
]);
|
|
3234
|
+
const totalHeight = rows.length * rowHeight;
|
|
3235
|
+
const firstVisible = Math.max(0, Math.floor(scrollTop / rowHeight) - OVERSCAN);
|
|
3236
|
+
const visibleCount = Math.ceil((viewportHeight || 480) / rowHeight) + 20;
|
|
3237
|
+
const lastVisible = Math.min(rows.length, firstVisible + visibleCount);
|
|
3238
|
+
const visibleRows = useMemo(() => rows.slice(firstVisible, lastVisible), [
|
|
3239
|
+
rows,
|
|
3240
|
+
firstVisible,
|
|
3241
|
+
lastVisible
|
|
3242
|
+
]);
|
|
3243
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3244
|
+
className: cn("@container/log flex min-h-0 flex-col", className),
|
|
3245
|
+
"data-opt-id": "NJ4N9",
|
|
3246
|
+
"data-opt-slug": "log-table.LogTable",
|
|
3247
|
+
children: [showHeader && /* @__PURE__ */ jsx(LogTableHeader, {
|
|
3248
|
+
columns,
|
|
3249
|
+
sort,
|
|
3250
|
+
onSortChange,
|
|
3251
|
+
density,
|
|
3252
|
+
labels
|
|
3253
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3254
|
+
ref: scrollRef,
|
|
3255
|
+
onScroll: handleScroll,
|
|
3256
|
+
className: "relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto",
|
|
3257
|
+
role: "listbox",
|
|
3258
|
+
"aria-label": labels.listLabel,
|
|
3259
|
+
"aria-activedescendant": selectedId ? `log-row-${selectedId}` : void 0,
|
|
3260
|
+
tabIndex: 0,
|
|
3261
|
+
children: [
|
|
3262
|
+
rows.length === 0 ? emptyState : /* @__PURE__ */ jsx("div", {
|
|
3263
|
+
style: { height: totalHeight },
|
|
3264
|
+
className: "relative",
|
|
3265
|
+
children: visibleRows.map((row, index) => {
|
|
3266
|
+
var _isNew;
|
|
3267
|
+
const id = getRowId(row);
|
|
3268
|
+
return /* @__PURE__ */ jsx(LogTableRow, {
|
|
3269
|
+
id,
|
|
3270
|
+
row,
|
|
3271
|
+
columns,
|
|
3272
|
+
top: (firstVisible + index) * rowHeight,
|
|
3273
|
+
height: rowHeight,
|
|
3274
|
+
density,
|
|
3275
|
+
selected: id === selectedId,
|
|
3276
|
+
isNew: (_isNew = isNew === null || isNew === void 0 ? void 0 : isNew(row)) !== null && _isNew !== void 0 ? _isNew : false,
|
|
3277
|
+
onSelect,
|
|
3278
|
+
onCellAction,
|
|
3279
|
+
labels
|
|
3280
|
+
}, id);
|
|
3281
|
+
})
|
|
3282
|
+
}),
|
|
3283
|
+
loadingMore && /* @__PURE__ */ jsxs("div", {
|
|
3284
|
+
className: "gap-element text-text-tertiary flex items-center justify-center py-3 text-xs",
|
|
3285
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
3286
|
+
size: "sm",
|
|
3287
|
+
"aria-hidden": true
|
|
3288
|
+
}), labels.loadingMore]
|
|
3289
|
+
}),
|
|
3290
|
+
!hasMore && rows.length > 0 && /* @__PURE__ */ jsx("p", {
|
|
3291
|
+
className: cn("text-text-tertiary", "py-3 text-center text-xs"),
|
|
3292
|
+
children: labels.endOfResults
|
|
3293
|
+
})
|
|
3294
|
+
]
|
|
3295
|
+
})]
|
|
3296
|
+
});
|
|
3297
|
+
}
|
|
3298
|
+
/**
|
|
3299
|
+
* LogTable — see {@link LogTableInner}.
|
|
3300
|
+
*
|
|
3301
|
+
* The cast preserves the row generic through `forwardRef`, which otherwise
|
|
3302
|
+
* widens it to its constraint and takes the column callbacks' types with it.
|
|
3303
|
+
*/
|
|
3304
|
+
const LogTable = forwardRef(LogTableInner);
|
|
3305
|
+
function LogTableHeader({ columns, sort, onSortChange, density, labels }) {
|
|
3306
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3307
|
+
role: "row",
|
|
3308
|
+
className: cn("border-border-subtle text-text-tertiary flex shrink-0 items-center gap-3 border-b px-3", DENSITY_TEXT[density]),
|
|
3309
|
+
style: { height: ROW_HEIGHT[density] },
|
|
3310
|
+
children: columns.map((column) => {
|
|
3311
|
+
var _column$priority;
|
|
3312
|
+
const active = (sort === null || sort === void 0 ? void 0 : sort.columnId) === column.id;
|
|
3313
|
+
const sortable = column.sortable && onSortChange;
|
|
3314
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3315
|
+
column.marker && /* @__PURE__ */ jsx("span", {
|
|
3316
|
+
"aria-hidden": true,
|
|
3317
|
+
className: "size-1.5 shrink-0"
|
|
3318
|
+
}),
|
|
3319
|
+
/* @__PURE__ */ jsx("span", {
|
|
3320
|
+
className: "truncate",
|
|
3321
|
+
children: column.header
|
|
3322
|
+
}),
|
|
3323
|
+
active && (sort.direction === "asc" ? /* @__PURE__ */ jsx(ChevronUp, {
|
|
3324
|
+
className: "size-3 shrink-0",
|
|
3325
|
+
"aria-hidden": true
|
|
3326
|
+
}) : /* @__PURE__ */ jsx(ChevronDown, {
|
|
3327
|
+
className: "size-3 shrink-0",
|
|
3328
|
+
"aria-hidden": true
|
|
3329
|
+
}))
|
|
3330
|
+
] });
|
|
3331
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3332
|
+
role: "columnheader",
|
|
3333
|
+
"aria-sort": active ? sort.direction === "asc" ? "ascending" : "descending" : void 0,
|
|
3334
|
+
className: cn("flex items-center gap-1.5", column.align === "right" && "justify-end", HIDE_BELOW[(_column$priority = column.priority) !== null && _column$priority !== void 0 ? _column$priority : "always"]),
|
|
3335
|
+
style: columnStyle(column),
|
|
3336
|
+
children: sortable ? /* @__PURE__ */ jsx("button", {
|
|
3337
|
+
type: "button",
|
|
3338
|
+
className: "hover:text-text-primary flex cursor-pointer items-center gap-1.5 truncate",
|
|
3339
|
+
title: active && sort.direction === "desc" ? labels.sortAscending : labels.sortDescending,
|
|
3340
|
+
onClick: () => onSortChange({
|
|
3341
|
+
columnId: column.id,
|
|
3342
|
+
direction: active && sort.direction === "desc" ? "asc" : "desc"
|
|
3343
|
+
}),
|
|
3344
|
+
children: content
|
|
3345
|
+
}) : content
|
|
3346
|
+
}, column.id);
|
|
3347
|
+
})
|
|
3348
|
+
});
|
|
3349
|
+
}
|
|
3350
|
+
function LogTableRowImpl({ id, row, columns, top, height, density, selected, isNew, onSelect, onCellAction, labels }) {
|
|
3351
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3352
|
+
role: "option",
|
|
3353
|
+
"aria-selected": selected,
|
|
3354
|
+
tabIndex: -1,
|
|
3355
|
+
id: `log-row-${id}`,
|
|
3356
|
+
"data-log-row-id": id,
|
|
3357
|
+
onClick: () => onSelect === null || onSelect === void 0 ? void 0 : onSelect(id),
|
|
3358
|
+
onKeyDown: (event) => {
|
|
3359
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
3360
|
+
event.preventDefault();
|
|
3361
|
+
onSelect === null || onSelect === void 0 || onSelect(id);
|
|
3362
|
+
},
|
|
3363
|
+
style: {
|
|
3364
|
+
top,
|
|
3365
|
+
height
|
|
3366
|
+
},
|
|
3367
|
+
className: cn("border-border-subtle/60 absolute inset-x-0 flex items-center gap-3 border-b px-3", DENSITY_TEXT[density], onSelect && "cursor-pointer", "transition-colors duration-100", "hover:bg-surface-hover", selected && "bg-accent-subtle hover:bg-accent-subtle", isNew && !selected && "opt-log-row-enter"),
|
|
3368
|
+
children: columns.map((column) => {
|
|
3369
|
+
var _column$priority2;
|
|
3370
|
+
const raw = column.value(row);
|
|
3371
|
+
const text = raw === null || raw === void 0 || raw === "" ? "" : String(raw);
|
|
3372
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3373
|
+
className: cn("group/cell relative flex min-w-0 items-center gap-1.5", column.align === "right" && "justify-end", HIDE_BELOW[(_column$priority2 = column.priority) !== null && _column$priority2 !== void 0 ? _column$priority2 : "always"]),
|
|
3374
|
+
style: columnStyle(column),
|
|
3375
|
+
children: [
|
|
3376
|
+
column.marker && text && /* @__PURE__ */ jsx("span", {
|
|
3377
|
+
"aria-hidden": true,
|
|
3378
|
+
className: "size-1.5 shrink-0 rounded-full",
|
|
3379
|
+
style: { backgroundColor: `hsl(${hueOf(text)} 65% 55%)` }
|
|
3380
|
+
}),
|
|
3381
|
+
/* @__PURE__ */ jsx("span", {
|
|
3382
|
+
className: cn("truncate", column.mono && "font-mono", text ? "text-text-secondary" : ABSENT),
|
|
3383
|
+
title: text || void 0,
|
|
3384
|
+
children: column.render ? column.render(row) : text || EM_DASH
|
|
3385
|
+
}),
|
|
3386
|
+
onCellAction && column.field && text && /* @__PURE__ */ jsx(CellActions, {
|
|
3387
|
+
field: column.field,
|
|
3388
|
+
value: text,
|
|
3389
|
+
onAction: onCellAction,
|
|
3390
|
+
labels
|
|
3391
|
+
})
|
|
3392
|
+
]
|
|
3393
|
+
}, column.id);
|
|
3394
|
+
})
|
|
3395
|
+
});
|
|
3396
|
+
}
|
|
3397
|
+
/**
|
|
3398
|
+
* Memoized because a live log re-renders several times a second while almost
|
|
3399
|
+
* every visible row is unchanged.
|
|
3400
|
+
*/
|
|
3401
|
+
const LogTableRow = memo(LogTableRowImpl);
|
|
3402
|
+
/**
|
|
3403
|
+
* The two questions a reader has about a value they just spotted: show me only
|
|
3404
|
+
* these, and get these out of my way.
|
|
3405
|
+
*
|
|
3406
|
+
* Revealed on hover rather than always drawn — a log is scanned, and a pair of
|
|
3407
|
+
* buttons on every cell of every row is a wall of chrome. They stay in the tab
|
|
3408
|
+
* order regardless, since hover is not an interaction everyone has.
|
|
3409
|
+
*/
|
|
3410
|
+
function CellActions({ field, value, onAction, labels }) {
|
|
3411
|
+
const button = "cursor-pointer rounded-sm p-0.5 text-text-tertiary hover:bg-bg-muted hover:text-text-primary";
|
|
3412
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
3413
|
+
className: cn("bg-surface/90 ml-auto hidden shrink-0 items-center gap-0.5 rounded pl-1", "group-hover/cell:flex focus-within:flex"),
|
|
3414
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
3415
|
+
type: "button",
|
|
3416
|
+
className: button,
|
|
3417
|
+
title: labels.filterFor(value),
|
|
3418
|
+
"aria-label": labels.filterFor(value),
|
|
3419
|
+
onClick: (event) => {
|
|
3420
|
+
event.stopPropagation();
|
|
3421
|
+
onAction({
|
|
3422
|
+
field,
|
|
3423
|
+
value,
|
|
3424
|
+
intent: "include"
|
|
3425
|
+
});
|
|
3426
|
+
},
|
|
3427
|
+
children: /* @__PURE__ */ jsx(Plus, {
|
|
3428
|
+
className: "size-3",
|
|
3429
|
+
"aria-hidden": true
|
|
3430
|
+
})
|
|
3431
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
3432
|
+
type: "button",
|
|
3433
|
+
className: button,
|
|
3434
|
+
title: labels.filterOut(value),
|
|
3435
|
+
"aria-label": labels.filterOut(value),
|
|
3436
|
+
onClick: (event) => {
|
|
3437
|
+
event.stopPropagation();
|
|
3438
|
+
onAction({
|
|
3439
|
+
field,
|
|
3440
|
+
value,
|
|
3441
|
+
intent: "exclude"
|
|
3442
|
+
});
|
|
3443
|
+
},
|
|
3444
|
+
children: /* @__PURE__ */ jsx(Minus, {
|
|
3445
|
+
className: "size-3",
|
|
3446
|
+
"aria-hidden": true
|
|
3447
|
+
})
|
|
3448
|
+
})]
|
|
3449
|
+
});
|
|
3450
|
+
}
|
|
3451
|
+
//#endregion
|
|
3452
|
+
//#region src/lib/query/query-ast.ts
|
|
3453
|
+
const EMPTY_QUERY = { clauses: [] };
|
|
3454
|
+
/** Whether a query constrains anything at all. */
|
|
3455
|
+
function isEmptyQuery(query) {
|
|
3456
|
+
return !query || query.clauses.length === 0;
|
|
3457
|
+
}
|
|
3458
|
+
function sameClause(a, b) {
|
|
3459
|
+
if (a.type !== b.type) return false;
|
|
3460
|
+
if (a.type === "term" && b.type === "term") return a.value === b.value && a.negated === b.negated;
|
|
3461
|
+
const fieldA = a;
|
|
3462
|
+
const fieldB = b;
|
|
3463
|
+
return fieldA.field === fieldB.field && fieldA.operator === fieldB.operator && fieldA.negated === fieldB.negated && fieldA.values.length === fieldB.values.length && fieldA.values.every((value, index) => value === fieldB.values[index]);
|
|
3464
|
+
}
|
|
3465
|
+
/** Add a clause unless an identical one is already there. */
|
|
3466
|
+
function addClause(query, clause) {
|
|
3467
|
+
if (query.clauses.some((existing) => sameClause(existing, clause))) return query;
|
|
3468
|
+
return { clauses: [...query.clauses, clause] };
|
|
3469
|
+
}
|
|
3470
|
+
/**
|
|
3471
|
+
* Constrain a field to a value — what a cell's "filter for this" action does.
|
|
3472
|
+
*
|
|
3473
|
+
* Applying the opposite of a constraint already present replaces it rather than
|
|
3474
|
+
* adding it: `status:200` then "filter out 200" should read as one changed
|
|
3475
|
+
* mind, not as a query that can never match.
|
|
3476
|
+
*/
|
|
3477
|
+
function withFieldValue(query, field, value, options = {}) {
|
|
3478
|
+
var _options$negated, _options$operator;
|
|
3479
|
+
const negated = (_options$negated = options.negated) !== null && _options$negated !== void 0 ? _options$negated : false;
|
|
3480
|
+
const operator = (_options$operator = options.operator) !== null && _options$operator !== void 0 ? _options$operator : "eq";
|
|
3481
|
+
return { clauses: [...query.clauses.filter((clause) => !(clause.type === "field" && clause.field === field && clause.operator === operator && clause.values.length === 1 && clause.values[0] === value)), {
|
|
3482
|
+
type: "field",
|
|
3483
|
+
field,
|
|
3484
|
+
operator,
|
|
3485
|
+
values: [value],
|
|
3486
|
+
negated
|
|
3487
|
+
}] };
|
|
3488
|
+
}
|
|
3489
|
+
/** Drop every clause naming `field`. */
|
|
3490
|
+
function withoutField(query, field) {
|
|
3491
|
+
return { clauses: query.clauses.filter((clause) => clause.type !== "field" || clause.field !== field) };
|
|
3492
|
+
}
|
|
3493
|
+
/** Drop the clause at `index`, for a removable chip. */
|
|
3494
|
+
function removeClause(query, index) {
|
|
3495
|
+
return { clauses: query.clauses.filter((_, at) => at !== index) };
|
|
3496
|
+
}
|
|
3497
|
+
/** Every field the query names, in the order they first appear. */
|
|
3498
|
+
function queryFields(query) {
|
|
3499
|
+
const seen = [];
|
|
3500
|
+
for (const clause of query.clauses) if (clause.type === "field" && !seen.includes(clause.field)) seen.push(clause.field);
|
|
3501
|
+
return seen;
|
|
3502
|
+
}
|
|
3503
|
+
/** The values a field is constrained to, if any — for showing a filter as active. */
|
|
3504
|
+
function fieldValues(query, field) {
|
|
3505
|
+
return query.clauses.flatMap((clause) => clause.type === "field" && clause.field === field && !clause.negated ? clause.values : []);
|
|
3506
|
+
}
|
|
3507
|
+
/**
|
|
3508
|
+
* Fold a cell action into the query.
|
|
3509
|
+
*
|
|
3510
|
+
* The pair of buttons on a log cell is the fastest path from "I noticed this
|
|
3511
|
+
* value" to a filtered view, and the reason it works is that the result is a
|
|
3512
|
+
* query the reader can then see, edit and share — not a hidden filter stack
|
|
3513
|
+
* with its own rules.
|
|
3514
|
+
*/
|
|
3515
|
+
function applyCellAction(query, action) {
|
|
3516
|
+
return withFieldValue(query, action.field, action.value, { negated: action.intent === "exclude" });
|
|
3517
|
+
}
|
|
3518
|
+
//#endregion
|
|
3519
|
+
//#region src/lib/query/query-parse.ts
|
|
3520
|
+
const FIELD_NAME = /^[A-Za-z_][A-Za-z0-9_.-]*$/;
|
|
3521
|
+
/**
|
|
3522
|
+
* Split on whitespace, but keep quoted runs and parenthesised groups whole.
|
|
3523
|
+
*
|
|
3524
|
+
* An unterminated quote or group swallows the rest of the line rather than
|
|
3525
|
+
* erroring: the reader is mid-word, and the alternative is the query flickering
|
|
3526
|
+
* between two different meanings as they type the closing character.
|
|
3527
|
+
*/
|
|
3528
|
+
function tokenize(input) {
|
|
3529
|
+
const tokens = [];
|
|
3530
|
+
let index = 0;
|
|
3531
|
+
while (index < input.length) {
|
|
3532
|
+
while (index < input.length && /\s/.test(input[index])) index += 1;
|
|
3533
|
+
if (index >= input.length) break;
|
|
3534
|
+
const start = index;
|
|
3535
|
+
let text = "";
|
|
3536
|
+
let quoted = false;
|
|
3537
|
+
let atTokenStart = true;
|
|
3538
|
+
let depth = 0;
|
|
3539
|
+
while (index < input.length) {
|
|
3540
|
+
const char = input[index];
|
|
3541
|
+
if (char === "\"") {
|
|
3542
|
+
if (atTokenStart) quoted = true;
|
|
3543
|
+
atTokenStart = false;
|
|
3544
|
+
index += 1;
|
|
3545
|
+
while (index < input.length && input[index] !== "\"") {
|
|
3546
|
+
text += input[index];
|
|
3547
|
+
index += 1;
|
|
3548
|
+
}
|
|
3549
|
+
index += 1;
|
|
3550
|
+
continue;
|
|
3551
|
+
}
|
|
3552
|
+
if (char === "(") depth += 1;
|
|
3553
|
+
if (char === ")") depth = Math.max(0, depth - 1);
|
|
3554
|
+
if (/\s/.test(char) && depth === 0) break;
|
|
3555
|
+
atTokenStart = false;
|
|
3556
|
+
text += char;
|
|
3557
|
+
index += 1;
|
|
3558
|
+
}
|
|
3559
|
+
if (text.length > 0 || quoted) tokens.push({
|
|
3560
|
+
text,
|
|
3561
|
+
at: start,
|
|
3562
|
+
quoted
|
|
3563
|
+
});
|
|
3564
|
+
}
|
|
3565
|
+
return tokens;
|
|
3566
|
+
}
|
|
3567
|
+
/** `(a or b)` → `["a", "b"]`; anything else is a single value. */
|
|
3568
|
+
function readValues(raw) {
|
|
3569
|
+
const trimmed = raw.trim();
|
|
3570
|
+
if (!trimmed.startsWith("(")) return [stripQuotes(trimmed)];
|
|
3571
|
+
return trimmed.replace(/^\(/, "").replace(/\)$/, "").split(/\s+or\s+/i).map((part) => stripQuotes(part.trim())).filter((part) => part.length > 0);
|
|
3572
|
+
}
|
|
3573
|
+
function stripQuotes(value) {
|
|
3574
|
+
if (value.length >= 2 && value.startsWith("\"") && value.endsWith("\"")) return value.slice(1, -1);
|
|
3575
|
+
return value.replace(/^"/, "");
|
|
3576
|
+
}
|
|
3577
|
+
const OPERATORS = [
|
|
3578
|
+
{
|
|
3579
|
+
symbol: ">=",
|
|
3580
|
+
operator: "gte"
|
|
3581
|
+
},
|
|
3582
|
+
{
|
|
3583
|
+
symbol: "<=",
|
|
3584
|
+
operator: "lte"
|
|
3585
|
+
},
|
|
3586
|
+
{
|
|
3587
|
+
symbol: ":",
|
|
3588
|
+
operator: "eq"
|
|
3589
|
+
},
|
|
3590
|
+
{
|
|
3591
|
+
symbol: ">",
|
|
3592
|
+
operator: "gt"
|
|
3593
|
+
},
|
|
3594
|
+
{
|
|
3595
|
+
symbol: "<",
|
|
3596
|
+
operator: "lt"
|
|
3597
|
+
}
|
|
3598
|
+
];
|
|
3599
|
+
/** Where a field operator starts in the token, or `-1`. */
|
|
3600
|
+
function findOperator(text) {
|
|
3601
|
+
let best = null;
|
|
3602
|
+
for (const { symbol, operator } of OPERATORS) {
|
|
3603
|
+
const index = text.indexOf(symbol);
|
|
3604
|
+
if (index <= 0) continue;
|
|
3605
|
+
if (!best || index < best.index || index === best.index && symbol.length > best.symbol.length) best = {
|
|
3606
|
+
index,
|
|
3607
|
+
symbol,
|
|
3608
|
+
operator
|
|
3609
|
+
};
|
|
3610
|
+
}
|
|
3611
|
+
return best;
|
|
3612
|
+
}
|
|
3613
|
+
/** Parse, keeping whatever could not be understood as a plain term. */
|
|
3614
|
+
function parseQueryWithDiagnostics(input) {
|
|
3615
|
+
const diagnostics = [];
|
|
3616
|
+
const clauses = [];
|
|
3617
|
+
let trailing = null;
|
|
3618
|
+
for (const token of tokenize(input)) {
|
|
3619
|
+
let text = token.text;
|
|
3620
|
+
let negated = false;
|
|
3621
|
+
if (!token.quoted && text.startsWith("-") && text.length > 1) {
|
|
3622
|
+
negated = true;
|
|
3623
|
+
text = text.slice(1);
|
|
3624
|
+
}
|
|
3625
|
+
const operator = token.quoted ? null : findOperator(text);
|
|
3626
|
+
if (!operator) {
|
|
3627
|
+
if (text.length > 0) clauses.push({
|
|
3628
|
+
type: "term",
|
|
3629
|
+
value: text,
|
|
3630
|
+
negated
|
|
3631
|
+
});
|
|
3632
|
+
continue;
|
|
3633
|
+
}
|
|
3634
|
+
const field = text.slice(0, operator.index);
|
|
3635
|
+
const rawValue = text.slice(operator.index + operator.symbol.length);
|
|
3636
|
+
if (!FIELD_NAME.test(field)) {
|
|
3637
|
+
clauses.push({
|
|
3638
|
+
type: "term",
|
|
3639
|
+
value: text,
|
|
3640
|
+
negated
|
|
3641
|
+
});
|
|
3642
|
+
continue;
|
|
3643
|
+
}
|
|
3644
|
+
if (rawValue === "") {
|
|
3645
|
+
trailing = {
|
|
3646
|
+
field,
|
|
3647
|
+
operator: operator.operator,
|
|
3648
|
+
value: ""
|
|
3649
|
+
};
|
|
3650
|
+
continue;
|
|
3651
|
+
}
|
|
3652
|
+
if (rawValue === "*" && operator.operator === "eq") {
|
|
3653
|
+
clauses.push({
|
|
3654
|
+
type: "field",
|
|
3655
|
+
field,
|
|
3656
|
+
operator: "exists",
|
|
3657
|
+
values: [],
|
|
3658
|
+
negated
|
|
3659
|
+
});
|
|
3660
|
+
continue;
|
|
3661
|
+
}
|
|
3662
|
+
if (operator.operator === "eq" && rawValue.length > 2 && rawValue.startsWith("*") && rawValue.endsWith("*")) {
|
|
3663
|
+
clauses.push({
|
|
3664
|
+
type: "field",
|
|
3665
|
+
field,
|
|
3666
|
+
operator: "contains",
|
|
3667
|
+
values: [stripQuotes(rawValue.slice(1, -1))],
|
|
3668
|
+
negated
|
|
3669
|
+
});
|
|
3670
|
+
continue;
|
|
3671
|
+
}
|
|
3672
|
+
const values = readValues(rawValue);
|
|
3673
|
+
if (values.length === 0) {
|
|
3674
|
+
diagnostics.push({
|
|
3675
|
+
at: token.at,
|
|
3676
|
+
text: token.text,
|
|
3677
|
+
message: "Empty value group"
|
|
3678
|
+
});
|
|
3679
|
+
continue;
|
|
3680
|
+
}
|
|
3681
|
+
if (operator.operator !== "eq" && values.length > 1) diagnostics.push({
|
|
3682
|
+
at: token.at,
|
|
3683
|
+
text: token.text,
|
|
3684
|
+
message: "A comparison takes a single value"
|
|
3685
|
+
});
|
|
3686
|
+
const clause = {
|
|
3687
|
+
type: "field",
|
|
3688
|
+
field,
|
|
3689
|
+
operator: operator.operator,
|
|
3690
|
+
values: operator.operator === "eq" ? values : values.slice(0, 1),
|
|
3691
|
+
negated
|
|
3692
|
+
};
|
|
3693
|
+
clauses.push(clause);
|
|
3694
|
+
if (!rawValue.startsWith("(")) {
|
|
3695
|
+
var _values$;
|
|
3696
|
+
trailing = {
|
|
3697
|
+
field,
|
|
3698
|
+
operator: operator.operator,
|
|
3699
|
+
value: (_values$ = values[0]) !== null && _values$ !== void 0 ? _values$ : ""
|
|
3700
|
+
};
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3703
|
+
return {
|
|
3704
|
+
query: { clauses },
|
|
3705
|
+
diagnostics,
|
|
3706
|
+
trailing
|
|
3707
|
+
};
|
|
3708
|
+
}
|
|
3709
|
+
/** Parse, discarding diagnostics. */
|
|
3710
|
+
function parseQuery(input) {
|
|
3711
|
+
return parseQueryWithDiagnostics(input).query;
|
|
3712
|
+
}
|
|
3713
|
+
//#endregion
|
|
3714
|
+
//#region src/lib/query/query-format.ts
|
|
3715
|
+
const OPERATOR_SYMBOL = {
|
|
3716
|
+
eq: ":",
|
|
3717
|
+
contains: ":",
|
|
3718
|
+
gt: ">",
|
|
3719
|
+
gte: ">=",
|
|
3720
|
+
lt: "<",
|
|
3721
|
+
lte: "<=",
|
|
3722
|
+
exists: ":"
|
|
3723
|
+
};
|
|
3724
|
+
/** Quote a value that would otherwise re-parse as something else. */
|
|
3725
|
+
function quoteValue(value) {
|
|
3726
|
+
return /[\s"()]/.test(value) || value === "" ? `"${value.replace(/"/g, "")}"` : value;
|
|
3727
|
+
}
|
|
3728
|
+
/** One clause as text. */
|
|
3729
|
+
function formatClause(clause) {
|
|
3730
|
+
var _clause$values$2;
|
|
3731
|
+
const prefix = clause.negated ? "-" : "";
|
|
3732
|
+
if (clause.type === "term") return `${prefix}${quoteValue(clause.value)}`;
|
|
3733
|
+
if (clause.operator === "exists") return `${prefix}${clause.field}:*`;
|
|
3734
|
+
if (clause.operator === "contains") {
|
|
3735
|
+
var _clause$values$;
|
|
3736
|
+
return `${prefix}${clause.field}:*${(_clause$values$ = clause.values[0]) !== null && _clause$values$ !== void 0 ? _clause$values$ : ""}*`;
|
|
3737
|
+
}
|
|
3738
|
+
const symbol = OPERATOR_SYMBOL[clause.operator];
|
|
3739
|
+
if (clause.values.length > 1) return `${prefix}${clause.field}${symbol}(${clause.values.map(quoteValue).join(" or ")})`;
|
|
3740
|
+
return `${prefix}${clause.field}${symbol}${quoteValue((_clause$values$2 = clause.values[0]) !== null && _clause$values$2 !== void 0 ? _clause$values$2 : "")}`;
|
|
3741
|
+
}
|
|
3742
|
+
/** The whole query as text. */
|
|
3743
|
+
function formatQuery(query) {
|
|
3744
|
+
return query.clauses.map(formatClause).join(" ");
|
|
3745
|
+
}
|
|
3746
|
+
/** A short human label for a clause chip. */
|
|
3747
|
+
function describeClause(clause) {
|
|
3748
|
+
if (clause.type === "term") return clause.negated ? `not "${clause.value}"` : `"${clause.value}"`;
|
|
3749
|
+
if (clause.operator === "exists") return clause.negated ? `${clause.field} missing` : `${clause.field} present`;
|
|
3750
|
+
if (clause.operator === "contains") {
|
|
3751
|
+
var _clause$values$3;
|
|
3752
|
+
return `${clause.negated ? "not " : ""}${clause.field} ⊃ ${(_clause$values$3 = clause.values[0]) !== null && _clause$values$3 !== void 0 ? _clause$values$3 : ""}`;
|
|
3753
|
+
}
|
|
3754
|
+
const values = clause.values.join(", ");
|
|
3755
|
+
const symbol = OPERATOR_SYMBOL[clause.operator];
|
|
3756
|
+
return `${clause.negated ? "not " : ""}${clause.field} ${symbol === ":" ? "=" : symbol} ${values}`;
|
|
3757
|
+
}
|
|
3758
|
+
//#endregion
|
|
3759
|
+
//#region src/shells/query-bar.tsx
|
|
3760
|
+
const defaultLabels$1 = {
|
|
3761
|
+
placeholder: "Search, or filter with field:value",
|
|
3762
|
+
ariaLabel: "Search query",
|
|
3763
|
+
clear: "Clear query",
|
|
3764
|
+
removeClause: (clause) => `Remove ${clause}`,
|
|
3765
|
+
fieldsHeading: "Fields",
|
|
3766
|
+
valuesHeading: "Values",
|
|
3767
|
+
syntaxHint: null
|
|
3768
|
+
};
|
|
3769
|
+
const MAX_SUGGESTIONS = 8;
|
|
3770
|
+
/**
|
|
3771
|
+
* QueryBar — one control for "find this" and "only these".
|
|
3772
|
+
*
|
|
3773
|
+
* A search box and a row of filter pickers answer halves of the same question
|
|
3774
|
+
* and neither can express the other, so people end up using both and holding
|
|
3775
|
+
* the combination in their head. Typing the filter is what closes that: the
|
|
3776
|
+
* whole question is one string, which means it can be read back, corrected in
|
|
3777
|
+
* place, pasted to a colleague, and stored in a URL.
|
|
3778
|
+
*
|
|
3779
|
+
* The text is the source of truth while the reader is typing; the parsed query
|
|
3780
|
+
* is committed on Enter or blur. Anything half-written parses to a plain term
|
|
3781
|
+
* rather than an error, so the bar never argues with someone mid-word.
|
|
3782
|
+
*
|
|
3783
|
+
* @example
|
|
3784
|
+
* ```tsx
|
|
3785
|
+
* <QueryBar
|
|
3786
|
+
* value={query}
|
|
3787
|
+
* onChange={setQuery}
|
|
3788
|
+
* fields={[{ name: "path", values: ["/checkout", "/cart"] }]}
|
|
3789
|
+
* showClauses
|
|
3790
|
+
* />
|
|
3791
|
+
* ```
|
|
3792
|
+
*/
|
|
3793
|
+
function QueryBar({ value, onChange, fields = [], showClauses = false, live = false, disabled = false, className, labels: customLabels }) {
|
|
3794
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels$1), customLabels);
|
|
3795
|
+
const inputRef = useRef(null);
|
|
3796
|
+
const [text, setText] = useState(() => formatQuery(value));
|
|
3797
|
+
const [focused, setFocused] = useState(false);
|
|
3798
|
+
const [highlighted, setHighlighted] = useState(0);
|
|
3799
|
+
const committedRef = useRef(formatQuery(value));
|
|
3800
|
+
useEffect(() => {
|
|
3801
|
+
const next = formatQuery(value);
|
|
3802
|
+
if (next === committedRef.current) return;
|
|
3803
|
+
committedRef.current = next;
|
|
3804
|
+
if (!focused) setText(next);
|
|
3805
|
+
}, [value, focused]);
|
|
3806
|
+
const parsed = useMemo(() => parseQueryWithDiagnostics(text), [text]);
|
|
3807
|
+
const commit = useCallback((nextText) => {
|
|
3808
|
+
const nextQuery = parseQueryWithDiagnostics(nextText).query;
|
|
3809
|
+
committedRef.current = formatQuery(nextQuery);
|
|
3810
|
+
onChange(nextQuery);
|
|
3811
|
+
}, [onChange]);
|
|
3812
|
+
const suggestions = useSuggestions(text, parsed.trailing, fields);
|
|
3813
|
+
const applySuggestion = useCallback((suggestion) => {
|
|
3814
|
+
var _inputRef$current;
|
|
3815
|
+
const nextText = suggestion.replace(text);
|
|
3816
|
+
setText(nextText);
|
|
3817
|
+
if (suggestion.kind === "value") commit(nextText);
|
|
3818
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
3819
|
+
setHighlighted(0);
|
|
3820
|
+
}, [text, commit]);
|
|
3821
|
+
const handleKeyDown = (event) => {
|
|
3822
|
+
if (suggestions.length > 0 && focused) {
|
|
3823
|
+
if (event.key === "ArrowDown") {
|
|
3824
|
+
event.preventDefault();
|
|
3825
|
+
setHighlighted((current) => (current + 1) % suggestions.length);
|
|
3826
|
+
return;
|
|
3827
|
+
}
|
|
3828
|
+
if (event.key === "ArrowUp") {
|
|
3829
|
+
event.preventDefault();
|
|
3830
|
+
setHighlighted((current) => (current - 1 + suggestions.length) % suggestions.length);
|
|
3831
|
+
return;
|
|
3832
|
+
}
|
|
3833
|
+
if (event.key === "Tab" || event.key === "Enter" && highlighted > 0) {
|
|
3834
|
+
event.preventDefault();
|
|
3835
|
+
applySuggestion(suggestions[highlighted]);
|
|
3836
|
+
return;
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
if (event.key === "Enter") {
|
|
3840
|
+
event.preventDefault();
|
|
3841
|
+
commit(text);
|
|
3842
|
+
return;
|
|
3843
|
+
}
|
|
3844
|
+
if (event.key === "Escape") {
|
|
3845
|
+
var _inputRef$current2;
|
|
3846
|
+
setText(committedRef.current);
|
|
3847
|
+
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.blur();
|
|
3848
|
+
}
|
|
3849
|
+
};
|
|
3850
|
+
const showSuggestions = focused && suggestions.length > 0;
|
|
3851
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3852
|
+
className: cn("relative flex min-w-0 flex-col gap-1.5", className),
|
|
3853
|
+
"data-opt-id": "JSVZ1",
|
|
3854
|
+
"data-opt-slug": "query-bar.QueryBar",
|
|
3855
|
+
children: [
|
|
3856
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3857
|
+
className: cn("bg-surface flex h-9 items-center gap-2 rounded-md border px-2.5", OPT_BORDER, "focus-within:border-accent transition-colors", disabled && "opacity-60"),
|
|
3858
|
+
children: [
|
|
3859
|
+
/* @__PURE__ */ jsx(Search, {
|
|
3860
|
+
className: "text-text-tertiary size-4 shrink-0",
|
|
3861
|
+
"aria-hidden": true
|
|
3862
|
+
}),
|
|
3863
|
+
/* @__PURE__ */ jsx("input", {
|
|
3864
|
+
ref: inputRef,
|
|
3865
|
+
type: "text",
|
|
3866
|
+
role: "combobox",
|
|
3867
|
+
"aria-expanded": showSuggestions,
|
|
3868
|
+
"aria-controls": "query-bar-suggestions",
|
|
3869
|
+
"aria-autocomplete": "list",
|
|
3870
|
+
"aria-label": labels.ariaLabel,
|
|
3871
|
+
placeholder: labels.placeholder,
|
|
3872
|
+
disabled,
|
|
3873
|
+
className: cn("text-text-primary placeholder:text-text-tertiary min-w-0 flex-1", "bg-transparent font-mono text-sm outline-none focus-visible:outline-none"),
|
|
3874
|
+
value: text,
|
|
3875
|
+
onChange: (event) => {
|
|
3876
|
+
setText(event.target.value);
|
|
3877
|
+
setHighlighted(0);
|
|
3878
|
+
if (live) commit(event.target.value);
|
|
3879
|
+
},
|
|
3880
|
+
onFocus: () => setFocused(true),
|
|
3881
|
+
onBlur: () => {
|
|
3882
|
+
window.setTimeout(() => setFocused(false), 120);
|
|
3883
|
+
if (!live) commit(text);
|
|
3884
|
+
},
|
|
3885
|
+
onKeyDown: handleKeyDown
|
|
3886
|
+
}),
|
|
3887
|
+
text.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
3888
|
+
type: "button",
|
|
3889
|
+
"aria-label": labels.clear,
|
|
3890
|
+
title: labels.clear,
|
|
3891
|
+
className: cn("text-text-tertiary hover:text-text-primary cursor-pointer rounded-sm p-0.5", "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-ring-offset"),
|
|
3892
|
+
onClick: () => {
|
|
3893
|
+
setText("");
|
|
3894
|
+
commit("");
|
|
3895
|
+
},
|
|
3896
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
3897
|
+
className: "size-3.5",
|
|
3898
|
+
"aria-hidden": true
|
|
3899
|
+
})
|
|
3900
|
+
})
|
|
3901
|
+
]
|
|
3902
|
+
}),
|
|
3903
|
+
showSuggestions && /* @__PURE__ */ jsx("ul", {
|
|
3904
|
+
id: "query-bar-suggestions",
|
|
3905
|
+
role: "listbox",
|
|
3906
|
+
className: cn("bg-surface-overlay absolute top-10 z-40 max-h-64 w-full overflow-y-auto rounded-md border p-1 shadow-lg", "border border-border"),
|
|
3907
|
+
children: suggestions.map((suggestion, index) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
|
|
3908
|
+
type: "button",
|
|
3909
|
+
role: "option",
|
|
3910
|
+
"aria-selected": index === highlighted,
|
|
3911
|
+
className: cn("flex w-full cursor-pointer items-center justify-between gap-3 rounded px-2 py-1 text-left text-sm", index === highlighted ? "bg-bg-subtle" : "hover:bg-bg-subtle"),
|
|
3912
|
+
onMouseEnter: () => setHighlighted(index),
|
|
3913
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
3914
|
+
onClick: () => applySuggestion(suggestion),
|
|
3915
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3916
|
+
className: "text-text-primary truncate font-mono",
|
|
3917
|
+
children: suggestion.label
|
|
3918
|
+
}), suggestion.hint && /* @__PURE__ */ jsx("span", {
|
|
3919
|
+
className: "text-text-tertiary shrink-0 text-xs",
|
|
3920
|
+
children: suggestion.hint
|
|
3921
|
+
})]
|
|
3922
|
+
}) }, `${suggestion.kind}-${suggestion.label}`))
|
|
3923
|
+
}),
|
|
3924
|
+
showClauses && value.clauses.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
3925
|
+
className: "flex flex-wrap items-center gap-1.5",
|
|
3926
|
+
children: value.clauses.map((clause, index) => {
|
|
3927
|
+
const label = describeClause(clause);
|
|
3928
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
3929
|
+
className: cn("bg-bg-subtle text-text-secondary flex items-center gap-1 rounded px-1.5 py-0.5 text-xs", clause.negated && "text-danger-fg"),
|
|
3930
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3931
|
+
className: "truncate",
|
|
3932
|
+
children: label
|
|
3933
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
3934
|
+
type: "button",
|
|
3935
|
+
"aria-label": labels.removeClause(label),
|
|
3936
|
+
className: "hover:text-text-primary cursor-pointer",
|
|
3937
|
+
onClick: () => {
|
|
3938
|
+
const next = removeClause(value, index);
|
|
3939
|
+
setText(formatQuery(next));
|
|
3940
|
+
committedRef.current = formatQuery(next);
|
|
3941
|
+
onChange(next);
|
|
3942
|
+
},
|
|
3943
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
3944
|
+
className: "size-3",
|
|
3945
|
+
"aria-hidden": true
|
|
3946
|
+
})
|
|
3947
|
+
})]
|
|
3948
|
+
}, `${label}-${index}`);
|
|
3949
|
+
})
|
|
3950
|
+
}),
|
|
3951
|
+
parsed.diagnostics.length > 0 && /* @__PURE__ */ jsx(QueryDiagnostics, { diagnostics: parsed.diagnostics }),
|
|
3952
|
+
labels.syntaxHint && !showSuggestions && /* @__PURE__ */ jsx("p", {
|
|
3953
|
+
className: "text-text-tertiary text-xs",
|
|
3954
|
+
children: labels.syntaxHint
|
|
3955
|
+
})
|
|
3956
|
+
]
|
|
3957
|
+
});
|
|
3958
|
+
}
|
|
3959
|
+
QueryBar.displayName = "QueryBar";
|
|
3960
|
+
function QueryDiagnostics({ diagnostics }) {
|
|
3961
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
3962
|
+
className: "text-warning-fg flex flex-col gap-0.5 text-xs",
|
|
3963
|
+
children: diagnostics.map((diagnostic, index) => /* @__PURE__ */ jsxs("li", { children: [
|
|
3964
|
+
/* @__PURE__ */ jsx("code", {
|
|
3965
|
+
className: "font-mono",
|
|
3966
|
+
children: diagnostic.text
|
|
3967
|
+
}),
|
|
3968
|
+
" —",
|
|
3969
|
+
" ",
|
|
3970
|
+
diagnostic.message
|
|
3971
|
+
] }, `${diagnostic.at}-${index}`))
|
|
3972
|
+
});
|
|
3973
|
+
}
|
|
3974
|
+
/**
|
|
3975
|
+
* What to offer, based on the token under the cursor.
|
|
3976
|
+
*
|
|
3977
|
+
* Completing fields is the part that makes the syntax discoverable at all —
|
|
3978
|
+
* nobody guesses that `utm_source` is a field they can filter on. Once the
|
|
3979
|
+
* field is chosen, its known values are the second half of the same guess.
|
|
3980
|
+
*/
|
|
3981
|
+
function useSuggestions(text, trailing, fields) {
|
|
3982
|
+
return useMemo(() => {
|
|
3983
|
+
const lastSpace = text.lastIndexOf(" ");
|
|
3984
|
+
const head = lastSpace === -1 ? "" : text.slice(0, lastSpace + 1);
|
|
3985
|
+
const token = text.slice(lastSpace + 1);
|
|
3986
|
+
if (trailing) {
|
|
3987
|
+
var _field$values;
|
|
3988
|
+
const field = fields.find((candidate) => candidate.name === trailing.field);
|
|
3989
|
+
const values = (_field$values = field === null || field === void 0 ? void 0 : field.values) !== null && _field$values !== void 0 ? _field$values : [];
|
|
3990
|
+
const typed = trailing.value.toLowerCase();
|
|
3991
|
+
return values.filter((value) => value.toLowerCase().includes(typed)).slice(0, MAX_SUGGESTIONS).map((value) => ({
|
|
3992
|
+
kind: "value",
|
|
3993
|
+
label: `${trailing.field}:${value}`,
|
|
3994
|
+
replace: () => `${head}${trailing.field}:${/[\s"()]/.test(value) ? `"${value}"` : value} `
|
|
3995
|
+
}));
|
|
3996
|
+
}
|
|
3997
|
+
const bare = token.replace(/^-/, "").toLowerCase();
|
|
3998
|
+
if (bare.length === 0) return [];
|
|
3999
|
+
return fields.filter((field) => field.name.toLowerCase().includes(bare)).slice(0, MAX_SUGGESTIONS).map((field) => ({
|
|
4000
|
+
kind: "field",
|
|
4001
|
+
label: `${field.name}:`,
|
|
4002
|
+
hint: field.hint,
|
|
4003
|
+
replace: () => `${head}${token.startsWith("-") ? "-" : ""}${field.name}:`
|
|
4004
|
+
}));
|
|
4005
|
+
}, [
|
|
4006
|
+
text,
|
|
4007
|
+
trailing,
|
|
4008
|
+
fields
|
|
4009
|
+
]);
|
|
4010
|
+
}
|
|
4011
|
+
//#endregion
|
|
4012
|
+
//#region src/shells/field-sidebar.tsx
|
|
4013
|
+
const defaultLabels = {
|
|
4014
|
+
heading: "Fields",
|
|
4015
|
+
searchPlaceholder: "Find a field",
|
|
4016
|
+
searchLabel: "Find a field",
|
|
4017
|
+
empty: "No fields match.",
|
|
4018
|
+
addColumn: (field) => `Show ${field} as a column`,
|
|
4019
|
+
removeColumn: (field) => `Remove the ${field} column`,
|
|
4020
|
+
filterFor: (value) => `Filter for ${value}`,
|
|
4021
|
+
filterOut: (value) => `Filter out ${value}`,
|
|
4022
|
+
topValues: (count) => `Top ${count} values`,
|
|
4023
|
+
noValues: "No values in this range.",
|
|
4024
|
+
loadingValues: "Counting…",
|
|
4025
|
+
otherGroup: "Other"
|
|
4026
|
+
};
|
|
4027
|
+
/**
|
|
4028
|
+
* FieldSidebar — what is in this data, and what does it contain.
|
|
4029
|
+
*
|
|
4030
|
+
* Without it, a log answers only the questions you already knew to ask: you can
|
|
4031
|
+
* filter on `utm_source` if you remember it exists, and you can read a value if
|
|
4032
|
+
* you open a row and scroll to it. Listing the fields turns that around — the
|
|
4033
|
+
* data tells the reader what is available — and the value counts answer the
|
|
4034
|
+
* question that actually follows ("mostly which?") before they have to run a
|
|
4035
|
+
* query to find out.
|
|
4036
|
+
*
|
|
4037
|
+
* Three actions live here because they are the three things people do next:
|
|
4038
|
+
* put the field in the table, keep only rows with a value, drop rows with it.
|
|
4039
|
+
*
|
|
4040
|
+
* @example
|
|
4041
|
+
* ```tsx
|
|
4042
|
+
* <FieldSidebar
|
|
4043
|
+
* fields={fields}
|
|
4044
|
+
* expandedField={openField}
|
|
4045
|
+
* onExpandedFieldChange={setOpenField}
|
|
4046
|
+
* values={valuesQuery.data}
|
|
4047
|
+
* valuesLoading={valuesQuery.isLoading}
|
|
4048
|
+
* onToggleColumn={(field, next) => setColumns(...)}
|
|
4049
|
+
* onFilter={(field, value, intent) => setQuery(applyCellAction(query, { field, value, intent }))}
|
|
4050
|
+
* />
|
|
4051
|
+
* ```
|
|
4052
|
+
*/
|
|
4053
|
+
function FieldSidebar({ fields, expandedField = null, onExpandedFieldChange, values, valuesLoading = false, sampledRows, onToggleColumn, onFilter, header, className, labels: customLabels }) {
|
|
4054
|
+
const labels = _objectSpread2(_objectSpread2({}, defaultLabels), customLabels);
|
|
4055
|
+
const [search, setSearch] = useState("");
|
|
4056
|
+
const groups = useMemo(() => {
|
|
4057
|
+
const needle = search.trim().toLowerCase();
|
|
4058
|
+
const matching = needle ? fields.filter((field) => field.name.toLowerCase().includes(needle)) : fields;
|
|
4059
|
+
const byGroup = /* @__PURE__ */ new Map();
|
|
4060
|
+
for (const field of matching) {
|
|
4061
|
+
var _field$group;
|
|
4062
|
+
const key = (_field$group = field.group) !== null && _field$group !== void 0 ? _field$group : "";
|
|
4063
|
+
const bucket = byGroup.get(key);
|
|
4064
|
+
if (bucket) bucket.push(field);
|
|
4065
|
+
else byGroup.set(key, [field]);
|
|
4066
|
+
}
|
|
4067
|
+
return [...byGroup.entries()];
|
|
4068
|
+
}, [fields, search]);
|
|
4069
|
+
const total = useMemo(() => (values !== null && values !== void 0 ? values : []).reduce((sum, entry) => sum + entry.count, 0), [values]);
|
|
4070
|
+
return /* @__PURE__ */ jsxs("aside", {
|
|
4071
|
+
className: cn("flex min-h-0 flex-col", className),
|
|
4072
|
+
"aria-label": labels.heading,
|
|
4073
|
+
"data-opt-id": "17D4Y",
|
|
4074
|
+
"data-opt-slug": "field-sidebar.FieldSidebar",
|
|
4075
|
+
children: [
|
|
4076
|
+
header,
|
|
4077
|
+
/* @__PURE__ */ jsxs("div", {
|
|
4078
|
+
className: cn("flex items-center gap-2 border-b px-3 py-2", "focus-within:border-accent transition-colors", OPT_BORDER),
|
|
4079
|
+
children: [/* @__PURE__ */ jsx(Search, {
|
|
4080
|
+
className: "text-text-tertiary size-3.5 shrink-0",
|
|
4081
|
+
"aria-hidden": true
|
|
4082
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
4083
|
+
type: "search",
|
|
4084
|
+
"aria-label": labels.searchLabel,
|
|
4085
|
+
placeholder: labels.searchPlaceholder,
|
|
4086
|
+
className: cn("text-text-primary placeholder:text-text-tertiary min-w-0 flex-1", "bg-transparent text-sm outline-none focus-visible:outline-none"),
|
|
4087
|
+
value: search,
|
|
4088
|
+
onChange: (event) => setSearch(event.target.value)
|
|
4089
|
+
})]
|
|
4090
|
+
}),
|
|
4091
|
+
/* @__PURE__ */ jsx("div", {
|
|
4092
|
+
className: "min-h-0 flex-1 overflow-y-auto",
|
|
4093
|
+
children: groups.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
4094
|
+
className: cn(OPT_TEXT_TERTIARY, "px-3 py-4 text-xs"),
|
|
4095
|
+
children: labels.empty
|
|
4096
|
+
}) : groups.map(([group, groupFields]) => /* @__PURE__ */ jsxs("section", { children: [group && /* @__PURE__ */ jsx("h4", {
|
|
4097
|
+
className: cn("text-text-tertiary", "px-3 pt-3 pb-1 text-[11px] font-medium tracking-wide uppercase"),
|
|
4098
|
+
children: group
|
|
4099
|
+
}), /* @__PURE__ */ jsx("ul", { children: groupFields.map((field) => /* @__PURE__ */ jsx(FieldRow, {
|
|
4100
|
+
field,
|
|
4101
|
+
expanded: expandedField === field.name,
|
|
4102
|
+
onToggleExpanded: () => onExpandedFieldChange === null || onExpandedFieldChange === void 0 ? void 0 : onExpandedFieldChange(expandedField === field.name ? null : field.name),
|
|
4103
|
+
onToggleColumn,
|
|
4104
|
+
labels,
|
|
4105
|
+
children: expandedField === field.name && /* @__PURE__ */ jsx(FieldValues, {
|
|
4106
|
+
values,
|
|
4107
|
+
loading: valuesLoading,
|
|
4108
|
+
total,
|
|
4109
|
+
sampledRows,
|
|
4110
|
+
onFilter: onFilter ? (value, intent) => onFilter(field.name, value, intent) : void 0,
|
|
4111
|
+
labels
|
|
4112
|
+
})
|
|
4113
|
+
}, field.name)) })] }, group || "__ungrouped__"))
|
|
4114
|
+
})
|
|
4115
|
+
]
|
|
4116
|
+
});
|
|
4117
|
+
}
|
|
4118
|
+
FieldSidebar.displayName = "FieldSidebar";
|
|
4119
|
+
function FieldRow({ field, expanded, onToggleExpanded, onToggleColumn, labels, children }) {
|
|
4120
|
+
var _field$columnable, _field$inTable;
|
|
4121
|
+
const columnable = (_field$columnable = field.columnable) !== null && _field$columnable !== void 0 ? _field$columnable : true;
|
|
4122
|
+
return /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsxs("div", {
|
|
4123
|
+
className: "hover:bg-bg-subtle group/field flex items-center gap-1.5 px-3 py-1",
|
|
4124
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
4125
|
+
type: "button",
|
|
4126
|
+
className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left",
|
|
4127
|
+
"aria-expanded": expanded,
|
|
4128
|
+
onClick: onToggleExpanded,
|
|
4129
|
+
children: [field.type && /* @__PURE__ */ jsx("span", {
|
|
4130
|
+
className: cn("text-text-tertiary", "w-8 shrink-0 truncate font-mono text-[10px] uppercase"),
|
|
4131
|
+
children: field.type
|
|
4132
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
4133
|
+
className: "text-text-primary truncate font-mono text-xs",
|
|
4134
|
+
children: field.name
|
|
4135
|
+
})]
|
|
4136
|
+
}), onToggleColumn && columnable && /* @__PURE__ */ jsx("button", {
|
|
4137
|
+
type: "button",
|
|
4138
|
+
className: cn("cursor-pointer rounded-sm p-0.5", field.inTable ? "text-accent" : "text-text-tertiary hover:text-text-primary opacity-0 group-hover/field:opacity-100 focus-visible:opacity-100"),
|
|
4139
|
+
"aria-label": field.inTable ? labels.removeColumn(field.name) : labels.addColumn(field.name),
|
|
4140
|
+
title: field.inTable ? labels.removeColumn(field.name) : labels.addColumn(field.name),
|
|
4141
|
+
"aria-pressed": (_field$inTable = field.inTable) !== null && _field$inTable !== void 0 ? _field$inTable : false,
|
|
4142
|
+
onClick: () => onToggleColumn(field.name, !field.inTable),
|
|
4143
|
+
children: /* @__PURE__ */ jsx(Columns3, {
|
|
4144
|
+
className: "size-3.5",
|
|
4145
|
+
"aria-hidden": true
|
|
4146
|
+
})
|
|
4147
|
+
})]
|
|
4148
|
+
}), children] });
|
|
4149
|
+
}
|
|
4150
|
+
/**
|
|
4151
|
+
* The distribution, as bars.
|
|
4152
|
+
*
|
|
4153
|
+
* A count alone ("342") means nothing without the denominator, and a reader
|
|
4154
|
+
* scanning for "what is this field mostly" reads the bar before the number.
|
|
4155
|
+
* The sample size is stated rather than implied — these are the top values in
|
|
4156
|
+
* the rows that were counted, not in all of history, and a chart that hides
|
|
4157
|
+
* that invites the wrong conclusion.
|
|
4158
|
+
*/
|
|
4159
|
+
function FieldValues({ values, loading, total, sampledRows, onFilter, labels }) {
|
|
4160
|
+
if (loading) return /* @__PURE__ */ jsxs("p", {
|
|
4161
|
+
className: cn(OPT_TEXT_TERTIARY, "flex items-center gap-2 px-3 pb-2 text-xs"),
|
|
4162
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
4163
|
+
size: "sm",
|
|
4164
|
+
"aria-hidden": true
|
|
4165
|
+
}), labels.loadingValues]
|
|
4166
|
+
});
|
|
4167
|
+
if (!values || values.length === 0) return /* @__PURE__ */ jsx("p", {
|
|
4168
|
+
className: cn(OPT_TEXT_TERTIARY, "px-3 pb-2 text-xs"),
|
|
4169
|
+
children: labels.noValues
|
|
4170
|
+
});
|
|
4171
|
+
const denominator = sampledRows !== null && sampledRows !== void 0 ? sampledRows : total;
|
|
4172
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4173
|
+
className: "flex flex-col gap-1 px-3 pt-1 pb-2",
|
|
4174
|
+
children: [/* @__PURE__ */ jsxs("p", {
|
|
4175
|
+
className: cn(OPT_TEXT_TERTIARY, "text-[11px]"),
|
|
4176
|
+
children: [labels.topValues(values.length), sampledRows ? ` · ${sampledRows.toLocaleString()}` : ""]
|
|
4177
|
+
}), values.map((entry) => {
|
|
4178
|
+
var _entry$share;
|
|
4179
|
+
const share = (_entry$share = entry.share) !== null && _entry$share !== void 0 ? _entry$share : denominator > 0 ? entry.count / denominator : 0;
|
|
4180
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4181
|
+
className: "group/value flex flex-col gap-0.5",
|
|
4182
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4183
|
+
className: "flex items-center justify-between gap-2",
|
|
4184
|
+
children: [
|
|
4185
|
+
/* @__PURE__ */ jsx("span", {
|
|
4186
|
+
className: "text-text-secondary min-w-0 flex-1 truncate font-mono text-[11px]",
|
|
4187
|
+
title: entry.value,
|
|
4188
|
+
children: entry.value || "—"
|
|
4189
|
+
}),
|
|
4190
|
+
/* @__PURE__ */ jsxs("span", {
|
|
4191
|
+
className: cn(OPT_TEXT_TERTIARY, "shrink-0 text-[11px] tabular-nums"),
|
|
4192
|
+
children: [Math.round(share * 100), "%"]
|
|
4193
|
+
}),
|
|
4194
|
+
onFilter && /* @__PURE__ */ jsxs("span", {
|
|
4195
|
+
className: "hidden shrink-0 items-center gap-0.5 group-hover/value:flex focus-within:flex",
|
|
4196
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
4197
|
+
type: "button",
|
|
4198
|
+
className: "text-text-tertiary hover:text-text-primary cursor-pointer",
|
|
4199
|
+
"aria-label": labels.filterFor(entry.value),
|
|
4200
|
+
title: labels.filterFor(entry.value),
|
|
4201
|
+
onClick: () => onFilter(entry.value, "include"),
|
|
4202
|
+
children: /* @__PURE__ */ jsx(Plus, {
|
|
4203
|
+
className: "size-3",
|
|
4204
|
+
"aria-hidden": true
|
|
4205
|
+
})
|
|
4206
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
4207
|
+
type: "button",
|
|
4208
|
+
className: "text-text-tertiary hover:text-text-primary cursor-pointer",
|
|
4209
|
+
"aria-label": labels.filterOut(entry.value),
|
|
4210
|
+
title: labels.filterOut(entry.value),
|
|
4211
|
+
onClick: () => onFilter(entry.value, "exclude"),
|
|
4212
|
+
children: /* @__PURE__ */ jsx(Minus, {
|
|
4213
|
+
className: "size-3",
|
|
4214
|
+
"aria-hidden": true
|
|
4215
|
+
})
|
|
4216
|
+
})]
|
|
4217
|
+
})
|
|
4218
|
+
]
|
|
4219
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4220
|
+
className: "bg-bg-muted h-1 w-full overflow-hidden rounded-full",
|
|
4221
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
4222
|
+
className: "bg-accent h-full rounded-full",
|
|
4223
|
+
style: { width: `${Math.max(2, Math.round(share * 100))}%` }
|
|
4224
|
+
})
|
|
4225
|
+
})]
|
|
4226
|
+
}, entry.value);
|
|
4227
|
+
})]
|
|
4228
|
+
});
|
|
4229
|
+
}
|
|
4230
|
+
//#endregion
|
|
4231
|
+
export { CommandList$1 as $, DataTable as A, SidebarNav as B, WorkflowCanvas as C, ToastProvider as D, NotificationToast as E, DeploymentTimeline as F, CommandPaletteTrigger as G, StatusSelect as H, SettingsForm as I, CommandDialog as J, CommandPalette as K, FaqAccordion as L, BranchSelect as M, EnvPanel as N, toast as O, ProjectSwitcher as P, CommandItem$1 as Q, ContentTabs as R, useAutoRefresh as S, FailureList as T, SearchCombobox as U, AppMenubar as V, DashboardGrid as W, CommandGroup$1 as X, CommandEmpty$1 as Y, CommandInput$1 as Z, withoutField as _, formatQuery as a, DEFAULT_TIME_PRESETS as b, parseQueryWithDiagnostics as c, applyCellAction as d, CommandSeparator$1 as et, fieldValues as f, withFieldValue as g, removeClause as h, formatClause as i, DomainTable as j, useToast as k, EMPTY_QUERY as l, queryFields as m, QueryBar as n, quoteValue as o, isEmptyQuery as p, Command as q, describeClause as r, parseQuery as s, FieldSidebar as t, CommandShortcut as tt, addClause as u, LogTable as v, KeyValueEditor as w, TimeRangeControl as x, TimeSeriesPanel as y, EditorToolbar as z };
|
|
4232
|
+
|
|
4233
|
+
//# sourceMappingURL=field-sidebar-Cs-J-5VE.js.map
|