@forgedevstack/bear 1.0.3 → 1.0.4
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/dist/components/Accordion/Accordion.cjs +1 -1
- package/dist/components/Accordion/Accordion.const.cjs +1 -0
- package/dist/components/Accordion/Accordion.const.d.ts +10 -0
- package/dist/components/Accordion/Accordion.const.js +8 -0
- package/dist/components/Accordion/Accordion.d.ts +1 -0
- package/dist/components/Accordion/Accordion.js +49 -44
- package/dist/components/Accordion/Accordion.types.d.ts +2 -0
- package/dist/components/Accordion/index.d.ts +3 -2
- package/dist/components/ActivityItem/ActivityItem.cjs +1 -0
- package/dist/components/ActivityItem/ActivityItem.d.ts +7 -0
- package/dist/components/ActivityItem/ActivityItem.js +44 -0
- package/dist/components/ActivityItem/ActivityItem.types.d.ts +17 -0
- package/dist/components/ActivityItem/index.d.ts +2 -0
- package/dist/components/Alert/Alert.cjs +1 -1
- package/dist/components/Alert/Alert.const.cjs +1 -0
- package/dist/components/Alert/Alert.const.d.ts +14 -0
- package/dist/components/Alert/Alert.const.js +27 -0
- package/dist/components/Alert/Alert.js +54 -63
- package/dist/components/Alert/Alert.types.d.ts +3 -1
- package/dist/components/Avatar/Avatar.cjs +1 -1
- package/dist/components/Avatar/Avatar.const.cjs +1 -0
- package/dist/components/Avatar/Avatar.const.d.ts +28 -0
- package/dist/components/Avatar/Avatar.const.js +28 -0
- package/dist/components/Avatar/Avatar.js +49 -60
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Badge/Badge.cjs +1 -1
- package/dist/components/Badge/Badge.js +24 -22
- package/dist/components/BearLogo/EmberLogo.cjs +17 -0
- package/dist/components/BearLogo/EmberLogo.js +91 -0
- package/dist/components/BearLogo/index.d.ts +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.const.cjs +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.const.d.ts +16 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.const.js +19 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +49 -34
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +8 -1
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.constants.cjs +1 -1
- package/dist/components/Button/Button.constants.d.ts +2 -2
- package/dist/components/Button/Button.constants.js +2 -2
- package/dist/components/Button/Button.js +41 -46
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.helpers.cjs +1 -0
- package/dist/components/Calendar/Calendar.helpers.d.ts +10 -0
- package/dist/components/Calendar/Calendar.helpers.js +9 -0
- package/dist/components/Calendar/Calendar.js +112 -115
- package/dist/components/Card/Card.cjs +1 -1
- package/dist/components/Card/Card.const.cjs +1 -0
- package/dist/components/Card/Card.const.d.ts +13 -0
- package/dist/components/Card/Card.const.js +32 -0
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Card/Card.js +101 -105
- package/dist/components/Card/index.d.ts +3 -2
- package/dist/components/Chart/Chart.cjs +1 -0
- package/dist/components/Chart/Chart.const.d.ts +15 -0
- package/dist/components/Chart/Chart.d.ts +18 -0
- package/dist/components/Chart/Chart.js +225 -0
- package/dist/components/Chart/Chart.types.d.ts +51 -0
- package/dist/components/Chart/Chart.utils.d.ts +31 -0
- package/dist/components/Chart/index.d.ts +2 -0
- package/dist/components/CodeBlock/CodeBlock.cjs +2 -2
- package/dist/components/CodeBlock/CodeBlock.js +65 -52
- package/dist/components/CodeBlock/CodeBlock.types.d.ts +12 -1
- package/dist/components/Editable/Editable.cjs +1 -1
- package/dist/components/Editable/Editable.js +115 -115
- package/dist/components/Gauge/Gauge.cjs +1 -0
- package/dist/components/Gauge/Gauge.d.ts +3 -0
- package/dist/components/Gauge/Gauge.js +92 -0
- package/dist/components/Gauge/Gauge.types.d.ts +27 -0
- package/dist/components/Gauge/index.d.ts +2 -0
- package/dist/components/Icon/icons/editor.cjs +1 -1
- package/dist/components/Icon/icons/editor.d.ts +1 -0
- package/dist/components/Icon/icons/editor.js +66 -61
- package/dist/components/Icon/icons/misc.cjs +1 -1
- package/dist/components/Icon/icons/misc.d.ts +13 -0
- package/dist/components/Icon/icons/misc.js +157 -88
- package/dist/components/Icon/index.d.ts +22 -0
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +36 -35
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.const.cjs +1 -0
- package/dist/components/Modal/Modal.const.d.ts +10 -0
- package/dist/components/Modal/Modal.const.js +17 -0
- package/dist/components/Modal/Modal.d.ts +11 -0
- package/dist/components/Modal/Modal.js +80 -77
- package/dist/components/Modal/Modal.types.d.ts +6 -1
- package/dist/components/Modal/index.d.ts +3 -2
- package/dist/components/Rating/Rating.cjs +1 -1
- package/dist/components/Rating/Rating.const.cjs +1 -0
- package/dist/components/Rating/Rating.const.d.ts +14 -0
- package/dist/components/Rating/Rating.const.js +22 -0
- package/dist/components/Rating/Rating.d.ts +5 -10
- package/dist/components/Rating/Rating.js +135 -93
- package/dist/components/Rating/Rating.types.d.ts +27 -25
- package/dist/components/Rating/index.d.ts +2 -2
- package/dist/components/RichEditor/RichEditor.cjs +1 -10
- package/dist/components/RichEditor/RichEditor.const.cjs +141 -0
- package/dist/components/RichEditor/RichEditor.const.d.ts +137 -0
- package/dist/components/RichEditor/RichEditor.const.js +279 -0
- package/dist/components/RichEditor/RichEditor.d.ts +14 -0
- package/dist/components/RichEditor/RichEditor.js +341 -129
- package/dist/components/RichEditor/RichEditor.types.d.ts +38 -1
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.cjs +1 -0
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.d.ts +4 -0
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.js +25 -0
- package/dist/components/RichEditor/components/ToolbarButton/index.d.ts +1 -0
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -0
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.d.ts +4 -0
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +126 -0
- package/dist/components/RichEditor/components/ToolbarColorPicker/index.d.ts +1 -0
- package/dist/components/RichEditor/components/ToolbarDropdown/ToolbarDropdown.cjs +1 -0
- package/dist/components/RichEditor/components/ToolbarDropdown/ToolbarDropdown.d.ts +4 -0
- package/dist/components/RichEditor/components/ToolbarDropdown/ToolbarDropdown.js +57 -0
- package/dist/components/RichEditor/components/ToolbarDropdown/index.d.ts +1 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.cjs +1 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.d.ts +7 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.js +45 -0
- package/dist/components/RichEditor/components/ToolbarMore/index.d.ts +2 -0
- package/dist/components/RichEditor/components/index.d.ts +4 -0
- package/dist/components/RichEditor/helpers/formatHelpers.cjs +1 -0
- package/dist/components/RichEditor/helpers/formatHelpers.d.ts +57 -0
- package/dist/components/RichEditor/helpers/formatHelpers.js +26 -0
- package/dist/components/RichEditor/helpers/index.d.ts +1 -0
- package/dist/components/RichEditor/index.d.ts +4 -2
- package/dist/components/Sidebar/Sidebar.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.const.cjs +1 -0
- package/dist/components/Sidebar/Sidebar.const.d.ts +16 -0
- package/dist/components/Sidebar/Sidebar.const.js +22 -0
- package/dist/components/Sidebar/Sidebar.d.ts +14 -2
- package/dist/components/Sidebar/Sidebar.js +50 -138
- package/dist/components/Sidebar/Sidebar.types.d.ts +7 -3
- package/dist/components/Sidebar/components/SidebarGroup/SidebarGroup.cjs +1 -0
- package/dist/components/Sidebar/components/SidebarGroup/SidebarGroup.d.ts +4 -0
- package/dist/components/Sidebar/components/SidebarGroup/SidebarGroup.js +45 -0
- package/dist/components/Sidebar/components/SidebarGroup/index.d.ts +2 -0
- package/dist/components/Sidebar/components/SidebarItem/SidebarItem.cjs +1 -0
- package/dist/components/Sidebar/components/SidebarItem/SidebarItem.d.ts +4 -0
- package/dist/components/Sidebar/components/SidebarItem/SidebarItem.js +66 -0
- package/dist/components/Sidebar/components/SidebarItem/index.d.ts +2 -0
- package/dist/components/Sidebar/components/index.d.ts +2 -0
- package/dist/components/Sidebar/index.d.ts +5 -2
- package/dist/components/SignPad/SignPad.cjs +1 -0
- package/dist/components/SignPad/SignPad.const.cjs +1 -0
- package/dist/components/SignPad/SignPad.const.d.ts +19 -0
- package/dist/components/SignPad/SignPad.const.js +20 -0
- package/dist/components/SignPad/SignPad.d.ts +17 -0
- package/dist/components/SignPad/SignPad.js +161 -0
- package/dist/components/SignPad/SignPad.types.d.ts +37 -0
- package/dist/components/SignPad/index.d.ts +3 -0
- package/dist/components/Skeleton/Skeleton.cjs +1 -1
- package/dist/components/Skeleton/Skeleton.const.cjs +36 -0
- package/dist/components/Skeleton/Skeleton.const.d.ts +12 -0
- package/dist/components/Skeleton/Skeleton.const.js +58 -0
- package/dist/components/Skeleton/Skeleton.d.ts +15 -24
- package/dist/components/Skeleton/Skeleton.js +132 -103
- package/dist/components/Skeleton/Skeleton.types.d.ts +18 -8
- package/dist/components/Skeleton/index.d.ts +2 -2
- package/dist/components/Sparkline/Sparkline.cjs +1 -0
- package/dist/components/Sparkline/Sparkline.const.cjs +1 -0
- package/dist/components/Sparkline/Sparkline.const.d.ts +16 -0
- package/dist/components/Sparkline/Sparkline.const.js +16 -0
- package/dist/components/Sparkline/Sparkline.d.ts +3 -0
- package/dist/components/Sparkline/Sparkline.js +80 -0
- package/dist/components/Sparkline/Sparkline.types.d.ts +19 -0
- package/dist/components/Sparkline/Sparkline.utils.cjs +1 -0
- package/dist/components/Sparkline/Sparkline.utils.d.ts +27 -0
- package/dist/components/Sparkline/Sparkline.utils.js +30 -0
- package/dist/components/Sparkline/index.d.ts +5 -0
- package/dist/components/SpeedDial/SpeedDial.cjs +12 -1
- package/dist/components/SpeedDial/SpeedDial.const.cjs +1 -0
- package/dist/components/SpeedDial/SpeedDial.const.d.ts +22 -0
- package/dist/components/SpeedDial/SpeedDial.const.js +26 -0
- package/dist/components/SpeedDial/SpeedDial.d.ts +5 -7
- package/dist/components/SpeedDial/SpeedDial.js +154 -144
- package/dist/components/SpeedDial/SpeedDial.types.d.ts +26 -29
- package/dist/components/SpeedDial/index.d.ts +1 -1
- package/dist/components/Spinner/Spinner.cjs +1 -1
- package/dist/components/Spinner/Spinner.js +17 -15
- package/dist/components/StatCard/StatCard.cjs +1 -0
- package/dist/components/StatCard/StatCard.d.ts +7 -0
- package/dist/components/StatCard/StatCard.js +36 -0
- package/dist/components/StatCard/StatCard.types.d.ts +13 -0
- package/dist/components/StatCard/index.d.ts +2 -0
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.const.cjs +1 -0
- package/dist/components/Stepper/Stepper.const.d.ts +29 -0
- package/dist/components/Stepper/Stepper.const.js +46 -0
- package/dist/components/Stepper/Stepper.d.ts +10 -3
- package/dist/components/Stepper/Stepper.js +143 -92
- package/dist/components/Stepper/Stepper.types.d.ts +63 -13
- package/dist/components/Stepper/index.d.ts +2 -2
- package/dist/components/Switch/Switch.cjs +1 -1
- package/dist/components/Switch/Switch.js +74 -47
- package/dist/components/Switch/Switch.types.d.ts +11 -1
- package/dist/components/Tabs/Tabs.cjs +1 -1
- package/dist/components/Tabs/Tabs.js +33 -29
- package/dist/components/TimePicker/TimePicker.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.d.ts +14 -0
- package/dist/components/TimePicker/TimePicker.constants.js +18 -4
- package/dist/components/TimePicker/TimePicker.js +92 -91
- package/dist/components/Timeline/Timeline.cjs +1 -1
- package/dist/components/Timeline/Timeline.const.cjs +1 -0
- package/dist/components/Timeline/Timeline.const.d.ts +40 -0
- package/dist/components/Timeline/Timeline.const.js +58 -0
- package/dist/components/Timeline/Timeline.d.ts +16 -2
- package/dist/components/Timeline/Timeline.js +131 -63
- package/dist/components/Timeline/Timeline.types.d.ts +30 -11
- package/dist/components/Timeline/index.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.js +37 -35
- package/dist/components/Typography/Typography.cjs +1 -1
- package/dist/components/Typography/Typography.js +38 -36
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +17 -5
- package/dist/components/index.js +216 -195
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +24 -0
- package/dist/hooks/index.js +42 -14
- package/dist/hooks/useBounce/index.d.ts +2 -0
- package/dist/hooks/useBounce/useBounce.cjs +1 -0
- package/dist/hooks/useBounce/useBounce.d.ts +2 -0
- package/dist/hooks/useBounce/useBounce.js +36 -0
- package/dist/hooks/useBounce/useBounce.types.d.ts +27 -0
- package/dist/hooks/useClickOutside/index.d.ts +2 -0
- package/dist/hooks/useClickOutside/useClickOutside.d.ts +22 -0
- package/dist/hooks/useClickOutside/useClickOutside.types.d.ts +10 -0
- package/dist/hooks/useClipboard/index.d.ts +2 -0
- package/dist/hooks/useClipboard/useClipboard.cjs +1 -0
- package/dist/hooks/useClipboard/useClipboard.d.ts +15 -0
- package/dist/hooks/useClipboard/useClipboard.js +22 -0
- package/dist/hooks/useClipboard/useClipboard.types.d.ts +20 -0
- package/dist/hooks/useDebounce/index.d.ts +2 -0
- package/dist/hooks/useDebounce/useDebounce.cjs +1 -0
- package/dist/hooks/useDebounce/useDebounce.d.ts +32 -0
- package/dist/hooks/useDebounce/useDebounce.js +39 -0
- package/dist/hooks/useDebounce/useDebounce.types.d.ts +20 -0
- package/dist/hooks/useFloat/index.d.ts +2 -0
- package/dist/hooks/useFloat/useFloat.cjs +1 -0
- package/dist/hooks/useFloat/useFloat.d.ts +2 -0
- package/dist/hooks/useFloat/useFloat.js +37 -0
- package/dist/hooks/useFloat/useFloat.types.d.ts +25 -0
- package/dist/hooks/useIntersectionObserver/index.d.ts +2 -0
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -0
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.d.ts +25 -0
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.js +39 -0
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.types.d.ts +22 -0
- package/dist/hooks/useKeyPress/index.d.ts +2 -0
- package/dist/hooks/useKeyPress/useKeyPress.cjs +1 -0
- package/dist/hooks/useKeyPress/useKeyPress.d.ts +22 -0
- package/dist/hooks/useKeyPress/useKeyPress.js +39 -0
- package/dist/hooks/useKeyPress/useKeyPress.types.d.ts +19 -0
- package/dist/hooks/useLocalStorage/index.d.ts +2 -0
- package/dist/hooks/useLocalStorage/useLocalStorage.cjs +1 -0
- package/dist/hooks/useLocalStorage/useLocalStorage.d.ts +11 -0
- package/dist/hooks/useLocalStorage/useLocalStorage.js +47 -0
- package/dist/hooks/useLocalStorage/useLocalStorage.types.d.ts +16 -0
- package/dist/hooks/useMediaQuery/index.d.ts +3 -0
- package/dist/hooks/useMediaQuery/useMediaQuery.d.ts +12 -0
- package/dist/hooks/useMediaQuery/useMediaQuery.types.d.ts +21 -0
- package/dist/hooks/useParallax/index.d.ts +2 -0
- package/dist/hooks/useParallax/useParallax.cjs +1 -0
- package/dist/hooks/useParallax/useParallax.d.ts +2 -0
- package/dist/hooks/useParallax/useParallax.js +36 -0
- package/dist/hooks/useParallax/useParallax.types.d.ts +19 -0
- package/dist/hooks/usePulse/index.d.ts +2 -0
- package/dist/hooks/usePulse/usePulse.cjs +1 -0
- package/dist/hooks/usePulse/usePulse.d.ts +2 -0
- package/dist/hooks/usePulse/usePulse.js +38 -0
- package/dist/hooks/usePulse/usePulse.types.d.ts +29 -0
- package/dist/hooks/useShake/index.d.ts +2 -0
- package/dist/hooks/useShake/useShake.cjs +1 -0
- package/dist/hooks/useShake/useShake.d.ts +2 -0
- package/dist/hooks/useShake/useShake.js +14 -0
- package/dist/hooks/useShake/useShake.types.d.ts +19 -0
- package/dist/hooks/useSlide/index.d.ts +2 -0
- package/dist/hooks/useSlide/useSlide.cjs +1 -0
- package/dist/hooks/useSlide/useSlide.d.ts +2 -0
- package/dist/hooks/useSlide/useSlide.js +68 -0
- package/dist/hooks/useSlide/useSlide.types.d.ts +36 -0
- package/dist/hooks/useThrottle/index.d.ts +2 -0
- package/dist/hooks/useThrottle/useThrottle.cjs +1 -0
- package/dist/hooks/useThrottle/useThrottle.d.ts +26 -0
- package/dist/hooks/useThrottle/useThrottle.js +44 -0
- package/dist/hooks/useThrottle/useThrottle.types.d.ts +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +273 -224
- package/dist/styles.css +1 -1
- package/package.json +14 -21
- package/dist/components/RichEditor/RichEditor.icons.cjs +0 -1
- package/dist/components/RichEditor/RichEditor.icons.d.ts +0 -16
- package/dist/components/RichEditor/RichEditor.icons.js +0 -62
- package/dist/components/RichEditor/RichEditor.utils.cjs +0 -1
- package/dist/components/RichEditor/RichEditor.utils.d.ts +0 -3
- package/dist/components/RichEditor/RichEditor.utils.js +0 -22
|
@@ -1,144 +1,356 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { jsxs as me, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as pe, useState as C, useEffect as _, useCallback as d } from "react";
|
|
3
|
+
import { cn as b } from "../../utils/cn.js";
|
|
4
|
+
import { getActiveFormats as be, queryCommandValue as Re, execCommand as u, insertLink as Te, setTextColor as x, setHighlightColor as S, fileToDataUrl as v, insertImage as A } from "./helpers/formatHelpers.js";
|
|
5
|
+
import { RICH_EDITOR_MIN_HEIGHT as ye, RICH_EDITOR_DEFAULT_TOOLBAR as _e, RICH_EDITOR_CONTENT_STYLES as Ee, RICH_EDITOR_BUTTON_CONFIG as O, RICH_EDITOR_TOOLBAR_CLASSES as Le, RICH_EDITOR_CONTENT_CLASSES as ze, RICH_EDITOR_ROOT_CLASSES as He, RICH_EDITOR_DIVIDER_CLASSES as ke, RICH_EDITOR_HEADING_OPTIONS as xe } from "./RichEditor.const.js";
|
|
6
|
+
import { ToolbarButton as f } from "./components/ToolbarButton/ToolbarButton.js";
|
|
7
|
+
import { ToolbarDropdown as Se } from "./components/ToolbarDropdown/ToolbarDropdown.js";
|
|
8
|
+
import { ToolbarColorPicker as D } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
|
|
9
|
+
import { ToolbarMore as ve } from "./components/ToolbarMore/ToolbarMore.js";
|
|
10
|
+
import { TextIcon as Ae, InsertLinkIcon as B, InsertPhotoIcon as F, AlignLeftIcon as N, AlignCenterIcon as w, AlignRightIcon as U, AlignJustifyIcon as M, IndentIncreaseIcon as V, IndentDecreaseIcon as j, FormatClearIcon as J, TableIcon as Oe, CodeIcon as De, QuoteIcon as Be, ListNumberedIcon as Fe, ListBulletIcon as Ne, Heading3Icon as we, Heading2Icon as Ue, Heading1Icon as Me, StrikethroughIcon as Ve, UnderlineIcon as je, ItalicIcon as Je, BoldIcon as Pe } from "../Icon/icons/editor.js";
|
|
11
|
+
const qe = 6, nt = (P) => {
|
|
12
|
+
const {
|
|
13
|
+
value: I,
|
|
14
|
+
defaultValue: E = "",
|
|
15
|
+
onChange: R,
|
|
16
|
+
placeholder: q = "Start typing...",
|
|
17
|
+
disabled: i = !1,
|
|
18
|
+
readOnly: o = !1,
|
|
19
|
+
minHeight: T = ye,
|
|
20
|
+
maxHeight: m,
|
|
21
|
+
toolbar: L = _e,
|
|
22
|
+
className: G = "",
|
|
23
|
+
testId: $,
|
|
24
|
+
id: Y,
|
|
25
|
+
allowImagePaste: z = !0,
|
|
26
|
+
...K
|
|
27
|
+
} = P, a = pe(null), [Q, W] = C(/* @__PURE__ */ new Set()), [X, H] = C("p"), [Z, ee] = C("#000000"), [te, ne] = C("#fef08a"), [ie, oe] = C([]), [re, le] = C([]);
|
|
28
|
+
_(() => {
|
|
29
|
+
const e = "bear-rich-editor-styles";
|
|
30
|
+
if (!document.getElementById(e)) {
|
|
31
|
+
const n = document.createElement("style");
|
|
32
|
+
n.id = e, n.textContent = Ee, document.head.appendChild(n);
|
|
33
|
+
}
|
|
34
|
+
}, []), _(() => {
|
|
35
|
+
a.current && I !== void 0 && a.current.innerHTML !== I && (a.current.innerHTML = I);
|
|
36
|
+
}, [I]), _(() => {
|
|
37
|
+
a.current && E && !I && (a.current.innerHTML = E);
|
|
37
38
|
}, []);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
39
|
+
const h = d(() => {
|
|
40
|
+
W(be());
|
|
41
|
+
const e = Re("formatBlock");
|
|
42
|
+
e && H(e.toLowerCase().replace(/[<>]/g, ""));
|
|
43
|
+
}, []), l = d(() => {
|
|
44
|
+
a.current && R && R(a.current.innerHTML), h();
|
|
45
|
+
}, [R, h]), ae = d((e) => {
|
|
46
|
+
var s;
|
|
47
|
+
if (i || o) return;
|
|
48
|
+
(s = a.current) == null || s.focus();
|
|
49
|
+
const n = O[e];
|
|
50
|
+
if (!n) return;
|
|
51
|
+
const c = "value" in n ? n.value : void 0;
|
|
52
|
+
c ? u(n.command, c) : u(n.command), h(), l();
|
|
53
|
+
}, [i, o, h, l]), se = d((e) => {
|
|
54
|
+
var n;
|
|
55
|
+
i || o || ((n = a.current) == null || n.focus(), u("formatBlock", e), H(e), l());
|
|
56
|
+
}, [i, o, l]), ce = d(() => {
|
|
57
|
+
var s;
|
|
58
|
+
if (i || o) return;
|
|
59
|
+
const e = window.getSelection(), n = e && e.toString().length > 0, c = prompt("Enter URL:", n ? "" : "https://");
|
|
60
|
+
c && ((s = a.current) == null || s.focus(), Te(c), l());
|
|
61
|
+
}, [i, o, l]), p = d((e, n) => {
|
|
62
|
+
if (!e) return;
|
|
63
|
+
(n === "text" ? oe : le)((s) => {
|
|
64
|
+
const r = s.filter((g) => g !== e);
|
|
65
|
+
return [e, ...r].slice(0, qe);
|
|
66
|
+
});
|
|
67
|
+
}, []), de = d((e) => {
|
|
68
|
+
var n;
|
|
69
|
+
i || o || ((n = a.current) == null || n.focus(), x(e), ee(e), p(e, "text"), l());
|
|
70
|
+
}, [i, o, l, p]), ue = d((e) => {
|
|
71
|
+
var n;
|
|
72
|
+
i || o || ((n = a.current) == null || n.focus(), S(e), ne(e), p(e, "highlight"), l());
|
|
73
|
+
}, [i, o, l, p]), fe = d((e) => {
|
|
74
|
+
var n;
|
|
75
|
+
i || o || ((n = a.current) == null || n.focus(), x(e), l());
|
|
76
|
+
}, [i, o, l]), ge = d((e) => {
|
|
77
|
+
var n;
|
|
78
|
+
i || o || ((n = a.current) == null || n.focus(), S(e), l());
|
|
79
|
+
}, [i, o, l]), he = d(async (e) => {
|
|
80
|
+
var c;
|
|
81
|
+
if (!z) return;
|
|
82
|
+
const n = (c = e.clipboardData) == null ? void 0 : c.items;
|
|
83
|
+
if (n)
|
|
84
|
+
for (let s = 0; s < n.length; s++) {
|
|
85
|
+
const r = n[s];
|
|
86
|
+
if (r.type.startsWith("image/")) {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
const g = r.getAsFile();
|
|
89
|
+
if (g) {
|
|
90
|
+
const y = await v(g);
|
|
91
|
+
A(y), l();
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
84
95
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
}, [z, l]), Ce = d(() => {
|
|
97
|
+
if (i || o) return;
|
|
98
|
+
const e = document.createElement("input");
|
|
99
|
+
e.type = "file", e.accept = "image/*", e.onchange = async (n) => {
|
|
100
|
+
var s, r;
|
|
101
|
+
const c = (s = n.target.files) == null ? void 0 : s[0];
|
|
102
|
+
if (c) {
|
|
103
|
+
const g = await v(c);
|
|
104
|
+
(r = a.current) == null || r.focus(), A(g), l();
|
|
105
|
+
}
|
|
106
|
+
}, e.click();
|
|
107
|
+
}, [i, o, l]), Ie = {
|
|
108
|
+
bold: /* @__PURE__ */ t(Pe, { size: 16 }),
|
|
109
|
+
italic: /* @__PURE__ */ t(Je, { size: 16 }),
|
|
110
|
+
underline: /* @__PURE__ */ t(je, { size: 16 }),
|
|
111
|
+
strikethrough: /* @__PURE__ */ t(Ve, { size: 16 }),
|
|
112
|
+
heading1: /* @__PURE__ */ t(Me, { size: 16 }),
|
|
113
|
+
heading2: /* @__PURE__ */ t(Ue, { size: 16 }),
|
|
114
|
+
heading3: /* @__PURE__ */ t(we, { size: 16 }),
|
|
115
|
+
bulletList: /* @__PURE__ */ t(Ne, { size: 16 }),
|
|
116
|
+
orderedList: /* @__PURE__ */ t(Fe, { size: 16 }),
|
|
117
|
+
blockquote: /* @__PURE__ */ t(Be, { size: 16 }),
|
|
118
|
+
code: /* @__PURE__ */ t(De, { size: 16 }),
|
|
119
|
+
link: /* @__PURE__ */ t(B, { size: 16 }),
|
|
120
|
+
alignLeft: /* @__PURE__ */ t(N, { size: 16 }),
|
|
121
|
+
alignCenter: /* @__PURE__ */ t(w, { size: 16 }),
|
|
122
|
+
alignRight: /* @__PURE__ */ t(U, { size: 16 }),
|
|
123
|
+
alignJustify: /* @__PURE__ */ t(M, { size: 16 }),
|
|
124
|
+
image: /* @__PURE__ */ t(F, { size: 16 }),
|
|
125
|
+
indent: /* @__PURE__ */ t(V, { size: 16 }),
|
|
126
|
+
outdent: /* @__PURE__ */ t(j, { size: 16 }),
|
|
127
|
+
clearFormat: /* @__PURE__ */ t(J, { size: 16 }),
|
|
128
|
+
table: /* @__PURE__ */ t(Oe, { size: 16 })
|
|
129
|
+
}, k = (e, n) => {
|
|
88
130
|
if (e === "divider")
|
|
89
|
-
return /* @__PURE__ */
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
131
|
+
return /* @__PURE__ */ t("div", { className: b("Bear-RichEditor__divider", ke) }, `divider-${n}`);
|
|
132
|
+
if (e === "headingDropdown")
|
|
133
|
+
return /* @__PURE__ */ t(
|
|
134
|
+
Se,
|
|
135
|
+
{
|
|
136
|
+
options: xe,
|
|
137
|
+
value: X,
|
|
138
|
+
onChange: se,
|
|
139
|
+
title: "Text Style",
|
|
140
|
+
disabled: i || o,
|
|
141
|
+
icon: /* @__PURE__ */ t(Ae, { size: 16 })
|
|
142
|
+
},
|
|
143
|
+
"heading-dropdown"
|
|
144
|
+
);
|
|
145
|
+
if (e === "textColor")
|
|
146
|
+
return /* @__PURE__ */ t(
|
|
147
|
+
D,
|
|
148
|
+
{
|
|
149
|
+
value: Z,
|
|
150
|
+
onChange: de,
|
|
151
|
+
title: "Text Color",
|
|
152
|
+
disabled: i || o,
|
|
153
|
+
type: "text",
|
|
154
|
+
recentColors: ie,
|
|
155
|
+
onApplyLast: fe
|
|
156
|
+
},
|
|
157
|
+
"text-color"
|
|
158
|
+
);
|
|
159
|
+
if (e === "highlightColor")
|
|
160
|
+
return /* @__PURE__ */ t(
|
|
161
|
+
D,
|
|
162
|
+
{
|
|
163
|
+
value: te,
|
|
164
|
+
onChange: ue,
|
|
165
|
+
title: "Highlight Color",
|
|
166
|
+
disabled: i || o,
|
|
167
|
+
type: "highlight",
|
|
168
|
+
recentColors: re,
|
|
169
|
+
onApplyLast: ge
|
|
170
|
+
},
|
|
171
|
+
"highlight-color"
|
|
172
|
+
);
|
|
173
|
+
if (e === "link")
|
|
174
|
+
return /* @__PURE__ */ t(
|
|
175
|
+
f,
|
|
176
|
+
{
|
|
177
|
+
icon: /* @__PURE__ */ t(B, { size: 16 }),
|
|
178
|
+
title: "Insert Link",
|
|
179
|
+
onClick: ce,
|
|
180
|
+
disabled: i || o
|
|
181
|
+
},
|
|
182
|
+
"link"
|
|
183
|
+
);
|
|
184
|
+
if (e === "image")
|
|
185
|
+
return /* @__PURE__ */ t(
|
|
186
|
+
f,
|
|
187
|
+
{
|
|
188
|
+
icon: /* @__PURE__ */ t(F, { size: 16 }),
|
|
189
|
+
title: "Insert Image",
|
|
190
|
+
onClick: Ce,
|
|
191
|
+
disabled: i || o
|
|
192
|
+
},
|
|
193
|
+
"image"
|
|
194
|
+
);
|
|
195
|
+
if (e === "alignLeft")
|
|
196
|
+
return /* @__PURE__ */ t(
|
|
197
|
+
f,
|
|
198
|
+
{
|
|
199
|
+
icon: /* @__PURE__ */ t(N, { size: 16 }),
|
|
200
|
+
title: "Align Left",
|
|
201
|
+
onClick: () => {
|
|
202
|
+
var r;
|
|
203
|
+
(r = a.current) == null || r.focus(), u("justifyLeft"), l();
|
|
204
|
+
},
|
|
205
|
+
disabled: i || o
|
|
206
|
+
},
|
|
207
|
+
"alignLeft"
|
|
208
|
+
);
|
|
209
|
+
if (e === "alignCenter")
|
|
210
|
+
return /* @__PURE__ */ t(
|
|
211
|
+
f,
|
|
212
|
+
{
|
|
213
|
+
icon: /* @__PURE__ */ t(w, { size: 16 }),
|
|
214
|
+
title: "Align Center",
|
|
215
|
+
onClick: () => {
|
|
216
|
+
var r;
|
|
217
|
+
(r = a.current) == null || r.focus(), u("justifyCenter"), l();
|
|
218
|
+
},
|
|
219
|
+
disabled: i || o
|
|
220
|
+
},
|
|
221
|
+
"alignCenter"
|
|
222
|
+
);
|
|
223
|
+
if (e === "alignRight")
|
|
224
|
+
return /* @__PURE__ */ t(
|
|
225
|
+
f,
|
|
226
|
+
{
|
|
227
|
+
icon: /* @__PURE__ */ t(U, { size: 16 }),
|
|
228
|
+
title: "Align Right",
|
|
229
|
+
onClick: () => {
|
|
230
|
+
var r;
|
|
231
|
+
(r = a.current) == null || r.focus(), u("justifyRight"), l();
|
|
232
|
+
},
|
|
233
|
+
disabled: i || o
|
|
234
|
+
},
|
|
235
|
+
"alignRight"
|
|
236
|
+
);
|
|
237
|
+
if (e === "alignJustify")
|
|
238
|
+
return /* @__PURE__ */ t(
|
|
239
|
+
f,
|
|
240
|
+
{
|
|
241
|
+
icon: /* @__PURE__ */ t(M, { size: 16 }),
|
|
242
|
+
title: "Justify",
|
|
243
|
+
onClick: () => {
|
|
244
|
+
var r;
|
|
245
|
+
(r = a.current) == null || r.focus(), u("justifyFull"), l();
|
|
246
|
+
},
|
|
247
|
+
disabled: i || o
|
|
248
|
+
},
|
|
249
|
+
"alignJustify"
|
|
250
|
+
);
|
|
251
|
+
if (e === "indent")
|
|
252
|
+
return /* @__PURE__ */ t(
|
|
253
|
+
f,
|
|
254
|
+
{
|
|
255
|
+
icon: /* @__PURE__ */ t(V, { size: 16 }),
|
|
256
|
+
title: "Increase Indent",
|
|
257
|
+
onClick: () => {
|
|
258
|
+
var r;
|
|
259
|
+
(r = a.current) == null || r.focus(), u("indent"), l();
|
|
260
|
+
},
|
|
261
|
+
disabled: i || o
|
|
262
|
+
},
|
|
263
|
+
"indent"
|
|
264
|
+
);
|
|
265
|
+
if (e === "outdent")
|
|
266
|
+
return /* @__PURE__ */ t(
|
|
267
|
+
f,
|
|
268
|
+
{
|
|
269
|
+
icon: /* @__PURE__ */ t(j, { size: 16 }),
|
|
270
|
+
title: "Decrease Indent",
|
|
271
|
+
onClick: () => {
|
|
272
|
+
var r;
|
|
273
|
+
(r = a.current) == null || r.focus(), u("outdent"), l();
|
|
274
|
+
},
|
|
275
|
+
disabled: i || o
|
|
276
|
+
},
|
|
277
|
+
"outdent"
|
|
278
|
+
);
|
|
279
|
+
if (e === "clearFormat")
|
|
280
|
+
return /* @__PURE__ */ t(
|
|
281
|
+
f,
|
|
282
|
+
{
|
|
283
|
+
icon: /* @__PURE__ */ t(J, { size: 16 }),
|
|
284
|
+
title: "Clear Formatting",
|
|
285
|
+
onClick: () => {
|
|
286
|
+
var r;
|
|
287
|
+
(r = a.current) == null || r.focus(), u("removeFormat"), l();
|
|
288
|
+
},
|
|
289
|
+
disabled: i || o
|
|
290
|
+
},
|
|
291
|
+
"clearFormat"
|
|
292
|
+
);
|
|
293
|
+
if (e === "more")
|
|
294
|
+
return /* @__PURE__ */ t(ve, { disabled: i || o, children: [
|
|
295
|
+
"alignLeft",
|
|
296
|
+
"alignCenter",
|
|
297
|
+
"alignRight",
|
|
298
|
+
"alignJustify",
|
|
299
|
+
"indent",
|
|
300
|
+
"outdent",
|
|
301
|
+
"blockquote",
|
|
302
|
+
"code",
|
|
303
|
+
"clearFormat"
|
|
304
|
+
].map((g, y) => k(g, y + 1e3)) }, "more");
|
|
305
|
+
const c = O[e], s = Ie[e];
|
|
306
|
+
return !c || !s ? null : /* @__PURE__ */ t(
|
|
307
|
+
f,
|
|
105
308
|
{
|
|
106
|
-
icon:
|
|
107
|
-
title:
|
|
108
|
-
active:
|
|
109
|
-
onClick: () =>
|
|
110
|
-
disabled: i ||
|
|
309
|
+
icon: s,
|
|
310
|
+
title: c.title,
|
|
311
|
+
active: Q.has(e),
|
|
312
|
+
onClick: () => ae(e),
|
|
313
|
+
disabled: i || o
|
|
111
314
|
},
|
|
112
315
|
e
|
|
113
|
-
)
|
|
316
|
+
);
|
|
114
317
|
};
|
|
115
|
-
return /* @__PURE__ */
|
|
318
|
+
return /* @__PURE__ */ me(
|
|
116
319
|
"div",
|
|
117
320
|
{
|
|
118
|
-
|
|
119
|
-
|
|
321
|
+
id: Y,
|
|
322
|
+
"data-testid": $,
|
|
323
|
+
className: b(
|
|
324
|
+
"Bear-RichEditor",
|
|
325
|
+
He,
|
|
326
|
+
i && "Bear-RichEditor--disabled",
|
|
327
|
+
o && "Bear-RichEditor--readonly",
|
|
328
|
+
G
|
|
329
|
+
),
|
|
330
|
+
...K,
|
|
120
331
|
children: [
|
|
121
|
-
|
|
122
|
-
/* @__PURE__ */
|
|
332
|
+
L.length > 0 && /* @__PURE__ */ t("div", { className: b("Bear-RichEditor__toolbar", Le), children: L.map((e, n) => k(e, n)) }),
|
|
333
|
+
/* @__PURE__ */ t(
|
|
123
334
|
"div",
|
|
124
335
|
{
|
|
125
|
-
ref:
|
|
126
|
-
contentEditable: !i && !
|
|
127
|
-
onInput:
|
|
128
|
-
onSelect:
|
|
129
|
-
onKeyUp:
|
|
130
|
-
onMouseUp:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
336
|
+
ref: a,
|
|
337
|
+
contentEditable: !i && !o,
|
|
338
|
+
onInput: l,
|
|
339
|
+
onSelect: h,
|
|
340
|
+
onKeyUp: h,
|
|
341
|
+
onMouseUp: h,
|
|
342
|
+
onPaste: he,
|
|
343
|
+
"data-placeholder": q,
|
|
344
|
+
className: b(
|
|
345
|
+
"Bear-RichEditor__content",
|
|
346
|
+
ze,
|
|
347
|
+
"[&:empty]:before:bear-content-[attr(data-placeholder)] [&:empty]:before:bear-text-gray-400 [&:empty]:before:bear-pointer-events-none",
|
|
348
|
+
i && "Bear-RichEditor__content--disabled bear-opacity-50 bear-cursor-not-allowed"
|
|
349
|
+
),
|
|
138
350
|
style: {
|
|
139
|
-
minHeight: typeof
|
|
140
|
-
maxHeight:
|
|
141
|
-
overflowY:
|
|
351
|
+
minHeight: typeof T == "number" ? `${T}px` : T,
|
|
352
|
+
maxHeight: m ? typeof m == "number" ? `${m}px` : m : void 0,
|
|
353
|
+
overflowY: m ? "auto" : void 0
|
|
142
354
|
}
|
|
143
355
|
}
|
|
144
356
|
)
|
|
@@ -147,5 +359,5 @@ const K = ({ icon: n, title: u, active: s, onClick: k, disabled: i }) => /* @__P
|
|
|
147
359
|
);
|
|
148
360
|
};
|
|
149
361
|
export {
|
|
150
|
-
|
|
362
|
+
nt as RichEditor
|
|
151
363
|
};
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
export interface RichEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
3
|
+
/** Controlled HTML content */
|
|
3
4
|
value?: string;
|
|
5
|
+
/** Initial HTML content (uncontrolled) */
|
|
4
6
|
defaultValue?: string;
|
|
7
|
+
/** Called when content changes */
|
|
5
8
|
onChange?: (value: string) => void;
|
|
9
|
+
/** Placeholder text when empty */
|
|
6
10
|
placeholder?: string;
|
|
11
|
+
/** Completely disables the editor */
|
|
7
12
|
disabled?: boolean;
|
|
13
|
+
/** Allows viewing but not editing */
|
|
8
14
|
readOnly?: boolean;
|
|
15
|
+
/** Minimum editor height in pixels */
|
|
9
16
|
minHeight?: string | number;
|
|
17
|
+
/** Maximum height (enables scroll) */
|
|
10
18
|
maxHeight?: string | number;
|
|
19
|
+
/** Toolbar buttons to display */
|
|
11
20
|
toolbar?: ToolbarOption[];
|
|
21
|
+
/** Test ID for testing purposes */
|
|
22
|
+
testId?: string;
|
|
23
|
+
/** Unique ID for accessibility */
|
|
24
|
+
id?: string;
|
|
25
|
+
/** Enable image paste support */
|
|
26
|
+
allowImagePaste?: boolean;
|
|
12
27
|
}
|
|
13
|
-
export type ToolbarOption = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'heading1' | 'heading2' | 'heading3' | 'bulletList' | 'orderedList' | 'blockquote' | 'code' | 'link' | 'divider';
|
|
28
|
+
export type ToolbarOption = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'headingDropdown' | 'bulletList' | 'orderedList' | 'blockquote' | 'code' | 'link' | 'image' | 'textColor' | 'highlightColor' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'indent' | 'outdent' | 'clearFormat' | 'table' | 'divider' | 'more';
|
|
14
29
|
export interface ToolbarButtonProps {
|
|
15
30
|
icon: ReactNode;
|
|
16
31
|
title: string;
|
|
@@ -18,3 +33,25 @@ export interface ToolbarButtonProps {
|
|
|
18
33
|
onClick: () => void;
|
|
19
34
|
disabled?: boolean;
|
|
20
35
|
}
|
|
36
|
+
export interface DropdownOption {
|
|
37
|
+
value: string;
|
|
38
|
+
label: string;
|
|
39
|
+
preview?: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
export interface ToolbarDropdownProps {
|
|
42
|
+
options: DropdownOption[];
|
|
43
|
+
value: string;
|
|
44
|
+
onChange: (value: string) => void;
|
|
45
|
+
title: string;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
icon?: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
export interface ToolbarColorPickerProps {
|
|
50
|
+
value: string;
|
|
51
|
+
onChange: (color: string) => void;
|
|
52
|
+
title: string;
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
type?: 'text' | 'highlight';
|
|
55
|
+
recentColors?: string[];
|
|
56
|
+
onApplyLast?: (color: string) => void;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),T=require("../../../../utils/cn.cjs"),t=require("../../RichEditor.const.cjs"),E=e=>{const{icon:i,title:_,active:n,onClick:r,disabled:o}=e;return c.jsx("button",{type:"button",title:_,onClick:r,disabled:o,className:T.cn("Bear-RichEditor__button",t.RICH_EDITOR_BUTTON_BASE_CLASSES,n?`Bear-RichEditor__button--active ${t.RICH_EDITOR_BUTTON_ACTIVE_CLASSES}`:t.RICH_EDITOR_BUTTON_INACTIVE_CLASSES,o&&`Bear-RichEditor__button--disabled ${t.RICH_EDITOR_BUTTON_DISABLED_CLASSES}`),children:i})};exports.ToolbarButton=E;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as T } from "react/jsx-runtime";
|
|
2
|
+
import { cn as S } from "../../../../utils/cn.js";
|
|
3
|
+
import { RICH_EDITOR_BUTTON_DISABLED_CLASSES as e, RICH_EDITOR_BUTTON_ACTIVE_CLASSES as n, RICH_EDITOR_BUTTON_INACTIVE_CLASSES as c, RICH_EDITOR_BUTTON_BASE_CLASSES as I } from "../../RichEditor.const.js";
|
|
4
|
+
const B = (o) => {
|
|
5
|
+
const { icon: _, title: i, active: r, onClick: E, disabled: t } = o;
|
|
6
|
+
return /* @__PURE__ */ T(
|
|
7
|
+
"button",
|
|
8
|
+
{
|
|
9
|
+
type: "button",
|
|
10
|
+
title: i,
|
|
11
|
+
onClick: E,
|
|
12
|
+
disabled: t,
|
|
13
|
+
className: S(
|
|
14
|
+
"Bear-RichEditor__button",
|
|
15
|
+
I,
|
|
16
|
+
r ? `Bear-RichEditor__button--active ${n}` : c,
|
|
17
|
+
t && `Bear-RichEditor__button--disabled ${e}`
|
|
18
|
+
),
|
|
19
|
+
children: _
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
B as ToolbarButton
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ToolbarButton, default } from './ToolbarButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("react"),s=require("../../../../utils/cn.cjs"),i=require("../../RichEditor.const.cjs"),m=require("../../../Icon/icons/editor.cjs"),_=require("../../../Icon/icons/status.cjs"),C=p=>{const{value:r,onChange:f,title:y,disabled:o,type:n="text",recentColors:a=[],onApplyLast:h}=p,[b,c]=g.useState(!1),l=g.useRef(null);g.useEffect(()=>{const e=u=>{l.current&&!l.current.contains(u.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const d=e=>{f(e),c(!1)},k=n==="text"?m.FormatColorTextIcon:m.HighlightIcon,x=a[0]||r;return t.jsxs("div",{ref:l,className:"Bear-RichEditor__color-picker relative flex items-center",children:[t.jsxs("button",{type:"button",title:y,disabled:o,onClick:()=>c(!b),className:s.cn("Bear-RichEditor__color-trigger",i.RICH_EDITOR_BUTTON_BASE_CLASSES,i.RICH_EDITOR_BUTTON_INACTIVE_CLASSES,"flex items-center gap-0.5",o&&`Bear-RichEditor__color-trigger--disabled ${i.RICH_EDITOR_BUTTON_DISABLED_CLASSES}`),children:[t.jsx(k,{size:16}),t.jsx("span",{className:"w-3 h-1 rounded-sm mt-0.5",style:{backgroundColor:r||(n==="text"?"#000000":"#fef08a")}})]}),x&&h&&t.jsx("button",{type:"button",title:`Apply ${n==="text"?"text":"highlight"} color`,disabled:o,onClick:()=>h(x),className:s.cn("Bear-RichEditor__color-apply","p-0.5 rounded transition-colors","text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700",o&&"opacity-50 cursor-not-allowed"),children:t.jsx(_.CheckIcon,{size:12})}),b&&t.jsxs("div",{className:"Bear-RichEditor__color-menu absolute bottom-full left-0 mb-1 p-3 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl min-w-[200px]",style:{zIndex:9999},children:[a.length>0&&t.jsxs("div",{className:"mb-3",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1.5",children:"Recent"}),t.jsx("div",{className:"flex gap-1",children:a.slice(0,6).map((e,u)=>t.jsx("button",{type:"button",onClick:()=>d(e),className:s.cn("w-6 h-6 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110",r===e&&"ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"),style:{backgroundColor:e},title:e},`recent-${u}`))})]}),t.jsx("div",{className:"grid grid-cols-8 gap-1",children:i.RICH_EDITOR_COLORS.map(e=>t.jsx("button",{type:"button",onClick:()=>d(e),className:s.cn("Bear-RichEditor__color-swatch","w-5 h-5 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110",r===e&&"ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"),style:{backgroundColor:e},title:e},e))}),t.jsxs("button",{type:"button",onClick:()=>d(""),className:"w-full mt-2 px-2 py-1.5 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded transition-colors",children:["Remove ",n==="text"?"color":"highlight"]})]})]})};exports.ToolbarColorPicker=C;
|