aeon-ui-engine 1.0.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/.changeset/README.md +23 -0
- package/.changeset/combobox-and-changesets.md +9 -0
- package/.changeset/config.json +30 -0
- package/.changeset/framework-adapters.md +12 -0
- package/.changeset/scene-3d.md +6 -0
- package/.changeset/scene-plane.md +8 -0
- package/.changeset/site-og.md +5 -0
- package/.cursor/rules/aeon-ui.mdc +22 -0
- package/ACCESSIBILITY.md +32 -0
- package/AGENTS.md +226 -0
- package/COMPONENTS.md +36 -0
- package/FRAMEWORKS.md +57 -0
- package/INTEGRATION.md +89 -0
- package/LICENSE +21 -0
- package/PHILOSOPHY.md +71 -0
- package/PUBLISHING.md +85 -0
- package/README.md +154 -0
- package/SCENE.md +113 -0
- package/STATES.md +243 -0
- package/apps/demo/index.html +31 -0
- package/apps/demo/og.config.mjs +15 -0
- package/apps/demo/package.json +41 -0
- package/apps/demo/public/favicon.svg +16 -0
- package/apps/demo/public/og.png +0 -0
- package/apps/demo/public/og.svg +35 -0
- package/apps/demo/scripts/generate-og-png.mjs +60 -0
- package/apps/demo/src/App.tsx +31 -0
- package/apps/demo/src/aeonDiagrams.ts +100 -0
- package/apps/demo/src/app.css +16 -0
- package/apps/demo/src/components/ActionCluster.tsx +20 -0
- package/apps/demo/src/components/AsyncMachineDemo.tsx +97 -0
- package/apps/demo/src/components/ButtonLifecycleDemo.tsx +63 -0
- package/apps/demo/src/components/CodeExample.tsx +7 -0
- package/apps/demo/src/components/ComboboxDemo.tsx +30 -0
- package/apps/demo/src/components/DiagramsSection.tsx +38 -0
- package/apps/demo/src/components/FieldStateDemo.tsx +51 -0
- package/apps/demo/src/components/GridMesh.tsx +8 -0
- package/apps/demo/src/components/HeroInstall.tsx +10 -0
- package/apps/demo/src/components/LandingFaq.tsx +29 -0
- package/apps/demo/src/components/LandingFooter.tsx +22 -0
- package/apps/demo/src/components/LandingHeader.tsx +60 -0
- package/apps/demo/src/components/LandingHero.tsx +55 -0
- package/apps/demo/src/components/LayersSection.tsx +51 -0
- package/apps/demo/src/components/MermaidDiagram.tsx +84 -0
- package/apps/demo/src/components/PhilosophySection.tsx +33 -0
- package/apps/demo/src/components/PlaygroundBlock.tsx +23 -0
- package/apps/demo/src/components/PlaygroundSection.tsx +204 -0
- package/apps/demo/src/components/SceneSection.tsx +157 -0
- package/apps/demo/src/components/ScrollRegionDemo.tsx +74 -0
- package/apps/demo/src/components/ThemeSwitcher.tsx +76 -0
- package/apps/demo/src/demo-layout.css +264 -0
- package/apps/demo/src/landing.css +1094 -0
- package/apps/demo/src/main.tsx +14 -0
- package/apps/demo/src/nav.ts +9 -0
- package/apps/demo/src/site.ts +347 -0
- package/apps/demo/tsconfig.json +17 -0
- package/apps/demo/vite-plugins/og-meta.ts +30 -0
- package/apps/demo/vite.config.ts +69 -0
- package/docs/API_PATTERNS.md +234 -0
- package/docs/ARCHITECTURE.md +125 -0
- package/docs/COMPONENT_CHECKLIST.md +103 -0
- package/docs/FILE_MAP.md +122 -0
- package/docs/GLOSSARY.md +125 -0
- package/docs/INDEX.md +53 -0
- package/docs/LAYOUT_COORDINATES.md +178 -0
- package/docs/MACHINES.md +166 -0
- package/docs/MIGRATION_FROM_ARK.md +295 -0
- package/docs/VITE_CONSUMER.md +114 -0
- package/package.json +25 -0
- package/packages/core/README.md +69 -0
- package/packages/core/package.json +37 -0
- package/packages/core/src/anatomy.ts +144 -0
- package/packages/core/src/attrs.ts +47 -0
- package/packages/core/src/index.ts +8 -0
- package/packages/core/src/layout.ts +176 -0
- package/packages/core/src/machine.test.ts +18 -0
- package/packages/core/src/machine.ts +15 -0
- package/packages/core/src/philosophy.ts +10 -0
- package/packages/core/src/scroll.ts +72 -0
- package/packages/core/src/theme.test.ts +14 -0
- package/packages/core/src/theme.ts +53 -0
- package/packages/core/src/types.ts +25 -0
- package/packages/core/theme-transition.css +58 -0
- package/packages/core/tsconfig.json +8 -0
- package/packages/core/vitest.config.ts +8 -0
- package/packages/geometry/README.md +7 -0
- package/packages/geometry/package.json +35 -0
- package/packages/geometry/src/index.ts +3 -0
- package/packages/geometry/src/patterns.ts +55 -0
- package/packages/geometry/src/scene-attrs.ts +11 -0
- package/packages/geometry/src/svg.ts +60 -0
- package/packages/geometry/tsconfig.json +8 -0
- package/packages/panda/README.md +66 -0
- package/packages/panda/package.json +40 -0
- package/packages/panda/panda.config.ts +229 -0
- package/packages/panda/scripts/emit-theme-runtime.ts +37 -0
- package/packages/panda/src/recipes/accordion.ts +95 -0
- package/packages/panda/src/recipes/async.ts +76 -0
- package/packages/panda/src/recipes/badge.ts +44 -0
- package/packages/panda/src/recipes/button-group.ts +33 -0
- package/packages/panda/src/recipes/button.ts +91 -0
- package/packages/panda/src/recipes/checkbox.ts +41 -0
- package/packages/panda/src/recipes/combobox.ts +121 -0
- package/packages/panda/src/recipes/dialog.ts +96 -0
- package/packages/panda/src/recipes/field-shared.ts +29 -0
- package/packages/panda/src/recipes/field.ts +72 -0
- package/packages/panda/src/recipes/floating.ts +170 -0
- package/packages/panda/src/recipes/index.ts +14 -0
- package/packages/panda/src/recipes/scroll-region.ts +55 -0
- package/packages/panda/src/recipes/select.ts +111 -0
- package/packages/panda/src/recipes/switch.ts +51 -0
- package/packages/panda/src/recipes/tabs.ts +50 -0
- package/packages/panda/src/theme/catalog-types.ts +24 -0
- package/packages/panda/src/theme/catalog.ts +73 -0
- package/packages/panda/src/theme/chrome.css +75 -0
- package/packages/panda/src/theme/global-theme-css.ts +42 -0
- package/packages/panda/src/theme/index.ts +5 -0
- package/packages/panda/src/theme/palette.ts +65 -0
- package/packages/panda/src/theme/scrollbars.css +96 -0
- package/packages/panda/src/theme/semantic-tokens.ts +17 -0
- package/packages/panda/src/theme/themes.config.ts +516 -0
- package/packages/panda/src/theme/tokens.ts +51 -0
- package/packages/panda/styled-system/css/conditions.mjs +36 -0
- package/packages/panda/styled-system/css/css.d.ts +22 -0
- package/packages/panda/styled-system/css/css.mjs +45 -0
- package/packages/panda/styled-system/css/cva.d.ts +6 -0
- package/packages/panda/styled-system/css/cva.mjs +87 -0
- package/packages/panda/styled-system/css/cx.d.ts +5 -0
- package/packages/panda/styled-system/css/cx.mjs +15 -0
- package/packages/panda/styled-system/css/index.d.ts +5 -0
- package/packages/panda/styled-system/css/index.mjs +4 -0
- package/packages/panda/styled-system/css/sva.d.ts +4 -0
- package/packages/panda/styled-system/css/sva.mjs +41 -0
- package/packages/panda/styled-system/helpers.mjs +339 -0
- package/packages/panda/styled-system/jsx/aspect-ratio.d.ts +10 -0
- package/packages/panda/styled-system/jsx/aspect-ratio.mjs +14 -0
- package/packages/panda/styled-system/jsx/bleed.d.ts +10 -0
- package/packages/panda/styled-system/jsx/bleed.mjs +14 -0
- package/packages/panda/styled-system/jsx/box.d.ts +10 -0
- package/packages/panda/styled-system/jsx/box.mjs +14 -0
- package/packages/panda/styled-system/jsx/center.d.ts +10 -0
- package/packages/panda/styled-system/jsx/center.mjs +14 -0
- package/packages/panda/styled-system/jsx/circle.d.ts +10 -0
- package/packages/panda/styled-system/jsx/circle.mjs +14 -0
- package/packages/panda/styled-system/jsx/container.d.ts +10 -0
- package/packages/panda/styled-system/jsx/container.mjs +14 -0
- package/packages/panda/styled-system/jsx/cq.d.ts +10 -0
- package/packages/panda/styled-system/jsx/cq.mjs +14 -0
- package/packages/panda/styled-system/jsx/divider.d.ts +10 -0
- package/packages/panda/styled-system/jsx/divider.mjs +14 -0
- package/packages/panda/styled-system/jsx/factory-helper.mjs +22 -0
- package/packages/panda/styled-system/jsx/factory.d.ts +3 -0
- package/packages/panda/styled-system/jsx/factory.mjs +80 -0
- package/packages/panda/styled-system/jsx/flex.d.ts +10 -0
- package/packages/panda/styled-system/jsx/flex.mjs +14 -0
- package/packages/panda/styled-system/jsx/float.d.ts +10 -0
- package/packages/panda/styled-system/jsx/float.mjs +14 -0
- package/packages/panda/styled-system/jsx/grid-item.d.ts +10 -0
- package/packages/panda/styled-system/jsx/grid-item.mjs +14 -0
- package/packages/panda/styled-system/jsx/grid.d.ts +10 -0
- package/packages/panda/styled-system/jsx/grid.mjs +14 -0
- package/packages/panda/styled-system/jsx/hstack.d.ts +10 -0
- package/packages/panda/styled-system/jsx/hstack.mjs +14 -0
- package/packages/panda/styled-system/jsx/index.d.ts +24 -0
- package/packages/panda/styled-system/jsx/index.mjs +22 -0
- package/packages/panda/styled-system/jsx/is-valid-prop.d.ts +11 -0
- package/packages/panda/styled-system/jsx/is-valid-prop.mjs +17 -0
- package/packages/panda/styled-system/jsx/link-overlay.d.ts +10 -0
- package/packages/panda/styled-system/jsx/link-overlay.mjs +14 -0
- package/packages/panda/styled-system/jsx/spacer.d.ts +10 -0
- package/packages/panda/styled-system/jsx/spacer.mjs +14 -0
- package/packages/panda/styled-system/jsx/square.d.ts +10 -0
- package/packages/panda/styled-system/jsx/square.mjs +14 -0
- package/packages/panda/styled-system/jsx/stack.d.ts +10 -0
- package/packages/panda/styled-system/jsx/stack.mjs +14 -0
- package/packages/panda/styled-system/jsx/visually-hidden.d.ts +10 -0
- package/packages/panda/styled-system/jsx/visually-hidden.mjs +14 -0
- package/packages/panda/styled-system/jsx/vstack.d.ts +10 -0
- package/packages/panda/styled-system/jsx/vstack.mjs +14 -0
- package/packages/panda/styled-system/jsx/wrap.d.ts +10 -0
- package/packages/panda/styled-system/jsx/wrap.mjs +14 -0
- package/packages/panda/styled-system/patterns/aspect-ratio.d.ts +21 -0
- package/packages/panda/styled-system/patterns/aspect-ratio.mjs +38 -0
- package/packages/panda/styled-system/patterns/bleed.d.ts +22 -0
- package/packages/panda/styled-system/patterns/bleed.mjs +24 -0
- package/packages/panda/styled-system/patterns/box.d.ts +21 -0
- package/packages/panda/styled-system/patterns/box.mjs +15 -0
- package/packages/panda/styled-system/patterns/center.d.ts +21 -0
- package/packages/panda/styled-system/patterns/center.mjs +21 -0
- package/packages/panda/styled-system/patterns/circle.d.ts +21 -0
- package/packages/panda/styled-system/patterns/circle.mjs +25 -0
- package/packages/panda/styled-system/patterns/container.d.ts +21 -0
- package/packages/panda/styled-system/patterns/container.mjs +21 -0
- package/packages/panda/styled-system/patterns/cq.d.ts +22 -0
- package/packages/panda/styled-system/patterns/cq.mjs +21 -0
- package/packages/panda/styled-system/patterns/divider.d.ts +23 -0
- package/packages/panda/styled-system/patterns/divider.mjs +25 -0
- package/packages/panda/styled-system/patterns/flex.d.ts +27 -0
- package/packages/panda/styled-system/patterns/flex.mjs +26 -0
- package/packages/panda/styled-system/patterns/float.d.ts +24 -0
- package/packages/panda/styled-system/patterns/float.mjs +52 -0
- package/packages/panda/styled-system/patterns/grid-item.d.ts +26 -0
- package/packages/panda/styled-system/patterns/grid-item.mjs +25 -0
- package/packages/panda/styled-system/patterns/grid.d.ts +25 -0
- package/packages/panda/styled-system/patterns/grid.mjs +27 -0
- package/packages/panda/styled-system/patterns/hstack.d.ts +22 -0
- package/packages/panda/styled-system/patterns/hstack.mjs +24 -0
- package/packages/panda/styled-system/patterns/index.d.ts +21 -0
- package/packages/panda/styled-system/patterns/index.mjs +20 -0
- package/packages/panda/styled-system/patterns/link-overlay.d.ts +21 -0
- package/packages/panda/styled-system/patterns/link-overlay.mjs +24 -0
- package/packages/panda/styled-system/patterns/spacer.d.ts +21 -0
- package/packages/panda/styled-system/patterns/spacer.mjs +21 -0
- package/packages/panda/styled-system/patterns/square.d.ts +21 -0
- package/packages/panda/styled-system/patterns/square.mjs +24 -0
- package/packages/panda/styled-system/patterns/stack.d.ts +24 -0
- package/packages/panda/styled-system/patterns/stack.mjs +24 -0
- package/packages/panda/styled-system/patterns/visually-hidden.d.ts +21 -0
- package/packages/panda/styled-system/patterns/visually-hidden.mjs +18 -0
- package/packages/panda/styled-system/patterns/vstack.d.ts +22 -0
- package/packages/panda/styled-system/patterns/vstack.mjs +24 -0
- package/packages/panda/styled-system/patterns/wrap.d.ts +25 -0
- package/packages/panda/styled-system/patterns/wrap.mjs +25 -0
- package/packages/panda/styled-system/recipes/aeon-accordion.d.ts +32 -0
- package/packages/panda/styled-system/recipes/aeon-accordion.mjs +48 -0
- package/packages/panda/styled-system/recipes/aeon-async.d.ts +32 -0
- package/packages/panda/styled-system/recipes/aeon-async.mjs +56 -0
- package/packages/panda/styled-system/recipes/aeon-badge.d.ts +31 -0
- package/packages/panda/styled-system/recipes/aeon-badge.mjs +32 -0
- package/packages/panda/styled-system/recipes/aeon-button-group.d.ts +39 -0
- package/packages/panda/styled-system/recipes/aeon-button-group.mjs +37 -0
- package/packages/panda/styled-system/recipes/aeon-button.d.ts +39 -0
- package/packages/panda/styled-system/recipes/aeon-button.mjs +39 -0
- package/packages/panda/styled-system/recipes/aeon-checkbox.d.ts +28 -0
- package/packages/panda/styled-system/recipes/aeon-checkbox.mjs +48 -0
- package/packages/panda/styled-system/recipes/aeon-combobox.d.ts +32 -0
- package/packages/panda/styled-system/recipes/aeon-combobox.mjs +52 -0
- package/packages/panda/styled-system/recipes/aeon-dialog.d.ts +28 -0
- package/packages/panda/styled-system/recipes/aeon-dialog.mjs +60 -0
- package/packages/panda/styled-system/recipes/aeon-field.d.ts +32 -0
- package/packages/panda/styled-system/recipes/aeon-field.mjs +52 -0
- package/packages/panda/styled-system/recipes/aeon-menu.d.ts +28 -0
- package/packages/panda/styled-system/recipes/aeon-menu.mjs +52 -0
- package/packages/panda/styled-system/recipes/aeon-popover.d.ts +28 -0
- package/packages/panda/styled-system/recipes/aeon-popover.mjs +52 -0
- package/packages/panda/styled-system/recipes/aeon-scroll.d.ts +43 -0
- package/packages/panda/styled-system/recipes/aeon-scroll.mjs +63 -0
- package/packages/panda/styled-system/recipes/aeon-select.d.ts +32 -0
- package/packages/panda/styled-system/recipes/aeon-select.mjs +56 -0
- package/packages/panda/styled-system/recipes/aeon-switch.d.ts +28 -0
- package/packages/panda/styled-system/recipes/aeon-switch.mjs +48 -0
- package/packages/panda/styled-system/recipes/aeon-tabs.d.ts +28 -0
- package/packages/panda/styled-system/recipes/aeon-tabs.mjs +48 -0
- package/packages/panda/styled-system/recipes/aeon-toast.d.ts +28 -0
- package/packages/panda/styled-system/recipes/aeon-toast.mjs +48 -0
- package/packages/panda/styled-system/recipes/aeon-tooltip.d.ts +28 -0
- package/packages/panda/styled-system/recipes/aeon-tooltip.mjs +48 -0
- package/packages/panda/styled-system/recipes/create-recipe.mjs +82 -0
- package/packages/panda/styled-system/recipes/index.d.ts +18 -0
- package/packages/panda/styled-system/recipes/index.mjs +17 -0
- package/packages/panda/styled-system/styles.css +2157 -0
- package/packages/panda/styled-system/tokens/index.d.ts +9 -0
- package/packages/panda/styled-system/tokens/index.mjs +2156 -0
- package/packages/panda/styled-system/tokens/tokens.d.ts +60 -0
- package/packages/panda/styled-system/types/composition.d.ts +164 -0
- package/packages/panda/styled-system/types/conditions.d.ts +322 -0
- package/packages/panda/styled-system/types/csstype.d.ts +21298 -0
- package/packages/panda/styled-system/types/global.d.ts +20 -0
- package/packages/panda/styled-system/types/index.d.ts +8 -0
- package/packages/panda/styled-system/types/jsx.d.ts +52 -0
- package/packages/panda/styled-system/types/parts.d.ts +8 -0
- package/packages/panda/styled-system/types/pattern.d.ts +78 -0
- package/packages/panda/styled-system/types/prop-type.d.ts +240 -0
- package/packages/panda/styled-system/types/recipe.d.ts +181 -0
- package/packages/panda/styled-system/types/selectors.d.ts +59 -0
- package/packages/panda/styled-system/types/static-css.d.ts +56 -0
- package/packages/panda/styled-system/types/style-props.d.ts +7491 -0
- package/packages/panda/styled-system/types/system-types.d.ts +193 -0
- package/packages/panda/theme-runtime.css +842 -0
- package/packages/panda/tsconfig.json +8 -0
- package/packages/primitives/README.md +54 -0
- package/packages/primitives/package.json +41 -0
- package/packages/primitives/src/__tests__/floating-surface.test.ts +29 -0
- package/packages/primitives/src/index.ts +9 -0
- package/packages/primitives/src/machines/accordion.ts +56 -0
- package/packages/primitives/src/machines/async.ts +108 -0
- package/packages/primitives/src/machines/button.ts +66 -0
- package/packages/primitives/src/machines/dialog.ts +61 -0
- package/packages/primitives/src/machines/field.ts +85 -0
- package/packages/primitives/src/machines/popover.ts +52 -0
- package/packages/primitives/src/machines/tabs.ts +46 -0
- package/packages/primitives/src/machines/toast.ts +48 -0
- package/packages/primitives/src/machines/toggle.ts +61 -0
- package/packages/primitives/tsconfig.json +8 -0
- package/packages/primitives/vitest.config.ts +8 -0
- package/packages/react/README.md +65 -0
- package/packages/react/package.json +52 -0
- package/packages/react/src/accordion/index.tsx +179 -0
- package/packages/react/src/async/actions.tsx +22 -0
- package/packages/react/src/async/context.tsx +54 -0
- package/packages/react/src/async/index.tsx +21 -0
- package/packages/react/src/async/legacy-region.tsx +38 -0
- package/packages/react/src/async/readout.tsx +34 -0
- package/packages/react/src/async/root.tsx +39 -0
- package/packages/react/src/async/track.tsx +59 -0
- package/packages/react/src/avatar/avatar.test.tsx +27 -0
- package/packages/react/src/avatar/index.tsx +122 -0
- package/packages/react/src/button/index.tsx +70 -0
- package/packages/react/src/checkbox/index.tsx +180 -0
- package/packages/react/src/combobox/index.tsx +430 -0
- package/packages/react/src/dialog/dialog.test.tsx +50 -0
- package/packages/react/src/dialog/index.tsx +275 -0
- package/packages/react/src/field/index.tsx +172 -0
- package/packages/react/src/hooks/use-aeon-machine.ts +10 -0
- package/packages/react/src/hooks/use-anchor-position.ts +33 -0
- package/packages/react/src/hooks/use-focus-trap.ts +51 -0
- package/packages/react/src/hooks/use-layout-mode.ts +22 -0
- package/packages/react/src/hooks/use-outside-click.ts +19 -0
- package/packages/react/src/hooks/use-portalled.ts +16 -0
- package/packages/react/src/hooks/use-scroll-lock.ts +13 -0
- package/packages/react/src/index.ts +18 -0
- package/packages/react/src/menu/index.tsx +195 -0
- package/packages/react/src/popover/index.tsx +191 -0
- package/packages/react/src/scroll/index.tsx +98 -0
- package/packages/react/src/scroll/use-scroll-state.ts +30 -0
- package/packages/react/src/select/index.tsx +372 -0
- package/packages/react/src/select/select.test.tsx +60 -0
- package/packages/react/src/switch/index.tsx +215 -0
- package/packages/react/src/tabs/index.tsx +140 -0
- package/packages/react/src/toast/context.tsx +28 -0
- package/packages/react/src/toast/index.tsx +20 -0
- package/packages/react/src/toast/primitives.tsx +129 -0
- package/packages/react/src/toast/provider.tsx +111 -0
- package/packages/react/src/toast/toast-item.tsx +32 -0
- package/packages/react/src/tooltip/index.tsx +191 -0
- package/packages/react/src/utils/merge-props.ts +24 -0
- package/packages/react/tsconfig.json +8 -0
- package/packages/react/vitest.config.ts +9 -0
- package/packages/react/vitest.setup.ts +5 -0
- package/packages/react-scene/README.md +11 -0
- package/packages/react-scene/package.json +47 -0
- package/packages/react-scene/scene-3d.css +37 -0
- package/packages/react-scene/scene-room.css +95 -0
- package/packages/react-scene/src/index.ts +20 -0
- package/packages/react-scene/src/procedural-grid.tsx +35 -0
- package/packages/react-scene/src/scene-layer.tsx +38 -0
- package/packages/react-scene/src/scene-plane.tsx +69 -0
- package/packages/react-scene/src/scene-room.tsx +81 -0
- package/packages/react-scene/src/scene-root.tsx +49 -0
- package/packages/react-scene/src/scene-slot.tsx +41 -0
- package/packages/react-scene/src/scene-stage.tsx +37 -0
- package/packages/react-scene/src/scene-surface.tsx +20 -0
- package/packages/react-scene/src/signal-bars.tsx +57 -0
- package/packages/react-scene/src/use-signal-visualizer.ts +103 -0
- package/packages/react-scene/tsconfig.json +8 -0
- package/packages/scene/README.md +5 -0
- package/packages/scene/package.json +32 -0
- package/packages/scene/src/index.ts +2 -0
- package/packages/scene/src/room.ts +40 -0
- package/packages/scene/src/transform.ts +60 -0
- package/packages/scene/tsconfig.json +8 -0
- package/packages/signal/README.md +9 -0
- package/packages/signal/package.json +32 -0
- package/packages/signal/src/analyser.ts +113 -0
- package/packages/signal/src/bands.ts +33 -0
- package/packages/signal/src/index.ts +3 -0
- package/packages/signal/src/motion.ts +80 -0
- package/packages/signal/tsconfig.json +8 -0
- package/packages/site/README.md +19 -0
- package/packages/site/package.json +32 -0
- package/packages/site/src/index.ts +8 -0
- package/packages/site/src/open-graph.ts +90 -0
- package/packages/site/tsconfig.json +8 -0
- package/packages/solid/README.md +30 -0
- package/packages/solid/package.json +42 -0
- package/packages/solid/src/hooks/use-aeon-machine.ts +10 -0
- package/packages/solid/src/index.ts +2 -0
- package/packages/solid/src/switch/index.tsx +191 -0
- package/packages/solid/src/utils/merge-props.ts +3 -0
- package/packages/solid/tsconfig.json +10 -0
- package/packages/surface/README.md +10 -0
- package/packages/surface/package.json +33 -0
- package/packages/surface/src/index.ts +1 -0
- package/packages/surface/src/materials.ts +14 -0
- package/packages/surface/surface.css +113 -0
- package/packages/surface/tsconfig.json +8 -0
- package/packages/svelte/README.md +45 -0
- package/packages/svelte/package.json +49 -0
- package/packages/svelte/src/Switch.svelte +86 -0
- package/packages/svelte/src/SwitchControl.svelte +45 -0
- package/packages/svelte/src/SwitchHiddenInput.svelte +12 -0
- package/packages/svelte/src/SwitchLabel.svelte +9 -0
- package/packages/svelte/src/SwitchThumb.svelte +16 -0
- package/packages/svelte/src/hooks/use-aeon-machine.ts +23 -0
- package/packages/svelte/src/index.ts +2 -0
- package/packages/svelte/src/switch-context.ts +13 -0
- package/packages/svelte/tsconfig.json +8 -0
- package/packages/ui/README.md +63 -0
- package/packages/ui/package.json +45 -0
- package/packages/ui/src/accordion.tsx +27 -0
- package/packages/ui/src/async.tsx +43 -0
- package/packages/ui/src/badge.tsx +18 -0
- package/packages/ui/src/button.tsx +38 -0
- package/packages/ui/src/checkbox.tsx +24 -0
- package/packages/ui/src/cn.ts +1 -0
- package/packages/ui/src/combobox.tsx +29 -0
- package/packages/ui/src/dialog.tsx +32 -0
- package/packages/ui/src/field.tsx +33 -0
- package/packages/ui/src/index.ts +17 -0
- package/packages/ui/src/menu.tsx +25 -0
- package/packages/ui/src/popover.tsx +22 -0
- package/packages/ui/src/scroll.tsx +51 -0
- package/packages/ui/src/select.tsx +33 -0
- package/packages/ui/src/styles.css +2 -0
- package/packages/ui/src/switch.tsx +22 -0
- package/packages/ui/src/tabs.tsx +22 -0
- package/packages/ui/src/toast.tsx +36 -0
- package/packages/ui/src/tooltip.tsx +19 -0
- package/packages/ui/tsconfig.json +12 -0
- package/packages/vue/README.md +40 -0
- package/packages/vue/package.json +42 -0
- package/packages/vue/src/hooks/use-aeon-machine.ts +10 -0
- package/packages/vue/src/index.ts +2 -0
- package/packages/vue/src/switch/index.ts +208 -0
- package/packages/vue/src/utils/part-props.ts +8 -0
- package/packages/vue/tsconfig.json +8 -0
- package/pnpm-workspace.yaml +3 -0
- package/scripts/ensure-headless-built.mjs +25 -0
- package/tsconfig.base.json +21 -0
- package/vercel.json +12 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { comboboxAnatomy, partAttrs, partOnlyAttrs } from '@aeon-ui/core'
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
forwardRef,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useId,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
type ButtonHTMLAttributes,
|
|
13
|
+
type HTMLAttributes,
|
|
14
|
+
type FocusEvent,
|
|
15
|
+
type ChangeEvent,
|
|
16
|
+
type InputHTMLAttributes,
|
|
17
|
+
type KeyboardEvent,
|
|
18
|
+
type MouseEvent,
|
|
19
|
+
type ReactNode,
|
|
20
|
+
} from 'react'
|
|
21
|
+
import { mergeProps } from '../utils/merge-props.js'
|
|
22
|
+
|
|
23
|
+
interface RegisteredItem {
|
|
24
|
+
value: string
|
|
25
|
+
label: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface ComboboxContextValue {
|
|
29
|
+
value: string
|
|
30
|
+
open: boolean
|
|
31
|
+
query: string
|
|
32
|
+
listboxId: string
|
|
33
|
+
highlightedValue: string | null
|
|
34
|
+
itemsVersion: number
|
|
35
|
+
setOpen: (open: boolean) => void
|
|
36
|
+
setQuery: (query: string) => void
|
|
37
|
+
setHighlightedValue: (value: string | null) => void
|
|
38
|
+
onValueChange?: (value: string) => void
|
|
39
|
+
registerItem: (item: RegisteredItem) => void
|
|
40
|
+
unregisterItem: (value: string) => void
|
|
41
|
+
getItems: () => RegisteredItem[]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const ComboboxCtx = createContext<ComboboxContextValue | null>(null)
|
|
45
|
+
|
|
46
|
+
function useComboboxCtx() {
|
|
47
|
+
const ctx = useContext(ComboboxCtx)
|
|
48
|
+
if (!ctx) throw new Error('Combobox parts must be used within <Combobox.Root>')
|
|
49
|
+
return ctx
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function normalizeLabel(label: string | undefined, children: ReactNode): string {
|
|
53
|
+
if (label) return label
|
|
54
|
+
if (typeof children === 'string') return children
|
|
55
|
+
return ''
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function matchesQuery(label: string, query: string): boolean {
|
|
59
|
+
const q = query.trim().toLowerCase()
|
|
60
|
+
if (!q) return true
|
|
61
|
+
return label.toLowerCase().includes(q)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ComboboxRootProps {
|
|
65
|
+
value: string
|
|
66
|
+
onValueChange?: (value: string) => void
|
|
67
|
+
children: ReactNode
|
|
68
|
+
className?: string
|
|
69
|
+
disabled?: boolean
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const Root = forwardRef<HTMLDivElement, ComboboxRootProps>(function ComboboxRoot(
|
|
73
|
+
{ value, onValueChange, children, className, disabled },
|
|
74
|
+
ref,
|
|
75
|
+
) {
|
|
76
|
+
const [open, setOpenState] = useState(false)
|
|
77
|
+
const [query, setQuery] = useState('')
|
|
78
|
+
const [highlightedValue, setHighlightedValue] = useState<string | null>(null)
|
|
79
|
+
const [itemsVersion, setItemsVersion] = useState(0)
|
|
80
|
+
const itemsRef = useRef<RegisteredItem[]>([])
|
|
81
|
+
const listboxId = useId()
|
|
82
|
+
|
|
83
|
+
const setOpen = useCallback(
|
|
84
|
+
(next: boolean) => {
|
|
85
|
+
if (disabled) return
|
|
86
|
+
setOpenState(next)
|
|
87
|
+
if (!next) {
|
|
88
|
+
setQuery('')
|
|
89
|
+
setHighlightedValue(null)
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[disabled],
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
const registerItem = useCallback((item: RegisteredItem) => {
|
|
96
|
+
itemsRef.current = [...itemsRef.current.filter((i) => i.value !== item.value), item]
|
|
97
|
+
setItemsVersion((v) => v + 1)
|
|
98
|
+
}, [])
|
|
99
|
+
|
|
100
|
+
const unregisterItem = useCallback((valueKey: string) => {
|
|
101
|
+
itemsRef.current = itemsRef.current.filter((i) => i.value !== valueKey)
|
|
102
|
+
setItemsVersion((v) => v + 1)
|
|
103
|
+
}, [])
|
|
104
|
+
|
|
105
|
+
const getItems = useCallback(() => itemsRef.current, [])
|
|
106
|
+
|
|
107
|
+
const ctx = useMemo(
|
|
108
|
+
() => ({
|
|
109
|
+
value,
|
|
110
|
+
open: disabled ? false : open,
|
|
111
|
+
query,
|
|
112
|
+
listboxId,
|
|
113
|
+
highlightedValue,
|
|
114
|
+
itemsVersion,
|
|
115
|
+
setOpen,
|
|
116
|
+
setQuery,
|
|
117
|
+
setHighlightedValue,
|
|
118
|
+
onValueChange,
|
|
119
|
+
registerItem,
|
|
120
|
+
unregisterItem,
|
|
121
|
+
getItems,
|
|
122
|
+
}),
|
|
123
|
+
[
|
|
124
|
+
value,
|
|
125
|
+
open,
|
|
126
|
+
query,
|
|
127
|
+
listboxId,
|
|
128
|
+
highlightedValue,
|
|
129
|
+
itemsVersion,
|
|
130
|
+
setOpen,
|
|
131
|
+
onValueChange,
|
|
132
|
+
registerItem,
|
|
133
|
+
unregisterItem,
|
|
134
|
+
getItems,
|
|
135
|
+
disabled,
|
|
136
|
+
],
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<ComboboxCtx.Provider value={ctx}>
|
|
141
|
+
<div
|
|
142
|
+
ref={ref}
|
|
143
|
+
className={className}
|
|
144
|
+
{...partAttrs(comboboxAnatomy.scope, comboboxAnatomy.root, {
|
|
145
|
+
state: open ? 'open' : 'closed',
|
|
146
|
+
})}
|
|
147
|
+
>
|
|
148
|
+
{children}
|
|
149
|
+
</div>
|
|
150
|
+
</ComboboxCtx.Provider>
|
|
151
|
+
)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
function useVisibleItems() {
|
|
155
|
+
const { query, getItems, itemsVersion } = useComboboxCtx()
|
|
156
|
+
return useMemo(() => {
|
|
157
|
+
void itemsVersion
|
|
158
|
+
return getItems().filter((i) => matchesQuery(i.label, query))
|
|
159
|
+
}, [query, getItems, itemsVersion])
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const Input = forwardRef<HTMLInputElement, InputHTMLAttributes<HTMLInputElement>>(function ComboboxInput(
|
|
163
|
+
{ onChange, onKeyDown, onFocus, onClick, value: valueProp, ...rest },
|
|
164
|
+
ref,
|
|
165
|
+
) {
|
|
166
|
+
const {
|
|
167
|
+
value: selected,
|
|
168
|
+
open,
|
|
169
|
+
query,
|
|
170
|
+
listboxId,
|
|
171
|
+
highlightedValue,
|
|
172
|
+
itemsVersion,
|
|
173
|
+
setOpen,
|
|
174
|
+
setQuery,
|
|
175
|
+
setHighlightedValue,
|
|
176
|
+
onValueChange,
|
|
177
|
+
getItems,
|
|
178
|
+
} = useComboboxCtx()
|
|
179
|
+
const inputRef = useRef<HTMLInputElement | null>(null)
|
|
180
|
+
const visible = useVisibleItems()
|
|
181
|
+
|
|
182
|
+
const selectedLabel = useMemo(() => {
|
|
183
|
+
void itemsVersion
|
|
184
|
+
return getItems().find((i) => i.value === selected)?.label ?? ''
|
|
185
|
+
}, [getItems, selected, itemsVersion])
|
|
186
|
+
|
|
187
|
+
const displayValue = open ? query : selectedLabel
|
|
188
|
+
|
|
189
|
+
const selectValue = useCallback(
|
|
190
|
+
(next: string) => {
|
|
191
|
+
onValueChange?.(next)
|
|
192
|
+
setOpen(false)
|
|
193
|
+
setQuery('')
|
|
194
|
+
setHighlightedValue(null)
|
|
195
|
+
},
|
|
196
|
+
[onValueChange, setOpen, setQuery, setHighlightedValue],
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
const moveHighlight = useCallback(
|
|
200
|
+
(delta: number) => {
|
|
201
|
+
if (visible.length === 0) {
|
|
202
|
+
setHighlightedValue(null)
|
|
203
|
+
return
|
|
204
|
+
}
|
|
205
|
+
const idx = highlightedValue
|
|
206
|
+
? visible.findIndex((i) => i.value === highlightedValue)
|
|
207
|
+
: -1
|
|
208
|
+
let next = idx + delta
|
|
209
|
+
if (next < 0) next = visible.length - 1
|
|
210
|
+
if (next >= visible.length) next = 0
|
|
211
|
+
setHighlightedValue(visible[next]!.value)
|
|
212
|
+
},
|
|
213
|
+
[visible, highlightedValue, setHighlightedValue],
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
const setRefs = useCallback(
|
|
217
|
+
(node: HTMLInputElement | null) => {
|
|
218
|
+
inputRef.current = node
|
|
219
|
+
if (typeof ref === 'function') ref(node)
|
|
220
|
+
else if (ref) ref.current = node
|
|
221
|
+
},
|
|
222
|
+
[ref],
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
if (!open) return
|
|
227
|
+
const onPointerDown = (e: PointerEvent) => {
|
|
228
|
+
const root = inputRef.current?.closest('[data-aeon-scope="combobox"]')
|
|
229
|
+
if (root && !root.contains(e.target as Node)) setOpen(false)
|
|
230
|
+
}
|
|
231
|
+
const onKey = (e: globalThis.KeyboardEvent) => {
|
|
232
|
+
if (e.key === 'Escape') setOpen(false)
|
|
233
|
+
}
|
|
234
|
+
document.addEventListener('pointerdown', onPointerDown)
|
|
235
|
+
document.addEventListener('keydown', onKey)
|
|
236
|
+
return () => {
|
|
237
|
+
document.removeEventListener('pointerdown', onPointerDown)
|
|
238
|
+
document.removeEventListener('keydown', onKey)
|
|
239
|
+
}
|
|
240
|
+
}, [open, setOpen])
|
|
241
|
+
|
|
242
|
+
const activeDescendant =
|
|
243
|
+
highlightedValue && open
|
|
244
|
+
? `${listboxId}-option-${highlightedValue}`
|
|
245
|
+
: undefined
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<>
|
|
249
|
+
<input
|
|
250
|
+
ref={setRefs}
|
|
251
|
+
type="text"
|
|
252
|
+
role="combobox"
|
|
253
|
+
aria-autocomplete="list"
|
|
254
|
+
aria-expanded={open}
|
|
255
|
+
aria-controls={open ? listboxId : undefined}
|
|
256
|
+
aria-activedescendant={activeDescendant}
|
|
257
|
+
autoComplete="off"
|
|
258
|
+
value={valueProp ?? displayValue}
|
|
259
|
+
{...partAttrs(comboboxAnatomy.scope, comboboxAnatomy.input, { state: open ? 'open' : 'closed' })}
|
|
260
|
+
{...mergeProps(rest, {
|
|
261
|
+
onFocus: (e: FocusEvent<HTMLInputElement>) => {
|
|
262
|
+
onFocus?.(e)
|
|
263
|
+
setOpen(true)
|
|
264
|
+
},
|
|
265
|
+
onClick: (e: MouseEvent<HTMLInputElement>) => {
|
|
266
|
+
onClick?.(e)
|
|
267
|
+
setOpen(true)
|
|
268
|
+
},
|
|
269
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => {
|
|
270
|
+
onChange?.(e)
|
|
271
|
+
if (!e.defaultPrevented) {
|
|
272
|
+
setOpen(true)
|
|
273
|
+
setQuery(e.target.value)
|
|
274
|
+
setHighlightedValue(null)
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => {
|
|
278
|
+
onKeyDown?.(e)
|
|
279
|
+
if (e.defaultPrevented) return
|
|
280
|
+
if (e.key === 'ArrowDown') {
|
|
281
|
+
e.preventDefault()
|
|
282
|
+
if (!open) setOpen(true)
|
|
283
|
+
else moveHighlight(1)
|
|
284
|
+
}
|
|
285
|
+
if (e.key === 'ArrowUp') {
|
|
286
|
+
e.preventDefault()
|
|
287
|
+
if (!open) setOpen(true)
|
|
288
|
+
else moveHighlight(-1)
|
|
289
|
+
}
|
|
290
|
+
if (e.key === 'Home' && open) {
|
|
291
|
+
e.preventDefault()
|
|
292
|
+
if (visible[0]) setHighlightedValue(visible[0].value)
|
|
293
|
+
}
|
|
294
|
+
if (e.key === 'End' && open) {
|
|
295
|
+
e.preventDefault()
|
|
296
|
+
if (visible[visible.length - 1]) setHighlightedValue(visible[visible.length - 1]!.value)
|
|
297
|
+
}
|
|
298
|
+
if (e.key === 'Enter') {
|
|
299
|
+
e.preventDefault()
|
|
300
|
+
const pick = highlightedValue ?? visible[0]?.value
|
|
301
|
+
if (pick) selectValue(pick)
|
|
302
|
+
}
|
|
303
|
+
if (e.key === 'Escape') setOpen(false)
|
|
304
|
+
},
|
|
305
|
+
})}
|
|
306
|
+
/>
|
|
307
|
+
<span
|
|
308
|
+
{...partOnlyAttrs(comboboxAnatomy.icon, { state: open ? 'open' : 'closed' })}
|
|
309
|
+
aria-hidden
|
|
310
|
+
style={
|
|
311
|
+
open
|
|
312
|
+
? { transform: 'rotate(-135deg) translateY(2px)' }
|
|
313
|
+
: undefined
|
|
314
|
+
}
|
|
315
|
+
/>
|
|
316
|
+
</>
|
|
317
|
+
)
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
const Content = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function ComboboxContent(
|
|
321
|
+
{ children, className, ...rest },
|
|
322
|
+
ref,
|
|
323
|
+
) {
|
|
324
|
+
const { open, listboxId } = useComboboxCtx()
|
|
325
|
+
if (!open) return null
|
|
326
|
+
|
|
327
|
+
return (
|
|
328
|
+
<div
|
|
329
|
+
ref={ref}
|
|
330
|
+
id={listboxId}
|
|
331
|
+
role="listbox"
|
|
332
|
+
className={className}
|
|
333
|
+
data-aeon-scroll=""
|
|
334
|
+
{...partAttrs(comboboxAnatomy.scope, comboboxAnatomy.content)}
|
|
335
|
+
{...rest}
|
|
336
|
+
>
|
|
337
|
+
{children}
|
|
338
|
+
</div>
|
|
339
|
+
)
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
export interface ComboboxItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
343
|
+
value: string
|
|
344
|
+
/** Used for typeahead filter when children are not plain text. */
|
|
345
|
+
textValue?: string
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const Item = forwardRef<HTMLButtonElement, ComboboxItemProps>(function ComboboxItem(
|
|
349
|
+
{ value, textValue, children, onClick, ...rest },
|
|
350
|
+
ref,
|
|
351
|
+
) {
|
|
352
|
+
const {
|
|
353
|
+
value: selected,
|
|
354
|
+
query,
|
|
355
|
+
highlightedValue,
|
|
356
|
+
listboxId,
|
|
357
|
+
onValueChange,
|
|
358
|
+
setOpen,
|
|
359
|
+
setHighlightedValue,
|
|
360
|
+
registerItem,
|
|
361
|
+
unregisterItem,
|
|
362
|
+
} = useComboboxCtx()
|
|
363
|
+
const label = normalizeLabel(textValue, children)
|
|
364
|
+
const resolvedOptionId = `${listboxId}-option-${value}`
|
|
365
|
+
|
|
366
|
+
useEffect(() => {
|
|
367
|
+
registerItem({ value, label })
|
|
368
|
+
return () => unregisterItem(value)
|
|
369
|
+
}, [value, label, registerItem, unregisterItem])
|
|
370
|
+
|
|
371
|
+
if (!matchesQuery(label, query)) return null
|
|
372
|
+
|
|
373
|
+
const selectedState = value === selected
|
|
374
|
+
const highlighted = value === highlightedValue
|
|
375
|
+
|
|
376
|
+
return (
|
|
377
|
+
<button
|
|
378
|
+
ref={ref}
|
|
379
|
+
type="button"
|
|
380
|
+
role="option"
|
|
381
|
+
id={resolvedOptionId}
|
|
382
|
+
aria-selected={selectedState}
|
|
383
|
+
data-highlighted={highlighted ? '' : undefined}
|
|
384
|
+
{...partAttrs(comboboxAnatomy.scope, comboboxAnatomy.item, {
|
|
385
|
+
state: selectedState ? 'selected' : 'idle',
|
|
386
|
+
highlighted,
|
|
387
|
+
})}
|
|
388
|
+
{...mergeProps(rest, {
|
|
389
|
+
onClick: (e: MouseEvent<HTMLButtonElement>) => {
|
|
390
|
+
onClick?.(e)
|
|
391
|
+
if (!e.defaultPrevented) {
|
|
392
|
+
onValueChange?.(value)
|
|
393
|
+
setOpen(false)
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
onMouseEnter: () => setHighlightedValue(value),
|
|
397
|
+
})}
|
|
398
|
+
>
|
|
399
|
+
{children}
|
|
400
|
+
</button>
|
|
401
|
+
)
|
|
402
|
+
})
|
|
403
|
+
|
|
404
|
+
const Empty = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function ComboboxEmpty(
|
|
405
|
+
{ children, className, ...rest },
|
|
406
|
+
ref,
|
|
407
|
+
) {
|
|
408
|
+
const { open, query } = useComboboxCtx()
|
|
409
|
+
const visible = useVisibleItems()
|
|
410
|
+
if (!open || !query.trim() || visible.length > 0) return null
|
|
411
|
+
|
|
412
|
+
return (
|
|
413
|
+
<div
|
|
414
|
+
ref={ref}
|
|
415
|
+
className={className}
|
|
416
|
+
{...partAttrs(comboboxAnatomy.scope, comboboxAnatomy.empty)}
|
|
417
|
+
{...rest}
|
|
418
|
+
>
|
|
419
|
+
{children ?? 'No results'}
|
|
420
|
+
</div>
|
|
421
|
+
)
|
|
422
|
+
})
|
|
423
|
+
|
|
424
|
+
export const Combobox = {
|
|
425
|
+
Root,
|
|
426
|
+
Input,
|
|
427
|
+
Content,
|
|
428
|
+
Item,
|
|
429
|
+
Empty,
|
|
430
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import userEvent from '@testing-library/user-event'
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
4
|
+
import { Dialog } from '../dialog/index.js'
|
|
5
|
+
|
|
6
|
+
describe('Dialog', () => {
|
|
7
|
+
it('opens from trigger and closes on escape', async () => {
|
|
8
|
+
const user = userEvent.setup()
|
|
9
|
+
const onOpenChange = vi.fn()
|
|
10
|
+
|
|
11
|
+
render(
|
|
12
|
+
<Dialog.Root onOpenChange={onOpenChange}>
|
|
13
|
+
<Dialog.Trigger>Open</Dialog.Trigger>
|
|
14
|
+
<Dialog.Portal portalled={false}>
|
|
15
|
+
<Dialog.Backdrop />
|
|
16
|
+
<Dialog.Positioner>
|
|
17
|
+
<Dialog.Content>
|
|
18
|
+
<Dialog.Title>Title</Dialog.Title>
|
|
19
|
+
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
|
|
20
|
+
</Dialog.Content>
|
|
21
|
+
</Dialog.Positioner>
|
|
22
|
+
</Dialog.Portal>
|
|
23
|
+
</Dialog.Root>,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
await user.click(screen.getByRole('button', { name: 'Open' }))
|
|
27
|
+
expect(screen.getByRole('dialog')).toBeInTheDocument()
|
|
28
|
+
expect(onOpenChange).toHaveBeenLastCalledWith(true)
|
|
29
|
+
|
|
30
|
+
await user.keyboard('{Escape}')
|
|
31
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
|
|
32
|
+
expect(onOpenChange).toHaveBeenLastCalledWith(false)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('locks body scroll while open and restores on unmount', () => {
|
|
36
|
+
const { unmount } = render(
|
|
37
|
+
<Dialog.Root defaultOpen>
|
|
38
|
+
<Dialog.Portal portalled={false}>
|
|
39
|
+
<Dialog.Content>
|
|
40
|
+
<Dialog.Title>Title</Dialog.Title>
|
|
41
|
+
</Dialog.Content>
|
|
42
|
+
</Dialog.Portal>
|
|
43
|
+
</Dialog.Root>,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
expect(document.body.style.overflow).toBe('hidden')
|
|
47
|
+
unmount()
|
|
48
|
+
expect(document.body.style.overflow).not.toBe('hidden')
|
|
49
|
+
})
|
|
50
|
+
})
|