@seekalfred/primitives 0.5.1 → 0.7.1
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/README.md +682 -19
- package/dist/accordion/accordion.js +10 -4
- package/dist/accordion/accordion.js.map +1 -1
- package/dist/action-button/action-button.d.ts +50 -0
- package/dist/action-button/action-button.js +159 -0
- package/dist/action-button/action-button.js.map +1 -0
- package/dist/action-button/index.d.ts +2 -0
- package/dist/action-button/index.js +2 -0
- package/dist/activity-heatmap/activity-heatmap.d.ts +92 -0
- package/dist/activity-heatmap/activity-heatmap.js +699 -0
- package/dist/activity-heatmap/activity-heatmap.js.map +1 -0
- package/dist/activity-heatmap/index.d.ts +2 -0
- package/dist/activity-heatmap/index.js +2 -0
- package/dist/alert/alert.d.ts +19 -1
- package/dist/alert/alert.js +180 -23
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert-dialog/alert-dialog.d.ts +45 -18
- package/dist/alert-dialog/alert-dialog.js +128 -9
- package/dist/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/alert-dialog/index.d.ts +2 -2
- package/dist/alert-dialog/index.js +2 -2
- package/dist/animated-counter/animated-counter.d.ts +38 -0
- package/dist/animated-counter/animated-counter.js +230 -0
- package/dist/animated-counter/animated-counter.js.map +1 -0
- package/dist/animated-counter/index.d.ts +2 -0
- package/dist/animated-counter/index.js +2 -0
- package/dist/announcement-bar/announcement-bar.d.ts +67 -0
- package/dist/announcement-bar/announcement-bar.js +364 -0
- package/dist/announcement-bar/announcement-bar.js.map +1 -0
- package/dist/announcement-bar/index.d.ts +2 -0
- package/dist/announcement-bar/index.js +2 -0
- package/dist/avatar/avatar.d.ts +6 -0
- package/dist/avatar/avatar.js +47 -16
- package/dist/avatar/avatar.js.map +1 -1
- package/dist/badge/badge.d.ts +10 -3
- package/dist/badge/badge.js +35 -5
- package/dist/badge/badge.js.map +1 -1
- package/dist/bar-chart/bar-chart.d.ts +51 -0
- package/dist/bar-chart/bar-chart.js +565 -0
- package/dist/bar-chart/bar-chart.js.map +1 -0
- package/dist/bar-chart/index.d.ts +2 -0
- package/dist/bar-chart/index.js +2 -0
- package/dist/breadcrumb/breadcrumb.d.ts +2 -29
- package/dist/breadcrumb/breadcrumb.js +32 -9
- package/dist/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/brush-chart/brush-chart.d.ts +64 -0
- package/dist/brush-chart/brush-chart.js +1056 -0
- package/dist/brush-chart/brush-chart.js.map +1 -0
- package/dist/brush-chart/index.d.ts +2 -0
- package/dist/brush-chart/index.js +2 -0
- package/dist/button/button.d.ts +36 -23
- package/dist/button/button.js +198 -45
- package/dist/button/button.js.map +1 -1
- package/dist/button-group/button-group.d.ts +76 -0
- package/dist/button-group/button-group.js +402 -0
- package/dist/button-group/button-group.js.map +1 -0
- package/dist/button-group/index.d.ts +2 -0
- package/dist/button-group/index.js +2 -0
- package/dist/calendar/calendar.d.ts +1 -1
- package/dist/calendar/calendar.js +257 -30
- package/dist/calendar/calendar.js.map +1 -1
- package/dist/card/card.d.ts +9 -2
- package/dist/card/card.js +16 -5
- package/dist/card/card.js.map +1 -1
- package/dist/card-stack/card-stack.d.ts +54 -0
- package/dist/card-stack/card-stack.js +492 -0
- package/dist/card-stack/card-stack.js.map +1 -0
- package/dist/card-stack/index.d.ts +2 -0
- package/dist/card-stack/index.js +2 -0
- package/dist/carousel/carousel.d.ts +56 -0
- package/dist/carousel/carousel.js +389 -0
- package/dist/carousel/carousel.js.map +1 -0
- package/dist/carousel/index.d.ts +2 -0
- package/dist/carousel/index.js +2 -0
- package/dist/checkbox/checkbox.d.ts +0 -7
- package/dist/checkbox/checkbox.js +26 -29
- package/dist/checkbox/checkbox.js.map +1 -1
- package/dist/chip-group/chip-group.d.ts +37 -0
- package/dist/chip-group/chip-group.js +148 -0
- package/dist/chip-group/chip-group.js.map +1 -0
- package/dist/chip-group/index.d.ts +2 -0
- package/dist/chip-group/index.js +2 -0
- package/dist/confirm-morph/confirm-morph.d.ts +85 -0
- package/dist/confirm-morph/confirm-morph.js +652 -0
- package/dist/confirm-morph/confirm-morph.js.map +1 -0
- package/dist/confirm-morph/index.d.ts +2 -0
- package/dist/confirm-morph/index.js +2 -0
- package/dist/copy-button/copy-button.d.ts +32 -0
- package/dist/copy-button/copy-button.js +134 -0
- package/dist/copy-button/copy-button.js.map +1 -0
- package/dist/copy-button/index.d.ts +2 -0
- package/dist/copy-button/index.js +2 -0
- package/dist/countdown/countdown.d.ts +45 -0
- package/dist/countdown/countdown.js +298 -0
- package/dist/countdown/countdown.js.map +1 -0
- package/dist/countdown/index.d.ts +2 -0
- package/dist/countdown/index.js +2 -0
- package/dist/date-picker/date-picker.d.ts +51 -0
- package/dist/date-picker/date-picker.js +241 -0
- package/dist/date-picker/date-picker.js.map +1 -0
- package/dist/date-picker/date-range-picker.d.ts +78 -0
- package/dist/date-picker/date-range-picker.js +1015 -0
- package/dist/date-picker/date-range-picker.js.map +1 -0
- package/dist/date-picker/index.d.ts +4 -0
- package/dist/date-picker/index.js +4 -0
- package/dist/date-picker/picker-parts.d.ts +46 -0
- package/dist/date-picker/picker-parts.js +135 -0
- package/dist/date-picker/picker-parts.js.map +1 -0
- package/dist/dialog/dialog.d.ts +10 -14
- package/dist/dialog/dialog.js +40 -12
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/donut-chart/donut-chart.d.ts +64 -0
- package/dist/donut-chart/donut-chart.js +576 -0
- package/dist/donut-chart/donut-chart.js.map +1 -0
- package/dist/donut-chart/index.d.ts +2 -0
- package/dist/donut-chart/index.js +2 -0
- package/dist/empty-state/empty-state.d.ts +55 -0
- package/dist/empty-state/empty-state.js +89 -0
- package/dist/empty-state/empty-state.js.map +1 -0
- package/dist/empty-state/index.d.ts +2 -0
- package/dist/empty-state/index.js +2 -0
- package/dist/expanding-button-group/expanding-button-group.d.ts +54 -0
- package/dist/expanding-button-group/expanding-button-group.js +350 -0
- package/dist/expanding-button-group/expanding-button-group.js.map +1 -0
- package/dist/expanding-button-group/index.d.ts +2 -0
- package/dist/expanding-button-group/index.js +2 -0
- package/dist/file-drop-zone/file-drop-zone.d.ts +71 -0
- package/dist/file-drop-zone/file-drop-zone.js +116 -0
- package/dist/file-drop-zone/file-drop-zone.js.map +1 -0
- package/dist/file-drop-zone/index.d.ts +2 -0
- package/dist/file-drop-zone/index.js +2 -0
- package/dist/filter-bar/filter-bar.d.ts +142 -0
- package/dist/filter-bar/filter-bar.js +416 -0
- package/dist/filter-bar/filter-bar.js.map +1 -0
- package/dist/filter-bar/index.d.ts +2 -0
- package/dist/filter-bar/index.js +2 -0
- package/dist/floating-button-group/floating-button-group.d.ts +61 -0
- package/dist/floating-button-group/floating-button-group.js +340 -0
- package/dist/floating-button-group/floating-button-group.js.map +1 -0
- package/dist/floating-button-group/index.d.ts +2 -0
- package/dist/floating-button-group/index.js +2 -0
- package/dist/gauge/gauge.d.ts +45 -0
- package/dist/gauge/gauge.js +219 -0
- package/dist/gauge/gauge.js.map +1 -0
- package/dist/gauge/index.d.ts +2 -0
- package/dist/gauge/index.js +2 -0
- package/dist/icon-morph/icon-morph.d.ts +55 -0
- package/dist/icon-morph/icon-morph.js +331 -0
- package/dist/icon-morph/icon-morph.js.map +1 -0
- package/dist/icon-morph/index.d.ts +2 -0
- package/dist/icon-morph/index.js +2 -0
- package/dist/in-view-title/in-view-title.d.ts +33 -0
- package/dist/in-view-title/in-view-title.js +119 -0
- package/dist/in-view-title/in-view-title.js.map +1 -0
- package/dist/in-view-title/index.d.ts +2 -0
- package/dist/in-view-title/index.js +2 -0
- package/dist/index.d.ts +71 -6
- package/dist/index.js +73 -11
- package/dist/input/input.d.ts +22 -0
- package/dist/input/input.js +36 -12
- package/dist/input/input.js.map +1 -1
- package/dist/lib/cn.js +11 -1
- package/dist/lib/cn.js.map +1 -1
- package/dist/lib/count-to.js +113 -0
- package/dist/lib/count-to.js.map +1 -0
- package/dist/lib/eye-morph.js +62 -0
- package/dist/lib/eye-morph.js.map +1 -0
- package/dist/lib/field-message.js +354 -0
- package/dist/lib/field-message.js.map +1 -0
- package/dist/lib/field-shell.js +81 -0
- package/dist/lib/field-shell.js.map +1 -0
- package/dist/lib/field-surface.js +11 -8
- package/dist/lib/field-surface.js.map +1 -1
- package/dist/lib/flag-emoji.js +50 -0
- package/dist/lib/flag-emoji.js.map +1 -0
- package/dist/lib/flip.js +88 -0
- package/dist/lib/flip.js.map +1 -0
- package/dist/lib/height-follow.js +59 -0
- package/dist/lib/height-follow.js.map +1 -0
- package/dist/lib/icon-swap.js +47 -0
- package/dist/lib/icon-swap.js.map +1 -0
- package/dist/lib/leaving-list.js +57 -0
- package/dist/lib/leaving-list.js.map +1 -0
- package/dist/lib/menu-highlight.js +64 -0
- package/dist/lib/menu-highlight.js.map +1 -0
- package/dist/lib/merge-refs.js +3 -3
- package/dist/lib/merge-refs.js.map +1 -1
- package/dist/lib/morph-text.js +128 -0
- package/dist/lib/morph-text.js.map +1 -0
- package/dist/lib/motion.js +169 -0
- package/dist/lib/motion.js.map +1 -0
- package/dist/lib/pausable-timeout.js +67 -0
- package/dist/lib/pausable-timeout.js.map +1 -0
- package/dist/lib/rolling-value.js +31 -0
- package/dist/lib/rolling-value.js.map +1 -0
- package/dist/lib/spring-progress.js +114 -0
- package/dist/lib/spring-progress.js.map +1 -0
- package/dist/lib/spring-tween.js +500 -0
- package/dist/lib/spring-tween.js.map +1 -0
- package/dist/lib/svg-id.js +10 -0
- package/dist/lib/svg-id.js.map +1 -0
- package/dist/lib/swap-text.js +79 -0
- package/dist/lib/swap-text.js.map +1 -0
- package/dist/lib/use-copy-feedback.js +36 -0
- package/dist/lib/use-copy-feedback.js.map +1 -0
- package/dist/line-chart/index.d.ts +2 -0
- package/dist/line-chart/index.js +2 -0
- package/dist/line-chart/line-chart.d.ts +76 -0
- package/dist/line-chart/line-chart.js +611 -0
- package/dist/line-chart/line-chart.js.map +1 -0
- package/dist/mention-input/index.d.ts +2 -0
- package/dist/mention-input/index.js +2 -0
- package/dist/mention-input/mention-input.d.ts +98 -0
- package/dist/mention-input/mention-input.js +576 -0
- package/dist/mention-input/mention-input.js.map +1 -0
- package/dist/menu/menu.d.ts +2 -0
- package/dist/menu/menu.js +23 -12
- package/dist/menu/menu.js.map +1 -1
- package/dist/money-input/index.d.ts +2 -0
- package/dist/money-input/index.js +2 -0
- package/dist/money-input/money-input.d.ts +65 -0
- package/dist/money-input/money-input.js +607 -0
- package/dist/money-input/money-input.js.map +1 -0
- package/dist/morph-select/index.d.ts +2 -0
- package/dist/morph-select/index.js +2 -0
- package/dist/morph-select/morph-select.d.ts +71 -0
- package/dist/morph-select/morph-select.js +693 -0
- package/dist/morph-select/morph-select.js.map +1 -0
- package/dist/multi-select/index.d.ts +2 -0
- package/dist/multi-select/index.js +2 -0
- package/dist/multi-select/multi-select.d.ts +36 -0
- package/dist/multi-select/multi-select.js +152 -0
- package/dist/multi-select/multi-select.js.map +1 -0
- package/dist/number-field/index.d.ts +2 -0
- package/dist/number-field/index.js +2 -0
- package/dist/number-field/number-field.d.ts +42 -0
- package/dist/number-field/number-field.js +199 -0
- package/dist/number-field/number-field.js.map +1 -0
- package/dist/onboarding-checklist/index.d.ts +2 -0
- package/dist/onboarding-checklist/index.js +2 -0
- package/dist/onboarding-checklist/onboarding-checklist.d.ts +55 -0
- package/dist/onboarding-checklist/onboarding-checklist.js +577 -0
- package/dist/onboarding-checklist/onboarding-checklist.js.map +1 -0
- package/dist/page-header/index.d.ts +2 -0
- package/dist/page-header/index.js +2 -0
- package/dist/page-header/page-header.d.ts +75 -0
- package/dist/page-header/page-header.js +83 -0
- package/dist/page-header/page-header.js.map +1 -0
- package/dist/password-field/index.d.ts +2 -0
- package/dist/password-field/index.js +2 -0
- package/dist/password-field/password-field.d.ts +37 -0
- package/dist/password-field/password-field.js +101 -0
- package/dist/password-field/password-field.js.map +1 -0
- package/dist/password-strength/index.d.ts +2 -0
- package/dist/password-strength/index.js +2 -0
- package/dist/password-strength/password-strength.d.ts +127 -0
- package/dist/password-strength/password-strength.js +455 -0
- package/dist/password-strength/password-strength.js.map +1 -0
- package/dist/phone-input/index.d.ts +3 -0
- package/dist/phone-input/index.js +3 -0
- package/dist/phone-input/phone-countries.d.ts +29 -0
- package/dist/phone-input/phone-countries.js +170 -0
- package/dist/phone-input/phone-countries.js.map +1 -0
- package/dist/phone-input/phone-input.d.ts +66 -0
- package/dist/phone-input/phone-input.js +440 -0
- package/dist/phone-input/phone-input.js.map +1 -0
- package/dist/popover/popover.d.ts +20 -0
- package/dist/popover/popover.js +33 -9
- package/dist/popover/popover.js.map +1 -1
- package/dist/progress/progress.js +46 -5
- package/dist/progress/progress.js.map +1 -1
- package/dist/radio-group/radio-group.js +8 -7
- package/dist/radio-group/radio-group.js.map +1 -1
- package/dist/reactions/index.d.ts +2 -0
- package/dist/reactions/index.js +2 -0
- package/dist/reactions/reactions.d.ts +50 -0
- package/dist/reactions/reactions.js +315 -0
- package/dist/reactions/reactions.js.map +1 -0
- package/dist/rich-text-editor/index.d.ts +3 -0
- package/dist/rich-text-editor/index.js +2 -0
- package/dist/rich-text-editor/rich-text-editor.d.ts +70 -0
- package/dist/rich-text-editor/rich-text-editor.js +909 -0
- package/dist/rich-text-editor/rich-text-editor.js.map +1 -0
- package/dist/rich-text-editor/rich-text-engine.d.ts +16 -0
- package/dist/rich-text-editor/rich-text-engine.js +366 -0
- package/dist/rich-text-editor/rich-text-engine.js.map +1 -0
- package/dist/rich-text-editor/rich-text-html.js +174 -0
- package/dist/rich-text-editor/rich-text-html.js.map +1 -0
- package/dist/rich-text-editor/rich-text-icons.js +43 -0
- package/dist/rich-text-editor/rich-text-icons.js.map +1 -0
- package/dist/ridgeline/index.d.ts +2 -0
- package/dist/ridgeline/index.js +2 -0
- package/dist/ridgeline/ridgeline.d.ts +55 -0
- package/dist/ridgeline/ridgeline.js +701 -0
- package/dist/ridgeline/ridgeline.js.map +1 -0
- package/dist/scroll-area/index.d.ts +2 -2
- package/dist/scroll-area/index.js +2 -2
- package/dist/scroll-area/scroll-area.d.ts +75 -28
- package/dist/scroll-area/scroll-area.js +212 -41
- package/dist/scroll-area/scroll-area.js.map +1 -1
- package/dist/scrub-input/evaluate.d.ts +14 -0
- package/dist/scrub-input/evaluate.js +72 -0
- package/dist/scrub-input/evaluate.js.map +1 -0
- package/dist/scrub-input/index.d.ts +3 -0
- package/dist/scrub-input/index.js +3 -0
- package/dist/scrub-input/scrub-input.d.ts +74 -0
- package/dist/scrub-input/scrub-input.js +486 -0
- package/dist/scrub-input/scrub-input.js.map +1 -0
- package/dist/search-field/index.d.ts +2 -0
- package/dist/search-field/index.js +2 -0
- package/dist/search-field/search-field.d.ts +27 -0
- package/dist/search-field/search-field.js +155 -0
- package/dist/search-field/search-field.js.map +1 -0
- package/dist/select/select.d.ts +3 -1
- package/dist/select/select.js +95 -25
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +1 -1
- package/dist/sheet/sheet.js +4 -2
- package/dist/sheet/sheet.js.map +1 -1
- package/dist/shortcut-recorder/index.d.ts +3 -0
- package/dist/shortcut-recorder/index.js +3 -0
- package/dist/shortcut-recorder/shortcut-model.d.ts +27 -0
- package/dist/shortcut-recorder/shortcut-model.js +206 -0
- package/dist/shortcut-recorder/shortcut-model.js.map +1 -0
- package/dist/shortcut-recorder/shortcut-recorder.d.ts +93 -0
- package/dist/shortcut-recorder/shortcut-recorder.js +489 -0
- package/dist/shortcut-recorder/shortcut-recorder.js.map +1 -0
- package/dist/side-nav/index.d.ts +2 -0
- package/dist/side-nav/index.js +2 -0
- package/dist/side-nav/side-nav.d.ts +72 -0
- package/dist/side-nav/side-nav.js +142 -0
- package/dist/side-nav/side-nav.js.map +1 -0
- package/dist/skeleton/skeleton.d.ts +8 -2
- package/dist/skeleton/skeleton.js +6 -2
- package/dist/skeleton/skeleton.js.map +1 -1
- package/dist/slider/index.d.ts +2 -2
- package/dist/slider/slider.d.ts +46 -14
- package/dist/slider/slider.js +188 -50
- package/dist/slider/slider.js.map +1 -1
- package/dist/slope-chart/index.d.ts +2 -0
- package/dist/slope-chart/index.js +2 -0
- package/dist/slope-chart/slope-chart.d.ts +54 -0
- package/dist/slope-chart/slope-chart.js +568 -0
- package/dist/slope-chart/slope-chart.js.map +1 -0
- package/dist/sparkline/index.d.ts +2 -0
- package/dist/sparkline/index.js +2 -0
- package/dist/sparkline/sparkline.d.ts +46 -0
- package/dist/sparkline/sparkline.js +390 -0
- package/dist/sparkline/sparkline.js.map +1 -0
- package/dist/split-bar/index.d.ts +2 -0
- package/dist/split-bar/index.js +2 -0
- package/dist/split-bar/split-bar.d.ts +62 -0
- package/dist/split-bar/split-bar.js +513 -0
- package/dist/split-bar/split-bar.js.map +1 -0
- package/dist/split-button/index.d.ts +2 -0
- package/dist/split-button/index.js +2 -0
- package/dist/split-button/split-button.d.ts +46 -0
- package/dist/split-button/split-button.js +123 -0
- package/dist/split-button/split-button.js.map +1 -0
- package/dist/stat-card/index.d.ts +2 -0
- package/dist/stat-card/index.js +2 -0
- package/dist/stat-card/stat-card.d.ts +101 -0
- package/dist/stat-card/stat-card.js +249 -0
- package/dist/stat-card/stat-card.js.map +1 -0
- package/dist/stepper/index.d.ts +2 -0
- package/dist/stepper/index.js +2 -0
- package/dist/stepper/stepper.d.ts +51 -0
- package/dist/stepper/stepper.js +215 -0
- package/dist/stepper/stepper.js.map +1 -0
- package/dist/streamgraph/index.d.ts +2 -0
- package/dist/streamgraph/index.js +2 -0
- package/dist/streamgraph/streamgraph.d.ts +70 -0
- package/dist/streamgraph/streamgraph.js +613 -0
- package/dist/streamgraph/streamgraph.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/swipe-actions/index.d.ts +2 -0
- package/dist/swipe-actions/index.js +2 -0
- package/dist/swipe-actions/swipe-actions.d.ts +67 -0
- package/dist/swipe-actions/swipe-actions.js +552 -0
- package/dist/swipe-actions/swipe-actions.js.map +1 -0
- package/dist/switch/switch.js +10 -9
- package/dist/switch/switch.js.map +1 -1
- package/dist/table/index.d.ts +2 -2
- package/dist/table/index.js +2 -2
- package/dist/table/table.d.ts +87 -4
- package/dist/table/table.js +441 -165
- package/dist/table/table.js.map +1 -1
- package/dist/tabs/tabs.js +143 -7
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/tag-input/index.d.ts +2 -0
- package/dist/tag-input/index.js +2 -0
- package/dist/tag-input/tag-input.d.ts +40 -0
- package/dist/tag-input/tag-input.js +269 -0
- package/dist/tag-input/tag-input.js.map +1 -0
- package/dist/text-morph/index.d.ts +2 -0
- package/dist/text-morph/index.js +2 -0
- package/dist/text-morph/text-morph.d.ts +23 -0
- package/dist/text-morph/text-morph.js +21 -0
- package/dist/text-morph/text-morph.js.map +1 -0
- package/dist/text-reveal/index.d.ts +2 -0
- package/dist/text-reveal/index.js +2 -0
- package/dist/text-reveal/text-reveal.d.ts +27 -0
- package/dist/text-reveal/text-reveal.js +51 -0
- package/dist/text-reveal/text-reveal.js.map +1 -0
- package/dist/text-shimmer/index.d.ts +2 -0
- package/dist/text-shimmer/index.js +2 -0
- package/dist/text-shimmer/text-shimmer.d.ts +29 -0
- package/dist/text-shimmer/text-shimmer.js +29 -0
- package/dist/text-shimmer/text-shimmer.js.map +1 -0
- package/dist/textarea/textarea.d.ts +23 -0
- package/dist/textarea/textarea.js +24 -2
- package/dist/textarea/textarea.js.map +1 -1
- package/dist/theme-switch/index.d.ts +2 -0
- package/dist/theme-switch/index.js +2 -0
- package/dist/theme-switch/theme-switch.d.ts +37 -0
- package/dist/theme-switch/theme-switch.js +123 -0
- package/dist/theme-switch/theme-switch.js.map +1 -0
- package/dist/time-picker/index.d.ts +2 -0
- package/dist/time-picker/index.js +2 -0
- package/dist/time-picker/time-picker.d.ts +54 -0
- package/dist/time-picker/time-picker.js +201 -0
- package/dist/time-picker/time-picker.js.map +1 -0
- package/dist/toast/index.d.ts +2 -2
- package/dist/toast/index.js +2 -2
- package/dist/toast/toast.d.ts +6 -0
- package/dist/toast/toast.js +98 -36
- package/dist/toast/toast.js.map +1 -1
- package/dist/tooltip/tooltip.d.ts +10 -3
- package/dist/tooltip/tooltip.js +67 -18
- package/dist/tooltip/tooltip.js.map +1 -1
- package/dist/treemap/index.d.ts +2 -0
- package/dist/treemap/index.js +2 -0
- package/dist/treemap/treemap.d.ts +53 -0
- package/dist/treemap/treemap.js +699 -0
- package/dist/treemap/treemap.js.map +1 -0
- package/dist/usage-meter/index.d.ts +2 -0
- package/dist/usage-meter/index.js +2 -0
- package/dist/usage-meter/usage-meter.d.ts +50 -0
- package/dist/usage-meter/usage-meter.js +440 -0
- package/dist/usage-meter/usage-meter.js.map +1 -0
- package/dist/waffle-chart/index.d.ts +2 -0
- package/dist/waffle-chart/index.js +2 -0
- package/dist/waffle-chart/waffle-chart.d.ts +57 -0
- package/dist/waffle-chart/waffle-chart.js +426 -0
- package/dist/waffle-chart/waffle-chart.js.map +1 -0
- package/package.json +245 -3
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
2
|
+
//#region src/lib/motion.ts
|
|
3
|
+
/** useLayoutEffect warns when rendered on the server in React 18, which this package supports; there it falls back to useEffect. */
|
|
4
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
5
|
+
const prefersReducedMotion = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
6
|
+
const subscribeReducedMotion = (notify) => {
|
|
7
|
+
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
8
|
+
query.addEventListener("change", notify);
|
|
9
|
+
return () => query.removeEventListener("change", notify);
|
|
10
|
+
};
|
|
11
|
+
/** Whether the visitor prefers reduced motion, kept current. False on the server and until hydrated. */
|
|
12
|
+
const useReducedMotion = () => useSyncExternalStore(subscribeReducedMotion, prefersReducedMotion, () => false);
|
|
13
|
+
/**
|
|
14
|
+
* Springs the slot to the natural width of the incoming label when it changes,
|
|
15
|
+
* so a new label never snaps the button's size. Only a resize within 700ms of a
|
|
16
|
+
* label change morphs; any other resize (a late web font, a parent reflow),
|
|
17
|
+
* the first measurement and reduced motion jump straight to the new width, so
|
|
18
|
+
* nothing wobbles on first paint. data-morphing turns on the slot's width
|
|
19
|
+
* transition and its clip-path (button-slot).
|
|
20
|
+
*/
|
|
21
|
+
function useMorphWidth(content, key, enabled = true) {
|
|
22
|
+
const lastKey = useRef(key);
|
|
23
|
+
const armedUntil = useRef(0);
|
|
24
|
+
useIsomorphicLayoutEffect(() => {
|
|
25
|
+
if (lastKey.current === key) return;
|
|
26
|
+
lastKey.current = key;
|
|
27
|
+
armedUntil.current = performance.now() + 700;
|
|
28
|
+
}, [key]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const node = content.current;
|
|
31
|
+
const slot = node?.parentElement;
|
|
32
|
+
if (!enabled || !node || !slot || typeof ResizeObserver === "undefined") return;
|
|
33
|
+
let measured = false;
|
|
34
|
+
let settle;
|
|
35
|
+
const done = () => {
|
|
36
|
+
clearTimeout(settle);
|
|
37
|
+
delete slot.dataset.morphing;
|
|
38
|
+
};
|
|
39
|
+
const onEnd = (event) => {
|
|
40
|
+
if (event.target === slot && event.propertyName === "width") done();
|
|
41
|
+
};
|
|
42
|
+
slot.addEventListener("transitionend", onEnd);
|
|
43
|
+
const apply = (next, at) => {
|
|
44
|
+
if (!next || !measured || prefersReducedMotion() || at > armedUntil.current) {
|
|
45
|
+
measured = next > 0;
|
|
46
|
+
slot.style.width = next ? next + "px" : "";
|
|
47
|
+
done();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
slot.dataset.morphing = "";
|
|
51
|
+
slot.style.width = next + "px";
|
|
52
|
+
clearTimeout(settle);
|
|
53
|
+
settle = setTimeout(done, 900);
|
|
54
|
+
};
|
|
55
|
+
let frame = 0;
|
|
56
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
57
|
+
if (!entry) return;
|
|
58
|
+
const next = entry.contentRect.width;
|
|
59
|
+
const at = performance.now();
|
|
60
|
+
cancelAnimationFrame(frame);
|
|
61
|
+
frame = requestAnimationFrame(() => apply(next, at));
|
|
62
|
+
});
|
|
63
|
+
observer.observe(node);
|
|
64
|
+
return () => {
|
|
65
|
+
cancelAnimationFrame(frame);
|
|
66
|
+
observer.disconnect();
|
|
67
|
+
slot.removeEventListener("transitionend", onEnd);
|
|
68
|
+
clearTimeout(settle);
|
|
69
|
+
};
|
|
70
|
+
}, [content, enabled]);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Runs remove after a backstop delay, in case an exit animation never ends (a
|
|
74
|
+
* consumer who disables animation). The delay must outlast the animation:
|
|
75
|
+
* 600ms covers the quick exits, a spring that settles in 736ms needs more.
|
|
76
|
+
*/
|
|
77
|
+
function useExitBackstop(active, remove, delay = 600) {
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!active) return;
|
|
80
|
+
const timer = setTimeout(remove, delay);
|
|
81
|
+
return () => clearTimeout(timer);
|
|
82
|
+
}, [
|
|
83
|
+
active,
|
|
84
|
+
remove,
|
|
85
|
+
delay
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
/** A press goes a little deeper on an icon button and a little less on a wide one, so every size reads as the same push. */
|
|
89
|
+
function pressScaleFor(width) {
|
|
90
|
+
return width > 220 ? "0.985" : width && width <= 48 ? "0.96" : "0.97";
|
|
91
|
+
}
|
|
92
|
+
/** True for a trigger that anchors a menu, popover or dialog; those never scale. */
|
|
93
|
+
function anchorsLayer(props) {
|
|
94
|
+
const { "aria-haspopup": popup, role, "data-state": state } = props;
|
|
95
|
+
return popup !== void 0 && popup !== false && popup !== "false" || role === "combobox" || state !== void 0;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Keeps the outgoing version of something on screen while its replacement
|
|
99
|
+
* enters, which CSS alone cannot do: a node React unmounts is gone.
|
|
100
|
+
*
|
|
101
|
+
* `key` says when it has changed. On a change the previous `value` joins
|
|
102
|
+
* `leaving`, stamped with the place it last occupied (read from `measure`,
|
|
103
|
+
* the CURRENT node, after every commit); the caller renders each leaving item
|
|
104
|
+
* out of flow at that rect with an exit animation and calls `remove` when it
|
|
105
|
+
* ends. `changed` turns true on the first change, so nothing animates on first
|
|
106
|
+
* mount. It must be a layout effect: the old node's position is DOM state that
|
|
107
|
+
* only exists until the next paint.
|
|
108
|
+
*/
|
|
109
|
+
function useLeavingItems(key, value, measure) {
|
|
110
|
+
const previous = useRef({
|
|
111
|
+
key,
|
|
112
|
+
value
|
|
113
|
+
});
|
|
114
|
+
const rect = useRef({
|
|
115
|
+
left: 0,
|
|
116
|
+
top: 0,
|
|
117
|
+
width: 0,
|
|
118
|
+
height: 0
|
|
119
|
+
});
|
|
120
|
+
const nextId = useRef(0);
|
|
121
|
+
const [leaving, setLeaving] = useState([]);
|
|
122
|
+
const [changed, setChanged] = useState(false);
|
|
123
|
+
useIsomorphicLayoutEffect(() => {
|
|
124
|
+
const old = previous.current;
|
|
125
|
+
if (old.key === key) return;
|
|
126
|
+
setLeaving((list) => [...list, {
|
|
127
|
+
id: nextId.current++,
|
|
128
|
+
value: old.value,
|
|
129
|
+
rect: rect.current
|
|
130
|
+
}]);
|
|
131
|
+
setChanged(true);
|
|
132
|
+
}, [key]);
|
|
133
|
+
useIsomorphicLayoutEffect(() => {
|
|
134
|
+
previous.current = {
|
|
135
|
+
key,
|
|
136
|
+
value
|
|
137
|
+
};
|
|
138
|
+
const node = measure();
|
|
139
|
+
if (node) rect.current = {
|
|
140
|
+
left: node.offsetLeft,
|
|
141
|
+
top: node.offsetTop,
|
|
142
|
+
width: node.offsetWidth,
|
|
143
|
+
height: node.offsetHeight
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
return {
|
|
147
|
+
leaving,
|
|
148
|
+
changed,
|
|
149
|
+
remove: useCallback((id) => setLeaving((list) => list.filter((item) => item.id !== id)), [])
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* React Aria sets aria-disabled and data-pending on a pending button but
|
|
154
|
+
* forwards no aria-busy, so a pending button was not announced as busy. Put the
|
|
155
|
+
* returned ref on the button (merge it with any other); nothing else manages
|
|
156
|
+
* this attribute on the element.
|
|
157
|
+
*/
|
|
158
|
+
function useAriaBusy(pending) {
|
|
159
|
+
const ref = useRef(null);
|
|
160
|
+
useIsomorphicLayoutEffect(() => {
|
|
161
|
+
if (pending) ref.current?.setAttribute("aria-busy", "true");
|
|
162
|
+
else ref.current?.removeAttribute("aria-busy");
|
|
163
|
+
}, [pending]);
|
|
164
|
+
return ref;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
export { anchorsLayer, prefersReducedMotion, pressScaleFor, useAriaBusy, useExitBackstop, useIsomorphicLayoutEffect, useLeavingItems, useMorphWidth, useReducedMotion };
|
|
168
|
+
|
|
169
|
+
//# sourceMappingURL=motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.js","names":[],"sources":["../../src/lib/motion.ts"],"sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, type RefObject } from \"react\";\n\n/*\n * Motion helpers shared by every component with button-like motion: the press\n * depth, the width that springs to fit new content, and the backstop for an\n * exit animation that never ends. Plain React and CSS, no animation library;\n * the animations themselves are keyframes and transitions in\n * @seekalfred/styles motion.css and the button-* utilities in styles.css.\n */\n\n/** useLayoutEffect warns when rendered on the server in React 18, which this package supports; there it falls back to useEffect. */\nexport const useIsomorphicLayoutEffect =\n typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\nexport const prefersReducedMotion = () =>\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\nconst subscribeReducedMotion = (notify: () => void) => {\n const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n query.addEventListener(\"change\", notify);\n return () => query.removeEventListener(\"change\", notify);\n};\n\n/** Whether the visitor prefers reduced motion, kept current. False on the server and until hydrated. */\nexport const useReducedMotion = () =>\n useSyncExternalStore(subscribeReducedMotion, prefersReducedMotion, () => false);\n\n/**\n * Springs the slot to the natural width of the incoming label when it changes,\n * so a new label never snaps the button's size. Only a resize within 700ms of a\n * label change morphs; any other resize (a late web font, a parent reflow),\n * the first measurement and reduced motion jump straight to the new width, so\n * nothing wobbles on first paint. data-morphing turns on the slot's width\n * transition and its clip-path (button-slot).\n */\nexport function useMorphWidth(content: RefObject<HTMLElement | null>, key: string, enabled = true) {\n const lastKey = useRef(key);\n const armedUntil = useRef(0);\n useIsomorphicLayoutEffect(() => {\n if (lastKey.current === key) return;\n lastKey.current = key;\n armedUntil.current = performance.now() + 700;\n }, [key]);\n useEffect(() => {\n const node = content.current;\n const slot = node?.parentElement;\n if (!enabled || !node || !slot || typeof ResizeObserver === \"undefined\") return;\n let measured = false;\n let settle: ReturnType<typeof setTimeout> | undefined;\n const done = () => {\n clearTimeout(settle);\n delete slot.dataset.morphing;\n };\n const onEnd = (event: TransitionEvent) => {\n if (event.target === slot && event.propertyName === \"width\") done();\n };\n slot.addEventListener(\"transitionend\", onEnd);\n const apply = (next: number, at: number) => {\n if (!next || !measured || prefersReducedMotion() || at > armedUntil.current) {\n measured = next > 0;\n slot.style.width = next ? next + \"px\" : \"\";\n done();\n return;\n }\n slot.dataset.morphing = \"\";\n slot.style.width = next + \"px\";\n // A morph that ends without a width transition (nothing to animate) would\n // leave the clip-path on; this is the backstop.\n clearTimeout(settle);\n settle = setTimeout(done, 900);\n };\n // The write is deferred a frame. Setting the slot's width resizes whatever\n // contains it, and if that is observed too (a segment in a button group) doing\n // it inside this notification reports a ResizeObserver loop error.\n let frame = 0;\n const observer = new ResizeObserver(([entry]) => {\n if (!entry) return;\n const next = entry.contentRect.width;\n const at = performance.now();\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(() => apply(next, at));\n });\n observer.observe(node);\n return () => {\n cancelAnimationFrame(frame);\n observer.disconnect();\n slot.removeEventListener(\"transitionend\", onEnd);\n clearTimeout(settle);\n };\n }, [content, enabled]);\n}\n\n/**\n * Runs remove after a backstop delay, in case an exit animation never ends (a\n * consumer who disables animation). The delay must outlast the animation:\n * 600ms covers the quick exits, a spring that settles in 736ms needs more.\n */\nexport function useExitBackstop(active: boolean, remove: () => void, delay = 600) {\n useEffect(() => {\n if (!active) return;\n const timer = setTimeout(remove, delay);\n return () => clearTimeout(timer);\n }, [active, remove, delay]);\n}\n\n/** A press goes a little deeper on an icon button and a little less on a wide one, so every size reads as the same push. */\nexport function pressScaleFor(width: number) {\n return width > 220 ? \"0.985\" : width && width <= 48 ? \"0.96\" : \"0.97\";\n}\n\n/** True for a trigger that anchors a menu, popover or dialog; those never scale. */\nexport function anchorsLayer(props: object) {\n const { \"aria-haspopup\": popup, role, \"data-state\": state } = props as Record<string, unknown>;\n return (\n (popup !== undefined && popup !== false && popup !== \"false\") ||\n role === \"combobox\" ||\n state !== undefined\n );\n}\n\n/** Where a node sat inside its offset parent, in px. */\nexport interface Rect {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\nexport interface LeavingItem<T> {\n id: number;\n value: T;\n /** The place the node last occupied, so it can be popped out of flow right there. */\n rect: Rect;\n}\n\n/**\n * Keeps the outgoing version of something on screen while its replacement\n * enters, which CSS alone cannot do: a node React unmounts is gone.\n *\n * `key` says when it has changed. On a change the previous `value` joins\n * `leaving`, stamped with the place it last occupied (read from `measure`,\n * the CURRENT node, after every commit); the caller renders each leaving item\n * out of flow at that rect with an exit animation and calls `remove` when it\n * ends. `changed` turns true on the first change, so nothing animates on first\n * mount. It must be a layout effect: the old node's position is DOM state that\n * only exists until the next paint.\n */\nexport function useLeavingItems<T>(key: string, value: T, measure: () => HTMLElement | null) {\n const previous = useRef({ key, value });\n const rect = useRef<Rect>({ left: 0, top: 0, width: 0, height: 0 });\n const nextId = useRef(0);\n const [leaving, setLeaving] = useState<LeavingItem<T>[]>([]);\n const [changed, setChanged] = useState(false);\n\n // Declared before the effect below, which overwrites the record this reads.\n useIsomorphicLayoutEffect(() => {\n const old = previous.current;\n if (old.key === key) return;\n setLeaving((list) => [...list, { id: nextId.current++, value: old.value, rect: rect.current }]);\n setChanged(true);\n }, [key]);\n\n useIsomorphicLayoutEffect(() => {\n previous.current = { key, value };\n const node = measure();\n if (node)\n rect.current = {\n left: node.offsetLeft,\n top: node.offsetTop,\n width: node.offsetWidth,\n height: node.offsetHeight,\n };\n });\n\n const remove = useCallback(\n (id: number) => setLeaving((list) => list.filter((item) => item.id !== id)),\n [],\n );\n return { leaving, changed, remove };\n}\n\n/**\n * React Aria sets aria-disabled and data-pending on a pending button but\n * forwards no aria-busy, so a pending button was not announced as busy. Put the\n * returned ref on the button (merge it with any other); nothing else manages\n * this attribute on the element.\n */\nexport function useAriaBusy(pending: boolean) {\n const ref = useRef<HTMLElement | null>(null);\n useIsomorphicLayoutEffect(() => {\n if (pending) ref.current?.setAttribute(\"aria-busy\", \"true\");\n else ref.current?.removeAttribute(\"aria-busy\");\n }, [pending]);\n return ref;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
//#region src/lib/pausable-timeout.ts
|
|
3
|
+
/**
|
|
4
|
+
* Calls `onExpire` after `ms`, unless held: while `hold()` is in effect the
|
|
5
|
+
* clock stops and resumes where it was. `key` restarts it (a new state of
|
|
6
|
+
* whatever is waiting). `ms` of 0 turns it off.
|
|
7
|
+
*
|
|
8
|
+
* Returns `setHeld`, which the caller drives from whatever should pause it (a
|
|
9
|
+
* pointer resting on the control, a hidden tab).
|
|
10
|
+
*/
|
|
11
|
+
function usePausableTimeout(ms, key, onExpire) {
|
|
12
|
+
const expire = useRef(onExpire);
|
|
13
|
+
const held = useRef({
|
|
14
|
+
hover: false,
|
|
15
|
+
hidden: false
|
|
16
|
+
});
|
|
17
|
+
const clock = useRef(null);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
expire.current = onExpire;
|
|
20
|
+
});
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!ms) return;
|
|
23
|
+
let remaining = ms;
|
|
24
|
+
let startedAt = performance.now();
|
|
25
|
+
let timer;
|
|
26
|
+
let running = false;
|
|
27
|
+
const run = () => {
|
|
28
|
+
startedAt = performance.now();
|
|
29
|
+
running = true;
|
|
30
|
+
timer = setTimeout(() => {
|
|
31
|
+
running = false;
|
|
32
|
+
clock.current = null;
|
|
33
|
+
expire.current();
|
|
34
|
+
}, remaining);
|
|
35
|
+
};
|
|
36
|
+
const sync = () => {
|
|
37
|
+
const isHeld = held.current.hover || held.current.hidden;
|
|
38
|
+
if (isHeld && running) {
|
|
39
|
+
clearTimeout(timer);
|
|
40
|
+
remaining -= performance.now() - startedAt;
|
|
41
|
+
running = false;
|
|
42
|
+
} else if (!isHeld && !running) run();
|
|
43
|
+
};
|
|
44
|
+
clock.current = { sync };
|
|
45
|
+
sync();
|
|
46
|
+
return () => {
|
|
47
|
+
clearTimeout(timer);
|
|
48
|
+
clock.current = null;
|
|
49
|
+
};
|
|
50
|
+
}, [ms, key]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const onVisibility = () => {
|
|
53
|
+
held.current.hidden = document.hidden;
|
|
54
|
+
clock.current?.sync();
|
|
55
|
+
};
|
|
56
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
57
|
+
return () => document.removeEventListener("visibilitychange", onVisibility);
|
|
58
|
+
}, []);
|
|
59
|
+
return useCallback((hover) => {
|
|
60
|
+
held.current.hover = hover;
|
|
61
|
+
clock.current?.sync();
|
|
62
|
+
}, []);
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { usePausableTimeout };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=pausable-timeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pausable-timeout.js","names":[],"sources":["../../src/lib/pausable-timeout.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from \"react\";\n\n/**\n * Calls `onExpire` after `ms`, unless held: while `hold()` is in effect the\n * clock stops and resumes where it was. `key` restarts it (a new state of\n * whatever is waiting). `ms` of 0 turns it off.\n *\n * Returns `setHeld`, which the caller drives from whatever should pause it (a\n * pointer resting on the control, a hidden tab).\n */\nexport function usePausableTimeout(ms: number, key: unknown, onExpire: () => void) {\n const expire = useRef(onExpire);\n const held = useRef({ hover: false, hidden: false });\n const clock = useRef<{ sync: () => void } | null>(null);\n\n useEffect(() => {\n expire.current = onExpire;\n });\n\n useEffect(() => {\n if (!ms) return;\n let remaining = ms;\n let startedAt = performance.now();\n let timer: ReturnType<typeof setTimeout> | undefined;\n let running = false;\n const run = () => {\n startedAt = performance.now();\n running = true;\n timer = setTimeout(() => {\n running = false;\n clock.current = null;\n expire.current();\n }, remaining);\n };\n const sync = () => {\n const isHeld = held.current.hover || held.current.hidden;\n if (isHeld && running) {\n clearTimeout(timer);\n remaining -= performance.now() - startedAt;\n running = false;\n } else if (!isHeld && !running) {\n run();\n }\n };\n clock.current = { sync };\n sync();\n return () => {\n clearTimeout(timer);\n clock.current = null;\n };\n }, [ms, key]);\n\n useEffect(() => {\n const onVisibility = () => {\n held.current.hidden = document.hidden;\n clock.current?.sync();\n };\n document.addEventListener(\"visibilitychange\", onVisibility);\n return () => document.removeEventListener(\"visibilitychange\", onVisibility);\n }, []);\n\n return useCallback((hover: boolean) => {\n held.current.hover = hover;\n clock.current?.sync();\n }, []);\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,mBAAmB,IAAY,KAAc,UAAsB;CACjF,MAAM,SAAS,OAAO,QAAQ;CAC9B,MAAM,OAAO,OAAO;EAAE,OAAO;EAAO,QAAQ;CAAM,CAAC;CACnD,MAAM,QAAQ,OAAoC,IAAI;CAEtD,gBAAgB;EACd,OAAO,UAAU;CACnB,CAAC;CAED,gBAAgB;EACd,IAAI,CAAC,IAAI;EACT,IAAI,YAAY;EAChB,IAAI,YAAY,YAAY,IAAI;EAChC,IAAI;EACJ,IAAI,UAAU;EACd,MAAM,YAAY;GAChB,YAAY,YAAY,IAAI;GAC5B,UAAU;GACV,QAAQ,iBAAiB;IACvB,UAAU;IACV,MAAM,UAAU;IAChB,OAAO,QAAQ;GACjB,GAAG,SAAS;EACd;EACA,MAAM,aAAa;GACjB,MAAM,SAAS,KAAK,QAAQ,SAAS,KAAK,QAAQ;GAClD,IAAI,UAAU,SAAS;IACrB,aAAa,KAAK;IAClB,aAAa,YAAY,IAAI,IAAI;IACjC,UAAU;GACZ,OAAO,IAAI,CAAC,UAAU,CAAC,SACrB,IAAI;EAER;EACA,MAAM,UAAU,EAAE,KAAK;EACvB,KAAK;EACL,aAAa;GACX,aAAa,KAAK;GAClB,MAAM,UAAU;EAClB;CACF,GAAG,CAAC,IAAI,GAAG,CAAC;CAEZ,gBAAgB;EACd,MAAM,qBAAqB;GACzB,KAAK,QAAQ,SAAS,SAAS;GAC/B,MAAM,SAAS,KAAK;EACtB;EACA,SAAS,iBAAiB,oBAAoB,YAAY;EAC1D,aAAa,SAAS,oBAAoB,oBAAoB,YAAY;CAC5E,GAAG,CAAC,CAAC;CAEL,OAAO,aAAa,UAAmB;EACrC,KAAK,QAAQ,QAAQ;EACrB,MAAM,SAAS,KAAK;CACtB,GAAG,CAAC,CAAC;AACP"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SwapText } from "./swap-text.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region src/lib/rolling-value.tsx
|
|
4
|
+
/**
|
|
5
|
+
* The value shown in a picker's trigger. The caller's own text stays, visually
|
|
6
|
+
* hidden, as what a screen reader reads (`srValue`); the copy the eye sees rolls
|
|
7
|
+
* when it changes: a later value rises in from below, an earlier one drops in from
|
|
8
|
+
* above, and the old one lifts away. Nothing animates on first mount. Long text is
|
|
9
|
+
* cut with an ellipsis. `instanceKey` remounts the swap, which is how a caller whose
|
|
10
|
+
* first value arrives a render late makes that arrival the first mount.
|
|
11
|
+
*/
|
|
12
|
+
function RollingValue({ srValue, swapKey, dir, instanceKey, children }) {
|
|
13
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
14
|
+
className: "grid min-w-0 flex-1",
|
|
15
|
+
children: [srValue, /* @__PURE__ */ jsx("span", {
|
|
16
|
+
"aria-hidden": "true",
|
|
17
|
+
className: "min-w-0 overflow-hidden whitespace-nowrap",
|
|
18
|
+
children: /* @__PURE__ */ jsx(SwapText, {
|
|
19
|
+
swapKey,
|
|
20
|
+
dir,
|
|
21
|
+
motion: "roll",
|
|
22
|
+
className: "flex items-center [&>span:not([aria-hidden])]:max-w-full [&>span:not([aria-hidden])]:truncate",
|
|
23
|
+
children
|
|
24
|
+
}, instanceKey)
|
|
25
|
+
})]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { RollingValue };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=rolling-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rolling-value.js","names":[],"sources":["../../src/lib/rolling-value.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\n\nimport { SwapText } from \"./swap-text.js\";\n\n/**\n * The value shown in a picker's trigger. The caller's own text stays, visually\n * hidden, as what a screen reader reads (`srValue`); the copy the eye sees rolls\n * when it changes: a later value rises in from below, an earlier one drops in from\n * above, and the old one lifts away. Nothing animates on first mount. Long text is\n * cut with an ellipsis. `instanceKey` remounts the swap, which is how a caller whose\n * first value arrives a render late makes that arrival the first mount.\n */\nexport function RollingValue({\n srValue,\n swapKey,\n dir,\n instanceKey,\n children,\n}: {\n srValue: ReactNode;\n swapKey: string;\n dir: number;\n instanceKey?: string;\n children: ReactNode;\n}) {\n return (\n <span className=\"grid min-w-0 flex-1\">\n {srValue}\n <span aria-hidden=\"true\" className=\"min-w-0 overflow-hidden whitespace-nowrap\">\n <SwapText\n key={instanceKey}\n swapKey={swapKey}\n dir={dir}\n motion=\"roll\"\n // A flex row, not a block of inline boxes: a truncated inline-block sits on the\n // line's baseline, which stretches the line and leaves the text above centre.\n className=\"flex items-center [&>span:not([aria-hidden])]:max-w-full [&>span:not([aria-hidden])]:truncate\"\n >\n {children}\n </SwapText>\n </span>\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,aAAa,EAC3B,SACA,SACA,KACA,aACA,YAOC;CACD,OACE,qBAAC,QAAD;EAAM,WAAU;EAAhB,UAAA,CACG,SACD,oBAAC,QAAD;GAAM,eAAY;GAAO,WAAU;GACjC,UAAA,oBAAC,UAAD;IAEW;IACJ;IACL,QAAO;IAGP,WAAU;IAET;GACO,GATH,WASG;EACN,CAAA,CACF;;AAEV"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { prefersReducedMotion } from "./motion.js";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
//#region src/lib/spring-progress.ts
|
|
4
|
+
/**
|
|
5
|
+
* The morph spring (--ease-morph, --duration-morph: visualDuration 0.42s, bounce
|
|
6
|
+
* 0.16), sampled every 16ms from Motion's solver. It is here as numbers because a
|
|
7
|
+
* script has to evaluate it: CSS cannot interpolate the `d` of a path in every
|
|
8
|
+
* browser, so an icon that morphs its outline drives the path from this.
|
|
9
|
+
*/
|
|
10
|
+
const MORPH_CURVE = [
|
|
11
|
+
0,
|
|
12
|
+
.0178,
|
|
13
|
+
.0636,
|
|
14
|
+
.1279,
|
|
15
|
+
.2033,
|
|
16
|
+
.2841,
|
|
17
|
+
.366,
|
|
18
|
+
.4459,
|
|
19
|
+
.5218,
|
|
20
|
+
.5921,
|
|
21
|
+
.6562,
|
|
22
|
+
.7136,
|
|
23
|
+
.7643,
|
|
24
|
+
.8086,
|
|
25
|
+
.8466,
|
|
26
|
+
.879,
|
|
27
|
+
.9063,
|
|
28
|
+
.9289,
|
|
29
|
+
.9475,
|
|
30
|
+
.9626,
|
|
31
|
+
.9746,
|
|
32
|
+
.9841,
|
|
33
|
+
.9914,
|
|
34
|
+
.9969,
|
|
35
|
+
1.001,
|
|
36
|
+
1.0038,
|
|
37
|
+
1.0058,
|
|
38
|
+
1.0069,
|
|
39
|
+
1.0075,
|
|
40
|
+
1.0077,
|
|
41
|
+
1.0076,
|
|
42
|
+
1.0072,
|
|
43
|
+
1.0067,
|
|
44
|
+
1.0062,
|
|
45
|
+
1.0055,
|
|
46
|
+
1.0049,
|
|
47
|
+
1.0043,
|
|
48
|
+
1.0037,
|
|
49
|
+
1.0032,
|
|
50
|
+
1.0027,
|
|
51
|
+
1.0022,
|
|
52
|
+
1.0018,
|
|
53
|
+
1.0015,
|
|
54
|
+
1.0012,
|
|
55
|
+
1.0009,
|
|
56
|
+
1.0007,
|
|
57
|
+
1
|
|
58
|
+
];
|
|
59
|
+
const MORPH_MS = 736;
|
|
60
|
+
const ease = (t) => {
|
|
61
|
+
const at = t * MORPH_MS / 16;
|
|
62
|
+
const i = Math.min(Math.floor(at), MORPH_CURVE.length - 2);
|
|
63
|
+
const a = MORPH_CURVE[i];
|
|
64
|
+
return a + (MORPH_CURVE[i + 1] - a) * (at - i);
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Follows `target` (0 or 1) on the morph spring and reports progress to
|
|
68
|
+
* `apply` every frame, mutating the DOM directly rather than re-rendering.
|
|
69
|
+
* It is interruptible: a new target mid-flight starts from where the value is.
|
|
70
|
+
* The first render, and reduced motion, jump straight to the target.
|
|
71
|
+
*/
|
|
72
|
+
function useSpringProgress(target, apply) {
|
|
73
|
+
const current = useRef(target);
|
|
74
|
+
const frame = useRef(0);
|
|
75
|
+
const applyRef = useRef(apply);
|
|
76
|
+
const first = useRef(true);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
applyRef.current = apply;
|
|
79
|
+
});
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
cancelAnimationFrame(frame.current);
|
|
82
|
+
if (first.current || prefersReducedMotion()) {
|
|
83
|
+
first.current = false;
|
|
84
|
+
current.current = target;
|
|
85
|
+
applyRef.current(target);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const from = current.current;
|
|
89
|
+
const start = performance.now();
|
|
90
|
+
const tick = (now) => {
|
|
91
|
+
const t = Math.min(Math.max((now - start) / MORPH_MS, 0), 1);
|
|
92
|
+
current.current = from + (target - from) * ease(t);
|
|
93
|
+
applyRef.current(current.current);
|
|
94
|
+
if (t < 1) frame.current = requestAnimationFrame(tick);
|
|
95
|
+
};
|
|
96
|
+
frame.current = requestAnimationFrame(tick);
|
|
97
|
+
return () => cancelAnimationFrame(frame.current);
|
|
98
|
+
}, [target]);
|
|
99
|
+
}
|
|
100
|
+
/** Interpolates the numbers of a path whose two states have the same commands. */
|
|
101
|
+
function lerpPath(from, to, progress) {
|
|
102
|
+
const a = from.match(/-?\d*\.?\d+/g).map(Number);
|
|
103
|
+
const b = to.match(/-?\d*\.?\d+/g).map(Number);
|
|
104
|
+
let i = 0;
|
|
105
|
+
return from.replace(/-?\d*\.?\d+/g, () => {
|
|
106
|
+
const n = a[i] + (b[i] - a[i]) * progress;
|
|
107
|
+
i += 1;
|
|
108
|
+
return String(Math.round(n * 1e3) / 1e3);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { lerpPath, useSpringProgress };
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=spring-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spring-progress.js","names":[],"sources":["../../src/lib/spring-progress.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nimport { prefersReducedMotion } from \"./motion.js\";\n\n/**\n * The morph spring (--ease-morph, --duration-morph: visualDuration 0.42s, bounce\n * 0.16), sampled every 16ms from Motion's solver. It is here as numbers because a\n * script has to evaluate it: CSS cannot interpolate the `d` of a path in every\n * browser, so an icon that morphs its outline drives the path from this.\n */\nconst MORPH_CURVE: readonly number[] = [\n 0, 0.0178, 0.0636, 0.1279, 0.2033, 0.2841, 0.366, 0.4459, 0.5218, 0.5921, 0.6562, 0.7136, 0.7643,\n 0.8086, 0.8466, 0.879, 0.9063, 0.9289, 0.9475, 0.9626, 0.9746, 0.9841, 0.9914, 0.9969, 1.001,\n 1.0038, 1.0058, 1.0069, 1.0075, 1.0077, 1.0076, 1.0072, 1.0067, 1.0062, 1.0055, 1.0049, 1.0043,\n 1.0037, 1.0032, 1.0027, 1.0022, 1.0018, 1.0015, 1.0012, 1.0009, 1.0007, 1,\n];\nconst MORPH_MS = 736;\n\nconst ease = (t: number) => {\n const at = (t * MORPH_MS) / 16;\n const i = Math.min(Math.floor(at), MORPH_CURVE.length - 2);\n const a = MORPH_CURVE[i]!;\n const b = MORPH_CURVE[i + 1]!;\n return a + (b - a) * (at - i);\n};\n\n/**\n * Follows `target` (0 or 1) on the morph spring and reports progress to\n * `apply` every frame, mutating the DOM directly rather than re-rendering.\n * It is interruptible: a new target mid-flight starts from where the value is.\n * The first render, and reduced motion, jump straight to the target.\n */\nexport function useSpringProgress(target: number, apply: (progress: number) => void) {\n const current = useRef(target);\n const frame = useRef(0);\n const applyRef = useRef(apply);\n const first = useRef(true);\n\n useEffect(() => {\n applyRef.current = apply;\n });\n\n useEffect(() => {\n cancelAnimationFrame(frame.current);\n if (first.current || prefersReducedMotion()) {\n first.current = false;\n current.current = target;\n applyRef.current(target);\n return;\n }\n const from = current.current;\n const start = performance.now();\n const tick = (now: number) => {\n // A frame's timestamp can precede `start`; a negative t would index the curve at -1.\n const t = Math.min(Math.max((now - start) / MORPH_MS, 0), 1);\n current.current = from + (target - from) * ease(t);\n applyRef.current(current.current);\n if (t < 1) frame.current = requestAnimationFrame(tick);\n };\n frame.current = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(frame.current);\n }, [target]);\n}\n\n/** Interpolates the numbers of a path whose two states have the same commands. */\nexport function lerpPath(from: string, to: string, progress: number) {\n const a = from.match(/-?\\d*\\.?\\d+/g)!.map(Number);\n const b = to.match(/-?\\d*\\.?\\d+/g)!.map(Number);\n let i = 0;\n return from.replace(/-?\\d*\\.?\\d+/g, () => {\n const n = a[i]! + (b[i]! - a[i]!) * progress;\n i += 1;\n return String(Math.round(n * 1000) / 1000);\n });\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,cAAiC;CACrC;CAAG;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAO;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAC1F;CAAQ;CAAQ;CAAO;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CACvF;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CACxF;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;AAC1E;AACA,MAAM,WAAW;AAEjB,MAAM,QAAQ,MAAc;CAC1B,MAAM,KAAM,IAAI,WAAY;CAC5B,MAAM,IAAI,KAAK,IAAI,KAAK,MAAM,EAAE,GAAG,YAAY,SAAS,CAAC;CACzD,MAAM,IAAI,YAAY;CAEtB,OAAO,KADG,YAAY,IAAI,KACV,MAAM,KAAK;AAC7B;;;;;;;AAQA,SAAgB,kBAAkB,QAAgB,OAAmC;CACnF,MAAM,UAAU,OAAO,MAAM;CAC7B,MAAM,QAAQ,OAAO,CAAC;CACtB,MAAM,WAAW,OAAO,KAAK;CAC7B,MAAM,QAAQ,OAAO,IAAI;CAEzB,gBAAgB;EACd,SAAS,UAAU;CACrB,CAAC;CAED,gBAAgB;EACd,qBAAqB,MAAM,OAAO;EAClC,IAAI,MAAM,WAAW,qBAAqB,GAAG;GAC3C,MAAM,UAAU;GAChB,QAAQ,UAAU;GAClB,SAAS,QAAQ,MAAM;GACvB;EACF;EACA,MAAM,OAAO,QAAQ;EACrB,MAAM,QAAQ,YAAY,IAAI;EAC9B,MAAM,QAAQ,QAAgB;GAE5B,MAAM,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,SAAS,UAAU,CAAC,GAAG,CAAC;GAC3D,QAAQ,UAAU,QAAQ,SAAS,QAAQ,KAAK,CAAC;GACjD,SAAS,QAAQ,QAAQ,OAAO;GAChC,IAAI,IAAI,GAAG,MAAM,UAAU,sBAAsB,IAAI;EACvD;EACA,MAAM,UAAU,sBAAsB,IAAI;EAC1C,aAAa,qBAAqB,MAAM,OAAO;CACjD,GAAG,CAAC,MAAM,CAAC;AACb;;AAGA,SAAgB,SAAS,MAAc,IAAY,UAAkB;CACnE,MAAM,IAAI,KAAK,MAAM,cAAc,CAAC,CAAE,IAAI,MAAM;CAChD,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,CAAE,IAAI,MAAM;CAC9C,IAAI,IAAI;CACR,OAAO,KAAK,QAAQ,sBAAsB;EACxC,MAAM,IAAI,EAAE,MAAO,EAAE,KAAM,EAAE,MAAO;EACpC,KAAK;EACL,OAAO,OAAO,KAAK,MAAM,IAAI,GAAI,IAAI,GAAI;CAC3C,CAAC;AACH"}
|