@kujoforall/paper-ui 0.1.0 → 0.2.1
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 +94 -0
- package/README.md +50 -7
- package/dist/components/editor/block-text.d.ts.map +1 -1
- package/dist/components/editor/block-text.js +52 -17
- package/dist/components/editor/block-text.js.map +1 -1
- package/dist/components/editor/blocks.d.ts.map +1 -1
- package/dist/components/editor/blocks.js +17 -13
- package/dist/components/editor/blocks.js.map +1 -1
- package/dist/components/editor/document-editor.d.ts.map +1 -1
- package/dist/components/editor/document-editor.js +4 -2
- package/dist/components/editor/document-editor.js.map +1 -1
- package/dist/components/editor/document-view.d.ts.map +1 -1
- package/dist/components/editor/document-view.js +17 -12
- package/dist/components/editor/document-view.js.map +1 -1
- package/dist/components/editor/editor-state.d.ts +7 -0
- package/dist/components/editor/editor-state.d.ts.map +1 -1
- package/dist/components/editor/editor-state.js +28 -3
- package/dist/components/editor/editor-state.js.map +1 -1
- 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.map +1 -1
- package/dist/components/editor/extensions/spoiler.js +2 -2
- package/dist/components/editor/extensions/spoiler.js.map +1 -1
- package/dist/components/editor/index.d.ts +1 -0
- package/dist/components/editor/index.d.ts.map +1 -1
- package/dist/components/editor/index.js +1 -0
- package/dist/components/editor/index.js.map +1 -1
- package/dist/components/editor/kinds.js +1 -1
- package/dist/components/editor/kinds.js.map +1 -1
- 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/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.js +1 -1
- package/dist/components/ui/accent-picker.js.map +1 -1
- 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 +1 -0
- package/dist/components/ui/app-shell.d.ts.map +1 -1
- package/dist/components/ui/app-shell.js +5 -3
- package/dist/components/ui/app-shell.js.map +1 -1
- 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 +3 -3
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js +2 -2
- package/dist/components/ui/badge.js.map +1 -1
- 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.js +1 -1
- package/dist/components/ui/breadcrumbs.js.map +1 -1
- package/dist/components/ui/button.d.ts +8 -6
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +91 -26
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.d.ts.map +1 -1
- package/dist/components/ui/calendar.js +6 -5
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/callout.d.ts +23 -4
- package/dist/components/ui/callout.d.ts.map +1 -1
- package/dist/components/ui/callout.js +28 -15
- package/dist/components/ui/callout.js.map +1 -1
- package/dist/components/ui/card.d.ts +13 -8
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/card.js +10 -9
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/checkbox.d.ts +9 -4
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +25 -5
- package/dist/components/ui/checkbox.js.map +1 -1
- 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 +5 -2
- package/dist/components/ui/command-menu.d.ts.map +1 -1
- package/dist/components/ui/command-menu.js +31 -6
- package/dist/components/ui/command-menu.js.map +1 -1
- 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 +6 -1
- package/dist/components/ui/date-picker.d.ts.map +1 -1
- package/dist/components/ui/date-picker.js +20 -12
- package/dist/components/ui/date-picker.js.map +1 -1
- package/dist/components/ui/date-time-picker.d.ts +3 -1
- package/dist/components/ui/date-time-picker.d.ts.map +1 -1
- package/dist/components/ui/date-time-picker.js +17 -15
- package/dist/components/ui/date-time-picker.js.map +1 -1
- package/dist/components/ui/dialog.d.ts +13 -9
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog.js +33 -3
- package/dist/components/ui/dialog.js.map +1 -1
- 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 +14 -10
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +22 -13
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/editable-text.d.ts +9 -2
- package/dist/components/ui/editable-text.d.ts.map +1 -1
- package/dist/components/ui/editable-text.js +27 -10
- package/dist/components/ui/editable-text.js.map +1 -1
- 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 +2 -1
- package/dist/components/ui/field-button.d.ts.map +1 -1
- package/dist/components/ui/field-button.js +7 -5
- package/dist/components/ui/field-button.js.map +1 -1
- package/dist/components/ui/file-preview.js +1 -1
- package/dist/components/ui/file-preview.js.map +1 -1
- package/dist/components/ui/file-uploader.d.ts.map +1 -1
- package/dist/components/ui/file-uploader.js +5 -4
- package/dist/components/ui/file-uploader.js.map +1 -1
- 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 +11 -1
- package/dist/components/ui/handle-row.d.ts.map +1 -1
- package/dist/components/ui/handle-row.js +101 -32
- package/dist/components/ui/handle-row.js.map +1 -1
- 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.js +4 -4
- package/dist/components/ui/image-block.js.map +1 -1
- package/dist/components/ui/image-card.d.ts.map +1 -1
- package/dist/components/ui/image-card.js +5 -4
- package/dist/components/ui/image-card.js.map +1 -1
- 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.map +1 -1
- package/dist/components/ui/image-viewer.js +38 -5
- package/dist/components/ui/image-viewer.js.map +1 -1
- package/dist/components/ui/image.d.ts +25 -3
- package/dist/components/ui/image.d.ts.map +1 -1
- package/dist/components/ui/image.js +50 -21
- package/dist/components/ui/image.js.map +1 -1
- package/dist/components/ui/index.d.ts +54 -11
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +53 -10
- package/dist/components/ui/index.js.map +1 -1
- package/dist/components/ui/input.d.ts +71 -12
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/input.js +236 -23
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/link-block.d.ts.map +1 -1
- package/dist/components/ui/link-block.js +1 -1
- package/dist/components/ui/link-block.js.map +1 -1
- 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.js +1 -1
- package/dist/components/ui/mac-card.js.map +1 -1
- 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.map +1 -1
- package/dist/components/ui/nav-tree.js +10 -3
- package/dist/components/ui/nav-tree.js.map +1 -1
- package/dist/components/ui/page.d.ts +16 -5
- package/dist/components/ui/page.d.ts.map +1 -1
- package/dist/components/ui/page.js +23 -10
- package/dist/components/ui/page.js.map +1 -1
- 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 +2 -2
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/progress.d.ts +11 -1
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/progress.js +17 -4
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/property.d.ts +2 -6
- package/dist/components/ui/property.d.ts.map +1 -1
- package/dist/components/ui/property.js +6 -22
- package/dist/components/ui/property.js.map +1 -1
- 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 +15 -7
- package/dist/components/ui/segmented.d.ts.map +1 -1
- package/dist/components/ui/segmented.js +8 -6
- package/dist/components/ui/segmented.js.map +1 -1
- package/dist/components/ui/select-menu.d.ts +3 -1
- package/dist/components/ui/select-menu.d.ts.map +1 -1
- package/dist/components/ui/select-menu.js +2 -2
- package/dist/components/ui/select-menu.js.map +1 -1
- package/dist/components/ui/select.d.ts +7 -2
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +19 -5
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/selection-bar.js +1 -1
- package/dist/components/ui/selection-bar.js.map +1 -1
- 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.map +1 -1
- package/dist/components/ui/spotlight.js +14 -11
- package/dist/components/ui/spotlight.js.map +1 -1
- package/dist/components/ui/step-dialog.js +3 -3
- package/dist/components/ui/step-dialog.js.map +1 -1
- 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 +13 -5
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +65 -12
- package/dist/components/ui/table.js.map +1 -1
- 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 +14 -0
- package/dist/components/ui/theme-toggle.d.ts.map +1 -1
- package/dist/components/ui/theme-toggle.js +69 -41
- package/dist/components/ui/theme-toggle.js.map +1 -1
- 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 +37 -11
- package/dist/components/ui/time-picker.d.ts.map +1 -1
- package/dist/components/ui/time-picker.js +130 -52
- package/dist/components/ui/time-picker.js.map +1 -1
- 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 +1 -1
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip.js +13 -2
- package/dist/components/ui/tooltip.js.map +1 -1
- 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 +11 -5
- package/dist/components/ui/typography.d.ts.map +1 -1
- package/dist/components/ui/typography.js +31 -5
- package/dist/components/ui/typography.js.map +1 -1
- package/dist/components/ui/video-block.d.ts.map +1 -1
- package/dist/components/ui/video-block.js +5 -1
- package/dist/components/ui/video-block.js.map +1 -1
- 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.map +1 -1
- package/dist/hooks/use-save-queue.js +19 -7
- package/dist/hooks/use-save-queue.js.map +1 -1
- package/dist/hooks/use-selection.d.ts.map +1 -1
- package/dist/hooks/use-selection.js +10 -1
- package/dist/hooks/use-selection.js.map +1 -1
- 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 +16 -0
- package/dist/lib/dates.d.ts.map +1 -1
- package/dist/lib/dates.js +27 -0
- package/dist/lib/dates.js.map +1 -1
- 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 +2 -0
- package/dist/lib/rich-text-dom.d.ts.map +1 -1
- package/dist/lib/rich-text-dom.js +5 -3
- package/dist/lib/rich-text-dom.js.map +1 -1
- 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/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +20 -2
- package/dist/lib/utils.js.map +1 -1
- package/dist/styles/notion.css +342 -51
- package/package.json +27 -4
- package/src/components/editor/block-text.tsx +58 -17
- package/src/components/editor/blocks.tsx +19 -14
- package/src/components/editor/document-editor.tsx +7 -2
- package/src/components/editor/document-view.tsx +37 -24
- package/src/components/editor/editor-state.tsx +31 -3
- package/src/components/editor/extensions/kit-blocks.tsx +452 -0
- package/src/components/editor/extensions/spoiler.tsx +9 -4
- package/src/components/editor/index.ts +1 -0
- package/src/components/editor/kinds.ts +1 -1
- package/src/components/editor/look.tsx +36 -0
- package/src/components/three/model-viewer.tsx +514 -0
- package/src/components/ui/accent-picker.tsx +2 -2
- 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 +9 -7
- package/src/components/ui/avatar.tsx +106 -0
- package/src/components/ui/badge.tsx +4 -4
- package/src/components/ui/banner.tsx +53 -0
- package/src/components/ui/breadcrumbs.tsx +1 -1
- package/src/components/ui/button.tsx +115 -41
- package/src/components/ui/calendar.tsx +8 -7
- package/src/components/ui/callout.tsx +41 -42
- package/src/components/ui/card.tsx +27 -58
- package/src/components/ui/checkbox.tsx +53 -19
- 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 +61 -31
- 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 +99 -61
- package/src/components/ui/date-time-picker.tsx +68 -62
- package/src/components/ui/dialog.tsx +48 -21
- package/src/components/ui/document-layout.tsx +52 -0
- package/src/components/ui/dropdown-menu.tsx +33 -31
- package/src/components/ui/editable-text.tsx +40 -7
- 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 +11 -9
- package/src/components/ui/file-preview.tsx +1 -1
- package/src/components/ui/file-uploader.tsx +23 -24
- 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 +176 -40
- 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 +6 -6
- package/src/components/ui/image-card.tsx +18 -25
- package/src/components/ui/image-framer.tsx +160 -0
- package/src/components/ui/image-viewer.tsx +53 -10
- package/src/components/ui/image.tsx +133 -29
- package/src/components/ui/index.ts +106 -11
- package/src/components/ui/input.tsx +437 -65
- package/src/components/ui/link-block.tsx +5 -2
- package/src/components/ui/list-detail.tsx +115 -0
- package/src/components/ui/listbox.ts +26 -0
- package/src/components/ui/mac-card.tsx +5 -5
- 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 +11 -5
- package/src/components/ui/page.tsx +63 -15
- package/src/components/ui/pagination.tsx +143 -0
- package/src/components/ui/picker-panel.tsx +69 -0
- package/src/components/ui/popover.tsx +3 -3
- package/src/components/ui/progress.tsx +56 -16
- package/src/components/ui/property.tsx +6 -37
- 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 +48 -16
- package/src/components/ui/select-menu.tsx +11 -3
- package/src/components/ui/select.tsx +33 -10
- package/src/components/ui/selection-bar.tsx +1 -1
- 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 +21 -21
- package/src/components/ui/step-dialog.tsx +6 -6
- package/src/components/ui/steps-layout.tsx +91 -0
- package/src/components/ui/switch.tsx +55 -0
- package/src/components/ui/table.tsx +75 -18
- package/src/components/ui/tabs.tsx +41 -0
- package/src/components/ui/theme-toggle.tsx +74 -83
- package/src/components/ui/time-list.tsx +106 -0
- package/src/components/ui/time-picker.tsx +305 -134
- package/src/components/ui/toast.tsx +132 -0
- package/src/components/ui/toggle.tsx +76 -0
- package/src/components/ui/tooltip.tsx +20 -6
- package/src/components/ui/top-bar.tsx +118 -0
- package/src/components/ui/typography.tsx +45 -9
- package/src/components/ui/video-block.tsx +9 -3
- 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 +19 -7
- package/src/hooks/use-selection.ts +8 -1
- package/src/lib/database.ts +322 -0
- package/src/lib/dates.ts +36 -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 +5 -3
- package/src/lib/theme.ts +18 -0
- package/src/lib/time.ts +83 -0
- package/src/lib/utils.ts +21 -2
- package/src/styles/notion.css +342 -51
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Maximize, Minimize, Pause, Play, RotateCcw, Rotate3d } from "lucide-react";
|
|
4
|
+
import { useEffect, useId, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
|
|
5
|
+
import * as THREE from "three";
|
|
6
|
+
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
7
|
+
import { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironment.js";
|
|
8
|
+
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
9
|
+
import { GLTFLoader, type GLTF } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
10
|
+
import { useMediaQuery } from "../../hooks/use-media-query.ts";
|
|
11
|
+
import { cn } from "../../lib/utils.ts";
|
|
12
|
+
import { Button } from "../ui/button.tsx";
|
|
13
|
+
import { ratioOf, type ImageRatio } from "../ui/image.tsx";
|
|
14
|
+
import { Tooltip } from "../ui/tooltip.tsx";
|
|
15
|
+
|
|
16
|
+
/* A 3D model (glTF or GLB) in place, to turn and look at: @kujoforall/paper-ui/three.
|
|
17
|
+
|
|
18
|
+
Loading: a wireframe box traces itself in, edge by edge, on repeat, with a
|
|
19
|
+
line under it filling as the file downloads; then the model eases in, growing and settling as the
|
|
20
|
+
camera comes in to it, as a picture sharpens in.
|
|
21
|
+
|
|
22
|
+
Animation: a model's own animations wait at their first frame until Play
|
|
23
|
+
(`autoPlay` to start them at once); `animation` chooses which.
|
|
24
|
+
|
|
25
|
+
Moving: drag to turn it, scroll or pinch to zoom, right-drag or two fingers to
|
|
26
|
+
move it. From the keyboard, once focused: the arrows turn it, + and − zoom, 0
|
|
27
|
+
puts it back. Buttons for putting the view back, turning on its own, playing the
|
|
28
|
+
model's own animation and filling the screen. The view is framed to the model
|
|
29
|
+
whatever its size.
|
|
30
|
+
|
|
31
|
+
It draws only when something moves, and not at all while off screen or in a
|
|
32
|
+
hidden tab. Reduced motion skips the entrance and does not turn on its own.
|
|
33
|
+
Everything it made is let go of on unmount. Needs `three` (an optional peer
|
|
34
|
+
dependency, from 0.160). */
|
|
35
|
+
|
|
36
|
+
export type ModelInfo = { animations: string[]; size: { x: number; y: number; z: number } };
|
|
37
|
+
|
|
38
|
+
export function ModelViewer({
|
|
39
|
+
src,
|
|
40
|
+
alt,
|
|
41
|
+
ratio = "landscape",
|
|
42
|
+
autoRotate = false,
|
|
43
|
+
animation = 0,
|
|
44
|
+
autoPlay = false,
|
|
45
|
+
draco,
|
|
46
|
+
pending = false,
|
|
47
|
+
controls = true,
|
|
48
|
+
background,
|
|
49
|
+
onLoad,
|
|
50
|
+
onError,
|
|
51
|
+
className,
|
|
52
|
+
children,
|
|
53
|
+
}: {
|
|
54
|
+
src: string;
|
|
55
|
+
/** What the model is, for a screen reader. */
|
|
56
|
+
alt: string;
|
|
57
|
+
ratio?: ImageRatio;
|
|
58
|
+
/** Turn slowly on its own (not under reduced motion). */
|
|
59
|
+
autoRotate?: boolean;
|
|
60
|
+
/** Which of the model's animations to play, by name or number; null for none. */
|
|
61
|
+
animation?: string | number | null;
|
|
62
|
+
/** Start the animation playing; by default it waits, at its first frame, for Play. */
|
|
63
|
+
autoPlay?: boolean;
|
|
64
|
+
/** Where the Draco decoder lives, for a compressed model (e.g. "https://www.gstatic.com/draco/versioned/decoders/1.5.7/"). */
|
|
65
|
+
draco?: string;
|
|
66
|
+
/** The model is on its way but its address is not known yet (still uploading): shows the loading state. */
|
|
67
|
+
pending?: boolean;
|
|
68
|
+
/** Show the buttons. */
|
|
69
|
+
controls?: boolean;
|
|
70
|
+
/** A CSS colour behind the model; the surface's own by default. */
|
|
71
|
+
background?: string;
|
|
72
|
+
onLoad?: (info: ModelInfo) => void;
|
|
73
|
+
onError?: (error: Error) => void;
|
|
74
|
+
className?: string;
|
|
75
|
+
/** Over the model, top left: a caption, a badge. */
|
|
76
|
+
children?: ReactNode;
|
|
77
|
+
}) {
|
|
78
|
+
const box = useRef<HTMLDivElement>(null);
|
|
79
|
+
const canvasHost = useRef<HTMLDivElement>(null);
|
|
80
|
+
const help = useId();
|
|
81
|
+
const reduced = useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
82
|
+
const [progress, setProgress] = useState<number | null>(0);
|
|
83
|
+
const [state, setState] = useState<"loading" | "ready" | "error">("loading");
|
|
84
|
+
const [error, setError] = useState<string | null>(null);
|
|
85
|
+
const [rotating, setRotating] = useState(autoRotate);
|
|
86
|
+
const [playing, setPlaying] = useState(autoPlay);
|
|
87
|
+
const [clips, setClips] = useState<string[]>([]);
|
|
88
|
+
const [full, setFull] = useState(false);
|
|
89
|
+
const [touched, setTouched] = useState(false);
|
|
90
|
+
// The live scene, for the buttons and keys to reach.
|
|
91
|
+
const world = useRef<{
|
|
92
|
+
camera: THREE.PerspectiveCamera;
|
|
93
|
+
controls: OrbitControls;
|
|
94
|
+
home: { position: THREE.Vector3; target: THREE.Vector3 };
|
|
95
|
+
mixer: THREE.AnimationMixer | null;
|
|
96
|
+
actions: THREE.AnimationAction[];
|
|
97
|
+
clipsByName: Map<string, THREE.AnimationAction>;
|
|
98
|
+
flyTo: (position: THREE.Vector3, target: THREE.Vector3, ms?: number) => void;
|
|
99
|
+
wake: () => void;
|
|
100
|
+
} | null>(null);
|
|
101
|
+
const latest = useRef({ onLoad, onError, reduced });
|
|
102
|
+
latest.current = { onLoad, onError, reduced };
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
const host = canvasHost.current;
|
|
106
|
+
if (!host) return;
|
|
107
|
+
let disposed = false;
|
|
108
|
+
setState("loading");
|
|
109
|
+
setProgress(pending ? null : 0);
|
|
110
|
+
setError(null);
|
|
111
|
+
if (pending) return;
|
|
112
|
+
|
|
113
|
+
let renderer: THREE.WebGLRenderer;
|
|
114
|
+
try {
|
|
115
|
+
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
|
|
116
|
+
} catch {
|
|
117
|
+
setState("error");
|
|
118
|
+
setError("This browser can't show 3D models.");
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
122
|
+
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
123
|
+
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
124
|
+
renderer.domElement.style.display = "block";
|
|
125
|
+
renderer.domElement.setAttribute("aria-hidden", "true");
|
|
126
|
+
host.appendChild(renderer.domElement);
|
|
127
|
+
|
|
128
|
+
const scene = new THREE.Scene();
|
|
129
|
+
const pmrem = new THREE.PMREMGenerator(renderer);
|
|
130
|
+
const room = new RoomEnvironment();
|
|
131
|
+
const environment = pmrem.fromScene(room, 0.04);
|
|
132
|
+
scene.environment = environment.texture;
|
|
133
|
+
const camera = new THREE.PerspectiveCamera(35, 1, 0.01, 1000);
|
|
134
|
+
const orbit = new OrbitControls(camera, renderer.domElement);
|
|
135
|
+
orbit.enableDamping = true;
|
|
136
|
+
orbit.dampingFactor = 0.08;
|
|
137
|
+
orbit.autoRotateSpeed = 1.2;
|
|
138
|
+
|
|
139
|
+
// The time between frames, kept by hand: THREE.Clock is deprecated from r185,
|
|
140
|
+
// and its replacement is not in every three this supports (from 0.160).
|
|
141
|
+
let lastFrame = performance.now();
|
|
142
|
+
let mixer: THREE.AnimationMixer | null = null;
|
|
143
|
+
let model: THREE.Object3D | null = null;
|
|
144
|
+
let visible = true;
|
|
145
|
+
let dirty = true;
|
|
146
|
+
// A camera flight (the entrance, a reset): from, to, start time, length.
|
|
147
|
+
let flight: { from: [THREE.Vector3, THREE.Vector3]; to: [THREE.Vector3, THREE.Vector3]; start: number; ms: number } | null = null;
|
|
148
|
+
let grow: { start: number; ms: number } | null = null;
|
|
149
|
+
const ease = (t: number) => 1 - Math.pow(1 - t, 3);
|
|
150
|
+
|
|
151
|
+
const flyTo = (position: THREE.Vector3, target: THREE.Vector3, ms = 450) => {
|
|
152
|
+
if (latest.current.reduced) {
|
|
153
|
+
camera.position.copy(position);
|
|
154
|
+
orbit.target.copy(target);
|
|
155
|
+
orbit.update();
|
|
156
|
+
dirty = true;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
flight = { from: [camera.position.clone(), orbit.target.clone()], to: [position.clone(), target.clone()], start: performance.now(), ms };
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const size = () => {
|
|
163
|
+
const { clientWidth: w, clientHeight: h } = host;
|
|
164
|
+
if (!w || !h) return;
|
|
165
|
+
renderer.setSize(w, h, false);
|
|
166
|
+
renderer.domElement.style.width = "100%";
|
|
167
|
+
renderer.domElement.style.height = "100%";
|
|
168
|
+
camera.aspect = w / h;
|
|
169
|
+
camera.updateProjectionMatrix();
|
|
170
|
+
dirty = true;
|
|
171
|
+
};
|
|
172
|
+
const resize = new ResizeObserver(size);
|
|
173
|
+
resize.observe(host);
|
|
174
|
+
size();
|
|
175
|
+
const seen = new IntersectionObserver(([entry]) => (visible = entry?.isIntersecting ?? true));
|
|
176
|
+
seen.observe(host);
|
|
177
|
+
orbit.addEventListener("change", () => (dirty = true));
|
|
178
|
+
orbit.addEventListener("start", () => setTouched(true));
|
|
179
|
+
|
|
180
|
+
renderer.setAnimationLoop(() => {
|
|
181
|
+
// Off screen or in a hidden tab: nothing drawn, and the clock kept current, so
|
|
182
|
+
// the animation picks up where it was rather than jumping ahead.
|
|
183
|
+
if (!visible || document.hidden) {
|
|
184
|
+
lastFrame = performance.now();
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const now = performance.now();
|
|
188
|
+
const delta = (now - lastFrame) / 1000;
|
|
189
|
+
lastFrame = now;
|
|
190
|
+
if (flight) {
|
|
191
|
+
const t = Math.min(1, (now - flight.start) / flight.ms);
|
|
192
|
+
camera.position.lerpVectors(flight.from[0], flight.to[0], ease(t));
|
|
193
|
+
orbit.target.lerpVectors(flight.from[1], flight.to[1], ease(t));
|
|
194
|
+
if (t === 1) flight = null;
|
|
195
|
+
dirty = true;
|
|
196
|
+
}
|
|
197
|
+
if (grow && model) {
|
|
198
|
+
const t = Math.min(1, (now - grow.start) / grow.ms);
|
|
199
|
+
model.scale.setScalar(0.9 + 0.1 * ease(t));
|
|
200
|
+
if (t === 1) grow = null;
|
|
201
|
+
dirty = true;
|
|
202
|
+
}
|
|
203
|
+
if (mixer && mixer.timeScale !== 0) {
|
|
204
|
+
mixer.update(delta);
|
|
205
|
+
dirty = true;
|
|
206
|
+
}
|
|
207
|
+
// Damping and turning on its own move the camera inside update().
|
|
208
|
+
if (orbit.update() || orbit.autoRotate) dirty = true;
|
|
209
|
+
if (dirty) {
|
|
210
|
+
renderer.render(scene, camera);
|
|
211
|
+
dirty = false;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const loader = new GLTFLoader();
|
|
216
|
+
let dracoLoader: DRACOLoader | null = null;
|
|
217
|
+
if (draco) {
|
|
218
|
+
dracoLoader = new DRACOLoader();
|
|
219
|
+
dracoLoader.setDecoderPath(draco);
|
|
220
|
+
loader.setDRACOLoader(dracoLoader);
|
|
221
|
+
}
|
|
222
|
+
loader.load(
|
|
223
|
+
src,
|
|
224
|
+
(gltf: GLTF) => {
|
|
225
|
+
if (disposed) return;
|
|
226
|
+
model = gltf.scene;
|
|
227
|
+
// Frame it: centred on the origin, the camera far enough back to see all of it.
|
|
228
|
+
const bounds = new THREE.Box3().setFromObject(model);
|
|
229
|
+
const sizeOf = bounds.getSize(new THREE.Vector3());
|
|
230
|
+
const centre = bounds.getCenter(new THREE.Vector3());
|
|
231
|
+
model.position.sub(centre);
|
|
232
|
+
const pivot = new THREE.Group();
|
|
233
|
+
pivot.add(model);
|
|
234
|
+
scene.add(pivot);
|
|
235
|
+
model = pivot;
|
|
236
|
+
const radius = sizeOf.length() / 2 || 1;
|
|
237
|
+
const distance = radius / Math.sin(THREE.MathUtils.degToRad(camera.fov / 2)) * 1.05;
|
|
238
|
+
const home = { position: new THREE.Vector3(0.55, 0.3, 1).normalize().multiplyScalar(distance), target: new THREE.Vector3() };
|
|
239
|
+
camera.near = distance / 100;
|
|
240
|
+
camera.far = distance * 20;
|
|
241
|
+
camera.updateProjectionMatrix();
|
|
242
|
+
orbit.minDistance = radius * 0.6;
|
|
243
|
+
orbit.maxDistance = distance * 4;
|
|
244
|
+
orbit.target.copy(home.target);
|
|
245
|
+
|
|
246
|
+
if (latest.current.reduced) {
|
|
247
|
+
camera.position.copy(home.position);
|
|
248
|
+
} else {
|
|
249
|
+
camera.position.copy(home.position).multiplyScalar(1.35);
|
|
250
|
+
flyTo(home.position, home.target, 900);
|
|
251
|
+
grow = { start: performance.now(), ms: 700 };
|
|
252
|
+
pivot.scale.setScalar(0.9);
|
|
253
|
+
}
|
|
254
|
+
orbit.update();
|
|
255
|
+
|
|
256
|
+
const clipsByName = new Map<string, THREE.AnimationAction>();
|
|
257
|
+
const actions: THREE.AnimationAction[] = [];
|
|
258
|
+
if (gltf.animations.length) {
|
|
259
|
+
mixer = new THREE.AnimationMixer(gltf.scene);
|
|
260
|
+
for (const clip of gltf.animations) {
|
|
261
|
+
const action = mixer.clipAction(clip);
|
|
262
|
+
actions.push(action);
|
|
263
|
+
clipsByName.set(clip.name, action);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
world.current = { camera, controls: orbit, home, mixer, actions, clipsByName, flyTo, wake: () => (dirty = true) };
|
|
267
|
+
setClips(gltf.animations.map((clip) => clip.name));
|
|
268
|
+
setProgress(1);
|
|
269
|
+
setState("ready");
|
|
270
|
+
dirty = true;
|
|
271
|
+
latest.current.onLoad?.({ animations: gltf.animations.map((clip) => clip.name), size: { x: sizeOf.x, y: sizeOf.y, z: sizeOf.z } });
|
|
272
|
+
},
|
|
273
|
+
(event) => {
|
|
274
|
+
if (!disposed) setProgress(event.lengthComputable && event.total ? event.loaded / event.total : null);
|
|
275
|
+
},
|
|
276
|
+
(err) => {
|
|
277
|
+
if (disposed) return;
|
|
278
|
+
setState("error");
|
|
279
|
+
setError("This model couldn't be loaded.");
|
|
280
|
+
latest.current.onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
281
|
+
},
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
return () => {
|
|
285
|
+
disposed = true;
|
|
286
|
+
world.current = null;
|
|
287
|
+
renderer.setAnimationLoop(null);
|
|
288
|
+
resize.disconnect();
|
|
289
|
+
seen.disconnect();
|
|
290
|
+
orbit.dispose();
|
|
291
|
+
mixer?.stopAllAction();
|
|
292
|
+
scene.traverse((object) => {
|
|
293
|
+
const mesh = object as THREE.Mesh;
|
|
294
|
+
mesh.geometry?.dispose();
|
|
295
|
+
const materials = Array.isArray(mesh.material) ? mesh.material : mesh.material ? [mesh.material] : [];
|
|
296
|
+
for (const material of materials) {
|
|
297
|
+
for (const value of Object.values(material)) if (value instanceof THREE.Texture) value.dispose();
|
|
298
|
+
material.dispose();
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
environment.dispose();
|
|
302
|
+
room.dispose?.();
|
|
303
|
+
pmrem.dispose();
|
|
304
|
+
dracoLoader?.dispose();
|
|
305
|
+
renderer.dispose();
|
|
306
|
+
// Let the browser have the context back now: switching models makes a new one,
|
|
307
|
+
// and browsers allow only a handful at once.
|
|
308
|
+
renderer.forceContextLoss();
|
|
309
|
+
renderer.domElement.remove();
|
|
310
|
+
};
|
|
311
|
+
}, [src, draco, pending]);
|
|
312
|
+
|
|
313
|
+
// Turning on its own, never under reduced motion.
|
|
314
|
+
useEffect(() => {
|
|
315
|
+
const w = world.current;
|
|
316
|
+
if (!w) return;
|
|
317
|
+
w.controls.autoRotate = rotating && !reduced;
|
|
318
|
+
w.wake();
|
|
319
|
+
}, [rotating, reduced, state]);
|
|
320
|
+
|
|
321
|
+
// The chosen animation, playing or held.
|
|
322
|
+
useEffect(() => {
|
|
323
|
+
const w = world.current;
|
|
324
|
+
if (!w?.mixer) return;
|
|
325
|
+
const chosen = animation === null ? undefined : typeof animation === "number" ? w.actions[animation] : w.clipsByName.get(animation);
|
|
326
|
+
w.mixer.timeScale = playing ? 1 : 0;
|
|
327
|
+
if (playing) {
|
|
328
|
+
for (const action of w.actions) if (action !== chosen) action.fadeOut(0.3);
|
|
329
|
+
chosen?.reset().fadeIn(0.3).play();
|
|
330
|
+
} else {
|
|
331
|
+
// Paused, there is no time for a crossfade: show the chosen one's first frame.
|
|
332
|
+
for (const action of w.actions) if (action !== chosen) action.stop();
|
|
333
|
+
chosen?.reset().setEffectiveWeight(1).play();
|
|
334
|
+
w.mixer.update(0);
|
|
335
|
+
}
|
|
336
|
+
w.wake();
|
|
337
|
+
}, [animation, playing, state]);
|
|
338
|
+
|
|
339
|
+
useEffect(() => {
|
|
340
|
+
const onChange = () => setFull(document.fullscreenElement === box.current);
|
|
341
|
+
document.addEventListener("fullscreenchange", onChange);
|
|
342
|
+
return () => document.removeEventListener("fullscreenchange", onChange);
|
|
343
|
+
}, []);
|
|
344
|
+
|
|
345
|
+
const reset = () => {
|
|
346
|
+
const w = world.current;
|
|
347
|
+
if (w) w.flyTo(w.home.position, w.home.target);
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
|
351
|
+
const w = world.current;
|
|
352
|
+
if (!w || e.target !== e.currentTarget) return;
|
|
353
|
+
const offset = w.camera.position.clone().sub(w.controls.target);
|
|
354
|
+
const spherical = new THREE.Spherical().setFromVector3(offset);
|
|
355
|
+
const turn = THREE.MathUtils.degToRad(e.shiftKey ? 45 : 15);
|
|
356
|
+
if (e.key === "ArrowLeft") spherical.theta -= turn;
|
|
357
|
+
else if (e.key === "ArrowRight") spherical.theta += turn;
|
|
358
|
+
else if (e.key === "ArrowUp") spherical.phi = Math.max(0.1, spherical.phi - turn);
|
|
359
|
+
else if (e.key === "ArrowDown") spherical.phi = Math.min(Math.PI - 0.1, spherical.phi + turn);
|
|
360
|
+
else if (e.key === "+" || e.key === "=") spherical.radius = Math.max(w.controls.minDistance, spherical.radius * 0.8);
|
|
361
|
+
else if (e.key === "-" || e.key === "_") spherical.radius = Math.min(w.controls.maxDistance, spherical.radius * 1.25);
|
|
362
|
+
else if (e.key === "0" || e.key === "Home") return (e.preventDefault(), reset());
|
|
363
|
+
else return;
|
|
364
|
+
e.preventDefault();
|
|
365
|
+
setTouched(true);
|
|
366
|
+
w.flyTo(new THREE.Vector3().setFromSpherical(spherical).add(w.controls.target), w.controls.target.clone(), 220);
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const loading = state === "loading";
|
|
370
|
+
const canFull = typeof document !== "undefined" && document.fullscreenEnabled;
|
|
371
|
+
|
|
372
|
+
return (
|
|
373
|
+
<div
|
|
374
|
+
ref={box}
|
|
375
|
+
role="application"
|
|
376
|
+
aria-roledescription="3D model"
|
|
377
|
+
aria-label={alt}
|
|
378
|
+
aria-describedby={help}
|
|
379
|
+
aria-busy={loading || undefined}
|
|
380
|
+
tabIndex={0}
|
|
381
|
+
onKeyDown={onKeyDown}
|
|
382
|
+
style={{ aspectRatio: full ? undefined : ratioOf(ratio), background: background ?? undefined }}
|
|
383
|
+
className={cn("group/model @container relative bg-surface-sunken rounded-surface overflow-hidden outline-offset-2 select-none", full && "rounded-none", className)}
|
|
384
|
+
>
|
|
385
|
+
<span id={help} className="sr-only">
|
|
386
|
+
Drag, or use the arrow keys, to turn it. Scroll, pinch, or plus and minus, to zoom. Zero puts it back.
|
|
387
|
+
</span>
|
|
388
|
+
<div
|
|
389
|
+
ref={canvasHost}
|
|
390
|
+
className={cn("absolute inset-0 transition-opacity duration-(--duration-reveal) ease-out-notion cursor-grab active:cursor-grabbing", loading || state === "error" ? "opacity-0" : "opacity-100")}
|
|
391
|
+
/>
|
|
392
|
+
|
|
393
|
+
{/* Loading: a ring that fills as it downloads, or a pulse when its size is unknown. */}
|
|
394
|
+
<div
|
|
395
|
+
aria-hidden={!loading}
|
|
396
|
+
className={cn("absolute inset-0 flex flex-col justify-center items-center gap-3 transition-opacity duration-(--duration-slow) pointer-events-none", loading ? "opacity-100" : "opacity-0")}
|
|
397
|
+
>
|
|
398
|
+
<span className="absolute inset-0 bg-tint-hover animate-pulse motion-reduce:animate-none" />
|
|
399
|
+
<TracingBox />
|
|
400
|
+
{/* How far, when the server says how large the file is. */}
|
|
401
|
+
<span className={cn("relative bg-hairline rounded-full w-24 h-0.5 overflow-hidden", progress === null && "invisible")}>
|
|
402
|
+
<span className="block bg-accent h-full transition-[width] duration-(--duration-slow) ease-out-notion" style={{ width: `${Math.round((progress ?? 0) * 100)}%` }} />
|
|
403
|
+
</span>
|
|
404
|
+
<span role="status" className="relative tabular-nums text-caption text-ink-secondary">
|
|
405
|
+
{loading ? (progress === null ? "Loading the model…" : `Loading the model, ${Math.round(progress * 100)}%`) : ""}
|
|
406
|
+
</span>
|
|
407
|
+
</div>
|
|
408
|
+
|
|
409
|
+
{state === "error" && (
|
|
410
|
+
<div role="alert" className="absolute inset-0 flex flex-col justify-center items-center gap-1.5 p-4 text-caption text-center text-ink-tertiary">
|
|
411
|
+
<Rotate3d className="size-6" strokeWidth={1.5} />
|
|
412
|
+
<span className="hidden @min-[12rem]:inline">{error}</span>
|
|
413
|
+
</div>
|
|
414
|
+
)}
|
|
415
|
+
|
|
416
|
+
{children !== undefined && <div className="top-3 left-3 absolute">{children}</div>}
|
|
417
|
+
|
|
418
|
+
{state === "ready" && (
|
|
419
|
+
<span
|
|
420
|
+
aria-hidden
|
|
421
|
+
className={cn(
|
|
422
|
+
"bottom-3 left-3 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-slow) pointer-events-none",
|
|
423
|
+
"@max-[20rem]:hidden",
|
|
424
|
+
touched && "opacity-0",
|
|
425
|
+
)}
|
|
426
|
+
>
|
|
427
|
+
<Rotate3d className="size-3.5" /> Drag to turn
|
|
428
|
+
</span>
|
|
429
|
+
)}
|
|
430
|
+
|
|
431
|
+
{controls && state === "ready" && (
|
|
432
|
+
<div className="right-2 bottom-2 absolute flex items-center gap-0.5 bg-on-media-strong p-0.5 rounded-control text-on-media-ink [&_button]:text-on-media-ink [&_button:hover]:bg-on-media">
|
|
433
|
+
{clips.length > 0 && animation !== null && (
|
|
434
|
+
<Tooltip content={playing ? "Pause" : "Play"}>
|
|
435
|
+
<Button variant="ghost" size="icon-sm" aria-label={playing ? "Pause the animation" : "Play the animation"} onClick={() => setPlaying((p) => !p)}>
|
|
436
|
+
{playing ? <Pause /> : <Play />}
|
|
437
|
+
</Button>
|
|
438
|
+
</Tooltip>
|
|
439
|
+
)}
|
|
440
|
+
{!reduced && (
|
|
441
|
+
<Tooltip content={rotating ? "Stop turning" : "Turn on its own"}>
|
|
442
|
+
<Button variant="ghost" size="icon-sm" aria-label="Turn on its own" aria-pressed={rotating} onClick={() => setRotating((r) => !r)} className="aria-pressed:bg-on-media">
|
|
443
|
+
<Rotate3d />
|
|
444
|
+
</Button>
|
|
445
|
+
</Tooltip>
|
|
446
|
+
)}
|
|
447
|
+
<Tooltip content="Reset the view" shortcut="0">
|
|
448
|
+
<Button variant="ghost" size="icon-sm" aria-label="Reset the view" onClick={reset}>
|
|
449
|
+
<RotateCcw />
|
|
450
|
+
</Button>
|
|
451
|
+
</Tooltip>
|
|
452
|
+
{canFull && (
|
|
453
|
+
<Tooltip content={full ? "Exit full screen" : "Full screen"}>
|
|
454
|
+
<Button
|
|
455
|
+
variant="ghost"
|
|
456
|
+
size="icon-sm"
|
|
457
|
+
aria-label={full ? "Exit full screen" : "Full screen"}
|
|
458
|
+
onClick={() => (full ? document.exitFullscreen() : box.current?.requestFullscreen())}
|
|
459
|
+
>
|
|
460
|
+
{full ? <Minimize /> : <Maximize />}
|
|
461
|
+
</Button>
|
|
462
|
+
</Tooltip>
|
|
463
|
+
)}
|
|
464
|
+
</div>
|
|
465
|
+
)}
|
|
466
|
+
</div>
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/* A wireframe box drawn edge by edge, like a circuit being traced: the three
|
|
471
|
+
edges at its back first (faint), then the back, the edges running forward and
|
|
472
|
+
the front face, each
|
|
473
|
+
a step after the last, then all fade and it draws again. Under reduced
|
|
474
|
+
motion it stands drawn. */
|
|
475
|
+
// The front face, and the back face up and to the right of it.
|
|
476
|
+
const F = { tl: [12, 24], tr: [40, 24], br: [40, 52], bl: [12, 52] } as const;
|
|
477
|
+
const B = { tl: [24, 12], tr: [52, 12], br: [52, 40], bl: [24, 40] } as const;
|
|
478
|
+
const line = (a: readonly number[], b: readonly number[]) => `M${a[0]} ${a[1]} L${b[0]} ${b[1]}`;
|
|
479
|
+
const EDGES: { d: string; back?: boolean }[] = [
|
|
480
|
+
// Behind: the hidden corner's three edges, faint.
|
|
481
|
+
{ d: line(B.bl, B.tl), back: true },
|
|
482
|
+
{ d: line(B.bl, B.br), back: true },
|
|
483
|
+
{ d: line(B.bl, F.bl), back: true },
|
|
484
|
+
// The back's top and side, the edges running forward, then the front face.
|
|
485
|
+
{ d: line(B.tl, B.tr) },
|
|
486
|
+
{ d: line(B.tr, B.br) },
|
|
487
|
+
{ d: line(B.tl, F.tl) },
|
|
488
|
+
{ d: line(B.tr, F.tr) },
|
|
489
|
+
{ d: line(B.br, F.br) },
|
|
490
|
+
{ d: line(F.tl, F.tr) },
|
|
491
|
+
{ d: line(F.tr, F.br) },
|
|
492
|
+
{ d: line(F.br, F.bl) },
|
|
493
|
+
{ d: line(F.bl, F.tl) },
|
|
494
|
+
];
|
|
495
|
+
|
|
496
|
+
function TracingBox() {
|
|
497
|
+
return (
|
|
498
|
+
<svg viewBox="0 0 64 64" className="relative size-20" aria-hidden fill="none" strokeLinecap="round" strokeLinejoin="round">
|
|
499
|
+
{EDGES.map((edge, i) => (
|
|
500
|
+
<path
|
|
501
|
+
key={i}
|
|
502
|
+
d={edge.d}
|
|
503
|
+
pathLength={1}
|
|
504
|
+
strokeDasharray="1 1"
|
|
505
|
+
strokeWidth={edge.back ? 1.25 : 1.75}
|
|
506
|
+
className={cn(edge.back ? "stroke-hairline-strong" : "stroke-accent", "animate-trace motion-reduce:animate-none")}
|
|
507
|
+
style={{ animationDelay: `${i * 90}ms` }}
|
|
508
|
+
/>
|
|
509
|
+
))}
|
|
510
|
+
{/* The corner nearest, lit as the drawing reaches it. */}
|
|
511
|
+
<circle cx={F.tr[0]} cy={F.tr[1]} r={1.75} className="fill-accent animate-trace motion-reduce:animate-none" style={{ animationDelay: "500ms" }} />
|
|
512
|
+
</svg>
|
|
513
|
+
);
|
|
514
|
+
}
|
|
@@ -46,7 +46,7 @@ export function AccentPicker() {
|
|
|
46
46
|
<button
|
|
47
47
|
type="button"
|
|
48
48
|
aria-label={`Colour theme: ${label(accent)}`}
|
|
49
|
-
className="flex h-
|
|
49
|
+
className="flex h-control-sm w-full items-center gap-2 rounded-control px-2 text-sm font-medium text-ink-secondary transition-colors duration-(--duration-fast) hover:bg-tint-hover data-[state=open]:bg-tint-hover"
|
|
50
50
|
>
|
|
51
51
|
<span className="flex size-5 items-center justify-center">
|
|
52
52
|
<Swatch accent={accent} />
|
|
@@ -56,7 +56,7 @@ export function AccentPicker() {
|
|
|
56
56
|
<ChevronsUpDown className="size-3.5 text-ink-tertiary" />
|
|
57
57
|
</button>
|
|
58
58
|
</DropdownMenuTrigger>
|
|
59
|
-
<DropdownMenuContent side="top" align="start" className="w-
|
|
59
|
+
<DropdownMenuContent side="top" align="start" className="w-(--radix-dropdown-menu-trigger-width)">
|
|
60
60
|
<DropdownMenuLabel>Colour theme</DropdownMenuLabel>
|
|
61
61
|
<DropdownMenuRadioGroup value={accent} onValueChange={(next) => choose(next as Accent)}>
|
|
62
62
|
{ACCENTS.map((a) => (
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
4
|
+
import { createContext, useCallback, useContext, useRef, useState, type ComponentProps, type ReactNode } from "react";
|
|
5
|
+
import { cn } from "../../lib/utils.ts";
|
|
6
|
+
import { Button } from "./button.tsx";
|
|
7
|
+
import { dialogPanelClasses, overlayClasses } from "./dialog.tsx";
|
|
8
|
+
|
|
9
|
+
/* A question that must be answered before anything else: "Delete these 3 pages?"
|
|
10
|
+
Unlike a Dialog it has no close button and a press outside does not dismiss it;
|
|
11
|
+
Escape answers no. Focus starts on Cancel, the safe answer. It looks like a
|
|
12
|
+
Dialog, a bottom sheet on a phone.
|
|
13
|
+
|
|
14
|
+
Most of the time, `useConfirm()` is all an app needs:
|
|
15
|
+
const confirm = useConfirm();
|
|
16
|
+
if (await confirm({ title: "Delete 3 pages?", confirmLabel: "Delete", danger: true })) …
|
|
17
|
+
with a ConfirmProvider somewhere above. */
|
|
18
|
+
|
|
19
|
+
export const AlertDialog = AlertDialogPrimitive.Root;
|
|
20
|
+
export const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
21
|
+
|
|
22
|
+
export function AlertDialogContent({ className, children, ...props }: ComponentProps<typeof AlertDialogPrimitive.Content>) {
|
|
23
|
+
return (
|
|
24
|
+
<AlertDialogPrimitive.Portal>
|
|
25
|
+
<AlertDialogPrimitive.Overlay className={overlayClasses} />
|
|
26
|
+
<AlertDialogPrimitive.Content
|
|
27
|
+
className={cn(dialogPanelClasses, "max-w-md", className)}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</AlertDialogPrimitive.Content>
|
|
32
|
+
</AlertDialogPrimitive.Portal>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function AlertDialogHeader({ className, ...props }: ComponentProps<"div">) {
|
|
37
|
+
return <div className={cn("px-5 pt-5", className)} {...props} />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function AlertDialogTitle({ className, ...props }: ComponentProps<typeof AlertDialogPrimitive.Title>) {
|
|
41
|
+
return <AlertDialogPrimitive.Title className={cn("font-semibold text-h3 text-ink", className)} {...props} />;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function AlertDialogDescription({ className, ...props }: ComponentProps<typeof AlertDialogPrimitive.Description>) {
|
|
45
|
+
return <AlertDialogPrimitive.Description className={cn("mt-1.5 text-ink-secondary text-sm", className)} {...props} />;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function AlertDialogFooter({ className, ...props }: ComponentProps<"div">) {
|
|
49
|
+
return <div className={cn("flex flex-wrap justify-end items-center gap-2 px-5 pt-5 pb-5", className)} {...props} />;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The safe answer. Takes focus when the question opens. */
|
|
53
|
+
export function AlertDialogCancel({ children = "Cancel", ...props }: ComponentProps<typeof AlertDialogPrimitive.Cancel>) {
|
|
54
|
+
return (
|
|
55
|
+
<AlertDialogPrimitive.Cancel asChild {...props}>
|
|
56
|
+
<Button variant="ghost">{children}</Button>
|
|
57
|
+
</AlertDialogPrimitive.Cancel>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The answer that goes ahead. `danger` when it cannot be undone. */
|
|
62
|
+
export function AlertDialogAction({ children = "Confirm", danger = false, ...props }: ComponentProps<typeof AlertDialogPrimitive.Action> & { danger?: boolean }) {
|
|
63
|
+
return (
|
|
64
|
+
<AlertDialogPrimitive.Action asChild {...props}>
|
|
65
|
+
<Button variant={danger ? "danger" : "primary"}>{children}</Button>
|
|
66
|
+
</AlertDialogPrimitive.Action>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ── confirm() ─────────────────────────────────────────────────────────────── */
|
|
71
|
+
|
|
72
|
+
export type ConfirmOptions = {
|
|
73
|
+
title: ReactNode;
|
|
74
|
+
description?: ReactNode;
|
|
75
|
+
confirmLabel?: string;
|
|
76
|
+
cancelLabel?: string;
|
|
77
|
+
/** It cannot be undone: the confirm button is the danger fill. */
|
|
78
|
+
danger?: boolean;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const ConfirmContext = createContext<((options: ConfirmOptions) => Promise<boolean>) | null>(null);
|
|
82
|
+
|
|
83
|
+
/** Asks a question and resolves true (confirmed) or false (cancelled, Escape). Needs a ConfirmProvider above. */
|
|
84
|
+
export function useConfirm(): (options: ConfirmOptions) => Promise<boolean> {
|
|
85
|
+
const confirm = useContext(ConfirmContext);
|
|
86
|
+
if (confirm === null) throw new Error("useConfirm must be used inside ConfirmProvider");
|
|
87
|
+
return confirm;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function ConfirmProvider({ children }: { children: ReactNode }) {
|
|
91
|
+
const [asking, setAsking] = useState<ConfirmOptions | null>(null);
|
|
92
|
+
const [open, setOpen] = useState(false);
|
|
93
|
+
const answer = useRef<(yes: boolean) => void>(() => {});
|
|
94
|
+
|
|
95
|
+
const confirm = useCallback(
|
|
96
|
+
(options: ConfirmOptions) =>
|
|
97
|
+
new Promise<boolean>((resolve) => {
|
|
98
|
+
answer.current(false); // a question still open is answered no
|
|
99
|
+
answer.current = resolve;
|
|
100
|
+
setAsking(options);
|
|
101
|
+
setOpen(true);
|
|
102
|
+
}),
|
|
103
|
+
[],
|
|
104
|
+
);
|
|
105
|
+
const settle = (yes: boolean) => {
|
|
106
|
+
answer.current(yes);
|
|
107
|
+
answer.current = () => {};
|
|
108
|
+
setOpen(false);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<ConfirmContext.Provider value={confirm}>
|
|
113
|
+
{children}
|
|
114
|
+
<AlertDialog open={open} onOpenChange={(o) => !o && settle(false)}>
|
|
115
|
+
{asking && (
|
|
116
|
+
// Focus goes to Cancel on every screen. (A dialog with a text field keeps
|
|
117
|
+
// it off on a touch screen so the keyboard stays down, but here there are
|
|
118
|
+
// only buttons, and leaving focus behind on the page would leave a screen
|
|
119
|
+
// reader outside the question, and Enter on the page asking it again.)
|
|
120
|
+
<AlertDialogContent>
|
|
121
|
+
<AlertDialogHeader>
|
|
122
|
+
<AlertDialogTitle>{asking.title}</AlertDialogTitle>
|
|
123
|
+
{asking.description && <AlertDialogDescription>{asking.description}</AlertDialogDescription>}
|
|
124
|
+
</AlertDialogHeader>
|
|
125
|
+
<AlertDialogFooter>
|
|
126
|
+
<AlertDialogCancel onClick={() => settle(false)}>{asking.cancelLabel ?? "Cancel"}</AlertDialogCancel>
|
|
127
|
+
<AlertDialogAction danger={asking.danger} onClick={() => settle(true)}>
|
|
128
|
+
{asking.confirmLabel ?? "Confirm"}
|
|
129
|
+
</AlertDialogAction>
|
|
130
|
+
</AlertDialogFooter>
|
|
131
|
+
</AlertDialogContent>
|
|
132
|
+
)}
|
|
133
|
+
</AlertDialog>
|
|
134
|
+
</ConfirmContext.Provider>
|
|
135
|
+
);
|
|
136
|
+
}
|