@bridgebrew/ui 0.0.0-stage → 0.1.10-next.79
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/LICENSE +21 -0
- package/README.md +39 -2
- package/SOURCE.md +182 -0
- package/dist/build.js +871 -0
- package/dist/theme-css.js +896 -0
- package/dist/themes.js +69 -0
- package/dist/types/build/stylesheet.d.ts +31 -0
- package/dist/types/components/composite/command/command.d.ts +94 -0
- package/dist/types/components/composite/command/index.d.ts +2 -0
- package/dist/types/components/composite/draft-bar/draft-bar.d.ts +12 -0
- package/dist/types/components/composite/draft-bar/index.d.ts +2 -0
- package/dist/types/components/composite/image-field/image-field.d.ts +33 -0
- package/dist/types/components/composite/image-field/index.d.ts +2 -0
- package/dist/types/components/composite/list/index.d.ts +3 -0
- package/dist/types/components/composite/list/list-swipe.d.ts +28 -0
- package/dist/types/components/composite/list/list.d.ts +95 -0
- package/dist/types/components/composite/picker/index.d.ts +2 -0
- package/dist/types/components/composite/picker/picker.d.ts +44 -0
- package/dist/types/components/composite/prompt-field/index.d.ts +2 -0
- package/dist/types/components/composite/prompt-field/prompt-field.d.ts +18 -0
- package/dist/types/components/composite/properties/index.d.ts +2 -0
- package/dist/types/components/composite/properties/properties.d.ts +24 -0
- package/dist/types/components/composite/snooze-menu/index.d.ts +4 -0
- package/dist/types/components/composite/snooze-menu/presets.d.ts +36 -0
- package/dist/types/components/composite/snooze-menu/snooze-menu.d.ts +27 -0
- package/dist/types/components/composite/tag-input/index.d.ts +2 -0
- package/dist/types/components/composite/tag-input/tag-input.d.ts +22 -0
- package/dist/types/components/composite/wizard/index.d.ts +2 -0
- package/dist/types/components/composite/wizard/wizard.d.ts +53 -0
- package/dist/types/components/core/avatar/avatar.d.ts +16 -0
- package/dist/types/components/core/avatar/index.d.ts +2 -0
- package/dist/types/components/core/badge/badge.d.ts +8 -0
- package/dist/types/components/core/badge/index.d.ts +2 -0
- package/dist/types/components/core/breadcrumb/breadcrumb.d.ts +21 -0
- package/dist/types/components/core/breadcrumb/index.d.ts +2 -0
- package/dist/types/components/core/bullets/bullets.d.ts +15 -0
- package/dist/types/components/core/bullets/index.d.ts +2 -0
- package/dist/types/components/core/button/button.d.ts +14 -0
- package/dist/types/components/core/button/index.d.ts +2 -0
- package/dist/types/components/core/card/card.d.ts +16 -0
- package/dist/types/components/core/card/index.d.ts +2 -0
- package/dist/types/components/core/checkbox/checkbox.d.ts +15 -0
- package/dist/types/components/core/checkbox/index.d.ts +2 -0
- package/dist/types/components/core/cluster/cluster.d.ts +5 -0
- package/dist/types/components/core/cluster/index.d.ts +1 -0
- package/dist/types/components/core/code-block/code-block.d.ts +18 -0
- package/dist/types/components/core/code-block/index.d.ts +2 -0
- package/dist/types/components/core/collapsible/collapsible.d.ts +8 -0
- package/dist/types/components/core/collapsible/index.d.ts +1 -0
- package/dist/types/components/core/colour-picker/colour-picker.d.ts +25 -0
- package/dist/types/components/core/colour-picker/index.d.ts +4 -0
- package/dist/types/components/core/combobox/combobox.d.ts +63 -0
- package/dist/types/components/core/combobox/index.d.ts +2 -0
- package/dist/types/components/core/detail/detail.d.ts +12 -0
- package/dist/types/components/core/detail/index.d.ts +1 -0
- package/dist/types/components/core/dialog/dialog.d.ts +43 -0
- package/dist/types/components/core/dialog/drag.d.ts +4 -0
- package/dist/types/components/core/dialog/index.d.ts +2 -0
- package/dist/types/components/core/drop-zone/drop-zone.d.ts +23 -0
- package/dist/types/components/core/drop-zone/index.d.ts +2 -0
- package/dist/types/components/core/dropdown-menu/dropdown-menu.d.ts +78 -0
- package/dist/types/components/core/dropdown-menu/index.d.ts +2 -0
- package/dist/types/components/core/editable-field/editable-field.d.ts +42 -0
- package/dist/types/components/core/editable-field/index.d.ts +2 -0
- package/dist/types/components/core/empty-state/empty-state.d.ts +11 -0
- package/dist/types/components/core/empty-state/index.d.ts +2 -0
- package/dist/types/components/core/field/field.d.ts +31 -0
- package/dist/types/components/core/field/index.d.ts +2 -0
- package/dist/types/components/core/icon/icon-sets.d.ts +38 -0
- package/dist/types/components/core/icon/icon.d.ts +14 -0
- package/dist/types/components/core/icon/index.d.ts +2 -0
- package/dist/types/components/core/input/index.d.ts +4 -0
- package/dist/types/components/core/input/input.d.ts +22 -0
- package/dist/types/components/core/input/textarea.d.ts +8 -0
- package/dist/types/components/core/kbd/index.d.ts +2 -0
- package/dist/types/components/core/kbd/kbd.d.ts +7 -0
- package/dist/types/components/core/label/index.d.ts +2 -0
- package/dist/types/components/core/label/label.d.ts +13 -0
- package/dist/types/components/core/main-content/index.d.ts +2 -0
- package/dist/types/components/core/main-content/main-content.d.ts +18 -0
- package/dist/types/components/core/pane/index.d.ts +1 -0
- package/dist/types/components/core/pane/pane.d.ts +12 -0
- package/dist/types/components/core/pick-menu/index.d.ts +4 -0
- package/dist/types/components/core/pick-menu/pick-menu.d.ts +57 -0
- package/dist/types/components/core/pick-menu/tag-menu.d.ts +19 -0
- package/dist/types/components/core/popover/index.d.ts +2 -0
- package/dist/types/components/core/popover/popover.d.ts +22 -0
- package/dist/types/components/core/progress/index.d.ts +2 -0
- package/dist/types/components/core/progress/progress.d.ts +13 -0
- package/dist/types/components/core/resizable/index.d.ts +2 -0
- package/dist/types/components/core/resizable/resizable.d.ts +15 -0
- package/dist/types/components/core/resizable/use-remembered-layout.d.ts +31 -0
- package/dist/types/components/core/screen-link/index.d.ts +2 -0
- package/dist/types/components/core/screen-link/screen-link.d.ts +52 -0
- package/dist/types/components/core/scroll-area/index.d.ts +2 -0
- package/dist/types/components/core/scroll-area/scroll-area.d.ts +13 -0
- package/dist/types/components/core/scroll-area/steps.d.ts +5 -0
- package/dist/types/components/core/section/index.d.ts +2 -0
- package/dist/types/components/core/section/section.d.ts +16 -0
- package/dist/types/components/core/segment-group/index.d.ts +2 -0
- package/dist/types/components/core/segment-group/segment-group.d.ts +24 -0
- package/dist/types/components/core/select/index.d.ts +2 -0
- package/dist/types/components/core/select/select.d.ts +39 -0
- package/dist/types/components/core/skeleton/index.d.ts +2 -0
- package/dist/types/components/core/skeleton/skeleton.d.ts +13 -0
- package/dist/types/components/core/slider/index.d.ts +2 -0
- package/dist/types/components/core/slider/slider.d.ts +9 -0
- package/dist/types/components/core/sortable/index.d.ts +2 -0
- package/dist/types/components/core/sortable/sortable.d.ts +53 -0
- package/dist/types/components/core/split-view/index.d.ts +2 -0
- package/dist/types/components/core/split-view/split-view.d.ts +28 -0
- package/dist/types/components/core/status-icon/index.d.ts +2 -0
- package/dist/types/components/core/status-icon/status-icon.d.ts +13 -0
- package/dist/types/components/core/table/collapsible-rows.d.ts +7 -0
- package/dist/types/components/core/table/expand-toggle.d.ts +10 -0
- package/dist/types/components/core/table/group-header.d.ts +14 -0
- package/dist/types/components/core/table/index.d.ts +8 -0
- package/dist/types/components/core/table/table.d.ts +31 -0
- package/dist/types/components/core/tabs/index.d.ts +2 -0
- package/dist/types/components/core/tabs/tabs.d.ts +20 -0
- package/dist/types/components/core/tag-pill/index.d.ts +2 -0
- package/dist/types/components/core/tag-pill/tag-pill.d.ts +25 -0
- package/dist/types/components/core/thumbnail/index.d.ts +2 -0
- package/dist/types/components/core/thumbnail/thumbnail.d.ts +23 -0
- package/dist/types/components/core/toast/index.d.ts +2 -0
- package/dist/types/components/core/toast/toast.d.ts +88 -0
- package/dist/types/components/core/toggle/index.d.ts +2 -0
- package/dist/types/components/core/toggle/toggle.d.ts +9 -0
- package/dist/types/components/core/toggle-group/index.d.ts +2 -0
- package/dist/types/components/core/toggle-group/toggle-group.d.ts +21 -0
- package/dist/types/components/core/tooltip/index.d.ts +2 -0
- package/dist/types/components/core/tooltip/tooltip.d.ts +33 -0
- package/dist/types/components/layout/multi-pane/index.d.ts +4 -0
- package/dist/types/components/layout/multi-pane/list-detail.d.ts +17 -0
- package/dist/types/components/layout/multi-pane/multi-pane.d.ts +34 -0
- package/dist/types/components/layout/single-pane/index.d.ts +2 -0
- package/dist/types/components/layout/single-pane/single-pane.d.ts +11 -0
- package/dist/types/components/shell/app-shell/app-shell.d.ts +12 -0
- package/dist/types/components/shell/app-shell/index.d.ts +2 -0
- package/dist/types/components/shell/sidebar/index.d.ts +2 -0
- package/dist/types/components/shell/sidebar/sidebar-group.d.ts +45 -0
- package/dist/types/components/shell/sidebar/sidebar-item.d.ts +19 -0
- package/dist/types/components/shell/sidebar/sidebar-resize-handle.d.ts +17 -0
- package/dist/types/components/shell/sidebar/sidebar-tree.d.ts +42 -0
- package/dist/types/components/shell/sidebar/sidebar.d.ts +27 -0
- package/dist/types/components/template/address-book-template/address-book-template.d.ts +15 -0
- package/dist/types/components/template/address-book-template/index.d.ts +2 -0
- package/dist/types/components/template/mail-template/index.d.ts +2 -0
- package/dist/types/components/template/mail-template/mail-template.d.ts +11 -0
- package/dist/types/components/template/use-narrow.d.ts +3 -0
- package/dist/types/index.d.ts +149 -0
- package/dist/types/kit/check-rendering.d.ts +3 -0
- package/dist/types/kit/kit.d.ts +76 -0
- package/dist/types/lib/clipboard.d.ts +5 -0
- package/dist/types/lib/dates.d.ts +9 -0
- package/dist/types/lib/json.d.ts +26 -0
- package/dist/types/lib/keys.d.ts +15 -0
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/lib/view-scope.d.ts +22 -0
- package/dist/types/profile/profile.d.ts +34 -0
- package/dist/types/theme/appearance.d.ts +31 -0
- package/dist/types/theme/boot.d.ts +3 -0
- package/dist/types/theme/client-appearance-react.d.ts +3 -0
- package/dist/types/theme/client-appearance.d.ts +69 -0
- package/dist/types/theme/generate-tokens.d.ts +45 -0
- package/dist/types/theme/pack-themes-react.d.ts +24 -0
- package/dist/types/theme/palette.d.ts +111 -0
- package/dist/types/theme/semantic-mapping.d.ts +28 -0
- package/dist/types/theme/set-theme.d.ts +30 -0
- package/dist/types/theme/theme-colours.d.ts +14 -0
- package/dist/types/theme/theme-css.d.ts +3 -0
- package/dist/types/theme/themes.d.ts +63 -0
- package/dist/types/theme/wallpaper-sheet.d.ts +16 -0
- package/dist/types/theme/wallpaper-theme-react.d.ts +7 -0
- package/dist/types/theme/wallpaper-theme.d.ts +37 -0
- package/package.json +87 -3
- package/src/build/stylesheet.ts +128 -0
- package/src/components/composite/command/command.meta.yaml +74 -0
- package/src/components/composite/command/command.tsx +939 -0
- package/src/components/composite/command/index.ts +17 -0
- package/src/components/composite/draft-bar/draft-bar.meta.yaml +19 -0
- package/src/components/composite/draft-bar/draft-bar.tsx +57 -0
- package/src/components/composite/draft-bar/index.ts +2 -0
- package/src/components/composite/image-field/image-field.meta.yaml +69 -0
- package/src/components/composite/image-field/image-field.tsx +267 -0
- package/src/components/composite/image-field/index.ts +2 -0
- package/src/components/composite/list/index.ts +18 -0
- package/src/components/composite/list/list-swipe.tsx +163 -0
- package/src/components/composite/list/list.meta.yaml +238 -0
- package/src/components/composite/list/list.tsx +868 -0
- package/src/components/composite/picker/index.ts +2 -0
- package/src/components/composite/picker/picker.meta.yaml +103 -0
- package/src/components/composite/picker/picker.tsx +276 -0
- package/src/components/composite/prompt-field/index.ts +2 -0
- package/src/components/composite/prompt-field/prompt-field.meta.yaml +60 -0
- package/src/components/composite/prompt-field/prompt-field.tsx +81 -0
- package/src/components/composite/properties/index.ts +9 -0
- package/src/components/composite/properties/properties.meta.yaml +56 -0
- package/src/components/composite/properties/properties.tsx +132 -0
- package/src/components/composite/snooze-menu/index.ts +11 -0
- package/src/components/composite/snooze-menu/presets.ts +169 -0
- package/src/components/composite/snooze-menu/snooze-menu.meta.yaml +58 -0
- package/src/components/composite/snooze-menu/snooze-menu.tsx +146 -0
- package/src/components/composite/tag-input/index.ts +2 -0
- package/src/components/composite/tag-input/tag-input.meta.yaml +51 -0
- package/src/components/composite/tag-input/tag-input.tsx +404 -0
- package/src/components/composite/wizard/index.ts +2 -0
- package/src/components/composite/wizard/wizard.meta.yaml +73 -0
- package/src/components/composite/wizard/wizard.tsx +256 -0
- package/src/components/core/avatar/avatar.meta.yaml +71 -0
- package/src/components/core/avatar/avatar.tsx +92 -0
- package/src/components/core/avatar/index.ts +2 -0
- package/src/components/core/badge/badge.meta.yaml +34 -0
- package/src/components/core/badge/badge.tsx +23 -0
- package/src/components/core/badge/index.ts +2 -0
- package/src/components/core/breadcrumb/breadcrumb.meta.yaml +45 -0
- package/src/components/core/breadcrumb/breadcrumb.tsx +110 -0
- package/src/components/core/breadcrumb/index.ts +2 -0
- package/src/components/core/bullets/bullets.meta.yaml +37 -0
- package/src/components/core/bullets/bullets.tsx +60 -0
- package/src/components/core/bullets/index.ts +2 -0
- package/src/components/core/button/button.meta.yaml +91 -0
- package/src/components/core/button/button.tsx +93 -0
- package/src/components/core/button/index.ts +2 -0
- package/src/components/core/card/card.meta.yaml +94 -0
- package/src/components/core/card/card.tsx +54 -0
- package/src/components/core/card/index.ts +2 -0
- package/src/components/core/checkbox/checkbox.meta.yaml +59 -0
- package/src/components/core/checkbox/checkbox.tsx +106 -0
- package/src/components/core/checkbox/index.ts +2 -0
- package/src/components/core/cluster/cluster.meta.yaml +4 -0
- package/src/components/core/cluster/cluster.tsx +17 -0
- package/src/components/core/cluster/index.ts +1 -0
- package/src/components/core/code-block/code-block.meta.yaml +30 -0
- package/src/components/core/code-block/code-block.tsx +93 -0
- package/src/components/core/code-block/index.ts +2 -0
- package/src/components/core/collapsible/collapsible.meta.yaml +34 -0
- package/src/components/core/collapsible/collapsible.tsx +54 -0
- package/src/components/core/collapsible/index.ts +1 -0
- package/src/components/core/colour-picker/colour-picker.meta.yaml +52 -0
- package/src/components/core/colour-picker/colour-picker.tsx +314 -0
- package/src/components/core/colour-picker/index.ts +4 -0
- package/src/components/core/combobox/combobox.meta.yaml +75 -0
- package/src/components/core/combobox/combobox.tsx +288 -0
- package/src/components/core/combobox/index.ts +2 -0
- package/src/components/core/detail/detail.meta.yaml +13 -0
- package/src/components/core/detail/detail.tsx +73 -0
- package/src/components/core/detail/index.ts +1 -0
- package/src/components/core/dialog/dialog.meta.yaml +95 -0
- package/src/components/core/dialog/dialog.tsx +254 -0
- package/src/components/core/dialog/drag.ts +40 -0
- package/src/components/core/dialog/index.ts +25 -0
- package/src/components/core/drop-zone/drop-zone.meta.yaml +55 -0
- package/src/components/core/drop-zone/drop-zone.tsx +146 -0
- package/src/components/core/drop-zone/index.ts +2 -0
- package/src/components/core/dropdown-menu/dropdown-menu.meta.yaml +118 -0
- package/src/components/core/dropdown-menu/dropdown-menu.tsx +407 -0
- package/src/components/core/dropdown-menu/index.ts +32 -0
- package/src/components/core/editable-field/editable-field.meta.yaml +120 -0
- package/src/components/core/editable-field/editable-field.tsx +346 -0
- package/src/components/core/editable-field/index.ts +2 -0
- package/src/components/core/empty-state/empty-state.meta.yaml +21 -0
- package/src/components/core/empty-state/empty-state.tsx +42 -0
- package/src/components/core/empty-state/index.ts +2 -0
- package/src/components/core/field/field.meta.yaml +37 -0
- package/src/components/core/field/field.tsx +100 -0
- package/src/components/core/field/index.ts +9 -0
- package/src/components/core/icon/curated-names.json +107 -0
- package/src/components/core/icon/icon-sets.ts +109 -0
- package/src/components/core/icon/icon.meta.yaml +30 -0
- package/src/components/core/icon/icon.tsx +93 -0
- package/src/components/core/icon/index.ts +2 -0
- package/src/components/core/input/index.ts +4 -0
- package/src/components/core/input/input.meta.yaml +98 -0
- package/src/components/core/input/input.tsx +133 -0
- package/src/components/core/input/textarea.meta.yaml +79 -0
- package/src/components/core/input/textarea.tsx +63 -0
- package/src/components/core/kbd/index.ts +2 -0
- package/src/components/core/kbd/kbd.meta.yaml +12 -0
- package/src/components/core/kbd/kbd.tsx +29 -0
- package/src/components/core/label/index.ts +2 -0
- package/src/components/core/label/label.meta.yaml +55 -0
- package/src/components/core/label/label.tsx +72 -0
- package/src/components/core/main-content/index.ts +2 -0
- package/src/components/core/main-content/main-content.meta.yaml +23 -0
- package/src/components/core/main-content/main-content.tsx +49 -0
- package/src/components/core/pane/index.ts +1 -0
- package/src/components/core/pane/pane.meta.yaml +13 -0
- package/src/components/core/pane/pane.tsx +64 -0
- package/src/components/core/pick-menu/index.ts +4 -0
- package/src/components/core/pick-menu/pick-menu.meta.yaml +36 -0
- package/src/components/core/pick-menu/pick-menu.tsx +348 -0
- package/src/components/core/pick-menu/tag-menu.meta.yaml +7 -0
- package/src/components/core/pick-menu/tag-menu.tsx +79 -0
- package/src/components/core/popover/index.ts +2 -0
- package/src/components/core/popover/popover.meta.yaml +16 -0
- package/src/components/core/popover/popover.tsx +66 -0
- package/src/components/core/progress/index.ts +2 -0
- package/src/components/core/progress/progress.meta.yaml +47 -0
- package/src/components/core/progress/progress.tsx +56 -0
- package/src/components/core/resizable/index.ts +13 -0
- package/src/components/core/resizable/resizable.meta.yaml +110 -0
- package/src/components/core/resizable/resizable.tsx +125 -0
- package/src/components/core/resizable/use-remembered-layout.ts +261 -0
- package/src/components/core/screen-link/index.ts +2 -0
- package/src/components/core/screen-link/screen-link.meta.yaml +34 -0
- package/src/components/core/screen-link/screen-link.tsx +100 -0
- package/src/components/core/scroll-area/index.ts +2 -0
- package/src/components/core/scroll-area/scroll-area.meta.yaml +72 -0
- package/src/components/core/scroll-area/scroll-area.tsx +95 -0
- package/src/components/core/scroll-area/steps.tsx +72 -0
- package/src/components/core/section/index.ts +2 -0
- package/src/components/core/section/section.meta.yaml +72 -0
- package/src/components/core/section/section.tsx +93 -0
- package/src/components/core/segment-group/index.ts +2 -0
- package/src/components/core/segment-group/segment-group.meta.yaml +71 -0
- package/src/components/core/segment-group/segment-group.tsx +166 -0
- package/src/components/core/select/index.ts +20 -0
- package/src/components/core/select/select.meta.yaml +48 -0
- package/src/components/core/select/select.tsx +226 -0
- package/src/components/core/skeleton/index.ts +2 -0
- package/src/components/core/skeleton/skeleton.meta.yaml +50 -0
- package/src/components/core/skeleton/skeleton.tsx +71 -0
- package/src/components/core/slider/index.ts +2 -0
- package/src/components/core/slider/slider.meta.yaml +55 -0
- package/src/components/core/slider/slider.tsx +46 -0
- package/src/components/core/sortable/index.ts +16 -0
- package/src/components/core/sortable/sortable.meta.yaml +125 -0
- package/src/components/core/sortable/sortable.tsx +471 -0
- package/src/components/core/split-view/index.ts +2 -0
- package/src/components/core/split-view/split-view.meta.yaml +85 -0
- package/src/components/core/split-view/split-view.tsx +193 -0
- package/src/components/core/status-icon/index.ts +2 -0
- package/src/components/core/status-icon/status-icon.meta.yaml +64 -0
- package/src/components/core/status-icon/status-icon.tsx +94 -0
- package/src/components/core/table/collapsible-rows.tsx +30 -0
- package/src/components/core/table/expand-toggle.tsx +58 -0
- package/src/components/core/table/group-header.tsx +35 -0
- package/src/components/core/table/index.ts +26 -0
- package/src/components/core/table/table.meta.yaml +67 -0
- package/src/components/core/table/table.tsx +166 -0
- package/src/components/core/tabs/index.ts +2 -0
- package/src/components/core/tabs/tabs.meta.yaml +57 -0
- package/src/components/core/tabs/tabs.tsx +74 -0
- package/src/components/core/tag-pill/index.ts +2 -0
- package/src/components/core/tag-pill/tag-pill.meta.yaml +19 -0
- package/src/components/core/tag-pill/tag-pill.tsx +102 -0
- package/src/components/core/thumbnail/index.ts +2 -0
- package/src/components/core/thumbnail/thumbnail.meta.yaml +59 -0
- package/src/components/core/thumbnail/thumbnail.tsx +162 -0
- package/src/components/core/toast/index.ts +12 -0
- package/src/components/core/toast/toast.meta.yaml +93 -0
- package/src/components/core/toast/toast.tsx +763 -0
- package/src/components/core/toggle/index.ts +2 -0
- package/src/components/core/toggle/toggle.meta.yaml +53 -0
- package/src/components/core/toggle/toggle.tsx +44 -0
- package/src/components/core/toggle-group/index.ts +2 -0
- package/src/components/core/toggle-group/toggle-group.meta.yaml +59 -0
- package/src/components/core/toggle-group/toggle-group.tsx +68 -0
- package/src/components/core/tooltip/index.ts +7 -0
- package/src/components/core/tooltip/tooltip.meta.yaml +93 -0
- package/src/components/core/tooltip/tooltip.tsx +198 -0
- package/src/components/layout/multi-pane/index.ts +4 -0
- package/src/components/layout/multi-pane/list-detail.tsx +45 -0
- package/src/components/layout/multi-pane/multi-pane.meta.yaml +67 -0
- package/src/components/layout/multi-pane/multi-pane.tsx +158 -0
- package/src/components/layout/single-pane/index.ts +2 -0
- package/src/components/layout/single-pane/single-pane.meta.yaml +35 -0
- package/src/components/layout/single-pane/single-pane.tsx +48 -0
- package/src/components/shell/app-shell/app-shell.meta.yaml +65 -0
- package/src/components/shell/app-shell/app-shell.tsx +61 -0
- package/src/components/shell/app-shell/index.ts +2 -0
- package/src/components/shell/sidebar/index.ts +35 -0
- package/src/components/shell/sidebar/sidebar-group.tsx +254 -0
- package/src/components/shell/sidebar/sidebar-item.tsx +88 -0
- package/src/components/shell/sidebar/sidebar-resize-handle.tsx +101 -0
- package/src/components/shell/sidebar/sidebar-tree.tsx +325 -0
- package/src/components/shell/sidebar/sidebar.meta.yaml +126 -0
- package/src/components/shell/sidebar/sidebar.tsx +142 -0
- package/src/components/template/address-book-template/address-book-template.meta.yaml +22 -0
- package/src/components/template/address-book-template/address-book-template.tsx +201 -0
- package/src/components/template/address-book-template/index.ts +2 -0
- package/src/components/template/mail-template/index.ts +2 -0
- package/src/components/template/mail-template/mail-template.meta.yaml +22 -0
- package/src/components/template/mail-template/mail-template.tsx +731 -0
- package/src/components/template/use-narrow.ts +18 -0
- package/src/index.ts +505 -0
- package/src/kit/check-rendering.tsx +130 -0
- package/src/kit/kit.tsx +177 -0
- package/src/lib/clipboard.ts +27 -0
- package/src/lib/dates.ts +13 -0
- package/src/lib/json.ts +59 -0
- package/src/lib/keys.ts +54 -0
- package/src/lib/utils.ts +12 -0
- package/src/lib/view-scope.tsx +60 -0
- package/src/profile/profile.ts +238 -0
- package/src/theme/appearance.ts +198 -0
- package/src/theme/boot.ts +6 -0
- package/src/theme/client-appearance-react.ts +14 -0
- package/src/theme/client-appearance.ts +284 -0
- package/src/theme/generate-tokens.ts +658 -0
- package/src/theme/pack-themes-react.ts +107 -0
- package/src/theme/palette.ts +301 -0
- package/src/theme/semantic-mapping.ts +165 -0
- package/src/theme/set-theme.ts +162 -0
- package/src/theme/theme-colours.ts +60 -0
- package/src/theme/theme-css.ts +15 -0
- package/src/theme/themes.ts +133 -0
- package/src/theme/wallpaper-sheet.ts +58 -0
- package/src/theme/wallpaper-theme-react.ts +60 -0
- package/src/theme/wallpaper-theme.ts +231 -0
|
@@ -0,0 +1,763 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as ReactDOM from "react-dom";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../../lib/utils";
|
|
6
|
+
import type { FollowEvent } from "../screen-link/screen-link";
|
|
7
|
+
import { Kbd } from "../kbd";
|
|
8
|
+
import { copyText } from "../../../lib/clipboard";
|
|
9
|
+
|
|
10
|
+
// --- Types ---
|
|
11
|
+
|
|
12
|
+
type ToastVariant = "success" | "error" | "warning" | "info";
|
|
13
|
+
|
|
14
|
+
interface ToastData {
|
|
15
|
+
id: string;
|
|
16
|
+
title: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
variant?: ToastVariant;
|
|
19
|
+
action?: {
|
|
20
|
+
label: string;
|
|
21
|
+
/** `event`: the click (a fix that opens a screen follows it, research-048); none from ⌘Z or another surface. */
|
|
22
|
+
onClick: (event?: FollowEvent) => void;
|
|
23
|
+
/** The action undoes what the toast says (research-033's mockup): ⌘Z (Ctrl+Z) runs the last such action, its toast
|
|
24
|
+
* shown or gone (the 20 last ones are kept), and the button shows ⌘Z. */
|
|
25
|
+
undo?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** A second, quiet text button after `action`; its `onClick` runs and the toast stays. */
|
|
28
|
+
secondary?: {
|
|
29
|
+
label: string;
|
|
30
|
+
onClick: () => void;
|
|
31
|
+
};
|
|
32
|
+
/** Text a small Copy button (beside the close one) writes with `copyText`; absent: no button. */
|
|
33
|
+
copy?: string;
|
|
34
|
+
/** Milliseconds before it fades away (3000 by default); `Infinity`: it stays until dismissed. */
|
|
35
|
+
duration?: number;
|
|
36
|
+
/** Draws a bar along the bottom edge that drains over `duration` (finite only) — an Undo toast shows how long is left. */
|
|
37
|
+
countdown?: boolean;
|
|
38
|
+
/** A toast with the key of one shown replaces it in place (a repeated failure does not stack). */
|
|
39
|
+
key?: string;
|
|
40
|
+
/** `false`: no close button, the toast stays until its action changes what it says (a page to reload). */
|
|
41
|
+
dismissible?: boolean;
|
|
42
|
+
/** Called once it goes by `dismiss` (its close button, Escape, its duration over), not when replaced by key. */
|
|
43
|
+
onClose?: () => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type ToastInput = Omit<ToastData, "id">;
|
|
47
|
+
|
|
48
|
+
/** A toast as another surface draws it (`ToastStack`): its action a label only, which that surface reports by id; a
|
|
49
|
+
* `secondary`'s callback cannot cross to another surface, so it is left out (`copy` is a plain string and stays). */
|
|
50
|
+
type ToastShown = Omit<ToastData, "action" | "secondary" | "onClose"> & {
|
|
51
|
+
action?: { label: string; undo?: boolean };
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** What `ToastItem` draws: a shown toast, plus the provider's own `secondary` (the sink's surfaces leave it out). */
|
|
55
|
+
type ToastDrawn = ToastShown & { secondary?: ToastData["secondary"] };
|
|
56
|
+
|
|
57
|
+
/** Another surface for a provider's toasts (an app's own view over a page that cannot show them): the provider draws
|
|
58
|
+
* none and hands their list to `show` on each change (an empty one when the sink goes); `subscribe` brings back what
|
|
59
|
+
* was used there, by toast id: its action (`"action"`, run as in the page) or its dismissal (`"dismiss"`). */
|
|
60
|
+
interface ToastSink {
|
|
61
|
+
show: (toasts: readonly ToastData[]) => void;
|
|
62
|
+
subscribe: (listener: (id: string, used: "action" | "dismiss") => void) => () => void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// --- CVA ---
|
|
66
|
+
|
|
67
|
+
const toastVariants = cva(
|
|
68
|
+
"flex items-start gap-3 w-[360px] rounded-default border p-3 shadow-dropdown text-sm",
|
|
69
|
+
{
|
|
70
|
+
variants: {
|
|
71
|
+
variant: {
|
|
72
|
+
info: "border-accent/30 bg-surface",
|
|
73
|
+
success: "border-success/30 bg-surface",
|
|
74
|
+
error: "border-destructive/30 bg-destructive-subtle",
|
|
75
|
+
warning: "border-warning/30 bg-surface",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
defaultVariants: {
|
|
79
|
+
variant: "info",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// --- Variant Icons ---
|
|
85
|
+
|
|
86
|
+
function VariantIcon({ variant }: { variant?: ToastVariant | undefined }) {
|
|
87
|
+
const base = "size-4 shrink-0 mt-0.5";
|
|
88
|
+
|
|
89
|
+
switch (variant) {
|
|
90
|
+
case "success":
|
|
91
|
+
return (
|
|
92
|
+
<svg
|
|
93
|
+
aria-hidden="true"
|
|
94
|
+
className={cn(base, "text-success")}
|
|
95
|
+
viewBox="0 0 24 24"
|
|
96
|
+
fill="none"
|
|
97
|
+
stroke="currentColor"
|
|
98
|
+
strokeWidth="2"
|
|
99
|
+
strokeLinecap="round"
|
|
100
|
+
strokeLinejoin="round"
|
|
101
|
+
>
|
|
102
|
+
<circle cx="12" cy="12" r="10" />
|
|
103
|
+
<polyline points="9 12 12 15 16 10" />
|
|
104
|
+
</svg>
|
|
105
|
+
);
|
|
106
|
+
case "error":
|
|
107
|
+
return (
|
|
108
|
+
<svg
|
|
109
|
+
aria-hidden="true"
|
|
110
|
+
className={cn(base, "text-destructive")}
|
|
111
|
+
viewBox="0 0 24 24"
|
|
112
|
+
fill="none"
|
|
113
|
+
stroke="currentColor"
|
|
114
|
+
strokeWidth="2"
|
|
115
|
+
strokeLinecap="round"
|
|
116
|
+
strokeLinejoin="round"
|
|
117
|
+
>
|
|
118
|
+
<circle cx="12" cy="12" r="10" />
|
|
119
|
+
<path d="m15 9-6 6" />
|
|
120
|
+
<path d="m9 9 6 6" />
|
|
121
|
+
</svg>
|
|
122
|
+
);
|
|
123
|
+
case "warning":
|
|
124
|
+
return (
|
|
125
|
+
<svg
|
|
126
|
+
aria-hidden="true"
|
|
127
|
+
className={cn(base, "text-warning")}
|
|
128
|
+
viewBox="0 0 24 24"
|
|
129
|
+
fill="none"
|
|
130
|
+
stroke="currentColor"
|
|
131
|
+
strokeWidth="2"
|
|
132
|
+
strokeLinecap="round"
|
|
133
|
+
strokeLinejoin="round"
|
|
134
|
+
>
|
|
135
|
+
<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" />
|
|
136
|
+
<path d="M12 9v4" />
|
|
137
|
+
<path d="M12 17h.01" />
|
|
138
|
+
</svg>
|
|
139
|
+
);
|
|
140
|
+
case "info":
|
|
141
|
+
default:
|
|
142
|
+
return (
|
|
143
|
+
<svg
|
|
144
|
+
aria-hidden="true"
|
|
145
|
+
className={cn(base, "text-accent")}
|
|
146
|
+
viewBox="0 0 24 24"
|
|
147
|
+
fill="none"
|
|
148
|
+
stroke="currentColor"
|
|
149
|
+
strokeWidth="2"
|
|
150
|
+
strokeLinecap="round"
|
|
151
|
+
strokeLinejoin="round"
|
|
152
|
+
>
|
|
153
|
+
<circle cx="12" cy="12" r="10" />
|
|
154
|
+
<path d="M12 16v-4" />
|
|
155
|
+
<path d="M12 8h.01" />
|
|
156
|
+
</svg>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// --- ToastAction ---
|
|
162
|
+
|
|
163
|
+
interface ToastActionProps extends React.ComponentProps<"button"> {}
|
|
164
|
+
|
|
165
|
+
function ToastAction({ className, ...props }: ToastActionProps) {
|
|
166
|
+
return (
|
|
167
|
+
<button
|
|
168
|
+
type="button"
|
|
169
|
+
data-slot="toast-action"
|
|
170
|
+
className={cn(
|
|
171
|
+
"inline-flex items-center h-sm px-2 text-xs font-medium rounded-control border border-border bg-transparent hover:bg-hover transition-colors cursor-pointer",
|
|
172
|
+
className,
|
|
173
|
+
)}
|
|
174
|
+
{...props}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const undoKeys =
|
|
180
|
+
typeof navigator !== "undefined" &&
|
|
181
|
+
/Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent)
|
|
182
|
+
? "⌘Z"
|
|
183
|
+
: "Ctrl+Z";
|
|
184
|
+
|
|
185
|
+
// --- Toast (individual) ---
|
|
186
|
+
|
|
187
|
+
/** Fixed fade-out duration in ms */
|
|
188
|
+
const FADE_DURATION = 1000;
|
|
189
|
+
|
|
190
|
+
interface ToastItemProps {
|
|
191
|
+
toast: ToastDrawn;
|
|
192
|
+
onAction: (id: string, event?: FollowEvent) => void;
|
|
193
|
+
onDismiss: (id: string) => void;
|
|
194
|
+
/** Its description unfolded (kept by the stack, so a toast replaced by key stays as the user left it). */
|
|
195
|
+
expanded?: boolean;
|
|
196
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Whether `el`'s rendered text takes more than one line. */
|
|
200
|
+
function overOneLine(el: HTMLElement): boolean {
|
|
201
|
+
const style = getComputedStyle(el);
|
|
202
|
+
const line = parseFloat(style.lineHeight) || parseFloat(style.fontSize) * 1.5;
|
|
203
|
+
return el.getBoundingClientRect().height > line * 1.5;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** How long the Copy button says `Copied` after a write, or `Copy failed` after a failed one. */
|
|
207
|
+
const COPIED_DURATION = 1500;
|
|
208
|
+
|
|
209
|
+
function ToastItem({
|
|
210
|
+
toast,
|
|
211
|
+
onAction,
|
|
212
|
+
onDismiss,
|
|
213
|
+
expanded = false,
|
|
214
|
+
onExpandedChange,
|
|
215
|
+
}: ToastItemProps) {
|
|
216
|
+
const duration = toast.duration ?? 3000;
|
|
217
|
+
const fadeDuration = Math.min(FADE_DURATION, duration);
|
|
218
|
+
const elRef = React.useRef<HTMLDivElement>(null);
|
|
219
|
+
const fadeTimerRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
220
|
+
const dismissTimerRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
221
|
+
const remainingRef = React.useRef(duration);
|
|
222
|
+
const startRef = React.useRef(0);
|
|
223
|
+
const [copied, setCopied] = React.useState<"copied" | "failed" | undefined>();
|
|
224
|
+
const [paused, setPaused] = React.useState(false);
|
|
225
|
+
const copiedTimerRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
226
|
+
// The latest callbacks, so a parent's new ones (inline arrows) do not restart the timers.
|
|
227
|
+
const onDismissRef = React.useRef(onDismiss);
|
|
228
|
+
onDismissRef.current = onDismiss;
|
|
229
|
+
const onActionRef = React.useRef(onAction);
|
|
230
|
+
onActionRef.current = onAction;
|
|
231
|
+
|
|
232
|
+
/** Writes `toast.copy`, saying `Copied`, or `Copy failed` when the write fails (no toast, no throw), for
|
|
233
|
+
* `COPIED_DURATION`. */
|
|
234
|
+
const copy = toast.copy;
|
|
235
|
+
const handleCopy = React.useCallback(() => {
|
|
236
|
+
if (copy === undefined) return;
|
|
237
|
+
const say = (outcome: "copied" | "failed") => {
|
|
238
|
+
setCopied(outcome);
|
|
239
|
+
clearTimeout(copiedTimerRef.current);
|
|
240
|
+
copiedTimerRef.current = setTimeout(() => setCopied(undefined), COPIED_DURATION);
|
|
241
|
+
};
|
|
242
|
+
void copyText(copy).then(
|
|
243
|
+
() => say("copied"),
|
|
244
|
+
() => say("failed"),
|
|
245
|
+
);
|
|
246
|
+
}, [copy]);
|
|
247
|
+
React.useEffect(() => () => clearTimeout(copiedTimerRef.current), []);
|
|
248
|
+
|
|
249
|
+
const startTimers = React.useCallback(
|
|
250
|
+
(remaining: number) => {
|
|
251
|
+
startRef.current = Date.now();
|
|
252
|
+
remainingRef.current = remaining;
|
|
253
|
+
if (remaining === Infinity) return;
|
|
254
|
+
|
|
255
|
+
const fadeDelay = Math.max(0, remaining - fadeDuration);
|
|
256
|
+
fadeTimerRef.current = setTimeout(() => {
|
|
257
|
+
const el = elRef.current;
|
|
258
|
+
if (el) {
|
|
259
|
+
el.style.transition = `opacity ${fadeDuration}ms ease-in`;
|
|
260
|
+
el.style.opacity = "0";
|
|
261
|
+
el.dataset.leaving = "";
|
|
262
|
+
}
|
|
263
|
+
}, fadeDelay);
|
|
264
|
+
dismissTimerRef.current = setTimeout(() => onDismissRef.current(toast.id), remaining);
|
|
265
|
+
},
|
|
266
|
+
[toast.id, fadeDuration],
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
const clearTimers = React.useCallback(() => {
|
|
270
|
+
clearTimeout(fadeTimerRef.current);
|
|
271
|
+
clearTimeout(dismissTimerRef.current);
|
|
272
|
+
}, []);
|
|
273
|
+
|
|
274
|
+
// Start timers on mount
|
|
275
|
+
React.useEffect(() => {
|
|
276
|
+
startTimers(duration);
|
|
277
|
+
return clearTimers;
|
|
278
|
+
}, [duration, startTimers, clearTimers]);
|
|
279
|
+
|
|
280
|
+
const handleMouseEnter = React.useCallback(() => {
|
|
281
|
+
clearTimers();
|
|
282
|
+
setPaused(true);
|
|
283
|
+
const el = elRef.current;
|
|
284
|
+
if (el) {
|
|
285
|
+
el.style.transition = "none";
|
|
286
|
+
el.style.opacity = "1";
|
|
287
|
+
delete el.dataset.leaving;
|
|
288
|
+
}
|
|
289
|
+
const elapsed = Date.now() - startRef.current;
|
|
290
|
+
remainingRef.current = Math.max(fadeDuration, remainingRef.current - elapsed);
|
|
291
|
+
}, [clearTimers, fadeDuration]);
|
|
292
|
+
|
|
293
|
+
const handleMouseLeave = React.useCallback(() => {
|
|
294
|
+
setPaused(false);
|
|
295
|
+
startTimers(remainingRef.current);
|
|
296
|
+
}, [startTimers]);
|
|
297
|
+
|
|
298
|
+
const showCountdown = toast.countdown === true && duration !== Infinity;
|
|
299
|
+
|
|
300
|
+
// A description over one line folds behind a chevron: measured as rendered (its width, its font, its skin), before
|
|
301
|
+
// the first paint, and again when its size changes. The fold animates only once the user toggles it.
|
|
302
|
+
const descriptionRef = React.useRef<HTMLParagraphElement>(null);
|
|
303
|
+
const [long, setLong] = React.useState(false);
|
|
304
|
+
const [animated, setAnimated] = React.useState(false);
|
|
305
|
+
React.useLayoutEffect(() => {
|
|
306
|
+
const el = descriptionRef.current;
|
|
307
|
+
if (!el) return setLong(false);
|
|
308
|
+
setLong(overOneLine(el));
|
|
309
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
310
|
+
const observer = new ResizeObserver(() => setLong(overOneLine(el)));
|
|
311
|
+
observer.observe(el);
|
|
312
|
+
return () => observer.disconnect();
|
|
313
|
+
}, [toast.description]);
|
|
314
|
+
const folded = long && !expanded;
|
|
315
|
+
const detailsId = React.useId();
|
|
316
|
+
|
|
317
|
+
return (
|
|
318
|
+
<div
|
|
319
|
+
ref={elRef}
|
|
320
|
+
data-slot="toast"
|
|
321
|
+
data-variant={toast.variant ?? "info"}
|
|
322
|
+
role="status"
|
|
323
|
+
aria-live="polite"
|
|
324
|
+
className={cn(
|
|
325
|
+
toastVariants({ variant: toast.variant ?? "info" }),
|
|
326
|
+
"relative",
|
|
327
|
+
// The countdown bar follows the toast's rounded corners.
|
|
328
|
+
showCountdown && "overflow-hidden",
|
|
329
|
+
)}
|
|
330
|
+
onMouseEnter={handleMouseEnter}
|
|
331
|
+
onMouseLeave={handleMouseLeave}
|
|
332
|
+
>
|
|
333
|
+
<VariantIcon variant={toast.variant} />
|
|
334
|
+
|
|
335
|
+
<div className="flex-1 min-w-0">
|
|
336
|
+
<div className="flex items-start gap-1">
|
|
337
|
+
<p data-slot="toast-title" className="font-medium text-foreground min-w-0">
|
|
338
|
+
{toast.title}
|
|
339
|
+
</p>
|
|
340
|
+
{long && (
|
|
341
|
+
<button
|
|
342
|
+
type="button"
|
|
343
|
+
data-slot="toast-expand"
|
|
344
|
+
aria-expanded={!folded}
|
|
345
|
+
aria-controls={detailsId}
|
|
346
|
+
aria-label="Details"
|
|
347
|
+
onClick={() => {
|
|
348
|
+
setAnimated(true);
|
|
349
|
+
onExpandedChange?.(folded);
|
|
350
|
+
}}
|
|
351
|
+
className={cn(
|
|
352
|
+
"shrink-0 mt-0.5 rounded-control bg-transparent border-none p-0 transition-colors cursor-pointer",
|
|
353
|
+
toast.variant === "error"
|
|
354
|
+
? "text-destructive/70 hover:text-destructive"
|
|
355
|
+
: "text-muted hover:text-foreground",
|
|
356
|
+
)}
|
|
357
|
+
>
|
|
358
|
+
<svg
|
|
359
|
+
aria-hidden="true"
|
|
360
|
+
className={cn(
|
|
361
|
+
"size-4 transition-transform duration-150 ease-out motion-reduce:transition-none",
|
|
362
|
+
!folded && "rotate-180",
|
|
363
|
+
)}
|
|
364
|
+
viewBox="0 0 24 24"
|
|
365
|
+
fill="none"
|
|
366
|
+
stroke="currentColor"
|
|
367
|
+
strokeWidth="2"
|
|
368
|
+
strokeLinecap="round"
|
|
369
|
+
strokeLinejoin="round"
|
|
370
|
+
>
|
|
371
|
+
<path d="m6 9 6 6 6-6" />
|
|
372
|
+
</svg>
|
|
373
|
+
</button>
|
|
374
|
+
)}
|
|
375
|
+
</div>
|
|
376
|
+
{toast.description && (
|
|
377
|
+
// The grid-rows fold of `SidebarCollapse`: folded, the text stays in the page (its `textContent` whole) but
|
|
378
|
+
// out of sight, of the tab order and of the accessibility tree.
|
|
379
|
+
<div
|
|
380
|
+
id={detailsId}
|
|
381
|
+
data-slot="toast-details"
|
|
382
|
+
data-state={folded ? "closed" : "open"}
|
|
383
|
+
inert={folded}
|
|
384
|
+
aria-hidden={folded || undefined}
|
|
385
|
+
className={cn(
|
|
386
|
+
"grid",
|
|
387
|
+
animated && "duration-150 ease-out motion-reduce:transition-none",
|
|
388
|
+
folded ? "invisible grid-rows-[0fr] opacity-0" : "grid-rows-[1fr] opacity-100",
|
|
389
|
+
animated &&
|
|
390
|
+
(folded
|
|
391
|
+
? "transition-[grid-template-rows,opacity,visibility]"
|
|
392
|
+
: "transition-[grid-template-rows,opacity]"),
|
|
393
|
+
)}
|
|
394
|
+
>
|
|
395
|
+
<div className="min-h-0 overflow-hidden">
|
|
396
|
+
<p
|
|
397
|
+
ref={descriptionRef}
|
|
398
|
+
data-slot="toast-description"
|
|
399
|
+
className="text-secondary pt-0.5"
|
|
400
|
+
>
|
|
401
|
+
{toast.description}
|
|
402
|
+
</p>
|
|
403
|
+
</div>
|
|
404
|
+
</div>
|
|
405
|
+
)}
|
|
406
|
+
{toast.action && (
|
|
407
|
+
<ToastAction
|
|
408
|
+
onClick={(event) => onActionRef.current(toast.id, event)}
|
|
409
|
+
onAuxClick={(event) => event.button === 1 && onActionRef.current(toast.id, event)}
|
|
410
|
+
className="mt-2"
|
|
411
|
+
>
|
|
412
|
+
{toast.action.label}
|
|
413
|
+
{toast.action.undo && <Kbd className="ml-1.5">{undoKeys}</Kbd>}
|
|
414
|
+
</ToastAction>
|
|
415
|
+
)}
|
|
416
|
+
{toast.secondary && (
|
|
417
|
+
<button
|
|
418
|
+
type="button"
|
|
419
|
+
data-slot="toast-secondary"
|
|
420
|
+
onClick={() => toast.secondary!.onClick()}
|
|
421
|
+
className={cn(
|
|
422
|
+
"inline-flex items-center h-sm px-2 mt-2 text-xs font-medium rounded-control bg-transparent text-secondary hover:bg-hover hover:text-foreground transition-colors cursor-pointer",
|
|
423
|
+
toast.action && "ml-2",
|
|
424
|
+
)}
|
|
425
|
+
>
|
|
426
|
+
{toast.secondary.label}
|
|
427
|
+
</button>
|
|
428
|
+
)}
|
|
429
|
+
</div>
|
|
430
|
+
|
|
431
|
+
{toast.copy !== undefined && (
|
|
432
|
+
<button
|
|
433
|
+
type="button"
|
|
434
|
+
data-slot="toast-copy"
|
|
435
|
+
onClick={handleCopy}
|
|
436
|
+
className={cn(
|
|
437
|
+
"shrink-0 mt-0.5 bg-transparent border-none p-0 transition-colors cursor-pointer",
|
|
438
|
+
toast.variant === "error"
|
|
439
|
+
? "text-destructive/70 hover:text-destructive"
|
|
440
|
+
: "text-muted hover:text-foreground",
|
|
441
|
+
)}
|
|
442
|
+
aria-label={copied === "copied" ? "Copied" : copied === "failed" ? "Copy failed" : "Copy"}
|
|
443
|
+
title={copied === "failed" ? "Copy failed" : undefined}
|
|
444
|
+
>
|
|
445
|
+
{copied === "failed" ? (
|
|
446
|
+
<svg
|
|
447
|
+
aria-hidden="true"
|
|
448
|
+
className="size-4"
|
|
449
|
+
viewBox="0 0 24 24"
|
|
450
|
+
fill="none"
|
|
451
|
+
stroke="currentColor"
|
|
452
|
+
strokeWidth="2"
|
|
453
|
+
strokeLinecap="round"
|
|
454
|
+
strokeLinejoin="round"
|
|
455
|
+
>
|
|
456
|
+
<path d="M18 6 6 18M6 6l12 12" />
|
|
457
|
+
</svg>
|
|
458
|
+
) : copied === "copied" ? (
|
|
459
|
+
<svg
|
|
460
|
+
aria-hidden="true"
|
|
461
|
+
className="size-4"
|
|
462
|
+
viewBox="0 0 24 24"
|
|
463
|
+
fill="none"
|
|
464
|
+
stroke="currentColor"
|
|
465
|
+
strokeWidth="2"
|
|
466
|
+
strokeLinecap="round"
|
|
467
|
+
strokeLinejoin="round"
|
|
468
|
+
>
|
|
469
|
+
<path d="M20 6 9 17l-5-5" />
|
|
470
|
+
</svg>
|
|
471
|
+
) : (
|
|
472
|
+
<svg
|
|
473
|
+
aria-hidden="true"
|
|
474
|
+
className="size-4"
|
|
475
|
+
viewBox="0 0 24 24"
|
|
476
|
+
fill="none"
|
|
477
|
+
stroke="currentColor"
|
|
478
|
+
strokeWidth="2"
|
|
479
|
+
strokeLinecap="round"
|
|
480
|
+
strokeLinejoin="round"
|
|
481
|
+
>
|
|
482
|
+
<rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
|
|
483
|
+
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
|
|
484
|
+
</svg>
|
|
485
|
+
)}
|
|
486
|
+
</button>
|
|
487
|
+
)}
|
|
488
|
+
|
|
489
|
+
{toast.dismissible !== false && (
|
|
490
|
+
<button
|
|
491
|
+
type="button"
|
|
492
|
+
data-slot="toast-close"
|
|
493
|
+
onClick={() => onDismissRef.current(toast.id)}
|
|
494
|
+
className={cn(
|
|
495
|
+
"shrink-0 mt-0.5 bg-transparent border-none p-0 transition-colors cursor-pointer",
|
|
496
|
+
toast.variant === "error"
|
|
497
|
+
? "text-destructive/70 hover:text-destructive"
|
|
498
|
+
: "text-muted hover:text-foreground",
|
|
499
|
+
)}
|
|
500
|
+
aria-label="Dismiss"
|
|
501
|
+
>
|
|
502
|
+
<svg
|
|
503
|
+
aria-hidden="true"
|
|
504
|
+
className="size-4"
|
|
505
|
+
viewBox="0 0 24 24"
|
|
506
|
+
fill="none"
|
|
507
|
+
stroke="currentColor"
|
|
508
|
+
strokeWidth="2"
|
|
509
|
+
strokeLinecap="round"
|
|
510
|
+
strokeLinejoin="round"
|
|
511
|
+
>
|
|
512
|
+
<path d="M18 6 6 18" />
|
|
513
|
+
<path d="m6 6 12 12" />
|
|
514
|
+
</svg>
|
|
515
|
+
</button>
|
|
516
|
+
)}
|
|
517
|
+
|
|
518
|
+
{showCountdown && (
|
|
519
|
+
<div
|
|
520
|
+
data-slot="toast-countdown"
|
|
521
|
+
aria-hidden="true"
|
|
522
|
+
data-paused={paused || undefined}
|
|
523
|
+
className="absolute left-0 right-0 bottom-0 h-0.5 bg-current opacity-30"
|
|
524
|
+
style={{
|
|
525
|
+
transformOrigin: "left",
|
|
526
|
+
animationName: "toast-countdown",
|
|
527
|
+
animationDuration: `${duration}ms`,
|
|
528
|
+
animationTimingFunction: "linear",
|
|
529
|
+
animationFillMode: "forwards",
|
|
530
|
+
animationPlayState: paused ? "paused" : "running",
|
|
531
|
+
}}
|
|
532
|
+
/>
|
|
533
|
+
)}
|
|
534
|
+
</div>
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// --- Context ---
|
|
539
|
+
|
|
540
|
+
interface ToastContextValue {
|
|
541
|
+
toast: (input: ToastInput) => string;
|
|
542
|
+
dismiss: (id: string) => void;
|
|
543
|
+
/** Runs the last undo action not used yet (what ⌘Z does); `false` when there is none. */
|
|
544
|
+
undo: () => boolean;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const ToastContext = React.createContext<ToastContextValue | undefined>(undefined);
|
|
548
|
+
|
|
549
|
+
// --- ToastProvider ---
|
|
550
|
+
|
|
551
|
+
interface ToastProviderProps {
|
|
552
|
+
children: React.ReactNode;
|
|
553
|
+
/** Given: the toasts go to it instead of being drawn here. */
|
|
554
|
+
sink?: ToastSink | undefined;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/** Toast ids: a counter, not `crypto.randomUUID()`, which browsers only offer on secure origins (Bridge is also
|
|
558
|
+
* opened over plain HTTP on the LAN). */
|
|
559
|
+
let lastToastId = 0;
|
|
560
|
+
|
|
561
|
+
function ToastProvider({ children, sink }: ToastProviderProps) {
|
|
562
|
+
const [toasts, setToasts] = React.useState<ToastData[]>([]);
|
|
563
|
+
const toastsRef = React.useRef(toasts);
|
|
564
|
+
toastsRef.current = toasts;
|
|
565
|
+
/** The undo actions not used yet, the last one last (⌘Z). */
|
|
566
|
+
const undos = React.useRef<{ id: string; run: () => void }[]>([]);
|
|
567
|
+
|
|
568
|
+
const dismiss = React.useCallback((id: string) => {
|
|
569
|
+
toastsRef.current.find((t) => t.id === id)?.onClose?.();
|
|
570
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
571
|
+
}, []);
|
|
572
|
+
|
|
573
|
+
const addToast = React.useCallback((input: ToastInput) => {
|
|
574
|
+
const id = String(++lastToastId);
|
|
575
|
+
if (input.action?.undo)
|
|
576
|
+
undos.current = [...undos.current, { id, run: input.action.onClick }].slice(-20);
|
|
577
|
+
|
|
578
|
+
setToasts((prev) => {
|
|
579
|
+
const toast = { ...input, id };
|
|
580
|
+
const same = input.key === undefined ? -1 : prev.findIndex((t) => t.key === input.key);
|
|
581
|
+
if (same >= 0) return prev.map((t, index) => (index === same ? toast : t));
|
|
582
|
+
const next = [...prev, toast];
|
|
583
|
+
// Past 5, the oldest goes: the oldest that fades first, a sticky one only when all are.
|
|
584
|
+
if (next.length > 5) {
|
|
585
|
+
const fading = next.findIndex((t) => t.duration !== Infinity);
|
|
586
|
+
next.splice(fading >= 0 ? fading : 0, 1);
|
|
587
|
+
}
|
|
588
|
+
return next;
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
return id;
|
|
592
|
+
}, []);
|
|
593
|
+
|
|
594
|
+
const act = React.useCallback((id: string, event?: FollowEvent) => {
|
|
595
|
+
undos.current = undos.current.filter((each) => each.id !== id);
|
|
596
|
+
toastsRef.current.find((t) => t.id === id)?.action?.onClick(event);
|
|
597
|
+
}, []);
|
|
598
|
+
|
|
599
|
+
const undo = React.useCallback(() => {
|
|
600
|
+
const last = undos.current.at(-1);
|
|
601
|
+
if (!last) return false;
|
|
602
|
+
undos.current = undos.current.slice(0, -1);
|
|
603
|
+
last.run();
|
|
604
|
+
dismiss(last.id);
|
|
605
|
+
addToast({ title: "Undone", variant: "info" });
|
|
606
|
+
return true;
|
|
607
|
+
}, [addToast, dismiss]);
|
|
608
|
+
|
|
609
|
+
// ⌘Z (Ctrl+Z): the last undo action, unless a field (its own undo) or another handler has the key.
|
|
610
|
+
React.useEffect(() => {
|
|
611
|
+
const onKey = (event: KeyboardEvent) => {
|
|
612
|
+
if (
|
|
613
|
+
event.defaultPrevented ||
|
|
614
|
+
event.shiftKey ||
|
|
615
|
+
event.altKey ||
|
|
616
|
+
!(event.metaKey || event.ctrlKey)
|
|
617
|
+
)
|
|
618
|
+
return;
|
|
619
|
+
if (event.key.toLowerCase() !== "z") return;
|
|
620
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
621
|
+
if (
|
|
622
|
+
target?.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]')
|
|
623
|
+
)
|
|
624
|
+
return;
|
|
625
|
+
if (undo()) event.preventDefault();
|
|
626
|
+
};
|
|
627
|
+
document.addEventListener("keydown", onKey);
|
|
628
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
629
|
+
}, [undo]);
|
|
630
|
+
|
|
631
|
+
React.useEffect(() => {
|
|
632
|
+
if (!sink) return;
|
|
633
|
+
sink.show(toasts);
|
|
634
|
+
}, [sink, toasts]);
|
|
635
|
+
|
|
636
|
+
// The sink gone (or replaced), its surface shows none of them any more: they are drawn here again.
|
|
637
|
+
React.useEffect(() => {
|
|
638
|
+
if (!sink) return;
|
|
639
|
+
const off = sink.subscribe((id, used) => (used === "action" ? act(id) : dismiss(id)));
|
|
640
|
+
return () => {
|
|
641
|
+
off();
|
|
642
|
+
sink.show([]);
|
|
643
|
+
};
|
|
644
|
+
}, [sink, act, dismiss]);
|
|
645
|
+
|
|
646
|
+
React.useEffect(() => {
|
|
647
|
+
const handler = (e: KeyboardEvent) => {
|
|
648
|
+
// An Escape another surface handled (a list clearing its selection) is not ours.
|
|
649
|
+
if (e.defaultPrevented) return;
|
|
650
|
+
// A toast that cannot be closed (dismissible: false) is not closed by Escape either.
|
|
651
|
+
const last = toasts.findLast((t) => t.dismissible !== false);
|
|
652
|
+
if (e.key === "Escape" && last) {
|
|
653
|
+
dismiss(last.id);
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
document.addEventListener("keydown", handler);
|
|
657
|
+
return () => document.removeEventListener("keydown", handler);
|
|
658
|
+
}, [toasts, dismiss]);
|
|
659
|
+
|
|
660
|
+
const contextValue = React.useMemo(
|
|
661
|
+
() => ({ toast: addToast, dismiss, undo }),
|
|
662
|
+
[addToast, dismiss, undo],
|
|
663
|
+
);
|
|
664
|
+
|
|
665
|
+
return (
|
|
666
|
+
<ToastContext.Provider value={contextValue}>
|
|
667
|
+
{children}
|
|
668
|
+
{!sink &&
|
|
669
|
+
typeof document !== "undefined" &&
|
|
670
|
+
ReactDOM.createPortal(
|
|
671
|
+
<ToastStack
|
|
672
|
+
toasts={toasts}
|
|
673
|
+
onAction={act}
|
|
674
|
+
onDismiss={dismiss}
|
|
675
|
+
className="fixed bottom-4 right-4 z-[100] pointer-events-none"
|
|
676
|
+
/>,
|
|
677
|
+
document.body,
|
|
678
|
+
)}
|
|
679
|
+
</ToastContext.Provider>
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// --- ToastStack ---
|
|
684
|
+
|
|
685
|
+
interface ToastStackProps {
|
|
686
|
+
toasts: readonly ToastDrawn[];
|
|
687
|
+
/** A toast's action button used. */
|
|
688
|
+
onAction: (id: string, event?: FollowEvent) => void;
|
|
689
|
+
/** Its close button used, or its duration over. */
|
|
690
|
+
onDismiss: (id: string) => void;
|
|
691
|
+
className?: string;
|
|
692
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/** Toasts drawn as given, newest at the bottom: the provider's own stack, or another surface's for a sink's toasts
|
|
696
|
+
* (it runs their timers and reports what is used by id). Nothing when there are none. A toast fading out carries
|
|
697
|
+
* `data-leaving`. */
|
|
698
|
+
function ToastStack({ toasts, onAction, onDismiss, className, ref }: ToastStackProps) {
|
|
699
|
+
// The toasts whose description the user unfolded, by key (or id): one replaced by key stays unfolded.
|
|
700
|
+
const [expanded, setExpanded] = React.useState<ReadonlySet<string>>(new Set());
|
|
701
|
+
// A toast gone (closed, faded, evicted) forgets it: a later one under its key starts folded.
|
|
702
|
+
const live = toasts.map((t) => t.key ?? t.id).join("\n");
|
|
703
|
+
React.useEffect(() => {
|
|
704
|
+
const keys = new Set(live.split("\n"));
|
|
705
|
+
setExpanded((prev) =>
|
|
706
|
+
[...prev].every((key) => keys.has(key))
|
|
707
|
+
? prev
|
|
708
|
+
: new Set([...prev].filter((key) => keys.has(key))),
|
|
709
|
+
);
|
|
710
|
+
}, [live]);
|
|
711
|
+
if (toasts.length === 0) return null;
|
|
712
|
+
return (
|
|
713
|
+
<div
|
|
714
|
+
ref={ref}
|
|
715
|
+
data-slot="toast-viewport"
|
|
716
|
+
role="region"
|
|
717
|
+
aria-label="Notifications"
|
|
718
|
+
className={cn("flex flex-col-reverse gap-2", className)}
|
|
719
|
+
>
|
|
720
|
+
{toasts.map((t) => (
|
|
721
|
+
<div key={t.id} className="pointer-events-auto">
|
|
722
|
+
<ToastItem
|
|
723
|
+
toast={t}
|
|
724
|
+
onAction={onAction}
|
|
725
|
+
onDismiss={onDismiss}
|
|
726
|
+
expanded={expanded.has(t.key ?? t.id)}
|
|
727
|
+
onExpandedChange={(open) =>
|
|
728
|
+
setExpanded((prev) => {
|
|
729
|
+
const next = new Set(prev);
|
|
730
|
+
if (open) next.add(t.key ?? t.id);
|
|
731
|
+
else next.delete(t.key ?? t.id);
|
|
732
|
+
return next;
|
|
733
|
+
})
|
|
734
|
+
}
|
|
735
|
+
/>
|
|
736
|
+
</div>
|
|
737
|
+
))}
|
|
738
|
+
</div>
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// --- useToast ---
|
|
743
|
+
|
|
744
|
+
function useToast(): ToastContextValue {
|
|
745
|
+
const context = React.useContext(ToastContext);
|
|
746
|
+
if (!context) {
|
|
747
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
748
|
+
}
|
|
749
|
+
return context;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
export { ToastProvider, ToastAction, ToastStack, toastVariants, useToast };
|
|
753
|
+
export type {
|
|
754
|
+
ToastProviderProps,
|
|
755
|
+
ToastStackProps,
|
|
756
|
+
ToastShown,
|
|
757
|
+
ToastSink,
|
|
758
|
+
ToastActionProps,
|
|
759
|
+
ToastData,
|
|
760
|
+
ToastInput,
|
|
761
|
+
ToastVariant,
|
|
762
|
+
ToastContextValue,
|
|
763
|
+
};
|