@thalavaisankar/atoms 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/README.md +142 -2
- package/THIRD_PARTY_NOTICES.md +246 -0
- package/dist/blocks/index.d.mts +2 -0
- package/dist/blocks/index.mjs +1 -0
- package/dist/blocks/index.mjs.map +1 -0
- package/dist/components/ui/accordion/accordion.mjs +194 -0
- package/dist/components/ui/accordion/accordion.mjs.map +1 -0
- package/dist/components/ui/accordion/index.mjs +15 -0
- package/dist/components/ui/accordion/index.mjs.map +1 -0
- package/dist/components/ui/activity-feed/activity-feed.mjs +287 -0
- package/dist/components/ui/activity-feed/activity-feed.mjs.map +1 -0
- package/dist/components/ui/activity-feed/index.mjs +39 -0
- package/dist/components/ui/activity-feed/index.mjs.map +1 -0
- package/dist/components/ui/alert/alert.mjs +128 -0
- package/dist/components/ui/alert/alert.mjs.map +1 -0
- package/dist/components/ui/alert/index.mjs +17 -0
- package/dist/components/ui/alert/index.mjs.map +1 -0
- package/dist/components/ui/animated-label/animated-label.mjs +89 -0
- package/dist/components/ui/animated-label/animated-label.mjs.map +1 -0
- package/dist/components/ui/animated-label/index.mjs +9 -0
- package/dist/components/ui/animated-label/index.mjs.map +1 -0
- package/dist/components/ui/animated-number/animated-number.mjs +101 -0
- package/dist/components/ui/animated-number/animated-number.mjs.map +1 -0
- package/dist/components/ui/animated-number/index.mjs +5 -0
- package/dist/components/ui/animated-number/index.mjs.map +1 -0
- package/dist/components/ui/avatar/avatar.mjs +130 -0
- package/dist/components/ui/avatar/avatar.mjs.map +1 -0
- package/dist/components/ui/avatar/index.mjs +17 -0
- package/dist/components/ui/avatar/index.mjs.map +1 -0
- package/dist/components/ui/avatar-group/avatar-group.mjs +49 -0
- package/dist/components/ui/avatar-group/avatar-group.mjs.map +1 -0
- package/dist/components/ui/avatar-group/index.mjs +5 -0
- package/dist/components/ui/avatar-group/index.mjs.map +1 -0
- package/dist/components/ui/badge/badge-motion.mjs +108 -0
- package/dist/components/ui/badge/badge-motion.mjs.map +1 -0
- package/dist/components/ui/badge/badge.mjs +314 -0
- package/dist/components/ui/badge/badge.mjs.map +1 -0
- package/dist/components/ui/badge/index.mjs +27 -0
- package/dist/components/ui/badge/index.mjs.map +1 -0
- package/dist/components/ui/badge/readable-ink.mjs +36 -0
- package/dist/components/ui/badge/readable-ink.mjs.map +1 -0
- package/dist/components/ui/badge-group/badge-group.mjs +132 -0
- package/dist/components/ui/badge-group/badge-group.mjs.map +1 -0
- package/dist/components/ui/badge-group/index.mjs +5 -0
- package/dist/components/ui/badge-group/index.mjs.map +1 -0
- package/dist/components/ui/breadcrumb/breadcrumb.mjs +108 -0
- package/dist/components/ui/breadcrumb/breadcrumb.mjs.map +1 -0
- package/dist/components/ui/breadcrumb/index.mjs +19 -0
- package/dist/components/ui/breadcrumb/index.mjs.map +1 -0
- package/dist/components/ui/button/button-variants.mjs +80 -0
- package/dist/components/ui/button/button-variants.mjs.map +1 -0
- package/dist/components/ui/button/button.mjs +74 -0
- package/dist/components/ui/button/button.mjs.map +1 -0
- package/dist/components/ui/button/index.mjs +17 -0
- package/dist/components/ui/button/index.mjs.map +1 -0
- package/dist/components/ui/button/social-button.mjs +45 -0
- package/dist/components/ui/button/social-button.mjs.map +1 -0
- package/dist/components/ui/button/social-logos.mjs +179 -0
- package/dist/components/ui/button/social-logos.mjs.map +1 -0
- package/dist/components/ui/button/split-button.mjs +72 -0
- package/dist/components/ui/button/split-button.mjs.map +1 -0
- package/dist/components/ui/button-group/button-group.mjs +58 -0
- package/dist/components/ui/button-group/button-group.mjs.map +1 -0
- package/dist/components/ui/button-group/index.mjs +11 -0
- package/dist/components/ui/button-group/index.mjs.map +1 -0
- package/dist/components/ui/card/card.mjs +131 -0
- package/dist/components/ui/card/card.mjs.map +1 -0
- package/dist/components/ui/card/index.mjs +23 -0
- package/dist/components/ui/card/index.mjs.map +1 -0
- package/dist/components/ui/chart/bar-list.mjs +87 -0
- package/dist/components/ui/chart/bar-list.mjs.map +1 -0
- package/dist/components/ui/chart/chart-colors.mjs +68 -0
- package/dist/components/ui/chart/chart-colors.mjs.map +1 -0
- package/dist/components/ui/chart/chart-geometry.mjs +152 -0
- package/dist/components/ui/chart/chart-geometry.mjs.map +1 -0
- package/dist/components/ui/chart/chart-specialized.mjs +194 -0
- package/dist/components/ui/chart/chart-specialized.mjs.map +1 -0
- package/dist/components/ui/chart/chart.mjs +648 -0
- package/dist/components/ui/chart/chart.mjs.map +1 -0
- package/dist/components/ui/chart/index.mjs +88 -0
- package/dist/components/ui/chart/index.mjs.map +1 -0
- package/dist/components/ui/chart/radial-meter.mjs +142 -0
- package/dist/components/ui/chart/radial-meter.mjs.map +1 -0
- package/dist/components/ui/chart/types.mjs +1 -0
- package/dist/components/ui/chart/types.mjs.map +1 -0
- package/dist/components/ui/checkbox/checkbox.mjs +183 -0
- package/dist/components/ui/checkbox/checkbox.mjs.map +1 -0
- package/dist/components/ui/checkbox/index.mjs +11 -0
- package/dist/components/ui/checkbox/index.mjs.map +1 -0
- package/dist/components/ui/checklist/checklist.mjs +353 -0
- package/dist/components/ui/checklist/checklist.mjs.map +1 -0
- package/dist/components/ui/checklist/index.mjs +33 -0
- package/dist/components/ui/checklist/index.mjs.map +1 -0
- package/dist/components/ui/chip/chip.mjs +202 -0
- package/dist/components/ui/chip/chip.mjs.map +1 -0
- package/dist/components/ui/chip/index.mjs +13 -0
- package/dist/components/ui/chip/index.mjs.map +1 -0
- package/dist/components/ui/chip-group/chip-group.mjs +204 -0
- package/dist/components/ui/chip-group/chip-group.mjs.map +1 -0
- package/dist/components/ui/chip-group/index.mjs +11 -0
- package/dist/components/ui/chip-group/index.mjs.map +1 -0
- package/dist/components/ui/code-snippet/code-highlighter.mjs +16 -0
- package/dist/components/ui/code-snippet/code-highlighter.mjs.map +1 -0
- package/dist/components/ui/code-snippet/code-snippet.mjs +437 -0
- package/dist/components/ui/code-snippet/code-snippet.mjs.map +1 -0
- package/dist/components/ui/code-snippet/index.mjs +17 -0
- package/dist/components/ui/code-snippet/index.mjs.map +1 -0
- package/dist/components/ui/code-snippet/labels.mjs +16 -0
- package/dist/components/ui/code-snippet/labels.mjs.map +1 -0
- package/dist/components/ui/code-snippet/tokenize.mjs +715 -0
- package/dist/components/ui/code-snippet/tokenize.mjs.map +1 -0
- package/dist/components/ui/code-snippet/types.mjs +1 -0
- package/dist/components/ui/code-snippet/types.mjs.map +1 -0
- package/dist/components/ui/collapsible/collapsible.mjs +85 -0
- package/dist/components/ui/collapsible/collapsible.mjs.map +1 -0
- package/dist/components/ui/collapsible/index.mjs +15 -0
- package/dist/components/ui/collapsible/index.mjs.map +1 -0
- package/dist/components/ui/color-picker/color-picker.mjs +852 -0
- package/dist/components/ui/color-picker/color-picker.mjs.map +1 -0
- package/dist/components/ui/color-picker/index.mjs +47 -0
- package/dist/components/ui/color-picker/index.mjs.map +1 -0
- package/dist/components/ui/combobox/combobox.mjs +745 -0
- package/dist/components/ui/combobox/combobox.mjs.map +1 -0
- package/dist/components/ui/combobox/index.mjs +27 -0
- package/dist/components/ui/combobox/index.mjs.map +1 -0
- package/dist/components/ui/command/command.mjs +439 -0
- package/dist/components/ui/command/command.mjs.map +1 -0
- package/dist/components/ui/command/index.mjs +31 -0
- package/dist/components/ui/command/index.mjs.map +1 -0
- package/dist/components/ui/compare-slider/compare-slider.mjs +335 -0
- package/dist/components/ui/compare-slider/compare-slider.mjs.map +1 -0
- package/dist/components/ui/compare-slider/index.mjs +17 -0
- package/dist/components/ui/compare-slider/index.mjs.map +1 -0
- package/dist/components/ui/context-menu/context-menu.mjs +184 -0
- package/dist/components/ui/context-menu/context-menu.mjs.map +1 -0
- package/dist/components/ui/context-menu/index.mjs +37 -0
- package/dist/components/ui/context-menu/index.mjs.map +1 -0
- package/dist/components/ui/data-table/active-filters.mjs +69 -0
- package/dist/components/ui/data-table/active-filters.mjs.map +1 -0
- package/dist/components/ui/data-table/body-row.mjs +118 -0
- package/dist/components/ui/data-table/body-row.mjs.map +1 -0
- package/dist/components/ui/data-table/cards.mjs +76 -0
- package/dist/components/ui/data-table/cards.mjs.map +1 -0
- package/dist/components/ui/data-table/data-table.mjs +680 -0
- package/dist/components/ui/data-table/data-table.mjs.map +1 -0
- package/dist/components/ui/data-table/empty.mjs +26 -0
- package/dist/components/ui/data-table/empty.mjs.map +1 -0
- package/dist/components/ui/data-table/expand.mjs +70 -0
- package/dist/components/ui/data-table/expand.mjs.map +1 -0
- package/dist/components/ui/data-table/faceted-filter.mjs +112 -0
- package/dist/components/ui/data-table/faceted-filter.mjs.map +1 -0
- package/dist/components/ui/data-table/features.mjs +96 -0
- package/dist/components/ui/data-table/features.mjs.map +1 -0
- package/dist/components/ui/data-table/grip.mjs +37 -0
- package/dist/components/ui/data-table/grip.mjs.map +1 -0
- package/dist/components/ui/data-table/header-cell.mjs +85 -0
- package/dist/components/ui/data-table/header-cell.mjs.map +1 -0
- package/dist/components/ui/data-table/index.mjs +55 -0
- package/dist/components/ui/data-table/index.mjs.map +1 -0
- package/dist/components/ui/data-table/labels.mjs +55 -0
- package/dist/components/ui/data-table/labels.mjs.map +1 -0
- package/dist/components/ui/data-table/load-more.mjs +56 -0
- package/dist/components/ui/data-table/load-more.mjs.map +1 -0
- package/dist/components/ui/data-table/move-item.mjs +11 -0
- package/dist/components/ui/data-table/move-item.mjs.map +1 -0
- package/dist/components/ui/data-table/persist.mjs +65 -0
- package/dist/components/ui/data-table/persist.mjs.map +1 -0
- package/dist/components/ui/data-table/selection-bar.mjs +51 -0
- package/dist/components/ui/data-table/selection-bar.mjs.map +1 -0
- package/dist/components/ui/data-table/tabs.mjs +48 -0
- package/dist/components/ui/data-table/tabs.mjs.map +1 -0
- package/dist/components/ui/data-table/toolbar.mjs +92 -0
- package/dist/components/ui/data-table/toolbar.mjs.map +1 -0
- package/dist/components/ui/data-table/use-reorder.mjs +239 -0
- package/dist/components/ui/data-table/use-reorder.mjs.map +1 -0
- package/dist/components/ui/data-table/use-reveal.mjs +24 -0
- package/dist/components/ui/data-table/use-reveal.mjs.map +1 -0
- package/dist/components/ui/data-table/use-table-state.mjs +38 -0
- package/dist/components/ui/data-table/use-table-state.mjs.map +1 -0
- package/dist/components/ui/data-table/view-options.mjs +66 -0
- package/dist/components/ui/data-table/view-options.mjs.map +1 -0
- package/dist/components/ui/date-picker/calendar.mjs +466 -0
- package/dist/components/ui/date-picker/calendar.mjs.map +1 -0
- package/dist/components/ui/date-picker/date-picker.mjs +366 -0
- package/dist/components/ui/date-picker/date-picker.mjs.map +1 -0
- package/dist/components/ui/date-picker/index.mjs +17 -0
- package/dist/components/ui/date-picker/index.mjs.map +1 -0
- package/dist/components/ui/date-picker/presets.mjs +49 -0
- package/dist/components/ui/date-picker/presets.mjs.map +1 -0
- package/dist/components/ui/description-list/description-list.mjs +40 -0
- package/dist/components/ui/description-list/description-list.mjs.map +1 -0
- package/dist/components/ui/description-list/index.mjs +15 -0
- package/dist/components/ui/description-list/index.mjs.map +1 -0
- package/dist/components/ui/dialog/dialog-stepper.mjs +23 -0
- package/dist/components/ui/dialog/dialog-stepper.mjs.map +1 -0
- package/dist/components/ui/dialog/dialog.mjs +343 -0
- package/dist/components/ui/dialog/dialog.mjs.map +1 -0
- package/dist/components/ui/dialog/focus-return.mjs +21 -0
- package/dist/components/ui/dialog/focus-return.mjs.map +1 -0
- package/dist/components/ui/dialog/index.mjs +33 -0
- package/dist/components/ui/dialog/index.mjs.map +1 -0
- package/dist/components/ui/divider/divider.mjs +130 -0
- package/dist/components/ui/divider/divider.mjs.map +1 -0
- package/dist/components/ui/divider/index.mjs +6 -0
- package/dist/components/ui/divider/index.mjs.map +1 -0
- package/dist/components/ui/dock/dock.mjs +444 -0
- package/dist/components/ui/dock/dock.mjs.map +1 -0
- package/dist/components/ui/dock/index.mjs +19 -0
- package/dist/components/ui/dock/index.mjs.map +1 -0
- package/dist/components/ui/document-editor/block-actions.mjs +118 -0
- package/dist/components/ui/document-editor/block-actions.mjs.map +1 -0
- package/dist/components/ui/document-editor/block-commands.mjs +182 -0
- package/dist/components/ui/document-editor/block-commands.mjs.map +1 -0
- package/dist/components/ui/document-editor/block-handle.mjs +387 -0
- package/dist/components/ui/document-editor/block-handle.mjs.map +1 -0
- package/dist/components/ui/document-editor/block-morph.mjs +95 -0
- package/dist/components/ui/document-editor/block-morph.mjs.map +1 -0
- package/dist/components/ui/document-editor/block-selection.mjs +81 -0
- package/dist/components/ui/document-editor/block-selection.mjs.map +1 -0
- package/dist/components/ui/document-editor/blocks.mjs +30 -0
- package/dist/components/ui/document-editor/blocks.mjs.map +1 -0
- package/dist/components/ui/document-editor/bubble-menu.mjs +120 -0
- package/dist/components/ui/document-editor/bubble-menu.mjs.map +1 -0
- package/dist/components/ui/document-editor/code-block.mjs +89 -0
- package/dist/components/ui/document-editor/code-block.mjs.map +1 -0
- package/dist/components/ui/document-editor/collaboration-types.mjs +9 -0
- package/dist/components/ui/document-editor/collaboration-types.mjs.map +1 -0
- package/dist/components/ui/document-editor/collaboration.mjs +198 -0
- package/dist/components/ui/document-editor/collaboration.mjs.map +1 -0
- package/dist/components/ui/document-editor/columns.mjs +52 -0
- package/dist/components/ui/document-editor/columns.mjs.map +1 -0
- package/dist/components/ui/document-editor/contents.mjs +60 -0
- package/dist/components/ui/document-editor/contents.mjs.map +1 -0
- package/dist/components/ui/document-editor/date-chip.mjs +115 -0
- package/dist/components/ui/document-editor/date-chip.mjs.map +1 -0
- package/dist/components/ui/document-editor/date-words.mjs +101 -0
- package/dist/components/ui/document-editor/date-words.mjs.map +1 -0
- package/dist/components/ui/document-editor/doc-labels.mjs +19 -0
- package/dist/components/ui/document-editor/doc-labels.mjs.map +1 -0
- package/dist/components/ui/document-editor/document-editor.mjs +496 -0
- package/dist/components/ui/document-editor/document-editor.mjs.map +1 -0
- package/dist/components/ui/document-editor/emoji-suggest.mjs +81 -0
- package/dist/components/ui/document-editor/emoji-suggest.mjs.map +1 -0
- package/dist/components/ui/document-editor/focus-mode.mjs +32 -0
- package/dist/components/ui/document-editor/focus-mode.mjs.map +1 -0
- package/dist/components/ui/document-editor/geometry.mjs +35 -0
- package/dist/components/ui/document-editor/geometry.mjs.map +1 -0
- package/dist/components/ui/document-editor/ghost-text.mjs +154 -0
- package/dist/components/ui/document-editor/ghost-text.mjs.map +1 -0
- package/dist/components/ui/document-editor/gliding-caret.mjs +118 -0
- package/dist/components/ui/document-editor/gliding-caret.mjs.map +1 -0
- package/dist/components/ui/document-editor/headings.mjs +64 -0
- package/dist/components/ui/document-editor/headings.mjs.map +1 -0
- package/dist/components/ui/document-editor/image.mjs +318 -0
- package/dist/components/ui/document-editor/image.mjs.map +1 -0
- package/dist/components/ui/document-editor/index.mjs +131 -0
- package/dist/components/ui/document-editor/index.mjs.map +1 -0
- package/dist/components/ui/document-editor/labels.mjs +96 -0
- package/dist/components/ui/document-editor/labels.mjs.map +1 -0
- package/dist/components/ui/document-editor/link-card.mjs +138 -0
- package/dist/components/ui/document-editor/link-card.mjs.map +1 -0
- package/dist/components/ui/document-editor/mentions.mjs +105 -0
- package/dist/components/ui/document-editor/mentions.mjs.map +1 -0
- package/dist/components/ui/document-editor/outline.mjs +138 -0
- package/dist/components/ui/document-editor/outline.mjs.map +1 -0
- package/dist/components/ui/document-editor/section-fold.mjs +124 -0
- package/dist/components/ui/document-editor/section-fold.mjs.map +1 -0
- package/dist/components/ui/document-editor/slash-command.mjs +210 -0
- package/dist/components/ui/document-editor/slash-command.mjs.map +1 -0
- package/dist/components/ui/document-editor/suggest-list.mjs +187 -0
- package/dist/components/ui/document-editor/suggest-list.mjs.map +1 -0
- package/dist/components/ui/document-editor/table.mjs +242 -0
- package/dist/components/ui/document-editor/table.mjs.map +1 -0
- package/dist/components/ui/document-editor/templates.mjs +66 -0
- package/dist/components/ui/document-editor/templates.mjs.map +1 -0
- package/dist/components/ui/document-editor/toggle.mjs +176 -0
- package/dist/components/ui/document-editor/toggle.mjs.map +1 -0
- package/dist/components/ui/document-editor/typography-rules.mjs +8 -0
- package/dist/components/ui/document-editor/typography-rules.mjs.map +1 -0
- package/dist/components/ui/document-editor/use-editor-value.mjs +34 -0
- package/dist/components/ui/document-editor/use-editor-value.mjs.map +1 -0
- package/dist/components/ui/drawer/drawer-nav.mjs +153 -0
- package/dist/components/ui/drawer/drawer-nav.mjs.map +1 -0
- package/dist/components/ui/drawer/drawer.mjs +334 -0
- package/dist/components/ui/drawer/drawer.mjs.map +1 -0
- package/dist/components/ui/drawer/index.mjs +37 -0
- package/dist/components/ui/drawer/index.mjs.map +1 -0
- package/dist/components/ui/drawer/use-swipe-to-close.mjs +77 -0
- package/dist/components/ui/drawer/use-swipe-to-close.mjs.map +1 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu.mjs +567 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu.mjs.map +1 -0
- package/dist/components/ui/dropdown-menu/index.mjs +43 -0
- package/dist/components/ui/dropdown-menu/index.mjs.map +1 -0
- package/dist/components/ui/editable-text/editable-text.mjs +148 -0
- package/dist/components/ui/editable-text/editable-text.mjs.map +1 -0
- package/dist/components/ui/editable-text/index.mjs +6 -0
- package/dist/components/ui/editable-text/index.mjs.map +1 -0
- package/dist/components/ui/emoji-picker/emoji-data.mjs +469 -0
- package/dist/components/ui/emoji-picker/emoji-data.mjs.map +1 -0
- package/dist/components/ui/emoji-picker/emoji-picker.mjs +464 -0
- package/dist/components/ui/emoji-picker/emoji-picker.mjs.map +1 -0
- package/dist/components/ui/emoji-picker/index.mjs +19 -0
- package/dist/components/ui/emoji-picker/index.mjs.map +1 -0
- package/dist/components/ui/empty-state/empty-state.mjs +110 -0
- package/dist/components/ui/empty-state/empty-state.mjs.map +1 -0
- package/dist/components/ui/empty-state/index.mjs +17 -0
- package/dist/components/ui/empty-state/index.mjs.map +1 -0
- package/dist/components/ui/event-calendar/calendar-math.mjs +256 -0
- package/dist/components/ui/event-calendar/calendar-math.mjs.map +1 -0
- package/dist/components/ui/event-calendar/context.mjs +51 -0
- package/dist/components/ui/event-calendar/context.mjs.map +1 -0
- package/dist/components/ui/event-calendar/editor.mjs +292 -0
- package/dist/components/ui/event-calendar/editor.mjs.map +1 -0
- package/dist/components/ui/event-calendar/event-block.mjs +55 -0
- package/dist/components/ui/event-calendar/event-block.mjs.map +1 -0
- package/dist/components/ui/event-calendar/event-calendar.mjs +438 -0
- package/dist/components/ui/event-calendar/event-calendar.mjs.map +1 -0
- package/dist/components/ui/event-calendar/event-keys.mjs +41 -0
- package/dist/components/ui/event-calendar/event-keys.mjs.map +1 -0
- package/dist/components/ui/event-calendar/index.mjs +37 -0
- package/dist/components/ui/event-calendar/index.mjs.map +1 -0
- package/dist/components/ui/event-calendar/month-grid.mjs +207 -0
- package/dist/components/ui/event-calendar/month-grid.mjs.map +1 -0
- package/dist/components/ui/event-calendar/narrow.mjs +193 -0
- package/dist/components/ui/event-calendar/narrow.mjs.map +1 -0
- package/dist/components/ui/event-calendar/time-grid.mjs +534 -0
- package/dist/components/ui/event-calendar/time-grid.mjs.map +1 -0
- package/dist/components/ui/expandable-search/expandable-search.mjs +174 -0
- package/dist/components/ui/expandable-search/expandable-search.mjs.map +1 -0
- package/dist/components/ui/expandable-search/index.mjs +6 -0
- package/dist/components/ui/expandable-search/index.mjs.map +1 -0
- package/dist/components/ui/field/field.mjs +444 -0
- package/dist/components/ui/field/field.mjs.map +1 -0
- package/dist/components/ui/field/index.mjs +21 -0
- package/dist/components/ui/field/index.mjs.map +1 -0
- package/dist/components/ui/file-card/file-card.mjs +198 -0
- package/dist/components/ui/file-card/file-card.mjs.map +1 -0
- package/dist/components/ui/file-card/file-icon.mjs +66 -0
- package/dist/components/ui/file-card/file-icon.mjs.map +1 -0
- package/dist/components/ui/file-card/file-types.mjs +70 -0
- package/dist/components/ui/file-card/file-types.mjs.map +1 -0
- package/dist/components/ui/file-card/index.mjs +32 -0
- package/dist/components/ui/file-card/index.mjs.map +1 -0
- package/dist/components/ui/file-preview/context.mjs +77 -0
- package/dist/components/ui/file-preview/context.mjs.map +1 -0
- package/dist/components/ui/file-preview/file-preview.mjs +865 -0
- package/dist/components/ui/file-preview/file-preview.mjs.map +1 -0
- package/dist/components/ui/file-preview/index.mjs +56 -0
- package/dist/components/ui/file-preview/index.mjs.map +1 -0
- package/dist/components/ui/file-preview/pdf.mjs +250 -0
- package/dist/components/ui/file-preview/pdf.mjs.map +1 -0
- package/dist/components/ui/file-preview/renderers.mjs +257 -0
- package/dist/components/ui/file-preview/renderers.mjs.map +1 -0
- package/dist/components/ui/file-upload/file-upload.mjs +633 -0
- package/dist/components/ui/file-upload/file-upload.mjs.map +1 -0
- package/dist/components/ui/file-upload/index.mjs +42 -0
- package/dist/components/ui/file-upload/index.mjs.map +1 -0
- package/dist/components/ui/file-upload/validate.mjs +111 -0
- package/dist/components/ui/file-upload/validate.mjs.map +1 -0
- package/dist/components/ui/flag/flag.mjs +39 -0
- package/dist/components/ui/flag/flag.mjs.map +1 -0
- package/dist/components/ui/flag/index.mjs +7 -0
- package/dist/components/ui/flag/index.mjs.map +1 -0
- package/dist/components/ui/floating-window/floating-window.mjs +255 -0
- package/dist/components/ui/floating-window/floating-window.mjs.map +1 -0
- package/dist/components/ui/floating-window/index.mjs +11 -0
- package/dist/components/ui/floating-window/index.mjs.map +1 -0
- package/dist/components/ui/form/form-section.mjs +87 -0
- package/dist/components/ui/form/form-section.mjs.map +1 -0
- package/dist/components/ui/form/form.mjs +205 -0
- package/dist/components/ui/form/form.mjs.map +1 -0
- package/dist/components/ui/form/index.mjs +29 -0
- package/dist/components/ui/form/index.mjs.map +1 -0
- package/dist/components/ui/globe/globe-data.mjs +9 -0
- package/dist/components/ui/globe/globe-data.mjs.map +1 -0
- package/dist/components/ui/globe/globe-math.mjs +269 -0
- package/dist/components/ui/globe/globe-math.mjs.map +1 -0
- package/dist/components/ui/globe/globe.mjs +719 -0
- package/dist/components/ui/globe/globe.mjs.map +1 -0
- package/dist/components/ui/globe/index.mjs +13 -0
- package/dist/components/ui/globe/index.mjs.map +1 -0
- package/dist/components/ui/highlight-match/highlight-children.mjs +13 -0
- package/dist/components/ui/highlight-match/highlight-children.mjs.map +1 -0
- package/dist/components/ui/highlight-match/highlight-match-variants.mjs +17 -0
- package/dist/components/ui/highlight-match/highlight-match-variants.mjs.map +1 -0
- package/dist/components/ui/highlight-match/highlight-match.mjs +37 -0
- package/dist/components/ui/highlight-match/highlight-match.mjs.map +1 -0
- package/dist/components/ui/highlight-match/index.mjs +15 -0
- package/dist/components/ui/highlight-match/index.mjs.map +1 -0
- package/dist/components/ui/highlight-match/match-ranges.mjs +50 -0
- package/dist/components/ui/highlight-match/match-ranges.mjs.map +1 -0
- package/dist/components/ui/histogram-slider/histogram-slider.mjs +83 -0
- package/dist/components/ui/histogram-slider/histogram-slider.mjs.map +1 -0
- package/dist/components/ui/histogram-slider/index.mjs +6 -0
- package/dist/components/ui/histogram-slider/index.mjs.map +1 -0
- package/dist/components/ui/hold-button/hold-button.mjs +258 -0
- package/dist/components/ui/hold-button/hold-button.mjs.map +1 -0
- package/dist/components/ui/hold-button/index.mjs +6 -0
- package/dist/components/ui/hold-button/index.mjs.map +1 -0
- package/dist/components/ui/hover-card/hover-card.mjs +111 -0
- package/dist/components/ui/hover-card/hover-card.mjs.map +1 -0
- package/dist/components/ui/hover-card/index.mjs +21 -0
- package/dist/components/ui/hover-card/index.mjs.map +1 -0
- package/dist/components/ui/ink-tray/index.mjs +29 -0
- package/dist/components/ui/ink-tray/index.mjs.map +1 -0
- package/dist/components/ui/ink-tray/ink-tray-art.mjs +68 -0
- package/dist/components/ui/ink-tray/ink-tray-art.mjs.map +1 -0
- package/dist/components/ui/ink-tray/ink-tray.mjs +350 -0
- package/dist/components/ui/ink-tray/ink-tray.mjs.map +1 -0
- package/dist/components/ui/input/index.mjs +41 -0
- package/dist/components/ui/input/index.mjs.map +1 -0
- package/dist/components/ui/input/input.mjs +268 -0
- package/dist/components/ui/input/input.mjs.map +1 -0
- package/dist/components/ui/input/number-input.mjs +272 -0
- package/dist/components/ui/input/number-input.mjs.map +1 -0
- package/dist/components/ui/input/password-input.mjs +49 -0
- package/dist/components/ui/input/password-input.mjs.map +1 -0
- package/dist/components/ui/input/phone-input-countries.mjs +216 -0
- package/dist/components/ui/input/phone-input-countries.mjs.map +1 -0
- package/dist/components/ui/input/phone-input.mjs +326 -0
- package/dist/components/ui/input/phone-input.mjs.map +1 -0
- package/dist/components/ui/input/use-controllable-state.mjs +24 -0
- package/dist/components/ui/input/use-controllable-state.mjs.map +1 -0
- package/dist/components/ui/input/use-hold-repeat.mjs +35 -0
- package/dist/components/ui/input/use-hold-repeat.mjs.map +1 -0
- package/dist/components/ui/input-group/index.mjs +11 -0
- package/dist/components/ui/input-group/index.mjs.map +1 -0
- package/dist/components/ui/input-group/input-group.mjs +78 -0
- package/dist/components/ui/input-group/input-group.mjs.map +1 -0
- package/dist/components/ui/island/index.mjs +23 -0
- package/dist/components/ui/island/index.mjs.map +1 -0
- package/dist/components/ui/island/island.mjs +328 -0
- package/dist/components/ui/island/island.mjs.map +1 -0
- package/dist/components/ui/kbd/index.mjs +6 -0
- package/dist/components/ui/kbd/index.mjs.map +1 -0
- package/dist/components/ui/kbd/kbd.mjs +73 -0
- package/dist/components/ui/kbd/kbd.mjs.map +1 -0
- package/dist/components/ui/keypad/index.mjs +23 -0
- package/dist/components/ui/keypad/index.mjs.map +1 -0
- package/dist/components/ui/keypad/keypad.mjs +345 -0
- package/dist/components/ui/keypad/keypad.mjs.map +1 -0
- package/dist/components/ui/label/index.mjs +7 -0
- package/dist/components/ui/label/index.mjs.map +1 -0
- package/dist/components/ui/label/label.mjs +117 -0
- package/dist/components/ui/label/label.mjs.map +1 -0
- package/dist/components/ui/lightbox/index.mjs +47 -0
- package/dist/components/ui/lightbox/index.mjs.map +1 -0
- package/dist/components/ui/lightbox/labels.mjs +23 -0
- package/dist/components/ui/lightbox/labels.mjs.map +1 -0
- package/dist/components/ui/lightbox/lightbox.mjs +1359 -0
- package/dist/components/ui/lightbox/lightbox.mjs.map +1 -0
- package/dist/components/ui/link/index.mjs +6 -0
- package/dist/components/ui/link/index.mjs.map +1 -0
- package/dist/components/ui/link/link.mjs +64 -0
- package/dist/components/ui/link/link.mjs.map +1 -0
- package/dist/components/ui/list/index.mjs +35 -0
- package/dist/components/ui/list/index.mjs.map +1 -0
- package/dist/components/ui/list/list.mjs +505 -0
- package/dist/components/ui/list/list.mjs.map +1 -0
- package/dist/components/ui/load-more/index.mjs +23 -0
- package/dist/components/ui/load-more/index.mjs.map +1 -0
- package/dist/components/ui/load-more/load-more.mjs +409 -0
- package/dist/components/ui/load-more/load-more.mjs.map +1 -0
- package/dist/components/ui/map/index.mjs +27 -0
- package/dist/components/ui/map/index.mjs.map +1 -0
- package/dist/components/ui/map/map-style.mjs +169 -0
- package/dist/components/ui/map/map-style.mjs.map +1 -0
- package/dist/components/ui/map/map.mjs +624 -0
- package/dist/components/ui/map/map.mjs.map +1 -0
- package/dist/components/ui/map-pin/index.mjs +6 -0
- package/dist/components/ui/map-pin/index.mjs.map +1 -0
- package/dist/components/ui/map-pin/map-pin.mjs +55 -0
- package/dist/components/ui/map-pin/map-pin.mjs.map +1 -0
- package/dist/components/ui/mention/index.mjs +29 -0
- package/dist/components/ui/mention/index.mjs.map +1 -0
- package/dist/components/ui/mention/mention.mjs +262 -0
- package/dist/components/ui/mention/mention.mjs.map +1 -0
- package/dist/components/ui/mention/split-mentions.mjs +24 -0
- package/dist/components/ui/mention/split-mentions.mjs.map +1 -0
- package/dist/components/ui/menubar/index.mjs +39 -0
- package/dist/components/ui/menubar/index.mjs.map +1 -0
- package/dist/components/ui/menubar/menubar.mjs +222 -0
- package/dist/components/ui/menubar/menubar.mjs.map +1 -0
- package/dist/components/ui/meter/index.mjs +21 -0
- package/dist/components/ui/meter/index.mjs.map +1 -0
- package/dist/components/ui/meter/meter.mjs +167 -0
- package/dist/components/ui/meter/meter.mjs.map +1 -0
- package/dist/components/ui/multi-select/index.mjs +25 -0
- package/dist/components/ui/multi-select/index.mjs.map +1 -0
- package/dist/components/ui/multi-select/multi-select.mjs +285 -0
- package/dist/components/ui/multi-select/multi-select.mjs.map +1 -0
- package/dist/components/ui/navigation-menu/index.mjs +41 -0
- package/dist/components/ui/navigation-menu/index.mjs.map +1 -0
- package/dist/components/ui/navigation-menu/navigation-menu.mjs +396 -0
- package/dist/components/ui/navigation-menu/navigation-menu.mjs.map +1 -0
- package/dist/components/ui/notebook-page/index.mjs +15 -0
- package/dist/components/ui/notebook-page/index.mjs.map +1 -0
- package/dist/components/ui/notebook-page/notebook-page.mjs +162 -0
- package/dist/components/ui/notebook-page/notebook-page.mjs.map +1 -0
- package/dist/components/ui/notification-inbox/index.mjs +47 -0
- package/dist/components/ui/notification-inbox/index.mjs.map +1 -0
- package/dist/components/ui/notification-inbox/notification-inbox.mjs +422 -0
- package/dist/components/ui/notification-inbox/notification-inbox.mjs.map +1 -0
- package/dist/components/ui/number-field/index.mjs +24 -0
- package/dist/components/ui/number-field/index.mjs.map +1 -0
- package/dist/components/ui/number-field/number-field.mjs +460 -0
- package/dist/components/ui/number-field/number-field.mjs.map +1 -0
- package/dist/components/ui/number-field/number-format.mjs +48 -0
- package/dist/components/ui/number-field/number-format.mjs.map +1 -0
- package/dist/components/ui/otp-input/index.mjs +9 -0
- package/dist/components/ui/otp-input/index.mjs.map +1 -0
- package/dist/components/ui/otp-input/otp-input.mjs +285 -0
- package/dist/components/ui/otp-input/otp-input.mjs.map +1 -0
- package/dist/components/ui/pager/index.mjs +7 -0
- package/dist/components/ui/pager/index.mjs.map +1 -0
- package/dist/components/ui/pager/pager.mjs +86 -0
- package/dist/components/ui/pager/pager.mjs.map +1 -0
- package/dist/components/ui/pagination/index.mjs +23 -0
- package/dist/components/ui/pagination/index.mjs.map +1 -0
- package/dist/components/ui/pagination/pagination.mjs +210 -0
- package/dist/components/ui/pagination/pagination.mjs.map +1 -0
- package/dist/components/ui/password-strength/index.mjs +21 -0
- package/dist/components/ui/password-strength/index.mjs.map +1 -0
- package/dist/components/ui/password-strength/password-rules.mjs +25 -0
- package/dist/components/ui/password-strength/password-rules.mjs.map +1 -0
- package/dist/components/ui/password-strength/password-strength.mjs +125 -0
- package/dist/components/ui/password-strength/password-strength.mjs.map +1 -0
- package/dist/components/ui/popover/index.mjs +31 -0
- package/dist/components/ui/popover/index.mjs.map +1 -0
- package/dist/components/ui/popover/popover.mjs +574 -0
- package/dist/components/ui/popover/popover.mjs.map +1 -0
- package/dist/components/ui/progress/index.mjs +15 -0
- package/dist/components/ui/progress/index.mjs.map +1 -0
- package/dist/components/ui/progress/progress.mjs +224 -0
- package/dist/components/ui/progress/progress.mjs.map +1 -0
- package/dist/components/ui/prose/index.mjs +6 -0
- package/dist/components/ui/prose/index.mjs.map +1 -0
- package/dist/components/ui/prose/prose.mjs +89 -0
- package/dist/components/ui/prose/prose.mjs.map +1 -0
- package/dist/components/ui/radio-group/index.mjs +15 -0
- package/dist/components/ui/radio-group/index.mjs.map +1 -0
- package/dist/components/ui/radio-group/radio-group.mjs +88 -0
- package/dist/components/ui/radio-group/radio-group.mjs.map +1 -0
- package/dist/components/ui/rating/index.mjs +6 -0
- package/dist/components/ui/rating/index.mjs.map +1 -0
- package/dist/components/ui/rating/rating.mjs +119 -0
- package/dist/components/ui/rating/rating.mjs.map +1 -0
- package/dist/components/ui/rich-text-editor/bubble-menu.mjs +120 -0
- package/dist/components/ui/rich-text-editor/bubble-menu.mjs.map +1 -0
- package/dist/components/ui/rich-text-editor/image-links.mjs +63 -0
- package/dist/components/ui/rich-text-editor/image-links.mjs.map +1 -0
- package/dist/components/ui/rich-text-editor/index.mjs +37 -0
- package/dist/components/ui/rich-text-editor/index.mjs.map +1 -0
- package/dist/components/ui/rich-text-editor/labels.mjs +27 -0
- package/dist/components/ui/rich-text-editor/labels.mjs.map +1 -0
- package/dist/components/ui/rich-text-editor/rich-text-editor.mjs +149 -0
- package/dist/components/ui/rich-text-editor/rich-text-editor.mjs.map +1 -0
- package/dist/components/ui/rich-text-editor/toolbar.mjs +325 -0
- package/dist/components/ui/rich-text-editor/toolbar.mjs.map +1 -0
- package/dist/components/ui/save-bar/index.mjs +13 -0
- package/dist/components/ui/save-bar/index.mjs.map +1 -0
- package/dist/components/ui/save-bar/save-bar.mjs +59 -0
- package/dist/components/ui/save-bar/save-bar.mjs.map +1 -0
- package/dist/components/ui/scroll-area/index.mjs +6 -0
- package/dist/components/ui/scroll-area/index.mjs.map +1 -0
- package/dist/components/ui/scroll-area/scroll-area.mjs +148 -0
- package/dist/components/ui/scroll-area/scroll-area.mjs.map +1 -0
- package/dist/components/ui/scroll-area/use-drag-scroll.mjs +134 -0
- package/dist/components/ui/scroll-area/use-drag-scroll.mjs.map +1 -0
- package/dist/components/ui/select/index.mjs +23 -0
- package/dist/components/ui/select/index.mjs.map +1 -0
- package/dist/components/ui/select/select.mjs +216 -0
- package/dist/components/ui/select/select.mjs.map +1 -0
- package/dist/components/ui/sheet/index.mjs +23 -0
- package/dist/components/ui/sheet/index.mjs.map +1 -0
- package/dist/components/ui/sheet/sheet.mjs +292 -0
- package/dist/components/ui/sheet/sheet.mjs.map +1 -0
- package/dist/components/ui/sidebar/index.mjs +122 -0
- package/dist/components/ui/sidebar/index.mjs.map +1 -0
- package/dist/components/ui/sidebar/sidebar-group.mjs +75 -0
- package/dist/components/ui/sidebar/sidebar-group.mjs.map +1 -0
- package/dist/components/ui/sidebar/sidebar-item.mjs +199 -0
- package/dist/components/ui/sidebar/sidebar-item.mjs.map +1 -0
- package/dist/components/ui/sidebar/sidebar-panels.mjs +182 -0
- package/dist/components/ui/sidebar/sidebar-panels.mjs.map +1 -0
- package/dist/components/ui/sidebar/sidebar-peek.mjs +324 -0
- package/dist/components/ui/sidebar/sidebar-peek.mjs.map +1 -0
- package/dist/components/ui/sidebar/sidebar-rich.mjs +65 -0
- package/dist/components/ui/sidebar/sidebar-rich.mjs.map +1 -0
- package/dist/components/ui/sidebar/sidebar-tree.mjs +224 -0
- package/dist/components/ui/sidebar/sidebar-tree.mjs.map +1 -0
- package/dist/components/ui/sidebar/sidebar.mjs +205 -0
- package/dist/components/ui/sidebar/sidebar.mjs.map +1 -0
- package/dist/components/ui/sidebar/variants.mjs +396 -0
- package/dist/components/ui/sidebar/variants.mjs.map +1 -0
- package/dist/components/ui/signature/index.mjs +6 -0
- package/dist/components/ui/signature/index.mjs.map +1 -0
- package/dist/components/ui/signature/signature.mjs +145 -0
- package/dist/components/ui/signature/signature.mjs.map +1 -0
- package/dist/components/ui/signature-pad/index.mjs +19 -0
- package/dist/components/ui/signature-pad/index.mjs.map +1 -0
- package/dist/components/ui/signature-pad/signature-pad.mjs +210 -0
- package/dist/components/ui/signature-pad/signature-pad.mjs.map +1 -0
- package/dist/components/ui/signature-pad/strokes.mjs +68 -0
- package/dist/components/ui/signature-pad/strokes.mjs.map +1 -0
- package/dist/components/ui/skeleton/index.mjs +9 -0
- package/dist/components/ui/skeleton/index.mjs.map +1 -0
- package/dist/components/ui/skeleton/skeleton.mjs +58 -0
- package/dist/components/ui/skeleton/skeleton.mjs.map +1 -0
- package/dist/components/ui/slide/index.mjs +25 -0
- package/dist/components/ui/slide/index.mjs.map +1 -0
- package/dist/components/ui/slide/slide.mjs +159 -0
- package/dist/components/ui/slide/slide.mjs.map +1 -0
- package/dist/components/ui/slider/index.mjs +21 -0
- package/dist/components/ui/slider/index.mjs.map +1 -0
- package/dist/components/ui/slider/slider-input.mjs +449 -0
- package/dist/components/ui/slider/slider-input.mjs.map +1 -0
- package/dist/components/ui/slider/slider.mjs +235 -0
- package/dist/components/ui/slider/slider.mjs.map +1 -0
- package/dist/components/ui/slides/index.mjs +31 -0
- package/dist/components/ui/slides/index.mjs.map +1 -0
- package/dist/components/ui/slides/slides.mjs +890 -0
- package/dist/components/ui/slides/slides.mjs.map +1 -0
- package/dist/components/ui/smooth-anchors/index.mjs +17 -0
- package/dist/components/ui/smooth-anchors/index.mjs.map +1 -0
- package/dist/components/ui/smooth-anchors/smooth-anchors.mjs +75 -0
- package/dist/components/ui/smooth-anchors/smooth-anchors.mjs.map +1 -0
- package/dist/components/ui/smooth-anchors/smooth-scroll.mjs +87 -0
- package/dist/components/ui/smooth-anchors/smooth-scroll.mjs.map +1 -0
- package/dist/components/ui/spinner/index.mjs +6 -0
- package/dist/components/ui/spinner/index.mjs.map +1 -0
- package/dist/components/ui/spinner/spinner.mjs +49 -0
- package/dist/components/ui/spinner/spinner.mjs.map +1 -0
- package/dist/components/ui/stat/index.mjs +29 -0
- package/dist/components/ui/stat/index.mjs.map +1 -0
- package/dist/components/ui/stat/stat.mjs +226 -0
- package/dist/components/ui/stat/stat.mjs.map +1 -0
- package/dist/components/ui/status-bar/index.mjs +17 -0
- package/dist/components/ui/status-bar/index.mjs.map +1 -0
- package/dist/components/ui/status-bar/status-bar.mjs +96 -0
- package/dist/components/ui/status-bar/status-bar.mjs.map +1 -0
- package/dist/components/ui/stepper/index.mjs +25 -0
- package/dist/components/ui/stepper/index.mjs.map +1 -0
- package/dist/components/ui/stepper/stepper.mjs +235 -0
- package/dist/components/ui/stepper/stepper.mjs.map +1 -0
- package/dist/components/ui/steps/index.mjs +9 -0
- package/dist/components/ui/steps/index.mjs.map +1 -0
- package/dist/components/ui/steps/steps.mjs +70 -0
- package/dist/components/ui/steps/steps.mjs.map +1 -0
- package/dist/components/ui/swatch-grid/index.mjs +7 -0
- package/dist/components/ui/swatch-grid/index.mjs.map +1 -0
- package/dist/components/ui/swatch-grid/swatch-grid.mjs +110 -0
- package/dist/components/ui/swatch-grid/swatch-grid.mjs.map +1 -0
- package/dist/components/ui/switch/index.mjs +7 -0
- package/dist/components/ui/switch/index.mjs.map +1 -0
- package/dist/components/ui/switch/switch.mjs +79 -0
- package/dist/components/ui/switch/switch.mjs.map +1 -0
- package/dist/components/ui/tab-strip/index.mjs +13 -0
- package/dist/components/ui/tab-strip/index.mjs.map +1 -0
- package/dist/components/ui/tab-strip/tab-strip.mjs +244 -0
- package/dist/components/ui/tab-strip/tab-strip.mjs.map +1 -0
- package/dist/components/ui/table/index.mjs +27 -0
- package/dist/components/ui/table/index.mjs.map +1 -0
- package/dist/components/ui/table/table.mjs +290 -0
- package/dist/components/ui/table/table.mjs.map +1 -0
- package/dist/components/ui/table-of-contents/index.mjs +20 -0
- package/dist/components/ui/table-of-contents/index.mjs.map +1 -0
- package/dist/components/ui/table-of-contents/scroll-spy.mjs +60 -0
- package/dist/components/ui/table-of-contents/scroll-spy.mjs.map +1 -0
- package/dist/components/ui/table-of-contents/table-of-contents.mjs +371 -0
- package/dist/components/ui/table-of-contents/table-of-contents.mjs.map +1 -0
- package/dist/components/ui/table-of-contents/use-headings.mjs +40 -0
- package/dist/components/ui/table-of-contents/use-headings.mjs.map +1 -0
- package/dist/components/ui/tablet-frame/index.mjs +7 -0
- package/dist/components/ui/tablet-frame/index.mjs.map +1 -0
- package/dist/components/ui/tablet-frame/tablet-frame.mjs +48 -0
- package/dist/components/ui/tablet-frame/tablet-frame.mjs.map +1 -0
- package/dist/components/ui/tabs/index.mjs +25 -0
- package/dist/components/ui/tabs/index.mjs.map +1 -0
- package/dist/components/ui/tabs/tabs.mjs +382 -0
- package/dist/components/ui/tabs/tabs.mjs.map +1 -0
- package/dist/components/ui/tabs/use-tabs-indicator.mjs +90 -0
- package/dist/components/ui/tabs/use-tabs-indicator.mjs.map +1 -0
- package/dist/components/ui/tags-input/index.mjs +9 -0
- package/dist/components/ui/tags-input/index.mjs.map +1 -0
- package/dist/components/ui/tags-input/split.mjs +38 -0
- package/dist/components/ui/tags-input/split.mjs.map +1 -0
- package/dist/components/ui/tags-input/tags-input.mjs +328 -0
- package/dist/components/ui/tags-input/tags-input.mjs.map +1 -0
- package/dist/components/ui/terminal/index.mjs +41 -0
- package/dist/components/ui/terminal/index.mjs.map +1 -0
- package/dist/components/ui/terminal/terminal.mjs +287 -0
- package/dist/components/ui/terminal/terminal.mjs.map +1 -0
- package/dist/components/ui/textarea/index.mjs +21 -0
- package/dist/components/ui/textarea/index.mjs.map +1 -0
- package/dist/components/ui/textarea/textarea.mjs +244 -0
- package/dist/components/ui/textarea/textarea.mjs.map +1 -0
- package/dist/components/ui/toast/index.mjs +19 -0
- package/dist/components/ui/toast/index.mjs.map +1 -0
- package/dist/components/ui/toast/store.mjs +96 -0
- package/dist/components/ui/toast/store.mjs.map +1 -0
- package/dist/components/ui/toast/toast.mjs +395 -0
- package/dist/components/ui/toast/toast.mjs.map +1 -0
- package/dist/components/ui/toggle/index.mjs +13 -0
- package/dist/components/ui/toggle/index.mjs.map +1 -0
- package/dist/components/ui/toggle/toggle.mjs +123 -0
- package/dist/components/ui/toggle/toggle.mjs.map +1 -0
- package/dist/components/ui/toggle-group/index.mjs +11 -0
- package/dist/components/ui/toggle-group/index.mjs.map +1 -0
- package/dist/components/ui/toggle-group/toggle-group.mjs +243 -0
- package/dist/components/ui/toggle-group/toggle-group.mjs.map +1 -0
- package/dist/components/ui/toggletip/index.mjs +6 -0
- package/dist/components/ui/toggletip/index.mjs.map +1 -0
- package/dist/components/ui/toggletip/toggletip.mjs +95 -0
- package/dist/components/ui/toggletip/toggletip.mjs.map +1 -0
- package/dist/components/ui/toolbar/index.mjs +21 -0
- package/dist/components/ui/toolbar/index.mjs.map +1 -0
- package/dist/components/ui/toolbar/toolbar.mjs +130 -0
- package/dist/components/ui/toolbar/toolbar.mjs.map +1 -0
- package/dist/components/ui/tooltip/index.mjs +29 -0
- package/dist/components/ui/tooltip/index.mjs.map +1 -0
- package/dist/components/ui/tooltip/tooltip.mjs +640 -0
- package/dist/components/ui/tooltip/tooltip.mjs.map +1 -0
- package/dist/components/ui/tree/index.mjs +11 -0
- package/dist/components/ui/tree/index.mjs.map +1 -0
- package/dist/components/ui/tree/tree.mjs +450 -0
- package/dist/components/ui/tree/tree.mjs.map +1 -0
- package/dist/index.d.mts +19332 -0
- package/dist/index.mjs +155 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/color.mjs +78 -0
- package/dist/lib/color.mjs.map +1 -0
- package/dist/lib/create-context.mjs +31 -0
- package/dist/lib/create-context.mjs.map +1 -0
- package/dist/lib/date.mjs +116 -0
- package/dist/lib/date.mjs.map +1 -0
- package/dist/lib/density.mjs +79 -0
- package/dist/lib/density.mjs.map +1 -0
- package/dist/lib/field-context.mjs +13 -0
- package/dist/lib/field-context.mjs.map +1 -0
- package/dist/lib/filter.mjs +28 -0
- package/dist/lib/filter.mjs.map +1 -0
- package/dist/lib/gesture.mjs +38 -0
- package/dist/lib/gesture.mjs.map +1 -0
- package/dist/lib/hit-area.mjs +14 -0
- package/dist/lib/hit-area.mjs.map +1 -0
- package/dist/lib/labels.mjs +27 -0
- package/dist/lib/labels.mjs.map +1 -0
- package/dist/lib/morph-box.mjs +56 -0
- package/dist/lib/morph-box.mjs.map +1 -0
- package/dist/lib/motion.mjs +70 -0
- package/dist/lib/motion.mjs.map +1 -0
- package/dist/lib/pulse.mjs +69 -0
- package/dist/lib/pulse.mjs.map +1 -0
- package/dist/lib/roving-focus.mjs +74 -0
- package/dist/lib/roving-focus.mjs.map +1 -0
- package/dist/lib/tv.mjs +11 -0
- package/dist/lib/tv.mjs.map +1 -0
- package/dist/lib/utils.mjs +82 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/dist/styles.css +2 -0
- package/package.json +133 -4
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Extension, InputRule } from "@tiptap/core";
|
|
4
|
+
import { PluginKey } from "@tiptap/pm/state";
|
|
5
|
+
import { Suggestion } from "@tiptap/suggestion";
|
|
6
|
+
import { emojiCategories } from "../emoji-picker/index.mjs";
|
|
7
|
+
import { labelsOf } from "./doc-labels.mjs";
|
|
8
|
+
import { suggestRender } from "./suggest-list.mjs";
|
|
9
|
+
const words = (text) => text.toLowerCase().split(/[\s_-]+/).filter(Boolean);
|
|
10
|
+
function search(all, query, limit) {
|
|
11
|
+
const q = query.toLowerCase().replace(/[_-]+/g, " ").trim();
|
|
12
|
+
if (!q) return [];
|
|
13
|
+
const score = (e) => {
|
|
14
|
+
const name = e.name.toLowerCase();
|
|
15
|
+
if (name === q) return 0;
|
|
16
|
+
if (name.startsWith(q)) return 1;
|
|
17
|
+
if (e.keywords.includes(q)) return 2;
|
|
18
|
+
if (words(name).some((w) => w.startsWith(q))) return 3;
|
|
19
|
+
return e.keywords.some((k) => k.startsWith(q)) ? 4 : 5;
|
|
20
|
+
};
|
|
21
|
+
return all.map((emoji) => ({ emoji, rank: score(emoji) })).filter(({ rank }) => rank < 5).sort((a, b) => a.rank - b.rank).slice(0, limit).map(({ emoji }) => emoji);
|
|
22
|
+
}
|
|
23
|
+
function emojiSuggestExtension({ data = emojiCategories, limit = 8, minLength = 2 } = {}) {
|
|
24
|
+
const all = data.flatMap((c) => c.emojis);
|
|
25
|
+
const key = new PluginKey("emojiSuggest");
|
|
26
|
+
return Extension.create({
|
|
27
|
+
name: "emojiSuggest",
|
|
28
|
+
addInputRules() {
|
|
29
|
+
return [
|
|
30
|
+
new InputRule({
|
|
31
|
+
find: /(?:^|\s):([a-z0-9][a-z0-9_+-]+):$/i,
|
|
32
|
+
handler: ({ state, range, match }) => {
|
|
33
|
+
const q = match[1].toLowerCase().replace(/[_-]+/g, " ");
|
|
34
|
+
const exact = all.find((e) => e.name.toLowerCase() === q) ?? all.find((e) => e.keywords.includes(q));
|
|
35
|
+
if (!exact) return null;
|
|
36
|
+
const lead = match[0].startsWith(":") ? 0 : 1;
|
|
37
|
+
state.tr.insertText(exact.char, range.from + lead, range.to);
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
];
|
|
41
|
+
},
|
|
42
|
+
addProseMirrorPlugins() {
|
|
43
|
+
return [
|
|
44
|
+
Suggestion({
|
|
45
|
+
editor: this.editor,
|
|
46
|
+
char: ":",
|
|
47
|
+
pluginKey: key,
|
|
48
|
+
// Closed until there's something to show, so it never takes a key it doesn't use.
|
|
49
|
+
allow: ({ state, range }) => {
|
|
50
|
+
const query = state.doc.textBetween(range.from, range.to).slice(1);
|
|
51
|
+
return query.length >= minLength && search(all, query, 1).length > 0;
|
|
52
|
+
},
|
|
53
|
+
items: ({ query }) => search(all, query, limit),
|
|
54
|
+
command: ({ editor, range, props }) => {
|
|
55
|
+
editor.chain().focus().insertContentAt(range, props.char).run();
|
|
56
|
+
},
|
|
57
|
+
render: suggestRender({
|
|
58
|
+
name: "emoji",
|
|
59
|
+
order: 2,
|
|
60
|
+
key,
|
|
61
|
+
groups: (items, pick, editor) => [
|
|
62
|
+
{
|
|
63
|
+
label: labelsOf(editor).emoji,
|
|
64
|
+
rows: items.map((e) => ({
|
|
65
|
+
id: e.char,
|
|
66
|
+
label: e.name,
|
|
67
|
+
lead: /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "w-5 shrink-0 text-center", children: e.char }),
|
|
68
|
+
pick: () => pick(e)
|
|
69
|
+
}))
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
emojiSuggestExtension
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=emoji-suggest.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/document-editor/emoji-suggest.tsx"],"sourcesContent":["\"use client\"\n\nimport { Extension, InputRule } from \"@tiptap/core\"\nimport { PluginKey } from \"@tiptap/pm/state\"\nimport { Suggestion } from \"@tiptap/suggestion\"\n\nimport { emojiCategories, type EmojiCategory, type EmojiDatum } from \"../emoji-picker/index.mjs\"\n\nimport { labelsOf } from \"./doc-labels.mjs\"\nimport { suggestRender } from \"./suggest-list.mjs\"\n\nexport interface EmojiSuggestOptions {\n /** The emoji to search; the Emoji Picker's set by default. */\n data?: EmojiCategory[]\n /** Rows shown. */\n limit?: number\n /** Letters typed after \":\" before the list opens. */\n minLength?: number\n}\n\nconst words = (text: string) => text.toLowerCase().split(/[\\s_-]+/).filter(Boolean)\n\nfunction search(all: EmojiDatum[], query: string, limit: number) {\n const q = query.toLowerCase().replace(/[_-]+/g, \" \").trim()\n if (!q) return []\n const score = (e: EmojiDatum) => {\n const name = e.name.toLowerCase()\n if (name === q) return 0\n if (name.startsWith(q)) return 1\n if (e.keywords.includes(q)) return 2\n if (words(name).some((w) => w.startsWith(q))) return 3\n return e.keywords.some((k) => k.startsWith(q)) ? 4 : 5\n }\n return all\n .map((emoji) => ({ emoji, rank: score(emoji) }))\n .filter(({ rank }) => rank < 5)\n .sort((a, b) => a.rank - b.rank)\n .slice(0, limit)\n .map(({ emoji }) => emoji)\n}\n\n/** `:` and a few letters for an emoji; a closing colon takes an exact match (`:rocket:`). */\nexport function emojiSuggestExtension({ data = emojiCategories, limit = 8, minLength = 2 }: EmojiSuggestOptions = {}) {\n const all = data.flatMap((c) => c.emojis)\n const key = new PluginKey(\"emojiSuggest\")\n return Extension.create({\n name: \"emojiSuggest\",\n\n addInputRules() {\n return [\n new InputRule({\n find: /(?:^|\\s):([a-z0-9][a-z0-9_+-]+):$/i,\n handler: ({ state, range, match }) => {\n const q = match[1].toLowerCase().replace(/[_-]+/g, \" \")\n const exact = all.find((e) => e.name.toLowerCase() === q) ?? all.find((e) => e.keywords.includes(q))\n if (!exact) return null\n const lead = match[0].startsWith(\":\") ? 0 : 1\n state.tr.insertText(exact.char, range.from + lead, range.to)\n },\n }),\n ]\n },\n\n addProseMirrorPlugins() {\n return [\n Suggestion<EmojiDatum>({\n editor: this.editor,\n char: \":\",\n pluginKey: key,\n // Closed until there's something to show, so it never takes a key it doesn't use.\n allow: ({ state, range }) => {\n const query = state.doc.textBetween(range.from, range.to).slice(1)\n return query.length >= minLength && search(all, query, 1).length > 0\n },\n items: ({ query }) => search(all, query, limit),\n command: ({ editor, range, props }) => {\n editor.chain().focus().insertContentAt(range, props.char).run()\n },\n render: suggestRender<EmojiDatum>({\n name: \"emoji\",\n order: 2,\n key,\n groups: (items, pick, editor) => [\n {\n label: labelsOf(editor).emoji,\n rows: items.map((e) => ({\n id: e.char,\n label: e.name,\n lead: (\n <span aria-hidden className=\"w-5 shrink-0 text-center\">\n {e.char}\n </span>\n ),\n pick: () => pick(e),\n })),\n },\n ],\n }),\n }),\n ]\n },\n })\n}\n"],"mappings":";AAyFoB;AAvFpB,SAAS,WAAW,iBAAiB;AACrC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAE3B,SAAS,uBAA4D;AAErE,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAW9B,MAAM,QAAQ,CAAC,SAAiB,KAAK,YAAY,EAAE,MAAM,SAAS,EAAE,OAAO,OAAO;AAElF,SAAS,OAAO,KAAmB,OAAe,OAAe;AAC/D,QAAM,IAAI,MAAM,YAAY,EAAE,QAAQ,UAAU,GAAG,EAAE,KAAK;AAC1D,MAAI,CAAC,EAAG,QAAO,CAAC;AAChB,QAAM,QAAQ,CAAC,MAAkB;AAC/B,UAAM,OAAO,EAAE,KAAK,YAAY;AAChC,QAAI,SAAS,EAAG,QAAO;AACvB,QAAI,KAAK,WAAW,CAAC,EAAG,QAAO;AAC/B,QAAI,EAAE,SAAS,SAAS,CAAC,EAAG,QAAO;AACnC,QAAI,MAAM,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,EAAG,QAAO;AACrD,WAAO,EAAE,SAAS,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,IAAI,IAAI;AAAA,EACvD;AACA,SAAO,IACJ,IAAI,CAAC,WAAW,EAAE,OAAO,MAAM,MAAM,KAAK,EAAE,EAAE,EAC9C,OAAO,CAAC,EAAE,KAAK,MAAM,OAAO,CAAC,EAC7B,KAAK,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,EAC9B,MAAM,GAAG,KAAK,EACd,IAAI,CAAC,EAAE,MAAM,MAAM,KAAK;AAC7B;AAGO,SAAS,sBAAsB,EAAE,OAAO,iBAAiB,QAAQ,GAAG,YAAY,EAAE,IAAy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A,QAAQ,cAA0B;AAAA,YAChC,MAAM;AAAA,YACN,OAAO;AAAA,YACP;AAAA,YACA,QAAQ,CAAC,OAAO,MAAM,WAAW;AAAA,cAC/B;AAAA,gBACE,OAAO,SAAS,MAAM,EAAE;AAAA,gBACxB,MAAM,MAAM,IAAI,CAAC,OAAO;AAAA,kBACtB,IAAI,EAAE;AAAA,kBACN,OAAO,EAAE;AAAA,kBACT,MACE,oBAAC,UAAK,eAAW,MAAC,WAAU,4BACzB,YAAE,MACL;AAAA,kBAEF,MAAM,MAAM,KAAK,CAAC;AAAA,gBACpB,EAAE;AAAA,cACJ;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
|
+
const key = new PluginKey("focusMode");
|
|
4
|
+
const isFocusMode = (editor) => key.getState(editor.state) ?? false;
|
|
5
|
+
const focusModeExtension = Extension.create({
|
|
6
|
+
name: "focusMode",
|
|
7
|
+
addCommands() {
|
|
8
|
+
return {
|
|
9
|
+
toggleFocusMode: (on) => ({ tr, state, dispatch }) => {
|
|
10
|
+
dispatch?.(tr.setMeta(key, on ?? !key.getState(state)));
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
addKeyboardShortcuts() {
|
|
16
|
+
return { "Mod-Shift-f": () => this.editor.commands.toggleFocusMode() };
|
|
17
|
+
},
|
|
18
|
+
addProseMirrorPlugins() {
|
|
19
|
+
return [
|
|
20
|
+
new Plugin({
|
|
21
|
+
key,
|
|
22
|
+
state: { init: () => false, apply: (tr, on) => tr.getMeta(key) ?? on },
|
|
23
|
+
props: { attributes: (state) => key.getState(state) ? { "data-focus-mode": "" } : {} }
|
|
24
|
+
})
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
export {
|
|
29
|
+
focusModeExtension,
|
|
30
|
+
isFocusMode
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=focus-mode.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/document-editor/focus-mode.ts"],"sourcesContent":["import { Extension, type Editor } from \"@tiptap/core\"\nimport { Plugin, PluginKey } from \"@tiptap/pm/state\"\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n focusMode: {\n /** Fades every block but the one being written; without a value it flips. */\n toggleFocusMode: (on?: boolean) => ReturnType\n }\n }\n}\n\nconst key = new PluginKey<boolean>(\"focusMode\")\n\n/** Whether focus mode is on. Read it live with `useEditorValue(editor, isFocusMode, false)`. */\nexport const isFocusMode = (editor: Editor) => key.getState(editor.state) ?? false\n\n/** Ctrl or ⌘ ⇧ F fades every block but the one with the caret, while the page has focus. */\nexport const focusModeExtension = Extension.create({\n name: \"focusMode\",\n addCommands() {\n return {\n toggleFocusMode:\n (on) =>\n ({ tr, state, dispatch }) => {\n dispatch?.(tr.setMeta(key, on ?? !key.getState(state)))\n return true\n },\n }\n },\n addKeyboardShortcuts() {\n return { \"Mod-Shift-f\": () => this.editor.commands.toggleFocusMode() }\n },\n addProseMirrorPlugins() {\n return [\n new Plugin<boolean>({\n key,\n state: { init: () => false, apply: (tr, on) => (tr.getMeta(key) as boolean | undefined) ?? on },\n props: { attributes: (state): Record<string, string> => (key.getState(state) ? { \"data-focus-mode\": \"\" } : {}) },\n }),\n ]\n },\n})\n"],"mappings":"AAAA,SAAS,iBAA8B;AACvC,SAAS,QAAQ,iBAAiB;AAWlC,MAAM,MAAM,IAAI,UAAmB,WAAW;AAGvC,MAAM,cAAc,CAAC,WAAmB,IAAI,SAAS,OAAO,KAAK,KAAK;AAGtE,MAAM,qBAAqB,UAAU,OAAO;AAAA,EACjD,MAAM;AAAA,EACN,cAAc;AACZ,WAAO;AAAA,MACL,iBACE,CAAC,OACD,CAAC,EAAE,IAAI,OAAO,SAAS,MAAM;AAC3B,mBAAW,GAAG,QAAQ,KAAK,MAAM,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC;AACtD,eAAO;AAAA,MACT;AAAA,IACJ;AAAA,EACF;AAAA,EACA,uBAAuB;AACrB,WAAO,EAAE,eAAe,MAAM,KAAK,OAAO,SAAS,gBAAgB,EAAE;AAAA,EACvE;AAAA,EACA,wBAAwB;AACtB,WAAO;AAAA,MACL,IAAI,OAAgB;AAAA,QAClB;AAAA,QACA,OAAO,EAAE,MAAM,MAAM,OAAO,OAAO,CAAC,IAAI,OAAQ,GAAG,QAAQ,GAAG,KAA6B,GAAG;AAAA,QAC9F,OAAO,EAAE,YAAY,CAAC,UAAmC,IAAI,SAAS,KAAK,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC,EAAG;AAAA,MACjH,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function originOf(root) {
|
|
2
|
+
const r = root.getBoundingClientRect();
|
|
3
|
+
return { left: r.left + root.clientLeft - root.scrollLeft, top: r.top + root.clientTop - root.scrollTop };
|
|
4
|
+
}
|
|
5
|
+
function scrollerOf(el) {
|
|
6
|
+
for (let node = el; node && node !== document.body; node = node.parentElement) {
|
|
7
|
+
if (/(auto|scroll)/.test(getComputedStyle(node).overflowY) && node.scrollHeight > node.clientHeight) return node;
|
|
8
|
+
}
|
|
9
|
+
return document.scrollingElement;
|
|
10
|
+
}
|
|
11
|
+
function listPosition(rect, width, height) {
|
|
12
|
+
const left = Math.max(8, Math.min(rect.left, window.innerWidth - width - 8));
|
|
13
|
+
return rect.bottom + height < window.innerHeight || rect.top < height ? { left, top: rect.bottom + 6 } : { left, bottom: window.innerHeight - rect.top + 6 };
|
|
14
|
+
}
|
|
15
|
+
function onViewportMove(update) {
|
|
16
|
+
let frame = 0;
|
|
17
|
+
const queue = () => {
|
|
18
|
+
cancelAnimationFrame(frame);
|
|
19
|
+
frame = requestAnimationFrame(update);
|
|
20
|
+
};
|
|
21
|
+
document.addEventListener("scroll", queue, { capture: true, passive: true });
|
|
22
|
+
window.addEventListener("resize", queue);
|
|
23
|
+
return () => {
|
|
24
|
+
cancelAnimationFrame(frame);
|
|
25
|
+
document.removeEventListener("scroll", queue, true);
|
|
26
|
+
window.removeEventListener("resize", queue);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
listPosition,
|
|
31
|
+
onViewportMove,
|
|
32
|
+
originOf,
|
|
33
|
+
scrollerOf
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=geometry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/document-editor/geometry.ts"],"sourcesContent":["/** Where a positioned child of `root` at 0,0 sits in the window, even when the root itself scrolls. */\nexport function originOf(root: HTMLElement) {\n const r = root.getBoundingClientRect()\n return { left: r.left + root.clientLeft - root.scrollLeft, top: r.top + root.clientTop - root.scrollTop }\n}\n\n/** The nearest box that scrolls, from the element itself up to the page. */\nexport function scrollerOf(el: HTMLElement): HTMLElement {\n for (let node: HTMLElement | null = el; node && node !== document.body; node = node.parentElement) {\n if (/(auto|scroll)/.test(getComputedStyle(node).overflowY) && node.scrollHeight > node.clientHeight) return node\n }\n return document.scrollingElement as HTMLElement\n}\n\nexport interface AnchorRect {\n left: number\n top: number\n bottom: number\n}\n\n/** Where a floating list sits: under its anchor, or above it without room, and always on screen. */\nexport function listPosition(rect: AnchorRect, width: number, height: number) {\n const left = Math.max(8, Math.min(rect.left, window.innerWidth - width - 8))\n return rect.bottom + height < window.innerHeight || rect.top < height\n ? { left, top: rect.bottom + 6 }\n : { left, bottom: window.innerHeight - rect.top + 6 }\n}\n\n/** Runs on any scroll or resize while a floating list is open. Returns the cleanup. */\nexport function onViewportMove(update: () => void) {\n let frame = 0\n const queue = () => {\n cancelAnimationFrame(frame)\n frame = requestAnimationFrame(update)\n }\n // Scroll doesn't bubble, so listen on the way down for whichever pane scrolls.\n document.addEventListener(\"scroll\", queue, { capture: true, passive: true })\n window.addEventListener(\"resize\", queue)\n return () => {\n cancelAnimationFrame(frame)\n document.removeEventListener(\"scroll\", queue, true)\n window.removeEventListener(\"resize\", queue)\n }\n}\n"],"mappings":"AACO,SAAS,SAAS,MAAmB;AAC1C,QAAM,IAAI,KAAK,sBAAsB;AACrC,SAAO,EAAE,MAAM,EAAE,OAAO,KAAK,aAAa,KAAK,YAAY,KAAK,EAAE,MAAM,KAAK,YAAY,KAAK,UAAU;AAC1G;AAGO,SAAS,WAAW,IAA8B;AACvD,WAAS,OAA2B,IAAI,QAAQ,SAAS,SAAS,MAAM,OAAO,KAAK,eAAe;AACjG,QAAI,gBAAgB,KAAK,iBAAiB,IAAI,EAAE,SAAS,KAAK,KAAK,eAAe,KAAK,aAAc,QAAO;AAAA,EAC9G;AACA,SAAO,SAAS;AAClB;AASO,SAAS,aAAa,MAAkB,OAAe,QAAgB;AAC5E,QAAM,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,MAAM,OAAO,aAAa,QAAQ,CAAC,CAAC;AAC3E,SAAO,KAAK,SAAS,SAAS,OAAO,eAAe,KAAK,MAAM,SAC3D,EAAE,MAAM,KAAK,KAAK,SAAS,EAAE,IAC7B,EAAE,MAAM,QAAQ,OAAO,cAAc,KAAK,MAAM,EAAE;AACxD;AAGO,SAAS,eAAe,QAAoB;AACjD,MAAI,QAAQ;AACZ,QAAM,QAAQ,MAAM;AAClB,yBAAqB,KAAK;AAC1B,YAAQ,sBAAsB,MAAM;AAAA,EACtC;AAEA,WAAS,iBAAiB,UAAU,OAAO,EAAE,SAAS,MAAM,SAAS,KAAK,CAAC;AAC3E,SAAO,iBAAiB,UAAU,KAAK;AACvC,SAAO,MAAM;AACX,yBAAqB,KAAK;AAC1B,aAAS,oBAAoB,UAAU,OAAO,IAAI;AAClD,WAAO,oBAAoB,UAAU,KAAK;AAAA,EAC5C;AACF;","names":[]}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Extension } from "@tiptap/core";
|
|
4
|
+
import { closeHistory } from "@tiptap/pm/history";
|
|
5
|
+
import { Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
|
|
6
|
+
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
7
|
+
import { isSharedChange, NEW_STEP } from "./collaboration-types.mjs";
|
|
8
|
+
import { useDocumentEditorContext } from "./document-editor.mjs";
|
|
9
|
+
import { useEditorValue } from "./use-editor-value.mjs";
|
|
10
|
+
const key = new PluginKey("ghostText");
|
|
11
|
+
const CONTEXT = 2e3;
|
|
12
|
+
const MAX = 240;
|
|
13
|
+
function openLine(state) {
|
|
14
|
+
const { $from, empty } = state.selection;
|
|
15
|
+
if (!empty || !(state.selection instanceof TextSelection)) return null;
|
|
16
|
+
if (!$from.parent.isTextblock || $from.parent.type.spec.code || $from.parentOffset < $from.parent.content.size) return null;
|
|
17
|
+
return $from;
|
|
18
|
+
}
|
|
19
|
+
const listOpen = (editor) => Boolean(editor.storage.suggestList?.store.get().open || editor.storage.slashCommand?.store.get().open);
|
|
20
|
+
function ghostTextExtension({ complete, delay = 400, minLength = 12 }) {
|
|
21
|
+
return Extension.create({
|
|
22
|
+
name: "ghostText",
|
|
23
|
+
// Ahead of lists, which use Tab to indent.
|
|
24
|
+
priority: 1200,
|
|
25
|
+
addKeyboardShortcuts() {
|
|
26
|
+
const take = (part) => () => {
|
|
27
|
+
const { state, view } = this.editor;
|
|
28
|
+
const ghost = key.getState(state);
|
|
29
|
+
if (!ghost || listOpen(this.editor)) return false;
|
|
30
|
+
view.dispatch(closeHistory(state.tr).setMeta(NEW_STEP, true).insertText(part(ghost.text), ghost.pos).scrollIntoView());
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
Tab: take((text) => text),
|
|
35
|
+
"Mod-ArrowRight": take((text) => /^\s*\S+/.exec(text)?.[0] ?? text),
|
|
36
|
+
Escape: () => {
|
|
37
|
+
const { state, view } = this.editor;
|
|
38
|
+
if (!key.getState(state) || listOpen(this.editor)) return false;
|
|
39
|
+
view.dispatch(state.tr.setMeta(key, { ghost: null }));
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
addProseMirrorPlugins() {
|
|
45
|
+
const editor = this.editor;
|
|
46
|
+
let timer;
|
|
47
|
+
let request = null;
|
|
48
|
+
let shared = false;
|
|
49
|
+
const stop = () => {
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
request?.abort();
|
|
52
|
+
request = null;
|
|
53
|
+
};
|
|
54
|
+
const ask = async (view) => {
|
|
55
|
+
const { state } = view;
|
|
56
|
+
const $from = openLine(state);
|
|
57
|
+
if (!$from || !editor.isEditable || view.composing || !view.hasFocus() || listOpen(editor)) return;
|
|
58
|
+
const text = $from.parent.textBetween(0, $from.parentOffset, void 0, " ");
|
|
59
|
+
if (text.trim().length < minLength) return;
|
|
60
|
+
const mine = request = new AbortController();
|
|
61
|
+
const context = state.doc.textBetween(Math.max(0, $from.pos - CONTEXT), $from.pos, "\n", " ");
|
|
62
|
+
let answer = null;
|
|
63
|
+
try {
|
|
64
|
+
answer = await complete({ text, context, signal: mine.signal });
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
const $now = mine.signal.aborted || editor.isDestroyed ? null : openLine(view.state);
|
|
68
|
+
if (!$now || $now.parent.textBetween(0, $now.parentOffset, void 0, " ") !== text) return;
|
|
69
|
+
const line = answer?.split("\n")[0].slice(0, MAX);
|
|
70
|
+
if (!line?.trim() || listOpen(editor)) return;
|
|
71
|
+
view.dispatch(view.state.tr.setMeta(key, { ghost: { pos: $now.pos, text: line } }).setMeta("addToHistory", false));
|
|
72
|
+
};
|
|
73
|
+
return [
|
|
74
|
+
new Plugin({
|
|
75
|
+
key,
|
|
76
|
+
state: {
|
|
77
|
+
init: () => null,
|
|
78
|
+
apply(tr, ghost, old, state) {
|
|
79
|
+
if (tr.docChanged) shared = isSharedChange(tr);
|
|
80
|
+
const meta = tr.getMeta(key);
|
|
81
|
+
if (meta) return meta.ghost;
|
|
82
|
+
if (!ghost) return null;
|
|
83
|
+
if (!tr.docChanged) return tr.selection.empty && tr.selection.head === ghost.pos ? ghost : null;
|
|
84
|
+
if (shared) {
|
|
85
|
+
const $was = old.selection.$head;
|
|
86
|
+
const $is = openLine(state);
|
|
87
|
+
const same = $is && $is.parent.textContent === $was.parent.textContent && $is.parentOffset === $was.parentOffset;
|
|
88
|
+
return same ? { ...ghost, pos: $is.pos } : null;
|
|
89
|
+
}
|
|
90
|
+
const head = tr.selection.head;
|
|
91
|
+
const typed = head > ghost.pos && head <= tr.doc.content.size ? tr.doc.textBetween(ghost.pos, head, "\n") : "";
|
|
92
|
+
const grew = tr.doc.content.size - tr.before.content.size;
|
|
93
|
+
if (!typed || grew !== typed.length || !ghost.text.startsWith(typed)) return null;
|
|
94
|
+
const rest = ghost.text.slice(typed.length);
|
|
95
|
+
return rest ? { pos: head, text: rest } : null;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
props: {
|
|
99
|
+
decorations(state) {
|
|
100
|
+
const ghost = key.getState(state);
|
|
101
|
+
if (!ghost) return null;
|
|
102
|
+
const widget = () => {
|
|
103
|
+
const span = document.createElement("span");
|
|
104
|
+
span.dataset.slot = "document-editor-ghost";
|
|
105
|
+
span.setAttribute("aria-hidden", "true");
|
|
106
|
+
span.textContent = ghost.text;
|
|
107
|
+
span.addEventListener("mousedown", (event) => {
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
const now = key.getState(editor.state);
|
|
110
|
+
if (now) editor.view.dispatch(closeHistory(editor.state.tr).setMeta(NEW_STEP, true).insertText(now.text, now.pos));
|
|
111
|
+
editor.view.focus();
|
|
112
|
+
});
|
|
113
|
+
return span;
|
|
114
|
+
};
|
|
115
|
+
return DecorationSet.create(state.doc, [
|
|
116
|
+
Decoration.widget(ghost.pos, widget, { side: 1, key: `ghost-${ghost.text}`, ignoreSelection: true, stopEvent: () => true })
|
|
117
|
+
]);
|
|
118
|
+
},
|
|
119
|
+
handleDOMEvents: {
|
|
120
|
+
blur: (view) => {
|
|
121
|
+
stop();
|
|
122
|
+
if (key.getState(view.state)) view.dispatch(view.state.tr.setMeta(key, { ghost: null }));
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
view: () => ({
|
|
128
|
+
update: (view, prev) => {
|
|
129
|
+
if (view.state.doc.eq(prev.doc)) {
|
|
130
|
+
if (!view.state.selection.eq(prev.selection)) stop();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (shared) return;
|
|
134
|
+
stop();
|
|
135
|
+
if (!key.getState(view.state)) timer = setTimeout(() => void ask(view), delay);
|
|
136
|
+
},
|
|
137
|
+
destroy: stop
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
const readGhost = (editor) => key.getState(editor.state)?.text ?? "";
|
|
145
|
+
function GhostTextStatus() {
|
|
146
|
+
const { editor, labels } = useDocumentEditorContext("GhostTextStatus");
|
|
147
|
+
const text = useEditorValue(editor, readGhost, "");
|
|
148
|
+
return /* @__PURE__ */ jsx("span", { role: "status", className: "sr-only", children: text ? labels.suggestion(text) : "" });
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
GhostTextStatus,
|
|
152
|
+
ghostTextExtension
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=ghost-text.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/document-editor/ghost-text.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { Extension, type Editor } from \"@tiptap/core\"\nimport { closeHistory } from \"@tiptap/pm/history\"\nimport { Plugin, PluginKey, TextSelection, type EditorState } from \"@tiptap/pm/state\"\nimport { Decoration, DecorationSet, type EditorView } from \"@tiptap/pm/view\"\n\nimport { isSharedChange, NEW_STEP } from \"./collaboration-types.mjs\"\nimport { useDocumentEditorContext } from \"./document-editor.mjs\"\nimport { useEditorValue } from \"./use-editor-value.mjs\"\n\nexport interface GhostTextRequest {\n /** The text of the block up to the caret. */\n text: string\n /** The last stretch of the document up to the caret, for context. */\n context: string\n /** Aborts when the writer moves on. Pass it to fetch. */\n signal: AbortSignal\n}\n\nexport interface GhostTextOptions {\n /** Returns what might come next, or null. Only the first line is used. */\n complete: (request: GhostTextRequest) => Promise<string | null> | string | null\n /** The pause in typing before asking, in ms. */\n delay?: number\n /** Letters in the block before asking. */\n minLength?: number\n}\n\ninterface Ghost {\n pos: number\n text: string\n}\n\nconst key = new PluginKey<Ghost | null>(\"ghostText\")\nconst CONTEXT = 2000\nconst MAX = 240\n\n/** The caret's block, when a suggestion could follow it: typing at the end of a line of text. */\nfunction openLine(state: EditorState) {\n const { $from, empty } = state.selection\n if (!empty || !(state.selection instanceof TextSelection)) return null\n if (!$from.parent.isTextblock || $from.parent.type.spec.code || $from.parentOffset < $from.parent.content.size) return null\n return $from\n}\n\n/** Any list under the caret has the keys first. */\nconst listOpen = (editor: Editor) =>\n Boolean(editor.storage.suggestList?.store.get().open || editor.storage.slashCommand?.store.get().open)\n\n/** What might come next, in quiet ink after the caret. Tab takes it; Ctrl or ⌘ → takes a word; Esc drops it. */\nexport function ghostTextExtension({ complete, delay = 400, minLength = 12 }: GhostTextOptions) {\n return Extension.create({\n name: \"ghostText\",\n // Ahead of lists, which use Tab to indent.\n priority: 1200,\n\n addKeyboardShortcuts() {\n const take = (part: (text: string) => string) => () => {\n const { state, view } = this.editor\n const ghost = key.getState(state)\n if (!ghost || listOpen(this.editor)) return false\n // Its own step, so undo takes back the suggestion and not what was typed before it.\n view.dispatch(closeHistory(state.tr).setMeta(NEW_STEP, true).insertText(part(ghost.text), ghost.pos).scrollIntoView())\n return true\n }\n return {\n Tab: take((text) => text),\n \"Mod-ArrowRight\": take((text) => /^\\s*\\S+/.exec(text)?.[0] ?? text),\n Escape: () => {\n const { state, view } = this.editor\n if (!key.getState(state) || listOpen(this.editor)) return false\n view.dispatch(state.tr.setMeta(key, { ghost: null }))\n return true\n },\n }\n },\n\n addProseMirrorPlugins() {\n const editor = this.editor\n let timer: ReturnType<typeof setTimeout> | undefined\n let request: AbortController | null = null\n // Whether the last change was someone else's: their typing asks nothing of you.\n let shared = false\n const stop = () => {\n clearTimeout(timer)\n request?.abort()\n request = null\n }\n\n const ask = async (view: EditorView) => {\n const { state } = view\n const $from = openLine(state)\n // A composing IME owns the text at the caret.\n if (!$from || !editor.isEditable || view.composing || !view.hasFocus() || listOpen(editor)) return\n const text = $from.parent.textBetween(0, $from.parentOffset, undefined, \" \")\n if (text.trim().length < minLength) return\n const mine = (request = new AbortController())\n const context = state.doc.textBetween(Math.max(0, $from.pos - CONTEXT), $from.pos, \"\\n\", \" \")\n let answer: string | null = null\n try {\n answer = await complete({ text, context, signal: mine.signal })\n } catch {\n // No suggestion this time; writing carries on.\n }\n // Still at the end of the same words, whatever happened elsewhere on a shared page.\n const $now = mine.signal.aborted || editor.isDestroyed ? null : openLine(view.state)\n if (!$now || $now.parent.textBetween(0, $now.parentOffset, undefined, \" \") !== text) return\n const line = answer?.split(\"\\n\")[0].slice(0, MAX)\n if (!line?.trim() || listOpen(editor)) return\n view.dispatch(view.state.tr.setMeta(key, { ghost: { pos: $now.pos, text: line } }).setMeta(\"addToHistory\", false))\n }\n\n return [\n new Plugin<Ghost | null>({\n key,\n state: {\n init: () => null,\n apply(tr, ghost, old, state) {\n if (tr.docChanged) shared = isSharedChange(tr)\n const meta = tr.getMeta(key) as { ghost: Ghost | null } | undefined\n if (meta) return meta.ghost\n if (!ghost) return null\n if (!tr.docChanged) return tr.selection.empty && tr.selection.head === ghost.pos ? ghost : null\n if (shared) {\n const $was = old.selection.$head\n const $is = openLine(state)\n const same = $is && $is.parent.textContent === $was.parent.textContent && $is.parentOffset === $was.parentOffset\n return same ? { ...ghost, pos: $is.pos } : null\n }\n // Typing the suggestion itself uses it up instead of dropping it.\n const head = tr.selection.head\n const typed = head > ghost.pos && head <= tr.doc.content.size ? tr.doc.textBetween(ghost.pos, head, \"\\n\") : \"\"\n const grew = tr.doc.content.size - tr.before.content.size\n if (!typed || grew !== typed.length || !ghost.text.startsWith(typed)) return null\n const rest = ghost.text.slice(typed.length)\n return rest ? { pos: head, text: rest } : null\n },\n },\n props: {\n decorations(state) {\n const ghost = key.getState(state)\n if (!ghost) return null\n const widget = () => {\n const span = document.createElement(\"span\")\n span.dataset.slot = \"document-editor-ghost\"\n span.setAttribute(\"aria-hidden\", \"true\")\n span.textContent = ghost.text\n // A phone has no Tab: a tap takes it.\n span.addEventListener(\"mousedown\", (event) => {\n event.preventDefault()\n const now = key.getState(editor.state)\n if (now) editor.view.dispatch(closeHistory(editor.state.tr).setMeta(NEW_STEP, true).insertText(now.text, now.pos))\n editor.view.focus()\n })\n return span\n }\n return DecorationSet.create(state.doc, [\n Decoration.widget(ghost.pos, widget, { side: 1, key: `ghost-${ghost.text}`, ignoreSelection: true, stopEvent: () => true }),\n ])\n },\n handleDOMEvents: {\n blur: (view) => {\n stop()\n if (key.getState(view.state)) view.dispatch(view.state.tr.setMeta(key, { ghost: null }))\n return false\n },\n },\n },\n view: () => ({\n update: (view, prev) => {\n if (view.state.doc.eq(prev.doc)) {\n // The caret moved: whatever was asked is about somewhere else.\n if (!view.state.selection.eq(prev.selection)) stop()\n return\n }\n if (shared) return\n stop()\n if (!key.getState(view.state)) timer = setTimeout(() => void ask(view), delay)\n },\n destroy: stop,\n }),\n }),\n ]\n },\n })\n}\n\nconst readGhost = (editor: Editor) => key.getState(editor.state)?.text ?? \"\"\n\n/** Says a suggestion aloud, since the ghost itself is only ink. The root renders it. */\nexport function GhostTextStatus() {\n const { editor, labels } = useDocumentEditorContext(\"GhostTextStatus\")\n const text = useEditorValue(editor, readGhost, \"\")\n return (\n <span role=\"status\" className=\"sr-only\">\n {text ? labels.suggestion(text) : \"\"}\n </span>\n )\n}\n"],"mappings":";AAoMI;AAjMJ,SAAS,iBAA8B;AACvC,SAAS,oBAAoB;AAC7B,SAAS,QAAQ,WAAW,qBAAuC;AACnE,SAAS,YAAY,qBAAsC;AAE3D,SAAS,gBAAgB,gBAAgB;AACzC,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAyB/B,MAAM,MAAM,IAAI,UAAwB,WAAW;AACnD,MAAM,UAAU;AAChB,MAAM,MAAM;AAGZ,SAAS,SAAS,OAAoB;AACpC,QAAM,EAAE,OAAO,MAAM,IAAI,MAAM;AAC/B,MAAI,CAAC,SAAS,EAAE,MAAM,qBAAqB,eAAgB,QAAO;AAClE,MAAI,CAAC,MAAM,OAAO,eAAe,MAAM,OAAO,KAAK,KAAK,QAAQ,MAAM,eAAe,MAAM,OAAO,QAAQ,KAAM,QAAO;AACvH,SAAO;AACT;AAGA,MAAM,WAAW,CAAC,WAChB,QAAQ,OAAO,QAAQ,aAAa,MAAM,IAAI,EAAE,QAAQ,OAAO,QAAQ,cAAc,MAAM,IAAI,EAAE,IAAI;AAGhG,SAAS,mBAAmB,EAAE,UAAU,QAAQ,KAAK,YAAY,GAAG,GAAqB;AAC9F,SAAO,UAAU,OAAO;AAAA,IACtB,MAAM;AAAA;AAAA,IAEN,UAAU;AAAA,IAEV,uBAAuB;AACrB,YAAM,OAAO,CAAC,SAAmC,MAAM;AACrD,cAAM,EAAE,OAAO,KAAK,IAAI,KAAK;AAC7B,cAAM,QAAQ,IAAI,SAAS,KAAK;AAChC,YAAI,CAAC,SAAS,SAAS,KAAK,MAAM,EAAG,QAAO;AAE5C,aAAK,SAAS,aAAa,MAAM,EAAE,EAAE,QAAQ,UAAU,IAAI,EAAE,WAAW,KAAK,MAAM,IAAI,GAAG,MAAM,GAAG,EAAE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,MAAM,SAAS;AACtB,kBAAI,KAAK,MAAM,IAAI,GAAG,KAAK,GAAG,GAAG;AAE/B,oBAAI,CAAC,KAAK,MAAM,UAAU,GAAG,KAAK,SAAS,EAAG,MAAK;AACnD;AAAA,cACF;AACA,kBAAI,OAAQ;AACZ,mBAAK;AACL,kBAAI,CAAC,IAAI,SAAS,KAAK,KAAK,EAAG,SAAQ,WAAW,MAAM,KAAK,IAAI,IAAI,GAAG,KAAK;AAAA,YAC/E;AAAA,YACA,SAAS;AAAA,UACX;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEA,MAAM,YAAY,CAAC,WAAmB,IAAI,SAAS,OAAO,KAAK,GAAG,QAAQ;AAGnE,SAAS,kBAAkB;AAChC,QAAM,EAAE,QAAQ,OAAO,IAAI,yBAAyB,iBAAiB;AACrE,QAAM,OAAO,eAAe,QAAQ,WAAW,EAAE;AACjD,SACE,oBAAC,UAAK,MAAK,UAAS,WAAU,WAC3B,iBAAO,OAAO,WAAW,IAAI,IAAI,IACpC;AAEJ;","names":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import { Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
|
|
3
|
+
const BLINK = 530;
|
|
4
|
+
const glidingCaretExtension = Extension.create({
|
|
5
|
+
name: "glidingCaret",
|
|
6
|
+
addProseMirrorPlugins() {
|
|
7
|
+
return [
|
|
8
|
+
new Plugin({
|
|
9
|
+
key: new PluginKey("glidingCaret"),
|
|
10
|
+
view: (view) => {
|
|
11
|
+
const host = view.dom.parentElement;
|
|
12
|
+
if (!host) return {};
|
|
13
|
+
const allowed = window.matchMedia("(prefers-reduced-motion: no-preference) and (pointer: fine)");
|
|
14
|
+
const caret = document.createElement("div");
|
|
15
|
+
caret.dataset.slot = "document-editor-caret";
|
|
16
|
+
caret.setAttribute("aria-hidden", "true");
|
|
17
|
+
caret.hidden = true;
|
|
18
|
+
const blink = caret.animate(
|
|
19
|
+
[{ opacity: 1 }, { opacity: 1, offset: 0.5 }, { opacity: 0, offset: 0.5 }, { opacity: 0 }],
|
|
20
|
+
{ duration: BLINK * 2, iterations: Infinity, delay: BLINK }
|
|
21
|
+
);
|
|
22
|
+
let composing = false;
|
|
23
|
+
let side = (before) => before;
|
|
24
|
+
let last = null;
|
|
25
|
+
let frame = 0;
|
|
26
|
+
const queue = () => {
|
|
27
|
+
cancelAnimationFrame(frame);
|
|
28
|
+
frame = requestAnimationFrame(draw);
|
|
29
|
+
};
|
|
30
|
+
const moving = () => view.dom.getAnimations({ subtree: true }).some((a) => a.playState === "running" && Number.isFinite(Number(a.effect?.getComputedTiming().endTime)));
|
|
31
|
+
const hide = () => {
|
|
32
|
+
caret.hidden = true;
|
|
33
|
+
last = null;
|
|
34
|
+
caret.parentElement?.removeAttribute("data-caret");
|
|
35
|
+
};
|
|
36
|
+
const draw = () => {
|
|
37
|
+
const mount = view.dom.parentElement;
|
|
38
|
+
const { selection } = view.state;
|
|
39
|
+
if (!mount || !allowed.matches || composing || view.isDestroyed || !view.editable || !view.hasFocus() || !selection.empty || !(selection instanceof TextSelection)) {
|
|
40
|
+
hide();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (caret.parentElement !== mount) mount.append(caret);
|
|
44
|
+
const at = side(view.coordsAtPos(selection.head, -1), view.coordsAtPos(selection.head, 1));
|
|
45
|
+
const origin = mount.getBoundingClientRect();
|
|
46
|
+
const x = at.left - origin.left + mount.scrollLeft;
|
|
47
|
+
const y = at.top - origin.top + mount.scrollTop;
|
|
48
|
+
caret.toggleAttribute("data-snap", last === null);
|
|
49
|
+
caret.style.transform = `translate(${x}px, ${y}px)`;
|
|
50
|
+
caret.style.height = `${at.bottom - at.top}px`;
|
|
51
|
+
caret.hidden = false;
|
|
52
|
+
mount.dataset.caret = "glide";
|
|
53
|
+
if (last === null) {
|
|
54
|
+
void caret.offsetWidth;
|
|
55
|
+
caret.removeAttribute("data-snap");
|
|
56
|
+
}
|
|
57
|
+
if (last && (last.left !== at.left || last.top !== at.top)) blink.currentTime = 0;
|
|
58
|
+
last = at;
|
|
59
|
+
if (moving()) queue();
|
|
60
|
+
};
|
|
61
|
+
const onKey = (event) => {
|
|
62
|
+
const from = last;
|
|
63
|
+
if (event.key === "Home" || event.key === "ArrowLeft" || event.key === "ArrowRight") side = (_, after) => after;
|
|
64
|
+
else if ((event.key === "ArrowUp" || event.key === "ArrowDown") && from)
|
|
65
|
+
side = (a, b) => Math.abs(a.left - from.left) <= Math.abs(b.left - from.left) ? a : b;
|
|
66
|
+
else side = (before) => before;
|
|
67
|
+
};
|
|
68
|
+
const onPointer = (event) => {
|
|
69
|
+
const { clientY } = event;
|
|
70
|
+
const away = (c) => Math.abs((c.top + c.bottom) / 2 - clientY);
|
|
71
|
+
side = (a, b) => away(a) <= away(b) ? a : b;
|
|
72
|
+
};
|
|
73
|
+
const onCompose = (event) => {
|
|
74
|
+
composing = event.type !== "compositionend";
|
|
75
|
+
queue();
|
|
76
|
+
};
|
|
77
|
+
const observer = new ResizeObserver(queue);
|
|
78
|
+
observer.observe(view.dom);
|
|
79
|
+
view.dom.addEventListener("keydown", onKey, true);
|
|
80
|
+
view.dom.addEventListener("mousedown", onPointer, true);
|
|
81
|
+
view.dom.addEventListener("mouseup", onPointer, true);
|
|
82
|
+
view.dom.addEventListener("focus", queue);
|
|
83
|
+
view.dom.addEventListener("blur", queue);
|
|
84
|
+
view.dom.addEventListener("compositionstart", onCompose);
|
|
85
|
+
view.dom.addEventListener("compositionend", onCompose);
|
|
86
|
+
view.dom.addEventListener("scroll", queue, true);
|
|
87
|
+
allowed.addEventListener("change", queue);
|
|
88
|
+
queue();
|
|
89
|
+
return {
|
|
90
|
+
update: (next, prev) => {
|
|
91
|
+
if (!next.state.selection.eq(prev.selection) || !next.state.doc.eq(prev.doc)) queue();
|
|
92
|
+
},
|
|
93
|
+
destroy: () => {
|
|
94
|
+
cancelAnimationFrame(frame);
|
|
95
|
+
observer.disconnect();
|
|
96
|
+
allowed.removeEventListener("change", queue);
|
|
97
|
+
view.dom.removeEventListener("keydown", onKey, true);
|
|
98
|
+
view.dom.removeEventListener("mousedown", onPointer, true);
|
|
99
|
+
view.dom.removeEventListener("mouseup", onPointer, true);
|
|
100
|
+
view.dom.removeEventListener("focus", queue);
|
|
101
|
+
view.dom.removeEventListener("blur", queue);
|
|
102
|
+
view.dom.removeEventListener("compositionstart", onCompose);
|
|
103
|
+
view.dom.removeEventListener("compositionend", onCompose);
|
|
104
|
+
view.dom.removeEventListener("scroll", queue, true);
|
|
105
|
+
hide();
|
|
106
|
+
blink.cancel();
|
|
107
|
+
caret.remove();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
export {
|
|
116
|
+
glidingCaretExtension
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=gliding-caret.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/document-editor/gliding-caret.ts"],"sourcesContent":["import { Extension } from \"@tiptap/core\"\nimport { Plugin, PluginKey, TextSelection } from \"@tiptap/pm/state\"\nimport type { EditorView } from \"@tiptap/pm/view\"\n\n/** How long the caret rests at each end of a blink. */\nconst BLINK = 530\n\ntype Coords = ReturnType<EditorView[\"coordsAtPos\"]>\n\n/**\n * A caret that slides to its next place instead of jumping. It stands in for the browser's only\n * for a plain caret in focused text, with a fine pointer, motion allowed, and no IME composing;\n * otherwise the browser's own shows.\n */\nexport const glidingCaretExtension = Extension.create({\n name: \"glidingCaret\",\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey(\"glidingCaret\"),\n view: (view) => {\n const host = view.dom.parentElement\n if (!host) return {}\n const allowed = window.matchMedia(\"(prefers-reduced-motion: no-preference) and (pointer: fine)\")\n const caret = document.createElement(\"div\")\n caret.dataset.slot = \"document-editor-caret\"\n caret.setAttribute(\"aria-hidden\", \"true\")\n caret.hidden = true\n const blink = caret.animate(\n [{ opacity: 1 }, { opacity: 1, offset: 0.5 }, { opacity: 0, offset: 0.5 }, { opacity: 0 }],\n { duration: BLINK * 2, iterations: Infinity, delay: BLINK },\n )\n let composing = false\n // At a soft wrap one position has two places. What moved the caret says which is meant.\n let side: (a: Coords, b: Coords) => Coords = (before) => before\n let last: Coords | null = null\n\n let frame = 0\n const queue = () => {\n cancelAnimationFrame(frame)\n frame = requestAnimationFrame(draw)\n }\n const moving = () =>\n view.dom\n .getAnimations({ subtree: true })\n .some((a) => a.playState === \"running\" && Number.isFinite(Number(a.effect?.getComputedTiming().endTime)))\n\n const hide = () => {\n caret.hidden = true\n last = null\n caret.parentElement?.removeAttribute(\"data-caret\")\n }\n\n const draw = () => {\n // React can move the editor to another mount, so it's read each time.\n const mount = view.dom.parentElement\n const { selection } = view.state\n if (\n !mount ||\n !allowed.matches ||\n composing ||\n view.isDestroyed ||\n !view.editable ||\n !view.hasFocus() ||\n !selection.empty ||\n !(selection instanceof TextSelection)\n ) {\n hide()\n return\n }\n if (caret.parentElement !== mount) mount.append(caret)\n const at = side(view.coordsAtPos(selection.head, -1), view.coordsAtPos(selection.head, 1))\n const origin = mount.getBoundingClientRect()\n const x = at.left - origin.left + mount.scrollLeft\n const y = at.top - origin.top + mount.scrollTop\n // The first place, and any after it was hidden, is taken without a slide.\n caret.toggleAttribute(\"data-snap\", last === null)\n caret.style.transform = `translate(${x}px, ${y}px)`\n caret.style.height = `${at.bottom - at.top}px`\n caret.hidden = false\n mount.dataset.caret = \"glide\"\n if (last === null) {\n void caret.offsetWidth\n caret.removeAttribute(\"data-snap\")\n }\n // Solid while it moves; it blinks once it rests.\n if (last && (last.left !== at.left || last.top !== at.top)) blink.currentTime = 0\n last = at\n // While blocks around it move (a morph, a template rising in), keep up until they settle.\n if (moving()) queue()\n }\n\n const onKey = (event: KeyboardEvent) => {\n const from = last\n if (event.key === \"Home\" || event.key === \"ArrowLeft\" || event.key === \"ArrowRight\") side = (_, after) => after\n else if ((event.key === \"ArrowUp\" || event.key === \"ArrowDown\") && from)\n side = (a, b) => (Math.abs(a.left - from.left) <= Math.abs(b.left - from.left) ? a : b)\n else side = (before) => before\n }\n const onPointer = (event: MouseEvent) => {\n const { clientY } = event\n const away = (c: Coords) => Math.abs((c.top + c.bottom) / 2 - clientY)\n side = (a, b) => (away(a) <= away(b) ? a : b)\n }\n const onCompose = (event: Event) => {\n composing = event.type !== \"compositionend\"\n queue()\n }\n const observer = new ResizeObserver(queue)\n observer.observe(view.dom)\n view.dom.addEventListener(\"keydown\", onKey, true)\n view.dom.addEventListener(\"mousedown\", onPointer, true)\n view.dom.addEventListener(\"mouseup\", onPointer, true)\n view.dom.addEventListener(\"focus\", queue)\n view.dom.addEventListener(\"blur\", queue)\n view.dom.addEventListener(\"compositionstart\", onCompose)\n view.dom.addEventListener(\"compositionend\", onCompose)\n // Code blocks and tables scroll inside the page.\n view.dom.addEventListener(\"scroll\", queue, true)\n allowed.addEventListener(\"change\", queue)\n queue()\n\n return {\n update: (next, prev) => {\n if (!next.state.selection.eq(prev.selection) || !next.state.doc.eq(prev.doc)) queue()\n },\n destroy: () => {\n cancelAnimationFrame(frame)\n observer.disconnect()\n allowed.removeEventListener(\"change\", queue)\n view.dom.removeEventListener(\"keydown\", onKey, true)\n view.dom.removeEventListener(\"mousedown\", onPointer, true)\n view.dom.removeEventListener(\"mouseup\", onPointer, true)\n view.dom.removeEventListener(\"focus\", queue)\n view.dom.removeEventListener(\"blur\", queue)\n view.dom.removeEventListener(\"compositionstart\", onCompose)\n view.dom.removeEventListener(\"compositionend\", onCompose)\n view.dom.removeEventListener(\"scroll\", queue, true)\n hide()\n blink.cancel()\n caret.remove()\n },\n }\n },\n }),\n ]\n },\n})\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,QAAQ,WAAW,qBAAqB;AAIjD,MAAM,QAAQ;AASP,MAAM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,SAAS;AAC1D,mBAAK,IAAI,oBAAoB,kBAAkB,SAAS;AACxD,mBAAK,IAAI,oBAAoB,UAAU,OAAO,IAAI;AAClD,mBAAK;AACL,oBAAM,OAAO;AACb,oBAAM,OAAO;AAAA,YACf;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
|
+
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
4
|
+
const slug = (text) => text.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "").slice(0, 48);
|
|
5
|
+
function collect(doc, prefix) {
|
|
6
|
+
const out = [];
|
|
7
|
+
const used = /* @__PURE__ */ new Map();
|
|
8
|
+
doc.descendants((node, pos) => {
|
|
9
|
+
if (node.type.name !== "heading") return !node.isTextblock;
|
|
10
|
+
const text = node.textContent.trim();
|
|
11
|
+
const base = `${prefix}-${slug(text) || "section"}`;
|
|
12
|
+
const count = used.get(base) ?? 0;
|
|
13
|
+
used.set(base, count + 1);
|
|
14
|
+
out.push({ id: count ? `${base}-${count + 1}` : base, level: node.attrs.level, text, pos });
|
|
15
|
+
return false;
|
|
16
|
+
});
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
function documentEditorHeadings(editor) {
|
|
20
|
+
return collect(editor.state.doc, editor.storage.headingIds?.prefix ?? "doc");
|
|
21
|
+
}
|
|
22
|
+
const HeadingIds = Extension.create({
|
|
23
|
+
name: "headingIds",
|
|
24
|
+
addStorage() {
|
|
25
|
+
return { prefix: `doc-${Math.random().toString(36).slice(2, 8)}` };
|
|
26
|
+
},
|
|
27
|
+
addProseMirrorPlugins() {
|
|
28
|
+
const { prefix } = this.storage;
|
|
29
|
+
const build = (doc) => DecorationSet.create(
|
|
30
|
+
doc,
|
|
31
|
+
collect(doc, prefix).map((h) => Decoration.node(h.pos, h.pos + (doc.nodeAt(h.pos)?.nodeSize ?? 1), { id: h.id }))
|
|
32
|
+
);
|
|
33
|
+
return [
|
|
34
|
+
new Plugin({
|
|
35
|
+
key: new PluginKey("headingIds"),
|
|
36
|
+
state: {
|
|
37
|
+
init: (_, state) => build(state.doc),
|
|
38
|
+
apply: (tr, set) => tr.docChanged ? build(tr.doc) : set
|
|
39
|
+
},
|
|
40
|
+
props: {
|
|
41
|
+
decorations(state) {
|
|
42
|
+
return this.getState(state);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
function scrollToHeading(editor, heading) {
|
|
50
|
+
const dom = editor.view.nodeDOM(heading.pos);
|
|
51
|
+
if (!(dom instanceof HTMLElement)) return;
|
|
52
|
+
const still = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
53
|
+
dom.scrollIntoView({ behavior: still ? "auto" : "smooth", block: "start" });
|
|
54
|
+
}
|
|
55
|
+
function sameHeadings(a, b) {
|
|
56
|
+
return a.length === b.length && a.every((h, i) => h.id === b[i].id && h.level === b[i].level && h.text === b[i].text && h.pos === b[i].pos);
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
HeadingIds,
|
|
60
|
+
documentEditorHeadings,
|
|
61
|
+
sameHeadings,
|
|
62
|
+
scrollToHeading
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=headings.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/document-editor/headings.ts"],"sourcesContent":["import { Extension, type Editor } from \"@tiptap/core\"\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\"\nimport { Plugin, PluginKey } from \"@tiptap/pm/state\"\nimport { Decoration, DecorationSet } from \"@tiptap/pm/view\"\n\nexport interface DocumentHeading {\n /** The id the heading carries on the page, unique to its editor. */\n id: string\n level: number\n text: string\n /** Where it starts in the document. */\n pos: number\n}\n\ndeclare module \"@tiptap/core\" {\n interface Storage {\n headingIds: { prefix: string }\n }\n}\n\nconst slug = (text: string) =>\n text\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}]+/gu, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, 48)\n\nfunction collect(doc: ProseMirrorNode, prefix: string): DocumentHeading[] {\n const out: DocumentHeading[] = []\n const used = new Map<string, number>()\n doc.descendants((node, pos) => {\n if (node.type.name !== \"heading\") return !node.isTextblock\n const text = node.textContent.trim()\n const base = `${prefix}-${slug(text) || \"section\"}`\n const count = used.get(base) ?? 0\n used.set(base, count + 1)\n out.push({ id: count ? `${base}-${count + 1}` : base, level: node.attrs.level as number, text, pos })\n return false\n })\n return out\n}\n\n/** The document's headings, in order, with the ids they carry on the page. */\nexport function documentEditorHeadings(editor: Editor): DocumentHeading[] {\n return collect(editor.state.doc, editor.storage.headingIds?.prefix ?? \"doc\")\n}\n\n/** Gives every heading an id on the page, so the outline and the contents block can link to it. */\nexport const HeadingIds = Extension.create<object, { prefix: string }>({\n name: \"headingIds\",\n addStorage() {\n return { prefix: `doc-${Math.random().toString(36).slice(2, 8)}` }\n },\n addProseMirrorPlugins() {\n const { prefix } = this.storage\n const build = (doc: ProseMirrorNode) =>\n DecorationSet.create(\n doc,\n collect(doc, prefix).map((h) => Decoration.node(h.pos, h.pos + (doc.nodeAt(h.pos)?.nodeSize ?? 1), { id: h.id })),\n )\n return [\n new Plugin<DecorationSet>({\n key: new PluginKey(\"headingIds\"),\n state: {\n init: (_, state) => build(state.doc),\n apply: (tr, set) => (tr.docChanged ? build(tr.doc) : set),\n },\n props: {\n decorations(state) {\n return this.getState(state)\n },\n },\n }),\n ]\n },\n})\n\n/** Scrolls a heading to the top of whatever scrolls it, and puts the caret at its end when editing. */\nexport function scrollToHeading(editor: Editor, heading: DocumentHeading) {\n const dom = editor.view.nodeDOM(heading.pos)\n if (!(dom instanceof HTMLElement)) return\n const still = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n dom.scrollIntoView({ behavior: still ? \"auto\" : \"smooth\", block: \"start\" })\n}\n\n/** Whether two heading lists hold the same rows. */\nexport function sameHeadings(a: DocumentHeading[], b: DocumentHeading[]) {\n return a.length === b.length && a.every((h, i) => h.id === b[i].id && h.level === b[i].level && h.text === b[i].text && h.pos === b[i].pos)\n}\n"],"mappings":"AAAA,SAAS,iBAA8B;AAEvC,SAAS,QAAQ,iBAAiB;AAClC,SAAS,YAAY,qBAAqB;AAiB1C,MAAM,OAAO,CAAC,SACZ,KACG,YAAY,EACZ,QAAQ,oBAAoB,GAAG,EAC/B,QAAQ,YAAY,EAAE,EACtB,MAAM,GAAG,EAAE;AAEhB,SAAS,QAAQ,KAAsB,QAAmC;AACxE,QAAM,MAAyB,CAAC;AAChC,QAAM,OAAO,oBAAI,IAAoB;AACrC,MAAI,YAAY,CAAC,MAAM,QAAQ;AAC7B,QAAI,KAAK,KAAK,SAAS,UAAW,QAAO,CAAC,KAAK;AAC/C,UAAM,OAAO,KAAK,YAAY,KAAK;AACnC,UAAM,OAAO,GAAG,MAAM,IAAI,KAAK,IAAI,KAAK,SAAS;AACjD,UAAM,QAAQ,KAAK,IAAI,IAAI,KAAK;AAChC,SAAK,IAAI,MAAM,QAAQ,CAAC;AACxB,QAAI,KAAK,EAAE,IAAI,QAAQ,GAAG,IAAI,IAAI,QAAQ,CAAC,KAAK,MAAM,OAAO,KAAK,MAAM,OAAiB,MAAM,IAAI,CAAC;AACpG,WAAO;AAAA,EACT,CAAC;AACD,SAAO;AACT;AAGO,SAAS,uBAAuB,QAAmC;AACxE,SAAO,QAAQ,OAAO,MAAM,KAAK,OAAO,QAAQ,YAAY,UAAU,KAAK;AAC7E;AAGO,MAAM,aAAa,UAAU,OAAmC;AAAA,EACrE,MAAM;AAAA,EACN,aAAa;AACX,WAAO,EAAE,QAAQ,OAAO,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAA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