@bridgebrew/ui 0.0.0-stage → 0.1.9
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
package/src/kit/kit.tsx
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// Renderings (Bridge addition, research-015 spike): the kit's components keep their logic, state and
|
|
2
|
+
// accessibility; a rendering, registered by a pack (a `_host` plugin), changes how they look through a
|
|
3
|
+
// versioned contract:
|
|
4
|
+
// 1. CSS on the attributes the components expose (`data-slot`, `data-variant`, `data-size`, Base UI's
|
|
5
|
+
// state attributes), scoped under `<html data-kit="<id>">` and shipped as the pack's stylesheet;
|
|
6
|
+
// 2. parts: small drawings the kit places at named spots (`KitParts`), each given fixed props;
|
|
7
|
+
// 3. roots: a component's root element rendered by the pack from the kit's wiring (`KitRoots`);
|
|
8
|
+
// 4. capabilities: behaviours the kit implements and a rendering turns on (`KitCapability`).
|
|
9
|
+
// Whatever a rendering leaves out, the kit draws itself. The chosen rendering is `<html data-kit>`, set
|
|
10
|
+
// before the first mount by the boot kernel and live by `setKit`; a switch keeps every component's element
|
|
11
|
+
// tree, so nothing remounts (a root must keep the kit's element and its children in place: `checkRendering`).
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
|
|
14
|
+
/** The contract a rendering is written for; a rendering of another version is refused. */
|
|
15
|
+
export const KIT_CONTRACT = 1;
|
|
16
|
+
/** The kit's own rendering. */
|
|
17
|
+
export const DEFAULT_KIT = "default";
|
|
18
|
+
/** Where the page keeps the chosen rendering; the boot kernel reads it before the first mount. */
|
|
19
|
+
export const KIT_STORAGE_KEY = "bridge.kit";
|
|
20
|
+
|
|
21
|
+
/** The parts a rendering may draw, with the props the kit gives each. */
|
|
22
|
+
export interface KitParts {
|
|
23
|
+
/** Inside the checkbox, when it is checked or indeterminate. */
|
|
24
|
+
"checkbox.glyph": { state: "checked" | "indeterminate" };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The roots a rendering may render: it gets the kit's wiring and must spread it on the same element. */
|
|
28
|
+
export interface KitRoots {
|
|
29
|
+
/** The dialog's window (a `div` with `role="dialog"`). */
|
|
30
|
+
"dialog.content": React.ComponentPropsWithRef<"div">;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Behaviours the kit implements, off unless the rendering turns them on. */
|
|
34
|
+
export type KitCapability =
|
|
35
|
+
/** The dialog's header drags its window (kept on screen; a reopened dialog starts centred). */
|
|
36
|
+
| "dialog.dragByTitleBar"
|
|
37
|
+
/** A scrollbar gets a step button at each end (`data-slot="scroll-area-step"`, `data-direction`). */
|
|
38
|
+
| "scrollArea.stepButtons";
|
|
39
|
+
|
|
40
|
+
export interface Rendering {
|
|
41
|
+
/** Lowercase letters, digits and dashes; "default" is the kit's own. */
|
|
42
|
+
id: string;
|
|
43
|
+
label: string;
|
|
44
|
+
/** `KIT_CONTRACT` when it was written. */
|
|
45
|
+
contract: number;
|
|
46
|
+
parts?: { [K in keyof KitParts]?: (props: KitParts[K]) => React.ReactNode };
|
|
47
|
+
roots?: { [K in keyof KitRoots]?: (props: KitRoots[K]) => React.ReactElement };
|
|
48
|
+
capabilities?: readonly KitCapability[];
|
|
49
|
+
/** The canvas an app shell paints behind its windows (a CSS colour, dark: what sits on it takes light ink), where
|
|
50
|
+
* the user chose none; none: the shell's own. */
|
|
51
|
+
canvas?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const ID = /^[a-z0-9-]+$/;
|
|
55
|
+
let renderings: readonly Rendering[] = [];
|
|
56
|
+
const listeners = new Set<() => void>();
|
|
57
|
+
const notify = () => listeners.forEach((listener) => listener());
|
|
58
|
+
/** Told only when a rendering comes or goes (`theme/appearance.ts` follows which ids exist). */
|
|
59
|
+
const registry = new Set<() => void>();
|
|
60
|
+
const changed = () => {
|
|
61
|
+
notify();
|
|
62
|
+
registry.forEach((listener) => listener());
|
|
63
|
+
};
|
|
64
|
+
/** The registered renderings' ids. */
|
|
65
|
+
export const renderingIds = () => renderings.map((r) => r.id);
|
|
66
|
+
/** Calls `listener` each time a rendering is registered or removed, until the returned function. */
|
|
67
|
+
export function onRenderingsChange(listener: () => void): () => void {
|
|
68
|
+
registry.add(listener);
|
|
69
|
+
return () => {
|
|
70
|
+
registry.delete(listener);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Registers a rendering, until the returned function removes it. Throws on a bad or taken id, or another
|
|
75
|
+
* contract version. */
|
|
76
|
+
export function registerRendering(rendering: Rendering): () => void {
|
|
77
|
+
const { id, contract } = rendering;
|
|
78
|
+
if (!ID.test(id) || id === DEFAULT_KIT)
|
|
79
|
+
throw new Error(
|
|
80
|
+
`rendering id "${id}": lowercase letters, digits and dashes, not "${DEFAULT_KIT}"`,
|
|
81
|
+
);
|
|
82
|
+
if (contract !== KIT_CONTRACT) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`rendering "${id}" is written for kit contract ${contract}, this kit has ${KIT_CONTRACT}: update the pack`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (renderings.some((r) => r.id === id))
|
|
88
|
+
throw new Error(`rendering "${id}" is already registered`);
|
|
89
|
+
renderings = [...renderings, rendering];
|
|
90
|
+
changed();
|
|
91
|
+
return () => {
|
|
92
|
+
renderings = renderings.filter((r) => r !== rendering);
|
|
93
|
+
changed();
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The chosen rendering's id (`<html data-kit>`), registered or not yet; "default" when none. */
|
|
98
|
+
export function getKit(): string {
|
|
99
|
+
const id = document.documentElement.dataset.kit;
|
|
100
|
+
return id && ID.test(id) ? id : DEFAULT_KIT;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Shows a rendering without remembering it (the Bridge default, `theme/appearance.ts`). */
|
|
104
|
+
export function applyKit(id: string): void {
|
|
105
|
+
if (!ID.test(id)) throw new Error(`rendering id "${id}": lowercase letters, digits and dashes`);
|
|
106
|
+
const root = document.documentElement;
|
|
107
|
+
if (id === DEFAULT_KIT) delete root.dataset.kit;
|
|
108
|
+
else root.dataset.kit = id;
|
|
109
|
+
notify();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Chooses a rendering for this browser and remembers it, "default" (the kit's own) included: it overrides the Bridge
|
|
113
|
+
* default. A storage failure leaves it chosen for this page only. */
|
|
114
|
+
export function setKit(id: string): void {
|
|
115
|
+
applyKit(id);
|
|
116
|
+
try {
|
|
117
|
+
localStorage.setItem(KIT_STORAGE_KEY, id);
|
|
118
|
+
} catch {
|
|
119
|
+
// Storage blocked or full: the choice lasts until the page reloads.
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const subscribe = (onChange: () => void) => {
|
|
124
|
+
listeners.add(onChange);
|
|
125
|
+
return () => {
|
|
126
|
+
listeners.delete(onChange);
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/** The registered renderings, outside React (the shell's look resolution: research-035). */
|
|
130
|
+
export const getRenderings = () => renderings;
|
|
131
|
+
/** Calls `onChange` when a rendering comes or goes (or the choice changes); returns the unsubscribe. */
|
|
132
|
+
export const subscribeRenderings = (onChange: () => void) => subscribe(onChange);
|
|
133
|
+
const getActive = () => {
|
|
134
|
+
const id = getKit();
|
|
135
|
+
return renderings.find((r) => r.id === id);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/** The chosen rendering's id, re-rendering the caller when it changes. */
|
|
139
|
+
export function useKit(): string {
|
|
140
|
+
return React.useSyncExternalStore(subscribe, getKit, () => DEFAULT_KIT);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** The registered renderings, re-rendering the caller when one comes or goes. */
|
|
144
|
+
export function useRenderings(): readonly Rendering[] {
|
|
145
|
+
return React.useSyncExternalStore(subscribe, getRenderings, getRenderings);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** The chosen rendering if registered (its pack may still be loading: the kit draws itself meanwhile). */
|
|
149
|
+
export function useRendering(): Rendering | undefined {
|
|
150
|
+
return React.useSyncExternalStore(subscribe, getActive, () => undefined);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Whether the chosen rendering turns `capability` on. */
|
|
154
|
+
export function useCapability(capability: KitCapability): boolean {
|
|
155
|
+
return useRendering()?.capabilities?.includes(capability) ?? false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** The chosen rendering's root for `name`, if it has one. */
|
|
159
|
+
export function useKitRoot<K extends keyof KitRoots>(
|
|
160
|
+
name: K,
|
|
161
|
+
): ((props: KitRoots[K]) => React.ReactElement) | undefined {
|
|
162
|
+
return useRendering()?.roots?.[name];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Draws part `name` from the chosen rendering, or the kit's own (`children`). */
|
|
166
|
+
export function KitPart<K extends keyof KitParts>({
|
|
167
|
+
name,
|
|
168
|
+
props,
|
|
169
|
+
children,
|
|
170
|
+
}: {
|
|
171
|
+
name: K;
|
|
172
|
+
props: KitParts[K];
|
|
173
|
+
children: React.ReactNode;
|
|
174
|
+
}) {
|
|
175
|
+
const draw = useRendering()?.parts?.[name];
|
|
176
|
+
return <>{draw ? draw(props) : children}</>;
|
|
177
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Copies `text`. The Clipboard API exists only in a secure context, and Bridge on the LAN is plain HTTP
|
|
2
|
+
* (`http://192.168.…`); it also rejects where the page lacks the permission (a frame without `clipboard-write`).
|
|
3
|
+
* There, a hidden textarea and `execCommand('copy')`. The textarea goes inside the open dialog,
|
|
4
|
+
* if any, so its focus trap does not take the selection away. Rejects when neither works. */
|
|
5
|
+
export async function copyText(text: string) {
|
|
6
|
+
if (navigator.clipboard?.writeText) {
|
|
7
|
+
try {
|
|
8
|
+
return await navigator.clipboard.writeText(text);
|
|
9
|
+
} catch {
|
|
10
|
+
// the textarea below
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const focus = document.activeElement as HTMLElement | null;
|
|
14
|
+
const input = document.createElement("textarea");
|
|
15
|
+
input.value = text;
|
|
16
|
+
input.setAttribute("aria-hidden", "true");
|
|
17
|
+
input.readOnly = true;
|
|
18
|
+
Object.assign(input.style, { position: "fixed", left: "-9999px", top: "0" });
|
|
19
|
+
(focus?.closest('[role="dialog"]') ?? document.body).append(input);
|
|
20
|
+
try {
|
|
21
|
+
input.select();
|
|
22
|
+
if (!document.execCommand("copy")) throw new Error("Clipboard unavailable");
|
|
23
|
+
} finally {
|
|
24
|
+
input.remove();
|
|
25
|
+
focus?.focus({ preventScroll: true });
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/lib/dates.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The user's locale: the browser's first preferred language, so dates and numbers show in the user's system format.
|
|
2
|
+
* Undefined outside a browser, which lets `Intl` take the runtime's own. Never a fixed `en-US`: a French user reads
|
|
3
|
+
* `03/12/1985` as 3 December. */
|
|
4
|
+
export const userLocale = (): string | undefined => globalThis.navigator?.languages?.[0];
|
|
5
|
+
|
|
6
|
+
/** A date, a time or both in the user's format: `options` say which parts (`{ dateStyle: 'medium' }`,
|
|
7
|
+
* `{ hour: 'numeric', minute: '2-digit' }`); none gives the date and the time. Stored values stay ISO. */
|
|
8
|
+
export const formatDate = (value: Date | string | number, options?: Intl.DateTimeFormatOptions) =>
|
|
9
|
+
new Date(value).toLocaleString(userLocale(), options);
|
|
10
|
+
|
|
11
|
+
/** A number in the user's format: `1,234` in English, `1 234` in French. */
|
|
12
|
+
export const formatNumber = (value: number, options?: Intl.NumberFormatOptions) =>
|
|
13
|
+
value.toLocaleString(userLocale(), options);
|
package/src/lib/json.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// A JSON value from outside, checked before its fields are read; and Bridge's HTTP answers, `{ error: { code, message,
|
|
2
|
+
// hint? } }` when refused. Import-free: the page and every plugin take it from `@bridge/ui`, so a refusal reads the same
|
|
3
|
+
// everywhere. The host keeps its own copy for Node (`@bridge/kernel/json`): the kit imports nothing of Bridge's.
|
|
4
|
+
|
|
5
|
+
/** An object, neither `null` nor an array: what a parsed JSON value is checked to be before its fields are read. */
|
|
6
|
+
export const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
7
|
+
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
|
+
|
|
9
|
+
/** `value`'s items when it is an array, else none: an array from outside read without `Array.isArray`'s `any[]`. */
|
|
10
|
+
export const listOf = (value: unknown): unknown[] => (Array.isArray(value) ? value : []);
|
|
11
|
+
|
|
12
|
+
/** What a refused answer says: its `error.message` (else `HTTP <status>`), and its `code` and `hint` when strings. */
|
|
13
|
+
export interface Refusal {
|
|
14
|
+
message: string;
|
|
15
|
+
code?: string;
|
|
16
|
+
hint?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The refusal in `body`, an answer of status `status`. */
|
|
20
|
+
export const refusalOf = (body: unknown, status: number): Refusal => {
|
|
21
|
+
const error = isRecord(body) && isRecord(body.error) ? body.error : {};
|
|
22
|
+
return {
|
|
23
|
+
message: typeof error.message === "string" && error.message ? error.message : `HTTP ${status}`,
|
|
24
|
+
...(typeof error.code === "string" && { code: error.code }),
|
|
25
|
+
...(typeof error.hint === "string" && { hint: error.hint }),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** A refused answer as an Error: the refusal's message, its `code` and `hint`, and the `status`. */
|
|
30
|
+
export class HttpError extends Error {
|
|
31
|
+
readonly status: number;
|
|
32
|
+
readonly code: string | undefined;
|
|
33
|
+
readonly hint: string | undefined;
|
|
34
|
+
constructor(status: number, refusal: Refusal) {
|
|
35
|
+
super(refusal.message);
|
|
36
|
+
this.name = "HttpError";
|
|
37
|
+
this.status = status;
|
|
38
|
+
this.code = refusal.code;
|
|
39
|
+
this.hint = refusal.hint;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Throws an `HttpError` when `res` is not ok. An ok answer's body is not read: for a caller that needs none of its
|
|
44
|
+
* fields, so a 2xx cut short (a host restarting) still counts as done. */
|
|
45
|
+
export async function ensureOk(res: Response): Promise<void> {
|
|
46
|
+
if (!res.ok) await readJson(res);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** `res`'s JSON body. Throws an `HttpError` when `res` is not ok, and when its body is not JSON even under a 2xx (the
|
|
50
|
+
* request aborted mid-answer): never an answer without its fields. The body is `unknown`: an answer of Bridge's own
|
|
51
|
+
* routes is typed once where it is read (`as T`); one from elsewhere is checked. */
|
|
52
|
+
export async function readJson(res: Response): Promise<unknown> {
|
|
53
|
+
const body: { value: unknown } | undefined = await res.json().then(
|
|
54
|
+
(value: unknown) => ({ value }),
|
|
55
|
+
() => undefined,
|
|
56
|
+
);
|
|
57
|
+
if (!res.ok || !body) throw new HttpError(res.status, refusalOf(body?.value, res.status));
|
|
58
|
+
return body.value;
|
|
59
|
+
}
|
package/src/lib/keys.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// A shortcut's keys as Bridge writes them ("Meta+Backspace", "Shift+J", "G P") and as the menus show them ("⌘⌫").
|
|
2
|
+
|
|
3
|
+
const KEY_LABELS: Record<string, string> = {
|
|
4
|
+
Shift: "⇧",
|
|
5
|
+
Meta: "⌘",
|
|
6
|
+
Alt: "⌥",
|
|
7
|
+
Ctrl: "⌃",
|
|
8
|
+
Backspace: "⌫",
|
|
9
|
+
Enter: "↵",
|
|
10
|
+
Escape: "Esc",
|
|
11
|
+
ArrowUp: "↑",
|
|
12
|
+
ArrowDown: "↓",
|
|
13
|
+
ArrowLeft: "←",
|
|
14
|
+
ArrowRight: "→",
|
|
15
|
+
Tab: "⇥",
|
|
16
|
+
Space: "Space",
|
|
17
|
+
Delete: "Del",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** The keys as the menus show them: modifiers glued to the key ("⌘⌫", "⇧J"),
|
|
21
|
+
* a sequence keeping its space ("G P"). */
|
|
22
|
+
function formatKeys(keys: string): string {
|
|
23
|
+
return keys
|
|
24
|
+
.trim()
|
|
25
|
+
.split(/\s+/)
|
|
26
|
+
.map((step) =>
|
|
27
|
+
step
|
|
28
|
+
.split("+")
|
|
29
|
+
.map((token) => KEY_LABELS[token] ?? token)
|
|
30
|
+
.join(""),
|
|
31
|
+
)
|
|
32
|
+
.join(" ");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The key belongs to an input method's composition (Japanese, Chinese, Korean…): the Enter that confirms the composed
|
|
36
|
+
* text is not a submit, nor a digit typed there a pick. Safari sends that last Enter with `isComposing` false and
|
|
37
|
+
* keyCode 229. Takes a React event or a native one. */
|
|
38
|
+
function isComposing(event: KeyboardEvent | { nativeEvent: KeyboardEvent }): boolean {
|
|
39
|
+
const native = "nativeEvent" in event ? event.nativeEvent : event;
|
|
40
|
+
return native.isComposing || native.keyCode === 229;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A modal dialog is open (the shortcuts' help, a confirmation): the keys are its own, no page shortcut acts under it.
|
|
44
|
+
* The kit's `DialogContent` is known by its backdrop, open (its popup's `data-slot` can be a caller's, and a popover's
|
|
45
|
+
* popup is a `role="dialog"` too); another one says `aria-modal="true"` or is an alert dialog. */
|
|
46
|
+
function modalOpen(): boolean {
|
|
47
|
+
return (
|
|
48
|
+
document.querySelector(
|
|
49
|
+
'[data-slot="dialog-overlay"][data-open], [role="dialog"][aria-modal="true"], [role="alertdialog"]',
|
|
50
|
+
) !== null
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { KEY_LABELS, formatKeys, isComposing, modalOpen };
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { clsx, type ClassValue } from "clsx";
|
|
2
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
3
|
+
|
|
4
|
+
// The kit's own radii (./../theme/generate-tokens.ts), so a `rounded-full` passed to a control replaces its
|
|
5
|
+
// `rounded-control` rather than sitting beside it.
|
|
6
|
+
const twMerge = extendTailwindMerge({
|
|
7
|
+
extend: { theme: { radius: ["control", "control-inner", "default", "dropdown", "dialog"] } },
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export function cn(...inputs: ClassValue[]) {
|
|
11
|
+
return twMerge(clsx(inputs));
|
|
12
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
// A view's editing signal (research-069): the shell gives each window's view a scope (`ViewScopeProvider`, around the
|
|
4
|
+
// window body); each editor of that view (a `@bridge/records` form, a hand-made one) registers its own signal there and
|
|
5
|
+
// removes only its own. The view is `editing` while any of them holds unsaved changes: an agent's page never replaces it.
|
|
6
|
+
|
|
7
|
+
/** One editor's registration in a view's scope: `set` says whether it holds unsaved changes, `remove` takes it out. */
|
|
8
|
+
interface EditingRegistration {
|
|
9
|
+
set(dirty: boolean): void;
|
|
10
|
+
remove(): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** What the shell provides around a window's view. */
|
|
14
|
+
interface ViewScope {
|
|
15
|
+
register(): EditingRegistration;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const ViewScopeContext = React.createContext<ViewScope | null>(null);
|
|
19
|
+
|
|
20
|
+
/** The shell's, around a window's view. */
|
|
21
|
+
function ViewScopeProvider({
|
|
22
|
+
value,
|
|
23
|
+
children,
|
|
24
|
+
}: {
|
|
25
|
+
value: ViewScope | null;
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
}) {
|
|
28
|
+
return <ViewScopeContext.Provider value={value}>{children}</ViewScopeContext.Provider>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** An editor's signal in the view it renders in: call it with whether it holds unsaved changes (from a form
|
|
32
|
+
* subscription: no render needed). Registered while mounted, removed when unmounted; outside a shell, nothing. */
|
|
33
|
+
function useEditingSignal(): (dirty: boolean) => void {
|
|
34
|
+
const scope = React.useContext(ViewScopeContext);
|
|
35
|
+
const dirty = React.useRef(false);
|
|
36
|
+
const registration = React.useRef<EditingRegistration | null>(null);
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (!scope) return;
|
|
39
|
+
const mine = scope.register();
|
|
40
|
+
mine.set(dirty.current);
|
|
41
|
+
registration.current = mine;
|
|
42
|
+
return () => {
|
|
43
|
+
mine.remove();
|
|
44
|
+
if (registration.current === mine) registration.current = null;
|
|
45
|
+
};
|
|
46
|
+
}, [scope]);
|
|
47
|
+
return React.useCallback((value: boolean) => {
|
|
48
|
+
dirty.current = value;
|
|
49
|
+
registration.current?.set(value);
|
|
50
|
+
}, []);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A hand-made view's editor: `dirty` while it holds unsaved changes (its view is then `editing`). */
|
|
54
|
+
function useEditing(dirty: boolean): void {
|
|
55
|
+
const signal = useEditingSignal();
|
|
56
|
+
React.useEffect(() => signal(dirty), [signal, dirty]);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { ViewScopeProvider, useEditing, useEditingSignal };
|
|
60
|
+
export type { ViewScope, EditingRegistration };
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// The user's profile (research-049): what the user changed for themselves on this device, per field and per level
|
|
2
|
+
// (client-wide, or one workspace of one Bridge), kept in this browser's localStorage. Each entry is its own storage
|
|
3
|
+
// key, so two tabs writing two fields never overwrite each other (localStorage has no compare-and-set); the same field
|
|
4
|
+
// written twice: the later revision wins. An entry is a value or a tombstone (`deleted`, a level reset to what it
|
|
5
|
+
// inherits) with a revision (`rev`: this device and a counter that only grows) and its time (`at`). Read as unknown and
|
|
6
|
+
// checked here: an unreadable entry is no entry.
|
|
7
|
+
import { isRecord } from "../lib/json.ts";
|
|
8
|
+
|
|
9
|
+
/** The prefix of this browser's keys: `<prefix><namespace>|<key>|<level>` per entry, `<prefix>device` and `<prefix>counter`. */
|
|
10
|
+
export const PROFILE_KEY = "bridge.profile:";
|
|
11
|
+
|
|
12
|
+
/** One Bridge's workspace: the page's Bridge and the workspace's slug in its path. */
|
|
13
|
+
export interface WorkspaceRef {
|
|
14
|
+
bridgeId: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The level an entry belongs to: the whole client, or one workspace of one Bridge. */
|
|
19
|
+
export type Where = { scope: "global" } | { scope: "workspace"; workspace: WorkspaceRef };
|
|
20
|
+
|
|
21
|
+
interface Revision {
|
|
22
|
+
device: string;
|
|
23
|
+
counter: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface Entry {
|
|
27
|
+
value?: unknown;
|
|
28
|
+
deleted?: true;
|
|
29
|
+
rev: Revision;
|
|
30
|
+
/** The revision this one was written over (none: the first): a later sync tells concurrent writes from a write
|
|
31
|
+
* that saw the other. */
|
|
32
|
+
base?: Revision;
|
|
33
|
+
at: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The user's profile: values by namespace and key, at a level. */
|
|
37
|
+
export interface Profile {
|
|
38
|
+
/** The value in effect for `where.workspace` (its own, else the client-wide one), else the client-wide one. */
|
|
39
|
+
get(namespace: string, key: string, where?: { workspace?: WorkspaceRef }): unknown;
|
|
40
|
+
/** The explicit entry of one level only: `undefined` where the value is inherited or reset. */
|
|
41
|
+
read(namespace: string, key: string, where: Where): unknown;
|
|
42
|
+
set(namespace: string, key: string, value: unknown, where: Where): void;
|
|
43
|
+
/** Leaves a tombstone at that level: the level reads `undefined`, the next level shows through. */
|
|
44
|
+
reset(namespace: string, key: string, where: Where): void;
|
|
45
|
+
/** Calls `listener` on each change (this page's or another tab's); returns the unsubscribe. */
|
|
46
|
+
subscribe(listener: () => void): () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const levelOf = (where: Where): string =>
|
|
50
|
+
where.scope === "global"
|
|
51
|
+
? "global"
|
|
52
|
+
: `workspace:${where.workspace.bridgeId}:${where.workspace.slug}`;
|
|
53
|
+
|
|
54
|
+
const DEVICE_KEY = `${PROFILE_KEY}device`;
|
|
55
|
+
/** The highest counter this browser wrote, so a revision grows across tabs and fields. */
|
|
56
|
+
const COUNTER_KEY = `${PROFILE_KEY}counter`;
|
|
57
|
+
const entryKey = (namespace: string, key: string, level: string) =>
|
|
58
|
+
`${PROFILE_KEY}${encodeURIComponent(namespace)}|${encodeURIComponent(key)}|${encodeURIComponent(level)}`;
|
|
59
|
+
|
|
60
|
+
const newDeviceId = (): string => {
|
|
61
|
+
const cryptoApi = globalThis.crypto;
|
|
62
|
+
if (cryptoApi && typeof cryptoApi.randomUUID === "function") return cryptoApi.randomUUID();
|
|
63
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const readRevision = (value: unknown): Revision | undefined => {
|
|
67
|
+
if (!isRecord(value)) return undefined;
|
|
68
|
+
const { device, counter } = value;
|
|
69
|
+
if (typeof device !== "string" || typeof counter !== "number" || !Number.isFinite(counter))
|
|
70
|
+
return undefined;
|
|
71
|
+
return { device, counter };
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const readEntry = (value: unknown): Entry | undefined => {
|
|
75
|
+
if (!isRecord(value) || typeof value.at !== "string") return undefined;
|
|
76
|
+
const rev = readRevision(value.rev);
|
|
77
|
+
if (!rev) return undefined;
|
|
78
|
+
const base = readRevision(value.base);
|
|
79
|
+
const kept = { rev, at: value.at, ...(base && { base }) };
|
|
80
|
+
return value.deleted === true ? { deleted: true, ...kept } : { value: value.value, ...kept };
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** `a` is a later revision than `b` (the counter, then the device to decide a tie the same way everywhere). */
|
|
84
|
+
const later = (a: Revision, b: Revision) =>
|
|
85
|
+
a.counter !== b.counter ? a.counter > b.counter : a.device > b.device;
|
|
86
|
+
|
|
87
|
+
/** A profile kept in this browser's storage. A write storage refuses (blocked, full) still holds for this page. */
|
|
88
|
+
export function createProfile(): Profile {
|
|
89
|
+
const listeners = new Set<() => void>();
|
|
90
|
+
/** Entries this page wrote that storage refused: kept for this page, until storage holds a later one. */
|
|
91
|
+
const pending = new Map<string, Entry>();
|
|
92
|
+
let device: string | undefined;
|
|
93
|
+
/** The highest counter this page saw or wrote. */
|
|
94
|
+
let counter = 0;
|
|
95
|
+
|
|
96
|
+
const storage = (): Storage | undefined => {
|
|
97
|
+
try {
|
|
98
|
+
return typeof window === "undefined" ? undefined : window.localStorage;
|
|
99
|
+
} catch {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const stored = (name: string): Entry | undefined => {
|
|
105
|
+
try {
|
|
106
|
+
const raw = storage()?.getItem(name) ?? null;
|
|
107
|
+
return raw === null ? undefined : readEntry(JSON.parse(raw) as unknown);
|
|
108
|
+
} catch {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** The entry at `name`: storage's, or this page's refused one while it is the later. */
|
|
114
|
+
const entry = (name: string): Entry | undefined => {
|
|
115
|
+
const kept = stored(name);
|
|
116
|
+
const mine = pending.get(name);
|
|
117
|
+
if (mine && kept && !later(mine.rev, kept.rev)) pending.delete(name);
|
|
118
|
+
const found = mine && (!kept || later(mine.rev, kept.rev)) ? mine : kept;
|
|
119
|
+
if (found) counter = Math.max(counter, found.rev.counter);
|
|
120
|
+
return found;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const deviceId = (): string => {
|
|
124
|
+
if (device) return device;
|
|
125
|
+
try {
|
|
126
|
+
const kept = storage()?.getItem(DEVICE_KEY) ?? null;
|
|
127
|
+
if (kept && kept.length >= 8) return (device = kept);
|
|
128
|
+
} catch {
|
|
129
|
+
// A blocked storage: this page's own id.
|
|
130
|
+
}
|
|
131
|
+
device = newDeviceId();
|
|
132
|
+
try {
|
|
133
|
+
storage()?.setItem(DEVICE_KEY, device);
|
|
134
|
+
} catch {
|
|
135
|
+
// Kept for this page.
|
|
136
|
+
}
|
|
137
|
+
return device;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const tell = () => {
|
|
141
|
+
for (const listener of listeners) listener();
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const write = (namespace: string, key: string, where: Where, make: (rev: Revision) => Entry) => {
|
|
145
|
+
const name = entryKey(namespace, key, levelOf(where));
|
|
146
|
+
const previous = entry(name);
|
|
147
|
+
// Grows past what this field had, what this page saw, and the clock (another tab's counter is not known).
|
|
148
|
+
let last = 0;
|
|
149
|
+
try {
|
|
150
|
+
last = Number(storage()?.getItem(COUNTER_KEY)) || 0;
|
|
151
|
+
} catch {
|
|
152
|
+
// This page's counter.
|
|
153
|
+
}
|
|
154
|
+
counter = Math.max(counter, last, previous?.rev.counter ?? 0, Date.now()) + 1;
|
|
155
|
+
const next = {
|
|
156
|
+
...make({ device: deviceId(), counter }),
|
|
157
|
+
...(previous && { base: previous.rev }),
|
|
158
|
+
};
|
|
159
|
+
pending.set(name, next);
|
|
160
|
+
try {
|
|
161
|
+
const target = storage();
|
|
162
|
+
if (target) {
|
|
163
|
+
// Never over a later revision another tab kept since (the window left is the two calls below).
|
|
164
|
+
const now = stored(name);
|
|
165
|
+
if (now && later(now.rev, next.rev)) {
|
|
166
|
+
pending.delete(name);
|
|
167
|
+
tell();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
target.setItem(COUNTER_KEY, String(counter));
|
|
171
|
+
target.setItem(name, JSON.stringify(next));
|
|
172
|
+
pending.delete(name);
|
|
173
|
+
// Storage takes writes again: this page's refused ones go in too, unless a later one is kept there.
|
|
174
|
+
for (const [other, entry] of [...pending]) {
|
|
175
|
+
const there = stored(other);
|
|
176
|
+
if (!there || later(entry.rev, there.rev)) target.setItem(other, JSON.stringify(entry));
|
|
177
|
+
pending.delete(other);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} catch {
|
|
181
|
+
// Kept in `pending` for this page.
|
|
182
|
+
}
|
|
183
|
+
tell();
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const read = (namespace: string, key: string, where: Where): unknown => {
|
|
187
|
+
const found = entry(entryKey(namespace, key, levelOf(where)));
|
|
188
|
+
return found !== undefined && found.deleted !== true ? found.value : undefined;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const get = (namespace: string, key: string, where?: { workspace?: WorkspaceRef }): unknown => {
|
|
192
|
+
const workspace = where?.workspace;
|
|
193
|
+
if (workspace !== undefined) {
|
|
194
|
+
const local = read(namespace, key, { scope: "workspace", workspace });
|
|
195
|
+
if (local !== undefined) return local;
|
|
196
|
+
}
|
|
197
|
+
return read(namespace, key, { scope: "global" });
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const set = (namespace: string, key: string, value: unknown, where: Where) =>
|
|
201
|
+
write(namespace, key, where, (rev) => ({ value, rev, at: new Date().toISOString() }));
|
|
202
|
+
|
|
203
|
+
const reset = (namespace: string, key: string, where: Where) =>
|
|
204
|
+
write(namespace, key, where, (rev) => ({ deleted: true, rev, at: new Date().toISOString() }));
|
|
205
|
+
|
|
206
|
+
const subscribe = (listener: () => void) => {
|
|
207
|
+
listeners.add(listener);
|
|
208
|
+
return () => void listeners.delete(listener);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
if (typeof window !== "undefined") {
|
|
212
|
+
window.addEventListener("storage", (event) => {
|
|
213
|
+
if (event.key !== null && !event.key.startsWith(PROFILE_KEY)) return;
|
|
214
|
+
tell();
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return { get, read, set, reset, subscribe };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** This page's profile: entries are read from storage at each operation. */
|
|
222
|
+
export const profile = createProfile();
|
|
223
|
+
|
|
224
|
+
/** The page's workspace: its Bridge (`meta[name="bridge-instance-id"]`) and the slug in its path; none without either. */
|
|
225
|
+
export function currentWorkspace(): WorkspaceRef | undefined {
|
|
226
|
+
if (typeof document === "undefined" || typeof window === "undefined") return undefined;
|
|
227
|
+
const bridgeId = document.querySelector<HTMLMetaElement>(
|
|
228
|
+
'meta[name="bridge-instance-id"]',
|
|
229
|
+
)?.content;
|
|
230
|
+
if (!bridgeId) return undefined;
|
|
231
|
+
const slug = /^\/([^/_][^/]*)\//.exec(window.location.pathname)?.[1];
|
|
232
|
+
if (slug === undefined) return undefined;
|
|
233
|
+
try {
|
|
234
|
+
return { bridgeId, slug: decodeURIComponent(slug) };
|
|
235
|
+
} catch {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
}
|