@panphora/bevel 0.1.0
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 +16 -0
- package/README.md +226 -0
- package/bevel-fonts.css +16 -0
- package/bevel.css +3075 -0
- package/bevel.js +2126 -0
- package/dist/react/components/activity-feed.d.ts +89 -0
- package/dist/react/components/activity-feed.js +54 -0
- package/dist/react/components/alert-dialog.d.ts +14 -0
- package/dist/react/components/alert-dialog.js +19 -0
- package/dist/react/components/app-shell.d.ts +98 -0
- package/dist/react/components/app-shell.js +86 -0
- package/dist/react/components/app-toolbar.d.ts +19 -0
- package/dist/react/components/app-toolbar.js +22 -0
- package/dist/react/components/avatar-group.d.ts +67 -0
- package/dist/react/components/avatar-group.js +49 -0
- package/dist/react/components/badge-and-pill.d.ts +34 -0
- package/dist/react/components/badge-and-pill.js +12 -0
- package/dist/react/components/breadcrumbs.d.ts +56 -0
- package/dist/react/components/breadcrumbs.js +44 -0
- package/dist/react/components/bulk-bar.d.ts +22 -0
- package/dist/react/components/bulk-bar.js +59 -0
- package/dist/react/components/button.d.ts +15 -0
- package/dist/react/components/button.js +20 -0
- package/dist/react/components/callout-and-hint.d.ts +17 -0
- package/dist/react/components/callout-and-hint.js +8 -0
- package/dist/react/components/checkbox.d.ts +5 -0
- package/dist/react/components/checkbox.js +13 -0
- package/dist/react/components/chip.d.ts +149 -0
- package/dist/react/components/chip.js +29 -0
- package/dist/react/components/code-block.d.ts +50 -0
- package/dist/react/components/code-block.js +77 -0
- package/dist/react/components/code-editor.d.ts +122 -0
- package/dist/react/components/code-editor.js +695 -0
- package/dist/react/components/column-manager.d.ts +28 -0
- package/dist/react/components/column-manager.js +85 -0
- package/dist/react/components/combobox.d.ts +32 -0
- package/dist/react/components/combobox.js +37 -0
- package/dist/react/components/data-grid.d.ts +108 -0
- package/dist/react/components/data-grid.js +159 -0
- package/dist/react/components/data-table.d.ts +2 -0
- package/dist/react/components/data-table.js +6 -0
- package/dist/react/components/date.d.ts +23 -0
- package/dist/react/components/date.js +11 -0
- package/dist/react/components/details.d.ts +13 -0
- package/dist/react/components/details.js +20 -0
- package/dist/react/components/dialog.d.ts +74 -0
- package/dist/react/components/dialog.js +31 -0
- package/dist/react/components/diff-view.d.ts +73 -0
- package/dist/react/components/diff-view.js +68 -0
- package/dist/react/components/documents.d.ts +70 -0
- package/dist/react/components/documents.js +10 -0
- package/dist/react/components/drawer.d.ts +45 -0
- package/dist/react/components/drawer.js +35 -0
- package/dist/react/components/editable-grid-cells.d.ts +32 -0
- package/dist/react/components/editable-grid-cells.js +116 -0
- package/dist/react/components/eyebrow-kicker-lede-pull-quote.d.ts +39 -0
- package/dist/react/components/eyebrow-kicker-lede-pull-quote.js +12 -0
- package/dist/react/components/field.d.ts +32 -0
- package/dist/react/components/field.js +27 -0
- package/dist/react/components/file-tree.d.ts +75 -0
- package/dist/react/components/file-tree.js +247 -0
- package/dist/react/components/file.d.ts +43 -0
- package/dist/react/components/file.js +73 -0
- package/dist/react/components/files-table.d.ts +174 -0
- package/dist/react/components/files-table.js +237 -0
- package/dist/react/components/filter-builder.d.ts +37 -0
- package/dist/react/components/filter-builder.js +109 -0
- package/dist/react/components/form-error-summary.d.ts +16 -0
- package/dist/react/components/form-error-summary.js +49 -0
- package/dist/react/components/icon-button.d.ts +8 -0
- package/dist/react/components/icon-button.js +14 -0
- package/dist/react/components/icon.d.ts +7 -0
- package/dist/react/components/icon.js +15 -0
- package/dist/react/components/image.d.ts +72 -0
- package/dist/react/components/image.js +24 -0
- package/dist/react/components/inline-edit.d.ts +70 -0
- package/dist/react/components/inline-edit.js +149 -0
- package/dist/react/components/input.d.ts +29 -0
- package/dist/react/components/input.js +20 -0
- package/dist/react/components/kanban-board.d.ts +140 -0
- package/dist/react/components/kanban-board.js +374 -0
- package/dist/react/components/layout.d.ts +51 -0
- package/dist/react/components/layout.js +28 -0
- package/dist/react/components/list.d.ts +28 -0
- package/dist/react/components/list.js +6 -0
- package/dist/react/components/masthead-and-verdict.d.ts +60 -0
- package/dist/react/components/masthead-and-verdict.js +8 -0
- package/dist/react/components/menu.d.ts +26 -0
- package/dist/react/components/menu.js +31 -0
- package/dist/react/components/multi-select-picker.d.ts +49 -0
- package/dist/react/components/multi-select-picker.js +20 -0
- package/dist/react/components/note.d.ts +33 -0
- package/dist/react/components/note.js +8 -0
- package/dist/react/components/number-field.d.ts +16 -0
- package/dist/react/components/number-field.js +17 -0
- package/dist/react/components/pagination.d.ts +45 -0
- package/dist/react/components/pagination.js +87 -0
- package/dist/react/components/persistent-action-banner.d.ts +71 -0
- package/dist/react/components/persistent-action-banner.js +39 -0
- package/dist/react/components/popconfirm.d.ts +42 -0
- package/dist/react/components/popconfirm.js +59 -0
- package/dist/react/components/popover.d.ts +16 -0
- package/dist/react/components/popover.js +21 -0
- package/dist/react/components/progress-and-gauge.d.ts +44 -0
- package/dist/react/components/progress-and-gauge.js +19 -0
- package/dist/react/components/radio.d.ts +7 -0
- package/dist/react/components/radio.js +13 -0
- package/dist/react/components/rich-text-toolbar.d.ts +26 -0
- package/dist/react/components/rich-text-toolbar.js +64 -0
- package/dist/react/components/rows-and-card.d.ts +88 -0
- package/dist/react/components/rows-and-card.js +10 -0
- package/dist/react/components/save-status-indicator.d.ts +11 -0
- package/dist/react/components/save-status-indicator.js +33 -0
- package/dist/react/components/segmented-control.d.ts +21 -0
- package/dist/react/components/segmented-control.js +15 -0
- package/dist/react/components/select.d.ts +29 -0
- package/dist/react/components/select.js +29 -0
- package/dist/react/components/selectable-cards.d.ts +30 -0
- package/dist/react/components/selectable-cards.js +29 -0
- package/dist/react/components/settings-rows.d.ts +51 -0
- package/dist/react/components/settings-rows.js +8 -0
- package/dist/react/components/sidebar-nav.d.ts +77 -0
- package/dist/react/components/sidebar-nav.js +41 -0
- package/dist/react/components/skeleton-and-empty.d.ts +51 -0
- package/dist/react/components/skeleton-and-empty.js +14 -0
- package/dist/react/components/slider.d.ts +19 -0
- package/dist/react/components/slider.js +17 -0
- package/dist/react/components/small-charts.d.ts +60 -0
- package/dist/react/components/small-charts.js +76 -0
- package/dist/react/components/sortable.d.ts +30 -0
- package/dist/react/components/sortable.js +85 -0
- package/dist/react/components/split-button.d.ts +38 -0
- package/dist/react/components/split-button.js +43 -0
- package/dist/react/components/split-panes.d.ts +35 -0
- package/dist/react/components/split-panes.js +102 -0
- package/dist/react/components/stat-tiles.d.ts +54 -0
- package/dist/react/components/stat-tiles.js +8 -0
- package/dist/react/components/steps.d.ts +11 -0
- package/dist/react/components/steps.js +13 -0
- package/dist/react/components/switch.d.ts +6 -0
- package/dist/react/components/switch.js +13 -0
- package/dist/react/components/table.d.ts +61 -0
- package/dist/react/components/table.js +6 -0
- package/dist/react/components/tabs.d.ts +7 -0
- package/dist/react/components/tabs.js +13 -0
- package/dist/react/components/tags.d.ts +33 -0
- package/dist/react/components/tags.js +83 -0
- package/dist/react/components/textarea.d.ts +10 -0
- package/dist/react/components/textarea.js +6 -0
- package/dist/react/components/toast.d.ts +35 -0
- package/dist/react/components/toast.js +90 -0
- package/dist/react/components/tooltip-and-key.d.ts +20 -0
- package/dist/react/components/tooltip-and-key.js +20 -0
- package/dist/react/components/tree-view.d.ts +34 -0
- package/dist/react/components/tree-view.js +118 -0
- package/dist/react/components/upload-dropzone.d.ts +92 -0
- package/dist/react/components/upload-dropzone.js +116 -0
- package/dist/react/components/wizard-shell.d.ts +78 -0
- package/dist/react/components/wizard-shell.js +176 -0
- package/dist/react/fonts.css.d.ts +1 -0
- package/dist/react/index.d.ts +76 -0
- package/dist/react/index.js +77 -0
- package/dist/react/integrations/quickcrop.d.ts +58 -0
- package/dist/react/integrations/quickcrop.js +137 -0
- package/dist/react/integrations/richclay.d.ts +43 -0
- package/dist/react/integrations/richclay.js +129 -0
- package/dist/react/internal/classes.d.ts +3 -0
- package/dist/react/internal/classes.js +10 -0
- package/dist/react/internal/close-mark.d.ts +1 -0
- package/dist/react/internal/close-mark.js +10 -0
- package/dist/react/internal/controllable-state.d.ts +9 -0
- package/dist/react/internal/controllable-state.js +22 -0
- package/dist/react/internal/drop-effect.d.ts +28 -0
- package/dist/react/internal/drop-effect.js +8 -0
- package/dist/react/internal/form-reset.d.ts +2 -0
- package/dist/react/internal/form-reset.js +22 -0
- package/dist/react/internal/format.d.ts +1 -0
- package/dist/react/internal/format.js +14 -0
- package/dist/react/internal/link.d.ts +2 -0
- package/dist/react/internal/link.js +8 -0
- package/dist/react/internal/part.d.ts +20 -0
- package/dist/react/internal/part.js +47 -0
- package/dist/react/internal/pointer-session.d.ts +8 -0
- package/dist/react/internal/pointer-session.js +60 -0
- package/dist/react/internal/refs.d.ts +2 -0
- package/dist/react/internal/refs.js +22 -0
- package/dist/react/internal/rich-text.d.ts +28 -0
- package/dist/react/internal/rich-text.js +4 -0
- package/dist/react/internal/table-context.d.ts +39 -0
- package/dist/react/internal/table-context.js +12 -0
- package/dist/react/internal/use-object-url.d.ts +1 -0
- package/dist/react/internal/use-object-url.js +15 -0
- package/dist/react/layout.css +274 -0
- package/dist/react/layout.css.d.ts +1 -0
- package/dist/react/models/filter.d.ts +31 -0
- package/dist/react/models/filter.js +79 -0
- package/dist/react/models/kanban.d.ts +51 -0
- package/dist/react/models/kanban.js +35 -0
- package/dist/react/models/reorder.d.ts +9 -0
- package/dist/react/models/reorder.js +23 -0
- package/dist/react/models/table.d.ts +85 -0
- package/dist/react/models/table.js +144 -0
- package/dist/react/models/tree.d.ts +16 -0
- package/dist/react/models/tree.js +26 -0
- package/dist/react/provider.d.ts +18 -0
- package/dist/react/provider.js +31 -0
- package/dist/react/recipes/context-hypercms.d.ts +17 -0
- package/dist/react/recipes/context-hypercms.js +71 -0
- package/dist/react/recipes/context-quickcrop.d.ts +8 -0
- package/dist/react/recipes/context-quickcrop.js +49 -0
- package/dist/react/theme.css +8004 -0
- package/dist/react/theme.css.d.ts +1 -0
- package/examples/README.md +34 -0
- package/examples/components/activity-feed.html +28 -0
- package/examples/components/app-shell.html +12 -0
- package/examples/components/app-toolbar.html +38 -0
- package/examples/components/avatar-group.html +27 -0
- package/examples/components/breadcrumbs.html +26 -0
- package/examples/components/bulk-bar.html +22 -0
- package/examples/components/code-block.html +12 -0
- package/examples/components/code-editor.html +25 -0
- package/examples/components/column-manager.html +9 -0
- package/examples/components/combobox.html +13 -0
- package/examples/components/context-hypercms.css +41 -0
- package/examples/components/context-hypercms.html +40 -0
- package/examples/components/context-hypercms.js +62 -0
- package/examples/components/context-quickcrop.html +137 -0
- package/examples/components/diff-view.html +9 -0
- package/examples/components/drawer.html +11 -0
- package/examples/components/editable-grid-cells.html +9 -0
- package/examples/components/file-browser.html +53 -0
- package/examples/components/file-tree.html +34 -0
- package/examples/components/files-table.html +80 -0
- package/examples/components/filter-builder.html +11 -0
- package/examples/components/form-error-summary.html +11 -0
- package/examples/components/index.html +51 -0
- package/examples/components/inline-edit.html +42 -0
- package/examples/components/kanban-board.html +42 -0
- package/examples/components/manifest.json +3279 -0
- package/examples/components/modal.html +11 -0
- package/examples/components/multi-select-picker.html +13 -0
- package/examples/components/pagination.html +32 -0
- package/examples/components/persistent-action-banner.html +23 -0
- package/examples/components/popconfirm.html +13 -0
- package/examples/components/popover-menu.html +13 -0
- package/examples/components/reference/baseline/DECISIONS.md +85 -0
- package/examples/components/reference/baseline/README.md +58 -0
- package/examples/components/reference/baseline/bevel-fonts.css +16 -0
- package/examples/components/reference/baseline/bevel.css +1339 -0
- package/examples/components/reference/baseline/bevel.js +496 -0
- package/examples/components/reference/baseline/fonts/LICENSE-ibm-plex-mono.txt +93 -0
- package/examples/components/reference/baseline/fonts/LICENSE-ibm-plex-sans.txt +93 -0
- package/examples/components/reference/baseline/fonts/LICENSE-newsreader.txt +93 -0
- package/examples/components/reference/baseline/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/examples/components/reference/baseline/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/examples/components/reference/baseline/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/examples/components/reference/baseline/fonts/ibm-plex-sans-latin-400-italic.woff2 +0 -0
- package/examples/components/reference/baseline/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- package/examples/components/reference/baseline/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
- package/examples/components/reference/baseline/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- package/examples/components/reference/baseline/fonts/newsreader-latin-opsz-italic.woff2 +0 -0
- package/examples/components/reference/baseline/fonts/newsreader-latin-opsz-normal.woff2 +0 -0
- package/examples/components/reference/fable/IMPROVEMENTS.md +106 -0
- package/examples/components/reference/fable/PARENT-REPAIRS.md +17 -0
- package/examples/components/reference/fable/__pycache__/build_repairs.cpython-311.pyc +0 -0
- package/examples/components/reference/fable/__pycache__/kanban.cpython-311.pyc +0 -0
- package/examples/components/reference/fable/as-authored/IMPROVEMENTS-completed.md +106 -0
- package/examples/components/reference/fable/as-authored/base-astra.css +17 -0
- package/examples/components/reference/fable/as-authored/base-parent.css +416 -0
- package/examples/components/reference/fable/as-authored/build.py +858 -0
- package/examples/components/reference/fable/as-authored/fable.css +823 -0
- package/examples/components/reference/fable/as-authored/kanban-completed.css +235 -0
- package/examples/components/reference/fable/as-authored/kanban-completed.html +53 -0
- package/examples/components/reference/fable/as-authored/kanban-completed.py +212 -0
- package/examples/components/reference/fable/as-authored/kanban.py +207 -0
- package/examples/components/reference/fable/base-astra.css +17 -0
- package/examples/components/reference/fable/base-parent.css +416 -0
- package/examples/components/reference/fable/build.py +858 -0
- package/examples/components/reference/fable/build_repairs.py +25 -0
- package/examples/components/reference/fable/components/activity-feed.html +3 -0
- package/examples/components/reference/fable/components/app-toolbar.html +3 -0
- package/examples/components/reference/fable/components/avatar-group.html +4 -0
- package/examples/components/reference/fable/components/breadcrumbs.html +3 -0
- package/examples/components/reference/fable/components/code-block.html +9 -0
- package/examples/components/reference/fable/components/column-manager.html +3 -0
- package/examples/components/reference/fable/components/combobox.html +6 -0
- package/examples/components/reference/fable/components/context-hypercms.html +3 -0
- package/examples/components/reference/fable/components/context-quickcrop.html +4 -0
- package/examples/components/reference/fable/components/diff-view.html +13 -0
- package/examples/components/reference/fable/components/drawer.html +3 -0
- package/examples/components/reference/fable/components/editable-grid-cells.html +3 -0
- package/examples/components/reference/fable/components/filter-builder.html +3 -0
- package/examples/components/reference/fable/components/form-error-summary.html +4 -0
- package/examples/components/reference/fable/components/inline-edit.html +3 -0
- package/examples/components/reference/fable/components/kanban-board.html +53 -0
- package/examples/components/reference/fable/components/modal.html +3 -0
- package/examples/components/reference/fable/components/multi-select-picker.html +5 -0
- package/examples/components/reference/fable/components/pagination.html +3 -0
- package/examples/components/reference/fable/components/persistent-action-banner.html +4 -0
- package/examples/components/reference/fable/components/popconfirm.html +5 -0
- package/examples/components/reference/fable/components/popover-menu.html +3 -0
- package/examples/components/reference/fable/components/rich-text-toolbar.html +3 -0
- package/examples/components/reference/fable/components/save-status-indicator.html +2 -0
- package/examples/components/reference/fable/components/selectable-cards.html +3 -0
- package/examples/components/reference/fable/components/settings-rows.html +3 -0
- package/examples/components/reference/fable/components/sidebar-nav.html +4 -0
- package/examples/components/reference/fable/components/small-charts.html +5 -0
- package/examples/components/reference/fable/components/split-button.html +4 -0
- package/examples/components/reference/fable/components/split-panes.html +8 -0
- package/examples/components/reference/fable/components/stat-tiles.html +3 -0
- package/examples/components/reference/fable/components/toast-stack.html +5 -0
- package/examples/components/reference/fable/components/tree-view.html +4 -0
- package/examples/components/reference/fable/components/upload-dropzone.html +6 -0
- package/examples/components/reference/fable/components/wizard-shell.html +3 -0
- package/examples/components/reference/fable/coverage.json +414 -0
- package/examples/components/reference/fable/fable.css +823 -0
- package/examples/components/reference/fable/index.html +5 -0
- package/examples/components/reference/fable/kanban.css +237 -0
- package/examples/components/reference/fable/kanban.py +212 -0
- package/examples/components/reference/fable/parent-repairs.css +9 -0
- package/examples/components/reference/fixtures/data.json +102 -0
- package/examples/components/reference/fixtures/host.js +47 -0
- package/examples/components/reference/fixtures/static-host.js +39 -0
- package/examples/components/reference/fixtures/workspace.jpg +0 -0
- package/examples/components/reference/parent/CHANGES.md +179 -0
- package/examples/components/reference/parent/__pycache__/kanban.cpython-311.pyc +0 -0
- package/examples/components/reference/parent/base-astra.css +17 -0
- package/examples/components/reference/parent/base-parent.css +416 -0
- package/examples/components/reference/parent/build.py +148 -0
- package/examples/components/reference/parent/components/activity-feed.html +2 -0
- package/examples/components/reference/parent/components/app-toolbar.html +2 -0
- package/examples/components/reference/parent/components/avatar-group.html +4 -0
- package/examples/components/reference/parent/components/breadcrumbs.html +2 -0
- package/examples/components/reference/parent/components/code-block.html +8 -0
- package/examples/components/reference/parent/components/column-manager.html +2 -0
- package/examples/components/reference/parent/components/combobox.html +6 -0
- package/examples/components/reference/parent/components/context-hypercms.html +2 -0
- package/examples/components/reference/parent/components/context-quickcrop.html +4 -0
- package/examples/components/reference/parent/components/diff-view.html +4 -0
- package/examples/components/reference/parent/components/drawer.html +2 -0
- package/examples/components/reference/parent/components/editable-grid-cells.html +2 -0
- package/examples/components/reference/parent/components/filter-builder.html +2 -0
- package/examples/components/reference/parent/components/form-error-summary.html +2 -0
- package/examples/components/reference/parent/components/inline-edit.html +2 -0
- package/examples/components/reference/parent/components/kanban-board.html +84 -0
- package/examples/components/reference/parent/components/modal.html +2 -0
- package/examples/components/reference/parent/components/multi-select-picker.html +5 -0
- package/examples/components/reference/parent/components/pagination.html +2 -0
- package/examples/components/reference/parent/components/persistent-action-banner.html +4 -0
- package/examples/components/reference/parent/components/popconfirm.html +5 -0
- package/examples/components/reference/parent/components/popover-menu.html +2 -0
- package/examples/components/reference/parent/components/rich-text-toolbar.html +2 -0
- package/examples/components/reference/parent/components/save-status-indicator.html +2 -0
- package/examples/components/reference/parent/components/selectable-cards.html +2 -0
- package/examples/components/reference/parent/components/settings-rows.html +2 -0
- package/examples/components/reference/parent/components/sidebar-nav.html +4 -0
- package/examples/components/reference/parent/components/small-charts.html +2 -0
- package/examples/components/reference/parent/components/split-button.html +5 -0
- package/examples/components/reference/parent/components/split-panes.html +8 -0
- package/examples/components/reference/parent/components/stat-tiles.html +2 -0
- package/examples/components/reference/parent/components/toast-stack.html +5 -0
- package/examples/components/reference/parent/components/tree-view.html +4 -0
- package/examples/components/reference/parent/components/upload-dropzone.html +6 -0
- package/examples/components/reference/parent/components/wizard-shell.html +2 -0
- package/examples/components/reference/parent/coverage.json +414 -0
- package/examples/components/reference/parent/index.html +1 -0
- package/examples/components/reference/parent/kanban.css +114 -0
- package/examples/components/reference/parent/kanban.py +55 -0
- package/examples/components/reference/parent/refinement.css +53 -0
- package/examples/components/reference/selected/build.py +70 -0
- package/examples/components/reference/selected/components/activity-feed.html +3 -0
- package/examples/components/reference/selected/components/app-toolbar.html +3 -0
- package/examples/components/reference/selected/components/avatar-group.html +4 -0
- package/examples/components/reference/selected/components/breadcrumbs.html +3 -0
- package/examples/components/reference/selected/components/code-block.html +9 -0
- package/examples/components/reference/selected/components/column-manager.html +3 -0
- package/examples/components/reference/selected/components/combobox.html +6 -0
- package/examples/components/reference/selected/components/context-hypercms.html +3 -0
- package/examples/components/reference/selected/components/context-quickcrop.html +4 -0
- package/examples/components/reference/selected/components/diff-view.html +13 -0
- package/examples/components/reference/selected/components/drawer.html +3 -0
- package/examples/components/reference/selected/components/editable-grid-cells.html +3 -0
- package/examples/components/reference/selected/components/filter-builder.html +3 -0
- package/examples/components/reference/selected/components/form-error-summary.html +4 -0
- package/examples/components/reference/selected/components/inline-edit.html +3 -0
- package/examples/components/reference/selected/components/kanban-board.html +53 -0
- package/examples/components/reference/selected/components/modal.html +2 -0
- package/examples/components/reference/selected/components/multi-select-picker.html +5 -0
- package/examples/components/reference/selected/components/pagination.html +3 -0
- package/examples/components/reference/selected/components/persistent-action-banner.html +4 -0
- package/examples/components/reference/selected/components/popconfirm.html +5 -0
- package/examples/components/reference/selected/components/popover-menu.html +3 -0
- package/examples/components/reference/selected/components/rich-text-toolbar.html +3 -0
- package/examples/components/reference/selected/components/save-status-indicator.html +2 -0
- package/examples/components/reference/selected/components/selectable-cards.html +3 -0
- package/examples/components/reference/selected/components/settings-rows.html +3 -0
- package/examples/components/reference/selected/components/sidebar-nav.html +4 -0
- package/examples/components/reference/selected/components/small-charts.html +5 -0
- package/examples/components/reference/selected/components/split-button.html +4 -0
- package/examples/components/reference/selected/components/split-panes.html +8 -0
- package/examples/components/reference/selected/components/stat-tiles.html +3 -0
- package/examples/components/reference/selected/components/toast-stack.html +5 -0
- package/examples/components/reference/selected/components/tree-view.html +4 -0
- package/examples/components/reference/selected/components/upload-dropzone.html +6 -0
- package/examples/components/reference/selected/components/wizard-shell.html +3 -0
- package/examples/components/reference/selected/corrections.css +11 -0
- package/examples/components/reference/selected/coverage.json +413 -0
- package/examples/components/reference/selected/gallery-build.mjs +49 -0
- package/examples/components/reference/selected/gallery-spec.json +12 -0
- package/examples/components/reference/selected/index.html +1 -0
- package/examples/components/reference/selected/kanban-comparison.json +6 -0
- package/examples/components/reference/selected/manifest.json +476 -0
- package/examples/components/reference/sha256.json +142 -0
- package/examples/components/reference/sources/diagonal-close.svg +1 -0
- package/examples/components/reference/sources/hyperclay/public-assets/css/hyperclay-app-source.css +614 -0
- package/examples/components/reference/sources/hyperclay/public-assets/js/app.js +94 -0
- package/examples/components/reference/sources/hyperclayjs/src/ui/theModal.js +897 -0
- package/examples/components/reference/sources/hypercms/scripts/build-theme.js +203 -0
- package/examples/components/reference/sources/hypercms/src/anchor.js +24 -0
- package/examples/components/reference/sources/hypercms/src/apply-loop.js +167 -0
- package/examples/components/reference/sources/hypercms/src/diagnostics.js +44 -0
- package/examples/components/reference/sources/hypercms/src/enhance.js +173 -0
- package/examples/components/reference/sources/hypercms/src/events.js +955 -0
- package/examples/components/reference/sources/hypercms/src/form-builder.js +518 -0
- package/examples/components/reference/sources/hypercms/src/form-rules.js +208 -0
- package/examples/components/reference/sources/hypercms/src/hooks.js +100 -0
- package/examples/components/reference/sources/hypercms/src/hypercms-bundle.js +10 -0
- package/examples/components/reference/sources/hypercms/src/hypercms.js +347 -0
- package/examples/components/reference/sources/hypercms/src/morph.js +10 -0
- package/examples/components/reference/sources/hypercms/src/path.js +61 -0
- package/examples/components/reference/sources/hypercms/src/place.js +131 -0
- package/examples/components/reference/sources/hypercms/src/platform.js +131 -0
- package/examples/components/reference/sources/hypercms/src/refresh.js +87 -0
- package/examples/components/reference/sources/hypercms/src/richclay-bridge.js +140 -0
- package/examples/components/reference/sources/hypercms/src/row-identity.js +111 -0
- package/examples/components/reference/sources/hypercms/src/scaffold.js +10 -0
- package/examples/components/reference/sources/hypercms/src/session.js +303 -0
- package/examples/components/reference/sources/hypercms/src/shell.js +248 -0
- package/examples/components/reference/sources/hypercms/src/styles.css +298 -0
- package/examples/components/reference/sources/hypercms/src/targets.js +144 -0
- package/examples/components/reference/sources/hypercms/src/templates.js +656 -0
- package/examples/components/reference/sources/hypercms/src/theme/pixel-quiet.overrides.css +761 -0
- package/examples/components/reference/sources/hypercms/src/theme.generated.css +1772 -0
- package/examples/components/reference/sources/hypercms/src/toggle.js +666 -0
- package/examples/components/reference/sources/hypercms/src/unresolved.js +211 -0
- package/examples/components/reference/sources/hypercms/src/vendor/mirk.vendor.js +212 -0
- package/examples/components/reference/sources/hypercms/src/views/inline-layer.js +421 -0
- package/examples/components/reference/sources/hypercms/src/views/inline.js +1072 -0
- package/examples/components/reference/sources/hypercms/src/views/sidebar.js +97 -0
- package/examples/components/reference/sources/modal-reference.html +301 -0
- package/examples/components/reference/sources/quickcrop/quickcrop.css +124 -0
- package/examples/components/reference/sources/quickcrop/quickcrop.js +400 -0
- package/examples/components/reference/sources/richclay/richclay.css +416 -0
- package/examples/components/reference/sources/richclay/richclay.js +2962 -0
- package/examples/components/reference/sources/richclay/src/a11y.js +67 -0
- package/examples/components/reference/sources/richclay/src/browser-global.js +7 -0
- package/examples/components/reference/sources/richclay/src/buttons.js +254 -0
- package/examples/components/reference/sources/richclay/src/hyperclay.js +470 -0
- package/examples/components/reference/sources/richclay/src/normalize.js +380 -0
- package/examples/components/reference/sources/richclay/src/richclay.js +1356 -0
- package/examples/components/reference/sources/richclay/src/sanitize.js +189 -0
- package/examples/components/reference/sources/richclay/src/styles.js +23 -0
- package/examples/components/reference/sources/richclay/src/toolbar-float.js +175 -0
- package/examples/components/reference/sources/richclay/src/toolbar.js +394 -0
- package/examples/components/reference/sources/richclay/src/vendor-bundle.js +15 -0
- package/examples/components/reference/sources/richclay/vendor/DOMPURIFY-LICENSE +202 -0
- package/examples/components/reference/sources/richclay/vendor/DOMPURIFY-LICENSE-MPL +373 -0
- package/examples/components/reference/sources/richclay/vendor/SQUIRE-LICENSE +21 -0
- package/examples/components/reference/sources/richclay/vendor/purify.es.mjs +2249 -0
- package/examples/components/reference/sources/richclay/vendor/purify.min.js +3 -0
- package/examples/components/reference/sources/richclay/vendor/squire.js +22 -0
- package/examples/components/reference/sources/richclay/vendor/squire.mjs +22 -0
- package/examples/components/reference/sources/richclay/vendor/squire.provenance.json +19 -0
- package/examples/components/rich-text-toolbar.html +43 -0
- package/examples/components/save-status-indicator.html +11 -0
- package/examples/components/selectable-cards.html +9 -0
- package/examples/components/settings-rows.html +10 -0
- package/examples/components/sidebar-nav.html +9 -0
- package/examples/components/small-charts.html +21 -0
- package/examples/components/split-button.html +13 -0
- package/examples/components/split-panes-editor.html +6 -0
- package/examples/components/split-panes.html +9 -0
- package/examples/components/stat-tiles.html +23 -0
- package/examples/components/toast-stack.html +21 -0
- package/examples/components/tree-view.html +9 -0
- package/examples/components/upload-dropzone.html +88 -0
- package/examples/components/wizard-shell.html +50 -0
- package/examples/datastar/index.html +38 -0
- package/examples/datastar/server.mjs +31 -0
- package/examples/fixtures/field-guide.pdf +14 -0
- package/examples/fixtures/workspace.jpg +0 -0
- package/examples/setup-peers.mjs +35 -0
- package/fonts/LICENSE-ibm-plex-mono.txt +93 -0
- package/fonts/LICENSE-ibm-plex-sans.txt +93 -0
- package/fonts/LICENSE-newsreader.txt +93 -0
- package/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-400-italic.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
- package/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- package/fonts/newsreader-latin-opsz-italic.woff2 +0 -0
- package/fonts/newsreader-latin-opsz-normal.woff2 +0 -0
- package/icons/LICENSE +21 -0
- package/icons/house.json +71 -0
- package/icons/icons.d.ts +17 -0
- package/icons/icons.js +648 -0
- package/icons/icons.svg +126 -0
- package/icons/marks/build-tray.source.mjs +45 -0
- package/icons/marks/hyperclay-local.svg +11 -0
- package/icons/phosphor.json +53 -0
- package/icons/round.json +8 -0
- package/integrations/datastar.js +202 -0
- package/integrations/quickcrop.css +26 -0
- package/integrations/quickcrop.js +56 -0
- package/integrations/richclay.css +100 -0
- package/integrations/richclay.js +131 -0
- package/package.json +630 -0
- package/react/README.md +244 -0
- package/src/README.md +83 -0
- package/vendor/datastar/datastar-1.0.3.js +10 -0
- package/vendor/datastar/provenance.json +6 -0
- package/vendor/floating-ui/LICENSE-core +20 -0
- package/vendor/floating-ui/LICENSE-dom +20 -0
- package/vendor/floating-ui/floating-ui.core.umd.min.js +1 -0
- package/vendor/floating-ui/floating-ui.dom.umd.min.js +1 -0
- package/vendor/floating-ui/provenance.json +17 -0
- package/vendor/richclay/LICENSE +16 -0
- package/vendor/richclay/THIRD-PARTY-NOTICES.md +45 -0
- package/vendor/richclay/provenance.json +17 -0
- package/vendor/richclay/richclay.css +404 -0
- package/vendor/richclay/richclay.js +2940 -0
- package/vendor/richclay/vendor/DOMPURIFY-LICENSE +202 -0
- package/vendor/richclay/vendor/DOMPURIFY-LICENSE-MPL +373 -0
- package/vendor/richclay/vendor/SQUIRE-LICENSE +21 -0
- package/vendor/richclay/vendor/purify.min.js +3 -0
- package/vendor/richclay/vendor/squire.js +22 -0
- package/vendor/richclay/vendor/squire.provenance.json +30 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
export const DEFAULT_SANITIZE_CONFIG = {
|
|
2
|
+
ALLOWED_TAGS: [
|
|
3
|
+
"a",
|
|
4
|
+
"b",
|
|
5
|
+
"blockquote",
|
|
6
|
+
"br",
|
|
7
|
+
"code",
|
|
8
|
+
"div",
|
|
9
|
+
"em",
|
|
10
|
+
"h1",
|
|
11
|
+
"h2",
|
|
12
|
+
"h3",
|
|
13
|
+
"h4",
|
|
14
|
+
"h5",
|
|
15
|
+
"h6",
|
|
16
|
+
"i",
|
|
17
|
+
"li",
|
|
18
|
+
"ol",
|
|
19
|
+
"p",
|
|
20
|
+
"pre",
|
|
21
|
+
"s",
|
|
22
|
+
"span",
|
|
23
|
+
"strong",
|
|
24
|
+
"sub",
|
|
25
|
+
"sup",
|
|
26
|
+
"u",
|
|
27
|
+
"ul"
|
|
28
|
+
],
|
|
29
|
+
ALLOWED_ATTR: ["aria-label", "href", "rel", "target", "title"],
|
|
30
|
+
ALLOW_DATA_ATTR: false,
|
|
31
|
+
ALLOW_ARIA_ATTR: true,
|
|
32
|
+
ALLOWED_URI_REGEXP:
|
|
33
|
+
/^(?:(?:(?:f|ht)tps?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,
|
|
34
|
+
FORBID_TAGS: ["script", "style", "iframe", "object", "embed", "form", "input"],
|
|
35
|
+
FORBID_ATTR: ["style", "srcset", "onerror", "onclick", "onload"]
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function createSanitizer(config = {}, doc = document) {
|
|
39
|
+
const purify = resolveDOMPurify(doc);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
sanitizeHTML(html) {
|
|
43
|
+
return sanitizeHTML(html, config, doc, purify);
|
|
44
|
+
},
|
|
45
|
+
sanitizeElement(element) {
|
|
46
|
+
return sanitizeElement(element, config, purify);
|
|
47
|
+
},
|
|
48
|
+
sanitizeToDOMFragment(html, editor) {
|
|
49
|
+
const ownerDocument = editor?.getRoot?.().ownerDocument || doc;
|
|
50
|
+
return sanitizeToDOMFragment(html, config, ownerDocument, purify);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function sanitizeHTML(html, config = {}, doc = document, purify = resolveDOMPurify(doc)) {
|
|
56
|
+
const template = doc.createElement("template");
|
|
57
|
+
template.innerHTML = purify.sanitize(String(html || ""), mergeConfig(config));
|
|
58
|
+
normalizeLinks(template.content);
|
|
59
|
+
return template.innerHTML;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function sanitizeElement(element, config = {}, purify = resolveDOMPurify(element.ownerDocument)) {
|
|
63
|
+
const doc = element.ownerDocument;
|
|
64
|
+
const wrapper = doc.createElement("div");
|
|
65
|
+
while (element.firstChild) wrapper.appendChild(element.firstChild);
|
|
66
|
+
|
|
67
|
+
purify.sanitize(wrapper, {
|
|
68
|
+
...mergeConfig(config),
|
|
69
|
+
IN_PLACE: true
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
normalizeLinks(wrapper);
|
|
73
|
+
while (wrapper.firstChild) element.appendChild(wrapper.firstChild);
|
|
74
|
+
return element;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function sanitizeToDOMFragment(
|
|
78
|
+
html,
|
|
79
|
+
config = {},
|
|
80
|
+
doc = document,
|
|
81
|
+
purify = resolveDOMPurify(doc)
|
|
82
|
+
) {
|
|
83
|
+
const fragment = purify.sanitize(String(html || ""), {
|
|
84
|
+
...mergeConfig(config),
|
|
85
|
+
RETURN_DOM_FRAGMENT: true
|
|
86
|
+
});
|
|
87
|
+
const clean = fragment?.ownerDocument === doc ? fragment : doc.importNode(fragment, true);
|
|
88
|
+
normalizeLinks(clean);
|
|
89
|
+
return clean || doc.createDocumentFragment();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function mergeConfig(config) {
|
|
93
|
+
return { ...DEFAULT_SANITIZE_CONFIG, ...config };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const SAFE_URL_SCHEMES = new Set(["http", "https", "mailto", "tel"]);
|
|
97
|
+
const URL_CONTROL_CHARS = new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]", "g");
|
|
98
|
+
|
|
99
|
+
export function isSafeUrl(url) {
|
|
100
|
+
const stripped = String(url == null ? "" : url).replace(URL_CONTROL_CHARS, "");
|
|
101
|
+
const scheme = (stripped.match(/^([a-z][a-z0-9+.\-]*):/i) || [])[1];
|
|
102
|
+
return !scheme || SAFE_URL_SCHEMES.has(scheme.toLowerCase());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function normalizeUrl(value) {
|
|
106
|
+
const raw = String(value == null ? "" : value).trim();
|
|
107
|
+
if (!raw || !isSafeUrl(raw)) return "";
|
|
108
|
+
if (/^(?:https?:|mailto:|tel:)/i.test(raw)) return raw;
|
|
109
|
+
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(raw)) return `mailto:${raw}`;
|
|
110
|
+
// Preserve fragment, query, root-relative, protocol-relative, and explicitly
|
|
111
|
+
// relative links as-is; only a bare hostname gets an https:// scheme.
|
|
112
|
+
if (/^(?:[#?]|\/|\.{1,2}\/)/.test(raw)) return raw;
|
|
113
|
+
return `https://${raw}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function resolveDOMPurify(doc) {
|
|
117
|
+
const supplied = globalThis.DOMPurify;
|
|
118
|
+
if (supplied?.sanitize) return supplied;
|
|
119
|
+
if (typeof supplied === "function") return supplied(doc.defaultView || globalThis);
|
|
120
|
+
|
|
121
|
+
throw new Error(
|
|
122
|
+
"RichClay requires DOMPurify. Load vendor/purify.min.js before richclay.js or provide globalThis.DOMPurify."
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function normalizeLinks(root) {
|
|
127
|
+
root.querySelectorAll?.("a[href]").forEach(link => {
|
|
128
|
+
const href = link.getAttribute("href") || "";
|
|
129
|
+
if (/^\s*javascript:/i.test(href)) {
|
|
130
|
+
link.removeAttribute("href");
|
|
131
|
+
}
|
|
132
|
+
if (link.getAttribute("target") === "_blank") {
|
|
133
|
+
const rel = new Set((link.getAttribute("rel") || "").split(/\s+/).filter(Boolean));
|
|
134
|
+
rel.add("noopener");
|
|
135
|
+
rel.add("noreferrer");
|
|
136
|
+
link.setAttribute("rel", Array.from(rel).join(" "));
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const INLINE_SANITIZE_EXTENSIONS = {
|
|
142
|
+
ADD_TAGS: ["img"],
|
|
143
|
+
ADD_ATTR: ["class", "id", "src", "alt", "width", "height"]
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Inline editors live inside real page markup, so paste/setHTML ingress keeps
|
|
147
|
+
// structural attributes and images that the card allowlist strips. Everything
|
|
148
|
+
// XSS-relevant (scripts, on* handlers, javascript: URLs) stays forbidden.
|
|
149
|
+
export function inlineSanitizeConfig(config = {}) {
|
|
150
|
+
return {
|
|
151
|
+
...config,
|
|
152
|
+
ADD_TAGS: [...new Set([...INLINE_SANITIZE_EXTENSIONS.ADD_TAGS, ...(config.ADD_TAGS || [])])],
|
|
153
|
+
ADD_ATTR: [...new Set([...INLINE_SANITIZE_EXTENSIONS.ADD_ATTR, ...(config.ADD_ATTR || [])])],
|
|
154
|
+
ALLOW_DATA_ATTR: config.ALLOW_DATA_ATTR ?? true
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const FLATTEN_SELECTOR =
|
|
159
|
+
"p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";
|
|
160
|
+
|
|
161
|
+
export function flattenFragmentToSingleLine(fragment) {
|
|
162
|
+
const doc = fragment.ownerDocument || document;
|
|
163
|
+
fragment.querySelectorAll?.("br").forEach(br => br.replaceWith(doc.createTextNode(" ")));
|
|
164
|
+
let block = fragment.querySelector?.(FLATTEN_SELECTOR);
|
|
165
|
+
while (block) {
|
|
166
|
+
const parent = block.parentNode;
|
|
167
|
+
parent.insertBefore(doc.createTextNode(" "), block);
|
|
168
|
+
while (block.firstChild) parent.insertBefore(block.firstChild, block);
|
|
169
|
+
parent.insertBefore(doc.createTextNode(" "), block);
|
|
170
|
+
block.remove();
|
|
171
|
+
block = fragment.querySelector(FLATTEN_SELECTOR);
|
|
172
|
+
}
|
|
173
|
+
collapseFragmentWhitespace(fragment, doc);
|
|
174
|
+
return fragment;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function collapseFragmentWhitespace(fragment, doc) {
|
|
178
|
+
fragment.normalize?.();
|
|
179
|
+
const walker = doc.createTreeWalker(fragment, 4 /* NodeFilter.SHOW_TEXT */);
|
|
180
|
+
const nodes = [];
|
|
181
|
+
while (walker.nextNode()) nodes.push(walker.currentNode);
|
|
182
|
+
nodes.forEach(node => {
|
|
183
|
+
node.nodeValue = node.nodeValue.replace(/\s+/g, " ");
|
|
184
|
+
});
|
|
185
|
+
const first = fragment.firstChild;
|
|
186
|
+
if (first?.nodeType === 3) first.nodeValue = first.nodeValue.replace(/^\s+/, "");
|
|
187
|
+
const last = fragment.lastChild;
|
|
188
|
+
if (last?.nodeType === 3) last.nodeValue = last.nodeValue.replace(/\s+$/, "");
|
|
189
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const STYLE_ID = "richclay-styles";
|
|
2
|
+
const styledDocs = new WeakSet();
|
|
3
|
+
let cssText = "";
|
|
4
|
+
|
|
5
|
+
export function setRichClayStyles(text) {
|
|
6
|
+
cssText = text || "";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function ensureStyles(doc = document) {
|
|
10
|
+
if (!doc || styledDocs.has(doc)) return;
|
|
11
|
+
if (doc.getElementById(STYLE_ID)) {
|
|
12
|
+
styledDocs.add(doc);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!cssText) return;
|
|
16
|
+
const style = doc.createElement("style");
|
|
17
|
+
style.id = STYLE_ID;
|
|
18
|
+
style.setAttribute("save-remove", "");
|
|
19
|
+
style.setAttribute("save-ignore", "");
|
|
20
|
+
style.textContent = cssText;
|
|
21
|
+
(doc.head || doc.documentElement).appendChild(style);
|
|
22
|
+
styledDocs.add(doc);
|
|
23
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Toolbar } from "./toolbar.js";
|
|
2
|
+
import { markChrome } from "./hyperclay.js";
|
|
3
|
+
|
|
4
|
+
export const GAP = 16;
|
|
5
|
+
export const GAP_LADDER = [16, 8, 0];
|
|
6
|
+
export const VIEWPORT_INSET = 8;
|
|
7
|
+
export const PLACEMENT_SLACK = 4;
|
|
8
|
+
|
|
9
|
+
// Pure placement ladder: above -> below -> side rail -> pinned to viewport top.
|
|
10
|
+
// All coords are viewport-relative (the shell is position: fixed). `current`
|
|
11
|
+
// gets PLACEMENT_SLACK of hysteresis so the mode doesn't flip-flop at exact
|
|
12
|
+
// boundaries.
|
|
13
|
+
export function placeToolbar({ anchor, bar, rail, viewport, current = null }) {
|
|
14
|
+
const slack = mode => (current === mode ? PLACEMENT_SLACK : 0);
|
|
15
|
+
|
|
16
|
+
if (
|
|
17
|
+
anchor.bottom <= 0 ||
|
|
18
|
+
anchor.top >= viewport.height ||
|
|
19
|
+
anchor.right <= 0 ||
|
|
20
|
+
anchor.left >= viewport.width
|
|
21
|
+
) {
|
|
22
|
+
return { mode: "hidden", x: 0, y: 0 };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const clampX = width =>
|
|
26
|
+
Math.max(VIEWPORT_INSET, Math.min(anchor.left, viewport.width - width - VIEWPORT_INSET));
|
|
27
|
+
|
|
28
|
+
const aboveY = anchor.top - GAP - bar.height;
|
|
29
|
+
if (aboveY >= VIEWPORT_INSET - slack("above")) {
|
|
30
|
+
return { mode: "above", x: clampX(bar.width), y: aboveY };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const belowY = anchor.bottom + GAP;
|
|
34
|
+
if (belowY + bar.height <= viewport.height - VIEWPORT_INSET + slack("below")) {
|
|
35
|
+
return { mode: "below", x: clampX(bar.width), y: belowY };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const rightSpace = viewport.width - anchor.right - VIEWPORT_INSET;
|
|
39
|
+
const leftSpace = anchor.left - VIEWPORT_INSET;
|
|
40
|
+
const sides =
|
|
41
|
+
rightSpace >= leftSpace
|
|
42
|
+
? [["rail-right", rightSpace], ["rail-left", leftSpace]]
|
|
43
|
+
: [["rail-left", leftSpace], ["rail-right", rightSpace]];
|
|
44
|
+
|
|
45
|
+
for (const [mode, space] of sides) {
|
|
46
|
+
for (const gap of GAP_LADDER) {
|
|
47
|
+
if (rail.width + gap > space + slack(mode)) continue;
|
|
48
|
+
const x =
|
|
49
|
+
mode === "rail-right"
|
|
50
|
+
? Math.min(anchor.right + gap, viewport.width - rail.width - VIEWPORT_INSET)
|
|
51
|
+
: Math.max(anchor.left - gap - rail.width, VIEWPORT_INSET);
|
|
52
|
+
const maxY = Math.min(anchor.bottom, viewport.height - VIEWPORT_INSET) - rail.height;
|
|
53
|
+
const y = Math.max(VIEWPORT_INSET, Math.min(Math.max(anchor.top, VIEWPORT_INSET), maxY));
|
|
54
|
+
return { mode, x, y, gap };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return { mode: "pinned", x: clampX(bar.width), y: VIEWPORT_INSET };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class FloatingToolbar {
|
|
62
|
+
constructor(editor, controls) {
|
|
63
|
+
this.editor = editor;
|
|
64
|
+
this.mode = null;
|
|
65
|
+
this.hidden = false;
|
|
66
|
+
this.frame = 0;
|
|
67
|
+
this.bar = { width: 0, height: 0 };
|
|
68
|
+
this.rail = { width: 0, height: 0 };
|
|
69
|
+
|
|
70
|
+
const doc = editor.element.ownerDocument;
|
|
71
|
+
this.doc = doc;
|
|
72
|
+
this.win = doc.defaultView || globalThis;
|
|
73
|
+
|
|
74
|
+
this.root = doc.createElement("div");
|
|
75
|
+
this.root.className = "richclay-float";
|
|
76
|
+
this.root.setAttribute("data-richclay-float", "");
|
|
77
|
+
this.root.setAttribute("save-remove", "");
|
|
78
|
+
markChrome(this.root);
|
|
79
|
+
doc.body.appendChild(this.root);
|
|
80
|
+
|
|
81
|
+
this.toolbar = new Toolbar(editor, controls, { toolbarContainer: this.root });
|
|
82
|
+
|
|
83
|
+
this.onScroll = () => this.schedule();
|
|
84
|
+
this.onResize = () => {
|
|
85
|
+
this.measure();
|
|
86
|
+
this.schedule();
|
|
87
|
+
};
|
|
88
|
+
doc.addEventListener("scroll", this.onScroll, { capture: true, passive: true });
|
|
89
|
+
this.win.addEventListener("resize", this.onResize, { passive: true });
|
|
90
|
+
this.win.visualViewport?.addEventListener("resize", this.onResize, { passive: true });
|
|
91
|
+
this.win.visualViewport?.addEventListener("scroll", this.onScroll, { passive: true });
|
|
92
|
+
this.resizeObserver =
|
|
93
|
+
typeof this.win.ResizeObserver === "function"
|
|
94
|
+
? new this.win.ResizeObserver(() => this.schedule())
|
|
95
|
+
: null;
|
|
96
|
+
this.resizeObserver?.observe(editor.element);
|
|
97
|
+
|
|
98
|
+
this.measure();
|
|
99
|
+
this.reposition();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Measure both orientations up front so the placement math can evaluate the
|
|
103
|
+
// rail without first switching to it.
|
|
104
|
+
measure() {
|
|
105
|
+
const wasRail = this.root.classList.contains("richclay-float-rail");
|
|
106
|
+
this.root.style.visibility = "hidden";
|
|
107
|
+
this.root.classList.remove("richclay-float-rail");
|
|
108
|
+
this.bar = { width: this.root.offsetWidth || 0, height: this.root.offsetHeight || 0 };
|
|
109
|
+
this.root.classList.add("richclay-float-rail");
|
|
110
|
+
this.rail = { width: this.root.offsetWidth || 0, height: this.root.offsetHeight || 0 };
|
|
111
|
+
this.root.classList.toggle("richclay-float-rail", wasRail);
|
|
112
|
+
this.root.style.visibility = "";
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
schedule() {
|
|
116
|
+
if (!this.win.requestAnimationFrame) {
|
|
117
|
+
this.reposition();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (this.frame) return;
|
|
121
|
+
this.frame = this.win.requestAnimationFrame(() => {
|
|
122
|
+
this.frame = 0;
|
|
123
|
+
this.reposition();
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
setVisible(visible) {
|
|
128
|
+
this.hidden = !visible;
|
|
129
|
+
this.reposition();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
reposition() {
|
|
133
|
+
if (this.hidden) {
|
|
134
|
+
this.root.style.display = "none";
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const anchor = this.editor.element.getBoundingClientRect();
|
|
138
|
+
const viewport = {
|
|
139
|
+
width: this.win.visualViewport?.width ?? this.win.innerWidth,
|
|
140
|
+
height: this.win.visualViewport?.height ?? this.win.innerHeight
|
|
141
|
+
};
|
|
142
|
+
const placement = placeToolbar({
|
|
143
|
+
anchor,
|
|
144
|
+
bar: this.bar,
|
|
145
|
+
rail: this.rail,
|
|
146
|
+
viewport,
|
|
147
|
+
current: this.mode
|
|
148
|
+
});
|
|
149
|
+
this.mode = placement.mode;
|
|
150
|
+
|
|
151
|
+
if (placement.mode === "hidden") {
|
|
152
|
+
this.root.style.display = "none";
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this.root.style.display = "";
|
|
156
|
+
this.root.classList.toggle(
|
|
157
|
+
"richclay-float-rail",
|
|
158
|
+
placement.mode === "rail-left" || placement.mode === "rail-right"
|
|
159
|
+
);
|
|
160
|
+
this.root.classList.toggle("richclay-float-pinned", placement.mode === "pinned");
|
|
161
|
+
this.root.style.transform = `translate(${Math.round(placement.x)}px, ${Math.round(placement.y)}px)`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
destroy() {
|
|
165
|
+
if (this.frame) this.win.cancelAnimationFrame?.(this.frame);
|
|
166
|
+
this.frame = 0;
|
|
167
|
+
this.doc.removeEventListener("scroll", this.onScroll, { capture: true });
|
|
168
|
+
this.win.removeEventListener("resize", this.onResize);
|
|
169
|
+
this.win.visualViewport?.removeEventListener("resize", this.onResize);
|
|
170
|
+
this.win.visualViewport?.removeEventListener("scroll", this.onScroll);
|
|
171
|
+
this.resizeObserver?.disconnect();
|
|
172
|
+
this.toolbar.destroy();
|
|
173
|
+
this.root.remove();
|
|
174
|
+
}
|
|
175
|
+
}
|