@forgedevstack/bear 1.0.6 → 1.0.8
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/Alert/Alert.cjs +1 -1
- package/dist/components/Alert/Alert.const.cjs +1 -1
- package/dist/components/Alert/Alert.const.d.ts +4 -0
- package/dist/components/Alert/Alert.const.js +9 -15
- package/dist/components/Alert/Alert.js +43 -38
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.js +20 -16
- package/dist/components/BackTop/BackTop.cjs +1 -0
- package/dist/components/BackTop/BackTop.const.cjs +1 -0
- package/dist/components/BackTop/BackTop.const.d.ts +34 -0
- package/dist/components/BackTop/BackTop.const.js +29 -0
- package/dist/components/BackTop/BackTop.d.ts +21 -0
- package/dist/components/BackTop/BackTop.js +87 -0
- package/dist/components/BackTop/BackTop.types.d.ts +28 -0
- package/dist/components/BackTop/index.d.ts +3 -0
- package/dist/components/Badge/Badge.constants.d.ts +4 -4
- package/dist/components/Badge/Badge.types.d.ts +3 -3
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +3 -0
- package/dist/components/BottomSheet/BottomSheet.js +103 -0
- package/dist/components/BottomSheet/BottomSheet.types.d.ts +13 -0
- package/dist/components/BottomSheet/index.d.ts +2 -0
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.constants.cjs +38 -48
- package/dist/components/Button/Button.constants.d.ts +22 -3
- package/dist/components/Button/Button.constants.js +51 -50
- package/dist/components/Button/Button.d.ts +14 -7
- package/dist/components/Button/Button.js +123 -43
- package/dist/components/Button/Button.types.d.ts +26 -4
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.js +3 -2
- package/dist/components/Card/Card.const.d.ts +2 -2
- package/dist/components/Card/Card.types.d.ts +2 -2
- package/dist/components/Chat/Chat.cjs +1 -0
- package/dist/components/Chat/Chat.const.cjs +1 -0
- package/dist/components/Chat/Chat.const.d.ts +26 -0
- package/dist/components/Chat/Chat.const.js +29 -0
- package/dist/components/Chat/Chat.d.ts +21 -0
- package/dist/components/Chat/Chat.js +179 -0
- package/dist/components/Chat/Chat.types.d.ts +55 -0
- package/dist/components/Chat/index.d.ts +2 -0
- package/dist/components/Confetti/Confetti.cjs +1 -0
- package/dist/components/Confetti/Confetti.const.cjs +1 -0
- package/dist/components/Confetti/Confetti.const.d.ts +16 -0
- package/dist/components/Confetti/Confetti.const.js +36 -0
- package/dist/components/Confetti/Confetti.d.ts +23 -0
- package/dist/components/Confetti/Confetti.js +94 -0
- package/dist/components/Confetti/Confetti.types.d.ts +50 -0
- package/dist/components/Confetti/index.d.ts +4 -0
- package/dist/components/Confetti/useConfetti.cjs +1 -0
- package/dist/components/Confetti/useConfetti.d.ts +13 -0
- package/dist/components/Confetti/useConfetti.js +12 -0
- package/dist/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.js +3 -2
- package/dist/components/DiffViewer/DiffViewer.cjs +1 -0
- package/dist/components/DiffViewer/DiffViewer.const.cjs +1 -0
- package/dist/components/DiffViewer/DiffViewer.const.d.ts +18 -0
- package/dist/components/DiffViewer/DiffViewer.const.js +21 -0
- package/dist/components/DiffViewer/DiffViewer.d.ts +18 -0
- package/dist/components/DiffViewer/DiffViewer.js +127 -0
- package/dist/components/DiffViewer/DiffViewer.types.d.ts +40 -0
- package/dist/components/DiffViewer/DiffViewer.utils.cjs +3 -0
- package/dist/components/DiffViewer/DiffViewer.utils.d.ts +9 -0
- package/dist/components/DiffViewer/DiffViewer.utils.js +39 -0
- package/dist/components/DiffViewer/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +35 -35
- package/dist/components/EmojiPicker/EmojiPicker.cjs +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.cjs +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.d.ts +5 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.js +10 -0
- package/dist/components/EmojiPicker/EmojiPicker.d.ts +3 -0
- package/dist/components/EmojiPicker/EmojiPicker.js +63 -0
- package/dist/components/EmojiPicker/EmojiPicker.types.d.ts +6 -0
- package/dist/components/EmojiPicker/index.d.ts +3 -0
- package/dist/components/FloatingChat/FloatingChat.cjs +1 -0
- package/dist/components/FloatingChat/FloatingChat.const.cjs +1 -0
- package/dist/components/FloatingChat/FloatingChat.const.d.ts +12 -0
- package/dist/components/FloatingChat/FloatingChat.const.js +15 -0
- package/dist/components/FloatingChat/FloatingChat.d.ts +19 -0
- package/dist/components/FloatingChat/FloatingChat.js +144 -0
- package/dist/components/FloatingChat/FloatingChat.types.d.ts +44 -0
- package/dist/components/FloatingChat/index.d.ts +2 -0
- package/dist/components/JsonViewer/JsonViewer.cjs +1 -0
- package/dist/components/JsonViewer/JsonViewer.const.cjs +1 -0
- package/dist/components/JsonViewer/JsonViewer.const.d.ts +4 -0
- package/dist/components/JsonViewer/JsonViewer.const.js +24 -0
- package/dist/components/JsonViewer/JsonViewer.d.ts +17 -0
- package/dist/components/JsonViewer/JsonViewer.js +195 -0
- package/dist/components/JsonViewer/JsonViewer.types.d.ts +54 -0
- package/dist/components/JsonViewer/index.d.ts +2 -0
- package/dist/components/Kanban/Kanban.cjs +1 -0
- package/dist/components/Kanban/Kanban.d.ts +3 -0
- package/dist/components/Kanban/Kanban.js +91 -0
- package/dist/components/Kanban/Kanban.types.d.ts +21 -0
- package/dist/components/Kanban/index.d.ts +2 -0
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -0
- package/dist/components/MentionsInput/MentionsInput.d.ts +3 -0
- package/dist/components/MentionsInput/MentionsInput.js +140 -0
- package/dist/components/MentionsInput/MentionsInput.types.d.ts +21 -0
- package/dist/components/MentionsInput/index.d.ts +2 -0
- package/dist/components/QRCode/QRCode.cjs +1 -0
- package/dist/components/QRCode/QRCode.const.cjs +1 -0
- package/dist/components/QRCode/QRCode.const.d.ts +21 -0
- package/dist/components/QRCode/QRCode.const.js +11 -0
- package/dist/components/QRCode/QRCode.d.ts +29 -0
- package/dist/components/QRCode/QRCode.js +68 -0
- package/dist/components/QRCode/QRCode.types.d.ts +32 -0
- package/dist/components/QRCode/QRCode.utils.cjs +1 -0
- package/dist/components/QRCode/QRCode.utils.d.ts +12 -0
- package/dist/components/QRCode/QRCode.utils.js +74 -0
- package/dist/components/QRCode/index.d.ts +3 -0
- package/dist/components/RichEditor/RichEditor.cjs +1 -1
- package/dist/components/RichEditor/RichEditor.const.cjs +2 -2
- package/dist/components/RichEditor/RichEditor.const.d.ts +4 -1
- package/dist/components/RichEditor/RichEditor.const.js +51 -18
- package/dist/components/RichEditor/RichEditor.js +106 -105
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +105 -95
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.d.ts +2 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.js +47 -29
- package/dist/components/SegmentedControl/SegmentedControl.cjs +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +58 -0
- package/dist/components/SegmentedControl/SegmentedControl.types.d.ts +16 -0
- package/dist/components/SegmentedControl/index.d.ts +2 -0
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.js +98 -90
- package/dist/components/SliderRange/SliderRange.cjs +1 -0
- package/dist/components/SliderRange/SliderRange.d.ts +3 -0
- package/dist/components/SliderRange/SliderRange.js +142 -0
- package/dist/components/SliderRange/SliderRange.types.d.ts +17 -0
- package/dist/components/SliderRange/index.d.ts +2 -0
- package/dist/components/Spinner/Spinner.types.d.ts +2 -2
- package/dist/components/TagsInput/TagsInput.cjs +1 -0
- package/dist/components/TagsInput/TagsInput.d.ts +3 -0
- package/dist/components/TagsInput/TagsInput.js +100 -0
- package/dist/components/TagsInput/TagsInput.types.d.ts +16 -0
- package/dist/components/TagsInput/index.d.ts +2 -0
- package/dist/components/Terminal/Terminal.cjs +1 -0
- package/dist/components/Terminal/Terminal.const.cjs +1 -0
- package/dist/components/Terminal/Terminal.const.d.ts +32 -0
- package/dist/components/Terminal/Terminal.const.js +42 -0
- package/dist/components/Terminal/Terminal.d.ts +27 -0
- package/dist/components/Terminal/Terminal.js +155 -0
- package/dist/components/Terminal/Terminal.types.d.ts +49 -0
- package/dist/components/Terminal/index.d.ts +2 -0
- package/dist/components/Tour/Tour.cjs +1 -0
- package/dist/components/Tour/Tour.const.cjs +1 -0
- package/dist/components/Tour/Tour.const.d.ts +25 -0
- package/dist/components/Tour/Tour.const.js +38 -0
- package/dist/components/Tour/Tour.d.ts +17 -0
- package/dist/components/Tour/Tour.js +179 -0
- package/dist/components/Tour/Tour.types.d.ts +80 -0
- package/dist/components/Tour/index.d.ts +4 -0
- package/dist/components/Tour/useTour.cjs +1 -0
- package/dist/components/Tour/useTour.d.ts +14 -0
- package/dist/components/Tour/useTour.js +27 -0
- package/dist/components/Typography/Typography.cjs +1 -1
- package/dist/components/Typography/Typography.d.ts +5 -1
- package/dist/components/Typography/Typography.js +93 -57
- package/dist/components/Typography/Typography.types.d.ts +29 -2
- package/dist/components/VirtualList/VirtualList.cjs +1 -0
- package/dist/components/VirtualList/VirtualList.d.ts +3 -0
- package/dist/components/VirtualList/VirtualList.js +68 -0
- package/dist/components/VirtualList/VirtualList.types.d.ts +10 -0
- package/dist/components/VirtualList/index.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +35 -1
- package/dist/components/index.js +240 -198
- package/dist/context/BearProvider.cjs +1 -1
- package/dist/context/BearProvider.d.ts +110 -5
- package/dist/context/BearProvider.js +198 -53
- package/dist/context/defaultTheme.cjs +1 -1
- package/dist/context/defaultTheme.js +11 -11
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +18 -0
- package/dist/hooks/index.js +56 -35
- package/dist/hooks/useBearComponent/index.d.ts +2 -0
- package/dist/hooks/useBearComponent/useBearComponent.cjs +1 -0
- package/dist/hooks/useBearComponent/useBearComponent.d.ts +71 -0
- package/dist/hooks/useBearComponent/useBearComponent.js +54 -0
- package/dist/hooks/useBearComponent/useBearComponent.types.d.ts +40 -0
- package/dist/hooks/useDragDrop/index.d.ts +2 -0
- package/dist/hooks/useDragDrop/useDragDrop.cjs +1 -0
- package/dist/hooks/useDragDrop/useDragDrop.d.ts +22 -0
- package/dist/hooks/useDragDrop/useDragDrop.js +56 -0
- package/dist/hooks/useDragDrop/useDragDrop.types.d.ts +55 -0
- package/dist/hooks/useIdle/index.d.ts +2 -0
- package/dist/hooks/useIdle/useIdle.cjs +1 -0
- package/dist/hooks/useIdle/useIdle.d.ts +22 -0
- package/dist/hooks/useIdle/useIdle.js +66 -0
- package/dist/hooks/useIdle/useIdle.types.d.ts +29 -0
- package/dist/hooks/useLazyLoad/index.d.ts +2 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.cjs +1 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.d.ts +26 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.js +27 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.types.d.ts +25 -0
- package/dist/hooks/useLongPress/index.d.ts +2 -0
- package/dist/hooks/useLongPress/useLongPress.cjs +1 -0
- package/dist/hooks/useLongPress/useLongPress.d.ts +17 -0
- package/dist/hooks/useLongPress/useLongPress.js +44 -0
- package/dist/hooks/useLongPress/useLongPress.types.d.ts +26 -0
- package/dist/hooks/useOnline/index.d.ts +2 -0
- package/dist/hooks/useOnline/useOnline.cjs +1 -0
- package/dist/hooks/useOnline/useOnline.d.ts +16 -0
- package/dist/hooks/useOnline/useOnline.js +25 -0
- package/dist/hooks/useOnline/useOnline.types.d.ts +15 -0
- package/dist/hooks/usePageVisibility/index.d.ts +2 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.cjs +1 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.d.ts +19 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.js +26 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.types.d.ts +15 -0
- package/dist/hooks/useSpotlight/index.d.ts +2 -0
- package/dist/hooks/useSpotlight/useSpotlight.cjs +1 -0
- package/dist/hooks/useSpotlight/useSpotlight.d.ts +24 -0
- package/dist/hooks/useSpotlight/useSpotlight.js +49 -0
- package/dist/hooks/useSpotlight/useSpotlight.types.d.ts +23 -0
- package/dist/hooks/useWebSocket/index.d.ts +2 -0
- package/dist/hooks/useWebSocket/useWebSocket.cjs +1 -0
- package/dist/hooks/useWebSocket/useWebSocket.d.ts +22 -0
- package/dist/hooks/useWebSocket/useWebSocket.js +75 -0
- package/dist/hooks/useWebSocket/useWebSocket.types.d.ts +44 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +327 -264
- package/dist/styles.css +1 -1
- package/dist/types/component.types.d.ts +125 -42
- package/dist/types/theme.types.d.ts +82 -0
- package/package.json +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsx as i, jsxs as D, Fragment as B } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as I } from "react";
|
|
3
|
+
import { cn as f } from "../../utils/cn.js";
|
|
4
|
+
import "../../context/BearProvider.js";
|
|
5
|
+
import { useDragDrop as P } from "../../hooks/useDragDrop/useDragDrop.js";
|
|
6
|
+
import "../../hooks/useBearComponent/useBearComponent.js";
|
|
7
|
+
const S = "bear-kanban", R = ({
|
|
8
|
+
columns: d,
|
|
9
|
+
onColumnsChange: g,
|
|
10
|
+
onCardMove: l,
|
|
11
|
+
renderCard: h,
|
|
12
|
+
renderColumnHeader: k,
|
|
13
|
+
disabled: y = !1,
|
|
14
|
+
className: _
|
|
15
|
+
}) => {
|
|
16
|
+
const z = I(
|
|
17
|
+
(r, e, b, t, n) => {
|
|
18
|
+
const x = d.find((a) => a.id === r), s = d.find((a) => a.id === e);
|
|
19
|
+
if (!x || !s) return;
|
|
20
|
+
const m = d.map((a) => {
|
|
21
|
+
if (a.id === r) {
|
|
22
|
+
const c = a.cards.filter((o, p) => p !== b);
|
|
23
|
+
return { ...a, cards: c };
|
|
24
|
+
}
|
|
25
|
+
if (a.id === e) {
|
|
26
|
+
const c = r === e && b < t ? t - 1 : t, o = [...a.cards];
|
|
27
|
+
return o.splice(Math.max(0, c), 0, n), { ...a, cards: o };
|
|
28
|
+
}
|
|
29
|
+
return a;
|
|
30
|
+
});
|
|
31
|
+
g == null || g(m), l == null || l(n.id, r, e, b, t);
|
|
32
|
+
},
|
|
33
|
+
[d, g, l]
|
|
34
|
+
), { getDragProps: u, getDropProps: w, isDragging: K, draggedId: $, dragOverId: N } = P({
|
|
35
|
+
disabled: y,
|
|
36
|
+
dragType: S,
|
|
37
|
+
onDrop: (r, e, b, t, n) => {
|
|
38
|
+
var v;
|
|
39
|
+
const x = String(r), s = String(e), m = x.split("-")[0], a = parseInt(x.split("-")[1], 10) || 0, c = s.endsWith("-col") ? s.replace("-col", "") : s.split("-")[0], o = s.endsWith("-col") ? ((v = d.find((j) => j.id === c)) == null ? void 0 : v.cards.length) ?? 0 : parseInt(s.split("-")[1], 10), p = n;
|
|
40
|
+
p != null && p.id && z(m, c, a, o, p);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return /* @__PURE__ */ i(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
className: f(
|
|
47
|
+
"Bear-Kanban bear-flex bear-gap-4 bear-overflow-x-auto bear-pb-4",
|
|
48
|
+
y && "bear-opacity-50 bear-pointer-events-none",
|
|
49
|
+
_
|
|
50
|
+
),
|
|
51
|
+
children: d.map((r) => /* @__PURE__ */ D(
|
|
52
|
+
"div",
|
|
53
|
+
{
|
|
54
|
+
...w(`${r.id}-col`, r, 0),
|
|
55
|
+
className: f(
|
|
56
|
+
"Bear-Kanban__column bear-flex-shrink-0 bear-w-72 bear-flex bear-flex-col bear-rounded-lg bear-bg-gray-100 dark:bear-bg-zinc-800/80 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-transition-colors",
|
|
57
|
+
N === `${r.id}-col` && "bear-border-bear-500 bear-bg-bear-500/5"
|
|
58
|
+
),
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ i("div", { className: "bear-px-4 bear-py-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700", children: k ? k(r) : /* @__PURE__ */ i("h3", { className: "bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white", children: r.title }) }),
|
|
61
|
+
/* @__PURE__ */ i("div", { className: "bear-flex-1 bear-flex bear-flex-col bear-gap-2 bear-p-3 bear-min-h-[120px]", children: r.cards.map((e, b) => {
|
|
62
|
+
const t = `${r.id}-${b}`, n = K && $ === t;
|
|
63
|
+
return /* @__PURE__ */ i(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
...w(t, e, b),
|
|
67
|
+
...u(t, e, b),
|
|
68
|
+
className: f(
|
|
69
|
+
"Bear-Kanban__card bear-rounded-lg bear-bg-white dark:bear-bg-zinc-700/80 bear-border bear-border-gray-200 dark:bear-border-zinc-600 bear-p-3 bear-cursor-grab active:bear-cursor-grabbing bear-transition-all bear-shadow-sm",
|
|
70
|
+
n && "bear-opacity-50 bear-scale-95",
|
|
71
|
+
N === t && "bear-border-bear-500 bear-bg-bear-500/10"
|
|
72
|
+
),
|
|
73
|
+
children: h ? h(e, r.id) : /* @__PURE__ */ D(B, { children: [
|
|
74
|
+
/* @__PURE__ */ i("div", { className: "bear-font-medium bear-text-gray-900 dark:bear-text-white", children: e.title }),
|
|
75
|
+
e.description && /* @__PURE__ */ i("div", { className: "bear-text-sm bear-text-gray-600 dark:bear-text-zinc-400 bear-mt-1", children: e.description }),
|
|
76
|
+
e.meta && /* @__PURE__ */ i("div", { className: "bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500 bear-mt-2", children: e.meta })
|
|
77
|
+
] })
|
|
78
|
+
},
|
|
79
|
+
e.id
|
|
80
|
+
);
|
|
81
|
+
}) })
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
r.id
|
|
85
|
+
))
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
R as Kanban
|
|
91
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface KanbanCard {
|
|
3
|
+
id: string;
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
meta?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export interface KanbanColumn {
|
|
9
|
+
id: string;
|
|
10
|
+
title: ReactNode;
|
|
11
|
+
cards: KanbanCard[];
|
|
12
|
+
}
|
|
13
|
+
export interface KanbanProps {
|
|
14
|
+
columns: KanbanColumn[];
|
|
15
|
+
onColumnsChange?: (columns: KanbanColumn[]) => void;
|
|
16
|
+
onCardMove?: (cardId: string, fromColumnId: string, toColumnId: string, fromIndex: number, toIndex: number) => void;
|
|
17
|
+
renderCard?: (card: KanbanCard, columnId: string) => ReactNode;
|
|
18
|
+
renderColumnHeader?: (column: KanbanColumn) => ReactNode;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),t=require("react"),v=require("../../utils/cn.cjs"),P={sm:"bear-h-8 bear-text-sm bear-px-3",md:"bear-h-10 bear-text-base bear-px-4",lg:"bear-h-12 bear-text-lg bear-px-5"},U=(u,g)=>{const a=g.toLowerCase();return u.filter(l=>l.value.toLowerCase().includes(a)||String(l.label).toLowerCase().includes(a))},V=({value:u,defaultValue:g="",onChange:a,onMentionSelect:l,options:S,trigger:c="@",placeholder:D="Type @ to mention...",disabled:k=!1,maxSuggestions:L=5,filterOptions:M=U,size:N="md",fullWidth:T=!1,className:$})=>{const[A,q]=t.useState(g),[d,K]=t.useState(""),[Q,x]=t.useState(!1),[b,h]=t.useState(0),[p,B]=t.useState(null),y=t.useRef(null),z=t.useRef(null),w=t.useRef(null),n=u??A,i=M(S,d).slice(0,L),E=Q&&d.length>=0,I=t.useCallback(()=>{const e=n.lastIndexOf(c);if(e===-1)return{query:"",start:null};const r=n.slice(e+c.length),s=r.indexOf(" ");return{query:s===-1?r:r.slice(0,s),start:e}},[n,c]);t.useEffect(()=>{const{query:e,start:r}=I();K(e),B(r),x(r!==null&&!e.includes(" "))},[n,I]),t.useEffect(()=>{h(0)},[d]),t.useEffect(()=>{if(b>=0&&w.current){const e=w.current.children[b];e==null||e.scrollIntoView({block:"nearest"})}},[b]),t.useEffect(()=>{const e=r=>{y.current&&!y.current.contains(r.target)&&x(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const R=e=>{const r=new RegExp(`${c}(\\w+)`,"g"),s=[];let f;for(;(f=r.exec(e))!==null;)s.push(f[1]);return[...new Set(s)]},F=e=>{const r=e.target.value;u===void 0&&q(r),a==null||a(r,R(r))},j=e=>{var O;if(p==null)return;const r=n.slice(0,p),s=n.slice(p+c.length+d.length),f=`${c}${e.value}`,m=r+f+" "+s;u===void 0&&q(m),a==null||a(m,R(m)),l==null||l(e),x(!1),(O=z.current)==null||O.focus()},H=e=>{if(!(!E||i.length===0)){if(e.key==="ArrowDown"){e.preventDefault(),h(r=>Math.min(r+1,i.length-1));return}if(e.key==="ArrowUp"){e.preventDefault(),h(r=>Math.max(r-1,0));return}if(e.key==="Enter"||e.key==="Tab"){e.preventDefault();const r=i[b];r&&j(r);return}e.key==="Escape"&&x(!1)}};return o.jsxs("div",{ref:y,className:v.cn("Bear-MentionsInput bear-relative",T&&"bear-w-full",$),children:[o.jsx("input",{ref:z,type:"text",value:n,onChange:F,onKeyDown:H,placeholder:D,disabled:k,className:v.cn("bear-w-full bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-900 bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-500 dark:placeholder:bear-text-zinc-500 bear-outline-none bear-transition-colors focus:bear-border-bear-500 focus:bear-ring-2 focus:bear-ring-bear-500/20",k&&"bear-opacity-50 bear-cursor-not-allowed",P[N])}),E&&i.length>0&&o.jsx("div",{ref:w,className:"bear-absolute bear-z-50 bear-mt-1 bear-w-full bear-max-h-48 bear-overflow-auto bear-rounded-lg bear-border bear-border-gray-200 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-py-1 bear-shadow-lg",children:i.map((e,r)=>o.jsxs("button",{type:"button",className:v.cn("bear-w-full bear-flex bear-items-center bear-gap-2 bear-px-3 bear-py-2 bear-text-left bear-text-gray-800 dark:bear-text-zinc-200 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-transition-colors",r===b&&"bear-bg-gray-100 dark:bear-bg-zinc-700"),onMouseEnter:()=>h(r),onClick:()=>j(e),children:[e.avatar&&o.jsx("span",{className:"bear-shrink-0",children:e.avatar}),o.jsx("span",{children:e.label})]},e.value))})]})};exports.MentionsInput=V;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsxs as M, jsx as x } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as k, useCallback as G, useEffect as p } from "react";
|
|
3
|
+
import { cn as z } from "../../utils/cn.js";
|
|
4
|
+
const J = {
|
|
5
|
+
sm: "bear-h-8 bear-text-sm bear-px-3",
|
|
6
|
+
md: "bear-h-10 bear-text-base bear-px-4",
|
|
7
|
+
lg: "bear-h-12 bear-text-lg bear-px-5"
|
|
8
|
+
}, P = (o, m) => {
|
|
9
|
+
const t = m.toLowerCase();
|
|
10
|
+
return o.filter(
|
|
11
|
+
(s) => s.value.toLowerCase().includes(t) || String(s.label).toLowerCase().includes(t)
|
|
12
|
+
);
|
|
13
|
+
}, Z = ({
|
|
14
|
+
value: o,
|
|
15
|
+
defaultValue: m = "",
|
|
16
|
+
onChange: t,
|
|
17
|
+
onMentionSelect: s,
|
|
18
|
+
options: T,
|
|
19
|
+
trigger: l = "@",
|
|
20
|
+
placeholder: $ = "Type @ to mention...",
|
|
21
|
+
disabled: I = !1,
|
|
22
|
+
maxSuggestions: j = 5,
|
|
23
|
+
filterOptions: A = P,
|
|
24
|
+
size: K = "md",
|
|
25
|
+
fullWidth: Q = !1,
|
|
26
|
+
className: B
|
|
27
|
+
}) => {
|
|
28
|
+
const [F, q] = u(m), [d, H] = u(""), [S, f] = u(!1), [c, h] = u(0), [g, U] = u(null), w = k(null), E = k(null), y = k(null), a = o ?? F, b = A(T, d).slice(0, j), D = S && d.length >= 0, L = G(() => {
|
|
29
|
+
const e = a.lastIndexOf(l);
|
|
30
|
+
if (e === -1) return { query: "", start: null };
|
|
31
|
+
const r = a.slice(e + l.length), n = r.indexOf(" ");
|
|
32
|
+
return { query: n === -1 ? r : r.slice(0, n), start: e };
|
|
33
|
+
}, [a, l]);
|
|
34
|
+
p(() => {
|
|
35
|
+
const { query: e, start: r } = L();
|
|
36
|
+
H(e), U(r), f(r !== null && !e.includes(" "));
|
|
37
|
+
}, [a, L]), p(() => {
|
|
38
|
+
h(0);
|
|
39
|
+
}, [d]), p(() => {
|
|
40
|
+
if (c >= 0 && y.current) {
|
|
41
|
+
const e = y.current.children[c];
|
|
42
|
+
e == null || e.scrollIntoView({ block: "nearest" });
|
|
43
|
+
}
|
|
44
|
+
}, [c]), p(() => {
|
|
45
|
+
const e = (r) => {
|
|
46
|
+
w.current && !w.current.contains(r.target) && f(!1);
|
|
47
|
+
};
|
|
48
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
49
|
+
}, []);
|
|
50
|
+
const O = (e) => {
|
|
51
|
+
const r = new RegExp(`${l}(\\w+)`, "g"), n = [];
|
|
52
|
+
let i;
|
|
53
|
+
for (; (i = r.exec(e)) !== null; )
|
|
54
|
+
n.push(i[1]);
|
|
55
|
+
return [...new Set(n)];
|
|
56
|
+
}, V = (e) => {
|
|
57
|
+
const r = e.target.value;
|
|
58
|
+
o === void 0 && q(r), t == null || t(r, O(r));
|
|
59
|
+
}, N = (e) => {
|
|
60
|
+
var R;
|
|
61
|
+
if (g == null) return;
|
|
62
|
+
const r = a.slice(0, g), n = a.slice(g + l.length + d.length), i = `${l}${e.value}`, v = r + i + " " + n;
|
|
63
|
+
o === void 0 && q(v), t == null || t(v, O(v)), s == null || s(e), f(!1), (R = E.current) == null || R.focus();
|
|
64
|
+
}, C = (e) => {
|
|
65
|
+
if (!(!D || b.length === 0)) {
|
|
66
|
+
if (e.key === "ArrowDown") {
|
|
67
|
+
e.preventDefault(), h((r) => Math.min(r + 1, b.length - 1));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (e.key === "ArrowUp") {
|
|
71
|
+
e.preventDefault(), h((r) => Math.max(r - 1, 0));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (e.key === "Enter" || e.key === "Tab") {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
const r = b[c];
|
|
77
|
+
r && N(r);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
e.key === "Escape" && f(!1);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return /* @__PURE__ */ M(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
ref: w,
|
|
87
|
+
className: z(
|
|
88
|
+
"Bear-MentionsInput bear-relative",
|
|
89
|
+
Q && "bear-w-full",
|
|
90
|
+
B
|
|
91
|
+
),
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ x(
|
|
94
|
+
"input",
|
|
95
|
+
{
|
|
96
|
+
ref: E,
|
|
97
|
+
type: "text",
|
|
98
|
+
value: a,
|
|
99
|
+
onChange: V,
|
|
100
|
+
onKeyDown: C,
|
|
101
|
+
placeholder: $,
|
|
102
|
+
disabled: I,
|
|
103
|
+
className: z(
|
|
104
|
+
"bear-w-full bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-900 bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-500 dark:placeholder:bear-text-zinc-500 bear-outline-none bear-transition-colors focus:bear-border-bear-500 focus:bear-ring-2 focus:bear-ring-bear-500/20",
|
|
105
|
+
I && "bear-opacity-50 bear-cursor-not-allowed",
|
|
106
|
+
J[K]
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
D && b.length > 0 && /* @__PURE__ */ x(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
ref: y,
|
|
114
|
+
className: "bear-absolute bear-z-50 bear-mt-1 bear-w-full bear-max-h-48 bear-overflow-auto bear-rounded-lg bear-border bear-border-gray-200 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-py-1 bear-shadow-lg",
|
|
115
|
+
children: b.map((e, r) => /* @__PURE__ */ M(
|
|
116
|
+
"button",
|
|
117
|
+
{
|
|
118
|
+
type: "button",
|
|
119
|
+
className: z(
|
|
120
|
+
"bear-w-full bear-flex bear-items-center bear-gap-2 bear-px-3 bear-py-2 bear-text-left bear-text-gray-800 dark:bear-text-zinc-200 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-transition-colors",
|
|
121
|
+
r === c && "bear-bg-gray-100 dark:bear-bg-zinc-700"
|
|
122
|
+
),
|
|
123
|
+
onMouseEnter: () => h(r),
|
|
124
|
+
onClick: () => N(e),
|
|
125
|
+
children: [
|
|
126
|
+
e.avatar && /* @__PURE__ */ x("span", { className: "bear-shrink-0", children: e.avatar }),
|
|
127
|
+
/* @__PURE__ */ x("span", { children: e.label })
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
e.value
|
|
131
|
+
))
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
export {
|
|
139
|
+
Z as MentionsInput
|
|
140
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface MentionOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
avatar?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface MentionsInputProps {
|
|
8
|
+
value?: string;
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
onChange?: (value: string, mentions: string[]) => void;
|
|
11
|
+
onMentionSelect?: (option: MentionOption) => void;
|
|
12
|
+
options: MentionOption[];
|
|
13
|
+
trigger?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
maxSuggestions?: number;
|
|
17
|
+
filterOptions?: (options: MentionOption[], query: string) => MentionOption[];
|
|
18
|
+
size?: 'sm' | 'md' | 'lg';
|
|
19
|
+
fullWidth?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("react"),L=require("../../utils/cn.cjs"),r=require("./QRCode.const.cjs"),x=require("./QRCode.utils.cjs"),m=({value:s,size:t=r.QRCODE_DEFAULTS.SIZE,level:h=r.QRCODE_DEFAULTS.LEVEL,bgColor:d=r.QRCODE_DEFAULTS.BG_COLOR,fgColor:D=r.QRCODE_DEFAULTS.FG_COLOR,includeMargin:E=r.QRCODE_DEFAULTS.INCLUDE_MARGIN,imageUrl:R,imageSize:C=r.QRCODE_DEFAULTS.IMAGE_SIZE,className:O,style:Q,testId:S})=>{const l=g.useMemo(()=>{if(!s)return null;const o=x.generateQRMatrix(s,h),c=E?4:0,u=o.size+c*2,a=t/u,_=x.matrixToSvgPath(o,a,c*a);return{matrix:o,path:_,cellSize:a,margin:c,totalModules:u}},[s,h,t,E]);if(!l)return null;const i=t*C,n=(t-i)/2;return e.jsxs("svg",{className:L.cn("Bear-QRCode",O),width:t,height:t,viewBox:`0 0 ${t} ${t}`,style:Q,"data-testid":S,children:[e.jsx("rect",{width:t,height:t,fill:d}),e.jsx("path",{d:l.path,fill:D}),R&&e.jsxs("g",{children:[e.jsx("rect",{x:n-4,y:n-4,width:i+8,height:i+8,fill:d,rx:4}),e.jsx("image",{href:R,x:n,y:n,width:i,height:i,preserveAspectRatio:"xMidYMid slice"})]})]})};exports.QRCode=m;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E={SIZE:128,LEVEL:"M",BG_COLOR:"#ffffff",FG_COLOR:"#000000",INCLUDE_MARGIN:!0,IMAGE_SIZE:.2};exports.QRCODE_DEFAULTS=E;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const QRCODE_DEFAULTS: {
|
|
2
|
+
readonly SIZE: 128;
|
|
3
|
+
readonly LEVEL: "M";
|
|
4
|
+
readonly BG_COLOR: "#ffffff";
|
|
5
|
+
readonly FG_COLOR: "#000000";
|
|
6
|
+
readonly INCLUDE_MARGIN: true;
|
|
7
|
+
readonly IMAGE_SIZE: 0.2;
|
|
8
|
+
readonly RENDER_AS: "svg";
|
|
9
|
+
};
|
|
10
|
+
export declare const QRCODE_ERROR_CORRECTION: {
|
|
11
|
+
readonly L: 0;
|
|
12
|
+
readonly M: 1;
|
|
13
|
+
readonly Q: 2;
|
|
14
|
+
readonly H: 3;
|
|
15
|
+
};
|
|
16
|
+
export declare const QRCODE_MODE: {
|
|
17
|
+
readonly NUMERIC: 1;
|
|
18
|
+
readonly ALPHANUMERIC: 2;
|
|
19
|
+
readonly BYTE: 4;
|
|
20
|
+
};
|
|
21
|
+
export declare const ALPHANUMERIC_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { QRCodeProps } from './QRCode.types';
|
|
3
|
+
/**
|
|
4
|
+
* QRCode - QR code generator component
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // Basic usage
|
|
9
|
+
* <QRCode value="https://forgestack.dev" />
|
|
10
|
+
*
|
|
11
|
+
* // Custom styling
|
|
12
|
+
* <QRCode
|
|
13
|
+
* value="Hello World"
|
|
14
|
+
* size={200}
|
|
15
|
+
* fgColor="#ec4899"
|
|
16
|
+
* bgColor="transparent"
|
|
17
|
+
* />
|
|
18
|
+
*
|
|
19
|
+
* // With center logo
|
|
20
|
+
* <QRCode
|
|
21
|
+
* value="https://forgestack.dev"
|
|
22
|
+
* imageUrl="/logo.png"
|
|
23
|
+
* imageSize={0.25}
|
|
24
|
+
* level="H"
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const QRCode: FC<QRCodeProps>;
|
|
29
|
+
export default QRCode;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsxs as x, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as u } from "react";
|
|
3
|
+
import { cn as w } from "../../utils/cn.js";
|
|
4
|
+
import { QRCODE_DEFAULTS as r } from "./QRCode.const.js";
|
|
5
|
+
import { generateQRMatrix as C, matrixToSvgPath as D } from "./QRCode.utils.js";
|
|
6
|
+
const Q = ({
|
|
7
|
+
value: n,
|
|
8
|
+
size: t = r.SIZE,
|
|
9
|
+
level: c = r.LEVEL,
|
|
10
|
+
bgColor: s = r.BG_COLOR,
|
|
11
|
+
fgColor: g = r.FG_COLOR,
|
|
12
|
+
includeMargin: d = r.INCLUDE_MARGIN,
|
|
13
|
+
imageUrl: f,
|
|
14
|
+
imageSize: E = r.IMAGE_SIZE,
|
|
15
|
+
className: R,
|
|
16
|
+
style: L,
|
|
17
|
+
testId: M
|
|
18
|
+
}) => {
|
|
19
|
+
const l = u(() => {
|
|
20
|
+
if (!n) return null;
|
|
21
|
+
const h = C(n, c), m = d ? 4 : 0, p = h.size + m * 2, a = t / p, O = D(h, a, m * a);
|
|
22
|
+
return { matrix: h, path: O, cellSize: a, margin: m, totalModules: p };
|
|
23
|
+
}, [n, c, t, d]);
|
|
24
|
+
if (!l) return null;
|
|
25
|
+
const o = t * E, i = (t - o) / 2;
|
|
26
|
+
return /* @__PURE__ */ x(
|
|
27
|
+
"svg",
|
|
28
|
+
{
|
|
29
|
+
className: w("Bear-QRCode", R),
|
|
30
|
+
width: t,
|
|
31
|
+
height: t,
|
|
32
|
+
viewBox: `0 0 ${t} ${t}`,
|
|
33
|
+
style: L,
|
|
34
|
+
"data-testid": M,
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ e("rect", { width: t, height: t, fill: s }),
|
|
37
|
+
/* @__PURE__ */ e("path", { d: l.path, fill: g }),
|
|
38
|
+
f && /* @__PURE__ */ x("g", { children: [
|
|
39
|
+
/* @__PURE__ */ e(
|
|
40
|
+
"rect",
|
|
41
|
+
{
|
|
42
|
+
x: i - 4,
|
|
43
|
+
y: i - 4,
|
|
44
|
+
width: o + 8,
|
|
45
|
+
height: o + 8,
|
|
46
|
+
fill: s,
|
|
47
|
+
rx: 4
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ e(
|
|
51
|
+
"image",
|
|
52
|
+
{
|
|
53
|
+
href: f,
|
|
54
|
+
x: i,
|
|
55
|
+
y: i,
|
|
56
|
+
width: o,
|
|
57
|
+
height: o,
|
|
58
|
+
preserveAspectRatio: "xMidYMid slice"
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] })
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
Q as QRCode
|
|
68
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export interface QRCodeProps {
|
|
3
|
+
/** The value to encode in the QR code */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Size in pixels */
|
|
6
|
+
size?: number;
|
|
7
|
+
/** Error correction level */
|
|
8
|
+
level?: 'L' | 'M' | 'Q' | 'H';
|
|
9
|
+
/** Background color */
|
|
10
|
+
bgColor?: string;
|
|
11
|
+
/** Foreground color */
|
|
12
|
+
fgColor?: string;
|
|
13
|
+
/** Include margin (quiet zone) */
|
|
14
|
+
includeMargin?: boolean;
|
|
15
|
+
/** Center image URL */
|
|
16
|
+
imageUrl?: string;
|
|
17
|
+
/** Center image size (as percentage of QR code size) */
|
|
18
|
+
imageSize?: number;
|
|
19
|
+
/** Render as canvas or SVG */
|
|
20
|
+
renderAs?: 'canvas' | 'svg';
|
|
21
|
+
/** Custom class name */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** Custom style */
|
|
24
|
+
style?: CSSProperties;
|
|
25
|
+
/** Test ID */
|
|
26
|
+
testId?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface QRCodeCell {
|
|
29
|
+
row: number;
|
|
30
|
+
col: number;
|
|
31
|
+
isDark: boolean;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(a,i){const f=[17,32,53,78,106,134,154,192,230],r=i==="L"?1:i==="M"?.85:i==="Q"?.65:.5;for(let e=1;e<=9;e++)if(a<=f[e-1]*r)return e;return 9}function v(a,i="M"){const f=y(a.length,i),r=f*4+17,e=Array(r).fill(null).map(()=>Array(r).fill(!1)),h=(t,n)=>{for(let o=-1;o<=7;o++)for(let s=-1;s<=7;s++){const c=t+o,d=n+s;if(c>=0&&c<r&&d>=0&&d<r){const M=o===-1||o===7||s===-1||s===7,p=o>=1&&o<=5&&s>=1&&s<=5,x=o>=2&&o<=4&&s>=2&&s<=4;e[c][d]=!M&&(x||!p)}}};h(0,0),h(0,r-7),h(r-7,0);for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0;if(f>=2){const t=r-7;for(let n=-2;n<=2;n++)for(let o=-2;o<=2;o++){const s=t+n,c=t+o;if(s>=0&&s<r&&c>=0&&c<r){const d=Math.abs(n)===2||Math.abs(o)===2,M=n===0&&o===0;e[s][c]=d||M}}}const l=new TextEncoder().encode(a);let u=0,g=0;for(let t=r-1;t>=1;t-=2){t===6&&(t=5);for(let n=0;n<r;n++)for(let o=0;o<2;o++){const s=t-o,c=(t+1)%4<2?r-1-n:n;if(!b(c,s,r,f))if(u<l.length){const d=l[u]>>7-g&1;e[c][s]=d===1,g++,g===8&&(g=0,u++)}else e[c][s]=(c+s)%2===0}}for(let t=0;t<r;t++)for(let n=0;n<r;n++)b(t,n,r,f)||(t+n)%2===0&&(e[t][n]=!e[t][n]);return{size:r,modules:e}}function b(a,i,f,r){if(a<=8&&i<=8||a<=8&&i>=f-8||a>=f-8&&i<=8||a===6||i===6)return!0;if(r>=2){const e=f-7;if(Math.abs(a-e)<=2&&Math.abs(i-e)<=2)return!0}return!1}function P(a,i,f){const{size:r,modules:e}=a;let h="";for(let l=0;l<r;l++)for(let u=0;u<r;u++)if(e[l][u]){const g=f+u*i,t=f+l*i;h+=`M${g},${t}h${i}v${i}h-${i}z`}return h}exports.generateQRMatrix=v;exports.matrixToSvgPath=P;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified QR Code generator utilities
|
|
3
|
+
* Note: For production, consider using a dedicated library like 'qrcode'
|
|
4
|
+
* This is a basic implementation for demonstration purposes
|
|
5
|
+
*/
|
|
6
|
+
interface QRMatrix {
|
|
7
|
+
size: number;
|
|
8
|
+
modules: boolean[][];
|
|
9
|
+
}
|
|
10
|
+
export declare function generateQRMatrix(text: string, level?: string): QRMatrix;
|
|
11
|
+
export declare function matrixToSvgPath(matrix: QRMatrix, cellSize: number, margin: number): string;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
function y(c, f) {
|
|
2
|
+
const i = [17, 32, 53, 78, 106, 134, 154, 192, 230], n = f === "L" ? 1 : f === "M" ? 0.85 : f === "Q" ? 0.65 : 0.5;
|
|
3
|
+
for (let r = 1; r <= 9; r++)
|
|
4
|
+
if (c <= i[r - 1] * n) return r;
|
|
5
|
+
return 9;
|
|
6
|
+
}
|
|
7
|
+
function $(c, f = "M") {
|
|
8
|
+
const i = y(c.length, f), n = i * 4 + 17, r = Array(n).fill(null).map(() => Array(n).fill(!1)), h = (t, e) => {
|
|
9
|
+
for (let o = -1; o <= 7; o++)
|
|
10
|
+
for (let s = -1; s <= 7; s++) {
|
|
11
|
+
const a = t + o, d = e + s;
|
|
12
|
+
if (a >= 0 && a < n && d >= 0 && d < n) {
|
|
13
|
+
const M = o === -1 || o === 7 || s === -1 || s === 7, x = o >= 1 && o <= 5 && s >= 1 && s <= 5, g = o >= 2 && o <= 4 && s >= 2 && s <= 4;
|
|
14
|
+
r[a][d] = !M && (g || !x);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
h(0, 0), h(0, n - 7), h(n - 7, 0);
|
|
19
|
+
for (let t = 8; t < n - 8; t++)
|
|
20
|
+
r[6][t] = t % 2 === 0, r[t][6] = t % 2 === 0;
|
|
21
|
+
if (i >= 2) {
|
|
22
|
+
const t = n - 7;
|
|
23
|
+
for (let e = -2; e <= 2; e++)
|
|
24
|
+
for (let o = -2; o <= 2; o++) {
|
|
25
|
+
const s = t + e, a = t + o;
|
|
26
|
+
if (s >= 0 && s < n && a >= 0 && a < n) {
|
|
27
|
+
const d = Math.abs(e) === 2 || Math.abs(o) === 2, M = e === 0 && o === 0;
|
|
28
|
+
r[s][a] = d || M;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const l = new TextEncoder().encode(c);
|
|
33
|
+
let u = 0, p = 0;
|
|
34
|
+
for (let t = n - 1; t >= 1; t -= 2) {
|
|
35
|
+
t === 6 && (t = 5);
|
|
36
|
+
for (let e = 0; e < n; e++)
|
|
37
|
+
for (let o = 0; o < 2; o++) {
|
|
38
|
+
const s = t - o, a = (t + 1) % 4 < 2 ? n - 1 - e : e;
|
|
39
|
+
if (!b(a, s, n, i))
|
|
40
|
+
if (u < l.length) {
|
|
41
|
+
const d = l[u] >> 7 - p & 1;
|
|
42
|
+
r[a][s] = d === 1, p++, p === 8 && (p = 0, u++);
|
|
43
|
+
} else
|
|
44
|
+
r[a][s] = (a + s) % 2 === 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
for (let t = 0; t < n; t++)
|
|
48
|
+
for (let e = 0; e < n; e++)
|
|
49
|
+
b(t, e, n, i) || (t + e) % 2 === 0 && (r[t][e] = !r[t][e]);
|
|
50
|
+
return { size: n, modules: r };
|
|
51
|
+
}
|
|
52
|
+
function b(c, f, i, n) {
|
|
53
|
+
if (c <= 8 && f <= 8 || c <= 8 && f >= i - 8 || c >= i - 8 && f <= 8 || c === 6 || f === 6) return !0;
|
|
54
|
+
if (n >= 2) {
|
|
55
|
+
const r = i - 7;
|
|
56
|
+
if (Math.abs(c - r) <= 2 && Math.abs(f - r) <= 2) return !0;
|
|
57
|
+
}
|
|
58
|
+
return !1;
|
|
59
|
+
}
|
|
60
|
+
function v(c, f, i) {
|
|
61
|
+
const { size: n, modules: r } = c;
|
|
62
|
+
let h = "";
|
|
63
|
+
for (let l = 0; l < n; l++)
|
|
64
|
+
for (let u = 0; u < n; u++)
|
|
65
|
+
if (r[l][u]) {
|
|
66
|
+
const p = i + u * f, t = i + l * f;
|
|
67
|
+
h += `M${p},${t}h${f}v${f}h-${f}z`;
|
|
68
|
+
}
|
|
69
|
+
return h;
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
$ as generateQRMatrix,
|
|
73
|
+
v as matrixToSvgPath
|
|
74
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),c=require("react"),T=require("../../utils/cn.cjs"),u=require("./helpers/formatHelpers.cjs"),f=require("./RichEditor.const.cjs"),C=require("./components/ToolbarButton/ToolbarButton.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),c=require("react"),T=require("../../utils/cn.cjs"),u=require("./helpers/formatHelpers.cjs"),f=require("./RichEditor.const.cjs"),re=require("../../hooks/useMediaQuery.cjs"),C=require("./components/ToolbarButton/ToolbarButton.cjs"),se=require("./components/ToolbarDropdown/ToolbarDropdown.cjs"),H=require("./components/ToolbarColorPicker/ToolbarColorPicker.cjs"),le=require("./components/ToolbarMore/ToolbarMore.cjs"),r=require("../Icon/icons/editor.cjs"),ae=6,ce=B=>{const{value:x,defaultValue:E="",onChange:R,placeholder:S="Start typing...",disabled:o=!1,readOnly:i=!1,minHeight:j=f.RICH_EDITOR_MIN_HEIGHT,maxHeight:b,toolbar:z=f.RICH_EDITOR_DEFAULT_TOOLBAR,className:A="",testId:D,id:v,allowImagePaste:y=!0,...N}=B,a=c.useRef(null),p=re.useMediaQuery(`(max-width: ${f.RICH_EDITOR_MOBILE_BREAKPOINT}px)`),k=p?f.RICH_EDITOR_MOBILE_TOOLBAR:z,[F,M]=c.useState(new Set),[q,L]=c.useState("p"),[w,U]=c.useState("#000000"),[P,V]=c.useState("#fef08a"),[J,G]=c.useState([]),[$,Q]=c.useState([]);c.useEffect(()=>{const e="bear-rich-editor-styles";if(!document.getElementById(e)){const n=document.createElement("style");n.id=e,n.textContent=f.RICH_EDITOR_CONTENT_STYLES,document.head.appendChild(n)}},[]),c.useEffect(()=>{a.current&&x!==void 0&&a.current.innerHTML!==x&&(a.current.innerHTML=x)},[x]),c.useEffect(()=>{a.current&&E&&!x&&(a.current.innerHTML=E)},[]);const h=c.useCallback(()=>{M(u.getActiveFormats());const e=u.queryCommandValue("formatBlock");e&&L(e.toLowerCase().replace(/[<>]/g,""))},[]),l=c.useCallback(()=>{a.current&&R&&R(a.current.innerHTML),h()},[R,h]),K=c.useCallback(e=>{var d;if(o||i)return;(d=a.current)==null||d.focus();const n=f.RICH_EDITOR_BUTTON_CONFIG[e];if(!n)return;const g="value"in n?n.value:void 0;g?u.execCommand(n.command,g):u.execCommand(n.command),h(),l()},[o,i,h,l]),Y=c.useCallback(e=>{var n;o||i||((n=a.current)==null||n.focus(),u.execCommand("formatBlock",e),L(e),l())},[o,i,l]),W=c.useCallback(()=>{var d;if(o||i)return;const e=window.getSelection(),n=e&&e.toString().length>0,g=prompt("Enter URL:",n?"":"https://");g&&((d=a.current)==null||d.focus(),u.insertLink(g),l())},[o,i,l]),m=c.useCallback((e,n)=>{if(!e)return;(n==="text"?G:Q)(d=>{const s=d.filter(I=>I!==e);return[e,...s].slice(0,ae)})},[]),X=c.useCallback(e=>{var n;o||i||((n=a.current)==null||n.focus(),u.setTextColor(e),U(e),m(e,"text"),l())},[o,i,l,m]),Z=c.useCallback(e=>{var n;o||i||((n=a.current)==null||n.focus(),u.setHighlightColor(e),V(e),m(e,"highlight"),l())},[o,i,l,m]),ee=c.useCallback(e=>{var n;o||i||((n=a.current)==null||n.focus(),u.setTextColor(e),l())},[o,i,l]),te=c.useCallback(e=>{var n;o||i||((n=a.current)==null||n.focus(),u.setHighlightColor(e),l())},[o,i,l]),ne=c.useCallback(async e=>{var g;if(!y)return;const n=(g=e.clipboardData)==null?void 0:g.items;if(n)for(let d=0;d<n.length;d++){const s=n[d];if(s.type.startsWith("image/")){e.preventDefault();const I=s.getAsFile();if(I){const _=await u.fileToDataUrl(I);u.insertImage(_),l()}return}}},[y,l]),oe=c.useCallback(()=>{if(o||i)return;const e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=async n=>{var d,s;const g=(d=n.target.files)==null?void 0:d[0];if(g){const I=await u.fileToDataUrl(g);(s=a.current)==null||s.focus(),u.insertImage(I),l()}},e.click()},[o,i,l]),ie={bold:t.jsx(r.BoldIcon,{size:16}),italic:t.jsx(r.ItalicIcon,{size:16}),underline:t.jsx(r.UnderlineIcon,{size:16}),strikethrough:t.jsx(r.StrikethroughIcon,{size:16}),heading1:t.jsx(r.Heading1Icon,{size:16}),heading2:t.jsx(r.Heading2Icon,{size:16}),heading3:t.jsx(r.Heading3Icon,{size:16}),bulletList:t.jsx(r.ListBulletIcon,{size:16}),orderedList:t.jsx(r.ListNumberedIcon,{size:16}),blockquote:t.jsx(r.QuoteIcon,{size:16}),code:t.jsx(r.CodeIcon,{size:16}),link:t.jsx(r.InsertLinkIcon,{size:16}),alignLeft:t.jsx(r.AlignLeftIcon,{size:16}),alignCenter:t.jsx(r.AlignCenterIcon,{size:16}),alignRight:t.jsx(r.AlignRightIcon,{size:16}),alignJustify:t.jsx(r.AlignJustifyIcon,{size:16}),image:t.jsx(r.InsertPhotoIcon,{size:16}),indent:t.jsx(r.IndentIncreaseIcon,{size:16}),outdent:t.jsx(r.IndentDecreaseIcon,{size:16}),clearFormat:t.jsx(r.FormatClearIcon,{size:16}),table:t.jsx(r.TableIcon,{size:16})},O=(e,n)=>{if(e==="divider")return t.jsx("div",{className:T.cn("Bear-RichEditor__divider",f.RICH_EDITOR_DIVIDER_CLASSES)},`divider-${n}`);if(e==="headingDropdown")return t.jsx(se.ToolbarDropdown,{options:f.RICH_EDITOR_HEADING_OPTIONS,value:q,onChange:Y,title:"Text Style",disabled:o||i,icon:t.jsx(r.TextIcon,{size:16})},"heading-dropdown");if(e==="textColor")return t.jsx(H.ToolbarColorPicker,{value:w,onChange:X,title:"Text Color",disabled:o||i,type:"text",recentColors:J,onApplyLast:ee},"text-color");if(e==="highlightColor")return t.jsx(H.ToolbarColorPicker,{value:P,onChange:Z,title:"Highlight Color",disabled:o||i,type:"highlight",recentColors:$,onApplyLast:te},"highlight-color");if(e==="link")return t.jsx(C.ToolbarButton,{icon:t.jsx(r.InsertLinkIcon,{size:16}),title:"Insert Link",onClick:W,disabled:o||i},"link");if(e==="image")return t.jsx(C.ToolbarButton,{icon:t.jsx(r.InsertPhotoIcon,{size:16}),title:"Insert Image",onClick:oe,disabled:o||i},"image");if(e==="alignLeft")return t.jsx(C.ToolbarButton,{icon:t.jsx(r.AlignLeftIcon,{size:16}),title:"Align Left",onClick:()=>{var s;(s=a.current)==null||s.focus(),u.execCommand("justifyLeft"),l()},disabled:o||i},"alignLeft");if(e==="alignCenter")return t.jsx(C.ToolbarButton,{icon:t.jsx(r.AlignCenterIcon,{size:16}),title:"Align Center",onClick:()=>{var s;(s=a.current)==null||s.focus(),u.execCommand("justifyCenter"),l()},disabled:o||i},"alignCenter");if(e==="alignRight")return t.jsx(C.ToolbarButton,{icon:t.jsx(r.AlignRightIcon,{size:16}),title:"Align Right",onClick:()=>{var s;(s=a.current)==null||s.focus(),u.execCommand("justifyRight"),l()},disabled:o||i},"alignRight");if(e==="alignJustify")return t.jsx(C.ToolbarButton,{icon:t.jsx(r.AlignJustifyIcon,{size:16}),title:"Justify",onClick:()=>{var s;(s=a.current)==null||s.focus(),u.execCommand("justifyFull"),l()},disabled:o||i},"alignJustify");if(e==="indent")return t.jsx(C.ToolbarButton,{icon:t.jsx(r.IndentIncreaseIcon,{size:16}),title:"Increase Indent",onClick:()=>{var s;(s=a.current)==null||s.focus(),u.execCommand("indent"),l()},disabled:o||i},"indent");if(e==="outdent")return t.jsx(C.ToolbarButton,{icon:t.jsx(r.IndentDecreaseIcon,{size:16}),title:"Decrease Indent",onClick:()=>{var s;(s=a.current)==null||s.focus(),u.execCommand("outdent"),l()},disabled:o||i},"outdent");if(e==="clearFormat")return t.jsx(C.ToolbarButton,{icon:t.jsx(r.FormatClearIcon,{size:16}),title:"Clear Formatting",onClick:()=>{var s;(s=a.current)==null||s.focus(),u.execCommand("removeFormat"),l()},disabled:o||i},"clearFormat");if(e==="more"){const s=p?f.RICH_EDITOR_MOBILE_MORE_ITEMS:["alignLeft","alignCenter","alignRight","alignJustify","indent","outdent","blockquote","code","clearFormat"];return t.jsx(le.ToolbarMore,{disabled:o||i,isMobile:p,children:s.map((I,_)=>O(I,_+1e3))},"more")}const g=f.RICH_EDITOR_BUTTON_CONFIG[e],d=ie[e];return!g||!d?null:t.jsx(C.ToolbarButton,{icon:d,title:g.title,active:F.has(e),onClick:()=>K(e),disabled:o||i},e)};return t.jsxs("div",{id:v,"data-testid":D,className:T.cn("Bear-RichEditor",f.RICH_EDITOR_ROOT_CLASSES,o&&"Bear-RichEditor--disabled",i&&"Bear-RichEditor--readonly",A),...N,children:[k.length>0&&t.jsx("div",{className:T.cn("Bear-RichEditor__toolbar",f.RICH_EDITOR_TOOLBAR_CLASSES),children:k.map((e,n)=>O(e,n))}),t.jsx("div",{ref:a,contentEditable:!o&&!i,onInput:l,onSelect:h,onKeyUp:h,onMouseUp:h,onPaste:ne,"data-placeholder":S,className:T.cn("Bear-RichEditor__content",f.RICH_EDITOR_CONTENT_CLASSES,"[&:empty]:before:bear-content-[attr(data-placeholder)] [&:empty]:before:bear-text-gray-400 [&:empty]:before:bear-pointer-events-none",o&&"Bear-RichEditor__content--disabled bear-opacity-50 bear-cursor-not-allowed"),style:{minHeight:typeof j=="number"?`${j}px`:j,maxHeight:b?typeof b=="number"?`${b}px`:b:void 0,overflowY:b?"auto":void 0}})]})};exports.RichEditor=ce;
|