@forgedevstack/bear 1.0.5 → 1.0.7
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/BottomSheet/BottomSheet.cjs +1 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +3 -0
- package/dist/components/BottomSheet/BottomSheet.js +102 -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.js +40 -38
- package/dist/components/Button/Button.types.d.ts +4 -0
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.const.cjs +1 -1
- package/dist/components/Calendar/Calendar.const.d.ts +1 -0
- package/dist/components/Calendar/Calendar.const.js +6 -5
- package/dist/components/Calendar/Calendar.helpers.cjs +1 -1
- package/dist/components/Calendar/Calendar.helpers.js +4 -4
- package/dist/components/Calendar/Calendar.js +128 -128
- package/dist/components/Cascader/Cascader.cjs +1 -0
- package/dist/components/Cascader/Cascader.const.cjs +1 -0
- package/dist/components/Cascader/Cascader.const.d.ts +33 -0
- package/dist/components/Cascader/Cascader.const.js +21 -0
- package/dist/components/Cascader/Cascader.d.ts +17 -0
- package/dist/components/Cascader/Cascader.js +227 -0
- package/dist/components/Cascader/Cascader.types.d.ts +94 -0
- package/dist/components/Cascader/index.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPalette.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.const.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.const.d.ts +25 -0
- package/dist/components/CommandPalette/CommandPalette.const.js +13 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +18 -0
- package/dist/components/CommandPalette/CommandPalette.js +190 -0
- package/dist/components/CommandPalette/CommandPalette.types.d.ts +90 -0
- package/dist/components/CommandPalette/CommandPalette.utils.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.utils.d.ts +17 -0
- package/dist/components/CommandPalette/CommandPalette.utils.js +63 -0
- package/dist/components/CommandPalette/index.d.ts +2 -0
- package/dist/components/CreditInput/CreditInput.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.const.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.const.d.ts +37 -0
- package/dist/components/CreditInput/CreditInput.const.js +66 -0
- package/dist/components/CreditInput/CreditInput.d.ts +15 -0
- package/dist/components/CreditInput/CreditInput.js +214 -0
- package/dist/components/CreditInput/CreditInput.types.d.ts +93 -0
- package/dist/components/CreditInput/CreditInput.utils.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.utils.d.ts +48 -0
- package/dist/components/CreditInput/CreditInput.utils.js +79 -0
- package/dist/components/CreditInput/index.d.ts +2 -0
- package/dist/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.js +108 -84
- package/dist/components/DatePicker/DatePicker.types.d.ts +2 -1
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +75 -44
- 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/Form/Form.cjs +1 -0
- package/dist/components/Form/Form.const.cjs +1 -0
- package/dist/components/Form/Form.const.d.ts +33 -0
- package/dist/components/Form/Form.const.js +27 -0
- package/dist/components/Form/Form.context.cjs +1 -0
- package/dist/components/Form/Form.context.d.ts +13 -0
- package/dist/components/Form/Form.context.js +12 -0
- package/dist/components/Form/Form.d.ts +18 -0
- package/dist/components/Form/Form.js +230 -0
- package/dist/components/Form/Form.types.d.ts +166 -0
- package/dist/components/Form/Form.utils.cjs +1 -0
- package/dist/components/Form/Form.utils.d.ts +17 -0
- package/dist/components/Form/Form.utils.js +31 -0
- package/dist/components/Form/index.d.ts +3 -0
- package/dist/components/Kanban/Kanban.cjs +1 -0
- package/dist/components/Kanban/Kanban.d.ts +3 -0
- package/dist/components/Kanban/Kanban.js +90 -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/NotificationCenter/NotificationCenter.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.d.ts +25 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.js +28 -0
- package/dist/components/NotificationCenter/NotificationCenter.d.ts +15 -0
- package/dist/components/NotificationCenter/NotificationCenter.js +223 -0
- package/dist/components/NotificationCenter/NotificationCenter.types.d.ts +117 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.d.ts +11 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.js +19 -0
- package/dist/components/NotificationCenter/index.d.ts +2 -0
- package/dist/components/PhoneInput/PhoneInput.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.const.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.const.d.ts +33 -0
- package/dist/components/PhoneInput/PhoneInput.const.js +82 -0
- package/dist/components/PhoneInput/PhoneInput.d.ts +16 -0
- package/dist/components/PhoneInput/PhoneInput.js +194 -0
- package/dist/components/PhoneInput/PhoneInput.types.d.ts +108 -0
- package/dist/components/PhoneInput/PhoneInput.utils.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.utils.d.ts +25 -0
- package/dist/components/PhoneInput/PhoneInput.utils.js +39 -0
- package/dist/components/PhoneInput/index.d.ts +2 -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 +94 -86
- 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/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/TimePicker/TimePicker.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.d.ts +22 -1
- package/dist/components/TimePicker/TimePicker.constants.js +36 -19
- package/dist/components/TimePicker/TimePicker.js +97 -131
- package/dist/components/TimePicker/TimePicker.types.d.ts +47 -6
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.cjs +1 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.d.ts +3 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.js +81 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/index.d.ts +1 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.d.ts +3 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +84 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/index.d.ts +1 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.d.ts +18 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +67 -0
- package/dist/components/TimePicker/helpers/index.d.ts +2 -0
- package/dist/components/TimePicker/index.d.ts +1 -1
- 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 +28 -2
- package/dist/components/index.js +177 -146
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +36 -32
- 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/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/index.cjs +1 -1
- package/dist/index.js +290 -255
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.cjs +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +0 -3
- package/dist/components/DateTimePicker/DateTimePicker.js +0 -178
- package/dist/components/DateTimePicker/DateTimePicker.types.d.ts +0 -26
- package/dist/components/DateTimePicker/DateTimePicker.utils.cjs +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.utils.d.ts +0 -2
- package/dist/components/DateTimePicker/DateTimePicker.utils.js +0 -16
- package/dist/components/DateTimePicker/index.d.ts +0 -2
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
const S = "bear-kanban", O = ({
|
|
7
|
+
columns: d,
|
|
8
|
+
onColumnsChange: o,
|
|
9
|
+
onCardMove: l,
|
|
10
|
+
renderCard: h,
|
|
11
|
+
renderColumnHeader: k,
|
|
12
|
+
disabled: y = !1,
|
|
13
|
+
className: _
|
|
14
|
+
}) => {
|
|
15
|
+
const z = I(
|
|
16
|
+
(r, e, t, b, n) => {
|
|
17
|
+
const x = d.find((a) => a.id === r), s = d.find((a) => a.id === e);
|
|
18
|
+
if (!x || !s) return;
|
|
19
|
+
const m = d.map((a) => {
|
|
20
|
+
if (a.id === r) {
|
|
21
|
+
const c = a.cards.filter((g, p) => p !== t);
|
|
22
|
+
return { ...a, cards: c };
|
|
23
|
+
}
|
|
24
|
+
if (a.id === e) {
|
|
25
|
+
const c = r === e && t < b ? b - 1 : b, g = [...a.cards];
|
|
26
|
+
return g.splice(Math.max(0, c), 0, n), { ...a, cards: g };
|
|
27
|
+
}
|
|
28
|
+
return a;
|
|
29
|
+
});
|
|
30
|
+
o == null || o(m), l == null || l(n.id, r, e, t, b);
|
|
31
|
+
},
|
|
32
|
+
[d, o, l]
|
|
33
|
+
), { getDragProps: u, getDropProps: w, isDragging: K, draggedId: $, dragOverId: N } = P({
|
|
34
|
+
disabled: y,
|
|
35
|
+
dragType: S,
|
|
36
|
+
onDrop: (r, e, t, b, n) => {
|
|
37
|
+
var v;
|
|
38
|
+
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], g = s.endsWith("-col") ? ((v = d.find((j) => j.id === c)) == null ? void 0 : v.cards.length) ?? 0 : parseInt(s.split("-")[1], 10), p = n;
|
|
39
|
+
p != null && p.id && z(m, c, a, g, p);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return /* @__PURE__ */ i(
|
|
43
|
+
"div",
|
|
44
|
+
{
|
|
45
|
+
className: f(
|
|
46
|
+
"Bear-Kanban bear-flex bear-gap-4 bear-overflow-x-auto bear-pb-4",
|
|
47
|
+
y && "bear-opacity-50 bear-pointer-events-none",
|
|
48
|
+
_
|
|
49
|
+
),
|
|
50
|
+
children: d.map((r) => /* @__PURE__ */ D(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
...w(`${r.id}-col`, r, 0),
|
|
54
|
+
className: f(
|
|
55
|
+
"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",
|
|
56
|
+
N === `${r.id}-col` && "bear-border-bear-500 bear-bg-bear-500/5"
|
|
57
|
+
),
|
|
58
|
+
children: [
|
|
59
|
+
/* @__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 }) }),
|
|
60
|
+
/* @__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, t) => {
|
|
61
|
+
const b = `${r.id}-${t}`, n = K && $ === b;
|
|
62
|
+
return /* @__PURE__ */ i(
|
|
63
|
+
"div",
|
|
64
|
+
{
|
|
65
|
+
...w(b, e, t),
|
|
66
|
+
...u(b, e, t),
|
|
67
|
+
className: f(
|
|
68
|
+
"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",
|
|
69
|
+
n && "bear-opacity-50 bear-scale-95",
|
|
70
|
+
N === b && "bear-border-bear-500 bear-bg-bear-500/10"
|
|
71
|
+
),
|
|
72
|
+
children: h ? h(e, r.id) : /* @__PURE__ */ D(B, { children: [
|
|
73
|
+
/* @__PURE__ */ i("div", { className: "bear-font-medium bear-text-gray-900 dark:bear-text-white", children: e.title }),
|
|
74
|
+
e.description && /* @__PURE__ */ i("div", { className: "bear-text-sm bear-text-gray-600 dark:bear-text-zinc-400 bear-mt-1", children: e.description }),
|
|
75
|
+
e.meta && /* @__PURE__ */ i("div", { className: "bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500 bear-mt-2", children: e.meta })
|
|
76
|
+
] })
|
|
77
|
+
},
|
|
78
|
+
e.id
|
|
79
|
+
);
|
|
80
|
+
}) })
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
r.id
|
|
84
|
+
))
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
export {
|
|
89
|
+
O as Kanban
|
|
90
|
+
};
|
|
@@ -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"),n=require("react"),q=require("react-dom"),c=require("../../utils/cn.cjs"),m=require("./NotificationCenter.const.cjs"),F=require("./NotificationCenter.utils.cjs"),W=({notification:r,onRead:d,onDismiss:g,onClick:b,translations:v})=>{const p=()=>{r.read||d==null||d(r.id),b==null||b(r)};return e.jsxs("div",{onClick:p,className:c.cn("Bear-NotificationCenter__item bear-flex bear-gap-3 bear-p-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700 last:bear-border-b-0 bear-cursor-pointer bear-transition-colors hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700/50",!r.read&&"bear-bg-gray-50 dark:bear-bg-zinc-800/50"),children:[e.jsx("div",{className:"Bear-NotificationCenter__item-icon bear-shrink-0",children:r.avatar?e.jsx("img",{src:r.avatar,alt:"",className:"bear-w-10 bear-h-10 bear-rounded-full bear-object-cover"}):r.icon?e.jsx("div",{className:c.cn("bear-w-10 bear-h-10 bear-rounded-full bear-flex bear-items-center bear-justify-center",m.NOTIFICATION_TYPE_COLORS[r.type]),children:r.icon}):e.jsxs("div",{className:c.cn("bear-w-10 bear-h-10 bear-rounded-full bear-flex bear-items-center bear-justify-center",m.NOTIFICATION_TYPE_COLORS[r.type]),children:[r.type==="success"&&e.jsx("svg",{className:"bear-w-5 bear-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),r.type==="error"&&e.jsx("svg",{className:"bear-w-5 bear-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),r.type==="warning"&&e.jsx("svg",{className:"bear-w-5 bear-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),r.type==="info"&&e.jsx("svg",{className:"bear-w-5 bear-h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})]})}),e.jsxs("div",{className:"Bear-NotificationCenter__item-content bear-flex-1 bear-min-w-0",children:[e.jsxs("div",{className:"bear-flex bear-items-start bear-justify-between bear-gap-2",children:[e.jsx("p",{className:c.cn("Bear-NotificationCenter__item-title bear-text-sm bear-font-medium bear-truncate",r.read?"bear-text-gray-600 dark:bear-text-zinc-300":"bear-text-gray-900 dark:bear-text-white"),children:r.title}),!r.read&&e.jsx("span",{className:"Bear-NotificationCenter__item-badge bear-w-2 bear-h-2 bear-rounded-full bear-bg-pink-500 bear-shrink-0 bear-mt-1.5"})]}),r.description&&e.jsx("p",{className:"Bear-NotificationCenter__item-description bear-text-xs bear-text-gray-500 dark:bear-text-zinc-400 bear-mt-0.5 bear-line-clamp-2",children:r.description}),e.jsx("p",{className:"Bear-NotificationCenter__item-time bear-text-xs bear-text-gray-400 dark:bear-text-zinc-500 bear-mt-1",children:F.formatRelativeTime(r.timestamp,v)}),r.actions&&r.actions.length>0&&e.jsx("div",{className:"Bear-NotificationCenter__item-actions bear-flex bear-gap-2 bear-mt-2",children:r.actions.map((a,j)=>e.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),a.onClick()},className:c.cn("bear-px-2 bear-py-1 bear-text-xs bear-rounded bear-transition-colors",a.variant==="primary"&&"bear-bg-pink-500 bear-text-white hover:bear-bg-pink-600",a.variant==="secondary"&&"bear-bg-gray-200 dark:bear-bg-zinc-600 bear-text-gray-900 dark:bear-text-white hover:bear-bg-gray-300 dark:hover:bear-bg-zinc-500",a.variant==="danger"&&"bear-bg-red-500 bear-text-white hover:bear-bg-red-600",!a.variant&&"bear-bg-gray-100 dark:bear-bg-zinc-700 bear-text-gray-700 dark:bear-text-zinc-300 hover:bear-bg-gray-200 dark:hover:bear-bg-zinc-600"),children:a.label},j))})]}),g&&e.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),g(r.id)},className:"Bear-NotificationCenter__item-dismiss bear-p-1 bear-rounded bear-text-gray-500 dark:bear-text-zinc-500 hover:bear-text-gray-700 dark:hover:bear-text-zinc-300 hover:bear-bg-gray-200 dark:hover:bear-bg-zinc-700 bear-transition-colors bear-shrink-0",children:e.jsx("svg",{className:"bear-w-4 bear-h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},D=({notifications:r,onNotificationClick:d,onMarkAsRead:g,onMarkAllAsRead:b,onDismiss:v,onClearAll:p,maxVisible:a=m.NOTIFICATION_CENTER_MAX_VISIBLE,groupByCategory:j=!1,position:x="top-right",trigger:C,open:I,onOpenChange:T,className:O,testId:E,translations:_,icon:M})=>{const[A,R]=n.useState(!1),[w,S]=n.useState({top:0,left:0}),[f,P]=n.useState(!1),B=n.useRef(null),y=n.useRef(null),h=I??A,N=T??R,o=n.useMemo(()=>({...m.NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS,..._}),[_]),i=n.useMemo(()=>r.filter(t=>!t.read).length,[r]),z=n.useMemo(()=>f?r:r.slice(0,a),[r,a,f]);n.useEffect(()=>{if(h&&y.current){const t=y.current.getBoundingClientRect(),k=window.scrollY||document.documentElement.scrollTop,s=window.scrollX||document.documentElement.scrollLeft;let u=t.bottom+k+8,l=t.left+s;x.includes("left")?l=t.left+s:l=t.right+s-360,x.includes("bottom")&&(u=t.top+k-8),S({top:u,left:Math.max(8,l)})}},[h,x]),n.useEffect(()=>{const t=k=>{var u,l;const s=k.target;(u=B.current)!=null&&u.contains(s)||(l=s.closest)!=null&&l.call(s,"[data-bear-notification-center]")||N(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[N]);const L=n.useCallback(()=>{N(!h)},[h,N]);return e.jsxs("div",{ref:B,className:c.cn("Bear-NotificationCenter bear-relative bear-inline-block",O),"data-testid":E,children:[C?e.jsx("div",{onClick:L,children:C}):e.jsxs("button",{ref:y,type:"button",onClick:L,className:"Bear-NotificationCenter__trigger bear-relative bear-p-2 bear-rounded-lg bear-text-gray-500 dark:bear-text-zinc-400 hover:bear-text-gray-900 dark:hover:bear-text-white hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-800 bear-transition-colors",children:[M??e.jsx("svg",{className:"bear-w-6 bear-h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"})}),i>0&&e.jsx("span",{className:"Bear-NotificationCenter__badge bear-absolute bear-top-0 bear-right-0 bear-w-5 bear-h-5 bear-flex bear-items-center bear-justify-center bear-text-xs bear-font-medium bear-text-white bear-bg-pink-500 bear-rounded-full",children:i>99?"99+":i})]}),h&&typeof document<"u"&&q.createPortal(e.jsxs("div",{"data-bear-notification-center":!0,className:"Bear-NotificationCenter__dropdown bear-fixed bear-w-[360px] bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-lg bear-shadow-xl bear-overflow-hidden",style:{top:w.top,left:w.left,zIndex:m.NOTIFICATION_CENTER_Z_INDEX},children:[e.jsxs("div",{className:"Bear-NotificationCenter__header bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700",children:[e.jsxs("h3",{className:"Bear-NotificationCenter__title bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white",children:[o.title,i>0&&e.jsxs("span",{className:"bear-ml-2 bear-text-xs bear-font-normal bear-text-gray-500 dark:bear-text-zinc-400",children:["(",i," ",o.new.toLowerCase(),")"]})]}),e.jsxs("div",{className:"bear-flex bear-gap-2",children:[b&&i>0&&e.jsx("button",{type:"button",onClick:b,className:"Bear-NotificationCenter__mark-all bear-text-xs bear-text-pink-400 hover:bear-text-pink-300 bear-transition-colors",children:o.markAllRead}),p&&r.length>0&&e.jsx("button",{type:"button",onClick:p,className:"Bear-NotificationCenter__clear-all bear-text-xs bear-text-gray-500 dark:bear-text-zinc-400 hover:bear-text-gray-700 dark:hover:bear-text-zinc-300 bear-transition-colors",children:o.clearAll})]})]}),e.jsx("div",{className:"Bear-NotificationCenter__list bear-max-h-[400px] bear-overflow-y-auto",children:z.length===0?e.jsx("div",{className:"Bear-NotificationCenter__empty bear-py-8 bear-text-center bear-text-sm bear-text-gray-500 dark:bear-text-zinc-500",children:o.noNotifications}):z.map(t=>e.jsx(W,{notification:t,onRead:g,onDismiss:v,onClick:d,translations:o},t.id))}),!f&&r.length>a&&e.jsx("div",{className:"Bear-NotificationCenter__footer bear-border-t bear-border-gray-200 dark:bear-border-zinc-700",children:e.jsxs("button",{type:"button",onClick:()=>P(!0),className:"bear-w-full bear-py-2 bear-text-sm bear-text-pink-500 dark:bear-text-pink-400 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700/50 bear-transition-colors",children:[o.showMore," (",r.length-a," more)"]})})]}),document.body)]})};exports.NotificationCenter=D;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={title:"Notifications",noNotifications:"No notifications",markAllRead:"Mark all as read",clearAll:"Clear all",showMore:"Show more",justNow:"Just now",minutesAgo:"{count}m ago",hoursAgo:"{count}h ago",daysAgo:"{count}d ago",new:"New"},T=5,o=9999,I={info:"bear-text-blue-400 bear-bg-blue-500/20",success:"bear-text-green-400 bear-bg-green-500/20",warning:"bear-text-amber-400 bear-bg-amber-500/20",error:"bear-text-red-400 bear-bg-red-500/20"},N={MINUTE:60*1e3,HOUR:3600*1e3,DAY:1440*60*1e3};exports.NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS=e;exports.NOTIFICATION_CENTER_MAX_VISIBLE=T;exports.NOTIFICATION_CENTER_Z_INDEX=o;exports.NOTIFICATION_TYPE_COLORS=I;exports.TIME_THRESHOLDS=N;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NotificationCenterTranslations, NotificationType } from './NotificationCenter.types';
|
|
2
|
+
/**
|
|
3
|
+
* Default translations
|
|
4
|
+
*/
|
|
5
|
+
export declare const NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS: NotificationCenterTranslations;
|
|
6
|
+
/**
|
|
7
|
+
* Maximum visible notifications default
|
|
8
|
+
*/
|
|
9
|
+
export declare const NOTIFICATION_CENTER_MAX_VISIBLE = 5;
|
|
10
|
+
/**
|
|
11
|
+
* Dropdown z-index
|
|
12
|
+
*/
|
|
13
|
+
export declare const NOTIFICATION_CENTER_Z_INDEX = 9999;
|
|
14
|
+
/**
|
|
15
|
+
* Type icon colors
|
|
16
|
+
*/
|
|
17
|
+
export declare const NOTIFICATION_TYPE_COLORS: Record<NotificationType, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Time thresholds for relative time formatting (in ms)
|
|
20
|
+
*/
|
|
21
|
+
export declare const TIME_THRESHOLDS: {
|
|
22
|
+
readonly MINUTE: number;
|
|
23
|
+
readonly HOUR: number;
|
|
24
|
+
readonly DAY: number;
|
|
25
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
title: "Notifications",
|
|
3
|
+
noNotifications: "No notifications",
|
|
4
|
+
markAllRead: "Mark all as read",
|
|
5
|
+
clearAll: "Clear all",
|
|
6
|
+
showMore: "Show more",
|
|
7
|
+
justNow: "Just now",
|
|
8
|
+
minutesAgo: "{count}m ago",
|
|
9
|
+
hoursAgo: "{count}h ago",
|
|
10
|
+
daysAgo: "{count}d ago",
|
|
11
|
+
new: "New"
|
|
12
|
+
}, o = 5, t = 9999, a = {
|
|
13
|
+
info: "bear-text-blue-400 bear-bg-blue-500/20",
|
|
14
|
+
success: "bear-text-green-400 bear-bg-green-500/20",
|
|
15
|
+
warning: "bear-text-amber-400 bear-bg-amber-500/20",
|
|
16
|
+
error: "bear-text-red-400 bear-bg-red-500/20"
|
|
17
|
+
}, r = {
|
|
18
|
+
MINUTE: 60 * 1e3,
|
|
19
|
+
HOUR: 3600 * 1e3,
|
|
20
|
+
DAY: 1440 * 60 * 1e3
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
e as NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS,
|
|
24
|
+
o as NOTIFICATION_CENTER_MAX_VISIBLE,
|
|
25
|
+
t as NOTIFICATION_CENTER_Z_INDEX,
|
|
26
|
+
a as NOTIFICATION_TYPE_COLORS,
|
|
27
|
+
r as TIME_THRESHOLDS
|
|
28
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { NotificationCenterProps } from './NotificationCenter.types';
|
|
3
|
+
/**
|
|
4
|
+
* NotificationCenter - Notification management component
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <NotificationCenter
|
|
9
|
+
* notifications={notifications}
|
|
10
|
+
* onMarkAsRead={handleMarkAsRead}
|
|
11
|
+
* onDismiss={handleDismiss}
|
|
12
|
+
* />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const NotificationCenter: FC<NotificationCenterProps>;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { jsxs as n, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as y, useRef as O, useMemo as C, useEffect as E, useCallback as Y } from "react";
|
|
3
|
+
import { createPortal as H } from "react-dom";
|
|
4
|
+
import { cn as c } from "../../utils/cn.js";
|
|
5
|
+
import { NOTIFICATION_CENTER_DEFAULT_TRANSLATIONS as U, NOTIFICATION_CENTER_MAX_VISIBLE as Z, NOTIFICATION_CENTER_Z_INDEX as q, NOTIFICATION_TYPE_COLORS as j } from "./NotificationCenter.const.js";
|
|
6
|
+
import { formatRelativeTime as G } from "./NotificationCenter.utils.js";
|
|
7
|
+
const J = ({
|
|
8
|
+
notification: e,
|
|
9
|
+
onRead: d,
|
|
10
|
+
onDismiss: p,
|
|
11
|
+
onClick: i,
|
|
12
|
+
translations: k
|
|
13
|
+
}) => /* @__PURE__ */ n(
|
|
14
|
+
"div",
|
|
15
|
+
{
|
|
16
|
+
onClick: () => {
|
|
17
|
+
e.read || d == null || d(e.id), i == null || i(e);
|
|
18
|
+
},
|
|
19
|
+
className: c(
|
|
20
|
+
"Bear-NotificationCenter__item bear-flex bear-gap-3 bear-p-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700 last:bear-border-b-0 bear-cursor-pointer bear-transition-colors hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700/50",
|
|
21
|
+
!e.read && "bear-bg-gray-50 dark:bear-bg-zinc-800/50"
|
|
22
|
+
),
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__item-icon bear-shrink-0", children: e.avatar ? /* @__PURE__ */ r(
|
|
25
|
+
"img",
|
|
26
|
+
{
|
|
27
|
+
src: e.avatar,
|
|
28
|
+
alt: "",
|
|
29
|
+
className: "bear-w-10 bear-h-10 bear-rounded-full bear-object-cover"
|
|
30
|
+
}
|
|
31
|
+
) : e.icon ? /* @__PURE__ */ r("div", { className: c(
|
|
32
|
+
"bear-w-10 bear-h-10 bear-rounded-full bear-flex bear-items-center bear-justify-center",
|
|
33
|
+
j[e.type]
|
|
34
|
+
), children: e.icon }) : /* @__PURE__ */ n("div", { className: c(
|
|
35
|
+
"bear-w-10 bear-h-10 bear-rounded-full bear-flex bear-items-center bear-justify-center",
|
|
36
|
+
j[e.type]
|
|
37
|
+
), children: [
|
|
38
|
+
e.type === "success" && /* @__PURE__ */ r("svg", { className: "bear-w-5 bear-h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }),
|
|
39
|
+
e.type === "error" && /* @__PURE__ */ r("svg", { className: "bear-w-5 bear-h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }),
|
|
40
|
+
e.type === "warning" && /* @__PURE__ */ r("svg", { className: "bear-w-5 bear-h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
|
|
41
|
+
e.type === "info" && /* @__PURE__ */ r("svg", { className: "bear-w-5 bear-h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) })
|
|
42
|
+
] }) }),
|
|
43
|
+
/* @__PURE__ */ n("div", { className: "Bear-NotificationCenter__item-content bear-flex-1 bear-min-w-0", children: [
|
|
44
|
+
/* @__PURE__ */ n("div", { className: "bear-flex bear-items-start bear-justify-between bear-gap-2", children: [
|
|
45
|
+
/* @__PURE__ */ r("p", { className: c(
|
|
46
|
+
"Bear-NotificationCenter__item-title bear-text-sm bear-font-medium bear-truncate",
|
|
47
|
+
e.read ? "bear-text-gray-600 dark:bear-text-zinc-300" : "bear-text-gray-900 dark:bear-text-white"
|
|
48
|
+
), children: e.title }),
|
|
49
|
+
!e.read && /* @__PURE__ */ r("span", { className: "Bear-NotificationCenter__item-badge bear-w-2 bear-h-2 bear-rounded-full bear-bg-pink-500 bear-shrink-0 bear-mt-1.5" })
|
|
50
|
+
] }),
|
|
51
|
+
e.description && /* @__PURE__ */ r("p", { className: "Bear-NotificationCenter__item-description bear-text-xs bear-text-gray-500 dark:bear-text-zinc-400 bear-mt-0.5 bear-line-clamp-2", children: e.description }),
|
|
52
|
+
/* @__PURE__ */ r("p", { className: "Bear-NotificationCenter__item-time bear-text-xs bear-text-gray-400 dark:bear-text-zinc-500 bear-mt-1", children: G(e.timestamp, k) }),
|
|
53
|
+
e.actions && e.actions.length > 0 && /* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__item-actions bear-flex bear-gap-2 bear-mt-2", children: e.actions.map((a, _) => /* @__PURE__ */ r(
|
|
54
|
+
"button",
|
|
55
|
+
{
|
|
56
|
+
type: "button",
|
|
57
|
+
onClick: (h) => {
|
|
58
|
+
h.stopPropagation(), a.onClick();
|
|
59
|
+
},
|
|
60
|
+
className: c(
|
|
61
|
+
"bear-px-2 bear-py-1 bear-text-xs bear-rounded bear-transition-colors",
|
|
62
|
+
a.variant === "primary" && "bear-bg-pink-500 bear-text-white hover:bear-bg-pink-600",
|
|
63
|
+
a.variant === "secondary" && "bear-bg-gray-200 dark:bear-bg-zinc-600 bear-text-gray-900 dark:bear-text-white hover:bear-bg-gray-300 dark:hover:bear-bg-zinc-500",
|
|
64
|
+
a.variant === "danger" && "bear-bg-red-500 bear-text-white hover:bear-bg-red-600",
|
|
65
|
+
!a.variant && "bear-bg-gray-100 dark:bear-bg-zinc-700 bear-text-gray-700 dark:bear-text-zinc-300 hover:bear-bg-gray-200 dark:hover:bear-bg-zinc-600"
|
|
66
|
+
),
|
|
67
|
+
children: a.label
|
|
68
|
+
},
|
|
69
|
+
_
|
|
70
|
+
)) })
|
|
71
|
+
] }),
|
|
72
|
+
p && /* @__PURE__ */ r(
|
|
73
|
+
"button",
|
|
74
|
+
{
|
|
75
|
+
type: "button",
|
|
76
|
+
onClick: (a) => {
|
|
77
|
+
a.stopPropagation(), p(e.id);
|
|
78
|
+
},
|
|
79
|
+
className: "Bear-NotificationCenter__item-dismiss bear-p-1 bear-rounded bear-text-gray-500 dark:bear-text-zinc-500 hover:bear-text-gray-700 dark:hover:bear-text-zinc-300 hover:bear-bg-gray-200 dark:hover:bear-bg-zinc-700 bear-transition-colors bear-shrink-0",
|
|
80
|
+
children: /* @__PURE__ */ r("svg", { className: "bear-w-4 bear-h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
), ae = ({
|
|
86
|
+
notifications: e,
|
|
87
|
+
onNotificationClick: d,
|
|
88
|
+
onMarkAsRead: p,
|
|
89
|
+
onMarkAllAsRead: i,
|
|
90
|
+
onDismiss: k,
|
|
91
|
+
onClearAll: N,
|
|
92
|
+
maxVisible: a = Z,
|
|
93
|
+
groupByCategory: _ = !1,
|
|
94
|
+
position: h = "top-right",
|
|
95
|
+
trigger: w,
|
|
96
|
+
open: M,
|
|
97
|
+
onOpenChange: A,
|
|
98
|
+
className: R,
|
|
99
|
+
testId: P,
|
|
100
|
+
translations: B,
|
|
101
|
+
icon: S
|
|
102
|
+
}) => {
|
|
103
|
+
const [W, F] = y(!1), [z, X] = y({ top: 0, left: 0 }), [v, D] = y(!1), L = O(null), f = O(null), m = M ?? W, g = A ?? F, b = C(() => ({
|
|
104
|
+
...U,
|
|
105
|
+
...B
|
|
106
|
+
}), [B]), l = C(
|
|
107
|
+
() => e.filter((t) => !t.read).length,
|
|
108
|
+
[e]
|
|
109
|
+
), I = C(() => v ? e : e.slice(0, a), [e, a, v]);
|
|
110
|
+
E(() => {
|
|
111
|
+
if (m && f.current) {
|
|
112
|
+
const t = f.current.getBoundingClientRect(), x = window.scrollY || document.documentElement.scrollTop, o = window.scrollX || document.documentElement.scrollLeft;
|
|
113
|
+
let u = t.bottom + x + 8, s = t.left + o;
|
|
114
|
+
h.includes("left") ? s = t.left + o : s = t.right + o - 360, h.includes("bottom") && (u = t.top + x - 8), X({ top: u, left: Math.max(8, s) });
|
|
115
|
+
}
|
|
116
|
+
}, [m, h]), E(() => {
|
|
117
|
+
const t = (x) => {
|
|
118
|
+
var u, s;
|
|
119
|
+
const o = x.target;
|
|
120
|
+
(u = L.current) != null && u.contains(o) || (s = o.closest) != null && s.call(o, "[data-bear-notification-center]") || g(!1);
|
|
121
|
+
};
|
|
122
|
+
return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
|
|
123
|
+
}, [g]);
|
|
124
|
+
const T = Y(() => {
|
|
125
|
+
g(!m);
|
|
126
|
+
}, [m, g]);
|
|
127
|
+
return /* @__PURE__ */ n(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
ref: L,
|
|
131
|
+
className: c("Bear-NotificationCenter bear-relative bear-inline-block", R),
|
|
132
|
+
"data-testid": P,
|
|
133
|
+
children: [
|
|
134
|
+
w ? /* @__PURE__ */ r("div", { onClick: T, children: w }) : /* @__PURE__ */ n(
|
|
135
|
+
"button",
|
|
136
|
+
{
|
|
137
|
+
ref: f,
|
|
138
|
+
type: "button",
|
|
139
|
+
onClick: T,
|
|
140
|
+
className: "Bear-NotificationCenter__trigger bear-relative bear-p-2 bear-rounded-lg bear-text-gray-500 dark:bear-text-zinc-400 hover:bear-text-gray-900 dark:hover:bear-text-white hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-800 bear-transition-colors",
|
|
141
|
+
children: [
|
|
142
|
+
S ?? /* @__PURE__ */ r("svg", { className: "bear-w-6 bear-h-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" }) }),
|
|
143
|
+
l > 0 && /* @__PURE__ */ r("span", { className: "Bear-NotificationCenter__badge bear-absolute bear-top-0 bear-right-0 bear-w-5 bear-h-5 bear-flex bear-items-center bear-justify-center bear-text-xs bear-font-medium bear-text-white bear-bg-pink-500 bear-rounded-full", children: l > 99 ? "99+" : l })
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
m && typeof document < "u" && H(
|
|
148
|
+
/* @__PURE__ */ n(
|
|
149
|
+
"div",
|
|
150
|
+
{
|
|
151
|
+
"data-bear-notification-center": !0,
|
|
152
|
+
className: "Bear-NotificationCenter__dropdown bear-fixed bear-w-[360px] bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-lg bear-shadow-xl bear-overflow-hidden",
|
|
153
|
+
style: { top: z.top, left: z.left, zIndex: q },
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ n("div", { className: "Bear-NotificationCenter__header bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700", children: [
|
|
156
|
+
/* @__PURE__ */ n("h3", { className: "Bear-NotificationCenter__title bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white", children: [
|
|
157
|
+
b.title,
|
|
158
|
+
l > 0 && /* @__PURE__ */ n("span", { className: "bear-ml-2 bear-text-xs bear-font-normal bear-text-gray-500 dark:bear-text-zinc-400", children: [
|
|
159
|
+
"(",
|
|
160
|
+
l,
|
|
161
|
+
" ",
|
|
162
|
+
b.new.toLowerCase(),
|
|
163
|
+
")"
|
|
164
|
+
] })
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ n("div", { className: "bear-flex bear-gap-2", children: [
|
|
167
|
+
i && l > 0 && /* @__PURE__ */ r(
|
|
168
|
+
"button",
|
|
169
|
+
{
|
|
170
|
+
type: "button",
|
|
171
|
+
onClick: i,
|
|
172
|
+
className: "Bear-NotificationCenter__mark-all bear-text-xs bear-text-pink-400 hover:bear-text-pink-300 bear-transition-colors",
|
|
173
|
+
children: b.markAllRead
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
N && e.length > 0 && /* @__PURE__ */ r(
|
|
177
|
+
"button",
|
|
178
|
+
{
|
|
179
|
+
type: "button",
|
|
180
|
+
onClick: N,
|
|
181
|
+
className: "Bear-NotificationCenter__clear-all bear-text-xs bear-text-gray-500 dark:bear-text-zinc-400 hover:bear-text-gray-700 dark:hover:bear-text-zinc-300 bear-transition-colors",
|
|
182
|
+
children: b.clearAll
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
] })
|
|
186
|
+
] }),
|
|
187
|
+
/* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__list bear-max-h-[400px] bear-overflow-y-auto", children: I.length === 0 ? /* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__empty bear-py-8 bear-text-center bear-text-sm bear-text-gray-500 dark:bear-text-zinc-500", children: b.noNotifications }) : I.map((t) => /* @__PURE__ */ r(
|
|
188
|
+
J,
|
|
189
|
+
{
|
|
190
|
+
notification: t,
|
|
191
|
+
onRead: p,
|
|
192
|
+
onDismiss: k,
|
|
193
|
+
onClick: d,
|
|
194
|
+
translations: b
|
|
195
|
+
},
|
|
196
|
+
t.id
|
|
197
|
+
)) }),
|
|
198
|
+
!v && e.length > a && /* @__PURE__ */ r("div", { className: "Bear-NotificationCenter__footer bear-border-t bear-border-gray-200 dark:bear-border-zinc-700", children: /* @__PURE__ */ n(
|
|
199
|
+
"button",
|
|
200
|
+
{
|
|
201
|
+
type: "button",
|
|
202
|
+
onClick: () => D(!0),
|
|
203
|
+
className: "bear-w-full bear-py-2 bear-text-sm bear-text-pink-500 dark:bear-text-pink-400 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700/50 bear-transition-colors",
|
|
204
|
+
children: [
|
|
205
|
+
b.showMore,
|
|
206
|
+
" (",
|
|
207
|
+
e.length - a,
|
|
208
|
+
" more)"
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
) })
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
),
|
|
215
|
+
document.body
|
|
216
|
+
)
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
};
|
|
221
|
+
export {
|
|
222
|
+
ae as NotificationCenter
|
|
223
|
+
};
|