@passui/react 0.1.16 → 0.1.19
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 +102 -1
- package/dist/types/src/appearance/index.d.ts +2 -0
- package/dist/types/src/appearance/platform.d.ts +9 -0
- package/dist/types/src/appearance/theme.d.ts +71 -0
- package/dist/types/src/components/ambient/ambient.d.ts +12 -0
- package/dist/types/src/components/ambient/index.d.ts +1 -0
- package/dist/types/src/components/button/button-styles.d.ts +12 -0
- package/dist/types/src/components/button/button.d.ts +30 -0
- package/dist/types/src/components/button/icon-button.d.ts +10 -0
- package/dist/types/src/components/button/pending-spinner.d.ts +5 -0
- package/dist/types/src/components/button/use-pending-indicator.d.ts +2 -0
- package/dist/types/src/components/chip/chip.d.ts +7 -0
- package/dist/types/src/components/compact-date-picker/calendar-month.d.ts +25 -0
- package/dist/types/src/components/compact-date-picker/compact-date-picker.d.ts +27 -0
- package/dist/types/src/components/compact-time-picker/compact-time-picker.d.ts +26 -0
- package/dist/types/src/components/compact-time-picker/time-value.d.ts +18 -0
- package/dist/types/src/components/content-view/content-view.d.ts +48 -0
- package/dist/types/src/components/content-view/index.d.ts +1 -0
- package/dist/types/src/components/context-menu/conceal-menu-source.d.ts +2 -0
- package/dist/types/src/components/context-menu/context-menu-host.d.ts +2 -0
- package/dist/types/src/components/context-menu/context-menu-store.d.ts +57 -0
- package/dist/types/src/components/context-menu/menu-navigation.d.ts +6 -0
- package/dist/types/src/components/context-menu/menu-position.d.ts +21 -0
- package/dist/types/src/components/context-menu/menu-reveal.d.ts +22 -0
- package/dist/types/src/components/context-menu/use-context-menu.d.ts +14 -0
- package/dist/types/src/components/conversation/conversation.d.ts +43 -0
- package/dist/types/src/components/conversation/index.d.ts +1 -0
- package/dist/types/src/components/date-picker/date-picker.d.ts +16 -0
- package/dist/types/src/components/date-picker/date-value.d.ts +2 -0
- package/dist/types/src/components/dialog/dialog-host.d.ts +6 -0
- package/dist/types/src/components/dialog/dialog-store.d.ts +21 -0
- package/dist/types/src/components/dialog/dialog.d.ts +30 -0
- package/dist/types/src/components/dialog/index.d.ts +1 -0
- package/dist/types/src/components/disclosure-group/disclosure-group.d.ts +13 -0
- package/dist/types/src/components/divider/divider.d.ts +9 -0
- package/dist/types/src/components/inline-disclosure/inline-disclosure.d.ts +15 -0
- package/dist/types/src/components/labeled-content/labeled-content.d.ts +19 -0
- package/dist/types/src/components/locale-switcher/index.d.ts +1 -0
- package/dist/types/src/components/locale-switcher/locale-switcher.d.ts +10 -0
- package/dist/types/src/components/menu/menu.d.ts +16 -0
- package/dist/types/src/components/picker/picker-trigger.d.ts +2 -0
- package/dist/types/src/components/picker/picker.d.ts +37 -0
- package/dist/types/src/components/popover/popover-fit.d.ts +21 -0
- package/dist/types/src/components/popover/popover.d.ts +14 -0
- package/dist/types/src/components/profile-image/profile-image.d.ts +4 -0
- package/dist/types/src/components/progress-view/progress-view.d.ts +13 -0
- package/dist/types/src/components/search-field/search-field.d.ts +2 -0
- package/dist/types/src/components/search-list/search-list.d.ts +19 -0
- package/dist/types/src/components/section/section.d.ts +15 -0
- package/dist/types/src/components/secure-field/secure-field.d.ts +4 -0
- package/dist/types/src/components/segmented-control/segmented-control.d.ts +20 -0
- package/dist/types/src/components/sheet/modal-environment.d.ts +2 -0
- package/dist/types/src/components/sheet/sheet-portal.d.ts +5 -0
- package/dist/types/src/components/sheet/sheet.d.ts +21 -0
- package/dist/types/src/components/sheet/use-sheet-focus.d.ts +3 -0
- package/dist/types/src/components/sidebar/sidebar.d.ts +18 -0
- package/dist/types/src/components/slider/slider.d.ts +14 -0
- package/dist/types/src/components/stat-tile/index.d.ts +1 -0
- package/dist/types/src/components/stat-tile/stat-tile.d.ts +15 -0
- package/dist/types/src/components/status-indicator/status-indicator.d.ts +14 -0
- package/dist/types/src/components/stepper/stepper.d.ts +19 -0
- package/dist/types/src/components/swatch-picker/swatch-picker.d.ts +17 -0
- package/dist/types/src/components/tab-bar/tab-bar.d.ts +40 -0
- package/dist/types/src/components/tab-view/tab-view.d.ts +24 -0
- package/dist/types/src/components/table/table.d.ts +10 -0
- package/dist/types/src/components/text-editor/text-editor.d.ts +2 -0
- package/dist/types/src/components/text-field/text-field.d.ts +18 -0
- package/dist/types/src/components/toast/toast-store.d.ts +47 -0
- package/dist/types/src/components/toast/toaster.d.ts +10 -0
- package/dist/types/src/components/toggle/toggle.d.ts +17 -0
- package/dist/types/src/components/tooltip/tooltip-host.d.ts +6 -0
- package/dist/types/src/components/view-controller/index.d.ts +1 -0
- package/dist/types/src/components/view-controller/view-controller.d.ts +21 -0
- package/dist/types/src/hooks/scroll/minimize-decision.d.ts +2 -0
- package/dist/types/src/hooks/use-anchored-placement.d.ts +7 -0
- package/dist/types/src/hooks/use-dismiss.d.ts +9 -0
- package/dist/types/src/hooks/use-floating-dismiss.d.ts +3 -0
- package/dist/types/src/hooks/use-media-query.d.ts +21 -0
- package/dist/types/src/hooks/use-minimize-on-scroll.d.ts +6 -0
- package/dist/types/src/hooks/use-visual-viewport.d.ts +4 -0
- package/dist/types/src/hooks/viewport/types.d.ts +19 -0
- package/dist/types/src/hooks/viewport/viewport-metrics.d.ts +3 -0
- package/dist/types/src/icons/icons.d.ts +612 -0
- package/dist/types/src/index.d.ts +58 -0
- package/dist/types/src/lib/anchored-placement.d.ts +39 -0
- package/dist/types/src/lib/class-names.d.ts +2 -0
- package/dist/types/src/lib/clipboard.d.ts +6 -0
- package/dist/types/src/lib/date.d.ts +50 -0
- package/dist/types/src/lib/floating-layers.d.ts +8 -0
- package/dist/types/src/lib/haptics.d.ts +8 -0
- package/dist/types/src/lib/language.d.ts +4 -0
- package/dist/types/src/lib/range-value.d.ts +4 -0
- package/dist/types/src/lib/screen-edges.d.ts +12 -0
- package/dist/types/src/lib/shapes.d.ts +17 -0
- package/dist/types/src/motion/transitions.d.ts +97 -0
- package/dist/types/src/tokens.d.ts +1 -0
- package/package.json +192 -40
- package/src/appearance/platform.tsx +10 -47
- package/src/appearance/theme.tsx +42 -142
- package/src/components/ambient/ambient.tsx +2 -10
- package/src/components/button/button-styles.ts +13 -31
- package/src/components/button/button.tsx +19 -14
- package/src/components/button/icon-button.tsx +14 -56
- package/src/components/button/use-pending-indicator.ts +2 -7
- package/src/components/chip/chip.tsx +8 -13
- package/src/components/compact-date-picker/calendar-month.ts +13 -57
- package/src/components/compact-date-picker/compact-date-picker.tsx +44 -123
- package/src/components/compact-time-picker/compact-time-picker.tsx +46 -130
- package/src/components/compact-time-picker/time-value.ts +4 -16
- package/src/components/content-view/content-view.tsx +13 -56
- package/src/components/context-menu/conceal-menu-source.ts +1 -4
- package/src/components/context-menu/context-menu-host.tsx +125 -195
- package/src/components/context-menu/context-menu-store.ts +3 -11
- package/src/components/context-menu/menu-navigation.ts +29 -0
- package/src/components/context-menu/menu-position.ts +6 -27
- package/src/components/context-menu/menu-reveal.ts +13 -54
- package/src/components/context-menu/use-context-menu.ts +6 -30
- package/src/components/conversation/conversation.tsx +26 -72
- package/src/components/date-picker/date-picker.tsx +8 -37
- package/src/components/date-picker/date-value.ts +5 -30
- package/src/components/dialog/dialog-host.tsx +31 -76
- package/src/components/dialog/dialog-store.ts +1 -3
- package/src/components/dialog/dialog.tsx +23 -80
- package/src/components/disclosure-group/disclosure-group.tsx +70 -0
- package/src/components/divider/divider.tsx +31 -0
- package/src/components/inline-disclosure/inline-disclosure.tsx +49 -0
- package/src/components/labeled-content/labeled-content.tsx +24 -18
- package/src/components/locale-switcher/locale-switcher.tsx +20 -70
- package/src/components/menu/menu.tsx +68 -0
- package/src/components/picker/picker-trigger.ts +10 -0
- package/src/components/picker/picker.tsx +72 -203
- package/src/components/popover/popover-fit.ts +69 -0
- package/src/components/popover/popover.tsx +94 -77
- package/src/components/profile-image/profile-image.tsx +6 -28
- package/src/components/progress-view/progress-view.tsx +65 -0
- package/src/components/search-field/search-field.tsx +27 -25
- package/src/components/search-list/search-list.tsx +43 -69
- package/src/components/section/section.tsx +18 -17
- package/src/components/secure-field/secure-field.tsx +5 -7
- package/src/components/segmented-control/segmented-control.tsx +20 -29
- package/src/components/sheet/modal-environment.ts +16 -54
- package/src/components/sheet/sheet-portal.tsx +10 -42
- package/src/components/sheet/sheet.tsx +17 -25
- package/src/components/sheet/use-sheet-focus.ts +15 -51
- package/src/components/sidebar/sidebar.tsx +27 -30
- package/src/components/slider/slider.tsx +76 -0
- package/src/components/stat-tile/stat-tile.tsx +9 -30
- package/src/components/status-indicator/status-indicator.tsx +12 -19
- package/src/components/stepper/stepper.tsx +80 -0
- package/src/components/swatch-picker/swatch-picker.tsx +19 -15
- package/src/components/tab-bar/tab-bar.tsx +59 -59
- package/src/components/tab-view/tab-view.tsx +52 -57
- package/src/components/table/table.tsx +14 -62
- package/src/components/text-editor/text-editor.tsx +2 -12
- package/src/components/text-field/text-field.tsx +11 -40
- package/src/components/toast/toast-store.ts +9 -30
- package/src/components/toast/toaster.tsx +90 -104
- package/src/components/toggle/toggle.tsx +28 -24
- package/src/components/tooltip/tooltip-host.tsx +71 -69
- package/src/components/view-controller/view-controller.tsx +4 -21
- package/src/hooks/scroll/minimize-decision.ts +1 -5
- package/src/hooks/use-anchored-placement.ts +4 -14
- package/src/hooks/use-dismiss.ts +5 -23
- package/src/hooks/use-floating-dismiss.ts +28 -0
- package/src/hooks/use-media-query.ts +12 -31
- package/src/hooks/use-minimize-on-scroll.ts +10 -34
- package/src/hooks/use-visual-viewport.ts +5 -14
- package/src/hooks/viewport/viewport-metrics.ts +4 -16
- package/src/icons/icons.tsx +167 -121
- package/src/index.ts +9 -1
- package/src/lib/anchored-placement.ts +5 -15
- package/src/lib/class-names.ts +1 -2
- package/src/lib/clipboard.ts +14 -0
- package/src/lib/date.ts +4 -15
- package/src/lib/floating-layers.ts +18 -8
- package/src/lib/haptics.ts +1 -3
- package/src/lib/language.ts +2 -7
- package/src/lib/range-value.ts +32 -0
- package/src/lib/screen-edges.ts +2 -6
- package/src/lib/shapes.ts +5 -20
- package/src/motion/transitions.ts +18 -12
- package/src/components/ambient/ambient.docs.tsx +0 -68
- package/src/components/ambient/examples/ambient-images.tsx +0 -30
- package/src/components/ambient/examples/ambient-now-playing.tsx +0 -55
- package/src/components/ambient/examples/ambient-showcase.tsx +0 -33
- package/src/components/ambient/examples/ambient-usage.tsx +0 -19
- package/src/components/button/button.docs.tsx +0 -116
- package/src/components/button/examples/button-disabled.tsx +0 -19
- package/src/components/button/examples/button-icon.tsx +0 -39
- package/src/components/button/examples/button-link.tsx +0 -12
- package/src/components/button/examples/button-pending.tsx +0 -27
- package/src/components/button/examples/button-showcase.tsx +0 -115
- package/src/components/button/examples/button-sizes.tsx +0 -12
- package/src/components/button/examples/button-usage.tsx +0 -12
- package/src/components/button/examples/button-variants.tsx +0 -15
- package/src/components/button/examples/button-with-icon.tsx +0 -32
- package/src/components/button/examples/icon-button-player.tsx +0 -38
- package/src/components/button/examples/icon-button-showcase.tsx +0 -83
- package/src/components/button/examples/icon-button-usage.tsx +0 -11
- package/src/components/button/examples/icon-button-variants.tsx +0 -39
- package/src/components/button/icon-button.docs.tsx +0 -68
- package/src/components/chip/chip.docs.tsx +0 -37
- package/src/components/chip/examples/chip-in-rows.tsx +0 -19
- package/src/components/chip/examples/chip-showcase.tsx +0 -51
- package/src/components/chip/examples/chip-tones.tsx +0 -13
- package/src/components/chip/examples/chip-usage.tsx +0 -5
- package/src/components/compact-date-picker/compact-date-picker.docs.tsx +0 -81
- package/src/components/compact-date-picker/examples/compact-date-picker-showcase.tsx +0 -35
- package/src/components/compact-date-picker/examples/compact-date-picker-usage.tsx +0 -22
- package/src/components/compact-time-picker/compact-time-picker.docs.tsx +0 -80
- package/src/components/compact-time-picker/examples/compact-time-picker-showcase.tsx +0 -31
- package/src/components/compact-time-picker/examples/compact-time-picker-usage.tsx +0 -21
- package/src/components/content-view/content-view.docs.tsx +0 -61
- package/src/components/content-view/examples/content-view-header-action.tsx +0 -33
- package/src/components/content-view/examples/content-view-showcase.tsx +0 -65
- package/src/components/content-view/examples/content-view-stats.tsx +0 -35
- package/src/components/content-view/examples/content-view-usage.tsx +0 -14
- package/src/components/context-menu/context-menu.docs.tsx +0 -92
- package/src/components/context-menu/examples/context-menu-checked.tsx +0 -37
- package/src/components/context-menu/examples/context-menu-list.tsx +0 -85
- package/src/components/context-menu/examples/context-menu-showcase.tsx +0 -56
- package/src/components/context-menu/examples/context-menu-toolbar.tsx +0 -63
- package/src/components/context-menu/examples/context-menu-usage.tsx +0 -24
- package/src/components/conversation/conversation.docs.tsx +0 -88
- package/src/components/conversation/examples/conversation-composer.tsx +0 -36
- package/src/components/conversation/examples/conversation-days.tsx +0 -48
- package/src/components/conversation/examples/conversation-showcase.tsx +0 -71
- package/src/components/conversation/examples/conversation-usage.tsx +0 -28
- package/src/components/date-picker/date-picker.docs.tsx +0 -88
- package/src/components/date-picker/examples/date-picker-locales.tsx +0 -41
- package/src/components/date-picker/examples/date-picker-past-only.tsx +0 -29
- package/src/components/date-picker/examples/date-picker-showcase.tsx +0 -49
- package/src/components/date-picker/examples/date-picker-usage.tsx +0 -22
- package/src/components/dialog/dialog.docs.tsx +0 -114
- package/src/components/dialog/examples/dialog-confirm.tsx +0 -24
- package/src/components/dialog/examples/dialog-form.tsx +0 -46
- package/src/components/dialog/examples/dialog-inline.tsx +0 -48
- package/src/components/dialog/examples/dialog-showcase.tsx +0 -53
- package/src/components/dialog/examples/dialog-usage.tsx +0 -31
- package/src/components/labeled-content/examples/labeled-content-descriptions.tsx +0 -37
- package/src/components/labeled-content/examples/labeled-content-showcase.tsx +0 -54
- package/src/components/labeled-content/examples/labeled-content-usage.tsx +0 -22
- package/src/components/labeled-content/examples/labeled-content-values.tsx +0 -26
- package/src/components/labeled-content/examples/labeled-content-wide.tsx +0 -46
- package/src/components/labeled-content/labeled-content.docs.tsx +0 -69
- package/src/components/locale-switcher/examples/locale-switcher-native-names.tsx +0 -30
- package/src/components/locale-switcher/examples/locale-switcher-showcase.tsx +0 -46
- package/src/components/locale-switcher/examples/locale-switcher-translated-page.tsx +0 -35
- package/src/components/locale-switcher/examples/locale-switcher-usage.tsx +0 -20
- package/src/components/locale-switcher/locale-switcher.docs.tsx +0 -91
- package/src/components/picker/examples/picker-details.tsx +0 -44
- package/src/components/picker/examples/picker-searchable.tsx +0 -48
- package/src/components/picker/examples/picker-showcase.tsx +0 -66
- package/src/components/picker/examples/picker-usage.tsx +0 -20
- package/src/components/picker/picker.docs.tsx +0 -68
- package/src/components/popover/examples/popover-help.tsx +0 -57
- package/src/components/popover/examples/popover-menu.tsx +0 -51
- package/src/components/popover/examples/popover-showcase.tsx +0 -61
- package/src/components/popover/examples/popover-usage.tsx +0 -31
- package/src/components/popover/popover.docs.tsx +0 -84
- package/src/components/profile-image/examples/profile-image-fallbacks.tsx +0 -29
- package/src/components/profile-image/examples/profile-image-group.tsx +0 -34
- package/src/components/profile-image/examples/profile-image-showcase.tsx +0 -30
- package/src/components/profile-image/examples/profile-image-usage.tsx +0 -14
- package/src/components/profile-image/profile-image.docs.tsx +0 -81
- package/src/components/search-field/examples/search-field-filter.tsx +0 -53
- package/src/components/search-field/examples/search-field-showcase.tsx +0 -56
- package/src/components/search-field/examples/search-field-toolbar.tsx +0 -27
- package/src/components/search-field/examples/search-field-usage.tsx +0 -18
- package/src/components/search-field/search-field.docs.tsx +0 -58
- package/src/components/search-list/examples/search-list-dropdown.tsx +0 -53
- package/src/components/search-list/examples/search-list-groups.tsx +0 -64
- package/src/components/search-list/examples/search-list-showcase.tsx +0 -67
- package/src/components/search-list/examples/search-list-usage.tsx +0 -27
- package/src/components/search-list/search-list.docs.tsx +0 -87
- package/src/components/section/examples/section-actions.tsx +0 -35
- package/src/components/section/examples/section-groups.tsx +0 -41
- package/src/components/section/examples/section-showcase.tsx +0 -63
- package/src/components/section/examples/section-usage.tsx +0 -19
- package/src/components/section/section.docs.tsx +0 -51
- package/src/components/secure-field/examples/secure-field-new-password.tsx +0 -56
- package/src/components/secure-field/examples/secure-field-reveal.tsx +0 -20
- package/src/components/secure-field/examples/secure-field-showcase.tsx +0 -62
- package/src/components/secure-field/examples/secure-field-usage.tsx +0 -19
- package/src/components/secure-field/secure-field.docs.tsx +0 -72
- package/src/components/segmented-control/examples/segmented-control-overflow.tsx +0 -28
- package/src/components/segmented-control/examples/segmented-control-showcase.tsx +0 -59
- package/src/components/segmented-control/examples/segmented-control-usage.tsx +0 -20
- package/src/components/segmented-control/examples/segmented-control-views.tsx +0 -32
- package/src/components/segmented-control/segmented-control.docs.tsx +0 -61
- package/src/components/sheet/examples/sheet-choices.tsx +0 -58
- package/src/components/sheet/examples/sheet-share.tsx +0 -51
- package/src/components/sheet/examples/sheet-showcase.tsx +0 -74
- package/src/components/sheet/examples/sheet-usage.tsx +0 -32
- package/src/components/sheet/sheet.docs.tsx +0 -75
- package/src/components/sidebar/examples/sidebar-groups.tsx +0 -133
- package/src/components/sidebar/examples/sidebar-showcase.tsx +0 -123
- package/src/components/sidebar/examples/sidebar-unread.tsx +0 -66
- package/src/components/sidebar/examples/sidebar-usage.tsx +0 -52
- package/src/components/sidebar/sidebar.docs.tsx +0 -135
- package/src/components/stat-tile/examples/stat-tile-filters.tsx +0 -32
- package/src/components/stat-tile/examples/stat-tile-grid.tsx +0 -21
- package/src/components/stat-tile/examples/stat-tile-showcase.tsx +0 -52
- package/src/components/stat-tile/examples/stat-tile-usage.tsx +0 -13
- package/src/components/stat-tile/stat-tile.docs.tsx +0 -60
- package/src/components/status-indicator/examples/status-indicator-live.tsx +0 -34
- package/src/components/status-indicator/examples/status-indicator-showcase.tsx +0 -39
- package/src/components/status-indicator/examples/status-indicator-states.tsx +0 -17
- package/src/components/status-indicator/examples/status-indicator-usage.tsx +0 -9
- package/src/components/status-indicator/status-indicator.docs.tsx +0 -43
- package/src/components/swatch-picker/examples/swatch-picker-accents.tsx +0 -42
- package/src/components/swatch-picker/examples/swatch-picker-labels.tsx +0 -45
- package/src/components/swatch-picker/examples/swatch-picker-showcase.tsx +0 -70
- package/src/components/swatch-picker/examples/swatch-picker-usage.tsx +0 -39
- package/src/components/swatch-picker/swatch-picker.docs.tsx +0 -60
- package/src/components/tab-bar/examples/tab-bar-five-tabs.tsx +0 -66
- package/src/components/tab-bar/examples/tab-bar-minimize.tsx +0 -71
- package/src/components/tab-bar/examples/tab-bar-showcase.tsx +0 -82
- package/src/components/tab-bar/examples/tab-bar-usage.tsx +0 -54
- package/src/components/tab-bar/tab-bar.docs.tsx +0 -136
- package/src/components/tab-view/examples/tab-view-keyboard.tsx +0 -39
- package/src/components/tab-view/examples/tab-view-settings.tsx +0 -56
- package/src/components/tab-view/examples/tab-view-showcase.tsx +0 -53
- package/src/components/tab-view/examples/tab-view-usage.tsx +0 -23
- package/src/components/tab-view/tab-view.docs.tsx +0 -77
- package/src/components/table/examples/table-empty.tsx +0 -53
- package/src/components/table/examples/table-invoices.tsx +0 -102
- package/src/components/table/examples/table-selection.tsx +0 -150
- package/src/components/table/examples/table-showcase.tsx +0 -115
- package/src/components/table/examples/table-usage.tsx +0 -67
- package/src/components/table/examples/table-wide.tsx +0 -75
- package/src/components/table/table.docs.tsx +0 -131
- package/src/components/text-editor/examples/text-editor-comment.tsx +0 -48
- package/src/components/text-editor/examples/text-editor-count.tsx +0 -38
- package/src/components/text-editor/examples/text-editor-showcase.tsx +0 -58
- package/src/components/text-editor/examples/text-editor-usage.tsx +0 -25
- package/src/components/text-editor/text-editor.docs.tsx +0 -61
- package/src/components/text-field/examples/text-field-icons.tsx +0 -72
- package/src/components/text-field/examples/text-field-showcase.tsx +0 -50
- package/src/components/text-field/examples/text-field-usage.tsx +0 -18
- package/src/components/text-field/examples/text-field-validation.tsx +0 -27
- package/src/components/text-field/text-field.docs.tsx +0 -118
- package/src/components/toast/examples/toast-action.tsx +0 -32
- package/src/components/toast/examples/toast-promise.tsx +0 -45
- package/src/components/toast/examples/toast-showcase.tsx +0 -49
- package/src/components/toast/examples/toast-usage.tsx +0 -13
- package/src/components/toast/toast.docs.tsx +0 -79
- package/src/components/toggle/examples/toggle-checkboxes.tsx +0 -43
- package/src/components/toggle/examples/toggle-settings.tsx +0 -31
- package/src/components/toggle/examples/toggle-showcase.tsx +0 -59
- package/src/components/toggle/examples/toggle-usage.tsx +0 -13
- package/src/components/toggle/toggle.docs.tsx +0 -69
- package/src/components/tooltip/examples/tooltip-icon-buttons.tsx +0 -27
- package/src/components/tooltip/examples/tooltip-shortcuts.tsx +0 -38
- package/src/components/tooltip/examples/tooltip-showcase.tsx +0 -44
- package/src/components/tooltip/examples/tooltip-usage.tsx +0 -13
- package/src/components/tooltip/tooltip.docs.tsx +0 -56
- package/src/components/view-controller/examples/view-controller-action.tsx +0 -27
- package/src/components/view-controller/examples/view-controller-settings.tsx +0 -31
- package/src/components/view-controller/examples/view-controller-showcase.tsx +0 -45
- package/src/components/view-controller/examples/view-controller-usage.tsx +0 -19
- package/src/components/view-controller/view-controller.docs.tsx +0 -71
- package/src/docs/index.ts +0 -3
- package/src/docs/registry.ts +0 -113
- package/src/docs/snippet.ts +0 -17
- package/src/docs/types.ts +0 -180
package/src/appearance/theme.tsx
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
memo,
|
|
5
|
-
useCallback,
|
|
6
|
-
useContext,
|
|
7
|
-
useEffect,
|
|
8
|
-
useMemo,
|
|
9
|
-
useState,
|
|
10
|
-
} from "react"
|
|
11
|
-
import type {
|
|
12
|
-
Dispatch,
|
|
13
|
-
PropsWithChildren,
|
|
14
|
-
ReactNode,
|
|
15
|
-
SetStateAction,
|
|
16
|
-
} from "react"
|
|
2
|
+
import { createContext, memo, useCallback, useContext, useEffect, useMemo, useState } from "react"
|
|
3
|
+
import type { Dispatch, PropsWithChildren, ReactNode, SetStateAction } from "react"
|
|
17
4
|
|
|
18
5
|
type ValueObject = {
|
|
19
6
|
[themeName: string]: string
|
|
@@ -40,8 +27,7 @@ export type SystemTheme = "dark" | "light"
|
|
|
40
27
|
|
|
41
28
|
export type Attribute = `data-${string}` | "class"
|
|
42
29
|
|
|
43
|
-
export interface ThemeProviderProps
|
|
44
|
-
extends PropsWithChildren {
|
|
30
|
+
export interface ThemeProviderProps extends PropsWithChildren {
|
|
45
31
|
/** List of all available theme names */
|
|
46
32
|
themes?: Array<string> | undefined
|
|
47
33
|
/** Forced theme name for the current page */
|
|
@@ -67,9 +53,7 @@ export interface ThemeProviderProps
|
|
|
67
53
|
const colorSchemes = ["light", "dark"]
|
|
68
54
|
const MEDIA = "(prefers-color-scheme: dark)"
|
|
69
55
|
const isServer = typeof window === "undefined"
|
|
70
|
-
const ThemeContext = createContext<UseThemeProps | undefined>(
|
|
71
|
-
undefined
|
|
72
|
-
)
|
|
56
|
+
const ThemeContext = createContext<UseThemeProps | undefined>(undefined)
|
|
73
57
|
const defaultContext: UseThemeProps = {
|
|
74
58
|
setTheme: () => {
|
|
75
59
|
/* no-op */
|
|
@@ -83,8 +67,7 @@ const defaultContext: UseThemeProps = {
|
|
|
83
67
|
* @example
|
|
84
68
|
* const { theme, setTheme } = useTheme()
|
|
85
69
|
*/
|
|
86
|
-
export const useTheme = (): UseThemeProps =>
|
|
87
|
-
useContext(ThemeContext) ?? defaultContext
|
|
70
|
+
export const useTheme = (): UseThemeProps => useContext(ThemeContext) ?? defaultContext
|
|
88
71
|
|
|
89
72
|
/**
|
|
90
73
|
* Theme provider component is used to wrap your app &
|
|
@@ -103,9 +86,7 @@ export const useTheme = (): UseThemeProps =>
|
|
|
103
86
|
* <App />
|
|
104
87
|
* </ThemeProvider>
|
|
105
88
|
*/
|
|
106
|
-
export const ThemeProvider = (
|
|
107
|
-
props: ThemeProviderProps
|
|
108
|
-
): ReactNode => {
|
|
89
|
+
export const ThemeProvider = (props: ThemeProviderProps): ReactNode => {
|
|
109
90
|
const context = useContext(ThemeContext)
|
|
110
91
|
// Ignore nested context providers, just passthrough children
|
|
111
92
|
if (context) {
|
|
@@ -128,15 +109,10 @@ const Theme = ({
|
|
|
128
109
|
children,
|
|
129
110
|
nonce,
|
|
130
111
|
}: ThemeProviderProps) => {
|
|
131
|
-
const [theme, setThemeState] = useState(() =>
|
|
132
|
-
getTheme(storageKey, defaultTheme)
|
|
133
|
-
)
|
|
112
|
+
const [theme, setThemeState] = useState(() => getTheme(storageKey, defaultTheme))
|
|
134
113
|
|
|
135
114
|
const applyClassAttribute = useCallback(
|
|
136
|
-
(
|
|
137
|
-
name: string | undefined,
|
|
138
|
-
attrValues: Array<string>
|
|
139
|
-
) => {
|
|
115
|
+
(name: string | undefined, attrValues: Array<string>) => {
|
|
140
116
|
const d = document.documentElement
|
|
141
117
|
d.classList.remove(...attrValues)
|
|
142
118
|
if (name) {
|
|
@@ -146,26 +122,19 @@ const Theme = ({
|
|
|
146
122
|
[]
|
|
147
123
|
)
|
|
148
124
|
|
|
149
|
-
const applyDataAttribute = useCallback(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
[]
|
|
159
|
-
)
|
|
125
|
+
const applyDataAttribute = useCallback((attr: string, name: string | undefined) => {
|
|
126
|
+
const d = document.documentElement
|
|
127
|
+
if (name) {
|
|
128
|
+
d.setAttribute(attr, name)
|
|
129
|
+
} else {
|
|
130
|
+
d.removeAttribute(attr)
|
|
131
|
+
}
|
|
132
|
+
}, [])
|
|
160
133
|
|
|
161
134
|
const applyAttributesToDOM = useCallback(
|
|
162
135
|
(resolved: string) => {
|
|
163
|
-
const attributeList = Array.isArray(attribute)
|
|
164
|
-
|
|
165
|
-
: [attribute]
|
|
166
|
-
const attrValues = value
|
|
167
|
-
? Object.values(value)
|
|
168
|
-
: themes
|
|
136
|
+
const attributeList = Array.isArray(attribute) ? attribute : [attribute]
|
|
137
|
+
const attrValues = value ? Object.values(value) : themes
|
|
169
138
|
const name = value ? value[resolved] : resolved
|
|
170
139
|
|
|
171
140
|
for (const attr of attributeList) {
|
|
@@ -176,13 +145,7 @@ const Theme = ({
|
|
|
176
145
|
}
|
|
177
146
|
}
|
|
178
147
|
},
|
|
179
|
-
[
|
|
180
|
-
attribute,
|
|
181
|
-
themes,
|
|
182
|
-
value,
|
|
183
|
-
applyClassAttribute,
|
|
184
|
-
applyDataAttribute,
|
|
185
|
-
]
|
|
148
|
+
[attribute, themes, value, applyClassAttribute, applyDataAttribute]
|
|
186
149
|
)
|
|
187
150
|
|
|
188
151
|
const applyColorScheme = useCallback(
|
|
@@ -190,18 +153,9 @@ const Theme = ({
|
|
|
190
153
|
if (!enableColorScheme) {
|
|
191
154
|
return
|
|
192
155
|
}
|
|
193
|
-
const fallback = colorSchemes.includes(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
? defaultTheme
|
|
197
|
-
: null
|
|
198
|
-
const colorScheme = colorSchemes.includes(
|
|
199
|
-
resolved
|
|
200
|
-
)
|
|
201
|
-
? resolved
|
|
202
|
-
: fallback
|
|
203
|
-
document.documentElement.style.colorScheme =
|
|
204
|
-
colorScheme || ""
|
|
156
|
+
const fallback = colorSchemes.includes(defaultTheme) ? defaultTheme : null
|
|
157
|
+
const colorScheme = colorSchemes.includes(resolved) ? resolved : fallback
|
|
158
|
+
document.documentElement.style.colorScheme = colorScheme || ""
|
|
205
159
|
},
|
|
206
160
|
[enableColorScheme, defaultTheme]
|
|
207
161
|
)
|
|
@@ -212,32 +166,19 @@ const Theme = ({
|
|
|
212
166
|
if (!nextTheme) {
|
|
213
167
|
return
|
|
214
168
|
}
|
|
215
|
-
const resolved =
|
|
216
|
-
|
|
217
|
-
? getSystemTheme()
|
|
218
|
-
: nextTheme
|
|
219
|
-
const enable = disableTransitionOnChange
|
|
220
|
-
? disableAnimation()
|
|
221
|
-
: null
|
|
169
|
+
const resolved = nextTheme === "system" && enableSystem ? getSystemTheme() : nextTheme
|
|
170
|
+
const enable = disableTransitionOnChange ? disableAnimation() : null
|
|
222
171
|
applyAttributesToDOM(resolved)
|
|
223
172
|
applyColorScheme(resolved)
|
|
224
173
|
enable?.()
|
|
225
174
|
},
|
|
226
|
-
[
|
|
227
|
-
enableSystem,
|
|
228
|
-
disableTransitionOnChange,
|
|
229
|
-
applyAttributesToDOM,
|
|
230
|
-
applyColorScheme,
|
|
231
|
-
]
|
|
175
|
+
[enableSystem, disableTransitionOnChange, applyAttributesToDOM, applyColorScheme]
|
|
232
176
|
)
|
|
233
177
|
|
|
234
178
|
// Set theme state and save to local storage
|
|
235
179
|
const setTheme = useCallback(
|
|
236
180
|
(newValue: SetStateAction<string>) => {
|
|
237
|
-
const newTheme =
|
|
238
|
-
typeof newValue === "function"
|
|
239
|
-
? newValue(theme ?? "")
|
|
240
|
-
: newValue
|
|
181
|
+
const newTheme = typeof newValue === "function" ? newValue(theme ?? "") : newValue
|
|
241
182
|
setThemeState(newTheme)
|
|
242
183
|
|
|
243
184
|
// Save to storage
|
|
@@ -245,9 +186,7 @@ const Theme = ({
|
|
|
245
186
|
localStorage.setItem(storageKey, newTheme)
|
|
246
187
|
} catch {
|
|
247
188
|
// localStorage might not be available
|
|
248
|
-
console.error(
|
|
249
|
-
"Failed to save theme to localStorage"
|
|
250
|
-
)
|
|
189
|
+
console.error("Failed to save theme to localStorage")
|
|
251
190
|
}
|
|
252
191
|
},
|
|
253
192
|
[theme, storageKey]
|
|
@@ -255,11 +194,7 @@ const Theme = ({
|
|
|
255
194
|
|
|
256
195
|
const handleMediaQuery = useCallback(
|
|
257
196
|
(_event: MediaQueryListEvent | MediaQueryList) => {
|
|
258
|
-
if (
|
|
259
|
-
theme === "system" &&
|
|
260
|
-
enableSystem &&
|
|
261
|
-
!forcedTheme
|
|
262
|
-
) {
|
|
197
|
+
if (theme === "system" && enableSystem && !forcedTheme) {
|
|
263
198
|
applyTheme("system")
|
|
264
199
|
}
|
|
265
200
|
},
|
|
@@ -276,11 +211,7 @@ const Theme = ({
|
|
|
276
211
|
// Intentionally use deprecated listener methods to support iOS 13 and older browsers
|
|
277
212
|
media.addEventListener("change", handleMediaQuery)
|
|
278
213
|
handleMediaQuery(media)
|
|
279
|
-
return () =>
|
|
280
|
-
media.removeEventListener(
|
|
281
|
-
"change",
|
|
282
|
-
handleMediaQuery
|
|
283
|
-
)
|
|
214
|
+
return () => media.removeEventListener("change", handleMediaQuery)
|
|
284
215
|
}, [handleMediaQuery])
|
|
285
216
|
|
|
286
217
|
// localStorage event handling, allow to sync theme changes between tabs
|
|
@@ -299,11 +230,7 @@ const Theme = ({
|
|
|
299
230
|
}
|
|
300
231
|
|
|
301
232
|
window.addEventListener("storage", handleStorage)
|
|
302
|
-
return () =>
|
|
303
|
-
window.removeEventListener(
|
|
304
|
-
"storage",
|
|
305
|
-
handleStorage
|
|
306
|
-
)
|
|
233
|
+
return () => window.removeEventListener("storage", handleStorage)
|
|
307
234
|
}, [defaultTheme, setTheme, storageKey])
|
|
308
235
|
|
|
309
236
|
// Whenever theme or forcedTheme changes, apply it
|
|
@@ -316,14 +243,9 @@ const Theme = ({
|
|
|
316
243
|
theme,
|
|
317
244
|
setTheme,
|
|
318
245
|
forcedTheme,
|
|
319
|
-
themes: enableSystem
|
|
320
|
-
? [...themes, "system"]
|
|
321
|
-
: themes,
|
|
246
|
+
themes: enableSystem ? [...themes, "system"] : themes,
|
|
322
247
|
systemTheme: enableSystem
|
|
323
|
-
? (getSystemTheme() as
|
|
324
|
-
| "dark"
|
|
325
|
-
| "light"
|
|
326
|
-
| undefined)
|
|
248
|
+
? (getSystemTheme() as "dark" | "light" | undefined)
|
|
327
249
|
: undefined,
|
|
328
250
|
}),
|
|
329
251
|
[theme, forcedTheme, enableSystem, themes, setTheme]
|
|
@@ -422,9 +344,7 @@ const disableAnimation = () => {
|
|
|
422
344
|
}
|
|
423
345
|
}
|
|
424
346
|
|
|
425
|
-
const getSystemTheme = (
|
|
426
|
-
e?: MediaQueryList | MediaQueryListEvent
|
|
427
|
-
) => {
|
|
347
|
+
const getSystemTheme = (e?: MediaQueryList | MediaQueryListEvent) => {
|
|
428
348
|
if (isServer) {
|
|
429
349
|
return "light"
|
|
430
350
|
}
|
|
@@ -451,9 +371,7 @@ export const script = (
|
|
|
451
371
|
) => {
|
|
452
372
|
const el = document.documentElement
|
|
453
373
|
const systemThemes = ["light", "dark"]
|
|
454
|
-
const attributes = Array.isArray(attribute)
|
|
455
|
-
? attribute
|
|
456
|
-
: [attribute]
|
|
374
|
+
const attributes = Array.isArray(attribute) ? attribute : [attribute]
|
|
457
375
|
const attrValues = value ? Object.values(value) : themes
|
|
458
376
|
|
|
459
377
|
function applyClassAttr(name: string | undefined) {
|
|
@@ -463,10 +381,7 @@ export const script = (
|
|
|
463
381
|
}
|
|
464
382
|
}
|
|
465
383
|
|
|
466
|
-
function applyDataAttr(
|
|
467
|
-
attr: string,
|
|
468
|
-
name: string | undefined
|
|
469
|
-
) {
|
|
384
|
+
function applyDataAttr(attr: string, name: string | undefined) {
|
|
470
385
|
if (name) {
|
|
471
386
|
el.setAttribute(attr, name)
|
|
472
387
|
} else {
|
|
@@ -493,39 +408,24 @@ export const script = (
|
|
|
493
408
|
return
|
|
494
409
|
}
|
|
495
410
|
|
|
496
|
-
const fallback = systemThemes.includes(defaultTheme)
|
|
497
|
-
|
|
498
|
-
: null
|
|
499
|
-
const colorScheme = systemThemes.includes(theme)
|
|
500
|
-
? theme
|
|
501
|
-
: fallback
|
|
411
|
+
const fallback = systemThemes.includes(defaultTheme) ? defaultTheme : null
|
|
412
|
+
const colorScheme = systemThemes.includes(theme) ? theme : fallback
|
|
502
413
|
el.style.colorScheme = colorScheme || ""
|
|
503
414
|
}
|
|
504
415
|
|
|
505
416
|
function resolveSystemTheme() {
|
|
506
|
-
return window.matchMedia(
|
|
507
|
-
"(prefers-color-scheme: dark)"
|
|
508
|
-
).matches
|
|
509
|
-
? "dark"
|
|
510
|
-
: "light"
|
|
417
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
|
|
511
418
|
}
|
|
512
419
|
|
|
513
420
|
if (forcedTheme) {
|
|
514
421
|
const resolvedForcedTheme =
|
|
515
|
-
forcedTheme === "system" && enableSystem
|
|
516
|
-
? resolveSystemTheme()
|
|
517
|
-
: forcedTheme
|
|
422
|
+
forcedTheme === "system" && enableSystem ? resolveSystemTheme() : forcedTheme
|
|
518
423
|
updateDOM(resolvedForcedTheme)
|
|
519
424
|
} else {
|
|
520
425
|
try {
|
|
521
|
-
const themeName =
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
const isSystem =
|
|
525
|
-
enableSystem && themeName === "system"
|
|
526
|
-
const theme = isSystem
|
|
527
|
-
? resolveSystemTheme()
|
|
528
|
-
: themeName
|
|
426
|
+
const themeName = localStorage.getItem(storageKey) || defaultTheme
|
|
427
|
+
const isSystem = enableSystem && themeName === "system"
|
|
428
|
+
const theme = isSystem ? resolveSystemTheme() : themeName
|
|
529
429
|
updateDOM(theme)
|
|
530
430
|
} catch {
|
|
531
431
|
// localStorage might not be available
|
|
@@ -11,17 +11,9 @@ type AmbientProps = ComponentPropsWithoutRef<"section"> & {
|
|
|
11
11
|
* edge: a blown-up, blurred copy of the image masked into a circle that
|
|
12
12
|
* fades into the page, the way Apple lets a photo light its surroundings.
|
|
13
13
|
*/
|
|
14
|
-
export function Ambient({
|
|
15
|
-
src,
|
|
16
|
-
className,
|
|
17
|
-
children,
|
|
18
|
-
...props
|
|
19
|
-
}: AmbientProps) {
|
|
14
|
+
export function Ambient({ src, className, children, ...props }: AmbientProps) {
|
|
20
15
|
return (
|
|
21
|
-
<section
|
|
22
|
-
className={cn("relative isolate", className)}
|
|
23
|
-
{...props}
|
|
24
|
-
>
|
|
16
|
+
<section className={cn("relative isolate", className)} {...props}>
|
|
25
17
|
{src && (
|
|
26
18
|
<img
|
|
27
19
|
aria-hidden
|
|
@@ -7,30 +7,24 @@ export type ButtonVariant =
|
|
|
7
7
|
| "link"
|
|
8
8
|
| "accent"
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
| "icon-full"
|
|
10
|
+
/** Icon-only buttons use the same sizing contract as Button. */
|
|
11
|
+
export const iconButtonSizes = {
|
|
12
|
+
icon: "size-11 p-0 rounded-full",
|
|
13
|
+
"icon-xs": "size-8 p-0 rounded-full",
|
|
14
|
+
"icon-sm": "size-9 p-0 rounded-full",
|
|
15
|
+
"icon-lg": "size-12 p-0 rounded-full",
|
|
16
|
+
} as const
|
|
17
|
+
|
|
18
|
+
export type IconButtonSize = keyof typeof iconButtonSizes
|
|
20
19
|
|
|
21
|
-
export type
|
|
22
|
-
| "icon"
|
|
23
|
-
| "icon-xs"
|
|
24
|
-
| "icon-sm"
|
|
25
|
-
| "icon-lg"
|
|
20
|
+
export type ButtonSize = "default" | "xs" | "sm" | "lg" | "icon-full" | IconButtonSize
|
|
26
21
|
|
|
27
22
|
export const buttonVariants: Record<ButtonVariant, string> = {
|
|
28
23
|
default:
|
|
29
24
|
"bg-inverse text-on-inverse shadow-[inset_0_1px_0_rgb(255_255_255/0.14),0_1px_2px_rgb(0_0_0/0.18),0_6px_16px_-6px_rgb(0_0_0/0.35)] hover:brightness-[1.12]",
|
|
30
25
|
destructive:
|
|
31
26
|
"bg-danger text-background shadow-[inset_0_1px_0_rgb(255_255_255/0.14),0_1px_2px_rgb(0_0_0/0.18),0_6px_16px_-6px_rgb(0_0_0/0.35)] hover:brightness-[1.08]",
|
|
32
|
-
outline:
|
|
33
|
-
"border border-separator bg-transparent text-label hover:bg-fill/60",
|
|
27
|
+
outline: "border border-separator bg-transparent text-label hover:bg-fill/60",
|
|
34
28
|
secondary:
|
|
35
29
|
"bg-elevated text-label shadow-[inset_0_0_0_0.5px_color-mix(in_srgb,var(--color-separator)_55%,transparent),0_1px_2px_rgb(40_30_0/0.06)] hover:bg-fill/60",
|
|
36
30
|
ghost: "bg-transparent text-label hover:bg-fill/80",
|
|
@@ -43,18 +37,6 @@ export const buttonSizes: Record<ButtonSize, string> = {
|
|
|
43
37
|
xs: "h-8 px-3 text-caption rounded-full",
|
|
44
38
|
sm: "h-9 px-4 text-subheadline rounded-full",
|
|
45
39
|
lg: "h-12 px-6 text-body rounded-full",
|
|
46
|
-
|
|
47
|
-
"icon-
|
|
48
|
-
"icon-sm": "size-9 p-0 rounded-full",
|
|
49
|
-
"icon-lg": "size-12 p-0 rounded-full",
|
|
50
|
-
"icon-full":
|
|
51
|
-
"h-11 w-full px-5 text-subheadline rounded-full",
|
|
40
|
+
...iconButtonSizes,
|
|
41
|
+
"icon-full": "h-11 w-full px-5 text-subheadline rounded-full",
|
|
52
42
|
}
|
|
53
|
-
|
|
54
|
-
export const iconButtonSizes: Record<IconButtonSize, string> =
|
|
55
|
-
{
|
|
56
|
-
icon: "size-11",
|
|
57
|
-
"icon-xs": "size-8",
|
|
58
|
-
"icon-sm": "size-9",
|
|
59
|
-
"icon-lg": "size-12",
|
|
60
|
-
}
|
|
@@ -2,12 +2,7 @@ import { type ButtonHTMLAttributes, forwardRef } from "react"
|
|
|
2
2
|
import { cn } from "../../lib/class-names"
|
|
3
3
|
import { PendingSpinner } from "./pending-spinner"
|
|
4
4
|
import { usePendingIndicator } from "./use-pending-indicator"
|
|
5
|
-
import {
|
|
6
|
-
buttonSizes,
|
|
7
|
-
buttonVariants,
|
|
8
|
-
type ButtonSize,
|
|
9
|
-
type ButtonVariant,
|
|
10
|
-
} from "./button-styles"
|
|
5
|
+
import { buttonSizes, buttonVariants, type ButtonSize, type ButtonVariant } from "./button-styles"
|
|
11
6
|
|
|
12
7
|
export type { ButtonSize, ButtonVariant }
|
|
13
8
|
|
|
@@ -15,10 +10,23 @@ export type { ButtonSize, ButtonVariant }
|
|
|
15
10
|
* Each variant has a little depth: a fine highlight along the top edge and
|
|
16
11
|
* a soft, layered shadow, like a well-made physical key.
|
|
17
12
|
*/
|
|
18
|
-
export interface ButtonProps
|
|
19
|
-
|
|
13
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
14
|
+
/**
|
|
15
|
+
* Visual emphasis: `default` (solid), `accent` (main action),
|
|
16
|
+
* `secondary` (quiet fill), `outline`, `ghost`, `link`, or `destructive`.
|
|
17
|
+
* @default "default"
|
|
18
|
+
*/
|
|
20
19
|
variant?: ButtonVariant
|
|
20
|
+
/**
|
|
21
|
+
* Label sizes: `xs`, `sm`, `default`, `lg`.
|
|
22
|
+
* Icon sizes: `icon-xs`, `icon-sm`, `icon`, `icon-lg`, `icon-full`.
|
|
23
|
+
* Prefer IconButton for an icon with a built-in accessible label.
|
|
24
|
+
* @default "default"
|
|
25
|
+
*/
|
|
21
26
|
size?: ButtonSize
|
|
27
|
+
/** Shows a delayed spinner, keeps the button's width, and prevents repeat presses.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
22
30
|
isPending?: boolean
|
|
23
31
|
}
|
|
24
32
|
|
|
@@ -39,10 +47,8 @@ export function buttonStyle({
|
|
|
39
47
|
)
|
|
40
48
|
}
|
|
41
49
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
ButtonProps
|
|
45
|
-
>(function Button(
|
|
50
|
+
/** A native button with Passui styling, pending feedback, and an HTMLButtonElement ref. */
|
|
51
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
|
|
46
52
|
{
|
|
47
53
|
variant = "default",
|
|
48
54
|
size = "default",
|
|
@@ -55,8 +61,7 @@ export const Button = forwardRef<
|
|
|
55
61
|
},
|
|
56
62
|
ref
|
|
57
63
|
) {
|
|
58
|
-
const showPendingIndicator =
|
|
59
|
-
usePendingIndicator(isPending)
|
|
64
|
+
const showPendingIndicator = usePendingIndicator(isPending)
|
|
60
65
|
|
|
61
66
|
return (
|
|
62
67
|
<button
|
|
@@ -1,73 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { forwardRef } from "react"
|
|
2
2
|
import { cn } from "../../lib/class-names"
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
buttonVariants,
|
|
7
|
-
iconButtonSizes,
|
|
8
|
-
type ButtonVariant,
|
|
9
|
-
type IconButtonSize,
|
|
10
|
-
} from "./button-styles"
|
|
3
|
+
import { Button, type ButtonProps } from "./button"
|
|
4
|
+
import type { ButtonVariant, IconButtonSize } from "./button-styles"
|
|
11
5
|
|
|
12
|
-
export type { IconButtonSize }
|
|
6
|
+
export type { ButtonVariant, IconButtonSize }
|
|
13
7
|
|
|
14
|
-
export interface IconButtonProps
|
|
15
|
-
|
|
16
|
-
/** Required: icon-only buttons need an accessible name. */
|
|
8
|
+
export interface IconButtonProps extends Omit<ButtonProps, "size"> {
|
|
9
|
+
/** Icon-only actions must have an accessible name. */
|
|
17
10
|
label: string
|
|
18
|
-
variant?: ButtonVariant
|
|
19
11
|
size?: IconButtonSize
|
|
20
|
-
isPending?: boolean
|
|
21
12
|
}
|
|
22
13
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
>(function IconButton(
|
|
27
|
-
{
|
|
28
|
-
label,
|
|
29
|
-
variant = "default",
|
|
30
|
-
size = "icon",
|
|
31
|
-
isPending = false,
|
|
32
|
-
disabled,
|
|
33
|
-
children,
|
|
34
|
-
className,
|
|
35
|
-
type = "button",
|
|
36
|
-
...props
|
|
37
|
-
},
|
|
14
|
+
/** An accessible icon-only presentation of Button, sharing its interaction behavior. */
|
|
15
|
+
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(
|
|
16
|
+
{ label, size = "icon", className, children, ...props },
|
|
38
17
|
ref
|
|
39
18
|
) {
|
|
40
|
-
const showPendingIndicator =
|
|
41
|
-
usePendingIndicator(isPending)
|
|
42
|
-
|
|
43
19
|
return (
|
|
44
|
-
<
|
|
20
|
+
<Button
|
|
45
21
|
ref={ref}
|
|
46
|
-
|
|
22
|
+
size={size}
|
|
47
23
|
aria-label={label}
|
|
48
24
|
data-tooltip={label}
|
|
49
|
-
className={cn(
|
|
50
|
-
"relative",
|
|
51
|
-
"group inline-flex shrink-0 items-center justify-center rounded-full transition-[background-color,filter,transform,box-shadow] duration-fast ease-standard active:scale-[0.92] disabled:pointer-events-none disabled:opacity-40 data-pending:cursor-progress data-pending:disabled:opacity-100",
|
|
52
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/70 focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
|
53
|
-
iconButtonSizes[size],
|
|
54
|
-
buttonVariants[variant],
|
|
55
|
-
className
|
|
56
|
-
)}
|
|
25
|
+
className={cn("active:scale-[0.92]", className)}
|
|
57
26
|
{...props}
|
|
58
|
-
data-pending={isPending || undefined}
|
|
59
|
-
disabled={disabled || isPending}
|
|
60
|
-
aria-busy={isPending || props["aria-busy"]}
|
|
61
27
|
>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"inline-flex items-center justify-center transition-opacity duration-200",
|
|
65
|
-
showPendingIndicator && "opacity-0"
|
|
66
|
-
)}
|
|
67
|
-
>
|
|
68
|
-
{children}
|
|
69
|
-
</span>
|
|
70
|
-
{showPendingIndicator && <PendingSpinner />}
|
|
71
|
-
</button>
|
|
28
|
+
{children}
|
|
29
|
+
</Button>
|
|
72
30
|
)
|
|
73
31
|
})
|
|
@@ -3,10 +3,7 @@ import { useEffect, useState } from "react"
|
|
|
3
3
|
const PENDING_INDICATOR_DELAY = 300
|
|
4
4
|
|
|
5
5
|
export function schedulePendingIndicator(onShow: () => void) {
|
|
6
|
-
const timeout = setTimeout(
|
|
7
|
-
onShow,
|
|
8
|
-
PENDING_INDICATOR_DELAY
|
|
9
|
-
)
|
|
6
|
+
const timeout = setTimeout(onShow, PENDING_INDICATOR_DELAY)
|
|
10
7
|
return () => clearTimeout(timeout)
|
|
11
8
|
}
|
|
12
9
|
|
|
@@ -18,9 +15,7 @@ export function usePendingIndicator(isPending: boolean) {
|
|
|
18
15
|
|
|
19
16
|
if (!isPending) return
|
|
20
17
|
|
|
21
|
-
return schedulePendingIndicator(() =>
|
|
22
|
-
setIsVisible(true)
|
|
23
|
-
)
|
|
18
|
+
return schedulePendingIndicator(() => setIsVisible(true))
|
|
24
19
|
}, [isPending])
|
|
25
20
|
|
|
26
21
|
return isPending && isVisible
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import type { HTMLAttributes } from "react"
|
|
2
2
|
import { cn } from "../../lib/class-names"
|
|
3
3
|
|
|
4
|
-
export type ChipTone =
|
|
5
|
-
| "neutral"
|
|
6
|
-
| "accent"
|
|
7
|
-
| "public"
|
|
8
|
-
| "family"
|
|
9
|
-
| "friends"
|
|
4
|
+
export type ChipTone = "neutral" | "accent" | "public" | "family" | "friends"
|
|
10
5
|
|
|
11
6
|
const tones: Record<ChipTone, string> = {
|
|
12
7
|
neutral: "bg-fill text-label-secondary",
|
|
13
8
|
accent: "bg-elevated text-accent-text",
|
|
14
9
|
public: "bg-[#e8efff] text-[#2c55b8] dark:bg-[#1c2740] dark:text-[#a9c1ff]",
|
|
15
10
|
family: "bg-[#e3f3eb] text-[#24704f] dark:bg-[#15302a] dark:text-[#8fd6b6]",
|
|
16
|
-
friends:
|
|
17
|
-
"bg-[#ede8ff] text-[#5a3fc0] dark:bg-[#26203f] dark:text-[#c3b5ff]",
|
|
11
|
+
friends: "bg-[#ede8ff] text-[#5a3fc0] dark:bg-[#26203f] dark:text-[#c3b5ff]",
|
|
18
12
|
}
|
|
19
13
|
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
export interface ChipProps extends HTMLAttributes<HTMLSpanElement> {
|
|
15
|
+
/** `neutral`, `accent`, `public`, `family`, or `friends`. @default "neutral" */
|
|
16
|
+
tone?: ChipTone
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function Chip({ tone = "neutral", className, ...props }: ChipProps) {
|
|
25
20
|
return (
|
|
26
21
|
<span
|
|
27
22
|
className={cn(
|