@bettercms-ai/kit 3.2.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/lossy.d.ts +4 -0
- package/dist/adapters/lossy.js +4 -0
- package/dist/adapters/lossy.js.map +1 -1
- package/dist/adapters/prod-types.d.ts +4 -0
- package/dist/adapters/prod-types.js +4 -1
- package/dist/adapters/prod-types.js.map +1 -1
- package/dist/adapters/schema.js +7 -0
- package/dist/adapters/schema.js.map +1 -1
- package/dist/context.d.ts +81 -4
- package/dist/context.js +58 -1
- package/dist/context.js.map +1 -1
- package/dist/controls/choice.d.ts +1 -1
- package/dist/controls/choice.js +21 -2
- package/dist/controls/choice.js.map +1 -1
- package/dist/controls/index.d.ts +1 -0
- package/dist/controls/index.js +3 -2
- package/dist/controls/index.js.map +1 -1
- package/dist/controls/link.d.ts +23 -2
- package/dist/controls/link.js +456 -4
- package/dist/controls/link.js.map +1 -1
- package/dist/controls/media-v16.d.ts +27 -0
- package/dist/controls/media-v16.js +261 -0
- package/dist/controls/media-v16.js.map +1 -0
- package/dist/controls/media.js +63 -1
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/reference-services.d.ts +8 -0
- package/dist/controls/reference.js +78 -2
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/ai-runs.d.ts +13 -0
- package/dist/controls/rich-text/ai-runs.js +71 -0
- package/dist/controls/rich-text/ai-runs.js.map +1 -0
- package/dist/controls/rich-text/block-tool.d.ts +31 -0
- package/dist/controls/rich-text/block-tool.js +62 -0
- package/dist/controls/rich-text/block-tool.js.map +1 -0
- package/dist/controls/rich-text/blocks.d.ts +6 -1
- package/dist/controls/rich-text/blocks.js +404 -24
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/catalog.d.ts +21 -6
- package/dist/controls/rich-text/catalog.js +312 -23
- package/dist/controls/rich-text/catalog.js.map +1 -1
- package/dist/controls/rich-text/code-head.d.ts +30 -0
- package/dist/controls/rich-text/code-head.js +230 -0
- package/dist/controls/rich-text/code-head.js.map +1 -0
- package/dist/controls/rich-text/codec.d.ts +3 -3
- package/dist/controls/rich-text/codec.js +3 -1
- package/dist/controls/rich-text/codec.js.map +1 -1
- package/dist/controls/rich-text/control.d.ts +1 -1
- package/dist/controls/rich-text/control.js +11 -29
- package/dist/controls/rich-text/control.js.map +1 -1
- package/dist/controls/rich-text/dom.d.ts +27 -0
- package/dist/controls/rich-text/dom.js +69 -4
- package/dist/controls/rich-text/dom.js.map +1 -1
- package/dist/controls/rich-text/editor.js +212 -50
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/ops.js +1 -0
- package/dist/controls/rich-text/ops.js.map +1 -1
- package/dist/controls/rich-text/slash-preview.d.ts +8 -0
- package/dist/controls/rich-text/slash-preview.js +287 -0
- package/dist/controls/rich-text/slash-preview.js.map +1 -0
- package/dist/controls/rich-text/table-grid.d.ts +22 -0
- package/dist/controls/rich-text/table-grid.js +1052 -0
- package/dist/controls/rich-text/table-grid.js.map +1 -0
- package/dist/controls/rich-text/toolbar.js +60 -18
- package/dist/controls/rich-text/toolbar.js.map +1 -1
- package/dist/controls/text.d.ts +6 -0
- package/dist/controls/text.js +95 -5
- package/dist/controls/text.js.map +1 -1
- package/dist/core/facets.d.ts +1 -0
- package/dist/core/facets.js +1 -0
- package/dist/core/facets.js.map +1 -1
- package/dist/engine/array.d.ts +7 -0
- package/dist/engine/array.js +164 -45
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/expand.d.ts +1 -1
- package/dist/engine/expand.js +1 -1
- package/dist/engine/expand.js.map +1 -1
- package/dist/engine/field-shell.d.ts +12 -0
- package/dist/engine/field-shell.js +217 -63
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +39 -2
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.d.ts +71 -10
- package/dist/engine/grouping.js +223 -26
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/held.d.ts +2 -2
- package/dist/engine/held.js +2 -2
- package/dist/engine/held.js.map +1 -1
- package/dist/engine/kit-field.d.ts +0 -10
- package/dist/engine/kit-field.js +40 -72
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/engine/schema-form.js +7 -2
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/dist/kit.css +85 -0
- package/dist/schema/table.d.ts +2 -1
- package/dist/schema/table.js +5 -0
- package/dist/schema/table.js.map +1 -1
- package/dist/schema/types.d.ts +6 -0
- package/dist/schema/types.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +115 -0
- package/dist/tokens.css +268 -0
- package/dist/ui/block-icon-picker.d.ts +38 -0
- package/dist/ui/block-icon-picker.js +141 -0
- package/dist/ui/block-icon-picker.js.map +1 -0
- package/dist/ui/button.js +1 -0
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/code-language-menu.d.ts +24 -0
- package/dist/ui/code-language-menu.js +123 -0
- package/dist/ui/code-language-menu.js.map +1 -0
- package/dist/ui/content-fields.d.ts +47 -0
- package/dist/ui/content-fields.js +278 -0
- package/dist/ui/content-fields.js.map +1 -0
- package/dist/ui/foundations.d.ts +118 -0
- package/dist/ui/foundations.js +564 -0
- package/dist/ui/foundations.js.map +1 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.js +7 -1
- package/dist/ui/inspector.d.ts +394 -0
- package/dist/ui/inspector.js +1173 -0
- package/dist/ui/inspector.js.map +1 -0
- package/dist/ui/overlay.d.ts +7 -2
- package/dist/ui/overlay.js +55 -20
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/shortcut-hint.js +1 -1
- package/dist/ui/shortcut-hint.js.map +1 -1
- package/dist/ui/toast.d.ts +5 -3
- package/dist/ui/toast.js +83 -11
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/tooltip-card.d.ts +45 -0
- package/dist/ui/tooltip-card.js +135 -0
- package/dist/ui/tooltip-card.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1173 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { InfoTooltip } from "./tooltip-card.js";
|
|
3
|
+
import { Menu, MenuContent, MenuItem, MenuLabel, MenuSeparator, MenuTrigger } from "./overlay.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { IconCheck, IconChevronDown, IconDots, IconGripVertical, IconInfoCircle, IconLock } from "@tabler/icons-react";
|
|
7
|
+
import { AnimatePresence, motion, useReducedMotion } from "framer-motion";
|
|
8
|
+
//#region src/ui/inspector.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Inspector foundation · V1.6: the Visual Editor inspector's own building blocks, as prototype editor-v16 draws them
|
|
11
|
+
* (src/kit.jsx:59-250, kit.css:1-100, styles.css:153-218 + 286-289, editor.css:242-251 + 411-461, faq.css:48-49).
|
|
12
|
+
*
|
|
13
|
+
* <InspectorBody> groups stacked 32 apart, 24/16/32 padding, a 1px divider 20 under every group but the last
|
|
14
|
+
* <InspectorGroup> one group: header, then its fields 16 below
|
|
15
|
+
* <GroupHeader> Content tab group: 14/20 medium title + 13/18 supporting line
|
|
16
|
+
* <SectionHeader> Design / Settings group: 16 icon + 14/20 medium, trailing Reset · Locked · collapse chevron
|
|
17
|
+
* <InspectorFields> stacked fields 20 apart (`rows`: inline rows 12 apart)
|
|
18
|
+
* <InlineRow> label left, control right in a fixed 194 column
|
|
19
|
+
* <InspectorSeg> segmented control with the sliding pill
|
|
20
|
+
* <SelectCompact> / <SelectField> / <ColourSelect> grey field selects (32 compact, 34 full width)
|
|
21
|
+
* <StepSlider> / <StepRow> / <ValueSlider> the stop slider and the value-inside slider
|
|
22
|
+
* <ToggleRow> / <ToggleCard> / <InspectorSwitch> label-left switch rows, related ones in one grey card
|
|
23
|
+
* <ItemListCard> + <ItemRow> + <ItemListAdd> + <ItemListNote> the grey item list card
|
|
24
|
+
* <ItemDeleteButton> the red "Delete <noun>" that ends an item screen
|
|
25
|
+
* <InspectorField> + <FieldCounter> label row with the focus dot, the sweep, and the n / max counter
|
|
26
|
+
*
|
|
27
|
+
* Editor-scoped: these read the --kit-insp-* roles (tokens.css) and nothing else in the kit draws them unless a host
|
|
28
|
+
* asks (`KitLookProvider look="v16"` for the engine). Every other kit consumer keeps the V2 look.
|
|
29
|
+
*/
|
|
30
|
+
/** The prototype's accordion curve (kit.jsx:60 ACC) and its sliding-pill spring (kit.jsx:59 PILL). */
|
|
31
|
+
var INSPECTOR_EASE = [
|
|
32
|
+
.22,
|
|
33
|
+
1,
|
|
34
|
+
.36,
|
|
35
|
+
1
|
|
36
|
+
];
|
|
37
|
+
var PILL = {
|
|
38
|
+
type: "spring",
|
|
39
|
+
stiffness: 520,
|
|
40
|
+
damping: 40,
|
|
41
|
+
mass: .8
|
|
42
|
+
};
|
|
43
|
+
var FOCUS = "outline-none focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-kit-insp-accent";
|
|
44
|
+
/** Panel body (kit.css:6-8). `sub` = a drill-in screen (16 on top instead of 24). */
|
|
45
|
+
function InspectorBody({ sub, className, children, ...rest }) {
|
|
46
|
+
return /* @__PURE__ */ jsx("div", {
|
|
47
|
+
"data-slot": "kit-insp-body",
|
|
48
|
+
className: cn("flex min-w-0 flex-col gap-8 px-4 pb-8", sub ? "pt-4" : "pt-6", "[&>[data-slot=kit-insp-group]:not(:last-child)]:border-b [&>[data-slot=kit-insp-group]:not(:last-child)]:border-kit-insp-divider [&>[data-slot=kit-insp-group]:not(:last-child)]:pb-5", className),
|
|
49
|
+
...rest,
|
|
50
|
+
children
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** One group in the body (kit.css:9, 13, 36). `locked` greys its fields and makes them read-only; `flash` runs the
|
|
54
|
+
* 1.2s violet flash a jump-to-group ends with. */
|
|
55
|
+
function InspectorGroup({ locked, flash, className, children, ...rest }) {
|
|
56
|
+
return /* @__PURE__ */ jsx("section", {
|
|
57
|
+
"data-slot": "kit-insp-group",
|
|
58
|
+
"data-locked": locked || void 0,
|
|
59
|
+
className: cn("flex min-w-0 flex-col gap-4", flash && "animate-[kit-insp-group-flash_1.2s_ease] motion-reduce:animate-none", className),
|
|
60
|
+
...rest,
|
|
61
|
+
children
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** The fields of a group (kit.css:10-11): 20 apart, or 12 for a run of inline rows. */
|
|
65
|
+
function InspectorFields({ rows, className, children, ...rest }) {
|
|
66
|
+
return /* @__PURE__ */ jsx("div", {
|
|
67
|
+
"data-slot": "kit-insp-fields",
|
|
68
|
+
className: cn("flex min-w-0 flex-col", rows ? "gap-3" : "gap-5", className),
|
|
69
|
+
...rest,
|
|
70
|
+
children
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** The 1px rule between groups, for a host that stacks groups outside <InspectorBody> (kit.css:8). */
|
|
74
|
+
function InspectorDivider({ className }) {
|
|
75
|
+
return /* @__PURE__ */ jsx("div", {
|
|
76
|
+
role: "separator",
|
|
77
|
+
"data-slot": "kit-insp-divider",
|
|
78
|
+
className: cn("h-px w-full shrink-0 bg-kit-insp-divider", className)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** Fields a role cannot edit (kit.css:36-37): one disabled fieldset at .45. */
|
|
82
|
+
function InspectorLocked({ on, children }) {
|
|
83
|
+
if (!on) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
84
|
+
return /* @__PURE__ */ jsx("fieldset", {
|
|
85
|
+
disabled: true,
|
|
86
|
+
"aria-disabled": "true",
|
|
87
|
+
"data-slot": "kit-insp-locked",
|
|
88
|
+
className: "m-0 flex min-w-0 flex-col gap-[inherit] border-0 p-0 opacity-45 [&_*]:!cursor-default",
|
|
89
|
+
children
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** Level-1 content group header (kit.jsx:66-68, kit.css:16-19; the inspector's ink is insp.css:19-20). */
|
|
93
|
+
function GroupHeader({ title, sub, actions, titleId, className }) {
|
|
94
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
95
|
+
"data-slot": "kit-group-header",
|
|
96
|
+
className: cn("flex items-start gap-2", className),
|
|
97
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
98
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
99
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
100
|
+
id: titleId,
|
|
101
|
+
className: "text-[14px] font-medium leading-5 tracking-[-0.2px] text-kit-group-title",
|
|
102
|
+
children: title
|
|
103
|
+
}), sub ? /* @__PURE__ */ jsx("p", {
|
|
104
|
+
className: "text-[13px] leading-[18px] tracking-[-0.16px] text-kit-group-sub",
|
|
105
|
+
children: sub
|
|
106
|
+
}) : null]
|
|
107
|
+
}), actions]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** Design / Settings group header (kit.jsx:72-91, kit.css:22-33). Static unless trailing="collapse". */
|
|
111
|
+
function SectionHeader({ icon, title, trailing, onReset, resetDisabled, open, onToggle, desc, actions, titleId, controls, className }) {
|
|
112
|
+
const row = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
113
|
+
/* @__PURE__ */ jsxs("span", {
|
|
114
|
+
id: titleId,
|
|
115
|
+
className: "flex min-w-0 items-center gap-1.5 text-[14px] font-medium leading-5 text-kit-insp-title [&>svg]:size-4 [&>svg]:shrink-0 [&>img]:size-4 [&>img]:shrink-0",
|
|
116
|
+
children: [icon, /* @__PURE__ */ jsx("span", {
|
|
117
|
+
className: "truncate",
|
|
118
|
+
children: title
|
|
119
|
+
})]
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
122
|
+
trailing === "locked" ? /* @__PURE__ */ jsxs("span", {
|
|
123
|
+
className: "inline-flex items-center gap-1 text-[13px] text-kit-insp-faint",
|
|
124
|
+
children: [/* @__PURE__ */ jsx(IconLock, {
|
|
125
|
+
"aria-hidden": true,
|
|
126
|
+
className: "size-3.5",
|
|
127
|
+
stroke: 1.8
|
|
128
|
+
}), "Locked"]
|
|
129
|
+
}) : null,
|
|
130
|
+
trailing === "collapse" ? /* @__PURE__ */ jsx("span", {
|
|
131
|
+
"aria-hidden": true,
|
|
132
|
+
className: cn("grid text-kit-insp-desc transition-transform duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none", open && "rotate-180"),
|
|
133
|
+
children: /* @__PURE__ */ jsx(IconChevronDown, {
|
|
134
|
+
className: "size-4",
|
|
135
|
+
stroke: 1.6
|
|
136
|
+
})
|
|
137
|
+
}) : null
|
|
138
|
+
] });
|
|
139
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
140
|
+
"data-slot": "kit-section-header",
|
|
141
|
+
className: cn("flex flex-col gap-1", className),
|
|
142
|
+
children: [trailing === "collapse" ? /* @__PURE__ */ jsxs("div", {
|
|
143
|
+
className: "flex min-h-6 w-full items-center gap-1.5",
|
|
144
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
145
|
+
type: "button",
|
|
146
|
+
"aria-expanded": !!open,
|
|
147
|
+
"aria-controls": controls,
|
|
148
|
+
onClick: onToggle,
|
|
149
|
+
className: cn("flex min-h-6 min-w-0 flex-1 items-center gap-1.5 rounded-[4px] text-left", FOCUS),
|
|
150
|
+
children: row
|
|
151
|
+
}), actions]
|
|
152
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
153
|
+
className: "flex min-h-6 w-full items-center gap-1.5",
|
|
154
|
+
children: [
|
|
155
|
+
row,
|
|
156
|
+
actions,
|
|
157
|
+
trailing === "reset" ? /* @__PURE__ */ jsx("button", {
|
|
158
|
+
type: "button",
|
|
159
|
+
onClick: onReset,
|
|
160
|
+
disabled: resetDisabled,
|
|
161
|
+
"aria-label": typeof title === "string" ? `Reset ${title}` : void 0,
|
|
162
|
+
className: cn("rounded-[4px] px-0.5 text-[13px] text-kit-insp-quiet transition-colors enabled:hover:text-kit-insp-ink disabled:cursor-default disabled:opacity-50", FOCUS),
|
|
163
|
+
children: "Reset"
|
|
164
|
+
}) : null
|
|
165
|
+
]
|
|
166
|
+
}), desc ? /* @__PURE__ */ jsx("p", {
|
|
167
|
+
className: "m-0 text-[13px] leading-[18px] tracking-[-0.16px] text-kit-insp-desc",
|
|
168
|
+
children: desc
|
|
169
|
+
}) : null]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/** The quiet note under a group's fields (insp.css:32 `.adv-note`): 12/16 in the sub colour. */
|
|
173
|
+
function InspectorNote({ id, className, children }) {
|
|
174
|
+
return /* @__PURE__ */ jsx("p", {
|
|
175
|
+
id,
|
|
176
|
+
"data-slot": "kit-insp-note",
|
|
177
|
+
className: cn("m-0 text-[12px] leading-4 text-kit-group-sub", className),
|
|
178
|
+
children
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
var LAYOUT_GLYPHS = {
|
|
182
|
+
centred: /* @__PURE__ */ jsx("path", { d: "M4 6h16M8 12h8M6 18h12" }),
|
|
183
|
+
left: /* @__PURE__ */ jsx("path", { d: "M4 6h16M4 12h10M4 18h14" }),
|
|
184
|
+
stacked: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("rect", {
|
|
185
|
+
x: "4",
|
|
186
|
+
y: "4",
|
|
187
|
+
width: "16",
|
|
188
|
+
height: "16",
|
|
189
|
+
rx: "2"
|
|
190
|
+
}), /* @__PURE__ */ jsx("path", { d: "M4 12h16" })] }),
|
|
191
|
+
two: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("rect", {
|
|
192
|
+
x: "4",
|
|
193
|
+
y: "4",
|
|
194
|
+
width: "16",
|
|
195
|
+
height: "16",
|
|
196
|
+
rx: "2"
|
|
197
|
+
}), /* @__PURE__ */ jsx("path", { d: "M12 4v16" })] }),
|
|
198
|
+
three: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("rect", {
|
|
199
|
+
x: "3",
|
|
200
|
+
y: "3",
|
|
201
|
+
width: "18",
|
|
202
|
+
height: "18",
|
|
203
|
+
rx: "1"
|
|
204
|
+
}), /* @__PURE__ */ jsx("path", { d: "M9 3v18M15 3v18" })] }),
|
|
205
|
+
split: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("rect", {
|
|
206
|
+
x: "4",
|
|
207
|
+
y: "4",
|
|
208
|
+
width: "16",
|
|
209
|
+
height: "16",
|
|
210
|
+
rx: "2"
|
|
211
|
+
}), /* @__PURE__ */ jsx("path", { d: "M15 4v16" })] }),
|
|
212
|
+
formLeft: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("rect", {
|
|
213
|
+
x: "4",
|
|
214
|
+
y: "4",
|
|
215
|
+
width: "16",
|
|
216
|
+
height: "16",
|
|
217
|
+
rx: "2"
|
|
218
|
+
}), /* @__PURE__ */ jsx("path", { d: "M9 4v16" })] }),
|
|
219
|
+
row: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("path", { d: "M4 4v16M20 4v16" }), /* @__PURE__ */ jsx("rect", {
|
|
220
|
+
x: "9",
|
|
221
|
+
y: "6",
|
|
222
|
+
width: "6",
|
|
223
|
+
height: "12",
|
|
224
|
+
rx: "2"
|
|
225
|
+
})] }),
|
|
226
|
+
grid: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
227
|
+
/* @__PURE__ */ jsx("rect", {
|
|
228
|
+
x: "4",
|
|
229
|
+
y: "4",
|
|
230
|
+
width: "6",
|
|
231
|
+
height: "6",
|
|
232
|
+
rx: "1"
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ jsx("rect", {
|
|
235
|
+
x: "14",
|
|
236
|
+
y: "4",
|
|
237
|
+
width: "6",
|
|
238
|
+
height: "6",
|
|
239
|
+
rx: "1"
|
|
240
|
+
}),
|
|
241
|
+
/* @__PURE__ */ jsx("rect", {
|
|
242
|
+
x: "4",
|
|
243
|
+
y: "14",
|
|
244
|
+
width: "6",
|
|
245
|
+
height: "6",
|
|
246
|
+
rx: "1"
|
|
247
|
+
}),
|
|
248
|
+
/* @__PURE__ */ jsx("rect", {
|
|
249
|
+
x: "14",
|
|
250
|
+
y: "14",
|
|
251
|
+
width: "6",
|
|
252
|
+
height: "6",
|
|
253
|
+
rx: "1"
|
|
254
|
+
})
|
|
255
|
+
] }),
|
|
256
|
+
scroll: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("rect", {
|
|
257
|
+
x: "7",
|
|
258
|
+
y: "5",
|
|
259
|
+
width: "10",
|
|
260
|
+
height: "14",
|
|
261
|
+
rx: "1"
|
|
262
|
+
}), /* @__PURE__ */ jsx("path", { d: "M22 17h-1a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h1M2 17h1a1 1 0 0 0 1-1V8a1 1 0 0 0-1-1H2" })] })
|
|
263
|
+
};
|
|
264
|
+
/** A layout glyph, then the option's label: `<LayoutOpt i="two">Two columns</LayoutOpt>`. */
|
|
265
|
+
function LayoutOpt({ i, children }) {
|
|
266
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("svg", {
|
|
267
|
+
width: "14",
|
|
268
|
+
height: "14",
|
|
269
|
+
viewBox: "0 0 24 24",
|
|
270
|
+
fill: "none",
|
|
271
|
+
stroke: "currentColor",
|
|
272
|
+
strokeWidth: "1.75",
|
|
273
|
+
strokeLinecap: "round",
|
|
274
|
+
strokeLinejoin: "round",
|
|
275
|
+
"aria-hidden": true,
|
|
276
|
+
className: "shrink-0",
|
|
277
|
+
children: LAYOUT_GLYPHS[i]
|
|
278
|
+
}), children] });
|
|
279
|
+
}
|
|
280
|
+
/** Collapsible body for a SectionHeader with trailing="collapse" (kit.jsx:248-252): height, then a 4px rise out of a
|
|
281
|
+
* 4px blur, both on the accordion curve. Instant with reduced motion. */
|
|
282
|
+
function InspectorCollapse({ open, id, rows, className, children }) {
|
|
283
|
+
const reduce = useReducedMotion();
|
|
284
|
+
const t = {
|
|
285
|
+
duration: reduce ? 0 : .3,
|
|
286
|
+
ease: INSPECTOR_EASE
|
|
287
|
+
};
|
|
288
|
+
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
289
|
+
initial: false,
|
|
290
|
+
children: open ? /* @__PURE__ */ jsx(motion.div, {
|
|
291
|
+
id,
|
|
292
|
+
"data-slot": "kit-insp-collapse",
|
|
293
|
+
initial: { height: 0 },
|
|
294
|
+
animate: { height: "auto" },
|
|
295
|
+
exit: { height: 0 },
|
|
296
|
+
transition: t,
|
|
297
|
+
className: "min-w-0 overflow-hidden",
|
|
298
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
299
|
+
initial: reduce ? false : {
|
|
300
|
+
opacity: 0,
|
|
301
|
+
y: -4,
|
|
302
|
+
filter: "blur(4px)"
|
|
303
|
+
},
|
|
304
|
+
animate: {
|
|
305
|
+
opacity: 1,
|
|
306
|
+
y: 0,
|
|
307
|
+
filter: "blur(0px)"
|
|
308
|
+
},
|
|
309
|
+
exit: reduce ? void 0 : {
|
|
310
|
+
opacity: 0,
|
|
311
|
+
y: -4,
|
|
312
|
+
filter: "blur(4px)"
|
|
313
|
+
},
|
|
314
|
+
transition: t,
|
|
315
|
+
className: cn("flex min-w-0 flex-col", rows ? "gap-3" : "gap-5", className),
|
|
316
|
+
children
|
|
317
|
+
})
|
|
318
|
+
}, "c") : null
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* The inspector field shell (editor.css:411-431, kit.css:506-515): label row 13/16 medium, min 20 high, the control 8
|
|
323
|
+
* under it, then an optional 12/16 footer. `current` puts the focus dot after the label (order: label · dot · spacer ·
|
|
324
|
+
* meta); `flash` runs the left-to-right violet sweep behind the whole field (a plain fade with reduced motion).
|
|
325
|
+
*/
|
|
326
|
+
function InspectorField({ label, labelId, htmlFor, info, meta, current, flash, state, hint, counter, className, children, ...rest }) {
|
|
327
|
+
const labelCls = "flex min-h-5 items-center gap-1.5 text-[13px] font-medium leading-4 text-kit-insp-label";
|
|
328
|
+
const labelInner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
329
|
+
label,
|
|
330
|
+
info ? /* @__PURE__ */ jsx(InfoTooltip, {
|
|
331
|
+
title: label,
|
|
332
|
+
children: info
|
|
333
|
+
}) : null,
|
|
334
|
+
current ? /* @__PURE__ */ jsx(FocusDot, {}) : null,
|
|
335
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
336
|
+
meta
|
|
337
|
+
] });
|
|
338
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
339
|
+
"data-slot": "kit-insp-field",
|
|
340
|
+
"data-cur": current || void 0,
|
|
341
|
+
"data-state": state,
|
|
342
|
+
className: cn("relative flex min-w-0 flex-col gap-2 rounded-[4px]", flash ? "isolate" : null, className),
|
|
343
|
+
...rest,
|
|
344
|
+
children: [
|
|
345
|
+
flash ? /* @__PURE__ */ jsx(FieldSweep, {}, String(flash)) : null,
|
|
346
|
+
htmlFor ? /* @__PURE__ */ jsx("label", {
|
|
347
|
+
id: labelId,
|
|
348
|
+
htmlFor,
|
|
349
|
+
"data-slot": "kit-insp-label",
|
|
350
|
+
className: labelCls,
|
|
351
|
+
children: labelInner
|
|
352
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
353
|
+
id: labelId,
|
|
354
|
+
"data-slot": "kit-insp-label",
|
|
355
|
+
className: labelCls,
|
|
356
|
+
children: labelInner
|
|
357
|
+
}),
|
|
358
|
+
children,
|
|
359
|
+
hint || counter ? /* @__PURE__ */ jsxs("div", {
|
|
360
|
+
"data-slot": "kit-insp-field-foot",
|
|
361
|
+
className: cn("flex justify-between gap-3 text-[12px] leading-4", state === "over" ? "text-kit-insp-error" : "text-kit-insp-faint"),
|
|
362
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
363
|
+
className: "min-w-0",
|
|
364
|
+
children: hint
|
|
365
|
+
}), counter]
|
|
366
|
+
}) : null
|
|
367
|
+
]
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
/** The 6px violet dot after a field's label while it is the one a canvas click opened (kit.css:513-515). */
|
|
371
|
+
function FocusDot({ className }) {
|
|
372
|
+
return /* @__PURE__ */ jsx("span", {
|
|
373
|
+
"aria-hidden": true,
|
|
374
|
+
"data-slot": "kit-focus-dot",
|
|
375
|
+
className: cn("size-1.5 shrink-0 rounded-full bg-kit-insp-accent animate-[kit-insp-dot_0.24s_cubic-bezier(0.2,0.8,0.2,1)_both] motion-reduce:animate-none", className)
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
/** The soft violet fill that sweeps across a field a canvas click opened (kit.css:506-511). Sits behind the field, 6/8
|
|
379
|
+
* outside it; the parent must be `relative isolate`. */
|
|
380
|
+
function FieldSweep({ className }) {
|
|
381
|
+
return /* @__PURE__ */ jsx("span", {
|
|
382
|
+
"aria-hidden": true,
|
|
383
|
+
"data-slot": "kit-field-sweep",
|
|
384
|
+
className: cn("pointer-events-none absolute -inset-x-2 -inset-y-1.5 -z-10 rounded-[6px] bg-linear-to-r/srgb from-kit-insp-flash-a via-kit-insp-flash-b via-55% to-kit-insp-flash-c", "[clip-path:inset(0_100%_0_0_round_6px)] animate-[kit-insp-sweep_1.4s_cubic-bezier(0.4,0,0.2,1)_forwards]", "motion-reduce:[clip-path:none] motion-reduce:animate-[kit-insp-fade_1.6s_ease_forwards]", className)
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
/** How close a count is to its limit, by the prototype's rule (state.js:93 countLevel): "near" above 91% of the
|
|
388
|
+
* limit, "over" past it. */
|
|
389
|
+
function counterState(n, max) {
|
|
390
|
+
if (!max) return "ok";
|
|
391
|
+
return n > max ? "over" : n > Math.floor(max * .91) ? "near" : "ok";
|
|
392
|
+
}
|
|
393
|
+
/** The 12px progress ring beside a counter that is near or over its limit (content.jsx:307-309, content.css:617): a
|
|
394
|
+
* grey track, an amber arc that fills with the count, red when over. Springs in and out (wrap it in AnimatePresence). */
|
|
395
|
+
function CountRing({ value, max, className }) {
|
|
396
|
+
const reduce = useReducedMotion();
|
|
397
|
+
const r = 4.5;
|
|
398
|
+
const c = 2 * Math.PI * r;
|
|
399
|
+
const over = value > max;
|
|
400
|
+
return /* @__PURE__ */ jsxs(motion.svg, {
|
|
401
|
+
"aria-hidden": true,
|
|
402
|
+
"data-slot": "kit-count-ring",
|
|
403
|
+
width: "12",
|
|
404
|
+
height: "12",
|
|
405
|
+
viewBox: "0 0 12 12",
|
|
406
|
+
initial: reduce ? false : {
|
|
407
|
+
scale: .5,
|
|
408
|
+
opacity: 0
|
|
409
|
+
},
|
|
410
|
+
animate: {
|
|
411
|
+
scale: 1,
|
|
412
|
+
opacity: 1
|
|
413
|
+
},
|
|
414
|
+
exit: reduce ? { opacity: 0 } : {
|
|
415
|
+
scale: .5,
|
|
416
|
+
opacity: 0
|
|
417
|
+
},
|
|
418
|
+
transition: reduce ? { duration: 0 } : {
|
|
419
|
+
type: "spring",
|
|
420
|
+
stiffness: 520,
|
|
421
|
+
damping: 22
|
|
422
|
+
},
|
|
423
|
+
className: cn("shrink-0", className),
|
|
424
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
425
|
+
cx: "6",
|
|
426
|
+
cy: "6",
|
|
427
|
+
r,
|
|
428
|
+
fill: "none",
|
|
429
|
+
strokeWidth: "2",
|
|
430
|
+
className: "stroke-kit-insp-track"
|
|
431
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
432
|
+
cx: "6",
|
|
433
|
+
cy: "6",
|
|
434
|
+
r,
|
|
435
|
+
fill: "none",
|
|
436
|
+
strokeWidth: "2",
|
|
437
|
+
strokeLinecap: "round",
|
|
438
|
+
strokeDasharray: `${Math.min(value / max, 1) * c} ${c}`,
|
|
439
|
+
transform: "rotate(-90 6 6)",
|
|
440
|
+
className: cn("transition-[stroke-dasharray,stroke] duration-200 motion-reduce:transition-none", over ? "stroke-kit-insp-ring-over" : "stroke-kit-insp-ring-near")
|
|
441
|
+
})]
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
/** The field counter "42 / 60" (content.jsx:310-320; content.css:614-616; insp.css:163-164): 12/16 tabular, amber and
|
|
445
|
+
* medium when near the limit, red over it, with the ring beside it in both states. Without `max` it is the bare count. */
|
|
446
|
+
function FieldCounter({ value, max, ring = true, size = 11, className }) {
|
|
447
|
+
const s = counterState(value, max);
|
|
448
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
449
|
+
"data-slot": "kit-field-counter",
|
|
450
|
+
"data-state": s,
|
|
451
|
+
"aria-label": max == null ? `${value} characters` : `${value} of ${max} characters`,
|
|
452
|
+
className: cn("inline-flex shrink-0 items-center gap-1.5 tabular-nums transition-colors duration-200", size === 11 ? "text-[11px] leading-[14px]" : "text-[12px] leading-4", s === "near" ? "font-medium text-kit-insp-count-near" : s === "over" ? "font-medium text-kit-insp-count-over" : "text-kit-insp-faint", className),
|
|
453
|
+
children: [/* @__PURE__ */ jsx(AnimatePresence, {
|
|
454
|
+
initial: false,
|
|
455
|
+
children: ring && max && s !== "ok" ? /* @__PURE__ */ jsx(CountRing, {
|
|
456
|
+
value,
|
|
457
|
+
max
|
|
458
|
+
}, "r") : null
|
|
459
|
+
}), max == null ? value : /* @__PURE__ */ jsxs("span", {
|
|
460
|
+
"aria-hidden": true,
|
|
461
|
+
className: "inline-flex items-center whitespace-pre",
|
|
462
|
+
children: [/* @__PURE__ */ jsx(RollNumber, { value }), ` / ${max}`]
|
|
463
|
+
})]
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
/** A number that rolls (ui.jsx:371-378 `Roll`, faq.css:90-91): the new figure rises in from 6 below while the old one
|
|
467
|
+
* lifts out, both blurred 2, in 0.16s. Tabular, so the text beside it does not move. */
|
|
468
|
+
function RollNumber({ value, className }) {
|
|
469
|
+
return /* @__PURE__ */ jsx("span", {
|
|
470
|
+
"data-slot": "kit-roll",
|
|
471
|
+
className: cn("relative inline-block tabular-nums", className),
|
|
472
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
473
|
+
mode: "popLayout",
|
|
474
|
+
initial: false,
|
|
475
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
476
|
+
className: "inline-block",
|
|
477
|
+
initial: {
|
|
478
|
+
opacity: 0,
|
|
479
|
+
y: 6,
|
|
480
|
+
filter: "blur(2px)"
|
|
481
|
+
},
|
|
482
|
+
animate: {
|
|
483
|
+
opacity: 1,
|
|
484
|
+
y: 0,
|
|
485
|
+
filter: "blur(0px)"
|
|
486
|
+
},
|
|
487
|
+
exit: {
|
|
488
|
+
opacity: 0,
|
|
489
|
+
y: -6,
|
|
490
|
+
filter: "blur(2px)"
|
|
491
|
+
},
|
|
492
|
+
transition: {
|
|
493
|
+
duration: .16,
|
|
494
|
+
ease: [
|
|
495
|
+
.22,
|
|
496
|
+
1,
|
|
497
|
+
.36,
|
|
498
|
+
1
|
|
499
|
+
]
|
|
500
|
+
},
|
|
501
|
+
children: value
|
|
502
|
+
}, value)
|
|
503
|
+
})
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
/** The line under a field that is over its limit, in the prototype's words (content.jsx:318). */
|
|
507
|
+
var overLimitText = (max) => `Over the ${max}-character limit`;
|
|
508
|
+
/** Put on the input of a field that just went over its limit: the red inset edge and one 0.32s shake (content.css:618). */
|
|
509
|
+
var OVER_LIMIT_CLASS = "shadow-[inset_0_0_0_1px_var(--kit-insp-ring-over)] animate-[kit-insp-shake_0.32s_ease] motion-reduce:animate-none";
|
|
510
|
+
/** Label left, control right in a fixed 194 column (kit.jsx:137, kit.css:50-55, 501-502). `meta` is the quiet current
|
|
511
|
+
* value after the label ("M · 8 px"); `info` adds the info tooltip. */
|
|
512
|
+
function InlineRow({ label, meta, info, labelId, className, children }) {
|
|
513
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
514
|
+
"data-slot": "kit-inline-row",
|
|
515
|
+
className: cn("flex min-h-8 items-center gap-4", className),
|
|
516
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
517
|
+
id: labelId,
|
|
518
|
+
className: "inline-flex min-w-0 flex-1 items-center gap-1 whitespace-nowrap text-[13px] leading-4 text-kit-insp-label",
|
|
519
|
+
children: [
|
|
520
|
+
label,
|
|
521
|
+
info ? /* @__PURE__ */ jsx(InfoTooltip, {
|
|
522
|
+
title: label,
|
|
523
|
+
children: info
|
|
524
|
+
}) : null,
|
|
525
|
+
meta ? /* @__PURE__ */ jsx("em", {
|
|
526
|
+
className: "truncate text-[12px] not-italic tabular-nums text-kit-insp-faint",
|
|
527
|
+
children: meta
|
|
528
|
+
}) : null
|
|
529
|
+
]
|
|
530
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
531
|
+
className: "w-[194px] flex-none",
|
|
532
|
+
children
|
|
533
|
+
})]
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Segmented control, 2–5 options, with the sliding pill (kit.jsx:114-120; styles.css:188-191, editor.css:287 + 458-461,
|
|
538
|
+
* insp.css:61). 36 high (32 with `small` or inside an InlineRow), 2 padding, grey track, white pill on the spring.
|
|
539
|
+
* A radiogroup: arrows move the choice.
|
|
540
|
+
*/
|
|
541
|
+
function InspectorSeg({ options, value, onChange, small, disabled, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy }) {
|
|
542
|
+
const id = React.useId();
|
|
543
|
+
const reduce = useReducedMotion();
|
|
544
|
+
const move = (e) => {
|
|
545
|
+
const d = e.key === "ArrowRight" || e.key === "ArrowDown" ? 1 : e.key === "ArrowLeft" || e.key === "ArrowUp" ? -1 : 0;
|
|
546
|
+
if (!d || disabled) return;
|
|
547
|
+
e.preventDefault();
|
|
548
|
+
const at = options.findIndex((o) => o.value === value);
|
|
549
|
+
const next = at < 0 ? options[d > 0 ? 0 : options.length - 1] : options[(at + d + options.length) % options.length];
|
|
550
|
+
if (!next) return;
|
|
551
|
+
onChange(next.value);
|
|
552
|
+
e.currentTarget.querySelector(`[data-seg="${CSS.escape(next.value)}"]`)?.focus();
|
|
553
|
+
};
|
|
554
|
+
return /* @__PURE__ */ jsx("div", {
|
|
555
|
+
role: "radiogroup",
|
|
556
|
+
"aria-label": ariaLabel,
|
|
557
|
+
"aria-labelledby": labelledBy,
|
|
558
|
+
"data-slot": "kit-insp-seg",
|
|
559
|
+
onKeyDown: move,
|
|
560
|
+
className: cn("flex w-full gap-0.5 rounded-[6px] bg-kit-insp-track p-0.5", small ? "h-8" : "h-9", className),
|
|
561
|
+
children: options.map((o, i) => {
|
|
562
|
+
const on = o.value === value;
|
|
563
|
+
const stop = on || i === 0 && !options.some((x) => x.value === value);
|
|
564
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
565
|
+
type: "button",
|
|
566
|
+
role: "radio",
|
|
567
|
+
"data-seg": o.value,
|
|
568
|
+
disabled,
|
|
569
|
+
"aria-checked": on,
|
|
570
|
+
"aria-label": o.title,
|
|
571
|
+
title: o.title,
|
|
572
|
+
tabIndex: stop ? 0 : -1,
|
|
573
|
+
onClick: () => onChange(o.value),
|
|
574
|
+
className: cn("relative min-w-0 flex-1 whitespace-nowrap rounded-[4px] tracking-[-0.16px] transition-colors disabled:cursor-default", small ? "text-[12.5px]" : "text-[13px]", on ? "font-medium text-kit-insp-ink" : "text-kit-insp-desc hover:text-kit-insp-ink", FOCUS),
|
|
575
|
+
children: [on ? /* @__PURE__ */ jsx(motion.span, {
|
|
576
|
+
layoutId: `kit-seg-${id}`,
|
|
577
|
+
transition: reduce ? { duration: 0 } : PILL,
|
|
578
|
+
className: "absolute inset-0 rounded-[5px] bg-kit-insp-seg-pill shadow-[0_0_0_0.5px_var(--kit-insp-line),0_1px_1px_rgb(0_0_0/0.1),0_3px_3px_rgb(0_0_0/0.09),0_6px_4px_rgb(0_0_0/0.05),0_11px_4px_rgb(0_0_0/0.01)]"
|
|
579
|
+
}) : null, /* @__PURE__ */ jsx("span", {
|
|
580
|
+
className: "relative inline-flex items-center justify-center gap-1.5 [&>svg]:size-3.5 [&>svg]:shrink-0",
|
|
581
|
+
children: o.label
|
|
582
|
+
})]
|
|
583
|
+
}, o.value);
|
|
584
|
+
})
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
var SELECT_BASE = "flex w-full items-center rounded-[6px] border border-transparent bg-kit-insp-card text-left text-[13px] leading-[18px] text-kit-insp-ink transition-colors hover:bg-kit-insp-card-hover data-[popup-open]:border-kit-insp-accent data-[popup-open]:bg-kit-insp-card-focus disabled:cursor-default";
|
|
588
|
+
function OptionItems({ options, value, onPick }) {
|
|
589
|
+
return /* @__PURE__ */ jsx(Fragment, { children: options.map((o) => /* @__PURE__ */ jsx(MenuItem, {
|
|
590
|
+
disabled: o.disabled,
|
|
591
|
+
onClick: () => onPick(o.value),
|
|
592
|
+
className: o.desc ? "h-auto py-1.5" : void 0,
|
|
593
|
+
"aria-current": o.value === value || void 0,
|
|
594
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
595
|
+
className: "flex items-center gap-2",
|
|
596
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
597
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
598
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
599
|
+
className: "truncate",
|
|
600
|
+
children: o.label
|
|
601
|
+
}), o.desc ? /* @__PURE__ */ jsx("span", {
|
|
602
|
+
className: "whitespace-normal text-[12px] leading-4 text-kit-insp-quiet",
|
|
603
|
+
children: o.desc
|
|
604
|
+
}) : null]
|
|
605
|
+
}), o.value === value ? /* @__PURE__ */ jsx(IconCheck, {
|
|
606
|
+
"aria-hidden": true,
|
|
607
|
+
className: "size-3.5 shrink-0 text-kit-insp-label",
|
|
608
|
+
stroke: 2
|
|
609
|
+
}) : null]
|
|
610
|
+
})
|
|
611
|
+
}, o.value)) });
|
|
612
|
+
}
|
|
613
|
+
/** Compact dropdown for an Inline row (kit.jsx:140-150, kit.css:58-62): 32 high, grey, violet edge while open. The menu
|
|
614
|
+
* is at least as wide as the control. */
|
|
615
|
+
function SelectCompact({ value, options, onPick, icon, label, disabled, className }) {
|
|
616
|
+
const cur = options.find((o) => o.value === value);
|
|
617
|
+
return /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsxs(MenuTrigger, {
|
|
618
|
+
"aria-label": label,
|
|
619
|
+
disabled,
|
|
620
|
+
"data-slot": "kit-select-compact",
|
|
621
|
+
className: cn(SELECT_BASE, "h-8 gap-1.5 pl-2.5 pr-2", FOCUS, className),
|
|
622
|
+
children: [
|
|
623
|
+
icon ? /* @__PURE__ */ jsx("span", {
|
|
624
|
+
"aria-hidden": true,
|
|
625
|
+
className: "flex shrink-0 text-kit-insp-label [&>svg]:size-3.5",
|
|
626
|
+
children: icon
|
|
627
|
+
}) : null,
|
|
628
|
+
/* @__PURE__ */ jsx("span", {
|
|
629
|
+
className: "min-w-0 flex-1 truncate",
|
|
630
|
+
children: cur ? cur.label : "Select…"
|
|
631
|
+
}),
|
|
632
|
+
/* @__PURE__ */ jsx(IconChevronDown, {
|
|
633
|
+
"aria-hidden": true,
|
|
634
|
+
className: "size-3.5 shrink-0 text-kit-insp-desc",
|
|
635
|
+
stroke: 1.6
|
|
636
|
+
})
|
|
637
|
+
]
|
|
638
|
+
}), /* @__PURE__ */ jsx(MenuContent, {
|
|
639
|
+
align: "start",
|
|
640
|
+
className: "min-w-[var(--anchor-width)]",
|
|
641
|
+
children: /* @__PURE__ */ jsx(OptionItems, {
|
|
642
|
+
options,
|
|
643
|
+
value,
|
|
644
|
+
onPick
|
|
645
|
+
})
|
|
646
|
+
})] });
|
|
647
|
+
}
|
|
648
|
+
/** Full-width select with its label above (kit.jsx:153-164; editor.css:416-417, 433; faq.css:59): 34 high. */
|
|
649
|
+
function SelectField({ label, value, options, onPick, placeholder = "Select…", icon, info, disabled, current, flash, className }) {
|
|
650
|
+
const id = React.useId();
|
|
651
|
+
const cur = options.find((o) => o.value === value);
|
|
652
|
+
return /* @__PURE__ */ jsx(InspectorField, {
|
|
653
|
+
label,
|
|
654
|
+
labelId: `${id}-l`,
|
|
655
|
+
info,
|
|
656
|
+
current,
|
|
657
|
+
flash,
|
|
658
|
+
className,
|
|
659
|
+
children: /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsxs(MenuTrigger, {
|
|
660
|
+
"aria-labelledby": `${id}-l ${id}-v`,
|
|
661
|
+
disabled,
|
|
662
|
+
"data-slot": "kit-select-field",
|
|
663
|
+
className: cn(SELECT_BASE, "h-[34px] gap-2 px-2.5 tracking-[-0.1625px]", FOCUS),
|
|
664
|
+
children: [
|
|
665
|
+
icon ? /* @__PURE__ */ jsx("span", {
|
|
666
|
+
"aria-hidden": true,
|
|
667
|
+
className: "flex shrink-0 text-kit-insp-label [&>svg]:size-3.5",
|
|
668
|
+
children: icon
|
|
669
|
+
}) : null,
|
|
670
|
+
/* @__PURE__ */ jsx("span", {
|
|
671
|
+
id: `${id}-v`,
|
|
672
|
+
className: cn("min-w-0 truncate", !cur && "text-kit-insp-faint"),
|
|
673
|
+
children: cur ? cur.label : placeholder
|
|
674
|
+
}),
|
|
675
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
676
|
+
/* @__PURE__ */ jsx(IconChevronDown, {
|
|
677
|
+
"aria-hidden": true,
|
|
678
|
+
className: "size-3.5 shrink-0 text-kit-insp-desc",
|
|
679
|
+
stroke: 1.6
|
|
680
|
+
})
|
|
681
|
+
]
|
|
682
|
+
}), /* @__PURE__ */ jsx(MenuContent, {
|
|
683
|
+
align: "start",
|
|
684
|
+
className: "min-w-[var(--anchor-width)]",
|
|
685
|
+
children: /* @__PURE__ */ jsx(OptionItems, {
|
|
686
|
+
options,
|
|
687
|
+
value,
|
|
688
|
+
onPick
|
|
689
|
+
})
|
|
690
|
+
})] })
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
/** Colour select (kit.jsx:219-232, kit.css:77-79): value left, swatch + token pill right; the menu lists the theme
|
|
694
|
+
* colours with their tokens under a header, then an optional readability note. */
|
|
695
|
+
function ColourSelect({ label, value, options, onPick, header = "Section background", note = "Text switches to light on Inverse so it stays readable (4.5:1). Colours come from your site theme.", disabled, className }) {
|
|
696
|
+
const id = React.useId();
|
|
697
|
+
const cur = options.find((o) => o.value === value) ?? options[0];
|
|
698
|
+
const swatch = (c) => /* @__PURE__ */ jsx("span", {
|
|
699
|
+
"aria-hidden": true,
|
|
700
|
+
className: "size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgb(0_0_0/0.12)]",
|
|
701
|
+
style: { background: c }
|
|
702
|
+
});
|
|
703
|
+
return /* @__PURE__ */ jsx(InspectorField, {
|
|
704
|
+
label,
|
|
705
|
+
labelId: `${id}-l`,
|
|
706
|
+
className,
|
|
707
|
+
children: /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsxs(MenuTrigger, {
|
|
708
|
+
"aria-labelledby": `${id}-l ${id}-v`,
|
|
709
|
+
disabled,
|
|
710
|
+
"data-slot": "kit-colour-select",
|
|
711
|
+
className: cn(SELECT_BASE, "h-[34px] gap-2 px-2.5 tracking-[-0.1625px]", FOCUS),
|
|
712
|
+
children: [
|
|
713
|
+
/* @__PURE__ */ jsx("span", {
|
|
714
|
+
id: `${id}-v`,
|
|
715
|
+
className: "shrink-0",
|
|
716
|
+
children: cur?.label ?? "Select…"
|
|
717
|
+
}),
|
|
718
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
719
|
+
cur ? /* @__PURE__ */ jsxs("span", {
|
|
720
|
+
className: "inline-flex h-[22px] items-center gap-1.5 whitespace-nowrap rounded-[4px] bg-kit-insp-token-chip pl-1 pr-1.5 text-[12px] text-kit-insp-desc",
|
|
721
|
+
children: [swatch(cur.colour), cur.token]
|
|
722
|
+
}) : null,
|
|
723
|
+
/* @__PURE__ */ jsx(IconChevronDown, {
|
|
724
|
+
"aria-hidden": true,
|
|
725
|
+
className: "size-3.5 shrink-0 text-kit-insp-desc",
|
|
726
|
+
stroke: 1.6
|
|
727
|
+
})
|
|
728
|
+
]
|
|
729
|
+
}), /* @__PURE__ */ jsxs(MenuContent, {
|
|
730
|
+
align: "start",
|
|
731
|
+
className: "w-[300px] min-w-[var(--anchor-width)]",
|
|
732
|
+
children: [
|
|
733
|
+
header ? /* @__PURE__ */ jsx(MenuLabel, { children: header }) : null,
|
|
734
|
+
options.map((o) => /* @__PURE__ */ jsx(MenuItem, {
|
|
735
|
+
icon: swatch(o.colour),
|
|
736
|
+
onClick: () => onPick(o.value),
|
|
737
|
+
"aria-current": o.value === value || void 0,
|
|
738
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
739
|
+
className: "flex items-center gap-2",
|
|
740
|
+
children: [
|
|
741
|
+
/* @__PURE__ */ jsx("span", {
|
|
742
|
+
className: "min-w-0 flex-1 truncate",
|
|
743
|
+
children: o.label
|
|
744
|
+
}),
|
|
745
|
+
/* @__PURE__ */ jsx("span", {
|
|
746
|
+
className: "shrink-0 text-[12px] text-kit-insp-quiet",
|
|
747
|
+
children: o.token
|
|
748
|
+
}),
|
|
749
|
+
o.value === value ? /* @__PURE__ */ jsx(IconCheck, {
|
|
750
|
+
"aria-hidden": true,
|
|
751
|
+
className: "size-3.5 shrink-0 text-kit-insp-label",
|
|
752
|
+
stroke: 2
|
|
753
|
+
}) : null
|
|
754
|
+
]
|
|
755
|
+
})
|
|
756
|
+
}, o.value)),
|
|
757
|
+
note ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MenuSeparator, {}), /* @__PURE__ */ jsx("p", {
|
|
758
|
+
className: "px-2 py-1.5 text-[12px] leading-[17px] text-kit-insp-quiet",
|
|
759
|
+
children: note
|
|
760
|
+
})] }) : null
|
|
761
|
+
]
|
|
762
|
+
})] })
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
var TRACK = "relative h-7 touch-none select-none rounded-[6px] bg-kit-insp-track shadow-[inset_0_1px_2px_rgb(0_0_0/0.06)]";
|
|
766
|
+
var HANDLE = "absolute top-1/2 -ml-[5px] -mt-[10.5px] h-[21px] w-2.5 rounded-[4px] bg-kit-insp-handle shadow-[0_0_0_0.5px_rgb(0_0_0/0.18),0_1px_2px_rgb(0_0_0/0.16),0_2px_4px_rgb(0_0_0/0.08)] after:absolute after:left-[4.5px] after:top-1.5 after:h-[9px] after:w-px after:rounded-[1px] after:bg-kit-insp-handle-mark";
|
|
767
|
+
function trackDrag(e, onMove, onEnd) {
|
|
768
|
+
e.preventDefault();
|
|
769
|
+
e.currentTarget.focus();
|
|
770
|
+
const body = e.currentTarget.ownerDocument.body;
|
|
771
|
+
const prev = body.style.cursor;
|
|
772
|
+
body.style.cursor = "ew-resize";
|
|
773
|
+
const mv = (ev) => onMove(ev.clientX);
|
|
774
|
+
const up = () => {
|
|
775
|
+
window.removeEventListener("pointermove", mv);
|
|
776
|
+
window.removeEventListener("pointerup", up);
|
|
777
|
+
window.removeEventListener("pointercancel", up);
|
|
778
|
+
body.style.cursor = prev;
|
|
779
|
+
onEnd?.();
|
|
780
|
+
};
|
|
781
|
+
window.addEventListener("pointermove", mv);
|
|
782
|
+
window.addEventListener("pointerup", up);
|
|
783
|
+
window.addEventListener("pointercancel", up);
|
|
784
|
+
onMove(e.clientX);
|
|
785
|
+
}
|
|
786
|
+
/** Step slider (kit.jsx:168-187, kit.css:65-73): filler + handle on the current stop, dots on the others. Click a stop,
|
|
787
|
+
* drag the handle, or use the arrow keys. `value` is the stop's index. */
|
|
788
|
+
function StepSlider({ label, stops, value, onChange, disabled, className, "aria-labelledby": labelledBy }) {
|
|
789
|
+
const ref = React.useRef(null);
|
|
790
|
+
const n = stops.length;
|
|
791
|
+
const last = Math.max(1, n - 1);
|
|
792
|
+
const i = Math.max(0, Math.min(n - 1, value));
|
|
793
|
+
const cur = React.useRef(i);
|
|
794
|
+
cur.current = i;
|
|
795
|
+
const pick = (clientX) => {
|
|
796
|
+
const r = ref.current.getBoundingClientRect();
|
|
797
|
+
const x = Math.min(Math.max(clientX - r.left - 8, 0), r.width - 16);
|
|
798
|
+
return Math.round(x / ((r.width - 16) / last));
|
|
799
|
+
};
|
|
800
|
+
const pct = i / last;
|
|
801
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
802
|
+
ref,
|
|
803
|
+
role: "slider",
|
|
804
|
+
tabIndex: disabled ? -1 : 0,
|
|
805
|
+
"aria-label": labelledBy ? void 0 : label,
|
|
806
|
+
"aria-labelledby": labelledBy,
|
|
807
|
+
"aria-valuemin": 0,
|
|
808
|
+
"aria-valuemax": n - 1,
|
|
809
|
+
"aria-valuenow": i,
|
|
810
|
+
"aria-valuetext": stops[i],
|
|
811
|
+
"aria-disabled": disabled || void 0,
|
|
812
|
+
"data-slot": "kit-step-slider",
|
|
813
|
+
onPointerDown: (e) => {
|
|
814
|
+
if (disabled) return;
|
|
815
|
+
trackDrag(e, (x) => {
|
|
816
|
+
const j = pick(x);
|
|
817
|
+
if (j !== cur.current) {
|
|
818
|
+
cur.current = j;
|
|
819
|
+
onChange(j);
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
},
|
|
823
|
+
onKeyDown: (e) => {
|
|
824
|
+
if (disabled) return;
|
|
825
|
+
if (e.key === "ArrowRight" || e.key === "ArrowUp") {
|
|
826
|
+
e.preventDefault();
|
|
827
|
+
onChange(Math.min(n - 1, i + 1));
|
|
828
|
+
}
|
|
829
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
|
|
830
|
+
e.preventDefault();
|
|
831
|
+
onChange(Math.max(0, i - 1));
|
|
832
|
+
}
|
|
833
|
+
},
|
|
834
|
+
className: cn(TRACK, "group/step", disabled ? "cursor-default opacity-45" : "cursor-pointer", FOCUS, className),
|
|
835
|
+
children: [
|
|
836
|
+
/* @__PURE__ */ jsx("span", {
|
|
837
|
+
"aria-hidden": true,
|
|
838
|
+
className: "absolute inset-y-0 left-0 rounded-[6px] bg-kit-insp-track-fill transition-[width] duration-[180ms] ease-[cubic-bezier(0.2,0.8,0.2,1)] motion-reduce:transition-none",
|
|
839
|
+
style: { width: `calc(${pct} * (100% - 16px) + 13px)` }
|
|
840
|
+
}),
|
|
841
|
+
stops.map((s, j) => /* @__PURE__ */ jsx("span", {
|
|
842
|
+
"aria-hidden": true,
|
|
843
|
+
title: s,
|
|
844
|
+
className: cn("absolute top-1/2 -ml-[1.5px] -mt-[1.5px] size-[3px] rounded-full bg-kit-insp-track-dot transition-opacity duration-100", j === i && "opacity-0"),
|
|
845
|
+
style: { left: `calc(${j / last} * (100% - 16px) + 8px)` }
|
|
846
|
+
}, j)),
|
|
847
|
+
/* @__PURE__ */ jsx("span", {
|
|
848
|
+
"aria-hidden": true,
|
|
849
|
+
className: cn(HANDLE, "transition-[left,transform] duration-[180ms] ease-[cubic-bezier(0.2,0.8,0.2,1)] motion-reduce:transition-none", !disabled && "group-active/step:scale-[1.08]"),
|
|
850
|
+
style: { left: `calc(${pct} * (100% - 16px) + 8px)` }
|
|
851
|
+
})
|
|
852
|
+
]
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
/** Step slider in an Inline row: label + the current stop's name on the left (kit.jsx:211-213). */
|
|
856
|
+
function StepRow({ label, stops, names, value, onChange, disabled, info }) {
|
|
857
|
+
return /* @__PURE__ */ jsx(InlineRow, {
|
|
858
|
+
label,
|
|
859
|
+
meta: (names ?? stops)[value],
|
|
860
|
+
info,
|
|
861
|
+
children: /* @__PURE__ */ jsx(StepSlider, {
|
|
862
|
+
label,
|
|
863
|
+
stops,
|
|
864
|
+
value,
|
|
865
|
+
onChange,
|
|
866
|
+
disabled
|
|
867
|
+
})
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Value slider (kit.jsx:191-209, kit.css:555-564): the step slider's track, filler and handle with the label left and
|
|
872
|
+
* the number right inside the track. origin "start" fills from the left; "center" fills out from a zero mark. Drag,
|
|
873
|
+
* click, arrow keys (Shift = ×10); double-click resets. `onStart` fires once before a gesture's first change (one undo step).
|
|
874
|
+
*/
|
|
875
|
+
function ValueSlider({ label, value, min = 0, max = 100, origin = "start", reset, format = String, onChange, onStart, disabled, className }) {
|
|
876
|
+
const ref = React.useRef(null);
|
|
877
|
+
const [drag, setDrag] = React.useState(false);
|
|
878
|
+
const span = max - min || 1;
|
|
879
|
+
const clamp = (v) => Math.max(min, Math.min(max, Math.round(v)));
|
|
880
|
+
const pct = (value - min) / span;
|
|
881
|
+
const at = (clientX) => {
|
|
882
|
+
const r = ref.current.getBoundingClientRect();
|
|
883
|
+
return clamp(min + Math.min(Math.max((clientX - r.left - 6) / (r.width - 12), 0), 1) * span);
|
|
884
|
+
};
|
|
885
|
+
const z = origin === "center" ? .5 : 0;
|
|
886
|
+
const a = Math.min(z, pct);
|
|
887
|
+
const b = Math.max(z, pct);
|
|
888
|
+
const move = drag ? "" : "transition-[left,width,transform] duration-[120ms] motion-reduce:transition-none";
|
|
889
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
890
|
+
ref,
|
|
891
|
+
role: "slider",
|
|
892
|
+
tabIndex: disabled ? -1 : 0,
|
|
893
|
+
"aria-label": label,
|
|
894
|
+
"aria-valuemin": min,
|
|
895
|
+
"aria-valuemax": max,
|
|
896
|
+
"aria-valuenow": value,
|
|
897
|
+
"aria-valuetext": format(value),
|
|
898
|
+
"aria-disabled": disabled || void 0,
|
|
899
|
+
"data-slot": "kit-value-slider",
|
|
900
|
+
onPointerDown: (e) => {
|
|
901
|
+
if (disabled) return;
|
|
902
|
+
onStart?.();
|
|
903
|
+
setDrag(true);
|
|
904
|
+
trackDrag(e, (x) => onChange(at(x)), () => setDrag(false));
|
|
905
|
+
},
|
|
906
|
+
onKeyDown: (e) => {
|
|
907
|
+
if (disabled) return;
|
|
908
|
+
const d = {
|
|
909
|
+
ArrowRight: 1,
|
|
910
|
+
ArrowUp: 1,
|
|
911
|
+
ArrowLeft: -1,
|
|
912
|
+
ArrowDown: -1
|
|
913
|
+
}[e.key];
|
|
914
|
+
if (!d) return;
|
|
915
|
+
e.preventDefault();
|
|
916
|
+
onStart?.();
|
|
917
|
+
onChange(clamp(value + d * (e.shiftKey ? 10 : 1)));
|
|
918
|
+
},
|
|
919
|
+
onDoubleClick: () => {
|
|
920
|
+
if (disabled) return;
|
|
921
|
+
onStart?.();
|
|
922
|
+
onChange(reset ?? (origin === "center" ? clamp((min + max) / 2) : min));
|
|
923
|
+
},
|
|
924
|
+
className: cn(TRACK, "flex items-center justify-between px-2.5", disabled ? "cursor-default opacity-45" : "cursor-ew-resize", FOCUS, className),
|
|
925
|
+
children: [
|
|
926
|
+
/* @__PURE__ */ jsx("span", {
|
|
927
|
+
"aria-hidden": true,
|
|
928
|
+
className: cn("absolute inset-y-0 bg-kit-insp-track-fill", origin === "start" && "rounded-l-[6px]", move),
|
|
929
|
+
style: {
|
|
930
|
+
left: `calc(${a} * (100% - 12px) + ${a ? 6 : 0}px)`,
|
|
931
|
+
width: `calc(${b - a} * (100% - 12px) + ${a ? 0 : 6}px)`
|
|
932
|
+
}
|
|
933
|
+
}),
|
|
934
|
+
origin === "center" ? /* @__PURE__ */ jsx("span", {
|
|
935
|
+
"aria-hidden": true,
|
|
936
|
+
className: "absolute inset-y-0 left-1/2 w-px bg-kit-insp-line-strong"
|
|
937
|
+
}) : null,
|
|
938
|
+
/* @__PURE__ */ jsx("span", {
|
|
939
|
+
className: "pointer-events-none relative z-[1] text-[12px] font-medium leading-4 text-kit-insp-tip-body",
|
|
940
|
+
children: label
|
|
941
|
+
}),
|
|
942
|
+
/* @__PURE__ */ jsx("span", {
|
|
943
|
+
className: "pointer-events-none relative z-[1] text-[12px] font-medium leading-4 tabular-nums text-kit-insp-tip-title",
|
|
944
|
+
children: format(value)
|
|
945
|
+
}),
|
|
946
|
+
/* @__PURE__ */ jsx("span", {
|
|
947
|
+
"aria-hidden": true,
|
|
948
|
+
className: cn(HANDLE, "z-[2]", move, drag && "scale-[1.08]"),
|
|
949
|
+
style: { left: `calc(${pct} * (100% - 12px) + 6px)` }
|
|
950
|
+
})
|
|
951
|
+
]
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
/** The prototype switch (ui.jsx:132-141, editor.css:242-251): 34×20 (sm 28×16), inset-shadow track, grey knob with a
|
|
955
|
+
* 1px grip line. `deco` draws it inside another control (a menu row): no button, hidden from assistive tech. */
|
|
956
|
+
function InspectorSwitch({ on, onChange, size = "md", label, disabled, deco, className, "aria-labelledby": labelledBy }) {
|
|
957
|
+
const sm = size === "sm";
|
|
958
|
+
const track = cn("relative block shrink-0 rounded-full p-0 shadow-[inset_0_1px_2px_rgb(0_0_0/0.25),inset_0_-1px_0.5px_rgb(255_255_255/0.2)] transition-colors duration-150", sm ? "h-4 w-7" : "h-5 w-[34px]", on ? "bg-kit-insp-switch-on" : "bg-kit-insp-switch-off", className);
|
|
959
|
+
const knob = /* @__PURE__ */ jsx("span", {
|
|
960
|
+
className: cn("absolute left-0.5 top-0.5 grid place-items-center rounded-full bg-kit-insp-switch-knob shadow-[0_1px_2px_rgb(0_0_0/0.25)] transition-transform duration-150 ease-[cubic-bezier(0.3,0.7,0.2,1)] motion-reduce:transition-none", sm ? "size-3" : "size-4", on && (sm ? "translate-x-3" : "translate-x-3.5")),
|
|
961
|
+
children: /* @__PURE__ */ jsx("i", { className: cn("block w-px rounded-[0.5px] bg-kit-insp-switch-knob-mark", sm ? "h-1.5" : "h-2") })
|
|
962
|
+
});
|
|
963
|
+
if (deco) return /* @__PURE__ */ jsx("span", {
|
|
964
|
+
"aria-hidden": true,
|
|
965
|
+
"data-slot": "kit-insp-switch",
|
|
966
|
+
className: track,
|
|
967
|
+
children: knob
|
|
968
|
+
});
|
|
969
|
+
return /* @__PURE__ */ jsx("button", {
|
|
970
|
+
type: "button",
|
|
971
|
+
role: "switch",
|
|
972
|
+
"aria-checked": on,
|
|
973
|
+
"aria-label": labelledBy ? void 0 : label,
|
|
974
|
+
"aria-labelledby": labelledBy,
|
|
975
|
+
disabled,
|
|
976
|
+
"data-slot": "kit-insp-switch",
|
|
977
|
+
onClick: (e) => {
|
|
978
|
+
e.stopPropagation();
|
|
979
|
+
onChange?.(!on);
|
|
980
|
+
},
|
|
981
|
+
className: cn(track, "cursor-pointer disabled:cursor-default disabled:opacity-40", FOCUS, "focus-visible:outline-offset-2"),
|
|
982
|
+
children: knob
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
/** Toggle row (kit.jsx:241-243; styles.css:286-289, editor.css:445-447): label + supporting text left, switch right,
|
|
986
|
+
* top-aligned. */
|
|
987
|
+
function ToggleRow({ label, desc, on, onChange, disabled, className }) {
|
|
988
|
+
const id = React.useId();
|
|
989
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
990
|
+
"data-slot": "kit-toggle-row",
|
|
991
|
+
className: cn("flex items-start justify-between gap-4", className),
|
|
992
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
993
|
+
className: "flex min-w-0 flex-1 flex-col gap-1 leading-[18px]",
|
|
994
|
+
children: [/* @__PURE__ */ jsx("b", {
|
|
995
|
+
id,
|
|
996
|
+
className: "text-[13px] font-medium tracking-[-0.1625px] text-kit-insp-ink",
|
|
997
|
+
children: label
|
|
998
|
+
}), desc ? /* @__PURE__ */ jsx("small", {
|
|
999
|
+
className: "text-[12px] leading-[18px] tracking-[-0.12px] text-kit-insp-quiet",
|
|
1000
|
+
children: desc
|
|
1001
|
+
}) : null]
|
|
1002
|
+
}), /* @__PURE__ */ jsx(InspectorSwitch, {
|
|
1003
|
+
on,
|
|
1004
|
+
onChange,
|
|
1005
|
+
disabled,
|
|
1006
|
+
"aria-labelledby": id
|
|
1007
|
+
})]
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
/** Related toggles share ONE grey card (kit.jsx:245, kit.css:84-85): #F5F5F5, radius 8, 12 padding, rows 14 apart. */
|
|
1011
|
+
function ToggleCard({ className, children, ...rest }) {
|
|
1012
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1013
|
+
"data-slot": "kit-toggle-card",
|
|
1014
|
+
className: cn("flex flex-col gap-3.5 rounded-[8px] bg-kit-insp-card p-3", className),
|
|
1015
|
+
...rest,
|
|
1016
|
+
children
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
/** The grey item list card (styles.css:200-201; faq.css:86): radius 12, 12/8/8 padding, rows in a 0-gap list, then the
|
|
1020
|
+
* Add button and the note, 4 apart. Pass <ItemRow>s as children, `add` and `note` below them. */
|
|
1021
|
+
function ItemListCard({ add, note, listRef, className, children, ...rest }) {
|
|
1022
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1023
|
+
"data-slot": "kit-item-card",
|
|
1024
|
+
className: cn("flex min-w-0 flex-col gap-1 overflow-hidden rounded-[12px] bg-kit-insp-card px-2 pb-2 pt-3", className),
|
|
1025
|
+
...rest,
|
|
1026
|
+
children: [
|
|
1027
|
+
/* @__PURE__ */ jsx("div", {
|
|
1028
|
+
ref: listRef,
|
|
1029
|
+
role: "list",
|
|
1030
|
+
"data-slot": "kit-item-list",
|
|
1031
|
+
className: "flex min-w-0 flex-col",
|
|
1032
|
+
children
|
|
1033
|
+
}),
|
|
1034
|
+
add,
|
|
1035
|
+
note
|
|
1036
|
+
]
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
var ITEM_ROW_CLASS = "group/li flex h-[46px] w-full min-w-0 cursor-pointer items-center gap-1 rounded-[6px] py-1 pl-0.5 pr-1 text-left transition-colors hover:bg-kit-insp-row-hover";
|
|
1040
|
+
var ITEM_ROW_GRIP_CLASS = "grid size-7 shrink-0 cursor-grab touch-none place-items-center rounded-[6px] text-kit-insp-quiet active:cursor-grabbing";
|
|
1041
|
+
var ITEM_ROW_MORE_CLASS = "grid size-7 shrink-0 place-items-center rounded-[6px] text-kit-insp-label transition-colors hover:bg-kit-insp-row-press aria-expanded:bg-kit-insp-row-press data-[popup-open]:bg-kit-insp-row-press";
|
|
1042
|
+
var ITEM_ROW_TITLE_CLASS = "truncate text-[13px] font-medium leading-[18px] tracking-[-0.1625px] text-kit-insp-ink";
|
|
1043
|
+
var ITEM_ROW_SUB_CLASS = "truncate text-[11.5px] leading-[14px] text-kit-insp-sub";
|
|
1044
|
+
/** One row of the item list card (styles.css:202-214, 258-261): 46 high, grip 28, title 13/18 medium over an 11.5/14
|
|
1045
|
+
* sub-line, ⋯ 28. Hover greys the row; `over` draws the drop line; `dragging` fades it. */
|
|
1046
|
+
function ItemRow({ title, sub, empty, onOpen, openLabel, grip, leading, tag, meta, more, compact, dragging, over, error, selected, className, ...rest }) {
|
|
1047
|
+
const text = /* @__PURE__ */ jsxs("span", {
|
|
1048
|
+
className: cn("flex min-w-0 flex-col px-1.5 py-1", compact ? "flex-initial" : "flex-1"),
|
|
1049
|
+
children: [/* @__PURE__ */ jsx("b", {
|
|
1050
|
+
className: cn(ITEM_ROW_TITLE_CLASS, error && "text-kit-insp-delete-fg"),
|
|
1051
|
+
children: title
|
|
1052
|
+
}), sub || empty ? /* @__PURE__ */ jsx("small", {
|
|
1053
|
+
className: cn(ITEM_ROW_SUB_CLASS, !sub && "text-kit-insp-faint"),
|
|
1054
|
+
children: sub || empty
|
|
1055
|
+
}) : null]
|
|
1056
|
+
});
|
|
1057
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1058
|
+
role: "listitem",
|
|
1059
|
+
"data-slot": "kit-item-row",
|
|
1060
|
+
"data-selected": selected || void 0,
|
|
1061
|
+
className: cn(ITEM_ROW_CLASS, compact && "h-11", dragging && "opacity-40", over && "shadow-[inset_0_2px_0_var(--kit-insp-accent)]", selected && "bg-kit-insp-token-chip", className),
|
|
1062
|
+
...rest,
|
|
1063
|
+
children: [
|
|
1064
|
+
grip === false || grip === void 0 ? null : /* @__PURE__ */ jsx("button", {
|
|
1065
|
+
type: "button",
|
|
1066
|
+
"aria-label": "Drag to reorder",
|
|
1067
|
+
title: "Drag to reorder",
|
|
1068
|
+
...grip,
|
|
1069
|
+
className: cn(ITEM_ROW_GRIP_CLASS, FOCUS, grip.className),
|
|
1070
|
+
children: /* @__PURE__ */ jsx(IconGripVertical, {
|
|
1071
|
+
"aria-hidden": true,
|
|
1072
|
+
className: "size-4",
|
|
1073
|
+
stroke: 1.6
|
|
1074
|
+
})
|
|
1075
|
+
}),
|
|
1076
|
+
onOpen ? /* @__PURE__ */ jsxs("button", {
|
|
1077
|
+
type: "button",
|
|
1078
|
+
onClick: onOpen,
|
|
1079
|
+
"aria-label": openLabel,
|
|
1080
|
+
className: cn("flex h-[38px] min-w-0 flex-1 items-center gap-2 rounded-[6px] text-left", FOCUS),
|
|
1081
|
+
children: [leading, text]
|
|
1082
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
1083
|
+
className: "flex h-[38px] min-w-0 flex-1 items-center gap-2",
|
|
1084
|
+
children: [leading, text]
|
|
1085
|
+
}),
|
|
1086
|
+
tag ? /* @__PURE__ */ jsx("span", {
|
|
1087
|
+
className: "flex min-h-5 shrink-0 items-center whitespace-nowrap rounded-[4px] bg-kit-insp-chip px-1.5 text-[10.5px] font-medium leading-4 text-kit-insp-note",
|
|
1088
|
+
children: tag
|
|
1089
|
+
}) : null,
|
|
1090
|
+
meta ? /* @__PURE__ */ jsx("span", {
|
|
1091
|
+
className: "shrink-0 whitespace-nowrap pr-1.5 text-[11.5px] text-kit-insp-sub",
|
|
1092
|
+
children: meta
|
|
1093
|
+
}) : null,
|
|
1094
|
+
more
|
|
1095
|
+
]
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
/** A plain ⋯ button for an ItemRow whose menu the host opens itself. */
|
|
1099
|
+
function ItemRowMore({ label, className, ...rest }) {
|
|
1100
|
+
return /* @__PURE__ */ jsx("button", {
|
|
1101
|
+
type: "button",
|
|
1102
|
+
"aria-label": label,
|
|
1103
|
+
"aria-haspopup": "menu",
|
|
1104
|
+
...rest,
|
|
1105
|
+
className: cn(ITEM_ROW_MORE_CLASS, FOCUS, className),
|
|
1106
|
+
children: /* @__PURE__ */ jsx(IconDots, {
|
|
1107
|
+
"aria-hidden": true,
|
|
1108
|
+
className: "size-4",
|
|
1109
|
+
stroke: 1.6
|
|
1110
|
+
})
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
var ITEM_LIST_ADD_CLASS = "h-10 w-full shrink-0 rounded-[6px] bg-kit-insp-btn text-[13px] font-medium leading-[18px] tracking-[-0.1625px] text-kit-insp-ink transition-[background-color,transform] duration-150 hover:bg-kit-insp-btn-hover active:scale-[0.98] disabled:cursor-not-allowed disabled:bg-kit-insp-btn-off disabled:text-kit-insp-faint disabled:active:scale-100 aria-disabled:cursor-not-allowed aria-disabled:bg-kit-insp-btn-off aria-disabled:text-kit-insp-faint data-[popup-open]:bg-kit-insp-btn-on motion-reduce:transition-none motion-reduce:active:scale-100";
|
|
1114
|
+
/** The Add button inside the card (styles.css:215-217, faq.css:96-97, page.css:11): full width, 40 high. */
|
|
1115
|
+
function ItemListAdd({ className, children, ...rest }) {
|
|
1116
|
+
return /* @__PURE__ */ jsx("button", {
|
|
1117
|
+
type: "button",
|
|
1118
|
+
"data-slot": "kit-item-add",
|
|
1119
|
+
...rest,
|
|
1120
|
+
className: cn(ITEM_LIST_ADD_CLASS, FOCUS, className),
|
|
1121
|
+
children
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
/** The card's note line, in the prototype's words (inspector.jsx:254): "3 of 6 questions. Drag to reorder." ·
|
|
1125
|
+
* "6 of 6 questions. Remove one to add another." · "3 questions. Drag to reorder." */
|
|
1126
|
+
function itemListNote(count, noun, max, opts) {
|
|
1127
|
+
const tail = opts?.sortable === false ? "" : " Drag to reorder.";
|
|
1128
|
+
if (max != null) return `${count} of ${max} ${noun}s.${count >= max ? " Remove one to add another." : tail}`;
|
|
1129
|
+
return `${count} ${noun}${count === 1 ? "" : "s"}.${tail}`;
|
|
1130
|
+
}
|
|
1131
|
+
/** The note under the Add button (styles.css:218): 12/18, 4 padding. */
|
|
1132
|
+
function ItemListNote({ className, children, ...rest }) {
|
|
1133
|
+
return /* @__PURE__ */ jsx("p", {
|
|
1134
|
+
"data-slot": "kit-item-note",
|
|
1135
|
+
className: cn("m-0 p-1 text-[12px] leading-[18px] tracking-[-0.15px] text-kit-insp-note", className),
|
|
1136
|
+
...rest,
|
|
1137
|
+
children
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
var ITEM_DELETE_CLASS = "inline-flex h-8 items-center gap-1.5 self-start rounded-[6px] bg-kit-insp-delete-bg px-3 text-[13px] font-medium text-kit-insp-delete-fg transition-[background-color,transform] duration-150 hover:bg-kit-insp-delete-bg-hover active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-kit-insp-delete-bg disabled:active:scale-100 motion-reduce:transition-none motion-reduce:active:scale-100";
|
|
1141
|
+
/**
|
|
1142
|
+
* The red "Delete <noun>" that ends an item screen (inspector.jsx:663, faq.css:48-49, kit.css:183). When it cannot run
|
|
1143
|
+
* (the list is at its minimum) pass `reason`: the button is disabled and the reason is its title and description.
|
|
1144
|
+
*/
|
|
1145
|
+
function ItemDeleteButton({ noun, reason, icon, className, children, ...rest }) {
|
|
1146
|
+
const id = React.useId();
|
|
1147
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("button", {
|
|
1148
|
+
type: "button",
|
|
1149
|
+
"data-slot": "kit-item-delete",
|
|
1150
|
+
disabled: !!reason || rest.disabled,
|
|
1151
|
+
title: reason,
|
|
1152
|
+
"aria-describedby": reason ? id : void 0,
|
|
1153
|
+
...rest,
|
|
1154
|
+
className: cn(ITEM_DELETE_CLASS, FOCUS, className),
|
|
1155
|
+
children: [icon, children ?? `Delete ${noun ?? "item"}`]
|
|
1156
|
+
}), reason ? /* @__PURE__ */ jsx("span", {
|
|
1157
|
+
id,
|
|
1158
|
+
className: "sr-only",
|
|
1159
|
+
children: reason
|
|
1160
|
+
}) : null] });
|
|
1161
|
+
}
|
|
1162
|
+
/** The quiet ⓘ after a label, 16 box with a 14 glyph (kit.css:445-446), for hosts that draw their own label row. */
|
|
1163
|
+
function InfoGlyph({ className }) {
|
|
1164
|
+
return /* @__PURE__ */ jsx(IconInfoCircle, {
|
|
1165
|
+
"aria-hidden": true,
|
|
1166
|
+
className: cn("size-3.5", className),
|
|
1167
|
+
stroke: 1.6
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
//#endregion
|
|
1171
|
+
export { ColourSelect, CountRing, FieldCounter, FieldSweep, FocusDot, GroupHeader, INSPECTOR_EASE, ITEM_DELETE_CLASS, ITEM_LIST_ADD_CLASS, ITEM_ROW_CLASS, ITEM_ROW_GRIP_CLASS, ITEM_ROW_MORE_CLASS, ITEM_ROW_SUB_CLASS, ITEM_ROW_TITLE_CLASS, InfoGlyph, InlineRow, InspectorBody, InspectorCollapse, InspectorDivider, InspectorField, InspectorFields, InspectorGroup, InspectorLocked, InspectorNote, InspectorSeg, InspectorSwitch, ItemDeleteButton, ItemListAdd, ItemListCard, ItemListNote, ItemRow, ItemRowMore, LAYOUT_GLYPHS, LayoutOpt, OVER_LIMIT_CLASS, RollNumber, SectionHeader, SelectCompact, SelectField, StepRow, StepSlider, ToggleCard, ToggleRow, ValueSlider, counterState, itemListNote, overLimitText };
|
|
1172
|
+
|
|
1173
|
+
//# sourceMappingURL=inspector.js.map
|