@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,400 @@
|
|
|
1
|
+
/*! quickcrop v1.1.0 | MIT-0 | https://github.com/panphora/quickcrop
|
|
2
|
+
*
|
|
3
|
+
* const result = await quickcrop(file, { aspect: 1 });
|
|
4
|
+
* // result: { blob, dataURL, width, height } on confirm, null on cancel
|
|
5
|
+
*
|
|
6
|
+
* Uses your modal system (themodal, or any adapter) or brings its own.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const CSS = `:root{--qc-surface:#f7f2ea;--qc-surface-hover:#efe7d8;--qc-border:#cdbfa6;--qc-text:#2b241b;--qc-text-hover:#463c2e;--qc-on-dark:#efe7d8;--qc-overlay:rgba(43,36,27,.6);--qc-dim:rgba(0,0,0,.55);--qc-radius:8px;--qc-crop-line:#fff;--qc-font:ui-sans-serif,system-ui,sans-serif;}.qc-css-probe{position:absolute;}.qc-backdrop{position:fixed;inset:0;background:var(--qc-overlay);display:grid;place-items:center;z-index:1000;animation:qc-fade .15s ease;}@keyframes qc-fade{from{opacity:0}}.qc-modal{background:var(--qc-surface);border:1px solid var(--qc-border);border-radius:var(--qc-radius);padding:16px;max-width:92vw;font-family:var(--qc-font);}.qc-bar{display:flex;justify-content:flex-end;gap:10px;margin-top:12px;}.qc-btn{font:inherit;font-family:var(--qc-font);font-size:.85rem;padding:.3rem .75rem;border:1px solid var(--qc-border);border-radius:6px;background:var(--qc-surface);color:var(--qc-text);cursor:pointer;}.qc-btn:hover{background:var(--qc-surface-hover);}.qc-btn-primary{background:var(--qc-text);border-color:var(--qc-text);color:var(--qc-on-dark);font-weight:600;}.qc-btn-primary:hover{background:var(--qc-text-hover);border-color:var(--qc-text-hover);}.qc-stage{position:relative;line-height:0;user-select:none;-webkit-user-select:none;touch-action:none;}.qc-stage img{display:block;max-width:100%;pointer-events:none;}.qc-dim{position:absolute;inset:0;background:var(--qc-dim);pointer-events:none;}.qc-box{position:absolute;cursor:move;outline:1px solid var(--qc-crop-line);background:linear-gradient(var(--qc-crop-line),var(--qc-crop-line)) 0 33.33%/100% 1px no-repeat,linear-gradient(var(--qc-crop-line),var(--qc-crop-line)) 0 66.66%/100% 1px no-repeat,linear-gradient(var(--qc-crop-line),var(--qc-crop-line)) 33.33% 0/1px 100% no-repeat,linear-gradient(var(--qc-crop-line),var(--qc-crop-line)) 66.66% 0/1px 100% no-repeat;background-blend-mode:overlay;}.qc-handle{position:absolute;box-sizing:border-box;width:28px;height:28px;border:7px solid transparent;background:var(--qc-crop-line);background-clip:padding-box;border-radius:9px;}.qc-nw{left:-14px;top:-14px;cursor:nwse-resize;}.qc-ne{right:-14px;top:-14px;cursor:nesw-resize;}.qc-sw{left:-14px;bottom:-14px;cursor:nesw-resize;}.qc-se{right:-14px;bottom:-14px;cursor:nwse-resize;}.qc-mount{line-height:0;}`;
|
|
10
|
+
|
|
11
|
+
const ENCODABLE = ['image/jpeg', 'image/png', 'image/webp'];
|
|
12
|
+
|
|
13
|
+
// iOS Safari silently produces a blank bitmap above ~16.7M canvas pixels
|
|
14
|
+
// (getContext still succeeds, toBlob still returns a blob), so cap the
|
|
15
|
+
// output area and downscale instead.
|
|
16
|
+
const MAX_AREA = 16777216;
|
|
17
|
+
|
|
18
|
+
let active = false;
|
|
19
|
+
|
|
20
|
+
function el(tag, cls = '', text = '') {
|
|
21
|
+
const n = document.createElement(tag);
|
|
22
|
+
if (cls) n.className = cls;
|
|
23
|
+
if (text) n.textContent = text;
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function escapeHtml(str) {
|
|
28
|
+
return String(str).replace(/[&<>"']/g, c => ({
|
|
29
|
+
'&': '&', '<': '<', '>': '>', '"': '"', "'": ''',
|
|
30
|
+
}[c]));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function ensureStyles() {
|
|
34
|
+
if (document.querySelector('style[data-quickcrop]')) return;
|
|
35
|
+
const probe = el('div', 'qc-css-probe');
|
|
36
|
+
probe.style.display = 'none';
|
|
37
|
+
document.body.append(probe);
|
|
38
|
+
const linked = getComputedStyle(probe).position === 'absolute';
|
|
39
|
+
probe.remove();
|
|
40
|
+
if (linked) return;
|
|
41
|
+
const style = document.createElement('style');
|
|
42
|
+
style.setAttribute('data-quickcrop', '');
|
|
43
|
+
style.setAttribute('save-remove', '');
|
|
44
|
+
style.setAttribute('snapshot-remove', '');
|
|
45
|
+
style.textContent = CSS;
|
|
46
|
+
document.head.append(style);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Modal adapters
|
|
51
|
+
//
|
|
52
|
+
// An adapter normalizes any modal system to:
|
|
53
|
+
// open({ content, confirmLabel, onConfirm, onCancel }) -> { close() }
|
|
54
|
+
// fit?() -> { width, height } optional: max content size the modal can host
|
|
55
|
+
// Dismissal affordances (Esc, backdrop, a close button) are the adapter's
|
|
56
|
+
// concern. onConfirm/onCancel must only fire from user interaction, never
|
|
57
|
+
// during open().
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
const builtinAdapter = {
|
|
61
|
+
open({ content, confirmLabel, onConfirm, onCancel }) {
|
|
62
|
+
ensureStyles();
|
|
63
|
+
const backdrop = el('div', 'qc-backdrop');
|
|
64
|
+
backdrop.setAttribute('save-remove', '');
|
|
65
|
+
backdrop.setAttribute('snapshot-remove', '');
|
|
66
|
+
const modal = el('div', 'qc-modal');
|
|
67
|
+
const bar = el('div', 'qc-bar');
|
|
68
|
+
const confirmBtn = el('button', 'qc-btn qc-btn-primary', confirmLabel);
|
|
69
|
+
confirmBtn.type = 'button';
|
|
70
|
+
bar.append(confirmBtn);
|
|
71
|
+
modal.append(content, bar);
|
|
72
|
+
backdrop.append(modal);
|
|
73
|
+
document.body.append(backdrop);
|
|
74
|
+
|
|
75
|
+
const onKey = e => { if (e.key === 'Escape') onCancel(); };
|
|
76
|
+
document.addEventListener('keydown', onKey);
|
|
77
|
+
confirmBtn.onclick = () => onConfirm();
|
|
78
|
+
backdrop.onclick = e => { if (e.target === backdrop) onCancel(); };
|
|
79
|
+
confirmBtn.focus();
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
close() {
|
|
83
|
+
document.removeEventListener('keydown', onKey);
|
|
84
|
+
backdrop.remove();
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
function isThemodal(m) {
|
|
91
|
+
return !!m && typeof m === 'object' &&
|
|
92
|
+
typeof m.open === 'function' &&
|
|
93
|
+
typeof m.close === 'function' &&
|
|
94
|
+
typeof m.onYes === 'function' &&
|
|
95
|
+
'html' in m;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const THEMODAL_CLOSE_X = '<svg viewBox="0 0 134 134" xmlns="http://www.w3.org/2000/svg">' +
|
|
99
|
+
'<path class="micromodal__close-bg" d="M132 132.5 1 1.5h131v131Z"/>' +
|
|
100
|
+
'<path d="M83 27l24 24M107 27L83 51" stroke="#fff" stroke-width="6"/></svg>';
|
|
101
|
+
|
|
102
|
+
function wrapThemodal(tm) {
|
|
103
|
+
// an already-open themodal dialog is a singleton collision: opening again
|
|
104
|
+
// would cross-fire that dialog's callbacks, so fall back to the built-in modal
|
|
105
|
+
const busy = () => tm.isShowing && !!document.querySelector('.micromodal-parent');
|
|
106
|
+
return {
|
|
107
|
+
// themodal's container is min(550px, 100vw - 2rem) with a 2px border and
|
|
108
|
+
// 40px/64px side padding; leave room for the button row below the stage
|
|
109
|
+
fit() {
|
|
110
|
+
if (busy()) return null;
|
|
111
|
+
const pad = window.innerWidth >= 640 ? 128 : 80;
|
|
112
|
+
return {
|
|
113
|
+
width: Math.max(120, Math.min(550, window.innerWidth - 32) - 4 - pad),
|
|
114
|
+
height: Math.max(120, window.innerHeight - 220),
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
open(opts) {
|
|
118
|
+
if (busy()) return builtinAdapter.open(opts);
|
|
119
|
+
const { content, confirmLabel, onConfirm, onCancel } = opts;
|
|
120
|
+
ensureStyles();
|
|
121
|
+
let done = false; // true once themodal is closing through its own paths
|
|
122
|
+
const finish = fn => {
|
|
123
|
+
if (done) return;
|
|
124
|
+
done = true;
|
|
125
|
+
document.removeEventListener('keydown', onKey, true);
|
|
126
|
+
fn();
|
|
127
|
+
};
|
|
128
|
+
// themodal's Esc goes straight through MicroModal without firing onNo,
|
|
129
|
+
// so intercept it in capture and run the cancel path ourselves
|
|
130
|
+
const onKey = e => {
|
|
131
|
+
if (e.key !== 'Escape') return;
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
onCancel();
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
tm.html = '<div class="qc-mount"></div>';
|
|
137
|
+
tm.yes = escapeHtml(confirmLabel);
|
|
138
|
+
tm.no = ''; // no cancel button; dismissal is the close X, backdrop, or Esc
|
|
139
|
+
tm.closeHtml = THEMODAL_CLOSE_X;
|
|
140
|
+
tm.disableFocus = true; // themodal would focus the cancel button; focus confirm instead
|
|
141
|
+
tm.onOpen(() => {
|
|
142
|
+
document.querySelector('.micromodal__content .qc-mount')?.append(content);
|
|
143
|
+
document.querySelector('.micromodal-parent .micromodal__yes')?.focus();
|
|
144
|
+
document.addEventListener('keydown', onKey, true);
|
|
145
|
+
});
|
|
146
|
+
tm.onYes(() => { finish(onConfirm); return true; });
|
|
147
|
+
tm.onNo(() => { finish(onCancel); });
|
|
148
|
+
tm.open();
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
close() {
|
|
152
|
+
if (done) return;
|
|
153
|
+
done = true;
|
|
154
|
+
document.removeEventListener('keydown', onKey, true);
|
|
155
|
+
tm.close();
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function resolveAdapter(modal) {
|
|
163
|
+
if (modal === 'builtin') return builtinAdapter;
|
|
164
|
+
if (modal && typeof modal === 'object') {
|
|
165
|
+
if (isThemodal(modal)) return wrapThemodal(modal);
|
|
166
|
+
if (typeof modal.open === 'function') return modal;
|
|
167
|
+
throw new TypeError('quickcrop: modal must be "auto", "builtin", a themodal instance, or an adapter with open()');
|
|
168
|
+
}
|
|
169
|
+
if (modal === 'auto') {
|
|
170
|
+
return isThemodal(window.themodal) ? wrapThemodal(window.themodal) : builtinAdapter;
|
|
171
|
+
}
|
|
172
|
+
throw new TypeError('quickcrop: modal must be "auto", "builtin", a themodal instance, or an adapter with open()');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
// quickcrop(file, options) -> Promise<{ blob, dataURL, width, height } | null>
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
function quickcrop(file, options = {}) {
|
|
180
|
+
const {
|
|
181
|
+
aspect = null,
|
|
182
|
+
type,
|
|
183
|
+
quality = 0.92,
|
|
184
|
+
maxWidth = null,
|
|
185
|
+
maxHeight = null,
|
|
186
|
+
minSize = 40,
|
|
187
|
+
labels = {},
|
|
188
|
+
modal = 'auto',
|
|
189
|
+
} = options;
|
|
190
|
+
const { confirm: confirmLabel = 'Crop' } = labels;
|
|
191
|
+
|
|
192
|
+
if (!(file instanceof Blob)) {
|
|
193
|
+
return Promise.reject(new TypeError('quickcrop: expected a File or Blob'));
|
|
194
|
+
}
|
|
195
|
+
if (active) {
|
|
196
|
+
return Promise.reject(new Error('quickcrop: already open'));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let adapter;
|
|
200
|
+
try {
|
|
201
|
+
adapter = resolveAdapter(modal);
|
|
202
|
+
} catch (err) {
|
|
203
|
+
return Promise.reject(err);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
active = true;
|
|
207
|
+
const outType = type || (ENCODABLE.includes(file.type) ? file.type : 'image/png');
|
|
208
|
+
const url = URL.createObjectURL(file);
|
|
209
|
+
const img = new Image();
|
|
210
|
+
|
|
211
|
+
return new Promise((resolve, reject) => {
|
|
212
|
+
img.onerror = () => {
|
|
213
|
+
URL.revokeObjectURL(url);
|
|
214
|
+
active = false;
|
|
215
|
+
reject(new Error('quickcrop: could not decode image'));
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
function mount() {
|
|
219
|
+
// Fit the image inside the host for display. The crop math works in
|
|
220
|
+
// these *display* pixels, then scales back up to the source resolution.
|
|
221
|
+
const fit = adapter.fit ? adapter.fit() : null;
|
|
222
|
+
const fitW = Math.max(1, Math.min(fit?.width ?? window.innerWidth * 0.86, img.naturalWidth));
|
|
223
|
+
const fitH = Math.max(1, fit?.height ?? window.innerHeight * 0.72);
|
|
224
|
+
const scale = Math.min(fitW / img.naturalWidth, fitH / img.naturalHeight, 1);
|
|
225
|
+
const dispW = Math.max(1, Math.round(img.naturalWidth * scale));
|
|
226
|
+
const dispH = Math.max(1, Math.round(img.naturalHeight * scale));
|
|
227
|
+
const min = Math.min(minSize, dispW, dispH);
|
|
228
|
+
|
|
229
|
+
ensureStyles();
|
|
230
|
+
|
|
231
|
+
const stage = el('div', 'qc-stage');
|
|
232
|
+
img.style.width = dispW + 'px';
|
|
233
|
+
img.style.height = dispH + 'px';
|
|
234
|
+
const dim = el('div', 'qc-dim');
|
|
235
|
+
const box = el('div', 'qc-box');
|
|
236
|
+
for (const c of ['nw', 'ne', 'sw', 'se']) box.appendChild(el('div', 'qc-handle qc-' + c));
|
|
237
|
+
stage.append(img, dim, box);
|
|
238
|
+
|
|
239
|
+
// initial crop box: locked aspect -> largest centered rect; free -> whole image
|
|
240
|
+
let w, h;
|
|
241
|
+
if (aspect) {
|
|
242
|
+
w = Math.min(dispW, dispH * aspect);
|
|
243
|
+
h = w / aspect;
|
|
244
|
+
if (h > dispH) { h = dispH; w = h * aspect; }
|
|
245
|
+
} else {
|
|
246
|
+
w = dispW;
|
|
247
|
+
h = dispH;
|
|
248
|
+
}
|
|
249
|
+
let x = (dispW - w) / 2;
|
|
250
|
+
let y = (dispH - h) / 2;
|
|
251
|
+
render();
|
|
252
|
+
|
|
253
|
+
function render() {
|
|
254
|
+
box.style.left = x + 'px';
|
|
255
|
+
box.style.top = y + 'px';
|
|
256
|
+
box.style.width = w + 'px';
|
|
257
|
+
box.style.height = h + 'px';
|
|
258
|
+
// dim the image outside the box: one donut polygon. The outer ring winds
|
|
259
|
+
// clockwise and the inner counter-clockwise, so the default nonzero fill
|
|
260
|
+
// rule punches the hole without the (less supported) evenodd keyword.
|
|
261
|
+
dim.style.clipPath = `polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 0, ` +
|
|
262
|
+
`${x}px ${y}px, ${x}px ${y + h}px, ${x + w}px ${y + h}px, ${x + w}px ${y}px, ${x}px ${y}px)`;
|
|
263
|
+
}
|
|
264
|
+
const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
265
|
+
|
|
266
|
+
// one pointer handler drives both moving and resizing
|
|
267
|
+
stage.addEventListener('pointerdown', e => {
|
|
268
|
+
const handle = e.target.closest('.qc-handle');
|
|
269
|
+
const onBox = e.target === box;
|
|
270
|
+
if (!handle && !onBox) return;
|
|
271
|
+
e.preventDefault();
|
|
272
|
+
stage.setPointerCapture(e.pointerId);
|
|
273
|
+
|
|
274
|
+
const start = { px: e.clientX, py: e.clientY, x, y, w, h };
|
|
275
|
+
const corner = handle && [...handle.classList].find(c => /^qc-(nw|ne|sw|se)$/.test(c))?.slice(3);
|
|
276
|
+
|
|
277
|
+
const move = ev => {
|
|
278
|
+
if (!corner) { // --- drag to move ---
|
|
279
|
+
x = clamp(start.x + (ev.clientX - start.px), 0, dispW - w);
|
|
280
|
+
y = clamp(start.y + (ev.clientY - start.py), 0, dispH - h);
|
|
281
|
+
} else { // --- drag to resize ---
|
|
282
|
+
// Anchor = the corner diagonally opposite the one being dragged; it
|
|
283
|
+
// stays pinned while the dragged corner follows the pointer.
|
|
284
|
+
const ax = corner.includes('w') ? start.x + start.w : start.x;
|
|
285
|
+
const ay = corner.includes('n') ? start.y + start.h : start.y;
|
|
286
|
+
const goingE = corner.includes('e'), goingS = corner.includes('s');
|
|
287
|
+
const rect = stage.getBoundingClientRect();
|
|
288
|
+
const dx = Math.abs(ev.clientX - (rect.left + ax));
|
|
289
|
+
const dy = Math.abs(ev.clientY - (rect.top + ay));
|
|
290
|
+
|
|
291
|
+
if (aspect) {
|
|
292
|
+
// room before an image edge, in width units, so the lock holds in both axes
|
|
293
|
+
const roomW = Math.min(goingE ? dispW - ax : ax, (goingS ? dispH - ay : ay) * aspect);
|
|
294
|
+
const minW = Math.min(Math.max(min, min * aspect), roomW);
|
|
295
|
+
w = clamp(Math.max(dx, dy * aspect), minW, roomW);
|
|
296
|
+
h = w / aspect;
|
|
297
|
+
} else {
|
|
298
|
+
w = clamp(dx, min, goingE ? dispW - ax : ax);
|
|
299
|
+
h = clamp(dy, min, goingS ? dispH - ay : ay);
|
|
300
|
+
}
|
|
301
|
+
x = goingE ? ax : ax - w;
|
|
302
|
+
y = goingS ? ay : ay - h;
|
|
303
|
+
}
|
|
304
|
+
render();
|
|
305
|
+
};
|
|
306
|
+
const up = () => {
|
|
307
|
+
stage.removeEventListener('pointermove', move);
|
|
308
|
+
stage.removeEventListener('pointerup', up);
|
|
309
|
+
stage.removeEventListener('pointercancel', up);
|
|
310
|
+
};
|
|
311
|
+
stage.addEventListener('pointermove', move);
|
|
312
|
+
stage.addEventListener('pointerup', up);
|
|
313
|
+
stage.addEventListener('pointercancel', up);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
function renderCrop() {
|
|
317
|
+
// display -> source scale, per axis: dispW/dispH round independently,
|
|
318
|
+
// so a shared scale would distort or overrun the source on one axis
|
|
319
|
+
const sx = img.naturalWidth / dispW;
|
|
320
|
+
const sy = img.naturalHeight / dispH;
|
|
321
|
+
const outW = Math.round(w * sx);
|
|
322
|
+
const outH = Math.round(h * sy);
|
|
323
|
+
let shrink = 1;
|
|
324
|
+
if (maxWidth && outW > maxWidth) shrink = maxWidth / outW;
|
|
325
|
+
if (maxHeight && outH * shrink > maxHeight) shrink = maxHeight / outH;
|
|
326
|
+
if (outW * shrink * outH * shrink > MAX_AREA) shrink = Math.sqrt(MAX_AREA / (outW * outH));
|
|
327
|
+
const canvas = document.createElement('canvas');
|
|
328
|
+
canvas.width = Math.max(1, Math.round(outW * shrink));
|
|
329
|
+
canvas.height = Math.max(1, Math.round(outH * shrink));
|
|
330
|
+
const ctx = canvas.getContext('2d');
|
|
331
|
+
if (!ctx) throw new Error('quickcrop: crop too large for a canvas');
|
|
332
|
+
if (outType === 'image/jpeg') { // jpeg has no alpha; avoid black fill
|
|
333
|
+
ctx.fillStyle = '#fff';
|
|
334
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
335
|
+
}
|
|
336
|
+
ctx.imageSmoothingQuality = 'high';
|
|
337
|
+
ctx.drawImage(
|
|
338
|
+
img, x * sx, y * sy, w * sx, h * sy, // source rect
|
|
339
|
+
0, 0, canvas.width, canvas.height // dest rect
|
|
340
|
+
);
|
|
341
|
+
return canvas;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
let settled = false;
|
|
345
|
+
const finishOnce = () => {
|
|
346
|
+
if (settled) return false;
|
|
347
|
+
settled = true;
|
|
348
|
+
host.close();
|
|
349
|
+
URL.revokeObjectURL(url);
|
|
350
|
+
active = false;
|
|
351
|
+
return true;
|
|
352
|
+
};
|
|
353
|
+
const host = adapter.open({
|
|
354
|
+
content: stage,
|
|
355
|
+
confirmLabel,
|
|
356
|
+
onConfirm() {
|
|
357
|
+
if (settled) return;
|
|
358
|
+
let canvas, dataURL;
|
|
359
|
+
try {
|
|
360
|
+
canvas = renderCrop();
|
|
361
|
+
dataURL = canvas.toDataURL(outType, quality);
|
|
362
|
+
} catch (err) {
|
|
363
|
+
if (finishOnce()) reject(err);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
if (!finishOnce()) return;
|
|
367
|
+
canvas.toBlob(blob => {
|
|
368
|
+
if (!blob) {
|
|
369
|
+
reject(new Error('quickcrop: image encoding failed'));
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
resolve({ blob, dataURL, width: canvas.width, height: canvas.height });
|
|
373
|
+
}, outType, quality);
|
|
374
|
+
},
|
|
375
|
+
onCancel() {
|
|
376
|
+
if (finishOnce()) resolve(null);
|
|
377
|
+
},
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// an adapter that throws during fit()/open() must not strand the cropper
|
|
382
|
+
img.onload = () => {
|
|
383
|
+
try {
|
|
384
|
+
mount();
|
|
385
|
+
} catch (err) {
|
|
386
|
+
URL.revokeObjectURL(url);
|
|
387
|
+
active = false;
|
|
388
|
+
reject(err);
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
img.src = url;
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// __QC_EXPORT_START__
|
|
396
|
+
if (!window.__hyperclayNoAutoExport) {
|
|
397
|
+
window.quickcrop = quickcrop;
|
|
398
|
+
}
|
|
399
|
+
// __QC_EXPORT_END__
|
|
400
|
+
export default quickcrop;
|