@gunkin/uiify 0.0.17-alpha → 0.0.20-alpha
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/agents/components.md +1 -1
- package/agents/index.md +1 -0
- package/agents/reference/components/breadcrumb.md +11 -1
- package/agents/reference/components/button.md +4 -4
- package/agents/reference/components/candle-chart.md +20 -1
- package/agents/reference/components/carousel.md +3 -2
- package/agents/reference/components/combobox.md +2 -1
- package/agents/reference/components/drawer.md +8 -1
- package/agents/reference/components/dropdown-menu.md +1 -1
- package/agents/reference/components/file-upload.md +12 -1
- package/agents/reference/components/line-chart.md +1 -0
- package/agents/reference/components/modal.md +8 -1
- package/agents/reference/components/number-field.md +14 -3
- package/agents/reference/components/pagination.md +22 -1
- package/agents/reference/components/slider.md +9 -1
- package/agents/reference/components/spinner.md +8 -1
- package/agents/reference/components/toast.md +14 -1
- package/dist/components/behavior.css +9 -9
- package/dist/components/behavior.css.map +1 -1
- package/dist/components/breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/Breadcrumb.js +21 -4
- package/dist/components/breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/components/breadcrumb/index.d.ts +1 -1
- package/dist/components/breadcrumb/index.d.ts.map +1 -1
- package/dist/components/breadcrumb/index.js.map +1 -1
- package/dist/components/breadcrumb/types.d.ts +7 -0
- package/dist/components/breadcrumb/types.d.ts.map +1 -1
- package/dist/components/button/types.d.ts +4 -0
- package/dist/components/button/types.d.ts.map +1 -1
- package/dist/components/candle-chart/CandleChart.d.ts +1 -1
- package/dist/components/candle-chart/CandleChart.d.ts.map +1 -1
- package/dist/components/candle-chart/CandleChart.js +81 -46
- package/dist/components/candle-chart/CandleChart.js.map +1 -1
- package/dist/components/candle-chart/client/CandleChartClient.d.ts.map +1 -1
- package/dist/components/candle-chart/client/CandleChartClient.js +5 -0
- package/dist/components/candle-chart/client/CandleChartClient.js.map +1 -1
- package/dist/components/candle-chart/index.d.ts +1 -1
- package/dist/components/candle-chart/index.d.ts.map +1 -1
- package/dist/components/candle-chart/index.js.map +1 -1
- package/dist/components/candle-chart/types.d.ts +17 -0
- package/dist/components/candle-chart/types.d.ts.map +1 -1
- package/dist/components/carousel/CarouselMarkup.d.ts.map +1 -1
- package/dist/components/carousel/CarouselMarkup.js +20 -3
- package/dist/components/carousel/CarouselMarkup.js.map +1 -1
- package/dist/components/carousel/carousel-markup.js +2 -2
- package/dist/components/carousel/carousel-markup.js.map +1 -1
- package/dist/components/carousel/types.d.ts +3 -2
- package/dist/components/carousel/types.d.ts.map +1 -1
- package/dist/components/combobox/Combobox.d.ts.map +1 -1
- package/dist/components/combobox/Combobox.js +37 -23
- package/dist/components/combobox/Combobox.js.map +1 -1
- package/dist/components/combobox/combobox-store.d.ts.map +1 -1
- package/dist/components/combobox/combobox-store.js +5 -2
- package/dist/components/combobox/combobox-store.js.map +1 -1
- package/dist/components/combobox/types.d.ts +2 -3
- package/dist/components/combobox/types.d.ts.map +1 -1
- package/dist/components/context-menu/ContextMenu.d.ts.map +1 -1
- package/dist/components/context-menu/ContextMenu.js +25 -5
- package/dist/components/context-menu/ContextMenu.js.map +1 -1
- package/dist/components/drawer/DrawerNative.d.ts +1 -1
- package/dist/components/drawer/DrawerNative.d.ts.map +1 -1
- package/dist/components/drawer/DrawerNative.js +5 -2
- package/dist/components/drawer/DrawerNative.js.map +1 -1
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/index.d.ts.map +1 -1
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/drawer/types.d.ts +4 -0
- package/dist/components/drawer/types.d.ts.map +1 -1
- package/dist/components/dropdown-menu/DropdownMenu.d.ts.map +1 -1
- package/dist/components/dropdown-menu/DropdownMenu.js +31 -15
- package/dist/components/dropdown-menu/DropdownMenu.js.map +1 -1
- package/dist/components/dropdown-menu/DropdownMenuBar.d.ts.map +1 -1
- package/dist/components/dropdown-menu/DropdownMenuBar.js +7 -5
- package/dist/components/dropdown-menu/DropdownMenuBar.js.map +1 -1
- package/dist/components/dropdown-menu/types.d.ts +1 -1
- package/dist/components/dropdown-menu/types.d.ts.map +1 -1
- package/dist/components/file-upload/FileUpload.d.ts.map +1 -1
- package/dist/components/file-upload/FileUpload.js +11 -4
- package/dist/components/file-upload/FileUpload.js.map +1 -1
- package/dist/components/file-upload/FileUploadRoot.d.ts +1 -1
- package/dist/components/file-upload/FileUploadRoot.d.ts.map +1 -1
- package/dist/components/file-upload/FileUploadRoot.js +9 -0
- package/dist/components/file-upload/FileUploadRoot.js.map +1 -1
- package/dist/components/file-upload/index.d.ts +1 -1
- package/dist/components/file-upload/index.d.ts.map +1 -1
- package/dist/components/file-upload/index.js.map +1 -1
- package/dist/components/file-upload/types.d.ts +8 -0
- package/dist/components/file-upload/types.d.ts.map +1 -1
- package/dist/components/line-chart/LineChart.d.ts.map +1 -1
- package/dist/components/line-chart/LineChart.js +3 -2
- package/dist/components/line-chart/LineChart.js.map +1 -1
- package/dist/components/line-chart/line-chart-geometry.d.ts +2 -2
- package/dist/components/line-chart/line-chart-geometry.d.ts.map +1 -1
- package/dist/components/line-chart/line-chart-geometry.js +6 -6
- package/dist/components/line-chart/line-chart-geometry.js.map +1 -1
- package/dist/components/line-chart/types.d.ts +2 -0
- package/dist/components/line-chart/types.d.ts.map +1 -1
- package/dist/components/modal/Modal.d.ts +1 -1
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/modal/Modal.js +5 -2
- package/dist/components/modal/Modal.js.map +1 -1
- package/dist/components/modal/index.d.ts +1 -1
- package/dist/components/modal/index.d.ts.map +1 -1
- package/dist/components/modal/index.js.map +1 -1
- package/dist/components/modal/types.d.ts +4 -0
- package/dist/components/modal/types.d.ts.map +1 -1
- package/dist/components/number-field/NumberField.d.ts +1 -1
- package/dist/components/number-field/NumberField.d.ts.map +1 -1
- package/dist/components/number-field/NumberField.js +25 -5
- package/dist/components/number-field/NumberField.js.map +1 -1
- package/dist/components/number-field/format.d.ts +1 -1
- package/dist/components/number-field/format.d.ts.map +1 -1
- package/dist/components/number-field/format.js +32 -7
- package/dist/components/number-field/format.js.map +1 -1
- package/dist/components/number-field/index.d.ts +1 -1
- package/dist/components/number-field/index.d.ts.map +1 -1
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/number-field/types.d.ts +11 -2
- package/dist/components/number-field/types.d.ts.map +1 -1
- package/dist/components/otp-input/OtpInput.d.ts.map +1 -1
- package/dist/components/otp-input/OtpInput.js +2 -0
- package/dist/components/otp-input/OtpInput.js.map +1 -1
- package/dist/components/pagination/Pagination.d.ts.map +1 -1
- package/dist/components/pagination/Pagination.js +93 -29
- package/dist/components/pagination/Pagination.js.map +1 -1
- package/dist/components/pagination/PaginationShell.d.ts +2 -1
- package/dist/components/pagination/PaginationShell.d.ts.map +1 -1
- package/dist/components/pagination/PaginationShell.js +44 -9
- package/dist/components/pagination/PaginationShell.js.map +1 -1
- package/dist/components/pagination/index.d.ts +1 -1
- package/dist/components/pagination/index.d.ts.map +1 -1
- package/dist/components/pagination/index.js.map +1 -1
- package/dist/components/pagination/types.d.ts +18 -0
- package/dist/components/pagination/types.d.ts.map +1 -1
- package/dist/components/slider/client/SliderClient.d.ts.map +1 -1
- package/dist/components/slider/client/SliderClient.js +11 -2
- package/dist/components/slider/client/SliderClient.js.map +1 -1
- package/dist/components/slider/index.d.ts +1 -1
- package/dist/components/slider/index.d.ts.map +1 -1
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/types.d.ts +5 -0
- package/dist/components/slider/types.d.ts.map +1 -1
- package/dist/components/spinner/Spinner.d.ts.map +1 -1
- package/dist/components/spinner/Spinner.js +6 -3
- package/dist/components/spinner/Spinner.js.map +1 -1
- package/dist/components/spinner/index.d.ts +1 -1
- package/dist/components/spinner/index.d.ts.map +1 -1
- package/dist/components/spinner/index.js.map +1 -1
- package/dist/components/spinner/types.d.ts +4 -0
- package/dist/components/spinner/types.d.ts.map +1 -1
- package/dist/components/tags-input/TagsInput.d.ts.map +1 -1
- package/dist/components/tags-input/TagsInput.js +2 -0
- package/dist/components/tags-input/TagsInput.js.map +1 -1
- package/dist/components/toast/Toast.d.ts +1 -1
- package/dist/components/toast/Toast.d.ts.map +1 -1
- package/dist/components/toast/Toast.js +33 -29
- package/dist/components/toast/Toast.js.map +1 -1
- package/dist/components/toast/ToastElements.d.ts.map +1 -1
- package/dist/components/toast/ToastElements.js +24 -12
- package/dist/components/toast/ToastElements.js.map +1 -1
- package/dist/components/toast/index.d.ts +1 -1
- package/dist/components/toast/index.d.ts.map +1 -1
- package/dist/components/toast/index.js.map +1 -1
- package/dist/components/toast/types.d.ts +10 -0
- package/dist/components/toast/types.d.ts.map +1 -1
- package/dist/components/toolbar/Toolbar.d.ts +2 -2
- package/dist/components/toolbar/Toolbar.d.ts.map +1 -1
- package/dist/components/toolbar/Toolbar.js +8 -4
- package/dist/components/toolbar/Toolbar.js.map +1 -1
- package/dist/core/direction.d.ts +2 -0
- package/dist/core/direction.d.ts.map +1 -1
- package/dist/core/direction.js +8 -3
- package/dist/core/direction.js.map +1 -1
- package/dist/core/dismissable-layer-registry.d.ts.map +1 -1
- package/dist/core/dismissable-layer-registry.js +3 -1
- package/dist/core/dismissable-layer-registry.js.map +1 -1
- package/dist/core/format-label.d.ts +2 -0
- package/dist/core/format-label.d.ts.map +1 -0
- package/dist/core/format-label.js +13 -0
- package/dist/core/format-label.js.map +1 -0
- package/dist/core/ime.d.ts +16 -0
- package/dist/core/ime.d.ts.map +1 -0
- package/dist/core/ime.js +7 -0
- package/dist/core/ime.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/roving-focus-store.d.ts +3 -2
- package/dist/core/roving-focus-store.d.ts.map +1 -1
- package/dist/core/roving-focus-store.js +5 -3
- package/dist/core/roving-focus-store.js.map +1 -1
- package/dist/core/roving-focus.d.ts.map +1 -1
- package/dist/core/roving-focus.js +10 -5
- package/dist/core/roving-focus.js.map +1 -1
- package/dist/core/text-direction.d.ts +7 -0
- package/dist/core/text-direction.d.ts.map +1 -0
- package/dist/core/text-direction.js +7 -0
- package/dist/core/text-direction.js.map +1 -0
- package/dist/styles/index.css +1 -1
- package/package.json +2 -1
- package/skills/uiify/SKILL.md +58 -33
- package/skills/uiify/references/compositions/card-rhythm.md +0 -2
- package/skills/uiify/references/compositions/destructive-confirmation.md +1 -3
- package/skills/uiify/references/compositions/form-grouping.md +0 -2
- package/skills/uiify/references/compositions/hero-actions.md +3 -5
- package/skills/uiify/references/compositions/page-frame.md +0 -2
- package/skills/uiify/references/compositions/pricing-actions.md +0 -2
- package/skills/uiify/references/compositions/save-feedback.md +1 -3
- package/skills/uiify/references/compositions/table-controls.md +1 -3
- package/skills/uiify/references/elements/accordion.md +38 -0
- package/skills/uiify/references/elements/alert-modal.md +32 -5
- package/skills/uiify/references/elements/avatar.md +31 -2
- package/skills/uiify/references/elements/badge.md +32 -3
- package/skills/uiify/references/elements/bar-chart.md +39 -7
- package/skills/uiify/references/elements/breadcrumb.md +38 -0
- package/skills/uiify/references/elements/button.md +38 -3
- package/skills/uiify/references/elements/candle-chart.md +40 -0
- package/skills/uiify/references/elements/card.md +38 -1
- package/skills/uiify/references/elements/carousel.md +40 -0
- package/skills/uiify/references/elements/checkbox.md +39 -0
- package/skills/uiify/references/elements/code-block.md +31 -2
- package/skills/uiify/references/elements/collapsible.md +38 -0
- package/skills/uiify/references/elements/color-picker.md +39 -0
- package/skills/uiify/references/elements/combobox.md +37 -0
- package/skills/uiify/references/elements/command-palette.md +33 -12
- package/skills/uiify/references/elements/context-menu.md +38 -0
- package/skills/uiify/references/elements/cookie-banner.md +30 -2
- package/skills/uiify/references/elements/date-picker.md +33 -9
- package/skills/uiify/references/elements/divider.md +30 -2
- package/skills/uiify/references/elements/drawer.md +38 -0
- package/skills/uiify/references/elements/dropdown-menu.md +38 -0
- package/skills/uiify/references/elements/empty-state.md +30 -2
- package/skills/uiify/references/elements/feature-grid.md +41 -1
- package/skills/uiify/references/elements/field.md +33 -3
- package/skills/uiify/references/elements/file-upload.md +40 -0
- package/skills/uiify/references/elements/footer.md +35 -4
- package/skills/uiify/references/elements/form.md +31 -4
- package/skills/uiify/references/elements/header.md +31 -3
- package/skills/uiify/references/elements/hero.md +43 -3
- package/skills/uiify/references/elements/hover-card.md +38 -0
- package/skills/uiify/references/elements/image-gallery.md +36 -4
- package/skills/uiify/references/elements/inline-alert.md +30 -2
- package/skills/uiify/references/elements/input.md +31 -4
- package/skills/uiify/references/elements/line-chart.md +38 -0
- package/skills/uiify/references/elements/logo-wall.md +31 -2
- package/skills/uiify/references/elements/modal.md +38 -0
- package/skills/uiify/references/elements/number-field.md +41 -0
- package/skills/uiify/references/elements/otp-input.md +39 -0
- package/skills/uiify/references/elements/pagination.md +33 -4
- package/skills/uiify/references/elements/password-input.md +33 -9
- package/skills/uiify/references/elements/popup.md +38 -0
- package/skills/uiify/references/elements/pricing-table.md +55 -2
- package/skills/uiify/references/elements/progress-bar.md +32 -4
- package/skills/uiify/references/elements/radio-group.md +39 -0
- package/skills/uiify/references/elements/rating.md +39 -0
- package/skills/uiify/references/elements/search-input.md +35 -4
- package/skills/uiify/references/elements/segmented-control.md +39 -0
- package/skills/uiify/references/elements/select.md +29 -1
- package/skills/uiify/references/elements/sidebar.md +33 -10
- package/skills/uiify/references/elements/skeleton.md +38 -0
- package/skills/uiify/references/elements/slider.md +39 -0
- package/skills/uiify/references/elements/spinner.md +38 -0
- package/skills/uiify/references/elements/stats-bar.md +30 -2
- package/skills/uiify/references/elements/stepper.md +32 -9
- package/skills/uiify/references/elements/switch.md +31 -4
- package/skills/uiify/references/elements/table-of-contents.md +39 -0
- package/skills/uiify/references/elements/table.md +32 -3
- package/skills/uiify/references/elements/tabs.md +38 -0
- package/skills/uiify/references/elements/tags-input.md +39 -0
- package/skills/uiify/references/elements/testimonial.md +35 -4
- package/skills/uiify/references/elements/textarea.md +30 -3
- package/skills/uiify/references/elements/timeline.md +31 -3
- package/skills/uiify/references/elements/toast.md +27 -1
- package/skills/uiify/references/elements/toggle-group.md +39 -0
- package/skills/uiify/references/elements/toggle.md +39 -0
- package/skills/uiify/references/elements/toolbar.md +39 -0
- package/skills/uiify/references/elements/tooltip.md +38 -0
- package/skills/uiify/references/elements/virtual-scroll.md +39 -0
- package/skills/uiify/references/examples/alert-confirmation.md +34 -0
- package/skills/uiify/references/examples/field-validation.md +37 -0
- package/skills/uiify/references/examples/select-basic.md +35 -0
- package/skills/uiify/references/examples/table-controls.md +40 -0
- package/skills/uiify/references/guides/assets.md +14 -0
- package/skills/uiify/references/guides/content.md +11 -0
- package/skills/uiify/references/guides/hierarchy.md +14 -0
- package/skills/uiify/references/guides/i18n.md +21 -0
- package/skills/uiify/references/guides/reference.md +9 -0
- package/skills/uiify/references/guides/states.md +12 -0
- package/skills/uiify/references/guides/surface.md +27 -0
- package/skills/uiify/scripts/lint.mjs +1 -1
- package/skills/uiify/scripts/static.mjs +150 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/toolbar/Toolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport type { HTMLAttributes, ReactElement, ReactNode } from \"react\";\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/toolbar/Toolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef } from \"react\";\nimport type { HTMLAttributes, ReactElement, ReactNode } from \"react\";\nimport { useDirectionOverride, type Direction } from \"@gunkin/uiify/core/direction\";\nimport { resolveDirection } from \"@gunkin/uiify/core/text-direction\";\nimport type { RovingFocusOrientation } from \"@gunkin/uiify/core/roving-focus\";\n\nimport {\n ToolbarButton as ServerToolbarButton,\n ToolbarLink as ServerToolbarLink,\n ToolbarSeparator as ServerToolbarSeparator,\n ToolbarToggleGroup as ServerToolbarToggleGroup,\n} from \"./ToolbarShell.js\";\nimport type {\n ToolbarButtonProps,\n ToolbarLinkProps,\n ToolbarSeparatorProps,\n ToolbarToggleGroupProps,\n} from \"./types.js\";\n\ninterface ToolbarRootClientProps extends HTMLAttributes<HTMLDivElement> {\n readonly children?: ReactNode;\n readonly dir?: Direction;\n readonly loop?: boolean;\n readonly orientation?: RovingFocusOrientation;\n}\n\nfunction getToolbarItems(root: HTMLDivElement): HTMLElement[] {\n return Array.from(root.querySelectorAll<HTMLElement>('[data-uiify-toolbar][data-part=\"item\"]'));\n}\n\nfunction isDisabledItem(item: HTMLElement): boolean {\n return item.getAttribute(\"aria-disabled\") === \"true\" || item.hasAttribute(\"disabled\");\n}\n\nfunction syncTabStops(root: HTMLDivElement, current: HTMLElement | null): HTMLElement | null {\n const items = getToolbarItems(root);\n const enabled = items.filter((item) => !isDisabledItem(item));\n if (enabled.length === 0) return null;\n\n const nextCurrent = current && enabled.includes(current) ? current : (enabled[0] ?? null);\n\n for (const item of items) {\n item.tabIndex = nextCurrent === item ? 0 : -1;\n }\n\n return nextCurrent;\n}\n\nfunction moveIndex(\n currentIndex: number,\n offset: number,\n length: number,\n loop: boolean,\n): number | null {\n if (length === 0) return null;\n if (loop) return (currentIndex + offset + length) % length;\n const nextIndex = currentIndex + offset;\n if (nextIndex < 0 || nextIndex >= length) return null;\n return nextIndex;\n}\n\nexport function ToolbarRootClient({\n children,\n className,\n dir: localDir,\n loop = true,\n orientation = \"horizontal\",\n ...consumerProps\n}: ToolbarRootClientProps): ReactElement {\n const dir = useDirectionOverride(localDir);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const currentRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n currentRef.current = syncTabStops(root, currentRef.current);\n });\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n const handleFocusIn = (event: FocusEvent) => {\n const target = event.target;\n if (!(target instanceof HTMLElement)) return;\n const item = target.closest<HTMLElement>('[data-uiify-toolbar][data-part=\"item\"]');\n if (!item || !root.contains(item) || isDisabledItem(item)) return;\n currentRef.current = syncTabStops(root, item);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const target = event.target;\n if (!(target instanceof HTMLElement)) return;\n const item = target.closest<HTMLElement>('[data-uiify-toolbar][data-part=\"item\"]');\n if (!item || !root.contains(item)) return;\n\n const enabled = getToolbarItems(root).filter((entry) => !isDisabledItem(entry));\n const currentIndex = enabled.indexOf(item);\n if (currentIndex === -1) return;\n\n let nextIndex: number | null = null;\n if (event.key === \"Home\") nextIndex = 0;\n if (event.key === \"End\") nextIndex = enabled.length - 1;\n const rtl = resolveDirection(item, dir) === \"rtl\";\n if (orientation !== \"vertical\" && event.key === \"ArrowRight\") {\n nextIndex = moveIndex(currentIndex, rtl ? -1 : 1, enabled.length, loop);\n }\n if (orientation !== \"vertical\" && event.key === \"ArrowLeft\") {\n nextIndex = moveIndex(currentIndex, rtl ? 1 : -1, enabled.length, loop);\n }\n if (orientation !== \"horizontal\" && event.key === \"ArrowDown\") {\n nextIndex = moveIndex(currentIndex, 1, enabled.length, loop);\n }\n if (orientation !== \"horizontal\" && event.key === \"ArrowUp\") {\n nextIndex = moveIndex(currentIndex, -1, enabled.length, loop);\n }\n\n if (nextIndex === null) return;\n\n event.preventDefault();\n const nextItem = enabled[nextIndex];\n if (!nextItem) return;\n currentRef.current = syncTabStops(root, nextItem);\n nextItem.focus();\n };\n\n root.addEventListener(\"focusin\", handleFocusIn);\n root.addEventListener(\"keydown\", handleKeyDown);\n\n return () => {\n root.removeEventListener(\"focusin\", handleFocusIn);\n root.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [dir, loop, orientation]);\n\n return (\n <div\n {...consumerProps}\n className={className}\n data-orientation={orientation}\n data-part=\"root\"\n data-uiify-toolbar=\"\"\n {...(dir ? { dir } : {})}\n ref={rootRef}\n role=\"toolbar\"\n >\n {children}\n </div>\n );\n}\nToolbarRootClient.displayName = \"ToolbarRootClient\";\n\nexport const ToolbarRoot = ToolbarRootClient;\n\nexport function ToolbarButton(props: ToolbarButtonProps): ReactElement | null {\n return <ServerToolbarButton {...props} />;\n}\nToolbarButton.displayName = \"ToolbarButton\";\n\nexport function ToolbarLink(props: ToolbarLinkProps): ReactElement | null {\n return <ServerToolbarLink {...props} />;\n}\nToolbarLink.displayName = \"ToolbarLink\";\n\nexport function ToolbarSeparator(props: ToolbarSeparatorProps): ReactElement | null {\n return <ServerToolbarSeparator {...props} />;\n}\nToolbarSeparator.displayName = \"ToolbarSeparator\";\n\nexport function ToolbarToggleGroup(props: ToolbarToggleGroupProps): ReactElement | null {\n return <ServerToolbarToggleGroup {...props} />;\n}\nToolbarToggleGroup.displayName = \"ToolbarToggleGroup\";\n\nexport const Toolbar = {\n Button: ToolbarButton,\n Link: ToolbarLink,\n Root: ToolbarRoot,\n Separator: ToolbarSeparator,\n ToggleGroup: ToolbarToggleGroup,\n};\n"],"mappings":";AA2II;AAzIJ,SAAS,WAAW,cAAc;AAElC,SAAS,4BAA4C;AACrD,SAAS,wBAAwB;AAGjC;AAAA,EACE,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,OACjB;AAeP,SAAS,gBAAgB,MAAqC;AAC5D,SAAO,MAAM,KAAK,KAAK,iBAA8B,wCAAwC,CAAC;AAChG;AAEA,SAAS,eAAe,MAA4B;AAClD,SAAO,KAAK,aAAa,eAAe,MAAM,UAAU,KAAK,aAAa,UAAU;AACtF;AAEA,SAAS,aAAa,MAAsB,SAAiD;AAC3F,QAAM,QAAQ,gBAAgB,IAAI;AAClC,QAAM,UAAU,MAAM,OAAO,CAAC,SAAS,CAAC,eAAe,IAAI,CAAC;AAC5D,MAAI,QAAQ,WAAW,EAAG,QAAO;AAEjC,QAAM,cAAc,WAAW,QAAQ,SAAS,OAAO,IAAI,UAAW,QAAQ,CAAC,KAAK;AAEpF,aAAW,QAAQ,OAAO;AACxB,SAAK,WAAW,gBAAgB,OAAO,IAAI;AAAA,EAC7C;AAEA,SAAO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AM,cAAc;AAEpB,SAAS,cAAc,OAAgD;AAC5E,SAAO,oBAAC,uBAAqB,GAAG,OAAO;AACzC;AACA,cAAc,cAAc;AAErB,SAAS,YAAY,OAA8C;AACxE,SAAO,oBAAC,qBAAmB,GAAG,OAAO;AACvC;AACA,YAAY,cAAc;AAEnB,SAAS,iBAAiB,OAAmD;AAClF,SAAO,oBAAC,0BAAwB,GAAG,OAAO;AAC5C;AACA,iBAAiB,cAAc;AAExB,SAAS,mBAAmB,OAAqD;AACtF,SAAO,oBAAC,4BAA0B,GAAG,OAAO;AAC9C;AACA,mBAAmB,cAAc;AAE1B,MAAM,UAAU;AAAA,EACrB,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AAAA,EACX,aAAa;AACf;","names":[]}
|
package/dist/core/direction.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export declare namespace DirectionProvider {
|
|
|
8
8
|
var displayName: string;
|
|
9
9
|
}
|
|
10
10
|
export declare function useDirection(local?: Direction, element?: Element | null): Direction;
|
|
11
|
+
/** Returns `local`, else the nearest `DirectionProvider` value, else `undefined`. */
|
|
12
|
+
export declare function useDirectionOverride(local?: Direction): Direction | undefined;
|
|
11
13
|
//# sourceMappingURL=direction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../../src/core/direction.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;AAItC,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,sBAAsB,+BAE1E;yBAFe,iBAAiB;;;AAKjC,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../../src/core/direction.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;AAItC,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,sBAAsB,+BAE1E;yBAFe,iBAAiB;;;AAKjC,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAQnF;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAG7E"}
|
package/dist/core/direction.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useContext } from "react";
|
|
4
|
-
const DirectionContext = createContext(
|
|
4
|
+
const DirectionContext = createContext(void 0);
|
|
5
5
|
function DirectionProvider({ children, dir }) {
|
|
6
6
|
return /* @__PURE__ */ jsx(DirectionContext, { value: dir, children });
|
|
7
7
|
}
|
|
@@ -10,10 +10,15 @@ function useDirection(local, element) {
|
|
|
10
10
|
const inherited = useContext(DirectionContext);
|
|
11
11
|
if (local) return local;
|
|
12
12
|
const semanticDirection = element?.closest("[dir]")?.getAttribute("dir");
|
|
13
|
-
return semanticDirection === "rtl" || semanticDirection === "ltr" ? semanticDirection : inherited;
|
|
13
|
+
return semanticDirection === "rtl" || semanticDirection === "ltr" ? semanticDirection : inherited ?? "ltr";
|
|
14
|
+
}
|
|
15
|
+
function useDirectionOverride(local) {
|
|
16
|
+
const inherited = useContext(DirectionContext);
|
|
17
|
+
return local ?? inherited;
|
|
14
18
|
}
|
|
15
19
|
export {
|
|
16
20
|
DirectionProvider,
|
|
17
|
-
useDirection
|
|
21
|
+
useDirection,
|
|
22
|
+
useDirectionOverride
|
|
18
23
|
};
|
|
19
24
|
//# sourceMappingURL=direction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/direction.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { PropsWithChildren } from \"react\";\n\nexport type Direction = \"ltr\" | \"rtl\";\n\nconst DirectionContext = createContext<Direction>(
|
|
1
|
+
{"version":3,"sources":["../../src/core/direction.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { PropsWithChildren } from \"react\";\n\nexport type Direction = \"ltr\" | \"rtl\";\n\nconst DirectionContext = createContext<Direction | undefined>(undefined);\n\nexport interface DirectionProviderProps extends PropsWithChildren {\n readonly dir: Direction;\n}\n\nexport function DirectionProvider({ children, dir }: DirectionProviderProps) {\n return <DirectionContext value={dir}>{children}</DirectionContext>;\n}\nDirectionProvider.displayName = \"DirectionProvider\";\n\nexport function useDirection(local?: Direction, element?: Element | null): Direction {\n const inherited = useContext(DirectionContext);\n if (local) return local;\n\n const semanticDirection = element?.closest(\"[dir]\")?.getAttribute(\"dir\");\n return semanticDirection === \"rtl\" || semanticDirection === \"ltr\"\n ? semanticDirection\n : (inherited ?? \"ltr\");\n}\n\n/** Returns `local`, else the nearest `DirectionProvider` value, else `undefined`. */\nexport function useDirectionOverride(local?: Direction): Direction | undefined {\n const inherited = useContext(DirectionContext);\n return local ?? inherited;\n}\n"],"mappings":";AAcS;AAZT,SAAS,eAAe,kBAAkB;AAK1C,MAAM,mBAAmB,cAAqC,MAAS;AAMhE,SAAS,kBAAkB,EAAE,UAAU,IAAI,GAA2B;AAC3E,SAAO,oBAAC,oBAAiB,OAAO,KAAM,UAAS;AACjD;AACA,kBAAkB,cAAc;AAEzB,SAAS,aAAa,OAAmB,SAAqC;AACnF,QAAM,YAAY,WAAW,gBAAgB;AAC7C,MAAI,MAAO,QAAO;AAElB,QAAM,oBAAoB,SAAS,QAAQ,OAAO,GAAG,aAAa,KAAK;AACvE,SAAO,sBAAsB,SAAS,sBAAsB,QACxD,oBACC,aAAa;AACpB;AAGO,SAAS,qBAAqB,OAA0C;AAC7E,QAAM,YAAY,WAAW,gBAAgB;AAC7C,SAAO,SAAS;AAClB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dismissable-layer-registry.d.ts","sourceRoot":"","sources":["../../src/core/dismissable-layer-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dismissable-layer-registry.d.ts","sourceRoot":"","sources":["../../src/core/dismissable-layer-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACtE;AA8CD,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,sBAAsB,GAC7B,MAAM,IAAI,CAaZ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isComposingKeyEvent } from "./ime.js";
|
|
1
2
|
import { getEventPath, isEventInsideLayer } from "./platform.js";
|
|
2
3
|
const registries = /* @__PURE__ */ new WeakMap();
|
|
3
4
|
function dispatch(document, reason, event) {
|
|
@@ -15,7 +16,8 @@ function createRegistry(document) {
|
|
|
15
16
|
document.addEventListener(
|
|
16
17
|
"keydown",
|
|
17
18
|
(event) => {
|
|
18
|
-
if (event.key === "Escape"
|
|
19
|
+
if (event.key === "Escape" && !isComposingKeyEvent(event))
|
|
20
|
+
dispatch(document, "escape-key", event);
|
|
19
21
|
},
|
|
20
22
|
options
|
|
21
23
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/dismissable-layer-registry.ts"],"sourcesContent":["import type { OpenChangeReason } from \"./open-change-details.js\";\nimport { getEventPath, isEventInsideLayer } from \"./platform.js\";\n\nexport interface DismissableLayerRecord {\n readonly branches: Set<Element>;\n readonly element: Element;\n readonly onDismiss: (reason: OpenChangeReason, event: Event) => void;\n}\n\ninterface Registry {\n readonly controller: AbortController;\n readonly layers: DismissableLayerRecord[];\n}\n\nconst registries = new WeakMap<Document, Registry>();\n\nfunction dispatch(document: Document, reason: OpenChangeReason, event: Event): void {\n const record = registries.get(document)?.layers.at(-1);\n if (!record) return;\n if (\n reason !== \"escape-key\" &&\n isEventInsideLayer(getEventPath(event), record.element, record.branches)\n ) {\n return;\n }\n record.onDismiss(reason, event);\n}\n\nfunction createRegistry(document: Document): Registry {\n const AbortControllerConstructor = document.defaultView?.AbortController ?? AbortController;\n const controller = new AbortControllerConstructor();\n const options = { capture: true, signal: controller.signal };\n document.addEventListener(\n \"keydown\",\n (event) => {\n if (event.key === \"Escape\")
|
|
1
|
+
{"version":3,"sources":["../../src/core/dismissable-layer-registry.ts"],"sourcesContent":["import { isComposingKeyEvent } from \"./ime.js\";\nimport type { OpenChangeReason } from \"./open-change-details.js\";\nimport { getEventPath, isEventInsideLayer } from \"./platform.js\";\n\nexport interface DismissableLayerRecord {\n readonly branches: Set<Element>;\n readonly element: Element;\n readonly onDismiss: (reason: OpenChangeReason, event: Event) => void;\n}\n\ninterface Registry {\n readonly controller: AbortController;\n readonly layers: DismissableLayerRecord[];\n}\n\nconst registries = new WeakMap<Document, Registry>();\n\nfunction dispatch(document: Document, reason: OpenChangeReason, event: Event): void {\n const record = registries.get(document)?.layers.at(-1);\n if (!record) return;\n if (\n reason !== \"escape-key\" &&\n isEventInsideLayer(getEventPath(event), record.element, record.branches)\n ) {\n return;\n }\n record.onDismiss(reason, event);\n}\n\nfunction createRegistry(document: Document): Registry {\n const AbortControllerConstructor = document.defaultView?.AbortController ?? AbortController;\n const controller = new AbortControllerConstructor();\n const options = { capture: true, signal: controller.signal };\n document.addEventListener(\n \"keydown\",\n (event) => {\n if (event.key === \"Escape\" && !isComposingKeyEvent(event))\n dispatch(document, \"escape-key\", event);\n },\n options,\n );\n document.addEventListener(\n \"pointerdown\",\n (event) => dispatch(document, \"outside-press\", event),\n options,\n );\n document.addEventListener(\n \"focusin\",\n (event) => dispatch(document, \"focus-outside\", event),\n options,\n );\n return { controller, layers: [] };\n}\n\nexport function registerDismissableLayer(\n document: Document,\n record: DismissableLayerRecord,\n): () => void {\n const registry = registries.get(document) ?? createRegistry(document);\n registries.set(document, registry);\n registry.layers.push(record);\n\n return () => {\n const index = registry.layers.indexOf(record);\n if (index >= 0) registry.layers.splice(index, 1);\n if (registry.layers.length === 0) {\n registry.controller.abort();\n registries.delete(document);\n }\n };\n}\n"],"mappings":"AAAA,SAAS,2BAA2B;AAEpC,SAAS,cAAc,0BAA0B;AAajD,MAAM,aAAa,oBAAI,QAA4B;AAEnD,SAAS,SAAS,UAAoB,QAA0B,OAAoB;AAClF,QAAM,SAAS,WAAW,IAAI,QAAQ,GAAG,OAAO,GAAG,EAAE;AACrD,MAAI,CAAC,OAAQ;AACb,MACE,WAAW,gBACX,mBAAmB,aAAa,KAAK,GAAG,OAAO,SAAS,OAAO,QAAQ,GACvE;AACA;AAAA,EACF;AACA,SAAO,UAAU,QAAQ,KAAK;AAChC;AAEA,SAAS,eAAe,UAA8B;AACpD,QAAM,6BAA6B,SAAS,aAAa,mBAAmB;AAC5E,QAAM,aAAa,IAAI,2BAA2B;AAClD,QAAM,UAAU,EAAE,SAAS,MAAM,QAAQ,WAAW,OAAO;AAC3D,WAAS;AAAA,IACP;AAAA,IACA,CAAC,UAAU;AACT,UAAI,MAAM,QAAQ,YAAY,CAAC,oBAAoB,KAAK;AACtD,iBAAS,UAAU,cAAc,KAAK;AAAA,IAC1C;AAAA,IACA;AAAA,EACF;AACA,WAAS;AAAA,IACP;AAAA,IACA,CAAC,UAAU,SAAS,UAAU,iBAAiB,KAAK;AAAA,IACpD;AAAA,EACF;AACA,WAAS;AAAA,IACP;AAAA,IACA,CAAC,UAAU,SAAS,UAAU,iBAAiB,KAAK;AAAA,IACpD;AAAA,EACF;AACA,SAAO,EAAE,YAAY,QAAQ,CAAC,EAAE;AAClC;AAEO,SAAS,yBACd,UACA,QACY;AACZ,QAAM,WAAW,WAAW,IAAI,QAAQ,KAAK,eAAe,QAAQ;AACpE,aAAW,IAAI,UAAU,QAAQ;AACjC,WAAS,OAAO,KAAK,MAAM;AAE3B,SAAO,MAAM;AACX,UAAM,QAAQ,SAAS,OAAO,QAAQ,MAAM;AAC5C,QAAI,SAAS,EAAG,UAAS,OAAO,OAAO,OAAO,CAAC;AAC/C,QAAI,SAAS,OAAO,WAAW,GAAG;AAChC,eAAS,WAAW,MAAM;AAC1B,iBAAW,OAAO,QAAQ;AAAA,IAC5B;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-label.d.ts","sourceRoot":"","sources":["../../src/core/format-label.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EACjD,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAWR"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function formatLabel(template, values, locale) {
|
|
2
|
+
const numberFormat = new Intl.NumberFormat(locale ?? "en-US");
|
|
3
|
+
return template.replace(/\{(\w+)\}/g, (placeholder, key) => {
|
|
4
|
+
if (!Object.hasOwn(values, key)) return placeholder;
|
|
5
|
+
const value = values[key];
|
|
6
|
+
if (value === void 0) return placeholder;
|
|
7
|
+
return typeof value === "number" ? numberFormat.format(value) : value;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
formatLabel
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=format-label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/format-label.ts"],"sourcesContent":["export function formatLabel(\n template: string,\n values: Readonly<Record<string, string | number>>,\n locale?: string,\n): string {\n const numberFormat = new Intl.NumberFormat(locale ?? \"en-US\");\n\n return template.replace(/\\{(\\w+)\\}/g, (placeholder, key: string) => {\n if (!Object.hasOwn(values, key)) return placeholder;\n\n const value = values[key];\n if (value === undefined) return placeholder;\n\n return typeof value === \"number\" ? numberFormat.format(value) : value;\n });\n}\n"],"mappings":"AAAO,SAAS,YACd,UACA,QACA,QACQ;AACR,QAAM,eAAe,IAAI,KAAK,aAAa,UAAU,OAAO;AAE5D,SAAO,SAAS,QAAQ,cAAc,CAAC,aAAa,QAAgB;AAClE,QAAI,CAAC,OAAO,OAAO,QAAQ,GAAG,EAAG,QAAO;AAExC,UAAM,QAAQ,OAAO,GAAG;AACxB,QAAI,UAAU,OAAW,QAAO;AAEhC,WAAO,OAAO,UAAU,WAAW,aAAa,OAAO,KAAK,IAAI;AAAA,EAClE,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface ComposingKeyEventLike {
|
|
2
|
+
readonly isComposing?: boolean;
|
|
3
|
+
readonly keyCode?: number;
|
|
4
|
+
readonly nativeEvent?: {
|
|
5
|
+
readonly isComposing?: boolean;
|
|
6
|
+
readonly keyCode?: number;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* True while an IME composition owns the key. Safari fires the final keydown after
|
|
11
|
+
* `compositionend` with `isComposing === false` and `keyCode === 229`, so both signals
|
|
12
|
+
* are checked. React synthetic events expose `isComposing` only on `nativeEvent`.
|
|
13
|
+
*/
|
|
14
|
+
declare function isComposingKeyEvent(event: ComposingKeyEventLike): boolean;
|
|
15
|
+
export { isComposingKeyEvent };
|
|
16
|
+
//# sourceMappingURL=ime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ime.d.ts","sourceRoot":"","sources":["../../src/core/ime.ts"],"names":[],"mappings":"AAAA,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE;QAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACtF;AAED;;;;GAIG;AACH,iBAAS,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAOlE;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
package/dist/core/ime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/ime.ts"],"sourcesContent":["interface ComposingKeyEventLike {\n readonly isComposing?: boolean;\n readonly keyCode?: number;\n readonly nativeEvent?: { readonly isComposing?: boolean; readonly keyCode?: number };\n}\n\n/**\n * True while an IME composition owns the key. Safari fires the final keydown after\n * `compositionend` with `isComposing === false` and `keyCode === 229`, so both signals\n * are checked. React synthetic events expose `isComposing` only on `nativeEvent`.\n */\nfunction isComposingKeyEvent(event: ComposingKeyEventLike): boolean {\n return (\n event.isComposing === true ||\n event.nativeEvent?.isComposing === true ||\n event.keyCode === 229 ||\n event.nativeEvent?.keyCode === 229\n );\n}\n\nexport { isComposingKeyEvent };\n"],"mappings":"AAWA,SAAS,oBAAoB,OAAuC;AAClE,SACE,MAAM,gBAAgB,QACtB,MAAM,aAAa,gBAAgB,QACnC,MAAM,YAAY,OAClB,MAAM,aAAa,YAAY;AAEnC;","names":[]}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ export * from "./dialog.js";
|
|
|
6
6
|
export * from "./direction.js";
|
|
7
7
|
export * from "./dismissable-layer.js";
|
|
8
8
|
export * from "./focus-scope.js";
|
|
9
|
+
export * from "./format-label.js";
|
|
9
10
|
export * from "./hover-intent-store.js";
|
|
10
11
|
export * from "./hover-overlay.js";
|
|
12
|
+
export * from "./ime.js";
|
|
11
13
|
export * from "./open-change-details.js";
|
|
12
14
|
export * from "./platform.js";
|
|
13
15
|
export * from "./popover.js";
|
|
@@ -16,6 +18,7 @@ export * from "./presence.js";
|
|
|
16
18
|
export * from "./render.js";
|
|
17
19
|
export * from "./roving-focus.js";
|
|
18
20
|
export * from "./split-ref.js";
|
|
21
|
+
export * from "./text-direction.js";
|
|
19
22
|
export * from "./tabbable.js";
|
|
20
23
|
export * from "./visually-hidden.js";
|
|
21
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -6,8 +6,10 @@ export * from "./dialog.js";
|
|
|
6
6
|
export * from "./direction.js";
|
|
7
7
|
export * from "./dismissable-layer.js";
|
|
8
8
|
export * from "./focus-scope.js";
|
|
9
|
+
export * from "./format-label.js";
|
|
9
10
|
export * from "./hover-intent-store.js";
|
|
10
11
|
export * from "./hover-overlay.js";
|
|
12
|
+
export * from "./ime.js";
|
|
11
13
|
export * from "./open-change-details.js";
|
|
12
14
|
export * from "./platform.js";
|
|
13
15
|
export * from "./popover.js";
|
|
@@ -16,6 +18,7 @@ export * from "./presence.js";
|
|
|
16
18
|
export * from "./render.js";
|
|
17
19
|
export * from "./roving-focus.js";
|
|
18
20
|
export * from "./split-ref.js";
|
|
21
|
+
export * from "./text-direction.js";
|
|
19
22
|
export * from "./tabbable.js";
|
|
20
23
|
export * from "./visually-hidden.js";
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["export * from \"./anchor-position.js\";\nexport * from \"./collection.js\";\nexport * from \"./compose-event-handlers.js\";\nexport * from \"./create-part-context.js\";\nexport * from \"./dialog.js\";\nexport * from \"./direction.js\";\nexport * from \"./dismissable-layer.js\";\nexport * from \"./focus-scope.js\";\nexport * from \"./hover-intent-store.js\";\nexport * from \"./hover-overlay.js\";\nexport * from \"./open-change-details.js\";\nexport * from \"./platform.js\";\nexport * from \"./popover.js\";\nexport * from \"./portal.js\";\nexport * from \"./presence.js\";\nexport * from \"./render.js\";\nexport * from \"./roving-focus.js\";\nexport * from \"./split-ref.js\";\nexport * from \"./tabbable.js\";\nexport * from \"./visually-hidden.js\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["export * from \"./anchor-position.js\";\nexport * from \"./collection.js\";\nexport * from \"./compose-event-handlers.js\";\nexport * from \"./create-part-context.js\";\nexport * from \"./dialog.js\";\nexport * from \"./direction.js\";\nexport * from \"./dismissable-layer.js\";\nexport * from \"./focus-scope.js\";\nexport * from \"./format-label.js\";\nexport * from \"./hover-intent-store.js\";\nexport * from \"./hover-overlay.js\";\nexport * from \"./ime.js\";\nexport * from \"./open-change-details.js\";\nexport * from \"./platform.js\";\nexport * from \"./popover.js\";\nexport * from \"./portal.js\";\nexport * from \"./presence.js\";\nexport * from \"./render.js\";\nexport * from \"./roving-focus.js\";\nexport * from \"./split-ref.js\";\nexport * from \"./text-direction.js\";\nexport * from \"./tabbable.js\";\nexport * from \"./visually-hidden.js\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -7,15 +7,16 @@ export interface RovingFocusItemRecord {
|
|
|
7
7
|
readonly textValue: string;
|
|
8
8
|
}
|
|
9
9
|
export interface RovingFocusConfig {
|
|
10
|
-
readonly direction
|
|
10
|
+
readonly direction?: Direction | undefined;
|
|
11
11
|
readonly loop: boolean;
|
|
12
12
|
readonly orientation: RovingFocusOrientation;
|
|
13
13
|
}
|
|
14
14
|
export interface RovingFocusStore {
|
|
15
15
|
focus(id: string): void;
|
|
16
16
|
getCurrentId(): string | null;
|
|
17
|
+
getDirection(): Direction | undefined;
|
|
17
18
|
getItems(): readonly RovingFocusItemRecord[];
|
|
18
|
-
move(fromId: string, key: string): boolean;
|
|
19
|
+
move(fromId: string, key: string, direction?: Direction): boolean;
|
|
19
20
|
register(item: RovingFocusItemRecord): () => void;
|
|
20
21
|
search(character: string): void;
|
|
21
22
|
setCurrentId(id: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roving-focus-store.d.ts","sourceRoot":"","sources":["../../src/core/roving-focus-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,MAAM,MAAM,sBAAsB,GAAG,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC;AAExE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,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B,GAAG,MAAM,IAAI,CAAC;IAClD,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1D,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5D,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC9C,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC;CACpE;AAMD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAwHnF"}
|
|
@@ -34,8 +34,10 @@ function createRovingFocusStore(initial) {
|
|
|
34
34
|
item.element?.focus({ preventScroll: true });
|
|
35
35
|
},
|
|
36
36
|
getCurrentId: () => currentId,
|
|
37
|
+
getDirection: () => config.direction,
|
|
37
38
|
getItems: () => orderedItems(items),
|
|
38
|
-
move(fromId, key) {
|
|
39
|
+
move(fromId, key, direction) {
|
|
40
|
+
const effectiveDirection = direction ?? config.direction ?? "ltr";
|
|
39
41
|
const enabled = getEnabled();
|
|
40
42
|
if (enabled.length === 0) return false;
|
|
41
43
|
const currentIndex = Math.max(
|
|
@@ -48,10 +50,10 @@ function createRovingFocusStore(initial) {
|
|
|
48
50
|
if (vertical && key === "ArrowDown") offset = 1;
|
|
49
51
|
if (vertical && key === "ArrowUp") offset = -1;
|
|
50
52
|
if (horizontal && key === "ArrowRight") {
|
|
51
|
-
offset =
|
|
53
|
+
offset = effectiveDirection === "rtl" ? -1 : 1;
|
|
52
54
|
}
|
|
53
55
|
if (horizontal && key === "ArrowLeft") {
|
|
54
|
-
offset =
|
|
56
|
+
offset = effectiveDirection === "rtl" ? 1 : -1;
|
|
55
57
|
}
|
|
56
58
|
if (offset === 0 && key !== "Home" && key !== "End") return false;
|
|
57
59
|
let nextIndex = key === "Home" ? 0 : key === "End" ? enabled.length - 1 : currentIndex + offset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/roving-focus-store.ts"],"sourcesContent":["import type { Direction } from \"./direction.js\";\nimport { sortByDocumentOrder } from \"./dom-order.js\";\n\nexport type RovingFocusOrientation = \"horizontal\" | \"vertical\" | \"both\";\n\nexport interface RovingFocusItemRecord {\n readonly disabled: boolean;\n readonly element: HTMLElement | null;\n readonly id: string;\n readonly textValue: string;\n}\n\nexport interface RovingFocusConfig {\n readonly direction
|
|
1
|
+
{"version":3,"sources":["../../src/core/roving-focus-store.ts"],"sourcesContent":["import type { Direction } from \"./direction.js\";\nimport { sortByDocumentOrder } from \"./dom-order.js\";\n\nexport type RovingFocusOrientation = \"horizontal\" | \"vertical\" | \"both\";\n\nexport interface RovingFocusItemRecord {\n readonly disabled: boolean;\n readonly element: HTMLElement | null;\n readonly id: string;\n readonly textValue: string;\n}\n\nexport interface RovingFocusConfig {\n readonly direction?: Direction | undefined;\n readonly loop: boolean;\n readonly orientation: RovingFocusOrientation;\n}\n\nexport interface RovingFocusStore {\n focus(id: string): void;\n getCurrentId(): string | null;\n getDirection(): Direction | undefined;\n getItems(): readonly RovingFocusItemRecord[];\n move(fromId: string, key: string, direction?: Direction): boolean;\n register(item: RovingFocusItemRecord): () => void;\n search(character: string): void;\n setCurrentId(id: string): void;\n setElement(id: string, element: HTMLElement | null): void;\n subscribe(listener: () => void): () => void;\n subscribeItem(id: string, listener: () => void): () => void;\n updateConfig(config: RovingFocusConfig): void;\n updateItem(id: string, item: Partial<RovingFocusItemRecord>): void;\n}\n\nfunction orderedItems(items: Map<string, RovingFocusItemRecord>) {\n return sortByDocumentOrder(items.values(), (item) => item.element);\n}\n\nexport function createRovingFocusStore(initial: RovingFocusConfig): RovingFocusStore {\n const items = new Map<string, RovingFocusItemRecord>();\n const listeners = new Set<() => void>();\n const itemListeners = new Map<string, Set<() => void>>();\n let config = initial;\n let currentId: string | null = null;\n let search = \"\";\n let searchTimer: ReturnType<typeof setTimeout> | undefined;\n const emit = () => {\n for (const listener of listeners) listener();\n };\n const emitItem = (id: string | null) => {\n if (!id) return;\n for (const listener of itemListeners.get(id) ?? []) listener();\n };\n const commitCurrentId = (id: string | null) => {\n if (currentId === id) return;\n const previous = currentId;\n currentId = id;\n emit();\n emitItem(previous);\n emitItem(id);\n };\n const getEnabled = () => orderedItems(items).filter((item) => !item.disabled);\n\n const store: RovingFocusStore = {\n focus(id) {\n const item = items.get(id);\n if (!item || item.disabled) return;\n store.setCurrentId(id);\n item.element?.focus({ preventScroll: true });\n },\n getCurrentId: () => currentId,\n getDirection: () => config.direction,\n getItems: () => orderedItems(items),\n move(fromId, key, direction) {\n const effectiveDirection = direction ?? config.direction ?? \"ltr\";\n const enabled = getEnabled();\n if (enabled.length === 0) return false;\n const currentIndex = Math.max(\n 0,\n enabled.findIndex((item) => item.id === fromId),\n );\n const horizontal = config.orientation !== \"vertical\";\n const vertical = config.orientation !== \"horizontal\";\n let offset = 0;\n if (vertical && key === \"ArrowDown\") offset = 1;\n if (vertical && key === \"ArrowUp\") offset = -1;\n if (horizontal && key === \"ArrowRight\") {\n offset = effectiveDirection === \"rtl\" ? -1 : 1;\n }\n if (horizontal && key === \"ArrowLeft\") {\n offset = effectiveDirection === \"rtl\" ? 1 : -1;\n }\n if (offset === 0 && key !== \"Home\" && key !== \"End\") return false;\n let nextIndex =\n key === \"Home\" ? 0 : key === \"End\" ? enabled.length - 1 : currentIndex + offset;\n if (config.loop) nextIndex = (nextIndex + enabled.length) % enabled.length;\n const next = enabled[nextIndex];\n if (!next) return false;\n store.focus(next.id);\n return true;\n },\n register(item) {\n items.set(item.id, item);\n if (currentId === null && !item.disabled) commitCurrentId(item.id);\n return () => {\n const wasCurrent = currentId === item.id;\n if (!items.delete(item.id)) return;\n if (wasCurrent) commitCurrentId(getEnabled()[0]?.id ?? null);\n else emit();\n };\n },\n search(character) {\n clearTimeout(searchTimer);\n const repeated = search.length > 0 && [...search].every((value) => value === character);\n search = repeated ? character : search + character;\n const query = search.toLocaleLowerCase();\n const enabled = getEnabled();\n const start = Math.max(0, enabled.findIndex((item) => item.id === currentId) + 1);\n const rotated = [...enabled.slice(start), ...enabled.slice(0, start)];\n const match = rotated.find((item) => item.textValue.toLocaleLowerCase().startsWith(query));\n if (match) store.focus(match.id);\n searchTimer = setTimeout(() => {\n search = \"\";\n }, 500);\n },\n setCurrentId(id) {\n commitCurrentId(id);\n },\n setElement(id, element) {\n store.updateItem(id, { element });\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n subscribeItem(id, listener) {\n const set = itemListeners.get(id) ?? new Set<() => void>();\n set.add(listener);\n itemListeners.set(id, set);\n return () => {\n set.delete(listener);\n if (set.size === 0) itemListeners.delete(id);\n };\n },\n updateConfig(next) {\n config = next;\n },\n updateItem(id, update) {\n const item = items.get(id);\n if (!item) return;\n const next = { ...item, ...update };\n items.set(id, next);\n if (id === currentId && next.disabled) {\n commitCurrentId(getEnabled()[0]?.id ?? null);\n }\n },\n };\n return store;\n}\n"],"mappings":"AACA,SAAS,2BAA2B;AAiCpC,SAAS,aAAa,OAA2C;AAC/D,SAAO,oBAAoB,MAAM,OAAO,GAAG,CAAC,SAAS,KAAK,OAAO;AACnE;AAEO,SAAS,uBAAuB,SAA8C;AACnF,QAAM,QAAQ,oBAAI,IAAmC;AACrD,QAAM,YAAY,oBAAI,IAAgB;AACtC,QAAM,gBAAgB,oBAAI,IAA6B;AACvD,MAAI,SAAS;AACb,MAAI,YAA2B;AAC/B,MAAI,SAAS;AACb,MAAI;AACJ,QAAM,OAAO,MAAM;AACjB,eAAW,YAAY,UAAW,UAAS;AAAA,EAC7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,IAAI;AACf,sBAAgB,EAAE;AAAA,IACpB;AAAA,IACA,WAAW,IAAI,SAAS;AACtB,YAAM,WAAW,IAAI,EAAE,QAAQ,CAAC;AAAA,IAClC;AAAA,IACA,UAAU,UAAU;AAClB,gBAAU,IAAI,QAAQ;AACtB,aAAO,MAAM,UAAU,OAAO,QAAQ;AAAA,IACxC;AAAA,IACA,cAAc,IAAI,UAAU;AAC1B,YAAM,MAAM,cAAc,IAAI,EAAE,KAAK,oBAAI,IAAgB;AACzD,UAAI,IAAI,QAAQ;AAChB,oBAAc,IAAI,IAAI,GAAG;AACzB,aAAO,MAAM;AACX,YAAI,OAAO,QAAQ;AACnB,YAAI,IAAI,SAAS,EAAG,eAAc,OAAO,EAAE;AAAA,MAC7C;AAAA,IACF;AAAA,IACA,aAAa,MAAM;AACjB,eAAS;AAAA,IACX;AAAA,IACA,WAAW,IAAI,QAAQ;AACrB,YAAM,OAAO,MAAM,IAAI,EAAE;AACzB,UAAI,CAAC,KAAM;AACX,YAAM,OAAO,EAAE,GAAG,MAAM,GAAG,OAAO;AAClC,YAAM,IAAI,IAAI,IAAI;AAClB,UAAI,OAAO,aAAa,KAAK,UAAU;AACrC,wBAAgB,WAAW,EAAE,CAAC,GAAG,MAAM,IAAI;AAAA,MAC7C;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roving-focus.d.ts","sourceRoot":"","sources":["../../src/core/roving-focus.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EAGX,YAAY,EACZ,GAAG,EACJ,MAAM,OAAO,CAAC;AAEf,OAAO,
|
|
1
|
+
{"version":3,"file":"roving-focus.d.ts","sourceRoot":"","sources":["../../src/core/roving-focus.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EAGX,YAAY,EACZ,GAAG,EACJ,MAAM,OAAO,CAAC;AAEf,OAAO,EAAwB,KAAK,SAAS,E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AC,GAC/B,YAAY,GAAG,IAAI,CAkFrB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -3,10 +3,12 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { createContext, useCallback, useContext, useRef, useSyncExternalStore } from "react";
|
|
4
4
|
import { useId, useIsomorphicLayoutEffect, useMergedRefs } from "@gunkin/uiify/hooks";
|
|
5
5
|
import { composeEventHandlers } from "./compose-event-handlers.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useDirectionOverride } from "./direction.js";
|
|
7
|
+
import { isComposingKeyEvent } from "./ime.js";
|
|
7
8
|
import {
|
|
8
9
|
createRovingFocusStore
|
|
9
10
|
} from "./roving-focus-store.js";
|
|
11
|
+
import { resolveDirection } from "./text-direction.js";
|
|
10
12
|
import { useRenderElement } from "./use-render-element.js";
|
|
11
13
|
const RovingFocusContext = createContext(null);
|
|
12
14
|
function RovingFocusRoot(props) {
|
|
@@ -18,7 +20,7 @@ function RovingFocusRoot(props) {
|
|
|
18
20
|
render,
|
|
19
21
|
...consumerProps
|
|
20
22
|
} = props;
|
|
21
|
-
const direction =
|
|
23
|
+
const direction = useDirectionOverride(localDirection);
|
|
22
24
|
const storeRef = useRef(null);
|
|
23
25
|
storeRef.current ??= createRovingFocusStore({ direction, loop, orientation });
|
|
24
26
|
storeRef.current.updateConfig({ direction, loop, orientation });
|
|
@@ -27,8 +29,8 @@ function RovingFocusRoot(props) {
|
|
|
27
29
|
defaultTag: "div",
|
|
28
30
|
props: {
|
|
29
31
|
...consumerProps,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
...direction ? { dir: direction } : {},
|
|
33
|
+
"data-orientation": orientation
|
|
32
34
|
},
|
|
33
35
|
render,
|
|
34
36
|
state: { orientation }
|
|
@@ -82,8 +84,11 @@ function RovingFocusItem(props) {
|
|
|
82
84
|
if (!disabled) store.setCurrentId(id);
|
|
83
85
|
};
|
|
84
86
|
const handleKeyDown = (event) => {
|
|
87
|
+
if (isComposingKeyEvent(event)) return;
|
|
85
88
|
if (event.key === "Home" || event.key === "End" || event.key.startsWith("Arrow")) {
|
|
86
|
-
if (store.move(id, event.key
|
|
89
|
+
if (store.move(id, event.key, resolveDirection(event.currentTarget, store.getDirection()))) {
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
}
|
|
87
92
|
} else if (event.key.length === 1 && !event.altKey && !event.ctrlKey && !event.metaKey) {
|
|
88
93
|
store.search(event.key);
|
|
89
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/roving-focus.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useCallback, useContext, useRef, useSyncExternalStore } from \"react\";\nimport { useId, useIsomorphicLayoutEffect, useMergedRefs } from \"@gunkin/uiify/hooks\";\nimport type {\n ElementType,\n FocusEvent as ReactFocusEvent,\n KeyboardEvent as ReactKeyboardEvent,\n ReactElement,\n Ref,\n} from \"react\";\nimport { composeEventHandlers } from \"./compose-event-handlers.js\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/core/roving-focus.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useCallback, useContext, useRef, useSyncExternalStore } from \"react\";\nimport { useId, useIsomorphicLayoutEffect, useMergedRefs } from \"@gunkin/uiify/hooks\";\nimport type {\n ElementType,\n FocusEvent as ReactFocusEvent,\n KeyboardEvent as ReactKeyboardEvent,\n ReactElement,\n Ref,\n} from \"react\";\nimport { composeEventHandlers } from \"./compose-event-handlers.js\";\nimport { useDirectionOverride, type Direction } from \"./direction.js\";\nimport { isComposingKeyEvent } from \"./ime.js\";\nimport type { RenderableProps } from \"./polymorphic.js\";\nimport {\n createRovingFocusStore,\n type RovingFocusOrientation,\n type RovingFocusStore,\n} from \"./roving-focus-store.js\";\nimport { resolveDirection } from \"./text-direction.js\";\nimport { useRenderElement } from \"./use-render-element.js\";\n\nconst RovingFocusContext = createContext<RovingFocusStore | null>(null);\n\nexport interface RovingFocusRootOwnProps {\n readonly direction?: Direction;\n readonly loop?: boolean;\n readonly orientation?: RovingFocusOrientation;\n}\n\nexport type RovingFocusRootProps<TAs extends ElementType = \"div\"> = RenderableProps<\n TAs,\n RovingFocusRootOwnProps,\n { orientation: RovingFocusOrientation },\n HTMLElement\n>;\n\nexport function RovingFocusRoot<TAs extends ElementType = \"div\">(\n props: RovingFocusRootProps<TAs>,\n): ReactElement | null {\n const {\n as,\n direction: localDirection,\n loop = true,\n orientation = \"both\",\n render,\n ...consumerProps\n } = props as RovingFocusRootProps<ElementType>;\n const direction = useDirectionOverride(localDirection);\n const storeRef = useRef<RovingFocusStore | null>(null);\n storeRef.current ??= createRovingFocusStore({ direction, loop, orientation });\n storeRef.current.updateConfig({ direction, loop, orientation });\n\n const element = useRenderElement({\n as,\n defaultTag: \"div\",\n props: {\n ...consumerProps,\n ...(direction ? { dir: direction } : {}),\n \"data-orientation\": orientation,\n },\n render,\n state: { orientation },\n });\n return <RovingFocusContext value={storeRef.current}>{element}</RovingFocusContext>;\n}\nRovingFocusRoot.displayName = \"RovingFocusRoot\";\n\nexport interface RovingFocusItemOwnProps {\n readonly ref?: Ref<HTMLElement>;\n readonly disabled?: boolean;\n readonly id?: string;\n readonly textValue?: string;\n}\n\nexport type RovingFocusItemProps<TAs extends ElementType = \"div\"> = RenderableProps<\n TAs,\n RovingFocusItemOwnProps,\n { current: boolean; disabled: boolean },\n HTMLElement\n>;\n\nexport function RovingFocusItem<TAs extends ElementType = \"div\">(\n props: RovingFocusItemProps<TAs>,\n): ReactElement | null {\n const {\n as,\n disabled = false,\n id: providedId,\n ref: consumerRef,\n render,\n textValue = \"\",\n ...consumerProps\n } = props as RovingFocusItemProps<ElementType> & { ref?: Ref<HTMLElement> };\n const { onFocus: consumerOnFocus, onKeyDown: consumerOnKeyDown } = consumerProps as {\n onFocus?: (event: ReactFocusEvent<HTMLElement>) => void;\n onKeyDown?: (event: ReactKeyboardEvent<HTMLElement>) => void;\n };\n const generatedId = useId();\n const id = providedId ?? generatedId;\n const store = useContext(RovingFocusContext);\n if (!store) throw new Error(\"RovingFocusItem must be used inside RovingFocusRoot\");\n const elementRef = useRef<HTMLElement | null>(null);\n const current = useSyncExternalStore(\n (listener) => store.subscribeItem(id, listener),\n () => store.getCurrentId() === id,\n () => false,\n );\n const setElement = useCallback(\n (element: HTMLElement | null) => store.setElement(id, element),\n [id, store],\n );\n const mergedRef = useMergedRefs(elementRef, consumerRef, setElement);\n\n useIsomorphicLayoutEffect(\n () =>\n store.register({\n disabled,\n element: elementRef.current,\n id,\n textValue: textValue || elementRef.current?.textContent?.trim() || \"\",\n }),\n [id, store],\n );\n useIsomorphicLayoutEffect(() => {\n store.updateItem(id, {\n disabled,\n textValue: textValue || elementRef.current?.textContent?.trim() || \"\",\n });\n }, [disabled, id, store, textValue]);\n\n const nativeButton = as === \"button\";\n\n const handleFocus = () => {\n if (!disabled) store.setCurrentId(id);\n };\n\n const handleKeyDown = (event: ReactKeyboardEvent<HTMLElement>) => {\n if (isComposingKeyEvent(event)) return;\n if (event.key === \"Home\" || event.key === \"End\" || event.key.startsWith(\"Arrow\")) {\n if (store.move(id, event.key, resolveDirection(event.currentTarget, store.getDirection()))) {\n event.preventDefault();\n }\n } else if (event.key.length === 1 && !event.altKey && !event.ctrlKey && !event.metaKey) {\n store.search(event.key);\n }\n };\n\n return useRenderElement({\n as,\n defaultTag: \"div\",\n props: {\n ...consumerProps,\n id,\n \"aria-disabled\": disabled || undefined,\n \"data-current\": current ? \"\" : undefined,\n \"data-disabled\": disabled ? \"\" : undefined,\n ...(nativeButton ? { disabled: disabled || undefined } : {}),\n onFocus: composeEventHandlers(consumerOnFocus, handleFocus),\n onKeyDown: composeEventHandlers(consumerOnKeyDown, handleKeyDown),\n ref: mergedRef,\n tabIndex: current && !disabled ? 0 : -1,\n },\n render,\n state: { current, disabled },\n });\n}\n\nexport { createRovingFocusStore };\nexport type { RovingFocusOrientation, RovingFoc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AA,EACF;AAEA,SAAO,iBAAiB;AAAA,IACtB;AAAA,IACA,YAAY;AAAA,IACZ,OAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,MACA,iBAAiB,YAAY;AAAA,MAC7B,gBAAgB,UAAU,KAAK;AAAA,MAC/B,iBAAiB,WAAW,KAAK;AAAA,MACjC,GAAI,eAAe,EAAE,UAAU,YAAY,OAAU,IAAI,CAAC;AAAA,MAC1D,SAAS,qBAAqB,iBAAiB,WAAW;AAAA,MAC1D,WAAW,qBAAqB,mBAAmB,aAAa;AAAA,MAChE,KAAK;AAAA,MACL,UAAU,WAAW,CAAC,WAAW,IAAI;AAAA,IACvC;AAAA,IACA;AAAA,IACA,OAAO,EAAE,SAAS,SAAS;AAAA,EAC7B,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Direction } from "./direction.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the effective text direction at event time with a selector match
|
|
4
|
+
* (no layout read). An explicit `override` wins over the DOM.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveDirection(element: Element | null | undefined, override?: Direction): Direction;
|
|
7
|
+
//# sourceMappingURL=text-direction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-direction.d.ts","sourceRoot":"","sources":["../../src/core/text-direction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EACnC,QAAQ,CAAC,EAAE,SAAS,GACnB,SAAS,CAEX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/text-direction.ts"],"sourcesContent":["import type { Direction } from \"./direction.js\";\n\n/**\n * Resolves the effective text direction at event time with a selector match\n * (no layout read). An explicit `override` wins over the DOM.\n */\nexport function resolveDirection(\n element: Element | null | undefined,\n override?: Direction,\n): Direction {\n return override ?? (element?.matches(\":dir(rtl)\") ? \"rtl\" : \"ltr\");\n}\n"],"mappings":"AAMO,SAAS,iBACd,SACA,UACW;AACX,SAAO,aAAa,SAAS,QAAQ,WAAW,IAAI,QAAQ;AAC9D;","names":[]}
|