@kujoforall/paper-ui 0.0.0-stage → 0.2.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/CHANGELOG.md +93 -0
- package/LICENSE +21 -0
- package/README.md +295 -2
- package/dist/components/editor/block-text.d.ts +8 -0
- package/dist/components/editor/block-text.d.ts.map +1 -0
- package/dist/components/editor/block-text.js +248 -0
- package/dist/components/editor/block-text.js.map +1 -0
- package/dist/components/editor/blocks.d.ts +33 -0
- package/dist/components/editor/blocks.d.ts.map +1 -0
- package/dist/components/editor/blocks.js +191 -0
- package/dist/components/editor/blocks.js.map +1 -0
- package/dist/components/editor/document-editor.d.ts +27 -0
- package/dist/components/editor/document-editor.d.ts.map +1 -0
- package/dist/components/editor/document-editor.js +42 -0
- package/dist/components/editor/document-editor.js.map +1 -0
- package/dist/components/editor/document-view.d.ts +22 -0
- package/dist/components/editor/document-view.d.ts.map +1 -0
- package/dist/components/editor/document-view.js +110 -0
- package/dist/components/editor/document-view.js.map +1 -0
- package/dist/components/editor/editor-state.d.ts +107 -0
- package/dist/components/editor/editor-state.d.ts.map +1 -0
- package/dist/components/editor/editor-state.js +217 -0
- package/dist/components/editor/editor-state.js.map +1 -0
- package/dist/components/editor/extensions/kit-blocks.d.ts +34 -0
- package/dist/components/editor/extensions/kit-blocks.d.ts.map +1 -0
- package/dist/components/editor/extensions/kit-blocks.js +201 -0
- package/dist/components/editor/extensions/kit-blocks.js.map +1 -0
- package/dist/components/editor/extensions/spoiler.d.ts +8 -0
- package/dist/components/editor/extensions/spoiler.d.ts.map +1 -0
- package/dist/components/editor/extensions/spoiler.js +36 -0
- package/dist/components/editor/extensions/spoiler.js.map +1 -0
- package/dist/components/editor/index.d.ts +10 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +10 -0
- package/dist/components/editor/index.js.map +1 -0
- package/dist/components/editor/kinds.d.ts +99 -0
- package/dist/components/editor/kinds.d.ts.map +1 -0
- package/dist/components/editor/kinds.js +74 -0
- package/dist/components/editor/kinds.js.map +1 -0
- package/dist/components/editor/look.d.ts +18 -0
- package/dist/components/editor/look.d.ts.map +1 -0
- package/dist/components/editor/look.js +21 -0
- package/dist/components/editor/look.js.map +1 -0
- package/dist/components/sketch/rough.d.ts +38 -0
- package/dist/components/sketch/rough.d.ts.map +1 -0
- package/dist/components/sketch/rough.js +57 -0
- package/dist/components/sketch/rough.js.map +1 -0
- package/dist/components/three/model-viewer.d.ts +36 -0
- package/dist/components/three/model-viewer.d.ts.map +1 -0
- package/dist/components/three/model-viewer.js +338 -0
- package/dist/components/three/model-viewer.js.map +1 -0
- package/dist/components/ui/accent-picker.d.ts +2 -0
- package/dist/components/ui/accent-picker.d.ts.map +1 -0
- package/dist/components/ui/accent-picker.js +44 -0
- package/dist/components/ui/accent-picker.js.map +1 -0
- package/dist/components/ui/address-field.d.ts +10 -0
- package/dist/components/ui/address-field.d.ts.map +1 -0
- package/dist/components/ui/address-field.js +24 -0
- package/dist/components/ui/address-field.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +29 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +72 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/animated-height.d.ts +6 -0
- package/dist/components/ui/animated-height.d.ts.map +1 -0
- package/dist/components/ui/animated-height.js +26 -0
- package/dist/components/ui/animated-height.js.map +1 -0
- package/dist/components/ui/app-shell.d.ts +26 -0
- package/dist/components/ui/app-shell.d.ts.map +1 -0
- package/dist/components/ui/app-shell.js +71 -0
- package/dist/components/ui/app-shell.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +30 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +50 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +19 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +62 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/banner.d.ts +33 -0
- package/dist/components/ui/banner.d.ts.map +1 -0
- package/dist/components/ui/banner.js +21 -0
- package/dist/components/ui/banner.js.map +1 -0
- package/dist/components/ui/breadcrumbs.d.ts +10 -0
- package/dist/components/ui/breadcrumbs.d.ts.map +1 -0
- package/dist/components/ui/breadcrumbs.js +9 -0
- package/dist/components/ui/breadcrumbs.js.map +1 -0
- package/dist/components/ui/button.d.ts +15 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +110 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/calendar.d.ts +5 -0
- package/dist/components/ui/calendar.d.ts.map +1 -0
- package/dist/components/ui/calendar.js +65 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/callout.d.ts +32 -0
- package/dist/components/ui/callout.d.ts.map +1 -0
- package/dist/components/ui/callout.js +40 -0
- package/dist/components/ui/callout.js.map +1 -0
- package/dist/components/ui/card.d.ts +18 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +28 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +11 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +30 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/choice-label.d.ts +13 -0
- package/dist/components/ui/choice-label.d.ts.map +1 -0
- package/dist/components/ui/choice-label.js +17 -0
- package/dist/components/ui/choice-label.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +10 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +21 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/collection-layout.d.ts +24 -0
- package/dist/components/ui/collection-layout.d.ts.map +1 -0
- package/dist/components/ui/collection-layout.js +16 -0
- package/dist/components/ui/collection-layout.js.map +1 -0
- package/dist/components/ui/combobox.d.ts +10 -0
- package/dist/components/ui/combobox.d.ts.map +1 -0
- package/dist/components/ui/combobox.js +93 -0
- package/dist/components/ui/combobox.js.map +1 -0
- package/dist/components/ui/command-menu.d.ts +18 -0
- package/dist/components/ui/command-menu.d.ts.map +1 -0
- package/dist/components/ui/command-menu.js +49 -0
- package/dist/components/ui/command-menu.js.map +1 -0
- package/dist/components/ui/context-menu.d.ts +19 -0
- package/dist/components/ui/context-menu.d.ts.map +1 -0
- package/dist/components/ui/context-menu.js +42 -0
- package/dist/components/ui/context-menu.js.map +1 -0
- package/dist/components/ui/copy-button.d.ts +11 -0
- package/dist/components/ui/copy-button.d.ts.map +1 -0
- package/dist/components/ui/copy-button.js +48 -0
- package/dist/components/ui/copy-button.js.map +1 -0
- package/dist/components/ui/database/calendar-view.d.ts +10 -0
- package/dist/components/ui/database/calendar-view.d.ts.map +1 -0
- package/dist/components/ui/database/calendar-view.js +65 -0
- package/dist/components/ui/database/calendar-view.js.map +1 -0
- package/dist/components/ui/database/card-views.d.ts +22 -0
- package/dist/components/ui/database/card-views.d.ts.map +1 -0
- package/dist/components/ui/database/card-views.js +74 -0
- package/dist/components/ui/database/card-views.js.map +1 -0
- package/dist/components/ui/database/cells.d.ts +20 -0
- package/dist/components/ui/database/cells.d.ts.map +1 -0
- package/dist/components/ui/database/cells.js +132 -0
- package/dist/components/ui/database/cells.js.map +1 -0
- package/dist/components/ui/database/database.d.ts +19 -0
- package/dist/components/ui/database/database.d.ts.map +1 -0
- package/dist/components/ui/database/database.js +102 -0
- package/dist/components/ui/database/database.js.map +1 -0
- package/dist/components/ui/database/icons.d.ts +5 -0
- package/dist/components/ui/database/icons.d.ts.map +1 -0
- package/dist/components/ui/database/icons.js +13 -0
- package/dist/components/ui/database/icons.js.map +1 -0
- package/dist/components/ui/database/table-view.d.ts +11 -0
- package/dist/components/ui/database/table-view.d.ts.map +1 -0
- package/dist/components/ui/database/table-view.js +157 -0
- package/dist/components/ui/database/table-view.js.map +1 -0
- package/dist/components/ui/date-picker.d.ts +40 -0
- package/dist/components/ui/date-picker.d.ts.map +1 -0
- package/dist/components/ui/date-picker.js +64 -0
- package/dist/components/ui/date-picker.js.map +1 -0
- package/dist/components/ui/date-time-picker.d.ts +21 -0
- package/dist/components/ui/date-time-picker.d.ts.map +1 -0
- package/dist/components/ui/date-time-picker.js +34 -0
- package/dist/components/ui/date-time-picker.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +21 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +63 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/document-layout.d.ts +15 -0
- package/dist/components/ui/document-layout.d.ts.map +1 -0
- package/dist/components/ui/document-layout.js +15 -0
- package/dist/components/ui/document-layout.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +24 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +65 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/editable-text.d.ts +24 -0
- package/dist/components/ui/editable-text.d.ts.map +1 -0
- package/dist/components/ui/editable-text.js +85 -0
- package/dist/components/ui/editable-text.js.map +1 -0
- package/dist/components/ui/empty-state.d.ts +11 -0
- package/dist/components/ui/empty-state.d.ts.map +1 -0
- package/dist/components/ui/empty-state.js +9 -0
- package/dist/components/ui/empty-state.js.map +1 -0
- package/dist/components/ui/error-state.d.ts +20 -0
- package/dist/components/ui/error-state.d.ts.map +1 -0
- package/dist/components/ui/error-state.js +17 -0
- package/dist/components/ui/error-state.js.map +1 -0
- package/dist/components/ui/field-button.d.ts +15 -0
- package/dist/components/ui/field-button.d.ts.map +1 -0
- package/dist/components/ui/field-button.js +18 -0
- package/dist/components/ui/field-button.js.map +1 -0
- package/dist/components/ui/file-preview.d.ts +5 -0
- package/dist/components/ui/file-preview.d.ts.map +1 -0
- package/dist/components/ui/file-preview.js +66 -0
- package/dist/components/ui/file-preview.js.map +1 -0
- package/dist/components/ui/file-uploader.d.ts +39 -0
- package/dist/components/ui/file-uploader.d.ts.map +1 -0
- package/dist/components/ui/file-uploader.js +111 -0
- package/dist/components/ui/file-uploader.js.map +1 -0
- package/dist/components/ui/filter-builder.d.ts +18 -0
- package/dist/components/ui/filter-builder.d.ts.map +1 -0
- package/dist/components/ui/filter-builder.js +98 -0
- package/dist/components/ui/filter-builder.js.map +1 -0
- package/dist/components/ui/focus-shell.d.ts +14 -0
- package/dist/components/ui/focus-shell.d.ts.map +1 -0
- package/dist/components/ui/focus-shell.js +13 -0
- package/dist/components/ui/focus-shell.js.map +1 -0
- package/dist/components/ui/handle-row.d.ts +25 -0
- package/dist/components/ui/handle-row.d.ts.map +1 -0
- package/dist/components/ui/handle-row.js +110 -0
- package/dist/components/ui/handle-row.js.map +1 -0
- package/dist/components/ui/header-bar.d.ts +5 -0
- package/dist/components/ui/header-bar.d.ts.map +1 -0
- package/dist/components/ui/header-bar.js +10 -0
- package/dist/components/ui/header-bar.js.map +1 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/hover-card.d.ts.map +1 -0
- package/dist/components/ui/hover-card.js +13 -0
- package/dist/components/ui/hover-card.js.map +1 -0
- package/dist/components/ui/image-block.d.ts +31 -0
- package/dist/components/ui/image-block.d.ts.map +1 -0
- package/dist/components/ui/image-block.js +103 -0
- package/dist/components/ui/image-block.js.map +1 -0
- package/dist/components/ui/image-card.d.ts +17 -0
- package/dist/components/ui/image-card.d.ts.map +1 -0
- package/dist/components/ui/image-card.js +39 -0
- package/dist/components/ui/image-card.js.map +1 -0
- package/dist/components/ui/image-framer.d.ts +24 -0
- package/dist/components/ui/image-framer.d.ts.map +1 -0
- package/dist/components/ui/image-framer.js +89 -0
- package/dist/components/ui/image-framer.js.map +1 -0
- package/dist/components/ui/image-viewer.d.ts +31 -0
- package/dist/components/ui/image-viewer.d.ts.map +1 -0
- package/dist/components/ui/image-viewer.js +114 -0
- package/dist/components/ui/image-viewer.js.map +1 -0
- package/dist/components/ui/image.d.ts +33 -0
- package/dist/components/ui/image.d.ts.map +1 -0
- package/dist/components/ui/image.js +61 -0
- package/dist/components/ui/image.js.map +1 -0
- package/dist/components/ui/index.d.ts +92 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +92 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/components/ui/input.d.ts +75 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +245 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/link-block.d.ts +13 -0
- package/dist/components/ui/link-block.d.ts.map +1 -0
- package/dist/components/ui/link-block.js +21 -0
- package/dist/components/ui/link-block.js.map +1 -0
- package/dist/components/ui/list-detail.d.ts +23 -0
- package/dist/components/ui/list-detail.d.ts.map +1 -0
- package/dist/components/ui/list-detail.js +33 -0
- package/dist/components/ui/list-detail.js.map +1 -0
- package/dist/components/ui/listbox.d.ts +7 -0
- package/dist/components/ui/listbox.d.ts.map +1 -0
- package/dist/components/ui/listbox.js +29 -0
- package/dist/components/ui/listbox.js.map +1 -0
- package/dist/components/ui/mac-card.d.ts +15 -0
- package/dist/components/ui/mac-card.d.ts.map +1 -0
- package/dist/components/ui/mac-card.js +9 -0
- package/dist/components/ui/mac-card.js.map +1 -0
- package/dist/components/ui/month-picker.d.ts +13 -0
- package/dist/components/ui/month-picker.d.ts.map +1 -0
- package/dist/components/ui/month-picker.js +53 -0
- package/dist/components/ui/month-picker.js.map +1 -0
- package/dist/components/ui/multi-select.d.ts +22 -0
- package/dist/components/ui/multi-select.d.ts.map +1 -0
- package/dist/components/ui/multi-select.js +88 -0
- package/dist/components/ui/multi-select.js.map +1 -0
- package/dist/components/ui/nav-tree.d.ts +16 -0
- package/dist/components/ui/nav-tree.d.ts.map +1 -0
- package/dist/components/ui/nav-tree.js +41 -0
- package/dist/components/ui/nav-tree.js.map +1 -0
- package/dist/components/ui/page.d.ts +23 -0
- package/dist/components/ui/page.d.ts.map +1 -0
- package/dist/components/ui/page.js +28 -0
- package/dist/components/ui/page.js.map +1 -0
- package/dist/components/ui/pagination.d.ts +26 -0
- package/dist/components/ui/pagination.d.ts.map +1 -0
- package/dist/components/ui/pagination.js +54 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/picker-panel.d.ts +13 -0
- package/dist/components/ui/picker-panel.d.ts.map +1 -0
- package/dist/components/ui/picker-panel.js +19 -0
- package/dist/components/ui/picker-panel.js.map +1 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +18 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/progress.d.ts +19 -0
- package/dist/components/ui/progress.d.ts.map +1 -0
- package/dist/components/ui/progress.js +22 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/property.d.ts +11 -0
- package/dist/components/ui/property.d.ts.map +1 -0
- package/dist/components/ui/property.js +18 -0
- package/dist/components/ui/property.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +8 -0
- package/dist/components/ui/radio-group.d.ts.map +1 -0
- package/dist/components/ui/radio-group.js +18 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/rating.d.ts +14 -0
- package/dist/components/ui/rating.d.ts.map +1 -0
- package/dist/components/ui/rating.js +61 -0
- package/dist/components/ui/rating.js.map +1 -0
- package/dist/components/ui/save-status.d.ts +8 -0
- package/dist/components/ui/save-status.d.ts.map +1 -0
- package/dist/components/ui/save-status.js +31 -0
- package/dist/components/ui/save-status.js.map +1 -0
- package/dist/components/ui/segmented.d.ts +21 -0
- package/dist/components/ui/segmented.d.ts.map +1 -0
- package/dist/components/ui/segmented.js +12 -0
- package/dist/components/ui/segmented.js.map +1 -0
- package/dist/components/ui/select-menu.d.ts +12 -0
- package/dist/components/ui/select-menu.d.ts.map +1 -0
- package/dist/components/ui/select-menu.js +10 -0
- package/dist/components/ui/select-menu.js.map +1 -0
- package/dist/components/ui/select.d.ts +16 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +45 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/selection-bar.d.ts +12 -0
- package/dist/components/ui/selection-bar.d.ts.map +1 -0
- package/dist/components/ui/selection-bar.js +15 -0
- package/dist/components/ui/selection-bar.js.map +1 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +12 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/settings-layout.d.ts +34 -0
- package/dist/components/ui/settings-layout.d.ts.map +1 -0
- package/dist/components/ui/settings-layout.js +16 -0
- package/dist/components/ui/settings-layout.js.map +1 -0
- package/dist/components/ui/share-link.d.ts +14 -0
- package/dist/components/ui/share-link.d.ts.map +1 -0
- package/dist/components/ui/share-link.js +16 -0
- package/dist/components/ui/share-link.js.map +1 -0
- package/dist/components/ui/sheet.d.ts +21 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +53 -0
- package/dist/components/ui/sheet.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +82 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +258 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +8 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +15 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +12 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +14 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/spotlight.d.ts +23 -0
- package/dist/components/ui/spotlight.d.ts.map +1 -0
- package/dist/components/ui/spotlight.js +110 -0
- package/dist/components/ui/spotlight.js.map +1 -0
- package/dist/components/ui/stat-tile.d.ts +8 -0
- package/dist/components/ui/stat-tile.d.ts.map +1 -0
- package/dist/components/ui/stat-tile.js +9 -0
- package/dist/components/ui/stat-tile.js.map +1 -0
- package/dist/components/ui/step-dialog.d.ts +20 -0
- package/dist/components/ui/step-dialog.d.ts.map +1 -0
- package/dist/components/ui/step-dialog.js +36 -0
- package/dist/components/ui/step-dialog.js.map +1 -0
- package/dist/components/ui/steps-layout.d.ts +20 -0
- package/dist/components/ui/steps-layout.d.ts.map +1 -0
- package/dist/components/ui/steps-layout.js +26 -0
- package/dist/components/ui/steps-layout.js.map +1 -0
- package/dist/components/ui/switch.d.ts +8 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +21 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/table.d.ts +16 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +76 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +19 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/theme-toggle.d.ts +16 -0
- package/dist/components/ui/theme-toggle.d.ts.map +1 -0
- package/dist/components/ui/theme-toggle.js +65 -0
- package/dist/components/ui/theme-toggle.js.map +1 -0
- package/dist/components/ui/time-list.d.ts +16 -0
- package/dist/components/ui/time-list.d.ts.map +1 -0
- package/dist/components/ui/time-list.js +49 -0
- package/dist/components/ui/time-list.js.map +1 -0
- package/dist/components/ui/time-picker.d.ts +47 -0
- package/dist/components/ui/time-picker.d.ts.map +1 -0
- package/dist/components/ui/time-picker.js +141 -0
- package/dist/components/ui/time-picker.js.map +1 -0
- package/dist/components/ui/toast.d.ts +18 -0
- package/dist/components/ui/toast.d.ts.map +1 -0
- package/dist/components/ui/toast.js +77 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/toggle.d.ts +15 -0
- package/dist/components/ui/toggle.d.ts.map +1 -0
- package/dist/components/ui/toggle.js +55 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +15 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +32 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/components/ui/top-bar.d.ts +25 -0
- package/dist/components/ui/top-bar.d.ts.map +1 -0
- package/dist/components/ui/top-bar.js +23 -0
- package/dist/components/ui/top-bar.js.map +1 -0
- package/dist/components/ui/typography.d.ts +40 -0
- package/dist/components/ui/typography.d.ts.map +1 -0
- package/dist/components/ui/typography.js +98 -0
- package/dist/components/ui/typography.js.map +1 -0
- package/dist/components/ui/video-block.d.ts +14 -0
- package/dist/components/ui/video-block.d.ts.map +1 -0
- package/dist/components/ui/video-block.js +22 -0
- package/dist/components/ui/video-block.js.map +1 -0
- package/dist/hooks/use-dismiss.d.ts +5 -0
- package/dist/hooks/use-dismiss.d.ts.map +1 -0
- package/dist/hooks/use-dismiss.js +23 -0
- package/dist/hooks/use-dismiss.js.map +1 -0
- package/dist/hooks/use-escape-first.d.ts +3 -0
- package/dist/hooks/use-escape-first.d.ts.map +1 -0
- package/dist/hooks/use-escape-first.js +27 -0
- package/dist/hooks/use-escape-first.js.map +1 -0
- package/dist/hooks/use-media-query.d.ts +5 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +16 -0
- package/dist/hooks/use-media-query.js.map +1 -0
- package/dist/hooks/use-save-queue.d.ts +13 -0
- package/dist/hooks/use-save-queue.d.ts.map +1 -0
- package/dist/hooks/use-save-queue.js +57 -0
- package/dist/hooks/use-save-queue.js.map +1 -0
- package/dist/hooks/use-selection.d.ts +10 -0
- package/dist/hooks/use-selection.d.ts.map +1 -0
- package/dist/hooks/use-selection.js +52 -0
- package/dist/hooks/use-selection.js.map +1 -0
- package/dist/hooks/use-shared-transition.d.ts +3 -0
- package/dist/hooks/use-shared-transition.d.ts.map +1 -0
- package/dist/hooks/use-shared-transition.js +38 -0
- package/dist/hooks/use-shared-transition.js.map +1 -0
- package/dist/hooks/use-upload-queue.d.ts +22 -0
- package/dist/hooks/use-upload-queue.d.ts.map +1 -0
- package/dist/hooks/use-upload-queue.js +78 -0
- package/dist/hooks/use-upload-queue.js.map +1 -0
- package/dist/lib/accent.d.ts +5 -0
- package/dist/lib/accent.d.ts.map +1 -0
- package/dist/lib/accent.js +10 -0
- package/dist/lib/accent.js.map +1 -0
- package/dist/lib/bento.d.ts +17 -0
- package/dist/lib/bento.d.ts.map +1 -0
- package/dist/lib/bento.js +92 -0
- package/dist/lib/bento.js.map +1 -0
- package/dist/lib/database.d.ts +92 -0
- package/dist/lib/database.d.ts.map +1 -0
- package/dist/lib/database.js +272 -0
- package/dist/lib/database.js.map +1 -0
- package/dist/lib/dates.d.ts +30 -0
- package/dist/lib/dates.d.ts.map +1 -0
- package/dist/lib/dates.js +61 -0
- package/dist/lib/dates.js.map +1 -0
- package/dist/lib/document.d.ts +79 -0
- package/dist/lib/document.d.ts.map +1 -0
- package/dist/lib/document.js +11 -0
- package/dist/lib/document.js.map +1 -0
- package/dist/lib/embed.d.ts +14 -0
- package/dist/lib/embed.d.ts.map +1 -0
- package/dist/lib/embed.js +63 -0
- package/dist/lib/embed.js.map +1 -0
- package/dist/lib/files.d.ts +23 -0
- package/dist/lib/files.d.ts.map +1 -0
- package/dist/lib/files.js +69 -0
- package/dist/lib/files.js.map +1 -0
- package/dist/lib/justified.d.ts +50 -0
- package/dist/lib/justified.d.ts.map +1 -0
- package/dist/lib/justified.js +78 -0
- package/dist/lib/justified.js.map +1 -0
- package/dist/lib/keys.d.ts +18 -0
- package/dist/lib/keys.d.ts.map +1 -0
- package/dist/lib/keys.js +66 -0
- package/dist/lib/keys.js.map +1 -0
- package/dist/lib/number.d.ts +4 -0
- package/dist/lib/number.d.ts.map +1 -0
- package/dist/lib/number.js +33 -0
- package/dist/lib/number.js.map +1 -0
- package/dist/lib/pointer.d.ts +2 -0
- package/dist/lib/pointer.d.ts.map +1 -0
- package/dist/lib/pointer.js +4 -0
- package/dist/lib/pointer.js.map +1 -0
- package/dist/lib/prepare-image.d.ts +43 -0
- package/dist/lib/prepare-image.d.ts.map +1 -0
- package/dist/lib/prepare-image.js +105 -0
- package/dist/lib/prepare-image.js.map +1 -0
- package/dist/lib/rich-text-dom.d.ts +16 -0
- package/dist/lib/rich-text-dom.d.ts.map +1 -0
- package/dist/lib/rich-text-dom.js +145 -0
- package/dist/lib/rich-text-dom.js.map +1 -0
- package/dist/lib/rich-text.d.ts +15 -0
- package/dist/lib/rich-text.d.ts.map +1 -0
- package/dist/lib/rich-text.js +35 -0
- package/dist/lib/rich-text.js.map +1 -0
- package/dist/lib/spotlight.d.ts +22 -0
- package/dist/lib/spotlight.d.ts.map +1 -0
- package/dist/lib/spotlight.js +66 -0
- package/dist/lib/spotlight.js.map +1 -0
- package/dist/lib/theme.d.ts +6 -0
- package/dist/lib/theme.d.ts.map +1 -0
- package/dist/lib/theme.js +15 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/lib/time.d.ts +19 -0
- package/dist/lib/time.d.ts.map +1 -0
- package/dist/lib/time.js +91 -0
- package/dist/lib/time.js.map +1 -0
- package/dist/lib/tree.d.ts +17 -0
- package/dist/lib/tree.d.ts.map +1 -0
- package/dist/lib/tree.js +35 -0
- package/dist/lib/tree.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +24 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/styles/notion.css +817 -0
- package/package.json +129 -5
- package/src/components/editor/block-text.tsx +271 -0
- package/src/components/editor/blocks.tsx +373 -0
- package/src/components/editor/document-editor.tsx +106 -0
- package/src/components/editor/document-view.tsx +205 -0
- package/src/components/editor/editor-state.tsx +298 -0
- package/src/components/editor/extensions/kit-blocks.tsx +452 -0
- package/src/components/editor/extensions/spoiler.tsx +81 -0
- package/src/components/editor/index.ts +10 -0
- package/src/components/editor/kinds.ts +158 -0
- package/src/components/editor/look.tsx +36 -0
- package/src/components/sketch/rough.tsx +90 -0
- package/src/components/three/model-viewer.tsx +514 -0
- package/src/components/ui/accent-picker.tsx +72 -0
- package/src/components/ui/address-field.tsx +57 -0
- package/src/components/ui/alert-dialog.tsx +136 -0
- package/src/components/ui/animated-height.tsx +34 -0
- package/src/components/ui/app-shell.tsx +140 -0
- package/src/components/ui/avatar.tsx +106 -0
- package/src/components/ui/badge.tsx +81 -0
- package/src/components/ui/banner.tsx +53 -0
- package/src/components/ui/breadcrumbs.tsx +25 -0
- package/src/components/ui/button.tsx +147 -0
- package/src/components/ui/calendar.tsx +101 -0
- package/src/components/ui/callout.tsx +61 -0
- package/src/components/ui/card.tsx +59 -0
- package/src/components/ui/checkbox.tsx +66 -0
- package/src/components/ui/choice-label.tsx +43 -0
- package/src/components/ui/collapsible.tsx +58 -0
- package/src/components/ui/collection-layout.tsx +69 -0
- package/src/components/ui/combobox.tsx +155 -0
- package/src/components/ui/command-menu.tsx +102 -0
- package/src/components/ui/context-menu.tsx +89 -0
- package/src/components/ui/copy-button.tsx +80 -0
- package/src/components/ui/database/calendar-view.tsx +180 -0
- package/src/components/ui/database/card-views.tsx +221 -0
- package/src/components/ui/database/cells.tsx +237 -0
- package/src/components/ui/database/database.tsx +279 -0
- package/src/components/ui/database/icons.ts +15 -0
- package/src/components/ui/database/table-view.tsx +311 -0
- package/src/components/ui/date-picker.tsx +208 -0
- package/src/components/ui/date-time-picker.tsx +123 -0
- package/src/components/ui/dialog.tsx +151 -0
- package/src/components/ui/document-layout.tsx +52 -0
- package/src/components/ui/dropdown-menu.tsx +185 -0
- package/src/components/ui/editable-text.tsx +142 -0
- package/src/components/ui/empty-state.tsx +35 -0
- package/src/components/ui/error-state.tsx +67 -0
- package/src/components/ui/field-button.tsx +70 -0
- package/src/components/ui/file-preview.tsx +80 -0
- package/src/components/ui/file-uploader.tsx +375 -0
- package/src/components/ui/filter-builder.tsx +304 -0
- package/src/components/ui/focus-shell.tsx +48 -0
- package/src/components/ui/handle-row.tsx +252 -0
- package/src/components/ui/header-bar.tsx +15 -0
- package/src/components/ui/hover-card.tsx +30 -0
- package/src/components/ui/image-block.tsx +238 -0
- package/src/components/ui/image-card.tsx +95 -0
- package/src/components/ui/image-framer.tsx +160 -0
- package/src/components/ui/image-viewer.tsx +230 -0
- package/src/components/ui/image.tsx +200 -0
- package/src/components/ui/index.ts +178 -0
- package/src/components/ui/input.tsx +471 -0
- package/src/components/ui/link-block.tsx +85 -0
- package/src/components/ui/list-detail.tsx +115 -0
- package/src/components/ui/listbox.ts +26 -0
- package/src/components/ui/mac-card.tsx +46 -0
- package/src/components/ui/month-picker.tsx +119 -0
- package/src/components/ui/multi-select.tsx +221 -0
- package/src/components/ui/nav-tree.tsx +92 -0
- package/src/components/ui/page.tsx +73 -0
- package/src/components/ui/pagination.tsx +143 -0
- package/src/components/ui/picker-panel.tsx +69 -0
- package/src/components/ui/popover.tsx +42 -0
- package/src/components/ui/progress.tsx +76 -0
- package/src/components/ui/property.tsx +33 -0
- package/src/components/ui/radio-group.tsx +61 -0
- package/src/components/ui/rating.tsx +122 -0
- package/src/components/ui/save-status.tsx +53 -0
- package/src/components/ui/segmented.tsx +74 -0
- package/src/components/ui/select-menu.tsx +54 -0
- package/src/components/ui/select.tsx +147 -0
- package/src/components/ui/selection-bar.tsx +50 -0
- package/src/components/ui/separator.tsx +30 -0
- package/src/components/ui/settings-layout.tsx +117 -0
- package/src/components/ui/share-link.tsx +66 -0
- package/src/components/ui/sheet.tsx +90 -0
- package/src/components/ui/sidebar.tsx +627 -0
- package/src/components/ui/skeleton.tsx +22 -0
- package/src/components/ui/spinner.tsx +28 -0
- package/src/components/ui/spotlight.tsx +222 -0
- package/src/components/ui/stat-tile.tsx +25 -0
- package/src/components/ui/step-dialog.tsx +104 -0
- package/src/components/ui/steps-layout.tsx +91 -0
- package/src/components/ui/switch.tsx +55 -0
- package/src/components/ui/table.tsx +99 -0
- package/src/components/ui/tabs.tsx +41 -0
- package/src/components/ui/theme-toggle.tsx +80 -0
- package/src/components/ui/time-list.tsx +106 -0
- package/src/components/ui/time-picker.tsx +344 -0
- package/src/components/ui/toast.tsx +132 -0
- package/src/components/ui/toggle.tsx +76 -0
- package/src/components/ui/tooltip.tsx +78 -0
- package/src/components/ui/top-bar.tsx +118 -0
- package/src/components/ui/typography.tsx +204 -0
- package/src/components/ui/video-block.tsx +66 -0
- package/src/hooks/use-dismiss.ts +24 -0
- package/src/hooks/use-escape-first.ts +25 -0
- package/src/hooks/use-media-query.ts +23 -0
- package/src/hooks/use-save-queue.ts +78 -0
- package/src/hooks/use-selection.ts +51 -0
- package/src/hooks/use-shared-transition.ts +40 -0
- package/src/hooks/use-upload-queue.ts +111 -0
- package/src/lib/accent.ts +11 -0
- package/src/lib/bento.ts +87 -0
- package/src/lib/database.ts +322 -0
- package/src/lib/dates.ts +75 -0
- package/src/lib/document.ts +55 -0
- package/src/lib/embed.ts +62 -0
- package/src/lib/files.ts +73 -0
- package/src/lib/justified.ts +106 -0
- package/src/lib/keys.ts +72 -0
- package/src/lib/number.ts +29 -0
- package/src/lib/pointer.ts +3 -0
- package/src/lib/prepare-image.ts +141 -0
- package/src/lib/rich-text-dom.ts +138 -0
- package/src/lib/rich-text.ts +50 -0
- package/src/lib/spotlight.ts +78 -0
- package/src/lib/theme.ts +18 -0
- package/src/lib/time.ts +83 -0
- package/src/lib/tree.ts +41 -0
- package/src/lib/utils.ts +25 -0
- package/src/styles/notion.css +817 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type DropSide = "before" | "after";
|
|
3
|
+
export declare function DragRows({ children }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
export declare function HandleRow({ children, className, onAdd, menu, onMove, selected, dragging, onDragStart, onDragEnd, onDragOverSide, onDrop, drop, }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
onAdd?: () => void;
|
|
10
|
+
menu?: ReactNode;
|
|
11
|
+
/** Moves the row one place, from the grip's menu; give `null` for a direction it cannot go. */
|
|
12
|
+
onMove?: {
|
|
13
|
+
up: (() => void) | null;
|
|
14
|
+
down: (() => void) | null;
|
|
15
|
+
};
|
|
16
|
+
/** The row is the one being edited or selected: on a touch screen, its grip shows. */
|
|
17
|
+
selected?: boolean;
|
|
18
|
+
dragging?: boolean;
|
|
19
|
+
onDragStart?: () => void;
|
|
20
|
+
onDragEnd?: () => void;
|
|
21
|
+
onDragOverSide?: (side: DropSide) => void;
|
|
22
|
+
onDrop?: () => void;
|
|
23
|
+
drop?: DropSide | null;
|
|
24
|
+
}): import("react").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=handle-row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-row.d.ts","sourceRoot":"","sources":["../../../src/components/ui/handle-row.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAgF,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAQrH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAmB1C,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BA2D7D;AAkBD,wBAAgB,SAAS,CAAC,EACtB,QAAQ,EACR,SAAS,EACT,KAAK,EACL,IAAI,EACJ,MAAM,EACN,QAAgB,EAChB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,MAAM,EACN,IAAI,GACP,EAAE;IACC,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IAEnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+FAA+F;IAC/F,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAA;KAAE,CAAC;IAChE,sFAAsF;IACtF,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IAEpB,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC1B,+BAoGA"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { DndContext, MouseSensor, pointerWithin, TouchSensor, useDraggable, useDroppable, useSensor, useSensors, } from "@dnd-kit/core";
|
|
4
|
+
import { ArrowDown, ArrowUp, GripVertical, Plus } from "lucide-react";
|
|
5
|
+
import { createContext, useContext, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "./dropdown-menu.js";
|
|
7
|
+
import { flushSync } from "react-dom";
|
|
8
|
+
import { cn } from "../../lib/utils.js";
|
|
9
|
+
const control = "flex h-6 items-center justify-center rounded-control text-ink-tertiary transition-colors duration-(--duration-fast) hover:bg-tint-hover [&_svg]:size-4";
|
|
10
|
+
/* The rows of one list (or tree) that can be dragged among each other. Each
|
|
11
|
+
HandleRow inside registers its handlers here, and the drag (dnd-kit's) calls
|
|
12
|
+
them: the row picked up, the half of the row under the pointer, the drop.
|
|
13
|
+
|
|
14
|
+
With a mouse a drag starts once the grip has moved 4px, so a click still opens
|
|
15
|
+
the grip's menu. On a touch screen it starts after a short press on the grip,
|
|
16
|
+
so a swipe over the page still scrolls it. The page scrolls on its own near
|
|
17
|
+
its edges while dragging. */
|
|
18
|
+
const Rows = createContext(null);
|
|
19
|
+
export function DragRows({ children }) {
|
|
20
|
+
const rows = useMemo(() => new Map(), []);
|
|
21
|
+
const dragged = useRef(null);
|
|
22
|
+
const lastOver = useRef(null);
|
|
23
|
+
const sensors = useSensors(useSensor(MouseSensor, { activationConstraint: { distance: 4 } }), useSensor(TouchSensor, { activationConstraint: { delay: 220, tolerance: 6 } }));
|
|
24
|
+
const pointerY = (e) => {
|
|
25
|
+
const start = e.activatorEvent;
|
|
26
|
+
const y = "touches" in start ? (start.touches[0]?.clientY ?? 0) : start.clientY;
|
|
27
|
+
return y + e.delta.y;
|
|
28
|
+
};
|
|
29
|
+
const onMove = (e) => {
|
|
30
|
+
const over = e.over;
|
|
31
|
+
if (!over || over.id === dragged.current)
|
|
32
|
+
return;
|
|
33
|
+
const side = pointerY(e) < over.rect.top + over.rect.height / 2 ? "before" : "after";
|
|
34
|
+
const id = String(over.id);
|
|
35
|
+
if (lastOver.current?.id === id && lastOver.current.side === side)
|
|
36
|
+
return;
|
|
37
|
+
lastOver.current = { id, side };
|
|
38
|
+
rows.get(id)?.current.onDragOverSide?.(side);
|
|
39
|
+
};
|
|
40
|
+
const finish = (e) => {
|
|
41
|
+
const from = dragged.current;
|
|
42
|
+
if (e?.over && String(e.over.id) !== from) {
|
|
43
|
+
// Where the pointer let go decides, even after a flick too quick for a
|
|
44
|
+
// move to be reported: the owner hears that side, rendered, then the drop.
|
|
45
|
+
const id = String(e.over.id);
|
|
46
|
+
const side = pointerY(e) < e.over.rect.top + e.over.rect.height / 2 ? "before" : "after";
|
|
47
|
+
if (lastOver.current?.id !== id || lastOver.current.side !== side)
|
|
48
|
+
flushSync(() => rows.get(id)?.current.onDragOverSide?.(side));
|
|
49
|
+
rows.get(id)?.current.onDrop?.();
|
|
50
|
+
}
|
|
51
|
+
if (from)
|
|
52
|
+
rows.get(from)?.current.onDragEnd?.();
|
|
53
|
+
dragged.current = null;
|
|
54
|
+
lastOver.current = null;
|
|
55
|
+
};
|
|
56
|
+
return (_jsx(Rows.Provider, { value: rows, children: _jsx(DndContext, { sensors: sensors,
|
|
57
|
+
// The row under the pointer is the target: what a person aims with, not
|
|
58
|
+
// the overlap of the small grip being carried.
|
|
59
|
+
collisionDetection: pointerWithin, onDragStart: (e) => {
|
|
60
|
+
dragged.current = String(e.active.id);
|
|
61
|
+
rows.get(dragged.current)?.current.onDragStart?.();
|
|
62
|
+
}, onDragMove: onMove, onDragOver: onMove, onDragEnd: finish, onDragCancel: () => finish(null), accessibility: { screenReaderInstructions: { draggable: "Press the grip for options, including Move up and Move down." } }, children: children }) }));
|
|
63
|
+
}
|
|
64
|
+
/* A row with Notion's two margin controls to its left, shown on hover: "+" to add
|
|
65
|
+
below, and a grip that drags the row and, pressed, opens its menu. Together they
|
|
66
|
+
are 46px wide, so whatever holds the row leaves that much room to its left
|
|
67
|
+
(DocumentEditor's gutter is 3rem).
|
|
68
|
+
|
|
69
|
+
On a screen that cannot hover, the grip alone shows on the row being edited or
|
|
70
|
+
selected (`selected`), small enough for a phone's margin; the menu it opens
|
|
71
|
+
holds everything + does and more.
|
|
72
|
+
|
|
73
|
+
Dragging needs a DragRows around the rows; the row reports which half the
|
|
74
|
+
pointer is over, the owner decides what a drop means and tells the row where to
|
|
75
|
+
draw the line (`drop`). From the keyboard, the grip's menu has Move up and Move
|
|
76
|
+
down (`onMove`).
|
|
77
|
+
|
|
78
|
+
Nest rows as siblings, not inside one another: put a row's children after this
|
|
79
|
+
element, or hovering a child lights up its parent's controls too. */
|
|
80
|
+
export function HandleRow({ children, className, onAdd, menu, onMove, selected = false, dragging, onDragStart, onDragEnd, onDragOverSide, onDrop, drop, }) {
|
|
81
|
+
const [open, setOpen] = useState(false);
|
|
82
|
+
const grip = useRef(null);
|
|
83
|
+
const id = useId();
|
|
84
|
+
const rows = useContext(Rows);
|
|
85
|
+
const handlers = useRef({});
|
|
86
|
+
handlers.current = { onDragStart, onDragEnd, onDragOverSide: dragging === false ? undefined : onDragOverSide, onDrop };
|
|
87
|
+
useLayoutEffect(() => {
|
|
88
|
+
if (!rows)
|
|
89
|
+
return;
|
|
90
|
+
rows.set(id, handlers);
|
|
91
|
+
return () => void rows.delete(id);
|
|
92
|
+
}, [rows, id]);
|
|
93
|
+
const canDrag = rows !== null && onDragStart !== undefined;
|
|
94
|
+
const draggable = useDraggable({ id, disabled: !canDrag });
|
|
95
|
+
const droppable = useDroppable({ id, disabled: rows === null });
|
|
96
|
+
const hasMenu = menu !== undefined || onMove !== undefined;
|
|
97
|
+
return (_jsxs("div", { ref: droppable.setNodeRef, "data-selected": selected || undefined, "data-dragged": draggable.isDragging || undefined, className: cn("group/row relative transition-opacity duration-(--duration-fast) data-dragged:opacity-40", className), children: [_jsxs("div", { contentEditable: false, "data-open": open, className: cn("absolute top-0 right-full flex h-[calc(1lh+6px)] items-center pr-1 opacity-0 transition-opacity duration-(--duration-fast)", "group-hover/row:opacity-100 focus-within:opacity-100 data-[open=true]:opacity-100",
|
|
98
|
+
// No hover: the grip shows on the row being edited or selected.
|
|
99
|
+
"[@media(hover:none)]:pr-0.5 [@media(hover:none)]:group-focus-within/row:opacity-100 [@media(hover:none)]:group-data-selected/row:opacity-100"), children: [onAdd && (_jsx("button", { type: "button", "aria-label": "Add below", className: cn(control, "w-6 [@media(hover:none)]:hidden"), onClick: onAdd, children: _jsx(Plus, {}) })), _jsxs(DropdownMenu, { open: open, onOpenChange: setOpen, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("span", { className: "pointer-events-none absolute inset-y-0 right-1 w-[18px]" }) }), _jsx("button", { ref: (el) => {
|
|
100
|
+
grip.current = el;
|
|
101
|
+
draggable.setNodeRef(el);
|
|
102
|
+
}, type: "button", ...(canDrag ? draggable.listeners : null), "aria-describedby": canDrag ? draggable.attributes["aria-describedby"] : undefined, "aria-label": hasMenu ? (canDrag ? "Drag to move, or press for options" : "Options") : "Drag to move", "aria-haspopup": hasMenu ? "menu" : undefined, "aria-expanded": hasMenu ? open : undefined, className: cn(control, "w-[18px] touch-none", canDrag && "cursor-grab active:cursor-grabbing"), onClick: () => hasMenu && setOpen(true), children: _jsx(GripVertical, {}) }), hasMenu && (_jsxs(DropdownMenuContent, { align: "start",
|
|
103
|
+
// Back to the grip that opened it: the menu's own trigger is a
|
|
104
|
+
// stand-in that cannot take focus, which would drop it to the page.
|
|
105
|
+
onCloseAutoFocus: (e) => {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
grip.current?.focus();
|
|
108
|
+
}, children: [onMove && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { disabled: !onMove.up, onSelect: () => onMove.up?.(), children: [_jsx(ArrowUp, {}), " Move up"] }), _jsxs(DropdownMenuItem, { disabled: !onMove.down, onSelect: () => onMove.down?.(), children: [_jsx(ArrowDown, {}), " Move down"] }), menu !== undefined && _jsx(DropdownMenuSeparator, {})] })), menu] }))] })] }), drop && (_jsx("div", { className: cn("pointer-events-none absolute inset-x-0 h-[3px] rounded-full bg-accent/50", drop === "before" ? "-top-0.5" : "-bottom-0.5") })), children] }));
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=handle-row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-row.js","sourceRoot":"","sources":["../../../src/components/ui/handle-row.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACH,UAAU,EACV,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,UAAU,GAIb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,E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AK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvD,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,SAAS,CAAA;CAAE,+BAO/G"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
/* The bar at the top of a page: what it is on the left (a sidebar's trigger,
|
|
4
|
+
breadcrumbs, a title), its actions on the right. Sticky, 2.75rem tall (the
|
|
5
|
+
sidebar's header is the same, so the two line up), on the page's surface. Inside
|
|
6
|
+
an inset sidebar it takes the card's rounded corners. */
|
|
7
|
+
export function HeaderBar({ className, children, end, ...props }) {
|
|
8
|
+
return (_jsxs("header", { className: cn("top-0 z-(--z-sticky) sticky flex items-center gap-1 bg-surface px-3 rounded-t-[inherit] h-11 shrink-0", className), ...props, children: [children, end !== undefined && _jsx("div", { className: "flex items-center gap-1 ml-auto shrink-0", children: end })] }));
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=header-bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-bar.js","sourceRoot":"","sources":["../../../src/components/ui/header-bar.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC;;;2DAG2D;AAC3D,MAAM,UAAU,SAAS,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,KAAK,EAAkD;IAC5G,OAAO,CACH,kBAAQ,SAAS,EAAE,EAAE,CAAC,uGAAuG,EAAE,SAAS,CAAC,KAAM,KAAK,aAC/I,QAAQ,EACR,GAAG,KAAK,SAAS,IAAI,cAAK,SAAS,EAAC,0CAA0C,YAAE,GAAG,GAAO,IACtF,CACZ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
|
+
export declare const HoverCard: import("react").FC<HoverCardPrimitive.HoverCardProps>;
|
|
4
|
+
export declare const HoverCardTrigger: import("react").ForwardRefExoticComponent<HoverCardPrimitive.HoverCardTriggerProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
5
|
+
export declare function HoverCardContent({ className, align, sideOffset, ...props }: ComponentProps<typeof HoverCardPrimitive.Content>): import("react").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=hover-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hover-card.d.ts","sourceRoot":"","sources":["../../../src/components/ui/hover-card.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,kBAAkB,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAO5C,eAAO,MAAM,SAAS,uDAA0B,CAAC;AACjD,eAAO,MAAM,gBAAgB,wIAA6B,CAAC;AAE3D,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,KAAe,EAAE,UAAc,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,OAAO,kBAAkB,CAAC,OAAO,CAAC,+BAgB3I"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
/* A preview of what a link leads to, on hover or keyboard focus: a page's first
|
|
6
|
+
lines, a person's card. It adds to the link and never replaces it, because a
|
|
7
|
+
touch screen never shows it: nothing in it may be the only way to something. */
|
|
8
|
+
export const HoverCard = HoverCardPrimitive.Root;
|
|
9
|
+
export const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
10
|
+
export function HoverCardContent({ className, align = "start", sideOffset = 6, ...props }) {
|
|
11
|
+
return (_jsx(HoverCardPrimitive.Portal, { children: _jsx(HoverCardPrimitive.Content, { align: align, sideOffset: sideOffset, collisionPadding: 8, className: cn("z-(--z-overlay) bg-surface-overlay shadow-popover p-4 rounded-overlay w-72 max-w-[calc(100vw-1rem)] outline-none", "data-[state=open]:animate-slide-in data-[state=closed]:animate-fade-out origin-[--radix-hover-card-content-transform-origin]", className), ...props }) }));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=hover-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hover-card.js","sourceRoot":"","sources":["../../../src/components/ui/hover-card.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,kBAAkB,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC;;kFAEkF;AAElF,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,OAAO,CAAC;AAE3D,MAAM,UAAU,gBAAgB,CAAC,EAAE,SAAS,EAAE,KAAK,GAAG,OAAO,EAAE,UAAU,GAAG,CAAC,EAAE,GAAG,KAAK,EAAqD;IACxI,OAAO,CACH,KAAC,kBAAkB,CAAC,MAAM,cACtB,KAAC,kBAAkB,CAAC,OAAO,IACvB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,CAAC,EACnB,SAAS,EAAE,EAAE,CACT,kHAAkH,EAClH,8HAA8H,EAC9H,SAAS,CACZ,KACG,KAAK,GACX,GACsB,CAC/B,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/** The narrowest a picture can be made, as a share of the page. */
|
|
3
|
+
export declare const MIN_IMAGE_WIDTH = 0.2;
|
|
4
|
+
export declare function ImageBlock({ src, placeholder, aspect, alt, width, onWidthChange, onFile, onLink, busy, error, caption, onOpen, actions, more, className, }: {
|
|
5
|
+
src?: string;
|
|
6
|
+
/** A small version of the same picture, shown blurred while `src` loads. */
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** Width over height, when known, so nothing below moves as it loads. */
|
|
9
|
+
aspect?: number;
|
|
10
|
+
alt?: string;
|
|
11
|
+
/** Share of the column, from MIN_IMAGE_WIDTH to 1. */
|
|
12
|
+
width: number;
|
|
13
|
+
onWidthChange?: (width: number) => void;
|
|
14
|
+
/** A file chosen, dropped or pasted onto the empty block. */
|
|
15
|
+
onFile?: (file: File) => void;
|
|
16
|
+
/** A link to a picture, pasted into the empty block. */
|
|
17
|
+
onLink?: (url: string) => void;
|
|
18
|
+
/** True, or progress from 0 to 1, while a picture is being made ready. */
|
|
19
|
+
busy?: boolean | number;
|
|
20
|
+
error?: string;
|
|
21
|
+
/** Under the picture: usually an EditableText. */
|
|
22
|
+
caption?: ReactNode;
|
|
23
|
+
/** A click on the picture: open it larger. */
|
|
24
|
+
onOpen?: () => void;
|
|
25
|
+
/** Buttons for the picture's top right corner, shown on hover. */
|
|
26
|
+
actions?: ReactNode;
|
|
27
|
+
/** More ways to find a picture, offered beside the file button when empty. */
|
|
28
|
+
more?: ReactNode;
|
|
29
|
+
className?: string;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
//# sourceMappingURL=image-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-block.d.ts","sourceRoot":"","sources":["../../../src/components/ui/image-block.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA2D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIhG,mEAAmE;AACnE,eAAO,MAAM,eAAe,MAAM,CAAC;AAanC,wBAAgB,UAAU,CAAC,EACvB,GAAG,EACH,WAAW,EACX,MAAM,EACN,GAAQ,EACR,KAAK,EACL,aAAa,EACb,MAAM,EACN,MAAM,EACN,IAAI,EACJ,KAAK,EACL,OAAO,EACP,MAAM,EACN,OAAO,EACP,IAAI,EACJ,SAAS,GACZ,EAAE;IACC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,6DAA6D;IAC7D,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9B,wDAAwD;IACxD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,0EAA0E;IAC1E,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,kEAAkE;IAClE,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,8EAA8E;IAC9E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,+BA8KA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { ImagePlus, Link2, LoaderCircle } from "lucide-react";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
import { Image } from "./image.js";
|
|
6
|
+
import { cn } from "../../lib/utils.js";
|
|
7
|
+
/** The narrowest a picture can be made, as a share of the page. */
|
|
8
|
+
export const MIN_IMAGE_WIDTH = 0.2;
|
|
9
|
+
const clampWidth = (w) => Math.min(1, Math.max(MIN_IMAGE_WIDTH, Math.round(w * 100) / 100));
|
|
10
|
+
/* A picture in a document, as Notion has it: centred, as wide as you drag it, with
|
|
11
|
+
a caption under it. Before it has a picture it is an invitation to add one:
|
|
12
|
+
choose a file, drop one on it, paste one, or paste a link to one on the web.
|
|
13
|
+
|
|
14
|
+
It holds no picture itself. The owner decides what a file becomes (an upload,
|
|
15
|
+
a data URL) and passes back `src`; `busy` shows while that is under way. Width
|
|
16
|
+
is a share of the column, so a picture reads the same on a phone and a wide
|
|
17
|
+
screen; it changes live while a side handle is dragged and is reported once,
|
|
18
|
+
when the handle is let go. The arrow keys move a focused handle by 5%. */
|
|
19
|
+
export function ImageBlock({ src, placeholder, aspect, alt = "", width, onWidthChange, onFile, onLink, busy, error, caption, onOpen, actions, more, className, }) {
|
|
20
|
+
const [dragging, setDragging] = useState(null);
|
|
21
|
+
const [dropping, setDropping] = useState(false);
|
|
22
|
+
const [link, setLink] = useState("");
|
|
23
|
+
const input = useRef(null);
|
|
24
|
+
const frame = useRef(null);
|
|
25
|
+
const shown = dragging ?? width;
|
|
26
|
+
if (src === undefined) {
|
|
27
|
+
const working = busy !== undefined && busy !== false;
|
|
28
|
+
return (_jsxs("div", { tabIndex: -1, className: cn("flex flex-col gap-3 rounded-surface bg-tint-hover p-4 text-sm text-ink-secondary transition-shadow duration-(--duration-base) outline-none sm:flex-row sm:items-center", dropping && "shadow-[0_0_0_2px_var(--accent)]", className), onDragOver: (e) => {
|
|
29
|
+
if (!onFile || !e.dataTransfer.types.includes("Files"))
|
|
30
|
+
return;
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
e.stopPropagation();
|
|
33
|
+
setDropping(true);
|
|
34
|
+
}, onDragLeave: () => setDropping(false), onDrop: (e) => {
|
|
35
|
+
const file = [...e.dataTransfer.files].find((f) => f.type.startsWith("image/"));
|
|
36
|
+
if (!onFile || !file)
|
|
37
|
+
return;
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
setDropping(false);
|
|
41
|
+
onFile(file);
|
|
42
|
+
}, onPaste: (e) => {
|
|
43
|
+
const file = [...e.clipboardData.files].find((f) => f.type.startsWith("image/"));
|
|
44
|
+
if (file && onFile) {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
onFile(file);
|
|
47
|
+
}
|
|
48
|
+
}, children: [working ? (_jsxs("span", { className: "flex items-center gap-2", children: [_jsx(LoaderCircle, { className: "size-4 animate-spin" }), typeof busy === "number" ? `Adding the picture… ${Math.round(busy * 100)}%` : "Adding the picture…"] })) : (_jsxs(_Fragment, { children: [onFile && (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", onClick: () => input.current?.click(), className: "flex h-8 shrink-0 items-center gap-2 rounded-control bg-surface px-3 font-medium text-ink shadow-xs transition-colors duration-(--duration-fast) hover:bg-surface-overlay [&_svg]:size-4", children: [_jsx(ImagePlus, {}), "Choose a picture"] }), _jsx("input", { ref: input, type: "file", accept: "image/*", hidden: true, onChange: (e) => {
|
|
49
|
+
const file = e.target.files?.[0];
|
|
50
|
+
e.target.value = "";
|
|
51
|
+
if (file)
|
|
52
|
+
onFile(file);
|
|
53
|
+
} })] })), more, onLink && (_jsxs("form", { className: "flex min-w-0 flex-1 items-center gap-2", onSubmit: (e) => {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
if (/^https?:\/\//i.test(link.trim()))
|
|
56
|
+
onLink(link.trim());
|
|
57
|
+
}, children: [_jsx(Link2, { className: "size-4 shrink-0 text-ink-tertiary" }), _jsx("input", { value: link, onChange: (e) => setLink(e.target.value), placeholder: onFile ? "or paste a link to a picture" : "Paste a link to a picture, then Enter", "aria-label": "Link to a picture", className: "h-8 min-w-0 flex-1 bg-transparent text-ink outline-none placeholder:text-ink-tertiary" })] }))] })), error && _jsx("span", { className: "text-danger", children: error })] }));
|
|
58
|
+
}
|
|
59
|
+
// Dragging one side moves both, since the picture stays centred: the change in
|
|
60
|
+
// width is twice how far the pointer moved.
|
|
61
|
+
const drag = (side) => ({
|
|
62
|
+
onPointerDown: (e) => {
|
|
63
|
+
if (!onWidthChange || !frame.current)
|
|
64
|
+
return;
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
const handle = e.currentTarget;
|
|
67
|
+
// Captured, so the drag keeps coming here however far the pointer strays.
|
|
68
|
+
handle.setPointerCapture(e.pointerId);
|
|
69
|
+
const column = frame.current.parentElement.getBoundingClientRect().width;
|
|
70
|
+
const start = { x: e.clientX, width };
|
|
71
|
+
let last = width;
|
|
72
|
+
const move = (ev) => {
|
|
73
|
+
last = clampWidth(start.width + (side * (ev.clientX - start.x) * 2) / column);
|
|
74
|
+
setDragging(last);
|
|
75
|
+
};
|
|
76
|
+
// A cancelled drag (the browser took the pointer for a scroll or a drag of
|
|
77
|
+
// its own) keeps the width reached, rather than snapping back.
|
|
78
|
+
const end = () => {
|
|
79
|
+
handle.removeEventListener("pointermove", move);
|
|
80
|
+
handle.removeEventListener("pointerup", end);
|
|
81
|
+
handle.removeEventListener("pointercancel", end);
|
|
82
|
+
setDragging(null);
|
|
83
|
+
if (last !== width)
|
|
84
|
+
onWidthChange(last);
|
|
85
|
+
};
|
|
86
|
+
handle.addEventListener("pointermove", move);
|
|
87
|
+
handle.addEventListener("pointerup", end);
|
|
88
|
+
handle.addEventListener("pointercancel", end);
|
|
89
|
+
},
|
|
90
|
+
onKeyDown: (e) => {
|
|
91
|
+
const step = e.key === "ArrowRight" ? side * 0.05 : e.key === "ArrowLeft" ? -side * 0.05 : 0;
|
|
92
|
+
if (step === 0 || !onWidthChange)
|
|
93
|
+
return;
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
const next = clampWidth(width + step);
|
|
96
|
+
if (next !== width)
|
|
97
|
+
onWidthChange(next);
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
const handle = (side) => onWidthChange && (_jsx("span", { role: "slider", tabIndex: 0, "aria-label": "Picture width", "aria-valuemin": MIN_IMAGE_WIDTH * 100, "aria-valuemax": 100, "aria-valuenow": Math.round(shown * 100), "aria-valuetext": `${Math.round(shown * 100)}% of the page`, ...drag(side), className: cn("absolute top-1/2 z-10 flex h-16 max-h-[60%] w-3 -translate-y-1/2 cursor-ew-resize touch-none items-center justify-center opacity-0 transition-opacity duration-(--duration-fast) group-hover/image:opacity-100 focus-visible:opacity-100 max-md:hidden", side === -1 ? "left-1" : "right-1", dragging !== null && "opacity-100"), children: _jsx("span", { className: "h-full w-1.5 rounded-full bg-on-media-strong shadow-[0_0_0_1px_var(--on-media-edge)]" }) }));
|
|
101
|
+
return (_jsxs("figure", { className: cn("flex flex-col items-center", className), children: [_jsxs("div", { ref: frame, className: "group/image relative max-w-full select-none", style: { width: `${shown * 100}%` }, onDragStart: (e) => e.preventDefault(), children: [handle(-1), _jsx("button", { type: "button", onClick: onOpen, disabled: !onOpen, "aria-label": alt === "" ? "Open the picture" : `Open ${alt}`, className: "block w-full cursor-zoom-in overflow-hidden rounded-surface disabled:cursor-default", children: _jsx(Image, { src: src, placeholder: placeholder, aspect: aspect, alt: alt, fit: "cover", draggable: false, className: "w-full" }) }), handle(1), actions && _jsx("div", { className: "absolute top-2 right-2 flex gap-1 opacity-0 transition-opacity duration-(--duration-fast) group-hover/image:opacity-100 focus-within:opacity-100 max-md:opacity-100", children: actions }), dragging !== null && (_jsxs("span", { className: "tabular-nums absolute top-2 left-2 rounded-control bg-on-media-strong px-1.5 py-0.5 text-caption text-on-media-ink", children: [Math.round(dragging * 100), "%"] }))] }), caption !== undefined && _jsx("figcaption", { className: "mt-1.5 w-full max-w-full text-sm text-ink-secondary", style: { width: `${shown * 100}%` }, children: caption })] }));
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=image-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-block.js","sourceRoot":"","sources":["../../../src/components/ui/image-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,EAC/M,QAAQ,KAAK,IAAI,IAAI,CAClB,gBAAM,SAAS,EAAC,oHAAoH,aAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,SAAS,CAC5K,IACC,EACL,OAAO,KAAK,SAAS,IAAI,qBAAY,SAAS,EAAC,qDAAqD,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,EAAE,YAAG,OAAO,GAAc,IAC5J,CACZ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
export declare function ImageCard({ children, topRight, bottomLeft, selecting, selected, onSelect, className, ...props }: Omit<ComponentPropsWithoutRef<"div">, "onSelect"> & {
|
|
3
|
+
/** Controls for the top-right corner, usually an `ImageCardButton`. */
|
|
4
|
+
topRight?: ReactNode;
|
|
5
|
+
/** Markers for the bottom-left corner, usually an `ImageCardBadge`. */
|
|
6
|
+
bottomLeft?: ReactNode;
|
|
7
|
+
selecting?: boolean;
|
|
8
|
+
selected?: boolean;
|
|
9
|
+
onSelect?: (event: {
|
|
10
|
+
range: boolean;
|
|
11
|
+
}) => void;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
13
|
+
export declare function ImageCardButton({ always, className, ...props }: ComponentPropsWithoutRef<"button"> & {
|
|
14
|
+
always?: boolean;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
export declare function ImageCardBadge({ className, ...props }: ComponentPropsWithoutRef<"span">): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=image-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-card.d.ts","sourceRoot":"","sources":["../../../src/components/ui/image-card.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAc,SAAS,EAAE,MAAM,OAAO,CAAC;AAc7E,wBAAgB,SAAS,CAAC,EACtB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAiB,EACjB,QAAgB,EAChB,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACX,EAAE,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG;IACnD,uEAAuE;IACvE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,uEAAuE;IACvE,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAClD,+BAyCA;AAMD,wBAAgB,eAAe,CAAC,EAAE,MAAc,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,CAAC,QAAQ,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,+BAEjI;AAID,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,CAAC,MAAM,CAAC,+BAOvF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Check } from "lucide-react";
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
/* A picture as a card: the image is the whole card, and anything else sits on
|
|
7
|
+
top of it in a corner. Rounded, with a slight dim on hover.
|
|
8
|
+
|
|
9
|
+
It can also be picked. While `selecting` is set, a press picks the card
|
|
10
|
+
instead of doing whatever its content would do, a tick shows in the corner,
|
|
11
|
+
and a picked card shrinks a little inside an accent ring. Shift is passed
|
|
12
|
+
through so a run of cards can be picked at once (see `useSelection`).
|
|
13
|
+
|
|
14
|
+
Put `group` to use: children can react to `group-hover`, and the corner
|
|
15
|
+
controls made with `ImageCardButton` stay hidden until then. */
|
|
16
|
+
export function ImageCard({ children, topRight, bottomLeft, selecting = false, selected = false, onSelect, className, ...props }) {
|
|
17
|
+
return (_jsxs("div", { className: cn("group relative overflow-hidden rounded-overlay bg-surface-sunken transition-[scale,box-shadow] duration-(--duration-base) ease-out-notion", "[&_img]:transition-[filter,opacity,scale] hover:[&_img]:brightness-[0.94]", selecting && selected && "scale-[0.94] shadow-[0_0_0_3px_var(--accent)]", selecting && !selected && "shadow-[0_0_0_0px_var(--accent)]", className),
|
|
18
|
+
// Capture, so the press never reaches a link or button inside.
|
|
19
|
+
onClickCapture: selecting
|
|
20
|
+
? (event) => {
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
event.stopPropagation();
|
|
23
|
+
onSelect?.({ range: event.shiftKey });
|
|
24
|
+
}
|
|
25
|
+
: undefined, "aria-selected": selecting ? selected : undefined, ...props, children: [children, _jsx("span", { "aria-hidden": true, className: cn("pointer-events-none absolute top-2 left-2 z-10 flex size-6 items-center justify-center rounded-full shadow-sm", "transition-[opacity,scale,background-color] duration-(--duration-base) ease-out-notion", selecting ? "opacity-100 scale-100" : "opacity-0 scale-50", selected ? "bg-accent-solid text-accent-ink" : "bg-on-media-edge text-transparent backdrop-blur-sm"), children: _jsx(Check, { className: cn("size-4 transition-[scale] duration-(--duration-base) ease-out-notion", selected ? "scale-100" : "scale-0") }) }), bottomLeft !== undefined && _jsx("div", { className: "pointer-events-none absolute bottom-2 left-2 flex gap-1", children: bottomLeft }), topRight !== undefined && !selecting && _jsx("div", { className: "absolute top-2 right-2 flex gap-1", children: topRight })] }));
|
|
26
|
+
}
|
|
27
|
+
/* A control on top of a picture. White on a soft dark disc in both themes,
|
|
28
|
+
because it has to read against the picture, not the page: a bright sky as
|
|
29
|
+
well as a dark one. Hidden until the card is hovered or it takes focus,
|
|
30
|
+
unless `always` is set (for a state that is on, like a favourite). */
|
|
31
|
+
export function ImageCardButton({ always = false, className, ...props }) {
|
|
32
|
+
return _jsx(Button, { variant: "on-media", size: "icon-sm", className: cn("[&_svg]:size-4", !always && "affordance", className), ...props });
|
|
33
|
+
}
|
|
34
|
+
/* A marker on top of a picture that is always shown: a fact about it that
|
|
35
|
+
should not take a hover to find out. */
|
|
36
|
+
export function ImageCardBadge({ className, ...props }) {
|
|
37
|
+
return (_jsx("span", { className: cn("flex size-6 items-center justify-center rounded-full bg-on-media text-on-media-ink backdrop-blur-sm [&_svg]:size-3.5", className), ...props }));
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=image-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-card.js","sourceRoot":"","sources":["../../../src/components/ui/image-card.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAc,CAAC;AAEtC;;;;;;;;;kEASkE;AAClE,MAAM,UAAU,SAAS,CAAC,EACtB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EASX;IACG,OAAO,CACH,eACI,SAAS,EAAE,EAAE,CACT,2IAA2I,EAC3I,2EAA2E,EAC3E,SAAS,IAAI,QAAQ,IAAI,+CAA+C,EACxE,SAAS,IAAI,CAAC,QAAQ,IAAI,kCAAkC,EAC5D,SAAS,CACZ;QACD,+DAA+D;QAC/D,cAAc,EACV,SAAS;YACL,CAAC,CAAC,CAAC,KAAiB,EAAE,EAAE;gBAClB,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,KAAK,CAAC,eAAe,EAAE,CAAC;gBACxB,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC1C,CAAC;YACH,CAAC,C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 1.5, 2, 3];
|
|
3
|
+
/** Keeps a focus within 0 and 1, and its zoom one of the steps. */
|
|
4
|
+
export declare function clampFocus(focus: ImageFocus): Required<ImageFocus>;
|
|
5
|
+
export declare function dragFocus(focus: Required<ImageFocus>, drag: {
|
|
6
|
+
dx: number;
|
|
7
|
+
dy: number;
|
|
8
|
+
}, frame: {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}, natural: {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}): Required<ImageFocus>;
|
|
15
|
+
export declare function ImageFramer({ src, alt, ratio, value, onChange, className, }: {
|
|
16
|
+
src: string;
|
|
17
|
+
alt: string;
|
|
18
|
+
/** The shape it will be shown in. */
|
|
19
|
+
ratio?: ImageRatio;
|
|
20
|
+
value: ImageFocus;
|
|
21
|
+
onChange: (focus: Required<ImageFocus>) => void;
|
|
22
|
+
className?: string;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=image-framer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-framer.d.ts","sourceRoot":"","sources":["../../../src/components/ui/image-framer.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAuB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAWpF,eAAO,MAAM,KAAK,yBAA0B,CAAC;AAE7C,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,CAGlE;AAMD,wBAAgB,SAAS,CACrB,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,EAC3B,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAChC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACxC,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3C,QAAQ,CAAC,UAAU,CAAC,CAStB;AAED,wBAAgB,WAAW,CAAC,EACxB,GAAG,EACH,GAAG,EACH,KAAgB,EAChB,KAAK,EACL,QAAQ,EACR,SAAS,GACZ,EAAE;IACC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,+BAmGA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Minus, Move, Plus } from "lucide-react";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { focusStyle, ratioOf } from "./image.js";
|
|
8
|
+
/* Choosing which part of a picture shows when its shape is not the frame's: a
|
|
9
|
+
portrait shown square, a wide photo as a tall card. The picture fills the frame
|
|
10
|
+
(`ratio`) and is dragged within it, by mouse or finger, or moved with the arrow
|
|
11
|
+
keys (Shift for bigger steps); the zoom goes in steps, 1× to 3×, with its
|
|
12
|
+
buttons or + and −. A rule-of-thirds grid shows while it moves.
|
|
13
|
+
|
|
14
|
+
It hands back `{ x, y, zoom }`: x and y from 0 to 1 across and down, the point
|
|
15
|
+
kept in view. Give the same to Image's `focus` and it shows exactly this. */
|
|
16
|
+
export const ZOOMS = [1, 1.5, 2, 3];
|
|
17
|
+
/** Keeps a focus within 0 and 1, and its zoom one of the steps. */
|
|
18
|
+
export function clampFocus(focus) {
|
|
19
|
+
const zoom = ZOOMS.reduce((best, z) => (Math.abs(z - (focus.zoom ?? 1)) < Math.abs(best - (focus.zoom ?? 1)) ? z : best), 1);
|
|
20
|
+
return { x: Math.min(1, Math.max(0, focus.x)), y: Math.min(1, Math.max(0, focus.y)), zoom };
|
|
21
|
+
}
|
|
22
|
+
/* How far the focus moves for a drag of (dx, dy) pixels. A covering picture overflows
|
|
23
|
+
the frame along one axis (more with zoom); dragging by the whole overflow moves the
|
|
24
|
+
focus from one edge to the other. Dragging right shows more of the left, so the
|
|
25
|
+
focus moves the other way. With no overflow on an axis, that axis does not move. */
|
|
26
|
+
export function dragFocus(focus, drag, frame, natural) {
|
|
27
|
+
const cover = Math.max(frame.width / natural.width, frame.height / natural.height);
|
|
28
|
+
const overflowX = natural.width * cover * focus.zoom - frame.width;
|
|
29
|
+
const overflowY = natural.height * cover * focus.zoom - frame.height;
|
|
30
|
+
return clampFocus({
|
|
31
|
+
x: overflowX > 0.5 ? focus.x - drag.dx / overflowX : focus.x,
|
|
32
|
+
y: overflowY > 0.5 ? focus.y - drag.dy / overflowY : focus.y,
|
|
33
|
+
zoom: focus.zoom,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function ImageFramer({ src, alt, ratio = "square", value, onChange, className, }) {
|
|
37
|
+
const focus = clampFocus(value);
|
|
38
|
+
const frame = useRef(null);
|
|
39
|
+
const img = useRef(null);
|
|
40
|
+
const drag = useRef(null);
|
|
41
|
+
const [moving, setMoving] = useState(false);
|
|
42
|
+
const measure = () => {
|
|
43
|
+
const f = frame.current?.getBoundingClientRect();
|
|
44
|
+
const i = img.current;
|
|
45
|
+
if (!f || !i || !i.naturalWidth)
|
|
46
|
+
return null;
|
|
47
|
+
return { frame: { width: f.width, height: f.height }, natural: { width: i.naturalWidth, height: i.naturalHeight } };
|
|
48
|
+
};
|
|
49
|
+
const onPointerDown = (e) => {
|
|
50
|
+
if (e.button !== 0)
|
|
51
|
+
return;
|
|
52
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
53
|
+
drag.current = { x: e.clientX, y: e.clientY, start: focus };
|
|
54
|
+
setMoving(true);
|
|
55
|
+
};
|
|
56
|
+
const onPointerMove = (e) => {
|
|
57
|
+
const d = drag.current;
|
|
58
|
+
const m = measure();
|
|
59
|
+
if (!d || !m)
|
|
60
|
+
return;
|
|
61
|
+
onChange(dragFocus(d.start, { dx: e.clientX - d.x, dy: e.clientY - d.y }, m.frame, m.natural));
|
|
62
|
+
};
|
|
63
|
+
const onPointerUp = () => {
|
|
64
|
+
drag.current = null;
|
|
65
|
+
setMoving(false);
|
|
66
|
+
};
|
|
67
|
+
const zoomBy = (step) => {
|
|
68
|
+
const at = ZOOMS.indexOf(focus.zoom);
|
|
69
|
+
onChange({ ...focus, zoom: ZOOMS[Math.min(ZOOMS.length - 1, Math.max(0, at + step))] });
|
|
70
|
+
};
|
|
71
|
+
const onKeyDown = (e) => {
|
|
72
|
+
const by = e.shiftKey ? 0.1 : 0.02;
|
|
73
|
+
const moves = { ArrowLeft: [-by, 0], ArrowRight: [by, 0], ArrowUp: [0, -by], ArrowDown: [0, by] };
|
|
74
|
+
if (moves[e.key]) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
onChange(clampFocus({ ...focus, x: focus.x + moves[e.key][0], y: focus.y + moves[e.key][1] }));
|
|
77
|
+
}
|
|
78
|
+
else if (e.key === "+" || e.key === "=") {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
zoomBy(1);
|
|
81
|
+
}
|
|
82
|
+
else if (e.key === "-" || e.key === "_") {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
zoomBy(-1);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return (_jsxs("div", { className: cn("flex flex-col gap-2", className), children: [_jsxs("div", { ref: frame, tabIndex: 0, role: "slider", "aria-label": `Position of ${alt}`, "aria-roledescription": "picture framer", "aria-valuetext": `${Math.round(focus.x * 100)}% across, ${Math.round(focus.y * 100)}% down, ${focus.zoom}× zoom`, "aria-keyshortcuts": "ArrowLeft ArrowRight ArrowUp ArrowDown + -", onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerUp, onKeyDown: onKeyDown, style: { aspectRatio: ratioOf(ratio) }, className: cn("relative bg-surface-sunken rounded-surface overflow-hidden outline-offset-2 select-none touch-none", moving ? "cursor-grabbing" : "cursor-grab"), children: [_jsx("img", { ref: img, src: src, alt: alt, draggable: false, style: focusStyle(focus), className: "w-full h-full object-cover pointer-events-none" }), _jsxs("span", { "aria-hidden": true, className: cn("absolute inset-0 transition-opacity duration-(--duration-fast) pointer-events-none", moving ? "opacity-100" : "opacity-0"), children: [_jsx("span", { className: "top-0 bottom-0 left-1/3 absolute bg-on-media-edge w-px" }), _jsx("span", { className: "top-0 bottom-0 left-2/3 absolute bg-on-media-edge w-px" }), _jsx("span", { className: "top-1/3 right-0 left-0 absolute bg-on-media-edge h-px" }), _jsx("span", { className: "top-2/3 right-0 left-0 absolute bg-on-media-edge h-px" })] }), _jsxs("span", { "aria-hidden": true, className: cn("bottom-2 left-2 absolute flex items-center gap-1 bg-on-media-strong px-1.5 py-0.5 rounded-control text-caption text-on-media-ink transition-opacity duration-(--duration-fast)", moving && "opacity-0"), children: [_jsx(Move, { className: "size-3.5" }), " Drag to frame"] })] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { size: "icon-sm", variant: "ghost", "aria-label": "Zoom out", disabled: focus.zoom === ZOOMS[0], onClick: () => zoomBy(-1), children: _jsx(Minus, {}) }), _jsxs("span", { className: "w-10 tabular-nums text-ink-secondary text-sm text-center", "aria-live": "polite", children: [focus.zoom, "\u00D7"] }), _jsx(Button, { size: "icon-sm", variant: "ghost", "aria-label": "Zoom in", disabled: focus.zoom === ZOOMS[ZOOMS.length - 1], onClick: () => zoomBy(1), children: _jsx(Plus, {}) }), _jsx(Button, { size: "sm", variant: "ghost", className: "ml-auto", onClick: () => onChange({ x: 0.5, y: 0.5, zoom: 1 }), children: "Centre" })] })] }));
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=image-framer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-framer.js","sourceRoot":"","sources":["../../../src/components/ui/image-framer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAyC,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAc,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAoC,MAAM,YAAa,CAAC;AAEpF;;;;;;;+EAO+E;AAE/E,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC;AAE7C,mEAAmE;AACnE,MAAM,UAAU,UAAU,CAAC,KAAiB;IACxC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAW,CAAC,CAAC;IACvI,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC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