@forgedevstack/bear 1.2.5 → 1.2.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/README.md +20 -1
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.const.cjs +1 -0
- package/dist/components/AppBar/AppBar.const.d.ts +36 -1
- package/dist/components/AppBar/AppBar.const.js +39 -0
- package/dist/components/AppBar/AppBar.js +66 -42
- package/dist/components/AppBar/AppBar.types.d.ts +9 -3
- package/dist/components/Autocomplete/Autocomplete.cjs +1 -1
- package/dist/components/Autocomplete/Autocomplete.js +32 -32
- package/dist/components/Backdrop/Backdrop.cjs +1 -0
- package/dist/components/Backdrop/Backdrop.const.cjs +1 -0
- package/dist/components/Backdrop/Backdrop.const.d.ts +8 -0
- package/dist/components/Backdrop/Backdrop.const.js +11 -0
- package/dist/components/Backdrop/Backdrop.d.ts +3 -0
- package/dist/components/Backdrop/Backdrop.js +50 -0
- package/dist/components/Backdrop/Backdrop.types.d.ts +14 -0
- package/dist/components/Backdrop/index.d.ts +2 -0
- package/dist/components/BottomNavigation/BottomNavigation.cjs +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.const.cjs +1 -0
- package/dist/components/BottomNavigation/BottomNavigation.const.d.ts +8 -1
- package/dist/components/BottomNavigation/BottomNavigation.const.js +11 -0
- package/dist/components/BottomNavigation/BottomNavigation.js +64 -46
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +65 -64
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.js +48 -48
- package/dist/components/Chip/Chip.cjs +1 -1
- package/dist/components/Chip/Chip.const.cjs +1 -0
- package/dist/components/Chip/Chip.const.d.ts +49 -0
- package/dist/components/Chip/Chip.const.js +53 -0
- package/dist/components/Chip/Chip.js +46 -65
- package/dist/components/ChipGroup/ChipGroup.cjs +1 -0
- package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -0
- package/dist/components/ChipGroup/ChipGroup.const.d.ts +11 -0
- package/dist/components/ChipGroup/ChipGroup.const.js +14 -0
- package/dist/components/ChipGroup/ChipGroup.d.ts +3 -0
- package/dist/components/ChipGroup/ChipGroup.js +95 -0
- package/dist/components/ChipGroup/ChipGroup.types.d.ts +14 -0
- package/dist/components/ChipGroup/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +68 -64
- package/dist/components/EmptyState/EmptyState.cjs +1 -1
- package/dist/components/EmptyState/EmptyState.const.cjs +1 -0
- package/dist/components/EmptyState/EmptyState.const.d.ts +26 -1
- package/dist/components/EmptyState/EmptyState.const.js +29 -0
- package/dist/components/EmptyState/EmptyState.js +49 -31
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.const.cjs +1 -1
- package/dist/components/Input/Input.const.d.ts +10 -0
- package/dist/components/Input/Input.const.js +16 -6
- package/dist/components/Input/Input.js +108 -107
- package/dist/components/List/List.cjs +1 -1
- package/dist/components/List/List.js +133 -123
- package/dist/components/List/List.types.d.ts +2 -0
- package/dist/components/MessageList/MessageList.cjs +1 -1
- package/dist/components/MessageList/MessageList.const.cjs +1 -1
- package/dist/components/MessageList/MessageList.const.d.ts +6 -0
- package/dist/components/MessageList/MessageList.const.js +26 -20
- package/dist/components/MessageList/MessageList.d.ts +0 -16
- package/dist/components/MessageList/MessageList.js +133 -115
- package/dist/components/MessageList/MessageList.types.d.ts +4 -0
- package/dist/components/MessageList/MessageList.utils.cjs +1 -1
- package/dist/components/MessageList/MessageList.utils.d.ts +7 -0
- package/dist/components/MessageList/MessageList.utils.js +47 -28
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.const.cjs +1 -1
- package/dist/components/Modal/Modal.const.js +7 -8
- package/dist/components/Modal/Modal.js +60 -55
- package/dist/components/PageHeader/PageHeader.cjs +1 -0
- package/dist/components/PageHeader/PageHeader.const.cjs +1 -0
- package/dist/components/PageHeader/PageHeader.const.d.ts +6 -0
- package/dist/components/PageHeader/PageHeader.const.js +9 -0
- package/dist/components/PageHeader/PageHeader.d.ts +3 -0
- package/dist/components/PageHeader/PageHeader.js +57 -0
- package/dist/components/PageHeader/PageHeader.types.d.ts +10 -0
- package/dist/components/PageHeader/index.d.ts +2 -0
- package/dist/components/Progress/Progress.cjs +1 -1
- package/dist/components/Progress/Progress.const.cjs +1 -0
- package/dist/components/Progress/Progress.const.d.ts +16 -1
- package/dist/components/Progress/Progress.const.js +19 -0
- package/dist/components/Progress/Progress.d.ts +0 -10
- package/dist/components/Progress/Progress.js +81 -71
- package/dist/components/Progress/Progress.types.d.ts +2 -11
- package/dist/components/PropsPlayground/PropsPlayground.cjs +1 -1
- package/dist/components/PropsPlayground/PropsPlayground.js +40 -40
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.const.cjs +1 -0
- package/dist/components/Select/Select.const.d.ts +9 -0
- package/dist/components/Select/Select.const.js +13 -0
- package/dist/components/Select/Select.js +151 -66
- package/dist/components/Select/Select.types.d.ts +3 -1
- package/dist/components/Snackbar/Snackbar.cjs +1 -1
- package/dist/components/Snackbar/Snackbar.js +62 -60
- package/dist/components/Snackbar/Snackbar.types.d.ts +2 -0
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.js +89 -83
- package/dist/components/Tabs/Tabs.cjs +1 -1
- package/dist/components/Tabs/Tabs.const.cjs +1 -0
- package/dist/components/Tabs/Tabs.const.d.ts +2 -0
- package/dist/components/Tabs/Tabs.const.js +5 -0
- package/dist/components/Tabs/Tabs.js +40 -35
- package/dist/components/Tabs/Tabs.types.d.ts +1 -0
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.const.cjs +1 -0
- package/dist/components/Toast/Toast.const.d.ts +4 -0
- package/dist/components/Toast/Toast.const.js +9 -0
- package/dist/components/Toast/Toast.d.ts +0 -1
- package/dist/components/Toast/Toast.js +111 -101
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +285 -279
- package/dist/context/BearProvider.cjs +1 -1
- package/dist/context/BearProvider.d.ts +8 -0
- package/dist/context/BearProvider.js +149 -139
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +12 -10
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +45 -41
- package/dist/hooks/useBreakpoint/index.d.ts +4 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.cjs +1 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.const.cjs +1 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.const.d.ts +8 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.const.js +10 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.d.ts +2 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.js +26 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.types.d.ts +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +464 -443
- package/dist/styles.css +67 -23
- package/dist/utils/generateBearId.const.cjs +1 -1
- package/dist/utils/generateBearId.const.d.ts +4 -2
- package/dist/utils/generateBearId.const.js +6 -4
- package/dist/utils/generateBearId.utils.cjs +1 -1
- package/dist/utils/generateBearId.utils.js +33 -21
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.js +27 -18
- package/dist/utils/liveRegion.const.cjs +1 -0
- package/dist/utils/liveRegion.const.d.ts +5 -0
- package/dist/utils/liveRegion.const.js +17 -0
- package/dist/utils/liveRegion.utils.cjs +1 -0
- package/dist/utils/liveRegion.utils.d.ts +7 -0
- package/dist/utils/liveRegion.utils.js +10 -0
- package/dist/utils/useBearId.cjs +1 -1
- package/dist/utils/useBearId.js +5 -4
- package/package.json +1 -1
|
@@ -1,119 +1,132 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { Avatar as
|
|
4
|
-
import { Typography as
|
|
5
|
-
import { MESSAGE_LIST_DEFAULT_HEIGHT as
|
|
6
|
-
import { buildMessageListItems as
|
|
7
|
-
import { cn as
|
|
8
|
-
import { resolveBearId as
|
|
9
|
-
import { useBearId as
|
|
10
|
-
const
|
|
11
|
-
id:
|
|
12
|
-
testId:
|
|
13
|
-
messages:
|
|
14
|
-
currentUserId:
|
|
15
|
-
groupWindowMs:
|
|
16
|
-
showDaySeparators:
|
|
17
|
-
showAvatars:
|
|
18
|
-
showTimestamps:
|
|
19
|
-
autoScroll:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { jsxs as i, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as a, useState as M, useEffect as C, useLayoutEffect as St } from "react";
|
|
3
|
+
import { Avatar as ct } from "../Avatar/Avatar.js";
|
|
4
|
+
import { Typography as d } from "../Typography/Typography.js";
|
|
5
|
+
import { MESSAGE_LIST_DEFAULT_HEIGHT as w, MESSAGE_LIST_VIRTUALIZE_THRESHOLD as ot, MESSAGE_LIST_DEFAULT_TRANSLATIONS as _t, MESSAGE_LIST_EMPTY_CLASSES as it, MESSAGE_LIST_ROOT_CLASS as e, MESSAGE_LIST_SCROLLER_CLASSES as at, MESSAGE_LIST_NEW_MESSAGES_CLASSES as Et, MESSAGE_LIST_BASE_CLASSES as dt, MESSAGE_LIST_GROUP_WINDOW_MS as At, MESSAGE_LIST_OVERSCAN as ut, MESSAGE_LIST_DAY_LINE_CLASSES as P, MESSAGE_LIST_DAY_LABEL_CLASSES as Lt, MESSAGE_LIST_DAY_SEPARATOR_CLASSES as mt, MESSAGE_LIST_BOTTOM_THRESHOLD_PX as Tt, MESSAGE_LIST_AUTHOR_CLASSES as pt, MESSAGE_LIST_TIMESTAMP_CLASSES as U, MESSAGE_LIST_META_CLASSES as It, MESSAGE_LIST_BUBBLE_OWN_CLASSES as ht, MESSAGE_LIST_BUBBLE_CLASSES as ft, MESSAGE_LIST_GROUP_BODY_OWN_CLASSES as Mt, MESSAGE_LIST_GROUP_BODY_CLASSES as Gt, MESSAGE_LIST_GROUP_OWN_CLASSES as Ot, MESSAGE_LIST_GROUP_CLASSES as Nt } from "./MessageList.const.js";
|
|
6
|
+
import { buildMessageListItems as vt, getMessageListWindow as Rt, getDefaultDayLabel as Ht, getDefaultTimestamp as yt } from "./MessageList.utils.js";
|
|
7
|
+
import { cn as s } from "../../utils/cn.js";
|
|
8
|
+
import { resolveBearId as Bt } from "../../utils/generateBearId.utils.js";
|
|
9
|
+
import { useBearId as $t } from "../../utils/useBearId.js";
|
|
10
|
+
const Yt = ({
|
|
11
|
+
id: D,
|
|
12
|
+
testId: x,
|
|
13
|
+
messages: r,
|
|
14
|
+
currentUserId: g,
|
|
15
|
+
groupWindowMs: W = At,
|
|
16
|
+
showDaySeparators: Y = !0,
|
|
17
|
+
showAvatars: F = !0,
|
|
18
|
+
showTimestamps: G = !0,
|
|
19
|
+
autoScroll: O = !0,
|
|
20
|
+
virtualized: V,
|
|
21
|
+
overscan: j = ut,
|
|
22
|
+
height: o = w,
|
|
23
|
+
renderMessage: A,
|
|
24
|
+
emptyState: k,
|
|
25
|
+
formatDayLabel: u,
|
|
26
|
+
formatTimestamp: L,
|
|
27
|
+
translations: z,
|
|
28
|
+
onNewMessagesClick: m,
|
|
29
|
+
className: X
|
|
28
30
|
}) => {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
31
|
+
const Z = $t("MessageList"), q = Bt(D, Z), c = a(null), N = a(!0), T = a(null), p = a(null), I = a(null), [J, h] = M(!1), [K, v] = M(0), [Q, R] = M(
|
|
32
|
+
typeof o == "number" ? o : w
|
|
33
|
+
), f = { ..._t, ...z }, E = vt(r, g, W, Y), tt = (t) => (u == null ? void 0 : u(t)) ?? Ht(t, f), H = (t) => (L == null ? void 0 : L(t)) ?? yt(t), y = V ?? r.length >= ot, B = (t) => {
|
|
34
|
+
const n = c.current;
|
|
35
|
+
n && n.scrollTo({ top: n.scrollHeight, behavior: t ? "smooth" : "auto" });
|
|
36
|
+
}, et = () => {
|
|
37
|
+
const t = c.current;
|
|
38
|
+
if (!t) return;
|
|
39
|
+
v(t.scrollTop), R(t.clientHeight);
|
|
40
|
+
const S = t.scrollHeight - t.scrollTop - t.clientHeight <= Tt;
|
|
41
|
+
N.current = S, S && h(!1);
|
|
37
42
|
};
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
C(() => {
|
|
44
|
+
const t = c.current;
|
|
45
|
+
t && R(t.clientHeight);
|
|
46
|
+
}, [o]), C(() => {
|
|
47
|
+
const t = r.length > 0 ? r[0].id : null, n = r.length > 0 ? r[r.length - 1].id : null, S = T.current === null, lt = t !== null && p.current !== null && t !== p.current, rt = n !== null && n !== T.current;
|
|
48
|
+
if (lt && c.current && (I.current = c.current.scrollHeight), p.current = t, T.current = n, !!rt) {
|
|
49
|
+
if (S || O && N.current) {
|
|
50
|
+
B(!S);
|
|
43
51
|
return;
|
|
44
52
|
}
|
|
45
|
-
|
|
53
|
+
h(!0);
|
|
46
54
|
}
|
|
47
|
-
}, [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
}, [r, O]), St(() => {
|
|
56
|
+
const t = c.current, n = I.current;
|
|
57
|
+
if (!t || n === null) return;
|
|
58
|
+
const S = t.scrollHeight - n;
|
|
59
|
+
S > 0 && (t.scrollTop += S, v(t.scrollTop)), I.current = null;
|
|
60
|
+
}, [r]);
|
|
61
|
+
const nt = () => {
|
|
62
|
+
B(!0), h(!1), m == null || m();
|
|
63
|
+
}, st = (t) => /* @__PURE__ */ i(
|
|
51
64
|
"div",
|
|
52
65
|
{
|
|
53
|
-
className:
|
|
54
|
-
`${
|
|
55
|
-
|
|
56
|
-
|
|
66
|
+
className: s(
|
|
67
|
+
`${e}__group`,
|
|
68
|
+
Nt,
|
|
69
|
+
t.isOwn && Ot
|
|
57
70
|
),
|
|
58
71
|
children: [
|
|
59
|
-
|
|
60
|
-
|
|
72
|
+
F && !t.isOwn && /* @__PURE__ */ l(
|
|
73
|
+
ct,
|
|
61
74
|
{
|
|
62
|
-
src:
|
|
63
|
-
initials:
|
|
75
|
+
src: t.author.avatar,
|
|
76
|
+
initials: t.author.name[0],
|
|
64
77
|
size: "sm",
|
|
65
78
|
className: "bear-flex-shrink-0"
|
|
66
79
|
}
|
|
67
80
|
),
|
|
68
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ i(
|
|
69
82
|
"div",
|
|
70
83
|
{
|
|
71
|
-
className:
|
|
72
|
-
`${
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
className: s(
|
|
85
|
+
`${e}__group-body`,
|
|
86
|
+
Gt,
|
|
87
|
+
t.isOwn && Mt
|
|
75
88
|
),
|
|
76
89
|
children: [
|
|
77
|
-
!
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
|
|
90
|
+
!t.isOwn && /* @__PURE__ */ i("div", { className: s(`${e}__meta`, It), children: [
|
|
91
|
+
/* @__PURE__ */ l(
|
|
92
|
+
d,
|
|
80
93
|
{
|
|
81
94
|
variant: "caption",
|
|
82
95
|
component: "span",
|
|
83
|
-
className:
|
|
84
|
-
children:
|
|
96
|
+
className: s(`${e}__author`, pt),
|
|
97
|
+
children: t.author.name
|
|
85
98
|
}
|
|
86
99
|
),
|
|
87
|
-
|
|
88
|
-
|
|
100
|
+
G && /* @__PURE__ */ l(
|
|
101
|
+
d,
|
|
89
102
|
{
|
|
90
103
|
variant: "caption",
|
|
91
104
|
component: "span",
|
|
92
|
-
className:
|
|
93
|
-
children:
|
|
105
|
+
className: s(`${e}__timestamp`, U),
|
|
106
|
+
children: H(t.messages[0].timestamp)
|
|
94
107
|
}
|
|
95
108
|
)
|
|
96
109
|
] }),
|
|
97
|
-
|
|
110
|
+
t.messages.map((n) => /* @__PURE__ */ l(
|
|
98
111
|
"div",
|
|
99
112
|
{
|
|
100
|
-
className:
|
|
101
|
-
`${
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
className: s(
|
|
114
|
+
`${e}__bubble`,
|
|
115
|
+
ft,
|
|
116
|
+
t.isOwn && `${e}__bubble--own`,
|
|
117
|
+
t.isOwn && ht
|
|
105
118
|
),
|
|
106
|
-
children: (
|
|
119
|
+
children: (A == null ? void 0 : A(n)) ?? n.content
|
|
107
120
|
},
|
|
108
|
-
|
|
121
|
+
n.id
|
|
109
122
|
)),
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
t.isOwn && G && /* @__PURE__ */ l(
|
|
124
|
+
d,
|
|
112
125
|
{
|
|
113
126
|
variant: "caption",
|
|
114
127
|
component: "span",
|
|
115
|
-
className:
|
|
116
|
-
children:
|
|
128
|
+
className: s(`${e}__timestamp`, U),
|
|
129
|
+
children: H(t.messages[t.messages.length - 1].timestamp)
|
|
117
130
|
}
|
|
118
131
|
)
|
|
119
132
|
]
|
|
@@ -121,56 +134,61 @@ const OS = ({
|
|
|
121
134
|
)
|
|
122
135
|
]
|
|
123
136
|
},
|
|
124
|
-
|
|
125
|
-
)
|
|
126
|
-
|
|
137
|
+
t.key
|
|
138
|
+
), $ = (t) => t.kind === "day" ? /* @__PURE__ */ i(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
className: s(
|
|
142
|
+
`${e}__day-separator`,
|
|
143
|
+
mt
|
|
144
|
+
),
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ l("span", { className: s(`${e}__day-line`, P) }),
|
|
147
|
+
/* @__PURE__ */ l("span", { className: s(`${e}__day-label`, Lt), children: tt(t.date) }),
|
|
148
|
+
/* @__PURE__ */ l("span", { className: s(`${e}__day-line`, P) })
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
t.key
|
|
152
|
+
) : st(t), _ = y ? Rt(E, K, Q, j) : null, b = _ === null ? E : E.slice(_.startIndex, _.endIndex + 1);
|
|
153
|
+
return /* @__PURE__ */ i(
|
|
127
154
|
"div",
|
|
128
155
|
{
|
|
129
|
-
id:
|
|
130
|
-
"data-testid":
|
|
131
|
-
className: e
|
|
132
|
-
style: { height: typeof
|
|
156
|
+
id: q,
|
|
157
|
+
"data-testid": x,
|
|
158
|
+
className: s(e, dt, X),
|
|
159
|
+
style: { height: typeof o == "number" ? `${o}px` : o },
|
|
133
160
|
children: [
|
|
134
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ i(
|
|
135
162
|
"div",
|
|
136
163
|
{
|
|
137
|
-
ref:
|
|
138
|
-
onScroll:
|
|
139
|
-
className:
|
|
164
|
+
ref: c,
|
|
165
|
+
onScroll: et,
|
|
166
|
+
className: s(`${e}__scroller`, at),
|
|
140
167
|
role: "log",
|
|
141
168
|
"aria-live": "polite",
|
|
142
169
|
children: [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
children: [
|
|
153
|
-
/* @__PURE__ */ n("span", { className: e(`${t}__day-line`, N) }),
|
|
154
|
-
/* @__PURE__ */ n("span", { className: e(`${t}__day-label`, K), children: W(S.date) }),
|
|
155
|
-
/* @__PURE__ */ n("span", { className: e(`${t}__day-line`, N) })
|
|
156
|
-
]
|
|
157
|
-
},
|
|
158
|
-
S.key
|
|
159
|
-
) : F(S)
|
|
160
|
-
)
|
|
170
|
+
E.length === 0 && /* @__PURE__ */ l("div", { className: s(`${e}__empty`, it), children: k ?? /* @__PURE__ */ l(d, { variant: "body2", component: "span", children: f.emptyLabel }) }),
|
|
171
|
+
y && _ ? /* @__PURE__ */ l(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
className: `${e}__virtual`,
|
|
175
|
+
style: { height: _.totalHeight, position: "relative" },
|
|
176
|
+
children: /* @__PURE__ */ l("div", { style: { transform: `translateY(${_.offsetTop}px)` }, children: b.map((t) => $(t)) })
|
|
177
|
+
}
|
|
178
|
+
) : b.map((t) => $(t))
|
|
161
179
|
]
|
|
162
180
|
}
|
|
163
181
|
),
|
|
164
|
-
|
|
182
|
+
J && /* @__PURE__ */ l(
|
|
165
183
|
"button",
|
|
166
184
|
{
|
|
167
185
|
type: "button",
|
|
168
|
-
onClick:
|
|
169
|
-
className:
|
|
170
|
-
`${
|
|
171
|
-
|
|
186
|
+
onClick: nt,
|
|
187
|
+
className: s(
|
|
188
|
+
`${e}__new-messages`,
|
|
189
|
+
Et
|
|
172
190
|
),
|
|
173
|
-
children:
|
|
191
|
+
children: f.newMessages
|
|
174
192
|
}
|
|
175
193
|
)
|
|
176
194
|
]
|
|
@@ -178,5 +196,5 @@ const OS = ({
|
|
|
178
196
|
);
|
|
179
197
|
};
|
|
180
198
|
export {
|
|
181
|
-
|
|
199
|
+
Yt as MessageList
|
|
182
200
|
};
|
|
@@ -53,6 +53,10 @@ export interface MessageListProps {
|
|
|
53
53
|
showTimestamps?: boolean;
|
|
54
54
|
/** Auto-scroll to bottom on new messages when already at the bottom */
|
|
55
55
|
autoScroll?: boolean;
|
|
56
|
+
/** Enable windowed rendering for long conversations (auto when message count exceeds threshold) */
|
|
57
|
+
virtualized?: boolean;
|
|
58
|
+
/** Extra items rendered above/below the viewport when virtualized */
|
|
59
|
+
overscan?: number;
|
|
56
60
|
/** Height of the scrollable area */
|
|
57
61
|
height?: number | string;
|
|
58
62
|
/** Custom message content renderer */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./MessageList.const.cjs"),S=(e,i)=>e.getFullYear()===i.getFullYear()&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate(),h=e=>`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`,M=(e,i)=>{const o=new Date;if(S(e,o))return i.today;const r=new Date(o.getTime()-l.MESSAGE_LIST_MS_PER_DAY);return S(e,r)?i.yesterday:e.toLocaleDateString([],{year:"numeric",month:"long",day:"numeric"})},y=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),E=(e,i,o,r)=>{const t=[];let u=null;for(const s of e){const m=u===null||!S(u,s.timestamp);r&&m&&t.push({kind:"day",key:`day-${h(s.timestamp)}`,date:s.timestamp});const a=t[t.length-1],g=a!==void 0&&a.kind==="group"&&a.author.id===s.author.id&&s.timestamp.getTime()-a.messages[a.messages.length-1].timestamp.getTime()<=o;a!==void 0&&a.kind==="group"&&g?a.messages.push(s):t.push({kind:"group",key:`group-${s.id}`,author:s.author,isOwn:s.author.id===i,messages:[s]}),u=s.timestamp}return t},_=e=>e.kind==="day"?l.MESSAGE_LIST_DAY_ESTIMATE_PX+l.MESSAGE_LIST_ITEM_GAP_PX:l.MESSAGE_LIST_GROUP_BASE_ESTIMATE_PX+e.messages.length*l.MESSAGE_LIST_BUBBLE_ESTIMATE_PX+l.MESSAGE_LIST_ITEM_GAP_PX,T=(e,i,o,r)=>{const t=e.map(_),u=t.reduce((n,c)=>n+c,0);let s=0,m=0;for(let n=0;n<t.length;n+=1){if(s+t[n]>i){m=Math.max(0,n-r);break}s+=t[n]}let a=0;for(let n=0;n<m;n+=1)a+=t[n];let g=m,d=a;for(;g<t.length&&d<i+o;)d+=t[g],g+=1;return g=Math.min(t.length-1,g+r),{startIndex:m,endIndex:g,offsetTop:a,totalHeight:u}};exports.buildMessageListItems=E;exports.estimateMessageListItemHeight=_;exports.getDayKey=h;exports.getDefaultDayLabel=M;exports.getDefaultTimestamp=y;exports.getMessageListWindow=T;exports.isSameDay=S;
|
|
@@ -4,3 +4,10 @@ export declare const getDayKey: (date: Date) => string;
|
|
|
4
4
|
export declare const getDefaultDayLabel: (date: Date, translations: MessageListTranslations) => string;
|
|
5
5
|
export declare const getDefaultTimestamp: (date: Date) => string;
|
|
6
6
|
export declare const buildMessageListItems: (messages: MessageListMessage[], currentUserId: string | undefined, groupWindowMs: number, showDaySeparators: boolean) => MessageListItem[];
|
|
7
|
+
export declare const estimateMessageListItemHeight: (item: MessageListItem) => number;
|
|
8
|
+
export declare const getMessageListWindow: (items: MessageListItem[], scrollTop: number, viewportHeight: number, overscan: number) => {
|
|
9
|
+
startIndex: number;
|
|
10
|
+
endIndex: number;
|
|
11
|
+
offsetTop: number;
|
|
12
|
+
totalHeight: number;
|
|
13
|
+
};
|
|
@@ -1,35 +1,54 @@
|
|
|
1
|
-
import { MESSAGE_LIST_MS_PER_DAY as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
if (
|
|
5
|
-
return
|
|
6
|
-
const
|
|
7
|
-
return
|
|
8
|
-
},
|
|
9
|
-
const
|
|
10
|
-
let
|
|
11
|
-
for (const
|
|
12
|
-
const m =
|
|
13
|
-
|
|
1
|
+
import { MESSAGE_LIST_DAY_ESTIMATE_PX as c, MESSAGE_LIST_ITEM_GAP_PX as d, MESSAGE_LIST_GROUP_BASE_ESTIMATE_PX as _, MESSAGE_LIST_BUBBLE_ESTIMATE_PX as E, MESSAGE_LIST_MS_PER_DAY as p } from "./MessageList.const.js";
|
|
2
|
+
const u = (e, a) => e.getFullYear() === a.getFullYear() && e.getMonth() === a.getMonth() && e.getDate() === a.getDate(), M = (e) => `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, T = (e, a) => {
|
|
3
|
+
const g = /* @__PURE__ */ new Date();
|
|
4
|
+
if (u(e, g))
|
|
5
|
+
return a.today;
|
|
6
|
+
const r = new Date(g.getTime() - p);
|
|
7
|
+
return u(e, r) ? a.yesterday : e.toLocaleDateString([], { year: "numeric", month: "long", day: "numeric" });
|
|
8
|
+
}, D = (e) => e.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), I = (e, a, g, r) => {
|
|
9
|
+
const t = [];
|
|
10
|
+
let l = null;
|
|
11
|
+
for (const s of e) {
|
|
12
|
+
const m = l === null || !u(l, s.timestamp);
|
|
13
|
+
r && m && t.push({
|
|
14
14
|
kind: "day",
|
|
15
|
-
key: `day-${
|
|
16
|
-
date:
|
|
15
|
+
key: `day-${M(s.timestamp)}`,
|
|
16
|
+
date: s.timestamp
|
|
17
17
|
});
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const n = t[t.length - 1], o = n !== void 0 && n.kind === "group" && n.author.id === s.author.id && s.timestamp.getTime() - n.messages[n.messages.length - 1].timestamp.getTime() <= g;
|
|
19
|
+
n !== void 0 && n.kind === "group" && o ? n.messages.push(s) : t.push({
|
|
20
20
|
kind: "group",
|
|
21
|
-
key: `group-${
|
|
22
|
-
author:
|
|
23
|
-
isOwn:
|
|
24
|
-
messages: [
|
|
25
|
-
}),
|
|
21
|
+
key: `group-${s.id}`,
|
|
22
|
+
author: s.author,
|
|
23
|
+
isOwn: s.author.id === a,
|
|
24
|
+
messages: [s]
|
|
25
|
+
}), l = s.timestamp;
|
|
26
26
|
}
|
|
27
|
-
return
|
|
27
|
+
return t;
|
|
28
|
+
}, f = (e) => e.kind === "day" ? c + d : _ + e.messages.length * E + d, A = (e, a, g, r) => {
|
|
29
|
+
const t = e.map(f), l = t.reduce((i, S) => i + S, 0);
|
|
30
|
+
let s = 0, m = 0;
|
|
31
|
+
for (let i = 0; i < t.length; i += 1) {
|
|
32
|
+
if (s + t[i] > a) {
|
|
33
|
+
m = Math.max(0, i - r);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
s += t[i];
|
|
37
|
+
}
|
|
38
|
+
let n = 0;
|
|
39
|
+
for (let i = 0; i < m; i += 1)
|
|
40
|
+
n += t[i];
|
|
41
|
+
let o = m, h = n;
|
|
42
|
+
for (; o < t.length && h < a + g; )
|
|
43
|
+
h += t[o], o += 1;
|
|
44
|
+
return o = Math.min(t.length - 1, o + r), { startIndex: m, endIndex: o, offsetTop: n, totalHeight: l };
|
|
28
45
|
};
|
|
29
46
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
I as buildMessageListItems,
|
|
48
|
+
f as estimateMessageListItemHeight,
|
|
49
|
+
M as getDayKey,
|
|
50
|
+
T as getDefaultDayLabel,
|
|
51
|
+
D as getDefaultTimestamp,
|
|
52
|
+
A as getMessageListWindow,
|
|
53
|
+
u as isSameDay
|
|
35
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("react"),N=require("react-dom"),o=require("../../utils/cn.cjs"),D=require("../../utils/generateBearId.utils.cjs"),I=require("../../utils/useBearId.cjs"),q=require("../Icon/icons/navigation.cjs"),g=require("../Backdrop/Backdrop.cjs"),a=require("./Modal.const.cjs"),w=b=>{const{isOpen:r,onClose:s,title:l,children:B,size:E="md",showCloseButton:n=!0,closeOnEscape:M=!0,disableEscapeKeyDown:C=!1,lockBodyScroll:L=!0,cancelPreventScroll:f=!1,closeOnBackdrop:k=!0,hideBackdrop:v=!1,keepMounted:d=!1,isCancelBackgroundClick:i,className:p,footer:u,testId:y,id:A}=b,O=I.useBearId("Modal"),c=D.resolveBearId(A,O),_=L&&!f,h=i!==void 0?i:k,S=M&&!C,t=m.useCallback(x=>{S&&x.key==="Escape"&&s()},[S,s]);if(m.useEffect(()=>{if(r)return document.addEventListener("keydown",t),_&&(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",t),document.body.style.overflow=""}},[r,t,_]),!r&&!d)return null;const j=e.jsxs("div",{className:"Bear-Modal bear-fixed bear-inset-0 bear-z-[11000] bear-flex bear-items-center bear-justify-center bear-p-4","data-testid":y,id:c,children:[!v&&e.jsx(g.Backdrop,{open:r,keepMounted:d,blur:!0,className:"Bear-Modal__backdrop",onClick:h?()=>s():void 0}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":l?`${c}-title`:void 0,className:o.cn("Bear-Modal__container",a.MODAL_CONTAINER_CLASSES,a.MODAL_SIZE_CLASSES[E],p),children:[(l||n)&&e.jsxs("div",{className:o.cn("Bear-Modal__header",a.MODAL_HEADER_CLASSES),children:[l&&e.jsx("h2",{id:`${c}-title`,className:o.cn("Bear-Modal__title",a.MODAL_TITLE_CLASSES),children:l}),n&&e.jsx("button",{onClick:s,className:o.cn("Bear-Modal__close",a.MODAL_CLOSE_CLASSES),"aria-label":"Close modal",children:e.jsx(q.CloseIcon,{className:"bear-w-5 bear-h-5"})})]}),e.jsx("div",{className:o.cn("Bear-Modal__body",a.MODAL_BODY_CLASSES),children:B}),u&&e.jsx("div",{className:o.cn("Bear-Modal__footer",a.MODAL_FOOTER_CLASSES),children:u})]})]});return N.createPortal(j,document.body)};exports.Modal=w;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r={sm:"bear-max-w-sm",md:"bear-max-w-md",lg:"bear-max-w-lg",xl:"bear-max-w-xl",full:"bear-max-w-full bear-mx-4"},e="bear-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r={sm:"bear-max-w-sm",md:"bear-max-w-md",lg:"bear-max-w-lg",xl:"bear-max-w-xl",full:"bear-max-w-full bear-mx-4"},e="bear-relative bear-w-full bear-max-h-[calc(100vh-2rem)] bear-overflow-y-auto bear-bg-white dark:bear-bg-zinc-900 bear-rounded-xl bear-shadow-2xl bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-transform bear-transition-all bear-animate-in bear-fade-in bear-zoom-in-95",a="bear-flex bear-items-center bear-justify-between bear-px-6 bear-py-4 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700",b="bear-text-lg bear-font-semibold bear-text-gray-900 dark:bear-text-white",t="bear-p-1 bear-rounded-lg bear-text-gray-400 dark:bear-text-zinc-500 hover:bear-text-gray-600 dark:hover:bear-text-white hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-transition-colors",S="bear-px-6 bear-py-4 bear-text-gray-600 dark:bear-text-gray-300",o="bear-flex bear-items-center bear-justify-end bear-gap-3 bear-px-6 bear-py-4 bear-border-t bear-border-gray-200 dark:bear-border-zinc-700";exports.MODAL_BODY_CLASSES=S;exports.MODAL_CLOSE_CLASSES=t;exports.MODAL_CONTAINER_CLASSES=e;exports.MODAL_FOOTER_CLASSES=o;exports.MODAL_HEADER_CLASSES=a;exports.MODAL_SIZE_CLASSES=r;exports.MODAL_TITLE_CLASSES=b;
|
|
@@ -4,14 +4,13 @@ const r = {
|
|
|
4
4
|
lg: "bear-max-w-lg",
|
|
5
5
|
xl: "bear-max-w-xl",
|
|
6
6
|
full: "bear-max-w-full bear-mx-4"
|
|
7
|
-
}, e = "bear-
|
|
7
|
+
}, e = "bear-relative bear-w-full bear-max-h-[calc(100vh-2rem)] bear-overflow-y-auto bear-bg-white dark:bear-bg-zinc-900 bear-rounded-xl bear-shadow-2xl bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-transform bear-transition-all bear-animate-in bear-fade-in bear-zoom-in-95", a = "bear-flex bear-items-center bear-justify-between bear-px-6 bear-py-4 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700", b = "bear-text-lg bear-font-semibold bear-text-gray-900 dark:bear-text-white", t = "bear-p-1 bear-rounded-lg bear-text-gray-400 dark:bear-text-zinc-500 hover:bear-text-gray-600 dark:hover:bear-text-white hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-transition-colors", o = "bear-px-6 bear-py-4 bear-text-gray-600 dark:bear-text-gray-300", n = "bear-flex bear-items-center bear-justify-end bear-gap-3 bear-px-6 bear-py-4 bear-border-t bear-border-gray-200 dark:bear-border-zinc-700";
|
|
8
8
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
b as MODAL_HEADER_CLASSES,
|
|
9
|
+
o as MODAL_BODY_CLASSES,
|
|
10
|
+
t as MODAL_CLOSE_CLASSES,
|
|
11
|
+
e as MODAL_CONTAINER_CLASSES,
|
|
12
|
+
n as MODAL_FOOTER_CLASSES,
|
|
13
|
+
a as MODAL_HEADER_CLASSES,
|
|
15
14
|
r as MODAL_SIZE_CLASSES,
|
|
16
|
-
|
|
15
|
+
b as MODAL_TITLE_CLASSES
|
|
17
16
|
};
|