@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,195 +1,205 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { LIST_VARIANT_CLASSES as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as s, jsxs as y } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as w, forwardRef as v, useContext as A } from "react";
|
|
3
|
+
import { cn as i } from "../../utils/cn.js";
|
|
4
|
+
import { LIST_VARIANT_CLASSES as D, LIST_SIZE_CLASSES as E, LIST_PADDING_CLASSES as B, LIST_BASE_CLASSES as T } from "./List.const.js";
|
|
5
|
+
const L = w({}), P = () => A(L), K = v((a, e) => {
|
|
6
6
|
const {
|
|
7
|
-
variant:
|
|
8
|
-
size:
|
|
9
|
-
hoverable:
|
|
10
|
-
dense:
|
|
11
|
-
disablePadding:
|
|
12
|
-
className:
|
|
13
|
-
children:
|
|
14
|
-
testId:
|
|
15
|
-
...
|
|
16
|
-
} =
|
|
17
|
-
return /* @__PURE__ */
|
|
7
|
+
variant: t = "default",
|
|
8
|
+
size: r = "md",
|
|
9
|
+
hoverable: o = !1,
|
|
10
|
+
dense: n = !1,
|
|
11
|
+
disablePadding: b = !1,
|
|
12
|
+
className: l,
|
|
13
|
+
children: m,
|
|
14
|
+
testId: g,
|
|
15
|
+
...c
|
|
16
|
+
} = a;
|
|
17
|
+
return /* @__PURE__ */ s(L.Provider, { value: { dense: n, hoverable: o }, children: /* @__PURE__ */ s(
|
|
18
18
|
"ul",
|
|
19
19
|
{
|
|
20
20
|
ref: e,
|
|
21
21
|
role: "list",
|
|
22
|
-
className:
|
|
23
|
-
|
|
24
|
-
!
|
|
25
|
-
E[
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
className: i(
|
|
23
|
+
T,
|
|
24
|
+
!b && B,
|
|
25
|
+
E[r],
|
|
26
|
+
D[t],
|
|
27
|
+
l
|
|
28
28
|
),
|
|
29
|
-
"data-testid":
|
|
30
|
-
...
|
|
31
|
-
children:
|
|
29
|
+
"data-testid": g,
|
|
30
|
+
...c,
|
|
31
|
+
children: m
|
|
32
32
|
}
|
|
33
33
|
) });
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
const j =
|
|
37
|
-
primary:
|
|
35
|
+
K.displayName = "List";
|
|
36
|
+
const j = v(({
|
|
37
|
+
primary: a,
|
|
38
38
|
secondary: e,
|
|
39
|
-
leading:
|
|
40
|
-
trailing:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
leading: t,
|
|
40
|
+
trailing: r,
|
|
41
|
+
secondaryAction: o,
|
|
42
|
+
selected: n = !1,
|
|
43
|
+
disabled: b = !1,
|
|
44
|
+
clickable: l = !1,
|
|
45
|
+
divider: m = !1,
|
|
46
|
+
dense: g,
|
|
47
|
+
onClick: c,
|
|
48
|
+
className: h,
|
|
49
|
+
children: u,
|
|
50
|
+
testId: I,
|
|
50
51
|
...N
|
|
51
52
|
}, S) => {
|
|
52
|
-
const { dense:
|
|
53
|
-
return /* @__PURE__ */
|
|
53
|
+
const { dense: k, hoverable: _ } = P(), p = g ?? k, x = l || !!c, f = o ?? r;
|
|
54
|
+
return /* @__PURE__ */ y(
|
|
54
55
|
"li",
|
|
55
56
|
{
|
|
56
57
|
ref: S,
|
|
57
|
-
role:
|
|
58
|
-
tabIndex:
|
|
59
|
-
"aria-selected":
|
|
60
|
-
"aria-disabled":
|
|
61
|
-
onClick:
|
|
62
|
-
onKeyDown: (
|
|
63
|
-
!
|
|
58
|
+
role: x ? "button" : "listitem",
|
|
59
|
+
tabIndex: x && !b ? 0 : void 0,
|
|
60
|
+
"aria-selected": n,
|
|
61
|
+
"aria-disabled": b,
|
|
62
|
+
onClick: b ? void 0 : c,
|
|
63
|
+
onKeyDown: (d) => {
|
|
64
|
+
!b && (d.key === "Enter" || d.key === " ") && (d.preventDefault(), c == null || c());
|
|
64
65
|
},
|
|
65
|
-
className:
|
|
66
|
+
className: i(
|
|
67
|
+
"Bear-ListItem",
|
|
66
68
|
"bear-flex bear-items-center bear-gap-3",
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
p ? "bear-py-1 bear-px-3" : "bear-py-2 bear-px-4",
|
|
70
|
+
x && !b && "bear-cursor-pointer",
|
|
71
|
+
(_ || x) && !b && "hover:bear-bg-gray-100 dark:hover:bear-bg-gray-800",
|
|
72
|
+
n && "bear-bg-primary-50 dark:bear-bg-primary-900/20",
|
|
73
|
+
b && "bear-opacity-50 bear-cursor-not-allowed",
|
|
74
|
+
m && "bear-border-b bear-border-gray-200 dark:bear-border-gray-700",
|
|
75
|
+
h
|
|
74
76
|
),
|
|
75
|
-
"data-testid":
|
|
77
|
+
"data-testid": I,
|
|
76
78
|
...N,
|
|
77
79
|
children: [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
e && /* @__PURE__ */
|
|
80
|
+
t && /* @__PURE__ */ s("div", { className: "Bear-ListItem__leading bear-flex-shrink-0 bear-text-gray-500 dark:bear-text-gray-400", children: t }),
|
|
81
|
+
a || e ? /* @__PURE__ */ y("div", { className: "Bear-ListItem__content bear-flex-1 bear-min-w-0", children: [
|
|
82
|
+
a && /* @__PURE__ */ s("div", { className: "bear-text-gray-900 dark:bear-text-gray-100 bear-truncate", children: a }),
|
|
83
|
+
e && /* @__PURE__ */ s("div", { className: i(
|
|
82
84
|
"bear-text-gray-500 dark:bear-text-gray-400 bear-truncate",
|
|
83
|
-
|
|
85
|
+
p ? "bear-text-xs" : "bear-text-sm"
|
|
84
86
|
), children: e })
|
|
85
|
-
] }) : /* @__PURE__ */
|
|
86
|
-
|
|
87
|
+
] }) : /* @__PURE__ */ s("div", { className: "Bear-ListItem__content bear-flex-1 bear-min-w-0", children: u }),
|
|
88
|
+
f && /* @__PURE__ */ s(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
className: "Bear-ListItem__secondary-action bear-flex-shrink-0 bear-text-gray-500 dark:bear-text-gray-400",
|
|
92
|
+
onClick: (d) => d.stopPropagation(),
|
|
93
|
+
onKeyDown: (d) => d.stopPropagation(),
|
|
94
|
+
children: f
|
|
95
|
+
}
|
|
96
|
+
)
|
|
87
97
|
]
|
|
88
98
|
}
|
|
89
99
|
);
|
|
90
100
|
});
|
|
91
101
|
j.displayName = "ListItem";
|
|
92
|
-
const
|
|
93
|
-
sticky:
|
|
102
|
+
const V = ({
|
|
103
|
+
sticky: a = !1,
|
|
94
104
|
inset: e = !1,
|
|
95
|
-
className:
|
|
96
|
-
children:
|
|
97
|
-
testId:
|
|
98
|
-
...
|
|
99
|
-
}) => /* @__PURE__ */
|
|
105
|
+
className: t,
|
|
106
|
+
children: r,
|
|
107
|
+
testId: o,
|
|
108
|
+
...n
|
|
109
|
+
}) => /* @__PURE__ */ s(
|
|
100
110
|
"li",
|
|
101
111
|
{
|
|
102
112
|
role: "presentation",
|
|
103
|
-
className:
|
|
113
|
+
className: i(
|
|
104
114
|
"bear-py-2 bear-px-4 bear-text-xs bear-font-semibold bear-uppercase bear-tracking-wider",
|
|
105
115
|
"bear-text-gray-500 dark:bear-text-gray-400",
|
|
106
116
|
"bear-bg-gray-50 dark:bear-bg-gray-800/50",
|
|
107
|
-
|
|
117
|
+
a && "bear-sticky bear-top-0 bear-z-10",
|
|
108
118
|
e && "bear-pl-12",
|
|
109
|
-
|
|
119
|
+
t
|
|
110
120
|
),
|
|
111
|
-
"data-testid":
|
|
112
|
-
...
|
|
113
|
-
children:
|
|
121
|
+
"data-testid": o,
|
|
122
|
+
...n,
|
|
123
|
+
children: r
|
|
114
124
|
}
|
|
115
|
-
),
|
|
116
|
-
primary:
|
|
125
|
+
), Z = ({
|
|
126
|
+
primary: a,
|
|
117
127
|
secondary: e,
|
|
118
|
-
inset:
|
|
119
|
-
dense:
|
|
120
|
-
className:
|
|
121
|
-
...
|
|
122
|
-
}) => /* @__PURE__ */
|
|
128
|
+
inset: t = !1,
|
|
129
|
+
dense: r = !1,
|
|
130
|
+
className: o,
|
|
131
|
+
...n
|
|
132
|
+
}) => /* @__PURE__ */ y(
|
|
123
133
|
"div",
|
|
124
134
|
{
|
|
125
|
-
className:
|
|
135
|
+
className: i(
|
|
126
136
|
"bear-flex-1 bear-min-w-0",
|
|
127
|
-
|
|
128
|
-
|
|
137
|
+
t && "bear-pl-9",
|
|
138
|
+
o
|
|
129
139
|
),
|
|
130
|
-
...
|
|
140
|
+
...n,
|
|
131
141
|
children: [
|
|
132
|
-
|
|
133
|
-
e && /* @__PURE__ */
|
|
142
|
+
a && /* @__PURE__ */ s("div", { className: "bear-text-gray-900 dark:bear-text-gray-100", children: a }),
|
|
143
|
+
e && /* @__PURE__ */ s("div", { className: i(
|
|
134
144
|
"bear-text-gray-500 dark:bear-text-gray-400",
|
|
135
|
-
|
|
145
|
+
r ? "bear-text-xs" : "bear-text-sm"
|
|
136
146
|
), children: e })
|
|
137
147
|
]
|
|
138
148
|
}
|
|
139
|
-
),
|
|
140
|
-
align:
|
|
149
|
+
), q = ({
|
|
150
|
+
align: a = "center",
|
|
141
151
|
className: e,
|
|
142
|
-
children:
|
|
143
|
-
...
|
|
144
|
-
}) => /* @__PURE__ */
|
|
152
|
+
children: t,
|
|
153
|
+
...r
|
|
154
|
+
}) => /* @__PURE__ */ s(
|
|
145
155
|
"div",
|
|
146
156
|
{
|
|
147
|
-
className:
|
|
157
|
+
className: i(
|
|
148
158
|
"bear-flex-shrink-0 bear-min-w-[36px]",
|
|
149
159
|
"bear-text-gray-500 dark:bear-text-gray-400",
|
|
150
|
-
|
|
160
|
+
a === "top" && "bear-self-start bear-mt-1",
|
|
151
161
|
e
|
|
152
162
|
),
|
|
153
|
-
...
|
|
154
|
-
children:
|
|
163
|
+
...r,
|
|
164
|
+
children: t
|
|
155
165
|
}
|
|
156
|
-
),
|
|
157
|
-
selected:
|
|
166
|
+
), F = ({
|
|
167
|
+
selected: a = !1,
|
|
158
168
|
disabled: e = !1,
|
|
159
|
-
dense:
|
|
160
|
-
onClick:
|
|
161
|
-
className:
|
|
162
|
-
children:
|
|
163
|
-
...
|
|
164
|
-
}) => /* @__PURE__ */
|
|
169
|
+
dense: t = !1,
|
|
170
|
+
onClick: r,
|
|
171
|
+
className: o,
|
|
172
|
+
children: n,
|
|
173
|
+
...b
|
|
174
|
+
}) => /* @__PURE__ */ s(
|
|
165
175
|
"div",
|
|
166
176
|
{
|
|
167
177
|
role: "button",
|
|
168
178
|
tabIndex: e ? -1 : 0,
|
|
169
|
-
"aria-selected":
|
|
179
|
+
"aria-selected": a,
|
|
170
180
|
"aria-disabled": e,
|
|
171
|
-
onClick: e ? void 0 :
|
|
172
|
-
onKeyDown: (
|
|
173
|
-
!e && (
|
|
181
|
+
onClick: e ? void 0 : r,
|
|
182
|
+
onKeyDown: (l) => {
|
|
183
|
+
!e && (l.key === "Enter" || l.key === " ") && (l.preventDefault(), r == null || r());
|
|
174
184
|
},
|
|
175
|
-
className:
|
|
185
|
+
className: i(
|
|
176
186
|
"bear-flex bear-items-center bear-gap-3 bear-w-full bear-text-left",
|
|
177
|
-
|
|
187
|
+
t ? "bear-py-1 bear-px-3" : "bear-py-2 bear-px-4",
|
|
178
188
|
"bear-cursor-pointer bear-transition-colors",
|
|
179
189
|
"hover:bear-bg-gray-100 dark:hover:bear-bg-gray-800",
|
|
180
|
-
|
|
190
|
+
a && "bear-bg-primary-50 dark:bear-bg-primary-900/20",
|
|
181
191
|
e && "bear-opacity-50 bear-cursor-not-allowed bear-pointer-events-none",
|
|
182
|
-
|
|
192
|
+
o
|
|
183
193
|
),
|
|
184
|
-
...
|
|
185
|
-
children:
|
|
194
|
+
...b,
|
|
195
|
+
children: n
|
|
186
196
|
}
|
|
187
197
|
);
|
|
188
198
|
export {
|
|
189
|
-
|
|
199
|
+
K as List,
|
|
190
200
|
j as ListItem,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
201
|
+
F as ListItemButton,
|
|
202
|
+
q as ListItemIcon,
|
|
203
|
+
Z as ListItemText,
|
|
204
|
+
V as ListSubheader
|
|
195
205
|
};
|
|
@@ -24,6 +24,8 @@ export interface ListItemProps extends HTMLAttributes<HTMLLIElement> {
|
|
|
24
24
|
leading?: ReactNode;
|
|
25
25
|
/** Trailing content (icon, button, badge) */
|
|
26
26
|
trailing?: ReactNode;
|
|
27
|
+
/** Secondary action rendered after content; clicks do not trigger the row onClick */
|
|
28
|
+
secondaryAction?: ReactNode;
|
|
27
29
|
/** Whether item is selected */
|
|
28
30
|
selected?: boolean;
|
|
29
31
|
/** Whether item is disabled */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),n=require("react"),Z=require("../Avatar/Avatar.cjs"),o=require("../Typography/Typography.cjs"),e=require("./MessageList.const.cjs"),A=require("./MessageList.utils.cjs"),t=require("../../utils/cn.cjs"),J=require("../../utils/generateBearId.utils.cjs"),K=require("../../utils/useBearId.cjs"),Q=({id:x,testId:f,messages:c,currentUserId:j,groupWindowMs:B=e.MESSAGE_LIST_GROUP_WINDOW_MS,showDaySeparators:b=!0,showAvatars:H=!0,showTimestamps:G=!0,autoScroll:R=!0,virtualized:$,height:E=e.MESSAGE_LIST_DEFAULT_HEIGHT,renderMessage:L,emptyState:g,formatDayLabel:T,formatTimestamp:I,translations:w,onNewMessagesClick:d,className:U})=>{const D=K.useBearId("MessageList"),P=J.resolveBearId(x,D),a=n.useRef(null),h=n.useRef(!0),O=n.useRef(null),[q,u]=n.useState(!1),[Y,W]=n.useState(0),[F,p]=n.useState(typeof E=="number"?E:e.MESSAGE_LIST_DEFAULT_HEIGHT),M={...e.MESSAGE_LIST_DEFAULT_TRANSLATIONS,...w},r=A.buildMessageListItems(c,j,B,b),V=S=>(T==null?void 0:T(S))??A.getDefaultDayLabel(S,M),m=S=>(I==null?void 0:I(S))??A.getDefaultTimestamp(S),C=$??c.length>=e.MESSAGE_LIST_VIRTUALIZE_THRESHOLD,y=S=>{const _=a.current;_&&_.scrollTo({top:_.scrollHeight,behavior:S?"smooth":"auto"})},k=()=>{const S=a.current;if(!S)return;W(S.scrollTop),p(S.clientHeight);const i=S.scrollHeight-S.scrollTop-S.clientHeight<=e.MESSAGE_LIST_BOTTOM_THRESHOLD_PX;h.current=i,i&&u(!1)};n.useEffect(()=>{const S=a.current;S&&p(S.clientHeight)},[E]),n.useEffect(()=>{const S=c.length>0?c[c.length-1].id:null,_=O.current===null,i=S!==null&&S!==O.current;if(O.current=S,!!i){if(_||R&&h.current){y(!_);return}u(!0)}},[c,R]);const z=()=>{y(!0),u(!1),d==null||d()},X=S=>s.jsxs("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__group`,e.MESSAGE_LIST_GROUP_CLASSES,S.isOwn&&e.MESSAGE_LIST_GROUP_OWN_CLASSES),children:[H&&!S.isOwn&&s.jsx(Z.Avatar,{src:S.author.avatar,initials:S.author.name[0],size:"sm",className:"bear-flex-shrink-0"}),s.jsxs("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__group-body`,e.MESSAGE_LIST_GROUP_BODY_CLASSES,S.isOwn&&e.MESSAGE_LIST_GROUP_BODY_OWN_CLASSES),children:[!S.isOwn&&s.jsxs("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__meta`,e.MESSAGE_LIST_META_CLASSES),children:[s.jsx(o.Typography,{variant:"caption",component:"span",className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__author`,e.MESSAGE_LIST_AUTHOR_CLASSES),children:S.author.name}),G&&s.jsx(o.Typography,{variant:"caption",component:"span",className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__timestamp`,e.MESSAGE_LIST_TIMESTAMP_CLASSES),children:m(S.messages[0].timestamp)})]}),S.messages.map(_=>s.jsx("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__bubble`,e.MESSAGE_LIST_BUBBLE_CLASSES,S.isOwn&&`${e.MESSAGE_LIST_ROOT_CLASS}__bubble--own`,S.isOwn&&e.MESSAGE_LIST_BUBBLE_OWN_CLASSES),children:(L==null?void 0:L(_))??_.content},_.id)),S.isOwn&&G&&s.jsx(o.Typography,{variant:"caption",component:"span",className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__timestamp`,e.MESSAGE_LIST_TIMESTAMP_CLASSES),children:m(S.messages[S.messages.length-1].timestamp)})]})]},S.key),N=S=>S.kind==="day"?s.jsxs("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-separator`,e.MESSAGE_LIST_DAY_SEPARATOR_CLASSES),children:[s.jsx("span",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-line`,e.MESSAGE_LIST_DAY_LINE_CLASSES)}),s.jsx("span",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-label`,e.MESSAGE_LIST_DAY_LABEL_CLASSES),children:V(S.date)}),s.jsx("span",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-line`,e.MESSAGE_LIST_DAY_LINE_CLASSES)})]},S.key):X(S),l=C?A.getMessageListWindow(r,Y,F,e.MESSAGE_LIST_OVERSCAN):null,v=l===null?r:r.slice(l.startIndex,l.endIndex+1);return s.jsxs("div",{id:P,"data-testid":f,className:t.cn(e.MESSAGE_LIST_ROOT_CLASS,e.MESSAGE_LIST_BASE_CLASSES,U),style:{height:typeof E=="number"?`${E}px`:E},children:[s.jsxs("div",{ref:a,onScroll:k,className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__scroller`,e.MESSAGE_LIST_SCROLLER_CLASSES),role:"log","aria-live":"polite",children:[r.length===0&&s.jsx("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__empty`,e.MESSAGE_LIST_EMPTY_CLASSES),children:g??s.jsx(o.Typography,{variant:"body2",component:"span",children:M.emptyLabel})}),C&&l?s.jsx("div",{className:`${e.MESSAGE_LIST_ROOT_CLASS}__virtual`,style:{height:l.totalHeight,position:"relative"},children:s.jsx("div",{style:{transform:`translateY(${l.offsetTop}px)`},children:v.map(S=>N(S))})}):v.map(S=>N(S))]}),q&&s.jsx("button",{type:"button",onClick:z,className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__new-messages`,e.MESSAGE_LIST_NEW_MESSAGES_CLASSES),children:M.newMessages})]})};exports.MessageList=Q;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S="Bear-MessageList",E=400,_=300*1e3,e=40,A=1440*60*1e3,L={newMessages:"New messages",today:"Today",yesterday:"Yesterday",emptyLabel:"No messages yet"},
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S="Bear-MessageList",E=400,_=300*1e3,e=40,A=1440*60*1e3,L={newMessages:"New messages",today:"Today",yesterday:"Yesterday",emptyLabel:"No messages yet"},T="bear-relative bear-flex bear-flex-col bear-rounded-xl bear-border bear-overflow-hidden",r="bear-flex-1 bear-overflow-y-auto bear-p-4 bear-flex bear-flex-col bear-gap-3",a="bear-flex bear-items-center bear-gap-3 bear-my-1",M="bear-flex-1 bear-h-px",I="bear-text-xs bear-font-medium bear-whitespace-nowrap",t="bear-flex bear-gap-2",G="bear-flex-row-reverse",b="bear-flex bear-flex-col bear-gap-1 bear-min-w-0 bear-flex-1",s="bear-items-end",o="bear-px-4 bear-py-2 bear-rounded-2xl bear-text-sm bear-max-w-[70%] bear-w-fit",n="bear-self-end",O="bear-flex bear-items-baseline bear-gap-2 bear-mb-1",c="bear-text-xs bear-font-semibold",C="bear-text-xs",R="bear-absolute-x-center bear-bottom-4 bear-flex bear-items-center bear-gap-2 bear-px-4 bear-py-2 bear-rounded-full bear-border-none bear-cursor-pointer bear-shadow-lg bear-text-xs bear-font-medium hover:bear-opacity-90",l="bear-flex-1 bear-flex bear-items-center bear-justify-center bear-text-sm",x=40,P=6,B=36,f=56,U=36,D=12;exports.MESSAGE_LIST_AUTHOR_CLASSES=c;exports.MESSAGE_LIST_BASE_CLASSES=T;exports.MESSAGE_LIST_BOTTOM_THRESHOLD_PX=e;exports.MESSAGE_LIST_BUBBLE_CLASSES=o;exports.MESSAGE_LIST_BUBBLE_ESTIMATE_PX=U;exports.MESSAGE_LIST_BUBBLE_OWN_CLASSES=n;exports.MESSAGE_LIST_DAY_ESTIMATE_PX=B;exports.MESSAGE_LIST_DAY_LABEL_CLASSES=I;exports.MESSAGE_LIST_DAY_LINE_CLASSES=M;exports.MESSAGE_LIST_DAY_SEPARATOR_CLASSES=a;exports.MESSAGE_LIST_DEFAULT_HEIGHT=E;exports.MESSAGE_LIST_DEFAULT_TRANSLATIONS=L;exports.MESSAGE_LIST_EMPTY_CLASSES=l;exports.MESSAGE_LIST_GROUP_BASE_ESTIMATE_PX=f;exports.MESSAGE_LIST_GROUP_BODY_CLASSES=b;exports.MESSAGE_LIST_GROUP_BODY_OWN_CLASSES=s;exports.MESSAGE_LIST_GROUP_CLASSES=t;exports.MESSAGE_LIST_GROUP_OWN_CLASSES=G;exports.MESSAGE_LIST_GROUP_WINDOW_MS=_;exports.MESSAGE_LIST_ITEM_GAP_PX=D;exports.MESSAGE_LIST_META_CLASSES=O;exports.MESSAGE_LIST_MS_PER_DAY=A;exports.MESSAGE_LIST_NEW_MESSAGES_CLASSES=R;exports.MESSAGE_LIST_OVERSCAN=P;exports.MESSAGE_LIST_ROOT_CLASS=S;exports.MESSAGE_LIST_SCROLLER_CLASSES=r;exports.MESSAGE_LIST_TIMESTAMP_CLASSES=C;exports.MESSAGE_LIST_VIRTUALIZE_THRESHOLD=x;
|
|
@@ -21,3 +21,9 @@ export declare const MESSAGE_LIST_AUTHOR_CLASSES = "bear-text-xs bear-font-semib
|
|
|
21
21
|
export declare const MESSAGE_LIST_TIMESTAMP_CLASSES = "bear-text-xs";
|
|
22
22
|
export declare const MESSAGE_LIST_NEW_MESSAGES_CLASSES = "bear-absolute-x-center bear-bottom-4 bear-flex bear-items-center bear-gap-2 bear-px-4 bear-py-2 bear-rounded-full bear-border-none bear-cursor-pointer bear-shadow-lg bear-text-xs bear-font-medium hover:bear-opacity-90";
|
|
23
23
|
export declare const MESSAGE_LIST_EMPTY_CLASSES = "bear-flex-1 bear-flex bear-items-center bear-justify-center bear-text-sm";
|
|
24
|
+
export declare const MESSAGE_LIST_VIRTUALIZE_THRESHOLD = 40;
|
|
25
|
+
export declare const MESSAGE_LIST_OVERSCAN = 6;
|
|
26
|
+
export declare const MESSAGE_LIST_DAY_ESTIMATE_PX = 36;
|
|
27
|
+
export declare const MESSAGE_LIST_GROUP_BASE_ESTIMATE_PX = 56;
|
|
28
|
+
export declare const MESSAGE_LIST_BUBBLE_ESTIMATE_PX = 36;
|
|
29
|
+
export declare const MESSAGE_LIST_ITEM_GAP_PX = 12;
|
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
const
|
|
1
|
+
const S = "Bear-MessageList", e = 400, E = 3e5, _ = 40, r = 864e5, a = {
|
|
2
2
|
newMessages: "New messages",
|
|
3
3
|
today: "Today",
|
|
4
4
|
yesterday: "Yesterday",
|
|
5
5
|
emptyLabel: "No messages yet"
|
|
6
|
-
}, b = "bear-relative bear-flex bear-flex-col bear-rounded-xl bear-border bear-overflow-hidden", t = "bear-flex-1 bear-overflow-y-auto bear-p-4 bear-flex bear-flex-col bear-gap-3",
|
|
6
|
+
}, b = "bear-relative bear-flex bear-flex-col bear-rounded-xl bear-border bear-overflow-hidden", t = "bear-flex-1 bear-overflow-y-auto bear-p-4 bear-flex bear-flex-col bear-gap-3", A = "bear-flex bear-items-center bear-gap-3 bear-my-1", s = "bear-flex-1 bear-h-px", L = "bear-text-xs bear-font-medium bear-whitespace-nowrap", o = "bear-flex bear-gap-2", T = "bear-flex-row-reverse", n = "bear-flex bear-flex-col bear-gap-1 bear-min-w-0 bear-flex-1", M = "bear-items-end", c = "bear-px-4 bear-py-2 bear-rounded-2xl bear-text-sm bear-max-w-[70%] bear-w-fit", I = "bear-self-end", G = "bear-flex bear-items-baseline bear-gap-2 bear-mb-1", x = "bear-text-xs bear-font-semibold", l = "bear-text-xs", f = "bear-absolute-x-center bear-bottom-4 bear-flex bear-items-center bear-gap-2 bear-px-4 bear-py-2 bear-rounded-full bear-border-none bear-cursor-pointer bear-shadow-lg bear-text-xs bear-font-medium hover:bear-opacity-90", O = "bear-flex-1 bear-flex bear-items-center bear-justify-center bear-text-sm", d = 40, m = 6, C = 36, i = 56, p = 36, R = 12;
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
x as MESSAGE_LIST_AUTHOR_CLASSES,
|
|
9
9
|
b as MESSAGE_LIST_BASE_CLASSES,
|
|
10
|
-
|
|
10
|
+
_ as MESSAGE_LIST_BOTTOM_THRESHOLD_PX,
|
|
11
11
|
c as MESSAGE_LIST_BUBBLE_CLASSES,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
n as
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
p as MESSAGE_LIST_BUBBLE_ESTIMATE_PX,
|
|
13
|
+
I as MESSAGE_LIST_BUBBLE_OWN_CLASSES,
|
|
14
|
+
C as MESSAGE_LIST_DAY_ESTIMATE_PX,
|
|
15
|
+
L as MESSAGE_LIST_DAY_LABEL_CLASSES,
|
|
16
|
+
s as MESSAGE_LIST_DAY_LINE_CLASSES,
|
|
17
|
+
A as MESSAGE_LIST_DAY_SEPARATOR_CLASSES,
|
|
18
|
+
e as MESSAGE_LIST_DEFAULT_HEIGHT,
|
|
19
|
+
a as MESSAGE_LIST_DEFAULT_TRANSLATIONS,
|
|
20
|
+
O as MESSAGE_LIST_EMPTY_CLASSES,
|
|
21
|
+
i as MESSAGE_LIST_GROUP_BASE_ESTIMATE_PX,
|
|
22
|
+
n as MESSAGE_LIST_GROUP_BODY_CLASSES,
|
|
23
|
+
M as MESSAGE_LIST_GROUP_BODY_OWN_CLASSES,
|
|
24
|
+
o as MESSAGE_LIST_GROUP_CLASSES,
|
|
25
|
+
T as MESSAGE_LIST_GROUP_OWN_CLASSES,
|
|
26
|
+
E as MESSAGE_LIST_GROUP_WINDOW_MS,
|
|
27
|
+
R as MESSAGE_LIST_ITEM_GAP_PX,
|
|
28
|
+
G as MESSAGE_LIST_META_CLASSES,
|
|
29
|
+
r as MESSAGE_LIST_MS_PER_DAY,
|
|
26
30
|
f as MESSAGE_LIST_NEW_MESSAGES_CLASSES,
|
|
27
|
-
|
|
31
|
+
m as MESSAGE_LIST_OVERSCAN,
|
|
32
|
+
S as MESSAGE_LIST_ROOT_CLASS,
|
|
28
33
|
t as MESSAGE_LIST_SCROLLER_CLASSES,
|
|
29
|
-
|
|
34
|
+
l as MESSAGE_LIST_TIMESTAMP_CLASSES,
|
|
35
|
+
d as MESSAGE_LIST_VIRTUALIZE_THRESHOLD
|
|
30
36
|
};
|
|
@@ -1,19 +1,3 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { MessageListProps } from './MessageList.types';
|
|
3
|
-
/**
|
|
4
|
-
* MessageList - Chat message list with consecutive-author grouping,
|
|
5
|
-
* day separators, and auto-scroll with a "new messages" affordance.
|
|
6
|
-
*
|
|
7
|
-
* Rendering is plain (non-virtualized); virtualization is planned as
|
|
8
|
-
* future work for very long conversations.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* <MessageList
|
|
13
|
-
* messages={messages}
|
|
14
|
-
* currentUserId="me"
|
|
15
|
-
* height={420}
|
|
16
|
-
* />
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
3
|
export declare const MessageList: FC<MessageListProps>;
|