@wzrhine/react 0.0.0-stage → 0.1.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/CHANGELOG.md +80 -0
- package/LICENSE +21 -0
- package/README.md +37 -3
- package/dist/advanced.css +398 -0
- package/dist/archive.css +704 -0
- package/dist/command.css +671 -0
- package/dist/components/Accordion.d.ts +82 -0
- package/dist/components/Accordion.d.ts.map +1 -0
- package/dist/components/Accordion.js +19 -0
- package/dist/components/Accordion.js.map +1 -0
- package/dist/components/Alert.d.ts +60 -0
- package/dist/components/Alert.d.ts.map +1 -0
- package/dist/components/Alert.js +29 -0
- package/dist/components/Alert.js.map +1 -0
- package/dist/components/AlertDialog.d.ts +41 -0
- package/dist/components/AlertDialog.d.ts.map +1 -0
- package/dist/components/AlertDialog.js +101 -0
- package/dist/components/AlertDialog.js.map +1 -0
- package/dist/components/ArchiveCard.d.ts +58 -0
- package/dist/components/ArchiveCard.d.ts.map +1 -0
- package/dist/components/ArchiveCard.js +40 -0
- package/dist/components/ArchiveCard.js.map +1 -0
- package/dist/components/Breadcrumb.d.ts +48 -0
- package/dist/components/Breadcrumb.d.ts.map +1 -0
- package/dist/components/Breadcrumb.js +55 -0
- package/dist/components/Breadcrumb.js.map +1 -0
- package/dist/components/Button.d.ts +30 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Button.js +24 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/Checkbox.d.ts +81 -0
- package/dist/components/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox.js +34 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/Collapsible.d.ts +47 -0
- package/dist/components/Collapsible.d.ts.map +1 -0
- package/dist/components/Collapsible.js +12 -0
- package/dist/components/Collapsible.js.map +1 -0
- package/dist/components/Combobox.d.ts +74 -0
- package/dist/components/Combobox.d.ts.map +1 -0
- package/dist/components/Combobox.js +61 -0
- package/dist/components/Combobox.js.map +1 -0
- package/dist/components/CommandPalette.d.ts +77 -0
- package/dist/components/CommandPalette.d.ts.map +1 -0
- package/dist/components/CommandPalette.js +150 -0
- package/dist/components/CommandPalette.js.map +1 -0
- package/dist/components/ContextMenu.d.ts +31 -0
- package/dist/components/ContextMenu.d.ts.map +1 -0
- package/dist/components/ContextMenu.js +25 -0
- package/dist/components/ContextMenu.js.map +1 -0
- package/dist/components/DataTable.d.ts +83 -0
- package/dist/components/DataTable.d.ts.map +1 -0
- package/dist/components/DataTable.js +97 -0
- package/dist/components/DataTable.js.map +1 -0
- package/dist/components/Dialog.d.ts +45 -0
- package/dist/components/Dialog.d.ts.map +1 -0
- package/dist/components/Dialog.js +46 -0
- package/dist/components/Dialog.js.map +1 -0
- package/dist/components/Drawer.d.ts +56 -0
- package/dist/components/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer.js +92 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/EmptyState.d.ts +39 -0
- package/dist/components/EmptyState.d.ts.map +1 -0
- package/dist/components/EmptyState.js +19 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/Field.d.ts +37 -0
- package/dist/components/Field.d.ts.map +1 -0
- package/dist/components/Field.js +12 -0
- package/dist/components/Field.js.map +1 -0
- package/dist/components/Fieldset.d.ts +24 -0
- package/dist/components/Fieldset.d.ts.map +1 -0
- package/dist/components/Fieldset.js +17 -0
- package/dist/components/Fieldset.js.map +1 -0
- package/dist/components/FileDropZone.d.ts +60 -0
- package/dist/components/FileDropZone.d.ts.map +1 -0
- package/dist/components/FileDropZone.js +121 -0
- package/dist/components/FileDropZone.js.map +1 -0
- package/dist/components/Form.d.ts +21 -0
- package/dist/components/Form.d.ts.map +1 -0
- package/dist/components/Form.js +20 -0
- package/dist/components/Form.js.map +1 -0
- package/dist/components/IconButton.d.ts +25 -0
- package/dist/components/IconButton.d.ts.map +1 -0
- package/dist/components/IconButton.js +14 -0
- package/dist/components/IconButton.js.map +1 -0
- package/dist/components/Input.d.ts +24 -0
- package/dist/components/Input.d.ts.map +1 -0
- package/dist/components/Input.js +15 -0
- package/dist/components/Input.js.map +1 -0
- package/dist/components/Menu.d.ts +66 -0
- package/dist/components/Menu.d.ts.map +1 -0
- package/dist/components/Menu.js +34 -0
- package/dist/components/Menu.js.map +1 -0
- package/dist/components/MetadataList.d.ts +51 -0
- package/dist/components/MetadataList.d.ts.map +1 -0
- package/dist/components/MetadataList.js +25 -0
- package/dist/components/MetadataList.js.map +1 -0
- package/dist/components/NumberField.d.ts +52 -0
- package/dist/components/NumberField.d.ts.map +1 -0
- package/dist/components/NumberField.js +21 -0
- package/dist/components/NumberField.js.map +1 -0
- package/dist/components/Pagination.d.ts +40 -0
- package/dist/components/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination.js +64 -0
- package/dist/components/Pagination.js.map +1 -0
- package/dist/components/Popover.d.ts +44 -0
- package/dist/components/Popover.d.ts.map +1 -0
- package/dist/components/Popover.js +14 -0
- package/dist/components/Popover.js.map +1 -0
- package/dist/components/Progress.d.ts +57 -0
- package/dist/components/Progress.d.ts.map +1 -0
- package/dist/components/Progress.js +31 -0
- package/dist/components/Progress.js.map +1 -0
- package/dist/components/Radio.d.ts +61 -0
- package/dist/components/Radio.d.ts.map +1 -0
- package/dist/components/Radio.js +18 -0
- package/dist/components/Radio.js.map +1 -0
- package/dist/components/RecordHeader.d.ts +53 -0
- package/dist/components/RecordHeader.d.ts.map +1 -0
- package/dist/components/RecordHeader.js +19 -0
- package/dist/components/RecordHeader.js.map +1 -0
- package/dist/components/ScrollArea.d.ts +55 -0
- package/dist/components/ScrollArea.d.ts.map +1 -0
- package/dist/components/ScrollArea.js +63 -0
- package/dist/components/ScrollArea.js.map +1 -0
- package/dist/components/Select.d.ts +39 -0
- package/dist/components/Select.d.ts.map +1 -0
- package/dist/components/Select.js +24 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Separator.d.ts +26 -0
- package/dist/components/Separator.d.ts.map +1 -0
- package/dist/components/Separator.js +22 -0
- package/dist/components/Separator.js.map +1 -0
- package/dist/components/Skeleton.d.ts +31 -0
- package/dist/components/Skeleton.d.ts.map +1 -0
- package/dist/components/Skeleton.js +17 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/Slider.d.ts +65 -0
- package/dist/components/Slider.d.ts.map +1 -0
- package/dist/components/Slider.js +30 -0
- package/dist/components/Slider.js.map +1 -0
- package/dist/components/Spinner.d.ts +23 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +13 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/SplitButton.d.ts +59 -0
- package/dist/components/SplitButton.d.ts.map +1 -0
- package/dist/components/SplitButton.js +30 -0
- package/dist/components/SplitButton.js.map +1 -0
- package/dist/components/Stat.d.ts +53 -0
- package/dist/components/Stat.d.ts.map +1 -0
- package/dist/components/Stat.js +23 -0
- package/dist/components/Stat.js.map +1 -0
- package/dist/components/StatusBadge.d.ts +19 -0
- package/dist/components/StatusBadge.d.ts.map +1 -0
- package/dist/components/StatusBadge.js +8 -0
- package/dist/components/StatusBadge.js.map +1 -0
- package/dist/components/StatusIndicator.d.ts +29 -0
- package/dist/components/StatusIndicator.d.ts.map +1 -0
- package/dist/components/StatusIndicator.js +8 -0
- package/dist/components/StatusIndicator.js.map +1 -0
- package/dist/components/Surface.d.ts +29 -0
- package/dist/components/Surface.d.ts.map +1 -0
- package/dist/components/Surface.js +8 -0
- package/dist/components/Surface.js.map +1 -0
- package/dist/components/Switch.d.ts +22 -0
- package/dist/components/Switch.d.ts.map +1 -0
- package/dist/components/Switch.js +11 -0
- package/dist/components/Switch.js.map +1 -0
- package/dist/components/Tabs.d.ts +45 -0
- package/dist/components/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs.js +49 -0
- package/dist/components/Tabs.js.map +1 -0
- package/dist/components/Text.d.ts +33 -0
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/Text.js +21 -0
- package/dist/components/Text.js.map +1 -0
- package/dist/components/Textarea.d.ts +54 -0
- package/dist/components/Textarea.d.ts.map +1 -0
- package/dist/components/Textarea.js +31 -0
- package/dist/components/Textarea.js.map +1 -0
- package/dist/components/Timeline.d.ts +35 -0
- package/dist/components/Timeline.d.ts.map +1 -0
- package/dist/components/Timeline.js +13 -0
- package/dist/components/Timeline.js.map +1 -0
- package/dist/components/Toast.d.ts +67 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/Toast.js +94 -0
- package/dist/components/Toast.js.map +1 -0
- package/dist/components/Tooltip.d.ts +26 -0
- package/dist/components/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip.js +15 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/VisuallyHidden.d.ts +17 -0
- package/dist/components/VisuallyHidden.d.ts.map +1 -0
- package/dist/components/VisuallyHidden.js +12 -0
- package/dist/components/VisuallyHidden.js.map +1 -0
- package/dist/components/fieldParts.d.ts +17 -0
- package/dist/components/fieldParts.d.ts.map +1 -0
- package/dist/components/fieldParts.js +22 -0
- package/dist/components/fieldParts.js.map +1 -0
- package/dist/components/meter-utils.d.ts +15 -0
- package/dist/components/meter-utils.d.ts.map +1 -0
- package/dist/components/meter-utils.js +15 -0
- package/dist/components/meter-utils.js.map +1 -0
- package/dist/components/pagination-utils.d.ts +10 -0
- package/dist/components/pagination-utils.d.ts.map +1 -0
- package/dist/components/pagination-utils.js +36 -0
- package/dist/components/pagination-utils.js.map +1 -0
- package/dist/components.css +632 -0
- package/dist/data.css +600 -0
- package/dist/disclosure.css +93 -0
- package/dist/drawer.css +226 -0
- package/dist/feedback.css +454 -0
- package/dist/forms.css +516 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/motion/lifecycle.d.ts +44 -0
- package/dist/motion/lifecycle.d.ts.map +1 -0
- package/dist/motion/lifecycle.js +73 -0
- package/dist/motion/lifecycle.js.map +1 -0
- package/dist/motion/presence.d.ts +69 -0
- package/dist/motion/presence.d.ts.map +1 -0
- package/dist/motion/presence.js +103 -0
- package/dist/motion/presence.js.map +1 -0
- package/dist/motion/presets.d.ts +63 -0
- package/dist/motion/presets.d.ts.map +1 -0
- package/dist/motion/presets.js +30 -0
- package/dist/motion/presets.js.map +1 -0
- package/dist/motion/resolve.d.ts +31 -0
- package/dist/motion/resolve.d.ts.map +1 -0
- package/dist/motion/resolve.js +40 -0
- package/dist/motion/resolve.js.map +1 -0
- package/dist/motion/useRhineMotion.d.ts +19 -0
- package/dist/motion/useRhineMotion.d.ts.map +1 -0
- package/dist/motion/useRhineMotion.js +19 -0
- package/dist/motion/useRhineMotion.js.map +1 -0
- package/dist/motion/visibility.d.ts +6 -0
- package/dist/motion/visibility.d.ts.map +1 -0
- package/dist/motion/visibility.js +31 -0
- package/dist/motion/visibility.js.map +1 -0
- package/dist/overlays.css +465 -0
- package/dist/provider/RhineProvider.d.ts +65 -0
- package/dist/provider/RhineProvider.d.ts.map +1 -0
- package/dist/provider/RhineProvider.js +26 -0
- package/dist/provider/RhineProvider.js.map +1 -0
- package/dist/provider/messages.d.ts +190 -0
- package/dist/provider/messages.d.ts.map +1 -0
- package/dist/provider/messages.js +160 -0
- package/dist/provider/messages.js.map +1 -0
- package/dist/provider/portal.d.ts +17 -0
- package/dist/provider/portal.d.ts.map +1 -0
- package/dist/provider/portal.js +20 -0
- package/dist/provider/portal.js.map +1 -0
- package/dist/reset.css +45 -0
- package/dist/split.css +159 -0
- package/dist/status.css +353 -0
- package/dist/utils/cx.d.ts +2 -0
- package/dist/utils/cx.d.ts.map +1 -0
- package/dist/utils/cx.js +4 -0
- package/dist/utils/cx.js.map +1 -0
- package/package.json +62 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Side-effect free: styles are opt-in via `@wzrhine/tokens/styles.css` and `@wzrhine/react/styles.css`.
|
|
2
|
+
export { Button } from './components/Button.js';
|
|
3
|
+
export { Surface } from './components/Surface.js';
|
|
4
|
+
export { StatusBadge } from './components/StatusBadge.js';
|
|
5
|
+
export { IconButton } from './components/IconButton.js';
|
|
6
|
+
export { Text } from './components/Text.js';
|
|
7
|
+
export { Field } from './components/Field.js';
|
|
8
|
+
export { Input } from './components/Input.js';
|
|
9
|
+
export { Textarea } from './components/Textarea.js';
|
|
10
|
+
export { Checkbox, CheckboxGroup } from './components/Checkbox.js';
|
|
11
|
+
export { Radio, RadioGroup } from './components/Radio.js';
|
|
12
|
+
export { Switch } from './components/Switch.js';
|
|
13
|
+
export { Form } from './components/Form.js';
|
|
14
|
+
export { Fieldset } from './components/Fieldset.js';
|
|
15
|
+
export { Separator } from './components/Separator.js';
|
|
16
|
+
export { VisuallyHidden } from './components/VisuallyHidden.js';
|
|
17
|
+
export { Tabs, TabList, Tab, TabPanel } from './components/Tabs.js';
|
|
18
|
+
export { Tooltip } from './components/Tooltip.js';
|
|
19
|
+
export { Dialog, DialogClose } from './components/Dialog.js';
|
|
20
|
+
export { Select } from './components/Select.js';
|
|
21
|
+
export { Popover, PopoverClose } from './components/Popover.js';
|
|
22
|
+
export { Menu, MenuCheckboxItem, MenuGroup, MenuItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, } from './components/Menu.js';
|
|
23
|
+
export { ToastProvider, ToastViewport, useToast } from './components/Toast.js';
|
|
24
|
+
export { MetadataList } from './components/MetadataList.js';
|
|
25
|
+
export { Pagination } from './components/Pagination.js';
|
|
26
|
+
export { getPaginationItems, paginate } from './components/pagination-utils.js';
|
|
27
|
+
export { Breadcrumb } from './components/Breadcrumb.js';
|
|
28
|
+
export { Progress, Meter } from './components/Progress.js';
|
|
29
|
+
export { getMeterState } from './components/meter-utils.js';
|
|
30
|
+
export { Stat } from './components/Stat.js';
|
|
31
|
+
export { AlertDialog } from './components/AlertDialog.js';
|
|
32
|
+
export { Drawer, DrawerClose } from './components/Drawer.js';
|
|
33
|
+
export { Alert, Callout } from './components/Alert.js';
|
|
34
|
+
export { EmptyState } from './components/EmptyState.js';
|
|
35
|
+
export { Skeleton } from './components/Skeleton.js';
|
|
36
|
+
export { Spinner } from './components/Spinner.js';
|
|
37
|
+
export { Collapsible } from './components/Collapsible.js';
|
|
38
|
+
export { Accordion, AccordionItem } from './components/Accordion.js';
|
|
39
|
+
export { Slider } from './components/Slider.js';
|
|
40
|
+
export { NumberField } from './components/NumberField.js';
|
|
41
|
+
export { ContextMenu } from './components/ContextMenu.js';
|
|
42
|
+
export { Combobox } from './components/Combobox.js';
|
|
43
|
+
export { CommandPalette, matchHotkey } from './components/CommandPalette.js';
|
|
44
|
+
export { SplitButton } from './components/SplitButton.js';
|
|
45
|
+
export { ScrollArea } from './components/ScrollArea.js';
|
|
46
|
+
export { FileDropZone, matchesAccept, validateFiles } from './components/FileDropZone.js';
|
|
47
|
+
export { DataTable } from './components/DataTable.js';
|
|
48
|
+
export { ArchiveCard } from './components/ArchiveCard.js';
|
|
49
|
+
export { StatusIndicator } from './components/StatusIndicator.js';
|
|
50
|
+
export { Timeline } from './components/Timeline.js';
|
|
51
|
+
export { RecordHeader } from './components/RecordHeader.js';
|
|
52
|
+
export { RhineProvider, usePortalContainer } from './provider/RhineProvider.js';
|
|
53
|
+
export { RhineMessagesProvider, enUS, useRhineLocale, useRhineMessages, zhCN } from './provider/messages.js';
|
|
54
|
+
export { duration, ease, fadePresence, pressScale, transition } from './motion/presets.js';
|
|
55
|
+
export { useRhineMotion } from './motion/useRhineMotion.js';
|
|
56
|
+
export { MotionSpeed, resolveMotion, useMotionSpeed } from './motion/resolve.js';
|
|
57
|
+
export { MotionPresence, RhineMotionGroup, RhineMotionItem } from './motion/presence.js';
|
|
58
|
+
export { useInViewport, usePageVisible } from './motion/visibility.js';
|
|
59
|
+
export { useLatestGuard, useMotionLifecycle } from './motion/lifecycle.js';
|
|
60
|
+
export { ArchiveIdentity } from './components/ArchiveCard.js';
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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
export type MotionPauseReason = 'manual' | 'hidden' | 'offscreen' | 'reduced';
|
|
4
|
+
export interface MotionLifecycleOptions {
|
|
5
|
+
/** Controlled request. When set, it overrides `start()` / `stop()`. */
|
|
6
|
+
active?: boolean;
|
|
7
|
+
/** Start on mount (uncontrolled only). */
|
|
8
|
+
autoStart?: boolean;
|
|
9
|
+
/** Pause while this element is outside the viewport. */
|
|
10
|
+
viewportRef?: React.RefObject<Element | null>;
|
|
11
|
+
/** Extra reduced-motion signal (e.g. an effect clock forcing reduce). OS / provider preference always applies. */
|
|
12
|
+
reduced?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface MotionLifecycle {
|
|
15
|
+
state: MotionLifecycleState;
|
|
16
|
+
/** True only in `running`; drive the loop from this. */
|
|
17
|
+
running: boolean;
|
|
18
|
+
/** Why a requested loop is not running; `null` when running, idle or stopped. */
|
|
19
|
+
pauseReason: MotionPauseReason | null;
|
|
20
|
+
start: () => void;
|
|
21
|
+
pause: () => void;
|
|
22
|
+
resume: () => void;
|
|
23
|
+
stop: () => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function useMotionLifecycle({ active, autoStart, viewportRef, reduced: forceReduced }?: MotionLifecycleOptions): MotionLifecycle;
|
|
26
|
+
export interface LatestGuard {
|
|
27
|
+
/** Begin a new async run; the returned check is true until a newer run begins, `cancel()` or unmount. */
|
|
28
|
+
begin: () => () => boolean;
|
|
29
|
+
/** Invalidate every pending run (e.g. when the dialog that started it closes). */
|
|
30
|
+
cancel: () => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Stale async result guard (MOTION.md lifecycle rule 2): a late response must not reopen a dialog
|
|
34
|
+
* or overwrite newer state.
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* const guard = useLatestGuard();
|
|
38
|
+
* const isCurrent = guard.begin();
|
|
39
|
+
* const data = await load();
|
|
40
|
+
* if (!isCurrent()) return;
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function useLatestGuard(): LatestGuard;
|
|
44
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/motion/lifecycle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAC7E,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AAE9E,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wDAAwD;IACxD,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC9C,kHAAkH;IAClH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,oBAAoB,CAAC;IAC5B,wDAAwD;IACxD,OAAO,EAAE,OAAO,CAAC;IACjB,iFAAiF;IACjF,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACtC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAID,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,SAAiB,EAAE,WAAW,EAAE,OAAO,EAAE,YAAoB,EAAE,GAAE,sBAA2B,GAAG,eAAe,CAkC1J;AAED,MAAM,WAAW,WAAW;IAC1B,yGAAyG;IACzG,KAAK,EAAE,MAAM,MAAM,OAAO,CAAC;IAC3B,kFAAkF;IAClF,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAsB5C"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useReducedMotionConfig } from 'motion/react';
|
|
4
|
+
import { useInViewport, usePageVisible } from './visibility.js';
|
|
5
|
+
const noRef = { current: null };
|
|
6
|
+
export function useMotionLifecycle({ active, autoStart = false, viewportRef, reduced: forceReduced = false } = {}) {
|
|
7
|
+
const [requested, setRequested] = React.useState(autoStart);
|
|
8
|
+
const [everStarted, setEverStarted] = React.useState(autoStart);
|
|
9
|
+
const [manualPause, setManualPause] = React.useState(false);
|
|
10
|
+
const visible = usePageVisible();
|
|
11
|
+
const inView = useInViewport(viewportRef ?? noRef);
|
|
12
|
+
const reduced = useReducedMotionConfig() === true || forceReduced;
|
|
13
|
+
const isRequested = active ?? requested;
|
|
14
|
+
const started = active === undefined ? everStarted : everStarted || active;
|
|
15
|
+
if (active && !everStarted)
|
|
16
|
+
setEverStarted(true);
|
|
17
|
+
let pauseReason = null;
|
|
18
|
+
if (isRequested) {
|
|
19
|
+
if (reduced)
|
|
20
|
+
pauseReason = 'reduced';
|
|
21
|
+
else if (manualPause)
|
|
22
|
+
pauseReason = 'manual';
|
|
23
|
+
else if (!visible)
|
|
24
|
+
pauseReason = 'hidden';
|
|
25
|
+
else if (viewportRef && !inView)
|
|
26
|
+
pauseReason = 'offscreen';
|
|
27
|
+
}
|
|
28
|
+
const state = !isRequested ? (started ? 'stopped' : 'idle') : pauseReason ? 'paused' : 'running';
|
|
29
|
+
const start = React.useCallback(() => {
|
|
30
|
+
setRequested(true);
|
|
31
|
+
setEverStarted(true);
|
|
32
|
+
setManualPause(false);
|
|
33
|
+
}, []);
|
|
34
|
+
const stop = React.useCallback(() => {
|
|
35
|
+
setRequested(false);
|
|
36
|
+
setManualPause(false);
|
|
37
|
+
}, []);
|
|
38
|
+
const pause = React.useCallback(() => setManualPause(true), []);
|
|
39
|
+
const resume = React.useCallback(() => setManualPause(false), []);
|
|
40
|
+
return { state, running: state === 'running', pauseReason, start, pause, resume, stop };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Stale async result guard (MOTION.md lifecycle rule 2): a late response must not reopen a dialog
|
|
44
|
+
* or overwrite newer state.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* const guard = useLatestGuard();
|
|
48
|
+
* const isCurrent = guard.begin();
|
|
49
|
+
* const data = await load();
|
|
50
|
+
* if (!isCurrent()) return;
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export function useLatestGuard() {
|
|
54
|
+
const generation = React.useRef(0);
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
// Re-arm after StrictMode's simulated unmount; invalidate on the real one.
|
|
57
|
+
generation.current += 1;
|
|
58
|
+
return () => {
|
|
59
|
+
generation.current += 1;
|
|
60
|
+
};
|
|
61
|
+
}, []);
|
|
62
|
+
return React.useMemo(() => ({
|
|
63
|
+
begin: () => {
|
|
64
|
+
generation.current += 1;
|
|
65
|
+
const mine = generation.current;
|
|
66
|
+
return () => generation.current === mine;
|
|
67
|
+
},
|
|
68
|
+
cancel: () => {
|
|
69
|
+
generation.current += 1;
|
|
70
|
+
},
|
|
71
|
+
}), []);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/motion/lifecycle.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAkChE,MAAM,KAAK,GAAoC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AA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E,GAAG,EAAE;YACV,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;YACxB,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC;YAChC,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,KAAK,IAAI,CAAC;QAC3C,CAAC;QACD,MAAM,EAAE,GAAG,EAAE;YACX,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC,EACF,EAAE,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Variants } from 'motion/react';
|
|
3
|
+
type MotionConflictingProps = 'onDrag' | 'onDragStart' | 'onDragEnd' | 'onAnimationStart' | 'onAnimationEnd' | 'onAnimationIteration';
|
|
4
|
+
type ElementProps = Omit<React.HTMLAttributes<HTMLElement>, MotionConflictingProps | 'children'>;
|
|
5
|
+
declare const tags: {
|
|
6
|
+
readonly div: import("motion/react").ForwardRefComponent<HTMLDivElement, import("motion/react").HTMLMotionProps<"div">>;
|
|
7
|
+
readonly section: import("motion/react").ForwardRefComponent<HTMLElement, import("motion/react").HTMLMotionProps<"section">>;
|
|
8
|
+
readonly span: import("motion/react").ForwardRefComponent<HTMLSpanElement, import("motion/react").HTMLMotionProps<"span">>;
|
|
9
|
+
readonly ul: import("motion/react").ForwardRefComponent<HTMLUListElement, import("motion/react").HTMLMotionProps<"ul">>;
|
|
10
|
+
readonly ol: import("motion/react").ForwardRefComponent<HTMLOListElement, import("motion/react").HTMLMotionProps<"ol">>;
|
|
11
|
+
readonly li: import("motion/react").ForwardRefComponent<HTMLLIElement, import("motion/react").HTMLMotionProps<"li">>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* - `fade`: opacity only, `fast` — tooltips, inline status swaps.
|
|
15
|
+
* - `panel`: opacity + 8px rise, `panel` — detail layers, dialogs, sheets.
|
|
16
|
+
* - `rise`: opacity + 4px rise, `base` — list items, inline feedback.
|
|
17
|
+
*/
|
|
18
|
+
export type MotionPresencePreset = 'fade' | 'panel' | 'rise';
|
|
19
|
+
/** Variants for one preset. Reduced motion drops the offset and keeps a short opacity fade. */
|
|
20
|
+
export declare function presenceVariants(preset: MotionPresencePreset, reduced: boolean, speed?: number): Variants;
|
|
21
|
+
export type MotionPresenceProps = ElementProps & {
|
|
22
|
+
/** Mount (true) or animate out and unmount (false). */
|
|
23
|
+
show: boolean;
|
|
24
|
+
preset?: MotionPresencePreset;
|
|
25
|
+
/** Animate on first render too. Off by default: content present at load just appears. */
|
|
26
|
+
initial?: boolean;
|
|
27
|
+
/** Element rendered for the animated wrapper. */
|
|
28
|
+
as?: keyof typeof tags;
|
|
29
|
+
/** Fires after the exit animation, once the content has unmounted. */
|
|
30
|
+
onExitComplete?: () => void;
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Enter / exit wrapper over `AnimatePresence`. Toggling `show` mid-flight reverses from the
|
|
35
|
+
* current visual state (no queued animations). Hidden content is unmounted, so it never lingers
|
|
36
|
+
* in the accessibility tree.
|
|
37
|
+
*/
|
|
38
|
+
export declare function MotionPresence({ show, preset, initial, as, onExitComplete, children, ...rest }: MotionPresenceProps): React.JSX.Element;
|
|
39
|
+
/** Per-item stagger step and total cap (MOTION.md: 20–30ms per item, capped). */
|
|
40
|
+
export declare const staggerStepMs = 24;
|
|
41
|
+
export declare const staggerMaxMs: number;
|
|
42
|
+
/** Delay (seconds) for the item at `index`. Zero under reduced motion. */
|
|
43
|
+
export declare function staggerDelay(index: number, reduced: boolean, speed?: number): number;
|
|
44
|
+
export type RhineMotionGroupProps = ElementProps & {
|
|
45
|
+
/** Mount (true) with staggered items, or fade the whole group out and unmount (false). */
|
|
46
|
+
show?: boolean;
|
|
47
|
+
/** Item preset. */
|
|
48
|
+
preset?: 'fade' | 'rise';
|
|
49
|
+
/** Animate on first render too. Off by default. */
|
|
50
|
+
initial?: boolean;
|
|
51
|
+
as?: 'div' | 'section' | 'ul' | 'ol';
|
|
52
|
+
onExitComplete?: () => void;
|
|
53
|
+
/** `RhineMotionItem` children; their order sets the stagger. */
|
|
54
|
+
children?: React.ReactNode;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Staggered entrance for a short group (≤ ~8 items). Item n waits n × 24ms, capped at the
|
|
58
|
+
* `fast` token (120ms) so long lists never trickle in; reduced motion removes the stagger and
|
|
59
|
+
* the offset. Exit is one group fade, never a reverse cascade.
|
|
60
|
+
*/
|
|
61
|
+
export declare function RhineMotionGroup({ show, preset, initial, as, onExitComplete, children, ...rest }: RhineMotionGroupProps): React.JSX.Element;
|
|
62
|
+
export type RhineMotionItemProps = ElementProps & {
|
|
63
|
+
as?: 'div' | 'li' | 'span';
|
|
64
|
+
children?: React.ReactNode;
|
|
65
|
+
};
|
|
66
|
+
/** One staggered item; must be a direct child of `RhineMotionGroup`. */
|
|
67
|
+
export declare function RhineMotionItem({ as, children, ...rest }: RhineMotionItemProps): React.JSX.Element;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../src/motion/presence.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAc,QAAQ,EAAE,MAAM,cAAc,CAAC;AAYzD,KAAK,sBAAsB,GACvB,QAAQ,GACR,aAAa,GACb,WAAW,GACX,kBAAkB,GAClB,gBAAgB,GAChB,sBAAsB,CAAC;AAE3B,KAAK,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,sBAAsB,GAAG,UAAU,CAAC,CAAC;AAEjG,QAAA,MAAM,IAAI;;;;;;;CAOA,CAAC;AAEX;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,OAAO,GAAG,MA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AK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,IAAW,EACX,MAAe,EACf,OAAe,EACf,EAAU,EACV,cAAc,EACd,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,qBAAqB,qBAyBvB;AAED,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG;IAChD,EAAE,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,EAAE,EAAU,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,oBAAoB,qBAwBtF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createElement as _createElement } from "react";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
6
|
+
import { duration } from './presets.js';
|
|
7
|
+
import { resolveMotion } from './resolve.js';
|
|
8
|
+
import { useRhineMotion } from './useRhineMotion.js';
|
|
9
|
+
const tags = {
|
|
10
|
+
div: motion.div,
|
|
11
|
+
section: motion.section,
|
|
12
|
+
span: motion.span,
|
|
13
|
+
ul: motion.ul,
|
|
14
|
+
ol: motion.ol,
|
|
15
|
+
li: motion.li,
|
|
16
|
+
};
|
|
17
|
+
const presenceSpec = {
|
|
18
|
+
fade: { name: 'fast', offset: 0 },
|
|
19
|
+
panel: { name: 'panel', offset: 8 },
|
|
20
|
+
rise: { name: 'base', offset: 4 },
|
|
21
|
+
};
|
|
22
|
+
/** Variants for one preset. Reduced motion drops the offset and keeps a short opacity fade. */
|
|
23
|
+
export function presenceVariants(preset, reduced, speed = 1) {
|
|
24
|
+
const { name, offset } = presenceSpec[preset];
|
|
25
|
+
const y = reduced ? 0 : offset;
|
|
26
|
+
const opacity = resolveMotion('opacity', name, reduced, speed);
|
|
27
|
+
const move = resolveMotion('transform', name, reduced, speed);
|
|
28
|
+
const both = { opacity, y: move };
|
|
29
|
+
return {
|
|
30
|
+
hidden: { opacity: 0, y, transition: both },
|
|
31
|
+
visible: { opacity: 1, y: 0, transition: both },
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Enter / exit wrapper over `AnimatePresence`. Toggling `show` mid-flight reverses from the
|
|
36
|
+
* current visual state (no queued animations). Hidden content is unmounted, so it never lingers
|
|
37
|
+
* in the accessibility tree.
|
|
38
|
+
*/
|
|
39
|
+
export function MotionPresence({ show, preset = 'fade', initial = false, as = 'div', onExitComplete, children, ...rest }) {
|
|
40
|
+
const { reduced, speed } = useRhineMotion();
|
|
41
|
+
const variants = presenceVariants(preset, reduced, speed);
|
|
42
|
+
const Comp = tags[as];
|
|
43
|
+
return (_jsx(AnimatePresence, { initial: initial, onExitComplete: onExitComplete, children: show && (_createElement(Comp, { ...rest, key: "rl-presence", "data-rl-presence": preset, variants: variants, initial: "hidden", animate: "visible", exit: "hidden" }, children)) }));
|
|
44
|
+
}
|
|
45
|
+
/** Per-item stagger step and total cap (MOTION.md: 20–30ms per item, capped). */
|
|
46
|
+
export const staggerStepMs = 24;
|
|
47
|
+
export const staggerMaxMs = duration.fast * 1000;
|
|
48
|
+
/** Delay (seconds) for the item at `index`. Zero under reduced motion. */
|
|
49
|
+
export function staggerDelay(index, reduced, speed = 1) {
|
|
50
|
+
if (reduced || index <= 0)
|
|
51
|
+
return 0;
|
|
52
|
+
return Math.min(index * staggerStepMs, staggerMaxMs) / 1000 / speed;
|
|
53
|
+
}
|
|
54
|
+
const GroupContext = React.createContext(null);
|
|
55
|
+
const ItemIndexContext = React.createContext(0);
|
|
56
|
+
/**
|
|
57
|
+
* Staggered entrance for a short group (≤ ~8 items). Item n waits n × 24ms, capped at the
|
|
58
|
+
* `fast` token (120ms) so long lists never trickle in; reduced motion removes the stagger and
|
|
59
|
+
* the offset. Exit is one group fade, never a reverse cascade.
|
|
60
|
+
*/
|
|
61
|
+
export function RhineMotionGroup({ show = true, preset = 'rise', initial = false, as = 'div', onExitComplete, children, ...rest }) {
|
|
62
|
+
const { reduced, speed } = useRhineMotion();
|
|
63
|
+
const Comp = tags[as];
|
|
64
|
+
const fadeOut = resolveMotion('opacity', 'fast', reduced, speed);
|
|
65
|
+
const container = {
|
|
66
|
+
hidden: { opacity: 1 },
|
|
67
|
+
visible: { opacity: 1 },
|
|
68
|
+
exit: { opacity: 0, transition: fadeOut },
|
|
69
|
+
};
|
|
70
|
+
const value = React.useMemo(() => ({ preset }), [preset]);
|
|
71
|
+
let index = 0;
|
|
72
|
+
const items = React.Children.map(children, (child) => {
|
|
73
|
+
if (!React.isValidElement(child))
|
|
74
|
+
return child;
|
|
75
|
+
const i = index++;
|
|
76
|
+
return _jsx(ItemIndexContext.Provider, { value: i, children: child });
|
|
77
|
+
});
|
|
78
|
+
return (_jsx(AnimatePresence, { initial: initial, onExitComplete: onExitComplete, children: show && (_createElement(Comp, { ...rest, key: "rl-group", "data-rl-motion-group": "", variants: container, initial: "hidden", animate: "visible", exit: "exit" },
|
|
79
|
+
_jsx(GroupContext.Provider, { value: value, children: items }))) }));
|
|
80
|
+
}
|
|
81
|
+
/** One staggered item; must be a direct child of `RhineMotionGroup`. */
|
|
82
|
+
export function RhineMotionItem({ as = 'div', children, ...rest }) {
|
|
83
|
+
const group = React.useContext(GroupContext);
|
|
84
|
+
const index = React.useContext(ItemIndexContext);
|
|
85
|
+
const { reduced, speed } = useRhineMotion();
|
|
86
|
+
const Comp = tags[as];
|
|
87
|
+
const base = presenceVariants(group?.preset ?? 'rise', reduced, speed);
|
|
88
|
+
const delay = staggerDelay(index, reduced, speed);
|
|
89
|
+
const visible = base.visible;
|
|
90
|
+
const variants = {
|
|
91
|
+
hidden: base.hidden,
|
|
92
|
+
visible: {
|
|
93
|
+
...visible,
|
|
94
|
+
transition: {
|
|
95
|
+
opacity: { ...visible.transition.opacity, delay },
|
|
96
|
+
y: { ...visible.transition.y, delay },
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
exit: {},
|
|
100
|
+
};
|
|
101
|
+
return (_jsx(Comp, { ...rest, "data-rl-motion-item": index, variants: variants, children: children }));
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=presence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.js","sourceRoot":"","sources":["../../src/motion/presence.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAkBrD,MAAM,IAAI,GAAG;IACX,GAAG,EAAE,MAAM,CAAC,GAAG;IACf,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,IAAI,EAAE,MAAM,CAAC,IAAI;IACjB,EAAE,EAAE,MAAM,CAAC,EAAE;IACb,EAAE,EAAE,MAAM,CAAC,EAAE;IACb,EAAE,EAAE,MAAM,CAAC,EAAE;CACL,CAAC;AASX,MAAM,YAAY,GAAgF;IAChG,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE;IACjC,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE;IACnC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE;CAClC,CAAC;AAEF,+FAA+F;AAC/F,MAAM,UAAU,gBAAgB,CAAC,MAA4B,EAAE,OAAgB,EAAE,KAAK,GAAG,CAAC;IACxF,MAAM,EAAE,IA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AAC;IAC3C,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAiF,CAAC;IACvG,MAAM,QAAQ,GAAa;QACzB,MAAM,EAAE,IAAI,CAAC,MAAO;QACpB,OAAO,EAAE;YACP,GAAG,OAAO;YACV,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE;gBACjD,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE;aACtC;SACF;QACD,IAAI,EAAE,EAAE;KACT,CAAC;IACF,OAAO,CACL,KAAC,IAAI,OAAK,IAAI,yBAAuB,KAAK,EAAE,QAAQ,EAAE,QAAQ,YAC3D,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { MotionDurationName } from '@wzrhine/tokens';
|
|
2
|
+
/** Duration tokens in seconds, derived from the shared token manifest. */
|
|
3
|
+
export declare const duration: Record<MotionDurationName, number>;
|
|
4
|
+
export declare const ease: {
|
|
5
|
+
readonly out: [number, number, number, number];
|
|
6
|
+
readonly inOut: [number, number, number, number];
|
|
7
|
+
readonly linear: "linear";
|
|
8
|
+
};
|
|
9
|
+
/** Named transitions. Components import these instead of writing their own numbers. */
|
|
10
|
+
export declare const transition: {
|
|
11
|
+
readonly press: {
|
|
12
|
+
readonly duration: number;
|
|
13
|
+
readonly ease: [number, number, number, number];
|
|
14
|
+
};
|
|
15
|
+
readonly release: {
|
|
16
|
+
readonly duration: number;
|
|
17
|
+
readonly ease: [number, number, number, number];
|
|
18
|
+
};
|
|
19
|
+
readonly fast: {
|
|
20
|
+
readonly duration: number;
|
|
21
|
+
readonly ease: [number, number, number, number];
|
|
22
|
+
};
|
|
23
|
+
readonly base: {
|
|
24
|
+
readonly duration: number;
|
|
25
|
+
readonly ease: [number, number, number, number];
|
|
26
|
+
};
|
|
27
|
+
readonly panel: {
|
|
28
|
+
readonly duration: number;
|
|
29
|
+
readonly ease: [number, number, number, number];
|
|
30
|
+
};
|
|
31
|
+
readonly scene: {
|
|
32
|
+
readonly duration: number;
|
|
33
|
+
readonly ease: [number, number, number, number];
|
|
34
|
+
};
|
|
35
|
+
/** User-triggered showcase scenes only (MOTION.md); never on a base component. */
|
|
36
|
+
readonly showcase: {
|
|
37
|
+
readonly duration: number;
|
|
38
|
+
readonly ease: [number, number, number, number];
|
|
39
|
+
};
|
|
40
|
+
readonly loop: {
|
|
41
|
+
readonly duration: number;
|
|
42
|
+
readonly ease: "linear";
|
|
43
|
+
readonly repeat: number;
|
|
44
|
+
};
|
|
45
|
+
readonly instant: {
|
|
46
|
+
readonly duration: 0;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/** Press feedback: ≤1.5% scale, no layout shift, no hit-area change. */
|
|
50
|
+
export declare const pressScale = 0.985;
|
|
51
|
+
/** Short presence fade used by inline feedback (spinner, status swap). */
|
|
52
|
+
export declare const fadePresence: {
|
|
53
|
+
readonly initial: {
|
|
54
|
+
readonly opacity: 0;
|
|
55
|
+
};
|
|
56
|
+
readonly animate: {
|
|
57
|
+
readonly opacity: 1;
|
|
58
|
+
};
|
|
59
|
+
readonly exit: {
|
|
60
|
+
readonly opacity: 0;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/motion/presets.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,0EAA0E;AAC1E,eAAO,MAAM,QAAQ,EAEhB,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAExC,eAAO,MAAM,IAAI;kBACgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;oBAC5B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;;CAE3D,CAAC;AAEX,uFAAuF;AACvF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;IAOrB,kFAAkF;;;;;;;;;;;;;CAIrC,CAAC;AAEhD,wEAAwE;AACxE,eAAO,MAAM,UAAU,QAAQ,CAAC;AAEhC,0EAA0E;AAC1E,eAAO,MAAM,YAAY;;;;;;;;;;CAIf,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { motionDurations, motionEasings, motionLoopMs } from '@wzrhine/tokens';
|
|
2
|
+
/** Duration tokens in seconds, derived from the shared token manifest. */
|
|
3
|
+
export const duration = Object.fromEntries(Object.entries(motionDurations).map(([name, ms]) => [name, ms / 1000]));
|
|
4
|
+
export const ease = {
|
|
5
|
+
out: [...motionEasings.out],
|
|
6
|
+
inOut: [...motionEasings.inOut],
|
|
7
|
+
linear: 'linear',
|
|
8
|
+
};
|
|
9
|
+
/** Named transitions. Components import these instead of writing their own numbers. */
|
|
10
|
+
export const transition = {
|
|
11
|
+
press: { duration: duration.press, ease: ease.out },
|
|
12
|
+
release: { duration: duration.fast, ease: ease.out },
|
|
13
|
+
fast: { duration: duration.fast, ease: ease.out },
|
|
14
|
+
base: { duration: duration.base, ease: ease.out },
|
|
15
|
+
panel: { duration: duration.panel, ease: ease.out },
|
|
16
|
+
scene: { duration: duration.scene, ease: ease.inOut },
|
|
17
|
+
/** User-triggered showcase scenes only (MOTION.md); never on a base component. */
|
|
18
|
+
showcase: { duration: duration.showcase, ease: ease.inOut },
|
|
19
|
+
loop: { duration: motionLoopMs / 1000, ease: 'linear', repeat: Infinity },
|
|
20
|
+
instant: { duration: 0 },
|
|
21
|
+
};
|
|
22
|
+
/** Press feedback: ≤1.5% scale, no layout shift, no hit-area change. */
|
|
23
|
+
export const pressScale = 0.985;
|
|
24
|
+
/** Short presence fade used by inline feedback (spinner, status swap). */
|
|
25
|
+
export const fadePresence = {
|
|
26
|
+
initial: { opacity: 0 },
|
|
27
|
+
animate: { opacity: 1 },
|
|
28
|
+
exit: { opacity: 0 },
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=presets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../../src/motion/presets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CACxC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,CACjC,CAAC;AAExC,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,GAAG,EAAE,CAAC,GAAG,aAAa,CAAC,GAAG,CAAqC;IAC/D,KAAK,EAAE,CAAC,GAAG,aAAa,CAAC,KAAK,CAAqC;IACnE,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX,uFAAuF;AACvF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;IACnD,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;IACpD,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;IACjD,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;IACjD,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;IACnD,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE;IACrD,kFAAkF;IAClF,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE;IAC3D,IAAI,EAAE,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE;IACzE,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE;CACqB,CAAC;AAEhD,wEAAwE;AACxE,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAEhC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IACvB,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IACvB,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;CACZ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Transition } from 'motion/react';
|
|
3
|
+
import { transition } from './presets.js';
|
|
4
|
+
/** Named preset keys (`instant` … `showcase`, plus `press`/`release`/`loop`). */
|
|
5
|
+
export type RhineTransitionName = keyof typeof transition;
|
|
6
|
+
/**
|
|
7
|
+
* What a transition animates. Reduced motion degrades by kind (ADR-0007):
|
|
8
|
+
* - `color` / `opacity`: keep a short fade, never longer than `fast`;
|
|
9
|
+
* - `transform` / `layout`: jump straight to the target;
|
|
10
|
+
* - `loop`: stop (instant, no repeat).
|
|
11
|
+
*/
|
|
12
|
+
export type MotionPropertyKind = 'color' | 'opacity' | 'transform' | 'layout' | 'loop';
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a named preset for one kind of property. Pure: pass `reduced` from `useRhineMotion()`
|
|
15
|
+
* (or use its `resolve`, which does this for you). `speed` < 1 slows the result down (showcase review only);
|
|
16
|
+
* it never lengthens the reduced fallback, which stays within the `fast` token.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveMotion(kind: MotionPropertyKind, name: RhineTransitionName, reduced: boolean, speed?: number): Transition;
|
|
19
|
+
export interface MotionSpeedProps {
|
|
20
|
+
/** 0.25 = four times slower. Values ≤ 0 are ignored. */
|
|
21
|
+
speed: number;
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Slows every `useRhineMotion()` transition in this subtree. Review and showcase only
|
|
26
|
+
* (e.g. the motion player's Slow ×0.25 lane); never ship it in a product view.
|
|
27
|
+
*/
|
|
28
|
+
export declare function MotionSpeed({ speed, children }: MotionSpeedProps): React.JSX.Element;
|
|
29
|
+
/** Current review speed (1 outside a `MotionSpeed`). */
|
|
30
|
+
export declare function useMotionSpeed(): number;
|
|
31
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/motion/resolve.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAkB,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1D,iFAAiF;AACjF,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,UAAU,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AASvF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,UAAU,CAU1H;AAID,MAAM,WAAW,gBAAgB;IAC/B,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,gBAAgB,qBAEhE;AAED,wDAAwD;AACxD,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { duration, ease, transition } from './presets.js';
|
|
5
|
+
function scaleTransition(t, speed) {
|
|
6
|
+
if (speed === 1 || !t.duration)
|
|
7
|
+
return t;
|
|
8
|
+
return { ...t, duration: t.duration / speed };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a named preset for one kind of property. Pure: pass `reduced` from `useRhineMotion()`
|
|
12
|
+
* (or use its `resolve`, which does this for you). `speed` < 1 slows the result down (showcase review only);
|
|
13
|
+
* it never lengthens the reduced fallback, which stays within the `fast` token.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveMotion(kind, name, reduced, speed = 1) {
|
|
16
|
+
const preset = transition[name];
|
|
17
|
+
if (!reduced)
|
|
18
|
+
return scaleTransition(preset, speed);
|
|
19
|
+
if (kind === 'color' || kind === 'opacity') {
|
|
20
|
+
const ms = Math.min(preset.duration ?? 0, duration.fast);
|
|
21
|
+
if (ms === 0 || 'repeat' in preset)
|
|
22
|
+
return transition.instant;
|
|
23
|
+
// Review speed never stretches the reduced fallback: reduce wins over Slow ×0.25.
|
|
24
|
+
return { duration: ms, ease: ease.out };
|
|
25
|
+
}
|
|
26
|
+
return transition.instant;
|
|
27
|
+
}
|
|
28
|
+
const MotionSpeedContext = React.createContext(1);
|
|
29
|
+
/**
|
|
30
|
+
* Slows every `useRhineMotion()` transition in this subtree. Review and showcase only
|
|
31
|
+
* (e.g. the motion player's Slow ×0.25 lane); never ship it in a product view.
|
|
32
|
+
*/
|
|
33
|
+
export function MotionSpeed({ speed, children }) {
|
|
34
|
+
return _jsx(MotionSpeedContext.Provider, { value: speed > 0 ? speed : 1, children: children });
|
|
35
|
+
}
|
|
36
|
+
/** Current review speed (1 outside a `MotionSpeed`). */
|
|
37
|
+
export function useMotionSpeed() {
|
|
38
|
+
return React.useContext(MotionSpeedContext);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/motion/resolve.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAe1D,SAAS,eAAe,CAAC,CAAkB,EAAE,KAAa;IACxD,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ;QAAE,OAAO,CAAC,CAAC;IACzC,OAAO,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,GAAG,KAAK,EAAE,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAwB,EAAE,IAAyB,EAAE,OAAgB,EAAE,KAAK,GAAG,CAAC;IAC5G,MAAM,MAAM,GAAoB,UAAU,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,CAAC,OAAO;QAAE,OAAO,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACpD,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,EAAE,KAAK,CAAC,IAAI,QAAQ,IAAI,MAAM;YAAE,OAAO,UAAU,CAAC,OAAO,CAAC;QAC9D,kFAAkF;QAClF,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,CAAC;AAC5B,CAAC;AAED,MAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;AAQlD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAoB;IAC/D,OAAO,KAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAG,QAAQ,GAA+B,CAAC;AAC7G,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,cAAc;IAC5B,OAAO,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Transition } from 'motion/react';
|
|
2
|
+
import type { MotionPropertyKind, RhineTransitionName } from './resolve.js';
|
|
3
|
+
export type { RhineTransitionName } from './resolve.js';
|
|
4
|
+
export interface RhineMotion {
|
|
5
|
+
/** True when the OS preference or the nearest `<MotionConfig reducedMotion>` asks for reduced motion. */
|
|
6
|
+
reduced: boolean;
|
|
7
|
+
/** Review speed from the nearest `MotionSpeed` (1 by default). */
|
|
8
|
+
speed: number;
|
|
9
|
+
/** Returns the named preset, or an instant transition when motion is reduced. */
|
|
10
|
+
get: (name: RhineTransitionName) => Transition;
|
|
11
|
+
/** Returns the named preset degraded for one property kind (ADR-0007): colour / opacity keep a short fade. */
|
|
12
|
+
resolve: (kind: MotionPropertyKind, name: RhineTransitionName) => Transition;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Single entry point for component motion. Honours `<MotionConfig reducedMotion="user" | "always" | "never">`
|
|
16
|
+
* so apps (and the showcase) can force either mode.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useRhineMotion(): RhineMotion;
|
|
19
|
+
//# sourceMappingURL=useRhineMotion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRhineMotion.d.ts","sourceRoot":"","sources":["../../src/motion/useRhineMotion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE5E,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B,yGAAyG;IACzG,OAAO,EAAE,OAAO,CAAC;IACjB,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,GAAG,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,UAAU,CAAC;IAC/C,8GAA8G;IAC9G,OAAO,EAAE,CAAC,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,mBAAmB,KAAK,UAAU,CAAC;CAC9E;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAS5C"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useReducedMotionConfig } from 'motion/react';
|
|
3
|
+
import { transition } from './presets.js';
|
|
4
|
+
import { resolveMotion, useMotionSpeed } from './resolve.js';
|
|
5
|
+
/**
|
|
6
|
+
* Single entry point for component motion. Honours `<MotionConfig reducedMotion="user" | "always" | "never">`
|
|
7
|
+
* so apps (and the showcase) can force either mode.
|
|
8
|
+
*/
|
|
9
|
+
export function useRhineMotion() {
|
|
10
|
+
const reduced = useReducedMotionConfig() === true;
|
|
11
|
+
const speed = useMotionSpeed();
|
|
12
|
+
return {
|
|
13
|
+
reduced,
|
|
14
|
+
speed,
|
|
15
|
+
get: (name) => (reduced ? transition.instant : resolveMotion('transform', name, false, speed)),
|
|
16
|
+
resolve: (kind, name) => resolveMotion(kind, name, reduced, speed),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=useRhineMotion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRhineMotion.js","sourceRoot":"","sources":["../../src/motion/useRhineMotion.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAgB7D;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,sBAAsB,EAAE,KAAK,IAAI,CAAC;IAClD,MAAM,KAAK,GAAG,cAAc,EAAE,CAAC;IAC/B,OAAO;QACL,OAAO;QACP,KAAK;QACL,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9F,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC;KACnE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/** True while the document is visible. Loops must pause when it turns false (MOTION.md lifecycle rule 4). */
|
|
3
|
+
export declare function usePageVisible(): boolean;
|
|
4
|
+
/** True while the element intersects the viewport. Treated as visible where IntersectionObserver is unavailable. */
|
|
5
|
+
export declare function useInViewport<T extends Element>(ref: React.RefObject<T | null>): boolean;
|
|
6
|
+
//# sourceMappingURL=visibility.d.ts.map
|