@bettercms-ai/kit 3.1.3 → 3.1.5
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/controls/choice.js +2 -2
- package/dist/controls/choice.js.map +1 -1
- package/dist/controls/code.js +1 -1
- package/dist/controls/code.js.map +1 -1
- package/dist/controls/color.js +1 -1
- package/dist/controls/color.js.map +1 -1
- package/dist/controls/date.js +1 -1
- package/dist/controls/date.js.map +1 -1
- package/dist/controls/icon.js +2 -2
- package/dist/controls/icon.js.map +1 -1
- package/dist/controls/location.js +1 -1
- package/dist/controls/location.js.map +1 -1
- package/dist/controls/media.js +15 -1
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/number.js +4 -4
- package/dist/controls/number.js.map +1 -1
- package/dist/controls/reference.js +3 -3
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/editor.js +23 -2
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/ops.d.ts +30 -0
- package/dist/controls/rich-text/ops.js +126 -9
- package/dist/controls/rich-text/ops.js.map +1 -1
- package/dist/controls/table/table-editor.js +1 -1
- package/dist/controls/table/table-editor.js.map +1 -1
- package/dist/engine/array.d.ts +4 -1
- package/dist/engine/array.js +29 -3
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/field-shell.js +16 -5
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/item-list.d.ts +1 -0
- package/dist/engine/item-list.js +2 -1
- package/dist/engine/item-list.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +3 -0
- package/dist/tokens.css +12 -6
- package/dist/ui/controls.js +9 -9
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/select.js +1 -1
- package/dist/ui/select.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.js","names":[],"sources":["../../src/controls/icon.tsx"],"sourcesContent":["/**\n * ICON — the icon field (DESIGN 8.14), V2 controls/icon.tsx fitted to what prod stores.\n *\n * Values (backend reference-validation `icon`, the classic PropsPanel IconValueInput):\n * \"arrow-right\" a name from the BetterCMS icon set (DOCK_ICON_NAMES, 473 names)\n * \"https://…/logo.svg\" an uploaded icon: an image URL (picked from the media library; a component prop\n * stores the URL string, like the classic panel's codec=\"url\")\n * { url, … } an uploaded icon stored as an image value: shown and kept until replaced\n * null no icon (\"No icon\"; the backend skips an empty value)\n * { source: pack | library | upload, …, label? } D65: a field with `icons` (V2 FieldSchema.icons) opts in to the\n * project's icon library, media uploads by id and an accessible label\n *\n * A field without `icons` draws and stores exactly what it always did. One with `icons` gets V2's source tabs (Icons ·\n * Library · Upload), the library from the host (KitServices.iconLibrary) and \"Describe this icon\" when it asks.\n *\n * The grid offers the BetterCMS set, the one prod accepts. Search also matches a name's Tabler twin through the\n * Tabler ↔ dock adapter (adapters/icons.ts), so \"map\" finds earth-americas. A stored name outside the set (a stale\n * Tabler or Lucide name) is shown with its reason and kept until the author picks another.\n *\n * Glyphs: the host draws them (KitServices.IconGlyph: the dashboard's DockIcon, the set the site renders). With no\n * host renderer the kit draws the Tabler twin, loaded on first use; a name with no Tabler twin shows its name.\n */\nimport * as React from \"react\";\nimport type { Icon as TablerIcon } from \"@tabler/icons-react\";\nimport { IconAlertTriangle, IconChevronDown, IconPhoto, IconSearch, IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport { iconLabel } from \"../lib/icons\";\nimport { useKitServices } from \"../context\";\nimport { DOCK_ICON_NAMES, DOCK_ICON_NAME_SET } from \"../adapters/prod-types\";\nimport { compactIcon, iconSrc, normalizeIcon, resolveIconOptions, withIconLabel, type IconObjectValue, type IconSource } from \"@bettercms-ai/types\";\nimport { Segmented } from \"../ui/controls\";\nimport { Input } from \"../ui/input\";\nimport { tablerIconOf } from \"../adapters/icons\";\nimport type { ControlProps } from \"../types\";\nimport { Button } from \"../ui/button\";\nimport { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../ui/overlay\";\nimport { TooltipLayer } from \"../ui/tooltip-root\";\n\n/* ── Glyphs ───────────────────────────────────────────────────────────── */\ndeclare module \"../context\" {\n interface KitServices {\n /**\n * Draws one icon of the BetterCMS set by name, aria-hidden (the name beside it is the accessible text): the glyphs\n * the site renders. The dashboard passes `DockIcon` (src/components/dock/DockIcon). Absent → the Tabler twin.\n */\n IconGlyph?: React.ComponentType<{ name: string; className?: string }>;\n /**\n * The project's icon library (V2 D65, the brand kit's icons): each with its resolved url and whether it follows the\n * text colour, and the sets. Absent → an icon field offers no Library tab.\n */\n iconLibrary?: () => { icons: KitLibraryIcon[]; sets: Array<{ key: string; name: string }> };\n }\n}\nexport type KitLibraryIcon = { key: string; name: string; set?: string; followsText: boolean; url: string };\n\n/** Any icon value as its glyph: a set name drawn by the host, a text-coloured library icon as a mask, else an image. */\nexport function IconValueGlyph({ value, className }: { value: unknown; className?: string }) {\n const { mediaSrc } = useKitServices();\n const src = iconSrc(value);\n if (!src) return null;\n if (\"name\" in src) return <Glyph name={src.name} className={className} />;\n const url = mediaSrc ? mediaSrc(src.url) : src.url;\n if (src.followsText) {\n const mask = `url(${JSON.stringify(url)}) center / contain no-repeat`;\n return <span aria-hidden className={cn(\"inline-block bg-current\", className)} style={{ mask, WebkitMask: mask }} />;\n }\n return <img src={url} alt=\"\" className={cn(\"object-contain\", className)} />;\n}\n\nlet tablerSet: Record<string, unknown> | null = null;\nlet tablerLoad: Promise<void> | null = null;\nconst pascal = (kebab: string) => `Icon${kebab.split(\"-\").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}`;\n\n/** The full Tabler set, loaded once and only when no host renderer is provided. */\nfunction useTablerSet(need: boolean): Record<string, unknown> | null {\n const [, landed] = React.useReducer((n: number) => n + 1, 0);\n React.useEffect(() => {\n if (!need || tablerSet) return;\n let live = true;\n tablerLoad ??= import(\"@tabler/icons-react\").then((m) => {\n tablerSet = m as unknown as Record<string, unknown>;\n });\n tablerLoad.then(() => live && landed(), () => {});\n return () => {\n live = false;\n };\n }, [need]);\n return tablerSet;\n}\n\nfunction Glyph({ name, className }: { name: string; className?: string }) {\n const Host = useKitServices().IconGlyph;\n const set = useTablerSet(!Host);\n if (Host) return <Host name={name} className={className} />;\n const T = set?.[pascal(tablerIconOf(name))] as TablerIcon | undefined;\n if (T) return <T className={className} stroke={1.5} aria-hidden />;\n // no Tabler twin (or the set is still loading): the name itself, never a stand-in shape\n return (\n <span aria-hidden className=\"max-w-full truncate px-0.5 text-[9px] leading-3 text-kit-fg-3\">\n {name}\n </span>\n );\n}\n\n/* ── Values ───────────────────────────────────────────────────────────── */\ntype Read =\n | { kind: \"empty\" }\n | { kind: \"name\"; name: string }\n | { kind: \"unknown\"; name: string }\n | { kind: \"upload\"; url: string }\n | { kind: \"unreadable\" };\nconst isUrlish = (s: string) => /[/.]/.test(s);\nfunction readIcon(v: unknown): Read {\n if (v == null || v === \"\") return { kind: \"empty\" };\n if (typeof v === \"string\") return DOCK_ICON_NAME_SET.has(v) ? { kind: \"name\", name: v } : isUrlish(v) ? { kind: \"upload\", url: v } : { kind: \"unknown\", name: v };\n if (isObj(v) && typeof v.url === \"string\" && v.url) return { kind: \"upload\", url: v.url };\n return { kind: \"unreadable\" };\n}\nconst fileName = (url: string) => decodeURIComponent(url.split(/[?#]/)[0].split(\"/\").pop() || url);\n\n/** Names picked this session, newest first (shown as \"Recent\"). */\nconst recents: string[] = [];\nconst pushRecent = (name: string) => {\n const i = recents.indexOf(name);\n if (i !== -1) recents.splice(i, 1);\n recents.unshift(name);\n recents.length = Math.min(recents.length, COLS);\n};\n\n/* ── The grid: one tab stop, arrow keys, Home / End ───────────────────── */\nconst COLS = 8;\nconst norm = (q: string) => q.toLowerCase().trim().replace(/\\s+/g, \"-\");\ninterface GridItem {\n key: string;\n label: string;\n node: React.ReactNode;\n}\n\ntype TipHandle = ReturnType<typeof TooltipPrimitive.createHandle<string>>;\n\n/** Up / down within a grid keep the column; past its edge they land in the same column of the next / previous grid. */\nfunction verticalTarget(grids: HTMLButtonElement[][], g: number, j: number, down: boolean): HTMLButtonElement | \"search\" | undefined {\n const col = j % COLS;\n const cur = grids[g];\n const within = down ? j + COLS : j - COLS;\n if (within >= 0 && within < cur.length) return cur[within];\n if (down && Math.floor(j / COLS) < Math.floor((cur.length - 1) / COLS)) return cur[cur.length - 1]; // a short last row\n const next = grids[down ? g + 1 : g - 1];\n if (!next) return down ? undefined : \"search\";\n if (down) return next[Math.min(col, next.length - 1)];\n const lastRow = Math.floor((next.length - 1) / COLS) * COLS;\n return next[Math.min(lastRow + col, next.length - 1)];\n}\n\nfunction IconGrid({ items, selected, onPick, label, tip }: { items: GridItem[]; selected?: string; onPick: (key: string) => void; label: string; tip: TipHandle }) {\n const ref = React.useRef<HTMLDivElement>(null);\n const stop = items.some((i) => i.key === selected) ? selected : items[0]?.key;\n const move = (e: React.KeyboardEvent) => {\n // one keyboard space across every group in the picker (Recent, the set, search results)\n const scope = ref.current?.closest(\"[data-icon-picker]\") ?? ref.current;\n const grids = Array.from(scope?.querySelectorAll<HTMLElement>(\"[data-icon-grid]\") ?? []).map((g) => Array.from(g.querySelectorAll<HTMLButtonElement>(\"[data-grid-item]\")));\n const btns = grids.flat();\n const i = btns.indexOf(document.activeElement as HTMLButtonElement);\n if (i === -1) return;\n const g = grids.findIndex((list) => list.includes(btns[i]));\n const j = grids[g].indexOf(btns[i]);\n let to: HTMLButtonElement | \"search\" | undefined;\n if (e.key === \"ArrowRight\") to = btns[Math.min(i + 1, btns.length - 1)];\n else if (e.key === \"ArrowLeft\") to = btns[Math.max(i - 1, 0)];\n else if (e.key === \"Home\") to = btns[0];\n else if (e.key === \"End\") to = btns[btns.length - 1];\n else if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") to = verticalTarget(grids, g, j, e.key === \"ArrowDown\") ?? btns[i];\n else return;\n e.preventDefault();\n if (to === \"search\") scope?.querySelector<HTMLInputElement>(\"input[data-icon-search]\")?.focus();\n else to?.focus();\n };\n return (\n <div ref={ref} data-icon-grid className=\"grid gap-0.5\" style={{ gridTemplateColumns: `repeat(${COLS}, minmax(0, 1fr))` }} role=\"listbox\" aria-label={label} onKeyDown={move}>\n {items.map((it) => (\n // one shared tooltip for the whole picker (hundreds of icons): each trigger hands it its label\n <TooltipPrimitive.Trigger\n key={it.key}\n handle={tip}\n payload={it.label}\n delay={500}\n render={\n <button\n type=\"button\"\n role=\"option\"\n data-grid-item\n data-icon={it.key}\n aria-selected={it.key === selected}\n aria-label={it.label}\n tabIndex={it.key === stop ? 0 : -1}\n onClick={() => onPick(it.key)}\n className={cn(\n \"flex aspect-square items-center justify-center rounded-kit-md text-kit-fg-2 transition-colors hover:bg-kit-hover hover:text-kit-fg\",\n it.key === selected && \"bg-kit-selected text-kit-fg ring-1 ring-inset ring-kit-line-strong\",\n )}\n >\n {it.node}\n </button>\n }\n />\n ))}\n </div>\n );\n}\n\nconst NONE = \"__none\";\n\n/** The picker: search, Recent, then the whole set (\"No icon\" first). Search spans the name and its Tabler twin.\n * `field`: the icon field's popover (V2 IconFieldPicker, a 22rem list); otherwise the app-UI grid (V2 IconPickerGrid, max-h-56). */\nexport function IconPicker({ value, onPick, onChooseMedia, field }: { value?: string; onPick: (name: string | null) => void; onChooseMedia?: () => void; field?: boolean }) {\n const [q, setQ] = React.useState(\"\");\n const root = React.useRef<HTMLDivElement>(null);\n const tip = React.useMemo(() => TooltipPrimitive.createHandle<string>(), []);\n const needle = norm(q);\n const item = (name: string): GridItem => ({ key: name, label: iconLabel(name), node: <Glyph name={name} className=\"size-[18px]\" /> });\n const pick = (key: string) => onPick(key === NONE ? null : key);\n const hits = needle ? DOCK_ICON_NAMES.filter((n) => n.includes(needle) || tablerIconOf(n).includes(needle)) : [];\n const recent = recents.filter((n) => DOCK_ICON_NAME_SET.has(n));\n return (\n <div ref={root} data-icon-picker className=\"flex flex-col gap-2\">\n <TooltipPrimitive.Root handle={tip}>{({ payload }) => (payload ? <TooltipLayer>{payload}</TooltipLayer> : null)}</TooltipPrimitive.Root>\n <label className=\"flex h-8 items-center gap-2 rounded-kit-md bg-kit-muted px-2.5 text-kit-fg-3 focus-within:bg-kit-field-bg focus-within:ring-1 focus-within:ring-kit-line-strong\">\n <IconSearch className=\"size-4 shrink-0\" stroke={1.5} aria-hidden />\n <input\n autoFocus\n data-icon-search\n value={q}\n onChange={(e) => setQ(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n root.current?.querySelector<HTMLButtonElement>(\"[data-grid-item]\")?.focus();\n }\n }}\n placeholder=\"Search icons\"\n aria-label=\"Search icons\"\n className=\"h-full min-w-0 flex-1 bg-transparent text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\"\n />\n </label>\n <div className={field ? \"max-h-[22rem] overflow-y-auto pr-0.5\" : \"max-h-56 overflow-y-auto pr-0.5\"}>\n {needle ? (\n <div className=\"flex flex-col gap-2\">\n {hits.length ? (\n <Group>\n <IconGrid label=\"Icons\" selected={value} onPick={pick} tip={tip} items={hits.map(item)} />\n </Group>\n ) : (\n <p className=\"py-6 text-center text-kit-sm text-kit-fg-3\">No icons match “{q.trim()}”</p>\n )}\n </div>\n ) : (\n <div className=\"flex flex-col gap-2\">\n {recent.length ? (\n <Group title=\"Recent\">\n <IconGrid label=\"Recent icons\" selected={value} onPick={pick} tip={tip} items={recent.map(item)} />\n </Group>\n ) : null}\n <Group title={recent.length ? \"All icons\" : undefined}>\n <IconGrid\n label=\"Icons\"\n selected={value ?? NONE}\n onPick={pick}\n tip={tip}\n items={[{ key: NONE, label: \"No icon\", node: <IconX className=\"size-4\" stroke={1.5} aria-hidden /> }, ...DOCK_ICON_NAMES.map(item)]}\n />\n </Group>\n </div>\n )}\n </div>\n {onChooseMedia ? (\n <div className=\"flex items-center justify-between gap-2 border-t border-kit-line pt-2\">\n <span className=\"whitespace-nowrap text-kit-xs text-kit-fg-3\">Images keep their colours.</span>\n <Button size=\"xs\" variant=\"ghost\" leftIcon={<IconPhoto stroke={1.5} />} onClick={onChooseMedia}>\n Choose from media\n </Button>\n </div>\n ) : null}\n </div>\n );\n}\n\nfunction Group({ title, children }: { title?: string; children: React.ReactNode }) {\n return (\n <div className=\"flex flex-col gap-1\">\n {title ? <div className=\"px-0.5 text-kit-2xs font-medium text-kit-fg-3\">{title}</div> : null}\n {children}\n </div>\n );\n}\n\n/* ── The control ──────────────────────────────────────────────────────── */\nconst TAB_LABEL: Record<IconSource, string> = { pack: \"Icons\", library: \"Library\", upload: \"Upload\" };\n\n/** The project's library icons a field offers: its sets, and only text-coloured ones when it takes no colour (V2). */\nfunction LibraryGrid({ field, selected, onPick }: { field: ControlProps[\"field\"]; selected?: string; onPick: (icon: KitLibraryIcon) => void }) {\n const { iconLibrary } = useKitServices();\n const opts = resolveIconOptions(field.icons);\n const tip = React.useMemo(() => TooltipPrimitive.createHandle<string>(), []);\n const icons = (iconLibrary?.().icons ?? []).filter((i) => (!opts.sets || (i.set && opts.sets.includes(i.set))) && (opts.allowColor || i.followsText));\n if (!icons.length) return <p className=\"py-6 text-center text-kit-sm text-kit-fg-3\">No library icons for this field yet</p>;\n return (\n <>\n <TooltipPrimitive.Root handle={tip}>{({ payload }) => (payload ? <TooltipLayer>{payload}</TooltipLayer> : null)}</TooltipPrimitive.Root>\n <IconGrid\n label=\"Library icons\"\n selected={selected}\n tip={tip}\n onPick={(key) => { const i = icons.find((x) => x.key === key); if (i) onPick(i); }}\n items={icons.map((i) => ({ key: i.key, label: i.name, node: <IconValueGlyph value={{ source: \"library\", id: i.key, url: i.url, followsText: i.followsText }} className=\"size-[18px]\" /> }))}\n />\n </>\n );\n}\n\nexport function IconControl({ field, value, onChange, readOnly, id, invalid }: ControlProps) {\n const { MediaPicker, iconLibrary } = useKitServices();\n const [open, setOpen] = React.useState(false);\n const [mediaOpen, setMediaOpen] = React.useState(false);\n const optedIn = !!field.icons;\n const opts = resolveIconOptions(field.icons);\n const sources = opts.sources.filter((s) => (s !== \"library\" || iconLibrary) && (s !== \"upload\" || MediaPicker));\n const n = normalizeIcon(value);\n const read = readIcon(value);\n const [tab, setTab] = React.useState<IconSource>(n && sources.includes(n.source) ? n.source : sources[0] ?? \"pack\");\n\n /** The picked icon, keeping the current description (V2: swapping the icon keeps what it says). */\n const commit = (next: IconObjectValue | null) => {\n const v = next && n?.label ? { ...next, label: n.label } : next;\n onChange(compactIcon(v) || null);\n if (v?.source === \"pack\" && DOCK_ICON_NAME_SET.has(v.name)) pushRecent(v.name);\n setOpen(false);\n };\n const library = n?.source === \"library\" ? iconLibrary?.().icons.find((i) => i.key === n.id) : undefined;\n\n const tile =\n read.kind === \"empty\" && !n ? (\n <span className=\"size-3 rounded-kit-md border border-dashed border-[var(--kit-emphasis-line)]\" />\n ) : read.kind === \"unknown\" || (read.kind === \"unreadable\" && !n) ? (\n <IconAlertTriangle className=\"size-3.5 text-kit-warning-fg\" stroke={1.5} aria-hidden />\n ) : (\n <IconValueGlyph value={value} className=\"size-4\" />\n );\n const text =\n n?.source === \"library\"\n ? library?.name ?? \"Library icon\"\n : read.kind === \"name\"\n ? iconLabel(read.name)\n : n?.source === \"upload\"\n ? fileName(n.url)\n : read.kind === \"unknown\"\n ? `“${read.name}” isn't in the icon set`\n : read.kind === \"unreadable\"\n ? \"This value isn't an icon this picker can read\"\n : \"Choose an icon\";\n const warn = read.kind === \"unknown\" || (read.kind === \"unreadable\" && !n);\n const chooseMedia = () => {\n setOpen(false);\n setMediaOpen(true);\n };\n const packPicker = (\n <IconPicker\n field\n value={n?.source === \"pack\" ? n.name : n ? \"\" : undefined}\n onPick={(name) => commit(name ? { source: \"pack\", name } : null)}\n onChooseMedia={!optedIn && MediaPicker ? chooseMedia : undefined}\n />\n );\n\n return (\n <div className=\"flex flex-col gap-1.5\">\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger\n render={\n <button\n id={id}\n type=\"button\"\n disabled={readOnly}\n aria-invalid={invalid || undefined}\n className={cn(\n \"flex h-8 w-full items-center gap-2.5 rounded-kit-md border border-kit-line-strong bg-kit-field-bg px-1 pr-2.5 text-left text-kit-sm transition-colors hover:border-kit-line-strong data-[popup-open]:border-kit-line-strong data-[popup-open]:bg-kit-field-bg\",\n invalid && \"border-[var(--kit-field-invalid)]\",\n )}\n />\n }\n >\n <span className=\"flex size-6 items-center justify-center rounded-kit-md border border-kit-line bg-kit-control-bg text-kit-fg\">{tile}</span>\n <span className={cn(\"min-w-0 flex-1 truncate\", warn ? \"text-kit-warning-fg\" : !n ? \"text-kit-fg-3\" : \"text-kit-fg\")}>{text}</span>\n <IconChevronDown className=\"size-3.5 text-kit-fg-3\" stroke={1.5} aria-hidden />\n </PopoverTrigger>\n <PopoverContent className=\"w-[320px] p-2\" align=\"start\" aria-label={`${field.title}: choose an icon`}>\n {optedIn && sources.length > 1 ? (\n <div className=\"flex flex-col gap-2\">\n <Segmented<IconSource> aria-label=\"Icon source\" size=\"sm\" value={tab} onChange={setTab} items={sources.map((s) => ({ value: s, label: TAB_LABEL[s] }))} className=\"w-full [&>button]:flex-1\" />\n {tab === \"pack\" ? (\n packPicker\n ) : tab === \"library\" ? (\n <LibraryGrid field={field} selected={n?.source === \"library\" ? n.id : undefined} onPick={(i) => commit({ source: \"library\", id: i.key, url: i.url, ...(i.followsText ? { followsText: true } : {}) })} />\n ) : (\n <div className=\"flex flex-col items-center gap-2 py-6\">\n <span className=\"text-kit-xs text-kit-fg-3\">Images keep their colours.</span>\n <Button size=\"xs\" variant=\"ghost\" leftIcon={<IconPhoto stroke={1.5} />} onClick={chooseMedia}>\n Choose from media\n </Button>\n </div>\n )}\n </div>\n ) : (\n packPicker\n )}\n </PopoverContent>\n </Popover>\n {optedIn && opts.decorative === \"ask\" && n ? (\n <Input\n size=\"sm\"\n value={n.label ?? \"\"}\n readOnly={readOnly}\n maxLength={80}\n onChange={(e) => onChange(withIconLabel(value, e.target.value) || null)}\n placeholder=\"Describe this icon\"\n aria-label={`Describe this icon (${field.title})`}\n />\n ) : null}\n {MediaPicker && mediaOpen ? (\n <MediaPicker\n open={mediaOpen}\n onOpenChange={setMediaOpen}\n accept={[\"svg\", \"image\"]}\n onPick={(assets) => {\n const a = assets[0];\n // a field that opts in keeps the media id (D65); one that does not stores the url, as it always did\n if (a?.url) commit({ source: \"upload\", url: a.url, ...(optedIn && a.id ? { assetId: a.id } : {}) });\n }}\n />\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,eAAe,EAAE,OAAO,aAAqD;CAC3F,MAAM,EAAE,aAAa,eAAe;CACpC,MAAM,MAAM,QAAQ,KAAK;CACzB,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI,UAAU,KAAK,OAAO,oBAAC,OAAD;EAAO,MAAM,IAAI;EAAiB;CAAY,CAAA;CACxE,MAAM,MAAM,WAAW,SAAS,IAAI,GAAG,IAAI,IAAI;CAC/C,IAAI,IAAI,aAAa;EACnB,MAAM,OAAO,OAAO,KAAK,UAAU,GAAG,EAAE;EACxC,OAAO,oBAAC,QAAD;GAAM,eAAA;GAAY,WAAW,GAAG,2BAA2B,SAAS;GAAG,OAAO;IAAE;IAAM,YAAY;GAAK;EAAI,CAAA;CACpH;CACA,OAAO,oBAAC,OAAD;EAAK,KAAK;EAAK,KAAI;EAAG,WAAW,GAAG,kBAAkB,SAAS;CAAI,CAAA;AAC5E;AAEA,IAAI,YAA4C;AAChD,IAAI,aAAmC;AACvC,IAAM,UAAU,UAAkB,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;;AAGpH,SAAS,aAAa,MAA+C;CACnE,MAAM,GAAG,UAAU,MAAM,YAAY,MAAc,IAAI,GAAG,CAAC;CAC3D,MAAM,gBAAgB;EACpB,IAAI,CAAC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["/**\n * ICON — the icon field (DESIGN 8.14), V2 controls/icon.tsx fitted to what prod stores.\n *\n * Values (backend reference-validation `icon`, the classic PropsPanel IconValueInput):\n * \"arrow-right\" a name from the BetterCMS icon set (DOCK_ICON_NAMES, 473 names)\n * \"https://…/logo.svg\" an uploaded icon: an image URL (picked from the media library; a component prop\n * stores the URL string, like the classic panel's codec=\"url\")\n * { url, … } an uploaded icon stored as an image value: shown and kept until replaced\n * null no icon (\"No icon\"; the backend skips an empty value)\n * { source: pack | library | upload, …, label? } D65: a field with `icons` (V2 FieldSchema.icons) opts in to the\n * project's icon library, media uploads by id and an accessible label\n *\n * A field without `icons` draws and stores exactly what it always did. One with `icons` gets V2's source tabs (Icons ·\n * Library · Upload), the library from the host (KitServices.iconLibrary) and \"Describe this icon\" when it asks.\n *\n * The grid offers the BetterCMS set, the one prod accepts. Search also matches a name's Tabler twin through the\n * Tabler ↔ dock adapter (adapters/icons.ts), so \"map\" finds earth-americas. A stored name outside the set (a stale\n * Tabler or Lucide name) is shown with its reason and kept until the author picks another.\n *\n * Glyphs: the host draws them (KitServices.IconGlyph: the dashboard's DockIcon, the set the site renders). With no\n * host renderer the kit draws the Tabler twin, loaded on first use; a name with no Tabler twin shows its name.\n */\nimport * as React from \"react\";\nimport type { Icon as TablerIcon } from \"@tabler/icons-react\";\nimport { IconAlertTriangle, IconChevronDown, IconPhoto, IconSearch, IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport { iconLabel } from \"../lib/icons\";\nimport { useKitServices } from \"../context\";\nimport { DOCK_ICON_NAMES, DOCK_ICON_NAME_SET } from \"../adapters/prod-types\";\nimport { compactIcon, iconSrc, normalizeIcon, resolveIconOptions, withIconLabel, type IconObjectValue, type IconSource } from \"@bettercms-ai/types\";\nimport { Segmented } from \"../ui/controls\";\nimport { Input } from \"../ui/input\";\nimport { tablerIconOf } from \"../adapters/icons\";\nimport type { ControlProps } from \"../types\";\nimport { Button } from \"../ui/button\";\nimport { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../ui/overlay\";\nimport { TooltipLayer } from \"../ui/tooltip-root\";\n\n/* ── Glyphs ───────────────────────────────────────────────────────────── */\ndeclare module \"../context\" {\n interface KitServices {\n /**\n * Draws one icon of the BetterCMS set by name, aria-hidden (the name beside it is the accessible text): the glyphs\n * the site renders. The dashboard passes `DockIcon` (src/components/dock/DockIcon). Absent → the Tabler twin.\n */\n IconGlyph?: React.ComponentType<{ name: string; className?: string }>;\n /**\n * The project's icon library (V2 D65, the brand kit's icons): each with its resolved url and whether it follows the\n * text colour, and the sets. Absent → an icon field offers no Library tab.\n */\n iconLibrary?: () => { icons: KitLibraryIcon[]; sets: Array<{ key: string; name: string }> };\n }\n}\nexport type KitLibraryIcon = { key: string; name: string; set?: string; followsText: boolean; url: string };\n\n/** Any icon value as its glyph: a set name drawn by the host, a text-coloured library icon as a mask, else an image. */\nexport function IconValueGlyph({ value, className }: { value: unknown; className?: string }) {\n const { mediaSrc } = useKitServices();\n const src = iconSrc(value);\n if (!src) return null;\n if (\"name\" in src) return <Glyph name={src.name} className={className} />;\n const url = mediaSrc ? mediaSrc(src.url) : src.url;\n if (src.followsText) {\n const mask = `url(${JSON.stringify(url)}) center / contain no-repeat`;\n return <span aria-hidden className={cn(\"inline-block bg-current\", className)} style={{ mask, WebkitMask: mask }} />;\n }\n return <img src={url} alt=\"\" className={cn(\"object-contain\", className)} />;\n}\n\nlet tablerSet: Record<string, unknown> | null = null;\nlet tablerLoad: Promise<void> | null = null;\nconst pascal = (kebab: string) => `Icon${kebab.split(\"-\").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}`;\n\n/** The full Tabler set, loaded once and only when no host renderer is provided. */\nfunction useTablerSet(need: boolean): Record<string, unknown> | null {\n const [, landed] = React.useReducer((n: number) => n + 1, 0);\n React.useEffect(() => {\n if (!need || tablerSet) return;\n let live = true;\n tablerLoad ??= import(\"@tabler/icons-react\").then((m) => {\n tablerSet = m as unknown as Record<string, unknown>;\n });\n tablerLoad.then(() => live && landed(), () => {});\n return () => {\n live = false;\n };\n }, [need]);\n return tablerSet;\n}\n\nfunction Glyph({ name, className }: { name: string; className?: string }) {\n const Host = useKitServices().IconGlyph;\n const set = useTablerSet(!Host);\n if (Host) return <Host name={name} className={className} />;\n const T = set?.[pascal(tablerIconOf(name))] as TablerIcon | undefined;\n if (T) return <T className={className} stroke={1.5} aria-hidden />;\n // no Tabler twin (or the set is still loading): the name itself, never a stand-in shape\n return (\n <span aria-hidden className=\"max-w-full truncate px-0.5 text-[9px] leading-3 text-kit-fg-3\">\n {name}\n </span>\n );\n}\n\n/* ── Values ───────────────────────────────────────────────────────────── */\ntype Read =\n | { kind: \"empty\" }\n | { kind: \"name\"; name: string }\n | { kind: \"unknown\"; name: string }\n | { kind: \"upload\"; url: string }\n | { kind: \"unreadable\" };\nconst isUrlish = (s: string) => /[/.]/.test(s);\nfunction readIcon(v: unknown): Read {\n if (v == null || v === \"\") return { kind: \"empty\" };\n if (typeof v === \"string\") return DOCK_ICON_NAME_SET.has(v) ? { kind: \"name\", name: v } : isUrlish(v) ? { kind: \"upload\", url: v } : { kind: \"unknown\", name: v };\n if (isObj(v) && typeof v.url === \"string\" && v.url) return { kind: \"upload\", url: v.url };\n return { kind: \"unreadable\" };\n}\nconst fileName = (url: string) => decodeURIComponent(url.split(/[?#]/)[0].split(\"/\").pop() || url);\n\n/** Names picked this session, newest first (shown as \"Recent\"). */\nconst recents: string[] = [];\nconst pushRecent = (name: string) => {\n const i = recents.indexOf(name);\n if (i !== -1) recents.splice(i, 1);\n recents.unshift(name);\n recents.length = Math.min(recents.length, COLS);\n};\n\n/* ── The grid: one tab stop, arrow keys, Home / End ───────────────────── */\nconst COLS = 8;\nconst norm = (q: string) => q.toLowerCase().trim().replace(/\\s+/g, \"-\");\ninterface GridItem {\n key: string;\n label: string;\n node: React.ReactNode;\n}\n\ntype TipHandle = ReturnType<typeof TooltipPrimitive.createHandle<string>>;\n\n/** Up / down within a grid keep the column; past its edge they land in the same column of the next / previous grid. */\nfunction verticalTarget(grids: HTMLButtonElement[][], g: number, j: number, down: boolean): HTMLButtonElement | \"search\" | undefined {\n const col = j % COLS;\n const cur = grids[g];\n const within = down ? j + COLS : j - COLS;\n if (within >= 0 && within < cur.length) return cur[within];\n if (down && Math.floor(j / COLS) < Math.floor((cur.length - 1) / COLS)) return cur[cur.length - 1]; // a short last row\n const next = grids[down ? g + 1 : g - 1];\n if (!next) return down ? undefined : \"search\";\n if (down) return next[Math.min(col, next.length - 1)];\n const lastRow = Math.floor((next.length - 1) / COLS) * COLS;\n return next[Math.min(lastRow + col, next.length - 1)];\n}\n\nfunction IconGrid({ items, selected, onPick, label, tip }: { items: GridItem[]; selected?: string; onPick: (key: string) => void; label: string; tip: TipHandle }) {\n const ref = React.useRef<HTMLDivElement>(null);\n const stop = items.some((i) => i.key === selected) ? selected : items[0]?.key;\n const move = (e: React.KeyboardEvent) => {\n // one keyboard space across every group in the picker (Recent, the set, search results)\n const scope = ref.current?.closest(\"[data-icon-picker]\") ?? ref.current;\n const grids = Array.from(scope?.querySelectorAll<HTMLElement>(\"[data-icon-grid]\") ?? []).map((g) => Array.from(g.querySelectorAll<HTMLButtonElement>(\"[data-grid-item]\")));\n const btns = grids.flat();\n const i = btns.indexOf(document.activeElement as HTMLButtonElement);\n if (i === -1) return;\n const g = grids.findIndex((list) => list.includes(btns[i]));\n const j = grids[g].indexOf(btns[i]);\n let to: HTMLButtonElement | \"search\" | undefined;\n if (e.key === \"ArrowRight\") to = btns[Math.min(i + 1, btns.length - 1)];\n else if (e.key === \"ArrowLeft\") to = btns[Math.max(i - 1, 0)];\n else if (e.key === \"Home\") to = btns[0];\n else if (e.key === \"End\") to = btns[btns.length - 1];\n else if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") to = verticalTarget(grids, g, j, e.key === \"ArrowDown\") ?? btns[i];\n else return;\n e.preventDefault();\n if (to === \"search\") scope?.querySelector<HTMLInputElement>(\"input[data-icon-search]\")?.focus();\n else to?.focus();\n };\n return (\n <div ref={ref} data-icon-grid className=\"grid gap-0.5\" style={{ gridTemplateColumns: `repeat(${COLS}, minmax(0, 1fr))` }} role=\"listbox\" aria-label={label} onKeyDown={move}>\n {items.map((it) => (\n // one shared tooltip for the whole picker (hundreds of icons): each trigger hands it its label\n <TooltipPrimitive.Trigger\n key={it.key}\n handle={tip}\n payload={it.label}\n delay={500}\n render={\n <button\n type=\"button\"\n role=\"option\"\n data-grid-item\n data-icon={it.key}\n aria-selected={it.key === selected}\n aria-label={it.label}\n tabIndex={it.key === stop ? 0 : -1}\n onClick={() => onPick(it.key)}\n className={cn(\n \"flex aspect-square items-center justify-center rounded-kit-md text-kit-fg-2 transition-colors hover:bg-kit-hover hover:text-kit-fg\",\n it.key === selected && \"bg-kit-selected text-kit-fg ring-1 ring-inset ring-kit-line-strong\",\n )}\n >\n {it.node}\n </button>\n }\n />\n ))}\n </div>\n );\n}\n\nconst NONE = \"__none\";\n\n/** The picker: search, Recent, then the whole set (\"No icon\" first). Search spans the name and its Tabler twin.\n * `field`: the icon field's popover (V2 IconFieldPicker, a 22rem list); otherwise the app-UI grid (V2 IconPickerGrid, max-h-56). */\nexport function IconPicker({ value, onPick, onChooseMedia, field }: { value?: string; onPick: (name: string | null) => void; onChooseMedia?: () => void; field?: boolean }) {\n const [q, setQ] = React.useState(\"\");\n const root = React.useRef<HTMLDivElement>(null);\n const tip = React.useMemo(() => TooltipPrimitive.createHandle<string>(), []);\n const needle = norm(q);\n const item = (name: string): GridItem => ({ key: name, label: iconLabel(name), node: <Glyph name={name} className=\"size-[18px]\" /> });\n const pick = (key: string) => onPick(key === NONE ? null : key);\n const hits = needle ? DOCK_ICON_NAMES.filter((n) => n.includes(needle) || tablerIconOf(n).includes(needle)) : [];\n const recent = recents.filter((n) => DOCK_ICON_NAME_SET.has(n));\n return (\n <div ref={root} data-icon-picker className=\"flex flex-col gap-2\">\n <TooltipPrimitive.Root handle={tip}>{({ payload }) => (payload ? <TooltipLayer>{payload}</TooltipLayer> : null)}</TooltipPrimitive.Root>\n <label className=\"flex h-8 items-center gap-2 rounded-kit-md bg-kit-muted px-2.5 text-kit-fg-3 focus-within:bg-kit-field-bg focus-within:ring-1 focus-within:ring-kit-line-strong\">\n <IconSearch className=\"size-4 shrink-0\" stroke={1.5} aria-hidden />\n <input\n autoFocus\n data-icon-search\n value={q}\n onChange={(e) => setQ(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n root.current?.querySelector<HTMLButtonElement>(\"[data-grid-item]\")?.focus();\n }\n }}\n placeholder=\"Search icons\"\n aria-label=\"Search icons\"\n className=\"h-full min-w-0 flex-1 bg-transparent text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\"\n />\n </label>\n <div className={field ? \"max-h-[22rem] overflow-y-auto pr-0.5\" : \"max-h-56 overflow-y-auto pr-0.5\"}>\n {needle ? (\n <div className=\"flex flex-col gap-2\">\n {hits.length ? (\n <Group>\n <IconGrid label=\"Icons\" selected={value} onPick={pick} tip={tip} items={hits.map(item)} />\n </Group>\n ) : (\n <p className=\"py-6 text-center text-kit-sm text-kit-fg-3\">No icons match “{q.trim()}”</p>\n )}\n </div>\n ) : (\n <div className=\"flex flex-col gap-2\">\n {recent.length ? (\n <Group title=\"Recent\">\n <IconGrid label=\"Recent icons\" selected={value} onPick={pick} tip={tip} items={recent.map(item)} />\n </Group>\n ) : null}\n <Group title={recent.length ? \"All icons\" : undefined}>\n <IconGrid\n label=\"Icons\"\n selected={value ?? NONE}\n onPick={pick}\n tip={tip}\n items={[{ key: NONE, label: \"No icon\", node: <IconX className=\"size-4\" stroke={1.5} aria-hidden /> }, ...DOCK_ICON_NAMES.map(item)]}\n />\n </Group>\n </div>\n )}\n </div>\n {onChooseMedia ? (\n <div className=\"flex items-center justify-between gap-2 border-t border-kit-line pt-2\">\n <span className=\"whitespace-nowrap text-kit-xs text-kit-fg-3\">Images keep their colours.</span>\n <Button size=\"xs\" variant=\"ghost\" leftIcon={<IconPhoto stroke={1.5} />} onClick={onChooseMedia}>\n Choose from media\n </Button>\n </div>\n ) : null}\n </div>\n );\n}\n\nfunction Group({ title, children }: { title?: string; children: React.ReactNode }) {\n return (\n <div className=\"flex flex-col gap-1\">\n {title ? <div className=\"px-0.5 text-kit-2xs font-medium text-kit-fg-3\">{title}</div> : null}\n {children}\n </div>\n );\n}\n\n/* ── The control ──────────────────────────────────────────────────────── */\nconst TAB_LABEL: Record<IconSource, string> = { pack: \"Icons\", library: \"Library\", upload: \"Upload\" };\n\n/** The project's library icons a field offers: its sets, and only text-coloured ones when it takes no colour (V2). */\nfunction LibraryGrid({ field, selected, onPick }: { field: ControlProps[\"field\"]; selected?: string; onPick: (icon: KitLibraryIcon) => void }) {\n const { iconLibrary } = useKitServices();\n const opts = resolveIconOptions(field.icons);\n const tip = React.useMemo(() => TooltipPrimitive.createHandle<string>(), []);\n const icons = (iconLibrary?.().icons ?? []).filter((i) => (!opts.sets || (i.set && opts.sets.includes(i.set))) && (opts.allowColor || i.followsText));\n if (!icons.length) return <p className=\"py-6 text-center text-kit-sm text-kit-fg-3\">No library icons for this field yet</p>;\n return (\n <>\n <TooltipPrimitive.Root handle={tip}>{({ payload }) => (payload ? <TooltipLayer>{payload}</TooltipLayer> : null)}</TooltipPrimitive.Root>\n <IconGrid\n label=\"Library icons\"\n selected={selected}\n tip={tip}\n onPick={(key) => { const i = icons.find((x) => x.key === key); if (i) onPick(i); }}\n items={icons.map((i) => ({ key: i.key, label: i.name, node: <IconValueGlyph value={{ source: \"library\", id: i.key, url: i.url, followsText: i.followsText }} className=\"size-[18px]\" /> }))}\n />\n </>\n );\n}\n\nexport function IconControl({ field, value, onChange, readOnly, id, invalid }: ControlProps) {\n const { MediaPicker, iconLibrary } = useKitServices();\n const [open, setOpen] = React.useState(false);\n const [mediaOpen, setMediaOpen] = React.useState(false);\n const optedIn = !!field.icons;\n const opts = resolveIconOptions(field.icons);\n const sources = opts.sources.filter((s) => (s !== \"library\" || iconLibrary) && (s !== \"upload\" || MediaPicker));\n const n = normalizeIcon(value);\n const read = readIcon(value);\n const [tab, setTab] = React.useState<IconSource>(n && sources.includes(n.source) ? n.source : sources[0] ?? \"pack\");\n\n /** The picked icon, keeping the current description (V2: swapping the icon keeps what it says). */\n const commit = (next: IconObjectValue | null) => {\n const v = next && n?.label ? { ...next, label: n.label } : next;\n onChange(compactIcon(v) || null);\n if (v?.source === \"pack\" && DOCK_ICON_NAME_SET.has(v.name)) pushRecent(v.name);\n setOpen(false);\n };\n const library = n?.source === \"library\" ? iconLibrary?.().icons.find((i) => i.key === n.id) : undefined;\n\n const tile =\n read.kind === \"empty\" && !n ? (\n <span className=\"size-3 rounded-kit-md border border-dashed border-[var(--kit-emphasis-line)]\" />\n ) : read.kind === \"unknown\" || (read.kind === \"unreadable\" && !n) ? (\n <IconAlertTriangle className=\"size-3.5 text-kit-warning-fg\" stroke={1.5} aria-hidden />\n ) : (\n <IconValueGlyph value={value} className=\"size-4\" />\n );\n const text =\n n?.source === \"library\"\n ? library?.name ?? \"Library icon\"\n : read.kind === \"name\"\n ? iconLabel(read.name)\n : n?.source === \"upload\"\n ? fileName(n.url)\n : read.kind === \"unknown\"\n ? `“${read.name}” isn't in the icon set`\n : read.kind === \"unreadable\"\n ? \"This value isn't an icon this picker can read\"\n : \"Choose an icon\";\n const warn = read.kind === \"unknown\" || (read.kind === \"unreadable\" && !n);\n const chooseMedia = () => {\n setOpen(false);\n setMediaOpen(true);\n };\n const packPicker = (\n <IconPicker\n field\n value={n?.source === \"pack\" ? n.name : n ? \"\" : undefined}\n onPick={(name) => commit(name ? { source: \"pack\", name } : null)}\n onChooseMedia={!optedIn && MediaPicker ? chooseMedia : undefined}\n />\n );\n\n return (\n <div className=\"flex flex-col gap-1.5\">\n <Popover open={open} onOpenChange={setOpen}>\n {/* the id on the Trigger, not the button: Base UI 1.4 read a render-element id as another trigger (KP-102) */}\n <PopoverTrigger\n id={id}\n render={\n <button\n type=\"button\"\n disabled={readOnly}\n aria-invalid={invalid || undefined}\n className={cn(\n \"flex h-8 w-full items-center gap-2.5 rounded-kit-md border border-kit-field-border bg-kit-field-bg px-1 pr-2.5 text-left text-kit-sm transition-colors hover:border-kit-field-border-hover data-[popup-open]:border-kit-field-border-focus data-[popup-open]:bg-kit-field-bg\",\n invalid && \"border-[var(--kit-field-invalid)]\",\n )}\n />\n }\n >\n <span className=\"flex size-6 items-center justify-center rounded-kit-md border border-kit-line bg-kit-control-bg text-kit-fg\">{tile}</span>\n <span className={cn(\"min-w-0 flex-1 truncate\", warn ? \"text-kit-warning-fg\" : !n ? \"text-kit-fg-3\" : \"text-kit-fg\")}>{text}</span>\n <IconChevronDown className=\"size-3.5 text-kit-fg-3\" stroke={1.5} aria-hidden />\n </PopoverTrigger>\n <PopoverContent className=\"w-[320px] p-2\" align=\"start\" aria-label={`${field.title}: choose an icon`}>\n {optedIn && sources.length > 1 ? (\n <div className=\"flex flex-col gap-2\">\n <Segmented<IconSource> aria-label=\"Icon source\" size=\"sm\" value={tab} onChange={setTab} items={sources.map((s) => ({ value: s, label: TAB_LABEL[s] }))} className=\"w-full [&>button]:flex-1\" />\n {tab === \"pack\" ? (\n packPicker\n ) : tab === \"library\" ? (\n <LibraryGrid field={field} selected={n?.source === \"library\" ? n.id : undefined} onPick={(i) => commit({ source: \"library\", id: i.key, url: i.url, ...(i.followsText ? { followsText: true } : {}) })} />\n ) : (\n <div className=\"flex flex-col items-center gap-2 py-6\">\n <span className=\"text-kit-xs text-kit-fg-3\">Images keep their colours.</span>\n <Button size=\"xs\" variant=\"ghost\" leftIcon={<IconPhoto stroke={1.5} />} onClick={chooseMedia}>\n Choose from media\n </Button>\n </div>\n )}\n </div>\n ) : (\n packPicker\n )}\n </PopoverContent>\n </Popover>\n {optedIn && opts.decorative === \"ask\" && n ? (\n <Input\n size=\"sm\"\n value={n.label ?? \"\"}\n readOnly={readOnly}\n maxLength={80}\n onChange={(e) => onChange(withIconLabel(value, e.target.value) || null)}\n placeholder=\"Describe this icon\"\n aria-label={`Describe this icon (${field.title})`}\n />\n ) : null}\n {MediaPicker && mediaOpen ? (\n <MediaPicker\n open={mediaOpen}\n onOpenChange={setMediaOpen}\n accept={[\"svg\", \"image\"]}\n onPick={(assets) => {\n const a = assets[0];\n // a field that opts in keeps the media id (D65); one that does not stores the url, as it always did\n if (a?.url) commit({ source: \"upload\", url: a.url, ...(optedIn && a.id ? { assetId: a.id } : {}) });\n }}\n />\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,eAAe,EAAE,OAAO,aAAqD;CAC3F,MAAM,EAAE,aAAa,eAAe;CACpC,MAAM,MAAM,QAAQ,KAAK;CACzB,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI,UAAU,KAAK,OAAO,oBAAC,OAAD;EAAO,MAAM,IAAI;EAAiB;CAAY,CAAA;CACxE,MAAM,MAAM,WAAW,SAAS,IAAI,GAAG,IAAI,IAAI;CAC/C,IAAI,IAAI,aAAa;EACnB,MAAM,OAAO,OAAO,KAAK,UAAU,GAAG,EAAE;EACxC,OAAO,oBAAC,QAAD;GAAM,eAAA;GAAY,WAAW,GAAG,2BAA2B,SAAS;GAAG,OAAO;IAAE;IAAM,YAAY;GAAK;EAAI,CAAA;CACpH;CACA,OAAO,oBAAC,OAAD;EAAK,KAAK;EAAK,KAAI;EAAG,WAAW,GAAG,kBAAkB,SAAS;CAAI,CAAA;AAC5E;AAEA,IAAI,YAA4C;AAChD,IAAI,aAAmC;AACvC,IAAM,UAAU,UAAkB,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;;AAGpH,SAAS,aAAa,MAA+C;CACnE,MA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AAA,IACC;EACD;;AAET"}
|
|
@@ -99,7 +99,7 @@ function LocationControl({ field, value, onChange, readOnly, id, invalid }) {
|
|
|
99
99
|
lng: value.lng
|
|
100
100
|
} : null;
|
|
101
101
|
return /* @__PURE__ */ jsxs("div", {
|
|
102
|
-
className: cn("overflow-hidden rounded-kit-lg border border-kit-
|
|
102
|
+
className: cn("overflow-hidden rounded-kit-lg border border-kit-field-border", invalid && "border-[var(--kit-field-invalid)]"),
|
|
103
103
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
104
104
|
className: "relative h-28 overflow-hidden bg-kit-subtle",
|
|
105
105
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location.js","names":[],"sources":["../../src/controls/location.tsx"],"sourcesContent":["/**\n * LOCATION — the geopoint field (DESIGN 8.21), V2 GeoControl fitted to what prod stores.\n *\n * Value (backend reference-validation `location`, the classic LocationField): `{ lat, lng, label? }`, lat −90…90 and\n * lng −180…180, finite numbers; null when empty. Keys the stored object carries beyond those are kept.\n *\n * A coordinate is written only when it is whole: both numbers, in range. Until then the field says what is missing\n * (\"Add the longitude too\") and keeps the stored value, because the backend refuses half a coordinate. Emptying all\n * three boxes clears the value. Pasting \"44.0582, -121.3153\" into either box fills both.\n *\n * The card above the inputs shows the pin and the coordinates, with a link that opens them on OpenStreetMap; it\n * draws no map tiles (no vendor, key or bundle).\n */\nimport * as React from \"react\";\nimport { IconMapPin } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport type { ControlProps } from \"../types\";\nimport { Input } from \"../ui/input\";\nimport { TEXT_FOCUS } from \"./text\";\n\ninterface Draft {\n lat: string;\n lng: string;\n label: string;\n}\nconst num = (v: unknown) => (typeof v === \"number\" && Number.isFinite(v) ? String(v) : \"\");\nconst draftOf = (v: unknown): Draft => (isObj(v) ? { lat: num(v.lat), lng: num(v.lng), label: typeof v.label === \"string\" ? v.label : \"\" } : { lat: \"\", lng: \"\", label: \"\" });\nconst PAIR = /^\\s*(-?\\d+(?:\\.\\d+)?)\\s*[,;\\s]\\s*(-?\\d+(?:\\.\\d+)?)\\s*$/;\n\n/** The value a draft writes, or the reason it can't be written yet. */\nexport function locationFromDraft(d: Draft, prev: unknown): { ok: true; value: Record<string, unknown> | null } | { ok: false; reason: string } {\n const lat = d.lat.trim();\n const lng = d.lng.trim();\n const label = d.label.trim();\n if (!lat && !lng && !label) return { ok: true, value: null };\n if (!lat || !lng) return { ok: false, reason: !lat && !lng ? \"Add a latitude and a longitude to save this location.\" : !lat ? \"Add the latitude too: a location needs both.\" : \"Add the longitude too: a location needs both.\" };\n const la = Number(lat);\n const lo = Number(lng);\n if (!Number.isFinite(la) || Math.abs(la) > 90) return { ok: false, reason: \"Latitude must be a number from −90 to 90.\" };\n if (!Number.isFinite(lo) || Math.abs(lo) > 180) return { ok: false, reason: \"Longitude must be a number from −180 to 180.\" };\n const out: Record<string, unknown> = { ...(isObj(prev) ? prev : {}), lat: la, lng: lo };\n if (label) out.label = label;\n else delete out.label;\n return { ok: true, value: out };\n}\n\nexport function LocationControl({ field, value, onChange, readOnly, id, invalid }: ControlProps) {\n const [draft, setDraft] = React.useState<Draft>(() => draftOf(value));\n const [seen, setSeen] = React.useState(value);\n const [mine, setMine] = React.useState<unknown>(undefined);\n // a value set from elsewhere (undo, another editor) replaces the draft; our own writes keep what the author typed\n if (value !== seen) {\n setSeen(value);\n if (value !== mine) setDraft(draftOf(value));\n }\n const result = locationFromDraft(draft, value);\n const reasonId = `${id}-reason`;\n\n const update = (patch: Partial<Draft>) => {\n const next = { ...draft, ...patch };\n setDraft(next);\n const r = locationFromDraft(next, value);\n if (!r.ok) return;\n const same = JSON.stringify(r.value) === JSON.stringify(value ?? null);\n if (same) return;\n setMine(r.value);\n onChange(r.value);\n };\n const coordinate = (key: \"lat\" | \"lng\") => (e: React.ChangeEvent<HTMLInputElement>) => {\n const pair = PAIR.exec(e.target.value);\n update(pair ? { lat: pair[1], lng: pair[2] } : ({ [key]: e.target.value } as Partial<Draft>));\n };\n\n const shown = isObj(value) && typeof value.lat === \"number\" && typeof value.lng === \"number\" ? { lat: value.lat, lng: value.lng } : null;\n return (\n <div className={cn(\"overflow-hidden rounded-kit-lg border border-kit-line\", invalid && \"border-[var(--kit-field-invalid)]\")}>\n <div className=\"relative h-28 overflow-hidden bg-kit-subtle\">\n {/* V2 `.grid-lines` (styles/index.css:1026), inlined: the dash has no such utility */}\n <div\n className=\"absolute inset-0 opacity-80\"\n style={{ backgroundImage: \"linear-gradient(var(--kit-line-subtle) 1px, transparent 1px), linear-gradient(90deg, var(--kit-line-subtle) 1px, transparent 1px)\", backgroundSize: \"24px 24px\" }}\n />\n <svg className=\"absolute inset-0 size-full text-kit-line-strong\" viewBox=\"0 0 400 112\" preserveAspectRatio=\"none\" aria-hidden>\n <path d=\"M0 76 C80 60 120 100 200 78 S320 40 400 60\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"6\" />\n <path d=\"M140 0 L170 112\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" />\n </svg>\n {shown ? (\n <>\n <div className=\"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-full flex-col items-center\" aria-hidden>\n <span className=\"flex size-7 items-center justify-center rounded-full bg-kit-inverse text-kit-fg-inverse shadow-kit-md\">\n <IconMapPin className=\"size-4\" stroke={1.5} />\n </span>\n <span className=\"size-2 -translate-y-0.5 rotate-45 bg-kit-inverse\" />\n </div>\n <a\n href={`https://www.openstreetmap.org/?mlat=${shown.lat}&mlon=${shown.lng}#map=15/${shown.lat}/${shown.lng}`}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n // D4: V2 (misc.tsx:195) draws the coordinates as a plain chip, no icon; the kit keeps the map link (its\n // accessible name says where it goes) and draws exactly V2's chip\n className=\"tabular-nums absolute bottom-2 right-2 rounded-kit-md bg-kit-surface/90 px-1.5 py-0.5 font-kit-mono text-kit-2xs text-kit-fg-2 shadow-kit-xs hover:text-kit-fg\"\n aria-label={`Open ${shown.lat.toFixed(4)}, ${shown.lng.toFixed(4)} on OpenStreetMap (new tab)`}\n >\n {shown.lat.toFixed(4)}, {shown.lng.toFixed(4)}\n </a>\n </>\n ) : (\n <p className=\"absolute inset-0 flex items-center justify-center text-kit-xs text-kit-fg-3\">No coordinates yet</p>\n )}\n </div>\n <div className=\"flex flex-col gap-2 p-2\">\n <Input\n id={id}\n value={draft.label}\n readOnly={readOnly}\n placeholder=\"Label, e.g. Head office\"\n aria-label={`${field.title} label`}\n leading={<IconMapPin stroke={1.5} />}\n onChange={(e) => update({ label: e.target.value })}\n className={TEXT_FOCUS}\n />\n <div className=\"grid grid-cols-2 gap-2\">\n <Input\n id={`${id}-lat`}\n size=\"sm\"\n inputMode=\"decimal\"\n value={draft.lat}\n readOnly={readOnly}\n aria-label={`${field.title} latitude`}\n aria-invalid={(!result.ok && /latitude/i.test(result.reason)) || undefined}\n aria-describedby={!result.ok ? reasonId : undefined}\n placeholder=\"−90 to 90\"\n onChange={coordinate(\"lat\")}\n leading={<span className=\"text-kit-2xs\">Lat</span>}\n />\n <Input\n id={`${id}-lng`}\n size=\"sm\"\n inputMode=\"decimal\"\n value={draft.lng}\n readOnly={readOnly}\n aria-label={`${field.title} longitude`}\n aria-invalid={(!result.ok && /longitude/i.test(result.reason)) || undefined}\n aria-describedby={!result.ok ? reasonId : undefined}\n placeholder=\"−180 to 180\"\n onChange={coordinate(\"lng\")}\n leading={<span className=\"text-kit-2xs\">Long</span>}\n />\n </div>\n {!result.ok ? (\n <p id={reasonId} role=\"status\" className=\"text-kit-xs text-kit-warning-fg\">\n {result.reason}\n </p>\n ) : null}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,IAAM,OAAO,MAAgB,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAAI,OAAO,CAAC,IAAI;AACvF,IAAM,WAAW,MAAuB,MAAM,CAAC,IAAI;CAAE,KAAK,IAAI,EAA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,UAAU,WAAW,KAAK;MAC1B,SAAS,oBAAC,QAAD;OAAM,WAAU;OAAe,UAAA;MAAS,CAAA;KAClD,CAAA,GACD,oBAAC,OAAD;MACE,IAAI,GAAG,GAAG;MACV,MAAK;MACL,WAAU;MACV,OAAO,MAAM;MACH;MACV,cAAY,GAAG,MAAM,MAAM;MAC3B,gBAAe,CAAC,OAAO,MAAM,aAAa,KAAK,OAAO,MAAM,KAAM,KAAA;MAClE,oBAAkB,CAAC,OAAO,KAAK,WAAW,KAAA;MAC1C,aAAY;MACZ,UAAU,WAAW,KAAK;MAC1B,SAAS,oBAAC,QAAD;OAAM,WAAU;OAAe,UAAA;MAAU,CAAA;KACnD,CAAA,CACE;;IACJ,CAAC,OAAO,KACP,oBAAC,KAAD;KAAG,IAAI;KAAU,MAAK;KAAS,WAAU;KACtC,UAAA,OAAO;IACP,CAAA,IACD;GACD;EACF,CAAA,CAAA;;AAET"}
|
|
1
|
+
{"version":3,"file":"location.js","names":[],"sources":["../../src/controls/location.tsx"],"sourcesContent":["/**\n * LOCATION — the geopoint field (DESIGN 8.21), V2 GeoControl fitted to what prod stores.\n *\n * Value (backend reference-validation `location`, the classic LocationField): `{ lat, lng, label? }`, lat −90…90 and\n * lng −180…180, finite numbers; null when empty. Keys the stored object carries beyond those are kept.\n *\n * A coordinate is written only when it is whole: both numbers, in range. Until then the field says what is missing\n * (\"Add the longitude too\") and keeps the stored value, because the backend refuses half a coordinate. Emptying all\n * three boxes clears the value. Pasting \"44.0582, -121.3153\" into either box fills both.\n *\n * The card above the inputs shows the pin and the coordinates, with a link that opens them on OpenStreetMap; it\n * draws no map tiles (no vendor, key or bundle).\n */\nimport * as React from \"react\";\nimport { IconMapPin } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport type { ControlProps } from \"../types\";\nimport { Input } from \"../ui/input\";\nimport { TEXT_FOCUS } from \"./text\";\n\ninterface Draft {\n lat: string;\n lng: string;\n label: string;\n}\nconst num = (v: unknown) => (typeof v === \"number\" && Number.isFinite(v) ? String(v) : \"\");\nconst draftOf = (v: unknown): Draft => (isObj(v) ? { lat: num(v.lat), lng: num(v.lng), label: typeof v.label === \"string\" ? v.label : \"\" } : { lat: \"\", lng: \"\", label: \"\" });\nconst PAIR = /^\\s*(-?\\d+(?:\\.\\d+)?)\\s*[,;\\s]\\s*(-?\\d+(?:\\.\\d+)?)\\s*$/;\n\n/** The value a draft writes, or the reason it can't be written yet. */\nexport function locationFromDraft(d: Draft, prev: unknown): { ok: true; value: Record<string, unknown> | null } | { ok: false; reason: string } {\n const lat = d.lat.trim();\n const lng = d.lng.trim();\n const label = d.label.trim();\n if (!lat && !lng && !label) return { ok: true, value: null };\n if (!lat || !lng) return { ok: false, reason: !lat && !lng ? \"Add a latitude and a longitude to save this location.\" : !lat ? \"Add the latitude too: a location needs both.\" : \"Add the longitude too: a location needs both.\" };\n const la = Number(lat);\n const lo = Number(lng);\n if (!Number.isFinite(la) || Math.abs(la) > 90) return { ok: false, reason: \"Latitude must be a number from −90 to 90.\" };\n if (!Number.isFinite(lo) || Math.abs(lo) > 180) return { ok: false, reason: \"Longitude must be a number from −180 to 180.\" };\n const out: Record<string, unknown> = { ...(isObj(prev) ? prev : {}), lat: la, lng: lo };\n if (label) out.label = label;\n else delete out.label;\n return { ok: true, value: out };\n}\n\nexport function LocationControl({ field, value, onChange, readOnly, id, invalid }: ControlProps) {\n const [draft, setDraft] = React.useState<Draft>(() => draftOf(value));\n const [seen, setSeen] = React.useState(value);\n const [mine, setMine] = React.useState<unknown>(undefined);\n // a value set from elsewhere (undo, another editor) replaces the draft; our own writes keep what the author typed\n if (value !== seen) {\n setSeen(value);\n if (value !== mine) setDraft(draftOf(value));\n }\n const result = locationFromDraft(draft, value);\n const reasonId = `${id}-reason`;\n\n const update = (patch: Partial<Draft>) => {\n const next = { ...draft, ...patch };\n setDraft(next);\n const r = locationFromDraft(next, value);\n if (!r.ok) return;\n const same = JSON.stringify(r.value) === JSON.stringify(value ?? null);\n if (same) return;\n setMine(r.value);\n onChange(r.value);\n };\n const coordinate = (key: \"lat\" | \"lng\") => (e: React.ChangeEvent<HTMLInputElement>) => {\n const pair = PAIR.exec(e.target.value);\n update(pair ? { lat: pair[1], lng: pair[2] } : ({ [key]: e.target.value } as Partial<Draft>));\n };\n\n const shown = isObj(value) && typeof value.lat === \"number\" && typeof value.lng === \"number\" ? { lat: value.lat, lng: value.lng } : null;\n return (\n <div className={cn(\"overflow-hidden rounded-kit-lg border border-kit-field-border\", invalid && \"border-[var(--kit-field-invalid)]\")}>\n <div className=\"relative h-28 overflow-hidden bg-kit-subtle\">\n {/* V2 `.grid-lines` (styles/index.css:1026), inlined: the dash has no such utility */}\n <div\n className=\"absolute inset-0 opacity-80\"\n style={{ backgroundImage: \"linear-gradient(var(--kit-line-subtle) 1px, transparent 1px), linear-gradient(90deg, var(--kit-line-subtle) 1px, transparent 1px)\", backgroundSize: \"24px 24px\" }}\n />\n <svg className=\"absolute inset-0 size-full text-kit-line-strong\" viewBox=\"0 0 400 112\" preserveAspectRatio=\"none\" aria-hidden>\n <path d=\"M0 76 C80 60 120 100 200 78 S320 40 400 60\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"6\" />\n <path d=\"M140 0 L170 112\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" />\n </svg>\n {shown ? (\n <>\n <div className=\"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-full flex-col items-center\" aria-hidden>\n <span className=\"flex size-7 items-center justify-center rounded-full bg-kit-inverse text-kit-fg-inverse shadow-kit-md\">\n <IconMapPin className=\"size-4\" stroke={1.5} />\n </span>\n <span className=\"size-2 -translate-y-0.5 rotate-45 bg-kit-inverse\" />\n </div>\n <a\n href={`https://www.openstreetmap.org/?mlat=${shown.lat}&mlon=${shown.lng}#map=15/${shown.lat}/${shown.lng}`}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n // D4: V2 (misc.tsx:195) draws the coordinates as a plain chip, no icon; the kit keeps the map link (its\n // accessible name says where it goes) and draws exactly V2's chip\n className=\"tabular-nums absolute bottom-2 right-2 rounded-kit-md bg-kit-surface/90 px-1.5 py-0.5 font-kit-mono text-kit-2xs text-kit-fg-2 shadow-kit-xs hover:text-kit-fg\"\n aria-label={`Open ${shown.lat.toFixed(4)}, ${shown.lng.toFixed(4)} on OpenStreetMap (new tab)`}\n >\n {shown.lat.toFixed(4)}, {shown.lng.toFixed(4)}\n </a>\n </>\n ) : (\n <p className=\"absolute inset-0 flex items-center justify-center text-kit-xs text-kit-fg-3\">No coordinates yet</p>\n )}\n </div>\n <div className=\"flex flex-col gap-2 p-2\">\n <Input\n id={id}\n value={draft.label}\n readOnly={readOnly}\n placeholder=\"Label, e.g. Head office\"\n aria-label={`${field.title} label`}\n leading={<IconMapPin stroke={1.5} />}\n onChange={(e) => update({ label: e.target.value })}\n className={TEXT_FOCUS}\n />\n <div className=\"grid grid-cols-2 gap-2\">\n <Input\n id={`${id}-lat`}\n size=\"sm\"\n inputMode=\"decimal\"\n value={draft.lat}\n readOnly={readOnly}\n aria-label={`${field.title} latitude`}\n aria-invalid={(!result.ok && /latitude/i.test(result.reason)) || undefined}\n aria-describedby={!result.ok ? reasonId : undefined}\n placeholder=\"−90 to 90\"\n onChange={coordinate(\"lat\")}\n leading={<span className=\"text-kit-2xs\">Lat</span>}\n />\n <Input\n id={`${id}-lng`}\n size=\"sm\"\n inputMode=\"decimal\"\n value={draft.lng}\n readOnly={readOnly}\n aria-label={`${field.title} longitude`}\n aria-invalid={(!result.ok && /longitude/i.test(result.reason)) || undefined}\n aria-describedby={!result.ok ? reasonId : undefined}\n placeholder=\"−180 to 180\"\n onChange={coordinate(\"lng\")}\n leading={<span className=\"text-kit-2xs\">Long</span>}\n />\n </div>\n {!result.ok ? (\n <p id={reasonId} role=\"status\" className=\"text-kit-xs text-kit-warning-fg\">\n {result.reason}\n </p>\n ) : null}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;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M;MACH;MACV,cAAY,GAAG,MAAM,MAAM;MAC3B,gBAAe,CAAC,OAAO,MAAM,YAAY,KAAK,OAAO,MAAM,KAAM,KAAA;MACjE,oBAAkB,CAAC,OAAO,KAAK,WAAW,KAAA;MAC1C,aAAY;MACZ,UAAU,WAAW,KAAK;MAC1B,SAAS,oBAAC,QAAD;OAAM,WAAU;OAAe,UAAA;MAAS,CAAA;KAClD,CAAA,GACD,oBAAC,OAAD;MACE,IAAI,GAAG,GAAG;MACV,MAAK;MACL,WAAU;MACV,OAAO,MAAM;MACH;MACV,cAAY,GAAG,MAAM,MAAM;MAC3B,gBAAe,CAAC,OAAO,MAAM,aAAa,KAAK,OAAO,MAAM,KAAM,KAAA;MAClE,oBAAkB,CAAC,OAAO,KAAK,WAAW,KAAA;MAC1C,aAAY;MACZ,UAAU,WAAW,KAAK;MAC1B,SAAS,oBAAC,QAAD;OAAM,WAAU;OAAe,UAAA;MAAU,CAAA;KACnD,CAAA,CACE;;IACJ,CAAC,OAAO,KACP,oBAAC,KAAD;KAAG,IAAI;KAAU,MAAK;KAAS,WAAU;KACtC,UAAA,OAAO;IACP,CAAA,IACD;GACD;EACF,CAAA,CAAA;;AAET"}
|
package/dist/controls/media.js
CHANGED
|
@@ -681,6 +681,7 @@ function ImageControl({ field, value, onChange: write, readOnly, id, path }) {
|
|
|
681
681
|
};
|
|
682
682
|
const [picker, setPicker] = React.useState(false);
|
|
683
683
|
const [details, setDetails] = React.useState(false);
|
|
684
|
+
const [over, setOver] = React.useState(false);
|
|
684
685
|
const up = useUpload(accept, "image", (a) => a[0] && onChange(fromAsset(a[0])));
|
|
685
686
|
const library = s.MediaPicker && !readOnly ? () => setPicker(true) : void 0;
|
|
686
687
|
const known = (s.useSiteIcons ?? NO_ICONS)();
|
|
@@ -797,7 +798,20 @@ function ImageControl({ field, value, onChange: write, readOnly, id, path }) {
|
|
|
797
798
|
/* @__PURE__ */ jsxs("div", {
|
|
798
799
|
"data-slot": "kit-image-frame",
|
|
799
800
|
"data-fit": fit,
|
|
800
|
-
|
|
801
|
+
"data-over": over || void 0,
|
|
802
|
+
onDragOver: up.run && !readOnly ? (e) => {
|
|
803
|
+
if (!e.dataTransfer.types.includes("Files")) return;
|
|
804
|
+
e.preventDefault();
|
|
805
|
+
setOver(true);
|
|
806
|
+
} : void 0,
|
|
807
|
+
onDragLeave: () => setOver(false),
|
|
808
|
+
onDrop: up.run && !readOnly ? (e) => {
|
|
809
|
+
if (!e.dataTransfer.files.length) return;
|
|
810
|
+
e.preventDefault();
|
|
811
|
+
setOver(false);
|
|
812
|
+
up.run(Array.from(e.dataTransfer.files));
|
|
813
|
+
} : void 0,
|
|
814
|
+
className: cn("group/img relative overflow-hidden rounded-kit-lg border border-kit-line", fit === "contain" ? CHECKER : "bg-kit-muted", over && "outline-2 -outline-offset-2 outline-kit-focus-ring [outline-style:dashed]"),
|
|
801
815
|
style: { aspectRatio: frameRatio && frameRatio !== "auto" ? frameRatio : "16/9" },
|
|
802
816
|
children: [
|
|
803
817
|
/* @__PURE__ */ jsx("button", {
|