@particle-academy/react-fancy 6.9.0 → 6.10.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/CHANGELOG.md +10 -0
- package/README.md +1 -0
- package/dist/autocomplete.cjs +3 -3
- package/dist/autocomplete.js +2 -2
- package/dist/{chunk-ZUJVGHFW.js → chunk-24RWB7Q3.js} +3 -3
- package/dist/{chunk-ZUJVGHFW.js.map → chunk-24RWB7Q3.js.map} +1 -1
- package/dist/{chunk-GODJVIIO.js → chunk-3W6BKQVZ.js} +4 -4
- package/dist/{chunk-GODJVIIO.js.map → chunk-3W6BKQVZ.js.map} +1 -1
- package/dist/{chunk-AZ5DWOQY.cjs → chunk-6B43ARGW.cjs} +4 -4
- package/dist/{chunk-AZ5DWOQY.cjs.map → chunk-6B43ARGW.cjs.map} +1 -1
- package/dist/{chunk-Q62RDKRA.cjs → chunk-7N7XVBH7.cjs} +6 -6
- package/dist/{chunk-Q62RDKRA.cjs.map → chunk-7N7XVBH7.cjs.map} +1 -1
- package/dist/{chunk-VGUAIFGE.js → chunk-C2VGO375.js} +3 -3
- package/dist/{chunk-VGUAIFGE.js.map → chunk-C2VGO375.js.map} +1 -1
- package/dist/{chunk-H7OTLGRD.cjs → chunk-DQWAG7YY.cjs} +4 -4
- package/dist/{chunk-H7OTLGRD.cjs.map → chunk-DQWAG7YY.cjs.map} +1 -1
- package/dist/{chunk-3KJN3GTB.cjs → chunk-EDIB6V6Y.cjs} +4 -4
- package/dist/{chunk-3KJN3GTB.cjs.map → chunk-EDIB6V6Y.cjs.map} +1 -1
- package/dist/{chunk-G5MDMQVQ.cjs → chunk-EEFU5BVM.cjs} +6 -6
- package/dist/{chunk-G5MDMQVQ.cjs.map → chunk-EEFU5BVM.cjs.map} +1 -1
- package/dist/{chunk-IYG436ZY.js → chunk-EW2N52FD.js} +3 -3
- package/dist/{chunk-IYG436ZY.js.map → chunk-EW2N52FD.js.map} +1 -1
- package/dist/{chunk-RSB2P3JK.js → chunk-FECD3WKN.js} +3 -3
- package/dist/{chunk-RSB2P3JK.js.map → chunk-FECD3WKN.js.map} +1 -1
- package/dist/{chunk-6RXEWM3V.js → chunk-FNHKZMMI.js} +3 -3
- package/dist/{chunk-6RXEWM3V.js.map → chunk-FNHKZMMI.js.map} +1 -1
- package/dist/{chunk-M5ER3Y5I.cjs → chunk-FR3V5IAJ.cjs} +4 -4
- package/dist/{chunk-M5ER3Y5I.cjs.map → chunk-FR3V5IAJ.cjs.map} +1 -1
- package/dist/{chunk-DXLPBLNC.cjs → chunk-FSLEFL4U.cjs} +4 -4
- package/dist/{chunk-DXLPBLNC.cjs.map → chunk-FSLEFL4U.cjs.map} +1 -1
- package/dist/{chunk-FQCLJZZS.js → chunk-FX37P4KR.js} +3 -3
- package/dist/{chunk-FQCLJZZS.js.map → chunk-FX37P4KR.js.map} +1 -1
- package/dist/{chunk-DW2PHLOA.js → chunk-H5LJFN7D.js} +3 -3
- package/dist/{chunk-DW2PHLOA.js.map → chunk-H5LJFN7D.js.map} +1 -1
- package/dist/{chunk-F3U4AVGF.js → chunk-HCIEXBEB.js} +3 -3
- package/dist/{chunk-F3U4AVGF.js.map → chunk-HCIEXBEB.js.map} +1 -1
- package/dist/{chunk-QAM6N3VG.cjs → chunk-HEGM5LMZ.cjs} +4 -4
- package/dist/{chunk-QAM6N3VG.cjs.map → chunk-HEGM5LMZ.cjs.map} +1 -1
- package/dist/{chunk-KAKKZDCE.js → chunk-J57JSHDC.js} +3 -3
- package/dist/{chunk-KAKKZDCE.js.map → chunk-J57JSHDC.js.map} +1 -1
- package/dist/{chunk-6BCXGP2T.js → chunk-JN5DHZ6I.js} +3 -3
- package/dist/{chunk-6BCXGP2T.js.map → chunk-JN5DHZ6I.js.map} +1 -1
- package/dist/chunk-LJCQI6ZS.js +1212 -0
- package/dist/chunk-LJCQI6ZS.js.map +1 -0
- package/dist/{chunk-JV2HEOCB.cjs → chunk-MAY4NMRI.cjs} +4 -4
- package/dist/{chunk-JV2HEOCB.cjs.map → chunk-MAY4NMRI.cjs.map} +1 -1
- package/dist/{chunk-BQENLOEV.js → chunk-MD7HUHJB.js} +4 -4
- package/dist/{chunk-BQENLOEV.js.map → chunk-MD7HUHJB.js.map} +1 -1
- package/dist/{chunk-QUZOGRZS.js → chunk-OE4AIUAN.js} +3 -3
- package/dist/{chunk-QUZOGRZS.js.map → chunk-OE4AIUAN.js.map} +1 -1
- package/dist/chunk-OP7A4SZZ.cjs +1216 -0
- package/dist/chunk-OP7A4SZZ.cjs.map +1 -0
- package/dist/{chunk-YBBBX5H2.cjs → chunk-OUPHLIXV.cjs} +11 -11
- package/dist/{chunk-YBBBX5H2.cjs.map → chunk-OUPHLIXV.cjs.map} +1 -1
- package/dist/{chunk-XGGAAG74.cjs → chunk-QQKWI7QP.cjs} +7 -3
- package/dist/chunk-QQKWI7QP.cjs.map +1 -0
- package/dist/{chunk-XT4WBBCD.cjs → chunk-R4SANV3G.cjs} +11 -11
- package/dist/{chunk-XT4WBBCD.cjs.map → chunk-R4SANV3G.cjs.map} +1 -1
- package/dist/{chunk-GJWNZMJT.js → chunk-RUEDMYBF.js} +7 -3
- package/dist/chunk-RUEDMYBF.js.map +1 -0
- package/dist/{chunk-UORN3Z7R.cjs → chunk-TBLKVTJC.cjs} +6 -6
- package/dist/{chunk-UORN3Z7R.cjs.map → chunk-TBLKVTJC.cjs.map} +1 -1
- package/dist/{chunk-L5NDZEL6.cjs → chunk-ZFXCZ2QO.cjs} +9 -9
- package/dist/{chunk-L5NDZEL6.cjs.map → chunk-ZFXCZ2QO.cjs.map} +1 -1
- package/dist/composer.cjs +6 -6
- package/dist/composer.js +4 -4
- package/dist/dropdown.cjs +4 -4
- package/dist/dropdown.js +2 -2
- package/dist/editor.cjs +1 -1
- package/dist/editor.js +1 -1
- package/dist/index.cjs +99 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -21
- package/dist/index.js.map +1 -1
- package/dist/input.cjs +5 -5
- package/dist/input.js +4 -4
- package/dist/inputs.cjs +19 -19
- package/dist/inputs.js +8 -8
- package/dist/json-editor.cjs +17 -17
- package/dist/json-editor.js +6 -6
- package/dist/mobile-menu.cjs +1 -1
- package/dist/mobile-menu.js +1 -1
- package/dist/number-field.cjs +6 -6
- package/dist/number-field.js +5 -5
- package/dist/paste-pills.cjs +16 -16
- package/dist/paste-pills.js +3 -3
- package/dist/phone-input.cjs +39 -0
- package/dist/phone-input.cjs.map +1 -0
- package/dist/phone-input.d.cts +139 -0
- package/dist/phone-input.d.ts +139 -0
- package/dist/phone-input.js +22 -0
- package/dist/phone-input.js.map +1 -0
- package/dist/popover.cjs +4 -4
- package/dist/popover.js +2 -2
- package/dist/prompt-input.cjs +8 -8
- package/dist/prompt-input.js +5 -5
- package/dist/reason-tag.cjs +4 -4
- package/dist/reason-tag.js +3 -3
- package/dist/select.cjs +3 -3
- package/dist/select.js +2 -2
- package/dist/sidebar.cjs +5 -5
- package/dist/sidebar.js +3 -3
- package/dist/tooltip.cjs +3 -3
- package/dist/tooltip.js +2 -2
- package/docs/PhoneInput.md +104 -0
- package/package.json +11 -1
- package/dist/chunk-GJWNZMJT.js.map +0 -1
- package/dist/chunk-XGGAAG74.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Dropdown/Dropdown.context.ts","../src/components/Dropdown/dropdown-focus.ts","../src/components/Dropdown/DropdownTrigger.tsx","../src/components/Dropdown/DropdownItems.tsx","../src/components/Dropdown/DropdownItem.tsx","../src/components/Dropdown/DropdownSeparator.tsx","../src/components/Dropdown/Dropdown.tsx"],"names":["jsx","useState","useRef","useCallback"],"mappings":";;;;;;;;;AAGO,IAAM,eAAA,GAAkB,cAA2C,IAAI,CAAA;AAEvE,SAAS,WAAA,GAAoC;AAClD,EAAA,MAAM,GAAA,GAAM,WAAW,eAAe,CAAA;AACtC,EAAA,IAAI,CAAC,GAAA,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jD,EAAA,MAAM,SAAA,GAAYC,OAAoB,IAAI,CAAA;AAC1C,EAAA,MAAM,eAAA,GAAkBA,OAAgC,IAAI,CAAA;AAC5D,EAAA,MAAM,OAAA,GAAUA,OAA2B,IAAI,CAAA;AAE/C,EAAA,MAAM,YAAA,GAAeC,YAAY,MAAM;AACrC,IAAA,MAAM,SAAS,SAAA,CAAU,OAAA;AACzB,IAAA,IAAI,CAAC,MAAA,EAAQ;AACb,IAAA,MAAM,MAAA,GACJ,OAAO,aAAA,CAA2B,iBAAiB,MAAM,MAAA,CAAO,QAAA,IAAY,IAAI,MAAA,GAAS,IAAA,CAAA;AAC3F,IAAA,MAAA,EAAQ,KAAA,EAAM;AAAA,EAChB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,GAAA,GAAM,OAAA;AAAA,IACV,OAAO;AAAA,MACL,IAAA;AAAA,MACA,OAAA;AAAA,MACA,SAAA;AAAA,MACA,WAAA;AAAA,MACA,cAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,eAAA;AAAA,MACA,OAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,IAAA,EAAM,SAAA,EAAW,WAAA,EAAa,SAAA,EAAW,QAAQ,YAAY;AAAA,GAChE;AAEA,EAAA,uBACEH,GAAAA,CAAC,eAAA,CAAgB,UAAhB,EAAyB,KAAA,EAAO,KAAM,QAAA,EAAS,CAAA;AAEpD;AAEO,IAAM,QAAA,GAAW,MAAA,CAAO,MAAA,CAAO,YAAA,EAAc;AAAA,EAClD,OAAA,EAAS,eAAA;AAAA,EACT,KAAA,EAAO,aAAA;AAAA,EACP,IAAA,EAAM,YAAA;AAAA,EACN,SAAA,EAAW;AACb,CAAC","file":"chunk-DW2PHLOA.js","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { DropdownContextValue } from \"./Dropdown.types\";\n\nexport const DropdownContext = createContext<DropdownContextValue | null>(null);\n\nexport function useDropdown(): DropdownContextValue {\n const ctx = useContext(DropdownContext);\n if (!ctx) {\n throw new Error(\n \"Dropdown compound components must be used within <Dropdown>\",\n );\n }\n return ctx;\n}\n","/** Enabled menu items, in DOM order. Disabled items are skipped. */\nexport function menuItems(menu: HTMLElement | null): HTMLElement[] {\n if (!menu) return [];\n return Array.from(\n menu.querySelectorAll<HTMLElement>('[role=\"menuitem\"]:not([aria-disabled=\"true\"]):not([disabled])'),\n );\n}\n\nexport type FocusMove = \"first\" | \"last\" | \"next\" | \"prev\";\n\n/**\n * Focus an item relative to the one that currently has focus, wrapping at both\n * ends. Returns the index focused, or -1 when the menu has no enabled item.\n */\nexport function focusMenuItem(menu: HTMLElement | null, move: FocusMove): number {\n const items = menuItems(menu);\n if (items.length === 0) return -1;\n const current = items.indexOf(document.activeElement as HTMLElement);\n let next: number;\n if (move === \"first\") next = 0;\n else if (move === \"last\") next = items.length - 1;\n else if (current === -1) next = move === \"next\" ? 0 : items.length - 1;\n else next = (current + (move === \"next\" ? 1 : -1) + items.length) % items.length;\n items[next]!.focus();\n return next;\n}\n\n/**\n * Typeahead: focus the next enabled item (after the focused one, wrapping)\n * whose text starts with `char`. Returns the index focused, or -1 for no match.\n */\nexport function focusByChar(menu: HTMLElement | null, char: string): number {\n const items = menuItems(menu);\n if (items.length === 0) return -1;\n const needle = char.toLowerCase();\n const start = items.indexOf(document.activeElement as HTMLElement);\n for (let step = 1; step <= items.length; step++) {\n const i = (start + step + items.length) % items.length;\n if ((items[i]!.textContent ?? \"\").trim().toLowerCase().startsWith(needle)) {\n items[i]!.focus();\n return i;\n }\n }\n return -1;\n}\n","import type { KeyboardEvent, MouseEvent } from \"react\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport { focusMenuItem } from \"./dropdown-focus\";\nimport type { DropdownTriggerProps } from \"./Dropdown.types\";\n\n/**\n * Elements the browser itself turns Enter / Space into a click on. For these\n * the trigger lets the native click open the menu; for anything else (an\n * avatar span with `tabIndex`) it opens the menu itself.\n */\nfunction activatesNatively(el: EventTarget | null): boolean {\n if (!(el instanceof HTMLElement)) return false;\n const tag = el.tagName;\n if (tag === \"BUTTON\" || tag === \"SUMMARY\") return true;\n if (tag === \"A\") return el.hasAttribute(\"href\");\n if (tag === \"INPUT\") {\n const type = (el as HTMLInputElement).type;\n return type === \"button\" || type === \"submit\" || type === \"reset\" || type === \"image\";\n }\n return false;\n}\n\nexport function DropdownTrigger({ children }: DropdownTriggerProps) {\n const { setOpen, open, anchorRef, pendingFocusRef, menuRef } = useDropdown();\n\n // WAI-ARIA menu button: Enter / Space / ArrowDown open the menu on its first\n // item, ArrowUp on its last.\n const onKeyDown = (e: KeyboardEvent<HTMLSpanElement>) => {\n if (e.defaultPrevented) return;\n\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n const target = e.key === \"ArrowDown\" ? \"first\" : \"last\";\n if (open && menuRef.current) {\n focusMenuItem(menuRef.current, target);\n return;\n }\n pendingFocusRef.current = target;\n setOpen(true);\n return;\n }\n\n if (e.key === \"Enter\" || e.key === \" \") {\n if (!open) pendingFocusRef.current = \"first\";\n if (activatesNatively(e.target)) return; // its click toggles the menu\n e.preventDefault();\n if (open) pendingFocusRef.current = null;\n setOpen(!open);\n }\n };\n\n const onClick = (_e: MouseEvent<HTMLSpanElement>) => {\n if (open) pendingFocusRef.current = null;\n setOpen(!open);\n };\n\n return (\n <span\n ref={anchorRef as React.RefObject<HTMLSpanElement>}\n data-react-fancy-dropdown-trigger=\"\"\n className=\"inline-flex\"\n onClick={onClick}\n onKeyDown={onKeyDown}\n aria-expanded={open}\n aria-haspopup=\"menu\"\n >\n {children}\n </span>\n );\n}\n\nDropdownTrigger.displayName = \"DropdownTrigger\";\n","import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { focusByChar, focusMenuItem, type FocusMove } from \"./dropdown-focus\";\nimport { cn } from \"../../utils/cn\";\nimport { Portal } from \"../Portal\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport { useFloatingPosition } from \"../../hooks/use-floating-position\";\nimport { useOutsideClick } from \"../../hooks/use-outside-click\";\nimport { useEscapeKey } from \"../../hooks/use-escape-key\";\nimport { useAnimation } from \"../../hooks/use-animation\";\nimport type { DropdownItemsProps } from \"./Dropdown.types\";\n\nexport function DropdownItems({ children, className }: DropdownItemsProps) {\n const {\n open,\n setOpen,\n anchorRef,\n setActiveIndex,\n placement,\n offset,\n pendingFocusRef,\n menuRef,\n focusTrigger,\n } = useDropdown();\n const floatingRef = useRef<HTMLDivElement>(null);\n const outsideRef = useRef<HTMLDivElement>(null);\n\n const position = useFloatingPosition(anchorRef, floatingRef, {\n placement,\n offset,\n enabled: open,\n });\n\n const close = useCallback(() => {\n pendingFocusRef.current = null;\n setOpen(false);\n setActiveIndex(-1);\n }, [setOpen, setActiveIndex, pendingFocusRef]);\n\n useOutsideClick(outsideRef, close, open, anchorRef);\n // Escape closes THIS menu (the innermost layer) and returns focus to where\n // the menu came from. An outside click does not move focus: the user put it\n // somewhere already.\n useEscapeKey(() => {\n close();\n focusTrigger();\n }, open);\n\n const { mounted, className: animClass, ref: animRef } = useAnimation({\n open,\n enterClass: \"fancy-scale-in\",\n exitClass: \"fancy-fade-out\",\n });\n\n // The menu element, as STATE. It does not exist when `open` first turns true:\n // `useAnimation` mounts it a render later and `Portal` a render after that.\n // Before 5.64.1 the key handler lived in an effect keyed on `open` that\n // returned early while the element was null and never re-ran, so the arrow\n // keys did nothing in any Dropdown. Keying on the element itself fixes the\n // timing for good.\n const [menuEl, setMenuEl] = useState<HTMLDivElement | null>(null);\n\n const setMenuRef = useCallback(\n (node: HTMLDivElement | null) => {\n outsideRef.current = node;\n floatingRef.current = node;\n (animRef as React.MutableRefObject<HTMLElement | null>).current = node;\n menuRef.current = node;\n setMenuEl(node);\n },\n [animRef, menuRef],\n );\n\n // Opened from the keyboard: focus the first / last item once it exists.\n useEffect(() => {\n if (!open || !menuEl) return;\n const target = pendingFocusRef.current;\n if (!target) return;\n pendingFocusRef.current = null;\n setActiveIndex(focusMenuItem(menuEl, target));\n }, [open, menuEl, pendingFocusRef, setActiveIndex]);\n\n // Keys are handled on the menu itself: focus is inside it while it is driven\n // from the keyboard, and React delivers the event through the portal.\n const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n const menu = e.currentTarget;\n const moves: Record<string, FocusMove> = {\n ArrowDown: \"next\",\n ArrowUp: \"prev\",\n Home: \"first\",\n End: \"last\",\n };\n const move = moves[e.key];\n if (move) {\n e.preventDefault();\n setActiveIndex(focusMenuItem(menu, move));\n return;\n }\n if (e.key === \"Tab\") {\n // Close, and put focus back on the trigger WITHOUT preventing the\n // default: the browser's own Tab then moves on from the trigger's place\n // in the tab order rather than from the end of <body>, where the\n // portalled menu lives.\n close();\n focusTrigger();\n return;\n }\n if (e.key.length === 1 && e.key !== \" \" && !e.ctrlKey && !e.metaKey && !e.altKey) {\n const i = focusByChar(menu, e.key);\n if (i >= 0) setActiveIndex(i);\n }\n };\n\n if (!mounted) return null;\n\n return (\n <Portal>\n <div\n ref={setMenuRef}\n data-react-fancy-dropdown=\"\"\n role=\"menu\"\n onKeyDown={onKeyDown}\n className={cn(\n \"fixed z-50 min-w-[8rem] rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] p-1 shadow-lg dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n animClass,\n className,\n )}\n dir={position.dir}\n style={{ left: position.x, top: position.y }}\n >\n {children}\n </div>\n </Portal>\n );\n}\n\nDropdownItems.displayName = \"DropdownItems\";\n","import { cn } from \"../../utils/cn\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport type { DropdownItemProps } from \"./Dropdown.types\";\n\nexport function DropdownItem({\n children,\n onClick,\n disabled = false,\n danger = false,\n className,\n}: DropdownItemProps) {\n const { setOpen, focusTrigger } = useDropdown();\n\n return (\n <button\n data-react-fancy-dropdown-item=\"\"\n type=\"button\"\n role=\"menuitem\"\n disabled={disabled}\n aria-disabled={disabled}\n className={cn(\n \"flex w-full items-center rounded-lg px-3 py-2 text-start text-sm transition-colors\",\n danger\n ? \"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950\"\n : \"text-[color:var(--fancy-text-soft,var(--color-zinc-700))] hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))] dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n disabled && \"cursor-not-allowed opacity-50\",\n className,\n )}\n onClick={(e) => {\n if (disabled) return;\n const hadFocus = document.activeElement === e.currentTarget;\n onClick?.();\n setOpen(false);\n // The item is about to unmount; without this, focus falls to <body>.\n // Only when the item held focus, and only if onClick did not move it.\n if (hadFocus && document.activeElement === e.currentTarget) focusTrigger();\n }}\n >\n {children}\n </button>\n );\n}\n\nDropdownItem.displayName = \"DropdownItem\";\n","import { cn } from \"../../utils/cn\";\nimport type { DropdownSeparatorProps } from \"./Dropdown.types\";\n\nexport function DropdownSeparator({ className }: DropdownSeparatorProps) {\n return (\n <div\n data-react-fancy-dropdown-separator=\"\"\n role=\"separator\"\n className={cn(\n \"my-1 h-px bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n />\n );\n}\n\nDropdownSeparator.displayName = \"DropdownSeparator\";\n","import { useCallback, useMemo, useRef, useState } from \"react\";\nimport { DropdownContext } from \"./Dropdown.context\";\nimport { DropdownTrigger } from \"./DropdownTrigger\";\nimport { DropdownItems } from \"./DropdownItems\";\nimport { DropdownItem } from \"./DropdownItem\";\nimport { DropdownSeparator } from \"./DropdownSeparator\";\nimport type { DropdownProps } from \"./Dropdown.types\";\n\nconst TRIGGER_FOCUSABLE =\n 'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\nfunction DropdownRoot({\n children,\n placement = \"bottom-start\",\n offset = 4,\n}: DropdownProps) {\n const [open, setOpen] = useState(false);\n const [activeIndex, setActiveIndex] = useState(-1);\n const anchorRef = useRef<HTMLElement>(null);\n const pendingFocusRef = useRef<\"first\" | \"last\" | null>(null);\n const menuRef = useRef<HTMLElement | null>(null);\n\n const focusTrigger = useCallback(() => {\n const anchor = anchorRef.current;\n if (!anchor) return;\n const target =\n anchor.querySelector<HTMLElement>(TRIGGER_FOCUSABLE) ?? (anchor.tabIndex >= 0 ? anchor : null);\n target?.focus();\n }, []);\n\n const ctx = useMemo(\n () => ({\n open,\n setOpen,\n anchorRef,\n activeIndex,\n setActiveIndex,\n placement,\n offset,\n pendingFocusRef,\n menuRef,\n focusTrigger,\n }),\n [open, anchorRef, activeIndex, placement, offset, focusTrigger],\n );\n\n return (\n <DropdownContext.Provider value={ctx}>{children}</DropdownContext.Provider>\n );\n}\n\nexport const Dropdown = Object.assign(DropdownRoot, {\n Trigger: DropdownTrigger,\n Items: DropdownItems,\n Item: DropdownItem,\n Separator: DropdownSeparator,\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/Dropdown/Dropdown.context.ts","../src/components/Dropdown/dropdown-focus.ts","../src/components/Dropdown/DropdownTrigger.tsx","../src/components/Dropdown/DropdownItems.tsx","../src/components/Dropdown/DropdownItem.tsx","../src/components/Dropdown/DropdownSeparator.tsx","../src/components/Dropdown/Dropdown.tsx"],"names":["jsx","useState","useRef","useCallback"],"mappings":";;;;;;;;;AAGO,IAAM,eAAA,GAAkB,cAA2C,IAAI,CAAA;AAEvE,SAAS,WAAA,GAAoC;AAClD,EAAA,MAAM,GAAA,GAAM,WAAW,eAAe,CAAA;AACtC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;;;ACZO,SAAS,UAAU,IAAA,EAAyC;AACjE,EAAA,IAAI,CAAC,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AAE/C,EAAA,MAAM,YAAA,GAAeC,YAAY,MAAM;AACrC,IAAA,MAAM,SAAS,SAAA,CAAU,OAAA;AACzB,IAAA,IAAI,CAAC,MAAA,EAAQ;AACb,IAAA,MAAM,MAAA,GACJ,OAAO,aAAA,CAA2B,iBAAiB,MAAM,MAAA,CAAO,QAAA,IAAY,IAAI,MAAA,GAAS,IAAA,CAAA;AAC3F,IAAA,MAAA,EAAQ,KAAA,EAAM;AAAA,EAChB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,GAAA,GAAM,OAAA;AAAA,IACV,OAAO;AAAA,MACL,IAAA;AAAA,MACA,OAAA;AAAA,MACA,SAAA;AAAA,MACA,WAAA;AAAA,MACA,cAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,eAAA;AAAA,MACA,OAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,IAAA,EAAM,SAAA,EAAW,WAAA,EAAa,SAAA,EAAW,QAAQ,YAAY;AAAA,GAChE;AAEA,EAAA,uBACEH,GAAAA,CAAC,eAAA,CAAgB,UAAhB,EAAyB,KAAA,EAAO,KAAM,QAAA,EAAS,CAAA;AAEpD;AAEO,IAAM,QAAA,GAAW,MAAA,CAAO,MAAA,CAAO,YAAA,EAAc;AAAA,EAClD,OAAA,EAAS,eAAA;AAAA,EACT,KAAA,EAAO,aAAA;AAAA,EACP,IAAA,EAAM,YAAA;AAAA,EACN,SAAA,EAAW;AACb,CAAC","file":"chunk-H5LJFN7D.js","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { DropdownContextValue } from \"./Dropdown.types\";\n\nexport const DropdownContext = createContext<DropdownContextValue | null>(null);\n\nexport function useDropdown(): DropdownContextValue {\n const ctx = useContext(DropdownContext);\n if (!ctx) {\n throw new Error(\n \"Dropdown compound components must be used within <Dropdown>\",\n );\n }\n return ctx;\n}\n","/** Enabled menu items, in DOM order. Disabled items are skipped. */\nexport function menuItems(menu: HTMLElement | null): HTMLElement[] {\n if (!menu) return [];\n return Array.from(\n menu.querySelectorAll<HTMLElement>('[role=\"menuitem\"]:not([aria-disabled=\"true\"]):not([disabled])'),\n );\n}\n\nexport type FocusMove = \"first\" | \"last\" | \"next\" | \"prev\";\n\n/**\n * Focus an item relative to the one that currently has focus, wrapping at both\n * ends. Returns the index focused, or -1 when the menu has no enabled item.\n */\nexport function focusMenuItem(menu: HTMLElement | null, move: FocusMove): number {\n const items = menuItems(menu);\n if (items.length === 0) return -1;\n const current = items.indexOf(document.activeElement as HTMLElement);\n let next: number;\n if (move === \"first\") next = 0;\n else if (move === \"last\") next = items.length - 1;\n else if (current === -1) next = move === \"next\" ? 0 : items.length - 1;\n else next = (current + (move === \"next\" ? 1 : -1) + items.length) % items.length;\n items[next]!.focus();\n return next;\n}\n\n/**\n * Typeahead: focus the next enabled item (after the focused one, wrapping)\n * whose text starts with `char`. Returns the index focused, or -1 for no match.\n */\nexport function focusByChar(menu: HTMLElement | null, char: string): number {\n const items = menuItems(menu);\n if (items.length === 0) return -1;\n const needle = char.toLowerCase();\n const start = items.indexOf(document.activeElement as HTMLElement);\n for (let step = 1; step <= items.length; step++) {\n const i = (start + step + items.length) % items.length;\n if ((items[i]!.textContent ?? \"\").trim().toLowerCase().startsWith(needle)) {\n items[i]!.focus();\n return i;\n }\n }\n return -1;\n}\n","import type { KeyboardEvent, MouseEvent } from \"react\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport { focusMenuItem } from \"./dropdown-focus\";\nimport type { DropdownTriggerProps } from \"./Dropdown.types\";\n\n/**\n * Elements the browser itself turns Enter / Space into a click on. For these\n * the trigger lets the native click open the menu; for anything else (an\n * avatar span with `tabIndex`) it opens the menu itself.\n */\nfunction activatesNatively(el: EventTarget | null): boolean {\n if (!(el instanceof HTMLElement)) return false;\n const tag = el.tagName;\n if (tag === \"BUTTON\" || tag === \"SUMMARY\") return true;\n if (tag === \"A\") return el.hasAttribute(\"href\");\n if (tag === \"INPUT\") {\n const type = (el as HTMLInputElement).type;\n return type === \"button\" || type === \"submit\" || type === \"reset\" || type === \"image\";\n }\n return false;\n}\n\nexport function DropdownTrigger({ children }: DropdownTriggerProps) {\n const { setOpen, open, anchorRef, pendingFocusRef, menuRef } = useDropdown();\n\n // WAI-ARIA menu button: Enter / Space / ArrowDown open the menu on its first\n // item, ArrowUp on its last.\n const onKeyDown = (e: KeyboardEvent<HTMLSpanElement>) => {\n if (e.defaultPrevented) return;\n\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n const target = e.key === \"ArrowDown\" ? \"first\" : \"last\";\n if (open && menuRef.current) {\n focusMenuItem(menuRef.current, target);\n return;\n }\n pendingFocusRef.current = target;\n setOpen(true);\n return;\n }\n\n if (e.key === \"Enter\" || e.key === \" \") {\n if (!open) pendingFocusRef.current = \"first\";\n if (activatesNatively(e.target)) return; // its click toggles the menu\n e.preventDefault();\n if (open) pendingFocusRef.current = null;\n setOpen(!open);\n }\n };\n\n const onClick = (_e: MouseEvent<HTMLSpanElement>) => {\n if (open) pendingFocusRef.current = null;\n setOpen(!open);\n };\n\n return (\n <span\n ref={anchorRef as React.RefObject<HTMLSpanElement>}\n data-react-fancy-dropdown-trigger=\"\"\n className=\"inline-flex\"\n onClick={onClick}\n onKeyDown={onKeyDown}\n aria-expanded={open}\n aria-haspopup=\"menu\"\n >\n {children}\n </span>\n );\n}\n\nDropdownTrigger.displayName = \"DropdownTrigger\";\n","import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { focusByChar, focusMenuItem, type FocusMove } from \"./dropdown-focus\";\nimport { cn } from \"../../utils/cn\";\nimport { Portal } from \"../Portal\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport { useFloatingPosition } from \"../../hooks/use-floating-position\";\nimport { useOutsideClick } from \"../../hooks/use-outside-click\";\nimport { useEscapeKey } from \"../../hooks/use-escape-key\";\nimport { useAnimation } from \"../../hooks/use-animation\";\nimport type { DropdownItemsProps } from \"./Dropdown.types\";\n\nexport function DropdownItems({ children, className }: DropdownItemsProps) {\n const {\n open,\n setOpen,\n anchorRef,\n setActiveIndex,\n placement,\n offset,\n pendingFocusRef,\n menuRef,\n focusTrigger,\n } = useDropdown();\n const floatingRef = useRef<HTMLDivElement>(null);\n const outsideRef = useRef<HTMLDivElement>(null);\n\n const position = useFloatingPosition(anchorRef, floatingRef, {\n placement,\n offset,\n enabled: open,\n });\n\n const close = useCallback(() => {\n pendingFocusRef.current = null;\n setOpen(false);\n setActiveIndex(-1);\n }, [setOpen, setActiveIndex, pendingFocusRef]);\n\n useOutsideClick(outsideRef, close, open, anchorRef);\n // Escape closes THIS menu (the innermost layer) and returns focus to where\n // the menu came from. An outside click does not move focus: the user put it\n // somewhere already.\n useEscapeKey(() => {\n close();\n focusTrigger();\n }, open);\n\n const { mounted, className: animClass, ref: animRef } = useAnimation({\n open,\n enterClass: \"fancy-scale-in\",\n exitClass: \"fancy-fade-out\",\n });\n\n // The menu element, as STATE. It does not exist when `open` first turns true:\n // `useAnimation` mounts it a render later and `Portal` a render after that.\n // Before 5.64.1 the key handler lived in an effect keyed on `open` that\n // returned early while the element was null and never re-ran, so the arrow\n // keys did nothing in any Dropdown. Keying on the element itself fixes the\n // timing for good.\n const [menuEl, setMenuEl] = useState<HTMLDivElement | null>(null);\n\n const setMenuRef = useCallback(\n (node: HTMLDivElement | null) => {\n outsideRef.current = node;\n floatingRef.current = node;\n (animRef as React.MutableRefObject<HTMLElement | null>).current = node;\n menuRef.current = node;\n setMenuEl(node);\n },\n [animRef, menuRef],\n );\n\n // Opened from the keyboard: focus the first / last item once it exists.\n useEffect(() => {\n if (!open || !menuEl) return;\n const target = pendingFocusRef.current;\n if (!target) return;\n pendingFocusRef.current = null;\n setActiveIndex(focusMenuItem(menuEl, target));\n }, [open, menuEl, pendingFocusRef, setActiveIndex]);\n\n // Keys are handled on the menu itself: focus is inside it while it is driven\n // from the keyboard, and React delivers the event through the portal.\n const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n const menu = e.currentTarget;\n const moves: Record<string, FocusMove> = {\n ArrowDown: \"next\",\n ArrowUp: \"prev\",\n Home: \"first\",\n End: \"last\",\n };\n const move = moves[e.key];\n if (move) {\n e.preventDefault();\n setActiveIndex(focusMenuItem(menu, move));\n return;\n }\n if (e.key === \"Tab\") {\n // Close, and put focus back on the trigger WITHOUT preventing the\n // default: the browser's own Tab then moves on from the trigger's place\n // in the tab order rather than from the end of <body>, where the\n // portalled menu lives.\n close();\n focusTrigger();\n return;\n }\n if (e.key.length === 1 && e.key !== \" \" && !e.ctrlKey && !e.metaKey && !e.altKey) {\n const i = focusByChar(menu, e.key);\n if (i >= 0) setActiveIndex(i);\n }\n };\n\n if (!mounted) return null;\n\n return (\n <Portal>\n <div\n ref={setMenuRef}\n data-react-fancy-dropdown=\"\"\n role=\"menu\"\n onKeyDown={onKeyDown}\n className={cn(\n \"fixed z-50 min-w-[8rem] rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] p-1 shadow-lg dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n animClass,\n className,\n )}\n dir={position.dir}\n style={{ left: position.x, top: position.y }}\n >\n {children}\n </div>\n </Portal>\n );\n}\n\nDropdownItems.displayName = \"DropdownItems\";\n","import { cn } from \"../../utils/cn\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport type { DropdownItemProps } from \"./Dropdown.types\";\n\nexport function DropdownItem({\n children,\n onClick,\n disabled = false,\n danger = false,\n className,\n}: DropdownItemProps) {\n const { setOpen, focusTrigger } = useDropdown();\n\n return (\n <button\n data-react-fancy-dropdown-item=\"\"\n type=\"button\"\n role=\"menuitem\"\n disabled={disabled}\n aria-disabled={disabled}\n className={cn(\n \"flex w-full items-center rounded-lg px-3 py-2 text-start text-sm transition-colors\",\n danger\n ? \"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950\"\n : \"text-[color:var(--fancy-text-soft,var(--color-zinc-700))] hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))] dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n disabled && \"cursor-not-allowed opacity-50\",\n className,\n )}\n onClick={(e) => {\n if (disabled) return;\n const hadFocus = document.activeElement === e.currentTarget;\n onClick?.();\n setOpen(false);\n // The item is about to unmount; without this, focus falls to <body>.\n // Only when the item held focus, and only if onClick did not move it.\n if (hadFocus && document.activeElement === e.currentTarget) focusTrigger();\n }}\n >\n {children}\n </button>\n );\n}\n\nDropdownItem.displayName = \"DropdownItem\";\n","import { cn } from \"../../utils/cn\";\nimport type { DropdownSeparatorProps } from \"./Dropdown.types\";\n\nexport function DropdownSeparator({ className }: DropdownSeparatorProps) {\n return (\n <div\n data-react-fancy-dropdown-separator=\"\"\n role=\"separator\"\n className={cn(\n \"my-1 h-px bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n />\n );\n}\n\nDropdownSeparator.displayName = \"DropdownSeparator\";\n","import { useCallback, useMemo, useRef, useState } from \"react\";\nimport { DropdownContext } from \"./Dropdown.context\";\nimport { DropdownTrigger } from \"./DropdownTrigger\";\nimport { DropdownItems } from \"./DropdownItems\";\nimport { DropdownItem } from \"./DropdownItem\";\nimport { DropdownSeparator } from \"./DropdownSeparator\";\nimport type { DropdownProps } from \"./Dropdown.types\";\n\nconst TRIGGER_FOCUSABLE =\n 'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\nfunction DropdownRoot({\n children,\n placement = \"bottom-start\",\n offset = 4,\n}: DropdownProps) {\n const [open, setOpen] = useState(false);\n const [activeIndex, setActiveIndex] = useState(-1);\n const anchorRef = useRef<HTMLElement>(null);\n const pendingFocusRef = useRef<\"first\" | \"last\" | null>(null);\n const menuRef = useRef<HTMLElement | null>(null);\n\n const focusTrigger = useCallback(() => {\n const anchor = anchorRef.current;\n if (!anchor) return;\n const target =\n anchor.querySelector<HTMLElement>(TRIGGER_FOCUSABLE) ?? (anchor.tabIndex >= 0 ? anchor : null);\n target?.focus();\n }, []);\n\n const ctx = useMemo(\n () => ({\n open,\n setOpen,\n anchorRef,\n activeIndex,\n setActiveIndex,\n placement,\n offset,\n pendingFocusRef,\n menuRef,\n focusTrigger,\n }),\n [open, anchorRef, activeIndex, placement, offset, focusTrigger],\n );\n\n return (\n <DropdownContext.Provider value={ctx}>{children}</DropdownContext.Provider>\n );\n}\n\nexport const Dropdown = Object.assign(DropdownRoot, {\n Trigger: DropdownTrigger,\n Items: DropdownItems,\n Item: DropdownItem,\n Separator: DropdownSeparator,\n});\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Input } from './chunk-
|
|
1
|
+
import { Input } from './chunk-EW2N52FD.js';
|
|
2
2
|
import { useControllableState } from './chunk-EDYAXGUM.js';
|
|
3
3
|
import { forwardRef, useState, useRef, useEffect } from 'react';
|
|
4
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
@@ -135,5 +135,5 @@ var NumberField = forwardRef(
|
|
|
135
135
|
NumberField.displayName = "NumberField";
|
|
136
136
|
|
|
137
137
|
export { NumberField };
|
|
138
|
-
//# sourceMappingURL=chunk-
|
|
139
|
-
//# sourceMappingURL=chunk-
|
|
138
|
+
//# sourceMappingURL=chunk-HCIEXBEB.js.map
|
|
139
|
+
//# sourceMappingURL=chunk-HCIEXBEB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/inputs/NumberField/NumberField.tsx"],"names":["k"],"mappings":";;;;;AASA,IAAM,MAAA,GAAS,2CAAA;AACf,IAAM,KAAA,GAAQ,YAAA;AAGd,SAAS,YAAY,IAAA,EAA6B;AAChD,EAAA,MAAM,OAAA,GAAU,KAAK,IAAA,E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AA,GAAU,EAAA;AACnB,YAAA,IAAI,OAAO,GAAA,KAAQ,UAAA,EAAY,GAAA,CAAI,EAAE,CAAA;AAAA,iBAAA,IAC5B,GAAA,MAAS,OAAA,GAAU,EAAA;AAAA,UAC9B,CAAA;AAAA,UAIA,IAAA,EAAK,MAAA;AAAA,UACL,KAAA,EAAO,IAAA;AAAA,UACP,aAAA,EAAe,CAAC,IAAA,KAAS;AACvB,YAAA,OAAA,CAAQ,IAAI,CAAA;AACZ,YAAA,MAAM,MAAA,GAAS,YAAY,IAAI,CAAA;AAC/B,YAAA,IAAI,MAAA,KAAW,OAAA,EAAS,QAAA,CAAS,MAAM,CAAA;AAAA,UACzC,CAAA;AAAA,UACA,SAAA,EAAW,aAAA;AAAA,UACX,MAAA,EAAQ,CAAC,CAAA,KAAM;AACb,YAAA,OAAA,CAAQ,YAAA,CAAa,OAAO,CAAC,CAAA;AAC7B,YAAA,MAAA,GAAS,CAAC,CAAA;AAAA,UACZ;AAAA;AAAA,OACF;AAAA,MAEC,IAAA,mBACC,GAAA;AAAA,QAAC,OAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,IAAA;AAAA,UACA,IAAA;AAAA,UACA,UAAU,IAAA,CAAK,QAAA;AAAA,UACf,KAAA,EAAO,aAAa,OAAO;AAAA;AAAA,OAC7B,GACE;AAAA,KAAA,EACN,CAAA;AAAA,EAEJ;AACF;AAEA,WAAA,CAAY,WAAA,GAAc,aAAA","file":"chunk-F3U4AVGF.js","sourcesContent":["import { forwardRef, useEffect, useRef, useState, type KeyboardEvent } from \"react\";\nimport { useControllableState } from \"../../../hooks/use-controllable-state\";\nimport { Input } from \"../Input\";\nimport type { NumberFieldProps } from \"./NumberField.types\";\n\n/**\n * Plain decimal notation only. `Number()` alone is not safe here: it reads \"0x10\"\n * as 16 and \"Infinity\" as a number, and those are wrong numbers to emit.\n */\nconst NUMBER = /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$/;\nconst WHOLE = /^[+-]?\\d+$/;\n\n/** The number the text says, or `null` if it does not say one. */\nfunction parseNumber(text: string): number | null {\n const trimmed = text.trim();\n if (!NUMBER.test(trimmed)) return null;\n\n const n = Number(trimmed);\n if (!Number.isFinite(n)) return null;\n // Past 2^53 a whole number rounds to a different one than was typed.\n if (WHOLE.test(trimmed) && !Number.isSafeInteger(n)) return null;\n\n return n === 0 ? 0 : n; // -0 is 0\n}\n\nfunction formatNumber(value: number | null): string {\n return value === null ? \"\" : String(value);\n}\n\n/** Decimal places in a number, so stepping can round away floating-point dust. */\nfunction decimals(n: number): number {\n const [mantissa, exponent] = String(n).split(\"e\");\n const places = (mantissa.split(\".\")[1] ?? \"\").length - Number(exponent ?? 0);\n return Math.min(Math.max(places, 0), 100);\n}\n\nfunction stepped(\n current: number | null,\n direction: 1 | -1,\n min: number | undefined,\n max: number | undefined,\n step: number,\n): number {\n const base = min ?? 0;\n const places = Math.max(decimals(step), decimals(base));\n const at = (k: number) => Number((base + k * step).toFixed(places));\n const position = ((current ?? 0) - base) / step;\n const nudge = 1e-9;\n\n // The next grid line in that direction, so an off-grid value lands on the grid.\n let k =\n direction === 1\n ? Math.floor(position + nudge) + 1\n : Math.ceil(position - nudge) - 1;\n\n if (max !== undefined && at(k) > max) k = Math.floor((max - base) / step + nudge);\n if (min !== undefined && at(k) < min) k = 0;\n\n return at(k);\n}\n\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(\n (\n {\n value,\n defaultValue = null,\n onValueChange,\n min,\n max,\n step,\n messages,\n name,\n form,\n inputMode,\n onKeyDown,\n onBlur,\n ...rest\n },\n ref,\n ) => {\n const [held, setValue] = useControllableState<number | null>(\n value,\n defaultValue,\n onValueChange,\n );\n // A host's NaN or Infinity has no text form, so it reads as no number.\n const current = typeof held === \"number\" && Number.isFinite(held) ? held : null;\n\n /*\n * The text is held apart from the number because \"1.\" and \"-\" have no number\n * that displays them. It only moves on its own when the number moved to\n * something the text does not say: a change from outside, or a parent refusing\n * this one.\n */\n const [text, setText] = useState(() => formatNumber(current));\n if (parseNumber(text) !== current && text !== formatNumber(current)) {\n setText(formatNumber(current));\n }\n\n const stepSize = typeof step === \"number\" && step > 0 ? step : 1;\n\n const problem = (() => {\n if (text.trim() !== \"\" && parseNumber(text) === null) {\n return messages?.invalid ?? \"Enter a number.\";\n }\n if (current === null) return \"\";\n if (min !== undefined && current < min) return messages?.min ?? `Must be at least ${min}.`;\n if (max !== undefined && current > max) return messages?.max ?? `Must be at most ${max}.`;\n if (typeof step === \"number\" && step > 0) {\n const position = (current - (min ?? 0)) / step;\n if (Math.abs(position - Math.round(position)) > 1e-9) {\n return messages?.step ?? `Must be in steps of ${step}.`;\n }\n }\n return \"\";\n })();\n\n // The text input has no min/max/step of its own, so a form learns of them here.\n // Runs every render: click-to-edit mounts a fresh input.\n const inputRef = useRef<HTMLInputElement | null>(null);\n useEffect(() => {\n inputRef.current?.setCustomValidity(problem);\n });\n\n const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || rest.disabled || rest.readOnly) return;\n if (e.key !== \"ArrowUp\" && e.key !== \"ArrowDown\") return;\n\n e.preventDefault(); // or the caret jumps to the end of the text\n const next = stepped(current, e.key === \"ArrowUp\" ? 1 : -1, min, max, stepSize);\n setText(formatNumber(next));\n if (next !== current) setValue(next);\n };\n\n return (\n <div data-react-fancy-number-field=\"\">\n <Input\n aria-invalid={problem ? true : undefined}\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={current ?? undefined}\n inputMode={\n inputMode ??\n // A numeric or decimal keypad has no minus sign on iOS, so those are\n // only offered where a negative number cannot be valid.\n (min !== undefined && min >= 0\n ? typeof step === \"number\" && Number.isInteger(step)\n ? \"numeric\"\n : \"decimal\"\n : \"text\")\n }\n role=\"spinbutton\"\n {...rest}\n ref={(el) => {\n inputRef.current = el;\n if (typeof ref === \"function\") ref(el);\n else if (ref) ref.current = el;\n }}\n // Text, not `number`: a browser reports \"-\" and \"1e\" in a number input as\n // an empty value, indistinguishable from blank, and turns the wheel into\n // a value change on a focused field. Neither applies to a text input.\n type=\"text\"\n value={text}\n onValueChange={(next) => {\n setText(next);\n const parsed = parseNumber(next);\n if (parsed !== current) setValue(parsed);\n }}\n onKeyDown={handleKeyDown}\n onBlur={(e) => {\n setText(formatNumber(current));\n onBlur?.(e);\n }}\n />\n {/* What a native submit posts: the number, never the half-typed text. */}\n {name ? (\n <input\n type=\"hidden\"\n name={name}\n form={form}\n disabled={rest.disabled}\n value={formatNumber(current)}\n />\n ) : null}\n </div>\n );\n },\n);\n\nNumberField.displayName = \"NumberField\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/inputs/NumberField/NumberField.tsx"],"names":["k"],"mappings":";;;;;AASA,IAAM,MAAA,GAAS,2CAAA;AACf,IAAM,KAAA,GAAQ,YAAA;AAGd,SAAS,YAAY,IAAA,EAA6B;AAChD,EAAA,MAAM,OAAA,GAAU,KAAK,IAAA,EAAK;AAC1B,EAAA,IAAI,CAAC,MAAA,CAAO,IAAA,CAAK,OAAO,GAAG,OAAO,IAAA;AAElC,EAAA,MAAM,CAAA,GAAI,OAAO,OAAO,CAAA;AACxB,EAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,CAAC,GAAG,OAAO,IAAA;AAEhC,EAAA,IAAI,KAAA,CAAM,KAAK,OAAO,CAAA,IAAK,CAAC,MAAA,CAAO,aAAA,CAAc,CAAC,CAAA,EAAG,OAAO,IAAA;AAE5D,EAAA,OAAO,CAAA,KAAM,IAAI,CAAA,GAAI,CAAA;AACvB;AAEA,SAAS,aAAa,KAAA,EAA8B;AAClD,EAAA,OAAO,KAAA,KAAU,IAAA,GAAO,EAAA,GAAK,MAAA,CAAO,KAAK,CAAA;AAC3C;AAGA,SAAS,SAAS,CAAA,EAAmB;AACnC,EAAA,MAAM,CAAC,UAAU,QAAQ,CAAA,GAAI,OAAO,CAAC,CAAA,CAAE,MAAM,G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AAAA;AAAA,OACF;AAAA,MAEC,IAAA,mBACC,GAAA;AAAA,QAAC,OAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,IAAA;AAAA,UACA,IAAA;AAAA,UACA,UAAU,IAAA,CAAK,QAAA;AAAA,UACf,KAAA,EAAO,aAAa,OAAO;AAAA;AAAA,OAC7B,GACE;AAAA,KAAA,EACN,CAAA;AAAA,EAEJ;AACF;AAEA,WAAA,CAAY,WAAA,GAAc,aAAA","file":"chunk-HCIEXBEB.js","sourcesContent":["import { forwardRef, useEffect, useRef, useState, type KeyboardEvent } from \"react\";\nimport { useControllableState } from \"../../../hooks/use-controllable-state\";\nimport { Input } from \"../Input\";\nimport type { NumberFieldProps } from \"./NumberField.types\";\n\n/**\n * Plain decimal notation only. `Number()` alone is not safe here: it reads \"0x10\"\n * as 16 and \"Infinity\" as a number, and those are wrong numbers to emit.\n */\nconst NUMBER = /^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$/;\nconst WHOLE = /^[+-]?\\d+$/;\n\n/** The number the text says, or `null` if it does not say one. */\nfunction parseNumber(text: string): number | null {\n const trimmed = text.trim();\n if (!NUMBER.test(trimmed)) return null;\n\n const n = Number(trimmed);\n if (!Number.isFinite(n)) return null;\n // Past 2^53 a whole number rounds to a different one than was typed.\n if (WHOLE.test(trimmed) && !Number.isSafeInteger(n)) return null;\n\n return n === 0 ? 0 : n; // -0 is 0\n}\n\nfunction formatNumber(value: number | null): string {\n return value === null ? \"\" : String(value);\n}\n\n/** Decimal places in a number, so stepping can round away floating-point dust. */\nfunction decimals(n: number): number {\n const [mantissa, exponent] = String(n).split(\"e\");\n const places = (mantissa.split(\".\")[1] ?? \"\").length - Number(exponent ?? 0);\n return Math.min(Math.max(places, 0), 100);\n}\n\nfunction stepped(\n current: number | null,\n direction: 1 | -1,\n min: number | undefined,\n max: number | undefined,\n step: number,\n): number {\n const base = min ?? 0;\n const places = Math.max(decimals(step), decimals(base));\n const at = (k: number) => Number((base + k * step).toFixed(places));\n const position = ((current ?? 0) - base) / step;\n const nudge = 1e-9;\n\n // The next grid line in that direction, so an off-grid value lands on the grid.\n let k =\n direction === 1\n ? Math.floor(position + nudge) + 1\n : Math.ceil(position - nudge) - 1;\n\n if (max !== undefined && at(k) > max) k = Math.floor((max - base) / step + nudge);\n if (min !== undefined && at(k) < min) k = 0;\n\n return at(k);\n}\n\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(\n (\n {\n value,\n defaultValue = null,\n onValueChange,\n min,\n max,\n step,\n messages,\n name,\n form,\n inputMode,\n onKeyDown,\n onBlur,\n ...rest\n },\n ref,\n ) => {\n const [held, setValue] = useControllableState<number | null>(\n value,\n defaultValue,\n onValueChange,\n );\n // A host's NaN or Infinity has no text form, so it reads as no number.\n const current = typeof held === \"number\" && Number.isFinite(held) ? held : null;\n\n /*\n * The text is held apart from the number because \"1.\" and \"-\" have no number\n * that displays them. It only moves on its own when the number moved to\n * something the text does not say: a change from outside, or a parent refusing\n * this one.\n */\n const [text, setText] = useState(() => formatNumber(current));\n if (parseNumber(text) !== current && text !== formatNumber(current)) {\n setText(formatNumber(current));\n }\n\n const stepSize = typeof step === \"number\" && step > 0 ? step : 1;\n\n const problem = (() => {\n if (text.trim() !== \"\" && parseNumber(text) === null) {\n return messages?.invalid ?? \"Enter a number.\";\n }\n if (current === null) return \"\";\n if (min !== undefined && current < min) return messages?.min ?? `Must be at least ${min}.`;\n if (max !== undefined && current > max) return messages?.max ?? `Must be at most ${max}.`;\n if (typeof step === \"number\" && step > 0) {\n const position = (current - (min ?? 0)) / step;\n if (Math.abs(position - Math.round(position)) > 1e-9) {\n return messages?.step ?? `Must be in steps of ${step}.`;\n }\n }\n return \"\";\n })();\n\n // The text input has no min/max/step of its own, so a form learns of them here.\n // Runs every render: click-to-edit mounts a fresh input.\n const inputRef = useRef<HTMLInputElement | null>(null);\n useEffect(() => {\n inputRef.current?.setCustomValidity(problem);\n });\n\n const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || rest.disabled || rest.readOnly) return;\n if (e.key !== \"ArrowUp\" && e.key !== \"ArrowDown\") return;\n\n e.preventDefault(); // or the caret jumps to the end of the text\n const next = stepped(current, e.key === \"ArrowUp\" ? 1 : -1, min, max, stepSize);\n setText(formatNumber(next));\n if (next !== current) setValue(next);\n };\n\n return (\n <div data-react-fancy-number-field=\"\">\n <Input\n aria-invalid={problem ? true : undefined}\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={current ?? undefined}\n inputMode={\n inputMode ??\n // A numeric or decimal keypad has no minus sign on iOS, so those are\n // only offered where a negative number cannot be valid.\n (min !== undefined && min >= 0\n ? typeof step === \"number\" && Number.isInteger(step)\n ? \"numeric\"\n : \"decimal\"\n : \"text\")\n }\n role=\"spinbutton\"\n {...rest}\n ref={(el) => {\n inputRef.current = el;\n if (typeof ref === \"function\") ref(el);\n else if (ref) ref.current = el;\n }}\n // Text, not `number`: a browser reports \"-\" and \"1e\" in a number input as\n // an empty value, indistinguishable from blank, and turns the wheel into\n // a value change on a focused field. Neither applies to a text input.\n type=\"text\"\n value={text}\n onValueChange={(next) => {\n setText(next);\n const parsed = parseNumber(next);\n if (parsed !== current) setValue(parsed);\n }}\n onKeyDown={handleKeyDown}\n onBlur={(e) => {\n setText(formatNumber(current));\n onBlur?.(e);\n }}\n />\n {/* What a native submit posts: the number, never the half-typed text. */}\n {name ? (\n <input\n type=\"hidden\"\n name={name}\n form={form}\n disabled={rest.disabled}\n value={formatNumber(current)}\n />\n ) : null}\n </div>\n );\n },\n);\n\nNumberField.displayName = \"NumberField\";\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkFQZE5N2N_cjs = require('./chunk-FQZE5N2N.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkQQKWI7QP_cjs = require('./chunk-QQKWI7QP.cjs');
|
|
5
5
|
var chunkTI7D4QDM_cjs = require('./chunk-TI7D4QDM.cjs');
|
|
6
6
|
var chunk57FQGQJK_cjs = require('./chunk-57FQGQJK.cjs');
|
|
7
7
|
var chunkOUYC6EIL_cjs = require('./chunk-OUYC6EIL.cjs');
|
|
@@ -120,7 +120,7 @@ function DropdownItems({ children, className }) {
|
|
|
120
120
|
} = useDropdown();
|
|
121
121
|
const floatingRef = react.useRef(null);
|
|
122
122
|
const outsideRef = react.useRef(null);
|
|
123
|
-
const position =
|
|
123
|
+
const position = chunkQQKWI7QP_cjs.useFloatingPosition(anchorRef, floatingRef, {
|
|
124
124
|
placement,
|
|
125
125
|
offset,
|
|
126
126
|
enabled: open
|
|
@@ -293,5 +293,5 @@ var Dropdown = Object.assign(DropdownRoot, {
|
|
|
293
293
|
|
|
294
294
|
exports.Dropdown = Dropdown;
|
|
295
295
|
exports.useDropdown = useDropdown;
|
|
296
|
-
//# sourceMappingURL=chunk-
|
|
297
|
-
//# sourceMappingURL=chunk-
|
|
296
|
+
//# sourceMappingURL=chunk-HEGM5LMZ.cjs.map
|
|
297
|
+
//# sourceMappingURL=chunk-HEGM5LMZ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Dropdown/Dropdown.context.ts","../src/components/Dropdown/dropdown-focus.ts","../src/components/Dropdown/DropdownTrigger.tsx","../src/components/Dropdown/DropdownItems.tsx","../src/components/Dropdown/DropdownItem.tsx","../src/components/Dropdown/DropdownSeparator.tsx","../src/components/Dropdown/Dropdown.tsx"],"names":["createContext","useContext","jsx","useRef","useFloatingPosition","useCallback","useOutsideClick","useEscapeKey","useAnimation","useState","useEffect","Portal","cn","useMemo"],"mappings":";;;;;;;;;;;AAGO,IAAM,eAAA,GAAkBA,oBAA2C,IAAI,CAAA;AAEvE,SAAS,WAAA,GAAoC;AAClD,EAAA,MAAM,GAAA,GAAMC,iBAAW,eAAe,CAAA;AACtC,EAAA,IAAI,CAAC,GAAA,EA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IA,eAAS,EAAE,CAAA;AACjD,EAAA,MAAM,SAAA,GAAYN,aAAoB,IAAI,CAAA;AAC1C,EAAA,MAAM,eAAA,GAAkBA,aAAgC,IAAI,CAAA;AAC5D,EAAA,MAAM,OAAA,GAAUA,aAA2B,IAAI,CAAA;AAE/C,EAAA,MAAM,YAAA,GAAeE,kBAAY,MAAM;AACrC,IAAA,MAAM,SAAS,SAAA,CAAU,OAAA;AACzB,IAAA,IAAI,CAAC,MAAA,EAAQ;AACb,IAAA,MAAM,MAAA,GACJ,OAAO,aAAA,CAA2B,iBAAiB,MAAM,MAAA,CAAO,QAAA,IAAY,IAAI,MAAA,GAAS,IAAA,CAAA;AAC3F,IAAA,MAAA,EAAQ,KAAA,EAAM;AAAA,EAChB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,GAAA,GAAMQ,aAAA;AAAA,IACV,OAAO;AAAA,MACL,IAAA;AAAA,MACA,OAAA;AAAA,MACA,SAAA;AAAA,MACA,WAAA;AAAA,MACA,cAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,eAAA;AAAA,MACA,OAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,IAAA,EAAM,SAAA,EAAW,WAAA,EAAa,SAAA,EAAW,QAAQ,YAAY;AAAA,GAChE;AAEA,EAAA,uBACEX,cAAAA,CAAC,eAAA,CAAgB,UAAhB,EAAyB,KAAA,EAAO,KAAM,QAAA,EAAS,CAAA;AAEpD;AAEO,IAAM,QAAA,GAAW,MAAA,CAAO,MAAA,CAAO,YAAA,EAAc;AAAA,EAClD,OAAA,EAAS,eAAA;AAAA,EACT,KAAA,EAAO,aAAA;AAAA,EACP,IAAA,EAAM,YAAA;AAAA,EACN,SAAA,EAAW;AACb,CAAC","file":"chunk-QAM6N3VG.cjs","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { DropdownContextValue } from \"./Dropdown.types\";\n\nexport const DropdownContext = createContext<DropdownContextValue | null>(null);\n\nexport function useDropdown(): DropdownContextValue {\n const ctx = useContext(DropdownContext);\n if (!ctx) {\n throw new Error(\n \"Dropdown compound components must be used within <Dropdown>\",\n );\n }\n return ctx;\n}\n","/** Enabled menu items, in DOM order. Disabled items are skipped. */\nexport function menuItems(menu: HTMLElement | null): HTMLElement[] {\n if (!menu) return [];\n return Array.from(\n menu.querySelectorAll<HTMLElement>('[role=\"menuitem\"]:not([aria-disabled=\"true\"]):not([disabled])'),\n );\n}\n\nexport type FocusMove = \"first\" | \"last\" | \"next\" | \"prev\";\n\n/**\n * Focus an item relative to the one that currently has focus, wrapping at both\n * ends. Returns the index focused, or -1 when the menu has no enabled item.\n */\nexport function focusMenuItem(menu: HTMLElement | null, move: FocusMove): number {\n const items = menuItems(menu);\n if (items.length === 0) return -1;\n const current = items.indexOf(document.activeElement as HTMLElement);\n let next: number;\n if (move === \"first\") next = 0;\n else if (move === \"last\") next = items.length - 1;\n else if (current === -1) next = move === \"next\" ? 0 : items.length - 1;\n else next = (current + (move === \"next\" ? 1 : -1) + items.length) % items.length;\n items[next]!.focus();\n return next;\n}\n\n/**\n * Typeahead: focus the next enabled item (after the focused one, wrapping)\n * whose text starts with `char`. Returns the index focused, or -1 for no match.\n */\nexport function focusByChar(menu: HTMLElement | null, char: string): number {\n const items = menuItems(menu);\n if (items.length === 0) return -1;\n const needle = char.toLowerCase();\n const start = items.indexOf(document.activeElement as HTMLElement);\n for (let step = 1; step <= items.length; step++) {\n const i = (start + step + items.length) % items.length;\n if ((items[i]!.textContent ?? \"\").trim().toLowerCase().startsWith(needle)) {\n items[i]!.focus();\n return i;\n }\n }\n return -1;\n}\n","import type { KeyboardEvent, MouseEvent } from \"react\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport { focusMenuItem } from \"./dropdown-focus\";\nimport type { DropdownTriggerProps } from \"./Dropdown.types\";\n\n/**\n * Elements the browser itself turns Enter / Space into a click on. For these\n * the trigger lets the native click open the menu; for anything else (an\n * avatar span with `tabIndex`) it opens the menu itself.\n */\nfunction activatesNatively(el: EventTarget | null): boolean {\n if (!(el instanceof HTMLElement)) return false;\n const tag = el.tagName;\n if (tag === \"BUTTON\" || tag === \"SUMMARY\") return true;\n if (tag === \"A\") return el.hasAttribute(\"href\");\n if (tag === \"INPUT\") {\n const type = (el as HTMLInputElement).type;\n return type === \"button\" || type === \"submit\" || type === \"reset\" || type === \"image\";\n }\n return false;\n}\n\nexport function DropdownTrigger({ children }: DropdownTriggerProps) {\n const { setOpen, open, anchorRef, pendingFocusRef, menuRef } = useDropdown();\n\n // WAI-ARIA menu button: Enter / Space / ArrowDown open the menu on its first\n // item, ArrowUp on its last.\n const onKeyDown = (e: KeyboardEvent<HTMLSpanElement>) => {\n if (e.defaultPrevented) return;\n\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n const target = e.key === \"ArrowDown\" ? \"first\" : \"last\";\n if (open && menuRef.current) {\n focusMenuItem(menuRef.current, target);\n return;\n }\n pendingFocusRef.current = target;\n setOpen(true);\n return;\n }\n\n if (e.key === \"Enter\" || e.key === \" \") {\n if (!open) pendingFocusRef.current = \"first\";\n if (activatesNatively(e.target)) return; // its click toggles the menu\n e.preventDefault();\n if (open) pendingFocusRef.current = null;\n setOpen(!open);\n }\n };\n\n const onClick = (_e: MouseEvent<HTMLSpanElement>) => {\n if (open) pendingFocusRef.current = null;\n setOpen(!open);\n };\n\n return (\n <span\n ref={anchorRef as React.RefObject<HTMLSpanElement>}\n data-react-fancy-dropdown-trigger=\"\"\n className=\"inline-flex\"\n onClick={onClick}\n onKeyDown={onKeyDown}\n aria-expanded={open}\n aria-haspopup=\"menu\"\n >\n {children}\n </span>\n );\n}\n\nDropdownTrigger.displayName = \"DropdownTrigger\";\n","import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { focusByChar, focusMenuItem, type FocusMove } from \"./dropdown-focus\";\nimport { cn } from \"../../utils/cn\";\nimport { Portal } from \"../Portal\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport { useFloatingPosition } from \"../../hooks/use-floating-position\";\nimport { useOutsideClick } from \"../../hooks/use-outside-click\";\nimport { useEscapeKey } from \"../../hooks/use-escape-key\";\nimport { useAnimation } from \"../../hooks/use-animation\";\nimport type { DropdownItemsProps } from \"./Dropdown.types\";\n\nexport function DropdownItems({ children, className }: DropdownItemsProps) {\n const {\n open,\n setOpen,\n anchorRef,\n setActiveIndex,\n placement,\n offset,\n pendingFocusRef,\n menuRef,\n focusTrigger,\n } = useDropdown();\n const floatingRef = useRef<HTMLDivElement>(null);\n const outsideRef = useRef<HTMLDivElement>(null);\n\n const position = useFloatingPosition(anchorRef, floatingRef, {\n placement,\n offset,\n enabled: open,\n });\n\n const close = useCallback(() => {\n pendingFocusRef.current = null;\n setOpen(false);\n setActiveIndex(-1);\n }, [setOpen, setActiveIndex, pendingFocusRef]);\n\n useOutsideClick(outsideRef, close, open, anchorRef);\n // Escape closes THIS menu (the innermost layer) and returns focus to where\n // the menu came from. An outside click does not move focus: the user put it\n // somewhere already.\n useEscapeKey(() => {\n close();\n focusTrigger();\n }, open);\n\n const { mounted, className: animClass, ref: animRef } = useAnimation({\n open,\n enterClass: \"fancy-scale-in\",\n exitClass: \"fancy-fade-out\",\n });\n\n // The menu element, as STATE. It does not exist when `open` first turns true:\n // `useAnimation` mounts it a render later and `Portal` a render after that.\n // Before 5.64.1 the key handler lived in an effect keyed on `open` that\n // returned early while the element was null and never re-ran, so the arrow\n // keys did nothing in any Dropdown. Keying on the element itself fixes the\n // timing for good.\n const [menuEl, setMenuEl] = useState<HTMLDivElement | null>(null);\n\n const setMenuRef = useCallback(\n (node: HTMLDivElement | null) => {\n outsideRef.current = node;\n floatingRef.current = node;\n (animRef as React.MutableRefObject<HTMLElement | null>).current = node;\n menuRef.current = node;\n setMenuEl(node);\n },\n [animRef, menuRef],\n );\n\n // Opened from the keyboard: focus the first / last item once it exists.\n useEffect(() => {\n if (!open || !menuEl) return;\n const target = pendingFocusRef.current;\n if (!target) return;\n pendingFocusRef.current = null;\n setActiveIndex(focusMenuItem(menuEl, target));\n }, [open, menuEl, pendingFocusRef, setActiveIndex]);\n\n // Keys are handled on the menu itself: focus is inside it while it is driven\n // from the keyboard, and React delivers the event through the portal.\n const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n const menu = e.currentTarget;\n const moves: Record<string, FocusMove> = {\n ArrowDown: \"next\",\n ArrowUp: \"prev\",\n Home: \"first\",\n End: \"last\",\n };\n const move = moves[e.key];\n if (move) {\n e.preventDefault();\n setActiveIndex(focusMenuItem(menu, move));\n return;\n }\n if (e.key === \"Tab\") {\n // Close, and put focus back on the trigger WITHOUT preventing the\n // default: the browser's own Tab then moves on from the trigger's place\n // in the tab order rather than from the end of <body>, where the\n // portalled menu lives.\n close();\n focusTrigger();\n return;\n }\n if (e.key.length === 1 && e.key !== \" \" && !e.ctrlKey && !e.metaKey && !e.altKey) {\n const i = focusByChar(menu, e.key);\n if (i >= 0) setActiveIndex(i);\n }\n };\n\n if (!mounted) return null;\n\n return (\n <Portal>\n <div\n ref={setMenuRef}\n data-react-fancy-dropdown=\"\"\n role=\"menu\"\n onKeyDown={onKeyDown}\n className={cn(\n \"fixed z-50 min-w-[8rem] rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] p-1 shadow-lg dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n animClass,\n className,\n )}\n dir={position.dir}\n style={{ left: position.x, top: position.y }}\n >\n {children}\n </div>\n </Portal>\n );\n}\n\nDropdownItems.displayName = \"DropdownItems\";\n","import { cn } from \"../../utils/cn\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport type { DropdownItemProps } from \"./Dropdown.types\";\n\nexport function DropdownItem({\n children,\n onClick,\n disabled = false,\n danger = false,\n className,\n}: DropdownItemProps) {\n const { setOpen, focusTrigger } = useDropdown();\n\n return (\n <button\n data-react-fancy-dropdown-item=\"\"\n type=\"button\"\n role=\"menuitem\"\n disabled={disabled}\n aria-disabled={disabled}\n className={cn(\n \"flex w-full items-center rounded-lg px-3 py-2 text-start text-sm transition-colors\",\n danger\n ? \"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950\"\n : \"text-[color:var(--fancy-text-soft,var(--color-zinc-700))] hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))] dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n disabled && \"cursor-not-allowed opacity-50\",\n className,\n )}\n onClick={(e) => {\n if (disabled) return;\n const hadFocus = document.activeElement === e.currentTarget;\n onClick?.();\n setOpen(false);\n // The item is about to unmount; without this, focus falls to <body>.\n // Only when the item held focus, and only if onClick did not move it.\n if (hadFocus && document.activeElement === e.currentTarget) focusTrigger();\n }}\n >\n {children}\n </button>\n );\n}\n\nDropdownItem.displayName = \"DropdownItem\";\n","import { cn } from \"../../utils/cn\";\nimport type { DropdownSeparatorProps } from \"./Dropdown.types\";\n\nexport function DropdownSeparator({ className }: DropdownSeparatorProps) {\n return (\n <div\n data-react-fancy-dropdown-separator=\"\"\n role=\"separator\"\n className={cn(\n \"my-1 h-px bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n />\n );\n}\n\nDropdownSeparator.displayName = \"DropdownSeparator\";\n","import { useCallback, useMemo, useRef, useState } from \"react\";\nimport { DropdownContext } from \"./Dropdown.context\";\nimport { DropdownTrigger } from \"./DropdownTrigger\";\nimport { DropdownItems } from \"./DropdownItems\";\nimport { DropdownItem } from \"./DropdownItem\";\nimport { DropdownSeparator } from \"./DropdownSeparator\";\nimport type { DropdownProps } from \"./Dropdown.types\";\n\nconst TRIGGER_FOCUSABLE =\n 'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\nfunction DropdownRoot({\n children,\n placement = \"bottom-start\",\n offset = 4,\n}: DropdownProps) {\n const [open, setOpen] = useState(false);\n const [activeIndex, setActiveIndex] = useState(-1);\n const anchorRef = useRef<HTMLElement>(null);\n const pendingFocusRef = useRef<\"first\" | \"last\" | null>(null);\n const menuRef = useRef<HTMLElement | null>(null);\n\n const focusTrigger = useCallback(() => {\n const anchor = anchorRef.current;\n if (!anchor) return;\n const target =\n anchor.querySelector<HTMLElement>(TRIGGER_FOCUSABLE) ?? (anchor.tabIndex >= 0 ? anchor : null);\n target?.focus();\n }, []);\n\n const ctx = useMemo(\n () => ({\n open,\n setOpen,\n anchorRef,\n activeIndex,\n setActiveIndex,\n placement,\n offset,\n pendingFocusRef,\n menuRef,\n focusTrigger,\n }),\n [open, anchorRef, activeIndex, placement, offset, focusTrigger],\n );\n\n return (\n <DropdownContext.Provider value={ctx}>{children}</DropdownContext.Provider>\n );\n}\n\nexport const Dropdown = Object.assign(DropdownRoot, {\n Trigger: DropdownTrigger,\n Items: DropdownItems,\n Item: DropdownItem,\n Separator: DropdownSeparator,\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/Dropdown/Dropdown.context.ts","../src/components/Dropdown/dropdown-focus.ts","../src/components/Dropdown/DropdownTrigger.tsx","../src/components/Dropdown/DropdownItems.tsx","../src/components/Dropdown/DropdownItem.tsx","../src/components/Dropdown/DropdownSeparator.tsx","../src/components/Dropdown/Dropdown.tsx"],"names":["createContext","useContext","jsx","useRef","useFloatingPosition","useCallback","useOutsideClick","useEscapeKey","useAnimation","useState","useEffect","Portal","cn","useMemo"],"mappings":";;;;;;;;;;;AAGO,IAAM,eAAA,GAAkBA,oBAA2C,IAAI,CAAA;AAEvE,SAAS,WAAA,GAAoC;AAClD,EAAA,MAAM,GAAA,GAAMC,iBAAW,eAAe,CAAA;AACtC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AA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GAAYN,aAAoB,IAAI,CAAA;AAC1C,EAAA,MAAM,eAAA,GAAkBA,aAAgC,IAAI,CAAA;AAC5D,EAAA,MAAM,OAAA,GAAUA,aAA2B,IAAI,CAAA;AAE/C,EAAA,MAAM,YAAA,GAAeE,kBAAY,MAAM;AACrC,IAAA,MAAM,SAAS,SAAA,CAAU,OAAA;AACzB,IAAA,IAAI,CAAC,MAAA,EAAQ;AACb,IAAA,MAAM,MAAA,GACJ,OAAO,aAAA,CAA2B,iBAAiB,MAAM,MAAA,CAAO,QAAA,IAAY,IAAI,MAAA,GAAS,IAAA,CAAA;AAC3F,IAAA,MAAA,EAAQ,KAAA,EAAM;AAAA,EAChB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,GAAA,GAAMQ,aAAA;AAAA,IACV,OAAO;AAAA,MACL,IAAA;AAAA,MACA,OAAA;AAAA,MACA,SAAA;AAAA,MACA,WAAA;AAAA,MACA,cAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,eAAA;AAAA,MACA,OAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,IAAA,EAAM,SAAA,EAAW,WAAA,EAAa,SAAA,EAAW,QAAQ,YAAY;AAAA,GAChE;AAEA,EAAA,uBACEX,cAAAA,CAAC,eAAA,CAAgB,UAAhB,EAAyB,KAAA,EAAO,KAAM,QAAA,EAAS,CAAA;AAEpD;AAEO,IAAM,QAAA,GAAW,MAAA,CAAO,MAAA,CAAO,YAAA,EAAc;AAAA,EAClD,OAAA,EAAS,eAAA;AAAA,EACT,KAAA,EAAO,aAAA;AAAA,EACP,IAAA,EAAM,YAAA;AAAA,EACN,SAAA,EAAW;AACb,CAAC","file":"chunk-HEGM5LMZ.cjs","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { DropdownContextValue } from \"./Dropdown.types\";\n\nexport const DropdownContext = createContext<DropdownContextValue | null>(null);\n\nexport function useDropdown(): DropdownContextValue {\n const ctx = useContext(DropdownContext);\n if (!ctx) {\n throw new Error(\n \"Dropdown compound components must be used within <Dropdown>\",\n );\n }\n return ctx;\n}\n","/** Enabled menu items, in DOM order. Disabled items are skipped. */\nexport function menuItems(menu: HTMLElement | null): HTMLElement[] {\n if (!menu) return [];\n return Array.from(\n menu.querySelectorAll<HTMLElement>('[role=\"menuitem\"]:not([aria-disabled=\"true\"]):not([disabled])'),\n );\n}\n\nexport type FocusMove = \"first\" | \"last\" | \"next\" | \"prev\";\n\n/**\n * Focus an item relative to the one that currently has focus, wrapping at both\n * ends. Returns the index focused, or -1 when the menu has no enabled item.\n */\nexport function focusMenuItem(menu: HTMLElement | null, move: FocusMove): number {\n const items = menuItems(menu);\n if (items.length === 0) return -1;\n const current = items.indexOf(document.activeElement as HTMLElement);\n let next: number;\n if (move === \"first\") next = 0;\n else if (move === \"last\") next = items.length - 1;\n else if (current === -1) next = move === \"next\" ? 0 : items.length - 1;\n else next = (current + (move === \"next\" ? 1 : -1) + items.length) % items.length;\n items[next]!.focus();\n return next;\n}\n\n/**\n * Typeahead: focus the next enabled item (after the focused one, wrapping)\n * whose text starts with `char`. Returns the index focused, or -1 for no match.\n */\nexport function focusByChar(menu: HTMLElement | null, char: string): number {\n const items = menuItems(menu);\n if (items.length === 0) return -1;\n const needle = char.toLowerCase();\n const start = items.indexOf(document.activeElement as HTMLElement);\n for (let step = 1; step <= items.length; step++) {\n const i = (start + step + items.length) % items.length;\n if ((items[i]!.textContent ?? \"\").trim().toLowerCase().startsWith(needle)) {\n items[i]!.focus();\n return i;\n }\n }\n return -1;\n}\n","import type { KeyboardEvent, MouseEvent } from \"react\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport { focusMenuItem } from \"./dropdown-focus\";\nimport type { DropdownTriggerProps } from \"./Dropdown.types\";\n\n/**\n * Elements the browser itself turns Enter / Space into a click on. For these\n * the trigger lets the native click open the menu; for anything else (an\n * avatar span with `tabIndex`) it opens the menu itself.\n */\nfunction activatesNatively(el: EventTarget | null): boolean {\n if (!(el instanceof HTMLElement)) return false;\n const tag = el.tagName;\n if (tag === \"BUTTON\" || tag === \"SUMMARY\") return true;\n if (tag === \"A\") return el.hasAttribute(\"href\");\n if (tag === \"INPUT\") {\n const type = (el as HTMLInputElement).type;\n return type === \"button\" || type === \"submit\" || type === \"reset\" || type === \"image\";\n }\n return false;\n}\n\nexport function DropdownTrigger({ children }: DropdownTriggerProps) {\n const { setOpen, open, anchorRef, pendingFocusRef, menuRef } = useDropdown();\n\n // WAI-ARIA menu button: Enter / Space / ArrowDown open the menu on its first\n // item, ArrowUp on its last.\n const onKeyDown = (e: KeyboardEvent<HTMLSpanElement>) => {\n if (e.defaultPrevented) return;\n\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n const target = e.key === \"ArrowDown\" ? \"first\" : \"last\";\n if (open && menuRef.current) {\n focusMenuItem(menuRef.current, target);\n return;\n }\n pendingFocusRef.current = target;\n setOpen(true);\n return;\n }\n\n if (e.key === \"Enter\" || e.key === \" \") {\n if (!open) pendingFocusRef.current = \"first\";\n if (activatesNatively(e.target)) return; // its click toggles the menu\n e.preventDefault();\n if (open) pendingFocusRef.current = null;\n setOpen(!open);\n }\n };\n\n const onClick = (_e: MouseEvent<HTMLSpanElement>) => {\n if (open) pendingFocusRef.current = null;\n setOpen(!open);\n };\n\n return (\n <span\n ref={anchorRef as React.RefObject<HTMLSpanElement>}\n data-react-fancy-dropdown-trigger=\"\"\n className=\"inline-flex\"\n onClick={onClick}\n onKeyDown={onKeyDown}\n aria-expanded={open}\n aria-haspopup=\"menu\"\n >\n {children}\n </span>\n );\n}\n\nDropdownTrigger.displayName = \"DropdownTrigger\";\n","import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { focusByChar, focusMenuItem, type FocusMove } from \"./dropdown-focus\";\nimport { cn } from \"../../utils/cn\";\nimport { Portal } from \"../Portal\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport { useFloatingPosition } from \"../../hooks/use-floating-position\";\nimport { useOutsideClick } from \"../../hooks/use-outside-click\";\nimport { useEscapeKey } from \"../../hooks/use-escape-key\";\nimport { useAnimation } from \"../../hooks/use-animation\";\nimport type { DropdownItemsProps } from \"./Dropdown.types\";\n\nexport function DropdownItems({ children, className }: DropdownItemsProps) {\n const {\n open,\n setOpen,\n anchorRef,\n setActiveIndex,\n placement,\n offset,\n pendingFocusRef,\n menuRef,\n focusTrigger,\n } = useDropdown();\n const floatingRef = useRef<HTMLDivElement>(null);\n const outsideRef = useRef<HTMLDivElement>(null);\n\n const position = useFloatingPosition(anchorRef, floatingRef, {\n placement,\n offset,\n enabled: open,\n });\n\n const close = useCallback(() => {\n pendingFocusRef.current = null;\n setOpen(false);\n setActiveIndex(-1);\n }, [setOpen, setActiveIndex, pendingFocusRef]);\n\n useOutsideClick(outsideRef, close, open, anchorRef);\n // Escape closes THIS menu (the innermost layer) and returns focus to where\n // the menu came from. An outside click does not move focus: the user put it\n // somewhere already.\n useEscapeKey(() => {\n close();\n focusTrigger();\n }, open);\n\n const { mounted, className: animClass, ref: animRef } = useAnimation({\n open,\n enterClass: \"fancy-scale-in\",\n exitClass: \"fancy-fade-out\",\n });\n\n // The menu element, as STATE. It does not exist when `open` first turns true:\n // `useAnimation` mounts it a render later and `Portal` a render after that.\n // Before 5.64.1 the key handler lived in an effect keyed on `open` that\n // returned early while the element was null and never re-ran, so the arrow\n // keys did nothing in any Dropdown. Keying on the element itself fixes the\n // timing for good.\n const [menuEl, setMenuEl] = useState<HTMLDivElement | null>(null);\n\n const setMenuRef = useCallback(\n (node: HTMLDivElement | null) => {\n outsideRef.current = node;\n floatingRef.current = node;\n (animRef as React.MutableRefObject<HTMLElement | null>).current = node;\n menuRef.current = node;\n setMenuEl(node);\n },\n [animRef, menuRef],\n );\n\n // Opened from the keyboard: focus the first / last item once it exists.\n useEffect(() => {\n if (!open || !menuEl) return;\n const target = pendingFocusRef.current;\n if (!target) return;\n pendingFocusRef.current = null;\n setActiveIndex(focusMenuItem(menuEl, target));\n }, [open, menuEl, pendingFocusRef, setActiveIndex]);\n\n // Keys are handled on the menu itself: focus is inside it while it is driven\n // from the keyboard, and React delivers the event through the portal.\n const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n const menu = e.currentTarget;\n const moves: Record<string, FocusMove> = {\n ArrowDown: \"next\",\n ArrowUp: \"prev\",\n Home: \"first\",\n End: \"last\",\n };\n const move = moves[e.key];\n if (move) {\n e.preventDefault();\n setActiveIndex(focusMenuItem(menu, move));\n return;\n }\n if (e.key === \"Tab\") {\n // Close, and put focus back on the trigger WITHOUT preventing the\n // default: the browser's own Tab then moves on from the trigger's place\n // in the tab order rather than from the end of <body>, where the\n // portalled menu lives.\n close();\n focusTrigger();\n return;\n }\n if (e.key.length === 1 && e.key !== \" \" && !e.ctrlKey && !e.metaKey && !e.altKey) {\n const i = focusByChar(menu, e.key);\n if (i >= 0) setActiveIndex(i);\n }\n };\n\n if (!mounted) return null;\n\n return (\n <Portal>\n <div\n ref={setMenuRef}\n data-react-fancy-dropdown=\"\"\n role=\"menu\"\n onKeyDown={onKeyDown}\n className={cn(\n \"fixed z-50 min-w-[8rem] rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] p-1 shadow-lg dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n animClass,\n className,\n )}\n dir={position.dir}\n style={{ left: position.x, top: position.y }}\n >\n {children}\n </div>\n </Portal>\n );\n}\n\nDropdownItems.displayName = \"DropdownItems\";\n","import { cn } from \"../../utils/cn\";\nimport { useDropdown } from \"./Dropdown.context\";\nimport type { DropdownItemProps } from \"./Dropdown.types\";\n\nexport function DropdownItem({\n children,\n onClick,\n disabled = false,\n danger = false,\n className,\n}: DropdownItemProps) {\n const { setOpen, focusTrigger } = useDropdown();\n\n return (\n <button\n data-react-fancy-dropdown-item=\"\"\n type=\"button\"\n role=\"menuitem\"\n disabled={disabled}\n aria-disabled={disabled}\n className={cn(\n \"flex w-full items-center rounded-lg px-3 py-2 text-start text-sm transition-colors\",\n danger\n ? \"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950\"\n : \"text-[color:var(--fancy-text-soft,var(--color-zinc-700))] hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))] dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n disabled && \"cursor-not-allowed opacity-50\",\n className,\n )}\n onClick={(e) => {\n if (disabled) return;\n const hadFocus = document.activeElement === e.currentTarget;\n onClick?.();\n setOpen(false);\n // The item is about to unmount; without this, focus falls to <body>.\n // Only when the item held focus, and only if onClick did not move it.\n if (hadFocus && document.activeElement === e.currentTarget) focusTrigger();\n }}\n >\n {children}\n </button>\n );\n}\n\nDropdownItem.displayName = \"DropdownItem\";\n","import { cn } from \"../../utils/cn\";\nimport type { DropdownSeparatorProps } from \"./Dropdown.types\";\n\nexport function DropdownSeparator({ className }: DropdownSeparatorProps) {\n return (\n <div\n data-react-fancy-dropdown-separator=\"\"\n role=\"separator\"\n className={cn(\n \"my-1 h-px bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n className,\n )}\n />\n );\n}\n\nDropdownSeparator.displayName = \"DropdownSeparator\";\n","import { useCallback, useMemo, useRef, useState } from \"react\";\nimport { DropdownContext } from \"./Dropdown.context\";\nimport { DropdownTrigger } from \"./DropdownTrigger\";\nimport { DropdownItems } from \"./DropdownItems\";\nimport { DropdownItem } from \"./DropdownItem\";\nimport { DropdownSeparator } from \"./DropdownSeparator\";\nimport type { DropdownProps } from \"./Dropdown.types\";\n\nconst TRIGGER_FOCUSABLE =\n 'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\nfunction DropdownRoot({\n children,\n placement = \"bottom-start\",\n offset = 4,\n}: DropdownProps) {\n const [open, setOpen] = useState(false);\n const [activeIndex, setActiveIndex] = useState(-1);\n const anchorRef = useRef<HTMLElement>(null);\n const pendingFocusRef = useRef<\"first\" | \"last\" | null>(null);\n const menuRef = useRef<HTMLElement | null>(null);\n\n const focusTrigger = useCallback(() => {\n const anchor = anchorRef.current;\n if (!anchor) return;\n const target =\n anchor.querySelector<HTMLElement>(TRIGGER_FOCUSABLE) ?? (anchor.tabIndex >= 0 ? anchor : null);\n target?.focus();\n }, []);\n\n const ctx = useMemo(\n () => ({\n open,\n setOpen,\n anchorRef,\n activeIndex,\n setActiveIndex,\n placement,\n offset,\n pendingFocusRef,\n menuRef,\n focusTrigger,\n }),\n [open, anchorRef, activeIndex, placement, offset, focusTrigger],\n );\n\n return (\n <DropdownContext.Provider value={ctx}>{children}</DropdownContext.Provider>\n );\n}\n\nexport const Dropdown = Object.assign(DropdownRoot, {\n Trigger: DropdownTrigger,\n Items: DropdownItems,\n Item: DropdownItem,\n Separator: DropdownSeparator,\n});\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useAcknowledgedSubmit } from './chunk-J6IQHJET.js';
|
|
2
|
-
import { useInlinePaste, withSeparators, endsOf, InlinePasteEditor, PastedFilesInput } from './chunk-
|
|
2
|
+
import { useInlinePaste, withSeparators, endsOf, InlinePasteEditor, PastedFilesInput } from './chunk-FECD3WKN.js';
|
|
3
3
|
import { visuallyHidden } from './chunk-I3LAFKJU.js';
|
|
4
4
|
import { isImeComposing } from './chunk-S42OGG43.js';
|
|
5
5
|
import { useControllableState } from './chunk-EDYAXGUM.js';
|
|
@@ -279,5 +279,5 @@ function sameImages(a, b) {
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
export { Composer };
|
|
282
|
-
//# sourceMappingURL=chunk-
|
|
283
|
-
//# sourceMappingURL=chunk-
|
|
282
|
+
//# sourceMappingURL=chunk-J57JSHDC.js.map
|
|
283
|
+
//# sourceMappingURL=chunk-J57JSHDC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Composer/Composer.tsx"],"names":["Composer","paste"],"mappings":";;;;;;;;;AAmBA,IAAM,aAAA,GAAgB,EAAA;AAEf,IAAM,QAAA,GAAW,UAAA;AAAA,EACtB,SAASA,SAAAA,CACP;AAAA,IACE,KAAA,EAAO,eAAA;AAAA,IACP,YAAA,GAAe,EAAA;AAAA,IACf,QAAA;AAAA,IACA,QAAA;AAAA,IACA,aAAA;AAAA,IACA,WAAA,GAAc,mBAAA;AAAA,IACd,OAAA;AAAA,IACA,QAAA,GAAW,KAAA;AAAA,IACX,YAAA,GAAe,KAAA;AAAA,IACf,IAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA,GAAiB,OAAA;AAAA,IACjB,WAAA,GAAc,KAAA;AAAA,IACd,YAAA,GAAe,aAAA;AAAA,IACf,kBAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA,EAAY,oBAAA;AAAA,IACZ,kBAAA;AAAA,IACA,UAAA,EAAY,oBAAA;AAAA,IACZ,kBAAA;AAAA,IACA;AAAA,KAEF,GAAA,EACA;AACA,IAAA,MAAM,SAAS,cAAA,KAAmB,QAAA;AAClC,IAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,oBAAA;AAAA,MACxB,eAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAM,WAAA,GAAc,OAA4B,IAAI,CAAA;AACpD,IAAA,MAAM,SAAA,GAAY,OAAgC,IAAI,CAAA;AAOtD,IAAA,MAAM,QAAQ,cAAA,CAAe;AAAA,MAC3B,cAAA;AAAA,MACA,WAAA;AAAA,MACA,YAAA;AAAA,MACA,kBAAA;AAAA,MACA,UAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAA,EAAY,oBAAA;AAAA,MACZ,kBAAA;AAAA,MACA,UAAA,EAAY,oBAAA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A;AAAA,cAAA;AAAA,gBACC,IAAA,EAAK,QAAA;AAAA,gBACL,gCAAA,EAA+B,EAAA;AAAA,gBAC/B,OAAA,EAAS,YAAA;AAAA,gBACT,QAAA,EAAU,QAAA,IAAY,YAAA,IAAgB,UAAA,IAAc,CAAC,UAAA;AAAA,gBACrD,aAAW,UAAA,IAAc,MAAA;AAAA,gBACzB,SAAA,EAAU,mLAAA;AAAA,gBACX,QAAA,EAAA;AAAA;AAAA;AAED,WAAA,EACF;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AAEA,QAAA,CAAS,WAAA,GAAc,UAAA;AAGvB,SAAS,UAAA,CAAW,GAAgB,CAAA,EAAyB;AAC3D,EAAA,OACE,CAAA,CAAE,MAAA,KAAW,CAAA,CAAE,MAAA,IACf,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,CAAE,EAAA,KAAO,CAAA,CAAE,CAAC,EAAG,EAAA,IAAM,CAAA,CAAE,IAAA,KAAS,CAAA,CAAE,CAAC,CAAA,CAAG,IAAA,IAAQ,CAAA,CAAE,KAAA,KAAU,CAAA,CAAE,CAAC,CAAA,CAAG,KAAK,CAAA;AAE3F;AAEA,SAAS,UAAA,CAAW,GAAgB,CAAA,EAAyB;AAC3D,EAAA,OACE,CAAA,CAAE,MAAA,KAAW,CAAA,CAAE,MAAA,IACf,CAAA,CAAE,KAAA,CAAM,CAAC,GAAA,EAAK,CAAA,KAAM,GAAA,CAAI,EAAA,KAAO,CAAA,CAAE,CAAC,EAAG,EAAA,IAAM,GAAA,CAAI,KAAA,KAAU,CAAA,CAAE,CAAC,CAAA,CAAG,KAAA,IAAS,GAAA,CAAI,IAAA,KAAS,CAAA,CAAE,CAAC,CAAA,CAAG,IAAI,CAAA;AAEnG","file":"chunk-KAKKZDCE.js","sourcesContent":["import { forwardRef, useCallback, useMemo, useRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { isImeComposing } from \"../../utils/ime\";\nimport { visuallyHidden } from \"../../utils/visually-hidden\";\nimport { useAcknowledgedSubmit } from \"../../hooks/use-acknowledged-submit\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport {\n endsOf,\n InlinePasteEditor,\n PastedFilesInput,\n useInlinePaste,\n withSeparators,\n type HeldImage,\n type HeldPaste,\n type InlinePasteEditorHandle,\n} from \"../PastePills\";\nimport type { ComposerProps } from \"./Composer.types\";\n\n/** Characters of a held paste shown at each end of the hover preview, unless `previewChars` says otherwise. */\nconst PREVIEW_CHARS = 20;\n\nexport const Composer = forwardRef<HTMLDivElement, ComposerProps>(\n function Composer(\n {\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onSubmit,\n onSubmitError,\n placeholder = \"Type a message...\",\n actions,\n disabled = false,\n sendDisabled = false,\n name,\n inputId,\n className,\n pasteThreshold,\n pastePlacement = \"above\",\n pasteImages = false,\n previewChars = PREVIEW_CHARS,\n renderPastePreview,\n classNames,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n pasteFilesName,\n },\n ref,\n ) {\n const inline = pastePlacement === \"inline\";\n const [value, setValue] = useControllableState(\n controlledValue,\n defaultValue,\n onChange,\n );\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const editorRef = useRef<InlinePasteEditorHandle>(null);\n /*\n * The holding logic lives in `usePastePills`, wrapped by `useInlinePaste` for\n * the inline placement — which `PromptInput` shares, so the two components\n * cannot disagree about what a pill means. The rule that must not drift is\n * the one below: a send with pills still closed carries the text.\n */\n const paste = useInlinePaste({\n pasteThreshold,\n pasteImages,\n previewChars,\n renderPastePreview,\n classNames,\n disabled,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n editorRef,\n });\n const pills = paste.pills;\n const heldPastes = paste.heldPastes;\n const pastedFiles = useMemo(\n () => (inline && pasteImages ? paste.imagesIn(value).map((i) => i.file) : []),\n [inline, pasteImages, paste, value],\n );\n\n const handlePaste = useCallback(\n (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n // Composable by design, so this reads as a question rather than a handover.\n // Nothing else here wants the paste, so the answer is simply ignored.\n pills.handlePaste(e);\n },\n [pills],\n );\n\n const handleInlineChange = useCallback(\n (next: string) => {\n setValue(next);\n paste.prune(next);\n },\n [setValue, paste],\n );\n\n /** Everything the person believes they are sending, in the order they built it. */\n const composeOutgoing = useCallback(() => {\n if (inline) return paste.expand(value);\n\n return [value, ...heldPastes.map((p) => p.text)].filter(Boolean).join(\"\\n\\n\");\n }, [inline, value, heldPastes, paste]);\n\n const hasContent = value.trim().length > 0 || (!inline && heldPastes.length > 0);\n\n const focusInput = useCallback(() => {\n if (inline) editorRef.current?.focus();\n else textareaRef.current?.focus();\n }, [inline]);\n\n const ack = useAcknowledgedSubmit(onSubmitError);\n const submitting = ack.status === \"submitting\";\n\n /*\n * The draft's REVISION: bumped by every render in which the text, a held\n * paste or a held image differs from the last one seen — the person typing\n * or pasting, or a host moving a controlled `value` / `heldPastes` /\n * `heldImages`. An acknowledged send clears only if the revision is still\n * the one it sent. Comparing content instead (5.70.0) threw away newer\n * drafts that happened to compare equal: an edit typed and undone, a pill\n * whose text the host changed under the same id.\n */\n const heldImages = paste.heldImages;\n const revisionRef = useRef(0);\n const seenRef = useRef({ value, heldPastes, heldImages });\n const seen = seenRef.current;\n if (seen.value !== value || seen.heldPastes !== heldPastes || seen.heldImages !== heldImages) {\n if (\n seen.value !== value ||\n !samePastes(seen.heldPastes, heldPastes) ||\n !sameImages(seen.heldImages, heldImages)\n ) {\n revisionRef.current += 1;\n }\n seenRef.current = { value, heldPastes, heldImages };\n }\n\n const handleSubmit = useCallback(() => {\n if (!hasContent || disabled || sendDisabled || ack.busy()) return;\n\n /*\n * THE DANGEROUS STATE, and the reason this feature needed a spec rather than\n * a guess. A pill reads as \"your paste is attached\" — so a send that drops it\n * means asking a question about a document without the document, and nobody\n * can tell: the sender believes it went, the receiver sees a question about\n * nothing.\n *\n * Above the input, held pastes go out in arrival order after what was typed,\n * because people type the question BEFORE pasting the thing it is about.\n * Inline, every pill goes out exactly where it sits.\n */\n const images = inline ? paste.imagesIn(value) : [];\n\n const result = onSubmit?.(composeOutgoing(), { images });\n const sent = revisionRef.current;\n ack.track(result, () => {\n /*\n * A void `onSubmit` reaches here synchronously, so `sent` is still the\n * current revision and this clears exactly as it always has. An async one\n * reaches here when it resolves: if anything changed the message while it\n * was in flight, that message is newer than the send, even if it reads the\n * same, and throwing it away is the one outcome nobody can undo. So only\n * the revision that was sent is cleared.\n */\n if (revisionRef.current !== sent) return;\n setValue(\"\");\n paste.clear();\n });\n // Focus goes back to the text at once, as before: it stays editable while\n // a send is in flight, and the send button the person may have clicked is\n // about to be disabled.\n focusInput();\n }, [hasContent, disabled, sendDisabled, ack, value, inline, paste, onSubmit, composeOutgoing, setValue, focusInput]);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n // Enter that confirms an IME composition finishes a word; it is not a send.\n if (e.key === \"Enter\" && !e.shiftKey && !isImeComposing(e)) {\n e.preventDefault();\n handleSubmit();\n }\n };\n\n /** Above the input: click a pill to dump it in, APPENDED to what is already typed. */\n const insertPaste = useCallback(\n (held: HeldPaste) => {\n // `expand` removes it and hands back the text; inserting is this\n // component's job because the hook owns no DOM.\n const text = pills.expand(held.id);\n\n if (text === undefined) return;\n\n setValue((current) => (current ? `${current}\\n\\n${text}` : text));\n textareaRef.current?.focus();\n },\n [pills, setValue],\n );\n\n return (\n <div\n data-react-fancy-composer=\"\"\n // Absent while idle; \"submitting\" while an onSubmit Promise is pending;\n // \"error\" after one was refused, until the next send.\n data-submit-state={ack.status === \"idle\" ? undefined : ack.status}\n ref={ref}\n className={cn(\n \"rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n {!inline && heldPastes.length > 0 && (\n <div\n data-react-fancy-composer-paste-pills=\"\"\n className=\"flex flex-wrap gap-1.5 px-3 pt-3\"\n >\n {heldPastes.map((paste) => (\n // `group` + `group-hover` rather than hover state: the preview is\n // presentation, and a useState for it would be one more thing an\n // agent could desynchronise.\n <span key={paste.id} className=\"group relative inline-flex\">\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill={paste.id}\n onClick={() => insertPaste(paste)}\n disabled={disabled}\n // No `title`. A native tooltip plus the hover preview below\n // renders TWO tooltips on the same hover, at different delays.\n // The label says what clicking does; the preview says what the\n // text is, and it is linked rather than merely adjacent so a\n // screen reader reaches it too.\n aria-label={`Insert this pasted text, ${withSeparators(paste.text.length)} characters`}\n aria-describedby={`${paste.id}-preview`}\n // `pr-7` leaves room for the absolutely-positioned × that sits\n // over this button's right edge. With a smaller right padding the\n // × lands on top of the label.\n className={cn(\n \"inline-flex items-center gap-1.5 rounded-full border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-zinc-50 py-1 ps-2.5 pe-7 text-xs text-zinc-700 transition-colors hover:bg-zinc-100 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700\",\n classNames?.pill,\n classNames?.textPill,\n )}\n >\n <span>\n Pasted text · {withSeparators(paste.text.length)} characters\n </span>\n </button>\n\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill-remove={paste.id}\n onClick={() => pills.remove(paste.id)}\n disabled={disabled}\n aria-label=\"Discard this pasted text\"\n className={cn(\n \"absolute end-1 top-1/2 -translate-y-1/2 rounded-full px-1 text-xs text-zinc-400 transition-colors hover:text-zinc-700 dark:hover:text-zinc-100\",\n classNames?.remove,\n )}\n >\n ×\n </button>\n\n <span\n id={`${paste.id}-preview`}\n data-react-fancy-composer-paste-pill-preview={paste.id}\n role=\"tooltip\"\n className={cn(\n \"pointer-events-none absolute bottom-full start-0 z-10 mb-1 hidden max-w-xs whitespace-pre-wrap break-all rounded-md bg-zinc-900 px-2 py-1 text-xs text-white group-hover:block dark:bg-zinc-100 dark:text-zinc-900\",\n classNames?.preview,\n )}\n >\n {renderPastePreview?.({ kind: \"text\", paste }) ??\n endsOf(paste.text, previewChars)}\n </span>\n </span>\n ))}\n </div>\n )}\n\n {inline ? (\n <>\n <InlinePasteEditor\n ref={editorRef}\n value={value}\n known={paste.known}\n onChange={handleInlineChange}\n onSubmit={handleSubmit}\n onPaste={paste.decidePaste}\n onHostsChange={paste.onHostsChange}\n placeholder={placeholder}\n disabled={disabled}\n id={inputId}\n className={classNames?.input}\n />\n {paste.portals}\n {/* A contenteditable is no form field, so `name` rides on a hidden\n one carrying what a send would carry: the expanded text. */}\n {name && <input type=\"hidden\" name={name} value={composeOutgoing()} />}\n {pasteImages && pasteFilesName && (\n <PastedFilesInput name={pasteFilesName} files={pastedFiles} />\n )}\n </>\n ) : (\n <textarea\n ref={textareaRef}\n // Its own handle, NOT the inline editor's `data-react-fancy-composer-input`:\n // that one already means \"the contenteditable is on\", and a host that\n // tests for it to pick a write path must not be handed a textarea.\n data-react-fancy-composer-textarea=\"\"\n id={inputId}\n name={name}\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n disabled={disabled}\n rows={3}\n className={cn(\n \"w-full resize-none bg-transparent px-4 pt-3 text-sm outline-none placeholder:text-zinc-400\",\n classNames?.input,\n )}\n />\n )}\n <div className=\"relative flex items-center justify-between border-t border-zinc-100 px-3 py-2 dark:border-zinc-800\">\n <div className=\"flex items-center gap-1\">{actions}</div>\n {ack.status === \"error\" && (\n // Mounted with its text, as `role=\"alert\"` is announced on insertion.\n <div\n role=\"alert\"\n data-react-fancy-composer-error=\"\"\n className=\"sr-only\"\n style={visuallyHidden}\n >\n {ack.message}\n </div>\n )}\n <button\n type=\"button\"\n data-react-fancy-composer-send=\"\"\n onClick={handleSubmit}\n disabled={disabled || sendDisabled || submitting || !hasContent}\n aria-busy={submitting || undefined}\n className=\"rounded-lg bg-zinc-900 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50 dark:bg-white dark:text-zinc-900 dark:hover:bg-zinc-100\"\n >\n Send\n </button>\n </div>\n </div>\n );\n },\n);\n\nComposer.displayName = \"Composer\";\n\n/** Same pills, same content: a host echoing a copy of what it was told is not a new revision. */\nfunction samePastes(a: HeldPaste[], b: HeldPaste[]): boolean {\n return (\n a.length === b.length &&\n a.every((p, i) => p.id === b[i]!.id && p.text === b[i]!.text && p.label === b[i]!.label)\n );\n}\n\nfunction sameImages(a: HeldImage[], b: HeldImage[]): boolean {\n return (\n a.length === b.length &&\n a.every((img, i) => img.id === b[i]!.id && img.label === b[i]!.label && img.file === b[i]!.file)\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/Composer/Composer.tsx"],"names":["Composer","paste"],"mappings":";;;;;;;;;AAmBA,IAAM,aAAA,GAAgB,EAAA;AAEf,IAAM,QAAA,GAAW,UAAA;AAAA,EACtB,SAASA,SAAAA,CACP;AAAA,IACE,KAAA,EAAO,eAAA;AAAA,IACP,YAAA,GAAe,EAAA;AAAA,IACf,QAAA;AAAA,IACA,QAAA;AAAA,IACA,aAAA;AAAA,IACA,WAAA,GAAc,mBAAA;AAAA,IACd,OAAA;AAAA,IACA,QAAA,GAAW,KAAA;AAAA,IACX,YAAA,GAAe,KAAA;AAAA,IACf,IAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA,GAAiB,OAAA;AAAA,IACjB,WAAA,GAAc,KAAA;AAAA,IACd,YAAA,GAAe,aAAA;AAAA,IACf,kBAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA,EAAY,oBAAA;AAAA,IACZ,kBAAA;AAAA,IACA,UAAA,EAAY,oBAAA;AAAA,IACZ,kBAAA;AAAA,I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G,KAAK,CAAA;AAE3F;AAEA,SAAS,UAAA,CAAW,GAAgB,CAAA,EAAyB;AAC3D,EAAA,OACE,CAAA,CAAE,MAAA,KAAW,CAAA,CAAE,MAAA,IACf,CAAA,CAAE,KAAA,CAAM,CAAC,GAAA,EAAK,CAAA,KAAM,GAAA,CAAI,EAAA,KAAO,CAAA,CAAE,CAAC,EAAG,EAAA,IAAM,GAAA,CAAI,KAAA,KAAU,CAAA,CAAE,CAAC,CAAA,CAAG,KAAA,IAAS,GAAA,CAAI,IAAA,KAAS,CAAA,CAAE,CAAC,CAAA,CAAG,IAAI,CAAA;AAEnG","file":"chunk-J57JSHDC.js","sourcesContent":["import { forwardRef, useCallback, useMemo, useRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { isImeComposing } from \"../../utils/ime\";\nimport { visuallyHidden } from \"../../utils/visually-hidden\";\nimport { useAcknowledgedSubmit } from \"../../hooks/use-acknowledged-submit\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport {\n endsOf,\n InlinePasteEditor,\n PastedFilesInput,\n useInlinePaste,\n withSeparators,\n type HeldImage,\n type HeldPaste,\n type InlinePasteEditorHandle,\n} from \"../PastePills\";\nimport type { ComposerProps } from \"./Composer.types\";\n\n/** Characters of a held paste shown at each end of the hover preview, unless `previewChars` says otherwise. */\nconst PREVIEW_CHARS = 20;\n\nexport const Composer = forwardRef<HTMLDivElement, ComposerProps>(\n function Composer(\n {\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onSubmit,\n onSubmitError,\n placeholder = \"Type a message...\",\n actions,\n disabled = false,\n sendDisabled = false,\n name,\n inputId,\n className,\n pasteThreshold,\n pastePlacement = \"above\",\n pasteImages = false,\n previewChars = PREVIEW_CHARS,\n renderPastePreview,\n classNames,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n pasteFilesName,\n },\n ref,\n ) {\n const inline = pastePlacement === \"inline\";\n const [value, setValue] = useControllableState(\n controlledValue,\n defaultValue,\n onChange,\n );\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const editorRef = useRef<InlinePasteEditorHandle>(null);\n /*\n * The holding logic lives in `usePastePills`, wrapped by `useInlinePaste` for\n * the inline placement — which `PromptInput` shares, so the two components\n * cannot disagree about what a pill means. The rule that must not drift is\n * the one below: a send with pills still closed carries the text.\n */\n const paste = useInlinePaste({\n pasteThreshold,\n pasteImages,\n previewChars,\n renderPastePreview,\n classNames,\n disabled,\n heldPastes: controlledHeldPastes,\n onHeldPastesChange,\n heldImages: controlledHeldImages,\n onHeldImagesChange,\n editorRef,\n });\n const pills = paste.pills;\n const heldPastes = paste.heldPastes;\n const pastedFiles = useMemo(\n () => (inline && pasteImages ? paste.imagesIn(value).map((i) => i.file) : []),\n [inline, pasteImages, paste, value],\n );\n\n const handlePaste = useCallback(\n (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n // Composable by design, so this reads as a question rather than a handover.\n // Nothing else here wants the paste, so the answer is simply ignored.\n pills.handlePaste(e);\n },\n [pills],\n );\n\n const handleInlineChange = useCallback(\n (next: string) => {\n setValue(next);\n paste.prune(next);\n },\n [setValue, paste],\n );\n\n /** Everything the person believes they are sending, in the order they built it. */\n const composeOutgoing = useCallback(() => {\n if (inline) return paste.expand(value);\n\n return [value, ...heldPastes.map((p) => p.text)].filter(Boolean).join(\"\\n\\n\");\n }, [inline, value, heldPastes, paste]);\n\n const hasContent = value.trim().length > 0 || (!inline && heldPastes.length > 0);\n\n const focusInput = useCallback(() => {\n if (inline) editorRef.current?.focus();\n else textareaRef.current?.focus();\n }, [inline]);\n\n const ack = useAcknowledgedSubmit(onSubmitError);\n const submitting = ack.status === \"submitting\";\n\n /*\n * The draft's REVISION: bumped by every render in which the text, a held\n * paste or a held image differs from the last one seen — the person typing\n * or pasting, or a host moving a controlled `value` / `heldPastes` /\n * `heldImages`. An acknowledged send clears only if the revision is still\n * the one it sent. Comparing content instead (5.70.0) threw away newer\n * drafts that happened to compare equal: an edit typed and undone, a pill\n * whose text the host changed under the same id.\n */\n const heldImages = paste.heldImages;\n const revisionRef = useRef(0);\n const seenRef = useRef({ value, heldPastes, heldImages });\n const seen = seenRef.current;\n if (seen.value !== value || seen.heldPastes !== heldPastes || seen.heldImages !== heldImages) {\n if (\n seen.value !== value ||\n !samePastes(seen.heldPastes, heldPastes) ||\n !sameImages(seen.heldImages, heldImages)\n ) {\n revisionRef.current += 1;\n }\n seenRef.current = { value, heldPastes, heldImages };\n }\n\n const handleSubmit = useCallback(() => {\n if (!hasContent || disabled || sendDisabled || ack.busy()) return;\n\n /*\n * THE DANGEROUS STATE, and the reason this feature needed a spec rather than\n * a guess. A pill reads as \"your paste is attached\" — so a send that drops it\n * means asking a question about a document without the document, and nobody\n * can tell: the sender believes it went, the receiver sees a question about\n * nothing.\n *\n * Above the input, held pastes go out in arrival order after what was typed,\n * because people type the question BEFORE pasting the thing it is about.\n * Inline, every pill goes out exactly where it sits.\n */\n const images = inline ? paste.imagesIn(value) : [];\n\n const result = onSubmit?.(composeOutgoing(), { images });\n const sent = revisionRef.current;\n ack.track(result, () => {\n /*\n * A void `onSubmit` reaches here synchronously, so `sent` is still the\n * current revision and this clears exactly as it always has. An async one\n * reaches here when it resolves: if anything changed the message while it\n * was in flight, that message is newer than the send, even if it reads the\n * same, and throwing it away is the one outcome nobody can undo. So only\n * the revision that was sent is cleared.\n */\n if (revisionRef.current !== sent) return;\n setValue(\"\");\n paste.clear();\n });\n // Focus goes back to the text at once, as before: it stays editable while\n // a send is in flight, and the send button the person may have clicked is\n // about to be disabled.\n focusInput();\n }, [hasContent, disabled, sendDisabled, ack, value, inline, paste, onSubmit, composeOutgoing, setValue, focusInput]);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n // Enter that confirms an IME composition finishes a word; it is not a send.\n if (e.key === \"Enter\" && !e.shiftKey && !isImeComposing(e)) {\n e.preventDefault();\n handleSubmit();\n }\n };\n\n /** Above the input: click a pill to dump it in, APPENDED to what is already typed. */\n const insertPaste = useCallback(\n (held: HeldPaste) => {\n // `expand` removes it and hands back the text; inserting is this\n // component's job because the hook owns no DOM.\n const text = pills.expand(held.id);\n\n if (text === undefined) return;\n\n setValue((current) => (current ? `${current}\\n\\n${text}` : text));\n textareaRef.current?.focus();\n },\n [pills, setValue],\n );\n\n return (\n <div\n data-react-fancy-composer=\"\"\n // Absent while idle; \"submitting\" while an onSubmit Promise is pending;\n // \"error\" after one was refused, until the next send.\n data-submit-state={ack.status === \"idle\" ? undefined : ack.status}\n ref={ref}\n className={cn(\n \"rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n {!inline && heldPastes.length > 0 && (\n <div\n data-react-fancy-composer-paste-pills=\"\"\n className=\"flex flex-wrap gap-1.5 px-3 pt-3\"\n >\n {heldPastes.map((paste) => (\n // `group` + `group-hover` rather than hover state: the preview is\n // presentation, and a useState for it would be one more thing an\n // agent could desynchronise.\n <span key={paste.id} className=\"group relative inline-flex\">\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill={paste.id}\n onClick={() => insertPaste(paste)}\n disabled={disabled}\n // No `title`. A native tooltip plus the hover preview below\n // renders TWO tooltips on the same hover, at different delays.\n // The label says what clicking does; the preview says what the\n // text is, and it is linked rather than merely adjacent so a\n // screen reader reaches it too.\n aria-label={`Insert this pasted text, ${withSeparators(paste.text.length)} characters`}\n aria-describedby={`${paste.id}-preview`}\n // `pr-7` leaves room for the absolutely-positioned × that sits\n // over this button's right edge. With a smaller right padding the\n // × lands on top of the label.\n className={cn(\n \"inline-flex items-center gap-1.5 rounded-full border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-zinc-50 py-1 ps-2.5 pe-7 text-xs text-zinc-700 transition-colors hover:bg-zinc-100 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-zinc-800 dark:text-zinc-200 dark:hover:bg-zinc-700\",\n classNames?.pill,\n classNames?.textPill,\n )}\n >\n <span>\n Pasted text · {withSeparators(paste.text.length)} characters\n </span>\n </button>\n\n <button\n type=\"button\"\n data-react-fancy-composer-paste-pill-remove={paste.id}\n onClick={() => pills.remove(paste.id)}\n disabled={disabled}\n aria-label=\"Discard this pasted text\"\n className={cn(\n \"absolute end-1 top-1/2 -translate-y-1/2 rounded-full px-1 text-xs text-zinc-400 transition-colors hover:text-zinc-700 dark:hover:text-zinc-100\",\n classNames?.remove,\n )}\n >\n ×\n </button>\n\n <span\n id={`${paste.id}-preview`}\n data-react-fancy-composer-paste-pill-preview={paste.id}\n role=\"tooltip\"\n className={cn(\n \"pointer-events-none absolute bottom-full start-0 z-10 mb-1 hidden max-w-xs whitespace-pre-wrap break-all rounded-md bg-zinc-900 px-2 py-1 text-xs text-white group-hover:block dark:bg-zinc-100 dark:text-zinc-900\",\n classNames?.preview,\n )}\n >\n {renderPastePreview?.({ kind: \"text\", paste }) ??\n endsOf(paste.text, previewChars)}\n </span>\n </span>\n ))}\n </div>\n )}\n\n {inline ? (\n <>\n <InlinePasteEditor\n ref={editorRef}\n value={value}\n known={paste.known}\n onChange={handleInlineChange}\n onSubmit={handleSubmit}\n onPaste={paste.decidePaste}\n onHostsChange={paste.onHostsChange}\n placeholder={placeholder}\n disabled={disabled}\n id={inputId}\n className={classNames?.input}\n />\n {paste.portals}\n {/* A contenteditable is no form field, so `name` rides on a hidden\n one carrying what a send would carry: the expanded text. */}\n {name && <input type=\"hidden\" name={name} value={composeOutgoing()} />}\n {pasteImages && pasteFilesName && (\n <PastedFilesInput name={pasteFilesName} files={pastedFiles} />\n )}\n </>\n ) : (\n <textarea\n ref={textareaRef}\n // Its own handle, NOT the inline editor's `data-react-fancy-composer-input`:\n // that one already means \"the contenteditable is on\", and a host that\n // tests for it to pick a write path must not be handed a textarea.\n data-react-fancy-composer-textarea=\"\"\n id={inputId}\n name={name}\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n placeholder={placeholder}\n disabled={disabled}\n rows={3}\n className={cn(\n \"w-full resize-none bg-transparent px-4 pt-3 text-sm outline-none placeholder:text-zinc-400\",\n classNames?.input,\n )}\n />\n )}\n <div className=\"relative flex items-center justify-between border-t border-zinc-100 px-3 py-2 dark:border-zinc-800\">\n <div className=\"flex items-center gap-1\">{actions}</div>\n {ack.status === \"error\" && (\n // Mounted with its text, as `role=\"alert\"` is announced on insertion.\n <div\n role=\"alert\"\n data-react-fancy-composer-error=\"\"\n className=\"sr-only\"\n style={visuallyHidden}\n >\n {ack.message}\n </div>\n )}\n <button\n type=\"button\"\n data-react-fancy-composer-send=\"\"\n onClick={handleSubmit}\n disabled={disabled || sendDisabled || submitting || !hasContent}\n aria-busy={submitting || undefined}\n className=\"rounded-lg bg-zinc-900 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-zinc-800 disabled:opacity-50 dark:bg-white dark:text-zinc-900 dark:hover:bg-zinc-100\"\n >\n Send\n </button>\n </div>\n </div>\n );\n },\n);\n\nComposer.displayName = \"Composer\";\n\n/** Same pills, same content: a host echoing a copy of what it was told is not a new revision. */\nfunction samePastes(a: HeldPaste[], b: HeldPaste[]): boolean {\n return (\n a.length === b.length &&\n a.every((p, i) => p.id === b[i]!.id && p.text === b[i]!.text && p.label === b[i]!.label)\n );\n}\n\nfunction sameImages(a: HeldImage[], b: HeldImage[]): boolean {\n return (\n a.length === b.length &&\n a.every((img, i) => img.id === b[i]!.id && img.label === b[i]!.label && img.file === b[i]!.file)\n );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Popover } from './chunk-
|
|
1
|
+
import { Popover } from './chunk-FNHKZMMI.js';
|
|
2
2
|
import { Button } from './chunk-Q4CNEHVN.js';
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
|
|
@@ -113,5 +113,5 @@ function ReasonTag({
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
export { ReasonTag };
|
|
116
|
-
//# sourceMappingURL=chunk-
|
|
117
|
-
//# sourceMappingURL=chunk-
|
|
116
|
+
//# sourceMappingURL=chunk-JN5DHZ6I.js.map
|
|
117
|
+
//# sourceMappingURL=chunk-JN5DHZ6I.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ReasonTag/ReasonTag.tsx"],"names":[],"mappings":";;;;AAuDA,IAAM,gBAAA,GAAyE;AAAA,EAC7E,EAAE,GAAA,EAAK,IAAA,EAAM,KAAA,EAAO,SAAA,EAAW,OAAO,MAAA,EAAO;AAAA,EAC7C,EAAE,GAAA,EAAK,GAAA,EAAK,KAAA,EAAO,SAAA,EAAW,OAAO,QAAA,EAAS;AAAA,EAC9C,EAAE,GAAA,EAAK,CAAA,EAAG,KAAA,EAAO,SAAA,EAAW,OAAO,KAAA;AACrC,CAAA;AAEA,SAAS,KAAK,CAAA,EAAW;AACvB,EAAA,OAAO,gBAAA,CAAiB,KAAK,CAAC,CAAA,KAAM,KAAK,CAAA,CAAE,GAAG,CAAA,IAAK,gBAAA,CAAiB,CAAC,CAAA;AACvE;AAEO,SAAS,SAAA,CAAU;AAAA,EACxB,KAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA,GAAa,CAAA;AAAA,EACb,UAAU,EAAC;AAAA,EACX,EAAA;AAAA,EACA,KAAA,GAAQ,KAAA;AAAA,EACR,MAAA,GAAS,KAAA;AAAA,EACT,UAAA;AAAA,EACA;AACF,CAAA,EAAmB;AACjB,EAAA,MAAM,CAAA,GAAI,KAAK,UAAU,CAAA;AAEzB,EAAA,MAAM,OAAA,GACJ,UAAU,MAAA,mBACR,IAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,CAAA,4FAAA,EAA+F,SAAA,IAAa,EAAE,CAAA,CA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,IAAA,uBACA,GAAA,EAAA,EAAE,SAAA,EAAU,iCAAA,EAAkC,IAAA,EAAM,CAAA,CAAE,IAAA,EACpD,QAAA,EAAA,CAAA,CAAE,KAAA,EACL,oBAEA,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,kCAAA,EACb,QAAA,EAAA,CAAA,CAAE,KAAA,EACL,CAAA,EAAA,EARK,CAUT,CACD,CAAA,EACH;AAAA,OAAA,EACF,CAAA;AAAA,MAED,UAAA,oBACC,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,yBACb,QAAA,kBAAA,GAAA,CAAC,MAAA,EAAA,EAAO,IAAA,EAAK,IAAA,EAAK,OAAA,EAAQ,OAAA,EAAQ,OAAA,EAAS,UAAA,EAAY,2BAEvD,CAAA,EACF;AAAA,KAAA,EAEJ,CAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-JN5DHZ6I.js","sourcesContent":["import { Popover } from \"../Popover\";\nimport { Button } from \"../Button\";\n\n/**\n * ReasonTag — wraps any value with a small affordance that reveals the\n * agent's reasoning, sources, and confidence on hover or click.\n *\n * <ReasonTag\n * value=\"$1.4M\"\n * reason=\"Projected Q3 ARR after stacking renewals.\"\n * confidence={0.91}\n * sources={[{ label: \"Q2 actuals · CRM export\" }]}\n * by=\"Forecaster\"\n * />\n *\n * Three visual styles:\n * • \"dot\" — value with a tiny coloured dot (default, subtle)\n * • \"underline\" — dotted underline + trailing \"?\"\n * • \"chip\" — full coloured pill (loud)\n *\n * Confidence drives the colour via three tiers (high / medium / low),\n * so a quick visual scan tells the human which suggestions deserve a\n * second look without opening any tooltips.\n *\n * `pinned` swaps the popover for an inline annotation slot — useful\n * when explainability should always be visible, not buried in a hover.\n */\nexport type ReasonTagSource = { label: string; href?: string };\n\nexport type ReasonTagTheme = \"dot\" | \"underline\" | \"chip\";\n\nexport interface ReasonTagProps {\n /** The value the tag wraps — usually a number, label, or short phrase. */\n value: React.ReactNode;\n /** Free-text rationale shown in the popover / inline annotation. */\n reason: string;\n /** 0..1 confidence. Drives the tier colour. Defaults to 1. */\n confidence?: number;\n /** Optional list of sources (label + optional href). */\n sources?: ReasonTagSource[];\n /** Optional author / agent name shown in the popover header. */\n by?: string;\n /** Visual treatment for the trigger. */\n theme?: ReasonTagTheme;\n /**\n * When true, the popover is replaced with an always-visible inline\n * annotation below the value.\n */\n pinned?: boolean;\n /** Called when the user hits the \"ask follow-up\" action. */\n onFollowUp?: () => void;\n /** Optional className applied to the trigger element. */\n className?: string;\n}\n\nconst CONFIDENCE_TIERS: Array<{ min: number; color: string; label: string }> = [\n { min: 0.85, color: \"#10b981\", label: \"high\" },\n { min: 0.6, color: \"#f59e0b\", label: \"medium\" },\n { min: 0, color: \"#ef4444\", label: \"low\" },\n];\n\nfunction tier(c: number) {\n return CONFIDENCE_TIERS.find((t) => c >= t.min) ?? CONFIDENCE_TIERS[2];\n}\n\nexport function ReasonTag({\n value,\n reason,\n confidence = 1,\n sources = [],\n by,\n theme = \"dot\",\n pinned = false,\n onFollowUp,\n className,\n}: ReasonTagProps) {\n const t = tier(confidence);\n\n const trigger =\n theme === \"chip\" ? (\n <span\n className={`inline-flex cursor-help items-center gap-1 rounded-full px-2 py-0.5 text-[12px] font-medium ${className ?? \"\"}`}\n style={{ backgroundColor: t.color + \"22\", color: t.color }}\n >\n <span\n className=\"h-1.5 w-1.5 rounded-full\"\n style={{ backgroundColor: t.color }}\n />\n {value}\n <span className=\"text-[10px] opacity-70\">?</span>\n </span>\n ) : theme === \"underline\" ? (\n <span\n className={`cursor-help underline decoration-dotted underline-offset-2 ${className ?? \"\"}`}\n style={{ textDecorationColor: t.color }}\n >\n {value}\n <span\n className=\"ms-0.5 font-mono text-[10px]\"\n style={{ color: t.color }}\n >\n ?\n </span>\n </span>\n ) : (\n <span className={`inline-flex cursor-help items-baseline gap-1 ${className ?? \"\"}`}>\n <span className=\"font-medium\">{value}</span>\n <span\n className=\"inline-block h-1.5 w-1.5 rounded-full align-middle\"\n style={{ backgroundColor: t.color }}\n title=\"reason available\"\n />\n </span>\n );\n\n if (pinned) {\n return (\n <span className=\"inline-flex flex-col items-start gap-0.5 align-top\">\n {trigger}\n <span\n className=\"block max-w-[280px] rounded border-s-2 ps-2 text-[11px] leading-snug text-zinc-600 dark:text-zinc-300\"\n style={{ borderColor: t.color }}\n >\n {reason}\n </span>\n </span>\n );\n }\n\n return (\n <Popover hover>\n <Popover.Trigger>{trigger}</Popover.Trigger>\n <Popover.Content>\n <div className=\"w-72 space-y-2 text-sm\">\n <div className=\"flex items-baseline gap-2\">\n <span\n className=\"text-[10px] font-semibold uppercase tracking-wider\"\n style={{ color: t.color }}\n >\n {t.label} confidence · {(confidence * 100).toFixed(0)}%\n </span>\n {by && (\n <span className=\"ms-auto font-mono text-[10px] text-zinc-400\">\n @{by}\n </span>\n )}\n </div>\n <p className=\"text-[13px] leading-snug text-zinc-700 dark:text-zinc-200\">\n {reason}\n </p>\n {sources.length > 0 && (\n <div>\n <div className=\"text-[10px] uppercase tracking-wider text-zinc-400\">\n sources\n </div>\n <ul className=\"mt-0.5 space-y-0.5 text-[12px]\">\n {sources.map((s, i) => (\n <li key={i}>\n {s.href ? (\n <a className=\"text-violet-600 hover:underline\" href={s.href}>\n {s.label}\n </a>\n ) : (\n <span className=\"text-zinc-600 dark:text-zinc-300\">\n {s.label}\n </span>\n )}\n </li>\n ))}\n </ul>\n </div>\n )}\n {onFollowUp && (\n <div className=\"flex justify-end pt-1\">\n <Button size=\"sm\" variant=\"ghost\" onClick={onFollowUp}>\n ask follow-up\n </Button>\n </div>\n )}\n </div>\n </Popover.Content>\n </Popover>\n );\n}\n"]}
|