@bettercms-ai/kit 3.1.28 → 3.1.31

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.
@@ -22,15 +22,17 @@ var PILL_SPRING = {
22
22
  stiffness: 520,
23
23
  damping: 42
24
24
  };
25
+ var FORCED_TRACK = "forced-colors:forced-color-adjust-none forced-colors:bg-[Canvas] forced-colors:shadow-[inset_0_0_0_1px_ButtonText] forced-colors:data-[checked]:bg-[Highlight] forced-colors:data-[checked]:shadow-[inset_0_0_0_1px_Highlight]";
26
+ var FORCED_THUMB = "forced-colors:forced-color-adjust-none forced-colors:bg-[ButtonText] forced-colors:shadow-none forced-colors:data-[checked]:bg-[HighlightText]";
25
27
  function Switch({ className, size = "md", ...props }) {
26
28
  const sm = size === "sm";
27
29
  const labelledBy = useFieldLabelledBy();
28
30
  const labelFor = useLabelFor(props.id);
29
31
  return /* @__PURE__ */ jsx(Switch$1.Root, {
30
- className: cn("group relative inline-flex shrink-0 items-center rounded-full bg-kit-switch-off transition-colors duration-200 data-[checked]:bg-kit-success data-[disabled]:opacity-40", sm ? "h-4 w-7" : "h-5 w-9", className),
32
+ className: cn("group relative inline-flex shrink-0 items-center rounded-full bg-kit-switch-off transition-colors duration-200 data-[checked]:bg-kit-success data-[disabled]:opacity-40", sm ? "h-4 w-7" : "h-5 w-9", FORCED_TRACK, className),
31
33
  "aria-labelledby": props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : labelFor ?? (props.id ? void 0 : labelledBy)),
32
34
  ...props,
33
- children: /* @__PURE__ */ jsx(Switch$1.Thumb, { className: cn("pointer-events-none block rounded-full bg-kit-control-thumb shadow-kit-sm transition-transform duration-200 ease-[var(--kit-ease-spring)]", sm ? "size-3 translate-x-0.5 data-[checked]:translate-x-[14px]" : "size-4 translate-x-0.5 data-[checked]:translate-x-[18px]") })
35
+ children: /* @__PURE__ */ jsx(Switch$1.Thumb, { className: cn("pointer-events-none block rounded-full bg-kit-control-thumb shadow-kit-sm transition-transform duration-200 ease-[var(--kit-ease-spring)]", sm ? "size-3 translate-x-0.5 data-[checked]:translate-x-[14px]" : "size-4 translate-x-0.5 data-[checked]:translate-x-[18px]", FORCED_THUMB) })
34
36
  });
35
37
  }
36
38
  /** `checked` keeps V2's tri-state value: true, false or "indeterminate". */
