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,54 @@
|
|
|
1
|
+
# @aeon-ui/primitives
|
|
2
|
+
|
|
3
|
+
**XState v5 machines** — behavior only, no DOM.
|
|
4
|
+
|
|
5
|
+
Agents: [docs/MACHINES.md](../../docs/MACHINES.md) lists every machine and events.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @aeon-ui/primitives
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Pair with `@aeon-ui/react` (`useAeonMachine`) or your own XState bindings.
|
|
14
|
+
|
|
15
|
+
## Exported machines
|
|
16
|
+
|
|
17
|
+
| Export | File | Use |
|
|
18
|
+
|--------|------|-----|
|
|
19
|
+
| `toggleMachine` | `machines/toggle.ts` | Switch, Checkbox |
|
|
20
|
+
| `dialogMachine` | `machines/dialog.ts` | Dialog |
|
|
21
|
+
| `tabsMachine` | `machines/tabs.ts` | Tabs |
|
|
22
|
+
| `accordionMachine` | `machines/accordion.ts` | Accordion |
|
|
23
|
+
| `createAsyncMachine` | `machines/async.ts` | Async regions |
|
|
24
|
+
| `asyncMachine` | default instance | |
|
|
25
|
+
| `buttonLifecycleMachine` | `machines/button.ts` | App/demo — not wired inside headless Button |
|
|
26
|
+
| `fieldMachine` | `machines/field.ts` | Field (parallel) |
|
|
27
|
+
| `popoverMachine` | `machines/popover.ts` | Menu, Popover, Select |
|
|
28
|
+
| `toastMachine` | `machines/toast.ts` | Toast item |
|
|
29
|
+
|
|
30
|
+
## Helpers
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { ASYNC_LIFECYCLE_STATES, isEmptyAsyncData, createAsyncMachine } from '@aeon-ui/primitives'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Async example
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const machine = createAsyncMachine<User[]>()
|
|
40
|
+
// send: FETCH | RESOLVE | REJECT | RESET | STALE | REFRESH
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Extend
|
|
44
|
+
|
|
45
|
+
1. Add `src/machines/<name>.ts`
|
|
46
|
+
2. Export from `src/index.ts`
|
|
47
|
+
3. Wire in `@aeon-ui/react`
|
|
48
|
+
4. Update `apps/demo/src/aeonDiagrams.ts`
|
|
49
|
+
5. [docs/COMPONENT_CHECKLIST.md](../../docs/COMPONENT_CHECKLIST.md)
|
|
50
|
+
|
|
51
|
+
## Related
|
|
52
|
+
|
|
53
|
+
- [STATES.md](../../STATES.md)
|
|
54
|
+
- [packages/react/README.md](../react/README.md)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aeon-ui/primitives",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "XState machines for Aeon UI primitives",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/GenericCPU/aeon-ui.git",
|
|
9
|
+
"directory": "packages/primitives"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": { "access": "public" },
|
|
12
|
+
"files": ["dist", "README.md"],
|
|
13
|
+
"keywords": ["aeon-ui", "xstate", "statechart", "machines"],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./machines/*": {
|
|
23
|
+
"types": "./dist/machines/*.d.ts",
|
|
24
|
+
"import": "./dist/machines/*.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup src/index.ts src/machines/*.ts --format esm --dts --clean",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"test": "vitest run"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@aeon-ui/core": "workspace:*",
|
|
34
|
+
"xstate": "^5.19.2"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"tsup": "^8.4.0",
|
|
38
|
+
"typescript": "^5.8.3",
|
|
39
|
+
"vitest": "^3.2.4"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createActor } from 'xstate'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { dialogMachine } from '../machines/dialog.js'
|
|
4
|
+
import { popoverMachine } from '../machines/popover.js'
|
|
5
|
+
|
|
6
|
+
const machines = [
|
|
7
|
+
{ name: 'popoverMachine', machine: popoverMachine, input: { open: false } },
|
|
8
|
+
{ name: 'dialogMachine', machine: dialogMachine, input: { open: false } },
|
|
9
|
+
] as const
|
|
10
|
+
|
|
11
|
+
describe.each(machines)('$name', ({ machine, input }) => {
|
|
12
|
+
it('opens on TOGGLE and closes on outside pointer', () => {
|
|
13
|
+
const actor = createActor(machine, { input })
|
|
14
|
+
actor.start()
|
|
15
|
+
actor.send({ type: 'TOGGLE' })
|
|
16
|
+
expect(actor.getSnapshot().matches('open')).toBe(true)
|
|
17
|
+
actor.send({ type: 'POINTER_DOWN_OUTSIDE' })
|
|
18
|
+
expect(actor.getSnapshot().matches('closed')).toBe(true)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('respects controlled SET_OPEN', () => {
|
|
22
|
+
const actor = createActor(machine, { input })
|
|
23
|
+
actor.start()
|
|
24
|
+
actor.send({ type: 'SET_OPEN', open: true })
|
|
25
|
+
expect(actor.getSnapshot().matches('open')).toBe(true)
|
|
26
|
+
actor.send({ type: 'SET_OPEN', open: false })
|
|
27
|
+
expect(actor.getSnapshot().matches('closed')).toBe(true)
|
|
28
|
+
})
|
|
29
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './machines/toggle.js'
|
|
2
|
+
export * from './machines/dialog.js'
|
|
3
|
+
export * from './machines/tabs.js'
|
|
4
|
+
export * from './machines/accordion.js'
|
|
5
|
+
export * from './machines/async.js'
|
|
6
|
+
export * from './machines/button.js'
|
|
7
|
+
export * from './machines/field.js'
|
|
8
|
+
export * from './machines/popover.js'
|
|
9
|
+
export * from './machines/toast.js'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { assign, setup } from 'xstate'
|
|
2
|
+
|
|
3
|
+
export interface AccordionContext {
|
|
4
|
+
value: string[]
|
|
5
|
+
multiple: boolean
|
|
6
|
+
collapsible: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type AccordionEvent =
|
|
10
|
+
| { type: 'TOGGLE'; item: string }
|
|
11
|
+
| { type: 'SET_VALUE'; value: string[] }
|
|
12
|
+
|
|
13
|
+
function toggleItem(items: string[], item: string, multiple: boolean, collapsible: boolean) {
|
|
14
|
+
const isOpen = items.includes(item)
|
|
15
|
+
if (!multiple) {
|
|
16
|
+
if (isOpen) return collapsible ? [] : items
|
|
17
|
+
return [item]
|
|
18
|
+
}
|
|
19
|
+
if (isOpen) return items.filter((i) => i !== item)
|
|
20
|
+
return [...items, item]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const accordionMachine = setup({
|
|
24
|
+
types: {
|
|
25
|
+
context: {} as AccordionContext,
|
|
26
|
+
events: {} as AccordionEvent,
|
|
27
|
+
input: {} as AccordionContext,
|
|
28
|
+
},
|
|
29
|
+
actions: {
|
|
30
|
+
toggle: assign({
|
|
31
|
+
value: ({ context, event }) =>
|
|
32
|
+
event.type === 'TOGGLE'
|
|
33
|
+
? toggleItem(context.value, event.item, context.multiple, context.collapsible)
|
|
34
|
+
: context.value,
|
|
35
|
+
}),
|
|
36
|
+
setValue: assign({
|
|
37
|
+
value: ({ event }) => (event.type === 'SET_VALUE' ? event.value : []),
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
}).createMachine({
|
|
41
|
+
id: 'accordion',
|
|
42
|
+
context: ({ input }) => ({
|
|
43
|
+
value: input.value ?? [],
|
|
44
|
+
multiple: input.multiple ?? false,
|
|
45
|
+
collapsible: input.collapsible ?? true,
|
|
46
|
+
}),
|
|
47
|
+
initial: 'managing',
|
|
48
|
+
states: {
|
|
49
|
+
managing: {
|
|
50
|
+
on: {
|
|
51
|
+
TOGGLE: { actions: 'toggle' },
|
|
52
|
+
SET_VALUE: { actions: 'setValue' },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
})
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { assign, setup } from 'xstate'
|
|
2
|
+
|
|
3
|
+
/** Stable lifecycle states for async data regions (see STATES.md). */
|
|
4
|
+
export const ASYNC_LIFECYCLE_STATES = [
|
|
5
|
+
'idle',
|
|
6
|
+
'loading',
|
|
7
|
+
'success',
|
|
8
|
+
'failure',
|
|
9
|
+
'empty',
|
|
10
|
+
] as const
|
|
11
|
+
|
|
12
|
+
export type AsyncLifecycleState = (typeof ASYNC_LIFECYCLE_STATES)[number]
|
|
13
|
+
|
|
14
|
+
export function isEmptyAsyncData(data: unknown): boolean {
|
|
15
|
+
if (data == null) return true
|
|
16
|
+
if (typeof data === 'string') return data.length === 0
|
|
17
|
+
if (Array.isArray(data)) return data.length === 0
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Thesis §2.1: fetch lifecycle as sequential, well-defined states.
|
|
23
|
+
* This machine models fetch lifecycle as mutually exclusive states.
|
|
24
|
+
*/
|
|
25
|
+
export interface AsyncContext<T = unknown> {
|
|
26
|
+
data: T | null
|
|
27
|
+
error: string | null
|
|
28
|
+
/** Success with background refresh — style readout as `success stale` (see STATES.md). */
|
|
29
|
+
stale?: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type AsyncEvent<T = unknown> =
|
|
33
|
+
| { type: 'FETCH' }
|
|
34
|
+
| { type: 'RESOLVE'; data: T }
|
|
35
|
+
| { type: 'REJECT'; error: string }
|
|
36
|
+
| { type: 'RESET' }
|
|
37
|
+
| { type: 'STALE' }
|
|
38
|
+
| { type: 'REFRESH' }
|
|
39
|
+
|
|
40
|
+
export function createAsyncMachine<T = unknown>() {
|
|
41
|
+
return setup({
|
|
42
|
+
types: {
|
|
43
|
+
context: {} as AsyncContext<T>,
|
|
44
|
+
events: {} as AsyncEvent<T>,
|
|
45
|
+
},
|
|
46
|
+
actions: {
|
|
47
|
+
clear: assign({ data: null, error: null }),
|
|
48
|
+
resolve: assign({
|
|
49
|
+
data: ({ event }) => (event.type === 'RESOLVE' ? event.data : null),
|
|
50
|
+
error: null,
|
|
51
|
+
stale: false,
|
|
52
|
+
}),
|
|
53
|
+
markStale: assign({ stale: true }),
|
|
54
|
+
clearStale: assign({ stale: false }),
|
|
55
|
+
reject: assign({
|
|
56
|
+
error: ({ event }) => (event.type === 'REJECT' ? event.error : null),
|
|
57
|
+
data: null,
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
}).createMachine({
|
|
61
|
+
id: 'async',
|
|
62
|
+
context: { data: null, error: null },
|
|
63
|
+
initial: 'idle',
|
|
64
|
+
states: {
|
|
65
|
+
idle: {
|
|
66
|
+
on: {
|
|
67
|
+
FETCH: 'loading',
|
|
68
|
+
RESET: { actions: 'clear' },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
loading: {
|
|
72
|
+
on: {
|
|
73
|
+
RESOLVE: [
|
|
74
|
+
{
|
|
75
|
+
target: 'empty',
|
|
76
|
+
actions: 'resolve',
|
|
77
|
+
guard: ({ event }) => event.type === 'RESOLVE' && isEmptyAsyncData(event.data),
|
|
78
|
+
},
|
|
79
|
+
{ target: 'success', actions: 'resolve' },
|
|
80
|
+
],
|
|
81
|
+
REJECT: { target: 'failure', actions: 'reject' },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
empty: {
|
|
85
|
+
on: {
|
|
86
|
+
FETCH: 'loading',
|
|
87
|
+
RESET: { target: 'idle', actions: 'clear' },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
success: {
|
|
91
|
+
on: {
|
|
92
|
+
FETCH: { target: 'loading', actions: 'clearStale' },
|
|
93
|
+
STALE: { actions: 'markStale' },
|
|
94
|
+
REFRESH: { actions: 'clearStale' },
|
|
95
|
+
RESET: { target: 'idle', actions: 'clear' },
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
failure: {
|
|
99
|
+
on: {
|
|
100
|
+
FETCH: 'loading',
|
|
101
|
+
RESET: { target: 'idle', actions: 'clear' },
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const asyncMachine = createAsyncMachine()
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { setup } from 'xstate'
|
|
2
|
+
|
|
3
|
+
export const BUTTON_LIFECYCLE_STATES = [
|
|
4
|
+
'idle',
|
|
5
|
+
'pending',
|
|
6
|
+
'success',
|
|
7
|
+
'failure',
|
|
8
|
+
'disabled',
|
|
9
|
+
] as const
|
|
10
|
+
|
|
11
|
+
export type ButtonLifecycleState = (typeof BUTTON_LIFECYCLE_STATES)[number]
|
|
12
|
+
|
|
13
|
+
export type ButtonLifecycleEvent =
|
|
14
|
+
| { type: 'PRESS' }
|
|
15
|
+
| { type: 'SUCCEED' }
|
|
16
|
+
| { type: 'FAIL' }
|
|
17
|
+
| { type: 'RESET' }
|
|
18
|
+
| { type: 'DISABLE' }
|
|
19
|
+
| { type: 'ENABLE' }
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Submit / action button lifecycle — idle → pending → success | failure.
|
|
23
|
+
* Use for controls that represent an in-flight operation, not mere `disabled`.
|
|
24
|
+
*/
|
|
25
|
+
export const buttonLifecycleMachine = setup({
|
|
26
|
+
types: {
|
|
27
|
+
events: {} as ButtonLifecycleEvent,
|
|
28
|
+
},
|
|
29
|
+
}).createMachine({
|
|
30
|
+
id: 'buttonLifecycle',
|
|
31
|
+
initial: 'idle',
|
|
32
|
+
states: {
|
|
33
|
+
idle: {
|
|
34
|
+
on: {
|
|
35
|
+
PRESS: 'pending',
|
|
36
|
+
DISABLE: 'disabled',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
pending: {
|
|
40
|
+
on: {
|
|
41
|
+
SUCCEED: 'success',
|
|
42
|
+
FAIL: 'failure',
|
|
43
|
+
DISABLE: 'disabled',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
success: {
|
|
47
|
+
on: {
|
|
48
|
+
RESET: 'idle',
|
|
49
|
+
PRESS: 'pending',
|
|
50
|
+
DISABLE: 'disabled',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
failure: {
|
|
54
|
+
on: {
|
|
55
|
+
RESET: 'idle',
|
|
56
|
+
PRESS: 'pending',
|
|
57
|
+
DISABLE: 'disabled',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
disabled: {
|
|
61
|
+
on: {
|
|
62
|
+
ENABLE: 'idle',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
})
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { assign, setup } from 'xstate'
|
|
2
|
+
|
|
3
|
+
export interface DialogContext {
|
|
4
|
+
open: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type DialogEvent =
|
|
8
|
+
| { type: 'OPEN' }
|
|
9
|
+
| { type: 'CLOSE' }
|
|
10
|
+
| { type: 'TOGGLE' }
|
|
11
|
+
| { type: 'SET_OPEN'; open: boolean }
|
|
12
|
+
| { type: 'ESCAPE' }
|
|
13
|
+
| { type: 'POINTER_DOWN_OUTSIDE' }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Dialog visibility is a single orthogonal region: closed | open.
|
|
17
|
+
* Open and closed are distinct, stable states.
|
|
18
|
+
*/
|
|
19
|
+
export const dialogMachine = setup({
|
|
20
|
+
types: {
|
|
21
|
+
context: {} as DialogContext,
|
|
22
|
+
events: {} as DialogEvent,
|
|
23
|
+
input: {} as DialogContext,
|
|
24
|
+
},
|
|
25
|
+
actions: {
|
|
26
|
+
markOpen: assign({ open: true }),
|
|
27
|
+
markClosed: assign({ open: false }),
|
|
28
|
+
toggleOpen: assign({ open: ({ context }) => !context.open }),
|
|
29
|
+
setOpen: assign({
|
|
30
|
+
open: ({ event }) => (event.type === 'SET_OPEN' ? event.open : false),
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
}).createMachine({
|
|
34
|
+
id: 'dialog',
|
|
35
|
+
context: ({ input }) => ({
|
|
36
|
+
open: input.open ?? false,
|
|
37
|
+
}),
|
|
38
|
+
initial: 'closed',
|
|
39
|
+
states: {
|
|
40
|
+
closed: {
|
|
41
|
+
on: {
|
|
42
|
+
OPEN: { target: 'open', actions: 'markOpen' },
|
|
43
|
+
TOGGLE: { target: 'open', actions: 'markOpen' },
|
|
44
|
+
SET_OPEN: [
|
|
45
|
+
{ target: 'open', actions: 'markOpen', guard: ({ event }) => event.open },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
open: {
|
|
50
|
+
on: {
|
|
51
|
+
CLOSE: { target: 'closed', actions: 'markClosed' },
|
|
52
|
+
ESCAPE: { target: 'closed', actions: 'markClosed' },
|
|
53
|
+
POINTER_DOWN_OUTSIDE: { target: 'closed', actions: 'markClosed' },
|
|
54
|
+
TOGGLE: { target: 'closed', actions: 'markClosed' },
|
|
55
|
+
SET_OPEN: [
|
|
56
|
+
{ target: 'closed', actions: 'markClosed', guard: ({ event }) => !event.open },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
})
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { setup } from 'xstate'
|
|
2
|
+
|
|
3
|
+
export const FIELD_INTERACTION_STATES = ['pristine', 'dirty'] as const
|
|
4
|
+
export const FIELD_VALIDATION_STATES = ['valid', 'invalid'] as const
|
|
5
|
+
export const FIELD_SUBMISSION_STATES = ['idle', 'pending'] as const
|
|
6
|
+
|
|
7
|
+
export type FieldInteractionState = (typeof FIELD_INTERACTION_STATES)[number]
|
|
8
|
+
export type FieldValidationState = (typeof FIELD_VALIDATION_STATES)[number]
|
|
9
|
+
export type FieldSubmissionState = (typeof FIELD_SUBMISSION_STATES)[number]
|
|
10
|
+
|
|
11
|
+
export type FieldEvent =
|
|
12
|
+
| { type: 'INPUT' }
|
|
13
|
+
| { type: 'BLUR' }
|
|
14
|
+
| { type: 'VALIDATE'; valid: boolean }
|
|
15
|
+
| { type: 'SUBMIT' }
|
|
16
|
+
| { type: 'SUBMIT_DONE' }
|
|
17
|
+
| { type: 'SUBMIT_FAIL' }
|
|
18
|
+
| { type: 'RESET' }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Orthogonal field regions — interaction, validation, and submission evolve independently.
|
|
22
|
+
* Snapshot value is nested; flatten with `stateToAttr` for `data-aeon-state`.
|
|
23
|
+
*/
|
|
24
|
+
export const fieldMachine = setup({
|
|
25
|
+
types: {
|
|
26
|
+
events: {} as FieldEvent,
|
|
27
|
+
},
|
|
28
|
+
}).createMachine({
|
|
29
|
+
id: 'field',
|
|
30
|
+
type: 'parallel',
|
|
31
|
+
states: {
|
|
32
|
+
interaction: {
|
|
33
|
+
initial: 'pristine',
|
|
34
|
+
states: {
|
|
35
|
+
pristine: {
|
|
36
|
+
on: {
|
|
37
|
+
INPUT: 'dirty',
|
|
38
|
+
BLUR: 'dirty',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
dirty: {
|
|
42
|
+
on: {
|
|
43
|
+
RESET: 'pristine',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
validation: {
|
|
49
|
+
initial: 'valid',
|
|
50
|
+
states: {
|
|
51
|
+
valid: {
|
|
52
|
+
on: {
|
|
53
|
+
VALIDATE: [
|
|
54
|
+
{ target: 'invalid', guard: ({ event }) => event.type === 'VALIDATE' && !event.valid },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
invalid: {
|
|
59
|
+
on: {
|
|
60
|
+
VALIDATE: [
|
|
61
|
+
{ target: 'valid', guard: ({ event }) => event.type === 'VALIDATE' && event.valid },
|
|
62
|
+
],
|
|
63
|
+
RESET: 'valid',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
submission: {
|
|
69
|
+
initial: 'idle',
|
|
70
|
+
states: {
|
|
71
|
+
idle: {
|
|
72
|
+
on: {
|
|
73
|
+
SUBMIT: 'pending',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
pending: {
|
|
77
|
+
on: {
|
|
78
|
+
SUBMIT_DONE: 'idle',
|
|
79
|
+
SUBMIT_FAIL: 'idle',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
})
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { assign, setup } from 'xstate'
|
|
2
|
+
|
|
3
|
+
export interface PopoverContext {
|
|
4
|
+
open: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type PopoverEvent =
|
|
8
|
+
| { type: 'OPEN' }
|
|
9
|
+
| { type: 'CLOSE' }
|
|
10
|
+
| { type: 'TOGGLE' }
|
|
11
|
+
| { type: 'SET_OPEN'; open: boolean }
|
|
12
|
+
| { type: 'ESCAPE' }
|
|
13
|
+
| { type: 'POINTER_DOWN_OUTSIDE' }
|
|
14
|
+
|
|
15
|
+
/** Floating surface: menu, popover, select listbox — closed | open. */
|
|
16
|
+
export const popoverMachine = setup({
|
|
17
|
+
types: {
|
|
18
|
+
context: {} as PopoverContext,
|
|
19
|
+
events: {} as PopoverEvent,
|
|
20
|
+
input: {} as PopoverContext,
|
|
21
|
+
},
|
|
22
|
+
actions: {
|
|
23
|
+
markOpen: assign({ open: true }),
|
|
24
|
+
markClosed: assign({ open: false }),
|
|
25
|
+
toggleOpen: assign({ open: ({ context }) => !context.open }),
|
|
26
|
+
setOpen: assign({
|
|
27
|
+
open: ({ event }) => (event.type === 'SET_OPEN' ? event.open : false),
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
}).createMachine({
|
|
31
|
+
id: 'popover',
|
|
32
|
+
context: ({ input }) => ({ open: input.open ?? false }),
|
|
33
|
+
initial: 'closed',
|
|
34
|
+
states: {
|
|
35
|
+
closed: {
|
|
36
|
+
on: {
|
|
37
|
+
OPEN: { target: 'open', actions: 'markOpen' },
|
|
38
|
+
TOGGLE: { target: 'open', actions: 'markOpen' },
|
|
39
|
+
SET_OPEN: [{ target: 'open', actions: 'markOpen', guard: ({ event }) => event.open }],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
open: {
|
|
43
|
+
on: {
|
|
44
|
+
CLOSE: { target: 'closed', actions: 'markClosed' },
|
|
45
|
+
ESCAPE: { target: 'closed', actions: 'markClosed' },
|
|
46
|
+
POINTER_DOWN_OUTSIDE: { target: 'closed', actions: 'markClosed' },
|
|
47
|
+
TOGGLE: { target: 'closed', actions: 'markClosed' },
|
|
48
|
+
SET_OPEN: [{ target: 'closed', actions: 'markClosed', guard: ({ event }) => !event.open }],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { assign, setup } from 'xstate'
|
|
2
|
+
|
|
3
|
+
export interface TabsContext {
|
|
4
|
+
value: string
|
|
5
|
+
disabled: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type TabsEvent =
|
|
9
|
+
| { type: 'SELECT'; value: string }
|
|
10
|
+
| { type: 'SET_VALUE'; value: string }
|
|
11
|
+
|
|
12
|
+
export const tabsMachine = setup({
|
|
13
|
+
types: {
|
|
14
|
+
context: {} as TabsContext,
|
|
15
|
+
events: {} as TabsEvent,
|
|
16
|
+
input: {} as TabsContext,
|
|
17
|
+
},
|
|
18
|
+
guards: {
|
|
19
|
+
notDisabled: ({ context }) => !context.disabled,
|
|
20
|
+
hasValue: ({ event }) => event.type === 'SELECT' && Boolean(event.value),
|
|
21
|
+
},
|
|
22
|
+
actions: {
|
|
23
|
+
select: assign({
|
|
24
|
+
value: ({ event }) => (event.type === 'SELECT' ? event.value : ''),
|
|
25
|
+
}),
|
|
26
|
+
setValue: assign({
|
|
27
|
+
value: ({ event }) => (event.type === 'SET_VALUE' ? event.value : ''),
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
}).createMachine({
|
|
31
|
+
id: 'tabs',
|
|
32
|
+
context: ({ input }) => ({
|
|
33
|
+
value: input.value ?? '',
|
|
34
|
+
disabled: input.disabled ?? false,
|
|
35
|
+
}),
|
|
36
|
+
/** Single stable region: which trigger is active. */
|
|
37
|
+
initial: 'active',
|
|
38
|
+
states: {
|
|
39
|
+
active: {
|
|
40
|
+
on: {
|
|
41
|
+
SELECT: { actions: 'select', guard: 'hasValue' },
|
|
42
|
+
SET_VALUE: { actions: 'setValue' },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { setup } from 'xstate'
|
|
2
|
+
|
|
3
|
+
export interface ToastContext {
|
|
4
|
+
durationMs: number
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type ToastEvent =
|
|
8
|
+
| { type: 'SHOW' }
|
|
9
|
+
| { type: 'DISMISS' }
|
|
10
|
+
| { type: 'TIMEOUT' }
|
|
11
|
+
|
|
12
|
+
/** Toast lifecycle: hidden → visible → hidden (dismiss or auto timeout). */
|
|
13
|
+
export const toastMachine = setup({
|
|
14
|
+
types: {
|
|
15
|
+
context: {} as ToastContext,
|
|
16
|
+
events: {} as ToastEvent,
|
|
17
|
+
input: {} as ToastContext,
|
|
18
|
+
},
|
|
19
|
+
guards: {
|
|
20
|
+
hasDuration: ({ context }) => context.durationMs > 0,
|
|
21
|
+
},
|
|
22
|
+
delays: {
|
|
23
|
+
VISIBLE_TIMEOUT: ({ context }) => context.durationMs,
|
|
24
|
+
},
|
|
25
|
+
}).createMachine({
|
|
26
|
+
id: 'toast',
|
|
27
|
+
context: ({ input }) => ({ durationMs: input.durationMs ?? 5000 }),
|
|
28
|
+
initial: 'hidden',
|
|
29
|
+
states: {
|
|
30
|
+
hidden: {
|
|
31
|
+
on: {
|
|
32
|
+
SHOW: 'visible',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
visible: {
|
|
36
|
+
on: {
|
|
37
|
+
DISMISS: 'hidden',
|
|
38
|
+
TIMEOUT: 'hidden',
|
|
39
|
+
},
|
|
40
|
+
after: {
|
|
41
|
+
VISIBLE_TIMEOUT: {
|
|
42
|
+
target: 'hidden',
|
|
43
|
+
guard: 'hasDuration',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
})
|