@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,198 @@
|
|
|
1
|
+
// The look's layers in the page (Bridge addition, research-016 W6, research-028): this page's own choice (`setKit`,
|
|
2
|
+
// `setIconSet`, `setTheme`, stored: the kit outside Bridge; in Bridge none since appearance slice 3 carried a browser's
|
|
3
|
+
// old choices into Mine) wins, axis by axis; else the workspace shown, as the user sees it (its proposal with the user's
|
|
4
|
+
// Mine over it: `setWorkspaceAppearance`, `<html data-workspace-kit|-icons|-light-theme|-dark-theme>` and the controls'
|
|
5
|
+
// size (`--control-height`, `--control-radius`), set by the shell,
|
|
6
|
+
// and by the boot page for the workspace it opens); else the Bridge default the owner set in Admin (`<html
|
|
7
|
+
// data-default-kit|-icons|-theme>`, an attribute only when it is not the kit's own); else the kit's own. The mode
|
|
8
|
+
// (light, dark, system) is the user's, client-wide (./client-appearance.ts).
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_ICON_SET,
|
|
12
|
+
ICON_SET_STORAGE_KEY,
|
|
13
|
+
applyIconSet,
|
|
14
|
+
iconSetIds,
|
|
15
|
+
onIconSetsChange,
|
|
16
|
+
} from "../components/core/icon/icon-sets";
|
|
17
|
+
import {
|
|
18
|
+
DEFAULT_KIT,
|
|
19
|
+
KIT_STORAGE_KEY,
|
|
20
|
+
applyKit,
|
|
21
|
+
onRenderingsChange,
|
|
22
|
+
renderingIds,
|
|
23
|
+
} from "../kit/kit";
|
|
24
|
+
import { hasOwnTheme, refreshTheme } from "./set-theme";
|
|
25
|
+
import { THEME_STORAGE_KEY } from "./themes";
|
|
26
|
+
|
|
27
|
+
export interface Appearance {
|
|
28
|
+
kit: string;
|
|
29
|
+
icons: string;
|
|
30
|
+
/** A theme id, or "system". */
|
|
31
|
+
theme: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** What a workspace proposes to the page (its `appearance` settings, research-028): each left out follows the Bridge
|
|
35
|
+
* default. */
|
|
36
|
+
export interface WorkspaceAppearance {
|
|
37
|
+
kit?: string | undefined;
|
|
38
|
+
icons?: string | undefined;
|
|
39
|
+
lightTheme?: string | undefined;
|
|
40
|
+
darkTheme?: string | undefined;
|
|
41
|
+
/** The controls' height and radius in pixels (`--control-height`, `--control-radius` on `<html>`): left out, the
|
|
42
|
+
* stylesheet's (30, 8), or a rendering's own. */
|
|
43
|
+
controlHeight?: number | undefined;
|
|
44
|
+
controlRadius?: number | undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const axes = [
|
|
48
|
+
{
|
|
49
|
+
key: KIT_STORAGE_KEY,
|
|
50
|
+
attribute: "defaultKit",
|
|
51
|
+
workspace: "workspaceKit",
|
|
52
|
+
fallback: DEFAULT_KIT,
|
|
53
|
+
apply: applyKit,
|
|
54
|
+
field: "kit",
|
|
55
|
+
known: renderingIds,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: ICON_SET_STORAGE_KEY,
|
|
59
|
+
attribute: "defaultIcons",
|
|
60
|
+
workspace: "workspaceIcons",
|
|
61
|
+
fallback: DEFAULT_ICON_SET,
|
|
62
|
+
apply: applyIconSet,
|
|
63
|
+
field: "icons",
|
|
64
|
+
known: iconSetIds,
|
|
65
|
+
},
|
|
66
|
+
] as const;
|
|
67
|
+
const id = /^[a-z0-9-]+$/;
|
|
68
|
+
|
|
69
|
+
const listeners = new Set<() => void>();
|
|
70
|
+
const notify = () => listeners.forEach((listener) => listener());
|
|
71
|
+
const stored = (key: string) => {
|
|
72
|
+
try {
|
|
73
|
+
return localStorage.getItem(key);
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
/** Whether the page's packs (`_host`'s browser entries) have loaded: the boot kernel marks `<html data-packs-settled>`. */
|
|
79
|
+
const settled = () => document.documentElement.dataset.packsSettled !== undefined;
|
|
80
|
+
/** What `axis` shows now: the browser's choice, else the workspace's, else the Bridge default, else the kit's own. Once
|
|
81
|
+
* the packs loaded, a workspace's or default's rendering or icon set this Bridge does not have is passed over (an
|
|
82
|
+
* icon set chosen but never registered would leave every icon blank); before, it is kept, so nothing flashes. */
|
|
83
|
+
const resolved = (axis: (typeof axes)[number]) => {
|
|
84
|
+
const data = document.documentElement.dataset;
|
|
85
|
+
const own = stored(axis.key);
|
|
86
|
+
if (own !== null && id.test(own)) return own;
|
|
87
|
+
const usable = (each: string | undefined) =>
|
|
88
|
+
each !== undefined && (each === axis.fallback || !settled() || axis.known().includes(each));
|
|
89
|
+
return [data[axis.workspace], data[axis.attribute]].find(usable) ?? axis.fallback;
|
|
90
|
+
};
|
|
91
|
+
const applyAll = () => {
|
|
92
|
+
for (const axis of axes) axis.apply(resolved(axis));
|
|
93
|
+
refreshTheme();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Again once the packs loaded and each time a rendering or an icon set comes or goes (`resolved` passes over missing ones).
|
|
97
|
+
if (typeof document !== "undefined") {
|
|
98
|
+
new MutationObserver(() => applyAll()).observe(document.documentElement, {
|
|
99
|
+
attributes: true,
|
|
100
|
+
attributeFilter: ["data-packs-settled"],
|
|
101
|
+
});
|
|
102
|
+
onRenderingsChange(() => {
|
|
103
|
+
if (settled()) applyAll();
|
|
104
|
+
});
|
|
105
|
+
onIconSetsChange(() => {
|
|
106
|
+
if (settled()) applyAll();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** The Bridge default look this page was given (or last told). */
|
|
111
|
+
export function getBridgeAppearance(): Appearance {
|
|
112
|
+
const data = document.documentElement.dataset;
|
|
113
|
+
return {
|
|
114
|
+
kit: data.defaultKit ?? DEFAULT_KIT,
|
|
115
|
+
icons: data.defaultIcons ?? DEFAULT_ICON_SET,
|
|
116
|
+
theme: data.defaultTheme ?? "system",
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Whether this browser chose any part of its look itself (its mode aside). */
|
|
121
|
+
export function hasOwnAppearance(): boolean {
|
|
122
|
+
return axes.some(({ key }) => stored(key) !== null) || hasOwnTheme();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Drops this browser's choices (but its mode): the page follows the workspace and the Bridge default again. */
|
|
126
|
+
export function followBridgeAppearance(): void {
|
|
127
|
+
for (const key of [...axes.map((axis) => axis.key), THEME_STORAGE_KEY]) {
|
|
128
|
+
try {
|
|
129
|
+
localStorage.removeItem(key);
|
|
130
|
+
} catch {
|
|
131
|
+
// storage blocked: nothing was kept
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
delete document.documentElement.dataset.themeChoice;
|
|
135
|
+
applyAll();
|
|
136
|
+
notify();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** A new Bridge default (System saved it): kept on the page, and shown on each axis nothing above it decides. */
|
|
140
|
+
export function setBridgeAppearance(next: Appearance): void {
|
|
141
|
+
const data = document.documentElement.dataset;
|
|
142
|
+
for (const [field, attribute, own] of [
|
|
143
|
+
["kit", "defaultKit", DEFAULT_KIT],
|
|
144
|
+
["icons", "defaultIcons", DEFAULT_ICON_SET],
|
|
145
|
+
["theme", "defaultTheme", "system"],
|
|
146
|
+
] as const) {
|
|
147
|
+
if (next[field] === own) delete data[attribute];
|
|
148
|
+
else data[attribute] = next[field];
|
|
149
|
+
}
|
|
150
|
+
applyAll();
|
|
151
|
+
notify();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The workspace shown proposes `next` (none: nothing): kept on the page, and shown on each axis the browser did not
|
|
155
|
+
* choose. An id that is no id is left out. */
|
|
156
|
+
export function setWorkspaceAppearance(next: WorkspaceAppearance | undefined): void {
|
|
157
|
+
const root = document.documentElement;
|
|
158
|
+
// Inline on <html>: a rendering imposes its own sizes with `--control-height: … !important` (an inline value does not
|
|
159
|
+
// beat a stylesheet's important one).
|
|
160
|
+
for (const [property, value] of [
|
|
161
|
+
["--control-height", next?.controlHeight],
|
|
162
|
+
["--control-radius", next?.controlRadius],
|
|
163
|
+
] as const) {
|
|
164
|
+
if (typeof value === "number" && Number.isFinite(value) && value >= 0)
|
|
165
|
+
root.style.setProperty(property, `${value}px`);
|
|
166
|
+
else root.style.removeProperty(property);
|
|
167
|
+
}
|
|
168
|
+
const data = root.dataset;
|
|
169
|
+
const fields = {
|
|
170
|
+
workspaceKit: next?.kit,
|
|
171
|
+
workspaceIcons: next?.icons,
|
|
172
|
+
workspaceLightTheme: next?.lightTheme,
|
|
173
|
+
workspaceDarkTheme: next?.darkTheme,
|
|
174
|
+
};
|
|
175
|
+
let changed = false;
|
|
176
|
+
for (const [attribute, value] of Object.entries(fields)) {
|
|
177
|
+
const wanted = value !== undefined && id.test(value) ? value : undefined;
|
|
178
|
+
if (data[attribute] === wanted) continue;
|
|
179
|
+
changed = true;
|
|
180
|
+
if (wanted === undefined) delete data[attribute];
|
|
181
|
+
else data[attribute] = wanted;
|
|
182
|
+
}
|
|
183
|
+
if (!changed) return;
|
|
184
|
+
applyAll();
|
|
185
|
+
notify();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const subscribe = (onChange: () => void) => {
|
|
189
|
+
listeners.add(onChange);
|
|
190
|
+
return () => {
|
|
191
|
+
listeners.delete(onChange);
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/** Whether this browser has its own look, re-rendering the caller when that may have changed. */
|
|
196
|
+
export function useOwnAppearance(): boolean {
|
|
197
|
+
return React.useSyncExternalStore(subscribe, hasOwnAppearance, () => false);
|
|
198
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// `@bridge/ui/boot`: what the boot kernel and the status page bundle of the kit, before anything renders (the host
|
|
2
|
+
// builds them with this subpath inlined; a plugin cannot import it). DOM-free of React and of the kit's other modules,
|
|
3
|
+
// so the boot resolves the theme with the kit's own rule, from the same release.
|
|
4
|
+
export { getClientAppearance } from "./client-appearance.ts";
|
|
5
|
+
export { THEME_STORAGE_KEY, packThemesOfAttribute, resolveTheme, setPackThemes } from "./themes.ts";
|
|
6
|
+
export { layKeptWallpaperRules } from "./wallpaper-sheet.ts";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// The client's appearance (./client-appearance.ts) for React: the store's functions, and `useClientAppearance`.
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { getClientAppearance, subscribeClientAppearance } from "./client-appearance";
|
|
4
|
+
|
|
5
|
+
export * from "./client-appearance";
|
|
6
|
+
|
|
7
|
+
/** The client's appearance (preferences, Mine by workspace, images), re-rendering the caller when it changes. */
|
|
8
|
+
export function useClientAppearance() {
|
|
9
|
+
return React.useSyncExternalStore(
|
|
10
|
+
subscribeClientAppearance,
|
|
11
|
+
getClientAppearance,
|
|
12
|
+
getClientAppearance,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
// The client's appearance (research-028, appearance slice 3): what the user changed for themselves, kept on their
|
|
2
|
+
// side, never on a Bridge. Client-wide preferences (`prefs`: the mode, the workspace switch animation), each workspace's
|
|
3
|
+
// "Mine" (its appearance fields the user overrides there, by slug, settings-shaped: the `appearance` plugin's values),
|
|
4
|
+
// and Mine's images (data URLs, by id). In a browser: this browser's localStorage (one key, `bridge.appearance`). In the
|
|
5
|
+
// desktop app: the app keeps it for every instance (`window.bridgeAppearance`, apps/desktop/src/preload.cjs), each page
|
|
6
|
+
// reading and writing its own Bridge's workspaces by slug; the home page also reads each joined Bridge's (`instances`,
|
|
7
|
+
// for the rail's tiles). Pure of React and of the kit's other modules: the boot kernel bundles it by relative path
|
|
8
|
+
// (packages/browser-boot/src/theme.ts), so the first frame already has Mine.
|
|
9
|
+
import { isRecord } from "../lib/json.ts";
|
|
10
|
+
|
|
11
|
+
export type Fields = Record<string, unknown>;
|
|
12
|
+
export interface ClientAppearance {
|
|
13
|
+
/** Client-wide preferences, by field (`mode`, `workspaceTransition`). */
|
|
14
|
+
prefs: Fields;
|
|
15
|
+
/** Mine of this page's Bridge's workspaces, by slug. */
|
|
16
|
+
workspaces: Record<string, Fields>;
|
|
17
|
+
/** Mine's images, by id (16 hex digits): data URLs. */
|
|
18
|
+
images: Record<string, string>;
|
|
19
|
+
/** The desktop app's home page: each joined Bridge's workspaces' Mine, by instance id then slug (no images). */
|
|
20
|
+
instances?: Record<string, Record<string, Fields>>;
|
|
21
|
+
}
|
|
22
|
+
/** A write: the preferences (whole), one workspace's Mine (whole; `null` drops it), images added. Images no workspace
|
|
23
|
+
* names any more, and not added by this write, are dropped. */
|
|
24
|
+
export interface ClientAppearanceChange {
|
|
25
|
+
prefs?: Fields;
|
|
26
|
+
workspace?: { slug: string; fields: Fields | null };
|
|
27
|
+
images?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
/** Where it is kept: `get` is synchronous (the boot kernel reads it before the first paint). */
|
|
30
|
+
export interface ClientAppearanceStore {
|
|
31
|
+
get(): ClientAppearance | null;
|
|
32
|
+
write(change: ClientAppearanceChange): Promise<{ ok: true } | { ok: false; error: string }>;
|
|
33
|
+
subscribe(listener: (next: ClientAppearance) => void): () => void;
|
|
34
|
+
}
|
|
35
|
+
declare global {
|
|
36
|
+
interface Window {
|
|
37
|
+
bridgeAppearance?: ClientAppearanceStore;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** This browser's key. */
|
|
42
|
+
export const CLIENT_APPEARANCE_KEY = "bridge.appearance";
|
|
43
|
+
const empty = (): ClientAppearance => ({ prefs: {}, workspaces: {}, images: {} });
|
|
44
|
+
|
|
45
|
+
/** `state` with `change` applied (./client-appearance.test.ts). */
|
|
46
|
+
export function applyChange(
|
|
47
|
+
state: ClientAppearance,
|
|
48
|
+
change: ClientAppearanceChange,
|
|
49
|
+
): ClientAppearance {
|
|
50
|
+
const workspaces = { ...state.workspaces };
|
|
51
|
+
if (change.workspace) {
|
|
52
|
+
if (change.workspace.fields === null || Object.keys(change.workspace.fields).length === 0)
|
|
53
|
+
delete workspaces[change.workspace.slug];
|
|
54
|
+
else workspaces[change.workspace.slug] = change.workspace.fields;
|
|
55
|
+
}
|
|
56
|
+
const named = JSON.stringify(workspaces);
|
|
57
|
+
const images = Object.fromEntries(
|
|
58
|
+
Object.entries({ ...state.images, ...change.images }).filter(
|
|
59
|
+
([id]) => Object.hasOwn(change.images ?? {}, id) || named.includes(`"${id}"`),
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
return { ...state, prefs: change.prefs ?? state.prefs, workspaces, images };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `value` read as the client's appearance (an unreadable one: empty). */
|
|
66
|
+
const readState = (value: unknown): ClientAppearance => {
|
|
67
|
+
if (!isRecord(value)) return empty();
|
|
68
|
+
const record = <T>(each: unknown, ok: (item: unknown) => item is T) =>
|
|
69
|
+
Object.fromEntries(
|
|
70
|
+
Object.entries(isRecord(each) ? each : {}).filter(([, item]) => ok(item)),
|
|
71
|
+
) as Record<string, T>;
|
|
72
|
+
return {
|
|
73
|
+
prefs: isRecord(value.prefs) ? value.prefs : {},
|
|
74
|
+
workspaces: record(value.workspaces, isRecord),
|
|
75
|
+
images: record(value.images, (item): item is string => typeof item === "string"),
|
|
76
|
+
...(isRecord(value.instances) && {
|
|
77
|
+
instances: record(value.instances, isRecord) as Record<string, Record<string, Fields>>,
|
|
78
|
+
}),
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** This browser's store (localStorage, followed across tabs). A write storage refuses (blocked, full) still holds for
|
|
83
|
+
* this page, and answers why it is not kept. */
|
|
84
|
+
function browserStore(): ClientAppearanceStore {
|
|
85
|
+
const listeners = new Set<(next: ClientAppearance) => void>();
|
|
86
|
+
let state: ClientAppearance | undefined;
|
|
87
|
+
const load = () => {
|
|
88
|
+
try {
|
|
89
|
+
return readState(JSON.parse(localStorage.getItem(CLIENT_APPEARANCE_KEY) ?? "null"));
|
|
90
|
+
} catch {
|
|
91
|
+
return empty();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
if (typeof window !== "undefined") {
|
|
95
|
+
window.addEventListener("storage", (event) => {
|
|
96
|
+
if (event.key !== CLIENT_APPEARANCE_KEY && event.key !== null) return;
|
|
97
|
+
state = load();
|
|
98
|
+
for (const listener of listeners) listener(state);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
get: () => (state ??= load()),
|
|
103
|
+
async write(change) {
|
|
104
|
+
state = applyChange((state ??= load()), change);
|
|
105
|
+
for (const listener of listeners) listener(state);
|
|
106
|
+
try {
|
|
107
|
+
localStorage.setItem(CLIENT_APPEARANCE_KEY, JSON.stringify(state));
|
|
108
|
+
return { ok: true };
|
|
109
|
+
} catch {
|
|
110
|
+
return {
|
|
111
|
+
ok: false,
|
|
112
|
+
error: "this browser has no room left to keep it (it holds for this page only)",
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
subscribe(listener) {
|
|
117
|
+
listeners.add(listener);
|
|
118
|
+
return () => void listeners.delete(listener);
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** The app's store (`window.bridgeAppearance`), with what this page wrote shown at once, before the app confirms. While
|
|
124
|
+
* this page's writes are pending, the app's pushes (each an earlier one confirmed) are passed over: they would briefly
|
|
125
|
+
* undo the later ones; the last write settled reads the app's state. */
|
|
126
|
+
function appStore(app: ClientAppearanceStore): ClientAppearanceStore {
|
|
127
|
+
const listeners = new Set<(next: ClientAppearance) => void>();
|
|
128
|
+
let state = readState(app.get());
|
|
129
|
+
let pending = 0;
|
|
130
|
+
const tell = () => {
|
|
131
|
+
for (const listener of listeners) listener(state);
|
|
132
|
+
};
|
|
133
|
+
app.subscribe((next) => {
|
|
134
|
+
if (pending === 0) {
|
|
135
|
+
state = readState(next);
|
|
136
|
+
tell();
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
get: () => state,
|
|
141
|
+
async write(change) {
|
|
142
|
+
state = applyChange(state, change);
|
|
143
|
+
tell();
|
|
144
|
+
pending++;
|
|
145
|
+
const result = await app.write(change).catch((error: unknown) => ({
|
|
146
|
+
ok: false as const,
|
|
147
|
+
error: error instanceof Error ? error.message : String(error),
|
|
148
|
+
}));
|
|
149
|
+
if (--pending === 0) {
|
|
150
|
+
state = readState(app.get());
|
|
151
|
+
tell();
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
},
|
|
155
|
+
subscribe(listener) {
|
|
156
|
+
listeners.add(listener);
|
|
157
|
+
return () => void listeners.delete(listener);
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let store: ClientAppearanceStore | undefined;
|
|
163
|
+
const theStore = () =>
|
|
164
|
+
(store ??=
|
|
165
|
+
typeof window !== "undefined" && window.bridgeAppearance
|
|
166
|
+
? appStore(window.bridgeAppearance)
|
|
167
|
+
: browserStore());
|
|
168
|
+
|
|
169
|
+
/** The client's appearance now (the same object until it changes). */
|
|
170
|
+
export const getClientAppearance = (): ClientAppearance => theStore().get() ?? empty();
|
|
171
|
+
/** Calls `listener` on each change; returns the unsubscribe. */
|
|
172
|
+
export const subscribeClientAppearance = (listener: () => void) =>
|
|
173
|
+
theStore().subscribe(() => listener());
|
|
174
|
+
/** Workspace `slug`'s Mine (none: `{}`). */
|
|
175
|
+
export const mineOf = (slug: string | undefined): Fields =>
|
|
176
|
+
slug === undefined ? {} : (getClientAppearance().workspaces[slug] ?? {});
|
|
177
|
+
|
|
178
|
+
/** Why a write is not kept, if it is not. */
|
|
179
|
+
const settle = async (change: ClientAppearanceChange) => {
|
|
180
|
+
const result = await theStore().write(change);
|
|
181
|
+
return result.ok ? undefined : result.error;
|
|
182
|
+
};
|
|
183
|
+
/** Sets (`undefined`: drops) field `field` of workspace `slug`'s Mine. */
|
|
184
|
+
export const setMine = (slug: string, field: string, value: unknown) =>
|
|
185
|
+
setMineFields(slug, { ...mineOf(slug), [field]: value });
|
|
186
|
+
/** Replaces workspace `slug`'s Mine (`null`, or fields all `undefined`: drops it). */
|
|
187
|
+
export function setMineFields(slug: string, fields: Fields | null) {
|
|
188
|
+
const kept =
|
|
189
|
+
fields && Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
|
|
190
|
+
return settle({ workspace: { slug, fields: kept && Object.keys(kept).length ? kept : null } });
|
|
191
|
+
}
|
|
192
|
+
/** The user's look everywhere (research-035, the desktop app): the look fields naming a plugin (style, icons, window
|
|
193
|
+
* manager, navigation) they want wherever the workspace's Bridge has it, kept with the client-wide preferences. */
|
|
194
|
+
export const everywhereOf = (): Fields => {
|
|
195
|
+
const value = getClientAppearance().prefs.everywhere;
|
|
196
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
197
|
+
? (value as Fields)
|
|
198
|
+
: {};
|
|
199
|
+
};
|
|
200
|
+
/** Sets (`undefined`: drops) field `field` of the look everywhere; the app keeps a joined Bridge's page from changing it. */
|
|
201
|
+
export function setEverywhere(field: string, value: unknown) {
|
|
202
|
+
const next = { ...everywhereOf(), [field]: value };
|
|
203
|
+
if (value === undefined) delete next[field];
|
|
204
|
+
return setPreference("everywhere", Object.keys(next).length ? next : undefined);
|
|
205
|
+
}
|
|
206
|
+
/** Sets (`undefined`: drops) client-wide preference `field`. */
|
|
207
|
+
export function setPreference(field: string, value: unknown) {
|
|
208
|
+
const prefs = { ...getClientAppearance().prefs, [field]: value };
|
|
209
|
+
if (value === undefined) delete prefs[field];
|
|
210
|
+
return settle({ prefs });
|
|
211
|
+
}
|
|
212
|
+
/** Each image's URL, made once from its data URL: a `blob:` URL (the pages' CSP takes no `data:` image). Kept for the
|
|
213
|
+
* page's life (ponytail: a few per session; revoke them if users swap many images). */
|
|
214
|
+
const urls = new Map<string, { data: string; url: string }>();
|
|
215
|
+
/** Mine's image `id`, as a URL the page can show, if the client keeps it. */
|
|
216
|
+
export function mineImageOf(id: string): string | undefined {
|
|
217
|
+
const data = getClientAppearance().images[id];
|
|
218
|
+
const known = urls.get(id);
|
|
219
|
+
// One dropped a moment ago (a row still drawing it while its reset saves): the URL it had.
|
|
220
|
+
if (data === undefined || known?.data === data) return known?.url;
|
|
221
|
+
const [head = "", body = ""] = data.split(",", 2);
|
|
222
|
+
const bytes = Uint8Array.from(atob(body), (c) => c.charCodeAt(0));
|
|
223
|
+
const url = URL.createObjectURL(
|
|
224
|
+
new Blob([bytes], { type: /^data:([^;]+)/.exec(head)?.[1] ?? "image/webp" }),
|
|
225
|
+
);
|
|
226
|
+
urls.set(id, { data, url });
|
|
227
|
+
return url;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** The longest side an image Mine keeps is drawn at, and its largest encoding: the app keeps more than a browser, whose
|
|
231
|
+
* localStorage holds about 5 M characters per origin for everything. */
|
|
232
|
+
const inApp = () => typeof window !== "undefined" && window.bridgeAppearance !== undefined;
|
|
233
|
+
const maxSide = () => (inApp() ? 2560 : 1920);
|
|
234
|
+
const maxBytes = () => (inApp() ? 3_500_000 : 1_000_000);
|
|
235
|
+
/** Keeps `file` (an image) for Mine: drawn at most `maxSide` wide or high, encoded as WebP (JPEG where the browser cannot),
|
|
236
|
+
* under a new id, written with field `field` of workspace `slug`'s Mine naming it (its `mode` half, else the whole
|
|
237
|
+
* field) in the same change, so no other write drops it first; answers the id, or why not. */
|
|
238
|
+
export async function addMineImage(
|
|
239
|
+
file: Blob,
|
|
240
|
+
slug: string,
|
|
241
|
+
field: string,
|
|
242
|
+
mode?: "light" | "dark",
|
|
243
|
+
): Promise<{ value: string } | { error: string; hint?: string }> {
|
|
244
|
+
let bitmap: ImageBitmap;
|
|
245
|
+
try {
|
|
246
|
+
bitmap = await createImageBitmap(file);
|
|
247
|
+
} catch {
|
|
248
|
+
return {
|
|
249
|
+
error: "this file is not an image this browser can read",
|
|
250
|
+
hint: "Choose a PNG, JPEG or WebP image.",
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
const scale = Math.min(1, maxSide() / Math.max(bitmap.width, bitmap.height));
|
|
254
|
+
const canvas = document.createElement("canvas");
|
|
255
|
+
canvas.width = Math.max(1, Math.round(bitmap.width * scale));
|
|
256
|
+
canvas.height = Math.max(1, Math.round(bitmap.height * scale));
|
|
257
|
+
canvas.getContext("2d")!.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
|
|
258
|
+
bitmap.close();
|
|
259
|
+
let url = canvas.toDataURL("image/webp", 0.85);
|
|
260
|
+
if (!url.startsWith("data:image/webp")) url = canvas.toDataURL("image/jpeg", 0.85);
|
|
261
|
+
if (url.length > maxBytes())
|
|
262
|
+
return {
|
|
263
|
+
error: "this image is too large to keep on this device",
|
|
264
|
+
hint: "Choose a smaller image.",
|
|
265
|
+
};
|
|
266
|
+
const id = [...crypto.getRandomValues(new Uint8Array(8))]
|
|
267
|
+
.map((byte) => byte.toString(16).padStart(2, "0"))
|
|
268
|
+
.join("");
|
|
269
|
+
const mine = mineOf(slug);
|
|
270
|
+
const current = mine[field];
|
|
271
|
+
const halves = isRecord(current)
|
|
272
|
+
? current
|
|
273
|
+
: typeof current === "string"
|
|
274
|
+
? { light: current, dark: current }
|
|
275
|
+
: {};
|
|
276
|
+
const refused = await settle({
|
|
277
|
+
workspace: {
|
|
278
|
+
slug,
|
|
279
|
+
fields: { ...mine, [field]: mode === undefined ? id : { ...halves, [mode]: id } },
|
|
280
|
+
},
|
|
281
|
+
images: { [id]: url },
|
|
282
|
+
});
|
|
283
|
+
return refused === undefined ? { value: id } : { error: refused };
|
|
284
|
+
}
|