@bettercms-ai/kit 4.1.1 → 4.2.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/dist/adapters/lossy.d.ts +1 -1
- package/dist/adapters/lossy.js +1 -1
- package/dist/adapters/lossy.js.map +1 -1
- package/dist/adapters/schema.js +1 -1
- package/dist/adapters/schema.js.map +1 -1
- package/dist/context.d.ts +8 -0
- package/dist/context.js.map +1 -1
- package/dist/controls/index.js +2 -2
- package/dist/controls/media-v16.d.ts +3 -1
- package/dist/controls/media-v16.js +3 -1
- package/dist/controls/media-v16.js.map +1 -1
- package/dist/controls/media.d.ts +5 -1
- package/dist/controls/media.js +25 -7
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/rich-text/block-tool.d.ts +1 -1
- package/dist/controls/rich-text/block-tool.js +1 -1
- package/dist/controls/rich-text/block-tool.js.map +1 -1
- package/dist/controls/rich-text/blocks.js +3 -1
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/catalog.d.ts +26 -3
- package/dist/controls/rich-text/catalog.js +239 -58
- package/dist/controls/rich-text/catalog.js.map +1 -1
- package/dist/controls/rich-text/codec.d.ts +7 -1
- package/dist/controls/rich-text/codec.js +2 -1
- package/dist/controls/rich-text/codec.js.map +1 -1
- package/dist/controls/rich-text/control.js +2 -1
- package/dist/controls/rich-text/control.js.map +1 -1
- package/dist/controls/rich-text/dom.js +8 -3
- package/dist/controls/rich-text/dom.js.map +1 -1
- package/dist/controls/rich-text/editor.d.ts +3 -1
- package/dist/controls/rich-text/editor.js +160 -44
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/rewriteSelection.d.ts +25 -0
- package/dist/controls/rich-text/rewriteSelection.js +28 -0
- package/dist/controls/rich-text/rewriteSelection.js.map +1 -0
- package/dist/controls/rich-text/slash-preview.js +18 -5
- package/dist/controls/rich-text/slash-preview.js.map +1 -1
- package/dist/controls/rich-text/table-grid.js +28 -21
- package/dist/controls/rich-text/table-grid.js.map +1 -1
- package/dist/controls/rich-text/toolbar.d.ts +6 -2
- package/dist/controls/rich-text/toolbar.js +205 -4
- package/dist/controls/rich-text/toolbar.js.map +1 -1
- package/dist/controls/text.d.ts +1 -1
- package/dist/controls/text.js +10 -7
- package/dist/controls/text.js.map +1 -1
- package/dist/engine/field-shell.js +8 -4
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +9 -2
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.js +4 -3
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/item-list.js +2 -2
- package/dist/engine/item-list.js.map +1 -1
- package/dist/engine/schema-form.d.ts +2 -0
- package/dist/engine/schema-form.js +2 -0
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/kit.css +6 -32
- package/dist/lib/reduced-motion.d.ts +1 -0
- package/dist/lib/reduced-motion.js +19 -0
- package/dist/lib/reduced-motion.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/theme.css +101 -0
- package/dist/tokens.css +9 -0
- package/dist/ui/content-fields.js +3 -2
- package/dist/ui/content-fields.js.map +1 -1
- package/dist/ui/controls.js +3 -2
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/floating-panel.js +3 -2
- package/dist/ui/floating-panel.js.map +1 -1
- package/dist/ui/foundations.js +3 -2
- package/dist/ui/foundations.js.map +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/ui/inspector.d.ts +23 -5
- package/dist/ui/inspector.js +75 -30
- package/dist/ui/inspector.js.map +1 -1
- package/dist/ui/overlay.js +2 -2
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/tab.js +3 -2
- package/dist/ui/tab.js.map +1 -1
- package/package.json +1 -1
package/dist/theme.css
CHANGED
|
@@ -169,6 +169,7 @@
|
|
|
169
169
|
--color-kit-insp-tip-bg: var(--kit-insp-tip-bg);
|
|
170
170
|
--color-kit-insp-tip-line: var(--kit-insp-tip-line);
|
|
171
171
|
--color-kit-insp-tip-title: var(--kit-insp-tip-title);
|
|
172
|
+
--color-kit-insp-link: var(--kit-insp-link);
|
|
172
173
|
--color-kit-insp-tip-body: var(--kit-insp-tip-body);
|
|
173
174
|
--color-kit-insp-tag-bg: var(--kit-insp-tag-bg);
|
|
174
175
|
--color-kit-insp-icon-tile: var(--kit-insp-icon-tile);
|
|
@@ -495,3 +496,103 @@
|
|
|
495
496
|
box-shadow: var(--kit-shadow-ink);
|
|
496
497
|
}
|
|
497
498
|
|
|
499
|
+
/* Slash menu AI icons · V1.6 (editor-v16 content.css:247-278; keyframes kit-ai-* in kit.css): each stroke of an icon
|
|
500
|
+
moves once, when the pointer is on its row, and once for the row the AI view opens on (CatalogList marks it
|
|
501
|
+
[data-aii-entry]). Never on arrow-key highlighting (aria-selected): keyboard movement is not animated (M28/F42).
|
|
502
|
+
kit-ai-move reads its offset from --dx/--dy, set inline on the path (catalog.tsx AiIcon). */
|
|
503
|
+
@layer components {
|
|
504
|
+
.kit-aii path { transform-box: fill-box; transform-origin: center; }
|
|
505
|
+
.kit-aii .ul, .kit-aii .l3, .kit-aii .ck { stroke-dasharray: 1 1; }
|
|
506
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-ai .star { animation: kit-ai-breathe 0.5s ease-out; }
|
|
507
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-ai .p1 { animation: kit-ai-blink 0.4s ease-out 0.05s; }
|
|
508
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-ai .p2 { animation: kit-ai-blink 0.4s ease-out 0.15s; }
|
|
509
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-prompt .pen { animation: kit-ai-move 0.55s ease-out; }
|
|
510
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-prompt .ul { animation: kit-ai-draw 0.5s ease-out; }
|
|
511
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-continue .arr { animation: kit-ai-move 0.5s ease-out; }
|
|
512
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-continue .l3 { animation: kit-ai-grow 0.45s ease-out; }
|
|
513
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-improve .wand { animation: kit-ai-tilt 0.55s ease-out; }
|
|
514
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-improve .s1 { animation: kit-ai-pop 0.4s ease-out; }
|
|
515
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-improve .s2 { animation: kit-ai-pop 0.4s ease-out 0.08s; }
|
|
516
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-improve .s3 { animation: kit-ai-pop 0.4s ease-out 0.16s; }
|
|
517
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-shorter .tr { animation: kit-ai-move 0.5s ease-out; }
|
|
518
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-shorter .bl { animation: kit-ai-move 0.5s ease-out; }
|
|
519
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-summarize .l1 { animation: kit-ai-move 0.5s ease-out; }
|
|
520
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-summarize .l2 { animation: kit-ai-move 0.5s ease-out 0.03s; }
|
|
521
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-summarize .l3 { animation: kit-ai-move 0.5s ease-out 0.06s; }
|
|
522
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-summarize .l4 { animation: kit-ai-move 0.5s ease-out 0.09s; }
|
|
523
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-summarize .arr { animation: kit-ai-move 0.5s ease-out; }
|
|
524
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-translate .g { animation: kit-ai-move 0.5s ease-out; }
|
|
525
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-translate .a { animation: kit-ai-move 0.5s ease-out 0.06s; }
|
|
526
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-spelling .a { animation: kit-ai-move 0.4s ease-out; }
|
|
527
|
+
:is([role="option"]:hover, [data-aii-entry]) .kit-aii-spelling .ck { animation: kit-ai-draw 0.45s ease-out 0.08s both; }
|
|
528
|
+
/* A tap leaves :hover stuck on a touch row: there only the AI view's entry row plays. */
|
|
529
|
+
@media (hover: none) {
|
|
530
|
+
[role="option"]:not([data-aii-entry]) .kit-aii path { animation: none !important; }
|
|
531
|
+
}
|
|
532
|
+
@media (prefers-reduced-motion: reduce) {
|
|
533
|
+
.kit-aii path { animation: none !important; }
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/* Image toolbar · look v16 (M30, blocks.tsx): the block toolbar's appear (kit-insp-appear: 6 up, .96, fade, 160ms) as
|
|
538
|
+
transitions, so a pointer that leaves mid-way reverses it; its buttons fade in 30ms apart. It leaves in 100ms with no
|
|
539
|
+
stagger. Shown while the image is hovered (hover devices) or holds focus, while one of its menus is open
|
|
540
|
+
([data-open]), and always on touch. Reduced motion: it fades, nothing moves. */
|
|
541
|
+
@layer components {
|
|
542
|
+
[data-rt-imgtool] {
|
|
543
|
+
opacity: 0;
|
|
544
|
+
translate: 0 6px;
|
|
545
|
+
scale: 0.96;
|
|
546
|
+
transition-property: opacity, translate, scale;
|
|
547
|
+
transition-duration: 100ms;
|
|
548
|
+
transition-timing-function: ease-in;
|
|
549
|
+
}
|
|
550
|
+
[data-rt-imgtool] > * {
|
|
551
|
+
opacity: 0;
|
|
552
|
+
transition: opacity 100ms ease-in;
|
|
553
|
+
}
|
|
554
|
+
:focus-within > [data-rt-imgtool],
|
|
555
|
+
[data-rt-imgtool][data-open] {
|
|
556
|
+
opacity: 1;
|
|
557
|
+
translate: 0 0;
|
|
558
|
+
scale: 1;
|
|
559
|
+
transition-duration: 160ms;
|
|
560
|
+
transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
|
|
561
|
+
}
|
|
562
|
+
@media (hover: hover) {
|
|
563
|
+
:hover > [data-rt-imgtool] {
|
|
564
|
+
opacity: 1;
|
|
565
|
+
translate: 0 0;
|
|
566
|
+
scale: 1;
|
|
567
|
+
transition-duration: 160ms;
|
|
568
|
+
transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
|
|
569
|
+
}
|
|
570
|
+
:hover > [data-rt-imgtool] > * { opacity: 1; transition-duration: 160ms; }
|
|
571
|
+
:hover > [data-rt-imgtool] > :nth-child(2) { transition-delay: 30ms; }
|
|
572
|
+
:hover > [data-rt-imgtool] > :nth-child(3) { transition-delay: 60ms; }
|
|
573
|
+
:hover > [data-rt-imgtool] > :nth-child(4) { transition-delay: 90ms; }
|
|
574
|
+
:hover > [data-rt-imgtool] > :nth-child(n + 5) { transition-delay: 120ms; }
|
|
575
|
+
}
|
|
576
|
+
:focus-within > [data-rt-imgtool] > *,
|
|
577
|
+
[data-rt-imgtool][data-open] > * {
|
|
578
|
+
opacity: 1;
|
|
579
|
+
}
|
|
580
|
+
@media (pointer: coarse) {
|
|
581
|
+
[data-rt-imgtool],
|
|
582
|
+
[data-rt-imgtool] > * {
|
|
583
|
+
opacity: 1;
|
|
584
|
+
translate: 0 0;
|
|
585
|
+
scale: 1;
|
|
586
|
+
transition: none;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
@media (prefers-reduced-motion: reduce) {
|
|
590
|
+
[data-rt-imgtool] {
|
|
591
|
+
translate: 0 0;
|
|
592
|
+
scale: 1;
|
|
593
|
+
}
|
|
594
|
+
[data-rt-imgtool] > * {
|
|
595
|
+
transition-delay: 0ms !important;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
package/dist/tokens.css
CHANGED
|
@@ -245,6 +245,8 @@
|
|
|
245
245
|
--kit-insp-tip-bg: #ffffff;
|
|
246
246
|
--kit-insp-tip-line: #ebebeb;
|
|
247
247
|
--kit-insp-tip-title: #171717;
|
|
248
|
+
/* look v16 body link ink (prototype kit.css:281 .rtx-body a) */
|
|
249
|
+
--kit-insp-link: #1d51a0;
|
|
248
250
|
--kit-insp-tip-body: #3b3b3b;
|
|
249
251
|
--kit-insp-tag-bg: #ececec;
|
|
250
252
|
--kit-insp-icon-tile: #fbfbfb;
|
|
@@ -722,6 +724,7 @@
|
|
|
722
724
|
--kit-insp-tip-bg: var(--kit-surface-raised);
|
|
723
725
|
--kit-insp-tip-line: var(--kit-line);
|
|
724
726
|
--kit-insp-tip-title: var(--kit-fg);
|
|
727
|
+
--kit-insp-link: #8ab4f8;
|
|
725
728
|
--kit-insp-tip-body: var(--kit-fg-2);
|
|
726
729
|
--kit-insp-tag-bg: var(--kit-hover);
|
|
727
730
|
--kit-insp-icon-tile: var(--kit-subtle);
|
|
@@ -760,6 +763,12 @@
|
|
|
760
763
|
--kit-insp-btool-icon: var(--kit-fg-2);
|
|
761
764
|
--kit-insp-btool-danger: var(--kit-danger-fg);
|
|
762
765
|
--kit-insp-table-guide: var(--kit-insp-accent);
|
|
766
|
+
/* Status icon strokes and fills (StatusIcon, FoundationBadge blue dot): graphics, not text, on the dark surface */
|
|
767
|
+
--kit-insp-ok: var(--kit-success-fg);
|
|
768
|
+
--kit-insp-ok-tint: var(--kit-success-soft);
|
|
769
|
+
--kit-insp-err: var(--kit-danger-fg);
|
|
770
|
+
--kit-insp-err-tint: var(--kit-danger-soft);
|
|
771
|
+
--kit-insp-badge-blue-dot: var(--kit-info);
|
|
763
772
|
--kit-insp-badge-green: var(--kit-success-soft);
|
|
764
773
|
--kit-insp-badge-green-fg: var(--kit-success-fg);
|
|
765
774
|
--kit-insp-badge-green-dot: var(--kit-success);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { useKitReducedMotion } from "../lib/reduced-motion.js";
|
|
2
3
|
import { Menu, MenuContent, MenuItem, MenuLabel, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger } from "./overlay.js";
|
|
3
4
|
import * as React from "react";
|
|
4
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { IconArrowsExchange, IconCheck, IconChevronDown, IconDots, IconPlus, IconTrash, IconUser, IconX } from "@tabler/icons-react";
|
|
6
|
-
import { AnimatePresence, motion
|
|
7
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
7
8
|
//#region src/ui/content-fields.tsx
|
|
8
9
|
/**
|
|
9
10
|
* Content fields of prototype editor-v16 (src/content.jsx:836-853, content.css:130-136, 171-174, 563-565):
|
|
@@ -20,7 +21,7 @@ var FIELD = "border border-transparent bg-kit-insp-card transition-colors durati
|
|
|
20
21
|
function TagsInput({ value, onChange, placeholder = "Add a tag", disabled, validate, id, className, ...aria }) {
|
|
21
22
|
const [v, setV] = React.useState("");
|
|
22
23
|
const [said, setSaid] = React.useState("");
|
|
23
|
-
const reduce =
|
|
24
|
+
const reduce = useKitReducedMotion();
|
|
24
25
|
const layout = reduce ? { duration: 0 } : {
|
|
25
26
|
type: "spring",
|
|
26
27
|
stiffness: 500,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-fields.js","names":[],"sources":["../../src/ui/content-fields.tsx"],"sourcesContent":["/**\n * Content fields of prototype editor-v16 (src/content.jsx:836-853, content.css:130-136, 171-174, 563-565):\n *\n * <TagsInput> grey box of white tag chips (24 high, 12/500) with \"Remove {tag}\" ×, an \"Add a tag\" input; Enter adds,\n * Backspace on the empty input removes the last; chips pop in and out\n * <AuthorField> one author. Empty = the \"Select an author\" picker (36 high, 20 placeholder circle); picked = an\n * outlined card with the grey profile (36 avatar, name 14/20 medium, \"Role · 4 posts\") and ⋯ beside it\n *\n * Editor-scoped look (the --kit-insp-* roles). The kit's own tags and reference controls are unchanged.\n */\nimport * as React from \"react\";\nimport { IconArrowsExchange, IconCheck, IconChevronDown, IconDots, IconPlus, IconTrash, IconUser, IconX } from \"@tabler/icons-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { cn } from \"../lib/cn\";\nimport { Menu, MenuContent, MenuItem, MenuLabel, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger } from \"./overlay\";\n\nconst HAIR = \"shadow-[0_1px_3px_rgb(0_0_0/0.05)]\";\nconst FIELD = \"border border-transparent bg-kit-insp-card transition-colors duration-100 hover:bg-kit-insp-card-hover\";\n\nexport interface TagsInputProps {\n value: string[];\n onChange: (next: string[]) => void;\n placeholder?: string;\n disabled?: boolean;\n /** refuse a tag (a duplicate is always refused); return the reason to announce, or nothing to accept */\n validate?: (tag: string, tags: string[]) => string | undefined;\n id?: string;\n \"aria-labelledby\"?: string;\n \"aria-label\"?: string;\n className?: string;\n}\n\nexport function TagsInput({ value, onChange, placeholder = \"Add a tag\", disabled, validate, id, className, ...aria }: TagsInputProps) {\n const [v, setV] = React.useState(\"\");\n const [said, setSaid] = React.useState(\"\");\n const reduce = useReducedMotion();\n const layout = reduce ? { duration: 0 } : ({ type: \"spring\", stiffness: 500, damping: 40 } as const);\n const add = () => {\n const t = v.trim();\n if (!t) return;\n const why = value.includes(t) ? `${t} is already added` : validate?.(t, value);\n if (why) return setSaid(why);\n onChange([...value, t]);\n setV(\"\");\n setSaid(`${t} added`);\n };\n const remove = (t: string) => {\n onChange(value.filter((x) => x !== t));\n setSaid(`${t} removed`);\n };\n return (\n <div data-slot=\"kit-tags-input\" className={cn(\"flex min-h-9 flex-wrap items-center gap-1.5 rounded-[6px] p-1.5\", FIELD, \"focus-within:border-kit-insp-accent focus-within:bg-kit-insp-card-focus\", disabled && \"pointer-events-none opacity-60\", className)}>\n <AnimatePresence initial={false} mode=\"popLayout\">\n {value.map((t) => (\n <motion.span\n layout\n key={t}\n data-slot=\"kit-tag\"\n initial={reduce ? false : { opacity: 0, scale: 0.8 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0, transition: { duration: 0 } } : { opacity: 0, scale: 0.8, transition: { duration: 0.14, ease: [0.4, 0, 1, 1] } }}\n transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 520, damping: 20, layout }}\n className={cn(\"inline-flex h-6 items-center gap-1 rounded-[4px] bg-kit-insp-tip-bg pl-2 pr-1 text-[12px] font-medium leading-[18px] text-kit-insp-tip-title\", HAIR)}\n >\n {t}\n <button type=\"button\" aria-label={`Remove ${t}`} disabled={disabled} onClick={() => remove(t)} className=\"grid size-4 place-items-center rounded-[3px] text-kit-group-sub outline-none hover:bg-kit-insp-card focus-visible:bg-kit-insp-card focus-visible:outline-2 focus-visible:outline-kit-insp-accent\">\n <IconX aria-hidden className=\"size-[11px]\" stroke={2} />\n </button>\n </motion.span>\n ))}\n </AnimatePresence>\n <motion.input\n layout\n transition={{ layout }}\n id={id}\n value={v}\n disabled={disabled}\n placeholder={placeholder}\n aria-label={aria[\"aria-labelledby\"] ? undefined : (aria[\"aria-label\"] ?? placeholder)}\n aria-labelledby={aria[\"aria-labelledby\"]}\n onChange={(e) => setV(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && v.trim()) {\n e.preventDefault();\n add();\n }\n if (e.key === \"Backspace\" && !v && value.length) remove(value[value.length - 1]!);\n }}\n className=\"min-w-20 flex-1 border-0 bg-transparent text-[13px] leading-[18px] text-kit-insp-ink outline-none placeholder:text-kit-group-sub\"\n />\n <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">{said}</span>\n </div>\n );\n}\n\nexport interface AuthorOption {\n id: string;\n name: string;\n /** \"Editor · 4 posts\": role and post count, on the card and in the picker */\n line?: string;\n /** the avatar (the host's own component or an <img>); drawn 24 in the picker and 36 on the card */\n avatar?: (size: number) => React.ReactNode;\n}\n\nexport interface AuthorFieldProps {\n value: string | null | undefined;\n people: AuthorOption[];\n onChange: (id: string | null) => void;\n /** \"New author in Authors\" at the end of the picker; omitted = no such row */\n onNew?: () => void;\n /** \"Open profile\" in the card's ⋯ menu; omitted = no such row */\n onOpenProfile?: (id: string) => void;\n /** what one of these is called: \"author\" (default), \"writer\"… */\n noun?: string;\n disabled?: boolean;\n \"aria-labelledby\"?: string;\n className?: string;\n}\n\nconst initials = (name: string) => name.split(/\\s+/).filter(Boolean).slice(0, 2).map((w) => w[0]!.toUpperCase()).join(\"\");\nfunction Face({ p, size }: { p: AuthorOption; size: number }) {\n return (\n <span aria-hidden className=\"grid shrink-0 place-items-center overflow-hidden rounded-full bg-kit-insp-chip font-medium text-kit-insp-label [&>img]:size-full [&>img]:object-cover\" style={{ width: size, height: size, fontSize: Math.round(size * 0.4) }}>\n {p.avatar ? p.avatar(size) : initials(p.name)}\n </span>\n );\n}\nfunction PersonItems({ people, value, onPick }: { people: AuthorOption[]; value: string | null | undefined; onPick: (id: string) => void }) {\n return (\n <>\n {people.map((p) => (\n <MenuItem key={p.id} icon={<Face p={p} size={24} />} onClick={() => onPick(p.id)} aria-current={p.id === value || undefined} className=\"h-auto py-1.5\">\n <span className=\"flex items-center gap-2\">\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"truncate\">{p.name}</span>\n {p.line ? <span className=\"truncate text-[12px] leading-4 text-kit-insp-quiet\">{p.line}</span> : null}\n </span>\n {p.id === value ? <IconCheck aria-hidden className=\"size-3.5 shrink-0 text-kit-insp-label\" stroke={2} /> : null}\n </span>\n </MenuItem>\n ))}\n </>\n );\n}\n\nexport function AuthorField({ value, people, onChange, onNew, onOpenProfile, noun = \"author\", disabled, className, ...aria }: AuthorFieldProps) {\n const p = value ? people.find((x) => x.id === value) : undefined;\n const Noun = `${noun.charAt(0).toUpperCase()}${noun.slice(1)}`;\n if (!p)\n return (\n <Menu>\n <MenuTrigger\n disabled={disabled}\n aria-labelledby={aria[\"aria-labelledby\"]}\n data-slot=\"kit-author-pick\"\n className={cn(\"flex h-9 w-full items-center gap-2 rounded-[6px] px-2.5 text-left text-[13px] leading-[19.5px] text-kit-insp-faint outline-none\", FIELD, \"focus-visible:border-kit-insp-accent focus-visible:bg-kit-insp-card-focus data-[popup-open]:border-kit-insp-accent data-[popup-open]:bg-kit-insp-card-focus\", className)}\n >\n <span aria-hidden className=\"size-5 shrink-0 rounded-full shadow-[inset_0_0_0_1px_var(--kit-insp-line-strong)]\" />\n Select an {noun}\n <IconChevronDown aria-hidden className=\"ml-auto size-3.5 shrink-0 text-kit-group-sub\" stroke={1.8} />\n </MenuTrigger>\n <MenuContent align=\"start\" className=\"w-[300px] min-w-[var(--anchor-width)]\">\n <MenuLabel>Search {noun}s</MenuLabel>\n <PersonItems people={people} value={value} onPick={onChange} />\n {onNew ? (\n <>\n <MenuSeparator />\n <MenuItem icon={<IconPlus stroke={1.5} />} onClick={onNew}>New {noun} in {Noun}s</MenuItem>\n </>\n ) : null}\n </MenuContent>\n </Menu>\n );\n return (\n <div data-slot=\"kit-author-card\" className={cn(\"flex items-center gap-1.5 rounded-[12px] bg-kit-insp-tip-bg p-1.5 shadow-[inset_0_0_0_1px_var(--kit-insp-divider),0_1px_3px_rgb(0_0_0/0.05)]\", className)}>\n <div className=\"flex min-w-0 flex-1 items-center gap-2.5 rounded-[8px] bg-kit-insp-card px-2.5 py-2\">\n <Face p={p} size={36} />\n <span className=\"flex min-w-0 flex-col\">\n <b className=\"truncate text-[14px] font-medium leading-5 text-kit-insp-tip-title\">{p.name}</b>\n {p.line ? <small className=\"truncate text-[12px] leading-4 text-kit-group-sub\">{p.line}</small> : null}\n </span>\n </div>\n {disabled ? null : (\n <Menu>\n <MenuTrigger aria-label={`${Noun} options`} data-slot=\"kit-author-more\" className=\"grid size-7 shrink-0 place-items-center rounded-[6px] text-kit-insp-label outline-none transition-colors hover:bg-kit-insp-card data-[popup-open]:bg-kit-insp-card focus-visible:outline-2 focus-visible:outline-kit-insp-accent\">\n <IconDots aria-hidden className=\"size-4\" stroke={1.6} />\n </MenuTrigger>\n <MenuContent align=\"end\" className=\"w-[220px]\">\n <MenuSub>\n <MenuSubTrigger icon={<IconArrowsExchange aria-hidden stroke={1.5} />}>Change {noun}</MenuSubTrigger>\n <MenuSubContent className=\"w-[280px]\">\n <PersonItems people={people} value={value} onPick={onChange} />\n </MenuSubContent>\n </MenuSub>\n {onOpenProfile ? <MenuItem icon={<IconUser stroke={1.5} />} onClick={() => onOpenProfile(p.id)}>Open profile</MenuItem> : null}\n <MenuSeparator />\n <MenuItem danger icon={<IconTrash stroke={1.5} />} onClick={() => onChange(null)}>Remove {noun}</MenuItem>\n </MenuContent>\n </Menu>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,IAAM,OAAO;AACb,IAAM,QAAQ;AAed,SAAgB,UAAU,EAAE,OAAO,UAAU,cAAc,aAAa,UAAU,UAAU,IAAI,WAAW,GAAG,QAAwB;CACpI,MAAM,CAAC,GAAG,QAAQ,MAAM,SAAS,EAAE;CACnC,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,EAAE;CACzC,MAAM,SAAS,iBAAiB;CAChC,MAAM,SAAS,SAAS,EAAE,UAAU,EAAE,IAAK;EAAE,MAAM;EAAU,WAAW;EAAK,SAAS;CAAG;CACzF,MAAM,YAAY;EAChB,MAAM,IAAI,EAAE,KAAK;EACjB,IAAI,CAAC,GAAG;EACR,MAAM,MAAM,MAAM,SAAS,CAAC,IAAI,GAAG,EAAE,qBAAqB,WAAW,GAAG,KAAK;EAC7E,IAAI,KAAK,OAAO,QAAQ,GAAG;EAC3B,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC;EACtB,KAAK,EAAE;EACP,QAAQ,GAAG,EAAE,OAAO;CACtB;CACA,MAAM,UAAU,MAAc;EAC5B,SAAS,MAAM,QAAQ,MAAM,MAAM,CAAC,CAAC;EACrC,QAAQ,GAAG,EAAE,SAAS;CACxB;CACA,OACE,qBAAC,OAAD;EAAK,aAAU;EAAiB,WAAW,GAAG,mEAAmE,OAAO,2EAA2E,YAAY,kCAAkC,SAAS;EAA1P,UAAA;GACE,oBAAC,iBAAD;IAAiB,SAAS;IAAO,MAAK;IACnC,UAAA,MAAM,KAAK,MACV,qBAAC,OAAO,MAAR;KACE,QAAA;KAEA,aAAU;KACV,SAAS,SAAS,QAAQ;MAAE,SAAS;MAA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AkB,WAAU;GAChF,UAAA,oBAAC,UAAD;IAAU,eAAA;IAAY,WAAU;IAAS,QAAQ;GAAM,CAAA;EAC5C,CAAA,GACb,qBAAC,aAAD;GAAa,OAAM;GAAM,WAAU;GAAnC,UAAA;IACE,qBAAC,SAAD,EAAA,UAAA,CACE,qBAAC,gBAAD;KAAgB,MAAM,oBAAC,oBAAD;MAAoB,eAAA;MAAY,QAAQ;KAAM,CAAA;KAApE,UAAA,CAAuE,WAAQ,IAAqB;IACpG,CAAA,GAAA,oBAAC,gBAAD;KAAgB,WAAU;KACxB,UAAA,oBAAC,aAAD;MAAqB;MAAe;MAAO,QAAQ;KAAW,CAAA;IAChD,CAAA,CACT,EAAA,CAAA;IACR,gBAAgB,oBAAC,UAAD;KAAU,MAAM,oBAAC,UAAD,EAAU,QAAQ,IAAM,CAAA;KAAG,eAAe,cAAc,EAAE,EAAE;KAAG,UAAA;IAAsB,CAAA,IAAI;IAC1H,oBAAC,eAAD,CAAgB,CAAA;IAChB,qBAAC,UAAD;KAAU,QAAA;KAAO,MAAM,oBAAC,WAAD,EAAW,QAAQ,IAAM,CAAA;KAAG,eAAe,SAAS,IAAI;KAA/E,UAAA,CAAkF,WAAQ,IAAe;;GAC9F;EACT,CAAA,CAAA,EAAA,CAAA,CAEL;;AAET"}
|
|
1
|
+
{"version":3,"file":"content-fields.js","names":[],"sources":["../../src/ui/content-fields.tsx"],"sourcesContent":["/**\n * Content fields of prototype editor-v16 (src/content.jsx:836-853, content.css:130-136, 171-174, 563-565):\n *\n * <TagsInput> grey box of white tag chips (24 high, 12/500) with \"Remove {tag}\" ×, an \"Add a tag\" input; Enter adds,\n * Backspace on the empty input removes the last; chips pop in and out\n * <AuthorField> one author. Empty = the \"Select an author\" picker (36 high, 20 placeholder circle); picked = an\n * outlined card with the grey profile (36 avatar, name 14/20 medium, \"Role · 4 posts\") and ⋯ beside it\n *\n * Editor-scoped look (the --kit-insp-* roles). The kit's own tags and reference controls are unchanged.\n */\nimport * as React from \"react\";\nimport { IconArrowsExchange, IconCheck, IconChevronDown, IconDots, IconPlus, IconTrash, IconUser, IconX } from \"@tabler/icons-react\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport { cn } from \"../lib/cn\";\nimport { Menu, MenuContent, MenuItem, MenuLabel, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger } from \"./overlay\";\nimport { useKitReducedMotion } from \"../lib/reduced-motion\";\n\nconst HAIR = \"shadow-[0_1px_3px_rgb(0_0_0/0.05)]\";\nconst FIELD = \"border border-transparent bg-kit-insp-card transition-colors duration-100 hover:bg-kit-insp-card-hover\";\n\nexport interface TagsInputProps {\n value: string[];\n onChange: (next: string[]) => void;\n placeholder?: string;\n disabled?: boolean;\n /** refuse a tag (a duplicate is always refused); return the reason to announce, or nothing to accept */\n validate?: (tag: string, tags: string[]) => string | undefined;\n id?: string;\n \"aria-labelledby\"?: string;\n \"aria-label\"?: string;\n className?: string;\n}\n\nexport function TagsInput({ value, onChange, placeholder = \"Add a tag\", disabled, validate, id, className, ...aria }: TagsInputProps) {\n const [v, setV] = React.useState(\"\");\n const [said, setSaid] = React.useState(\"\");\n const reduce = useKitReducedMotion();\n const layout = reduce ? { duration: 0 } : ({ type: \"spring\", stiffness: 500, damping: 40 } as const);\n const add = () => {\n const t = v.trim();\n if (!t) return;\n const why = value.includes(t) ? `${t} is already added` : validate?.(t, value);\n if (why) return setSaid(why);\n onChange([...value, t]);\n setV(\"\");\n setSaid(`${t} added`);\n };\n const remove = (t: string) => {\n onChange(value.filter((x) => x !== t));\n setSaid(`${t} removed`);\n };\n return (\n <div data-slot=\"kit-tags-input\" className={cn(\"flex min-h-9 flex-wrap items-center gap-1.5 rounded-[6px] p-1.5\", FIELD, \"focus-within:border-kit-insp-accent focus-within:bg-kit-insp-card-focus\", disabled && \"pointer-events-none opacity-60\", className)}>\n <AnimatePresence initial={false} mode=\"popLayout\">\n {value.map((t) => (\n <motion.span\n layout\n key={t}\n data-slot=\"kit-tag\"\n initial={reduce ? false : { opacity: 0, scale: 0.8 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0, transition: { duration: 0 } } : { opacity: 0, scale: 0.8, transition: { duration: 0.14, ease: [0.4, 0, 1, 1] } }}\n transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 520, damping: 20, layout }}\n className={cn(\"inline-flex h-6 items-center gap-1 rounded-[4px] bg-kit-insp-tip-bg pl-2 pr-1 text-[12px] font-medium leading-[18px] text-kit-insp-tip-title\", HAIR)}\n >\n {t}\n <button type=\"button\" aria-label={`Remove ${t}`} disabled={disabled} onClick={() => remove(t)} className=\"grid size-4 place-items-center rounded-[3px] text-kit-group-sub outline-none hover:bg-kit-insp-card focus-visible:bg-kit-insp-card focus-visible:outline-2 focus-visible:outline-kit-insp-accent\">\n <IconX aria-hidden className=\"size-[11px]\" stroke={2} />\n </button>\n </motion.span>\n ))}\n </AnimatePresence>\n <motion.input\n layout\n transition={{ layout }}\n id={id}\n value={v}\n disabled={disabled}\n placeholder={placeholder}\n aria-label={aria[\"aria-labelledby\"] ? undefined : (aria[\"aria-label\"] ?? placeholder)}\n aria-labelledby={aria[\"aria-labelledby\"]}\n onChange={(e) => setV(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && v.trim()) {\n e.preventDefault();\n add();\n }\n if (e.key === \"Backspace\" && !v && value.length) remove(value[value.length - 1]!);\n }}\n className=\"min-w-20 flex-1 border-0 bg-transparent text-[13px] leading-[18px] text-kit-insp-ink outline-none placeholder:text-kit-group-sub\"\n />\n <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">{said}</span>\n </div>\n );\n}\n\nexport interface AuthorOption {\n id: string;\n name: string;\n /** \"Editor · 4 posts\": role and post count, on the card and in the picker */\n line?: string;\n /** the avatar (the host's own component or an <img>); drawn 24 in the picker and 36 on the card */\n avatar?: (size: number) => React.ReactNode;\n}\n\nexport interface AuthorFieldProps {\n value: string | null | undefined;\n people: AuthorOption[];\n onChange: (id: string | null) => void;\n /** \"New author in Authors\" at the end of the picker; omitted = no such row */\n onNew?: () => void;\n /** \"Open profile\" in the card's ⋯ menu; omitted = no such row */\n onOpenProfile?: (id: string) => void;\n /** what one of these is called: \"author\" (default), \"writer\"… */\n noun?: string;\n disabled?: boolean;\n \"aria-labelledby\"?: string;\n className?: string;\n}\n\nconst initials = (name: string) => name.split(/\\s+/).filter(Boolean).slice(0, 2).map((w) => w[0]!.toUpperCase()).join(\"\");\nfunction Face({ p, size }: { p: AuthorOption; size: number }) {\n return (\n <span aria-hidden className=\"grid shrink-0 place-items-center overflow-hidden rounded-full bg-kit-insp-chip font-medium text-kit-insp-label [&>img]:size-full [&>img]:object-cover\" style={{ width: size, height: size, fontSize: Math.round(size * 0.4) }}>\n {p.avatar ? p.avatar(size) : initials(p.name)}\n </span>\n );\n}\nfunction PersonItems({ people, value, onPick }: { people: AuthorOption[]; value: string | null | undefined; onPick: (id: string) => void }) {\n return (\n <>\n {people.map((p) => (\n <MenuItem key={p.id} icon={<Face p={p} size={24} />} onClick={() => onPick(p.id)} aria-current={p.id === value || undefined} className=\"h-auto py-1.5\">\n <span className=\"flex items-center gap-2\">\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"truncate\">{p.name}</span>\n {p.line ? <span className=\"truncate text-[12px] leading-4 text-kit-insp-quiet\">{p.line}</span> : null}\n </span>\n {p.id === value ? <IconCheck aria-hidden className=\"size-3.5 shrink-0 text-kit-insp-label\" stroke={2} /> : null}\n </span>\n </MenuItem>\n ))}\n </>\n );\n}\n\nexport function AuthorField({ value, people, onChange, onNew, onOpenProfile, noun = \"author\", disabled, className, ...aria }: AuthorFieldProps) {\n const p = value ? people.find((x) => x.id === value) : undefined;\n const Noun = `${noun.charAt(0).toUpperCase()}${noun.slice(1)}`;\n if (!p)\n return (\n <Menu>\n <MenuTrigger\n disabled={disabled}\n aria-labelledby={aria[\"aria-labelledby\"]}\n data-slot=\"kit-author-pick\"\n className={cn(\"flex h-9 w-full items-center gap-2 rounded-[6px] px-2.5 text-left text-[13px] leading-[19.5px] text-kit-insp-faint outline-none\", FIELD, \"focus-visible:border-kit-insp-accent focus-visible:bg-kit-insp-card-focus data-[popup-open]:border-kit-insp-accent data-[popup-open]:bg-kit-insp-card-focus\", className)}\n >\n <span aria-hidden className=\"size-5 shrink-0 rounded-full shadow-[inset_0_0_0_1px_var(--kit-insp-line-strong)]\" />\n Select an {noun}\n <IconChevronDown aria-hidden className=\"ml-auto size-3.5 shrink-0 text-kit-group-sub\" stroke={1.8} />\n </MenuTrigger>\n <MenuContent align=\"start\" className=\"w-[300px] min-w-[var(--anchor-width)]\">\n <MenuLabel>Search {noun}s</MenuLabel>\n <PersonItems people={people} value={value} onPick={onChange} />\n {onNew ? (\n <>\n <MenuSeparator />\n <MenuItem icon={<IconPlus stroke={1.5} />} onClick={onNew}>New {noun} in {Noun}s</MenuItem>\n </>\n ) : null}\n </MenuContent>\n </Menu>\n );\n return (\n <div data-slot=\"kit-author-card\" className={cn(\"flex items-center gap-1.5 rounded-[12px] bg-kit-insp-tip-bg p-1.5 shadow-[inset_0_0_0_1px_var(--kit-insp-divider),0_1px_3px_rgb(0_0_0/0.05)]\", className)}>\n <div className=\"flex min-w-0 flex-1 items-center gap-2.5 rounded-[8px] bg-kit-insp-card px-2.5 py-2\">\n <Face p={p} size={36} />\n <span className=\"flex min-w-0 flex-col\">\n <b className=\"truncate text-[14px] font-medium leading-5 text-kit-insp-tip-title\">{p.name}</b>\n {p.line ? <small className=\"truncate text-[12px] leading-4 text-kit-group-sub\">{p.line}</small> : null}\n </span>\n </div>\n {disabled ? null : (\n <Menu>\n <MenuTrigger aria-label={`${Noun} options`} data-slot=\"kit-author-more\" className=\"grid size-7 shrink-0 place-items-center rounded-[6px] text-kit-insp-label outline-none transition-colors hover:bg-kit-insp-card data-[popup-open]:bg-kit-insp-card focus-visible:outline-2 focus-visible:outline-kit-insp-accent\">\n <IconDots aria-hidden className=\"size-4\" stroke={1.6} />\n </MenuTrigger>\n <MenuContent align=\"end\" className=\"w-[220px]\">\n <MenuSub>\n <MenuSubTrigger icon={<IconArrowsExchange aria-hidden stroke={1.5} />}>Change {noun}</MenuSubTrigger>\n <MenuSubContent className=\"w-[280px]\">\n <PersonItems people={people} value={value} onPick={onChange} />\n </MenuSubContent>\n </MenuSub>\n {onOpenProfile ? <MenuItem icon={<IconUser stroke={1.5} />} onClick={() => onOpenProfile(p.id)}>Open profile</MenuItem> : null}\n <MenuSeparator />\n <MenuItem danger icon={<IconTrash stroke={1.5} />} onClick={() => onChange(null)}>Remove {noun}</MenuItem>\n </MenuContent>\n </Menu>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,IAAM,OAAO;AACb,IAAM,QAAQ;AAed,SAAgB,UAAU,EAAE,OAAO,UAAU,cAAc,aAAa,UAAU,UAAU,IAAI,WAAW,GAAG,QAAwB;CACpI,MAAM,CAAC,GAAG,QAAQ,MAAM,SAAS,EAAE;CACnC,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,EAAE;CACzC,MAAM,SAAS,oBAAoB;CACnC,MAAM,SAAS,SAAS,EAAE,UAAU,EAAE,IAAK;EAAE,MAAM;EAAU,WAAW;EAAK,SAAS;CAAG;CACzF,MAAM,YAAY;EAChB,MAAM,IAAI,EAAE,KAAK;EACjB,IAAI,CAAC,GAAG;EACR,MAAM,MAAM,MAAM,SAAS,CAAC,IAAI,GAAG,EAAE,qBAAqB,WAAW,GAAG,KAAK;EAC7E,IAAI,KAAK,OAAO,QAAQ,GAAG;EAC3B,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC;EACtB,KAAK,EAAE;EACP,QAAQ,GAAG,EAAE,OAAO;CACtB;CACA,MAAM,UAAU,MAAc;EAC5B,SAAS,MAAM,QAAQ,MAAM,MAAM,CAAC,CAAC;EACrC,QAAQ,GAAG,EAAE,SAAS;CACxB;CACA,OACE,qBAAC,OAAD;EAAK,aAAU;EAAiB,WAAW,GAAG,m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,EAAE,OAAO,oBAAC,SAAD;KAAO,WAAU;KAAqD,UAAA,EAAE;IAAY,CAAA,IAAI,IAC9F;GACH,CAAA,CAAA;EACJ,CAAA,GAAA,WAAW,OACV,qBAAC,MAAD,EAAA,UAAA,CACE,oBAAC,aAAD;GAAa,cAAY,GAAG,KAAK;GAAW,aAAU;GAAkB,WAAU;GAChF,UAAA,oBAAC,UAAD;IAAU,eAAA;IAAY,WAAU;IAAS,QAAQ;GAAM,CAAA;EAC5C,CAAA,GACb,qBAAC,aAAD;GAAa,OAAM;GAAM,WAAU;GAAnC,UAAA;IACE,qBAAC,SAAD,EAAA,UAAA,CACE,qBAAC,gBAAD;KAAgB,MAAM,oBAAC,oBAAD;MAAoB,eAAA;MAAY,QAAQ;KAAM,CAAA;KAApE,UAAA,CAAuE,WAAQ,IAAqB;IACpG,CAAA,GAAA,oBAAC,gBAAD;KAAgB,WAAU;KACxB,UAAA,oBAAC,aAAD;MAAqB;MAAe;MAAO,QAAQ;KAAW,CAAA;IAChD,CAAA,CACT,EAAA,CAAA;IACR,gBAAgB,oBAAC,UAAD;KAAU,MAAM,oBAAC,UAAD,EAAU,QAAQ,IAAM,CAAA;KAAG,eAAe,cAAc,EAAE,EAAE;KAAG,UAAA;IAAsB,CAAA,IAAI;IAC1H,oBAAC,eAAD,CAAgB,CAAA;IAChB,qBAAC,UAAD;KAAU,QAAA;KAAO,MAAM,oBAAC,WAAD,EAAW,QAAQ,IAAM,CAAA;KAAG,eAAe,SAAS,IAAI;KAA/E,UAAA,CAAkF,WAAQ,IAAe;;GAC9F;EACT,CAAA,CAAA,EAAA,CAAA,CAEL;;AAET"}
|
package/dist/ui/controls.js
CHANGED
|
@@ -3,10 +3,11 @@ import { useFieldLabelledBy, useLabelFor } from "./field-context.js";
|
|
|
3
3
|
import { TooltipLayer, TooltipRoot } from "./tooltip-root.js";
|
|
4
4
|
import { TooltipScope } from "./button.js";
|
|
5
5
|
import { useShortcutHints } from "./shortcut-hint.js";
|
|
6
|
+
import { useKitReducedMotion } from "../lib/reduced-motion.js";
|
|
6
7
|
import * as React from "react";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
import { IconCheck, IconMinus } from "@tabler/icons-react";
|
|
9
|
-
import { AnimatePresence, motion
|
|
10
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
10
11
|
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
11
12
|
import { Checkbox as Checkbox$1 } from "@base-ui/react/checkbox";
|
|
12
13
|
import { RadioGroup as RadioGroup$1 } from "@base-ui/react/radio-group";
|
|
@@ -153,7 +154,7 @@ function SegmentTooltip({ content, shortcut, children }) {
|
|
|
153
154
|
function Segmented({ value, onChange, items, size = "md", className, layoutId, iconOnly, collapseInactive, variant, bordered, "aria-label": ariaLabel }) {
|
|
154
155
|
const id = React.useId();
|
|
155
156
|
const v = variant ?? "toggle";
|
|
156
|
-
const reduceMotion =
|
|
157
|
+
const reduceMotion = useKitReducedMotion();
|
|
157
158
|
const pillTransition = reduceMotion ? { duration: 0 } : PILL_SPRING;
|
|
158
159
|
const onKey = (e, i) => {
|
|
159
160
|
const enabled = items.filter((x) => !x.disabled);
|
package/dist/ui/controls.js.map
CHANGED
|
@@ -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 ─────────────────────────────────────────────────────────────── */\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,WAAD;IAAW,WAAU;IAAS,QAAQ;GAAI,CAAA;EAC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AiB;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 } 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\";\nimport { useKitReducedMotion } from \"../lib/reduced-motion\";\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 = useKitReducedMotion();\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":";;;;;;;;;;;;;;;;;;;;AAoBA,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,WAAD;IAAW,WAAU;IAAS,QAAQ;GAAI,CAAA;EAC9E,CAAA;CACP,CAAA;AAE5B;AAG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E,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,9 +1,10 @@
|
|
|
1
1
|
import { cn } from "../lib/cn.js";
|
|
2
2
|
import { KIT_SCOPE } from "./surfaces.js";
|
|
3
|
+
import { useKitReducedMotion } from "../lib/reduced-motion.js";
|
|
3
4
|
import { eventKey } from "../lib/key-event.js";
|
|
4
5
|
import * as React from "react";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { motion, useMotionValue
|
|
7
|
+
import { motion, useMotionValue } from "framer-motion";
|
|
7
8
|
import { createPortal } from "react-dom";
|
|
8
9
|
//#region src/ui/floating-panel.tsx
|
|
9
10
|
/**
|
|
@@ -385,7 +386,7 @@ var FLOAT_BOUNDS = {
|
|
|
385
386
|
pad: 8
|
|
386
387
|
};
|
|
387
388
|
var FloatingPanel = React.forwardRef(function FloatingPanel({ id, labelledBy, anchor, container, header, children, sheetFooter, onClose, focusBack, instant, bodyClassName, onPanelKeyDown }, handle) {
|
|
388
|
-
const reduce =
|
|
389
|
+
const reduce = useKitReducedMotion();
|
|
389
390
|
const mode = usePanelMode(!!container);
|
|
390
391
|
const root = React.useRef(null);
|
|
391
392
|
const live = React.useRef(null);
|