@adea-ai/ui 0.156.0 → 0.158.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/components/composites/appearance-editor/appearance-editor.d.ts +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.js +305 -172
- package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.d.ts +6 -0
- package/dist/components/composites/appearance-editor/appearance-rows.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.js +2 -2
- package/dist/components/composites/appearance-editor/appearance-rows.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-types.d.ts +26 -0
- package/dist/components/composites/appearance-editor/appearance-types.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-types.js +10 -0
- package/dist/components/composites/appearance-editor/appearance-types.js.map +1 -0
- package/dist/components/composites/appearance-editor/font-settings-group.d.ts +13 -1
- package/dist/components/composites/appearance-editor/font-settings-group.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/font-settings-group.js +51 -15
- package/dist/components/composites/appearance-editor/font-settings-group.js.map +1 -1
- package/dist/components/composites/appearance-editor/index.d.ts +2 -1
- package/dist/components/composites/appearance-editor/index.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/index.js +3 -2
- package/dist/components/theme/theme-document.d.ts +1 -1
- package/dist/components/theme/theme-document.js.map +1 -1
- package/dist/components/theme/theme-provider-value.d.ts +1 -1
- package/dist/components/theme/theme-provider-value.js.map +1 -1
- package/dist/components/ui/button/button.d.ts.map +1 -1
- package/dist/components/ui/button/button.js +3 -3
- package/dist/components/ui/button/button.js.map +1 -1
- package/dist/components/ui/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip/tooltip.js +4 -18
- package/dist/components/ui/tooltip/tooltip.js.map +1 -1
- package/dist/index.js +3 -2
- package/dist/lib/appearance-font-settings.d.ts +18 -4
- package/dist/lib/appearance-font-settings.d.ts.map +1 -1
- package/dist/lib/appearance-font-settings.js +24 -6
- package/dist/lib/appearance-font-settings.js.map +1 -1
- package/dist/lib/fast-icon.d.ts +2 -1
- package/dist/lib/fast-icon.d.ts.map +1 -1
- package/dist/lib/fast-icon.js +4 -3
- package/dist/lib/fast-icon.js.map +1 -1
- package/dist/lib/font-catalog.d.ts +5 -0
- package/dist/lib/font-catalog.d.ts.map +1 -1
- package/dist/lib/font-catalog.js +10 -5
- package/dist/lib/font-catalog.js.map +1 -1
- package/dist/lib/font-zoom.d.ts +1 -1
- package/dist/lib/font-zoom.d.ts.map +1 -1
- package/dist/lib/font-zoom.js +5 -1
- package/dist/lib/font-zoom.js.map +1 -1
- package/dist/lib/theme-defaults.generated.d.ts.map +1 -1
- package/dist/lib/theme-defaults.generated.js +88 -60
- package/dist/lib/theme-defaults.generated.js.map +1 -1
- package/dist/lib/theme-projection.d.ts +2 -0
- package/dist/lib/theme-projection.d.ts.map +1 -1
- package/dist/lib/theme-projection.js +2 -2
- package/dist/lib/theme-projection.js.map +1 -1
- package/dist/lib/theme-types.d.ts +7 -0
- package/dist/lib/theme-types.d.ts.map +1 -1
- package/dist/lib/theme-types.js +7 -0
- package/dist/lib/theme-types.js.map +1 -1
- package/dist/lib/tokens.d.ts.map +1 -1
- package/dist/lib/tokens.js +17 -2
- package/dist/lib/tokens.js.map +1 -1
- package/dist/r/appearance-editor.json +2 -1
- package/dist/r/lib.json +1 -1
- package/dist/r/registry.json +4 -3
- package/dist/r/src/components/composites/appearance-editor/appearance-editor.tsx +202 -110
- package/dist/r/src/components/composites/appearance-editor/appearance-rows.tsx +11 -1
- package/dist/r/src/components/composites/appearance-editor/appearance-types.ts +27 -0
- package/dist/r/src/components/composites/appearance-editor/font-settings-group.tsx +50 -10
- package/dist/r/src/components/composites/appearance-editor/index.ts +3 -0
- package/dist/r/src/components/theme/theme-document.ts +1 -1
- package/dist/r/src/components/theme/theme-provider-value.ts +1 -1
- package/dist/r/src/components/ui/button/button.tsx +12 -3
- package/dist/r/src/components/ui/tooltip/tooltip.tsx +9 -18
- package/dist/r/src/lib/appearance-font-settings.ts +43 -7
- package/dist/r/src/lib/fast-icon.ts +11 -4
- package/dist/r/src/lib/font-catalog.ts +5 -0
- package/dist/r/src/lib/font-zoom.ts +3 -0
- package/dist/r/src/lib/theme-defaults.generated.ts +88 -60
- package/dist/r/src/lib/theme-projection.ts +2 -0
- package/dist/r/src/lib/theme-types.ts +7 -0
- package/dist/r/src/lib/tokens.ts +17 -2
- package/dist/r/src/styles/appearance-font-settings.css +2 -0
- package/dist/r/src/styles/theme-variants.css +608 -370
- package/dist/r/src/styles/theme.css +4 -4
- package/dist/r/theming.json +1 -1
- package/package.json +2 -2
- package/registry.json +4 -3
- package/src/components/composites/appearance-editor/appearance-editor.tsx +202 -110
- package/src/components/composites/appearance-editor/appearance-rows.tsx +11 -1
- package/src/components/composites/appearance-editor/appearance-types.ts +27 -0
- package/src/components/composites/appearance-editor/font-settings-group.tsx +50 -10
- package/src/components/composites/appearance-editor/index.ts +3 -0
- package/src/components/theme/theme-document.ts +1 -1
- package/src/components/theme/theme-provider-value.ts +1 -1
- package/src/components/ui/button/button.tsx +12 -3
- package/src/components/ui/tooltip/tooltip.tsx +9 -18
- package/src/lib/appearance-font-settings.ts +43 -7
- package/src/lib/fast-icon.ts +11 -4
- package/src/lib/font-catalog.ts +5 -0
- package/src/lib/font-zoom.ts +3 -0
- package/src/lib/theme-defaults.generated.ts +88 -60
- package/src/lib/theme-projection.ts +2 -0
- package/src/lib/theme-types.ts +7 -0
- package/src/lib/tokens.ts +17 -2
- package/src/styles/appearance-font-settings.css +2 -0
- package/src/styles/theme-variants.css +608 -370
- package/src/styles/theme.css +4 -4
- package/src/styles/themes/aardvark-blue.css +7 -0
- package/src/styles/themes/aardvark-ink.css +7 -0
- package/src/styles/themes/adea-dark-colorblind.css +22 -15
- package/src/styles/themes/adea-dark-high-contrast.css +22 -15
- package/src/styles/themes/adea-dark.css +22 -15
- package/src/styles/themes/adea-light-colorblind.css +21 -14
- package/src/styles/themes/adea-light-high-contrast.css +21 -14
- package/src/styles/themes/adea-light.css +22 -15
- package/src/styles/themes/ayu-light.css +20 -13
- package/src/styles/themes/ayu-mirage.css +21 -14
- package/src/styles/themes/ayu.css +22 -15
- package/src/styles/themes/catppuccin-frappe.css +16 -9
- package/src/styles/themes/catppuccin-latte.css +15 -8
- package/src/styles/themes/catppuccin-macchiato.css +16 -9
- package/src/styles/themes/catppuccin-mocha.css +16 -9
- package/src/styles/themes/dracula.css +16 -9
- package/src/styles/themes/everforest-dark.css +19 -12
- package/src/styles/themes/everforest-light.css +21 -14
- package/src/styles/themes/gruvbox-dark.css +21 -14
- package/src/styles/themes/gruvbox-light.css +20 -13
- package/src/styles/themes/kanagawa.css +18 -11
- package/src/styles/themes/monokai.css +19 -12
- package/src/styles/themes/nord-light.css +7 -0
- package/src/styles/themes/nord.css +19 -12
- package/src/styles/themes/one-dark.css +16 -9
- package/src/styles/themes/rosepine-dawn.css +19 -12
- package/src/styles/themes/rosepine-moon.css +20 -13
- package/src/styles/themes/rosepine.css +20 -13
- package/src/styles/themes/solarized-dark.css +19 -12
- package/src/styles/themes/solarized-light.css +19 -12
- package/src/styles/themes/tokyonight-day.css +7 -0
- package/src/styles/themes/tokyonight-night.css +18 -11
- package/src/styles/themes/tokyonight-storm.css +18 -11
- package/src/styles/themes/vesper.css +22 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","names":["Tooltip","KobalteTooltip","useTooltipContext","children","resolveChildren","createContext","createEffect","createSignal","createUniqueId","onCleanup","Show","splitProps","useContext","isServer","callHandler","tooltipMotion","tooltipTip","topLayerProps","acquireTooltipFocusGate","releaseTooltipFocusGate","cn","openDelay","closeDelay","skipDelayDuration","tooltipDefaults","TooltipTimingContext","POINTER_CLOSE_INTENT_SLACK_MS","TooltipEscapeTargetContext","element","dismiss","event","ESCAPE_LAYER_SELECTOR","id","trigger","setTrigger","isOpen","isDisabled","isTriggerFocused","markOpenIntent","clearOpenIntent","requestCloseFromAnotherTooltip","markPointerCloseIntent","clearPointerCloseIntent","markCloseIntent","TooltipInteractionContext","openTooltipInteractions","Set","pendingTooltipOpenId","tooltipScrollListenerAttached","clearPendingTooltipOpen","undefined","tooltipScrollContainsTrigger","target","window","Node","contains","handleTooltipScroll","interaction","handleTooltipPointerMove","setTooltipInteractionOpen","open","has","add","addEventListener","document","delete","size","removeEventListener","registerTooltipInteraction","TooltipProvider","props","_$createComponent","Provider","value","timing","local","rest","controlled","uncontrolledOpen","setUncontrolledOpen","defaultOpen","closeIntent","ignoreDuplicateClose","onOpenChange","next","source","pointerCloseIntentUntil","pointerCloseIntentTimeout","setTimeout","clearTimeout","intentWindow","Date","now","queueMicrotask","disabled","Boolean","activeElement","openInteraction","focusedTrigger","anotherTooltipOpening","handleKeyDown","key","_$mergeProps","TooltipTrigger","Trigger","ref","onFocus","defaultPrevented","onBlur","onPointerEnter","onPointerLeave","onClick","Content","icon","TooltipContent","context","escapeTarget","Portal","class","style","_$memo","onEscapeKeyDown","layer","closest","onPointerDownOutside","when","iconSlot","_el$","_tmpl$","_$insert"],"sources":["../../../../src/components/ui/tooltip/tooltip.tsx"],"sourcesContent":["import { Tooltip as KobalteTooltip, useTooltipContext } from '@kobalte/core/tooltip'\nimport type { Accessor, ComponentProps, JSX } from 'solid-js'\nimport {\n children as resolveChildren,\n createContext,\n createEffect,\n createSignal,\n createUniqueId,\n onCleanup,\n Show,\n splitProps,\n useContext,\n} from 'solid-js'\nimport { isServer } from 'solid-js/web'\nimport { callHandler } from '#lib/events'\nimport { tooltipMotion, tooltipTip, topLayerProps } from '#lib/overlay'\nimport { acquireTooltipFocusGate, releaseTooltipFocusGate } from '#lib/tooltip-focus-gate'\nimport { cn } from '#lib/utils'\n\n/**\n * The provider sets the *timing* defaults for every tooltip below it.\n *\n * Timing is the part of a tooltip that has to agree across an app: one that\n * opens in 200ms in a toolbar and 700ms in a sidebar reads as a bug. The\n * provider is where that agreement lives. It is optional — a tooltip outside a\n * provider falls back to the same defaults — so a consumer can drop it in\n * without restructuring anything.\n */\ntype TooltipTiming = {\n openDelay: number\n closeDelay: number\n skipDelayDuration: number\n}\n\nconst tooltipDefaults: TooltipTiming = {\n /** Long enough that a pointer crossing a toolbar does not strobe tooltips. */\n openDelay: 400,\n /** Short, because the pointer has already left the control. */\n closeDelay: 80,\n /**\n * After a tooltip has been seen, the next one opens immediately for this\n * long. This is what makes moving along a row of icons feel like one\n * gesture instead of four separate waits.\n */\n skipDelayDuration: 500,\n}\n\nconst TooltipTimingContext = createContext<TooltipTiming>(tooltipDefaults)\n\n/**\n * How long after a pointer leaves a keyboard-focused trigger its close request\n * still counts as the pointer's: Kobalte reports that close one `closeDelay`\n * later, plus a frame of slack for the timer to fire.\n */\nconst POINTER_CLOSE_INTENT_SLACK_MS = 50\n\n/**\n * The layer a tooltip sits in, when that layer closes on Escape.\n *\n * Kobalte stacks a tooltip's content as the top-most dismissable layer, and\n * only the top-most layer receives Escape — so a tip shown on a focused\n * control inside a dialog took the key the dialog needed, and stayed the top\n * layer for its exit animation. A tip is never a stop for Escape: when it\n * receives the key it closes and passes it on to this layer, provided focus is\n * still inside that layer and in no menu, listbox or popover stacked between\n * them. The layer's own Escape handler runs first and can still keep it open.\n * Dialog-shaped overlays provide it; nothing else needs to.\n */\nexport const TooltipEscapeTargetContext = createContext<{\n element: Accessor<HTMLElement | undefined>\n dismiss: (event: KeyboardEvent) => void\n}>()\n\n/** The layers that take Escape before the dialog-shaped one around them. */\nconst ESCAPE_LAYER_SELECTOR = '[role$=dialog],[role=menu],[role=listbox]'\n\ntype TooltipInteraction = {\n id: string\n trigger: () => HTMLElement | undefined\n setTrigger: (element: HTMLElement) => void\n isOpen: () => boolean\n isDisabled: () => boolean\n isTriggerFocused: () => boolean\n markOpenIntent: () => void\n clearOpenIntent: () => void\n requestCloseFromAnotherTooltip: () => void\n markPointerCloseIntent: () => void\n clearPointerCloseIntent: () => void\n markCloseIntent: () => void\n}\n\nconst TooltipInteractionContext = createContext<TooltipInteraction>()\nconst openTooltipInteractions = new Set<TooltipInteraction>()\nlet pendingTooltipOpenId: string | undefined\nlet tooltipScrollListenerAttached = false\n\nfunction clearPendingTooltipOpen(id: string) {\n if (pendingTooltipOpenId === id) pendingTooltipOpenId = undefined\n}\n\nfunction tooltipScrollContainsTrigger(event: Event, trigger: HTMLElement) {\n const target = event.target\n return target === window || (target instanceof Node && target.contains(trigger))\n}\n\nfunction handleTooltipScroll(event: Event) {\n for (const interaction of openTooltipInteractions) {\n const trigger = interaction.trigger()\n if (interaction.isOpen() && trigger && tooltipScrollContainsTrigger(event, trigger)) {\n interaction.markCloseIntent()\n }\n }\n}\n\nfunction handleTooltipPointerMove(event: PointerEvent) {\n for (const interaction of openTooltipInteractions) {\n const trigger = interaction.trigger()\n const target = event.target\n if (\n interaction.isOpen() &&\n interaction.isTriggerFocused() &&\n trigger &&\n !(target instanceof Node && trigger.contains(target))\n ) {\n interaction.markPointerCloseIntent()\n }\n }\n}\n\nfunction setTooltipInteractionOpen(interaction: TooltipInteraction, open: boolean) {\n if (isServer) return\n\n if (open) {\n if (openTooltipInteractions.has(interaction)) return\n openTooltipInteractions.add(interaction)\n if (!tooltipScrollListenerAttached) {\n tooltipScrollListenerAttached = true\n // Register before Kobalte's global listeners so intentional scroll\n // dismissal can be distinguished from its delayed pointer dismissal.\n window.addEventListener('scroll', handleTooltipScroll, true)\n document.addEventListener('pointermove', handleTooltipPointerMove, true)\n }\n } else {\n openTooltipInteractions.delete(interaction)\n if (openTooltipInteractions.size === 0 && tooltipScrollListenerAttached) {\n tooltipScrollListenerAttached = false\n window.removeEventListener('scroll', handleTooltipScroll, true)\n document.removeEventListener('pointermove', handleTooltipPointerMove, true)\n }\n }\n}\n\nfunction registerTooltipInteraction(interaction: TooltipInteraction) {\n onCleanup(() => {\n setTooltipInteractionOpen(interaction, false)\n clearPendingTooltipOpen(interaction.id)\n })\n}\n\nexport type TooltipProviderProps = {\n children?: ComponentProps<'div'>['children']\n openDelay?: number\n closeDelay?: number\n skipDelayDuration?: number\n}\n\nexport function TooltipProvider(props: TooltipProviderProps) {\n return (\n <TooltipTimingContext.Provider\n value={{\n openDelay: props.openDelay ?? tooltipDefaults.openDelay,\n closeDelay: props.closeDelay ?? tooltipDefaults.closeDelay,\n skipDelayDuration: props.skipDelayDuration ?? tooltipDefaults.skipDelayDuration,\n }}\n >\n {props.children}\n </TooltipTimingContext.Provider>\n )\n}\n\nexport type TooltipRootProps = ComponentProps<typeof KobalteTooltip>\n\nexport function Tooltip(props: TooltipRootProps) {\n // One document-level focus gate for every tooltip in the document: the first\n // tooltip acquires it, the last to unmount releases it. This is what keeps a\n // dialog's autofocus and an overlay's focus restoration from opening a tip —\n // see #lib/tooltip-focus-gate for the contract and the two over-reach traps\n // (pointer gestures and separator resize grips) it must not swallow.\n if (!isServer) {\n acquireTooltipFocusGate()\n onCleanup(releaseTooltipFocusGate)\n }\n const timing = useContext(TooltipTimingContext)\n const [local, rest] = splitProps(props, ['open', 'defaultOpen', 'onOpenChange', 'disabled'])\n const id = createUniqueId()\n const controlled = () => local.open !== undefined\n const [uncontrolledOpen, setUncontrolledOpen] = createSignal(local.defaultOpen ?? false)\n const isOpen = () => (controlled() ? (local.open ?? false) : uncontrolledOpen())\n const [trigger, setTrigger] = createSignal<HTMLElement>()\n let closeIntent = false\n let ignoreDuplicateClose = false\n let onOpenChange: (next: boolean, source?: 'handoff') => void\n let pointerCloseIntentUntil = 0\n let pointerCloseIntentTimeout: ReturnType<typeof setTimeout> | undefined\n const clearPointerCloseIntent = () => {\n pointerCloseIntentUntil = 0\n if (pointerCloseIntentTimeout) clearTimeout(pointerCloseIntentTimeout)\n pointerCloseIntentTimeout = undefined\n }\n const markPointerCloseIntent = () => {\n if (!isOpen()) return\n clearPointerCloseIntent()\n const intentWindow = (props.closeDelay ?? timing.closeDelay) + POINTER_CLOSE_INTENT_SLACK_MS\n pointerCloseIntentUntil = Date.now() + intentWindow\n pointerCloseIntentTimeout = setTimeout(clearPointerCloseIntent, intentWindow)\n }\n const markCloseIntent = () => {\n closeIntent = true\n clearPointerCloseIntent()\n queueMicrotask(() => {\n closeIntent = false\n })\n }\n const requestCloseFromAnotherTooltip = () => {\n if (!isOpen()) return\n\n // Another trigger is an explicit handoff, even when a focused tooltip has\n // a pending pointer-close intent that would otherwise suppress Kobalte's\n // close callback. Route the request through the same controlled/uncontrolled\n // state contract as Kobalte and ignore its duplicate callback for this turn.\n ignoreDuplicateClose = true\n queueMicrotask(() => {\n ignoreDuplicateClose = false\n })\n onOpenChange(false, 'handoff')\n }\n const interaction: TooltipInteraction = {\n id,\n trigger,\n setTrigger,\n isOpen,\n isDisabled: () => local.disabled ?? false,\n isTriggerFocused: () =>\n Boolean(trigger() && typeof document !== 'undefined' && trigger() === document.activeElement),\n markOpenIntent: () => {\n clearPointerCloseIntent()\n pendingTooltipOpenId = id\n // A focused tooltip ignores ordinary pointer movement, but entering or\n // focusing another tooltip is an explicit transfer.\n for (const openInteraction of openTooltipInteractions) {\n if (openInteraction.id !== id) openInteraction.requestCloseFromAnotherTooltip()\n }\n },\n clearOpenIntent: () => clearPendingTooltipOpen(id),\n requestCloseFromAnotherTooltip,\n markPointerCloseIntent,\n clearPointerCloseIntent,\n markCloseIntent,\n }\n registerTooltipInteraction(interaction)\n onCleanup(() => {\n clearPointerCloseIntent()\n ignoreDuplicateClose = false\n })\n if (isOpen()) setTooltipInteractionOpen(interaction, true)\n createEffect(() => setTooltipInteractionOpen(interaction, isOpen()))\n onOpenChange = (next: boolean, source) => {\n if (!next && source !== 'handoff' && ignoreDuplicateClose) return\n\n if (next) {\n clearPendingTooltipOpen(id)\n clearPointerCloseIntent()\n // Install this capture listener before Kobalte's open-state effect adds\n // its scroll listener later in the same update.\n setTooltipInteractionOpen(interaction, true)\n } else {\n const focusedTrigger = interaction.isTriggerFocused()\n const anotherTooltipOpening =\n pendingTooltipOpenId !== undefined && pendingTooltipOpenId !== id\n const pointerClosePending = Date.now() <= pointerCloseIntentUntil\n if (\n source !== 'handoff' &&\n focusedTrigger &&\n pointerClosePending &&\n !closeIntent &&\n !anotherTooltipOpening\n ) {\n clearPointerCloseIntent()\n return\n }\n closeIntent = false\n clearPointerCloseIntent()\n clearPendingTooltipOpen(id)\n }\n\n if (!controlled()) setUncontrolledOpen(next)\n local.onOpenChange?.(next)\n if (next) {\n // A controlled parent can reject the open request without changing its\n // signal, so the effect above would not rerun to release this listener.\n queueMicrotask(() => {\n if (!isOpen()) setTooltipInteractionOpen(interaction, false)\n })\n }\n }\n\n // Kobalte dismisses on Escape only when its content owns the top-most\n // layer, and a handoff keeps the previous tooltip's content mounted while\n // it exits — swallowing the key for the tooltip that just took over.\n // Listening on document (capture) closes this tooltip first; the layer's\n // own handler still runs for anything stacked above it.\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n markCloseIntent()\n onOpenChange(false)\n }\n createEffect(() => {\n if (isServer || !isOpen()) return\n document.addEventListener('keydown', handleKeyDown, true)\n onCleanup(() => document.removeEventListener('keydown', handleKeyDown, true))\n })\n\n return (\n <TooltipInteractionContext.Provider value={interaction}>\n <KobalteTooltip\n open={isOpen()}\n onOpenChange={onOpenChange}\n disabled={local.disabled}\n openDelay={props.openDelay ?? timing.openDelay}\n closeDelay={props.closeDelay ?? timing.closeDelay}\n skipDelayDuration={props.skipDelayDuration ?? timing.skipDelayDuration}\n {...rest}\n />\n </TooltipInteractionContext.Provider>\n )\n}\n\nexport function TooltipTrigger(props: ComponentProps<typeof KobalteTooltip.Trigger>) {\n const interaction = useContext(TooltipInteractionContext)\n const [local, rest] = splitProps(props, [\n 'ref',\n 'onFocus',\n 'onBlur',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onClick',\n ])\n\n return (\n <KobalteTooltip.Trigger\n {...rest}\n ref={(element) => {\n interaction?.setTrigger(element)\n if (typeof local.ref === 'function') local.ref(element)\n }}\n onFocus={(event) => {\n callHandler(local.onFocus, event)\n if (!event.defaultPrevented && !interaction?.isDisabled()) interaction?.markOpenIntent()\n }}\n onBlur={(event) => {\n callHandler(local.onBlur, event)\n interaction?.clearOpenIntent()\n interaction?.markCloseIntent()\n }}\n onPointerEnter={(event) => {\n callHandler(local.onPointerEnter, event)\n if (!event.defaultPrevented && !interaction?.isDisabled()) interaction?.markOpenIntent()\n }}\n onPointerLeave={(event) => {\n callHandler(local.onPointerLeave, event)\n interaction?.clearOpenIntent()\n interaction?.markPointerCloseIntent()\n }}\n onClick={(event) => {\n callHandler(local.onClick, event)\n interaction?.markCloseIntent()\n }}\n />\n )\n}\n\nexport type TooltipContentProps = ComponentProps<typeof KobalteTooltip.Content> & {\n /**\n * A leading icon, repeating the trigger's glyph inside the tip — the side\n * rail's icon+label treatment, offered so a toolbar or rail tooltip does not\n * have to hand-roll it. Decorative by contract: the tip is `aria-hidden`\n * while closed and never the accessible name, so the icon must not be the\n * only carrier of meaning. Size it by leaving the svg bare; the slot fixes\n * it to the system's control size.\n */\n icon?: JSX.Element\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const interaction = useContext(TooltipInteractionContext)\n const [local, rest] = splitProps(props, [\n 'class',\n 'children',\n 'icon',\n 'aria-hidden',\n 'onEscapeKeyDown',\n 'onPointerDownOutside',\n ])\n const context = useTooltipContext()\n const escapeTarget = useContext(TooltipEscapeTargetContext)\n\n // Kobalte keeps force-mounted and exiting content present after close. Hide\n // that retained tooltip from assistive technology until it opens again.\n const icon = resolveChildren(() => local.icon)\n return (\n <KobalteTooltip.Portal>\n <KobalteTooltip.Content\n /* The slot is what base.css's pointer-transparency rule keys on; every\n tip carries it, so no consumer has to remember to pass it. */\n data-slot=\"tooltip-content\"\n class={cn(\n tooltipTip,\n // The max width is a token, not a fixed measure: it has to fall\n // behind the viewport at large root font sizes or the tip — which\n // Kobalte can shift but never shrink — forces a horizontal scroll.\n 'z-(--z-tooltip) w-fit max-w-(--tooltip-max-width) px-3 py-1.5',\n 'origin-(--kb-tooltip-content-transform-origin) text-balance',\n tooltipMotion,\n // An icon+label tip is one row that reads as a unit, so the label\n // never wraps under the glyph.\n { 'flex items-center gap-2 whitespace-nowrap': !!icon() },\n local.class\n )}\n // A tooltip is never interactive: the content is plain text, and the\n // placement draws the tip below its action — where a hit-testing tip\n // would hold the next control hostage, open or departing. Kobalte\n // inlines pointer-events auto, so this is forced after its merge; the\n // pointer belongs to the control underneath.\n style={{ 'pointer-events': 'none' }}\n aria-hidden={context.isOpen() ? local['aria-hidden'] : true}\n onEscapeKeyDown={(event) => {\n local.onEscapeKeyDown?.(event)\n if (event.defaultPrevented) return\n interaction?.markCloseIntent()\n const layer = escapeTarget?.element()\n if (layer && document.activeElement?.closest(ESCAPE_LAYER_SELECTOR) === layer)\n escapeTarget?.dismiss(event)\n }}\n onPointerDownOutside={(event) => {\n local.onPointerDownOutside?.(event)\n if (!event.defaultPrevented) interaction?.markCloseIntent()\n }}\n // A tooltip opened from inside a modal dialog is part of that dialog's\n // surface, so it carries the same top-layer exemption as a menu or a\n // popover — without it the dialog's hide-outside observer aria-hides\n // the tip while it is on screen.\n {...topLayerProps}\n {...rest}\n >\n <Show when={icon()}>\n {(iconSlot) => (\n <span\n data-slot=\"tooltip-icon\"\n aria-hidden=\"true\"\n class=\"flex size-4 shrink-0 items-center justify-center [&_svg]:size-4\"\n >\n {iconSlot()}\n </span>\n )}\n </Show>\n {local.children}\n </KobalteTooltip.Content>\n </KobalteTooltip.Portal>\n )\n}\n"],"mappings":";;;;;;;;;AAkCA,IAAMwB,kBAAiC;;CAErCH,WAAW;;CAEXC,YAAY;;;;;;CAMZC,mBAAmB;AACrB;AAEA,IAAME,uBAAuBpB,cAA6BmB,eAAe;;;;;;AAOzE,IAAME,gCAAgC;;;;;;;;;;;;;AActC,IAAaC,6BAA6BtB,cAGvC;;AAGH,IAAM0B,wBAAwB;AAiB9B,IAAMa,4BAA4BvC,cAAkC;A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,IAAAlH,WAAA;EAAA,OAAAoE,gBACnBtE,QAAe+G,SAAOV,WAAA;GAAA,aAAA;GAAA,KAAA,WAAA;IAAA,OAIdlF,GACLJ,YAIA,iEACA,+DACAD,eAGA,EAAE,6CAA6C,CAAC,CAACkG,KAAK,EAAE,GACxDtC,MAAM2C,KACR;GAAC;GAMDC,OAAO,EAAE,kBAAkB,OAAO;GAAC,KAAA,iBAAA;IAAA,OACtBC,WAAA,CAAA,CAAAL,QAAQhF,OAAO,CAAC,CAAA,CAAA,IAAGwC,MAAM,iBAAiB;GAAI;GAC3D8C,kBAAkB3F,UAAU;IAC1B6C,MAAM8C,kBAAkB3F,KAAK;IAC7B,IAAIA,MAAM6E,kBAAkB;IAC5BlD,aAAad,gBAAgB;IAC7B,MAAM+E,QAAQN,cAAcxF,QAAQ;IACpC,IAAI8F,SAAS1D,SAASgC,eAAe2B,QAAQ5F,qBAAqB,MAAM2F,OACtEN,cAAcvF,QAAQC,KAAK;GAC/B;GACA8F,uBAAuB9F,UAAU;IAC/B6C,MAAMiD,uBAAuB9F,KAAK;IAClC,IAAI,CAACA,MAAM6E,kBAAkBlD,aAAad,gBAAgB;GAC5D;EAAC,GAKG1B,eACA2D,MAAI,EAAA,IAAAzE,WAAA;GAAA,OAAA,CAAAoE,gBAEP7D,MAAI;IAAA,IAACmH,OAAI;KAAA,OAAEZ,KAAK;IAAC;IAAA9G,WACd2H,oBAAQ;KAAA,IAAAC,OAAAC,OAAA;KAAAC,OAAAF,MAMLD,QAAQ;KAAA,OAAAC;IAAA,EAAA,CAAA;GAEZ,CAAA,GAAAP,WAEF7C,MAAMxE,QAAQ,CAAA;EAAA,EAAA,CAAA,CAAA;CAAA,EAAA,CAAA;AAIvB"}
|
|
1
|
+
{"version":3,"file":"tooltip.js","names":["Tooltip","KobalteTooltip","useTooltipContext","children","resolveChildren","createContext","createEffect","createSignal","createUniqueId","onCleanup","Show","splitProps","useContext","isServer","callHandler","tooltipMotion","tooltipTip","topLayerProps","acquireTooltipFocusGate","releaseTooltipFocusGate","cn","openDelay","closeDelay","skipDelayDuration","tooltipDefaults","TooltipTimingContext","TooltipEscapeTargetContext","element","dismiss","event","ESCAPE_LAYER_SELECTOR","id","trigger","setTrigger","isOpen","isDisabled","isTriggerFocused","markOpenIntent","clearOpenIntent","requestCloseFromAnotherTooltip","markPointerCloseIntent","clearPointerCloseIntent","markCloseIntent","TooltipInteractionContext","openTooltipInteractions","Set","pendingTooltipOpenId","tooltipScrollListenerAttached","clearPendingTooltipOpen","undefined","tooltipScrollContainsTrigger","target","window","Node","contains","handleTooltipScroll","interaction","handleTooltipPointerMove","setTooltipInteractionOpen","open","has","add","addEventListener","document","delete","size","removeEventListener","registerTooltipInteraction","TooltipProvider","props","_$createComponent","Provider","value","timing","local","rest","controlled","uncontrolledOpen","setUncontrolledOpen","defaultOpen","closeIntent","ignoreDuplicateClose","onOpenChange","next","source","pointerClosePending","queueMicrotask","disabled","Boolean","activeElement","openInteraction","focusedTrigger","handleKeyDown","key","_$mergeProps","TooltipTrigger","Trigger","ref","onFocus","defaultPrevented","onBlur","onPointerEnter","onPointerLeave","onClick","Content","icon","TooltipContent","context","escapeTarget","Portal","class","style","_$memo","onEscapeKeyDown","layer","closest","onPointerDownOutside","when","iconSlot","_el$","_tmpl$","_$insert"],"sources":["../../../../src/components/ui/tooltip/tooltip.tsx"],"sourcesContent":["import { Tooltip as KobalteTooltip, useTooltipContext } from '@kobalte/core/tooltip'\nimport type { Accessor, ComponentProps, JSX } from 'solid-js'\nimport {\n children as resolveChildren,\n createContext,\n createEffect,\n createSignal,\n createUniqueId,\n onCleanup,\n Show,\n splitProps,\n useContext,\n} from 'solid-js'\nimport { isServer } from 'solid-js/web'\nimport { callHandler } from '#lib/events'\nimport { tooltipMotion, tooltipTip, topLayerProps } from '#lib/overlay'\nimport { acquireTooltipFocusGate, releaseTooltipFocusGate } from '#lib/tooltip-focus-gate'\nimport { cn } from '#lib/utils'\n\n/**\n * The provider sets the *timing* defaults for every tooltip below it.\n *\n * Timing is the part of a tooltip that has to agree across an app: one that\n * opens in 200ms in a toolbar and 700ms in a sidebar reads as a bug. The\n * provider is where that agreement lives. It is optional — a tooltip outside a\n * provider falls back to the same defaults — so a consumer can drop it in\n * without restructuring anything.\n */\ntype TooltipTiming = {\n openDelay: number\n closeDelay: number\n skipDelayDuration: number\n}\n\nconst tooltipDefaults: TooltipTiming = {\n /** Long enough that a pointer crossing a toolbar does not strobe tooltips. */\n openDelay: 400,\n /** Short, because the pointer has already left the control. */\n closeDelay: 80,\n /**\n * After a tooltip has been seen, the next one opens immediately for this\n * long. This is what makes moving along a row of icons feel like one\n * gesture instead of four separate waits.\n */\n skipDelayDuration: 500,\n}\n\nconst TooltipTimingContext = createContext<TooltipTiming>(tooltipDefaults)\n\n/**\n * The layer a tooltip sits in, when that layer closes on Escape.\n *\n * Kobalte stacks a tooltip's content as the top-most dismissable layer, and\n * only the top-most layer receives Escape — so a tip shown on a focused\n * control inside a dialog took the key the dialog needed, and stayed the top\n * layer for its exit animation. A tip is never a stop for Escape: when it\n * receives the key it closes and passes it on to this layer, provided focus is\n * still inside that layer and in no menu, listbox or popover stacked between\n * them. The layer's own Escape handler runs first and can still keep it open.\n * Dialog-shaped overlays provide it; nothing else needs to.\n */\nexport const TooltipEscapeTargetContext = createContext<{\n element: Accessor<HTMLElement | undefined>\n dismiss: (event: KeyboardEvent) => void\n}>()\n\n/** The layers that take Escape before the dialog-shaped one around them. */\nconst ESCAPE_LAYER_SELECTOR = '[role$=dialog],[role=menu],[role=listbox]'\n\ntype TooltipInteraction = {\n id: string\n trigger: () => HTMLElement | undefined\n setTrigger: (element: HTMLElement) => void\n isOpen: () => boolean\n isDisabled: () => boolean\n isTriggerFocused: () => boolean\n markOpenIntent: () => void\n clearOpenIntent: () => void\n requestCloseFromAnotherTooltip: () => void\n markPointerCloseIntent: () => void\n clearPointerCloseIntent: () => void\n markCloseIntent: () => void\n}\n\nconst TooltipInteractionContext = createContext<TooltipInteraction>()\nconst openTooltipInteractions = new Set<TooltipInteraction>()\nlet pendingTooltipOpenId: string | undefined\nlet tooltipScrollListenerAttached = false\n\nfunction clearPendingTooltipOpen(id: string) {\n if (pendingTooltipOpenId === id) pendingTooltipOpenId = undefined\n}\n\nfunction tooltipScrollContainsTrigger(event: Event, trigger: HTMLElement) {\n const target = event.target\n return target === window || (target instanceof Node && target.contains(trigger))\n}\n\nfunction handleTooltipScroll(event: Event) {\n for (const interaction of openTooltipInteractions) {\n const trigger = interaction.trigger()\n if (interaction.isOpen() && trigger && tooltipScrollContainsTrigger(event, trigger)) {\n interaction.markCloseIntent()\n }\n }\n}\n\nfunction handleTooltipPointerMove(event: PointerEvent) {\n for (const interaction of openTooltipInteractions) {\n const trigger = interaction.trigger()\n const target = event.target\n if (\n interaction.isOpen() &&\n interaction.isTriggerFocused() &&\n trigger &&\n !(target instanceof Node && trigger.contains(target))\n ) {\n interaction.markPointerCloseIntent()\n }\n }\n}\n\nfunction setTooltipInteractionOpen(interaction: TooltipInteraction, open: boolean) {\n if (isServer) return\n\n if (open) {\n if (openTooltipInteractions.has(interaction)) return\n openTooltipInteractions.add(interaction)\n if (!tooltipScrollListenerAttached) {\n tooltipScrollListenerAttached = true\n // Register before Kobalte's global listeners so intentional scroll\n // dismissal can be distinguished from its delayed pointer dismissal.\n window.addEventListener('scroll', handleTooltipScroll, true)\n document.addEventListener('pointermove', handleTooltipPointerMove, true)\n }\n } else {\n openTooltipInteractions.delete(interaction)\n if (openTooltipInteractions.size === 0 && tooltipScrollListenerAttached) {\n tooltipScrollListenerAttached = false\n window.removeEventListener('scroll', handleTooltipScroll, true)\n document.removeEventListener('pointermove', handleTooltipPointerMove, true)\n }\n }\n}\n\nfunction registerTooltipInteraction(interaction: TooltipInteraction) {\n onCleanup(() => {\n setTooltipInteractionOpen(interaction, false)\n clearPendingTooltipOpen(interaction.id)\n })\n}\n\nexport type TooltipProviderProps = {\n children?: ComponentProps<'div'>['children']\n openDelay?: number\n closeDelay?: number\n skipDelayDuration?: number\n}\n\nexport function TooltipProvider(props: TooltipProviderProps) {\n return (\n <TooltipTimingContext.Provider\n value={{\n openDelay: props.openDelay ?? tooltipDefaults.openDelay,\n closeDelay: props.closeDelay ?? tooltipDefaults.closeDelay,\n skipDelayDuration: props.skipDelayDuration ?? tooltipDefaults.skipDelayDuration,\n }}\n >\n {props.children}\n </TooltipTimingContext.Provider>\n )\n}\n\nexport type TooltipRootProps = ComponentProps<typeof KobalteTooltip>\n\nexport function Tooltip(props: TooltipRootProps) {\n // One document-level focus gate for every tooltip in the document: the first\n // tooltip acquires it, the last to unmount releases it. This is what keeps a\n // dialog's autofocus and an overlay's focus restoration from opening a tip —\n // see #lib/tooltip-focus-gate for the contract and the two over-reach traps\n // (pointer gestures and separator resize grips) it must not swallow.\n if (!isServer) {\n acquireTooltipFocusGate()\n onCleanup(releaseTooltipFocusGate)\n }\n const timing = useContext(TooltipTimingContext)\n const [local, rest] = splitProps(props, ['open', 'defaultOpen', 'onOpenChange', 'disabled'])\n const id = createUniqueId()\n const controlled = () => local.open !== undefined\n const [uncontrolledOpen, setUncontrolledOpen] = createSignal(local.defaultOpen ?? false)\n const isOpen = () => (controlled() ? (local.open ?? false) : uncontrolledOpen())\n const [trigger, setTrigger] = createSignal<HTMLElement>()\n let closeIntent = false\n let ignoreDuplicateClose = false\n let onOpenChange: (next: boolean, source?: 'handoff') => void\n // Whether the next close Kobalte reports belongs to the pointer having left a\n // trigger that still holds keyboard focus. It is state, not a deadline: Kobalte\n // reports that close one `closeDelay` later on a timer, and a busy event loop\n // can deliver it arbitrarily late, so the request stays the pointer's until it\n // is answered or something explicit (open, blur, click, Escape, scroll, a\n // handoff) takes over.\n let pointerClosePending = false\n const clearPointerCloseIntent = () => {\n pointerClosePending = false\n }\n const markPointerCloseIntent = () => {\n if (isOpen()) pointerClosePending = true\n }\n const markCloseIntent = () => {\n closeIntent = true\n clearPointerCloseIntent()\n queueMicrotask(() => {\n closeIntent = false\n })\n }\n const requestCloseFromAnotherTooltip = () => {\n if (!isOpen()) return\n\n // Another trigger is an explicit handoff, even when a focused tooltip has\n // a pending pointer-close intent that would otherwise suppress Kobalte's\n // close callback. Route the request through the same controlled/uncontrolled\n // state contract as Kobalte and ignore its duplicate callback for this turn.\n ignoreDuplicateClose = true\n queueMicrotask(() => {\n ignoreDuplicateClose = false\n })\n onOpenChange(false, 'handoff')\n }\n const interaction: TooltipInteraction = {\n id,\n trigger,\n setTrigger,\n isOpen,\n isDisabled: () => local.disabled ?? false,\n isTriggerFocused: () =>\n Boolean(trigger() && typeof document !== 'undefined' && trigger() === document.activeElement),\n markOpenIntent: () => {\n clearPointerCloseIntent()\n pendingTooltipOpenId = id\n // A focused tooltip ignores ordinary pointer movement, but entering or\n // focusing another tooltip is an explicit transfer.\n for (const openInteraction of openTooltipInteractions) {\n if (openInteraction.id !== id) openInteraction.requestCloseFromAnotherTooltip()\n }\n },\n clearOpenIntent: () => clearPendingTooltipOpen(id),\n requestCloseFromAnotherTooltip,\n markPointerCloseIntent,\n clearPointerCloseIntent,\n markCloseIntent,\n }\n registerTooltipInteraction(interaction)\n onCleanup(() => {\n clearPointerCloseIntent()\n ignoreDuplicateClose = false\n })\n if (isOpen()) setTooltipInteractionOpen(interaction, true)\n createEffect(() => setTooltipInteractionOpen(interaction, isOpen()))\n onOpenChange = (next: boolean, source) => {\n if (!next && source !== 'handoff' && ignoreDuplicateClose) return\n\n if (next) {\n clearPendingTooltipOpen(id)\n clearPointerCloseIntent()\n // Install this capture listener before Kobalte's open-state effect adds\n // its scroll listener later in the same update.\n setTooltipInteractionOpen(interaction, true)\n } else {\n const focusedTrigger = interaction.isTriggerFocused()\n const anotherTooltipOpening =\n pendingTooltipOpenId !== undefined && pendingTooltipOpenId !== id\n if (\n source !== 'handoff' &&\n focusedTrigger &&\n pointerClosePending &&\n !closeIntent &&\n !anotherTooltipOpening\n ) {\n clearPointerCloseIntent()\n return\n }\n closeIntent = false\n clearPointerCloseIntent()\n clearPendingTooltipOpen(id)\n }\n\n if (!controlled()) setUncontrolledOpen(next)\n local.onOpenChange?.(next)\n if (next) {\n // A controlled parent can reject the open request without changing its\n // signal, so the effect above would not rerun to release this listener.\n queueMicrotask(() => {\n if (!isOpen()) setTooltipInteractionOpen(interaction, false)\n })\n }\n }\n\n // Kobalte dismisses on Escape only when its content owns the top-most\n // layer, and a handoff keeps the previous tooltip's content mounted while\n // it exits — swallowing the key for the tooltip that just took over.\n // Listening on document (capture) closes this tooltip first; the layer's\n // own handler still runs for anything stacked above it.\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n markCloseIntent()\n onOpenChange(false)\n }\n createEffect(() => {\n if (isServer || !isOpen()) return\n document.addEventListener('keydown', handleKeyDown, true)\n onCleanup(() => document.removeEventListener('keydown', handleKeyDown, true))\n })\n\n return (\n <TooltipInteractionContext.Provider value={interaction}>\n <KobalteTooltip\n open={isOpen()}\n onOpenChange={onOpenChange}\n disabled={local.disabled}\n openDelay={props.openDelay ?? timing.openDelay}\n closeDelay={props.closeDelay ?? timing.closeDelay}\n skipDelayDuration={props.skipDelayDuration ?? timing.skipDelayDuration}\n {...rest}\n />\n </TooltipInteractionContext.Provider>\n )\n}\n\nexport function TooltipTrigger(props: ComponentProps<typeof KobalteTooltip.Trigger>) {\n const interaction = useContext(TooltipInteractionContext)\n const [local, rest] = splitProps(props, [\n 'ref',\n 'onFocus',\n 'onBlur',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onClick',\n ])\n\n return (\n <KobalteTooltip.Trigger\n {...rest}\n ref={(element) => {\n interaction?.setTrigger(element)\n if (typeof local.ref === 'function') local.ref(element)\n }}\n onFocus={(event) => {\n callHandler(local.onFocus, event)\n if (!event.defaultPrevented && !interaction?.isDisabled()) interaction?.markOpenIntent()\n }}\n onBlur={(event) => {\n callHandler(local.onBlur, event)\n interaction?.clearOpenIntent()\n interaction?.markCloseIntent()\n }}\n onPointerEnter={(event) => {\n callHandler(local.onPointerEnter, event)\n if (!event.defaultPrevented && !interaction?.isDisabled()) interaction?.markOpenIntent()\n }}\n onPointerLeave={(event) => {\n callHandler(local.onPointerLeave, event)\n interaction?.clearOpenIntent()\n interaction?.markPointerCloseIntent()\n }}\n onClick={(event) => {\n callHandler(local.onClick, event)\n interaction?.markCloseIntent()\n }}\n />\n )\n}\n\nexport type TooltipContentProps = ComponentProps<typeof KobalteTooltip.Content> & {\n /**\n * A leading icon, repeating the trigger's glyph inside the tip — the side\n * rail's icon+label treatment, offered so a toolbar or rail tooltip does not\n * have to hand-roll it. Decorative by contract: the tip is `aria-hidden`\n * while closed and never the accessible name, so the icon must not be the\n * only carrier of meaning. Size it by leaving the svg bare; the slot fixes\n * it to the system's control size.\n */\n icon?: JSX.Element\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const interaction = useContext(TooltipInteractionContext)\n const [local, rest] = splitProps(props, [\n 'class',\n 'children',\n 'icon',\n 'aria-hidden',\n 'onEscapeKeyDown',\n 'onPointerDownOutside',\n ])\n const context = useTooltipContext()\n const escapeTarget = useContext(TooltipEscapeTargetContext)\n\n // Kobalte keeps force-mounted and exiting content present after close. Hide\n // that retained tooltip from assistive technology until it opens again.\n const icon = resolveChildren(() => local.icon)\n return (\n <KobalteTooltip.Portal>\n <KobalteTooltip.Content\n /* The slot is what base.css's pointer-transparency rule keys on; every\n tip carries it, so no consumer has to remember to pass it. */\n data-slot=\"tooltip-content\"\n class={cn(\n tooltipTip,\n // The max width is a token, not a fixed measure: it has to fall\n // behind the viewport at large root font sizes or the tip — which\n // Kobalte can shift but never shrink — forces a horizontal scroll.\n 'z-(--z-tooltip) w-fit max-w-(--tooltip-max-width) px-3 py-1.5',\n 'origin-(--kb-tooltip-content-transform-origin) text-balance',\n tooltipMotion,\n // An icon+label tip is one row that reads as a unit, so the label\n // never wraps under the glyph.\n { 'flex items-center gap-2 whitespace-nowrap': !!icon() },\n local.class\n )}\n // A tooltip is never interactive: the content is plain text, and the\n // placement draws the tip below its action — where a hit-testing tip\n // would hold the next control hostage, open or departing. Kobalte\n // inlines pointer-events auto, so this is forced after its merge; the\n // pointer belongs to the control underneath.\n style={{ 'pointer-events': 'none' }}\n aria-hidden={context.isOpen() ? local['aria-hidden'] : true}\n onEscapeKeyDown={(event) => {\n local.onEscapeKeyDown?.(event)\n if (event.defaultPrevented) return\n interaction?.markCloseIntent()\n const layer = escapeTarget?.element()\n if (layer && document.activeElement?.closest(ESCAPE_LAYER_SELECTOR) === layer)\n escapeTarget?.dismiss(event)\n }}\n onPointerDownOutside={(event) => {\n local.onPointerDownOutside?.(event)\n if (!event.defaultPrevented) interaction?.markCloseIntent()\n }}\n // A tooltip opened from inside a modal dialog is part of that dialog's\n // surface, so it carries the same top-layer exemption as a menu or a\n // popover — without it the dialog's hide-outside observer aria-hides\n // the tip while it is on screen.\n {...topLayerProps}\n {...rest}\n >\n <Show when={icon()}>\n {(iconSlot) => (\n <span\n data-slot=\"tooltip-icon\"\n aria-hidden=\"true\"\n class=\"flex size-4 shrink-0 items-center justify-center [&_svg]:size-4\"\n >\n {iconSlot()}\n </span>\n )}\n </Show>\n {local.children}\n </KobalteTooltip.Content>\n </KobalteTooltip.Portal>\n )\n}\n"],"mappings":";;;;;;;;;AAkCA,IAAMwB,kBAAiC;;CAErCH,WAAW;;CAEXC,YAAY;;;;;;CAMZC,mBAAmB;AACrB;AAEA,IAAME,uBAAuBpB,cAA6BmB,eAAe;;;;;;;;;;;;;AAczE,IAAaE,6BAA6BrB,cAGvC;;AAGH,IAAMyB,wBAAwB;AAiB9B,IAAMa,4BAA4BtC,cAAkC;AACpE,IAAMuC,0CAA0B,IAAIC,IAAwB;AAC5D,IAAIC;AACJ,IAAIC,gCAAgC;AAEpC,SAASC,wBAAwBjB,IAAY;CAC3C,IAAIe,yBAAyBf,IAAIe,uBAAuBG,KAAAA;AAC1D;AAEA,SAASC,6BAA6BrB,OAAcG,SAAsB;CACxE,MAAMmB,SAAStB,MAAMsB;CACrB,OAAOA,WAAWC,UAAWD,kBAAkBE,QAAQ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BAAqB,MAAMoF,OACtEN,cAAchF,QAAQC,KAAK;GAC/B;GACAuF,uBAAuBvF,UAAU;IAC/B6C,MAAM0C,uBAAuBvF,KAAK;IAClC,IAAI,CAACA,MAAMsE,kBAAkB3C,aAAad,gBAAgB;GAC5D;EAAC,GAKGzB,eACA0D,MAAI,EAAA,IAAAxE,WAAA;GAAA,OAAA,CAAAmE,gBAEP5D,MAAI;IAAA,IAAC2G,OAAI;KAAA,OAAEZ,KAAK;IAAC;IAAAtG,WACdmH,oBAAQ;KAAA,IAAAC,OAAAC,OAAA;KAAAC,OAAAF,MAMLD,QAAQ;KAAA,OAAAC;IAAA,EAAA,CAAA;GAEZ,CAAA,GAAAP,WAEFtC,MAAMvE,QAAQ,CAAA;EAAA,EAAA,CAAA,CAAA;CAAA,EAAA,CAAA;AAIvB"}
|
package/dist/index.js
CHANGED
|
@@ -123,7 +123,7 @@ import { defaultDarkThemeId, defaultLightThemeId, resolveVariant } from "./lib/t
|
|
|
123
123
|
import { accentPresets } from "./lib/accent-presets.js";
|
|
124
124
|
import { fontOptions } from "./lib/font-catalog.js";
|
|
125
125
|
import { safeScriptStringLiteral } from "./lib/safe-script.js";
|
|
126
|
-
import { APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, applyAppearanceFontSettings, fontSettingsBootstrapScript, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize } from "./lib/appearance-font-settings.js";
|
|
126
|
+
import { APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, applyAppearanceFontSettings, fontSettingsBootstrapScript, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize, resolveAppearanceEditorFontSettings } from "./lib/appearance-font-settings.js";
|
|
127
127
|
import { AccentSwatchGroups } from "./components/composites/appearance-editor/accent-swatch-groups.js";
|
|
128
128
|
import { AppearanceFontSettingsGroup } from "./components/composites/appearance-editor/font-settings-group.js";
|
|
129
129
|
import { ThemePicker, ThemePreview, ThemeSwatch } from "./components/theme/theme-picker.js";
|
|
@@ -192,6 +192,7 @@ import { SceneControls } from "./components/composites/scene-controls/scene-cont
|
|
|
192
192
|
import { PropertyList, PropertyRow, PropertyTerm, PropertyValue, Stat, StatGroup } from "./components/composites/stat/stat.js";
|
|
193
193
|
import { PalettePreview, ThemeMiniature, ThemeMiniatureSplit } from "./components/composites/appearance-editor/theme-preview.js";
|
|
194
194
|
import { SettingsRow } from "./components/composites/appearance-editor/appearance-rows.js";
|
|
195
|
+
import { APPEARANCE_EDITOR_TABS } from "./components/composites/appearance-editor/appearance-types.js";
|
|
195
196
|
import { AccentPicker, isCustomAccentValue } from "./components/composites/accent-picker/accent-picker.js";
|
|
196
197
|
import { AppearanceEditor, AppearanceEditorActions, AppearancePopover } from "./components/composites/appearance-editor/appearance-editor.js";
|
|
197
198
|
import { writeClipboardText } from "./lib/clipboard.js";
|
|
@@ -208,4 +209,4 @@ import { isShellIconKey, resolveShellIcon, shellIconEntries, shellIconLabel } fr
|
|
|
208
209
|
import { IconPicker, IconPickerDropdown } from "./components/composites/icon-picker/icon-picker.js";
|
|
209
210
|
import { formatBytes, formatReleaseDate, plainTextFromMarkdown } from "./lib/version-notes.js";
|
|
210
211
|
import { allTokens, colorTokens, densityTokens, designTokens, elevationTokens, motionTokens, radiusTokens, typographyTokens, undocumentedTokenAliases, zIndexTokens } from "./lib/tokens.js";
|
|
211
|
-
export { ANSI_MAX_LINE_LENGTH, ANSI_RETAIN_LINES, APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, AboutDialog, AccentPicker, AccentSwatchGroups, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountMenu, ActionButton, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnnotationSurface, AppShell, AppShellBody, AppShellContent, AppShellMain, AppearanceEditor, AppearanceEditorActions, AppearanceFontSettingsGroup, AppearancePanel, AppearancePopover, SettingsRow as AppearanceSettingsRow, AspectRatio, Attachment, AttachmentCard, AttachmentList, Avatar, AvatarFallback, AvatarImage, Badge, Board, BoardCardBody, BoardCardTitle, BoardCardTrigger, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Bubble, BusySendButton, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CHAIN_OF_THOUGHT_STATUS_LABELS, CODE_BLOCK_LINE_LIMIT, CalendarSurface, Callout, CalloutTitle, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CatalogBrowser, CatalogDetail, CatalogDetailSection, ChainOfThought, ChainOfThoughtResult, ChainOfThoughtResults, ChainOfThoughtStep, Chat, ChatComposer, ChatEmpty, ChatHeader, ChatNotice, Checkbox, CheckboxDescription, CheckboxLabel, Checkpoint, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxClear, ComboboxContent, ComboboxControl, ComboboxInput, ComboboxItem, ComboboxSection, ComboboxTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandHint, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut, CommandStatus, ComposerAttachmentButton, ComposerHint, ComposerMenu, ComposerMenuItem, Confirmation, Context, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, ContextualSidebar, ConversationAvatar, ConversationPane, ConversationSurface, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, DatePicker, DetailPanel, DetailPanelBody, DetailPanelField, DetailPanelHeader, DetailPanelSection, Dialog, DialogClose, DialogCloseButton, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffBlock, DiffSummary, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, EntityIcon, FILE_CHANGE_LABELS, FILE_TREE_AUTO_EXPAND_LIMIT, FILE_TREE_MAX_DEPTH, FILE_TREE_MAX_ROWS, FLOATING_PREVIEW_CORNER_RADIUS, FLOATING_PREVIEW_EDGE_GAP, Field, FieldDescription, FieldError, FieldGroup, FieldInput, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTextArea, FileTree, FloatingPreview, FormField, Heading, HelpCenter, HoverCard, HoverCardContent, HoverCardTrigger, IconPicker, IconPickerDropdown, InlineCitation, InlineCode, Input, InputControl, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOtp, InputOtpCaret, Item, ItemDescription, ItemEmpty, ItemGroup, ItemGroupEntry, ItemTitle, Kbd, KbdChord, KbdGroup, Label, LazyTooltip, ListGroup, ListRow, ListRowControl, MARK_IMAGE_MAX_DATA_URL_LENGTH, MARK_IMAGE_MAX_SOURCE_BYTES, MARK_IMAGE_SIZE, MAX_LAYOUT_DEPTH, MAX_LAYOUT_LEAVES, MAX_SPLIT_RATIO, MIN_SPLIT_RATIO, MODEL_SEARCH_THRESHOLD, MarkImageError, Marker, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, Message, MessageAction, MessageActions, MessageBody, MessageComposer, MessageContent, MessageCopyAction, MessageDayDivider, MessageFooter, MessageGroup, MessageHeader, MessageRow, MessageScroller, MessageText, ModalDialog, ModelSelector, Motion, NativeSelect, NavigationMenu, NavigationMenuContent, NavigationMenuGroup, NavigationMenuGroupLabel, NavigationMenuItem, NavigationMenuMenu, NavigationMenuSeparator, NavigationMenuTrigger, NavigationMenuViewport, NumberField, OrbitItem, OrbitLayout, PASTE_THRESHOLD_CHARS, PASTE_THRESHOLD_LINES, PASTE_TOKEN_REGEX, Page, PageHeader, PageHeaderActions, PageHeaderContent, PageHeaderDescription, PageHeaderTitle, PageSection, Pagination, PaginationEllipsis, PaginationItem, PaginationNext, PaginationPrevious, PalettePreview, Panel, PanelActions, PanelBody, PanelCard, PanelDescription, PanelFooter, PanelHeader, PanelPlaceholder, PanelTitle, PanelToolbar, PixelPane, PixelResizeHandle, Plan, Popover, PopoverAnchor, PopoverCloseButton, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, Presence, Progress, PromptInput, PromptInputBody, PromptInputButton, PromptInputControl, PromptInputFooter, PromptInputHeader, PromptInputSubmit, PromptInputTextarea, PromptInputTools, PropertyList, PropertyRow, PropertyTerm, PropertyValue, Questionnaire, Queue, QueueFollowUps, REDUCED_TRANSPARENCY_QUERY, RadioGroup, RadioGroupItem, Reasoning, ResizableHandle, ResizablePanel, ResizablePanelGroup, SOURCE_SNIPPET_LIMIT, SOURCE_TITLE_LIMIT, STACK_MAX_LINES, STACK_TRACE_MAX_BLOCKS, SceneControls, ScrollArea, SecretInputGroup, Select, SelectChevronsUpDown, SelectContent, SelectItem, SelectLabel, SelectSection, SelectTrigger, SelectValue, Separator, SettingsField, SettingsLayout, SettingsNavigation, SettingsPage, SettingsRow$1 as SettingsRow, SettingsSection, Sheet, SheetBody, SheetCloseButton, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, ShellRail, ShellTopBar, SideRail, SideRailButton, SideRailContent, SideRailFooter, SideRailHeader, SideRailItem, SideRailSection, SidebarNav, SidebarNavButton, SidebarNavContent, SidebarNavFooter, SidebarNavHeader, SidebarNavItem, SidebarNavLabel, SidebarNavResizeHandle, SidebarNavRow, SidebarNavSection, SidebarNavTitle, Skeleton, SkipLink, Slider, Sources, Spinner, SplitLayout, StackTrace, Stat, StatGroup, StatusBar, StatusBarItem, StatusBarSpacer, StatusChip, StatusList, Subagent, Suggestion, Suggestions, Switch, SwitchDescription, SwitchLabel, TALL_CODE_BLOCK_PX, TASK_ITEM_STATUS_LABELS, TERMINAL_MAX_LINES, TEST_RESULTS_LIST_LIMIT, TOOL_STATUS_LABELS, TOOL_VALUE_MAX_CHARS, TRACE_STATUS_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableNumericCell, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Task, TaskItemList, TaskItemRow, Terminal, TestResults, Text, TextLink, Textarea, ThemeMiniature, ThemeMiniatureSplit, ThemeModeToggle, ThemePicker, ThemePreview, ThemeProvider, ThemeSwatch, ThemeToggle, ThreadPanel, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tool, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopBar, TopBarBreadcrumb, TopBarPill, TopBarSearch, TopBarSection, TopBarTitle, Trace, TraceDetail, TraceError, TraceLine, TraceMark, TranscriptComposition, Tree, TreeRow, TreeRowActions, TreeStickyHeader, UpdateChannelControl, UpdateDialog, ValueCombobox, VirtualWindow, WORK_STATUS_LABELS, WORK_TRACE_STATUS, WorkspaceMark, WorkspaceReorderDialog, WorkspaceSwitcher, accentPresets, alertVariants, allTokens, ansi256ToColor, ansiLineText, appearancePreviewThemes, applyAppearanceFontSettings, badgeVariants, boardCardTitleVariants, boundText, breakdownRows, bubbleVariants, buildFileTree, builtinThemes, buttonVariants, calloutVariants, captureAnchor, cardVariants, centredSquare, chatNoticeVariants, checkMarkImageFile, checkpointLabel, checkpointStatus, citationLabel, citationName, clampFloatingPreviewPosition, clampSplitRatio, clampWindow, classifyFrame, closePane, cn, colorTokens, computeLayoutFrames, confirmationOutcome, contextLabel, contextLevel, contextLevelWord, contextPercent, contextShort, contrastRatio, controlInteractive, controlSize, controlSizeIcon, controlSizes, countChanges, countLeaves, countLines, createAnsiParser, createAppMenuItems, createDeferredTooltip, createLayoutState, createPoll, createVersionedPersistence, cva, decisionReason, dedentLines, defaultDarkThemeId, defaultLightThemeId, defaultPreferenceStorage, defaultThemeSelection, densityTokens, describeChanges, describeCount, describeFrameGroup, designTokens, diffLineVariants, diffStats, diffTargetPath, editorPaletteFor, elevationTokens, entityIconVariants, expandAll, findModel, findTokenRanges, firstFailureKey, flattenFileTree, focusPane, fontOptions, fontSettingsBootstrapScript, fontZoomShortcut, formatAttachmentSize, formatBytes, formatCost, formatDuration, formatExact, formatReleaseDate, formatDuration$1 as formatTestDuration, formatToken, formatTokens, formatToolValue, frameLocation, groupModels, groupStackEntries, hasContextFigures, headingElement, headingVariants, indexFileTree, initialExpanded, initialsFrom, safeScriptStringLiteral as inlineScriptLiteral, isAwaitingAnswer, isCustomAccent, isCustomAccentValue, isFailedExit, isFigure, isMarkImageDataUrl, isPasteBlock, isPlainStyle, isQuestionAnswered, isShellIconKey, isThemeAccentId, itemVariants, kbdChordKeys, kbdGroupVariants, kbdVariants, keyedRows, layoutDepth, listLeaves, listedCounts, localStoragePersistence, markImageFromFile, markImageProblemCopy, markerVariants, messageCitations, modelSearchValue, monogram, motionTokens, movePane, moveTarget, moveWorkspace, nearestAnsiColor, needsSearch, neighborLeaf, nextCitationMode, nextSeq, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize, normalizeCustomAccent, normalizeEfforts, normalizeLayout, normalizePath, normalizeSurface, paintAccentRoles, parseAnsi, parseDiff, parseInline, parseMessageText, parseMessageTextIncremental, parseStackTrace, partitionQueue, placeCitationMarkers, plainTextFromMarkdown, platformModifierKey, pruneBlocks, quarantineRecord, radiusTokens, readLegacyValue, readVersionedRecord, reasoningTitle, recollapsePastes, reconcileCounts, recoveryEnvelope, recoveryKeyFor, remapCarriedBlocks, resizeFloatingPreview, resizeSplit, resolveAccentPreset, resolveAccentRoles, resolveColors, resolveEffort, resolveFloatingPreviewFrame, resolveShellIcon, resolveSurface, resolveSurfaceState, resolveVariant, resolvedDensity, restoreAnchor, restoreControl, restoreDialogCopy, revealInWindow, safeHref, safePreviewSrc, safeSourceUrl, searchShortcutKeyshortcuts, searchShortcutLabel, settleDecision, sheetVariants, shellIconEntries, shellIconLabel, shouldCollapse, sidebarNavItemClass, sidebarNavItemStateClass, sourceHost, sourceTitle, sourcesLabel, splitLocation, splitPane, splitPaneBalanced, statusDotVariants, stepAppearanceFontSizes, stepCountLabel, stripTrailingBlankLines, suiteKey, suiteState, surfaceAlpha, surfaceInteractive, swapPanes, taskProgress, taskProgressLabel, terminalCssVariables, terminalStatusLabel, testKey, textElement, textVariants, textareaVariants, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themeScript, themeSurfaces, themesForAppearance, toast, toaster, toggleVariants, tokenRangeAt, tokensAsHex, transcriptDisclosureKey, treeStickyAncestors, typeaheadIndex, typographyTokens, undoClosePane, undocumentedTokenAliases, useOptionalTheme, useSideRail, useTheme, validateTheme, validateThemeRegistry, variantFromRecord, withAccent, wrapIndex, writeClipboardText, writeVersionedRecord, zIndexTokens };
|
|
212
|
+
export { ANSI_MAX_LINE_LENGTH, ANSI_RETAIN_LINES, APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, APPEARANCE_EDITOR_TABS, AboutDialog, AccentPicker, AccentSwatchGroups, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountMenu, ActionButton, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnnotationSurface, AppShell, AppShellBody, AppShellContent, AppShellMain, AppearanceEditor, AppearanceEditorActions, AppearanceFontSettingsGroup, AppearancePanel, AppearancePopover, SettingsRow as AppearanceSettingsRow, AspectRatio, Attachment, AttachmentCard, AttachmentList, Avatar, AvatarFallback, AvatarImage, Badge, Board, BoardCardBody, BoardCardTitle, BoardCardTrigger, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Bubble, BusySendButton, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CHAIN_OF_THOUGHT_STATUS_LABELS, CODE_BLOCK_LINE_LIMIT, CalendarSurface, Callout, CalloutTitle, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CatalogBrowser, CatalogDetail, CatalogDetailSection, ChainOfThought, ChainOfThoughtResult, ChainOfThoughtResults, ChainOfThoughtStep, Chat, ChatComposer, ChatEmpty, ChatHeader, ChatNotice, Checkbox, CheckboxDescription, CheckboxLabel, Checkpoint, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxClear, ComboboxContent, ComboboxControl, ComboboxInput, ComboboxItem, ComboboxSection, ComboboxTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandHint, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut, CommandStatus, ComposerAttachmentButton, ComposerHint, ComposerMenu, ComposerMenuItem, Confirmation, Context, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, ContextualSidebar, ConversationAvatar, ConversationPane, ConversationSurface, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, DatePicker, DetailPanel, DetailPanelBody, DetailPanelField, DetailPanelHeader, DetailPanelSection, Dialog, DialogClose, DialogCloseButton, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffBlock, DiffSummary, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, EntityIcon, FILE_CHANGE_LABELS, FILE_TREE_AUTO_EXPAND_LIMIT, FILE_TREE_MAX_DEPTH, FILE_TREE_MAX_ROWS, FLOATING_PREVIEW_CORNER_RADIUS, FLOATING_PREVIEW_EDGE_GAP, Field, FieldDescription, FieldError, FieldGroup, FieldInput, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTextArea, FileTree, FloatingPreview, FormField, Heading, HelpCenter, HoverCard, HoverCardContent, HoverCardTrigger, IconPicker, IconPickerDropdown, InlineCitation, InlineCode, Input, InputControl, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOtp, InputOtpCaret, Item, ItemDescription, ItemEmpty, ItemGroup, ItemGroupEntry, ItemTitle, Kbd, KbdChord, KbdGroup, Label, LazyTooltip, ListGroup, ListRow, ListRowControl, MARK_IMAGE_MAX_DATA_URL_LENGTH, MARK_IMAGE_MAX_SOURCE_BYTES, MARK_IMAGE_SIZE, MAX_LAYOUT_DEPTH, MAX_LAYOUT_LEAVES, MAX_SPLIT_RATIO, MIN_SPLIT_RATIO, MODEL_SEARCH_THRESHOLD, MarkImageError, Marker, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, Message, MessageAction, MessageActions, MessageBody, MessageComposer, MessageContent, MessageCopyAction, MessageDayDivider, MessageFooter, MessageGroup, MessageHeader, MessageRow, MessageScroller, MessageText, ModalDialog, ModelSelector, Motion, NativeSelect, NavigationMenu, NavigationMenuContent, NavigationMenuGroup, NavigationMenuGroupLabel, NavigationMenuItem, NavigationMenuMenu, NavigationMenuSeparator, NavigationMenuTrigger, NavigationMenuViewport, NumberField, OrbitItem, OrbitLayout, PASTE_THRESHOLD_CHARS, PASTE_THRESHOLD_LINES, PASTE_TOKEN_REGEX, Page, PageHeader, PageHeaderActions, PageHeaderContent, PageHeaderDescription, PageHeaderTitle, PageSection, Pagination, PaginationEllipsis, PaginationItem, PaginationNext, PaginationPrevious, PalettePreview, Panel, PanelActions, PanelBody, PanelCard, PanelDescription, PanelFooter, PanelHeader, PanelPlaceholder, PanelTitle, PanelToolbar, PixelPane, PixelResizeHandle, Plan, Popover, PopoverAnchor, PopoverCloseButton, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, Presence, Progress, PromptInput, PromptInputBody, PromptInputButton, PromptInputControl, PromptInputFooter, PromptInputHeader, PromptInputSubmit, PromptInputTextarea, PromptInputTools, PropertyList, PropertyRow, PropertyTerm, PropertyValue, Questionnaire, Queue, QueueFollowUps, REDUCED_TRANSPARENCY_QUERY, RadioGroup, RadioGroupItem, Reasoning, ResizableHandle, ResizablePanel, ResizablePanelGroup, SOURCE_SNIPPET_LIMIT, SOURCE_TITLE_LIMIT, STACK_MAX_LINES, STACK_TRACE_MAX_BLOCKS, SceneControls, ScrollArea, SecretInputGroup, Select, SelectChevronsUpDown, SelectContent, SelectItem, SelectLabel, SelectSection, SelectTrigger, SelectValue, Separator, SettingsField, SettingsLayout, SettingsNavigation, SettingsPage, SettingsRow$1 as SettingsRow, SettingsSection, Sheet, SheetBody, SheetCloseButton, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, ShellRail, ShellTopBar, SideRail, SideRailButton, SideRailContent, SideRailFooter, SideRailHeader, SideRailItem, SideRailSection, SidebarNav, SidebarNavButton, SidebarNavContent, SidebarNavFooter, SidebarNavHeader, SidebarNavItem, SidebarNavLabel, SidebarNavResizeHandle, SidebarNavRow, SidebarNavSection, SidebarNavTitle, Skeleton, SkipLink, Slider, Sources, Spinner, SplitLayout, StackTrace, Stat, StatGroup, StatusBar, StatusBarItem, StatusBarSpacer, StatusChip, StatusList, Subagent, Suggestion, Suggestions, Switch, SwitchDescription, SwitchLabel, TALL_CODE_BLOCK_PX, TASK_ITEM_STATUS_LABELS, TERMINAL_MAX_LINES, TEST_RESULTS_LIST_LIMIT, TOOL_STATUS_LABELS, TOOL_VALUE_MAX_CHARS, TRACE_STATUS_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableNumericCell, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Task, TaskItemList, TaskItemRow, Terminal, TestResults, Text, TextLink, Textarea, ThemeMiniature, ThemeMiniatureSplit, ThemeModeToggle, ThemePicker, ThemePreview, ThemeProvider, ThemeSwatch, ThemeToggle, ThreadPanel, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tool, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopBar, TopBarBreadcrumb, TopBarPill, TopBarSearch, TopBarSection, TopBarTitle, Trace, TraceDetail, TraceError, TraceLine, TraceMark, TranscriptComposition, Tree, TreeRow, TreeRowActions, TreeStickyHeader, UpdateChannelControl, UpdateDialog, ValueCombobox, VirtualWindow, WORK_STATUS_LABELS, WORK_TRACE_STATUS, WorkspaceMark, WorkspaceReorderDialog, WorkspaceSwitcher, accentPresets, alertVariants, allTokens, ansi256ToColor, ansiLineText, appearancePreviewThemes, applyAppearanceFontSettings, badgeVariants, boardCardTitleVariants, boundText, breakdownRows, bubbleVariants, buildFileTree, builtinThemes, buttonVariants, calloutVariants, captureAnchor, cardVariants, centredSquare, chatNoticeVariants, checkMarkImageFile, checkpointLabel, checkpointStatus, citationLabel, citationName, clampFloatingPreviewPosition, clampSplitRatio, clampWindow, classifyFrame, closePane, cn, colorTokens, computeLayoutFrames, confirmationOutcome, contextLabel, contextLevel, contextLevelWord, contextPercent, contextShort, contrastRatio, controlInteractive, controlSize, controlSizeIcon, controlSizes, countChanges, countLeaves, countLines, createAnsiParser, createAppMenuItems, createDeferredTooltip, createLayoutState, createPoll, createVersionedPersistence, cva, decisionReason, dedentLines, defaultDarkThemeId, defaultLightThemeId, defaultPreferenceStorage, defaultThemeSelection, densityTokens, describeChanges, describeCount, describeFrameGroup, designTokens, diffLineVariants, diffStats, diffTargetPath, editorPaletteFor, elevationTokens, entityIconVariants, expandAll, findModel, findTokenRanges, firstFailureKey, flattenFileTree, focusPane, fontOptions, fontSettingsBootstrapScript, fontZoomShortcut, formatAttachmentSize, formatBytes, formatCost, formatDuration, formatExact, formatReleaseDate, formatDuration$1 as formatTestDuration, formatToken, formatTokens, formatToolValue, frameLocation, groupModels, groupStackEntries, hasContextFigures, headingElement, headingVariants, indexFileTree, initialExpanded, initialsFrom, safeScriptStringLiteral as inlineScriptLiteral, isAwaitingAnswer, isCustomAccent, isCustomAccentValue, isFailedExit, isFigure, isMarkImageDataUrl, isPasteBlock, isPlainStyle, isQuestionAnswered, isShellIconKey, isThemeAccentId, itemVariants, kbdChordKeys, kbdGroupVariants, kbdVariants, keyedRows, layoutDepth, listLeaves, listedCounts, localStoragePersistence, markImageFromFile, markImageProblemCopy, markerVariants, messageCitations, modelSearchValue, monogram, motionTokens, movePane, moveTarget, moveWorkspace, nearestAnsiColor, needsSearch, neighborLeaf, nextCitationMode, nextSeq, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize, normalizeCustomAccent, normalizeEfforts, normalizeLayout, normalizePath, normalizeSurface, paintAccentRoles, parseAnsi, parseDiff, parseInline, parseMessageText, parseMessageTextIncremental, parseStackTrace, partitionQueue, placeCitationMarkers, plainTextFromMarkdown, platformModifierKey, pruneBlocks, quarantineRecord, radiusTokens, readLegacyValue, readVersionedRecord, reasoningTitle, recollapsePastes, reconcileCounts, recoveryEnvelope, recoveryKeyFor, remapCarriedBlocks, resizeFloatingPreview, resizeSplit, resolveAccentPreset, resolveAccentRoles, resolveAppearanceEditorFontSettings, resolveColors, resolveEffort, resolveFloatingPreviewFrame, resolveShellIcon, resolveSurface, resolveSurfaceState, resolveVariant, resolvedDensity, restoreAnchor, restoreControl, restoreDialogCopy, revealInWindow, safeHref, safePreviewSrc, safeSourceUrl, searchShortcutKeyshortcuts, searchShortcutLabel, settleDecision, sheetVariants, shellIconEntries, shellIconLabel, shouldCollapse, sidebarNavItemClass, sidebarNavItemStateClass, sourceHost, sourceTitle, sourcesLabel, splitLocation, splitPane, splitPaneBalanced, statusDotVariants, stepAppearanceFontSizes, stepCountLabel, stripTrailingBlankLines, suiteKey, suiteState, surfaceAlpha, surfaceInteractive, swapPanes, taskProgress, taskProgressLabel, terminalCssVariables, terminalStatusLabel, testKey, textElement, textVariants, textareaVariants, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themeScript, themeSurfaces, themesForAppearance, toast, toaster, toggleVariants, tokenRangeAt, tokensAsHex, transcriptDisclosureKey, treeStickyAncestors, typeaheadIndex, typographyTokens, undoClosePane, undocumentedTokenAliases, useOptionalTheme, useSideRail, useTheme, validateTheme, validateThemeRegistry, variantFromRecord, withAccent, wrapIndex, writeClipboardText, writeVersionedRecord, zIndexTokens };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FontOption } from '#lib/font-catalog';
|
|
2
|
-
export declare const APPEARANCE_EDITOR_FONT_AXES: readonly ['ui', 'content', 'code'];
|
|
2
|
+
export declare const APPEARANCE_EDITOR_FONT_AXES: readonly ['ui', 'content', 'code', 'terminal'];
|
|
3
3
|
export type AppearanceEditorFontAxis = (typeof APPEARANCE_EDITOR_FONT_AXES)[number];
|
|
4
4
|
export type AppearanceEditorFontFamilyId = FontOption['id'];
|
|
5
5
|
export type AppearanceEditorFontSetting = Readonly<{
|
|
@@ -8,12 +8,24 @@ export type AppearanceEditorFontSetting = Readonly<{
|
|
|
8
8
|
/** A pixel size, normalized to the supported range. */
|
|
9
9
|
size: number;
|
|
10
10
|
}>;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The host-owned choices edited by the shared appearance composition.
|
|
13
|
+
*
|
|
14
|
+
* `terminal` is optional in what a host stores: a record written before the
|
|
15
|
+
* terminal had its own axis, or by a host that never offers one, follows the
|
|
16
|
+
* Code axis. Normalization keeps it absent, so such a record is stored as it was.
|
|
17
|
+
*/
|
|
18
|
+
export type AppearanceEditorFontSettings = Readonly<Record<Exclude<AppearanceEditorFontAxis, 'terminal'>, AppearanceEditorFontSetting> & {
|
|
19
|
+
terminal?: AppearanceEditorFontSetting;
|
|
20
|
+
}>;
|
|
21
|
+
/** Font settings with every axis resolved (`resolveAppearanceEditorFontSettings`). */
|
|
22
|
+
export type ResolvedAppearanceEditorFontSettings = Readonly<Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>>;
|
|
13
23
|
export declare const APPEARANCE_EDITOR_FONT_SIZE_MIN = 10;
|
|
14
24
|
export declare const APPEARANCE_EDITOR_FONT_SIZE_MAX = 32;
|
|
15
25
|
/** New preferences use the platform face in each text role. */
|
|
16
26
|
export declare const DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS: AppearanceEditorFontSettings;
|
|
27
|
+
/** Every axis with a value: the terminal follows Code until it is given its own. */
|
|
28
|
+
export declare function resolveAppearanceEditorFontSettings(settings: AppearanceEditorFontSettings): ResolvedAppearanceEditorFontSettings;
|
|
17
29
|
export type NormalizedAppearanceEditorFontSettings = Readonly<{
|
|
18
30
|
settings: AppearanceEditorFontSettings;
|
|
19
31
|
/** Axes whose persisted family or size was unavailable or outside its limits. */
|
|
@@ -24,6 +36,8 @@ export declare function normalizeAppearanceEditorFontSize(value: unknown, fallba
|
|
|
24
36
|
/**
|
|
25
37
|
* Recover persisted font choices against the shared font catalogue.
|
|
26
38
|
*
|
|
39
|
+
* A record with no `terminal` axis is returned without one: it follows Code.
|
|
40
|
+
*
|
|
27
41
|
* `legacyUiFamily` lets a host migrate its previous single font field into the
|
|
28
42
|
* UI axis. Content and code remain on the new System defaults during that
|
|
29
43
|
* migration. Missing settings are ordinary defaults; an unknown saved id or an
|
|
@@ -35,7 +49,7 @@ export declare function normalizeAppearanceEditorFontSettings(value: unknown, le
|
|
|
35
49
|
*
|
|
36
50
|
* This is shared by `ThemeProvider` and hosts that own their own appearance
|
|
37
51
|
* persistence, so UI/content/code use the same catalogue ids, theme tokens,
|
|
38
|
-
* sizes, and projected CSS variables. The marker activates the optional role
|
|
52
|
+
* sizes, and projected CSS variables (terminal included). The marker activates the optional role
|
|
39
53
|
* stylesheet and survives CSS import reordering.
|
|
40
54
|
*/
|
|
41
55
|
export declare function applyAppearanceFontSettings(root: Pick<HTMLElement, 'removeAttribute' | 'setAttribute' | 'style'>, value: unknown): NormalizedAppearanceEditorFontSettings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance-font-settings.d.ts","sourceRoot":"","sources":["../../src/lib/appearance-font-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGjF,eAAO,MAAM,2BAA2B,YAAI,IAAI,EAAE,SAAS,EAAE,MAAM,CAA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AAC,CAAA;AAqEF,oFAAoF;AACpF,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ1F;AAED;;;;;;;;;GASG;AACH,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,OAAO,EACd,cAAc,CAAC,EAAE,OAAO,GACvB,sCAAsC,CAoDxC;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,iBAAiB,GAAG,cAAc,GAAG,OAAO,CAAC,EACrE,KAAK,EAAE,OAAO,GACb,sCAAsC,CAiCxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAajG"}
|
|
@@ -4,7 +4,8 @@ import { safeScriptStringLiteral } from "./safe-script.js";
|
|
|
4
4
|
var APPEARANCE_EDITOR_FONT_AXES = [
|
|
5
5
|
"ui",
|
|
6
6
|
"content",
|
|
7
|
-
"code"
|
|
7
|
+
"code",
|
|
8
|
+
"terminal"
|
|
8
9
|
];
|
|
9
10
|
var APPEARANCE_EDITOR_FONT_SIZE_MIN = 10;
|
|
10
11
|
var APPEARANCE_EDITOR_FONT_SIZE_MAX = 32;
|
|
@@ -23,6 +24,13 @@ var DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS = Object.freeze({
|
|
|
23
24
|
size: 12
|
|
24
25
|
})
|
|
25
26
|
});
|
|
27
|
+
/** Every axis with a value: the terminal follows Code until it is given its own. */
|
|
28
|
+
function resolveAppearanceEditorFontSettings(settings) {
|
|
29
|
+
return settings.terminal ? settings : {
|
|
30
|
+
...settings,
|
|
31
|
+
terminal: settings.code
|
|
32
|
+
};
|
|
33
|
+
}
|
|
26
34
|
var fontProjectionById = Object.freeze(Object.fromEntries(fontOptions.map((option) => [option.id, {
|
|
27
35
|
familyVariables: option.familyVariables,
|
|
28
36
|
uiTracking: option.uiTracking,
|
|
@@ -49,6 +57,13 @@ var fontAxisProjection = Object.freeze({
|
|
|
49
57
|
sizeProperty: "--font-code-size",
|
|
50
58
|
scaleProperty: "--font-code-scale",
|
|
51
59
|
defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size
|
|
60
|
+
}),
|
|
61
|
+
terminal: Object.freeze({
|
|
62
|
+
familyAttribute: "data-terminal-font",
|
|
63
|
+
familyProperty: "--font-terminal",
|
|
64
|
+
sizeProperty: "--font-terminal-size",
|
|
65
|
+
scaleProperty: "--font-terminal-scale",
|
|
66
|
+
defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size
|
|
52
67
|
})
|
|
53
68
|
});
|
|
54
69
|
function isRecord(value) {
|
|
@@ -71,6 +86,8 @@ function normalizeAppearanceEditorFontSize(value, fallback) {
|
|
|
71
86
|
/**
|
|
72
87
|
* Recover persisted font choices against the shared font catalogue.
|
|
73
88
|
*
|
|
89
|
+
* A record with no `terminal` axis is returned without one: it follows Code.
|
|
90
|
+
*
|
|
74
91
|
* `legacyUiFamily` lets a host migrate its previous single font field into the
|
|
75
92
|
* UI axis. Content and code remain on the new System defaults during that
|
|
76
93
|
* migration. Missing settings are ordinary defaults; an unknown saved id or an
|
|
@@ -85,7 +102,8 @@ function normalizeAppearanceEditorFontSettings(value, legacyUiFamily) {
|
|
|
85
102
|
const axisPresent = source ? hasOwn(source, axis) : false;
|
|
86
103
|
const axisValue = source?.[axis];
|
|
87
104
|
const axisSource = isRecord(axisValue) ? axisValue : void 0;
|
|
88
|
-
|
|
105
|
+
if (axis === "terminal" && !axisPresent) continue;
|
|
106
|
+
const fallback = DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS[axis === "terminal" ? "code" : axis];
|
|
89
107
|
if (malformedRoot || axisPresent && axisSource === void 0) recovered.add(axis);
|
|
90
108
|
const hasFamily = axisSource ? hasOwn(axisSource, "family") : false;
|
|
91
109
|
const familyInput = hasFamily ? axisSource?.["family"] : axis === "ui" && legacyUiFamily !== void 0 ? legacyUiFamily : void 0;
|
|
@@ -110,12 +128,12 @@ function normalizeAppearanceEditorFontSettings(value, legacyUiFamily) {
|
|
|
110
128
|
*
|
|
111
129
|
* This is shared by `ThemeProvider` and hosts that own their own appearance
|
|
112
130
|
* persistence, so UI/content/code use the same catalogue ids, theme tokens,
|
|
113
|
-
* sizes, and projected CSS variables. The marker activates the optional role
|
|
131
|
+
* sizes, and projected CSS variables (terminal included). The marker activates the optional role
|
|
114
132
|
* stylesheet and survives CSS import reordering.
|
|
115
133
|
*/
|
|
116
134
|
function applyAppearanceFontSettings(root, value) {
|
|
117
135
|
const normalized = normalizeAppearanceEditorFontSettings(value);
|
|
118
|
-
const
|
|
136
|
+
const settings = resolveAppearanceEditorFontSettings(normalized.settings);
|
|
119
137
|
const readAttribute = root.getAttribute;
|
|
120
138
|
const setAttribute = (name, next) => {
|
|
121
139
|
if (readAttribute?.call(root, name) !== next) root.setAttribute(name, next);
|
|
@@ -158,8 +176,8 @@ function fontSettingsBootstrapScript(storageKey, persistedVersion) {
|
|
|
158
176
|
const fontProjection = JSON.stringify(fontProjectionById);
|
|
159
177
|
const fontIds = `[${fontOptions.map((option) => safeScriptStringLiteral(option.id)).join(",")}]`;
|
|
160
178
|
const persistedVersionGuard = persistedVersion === void 0 ? "" : `&&parsed.version===Number(${safeScriptStringLiteral(String(persistedVersion))})`;
|
|
161
|
-
return `(function(){var r=document.documentElement;var axes=JSON.parse(${safeScriptStringLiteral(axisConfig)});var projection=JSON.parse(${safeScriptStringLiteral(fontProjection)});var ids=${fontIds};var has=function(v,k){return Object.prototype.hasOwnProperty.call(v,k)};var record=function(v){return typeof v==='object'&&v!==null&&!Array.isArray(v)};var p={};try{var raw=localStorage.getItem(${safeScriptStringLiteral(storageKey)});var parsed=raw?JSON.parse(raw):{};if(record(parsed)${persistedVersionGuard})p=parsed;}catch(e){}var saved=record(p.fonts)?p.fonts:{};var valid=function(v,d){return ids.indexOf(v)!==-1?v:d};var size=function(v,d){var n=typeof v==='number'?v:typeof v==='string'&&v.trim()!==''?Number(v):NaN;return Number.isFinite(n)?Math.min(32,Math.max(10,Math.round(n))):d};r.setAttribute('data-font-settings','');for(var axis in axes){if(!has(axes,axis))continue;var spec=axes[axis];var candidate=saved[axis];var value=record(candidate)?candidate:{};var legacyUi=axis==='ui'&&!has(value,'family');var family=legacyUi?valid(p.font,'system'):valid(value.family,'system');var font=projection[family];if(family==='system')r.removeAttribute(spec.familyAttribute);else r.setAttribute(spec.familyAttribute,family);r.style.setProperty(spec.familyProperty,'var('+font.familyVariables[axis]+')');var px=size(value.size,spec.defaultSize);r.style.setProperty(spec.sizeProperty,px+'px');r.style.setProperty(spec.scaleProperty,String(px/spec.defaultSize));if(axis==='ui'){r.style.setProperty('--ui-tracking',font.uiTracking);r.style.setProperty('--ui-word-spacing',font.uiWordSpacing);}}r.removeAttribute('data-font');})();`;
|
|
179
|
+
return `(function(){var r=document.documentElement;var axes=JSON.parse(${safeScriptStringLiteral(axisConfig)});var projection=JSON.parse(${safeScriptStringLiteral(fontProjection)});var ids=${fontIds};var has=function(v,k){return Object.prototype.hasOwnProperty.call(v,k)};var record=function(v){return typeof v==='object'&&v!==null&&!Array.isArray(v)};var p={};try{var raw=localStorage.getItem(${safeScriptStringLiteral(storageKey)});var parsed=raw?JSON.parse(raw):{};if(record(parsed)${persistedVersionGuard})p=parsed;}catch(e){}var saved=record(p.fonts)?p.fonts:{};var valid=function(v,d){return ids.indexOf(v)!==-1?v:d};var size=function(v,d){var n=typeof v==='number'?v:typeof v==='string'&&v.trim()!==''?Number(v):NaN;return Number.isFinite(n)?Math.min(32,Math.max(10,Math.round(n))):d};r.setAttribute('data-font-settings','');for(var axis in axes){if(!has(axes,axis))continue;var spec=axes[axis];var candidate=axis==='terminal'&&!has(saved,'terminal')?saved.code:saved[axis];var value=record(candidate)?candidate:{};var legacyUi=axis==='ui'&&!has(value,'family');var family=legacyUi?valid(p.font,'system'):valid(value.family,'system');var font=projection[family];if(family==='system')r.removeAttribute(spec.familyAttribute);else r.setAttribute(spec.familyAttribute,family);r.style.setProperty(spec.familyProperty,'var('+font.familyVariables[axis]+')');var px=size(value.size,spec.defaultSize);r.style.setProperty(spec.sizeProperty,px+'px');r.style.setProperty(spec.scaleProperty,String(px/spec.defaultSize));if(axis==='ui'){r.style.setProperty('--ui-tracking',font.uiTracking);r.style.setProperty('--ui-word-spacing',font.uiWordSpacing);}}r.removeAttribute('data-font');})();`;
|
|
162
180
|
}
|
|
163
|
-
export { APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, applyAppearanceFontSettings, fontSettingsBootstrapScript, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize };
|
|
181
|
+
export { APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, applyAppearanceFontSettings, fontSettingsBootstrapScript, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize, resolveAppearanceEditorFontSettings };
|
|
164
182
|
|
|
165
183
|
//# sourceMappingURL=appearance-font-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance-font-settings.js","names":[],"sources":["../../src/lib/appearance-font-settings.ts"],"sourcesContent":["import { DEFAULT_FONT_ID, fontOptions, type FontOption } from '#lib/font-catalog'\nimport { safeScriptStringLiteral } from '#lib/safe-script'\n\nexport const APPEARANCE_EDITOR_FONT_AXES = ['ui', 'content', 'code'] as const\n\nexport type AppearanceEditorFontAxis = (typeof APPEARANCE_EDITOR_FONT_AXES)[number]\nexport type AppearanceEditorFontFamilyId = FontOption['id']\n\nexport type AppearanceEditorFontSetting = Readonly<{\n /** A stable id from the shared font catalogue, never a CSS family string. */\n family: AppearanceEditorFontFamilyId\n /** A pixel size, normalized to the supported range. */\n size: number\n}>\n\n/** The host-owned choices edited by the shared appearance composition. */\nexport type AppearanceEditorFontSettings = Readonly<\n Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n>\n\nexport const APPEARANCE_EDITOR_FONT_SIZE_MIN = 10\nexport const APPEARANCE_EDITOR_FONT_SIZE_MAX = 32\n\n/** New preferences use the platform face in each text role. */\nexport const DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS: AppearanceEditorFontSettings = Object.freeze({\n ui: Object.freeze({ family: DEFAULT_FONT_ID, size: 14 }),\n content: Object.freeze({ family: DEFAULT_FONT_ID, size: 14 }),\n code: Object.freeze({ family: DEFAULT_FONT_ID, size: 12 }),\n})\n\nexport type NormalizedAppearanceEditorFontSettings = Readonly<{\n settings: AppearanceEditorFontSettings\n /** Axes whose persisted family or size was unavailable or outside its limits. */\n recoveredAxes: readonly AppearanceEditorFontAxis[]\n}>\n\nconst fontProjectionById = Object.freeze(\n Object.fromEntries(\n fontOptions.map((option) => [\n option.id,\n {\n familyVariables: option.familyVariables,\n uiTracking: option.uiTracking,\n uiWordSpacing: option.uiWordSpacing,\n },\n ])\n ) as Record<\n AppearanceEditorFontFamilyId,\n Pick<FontOption, 'familyVariables' | 'uiTracking' | 'uiWordSpacing'>\n >\n)\nconst fontAxisProjection = Object.freeze({\n ui: Object.freeze({\n familyAttribute: 'data-ui-font',\n familyProperty: '--font-ui',\n sizeProperty: '--font-ui-size',\n scaleProperty: '--font-ui-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.ui.size,\n }),\n content: Object.freeze({\n familyAttribute: 'data-content-font',\n familyProperty: '--font-content',\n sizeProperty: '--font-content-size',\n scaleProperty: '--font-content-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.content.size,\n }),\n code: Object.freeze({\n familyAttribute: 'data-code-font',\n familyProperty: '--font-code',\n sizeProperty: '--font-code-size',\n scaleProperty: '--font-code-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size,\n }),\n})\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction hasOwn(value: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(value, key)\n}\n\nfunction normalizeFamily(value: unknown): AppearanceEditorFontFamilyId | undefined {\n return typeof value === 'string' && hasOwn(fontProjectionById, value)\n ? (value as AppearanceEditorFontFamilyId)\n : undefined\n}\n\nfunction clampFontSize(value: number): number {\n return Math.min(\n APPEARANCE_EDITOR_FONT_SIZE_MAX,\n Math.max(APPEARANCE_EDITOR_FONT_SIZE_MIN, Math.round(value))\n )\n}\n\n/** Normalize a single number-input value; invalid edits return the current size. */\nexport function normalizeAppearanceEditorFontSize(value: unknown, fallback: number): number {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string' && value.trim() !== ''\n ? Number(value)\n : Number.NaN\n return Number.isFinite(parsed) ? clampFontSize(parsed) : clampFontSize(fallback)\n}\n\n/**\n * Recover persisted font choices against the shared font catalogue.\n *\n * `legacyUiFamily` lets a host migrate its previous single font field into the\n * UI axis. Content and code remain on the new System defaults during that\n * migration. Missing settings are ordinary defaults; an unknown saved id or an\n * invalid size is reported through `recoveredAxes` for the host's notice.\n */\nexport function normalizeAppearanceEditorFontSettings(\n value: unknown,\n legacyUiFamily?: unknown\n): NormalizedAppearanceEditorFontSettings {\n const source = isRecord(value) ? value : undefined\n const malformedRoot = value !== undefined && value !== null && source === undefined\n const recovered = new Set<AppearanceEditorFontAxis>()\n const settings = {} as Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const axisPresent = source ? hasOwn(source, axis) : false\n const axisValue = source?.[axis]\n const axisSource = isRecord(axisValue) ? axisValue : undefined\n const fallback = DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS[axis]\n\n if (malformedRoot || (axisPresent && axisSource === undefined)) recovered.add(axis)\n\n const hasFamily = axisSource ? hasOwn(axisSource, 'family') : false\n const familyInput = hasFamily\n ? axisSource?.['family']\n : axis === 'ui' && legacyUiFamily !== undefined\n ? legacyUiFamily\n : undefined\n const family = normalizeFamily(familyInput) ?? fallback.family\n if (\n (hasFamily || (axis === 'ui' && legacyUiFamily !== undefined)) &&\n !normalizeFamily(familyInput)\n ) {\n recovered.add(axis)\n }\n\n const hasSize = axisSource ? hasOwn(axisSource, 'size') : false\n const sizeInput = axisSource?.['size']\n const size = hasSize\n ? normalizeAppearanceEditorFontSize(sizeInput, fallback.size)\n : fallback.size\n if (\n hasSize &&\n (typeof sizeInput !== 'number' || !Number.isFinite(sizeInput) || sizeInput !== size)\n ) {\n recovered.add(axis)\n }\n\n settings[axis] = Object.freeze({ family, size })\n }\n\n return Object.freeze({\n settings: Object.freeze(settings),\n recoveredAxes: Object.freeze(APPEARANCE_EDITOR_FONT_AXES.filter((axis) => recovered.has(axis))),\n })\n}\n\n/**\n * Project normalized font preferences onto a document root.\n *\n * This is shared by `ThemeProvider` and hosts that own their own appearance\n * persistence, so UI/content/code use the same catalogue ids, theme tokens,\n * sizes, and projected CSS variables. The marker activates the optional role\n * stylesheet and survives CSS import reordering.\n */\nexport function applyAppearanceFontSettings(\n root: Pick<HTMLElement, 'removeAttribute' | 'setAttribute' | 'style'>,\n value: unknown\n): NormalizedAppearanceEditorFontSettings {\n const normalized = normalizeAppearanceEditorFontSettings(value)\n const { settings } = normalized\n\n // Only changed values are written: this runs on every theme pass, and an\n // unchanged attribute or property rewritten still dirties the document's style.\n const readAttribute = (root as Partial<Pick<HTMLElement, 'getAttribute'>>).getAttribute\n const setAttribute = (name: string, next: string) => {\n if (readAttribute?.call(root, name) !== next) root.setAttribute(name, next)\n }\n const style = root.style as Pick<CSSStyleDeclaration, 'setProperty'> &\n Partial<Pick<CSSStyleDeclaration, 'getPropertyValue'>>\n const setProperty = (name: string, next: string) => {\n if (style.getPropertyValue?.(name) !== next) style.setProperty(name, next)\n }\n root.removeAttribute('data-font')\n setAttribute('data-font-settings', '')\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const projection = fontAxisProjection[axis]\n const setting = settings[axis]\n const option = fontProjectionById[setting.family]\n if (setting.family === DEFAULT_FONT_ID) root.removeAttribute(projection.familyAttribute)\n else setAttribute(projection.familyAttribute, setting.family)\n setProperty(projection.familyProperty, `var(${option.familyVariables[axis]})`)\n setProperty(projection.sizeProperty, String(setting.size) + 'px')\n setProperty(projection.scaleProperty, String(setting.size / projection.defaultSize))\n if (axis === 'ui') {\n setProperty('--ui-tracking', option.uiTracking)\n setProperty('--ui-word-spacing', option.uiWordSpacing)\n }\n }\n\n return normalized\n}\n\n/**\n * Generate a safe inline prepaint script for a host-owned appearance record.\n *\n * The stored object is read from `localStorage[storageKey].fonts`. A legacy\n * top-level `font` family migrates into UI only; content/code use the shared\n * defaults. The script applies the same catalogue whitelist, limits, attributes,\n * and CSS properties as `applyAppearanceFontSettings` before styles paint. When\n * `persistedVersion` is supplied, only a record with that exact top-level version\n * is used; absent or mismatched records receive the System defaults.\n */\nexport function fontSettingsBootstrapScript(storageKey: string, persistedVersion?: number): string {\n if (persistedVersion !== undefined && !Number.isSafeInteger(persistedVersion)) {\n throw new RangeError('persistedVersion must be a safe integer')\n }\n const axisConfig = JSON.stringify(fontAxisProjection)\n const fontProjection = JSON.stringify(fontProjectionById)\n const fontIds = `[${fontOptions.map((option) => safeScriptStringLiteral(option.id)).join(',')}]`\n const persistedVersionGuard =\n persistedVersion === undefined\n ? ''\n : `&&parsed.version===Number(${safeScriptStringLiteral(String(persistedVersion))})`\n\n return `(function(){var r=document.documentElement;var axes=JSON.parse(${safeScriptStringLiteral(axisConfig)});var projection=JSON.parse(${safeScriptStringLiteral(fontProjection)});var ids=${fontIds};var has=function(v,k){return Object.prototype.hasOwnProperty.call(v,k)};var record=function(v){return typeof v==='object'&&v!==null&&!Array.isArray(v)};var p={};try{var raw=localStorage.getItem(${safeScriptStringLiteral(storageKey)});var parsed=raw?JSON.parse(raw):{};if(record(parsed)${persistedVersionGuard})p=parsed;}catch(e){}var saved=record(p.fonts)?p.fonts:{};var valid=function(v,d){return ids.indexOf(v)!==-1?v:d};var size=function(v,d){var n=typeof v==='number'?v:typeof v==='string'&&v.trim()!==''?Number(v):NaN;return Number.isFinite(n)?Math.min(${APPEARANCE_EDITOR_FONT_SIZE_MAX},Math.max(${APPEARANCE_EDITOR_FONT_SIZE_MIN},Math.round(n))):d};r.setAttribute('data-font-settings','');for(var axis in axes){if(!has(axes,axis))continue;var spec=axes[axis];var candidate=saved[axis];var value=record(candidate)?candidate:{};var legacyUi=axis==='ui'&&!has(value,'family');var family=legacyUi?valid(p.font,'system'):valid(value.family,'system');var font=projection[family];if(family==='system')r.removeAttribute(spec.familyAttribute);else r.setAttribute(spec.familyAttribute,family);r.style.setProperty(spec.familyProperty,'var('+font.familyVariables[axis]+')');var px=size(value.size,spec.defaultSize);r.style.setProperty(spec.sizeProperty,px+'px');r.style.setProperty(spec.scaleProperty,String(px/spec.defaultSize));if(axis==='ui'){r.style.setProperty('--ui-tracking',font.uiTracking);r.style.setProperty('--ui-word-spacing',font.uiWordSpacing);}}r.removeAttribute('data-font');})();`\n}\n"],"mappings":";;;AAGA,IAAa,8BAA8B;CAAC;CAAM;CAAW;AAAM;AAiBnE,IAAa,kCAAkC;AAC/C,IAAa,kCAAkC;;AAG/C,IAAa,0CAAwE,OAAO,OAAO;CACjG,IAAI,OAAO,OAAO;EAAE,QAAQ;EAAiB,MAAM;CAAG,CAAC;CACvD,SAAS,OAAO,OAAO;EAAE,QAAQ;EAAiB,MAAM;CAAG,CAAC;CAC5D,MAAM,OAAO,OAAO;EAAE,QAAQ;EAAiB,MAAM;CAAG,CAAC;AAC3D,CAAC;AAQD,IAAM,qBAAqB,OAAO,OAChC,OAAO,YACL,YAAY,KAAK,WAAW,CAC1B,OAAO,IACP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BAAwB,UAAU,EAAE,uDAAuD,sBAAsB;AAC/f"}
|
|
1
|
+
{"version":3,"file":"appearance-font-settings.js","names":[],"sources":["../../src/lib/appearance-font-settings.ts"],"sourcesContent":["import { DEFAULT_FONT_ID, fontOptions, type FontOption } from '#lib/font-catalog'\nimport { safeScriptStringLiteral } from '#lib/safe-script'\n\nexport const APPEARANCE_EDITOR_FONT_AXES = ['ui', 'content', 'code', 'terminal'] as const\n\nexport type AppearanceEditorFontAxis = (typeof APPEARANCE_EDITOR_FONT_AXES)[number]\nexport type AppearanceEditorFontFamilyId = FontOption['id']\n\nexport type AppearanceEditorFontSetting = Readonly<{\n /** A stable id from the shared font catalogue, never a CSS family string. */\n family: AppearanceEditorFontFamilyId\n /** A pixel size, normalized to the supported range. */\n size: number\n}>\n\n/**\n * The host-owned choices edited by the shared appearance composition.\n *\n * `terminal` is optional in what a host stores: a record written before the\n * terminal had its own axis, or by a host that never offers one, follows the\n * Code axis. Normalization keeps it absent, so such a record is stored as it was.\n */\nexport type AppearanceEditorFontSettings = Readonly<\n Record<Exclude<AppearanceEditorFontAxis, 'terminal'>, AppearanceEditorFontSetting> & {\n terminal?: AppearanceEditorFontSetting\n }\n>\n\n/** Font settings with every axis resolved (`resolveAppearanceEditorFontSettings`). */\nexport type ResolvedAppearanceEditorFontSettings = Readonly<\n Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n>\n\nexport const APPEARANCE_EDITOR_FONT_SIZE_MIN = 10\nexport const APPEARANCE_EDITOR_FONT_SIZE_MAX = 32\n\n/** New preferences use the platform face in each text role. */\nexport const DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS: AppearanceEditorFontSettings = Object.freeze({\n ui: Object.freeze({ family: DEFAULT_FONT_ID, size: 14 }),\n content: Object.freeze({ family: DEFAULT_FONT_ID, size: 14 }),\n code: Object.freeze({ family: DEFAULT_FONT_ID, size: 12 }),\n})\n\n/** Every axis with a value: the terminal follows Code until it is given its own. */\nexport function resolveAppearanceEditorFontSettings(\n settings: AppearanceEditorFontSettings\n): ResolvedAppearanceEditorFontSettings {\n return settings.terminal\n ? (settings as ResolvedAppearanceEditorFontSettings)\n : { ...settings, terminal: settings.code }\n}\n\nexport type NormalizedAppearanceEditorFontSettings = Readonly<{\n settings: AppearanceEditorFontSettings\n /** Axes whose persisted family or size was unavailable or outside its limits. */\n recoveredAxes: readonly AppearanceEditorFontAxis[]\n}>\n\nconst fontProjectionById = Object.freeze(\n Object.fromEntries(\n fontOptions.map((option) => [\n option.id,\n {\n familyVariables: option.familyVariables,\n uiTracking: option.uiTracking,\n uiWordSpacing: option.uiWordSpacing,\n },\n ])\n ) as Record<\n AppearanceEditorFontFamilyId,\n Pick<FontOption, 'familyVariables' | 'uiTracking' | 'uiWordSpacing'>\n >\n)\nconst fontAxisProjection = Object.freeze({\n ui: Object.freeze({\n familyAttribute: 'data-ui-font',\n familyProperty: '--font-ui',\n sizeProperty: '--font-ui-size',\n scaleProperty: '--font-ui-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.ui.size,\n }),\n content: Object.freeze({\n familyAttribute: 'data-content-font',\n familyProperty: '--font-content',\n sizeProperty: '--font-content-size',\n scaleProperty: '--font-content-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.content.size,\n }),\n code: Object.freeze({\n familyAttribute: 'data-code-font',\n familyProperty: '--font-code',\n sizeProperty: '--font-code-size',\n scaleProperty: '--font-code-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size,\n }),\n terminal: Object.freeze({\n familyAttribute: 'data-terminal-font',\n familyProperty: '--font-terminal',\n sizeProperty: '--font-terminal-size',\n scaleProperty: '--font-terminal-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size,\n }),\n})\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction hasOwn(value: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(value, key)\n}\n\nfunction normalizeFamily(value: unknown): AppearanceEditorFontFamilyId | undefined {\n return typeof value === 'string' && hasOwn(fontProjectionById, value)\n ? (value as AppearanceEditorFontFamilyId)\n : undefined\n}\n\nfunction clampFontSize(value: number): number {\n return Math.min(\n APPEARANCE_EDITOR_FONT_SIZE_MAX,\n Math.max(APPEARANCE_EDITOR_FONT_SIZE_MIN, Math.round(value))\n )\n}\n\n/** Normalize a single number-input value; invalid edits return the current size. */\nexport function normalizeAppearanceEditorFontSize(value: unknown, fallback: number): number {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string' && value.trim() !== ''\n ? Number(value)\n : Number.NaN\n return Number.isFinite(parsed) ? clampFontSize(parsed) : clampFontSize(fallback)\n}\n\n/**\n * Recover persisted font choices against the shared font catalogue.\n *\n * A record with no `terminal` axis is returned without one: it follows Code.\n *\n * `legacyUiFamily` lets a host migrate its previous single font field into the\n * UI axis. Content and code remain on the new System defaults during that\n * migration. Missing settings are ordinary defaults; an unknown saved id or an\n * invalid size is reported through `recoveredAxes` for the host's notice.\n */\nexport function normalizeAppearanceEditorFontSettings(\n value: unknown,\n legacyUiFamily?: unknown\n): NormalizedAppearanceEditorFontSettings {\n const source = isRecord(value) ? value : undefined\n const malformedRoot = value !== undefined && value !== null && source === undefined\n const recovered = new Set<AppearanceEditorFontAxis>()\n const settings = {} as {\n -readonly [Axis in keyof AppearanceEditorFontSettings]: AppearanceEditorFontSettings[Axis]\n }\n\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const axisPresent = source ? hasOwn(source, axis) : false\n const axisValue = source?.[axis]\n const axisSource = isRecord(axisValue) ? axisValue : undefined\n // The terminal used the Code axis before it had its own. A record without a\n // terminal entry stays without one and keeps following Code.\n if (axis === 'terminal' && !axisPresent) continue\n const fallback = DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS[axis === 'terminal' ? 'code' : axis]\n\n if (malformedRoot || (axisPresent && axisSource === undefined)) recovered.add(axis)\n\n const hasFamily = axisSource ? hasOwn(axisSource, 'family') : false\n const familyInput = hasFamily\n ? axisSource?.['family']\n : axis === 'ui' && legacyUiFamily !== undefined\n ? legacyUiFamily\n : undefined\n const family = normalizeFamily(familyInput) ?? fallback.family\n if (\n (hasFamily || (axis === 'ui' && legacyUiFamily !== undefined)) &&\n !normalizeFamily(familyInput)\n ) {\n recovered.add(axis)\n }\n\n const hasSize = axisSource ? hasOwn(axisSource, 'size') : false\n const sizeInput = axisSource?.['size']\n const size = hasSize\n ? normalizeAppearanceEditorFontSize(sizeInput, fallback.size)\n : fallback.size\n if (\n hasSize &&\n (typeof sizeInput !== 'number' || !Number.isFinite(sizeInput) || sizeInput !== size)\n ) {\n recovered.add(axis)\n }\n\n settings[axis] = Object.freeze({ family, size })\n }\n\n return Object.freeze({\n settings: Object.freeze(settings),\n recoveredAxes: Object.freeze(APPEARANCE_EDITOR_FONT_AXES.filter((axis) => recovered.has(axis))),\n })\n}\n\n/**\n * Project normalized font preferences onto a document root.\n *\n * This is shared by `ThemeProvider` and hosts that own their own appearance\n * persistence, so UI/content/code use the same catalogue ids, theme tokens,\n * sizes, and projected CSS variables (terminal included). The marker activates the optional role\n * stylesheet and survives CSS import reordering.\n */\nexport function applyAppearanceFontSettings(\n root: Pick<HTMLElement, 'removeAttribute' | 'setAttribute' | 'style'>,\n value: unknown\n): NormalizedAppearanceEditorFontSettings {\n const normalized = normalizeAppearanceEditorFontSettings(value)\n const settings = resolveAppearanceEditorFontSettings(normalized.settings)\n\n // Only changed values are written: this runs on every theme pass, and an\n // unchanged attribute or property rewritten still dirties the document's style.\n const readAttribute = (root as Partial<Pick<HTMLElement, 'getAttribute'>>).getAttribute\n const setAttribute = (name: string, next: string) => {\n if (readAttribute?.call(root, name) !== next) root.setAttribute(name, next)\n }\n const style = root.style as Pick<CSSStyleDeclaration, 'setProperty'> &\n Partial<Pick<CSSStyleDeclaration, 'getPropertyValue'>>\n const setProperty = (name: string, next: string) => {\n if (style.getPropertyValue?.(name) !== next) style.setProperty(name, next)\n }\n root.removeAttribute('data-font')\n setAttribute('data-font-settings', '')\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const projection = fontAxisProjection[axis]\n const setting = settings[axis]\n const option = fontProjectionById[setting.family]\n if (setting.family === DEFAULT_FONT_ID) root.removeAttribute(projection.familyAttribute)\n else setAttribute(projection.familyAttribute, setting.family)\n setProperty(projection.familyProperty, `var(${option.familyVariables[axis]})`)\n setProperty(projection.sizeProperty, String(setting.size) + 'px')\n setProperty(projection.scaleProperty, String(setting.size / projection.defaultSize))\n if (axis === 'ui') {\n setProperty('--ui-tracking', option.uiTracking)\n setProperty('--ui-word-spacing', option.uiWordSpacing)\n }\n }\n\n return normalized\n}\n\n/**\n * Generate a safe inline prepaint script for a host-owned appearance record.\n *\n * The stored object is read from `localStorage[storageKey].fonts`. A legacy\n * top-level `font` family migrates into UI only; content/code use the shared\n * defaults. The script applies the same catalogue whitelist, limits, attributes,\n * and CSS properties as `applyAppearanceFontSettings` before styles paint. When\n * `persistedVersion` is supplied, only a record with that exact top-level version\n * is used; absent or mismatched records receive the System defaults.\n */\nexport function fontSettingsBootstrapScript(storageKey: string, persistedVersion?: number): string {\n if (persistedVersion !== undefined && !Number.isSafeInteger(persistedVersion)) {\n throw new RangeError('persistedVersion must be a safe integer')\n }\n const axisConfig = JSON.stringify(fontAxisProjection)\n const fontProjection = JSON.stringify(fontProjectionById)\n const fontIds = `[${fontOptions.map((option) => safeScriptStringLiteral(option.id)).join(',')}]`\n const persistedVersionGuard =\n persistedVersion === undefined\n ? ''\n : `&&parsed.version===Number(${safeScriptStringLiteral(String(persistedVersion))})`\n\n return `(function(){var r=document.documentElement;var axes=JSON.parse(${safeScriptStringLiteral(axisConfig)});var projection=JSON.parse(${safeScriptStringLiteral(fontProjection)});var ids=${fontIds};var has=function(v,k){return Object.prototype.hasOwnProperty.call(v,k)};var record=function(v){return typeof v==='object'&&v!==null&&!Array.isArray(v)};var p={};try{var raw=localStorage.getItem(${safeScriptStringLiteral(storageKey)});var parsed=raw?JSON.parse(raw):{};if(record(parsed)${persistedVersionGuard})p=parsed;}catch(e){}var saved=record(p.fonts)?p.fonts:{};var valid=function(v,d){return ids.indexOf(v)!==-1?v:d};var size=function(v,d){var n=typeof v==='number'?v:typeof v==='string'&&v.trim()!==''?Number(v):NaN;return Number.isFinite(n)?Math.min(${APPEARANCE_EDITOR_FONT_SIZE_MAX},Math.max(${APPEARANCE_EDITOR_FONT_SIZE_MIN},Math.round(n))):d};r.setAttribute('data-font-settings','');for(var axis in axes){if(!has(axes,axis))continue;var spec=axes[axis];var candidate=axis==='terminal'&&!has(saved,'terminal')?saved.code:saved[axis];var value=record(candidate)?candidate:{};var legacyUi=axis==='ui'&&!has(value,'family');var family=legacyUi?valid(p.font,'system'):valid(value.family,'system');var font=projection[family];if(family==='system')r.removeAttribute(spec.familyAttribute);else r.setAttribute(spec.familyAttribute,family);r.style.setProperty(spec.familyProperty,'var('+font.familyVariables[axis]+')');var px=size(value.size,spec.defaultSize);r.style.setProperty(spec.sizeProperty,px+'px');r.style.setProperty(spec.scaleProperty,String(px/spec.defaultSize));if(axis==='ui'){r.style.setProperty('--ui-tracking',font.uiTracking);r.style.setProperty('--ui-word-spacing',font.uiWordSpacing);}}r.removeAttribute('data-font');})();`\n}\n"],"mappings":";;;AAGA,IAAa,8BAA8B;CAAC;CAAM;CAAW;CAAQ;AAAU;AA8B/E,IAAa,kCAAkC;AAC/C,IAAa,kCAAkC;;AAG/C,IAAa,0CAAwE,OAAO,OAAO;CACjG,IAAI,OAAO,OAAO;EAAE,QAAQ;EAAiB,MAAM;CAAG,CAAC;CACvD,SAAS,OAAO,OAAO;EAAE,QAAQ;EAAiB,MAAM;CAAG,CAAC;CAC5D,MAAM,OAAO,OAAO;EAAE,QAAQ;EAAiB,MAAM;CAAG,CAAC;AAC3D,CAAC;;AAGD,SAAgB,oCACd,UACsC;CACtC,OAAO,SAAS,W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,MAAM,iBAAiB,KAAK,UAAU,kBAAkB;CACxD,MAAM,UAAU,IAAI,YAAY,KAAK,WAAW,wBAAwB,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;CAC9F,MAAM,wBACJ,qBAAqB,KAAA,IACjB,KACA,6BAA6B,wBAAwB,OAAO,gBAAgB,CAAC,EAAE;CAErF,OAAO,kEAAkE,wBAAwB,UAAU,EAAE,8BAA8B,wBAAwB,cAAc,EAAE,YAAY,QAAQ,qMAAqM,wBAAwB,UAAU,EAAE,uDAAuD,sBAAsB;AAC/f"}
|
package/dist/lib/fast-icon.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ import type { JSX } from 'solid-js';
|
|
|
12
12
|
* drew, so the markup (attributes, class names, path keys) stays exactly
|
|
13
13
|
* lucide's. Props that change the drawing (`size`, `color`, `strokeWidth`,
|
|
14
14
|
* `absoluteStrokeWidth`) or a `LucideProvider` are not supported: those callers
|
|
15
|
-
* keep the lucide component. On the server
|
|
15
|
+
* keep the lucide component. On the server, and while the client hydrates, the
|
|
16
|
+
* lucide component renders as is.
|
|
16
17
|
*/
|
|
17
18
|
export declare function fastIcon<T extends (props: never) => JSX.Element>(LucideIcon: T): T;
|
|
18
19
|
//# sourceMappingURL=fast-icon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-icon.d.ts","sourceRoot":"","sources":["../../src/lib/fast-icon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAoBnC
|
|
1
|
+
{"version":3,"file":"fast-icon.d.ts","sourceRoot":"","sources":["../../src/lib/fast-icon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAoBnC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,KAAK,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAqClF"}
|
package/dist/lib/fast-icon.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isServer, spread } from "solid-js/web";
|
|
2
|
-
import { createRoot, mergeProps as mergeProps$1, splitProps } from "solid-js";
|
|
2
|
+
import { createRoot, mergeProps as mergeProps$1, sharedConfig, splitProps } from "solid-js";
|
|
3
3
|
// src/lib/fast-icon.ts
|
|
4
4
|
var DRAWING = [
|
|
5
5
|
"size",
|
|
@@ -25,12 +25,13 @@ var A11Y = /^(aria-|role$|title$)/;
|
|
|
25
25
|
* drew, so the markup (attributes, class names, path keys) stays exactly
|
|
26
26
|
* lucide's. Props that change the drawing (`size`, `color`, `strokeWidth`,
|
|
27
27
|
* `absoluteStrokeWidth`) or a `LucideProvider` are not supported: those callers
|
|
28
|
-
* keep the lucide component. On the server
|
|
28
|
+
* keep the lucide component. On the server, and while the client hydrates, the
|
|
29
|
+
* lucide component renders as is.
|
|
29
30
|
*/
|
|
30
31
|
function fastIcon(LucideIcon) {
|
|
31
32
|
const Icon = LucideIcon;
|
|
32
33
|
const Fast = (props) => {
|
|
33
|
-
if (isServer || props.children !== void 0 || DRAWING.some((key) => key in props)) return Icon(props);
|
|
34
|
+
if (isServer || sharedConfig.context || props.children !== void 0 || DRAWING.some((key) => key in props)) return Icon(props);
|
|
34
35
|
const template = capture(Icon);
|
|
35
36
|
const [local, rest] = splitProps(props, ["class"]);
|
|
36
37
|
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-icon.js","names":["mergeProps"],"sources":["../../src/lib/fast-icon.ts"],"sourcesContent":["import type { JSX } from 'solid-js'\nimport { createRoot, mergeProps, splitProps } from 'solid-js'\nimport { isServer, spread } from 'solid-js/web'\n\ntype IconComponent = (props: JSX.SvgSVGAttributes<SVGSVGElement>) => JSX.Element\n// lucide's own drawing props: an icon given one keeps lucide's component.\nconst DRAWING = [\n 'size',\n 'color',\n 'strokeWidth',\n 'absoluteStrokeWidth',\n 'nonScalingStroke',\n 'width',\n 'height',\n]\ntype Captured = { attributes: [string, string][]; className: string; body: DocumentFragment }\n\nconst captured = new WeakMap<IconComponent, Captured>()\nconst A11Y = /^(aria-|role$|title$)/\n\n/**\n * The same lucide icon, built by cloning a template instead of by components.\n *\n * lucide-solid builds every icon as a `<For>` of `<Dynamic>` children, one\n * component and one spread effect per path. A plain six-path icon cost as much\n * to mount as a Button, and a transcript row spent a quarter of its mount time\n * in its avatar's icon. The paths never change, so they are drawn once per icon\n * and cloned after that; only the outer `<svg>` takes props.\n *\n * The first instance renders the lucide component itself and records what it\n * drew, so the markup (attributes, class names, path keys) stays exactly\n * lucide's. Props that change the drawing (`size`, `color`, `strokeWidth`,\n * `absoluteStrokeWidth`) or a `LucideProvider` are not supported: those callers\n * keep the lucide component. On the server the lucide component renders as is.\n */\nexport function fastIcon<T extends (props: never) => JSX.Element>(LucideIcon: T): T {\n const Icon = LucideIcon as unknown as IconComponent\n const Fast = (props: JSX.SvgSVGAttributes<SVGSVGElement>) => {\n // Children (a <title>), drawing props
|
|
1
|
+
{"version":3,"file":"fast-icon.js","names":["mergeProps"],"sources":["../../src/lib/fast-icon.ts"],"sourcesContent":["import type { JSX } from 'solid-js'\nimport { createRoot, mergeProps, sharedConfig, splitProps } from 'solid-js'\nimport { isServer, spread } from 'solid-js/web'\n\ntype IconComponent = (props: JSX.SvgSVGAttributes<SVGSVGElement>) => JSX.Element\n// lucide's own drawing props: an icon given one keeps lucide's component.\nconst DRAWING = [\n 'size',\n 'color',\n 'strokeWidth',\n 'absoluteStrokeWidth',\n 'nonScalingStroke',\n 'width',\n 'height',\n]\ntype Captured = { attributes: [string, string][]; className: string; body: DocumentFragment }\n\nconst captured = new WeakMap<IconComponent, Captured>()\nconst A11Y = /^(aria-|role$|title$)/\n\n/**\n * The same lucide icon, built by cloning a template instead of by components.\n *\n * lucide-solid builds every icon as a `<For>` of `<Dynamic>` children, one\n * component and one spread effect per path. A plain six-path icon cost as much\n * to mount as a Button, and a transcript row spent a quarter of its mount time\n * in its avatar's icon. The paths never change, so they are drawn once per icon\n * and cloned after that; only the outer `<svg>` takes props.\n *\n * The first instance renders the lucide component itself and records what it\n * drew, so the markup (attributes, class names, path keys) stays exactly\n * lucide's. Props that change the drawing (`size`, `color`, `strokeWidth`,\n * `absoluteStrokeWidth`) or a `LucideProvider` are not supported: those callers\n * keep the lucide component. On the server, and while the client hydrates, the\n * lucide component renders as is.\n */\nexport function fastIcon<T extends (props: never) => JSX.Element>(LucideIcon: T): T {\n const Icon = LucideIcon as unknown as IconComponent\n const Fast = (props: JSX.SvgSVGAttributes<SVGSVGElement>) => {\n // Children (a <title>), drawing props, the server and hydration keep lucide's\n // component: a hydrating icon must claim the server's nodes, not build its own.\n if (\n isServer ||\n sharedConfig.context ||\n props.children !== undefined ||\n DRAWING.some((key) => key in props)\n )\n return Icon(props)\n const template = capture(Icon)\n const [local, rest] = splitProps(props, ['class'])\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')\n let labelled = false\n for (const key in rest) if (A11Y.test(key)) labelled = true\n for (const [name, value] of template.attributes) svg.setAttribute(name, value)\n svg.append(template.body.cloneNode(true))\n // In lucide's order: its attributes, the class, aria-hidden, then the caller's.\n spread(\n svg,\n mergeProps(\n {\n get class() {\n return local.class ? `${template.className} ${local.class}` : template.className\n },\n ...(labelled ? {} : { 'aria-hidden': 'true' }),\n },\n rest\n ) as never,\n true,\n true\n )\n return svg as unknown as JSX.Element\n }\n return Fast as unknown as T\n}\n\nfunction capture(Icon: IconComponent): Captured {\n const known = captured.get(Icon)\n if (known) return known\n const svg = createRoot((dispose) => {\n const element = Icon({}) as unknown as SVGSVGElement\n dispose()\n return element\n })\n const attributes: [string, string][] = []\n let className = ''\n for (const attribute of Array.from(svg.attributes)) {\n if (attribute.name === 'class') className = attribute.value\n else if (attribute.name !== 'aria-hidden') attributes.push([attribute.name, attribute.value])\n }\n const body = document.createDocumentFragment()\n for (const child of Array.from(svg.childNodes)) body.append(child.cloneNode(true))\n const result = { attributes, className, body }\n captured.set(Icon, result)\n return result\n}\n"],"mappings":";;;AAMA,IAAM,UAAU;CACd;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,IAAM,2BAAW,IAAI,QAAiC;AACtD,IAAM,OAAO;;;;;;;;;;;;;;;;;AAkBb,SAAgB,SAAkD,YAAkB;CAClF,MAAM,OAAO;CACb,MAAM,QAAQ,UAA+C;EAG3D,IACE,YACA,aAAa,WACb,MAAM,aAAa,KAAA,KACnB,QAAQ,MAAM,QAAQ,OAAO,KAAK,GAElC,OAAO,KAAK,KAAK;EACnB,MAAM,WAAW,QAAQ,IAAI;EAC7B,MAAM,CAAC,OAAO,QAAQ,WAAW,OAAO,CAAC,OAAO,CAAC;EACjD,MAAM,MAAM,SAAS,gBAAgB,8BAA8B,KAAK;EACxE,IAAI,WAAW;EACf,KAAK,MAAM,OAAO,MAAM,IAAI,KAAK,KAAK,GAAG,GAAG,WAAW;EACvD,KAAK,MAAM,CAAC,MAAM,UAAU,SAAS,YAAY,IAAI,aAAa,MAAM,KAAK;EAC7E,IAAI,OAAO,SAAS,KAAK,UAAU,IAAI,CAAC;EAExC,OACE,KACAA,aACE;GACE,IAAI,QAAQ;IACV,OAAO,MAAM,QAAQ,GAAG,SAAS,UAAU,GAAG,MAAM,UAAU,SAAS;GACzE;GACA,GAAI,WAAW,CAAC,IAAI,EAAE,eAAe,OAAO;EAC9C,GACA,IACF,GACA,MACA,IACF;EACA,OAAO;CACT;CACA,OAAO;AACT;AAEA,SAAS,QAAQ,MAA+B;CAC9C,MAAM,QAAQ,SAAS,IAAI,IAAI;CAC/B,IAAI,OAAO,OAAO;CAClB,MAAM,MAAM,YAAY,YAAY;EAClC,MAAM,UAAU,KAAK,CAAC,CAAC;EACvB,QAAQ;EACR,OAAO;CACT,CAAC;CACD,MAAM,aAAiC,CAAC;CACxC,IAAI,YAAY;CAChB,KAAK,MAAM,aAAa,MAAM,KAAK,IAAI,UAAU,GAC/C,IAAI,UAAU,SAAS,SAAS,YAAY,UAAU;MACjD,IAAI,UAAU,SAAS,eAAe,WAAW,KAAK,CAAC,UAAU,MAAM,UAAU,KAAK,CAAC;CAE9F,MAAM,OAAO,SAAS,uBAAuB;CAC7C,KAAK,MAAM,SAAS,MAAM,KAAK,IAAI,UAAU,GAAG,KAAK,OAAO,MAAM,UAAU,IAAI,CAAC;CACjF,MAAM,SAAS;EAAE;EAAY;EAAW;CAAK;CAC7C,SAAS,IAAI,MAAM,MAAM;CACzB,OAAO;AACT"}
|
|
@@ -14,6 +14,7 @@ declare const FONT_OPTIONS: readonly [{
|
|
|
14
14
|
readonly ui: '--font-family-space-grotesk';
|
|
15
15
|
readonly content: '--font-family-space-grotesk';
|
|
16
16
|
readonly code: '--font-family-space-grotesk';
|
|
17
|
+
readonly terminal: '--font-family-space-grotesk';
|
|
17
18
|
};
|
|
18
19
|
readonly uiTracking: 'normal';
|
|
19
20
|
readonly uiWordSpacing: 'normal';
|
|
@@ -25,6 +26,7 @@ declare const FONT_OPTIONS: readonly [{
|
|
|
25
26
|
readonly ui: '--font-family-system';
|
|
26
27
|
readonly content: '--font-family-system';
|
|
27
28
|
readonly code: '--font-family-system-mono';
|
|
29
|
+
readonly terminal: '--font-family-system-mono';
|
|
28
30
|
};
|
|
29
31
|
readonly uiTracking: 'normal';
|
|
30
32
|
readonly uiWordSpacing: 'normal';
|
|
@@ -36,6 +38,7 @@ declare const FONT_OPTIONS: readonly [{
|
|
|
36
38
|
readonly ui: '--font-family-geist';
|
|
37
39
|
readonly content: '--font-family-geist';
|
|
38
40
|
readonly code: '--font-family-geist';
|
|
41
|
+
readonly terminal: '--font-family-geist';
|
|
39
42
|
};
|
|
40
43
|
readonly uiTracking: 'normal';
|
|
41
44
|
readonly uiWordSpacing: 'normal';
|
|
@@ -47,6 +50,7 @@ declare const FONT_OPTIONS: readonly [{
|
|
|
47
50
|
readonly ui: '--font-family-geist-mono';
|
|
48
51
|
readonly content: '--font-family-geist-mono';
|
|
49
52
|
readonly code: '--font-family-geist-mono';
|
|
53
|
+
readonly terminal: '--font-family-geist-mono';
|
|
50
54
|
};
|
|
51
55
|
readonly uiTracking: '-0.03em';
|
|
52
56
|
readonly uiWordSpacing: '-1.5px';
|
|
@@ -58,6 +62,7 @@ declare const FONT_OPTIONS: readonly [{
|
|
|
58
62
|
readonly ui: '--font-family-jetbrains-mono';
|
|
59
63
|
readonly content: '--font-family-jetbrains-mono';
|
|
60
64
|
readonly code: '--font-family-jetbrains-mono';
|
|
65
|
+
readonly terminal: '--font-family-jetbrains-mono';
|
|
61
66
|
};
|
|
62
67
|
readonly uiTracking: '-0.04em';
|
|
63
68
|
readonly uiWordSpacing: '-2.5px';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-catalog.d.ts","sourceRoot":"","sources":["../../src/lib/font-catalog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,kEAAkE;AAClE,eAAO,MAAM,eAAe,WAAW,CAAA;AAEvC,QAAA,MAAM,YAAY;aAEd,EAAE,EAAE,eAAe;aACnB,KAAK,EAAE,eAAe;aACtB,WAAW,EAAE,uCAAuC;aACpD,eAAe;iBACb,EAAE,EAAE,6BAA6B;iBACjC,OAAO,EAAE,6BAA6B;iBACtC,IAAI,EAAE,6BAA6B;;
|
|
1
|
+
{"version":3,"file":"font-catalog.d.ts","sourceRoot":"","sources":["../../src/lib/font-catalog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,kEAAkE;AAClE,eAAO,MAAM,eAAe,WAAW,CAAA;AAEvC,QAAA,MAAM,YAAY;aAEd,EAAE,EAAE,eAAe;aACnB,KAAK,EAAE,eAAe;aACtB,WAAW,EAAE,uCAAuC;aACpD,eAAe;iBACb,EAAE,EAAE,6BAA6B;iBACjC,OAAO,EAAE,6BAA6B;iBACtC,IAAI,EAAE,6BAA6B;iBACnC,QAAQ,EAAE,6BAA6B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