@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,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useLayoutEffect, useRef, type KeyboardEvent } from "react";
|
|
4
|
+
import { durationLabel, formatTime, localHourCycle, minutesOf, nearest, timesEvery, type HourCycle } from "../../lib/time.ts";
|
|
5
|
+
import { cn } from "../../lib/utils.ts";
|
|
6
|
+
|
|
7
|
+
/* The times of a day, every `step` minutes, as a list to choose from: Google
|
|
8
|
+
Calendar's way. It opens on the chosen time (or the one nearest now), centred.
|
|
9
|
+
With `relativeTo` (an end time's start) it starts after that time and says how
|
|
10
|
+
long each is ("10:30 AM · 1 hr"). Rows are 28px with a mouse and 44px on a touch
|
|
11
|
+
screen.
|
|
12
|
+
|
|
13
|
+
`focus` mode: a listbox with one tab stop, the arrows moving between times,
|
|
14
|
+
Enter or a press choosing. `active` mode: for a list a text field drives (the
|
|
15
|
+
field keeps focus; `active` is the highlighted one, named by aria-activedescendant
|
|
16
|
+
on the field). */
|
|
17
|
+
export function TimeList({
|
|
18
|
+
value,
|
|
19
|
+
onChange,
|
|
20
|
+
step = 15,
|
|
21
|
+
hourCycle,
|
|
22
|
+
relativeTo,
|
|
23
|
+
label = "Times",
|
|
24
|
+
mode = "focus",
|
|
25
|
+
active,
|
|
26
|
+
onActive,
|
|
27
|
+
id,
|
|
28
|
+
className,
|
|
29
|
+
}: {
|
|
30
|
+
value: string | null;
|
|
31
|
+
onChange: (value: string) => void;
|
|
32
|
+
step?: number;
|
|
33
|
+
hourCycle?: HourCycle;
|
|
34
|
+
relativeTo?: string | null;
|
|
35
|
+
label?: string;
|
|
36
|
+
mode?: "focus" | "active";
|
|
37
|
+
active?: string | null;
|
|
38
|
+
onActive?: (time: string) => void;
|
|
39
|
+
/** The listbox's id; each option is `${id}-HHMM`. */
|
|
40
|
+
id?: string;
|
|
41
|
+
className?: string;
|
|
42
|
+
}) {
|
|
43
|
+
const cycle = hourCycle ?? localHourCycle();
|
|
44
|
+
const times = timesEvery(step, { after: relativeTo, include: value });
|
|
45
|
+
const list = useRef<HTMLDivElement>(null);
|
|
46
|
+
const anchor = value ?? nearest(times, relativeTo ?? undefined) ?? times[0];
|
|
47
|
+
const optionId = (t: string) => (id ? `${id}-${t.replace(":", "")}` : undefined);
|
|
48
|
+
|
|
49
|
+
// Open on the chosen time, centred. Set on the list itself: scrollIntoView would
|
|
50
|
+
// scroll every ancestor too, and the page would jump under the panel.
|
|
51
|
+
useLayoutEffect(() => {
|
|
52
|
+
const el = list.current;
|
|
53
|
+
const at = el?.querySelector<HTMLElement>(`[data-time="${mode === "active" && active ? active : anchor}"]`);
|
|
54
|
+
if (el && at) el.scrollTop = at.offsetTop - el.clientHeight / 2 + at.offsetHeight / 2;
|
|
55
|
+
}, [anchor, active, mode]);
|
|
56
|
+
|
|
57
|
+
const move = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
58
|
+
if (mode !== "focus") return;
|
|
59
|
+
const keys = ["ArrowDown", "ArrowUp", "Home", "End", "PageDown", "PageUp"];
|
|
60
|
+
if (!keys.includes(event.key)) return;
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
const items = [...(list.current?.querySelectorAll<HTMLElement>("[role=option]") ?? [])];
|
|
63
|
+
const at = items.indexOf(document.activeElement as HTMLElement);
|
|
64
|
+
const page = Math.max(1, Math.round(60 / step));
|
|
65
|
+
const next = { Home: 0, End: items.length - 1, ArrowDown: at + 1, ArrowUp: at - 1, PageDown: at + page, PageUp: at - page }[event.key]!;
|
|
66
|
+
items[Math.max(0, Math.min(items.length - 1, next))]?.focus();
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
ref={list}
|
|
72
|
+
id={id}
|
|
73
|
+
role="listbox"
|
|
74
|
+
aria-label={label}
|
|
75
|
+
onKeyDown={move}
|
|
76
|
+
className={cn("flex flex-col gap-px p-1.5 w-full min-w-40 h-64 overflow-y-auto overscroll-contain", className)}
|
|
77
|
+
>
|
|
78
|
+
{times.map((time) => {
|
|
79
|
+
const chosen = time === value;
|
|
80
|
+
const highlighted = mode === "active" && time === active;
|
|
81
|
+
return (
|
|
82
|
+
<button
|
|
83
|
+
key={time}
|
|
84
|
+
type="button"
|
|
85
|
+
role="option"
|
|
86
|
+
id={optionId(time)}
|
|
87
|
+
data-time={time}
|
|
88
|
+
aria-selected={chosen}
|
|
89
|
+
tabIndex={mode === "focus" && time === anchor ? 0 : -1}
|
|
90
|
+
onClick={() => onChange(time)}
|
|
91
|
+
onMouseDown={mode === "active" ? (e) => e.preventDefault() : undefined}
|
|
92
|
+
onMouseEnter={mode === "active" ? () => onActive?.(time) : undefined}
|
|
93
|
+
className={cn(
|
|
94
|
+
"flex justify-between items-center gap-3 px-2.5 rounded-control h-control-sm [@media(pointer:coarse)]:h-11 text-sm text-left tabular-nums whitespace-nowrap cursor-pointer shrink-0",
|
|
95
|
+
"transition-colors duration-(--duration-instant)",
|
|
96
|
+
chosen ? "bg-accent-solid font-medium text-accent-ink" : highlighted ? "bg-tint-hover text-ink" : "text-ink hover:bg-tint-hover",
|
|
97
|
+
)}
|
|
98
|
+
>
|
|
99
|
+
<span>{formatTime(time, cycle)}</span>
|
|
100
|
+
{relativeTo && <span className={cn("text-caption", chosen ? "text-accent-ink" : "text-ink-tertiary")}>{durationLabel(minutesOf(time) - minutesOf(relativeTo))}</span>}
|
|
101
|
+
</button>
|
|
102
|
+
);
|
|
103
|
+
})}
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -1,173 +1,344 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Button } from "./button.tsx";
|
|
3
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
4
|
+
import { Clock, X } from "lucide-react";
|
|
5
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
6
|
+
import { useMediaQuery } from "../../hooks/use-media-query.ts";
|
|
8
7
|
import { isTime } from "../../lib/dates.ts";
|
|
8
|
+
import { formatTime, localHourCycle, minutesOf, nearest, parseTime, timesEvery, type HourCycle } from "../../lib/time.ts";
|
|
9
9
|
import { cn } from "../../lib/utils.ts";
|
|
10
|
+
import { FieldButton } from "./field-button.tsx";
|
|
11
|
+
import { Input } from "./input.tsx";
|
|
12
|
+
import { PickerPanel } from "./picker-panel.tsx";
|
|
13
|
+
import { TimeList } from "./time-list.tsx";
|
|
14
|
+
import { useEscapeFirst } from "../../hooks/use-escape-first.ts";
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
const HOURS = Array.from({ length: 24 }, (_, hour) => pad(hour));
|
|
16
|
+
/* A time of day, as Google Calendar and Linear take one.
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
for (let minute = 0; minute < 60; minute += safe) minutes.add(pad(minute));
|
|
19
|
-
if (chosen !== null) minutes.add(chosen);
|
|
20
|
-
return [...minutes].sort();
|
|
21
|
-
}
|
|
18
|
+
With a mouse it is a field to type in: "9", "930", "9:30pm", "noon" all read as
|
|
19
|
+
meant (lib/time), and a list of times opens under it, on the nearest; the arrows
|
|
20
|
+
move through it, Enter takes the highlighted one or what was typed, leaving the
|
|
21
|
+
field keeps a valid time and puts back an invalid one.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function Column({
|
|
26
|
-
label,
|
|
27
|
-
options,
|
|
28
|
-
value,
|
|
29
|
-
onChange,
|
|
30
|
-
}: {
|
|
31
|
-
label: string;
|
|
32
|
-
options: string[];
|
|
33
|
-
value: string | null;
|
|
34
|
-
onChange: (value: string) => void;
|
|
35
|
-
}) {
|
|
36
|
-
const list = useRef<HTMLDivElement>(null);
|
|
37
|
-
|
|
38
|
-
// Open on the chosen value, centred. Set on the column itself: scrollIntoView
|
|
39
|
-
// would scroll every ancestor too, and the page would jump under the popover.
|
|
40
|
-
useLayoutEffect(() => {
|
|
41
|
-
const el = list.current;
|
|
42
|
-
const chosen = el?.querySelector<HTMLElement>("[aria-selected=true]");
|
|
43
|
-
if (el == null || chosen == null) return;
|
|
44
|
-
el.scrollTop = chosen.offsetTop - el.clientHeight / 2 + chosen.offsetHeight / 2;
|
|
45
|
-
}, []);
|
|
23
|
+
On a touch screen it is a field to press: the list opens (as a sheet on a phone)
|
|
24
|
+
with large rows, and no keyboard comes up.
|
|
46
25
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const items = [...(list.current?.querySelectorAll<HTMLElement>("[role=option]") ?? [])];
|
|
52
|
-
const at = items.indexOf(document.activeElement as HTMLElement);
|
|
53
|
-
const next =
|
|
54
|
-
event.key === "Home" ? 0 : event.key === "End" ? items.length - 1 : event.key === "ArrowDown" ? at + 1 : at - 1;
|
|
55
|
-
items[Math.max(0, Math.min(items.length - 1, next))]?.focus();
|
|
56
|
-
};
|
|
26
|
+
The value is `HH:MM` on a 24-hour clock, what a form and a `time` column hold;
|
|
27
|
+
it is shown on the reader's own clock (9:30 PM or 21:30) unless `hourCycle` says.
|
|
28
|
+
With `relativeTo`, an end time's list starts after that time and gives each
|
|
29
|
+
one's length. Anything not a time passed in shows as empty. */
|
|
57
30
|
|
|
58
|
-
|
|
31
|
+
export interface TimePickerProps {
|
|
32
|
+
/** `HH:MM`, 24-hour, or null for none. */
|
|
33
|
+
value: string | null;
|
|
34
|
+
onChange: (value: string | null) => void;
|
|
35
|
+
/** Minutes between the listed times. Any time can still be typed. */
|
|
36
|
+
minuteStep?: number;
|
|
37
|
+
hourCycle?: HourCycle;
|
|
38
|
+
/** The start of a span: the list starts after it and gives lengths. */
|
|
39
|
+
relativeTo?: string | null;
|
|
40
|
+
/** Show the cross that empties it. On by default; turn off for a required time. */
|
|
41
|
+
clearable?: boolean;
|
|
42
|
+
/** Sends the value with a form, as a hidden field of this name. */
|
|
43
|
+
name?: string;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
size?: "sm" | "md" | "lg";
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
invalid?: boolean;
|
|
48
|
+
id?: string;
|
|
49
|
+
className?: string;
|
|
50
|
+
"aria-label"?: string;
|
|
51
|
+
"aria-labelledby"?: string;
|
|
52
|
+
"aria-describedby"?: string;
|
|
53
|
+
}
|
|
59
54
|
|
|
55
|
+
export function TimePicker(props: TimePickerProps) {
|
|
56
|
+
// A mouse or trackpad types; a finger presses. Decided as the device says, live.
|
|
57
|
+
const fine = useMediaQuery("(pointer: fine)");
|
|
60
58
|
return (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
onKeyDown={move}
|
|
66
|
-
className="relative flex h-56 w-14 flex-col gap-0.5 overflow-y-auto overscroll-contain p-1.5 [scrollbar-width:thin]"
|
|
67
|
-
>
|
|
68
|
-
{options.map((option) => (
|
|
69
|
-
<button
|
|
70
|
-
key={option}
|
|
71
|
-
type="button"
|
|
72
|
-
role="option"
|
|
73
|
-
aria-selected={option === value}
|
|
74
|
-
tabIndex={option === tabStop ? 0 : -1}
|
|
75
|
-
onClick={() => onChange(option)}
|
|
76
|
-
className={cn(
|
|
77
|
-
"flex h-7 shrink-0 items-center justify-center rounded-control text-sm tabular-nums cursor-pointer",
|
|
78
|
-
"transition-colors duration-75",
|
|
79
|
-
option === value
|
|
80
|
-
? "bg-accent font-medium text-accent-ink hover:bg-accent-hover"
|
|
81
|
-
: "text-ink hover:bg-tint-hover",
|
|
82
|
-
)}
|
|
83
|
-
>
|
|
84
|
-
{option}
|
|
85
|
-
</button>
|
|
86
|
-
))}
|
|
87
|
-
</div>
|
|
59
|
+
<>
|
|
60
|
+
{fine ? <TypedTime {...props} /> : <PressedTime {...props} />}
|
|
61
|
+
{props.name !== undefined && <input type="hidden" name={props.name} value={isTime(props.value) ? props.value : ""} />}
|
|
62
|
+
</>
|
|
88
63
|
);
|
|
89
64
|
}
|
|
90
65
|
|
|
91
|
-
|
|
92
|
-
alone is on the hour, a minute alone is in the hour given as `fallbackHour`. */
|
|
93
|
-
export function TimeColumns({
|
|
66
|
+
function TypedTime({
|
|
94
67
|
value,
|
|
95
68
|
onChange,
|
|
96
|
-
minuteStep =
|
|
97
|
-
|
|
69
|
+
minuteStep = 15,
|
|
70
|
+
hourCycle,
|
|
71
|
+
relativeTo,
|
|
72
|
+
clearable = true,
|
|
73
|
+
placeholder = "Pick a time",
|
|
74
|
+
size,
|
|
75
|
+
disabled,
|
|
76
|
+
invalid,
|
|
77
|
+
id,
|
|
98
78
|
className,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const [
|
|
79
|
+
// Sent by the hidden field TimePicker draws, never by the visible one.
|
|
80
|
+
name: _name,
|
|
81
|
+
...aria
|
|
82
|
+
}: TimePickerProps) {
|
|
83
|
+
const cycle = hourCycle ?? localHourCycle();
|
|
84
|
+
const time = isTime(value) ? value : null;
|
|
85
|
+
const shown = time === null ? "" : formatTime(time, cycle);
|
|
86
|
+
const [text, setText] = useState(shown);
|
|
87
|
+
const [open, setOpen] = useState(false);
|
|
88
|
+
const [active, setActive] = useState<string | null>(null);
|
|
89
|
+
const field = useRef<HTMLInputElement>(null);
|
|
90
|
+
const listId = useId();
|
|
91
|
+
const times = timesEvery(minuteStep, { after: relativeTo, include: time });
|
|
92
|
+
|
|
93
|
+
// Follow the value while it is not being typed in.
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (document.activeElement !== field.current) setText(shown);
|
|
96
|
+
}, [shown]);
|
|
97
|
+
|
|
98
|
+
const commit = (next: string | null) => {
|
|
99
|
+
setOpen(false);
|
|
100
|
+
setActive(null);
|
|
101
|
+
if (next === null) {
|
|
102
|
+
setText(shown);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
setText(formatTime(next, cycle));
|
|
106
|
+
if (next !== time) onChange(next);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Escape closes the list and nothing else, before a dialog around it hears it.
|
|
110
|
+
useEscapeFirst(open, field, () => {
|
|
111
|
+
setOpen(false);
|
|
112
|
+
setText(shown);
|
|
113
|
+
});
|
|
108
114
|
|
|
109
115
|
return (
|
|
110
|
-
<
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
<PopoverPrimitive.Root open={open && !disabled}>
|
|
117
|
+
<PopoverPrimitive.Anchor asChild>
|
|
118
|
+
<div className={cn("w-full min-w-0", className)}>
|
|
119
|
+
<Input
|
|
120
|
+
ref={field}
|
|
121
|
+
id={id}
|
|
122
|
+
size={size}
|
|
123
|
+
role="combobox"
|
|
124
|
+
aria-expanded={open}
|
|
125
|
+
aria-controls={open ? listId : undefined}
|
|
126
|
+
aria-autocomplete="list"
|
|
127
|
+
aria-activedescendant={open && active ? `${listId}-${active.replace(":", "")}` : undefined}
|
|
128
|
+
aria-invalid={invalid || undefined}
|
|
129
|
+
autoComplete="off"
|
|
130
|
+
disabled={disabled}
|
|
131
|
+
placeholder={placeholder}
|
|
132
|
+
value={text}
|
|
133
|
+
start={<Clock aria-hidden />}
|
|
134
|
+
end={
|
|
135
|
+
clearable && time !== null && !disabled ? (
|
|
136
|
+
<button
|
|
137
|
+
type="button"
|
|
138
|
+
aria-label="Clear the time"
|
|
139
|
+
onClick={() => {
|
|
140
|
+
onChange(null);
|
|
141
|
+
setText("");
|
|
142
|
+
field.current?.focus();
|
|
143
|
+
}}
|
|
144
|
+
className="flex justify-center items-center hover:bg-tint-active -mr-1 rounded-small size-5 text-ink-tertiary hover:text-ink [&_svg]:size-3.5"
|
|
145
|
+
>
|
|
146
|
+
<X />
|
|
147
|
+
</button>
|
|
148
|
+
) : undefined
|
|
149
|
+
}
|
|
150
|
+
onFocus={(e) => {
|
|
151
|
+
e.currentTarget.select();
|
|
152
|
+
setOpen(true);
|
|
153
|
+
setActive(time ?? nearest(times, relativeTo) ?? null);
|
|
154
|
+
}}
|
|
155
|
+
onChange={(e) => {
|
|
156
|
+
setText(e.target.value);
|
|
157
|
+
setOpen(true);
|
|
158
|
+
const typed = parseTime(e.target.value);
|
|
159
|
+
if (typed) setActive(times.includes(typed) ? typed : (nearest(times, typed) ?? null));
|
|
160
|
+
}}
|
|
161
|
+
onBlur={() => {
|
|
162
|
+
if (text.trim() === "") {
|
|
163
|
+
// Emptied: that clears it, if it may be cleared; otherwise the time stays.
|
|
164
|
+
setOpen(false);
|
|
165
|
+
if (clearable) {
|
|
166
|
+
if (time !== null) onChange(null);
|
|
167
|
+
setText("");
|
|
168
|
+
} else setText(shown);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
// A time is kept; anything else is put back as it was.
|
|
172
|
+
commit(parseTime(text));
|
|
173
|
+
}}
|
|
174
|
+
onKeyDown={(e) => {
|
|
175
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
setOpen(true);
|
|
178
|
+
const at = active ? times.indexOf(active) : -1;
|
|
179
|
+
const next = e.key === "ArrowDown" ? Math.min(times.length - 1, at + 1) : Math.max(0, at === -1 ? times.length - 1 : at - 1);
|
|
180
|
+
setActive(times[next]);
|
|
181
|
+
setText(formatTime(times[next], cycle));
|
|
182
|
+
} else if (e.key === "Enter") {
|
|
183
|
+
const typed = parseTime(text);
|
|
184
|
+
if (open || typed) {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
commit(typed ?? active);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}}
|
|
190
|
+
{...aria}
|
|
191
|
+
/>
|
|
192
|
+
</div>
|
|
193
|
+
</PopoverPrimitive.Anchor>
|
|
194
|
+
<PopoverPrimitive.Portal>
|
|
195
|
+
<PopoverPrimitive.Content
|
|
196
|
+
onOpenAutoFocus={(e) => e.preventDefault()}
|
|
197
|
+
onCloseAutoFocus={(e) => e.preventDefault()}
|
|
198
|
+
onInteractOutside={(e) => {
|
|
199
|
+
if (e.target instanceof Node && field.current?.parentElement?.contains(e.target)) e.preventDefault();
|
|
200
|
+
}}
|
|
201
|
+
align="start"
|
|
202
|
+
sideOffset={4}
|
|
203
|
+
collisionPadding={8}
|
|
204
|
+
className="z-(--z-overlay) bg-surface-overlay shadow-popover rounded-surface outline-none w-(--radix-popper-anchor-width) min-w-44 animate-slide-in"
|
|
205
|
+
>
|
|
206
|
+
<TimeList
|
|
207
|
+
id={listId}
|
|
208
|
+
mode="active"
|
|
209
|
+
value={time}
|
|
210
|
+
active={active}
|
|
211
|
+
onActive={setActive}
|
|
212
|
+
onChange={(t) => commit(t)}
|
|
213
|
+
step={minuteStep}
|
|
214
|
+
hourCycle={cycle}
|
|
215
|
+
relativeTo={relativeTo}
|
|
216
|
+
className="h-56"
|
|
217
|
+
/>
|
|
218
|
+
</PopoverPrimitive.Content>
|
|
219
|
+
</PopoverPrimitive.Portal>
|
|
220
|
+
</PopoverPrimitive.Root>
|
|
119
221
|
);
|
|
120
222
|
}
|
|
121
223
|
|
|
122
|
-
|
|
123
|
-
/** `HH:MM`, 24-hour, or null for none. */
|
|
124
|
-
value: string | null;
|
|
125
|
-
onChange: (value: string | null) => void;
|
|
126
|
-
minuteStep?: number;
|
|
127
|
-
/** Show the cross that empties it. On by default; turn off for a required time. */
|
|
128
|
-
clearable?: boolean;
|
|
129
|
-
/** Sends the value with a form, as a hidden field of this name. */
|
|
130
|
-
name?: string;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/* A time of day. The value is a string, `HH:MM`, which is what a form holds and
|
|
134
|
-
what a `time` column takes; anything else passed in shows as empty. */
|
|
135
|
-
export function TimePicker({
|
|
224
|
+
function PressedTime({
|
|
136
225
|
value,
|
|
137
226
|
onChange,
|
|
138
|
-
minuteStep =
|
|
227
|
+
minuteStep = 15,
|
|
228
|
+
hourCycle,
|
|
229
|
+
relativeTo,
|
|
139
230
|
clearable = true,
|
|
140
231
|
placeholder = "Pick a time",
|
|
141
|
-
|
|
142
|
-
|
|
232
|
+
size,
|
|
233
|
+
disabled,
|
|
234
|
+
invalid,
|
|
235
|
+
id,
|
|
236
|
+
className,
|
|
237
|
+
// Sent by the hidden field TimePicker draws, never by the visible one.
|
|
238
|
+
name: _name,
|
|
239
|
+
...aria
|
|
143
240
|
}: TimePickerProps) {
|
|
144
241
|
const [open, setOpen] = useState(false);
|
|
242
|
+
const cycle = hourCycle ?? localHourCycle();
|
|
145
243
|
const time = isTime(value) ? value : null;
|
|
146
|
-
|
|
147
244
|
return (
|
|
148
|
-
<
|
|
149
|
-
|
|
245
|
+
<PickerPanel
|
|
246
|
+
open={open}
|
|
247
|
+
onOpenChange={setOpen}
|
|
248
|
+
title={aria["aria-label"] ?? "Pick a time"}
|
|
249
|
+
// The list takes focus on the chosen time, so the arrows start there.
|
|
250
|
+
onOpenAutoFocus={(e) => {
|
|
251
|
+
e.preventDefault();
|
|
252
|
+
(e.currentTarget as HTMLElement).querySelector<HTMLElement>('[role=option][tabindex="0"]')?.focus({ preventScroll: true });
|
|
253
|
+
}}
|
|
254
|
+
trigger={
|
|
150
255
|
<FieldButton
|
|
151
256
|
icon={Clock}
|
|
257
|
+
id={id}
|
|
258
|
+
size={size}
|
|
259
|
+
disabled={disabled}
|
|
260
|
+
invalid={invalid}
|
|
152
261
|
placeholder={placeholder}
|
|
153
262
|
onClear={clearable ? () => onChange(null) : undefined}
|
|
154
263
|
clearLabel="Clear the time"
|
|
155
|
-
{
|
|
264
|
+
className={className}
|
|
265
|
+
{...aria}
|
|
156
266
|
>
|
|
157
|
-
{time === null ? null : <span className="tabular-nums">{time}</span>}
|
|
267
|
+
{time === null ? null : <span className="tabular-nums">{formatTime(time, cycle)}</span>}
|
|
158
268
|
</FieldButton>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
<
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
269
|
+
}
|
|
270
|
+
>
|
|
271
|
+
<TimeList
|
|
272
|
+
value={time}
|
|
273
|
+
onChange={(t) => {
|
|
274
|
+
onChange(t);
|
|
275
|
+
setOpen(false);
|
|
276
|
+
}}
|
|
277
|
+
step={minuteStep}
|
|
278
|
+
hourCycle={cycle}
|
|
279
|
+
relativeTo={relativeTo}
|
|
280
|
+
label={aria["aria-label"] ?? "Times"}
|
|
281
|
+
className="max-sm:w-full max-sm:h-[min(24rem,60dvh)]"
|
|
282
|
+
/>
|
|
283
|
+
</PickerPanel>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/* A start and an end time, in two fields: the end's list starts after the start
|
|
288
|
+
and gives each time's length. Moving the start moves the end with it, keeping
|
|
289
|
+
the length, as a calendar does. */
|
|
290
|
+
export function TimeRangePicker({
|
|
291
|
+
value,
|
|
292
|
+
onChange,
|
|
293
|
+
minuteStep = 15,
|
|
294
|
+
hourCycle,
|
|
295
|
+
names,
|
|
296
|
+
className,
|
|
297
|
+
labels = { from: "Start time", to: "End time" },
|
|
298
|
+
}: {
|
|
299
|
+
value: { from: string | null; to: string | null };
|
|
300
|
+
onChange: (value: { from: string | null; to: string | null }) => void;
|
|
301
|
+
minuteStep?: number;
|
|
302
|
+
hourCycle?: HourCycle;
|
|
303
|
+
names?: { from: string; to: string };
|
|
304
|
+
labels?: { from: string; to: string };
|
|
305
|
+
className?: string;
|
|
306
|
+
}) {
|
|
307
|
+
return (
|
|
308
|
+
<div className={cn("flex items-center gap-2", className)}>
|
|
309
|
+
<TimePicker
|
|
310
|
+
// Two fields share the row: each may shrink below an input's natural width.
|
|
311
|
+
className="flex-1 min-w-0"
|
|
312
|
+
aria-label={labels.from}
|
|
313
|
+
placeholder="Start"
|
|
314
|
+
value={value.from}
|
|
315
|
+
minuteStep={minuteStep}
|
|
316
|
+
hourCycle={hourCycle}
|
|
317
|
+
name={names?.from}
|
|
318
|
+
onChange={(from) => {
|
|
319
|
+
if (from && value.from && value.to) {
|
|
320
|
+
const length = minutesOf(value.to) - minutesOf(value.from);
|
|
321
|
+
const end = minutesOf(from) + length;
|
|
322
|
+
if (length > 0 && end < 24 * 60) return onChange({ from, to: `${String(Math.floor(end / 60)).padStart(2, "0")}:${String(end % 60).padStart(2, "0")}` });
|
|
323
|
+
}
|
|
324
|
+
onChange({ from, to: value.to && from && minutesOf(value.to) <= minutesOf(from) ? null : value.to });
|
|
325
|
+
}}
|
|
326
|
+
/>
|
|
327
|
+
<span aria-hidden className="text-ink-tertiary">
|
|
328
|
+
–
|
|
329
|
+
</span>
|
|
330
|
+
<TimePicker
|
|
331
|
+
// Two fields share the row: each may shrink below an input's natural width.
|
|
332
|
+
className="flex-1 min-w-0"
|
|
333
|
+
aria-label={labels.to}
|
|
334
|
+
placeholder="End"
|
|
335
|
+
value={value.to}
|
|
336
|
+
relativeTo={value.from}
|
|
337
|
+
minuteStep={minuteStep}
|
|
338
|
+
hourCycle={hourCycle}
|
|
339
|
+
name={names?.to}
|
|
340
|
+
onChange={(to) => onChange({ ...value, to })}
|
|
341
|
+
/>
|
|
342
|
+
</div>
|
|
172
343
|
);
|
|
173
344
|
}
|