@usefragments/ui 1.0.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 +21 -0
- package/README.md +318 -0
- package/dist/assets/fragments-logo.cjs +32 -0
- package/dist/assets/fragments-logo.d.ts +13 -0
- package/dist/assets/fragments-logo.d.ts.map +1 -0
- package/dist/assets/fragments-logo.js +32 -0
- package/dist/assets/ui.css +12290 -0
- package/dist/blocks/AccountSettings.block.d.ts +3 -0
- package/dist/blocks/AccountSettings.block.d.ts.map +1 -0
- package/dist/blocks/ActivityFeed.block.d.ts +3 -0
- package/dist/blocks/ActivityFeed.block.d.ts.map +1 -0
- package/dist/blocks/ActivityFeedSkeleton.block.d.ts +3 -0
- package/dist/blocks/ActivityFeedSkeleton.block.d.ts.map +1 -0
- package/dist/blocks/BlogEditor.block.d.ts +3 -0
- package/dist/blocks/BlogEditor.block.d.ts.map +1 -0
- package/dist/blocks/ChatInterface.block.d.ts +3 -0
- package/dist/blocks/ChatInterface.block.d.ts.map +1 -0
- package/dist/blocks/ChatMessages.block.d.ts +3 -0
- package/dist/blocks/ChatMessages.block.d.ts.map +1 -0
- package/dist/blocks/CheckoutForm.block.d.ts +3 -0
- package/dist/blocks/CheckoutForm.block.d.ts.map +1 -0
- package/dist/blocks/CommandPalette.block.d.ts +3 -0
- package/dist/blocks/CommandPalette.block.d.ts.map +1 -0
- package/dist/blocks/ContactForm.block.d.ts +3 -0
- package/dist/blocks/ContactForm.block.d.ts.map +1 -0
- package/dist/blocks/DashboardLayout.block.d.ts +3 -0
- package/dist/blocks/DashboardLayout.block.d.ts.map +1 -0
- package/dist/blocks/DashboardPage.block.d.ts +3 -0
- package/dist/blocks/DashboardPage.block.d.ts.map +1 -0
- package/dist/blocks/DashboardSkeleton.block.d.ts +3 -0
- package/dist/blocks/DashboardSkeleton.block.d.ts.map +1 -0
- package/dist/blocks/DataTable.block.d.ts +3 -0
- package/dist/blocks/DataTable.block.d.ts.map +1 -0
- package/dist/blocks/EmptyState.block.d.ts +3 -0
- package/dist/blocks/EmptyState.block.d.ts.map +1 -0
- package/dist/blocks/FAQSection.block.d.ts +3 -0
- package/dist/blocks/FAQSection.block.d.ts.map +1 -0
- package/dist/blocks/FeatureGrid.block.d.ts +3 -0
- package/dist/blocks/FeatureGrid.block.d.ts.map +1 -0
- package/dist/blocks/HeroSection.block.d.ts +3 -0
- package/dist/blocks/HeroSection.block.d.ts.map +1 -0
- package/dist/blocks/LoginForm.block.d.ts +3 -0
- package/dist/blocks/LoginForm.block.d.ts.map +1 -0
- package/dist/blocks/NavigationHeader.block.d.ts +3 -0
- package/dist/blocks/NavigationHeader.block.d.ts.map +1 -0
- package/dist/blocks/PaginatedTable.block.d.ts +3 -0
- package/dist/blocks/PaginatedTable.block.d.ts.map +1 -0
- package/dist/blocks/PricingComparison.block.d.ts +3 -0
- package/dist/blocks/PricingComparison.block.d.ts.map +1 -0
- package/dist/blocks/ProductCard.block.d.ts +3 -0
- package/dist/blocks/ProductCard.block.d.ts.map +1 -0
- package/dist/blocks/RegistrationForm.block.d.ts +3 -0
- package/dist/blocks/RegistrationForm.block.d.ts.map +1 -0
- package/dist/blocks/SettingsDrawer.block.d.ts +3 -0
- package/dist/blocks/SettingsDrawer.block.d.ts.map +1 -0
- package/dist/blocks/SettingsPanel.block.d.ts +3 -0
- package/dist/blocks/SettingsPanel.block.d.ts.map +1 -0
- package/dist/blocks/ShoppingCart.block.d.ts +3 -0
- package/dist/blocks/ShoppingCart.block.d.ts.map +1 -0
- package/dist/blocks/StatsCard.block.d.ts +3 -0
- package/dist/blocks/StatsCard.block.d.ts.map +1 -0
- package/dist/blocks/StatsCardSkeleton.block.d.ts +3 -0
- package/dist/blocks/StatsCardSkeleton.block.d.ts.map +1 -0
- package/dist/blocks/TableSkeleton.block.d.ts +3 -0
- package/dist/blocks/TableSkeleton.block.d.ts.map +1 -0
- package/dist/blocks/ThinkingStates.block.d.ts +3 -0
- package/dist/blocks/ThinkingStates.block.d.ts.map +1 -0
- package/dist/blocks/components/ActivityFeed.d.ts +25 -0
- package/dist/blocks/components/ActivityFeed.d.ts.map +1 -0
- package/dist/blocks/components/DashboardLayout.d.ts +13 -0
- package/dist/blocks/components/DashboardLayout.d.ts.map +1 -0
- package/dist/blocks/components/LoginForm.d.ts +16 -0
- package/dist/blocks/components/LoginForm.d.ts.map +1 -0
- package/dist/blocks/components/StatsCard.d.ts +17 -0
- package/dist/blocks/components/StatsCard.d.ts.map +1 -0
- package/dist/blocks/components/index.d.ts +9 -0
- package/dist/blocks/components/index.d.ts.map +1 -0
- package/dist/chart.cjs +236 -0
- package/dist/chart.js +219 -0
- package/dist/codeblock.cjs +599 -0
- package/dist/codeblock.js +561 -0
- package/dist/colorpicker.cjs +149 -0
- package/dist/colorpicker.js +132 -0
- package/dist/components/Accordion/Accordion.module.scss.cjs +29 -0
- package/dist/components/Accordion/Accordion.module.scss.js +29 -0
- package/dist/components/Accordion/index.cjs +201 -0
- package/dist/components/Accordion/index.d.ts +62 -0
- package/dist/components/Accordion/index.d.ts.map +1 -0
- package/dist/components/Accordion/index.js +184 -0
- package/dist/components/Alert/Alert.module.scss.cjs +41 -0
- package/dist/components/Alert/Alert.module.scss.js +41 -0
- package/dist/components/Alert/index.cjs +151 -0
- package/dist/components/Alert/index.d.ts +61 -0
- package/dist/components/Alert/index.d.ts.map +1 -0
- package/dist/components/Alert/index.js +134 -0
- package/dist/components/AppShell/AppShell.module.scss.cjs +35 -0
- package/dist/components/AppShell/AppShell.module.scss.js +35 -0
- package/dist/components/AppShell/index.cjs +285 -0
- package/dist/components/AppShell/index.d.ts +133 -0
- package/dist/components/AppShell/index.d.ts.map +1 -0
- package/dist/components/AppShell/index.js +268 -0
- package/dist/components/Avatar/Avatar.module.scss.cjs +44 -0
- package/dist/components/Avatar/Avatar.module.scss.js +44 -0
- package/dist/components/Avatar/index.cjs +238 -0
- package/dist/components/Avatar/index.d.ts +42 -0
- package/dist/components/Avatar/index.d.ts.map +1 -0
- package/dist/components/Avatar/index.js +221 -0
- package/dist/components/Badge/Badge.module.scss.cjs +51 -0
- package/dist/components/Badge/Badge.module.scss.js +51 -0
- package/dist/components/Badge/index.cjs +78 -0
- package/dist/components/Badge/index.d.ts +41 -0
- package/dist/components/Badge/index.d.ts.map +1 -0
- package/dist/components/Badge/index.js +61 -0
- package/dist/components/BentoGrid/BentoGrid.module.scss.cjs +47 -0
- package/dist/components/BentoGrid/BentoGrid.module.scss.js +47 -0
- package/dist/components/BentoGrid/index.cjs +87 -0
- package/dist/components/BentoGrid/index.d.ts +43 -0
- package/dist/components/BentoGrid/index.d.ts.map +1 -0
- package/dist/components/BentoGrid/index.js +70 -0
- package/dist/components/Box/Box.module.scss.cjs +315 -0
- package/dist/components/Box/Box.module.scss.js +315 -0
- package/dist/components/Box/index.cjs +104 -0
- package/dist/components/Box/index.d.ts +62 -0
- package/dist/components/Box/index.d.ts.map +1 -0
- package/dist/components/Box/index.js +87 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.cjs +29 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.js +29 -0
- package/dist/components/Breadcrumbs/index.cjs +118 -0
- package/dist/components/Breadcrumbs/index.d.ts +32 -0
- package/dist/components/Breadcrumbs/index.d.ts.map +1 -0
- package/dist/components/Breadcrumbs/index.js +101 -0
- package/dist/components/Button/Button.module.scss.cjs +44 -0
- package/dist/components/Button/Button.module.scss.js +44 -0
- package/dist/components/Button/index.cjs +140 -0
- package/dist/components/Button/index.d.ts +39 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/Button/index.js +123 -0
- package/dist/components/ButtonGroup/ButtonGroup.module.scss.cjs +38 -0
- package/dist/components/ButtonGroup/ButtonGroup.module.scss.js +38 -0
- package/dist/components/ButtonGroup/index.cjs +36 -0
- package/dist/components/ButtonGroup/index.d.ts +11 -0
- package/dist/components/ButtonGroup/index.d.ts.map +1 -0
- package/dist/components/ButtonGroup/index.js +19 -0
- package/dist/components/Card/Card.module.scss.cjs +54 -0
- package/dist/components/Card/Card.module.scss.js +54 -0
- package/dist/components/Card/index.cjs +123 -0
- package/dist/components/Card/index.d.ts +62 -0
- package/dist/components/Card/index.d.ts.map +1 -0
- package/dist/components/Card/index.js +106 -0
- package/dist/components/Chart/Chart.module.scss.cjs +50 -0
- package/dist/components/Chart/Chart.module.scss.js +50 -0
- package/dist/components/Chart/index.d.ts +65 -0
- package/dist/components/Chart/index.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.module.scss.cjs +38 -0
- package/dist/components/Checkbox/Checkbox.module.scss.js +38 -0
- package/dist/components/Checkbox/index.cjs +179 -0
- package/dist/components/Checkbox/index.d.ts +68 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -0
- package/dist/components/Checkbox/index.js +162 -0
- package/dist/components/Chip/Chip.module.scss.cjs +50 -0
- package/dist/components/Chip/Chip.module.scss.js +50 -0
- package/dist/components/Chip/index.cjs +138 -0
- package/dist/components/Chip/index.d.ts +38 -0
- package/dist/components/Chip/index.d.ts.map +1 -0
- package/dist/components/Chip/index.js +121 -0
- package/dist/components/Cloud/DashboardLayoutPrototypes.shared.d.ts +33 -0
- package/dist/components/Cloud/DashboardLayoutPrototypes.shared.d.ts.map +1 -0
- package/dist/components/Cloud/DashboardLayoutPrototypes.shell.d.ts +11 -0
- package/dist/components/Cloud/DashboardLayoutPrototypes.shell.d.ts.map +1 -0
- package/dist/components/Cloud/PullRequestsPrototypes.content.d.ts +5 -0
- package/dist/components/Cloud/PullRequestsPrototypes.content.d.ts.map +1 -0
- package/dist/components/Cloud/PullRequestsPrototypes.detail-panels.d.ts +4 -0
- package/dist/components/Cloud/PullRequestsPrototypes.detail-panels.d.ts.map +1 -0
- package/dist/components/Cloud/PullRequestsPrototypes.detail.d.ts +3 -0
- package/dist/components/Cloud/PullRequestsPrototypes.detail.d.ts.map +1 -0
- package/dist/components/Cloud/PullRequestsPrototypes.id-data.d.ts +86 -0
- package/dist/components/Cloud/PullRequestsPrototypes.id-data.d.ts.map +1 -0
- package/dist/components/Cloud/PullRequestsPrototypes.id-page.d.ts +2 -0
- package/dist/components/Cloud/PullRequestsPrototypes.id-page.d.ts.map +1 -0
- package/dist/components/CodeBlock/CodeBlock.module.scss.cjs +68 -0
- package/dist/components/CodeBlock/CodeBlock.module.scss.js +68 -0
- package/dist/components/CodeBlock/index.d.ts +95 -0
- package/dist/components/CodeBlock/index.d.ts.map +1 -0
- package/dist/components/Collapsible/Collapsible.module.scss.cjs +35 -0
- package/dist/components/Collapsible/Collapsible.module.scss.js +35 -0
- package/dist/components/Collapsible/index.cjs +186 -0
- package/dist/components/Collapsible/index.d.ts +45 -0
- package/dist/components/Collapsible/index.d.ts.map +1 -0
- package/dist/components/Collapsible/index.js +186 -0
- package/dist/components/ColorPicker/ColorPicker.module.scss.cjs +47 -0
- package/dist/components/ColorPicker/ColorPicker.module.scss.js +47 -0
- package/dist/components/ColorPicker/index.d.ts +29 -0
- package/dist/components/ColorPicker/index.d.ts.map +1 -0
- package/dist/components/Combobox/Combobox.module.scss.cjs +74 -0
- package/dist/components/Combobox/Combobox.module.scss.js +74 -0
- package/dist/components/Combobox/index.cjs +402 -0
- package/dist/components/Combobox/index.d.ts +99 -0
- package/dist/components/Combobox/index.d.ts.map +1 -0
- package/dist/components/Combobox/index.js +385 -0
- package/dist/components/Command/Command.module.scss.cjs +38 -0
- package/dist/components/Command/Command.module.scss.js +38 -0
- package/dist/components/Command/index.cjs +415 -0
- package/dist/components/Command/index.d.ts +58 -0
- package/dist/components/Command/index.d.ts.map +1 -0
- package/dist/components/Command/index.js +398 -0
- package/dist/components/ComponentDefaults/index.cjs +51 -0
- package/dist/components/ComponentDefaults/index.d.ts +15 -0
- package/dist/components/ComponentDefaults/index.d.ts.map +1 -0
- package/dist/components/ComponentDefaults/index.js +34 -0
- package/dist/components/ConversationList/ConversationList.module.scss.cjs +35 -0
- package/dist/components/ConversationList/ConversationList.module.scss.js +35 -0
- package/dist/components/ConversationList/index.cjs +168 -0
- package/dist/components/ConversationList/index.d.ts +43 -0
- package/dist/components/ConversationList/index.d.ts.map +1 -0
- package/dist/components/ConversationList/index.js +151 -0
- package/dist/components/DataTable/DataTable.icons.cjs +69 -0
- package/dist/components/DataTable/DataTable.icons.d.ts +7 -0
- package/dist/components/DataTable/DataTable.icons.d.ts.map +1 -0
- package/dist/components/DataTable/DataTable.icons.js +69 -0
- package/dist/components/DataTable/DataTable.module.scss.cjs +107 -0
- package/dist/components/DataTable/DataTable.module.scss.js +107 -0
- package/dist/components/DataTable/DataTable.support.cjs +64 -0
- package/dist/components/DataTable/DataTable.support.d.ts +10 -0
- package/dist/components/DataTable/DataTable.support.d.ts.map +1 -0
- package/dist/components/DataTable/DataTable.support.js +47 -0
- package/dist/components/DataTable/DataTable.virtual.cjs +103 -0
- package/dist/components/DataTable/DataTable.virtual.d.ts +92 -0
- package/dist/components/DataTable/DataTable.virtual.d.ts.map +1 -0
- package/dist/components/DataTable/DataTable.virtual.js +86 -0
- package/dist/components/DataTable/index.d.ts +100 -0
- package/dist/components/DataTable/index.d.ts.map +1 -0
- package/dist/components/DatePicker/DatePicker.module.scss.cjs +104 -0
- package/dist/components/DatePicker/DatePicker.module.scss.js +104 -0
- package/dist/components/DatePicker/index.d.ts +86 -0
- package/dist/components/DatePicker/index.d.ts.map +1 -0
- package/dist/components/Dialog/Dialog.module.scss.cjs +47 -0
- package/dist/components/Dialog/Dialog.module.scss.js +47 -0
- package/dist/components/Dialog/index.cjs +135 -0
- package/dist/components/Dialog/index.d.ts +81 -0
- package/dist/components/Dialog/index.d.ts.map +1 -0
- package/dist/components/Dialog/index.js +135 -0
- package/dist/components/Drawer/Drawer.module.scss.cjs +71 -0
- package/dist/components/Drawer/Drawer.module.scss.js +71 -0
- package/dist/components/Drawer/index.cjs +194 -0
- package/dist/components/Drawer/index.d.ts +95 -0
- package/dist/components/Drawer/index.d.ts.map +1 -0
- package/dist/components/Drawer/index.js +177 -0
- package/dist/components/Editor/Editor.module.scss.cjs +56 -0
- package/dist/components/Editor/Editor.module.scss.js +56 -0
- package/dist/components/Editor/index.d.ts +120 -0
- package/dist/components/Editor/index.d.ts.map +1 -0
- package/dist/components/EmptyState/EmptyState.module.scss.cjs +29 -0
- package/dist/components/EmptyState/EmptyState.module.scss.js +29 -0
- package/dist/components/EmptyState/index.cjs +65 -0
- package/dist/components/EmptyState/index.d.ts +34 -0
- package/dist/components/EmptyState/index.d.ts.map +1 -0
- package/dist/components/EmptyState/index.js +48 -0
- package/dist/components/Field/Field.module.scss.cjs +17 -0
- package/dist/components/Field/Field.module.scss.js +17 -0
- package/dist/components/Field/index.cjs +71 -0
- package/dist/components/Field/index.d.ts +54 -0
- package/dist/components/Field/index.d.ts.map +1 -0
- package/dist/components/Field/index.js +71 -0
- package/dist/components/Fieldset/Fieldset.module.scss.cjs +14 -0
- package/dist/components/Fieldset/Fieldset.module.scss.js +14 -0
- package/dist/components/Fieldset/index.cjs +25 -0
- package/dist/components/Fieldset/index.d.ts +20 -0
- package/dist/components/Fieldset/index.d.ts.map +1 -0
- package/dist/components/Fieldset/index.js +25 -0
- package/dist/components/Form/Form.module.scss.cjs +8 -0
- package/dist/components/Form/Form.module.scss.js +8 -0
- package/dist/components/Form/index.cjs +33 -0
- package/dist/components/Form/index.d.ts +17 -0
- package/dist/components/Form/index.d.ts.map +1 -0
- package/dist/components/Form/index.js +33 -0
- package/dist/components/Grid/Grid.module.scss.cjs +185 -0
- package/dist/components/Grid/Grid.module.scss.js +185 -0
- package/dist/components/Grid/index.cjs +120 -0
- package/dist/components/Grid/index.d.ts +71 -0
- package/dist/components/Grid/index.d.ts.map +1 -0
- package/dist/components/Grid/index.js +103 -0
- package/dist/components/Header/Header.module.scss.cjs +89 -0
- package/dist/components/Header/Header.module.scss.js +89 -0
- package/dist/components/Header/index.cjs +378 -0
- package/dist/components/Header/index.d.ts +155 -0
- package/dist/components/Header/index.d.ts.map +1 -0
- package/dist/components/Header/index.js +361 -0
- package/dist/components/Icon/Icon.module.scss.cjs +29 -0
- package/dist/components/Icon/Icon.module.scss.js +29 -0
- package/dist/components/Icon/index.cjs +75 -0
- package/dist/components/Icon/index.d.ts +37 -0
- package/dist/components/Icon/index.d.ts.map +1 -0
- package/dist/components/Icon/index.js +58 -0
- package/dist/components/IconButton/IconButton.module.scss.cjs +29 -0
- package/dist/components/IconButton/IconButton.module.scss.js +29 -0
- package/dist/components/IconButton/index.cjs +66 -0
- package/dist/components/IconButton/index.d.ts +38 -0
- package/dist/components/IconButton/index.d.ts.map +1 -0
- package/dist/components/IconButton/index.js +49 -0
- package/dist/components/Image/Image.module.scss.cjs +62 -0
- package/dist/components/Image/Image.module.scss.js +62 -0
- package/dist/components/Image/index.cjs +92 -0
- package/dist/components/Image/index.d.ts +33 -0
- package/dist/components/Image/index.d.ts.map +1 -0
- package/dist/components/Image/index.js +75 -0
- package/dist/components/Input/Input.module.scss.cjs +62 -0
- package/dist/components/Input/Input.module.scss.js +62 -0
- package/dist/components/Input/index.cjs +209 -0
- package/dist/components/Input/index.d.ts +64 -0
- package/dist/components/Input/index.d.ts.map +1 -0
- package/dist/components/Input/index.js +192 -0
- package/dist/components/Link/Link.module.scss.cjs +27 -0
- package/dist/components/Link/Link.module.scss.js +27 -0
- package/dist/components/Link/index.cjs +80 -0
- package/dist/components/Link/index.d.ts +23 -0
- package/dist/components/Link/index.d.ts.map +1 -0
- package/dist/components/Link/index.js +63 -0
- package/dist/components/List/List.module.scss.cjs +52 -0
- package/dist/components/List/List.module.scss.js +52 -0
- package/dist/components/List/index.cjs +65 -0
- package/dist/components/List/index.d.ts +26 -0
- package/dist/components/List/index.d.ts.map +1 -0
- package/dist/components/List/index.js +48 -0
- package/dist/components/Listbox/Listbox.module.scss.cjs +29 -0
- package/dist/components/Listbox/Listbox.module.scss.js +29 -0
- package/dist/components/Listbox/index.cjs +246 -0
- package/dist/components/Listbox/index.d.ts +32 -0
- package/dist/components/Listbox/index.d.ts.map +1 -0
- package/dist/components/Listbox/index.js +229 -0
- package/dist/components/Loading/Loading.module.scss.cjs +85 -0
- package/dist/components/Loading/Loading.module.scss.js +85 -0
- package/dist/components/Loading/index.cjs +150 -0
- package/dist/components/Loading/index.d.ts +44 -0
- package/dist/components/Loading/index.d.ts.map +1 -0
- package/dist/components/Loading/index.js +133 -0
- package/dist/components/Markdown/Markdown.module.scss.cjs +8 -0
- package/dist/components/Markdown/Markdown.module.scss.js +8 -0
- package/dist/components/Markdown/index.d.ts +15 -0
- package/dist/components/Markdown/index.d.ts.map +1 -0
- package/dist/components/Menu/Menu.module.scss.cjs +47 -0
- package/dist/components/Menu/Menu.module.scss.js +47 -0
- package/dist/components/Menu/index.cjs +283 -0
- package/dist/components/Menu/index.d.ts +96 -0
- package/dist/components/Menu/index.d.ts.map +1 -0
- package/dist/components/Menu/index.js +266 -0
- package/dist/components/Message/Message.module.scss.cjs +59 -0
- package/dist/components/Message/Message.module.scss.js +59 -0
- package/dist/components/Message/index.cjs +179 -0
- package/dist/components/Message/index.d.ts +58 -0
- package/dist/components/Message/index.d.ts.map +1 -0
- package/dist/components/Message/index.js +162 -0
- package/dist/components/NavigationMenu/NavigationMenu.module.scss.cjs +89 -0
- package/dist/components/NavigationMenu/NavigationMenu.module.scss.js +89 -0
- package/dist/components/NavigationMenu/NavigationMenuContext.cjs +40 -0
- package/dist/components/NavigationMenu/NavigationMenuContext.d.ts +58 -0
- package/dist/components/NavigationMenu/NavigationMenuContext.d.ts.map +1 -0
- package/dist/components/NavigationMenu/NavigationMenuContext.js +23 -0
- package/dist/components/NavigationMenu/index.cjs +675 -0
- package/dist/components/NavigationMenu/index.d.ts +96 -0
- package/dist/components/NavigationMenu/index.d.ts.map +1 -0
- package/dist/components/NavigationMenu/index.js +658 -0
- package/dist/components/NavigationMenu/useNavigationMenu.cjs +89 -0
- package/dist/components/NavigationMenu/useNavigationMenu.d.ts +40 -0
- package/dist/components/NavigationMenu/useNavigationMenu.d.ts.map +1 -0
- package/dist/components/NavigationMenu/useNavigationMenu.js +72 -0
- package/dist/components/Pagination/Pagination.module.scss.cjs +26 -0
- package/dist/components/Pagination/Pagination.module.scss.js +26 -0
- package/dist/components/Pagination/index.cjs +268 -0
- package/dist/components/Pagination/index.d.ts +37 -0
- package/dist/components/Pagination/index.d.ts.map +1 -0
- package/dist/components/Pagination/index.js +251 -0
- package/dist/components/Popover/Popover.module.scss.cjs +35 -0
- package/dist/components/Popover/Popover.module.scss.js +35 -0
- package/dist/components/Popover/index.cjs +178 -0
- package/dist/components/Popover/index.d.ts +90 -0
- package/dist/components/Popover/index.d.ts.map +1 -0
- package/dist/components/Popover/index.js +161 -0
- package/dist/components/Progress/Progress.module.scss.cjs +80 -0
- package/dist/components/Progress/Progress.module.scss.js +80 -0
- package/dist/components/Progress/index.cjs +166 -0
- package/dist/components/Progress/index.d.ts +40 -0
- package/dist/components/Progress/index.d.ts.map +1 -0
- package/dist/components/Progress/index.js +166 -0
- package/dist/components/Prompt/Prompt.module.scss.cjs +59 -0
- package/dist/components/Prompt/Prompt.module.scss.js +59 -0
- package/dist/components/Prompt/index.cjs +322 -0
- package/dist/components/Prompt/index.d.ts +132 -0
- package/dist/components/Prompt/index.d.ts.map +1 -0
- package/dist/components/Prompt/index.js +305 -0
- package/dist/components/RadioGroup/RadioGroup.module.scss.cjs +56 -0
- package/dist/components/RadioGroup/RadioGroup.module.scss.js +56 -0
- package/dist/components/RadioGroup/index.cjs +182 -0
- package/dist/components/RadioGroup/index.d.ts +81 -0
- package/dist/components/RadioGroup/index.d.ts.map +1 -0
- package/dist/components/RadioGroup/index.js +165 -0
- package/dist/components/ScrollArea/ScrollArea.module.scss.cjs +35 -0
- package/dist/components/ScrollArea/ScrollArea.module.scss.js +35 -0
- package/dist/components/ScrollArea/index.cjs +84 -0
- package/dist/components/ScrollArea/index.d.ts +24 -0
- package/dist/components/ScrollArea/index.d.ts.map +1 -0
- package/dist/components/ScrollArea/index.js +67 -0
- package/dist/components/Select/Select.module.scss.cjs +56 -0
- package/dist/components/Select/Select.module.scss.js +56 -0
- package/dist/components/Select/index.cjs +276 -0
- package/dist/components/Select/index.d.ts +87 -0
- package/dist/components/Select/index.d.ts.map +1 -0
- package/dist/components/Select/index.js +259 -0
- package/dist/components/Separator/Separator.module.scss.cjs +35 -0
- package/dist/components/Separator/Separator.module.scss.js +35 -0
- package/dist/components/Separator/index.cjs +83 -0
- package/dist/components/Separator/index.d.ts +15 -0
- package/dist/components/Separator/index.d.ts.map +1 -0
- package/dist/components/Separator/index.js +66 -0
- package/dist/components/Sidebar/Sidebar.module.scss.cjs +131 -0
- package/dist/components/Sidebar/Sidebar.module.scss.js +131 -0
- package/dist/components/Sidebar/index.cjs +763 -0
- package/dist/components/Sidebar/index.d.ts +216 -0
- package/dist/components/Sidebar/index.d.ts.map +1 -0
- package/dist/components/Sidebar/index.js +746 -0
- package/dist/components/Skeleton/Skeleton.module.scss.cjs +89 -0
- package/dist/components/Skeleton/Skeleton.module.scss.js +89 -0
- package/dist/components/Skeleton/index.cjs +110 -0
- package/dist/components/Skeleton/index.d.ts +60 -0
- package/dist/components/Skeleton/index.d.ts.map +1 -0
- package/dist/components/Skeleton/index.js +93 -0
- package/dist/components/Slider/Slider.module.scss.cjs +41 -0
- package/dist/components/Slider/Slider.module.scss.js +41 -0
- package/dist/components/Slider/index.cjs +142 -0
- package/dist/components/Slider/index.d.ts +48 -0
- package/dist/components/Slider/index.d.ts.map +1 -0
- package/dist/components/Slider/index.js +125 -0
- package/dist/components/Stack/Stack.module.scss.cjs +82 -0
- package/dist/components/Stack/Stack.module.scss.js +82 -0
- package/dist/components/Stack/index.cjs +138 -0
- package/dist/components/Stack/index.d.ts +68 -0
- package/dist/components/Stack/index.d.ts.map +1 -0
- package/dist/components/Stack/index.js +121 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/index.d.ts.map +1 -0
- package/dist/components/Table/Table.module.scss.cjs +59 -0
- package/dist/components/Table/Table.module.scss.js +59 -0
- package/dist/components/Table/index.d.ts +61 -0
- package/dist/components/Table/index.d.ts.map +1 -0
- package/dist/components/TableOfContents/TableOfContents.module.scss.cjs +50 -0
- package/dist/components/TableOfContents/TableOfContents.module.scss.js +50 -0
- package/dist/components/TableOfContents/index.cjs +176 -0
- package/dist/components/TableOfContents/index.d.ts +53 -0
- package/dist/components/TableOfContents/index.d.ts.map +1 -0
- package/dist/components/TableOfContents/index.js +159 -0
- package/dist/components/Tabs/Tabs.module.scss.cjs +41 -0
- package/dist/components/Tabs/Tabs.module.scss.js +41 -0
- package/dist/components/Tabs/index.cjs +93 -0
- package/dist/components/Tabs/index.d.ts +58 -0
- package/dist/components/Tabs/index.d.ts.map +1 -0
- package/dist/components/Tabs/index.js +76 -0
- package/dist/components/Text/Text.module.scss.cjs +112 -0
- package/dist/components/Text/Text.module.scss.js +112 -0
- package/dist/components/Text/index.cjs +60 -0
- package/dist/components/Text/index.d.ts +41 -0
- package/dist/components/Text/index.d.ts.map +1 -0
- package/dist/components/Text/index.js +43 -0
- package/dist/components/Textarea/Textarea.module.scss.cjs +66 -0
- package/dist/components/Textarea/Textarea.module.scss.js +66 -0
- package/dist/components/Textarea/index.cjs +150 -0
- package/dist/components/Textarea/index.d.ts +62 -0
- package/dist/components/Textarea/index.d.ts.map +1 -0
- package/dist/components/Textarea/index.js +133 -0
- package/dist/components/Theme/ThemeToggle.module.scss.cjs +23 -0
- package/dist/components/Theme/ThemeToggle.module.scss.js +23 -0
- package/dist/components/Theme/index.cjs +353 -0
- package/dist/components/Theme/index.d.ts +111 -0
- package/dist/components/Theme/index.d.ts.map +1 -0
- package/dist/components/Theme/index.js +336 -0
- package/dist/components/ThinkingIndicator/ThinkingIndicator.module.scss.cjs +44 -0
- package/dist/components/ThinkingIndicator/ThinkingIndicator.module.scss.js +44 -0
- package/dist/components/ThinkingIndicator/index.cjs +171 -0
- package/dist/components/ThinkingIndicator/index.d.ts +44 -0
- package/dist/components/ThinkingIndicator/index.d.ts.map +1 -0
- package/dist/components/ThinkingIndicator/index.js +154 -0
- package/dist/components/Toast/Toast.module.scss.cjs +63 -0
- package/dist/components/Toast/Toast.module.scss.js +63 -0
- package/dist/components/Toast/index.cjs +316 -0
- package/dist/components/Toast/index.d.ts +52 -0
- package/dist/components/Toast/index.d.ts.map +1 -0
- package/dist/components/Toast/index.js +299 -0
- package/dist/components/Toggle/Toggle.module.scss.cjs +44 -0
- package/dist/components/Toggle/Toggle.module.scss.js +44 -0
- package/dist/components/Toggle/index.cjs +99 -0
- package/dist/components/Toggle/index.d.ts +43 -0
- package/dist/components/Toggle/index.d.ts.map +1 -0
- package/dist/components/Toggle/index.js +82 -0
- package/dist/components/ToggleGroup/ToggleGroup.module.scss.cjs +44 -0
- package/dist/components/ToggleGroup/ToggleGroup.module.scss.js +44 -0
- package/dist/components/ToggleGroup/index.cjs +172 -0
- package/dist/components/ToggleGroup/index.d.ts +53 -0
- package/dist/components/ToggleGroup/index.d.ts.map +1 -0
- package/dist/components/ToggleGroup/index.js +155 -0
- package/dist/components/Tooltip/Tooltip.module.scss.cjs +14 -0
- package/dist/components/Tooltip/Tooltip.module.scss.js +14 -0
- package/dist/components/Tooltip/index.cjs +133 -0
- package/dist/components/Tooltip/index.d.ts +76 -0
- package/dist/components/Tooltip/index.d.ts.map +1 -0
- package/dist/components/Tooltip/index.js +116 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.module.scss.cjs +8 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.module.scss.js +8 -0
- package/dist/components/VisuallyHidden/index.cjs +39 -0
- package/dist/components/VisuallyHidden/index.d.ts +10 -0
- package/dist/components/VisuallyHidden/index.d.ts.map +1 -0
- package/dist/components/VisuallyHidden/index.js +22 -0
- package/dist/data-table.cjs +310 -0
- package/dist/data-table.js +293 -0
- package/dist/datepicker.cjs +459 -0
- package/dist/datepicker.js +442 -0
- package/dist/editor.cjs +572 -0
- package/dist/editor.js +555 -0
- package/dist/index.cjs +288 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +288 -0
- package/dist/markdown.cjs +70 -0
- package/dist/markdown.js +53 -0
- package/dist/node_modules/.pnpm/@tanstack_react-virtual@3.13.18_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-virtual/dist/esm/index.cjs +68 -0
- package/dist/node_modules/.pnpm/@tanstack_react-virtual@3.13.18_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-virtual/dist/esm/index.js +52 -0
- package/dist/node_modules/.pnpm/@tanstack_virtual-core@3.13.18/node_modules/@tanstack/virtual-core/dist/esm/index.cjs +822 -0
- package/dist/node_modules/.pnpm/@tanstack_virtual-core@3.13.18/node_modules/@tanstack/virtual-core/dist/esm/index.js +822 -0
- package/dist/node_modules/.pnpm/@tanstack_virtual-core@3.13.18/node_modules/@tanstack/virtual-core/dist/esm/utils.cjs +72 -0
- package/dist/node_modules/.pnpm/@tanstack_virtual-core@3.13.18/node_modules/@tanstack/virtual-core/dist/esm/utils.js +72 -0
- package/dist/table.cjs +122 -0
- package/dist/table.js +105 -0
- package/dist/utils/a11y.cjs +232 -0
- package/dist/utils/a11y.d.ts +133 -0
- package/dist/utils/a11y.d.ts.map +1 -0
- package/dist/utils/a11y.js +215 -0
- package/dist/utils/aria.cjs +41 -0
- package/dist/utils/aria.d.ts +44 -0
- package/dist/utils/aria.d.ts.map +1 -0
- package/dist/utils/aria.js +24 -0
- package/dist/utils/canonical-stamp.cjs +18 -0
- package/dist/utils/canonical-stamp.d.ts +25 -0
- package/dist/utils/canonical-stamp.d.ts.map +1 -0
- package/dist/utils/canonical-stamp.js +18 -0
- package/dist/utils/css-warning.cjs +17 -0
- package/dist/utils/css-warning.d.ts +2 -0
- package/dist/utils/css-warning.d.ts.map +1 -0
- package/dist/utils/css-warning.js +17 -0
- package/dist/utils/keyboard-shortcuts.cjs +294 -0
- package/dist/utils/keyboard-shortcuts.d.ts +293 -0
- package/dist/utils/keyboard-shortcuts.d.ts.map +1 -0
- package/dist/utils/keyboard-shortcuts.js +294 -0
- package/dist/utils/seed-derivation.cjs +478 -0
- package/dist/utils/seed-derivation.d.ts +140 -0
- package/dist/utils/seed-derivation.d.ts.map +1 -0
- package/dist/utils/seed-derivation.js +478 -0
- package/dist/utils/theme-presets.cjs +229 -0
- package/dist/utils/theme-presets.d.ts +103 -0
- package/dist/utils/theme-presets.d.ts.map +1 -0
- package/dist/utils/theme-presets.js +229 -0
- package/fragments.json +1 -0
- package/package.json +258 -0
- package/src/assets/fragments-logo.tsx +38 -0
- package/src/components/Accordion/Accordion.contract.json +169 -0
- package/src/components/Accordion/Accordion.module.scss +113 -0
- package/src/components/Accordion/Accordion.stories.tsx +106 -0
- package/src/components/Accordion/index.tsx +306 -0
- package/src/components/Alert/Alert.contract.json +157 -0
- package/src/components/Alert/Alert.module.scss +130 -0
- package/src/components/Alert/Alert.stories.tsx +119 -0
- package/src/components/Alert/index.tsx +249 -0
- package/src/components/AppShell/AppShell.contract.json +155 -0
- package/src/components/AppShell/AppShell.module.scss +239 -0
- package/src/components/AppShell/AppShell.stories.tsx +156 -0
- package/src/components/AppShell/index.tsx +518 -0
- package/src/components/Avatar/Avatar.contract.json +189 -0
- package/src/components/Avatar/Avatar.module.scss +136 -0
- package/src/components/Avatar/Avatar.stories.tsx +74 -0
- package/src/components/Avatar/index.tsx +311 -0
- package/src/components/Badge/Badge.contract.json +170 -0
- package/src/components/Badge/Badge.module.scss +146 -0
- package/src/components/Badge/Badge.stories.tsx +92 -0
- package/src/components/Badge/index.tsx +115 -0
- package/src/components/BentoGrid/BentoGrid.contract.json +135 -0
- package/src/components/BentoGrid/BentoGrid.module.scss +179 -0
- package/src/components/BentoGrid/BentoGrid.stories.tsx +98 -0
- package/src/components/BentoGrid/index.tsx +164 -0
- package/src/components/Box/Box.contract.json +423 -0
- package/src/components/Box/Box.module.scss +126 -0
- package/src/components/Box/Box.stories.tsx +150 -0
- package/src/components/Box/index.tsx +154 -0
- package/src/components/Breadcrumbs/Breadcrumbs.contract.json +143 -0
- package/src/components/Breadcrumbs/Breadcrumbs.module.scss +121 -0
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +87 -0
- package/src/components/Breadcrumbs/index.tsx +205 -0
- package/src/components/Button/Button.contract.json +212 -0
- package/src/components/Button/Button.module.scss +296 -0
- package/src/components/Button/Button.stories.tsx +103 -0
- package/src/components/Button/index.tsx +190 -0
- package/src/components/ButtonGroup/ButtonGroup.contract.json +140 -0
- package/src/components/ButtonGroup/ButtonGroup.module.scss +61 -0
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +97 -0
- package/src/components/ButtonGroup/index.tsx +34 -0
- package/src/components/Card/Card.contract.json +170 -0
- package/src/components/Card/Card.module.scss +212 -0
- package/src/components/Card/Card.stories.tsx +144 -0
- package/src/components/Card/index.tsx +233 -0
- package/src/components/Chart/Chart.contract.json +129 -0
- package/src/components/Chart/Chart.module.scss +128 -0
- package/src/components/Chart/Chart.stories.tsx +119 -0
- package/src/components/Chart/index.tsx +365 -0
- package/src/components/Checkbox/Checkbox.contract.json +256 -0
- package/src/components/Checkbox/Checkbox.module.scss +256 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +68 -0
- package/src/components/Checkbox/index.tsx +264 -0
- package/src/components/Chip/Chip.contract.json +212 -0
- package/src/components/Chip/Chip.module.scss +265 -0
- package/src/components/Chip/Chip.stories.tsx +70 -0
- package/src/components/Chip/index.tsx +194 -0
- package/src/components/Cloud/CloudGovernanceShell.module.scss +88 -0
- package/src/components/Cloud/CloudGovernanceShell.stories.tsx +446 -0
- package/src/components/Cloud/ControlSizing.module.scss +49 -0
- package/src/components/Cloud/ControlSizing.stories.tsx +238 -0
- package/src/components/Cloud/DashboardLayoutPrototypes.module.scss +462 -0
- package/src/components/Cloud/DashboardLayoutPrototypes.shared.tsx +375 -0
- package/src/components/Cloud/DashboardLayoutPrototypes.shell.tsx +147 -0
- package/src/components/Cloud/DashboardLayoutPrototypes.stories.tsx +328 -0
- package/src/components/Cloud/PullRequestsPrototypes.content.tsx +283 -0
- package/src/components/Cloud/PullRequestsPrototypes.detail-panels.tsx +381 -0
- package/src/components/Cloud/PullRequestsPrototypes.detail.tsx +204 -0
- package/src/components/Cloud/PullRequestsPrototypes.id-data.ts +395 -0
- package/src/components/Cloud/PullRequestsPrototypes.id-page.tsx +349 -0
- package/src/components/Cloud/PullRequestsPrototypes.stories.tsx +81 -0
- package/src/components/CodeBlock/CodeBlock.contract.json +388 -0
- package/src/components/CodeBlock/CodeBlock.module.scss +384 -0
- package/src/components/CodeBlock/CodeBlock.stories.tsx +147 -0
- package/src/components/CodeBlock/index.tsx +872 -0
- package/src/components/Collapsible/Collapsible.contract.json +154 -0
- package/src/components/Collapsible/Collapsible.module.scss +119 -0
- package/src/components/Collapsible/Collapsible.stories.tsx +94 -0
- package/src/components/Collapsible/index.tsx +254 -0
- package/src/components/ColorPicker/ColorPicker.contract.json +212 -0
- package/src/components/ColorPicker/ColorPicker.module.scss +142 -0
- package/src/components/ColorPicker/ColorPicker.stories.tsx +74 -0
- package/src/components/ColorPicker/index.tsx +182 -0
- package/src/components/Combobox/Combobox.contract.json +297 -0
- package/src/components/Combobox/Combobox.module.scss +334 -0
- package/src/components/Combobox/Combobox.stories.tsx +133 -0
- package/src/components/Combobox/index.tsx +619 -0
- package/src/components/Command/Command.contract.json +165 -0
- package/src/components/Command/Command.module.scss +152 -0
- package/src/components/Command/Command.stories.tsx +102 -0
- package/src/components/Command/index.tsx +548 -0
- package/src/components/ComponentDefaults/index.tsx +56 -0
- package/src/components/ConversationList/ConversationList.contract.json +151 -0
- package/src/components/ConversationList/ConversationList.module.scss +160 -0
- package/src/components/ConversationList/ConversationList.stories.tsx +93 -0
- package/src/components/ConversationList/index.tsx +257 -0
- package/src/components/DataTable/DataTable.contract.json +302 -0
- package/src/components/DataTable/DataTable.icons.tsx +67 -0
- package/src/components/DataTable/DataTable.module.scss +429 -0
- package/src/components/DataTable/DataTable.stories.tsx +129 -0
- package/src/components/DataTable/DataTable.support.tsx +75 -0
- package/src/components/DataTable/DataTable.virtual.tsx +197 -0
- package/src/components/DataTable/index.tsx +519 -0
- package/src/components/DatePicker/DatePicker.contract.json +283 -0
- package/src/components/DatePicker/DatePicker.module.scss +434 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +129 -0
- package/src/components/DatePicker/index.tsx +670 -0
- package/src/components/Dialog/Dialog.contract.json +159 -0
- package/src/components/Dialog/Dialog.module.scss +177 -0
- package/src/components/Dialog/Dialog.stories.tsx +154 -0
- package/src/components/Dialog/index.tsx +264 -0
- package/src/components/Drawer/Drawer.contract.json +161 -0
- package/src/components/Drawer/Drawer.module.scss +255 -0
- package/src/components/Drawer/Drawer.stories.tsx +144 -0
- package/src/components/Drawer/index.tsx +329 -0
- package/src/components/Editor/Editor.contract.json +263 -0
- package/src/components/Editor/Editor.module.scss +352 -0
- package/src/components/Editor/Editor.stories.tsx +99 -0
- package/src/components/Editor/index.tsx +866 -0
- package/src/components/EmptyState/EmptyState.contract.json +133 -0
- package/src/components/EmptyState/EmptyState.module.scss +131 -0
- package/src/components/EmptyState/EmptyState.stories.tsx +97 -0
- package/src/components/EmptyState/index.tsx +115 -0
- package/src/components/Field/Field.contract.json +157 -0
- package/src/components/Field/Field.module.scss +31 -0
- package/src/components/Field/Field.stories.tsx +109 -0
- package/src/components/Field/index.tsx +144 -0
- package/src/components/Fieldset/Fieldset.contract.json +117 -0
- package/src/components/Fieldset/Fieldset.module.scss +28 -0
- package/src/components/Fieldset/Fieldset.stories.tsx +116 -0
- package/src/components/Fieldset/index.tsx +57 -0
- package/src/components/Form/Form.contract.json +145 -0
- package/src/components/Form/Form.module.scss +8 -0
- package/src/components/Form/Form.stories.tsx +142 -0
- package/src/components/Form/index.tsx +54 -0
- package/src/components/Grid/Grid.contract.json +195 -0
- package/src/components/Grid/Grid.module.scss +165 -0
- package/src/components/Grid/Grid.stories.tsx +125 -0
- package/src/components/Grid/index.tsx +234 -0
- package/src/components/Header/Header.contract.json +196 -0
- package/src/components/Header/Header.module.scss +432 -0
- package/src/components/Header/Header.stories.tsx +133 -0
- package/src/components/Header/index.tsx +660 -0
- package/src/components/Icon/Icon.contract.json +194 -0
- package/src/components/Icon/Icon.module.scss +38 -0
- package/src/components/Icon/Icon.stories.tsx +80 -0
- package/src/components/Icon/index.tsx +105 -0
- package/src/components/IconButton/IconButton.module.scss +102 -0
- package/src/components/IconButton/IconButton.stories.tsx +78 -0
- package/src/components/IconButton/index.tsx +93 -0
- package/src/components/Image/Image.contract.json +209 -0
- package/src/components/Image/Image.module.scss +77 -0
- package/src/components/Image/Image.stories.tsx +109 -0
- package/src/components/Image/index.tsx +128 -0
- package/src/components/Input/Input.contract.json +325 -0
- package/src/components/Input/Input.module.scss +231 -0
- package/src/components/Input/Input.stories.tsx +104 -0
- package/src/components/Input/index.tsx +301 -0
- package/src/components/Link/Link.contract.json +180 -0
- package/src/components/Link/Link.module.scss +67 -0
- package/src/components/Link/Link.stories.tsx +67 -0
- package/src/components/Link/index.tsx +102 -0
- package/src/components/List/List.contract.json +154 -0
- package/src/components/List/List.module.scss +71 -0
- package/src/components/List/List.stories.tsx +95 -0
- package/src/components/List/index.tsx +107 -0
- package/src/components/Listbox/Listbox.contract.json +158 -0
- package/src/components/Listbox/Listbox.module.scss +113 -0
- package/src/components/Listbox/Listbox.stories.tsx +81 -0
- package/src/components/Listbox/index.tsx +309 -0
- package/src/components/Loading/Loading.contract.json +167 -0
- package/src/components/Loading/Loading.module.scss +259 -0
- package/src/components/Loading/Loading.stories.tsx +69 -0
- package/src/components/Loading/index.tsx +229 -0
- package/src/components/Markdown/Markdown.contract.json +127 -0
- package/src/components/Markdown/Markdown.module.scss +233 -0
- package/src/components/Markdown/Markdown.stories.tsx +75 -0
- package/src/components/Markdown/index.tsx +112 -0
- package/src/components/Menu/Menu.contract.json +177 -0
- package/src/components/Menu/Menu.module.scss +215 -0
- package/src/components/Menu/Menu.stories.tsx +113 -0
- package/src/components/Menu/index.tsx +411 -0
- package/src/components/Message/Message.contract.json +183 -0
- package/src/components/Message/Message.module.scss +238 -0
- package/src/components/Message/Message.stories.tsx +85 -0
- package/src/components/Message/index.tsx +293 -0
- package/src/components/NavigationMenu/NavigationMenu.contract.json +203 -0
- package/src/components/NavigationMenu/NavigationMenu.module.scss +515 -0
- package/src/components/NavigationMenu/NavigationMenu.stories.tsx +161 -0
- package/src/components/NavigationMenu/NavigationMenuContext.ts +108 -0
- package/src/components/NavigationMenu/index.tsx +1001 -0
- package/src/components/NavigationMenu/useNavigationMenu.ts +101 -0
- package/src/components/Pagination/Pagination.contract.json +163 -0
- package/src/components/Pagination/Pagination.module.scss +111 -0
- package/src/components/Pagination/Pagination.stories.tsx +81 -0
- package/src/components/Pagination/index.tsx +387 -0
- package/src/components/Popover/Popover.contract.json +163 -0
- package/src/components/Popover/Popover.module.scss +189 -0
- package/src/components/Popover/Popover.stories.tsx +152 -0
- package/src/components/Popover/index.tsx +284 -0
- package/src/components/Progress/Progress.contract.json +176 -0
- package/src/components/Progress/Progress.module.scss +185 -0
- package/src/components/Progress/Progress.stories.tsx +64 -0
- package/src/components/Progress/index.tsx +238 -0
- package/src/components/Prompt/Prompt.contract.json +213 -0
- package/src/components/Prompt/Prompt.module.scss +346 -0
- package/src/components/Prompt/Prompt.stories.tsx +93 -0
- package/src/components/Prompt/index.tsx +508 -0
- package/src/components/RadioGroup/RadioGroup.contract.json +236 -0
- package/src/components/RadioGroup/RadioGroup.module.scss +272 -0
- package/src/components/RadioGroup/RadioGroup.stories.tsx +107 -0
- package/src/components/RadioGroup/index.tsx +298 -0
- package/src/components/ScrollArea/ScrollArea.contract.json +131 -0
- package/src/components/ScrollArea/ScrollArea.module.scss +149 -0
- package/src/components/ScrollArea/ScrollArea.stories.tsx +97 -0
- package/src/components/ScrollArea/index.tsx +122 -0
- package/src/components/Select/Select.contract.json +249 -0
- package/src/components/Select/Select.module.scss +226 -0
- package/src/components/Select/Select.stories.tsx +127 -0
- package/src/components/Select/index.tsx +457 -0
- package/src/components/Separator/Separator.contract.json +143 -0
- package/src/components/Separator/Separator.module.scss +92 -0
- package/src/components/Separator/Separator.stories.tsx +84 -0
- package/src/components/Separator/index.tsx +97 -0
- package/src/components/Sidebar/Sidebar.contract.json +258 -0
- package/src/components/Sidebar/Sidebar.module.scss +650 -0
- package/src/components/Sidebar/Sidebar.stories.tsx +122 -0
- package/src/components/Sidebar/index.tsx +1168 -0
- package/src/components/Skeleton/Skeleton.contract.json +166 -0
- package/src/components/Skeleton/Skeleton.module.scss +166 -0
- package/src/components/Skeleton/Skeleton.stories.tsx +80 -0
- package/src/components/Skeleton/index.tsx +182 -0
- package/src/components/Slider/Slider.contract.json +248 -0
- package/src/components/Slider/Slider.module.scss +147 -0
- package/src/components/Slider/Slider.stories.tsx +73 -0
- package/src/components/Slider/index.tsx +189 -0
- package/src/components/Stack/Stack.contract.json +220 -0
- package/src/components/Stack/Stack.module.scss +136 -0
- package/src/components/Stack/Stack.stories.tsx +73 -0
- package/src/components/Stack/index.tsx +207 -0
- package/src/components/Switch/Switch.stories.tsx +59 -0
- package/src/components/Switch/index.ts +3 -0
- package/src/components/Table/Table.contract.json +171 -0
- package/src/components/Table/Table.module.scss +206 -0
- package/src/components/Table/Table.stories.tsx +219 -0
- package/src/components/Table/index.tsx +205 -0
- package/src/components/TableOfContents/TableOfContents.contract.json +165 -0
- package/src/components/TableOfContents/TableOfContents.module.scss +324 -0
- package/src/components/TableOfContents/TableOfContents.stories.tsx +120 -0
- package/src/components/TableOfContents/index.tsx +266 -0
- package/src/components/Tabs/Tabs.contract.json +159 -0
- package/src/components/Tabs/Tabs.module.scss +179 -0
- package/src/components/Tabs/Tabs.stories.tsx +136 -0
- package/src/components/Tabs/index.tsx +168 -0
- package/src/components/Text/Text.contract.json +241 -0
- package/src/components/Text/Text.module.scss +136 -0
- package/src/components/Text/Text.stories.tsx +133 -0
- package/src/components/Text/index.tsx +91 -0
- package/src/components/Textarea/Textarea.contract.json +308 -0
- package/src/components/Textarea/Textarea.module.scss +175 -0
- package/src/components/Textarea/Textarea.stories.tsx +107 -0
- package/src/components/Textarea/index.tsx +205 -0
- package/src/components/Theme/Theme.contract.json +152 -0
- package/src/components/Theme/Theme.stories.tsx +95 -0
- package/src/components/Theme/ThemeToggle.module.scss +91 -0
- package/src/components/Theme/index.tsx +579 -0
- package/src/components/ThinkingIndicator/ThinkingIndicator.contract.json +165 -0
- package/src/components/ThinkingIndicator/ThinkingIndicator.module.scss +107 -0
- package/src/components/ThinkingIndicator/ThinkingIndicator.stories.tsx +85 -0
- package/src/components/ThinkingIndicator/index.tsx +257 -0
- package/src/components/Toast/Toast.contract.json +181 -0
- package/src/components/Toast/Toast.module.scss +286 -0
- package/src/components/Toast/Toast.stories.tsx +91 -0
- package/src/components/Toast/index.tsx +439 -0
- package/src/components/Toggle/Toggle.contract.json +231 -0
- package/src/components/Toggle/Toggle.module.scss +244 -0
- package/src/components/Toggle/index.tsx +140 -0
- package/src/components/ToggleGroup/ToggleGroup.contract.json +206 -0
- package/src/components/ToggleGroup/ToggleGroup.module.scss +160 -0
- package/src/components/ToggleGroup/ToggleGroup.stories.tsx +114 -0
- package/src/components/ToggleGroup/index.tsx +252 -0
- package/src/components/Tooltip/Tooltip.contract.json +214 -0
- package/src/components/Tooltip/Tooltip.module.scss +87 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +95 -0
- package/src/components/Tooltip/index.tsx +209 -0
- package/src/components/VisuallyHidden/VisuallyHidden.contract.json +116 -0
- package/src/components/VisuallyHidden/VisuallyHidden.module.scss +13 -0
- package/src/components/VisuallyHidden/VisuallyHidden.stories.tsx +78 -0
- package/src/components/VisuallyHidden/index.tsx +37 -0
- package/src/index.ts +728 -0
- package/src/scss.d.ts +4 -0
- package/src/styles/globals.scss +207 -0
- package/src/tokens/_computed.scss +225 -0
- package/src/tokens/_density.scss +176 -0
- package/src/tokens/_derive.scss +513 -0
- package/src/tokens/_mixins.scss +471 -0
- package/src/tokens/_palettes.scss +225 -0
- package/src/tokens/_property-registrations.scss +218 -0
- package/src/tokens/_radius.scss +107 -0
- package/src/tokens/_seeds.scss +83 -0
- package/src/tokens/_variables.scss +1045 -0
- package/src/utils/a11y.tsx +431 -0
- package/src/utils/aria.ts +63 -0
- package/src/utils/canonical-stamp.ts +47 -0
- package/src/utils/css-warning.ts +29 -0
- package/src/utils/keyboard-shortcuts.ts +502 -0
- package/src/utils/seed-derivation.ts +706 -0
- package/src/utils/theme-presets.ts +360 -0
|
@@ -0,0 +1,866 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import styles from './Editor.module.scss';
|
|
5
|
+
import {
|
|
6
|
+
TextB,
|
|
7
|
+
TextItalic,
|
|
8
|
+
TextStrikethrough,
|
|
9
|
+
LinkSimple,
|
|
10
|
+
Code,
|
|
11
|
+
ListBullets,
|
|
12
|
+
ListNumbers,
|
|
13
|
+
TextHOne,
|
|
14
|
+
TextHTwo,
|
|
15
|
+
TextHThree,
|
|
16
|
+
Quotes,
|
|
17
|
+
ArrowCounterClockwise,
|
|
18
|
+
ArrowClockwise,
|
|
19
|
+
} from '@phosphor-icons/react';
|
|
20
|
+
import { KEYBOARD_SHORTCUTS } from '../../utils/keyboard-shortcuts';
|
|
21
|
+
|
|
22
|
+
// ============================================
|
|
23
|
+
// Lazy-loaded dependency (TipTap)
|
|
24
|
+
// ============================================
|
|
25
|
+
|
|
26
|
+
let _useEditor: ((config: Record<string, unknown>) => unknown) | null = null;
|
|
27
|
+
let _EditorContent: React.ComponentType<Record<string, unknown>> | null = null;
|
|
28
|
+
let _StarterKit: unknown = null;
|
|
29
|
+
let _LinkExtension: unknown = null;
|
|
30
|
+
let _tiptapLoaded = false;
|
|
31
|
+
let _tiptapFailed = false;
|
|
32
|
+
|
|
33
|
+
function loadTipTapDeps() {
|
|
34
|
+
if (_tiptapLoaded) return;
|
|
35
|
+
_tiptapLoaded = true;
|
|
36
|
+
try {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
38
|
+
const tiptapReact = require('@tiptap/react');
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
40
|
+
const starterKit = require('@tiptap/starter-kit');
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
42
|
+
const linkExt = require('@tiptap/extension-link');
|
|
43
|
+
|
|
44
|
+
_useEditor = tiptapReact.useEditor;
|
|
45
|
+
_EditorContent = tiptapReact.EditorContent;
|
|
46
|
+
_StarterKit = starterKit.default ?? starterKit.StarterKit ?? starterKit;
|
|
47
|
+
_LinkExtension = linkExt.default ?? linkExt.Link ?? linkExt;
|
|
48
|
+
} catch {
|
|
49
|
+
_tiptapFailed = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ============================================
|
|
54
|
+
// Types
|
|
55
|
+
// ============================================
|
|
56
|
+
|
|
57
|
+
export type EditorFormat =
|
|
58
|
+
| 'bold' | 'italic' | 'strikethrough' | 'link' | 'code'
|
|
59
|
+
| 'bulletList' | 'orderedList'
|
|
60
|
+
| 'heading1' | 'heading2' | 'heading3'
|
|
61
|
+
| 'blockquote'
|
|
62
|
+
| 'undo' | 'redo';
|
|
63
|
+
|
|
64
|
+
export type EditorSaveStatus = 'idle' | 'saving' | 'saved' | 'error';
|
|
65
|
+
|
|
66
|
+
export type EditorMode = 'rich' | 'markdown';
|
|
67
|
+
|
|
68
|
+
export type EditorSize = 'sm' | 'md' | 'lg';
|
|
69
|
+
|
|
70
|
+
export interface EditorToolbarIconRenderState {
|
|
71
|
+
format: EditorFormat;
|
|
72
|
+
active: boolean;
|
|
73
|
+
disabled: boolean;
|
|
74
|
+
readOnly: boolean;
|
|
75
|
+
isDisabled: boolean;
|
|
76
|
+
mode: EditorMode;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type EditorToolbarIconSlot =
|
|
80
|
+
| React.ReactNode
|
|
81
|
+
| ((state: EditorToolbarIconRenderState) => React.ReactNode);
|
|
82
|
+
|
|
83
|
+
export type EditorToolbarIcons = Partial<Record<EditorFormat, EditorToolbarIconSlot>>;
|
|
84
|
+
|
|
85
|
+
export interface EditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
86
|
+
children?: React.ReactNode;
|
|
87
|
+
/** Controlled value */
|
|
88
|
+
value?: string;
|
|
89
|
+
/** Default value for uncontrolled usage */
|
|
90
|
+
defaultValue?: string;
|
|
91
|
+
/** Called when content changes */
|
|
92
|
+
onValueChange?: (value: string) => void;
|
|
93
|
+
/** Placeholder text */
|
|
94
|
+
placeholder?: string;
|
|
95
|
+
/** Disable the editor */
|
|
96
|
+
disabled?: boolean;
|
|
97
|
+
/** Read-only mode */
|
|
98
|
+
readOnly?: boolean;
|
|
99
|
+
/** Which format buttons to show */
|
|
100
|
+
formats?: EditorFormat[];
|
|
101
|
+
/** Show default toolbar */
|
|
102
|
+
toolbar?: boolean;
|
|
103
|
+
/** Show default status bar */
|
|
104
|
+
statusBar?: boolean;
|
|
105
|
+
/** Auto-save callback (sync or async) */
|
|
106
|
+
onAutoSave?: (value: string) => void | Promise<void>;
|
|
107
|
+
/** Auto-save interval in ms */
|
|
108
|
+
autoSaveInterval?: number;
|
|
109
|
+
/** Editor size preset */
|
|
110
|
+
size?: EditorSize;
|
|
111
|
+
/** Maximum character count (shows indicator in status bar) */
|
|
112
|
+
maxLength?: number;
|
|
113
|
+
/** Custom toolbar icons keyed by format/action, for any icon package */
|
|
114
|
+
toolbarIcons?: EditorToolbarIcons;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface EditorToolbarProps {
|
|
118
|
+
children: React.ReactNode;
|
|
119
|
+
className?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface EditorToolbarGroupProps {
|
|
123
|
+
children: React.ReactNode;
|
|
124
|
+
'aria-label'?: string;
|
|
125
|
+
className?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface EditorToolbarButtonProps {
|
|
129
|
+
/** Which format this button toggles */
|
|
130
|
+
format: EditorFormat;
|
|
131
|
+
className?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface EditorSeparatorProps {
|
|
135
|
+
className?: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface EditorStatusIndicatorProps {
|
|
139
|
+
/** Override the save status from context */
|
|
140
|
+
status?: EditorSaveStatus;
|
|
141
|
+
/** Custom labels per status */
|
|
142
|
+
labels?: Partial<Record<EditorSaveStatus, string>>;
|
|
143
|
+
className?: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface EditorContentProps {
|
|
147
|
+
className?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface EditorStatusBarProps {
|
|
151
|
+
/** Show word count */
|
|
152
|
+
showWordCount?: boolean;
|
|
153
|
+
/** Show character count */
|
|
154
|
+
showCharCount?: boolean;
|
|
155
|
+
className?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ============================================
|
|
159
|
+
// Format metadata
|
|
160
|
+
// ============================================
|
|
161
|
+
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
163
|
+
const FORMAT_META: Record<EditorFormat, { icon: React.ComponentType<any>; label: string; shortcut: string }> = {
|
|
164
|
+
bold: { icon: TextB, label: 'Bold', shortcut: KEYBOARD_SHORTCUTS.EDITOR_BOLD.label },
|
|
165
|
+
italic: { icon: TextItalic, label: 'Italic', shortcut: KEYBOARD_SHORTCUTS.EDITOR_ITALIC.label },
|
|
166
|
+
strikethrough: { icon: TextStrikethrough, label: 'Strikethrough', shortcut: KEYBOARD_SHORTCUTS.EDITOR_STRIKETHROUGH.label },
|
|
167
|
+
link: { icon: LinkSimple, label: 'Link', shortcut: KEYBOARD_SHORTCUTS.EDITOR_LINK.label },
|
|
168
|
+
code: { icon: Code, label: 'Code', shortcut: KEYBOARD_SHORTCUTS.EDITOR_CODE.label },
|
|
169
|
+
bulletList: { icon: ListBullets, label: 'Bullet list', shortcut: KEYBOARD_SHORTCUTS.EDITOR_BULLET_LIST.label },
|
|
170
|
+
orderedList: { icon: ListNumbers, label: 'Ordered list', shortcut: KEYBOARD_SHORTCUTS.EDITOR_ORDERED_LIST.label },
|
|
171
|
+
heading1: { icon: TextHOne, label: 'Heading 1', shortcut: KEYBOARD_SHORTCUTS.EDITOR_HEADING1.label },
|
|
172
|
+
heading2: { icon: TextHTwo, label: 'Heading 2', shortcut: KEYBOARD_SHORTCUTS.EDITOR_HEADING2.label },
|
|
173
|
+
heading3: { icon: TextHThree, label: 'Heading 3', shortcut: KEYBOARD_SHORTCUTS.EDITOR_HEADING3.label },
|
|
174
|
+
blockquote: { icon: Quotes, label: 'Blockquote', shortcut: KEYBOARD_SHORTCUTS.EDITOR_BLOCKQUOTE.label },
|
|
175
|
+
undo: { icon: ArrowCounterClockwise, label: 'Undo', shortcut: KEYBOARD_SHORTCUTS.EDITOR_UNDO.label },
|
|
176
|
+
redo: { icon: ArrowClockwise, label: 'Redo', shortcut: KEYBOARD_SHORTCUTS.EDITOR_REDO.label },
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const DEFAULT_FORMATS: EditorFormat[] = ['bold', 'italic', 'strikethrough', 'link', 'code', 'bulletList'];
|
|
180
|
+
|
|
181
|
+
/** Formats that are actions (not toggles) — no aria-pressed, different disable logic */
|
|
182
|
+
const ACTION_FORMATS = new Set<EditorFormat>(['undo', 'redo']);
|
|
183
|
+
|
|
184
|
+
const DEFAULT_STATUS_LABELS: Record<EditorSaveStatus, string> = {
|
|
185
|
+
idle: '',
|
|
186
|
+
saving: 'SAVING...',
|
|
187
|
+
saved: 'AUTO-SAVED',
|
|
188
|
+
error: 'SAVE FAILED',
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// ============================================
|
|
192
|
+
// Markdown formatting helpers (textarea fallback)
|
|
193
|
+
// ============================================
|
|
194
|
+
|
|
195
|
+
interface TextareaSelection {
|
|
196
|
+
start: number;
|
|
197
|
+
end: number;
|
|
198
|
+
text: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function getSelection(textarea: HTMLTextAreaElement): TextareaSelection {
|
|
202
|
+
return {
|
|
203
|
+
start: textarea.selectionStart,
|
|
204
|
+
end: textarea.selectionEnd,
|
|
205
|
+
text: textarea.value.substring(textarea.selectionStart, textarea.selectionEnd),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function wrapSelection(
|
|
210
|
+
textarea: HTMLTextAreaElement,
|
|
211
|
+
prefix: string,
|
|
212
|
+
suffix: string,
|
|
213
|
+
setValue: (v: string) => void,
|
|
214
|
+
) {
|
|
215
|
+
const sel = getSelection(textarea);
|
|
216
|
+
const before = textarea.value.substring(0, sel.start);
|
|
217
|
+
const after = textarea.value.substring(sel.end);
|
|
218
|
+
const wrapped = `${prefix}${sel.text || 'text'}${suffix}`;
|
|
219
|
+
const newValue = `${before}${wrapped}${after}`;
|
|
220
|
+
setValue(newValue);
|
|
221
|
+
|
|
222
|
+
requestAnimationFrame(() => {
|
|
223
|
+
textarea.focus();
|
|
224
|
+
const newStart = sel.start + prefix.length;
|
|
225
|
+
const newEnd = newStart + (sel.text || 'text').length;
|
|
226
|
+
textarea.setSelectionRange(newStart, newEnd);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function applyMarkdownFormat(
|
|
231
|
+
format: EditorFormat,
|
|
232
|
+
textarea: HTMLTextAreaElement,
|
|
233
|
+
setValue: (v: string) => void,
|
|
234
|
+
) {
|
|
235
|
+
switch (format) {
|
|
236
|
+
case 'bold':
|
|
237
|
+
wrapSelection(textarea, '**', '**', setValue);
|
|
238
|
+
break;
|
|
239
|
+
case 'italic':
|
|
240
|
+
wrapSelection(textarea, '*', '*', setValue);
|
|
241
|
+
break;
|
|
242
|
+
case 'strikethrough':
|
|
243
|
+
wrapSelection(textarea, '~~', '~~', setValue);
|
|
244
|
+
break;
|
|
245
|
+
case 'code':
|
|
246
|
+
wrapSelection(textarea, '`', '`', setValue);
|
|
247
|
+
break;
|
|
248
|
+
case 'link': {
|
|
249
|
+
const sel = getSelection(textarea);
|
|
250
|
+
const linkText = sel.text || 'link text';
|
|
251
|
+
const before = textarea.value.substring(0, sel.start);
|
|
252
|
+
const after = textarea.value.substring(sel.end);
|
|
253
|
+
const newValue = `${before}[${linkText}](url)${after}`;
|
|
254
|
+
setValue(newValue);
|
|
255
|
+
requestAnimationFrame(() => {
|
|
256
|
+
textarea.focus();
|
|
257
|
+
const urlStart = sel.start + linkText.length + 3;
|
|
258
|
+
textarea.setSelectionRange(urlStart, urlStart + 3);
|
|
259
|
+
});
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
case 'bulletList': {
|
|
263
|
+
const sel = getSelection(textarea);
|
|
264
|
+
const before = textarea.value.substring(0, sel.start);
|
|
265
|
+
const after = textarea.value.substring(sel.end);
|
|
266
|
+
const lines = (sel.text || 'item').split('\n');
|
|
267
|
+
const bulleted = lines.map((l) => `- ${l}`).join('\n');
|
|
268
|
+
const newValue = `${before}${bulleted}${after}`;
|
|
269
|
+
setValue(newValue);
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
case 'orderedList': {
|
|
273
|
+
const sel = getSelection(textarea);
|
|
274
|
+
const before = textarea.value.substring(0, sel.start);
|
|
275
|
+
const after = textarea.value.substring(sel.end);
|
|
276
|
+
const lines = (sel.text || 'item').split('\n');
|
|
277
|
+
const numbered = lines.map((l, i) => `${i + 1}. ${l}`).join('\n');
|
|
278
|
+
const newValue = `${before}${numbered}${after}`;
|
|
279
|
+
setValue(newValue);
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
case 'heading1':
|
|
283
|
+
wrapSelection(textarea, '# ', '', setValue);
|
|
284
|
+
break;
|
|
285
|
+
case 'heading2':
|
|
286
|
+
wrapSelection(textarea, '## ', '', setValue);
|
|
287
|
+
break;
|
|
288
|
+
case 'heading3':
|
|
289
|
+
wrapSelection(textarea, '### ', '', setValue);
|
|
290
|
+
break;
|
|
291
|
+
case 'blockquote': {
|
|
292
|
+
const sel = getSelection(textarea);
|
|
293
|
+
const before = textarea.value.substring(0, sel.start);
|
|
294
|
+
const after = textarea.value.substring(sel.end);
|
|
295
|
+
const lines = (sel.text || 'quote').split('\n');
|
|
296
|
+
const quoted = lines.map((l) => `> ${l}`).join('\n');
|
|
297
|
+
const newValue = `${before}${quoted}${after}`;
|
|
298
|
+
setValue(newValue);
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
case 'undo':
|
|
302
|
+
case 'redo':
|
|
303
|
+
// Undo/redo in textarea mode is handled natively by the browser
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// ============================================
|
|
309
|
+
// Context
|
|
310
|
+
// ============================================
|
|
311
|
+
|
|
312
|
+
interface EditorContextValue {
|
|
313
|
+
value: string;
|
|
314
|
+
setValue: (v: string) => void;
|
|
315
|
+
placeholder: string;
|
|
316
|
+
disabled: boolean;
|
|
317
|
+
readOnly: boolean;
|
|
318
|
+
formats: EditorFormat[];
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
320
|
+
editor: any | null;
|
|
321
|
+
mode: EditorMode;
|
|
322
|
+
size: EditorSize;
|
|
323
|
+
maxLength?: number;
|
|
324
|
+
toolbarIcons?: EditorToolbarIcons;
|
|
325
|
+
wordCount: number;
|
|
326
|
+
charCount: number;
|
|
327
|
+
toggleFormat: (f: EditorFormat) => void;
|
|
328
|
+
isFormatActive: (f: EditorFormat) => boolean;
|
|
329
|
+
saveStatus: EditorSaveStatus;
|
|
330
|
+
contentRef: React.RefObject<HTMLTextAreaElement | null>;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const EditorContext = React.createContext<EditorContextValue | null>(null);
|
|
334
|
+
|
|
335
|
+
function useEditorContext() {
|
|
336
|
+
const context = React.useContext(EditorContext);
|
|
337
|
+
if (!context) {
|
|
338
|
+
throw new Error('Editor compound components must be used within an Editor');
|
|
339
|
+
}
|
|
340
|
+
return context;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// ============================================
|
|
344
|
+
// Hooks
|
|
345
|
+
// ============================================
|
|
346
|
+
|
|
347
|
+
function useControllableState<T>(
|
|
348
|
+
controlledValue: T | undefined,
|
|
349
|
+
defaultValue: T,
|
|
350
|
+
onChange?: (value: T) => void,
|
|
351
|
+
): [T, (value: T) => void] {
|
|
352
|
+
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);
|
|
353
|
+
const isControlled = controlledValue !== undefined;
|
|
354
|
+
const value = isControlled ? controlledValue : uncontrolledValue;
|
|
355
|
+
|
|
356
|
+
const setValue = React.useCallback(
|
|
357
|
+
(newValue: T) => {
|
|
358
|
+
if (!isControlled) {
|
|
359
|
+
setUncontrolledValue(newValue);
|
|
360
|
+
}
|
|
361
|
+
onChange?.(newValue);
|
|
362
|
+
},
|
|
363
|
+
[isControlled, onChange],
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
return [value, setValue];
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function countWords(text: string): number {
|
|
370
|
+
const trimmed = text.trim();
|
|
371
|
+
if (!trimmed) return 0;
|
|
372
|
+
return trimmed.split(/\s+/).length;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ============================================
|
|
376
|
+
// Components
|
|
377
|
+
// ============================================
|
|
378
|
+
|
|
379
|
+
function EditorRoot({
|
|
380
|
+
children,
|
|
381
|
+
value: controlledValue,
|
|
382
|
+
defaultValue = '',
|
|
383
|
+
onValueChange,
|
|
384
|
+
placeholder = 'Start typing...',
|
|
385
|
+
disabled = false,
|
|
386
|
+
readOnly = false,
|
|
387
|
+
formats = DEFAULT_FORMATS,
|
|
388
|
+
toolbar = true,
|
|
389
|
+
statusBar = true,
|
|
390
|
+
onAutoSave,
|
|
391
|
+
autoSaveInterval = 30000,
|
|
392
|
+
size = 'md',
|
|
393
|
+
maxLength,
|
|
394
|
+
toolbarIcons,
|
|
395
|
+
className,
|
|
396
|
+
...htmlProps
|
|
397
|
+
}: EditorProps) {
|
|
398
|
+
const contentRef = React.useRef<HTMLTextAreaElement>(null);
|
|
399
|
+
|
|
400
|
+
const [value, setValue] = useControllableState(
|
|
401
|
+
controlledValue,
|
|
402
|
+
defaultValue,
|
|
403
|
+
onValueChange,
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
const [saveStatus, setSaveStatus] = React.useState<EditorSaveStatus>('idle');
|
|
407
|
+
|
|
408
|
+
// Try loading TipTap
|
|
409
|
+
loadTipTapDeps();
|
|
410
|
+
const hasTipTap = !_tiptapFailed && _useEditor && _EditorContent && _StarterKit;
|
|
411
|
+
const mode: EditorMode = hasTipTap ? 'rich' : 'markdown';
|
|
412
|
+
|
|
413
|
+
// TipTap editor instance (only when available)
|
|
414
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
415
|
+
const tiptapEditor: any = hasTipTap
|
|
416
|
+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
417
|
+
(_useEditor as any)({
|
|
418
|
+
extensions: [
|
|
419
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
420
|
+
(_StarterKit as any).configure({
|
|
421
|
+
heading: { levels: [1, 2, 3] },
|
|
422
|
+
blockquote: {},
|
|
423
|
+
codeBlock: false,
|
|
424
|
+
horizontalRule: false,
|
|
425
|
+
hardBreak: false,
|
|
426
|
+
}),
|
|
427
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
428
|
+
(_LinkExtension as any).configure({
|
|
429
|
+
openOnClick: false,
|
|
430
|
+
HTMLAttributes: { rel: 'noopener noreferrer', target: '_blank' },
|
|
431
|
+
}),
|
|
432
|
+
],
|
|
433
|
+
editorProps: {
|
|
434
|
+
attributes: {
|
|
435
|
+
role: 'textbox',
|
|
436
|
+
'aria-label': placeholder,
|
|
437
|
+
'aria-multiline': 'true',
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
content: controlledValue !== undefined ? controlledValue : defaultValue,
|
|
441
|
+
editable: !disabled && !readOnly,
|
|
442
|
+
onUpdate: ({ editor: e }: { editor: { getHTML: () => string } }) => {
|
|
443
|
+
const html = e.getHTML();
|
|
444
|
+
setValue(html);
|
|
445
|
+
},
|
|
446
|
+
})
|
|
447
|
+
: null;
|
|
448
|
+
|
|
449
|
+
// Sync controlled value to TipTap
|
|
450
|
+
React.useEffect(() => {
|
|
451
|
+
if (tiptapEditor && controlledValue !== undefined) {
|
|
452
|
+
const currentContent = tiptapEditor.getHTML();
|
|
453
|
+
if (currentContent !== controlledValue) {
|
|
454
|
+
tiptapEditor.commands.setContent(controlledValue, false);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}, [controlledValue, tiptapEditor]);
|
|
458
|
+
|
|
459
|
+
// Update editable state
|
|
460
|
+
React.useEffect(() => {
|
|
461
|
+
if (tiptapEditor) {
|
|
462
|
+
tiptapEditor.setEditable(!disabled && !readOnly);
|
|
463
|
+
}
|
|
464
|
+
}, [tiptapEditor, disabled, readOnly]);
|
|
465
|
+
|
|
466
|
+
// Auto-save
|
|
467
|
+
React.useEffect(() => {
|
|
468
|
+
if (!onAutoSave || !value) return;
|
|
469
|
+
|
|
470
|
+
let cancelled = false;
|
|
471
|
+
const timer = setTimeout(() => {
|
|
472
|
+
setSaveStatus('saving');
|
|
473
|
+
try {
|
|
474
|
+
Promise.resolve(onAutoSave(value))
|
|
475
|
+
.then(() => {
|
|
476
|
+
if (!cancelled) {
|
|
477
|
+
setSaveStatus('saved');
|
|
478
|
+
}
|
|
479
|
+
})
|
|
480
|
+
.catch(() => {
|
|
481
|
+
if (!cancelled) {
|
|
482
|
+
setSaveStatus('error');
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
} catch {
|
|
486
|
+
if (!cancelled) {
|
|
487
|
+
setSaveStatus('error');
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}, autoSaveInterval);
|
|
491
|
+
|
|
492
|
+
return () => {
|
|
493
|
+
cancelled = true;
|
|
494
|
+
clearTimeout(timer);
|
|
495
|
+
};
|
|
496
|
+
}, [value, onAutoSave, autoSaveInterval]);
|
|
497
|
+
|
|
498
|
+
const toggleFormat = React.useCallback(
|
|
499
|
+
(format: EditorFormat) => {
|
|
500
|
+
if (disabled || readOnly) return;
|
|
501
|
+
|
|
502
|
+
if (tiptapEditor) {
|
|
503
|
+
switch (format) {
|
|
504
|
+
case 'bold':
|
|
505
|
+
tiptapEditor.chain().focus().toggleBold().run();
|
|
506
|
+
break;
|
|
507
|
+
case 'italic':
|
|
508
|
+
tiptapEditor.chain().focus().toggleItalic().run();
|
|
509
|
+
break;
|
|
510
|
+
case 'strikethrough':
|
|
511
|
+
tiptapEditor.chain().focus().toggleStrike().run();
|
|
512
|
+
break;
|
|
513
|
+
case 'code':
|
|
514
|
+
tiptapEditor.chain().focus().toggleCode().run();
|
|
515
|
+
break;
|
|
516
|
+
case 'bulletList':
|
|
517
|
+
tiptapEditor.chain().focus().toggleBulletList().run();
|
|
518
|
+
break;
|
|
519
|
+
case 'orderedList':
|
|
520
|
+
tiptapEditor.chain().focus().toggleOrderedList().run();
|
|
521
|
+
break;
|
|
522
|
+
case 'heading1':
|
|
523
|
+
tiptapEditor.chain().focus().toggleHeading({ level: 1 }).run();
|
|
524
|
+
break;
|
|
525
|
+
case 'heading2':
|
|
526
|
+
tiptapEditor.chain().focus().toggleHeading({ level: 2 }).run();
|
|
527
|
+
break;
|
|
528
|
+
case 'heading3':
|
|
529
|
+
tiptapEditor.chain().focus().toggleHeading({ level: 3 }).run();
|
|
530
|
+
break;
|
|
531
|
+
case 'blockquote':
|
|
532
|
+
tiptapEditor.chain().focus().toggleBlockquote().run();
|
|
533
|
+
break;
|
|
534
|
+
case 'undo':
|
|
535
|
+
tiptapEditor.chain().focus().undo().run();
|
|
536
|
+
break;
|
|
537
|
+
case 'redo':
|
|
538
|
+
tiptapEditor.chain().focus().redo().run();
|
|
539
|
+
break;
|
|
540
|
+
case 'link': {
|
|
541
|
+
const previousUrl = tiptapEditor.getAttributes('link').href;
|
|
542
|
+
if (previousUrl) {
|
|
543
|
+
tiptapEditor.chain().focus().unsetLink().run();
|
|
544
|
+
} else {
|
|
545
|
+
const url = window.prompt('Enter URL');
|
|
546
|
+
if (url) {
|
|
547
|
+
tiptapEditor.chain().focus().setLink({ href: url }).run();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
} else if (contentRef.current) {
|
|
554
|
+
applyMarkdownFormat(format, contentRef.current, setValue);
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
[disabled, readOnly, tiptapEditor, setValue],
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
const isFormatActive = React.useCallback(
|
|
561
|
+
(format: EditorFormat): boolean => {
|
|
562
|
+
if (!tiptapEditor) return false;
|
|
563
|
+
switch (format) {
|
|
564
|
+
case 'bold':
|
|
565
|
+
return tiptapEditor.isActive('bold');
|
|
566
|
+
case 'italic':
|
|
567
|
+
return tiptapEditor.isActive('italic');
|
|
568
|
+
case 'strikethrough':
|
|
569
|
+
return tiptapEditor.isActive('strike');
|
|
570
|
+
case 'code':
|
|
571
|
+
return tiptapEditor.isActive('code');
|
|
572
|
+
case 'bulletList':
|
|
573
|
+
return tiptapEditor.isActive('bulletList');
|
|
574
|
+
case 'orderedList':
|
|
575
|
+
return tiptapEditor.isActive('orderedList');
|
|
576
|
+
case 'heading1':
|
|
577
|
+
return tiptapEditor.isActive('heading', { level: 1 });
|
|
578
|
+
case 'heading2':
|
|
579
|
+
return tiptapEditor.isActive('heading', { level: 2 });
|
|
580
|
+
case 'heading3':
|
|
581
|
+
return tiptapEditor.isActive('heading', { level: 3 });
|
|
582
|
+
case 'blockquote':
|
|
583
|
+
return tiptapEditor.isActive('blockquote');
|
|
584
|
+
case 'link':
|
|
585
|
+
return tiptapEditor.isActive('link');
|
|
586
|
+
case 'undo':
|
|
587
|
+
case 'redo':
|
|
588
|
+
return false; // Actions don't have active state
|
|
589
|
+
default:
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
[tiptapEditor],
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
const wordCount = React.useMemo(() => {
|
|
597
|
+
if (tiptapEditor) {
|
|
598
|
+
const text = tiptapEditor.getText?.() ?? '';
|
|
599
|
+
return countWords(text);
|
|
600
|
+
}
|
|
601
|
+
return countWords(value);
|
|
602
|
+
}, [value, tiptapEditor]);
|
|
603
|
+
|
|
604
|
+
const charCount = React.useMemo(() => {
|
|
605
|
+
if (tiptapEditor) {
|
|
606
|
+
return (tiptapEditor.getText?.() ?? '').length;
|
|
607
|
+
}
|
|
608
|
+
return value.length;
|
|
609
|
+
}, [value, tiptapEditor]);
|
|
610
|
+
|
|
611
|
+
const contextValue: EditorContextValue = {
|
|
612
|
+
value,
|
|
613
|
+
setValue,
|
|
614
|
+
placeholder,
|
|
615
|
+
disabled,
|
|
616
|
+
readOnly,
|
|
617
|
+
formats,
|
|
618
|
+
editor: tiptapEditor,
|
|
619
|
+
mode,
|
|
620
|
+
size,
|
|
621
|
+
maxLength,
|
|
622
|
+
toolbarIcons,
|
|
623
|
+
wordCount,
|
|
624
|
+
charCount,
|
|
625
|
+
toggleFormat,
|
|
626
|
+
isFormatActive,
|
|
627
|
+
saveStatus,
|
|
628
|
+
contentRef,
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
const classes = [
|
|
632
|
+
styles.editor,
|
|
633
|
+
disabled && styles.disabled,
|
|
634
|
+
readOnly && styles.readOnly,
|
|
635
|
+
className,
|
|
636
|
+
].filter(Boolean).join(' ');
|
|
637
|
+
|
|
638
|
+
const hasCustomChildren = children !== undefined;
|
|
639
|
+
|
|
640
|
+
return (
|
|
641
|
+
<EditorContext.Provider value={contextValue}>
|
|
642
|
+
<div
|
|
643
|
+
{...htmlProps}
|
|
644
|
+
className={classes}
|
|
645
|
+
data-disabled={disabled || undefined}
|
|
646
|
+
data-readonly={readOnly || undefined}
|
|
647
|
+
data-size={size}
|
|
648
|
+
>
|
|
649
|
+
{hasCustomChildren ? (
|
|
650
|
+
children
|
|
651
|
+
) : (
|
|
652
|
+
<>
|
|
653
|
+
{toolbar && (
|
|
654
|
+
<EditorToolbar>
|
|
655
|
+
<EditorToolbarGroup aria-label="Text formatting">
|
|
656
|
+
{formats.map((f) => (
|
|
657
|
+
<EditorToolbarButton key={f} format={f} />
|
|
658
|
+
))}
|
|
659
|
+
</EditorToolbarGroup>
|
|
660
|
+
</EditorToolbar>
|
|
661
|
+
)}
|
|
662
|
+
<EditorContentArea />
|
|
663
|
+
{statusBar && <EditorStatusBar showWordCount showCharCount />}
|
|
664
|
+
</>
|
|
665
|
+
)}
|
|
666
|
+
</div>
|
|
667
|
+
</EditorContext.Provider>
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function EditorToolbar({ children, className }: EditorToolbarProps) {
|
|
672
|
+
const classes = [styles.toolbar, className].filter(Boolean).join(' ');
|
|
673
|
+
return (
|
|
674
|
+
<div className={classes} role="toolbar" aria-label="Editor formatting">
|
|
675
|
+
{children}
|
|
676
|
+
</div>
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function EditorToolbarGroup({ children, 'aria-label': ariaLabel, className }: EditorToolbarGroupProps) {
|
|
681
|
+
const classes = [styles.toolbarGroup, className].filter(Boolean).join(' ');
|
|
682
|
+
return (
|
|
683
|
+
<div className={classes} role="group" aria-label={ariaLabel}>
|
|
684
|
+
{children}
|
|
685
|
+
</div>
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function EditorToolbarButton({ format, className }: EditorToolbarButtonProps) {
|
|
690
|
+
const { toggleFormat, isFormatActive, disabled, readOnly, editor, mode, toolbarIcons } = useEditorContext();
|
|
691
|
+
const meta = FORMAT_META[format];
|
|
692
|
+
const isAction = ACTION_FORMATS.has(format);
|
|
693
|
+
const active = isAction ? false : isFormatActive(format);
|
|
694
|
+
const IconComponent = meta.icon;
|
|
695
|
+
|
|
696
|
+
// Action buttons (undo/redo) have special disable logic
|
|
697
|
+
let isDisabled = disabled || readOnly;
|
|
698
|
+
if (isAction && !isDisabled) {
|
|
699
|
+
if (mode === 'markdown') {
|
|
700
|
+
// Undo/redo in textarea mode is handled natively by the browser
|
|
701
|
+
isDisabled = true;
|
|
702
|
+
} else if (editor) {
|
|
703
|
+
isDisabled = format === 'undo' ? !editor.can().undo() : !editor.can().redo();
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
const iconState: EditorToolbarIconRenderState = {
|
|
708
|
+
format,
|
|
709
|
+
active,
|
|
710
|
+
disabled,
|
|
711
|
+
readOnly,
|
|
712
|
+
isDisabled,
|
|
713
|
+
mode,
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
const iconOverride = toolbarIcons?.[format];
|
|
717
|
+
const renderedOverride = typeof iconOverride === 'function'
|
|
718
|
+
? iconOverride(iconState)
|
|
719
|
+
: iconOverride;
|
|
720
|
+
|
|
721
|
+
const classes = [
|
|
722
|
+
styles.toolbarButton,
|
|
723
|
+
active && styles.toolbarButtonActive,
|
|
724
|
+
className,
|
|
725
|
+
].filter(Boolean).join(' ');
|
|
726
|
+
|
|
727
|
+
return (
|
|
728
|
+
<button
|
|
729
|
+
type="button"
|
|
730
|
+
className={classes}
|
|
731
|
+
onClick={() => toggleFormat(format)}
|
|
732
|
+
disabled={isDisabled}
|
|
733
|
+
aria-label={meta.label}
|
|
734
|
+
title={`${meta.label} (${meta.shortcut})`}
|
|
735
|
+
{...(isAction ? {} : { 'aria-pressed': active })}
|
|
736
|
+
>
|
|
737
|
+
{iconOverride !== undefined
|
|
738
|
+
? renderedOverride
|
|
739
|
+
: <IconComponent size={16} weight={active ? 'bold' : 'regular'} />}
|
|
740
|
+
</button>
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
function EditorSeparator({ className }: EditorSeparatorProps) {
|
|
745
|
+
const classes = [styles.separator, className].filter(Boolean).join(' ');
|
|
746
|
+
return <div className={classes} role="separator" aria-orientation="vertical" />;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
function EditorStatusIndicator({ status: statusOverride, labels, className }: EditorStatusIndicatorProps) {
|
|
750
|
+
const { saveStatus } = useEditorContext();
|
|
751
|
+
const status = statusOverride ?? saveStatus;
|
|
752
|
+
const mergedLabels = { ...DEFAULT_STATUS_LABELS, ...labels };
|
|
753
|
+
const label = mergedLabels[status];
|
|
754
|
+
|
|
755
|
+
if (!label) return null;
|
|
756
|
+
|
|
757
|
+
const classes = [
|
|
758
|
+
styles.statusIndicator,
|
|
759
|
+
status === 'error' && styles.statusError,
|
|
760
|
+
className,
|
|
761
|
+
].filter(Boolean).join(' ');
|
|
762
|
+
|
|
763
|
+
return (
|
|
764
|
+
<span className={classes} aria-live="polite" role="status">
|
|
765
|
+
{label}
|
|
766
|
+
</span>
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
function EditorContentArea({ className }: EditorContentProps) {
|
|
771
|
+
const { value, setValue, placeholder, disabled, readOnly, editor, mode, contentRef } =
|
|
772
|
+
useEditorContext();
|
|
773
|
+
|
|
774
|
+
if (mode === 'rich' && editor && _EditorContent) {
|
|
775
|
+
const TipTapContent = _EditorContent;
|
|
776
|
+
const classes = [styles.content, styles.contentRich, className].filter(Boolean).join(' ');
|
|
777
|
+
return (
|
|
778
|
+
<div className={classes} data-placeholder={placeholder}>
|
|
779
|
+
<TipTapContent editor={editor} />
|
|
780
|
+
</div>
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// Textarea fallback for markdown mode
|
|
785
|
+
const classes = [styles.content, className].filter(Boolean).join(' ');
|
|
786
|
+
return (
|
|
787
|
+
<div className={classes}>
|
|
788
|
+
<textarea
|
|
789
|
+
ref={contentRef}
|
|
790
|
+
className={styles.contentTextarea}
|
|
791
|
+
value={value}
|
|
792
|
+
onChange={(e) => setValue(e.target.value)}
|
|
793
|
+
placeholder={placeholder}
|
|
794
|
+
disabled={disabled}
|
|
795
|
+
readOnly={readOnly}
|
|
796
|
+
aria-label={placeholder}
|
|
797
|
+
/>
|
|
798
|
+
</div>
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function EditorStatusBar({ showWordCount = true, showCharCount = true, className }: EditorStatusBarProps) {
|
|
803
|
+
const { wordCount, charCount, maxLength } = useEditorContext();
|
|
804
|
+
|
|
805
|
+
const classes = [styles.statusBar, className].filter(Boolean).join(' ');
|
|
806
|
+
|
|
807
|
+
const isOverLimit = maxLength !== undefined && charCount > maxLength;
|
|
808
|
+
const isNearLimit = maxLength !== undefined && !isOverLimit && charCount >= maxLength * 0.9;
|
|
809
|
+
|
|
810
|
+
const charLimitClasses = [
|
|
811
|
+
styles.statusBarItem,
|
|
812
|
+
isNearLimit && styles.statusBarItemWarning,
|
|
813
|
+
isOverLimit && styles.statusBarItemError,
|
|
814
|
+
].filter(Boolean).join(' ');
|
|
815
|
+
|
|
816
|
+
return (
|
|
817
|
+
<div className={classes} aria-label="Editor statistics">
|
|
818
|
+
<div className={styles.statusBarLeft} />
|
|
819
|
+
<div className={styles.statusBarRight}>
|
|
820
|
+
{showWordCount && (
|
|
821
|
+
<span className={styles.statusBarItem}>
|
|
822
|
+
{wordCount} {wordCount === 1 ? 'Word' : 'Words'}
|
|
823
|
+
</span>
|
|
824
|
+
)}
|
|
825
|
+
{showWordCount && showCharCount && (
|
|
826
|
+
<EditorSeparator />
|
|
827
|
+
)}
|
|
828
|
+
{showCharCount && (
|
|
829
|
+
<span className={charLimitClasses}>
|
|
830
|
+
{maxLength !== undefined
|
|
831
|
+
? `${charCount} / ${maxLength}`
|
|
832
|
+
: `${charCount} ${charCount === 1 ? 'Character' : 'Characters'}`
|
|
833
|
+
}
|
|
834
|
+
</span>
|
|
835
|
+
)}
|
|
836
|
+
</div>
|
|
837
|
+
</div>
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// ============================================
|
|
842
|
+
// Export compound component
|
|
843
|
+
// ============================================
|
|
844
|
+
|
|
845
|
+
export const Editor = Object.assign(EditorRoot, {
|
|
846
|
+
Toolbar: EditorToolbar,
|
|
847
|
+
ToolbarGroup: EditorToolbarGroup,
|
|
848
|
+
ToolbarButton: EditorToolbarButton,
|
|
849
|
+
Separator: EditorSeparator,
|
|
850
|
+
StatusIndicator: EditorStatusIndicator,
|
|
851
|
+
Content: EditorContentArea,
|
|
852
|
+
StatusBar: EditorStatusBar,
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
export {
|
|
856
|
+
EditorRoot,
|
|
857
|
+
EditorToolbar,
|
|
858
|
+
EditorToolbarGroup,
|
|
859
|
+
EditorToolbarButton,
|
|
860
|
+
EditorSeparator,
|
|
861
|
+
EditorStatusIndicator,
|
|
862
|
+
EditorContentArea,
|
|
863
|
+
EditorStatusBar,
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
export { useEditorContext };
|