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,275 @@
|
|
|
1
|
+
import { dialogAnatomy, partAttrs } from '@aeon-ui/core'
|
|
2
|
+
import { dialogMachine } from '@aeon-ui/primitives'
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useId,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
type ButtonHTMLAttributes,
|
|
12
|
+
type HTMLAttributes,
|
|
13
|
+
type KeyboardEvent,
|
|
14
|
+
type MouseEvent,
|
|
15
|
+
type ReactNode,
|
|
16
|
+
} from 'react'
|
|
17
|
+
import { useAeonMachine } from '../hooks/use-aeon-machine.js'
|
|
18
|
+
import { useFocusTrap } from '../hooks/use-focus-trap.js'
|
|
19
|
+
import { renderPortalled, usePortalledMount } from '../hooks/use-portalled.js'
|
|
20
|
+
import { useScrollLock } from '../hooks/use-scroll-lock.js'
|
|
21
|
+
import { mergeProps } from '../utils/merge-props.js'
|
|
22
|
+
|
|
23
|
+
interface DialogContextValue {
|
|
24
|
+
open: boolean
|
|
25
|
+
send: ReturnType<typeof useAeonMachine<typeof dialogMachine>>[1]
|
|
26
|
+
titleId: string
|
|
27
|
+
descriptionId: string
|
|
28
|
+
contentRef: React.RefObject<HTMLDivElement | null>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const DialogCtx = createContext<DialogContextValue | null>(null)
|
|
32
|
+
|
|
33
|
+
function useDialogCtx() {
|
|
34
|
+
const ctx = useContext(DialogCtx)
|
|
35
|
+
if (!ctx) throw new Error('Dialog parts must be used within Dialog.Root')
|
|
36
|
+
return ctx
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface DialogRootProps {
|
|
40
|
+
open?: boolean
|
|
41
|
+
defaultOpen?: boolean
|
|
42
|
+
onOpenChange?: (open: boolean) => void
|
|
43
|
+
children?: ReactNode
|
|
44
|
+
className?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const Root = forwardRef<HTMLDivElement, DialogRootProps>(function DialogRoot(
|
|
48
|
+
{ open, defaultOpen = false, onOpenChange, children, className, ...rest },
|
|
49
|
+
ref,
|
|
50
|
+
) {
|
|
51
|
+
const [snapshot, send] = useAeonMachine(dialogMachine, {
|
|
52
|
+
input: { open: defaultOpen },
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const resolvedOpen = open ?? snapshot.context.open
|
|
56
|
+
const contentRef = useRef<HTMLDivElement>(null)
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
onOpenChange?.(resolvedOpen)
|
|
60
|
+
}, [resolvedOpen, onOpenChange])
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (open !== undefined) {
|
|
64
|
+
send({ type: 'SET_OPEN', open })
|
|
65
|
+
}
|
|
66
|
+
}, [open, send])
|
|
67
|
+
|
|
68
|
+
const titleId = useId()
|
|
69
|
+
const descriptionId = useId()
|
|
70
|
+
const value = useMemo(
|
|
71
|
+
() => ({ open: resolvedOpen, send, titleId, descriptionId, contentRef }),
|
|
72
|
+
[resolvedOpen, send, titleId, descriptionId],
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<DialogCtx.Provider value={value}>
|
|
77
|
+
<div
|
|
78
|
+
ref={ref}
|
|
79
|
+
className={className}
|
|
80
|
+
{...mergeProps(
|
|
81
|
+
partAttrs(dialogAnatomy.scope, dialogAnatomy.root, {
|
|
82
|
+
state: resolvedOpen ? 'open' : 'closed',
|
|
83
|
+
}),
|
|
84
|
+
rest as HTMLAttributes<HTMLDivElement>,
|
|
85
|
+
)}
|
|
86
|
+
>
|
|
87
|
+
{children}
|
|
88
|
+
</div>
|
|
89
|
+
</DialogCtx.Provider>
|
|
90
|
+
)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const Trigger = forwardRef<HTMLButtonElement, ButtonHTMLAttributes<HTMLButtonElement>>(function DialogTrigger(
|
|
94
|
+
{ onClick, ...rest },
|
|
95
|
+
ref,
|
|
96
|
+
) {
|
|
97
|
+
const { send } = useDialogCtx()
|
|
98
|
+
return (
|
|
99
|
+
<button
|
|
100
|
+
ref={ref}
|
|
101
|
+
type="button"
|
|
102
|
+
{...mergeProps(
|
|
103
|
+
partAttrs(dialogAnatomy.scope, dialogAnatomy.trigger),
|
|
104
|
+
{
|
|
105
|
+
onClick: (e: MouseEvent<HTMLButtonElement>) => {
|
|
106
|
+
onClick?.(e)
|
|
107
|
+
send({ type: 'OPEN' })
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
rest,
|
|
111
|
+
)}
|
|
112
|
+
/>
|
|
113
|
+
)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
export interface DialogPortalProps extends HTMLAttributes<HTMLDivElement> {
|
|
117
|
+
/** Mount overlay in document.body (default true). */
|
|
118
|
+
portalled?: boolean
|
|
119
|
+
children?: ReactNode
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const Portal = forwardRef<HTMLDivElement, DialogPortalProps>(function DialogPortal(
|
|
123
|
+
{ portalled = true, children, className, ...rest },
|
|
124
|
+
ref,
|
|
125
|
+
) {
|
|
126
|
+
const { open } = useDialogCtx()
|
|
127
|
+
const mounted = usePortalledMount()
|
|
128
|
+
|
|
129
|
+
useScrollLock(open)
|
|
130
|
+
|
|
131
|
+
if (!open) return null
|
|
132
|
+
|
|
133
|
+
const node = (
|
|
134
|
+
<div
|
|
135
|
+
ref={ref}
|
|
136
|
+
className={className}
|
|
137
|
+
{...mergeProps(partAttrs(dialogAnatomy.scope, dialogAnatomy.portal, { state: 'open' }), rest)}
|
|
138
|
+
>
|
|
139
|
+
{children}
|
|
140
|
+
</div>
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
return renderPortalled(node, portalled, mounted)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const Backdrop = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function DialogBackdrop(
|
|
147
|
+
props,
|
|
148
|
+
ref,
|
|
149
|
+
) {
|
|
150
|
+
const { open, send } = useDialogCtx()
|
|
151
|
+
if (!open) return null
|
|
152
|
+
return (
|
|
153
|
+
<div
|
|
154
|
+
ref={ref}
|
|
155
|
+
{...mergeProps(
|
|
156
|
+
partAttrs(dialogAnatomy.scope, dialogAnatomy.backdrop, { state: 'open' }),
|
|
157
|
+
{
|
|
158
|
+
onClick: () => send({ type: 'POINTER_DOWN_OUTSIDE' }),
|
|
159
|
+
},
|
|
160
|
+
props,
|
|
161
|
+
)}
|
|
162
|
+
/>
|
|
163
|
+
)
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
const Positioner = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function DialogPositioner(
|
|
167
|
+
props,
|
|
168
|
+
ref,
|
|
169
|
+
) {
|
|
170
|
+
const { open } = useDialogCtx()
|
|
171
|
+
if (!open) return null
|
|
172
|
+
return (
|
|
173
|
+
<div
|
|
174
|
+
ref={ref}
|
|
175
|
+
{...mergeProps(partAttrs(dialogAnatomy.scope, dialogAnatomy.positioner, { state: 'open' }), props)}
|
|
176
|
+
/>
|
|
177
|
+
)
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
const Content = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function DialogContent(
|
|
181
|
+
{ onKeyDown, ...rest },
|
|
182
|
+
ref,
|
|
183
|
+
) {
|
|
184
|
+
const { open, send, titleId, descriptionId, contentRef } = useDialogCtx()
|
|
185
|
+
|
|
186
|
+
useFocusTrap(contentRef, open)
|
|
187
|
+
|
|
188
|
+
useEffect(() => {
|
|
189
|
+
if (open) contentRef.current?.focus()
|
|
190
|
+
}, [open, contentRef])
|
|
191
|
+
|
|
192
|
+
if (!open) return null
|
|
193
|
+
return (
|
|
194
|
+
<div
|
|
195
|
+
ref={(node) => {
|
|
196
|
+
contentRef.current = node
|
|
197
|
+
if (typeof ref === 'function') ref(node)
|
|
198
|
+
else if (ref) ref.current = node
|
|
199
|
+
}}
|
|
200
|
+
role="dialog"
|
|
201
|
+
aria-modal="true"
|
|
202
|
+
aria-labelledby={titleId}
|
|
203
|
+
aria-describedby={descriptionId}
|
|
204
|
+
tabIndex={-1}
|
|
205
|
+
{...mergeProps(
|
|
206
|
+
partAttrs(dialogAnatomy.scope, dialogAnatomy.content, { state: 'open' }),
|
|
207
|
+
{
|
|
208
|
+
onKeyDown: (e: KeyboardEvent<HTMLDivElement>) => {
|
|
209
|
+
onKeyDown?.(e)
|
|
210
|
+
if (e.key === 'Escape') send({ type: 'ESCAPE' })
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
rest,
|
|
214
|
+
)}
|
|
215
|
+
/>
|
|
216
|
+
)
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
const Title = forwardRef<HTMLHeadingElement, HTMLAttributes<HTMLHeadingElement>>(function DialogTitle(
|
|
220
|
+
props,
|
|
221
|
+
ref,
|
|
222
|
+
) {
|
|
223
|
+
const { titleId } = useDialogCtx()
|
|
224
|
+
return (
|
|
225
|
+
<h2 ref={ref} id={titleId} {...mergeProps(partAttrs(dialogAnatomy.scope, dialogAnatomy.title), props)} />
|
|
226
|
+
)
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
const Description = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLParagraphElement>>(
|
|
230
|
+
function DialogDescription(props, ref) {
|
|
231
|
+
const { descriptionId } = useDialogCtx()
|
|
232
|
+
return (
|
|
233
|
+
<p
|
|
234
|
+
ref={ref}
|
|
235
|
+
id={descriptionId}
|
|
236
|
+
{...mergeProps(partAttrs(dialogAnatomy.scope, dialogAnatomy.description), props)}
|
|
237
|
+
/>
|
|
238
|
+
)
|
|
239
|
+
},
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
const CloseTrigger = forwardRef<HTMLButtonElement, ButtonHTMLAttributes<HTMLButtonElement>>(
|
|
243
|
+
function DialogCloseTrigger({ onClick, ...rest }, ref) {
|
|
244
|
+
const { send } = useDialogCtx()
|
|
245
|
+
return (
|
|
246
|
+
<button
|
|
247
|
+
ref={ref}
|
|
248
|
+
type="button"
|
|
249
|
+
{...mergeProps(
|
|
250
|
+
partAttrs(dialogAnatomy.scope, dialogAnatomy.closeTrigger),
|
|
251
|
+
{
|
|
252
|
+
'aria-label': 'Close dialog',
|
|
253
|
+
onClick: (e: MouseEvent<HTMLButtonElement>) => {
|
|
254
|
+
onClick?.(e)
|
|
255
|
+
send({ type: 'CLOSE' })
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
rest,
|
|
259
|
+
)}
|
|
260
|
+
/>
|
|
261
|
+
)
|
|
262
|
+
},
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
export const Dialog = {
|
|
266
|
+
Root,
|
|
267
|
+
Trigger,
|
|
268
|
+
Portal,
|
|
269
|
+
Backdrop,
|
|
270
|
+
Positioner,
|
|
271
|
+
Content,
|
|
272
|
+
Title,
|
|
273
|
+
Description,
|
|
274
|
+
CloseTrigger,
|
|
275
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { fieldAnatomy, partAttrs, partOnlyAttrs, stateToAttr } from '@aeon-ui/core'
|
|
2
|
+
import { fieldMachine } from '@aeon-ui/primitives'
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useContext,
|
|
7
|
+
useMemo,
|
|
8
|
+
type ChangeEvent,
|
|
9
|
+
type FocusEvent,
|
|
10
|
+
type InputHTMLAttributes,
|
|
11
|
+
type LabelHTMLAttributes,
|
|
12
|
+
type ReactNode,
|
|
13
|
+
type TextareaHTMLAttributes,
|
|
14
|
+
} from 'react'
|
|
15
|
+
import { useAeonMachine } from '../hooks/use-aeon-machine.js'
|
|
16
|
+
import { mergeProps } from '../utils/merge-props.js'
|
|
17
|
+
|
|
18
|
+
interface FieldContextValue {
|
|
19
|
+
stateAttr: string
|
|
20
|
+
send: ReturnType<typeof useAeonMachine<typeof fieldMachine>>[1]
|
|
21
|
+
invalid: boolean
|
|
22
|
+
pending: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const FieldCtx = createContext<FieldContextValue | null>(null)
|
|
26
|
+
|
|
27
|
+
export function useFieldContext(): FieldContextValue {
|
|
28
|
+
const ctx = useContext(FieldCtx)
|
|
29
|
+
if (!ctx) throw new Error('Field parts must be used within <Field.Root>')
|
|
30
|
+
return ctx
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface FieldRootProps {
|
|
34
|
+
children: ReactNode
|
|
35
|
+
className?: string
|
|
36
|
+
id?: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const Root = forwardRef<HTMLDivElement, FieldRootProps>(function FieldRoot(
|
|
40
|
+
{ children, className, id },
|
|
41
|
+
ref,
|
|
42
|
+
) {
|
|
43
|
+
const [snapshot, send] = useAeonMachine(fieldMachine)
|
|
44
|
+
const stateAttr = stateToAttr(snapshot.value)
|
|
45
|
+
const invalid =
|
|
46
|
+
typeof snapshot.value === 'object' &&
|
|
47
|
+
snapshot.value !== null &&
|
|
48
|
+
'validation' in snapshot.value &&
|
|
49
|
+
(snapshot.value as { validation: string }).validation === 'invalid'
|
|
50
|
+
const pending =
|
|
51
|
+
typeof snapshot.value === 'object' &&
|
|
52
|
+
snapshot.value !== null &&
|
|
53
|
+
'submission' in snapshot.value &&
|
|
54
|
+
(snapshot.value as { submission: string }).submission === 'pending'
|
|
55
|
+
|
|
56
|
+
const value = useMemo(
|
|
57
|
+
() => ({ stateAttr, send, invalid, pending }),
|
|
58
|
+
[stateAttr, send, invalid, pending],
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<FieldCtx.Provider value={value}>
|
|
63
|
+
<div
|
|
64
|
+
ref={ref}
|
|
65
|
+
id={id}
|
|
66
|
+
className={className}
|
|
67
|
+
{...partAttrs(fieldAnatomy.scope, fieldAnatomy.root, { state: stateAttr })}
|
|
68
|
+
>
|
|
69
|
+
{children}
|
|
70
|
+
</div>
|
|
71
|
+
</FieldCtx.Provider>
|
|
72
|
+
)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const Label = forwardRef<HTMLLabelElement, LabelHTMLAttributes<HTMLLabelElement>>(function FieldLabel(
|
|
76
|
+
props,
|
|
77
|
+
ref,
|
|
78
|
+
) {
|
|
79
|
+
return <label ref={ref} {...partOnlyAttrs(fieldAnatomy.label)} {...props} />
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
export interface FieldControlProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
83
|
+
validate?: (value: string) => boolean
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const Control = forwardRef<HTMLInputElement, FieldControlProps>(function FieldControl(
|
|
87
|
+
{ validate, onChange, onBlur, ...rest },
|
|
88
|
+
ref,
|
|
89
|
+
) {
|
|
90
|
+
const { send, invalid } = useFieldContext()
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<input
|
|
94
|
+
ref={ref}
|
|
95
|
+
aria-invalid={invalid || undefined}
|
|
96
|
+
{...partOnlyAttrs(fieldAnatomy.control)}
|
|
97
|
+
{...mergeProps(
|
|
98
|
+
{
|
|
99
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => {
|
|
100
|
+
send({ type: 'INPUT' })
|
|
101
|
+
const ok = validate?.(e.target.value) ?? true
|
|
102
|
+
send({ type: 'VALIDATE', valid: ok })
|
|
103
|
+
onChange?.(e)
|
|
104
|
+
},
|
|
105
|
+
onBlur: (e: FocusEvent<HTMLInputElement>) => {
|
|
106
|
+
send({ type: 'BLUR' })
|
|
107
|
+
onBlur?.(e)
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
rest,
|
|
111
|
+
)}
|
|
112
|
+
/>
|
|
113
|
+
)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
export interface FieldTextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
117
|
+
validate?: (value: string) => boolean
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const Textarea = forwardRef<HTMLTextAreaElement, FieldTextareaProps>(function FieldTextarea(
|
|
121
|
+
{ validate, onChange, onBlur, ...rest },
|
|
122
|
+
ref,
|
|
123
|
+
) {
|
|
124
|
+
const { send, invalid } = useFieldContext()
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<textarea
|
|
128
|
+
ref={ref}
|
|
129
|
+
aria-invalid={invalid || undefined}
|
|
130
|
+
{...partOnlyAttrs(fieldAnatomy.textarea)}
|
|
131
|
+
{...mergeProps(
|
|
132
|
+
{
|
|
133
|
+
onChange: (e: ChangeEvent<HTMLTextAreaElement>) => {
|
|
134
|
+
send({ type: 'INPUT' })
|
|
135
|
+
const ok = validate?.(e.target.value) ?? true
|
|
136
|
+
send({ type: 'VALIDATE', valid: ok })
|
|
137
|
+
onChange?.(e)
|
|
138
|
+
},
|
|
139
|
+
onBlur: (e: FocusEvent<HTMLTextAreaElement>) => {
|
|
140
|
+
send({ type: 'BLUR' })
|
|
141
|
+
onBlur?.(e)
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
rest,
|
|
145
|
+
)}
|
|
146
|
+
/>
|
|
147
|
+
)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
const Message = forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
|
151
|
+
function FieldMessage(props, ref) {
|
|
152
|
+
const { invalid } = useFieldContext()
|
|
153
|
+
if (!invalid) return null
|
|
154
|
+
return (
|
|
155
|
+
<p
|
|
156
|
+
ref={ref}
|
|
157
|
+
role="alert"
|
|
158
|
+
{...partOnlyAttrs(fieldAnatomy.message, { state: 'invalid' })}
|
|
159
|
+
{...props}
|
|
160
|
+
/>
|
|
161
|
+
)
|
|
162
|
+
},
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
const Hint = forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
|
166
|
+
function FieldHint(props, ref) {
|
|
167
|
+
return <p ref={ref} {...partOnlyAttrs(fieldAnatomy.hint)} {...props} />
|
|
168
|
+
},
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
export const Field = { Root, Label, Control, Textarea, Message, Hint }
|
|
172
|
+
export { fieldMachine }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useMachine } from '@xstate/react'
|
|
2
|
+
import type { AnyStateMachine } from 'xstate'
|
|
3
|
+
|
|
4
|
+
/** Bridge executable statecharts to React — UI = f(snapshot). */
|
|
5
|
+
export function useAeonMachine<M extends AnyStateMachine>(
|
|
6
|
+
machine: M,
|
|
7
|
+
options?: Parameters<typeof useMachine<M>>[1],
|
|
8
|
+
) {
|
|
9
|
+
return useMachine(machine, options)
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect, type RefObject } from 'react'
|
|
2
|
+
|
|
3
|
+
/** Pin floating listbox to trigger rect (for portalled selects). */
|
|
4
|
+
export function useAnchorPosition(
|
|
5
|
+
anchorRef: RefObject<HTMLElement | null>,
|
|
6
|
+
floatingRef: RefObject<HTMLElement | null>,
|
|
7
|
+
active: boolean,
|
|
8
|
+
) {
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!active || !anchorRef.current || !floatingRef.current) return
|
|
11
|
+
|
|
12
|
+
const update = () => {
|
|
13
|
+
const anchor = anchorRef.current
|
|
14
|
+
const floating = floatingRef.current
|
|
15
|
+
if (!anchor || !floating) return
|
|
16
|
+
const rect = anchor.getBoundingClientRect()
|
|
17
|
+
floating.style.position = 'fixed'
|
|
18
|
+
floating.style.top = `${rect.bottom + 4}px`
|
|
19
|
+
floating.style.left = `${rect.left}px`
|
|
20
|
+
floating.style.width = `${rect.width}px`
|
|
21
|
+
floating.style.minWidth = `${rect.width}px`
|
|
22
|
+
floating.style.zIndex = '50'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
update()
|
|
26
|
+
window.addEventListener('resize', update)
|
|
27
|
+
window.addEventListener('scroll', update, true)
|
|
28
|
+
return () => {
|
|
29
|
+
window.removeEventListener('resize', update)
|
|
30
|
+
window.removeEventListener('scroll', update, true)
|
|
31
|
+
}
|
|
32
|
+
}, [active, anchorRef, floatingRef])
|
|
33
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useEffect, type RefObject } from 'react'
|
|
2
|
+
|
|
3
|
+
const FOCUSABLE =
|
|
4
|
+
'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
5
|
+
|
|
6
|
+
function getFocusable(container: HTMLElement): HTMLElement[] {
|
|
7
|
+
return Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE)).filter(
|
|
8
|
+
(el) => !el.hasAttribute('disabled') && el.tabIndex !== -1,
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Keep Tab cycles inside `container` while `active`. Restores focus on deactivate. */
|
|
13
|
+
export function useFocusTrap(containerRef: RefObject<HTMLElement | null>, active: boolean) {
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!active || !containerRef.current) return
|
|
16
|
+
|
|
17
|
+
const container = containerRef.current
|
|
18
|
+
const previous = document.activeElement
|
|
19
|
+
|
|
20
|
+
const focusables = getFocusable(container)
|
|
21
|
+
focusables[0]?.focus()
|
|
22
|
+
|
|
23
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
24
|
+
if (e.key !== 'Tab') return
|
|
25
|
+
const nodes = getFocusable(container)
|
|
26
|
+
if (nodes.length === 0) return
|
|
27
|
+
|
|
28
|
+
const first = nodes[0]!
|
|
29
|
+
const last = nodes[nodes.length - 1]!
|
|
30
|
+
const current = document.activeElement
|
|
31
|
+
|
|
32
|
+
if (e.shiftKey) {
|
|
33
|
+
if (current === first || !container.contains(current)) {
|
|
34
|
+
e.preventDefault()
|
|
35
|
+
last.focus()
|
|
36
|
+
}
|
|
37
|
+
} else if (current === last || !container.contains(current)) {
|
|
38
|
+
e.preventDefault()
|
|
39
|
+
first.focus()
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
document.addEventListener('keydown', onKeyDown)
|
|
44
|
+
return () => {
|
|
45
|
+
document.removeEventListener('keydown', onKeyDown)
|
|
46
|
+
if (previous instanceof HTMLElement && document.contains(previous)) {
|
|
47
|
+
previous.focus()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, [active, containerRef])
|
|
51
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { LayoutCompositionSpec, LayoutMode, ResponsiveLayoutSpec } from '@aeon-ui/core'
|
|
2
|
+
import { getCompactMq, layoutCompositionForMode, matchLayoutMode } from '@aeon-ui/core'
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
4
|
+
|
|
5
|
+
export function useLayoutMode(spec: ResponsiveLayoutSpec): {
|
|
6
|
+
mode: LayoutMode
|
|
7
|
+
composition: LayoutCompositionSpec
|
|
8
|
+
} {
|
|
9
|
+
const mq = useMemo(() => getCompactMq(spec), [spec.compactMq])
|
|
10
|
+
const [mode, setMode] = useState<LayoutMode>(() => matchLayoutMode(spec, mq))
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const sync = () => setMode(matchLayoutMode(spec, mq))
|
|
14
|
+
sync()
|
|
15
|
+
mq.addEventListener('change', sync)
|
|
16
|
+
return () => mq.removeEventListener('change', sync)
|
|
17
|
+
}, [spec, mq])
|
|
18
|
+
|
|
19
|
+
const composition = useMemo(() => layoutCompositionForMode(spec, mode), [spec, mode])
|
|
20
|
+
|
|
21
|
+
return { mode, composition }
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect, type RefObject } from 'react'
|
|
2
|
+
|
|
3
|
+
/** Close floating content when pointer down occurs outside the container. */
|
|
4
|
+
export function useOutsideClick(
|
|
5
|
+
refs: RefObject<HTMLElement | null>[],
|
|
6
|
+
enabled: boolean,
|
|
7
|
+
onOutside: () => void,
|
|
8
|
+
) {
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!enabled) return
|
|
11
|
+
const onDown = (e: MouseEvent) => {
|
|
12
|
+
const target = e.target as Node
|
|
13
|
+
if (refs.some((r) => r.current?.contains(target))) return
|
|
14
|
+
onOutside()
|
|
15
|
+
}
|
|
16
|
+
document.addEventListener('mousedown', onDown)
|
|
17
|
+
return () => document.removeEventListener('mousedown', onDown)
|
|
18
|
+
}, [refs, enabled, onOutside])
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect, useState, type ReactNode } from 'react'
|
|
2
|
+
import { createPortal } from 'react-dom'
|
|
3
|
+
|
|
4
|
+
/** Client-only gate before `createPortal` (SSR/hydration). */
|
|
5
|
+
export function usePortalledMount() {
|
|
6
|
+
const [mounted, setMounted] = useState(false)
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
setMounted(true)
|
|
9
|
+
}, [])
|
|
10
|
+
return mounted
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function renderPortalled(node: ReactNode, portalled: boolean, mounted: boolean) {
|
|
14
|
+
if (!portalled || !mounted) return node
|
|
15
|
+
return createPortal(node, document.body)
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
/** Prevent body scroll while overlays are open (modal dialogs). */
|
|
4
|
+
export function useScrollLock(active: boolean) {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (!active) return
|
|
7
|
+
const prev = document.body.style.overflow
|
|
8
|
+
document.body.style.overflow = 'hidden'
|
|
9
|
+
return () => {
|
|
10
|
+
document.body.style.overflow = prev
|
|
11
|
+
}
|
|
12
|
+
}, [active])
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './button/index.js'
|
|
2
|
+
export * from './switch/index.js'
|
|
3
|
+
export * from './checkbox/index.js'
|
|
4
|
+
export * from './dialog/index.js'
|
|
5
|
+
export * from './tabs/index.js'
|
|
6
|
+
export * from './accordion/index.js'
|
|
7
|
+
export * from './async/index.js'
|
|
8
|
+
export * from './field/index.js'
|
|
9
|
+
export * from './scroll/index.js'
|
|
10
|
+
export * from './select/index.js'
|
|
11
|
+
export * from './combobox/index.js'
|
|
12
|
+
export * from './popover/index.js'
|
|
13
|
+
export * from './menu/index.js'
|
|
14
|
+
export * from './tooltip/index.js'
|
|
15
|
+
export * from './toast/index.js'
|
|
16
|
+
export * from './avatar/index.js'
|
|
17
|
+
export { useAeonMachine } from './hooks/use-aeon-machine.js'
|
|
18
|
+
export { useLayoutMode } from './hooks/use-layout-mode.js'
|