@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 @@
|
|
|
1
|
+
{"version":3,"file":"list-detail.d.ts","sourceRoot":"","sources":["../../../src/components/ui/list-detail.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAYtE,wBAAgB,UAAU,CAAC,EACvB,IAAI,EACJ,MAAM,EACN,UAAU,EACV,MAAM,EACN,SAAkB,EAClB,SAAkB,EAClB,WAAsB,EACtB,KAAK,EACL,SAAmB,EACnB,SAAS,GACZ,EAAE;IACC,IAAI,EAAE,SAAS,CAAC;IAChB,wCAAwC;IACxC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,4EAA4E;IAC5E,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,+BAqCA;AAKD,wBAAgB,QAAQ,CAAC,EACrB,KAAK,EACL,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACX,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,GAAG;IACzC,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,+BAoBA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronLeft, MousePointerClick } from "lucide-react";
|
|
4
|
+
import { cn } from "../../lib/utils.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
import { EmptyState } from "./empty-state.js";
|
|
7
|
+
/* A list beside the one chosen from it: mail, notes, a feed with a reader.
|
|
8
|
+
|
|
9
|
+
From 48rem of room (its own width, not the window's, so it works inside a
|
|
10
|
+
sidebar app) the two sit side by side, each scrolling on its own. Narrower, one
|
|
11
|
+
shows at a time: the list, or, once something is chosen (`showDetail`), the
|
|
12
|
+
detail with a way back (`onBack`). The arrow keys move between the list's items
|
|
13
|
+
(ListItem). It fills the height it is given: put it in a parent with a height. */
|
|
14
|
+
export function ListDetail({ list, detail, showDetail, onBack, backLabel = "Back", listLabel = "List", detailLabel = "Detail", empty, listWidth = "20rem", className, }) {
|
|
15
|
+
const move = (e) => {
|
|
16
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp")
|
|
17
|
+
return;
|
|
18
|
+
const items = [...e.currentTarget.querySelectorAll("[data-list-item]")];
|
|
19
|
+
const at = items.indexOf(document.activeElement);
|
|
20
|
+
if (at === -1)
|
|
21
|
+
return;
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
items[Math.max(0, Math.min(items.length - 1, at + (e.key === "ArrowDown" ? 1 : -1)))]?.focus();
|
|
24
|
+
};
|
|
25
|
+
return (_jsxs("div", { className: cn("@container flex h-full min-h-0", className), style: { "--list-w": listWidth }, children: [_jsx("section", { "aria-label": listLabel, onKeyDown: move, className: cn("flex flex-col w-full @3xl:w-(--list-w) min-h-0 overflow-y-auto overscroll-contain shrink-0", "@3xl:shadow-edge-r", showDetail && "@max-3xl:hidden"), children: list }), _jsxs("section", { "aria-label": detailLabel, className: cn("flex flex-col flex-1 min-w-0 min-h-0 overflow-y-auto overscroll-contain", !showDetail && "@max-3xl:hidden"), children: [showDetail && (_jsx("div", { className: "@3xl:hidden px-2 pt-2", children: _jsxs(Button, { variant: "ghost", size: "sm", onClick: onBack, children: [_jsx(ChevronLeft, {}), " ", backLabel] }) })), showDetail ? detail : empty ?? _jsx(EmptyState, { icon: MousePointerClick, title: "Nothing chosen", description: "Choose one from the list." })] })] }));
|
|
26
|
+
}
|
|
27
|
+
/* One item in a ListDetail's list: a title, a line under it, something at the end
|
|
28
|
+
(a date, a count). A button, or a link with `asChild`-free `href`. The chosen one
|
|
29
|
+
is tinted and says so (aria-current). */
|
|
30
|
+
export function ListItem({ title, description, meta, selected, className, ...props }) {
|
|
31
|
+
return (_jsxs("button", { type: "button", "data-list-item": true, "aria-current": selected ? "true" : undefined, className: cn("flex flex-col gap-0.5 mx-1.5 my-px px-3 py-2.5 w-[calc(100%-0.75rem)] rounded-control text-left transition-colors duration-(--duration-instant) outline-offset-[-2px]", selected ? "bg-tint-active" : "hover:bg-tint-hover", className), ...props, children: [_jsxs("span", { className: "flex items-baseline gap-2 w-full", children: [_jsx("span", { className: "flex-1 min-w-0 font-medium text-ink text-sm truncate", children: title }), meta !== undefined && _jsx("span", { className: "tabular-nums text-caption text-ink-tertiary shrink-0", children: meta })] }), description !== undefined && _jsx("span", { className: "w-full text-ink-secondary text-sm line-clamp-2", children: description })] }));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=list-detail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-detail.js","sourceRoot":"","sources":["../../../src/components/ui/list-detail.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC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0 +1,7 @@
|
|
|
1
|
+
/** A list's panel, as a popover. */
|
|
2
|
+
export declare const listSurfaceClasses = "bg-surface-overlay shadow-popover p-1.5 rounded-overlay outline-none overflow-y-auto overscroll-contain";
|
|
3
|
+
/** One option. Set data-active on the highlighted one. Taller by className where a row carries more (Spotlight's). */
|
|
4
|
+
export declare const optionClasses: string;
|
|
5
|
+
/** Where the highlight goes for a key: the arrows step and wrap round, Home and End jump. From nothing (-1), down is the first and up the last. Null for any other key. */
|
|
6
|
+
export declare function stepActive(current: number, count: number, key: string): number | null;
|
|
7
|
+
//# sourceMappingURL=listbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listbox.d.ts","sourceRoot":"","sources":["../../../src/components/ui/listbox.ts"],"names":[],"mappings":"AAOA,oCAAoC;AACpC,eAAO,MAAM,kBAAkB,4GAA4G,CAAC;AAE5I,sHAAsH;AACtH,eAAO,MAAM,aAAa,QAIf,CAAC;AAEZ,2KAA2K;AAC3K,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOrF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* The pieces every list of options shares: Combobox, MultiSelect, Spotlight, the
|
|
2
|
+
"/" CommandMenu. Kept in one place so their rows and panels stay one look (they
|
|
3
|
+
had drifted to three row heights, two paddings and two radii).
|
|
4
|
+
|
|
5
|
+
The highlight is `data-active`, not aria-selected: in a multiple choice list
|
|
6
|
+
(MultiSelect) aria-selected says chosen, and the two must not be confused. */
|
|
7
|
+
/** A list's panel, as a popover. */
|
|
8
|
+
export const listSurfaceClasses = "bg-surface-overlay shadow-popover p-1.5 rounded-overlay outline-none overflow-y-auto overscroll-contain";
|
|
9
|
+
/** One option. Set data-active on the highlighted one. Taller by className where a row carries more (Spotlight's). */
|
|
10
|
+
export const optionClasses = [
|
|
11
|
+
"flex items-center gap-2 px-2 rounded-control w-full h-control-sm text-sm text-left cursor-pointer select-none",
|
|
12
|
+
"transition-colors duration-(--duration-instant) data-[active=true]:bg-tint-hover",
|
|
13
|
+
"aria-disabled:pointer-events-none aria-disabled:text-ink-disabled",
|
|
14
|
+
].join(" ");
|
|
15
|
+
/** Where the highlight goes for a key: the arrows step and wrap round, Home and End jump. From nothing (-1), down is the first and up the last. Null for any other key. */
|
|
16
|
+
export function stepActive(current, count, key) {
|
|
17
|
+
if (count === 0)
|
|
18
|
+
return null;
|
|
19
|
+
if (key === "Home")
|
|
20
|
+
return 0;
|
|
21
|
+
if (key === "End")
|
|
22
|
+
return count - 1;
|
|
23
|
+
if (key === "ArrowDown")
|
|
24
|
+
return current < 0 ? 0 : (current + 1) % count;
|
|
25
|
+
if (key === "ArrowUp")
|
|
26
|
+
return current < 0 ? count - 1 : (current - 1 + count) % count;
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=listbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listbox.js","sourceRoot":"","sources":["../../../src/components/ui/listbox.ts"],"names":[],"mappings":"AAAA;;;;;gFAKgF;AAEhF,oCAAoC;AACpC,MAAM,CAAC,MAAM,kBAAkB,GAAG,yGAAyG,CAAC;AAE5I,sHAAsH;AACtH,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,+GAA+G;IAC/G,kFAAkF;IAClF,mEAAmE;CACtE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,2KAA2K;AAC3K,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,KAAa,EAAE,GAAW;IAClE,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7B,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,CAAC,CAAC;IAC7B,IAAI,GAAG,KAAK,KAAK;QAAE,OAAO,KAAK,GAAG,CAAC,CAAC;IACpC,IAAI,GAAG,KAAK,WAAW;QAAE,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;IACxE,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;IACtF,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../lib/utils.js";
|
|
3
3
|
export function MacWindowHeader({ title, className }) {
|
|
4
|
-
return (_jsxs("div", { className: cn("flex items-center gap-1.5 bg-
|
|
4
|
+
return (_jsxs("div", { className: cn("flex items-center gap-1.5 bg-surface-sunken px-4 py-2.5 border-b", className), children: [_jsx("span", { className: "bg-tag-red-ink/70 rounded-full size-2.5" }), _jsx("span", { className: "bg-tag-yellow-ink/70 rounded-full size-2.5" }), _jsx("span", { className: "bg-tag-green-ink/70 rounded-full size-2.5" }), _jsx("span", { className: "ml-auto font-mono text-ink-tertiary text-caption", children: title })] }));
|
|
5
5
|
}
|
|
6
6
|
export function MacCard({ title, children, className, headerClassName, }) {
|
|
7
7
|
return (_jsxs("div", { className: cn("overflow-hidden", className), children: [_jsx(MacWindowHeader, { title: title, className: headerClassName }), children] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mac-card.js","sourceRoot":"","sources":["../../../src/components/ui/mac-card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAQxC,MAAM,UAAU,eAAe,CAAC,EAAE,KAAK,EAAE,SAAS,EAAwB;IACtE,OAAO,CACH,eACI,SAAS,EAAE,EAAE,CACT,
|
|
1
|
+
{"version":3,"file":"mac-card.js","sourceRoot":"","sources":["../../../src/components/ui/mac-card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAQxC,MAAM,UAAU,eAAe,CAAC,EAAE,KAAK,EAAE,SAAS,EAAwB;IACtE,OAAO,CACH,eACI,SAAS,EAAE,EAAE,CACT,kEAAkE,EAClE,SAAS,CACZ,aAED,eAAM,SAAS,EAAC,yCAAyC,GAAG,EAC5D,eAAM,SAAS,EAAC,4CAA4C,GAAG,EAC/D,eAAM,SAAS,EAAC,2CAA2C,GAAG,EAC9D,eAAM,SAAS,EAAC,kDAAkD,YAC7D,KAAK,GACH,IACL,CACT,CAAC;AACN,CAAC;AASD,MAAM,UAAU,OAAO,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,SAAS,EACT,eAAe,GACJ;IACX,OAAO,CACH,eAAK,SAAS,EAAE,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,aAC5C,KAAC,eAAe,IAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,GAAI,EAC5D,QAAQ,IACP,CACT,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FieldButtonProps } from "./field-button.js";
|
|
2
|
+
export interface MonthPickerProps extends Omit<FieldButtonProps, "value" | "onChange" | "children" | "onClear" | "icon"> {
|
|
3
|
+
/** `YYYY-MM`, or null for none. */
|
|
4
|
+
value: string | null;
|
|
5
|
+
onChange: (value: string | null) => void;
|
|
6
|
+
/** Earliest and latest month, `YYYY-MM`. */
|
|
7
|
+
min?: string | null;
|
|
8
|
+
max?: string | null;
|
|
9
|
+
clearable?: boolean;
|
|
10
|
+
name?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function MonthPicker({ value, onChange, min, max, clearable, placeholder, name, ...props }: MonthPickerProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=month-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"month-picker.d.ts","sourceRoot":"","sources":["../../../src/components/ui/month-picker.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMxE,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;IACpH,mCAAmC;IACnC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,4CAA4C;IAC5C,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAKD,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,SAAgB,EAAE,WAA4B,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,+BA4F1I"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { CalendarRange, ChevronLeft, ChevronRight } from "lucide-react";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
import { formatMonth, isMonth, today } from "../../lib/dates.js";
|
|
6
|
+
import { cn } from "../../lib/utils.js";
|
|
7
|
+
import { FieldButton } from "./field-button.js";
|
|
8
|
+
import { PickerPanel } from "./picker-panel.js";
|
|
9
|
+
const SHORT = new Intl.DateTimeFormat(undefined, { month: "short" });
|
|
10
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
11
|
+
/* A month: a budget's, a report's, a calendar's. A year of months on a grid, the
|
|
12
|
+
year changed with the arrows beside it. The arrow keys move through the months,
|
|
13
|
+
across years; Enter chooses. */
|
|
14
|
+
export function MonthPicker({ value, onChange, min, max, clearable = true, placeholder = "Pick a month", name, ...props }) {
|
|
15
|
+
const chosen = isMonth(value) ? value : null;
|
|
16
|
+
const [open, setOpen] = useState(false);
|
|
17
|
+
const [year, setYear] = useState(() => Number((chosen ?? today()).slice(0, 4)));
|
|
18
|
+
const [focusMonth, setFocusMonth] = useState(chosen ?? today().slice(0, 7));
|
|
19
|
+
const grid = useRef(null);
|
|
20
|
+
const outside = (m) => (min != null && m < min) || (max != null && m > max);
|
|
21
|
+
const moveTo = (m) => {
|
|
22
|
+
setFocusMonth(m);
|
|
23
|
+
setYear(Number(m.slice(0, 4)));
|
|
24
|
+
requestAnimationFrame(() => grid.current?.querySelector(`[data-month="${m}"]`)?.focus());
|
|
25
|
+
};
|
|
26
|
+
const onKey = (e) => {
|
|
27
|
+
const by = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: 3, ArrowUp: -3 }[e.key];
|
|
28
|
+
if (by === undefined)
|
|
29
|
+
return;
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
const [y, m] = focusMonth.split("-").map(Number);
|
|
32
|
+
const d = new Date(y, m - 1 + by, 1);
|
|
33
|
+
moveTo(`${d.getFullYear()}-${pad(d.getMonth() + 1)}`);
|
|
34
|
+
};
|
|
35
|
+
return (_jsxs(_Fragment, { children: [_jsx(PickerPanel, { open: open, onOpenChange: (next) => {
|
|
36
|
+
setOpen(next);
|
|
37
|
+
if (next) {
|
|
38
|
+
setYear(Number((chosen ?? today()).slice(0, 4)));
|
|
39
|
+
setFocusMonth(chosen ?? today().slice(0, 7));
|
|
40
|
+
}
|
|
41
|
+
}, title: props["aria-label"] ?? "Pick a month", onOpenAutoFocus: (e) => {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
e.currentTarget.querySelector('[data-month][tabindex="0"]')?.focus();
|
|
44
|
+
}, trigger: _jsx(FieldButton, { icon: CalendarRange, placeholder: placeholder, onClear: clearable ? () => onChange(null) : undefined, clearLabel: "Clear the month", ...props, children: chosen === null ? null : formatMonth(chosen) }), children: _jsxs("div", { className: "p-3 w-72 max-sm:w-full max-sm:max-w-sm", children: [_jsxs("div", { className: "flex justify-between items-center mb-2", children: [_jsx("button", { type: "button", "aria-label": "Previous year", onClick: () => setYear((y) => y - 1), className: "inline-flex justify-center items-center hover:bg-tint-hover rounded-control size-7 [@media(pointer:coarse)]:size-10 text-ink-secondary", children: _jsx(ChevronLeft, { className: "size-4" }) }), _jsx("span", { "aria-live": "polite", className: "font-medium text-sm tabular-nums", children: year }), _jsx("button", { type: "button", "aria-label": "Next year", onClick: () => setYear((y) => y + 1), className: "inline-flex justify-center items-center hover:bg-tint-hover rounded-control size-7 [@media(pointer:coarse)]:size-10 text-ink-secondary", children: _jsx(ChevronRight, { className: "size-4" }) })] }), _jsx("div", { ref: grid, role: "grid", "aria-label": `Months of ${year}`, onKeyDown: onKey, className: "gap-1 grid grid-cols-3", children: Array.from({ length: 12 }, (_, i) => {
|
|
45
|
+
const m = `${year}-${pad(i + 1)}`;
|
|
46
|
+
const isChosen = m === chosen;
|
|
47
|
+
return (_jsx("button", { type: "button", role: "gridcell", "data-month": m, "aria-selected": isChosen, "aria-label": formatMonth(m), tabIndex: m === focusMonth ? 0 : -1, disabled: outside(m), onFocus: () => setFocusMonth(m), onClick: () => {
|
|
48
|
+
onChange(m);
|
|
49
|
+
setOpen(false);
|
|
50
|
+
}, className: cn("rounded-control h-9 [@media(pointer:coarse)]:h-12 text-sm transition-colors duration-(--duration-instant)", isChosen ? "bg-accent-solid font-medium text-accent-ink hover:bg-accent-solid-hover" : "text-ink hover:bg-tint-hover", m === today().slice(0, 7) && !isChosen && "font-semibold shadow-[inset_0_0_0_1px_var(--hairline-strong)]", "disabled:text-ink-disabled disabled:pointer-events-none"), children: SHORT.format(new Date(year, i, 1)) }, m));
|
|
51
|
+
}) })] }) }), name !== undefined && _jsx("input", { type: "hidden", name: name, value: chosen ?? "" })] }));
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=month-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"month-picker.js","sourceRoot":"","sources":["../../../src/components/ui/month-picker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAyB,MAAM,mBAAoB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAoB,CAAC;AAEjD,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AACrE,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAatD;;kCAEkC;AAClC,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI,EAAE,WAAW,GAAG,cAAc,EAAE,IAAI,EAAE,GAAG,KAAK,EAAoB;IACvI,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,GAAG,E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AAC,EACpB,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAC/B,OAAO,EAAE,GAAG,EAAE;wCACV,QAAQ,CAAC,CAAC,CAAC,CAAC;wCACZ,OAAO,CAAC,KAAK,CAAC,CAAC;oCACnB,CAAC,EACD,SAAS,EAAE,EAAE,CACT,2GAA2G,EAC3G,QAAQ,CAAC,CAAC,CAAC,yEAAyE,CAAC,CAAC,CAAC,8BAA8B,EACrH,CAAC,KAAK,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,+DAA+D,EACzG,yDAAyD,CAC5D,YAEA,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IApB9B,CAAC,CAqBD,CACZ,CAAC;4BACN,CAAC,CAAC,GACA,IACJ,GACI,EACb,IAAI,KAAK,SAAS,IAAI,gBAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,IAAI,EAAE,GAAI,IAChF,CACN,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type TagColor } from "./badge.js";
|
|
2
|
+
export type MultiSelectOption = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
color?: TagColor;
|
|
6
|
+
};
|
|
7
|
+
export declare function MultiSelect({ options, value, onChange, onCreate, placeholder, size, disabled, name, className, "aria-label": ariaLabel, autoFocus, }: {
|
|
8
|
+
options: readonly MultiSelectOption[];
|
|
9
|
+
value: readonly string[];
|
|
10
|
+
onChange: (value: string[]) => void;
|
|
11
|
+
/** Offers "Create …" for what was typed; return the new option (it is chosen at once). */
|
|
12
|
+
onCreate?: (label: string) => MultiSelectOption | void;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
size?: "sm" | "md" | "lg";
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
name?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
"aria-label"?: string;
|
|
19
|
+
/** Put the caret in it when it appears (in a popover opened to edit it). */
|
|
20
|
+
autoFocus?: boolean;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
22
|
+
//# sourceMappingURL=multi-select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-select.d.ts","sourceRoot":"","sources":["../../../src/components/ui/multi-select.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAiBhE,MAAM,MAAM,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEnF,wBAAgB,WAAW,CAAC,EACxB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,WAAoB,EACpB,IAAW,EACX,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,SAAS,GACZ,EAAE;IACC,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACpC,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,iBAAiB,GAAG,IAAI,CAAC;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,+BAyKA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
4
|
+
import { Check, Plus, X } from "lucide-react";
|
|
5
|
+
import { useId, useRef, useState } from "react";
|
|
6
|
+
import { cn } from "../../lib/utils.js";
|
|
7
|
+
import { Badge, tagColorFor } from "./badge.js";
|
|
8
|
+
import { fieldVariants, fromField, useField } from "./input.js";
|
|
9
|
+
import { useEscapeFirst } from "../../hooks/use-escape-first.js";
|
|
10
|
+
import { listSurfaceClasses, optionClasses, stepActive } from "./listbox.js";
|
|
11
|
+
export function MultiSelect({ options, value, onChange, onCreate, placeholder = "Add…", size = "md", disabled, name, className, "aria-label": ariaLabel, autoFocus, }) {
|
|
12
|
+
const listId = useId();
|
|
13
|
+
const own = fromField(useField(), { disabled, "aria-label": ariaLabel });
|
|
14
|
+
const input = useRef(null);
|
|
15
|
+
const [query, setQuery] = useState("");
|
|
16
|
+
const [open, setOpen] = useState(false);
|
|
17
|
+
const [at, setAt] = useState(-1);
|
|
18
|
+
const byValue = new Map(options.map((o) => [o.value, o]));
|
|
19
|
+
const chosen = value.map((v) => byValue.get(v) ?? { value: v, label: v });
|
|
20
|
+
const typed = query.trim();
|
|
21
|
+
const found = options.filter((o) => o.label.toLowerCase().includes(typed.toLowerCase()));
|
|
22
|
+
const canCreate = onCreate !== undefined && typed !== "" && !options.some((o) => o.label.toLowerCase() === typed.toLowerCase());
|
|
23
|
+
const rows = found.length + (canCreate ? 1 : 0);
|
|
24
|
+
const showing = open && rows > 0 && !own.disabled;
|
|
25
|
+
// One past the end (the options changed under it) is no highlight.
|
|
26
|
+
const active = at < rows ? at : -1;
|
|
27
|
+
const optionId = (i) => `${listId}-${i}`;
|
|
28
|
+
const colorOf = (o) => o.color ?? tagColorFor(o.value);
|
|
29
|
+
const toggle = (v) => onChange(value.includes(v) ? value.filter((x) => x !== v) : [...value, v]);
|
|
30
|
+
const pick = (i) => {
|
|
31
|
+
if (i < found.length)
|
|
32
|
+
toggle(found[i].value);
|
|
33
|
+
else if (canCreate) {
|
|
34
|
+
const made = onCreate(typed);
|
|
35
|
+
if (made)
|
|
36
|
+
onChange([...value, made.value]);
|
|
37
|
+
}
|
|
38
|
+
setQuery("");
|
|
39
|
+
setAt(-1);
|
|
40
|
+
};
|
|
41
|
+
// Escape closes the list and nothing else, before a dialog around it hears it.
|
|
42
|
+
useEscapeFirst(showing, input, () => setOpen(false));
|
|
43
|
+
return (_jsxs(PopoverPrimitive.Root, { open: showing, children: [_jsx(PopoverPrimitive.Anchor, { asChild: true, children: _jsxs("div", { className: cn(fieldVariants({ size }), "flex flex-wrap items-center gap-1 h-auto py-1 cursor-text", size === "sm" ? "min-h-control-sm" : size === "lg" ? "min-h-control-lg" : "min-h-control-md",
|
|
44
|
+
// The field shows focus while its input has it.
|
|
45
|
+
"focus-within:bg-surface focus-within:shadow-[inset_0_0_0_1px_var(--accent),0_0_0_3px_var(--accent-tint)]", own["aria-invalid"] && "shadow-[inset_0_0_0_1px_var(--danger)] focus-within:shadow-[inset_0_0_0_1px_var(--danger),0_0_0_3px_var(--danger-tint)]", own.disabled && "cursor-not-allowed text-ink-disabled", className), onPointerDown: (e) => {
|
|
46
|
+
if (e.target === e.currentTarget) {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
input.current?.focus();
|
|
49
|
+
}
|
|
50
|
+
}, children: [chosen.map((o) => (_jsxs(Badge, { color: colorOf(o), className: "gap-0.5 pr-0.5", children: [o.label, _jsx("button", { type: "button", "aria-label": `Remove ${o.label}`, disabled: own.disabled, onClick: () => toggle(o.value), className: "relative flex justify-center items-center opacity-70 hover:opacity-100 rounded-small size-3.5 after:absolute after:-inset-1 after:content-['']", children: _jsx(X, { className: "size-3" }) })] }, o.value))), _jsx("input", { ref: input, autoFocus: autoFocus, id: own.id, role: "combobox", "aria-label": own["aria-label"], "aria-describedby": own["aria-describedby"], "aria-invalid": own["aria-invalid"], "aria-expanded": showing, "aria-controls": showing ? listId : undefined, "aria-autocomplete": "list", "aria-activedescendant": showing && active >= 0 ? optionId(active) : undefined, autoComplete: "off", disabled: own.disabled, value: query, placeholder: chosen.length === 0 ? placeholder : undefined, onChange: (e) => {
|
|
51
|
+
setQuery(e.target.value);
|
|
52
|
+
setOpen(true);
|
|
53
|
+
setAt(e.target.value.trim() === "" ? -1 : 0);
|
|
54
|
+
}, onFocus: () => setOpen(true),
|
|
55
|
+
// A click in the list is a prevented mousedown and keeps the focus
|
|
56
|
+
// here, so a blur means the field really was left.
|
|
57
|
+
onBlur: () => setOpen(false), onKeyDown: (e) => {
|
|
58
|
+
if (e.nativeEvent.isComposing || e.keyCode === 229)
|
|
59
|
+
return;
|
|
60
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
setOpen(true);
|
|
63
|
+
const next = stepActive(active, rows, e.key);
|
|
64
|
+
if (next !== null)
|
|
65
|
+
setAt(next);
|
|
66
|
+
}
|
|
67
|
+
else if (e.key === "Enter") {
|
|
68
|
+
// Words typed are a tag being chosen, never a form to send.
|
|
69
|
+
if (query.trim() !== "" || (showing && active >= 0))
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
if (showing && active >= 0)
|
|
72
|
+
pick(active);
|
|
73
|
+
}
|
|
74
|
+
else if (e.key === "Backspace" && query === "" && value.length > 0) {
|
|
75
|
+
onChange(value.slice(0, -1));
|
|
76
|
+
}
|
|
77
|
+
}, className: "flex-1 bg-transparent disabled:cursor-not-allowed outline-none min-w-16 h-control-sm placeholder:text-ink-placeholder" }), name !== undefined && value.map((v) => _jsx("input", { type: "hidden", name: name, value: v }, v))] }) }), _jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { onOpenAutoFocus: (e) => e.preventDefault(), onMouseDown: (e) => e.preventDefault(), onCloseAutoFocus: (e) => e.preventDefault(), onInteractOutside: (e) => {
|
|
78
|
+
if (e.target instanceof Node && input.current?.parentElement?.contains(e.target))
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
}, align: "start", sideOffset: 4, collisionPadding: 8, className: cn("z-(--z-overlay) w-(--radix-popper-anchor-width) max-h-[min(20rem,var(--radix-popper-available-height))] animate-slide-in", listSurfaceClasses), children: _jsxs("ul", { id: listId, role: "listbox", "aria-multiselectable": "true", children: [found.map((o, i) => (_jsxs("li", { id: optionId(i), role: "option", "aria-selected": value.includes(o.value), "data-active": i === active, onMouseDown: (e) => {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
pick(i);
|
|
83
|
+
}, onMouseEnter: () => setAt(i), className: optionClasses, children: [_jsx(Badge, { color: colorOf(o), children: o.label }), value.includes(o.value) && _jsx(Check, { "aria-hidden": true, className: "ml-auto size-4 text-ink-secondary" })] }, o.value))), canCreate && (_jsxs("li", { id: optionId(found.length), role: "option", "aria-selected": false, "data-active": active === found.length, onMouseDown: (e) => {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
pick(found.length);
|
|
86
|
+
}, onMouseEnter: () => setAt(found.length), className: optionClasses, children: [_jsx(Plus, { "aria-hidden": true, className: "size-4 text-ink-tertiary" }), _jsx("span", { className: "text-ink-secondary", children: "Create" }), _jsx(Badge, { color: tagColorFor(typed), children: typed })] }))] }) }) })] }));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=multi-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-select.js","sourceRoot":"","sources":["../../../src/components/ui/multi-select.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OA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Root":"","sources":["../../../src/components/ui/nav-tree.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"nav-tree.d.ts","sourceRoot":"","sources":["../../../src/components/ui/nav-tree.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AAG9D,MAAM,MAAM,OAAO,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC;AAmE3G,wBAAgB,OAAO,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,KAAS,EACT,IAAU,GACb,EAAE;IACC,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;CACtB,+BAQA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ChevronRight, FileText } from "lucide-react";
|
|
4
|
-
import { useState } from "react";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
5
|
import { cn } from "../../lib/utils.js";
|
|
6
6
|
// Each entry keeps one of the nine tag colours for its icon, picked from its id, so
|
|
7
7
|
// a sidebar has some colour and an entry is recognisable by more than its name.
|
|
@@ -18,10 +18,17 @@ function iconColor(id) {
|
|
|
18
18
|
const holds = (node, id) => (node.children ?? []).some((c) => c.id === id || holds(c, id));
|
|
19
19
|
function Row({ node, depth, activeId, link: Link }) {
|
|
20
20
|
const children = node.children ?? [];
|
|
21
|
-
const
|
|
21
|
+
const holdsActive = activeId !== undefined && holds(node, activeId);
|
|
22
|
+
const [open, setOpen] = useState(holdsActive);
|
|
23
|
+
// Opening a page inside this one, from anywhere, shows where it is. Closing it by
|
|
24
|
+
// hand afterwards still works.
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (holdsActive)
|
|
27
|
+
setOpen(true);
|
|
28
|
+
}, [holdsActive]);
|
|
22
29
|
const current = node.id === activeId;
|
|
23
30
|
const Icon = node.icon ?? FileText;
|
|
24
|
-
return (_jsxs("li", { children: [_jsxs("div", { className: cn("group flex h-
|
|
31
|
+
return (_jsxs("li", { children: [_jsxs("div", { className: cn("group flex h-control-sm items-center rounded-control pr-2 text-sm font-medium transition-colors duration-(--duration-fast)", current ? "bg-accent-tint text-accent-text" : "text-ink-secondary hover:bg-tint-hover"), style: { paddingLeft: 8 + depth * 16 }, children: [_jsxs("span", { className: "relative mr-1.5 flex size-5 shrink-0 items-center justify-center", children: [_jsx(Icon, { className: cn("size-4", iconColor(node.id), children.length > 0 && "group-hover:opacity-0") }), children.length > 0 && (_jsx("button", { type: "button", "aria-label": open ? `Collapse ${node.title}` : `Expand ${node.title}`, "aria-expanded": open, onClick: () => setOpen(!open), className: "affordance absolute inset-0 flex items-center justify-center rounded-small hover:bg-tint-active", children: _jsx(ChevronRight, { className: cn("size-3.5 transition-transform duration-(--duration-fast)", open && "rotate-90") }) }))] }), _jsx(Link, { href: node.href, "aria-current": current ? "page" : undefined, className: "flex h-full min-w-0 flex-1 items-center outline-offset-[-2px]", children: _jsx("span", { className: "truncate", children: node.title }) })] }), children.length > 0 && open && _jsx(NavTree, { nodes: children, depth: depth + 1, activeId: activeId, link: Link })] }));
|
|
25
32
|
}
|
|
26
33
|
/* A sidebar's tree of destinations. The entry matching `activeId` is highlighted
|
|
27
34
|
in the accent, and its ancestors start open. Pass your router's link as `link`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nav-tree.js","sourceRoot":"","sources":["../../../src/components/ui/nav-tree.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"nav-tree.js","sourceRoot":"","sources":["../../../src/components/ui/nav-tree.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAoB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAIxC,oFAAoF;AACpF,gFAAgF;AAChF,MAAM,WAAW,GAAG;IAChB,mBAAmB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,oBAAoB;IAC7G,mBAAmB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,kBAAkB;CACtF,CAAC;AACF,SAAS,SAAS,CAAC,EAAU;IACzB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,EAAE,IAAI,EAAE;QAAE,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC/D,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,KAAK,GAAG,CAAC,IAAa,EAAE,EAAU,EAAW,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CA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AE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAC7B,SAAS,EAAC,iGAAiG,YAE3G,KAAC,YAAY,IAAC,SAAS,EAAE,EAAE,CAAC,0DAA0D,EAAE,IAAI,IAAI,WAAW,CAAC,GAAI,GAC3G,CACZ,IACE,EACP,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,kBAAgB,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,EAAC,+DAA+D,YACxI,eAAM,SAAS,EAAC,UAAU,YAAE,IAAI,CAAC,KAAK,GAAQ,GAC3C,IACL,EACL,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,IAAI,KAAC,OAAO,IAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAI,IAC7G,CACR,CAAC;AACN,CAAC;AAED;;;;2DAI2D;AAC3D,MAAM,UAAU,OAAO,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,KAAK,GAAG,CAAC,EACT,IAAI,GAAG,GAAG,GAMb;IACG,OAAO,CACH,aAAI,SAAS,EAAC,sBAAsB,YAC/B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACjB,KAAC,GAAG,IAAe,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,IAAjE,IAAI,CAAC,EAAE,CAA8D,CAClF,CAAC,GACD,CACR,CAAC;AACN,CAAC"}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
declare const WIDTHS: {
|
|
3
|
+
/** A reading width, for forms, settings and pages of text (endgame's). */
|
|
4
|
+
reading: string;
|
|
5
|
+
/** Room for a grid of pictures or a wide table (vault's). */
|
|
6
|
+
wide: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function Page({ width, className, ...props }: ComponentPropsWithoutRef<"div"> & {
|
|
9
|
+
width?: keyof typeof WIDTHS;
|
|
5
10
|
}): import("react").JSX.Element;
|
|
6
|
-
export declare function PageHeader({ title, lead, note, actions }: {
|
|
11
|
+
export declare function PageHeader({ title, lead, note, actions, className, }: {
|
|
7
12
|
title: ReactNode;
|
|
8
13
|
lead?: ReactNode;
|
|
9
14
|
note?: ReactNode;
|
|
10
15
|
actions?: ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
export declare function Section({ title, aside, children, className, ...props }: Omit<ComponentPropsWithoutRef<"section">, "title"> & {
|
|
19
|
+
title: ReactNode;
|
|
20
|
+
aside?: ReactNode;
|
|
11
21
|
}): import("react").JSX.Element;
|
|
22
|
+
export {};
|
|
12
23
|
//# sourceMappingURL=page.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/components/ui/page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/components/ui/page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGjE,QAAA,MAAM,MAAM;IACR,0EAA0E;;IAE1E,6DAA6D;;CAEhE,CAAC;AAQF,wBAAgB,IAAI,CAAC,EACjB,KAAc,EACd,SAAS,EACT,GAAG,KAAK,EACX,EAAE,wBAAwB,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,OAAO,MAAM,CAAA;CAAE,+BAEnE;AAID,wBAAgB,UAAU,CAAC,EACvB,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,SAAS,GACZ,EAAE;IACC,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,+BAcA;AAID,wBAAgB,OAAO,CAAC,EACpB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACX,EAAE,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,+BAU9F"}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../lib/utils.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const WIDTHS = {
|
|
4
|
+
/** A reading width, for forms, settings and pages of text (endgame's). */
|
|
5
|
+
reading: "max-w-reading",
|
|
6
|
+
/** Room for a grid of pictures or a wide table (vault's). */
|
|
7
|
+
wide: "max-w-wide",
|
|
8
|
+
};
|
|
9
|
+
/* Every page of an app sits in this: one width and one set of margins, so moving
|
|
10
|
+
between views does not shift the left edge. Meant for inside `SidebarInset` (or
|
|
11
|
+
any container): its margins answer to the room the page really has, sidebar
|
|
12
|
+
open or shut, not to the window. 20px on a phone, 32px from a 36rem page, 48px
|
|
13
|
+
from 56rem; checked at 360 to 2560px wide. Pick one width per app, or per kind
|
|
14
|
+
of page. */
|
|
15
|
+
export function Page({ width = "wide", className, ...props }) {
|
|
16
|
+
return _jsx("div", { className: cn("mx-auto w-full px-5 pt-8 pb-24 @xl:px-8 @xl:pt-12 @4xl:px-12", WIDTHS[width], className), ...props });
|
|
9
17
|
}
|
|
10
|
-
/* A page's name at the display size, the line under it, and room on the right
|
|
11
|
-
|
|
12
|
-
export function PageHeader({ title, lead, note, actions }) {
|
|
13
|
-
return (_jsxs("header", { className: "
|
|
18
|
+
/* A page's name at the display size, the line under it, and room on the right for
|
|
19
|
+
its actions. */
|
|
20
|
+
export function PageHeader({ title, lead, note, actions, className, }) {
|
|
21
|
+
return (_jsxs("header", { className: cn("flex flex-wrap items-end gap-x-4 gap-y-3 mb-8", className), children: [_jsxs("div", { className: "flex-1 min-w-min", children: [_jsx("h1", { className: "text-display text-ink text-balance", children: title }), lead !== undefined && _jsx("p", { className: "mt-2 text-ink-secondary", children: lead }), note !== undefined && _jsx("p", { className: "mt-2 max-w-2xl text-ink-tertiary text-sm", children: note })] }), actions !== undefined && _jsx("div", { className: "flex items-center gap-1 pb-1 shrink-0", children: actions })] }));
|
|
22
|
+
}
|
|
23
|
+
/* A titled part of a page, with an optional link or button beside the title.
|
|
24
|
+
From endgame, 2026-12-05. */
|
|
25
|
+
export function Section({ title, aside, children, className, ...props }) {
|
|
26
|
+
return (_jsxs("section", { className: cn("min-w-0", className), ...props, children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 mb-2", children: [_jsx("h2", { className: "flex-1 min-w-0 text-h3", children: title }), aside] }), children] }));
|
|
14
27
|
}
|
|
15
28
|
//# sourceMappingURL=page.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../../src/components/ui/page.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../../src/components/ui/page.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,MAAM,MAAM,GAAG;IACX,0EAA0E;IAC1E,OAAO,EAAE,e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
|
+
/** The pages to show for `page` of `count`: the first, the last, the current and its neighbours, with "…" for the gaps. Never more than 7 entries. */
|
|
3
|
+
export declare function pageWindow(page: number, count: number, around?: number): (number | "gap")[];
|
|
4
|
+
export declare function Pagination({ page, count, onChange, href, link: Link, label, className, }: {
|
|
5
|
+
/** From 1. */
|
|
6
|
+
page: number;
|
|
7
|
+
count: number;
|
|
8
|
+
onChange?: (page: number) => void;
|
|
9
|
+
href?: (page: number) => string;
|
|
10
|
+
link?: ElementType;
|
|
11
|
+
label?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
}): import("react").JSX.Element | null;
|
|
14
|
+
export declare function LoadMore({ onLoad, loading, hasMore, auto, shown, total, label, endText, className, }: {
|
|
15
|
+
onLoad: () => void;
|
|
16
|
+
loading: boolean;
|
|
17
|
+
hasMore: boolean;
|
|
18
|
+
/** Load the next page on its own when this comes into view. */
|
|
19
|
+
auto?: boolean;
|
|
20
|
+
shown?: number;
|
|
21
|
+
total?: number;
|
|
22
|
+
label?: string;
|
|
23
|
+
endText?: ReactNode;
|
|
24
|
+
className?: string;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/components/ui/pagination.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAK5E,sJAAsJ;AACtJ,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,CAKtF;AAMD,wBAAgB,UAAU,CAAC,EACvB,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,IAAI,EAAE,IAAU,EAChB,KAAe,EACf,SAAS,GACZ,EAAE;IACC,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAChC,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,sCAwCA;AAMD,wBAAgB,QAAQ,CAAC,EACrB,MAAM,EACN,OAAO,EACP,OAAO,EACP,IAAY,EACZ,KAAK,EACL,KAAK,EACL,KAAmB,EACnB,OAA8B,EAC9B,SAAS,GACZ,EAAE;IACC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,+BAsCA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { Spinner } from "./spinner.js";
|
|
8
|
+
/** The pages to show for `page` of `count`: the first, the last, the current and its neighbours, with "…" for the gaps. Never more than 7 entries. */
|
|
9
|
+
export function pageWindow(page, count, around = 1) {
|
|
10
|
+
if (count <= 5 + around * 2)
|
|
11
|
+
return Array.from({ length: count }, (_, i) => i + 1);
|
|
12
|
+
const from = Math.max(2, Math.min(page - around, count - 2 - around * 2));
|
|
13
|
+
const to = Math.min(count - 1, Math.max(page + around, 3 + around * 2));
|
|
14
|
+
return [1, ...(from > 2 ? ["gap"] : []), ...Array.from({ length: to - from + 1 }, (_, i) => from + i), ...(to < count - 1 ? ["gap"] : []), count];
|
|
15
|
+
}
|
|
16
|
+
/* Numbered pages, Previous and Next. Under 20rem of room the numbers give way to "Page 3
|
|
17
|
+
of 12" between the two arrows. Pages are links when `href` is given (so they
|
|
18
|
+
can be opened in a tab and crawled; pass your router's `link`), buttons
|
|
19
|
+
otherwise. */
|
|
20
|
+
export function Pagination({ page, count, onChange, href, link: Link = "a", label = "Pages", className, }) {
|
|
21
|
+
if (count <= 1)
|
|
22
|
+
return null;
|
|
23
|
+
const go = (p, children, props) => {
|
|
24
|
+
const { disabled, ...rest } = props;
|
|
25
|
+
if (href && !disabled)
|
|
26
|
+
return (_jsx(Button, { asChild: true, ...rest, className: "tabular-nums", children: _jsx(Link, { href: href(p), onClick: () => onChange?.(p), children: children }) }));
|
|
27
|
+
return (_jsx(Button, { ...rest, disabled: disabled, onClick: () => onChange?.(p), className: "tabular-nums", children: children }));
|
|
28
|
+
};
|
|
29
|
+
return (_jsx("nav", { "aria-label": label, className: cn("@container flex justify-center", className), children: _jsxs("ul", { className: "flex items-center gap-1", children: [_jsx("li", { children: go(page - 1, _jsx(ChevronLeft, {}), { "aria-label": "Previous page", disabled: page <= 1, size: "icon-sm", variant: "ghost" }) }), pageWindow(page, count).map((p, i) => p === "gap" ? (_jsx("li", { "aria-hidden": true, className: "@max-xs:hidden px-1 text-ink-tertiary", children: "\u2026" }, `gap-${i}`)) : (_jsx("li", { className: "@max-xs:hidden", children: go(p, p, { "aria-label": `Page ${p}`, "aria-current": p === page ? "page" : undefined, size: "sm", variant: p === page ? "subtle" : "ghost" }) }, p))), _jsxs("li", { className: "@xs:hidden px-2 tabular-nums text-ink-secondary text-sm", "aria-hidden": true, children: ["Page ", page, " of ", count] }), _jsx("li", { children: go(page + 1, _jsx(ChevronRight, {}), { "aria-label": "Next page", disabled: page >= count, size: "icon-sm", variant: "ghost" }) })] }) }));
|
|
30
|
+
}
|
|
31
|
+
/* The foot of a feed: "Load more" to fetch the next page, or, with `auto`, the
|
|
32
|
+
next page fetched as the foot scrolls into view (an infinite list), with the
|
|
33
|
+
button kept as the fallback and for the keyboard. Says how many are shown, and
|
|
34
|
+
when there are no more. */
|
|
35
|
+
export function LoadMore({ onLoad, loading, hasMore, auto = false, shown, total, label = "Load more", endText = "That's everything.", className, }) {
|
|
36
|
+
// One observer while it may load, not one per render: a new observer reports
|
|
37
|
+
// at once, so an unrelated re-render would load the same page again.
|
|
38
|
+
const ref = useRef(null);
|
|
39
|
+
const latest = useRef({ onLoad, loading });
|
|
40
|
+
latest.current = { onLoad, loading };
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const el = ref.current;
|
|
43
|
+
if (!el || !auto || !hasMore || typeof IntersectionObserver === "undefined")
|
|
44
|
+
return;
|
|
45
|
+
const observer = new IntersectionObserver((entries) => {
|
|
46
|
+
if (entries.some((e) => e.isIntersecting) && !latest.current.loading)
|
|
47
|
+
latest.current.onLoad();
|
|
48
|
+
}, { rootMargin: "400px 0px" });
|
|
49
|
+
observer.observe(el);
|
|
50
|
+
return () => observer.disconnect();
|
|
51
|
+
}, [auto, hasMore, loading]);
|
|
52
|
+
return (_jsxs("div", { ref: ref, className: cn("flex flex-col items-center gap-2 py-6", className), children: [shown !== undefined && total !== undefined && (_jsxs("p", { className: "tabular-nums text-caption text-ink-tertiary", "aria-live": "polite", children: [shown, " of ", total] })), hasMore ? (auto && loading ? (_jsx(Spinner, { label: "Loading more" })) : (_jsx(Button, { variant: "secondary", loading: loading, onClick: onLoad, children: label }))) : (_jsx("p", { className: "text-ink-tertiary text-sm", children: endText }))] }));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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