@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,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Moon, Sun } from "lucide-react";
|
|
4
|
+
import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
|
|
5
|
+
import { isTheme, THEME_KEY, type Theme } from "../../lib/theme.ts";
|
|
6
|
+
import { Button } from "./button.tsx";
|
|
7
|
+
import { Tooltip } from "./tooltip.tsx";
|
|
8
|
+
|
|
9
|
+
type ThemeContextValue = { theme: Theme; resolved: "light" | "dark"; setTheme: (theme: Theme) => void };
|
|
10
|
+
|
|
11
|
+
const ThemeContext = createContext<ThemeContextValue | null>(null);
|
|
12
|
+
|
|
13
|
+
const prefersDark = (): boolean => typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
14
|
+
|
|
15
|
+
function read(storageKey: string): Theme {
|
|
16
|
+
try {
|
|
17
|
+
const stored = localStorage.getItem(storageKey);
|
|
18
|
+
return isTheme(stored) ? stored : "system";
|
|
19
|
+
} catch {
|
|
20
|
+
// Private windows and blocked site data both throw here.
|
|
21
|
+
return "system";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Holds the theme for everything inside it and puts the `dark` class on <html>.
|
|
26
|
+
"system" keeps following the OS after load, not just at it. Pair it with
|
|
27
|
+
themeInitScript() in <head> so the first paint is already right.
|
|
28
|
+
|
|
29
|
+
From triptrack and medialogue, 2026-12-05; it replaces the kit's animated toggle,
|
|
30
|
+
which had no system mode and could throw where storage is blocked. */
|
|
31
|
+
export function ThemeProvider({ children, storageKey = THEME_KEY }: { children: ReactNode; storageKey?: string }) {
|
|
32
|
+
const [theme, setThemeState] = useState<Theme>(() => (typeof window === "undefined" ? "system" : read(storageKey)));
|
|
33
|
+
const [systemDark, setSystemDark] = useState(prefersDark);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const query = window.matchMedia("(prefers-color-scheme: dark)");
|
|
37
|
+
const onChange = (event: MediaQueryListEvent) => setSystemDark(event.matches);
|
|
38
|
+
query.addEventListener("change", onChange);
|
|
39
|
+
return () => query.removeEventListener("change", onChange);
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
const resolved = theme === "system" ? (systemDark ? "dark" : "light") : theme;
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
document.documentElement.classList.toggle("dark", resolved === "dark");
|
|
46
|
+
}, [resolved]);
|
|
47
|
+
|
|
48
|
+
const setTheme = (next: Theme) => {
|
|
49
|
+
setThemeState(next);
|
|
50
|
+
try {
|
|
51
|
+
localStorage.setItem(storageKey, next);
|
|
52
|
+
} catch {
|
|
53
|
+
// Remembering the choice is a convenience, not a requirement.
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return <ThemeContext.Provider value={{ theme, resolved, setTheme }}>{children}</ThemeContext.Provider>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The theme chosen (`theme`), what it comes to now (`resolved`), and a way to change it. */
|
|
61
|
+
export function useTheme(): ThemeContextValue {
|
|
62
|
+
const value = useContext(ThemeContext);
|
|
63
|
+
if (value === null) throw new Error("useTheme must be used inside ThemeProvider");
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* One button between light and dark. Until it is pressed the app follows the
|
|
68
|
+
system; pressing it is a choice, and the choice is kept. To offer "system" again,
|
|
69
|
+
put the three THEMES in a Segmented or a menu and call setTheme. */
|
|
70
|
+
export function ThemeToggle() {
|
|
71
|
+
const { resolved, setTheme } = useTheme();
|
|
72
|
+
const next = resolved === "dark" ? "light" : "dark";
|
|
73
|
+
return (
|
|
74
|
+
<Tooltip content="Toggle theme" side="bottom">
|
|
75
|
+
<Button variant="ghost" size="icon-sm" aria-label={`Switch to ${next} mode`} onClick={() => setTheme(next)}>
|
|
76
|
+
{resolved === "dark" ? <Moon /> : <Sun />}
|
|
77
|
+
</Button>
|
|
78
|
+
</Tooltip>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useLayoutEffect, useRef, type KeyboardEvent } from "react";
|
|
4
|
+
import { durationLabel, formatTime, localHourCycle, minutesOf, nearest, timesEvery, type HourCycle } from "../../lib/time.ts";
|
|
5
|
+
import { cn } from "../../lib/utils.ts";
|
|
6
|
+
|
|
7
|
+
/* The times of a day, every `step` minutes, as a list to choose from: Google
|
|
8
|
+
Calendar's way. It opens on the chosen time (or the one nearest now), centred.
|
|
9
|
+
With `relativeTo` (an end time's start) it starts after that time and says how
|
|
10
|
+
long each is ("10:30 AM · 1 hr"). Rows are 28px with a mouse and 44px on a touch
|
|
11
|
+
screen.
|
|
12
|
+
|
|
13
|
+
`focus` mode: a listbox with one tab stop, the arrows moving between times,
|
|
14
|
+
Enter or a press choosing. `active` mode: for a list a text field drives (the
|
|
15
|
+
field keeps focus; `active` is the highlighted one, named by aria-activedescendant
|
|
16
|
+
on the field). */
|
|
17
|
+
export function TimeList({
|
|
18
|
+
value,
|
|
19
|
+
onChange,
|
|
20
|
+
step = 15,
|
|
21
|
+
hourCycle,
|
|
22
|
+
relativeTo,
|
|
23
|
+
label = "Times",
|
|
24
|
+
mode = "focus",
|
|
25
|
+
active,
|
|
26
|
+
onActive,
|
|
27
|
+
id,
|
|
28
|
+
className,
|
|
29
|
+
}: {
|
|
30
|
+
value: string | null;
|
|
31
|
+
onChange: (value: string) => void;
|
|
32
|
+
step?: number;
|
|
33
|
+
hourCycle?: HourCycle;
|
|
34
|
+
relativeTo?: string | null;
|
|
35
|
+
label?: string;
|
|
36
|
+
mode?: "focus" | "active";
|
|
37
|
+
active?: string | null;
|
|
38
|
+
onActive?: (time: string) => void;
|
|
39
|
+
/** The listbox's id; each option is `${id}-HHMM`. */
|
|
40
|
+
id?: string;
|
|
41
|
+
className?: string;
|
|
42
|
+
}) {
|
|
43
|
+
const cycle = hourCycle ?? localHourCycle();
|
|
44
|
+
const times = timesEvery(step, { after: relativeTo, include: value });
|
|
45
|
+
const list = useRef<HTMLDivElement>(null);
|
|
46
|
+
const anchor = value ?? nearest(times, relativeTo ?? undefined) ?? times[0];
|
|
47
|
+
const optionId = (t: string) => (id ? `${id}-${t.replace(":", "")}` : undefined);
|
|
48
|
+
|
|
49
|
+
// Open on the chosen time, centred. Set on the list itself: scrollIntoView would
|
|
50
|
+
// scroll every ancestor too, and the page would jump under the panel.
|
|
51
|
+
useLayoutEffect(() => {
|
|
52
|
+
const el = list.current;
|
|
53
|
+
const at = el?.querySelector<HTMLElement>(`[data-time="${mode === "active" && active ? active : anchor}"]`);
|
|
54
|
+
if (el && at) el.scrollTop = at.offsetTop - el.clientHeight / 2 + at.offsetHeight / 2;
|
|
55
|
+
}, [anchor, active, mode]);
|
|
56
|
+
|
|
57
|
+
const move = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
58
|
+
if (mode !== "focus") return;
|
|
59
|
+
const keys = ["ArrowDown", "ArrowUp", "Home", "End", "PageDown", "PageUp"];
|
|
60
|
+
if (!keys.includes(event.key)) return;
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
const items = [...(list.current?.querySelectorAll<HTMLElement>("[role=option]") ?? [])];
|
|
63
|
+
const at = items.indexOf(document.activeElement as HTMLElement);
|
|
64
|
+
const page = Math.max(1, Math.round(60 / step));
|
|
65
|
+
const next = { Home: 0, End: items.length - 1, ArrowDown: at + 1, ArrowUp: at - 1, PageDown: at + page, PageUp: at - page }[event.key]!;
|
|
66
|
+
items[Math.max(0, Math.min(items.length - 1, next))]?.focus();
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
ref={list}
|
|
72
|
+
id={id}
|
|
73
|
+
role="listbox"
|
|
74
|
+
aria-label={label}
|
|
75
|
+
onKeyDown={move}
|
|
76
|
+
className={cn("flex flex-col gap-px p-1.5 w-full min-w-40 h-64 overflow-y-auto overscroll-contain", className)}
|
|
77
|
+
>
|
|
78
|
+
{times.map((time) => {
|
|
79
|
+
const chosen = time === value;
|
|
80
|
+
const highlighted = mode === "active" && time === active;
|
|
81
|
+
return (
|
|
82
|
+
<button
|
|
83
|
+
key={time}
|
|
84
|
+
type="button"
|
|
85
|
+
role="option"
|
|
86
|
+
id={optionId(time)}
|
|
87
|
+
data-time={time}
|
|
88
|
+
aria-selected={chosen}
|
|
89
|
+
tabIndex={mode === "focus" && time === anchor ? 0 : -1}
|
|
90
|
+
onClick={() => onChange(time)}
|
|
91
|
+
onMouseDown={mode === "active" ? (e) => e.preventDefault() : undefined}
|
|
92
|
+
onMouseEnter={mode === "active" ? () => onActive?.(time) : undefined}
|
|
93
|
+
className={cn(
|
|
94
|
+
"flex justify-between items-center gap-3 px-2.5 rounded-control h-control-sm [@media(pointer:coarse)]:h-11 text-sm text-left tabular-nums whitespace-nowrap cursor-pointer shrink-0",
|
|
95
|
+
"transition-colors duration-(--duration-instant)",
|
|
96
|
+
chosen ? "bg-accent-solid font-medium text-accent-ink" : highlighted ? "bg-tint-hover text-ink" : "text-ink hover:bg-tint-hover",
|
|
97
|
+
)}
|
|
98
|
+
>
|
|
99
|
+
<span>{formatTime(time, cycle)}</span>
|
|
100
|
+
{relativeTo && <span className={cn("text-caption", chosen ? "text-accent-ink" : "text-ink-tertiary")}>{durationLabel(minutesOf(time) - minutesOf(relativeTo))}</span>}
|
|
101
|
+
</button>
|
|
102
|
+
);
|
|
103
|
+
})}
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
4
|
+
import { Clock, X } from "lucide-react";
|
|
5
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
6
|
+
import { useMediaQuery } from "../../hooks/use-media-query.ts";
|
|
7
|
+
import { isTime } from "../../lib/dates.ts";
|
|
8
|
+
import { formatTime, localHourCycle, minutesOf, nearest, parseTime, timesEvery, type HourCycle } from "../../lib/time.ts";
|
|
9
|
+
import { cn } from "../../lib/utils.ts";
|
|
10
|
+
import { FieldButton } from "./field-button.tsx";
|
|
11
|
+
import { Input } from "./input.tsx";
|
|
12
|
+
import { PickerPanel } from "./picker-panel.tsx";
|
|
13
|
+
import { TimeList } from "./time-list.tsx";
|
|
14
|
+
import { useEscapeFirst } from "../../hooks/use-escape-first.ts";
|
|
15
|
+
|
|
16
|
+
/* A time of day, as Google Calendar and Linear take one.
|
|
17
|
+
|
|
18
|
+
With a mouse it is a field to type in: "9", "930", "9:30pm", "noon" all read as
|
|
19
|
+
meant (lib/time), and a list of times opens under it, on the nearest; the arrows
|
|
20
|
+
move through it, Enter takes the highlighted one or what was typed, leaving the
|
|
21
|
+
field keeps a valid time and puts back an invalid one.
|
|
22
|
+
|
|
23
|
+
On a touch screen it is a field to press: the list opens (as a sheet on a phone)
|
|
24
|
+
with large rows, and no keyboard comes up.
|
|
25
|
+
|
|
26
|
+
The value is `HH:MM` on a 24-hour clock, what a form and a `time` column hold;
|
|
27
|
+
it is shown on the reader's own clock (9:30 PM or 21:30) unless `hourCycle` says.
|
|
28
|
+
With `relativeTo`, an end time's list starts after that time and gives each
|
|
29
|
+
one's length. Anything not a time passed in shows as empty. */
|
|
30
|
+
|
|
31
|
+
export interface TimePickerProps {
|
|
32
|
+
/** `HH:MM`, 24-hour, or null for none. */
|
|
33
|
+
value: string | null;
|
|
34
|
+
onChange: (value: string | null) => void;
|
|
35
|
+
/** Minutes between the listed times. Any time can still be typed. */
|
|
36
|
+
minuteStep?: number;
|
|
37
|
+
hourCycle?: HourCycle;
|
|
38
|
+
/** The start of a span: the list starts after it and gives lengths. */
|
|
39
|
+
relativeTo?: string | null;
|
|
40
|
+
/** Show the cross that empties it. On by default; turn off for a required time. */
|
|
41
|
+
clearable?: boolean;
|
|
42
|
+
/** Sends the value with a form, as a hidden field of this name. */
|
|
43
|
+
name?: string;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
size?: "sm" | "md" | "lg";
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
invalid?: boolean;
|
|
48
|
+
id?: string;
|
|
49
|
+
className?: string;
|
|
50
|
+
"aria-label"?: string;
|
|
51
|
+
"aria-labelledby"?: string;
|
|
52
|
+
"aria-describedby"?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function TimePicker(props: TimePickerProps) {
|
|
56
|
+
// A mouse or trackpad types; a finger presses. Decided as the device says, live.
|
|
57
|
+
const fine = useMediaQuery("(pointer: fine)");
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
{fine ? <TypedTime {...props} /> : <PressedTime {...props} />}
|
|
61
|
+
{props.name !== undefined && <input type="hidden" name={props.name} value={isTime(props.value) ? props.value : ""} />}
|
|
62
|
+
</>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function TypedTime({
|
|
67
|
+
value,
|
|
68
|
+
onChange,
|
|
69
|
+
minuteStep = 15,
|
|
70
|
+
hourCycle,
|
|
71
|
+
relativeTo,
|
|
72
|
+
clearable = true,
|
|
73
|
+
placeholder = "Pick a time",
|
|
74
|
+
size,
|
|
75
|
+
disabled,
|
|
76
|
+
invalid,
|
|
77
|
+
id,
|
|
78
|
+
className,
|
|
79
|
+
// Sent by the hidden field TimePicker draws, never by the visible one.
|
|
80
|
+
name: _name,
|
|
81
|
+
...aria
|
|
82
|
+
}: TimePickerProps) {
|
|
83
|
+
const cycle = hourCycle ?? localHourCycle();
|
|
84
|
+
const time = isTime(value) ? value : null;
|
|
85
|
+
const shown = time === null ? "" : formatTime(time, cycle);
|
|
86
|
+
const [text, setText] = useState(shown);
|
|
87
|
+
const [open, setOpen] = useState(false);
|
|
88
|
+
const [active, setActive] = useState<string | null>(null);
|
|
89
|
+
const field = useRef<HTMLInputElement>(null);
|
|
90
|
+
const listId = useId();
|
|
91
|
+
const times = timesEvery(minuteStep, { after: relativeTo, include: time });
|
|
92
|
+
|
|
93
|
+
// Follow the value while it is not being typed in.
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (document.activeElement !== field.current) setText(shown);
|
|
96
|
+
}, [shown]);
|
|
97
|
+
|
|
98
|
+
const commit = (next: string | null) => {
|
|
99
|
+
setOpen(false);
|
|
100
|
+
setActive(null);
|
|
101
|
+
if (next === null) {
|
|
102
|
+
setText(shown);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
setText(formatTime(next, cycle));
|
|
106
|
+
if (next !== time) onChange(next);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Escape closes the list and nothing else, before a dialog around it hears it.
|
|
110
|
+
useEscapeFirst(open, field, () => {
|
|
111
|
+
setOpen(false);
|
|
112
|
+
setText(shown);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<PopoverPrimitive.Root open={open && !disabled}>
|
|
117
|
+
<PopoverPrimitive.Anchor asChild>
|
|
118
|
+
<div className={cn("w-full min-w-0", className)}>
|
|
119
|
+
<Input
|
|
120
|
+
ref={field}
|
|
121
|
+
id={id}
|
|
122
|
+
size={size}
|
|
123
|
+
role="combobox"
|
|
124
|
+
aria-expanded={open}
|
|
125
|
+
aria-controls={open ? listId : undefined}
|
|
126
|
+
aria-autocomplete="list"
|
|
127
|
+
aria-activedescendant={open && active ? `${listId}-${active.replace(":", "")}` : undefined}
|
|
128
|
+
aria-invalid={invalid || undefined}
|
|
129
|
+
autoComplete="off"
|
|
130
|
+
disabled={disabled}
|
|
131
|
+
placeholder={placeholder}
|
|
132
|
+
value={text}
|
|
133
|
+
start={<Clock aria-hidden />}
|
|
134
|
+
end={
|
|
135
|
+
clearable && time !== null && !disabled ? (
|
|
136
|
+
<button
|
|
137
|
+
type="button"
|
|
138
|
+
aria-label="Clear the time"
|
|
139
|
+
onClick={() => {
|
|
140
|
+
onChange(null);
|
|
141
|
+
setText("");
|
|
142
|
+
field.current?.focus();
|
|
143
|
+
}}
|
|
144
|
+
className="flex justify-center items-center hover:bg-tint-active -mr-1 rounded-small size-5 text-ink-tertiary hover:text-ink [&_svg]:size-3.5"
|
|
145
|
+
>
|
|
146
|
+
<X />
|
|
147
|
+
</button>
|
|
148
|
+
) : undefined
|
|
149
|
+
}
|
|
150
|
+
onFocus={(e) => {
|
|
151
|
+
e.currentTarget.select();
|
|
152
|
+
setOpen(true);
|
|
153
|
+
setActive(time ?? nearest(times, relativeTo) ?? null);
|
|
154
|
+
}}
|
|
155
|
+
onChange={(e) => {
|
|
156
|
+
setText(e.target.value);
|
|
157
|
+
setOpen(true);
|
|
158
|
+
const typed = parseTime(e.target.value);
|
|
159
|
+
if (typed) setActive(times.includes(typed) ? typed : (nearest(times, typed) ?? null));
|
|
160
|
+
}}
|
|
161
|
+
onBlur={() => {
|
|
162
|
+
if (text.trim() === "") {
|
|
163
|
+
// Emptied: that clears it, if it may be cleared; otherwise the time stays.
|
|
164
|
+
setOpen(false);
|
|
165
|
+
if (clearable) {
|
|
166
|
+
if (time !== null) onChange(null);
|
|
167
|
+
setText("");
|
|
168
|
+
} else setText(shown);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
// A time is kept; anything else is put back as it was.
|
|
172
|
+
commit(parseTime(text));
|
|
173
|
+
}}
|
|
174
|
+
onKeyDown={(e) => {
|
|
175
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
setOpen(true);
|
|
178
|
+
const at = active ? times.indexOf(active) : -1;
|
|
179
|
+
const next = e.key === "ArrowDown" ? Math.min(times.length - 1, at + 1) : Math.max(0, at === -1 ? times.length - 1 : at - 1);
|
|
180
|
+
setActive(times[next]);
|
|
181
|
+
setText(formatTime(times[next], cycle));
|
|
182
|
+
} else if (e.key === "Enter") {
|
|
183
|
+
const typed = parseTime(text);
|
|
184
|
+
if (open || typed) {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
commit(typed ?? active);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}}
|
|
190
|
+
{...aria}
|
|
191
|
+
/>
|
|
192
|
+
</div>
|
|
193
|
+
</PopoverPrimitive.Anchor>
|
|
194
|
+
<PopoverPrimitive.Portal>
|
|
195
|
+
<PopoverPrimitive.Content
|
|
196
|
+
onOpenAutoFocus={(e) => e.preventDefault()}
|
|
197
|
+
onCloseAutoFocus={(e) => e.preventDefault()}
|
|
198
|
+
onInteractOutside={(e) => {
|
|
199
|
+
if (e.target instanceof Node && field.current?.parentElement?.contains(e.target)) e.preventDefault();
|
|
200
|
+
}}
|
|
201
|
+
align="start"
|
|
202
|
+
sideOffset={4}
|
|
203
|
+
collisionPadding={8}
|
|
204
|
+
className="z-(--z-overlay) bg-surface-overlay shadow-popover rounded-surface outline-none w-(--radix-popper-anchor-width) min-w-44 animate-slide-in"
|
|
205
|
+
>
|
|
206
|
+
<TimeList
|
|
207
|
+
id={listId}
|
|
208
|
+
mode="active"
|
|
209
|
+
value={time}
|
|
210
|
+
active={active}
|
|
211
|
+
onActive={setActive}
|
|
212
|
+
onChange={(t) => commit(t)}
|
|
213
|
+
step={minuteStep}
|
|
214
|
+
hourCycle={cycle}
|
|
215
|
+
relativeTo={relativeTo}
|
|
216
|
+
className="h-56"
|
|
217
|
+
/>
|
|
218
|
+
</PopoverPrimitive.Content>
|
|
219
|
+
</PopoverPrimitive.Portal>
|
|
220
|
+
</PopoverPrimitive.Root>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function PressedTime({
|
|
225
|
+
value,
|
|
226
|
+
onChange,
|
|
227
|
+
minuteStep = 15,
|
|
228
|
+
hourCycle,
|
|
229
|
+
relativeTo,
|
|
230
|
+
clearable = true,
|
|
231
|
+
placeholder = "Pick a time",
|
|
232
|
+
size,
|
|
233
|
+
disabled,
|
|
234
|
+
invalid,
|
|
235
|
+
id,
|
|
236
|
+
className,
|
|
237
|
+
// Sent by the hidden field TimePicker draws, never by the visible one.
|
|
238
|
+
name: _name,
|
|
239
|
+
...aria
|
|
240
|
+
}: TimePickerProps) {
|
|
241
|
+
const [open, setOpen] = useState(false);
|
|
242
|
+
const cycle = hourCycle ?? localHourCycle();
|
|
243
|
+
const time = isTime(value) ? value : null;
|
|
244
|
+
return (
|
|
245
|
+
<PickerPanel
|
|
246
|
+
open={open}
|
|
247
|
+
onOpenChange={setOpen}
|
|
248
|
+
title={aria["aria-label"] ?? "Pick a time"}
|
|
249
|
+
// The list takes focus on the chosen time, so the arrows start there.
|
|
250
|
+
onOpenAutoFocus={(e) => {
|
|
251
|
+
e.preventDefault();
|
|
252
|
+
(e.currentTarget as HTMLElement).querySelector<HTMLElement>('[role=option][tabindex="0"]')?.focus({ preventScroll: true });
|
|
253
|
+
}}
|
|
254
|
+
trigger={
|
|
255
|
+
<FieldButton
|
|
256
|
+
icon={Clock}
|
|
257
|
+
id={id}
|
|
258
|
+
size={size}
|
|
259
|
+
disabled={disabled}
|
|
260
|
+
invalid={invalid}
|
|
261
|
+
placeholder={placeholder}
|
|
262
|
+
onClear={clearable ? () => onChange(null) : undefined}
|
|
263
|
+
clearLabel="Clear the time"
|
|
264
|
+
className={className}
|
|
265
|
+
{...aria}
|
|
266
|
+
>
|
|
267
|
+
{time === null ? null : <span className="tabular-nums">{formatTime(time, cycle)}</span>}
|
|
268
|
+
</FieldButton>
|
|
269
|
+
}
|
|
270
|
+
>
|
|
271
|
+
<TimeList
|
|
272
|
+
value={time}
|
|
273
|
+
onChange={(t) => {
|
|
274
|
+
onChange(t);
|
|
275
|
+
setOpen(false);
|
|
276
|
+
}}
|
|
277
|
+
step={minuteStep}
|
|
278
|
+
hourCycle={cycle}
|
|
279
|
+
relativeTo={relativeTo}
|
|
280
|
+
label={aria["aria-label"] ?? "Times"}
|
|
281
|
+
className="max-sm:w-full max-sm:h-[min(24rem,60dvh)]"
|
|
282
|
+
/>
|
|
283
|
+
</PickerPanel>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/* A start and an end time, in two fields: the end's list starts after the start
|
|
288
|
+
and gives each time's length. Moving the start moves the end with it, keeping
|
|
289
|
+
the length, as a calendar does. */
|
|
290
|
+
export function TimeRangePicker({
|
|
291
|
+
value,
|
|
292
|
+
onChange,
|
|
293
|
+
minuteStep = 15,
|
|
294
|
+
hourCycle,
|
|
295
|
+
names,
|
|
296
|
+
className,
|
|
297
|
+
labels = { from: "Start time", to: "End time" },
|
|
298
|
+
}: {
|
|
299
|
+
value: { from: string | null; to: string | null };
|
|
300
|
+
onChange: (value: { from: string | null; to: string | null }) => void;
|
|
301
|
+
minuteStep?: number;
|
|
302
|
+
hourCycle?: HourCycle;
|
|
303
|
+
names?: { from: string; to: string };
|
|
304
|
+
labels?: { from: string; to: string };
|
|
305
|
+
className?: string;
|
|
306
|
+
}) {
|
|
307
|
+
return (
|
|
308
|
+
<div className={cn("flex items-center gap-2", className)}>
|
|
309
|
+
<TimePicker
|
|
310
|
+
// Two fields share the row: each may shrink below an input's natural width.
|
|
311
|
+
className="flex-1 min-w-0"
|
|
312
|
+
aria-label={labels.from}
|
|
313
|
+
placeholder="Start"
|
|
314
|
+
value={value.from}
|
|
315
|
+
minuteStep={minuteStep}
|
|
316
|
+
hourCycle={hourCycle}
|
|
317
|
+
name={names?.from}
|
|
318
|
+
onChange={(from) => {
|
|
319
|
+
if (from && value.from && value.to) {
|
|
320
|
+
const length = minutesOf(value.to) - minutesOf(value.from);
|
|
321
|
+
const end = minutesOf(from) + length;
|
|
322
|
+
if (length > 0 && end < 24 * 60) return onChange({ from, to: `${String(Math.floor(end / 60)).padStart(2, "0")}:${String(end % 60).padStart(2, "0")}` });
|
|
323
|
+
}
|
|
324
|
+
onChange({ from, to: value.to && from && minutesOf(value.to) <= minutesOf(from) ? null : value.to });
|
|
325
|
+
}}
|
|
326
|
+
/>
|
|
327
|
+
<span aria-hidden className="text-ink-tertiary">
|
|
328
|
+
–
|
|
329
|
+
</span>
|
|
330
|
+
<TimePicker
|
|
331
|
+
// Two fields share the row: each may shrink below an input's natural width.
|
|
332
|
+
className="flex-1 min-w-0"
|
|
333
|
+
aria-label={labels.to}
|
|
334
|
+
placeholder="End"
|
|
335
|
+
value={value.to}
|
|
336
|
+
relativeTo={value.from}
|
|
337
|
+
minuteStep={minuteStep}
|
|
338
|
+
hourCycle={hourCycle}
|
|
339
|
+
name={names?.to}
|
|
340
|
+
onChange={(to) => onChange({ ...value, to })}
|
|
341
|
+
/>
|
|
342
|
+
</div>
|
|
343
|
+
);
|
|
344
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Check, Info, TriangleAlert, X } from "lucide-react";
|
|
4
|
+
import { createContext, useCallback, useContext, useEffect, useRef, useState, type ReactNode } from "react";
|
|
5
|
+
import { cn } from "../../lib/utils.ts";
|
|
6
|
+
import { Button } from "./button.tsx";
|
|
7
|
+
|
|
8
|
+
export type ToastTone = "done" | "info" | "error";
|
|
9
|
+
export type Toast = {
|
|
10
|
+
message: ReactNode;
|
|
11
|
+
tone?: ToastTone;
|
|
12
|
+
action?: { label: string; onAction: () => void };
|
|
13
|
+
/** How long it stays, in ms. 6s, or 10s when it has an action to reach. */
|
|
14
|
+
duration?: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const Ctx = createContext<(toast: Toast) => void>(() => {});
|
|
18
|
+
|
|
19
|
+
/** Says, briefly and out of the way, that something happened. Needs a ToastProvider above. */
|
|
20
|
+
export const useToast = () => useContext(Ctx);
|
|
21
|
+
|
|
22
|
+
const SHOWN_MS = 6000;
|
|
23
|
+
const WITH_ACTION_MS = 10000;
|
|
24
|
+
|
|
25
|
+
const TONES: Record<ToastTone, { icon: typeof Check; className: string }> = {
|
|
26
|
+
done: { icon: Check, className: "bg-tag-green-bg text-tag-green-ink" },
|
|
27
|
+
info: { icon: Info, className: "bg-tag-blue-bg text-tag-blue-ink" },
|
|
28
|
+
error: { icon: TriangleAlert, className: "bg-tag-red-bg text-tag-red-ink" },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/* One toast at a time, at the bottom of the window. A newer one replaces the one
|
|
32
|
+
showing. It leaves by itself; hovering or focusing it holds it, and its action or
|
|
33
|
+
its cross dismisses it. For telling what just happened, never for something that
|
|
34
|
+
needs an answer: that is a dialog.
|
|
35
|
+
|
|
36
|
+
A toast is at the far end of the page, out of a keyboard's easy reach, so F8
|
|
37
|
+
moves focus to it (as Radix's toasts do), Escape there dismisses it, and one
|
|
38
|
+
with an action stays 10 seconds rather than 6.
|
|
39
|
+
|
|
40
|
+
From endgame, 2026-12-05, with tones added. */
|
|
41
|
+
export function ToastProvider({ children }: { children: ReactNode }) {
|
|
42
|
+
const [toast, setToast] = useState<(Toast & { id: number }) | null>(null);
|
|
43
|
+
const [held, setHeld] = useState(false);
|
|
44
|
+
const next = useRef(0);
|
|
45
|
+
const box = useRef<HTMLDivElement>(null);
|
|
46
|
+
// Where focus was before F8 took it to the toast, to go back to.
|
|
47
|
+
const returnTo = useRef<HTMLElement | null>(null);
|
|
48
|
+
const show = useCallback((t: Toast) => setToast({ ...t, id: ++next.current }), []);
|
|
49
|
+
// Gone by its cross, its action or Escape: a toast that leaves never hears the
|
|
50
|
+
// pointer leave or the focus go, so `held` is let go of here, or every later
|
|
51
|
+
// toast would stay up. Focus taken to it by F8 goes back where it came from.
|
|
52
|
+
const dismiss = useCallback(() => {
|
|
53
|
+
const hadFocus = box.current?.contains(document.activeElement) ?? false;
|
|
54
|
+
setToast(null);
|
|
55
|
+
setHeld(false);
|
|
56
|
+
if (hadFocus) {
|
|
57
|
+
returnTo.current?.focus?.();
|
|
58
|
+
returnTo.current = null;
|
|
59
|
+
}
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (!toast || held) return;
|
|
64
|
+
const timer = setTimeout(() => setToast(null), toast.duration ?? (toast.action ? WITH_ACTION_MS : SHOWN_MS));
|
|
65
|
+
return () => clearTimeout(timer);
|
|
66
|
+
}, [toast, held]);
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!toast) return;
|
|
70
|
+
const onKey = (e: KeyboardEvent) => {
|
|
71
|
+
if (e.key === "F8") {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
if (!box.current?.contains(document.activeElement)) returnTo.current = document.activeElement as HTMLElement | null;
|
|
74
|
+
box.current?.querySelector<HTMLElement>("button")?.focus();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
window.addEventListener("keydown", onKey);
|
|
78
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
79
|
+
}, [toast]);
|
|
80
|
+
|
|
81
|
+
const tone = TONES[toast?.tone ?? "done"];
|
|
82
|
+
const Icon = tone.icon;
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Ctx.Provider value={show}>
|
|
86
|
+
{children}
|
|
87
|
+
<div
|
|
88
|
+
role="region"
|
|
89
|
+
aria-label="Notifications (F8)"
|
|
90
|
+
aria-live="polite"
|
|
91
|
+
className="z-(--z-toast) fixed inset-x-0 bottom-0 flex justify-center p-4 pb-[max(1rem,env(safe-area-inset-bottom))] pointer-events-none"
|
|
92
|
+
>
|
|
93
|
+
{toast && (
|
|
94
|
+
<div
|
|
95
|
+
ref={box}
|
|
96
|
+
key={toast.id}
|
|
97
|
+
onKeyDown={(e) => {
|
|
98
|
+
if (e.key === "Escape") dismiss();
|
|
99
|
+
}}
|
|
100
|
+
role={toast.tone === "error" ? "alert" : "status"}
|
|
101
|
+
onMouseEnter={() => setHeld(true)}
|
|
102
|
+
onMouseLeave={() => setHeld(false)}
|
|
103
|
+
onFocus={() => setHeld(true)}
|
|
104
|
+
onBlur={() => setHeld(false)}
|
|
105
|
+
className="flex items-center gap-3 bg-surface-overlay shadow-popover py-2 pr-2 pl-3 rounded-overlay max-w-[min(32rem,100%)] text-sm animate-toast-in pointer-events-auto"
|
|
106
|
+
>
|
|
107
|
+
<span className={cn("flex justify-center items-center rounded-full size-5 shrink-0", tone.className)}>
|
|
108
|
+
<Icon className="size-3" strokeWidth={3} />
|
|
109
|
+
</span>
|
|
110
|
+
<span className="flex-1 min-w-0">{toast.message}</span>
|
|
111
|
+
{toast.action && (
|
|
112
|
+
<Button
|
|
113
|
+
variant="ghost"
|
|
114
|
+
size="sm"
|
|
115
|
+
onClick={() => {
|
|
116
|
+
toast.action!.onAction();
|
|
117
|
+
dismiss();
|
|
118
|
+
}}
|
|
119
|
+
className="font-medium text-accent-text shrink-0"
|
|
120
|
+
>
|
|
121
|
+
{toast.action.label}
|
|
122
|
+
</Button>
|
|
123
|
+
)}
|
|
124
|
+
<Button variant="ghost" size="icon-sm" aria-label="Dismiss" onClick={dismiss} className="text-ink-tertiary hover:text-ink shrink-0">
|
|
125
|
+
<X />
|
|
126
|
+
</Button>
|
|
127
|
+
</div>
|
|
128
|
+
)}
|
|
129
|
+
</div>
|
|
130
|
+
</Ctx.Provider>
|
|
131
|
+
);
|
|
132
|
+
}
|