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,61 @@
|
|
|
1
|
+
import { assign, setup } from 'xstate'
|
|
2
|
+
|
|
3
|
+
export interface ToggleContext {
|
|
4
|
+
checked: boolean
|
|
5
|
+
disabled: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type ToggleEvent =
|
|
9
|
+
| { type: 'TOGGLE' }
|
|
10
|
+
| { type: 'SET_CHECKED'; checked: boolean }
|
|
11
|
+
| { type: 'POINTER_DOWN' }
|
|
12
|
+
| { type: 'POINTER_UP' }
|
|
13
|
+
| { type: 'POINTER_LEAVE' }
|
|
14
|
+
|
|
15
|
+
/** Checked and unchecked are distinct, stable states. */
|
|
16
|
+
export const toggleMachine = setup({
|
|
17
|
+
types: {
|
|
18
|
+
context: {} as ToggleContext,
|
|
19
|
+
events: {} as ToggleEvent,
|
|
20
|
+
input: {} as ToggleContext,
|
|
21
|
+
},
|
|
22
|
+
guards: {
|
|
23
|
+
notDisabled: ({ context }) => !context.disabled,
|
|
24
|
+
},
|
|
25
|
+
actions: {
|
|
26
|
+
flip: assign({
|
|
27
|
+
checked: ({ context }) => !context.checked,
|
|
28
|
+
}),
|
|
29
|
+
setChecked: assign({
|
|
30
|
+
checked: ({ event }) => (event.type === 'SET_CHECKED' ? event.checked : false),
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
}).createMachine({
|
|
34
|
+
id: 'toggle',
|
|
35
|
+
context: ({ input }) => ({
|
|
36
|
+
checked: input.checked ?? false,
|
|
37
|
+
disabled: input.disabled ?? false,
|
|
38
|
+
}),
|
|
39
|
+
initial: 'interaction',
|
|
40
|
+
states: {
|
|
41
|
+
interaction: {
|
|
42
|
+
initial: 'idle',
|
|
43
|
+
states: {
|
|
44
|
+
idle: {
|
|
45
|
+
on: {
|
|
46
|
+
POINTER_DOWN: { target: 'pressed', guard: 'notDisabled' },
|
|
47
|
+
TOGGLE: { actions: 'flip', guard: 'notDisabled' },
|
|
48
|
+
SET_CHECKED: { actions: 'setChecked' },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
pressed: {
|
|
52
|
+
on: {
|
|
53
|
+
/* Flip on TOGGLE (click/keyboard) only — pointer up is visual press state. */
|
|
54
|
+
POINTER_UP: 'idle',
|
|
55
|
+
POINTER_LEAVE: 'idle',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @aeon-ui/react
|
|
2
|
+
|
|
3
|
+
**Headless compound components** — snapshot/props → DOM + accessibility.
|
|
4
|
+
|
|
5
|
+
Agents: [docs/MACHINES.md](../../docs/MACHINES.md) before editing state wiring.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @aeon-ui/react @aeon-ui/core @aeon-ui/primitives
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Style yourself with `[data-aeon-*]` or use `@aeon-ui/ui`.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Dialog, Button, useAeonMachine } from '@aeon-ui/react'
|
|
19
|
+
import { buttonLifecycleMachine } from '@aeon-ui/primitives'
|
|
20
|
+
|
|
21
|
+
<Dialog.Root>
|
|
22
|
+
<Dialog.Trigger>Open</Dialog.Trigger>
|
|
23
|
+
<Dialog.Backdrop />
|
|
24
|
+
<Dialog.Positioner>
|
|
25
|
+
<Dialog.Content>
|
|
26
|
+
<Dialog.Title>Title</Dialog.Title>
|
|
27
|
+
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
|
|
28
|
+
</Dialog.Content>
|
|
29
|
+
</Dialog.Positioner>
|
|
30
|
+
</Dialog.Root>
|
|
31
|
+
|
|
32
|
+
<Button.Root status="pending">Save</Button.Root>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Catalog
|
|
36
|
+
|
|
37
|
+
`Button`, `Switch`, `Checkbox`, `Dialog`, `Tabs`, `Accordion`, `Select`, `Combobox`, `Async`, `Field`, `Scroll`, `Menu`, `Popover`, `Tooltip`, `Toast`, `useAeonMachine`, `useLayoutMode`.
|
|
38
|
+
|
|
39
|
+
See [COMPONENTS.md](../../COMPONENTS.md).
|
|
40
|
+
|
|
41
|
+
## Patterns
|
|
42
|
+
|
|
43
|
+
| Pattern | Components |
|
|
44
|
+
|---------|------------|
|
|
45
|
+
| `useAeonMachine` + primitives | Dialog, Switch, Async, Field, Tabs, … |
|
|
46
|
+
| `status` prop | Button |
|
|
47
|
+
| `useState` | Select, Combobox, Tooltip |
|
|
48
|
+
| `getScrollSnapshot` | Scroll |
|
|
49
|
+
|
|
50
|
+
## Custom wrapper
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { partAttrs, dialogAnatomy } from '@aeon-ui/core'
|
|
54
|
+
|
|
55
|
+
<button {...partAttrs(dialogAnatomy.scope, dialogAnatomy.trigger, { state: 'closed' })} />
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## File layout
|
|
59
|
+
|
|
60
|
+
`src/<component>/index.tsx` — see [docs/FILE_MAP.md](../../docs/FILE_MAP.md).
|
|
61
|
+
|
|
62
|
+
## Related
|
|
63
|
+
|
|
64
|
+
- [INTEGRATION.md](../../INTEGRATION.md)
|
|
65
|
+
- [FRAMEWORKS.md](../../FRAMEWORKS.md)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aeon-ui/react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Headless React components backed by XState machines",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/GenericCPU/aeon-ui.git",
|
|
9
|
+
"directory": "packages/react"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": { "access": "public" },
|
|
12
|
+
"files": ["dist", "README.md"],
|
|
13
|
+
"keywords": ["aeon-ui", "react", "headless", "xstate", "statechart"],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup src/index.ts --format esm --dts --clean --external react --external react-dom",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"test": "vitest run"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@aeon-ui/core": "workspace:*",
|
|
31
|
+
"@aeon-ui/primitives": "workspace:*",
|
|
32
|
+
"@xstate/react": "^5.0.3",
|
|
33
|
+
"xstate": "^5.19.2"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"react": "^18 || ^19",
|
|
37
|
+
"react-dom": "^18 || ^19"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
41
|
+
"@testing-library/react": "^16.3.0",
|
|
42
|
+
"@testing-library/user-event": "^14.6.1",
|
|
43
|
+
"@types/react": "^19.1.2",
|
|
44
|
+
"@types/react-dom": "^19.1.2",
|
|
45
|
+
"jsdom": "^26.1.0",
|
|
46
|
+
"react": "^19.1.0",
|
|
47
|
+
"react-dom": "^19.1.0",
|
|
48
|
+
"tsup": "^8.4.0",
|
|
49
|
+
"typescript": "^5.8.3",
|
|
50
|
+
"vitest": "^3.2.4"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { accordionAnatomy, partOnlyAttrs, scopeAttrs } from '@aeon-ui/core'
|
|
2
|
+
import { accordionMachine } from '@aeon-ui/primitives'
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
type ButtonHTMLAttributes,
|
|
10
|
+
type HTMLAttributes,
|
|
11
|
+
type MouseEvent,
|
|
12
|
+
type ReactNode,
|
|
13
|
+
} from 'react'
|
|
14
|
+
import { useAeonMachine } from '../hooks/use-aeon-machine.js'
|
|
15
|
+
import { mergeProps } from '../utils/merge-props.js'
|
|
16
|
+
|
|
17
|
+
interface AccordionContextValue {
|
|
18
|
+
value: string[]
|
|
19
|
+
send: ReturnType<typeof useAeonMachine<typeof accordionMachine>>[1]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const AccordionCtx = createContext<AccordionContextValue | null>(null)
|
|
23
|
+
|
|
24
|
+
function useAccordionCtx() {
|
|
25
|
+
const ctx = useContext(AccordionCtx)
|
|
26
|
+
if (!ctx) throw new Error('Accordion parts must be used within Accordion.Root')
|
|
27
|
+
return ctx
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface AccordionRootProps {
|
|
31
|
+
value?: string[]
|
|
32
|
+
defaultValue?: string[]
|
|
33
|
+
multiple?: boolean
|
|
34
|
+
collapsible?: boolean
|
|
35
|
+
onValueChange?: (value: string[]) => void
|
|
36
|
+
children?: ReactNode
|
|
37
|
+
className?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const Root = forwardRef<HTMLDivElement, AccordionRootProps>(function AccordionRoot(
|
|
41
|
+
{
|
|
42
|
+
value,
|
|
43
|
+
defaultValue = [],
|
|
44
|
+
multiple = false,
|
|
45
|
+
collapsible = true,
|
|
46
|
+
onValueChange,
|
|
47
|
+
children,
|
|
48
|
+
className,
|
|
49
|
+
...rest
|
|
50
|
+
},
|
|
51
|
+
ref,
|
|
52
|
+
) {
|
|
53
|
+
const [snapshot, send] = useAeonMachine(accordionMachine, {
|
|
54
|
+
input: { value: defaultValue, multiple, collapsible },
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const resolvedValue = value ?? snapshot.context.value
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
onValueChange?.(resolvedValue)
|
|
61
|
+
}, [resolvedValue, onValueChange])
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (value !== undefined) send({ type: 'SET_VALUE', value })
|
|
65
|
+
}, [value, send])
|
|
66
|
+
|
|
67
|
+
const ctx = useMemo(() => ({ value: resolvedValue, send }), [resolvedValue, send])
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<AccordionCtx.Provider value={ctx}>
|
|
71
|
+
<div
|
|
72
|
+
ref={ref}
|
|
73
|
+
className={className}
|
|
74
|
+
{...mergeProps(
|
|
75
|
+
scopeAttrs(accordionAnatomy.scope, accordionAnatomy.root),
|
|
76
|
+
rest as HTMLAttributes<HTMLDivElement>,
|
|
77
|
+
)}
|
|
78
|
+
>
|
|
79
|
+
{children}
|
|
80
|
+
</div>
|
|
81
|
+
</AccordionCtx.Provider>
|
|
82
|
+
)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
export interface AccordionItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
86
|
+
value: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const Item = forwardRef<HTMLDivElement, AccordionItemProps>(function AccordionItem(
|
|
90
|
+
{ value: itemValue, children, ...rest },
|
|
91
|
+
ref,
|
|
92
|
+
) {
|
|
93
|
+
const { value } = useAccordionCtx()
|
|
94
|
+
const open = value.includes(itemValue)
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div
|
|
98
|
+
ref={ref}
|
|
99
|
+
{...mergeProps(
|
|
100
|
+
partOnlyAttrs(accordionAnatomy.item, {
|
|
101
|
+
state: open ? 'open' : 'closed',
|
|
102
|
+
}),
|
|
103
|
+
rest,
|
|
104
|
+
)}
|
|
105
|
+
>
|
|
106
|
+
{children}
|
|
107
|
+
</div>
|
|
108
|
+
)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
export interface AccordionItemTriggerProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
112
|
+
value: string
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const ItemTrigger = forwardRef<HTMLButtonElement, AccordionItemTriggerProps>(function AccordionItemTrigger(
|
|
116
|
+
{ value: itemValue, onClick, ...rest },
|
|
117
|
+
ref,
|
|
118
|
+
) {
|
|
119
|
+
const { value, send } = useAccordionCtx()
|
|
120
|
+
const open = value.includes(itemValue)
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<button
|
|
124
|
+
ref={ref}
|
|
125
|
+
type="button"
|
|
126
|
+
aria-expanded={open}
|
|
127
|
+
{...mergeProps(
|
|
128
|
+
partOnlyAttrs(accordionAnatomy.itemTrigger, {
|
|
129
|
+
state: open ? 'open' : 'closed',
|
|
130
|
+
}),
|
|
131
|
+
{
|
|
132
|
+
onClick: (e: MouseEvent<HTMLButtonElement>) => {
|
|
133
|
+
onClick?.(e)
|
|
134
|
+
send({ type: 'TOGGLE', item: itemValue })
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
rest,
|
|
138
|
+
)}
|
|
139
|
+
/>
|
|
140
|
+
)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
export interface AccordionItemContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
144
|
+
value: string
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const ItemContent = forwardRef<HTMLDivElement, AccordionItemContentProps>(function AccordionItemContent(
|
|
148
|
+
{ value: itemValue, children, ...rest },
|
|
149
|
+
ref,
|
|
150
|
+
) {
|
|
151
|
+
const { value } = useAccordionCtx()
|
|
152
|
+
if (!value.includes(itemValue)) return null
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<div
|
|
156
|
+
ref={ref}
|
|
157
|
+
{...mergeProps(
|
|
158
|
+
partOnlyAttrs(accordionAnatomy.itemContent, { state: 'open' }),
|
|
159
|
+
rest,
|
|
160
|
+
)}
|
|
161
|
+
>
|
|
162
|
+
{children}
|
|
163
|
+
</div>
|
|
164
|
+
)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
const ItemIndicator = forwardRef<HTMLSpanElement, HTMLAttributes<HTMLSpanElement>>(function AccordionItemIndicator(
|
|
168
|
+
props,
|
|
169
|
+
ref,
|
|
170
|
+
) {
|
|
171
|
+
return (
|
|
172
|
+
<span
|
|
173
|
+
ref={ref}
|
|
174
|
+
{...mergeProps(partOnlyAttrs(accordionAnatomy.itemIndicator), props)}
|
|
175
|
+
/>
|
|
176
|
+
)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
export const Accordion = { Root, Item, ItemTrigger, ItemContent, ItemIndicator }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { asyncAnatomy, partOnlyAttrs } from '@aeon-ui/core'
|
|
2
|
+
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react'
|
|
3
|
+
import { mergeProps } from '../utils/merge-props.js'
|
|
4
|
+
|
|
5
|
+
export interface AsyncActionsProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
children: ReactNode
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const AsyncActions = forwardRef<HTMLDivElement, AsyncActionsProps>(function AsyncActions(
|
|
10
|
+
{ children, className, ...rest },
|
|
11
|
+
ref,
|
|
12
|
+
) {
|
|
13
|
+
return (
|
|
14
|
+
<div
|
|
15
|
+
ref={ref}
|
|
16
|
+
className={className}
|
|
17
|
+
{...mergeProps(partOnlyAttrs(asyncAnatomy.actions), rest)}
|
|
18
|
+
>
|
|
19
|
+
{children}
|
|
20
|
+
</div>
|
|
21
|
+
)
|
|
22
|
+
})
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AsyncContext } from '@aeon-ui/primitives'
|
|
2
|
+
import { createAsyncMachine } from '@aeon-ui/primitives'
|
|
3
|
+
import { createContext, useContext, useMemo, type ReactNode } from 'react'
|
|
4
|
+
import { useAeonMachine } from '../hooks/use-aeon-machine.js'
|
|
5
|
+
|
|
6
|
+
const defaultMachine = createAsyncMachine()
|
|
7
|
+
|
|
8
|
+
export interface AsyncProviderValue {
|
|
9
|
+
status: string
|
|
10
|
+
data: unknown
|
|
11
|
+
error: string | null
|
|
12
|
+
stale: boolean
|
|
13
|
+
stateAttr: string
|
|
14
|
+
send: ReturnType<typeof useAeonMachine<typeof defaultMachine>>[1]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const AsyncCtx = createContext<AsyncProviderValue | null>(null)
|
|
18
|
+
|
|
19
|
+
export function useAsyncContext(): AsyncProviderValue {
|
|
20
|
+
const ctx = useContext(AsyncCtx)
|
|
21
|
+
if (!ctx) {
|
|
22
|
+
throw new Error('Async compound components must be used within <Async.Root>')
|
|
23
|
+
}
|
|
24
|
+
return ctx
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface AsyncProviderProps {
|
|
28
|
+
children: ReactNode
|
|
29
|
+
machine?: typeof defaultMachine
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function AsyncProvider({ children, machine }: AsyncProviderProps) {
|
|
33
|
+
const resolvedMachine = machine ?? defaultMachine
|
|
34
|
+
const [snapshot, send] = useAeonMachine(resolvedMachine)
|
|
35
|
+
const status = String(snapshot.value)
|
|
36
|
+
const { data, error, stale } = snapshot.context as AsyncContext
|
|
37
|
+
const stateAttr = stale && status === 'success' ? `${status} stale` : status
|
|
38
|
+
|
|
39
|
+
const value = useMemo<AsyncProviderValue>(
|
|
40
|
+
() => ({
|
|
41
|
+
send,
|
|
42
|
+
status,
|
|
43
|
+
data,
|
|
44
|
+
error,
|
|
45
|
+
stale: Boolean(stale),
|
|
46
|
+
stateAttr,
|
|
47
|
+
}),
|
|
48
|
+
[send, status, data, error, stale, stateAttr],
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
return <AsyncCtx.Provider value={value}>{children}</AsyncCtx.Provider>
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type { AsyncEvent } from '@aeon-ui/primitives'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AsyncActions } from './actions.js'
|
|
2
|
+
import { AsyncProvider } from './context.js'
|
|
3
|
+
import { AsyncReadout } from './readout.js'
|
|
4
|
+
import { AsyncRoot } from './root.js'
|
|
5
|
+
import { AsyncTrack } from './track.js'
|
|
6
|
+
|
|
7
|
+
export { AsyncProvider, useAsyncContext } from './context.js'
|
|
8
|
+
export { AsyncTrack } from './track.js'
|
|
9
|
+
export { AsyncReadout } from './readout.js'
|
|
10
|
+
export { AsyncActions } from './actions.js'
|
|
11
|
+
export { AsyncRoot } from './root.js'
|
|
12
|
+
export { AsyncRegion } from './legacy-region.js'
|
|
13
|
+
export { createAsyncMachine } from '@aeon-ui/primitives'
|
|
14
|
+
|
|
15
|
+
export const Async = {
|
|
16
|
+
Root: AsyncRoot,
|
|
17
|
+
Provider: AsyncProvider,
|
|
18
|
+
Track: AsyncTrack,
|
|
19
|
+
Readout: AsyncReadout,
|
|
20
|
+
Actions: AsyncActions,
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { partAttrs } from '@aeon-ui/core'
|
|
2
|
+
import { createAsyncMachine } from '@aeon-ui/primitives'
|
|
3
|
+
import { useMemo, type ReactNode } from 'react'
|
|
4
|
+
import { useAeonMachine } from '../hooks/use-aeon-machine.js'
|
|
5
|
+
import { mergeProps } from '../utils/merge-props.js'
|
|
6
|
+
|
|
7
|
+
export interface AsyncRegionProps<T = unknown> {
|
|
8
|
+
children?: ReactNode | ((state: { status: string; data: T | null; error: string | null }) => ReactNode)
|
|
9
|
+
className?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** @deprecated Prefer `<Async.Root>` with Track, Readout, and Actions. */
|
|
13
|
+
export function AsyncRegion<T = unknown>({ children, className }: AsyncRegionProps<T>) {
|
|
14
|
+
const machine = useMemo(() => createAsyncMachine<T>(), [])
|
|
15
|
+
const [snapshot] = useAeonMachine(machine)
|
|
16
|
+
const status = snapshot.value as string
|
|
17
|
+
const { data, error } = snapshot.context
|
|
18
|
+
|
|
19
|
+
const content =
|
|
20
|
+
typeof children === 'function' ? children({ status, data: data as T | null, error }) : children
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
className={className}
|
|
25
|
+
{...mergeProps(partAttrs('async', 'root', { state: status }))}
|
|
26
|
+
>
|
|
27
|
+
{content ?? (
|
|
28
|
+
<>
|
|
29
|
+
{status === 'idle' && <span data-aeon-part="idle">Ready</span>}
|
|
30
|
+
{status === 'loading' && <span data-aeon-part="loading">Loading…</span>}
|
|
31
|
+
{status === 'success' && <span data-aeon-part="success">{String(data)}</span>}
|
|
32
|
+
{status === 'failure' && <span data-aeon-part="failure">{error}</span>}
|
|
33
|
+
{status === 'empty' && <span data-aeon-part="empty">No results</span>}
|
|
34
|
+
</>
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { asyncAnatomy, partAttrs, partOnlyAttrs } from '@aeon-ui/core'
|
|
2
|
+
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react'
|
|
3
|
+
import { mergeProps } from '../utils/merge-props.js'
|
|
4
|
+
import { useAsyncContext } from './context.js'
|
|
5
|
+
|
|
6
|
+
export interface AsyncReadoutProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
children?: ReactNode
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const AsyncReadout = forwardRef<HTMLDivElement, AsyncReadoutProps>(function AsyncReadout(
|
|
11
|
+
{ children, className, ...rest },
|
|
12
|
+
ref,
|
|
13
|
+
) {
|
|
14
|
+
const { stateAttr } = useAsyncContext()
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
ref={ref}
|
|
19
|
+
role="status"
|
|
20
|
+
aria-live="polite"
|
|
21
|
+
className={className}
|
|
22
|
+
{...mergeProps(partAttrs(asyncAnatomy.scope, asyncAnatomy.readout, { state: stateAttr }), rest)}
|
|
23
|
+
>
|
|
24
|
+
<span
|
|
25
|
+
className="aeon-async-readout__rail"
|
|
26
|
+
aria-hidden
|
|
27
|
+
{...partOnlyAttrs(asyncAnatomy.readoutRail)}
|
|
28
|
+
/>
|
|
29
|
+
<div className="aeon-async-readout__body" {...partOnlyAttrs(asyncAnatomy.readoutBody)}>
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { asyncAnatomy, partAttrs } from '@aeon-ui/core'
|
|
2
|
+
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react'
|
|
3
|
+
import { mergeProps } from '../utils/merge-props.js'
|
|
4
|
+
import { AsyncProvider, useAsyncContext } from './context.js'
|
|
5
|
+
|
|
6
|
+
export interface AsyncRootProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
children: ReactNode
|
|
8
|
+
className?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const AsyncRootInner = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function AsyncRootInner(
|
|
12
|
+
{ children, className, ...rest },
|
|
13
|
+
ref,
|
|
14
|
+
) {
|
|
15
|
+
const { stateAttr } = useAsyncContext()
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={className}
|
|
21
|
+
{...mergeProps(partAttrs(asyncAnatomy.scope, asyncAnatomy.root, { state: stateAttr }), rest)}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
export const AsyncRoot = forwardRef<HTMLDivElement, AsyncRootProps>(function AsyncRoot(
|
|
29
|
+
{ children, className, ...rest },
|
|
30
|
+
ref,
|
|
31
|
+
) {
|
|
32
|
+
return (
|
|
33
|
+
<AsyncProvider>
|
|
34
|
+
<AsyncRootInner ref={ref} className={className} {...rest}>
|
|
35
|
+
{children}
|
|
36
|
+
</AsyncRootInner>
|
|
37
|
+
</AsyncProvider>
|
|
38
|
+
)
|
|
39
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { asyncAnatomy, partOnlyAttrs } from '@aeon-ui/core'
|
|
2
|
+
import { ASYNC_LIFECYCLE_STATES } from '@aeon-ui/primitives'
|
|
3
|
+
import { forwardRef, type CSSProperties, type HTMLAttributes } from 'react'
|
|
4
|
+
import { mergeProps } from '../utils/merge-props.js'
|
|
5
|
+
import { useAsyncContext } from './context.js'
|
|
6
|
+
|
|
7
|
+
type SegmentPhase = 'past' | 'active' | 'future'
|
|
8
|
+
|
|
9
|
+
function segmentPhase(index: number, activeIndex: number): SegmentPhase {
|
|
10
|
+
if (activeIndex === -1) return 'future'
|
|
11
|
+
if (index === activeIndex) return 'active'
|
|
12
|
+
if (index < activeIndex) return 'past'
|
|
13
|
+
return 'future'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AsyncTrackProps extends HTMLAttributes<HTMLDivElement> {
|
|
17
|
+
states?: readonly string[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const AsyncTrack = forwardRef<HTMLDivElement, AsyncTrackProps>(function AsyncTrack(
|
|
21
|
+
{ states = ASYNC_LIFECYCLE_STATES, className, ...rest },
|
|
22
|
+
ref,
|
|
23
|
+
) {
|
|
24
|
+
const { status } = useAsyncContext()
|
|
25
|
+
const activeIndex = states.indexOf(status)
|
|
26
|
+
const { style, ...restWithoutStyle } = rest
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
ref={ref}
|
|
31
|
+
role="list"
|
|
32
|
+
aria-label="Async lifecycle states"
|
|
33
|
+
className={className}
|
|
34
|
+
style={
|
|
35
|
+
{
|
|
36
|
+
...style,
|
|
37
|
+
['--aeon-state-track-count' as string]: states.length,
|
|
38
|
+
} as CSSProperties
|
|
39
|
+
}
|
|
40
|
+
{...mergeProps(partOnlyAttrs(asyncAnatomy.track), restWithoutStyle)}
|
|
41
|
+
>
|
|
42
|
+
{states.map((id, index) => {
|
|
43
|
+
const phase = segmentPhase(index, activeIndex)
|
|
44
|
+
return (
|
|
45
|
+
<span
|
|
46
|
+
key={id}
|
|
47
|
+
role="listitem"
|
|
48
|
+
aria-current={phase === 'active' ? 'step' : undefined}
|
|
49
|
+
title={id}
|
|
50
|
+
className={`state-track__seg state-track__seg--${id} state-track__seg--${phase}`}
|
|
51
|
+
{...partOnlyAttrs(asyncAnatomy.segment, { state: `${id} ${phase}` })}
|
|
52
|
+
>
|
|
53
|
+
{id}
|
|
54
|
+
</span>
|
|
55
|
+
)
|
|
56
|
+
})}
|
|
57
|
+
</div>
|
|
58
|
+
)
|
|
59
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { Avatar } from './index.js'
|
|
4
|
+
|
|
5
|
+
describe('Avatar', () => {
|
|
6
|
+
it('shows fallback until image loads', () => {
|
|
7
|
+
render(
|
|
8
|
+
<Avatar.Root>
|
|
9
|
+
<Avatar.Image src="/photo.jpg" alt="User" />
|
|
10
|
+
<Avatar.Fallback>AB</Avatar.Fallback>
|
|
11
|
+
</Avatar.Root>,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
expect(screen.getByText('AB')).toBeVisible()
|
|
15
|
+
expect(document.querySelector('[data-aeon-part="image"]')).toHaveAttribute('hidden')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('shows fallback when there is no src', () => {
|
|
19
|
+
render(
|
|
20
|
+
<Avatar.Root>
|
|
21
|
+
<Avatar.Fallback>?</Avatar.Fallback>
|
|
22
|
+
</Avatar.Root>,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
expect(screen.getByText('?')).toBeVisible()
|
|
26
|
+
})
|
|
27
|
+
})
|