@forgedevstack/bear 1.0.2 → 1.0.3
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/ActiveBar/ActiveBar.cjs +8 -0
- package/dist/components/ActiveBar/ActiveBar.d.ts +2 -0
- package/dist/components/ActiveBar/ActiveBar.js +90 -0
- package/dist/components/ActiveBar/ActiveBar.types.d.ts +16 -0
- package/dist/components/ActiveBar/index.d.ts +2 -0
- package/dist/components/Box/Box.cjs +1 -0
- package/dist/components/Box/Box.d.ts +2 -0
- package/dist/components/Box/Box.js +64 -0
- package/dist/components/Box/Box.types.d.ts +24 -0
- package/dist/components/Box/Box.utils.cjs +1 -0
- package/dist/components/Box/Box.utils.d.ts +3 -0
- package/dist/components/Box/Box.utils.js +21 -0
- package/dist/components/Box/index.d.ts +2 -0
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.const.cjs +1 -0
- package/dist/components/Calendar/Calendar.const.d.ts +18 -0
- package/dist/components/Calendar/Calendar.const.js +27 -0
- package/dist/components/Calendar/Calendar.js +131 -145
- package/dist/components/Calendar/Calendar.types.d.ts +4 -0
- package/dist/components/Calendar/Calendar.utils.cjs +1 -0
- package/dist/components/Calendar/Calendar.utils.d.ts +41 -0
- package/dist/components/Calendar/Calendar.utils.js +33 -0
- package/dist/components/Calendar/index.d.ts +2 -0
- package/dist/components/CodeBlock/CodeBlock.cjs +2 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +2 -0
- package/dist/components/CodeBlock/CodeBlock.js +55 -0
- package/dist/components/CodeBlock/CodeBlock.types.d.ts +10 -0
- package/dist/components/CodeBlock/index.d.ts +2 -0
- package/dist/components/Columns/Columns.cjs +1 -0
- package/dist/components/Columns/Columns.d.ts +5 -0
- package/dist/components/Columns/Columns.js +54 -0
- package/dist/components/Columns/Columns.types.d.ts +17 -0
- package/dist/components/Columns/index.d.ts +2 -0
- package/dist/components/DateTimePicker/DateTimePicker.cjs +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.js +28 -28
- package/dist/components/Editable/Editable.cjs +1 -0
- package/dist/components/Editable/Editable.d.ts +10 -0
- package/dist/components/Editable/Editable.js +194 -0
- package/dist/components/Editable/Editable.types.d.ts +39 -0
- package/dist/components/Editable/index.d.ts +2 -0
- package/dist/components/Em/Em.cjs +1 -0
- package/dist/components/Em/Em.d.ts +2 -0
- package/dist/components/Em/Em.js +24 -0
- package/dist/components/Em/Em.types.d.ts +5 -0
- package/dist/components/Em/index.d.ts +2 -0
- package/dist/components/Fab/Fab.cjs +1 -1
- package/dist/components/Fab/Fab.js +9 -9
- package/dist/components/Highlight/Highlight.cjs +1 -0
- package/dist/components/Highlight/Highlight.d.ts +2 -0
- package/dist/components/Highlight/Highlight.js +28 -0
- package/dist/components/Highlight/Highlight.types.d.ts +6 -0
- package/dist/components/Highlight/index.d.ts +2 -0
- package/dist/components/HoverCard/HoverCard.cjs +6 -0
- package/dist/components/HoverCard/HoverCard.d.ts +2 -0
- package/dist/components/HoverCard/HoverCard.js +68 -0
- package/dist/components/HoverCard/HoverCard.types.d.ts +13 -0
- package/dist/components/HoverCard/HoverCard.utils.cjs +1 -0
- package/dist/components/HoverCard/HoverCard.utils.d.ts +2 -0
- package/dist/components/HoverCard/HoverCard.utils.js +23 -0
- package/dist/components/HoverCard/index.d.ts +2 -0
- package/dist/components/Icon/icons/status.js +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.d.ts +5 -0
- package/dist/components/Icon/index.js +28 -21
- package/dist/components/Mark/Mark.cjs +1 -0
- package/dist/components/Mark/Mark.d.ts +2 -0
- package/dist/components/Mark/Mark.js +26 -0
- package/dist/components/Mark/Mark.types.d.ts +5 -0
- package/dist/components/Mark/index.d.ts +2 -0
- package/dist/components/RichEditor/RichEditor.cjs +10 -0
- package/dist/components/RichEditor/RichEditor.d.ts +4 -0
- package/dist/components/RichEditor/RichEditor.icons.cjs +1 -0
- package/dist/components/RichEditor/RichEditor.icons.d.ts +16 -0
- package/dist/components/RichEditor/RichEditor.icons.js +62 -0
- package/dist/components/RichEditor/RichEditor.js +151 -0
- package/dist/components/RichEditor/RichEditor.types.d.ts +20 -0
- package/dist/components/RichEditor/RichEditor.utils.cjs +1 -0
- package/dist/components/RichEditor/RichEditor.utils.d.ts +3 -0
- package/dist/components/RichEditor/RichEditor.utils.js +22 -0
- package/dist/components/RichEditor/index.d.ts +2 -0
- package/dist/components/Sidebar/Sidebar.cjs +1 -0
- package/dist/components/Sidebar/Sidebar.d.ts +5 -0
- package/dist/components/Sidebar/Sidebar.js +158 -0
- package/dist/components/Sidebar/Sidebar.types.d.ts +40 -0
- package/dist/components/Sidebar/index.d.ts +2 -0
- package/dist/components/Slider/Slider.cjs +1 -1
- package/dist/components/Slider/Slider.js +8 -8
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +87 -63
- package/dist/index.cjs +1 -1
- package/dist/index.js +107 -83
- package/dist/styles.css +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsxs as n, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as y, useState as x, useRef as c, useEffect as T } from "react";
|
|
3
|
+
import { getArrowClasses as w, getSideClasses as M } from "./HoverCard.utils.js";
|
|
4
|
+
const k = y(({
|
|
5
|
+
children: u,
|
|
6
|
+
cardContent: l,
|
|
7
|
+
side: t = "bottom",
|
|
8
|
+
align: d = "center",
|
|
9
|
+
openDelay: m = 200,
|
|
10
|
+
closeDelay: b = 300,
|
|
11
|
+
arrow: f = !0,
|
|
12
|
+
className: p = "",
|
|
13
|
+
...v
|
|
14
|
+
}, g) => {
|
|
15
|
+
const [h, o] = x(!1), e = c(), r = c(), a = () => {
|
|
16
|
+
r.current && clearTimeout(r.current), e.current = setTimeout(() => {
|
|
17
|
+
o(!0);
|
|
18
|
+
}, m);
|
|
19
|
+
}, s = () => {
|
|
20
|
+
e.current && clearTimeout(e.current), r.current = setTimeout(() => {
|
|
21
|
+
o(!1);
|
|
22
|
+
}, b);
|
|
23
|
+
};
|
|
24
|
+
return T(() => () => {
|
|
25
|
+
e.current && clearTimeout(e.current), r.current && clearTimeout(r.current);
|
|
26
|
+
}, []), /* @__PURE__ */ n(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
ref: g,
|
|
30
|
+
className: `bear-hover-card relative inline-block ${p}`.trim(),
|
|
31
|
+
onMouseEnter: a,
|
|
32
|
+
onMouseLeave: s,
|
|
33
|
+
...v,
|
|
34
|
+
children: [
|
|
35
|
+
u,
|
|
36
|
+
/* @__PURE__ */ i(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
className: `
|
|
40
|
+
absolute z-50 w-72
|
|
41
|
+
${M(t, d)}
|
|
42
|
+
transition-all duration-200
|
|
43
|
+
${h ? "opacity-100 visible scale-100" : "opacity-0 invisible scale-95 pointer-events-none"}
|
|
44
|
+
`,
|
|
45
|
+
onMouseEnter: a,
|
|
46
|
+
onMouseLeave: s,
|
|
47
|
+
children: /* @__PURE__ */ n("div", { className: "bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 p-4", children: [
|
|
48
|
+
f && /* @__PURE__ */ i(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
className: `absolute w-3 h-3 bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 ${w(t)}`,
|
|
52
|
+
style: {
|
|
53
|
+
borderWidth: t === "top" || t === "left" ? "0 1px 1px 0" : "1px 0 0 1px"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
l
|
|
58
|
+
] })
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
k.displayName = "HoverCard";
|
|
66
|
+
export {
|
|
67
|
+
k as HoverCard
|
|
68
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface HoverCardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'content'> {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
cardContent: ReactNode;
|
|
5
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
6
|
+
align?: 'start' | 'center' | 'end';
|
|
7
|
+
openDelay?: number;
|
|
8
|
+
closeDelay?: number;
|
|
9
|
+
arrow?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface HoverCardContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=(t,e)=>{const r={top:"bottom-full mb-2",bottom:"top-full mt-2",left:"right-full mr-2",right:"left-full ml-2"},s={top:{start:"left-0",center:"left-1/2 -translate-x-1/2",end:"right-0"},bottom:{start:"left-0",center:"left-1/2 -translate-x-1/2",end:"right-0"},left:{start:"top-0",center:"top-1/2 -translate-y-1/2",end:"bottom-0"},right:{start:"top-0",center:"top-1/2 -translate-y-1/2",end:"bottom-0"}};return`${r[t]} ${s[t][e]}`},l=t=>({top:"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 rotate-45",bottom:"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-45",left:"right-0 top-1/2 translate-x-1/2 -translate-y-1/2 rotate-45",right:"left-0 top-1/2 -translate-x-1/2 -translate-y-1/2 rotate-45"})[t];exports.getArrowClasses=l;exports.getSideClasses=a;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const l = (t, e) => {
|
|
2
|
+
const r = {
|
|
3
|
+
top: "bottom-full mb-2",
|
|
4
|
+
bottom: "top-full mt-2",
|
|
5
|
+
left: "right-full mr-2",
|
|
6
|
+
right: "left-full ml-2"
|
|
7
|
+
}, a = {
|
|
8
|
+
top: { start: "left-0", center: "left-1/2 -translate-x-1/2", end: "right-0" },
|
|
9
|
+
bottom: { start: "left-0", center: "left-1/2 -translate-x-1/2", end: "right-0" },
|
|
10
|
+
left: { start: "top-0", center: "top-1/2 -translate-y-1/2", end: "bottom-0" },
|
|
11
|
+
right: { start: "top-0", center: "top-1/2 -translate-y-1/2", end: "bottom-0" }
|
|
12
|
+
};
|
|
13
|
+
return `${r[t]} ${a[t][e]}`;
|
|
14
|
+
}, s = (t) => ({
|
|
15
|
+
top: "bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 rotate-45",
|
|
16
|
+
bottom: "top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-45",
|
|
17
|
+
left: "right-0 top-1/2 translate-x-1/2 -translate-y-1/2 rotate-45",
|
|
18
|
+
right: "left-0 top-1/2 -translate-x-1/2 -translate-y-1/2 rotate-45"
|
|
19
|
+
})[t];
|
|
20
|
+
export {
|
|
21
|
+
s as getArrowClasses,
|
|
22
|
+
l as getSideClasses
|
|
23
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as c, jsxs as e } from "react/jsx-runtime";
|
|
2
2
|
import { Icon as l } from "../Icon.js";
|
|
3
3
|
const h = (n) => /* @__PURE__ */ c(l, { ...n, children: /* @__PURE__ */ c("polyline", { points: "20 6 9 17 4 12" }) }), o = (n) => /* @__PURE__ */ e(l, { ...n, children: [
|
|
4
4
|
/* @__PURE__ */ c("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");const n=require("./icons/action.cjs"),o=require("./icons/navigation.cjs"),t=require("./icons/content.cjs"),r=require("./icons/communication.cjs"),c=require("./icons/status.cjs"),i=require("./icons/media.cjs"),s=require("./icons/editor.cjs"),e=require("./icons/misc.cjs"),I=c.CheckIcon,h=o.CloseIcon,C=n.EditIcon,v=o.ChevronDownIcon,u=o.ChevronRightIcon,a=o.ChevronLeftIcon,g=o.ChevronsLeftIcon,d=o.ChevronsRightIcon,q=e.XIcon,f={...n,...o,...t,...r,...c,...i,...s,...e,Action:n,Navigation:o,Content:t,Communication:r,Status:c,Media:i,Editor:s,Misc:e};exports.BearIcons=f;exports.CheckIcon=I;exports.ChevronDownIcon=v;exports.ChevronLeftIcon=a;exports.ChevronRightIcon=u;exports.ChevronsLeftIcon=g;exports.ChevronsRightIcon=d;exports.CloseIcon=h;exports.EditIcon=C;exports.XIcon=q;
|
|
@@ -16,10 +16,15 @@ import * as EditorIcons from './icons/editor';
|
|
|
16
16
|
import * as MiscIcons from './icons/misc';
|
|
17
17
|
export declare const CheckIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
18
18
|
export declare const CloseIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
19
|
+
export declare const EditIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
19
20
|
export declare const ChevronDownIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
20
21
|
export declare const ChevronRightIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
21
22
|
export declare const ChevronLeftIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
22
23
|
export declare const ChevronUpIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
24
|
+
export declare const ChevronsUpIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
25
|
+
export declare const ChevronsDownIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
26
|
+
export declare const ChevronsLeftIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
27
|
+
export declare const ChevronsRightIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
23
28
|
export declare const MenuIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
24
29
|
export declare const SearchIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
25
30
|
export declare const SettingsIcon: import('react').FunctionComponent<Omit<import('./Icon.types').IconProps, "children">>;
|
|
@@ -1,38 +1,45 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import * as o from "./icons/action.js";
|
|
3
|
+
import { EditIcon as m } from "./icons/action.js";
|
|
3
4
|
import * as n from "./icons/navigation.js";
|
|
4
|
-
import { ChevronDownIcon as
|
|
5
|
+
import { CloseIcon as a, ChevronDownIcon as I, ChevronRightIcon as h, ChevronLeftIcon as C, ChevronsLeftIcon as f, ChevronsRightIcon as v } from "./icons/navigation.js";
|
|
5
6
|
import * as t from "./icons/content.js";
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
8
|
-
import { CheckIcon as
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
11
|
-
import * as
|
|
12
|
-
import { XIcon as
|
|
13
|
-
const
|
|
7
|
+
import * as c from "./icons/communication.js";
|
|
8
|
+
import * as r from "./icons/status.js";
|
|
9
|
+
import { CheckIcon as p } from "./icons/status.js";
|
|
10
|
+
import * as s from "./icons/media.js";
|
|
11
|
+
import * as i from "./icons/editor.js";
|
|
12
|
+
import * as e from "./icons/misc.js";
|
|
13
|
+
import { XIcon as $ } from "./icons/misc.js";
|
|
14
|
+
const E = p, k = a, l = m, w = I, D = h, X = C, M = f, x = v, A = $, B = {
|
|
14
15
|
// Flat access to common icons (shortcuts)
|
|
15
16
|
...o,
|
|
16
17
|
...n,
|
|
17
18
|
...t,
|
|
19
|
+
...c,
|
|
18
20
|
...r,
|
|
19
|
-
...
|
|
21
|
+
...s,
|
|
20
22
|
...i,
|
|
21
|
-
...
|
|
22
|
-
...a,
|
|
23
|
+
...e,
|
|
23
24
|
// Category-based access
|
|
24
25
|
Action: o,
|
|
25
26
|
Navigation: n,
|
|
26
27
|
Content: t,
|
|
27
|
-
Communication:
|
|
28
|
-
Status:
|
|
29
|
-
Media:
|
|
30
|
-
Editor:
|
|
31
|
-
Misc:
|
|
28
|
+
Communication: c,
|
|
29
|
+
Status: r,
|
|
30
|
+
Media: s,
|
|
31
|
+
Editor: i,
|
|
32
|
+
Misc: e
|
|
32
33
|
};
|
|
33
34
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
B as BearIcons,
|
|
36
|
+
E as CheckIcon,
|
|
37
|
+
w as ChevronDownIcon,
|
|
38
|
+
X as ChevronLeftIcon,
|
|
39
|
+
D as ChevronRightIcon,
|
|
40
|
+
M as ChevronsLeftIcon,
|
|
41
|
+
x as ChevronsRightIcon,
|
|
42
|
+
k as CloseIcon,
|
|
43
|
+
l as EditIcon,
|
|
44
|
+
A as XIcon
|
|
38
45
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),b=require("react"),i={default:"bg-yellow-300 dark:bg-yellow-600/50 text-gray-900 dark:text-white",pink:"bg-pink-300 dark:bg-pink-600/50 text-gray-900 dark:text-white",blue:"bg-blue-300 dark:bg-blue-600/50 text-gray-900 dark:text-white",green:"bg-green-300 dark:bg-green-600/50 text-gray-900 dark:text-white",red:"bg-red-300 dark:bg-red-600/50 text-gray-900 dark:text-white"},e=b.forwardRef(({children:r,color:t="default",className:a="",...d},g)=>k.jsx("mark",{ref:g,className:`bear-mark px-0.5 rounded-sm ${i[t]} ${a}`.trim(),...d,children:r}));e.displayName="Mark";exports.Mark=e;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as k } from "react";
|
|
3
|
+
const b = {
|
|
4
|
+
default: "bg-yellow-300 dark:bg-yellow-600/50 text-gray-900 dark:text-white",
|
|
5
|
+
pink: "bg-pink-300 dark:bg-pink-600/50 text-gray-900 dark:text-white",
|
|
6
|
+
blue: "bg-blue-300 dark:bg-blue-600/50 text-gray-900 dark:text-white",
|
|
7
|
+
green: "bg-green-300 dark:bg-green-600/50 text-gray-900 dark:text-white",
|
|
8
|
+
red: "bg-red-300 dark:bg-red-600/50 text-gray-900 dark:text-white"
|
|
9
|
+
}, l = k(({
|
|
10
|
+
children: e,
|
|
11
|
+
color: r = "default",
|
|
12
|
+
className: t = "",
|
|
13
|
+
...a
|
|
14
|
+
}, d) => /* @__PURE__ */ g(
|
|
15
|
+
"mark",
|
|
16
|
+
{
|
|
17
|
+
ref: d,
|
|
18
|
+
className: `bear-mark px-0.5 rounded-sm ${b[r]} ${t}`.trim(),
|
|
19
|
+
...a,
|
|
20
|
+
children: e
|
|
21
|
+
}
|
|
22
|
+
));
|
|
23
|
+
l.displayName = "Mark";
|
|
24
|
+
export {
|
|
25
|
+
l as Mark
|
|
26
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),d=require("react"),e=require("./RichEditor.utils.cjs"),o=require("./RichEditor.icons.cjs"),S=({icon:a,title:m,active:l,onClick:k,disabled:i})=>r.jsx("button",{type:"button",title:m,onClick:k,disabled:i,className:`
|
|
2
|
+
p-1.5 rounded transition-colors
|
|
3
|
+
${l?"bg-pink-500 text-white":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}
|
|
4
|
+
${i?"opacity-50 cursor-not-allowed":"cursor-pointer"}
|
|
5
|
+
`,children:a}),q=({value:a,defaultValue:m="",onChange:l,placeholder:k="Start typing...",disabled:i=!1,readOnly:b=!1,minHeight:g=150,maxHeight:u,toolbar:p=e.DEFAULT_TOOLBAR,className:y="",...L})=>{const n=d.useRef(null),[C,j]=d.useState(new Set);d.useEffect(()=>{n.current&&a!==void 0&&n.current.innerHTML!==a&&(n.current.innerHTML=a)},[a]),d.useEffect(()=>{n.current&&m&&!a&&(n.current.innerHTML=m)},[]);const c=d.useCallback(()=>{const t=new Set;e.queryCommandState("bold")&&t.add("bold"),e.queryCommandState("italic")&&t.add("italic"),e.queryCommandState("underline")&&t.add("underline"),e.queryCommandState("strikeThrough")&&t.add("strikethrough"),e.queryCommandState("insertUnorderedList")&&t.add("bulletList"),e.queryCommandState("insertOrderedList")&&t.add("orderedList"),j(t)},[]),f=d.useCallback(()=>{n.current&&l&&l(n.current.innerHTML),c()},[l,c]),I=d.useCallback(t=>{var s;if(!(i||b)){switch((s=n.current)==null||s.focus(),t){case"bold":e.execCommand("bold");break;case"italic":e.execCommand("italic");break;case"underline":e.execCommand("underline");break;case"strikethrough":e.execCommand("strikeThrough");break;case"heading1":e.execCommand("formatBlock","<h1>");break;case"heading2":e.execCommand("formatBlock","<h2>");break;case"heading3":e.execCommand("formatBlock","<h3>");break;case"bulletList":e.execCommand("insertUnorderedList");break;case"orderedList":e.execCommand("insertOrderedList");break;case"blockquote":e.execCommand("formatBlock","<blockquote>");break;case"code":e.execCommand("formatBlock","<pre>");break;case"link":const h=prompt("Enter URL:");h&&e.execCommand("createLink",h);break}c(),f()}},[i,b,c,f]),v=(t,s)=>{if(t==="divider")return r.jsx("div",{className:"w-px h-5 bg-gray-300 dark:bg-gray-600 mx-1"},`divider-${s}`);const x={bold:{icon:r.jsx(o.BoldIcon,{}),title:"Bold"},italic:{icon:r.jsx(o.ItalicIcon,{}),title:"Italic"},underline:{icon:r.jsx(o.UnderlineIcon,{}),title:"Underline"},strikethrough:{icon:r.jsx(o.StrikethroughIcon,{}),title:"Strikethrough"},heading1:{icon:r.jsx(o.Heading1Icon,{}),title:"Heading 1"},heading2:{icon:r.jsx(o.Heading2Icon,{}),title:"Heading 2"},bulletList:{icon:r.jsx(o.BulletListIcon,{}),title:"Bullet List"},orderedList:{icon:r.jsx(o.OrderedListIcon,{}),title:"Numbered List"},blockquote:{icon:r.jsx(o.BlockquoteIcon,{}),title:"Quote"},code:{icon:r.jsx(o.CodeIcon,{}),title:"Code Block"},link:{icon:r.jsx(o.LinkIcon,{}),title:"Insert Link"}}[t];return x?r.jsx(S,{icon:x.icon,title:x.title,active:C.has(t),onClick:()=>I(t),disabled:i||b},t):null};return r.jsxs("div",{className:`bear-rich-editor rounded-lg border border-gray-300 dark:border-gray-600 overflow-hidden bg-white dark:bg-gray-900 ${y}`,...L,children:[p.length>0&&r.jsx("div",{className:"bear-rich-editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800",children:p.map((t,s)=>v(t,s))}),r.jsx("div",{ref:n,contentEditable:!i&&!b,onInput:f,onSelect:c,onKeyUp:c,onMouseUp:c,"data-placeholder":k,className:`
|
|
6
|
+
bear-rich-editor-content p-3 outline-none prose prose-sm dark:prose-invert max-w-none
|
|
7
|
+
text-gray-900 dark:text-white
|
|
8
|
+
[&:empty]:before:content-[attr(data-placeholder)] [&:empty]:before:text-gray-400 [&:empty]:before:pointer-events-none
|
|
9
|
+
${i?"opacity-50 cursor-not-allowed":""}
|
|
10
|
+
`,style:{minHeight:typeof g=="number"?`${g}px`:g,maxHeight:u?typeof u=="number"?`${u}px`:u:void 0,overflowY:u?"auto":void 0}})]})};exports.RichEditor=q;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),e=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),o.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]}),t=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),o.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),o.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]}),r=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3"}),o.jsx("line",{x1:"4",y1:"21",x2:"20",y2:"21"})]}),i=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M17.3 4.9c-2.3-.6-4.4-1-6.2-.9-2.7 0-5.3.7-5.3 3.6 0 1.5 1.8 3.3 3.6 3.9h.2"}),o.jsx("path",{d:"M8.7 19.1c2.3.6 4.4 1 6.2.9 2.7 0 5.3-.7 5.3-3.6 0-1.5-1.8-3.3-3.6-3.9h-.2"}),o.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]}),s=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M4 12h8"}),o.jsx("path",{d:"M4 18V6"}),o.jsx("path",{d:"M12 18V6"}),o.jsx("path",{d:"M17 12l3-2v8"})]}),c=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M4 12h8"}),o.jsx("path",{d:"M4 18V6"}),o.jsx("path",{d:"M12 18V6"}),o.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]}),d=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"9",y1:"6",x2:"20",y2:"6"}),o.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),o.jsx("line",{x1:"9",y1:"18",x2:"20",y2:"18"}),o.jsx("circle",{cx:"4",cy:"6",r:"1",fill:"currentColor"}),o.jsx("circle",{cx:"4",cy:"12",r:"1",fill:"currentColor"}),o.jsx("circle",{cx:"4",cy:"18",r:"1",fill:"currentColor"})]}),l=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),o.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),o.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"}),o.jsx("path",{d:"M4 6h1v4"}),o.jsx("path",{d:"M4 10h2"}),o.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]}),h=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"}),o.jsx("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z"})]}),x=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("polyline",{points:"16 18 22 12 16 6"}),o.jsx("polyline",{points:"8 6 2 12 8 18"})]}),j=({size:n=16})=>o.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]});exports.BlockquoteIcon=h;exports.BoldIcon=e;exports.BulletListIcon=d;exports.CodeIcon=x;exports.Heading1Icon=s;exports.Heading2Icon=c;exports.ItalicIcon=t;exports.LinkIcon=j;exports.OrderedListIcon=l;exports.StrikethroughIcon=i;exports.UnderlineIcon=r;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
interface IconProps {
|
|
3
|
+
size?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare const BoldIcon: FC<IconProps>;
|
|
6
|
+
export declare const ItalicIcon: FC<IconProps>;
|
|
7
|
+
export declare const UnderlineIcon: FC<IconProps>;
|
|
8
|
+
export declare const StrikethroughIcon: FC<IconProps>;
|
|
9
|
+
export declare const Heading1Icon: FC<IconProps>;
|
|
10
|
+
export declare const Heading2Icon: FC<IconProps>;
|
|
11
|
+
export declare const BulletListIcon: FC<IconProps>;
|
|
12
|
+
export declare const OrderedListIcon: FC<IconProps>;
|
|
13
|
+
export declare const BlockquoteIcon: FC<IconProps>;
|
|
14
|
+
export declare const CodeIcon: FC<IconProps>;
|
|
15
|
+
export declare const LinkIcon: FC<IconProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsxs as e, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
const t = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
3
|
+
/* @__PURE__ */ o("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
|
|
4
|
+
/* @__PURE__ */ o("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
|
|
5
|
+
] }), i = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
6
|
+
/* @__PURE__ */ o("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
|
|
7
|
+
/* @__PURE__ */ o("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
|
|
8
|
+
/* @__PURE__ */ o("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
|
|
9
|
+
] }), h = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
10
|
+
/* @__PURE__ */ o("path", { d: "M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3" }),
|
|
11
|
+
/* @__PURE__ */ o("line", { x1: "4", y1: "21", x2: "20", y2: "21" })
|
|
12
|
+
] }), c = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
13
|
+
/* @__PURE__ */ o("path", { d: "M17.3 4.9c-2.3-.6-4.4-1-6.2-.9-2.7 0-5.3.7-5.3 3.6 0 1.5 1.8 3.3 3.6 3.9h.2" }),
|
|
14
|
+
/* @__PURE__ */ o("path", { d: "M8.7 19.1c2.3.6 4.4 1 6.2.9 2.7 0 5.3-.7 5.3-3.6 0-1.5-1.8-3.3-3.6-3.9h-.2" }),
|
|
15
|
+
/* @__PURE__ */ o("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
|
|
16
|
+
] }), d = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
17
|
+
/* @__PURE__ */ o("path", { d: "M4 12h8" }),
|
|
18
|
+
/* @__PURE__ */ o("path", { d: "M4 18V6" }),
|
|
19
|
+
/* @__PURE__ */ o("path", { d: "M12 18V6" }),
|
|
20
|
+
/* @__PURE__ */ o("path", { d: "M17 12l3-2v8" })
|
|
21
|
+
] }), l = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
22
|
+
/* @__PURE__ */ o("path", { d: "M4 12h8" }),
|
|
23
|
+
/* @__PURE__ */ o("path", { d: "M4 18V6" }),
|
|
24
|
+
/* @__PURE__ */ o("path", { d: "M12 18V6" }),
|
|
25
|
+
/* @__PURE__ */ o("path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" })
|
|
26
|
+
] }), s = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
27
|
+
/* @__PURE__ */ o("line", { x1: "9", y1: "6", x2: "20", y2: "6" }),
|
|
28
|
+
/* @__PURE__ */ o("line", { x1: "9", y1: "12", x2: "20", y2: "12" }),
|
|
29
|
+
/* @__PURE__ */ o("line", { x1: "9", y1: "18", x2: "20", y2: "18" }),
|
|
30
|
+
/* @__PURE__ */ o("circle", { cx: "4", cy: "6", r: "1", fill: "currentColor" }),
|
|
31
|
+
/* @__PURE__ */ o("circle", { cx: "4", cy: "12", r: "1", fill: "currentColor" }),
|
|
32
|
+
/* @__PURE__ */ o("circle", { cx: "4", cy: "18", r: "1", fill: "currentColor" })
|
|
33
|
+
] }), k = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
34
|
+
/* @__PURE__ */ o("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
|
|
35
|
+
/* @__PURE__ */ o("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
|
|
36
|
+
/* @__PURE__ */ o("line", { x1: "10", y1: "18", x2: "21", y2: "18" }),
|
|
37
|
+
/* @__PURE__ */ o("path", { d: "M4 6h1v4" }),
|
|
38
|
+
/* @__PURE__ */ o("path", { d: "M4 10h2" }),
|
|
39
|
+
/* @__PURE__ */ o("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
|
|
40
|
+
] }), a = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
41
|
+
/* @__PURE__ */ o("path", { d: "M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z" }),
|
|
42
|
+
/* @__PURE__ */ o("path", { d: "M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z" })
|
|
43
|
+
] }), u = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
44
|
+
/* @__PURE__ */ o("polyline", { points: "16 18 22 12 16 6" }),
|
|
45
|
+
/* @__PURE__ */ o("polyline", { points: "8 6 2 12 8 18" })
|
|
46
|
+
] }), x = ({ size: n = 16 }) => /* @__PURE__ */ e("svg", { width: n, height: n, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
47
|
+
/* @__PURE__ */ o("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
48
|
+
/* @__PURE__ */ o("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
49
|
+
] });
|
|
50
|
+
export {
|
|
51
|
+
a as BlockquoteIcon,
|
|
52
|
+
t as BoldIcon,
|
|
53
|
+
s as BulletListIcon,
|
|
54
|
+
u as CodeIcon,
|
|
55
|
+
d as Heading1Icon,
|
|
56
|
+
l as Heading2Icon,
|
|
57
|
+
i as ItalicIcon,
|
|
58
|
+
x as LinkIcon,
|
|
59
|
+
k as OrderedListIcon,
|
|
60
|
+
c as StrikethroughIcon,
|
|
61
|
+
h as UnderlineIcon
|
|
62
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsxs as S, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as U, useState as $, useEffect as L, useCallback as m } from "react";
|
|
3
|
+
import { queryCommandState as d, execCommand as t, DEFAULT_TOOLBAR as N } from "./RichEditor.utils.js";
|
|
4
|
+
import { LinkIcon as q, CodeIcon as E, BlockquoteIcon as F, OrderedListIcon as M, BulletListIcon as R, Heading2Icon as A, Heading1Icon as C, StrikethroughIcon as H, UnderlineIcon as j, ItalicIcon as O, BoldIcon as D } from "./RichEditor.icons.js";
|
|
5
|
+
const K = ({ icon: n, title: u, active: s, onClick: k, disabled: i }) => /* @__PURE__ */ r(
|
|
6
|
+
"button",
|
|
7
|
+
{
|
|
8
|
+
type: "button",
|
|
9
|
+
title: u,
|
|
10
|
+
onClick: k,
|
|
11
|
+
disabled: i,
|
|
12
|
+
className: `
|
|
13
|
+
p-1.5 rounded transition-colors
|
|
14
|
+
${s ? "bg-pink-500 text-white" : "text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}
|
|
15
|
+
${i ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
|
|
16
|
+
`,
|
|
17
|
+
children: n
|
|
18
|
+
}
|
|
19
|
+
), G = ({
|
|
20
|
+
value: n,
|
|
21
|
+
defaultValue: u = "",
|
|
22
|
+
onChange: s,
|
|
23
|
+
placeholder: k = "Start typing...",
|
|
24
|
+
disabled: i = !1,
|
|
25
|
+
readOnly: b = !1,
|
|
26
|
+
minHeight: f = 150,
|
|
27
|
+
maxHeight: l,
|
|
28
|
+
toolbar: y = N,
|
|
29
|
+
className: I = "",
|
|
30
|
+
...v
|
|
31
|
+
}) => {
|
|
32
|
+
const o = U(null), [x, w] = $(/* @__PURE__ */ new Set());
|
|
33
|
+
L(() => {
|
|
34
|
+
o.current && n !== void 0 && o.current.innerHTML !== n && (o.current.innerHTML = n);
|
|
35
|
+
}, [n]), L(() => {
|
|
36
|
+
o.current && u && !n && (o.current.innerHTML = u);
|
|
37
|
+
}, []);
|
|
38
|
+
const c = m(() => {
|
|
39
|
+
const e = /* @__PURE__ */ new Set();
|
|
40
|
+
d("bold") && e.add("bold"), d("italic") && e.add("italic"), d("underline") && e.add("underline"), d("strikeThrough") && e.add("strikethrough"), d("insertUnorderedList") && e.add("bulletList"), d("insertOrderedList") && e.add("orderedList"), w(e);
|
|
41
|
+
}, []), g = m(() => {
|
|
42
|
+
o.current && s && s(o.current.innerHTML), c();
|
|
43
|
+
}, [s, c]), B = m((e) => {
|
|
44
|
+
var a;
|
|
45
|
+
if (!(i || b)) {
|
|
46
|
+
switch ((a = o.current) == null || a.focus(), e) {
|
|
47
|
+
case "bold":
|
|
48
|
+
t("bold");
|
|
49
|
+
break;
|
|
50
|
+
case "italic":
|
|
51
|
+
t("italic");
|
|
52
|
+
break;
|
|
53
|
+
case "underline":
|
|
54
|
+
t("underline");
|
|
55
|
+
break;
|
|
56
|
+
case "strikethrough":
|
|
57
|
+
t("strikeThrough");
|
|
58
|
+
break;
|
|
59
|
+
case "heading1":
|
|
60
|
+
t("formatBlock", "<h1>");
|
|
61
|
+
break;
|
|
62
|
+
case "heading2":
|
|
63
|
+
t("formatBlock", "<h2>");
|
|
64
|
+
break;
|
|
65
|
+
case "heading3":
|
|
66
|
+
t("formatBlock", "<h3>");
|
|
67
|
+
break;
|
|
68
|
+
case "bulletList":
|
|
69
|
+
t("insertUnorderedList");
|
|
70
|
+
break;
|
|
71
|
+
case "orderedList":
|
|
72
|
+
t("insertOrderedList");
|
|
73
|
+
break;
|
|
74
|
+
case "blockquote":
|
|
75
|
+
t("formatBlock", "<blockquote>");
|
|
76
|
+
break;
|
|
77
|
+
case "code":
|
|
78
|
+
t("formatBlock", "<pre>");
|
|
79
|
+
break;
|
|
80
|
+
case "link":
|
|
81
|
+
const p = prompt("Enter URL:");
|
|
82
|
+
p && t("createLink", p);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
c(), g();
|
|
86
|
+
}
|
|
87
|
+
}, [i, b, c, g]), T = (e, a) => {
|
|
88
|
+
if (e === "divider")
|
|
89
|
+
return /* @__PURE__ */ r("div", { className: "w-px h-5 bg-gray-300 dark:bg-gray-600 mx-1" }, `divider-${a}`);
|
|
90
|
+
const h = {
|
|
91
|
+
bold: { icon: /* @__PURE__ */ r(D, {}), title: "Bold" },
|
|
92
|
+
italic: { icon: /* @__PURE__ */ r(O, {}), title: "Italic" },
|
|
93
|
+
underline: { icon: /* @__PURE__ */ r(j, {}), title: "Underline" },
|
|
94
|
+
strikethrough: { icon: /* @__PURE__ */ r(H, {}), title: "Strikethrough" },
|
|
95
|
+
heading1: { icon: /* @__PURE__ */ r(C, {}), title: "Heading 1" },
|
|
96
|
+
heading2: { icon: /* @__PURE__ */ r(A, {}), title: "Heading 2" },
|
|
97
|
+
bulletList: { icon: /* @__PURE__ */ r(R, {}), title: "Bullet List" },
|
|
98
|
+
orderedList: { icon: /* @__PURE__ */ r(M, {}), title: "Numbered List" },
|
|
99
|
+
blockquote: { icon: /* @__PURE__ */ r(F, {}), title: "Quote" },
|
|
100
|
+
code: { icon: /* @__PURE__ */ r(E, {}), title: "Code Block" },
|
|
101
|
+
link: { icon: /* @__PURE__ */ r(q, {}), title: "Insert Link" }
|
|
102
|
+
}[e];
|
|
103
|
+
return h ? /* @__PURE__ */ r(
|
|
104
|
+
K,
|
|
105
|
+
{
|
|
106
|
+
icon: h.icon,
|
|
107
|
+
title: h.title,
|
|
108
|
+
active: x.has(e),
|
|
109
|
+
onClick: () => B(e),
|
|
110
|
+
disabled: i || b
|
|
111
|
+
},
|
|
112
|
+
e
|
|
113
|
+
) : null;
|
|
114
|
+
};
|
|
115
|
+
return /* @__PURE__ */ S(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
className: `bear-rich-editor rounded-lg border border-gray-300 dark:border-gray-600 overflow-hidden bg-white dark:bg-gray-900 ${I}`,
|
|
119
|
+
...v,
|
|
120
|
+
children: [
|
|
121
|
+
y.length > 0 && /* @__PURE__ */ r("div", { className: "bear-rich-editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800", children: y.map((e, a) => T(e, a)) }),
|
|
122
|
+
/* @__PURE__ */ r(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
ref: o,
|
|
126
|
+
contentEditable: !i && !b,
|
|
127
|
+
onInput: g,
|
|
128
|
+
onSelect: c,
|
|
129
|
+
onKeyUp: c,
|
|
130
|
+
onMouseUp: c,
|
|
131
|
+
"data-placeholder": k,
|
|
132
|
+
className: `
|
|
133
|
+
bear-rich-editor-content p-3 outline-none prose prose-sm dark:prose-invert max-w-none
|
|
134
|
+
text-gray-900 dark:text-white
|
|
135
|
+
[&:empty]:before:content-[attr(data-placeholder)] [&:empty]:before:text-gray-400 [&:empty]:before:pointer-events-none
|
|
136
|
+
${i ? "opacity-50 cursor-not-allowed" : ""}
|
|
137
|
+
`,
|
|
138
|
+
style: {
|
|
139
|
+
minHeight: typeof f == "number" ? `${f}px` : f,
|
|
140
|
+
maxHeight: l ? typeof l == "number" ? `${l}px` : l : void 0,
|
|
141
|
+
overflowY: l ? "auto" : void 0
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
G as RichEditor
|
|
151
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface RichEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
3
|
+
value?: string;
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
onChange?: (value: string) => void;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
readOnly?: boolean;
|
|
9
|
+
minHeight?: string | number;
|
|
10
|
+
maxHeight?: string | number;
|
|
11
|
+
toolbar?: ToolbarOption[];
|
|
12
|
+
}
|
|
13
|
+
export type ToolbarOption = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'heading1' | 'heading2' | 'heading3' | 'bulletList' | 'orderedList' | 'blockquote' | 'code' | 'link' | 'divider';
|
|
14
|
+
export interface ToolbarButtonProps {
|
|
15
|
+
icon: ReactNode;
|
|
16
|
+
title: string;
|
|
17
|
+
active?: boolean;
|
|
18
|
+
onClick: () => void;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=["bold","italic","underline","divider","heading1","heading2","divider","bulletList","orderedList","divider","blockquote","code","link"],o=(e,d)=>{document.execCommand(e,!1,d)},n=e=>document.queryCommandState(e);exports.DEFAULT_TOOLBAR=t;exports.execCommand=o;exports.queryCommandState=n;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const t = [
|
|
2
|
+
"bold",
|
|
3
|
+
"italic",
|
|
4
|
+
"underline",
|
|
5
|
+
"divider",
|
|
6
|
+
"heading1",
|
|
7
|
+
"heading2",
|
|
8
|
+
"divider",
|
|
9
|
+
"bulletList",
|
|
10
|
+
"orderedList",
|
|
11
|
+
"divider",
|
|
12
|
+
"blockquote",
|
|
13
|
+
"code",
|
|
14
|
+
"link"
|
|
15
|
+
], n = (e, d) => {
|
|
16
|
+
document.execCommand(e, !1, d);
|
|
17
|
+
}, o = (e) => document.queryCommandState(e);
|
|
18
|
+
export {
|
|
19
|
+
t as DEFAULT_TOOLBAR,
|
|
20
|
+
n as execCommand,
|
|
21
|
+
o as queryCommandState
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("react"),l=require("../../utils/cn.cjs"),d=require("../Icon/index.cjs"),z=256,N=64,p=({item:r,isActive:b,collapsed:a,depth:t=0,onClick:n})=>{const[s,i]=m.useState(!1),c=r.children&&r.children.length>0,u=a?16:16+t*12,h=m.useCallback(()=>{c&&i(o=>!o),r.onClick&&r.onClick(),n==null||n(r)},[c,r,n]),x=e.jsxs(e.Fragment,{children:[r.icon&&e.jsx("span",{className:"bear-shrink-0 bear-w-5 bear-h-5 bear-flex bear-items-center bear-justify-center",children:r.icon}),!a&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bear-flex-1 bear-truncate",children:r.label}),r.badge&&e.jsx("span",{className:"bear-ml-auto",children:r.badge}),c&&e.jsx(d.ChevronDownIcon,{size:14,className:l.cn("bear-ml-1 bear-transition-transform bear-duration-200",s&&"bear-rotate-180")})]})]}),f=l.cn("bear-flex bear-items-center bear-gap-3 bear-py-2.5 bear-px-3 bear-rounded-lg bear-text-sm bear-transition-all bear-duration-200 bear-cursor-pointer",b?"bear-bg-bear-500 bear-text-white bear-shadow-md":"bear-text-zinc-600 hover:bear-bg-zinc-100 hover:bear-text-zinc-900",r.disabled&&"bear-opacity-50 bear-cursor-not-allowed bear-pointer-events-none",a&&"bear-justify-center"),j=r.href?"a":"button";return e.jsxs("div",{children:[e.jsx(j,{href:r.href,onClick:h,disabled:r.disabled,className:f,style:{paddingLeft:u},title:a?r.label:void 0,children:x}),c&&s&&!a&&e.jsx("div",{className:"bear-mt-1",children:r.children.map(o=>e.jsx(p,{item:o,isActive:!1,collapsed:a,depth:t+1,onClick:n},o.id))})]})},w=({title:r,children:b,collapsible:a=!1,defaultCollapsed:t=!1,className:n})=>{const[s,i]=m.useState(t);return e.jsxs("div",{className:l.cn("bear-mb-4",n),children:[r&&e.jsxs("button",{type:"button",onClick:()=>a&&i(!s),className:l.cn("bear-flex bear-items-center bear-gap-2 bear-px-3 bear-py-2 bear-text-xs bear-font-semibold bear-uppercase bear-tracking-wider bear-text-zinc-400",a&&"bear-cursor-pointer hover:bear-text-zinc-600"),children:[a&&e.jsx(d.ChevronDownIcon,{size:12,className:l.cn("bear-transition-transform",s&&"-bear-rotate-90")}),r]}),!s&&e.jsx("div",{className:"bear-space-y-1",children:b})]})},S=({items:r,collapsed:b=!1,onCollapsedChange:a,width:t=z,collapsedWidth:n=N,header:s,footer:i,activeItemId:c,onItemClick:u,variant:h="default",position:x="left",className:f,style:j})=>{const o=b?n:t,v={default:"bear-bg-white dark:bear-bg-gray-900 bear-border-zinc-200 dark:bear-border-zinc-700",bordered:"bear-bg-white dark:bear-bg-gray-900 bear-border-2 bear-border-zinc-300 dark:bear-border-zinc-600 bear-rounded-xl bear-m-2",floating:"bear-bg-white/95 dark:bear-bg-gray-900/95 bear-backdrop-blur-sm bear-shadow-2xl bear-rounded-xl bear-m-3"},y=x==="left"?"bear-border-r":"bear-border-l";return e.jsxs("aside",{className:l.cn("bear-flex bear-flex-col bear-h-full bear-transition-all bear-duration-300",h==="default"&&y,v[h],f),style:{width:o,...j},children:[s&&e.jsxs("div",{className:"bear-px-3 bear-py-4 bear-border-b bear-border-zinc-100 bear-flex bear-items-center bear-justify-between",children:[!b&&s,a&&e.jsx("button",{type:"button",onClick:()=>a(!b),className:"bear-p-1.5 bear-rounded-lg bear-text-zinc-400 hover:bear-bg-zinc-100 hover:bear-text-zinc-600 bear-transition-colors","aria-label":b?"Expand sidebar":"Collapse sidebar",children:b?x==="left"?e.jsx(d.ChevronRightIcon,{size:18}):e.jsx(d.ChevronLeftIcon,{size:18}):x==="left"?e.jsx(d.ChevronLeftIcon,{size:18}):e.jsx(d.ChevronRightIcon,{size:18})})]}),e.jsx("nav",{className:"bear-flex-1 bear-overflow-y-auto bear-px-2 bear-py-3 bear-space-y-1",children:r.map(g=>e.jsx(p,{item:g,isActive:g.id===c,collapsed:b,onClick:u},g.id))}),i&&e.jsx("div",{className:"bear-px-3 bear-py-3 bear-border-t bear-border-zinc-100 bear-mt-auto",children:b?null:i})]})};exports.Sidebar=S;exports.SidebarGroup=w;
|