@@ -1 +1 @@
1
- {"version":3,"file":"controls.js","names":[],"sources":["../../src/ui/controls.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Switch as SwitchPrimitive } from \"@base-ui/react/switch\";\nimport { Checkbox as CheckboxPrimitive } from \"@base-ui/react/checkbox\";\nimport { RadioGroup as RadioGroupPrimitive } from \"@base-ui/react/radio-group\";\nimport { Radio as RadioPrimitive } from \"@base-ui/react/radio\";\nimport { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\";\nimport { Slider as SliderPrimitive } from \"@base-ui/react/slider\";\nimport { ToggleGroup as ToggleGroupPrimitive } from \"@base-ui/react/toggle-group\";\nimport { Toggle as TogglePrimitive } from \"@base-ui/react/toggle\";\nimport { Progress as ProgressPrimitive } from \"@base-ui/react/progress\";\nimport { IconCheck, IconMinus } from \"@tabler/icons-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { cn } from \"../lib/cn\";\nimport { useFieldLabelledBy, useLabelFor } from \"./field-context\";\nimport { TooltipScope } from \"./button\";\nimport { useShortcutHints } from \"./shortcut-hint\";\nimport { TooltipLayer, TooltipRoot } from \"./tooltip-root\";\n\n/* Underlines and selected pills share one spring (DESIGN.md 3.6). */\nconst PILL_SPRING = { type: \"spring\", stiffness: 520, damping: 42 } as const;\n\n/* ── Switch ─────────────────────────────────────────────────────────────── */\nexport function Switch({\n className,\n size = \"md\",\n ...props\n}: SwitchPrimitive.Root.Props & { size?: \"sm\" | \"md\" }) {\n const sm = size === \"sm\";\n const labelledBy = useFieldLabelledBy();\n const labelFor = useLabelFor(props.id);\n return (\n <SwitchPrimitive.Root\n className={cn(\n \"group relative inline-flex shrink-0 items-center rounded-full bg-kit-switch-off transition-colors duration-200 data-[checked]:bg-kit-success data-[disabled]:opacity-40\",\n sm ? \"h-4 w-7\" : \"h-5 w-9\",\n className,\n )}\n aria-labelledby={props[\"aria-labelledby\"] ?? (props[\"aria-label\"] ? undefined : (labelFor ?? (props.id ? undefined : labelledBy)))}\n {...props}\n >\n <SwitchPrimitive.Thumb\n className={cn(\n \"pointer-events-none block rounded-full bg-kit-control-thumb shadow-kit-sm transition-transform duration-200 ease-[var(--kit-ease-spring)]\",\n sm ? \"size-3 translate-x-0.5 data-[checked]:translate-x-[14px]\" : \"size-4 translate-x-0.5 data-[checked]:translate-x-[18px]\",\n )}\n />\n </SwitchPrimitive.Root>\n );\n}\n\n/* ── Checkbox ───────────────────────────────────────────────────────────── */\n/** `checked` keeps V2's tri-state value: true, false or \"indeterminate\". */\nexport function Checkbox({\n className,\n checked,\n ...props\n}: Omit<CheckboxPrimitive.Root.Props, \"checked\" | \"indeterminate\"> & { checked?: boolean | \"indeterminate\" }) {\n const indeterminate = checked === \"indeterminate\";\n const labelFor = useLabelFor(props.id);\n return (\n <CheckboxPrimitive.Root\n aria-labelledby={props[\"aria-labelledby\"] ?? (props[\"aria-label\"] ? undefined : labelFor)}\n className={cn(\n \"peer flex size-4 shrink-0 items-center justify-center rounded-kit-sm border border-kit-line-strong bg-kit-control-bg shadow-kit-xs transition-colors hover:border-[var(--kit-emphasis-line)] data-[checked]:border-kit-inverse data-[checked]:bg-kit-inverse data-[indeterminate]:border-kit-inverse data-[indeterminate]:bg-kit-inverse\",\n className,\n )}\n checked={checked === undefined ? undefined : checked === true}\n indeterminate={indeterminate}\n {...props}\n >\n <CheckboxPrimitive.Indicator className=\"text-kit-fg-inverse\">\n {indeterminate ? <IconMinus className=\"size-3\" stroke={3} /> : <IconCheck className=\"size-3\" stroke={3} />}\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n}\n\n/* ── Radio ──────────────────────────────────────────────────────────────── */\nexport const RadioGroup = RadioGroupPrimitive;\nexport function Radio({ className, ...props }: RadioPrimitive.Root.Props) {\n return (\n <RadioPrimitive.Root\n className={cn(\n \"flex size-4 shrink-0 items-center justify-center rounded-full border border-kit-line-strong bg-kit-control-bg shadow-kit-xs transition-colors hover:border-[var(--kit-emphasis-line)] data-[checked]:border-kit-accent\",\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator className=\"block size-2 rounded-full bg-kit-accent\" />\n </RadioPrimitive.Root>\n );\n}\n\n/** Large selectable card used for choices (plans, project kinds, roles). */\nexport function ChoiceCard({\n selected,\n onSelect,\n icon,\n title,\n description,\n badge,\n className,\n children,\n}: {\n selected: boolean;\n onSelect: () => void;\n icon?: React.ReactNode;\n title: React.ReactNode;\n description?: React.ReactNode;\n badge?: React.ReactNode;\n className?: string;\n children?: React.ReactNode;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onSelect}\n aria-pressed={selected}\n className={cn(\n \"focus-inset group relative flex w-full flex-col gap-1.5 rounded-kit-lg border bg-kit-control-bg px-3 py-2.5 text-left transition-[border-color,box-shadow,background-color] duration-150\", // inset: option cards often sit in a clipped, gapless list\n selected\n ? \"border-[var(--kit-emphasis-line)] shadow-kit-ring-field\"\n : \"border-kit-line-strong hover:border-[var(--kit-emphasis-line)] hover:shadow-kit-sm\",\n className,\n )}\n >\n <div className=\"flex items-start gap-3\">\n {icon ? (\n <span className={cn(\"mt-0.5 flex shrink-0 items-center justify-center text-kit-fg-2 [&_svg]:size-4\", selected && \"text-kit-fg\")}>\n {icon}\n </span>\n ) : null}\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-center gap-2 text-kit-sm font-medium text-kit-fg\">\n {title}\n {badge}\n </div>\n {description ? <p className=\"mt-0.5 text-[13px] leading-[18px] text-kit-fg-2\">{description}</p> : null}\n </div>\n <span\n className={cn(\n \"mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors\",\n selected ? \"border-kit-inverse bg-kit-inverse text-kit-fg-inverse\" : \"border-kit-line-strong\",\n )}\n >\n {selected ? <IconCheck className=\"size-2.5\" stroke={3.5} /> : null}\n </span>\n </div>\n {children}\n </button>\n );\n}\n\n/** D15: 2–4 choices → one hairline list of compact rows. Wrap <ChoiceCard>s in it; they lose their own card chrome. */\nexport function ChoiceList({ className, children, ...props }: React.HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n role=\"group\"\n className={cn(\n \"flex flex-col divide-y divide-kit-line-subtle overflow-hidden rounded-kit-lg border border-kit-line-strong\",\n \"[&>*]:rounded-none [&>*]:border-0 [&>*]:shadow-none [&>*]:hover:shadow-none [&>*]:hover:bg-kit-hover [&>[aria-pressed=true]]:bg-kit-selected [&>[aria-pressed=true]]:shadow-none\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n}\n\n/* ── Slider ─────────────────────────────────────────────────────────────── */\nexport function Slider({\n className,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n label,\n ...props\n}: Omit<SliderPrimitive.Root.Props<number | readonly number[]>, \"className\"> & {\n className?: string;\n /** accessible name for the thumb(s) */\n label?: string;\n}) {\n const name = ariaLabel ?? label;\n const v = props.value ?? props.defaultValue ?? [0];\n const thumbs = Array.isArray(v) ? v.length : 1;\n return (\n <SliderPrimitive.Root className={cn(\"w-full\", className)} {...props}>\n <SliderPrimitive.Control className=\"relative flex h-5 w-full touch-none select-none items-center\">\n {/* Figma §4.3 slider: 4px track, --fg-2 fill, 12px light thumb with a border (control-thumb lifts off the dark track) */}\n <SliderPrimitive.Track className=\"relative h-1 w-full grow overflow-hidden rounded-full bg-[var(--kit-track-line)]\">\n <SliderPrimitive.Indicator className=\"absolute h-full bg-kit-fg-2\" />\n </SliderPrimitive.Track>\n {Array.from({ length: thumbs }, (_, i) => (\n <SliderPrimitive.Thumb\n key={i}\n index={thumbs > 1 ? i : undefined}\n getAriaLabel={name ? () => name : undefined}\n aria-labelledby={name ? undefined : ariaLabelledby}\n className=\"block size-3 rounded-full border border-kit-line-strong bg-kit-control-thumb shadow-kit-md transition-transform hover:scale-110 has-[:focus-visible]:scale-110 has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-kit-focus-ring has-[:focus-visible]:[outline-style:solid]\"\n />\n ))}\n </SliderPrimitive.Control>\n </SliderPrimitive.Root>\n );\n}\n\n/* V2's overlay <Tooltip> (side bottom, 350ms) for collapsed and icon-only segments, built on the shared ink layer. */\nfunction SegmentTooltip({ content, shortcut, children }: { content: React.ReactNode; shortcut?: string; children: React.ReactElement }) {\n const hints = useShortcutHints();\n return (\n <TooltipScope.Provider value>\n <TooltipRoot>\n <TooltipPrimitive.Trigger delay={350} render={children} />\n <TooltipLayer side=\"bottom\">\n <span className=\"line-clamp-[8] min-w-0 whitespace-normal [overflow-wrap:anywhere]\">{content}</span>\n {shortcut && hints ? (\n <kbd data-hint=\"shortcuts\" className=\"mt-px shrink-0 rounded-kit-sm bg-kit-ink-active px-1 font-kit-sans text-kit-2xs\">\n {shortcut}\n </kbd>\n ) : null}\n </TooltipLayer>\n </TooltipRoot>\n </TooltipScope.Provider>\n );\n}\n\n/* ── Segmented ───────────────────────────────────────────────────────────\n Two deliberate looks (founder: no \"AI-sloppy\" grey pills with counts inside):\n • variant=\"tabs\" (opt-in) — quiet text tabs, muted tabular count, 1.5px animated underline.\n Use for filters, view sections, panel tabs.\n • variant=\"toggle\" (default) — slim hairline-bordered control, subtle selected fill, no shadow.\n Use for binary/ternary switches: list|grid, light|dark, desktop|tablet|mobile.\n Pass `count` on items instead of baking numbers into labels. */\nexport type SegmentedItem<T extends string> = {\n value: T;\n label: React.ReactNode;\n icon?: React.ReactNode;\n disabled?: boolean;\n count?: number;\n tooltip?: React.ReactNode;\n shortcut?: string;\n name?: string;\n};\n\nexport function Segmented<T extends string>({\n value,\n onChange,\n items,\n size = \"md\",\n className,\n layoutId,\n iconOnly,\n collapseInactive,\n variant,\n bordered,\n \"aria-label\": ariaLabel,\n}: {\n \"aria-label\"?: string;\n value: T;\n onChange: (v: T) => void;\n items: SegmentedItem<T>[];\n /** Toggle variant: only the selected item shows its label; the others collapse to icon + tooltip. */\n collapseInactive?: boolean;\n size?: \"sm\" | \"md\";\n className?: string;\n layoutId?: string;\n iconOnly?: boolean;\n variant?: \"tabs\" | \"toggle\";\n /** tabs only: draw a hairline under the whole tab row */\n bordered?: boolean;\n}) {\n const id = React.useId();\n const v = variant ?? \"toggle\";\n const reduceMotion = useReducedMotion();\n const pillTransition = reduceMotion ? { duration: 0 } : PILL_SPRING;\n const onKey = (e: React.KeyboardEvent, i: number) => {\n const enabled = items.filter((x) => !x.disabled);\n const idx = enabled.findIndex((x) => x.value === items[i].value);\n const fwd = e.key === \"ArrowRight\" || e.key === \"ArrowDown\";\n const back = e.key === \"ArrowLeft\" || e.key === \"ArrowUp\";\n const next = fwd\n ? enabled[(idx + 1) % enabled.length]\n : back\n ? enabled[(idx - 1 + enabled.length) % enabled.length]\n : e.key === \"Home\"\n ? enabled[0]\n : e.key === \"End\"\n ? enabled[enabled.length - 1]\n : null;\n if (next) {\n e.preventDefault();\n onChange(next.value);\n // roving tabindex: keep keyboard focus on the newly selected item\n const group = (e.currentTarget as HTMLElement).closest(\"[data-segmented]\");\n requestAnimationFrame(() => group?.querySelector<HTMLElement>(`[data-seg-value=\"${CSS.escape(next.value)}\"]`)?.focus());\n }\n };\n\n if (v === \"tabs\") {\n return (\n <div role=\"tablist\" aria-label={ariaLabel} data-segmented className={cn(\"inline-flex items-center gap-5\", bordered && \"border-b border-kit-line\", className)}>\n {items.map((it, i) => {\n const active = it.value === value;\n return (\n <button\n key={it.value}\n role=\"tab\"\n type=\"button\"\n data-seg-value={it.value}\n aria-selected={active}\n tabIndex={active ? 0 : -1}\n disabled={it.disabled}\n onKeyDown={(e) => onKey(e, i)}\n onClick={() => onChange(it.value)}\n className={cn(\n \"group relative inline-flex items-center justify-center gap-1.5 whitespace-nowrap font-medium tracking-[-0.01em] transition-colors duration-150 disabled:opacity-40 [&_svg]:size-4\",\n size === \"sm\" ? \"h-7 text-kit-xs [&_svg]:size-3.5\" : \"h-8 text-kit-sm\",\n active ? \"text-kit-fg\" : \"text-kit-fg-3 hover:text-kit-fg-2\",\n )}\n >\n {it.icon}\n {iconOnly ? null : it.label}\n {typeof it.count === \"number\" ? (\n <span className={cn(\"text-kit-xs font-normal tabular-nums\", active ? \"text-kit-fg-2\" : \"text-kit-fg-4\")}>{it.count}</span>\n ) : null}\n {active ? (\n <motion.span\n layoutId={layoutId ?? `tab-${id}`}\n transition={pillTransition}\n data-seg-indicator=\"\"\n className={cn(\"absolute inset-x-0 h-[1.5px] rounded-full bg-kit-fg\", bordered ? \"-bottom-px\" : \"bottom-0\")}\n />\n ) : null}\n </button>\n );\n })}\n </div>\n );\n }\n\n return (\n /* Toggle metrics (D29, founder): container 1px border + 2px padding, 2px between items, pill radius = container (6) − 2.\n md items are 28px tall and icon-only items exactly 28×28; sm items 24px. Collapsing items keep the icon at the same\n inset in both states (6px md / 5px sm) — only the label wrapper animates its width, with the icon→label gap inside it. */\n <div role=\"radiogroup\" aria-label={ariaLabel} data-segmented className={cn(\"inline-flex items-center gap-[2px] rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-[2px]\", className)}>\n {items.map((it, i) => {\n const active = it.value === value;\n const sm = size === \"sm\";\n const hasLabel = !iconOnly && it.label !== \"\" && it.label != null;\n const showLabel = hasLabel && (!collapseInactive || active);\n const btn = (\n <button\n key={it.value}\n role=\"radio\"\n type=\"button\"\n data-seg-value={it.value}\n aria-checked={active}\n aria-label={iconOnly && typeof it.label === \"string\" ? it.label : collapseInactive ? it.name : undefined}\n tabIndex={active ? 0 : -1}\n disabled={it.disabled}\n onKeyDown={(e) => onKey(e, i)}\n onClick={() => onChange(it.value)}\n className={cn(\n \"relative inline-flex shrink-0 items-center justify-center whitespace-nowrap rounded-kit-sm font-medium transition-[color,background-color,padding] duration-150 disabled:opacity-40 [&_svg]:size-4 [&_svg]:shrink-0\",\n sm ? \"h-6 text-kit-xs [&_svg]:size-3.5\" : \"h-7 text-kit-sm\",\n iconOnly || !hasLabel\n ? sm ? \"w-6 px-0\" : \"w-7 px-0\"\n : collapseInactive\n ? sm ? (active ? \"pl-[5px] pr-2\" : \"px-[5px]\") : active ? \"pl-1.5 pr-2.5\" : \"px-1.5\"\n : sm ? \"px-2\" : \"px-2.5\",\n active ? \"text-kit-fg\" : \"text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\",\n )}\n >\n {active ? (\n <motion.span\n layoutId={layoutId ?? `seg-${id}`}\n transition={pillTransition}\n data-seg-indicator=\"\"\n className=\"absolute inset-0 rounded-kit-sm bg-kit-selected ring-1 ring-inset ring-kit-line-strong\"\n />\n ) : null}\n <span className={cn(\"relative z-[1] inline-flex items-center\", !collapseInactive && \"gap-1.5\")}>\n {it.icon}\n {!hasLabel ? null : collapseInactive ? (\n <AnimatePresence initial={false}>\n {showLabel ? (\n <motion.span\n key=\"label\"\n initial={{ width: 0, opacity: 0 }}\n animate={{ width: \"auto\", opacity: 1 }}\n exit={{ width: 0, opacity: 0 }}\n transition={reduceMotion ? { duration: 0 } : { duration: 0.18, ease: [0.2, 0, 0, 1] }}\n className=\"inline-flex overflow-hidden\"\n >\n <span className={sm ? \"pl-1\" : \"pl-1.5\"}>{it.label}</span>\n </motion.span>\n ) : null}\n </AnimatePresence>\n ) : (\n it.label\n )}\n {typeof it.count === \"number\" ? <span className=\"text-kit-xs font-normal tabular-nums text-kit-fg-3\">{it.count}</span> : null}\n </span>\n </button>\n );\n if (collapseInactive && it.tooltip)\n return (\n <SegmentTooltip key={it.value} content={it.tooltip} shortcut={it.shortcut}>\n {btn}\n </SegmentTooltip>\n );\n return iconOnly && typeof it.label === \"string\" ? (\n <SegmentTooltip key={it.value} content={it.label}>\n {btn}\n </SegmentTooltip>\n ) : (\n btn\n );\n })}\n </div>\n );\n}\n\n/* ── Toggle group (toolbar style) ───────────────────────────────────────\n One choice (the default) is a radio group in WAI-ARIA: role=\"radiogroup\" with role=\"radio\" + aria-checked items, as\n V2's Radix ToggleGroup type=\"single\" renders. `multiple` keeps group + aria-pressed (independent toggles). The arrow\n keys rove the items either way (Base UI's composite). */\nconst ToggleGroupSingle = React.createContext(false);\nexport function ToggleGroup({ className, ...props }: Omit<ToggleGroupPrimitive.Props, \"className\"> & { className?: string }) {\n const single = !props.multiple;\n return (\n <ToggleGroupSingle.Provider value={single}>\n <ToggleGroupPrimitive\n className={cn(\"inline-flex items-center gap-px rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-[2px]\", className)}\n {...(single ? { role: \"radiogroup\" } : {})}\n {...props}\n />\n </ToggleGroupSingle.Provider>\n );\n}\nexport function ToggleItem({ className, ...props }: Omit<TogglePrimitive.Props, \"className\"> & { className?: string }) {\n const single = React.useContext(ToggleGroupSingle);\n return (\n <TogglePrimitive\n {...(single\n ? { render: (p: React.ComponentProps<\"button\">, state: { pressed: boolean }) => <button {...p} role=\"radio\" aria-checked={state.pressed} aria-pressed={undefined} /> }\n : {})}\n className={cn(\n \"inline-flex h-6 min-w-6 items-center justify-center gap-1 rounded-kit-sm px-1.5 text-kit-xs font-medium text-kit-fg-3 transition-colors hover:bg-kit-hover hover:text-kit-fg data-[pressed]:bg-kit-selected data-[pressed]:ring-1 data-[pressed]:ring-inset data-[pressed]:ring-kit-line-strong data-[pressed]:text-kit-fg [&_svg]:size-3.5\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/* ── Progress ──────────────────────────────────────────────────────────── */\nconst progressTones = {\n success: \"bg-kit-success\",\n accent: \"bg-kit-accent\",\n warning: \"bg-kit-warning\",\n danger: \"bg-kit-danger\",\n // --bar-fill: ink in light, a quiet grey in dark (no near-white glare on a dark track)\n ink: \"bg-[var(--kit-bar-fill)]\",\n brand: \"bg-[var(--kit-bar-fill)]\",\n};\nexport function Progress({\n value,\n className,\n tone = \"success\",\n size = \"md\",\n label = \"Progress\",\n}: {\n value: number;\n className?: string;\n /** accessible name, e.g. \"AI credits used\" */\n label?: string;\n tone?: keyof typeof progressTones;\n size?: \"sm\" | \"md\";\n}) {\n const pct = Math.min(100, Math.max(0, value));\n return (\n <ProgressPrimitive.Root\n value={pct}\n aria-label={label}\n className={cn(\n \"relative w-full overflow-hidden rounded-full bg-[var(--kit-track)]\",\n size === \"sm\" ? \"h-1\" : \"h-1.5\",\n className,\n )}\n >\n <ProgressPrimitive.Indicator\n className={cn(\"h-full rounded-full transition-[width] duration-500 ease-[var(--kit-ease-out-soft)]\", progressTones[tone])}\n style={{ width: `${pct}%` }}\n />\n </ProgressPrimitive.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,IAAM,cAAc;CAAE,MAAM;CAAU,WAAW;CAAK,SAAS;AAAG;AAGlE,SAAgB,OAAO,EACrB,WACA,OAAO,MACP,GAAG,SACmD;CACtD,MAAM,KAAK,SAAS;CACpB,MAAM,aAAa,mBAAmB;CACtC,MAAM,WAAW,YAAY,MAAM,EAAE;CACrC,OACE,oBAAC,SAAgB,MAAjB;EACE,WAAW,GACT,2KACA,KAAK,YAAY,WACjB,SACF;EACA,mBAAiB,MAAM,uBAAuB,MAAM,gBAAgB,KAAA,IAAa,aAAa,MAAM,KAAK,KAAA,IAAY;EACrH,GAAI;EAEJ,UAAA,oBAAC,SAAgB,OAAjB,EACE,WAAW,GACT,6IACA,KAAK,6DAA6D,0DACpE,EACD,CAAA;CACmB,CAAA;AAE1B;;AAIA,SAAgB,SAAS,EACvB,WACA,SACA,GAAG,SACyG;CAC5G,MAAM,gBAAgB,YAAY;CAClC,MAAM,WAAW,YAAY,MAAM,EAAE;CACrC,OACE,oBAAC,WAAkB,MAAnB;EACE,mBAAiB,MAAM,uBAAuB,MAAM,gBAAgB,KAAA,IAAY;EAChF,WAAW,GACT,4UACA,SACF;EACA,SAAS,YAAY,KAAA,IAAY,KAAA,IAAY,YAAY;EAC1C;EACf,GAAI;EAEJ,UAAA,oBAAC,WAAkB,WAAnB;GAA6B,WAAU;GACpC,UAAA,gBAAgB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AAI;EACL,CAAA;CACyB,CAAA;AAEhC;AACA,SAAgB,WAAW,EAAE,WAAW,GAAG,SAA4E;CACrH,MAAM,SAAS,MAAM,WAAW,iBAAiB;CACjD,OACE,oBAAC,QAAD;EACE,GAAK,SACD,EAAE,SAAS,GAAmC,UAAgC,oBAAC,UAAD;GAAQ,GAAI;GAAG,MAAK;GAAQ,gBAAc,MAAM;GAAS,gBAAc,KAAA;EAAY,CAAA,EAAE,IACnK,CAAC;EACL,WAAW,GACT,+UACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAGA,IAAM,gBAAgB;CACpB,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CAER,KAAK;CACL,OAAO;AACT;AACA,SAAgB,SAAS,EACvB,OACA,WACA,OAAO,WACP,OAAO,MACP,QAAQ,cAQP;CACD,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC;CAC5C,OACE,oBAAC,WAAkB,MAAnB;EACE,OAAO;EACP,cAAY;EACZ,WAAW,GACT,sEACA,SAAS,OAAO,QAAQ,SACxB,SACF;EAEA,UAAA,oBAAC,WAAkB,WAAnB;GACE,WAAW,GAAG,uFAAuF,cAAc,KAAK;GACxH,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG;EAC3B,CAAA;CACqB,CAAA;AAE5B"}
1
+ {"version":3,"file":"controls.js","names":[],"sources":["../../src/ui/controls.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Switch as SwitchPrimitive } from \"@base-ui/react/switch\";\nimport { Checkbox as CheckboxPrimitive } from \"@base-ui/react/checkbox\";\nimport { RadioGroup as RadioGroupPrimitive } from \"@base-ui/react/radio-group\";\nimport { Radio as RadioPrimitive } from \"@base-ui/react/radio\";\nimport { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\";\nimport { Slider as SliderPrimitive } from \"@base-ui/react/slider\";\nimport { ToggleGroup as ToggleGroupPrimitive } from \"@base-ui/react/toggle-group\";\nimport { Toggle as TogglePrimitive } from \"@base-ui/react/toggle\";\nimport { Progress as ProgressPrimitive } from \"@base-ui/react/progress\";\nimport { IconCheck, IconMinus } from \"@tabler/icons-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { cn } from \"../lib/cn\";\nimport { useFieldLabelledBy, useLabelFor } from \"./field-context\";\nimport { TooltipScope } from \"./button\";\nimport { useShortcutHints } from \"./shortcut-hint\";\nimport { TooltipLayer, TooltipRoot } from \"./tooltip-root\";\n\n/* Underlines and selected pills share one spring (DESIGN.md 3.6). */\nconst PILL_SPRING = { type: \"spring\", stiffness: 520, damping: 42 } as const;\n\n/* ── Switch ─────────────────────────────────────────────────────────────── */\n/* Forced colours (NEW-Q54-FCSWITCH): the system repaints both fills to Canvas and the track has no border, so the\n switch vanished. Opt out of the repaint and draw it in system colours: off is a ButtonText ring with a ButtonText\n thumb on the left, on is a Highlight track with a HighlightText thumb on the right. The ring is an inset shadow,\n not a border, so the track keeps its size and the thumb its travel. Normal colours are untouched. */\nconst FORCED_TRACK =\n \"forced-colors:forced-color-adjust-none forced-colors:bg-[Canvas] forced-colors:shadow-[inset_0_0_0_1px_ButtonText] forced-colors:data-[checked]:bg-[Highlight] forced-colors:data-[checked]:shadow-[inset_0_0_0_1px_Highlight]\";\nconst FORCED_THUMB =\n \"forced-colors:forced-color-adjust-none forced-colors:bg-[ButtonText] forced-colors:shadow-none forced-colors:data-[checked]:bg-[HighlightText]\";\n\nexport function Switch({\n className,\n size = \"md\",\n ...props\n}: SwitchPrimitive.Root.Props & { size?: \"sm\" | \"md\" }) {\n const sm = size === \"sm\";\n const labelledBy = useFieldLabelledBy();\n const labelFor = useLabelFor(props.id);\n return (\n <SwitchPrimitive.Root\n className={cn(\n \"group relative inline-flex shrink-0 items-center rounded-full bg-kit-switch-off transition-colors duration-200 data-[checked]:bg-kit-success data-[disabled]:opacity-40\",\n sm ? \"h-4 w-7\" : \"h-5 w-9\",\n FORCED_TRACK,\n className,\n )}\n aria-labelledby={props[\"aria-labelledby\"] ?? (props[\"aria-label\"] ? undefined : (labelFor ?? (props.id ? undefined : labelledBy)))}\n {...props}\n >\n <SwitchPrimitive.Thumb\n className={cn(\n \"pointer-events-none block rounded-full bg-kit-control-thumb shadow-kit-sm transition-transform duration-200 ease-[var(--kit-ease-spring)]\",\n sm ? \"size-3 translate-x-0.5 data-[checked]:translate-x-[14px]\" : \"size-4 translate-x-0.5 data-[checked]:translate-x-[18px]\",\n FORCED_THUMB,\n )}\n />\n </SwitchPrimitive.Root>\n );\n}\n\n/* ── Checkbox ───────────────────────────────────────────────────────────── */\n/** `checked` keeps V2's tri-state value: true, false or \"indeterminate\". */\nexport function Checkbox({\n className,\n checked,\n ...props\n}: Omit<CheckboxPrimitive.Root.Props, \"checked\" | \"indeterminate\"> & { checked?: boolean | \"indeterminate\" }) {\n const indeterminate = checked === \"indeterminate\";\n const labelFor = useLabelFor(props.id);\n return (\n <CheckboxPrimitive.Root\n aria-labelledby={props[\"aria-labelledby\"] ?? (props[\"aria-label\"] ? undefined : labelFor)}\n className={cn(\n \"peer flex size-4 shrink-0 items-center justify-center rounded-kit-sm border border-kit-line-strong bg-kit-control-bg shadow-kit-xs transition-colors hover:border-[var(--kit-emphasis-line)] data-[checked]:border-kit-inverse data-[checked]:bg-kit-inverse data-[indeterminate]:border-kit-inverse data-[indeterminate]:bg-kit-inverse\",\n className,\n )}\n checked={checked === undefined ? undefined : checked === true}\n indeterminate={indeterminate}\n {...props}\n >\n <CheckboxPrimitive.Indicator className=\"text-kit-fg-inverse\">\n {indeterminate ? <IconMinus className=\"size-3\" stroke={3} /> : <IconCheck className=\"size-3\" stroke={3} />}\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n}\n\n/* ── Radio ──────────────────────────────────────────────────────────────── */\nexport const RadioGroup = RadioGroupPrimitive;\nexport function Radio({ className, ...props }: RadioPrimitive.Root.Props) {\n return (\n <RadioPrimitive.Root\n className={cn(\n \"flex size-4 shrink-0 items-center justify-center rounded-full border border-kit-line-strong bg-kit-control-bg shadow-kit-xs transition-colors hover:border-[var(--kit-emphasis-line)] data-[checked]:border-kit-accent\",\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator className=\"block size-2 rounded-full bg-kit-accent\" />\n </RadioPrimitive.Root>\n );\n}\n\n/** Large selectable card used for choices (plans, project kinds, roles). */\nexport function ChoiceCard({\n selected,\n onSelect,\n icon,\n title,\n description,\n badge,\n className,\n children,\n}: {\n selected: boolean;\n onSelect: () => void;\n icon?: React.ReactNode;\n title: React.ReactNode;\n description?: React.ReactNode;\n badge?: React.ReactNode;\n className?: string;\n children?: React.ReactNode;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onSelect}\n aria-pressed={selected}\n className={cn(\n \"focus-inset group relative flex w-full flex-col gap-1.5 rounded-kit-lg border bg-kit-control-bg px-3 py-2.5 text-left transition-[border-color,box-shadow,background-color] duration-150\", // inset: option cards often sit in a clipped, gapless list\n selected\n ? \"border-[var(--kit-emphasis-line)] shadow-kit-ring-field\"\n : \"border-kit-line-strong hover:border-[var(--kit-emphasis-line)] hover:shadow-kit-sm\",\n className,\n )}\n >\n <div className=\"flex items-start gap-3\">\n {icon ? (\n <span className={cn(\"mt-0.5 flex shrink-0 items-center justify-center text-kit-fg-2 [&_svg]:size-4\", selected && \"text-kit-fg\")}>\n {icon}\n </span>\n ) : null}\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-center gap-2 text-kit-sm font-medium text-kit-fg\">\n {title}\n {badge}\n </div>\n {description ? <p className=\"mt-0.5 text-[13px] leading-[18px] text-kit-fg-2\">{description}</p> : null}\n </div>\n <span\n className={cn(\n \"mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors\",\n selected ? \"border-kit-inverse bg-kit-inverse text-kit-fg-inverse\" : \"border-kit-line-strong\",\n )}\n >\n {selected ? <IconCheck className=\"size-2.5\" stroke={3.5} /> : null}\n </span>\n </div>\n {children}\n </button>\n );\n}\n\n/** D15: 2–4 choices → one hairline list of compact rows. Wrap <ChoiceCard>s in it; they lose their own card chrome. */\nexport function ChoiceList({ className, children, ...props }: React.HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n role=\"group\"\n className={cn(\n \"flex flex-col divide-y divide-kit-line-subtle overflow-hidden rounded-kit-lg border border-kit-line-strong\",\n \"[&>*]:rounded-none [&>*]:border-0 [&>*]:shadow-none [&>*]:hover:shadow-none [&>*]:hover:bg-kit-hover [&>[aria-pressed=true]]:bg-kit-selected [&>[aria-pressed=true]]:shadow-none\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n}\n\n/* ── Slider ─────────────────────────────────────────────────────────────── */\nexport function Slider({\n className,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n label,\n ...props\n}: Omit<SliderPrimitive.Root.Props<number | readonly number[]>, \"className\"> & {\n className?: string;\n /** accessible name for the thumb(s) */\n label?: string;\n}) {\n const name = ariaLabel ?? label;\n const v = props.value ?? props.defaultValue ?? [0];\n const thumbs = Array.isArray(v) ? v.length : 1;\n return (\n <SliderPrimitive.Root className={cn(\"w-full\", className)} {...props}>\n <SliderPrimitive.Control className=\"relative flex h-5 w-full touch-none select-none items-center\">\n {/* Figma §4.3 slider: 4px track, --fg-2 fill, 12px light thumb with a border (control-thumb lifts off the dark track) */}\n <SliderPrimitive.Track className=\"relative h-1 w-full grow overflow-hidden rounded-full bg-[var(--kit-track-line)]\">\n <SliderPrimitive.Indicator className=\"absolute h-full bg-kit-fg-2\" />\n </SliderPrimitive.Track>\n {Array.from({ length: thumbs }, (_, i) => (\n <SliderPrimitive.Thumb\n key={i}\n index={thumbs > 1 ? i : undefined}\n getAriaLabel={name ? () => name : undefined}\n aria-labelledby={name ? undefined : ariaLabelledby}\n className=\"block size-3 rounded-full border border-kit-line-strong bg-kit-control-thumb shadow-kit-md transition-transform hover:scale-110 has-[:focus-visible]:scale-110 has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-kit-focus-ring has-[:focus-visible]:[outline-style:solid]\"\n />\n ))}\n </SliderPrimitive.Control>\n </SliderPrimitive.Root>\n );\n}\n\n/* V2's overlay <Tooltip> (side bottom, 350ms) for collapsed and icon-only segments, built on the shared ink layer. */\nfunction SegmentTooltip({ content, shortcut, children }: { content: React.ReactNode; shortcut?: string; children: React.ReactElement }) {\n const hints = useShortcutHints();\n return (\n <TooltipScope.Provider value>\n <TooltipRoot>\n <TooltipPrimitive.Trigger delay={350} render={children} />\n <TooltipLayer side=\"bottom\">\n <span className=\"line-clamp-[8] min-w-0 whitespace-normal [overflow-wrap:anywhere]\">{content}</span>\n {shortcut && hints ? (\n <kbd data-hint=\"shortcuts\" className=\"mt-px shrink-0 rounded-kit-sm bg-kit-ink-active px-1 font-kit-sans text-kit-2xs\">\n {shortcut}\n </kbd>\n ) : null}\n </TooltipLayer>\n </TooltipRoot>\n </TooltipScope.Provider>\n );\n}\n\n/* ── Segmented ───────────────────────────────────────────────────────────\n Two deliberate looks (founder: no \"AI-sloppy\" grey pills with counts inside):\n • variant=\"tabs\" (opt-in) — quiet text tabs, muted tabular count, 1.5px animated underline.\n Use for filters, view sections, panel tabs.\n • variant=\"toggle\" (default) — slim hairline-bordered control, subtle selected fill, no shadow.\n Use for binary/ternary switches: list|grid, light|dark, desktop|tablet|mobile.\n Pass `count` on items instead of baking numbers into labels. */\nexport type SegmentedItem<T extends string> = {\n value: T;\n label: React.ReactNode;\n icon?: React.ReactNode;\n disabled?: boolean;\n count?: number;\n tooltip?: React.ReactNode;\n shortcut?: string;\n name?: string;\n};\n\nexport function Segmented<T extends string>({\n value,\n onChange,\n items,\n size = \"md\",\n className,\n layoutId,\n iconOnly,\n collapseInactive,\n variant,\n bordered,\n \"aria-label\": ariaLabel,\n}: {\n \"aria-label\"?: string;\n value: T;\n onChange: (v: T) => void;\n items: SegmentedItem<T>[];\n /** Toggle variant: only the selected item shows its label; the others collapse to icon + tooltip. */\n collapseInactive?: boolean;\n size?: \"sm\" | \"md\";\n className?: string;\n layoutId?: string;\n iconOnly?: boolean;\n variant?: \"tabs\" | \"toggle\";\n /** tabs only: draw a hairline under the whole tab row */\n bordered?: boolean;\n}) {\n const id = React.useId();\n const v = variant ?? \"toggle\";\n const reduceMotion = useReducedMotion();\n const pillTransition = reduceMotion ? { duration: 0 } : PILL_SPRING;\n const onKey = (e: React.KeyboardEvent, i: number) => {\n const enabled = items.filter((x) => !x.disabled);\n const idx = enabled.findIndex((x) => x.value === items[i].value);\n const fwd = e.key === \"ArrowRight\" || e.key === \"ArrowDown\";\n const back = e.key === \"ArrowLeft\" || e.key === \"ArrowUp\";\n const next = fwd\n ? enabled[(idx + 1) % enabled.length]\n : back\n ? enabled[(idx - 1 + enabled.length) % enabled.length]\n : e.key === \"Home\"\n ? enabled[0]\n : e.key === \"End\"\n ? enabled[enabled.length - 1]\n : null;\n if (next) {\n e.preventDefault();\n onChange(next.value);\n // roving tabindex: keep keyboard focus on the newly selected item\n const group = (e.currentTarget as HTMLElement).closest(\"[data-segmented]\");\n requestAnimationFrame(() => group?.querySelector<HTMLElement>(`[data-seg-value=\"${CSS.escape(next.value)}\"]`)?.focus());\n }\n };\n\n if (v === \"tabs\") {\n return (\n <div role=\"tablist\" aria-label={ariaLabel} data-segmented className={cn(\"inline-flex items-center gap-5\", bordered && \"border-b border-kit-line\", className)}>\n {items.map((it, i) => {\n const active = it.value === value;\n return (\n <button\n key={it.value}\n role=\"tab\"\n type=\"button\"\n data-seg-value={it.value}\n aria-selected={active}\n tabIndex={active ? 0 : -1}\n disabled={it.disabled}\n onKeyDown={(e) => onKey(e, i)}\n onClick={() => onChange(it.value)}\n className={cn(\n \"group relative inline-flex items-center justify-center gap-1.5 whitespace-nowrap font-medium tracking-[-0.01em] transition-colors duration-150 disabled:opacity-40 [&_svg]:size-4\",\n size === \"sm\" ? \"h-7 text-kit-xs [&_svg]:size-3.5\" : \"h-8 text-kit-sm\",\n active ? \"text-kit-fg\" : \"text-kit-fg-3 hover:text-kit-fg-2\",\n )}\n >\n {it.icon}\n {iconOnly ? null : it.label}\n {typeof it.count === \"number\" ? (\n <span className={cn(\"text-kit-xs font-normal tabular-nums\", active ? \"text-kit-fg-2\" : \"text-kit-fg-4\")}>{it.count}</span>\n ) : null}\n {active ? (\n <motion.span\n layoutId={layoutId ?? `tab-${id}`}\n transition={pillTransition}\n data-seg-indicator=\"\"\n className={cn(\"absolute inset-x-0 h-[1.5px] rounded-full bg-kit-fg\", bordered ? \"-bottom-px\" : \"bottom-0\")}\n />\n ) : null}\n </button>\n );\n })}\n </div>\n );\n }\n\n return (\n /* Toggle metrics (D29, founder): container 1px border + 2px padding, 2px between items, pill radius = container (6) − 2.\n md items are 28px tall and icon-only items exactly 28×28; sm items 24px. Collapsing items keep the icon at the same\n inset in both states (6px md / 5px sm) — only the label wrapper animates its width, with the icon→label gap inside it. */\n <div role=\"radiogroup\" aria-label={ariaLabel} data-segmented className={cn(\"inline-flex items-center gap-[2px] rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-[2px]\", className)}>\n {items.map((it, i) => {\n const active = it.value === value;\n const sm = size === \"sm\";\n const hasLabel = !iconOnly && it.label !== \"\" && it.label != null;\n const showLabel = hasLabel && (!collapseInactive || active);\n const btn = (\n <button\n key={it.value}\n role=\"radio\"\n type=\"button\"\n data-seg-value={it.value}\n aria-checked={active}\n aria-label={iconOnly && typeof it.label === \"string\" ? it.label : collapseInactive ? it.name : undefined}\n tabIndex={active ? 0 : -1}\n disabled={it.disabled}\n onKeyDown={(e) => onKey(e, i)}\n onClick={() => onChange(it.value)}\n className={cn(\n \"relative inline-flex shrink-0 items-center justify-center whitespace-nowrap rounded-kit-sm font-medium transition-[color,background-color,padding] duration-150 disabled:opacity-40 [&_svg]:size-4 [&_svg]:shrink-0\",\n sm ? \"h-6 text-kit-xs [&_svg]:size-3.5\" : \"h-7 text-kit-sm\",\n iconOnly || !hasLabel\n ? sm ? \"w-6 px-0\" : \"w-7 px-0\"\n : collapseInactive\n ? sm ? (active ? \"pl-[5px] pr-2\" : \"px-[5px]\") : active ? \"pl-1.5 pr-2.5\" : \"px-1.5\"\n : sm ? \"px-2\" : \"px-2.5\",\n active ? \"text-kit-fg\" : \"text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\",\n )}\n >\n {active ? (\n <motion.span\n layoutId={layoutId ?? `seg-${id}`}\n transition={pillTransition}\n data-seg-indicator=\"\"\n className=\"absolute inset-0 rounded-kit-sm bg-kit-selected ring-1 ring-inset ring-kit-line-strong\"\n />\n ) : null}\n <span className={cn(\"relative z-[1] inline-flex items-center\", !collapseInactive && \"gap-1.5\")}>\n {it.icon}\n {!hasLabel ? null : collapseInactive ? (\n <AnimatePresence initial={false}>\n {showLabel ? (\n <motion.span\n key=\"label\"\n initial={{ width: 0, opacity: 0 }}\n animate={{ width: \"auto\", opacity: 1 }}\n exit={{ width: 0, opacity: 0 }}\n transition={reduceMotion ? { duration: 0 } : { duration: 0.18, ease: [0.2, 0, 0, 1] }}\n className=\"inline-flex overflow-hidden\"\n >\n <span className={sm ? \"pl-1\" : \"pl-1.5\"}>{it.label}</span>\n </motion.span>\n ) : null}\n </AnimatePresence>\n ) : (\n it.label\n )}\n {typeof it.count === \"number\" ? <span className=\"text-kit-xs font-normal tabular-nums text-kit-fg-3\">{it.count}</span> : null}\n </span>\n </button>\n );\n if (collapseInactive && it.tooltip)\n return (\n <SegmentTooltip key={it.value} content={it.tooltip} shortcut={it.shortcut}>\n {btn}\n </SegmentTooltip>\n );\n return iconOnly && typeof it.label === \"string\" ? (\n <SegmentTooltip key={it.value} content={it.label}>\n {btn}\n </SegmentTooltip>\n ) : (\n btn\n );\n })}\n </div>\n );\n}\n\n/* ── Toggle group (toolbar style) ───────────────────────────────────────\n One choice (the default) is a radio group in WAI-ARIA: role=\"radiogroup\" with role=\"radio\" + aria-checked items, as\n V2's Radix ToggleGroup type=\"single\" renders. `multiple` keeps group + aria-pressed (independent toggles). The arrow\n keys rove the items either way (Base UI's composite). */\nconst ToggleGroupSingle = React.createContext(false);\nexport function ToggleGroup({ className, ...props }: Omit<ToggleGroupPrimitive.Props, \"className\"> & { className?: string }) {\n const single = !props.multiple;\n return (\n <ToggleGroupSingle.Provider value={single}>\n <ToggleGroupPrimitive\n className={cn(\"inline-flex items-center gap-px rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-[2px]\", className)}\n {...(single ? { role: \"radiogroup\" } : {})}\n {...props}\n />\n </ToggleGroupSingle.Provider>\n );\n}\nexport function ToggleItem({ className, ...props }: Omit<TogglePrimitive.Props, \"className\"> & { className?: string }) {\n const single = React.useContext(ToggleGroupSingle);\n return (\n <TogglePrimitive\n {...(single\n ? { render: (p: React.ComponentProps<\"button\">, state: { pressed: boolean }) => <button {...p} role=\"radio\" aria-checked={state.pressed} aria-pressed={undefined} /> }\n : {})}\n className={cn(\n \"inline-flex h-6 min-w-6 items-center justify-center gap-1 rounded-kit-sm px-1.5 text-kit-xs font-medium text-kit-fg-3 transition-colors hover:bg-kit-hover hover:text-kit-fg data-[pressed]:bg-kit-selected data-[pressed]:ring-1 data-[pressed]:ring-inset data-[pressed]:ring-kit-line-strong data-[pressed]:text-kit-fg [&_svg]:size-3.5\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/* ── Progress ──────────────────────────────────────────────────────────── */\nconst progressTones = {\n success: \"bg-kit-success\",\n accent: \"bg-kit-accent\",\n warning: \"bg-kit-warning\",\n danger: \"bg-kit-danger\",\n // --bar-fill: ink in light, a quiet grey in dark (no near-white glare on a dark track)\n ink: \"bg-[var(--kit-bar-fill)]\",\n brand: \"bg-[var(--kit-bar-fill)]\",\n};\nexport function Progress({\n value,\n className,\n tone = \"success\",\n size = \"md\",\n label = \"Progress\",\n}: {\n value: number;\n className?: string;\n /** accessible name, e.g. \"AI credits used\" */\n label?: string;\n tone?: keyof typeof progressTones;\n size?: \"sm\" | \"md\";\n}) {\n const pct = Math.min(100, Math.max(0, value));\n return (\n <ProgressPrimitive.Root\n value={pct}\n aria-label={label}\n className={cn(\n \"relative w-full overflow-hidden rounded-full bg-[var(--kit-track)]\",\n size === \"sm\" ? \"h-1\" : \"h-1.5\",\n className,\n )}\n >\n <ProgressPrimitive.Indicator\n className={cn(\"h-full rounded-full transition-[width] duration-500 ease-[var(--kit-ease-out-soft)]\", progressTones[tone])}\n style={{ width: `${pct}%` }}\n />\n </ProgressPrimitive.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,IAAM,cAAc;CAAE,MAAM;CAAU,WAAW;CAAK,SAAS;AAAG;AAOlE,IAAM,eACJ;AACF,IAAM,eACJ;AAEF,SAAgB,OAAO,EACrB,WACA,OAAO,MACP,GAAG,SACmD;CACtD,MAAM,KAAK,SAAS;CACpB,MAAM,aAAa,mBAAmB;CACtC,MAAM,WAAW,YAAY,MAAM,EAAE;CACrC,OACE,oBAAC,SAAgB,MAAjB;EACE,WAAW,GACT,2KACA,KAAK,YAAY,WACjB,cACA,SACF;EACA,mBAAiB,MAAM,uBAAuB,MAAM,gBAAgB,KAAA,IAAa,aAAa,MAAM,KAAK,KAAA,IAAY;EACrH,GAAI;EAEJ,UAAA,oBAAC,SAAgB,OAAjB,EACE,WAAW,GACT,6IACA,KAAK,6DAA6D,4DAClE,YACF,EACD,CAAA;CACmB,CAAA;AAE1B;;AAIA,SAAgB,SAAS,EACvB,WACA,SACA,GAAG,SACyG;CAC5G,MAAM,gBAAgB,YAAY;CAClC,MAAM,WAAW,YAAY,MAAM,EAAE;CACrC,OACE,oBAAC,WAAkB,MAAnB;EACE,mBAAiB,MAAM,uBAAuB,MAAM,gBAAgB,KAAA,IAAY;EAChF,WAAW,GACT,4UACA,SACF;EACA,SAAS,YAAY,KAAA,IAAY,KAAA,IAAY,YAAY;EAC1C;EACf,GAAI;EAEJ,UAAA,oBAAC,WAAkB,WAAnB;GAA6B,WAAU;GACpC,UAAA,gBAAgB,oBAAC,WAAD;IAAW,WAAU;IAAS,QAAQ;GAAI,CAAA,IAAI,oBAAC,WAA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G,SAA4E;CACrH,MAAM,SAAS,MAAM,WAAW,iBAAiB;CACjD,OACE,oBAAC,QAAD;EACE,GAAK,SACD,EAAE,SAAS,GAAmC,UAAgC,oBAAC,UAAD;GAAQ,GAAI;GAAG,MAAK;GAAQ,gBAAc,MAAM;GAAS,gBAAc,KAAA;EAAY,CAAA,EAAE,IACnK,CAAC;EACL,WAAW,GACT,+UACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAGA,IAAM,gBAAgB;CACpB,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CAER,KAAK;CACL,OAAO;AACT;AACA,SAAgB,SAAS,EACvB,OACA,WACA,OAAO,WACP,OAAO,MACP,QAAQ,cAQP;CACD,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC;CAC5C,OACE,oBAAC,WAAkB,MAAnB;EACE,OAAO;EACP,cAAY;EACZ,WAAW,GACT,sEACA,SAAS,OAAO,QAAQ,SACxB,SACF;EAEA,UAAA,oBAAC,WAAkB,WAAnB;GACE,WAAW,GAAG,uFAAuF,cAAc,KAAK;GACxH,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG;EAC3B,CAAA;CACqB,CAAA;AAE5B"}
package/dist/ui/input.js CHANGED
@@ -12,6 +12,45 @@ import { IconInfoCircle, IconSearch, IconX } from "@tabler/icons-react";
12
12
  * Heights follow buttons: sm 28 · md 32 · lg 36.
13
13
  */
14
14
  var joinIds = (...ids) => ids.filter(Boolean).join(" ") || void 0;
15
+ /**
16
+ * An IME composition is ONE edit (NEW-Q54-DOCKIME). React fires onChange for every composition step (romaji, kana,
17
+ * each candidate), and a host that saves on change saved them all: one Japanese word in a dock text field was 16
18
+ * page versions. While a composition runs, the field shows the composing text from a local draft (a controlled
19
+ * field would otherwise be reset to its old value, which breaks the IME) and the owner's onChange waits; on
20
+ * compositionend it gets the committed text once. A browser that sends a last input event after compositionend
21
+ * with the same text (Safari) is not passed on twice. Typing without an IME never composes, so nothing changes there.
22
+ */
23
+ function useCompositionHold({ value, onChange, onCompositionStart, onCompositionEnd }) {
24
+ const [draft, setDraft] = React.useState(null);
25
+ const composing = React.useRef(false);
26
+ const committed = React.useRef(null);
27
+ const controlled = value !== void 0;
28
+ return {
29
+ value: controlled && draft !== null ? draft : value,
30
+ onChange: (e) => {
31
+ if (composing.current) {
32
+ if (controlled) setDraft(e.target.value);
33
+ return;
34
+ }
35
+ const again = committed.current === e.target.value;
36
+ committed.current = null;
37
+ if (!again) onChange?.(e);
38
+ },
39
+ onCompositionStart: (e) => {
40
+ composing.current = true;
41
+ committed.current = null;
42
+ if (controlled) setDraft(e.currentTarget.value);
43
+ onCompositionStart?.(e);
44
+ },
45
+ onCompositionEnd: (e) => {
46
+ composing.current = false;
47
+ setDraft(null);
48
+ committed.current = e.currentTarget.value;
49
+ onChange?.(e);
50
+ onCompositionEnd?.(e);
51
+ }
52
+ };
53
+ }
15
54
  var base = "w-full min-w-0 rounded-kit-md border border-kit-field-border bg-kit-field-bg text-kit-fg shadow-kit-field placeholder:text-kit-fg-4 transition-[border-color,box-shadow] duration-150 hover:border-kit-field-border-hover focus:border-kit-field-border-focus focus:shadow-kit-ring-field disabled:cursor-not-allowed disabled:bg-kit-subtle disabled:opacity-60 aria-[invalid=true]:border-[var(--kit-field-invalid)]";
16
55
  var Input = React.forwardRef(({ className, size = "md", leading, trailing, variant = "outline", ...rest }, ref) => {
17
56
  const fieldId = useFieldId();
@@ -19,8 +58,10 @@ var Input = React.forwardRef(({ className, size = "md", leading, trailing, varia
19
58
  const named = rest.id ?? fieldId ?? rest["aria-label"] ?? rest["aria-labelledby"];
20
59
  const labelFor = useLabelFor(rest.id ?? fieldId);
21
60
  const describedBy = useFieldDescribedBy();
61
+ const hold = useCompositionHold(rest);
22
62
  const props = {
23
63
  ...rest,
64
+ ...hold,
24
65
  id: rest.id ?? fieldId,
25
66
  "aria-labelledby": rest["aria-labelledby"] ?? (rest["aria-label"] ? void 0 : labelFor ?? (named ? void 0 : labelledBy)),
26
67
  "aria-describedby": joinIds(rest["aria-describedby"], describedBy)
@@ -56,8 +97,10 @@ var Textarea = React.forwardRef(({ className, autoGrow = true, variant = "outlin
56
97
  const fieldId = useFieldId();
57
98
  const labelFor = useLabelFor(rest.id ?? fieldId);
58
99
  const describedBy = useFieldDescribedBy();
100
+ const hold = useCompositionHold(rest);
59
101
  const props = {
60
102
  ...rest,
103
+ ...hold,
61
104
  id: rest.id ?? fieldId,
62
105
  "aria-labelledby": rest["aria-labelledby"] ?? (rest["aria-label"] ? void 0 : labelFor),
63
106
  "aria-describedby": joinIds(rest["aria-describedby"], describedBy)
@@ -1 +1 @@
1
- {"version":3,"file":"input.js","names":[],"sources":["../../src/ui/input.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { IconInfoCircle, IconSearch, IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { HintTooltip } from \"./button\";\nimport { useShortcutHints } from \"./shortcut-hint\";\n\n/**\n * Inputs — CPO D19: white field + 1px --field-border at rest (default \"outline\"), border darkens on hover, halo on focus.\n * \"filled\" (grey, borderless) is kept only for search fields, which Figma draws grey.\n * Heights follow buttons: sm 28 · md 32 · lg 36.\n */\nimport {\n FieldDescribedByContext,\n FieldIdContext,\n FieldLabelledByContext,\n useFieldDescribedBy,\n useFieldId,\n useFieldLabelledBy,\n useLabelFor,\n} from \"./field-context\";\n/* The Field contexts live in field-context.ts so controls in other files (Switch, Select) read the same ones. */\nexport { FieldDescribedByContext, FieldLabelledByContext, useFieldDescribedBy, useFieldId, useFieldLabelledBy };\n\nconst joinIds = (...ids: (string | undefined)[]) => ids.filter(Boolean).join(\" \") || undefined;\n\nconst base =\n \"w-full min-w-0 rounded-kit-md border border-kit-field-border bg-kit-field-bg text-kit-fg shadow-kit-field placeholder:text-kit-fg-4 transition-[border-color,box-shadow] duration-150 hover:border-kit-field-border-hover focus:border-kit-field-border-focus focus:shadow-kit-ring-field disabled:cursor-not-allowed disabled:bg-kit-subtle disabled:opacity-60 aria-[invalid=true]:border-[var(--kit-field-invalid)]\";\n\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"prefix\"> {\n size?: \"sm\" | \"md\" | \"lg\";\n leading?: React.ReactNode;\n trailing?: React.ReactNode;\n variant?: \"filled\" | \"outline\";\n}\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ className, size = \"md\", leading, trailing, variant = \"outline\", ...rest }, ref) => {\n const fieldId = useFieldId();\n const labelledBy = useFieldLabelledBy();\n const named = rest.id ?? fieldId ?? rest[\"aria-label\"] ?? rest[\"aria-labelledby\"];\n const labelFor = useLabelFor(rest.id ?? fieldId);\n const describedBy = useFieldDescribedBy();\n const props = {\n ...rest,\n id: rest.id ?? fieldId,\n \"aria-labelledby\": rest[\"aria-labelledby\"] ?? (rest[\"aria-label\"] ? undefined : (labelFor ?? (named ? undefined : labelledBy))),\n \"aria-describedby\": joinIds(rest[\"aria-describedby\"], describedBy),\n };\n const h = size === \"sm\" ? \"h-7 text-kit-sm\" : size === \"lg\" ? \"h-9 text-kit-base\" : \"h-8 text-kit-sm\";\n const v = variant === \"filled\" ? \"bg-kit-muted border-transparent shadow-none hover:border-kit-line-strong\" : \"\";\n if (!leading && !trailing) return <input ref={ref} className={cn(base, h, v, \"px-2.5\", className)} {...props} />;\n return (\n <div className={cn(\"relative flex items-center\", className)}>\n {leading ? (\n <span className=\"pointer-events-none absolute left-2.5 flex text-kit-fg-3 [&_svg]:size-4\">{leading}</span>\n ) : null}\n <input ref={ref} className={cn(base, h, v, leading ? \"pl-8\" : \"pl-2.5\", trailing ? \"pr-8\" : \"pr-2.5\")} {...props} />\n {trailing ? <span className=\"absolute right-2 flex items-center text-kit-fg-3 [&_svg]:size-4\">{trailing}</span> : null}\n </div>\n );\n },\n);\nInput.displayName = \"Input\";\n\nexport type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & { autoGrow?: boolean; variant?: \"filled\" | \"outline\" };\n\nexport const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(\n ({ className, autoGrow = true, variant = \"outline\", onInput, ...rest }, ref) => {\n const fieldId = useFieldId();\n const labelFor = useLabelFor(rest.id ?? fieldId);\n const describedBy = useFieldDescribedBy();\n const props = {\n ...rest,\n id: rest.id ?? fieldId,\n \"aria-labelledby\": rest[\"aria-labelledby\"] ?? (rest[\"aria-label\"] ? undefined : labelFor),\n \"aria-describedby\": joinIds(rest[\"aria-describedby\"], describedBy),\n };\n const inner = React.useRef<HTMLTextAreaElement | null>(null);\n React.useImperativeHandle(ref, () => inner.current as HTMLTextAreaElement);\n const grow = () => {\n const el = inner.current;\n if (!el || !autoGrow || !el.clientWidth) return; // hidden / zero-width: measuring now would be wrong\n el.style.height = \"auto\";\n el.style.height = `${el.scrollHeight + 2}px`;\n };\n React.useLayoutEffect(grow, [props.value, autoGrow]); // eslint-disable-line react-hooks/exhaustive-deps\n /* Re-measure when the WIDTH changes (a panel resize or a panel that mounts mid-animation): a height measured at a\n narrower width is stale and leaves single-line fields hundreds of px tall. Height-only changes are ignored, so\n the observer never feeds itself. */\n React.useEffect(() => {\n const el = inner.current;\n if (!el || !autoGrow || typeof ResizeObserver === \"undefined\") return;\n let w = el.clientWidth;\n let raf = 0;\n const ro = new ResizeObserver(() => {\n const nw = el.clientWidth;\n if (nw === w) return;\n w = nw;\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(grow);\n });\n ro.observe(el);\n return () => {\n cancelAnimationFrame(raf);\n ro.disconnect();\n };\n }, [autoGrow]); // eslint-disable-line react-hooks/exhaustive-deps\n /* KP-226: the text can change height with no change to the value or the width: a web font arriving, or the\n browser's zoom / text size changing. Neither resizes the box (its height is set inline), so no observer fires;\n re-measure when fonts finish loading and when the window resizes (a zoom change is one). */\n React.useEffect(() => {\n if (!autoGrow) return;\n const again = () => grow();\n const fonts = typeof document !== \"undefined\" ? document.fonts : undefined;\n void fonts?.ready?.then(again);\n fonts?.addEventListener?.(\"loadingdone\", again);\n window.addEventListener(\"resize\", again);\n return () => {\n fonts?.removeEventListener?.(\"loadingdone\", again);\n window.removeEventListener(\"resize\", again);\n };\n }, [autoGrow]); // eslint-disable-line react-hooks/exhaustive-deps\n return (\n <textarea\n ref={inner}\n rows={props.rows ?? 2}\n onInput={(e) => {\n grow();\n onInput?.(e);\n }}\n className={cn(\n base,\n \"min-h-16 resize-none px-2.5 py-2 text-kit-sm leading-[20px]\",\n variant === \"filled\" && \"bg-kit-muted border-transparent shadow-none\",\n className,\n )}\n {...props}\n />\n );\n },\n);\nTextarea.displayName = \"Textarea\";\n\nexport function SearchInput({\n value,\n onChange,\n placeholder = \"Search…\",\n className,\n size = \"md\",\n autoFocus,\n shortcut,\n variant = \"filled\",\n count,\n onKeyDown,\n inputRef,\n \"aria-label\": ariaLabel,\n}: {\n \"aria-label\"?: string;\n value: string;\n onChange: (v: string) => void;\n placeholder?: string;\n className?: string;\n size?: \"sm\" | \"md\" | \"lg\";\n autoFocus?: boolean;\n /** Shown only while the D44 keyboard hints switch is on. */\n shortcut?: string;\n /**\n * \"filled\" (grey) for search on white surfaces (menus, sidebars, lists); \"outline\" is the standard field (field-bg,\n * field-border) for search that sits on a grey plane, where a grey fill reads as a pill, not a field (D70, the schema desk).\n */\n variant?: \"filled\" | \"outline\";\n /** a result count shown inside the field while there is a query (\"3 matches\", \"2 of 5\"); announced politely */\n count?: string;\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n inputRef?: React.Ref<HTMLInputElement>;\n}) {\n const hints = useShortcutHints();\n return (\n <Input\n ref={inputRef}\n variant={variant}\n size={size}\n autoFocus={autoFocus}\n value={value}\n placeholder={placeholder}\n aria-label={ariaLabel ?? placeholder.replace(/…$/, \"\")}\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={onKeyDown}\n leading={<IconSearch aria-hidden />}\n className={cn(className, value && count ? \"[&_input]:pr-28\" : undefined)}\n trailing={\n value ? (\n <span className=\"flex items-center gap-1.5\">\n {count ? (\n <span aria-live=\"polite\" className=\"whitespace-nowrap text-kit-xs tabular-nums text-kit-fg-3\">\n {count}\n </span>\n ) : null}\n <button\n type=\"button\"\n aria-label=\"Clear search\"\n onClick={() => onChange(\"\")}\n className=\"flex size-5 items-center justify-center rounded-kit-sm text-kit-fg-3 hover:bg-kit-selected hover:text-kit-fg [&_svg]:size-3.5\"\n >\n <IconX aria-hidden />\n </button>\n </span>\n ) : shortcut && hints ? (\n <kbd data-hint=\"shortcuts\" className=\"font-kit-sans text-kit-2xs text-kit-fg-3\">\n {shortcut}\n </kbd>\n ) : undefined\n }\n />\n );\n}\n\nexport function Label({ className, ...props }: React.LabelHTMLAttributes<HTMLLabelElement>) {\n return <label className={cn(\"text-kit-sm font-medium text-kit-fg\", className)} {...props} />;\n}\n\n/**\n * Field = label row · help · control · error. CPO D39, the one help system (same spec as the Block Kit FieldShell):\n * [Label *] [hint] [i helpMore] …… [counter] [actions]\n * help: 12/16, --fg-3 (≥4.5:1 light + dark), 4px under the label, 1–2 lines\n * control\n * error: replaces the help, danger colour, under the control\n * The control gets `aria-describedby` → help + ⓘ text + error.\n * Required marker is V2 ui/input.tsx:249 (--danger-fg); the sr-only \"(required)\" names it for screen readers.\n */\nexport function Field({\n label,\n htmlFor,\n hint,\n help,\n helpMore,\n error,\n required,\n counter,\n actions,\n children,\n className,\n}: {\n label?: React.ReactNode;\n htmlFor?: string;\n /** short, quiet aside on the label row (\"Optional\", \"Shown publicly\") */\n hint?: React.ReactNode;\n /** the help line under the label */\n help?: React.ReactNode;\n /** longer explanation behind the ⓘ next to the label */\n helpMore?: React.ReactNode;\n error?: React.ReactNode;\n required?: boolean;\n counter?: { value: number; max: number };\n actions?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n}) {\n const autoId = React.useId();\n const id = htmlFor ?? autoId;\n const helpId = `${id}-help`;\n const moreId = `${id}-more`;\n const errId = `${id}-error`;\n const describedBy = [error ? errId : help ? helpId : null, helpMore ? moreId : null].filter(Boolean).join(\" \") || undefined;\n return (\n <div className={cn(\"flex flex-col gap-1.5\", className)}>\n {label || actions || counter ? (\n <div className=\"flex min-h-5 items-center justify-between gap-2\">\n <span className=\"flex min-w-0 items-center gap-1\">\n <Label htmlFor={label ? id : undefined} className=\"flex items-center gap-1.5 text-kit-sm text-kit-fg-2\">\n {label}\n {required ? (\n <>\n <span aria-hidden className=\"text-kit-danger-fg\">*</span>\n <span className=\"sr-only\">(required)</span>\n </>\n ) : null}\n {hint ? <span className=\"font-normal text-kit-fg-3\">{hint}</span> : null}\n </Label>\n {helpMore ? (\n <HelpMore id={moreId} label={typeof label === \"string\" ? label : undefined}>\n {helpMore}\n </HelpMore>\n ) : null}\n </span>\n <div className=\"flex items-center gap-1\">\n {counter ? (\n <span\n className={cn(\n \"tabular-nums text-kit-xs\",\n counter.value > counter.max\n ? \"text-kit-danger-fg\"\n : counter.value > counter.max * 0.9\n ? \"text-kit-warning-fg\"\n : \"text-kit-fg-3\",\n )}\n >\n {counter.value}/{counter.max}\n </span>\n ) : null}\n {actions}\n </div>\n </div>\n ) : null}\n {help && !error ? (\n <p id={helpId} data-slot=\"field-help\" className=\"-mt-0.5 text-kit-xs leading-4 text-kit-fg-3\">\n {help}\n </p>\n ) : null}\n <FieldIdContext.Provider value={label ? id : undefined}>\n <FieldDescribedByContext.Provider value={describedBy}>{children}</FieldDescribedByContext.Provider>\n </FieldIdContext.Provider>\n {error ? (\n <p id={errId} role=\"alert\" className=\"text-kit-xs leading-4 text-kit-danger-fg\">\n {error}\n </p>\n ) : null}\n </div>\n );\n}\n\n/** The ⓘ next to a label: longer help in a tooltip, also read by screen readers through aria-describedby (D39). */\nexport function HelpMore({ id, label, children }: { id?: string; label?: string; children: React.ReactNode }) {\n return (\n <HintTooltip content={<span className=\"block max-w-[260px] whitespace-normal font-normal leading-4\">{children}</span>}>\n <button\n type=\"button\"\n aria-label={label ? `About ${label}` : \"More about this field\"}\n className=\"hit-area inline-flex size-4 shrink-0 items-center justify-center rounded-kit-sm text-kit-fg-4 [--hit-size:16px] hover:text-kit-fg-2\"\n >\n <IconInfoCircle className=\"size-3.5\" stroke={1.5} aria-hidden />\n <span id={id} className=\"sr-only\">\n {children}\n </span>\n </button>\n </HintTooltip>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAM,WAAW,GAAG,QAAgC,IAAI,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;AAErF,IAAM,OACJ;AASF,IAAa,QAAQ,MAAM,YACxB,EAAE,WAAW,OAAO,MAAM,SAAS,UAAU,UAAU,WAAW,GAAG,QAAQ,QAAQ;CACpF,MAAM,UAAU,WAAW;CAC3B,MAAM,aAAa,mBAAmB;CACtC,MAAM,QAAQ,KAAK,MAAM,WAAW,KAAK,iBAAiB,KAAK;CAC/D,MAAM,WAAW,YAAY,KAAK,MAAM,OAAO;CAC/C,MAAM,cAAc,oBAAoB;CACxC,MAAM,QAAQ;EACZ,GAAG;EACH,IAAI,KAAK,MAAM;EACf,mBAAmB,KAAK,uBAAuB,KAAK,gBAAgB,KAAA,IAAa,aAAa,QAAQ,KAAA,IAAY;EAClH,oBAAoB,QAAQ,KAAK,qBAAqB,WAAW;CACnE;CACA,MAAM,IAAI,SAAS,OAAO,oBAAoB,SAAS,OAAO,sBAAsB;CACpF,MAAM,IAAI,YAAY,WAAW,6EAA6E;CAC9G,IAAI,CAAC,WAAW,CAAC,UAAU,OAAO,oBAAC,SAAD;EAAY;EAAK,WAAW,GAAG,MAAM,GAAG,GAAG,UAAU,SAAS;EAAG,GAAI;CAAQ,CAAA;CAC/G,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,8BAA8B,SAAS;EAA1D,UAAA;GACG,UACC,oBAAC,QAAD;IAAM,WAAU;IAA2E,UAAA;GAAc,CAAA,IACvG;GACJ,oBAAC,SAAD;IAAY;IAAK,WAAW,GAAG,MAAM,GAAG,GAAG,UAAU,SAAS,UAAU,WAAW,SAAS,QAAQ;IAAG,GAAI;GAAQ,CAAA;GACl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AAC,QAAD;MACE,WAAW,GACT,4BACA,QAAQ,QAAQ,QAAQ,MACpB,uBACA,QAAQ,QAAQ,QAAQ,MAAM,KAC5B,wBACA,eACR;MARF,UAAA;OAUG,QAAQ;OAAM;OAAE,QAAQ;MACrB;KACJ,CAAA,IAAA,MACH,OACE;IACF,CAAA,CAAA;GACH,CAAA,IAAA;GACH,QAAQ,CAAC,QACR,oBAAC,KAAD;IAAG,IAAI;IAAQ,aAAU;IAAa,WAAU;IAC7C,UAAA;GACA,CAAA,IACD;GACJ,oBAAC,eAAe,UAAhB;IAAyB,OAAO,QAAQ,KAAK,KAAA;IAC3C,UAAA,oBAAC,wBAAwB,UAAzB;KAAkC,OAAO;KAAc;IAA2C,CAAA;GAC3E,CAAA;GACxB,QACC,oBAAC,KAAD;IAAG,IAAI;IAAO,MAAK;IAAQ,WAAU;IAClC,UAAA;GACA,CAAA,IACD;EACD;;AAET;;AAGA,SAAgB,SAAS,EAAE,IAAI,OAAO,YAAwE;CAC5G,OACE,oBAAC,aAAD;EAAa,SAAS,oBAAC,QAAD;GAAM,WAAU;GAA+D;EAAe,CAAA;EAClH,UAAA,qBAAC,UAAD;GACE,MAAK;GACL,cAAY,QAAQ,SAAS,UAAU;GACvC,WAAU;GAHZ,UAAA,CAKE,oBAAC,gBAAD;IAAgB,WAAU;IAAW,QAAQ;IAAK,eAAA;GAAa,CAAA,GAC/D,oBAAC,QAAD;IAAU;IAAI,WAAU;IACrB;GACG,CAAA,CACA;;CACG,CAAA;AAEjB"}
1
+ {"version":3,"file":"input.js","names":[],"sources":["../../src/ui/input.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { IconInfoCircle, IconSearch, IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { HintTooltip } from \"./button\";\nimport { useShortcutHints } from \"./shortcut-hint\";\n\n/**\n * Inputs — CPO D19: white field + 1px --field-border at rest (default \"outline\"), border darkens on hover, halo on focus.\n * \"filled\" (grey, borderless) is kept only for search fields, which Figma draws grey.\n * Heights follow buttons: sm 28 · md 32 · lg 36.\n */\nimport {\n FieldDescribedByContext,\n FieldIdContext,\n FieldLabelledByContext,\n useFieldDescribedBy,\n useFieldId,\n useFieldLabelledBy,\n useLabelFor,\n} from \"./field-context\";\n/* The Field contexts live in field-context.ts so controls in other files (Switch, Select) read the same ones. */\nexport { FieldDescribedByContext, FieldLabelledByContext, useFieldDescribedBy, useFieldId, useFieldLabelledBy };\n\nconst joinIds = (...ids: (string | undefined)[]) => ids.filter(Boolean).join(\" \") || undefined;\n\n/**\n * An IME composition is ONE edit (NEW-Q54-DOCKIME). React fires onChange for every composition step (romaji, kana,\n * each candidate), and a host that saves on change saved them all: one Japanese word in a dock text field was 16\n * page versions. While a composition runs, the field shows the composing text from a local draft (a controlled\n * field would otherwise be reset to its old value, which breaks the IME) and the owner's onChange waits; on\n * compositionend it gets the committed text once. A browser that sends a last input event after compositionend\n * with the same text (Safari) is not passed on twice. Typing without an IME never composes, so nothing changes there.\n */\nfunction useCompositionHold<E extends HTMLInputElement | HTMLTextAreaElement>({\n value,\n onChange,\n onCompositionStart,\n onCompositionEnd,\n}: Pick<React.InputHTMLAttributes<E>, \"value\" | \"onChange\" | \"onCompositionStart\" | \"onCompositionEnd\">) {\n const [draft, setDraft] = React.useState<string | null>(null);\n const composing = React.useRef(false);\n const committed = React.useRef<string | null>(null);\n const controlled = value !== undefined;\n return {\n value: controlled && draft !== null ? draft : value,\n onChange: (e: React.ChangeEvent<E>) => {\n if (composing.current) {\n if (controlled) setDraft(e.target.value);\n return;\n }\n const again = committed.current === e.target.value;\n committed.current = null;\n if (!again) onChange?.(e);\n },\n onCompositionStart: (e: React.CompositionEvent<E>) => {\n composing.current = true;\n committed.current = null;\n if (controlled) setDraft(e.currentTarget.value);\n onCompositionStart?.(e);\n },\n onCompositionEnd: (e: React.CompositionEvent<E>) => {\n composing.current = false;\n setDraft(null);\n committed.current = e.currentTarget.value;\n // the committed text, through the owner's own handler (it reads e.target.value, which is the field)\n onChange?.(e as unknown as React.ChangeEvent<E>);\n onCompositionEnd?.(e);\n },\n };\n}\n\nconst base =\n \"w-full min-w-0 rounded-kit-md border border-kit-field-border bg-kit-field-bg text-kit-fg shadow-kit-field placeholder:text-kit-fg-4 transition-[border-color,box-shadow] duration-150 hover:border-kit-field-border-hover focus:border-kit-field-border-focus focus:shadow-kit-ring-field disabled:cursor-not-allowed disabled:bg-kit-subtle disabled:opacity-60 aria-[invalid=true]:border-[var(--kit-field-invalid)]\";\n\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"prefix\"> {\n size?: \"sm\" | \"md\" | \"lg\";\n leading?: React.ReactNode;\n trailing?: React.ReactNode;\n variant?: \"filled\" | \"outline\";\n}\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ className, size = \"md\", leading, trailing, variant = \"outline\", ...rest }, ref) => {\n const fieldId = useFieldId();\n const labelledBy = useFieldLabelledBy();\n const named = rest.id ?? fieldId ?? rest[\"aria-label\"] ?? rest[\"aria-labelledby\"];\n const labelFor = useLabelFor(rest.id ?? fieldId);\n const describedBy = useFieldDescribedBy();\n const hold = useCompositionHold<HTMLInputElement>(rest);\n const props = {\n ...rest,\n ...hold,\n id: rest.id ?? fieldId,\n \"aria-labelledby\": rest[\"aria-labelledby\"] ?? (rest[\"aria-label\"] ? undefined : (labelFor ?? (named ? undefined : labelledBy))),\n \"aria-describedby\": joinIds(rest[\"aria-describedby\"], describedBy),\n };\n const h = size === \"sm\" ? \"h-7 text-kit-sm\" : size === \"lg\" ? \"h-9 text-kit-base\" : \"h-8 text-kit-sm\";\n const v = variant === \"filled\" ? \"bg-kit-muted border-transparent shadow-none hover:border-kit-line-strong\" : \"\";\n if (!leading && !trailing) return <input ref={ref} className={cn(base, h, v, \"px-2.5\", className)} {...props} />;\n return (\n <div className={cn(\"relative flex items-center\", className)}>\n {leading ? (\n <span className=\"pointer-events-none absolute left-2.5 flex text-kit-fg-3 [&_svg]:size-4\">{leading}</span>\n ) : null}\n <input ref={ref} className={cn(base, h, v, leading ? \"pl-8\" : \"pl-2.5\", trailing ? \"pr-8\" : \"pr-2.5\")} {...props} />\n {trailing ? <span className=\"absolute right-2 flex items-center text-kit-fg-3 [&_svg]:size-4\">{trailing}</span> : null}\n </div>\n );\n },\n);\nInput.displayName = \"Input\";\n\nexport type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & { autoGrow?: boolean; variant?: \"filled\" | \"outline\" };\n\nexport const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(\n ({ className, autoGrow = true, variant = \"outline\", onInput, ...rest }, ref) => {\n const fieldId = useFieldId();\n const labelFor = useLabelFor(rest.id ?? fieldId);\n const describedBy = useFieldDescribedBy();\n const hold = useCompositionHold<HTMLTextAreaElement>(rest);\n const props = {\n ...rest,\n ...hold,\n id: rest.id ?? fieldId,\n \"aria-labelledby\": rest[\"aria-labelledby\"] ?? (rest[\"aria-label\"] ? undefined : labelFor),\n \"aria-describedby\": joinIds(rest[\"aria-describedby\"], describedBy),\n };\n const inner = React.useRef<HTMLTextAreaElement | null>(null);\n React.useImperativeHandle(ref, () => inner.current as HTMLTextAreaElement);\n const grow = () => {\n const el = inner.current;\n if (!el || !autoGrow || !el.clientWidth) return; // hidden / zero-width: measuring now would be wrong\n el.style.height = \"auto\";\n el.style.height = `${el.scrollHeight + 2}px`;\n };\n React.useLayoutEffect(grow, [props.value, autoGrow]); // eslint-disable-line react-hooks/exhaustive-deps\n /* Re-measure when the WIDTH changes (a panel resize or a panel that mounts mid-animation): a height measured at a\n narrower width is stale and leaves single-line fields hundreds of px tall. Height-only changes are ignored, so\n the observer never feeds itself. */\n React.useEffect(() => {\n const el = inner.current;\n if (!el || !autoGrow || typeof ResizeObserver === \"undefined\") return;\n let w = el.clientWidth;\n let raf = 0;\n const ro = new ResizeObserver(() => {\n const nw = el.clientWidth;\n if (nw === w) return;\n w = nw;\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(grow);\n });\n ro.observe(el);\n return () => {\n cancelAnimationFrame(raf);\n ro.disconnect();\n };\n }, [autoGrow]); // eslint-disable-line react-hooks/exhaustive-deps\n /* KP-226: the text can change height with no change to the value or the width: a web font arriving, or the\n browser's zoom / text size changing. Neither resizes the box (its height is set inline), so no observer fires;\n re-measure when fonts finish loading and when the window resizes (a zoom change is one). */\n React.useEffect(() => {\n if (!autoGrow) return;\n const again = () => grow();\n const fonts = typeof document !== \"undefined\" ? document.fonts : undefined;\n void fonts?.ready?.then(again);\n fonts?.addEventListener?.(\"loadingdone\", again);\n window.addEventListener(\"resize\", again);\n return () => {\n fonts?.removeEventListener?.(\"loadingdone\", again);\n window.removeEventListener(\"resize\", again);\n };\n }, [autoGrow]); // eslint-disable-line react-hooks/exhaustive-deps\n return (\n <textarea\n ref={inner}\n rows={props.rows ?? 2}\n onInput={(e) => {\n grow();\n onInput?.(e);\n }}\n className={cn(\n base,\n \"min-h-16 resize-none px-2.5 py-2 text-kit-sm leading-[20px]\",\n variant === \"filled\" && \"bg-kit-muted border-transparent shadow-none\",\n className,\n )}\n {...props}\n />\n );\n },\n);\nTextarea.displayName = \"Textarea\";\n\nexport function SearchInput({\n value,\n onChange,\n placeholder = \"Search…\",\n className,\n size = \"md\",\n autoFocus,\n shortcut,\n variant = \"filled\",\n count,\n onKeyDown,\n inputRef,\n \"aria-label\": ariaLabel,\n}: {\n \"aria-label\"?: string;\n value: string;\n onChange: (v: string) => void;\n placeholder?: string;\n className?: string;\n size?: \"sm\" | \"md\" | \"lg\";\n autoFocus?: boolean;\n /** Shown only while the D44 keyboard hints switch is on. */\n shortcut?: string;\n /**\n * \"filled\" (grey) for search on white surfaces (menus, sidebars, lists); \"outline\" is the standard field (field-bg,\n * field-border) for search that sits on a grey plane, where a grey fill reads as a pill, not a field (D70, the schema desk).\n */\n variant?: \"filled\" | \"outline\";\n /** a result count shown inside the field while there is a query (\"3 matches\", \"2 of 5\"); announced politely */\n count?: string;\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n inputRef?: React.Ref<HTMLInputElement>;\n}) {\n const hints = useShortcutHints();\n return (\n <Input\n ref={inputRef}\n variant={variant}\n size={size}\n autoFocus={autoFocus}\n value={value}\n placeholder={placeholder}\n aria-label={ariaLabel ?? placeholder.replace(/…$/, \"\")}\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={onKeyDown}\n leading={<IconSearch aria-hidden />}\n className={cn(className, value && count ? \"[&_input]:pr-28\" : undefined)}\n trailing={\n value ? (\n <span className=\"flex items-center gap-1.5\">\n {count ? (\n <span aria-live=\"polite\" className=\"whitespace-nowrap text-kit-xs tabular-nums text-kit-fg-3\">\n {count}\n </span>\n ) : null}\n <button\n type=\"button\"\n aria-label=\"Clear search\"\n onClick={() => onChange(\"\")}\n className=\"flex size-5 items-center justify-center rounded-kit-sm text-kit-fg-3 hover:bg-kit-selected hover:text-kit-fg [&_svg]:size-3.5\"\n >\n <IconX aria-hidden />\n </button>\n </span>\n ) : shortcut && hints ? (\n <kbd data-hint=\"shortcuts\" className=\"font-kit-sans text-kit-2xs text-kit-fg-3\">\n {shortcut}\n </kbd>\n ) : undefined\n }\n />\n );\n}\n\nexport function Label({ className, ...props }: React.LabelHTMLAttributes<HTMLLabelElement>) {\n return <label className={cn(\"text-kit-sm font-medium text-kit-fg\", className)} {...props} />;\n}\n\n/**\n * Field = label row · help · control · error. CPO D39, the one help system (same spec as the Block Kit FieldShell):\n * [Label *] [hint] [i helpMore] …… [counter] [actions]\n * help: 12/16, --fg-3 (≥4.5:1 light + dark), 4px under the label, 1–2 lines\n * control\n * error: replaces the help, danger colour, under the control\n * The control gets `aria-describedby` → help + ⓘ text + error.\n * Required marker is V2 ui/input.tsx:249 (--danger-fg); the sr-only \"(required)\" names it for screen readers.\n */\nexport function Field({\n label,\n htmlFor,\n hint,\n help,\n helpMore,\n error,\n required,\n counter,\n actions,\n children,\n className,\n}: {\n label?: React.ReactNode;\n htmlFor?: string;\n /** short, quiet aside on the label row (\"Optional\", \"Shown publicly\") */\n hint?: React.ReactNode;\n /** the help line under the label */\n help?: React.ReactNode;\n /** longer explanation behind the ⓘ next to the label */\n helpMore?: React.ReactNode;\n error?: React.ReactNode;\n required?: boolean;\n counter?: { value: number; max: number };\n actions?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n}) {\n const autoId = React.useId();\n const id = htmlFor ?? autoId;\n const helpId = `${id}-help`;\n const moreId = `${id}-more`;\n const errId = `${id}-error`;\n const describedBy = [error ? errId : help ? helpId : null, helpMore ? moreId : null].filter(Boolean).join(\" \") || undefined;\n return (\n <div className={cn(\"flex flex-col gap-1.5\", className)}>\n {label || actions || counter ? (\n <div className=\"flex min-h-5 items-center justify-between gap-2\">\n <span className=\"flex min-w-0 items-center gap-1\">\n <Label htmlFor={label ? id : undefined} className=\"flex items-center gap-1.5 text-kit-sm text-kit-fg-2\">\n {label}\n {required ? (\n <>\n <span aria-hidden className=\"text-kit-danger-fg\">*</span>\n <span className=\"sr-only\">(required)</span>\n </>\n ) : null}\n {hint ? <span className=\"font-normal text-kit-fg-3\">{hint}</span> : null}\n </Label>\n {helpMore ? (\n <HelpMore id={moreId} label={typeof label === \"string\" ? label : undefined}>\n {helpMore}\n </HelpMore>\n ) : null}\n </span>\n <div className=\"flex items-center gap-1\">\n {counter ? (\n <span\n className={cn(\n \"tabular-nums text-kit-xs\",\n counter.value > counter.max\n ? \"text-kit-danger-fg\"\n : counter.value > counter.max * 0.9\n ? \"text-kit-warning-fg\"\n : \"text-kit-fg-3\",\n )}\n >\n {counter.value}/{counter.max}\n </span>\n ) : null}\n {actions}\n </div>\n </div>\n ) : null}\n {help && !error ? (\n <p id={helpId} data-slot=\"field-help\" className=\"-mt-0.5 text-kit-xs leading-4 text-kit-fg-3\">\n {help}\n </p>\n ) : null}\n <FieldIdContext.Provider value={label ? id : undefined}>\n <FieldDescribedByContext.Provider value={describedBy}>{children}</FieldDescribedByContext.Provider>\n </FieldIdContext.Provider>\n {error ? (\n <p id={errId} role=\"alert\" className=\"text-kit-xs leading-4 text-kit-danger-fg\">\n {error}\n </p>\n ) : null}\n </div>\n );\n}\n\n/** The ⓘ next to a label: longer help in a tooltip, also read by screen readers through aria-describedby (D39). */\nexport function HelpMore({ id, label, children }: { id?: string; label?: string; children: React.ReactNode }) {\n return (\n <HintTooltip content={<span className=\"block max-w-[260px] whitespace-normal font-normal leading-4\">{children}</span>}>\n <button\n type=\"button\"\n aria-label={label ? `About ${label}` : \"More about this field\"}\n className=\"hit-area inline-flex size-4 shrink-0 items-center justify-center rounded-kit-sm text-kit-fg-4 [--hit-size:16px] hover:text-kit-fg-2\"\n >\n <IconInfoCircle className=\"size-3.5\" stroke={1.5} aria-hidden />\n <span id={id} className=\"sr-only\">\n {children}\n </span>\n </button>\n </HintTooltip>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAM,WAAW,GAAG,QAAgC,IAAI,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;;;;;;;;;AAUrF,SAAS,mBAAqE,EAC5E,OACA,UACA,oBACA,oBACuG;CACvG,MAAM,CAAC,OAAO,YAAY,MAAM,SAAwB,IAAI;CAC5D,MAAM,YAAY,MAAM,OAAO,KAAK;CACpC,MAAM,YAAY,MAAM,OAAsB,IAAI;CAClD,MAAM,aAAa,UAAU,KAAA;CAC7B,OAAO;EACL,OAAO,cAAc,UAAU,OAAO,QAAQ;EAC9C,WAAW,MAA4B;GACrC,IAAI,UAAU,SAAS;IACrB,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK;IACvC;GACF;GACA,MAAM,QAAQ,UAAU,YAAY,EAAE,OAAO;GAC7C,UAAU,UAAU;GACpB,IAAI,CAAC,OAAO,WAAW,CAAC;EAC1B;EACA,qBAAqB,MAAiC;GACpD,UAAU,UAAU;GACpB,UAAU,UAAU;GACpB,IAAI,YAAY,SAAS,EAAE,cAAc,KAAK;GAC9C,qBAAqB,CAAC;EACxB;EACA,mBAAmB,MAAiC;GAClD,UAAU,UA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BACA,QAAQ,QAAQ,QAAQ,MAAM,KAC5B,wBACA,eACR;MARF,UAAA;OAUG,QAAQ;OAAM;OAAE,QAAQ;MACrB;KACJ,CAAA,IAAA,MACH,OACE;IACF,CAAA,CAAA;GACH,CAAA,IAAA;GACH,QAAQ,CAAC,QACR,oBAAC,KAAD;IAAG,IAAI;IAAQ,aAAU;IAAa,WAAU;IAC7C,UAAA;GACA,CAAA,IACD;GACJ,oBAAC,eAAe,UAAhB;IAAyB,OAAO,QAAQ,KAAK,KAAA;IAC3C,UAAA,oBAAC,wBAAwB,UAAzB;KAAkC,OAAO;KAAc;IAA2C,CAAA;GAC3E,CAAA;GACxB,QACC,oBAAC,KAAD;IAAG,IAAI;IAAO,MAAK;IAAQ,WAAU;IAClC,UAAA;GACA,CAAA,IACD;EACD;;AAET;;AAGA,SAAgB,SAAS,EAAE,IAAI,OAAO,YAAwE;CAC5G,OACE,oBAAC,aAAD;EAAa,SAAS,oBAAC,QAAD;GAAM,WAAU;GAA+D;EAAe,CAAA;EAClH,UAAA,qBAAC,UAAD;GACE,MAAK;GACL,cAAY,QAAQ,SAAS,UAAU;GACvC,WAAU;GAHZ,UAAA,CAKE,oBAAC,gBAAD;IAAgB,WAAU;IAAW,QAAQ;IAAK,eAAA;GAAa,CAAA,GAC/D,oBAAC,QAAD;IAAU;IAAI,WAAU;IACrB;GACG,CAAA,CACA;;CACG,CAAA;AAEjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bettercms-ai/kit",
3
- "version": "3.1.28",
3
+ "version": "3.1.31",
4
4
  "description": "The BetterCMS V2 Block Kit: schema language, form engine, controls and design tokens.",
5
5
  "license": "MIT",
6
6
  "type": "module",