@forgedevstack/bear 1.2.5 → 1.2.6
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 +15 -0
- 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 +65 -42
- package/dist/components/AppBar/AppBar.types.d.ts +9 -3
- 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 +7 -0
- package/dist/components/Backdrop/Backdrop.const.js +10 -0
- package/dist/components/Backdrop/Backdrop.d.ts +3 -0
- package/dist/components/Backdrop/Backdrop.js +43 -0
- package/dist/components/Backdrop/Backdrop.types.d.ts +12 -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/Chip/Chip.cjs +1 -1
- package/dist/components/Chip/Chip.const.cjs +1 -0
- package/dist/components/Chip/Chip.const.d.ts +39 -0
- package/dist/components/Chip/Chip.const.js +43 -0
- package/dist/components/Chip/Chip.js +44 -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 +8 -0
- package/dist/components/ChipGroup/ChipGroup.const.js +11 -0
- package/dist/components/ChipGroup/ChipGroup.d.ts +3 -0
- package/dist/components/ChipGroup/ChipGroup.js +41 -0
- package/dist/components/ChipGroup/ChipGroup.types.d.ts +9 -0
- package/dist/components/ChipGroup/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +57 -56
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +63 -62
- 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 +127 -115
- package/dist/components/MessageList/MessageList.types.d.ts +2 -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/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 +144 -68
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.js +89 -83
- 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 +17 -0
- package/dist/components/Toast/Toast.d.ts +0 -1
- package/dist/components/Toast/Toast.js +90 -84
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +277 -273
- 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/index.cjs +1 -1
- package/dist/index.js +385 -379
- package/dist/styles.css +67 -19
- package/package.json +1 -1
|
@@ -1,119 +1,126 @@
|
|
|
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 o, jsx as S } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as u, useState as h, useEffect as b } from "react";
|
|
3
|
+
import { Avatar as et } from "../Avatar/Avatar.js";
|
|
4
|
+
import { Typography as E } from "../Typography/Typography.js";
|
|
5
|
+
import { MESSAGE_LIST_DEFAULT_HEIGHT as y, MESSAGE_LIST_VIRTUALIZE_THRESHOLD as st, MESSAGE_LIST_DEFAULT_TRANSLATIONS as St, MESSAGE_LIST_EMPTY_CLASSES as nt, MESSAGE_LIST_ROOT_CLASS as e, MESSAGE_LIST_SCROLLER_CLASSES as lt, MESSAGE_LIST_NEW_MESSAGES_CLASSES as _t, MESSAGE_LIST_BASE_CLASSES as rt, MESSAGE_LIST_GROUP_WINDOW_MS as ot, MESSAGE_LIST_OVERSCAN as at, MESSAGE_LIST_DAY_LINE_CLASSES as C, MESSAGE_LIST_DAY_LABEL_CLASSES as ct, MESSAGE_LIST_DAY_SEPARATOR_CLASSES as it, MESSAGE_LIST_BOTTOM_THRESHOLD_PX as Et, MESSAGE_LIST_AUTHOR_CLASSES as At, MESSAGE_LIST_TIMESTAMP_CLASSES as H, MESSAGE_LIST_META_CLASSES as dt, MESSAGE_LIST_BUBBLE_OWN_CLASSES as Lt, MESSAGE_LIST_BUBBLE_CLASSES as mt, MESSAGE_LIST_GROUP_BODY_OWN_CLASSES as Tt, MESSAGE_LIST_GROUP_BODY_CLASSES as It, MESSAGE_LIST_GROUP_OWN_CLASSES as pt, MESSAGE_LIST_GROUP_CLASSES as ut } from "./MessageList.const.js";
|
|
6
|
+
import { buildMessageListItems as ht, getMessageListWindow as Gt, getDefaultDayLabel as Mt, getDefaultTimestamp as Ot } from "./MessageList.utils.js";
|
|
7
|
+
import { cn as s } from "../../utils/cn.js";
|
|
8
|
+
import { resolveBearId as ft } from "../../utils/generateBearId.utils.js";
|
|
9
|
+
import { useBearId as Nt } from "../../utils/useBearId.js";
|
|
10
|
+
const Ut = ({
|
|
11
|
+
id: w,
|
|
12
|
+
testId: U,
|
|
13
|
+
messages: l,
|
|
14
|
+
currentUserId: D,
|
|
15
|
+
groupWindowMs: P = ot,
|
|
16
|
+
showDaySeparators: x = !0,
|
|
17
|
+
showAvatars: W = !0,
|
|
18
|
+
showTimestamps: G = !0,
|
|
19
|
+
autoScroll: M = !0,
|
|
20
|
+
virtualized: Y,
|
|
21
|
+
height: _ = y,
|
|
22
|
+
renderMessage: A,
|
|
23
|
+
emptyState: F,
|
|
24
|
+
formatDayLabel: d,
|
|
25
|
+
formatTimestamp: L,
|
|
26
|
+
translations: g,
|
|
27
|
+
onNewMessagesClick: m,
|
|
28
|
+
className: V
|
|
28
29
|
}) => {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
30
|
+
const j = Nt("MessageList"), k = ft(w, j), a = u(null), O = u(!0), T = u(null), [z, I] = h(!1), [X, Z] = h(0), [q, f] = h(
|
|
31
|
+
typeof _ == "number" ? _ : y
|
|
32
|
+
), p = { ...St, ...g }, c = ht(l, D, P, x), J = (t) => (d == null ? void 0 : d(t)) ?? Mt(t, p), N = (t) => (L == null ? void 0 : L(t)) ?? Ot(t), v = Y ?? l.length >= st, R = (t) => {
|
|
33
|
+
const n = a.current;
|
|
34
|
+
n && n.scrollTo({ top: n.scrollHeight, behavior: t ? "smooth" : "auto" });
|
|
35
|
+
}, K = () => {
|
|
36
|
+
const t = a.current;
|
|
37
|
+
if (!t) return;
|
|
38
|
+
Z(t.scrollTop), f(t.clientHeight);
|
|
39
|
+
const i = t.scrollHeight - t.scrollTop - t.clientHeight <= Et;
|
|
40
|
+
O.current = i, i && I(!1);
|
|
37
41
|
};
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
b(() => {
|
|
43
|
+
const t = a.current;
|
|
44
|
+
t && f(t.clientHeight);
|
|
45
|
+
}, [_]), b(() => {
|
|
46
|
+
const t = l.length > 0 ? l[l.length - 1].id : null, n = T.current === null, i = t !== null && t !== T.current;
|
|
47
|
+
if (T.current = t, !!i) {
|
|
48
|
+
if (n || M && O.current) {
|
|
49
|
+
R(!n);
|
|
43
50
|
return;
|
|
44
51
|
}
|
|
45
|
-
|
|
52
|
+
I(!0);
|
|
46
53
|
}
|
|
47
|
-
}, [
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
},
|
|
54
|
+
}, [l, M]);
|
|
55
|
+
const Q = () => {
|
|
56
|
+
R(!0), I(!1), m == null || m();
|
|
57
|
+
}, tt = (t) => /* @__PURE__ */ o(
|
|
51
58
|
"div",
|
|
52
59
|
{
|
|
53
|
-
className:
|
|
54
|
-
`${
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
className: s(
|
|
61
|
+
`${e}__group`,
|
|
62
|
+
ut,
|
|
63
|
+
t.isOwn && pt
|
|
57
64
|
),
|
|
58
65
|
children: [
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
W && !t.isOwn && /* @__PURE__ */ S(
|
|
67
|
+
et,
|
|
61
68
|
{
|
|
62
|
-
src:
|
|
63
|
-
initials:
|
|
69
|
+
src: t.author.avatar,
|
|
70
|
+
initials: t.author.name[0],
|
|
64
71
|
size: "sm",
|
|
65
72
|
className: "bear-flex-shrink-0"
|
|
66
73
|
}
|
|
67
74
|
),
|
|
68
|
-
/* @__PURE__ */
|
|
75
|
+
/* @__PURE__ */ o(
|
|
69
76
|
"div",
|
|
70
77
|
{
|
|
71
|
-
className:
|
|
72
|
-
`${
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
className: s(
|
|
79
|
+
`${e}__group-body`,
|
|
80
|
+
It,
|
|
81
|
+
t.isOwn && Tt
|
|
75
82
|
),
|
|
76
83
|
children: [
|
|
77
|
-
!
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
|
|
84
|
+
!t.isOwn && /* @__PURE__ */ o("div", { className: s(`${e}__meta`, dt), children: [
|
|
85
|
+
/* @__PURE__ */ S(
|
|
86
|
+
E,
|
|
80
87
|
{
|
|
81
88
|
variant: "caption",
|
|
82
89
|
component: "span",
|
|
83
|
-
className:
|
|
84
|
-
children:
|
|
90
|
+
className: s(`${e}__author`, At),
|
|
91
|
+
children: t.author.name
|
|
85
92
|
}
|
|
86
93
|
),
|
|
87
|
-
|
|
88
|
-
|
|
94
|
+
G && /* @__PURE__ */ S(
|
|
95
|
+
E,
|
|
89
96
|
{
|
|
90
97
|
variant: "caption",
|
|
91
98
|
component: "span",
|
|
92
|
-
className:
|
|
93
|
-
children:
|
|
99
|
+
className: s(`${e}__timestamp`, H),
|
|
100
|
+
children: N(t.messages[0].timestamp)
|
|
94
101
|
}
|
|
95
102
|
)
|
|
96
103
|
] }),
|
|
97
|
-
|
|
104
|
+
t.messages.map((n) => /* @__PURE__ */ S(
|
|
98
105
|
"div",
|
|
99
106
|
{
|
|
100
|
-
className:
|
|
101
|
-
`${
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
className: s(
|
|
108
|
+
`${e}__bubble`,
|
|
109
|
+
mt,
|
|
110
|
+
t.isOwn && `${e}__bubble--own`,
|
|
111
|
+
t.isOwn && Lt
|
|
105
112
|
),
|
|
106
|
-
children: (
|
|
113
|
+
children: (A == null ? void 0 : A(n)) ?? n.content
|
|
107
114
|
},
|
|
108
|
-
|
|
115
|
+
n.id
|
|
109
116
|
)),
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
t.isOwn && G && /* @__PURE__ */ S(
|
|
118
|
+
E,
|
|
112
119
|
{
|
|
113
120
|
variant: "caption",
|
|
114
121
|
component: "span",
|
|
115
|
-
className:
|
|
116
|
-
children:
|
|
122
|
+
className: s(`${e}__timestamp`, H),
|
|
123
|
+
children: N(t.messages[t.messages.length - 1].timestamp)
|
|
117
124
|
}
|
|
118
125
|
)
|
|
119
126
|
]
|
|
@@ -121,56 +128,61 @@ const OS = ({
|
|
|
121
128
|
)
|
|
122
129
|
]
|
|
123
130
|
},
|
|
124
|
-
|
|
125
|
-
)
|
|
126
|
-
|
|
131
|
+
t.key
|
|
132
|
+
), B = (t) => t.kind === "day" ? /* @__PURE__ */ o(
|
|
133
|
+
"div",
|
|
134
|
+
{
|
|
135
|
+
className: s(
|
|
136
|
+
`${e}__day-separator`,
|
|
137
|
+
it
|
|
138
|
+
),
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ S("span", { className: s(`${e}__day-line`, C) }),
|
|
141
|
+
/* @__PURE__ */ S("span", { className: s(`${e}__day-label`, ct), children: J(t.date) }),
|
|
142
|
+
/* @__PURE__ */ S("span", { className: s(`${e}__day-line`, C) })
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
t.key
|
|
146
|
+
) : tt(t), r = v ? Gt(c, X, q, at) : null, $ = r === null ? c : c.slice(r.startIndex, r.endIndex + 1);
|
|
147
|
+
return /* @__PURE__ */ o(
|
|
127
148
|
"div",
|
|
128
149
|
{
|
|
129
|
-
id:
|
|
130
|
-
"data-testid":
|
|
131
|
-
className: e
|
|
132
|
-
style: { height: typeof
|
|
150
|
+
id: k,
|
|
151
|
+
"data-testid": U,
|
|
152
|
+
className: s(e, rt, V),
|
|
153
|
+
style: { height: typeof _ == "number" ? `${_}px` : _ },
|
|
133
154
|
children: [
|
|
134
|
-
/* @__PURE__ */
|
|
155
|
+
/* @__PURE__ */ o(
|
|
135
156
|
"div",
|
|
136
157
|
{
|
|
137
|
-
ref:
|
|
138
|
-
onScroll:
|
|
139
|
-
className:
|
|
158
|
+
ref: a,
|
|
159
|
+
onScroll: K,
|
|
160
|
+
className: s(`${e}__scroller`, lt),
|
|
140
161
|
role: "log",
|
|
141
162
|
"aria-live": "polite",
|
|
142
163
|
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
|
-
)
|
|
164
|
+
c.length === 0 && /* @__PURE__ */ S("div", { className: s(`${e}__empty`, nt), children: F ?? /* @__PURE__ */ S(E, { variant: "body2", component: "span", children: p.emptyLabel }) }),
|
|
165
|
+
v && r ? /* @__PURE__ */ S(
|
|
166
|
+
"div",
|
|
167
|
+
{
|
|
168
|
+
className: `${e}__virtual`,
|
|
169
|
+
style: { height: r.totalHeight, position: "relative" },
|
|
170
|
+
children: /* @__PURE__ */ S("div", { style: { transform: `translateY(${r.offsetTop}px)` }, children: $.map((t) => B(t)) })
|
|
171
|
+
}
|
|
172
|
+
) : $.map((t) => B(t))
|
|
161
173
|
]
|
|
162
174
|
}
|
|
163
175
|
),
|
|
164
|
-
|
|
176
|
+
z && /* @__PURE__ */ S(
|
|
165
177
|
"button",
|
|
166
178
|
{
|
|
167
179
|
type: "button",
|
|
168
|
-
onClick:
|
|
169
|
-
className:
|
|
170
|
-
`${
|
|
171
|
-
|
|
180
|
+
onClick: Q,
|
|
181
|
+
className: s(
|
|
182
|
+
`${e}__new-messages`,
|
|
183
|
+
_t
|
|
172
184
|
),
|
|
173
|
-
children:
|
|
185
|
+
children: p.newMessages
|
|
174
186
|
}
|
|
175
187
|
)
|
|
176
188
|
]
|
|
@@ -178,5 +190,5 @@ const OS = ({
|
|
|
178
190
|
);
|
|
179
191
|
};
|
|
180
192
|
export {
|
|
181
|
-
|
|
193
|
+
Ut as MessageList
|
|
182
194
|
};
|
|
@@ -53,6 +53,8 @@ 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;
|
|
56
58
|
/** Height of the scrollable area */
|
|
57
59
|
height?: number | string;
|
|
58
60
|
/** 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
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),e=require("./Progress.const.cjs"),s=require("../../utils/cn.cjs");require("react");const E=require("../../utils/generateBearId.utils.cjs"),P=require("../../utils/useBearId.cjs"),v=m=>{const{id:_,value:l,max:n=100,bufferValue:d,size:b="md",color:R="default",showLabel:o=!1,label:u=e.PROGRESS_DEFAULT_LABEL,labelPosition:S="outside",striped:i=!1,animated:g=!1,indeterminate:r=!1,className:x,testId:f}=m,O=P.useBearId("Progress"),h=E.resolveBearId(_,O),t=Math.min(100,Math.max(0,l/n*100)),c=d==null?null:Math.min(100,Math.max(t,Math.max(0,d/n*100)));return a.jsxs("div",{id:h,className:s.cn(e.PROGRESS_ROOT_CLASS,"bear-w-full",x),"data-testid":f,children:[o&&S==="outside"&&a.jsxs("div",{className:`${e.PROGRESS_ROOT_CLASS}__label-row bear-flex bear-justify-between bear-mb-1`,children:[a.jsx("span",{className:"bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200",children:u}),a.jsxs("span",{className:"bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200",children:[Math.round(t),"%"]})]}),a.jsxs("div",{className:s.cn(`${e.PROGRESS_ROOT_CLASS}__track`,e.PROGRESS_TRACK_CLASSES,e.PROGRESS_SIZE_CLASSES[b]),children:[c!=null&&!r&&a.jsx("div",{className:s.cn(`${e.PROGRESS_ROOT_CLASS}__buffer`,"bear-absolute bear-inset-y-0 bear-left-0 bear-rounded-full",e.PROGRESS_BUFFER_CLASSES),style:{width:`${c}%`}}),a.jsx("div",{className:s.cn(`${e.PROGRESS_ROOT_CLASS}__bar`,"bear-relative bear-h-full bear-rounded-full bear-transition-all bear-duration-300 bear-ease-out","bear-flex bear-items-center bear-justify-center",e.PROGRESS_COLOR_CLASSES[R],i&&"bear-bg-stripes",g&&"bear-animate-stripes",r&&"bear-animate-indeterminate"),style:{width:r?"50%":`${t}%`,backgroundSize:i?"1rem 1rem":void 0,backgroundImage:i?"linear-gradient(45deg, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent)":void 0},role:"progressbar","aria-valuenow":r?void 0:l,"aria-valuemin":0,"aria-valuemax":n,"aria-label":u,children:o&&S==="inside"&&b==="lg"&&!r&&a.jsxs("span",{className:"bear-text-xs bear-font-medium bear-text-white",children:[Math.round(t),"%"]})})]})]})};exports.Progress=v;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S="Bear-Progress",e={sm:"bear-h-1.5",md:"bear-h-2.5",lg:"bear-h-4"},r={default:"bear-bg-bear-500",success:"bear-bg-green-500",warning:"bear-bg-amber-500",danger:"bear-bg-red-500",info:"bear-bg-blue-500"},b="bear-bg-bear-500/30 dark:bear-bg-bear-400/25",R="bear-w-full bear-bg-gray-200 dark:bear-bg-gray-700 bear-rounded-full bear-overflow-hidden bear-relative",a="Progress";exports.PROGRESS_BUFFER_CLASSES=b;exports.PROGRESS_COLOR_CLASSES=r;exports.PROGRESS_DEFAULT_LABEL=a;exports.PROGRESS_ROOT_CLASS=S;exports.PROGRESS_SIZE_CLASSES=e;exports.PROGRESS_TRACK_CLASSES=R;
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const PROGRESS_ROOT_CLASS = "Bear-Progress";
|
|
2
|
+
export declare const PROGRESS_SIZE_CLASSES: {
|
|
3
|
+
readonly sm: "bear-h-1.5";
|
|
4
|
+
readonly md: "bear-h-2.5";
|
|
5
|
+
readonly lg: "bear-h-4";
|
|
6
|
+
};
|
|
7
|
+
export declare const PROGRESS_COLOR_CLASSES: {
|
|
8
|
+
readonly default: "bear-bg-bear-500";
|
|
9
|
+
readonly success: "bear-bg-green-500";
|
|
10
|
+
readonly warning: "bear-bg-amber-500";
|
|
11
|
+
readonly danger: "bear-bg-red-500";
|
|
12
|
+
readonly info: "bear-bg-blue-500";
|
|
13
|
+
};
|
|
14
|
+
export declare const PROGRESS_BUFFER_CLASSES = "bear-bg-bear-500/30 dark:bear-bg-bear-400/25";
|
|
15
|
+
export declare const PROGRESS_TRACK_CLASSES = "bear-w-full bear-bg-gray-200 dark:bear-bg-gray-700 bear-rounded-full bear-overflow-hidden bear-relative";
|
|
16
|
+
export declare const PROGRESS_DEFAULT_LABEL = "Progress";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const r = "Bear-Progress", e = {
|
|
2
|
+
sm: "bear-h-1.5",
|
|
3
|
+
md: "bear-h-2.5",
|
|
4
|
+
lg: "bear-h-4"
|
|
5
|
+
}, b = {
|
|
6
|
+
default: "bear-bg-bear-500",
|
|
7
|
+
success: "bear-bg-green-500",
|
|
8
|
+
warning: "bear-bg-amber-500",
|
|
9
|
+
danger: "bear-bg-red-500",
|
|
10
|
+
info: "bear-bg-blue-500"
|
|
11
|
+
}, a = "bear-bg-bear-500/30 dark:bear-bg-bear-400/25", S = "bear-w-full bear-bg-gray-200 dark:bear-bg-gray-700 bear-rounded-full bear-overflow-hidden bear-relative", g = "Progress";
|
|
12
|
+
export {
|
|
13
|
+
a as PROGRESS_BUFFER_CLASSES,
|
|
14
|
+
b as PROGRESS_COLOR_CLASSES,
|
|
15
|
+
g as PROGRESS_DEFAULT_LABEL,
|
|
16
|
+
r as PROGRESS_ROOT_CLASS,
|
|
17
|
+
e as PROGRESS_SIZE_CLASSES,
|
|
18
|
+
S as PROGRESS_TRACK_CLASSES
|
|
19
|
+
};
|
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { ProgressProps } from './Progress.types';
|
|
3
|
-
/**
|
|
4
|
-
* Progress - Progress bar with multiple variants
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```tsx
|
|
8
|
-
* <Progress value={75} showLabel />
|
|
9
|
-
* <Progress value={50} color="success" striped animated />
|
|
10
|
-
* <Progress indeterminate />
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
3
|
export declare const Progress: FC<ProgressProps>;
|