@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,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { RadioGroup as RadioGroupPrimitive } from "radix-ui";
|
|
5
|
+
import { Star } from "atoms-icons";
|
|
6
|
+
import { useControllableState } from "../input/use-controllable-state.mjs";
|
|
7
|
+
import { hitY } from "../../../lib/hit-area.mjs";
|
|
8
|
+
import { tv } from "../../../lib/tv.mjs";
|
|
9
|
+
const ratingVariants = tv({
|
|
10
|
+
slots: {
|
|
11
|
+
root: "inline-flex items-center gap-0.5 data-disabled:opacity-50",
|
|
12
|
+
star: [
|
|
13
|
+
"inline-flex shrink-0 items-center justify-center rounded-sm p-0.5",
|
|
14
|
+
hitY,
|
|
15
|
+
"transition-transform duration-fast ease-out outline-none hover:scale-110 active:scale-95 motion-reduce:transform-none",
|
|
16
|
+
"focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
17
|
+
"disabled:pointer-events-none cursor-pointer"
|
|
18
|
+
],
|
|
19
|
+
cell: "relative inline-flex shrink-0",
|
|
20
|
+
empty: "",
|
|
21
|
+
clip: "absolute inset-y-0 start-0 overflow-hidden",
|
|
22
|
+
fill: ""
|
|
23
|
+
},
|
|
24
|
+
variants: {
|
|
25
|
+
size: {
|
|
26
|
+
sm: { cell: "size-4", empty: "size-4", fill: "size-4" },
|
|
27
|
+
md: { cell: "size-5", empty: "size-5", fill: "size-5" },
|
|
28
|
+
lg: { cell: "size-7", empty: "size-7", fill: "size-7" }
|
|
29
|
+
},
|
|
30
|
+
variant: {
|
|
31
|
+
filled: { empty: "text-muted-foreground/25", fill: "fill-current" },
|
|
32
|
+
outline: { empty: "text-muted-foreground/35", fill: "" }
|
|
33
|
+
},
|
|
34
|
+
tone: {
|
|
35
|
+
amber: { fill: "text-rating" },
|
|
36
|
+
red: { fill: "text-rating-red" }
|
|
37
|
+
},
|
|
38
|
+
readOnly: {
|
|
39
|
+
true: { star: "p-0 cursor-default hover:scale-100 active:scale-100" }
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
defaultVariants: { size: "md", variant: "filled", tone: "amber" }
|
|
43
|
+
});
|
|
44
|
+
function Glyph({ Icon, share, slots }) {
|
|
45
|
+
return /* @__PURE__ */ jsxs("span", { "aria-hidden": true, className: slots.cell(), children: [
|
|
46
|
+
/* @__PURE__ */ jsx(Icon, { className: slots.empty() }),
|
|
47
|
+
/* @__PURE__ */ jsx("span", { className: slots.clip(), style: { width: `${Math.round(share * 100)}%` }, children: /* @__PURE__ */ jsx(Icon, { className: slots.fill() }) })
|
|
48
|
+
] });
|
|
49
|
+
}
|
|
50
|
+
function Rating({
|
|
51
|
+
value: valueProp,
|
|
52
|
+
defaultValue = 0,
|
|
53
|
+
onValueChange,
|
|
54
|
+
max = 5,
|
|
55
|
+
readOnly = false,
|
|
56
|
+
disabled = false,
|
|
57
|
+
name,
|
|
58
|
+
icon: Icon = Star,
|
|
59
|
+
size = "md",
|
|
60
|
+
variant = "filled",
|
|
61
|
+
tone = "amber",
|
|
62
|
+
className,
|
|
63
|
+
"aria-label": ariaLabel = "Rating",
|
|
64
|
+
...props
|
|
65
|
+
}) {
|
|
66
|
+
const [value, setValue] = useControllableState({ prop: valueProp, defaultProp: defaultValue, onChange: onValueChange });
|
|
67
|
+
const [hover, setHover] = React.useState(null);
|
|
68
|
+
const slots = ratingVariants({ size, variant, tone, readOnly });
|
|
69
|
+
const stars = Array.from({ length: max }, (_, i) => i + 1);
|
|
70
|
+
if (readOnly) {
|
|
71
|
+
const clamped = Math.min(max, Math.max(0, value));
|
|
72
|
+
return /* @__PURE__ */ jsx(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
role: "img",
|
|
76
|
+
"aria-label": `${ariaLabel}: ${Number(clamped.toFixed(1))} of ${max}`,
|
|
77
|
+
"data-slot": "rating",
|
|
78
|
+
className: slots.root({ className }),
|
|
79
|
+
...props,
|
|
80
|
+
children: stars.map((n) => /* @__PURE__ */ jsx("span", { className: slots.star(), children: /* @__PURE__ */ jsx(Glyph, { Icon, share: Math.min(1, Math.max(0, clamped - (n - 1))), slots }) }, n))
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
const shown = hover ?? value;
|
|
85
|
+
return /* @__PURE__ */ jsx(
|
|
86
|
+
RadioGroupPrimitive.Root,
|
|
87
|
+
{
|
|
88
|
+
"data-slot": "rating",
|
|
89
|
+
"aria-label": ariaLabel,
|
|
90
|
+
orientation: "horizontal",
|
|
91
|
+
loop: false,
|
|
92
|
+
disabled,
|
|
93
|
+
name,
|
|
94
|
+
value: value > 0 ? String(value) : "",
|
|
95
|
+
onValueChange: (next) => setValue(Number(next)),
|
|
96
|
+
onPointerLeave: () => setHover(null),
|
|
97
|
+
className: slots.root({ className }),
|
|
98
|
+
...props,
|
|
99
|
+
children: stars.map((n) => /* @__PURE__ */ jsx(
|
|
100
|
+
RadioGroupPrimitive.Item,
|
|
101
|
+
{
|
|
102
|
+
value: String(n),
|
|
103
|
+
"aria-label": `${ariaLabel} ${n} of ${max}`,
|
|
104
|
+
className: slots.star(),
|
|
105
|
+
onPointerEnter: (event) => {
|
|
106
|
+
if (event.pointerType === "mouse") setHover(n);
|
|
107
|
+
},
|
|
108
|
+
children: /* @__PURE__ */ jsx(Glyph, { Icon, share: n <= shown ? 1 : 0, slots })
|
|
109
|
+
},
|
|
110
|
+
n
|
|
111
|
+
))
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
Rating,
|
|
117
|
+
ratingVariants
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=rating.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/rating/rating.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport { RadioGroup as RadioGroupPrimitive } from \"radix-ui\"\r\nimport { Star } from \"atoms-icons\"\r\n\r\nimport { useControllableState } from \"../input/use-controllable-state.mjs\"\r\nimport { hitY } from \"../../../lib/hit-area.mjs\"\r\nimport { tv } from \"../../../lib/tv.mjs\"\r\n\r\n/*\r\n * A 1-to-N star rating over Radix RadioGroup: roving focus, the arrow keys and a single value come\r\n * from Radix. Each star stacks a faint glyph under a coloured one clipped to a width, so a\r\n * read-only average like 4.3 shows a partly filled star. The active glyph is the same outline icon\r\n * filled with `fill-current`: the one documented opt-out of outline-only icons.\r\n */\r\nexport const ratingVariants = tv({\r\n slots: {\r\n root: \"inline-flex items-center gap-0.5 data-disabled:opacity-50\",\r\n star: [\r\n \"inline-flex shrink-0 items-center justify-center rounded-sm p-0.5\",\r\n hitY,\r\n \"transition-transform duration-fast ease-out outline-none hover:scale-110 active:scale-95 motion-reduce:transform-none\",\r\n \"focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\r\n \"disabled:pointer-events-none cursor-pointer\",\r\n ],\r\n cell: \"relative inline-flex shrink-0\",\r\n empty: \"\",\r\n clip: \"absolute inset-y-0 start-0 overflow-hidden\",\r\n fill: \"\",\r\n },\r\n variants: {\r\n size: {\r\n sm: { cell: \"size-4\", empty: \"size-4\", fill: \"size-4\" },\r\n md: { cell: \"size-5\", empty: \"size-5\", fill: \"size-5\" },\r\n lg: { cell: \"size-7\", empty: \"size-7\", fill: \"size-7\" },\r\n },\r\n variant: {\r\n filled: { empty: \"text-muted-foreground/25\", fill: \"fill-current\" },\r\n outline: { empty: \"text-muted-foreground/35\", fill: \"\" },\r\n },\r\n tone: {\r\n amber: { fill: \"text-rating\" },\r\n red: { fill: \"text-rating-red\" },\r\n },\r\n readOnly: {\r\n true: { star: \"p-0 cursor-default hover:scale-100 active:scale-100\" },\r\n },\r\n },\r\n defaultVariants: { size: \"md\", variant: \"filled\", tone: \"amber\" },\r\n})\r\n\r\ntype RatingIcon = React.ComponentType<React.SVGProps<SVGSVGElement>>\r\n\r\nexport interface RatingProps extends Omit<React.ComponentProps<\"div\">, \"onChange\" | \"defaultValue\" | \"dir\"> {\r\n /** Controlled value. Whole numbers when interactive; fractions render when readOnly. */\r\n value?: number\r\n /** Uncontrolled initial value. */\r\n defaultValue?: number\r\n /** Called with the new whole-star value when a star is selected. */\r\n onValueChange?: (value: number) => void\r\n /** Number of stars in the scale. */\r\n max?: number\r\n /** A static, fraction-capable display, labelled like \"Rating: 4.3 of 5\". */\r\n readOnly?: boolean\r\n /** Disables every star and fades the row. */\r\n disabled?: boolean\r\n /** Form field name, so the value submits with a form. */\r\n name?: string\r\n /** Any atoms-icons component instead of the star, e.g. Heart. */\r\n icon?: RatingIcon\r\n /** Star size: 16, 20 or 28px. */\r\n size?: \"sm\" | \"md\" | \"lg\"\r\n /** filled draws the active glyph solid; outline keeps it a tinted outline. */\r\n variant?: \"filled\" | \"outline\"\r\n /** Hue of the active glyph: review gold, or a red that suits a heart. */\r\n tone?: \"amber\" | \"red\"\r\n}\r\n\r\nfunction Glyph({ Icon, share, slots }: { Icon: RatingIcon; share: number; slots: ReturnType<typeof ratingVariants> }) {\r\n return (\r\n <span aria-hidden className={slots.cell()}>\r\n <Icon className={slots.empty()} />\r\n <span className={slots.clip()} style={{ width: `${Math.round(share * 100)}%` }}>\r\n <Icon className={slots.fill()} />\r\n </span>\r\n </span>\r\n )\r\n}\r\n\r\nexport function Rating({\r\n value: valueProp,\r\n defaultValue = 0,\r\n onValueChange,\r\n max = 5,\r\n readOnly = false,\r\n disabled = false,\r\n name,\r\n icon: Icon = Star,\r\n size = \"md\",\r\n variant = \"filled\",\r\n tone = \"amber\",\r\n className,\r\n \"aria-label\": ariaLabel = \"Rating\",\r\n ...props\r\n}: RatingProps) {\r\n const [value, setValue] = useControllableState({ prop: valueProp, defaultProp: defaultValue, onChange: onValueChange })\r\n const [hover, setHover] = React.useState<number | null>(null)\r\n const slots = ratingVariants({ size, variant, tone, readOnly })\r\n const stars = Array.from({ length: max }, (_, i) => i + 1)\r\n\r\n if (readOnly) {\r\n const clamped = Math.min(max, Math.max(0, value))\r\n return (\r\n <div\r\n role=\"img\"\r\n aria-label={`${ariaLabel}: ${Number(clamped.toFixed(1))} of ${max}`}\r\n data-slot=\"rating\"\r\n className={slots.root({ className })}\r\n {...props}\r\n >\r\n {stars.map((n) => (\r\n <span key={n} className={slots.star()}>\r\n <Glyph Icon={Icon} share={Math.min(1, Math.max(0, clamped - (n - 1)))} slots={slots} />\r\n </span>\r\n ))}\r\n </div>\r\n )\r\n }\r\n\r\n const shown = hover ?? value\r\n return (\r\n <RadioGroupPrimitive.Root\r\n data-slot=\"rating\"\r\n aria-label={ariaLabel}\r\n orientation=\"horizontal\"\r\n loop={false}\r\n disabled={disabled}\r\n name={name}\r\n value={value > 0 ? String(value) : \"\"}\r\n onValueChange={(next) => setValue(Number(next))}\r\n onPointerLeave={() => setHover(null)}\r\n className={slots.root({ className })}\r\n {...props}\r\n >\r\n {stars.map((n) => (\r\n <RadioGroupPrimitive.Item\r\n key={n}\r\n value={String(n)}\r\n aria-label={`${ariaLabel} ${n} of ${max}`}\r\n className={slots.star()}\r\n onPointerEnter={(event) => {\r\n if (event.pointerType === \"mouse\") setHover(n)\r\n }}\r\n >\r\n <Glyph Icon={Icon} share={n <= shown ? 1 : 0} slots={slots} />\r\n </RadioGroupPrimitive.Item>\r\n ))}\r\n </RadioGroupPrimitive.Root>\r\n )\r\n}\r\n"],"mappings":";AAiFI,SACE,KADF;AA/EJ,YAAY,WAAW;AACvB,SAAS,cAAc,2BAA2B;AAClD,SAAS,YAAY;AAErB,SAAS,4BAA4B;AACrC,SAAS,YAAY;AACrB,SAAS,UAAU;AAQZ,MAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI,EAAE,MAAM,UAAU,OAAO,UAAU,MAAM,SAAS;AAAA,MACtD,IAAI,EAAE,MAAM,UAAU,OAAO,UAAU,MAAM,SAAS;AAAA,MACtD,IAAI,EAAE,MAAM,UAAU,OAAO,UAAU,MAAM,SAAS;AAAA,IACxD;AAAA,IACA,SAAS;AAAA,MACP,QAAQ,EAAE,OAAO,4BAA4B,MAAM,eAAe;AAAA,MAClE,SAAS,EAAE,OAAO,4BAA4B,MAAM,GAAG;AAAA,IACzD;AAAA,IACA,MAAM;AAAA,MACJ,OAAO,EAAE,MAAM,cAAc;AAAA,MAC7B,KAAK,EAAE,MAAM,kB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import * as React from "react";
|
|
4
|
+
import { useEditorState } from "@tiptap/react";
|
|
5
|
+
import { BubbleMenu } from "@tiptap/react/menus";
|
|
6
|
+
import { Check, Link as LinkIcon, TextB, TextItalic, TextUnderline, X } from "atoms-icons";
|
|
7
|
+
import { Toolbar as ToolbarPrimitive } from "radix-ui";
|
|
8
|
+
import { Button } from "../button/index.mjs";
|
|
9
|
+
import { InputField, InputRoot } from "../input/index.mjs";
|
|
10
|
+
import { TooltipGroup } from "../tooltip/index.mjs";
|
|
11
|
+
import { cn } from "../../../lib/utils.mjs";
|
|
12
|
+
import { useRichTextEditorContext } from "./rich-text-editor.mjs";
|
|
13
|
+
import { RichTextEditorButton, applyLink } from "./toolbar.mjs";
|
|
14
|
+
const bubbleClass = [
|
|
15
|
+
"flex items-center gap-0.5 rounded-lg bg-popover p-1 inset-ring-1 inset-ring-border-soft text-popover-foreground shadow-md outline-none [--surface:var(--popover)]",
|
|
16
|
+
"origin-bottom animate-in fade-in-0 zoom-in-95 duration-fast ease-out"
|
|
17
|
+
].join(" ");
|
|
18
|
+
const BubbleLinkContext = React.createContext(null);
|
|
19
|
+
function RichTextEditorBubbleLink() {
|
|
20
|
+
const { editor, labels } = useRichTextEditorContext("RichTextEditorBubbleLink");
|
|
21
|
+
const setLinking = React.useContext(BubbleLinkContext);
|
|
22
|
+
const active = useEditorState({ editor, selector: ({ editor: editor2 }) => editor2?.isActive("link") ?? false });
|
|
23
|
+
return /* @__PURE__ */ jsx(RichTextEditorButton, { size: "sm", tooltip: labels.link, pressed: active ?? false, onClick: () => setLinking?.(true), children: /* @__PURE__ */ jsx(LinkIcon, {}) });
|
|
24
|
+
}
|
|
25
|
+
function DefaultBubbleControls() {
|
|
26
|
+
const { editor, labels } = useRichTextEditorContext("RichTextEditorBubbleMenu");
|
|
27
|
+
const state = useEditorState({
|
|
28
|
+
editor,
|
|
29
|
+
selector: ({ editor: editor2 }) => ({
|
|
30
|
+
bold: editor2?.isActive("bold") ?? false,
|
|
31
|
+
italic: editor2?.isActive("italic") ?? false,
|
|
32
|
+
underline: editor2?.isActive("underline") ?? false
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
36
|
+
/* @__PURE__ */ jsx(RichTextEditorButton, { size: "sm", tooltip: labels.bold, pressed: state?.bold, onClick: () => editor?.chain().focus().toggleBold().run(), children: /* @__PURE__ */ jsx(TextB, {}) }),
|
|
37
|
+
/* @__PURE__ */ jsx(RichTextEditorButton, { size: "sm", tooltip: labels.italic, pressed: state?.italic, onClick: () => editor?.chain().focus().toggleItalic().run(), children: /* @__PURE__ */ jsx(TextItalic, {}) }),
|
|
38
|
+
/* @__PURE__ */ jsx(RichTextEditorButton, { size: "sm", tooltip: labels.underline, pressed: state?.underline, onClick: () => editor?.chain().focus().toggleUnderline().run(), children: /* @__PURE__ */ jsx(TextUnderline, {}) }),
|
|
39
|
+
/* @__PURE__ */ jsx(RichTextEditorBubbleLink, {})
|
|
40
|
+
] });
|
|
41
|
+
}
|
|
42
|
+
function RichTextEditorBubbleMenu({
|
|
43
|
+
children,
|
|
44
|
+
className,
|
|
45
|
+
options,
|
|
46
|
+
updateDelay = 250,
|
|
47
|
+
...props
|
|
48
|
+
}) {
|
|
49
|
+
const { editor, labels } = useRichTextEditorContext("RichTextEditorBubbleMenu");
|
|
50
|
+
const [linking, setLinking] = React.useState(false);
|
|
51
|
+
const [href, setHref] = React.useState("");
|
|
52
|
+
const startLinking = React.useCallback(
|
|
53
|
+
(open) => {
|
|
54
|
+
if (open) setHref(editor?.getAttributes("link").href ?? "");
|
|
55
|
+
setLinking(open);
|
|
56
|
+
},
|
|
57
|
+
[editor]
|
|
58
|
+
);
|
|
59
|
+
if (!editor) return null;
|
|
60
|
+
const finish = () => {
|
|
61
|
+
setLinking(false);
|
|
62
|
+
editor.commands.focus();
|
|
63
|
+
};
|
|
64
|
+
return /* @__PURE__ */ jsx(
|
|
65
|
+
BubbleMenu,
|
|
66
|
+
{
|
|
67
|
+
editor,
|
|
68
|
+
updateDelay,
|
|
69
|
+
options: { placement: "top", offset: 8, onHide: () => setLinking(false), ...options },
|
|
70
|
+
...props,
|
|
71
|
+
children: /* @__PURE__ */ jsx(TooltipGroup, { children: /* @__PURE__ */ jsx(
|
|
72
|
+
ToolbarPrimitive.Root,
|
|
73
|
+
{
|
|
74
|
+
"aria-label": labels.bubble,
|
|
75
|
+
"data-slot": "rich-text-editor-bubble",
|
|
76
|
+
className: cn(bubbleClass, className),
|
|
77
|
+
onKeyDown: (event) => {
|
|
78
|
+
if (event.key === "Escape" && linking) {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
finish();
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
children: linking ? /* @__PURE__ */ jsxs(
|
|
84
|
+
"form",
|
|
85
|
+
{
|
|
86
|
+
className: "flex items-center gap-1",
|
|
87
|
+
onSubmit: (event) => {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
applyLink(editor, href);
|
|
90
|
+
setLinking(false);
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsx(InputRoot, { size: "sm", className: "h-8 w-56", children: /* @__PURE__ */ jsx(
|
|
94
|
+
InputField,
|
|
95
|
+
{
|
|
96
|
+
type: "text",
|
|
97
|
+
autoComplete: "url",
|
|
98
|
+
inputMode: "url",
|
|
99
|
+
autoFocus: true,
|
|
100
|
+
"aria-label": labels.link,
|
|
101
|
+
placeholder: labels.linkPlaceholder,
|
|
102
|
+
value: href,
|
|
103
|
+
onChange: (event) => setHref(event.target.value)
|
|
104
|
+
}
|
|
105
|
+
) }),
|
|
106
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", size: "sm", iconOnly: true, "aria-label": labels.applyLink, className: "rounded-md", children: /* @__PURE__ */ jsx(Check, {}) }),
|
|
107
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", iconOnly: true, "aria-label": labels.cancel, className: "rounded-md", onClick: finish, children: /* @__PURE__ */ jsx(X, {}) })
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
) : /* @__PURE__ */ jsx(BubbleLinkContext.Provider, { value: startLinking, children: children ?? /* @__PURE__ */ jsx(DefaultBubbleControls, {}) })
|
|
111
|
+
}
|
|
112
|
+
) })
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
RichTextEditorBubbleLink,
|
|
118
|
+
RichTextEditorBubbleMenu
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=bubble-menu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/rich-text-editor/bubble-menu.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport { useEditorState } from \"@tiptap/react\"\r\nimport { BubbleMenu, type BubbleMenuProps } from \"@tiptap/react/menus\"\r\nimport { Check, Link as LinkIcon, TextB, TextItalic, TextUnderline, X } from \"atoms-icons\"\r\nimport { Toolbar as ToolbarPrimitive } from \"radix-ui\"\r\n\r\nimport { Button } from \"../button/index.mjs\"\r\nimport { InputField, InputRoot } from \"../input/index.mjs\"\r\nimport { TooltipGroup } from \"../tooltip/index.mjs\"\r\nimport { cn } from \"../../../lib/utils.mjs\"\r\n\r\nimport { useRichTextEditorContext } from \"./rich-text-editor.mjs\"\r\nimport { RichTextEditorButton, applyLink } from \"./toolbar.mjs\"\r\n\r\nconst bubbleClass = [\r\n \"flex items-center gap-0.5 rounded-lg bg-popover p-1 inset-ring-1 inset-ring-border-soft text-popover-foreground shadow-md outline-none [--surface:var(--popover)]\",\r\n \"origin-bottom animate-in fade-in-0 zoom-in-95 duration-fast ease-out\",\r\n].join(\" \")\r\n\r\nconst BubbleLinkContext = React.createContext<((open: boolean) => void) | null>(null)\r\n\r\n/** The bubble's link control: expands the bubble in place into a URL field, so it never closes while you type. */\r\nexport function RichTextEditorBubbleLink() {\r\n const { editor, labels } = useRichTextEditorContext(\"RichTextEditorBubbleLink\")\r\n const setLinking = React.useContext(BubbleLinkContext)\r\n const active = useEditorState({ editor, selector: ({ editor }) => editor?.isActive(\"link\") ?? false })\r\n return (\r\n <RichTextEditorButton size=\"sm\" tooltip={labels.link} pressed={active ?? false} onClick={() => setLinking?.(true)}>\r\n <LinkIcon />\r\n </RichTextEditorButton>\r\n )\r\n}\r\n\r\nfunction DefaultBubbleControls() {\r\n const { editor, labels } = useRichTextEditorContext(\"RichTextEditorBubbleMenu\")\r\n const state = useEditorState({\r\n editor,\r\n selector: ({ editor }) => ({\r\n bold: editor?.isActive(\"bold\") ?? false,\r\n italic: editor?.isActive(\"italic\") ?? false,\r\n underline: editor?.isActive(\"underline\") ?? false,\r\n }),\r\n })\r\n return (\r\n <>\r\n <RichTextEditorButton size=\"sm\" tooltip={labels.bold} pressed={state?.bold} onClick={() => editor?.chain().focus().toggleBold().run()}>\r\n <TextB />\r\n </RichTextEditorButton>\r\n <RichTextEditorButton size=\"sm\" tooltip={labels.italic} pressed={state?.italic} onClick={() => editor?.chain().focus().toggleItalic().run()}>\r\n <TextItalic />\r\n </RichTextEditorButton>\r\n <RichTextEditorButton size=\"sm\" tooltip={labels.underline} pressed={state?.underline} onClick={() => editor?.chain().focus().toggleUnderline().run()}>\r\n <TextUnderline />\r\n </RichTextEditorButton>\r\n <RichTextEditorBubbleLink />\r\n </>\r\n )\r\n}\r\n\r\nexport interface RichTextEditorBubbleMenuProps extends Omit<BubbleMenuProps, \"editor\" | \"children\"> {\r\n /** Custom controls (use `size=\"sm\"` buttons). Without children: bold, italic, underline and link. */\r\n children?: React.ReactNode\r\n}\r\n\r\n/**\r\n * A floating toolbar over the current selection, on Tiptap's BubbleMenu (Floating UI). `className`\r\n * styles the inner toolbar; other props go to the floating wrapper. Renders nothing before mount.\r\n */\r\nexport function RichTextEditorBubbleMenu({\r\n children,\r\n className,\r\n options,\r\n updateDelay = 250,\r\n ...props\r\n}: RichTextEditorBubbleMenuProps) {\r\n const { editor, labels } = useRichTextEditorContext(\"RichTextEditorBubbleMenu\")\r\n const [linking, setLinking] = React.useState(false)\r\n const [href, setHref] = React.useState(\"\")\r\n\r\n const startLinking = React.useCallback(\r\n (open: boolean) => {\r\n if (open) setHref((editor?.getAttributes(\"link\").href as string | undefined) ?? \"\")\r\n setLinking(open)\r\n },\r\n [editor],\r\n )\r\n\r\n if (!editor) return null\r\n\r\n const finish = () => {\r\n setLinking(false)\r\n editor.commands.focus()\r\n }\r\n\r\n return (\r\n <BubbleMenu\r\n editor={editor}\r\n updateDelay={updateDelay}\r\n options={{ placement: \"top\", offset: 8, onHide: () => setLinking(false), ...options }}\r\n {...props}\r\n >\r\n <TooltipGroup>\r\n <ToolbarPrimitive.Root\r\n aria-label={labels.bubble}\r\n data-slot=\"rich-text-editor-bubble\"\r\n className={cn(bubbleClass, className)}\r\n onKeyDown={(event) => {\r\n if (event.key === \"Escape\" && linking) {\r\n event.preventDefault()\r\n finish()\r\n }\r\n }}\r\n >\r\n {linking ? (\r\n <form\r\n className=\"flex items-center gap-1\"\r\n onSubmit={(event) => {\r\n event.preventDefault()\r\n applyLink(editor, href)\r\n setLinking(false)\r\n }}\r\n >\r\n <InputRoot size=\"sm\" className=\"h-8 w-56\">\r\n <InputField\r\n // Text, not url: a bare domain is fine, normalizeHref adds the scheme.\r\n type=\"text\"\r\n autoComplete=\"url\"\r\n inputMode=\"url\"\r\n autoFocus\r\n aria-label={labels.link}\r\n placeholder={labels.linkPlaceholder}\r\n value={href}\r\n onChange={(event) => setHref(event.target.value)}\r\n />\r\n </InputRoot>\r\n <Button type=\"submit\" size=\"sm\" iconOnly aria-label={labels.applyLink} className=\"rounded-md\">\r\n <Check />\r\n </Button>\r\n <Button type=\"button\" variant=\"ghost\" size=\"sm\" iconOnly aria-label={labels.cancel} className=\"rounded-md\" onClick={finish}>\r\n <X />\r\n </Button>\r\n </form>\r\n ) : (\r\n <BubbleLinkContext.Provider value={startLinking}>{children ?? <DefaultBubb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@tiptap/pm/state";
|
|
3
|
+
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
4
|
+
const IMAGE_URL = /^(?:https?:\/\/|\/)[^\s]+\.(?:png|jpe?g|gif|webp|avif|svg)(?:[?#][^\s]*)?$/i;
|
|
5
|
+
const URL_IN_TEXT = /(?:https?:\/\/|(?<=\s|^)\/)[^\s]+/gi;
|
|
6
|
+
function imageUrls(block) {
|
|
7
|
+
const urls = [];
|
|
8
|
+
block.descendants((child) => {
|
|
9
|
+
const href = child.marks.find((mark) => mark.type.name === "link")?.attrs.href;
|
|
10
|
+
if (href && IMAGE_URL.test(href)) urls.push(href);
|
|
11
|
+
else if (child.isText && child.text) {
|
|
12
|
+
for (const match of child.text.matchAll(URL_IN_TEXT)) if (IMAGE_URL.test(match[0])) urls.push(match[0]);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return [...new Set(urls)];
|
|
16
|
+
}
|
|
17
|
+
function figure(url) {
|
|
18
|
+
const node = document.createElement("figure");
|
|
19
|
+
node.setAttribute("data-slot", "rich-text-editor-image-link");
|
|
20
|
+
node.contentEditable = "false";
|
|
21
|
+
node.className = "!mt-2 block w-fit max-w-full select-none";
|
|
22
|
+
const image = document.createElement("img");
|
|
23
|
+
image.src = url;
|
|
24
|
+
image.alt = "";
|
|
25
|
+
image.loading = "lazy";
|
|
26
|
+
image.decoding = "async";
|
|
27
|
+
image.referrerPolicy = "no-referrer";
|
|
28
|
+
image.draggable = false;
|
|
29
|
+
image.className = "block max-h-80 max-w-full rounded-md object-contain ring-1 ring-edge";
|
|
30
|
+
image.addEventListener("error", () => {
|
|
31
|
+
node.hidden = true;
|
|
32
|
+
});
|
|
33
|
+
node.append(image);
|
|
34
|
+
return node;
|
|
35
|
+
}
|
|
36
|
+
const key = new PluginKey("imageLinks");
|
|
37
|
+
const ImageLinks = Extension.create({
|
|
38
|
+
name: "imageLinks",
|
|
39
|
+
addProseMirrorPlugins() {
|
|
40
|
+
return [
|
|
41
|
+
new Plugin({
|
|
42
|
+
key,
|
|
43
|
+
props: {
|
|
44
|
+
decorations(state) {
|
|
45
|
+
const decorations = [];
|
|
46
|
+
state.doc.descendants((node, pos) => {
|
|
47
|
+
if (!node.isTextblock) return true;
|
|
48
|
+
for (const url of imageUrls(node)) {
|
|
49
|
+
decorations.push(Decoration.widget(pos + node.nodeSize, () => figure(url), { key: `${pos}:${url}`, side: 1 }));
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
});
|
|
53
|
+
return DecorationSet.create(state.doc, decorations);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
export {
|
|
61
|
+
ImageLinks
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=image-links.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/rich-text-editor/image-links.ts"],"sourcesContent":["import { Extension } from \"@tiptap/core\"\nimport type { Node as PMNode } from \"@tiptap/pm/model\"\nimport { Plugin, PluginKey } from \"@tiptap/pm/state\"\nimport { Decoration, DecorationSet } from \"@tiptap/pm/view\"\n\n/*\n * Image links: any text block that links to an image file shows the picture right under it. It is a\n * decoration, not content: the saved HTML keeps the link alone, and a picture that fails to load\n * takes no room. Atoms adds `.svg` to the reference's list so previews can run on local art.\n */\n\nconst IMAGE_URL = /^(?:https?:\\/\\/|\\/)[^\\s]+\\.(?:png|jpe?g|gif|webp|avif|svg)(?:[?#][^\\s]*)?$/i\nconst URL_IN_TEXT = /(?:https?:\\/\\/|(?<=\\s|^)\\/)[^\\s]+/gi\n\n/** Image URLs a text block links to, through a link mark or as a typed URL, in order. */\nfunction imageUrls(block: PMNode): string[] {\n const urls: string[] = []\n block.descendants((child) => {\n const href = child.marks.find((mark) => mark.type.name === \"link\")?.attrs.href as string | undefined\n if (href && IMAGE_URL.test(href)) urls.push(href)\n else if (child.isText && child.text) {\n for (const match of child.text.matchAll(URL_IN_TEXT)) if (IMAGE_URL.test(match[0])) urls.push(match[0])\n }\n })\n return [...new Set(urls)]\n}\n\nfunction figure(url: string) {\n const node = document.createElement(\"figure\")\n node.setAttribute(\"data-slot\", \"rich-text-editor-image-link\")\n node.contentEditable = \"false\"\n node.className = \"!mt-2 block w-fit max-w-full select-none\"\n const image = document.createElement(\"img\")\n image.src = url\n image.alt = \"\"\n image.loading = \"lazy\"\n image.decoding = \"async\"\n image.referrerPolicy = \"no-referrer\"\n image.draggable = false\n image.className = \"block max-h-80 max-w-full rounded-md object-contain ring-1 ring-edge\"\n image.addEventListener(\"error\", () => {\n node.hidden = true\n })\n node.append(image)\n return node\n}\n\nconst key = new PluginKey(\"imageLinks\")\n\nexport const ImageLinks = Extension.create({\n name: \"imageLinks\",\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key,\n props: {\n decorations(state) {\n const decorations: Decoration[] = []\n state.doc.descendants((node, pos) => {\n if (!node.isTextblock) return true\n for (const url of imageUrls(node)) {\n decorations.push(Decoration.widget(pos + node.nodeSize, () => figure(url), { key: `${pos}:${url}`, side: 1 }))\n }\n return false\n })\n return DecorationSet.create(state.doc, decorations)\n },\n },\n }),\n ]\n },\n})\n"],"mappings":"AAAA,SAAS,iBAAiB;AAE1B,SAAS,QAAQ,iBAAiB;AAClC,SAAS,YAAY,qBAAqB;AAQ1C,MAAM,YAAY;AAClB,MAAM,cAAc;AAGpB,SAAS,UAAU,OAAyB;AAC1C,QAAM,OAAiB,CAAC;AACxB,QAAM,YAAY,CAAC,UAAU;AAC3B,UAAM,OAAO,MAAM,MAAM,KAAK,CAAC,SAAS,KAAK,KAAK,SAAS,MAAM,GAAG,MAAM;AAC1E,QAAI,QAAQ,UAAU,KAAK,IAAI,EAAG,MAAK,KAAK,IAAI;AAAA,aACvC,MAAM,UAAU,MAAM,MAAM;AACnC,iBAAW,SAAS,MAAM,KAAK,SAAS,WAAW,EAAG,KAAI,UAAU,KAAK,MAAM,CAAC,CAA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extEditor,
|
|
3
|
+
RichTextEditorContent,
|
|
4
|
+
useRichTextEditor,
|
|
5
|
+
richTextEditorVariants
|
|
6
|
+
} from "./rich-text-editor.mjs";
|
|
7
|
+
import {
|
|
8
|
+
RichTextEditorToolbar,
|
|
9
|
+
RichTextEditorButton,
|
|
10
|
+
RichTextEditorSeparator,
|
|
11
|
+
RichTextEditorAlignGroup,
|
|
12
|
+
RichTextEditorLinkButton,
|
|
13
|
+
richTextEditorToolbarVariants
|
|
14
|
+
} from "./toolbar.mjs";
|
|
15
|
+
import {
|
|
16
|
+
RichTextEditorBubbleMenu,
|
|
17
|
+
RichTextEditorBubbleLink
|
|
18
|
+
} from "./bubble-menu.mjs";
|
|
19
|
+
import { defaultLabels } from "./labels.mjs";
|
|
20
|
+
import { ImageLinks } from "./image-links.mjs";
|
|
21
|
+
export {
|
|
22
|
+
ImageLinks,
|
|
23
|
+
RichTextEditor,
|
|
24
|
+
RichTextEditorAlignGroup,
|
|
25
|
+
RichTextEditorBubbleLink,
|
|
26
|
+
RichTextEditorBubbleMenu,
|
|
27
|
+
RichTextEditorButton,
|
|
28
|
+
RichTextEditorContent,
|
|
29
|
+
RichTextEditorLinkButton,
|
|
30
|
+
RichTextEditorSeparator,
|
|
31
|
+
RichTextEditorToolbar,
|
|
32
|
+
defaultLabels as richTextEditorDefaultLabels,
|
|
33
|
+
richTextEditorToolbarVariants,
|
|
34
|
+
richTextEditorVariants,
|
|
35
|
+
useRichTextEditor
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/rich-text-editor/index.ts"],"sourcesContent":["export {\n RichTextEditor,\n RichTextEditorContent,\n useRichTextEditor,\n richTextEditorVariants,\n type RichTextEditorProps,\n type RichTextEditorAlignment,\n} from \"./rich-text-editor.mjs\"\nexport {\n RichTextEditorToolbar,\n RichTextEditorButton,\n RichTextEditorSeparator,\n RichTextEditorAlignGroup,\n RichTextEditorLinkButton,\n richTextEditorToolbarVariants,\n type RichTextEditorToolbarProps,\n type RichTextEditorButtonProps,\n} from \"./toolbar.mjs\"\nexport {\n RichTextEditorBubbleMenu,\n RichTextEditorBubbleLink,\n type RichTextEditorBubbleMenuProps,\n} from \"./bubble-menu.mjs\"\nexport { defaultLabels as richTextEditorDefaultLabels, type RichTextEditorLabels } from \"./labels.mjs\"\nexport { ImageLinks } from \"./image-links.mjs\"\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAA0B,qBAA8D;AACxF,SAAS,kBAAkB;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const defaultLabels = {
|
|
2
|
+
toolbar: "Formatting",
|
|
3
|
+
bubble: "Selection formatting",
|
|
4
|
+
heading1: "Heading 1",
|
|
5
|
+
heading2: "Heading 2",
|
|
6
|
+
heading3: "Heading 3",
|
|
7
|
+
heading4: "Heading 4",
|
|
8
|
+
bold: "Bold",
|
|
9
|
+
italic: "Italic",
|
|
10
|
+
underline: "Underline",
|
|
11
|
+
link: "Link",
|
|
12
|
+
bulletList: "Bullet list",
|
|
13
|
+
orderedList: "Numbered list",
|
|
14
|
+
alignment: "Text alignment",
|
|
15
|
+
alignLeft: "Align left",
|
|
16
|
+
alignCenter: "Align center",
|
|
17
|
+
alignRight: "Align right",
|
|
18
|
+
alignJustify: "Justify",
|
|
19
|
+
linkPlaceholder: "https://example.com",
|
|
20
|
+
applyLink: "Apply",
|
|
21
|
+
removeLink: "Remove link",
|
|
22
|
+
cancel: "Cancel"
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
defaultLabels
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=labels.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/rich-text-editor/labels.ts"],"sourcesContent":["/** Every string the built-in controls speak or show. Pass the keys you want to change through `labels`. */\nexport interface RichTextEditorLabels {\n toolbar: string\n bubble: string\n heading1: string\n heading2: string\n heading3: string\n heading4: string\n bold: string\n italic: string\n underline: string\n link: string\n bulletList: string\n orderedList: string\n alignment: string\n alignLeft: string\n alignCenter: string\n alignRight: string\n alignJustify: string\n linkPlaceholder: string\n applyLink: string\n removeLink: string\n cancel: string\n}\n\nexport const defaultLabels: RichTextEditorLabels = {\n toolbar: \"Formatting\",\n bubble: \"Selection formatting\",\n heading1: \"Heading 1\",\n heading2: \"Heading 2\",\n heading3: \"Heading 3\",\n heading4: \"Heading 4\",\n bold: \"Bold\",\n italic: \"Italic\",\n underline: \"Underline\",\n link: \"Link\",\n bulletList: \"Bullet list\",\n orderedList: \"Numbered list\",\n alignment: \"Text alignment\",\n alignLeft: \"Align left\",\n alignCenter: \"Align center\",\n alignRight: \"Align right\",\n alignJustify: \"Justify\",\n linkPlaceholder: \"https://example.com\",\n applyLink: \"Apply\",\n removeLink: \"Remove link\",\n cancel: \"Cancel\",\n}\n"],"mappings":"AAyBO,MAAM,gBAAsC;AAAA,EACjD,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,QAAQ;AACV;","names":[]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { TextAlign } from "@tiptap/extension-text-align";
|
|
5
|
+
import { Placeholder } from "@tiptap/extensions";
|
|
6
|
+
import { EditorContent, useEditor } from "@tiptap/react";
|
|
7
|
+
import { StarterKit } from "@tiptap/starter-kit";
|
|
8
|
+
import { useDensity } from "../../../lib/density.mjs";
|
|
9
|
+
import { tv } from "../../../lib/tv.mjs";
|
|
10
|
+
import { ImageLinks } from "./image-links.mjs";
|
|
11
|
+
import { defaultLabels } from "./labels.mjs";
|
|
12
|
+
const richTextEditorVariants = tv({
|
|
13
|
+
slots: {
|
|
14
|
+
root: [
|
|
15
|
+
"flex flex-col overflow-hidden rounded-xl bg-background text-foreground inset-ring-1 inset-ring-input",
|
|
16
|
+
"transition-[box-shadow] duration-fast ease-out",
|
|
17
|
+
"focus-within:inset-ring-focus focus-within:ring-3 focus-within:ring-[color:var(--ring-focus)]"
|
|
18
|
+
],
|
|
19
|
+
content: [
|
|
20
|
+
"text-sm pointer-coarse:text-base text-muted-foreground",
|
|
21
|
+
"[&_.tiptap]:outline-none [&_.tiptap>*+*]:mt-3",
|
|
22
|
+
"[&_.tiptap_h1]:text-3xl [&_.tiptap_h1]:font-semibold [&_.tiptap_h1]:tracking-tight [&_.tiptap_h1]:text-foreground",
|
|
23
|
+
"[&_.tiptap_h2]:text-xl [&_.tiptap_h2]:font-semibold [&_.tiptap_h2]:tracking-tight [&_.tiptap_h2]:text-foreground",
|
|
24
|
+
"[&_.tiptap_h3]:text-lg [&_.tiptap_h3]:font-semibold [&_.tiptap_h3]:text-foreground",
|
|
25
|
+
"[&_.tiptap_h4]:font-sans [&_.tiptap_h4]:text-sm [&_.tiptap_h4]:font-semibold [&_.tiptap_h4]:text-foreground",
|
|
26
|
+
"[&_.tiptap_p]:leading-relaxed",
|
|
27
|
+
"[&_.tiptap_ul]:list-disc [&_.tiptap_ul]:pl-5 [&_.tiptap_ol]:list-decimal [&_.tiptap_ol]:pl-5",
|
|
28
|
+
"[&_.tiptap_li]:my-0.5 [&_.tiptap_li_p]:my-0 [&_.tiptap_li_ul]:mt-1 [&_.tiptap_li_ol]:mt-1",
|
|
29
|
+
"[&_.tiptap_strong]:font-semibold [&_.tiptap_strong]:text-foreground",
|
|
30
|
+
"[&_.tiptap_a]:cursor-pointer [&_.tiptap_a]:text-foreground [&_.tiptap_a]:underline [&_.tiptap_a]:underline-offset-2",
|
|
31
|
+
"[&_.tiptap_blockquote]:border-l-2 [&_.tiptap_blockquote]:border-border [&_.tiptap_blockquote]:pl-4 [&_.tiptap_blockquote]:italic",
|
|
32
|
+
"[&_.tiptap_code]:rounded-sm [&_.tiptap_code]:bg-muted [&_.tiptap_code]:px-1 [&_.tiptap_code]:py-0.5 [&_.tiptap_code]:font-mono [&_.tiptap_code]:text-[0.875em] [&_.tiptap_code]:text-foreground",
|
|
33
|
+
"[&_.tiptap_pre]:overflow-x-auto [&_.tiptap_pre]:rounded-md [&_.tiptap_pre]:bg-muted [&_.tiptap_pre]:px-4 [&_.tiptap_pre]:py-3 [&_.tiptap_pre]:font-mono [&_.tiptap_pre]:text-[0.8125rem] [&_.tiptap_pre]:leading-relaxed [&_.tiptap_pre]:text-foreground",
|
|
34
|
+
"[&_.tiptap_pre_code]:bg-transparent [&_.tiptap_pre_code]:p-0 [&_.tiptap_pre_code]:text-[length:inherit]",
|
|
35
|
+
"[&_.tiptap_hr]:border-border",
|
|
36
|
+
"[&_.tiptap_p.is-editor-empty:first-child]:before:pointer-events-none [&_.tiptap_p.is-editor-empty:first-child]:before:float-left [&_.tiptap_p.is-editor-empty:first-child]:before:h-0",
|
|
37
|
+
"[&_.tiptap_p.is-editor-empty:first-child]:before:text-placeholder [&_.tiptap_p.is-editor-empty:first-child]:before:content-[attr(data-placeholder)]"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const proseMirrorClass = (density) => `min-h-32 outline-none ${density === "comfortable" ? "px-4 py-3" : "px-3 py-2.5"}`;
|
|
42
|
+
const ALL_ALIGNMENTS = ["left", "center", "right", "justify"];
|
|
43
|
+
const RichTextEditorContext = React.createContext(null);
|
|
44
|
+
const RichTextEditorContextProvider = RichTextEditorContext.Provider;
|
|
45
|
+
function useRichTextEditorContext(consumer) {
|
|
46
|
+
const context = React.useContext(RichTextEditorContext);
|
|
47
|
+
if (!context) throw new Error(`\`${consumer}\` must be used within \`RichTextEditor\``);
|
|
48
|
+
return context;
|
|
49
|
+
}
|
|
50
|
+
function useRichTextEditor() {
|
|
51
|
+
return useRichTextEditorContext("useRichTextEditor").editor;
|
|
52
|
+
}
|
|
53
|
+
function RichTextEditor({
|
|
54
|
+
defaultValue = "",
|
|
55
|
+
onChange,
|
|
56
|
+
placeholder = "Write something\u2026",
|
|
57
|
+
editable = true,
|
|
58
|
+
density: densityProp,
|
|
59
|
+
alignment = false,
|
|
60
|
+
labels: labelsProp,
|
|
61
|
+
starterKit,
|
|
62
|
+
extensions = [],
|
|
63
|
+
imageLinks = false,
|
|
64
|
+
className,
|
|
65
|
+
children,
|
|
66
|
+
...props
|
|
67
|
+
}) {
|
|
68
|
+
const density = useDensity(densityProp);
|
|
69
|
+
const onChangeRef = React.useRef(onChange);
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
onChangeRef.current = onChange;
|
|
72
|
+
});
|
|
73
|
+
const alignments = React.useMemo(
|
|
74
|
+
() => alignment === true ? ALL_ALIGNMENTS : alignment || [],
|
|
75
|
+
// The schema is read once, on mount.
|
|
76
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
+
[]
|
|
78
|
+
);
|
|
79
|
+
const [editor, setEditor] = React.useState(null);
|
|
80
|
+
const isClient = React.useSyncExternalStore(subscribeNothing, () => true, () => false);
|
|
81
|
+
const [options] = React.useState(() => ({
|
|
82
|
+
// Render after mount, so the server and the first client render agree.
|
|
83
|
+
immediatelyRender: false,
|
|
84
|
+
extensions: [
|
|
85
|
+
StarterKit.configure({
|
|
86
|
+
heading: { levels: [1, 2, 3, 4] },
|
|
87
|
+
link: { openOnClick: false, autolink: true, defaultProtocol: "https" },
|
|
88
|
+
...starterKit
|
|
89
|
+
}),
|
|
90
|
+
Placeholder.configure({ placeholder }),
|
|
91
|
+
...alignments.length ? [TextAlign.configure({ types: ["heading", "paragraph"], alignments })] : [],
|
|
92
|
+
...imageLinks ? [ImageLinks] : [],
|
|
93
|
+
...extensions
|
|
94
|
+
],
|
|
95
|
+
content: defaultValue,
|
|
96
|
+
editable,
|
|
97
|
+
editorProps: { attributes: { class: proseMirrorClass(density) } },
|
|
98
|
+
onUpdate: ({ editor: editor2 }) => onChangeRef.current?.(editor2.getHTML())
|
|
99
|
+
}));
|
|
100
|
+
React.useEffect(() => {
|
|
101
|
+
if (editor && editor.isEditable !== editable) editor.setEditable(editable);
|
|
102
|
+
}, [editor, editable]);
|
|
103
|
+
React.useEffect(() => {
|
|
104
|
+
editor?.setOptions({ editorProps: { attributes: { class: proseMirrorClass(density) } } });
|
|
105
|
+
}, [editor, density]);
|
|
106
|
+
const labels = React.useMemo(() => ({ ...defaultLabels, ...labelsProp }), [labelsProp]);
|
|
107
|
+
const value = React.useMemo(() => ({ editor, labels, alignments, density }), [editor, labels, alignments, density]);
|
|
108
|
+
return /* @__PURE__ */ jsxs(RichTextEditorContext.Provider, { value, children: [
|
|
109
|
+
isClient && /* @__PURE__ */ jsx(EditorHost, { options, onEditor: setEditor }),
|
|
110
|
+
/* @__PURE__ */ jsx("div", { "data-slot": "rich-text-editor", className: richTextEditorVariants().root({ className }), ...props, children })
|
|
111
|
+
] });
|
|
112
|
+
}
|
|
113
|
+
const subscribeNothing = () => () => {
|
|
114
|
+
};
|
|
115
|
+
function EditorHost({ options, onEditor }) {
|
|
116
|
+
const editor = useEditor(options);
|
|
117
|
+
React.useEffect(() => {
|
|
118
|
+
onEditor(editor);
|
|
119
|
+
return () => onEditor(null);
|
|
120
|
+
}, [editor, onEditor]);
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
function RichTextEditorContent({
|
|
124
|
+
className,
|
|
125
|
+
...props
|
|
126
|
+
}) {
|
|
127
|
+
const { editor, density } = useRichTextEditorContext("RichTextEditorContent");
|
|
128
|
+
if (!editor) {
|
|
129
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "rich-text-editor-content", className: richTextEditorVariants().content({ className }), children: /* @__PURE__ */ jsx("div", { "aria-hidden": true, className: proseMirrorClass(density) }) });
|
|
130
|
+
}
|
|
131
|
+
return /* @__PURE__ */ jsx(
|
|
132
|
+
EditorContent,
|
|
133
|
+
{
|
|
134
|
+
editor,
|
|
135
|
+
"data-slot": "rich-text-editor-content",
|
|
136
|
+
className: richTextEditorVariants().content({ className }),
|
|
137
|
+
...props
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
RichTextEditor,
|
|
143
|
+
RichTextEditorContent,
|
|
144
|
+
RichTextEditorContextProvider,
|
|
145
|
+
richTextEditorVariants,
|
|
146
|
+
useRichTextEditor,
|
|
147
|
+
useRichTextEditorContext
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=rich-text-editor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/rich-text-editor/rich-text-editor.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport type { Editor, Extensions } from \"@tiptap/core\"\r\nimport { TextAlign } from \"@tiptap/extension-text-align\"\r\nimport { Placeholder } from \"@tiptap/extensions\"\r\nimport { EditorContent, useEditor, type UseEditorOptions } from \"@tiptap/react\"\r\nimport { StarterKit, type StarterKitOptions } from \"@tiptap/starter-kit\"\r\n\r\nimport { useDensity, type Density } from \"../../../lib/density.mjs\"\r\nimport { tv } from \"../../../lib/tv.mjs\"\r\n\r\nimport { ImageLinks } from \"./image-links.mjs\"\r\nimport { defaultLabels, type RichTextEditorLabels } from \"./labels.mjs\"\r\n\r\n/*\r\n * A WYSIWYG field for formatted prose. Tiptap (ProseMirror) owns the document model, selection,\r\n * undo and paste, which no Radix primitive provides; every visible part is still an Atoms recipe.\r\n */\r\nexport const richTextEditorVariants = tv({\r\n slots: {\r\n root: [\r\n \"flex flex-col overflow-hidden rounded-xl bg-background text-foreground inset-ring-1 inset-ring-input\",\r\n \"transition-[box-shadow] duration-fast ease-out\",\r\n \"focus-within:inset-ring-focus focus-within:ring-3 focus-within:ring-[color:var(--ring-focus)]\",\r\n ],\r\n content: [\r\n \"text-sm pointer-coarse:text-base text-muted-foreground\",\r\n \"[&_.tiptap]:outline-none [&_.tiptap>*+*]:mt-3\",\r\n \"[&_.tiptap_h1]:text-3xl [&_.tiptap_h1]:font-semibold [&_.tiptap_h1]:tracking-tight [&_.tiptap_h1]:text-foreground\",\r\n \"[&_.tiptap_h2]:text-xl [&_.tiptap_h2]:font-semibold [&_.tiptap_h2]:tracking-tight [&_.tiptap_h2]:text-foreground\",\r\n \"[&_.tiptap_h3]:text-lg [&_.tiptap_h3]:font-semibold [&_.tiptap_h3]:text-foreground\",\r\n \"[&_.tiptap_h4]:font-sans [&_.tiptap_h4]:text-sm [&_.tiptap_h4]:font-semibold [&_.tiptap_h4]:text-foreground\",\r\n \"[&_.tiptap_p]:leading-relaxed\",\r\n \"[&_.tiptap_ul]:list-disc [&_.tiptap_ul]:pl-5 [&_.tiptap_ol]:list-decimal [&_.tiptap_ol]:pl-5\",\r\n \"[&_.tiptap_li]:my-0.5 [&_.tiptap_li_p]:my-0 [&_.tiptap_li_ul]:mt-1 [&_.tiptap_li_ol]:mt-1\",\r\n \"[&_.tiptap_strong]:font-semibold [&_.tiptap_strong]:text-foreground\",\r\n \"[&_.tiptap_a]:cursor-pointer [&_.tiptap_a]:text-foreground [&_.tiptap_a]:underline [&_.tiptap_a]:underline-offset-2\",\r\n \"[&_.tiptap_blockquote]:border-l-2 [&_.tiptap_blockquote]:border-border [&_.tiptap_blockquote]:pl-4 [&_.tiptap_blockquote]:italic\",\r\n \"[&_.tiptap_code]:rounded-sm [&_.tiptap_code]:bg-muted [&_.tiptap_code]:px-1 [&_.tiptap_code]:py-0.5 [&_.tiptap_code]:font-mono [&_.tiptap_code]:text-[0.875em] [&_.tiptap_code]:text-foreground\",\r\n \"[&_.tiptap_pre]:overflow-x-auto [&_.tiptap_pre]:rounded-md [&_.tiptap_pre]:bg-muted [&_.tiptap_pre]:px-4 [&_.tiptap_pre]:py-3 [&_.tiptap_pre]:font-mono [&_.tiptap_pre]:text-[0.8125rem] [&_.tiptap_pre]:leading-relaxed [&_.tiptap_pre]:text-foreground\",\r\n \"[&_.tiptap_pre_code]:bg-transparent [&_.tiptap_pre_code]:p-0 [&_.tiptap_pre_code]:text-[length:inherit]\",\r\n \"[&_.tiptap_hr]:border-border\",\r\n \"[&_.tiptap_p.is-editor-empty:first-child]:before:pointer-events-none [&_.tiptap_p.is-editor-empty:first-child]:before:float-left [&_.tiptap_p.is-editor-empty:first-child]:before:h-0\",\r\n \"[&_.tiptap_p.is-editor-empty:first-child]:before:text-placeholder [&_.tiptap_p.is-editor-empty:first-child]:before:content-[attr(data-placeholder)]\",\r\n ],\r\n },\r\n})\r\n\r\n/** The ProseMirror node's own classes: its minimum height and the density's padding. */\r\nconst proseMirrorClass = (density: Density) =>\r\n `min-h-32 outline-none ${density === \"comfortable\" ? \"px-4 py-3\" : \"px-3 py-2.5\"}`\r\n\r\nexport type RichTextEditorAlignment = \"left\" | \"center\" | \"right\" | \"justify\"\r\nconst ALL_ALIGNMENTS: RichTextEditorAlignment[] = [\"left\", \"center\", \"right\", \"justify\"]\r\n\r\ninterface RichTextEditorContextValue {\r\n editor: Editor | null\r\n labels: RichTextEditorLabels\r\n /** The alignments offered, or empty while alignment is off. */\r\n alignments: RichTextEditorAlignment[]\r\n density: Density\r\n}\r\n\r\nconst RichTextEditorContext = React.createContext<RichTextEditorContextValue | null>(null)\r\n\r\n/** Lets another editor surface (the Document Editor) reuse the toolbar and bubble parts. */\r\nexport const RichTextEditorContextProvider = RichTextEditorContext.Provider\r\nexport type { RichTextEditorContextValue }\r\n\r\nexport function useRichTextEditorContext(consumer: string) {\r\n const context = React.useContext(RichTextEditorContext)\r\n if (!context) throw new Error(`\\`${consumer}\\` must be used within \\`RichTextEditor\\``)\r\n return context\r\n}\r\n\r\n/**\r\n * The live Tiptap Editor from the nearest RichTextEditor, for custom toolbars, word counts or\r\n * imperative reads and writes. Null on the first client render (the editor mounts after it).\r\n */\r\nexport function useRichTextEditor(): Editor | null {\r\n return useRichTextEditorContext(\"useRichTextEditor\").editor\r\n}\r\n\r\nexport interface RichTextEditorProps extends Omit<React.ComponentProps<\"div\">, \"onChange\" | \"defaultValue\"> {\r\n /** Initial HTML content. Uncontrolled: the editor owns its document from here on. */\r\n defaultValue?: string\r\n /** Called with the serialized HTML on every edit. */\r\n onChange?: (html: string) => void\r\n /** Ghost text shown while the document is empty. */\r\n placeholder?: string\r\n /** Set false for a read-only render; toggles without remounting. */\r\n editable?: boolean\r\n /** Pads the writing area (compact 12×10px, comfortable 16×12px). Falls back to DensityProvider. */\r\n density?: Density\r\n /** Lets paragraphs and headings be aligned: true for all four, or a list. Read on mount. */\r\n alignment?: boolean | RichTextEditorAlignment[]\r\n /** Translates or rewords the built-in controls' strings. */\r\n labels?: Partial<RichTextEditorLabels>\r\n /** Reconfigures the built-in StarterKit key by key; false drops an extension. Read on mount. */\r\n starterKit?: Partial<StarterKitOptions>\r\n /** More Tiptap extensions, registered after the built-in ones. Read on mount. */\r\n extensions?: Extensions\r\n /** Shows the picture under any block that links to an image file. Display only. Read on mount. */\r\n imageLinks?: boolean\r\n}\r\n\r\nexport function RichTextEditor({\r\n defaultValue = \"\",\r\n onChange,\r\n placeholder = \"Write something…\",\r\n editable = true,\r\n density: densityProp,\r\n alignment = false,\r\n labels: labelsProp,\r\n starterKit,\r\n extensions = [],\r\n imageLinks = false,\r\n className,\r\n children,\r\n ...props\r\n}: RichTextEditorProps) {\r\n const density = useDensity(densityProp)\r\n const onChangeRef = React.useRef(onChange)\r\n React.useEffect(() => {\r\n onChangeRef.current = onChange\r\n })\r\n\r\n const alignments = React.useMemo<RichTextEditorAlignment[]>(\r\n () => (alignment === true ? ALL_ALIGNMENTS : alignment || []),\r\n // The schema is read once, on mount.\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n [],\r\n )\r\n\r\n const [editor, setEditor] = React.useState<Editor | null>(null)\r\n const isClient = React.useSyncExternalStore(subscribeNothing, () => true, () => false)\r\n\r\n // Read once, when the editor mounts (like the rest of its schema).\r\n const [options] = React.useState<UseEditorOptions>(() => ({\r\n // Render after mount, so the server and the first client render agree.\r\n immediatelyRender: false,\r\n extensions: [\r\n StarterKit.configure({\r\n heading: { levels: [1, 2, 3, 4] },\r\n link: { openOnClick: false, autolink: true, defaultProtocol: \"https\" },\r\n ...starterKit,\r\n }),\r\n Placeholder.configure({ placeholder }),\r\n ...(alignments.length ? [TextAlign.configure({ types: [\"heading\", \"paragraph\"], alignments })] : []),\r\n ...(imageLinks ? [ImageLinks] : []),\r\n ...extensions,\r\n ],\r\n content: defaultValue,\r\n editable,\r\n editorProps: { attributes: { class: proseMirrorClass(density) } },\r\n onUpdate: ({ editor }) => onChangeRef.current?.(editor.getHTML()),\r\n }))\r\n\r\n React.useEffect(() => {\r\n if (editor && editor.isEditable !== editable) editor.setEditable(editable)\r\n }, [editor, editable])\r\n\r\n React.useEffect(() => {\r\n editor?.setOptions({ editorProps: { attributes: { class: proseMirrorClass(density) } } })\r\n }, [editor, density])\r\n\r\n const labels = React.useMemo(() => ({ ...defaultLabels, ...labelsProp }), [labelsProp])\r\n const value = React.useMemo(() => ({ editor, labels, alignments, density }), [editor, labels, alignments, density])\r\n\r\n return (\r\n <RichTextEditorContext.Provider value={value}>\r\n {/* The editor is created on the client only: Tiptap reads randomness and the DOM as it starts. */}\r\n {isClient && <EditorHost options={options} onEditor={setEditor} />}\r\n <div data-slot=\"rich-text-editor\" className={richTextEditorVariants().root({ className })} {...props}>\r\n {children}\r\n </div>\r\n </RichTextEditorContext.Provider>\r\n )\r\n}\r\n\r\nconst subscribeNothing = () => () => {}\r\n\r\n/** Creates the Tiptap editor and hands it to the root, which shares it through context. */\r\nfunction EditorHost({ options, onEditor }: { options: UseEditorOptions; onEditor: (editor: Editor | null) => void }) {\r\n const editor = useEditor(options)\r\n React.useEffect(() => {\r\n onEditor(editor)\r\n return () => onEditor(null)\r\n }, [editor, onEditor])\r\n return null\r\n}\r\n\r\n/** The writing area: Tiptap's EditorContent with the Atoms prose styling. */\r\nexport function RichTextEditorContent({\r\n className,\r\n ...props\r\n}: Omit<React.ComponentProps<typeof EditorContent>, \"editor\">) {\r\n const { editor, density } = useRichTextEditorContext(\"RichTextEditorContent\")\r\n // Until the editor exists (always, on the server), hold its place with a same-sized box:\r\n // Tiptap's EditorContent can't render before there is an editor to mount.\r\n if (!editor) {\r\n return (\r\n <div data-slot=\"rich-text-editor-content\" className={richTextEditorVariants().content({ className })}>\r\n <div aria-hidden className={proseMirrorClass(density)} />\r\n </div>\r\n )\r\n }\r\n return (\r\n <EditorContent\r\n editor={editor}\r\n data-slot=\"rich-text-editor-content\"\r\n className={richTextEditorVariants().content({ className })}\r\n {...props}\r\n />\r\n )\r\n}\r\n"],"mappings":";AA2KI,SAEe,KAFf;AAzKJ,YAAY,WAAW;AAEvB,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,eAAe,iBAAwC;AAChE,SAAS,kBAA0C;AAEnD,SAAS,kBAAgC;AACzC,SAAS,UAAU;AAEnB,SAAS,kBAAkB;AAC3B,SAAS,qBAAgD;AAMlD,MAAM,yBAAyB,GAAG;AAAA,EACvC,OAAO;AAAA,IACL,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;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