@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,237 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Check } from "lucide-react";
|
|
4
|
+
import { useRef, useState, type KeyboardEvent } from "react";
|
|
5
|
+
import { useEscapeFirst } from "../../../hooks/use-escape-first.ts";
|
|
6
|
+
import { formatShortDay, fromISODate, toISODate } from "../../../lib/dates.ts";
|
|
7
|
+
import { isEmpty, type Property, type Value } from "../../../lib/database.ts";
|
|
8
|
+
import { isWebUrl } from "../../../lib/embed.ts";
|
|
9
|
+
import { cn } from "../../../lib/utils.ts";
|
|
10
|
+
import { Badge } from "../badge.tsx";
|
|
11
|
+
import { Calendar } from "../calendar.tsx";
|
|
12
|
+
import { MultiSelect } from "../multi-select.tsx";
|
|
13
|
+
import { optionClasses, stepActive } from "../listbox.ts";
|
|
14
|
+
|
|
15
|
+
/* A database's values: how each kind looks (CellValue) and the field each is
|
|
16
|
+
changed in (CellEditor). Shared by every view, so a value looks the same in a
|
|
17
|
+
table's cell, on a board's card and in a calendar's day. */
|
|
18
|
+
|
|
19
|
+
export function CellValue({
|
|
20
|
+
property,
|
|
21
|
+
value,
|
|
22
|
+
className,
|
|
23
|
+
plain = false,
|
|
24
|
+
linkTabIndex,
|
|
25
|
+
}: {
|
|
26
|
+
property: Property;
|
|
27
|
+
value: Value | undefined;
|
|
28
|
+
className?: string;
|
|
29
|
+
/** Draw a link as words: inside something that is itself pressed (a card, a list's line). */
|
|
30
|
+
plain?: boolean;
|
|
31
|
+
linkTabIndex?: number;
|
|
32
|
+
}) {
|
|
33
|
+
if (property.type === "checkbox")
|
|
34
|
+
return (
|
|
35
|
+
<span
|
|
36
|
+
role="img"
|
|
37
|
+
aria-label={value ? "Yes" : "No"}
|
|
38
|
+
className={cn(
|
|
39
|
+
"inline-flex justify-center items-center rounded-small size-4 shrink-0",
|
|
40
|
+
value ? "bg-accent-solid text-accent-ink" : "shadow-[inset_0_0_0_1.5px_var(--control-edge)]",
|
|
41
|
+
className,
|
|
42
|
+
)}
|
|
43
|
+
>
|
|
44
|
+
{value === true && <Check className="size-3" strokeWidth={3} />}
|
|
45
|
+
</span>
|
|
46
|
+
);
|
|
47
|
+
if (isEmpty(value ?? null)) return null;
|
|
48
|
+
switch (property.type) {
|
|
49
|
+
case "select": {
|
|
50
|
+
const o = property.options?.find((x) => x.id === value);
|
|
51
|
+
return o ? (
|
|
52
|
+
<Badge color={o.color} className={className}>
|
|
53
|
+
{o.name}
|
|
54
|
+
</Badge>
|
|
55
|
+
) : null;
|
|
56
|
+
}
|
|
57
|
+
case "multiSelect":
|
|
58
|
+
return (
|
|
59
|
+
<span className={cn("inline-flex flex-wrap gap-1", className)}>
|
|
60
|
+
{(value as string[]).map((id) => {
|
|
61
|
+
const o = property.options?.find((x) => x.id === id);
|
|
62
|
+
return o ? (
|
|
63
|
+
<Badge key={id} color={o.color}>
|
|
64
|
+
{o.name}
|
|
65
|
+
</Badge>
|
|
66
|
+
) : null;
|
|
67
|
+
})}
|
|
68
|
+
</span>
|
|
69
|
+
);
|
|
70
|
+
case "date": {
|
|
71
|
+
const d = fromISODate(String(value));
|
|
72
|
+
return <span className={cn("tabular-nums", className)}>{d ? formatShortDay(d) : String(value)}</span>;
|
|
73
|
+
}
|
|
74
|
+
case "number":
|
|
75
|
+
return <span className={cn("tabular-nums", className)}>{Number(value).toLocaleString()}</span>;
|
|
76
|
+
case "url": {
|
|
77
|
+
const url = String(value);
|
|
78
|
+
return isWebUrl(url) && !plain ? (
|
|
79
|
+
<a href={url} target="_blank" rel="noreferrer" tabIndex={linkTabIndex} className={cn("link truncate", className)} onClick={(e) => e.stopPropagation()}>
|
|
80
|
+
{url.replace(/^https?:\/\/(www\.)?/, "")}
|
|
81
|
+
</a>
|
|
82
|
+
) : (
|
|
83
|
+
<span className={className}>{url}</span>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
return <span className={cn("truncate", className)}>{String(value)}</span>;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* The field a value is changed in, in place (a table's cell) or in a popover
|
|
92
|
+
(a card). Words and numbers are an input: Enter keeps, Escape puts back. An
|
|
93
|
+
option is a list to choose from; options are a MultiSelect; a date a calendar.
|
|
94
|
+
`onDone` closes it. */
|
|
95
|
+
export function CellEditor({
|
|
96
|
+
property,
|
|
97
|
+
value,
|
|
98
|
+
seed,
|
|
99
|
+
onChange,
|
|
100
|
+
onDone,
|
|
101
|
+
}: {
|
|
102
|
+
property: Property;
|
|
103
|
+
value: Value | undefined;
|
|
104
|
+
/** What was typed to start the change, in place of the value (a spreadsheet's way). */
|
|
105
|
+
seed?: string;
|
|
106
|
+
onChange: (value: Value) => void;
|
|
107
|
+
onDone: (move?: "down" | "right" | "left") => void;
|
|
108
|
+
}) {
|
|
109
|
+
// Starts from what was typed, if anything; kept when it differs from the value
|
|
110
|
+
// itself (not from the seed, or typing one letter and Enter would keep nothing).
|
|
111
|
+
const [draft, setDraft] = useState(seed ?? (value === null || value === undefined ? "" : String(value)));
|
|
112
|
+
const input = useRef<HTMLInputElement>(null);
|
|
113
|
+
// Finished by a key (kept or put back): the blur that follows as focus returns
|
|
114
|
+
// to the cell must not keep it again, or Escape would keep what it puts back.
|
|
115
|
+
const finished = useRef(false);
|
|
116
|
+
// Escape puts the change back and nothing else, not the dialog the table is in.
|
|
117
|
+
useEscapeFirst(!editsInPopover(property) && property.type !== "checkbox", input, () => {
|
|
118
|
+
finished.current = true;
|
|
119
|
+
onDone();
|
|
120
|
+
});
|
|
121
|
+
const keep = () => {
|
|
122
|
+
const next: Value = property.type === "number" ? (draft.trim() === "" || Number.isNaN(Number(draft)) ? null : Number(draft)) : draft;
|
|
123
|
+
if (next !== (value ?? (property.type === "number" ? null : ""))) onChange(next);
|
|
124
|
+
};
|
|
125
|
+
const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
|
126
|
+
if (e.nativeEvent.isComposing) return;
|
|
127
|
+
if (e.key === "Enter") {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
keep();
|
|
130
|
+
finished.current = true;
|
|
131
|
+
onDone("down");
|
|
132
|
+
} else if (e.key === "Escape") {
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
e.stopPropagation();
|
|
135
|
+
finished.current = true;
|
|
136
|
+
onDone();
|
|
137
|
+
} else if (e.key === "Tab") {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
keep();
|
|
140
|
+
finished.current = true;
|
|
141
|
+
onDone(e.shiftKey ? "left" : "right");
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
switch (property.type) {
|
|
146
|
+
case "select": {
|
|
147
|
+
const options = property.options ?? [];
|
|
148
|
+
return (
|
|
149
|
+
<div
|
|
150
|
+
role="listbox"
|
|
151
|
+
aria-label={property.name}
|
|
152
|
+
className="flex flex-col p-1.5 min-w-48"
|
|
153
|
+
// The arrows move between options; Escape is the popover's own.
|
|
154
|
+
onKeyDown={(e) => {
|
|
155
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp" && e.key !== "Home" && e.key !== "End") return;
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
const all = [...e.currentTarget.querySelectorAll<HTMLElement>("[role=option]")];
|
|
158
|
+
const at = all.indexOf(document.activeElement as HTMLElement);
|
|
159
|
+
const next = stepActive(at, all.length, e.key);
|
|
160
|
+
if (next !== null) all[next]?.focus();
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
{[...options, null].map((o, i) => {
|
|
164
|
+
const id = o?.id ?? null;
|
|
165
|
+
return (
|
|
166
|
+
<button
|
|
167
|
+
key={id ?? "none"}
|
|
168
|
+
type="button"
|
|
169
|
+
role="option"
|
|
170
|
+
aria-selected={value === id || (id === null && isEmpty(value ?? null))}
|
|
171
|
+
autoFocus={value === id || (i === 0 && isEmpty(value ?? null))}
|
|
172
|
+
onClick={() => {
|
|
173
|
+
onChange(id);
|
|
174
|
+
onDone();
|
|
175
|
+
}}
|
|
176
|
+
className={cn(optionClasses, "hover:bg-tint-hover focus-visible:bg-tint-hover outline-none")}
|
|
177
|
+
>
|
|
178
|
+
{o ? <Badge color={o.color}>{o.name}</Badge> : <span className="text-ink-tertiary">No value</span>}
|
|
179
|
+
{(value === id || (id === null && isEmpty(value ?? null))) && <Check className="ml-auto size-4 text-ink-secondary" />}
|
|
180
|
+
</button>
|
|
181
|
+
);
|
|
182
|
+
})}
|
|
183
|
+
</div>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
case "multiSelect":
|
|
187
|
+
return (
|
|
188
|
+
<div className="p-2 w-72">
|
|
189
|
+
<MultiSelect
|
|
190
|
+
aria-label={property.name}
|
|
191
|
+
autoFocus
|
|
192
|
+
options={(property.options ?? []).map((o) => ({ value: o.id, label: o.name, color: o.color }))}
|
|
193
|
+
value={Array.isArray(value) ? value : []}
|
|
194
|
+
onChange={(ids) => onChange(ids)}
|
|
195
|
+
/>
|
|
196
|
+
</div>
|
|
197
|
+
);
|
|
198
|
+
case "date":
|
|
199
|
+
return (
|
|
200
|
+
<div>
|
|
201
|
+
<Calendar
|
|
202
|
+
mode="single"
|
|
203
|
+
autoFocus
|
|
204
|
+
selected={fromISODate(typeof value === "string" ? value : null)}
|
|
205
|
+
defaultMonth={fromISODate(typeof value === "string" ? value : null)}
|
|
206
|
+
onSelect={(day: Date | undefined) => {
|
|
207
|
+
onChange(day ? toISODate(day) : null);
|
|
208
|
+
onDone();
|
|
209
|
+
}}
|
|
210
|
+
/>
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
case "checkbox":
|
|
214
|
+
return null;
|
|
215
|
+
default:
|
|
216
|
+
return (
|
|
217
|
+
<input
|
|
218
|
+
ref={input}
|
|
219
|
+
autoFocus
|
|
220
|
+
aria-label={property.name}
|
|
221
|
+
inputMode={property.type === "number" ? "decimal" : property.type === "url" ? "url" : undefined}
|
|
222
|
+
value={draft}
|
|
223
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
224
|
+
onKeyDown={onKeyDown}
|
|
225
|
+
onBlur={() => {
|
|
226
|
+
if (finished.current) return;
|
|
227
|
+
keep();
|
|
228
|
+
onDone();
|
|
229
|
+
}}
|
|
230
|
+
className={cn("bg-surface px-2 py-1.5 outline-none w-full min-w-0 text-sm", property.type === "number" && "text-right tabular-nums")}
|
|
231
|
+
/>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Whether a property is changed in a popover (true) or in place (false), or toggled (checkbox). */
|
|
237
|
+
export const editsInPopover = (property: Property) => property.type === "select" || property.type === "multiSelect" || property.type === "date";
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { CalendarDays, Columns3, Copy, LayoutGrid, List, Plus, Settings2, Table2, Trash2, type LucideIcon } from "lucide-react";
|
|
4
|
+
import { useId, useState } from "react";
|
|
5
|
+
import { applyView, newView, type Property, type Row, type Value, type View, type ViewKind } from "../../../lib/database.ts";
|
|
6
|
+
import { cn } from "../../../lib/utils.ts";
|
|
7
|
+
import { Button } from "../button.tsx";
|
|
8
|
+
import {
|
|
9
|
+
DropdownMenu,
|
|
10
|
+
DropdownMenuCheckboxItem,
|
|
11
|
+
DropdownMenuContent,
|
|
12
|
+
DropdownMenuItem,
|
|
13
|
+
DropdownMenuLabel,
|
|
14
|
+
DropdownMenuRadioGroup,
|
|
15
|
+
DropdownMenuRadioItem,
|
|
16
|
+
DropdownMenuSeparator,
|
|
17
|
+
DropdownMenuTrigger,
|
|
18
|
+
} from "../dropdown-menu.tsx";
|
|
19
|
+
import { EmptyState } from "../empty-state.tsx";
|
|
20
|
+
import { FilterButton, SortButton } from "../filter-builder.tsx";
|
|
21
|
+
import { SearchField } from "../input.tsx";
|
|
22
|
+
import { CalendarView } from "./calendar-view.tsx";
|
|
23
|
+
import { BoardView, GalleryView, ListView } from "./card-views.tsx";
|
|
24
|
+
import { TableView } from "./table-view.tsx";
|
|
25
|
+
|
|
26
|
+
/* Notion's database: one set of rows with typed properties (lib/database), seen
|
|
27
|
+
through views: a table, a board, a gallery, a list, a calendar. The app owns the
|
|
28
|
+
rows and the views; this draws and edits them and reports every change.
|
|
29
|
+
|
|
30
|
+
Around the views: a row of the views' tabs (switch, add, duplicate, delete), and
|
|
31
|
+
a toolbar with search, Filter and Sort (kept per view), the view's options
|
|
32
|
+
(properties to show; what a board groups by and a calendar dates by) and New.
|
|
33
|
+
A row opens through `onOpenRow`: the app decides whether that is a dialog, a
|
|
34
|
+
Sheet or a page of its own.
|
|
35
|
+
|
|
36
|
+
Limits in v1: no virtualisation (comfortable to about 1,000 rows), no formulas,
|
|
37
|
+
relations or rollups, no grouping in the table. */
|
|
38
|
+
|
|
39
|
+
export const VIEW_ICONS: Record<ViewKind, LucideIcon> = { table: Table2, board: Columns3, gallery: LayoutGrid, list: List, calendar: CalendarDays };
|
|
40
|
+
|
|
41
|
+
let made = 0;
|
|
42
|
+
const freshId = (prefix: string) =>
|
|
43
|
+
typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `${prefix}-${Date.now().toString(36)}-${(made++).toString(36)}`;
|
|
44
|
+
|
|
45
|
+
export function Database({
|
|
46
|
+
properties,
|
|
47
|
+
rows,
|
|
48
|
+
views,
|
|
49
|
+
onRowsChange,
|
|
50
|
+
onViewsChange,
|
|
51
|
+
onOpenRow,
|
|
52
|
+
view: controlled,
|
|
53
|
+
onViewChange,
|
|
54
|
+
newRowId = () => freshId("row"),
|
|
55
|
+
title,
|
|
56
|
+
className,
|
|
57
|
+
}: {
|
|
58
|
+
properties: readonly Property[];
|
|
59
|
+
rows: readonly Row[];
|
|
60
|
+
views: readonly View[];
|
|
61
|
+
onRowsChange: (rows: Row[]) => void;
|
|
62
|
+
onViewsChange: (views: View[]) => void;
|
|
63
|
+
onOpenRow?: (row: Row) => void;
|
|
64
|
+
/** Which view shows, if the app keeps it (in the address, say). */
|
|
65
|
+
view?: string;
|
|
66
|
+
onViewChange?: (id: string) => void;
|
|
67
|
+
newRowId?: () => string;
|
|
68
|
+
/** Names the database for a screen reader, and is shown above the views. */
|
|
69
|
+
title?: string;
|
|
70
|
+
className?: string;
|
|
71
|
+
}) {
|
|
72
|
+
const [own, setOwn] = useState(views[0]?.id);
|
|
73
|
+
const uid = useId();
|
|
74
|
+
const currentId = controlled ?? own;
|
|
75
|
+
const view = views.find((v) => v.id === currentId) ?? views[0];
|
|
76
|
+
const [query, setQuery] = useState("");
|
|
77
|
+
const choose = (id: string) => {
|
|
78
|
+
setOwn(id);
|
|
79
|
+
onViewChange?.(id);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const setView = (next: View) => onViewsChange(views.map((v) => (v.id === next.id ? next : v)));
|
|
83
|
+
const setValue = (row: Row, property: Property, value: Value) => onRowsChange(rows.map((r) => (r.id === row.id ? { ...r, values: { ...r.values, [property.id]: value } } : r)));
|
|
84
|
+
// A new row takes the view's simple "is" filters (Status is Booked, Shared), so
|
|
85
|
+
// in a filtered view it stays in sight rather than vanishing as it is added.
|
|
86
|
+
const addRow = (values: Record<string, Value> = {}) => {
|
|
87
|
+
const fromFilters: Record<string, Value> = {};
|
|
88
|
+
if ((view?.match ?? "all") === "all")
|
|
89
|
+
for (const f of view?.filter ?? []) {
|
|
90
|
+
const p = properties.find((x) => x.id === f.property);
|
|
91
|
+
if (p && f.op === "is" && f.value !== undefined && f.value !== null && f.value !== "") fromFilters[p.id] = f.value;
|
|
92
|
+
}
|
|
93
|
+
const row: Row = { id: newRowId(), values: { ...fromFilters, ...values } };
|
|
94
|
+
onRowsChange([...rows, row]);
|
|
95
|
+
return row;
|
|
96
|
+
};
|
|
97
|
+
const addView = (kind: ViewKind) => {
|
|
98
|
+
const next = newView(kind, properties, freshId("view"));
|
|
99
|
+
onViewsChange([...views, next]);
|
|
100
|
+
choose(next.id);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
if (!view) return <EmptyState title="No views" action={<Button onClick={() => addView("table")}>Add a table view</Button>} />;
|
|
104
|
+
const shown = applyView(rows, properties, view, query);
|
|
105
|
+
const selects = properties.filter((p) => p.type === "select");
|
|
106
|
+
const dates = properties.filter((p) => p.type === "date");
|
|
107
|
+
const common = { properties, rows: shown, view, onOpenRow };
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<section aria-label={title ?? "Database"} className={cn("@container flex flex-col gap-2", className)}>
|
|
111
|
+
{title && <h2 className="font-semibold text-h2">{title}</h2>}
|
|
112
|
+
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
|
|
113
|
+
<div className="flex items-center gap-0.5 max-w-full">
|
|
114
|
+
<div role="tablist" aria-label="Views" className="flex items-center gap-0.5 min-w-0 overflow-x-auto [scrollbar-width:none]">
|
|
115
|
+
{views.map((v) => {
|
|
116
|
+
const Icon = VIEW_ICONS[v.kind];
|
|
117
|
+
const current = v.id === view.id;
|
|
118
|
+
return (
|
|
119
|
+
<button
|
|
120
|
+
key={v.id}
|
|
121
|
+
type="button"
|
|
122
|
+
role="tab"
|
|
123
|
+
id={`${uid}-tab-${v.id}`}
|
|
124
|
+
aria-controls={`${uid}-panel`}
|
|
125
|
+
aria-selected={current}
|
|
126
|
+
tabIndex={current ? 0 : -1}
|
|
127
|
+
onClick={() => choose(v.id)}
|
|
128
|
+
onKeyDown={(e) => {
|
|
129
|
+
const i = views.indexOf(v);
|
|
130
|
+
const to = e.key === "ArrowRight" ? i + 1 : e.key === "ArrowLeft" ? i - 1 : e.key === "Home" ? 0 : e.key === "End" ? views.length - 1 : null;
|
|
131
|
+
if (to === null) return;
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
const next = views[(to + views.length) % views.length]!;
|
|
134
|
+
choose(next.id);
|
|
135
|
+
(e.currentTarget.parentElement?.children[(to + views.length) % views.length] as HTMLElement | undefined)?.focus();
|
|
136
|
+
}}
|
|
137
|
+
className={cn(
|
|
138
|
+
"relative flex items-center gap-1.5 hover:bg-tint-hover px-2 rounded-control h-control-sm text-sm whitespace-nowrap shrink-0",
|
|
139
|
+
current ? "text-ink font-medium after:absolute after:inset-x-2 after:-bottom-1.25 after:h-0.5 after:rounded-full after:bg-ink after:content-['']" : "text-ink-secondary",
|
|
140
|
+
)}
|
|
141
|
+
>
|
|
142
|
+
<Icon className="size-4" aria-hidden />
|
|
143
|
+
{v.name}
|
|
144
|
+
</button>
|
|
145
|
+
);
|
|
146
|
+
})}
|
|
147
|
+
</div>
|
|
148
|
+
{/* Beside the tabs, not among them: it is not a view. */}
|
|
149
|
+
<DropdownMenu>
|
|
150
|
+
<DropdownMenuTrigger asChild>
|
|
151
|
+
<Button variant="ghost" size="icon-sm" aria-label="Add a view" className="text-ink-tertiary">
|
|
152
|
+
<Plus />
|
|
153
|
+
</Button>
|
|
154
|
+
</DropdownMenuTrigger>
|
|
155
|
+
<DropdownMenuContent align="start">
|
|
156
|
+
<DropdownMenuLabel>Add a view</DropdownMenuLabel>
|
|
157
|
+
{(Object.keys(VIEW_ICONS) as ViewKind[]).map((kind) => {
|
|
158
|
+
const Icon = VIEW_ICONS[kind];
|
|
159
|
+
return (
|
|
160
|
+
<DropdownMenuItem key={kind} onSelect={() => addView(kind)}>
|
|
161
|
+
<Icon /> {kind[0]!.toUpperCase() + kind.slice(1)}
|
|
162
|
+
</DropdownMenuItem>
|
|
163
|
+
);
|
|
164
|
+
})}
|
|
165
|
+
</DropdownMenuContent>
|
|
166
|
+
</DropdownMenu>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<div className="flex flex-wrap items-center gap-1 @lg:ml-auto">
|
|
170
|
+
<SearchField size="sm" value={query} onChange={setQuery} placeholder="Search" aria-label={`Search ${title ?? "the database"}`} className="w-40 @max-lg:w-full" />
|
|
171
|
+
<FilterButton properties={properties} filters={view.filter} onChange={(filter) => setView({ ...view, filter })} match={view.match ?? "all"} onMatchChange={(match) => setView({ ...view, match })} />
|
|
172
|
+
<SortButton properties={properties} sorts={view.sort} onChange={(sort) => setView({ ...view, sort })} />
|
|
173
|
+
<DropdownMenu>
|
|
174
|
+
<DropdownMenuTrigger asChild>
|
|
175
|
+
<Button variant="ghost" size="icon-sm" aria-label="View options">
|
|
176
|
+
<Settings2 />
|
|
177
|
+
</Button>
|
|
178
|
+
</DropdownMenuTrigger>
|
|
179
|
+
<DropdownMenuContent align="end" className="min-w-56">
|
|
180
|
+
{view.kind === "board" && (
|
|
181
|
+
<>
|
|
182
|
+
<DropdownMenuLabel>Group by</DropdownMenuLabel>
|
|
183
|
+
<DropdownMenuRadioGroup value={view.groupBy ?? ""} onValueChange={(groupBy) => setView({ ...view, groupBy })}>
|
|
184
|
+
{selects.map((p) => (
|
|
185
|
+
<DropdownMenuRadioItem key={p.id} value={p.id}>
|
|
186
|
+
{p.name}
|
|
187
|
+
</DropdownMenuRadioItem>
|
|
188
|
+
))}
|
|
189
|
+
</DropdownMenuRadioGroup>
|
|
190
|
+
<DropdownMenuSeparator />
|
|
191
|
+
</>
|
|
192
|
+
)}
|
|
193
|
+
{view.kind === "calendar" && (
|
|
194
|
+
<>
|
|
195
|
+
<DropdownMenuLabel>Date by</DropdownMenuLabel>
|
|
196
|
+
<DropdownMenuRadioGroup value={view.dateProperty ?? ""} onValueChange={(dateProperty) => setView({ ...view, dateProperty })}>
|
|
197
|
+
{dates.map((p) => (
|
|
198
|
+
<DropdownMenuRadioItem key={p.id} value={p.id}>
|
|
199
|
+
{p.name}
|
|
200
|
+
</DropdownMenuRadioItem>
|
|
201
|
+
))}
|
|
202
|
+
</DropdownMenuRadioGroup>
|
|
203
|
+
<DropdownMenuSeparator />
|
|
204
|
+
</>
|
|
205
|
+
)}
|
|
206
|
+
<DropdownMenuLabel>Properties shown</DropdownMenuLabel>
|
|
207
|
+
{properties
|
|
208
|
+
.filter((p) => p.type !== "title")
|
|
209
|
+
.map((p) => (
|
|
210
|
+
<DropdownMenuCheckboxItem
|
|
211
|
+
key={p.id}
|
|
212
|
+
checked={!view.hidden.includes(p.id)}
|
|
213
|
+
onSelect={(e) => e.preventDefault()}
|
|
214
|
+
onCheckedChange={(on) => setView({ ...view, hidden: on ? view.hidden.filter((h) => h !== p.id) : [...view.hidden, p.id] })}
|
|
215
|
+
>
|
|
216
|
+
{p.name}
|
|
217
|
+
</DropdownMenuCheckboxItem>
|
|
218
|
+
))}
|
|
219
|
+
<DropdownMenuSeparator />
|
|
220
|
+
<DropdownMenuItem
|
|
221
|
+
onSelect={() => {
|
|
222
|
+
const copy = { ...view, id: freshId("view"), name: `${view.name} copy` };
|
|
223
|
+
onViewsChange([...views, copy]);
|
|
224
|
+
choose(copy.id);
|
|
225
|
+
}}
|
|
226
|
+
>
|
|
227
|
+
<Copy /> Duplicate this view
|
|
228
|
+
</DropdownMenuItem>
|
|
229
|
+
<DropdownMenuItem
|
|
230
|
+
danger
|
|
231
|
+
disabled={views.length <= 1}
|
|
232
|
+
onSelect={() => {
|
|
233
|
+
const rest = views.filter((v) => v.id !== view.id);
|
|
234
|
+
onViewsChange(rest);
|
|
235
|
+
choose(rest[0]!.id);
|
|
236
|
+
}}
|
|
237
|
+
>
|
|
238
|
+
<Trash2 /> Delete this view
|
|
239
|
+
</DropdownMenuItem>
|
|
240
|
+
</DropdownMenuContent>
|
|
241
|
+
</DropdownMenu>
|
|
242
|
+
<Button
|
|
243
|
+
variant="primary"
|
|
244
|
+
size="sm"
|
|
245
|
+
onClick={() => {
|
|
246
|
+
// Added first, opened after: written as onOpenRow?.(addRow()), an app
|
|
247
|
+
// without onOpenRow would skip the call and its argument, adding nothing.
|
|
248
|
+
const row = addRow();
|
|
249
|
+
onOpenRow?.(row);
|
|
250
|
+
}}
|
|
251
|
+
>
|
|
252
|
+
<Plus /> New
|
|
253
|
+
</Button>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
<p className="sr-only" aria-live="polite">
|
|
258
|
+
{shown.length} of {rows.length} shown
|
|
259
|
+
</p>
|
|
260
|
+
|
|
261
|
+
<div role="tabpanel" id={`${uid}-panel`} aria-labelledby={`${uid}-tab-${view.id}`}>
|
|
262
|
+
{shown.length === 0 && rows.length > 0 && view.kind !== "board" && view.kind !== "calendar" ? (
|
|
263
|
+
<EmptyState compact title="Nothing matches" description="Change the search or the view's filters." />
|
|
264
|
+
) : view.kind === "table" ? (
|
|
265
|
+
// Its own cursor and edit state per view.
|
|
266
|
+
<TableView key={view.id} {...common} onViewChange={setView} onSetValue={setValue} onAddRow={() => addRow()} />
|
|
267
|
+
) : view.kind === "board" ? (
|
|
268
|
+
<BoardView {...common} onSetValue={setValue} onAddRow={addRow} />
|
|
269
|
+
) : view.kind === "gallery" ? (
|
|
270
|
+
<GalleryView {...common} />
|
|
271
|
+
) : view.kind === "list" ? (
|
|
272
|
+
<ListView {...common} />
|
|
273
|
+
) : (
|
|
274
|
+
<CalendarView {...common} onSetValue={setValue} onAddRow={addRow} />
|
|
275
|
+
)}
|
|
276
|
+
</div>
|
|
277
|
+
</section>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Calendar, CheckSquare, CircleChevronDown, Hash, Link, Tags, Text, Type, type LucideIcon } from "lucide-react";
|
|
2
|
+
import type { PropertyType } from "../../../lib/database.ts";
|
|
3
|
+
|
|
4
|
+
/** Each kind of property's icon, beside its name in a table's header and a builder's menus. */
|
|
5
|
+
export const PROPERTY_ICONS: Record<PropertyType, LucideIcon> = {
|
|
6
|
+
title: Type,
|
|
7
|
+
text: Text,
|
|
8
|
+
number: Hash,
|
|
9
|
+
select: CircleChevronDown,
|
|
10
|
+
multiSelect: Tags,
|
|
11
|
+
date: Calendar,
|
|
12
|
+
checkbox: CheckSquare,
|
|
13
|
+
url: Link,
|
|
14
|
+
};
|
|
15
|
+
|