@usefragments/ui 1.6.0 → 2.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/README.md +54 -66
- package/dist/assets/fragments-wordmark.cjs +2 -2
- package/dist/assets/fragments-wordmark.d.ts.map +1 -1
- package/dist/assets/fragments-wordmark.js +2 -2
- package/dist/assets/nav-glyph.cjs +139 -0
- package/dist/assets/nav-glyph.d.ts +28 -0
- package/dist/assets/nav-glyph.d.ts.map +1 -0
- package/dist/assets/nav-glyph.js +139 -0
- package/dist/assets/nav-glyph.module.scss.cjs +71 -0
- package/dist/assets/nav-glyph.module.scss.js +71 -0
- package/dist/assets/ui.css +6885 -6308
- package/dist/blocks/components/StatsCard.d.ts +1 -1
- package/dist/blocks/components/StatsCard.d.ts.map +1 -1
- package/dist/chart.cjs +24 -6
- package/dist/chart.js +24 -6
- package/dist/codeblock.cjs +76 -43
- package/dist/codeblock.js +71 -38
- package/dist/colorpicker.cjs +4 -1
- package/dist/colorpicker.js +4 -1
- package/dist/components/Accordion/Accordion.module.scss.cjs +8 -8
- package/dist/components/Accordion/Accordion.module.scss.js +8 -8
- package/dist/components/Alert/Alert.module.scss.cjs +23 -20
- package/dist/components/Alert/Alert.module.scss.js +23 -20
- package/dist/components/Alert/index.cjs +20 -8
- package/dist/components/Alert/index.d.ts +17 -11
- package/dist/components/Alert/index.d.ts.map +1 -1
- package/dist/components/Alert/index.js +20 -8
- package/dist/components/AppShell/AppShell.module.scss.cjs +14 -14
- package/dist/components/AppShell/AppShell.module.scss.js +14 -14
- package/dist/components/AppShell/index.cjs +2 -2
- package/dist/components/AppShell/index.js +2 -2
- package/dist/components/Avatar/Avatar.module.scss.cjs +14 -14
- package/dist/components/Avatar/Avatar.module.scss.js +14 -14
- package/dist/components/Badge/Badge.module.scss.cjs +33 -31
- package/dist/components/Badge/Badge.module.scss.js +33 -31
- package/dist/components/Badge/index.cjs +13 -3
- package/dist/components/Badge/index.d.ts +18 -13
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js +13 -3
- package/dist/components/BentoGrid/BentoGrid.module.scss.cjs +14 -14
- package/dist/components/BentoGrid/BentoGrid.module.scss.js +14 -14
- package/dist/components/Box/Box.module.scss.cjs +152 -152
- package/dist/components/Box/Box.module.scss.js +152 -152
- package/dist/components/Box/index.cjs +64 -75
- package/dist/components/Box/index.d.ts +16 -16
- package/dist/components/Box/index.d.ts.map +1 -1
- package/dist/components/Box/index.js +64 -75
- package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.cjs +11 -8
- package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.js +11 -8
- package/dist/components/Breadcrumbs/index.cjs +1 -1
- package/dist/components/Breadcrumbs/index.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/index.js +1 -1
- package/dist/components/Button/Button.module.scss.cjs +36 -27
- package/dist/components/Button/Button.module.scss.js +36 -27
- package/dist/components/Button/index.cjs +20 -4
- package/dist/components/Button/index.d.ts +18 -10
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +20 -4
- package/dist/components/ButtonGroup/ButtonGroup.module.scss.cjs +15 -15
- package/dist/components/ButtonGroup/ButtonGroup.module.scss.js +15 -15
- package/dist/components/Card/Card.module.scss.cjs +31 -26
- package/dist/components/Card/Card.module.scss.js +32 -27
- package/dist/components/Card/index.cjs +16 -3
- package/dist/components/Card/index.d.ts +23 -15
- package/dist/components/Card/index.d.ts.map +1 -1
- package/dist/components/Card/index.js +16 -3
- package/dist/components/Chart/Chart.module.scss.cjs +15 -15
- package/dist/components/Chart/Chart.module.scss.js +15 -15
- package/dist/components/Chart/index.d.ts.map +1 -1
- package/dist/components/Checkbox/Checkbox.module.scss.cjs +11 -11
- package/dist/components/Checkbox/Checkbox.module.scss.js +11 -11
- package/dist/components/Checkbox/index.cjs +4 -4
- package/dist/components/Checkbox/index.d.ts +4 -6
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +4 -4
- package/dist/components/Chip/Chip.module.scss.cjs +19 -19
- package/dist/components/Chip/Chip.module.scss.js +19 -19
- package/dist/components/Chip/index.cjs +3 -3
- package/dist/components/Chip/index.d.ts +8 -3
- package/dist/components/Chip/index.d.ts.map +1 -1
- package/dist/components/Chip/index.js +3 -3
- package/dist/components/CodeBlock/CodeBlock.module.scss.cjs +26 -23
- package/dist/components/CodeBlock/CodeBlock.module.scss.js +26 -23
- package/dist/components/CodeBlock/css-variables-theme.cjs +98 -0
- package/dist/components/CodeBlock/css-variables-theme.d.ts +27 -0
- package/dist/components/CodeBlock/css-variables-theme.d.ts.map +1 -0
- package/dist/components/CodeBlock/css-variables-theme.js +98 -0
- package/dist/components/CodeBlock/index.d.ts +20 -5
- package/dist/components/CodeBlock/index.d.ts.map +1 -1
- package/dist/components/Collapsible/Collapsible.module.scss.cjs +9 -9
- package/dist/components/Collapsible/Collapsible.module.scss.js +9 -9
- package/dist/components/ColorPicker/ColorPicker.module.scss.cjs +14 -14
- package/dist/components/ColorPicker/ColorPicker.module.scss.js +14 -14
- package/dist/components/ColorPicker/index.d.ts.map +1 -1
- package/dist/components/Combobox/Combobox.module.scss.cjs +21 -21
- package/dist/components/Combobox/Combobox.module.scss.js +21 -21
- package/dist/components/Combobox/index.cjs +26 -6
- package/dist/components/Combobox/index.d.ts.map +1 -1
- package/dist/components/Combobox/index.js +26 -6
- package/dist/components/Command/Command.module.scss.cjs +14 -11
- package/dist/components/Command/Command.module.scss.js +14 -11
- package/dist/components/Command/index.cjs +28 -16
- package/dist/components/Command/index.d.ts +8 -3
- package/dist/components/Command/index.d.ts.map +1 -1
- package/dist/components/Command/index.js +28 -16
- package/dist/components/ConversationList/ConversationList.module.scss.cjs +10 -10
- package/dist/components/ConversationList/ConversationList.module.scss.js +10 -10
- package/dist/components/ConversationList/index.cjs +2 -2
- package/dist/components/ConversationList/index.js +2 -2
- package/dist/components/DataTable/DataTable.icons.cjs +6 -33
- package/dist/components/DataTable/DataTable.icons.d.ts.map +1 -1
- package/dist/components/DataTable/DataTable.icons.js +6 -33
- package/dist/components/DataTable/DataTable.module.scss.cjs +31 -28
- package/dist/components/DataTable/DataTable.module.scss.js +31 -28
- package/dist/components/DataTable/DataTable.virtual.d.ts.map +1 -1
- package/dist/components/DataTable/index.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.module.scss.cjs +33 -33
- package/dist/components/DatePicker/DatePicker.module.scss.js +33 -33
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/Dialog/Dialog.module.scss.cjs +14 -14
- package/dist/components/Dialog/Dialog.module.scss.js +14 -14
- package/dist/components/Dialog/index.cjs +13 -16
- package/dist/components/Dialog/index.d.ts +11 -10
- package/dist/components/Dialog/index.d.ts.map +1 -1
- package/dist/components/Dialog/index.js +13 -16
- package/dist/components/Drawer/Drawer.module.scss.cjs +39 -39
- package/dist/components/Drawer/Drawer.module.scss.js +40 -40
- package/dist/components/Drawer/index.cjs +2 -2
- package/dist/components/Drawer/index.d.ts +5 -4
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +2 -2
- package/dist/components/Editor/Editor.module.scss.cjs +17 -17
- package/dist/components/Editor/Editor.module.scss.js +17 -17
- package/dist/components/Editor/index.d.ts +10 -10
- package/dist/components/Editor/index.d.ts.map +1 -1
- package/dist/components/EmptyState/EmptyState.module.scss.cjs +11 -8
- package/dist/components/EmptyState/EmptyState.module.scss.js +11 -8
- package/dist/components/EmptyState/index.cjs +13 -6
- package/dist/components/EmptyState/index.d.ts +13 -5
- package/dist/components/EmptyState/index.d.ts.map +1 -1
- package/dist/components/EmptyState/index.js +13 -6
- package/dist/components/Field/Field.module.scss.cjs +5 -5
- package/dist/components/Field/Field.module.scss.js +5 -5
- package/dist/components/Field/index.cjs +9 -1
- package/dist/components/Field/index.d.ts.map +1 -1
- package/dist/components/Field/index.js +9 -1
- package/dist/components/Fieldset/Fieldset.module.scss.cjs +3 -3
- package/dist/components/Fieldset/Fieldset.module.scss.js +3 -3
- package/dist/components/Grid/Grid.module.scss.cjs +54 -54
- package/dist/components/Grid/Grid.module.scss.js +54 -54
- package/dist/components/Grid/index.cjs +1 -1
- package/dist/components/Grid/index.js +1 -1
- package/dist/components/Header/Header.module.scss.cjs +33 -33
- package/dist/components/Header/Header.module.scss.js +33 -33
- package/dist/components/Header/index.cjs +17 -38
- package/dist/components/Header/index.d.ts +15 -11
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +17 -38
- package/dist/components/Icon/Icon.module.scss.cjs +30 -33
- package/dist/components/Icon/Icon.module.scss.js +30 -33
- package/dist/components/Icon/index.cjs +15 -14
- package/dist/components/Icon/index.d.ts +23 -12
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +15 -14
- package/dist/components/IconButton/IconButton.module.scss.cjs +12 -12
- package/dist/components/IconButton/IconButton.module.scss.js +12 -12
- package/dist/components/IconButton/index.cjs +2 -1
- package/dist/components/IconButton/index.d.ts +4 -4
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/IconButton/index.js +2 -1
- package/dist/components/Image/Image.module.scss.cjs +27 -27
- package/dist/components/Image/Image.module.scss.js +27 -27
- package/dist/components/Input/Input.module.scss.cjs +15 -21
- package/dist/components/Input/Input.module.scss.js +15 -21
- package/dist/components/Input/index.cjs +2 -14
- package/dist/components/Input/index.d.ts +0 -2
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +2 -14
- package/dist/components/Link/Link.module.scss.cjs +26 -14
- package/dist/components/Link/Link.module.scss.js +26 -14
- package/dist/components/Link/index.cjs +13 -2
- package/dist/components/Link/index.d.ts +11 -4
- package/dist/components/Link/index.d.ts.map +1 -1
- package/dist/components/Link/index.js +13 -2
- package/dist/components/List/List.module.scss.cjs +23 -19
- package/dist/components/List/List.module.scss.js +23 -19
- package/dist/components/List/index.cjs +7 -7
- package/dist/components/List/index.d.ts +10 -7
- package/dist/components/List/index.d.ts.map +1 -1
- package/dist/components/List/index.js +7 -7
- package/dist/components/Listbox/Listbox.module.scss.cjs +8 -8
- package/dist/components/Listbox/Listbox.module.scss.js +8 -8
- package/dist/components/Loading/Loading.module.scss.cjs +34 -34
- package/dist/components/Loading/Loading.module.scss.js +34 -34
- package/dist/components/Loading/index.cjs +5 -5
- package/dist/components/Loading/index.d.ts +8 -7
- package/dist/components/Loading/index.d.ts.map +1 -1
- package/dist/components/Loading/index.js +5 -5
- package/dist/components/Markdown/Markdown.module.scss.cjs +1 -1
- package/dist/components/Markdown/Markdown.module.scss.js +1 -1
- package/dist/components/Markdown/index.d.ts +2 -2
- package/dist/components/Markdown/index.d.ts.map +1 -1
- package/dist/components/Menu/Menu.module.scss.cjs +14 -14
- package/dist/components/Menu/Menu.module.scss.js +14 -14
- package/dist/components/Message/Message.module.scss.cjs +20 -20
- package/dist/components/Message/Message.module.scss.js +20 -20
- package/dist/components/Message/index.cjs +1 -1
- package/dist/components/Message/index.d.ts +1 -1
- package/dist/components/Message/index.js +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.module.scss.cjs +34 -31
- package/dist/components/NavigationMenu/NavigationMenu.module.scss.js +34 -31
- package/dist/components/NavigationMenu/index.cjs +32 -15
- package/dist/components/NavigationMenu/index.d.ts +12 -6
- package/dist/components/NavigationMenu/index.d.ts.map +1 -1
- package/dist/components/NavigationMenu/index.js +32 -15
- package/dist/components/Pagination/Pagination.module.scss.cjs +10 -10
- package/dist/components/Pagination/Pagination.module.scss.js +10 -10
- package/dist/components/Popover/Popover.module.scss.cjs +10 -10
- package/dist/components/Popover/Popover.module.scss.js +10 -10
- package/dist/components/Progress/Progress.module.scss.cjs +28 -25
- package/dist/components/Progress/Progress.module.scss.js +28 -25
- package/dist/components/Progress/index.cjs +21 -12
- package/dist/components/Progress/index.d.ts +10 -6
- package/dist/components/Progress/index.d.ts.map +1 -1
- package/dist/components/Progress/index.js +21 -12
- package/dist/components/Prompt/Prompt.module.scss.cjs +30 -30
- package/dist/components/Prompt/Prompt.module.scss.js +30 -30
- package/dist/components/Prompt/index.cjs +7 -7
- package/dist/components/Prompt/index.d.ts +11 -9
- package/dist/components/Prompt/index.d.ts.map +1 -1
- package/dist/components/Prompt/index.js +7 -7
- package/dist/components/RadioGroup/RadioGroup.module.scss.cjs +20 -17
- package/dist/components/RadioGroup/RadioGroup.module.scss.js +20 -17
- package/dist/components/RadioGroup/index.cjs +10 -5
- package/dist/components/RadioGroup/index.d.ts +11 -7
- package/dist/components/RadioGroup/index.d.ts.map +1 -1
- package/dist/components/RadioGroup/index.js +10 -5
- package/dist/components/ScrollArea/ScrollArea.module.scss.cjs +5 -5
- package/dist/components/ScrollArea/ScrollArea.module.scss.js +5 -5
- package/dist/components/ScrollArea/index.d.ts +4 -4
- package/dist/components/ScrollArea/index.d.ts.map +1 -1
- package/dist/components/ScrollArea/scroll-state.d.ts +5 -5
- package/dist/components/Select/Select.module.scss.cjs +21 -21
- package/dist/components/Select/Select.module.scss.js +21 -21
- package/dist/components/Select/index.cjs +26 -20
- package/dist/components/Select/index.d.ts +5 -5
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +26 -20
- package/dist/components/Separator/Separator.module.scss.cjs +25 -19
- package/dist/components/Separator/Separator.module.scss.js +25 -19
- package/dist/components/Separator/index.cjs +10 -8
- package/dist/components/Separator/index.d.ts +4 -2
- package/dist/components/Separator/index.d.ts.map +1 -1
- package/dist/components/Separator/index.js +10 -8
- package/dist/components/Sidebar/Sidebar.module.scss.cjs +43 -43
- package/dist/components/Sidebar/Sidebar.module.scss.js +43 -43
- package/dist/components/Sidebar/index.cjs +15 -38
- package/dist/components/Sidebar/index.d.ts +19 -19
- package/dist/components/Sidebar/index.d.ts.map +1 -1
- package/dist/components/Sidebar/index.js +15 -38
- package/dist/components/Skeleton/Skeleton.module.scss.cjs +50 -46
- package/dist/components/Skeleton/Skeleton.module.scss.js +50 -46
- package/dist/components/Skeleton/index.cjs +7 -7
- package/dist/components/Skeleton/index.d.ts +8 -7
- package/dist/components/Skeleton/index.d.ts.map +1 -1
- package/dist/components/Skeleton/index.js +7 -7
- package/dist/components/Slider/Slider.module.scss.cjs +12 -12
- package/dist/components/Slider/Slider.module.scss.js +12 -12
- package/dist/components/Stack/Stack.module.scss.cjs +25 -25
- package/dist/components/Stack/Stack.module.scss.js +25 -25
- package/dist/components/Stack/index.cjs +1 -1
- package/dist/components/Stack/index.js +1 -1
- package/dist/components/Switch/Switch.module.scss.cjs +9 -9
- package/dist/components/Switch/Switch.module.scss.js +9 -9
- package/dist/components/Table/Table.module.scss.cjs +19 -19
- package/dist/components/Table/Table.module.scss.js +19 -19
- package/dist/components/TableOfContents/TableOfContents.module.scss.cjs +15 -15
- package/dist/components/TableOfContents/TableOfContents.module.scss.js +15 -15
- package/dist/components/TableOfContents/index.cjs +14 -10
- package/dist/components/TableOfContents/index.d.ts +5 -3
- package/dist/components/TableOfContents/index.d.ts.map +1 -1
- package/dist/components/TableOfContents/index.js +14 -10
- package/dist/components/Tabs/Tabs.module.scss.cjs +18 -18
- package/dist/components/Tabs/Tabs.module.scss.js +18 -18
- package/dist/components/Tabs/index.cjs +30 -11
- package/dist/components/Tabs/index.d.ts +8 -6
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.js +30 -11
- package/dist/components/Text/Text.module.scss.cjs +109 -97
- package/dist/components/Text/Text.module.scss.js +109 -97
- package/dist/components/Text/index.cjs +45 -41
- package/dist/components/Text/index.d.ts +24 -19
- package/dist/components/Text/index.d.ts.map +1 -1
- package/dist/components/Text/index.js +45 -41
- package/dist/components/Textarea/Textarea.module.scss.cjs +22 -28
- package/dist/components/Textarea/Textarea.module.scss.js +22 -28
- package/dist/components/Textarea/index.cjs +3 -10
- package/dist/components/Textarea/index.d.ts +0 -2
- package/dist/components/Textarea/index.d.ts.map +1 -1
- package/dist/components/Textarea/index.js +3 -10
- package/dist/components/Theme/index.cjs +22 -5
- package/dist/components/Theme/index.d.ts +6 -12
- package/dist/components/Theme/index.d.ts.map +1 -1
- package/dist/components/Theme/index.js +22 -5
- package/dist/components/ThemeToggle/ThemeButton.cjs +51 -0
- package/dist/components/ThemeToggle/ThemeButton.d.ts +16 -0
- package/dist/components/ThemeToggle/ThemeButton.d.ts.map +1 -0
- package/dist/components/ThemeToggle/ThemeButton.js +34 -0
- package/dist/components/ThemeToggle/ThemeToggle.module.scss.cjs +6 -6
- package/dist/components/ThemeToggle/ThemeToggle.module.scss.js +6 -6
- package/dist/components/ThemeToggle/icons.cjs +48 -0
- package/dist/components/ThemeToggle/icons.d.ts +10 -0
- package/dist/components/ThemeToggle/icons.d.ts.map +1 -0
- package/dist/components/ThemeToggle/icons.js +48 -0
- package/dist/components/ThemeToggle/index.cjs +6 -50
- package/dist/components/ThemeToggle/index.d.ts +5 -3
- package/dist/components/ThemeToggle/index.d.ts.map +1 -1
- package/dist/components/ThemeToggle/index.js +3 -47
- package/dist/components/ThinkingIndicator/ThinkingIndicator.module.scss.cjs +18 -15
- package/dist/components/ThinkingIndicator/ThinkingIndicator.module.scss.js +18 -15
- package/dist/components/ThinkingIndicator/index.cjs +7 -8
- package/dist/components/ThinkingIndicator/index.d.ts +6 -5
- package/dist/components/ThinkingIndicator/index.d.ts.map +1 -1
- package/dist/components/ThinkingIndicator/index.js +7 -8
- package/dist/components/Toast/Toast.module.scss.cjs +28 -29
- package/dist/components/Toast/Toast.module.scss.js +29 -30
- package/dist/components/Toast/index.cjs +28 -30
- package/dist/components/Toast/index.d.ts +9 -8
- package/dist/components/Toast/index.d.ts.map +1 -1
- package/dist/components/Toast/index.js +28 -30
- package/dist/components/ToggleGroup/ToggleGroup.module.scss.cjs +21 -19
- package/dist/components/ToggleGroup/ToggleGroup.module.scss.js +22 -20
- package/dist/components/ToggleGroup/index.cjs +4 -5
- package/dist/components/ToggleGroup/index.d.ts +7 -6
- package/dist/components/ToggleGroup/index.d.ts.map +1 -1
- package/dist/components/ToggleGroup/index.js +4 -5
- package/dist/components/Tooltip/Tooltip.module.scss.cjs +3 -3
- package/dist/components/Tooltip/Tooltip.module.scss.js +3 -3
- package/dist/components/Tooltip/index.cjs +24 -40
- package/dist/components/Tooltip/index.d.ts +4 -4
- package/dist/components/Tooltip/index.d.ts.map +1 -1
- package/dist/components/Tooltip/index.js +24 -40
- package/dist/components/VisuallyHidden/VisuallyHidden.module.scss.cjs +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.module.scss.js +1 -1
- package/dist/components/VisuallyHidden/index.d.ts +2 -2
- package/dist/data-table-virtual.cjs +3 -2
- package/dist/data-table-virtual.js +3 -2
- package/dist/data-table.cjs +3 -2
- package/dist/data-table.js +3 -2
- package/dist/datepicker.cjs +26 -13
- package/dist/datepicker.js +26 -13
- package/dist/editor.cjs +68 -28
- package/dist/editor.js +68 -28
- package/dist/index.cjs +6 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/markdown.cjs +21 -29
- package/dist/markdown.js +21 -29
- package/dist/measurements/generated.cjs +46 -94
- package/dist/measurements/generated.d.ts +44 -92
- package/dist/measurements/generated.d.ts.map +1 -1
- package/dist/measurements/generated.js +46 -94
- package/dist/measurements/index.d.ts +1 -1
- package/dist/measurements/index.d.ts.map +1 -1
- package/dist/utils/a11y.cjs +5 -2
- package/dist/utils/a11y.d.ts +5 -5
- package/dist/utils/a11y.d.ts.map +1 -1
- package/dist/utils/a11y.js +5 -2
- package/dist/utils/canonical-stamp.cjs +2 -8
- package/dist/utils/canonical-stamp.d.ts.map +1 -1
- package/dist/utils/canonical-stamp.js +1 -7
- package/dist/utils/css-warning.cjs +1 -1
- package/dist/utils/css-warning.js +1 -1
- package/dist/utils/env.cjs +17 -0
- package/dist/utils/env.d.ts +3 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +17 -0
- package/dist/utils/keyboard-shortcuts.cjs +3 -10
- package/dist/utils/keyboard-shortcuts.d.ts +4 -4
- package/dist/utils/keyboard-shortcuts.d.ts.map +1 -1
- package/dist/utils/keyboard-shortcuts.js +3 -10
- package/dist/utils/seed-derivation.cjs +10 -7
- package/dist/utils/seed-derivation.d.ts +1 -3
- package/dist/utils/seed-derivation.d.ts.map +1 -1
- package/dist/utils/seed-derivation.js +10 -7
- package/dist/utils/theme-presets.cjs +5 -10
- package/dist/utils/theme-presets.d.ts +1 -2
- package/dist/utils/theme-presets.d.ts.map +1 -1
- package/dist/utils/theme-presets.js +5 -10
- package/fragments.json +1 -1
- package/package.json +9 -10
- package/src/assets/fragments-logo.tsx +2 -2
- package/src/assets/fragments-wordmark.tsx +4 -2
- package/src/assets/nav-glyph.module.scss +166 -0
- package/src/assets/nav-glyph.tsx +188 -0
- package/src/components/Accordion/Accordion.contract.json +24 -48
- package/src/components/Accordion/Accordion.module.scss +5 -3
- package/src/components/Alert/Alert.contract.json +49 -65
- package/src/components/Alert/Alert.module.scss +57 -47
- package/src/components/Alert/index.tsx +72 -39
- package/src/components/AppShell/AppShell.contract.json +34 -51
- package/src/components/AppShell/AppShell.module.scss +99 -54
- package/src/components/AppShell/index.tsx +2 -2
- package/src/components/Avatar/Avatar.contract.json +31 -48
- package/src/components/Avatar/Avatar.module.scss +4 -2
- package/src/components/Badge/Badge.contract.json +86 -55
- package/src/components/Badge/Badge.module.scss +80 -48
- package/src/components/Badge/index.tsx +34 -17
- package/src/components/BentoGrid/BentoGrid.contract.json +21 -45
- package/src/components/BentoGrid/BentoGrid.module.scss +4 -8
- package/src/components/Box/Box.contract.json +40 -148
- package/src/components/Box/Box.module.scss +7 -6
- package/src/components/Box/index.tsx +92 -99
- package/src/components/Breadcrumbs/Breadcrumbs.contract.json +21 -34
- package/src/components/Breadcrumbs/Breadcrumbs.module.scss +27 -12
- package/src/components/Breadcrumbs/index.tsx +5 -1
- package/src/components/Button/Button.module.scss +261 -185
- package/src/components/Button/index.tsx +41 -28
- package/src/components/ButtonGroup/ButtonGroup.contract.json +34 -49
- package/src/components/ButtonGroup/ButtonGroup.module.scss +8 -6
- package/src/components/Card/Card.consumer-fixture.module.scss +5 -2
- package/src/components/Card/Card.module.scss +97 -76
- package/src/components/Card/index.tsx +44 -20
- package/src/components/Chart/Chart.contract.json +21 -29
- package/src/components/Chart/Chart.module.scss +6 -5
- package/src/components/Chart/index.tsx +36 -6
- package/src/components/Checkbox/Checkbox.contract.json +28 -27
- package/src/components/Checkbox/Checkbox.module.scss +47 -54
- package/src/components/Checkbox/index.tsx +10 -10
- package/src/components/Chip/Chip.contract.json +38 -45
- package/src/components/Chip/Chip.module.scss +24 -23
- package/src/components/Chip/index.tsx +12 -7
- package/src/components/CodeBlock/CodeBlock.contract.json +46 -76
- package/src/components/CodeBlock/CodeBlock.module.scss +75 -73
- package/src/components/CodeBlock/css-variables-theme.ts +102 -0
- package/src/components/CodeBlock/index.tsx +114 -51
- package/src/components/Collapsible/Collapsible.contract.json +21 -36
- package/src/components/Collapsible/Collapsible.module.scss +1 -7
- package/src/components/ColorPicker/ColorPicker.contract.json +29 -48
- package/src/components/ColorPicker/ColorPicker.module.scss +34 -24
- package/src/components/ColorPicker/index.tsx +6 -1
- package/src/components/Combobox/Combobox.contract.json +36 -37
- package/src/components/Combobox/Combobox.module.scss +16 -19
- package/src/components/Combobox/index.tsx +41 -6
- package/src/components/Command/Command.contract.json +28 -44
- package/src/components/Command/Command.module.scss +19 -21
- package/src/components/Command/index.tsx +64 -47
- package/src/components/ComponentDefaults/ComponentDefaults.contract.json +91 -0
- package/src/components/ConversationList/ConversationList.contract.json +27 -32
- package/src/components/ConversationList/ConversationList.module.scss +2 -3
- package/src/components/ConversationList/index.tsx +2 -2
- package/src/components/DataTable/DataTable.icons.tsx +4 -21
- package/src/components/DataTable/DataTable.module.scss +24 -17
- package/src/components/DataTable/DataTable.virtual.tsx +3 -2
- package/src/components/DataTable/index.tsx +9 -8
- package/src/components/DatePicker/DatePicker.contract.json +27 -28
- package/src/components/DatePicker/DatePicker.module.scss +41 -44
- package/src/components/DatePicker/index.tsx +23 -9
- package/src/components/Dialog/Dialog.module.scss +26 -32
- package/src/components/Dialog/index.tsx +51 -39
- package/src/components/Drawer/Drawer.contract.json +28 -42
- package/src/components/Drawer/Drawer.module.scss +123 -64
- package/src/components/Drawer/index.tsx +7 -5
- package/src/components/Editor/Editor.contract.json +32 -49
- package/src/components/Editor/Editor.module.scss +60 -25
- package/src/components/Editor/index.tsx +240 -179
- package/src/components/EmptyState/EmptyState.contract.json +33 -45
- package/src/components/EmptyState/EmptyState.module.scss +37 -21
- package/src/components/EmptyState/index.tsx +56 -23
- package/src/components/Field/Field.contract.json +28 -46
- package/src/components/Field/Field.module.scss +2 -1
- package/src/components/Field/index.tsx +5 -1
- package/src/components/Fieldset/Fieldset.contract.json +21 -38
- package/src/components/Fieldset/Fieldset.module.scss +15 -7
- package/src/components/Form/Form.contract.json +23 -23
- package/src/components/Grid/Grid.contract.json +28 -64
- package/src/components/Grid/Grid.module.scss +2 -2
- package/src/components/Grid/index.tsx +10 -10
- package/src/components/Header/Header.contract.json +31 -67
- package/src/components/Header/Header.module.scss +57 -54
- package/src/components/Header/index.tsx +134 -122
- package/src/components/Icon/Icon.contract.json +37 -81
- package/src/components/Icon/Icon.module.scss +13 -12
- package/src/components/Icon/index.tsx +31 -31
- package/src/components/IconButton/IconButton.contract.json +37 -21
- package/src/components/IconButton/IconButton.module.scss +19 -11
- package/src/components/IconButton/index.tsx +6 -5
- package/src/components/Image/Image.contract.json +23 -56
- package/src/components/Input/Input.contract.json +25 -44
- package/src/components/Input/Input.module.scss +6 -55
- package/src/components/Input/index.tsx +2 -18
- package/src/components/Link/Link.contract.json +46 -58
- package/src/components/Link/Link.module.scss +41 -10
- package/src/components/Link/index.tsx +27 -6
- package/src/components/List/List.contract.json +33 -62
- package/src/components/List/List.module.scss +10 -5
- package/src/components/List/index.tsx +17 -13
- package/src/components/Listbox/Listbox.contract.json +21 -37
- package/src/components/Listbox/Listbox.module.scss +14 -20
- package/src/components/Loading/Loading.contract.json +41 -65
- package/src/components/Loading/Loading.module.scss +37 -31
- package/src/components/Loading/index.tsx +15 -14
- package/src/components/Main/Main.contract.json +17 -9
- package/src/components/Markdown/Markdown.contract.json +22 -43
- package/src/components/Markdown/Markdown.module.scss +45 -6
- package/src/components/Markdown/index.tsx +48 -49
- package/src/components/Menu/Menu.contract.json +30 -46
- package/src/components/Menu/Menu.module.scss +32 -16
- package/src/components/Message/Message.contract.json +31 -54
- package/src/components/Message/Message.module.scss +18 -9
- package/src/components/Message/index.tsx +2 -2
- package/src/components/NavigationMenu/NavigationMenu.contract.json +36 -45
- package/src/components/NavigationMenu/NavigationMenu.module.scss +66 -66
- package/src/components/NavigationMenu/index.tsx +105 -81
- package/src/components/Pagination/Pagination.contract.json +22 -40
- package/src/components/Pagination/Pagination.module.scss +9 -16
- package/src/components/Popover/Popover.contract.json +28 -50
- package/src/components/Popover/Popover.module.scss +30 -28
- package/src/components/Progress/Progress.contract.json +39 -35
- package/src/components/Progress/Progress.module.scss +16 -10
- package/src/components/Progress/index.tsx +34 -16
- package/src/components/Prompt/Prompt.contract.json +40 -56
- package/src/components/Prompt/Prompt.module.scss +49 -48
- package/src/components/Prompt/index.tsx +17 -15
- package/src/components/RadioGroup/RadioGroup.contract.json +29 -28
- package/src/components/RadioGroup/RadioGroup.module.scss +50 -45
- package/src/components/RadioGroup/index.tsx +23 -10
- package/src/components/ScrollArea/ScrollArea.contract.json +18 -19
- package/src/components/ScrollArea/ScrollArea.module.scss +45 -48
- package/src/components/ScrollArea/index.tsx +16 -16
- package/src/components/ScrollArea/scroll-state.ts +24 -24
- package/src/components/Select/Select.module.scss +20 -19
- package/src/components/Select/index.tsx +26 -24
- package/src/components/Separator/Separator.contract.json +29 -53
- package/src/components/Separator/Separator.module.scss +24 -40
- package/src/components/Separator/index.tsx +16 -11
- package/src/components/Sidebar/Sidebar.contract.json +35 -67
- package/src/components/Sidebar/Sidebar.module.scss +94 -88
- package/src/components/Sidebar/index.tsx +167 -167
- package/src/components/Skeleton/Skeleton.contract.json +34 -60
- package/src/components/Skeleton/Skeleton.module.scss +50 -26
- package/src/components/Skeleton/index.tsx +16 -15
- package/src/components/Slider/Slider.contract.json +27 -39
- package/src/components/Slider/Slider.module.scss +9 -22
- package/src/components/Stack/Stack.contract.json +30 -57
- package/src/components/Stack/Stack.module.scss +26 -24
- package/src/components/Stack/index.tsx +3 -3
- package/src/components/Switch/Switch.contract.json +33 -46
- package/src/components/Switch/Switch.module.scss +106 -59
- package/src/components/Table/Table.contract.json +28 -46
- package/src/components/Table/Table.module.scss +24 -16
- package/src/components/TableOfContents/TableOfContents.contract.json +34 -21
- package/src/components/TableOfContents/TableOfContents.module.scss +17 -13
- package/src/components/TableOfContents/index.tsx +27 -10
- package/src/components/Tabs/Tabs.contract.json +35 -56
- package/src/components/Tabs/Tabs.module.scss +27 -31
- package/src/components/Tabs/index.tsx +30 -15
- package/src/components/Text/Text.contract.json +52 -72
- package/src/components/Text/Text.module.scss +34 -18
- package/src/components/Text/index.tsx +123 -83
- package/src/components/Textarea/Textarea.contract.json +24 -55
- package/src/components/Textarea/Textarea.module.scss +22 -52
- package/src/components/Textarea/index.tsx +3 -14
- package/src/components/Theme/Theme.contract.json +35 -53
- package/src/components/Theme/index.tsx +41 -13
- package/src/components/ThemeToggle/ThemeButton.tsx +49 -0
- package/src/components/ThemeToggle/ThemeToggle.module.scss +20 -27
- package/src/components/ThemeToggle/icons.tsx +46 -0
- package/src/components/ThemeToggle/index.tsx +9 -55
- package/src/components/ThinkingIndicator/ThinkingIndicator.contract.json +34 -50
- package/src/components/ThinkingIndicator/ThinkingIndicator.module.scss +9 -7
- package/src/components/ThinkingIndicator/index.tsx +12 -14
- package/src/components/Toast/Toast.contract.json +55 -49
- package/src/components/Toast/Toast.module.scss +50 -105
- package/src/components/Toast/index.tsx +39 -34
- package/src/components/ToggleGroup/ToggleGroup.contract.json +39 -40
- package/src/components/ToggleGroup/ToggleGroup.module.scss +30 -27
- package/src/components/ToggleGroup/index.tsx +11 -11
- package/src/components/Tooltip/Tooltip.contract.json +31 -52
- package/src/components/Tooltip/Tooltip.module.scss +16 -10
- package/src/components/Tooltip/index.tsx +19 -24
- package/src/components/VisuallyHidden/VisuallyHidden.contract.json +22 -44
- package/src/components/VisuallyHidden/VisuallyHidden.module.scss +4 -14
- package/src/components/VisuallyHidden/index.tsx +5 -5
- package/src/index.ts +16 -12
- package/src/measurements/MeasurementTargets.module.scss +6 -7
- package/src/measurements/generated.ts +46 -97
- package/src/measurements/index.ts +0 -1
- package/src/measurements/measurements.json +44 -116
- package/src/recipes/_action.scss +4 -4
- package/src/recipes/_boolean-range.scss +12 -16
- package/src/recipes/_feedback.scss +17 -16
- package/src/recipes/_field.scss +28 -16
- package/src/recipes/_layout.scss +14 -7
- package/src/recipes/_navigation.scss +84 -29
- package/src/recipes/_overlay.scss +143 -43
- package/src/recipes/_popup.scss +54 -34
- package/src/recipes/_prose.scss +48 -28
- package/src/recipes/_representation.scss +10 -9
- package/src/recipes/_segmented.scss +1 -1
- package/src/recipes/_table-chrome.scss +42 -17
- package/src/recipes/_target.scss +2 -4
- package/src/recipes/_typography.scss +10 -0
- package/src/scss.d.ts +1 -1
- package/src/styles/globals.scss +31 -25
- package/src/tokens/_component-properties.scss +19 -1
- package/src/tokens/_computed.scss +32 -49
- package/src/tokens/_derive.scss +112 -210
- package/src/tokens/_measurements.catalog.generated.css +62 -44
- package/src/tokens/_measurements.generated.scss +119 -249
- package/src/tokens/_mixins.scss +49 -48
- package/src/tokens/_palettes.scss +39 -167
- package/src/tokens/_property-registrations.scss +9 -0
- package/src/tokens/_seeds.scss +20 -31
- package/src/tokens/_variables.scss +251 -94
- package/src/utils/a11y.tsx +69 -69
- package/src/utils/aria.ts +3 -3
- package/src/utils/canonical-stamp.ts +2 -12
- package/src/utils/css-warning.ts +7 -7
- package/src/utils/env.ts +25 -0
- package/src/utils/keyboard-shortcuts.ts +131 -126
- package/src/utils/seed-derivation.ts +11 -14
- package/src/utils/theme-presets.ts +5 -12
- package/dist/blocks/AccountSettings.block.d.ts +0 -3
- package/dist/blocks/AccountSettings.block.d.ts.map +0 -1
- package/dist/blocks/ActivityFeedSkeleton.block.d.ts +0 -3
- package/dist/blocks/ActivityFeedSkeleton.block.d.ts.map +0 -1
- package/dist/blocks/BlogEditor.block.d.ts +0 -3
- package/dist/blocks/BlogEditor.block.d.ts.map +0 -1
- package/dist/blocks/ChatInterface.block.d.ts +0 -3
- package/dist/blocks/ChatInterface.block.d.ts.map +0 -1
- package/dist/blocks/ChatMessages.block.d.ts +0 -3
- package/dist/blocks/ChatMessages.block.d.ts.map +0 -1
- package/dist/blocks/CheckoutForm.block.d.ts +0 -3
- package/dist/blocks/CheckoutForm.block.d.ts.map +0 -1
- package/dist/blocks/CommandPalette.block.d.ts +0 -3
- package/dist/blocks/CommandPalette.block.d.ts.map +0 -1
- package/dist/blocks/ContactForm.block.d.ts +0 -3
- package/dist/blocks/ContactForm.block.d.ts.map +0 -1
- package/dist/blocks/DashboardPage.block.d.ts +0 -3
- package/dist/blocks/DashboardPage.block.d.ts.map +0 -1
- package/dist/blocks/DashboardSkeleton.block.d.ts +0 -3
- package/dist/blocks/DashboardSkeleton.block.d.ts.map +0 -1
- package/dist/blocks/DataTable.block.d.ts +0 -3
- package/dist/blocks/DataTable.block.d.ts.map +0 -1
- package/dist/blocks/EmptyState.block.d.ts +0 -3
- package/dist/blocks/EmptyState.block.d.ts.map +0 -1
- package/dist/blocks/FAQSection.block.d.ts +0 -3
- package/dist/blocks/FAQSection.block.d.ts.map +0 -1
- package/dist/blocks/FeatureGrid.block.d.ts +0 -3
- package/dist/blocks/FeatureGrid.block.d.ts.map +0 -1
- package/dist/blocks/HeroSection.block.d.ts +0 -3
- package/dist/blocks/HeroSection.block.d.ts.map +0 -1
- package/dist/blocks/NavigationHeader.block.d.ts +0 -3
- package/dist/blocks/NavigationHeader.block.d.ts.map +0 -1
- package/dist/blocks/PaginatedTable.block.d.ts +0 -3
- package/dist/blocks/PaginatedTable.block.d.ts.map +0 -1
- package/dist/blocks/PricingComparison.block.d.ts +0 -3
- package/dist/blocks/PricingComparison.block.d.ts.map +0 -1
- package/dist/blocks/ProductCard.block.d.ts +0 -3
- package/dist/blocks/ProductCard.block.d.ts.map +0 -1
- package/dist/blocks/RegistrationForm.block.d.ts +0 -3
- package/dist/blocks/RegistrationForm.block.d.ts.map +0 -1
- package/dist/blocks/SettingsDrawer.block.d.ts +0 -3
- package/dist/blocks/SettingsDrawer.block.d.ts.map +0 -1
- package/dist/blocks/SettingsPanel.block.d.ts +0 -3
- package/dist/blocks/SettingsPanel.block.d.ts.map +0 -1
- package/dist/blocks/ShoppingCart.block.d.ts +0 -3
- package/dist/blocks/ShoppingCart.block.d.ts.map +0 -1
- package/dist/blocks/StatsCardSkeleton.block.d.ts +0 -3
- package/dist/blocks/StatsCardSkeleton.block.d.ts.map +0 -1
- package/dist/blocks/TableSkeleton.block.d.ts +0 -3
- package/dist/blocks/TableSkeleton.block.d.ts.map +0 -1
- package/dist/blocks/ThinkingStates.block.d.ts +0 -3
- package/dist/blocks/ThinkingStates.block.d.ts.map +0 -1
- package/dist/components/Toggle/index.d.ts +0 -3
- package/dist/components/Toggle/index.d.ts.map +0 -1
- package/src/components/Button/Button.contract.json +0 -218
- package/src/components/Card/Card.contract.json +0 -175
- package/src/components/DataTable/DataTable.contract.json +0 -302
- package/src/components/Dialog/Dialog.contract.json +0 -159
- package/src/components/Select/Select.contract.json +0 -259
- package/src/components/Toggle/index.ts +0 -7
- package/src/tokens/_density.scss +0 -85
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import styles from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import styles from "./Editor.module.scss";
|
|
5
5
|
import {
|
|
6
6
|
TextB,
|
|
7
7
|
TextItalic,
|
|
@@ -16,8 +16,9 @@ import {
|
|
|
16
16
|
Quotes,
|
|
17
17
|
ArrowCounterClockwise,
|
|
18
18
|
ArrowClockwise,
|
|
19
|
-
} from
|
|
20
|
-
import { KEYBOARD_SHORTCUTS } from
|
|
19
|
+
} from "@phosphor-icons/react";
|
|
20
|
+
import { KEYBOARD_SHORTCUTS } from "../../utils/keyboard-shortcuts";
|
|
21
|
+
import { isDevelopmentBuild } from "../../utils/env";
|
|
21
22
|
|
|
22
23
|
// ============================================
|
|
23
24
|
// Lazy-loaded dependency (TipTap)
|
|
@@ -37,13 +38,13 @@ function loadTipTapDeps(): Promise<void> {
|
|
|
37
38
|
_tiptapLoadPromise = (async () => {
|
|
38
39
|
try {
|
|
39
40
|
const [tiptapReact, starterKit, linkExt] = await Promise.all([
|
|
40
|
-
import(
|
|
41
|
-
import(
|
|
42
|
-
import(
|
|
41
|
+
import("@tiptap/react"),
|
|
42
|
+
import("@tiptap/starter-kit"),
|
|
43
|
+
import("@tiptap/extension-link"),
|
|
43
44
|
]);
|
|
44
45
|
|
|
45
46
|
_useEditor = tiptapReact.useEditor as unknown as (
|
|
46
|
-
config: Record<string, unknown
|
|
47
|
+
config: Record<string, unknown>
|
|
47
48
|
) => unknown;
|
|
48
49
|
_EditorContent = tiptapReact.EditorContent as unknown as React.ComponentType<
|
|
49
50
|
Record<string, unknown>
|
|
@@ -58,10 +59,10 @@ function loadTipTapDeps(): Promise<void> {
|
|
|
58
59
|
linkExt;
|
|
59
60
|
} catch {
|
|
60
61
|
_tiptapFailed = true;
|
|
61
|
-
if (
|
|
62
|
+
if (isDevelopmentBuild()) {
|
|
62
63
|
console.warn(
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
"[@usefragments/ui] Editor: TipTap is not installed; falling back to markdown mode. " +
|
|
65
|
+
"Install it with: npm install @tiptap/react @tiptap/starter-kit @tiptap/extension-link"
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -91,17 +92,25 @@ function useTipTapDeps(): boolean {
|
|
|
91
92
|
// ============================================
|
|
92
93
|
|
|
93
94
|
export type EditorFormat =
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
| "bold"
|
|
96
|
+
| "italic"
|
|
97
|
+
| "strikethrough"
|
|
98
|
+
| "link"
|
|
99
|
+
| "code"
|
|
100
|
+
| "bulletList"
|
|
101
|
+
| "orderedList"
|
|
102
|
+
| "heading1"
|
|
103
|
+
| "heading2"
|
|
104
|
+
| "heading3"
|
|
105
|
+
| "blockquote"
|
|
106
|
+
| "undo"
|
|
107
|
+
| "redo";
|
|
108
|
+
|
|
109
|
+
export type EditorSaveStatus = "idle" | "saving" | "saved" | "error";
|
|
110
|
+
|
|
111
|
+
export type EditorMode = "rich" | "markdown";
|
|
112
|
+
|
|
113
|
+
export type EditorSize = "sm" | "md" | "lg";
|
|
105
114
|
|
|
106
115
|
export interface EditorToolbarIconRenderState {
|
|
107
116
|
format: EditorFormat;
|
|
@@ -118,7 +127,10 @@ export type EditorToolbarIconSlot =
|
|
|
118
127
|
|
|
119
128
|
export type EditorToolbarIcons = Partial<Record<EditorFormat, EditorToolbarIconSlot>>;
|
|
120
129
|
|
|
121
|
-
export interface EditorProps extends Omit<
|
|
130
|
+
export interface EditorProps extends Omit<
|
|
131
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
132
|
+
"onChange" | "defaultValue"
|
|
133
|
+
> {
|
|
122
134
|
children?: React.ReactNode;
|
|
123
135
|
/** Controlled value */
|
|
124
136
|
value?: string;
|
|
@@ -157,7 +169,7 @@ export interface EditorToolbarProps {
|
|
|
157
169
|
|
|
158
170
|
export interface EditorToolbarGroupProps {
|
|
159
171
|
children: React.ReactNode;
|
|
160
|
-
|
|
172
|
+
"aria-label"?: string;
|
|
161
173
|
className?: string;
|
|
162
174
|
}
|
|
163
175
|
|
|
@@ -196,32 +208,74 @@ export interface EditorStatusBarProps {
|
|
|
196
208
|
// ============================================
|
|
197
209
|
|
|
198
210
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
199
|
-
const FORMAT_META: Record<
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
const FORMAT_META: Record<
|
|
212
|
+
EditorFormat,
|
|
213
|
+
{ icon: React.ComponentType<any>; label: string; shortcut: string }
|
|
214
|
+
> = {
|
|
215
|
+
bold: { icon: TextB, label: "Bold", shortcut: KEYBOARD_SHORTCUTS.EDITOR_BOLD.label },
|
|
216
|
+
italic: { icon: TextItalic, label: "Italic", shortcut: KEYBOARD_SHORTCUTS.EDITOR_ITALIC.label },
|
|
217
|
+
strikethrough: {
|
|
218
|
+
icon: TextStrikethrough,
|
|
219
|
+
label: "Strikethrough",
|
|
220
|
+
shortcut: KEYBOARD_SHORTCUTS.EDITOR_STRIKETHROUGH.label,
|
|
221
|
+
},
|
|
222
|
+
link: { icon: LinkSimple, label: "Link", shortcut: KEYBOARD_SHORTCUTS.EDITOR_LINK.label },
|
|
223
|
+
code: { icon: Code, label: "Code", shortcut: KEYBOARD_SHORTCUTS.EDITOR_CODE.label },
|
|
224
|
+
bulletList: {
|
|
225
|
+
icon: ListBullets,
|
|
226
|
+
label: "Bullet list",
|
|
227
|
+
shortcut: KEYBOARD_SHORTCUTS.EDITOR_BULLET_LIST.label,
|
|
228
|
+
},
|
|
229
|
+
orderedList: {
|
|
230
|
+
icon: ListNumbers,
|
|
231
|
+
label: "Ordered list",
|
|
232
|
+
shortcut: KEYBOARD_SHORTCUTS.EDITOR_ORDERED_LIST.label,
|
|
233
|
+
},
|
|
234
|
+
heading1: {
|
|
235
|
+
icon: TextHOne,
|
|
236
|
+
label: "Heading 1",
|
|
237
|
+
shortcut: KEYBOARD_SHORTCUTS.EDITOR_HEADING1.label,
|
|
238
|
+
},
|
|
239
|
+
heading2: {
|
|
240
|
+
icon: TextHTwo,
|
|
241
|
+
label: "Heading 2",
|
|
242
|
+
shortcut: KEYBOARD_SHORTCUTS.EDITOR_HEADING2.label,
|
|
243
|
+
},
|
|
244
|
+
heading3: {
|
|
245
|
+
icon: TextHThree,
|
|
246
|
+
label: "Heading 3",
|
|
247
|
+
shortcut: KEYBOARD_SHORTCUTS.EDITOR_HEADING3.label,
|
|
248
|
+
},
|
|
249
|
+
blockquote: {
|
|
250
|
+
icon: Quotes,
|
|
251
|
+
label: "Blockquote",
|
|
252
|
+
shortcut: KEYBOARD_SHORTCUTS.EDITOR_BLOCKQUOTE.label,
|
|
253
|
+
},
|
|
254
|
+
undo: {
|
|
255
|
+
icon: ArrowCounterClockwise,
|
|
256
|
+
label: "Undo",
|
|
257
|
+
shortcut: KEYBOARD_SHORTCUTS.EDITOR_UNDO.label,
|
|
258
|
+
},
|
|
259
|
+
redo: { icon: ArrowClockwise, label: "Redo", shortcut: KEYBOARD_SHORTCUTS.EDITOR_REDO.label },
|
|
213
260
|
};
|
|
214
261
|
|
|
215
|
-
const DEFAULT_FORMATS: EditorFormat[] = [
|
|
262
|
+
const DEFAULT_FORMATS: EditorFormat[] = [
|
|
263
|
+
"bold",
|
|
264
|
+
"italic",
|
|
265
|
+
"strikethrough",
|
|
266
|
+
"link",
|
|
267
|
+
"code",
|
|
268
|
+
"bulletList",
|
|
269
|
+
];
|
|
216
270
|
|
|
217
271
|
/** Formats that are actions (not toggles) — no aria-pressed, different disable logic */
|
|
218
|
-
const ACTION_FORMATS = new Set<EditorFormat>([
|
|
272
|
+
const ACTION_FORMATS = new Set<EditorFormat>(["undo", "redo"]);
|
|
219
273
|
|
|
220
274
|
const DEFAULT_STATUS_LABELS: Record<EditorSaveStatus, string> = {
|
|
221
|
-
idle:
|
|
222
|
-
saving:
|
|
223
|
-
saved:
|
|
224
|
-
error:
|
|
275
|
+
idle: "",
|
|
276
|
+
saving: "SAVING...",
|
|
277
|
+
saved: "AUTO-SAVED",
|
|
278
|
+
error: "SAVE FAILED",
|
|
225
279
|
};
|
|
226
280
|
|
|
227
281
|
// ============================================
|
|
@@ -246,19 +300,19 @@ function wrapSelection(
|
|
|
246
300
|
textarea: HTMLTextAreaElement,
|
|
247
301
|
prefix: string,
|
|
248
302
|
suffix: string,
|
|
249
|
-
setValue: (v: string) => void
|
|
303
|
+
setValue: (v: string) => void
|
|
250
304
|
) {
|
|
251
305
|
const sel = getSelection(textarea);
|
|
252
306
|
const before = textarea.value.substring(0, sel.start);
|
|
253
307
|
const after = textarea.value.substring(sel.end);
|
|
254
|
-
const wrapped = `${prefix}${sel.text ||
|
|
308
|
+
const wrapped = `${prefix}${sel.text || "text"}${suffix}`;
|
|
255
309
|
const newValue = `${before}${wrapped}${after}`;
|
|
256
310
|
setValue(newValue);
|
|
257
311
|
|
|
258
312
|
requestAnimationFrame(() => {
|
|
259
313
|
textarea.focus();
|
|
260
314
|
const newStart = sel.start + prefix.length;
|
|
261
|
-
const newEnd = newStart + (sel.text ||
|
|
315
|
+
const newEnd = newStart + (sel.text || "text").length;
|
|
262
316
|
textarea.setSelectionRange(newStart, newEnd);
|
|
263
317
|
});
|
|
264
318
|
}
|
|
@@ -266,24 +320,24 @@ function wrapSelection(
|
|
|
266
320
|
function applyMarkdownFormat(
|
|
267
321
|
format: EditorFormat,
|
|
268
322
|
textarea: HTMLTextAreaElement,
|
|
269
|
-
setValue: (v: string) => void
|
|
323
|
+
setValue: (v: string) => void
|
|
270
324
|
) {
|
|
271
325
|
switch (format) {
|
|
272
|
-
case
|
|
273
|
-
wrapSelection(textarea,
|
|
326
|
+
case "bold":
|
|
327
|
+
wrapSelection(textarea, "**", "**", setValue);
|
|
274
328
|
break;
|
|
275
|
-
case
|
|
276
|
-
wrapSelection(textarea,
|
|
329
|
+
case "italic":
|
|
330
|
+
wrapSelection(textarea, "*", "*", setValue);
|
|
277
331
|
break;
|
|
278
|
-
case
|
|
279
|
-
wrapSelection(textarea,
|
|
332
|
+
case "strikethrough":
|
|
333
|
+
wrapSelection(textarea, "~~", "~~", setValue);
|
|
280
334
|
break;
|
|
281
|
-
case
|
|
282
|
-
wrapSelection(textarea,
|
|
335
|
+
case "code":
|
|
336
|
+
wrapSelection(textarea, "`", "`", setValue);
|
|
283
337
|
break;
|
|
284
|
-
case
|
|
338
|
+
case "link": {
|
|
285
339
|
const sel = getSelection(textarea);
|
|
286
|
-
const linkText = sel.text ||
|
|
340
|
+
const linkText = sel.text || "link text";
|
|
287
341
|
const before = textarea.value.substring(0, sel.start);
|
|
288
342
|
const after = textarea.value.substring(sel.end);
|
|
289
343
|
const newValue = `${before}[${linkText}](url)${after}`;
|
|
@@ -295,47 +349,47 @@ function applyMarkdownFormat(
|
|
|
295
349
|
});
|
|
296
350
|
break;
|
|
297
351
|
}
|
|
298
|
-
case
|
|
352
|
+
case "bulletList": {
|
|
299
353
|
const sel = getSelection(textarea);
|
|
300
354
|
const before = textarea.value.substring(0, sel.start);
|
|
301
355
|
const after = textarea.value.substring(sel.end);
|
|
302
|
-
const lines = (sel.text ||
|
|
303
|
-
const bulleted = lines.map((l) => `- ${l}`).join(
|
|
356
|
+
const lines = (sel.text || "item").split("\n");
|
|
357
|
+
const bulleted = lines.map((l) => `- ${l}`).join("\n");
|
|
304
358
|
const newValue = `${before}${bulleted}${after}`;
|
|
305
359
|
setValue(newValue);
|
|
306
360
|
break;
|
|
307
361
|
}
|
|
308
|
-
case
|
|
362
|
+
case "orderedList": {
|
|
309
363
|
const sel = getSelection(textarea);
|
|
310
364
|
const before = textarea.value.substring(0, sel.start);
|
|
311
365
|
const after = textarea.value.substring(sel.end);
|
|
312
|
-
const lines = (sel.text ||
|
|
313
|
-
const numbered = lines.map((l, i) => `${i + 1}. ${l}`).join(
|
|
366
|
+
const lines = (sel.text || "item").split("\n");
|
|
367
|
+
const numbered = lines.map((l, i) => `${i + 1}. ${l}`).join("\n");
|
|
314
368
|
const newValue = `${before}${numbered}${after}`;
|
|
315
369
|
setValue(newValue);
|
|
316
370
|
break;
|
|
317
371
|
}
|
|
318
|
-
case
|
|
319
|
-
wrapSelection(textarea,
|
|
372
|
+
case "heading1":
|
|
373
|
+
wrapSelection(textarea, "# ", "", setValue);
|
|
320
374
|
break;
|
|
321
|
-
case
|
|
322
|
-
wrapSelection(textarea,
|
|
375
|
+
case "heading2":
|
|
376
|
+
wrapSelection(textarea, "## ", "", setValue);
|
|
323
377
|
break;
|
|
324
|
-
case
|
|
325
|
-
wrapSelection(textarea,
|
|
378
|
+
case "heading3":
|
|
379
|
+
wrapSelection(textarea, "### ", "", setValue);
|
|
326
380
|
break;
|
|
327
|
-
case
|
|
381
|
+
case "blockquote": {
|
|
328
382
|
const sel = getSelection(textarea);
|
|
329
383
|
const before = textarea.value.substring(0, sel.start);
|
|
330
384
|
const after = textarea.value.substring(sel.end);
|
|
331
|
-
const lines = (sel.text ||
|
|
332
|
-
const quoted = lines.map((l) => `> ${l}`).join(
|
|
385
|
+
const lines = (sel.text || "quote").split("\n");
|
|
386
|
+
const quoted = lines.map((l) => `> ${l}`).join("\n");
|
|
333
387
|
const newValue = `${before}${quoted}${after}`;
|
|
334
388
|
setValue(newValue);
|
|
335
389
|
break;
|
|
336
390
|
}
|
|
337
|
-
case
|
|
338
|
-
case
|
|
391
|
+
case "undo":
|
|
392
|
+
case "redo":
|
|
339
393
|
// Undo/redo in textarea mode is handled natively by the browser
|
|
340
394
|
break;
|
|
341
395
|
}
|
|
@@ -371,7 +425,7 @@ const EditorContext = React.createContext<EditorContextValue | null>(null);
|
|
|
371
425
|
function useEditorContext() {
|
|
372
426
|
const context = React.useContext(EditorContext);
|
|
373
427
|
if (!context) {
|
|
374
|
-
throw new Error(
|
|
428
|
+
throw new Error("Editor compound components must be used within an Editor");
|
|
375
429
|
}
|
|
376
430
|
return context;
|
|
377
431
|
}
|
|
@@ -383,7 +437,7 @@ function useEditorContext() {
|
|
|
383
437
|
function useControllableState<T>(
|
|
384
438
|
controlledValue: T | undefined,
|
|
385
439
|
defaultValue: T,
|
|
386
|
-
onChange?: (value: T) => void
|
|
440
|
+
onChange?: (value: T) => void
|
|
387
441
|
): [T, (value: T) => void] {
|
|
388
442
|
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);
|
|
389
443
|
const isControlled = controlledValue !== undefined;
|
|
@@ -396,7 +450,7 @@ function useControllableState<T>(
|
|
|
396
450
|
}
|
|
397
451
|
onChange?.(newValue);
|
|
398
452
|
},
|
|
399
|
-
[isControlled, onChange]
|
|
453
|
+
[isControlled, onChange]
|
|
400
454
|
);
|
|
401
455
|
|
|
402
456
|
return [value, setValue];
|
|
@@ -417,16 +471,16 @@ function EditorRoot(props: EditorProps) {
|
|
|
417
471
|
// The rich implementation calls TipTap's useEditor hook, so an instance's
|
|
418
472
|
// mode must never change mid-lifetime. Keying by mode remounts the
|
|
419
473
|
// implementation exactly once, when the lazy TipTap load resolves.
|
|
420
|
-
return <EditorImpl key={hasTipTap ?
|
|
474
|
+
return <EditorImpl key={hasTipTap ? "rich" : "markdown"} hasTipTap={hasTipTap} {...props} />;
|
|
421
475
|
}
|
|
422
476
|
|
|
423
477
|
function EditorImpl({
|
|
424
478
|
hasTipTap,
|
|
425
479
|
children,
|
|
426
480
|
value: controlledValue,
|
|
427
|
-
defaultValue =
|
|
481
|
+
defaultValue = "",
|
|
428
482
|
onValueChange,
|
|
429
|
-
placeholder =
|
|
483
|
+
placeholder = "Start typing...",
|
|
430
484
|
disabled = false,
|
|
431
485
|
readOnly = false,
|
|
432
486
|
formats = DEFAULT_FORMATS,
|
|
@@ -434,7 +488,7 @@ function EditorImpl({
|
|
|
434
488
|
statusBar = true,
|
|
435
489
|
onAutoSave,
|
|
436
490
|
autoSaveInterval = 30000,
|
|
437
|
-
size =
|
|
491
|
+
size = "md",
|
|
438
492
|
maxLength,
|
|
439
493
|
toolbarIcons,
|
|
440
494
|
className,
|
|
@@ -442,15 +496,11 @@ function EditorImpl({
|
|
|
442
496
|
}: EditorProps & { hasTipTap: boolean }) {
|
|
443
497
|
const contentRef = React.useRef<HTMLTextAreaElement>(null);
|
|
444
498
|
|
|
445
|
-
const [value, setValue] = useControllableState(
|
|
446
|
-
controlledValue,
|
|
447
|
-
defaultValue,
|
|
448
|
-
onValueChange,
|
|
449
|
-
);
|
|
499
|
+
const [value, setValue] = useControllableState(controlledValue, defaultValue, onValueChange);
|
|
450
500
|
|
|
451
|
-
const [saveStatus, setSaveStatus] = React.useState<EditorSaveStatus>(
|
|
501
|
+
const [saveStatus, setSaveStatus] = React.useState<EditorSaveStatus>("idle");
|
|
452
502
|
|
|
453
|
-
const mode: EditorMode = hasTipTap ?
|
|
503
|
+
const mode: EditorMode = hasTipTap ? "rich" : "markdown";
|
|
454
504
|
|
|
455
505
|
// TipTap editor instance (only when available)
|
|
456
506
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -469,14 +519,14 @@ function EditorImpl({
|
|
|
469
519
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
470
520
|
(_LinkExtension as any).configure({
|
|
471
521
|
openOnClick: false,
|
|
472
|
-
HTMLAttributes: { rel:
|
|
522
|
+
HTMLAttributes: { rel: "noopener noreferrer", target: "_blank" },
|
|
473
523
|
}),
|
|
474
524
|
],
|
|
475
525
|
editorProps: {
|
|
476
526
|
attributes: {
|
|
477
|
-
role:
|
|
478
|
-
|
|
479
|
-
|
|
527
|
+
role: "textbox",
|
|
528
|
+
"aria-label": placeholder,
|
|
529
|
+
"aria-multiline": "true",
|
|
480
530
|
},
|
|
481
531
|
},
|
|
482
532
|
content: controlledValue !== undefined ? controlledValue : defaultValue,
|
|
@@ -511,22 +561,22 @@ function EditorImpl({
|
|
|
511
561
|
|
|
512
562
|
let cancelled = false;
|
|
513
563
|
const timer = setTimeout(() => {
|
|
514
|
-
setSaveStatus(
|
|
564
|
+
setSaveStatus("saving");
|
|
515
565
|
try {
|
|
516
566
|
Promise.resolve(onAutoSave(value))
|
|
517
567
|
.then(() => {
|
|
518
568
|
if (!cancelled) {
|
|
519
|
-
setSaveStatus(
|
|
569
|
+
setSaveStatus("saved");
|
|
520
570
|
}
|
|
521
571
|
})
|
|
522
572
|
.catch(() => {
|
|
523
573
|
if (!cancelled) {
|
|
524
|
-
setSaveStatus(
|
|
574
|
+
setSaveStatus("error");
|
|
525
575
|
}
|
|
526
576
|
});
|
|
527
577
|
} catch {
|
|
528
578
|
if (!cancelled) {
|
|
529
|
-
setSaveStatus(
|
|
579
|
+
setSaveStatus("error");
|
|
530
580
|
}
|
|
531
581
|
}
|
|
532
582
|
}, autoSaveInterval);
|
|
@@ -543,48 +593,48 @@ function EditorImpl({
|
|
|
543
593
|
|
|
544
594
|
if (tiptapEditor) {
|
|
545
595
|
switch (format) {
|
|
546
|
-
case
|
|
596
|
+
case "bold":
|
|
547
597
|
tiptapEditor.chain().focus().toggleBold().run();
|
|
548
598
|
break;
|
|
549
|
-
case
|
|
599
|
+
case "italic":
|
|
550
600
|
tiptapEditor.chain().focus().toggleItalic().run();
|
|
551
601
|
break;
|
|
552
|
-
case
|
|
602
|
+
case "strikethrough":
|
|
553
603
|
tiptapEditor.chain().focus().toggleStrike().run();
|
|
554
604
|
break;
|
|
555
|
-
case
|
|
605
|
+
case "code":
|
|
556
606
|
tiptapEditor.chain().focus().toggleCode().run();
|
|
557
607
|
break;
|
|
558
|
-
case
|
|
608
|
+
case "bulletList":
|
|
559
609
|
tiptapEditor.chain().focus().toggleBulletList().run();
|
|
560
610
|
break;
|
|
561
|
-
case
|
|
611
|
+
case "orderedList":
|
|
562
612
|
tiptapEditor.chain().focus().toggleOrderedList().run();
|
|
563
613
|
break;
|
|
564
|
-
case
|
|
614
|
+
case "heading1":
|
|
565
615
|
tiptapEditor.chain().focus().toggleHeading({ level: 1 }).run();
|
|
566
616
|
break;
|
|
567
|
-
case
|
|
617
|
+
case "heading2":
|
|
568
618
|
tiptapEditor.chain().focus().toggleHeading({ level: 2 }).run();
|
|
569
619
|
break;
|
|
570
|
-
case
|
|
620
|
+
case "heading3":
|
|
571
621
|
tiptapEditor.chain().focus().toggleHeading({ level: 3 }).run();
|
|
572
622
|
break;
|
|
573
|
-
case
|
|
623
|
+
case "blockquote":
|
|
574
624
|
tiptapEditor.chain().focus().toggleBlockquote().run();
|
|
575
625
|
break;
|
|
576
|
-
case
|
|
626
|
+
case "undo":
|
|
577
627
|
tiptapEditor.chain().focus().undo().run();
|
|
578
628
|
break;
|
|
579
|
-
case
|
|
629
|
+
case "redo":
|
|
580
630
|
tiptapEditor.chain().focus().redo().run();
|
|
581
631
|
break;
|
|
582
|
-
case
|
|
583
|
-
const previousUrl = tiptapEditor.getAttributes(
|
|
632
|
+
case "link": {
|
|
633
|
+
const previousUrl = tiptapEditor.getAttributes("link").href;
|
|
584
634
|
if (previousUrl) {
|
|
585
635
|
tiptapEditor.chain().focus().unsetLink().run();
|
|
586
636
|
} else {
|
|
587
|
-
const url = window.prompt(
|
|
637
|
+
const url = window.prompt("Enter URL");
|
|
588
638
|
if (url) {
|
|
589
639
|
tiptapEditor.chain().focus().setLink({ href: url }).run();
|
|
590
640
|
}
|
|
@@ -596,48 +646,48 @@ function EditorImpl({
|
|
|
596
646
|
applyMarkdownFormat(format, contentRef.current, setValue);
|
|
597
647
|
}
|
|
598
648
|
},
|
|
599
|
-
[disabled, readOnly, tiptapEditor, setValue]
|
|
649
|
+
[disabled, readOnly, tiptapEditor, setValue]
|
|
600
650
|
);
|
|
601
651
|
|
|
602
652
|
const isFormatActive = React.useCallback(
|
|
603
653
|
(format: EditorFormat): boolean => {
|
|
604
654
|
if (!tiptapEditor) return false;
|
|
605
655
|
switch (format) {
|
|
606
|
-
case
|
|
607
|
-
return tiptapEditor.isActive(
|
|
608
|
-
case
|
|
609
|
-
return tiptapEditor.isActive(
|
|
610
|
-
case
|
|
611
|
-
return tiptapEditor.isActive(
|
|
612
|
-
case
|
|
613
|
-
return tiptapEditor.isActive(
|
|
614
|
-
case
|
|
615
|
-
return tiptapEditor.isActive(
|
|
616
|
-
case
|
|
617
|
-
return tiptapEditor.isActive(
|
|
618
|
-
case
|
|
619
|
-
return tiptapEditor.isActive(
|
|
620
|
-
case
|
|
621
|
-
return tiptapEditor.isActive(
|
|
622
|
-
case
|
|
623
|
-
return tiptapEditor.isActive(
|
|
624
|
-
case
|
|
625
|
-
return tiptapEditor.isActive(
|
|
626
|
-
case
|
|
627
|
-
return tiptapEditor.isActive(
|
|
628
|
-
case
|
|
629
|
-
case
|
|
656
|
+
case "bold":
|
|
657
|
+
return tiptapEditor.isActive("bold");
|
|
658
|
+
case "italic":
|
|
659
|
+
return tiptapEditor.isActive("italic");
|
|
660
|
+
case "strikethrough":
|
|
661
|
+
return tiptapEditor.isActive("strike");
|
|
662
|
+
case "code":
|
|
663
|
+
return tiptapEditor.isActive("code");
|
|
664
|
+
case "bulletList":
|
|
665
|
+
return tiptapEditor.isActive("bulletList");
|
|
666
|
+
case "orderedList":
|
|
667
|
+
return tiptapEditor.isActive("orderedList");
|
|
668
|
+
case "heading1":
|
|
669
|
+
return tiptapEditor.isActive("heading", { level: 1 });
|
|
670
|
+
case "heading2":
|
|
671
|
+
return tiptapEditor.isActive("heading", { level: 2 });
|
|
672
|
+
case "heading3":
|
|
673
|
+
return tiptapEditor.isActive("heading", { level: 3 });
|
|
674
|
+
case "blockquote":
|
|
675
|
+
return tiptapEditor.isActive("blockquote");
|
|
676
|
+
case "link":
|
|
677
|
+
return tiptapEditor.isActive("link");
|
|
678
|
+
case "undo":
|
|
679
|
+
case "redo":
|
|
630
680
|
return false; // Actions don't have active state
|
|
631
681
|
default:
|
|
632
682
|
return false;
|
|
633
683
|
}
|
|
634
684
|
},
|
|
635
|
-
[tiptapEditor]
|
|
685
|
+
[tiptapEditor]
|
|
636
686
|
);
|
|
637
687
|
|
|
638
688
|
const wordCount = React.useMemo(() => {
|
|
639
689
|
if (tiptapEditor) {
|
|
640
|
-
const text = tiptapEditor.getText?.() ??
|
|
690
|
+
const text = tiptapEditor.getText?.() ?? "";
|
|
641
691
|
return countWords(text);
|
|
642
692
|
}
|
|
643
693
|
return countWords(value);
|
|
@@ -645,7 +695,7 @@ function EditorImpl({
|
|
|
645
695
|
|
|
646
696
|
const charCount = React.useMemo(() => {
|
|
647
697
|
if (tiptapEditor) {
|
|
648
|
-
return (tiptapEditor.getText?.() ??
|
|
698
|
+
return (tiptapEditor.getText?.() ?? "").length;
|
|
649
699
|
}
|
|
650
700
|
return value.length;
|
|
651
701
|
}, [value, tiptapEditor]);
|
|
@@ -675,7 +725,9 @@ function EditorImpl({
|
|
|
675
725
|
disabled && styles.disabled,
|
|
676
726
|
readOnly && styles.readOnly,
|
|
677
727
|
className,
|
|
678
|
-
]
|
|
728
|
+
]
|
|
729
|
+
.filter(Boolean)
|
|
730
|
+
.join(" ");
|
|
679
731
|
|
|
680
732
|
const hasCustomChildren = children !== undefined;
|
|
681
733
|
|
|
@@ -711,7 +763,7 @@ function EditorImpl({
|
|
|
711
763
|
}
|
|
712
764
|
|
|
713
765
|
function EditorToolbar({ children, className }: EditorToolbarProps) {
|
|
714
|
-
const classes = [styles.toolbar, className].filter(Boolean).join(
|
|
766
|
+
const classes = [styles.toolbar, className].filter(Boolean).join(" ");
|
|
715
767
|
return (
|
|
716
768
|
<div className={classes} role="toolbar" aria-label="Editor formatting">
|
|
717
769
|
{children}
|
|
@@ -719,8 +771,12 @@ function EditorToolbar({ children, className }: EditorToolbarProps) {
|
|
|
719
771
|
);
|
|
720
772
|
}
|
|
721
773
|
|
|
722
|
-
function EditorToolbarGroup({
|
|
723
|
-
|
|
774
|
+
function EditorToolbarGroup({
|
|
775
|
+
children,
|
|
776
|
+
"aria-label": ariaLabel,
|
|
777
|
+
className,
|
|
778
|
+
}: EditorToolbarGroupProps) {
|
|
779
|
+
const classes = [styles.toolbarGroup, className].filter(Boolean).join(" ");
|
|
724
780
|
return (
|
|
725
781
|
<div className={classes} role="group" aria-label={ariaLabel}>
|
|
726
782
|
{children}
|
|
@@ -729,7 +785,8 @@ function EditorToolbarGroup({ children, 'aria-label': ariaLabel, className }: Ed
|
|
|
729
785
|
}
|
|
730
786
|
|
|
731
787
|
function EditorToolbarButton({ format, className }: EditorToolbarButtonProps) {
|
|
732
|
-
const { toggleFormat, isFormatActive, disabled, readOnly, editor, mode, toolbarIcons } =
|
|
788
|
+
const { toggleFormat, isFormatActive, disabled, readOnly, editor, mode, toolbarIcons } =
|
|
789
|
+
useEditorContext();
|
|
733
790
|
const meta = FORMAT_META[format];
|
|
734
791
|
const isAction = ACTION_FORMATS.has(format);
|
|
735
792
|
const active = isAction ? false : isFormatActive(format);
|
|
@@ -738,11 +795,11 @@ function EditorToolbarButton({ format, className }: EditorToolbarButtonProps) {
|
|
|
738
795
|
// Action buttons (undo/redo) have special disable logic
|
|
739
796
|
let isDisabled = disabled || readOnly;
|
|
740
797
|
if (isAction && !isDisabled) {
|
|
741
|
-
if (mode ===
|
|
798
|
+
if (mode === "markdown") {
|
|
742
799
|
// Undo/redo in textarea mode is handled natively by the browser
|
|
743
800
|
isDisabled = true;
|
|
744
801
|
} else if (editor) {
|
|
745
|
-
isDisabled = format ===
|
|
802
|
+
isDisabled = format === "undo" ? !editor.can().undo() : !editor.can().redo();
|
|
746
803
|
}
|
|
747
804
|
}
|
|
748
805
|
|
|
@@ -756,15 +813,12 @@ function EditorToolbarButton({ format, className }: EditorToolbarButtonProps) {
|
|
|
756
813
|
};
|
|
757
814
|
|
|
758
815
|
const iconOverride = toolbarIcons?.[format];
|
|
759
|
-
const renderedOverride =
|
|
760
|
-
? iconOverride(iconState)
|
|
761
|
-
: iconOverride;
|
|
816
|
+
const renderedOverride =
|
|
817
|
+
typeof iconOverride === "function" ? iconOverride(iconState) : iconOverride;
|
|
762
818
|
|
|
763
|
-
const classes = [
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
className,
|
|
767
|
-
].filter(Boolean).join(' ');
|
|
819
|
+
const classes = [styles.toolbarButton, active && styles.toolbarButtonActive, className]
|
|
820
|
+
.filter(Boolean)
|
|
821
|
+
.join(" ");
|
|
768
822
|
|
|
769
823
|
return (
|
|
770
824
|
<button
|
|
@@ -774,21 +828,27 @@ function EditorToolbarButton({ format, className }: EditorToolbarButtonProps) {
|
|
|
774
828
|
disabled={isDisabled}
|
|
775
829
|
aria-label={meta.label}
|
|
776
830
|
title={`${meta.label} (${meta.shortcut})`}
|
|
777
|
-
{...(isAction ? {} : {
|
|
831
|
+
{...(isAction ? {} : { "aria-pressed": active })}
|
|
778
832
|
>
|
|
779
|
-
{iconOverride !== undefined
|
|
780
|
-
|
|
781
|
-
|
|
833
|
+
{iconOverride !== undefined ? (
|
|
834
|
+
renderedOverride
|
|
835
|
+
) : (
|
|
836
|
+
<IconComponent size={16} weight={active ? "bold" : "regular"} />
|
|
837
|
+
)}
|
|
782
838
|
</button>
|
|
783
839
|
);
|
|
784
840
|
}
|
|
785
841
|
|
|
786
842
|
function EditorSeparator({ className }: EditorSeparatorProps) {
|
|
787
|
-
const classes = [styles.separator, className].filter(Boolean).join(
|
|
843
|
+
const classes = [styles.separator, className].filter(Boolean).join(" ");
|
|
788
844
|
return <div className={classes} role="separator" aria-orientation="vertical" />;
|
|
789
845
|
}
|
|
790
846
|
|
|
791
|
-
function EditorStatusIndicator({
|
|
847
|
+
function EditorStatusIndicator({
|
|
848
|
+
status: statusOverride,
|
|
849
|
+
labels,
|
|
850
|
+
className,
|
|
851
|
+
}: EditorStatusIndicatorProps) {
|
|
792
852
|
const { saveStatus } = useEditorContext();
|
|
793
853
|
const status = statusOverride ?? saveStatus;
|
|
794
854
|
const mergedLabels = { ...DEFAULT_STATUS_LABELS, ...labels };
|
|
@@ -796,11 +856,9 @@ function EditorStatusIndicator({ status: statusOverride, labels, className }: Ed
|
|
|
796
856
|
|
|
797
857
|
if (!label) return null;
|
|
798
858
|
|
|
799
|
-
const classes = [
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
className,
|
|
803
|
-
].filter(Boolean).join(' ');
|
|
859
|
+
const classes = [styles.statusIndicator, status === "error" && styles.statusError, className]
|
|
860
|
+
.filter(Boolean)
|
|
861
|
+
.join(" ");
|
|
804
862
|
|
|
805
863
|
return (
|
|
806
864
|
<span className={classes} aria-live="polite" role="status">
|
|
@@ -813,9 +871,9 @@ function EditorContentArea({ className }: EditorContentProps) {
|
|
|
813
871
|
const { value, setValue, placeholder, disabled, readOnly, editor, mode, contentRef } =
|
|
814
872
|
useEditorContext();
|
|
815
873
|
|
|
816
|
-
if (mode ===
|
|
874
|
+
if (mode === "rich" && editor && _EditorContent) {
|
|
817
875
|
const TipTapContent = _EditorContent;
|
|
818
|
-
const classes = [styles.content, styles.contentRich, className].filter(Boolean).join(
|
|
876
|
+
const classes = [styles.content, styles.contentRich, className].filter(Boolean).join(" ");
|
|
819
877
|
return (
|
|
820
878
|
<div className={classes} data-placeholder={placeholder}>
|
|
821
879
|
<TipTapContent editor={editor} />
|
|
@@ -824,7 +882,7 @@ function EditorContentArea({ className }: EditorContentProps) {
|
|
|
824
882
|
}
|
|
825
883
|
|
|
826
884
|
// Textarea fallback for markdown mode
|
|
827
|
-
const classes = [styles.content, className].filter(Boolean).join(
|
|
885
|
+
const classes = [styles.content, className].filter(Boolean).join(" ");
|
|
828
886
|
return (
|
|
829
887
|
<div className={classes}>
|
|
830
888
|
<textarea
|
|
@@ -841,10 +899,14 @@ function EditorContentArea({ className }: EditorContentProps) {
|
|
|
841
899
|
);
|
|
842
900
|
}
|
|
843
901
|
|
|
844
|
-
function EditorStatusBar({
|
|
902
|
+
function EditorStatusBar({
|
|
903
|
+
showWordCount = true,
|
|
904
|
+
showCharCount = true,
|
|
905
|
+
className,
|
|
906
|
+
}: EditorStatusBarProps) {
|
|
845
907
|
const { wordCount, charCount, maxLength } = useEditorContext();
|
|
846
908
|
|
|
847
|
-
const classes = [styles.statusBar, className].filter(Boolean).join(
|
|
909
|
+
const classes = [styles.statusBar, className].filter(Boolean).join(" ");
|
|
848
910
|
|
|
849
911
|
const isOverLimit = maxLength !== undefined && charCount > maxLength;
|
|
850
912
|
const isNearLimit = maxLength !== undefined && !isOverLimit && charCount >= maxLength * 0.9;
|
|
@@ -853,7 +915,9 @@ function EditorStatusBar({ showWordCount = true, showCharCount = true, className
|
|
|
853
915
|
styles.statusBarItem,
|
|
854
916
|
isNearLimit && styles.statusBarItemWarning,
|
|
855
917
|
isOverLimit && styles.statusBarItemError,
|
|
856
|
-
]
|
|
918
|
+
]
|
|
919
|
+
.filter(Boolean)
|
|
920
|
+
.join(" ");
|
|
857
921
|
|
|
858
922
|
return (
|
|
859
923
|
<div className={classes} aria-label="Editor statistics">
|
|
@@ -861,18 +925,15 @@ function EditorStatusBar({ showWordCount = true, showCharCount = true, className
|
|
|
861
925
|
<div className={styles.statusBarRight}>
|
|
862
926
|
{showWordCount && (
|
|
863
927
|
<span className={styles.statusBarItem}>
|
|
864
|
-
{wordCount} {wordCount === 1 ?
|
|
928
|
+
{wordCount} {wordCount === 1 ? "Word" : "Words"}
|
|
865
929
|
</span>
|
|
866
930
|
)}
|
|
867
|
-
{showWordCount && showCharCount &&
|
|
868
|
-
<EditorSeparator />
|
|
869
|
-
)}
|
|
931
|
+
{showWordCount && showCharCount && <EditorSeparator />}
|
|
870
932
|
{showCharCount && (
|
|
871
933
|
<span className={charLimitClasses}>
|
|
872
934
|
{maxLength !== undefined
|
|
873
935
|
? `${charCount} / ${maxLength}`
|
|
874
|
-
: `${charCount} ${charCount === 1 ?
|
|
875
|
-
}
|
|
936
|
+
: `${charCount} ${charCount === 1 ? "Character" : "Characters"}`}
|
|
876
937
|
</span>
|
|
877
938
|
)}
|
|
878
939
|
</div>
|