@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,272 @@
|
|
|
1
|
+
/* A database, as Notion's: rows with typed properties, seen through views that
|
|
2
|
+
filter, sort and group them. The app owns the data; this is the meaning of it,
|
|
3
|
+
pure functions with no React, so a server can filter and sort by the same
|
|
4
|
+
rules the page does.
|
|
5
|
+
|
|
6
|
+
Values are plain JSON: text as a string, a number, a date as "YYYY-MM-DD", a
|
|
7
|
+
checkbox as a boolean, a select as its option's id, a multi-select as an array
|
|
8
|
+
of option ids. Empty is null (or "" or []). */
|
|
9
|
+
/** What can be asked of each kind of property, in the order a menu shows them, with their words. */
|
|
10
|
+
export const OPS = {
|
|
11
|
+
title: textOps(),
|
|
12
|
+
text: textOps(),
|
|
13
|
+
url: textOps(),
|
|
14
|
+
number: [
|
|
15
|
+
{ op: "is", label: "=" },
|
|
16
|
+
{ op: "isNot", label: "≠" },
|
|
17
|
+
{ op: "gt", label: ">" },
|
|
18
|
+
{ op: "lt", label: "<" },
|
|
19
|
+
{ op: "gte", label: "≥" },
|
|
20
|
+
{ op: "lte", label: "≤" },
|
|
21
|
+
{ op: "isEmpty", label: "is empty" },
|
|
22
|
+
{ op: "isNotEmpty", label: "is not empty" },
|
|
23
|
+
],
|
|
24
|
+
select: [
|
|
25
|
+
{ op: "is", label: "is" },
|
|
26
|
+
{ op: "isNot", label: "is not" },
|
|
27
|
+
{ op: "isEmpty", label: "is empty" },
|
|
28
|
+
{ op: "isNotEmpty", label: "is not empty" },
|
|
29
|
+
],
|
|
30
|
+
multiSelect: [
|
|
31
|
+
{ op: "contains", label: "contains" },
|
|
32
|
+
{ op: "notContains", label: "does not contain" },
|
|
33
|
+
{ op: "isEmpty", label: "is empty" },
|
|
34
|
+
{ op: "isNotEmpty", label: "is not empty" },
|
|
35
|
+
],
|
|
36
|
+
date: [
|
|
37
|
+
{ op: "is", label: "is" },
|
|
38
|
+
{ op: "before", label: "is before" },
|
|
39
|
+
{ op: "after", label: "is after" },
|
|
40
|
+
{ op: "onOrBefore", label: "is on or before" },
|
|
41
|
+
{ op: "onOrAfter", label: "is on or after" },
|
|
42
|
+
{ op: "isEmpty", label: "is empty" },
|
|
43
|
+
{ op: "isNotEmpty", label: "is not empty" },
|
|
44
|
+
],
|
|
45
|
+
checkbox: [{ op: "is", label: "is" }],
|
|
46
|
+
};
|
|
47
|
+
function textOps() {
|
|
48
|
+
return [
|
|
49
|
+
{ op: "contains", label: "contains" },
|
|
50
|
+
{ op: "notContains", label: "does not contain" },
|
|
51
|
+
{ op: "is", label: "is" },
|
|
52
|
+
{ op: "isNot", label: "is not" },
|
|
53
|
+
{ op: "isEmpty", label: "is empty" },
|
|
54
|
+
{ op: "isNotEmpty", label: "is not empty" },
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
/** Whether an op needs a value to compare with (is empty does not). */
|
|
58
|
+
export const needsValue = (op) => op !== "isEmpty" && op !== "isNotEmpty";
|
|
59
|
+
export const isEmpty = (v) => v === null || v === undefined || v === "" || (Array.isArray(v) && v.length === 0);
|
|
60
|
+
/** A filter just added for `property`: its first op, and for a checkbox, checked. */
|
|
61
|
+
export function newFilter(property, id) {
|
|
62
|
+
const op = OPS[property.type][0].op;
|
|
63
|
+
return { id, property: property.id, op, value: property.type === "checkbox" ? true : null };
|
|
64
|
+
}
|
|
65
|
+
/** Whether `row` passes `filter`. A filter still missing its value lets everything through, so a half-written one never empties the view. */
|
|
66
|
+
export function passes(row, filter, property) {
|
|
67
|
+
if (!property)
|
|
68
|
+
return true;
|
|
69
|
+
const v = row.values[property.id] ?? null;
|
|
70
|
+
if (filter.op === "isEmpty")
|
|
71
|
+
return isEmpty(v);
|
|
72
|
+
if (filter.op === "isNotEmpty")
|
|
73
|
+
return !isEmpty(v);
|
|
74
|
+
const want = filter.value;
|
|
75
|
+
if (property.type === "checkbox")
|
|
76
|
+
return (v === true) === (want !== false);
|
|
77
|
+
if (isEmpty(want))
|
|
78
|
+
return true;
|
|
79
|
+
switch (property.type) {
|
|
80
|
+
case "title":
|
|
81
|
+
case "text":
|
|
82
|
+
case "url": {
|
|
83
|
+
const have = String(v ?? "").toLocaleLowerCase();
|
|
84
|
+
const w = String(want).toLocaleLowerCase();
|
|
85
|
+
if (filter.op === "contains")
|
|
86
|
+
return have.includes(w);
|
|
87
|
+
if (filter.op === "notContains")
|
|
88
|
+
return !have.includes(w);
|
|
89
|
+
if (filter.op === "is")
|
|
90
|
+
return have === w;
|
|
91
|
+
if (filter.op === "isNot")
|
|
92
|
+
return have !== w;
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
case "number": {
|
|
96
|
+
// A number stored as text counts as that number.
|
|
97
|
+
const n = typeof v === "number" ? v : typeof v === "string" && v.trim() !== "" ? Number(v) : NaN;
|
|
98
|
+
if (Number.isNaN(n))
|
|
99
|
+
return filter.op === "isNot";
|
|
100
|
+
const w = Number(want);
|
|
101
|
+
const v2 = n;
|
|
102
|
+
return { is: v2 === w, isNot: v2 !== w, gt: v2 > w, lt: v2 < w, gte: v2 >= w, lte: v2 <= w }[filter.op] ?? true;
|
|
103
|
+
}
|
|
104
|
+
case "select":
|
|
105
|
+
if (filter.op === "is")
|
|
106
|
+
return v === want;
|
|
107
|
+
if (filter.op === "isNot")
|
|
108
|
+
return v !== want;
|
|
109
|
+
return true;
|
|
110
|
+
case "multiSelect": {
|
|
111
|
+
const have = Array.isArray(v) ? v : [];
|
|
112
|
+
const wants = Array.isArray(want) ? want : [String(want)];
|
|
113
|
+
const any = wants.some((w) => have.includes(w));
|
|
114
|
+
return filter.op === "notContains" ? !any : any;
|
|
115
|
+
}
|
|
116
|
+
case "date": {
|
|
117
|
+
if (typeof v !== "string" || v === "")
|
|
118
|
+
return false;
|
|
119
|
+
const w = String(want);
|
|
120
|
+
// "YYYY-MM-DD" compares as text in date order.
|
|
121
|
+
const day = v.slice(0, 10);
|
|
122
|
+
return { is: day === w, before: day < w, after: day > w, onOrBefore: day <= w, onOrAfter: day >= w }[filter.op] ?? true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/** Whether a filter says anything yet: its property exists, and it has a value if it needs one. */
|
|
127
|
+
export function isActive(filter, property) {
|
|
128
|
+
if (!property)
|
|
129
|
+
return false;
|
|
130
|
+
if (!needsValue(filter.op) || property.type === "checkbox")
|
|
131
|
+
return true;
|
|
132
|
+
return !isEmpty(filter.value ?? null);
|
|
133
|
+
}
|
|
134
|
+
/** Rows passing all (or any) of the filters. Filters that say nothing yet (a deleted property, a value not given) are left out,
|
|
135
|
+
so with "any" a half-written one does not let every row through. */
|
|
136
|
+
export function filterRows(rows, properties, filters, match = "all") {
|
|
137
|
+
const byId = new Map(properties.map((p) => [p.id, p]));
|
|
138
|
+
const active = filters.filter((f) => isActive(f, byId.get(f.property)));
|
|
139
|
+
if (active.length === 0)
|
|
140
|
+
return [...rows];
|
|
141
|
+
return rows.filter((row) => (match === "all" ? active.every((f) => passes(row, f, byId.get(f.property))) : active.some((f) => passes(row, f, byId.get(f.property)))));
|
|
142
|
+
}
|
|
143
|
+
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });
|
|
144
|
+
/** How two values of `property` order, ascending. Empty sorts last, whichever way. */
|
|
145
|
+
export function compareValues(a, b, property) {
|
|
146
|
+
switch (property.type) {
|
|
147
|
+
case "number": {
|
|
148
|
+
// Something not a number sorts after every number.
|
|
149
|
+
const na = Number(a);
|
|
150
|
+
const nb = Number(b);
|
|
151
|
+
if (Number.isNaN(na) || Number.isNaN(nb))
|
|
152
|
+
return Number(Number.isNaN(na)) - Number(Number.isNaN(nb));
|
|
153
|
+
return na - nb;
|
|
154
|
+
}
|
|
155
|
+
case "checkbox":
|
|
156
|
+
return Number(a === true) - Number(b === true);
|
|
157
|
+
case "select": {
|
|
158
|
+
// In the options' own order, as a board's columns are.
|
|
159
|
+
// An id no longer among the options sorts after them.
|
|
160
|
+
const order = (v) => {
|
|
161
|
+
const i = property.options?.findIndex((o) => o.id === v) ?? -1;
|
|
162
|
+
return i === -1 ? Number.MAX_SAFE_INTEGER : i;
|
|
163
|
+
};
|
|
164
|
+
return order(a) - order(b);
|
|
165
|
+
}
|
|
166
|
+
case "multiSelect": {
|
|
167
|
+
const name = (v) => (Array.isArray(v) ? v.map((id) => property.options?.find((o) => o.id === id)?.name ?? id).join(", ") : "");
|
|
168
|
+
return collator.compare(name(a), name(b));
|
|
169
|
+
}
|
|
170
|
+
default:
|
|
171
|
+
return collator.compare(String(a ?? ""), String(b ?? ""));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** Sorted by each sort in turn; rows equal on all of them keep their order. */
|
|
175
|
+
export function sortRows(rows, properties, sorts) {
|
|
176
|
+
const byId = new Map(properties.map((p) => [p.id, p]));
|
|
177
|
+
const keyed = rows.map((row, index) => ({ row, index }));
|
|
178
|
+
keyed.sort((x, y) => {
|
|
179
|
+
for (const sort of sorts) {
|
|
180
|
+
const property = byId.get(sort.property);
|
|
181
|
+
if (!property)
|
|
182
|
+
continue;
|
|
183
|
+
const a = x.row.values[property.id];
|
|
184
|
+
const b = y.row.values[property.id];
|
|
185
|
+
// A checkbox is never empty: unset is unchecked, sorted with the unchecked.
|
|
186
|
+
const ea = property.type !== "checkbox" && isEmpty(a ?? null);
|
|
187
|
+
const eb = property.type !== "checkbox" && isEmpty(b ?? null);
|
|
188
|
+
if (ea !== eb)
|
|
189
|
+
return ea ? 1 : -1;
|
|
190
|
+
if (ea && eb)
|
|
191
|
+
continue;
|
|
192
|
+
const c = compareValues(a, b, property);
|
|
193
|
+
if (c !== 0)
|
|
194
|
+
return sort.direction === "asc" ? c : -c;
|
|
195
|
+
}
|
|
196
|
+
return x.index - y.index;
|
|
197
|
+
});
|
|
198
|
+
return keyed.map((k) => k.row);
|
|
199
|
+
}
|
|
200
|
+
/** Rows by a select (or a checkbox): a group per option in its order, then "No value". Empty groups are kept, for a board's columns. */
|
|
201
|
+
export function groupRows(rows, property) {
|
|
202
|
+
if (property.type === "checkbox") {
|
|
203
|
+
return [true, false].map((on) => ({ key: String(on), option: null, rows: rows.filter((r) => (r.values[property.id] === true) === on) }));
|
|
204
|
+
}
|
|
205
|
+
const options = property.options ?? [];
|
|
206
|
+
const groups = options.map((option) => ({ key: option.id, option, rows: [] }));
|
|
207
|
+
const none = { key: null, option: null, rows: [] };
|
|
208
|
+
for (const row of rows) {
|
|
209
|
+
const v = row.values[property.id];
|
|
210
|
+
const ids = Array.isArray(v) ? v : v === null || v === undefined || v === "" ? [] : [String(v)];
|
|
211
|
+
const homes = groups.filter((g) => ids.includes(g.key));
|
|
212
|
+
if (homes.length === 0)
|
|
213
|
+
none.rows.push(row);
|
|
214
|
+
for (const g of homes)
|
|
215
|
+
g.rows.push(row);
|
|
216
|
+
}
|
|
217
|
+
return [...groups, none];
|
|
218
|
+
}
|
|
219
|
+
/** The first title property, which names a row. */
|
|
220
|
+
export const titleOf = (properties) => properties.find((p) => p.type === "title");
|
|
221
|
+
/** A value as words, for a screen reader or a plain cell. */
|
|
222
|
+
export function valueText(v, property) {
|
|
223
|
+
if (isEmpty(v ?? null))
|
|
224
|
+
return "";
|
|
225
|
+
switch (property.type) {
|
|
226
|
+
case "checkbox":
|
|
227
|
+
return v ? "Yes" : "No";
|
|
228
|
+
case "select":
|
|
229
|
+
return property.options?.find((o) => o.id === v)?.name ?? String(v);
|
|
230
|
+
case "multiSelect":
|
|
231
|
+
return v.map((id) => property.options?.find((o) => o.id === id)?.name ?? id).join(", ");
|
|
232
|
+
default:
|
|
233
|
+
return String(v);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/** Rows whose words (title, text, url, select and multi-select names) contain `query`, ignoring case. */
|
|
237
|
+
export function searchRows(rows, properties, query) {
|
|
238
|
+
const q = query.trim().toLocaleLowerCase();
|
|
239
|
+
if (q === "")
|
|
240
|
+
return [...rows];
|
|
241
|
+
const words = properties.filter((p) => p.type !== "checkbox" && p.type !== "number" && p.type !== "date");
|
|
242
|
+
return rows.filter((row) => words.some((p) => valueText(row.values[p.id], p).toLocaleLowerCase().includes(q)));
|
|
243
|
+
}
|
|
244
|
+
/** What a view shows: searched, filtered, then sorted. */
|
|
245
|
+
export function applyView(rows, properties, view, query = "") {
|
|
246
|
+
return sortRows(filterRows(searchRows(rows, properties, query), properties, view.filter, view.match), properties, view.sort);
|
|
247
|
+
}
|
|
248
|
+
/** A view's properties to show, in its order, without the hidden ones. The title always shows. */
|
|
249
|
+
export function shownProperties(properties, view) {
|
|
250
|
+
const order = view.order ?? [];
|
|
251
|
+
const ranked = [...properties].sort((a, b) => {
|
|
252
|
+
const ia = order.indexOf(a.id);
|
|
253
|
+
const ib = order.indexOf(b.id);
|
|
254
|
+
return (ia === -1 ? order.length + properties.indexOf(a) : ia) - (ib === -1 ? order.length + properties.indexOf(b) : ib);
|
|
255
|
+
});
|
|
256
|
+
return ranked.filter((p) => p.type === "title" || !view.hidden.includes(p.id));
|
|
257
|
+
}
|
|
258
|
+
/** A fresh view of `kind`, choosing what a board groups by and a calendar dates by. */
|
|
259
|
+
export function newView(kind, properties, id, name) {
|
|
260
|
+
const names = { table: "Table", board: "Board", gallery: "Gallery", list: "List", calendar: "Calendar" };
|
|
261
|
+
return {
|
|
262
|
+
id,
|
|
263
|
+
name: name ?? names[kind],
|
|
264
|
+
kind,
|
|
265
|
+
sort: [],
|
|
266
|
+
filter: [],
|
|
267
|
+
hidden: [],
|
|
268
|
+
groupBy: kind === "board" ? properties.find((p) => p.type === "select")?.id : undefined,
|
|
269
|
+
dateProperty: kind === "calendar" ? properties.find((p) => p.type === "date")?.id : undefined,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/lib/database.ts"],"names":[],"mappings":"AAAA;;;;;;;iDAOiD;AAkCjD,oGAAoG;AACpG,MAAM,CAAC,MAAM,GAAG,GAAqE;IACjF,KAAK,EAAE,OAAO,EAAE;IAChB,IAAI,EAAE,OAAO,EAAE;IACf,GAAG,EAAE,OAAO,EAAE;IACd,MAAM,EAAE;QACJ,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;QACxB,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE;QAC3B,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;QACxB,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;QACxB,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE;QACzB,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE;QACpC,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE;KAC9C;IACD,MAAM,EAAE;QACJ,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;QACzB,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;QAChC,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE;QACpC,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE;KAC9C;IACD,WAAW,EAAE;QACT,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;QACrC,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE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AU,EAAE,CAAC;IACnI,OAAO;QACH,EAAE;QACF,IAAI,EAAE,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC;QACzB,IAAI;QACJ,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS;QACvF,YAAY,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS;KAChG,CAAC;AACN,CAAC"}
|
package/dist/lib/dates.d.ts
CHANGED
|
@@ -11,4 +11,20 @@ export declare function splitDateTime(value: string | null | undefined): {
|
|
|
11
11
|
export declare const formatDay: (date: Date) => string;
|
|
12
12
|
/** "27 Dec 2026" */
|
|
13
13
|
export declare const formatShortDay: (date: Date) => string;
|
|
14
|
+
/** The reader's local day, `YYYY-MM-DD`. */
|
|
15
|
+
export declare const today: (now?: Date) => string;
|
|
16
|
+
export declare const isMonth: (value: unknown) => value is string;
|
|
17
|
+
/** The month a `YYYY-MM-DD` falls in. */
|
|
18
|
+
export declare const monthOf: (day: string) => string;
|
|
19
|
+
/** How many days the month has (28 to 31). */
|
|
20
|
+
export declare function daysIn(month: string): number;
|
|
21
|
+
/** The month `by` months before or after, across a year's end. */
|
|
22
|
+
export declare function shiftMonth(month: string, by: number): string;
|
|
23
|
+
/** The first and last day of a month, both included. */
|
|
24
|
+
export declare const monthSpan: (month: string) => {
|
|
25
|
+
from: string;
|
|
26
|
+
to: string;
|
|
27
|
+
};
|
|
28
|
+
/** "December 2026" */
|
|
29
|
+
export declare const formatMonth: (month: string) => string;
|
|
14
30
|
//# sourceMappingURL=dates.d.ts.map
|
package/dist/lib/dates.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../../src/lib/dates.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE5C;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAK9E;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,MAAM,CAExE;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAM5G;AAKD,wBAAwB;AACxB,eAAO,MAAM,SAAS,GAAI,MAAM,IAAI,KAAG,MAA2C,CAAC;AACnF,oBAAoB;AACpB,eAAO,MAAM,cAAc,GAAI,MAAM,IAAI,KAAG,MAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../../src/lib/dates.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE5C;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAK9E;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,MAAM,CAExE;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAM5G;AAKD,wBAAwB;AACxB,eAAO,MAAM,SAAS,GAAI,MAAM,IAAI,KAAG,MAA2C,CAAC;AACnF,oBAAoB;AACpB,eAAO,MAAM,cAAc,GAAI,MAAM,IAAI,KAAG,MAAgC,CAAC;AAM7E,4CAA4C;AAC5C,eAAO,MAAM,KAAK,GAAI,MAAK,IAAiB,KAAG,MAAwB,CAAC;AAExE,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAA4E,CAAC;AAE/H,yCAAyC;AACzC,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAyB,CAAC;AAEhE,8CAA8C;AAC9C,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED,wDAAwD;AACxD,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAqE,CAAC;AAI1I,sBAAsB;AACtB,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,MAG3C,CAAC"}
|
package/dist/lib/dates.js
CHANGED
|
@@ -31,4 +31,31 @@ const SHORT_DAY = new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "sho
|
|
|
31
31
|
export const formatDay = (date) => DAY.format(date).replace(",", "");
|
|
32
32
|
/** "27 Dec 2026" */
|
|
33
33
|
export const formatShortDay = (date) => SHORT_DAY.format(date);
|
|
34
|
+
/* Months as `YYYY-MM`, for a month at a time: a calendar, a budget, a report.
|
|
35
|
+
From endgame, 2026-12-05, without its fixed time zone: "today" here is the
|
|
36
|
+
browser's local day, which is the reader's. */
|
|
37
|
+
/** The reader's local day, `YYYY-MM-DD`. */
|
|
38
|
+
export const today = (now = new Date()) => toISODate(now);
|
|
39
|
+
export const isMonth = (value) => typeof value === "string" && /^\d{4}-(0[1-9]|1[0-2])$/.test(value);
|
|
40
|
+
/** The month a `YYYY-MM-DD` falls in. */
|
|
41
|
+
export const monthOf = (day) => day.slice(0, 7);
|
|
42
|
+
/** How many days the month has (28 to 31). */
|
|
43
|
+
export function daysIn(month) {
|
|
44
|
+
const [y, m] = month.split("-").map(Number);
|
|
45
|
+
return new Date(y, m, 0).getDate();
|
|
46
|
+
}
|
|
47
|
+
/** The month `by` months before or after, across a year's end. */
|
|
48
|
+
export function shiftMonth(month, by) {
|
|
49
|
+
const [y, m] = month.split("-").map(Number);
|
|
50
|
+
const date = new Date(y, m - 1 + by, 1);
|
|
51
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}`;
|
|
52
|
+
}
|
|
53
|
+
/** The first and last day of a month, both included. */
|
|
54
|
+
export const monthSpan = (month) => ({ from: `${month}-01`, to: `${month}-${pad(daysIn(month))}` });
|
|
55
|
+
const MONTH = new Intl.DateTimeFormat("en-GB", { month: "long", year: "numeric" });
|
|
56
|
+
/** "December 2026" */
|
|
57
|
+
export const formatMonth = (month) => {
|
|
58
|
+
const [y, m] = month.split("-").map(Number);
|
|
59
|
+
return MONTH.format(new Date(y, m - 1, 1));
|
|
60
|
+
};
|
|
34
61
|
//# sourceMappingURL=dates.js.map
|
package/dist/lib/dates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.js","sourceRoot":"","sources":["../../src/lib/dates.ts"],"names":[],"mappings":"AAAA;;;mCAGmC;AAEnC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAE9D,MAAM,UAAU,SAAS,CAAC,IAAU;IAChC,OAAO,GAAG,IAAI,CAAC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AAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;IACxC,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;AAC/D,CAAC;AAED,wDAAwD;AACxD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAgC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,KAAK,EAAE,EAAE,EAAE,GAAG,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE1I,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AAEnF,sBAAsB;AACtB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE;IACjD,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type Platform = "apple" | "other";
|
|
2
|
+
/** Which platform the browser says it is. "other" on the server. */
|
|
3
|
+
export declare function platform(): Platform;
|
|
4
|
+
type Key = {
|
|
5
|
+
shown: string;
|
|
6
|
+
spoken: string;
|
|
7
|
+
};
|
|
8
|
+
/** "mod+shift+k" → the keys as shown and as spoken on `on`. */
|
|
9
|
+
export declare function shortcutKeys(shortcut: string, on?: Platform): Key[];
|
|
10
|
+
/** "mod+k" → "⌘K" on Apple, "Ctrl+K" elsewhere: for text, such as a tooltip. */
|
|
11
|
+
export declare function formatShortcut(shortcut: string, on?: Platform): string;
|
|
12
|
+
/** "mod+k" → "Command K": what a screen reader should say. */
|
|
13
|
+
export declare const speakShortcut: (shortcut: string, on?: Platform) => string;
|
|
14
|
+
/** Whether a key press is `shortcut` ("mod+k", "shift+?", "f8"). `mod` is ⌘ or Ctrl, either, as the kit's
|
|
15
|
+
own shortcuts take both. Modifiers not written must be up. Safe for the key events autofill sends with no key. */
|
|
16
|
+
export declare function matchShortcut(e: Pick<KeyboardEvent, "key" | "metaKey" | "ctrlKey" | "altKey" | "shiftKey">, shortcut: string): boolean;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/lib/keys.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAEzC,oEAAoE;AACpE,wBAAgB,QAAQ,IAAI,QAAQ,CAInC;AAED,KAAK,GAAG,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAmB7C,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,QAAqB,GAAG,GAAG,EAAE,CAQ/E;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,QAAqB,GAAG,MAAM,CAIlF;AAED,8DAA8D;AAC9D,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,EAAE,KAAI,QAAqB,KAAG,MAG1D,CAAC;AAInB;qHACqH;AACrH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAWtI"}
|
package/dist/lib/keys.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* Keyboard shortcuts written once, shown right on every platform. A shortcut is
|
|
2
|
+
written as "mod+shift+k": `mod` is ⌘ on Apple platforms and Ctrl elsewhere,
|
|
3
|
+
which is what the kit's own shortcuts listen for (⌘\, ⌘K). */
|
|
4
|
+
/** Which platform the browser says it is. "other" on the server. */
|
|
5
|
+
export function platform() {
|
|
6
|
+
if (typeof navigator === "undefined")
|
|
7
|
+
return "other";
|
|
8
|
+
const name = navigator.userAgentData?.platform ?? navigator.platform ?? "";
|
|
9
|
+
return /mac|iphone|ipad|ipod/i.test(name) ? "apple" : "other";
|
|
10
|
+
}
|
|
11
|
+
const NAMES = {
|
|
12
|
+
mod: { apple: { shown: "⌘", spoken: "Command" }, other: { shown: "Ctrl", spoken: "Control" } },
|
|
13
|
+
ctrl: { apple: { shown: "⌃", spoken: "Control" }, other: { shown: "Ctrl", spoken: "Control" } },
|
|
14
|
+
alt: { apple: { shown: "⌥", spoken: "Option" }, other: { shown: "Alt", spoken: "Alt" } },
|
|
15
|
+
shift: { apple: { shown: "⇧", spoken: "Shift" }, other: { shown: "Shift", spoken: "Shift" } },
|
|
16
|
+
enter: { apple: { shown: "↵", spoken: "Enter" }, other: { shown: "Enter", spoken: "Enter" } },
|
|
17
|
+
backspace: { apple: { shown: "⌫", spoken: "Backspace" }, other: { shown: "Backspace", spoken: "Backspace" } },
|
|
18
|
+
escape: { apple: { shown: "Esc", spoken: "Escape" }, other: { shown: "Esc", spoken: "Escape" } },
|
|
19
|
+
tab: { apple: { shown: "⇥", spoken: "Tab" }, other: { shown: "Tab", spoken: "Tab" } },
|
|
20
|
+
up: { apple: { shown: "↑", spoken: "Up" }, other: { shown: "↑", spoken: "Up" } },
|
|
21
|
+
down: { apple: { shown: "↓", spoken: "Down" }, other: { shown: "↓", spoken: "Down" } },
|
|
22
|
+
left: { apple: { shown: "←", spoken: "Left" }, other: { shown: "←", spoken: "Left" } },
|
|
23
|
+
right: { apple: { shown: "→", spoken: "Right" }, other: { shown: "→", spoken: "Right" } },
|
|
24
|
+
"\\": { apple: { shown: "\\", spoken: "Backslash" }, other: { shown: "\\", spoken: "Backslash" } },
|
|
25
|
+
"/": { apple: { shown: "/", spoken: "Slash" }, other: { shown: "/", spoken: "Slash" } },
|
|
26
|
+
};
|
|
27
|
+
/** "mod+shift+k" → the keys as shown and as spoken on `on`. */
|
|
28
|
+
export function shortcutKeys(shortcut, on = platform()) {
|
|
29
|
+
return shortcut
|
|
30
|
+
.split("+")
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.map((part) => {
|
|
33
|
+
const key = part.trim().toLowerCase();
|
|
34
|
+
return NAMES[key]?.[on] ?? { shown: key.length === 1 ? key.toUpperCase() : part.trim(), spoken: key.length === 1 ? key.toUpperCase() : part.trim() };
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** "mod+k" → "⌘K" on Apple, "Ctrl+K" elsewhere: for text, such as a tooltip. */
|
|
38
|
+
export function formatShortcut(shortcut, on = platform()) {
|
|
39
|
+
return shortcutKeys(shortcut, on)
|
|
40
|
+
.map((k) => k.shown)
|
|
41
|
+
.join(on === "apple" ? "" : "+");
|
|
42
|
+
}
|
|
43
|
+
/** "mod+k" → "Command K": what a screen reader should say. */
|
|
44
|
+
export const speakShortcut = (shortcut, on = platform()) => shortcutKeys(shortcut, on)
|
|
45
|
+
.map((k) => k.spoken)
|
|
46
|
+
.join(" ");
|
|
47
|
+
const KEY_NAMES = { enter: "enter", escape: "escape", tab: "tab", backspace: "backspace", up: "arrowup", down: "arrowdown", left: "arrowleft", right: "arrowright", space: " " };
|
|
48
|
+
/** Whether a key press is `shortcut` ("mod+k", "shift+?", "f8"). `mod` is ⌘ or Ctrl, either, as the kit's
|
|
49
|
+
own shortcuts take both. Modifiers not written must be up. Safe for the key events autofill sends with no key. */
|
|
50
|
+
export function matchShortcut(e, shortcut) {
|
|
51
|
+
if (typeof e.key !== "string" || e.key === "")
|
|
52
|
+
return false;
|
|
53
|
+
const parts = shortcut.toLowerCase().split("+");
|
|
54
|
+
const key = parts.pop();
|
|
55
|
+
const want = new Set(parts);
|
|
56
|
+
const mod = want.has("mod");
|
|
57
|
+
if (mod ? !(e.metaKey || e.ctrlKey) : e.metaKey !== want.has("meta") || e.ctrlKey !== want.has("ctrl"))
|
|
58
|
+
return false;
|
|
59
|
+
if (e.altKey !== want.has("alt"))
|
|
60
|
+
return false;
|
|
61
|
+
// A shifted symbol ("?") is its own key; shift is only checked when written, or for a letter.
|
|
62
|
+
if (want.has("shift") ? !e.shiftKey : e.shiftKey && /^[a-z0-9]$/.test(key))
|
|
63
|
+
return false;
|
|
64
|
+
return e.key.toLowerCase() === (KEY_NAMES[key] ?? key);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/lib/keys.ts"],"names":[],"mappings":"AAAA;;gEAEgE;AAIhE,oEAAoE;AACpE,MAAM,UAAU,QAAQ;IACpB,IAAI,OAAO,SAAS,KAAK,WAAW;QAAE,OAAO,OAAO,CAAC;IACrD,MAAM,IAAI,GAAI,SAAmE,CAAC,aAAa,EAAE,QAAQ,IAAI,SAAS,CAAC,QAAQ,IAAI,EAAE,CAAC;IACtI,OAAO,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AAClE,CAAC;AAID,MAAM,KAAK,GAA0C;IACjD,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAA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":"AAWA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAcvD;AAED,4EAA4E;AAC5E,eAAO,MAAM,KAAK,GAAI,GAAG,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAAkE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* Reading a number someone typed, in whichever way they write numbers.
|
|
2
|
+
|
|
3
|
+
Currency signs, spaces and apostrophes (1'000, as in Switzerland) are ignored.
|
|
4
|
+
With both "," and ".", the last one is the decimal point: 1,234.5 and 1.234,5
|
|
5
|
+
are both one thousand two hundred and thirty-four and a half. With only commas,
|
|
6
|
+
they are thousands when every group after the first is three digits (1,234 and
|
|
7
|
+
12,345,678), and otherwise the decimal point (12,5). With only points, one is the
|
|
8
|
+
decimal point and several are thousands (1.234.567).
|
|
9
|
+
|
|
10
|
+
Returns null for an empty field and NaN for anything that is not a number, so a
|
|
11
|
+
caller can tell "cleared" from "typed nonsense". */
|
|
12
|
+
export function parseNumber(text) {
|
|
13
|
+
let s = text.replace(/[\s '’$€£¥₹]/g, "").replace(/^\((.*)\)$/, "-$1");
|
|
14
|
+
if (s === "")
|
|
15
|
+
return null;
|
|
16
|
+
const comma = s.lastIndexOf(",");
|
|
17
|
+
const point = s.lastIndexOf(".");
|
|
18
|
+
if (comma !== -1 && point !== -1) {
|
|
19
|
+
s = comma > point ? s.replace(/\./g, "").replace(",", ".") : s.replace(/,/g, "");
|
|
20
|
+
}
|
|
21
|
+
else if (comma !== -1) {
|
|
22
|
+
s = /^[-+]?\d{1,3}(,\d{3})+$/.test(s) ? s.replace(/,/g, "") : s.replace(",", ".");
|
|
23
|
+
}
|
|
24
|
+
else if ((s.match(/\./g) ?? []).length > 1) {
|
|
25
|
+
s = s.replace(/\./g, "");
|
|
26
|
+
}
|
|
27
|
+
if (!/^[-+]?(\d+\.?\d*|\.\d+)$/.test(s))
|
|
28
|
+
return Number.NaN;
|
|
29
|
+
return Number(s);
|
|
30
|
+
}
|
|
31
|
+
/** Keeps a number within `min` and `max`, either of which may be absent. */
|
|
32
|
+
export const clamp = (n, min, max) => Math.min(max ?? Infinity, Math.max(min ?? -Infinity, n));
|
|
33
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../src/lib/number.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;sDAUsD;AACtD,MAAM,UAAU,WAAW,CAAC,IAAY;IACpC,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACxE,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC1B,MAAM,KAAK,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QAC/B,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACrF,CAAC;SAAM,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACtB,CAAC,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtF,CAAC;SAAM,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3C,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC;IAC3D,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,GAAY,EAAE,GAAY,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/lib/pointer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,QAAO,OAAwF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Whether the device is driven by a mouse or trackpad rather than a finger. Asked at
|
|
2
|
+
// the moment of use, in the browser.
|
|
3
|
+
export const finePointer = () => typeof window !== "undefined" && window.matchMedia("(pointer: fine)").matches;
|
|
4
|
+
//# sourceMappingURL=pointer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.js","sourceRoot":"","sources":["../../src/lib/pointer.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,qCAAqC;AACrC,MAAM,CAAC,MAAM,WAAW,GAAG,GAAY,EAAE,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type ImageCopy = {
|
|
2
|
+
/** The longest edge, in pixels. */
|
|
3
|
+
edge?: number;
|
|
4
|
+
/** Or the height, for a thumbnail strip of even height. */
|
|
5
|
+
height?: number;
|
|
6
|
+
/** The most bytes the JPEG may be. */
|
|
7
|
+
bytes: number;
|
|
8
|
+
};
|
|
9
|
+
export type PreparedImage = {
|
|
10
|
+
display: Blob;
|
|
11
|
+
thumb: Blob;
|
|
12
|
+
/** The display copy's size. */
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
aspect: number;
|
|
16
|
+
/** SHA-256 of the original, as hex, when asked for. */
|
|
17
|
+
hash?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const QUALITIES: readonly [0.82, 0.72, 0.6, 0.5, 0.4];
|
|
20
|
+
/** The size a picture of `width` × `height` becomes for `copy`, never larger than it was. */
|
|
21
|
+
export declare function fitSize(width: number, height: number, copy: Pick<ImageCopy, "edge" | "height">): {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
type Crop = {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
/** `source` (its `crop`) drawn at `width` × `height`, halving on the way so nothing shimmers. */
|
|
32
|
+
export declare function resizeTo(source: CanvasImageSource, crop: Crop, width: number, height: number): HTMLCanvasElement;
|
|
33
|
+
/** The best quality JPEG that fits in `bytes`. */
|
|
34
|
+
export declare function jpegUnder(canvas: HTMLCanvasElement, bytes: number, qualities?: readonly number[]): Promise<Blob>;
|
|
35
|
+
export declare function prepareImage(file: Blob, { display, thumb, square, hash, qualities, }?: {
|
|
36
|
+
display?: ImageCopy;
|
|
37
|
+
thumb?: ImageCopy;
|
|
38
|
+
square?: boolean;
|
|
39
|
+
hash?: boolean;
|
|
40
|
+
qualities?: readonly number[];
|
|
41
|
+
}): Promise<PreparedImage>;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=prepare-image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