@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
package/dist/sheet/sheet.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
|
-
import { Dialog } from "../dialog/dialog.js";
|
|
4
3
|
import { Button } from "../button/button.js";
|
|
4
|
+
import { Dialog } from "../dialog/dialog.js";
|
|
5
5
|
import { ScrollArea } from "../scroll-area/scroll-area.js";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
7
|
import { forwardRef } from "react";
|
|
@@ -73,6 +73,7 @@ function BackArrowGlyph() {
|
|
|
73
73
|
}
|
|
74
74
|
const Sheet = forwardRef(function Sheet({ side = "right", className, onBack, backLabel = "Back", scrollResetKey, bodyClassName, bodyLabel, title, children, ...props }, ref) {
|
|
75
75
|
return /* @__PURE__ */ jsx(Dialog, {
|
|
76
|
+
entrance: "none",
|
|
76
77
|
...props,
|
|
77
78
|
ref,
|
|
78
79
|
title,
|
|
@@ -90,7 +91,8 @@ const Sheet = forwardRef(function Sheet({ side = "right", className, onBack, bac
|
|
|
90
91
|
children: /* @__PURE__ */ jsx(ScrollArea, {
|
|
91
92
|
scrollResetKey,
|
|
92
93
|
label: bodyLabel ?? (typeof title === "string" ? title : ""),
|
|
93
|
-
className:
|
|
94
|
+
className: "min-h-0 flex-1",
|
|
95
|
+
viewportClassName: bodyClassName,
|
|
94
96
|
children
|
|
95
97
|
})
|
|
96
98
|
});
|
package/dist/sheet/sheet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet.js","names":[],"sources":["../../src/sheet/sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport { forwardRef } from \"react\";\n\nimport { Button } from \"../button/button.js\";\nimport { cn } from \"../lib/cn.js\";\nimport { Dialog, type DialogProps } from \"../dialog/dialog.js\";\nimport { ScrollArea } from \"../scroll-area/scroll-area.js\";\n\n/**\n * Sheet: a dialog that arrives from an edge.\n *\n * A PRESET over `Dialog`, like `AlertDialog`. The legacy `sheet.tsx` is\n * `@radix-ui/react-dialog` again -- the same import, the same parts, the\n * same close button -- with one prop changing where it sits. Keeping a\n * second copy is how the legacy `dialog.tsx` and `alert-dialog.tsx`\n * drifted, and this is the same file for the third time.\n *\n * Census: 2 files, 3 uses. `side=\"right\"` twice, `side=\"left\"` once, and\n * `className` four times. `SheetHeader`, `SheetFooter`, `SheetTitle`,\n * `SheetDescription` and `SheetClose` are exported by the legacy and used\n * by NOBODY -- so all three sheets in the app render a `role=\"dialog\"`\n * with no title at all. Radix even warns about it in the console.\n *\n * `title` is required here, inherited from Dialog, so that is no longer\n * expressible.\n *\n * `side` is `\"left\" | \"right\"` only. The legacy also offers `\"top\"` and\n * `\"bottom\"`; both have zero call sites, and each is two lines to add the\n * day something needs one.\n *\n * A REAL BUG THE PORT FIXES: the legacy panel is `w-3/4 sm:max-w-sm`, and\n * `sm:max-w-sm` names `--container-sm`, which this repo does not define --\n * so in Alfred it would compile to NOTHING and the sheet would be 75% of\n * the viewport at every width, on a phone and on a 4K monitor alike. The\n * width here is a spacing-scale step that actually resolves.\n *\n * NOT PORTED: the slide-in animation. It comes from tailwindcss-animate,\n * which this repo does not ship. React Aria exposes `data-entering` and\n * `data-exiting`, and `--animate-*` tokens now exist, so it is a small\n * follow-up rather than a blocker.\n */\nexport const sheetOverlayVariants = cva(\"p-0\", {\n variants: {\n // The overlay is a flex box centring the panel. A sheet replaces that\n // centring with an edge alignment rather than positioning the panel\n // absolutely, so the scrim and the panel stay one layout.\n side: {\n left: \"justify-start items-stretch\",\n right: \"justify-end items-stretch\",\n },\n },\n defaultVariants: { side: \"right\" },\n});\n\nexport const sheetPanelVariants = cva(\n [\n // max-w-96 is 384px and RESOLVES. See the note above on sm:max-w-sm.\n \"h-full w-full max-w-96\",\n // Square against the edge it is attached to: a rounded corner flush\n // with the viewport edge reads as a rendering fault.\n \"rounded-none\",\n \"max-h-full overflow-y-auto\",\n ],\n {\n variants: {\n side: {\n left: \"border-y-0 border-s-0\",\n right: \"border-y-0 border-e-0\",\n },\n },\n defaultVariants: { side: \"right\" },\n },\n);\n\n/**\n * A panel that arrives from the side.\n *\n * @example\n * <Sheet isOpen={open} onOpenChange={setOpen} title=\"Filters\">\n * ...\n * </Sheet>\n */\nexport interface SheetProps extends Omit<DialogProps, \"overlayClassName\"> {\n /**\n * Which edge it is attached to.\n *\n * `\"top\"` and `\"bottom\"` exist in the legacy and have zero call sites.\n *\n * @default \"right\"\n */\n side?: \"left\" | \"right\";\n /**\n * Show a back control, and what it does.\n *\n * A side panel that goes a level deeper REPLACES its own contents rather\n * than stacking a second modal on top, so the browser's back affordance and\n * the escape key both do the wrong thing -- they close the whole panel\n * instead of returning one level. The product's own note calls this the\n * thing that \"makes items 119 and 120 one change rather than two\".\n */\n onBack?: () => void;\n /** Accessible name and label for the back control. @default \"Back\" */\n backLabel?: string;\n /**\n * Change this when the panel's contents change, and the body scrolls back\n * to the top.\n *\n * Going a level deeper and landing halfway down the new view is\n * disorienting, and it is the kind of thing every call site forgets --\n * which is why it belongs here rather than in each of them.\n */\n scrollResetKey?: string | number;\n /** Extra classes for the scrolling body region. */\n bodyClassName?: string;\n /**\n * Names the scrolling body region. Defaults to `title` when that is a\n * string, which it is at every call site in the product.\n *\n * The body is a `ScrollArea`, so it is focusable -- a scrollable region that\n * is not reachable by keyboard is WCAG 2.1.1, and axe caught exactly that\n * when this was a plain div. The product's own `SidePanelBody` still is one.\n * A focusable element needs a role and a role needs a name, so this is the\n * only combination that is actually correct.\n */\n bodyLabel?: string;\n}\n\nfunction BackArrowGlyph() {\n return (\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n // Logical, so it points the right way once the panel mirrors in RTL.\n className=\"size-(--icon-sm) rtl:-scale-x-100\"\n >\n <path d=\"M10 3 5 8l5 5\" />\n </svg>\n );\n}\n\nexport const Sheet = forwardRef<HTMLElement, SheetProps>(function Sheet(\n {\n side = \"right\",\n className,\n onBack,\n backLabel = \"Back\",\n scrollResetKey,\n bodyClassName,\n bodyLabel,\n title,\n children,\n ...props\n },\n ref,\n) {\n return (\n /*\n No data-slot here. Dialog spreads its props onto the ModalOverlay and\n writes data-slot=\"dialog-overlay\" AFTER the spread, so a data-slot\n passed from here is overwritten before it reaches the DOM -- it read as\n working while rendering nothing. A sheet is identified by its side\n variant and its panel classes instead.\n */\n <Dialog\n {...props}\n ref={ref}\n title={title}\n beforeTitle={\n onBack ? (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n data-slot=\"sheet-back\"\n className=\"-ms-2 w-fit\"\n startIcon={<BackArrowGlyph />}\n onPress={onBack}\n >\n {backLabel}\n </Button>\n ) : undefined\n }\n overlayClassName={sheetOverlayVariants({ side })}\n className={cn(sheetPanelVariants({ side }), className)}\n >\n {/*\n The scrolling region is its own element so the title and the back\n control stay put while the content moves. A panel that scrolled as one\n block would take its own heading off screen.\n */}\n {/*\n No data-slot=\"sheet-body\" here, for the same reason the overlay has\n none: ScrollArea spreads its props and writes data-slot=\"scroll-area\"\n AFTER the spread, so one passed from here is overwritten before it\n reaches the DOM. It read as wired while selecting nothing.\n */}\n <ScrollArea\n scrollResetKey={scrollResetKey}\n label={bodyLabel ?? (typeof title === \"string\" ? title : \"\")}\n className
|
|
1
|
+
{"version":3,"file":"sheet.js","names":[],"sources":["../../src/sheet/sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport { forwardRef } from \"react\";\n\nimport { Button } from \"../button/button.js\";\nimport { cn } from \"../lib/cn.js\";\nimport { Dialog, type DialogProps } from \"../dialog/dialog.js\";\nimport { ScrollArea } from \"../scroll-area/scroll-area.js\";\n\n/**\n * Sheet: a dialog that arrives from an edge.\n *\n * A PRESET over `Dialog`, like `AlertDialog`. The legacy `sheet.tsx` is\n * `@radix-ui/react-dialog` again -- the same import, the same parts, the\n * same close button -- with one prop changing where it sits. Keeping a\n * second copy is how the legacy `dialog.tsx` and `alert-dialog.tsx`\n * drifted, and this is the same file for the third time.\n *\n * Census: 2 files, 3 uses. `side=\"right\"` twice, `side=\"left\"` once, and\n * `className` four times. `SheetHeader`, `SheetFooter`, `SheetTitle`,\n * `SheetDescription` and `SheetClose` are exported by the legacy and used\n * by NOBODY -- so all three sheets in the app render a `role=\"dialog\"`\n * with no title at all. Radix even warns about it in the console.\n *\n * `title` is required here, inherited from Dialog, so that is no longer\n * expressible.\n *\n * `side` is `\"left\" | \"right\"` only. The legacy also offers `\"top\"` and\n * `\"bottom\"`; both have zero call sites, and each is two lines to add the\n * day something needs one.\n *\n * A REAL BUG THE PORT FIXES: the legacy panel is `w-3/4 sm:max-w-sm`, and\n * `sm:max-w-sm` names `--container-sm`, which this repo does not define --\n * so in Alfred it would compile to NOTHING and the sheet would be 75% of\n * the viewport at every width, on a phone and on a 4K monitor alike. The\n * width here is a spacing-scale step that actually resolves.\n *\n * NOT PORTED: the slide-in animation. It comes from tailwindcss-animate,\n * which this repo does not ship. React Aria exposes `data-entering` and\n * `data-exiting`, and `--animate-*` tokens now exist, so it is a small\n * follow-up rather than a blocker.\n */\nexport const sheetOverlayVariants = cva(\"p-0\", {\n variants: {\n // The overlay is a flex box centring the panel. A sheet replaces that\n // centring with an edge alignment rather than positioning the panel\n // absolutely, so the scrim and the panel stay one layout.\n side: {\n left: \"justify-start items-stretch\",\n right: \"justify-end items-stretch\",\n },\n },\n defaultVariants: { side: \"right\" },\n});\n\nexport const sheetPanelVariants = cva(\n [\n // max-w-96 is 384px and RESOLVES. See the note above on sm:max-w-sm.\n \"h-full w-full max-w-96\",\n // Square against the edge it is attached to: a rounded corner flush\n // with the viewport edge reads as a rendering fault.\n \"rounded-none\",\n \"max-h-full overflow-y-auto\",\n ],\n {\n variants: {\n side: {\n left: \"border-y-0 border-s-0\",\n right: \"border-y-0 border-e-0\",\n },\n },\n defaultVariants: { side: \"right\" },\n },\n);\n\n/**\n * A panel that arrives from the side.\n *\n * @example\n * <Sheet isOpen={open} onOpenChange={setOpen} title=\"Filters\">\n * ...\n * </Sheet>\n */\nexport interface SheetProps extends Omit<DialogProps, \"overlayClassName\"> {\n /**\n * Which edge it is attached to.\n *\n * `\"top\"` and `\"bottom\"` exist in the legacy and have zero call sites.\n *\n * @default \"right\"\n */\n side?: \"left\" | \"right\";\n /**\n * Show a back control, and what it does.\n *\n * A side panel that goes a level deeper REPLACES its own contents rather\n * than stacking a second modal on top, so the browser's back affordance and\n * the escape key both do the wrong thing -- they close the whole panel\n * instead of returning one level. The product's own note calls this the\n * thing that \"makes items 119 and 120 one change rather than two\".\n */\n onBack?: () => void;\n /** Accessible name and label for the back control. @default \"Back\" */\n backLabel?: string;\n /**\n * Change this when the panel's contents change, and the body scrolls back\n * to the top.\n *\n * Going a level deeper and landing halfway down the new view is\n * disorienting, and it is the kind of thing every call site forgets --\n * which is why it belongs here rather than in each of them.\n */\n scrollResetKey?: string | number;\n /** Extra classes for the scrolling body region. */\n bodyClassName?: string;\n /**\n * Names the scrolling body region. Defaults to `title` when that is a\n * string, which it is at every call site in the product.\n *\n * The body is a `ScrollArea`, so it is focusable -- a scrollable region that\n * is not reachable by keyboard is WCAG 2.1.1, and axe caught exactly that\n * when this was a plain div. The product's own `SidePanelBody` still is one.\n * A focusable element needs a role and a role needs a name, so this is the\n * only combination that is actually correct.\n */\n bodyLabel?: string;\n}\n\nfunction BackArrowGlyph() {\n return (\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n // Logical, so it points the right way once the panel mirrors in RTL.\n className=\"size-(--icon-sm) rtl:-scale-x-100\"\n >\n <path d=\"M10 3 5 8l5 5\" />\n </svg>\n );\n}\n\nexport const Sheet = forwardRef<HTMLElement, SheetProps>(function Sheet(\n {\n side = \"right\",\n className,\n onBack,\n backLabel = \"Back\",\n scrollResetKey,\n bodyClassName,\n bodyLabel,\n title,\n children,\n ...props\n },\n ref,\n) {\n return (\n /*\n No data-slot here. Dialog spreads its props onto the ModalOverlay and\n writes data-slot=\"dialog-overlay\" AFTER the spread, so a data-slot\n passed from here is overwritten before it reaches the DOM -- it read as\n working while rendering nothing. A sheet is identified by its side\n variant and its panel classes instead.\n */\n <Dialog\n entrance=\"none\"\n {...props}\n ref={ref}\n title={title}\n beforeTitle={\n onBack ? (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n data-slot=\"sheet-back\"\n className=\"-ms-2 w-fit\"\n startIcon={<BackArrowGlyph />}\n onPress={onBack}\n >\n {backLabel}\n </Button>\n ) : undefined\n }\n overlayClassName={sheetOverlayVariants({ side })}\n className={cn(sheetPanelVariants({ side }), className)}\n >\n {/*\n The scrolling region is its own element so the title and the back\n control stay put while the content moves. A panel that scrolled as one\n block would take its own heading off screen.\n */}\n {/*\n No data-slot=\"sheet-body\" here, for the same reason the overlay has\n none: ScrollArea spreads its props and writes data-slot=\"scroll-area\"\n AFTER the spread, so one passed from here is overwritten before it\n reaches the DOM. It read as wired while selecting nothing.\n */}\n <ScrollArea\n scrollResetKey={scrollResetKey}\n label={bodyLabel ?? (typeof title === \"string\" ? title : \"\")}\n className=\"min-h-0 flex-1\"\n viewportClassName={bodyClassName}\n >\n {children}\n </ScrollArea>\n </Dialog>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,uBAAuB,IAAI,OAAO;CAC7C,UAAU,EAIR,MAAM;EACJ,MAAM;EACN,OAAO;CACT,EACF;CACA,iBAAiB,EAAE,MAAM,QAAQ;AACnC,CAAC;AAED,MAAa,qBAAqB,IAChC;CAEE;CAGA;CACA;AACF,GACA;CACE,UAAU,EACR,MAAM;EACJ,MAAM;EACN,OAAO;CACT,EACF;CACA,iBAAiB,EAAE,MAAM,QAAQ;AACnC,CACF;AAuDA,SAAS,iBAAiB;CACxB,OACE,oBAAC,OAAD;EACE,eAAY;EACZ,SAAQ;EACR,MAAK;EACL,QAAO;EACP,aAAY;EACZ,eAAc;EACd,gBAAe;EAEf,WAAU;EAEV,UAAA,oBAAC,QAAD,EAAM,GAAE,gBAAiB,CAAA;CACtB,CAAA;AAET;AAEA,MAAa,QAAQ,WAAoC,SAAS,MAChE,EACE,OAAO,SACP,WACA,QACA,YAAY,QACZ,gBACA,eACA,WACA,OACA,UACA,GAAG,SAEL,KACA;CACA,OAQE,oBAAC,QAAD;EACE,UAAS;EACT,GAAI;EACC;EACE;EACP,aACE,SACE,oBAAC,QAAD;GACE,SAAQ;GACR,MAAK;GACL,aAAU;GACV,WAAU;GACV,WAAW,oBAAC,gBAAD,CAAiB,CAAA;GAC5B,SAAS;GAER,UAAA;EACK,CAAA,IACN,KAAA;EAEN,kBAAkB,qBAAqB,EAAE,KAAK,CAAC;EAC/C,WAAW,GAAG,mBAAmB,EAAE,KAAK,CAAC,GAAG,SAAS;EAarD,UAAA,oBAAC,YAAD;GACkB;GAChB,OAAO,cAAc,OAAO,UAAU,WAAW,QAAQ;GACzD,WAAU;GACV,mBAAmB;GAElB;EACS,CAAA;CACN,CAAA;AAEZ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Platform, ShortcutToken, formatShortcut, matchesShortcut, normalizeShortcut, shortcutFromEvent, shortcutTokens } from "./shortcut-model.js";
|
|
2
|
+
import { ShortcutBinding, ShortcutKbd, ShortcutKbdProps, ShortcutKeys, ShortcutKeysProps, ShortcutRecorder, ShortcutRecorderProps, usePlatform, usePressedKeys } from "./shortcut-recorder.js";
|
|
3
|
+
export { type Platform, type ShortcutBinding, ShortcutKbd, type ShortcutKbdProps, ShortcutKeys, type ShortcutKeysProps, ShortcutRecorder, type ShortcutRecorderProps, type ShortcutToken, formatShortcut, matchesShortcut, normalizeShortcut, shortcutFromEvent, shortcutTokens, usePlatform, usePressedKeys };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { formatShortcut, matchesShortcut, normalizeShortcut, shortcutFromEvent, shortcutTokens } from "./shortcut-model.js";
|
|
2
|
+
import { ShortcutKbd, ShortcutKeys, ShortcutRecorder, usePlatform, usePressedKeys } from "./shortcut-recorder.js";
|
|
3
|
+
export { ShortcutKbd, ShortcutKeys, ShortcutRecorder, formatShortcut, matchesShortcut, normalizeShortcut, shortcutFromEvent, shortcutTokens, usePlatform, usePressedKeys };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/shortcut-recorder/shortcut-model.d.ts
|
|
2
|
+
export type Platform = "mac" | "other";
|
|
3
|
+
export interface ShortcutToken {
|
|
4
|
+
/** What the key cap shows. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Physical key id, matched against held keys. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** How a screen reader says it. */
|
|
9
|
+
spoken: string;
|
|
10
|
+
}
|
|
11
|
+
/** The parts of a keyboard event the model reads, so a test can pass a plain object. */
|
|
12
|
+
export type KeyEventLike = Pick<KeyboardEvent, "key" | "code" | "metaKey" | "ctrlKey" | "altKey" | "shiftKey">;
|
|
13
|
+
/** One spelling per combination: on a Mac, Command is `mod`; elsewhere, Ctrl is. Modifiers come in a fixed order. */
|
|
14
|
+
export declare function normalizeShortcut(shortcut: string, platform: Platform): string;
|
|
15
|
+
/** Reads a keydown into a shortcut string, or `null` while only modifiers are down. */
|
|
16
|
+
export declare function shortcutFromEvent(event: KeyEventLike, platform: Platform): string | null;
|
|
17
|
+
/** True when a keydown is this shortcut. Use it to run the action a recorded shortcut is bound to. */
|
|
18
|
+
export declare function matchesShortcut(event: KeyEventLike, shortcut: string, platform: Platform): boolean;
|
|
19
|
+
/** Key caps for a shortcut in platform order: Control, Option, Shift, Command symbols on a Mac; Ctrl, Alt, Shift, Win elsewhere. */
|
|
20
|
+
export declare function shortcutTokens(shortcut: string, platform: Platform): ShortcutToken[];
|
|
21
|
+
/** The shortcut as text ("⌘⇧K" on a Mac, "Ctrl+Shift+K" elsewhere), plus a spoken form for assistive technology. */
|
|
22
|
+
export declare function formatShortcut(shortcut: string, platform: Platform): {
|
|
23
|
+
text: string;
|
|
24
|
+
spoken: string;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
//# sourceMappingURL=shortcut-model.d.ts.map
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
//#region src/shortcut-recorder/shortcut-model.ts
|
|
2
|
+
const MODIFIER_ORDER = [
|
|
3
|
+
"mod",
|
|
4
|
+
"ctrl",
|
|
5
|
+
"alt",
|
|
6
|
+
"shift",
|
|
7
|
+
"meta"
|
|
8
|
+
];
|
|
9
|
+
const isModifier = (part) => MODIFIER_ORDER.includes(part);
|
|
10
|
+
const CODE_KEYS = {
|
|
11
|
+
Comma: ",",
|
|
12
|
+
Period: ".",
|
|
13
|
+
Slash: "/",
|
|
14
|
+
Semicolon: ";",
|
|
15
|
+
Quote: "'",
|
|
16
|
+
BracketLeft: "[",
|
|
17
|
+
BracketRight: "]",
|
|
18
|
+
Backslash: "\\",
|
|
19
|
+
Minus: "-",
|
|
20
|
+
Equal: "=",
|
|
21
|
+
Backquote: "`",
|
|
22
|
+
Space: "space",
|
|
23
|
+
Enter: "enter",
|
|
24
|
+
NumpadEnter: "enter",
|
|
25
|
+
Escape: "escape",
|
|
26
|
+
Backspace: "backspace",
|
|
27
|
+
Delete: "delete",
|
|
28
|
+
Tab: "tab",
|
|
29
|
+
ArrowUp: "up",
|
|
30
|
+
ArrowDown: "down",
|
|
31
|
+
ArrowLeft: "left",
|
|
32
|
+
ArrowRight: "right",
|
|
33
|
+
Home: "home",
|
|
34
|
+
End: "end",
|
|
35
|
+
PageUp: "pageup",
|
|
36
|
+
PageDown: "pagedown"
|
|
37
|
+
};
|
|
38
|
+
const MODIFIER_KEYS = {
|
|
39
|
+
Meta: "meta",
|
|
40
|
+
OS: "meta",
|
|
41
|
+
Control: "ctrl",
|
|
42
|
+
Alt: "alt",
|
|
43
|
+
AltGraph: "alt",
|
|
44
|
+
Shift: "shift"
|
|
45
|
+
};
|
|
46
|
+
const HELD_MODIFIERS = [
|
|
47
|
+
"meta",
|
|
48
|
+
"ctrl",
|
|
49
|
+
"alt",
|
|
50
|
+
"shift"
|
|
51
|
+
];
|
|
52
|
+
/** The physical key id for an event: "k", "1", "enter", "meta", "shift"... `null` for keys that never make a shortcut, such as Caps Lock. */
|
|
53
|
+
function keyId(event) {
|
|
54
|
+
const { code, key } = event;
|
|
55
|
+
if (MODIFIER_KEYS[key]) return MODIFIER_KEYS[key] ?? null;
|
|
56
|
+
if (/^Key[A-Z]$/.test(code)) return code.slice(3).toLowerCase();
|
|
57
|
+
if (/^Digit\d$/.test(code)) return code.slice(5);
|
|
58
|
+
if (/^Numpad\d$/.test(code)) return code.slice(6);
|
|
59
|
+
if (CODE_KEYS[code]) return CODE_KEYS[code] ?? null;
|
|
60
|
+
if (/^F\d{1,2}$/.test(key)) return key.toLowerCase();
|
|
61
|
+
if (key === "CapsLock" || key === "Fn" || key === "Dead" || key === "Unidentified" || key === "Process") return null;
|
|
62
|
+
return key.length === 1 ? key.toLowerCase() : null;
|
|
63
|
+
}
|
|
64
|
+
function splitShortcut(shortcut) {
|
|
65
|
+
const parts = shortcut.toLowerCase().split("+").map((part) => part.trim()).filter(Boolean);
|
|
66
|
+
const key = parts.filter((part) => !isModifier(part)).pop() ?? "";
|
|
67
|
+
return {
|
|
68
|
+
mods: new Set(parts.filter(isModifier)),
|
|
69
|
+
key
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** One spelling per combination: on a Mac, Command is `mod`; elsewhere, Ctrl is. Modifiers come in a fixed order. */
|
|
73
|
+
function normalizeShortcut(shortcut, platform) {
|
|
74
|
+
const { mods, key } = splitShortcut(shortcut);
|
|
75
|
+
if (platform === "mac" && mods.delete("meta")) mods.add("mod");
|
|
76
|
+
if (platform === "other" && mods.delete("ctrl")) mods.add("mod");
|
|
77
|
+
return [...MODIFIER_ORDER.filter((mod) => mods.has(mod)), key].filter(Boolean).join("+");
|
|
78
|
+
}
|
|
79
|
+
/** The modifiers an event holds, in the model's spelling. */
|
|
80
|
+
function modifiersFromEvent(event, platform) {
|
|
81
|
+
const mods = [];
|
|
82
|
+
if (platform === "mac" ? event.metaKey : event.ctrlKey) mods.push("mod");
|
|
83
|
+
if (platform === "mac" && event.ctrlKey) mods.push("ctrl");
|
|
84
|
+
if (event.altKey) mods.push("alt");
|
|
85
|
+
if (event.shiftKey) mods.push("shift");
|
|
86
|
+
if (platform === "other" && event.metaKey) mods.push("meta");
|
|
87
|
+
return mods;
|
|
88
|
+
}
|
|
89
|
+
/** Reads a keydown into a shortcut string, or `null` while only modifiers are down. */
|
|
90
|
+
function shortcutFromEvent(event, platform) {
|
|
91
|
+
const key = keyId(event);
|
|
92
|
+
if (!key || HELD_MODIFIERS.includes(key)) return null;
|
|
93
|
+
return normalizeShortcut([...modifiersFromEvent(event, platform), key].join("+"), platform);
|
|
94
|
+
}
|
|
95
|
+
/** True when a keydown is this shortcut. Use it to run the action a recorded shortcut is bound to. */
|
|
96
|
+
function matchesShortcut(event, shortcut, platform) {
|
|
97
|
+
const pressed = shortcutFromEvent(event, platform);
|
|
98
|
+
return !!pressed && pressed === normalizeShortcut(shortcut, platform);
|
|
99
|
+
}
|
|
100
|
+
const MAC_KEYS = {
|
|
101
|
+
enter: ["↩", "Return"],
|
|
102
|
+
backspace: ["⌫", "Delete"],
|
|
103
|
+
delete: ["⌦", "Forward delete"],
|
|
104
|
+
tab: ["⇥", "Tab"],
|
|
105
|
+
escape: ["esc", "Escape"]
|
|
106
|
+
};
|
|
107
|
+
const SHARED_KEYS = {
|
|
108
|
+
space: ["Space", "Space"],
|
|
109
|
+
enter: ["Enter", "Enter"],
|
|
110
|
+
escape: ["Esc", "Escape"],
|
|
111
|
+
backspace: ["Backspace", "Backspace"],
|
|
112
|
+
delete: ["Del", "Delete"],
|
|
113
|
+
tab: ["Tab", "Tab"],
|
|
114
|
+
up: ["↑", "Up arrow"],
|
|
115
|
+
down: ["↓", "Down arrow"],
|
|
116
|
+
left: ["←", "Left arrow"],
|
|
117
|
+
right: ["→", "Right arrow"],
|
|
118
|
+
home: ["Home", "Home"],
|
|
119
|
+
end: ["End", "End"],
|
|
120
|
+
pageup: ["PgUp", "Page up"],
|
|
121
|
+
pagedown: ["PgDn", "Page down"],
|
|
122
|
+
",": [",", "Comma"],
|
|
123
|
+
".": [".", "Period"],
|
|
124
|
+
"/": ["/", "Slash"],
|
|
125
|
+
";": [";", "Semicolon"],
|
|
126
|
+
"'": ["'", "Quote"],
|
|
127
|
+
"[": ["[", "Left bracket"],
|
|
128
|
+
"]": ["]", "Right bracket"],
|
|
129
|
+
"\\": ["\\", "Backslash"],
|
|
130
|
+
"-": ["-", "Minus"],
|
|
131
|
+
"=": ["=", "Equals"],
|
|
132
|
+
"`": ["`", "Backtick"]
|
|
133
|
+
};
|
|
134
|
+
/** Key caps for a shortcut in platform order: Control, Option, Shift, Command symbols on a Mac; Ctrl, Alt, Shift, Win elsewhere. */
|
|
135
|
+
function shortcutTokens(shortcut, platform) {
|
|
136
|
+
const { mods, key } = splitShortcut(normalizeShortcut(shortcut, platform));
|
|
137
|
+
const tokens = [];
|
|
138
|
+
if (platform === "mac") {
|
|
139
|
+
if (mods.has("ctrl")) tokens.push({
|
|
140
|
+
label: "⌃",
|
|
141
|
+
id: "ctrl",
|
|
142
|
+
spoken: "Control"
|
|
143
|
+
});
|
|
144
|
+
if (mods.has("alt")) tokens.push({
|
|
145
|
+
label: "⌥",
|
|
146
|
+
id: "alt",
|
|
147
|
+
spoken: "Option"
|
|
148
|
+
});
|
|
149
|
+
if (mods.has("shift")) tokens.push({
|
|
150
|
+
label: "⇧",
|
|
151
|
+
id: "shift",
|
|
152
|
+
spoken: "Shift"
|
|
153
|
+
});
|
|
154
|
+
if (mods.has("mod") || mods.has("meta")) tokens.push({
|
|
155
|
+
label: "⌘",
|
|
156
|
+
id: "meta",
|
|
157
|
+
spoken: "Command"
|
|
158
|
+
});
|
|
159
|
+
} else {
|
|
160
|
+
if (mods.has("mod") || mods.has("ctrl")) tokens.push({
|
|
161
|
+
label: "Ctrl",
|
|
162
|
+
id: "ctrl",
|
|
163
|
+
spoken: "Control"
|
|
164
|
+
});
|
|
165
|
+
if (mods.has("alt")) tokens.push({
|
|
166
|
+
label: "Alt",
|
|
167
|
+
id: "alt",
|
|
168
|
+
spoken: "Alt"
|
|
169
|
+
});
|
|
170
|
+
if (mods.has("shift")) tokens.push({
|
|
171
|
+
label: "Shift",
|
|
172
|
+
id: "shift",
|
|
173
|
+
spoken: "Shift"
|
|
174
|
+
});
|
|
175
|
+
if (mods.has("meta")) tokens.push({
|
|
176
|
+
label: "Win",
|
|
177
|
+
id: "meta",
|
|
178
|
+
spoken: "Windows"
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (key) {
|
|
182
|
+
const named = (platform === "mac" ? MAC_KEYS[key] : void 0) ?? SHARED_KEYS[key];
|
|
183
|
+
tokens.push(named ? {
|
|
184
|
+
label: named[0],
|
|
185
|
+
id: key,
|
|
186
|
+
spoken: named[1]
|
|
187
|
+
} : {
|
|
188
|
+
label: key.toUpperCase(),
|
|
189
|
+
id: key,
|
|
190
|
+
spoken: key.toUpperCase()
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return tokens;
|
|
194
|
+
}
|
|
195
|
+
/** The shortcut as text ("⌘⇧K" on a Mac, "Ctrl+Shift+K" elsewhere), plus a spoken form for assistive technology. */
|
|
196
|
+
function formatShortcut(shortcut, platform) {
|
|
197
|
+
const tokens = shortcutTokens(shortcut, platform);
|
|
198
|
+
return {
|
|
199
|
+
text: tokens.map((token) => token.label).join(platform === "mac" ? "" : "+"),
|
|
200
|
+
spoken: tokens.map((token) => token.spoken).join(" ")
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
export { formatShortcut, keyId, matchesShortcut, modifiersFromEvent, normalizeShortcut, shortcutFromEvent, shortcutTokens, splitShortcut };
|
|
205
|
+
|
|
206
|
+
//# sourceMappingURL=shortcut-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortcut-model.js","names":[],"sources":["../../src/shortcut-recorder/shortcut-model.ts"],"sourcesContent":["/*\n * The shortcut model. A shortcut is a string such as \"mod+shift+k\". `mod` is\n * Command on Apple platforms and Control elsewhere, so one binding reads right\n * everywhere. Keys come from the physical key (`event.code`) where it matters,\n * so Option+K records as \"alt+k\" instead of the character it types.\n */\n\nexport type Platform = \"mac\" | \"other\";\n\nexport interface ShortcutToken {\n /** What the key cap shows. */\n label: string;\n /** Physical key id, matched against held keys. */\n id: string;\n /** How a screen reader says it. */\n spoken: string;\n}\n\n/** The parts of a keyboard event the model reads, so a test can pass a plain object. */\nexport type KeyEventLike = Pick<\n KeyboardEvent,\n \"key\" | \"code\" | \"metaKey\" | \"ctrlKey\" | \"altKey\" | \"shiftKey\"\n>;\n\nconst MODIFIER_ORDER = [\"mod\", \"ctrl\", \"alt\", \"shift\", \"meta\"] as const;\ntype Modifier = (typeof MODIFIER_ORDER)[number];\nconst isModifier = (part: string): part is Modifier =>\n (MODIFIER_ORDER as readonly string[]).includes(part);\n\nconst CODE_KEYS: Record<string, string> = {\n Comma: \",\",\n Period: \".\",\n Slash: \"/\",\n Semicolon: \";\",\n Quote: \"'\",\n BracketLeft: \"[\",\n BracketRight: \"]\",\n Backslash: \"\\\\\",\n Minus: \"-\",\n Equal: \"=\",\n Backquote: \"`\",\n Space: \"space\",\n Enter: \"enter\",\n NumpadEnter: \"enter\",\n Escape: \"escape\",\n Backspace: \"backspace\",\n Delete: \"delete\",\n Tab: \"tab\",\n ArrowUp: \"up\",\n ArrowDown: \"down\",\n ArrowLeft: \"left\",\n ArrowRight: \"right\",\n Home: \"home\",\n End: \"end\",\n PageUp: \"pageup\",\n PageDown: \"pagedown\",\n};\n\nconst MODIFIER_KEYS: Record<string, string> = {\n Meta: \"meta\",\n OS: \"meta\",\n Control: \"ctrl\",\n Alt: \"alt\",\n AltGraph: \"alt\",\n Shift: \"shift\",\n};\n\nconst HELD_MODIFIERS = [\"meta\", \"ctrl\", \"alt\", \"shift\"];\n\n/** The physical key id for an event: \"k\", \"1\", \"enter\", \"meta\", \"shift\"... `null` for keys that never make a shortcut, such as Caps Lock. */\nexport function keyId(event: Pick<KeyboardEvent, \"key\" | \"code\">): string | null {\n const { code, key } = event;\n if (MODIFIER_KEYS[key]) return MODIFIER_KEYS[key] ?? null;\n if (/^Key[A-Z]$/.test(code)) return code.slice(3).toLowerCase();\n if (/^Digit\\d$/.test(code)) return code.slice(5);\n if (/^Numpad\\d$/.test(code)) return code.slice(6);\n if (CODE_KEYS[code]) return CODE_KEYS[code] ?? null;\n if (/^F\\d{1,2}$/.test(key)) return key.toLowerCase();\n if (\n key === \"CapsLock\" ||\n key === \"Fn\" ||\n key === \"Dead\" ||\n key === \"Unidentified\" ||\n key === \"Process\"\n )\n return null;\n return key.length === 1 ? key.toLowerCase() : null;\n}\n\nexport function splitShortcut(shortcut: string) {\n const parts = shortcut\n .toLowerCase()\n .split(\"+\")\n .map((part) => part.trim())\n .filter(Boolean);\n const key = parts.filter((part) => !isModifier(part)).pop() ?? \"\";\n return { mods: new Set(parts.filter(isModifier)), key };\n}\n\n/** One spelling per combination: on a Mac, Command is `mod`; elsewhere, Ctrl is. Modifiers come in a fixed order. */\nexport function normalizeShortcut(shortcut: string, platform: Platform) {\n const { mods, key } = splitShortcut(shortcut);\n if (platform === \"mac\" && mods.delete(\"meta\")) mods.add(\"mod\");\n if (platform === \"other\" && mods.delete(\"ctrl\")) mods.add(\"mod\");\n return [...MODIFIER_ORDER.filter((mod) => mods.has(mod)), key].filter(Boolean).join(\"+\");\n}\n\n/** The modifiers an event holds, in the model's spelling. */\nexport function modifiersFromEvent(\n event: Pick<KeyEventLike, \"metaKey\" | \"ctrlKey\" | \"altKey\" | \"shiftKey\">,\n platform: Platform,\n) {\n const mods: string[] = [];\n if (platform === \"mac\" ? event.metaKey : event.ctrlKey) mods.push(\"mod\");\n if (platform === \"mac\" && event.ctrlKey) mods.push(\"ctrl\");\n if (event.altKey) mods.push(\"alt\");\n if (event.shiftKey) mods.push(\"shift\");\n if (platform === \"other\" && event.metaKey) mods.push(\"meta\");\n return mods;\n}\n\n/** Reads a keydown into a shortcut string, or `null` while only modifiers are down. */\nexport function shortcutFromEvent(event: KeyEventLike, platform: Platform) {\n const key = keyId(event);\n if (!key || HELD_MODIFIERS.includes(key)) return null;\n return normalizeShortcut([...modifiersFromEvent(event, platform), key].join(\"+\"), platform);\n}\n\n/** True when a keydown is this shortcut. Use it to run the action a recorded shortcut is bound to. */\nexport function matchesShortcut(event: KeyEventLike, shortcut: string, platform: Platform) {\n const pressed = shortcutFromEvent(event, platform);\n return !!pressed && pressed === normalizeShortcut(shortcut, platform);\n}\n\nconst MAC_KEYS: Record<string, [string, string]> = {\n enter: [\"↩\", \"Return\"],\n backspace: [\"⌫\", \"Delete\"],\n delete: [\"⌦\", \"Forward delete\"],\n tab: [\"⇥\", \"Tab\"],\n escape: [\"esc\", \"Escape\"],\n};\n\nconst SHARED_KEYS: Record<string, [string, string]> = {\n space: [\"Space\", \"Space\"],\n enter: [\"Enter\", \"Enter\"],\n escape: [\"Esc\", \"Escape\"],\n backspace: [\"Backspace\", \"Backspace\"],\n delete: [\"Del\", \"Delete\"],\n tab: [\"Tab\", \"Tab\"],\n up: [\"↑\", \"Up arrow\"],\n down: [\"↓\", \"Down arrow\"],\n left: [\"←\", \"Left arrow\"],\n right: [\"→\", \"Right arrow\"],\n home: [\"Home\", \"Home\"],\n end: [\"End\", \"End\"],\n pageup: [\"PgUp\", \"Page up\"],\n pagedown: [\"PgDn\", \"Page down\"],\n \",\": [\",\", \"Comma\"],\n \".\": [\".\", \"Period\"],\n \"/\": [\"/\", \"Slash\"],\n \";\": [\";\", \"Semicolon\"],\n \"'\": [\"'\", \"Quote\"],\n \"[\": [\"[\", \"Left bracket\"],\n \"]\": [\"]\", \"Right bracket\"],\n \"\\\\\": [\"\\\\\", \"Backslash\"],\n \"-\": [\"-\", \"Minus\"],\n \"=\": [\"=\", \"Equals\"],\n \"`\": [\"`\", \"Backtick\"],\n};\n\n/** Key caps for a shortcut in platform order: Control, Option, Shift, Command symbols on a Mac; Ctrl, Alt, Shift, Win elsewhere. */\nexport function shortcutTokens(shortcut: string, platform: Platform): ShortcutToken[] {\n const { mods, key } = splitShortcut(normalizeShortcut(shortcut, platform));\n const tokens: ShortcutToken[] = [];\n if (platform === \"mac\") {\n if (mods.has(\"ctrl\")) tokens.push({ label: \"⌃\", id: \"ctrl\", spoken: \"Control\" });\n if (mods.has(\"alt\")) tokens.push({ label: \"⌥\", id: \"alt\", spoken: \"Option\" });\n if (mods.has(\"shift\")) tokens.push({ label: \"⇧\", id: \"shift\", spoken: \"Shift\" });\n if (mods.has(\"mod\") || mods.has(\"meta\"))\n tokens.push({ label: \"⌘\", id: \"meta\", spoken: \"Command\" });\n } else {\n if (mods.has(\"mod\") || mods.has(\"ctrl\"))\n tokens.push({ label: \"Ctrl\", id: \"ctrl\", spoken: \"Control\" });\n if (mods.has(\"alt\")) tokens.push({ label: \"Alt\", id: \"alt\", spoken: \"Alt\" });\n if (mods.has(\"shift\")) tokens.push({ label: \"Shift\", id: \"shift\", spoken: \"Shift\" });\n if (mods.has(\"meta\")) tokens.push({ label: \"Win\", id: \"meta\", spoken: \"Windows\" });\n }\n if (key) {\n const named = (platform === \"mac\" ? MAC_KEYS[key] : undefined) ?? SHARED_KEYS[key];\n tokens.push(\n named\n ? { label: named[0], id: key, spoken: named[1] }\n : { label: key.toUpperCase(), id: key, spoken: key.toUpperCase() },\n );\n }\n return tokens;\n}\n\n/** The shortcut as text (\"⌘⇧K\" on a Mac, \"Ctrl+Shift+K\" elsewhere), plus a spoken form for assistive technology. */\nexport function formatShortcut(shortcut: string, platform: Platform) {\n const tokens = shortcutTokens(shortcut, platform);\n return {\n text: tokens.map((token) => token.label).join(platform === \"mac\" ? \"\" : \"+\"),\n spoken: tokens.map((token) => token.spoken).join(\" \"),\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Platform } from "./shortcut-model.js";
|
|
2
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
//#region src/shortcut-recorder/shortcut-recorder.d.ts
|
|
4
|
+
/** The viewer's platform. A server render assumes a Mac and settles on the first client render. */
|
|
5
|
+
export declare function usePlatform(override?: Platform): Platform;
|
|
6
|
+
/**
|
|
7
|
+
* The keys held down right now, by physical id (feed it to `ShortcutKeys` to light the
|
|
8
|
+
* caps as they are pressed). Clears when the window loses focus, and after Command lifts
|
|
9
|
+
* (macOS drops the other keyups).
|
|
10
|
+
*/
|
|
11
|
+
export declare function usePressedKeys(enabled?: boolean): ReadonlySet<string>;
|
|
12
|
+
export interface ShortcutKbdProps extends Omit<HTMLAttributes<HTMLElement>, "className"> {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
/** Draws the key pushed down and lit, such as while it is held. */
|
|
15
|
+
pressed?: boolean;
|
|
16
|
+
/** `warning` tints the cap, for a combination that is taken. */
|
|
17
|
+
tone?: "warning";
|
|
18
|
+
size?: "sm" | "md";
|
|
19
|
+
/** Extra classes. Merged last, so they win conflicts with ours. */
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
/** One key cap. Use it inline in copy, or through `ShortcutKeys` for a whole combination. */
|
|
23
|
+
export declare const ShortcutKbd: import("react").ForwardRefExoticComponent<ShortcutKbdProps & import("react").RefAttributes<HTMLElement>>;
|
|
24
|
+
export interface ShortcutKeysProps {
|
|
25
|
+
/** A shortcut such as `"mod+shift+k"`. `mod` is Command on a Mac and Control elsewhere. */
|
|
26
|
+
shortcut: string;
|
|
27
|
+
/** Defaults to the viewer's platform. */
|
|
28
|
+
platform?: Platform;
|
|
29
|
+
/** Held key ids from `usePressedKeys`: the matching caps light up. */
|
|
30
|
+
pressed?: ReadonlySet<string>;
|
|
31
|
+
size?: "sm" | "md";
|
|
32
|
+
/** Extra classes. Merged last. */
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
/** A shortcut as key caps, with one spoken label ("Command Shift K") for assistive technology. */
|
|
36
|
+
export declare function ShortcutKeys({ shortcut, platform: platformProp, pressed, size, className }: ShortcutKeysProps): import("react").JSX.Element;
|
|
37
|
+
export interface ShortcutBinding {
|
|
38
|
+
shortcut: string;
|
|
39
|
+
/** What the shortcut does, shown when a recording collides with it. */
|
|
40
|
+
label: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ShortcutRecorderProps {
|
|
43
|
+
/** What the shortcut is for, and the field's accessible name. */
|
|
44
|
+
label: string;
|
|
45
|
+
/** Hides the label visually; it stays the accessible name. */
|
|
46
|
+
hideLabel?: boolean;
|
|
47
|
+
/** The shortcut, such as `"mod+shift+k"`, or `null` for none. Controlled when given. */
|
|
48
|
+
value?: string | null;
|
|
49
|
+
defaultValue?: string | null;
|
|
50
|
+
/** `replaced` is the binding a shortcut was taken from after "Use anyway", so the caller can unbind it. */
|
|
51
|
+
onValueChange?: (value: string | null, details: {
|
|
52
|
+
replaced?: ShortcutBinding;
|
|
53
|
+
}) => void;
|
|
54
|
+
/** What the reset button restores. Defaults to `defaultValue`. */
|
|
55
|
+
resetValue?: string | null;
|
|
56
|
+
/** Shortcuts already in use. Recording one of them asks before taking it. */
|
|
57
|
+
bindings?: ShortcutBinding[];
|
|
58
|
+
/** Also warn about combinations a browser or system keeps, such as Command W and Command C. @default true */
|
|
59
|
+
warnReserved?: boolean;
|
|
60
|
+
/** Require Command, Control or Option (function keys are always allowed), so a bare letter cannot be recorded. @default true */
|
|
61
|
+
requireModifier?: boolean;
|
|
62
|
+
/** Defaults to the viewer's platform. */
|
|
63
|
+
platform?: Platform;
|
|
64
|
+
/** Shown while there is no shortcut. @default "Record shortcut" */
|
|
65
|
+
placeholder?: string;
|
|
66
|
+
/** Helper text under the field. */
|
|
67
|
+
description?: string;
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
id?: string;
|
|
70
|
+
/** Extra classes for the wrapper. Merged last. */
|
|
71
|
+
className?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A field that records a keyboard shortcut. Press it (or focus it and press Enter or
|
|
75
|
+
* Space), then press the combination: held modifiers show as caps while you build the
|
|
76
|
+
* chord, the finished shortcut settles into place and is announced, and a combination
|
|
77
|
+
* that is already taken asks before it is used.
|
|
78
|
+
*
|
|
79
|
+
* Keyboard: Escape cancels, Backspace or Delete clears, and Tab leaves the field
|
|
80
|
+
* (it is never swallowed, so recording cannot trap focus). Escape and Tab can still be
|
|
81
|
+
* recorded with a modifier held. Outside recording, Backspace or Delete clears the
|
|
82
|
+
* shortcut, and the reset button restores the default. Caps follow the platform:
|
|
83
|
+
* Command symbols on a Mac, Ctrl and Alt elsewhere.
|
|
84
|
+
*
|
|
85
|
+
* While recording, the chord belongs to the recorder: its keys are kept from the page's
|
|
86
|
+
* own shortcuts. Nothing animates on first render.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* <ShortcutRecorder label="Open command menu" defaultValue="mod+k" onValueChange={save} />
|
|
90
|
+
*/
|
|
91
|
+
export declare function ShortcutRecorder({ label, hideLabel, value, defaultValue, onValueChange, resetValue, bindings, warnReserved, requireModifier, platform: platformProp, placeholder, description, disabled, id, className }: ShortcutRecorderProps): import("react").JSX.Element;
|
|
92
|
+
//#endregion
|
|
93
|
+
//# sourceMappingURL=shortcut-recorder.d.ts.map
|