@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,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
|
+
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ArrowDownWideNarrow, ArrowLeft, ArrowRight, ArrowUpNarrowWide, EyeOff, Maximize2, Plus } from "lucide-react";
|
|
4
|
+
import { useRef, useState, type KeyboardEvent, type PointerEvent } from "react";
|
|
5
|
+
import { isEmpty, shownProperties, type Property, type Row, type Value, type View } from "../../../lib/database.ts";
|
|
6
|
+
import { cn } from "../../../lib/utils.ts";
|
|
7
|
+
import { Button } from "../button.tsx";
|
|
8
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "../dropdown-menu.tsx";
|
|
9
|
+
import { Popover, PopoverAnchor, PopoverContent } from "../popover.tsx";
|
|
10
|
+
import { CellEditor, CellValue, editsInPopover } from "./cells.tsx";
|
|
11
|
+
import { PROPERTY_ICONS } from "./icons.ts";
|
|
12
|
+
|
|
13
|
+
/* The table view: a spreadsheet of the rows. One cell is current (the arrows move
|
|
14
|
+
it, Home and End to a row's ends); Enter, F2 or typing changes it, Escape puts
|
|
15
|
+
it back, Tab keeps and moves along. Space ticks a checkbox; Delete empties a
|
|
16
|
+
cell. A row's title has Open beside it. Columns are resized by their edge and
|
|
17
|
+
sorted, hidden and moved from their name's menu. It scrolls sideways inside
|
|
18
|
+
itself on a narrow screen. */
|
|
19
|
+
|
|
20
|
+
const MIN_WIDTH = 96;
|
|
21
|
+
const widthOf = (view: View, property: Property) => view.widths?.[property.id] ?? (property.type === "title" ? 260 : property.type === "checkbox" ? 110 : 180);
|
|
22
|
+
|
|
23
|
+
export function TableView({
|
|
24
|
+
properties,
|
|
25
|
+
rows,
|
|
26
|
+
view,
|
|
27
|
+
onViewChange,
|
|
28
|
+
onSetValue,
|
|
29
|
+
onAddRow,
|
|
30
|
+
onOpenRow,
|
|
31
|
+
}: {
|
|
32
|
+
properties: readonly Property[];
|
|
33
|
+
rows: readonly Row[];
|
|
34
|
+
view: View;
|
|
35
|
+
onViewChange: (view: View) => void;
|
|
36
|
+
onSetValue: (row: Row, property: Property, value: Value) => void;
|
|
37
|
+
onAddRow: () => void;
|
|
38
|
+
onOpenRow?: (row: Row) => void;
|
|
39
|
+
}) {
|
|
40
|
+
const columns = shownProperties(properties, view);
|
|
41
|
+
const [at, setAt] = useState<{ r: number; c: number }>({ r: 0, c: 0 });
|
|
42
|
+
// The cell being changed, by its row's id and its column: a row that moves (the
|
|
43
|
+
// change re-sorts it, or filters it out) takes the change with it, or ends it.
|
|
44
|
+
const [editingCell, setEditing] = useState<{ id: string; c: number; seed?: string } | null>(null);
|
|
45
|
+
const editingR = editingCell ? rows.findIndex((row) => row.id === editingCell.id) : -1;
|
|
46
|
+
const editing = editingCell && editingR !== -1 ? { r: editingR, c: editingCell.c, seed: editingCell.seed } : null;
|
|
47
|
+
const grid = useRef<HTMLDivElement>(null);
|
|
48
|
+
const r0 = Math.min(at.r, Math.max(0, rows.length - 1));
|
|
49
|
+
const c0 = Math.min(at.c, columns.length - 1);
|
|
50
|
+
|
|
51
|
+
// At once, so a second key pressed quickly comes from the new cell; a frame
|
|
52
|
+
// later as well, for a cell that is only now being drawn (a row just added).
|
|
53
|
+
// When a change ends without a move (Escape, a click elsewhere), focus comes
|
|
54
|
+
// back to the cell only if it has nowhere else to be: a click on the search or
|
|
55
|
+
// another cell keeps it there.
|
|
56
|
+
const focusCell = (r: number, c: number, onlyIfLost = false) => {
|
|
57
|
+
setAt({ r, c });
|
|
58
|
+
const find = () => grid.current?.querySelector<HTMLElement>(`[data-cell="${r}-${c}"]`);
|
|
59
|
+
if (!onlyIfLost) find()?.focus();
|
|
60
|
+
requestAnimationFrame(() => {
|
|
61
|
+
const cell = find();
|
|
62
|
+
const active = document.activeElement;
|
|
63
|
+
const lost = active === null || active === document.body || (onlyIfLost ? false : !cell?.contains(active));
|
|
64
|
+
if (cell && lost) cell.focus();
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const done = (move?: "down" | "right" | "left") => {
|
|
68
|
+
const from = editing ?? { r: r0, c: c0 };
|
|
69
|
+
setEditing(null);
|
|
70
|
+
if (move === "down") focusCell(Math.min(rows.length - 1, from.r + 1), from.c);
|
|
71
|
+
else if (move === "right") focusCell(from.r, Math.min(columns.length - 1, from.c + 1));
|
|
72
|
+
else if (move === "left") focusCell(from.r, Math.max(0, from.c - 1));
|
|
73
|
+
else focusCell(from.r, from.c, true);
|
|
74
|
+
};
|
|
75
|
+
const startEditing = (r: number, c: number, seed?: string) => setEditing({ id: rows[r]!.id, c, seed });
|
|
76
|
+
|
|
77
|
+
const onKeyDown = (e: KeyboardEvent<HTMLDivElement>, r: number, c: number) => {
|
|
78
|
+
// Keys on what is inside the cell (Open, a link) are theirs.
|
|
79
|
+
if (editing || e.target !== e.currentTarget) return;
|
|
80
|
+
const row = rows[r]!;
|
|
81
|
+
const property = columns[c]!;
|
|
82
|
+
const moves: Record<string, [number, number]> = { ArrowUp: [-1, 0], ArrowDown: [1, 0], ArrowLeft: [0, -1], ArrowRight: [0, 1] };
|
|
83
|
+
if (moves[e.key]) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
const [dr, dc] = moves[e.key]!;
|
|
86
|
+
focusCell(Math.max(0, Math.min(rows.length - 1, r + dr)), Math.max(0, Math.min(columns.length - 1, c + dc)));
|
|
87
|
+
} else if (e.key === "Home" || e.key === "End") {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
focusCell(r, e.key === "Home" ? 0 : columns.length - 1);
|
|
90
|
+
} else if (e.key === " " && property.type === "checkbox") {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
onSetValue(row, property, row.values[property.id] !== true);
|
|
93
|
+
} else if (e.key === "Enter" || e.key === "F2") {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
if (property.type === "checkbox") onSetValue(row, property, row.values[property.id] !== true);
|
|
96
|
+
else startEditing(r, c);
|
|
97
|
+
} else if ((e.key === "Delete" || e.key === "Backspace") && property.type !== "title") {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
onSetValue(row, property, property.type === "checkbox" ? false : property.type === "multiSelect" ? [] : null);
|
|
100
|
+
} else if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey && !editsInPopover(property) && property.type !== "checkbox") {
|
|
101
|
+
// Typing starts a change with what was typed, as in a spreadsheet.
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
startEditing(r, c, e.key);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const resize = (e: PointerEvent<HTMLSpanElement>, property: Property) => {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
e.stopPropagation();
|
|
110
|
+
const startX = e.clientX;
|
|
111
|
+
const start = widthOf(view, property);
|
|
112
|
+
const el = e.currentTarget;
|
|
113
|
+
el.setPointerCapture(e.pointerId);
|
|
114
|
+
let width = start;
|
|
115
|
+
const th = el.closest("th")!;
|
|
116
|
+
const move = (ev: globalThis.PointerEvent) => {
|
|
117
|
+
width = Math.max(MIN_WIDTH, Math.round(start + ev.clientX - startX));
|
|
118
|
+
th.style.width = `${width}px`;
|
|
119
|
+
};
|
|
120
|
+
const up = () => {
|
|
121
|
+
el.removeEventListener("pointermove", move);
|
|
122
|
+
el.removeEventListener("pointerup", up);
|
|
123
|
+
el.removeEventListener("pointercancel", up);
|
|
124
|
+
if (width !== start) onViewChange({ ...view, widths: { ...view.widths, [property.id]: width } });
|
|
125
|
+
};
|
|
126
|
+
el.addEventListener("pointermove", move);
|
|
127
|
+
el.addEventListener("pointerup", up);
|
|
128
|
+
el.addEventListener("pointercancel", up);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Swaps two shown columns within the order of all of them, so a hidden column
|
|
132
|
+
// keeps its place for when it is shown again.
|
|
133
|
+
const moveColumn = (index: number, by: -1 | 1) => {
|
|
134
|
+
const to = index + by;
|
|
135
|
+
if (to < 0 || to >= columns.length) return;
|
|
136
|
+
const all = shownProperties(properties, { ...view, hidden: [] }).map((p) => p.id);
|
|
137
|
+
const a = all.indexOf(columns[index]!.id);
|
|
138
|
+
const b = all.indexOf(columns[to]!.id);
|
|
139
|
+
[all[a], all[b]] = [all[b]!, all[a]!];
|
|
140
|
+
onViewChange({ ...view, order: all });
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<div>
|
|
145
|
+
{/* Room under the table for a scrollbar, and New outside the scrolling, so the bar never covers it. */}
|
|
146
|
+
<div ref={grid} className="pb-1.5 overflow-x-auto overscroll-x-contain">
|
|
147
|
+
<table
|
|
148
|
+
role="grid"
|
|
149
|
+
aria-label={view.name}
|
|
150
|
+
aria-rowcount={rows.length + 1}
|
|
151
|
+
className="border-collapse text-sm table-fixed"
|
|
152
|
+
style={{ width: columns.reduce((w, p) => w + widthOf(view, p), 0) }}
|
|
153
|
+
>
|
|
154
|
+
<thead>
|
|
155
|
+
<tr>
|
|
156
|
+
{columns.map((property, c) => {
|
|
157
|
+
const Icon = PROPERTY_ICONS[property.type];
|
|
158
|
+
const sorted = view.sort.find((s) => s.property === property.id);
|
|
159
|
+
return (
|
|
160
|
+
<th
|
|
161
|
+
key={property.id}
|
|
162
|
+
scope="col"
|
|
163
|
+
aria-sort={sorted ? (sorted.direction === "asc" ? "ascending" : "descending") : undefined}
|
|
164
|
+
style={{ width: widthOf(view, property) }}
|
|
165
|
+
className="relative p-0 border-hairline border-y border-r last:border-r-0 font-normal text-ink-secondary text-left"
|
|
166
|
+
>
|
|
167
|
+
<DropdownMenu>
|
|
168
|
+
<DropdownMenuTrigger asChild>
|
|
169
|
+
<button
|
|
170
|
+
type="button"
|
|
171
|
+
className="flex items-center gap-1.5 hover:bg-tint-hover px-2 w-full h-control-md text-left"
|
|
172
|
+
>
|
|
173
|
+
<Icon className="size-3.5 text-ink-tertiary shrink-0" aria-hidden />
|
|
174
|
+
<span className="truncate">{property.name}</span>
|
|
175
|
+
{sorted &&
|
|
176
|
+
(sorted.direction === "asc" ? (
|
|
177
|
+
<ArrowUpNarrowWide className="ml-auto size-3.5" aria-hidden />
|
|
178
|
+
) : (
|
|
179
|
+
<ArrowDownWideNarrow className="ml-auto size-3.5" aria-hidden />
|
|
180
|
+
))}
|
|
181
|
+
</button>
|
|
182
|
+
</DropdownMenuTrigger>
|
|
183
|
+
<DropdownMenuContent align="start">
|
|
184
|
+
<DropdownMenuItem
|
|
185
|
+
onSelect={() => onViewChange({ ...view, sort: [{ property: property.id, direction: "asc" }] })}
|
|
186
|
+
>
|
|
187
|
+
<ArrowUpNarrowWide /> Sort ascending
|
|
188
|
+
</DropdownMenuItem>
|
|
189
|
+
<DropdownMenuItem
|
|
190
|
+
onSelect={() => onViewChange({ ...view, sort: [{ property: property.id, direction: "desc" }] })}
|
|
191
|
+
>
|
|
192
|
+
<ArrowDownWideNarrow /> Sort descending
|
|
193
|
+
</DropdownMenuItem>
|
|
194
|
+
<DropdownMenuSeparator />
|
|
195
|
+
<DropdownMenuItem disabled={c === 0} onSelect={() => moveColumn(c, -1)}>
|
|
196
|
+
<ArrowLeft /> Move left
|
|
197
|
+
</DropdownMenuItem>
|
|
198
|
+
<DropdownMenuItem disabled={c === columns.length - 1} onSelect={() => moveColumn(c, 1)}>
|
|
199
|
+
<ArrowRight /> Move right
|
|
200
|
+
</DropdownMenuItem>
|
|
201
|
+
{property.type !== "title" && (
|
|
202
|
+
<DropdownMenuItem onSelect={() => onViewChange({ ...view, hidden: [...view.hidden, property.id] })}>
|
|
203
|
+
<EyeOff /> Hide
|
|
204
|
+
</DropdownMenuItem>
|
|
205
|
+
)}
|
|
206
|
+
</DropdownMenuContent>
|
|
207
|
+
</DropdownMenu>
|
|
208
|
+
{/* The column's edge, dragged to resize. */}
|
|
209
|
+
<span
|
|
210
|
+
aria-hidden
|
|
211
|
+
onPointerDown={(e) => resize(e, property)}
|
|
212
|
+
className="top-0 -right-1 z-1 absolute hover:bg-accent/40 w-2 h-full cursor-col-resize touch-none"
|
|
213
|
+
/>
|
|
214
|
+
</th>
|
|
215
|
+
);
|
|
216
|
+
})}
|
|
217
|
+
</tr>
|
|
218
|
+
</thead>
|
|
219
|
+
<tbody>
|
|
220
|
+
{rows.map((row, r) => (
|
|
221
|
+
<tr key={row.id} className="group/tr">
|
|
222
|
+
{columns.map((property, c) => {
|
|
223
|
+
const current = r === r0 && c === c0;
|
|
224
|
+
const isEditing = editing?.r === r && editing.c === c;
|
|
225
|
+
const value = row.values[property.id];
|
|
226
|
+
const popover = editsInPopover(property);
|
|
227
|
+
return (
|
|
228
|
+
<td
|
|
229
|
+
key={property.id}
|
|
230
|
+
data-cell={`${r}-${c}`}
|
|
231
|
+
role="gridcell"
|
|
232
|
+
tabIndex={current && !isEditing ? 0 : -1}
|
|
233
|
+
aria-label={property.type === "checkbox" ? `${property.name}: ${value ? "yes" : "no"}` : undefined}
|
|
234
|
+
onKeyDown={(e) => onKeyDown(e, r, c)}
|
|
235
|
+
onClick={() => {
|
|
236
|
+
setAt({ r, c });
|
|
237
|
+
if (property.type === "checkbox") onSetValue(row, property, value !== true);
|
|
238
|
+
}}
|
|
239
|
+
onDoubleClick={() => property.type !== "checkbox" && startEditing(r, c)}
|
|
240
|
+
className={cn(
|
|
241
|
+
"relative p-0 border-hairline border-y border-r last:border-r-0 h-control-md align-middle outline-none",
|
|
242
|
+
"focus-visible:shadow-[inset_0_0_0_2px_var(--accent)]",
|
|
243
|
+
property.type === "number" && "text-right"
|
|
244
|
+
)}
|
|
245
|
+
>
|
|
246
|
+
{isEditing && !popover ? (
|
|
247
|
+
<div className="absolute inset-0 z-1 shadow-[inset_0_0_0_2px_var(--accent)]">
|
|
248
|
+
<CellEditor
|
|
249
|
+
property={property}
|
|
250
|
+
value={value}
|
|
251
|
+
seed={editing.seed}
|
|
252
|
+
onChange={(v) => onSetValue(row, property, v)}
|
|
253
|
+
onDone={done}
|
|
254
|
+
/>
|
|
255
|
+
</div>
|
|
256
|
+
) : (
|
|
257
|
+
<Popover open={isEditing && popover} onOpenChange={(open) => !open && done()}>
|
|
258
|
+
<PopoverAnchor asChild>
|
|
259
|
+
<div className="flex items-center gap-1 px-2 py-1 min-h-control-md overflow-hidden">
|
|
260
|
+
<CellValue
|
|
261
|
+
property={property}
|
|
262
|
+
value={value}
|
|
263
|
+
// A link in a cell is clicked, not tabbed to: the grid is one stop.
|
|
264
|
+
linkTabIndex={-1}
|
|
265
|
+
className={cn(property.type === "number" && "ml-auto")}
|
|
266
|
+
/>
|
|
267
|
+
{property.type === "title" && isEmpty(value ?? null) && (
|
|
268
|
+
<span className="text-ink-tertiary">Untitled</span>
|
|
269
|
+
)}
|
|
270
|
+
{property.type === "title" && onOpenRow && (
|
|
271
|
+
<Button
|
|
272
|
+
variant="secondary"
|
|
273
|
+
size="sm"
|
|
274
|
+
tabIndex={current ? 0 : -1}
|
|
275
|
+
onClick={(e) => {
|
|
276
|
+
e.stopPropagation();
|
|
277
|
+
onOpenRow(row);
|
|
278
|
+
}}
|
|
279
|
+
className="ml-auto h-6 text-caption affordance group-hover/tr:opacity-100 [@media(hover:none)]:opacity-100"
|
|
280
|
+
>
|
|
281
|
+
<Maximize2 /> Open
|
|
282
|
+
</Button>
|
|
283
|
+
)}
|
|
284
|
+
</div>
|
|
285
|
+
</PopoverAnchor>
|
|
286
|
+
{isEditing && popover && (
|
|
287
|
+
<PopoverContent align="start" className="p-0 w-auto">
|
|
288
|
+
<CellEditor
|
|
289
|
+
property={property}
|
|
290
|
+
value={value}
|
|
291
|
+
onChange={(v) => onSetValue(row, property, v)}
|
|
292
|
+
onDone={done}
|
|
293
|
+
/>
|
|
294
|
+
</PopoverContent>
|
|
295
|
+
)}
|
|
296
|
+
</Popover>
|
|
297
|
+
)}
|
|
298
|
+
</td>
|
|
299
|
+
);
|
|
300
|
+
})}
|
|
301
|
+
</tr>
|
|
302
|
+
))}
|
|
303
|
+
</tbody>
|
|
304
|
+
</table>
|
|
305
|
+
</div>
|
|
306
|
+
<Button variant="ghost" size="sm" onClick={onAddRow} className="text-ink-tertiary">
|
|
307
|
+
<Plus /> New
|
|
308
|
+
</Button>
|
|
309
|
+
</div>
|
|
310
|
+
);
|
|
311
|
+
}
|