@raydenui/ui 0.9.6 → 0.10.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/dist/Table-DCNSxua1.d.cts +31 -0
- package/dist/Table-DCNSxua1.d.ts +31 -0
- package/dist/blocks/ApplicationShellBlock.cjs +157 -0
- package/dist/blocks/ApplicationShellBlock.js +154 -0
- package/dist/blocks/CheckoutReviewBlock.cjs +16 -0
- package/dist/blocks/CheckoutReviewBlock.js +13 -0
- package/dist/blocks/CommandPaletteBlock.cjs +334 -0
- package/dist/blocks/CommandPaletteBlock.js +331 -0
- package/dist/blocks/CreateAccountBlock.cjs +147 -0
- package/dist/blocks/CreateAccountBlock.js +143 -0
- package/dist/blocks/EmptyStateBlock.cjs +19 -0
- package/dist/blocks/EmptyStateBlock.js +16 -0
- package/dist/blocks/FeatureOverviewBlock.cjs +54 -0
- package/dist/blocks/FeatureOverviewBlock.js +51 -0
- package/dist/blocks/HeaderBlock.cjs +230 -0
- package/dist/blocks/HeaderBlock.js +227 -0
- package/dist/blocks/KpiOverviewBlock.cjs +63 -0
- package/dist/blocks/KpiOverviewBlock.js +60 -0
- package/dist/blocks/LoginBlock.cjs +66 -0
- package/dist/blocks/LoginBlock.js +63 -0
- package/dist/blocks/NotificationsBlock.cjs +17 -0
- package/dist/blocks/NotificationsBlock.js +14 -0
- package/dist/blocks/PageHeaderBlock.cjs +121 -0
- package/dist/blocks/PageHeaderBlock.js +118 -0
- package/dist/blocks/PricingPlansBlock.cjs +146 -0
- package/dist/blocks/PricingPlansBlock.js +143 -0
- package/dist/blocks/ProductCollectionBlock.cjs +37 -0
- package/dist/blocks/ProductCollectionBlock.js +34 -0
- package/dist/blocks/ProductDetailBlock.cjs +30 -0
- package/dist/blocks/ProductDetailBlock.js +27 -0
- package/dist/blocks/ProductHeroBlock.cjs +83 -0
- package/dist/blocks/ProductHeroBlock.js +80 -0
- package/dist/blocks/ProfileSettingsBlock.cjs +130 -0
- package/dist/blocks/ProfileSettingsBlock.js +126 -0
- package/dist/blocks/QuickSendBlock.cjs +11 -0
- package/dist/blocks/QuickSendBlock.js +8 -0
- package/dist/blocks/RecentTransactionsBlock.cjs +13 -0
- package/dist/blocks/RecentTransactionsBlock.js +10 -0
- package/dist/blocks/SearchableTableBlock.cjs +91 -0
- package/dist/blocks/SearchableTableBlock.js +88 -0
- package/dist/blocks/ShoppingCartBlock.cjs +16 -0
- package/dist/blocks/ShoppingCartBlock.js +13 -0
- package/dist/blocks/SiteFooterBlock.cjs +69 -0
- package/dist/blocks/SiteFooterBlock.js +66 -0
- package/dist/blocks/TableBlock.cjs +20 -0
- package/dist/blocks/TableBlock.js +17 -0
- package/dist/blocks/TaskListBlock.cjs +198 -0
- package/dist/blocks/TaskListBlock.js +195 -0
- package/dist/blocks/WorkspaceSwitcherBlock.cjs +291 -0
- package/dist/blocks/WorkspaceSwitcherBlock.js +288 -0
- package/dist/blocks/commerce.cjs +44 -0
- package/dist/blocks/commerce.js +35 -0
- package/dist/blocks/index.cjs +53 -0
- package/dist/blocks/index.js +24 -0
- package/dist/blocks.d.cts +1820 -0
- package/dist/blocks.d.ts +1820 -0
- package/dist/chart.cjs +13 -0
- package/dist/chart.d.cts +59 -0
- package/dist/chart.d.ts +59 -0
- package/dist/chart.js +5 -0
- package/dist/components/Accordion/Accordion.cjs +94 -0
- package/dist/components/Accordion/Accordion.js +91 -0
- package/dist/components/Accordion/index.cjs +8 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/ActivityFeed/ActivityContent.cjs +40 -0
- package/dist/components/ActivityFeed/ActivityContent.js +37 -0
- package/dist/components/ActivityFeed/ActivityItem.cjs +19 -0
- package/dist/components/ActivityFeed/ActivityItem.js +16 -0
- package/dist/components/ActivityFeed/index.cjs +7 -0
- package/dist/components/ActivityFeed/index.js +2 -0
- package/dist/components/Alert/Alert.cjs +42 -0
- package/dist/components/Alert/Alert.js +39 -0
- package/dist/components/Alert/index.cjs +5 -0
- package/dist/components/Alert/index.js +1 -0
- package/dist/components/Avatar/Avatar.cjs +101 -0
- package/dist/components/Avatar/Avatar.js +98 -0
- package/dist/components/Avatar/index.cjs +6 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/Badge/Badge.cjs +53 -0
- package/dist/components/Badge/Badge.js +50 -0
- package/dist/components/Badge/index.cjs +5 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Banner/Banner.cjs +83 -0
- package/dist/components/Banner/Banner.js +80 -0
- package/dist/components/Banner/index.cjs +5 -0
- package/dist/components/Banner/index.js +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.cjs +31 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +28 -0
- package/dist/components/Breadcrumb/index.cjs +5 -0
- package/dist/components/Breadcrumb/index.js +1 -0
- package/dist/components/Button/Button.cjs +88 -0
- package/dist/components/Button/Button.js +85 -0
- package/dist/components/Button/index.cjs +5 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.cjs +8 -0
- package/dist/components/ButtonGroup/ButtonGroup.js +5 -0
- package/dist/components/ButtonGroup/ButtonGroupItem.cjs +15 -0
- package/dist/components/ButtonGroup/ButtonGroupItem.js +12 -0
- package/dist/components/ButtonGroup/index.cjs +7 -0
- package/dist/components/ButtonGroup/index.js +2 -0
- package/dist/components/Card/Card.cjs +94 -0
- package/dist/components/Card/Card.js +91 -0
- package/dist/components/Card/index.cjs +9 -0
- package/dist/components/Card/index.js +1 -0
- package/dist/components/Chart/Chart.cjs +160 -0
- package/dist/components/Chart/Chart.js +153 -0
- package/dist/components/Chart/index.cjs +10 -0
- package/dist/components/Chart/index.js +2 -0
- package/dist/components/Chart/theme.cjs +67 -0
- package/dist/components/Chart/theme.js +62 -0
- package/dist/components/Chip/Chip.cjs +18 -0
- package/dist/components/Chip/Chip.js +15 -0
- package/dist/components/Chip/index.cjs +5 -0
- package/dist/components/Chip/index.js +1 -0
- package/dist/components/Counter/Counter.cjs +74 -0
- package/dist/components/Counter/Counter.js +71 -0
- package/dist/components/Counter/index.cjs +6 -0
- package/dist/components/Counter/index.js +1 -0
- package/dist/components/DatePicker/DatePicker.cjs +343 -0
- package/dist/components/DatePicker/DatePicker.js +340 -0
- package/dist/components/DatePicker/index.cjs +5 -0
- package/dist/components/DatePicker/index.js +1 -0
- package/dist/components/Divider/Divider.cjs +31 -0
- package/dist/components/Divider/Divider.js +28 -0
- package/dist/components/Divider/index.cjs +5 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.cjs +108 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +105 -0
- package/dist/components/DropdownMenu/index.cjs +11 -0
- package/dist/components/DropdownMenu/index.js +1 -0
- package/dist/components/EmptyStateIllustration/EmptyStateIllustration.cjs +42 -0
- package/dist/components/EmptyStateIllustration/EmptyStateIllustration.js +39 -0
- package/dist/components/EmptyStateIllustration/illustrations.cjs +3322 -0
- package/dist/components/EmptyStateIllustration/illustrations.js +3319 -0
- package/dist/components/EmptyStateIllustration/index.cjs +7 -0
- package/dist/components/EmptyStateIllustration/index.js +2 -0
- package/dist/components/FileUpload/FileUpload.cjs +116 -0
- package/dist/components/FileUpload/FileUpload.js +113 -0
- package/dist/components/FileUpload/FileUploadDropZone.cjs +58 -0
- package/dist/components/FileUpload/FileUploadDropZone.js +55 -0
- package/dist/components/FileUpload/FileUploadIcons.cjs +55 -0
- package/dist/components/FileUpload/FileUploadIcons.js +50 -0
- package/dist/components/FileUpload/FileUploadItem.cjs +34 -0
- package/dist/components/FileUpload/FileUploadItem.js +31 -0
- package/dist/components/FileUpload/index.cjs +9 -0
- package/dist/components/FileUpload/index.js +3 -0
- package/dist/components/FormControl/Checkbox.cjs +27 -0
- package/dist/components/FormControl/Checkbox.js +24 -0
- package/dist/components/FormControl/Radio.cjs +15 -0
- package/dist/components/FormControl/Radio.js +12 -0
- package/dist/components/FormControl/Toggle.cjs +15 -0
- package/dist/components/FormControl/Toggle.js +12 -0
- package/dist/components/FormControl/index.cjs +9 -0
- package/dist/components/FormControl/index.js +3 -0
- package/dist/components/Icon/Icon.cjs +70 -0
- package/dist/components/Icon/Icon.js +34 -0
- package/dist/components/Icon/catalog.cjs +1672 -0
- package/dist/components/Icon/catalog.js +1669 -0
- package/dist/components/Icon/icons.cjs +5621 -0
- package/dist/components/Icon/icons.js +5610 -0
- package/dist/components/Icon/index.cjs +8 -0
- package/dist/components/Icon/index.js +2 -0
- package/dist/components/Input/Input.cjs +64 -0
- package/dist/components/Input/Input.js +61 -0
- package/dist/components/Input/index.cjs +5 -0
- package/dist/components/Input/index.js +1 -0
- package/dist/components/MetricsCard/MetricsCard.cjs +107 -0
- package/dist/components/MetricsCard/MetricsCard.js +104 -0
- package/dist/components/MetricsCard/index.cjs +5 -0
- package/dist/components/MetricsCard/index.js +1 -0
- package/dist/components/Modal/Modal.cjs +126 -0
- package/dist/components/Modal/Modal.js +123 -0
- package/dist/components/Modal/index.cjs +5 -0
- package/dist/components/Modal/index.js +1 -0
- package/dist/components/Pagination/Pagination.cjs +42 -0
- package/dist/components/Pagination/Pagination.js +39 -0
- package/dist/components/Pagination/index.cjs +5 -0
- package/dist/components/Pagination/index.js +1 -0
- package/dist/components/ProgressBar/ProgressBar.cjs +34 -0
- package/dist/components/ProgressBar/ProgressBar.js +31 -0
- package/dist/components/ProgressBar/index.cjs +5 -0
- package/dist/components/ProgressBar/index.js +1 -0
- package/dist/components/ProgressCircle/ProgressCircle.cjs +34 -0
- package/dist/components/ProgressCircle/ProgressCircle.js +31 -0
- package/dist/components/ProgressCircle/index.cjs +5 -0
- package/dist/components/ProgressCircle/index.js +1 -0
- package/dist/components/Select/Select.cjs +84 -0
- package/dist/components/Select/Select.js +80 -0
- package/dist/components/Select/SelectOption.cjs +26 -0
- package/dist/components/Select/SelectOption.js +23 -0
- package/dist/components/Select/index.cjs +7 -0
- package/dist/components/Select/index.js +2 -0
- package/dist/components/SidebarMenu/SidebarMenu.cjs +85 -0
- package/dist/components/SidebarMenu/SidebarMenu.js +81 -0
- package/dist/components/SidebarMenu/SidebarMenuItem.cjs +126 -0
- package/dist/components/SidebarMenu/SidebarMenuItem.js +122 -0
- package/dist/components/SidebarMenu/SidebarMenuSection.cjs +14 -0
- package/dist/components/SidebarMenu/SidebarMenuSection.js +11 -0
- package/dist/components/SidebarMenu/index.cjs +12 -0
- package/dist/components/SidebarMenu/index.js +4 -0
- package/dist/components/Slider/Slider.cjs +161 -0
- package/dist/components/Slider/Slider.js +158 -0
- package/dist/components/Slider/index.cjs +6 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Spinner/Spinner.cjs +93 -0
- package/dist/components/Spinner/Spinner.js +90 -0
- package/dist/components/Spinner/index.cjs +5 -0
- package/dist/components/Spinner/index.js +1 -0
- package/dist/components/Stepper/Stepper.cjs +82 -0
- package/dist/components/Stepper/Stepper.js +79 -0
- package/dist/components/Stepper/index.cjs +7 -0
- package/dist/components/Stepper/index.js +1 -0
- package/dist/components/Table/Table.cjs +25 -0
- package/dist/components/Table/Table.js +22 -0
- package/dist/components/Table/index.cjs +10 -0
- package/dist/components/Table/index.js +1 -0
- package/dist/components/Table/useTableSelection.cjs +60 -0
- package/dist/components/Table/useTableSelection.js +57 -0
- package/dist/components/Tabs/Tab.cjs +70 -0
- package/dist/components/Tabs/Tab.js +67 -0
- package/dist/components/Tabs/Tabs.cjs +133 -0
- package/dist/components/Tabs/Tabs.js +129 -0
- package/dist/components/Tabs/index.cjs +7 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tooltip/Tooltip.cjs +101 -0
- package/dist/components/Tooltip/Tooltip.js +98 -0
- package/dist/components/Tooltip/index.cjs +5 -0
- package/dist/components/Tooltip/index.js +1 -0
- package/dist/context/ThemeContext.cjs +97 -0
- package/dist/context/ThemeContext.js +92 -0
- package/dist/fonts/README.md +13 -0
- package/dist/fonts/hanken-grotesk-cyrillic-ext-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-cyrillic-ext-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-ext-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-ext-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-vietnamese-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-vietnamese-normal.woff2 +0 -0
- package/dist/fonts/hankengrotesk-LICENSE.txt +94 -0
- package/dist/fonts/manrope-LICENSE.txt +93 -0
- package/dist/fonts/manrope-cyrillic-ext-normal.woff2 +0 -0
- package/dist/fonts/manrope-cyrillic-normal.woff2 +0 -0
- package/dist/fonts/manrope-greek-normal.woff2 +0 -0
- package/dist/fonts/manrope-latin-ext-normal.woff2 +0 -0
- package/dist/fonts/manrope-latin-normal.woff2 +0 -0
- package/dist/fonts/manrope-vietnamese-normal.woff2 +0 -0
- package/dist/fonts.css +148 -0
- package/dist/hooks/form/index.cjs +11 -0
- package/dist/hooks/form/index.js +3 -0
- package/dist/hooks/form/useRaydenFormControl.cjs +81 -0
- package/dist/hooks/form/useRaydenFormControl.js +76 -0
- package/dist/hooks/form/useRaydenInput.cjs +38 -0
- package/dist/hooks/form/useRaydenInput.js +35 -0
- package/dist/hooks/form/useRaydenSelect.cjs +45 -0
- package/dist/hooks/form/useRaydenSelect.js +42 -0
- package/dist/hooks/index.cjs +17 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useBodyScrollLock.cjs +24 -0
- package/dist/hooks/useBodyScrollLock.js +21 -0
- package/dist/hooks/useCollisionAwareSide.cjs +72 -0
- package/dist/hooks/useCollisionAwareSide.js +69 -0
- package/dist/hooks/useControllableValue.cjs +16 -0
- package/dist/hooks/useControllableValue.js +13 -0
- package/dist/hooks/useDismissableLayer.cjs +100 -0
- package/dist/hooks/useDismissableLayer.js +97 -0
- package/dist/hooks/usePopupList.cjs +101 -0
- package/dist/hooks/usePopupList.js +98 -0
- package/dist/icons-8yD7I5jO.d.cts +430 -0
- package/dist/icons-8yD7I5jO.d.ts +430 -0
- package/dist/icons.cjs +2111 -418
- package/dist/icons.d.cts +1256 -429
- package/dist/icons.d.ts +1256 -429
- package/dist/icons.js +2089 -1
- package/dist/index.cjs +128 -15034
- package/dist/index.d.cts +698 -661
- package/dist/index.d.ts +698 -661
- package/dist/index.js +43 -14950
- package/dist/motion/Collapse.cjs +28 -0
- package/dist/motion/Collapse.js +25 -0
- package/dist/motion/MotionProvider.cjs +43 -0
- package/dist/motion/MotionProvider.js +38 -0
- package/dist/motion/Pressable.cjs +46 -0
- package/dist/motion/Pressable.js +43 -0
- package/dist/motion/Reveal.cjs +19 -0
- package/dist/motion/Reveal.js +16 -0
- package/dist/motion/SharedLayout.cjs +46 -0
- package/dist/motion/SharedLayout.js +43 -0
- package/dist/motion/index.cjs +19 -0
- package/dist/motion/index.js +6 -0
- package/dist/motion/presence.cjs +58 -0
- package/dist/motion/presence.js +55 -0
- package/dist/motion/presets.cjs +88 -0
- package/dist/motion/presets.js +84 -0
- package/dist/motion.d.cts +51 -0
- package/dist/motion.d.ts +51 -0
- package/dist/preset.cjs +356 -195
- package/dist/preset.d.cts +111 -32
- package/dist/preset.d.ts +111 -32
- package/dist/preset.js +353 -187
- package/dist/presets-Ba5QndHg.d.cts +144 -0
- package/dist/presets-Ba5QndHg.d.ts +144 -0
- package/dist/styles.css +1 -1
- package/dist/utils/cn.cjs +38 -0
- package/dist/utils/cn.js +35 -0
- package/dist/utils/resolveIcon.cjs +18 -0
- package/dist/utils/resolveIcon.js +15 -0
- package/package.json +79 -21
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Collapse = Collapse;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const MotionProvider_1 = require("./MotionProvider.cjs");
|
|
7
|
+
/** Disclosure region. Supply an external trigger with aria-expanded and aria-controls. */
|
|
8
|
+
function Collapse({ open, motion = true, children, style, ...props }) {
|
|
9
|
+
const { preset, tokens } = (0, MotionProvider_1.useRaydenMotion)(motion);
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)("div", { ...props, ref: (element) => {
|
|
11
|
+
if (!element)
|
|
12
|
+
return;
|
|
13
|
+
if (!open && element.contains(document.activeElement)) {
|
|
14
|
+
const trigger = element.id
|
|
15
|
+
? Array.from(document.querySelectorAll("[aria-controls]")).find((candidate) => candidate.getAttribute("aria-controls")?.split(/\s+/).includes(element.id))
|
|
16
|
+
: undefined;
|
|
17
|
+
if (trigger)
|
|
18
|
+
trigger.focus({ preventScroll: true });
|
|
19
|
+
else
|
|
20
|
+
document.activeElement?.blur();
|
|
21
|
+
}
|
|
22
|
+
element.toggleAttribute("inert", !open);
|
|
23
|
+
}, "data-rayden-collapse": "", "data-rayden-motion": preset, "data-state": open ? "open" : "closed", "aria-hidden": !open || props["aria-hidden"], style: {
|
|
24
|
+
"--rayden-motion-duration": `${open ? tokens.duration.normal : Math.round(tokens.duration.normal * 0.75)}ms`,
|
|
25
|
+
"--rayden-motion-ease": open ? tokens.ease.enter : tokens.ease.exit,
|
|
26
|
+
...style,
|
|
27
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { "data-rayden-collapse-inner": "", children: children }) }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useRaydenMotion } from "./MotionProvider.js";
|
|
4
|
+
/** Disclosure region. Supply an external trigger with aria-expanded and aria-controls. */
|
|
5
|
+
export function Collapse({ open, motion = true, children, style, ...props }) {
|
|
6
|
+
const { preset, tokens } = useRaydenMotion(motion);
|
|
7
|
+
return (_jsx("div", { ...props, ref: (element) => {
|
|
8
|
+
if (!element)
|
|
9
|
+
return;
|
|
10
|
+
if (!open && element.contains(document.activeElement)) {
|
|
11
|
+
const trigger = element.id
|
|
12
|
+
? Array.from(document.querySelectorAll("[aria-controls]")).find((candidate) => candidate.getAttribute("aria-controls")?.split(/\s+/).includes(element.id))
|
|
13
|
+
: undefined;
|
|
14
|
+
if (trigger)
|
|
15
|
+
trigger.focus({ preventScroll: true });
|
|
16
|
+
else
|
|
17
|
+
document.activeElement?.blur();
|
|
18
|
+
}
|
|
19
|
+
element.toggleAttribute("inert", !open);
|
|
20
|
+
}, "data-rayden-collapse": "", "data-rayden-motion": preset, "data-state": open ? "open" : "closed", "aria-hidden": !open || props["aria-hidden"], style: {
|
|
21
|
+
"--rayden-motion-duration": `${open ? tokens.duration.normal : Math.round(tokens.duration.normal * 0.75)}ms`,
|
|
22
|
+
"--rayden-motion-ease": open ? tokens.ease.enter : tokens.ease.exit,
|
|
23
|
+
...style,
|
|
24
|
+
}, children: _jsx("div", { "data-rayden-collapse-inner": "", children: children }) }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useReducedMotionPreference = useReducedMotionPreference;
|
|
5
|
+
exports.MotionProvider = MotionProvider;
|
|
6
|
+
exports.useRaydenMotion = useRaydenMotion;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const presets_1 = require("./presets.cjs");
|
|
10
|
+
const MotionContext = (0, react_1.createContext)("calm");
|
|
11
|
+
const query = "(prefers-reduced-motion: reduce)";
|
|
12
|
+
function subscribe(callback) {
|
|
13
|
+
if (typeof window === "undefined" || !window.matchMedia)
|
|
14
|
+
return () => { };
|
|
15
|
+
const media = window.matchMedia(query);
|
|
16
|
+
media.addEventListener("change", callback);
|
|
17
|
+
return () => media.removeEventListener("change", callback);
|
|
18
|
+
}
|
|
19
|
+
function snapshot() {
|
|
20
|
+
return typeof window === "undefined" || !window.matchMedia || window.matchMedia(query).matches;
|
|
21
|
+
}
|
|
22
|
+
/** The server conservatively disables motion; hydration adopts the user's preference. */
|
|
23
|
+
function useReducedMotionPreference() {
|
|
24
|
+
return (0, react_1.useSyncExternalStore)(subscribe, snapshot, () => true);
|
|
25
|
+
}
|
|
26
|
+
/** Context-only scope: nested scopes and React portals inherit without mutating document root. */
|
|
27
|
+
function MotionProvider({ preset, children }) {
|
|
28
|
+
const inherited = (0, react_1.useContext)(MotionContext);
|
|
29
|
+
return (0, jsx_runtime_1.jsx)(MotionContext.Provider, { value: preset ?? inherited, children: children });
|
|
30
|
+
}
|
|
31
|
+
/** Passing false disables this element's motion. OS reduced motion always wins. */
|
|
32
|
+
function useRaydenMotion(option = true) {
|
|
33
|
+
const inherited = (0, react_1.useContext)(MotionContext);
|
|
34
|
+
const prefersReduced = useReducedMotionPreference();
|
|
35
|
+
const requestedPreset = typeof option === "string" ? option : inherited;
|
|
36
|
+
const preset = prefersReduced || option === false ? "reduced" : requestedPreset;
|
|
37
|
+
return {
|
|
38
|
+
requestedPreset,
|
|
39
|
+
preset,
|
|
40
|
+
reducedMotion: preset === "reduced",
|
|
41
|
+
tokens: presets_1.motionPresets[preset],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useSyncExternalStore } from "react";
|
|
4
|
+
import { motionPresets } from "./presets.js";
|
|
5
|
+
const MotionContext = createContext("calm");
|
|
6
|
+
const query = "(prefers-reduced-motion: reduce)";
|
|
7
|
+
function subscribe(callback) {
|
|
8
|
+
if (typeof window === "undefined" || !window.matchMedia)
|
|
9
|
+
return () => { };
|
|
10
|
+
const media = window.matchMedia(query);
|
|
11
|
+
media.addEventListener("change", callback);
|
|
12
|
+
return () => media.removeEventListener("change", callback);
|
|
13
|
+
}
|
|
14
|
+
function snapshot() {
|
|
15
|
+
return typeof window === "undefined" || !window.matchMedia || window.matchMedia(query).matches;
|
|
16
|
+
}
|
|
17
|
+
/** The server conservatively disables motion; hydration adopts the user's preference. */
|
|
18
|
+
export function useReducedMotionPreference() {
|
|
19
|
+
return useSyncExternalStore(subscribe, snapshot, () => true);
|
|
20
|
+
}
|
|
21
|
+
/** Context-only scope: nested scopes and React portals inherit without mutating document root. */
|
|
22
|
+
export function MotionProvider({ preset, children }) {
|
|
23
|
+
const inherited = useContext(MotionContext);
|
|
24
|
+
return _jsx(MotionContext.Provider, { value: preset ?? inherited, children: children });
|
|
25
|
+
}
|
|
26
|
+
/** Passing false disables this element's motion. OS reduced motion always wins. */
|
|
27
|
+
export function useRaydenMotion(option = true) {
|
|
28
|
+
const inherited = useContext(MotionContext);
|
|
29
|
+
const prefersReduced = useReducedMotionPreference();
|
|
30
|
+
const requestedPreset = typeof option === "string" ? option : inherited;
|
|
31
|
+
const preset = prefersReduced || option === false ? "reduced" : requestedPreset;
|
|
32
|
+
return {
|
|
33
|
+
requestedPreset,
|
|
34
|
+
preset,
|
|
35
|
+
reducedMotion: preset === "reduced",
|
|
36
|
+
tokens: motionPresets[preset],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Pressable = void 0;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const MotionProvider_1 = require("./MotionProvider.cjs");
|
|
8
|
+
/** Native button semantics, focus and activation are retained; only press feedback is added. */
|
|
9
|
+
exports.Pressable = (0, react_1.forwardRef)(function Pressable({ motion = true, type = "button", disabled, style, onPointerDown, onPointerUp, onPointerCancel, onPointerLeave, onKeyDown, onKeyUp, onBlur, ...props }, ref) {
|
|
10
|
+
const [pressed, setPressed] = (0, react_1.useState)(false);
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
if (disabled)
|
|
13
|
+
setPressed(false);
|
|
14
|
+
}, [disabled]);
|
|
15
|
+
const { preset, tokens } = (0, MotionProvider_1.useRaydenMotion)(motion);
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)("button", { ...props, ref: ref, type: type, disabled: disabled, "data-rayden-motion": preset, "data-rayden-pressable": "", "data-pressed": pressed && !disabled, style: {
|
|
17
|
+
"--rayden-press-scale": tokens.scale.press,
|
|
18
|
+
"--rayden-motion-fast": `${tokens.duration.fast}ms`,
|
|
19
|
+
"--rayden-motion-ease": tokens.ease.standard,
|
|
20
|
+
...style,
|
|
21
|
+
}, onPointerDown: (event) => {
|
|
22
|
+
onPointerDown?.(event);
|
|
23
|
+
if (!event.defaultPrevented && !disabled && event.button === 0)
|
|
24
|
+
setPressed(true);
|
|
25
|
+
}, onPointerUp: (event) => {
|
|
26
|
+
setPressed(false);
|
|
27
|
+
onPointerUp?.(event);
|
|
28
|
+
}, onPointerCancel: (event) => {
|
|
29
|
+
setPressed(false);
|
|
30
|
+
onPointerCancel?.(event);
|
|
31
|
+
}, onPointerLeave: (event) => {
|
|
32
|
+
setPressed(false);
|
|
33
|
+
onPointerLeave?.(event);
|
|
34
|
+
}, onKeyDown: (event) => {
|
|
35
|
+
onKeyDown?.(event);
|
|
36
|
+
if (!event.defaultPrevented && !disabled && (event.key === " " || event.key === "Enter"))
|
|
37
|
+
setPressed(true);
|
|
38
|
+
}, onKeyUp: (event) => {
|
|
39
|
+
if (event.key === " " || event.key === "Enter")
|
|
40
|
+
setPressed(false);
|
|
41
|
+
onKeyUp?.(event);
|
|
42
|
+
}, onBlur: (event) => {
|
|
43
|
+
setPressed(false);
|
|
44
|
+
onBlur?.(event);
|
|
45
|
+
} }));
|
|
46
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useState, useEffect, } from "react";
|
|
4
|
+
import { useRaydenMotion } from "./MotionProvider.js";
|
|
5
|
+
/** Native button semantics, focus and activation are retained; only press feedback is added. */
|
|
6
|
+
export const Pressable = forwardRef(function Pressable({ motion = true, type = "button", disabled, style, onPointerDown, onPointerUp, onPointerCancel, onPointerLeave, onKeyDown, onKeyUp, onBlur, ...props }, ref) {
|
|
7
|
+
const [pressed, setPressed] = useState(false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (disabled)
|
|
10
|
+
setPressed(false);
|
|
11
|
+
}, [disabled]);
|
|
12
|
+
const { preset, tokens } = useRaydenMotion(motion);
|
|
13
|
+
return (_jsx("button", { ...props, ref: ref, type: type, disabled: disabled, "data-rayden-motion": preset, "data-rayden-pressable": "", "data-pressed": pressed && !disabled, style: {
|
|
14
|
+
"--rayden-press-scale": tokens.scale.press,
|
|
15
|
+
"--rayden-motion-fast": `${tokens.duration.fast}ms`,
|
|
16
|
+
"--rayden-motion-ease": tokens.ease.standard,
|
|
17
|
+
...style,
|
|
18
|
+
}, onPointerDown: (event) => {
|
|
19
|
+
onPointerDown?.(event);
|
|
20
|
+
if (!event.defaultPrevented && !disabled && event.button === 0)
|
|
21
|
+
setPressed(true);
|
|
22
|
+
}, onPointerUp: (event) => {
|
|
23
|
+
setPressed(false);
|
|
24
|
+
onPointerUp?.(event);
|
|
25
|
+
}, onPointerCancel: (event) => {
|
|
26
|
+
setPressed(false);
|
|
27
|
+
onPointerCancel?.(event);
|
|
28
|
+
}, onPointerLeave: (event) => {
|
|
29
|
+
setPressed(false);
|
|
30
|
+
onPointerLeave?.(event);
|
|
31
|
+
}, onKeyDown: (event) => {
|
|
32
|
+
onKeyDown?.(event);
|
|
33
|
+
if (!event.defaultPrevented && !disabled && (event.key === " " || event.key === "Enter"))
|
|
34
|
+
setPressed(true);
|
|
35
|
+
}, onKeyUp: (event) => {
|
|
36
|
+
if (event.key === " " || event.key === "Enter")
|
|
37
|
+
setPressed(false);
|
|
38
|
+
onKeyUp?.(event);
|
|
39
|
+
}, onBlur: (event) => {
|
|
40
|
+
setPressed(false);
|
|
41
|
+
onBlur?.(event);
|
|
42
|
+
} }));
|
|
43
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Reveal = Reveal;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const presence_1 = require("./presence.cjs");
|
|
8
|
+
/** Presence for non-interactive content; exiting content is inert immediately. */
|
|
9
|
+
function Reveal({ present = true, motion = true, recipe = "appear.fadeUp", children, ...props }) {
|
|
10
|
+
const ref = (0, react_1.useRef)(null);
|
|
11
|
+
const state = (0, presence_1.useMotionPresence)(present, ref, motion, recipe);
|
|
12
|
+
if (!state.present)
|
|
13
|
+
return null;
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)("div", { ...props, ref: (element) => {
|
|
15
|
+
ref.current = element;
|
|
16
|
+
// DOM attribute works in both React 18 and 19 (React 18 lacks boolean inert support).
|
|
17
|
+
element?.toggleAttribute("inert", !present);
|
|
18
|
+
}, "data-rayden-motion": state.preset, "data-state": present ? "open" : "closed", "aria-hidden": !present || props["aria-hidden"], children: children }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { useMotionPresence } from "./presence.js";
|
|
5
|
+
/** Presence for non-interactive content; exiting content is inert immediately. */
|
|
6
|
+
export function Reveal({ present = true, motion = true, recipe = "appear.fadeUp", children, ...props }) {
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
const state = useMotionPresence(present, ref, motion, recipe);
|
|
9
|
+
if (!state.present)
|
|
10
|
+
return null;
|
|
11
|
+
return (_jsx("div", { ...props, ref: (element) => {
|
|
12
|
+
ref.current = element;
|
|
13
|
+
// DOM attribute works in both React 18 and 19 (React 18 lacks boolean inert support).
|
|
14
|
+
element?.toggleAttribute("inert", !present);
|
|
15
|
+
}, "data-rayden-motion": state.preset, "data-state": present ? "open" : "closed", "aria-hidden": !present || props["aria-hidden"], children: children }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SharedLayout = SharedLayout;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const MotionProvider_1 = require("./MotionProvider.cjs");
|
|
8
|
+
const useBrowserLayoutEffect = typeof window === "undefined" ? react_1.useEffect : react_1.useLayoutEffect;
|
|
9
|
+
/** FLIP animation of this persistent element's geometry when layoutKey changes. Not cross-tree presence. */
|
|
10
|
+
function SharedLayout({ layoutKey, motion = true, children, ...props }) {
|
|
11
|
+
const ref = (0, react_1.useRef)(null);
|
|
12
|
+
const previous = (0, react_1.useRef)(null);
|
|
13
|
+
const animation = (0, react_1.useRef)(null);
|
|
14
|
+
const { preset, tokens } = (0, MotionProvider_1.useRaydenMotion)(motion);
|
|
15
|
+
useBrowserLayoutEffect(() => {
|
|
16
|
+
const element = ref.current;
|
|
17
|
+
if (!element)
|
|
18
|
+
return;
|
|
19
|
+
// Continue interrupted movement from its current visual position, not the old target.
|
|
20
|
+
let last = previous.current;
|
|
21
|
+
if (animation.current && last) {
|
|
22
|
+
const matrix = new DOMMatrixReadOnly(getComputedStyle(element).transform);
|
|
23
|
+
last = new DOMRect(last.x + matrix.m41, last.y + matrix.m42, last.width * matrix.a, last.height * matrix.d);
|
|
24
|
+
}
|
|
25
|
+
animation.current?.cancel();
|
|
26
|
+
animation.current = null;
|
|
27
|
+
const next = element.getBoundingClientRect();
|
|
28
|
+
previous.current = next;
|
|
29
|
+
if (!last || preset === "reduced" || !next.width || !next.height || !element.animate)
|
|
30
|
+
return;
|
|
31
|
+
const running = element.animate([
|
|
32
|
+
{
|
|
33
|
+
transform: `translate(${last.x - next.x}px, ${last.y - next.y}px) scale(${last.width / next.width}, ${last.height / next.height})`,
|
|
34
|
+
transformOrigin: "0 0",
|
|
35
|
+
},
|
|
36
|
+
{ transform: "none", transformOrigin: "0 0" },
|
|
37
|
+
], { duration: tokens.duration.normal, easing: tokens.ease.standard });
|
|
38
|
+
animation.current = running;
|
|
39
|
+
running.onfinish = () => {
|
|
40
|
+
previous.current = element.getBoundingClientRect();
|
|
41
|
+
animation.current = null;
|
|
42
|
+
};
|
|
43
|
+
}, [layoutKey, preset, tokens]);
|
|
44
|
+
(0, react_1.useEffect)(() => () => animation.current?.cancel(), []);
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)("div", { ...props, ref: ref, "data-rayden-motion": preset, children: children }));
|
|
46
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
4
|
+
import { useRaydenMotion } from "./MotionProvider.js";
|
|
5
|
+
const useBrowserLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
6
|
+
/** FLIP animation of this persistent element's geometry when layoutKey changes. Not cross-tree presence. */
|
|
7
|
+
export function SharedLayout({ layoutKey, motion = true, children, ...props }) {
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
const previous = useRef(null);
|
|
10
|
+
const animation = useRef(null);
|
|
11
|
+
const { preset, tokens } = useRaydenMotion(motion);
|
|
12
|
+
useBrowserLayoutEffect(() => {
|
|
13
|
+
const element = ref.current;
|
|
14
|
+
if (!element)
|
|
15
|
+
return;
|
|
16
|
+
// Continue interrupted movement from its current visual position, not the old target.
|
|
17
|
+
let last = previous.current;
|
|
18
|
+
if (animation.current && last) {
|
|
19
|
+
const matrix = new DOMMatrixReadOnly(getComputedStyle(element).transform);
|
|
20
|
+
last = new DOMRect(last.x + matrix.m41, last.y + matrix.m42, last.width * matrix.a, last.height * matrix.d);
|
|
21
|
+
}
|
|
22
|
+
animation.current?.cancel();
|
|
23
|
+
animation.current = null;
|
|
24
|
+
const next = element.getBoundingClientRect();
|
|
25
|
+
previous.current = next;
|
|
26
|
+
if (!last || preset === "reduced" || !next.width || !next.height || !element.animate)
|
|
27
|
+
return;
|
|
28
|
+
const running = element.animate([
|
|
29
|
+
{
|
|
30
|
+
transform: `translate(${last.x - next.x}px, ${last.y - next.y}px) scale(${last.width / next.width}, ${last.height / next.height})`,
|
|
31
|
+
transformOrigin: "0 0",
|
|
32
|
+
},
|
|
33
|
+
{ transform: "none", transformOrigin: "0 0" },
|
|
34
|
+
], { duration: tokens.duration.normal, easing: tokens.ease.standard });
|
|
35
|
+
animation.current = running;
|
|
36
|
+
running.onfinish = () => {
|
|
37
|
+
previous.current = element.getBoundingClientRect();
|
|
38
|
+
animation.current = null;
|
|
39
|
+
};
|
|
40
|
+
}, [layoutKey, preset, tokens]);
|
|
41
|
+
useEffect(() => () => animation.current?.cancel(), []);
|
|
42
|
+
return (_jsx("div", { ...props, ref: ref, "data-rayden-motion": preset, children: children }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMotionRecipe = exports.motionRecipes = exports.motionPresets = exports.SharedLayout = exports.Collapse = exports.Reveal = exports.Pressable = exports.useReducedMotionPreference = exports.useRaydenMotion = exports.MotionProvider = void 0;
|
|
4
|
+
var MotionProvider_1 = require("./MotionProvider.cjs");
|
|
5
|
+
Object.defineProperty(exports, "MotionProvider", { enumerable: true, get: function () { return MotionProvider_1.MotionProvider; } });
|
|
6
|
+
Object.defineProperty(exports, "useRaydenMotion", { enumerable: true, get: function () { return MotionProvider_1.useRaydenMotion; } });
|
|
7
|
+
Object.defineProperty(exports, "useReducedMotionPreference", { enumerable: true, get: function () { return MotionProvider_1.useReducedMotionPreference; } });
|
|
8
|
+
var Pressable_1 = require("./Pressable.cjs");
|
|
9
|
+
Object.defineProperty(exports, "Pressable", { enumerable: true, get: function () { return Pressable_1.Pressable; } });
|
|
10
|
+
var Reveal_1 = require("./Reveal.cjs");
|
|
11
|
+
Object.defineProperty(exports, "Reveal", { enumerable: true, get: function () { return Reveal_1.Reveal; } });
|
|
12
|
+
var Collapse_1 = require("./Collapse.cjs");
|
|
13
|
+
Object.defineProperty(exports, "Collapse", { enumerable: true, get: function () { return Collapse_1.Collapse; } });
|
|
14
|
+
var SharedLayout_1 = require("./SharedLayout.cjs");
|
|
15
|
+
Object.defineProperty(exports, "SharedLayout", { enumerable: true, get: function () { return SharedLayout_1.SharedLayout; } });
|
|
16
|
+
var presets_1 = require("./presets.cjs");
|
|
17
|
+
Object.defineProperty(exports, "motionPresets", { enumerable: true, get: function () { return presets_1.motionPresets; } });
|
|
18
|
+
Object.defineProperty(exports, "motionRecipes", { enumerable: true, get: function () { return presets_1.motionRecipes; } });
|
|
19
|
+
Object.defineProperty(exports, "getMotionRecipe", { enumerable: true, get: function () { return presets_1.getMotionRecipe; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { MotionProvider, useRaydenMotion, useReducedMotionPreference } from "./MotionProvider.js";
|
|
2
|
+
export { Pressable } from "./Pressable.js";
|
|
3
|
+
export { Reveal } from "./Reveal.js";
|
|
4
|
+
export { Collapse } from "./Collapse.js";
|
|
5
|
+
export { SharedLayout } from "./SharedLayout.js";
|
|
6
|
+
export { motionPresets, motionRecipes, getMotionRecipe } from "./presets.js";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useMotionPresence = useMotionPresence;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const MotionProvider_1 = require("./MotionProvider.cjs");
|
|
7
|
+
/** Internal presence controller. Cancelled animations never complete an obsolete exit. */
|
|
8
|
+
function useMotionPresence(open, ref, motion = true, recipe = "appear.fadeUp", ready = true) {
|
|
9
|
+
const { preset, tokens } = (0, MotionProvider_1.useRaydenMotion)(motion);
|
|
10
|
+
const [retained, setRetained] = (0, react_1.useState)(open);
|
|
11
|
+
const animation = (0, react_1.useRef)(null);
|
|
12
|
+
const present = open || retained;
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
const element = ref.current;
|
|
15
|
+
if (!ready || !element)
|
|
16
|
+
return;
|
|
17
|
+
const currentStyle = animation.current ? getComputedStyle(element) : null;
|
|
18
|
+
const from = currentStyle
|
|
19
|
+
? { opacity: currentStyle.opacity, transform: currentStyle.transform }
|
|
20
|
+
: null;
|
|
21
|
+
animation.current?.cancel();
|
|
22
|
+
animation.current = null;
|
|
23
|
+
setRetained(open);
|
|
24
|
+
if (preset === "reduced" || typeof element.animate !== "function")
|
|
25
|
+
return;
|
|
26
|
+
if (!open)
|
|
27
|
+
setRetained(true);
|
|
28
|
+
const hidden = {
|
|
29
|
+
opacity: 0,
|
|
30
|
+
transform: recipe === "appear.fade"
|
|
31
|
+
? "none"
|
|
32
|
+
: recipe === "appear.scale" || recipe === "overlay.pop"
|
|
33
|
+
? `scale(${tokens.scale.enter})`
|
|
34
|
+
: `translateY(${tokens.distance.short}px)`,
|
|
35
|
+
};
|
|
36
|
+
const shown = { opacity: 1, transform: "none" };
|
|
37
|
+
const running = element.animate([from ?? (open ? hidden : shown), open ? shown : hidden], {
|
|
38
|
+
duration: open ? tokens.duration.normal : Math.round(tokens.duration.normal * 0.75),
|
|
39
|
+
easing: open ? tokens.ease.enter : tokens.ease.exit,
|
|
40
|
+
fill: "both",
|
|
41
|
+
});
|
|
42
|
+
animation.current = running;
|
|
43
|
+
running.onfinish = () => {
|
|
44
|
+
animation.current = null;
|
|
45
|
+
running.cancel();
|
|
46
|
+
if (!open)
|
|
47
|
+
setRetained(false);
|
|
48
|
+
};
|
|
49
|
+
return () => {
|
|
50
|
+
// Keep the current animation until the next effect can sample its visual state.
|
|
51
|
+
running.onfinish = null;
|
|
52
|
+
};
|
|
53
|
+
}, [open, ready, preset, recipe, tokens, ref]);
|
|
54
|
+
(0, react_1.useEffect)(() => () => {
|
|
55
|
+
animation.current?.cancel();
|
|
56
|
+
}, []);
|
|
57
|
+
return { present, preset };
|
|
58
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useRaydenMotion } from "./MotionProvider.js";
|
|
4
|
+
/** Internal presence controller. Cancelled animations never complete an obsolete exit. */
|
|
5
|
+
export function useMotionPresence(open, ref, motion = true, recipe = "appear.fadeUp", ready = true) {
|
|
6
|
+
const { preset, tokens } = useRaydenMotion(motion);
|
|
7
|
+
const [retained, setRetained] = useState(open);
|
|
8
|
+
const animation = useRef(null);
|
|
9
|
+
const present = open || retained;
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const element = ref.current;
|
|
12
|
+
if (!ready || !element)
|
|
13
|
+
return;
|
|
14
|
+
const currentStyle = animation.current ? getComputedStyle(element) : null;
|
|
15
|
+
const from = currentStyle
|
|
16
|
+
? { opacity: currentStyle.opacity, transform: currentStyle.transform }
|
|
17
|
+
: null;
|
|
18
|
+
animation.current?.cancel();
|
|
19
|
+
animation.current = null;
|
|
20
|
+
setRetained(open);
|
|
21
|
+
if (preset === "reduced" || typeof element.animate !== "function")
|
|
22
|
+
return;
|
|
23
|
+
if (!open)
|
|
24
|
+
setRetained(true);
|
|
25
|
+
const hidden = {
|
|
26
|
+
opacity: 0,
|
|
27
|
+
transform: recipe === "appear.fade"
|
|
28
|
+
? "none"
|
|
29
|
+
: recipe === "appear.scale" || recipe === "overlay.pop"
|
|
30
|
+
? `scale(${tokens.scale.enter})`
|
|
31
|
+
: `translateY(${tokens.distance.short}px)`,
|
|
32
|
+
};
|
|
33
|
+
const shown = { opacity: 1, transform: "none" };
|
|
34
|
+
const running = element.animate([from ?? (open ? hidden : shown), open ? shown : hidden], {
|
|
35
|
+
duration: open ? tokens.duration.normal : Math.round(tokens.duration.normal * 0.75),
|
|
36
|
+
easing: open ? tokens.ease.enter : tokens.ease.exit,
|
|
37
|
+
fill: "both",
|
|
38
|
+
});
|
|
39
|
+
animation.current = running;
|
|
40
|
+
running.onfinish = () => {
|
|
41
|
+
animation.current = null;
|
|
42
|
+
running.cancel();
|
|
43
|
+
if (!open)
|
|
44
|
+
setRetained(false);
|
|
45
|
+
};
|
|
46
|
+
return () => {
|
|
47
|
+
// Keep the current animation until the next effect can sample its visual state.
|
|
48
|
+
running.onfinish = null;
|
|
49
|
+
};
|
|
50
|
+
}, [open, ready, preset, recipe, tokens, ref]);
|
|
51
|
+
useEffect(() => () => {
|
|
52
|
+
animation.current?.cancel();
|
|
53
|
+
}, []);
|
|
54
|
+
return { present, preset };
|
|
55
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.motionRecipes = exports.motionPresets = void 0;
|
|
4
|
+
exports.getMotionRecipe = getMotionRecipe;
|
|
5
|
+
const ease = {
|
|
6
|
+
enter: "cubic-bezier(0.16, 1, 0.3, 1)",
|
|
7
|
+
exit: "cubic-bezier(0.4, 0, 1, 1)",
|
|
8
|
+
standard: "cubic-bezier(0.25, 1, 0.5, 1)",
|
|
9
|
+
};
|
|
10
|
+
exports.motionPresets = {
|
|
11
|
+
calm: {
|
|
12
|
+
duration: { instant: 0, fast: 100, normal: 220, slow: 280 },
|
|
13
|
+
ease,
|
|
14
|
+
distance: { micro: 2, short: 6 },
|
|
15
|
+
scale: { press: 0.98, enter: 0.98 },
|
|
16
|
+
},
|
|
17
|
+
snappy: {
|
|
18
|
+
duration: { instant: 0, fast: 80, normal: 140, slow: 180 },
|
|
19
|
+
ease,
|
|
20
|
+
distance: { micro: 2, short: 4 },
|
|
21
|
+
scale: { press: 0.97, enter: 0.98 },
|
|
22
|
+
},
|
|
23
|
+
playful: {
|
|
24
|
+
duration: { instant: 0, fast: 120, normal: 260, slow: 340 },
|
|
25
|
+
ease,
|
|
26
|
+
distance: { micro: 4, short: 12 },
|
|
27
|
+
scale: { press: 0.95, enter: 0.94 },
|
|
28
|
+
},
|
|
29
|
+
reduced: {
|
|
30
|
+
duration: { instant: 0, fast: 0, normal: 0, slow: 0 },
|
|
31
|
+
ease,
|
|
32
|
+
distance: { micro: 0, short: 0 },
|
|
33
|
+
scale: { press: 1, enter: 1 },
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
exports.motionRecipes = {
|
|
37
|
+
"appear.fade": {
|
|
38
|
+
primitive: "Reveal",
|
|
39
|
+
purpose: "Reveal content without displacement",
|
|
40
|
+
reducedMotion: "Immediate visibility",
|
|
41
|
+
engine: "waapi",
|
|
42
|
+
},
|
|
43
|
+
"appear.fadeUp": {
|
|
44
|
+
primitive: "Reveal",
|
|
45
|
+
purpose: "Introduce newly available content",
|
|
46
|
+
reducedMotion: "Immediate visibility",
|
|
47
|
+
engine: "waapi",
|
|
48
|
+
},
|
|
49
|
+
"appear.scale": {
|
|
50
|
+
primitive: "Reveal",
|
|
51
|
+
purpose: "Introduce a compact surface",
|
|
52
|
+
reducedMotion: "Immediate visibility",
|
|
53
|
+
engine: "waapi",
|
|
54
|
+
},
|
|
55
|
+
"overlay.pop": {
|
|
56
|
+
primitive: "Modal",
|
|
57
|
+
purpose: "Open or dismiss a dialog panel",
|
|
58
|
+
reducedMotion: "Immediate open and close with focus preserved",
|
|
59
|
+
engine: "waapi",
|
|
60
|
+
},
|
|
61
|
+
"selection.slideIndicator": {
|
|
62
|
+
primitive: "SharedLayout",
|
|
63
|
+
purpose: "Track tab selection",
|
|
64
|
+
reducedMotion: "Immediate selection indicator",
|
|
65
|
+
engine: "waapi",
|
|
66
|
+
},
|
|
67
|
+
"selection.sharedPill": {
|
|
68
|
+
primitive: "SharedLayout",
|
|
69
|
+
purpose: "Track segmented or pill selection",
|
|
70
|
+
reducedMotion: "Immediate selection indicator",
|
|
71
|
+
engine: "waapi",
|
|
72
|
+
},
|
|
73
|
+
"disclosure.collapse": {
|
|
74
|
+
primitive: "Collapse",
|
|
75
|
+
purpose: "Expand optional content",
|
|
76
|
+
reducedMotion: "Immediate disclosure",
|
|
77
|
+
engine: "css",
|
|
78
|
+
},
|
|
79
|
+
"feedback.press": {
|
|
80
|
+
primitive: "Pressable",
|
|
81
|
+
purpose: "Acknowledge pointer and keyboard press",
|
|
82
|
+
reducedMotion: "Native focus and active state without scaling",
|
|
83
|
+
engine: "css",
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
function getMotionRecipe(name, preset = "calm") {
|
|
87
|
+
return { name, ...exports.motionRecipes[name], preset, tokens: exports.motionPresets[preset] };
|
|
88
|
+
}
|