@bikdotai/bik-component-library 0.0.840-tools-beta.5 → 0.0.840
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/cjs/components/BikGiftedChat/GiftedChat/GiftedChat.js +1 -1
- package/dist/cjs/components/BikGiftedChat/GiftedChat/GiftedChat.js.map +1 -1
- package/dist/cjs/components/SearchFilter/index.js +1 -1
- package/dist/cjs/components/SearchFilter/index.js.map +1 -1
- package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -1
- package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsChip.js +1 -1
- package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsChip.js.map +1 -1
- package/dist/cjs/components/button/themes.js +11 -11
- package/dist/cjs/components/button/themes.js.map +1 -1
- package/dist/cjs/components/dashboard-review-popup/DashboardReviewPopUp.js +1 -1
- package/dist/cjs/components/dashboard-review-popup/DashboardReviewPopUp.js.map +1 -1
- package/dist/cjs/components/dropdown-button/DropdownButton.js +1 -1
- package/dist/cjs/components/dropdown-button/DropdownButton.js.map +1 -1
- package/dist/cjs/components/input/Input.js +1 -1
- package/dist/cjs/components/input/Input.js.map +1 -1
- package/dist/cjs/components/multi-level-dropdown/MenuItem.js +1 -1
- package/dist/cjs/components/multi-level-dropdown/MenuItem.js.map +1 -1
- package/dist/cjs/components/radioButton/RadioButton.js +1 -1
- package/dist/cjs/components/radioButton/RadioButton.js.map +1 -1
- package/dist/cjs/components/radioList/RadioList.js +1 -1
- package/dist/cjs/components/radioList/RadioList.js.map +1 -1
- package/dist/cjs/components/searchBar/searchBar.js +1 -1
- package/dist/cjs/components/searchBar/searchBar.js.map +1 -1
- package/dist/cjs/components/side-modal/SideModal.js +1 -1
- package/dist/cjs/components/side-modal/SideModal.js.map +1 -1
- package/dist/cjs/components/star-rating/Star.js +1 -1
- package/dist/cjs/components/star-rating/Star.js.map +1 -1
- package/dist/cjs/components/star-rating/StarRating.js +2 -2
- package/dist/cjs/components/star-rating/StarRating.js.map +1 -1
- package/dist/cjs/components/template-preview/TemplatePreview.js +1 -1
- package/dist/cjs/components/template-preview/TemplatePreview.js.map +1 -1
- package/dist/cjs/components/thumbnail/Thumbnail.js +1 -1
- package/dist/cjs/components/thumbnail/Thumbnail.js.map +1 -1
- package/dist/cjs/components/zeroState/ZeroState.js +3 -3
- package/dist/cjs/components/zeroState/ZeroState.js.map +1 -1
- package/dist/cjs/icons/Media/Visual/FormkitNeutral.js +2 -0
- package/dist/cjs/icons/Media/Visual/FormkitNeutral.js.map +1 -0
- package/dist/cjs/icons/Media/Visual/FormkitSad.js +2 -0
- package/dist/cjs/icons/Media/Visual/FormkitSad.js.map +1 -0
- package/dist/cjs/icons/index.js +1 -1
- package/dist/esm/components/BikGiftedChat/GiftedChat/GiftedChat.js +66 -61
- package/dist/esm/components/BikGiftedChat/GiftedChat/GiftedChat.js.map +1 -1
- package/dist/esm/components/SearchFilter/index.js +11 -10
- package/dist/esm/components/SearchFilter/index.js.map +1 -1
- package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
- package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsChip.js +11 -10
- package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsChip.js.map +1 -1
- package/dist/esm/components/button/themes.d.ts +1 -0
- package/dist/esm/components/button/themes.js +61 -51
- package/dist/esm/components/button/themes.js.map +1 -1
- package/dist/esm/components/dashboard-review-popup/DashboardReviewPopUp.js +28 -21
- package/dist/esm/components/dashboard-review-popup/DashboardReviewPopUp.js.map +1 -1
- package/dist/esm/components/dropdown-button/DropdownButton.js +13 -13
- package/dist/esm/components/dropdown-button/DropdownButton.js.map +1 -1
- package/dist/esm/components/input/Input.js +35 -34
- package/dist/esm/components/input/Input.js.map +1 -1
- package/dist/esm/components/input/Input.model.d.ts +1 -0
- package/dist/esm/components/multi-level-dropdown/MenuItem.js +28 -27
- package/dist/esm/components/multi-level-dropdown/MenuItem.js.map +1 -1
- package/dist/esm/components/radioButton/RadioButton.js +10 -9
- package/dist/esm/components/radioButton/RadioButton.js.map +1 -1
- package/dist/esm/components/radioList/RadioList.js +28 -19
- package/dist/esm/components/radioList/RadioList.js.map +1 -1
- package/dist/esm/components/searchBar/searchBar.js +11 -10
- package/dist/esm/components/searchBar/searchBar.js.map +1 -1
- package/dist/esm/components/side-modal/SideModal.js +13 -5
- package/dist/esm/components/side-modal/SideModal.js.map +1 -1
- package/dist/esm/components/star-rating/Star.d.ts +1 -0
- package/dist/esm/components/star-rating/Star.js +32 -27
- package/dist/esm/components/star-rating/Star.js.map +1 -1
- package/dist/esm/components/star-rating/StarRating.js +17 -16
- package/dist/esm/components/star-rating/StarRating.js.map +1 -1
- package/dist/esm/components/template-preview/TemplatePreview.js +41 -40
- package/dist/esm/components/template-preview/TemplatePreview.js.map +1 -1
- package/dist/esm/components/thumbnail/Thumbnail.js +3 -3
- package/dist/esm/components/thumbnail/Thumbnail.js.map +1 -1
- package/dist/esm/components/zeroState/ZeroState.js +20 -13
- package/dist/esm/components/zeroState/ZeroState.js.map +1 -1
- package/dist/esm/icons/Media/Visual/FormkitNeutral.js +58 -0
- package/dist/esm/icons/Media/Visual/FormkitNeutral.js.map +1 -0
- package/dist/esm/icons/Media/Visual/FormkitSad.js +61 -0
- package/dist/esm/icons/Media/Visual/FormkitSad.js.map +1 -0
- package/dist/esm/icons/Media/Visual/index.d.ts +2 -0
- package/dist/esm/icons/index.d.ts +25 -25
- package/dist/esm/icons/index.js +420 -416
- package/dist/esm/icons/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import oe, { forwardRef as
|
|
1
|
+
import { jsx as n, Fragment as X, jsxs as k } from "react/jsx-runtime";
|
|
2
|
+
import oe, { forwardRef as ne, useRef as D, useState as q, useMemo as U, useImperativeHandle as se, useCallback as I, useEffect as ie } from "react";
|
|
3
3
|
import { COLORS as M } from "../../../constants/Theme.js";
|
|
4
4
|
import { useWindowSize as le } from "../../../hooks/useWindowSize.js";
|
|
5
5
|
import { BodySecondary as ae } from "../../TypographyStyle.js";
|
|
@@ -10,17 +10,17 @@ import { useScrollToBottom as ue, useInitialMountScroll as he, useScrollCleanup
|
|
|
10
10
|
import { MESSAGE_CHANNELS as Y } from "./types.js";
|
|
11
11
|
import { TOP_THRESHOLD as Se, normalizeRef as xe, isSameDay as be, Constants as P } from "./utils.js";
|
|
12
12
|
import { Button as Te } from "../../button/Button.js";
|
|
13
|
-
const G = 204, Ae = ({ text: R, isExpanded: h, onToggle:
|
|
14
|
-
const i = D(null), [
|
|
13
|
+
const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: s }) => {
|
|
14
|
+
const i = D(null), [x, b] = q(!1);
|
|
15
15
|
return ie(() => {
|
|
16
16
|
const g = i.current;
|
|
17
17
|
if (g) {
|
|
18
18
|
g.style.maxHeight = "none";
|
|
19
19
|
const $ = g.scrollHeight > G;
|
|
20
|
-
g.style.maxHeight = h ? "none" : `${G}px`,
|
|
20
|
+
g.style.maxHeight = h ? "none" : `${G}px`, b($);
|
|
21
21
|
}
|
|
22
22
|
}, [R, h]), /* @__PURE__ */ k(X, { children: [
|
|
23
|
-
/* @__PURE__ */
|
|
23
|
+
/* @__PURE__ */ n(
|
|
24
24
|
"div",
|
|
25
25
|
{
|
|
26
26
|
ref: i,
|
|
@@ -28,25 +28,25 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
28
28
|
maxHeight: h ? "none" : G,
|
|
29
29
|
overflow: "hidden"
|
|
30
30
|
},
|
|
31
|
-
children: /* @__PURE__ */
|
|
31
|
+
children: /* @__PURE__ */ n(ae, { children: R })
|
|
32
32
|
}
|
|
33
33
|
),
|
|
34
|
-
|
|
34
|
+
x && /* @__PURE__ */ n(
|
|
35
35
|
Te,
|
|
36
36
|
{
|
|
37
37
|
buttonType: "text",
|
|
38
38
|
size: "xs",
|
|
39
39
|
buttonText: h ? "Show less" : "Read more",
|
|
40
|
-
onClick:
|
|
40
|
+
onClick: s
|
|
41
41
|
}
|
|
42
42
|
)
|
|
43
43
|
] });
|
|
44
44
|
}, Me = (R, h) => {
|
|
45
45
|
const {
|
|
46
|
-
messages:
|
|
46
|
+
messages: s = [],
|
|
47
47
|
user: i,
|
|
48
|
-
renderBubble:
|
|
49
|
-
renderAvatar:
|
|
48
|
+
renderBubble: x,
|
|
49
|
+
renderAvatar: b,
|
|
50
50
|
renderDay: g,
|
|
51
51
|
renderLoading: $,
|
|
52
52
|
renderChatEmpty: N,
|
|
@@ -59,9 +59,9 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
59
59
|
topThreshold: J = Se,
|
|
60
60
|
appType: c = u.Bik,
|
|
61
61
|
maxHeight: O,
|
|
62
|
-
isActivityMessage:
|
|
62
|
+
isActivityMessage: T,
|
|
63
63
|
...F
|
|
64
|
-
} = R || {},
|
|
64
|
+
} = R || {}, S = le(), K = D(null), p = xe(
|
|
65
65
|
w.ref || h,
|
|
66
66
|
K
|
|
67
67
|
), m = D({
|
|
@@ -70,18 +70,18 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
70
70
|
isLoadingOldMessages: !1,
|
|
71
71
|
isAtBottom: !0,
|
|
72
72
|
hasTriggeredEndReached: !1,
|
|
73
|
-
lastMessagesLength:
|
|
73
|
+
lastMessagesLength: s?.length ?? 0,
|
|
74
74
|
previousScrollHeight: 0,
|
|
75
75
|
previousScrollTop: 0,
|
|
76
76
|
scrollTimeout: null
|
|
77
|
-
}), [V, Q] = q(/* @__PURE__ */ new Set()), d = U(() => !
|
|
77
|
+
}), [V, Q] = q(/* @__PURE__ */ new Set()), d = U(() => !s || s.length === 0 ? [] : [...s].reverse(), [s]), Z = U(() => {
|
|
78
78
|
const e = [];
|
|
79
79
|
return d.forEach((o, r) => {
|
|
80
80
|
const t = d[r - 1];
|
|
81
81
|
r === 0 || !be(o, t) ? e.push({ createdAt: o.createdAt, indices: [r] }) : e[e.length - 1].indices.push(r);
|
|
82
82
|
}), e;
|
|
83
83
|
}, [d]), E = ue(p, m);
|
|
84
|
-
|
|
84
|
+
se(h, () => p.current), he(
|
|
85
85
|
p,
|
|
86
86
|
m,
|
|
87
87
|
d.length,
|
|
@@ -89,10 +89,10 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
89
89
|
), ge(m), pe(p, m, d.length), me(
|
|
90
90
|
p,
|
|
91
91
|
m,
|
|
92
|
-
|
|
92
|
+
s.length,
|
|
93
93
|
E
|
|
94
94
|
), ye(
|
|
95
|
-
|
|
95
|
+
s?.[0],
|
|
96
96
|
m,
|
|
97
97
|
E,
|
|
98
98
|
L
|
|
@@ -102,15 +102,20 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
102
102
|
w.onEndReached,
|
|
103
103
|
w.onScroll,
|
|
104
104
|
J
|
|
105
|
-
),
|
|
105
|
+
), f = I(
|
|
106
106
|
(e) => !!(e && i && e.user?._id === i._id),
|
|
107
107
|
[i]
|
|
108
108
|
), W = I(
|
|
109
|
-
(e, o) => C ? _ ? !0 : !o || (
|
|
110
|
-
[
|
|
109
|
+
(e, o) => C ? _ || f(e) ? !0 : !o || (T ? T(e) : !1) || (T ? T(o) : !1) || o.user._id !== e.user._id : !1,
|
|
110
|
+
[
|
|
111
|
+
C,
|
|
112
|
+
_,
|
|
113
|
+
T,
|
|
114
|
+
f
|
|
115
|
+
]
|
|
111
116
|
), te = I(
|
|
112
117
|
(e, o, r) => {
|
|
113
|
-
const t =
|
|
118
|
+
const t = f(e) ? "right" : "left", a = o?.user?._id !== e?.user?._id, y = r?.user?._id !== e?.user?._id, A = {
|
|
114
119
|
currentMessage: e,
|
|
115
120
|
previousMessage: o,
|
|
116
121
|
nextMessage: r,
|
|
@@ -118,10 +123,10 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
118
123
|
user: i,
|
|
119
124
|
...F
|
|
120
125
|
};
|
|
121
|
-
if (
|
|
122
|
-
return
|
|
123
|
-
const
|
|
124
|
-
return /* @__PURE__ */
|
|
126
|
+
if (x)
|
|
127
|
+
return x(A);
|
|
128
|
+
const l = e._id, B = V.has(l);
|
|
129
|
+
return /* @__PURE__ */ n(
|
|
125
130
|
"div",
|
|
126
131
|
{
|
|
127
132
|
style: {
|
|
@@ -129,39 +134,39 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
129
134
|
width: "fit-content",
|
|
130
135
|
...c === u.Manifest ? { minWidth: "130px" } : {},
|
|
131
136
|
padding: "8px 12px",
|
|
132
|
-
borderTopLeftRadius: t === "left" ?
|
|
133
|
-
borderTopRightRadius:
|
|
134
|
-
borderBottomLeftRadius: t === "left" ?
|
|
135
|
-
borderBottomRightRadius:
|
|
137
|
+
borderTopLeftRadius: t === "left" ? a ? 12 : 2 : 12,
|
|
138
|
+
borderTopRightRadius: 12,
|
|
139
|
+
borderBottomLeftRadius: t === "left" ? y ? 12 : 2 : 12,
|
|
140
|
+
borderBottomRightRadius: 12,
|
|
136
141
|
border: t === "left" && c === u.Manifest ? "1px solid rgb(224, 224, 224)" : "none",
|
|
137
142
|
backgroundColor: t === "right" ? c === u.Manifest ? M.background.brandTint : M.background.brandLight : c === u.Manifest ? M.background.pureWhite : M.background.inactive,
|
|
138
143
|
color: M.content.primary,
|
|
139
144
|
wordBreak: "break-word"
|
|
140
145
|
},
|
|
141
|
-
children: /* @__PURE__ */
|
|
146
|
+
children: /* @__PURE__ */ n(
|
|
142
147
|
Ae,
|
|
143
148
|
{
|
|
144
149
|
text: e.text ?? "",
|
|
145
150
|
isExpanded: B,
|
|
146
151
|
onToggle: () => Q((H) => {
|
|
147
|
-
const
|
|
148
|
-
return B ?
|
|
152
|
+
const v = new Set(H);
|
|
153
|
+
return B ? v.delete(l) : v.add(l), v;
|
|
149
154
|
})
|
|
150
155
|
}
|
|
151
156
|
)
|
|
152
157
|
}
|
|
153
158
|
);
|
|
154
159
|
},
|
|
155
|
-
[
|
|
160
|
+
[f, i, x, F, V]
|
|
156
161
|
), j = I(
|
|
157
162
|
(e, o, r) => {
|
|
158
163
|
if (!W(e, o)) return null;
|
|
159
|
-
const
|
|
160
|
-
return
|
|
164
|
+
const a = f(e) ? "right" : "left";
|
|
165
|
+
return b ? b({
|
|
161
166
|
currentMessage: e,
|
|
162
167
|
previousMessage: o,
|
|
163
168
|
nextMessage: r,
|
|
164
|
-
position:
|
|
169
|
+
position: a,
|
|
165
170
|
user: i,
|
|
166
171
|
renderAvatarOnTop: z,
|
|
167
172
|
showUserAvatar: C,
|
|
@@ -170,15 +175,15 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
170
175
|
},
|
|
171
176
|
[
|
|
172
177
|
W,
|
|
173
|
-
|
|
178
|
+
f,
|
|
174
179
|
i,
|
|
175
180
|
z,
|
|
176
181
|
C,
|
|
177
182
|
_,
|
|
178
|
-
|
|
183
|
+
b
|
|
179
184
|
]
|
|
180
185
|
);
|
|
181
|
-
return !
|
|
186
|
+
return !s || s.length === 0 ? N ? /* @__PURE__ */ n(X, { children: N() }) : null : /* @__PURE__ */ k(
|
|
182
187
|
"div",
|
|
183
188
|
{
|
|
184
189
|
ref: p,
|
|
@@ -193,8 +198,8 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
193
198
|
},
|
|
194
199
|
onScroll: ee,
|
|
195
200
|
children: [
|
|
196
|
-
/* @__PURE__ */
|
|
197
|
-
/* @__PURE__ */
|
|
201
|
+
/* @__PURE__ */ n("div", { style: { flex: "1 0 auto" } }),
|
|
202
|
+
/* @__PURE__ */ n(
|
|
198
203
|
"div",
|
|
199
204
|
{
|
|
200
205
|
style: {
|
|
@@ -203,7 +208,7 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
203
208
|
flex: "0 0 auto"
|
|
204
209
|
},
|
|
205
210
|
children: Z.map((e, o) => /* @__PURE__ */ k("div", { children: [
|
|
206
|
-
g ? /* @__PURE__ */
|
|
211
|
+
g ? /* @__PURE__ */ n("div", { style: { position: "sticky", top: 0, zIndex: 2 }, children: g({ createdAt: e.createdAt }) }) : /* @__PURE__ */ n(
|
|
207
212
|
ce,
|
|
208
213
|
{
|
|
209
214
|
createdAt: e.createdAt,
|
|
@@ -212,29 +217,29 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
212
217
|
}
|
|
213
218
|
),
|
|
214
219
|
e.indices.map((r) => {
|
|
215
|
-
const t = d[r],
|
|
216
|
-
return /* @__PURE__ */
|
|
220
|
+
const t = d[r], a = t?.channelId === Y.SMTP || t?.channelName === Y.SMTP, y = a ? "left" : f(t) ? "right" : "left", A = d[r - 1], l = d[r + 1], B = de(t, y), H = fe(t), v = t.category === P.ChatActivity.Category.ACTIVITY && t.activityType === P.ChatActivity.Type.PRIVATE_NOTE, re = t.category === P.ChatActivity.Category.ACTIVITY && !v;
|
|
221
|
+
return /* @__PURE__ */ n(
|
|
217
222
|
oe.Fragment,
|
|
218
223
|
{
|
|
219
224
|
children: /* @__PURE__ */ k(
|
|
220
225
|
"div",
|
|
221
226
|
{
|
|
222
227
|
style: {
|
|
223
|
-
...
|
|
228
|
+
...S ? { margin: "0 4px" } : {},
|
|
224
229
|
...H ? {} : { display: "flex", alignItems: "flex-start" },
|
|
225
|
-
...c !== u.Manifest ? !
|
|
226
|
-
...
|
|
227
|
-
...
|
|
230
|
+
...c !== u.Manifest ? !S && y === "right" ? { marginLeft: 8 } : { marginRight: 8 } : {},
|
|
231
|
+
...a && !v && S ? { marginLeft: 8, marginRight: 8 } : {},
|
|
232
|
+
...a && v ? { marginRight: 16 } : {},
|
|
228
233
|
justifyContent: B,
|
|
229
|
-
marginBottom:
|
|
234
|
+
marginBottom: a ? (
|
|
230
235
|
// SMTP: flat 24px between mails, no same/different-user split.
|
|
231
|
-
|
|
232
|
-
) :
|
|
236
|
+
l ? 24 : 0
|
|
237
|
+
) : l ? l?.user?._id === t?.user?._id ? f(t) ? 20 : 4 : 20 : 0,
|
|
233
238
|
// Activity cards: no left/bottom margin.
|
|
234
239
|
...re ? { marginLeft: 0, marginBottom: 0 } : {}
|
|
235
240
|
},
|
|
236
241
|
children: [
|
|
237
|
-
!
|
|
242
|
+
!S && y === "left" && /* @__PURE__ */ n(
|
|
238
243
|
"div",
|
|
239
244
|
{
|
|
240
245
|
style: {
|
|
@@ -245,23 +250,23 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
245
250
|
children: j(
|
|
246
251
|
t,
|
|
247
252
|
A,
|
|
248
|
-
|
|
253
|
+
l
|
|
249
254
|
)
|
|
250
255
|
}
|
|
251
256
|
),
|
|
252
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ n(
|
|
253
258
|
"div",
|
|
254
259
|
{
|
|
255
260
|
id: `message-bubble-${t._id ?? `${r}-${L?.() ?? "id"}`}`,
|
|
256
|
-
style: c === u.Manifest ? { width: "100%" } :
|
|
261
|
+
style: c === u.Manifest ? { width: "100%" } : S || a ? { display: "flex", flexGrow: 1, width: "100%" } : {},
|
|
257
262
|
children: te(
|
|
258
263
|
t,
|
|
259
264
|
A,
|
|
260
|
-
|
|
265
|
+
l
|
|
261
266
|
)
|
|
262
267
|
}
|
|
263
268
|
),
|
|
264
|
-
!
|
|
269
|
+
!S && y === "right" && /* @__PURE__ */ n(
|
|
265
270
|
"div",
|
|
266
271
|
{
|
|
267
272
|
style: {
|
|
@@ -273,7 +278,7 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
273
278
|
children: j(
|
|
274
279
|
t,
|
|
275
280
|
A,
|
|
276
|
-
|
|
281
|
+
l
|
|
277
282
|
)
|
|
278
283
|
}
|
|
279
284
|
)
|
|
@@ -290,7 +295,7 @@ const G = 204, Ae = ({ text: R, isExpanded: h, onToggle: n }) => {
|
|
|
290
295
|
]
|
|
291
296
|
}
|
|
292
297
|
);
|
|
293
|
-
}, De =
|
|
298
|
+
}, De = ne(
|
|
294
299
|
Me
|
|
295
300
|
);
|
|
296
301
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GiftedChat.js","sources":["../../../../../src/components/BikGiftedChat/GiftedChat/GiftedChat.tsx"],"sourcesContent":["import React, {\n\tforwardRef,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { COLORS } from '../../../constants/Theme';\nimport { useWindowSize } from '../../../hooks/useWindowSize';\nimport { Button } from '../../button';\nimport { BodySecondary } from '../../TypographyStyle';\nimport { BubbleProps, GiftedChatAppType } from '../Bubble/types';\nimport { IMessage } from '../types';\nimport { Day } from './Day';\nimport { getMessagePlacement, shouldCenterAlign } from './messageHelpers';\nimport {\n\tuseAutoScrollOnNewMessages,\n\tuseInitialMountScroll,\n\tuseResizeObserverForFirstMessage,\n\tuseRestoreScrollPosition,\n\tuseScrollCleanup,\n\tuseScrollHandler,\n\tuseScrollToBottom,\n} from './scrollHooks';\nimport { AvatarProps, GiftedChatProps, MESSAGE_CHANNELS } from './types';\nimport { isSameDay, normalizeRef } from './utils';\nimport { Constants, TOP_THRESHOLD } from './utils';\n\nconst COLLAPSED_MAX_HEIGHT = 204;\n\nconst CollapsibleBubbleText: React.FC<{\n\ttext: string;\n\tisExpanded: boolean;\n\tonToggle: () => void;\n}> = ({ text, isExpanded, onToggle }) => {\n\tconst textRef = useRef<HTMLDivElement>(null);\n\tconst [isOverflowing, setIsOverflowing] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst el = textRef.current;\n\t\tif (el) {\n\t\t\t// Temporarily remove max-height to measure true scroll height\n\t\t\tel.style.maxHeight = 'none';\n\t\t\tconst overflows = el.scrollHeight > COLLAPSED_MAX_HEIGHT;\n\t\t\tel.style.maxHeight = isExpanded ? 'none' : `${COLLAPSED_MAX_HEIGHT}px`;\n\t\t\tsetIsOverflowing(overflows);\n\t\t}\n\t}, [text, isExpanded]);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={textRef}\n\t\t\t\tstyle={{\n\t\t\t\t\tmaxHeight: isExpanded ? 'none' : COLLAPSED_MAX_HEIGHT,\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<BodySecondary>{text}</BodySecondary>\n\t\t\t</div>\n\t\t\t{isOverflowing && (\n\t\t\t\t<Button\n\t\t\t\t\tbuttonType=\"text\"\n\t\t\t\t\tsize=\"xs\"\n\t\t\t\t\tbuttonText={isExpanded ? 'Show less' : 'Read more'}\n\t\t\t\t\tonClick={onToggle}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</>\n\t);\n};\n\nconst GiftedChatInner = (\n\tprops: Omit<GiftedChatProps<IMessage>, 'ref'>,\n\tforwardedRef: React.Ref<HTMLDivElement>,\n) => {\n\tconst {\n\t\tmessages = [],\n\t\tuser,\n\t\trenderBubble,\n\t\trenderAvatar,\n\t\trenderDay,\n\t\trenderLoading,\n\t\trenderChatEmpty,\n\t\tlistViewProps = {},\n\t\trenderAvatarOnTop = false,\n\t\tshowUserAvatar = false,\n\t\tshowAvatarForEveryMessage = false,\n\t\tinverted = false,\n\t\tmessageIdGenerator,\n\t\ttopThreshold = TOP_THRESHOLD,\n\t\tappType = GiftedChatAppType.Bik,\n\t\tmaxHeight,\n\t\tisActivityMessage,\n\t\t...extraProps\n\t} = props || {};\n\n\tconst isMobile = useWindowSize();\n\n\tconst internalScrollRef = useRef<HTMLDivElement | null>(null);\n\tconst scrollRef = normalizeRef(\n\t\tlistViewProps.ref || forwardedRef,\n\t\tinternalScrollRef,\n\t);\n\n\tconst scrollState = useRef({\n\t\tisInitialMount: true,\n\t\tisUserScrolling: false,\n\t\tisLoadingOldMessages: false,\n\t\tisAtBottom: true,\n\t\thasTriggeredEndReached: false,\n\t\tlastMessagesLength: messages?.length ?? 0,\n\t\tpreviousScrollHeight: 0,\n\t\tpreviousScrollTop: 0,\n\t\tscrollTimeout: null,\n\t});\n\n\tconst [expandedMessages, setExpandedMessages] = useState<\n\t\tSet<string | number>\n\t>(new Set());\n\n\t// Reverse messages so newest appears last in DOM (natural reading order)\n\tconst reversedMessages = useMemo(() => {\n\t\tif (!messages || messages.length === 0) return [] as IMessage[];\n\t\treturn [...messages].reverse() as IMessage[];\n\t}, [messages]);\n\n\t// Group consecutive same-day messages so each day separator can stick\n\t// within its own section and get pushed out by the next day's separator.\n\tconst dayGroups = useMemo(() => {\n\t\tconst groups: { createdAt: IMessage['createdAt']; indices: number[] }[] =\n\t\t\t[];\n\t\treversedMessages.forEach((message, index) => {\n\t\t\tconst previousMessage = reversedMessages[index - 1];\n\t\t\tif (index === 0 || !isSameDay(message, previousMessage)) {\n\t\t\t\tgroups.push({ createdAt: message.createdAt, indices: [index] });\n\t\t\t} else {\n\t\t\t\tgroups[groups.length - 1].indices.push(index);\n\t\t\t}\n\t\t});\n\t\treturn groups;\n\t}, [reversedMessages]);\n\n\tconst scrollToBottom = useScrollToBottom(scrollRef, scrollState);\n\n\tuseImperativeHandle(forwardedRef, () => scrollRef.current!);\n\n\tuseInitialMountScroll(\n\t\tscrollRef,\n\t\tscrollState,\n\t\treversedMessages.length,\n\t\tscrollToBottom,\n\t);\n\n\tuseScrollCleanup(scrollState);\n\n\tuseRestoreScrollPosition(scrollRef, scrollState, reversedMessages.length);\n\n\tuseAutoScrollOnNewMessages(\n\t\tscrollRef,\n\t\tscrollState,\n\t\tmessages.length,\n\t\tscrollToBottom,\n\t);\n\n\tuseResizeObserverForFirstMessage(\n\t\tmessages?.[0],\n\t\tscrollState,\n\t\tscrollToBottom,\n\t\tmessageIdGenerator,\n\t);\n\n\tconst handleScroll = useScrollHandler(\n\t\tscrollState,\n\t\tlistViewProps.onEndReached,\n\t\tlistViewProps.onScroll,\n\t\ttopThreshold,\n\t);\n\n\t// Check if a message belongs to the current user\n\tconst isUserMessage = useCallback(\n\t\t(message: IMessage) => {\n\t\t\treturn Boolean(message && user && message.user?._id === user._id);\n\t\t},\n\t\t[user],\n\t);\n\n\t// Determine if avatar should be shown for this message\n\tconst shouldShowAvatar = useCallback(\n\t\t(message: IMessage, previousMessage?: IMessage) => {\n\t\t\tif (!showUserAvatar) return false;\n\t\t\tif (showAvatarForEveryMessage) return true;\n\n\t\t\t// Show avatar on the first message in a consecutive sender stack,\n\t\t\t// or when an activity interrupts the stack, or when the current message itself is an activity\n\t\t\treturn (\n\t\t\t\t!previousMessage ||\n\t\t\t\t(isActivityMessage ? isActivityMessage(message) : false) ||\n\t\t\t\t(isActivityMessage ? isActivityMessage(previousMessage) : false) ||\n\t\t\t\tpreviousMessage.user._id !== message.user._id\n\t\t\t);\n\t\t},\n\t\t[showUserAvatar, showAvatarForEveryMessage, isActivityMessage],\n\t);\n\n\t// Render a message bubble (or call custom renderBubble)\n\tconst renderMessageBubble = useCallback(\n\t\t(message: IMessage, previousMessage?: IMessage, nextMessage?: IMessage) => {\n\t\t\tconst position = isUserMessage(message) ? 'right' : 'left';\n\t\t\tconst isTopOfStack = previousMessage?.user?._id !== message?.user?._id;\n\t\t\tconst isBottomOfStack = nextMessage?.user?._id !== message?.user?._id;\n\n\t\t\tconst bubbleProps: BubbleProps<IMessage> = {\n\t\t\t\tcurrentMessage: message,\n\t\t\t\tpreviousMessage,\n\t\t\t\tnextMessage,\n\t\t\t\tposition,\n\t\t\t\tuser,\n\t\t\t\t...extraProps,\n\t\t\t};\n\n\t\t\t// Use custom render function if provided\n\t\t\tif (renderBubble) {\n\t\t\t\treturn renderBubble(bubbleProps);\n\t\t\t}\n\n\t\t\t// Default bubble rendering\n\t\t\tconst messageId = message._id;\n\t\t\tconst isExpanded = expandedMessages.has(messageId);\n\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tmaxWidth: appType === GiftedChatAppType.Manifest ? '50%' : '70%',\n\t\t\t\t\t\twidth: 'fit-content',\n\t\t\t\t\t\t...(appType === GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t? { minWidth: '130px' }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\tpadding: '8px 12px',\n\t\t\t\t\t\tborderTopLeftRadius:\n\t\t\t\t\t\t\tposition === 'left' ? (isTopOfStack ? 12 : 2) : 12,\n\t\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\t\tposition === 'right' ? (isTopOfStack ? 12 : 2) : 12,\n\t\t\t\t\t\tborderBottomLeftRadius:\n\t\t\t\t\t\t\tposition === 'left' ? (isBottomOfStack ? 12 : 2) : 12,\n\t\t\t\t\t\tborderBottomRightRadius:\n\t\t\t\t\t\t\tposition === 'right' ? (isBottomOfStack ? 12 : 2) : 12,\n\t\t\t\t\t\tborder:\n\t\t\t\t\t\t\tposition === 'left' && appType === GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t\t? '1px solid rgb(224, 224, 224)'\n\t\t\t\t\t\t\t\t: 'none',\n\t\t\t\t\t\tbackgroundColor:\n\t\t\t\t\t\t\tposition === 'right'\n\t\t\t\t\t\t\t\t? appType === GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t\t\t? COLORS.background.brandTint\n\t\t\t\t\t\t\t\t\t: COLORS.background.brandLight\n\t\t\t\t\t\t\t\t: appType === GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t\t? COLORS.background.pureWhite\n\t\t\t\t\t\t\t\t: COLORS.background.inactive,\n\t\t\t\t\t\tcolor: COLORS.content.primary,\n\t\t\t\t\t\twordBreak: 'break-word',\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<CollapsibleBubbleText\n\t\t\t\t\t\ttext={message.text ?? ''}\n\t\t\t\t\t\tisExpanded={isExpanded}\n\t\t\t\t\t\tonToggle={() =>\n\t\t\t\t\t\t\tsetExpandedMessages((prev) => {\n\t\t\t\t\t\t\t\tconst next = new Set(prev);\n\t\t\t\t\t\t\t\tif (isExpanded) next.delete(messageId);\n\t\t\t\t\t\t\t\telse next.add(messageId);\n\t\t\t\t\t\t\t\treturn next;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t);\n\t\t},\n\t\t[isUserMessage, user, renderBubble, extraProps, expandedMessages],\n\t);\n\n\t// Render a message avatar (or call custom renderAvatar)\n\tconst renderMessageAvatar = useCallback(\n\t\t(message: IMessage, previousMessage?: IMessage, nextMessage?: IMessage) => {\n\t\t\tconst shouldShow = shouldShowAvatar(message, previousMessage);\n\n\t\t\tif (!shouldShow) return null;\n\n\t\t\tconst position = isUserMessage(message) ? 'right' : 'left';\n\n\t\t\tconst avatarProps: AvatarProps<IMessage> = {\n\t\t\t\tcurrentMessage: message,\n\t\t\t\tpreviousMessage,\n\t\t\t\tnextMessage,\n\t\t\t\tposition,\n\t\t\t\tuser,\n\t\t\t\trenderAvatarOnTop,\n\t\t\t\tshowUserAvatar,\n\t\t\t\tshowAvatarForEveryMessage,\n\t\t\t};\n\n\t\t\treturn renderAvatar ? renderAvatar(avatarProps) : null;\n\t\t},\n\t\t[\n\t\t\tshouldShowAvatar,\n\t\t\tisUserMessage,\n\t\t\tuser,\n\t\t\trenderAvatarOnTop,\n\t\t\tshowUserAvatar,\n\t\t\tshowAvatarForEveryMessage,\n\t\t\trenderAvatar,\n\t\t],\n\t);\n\n\t// Render: Empty State\n\tif (!messages || messages.length === 0) {\n\t\treturn renderChatEmpty ? <>{renderChatEmpty()}</> : null;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={scrollRef as React.RefObject<HTMLDivElement>}\n\t\t\tstyle={{\n\t\t\t\tflex: 1,\n\t\t\t\toverflowY: 'auto',\n\t\t\t\toverflowX: 'hidden',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\tflexDirection: 'column',\n\t\t\t\t...(maxHeight ? { maxHeight, height: maxHeight } : {}),\n\t\t\t\t...listViewProps.style,\n\t\t\t}}\n\t\t\tonScroll={handleScroll}\n\t\t>\n\t\t\t{/* Spacer to push messages to bottom (newest appears last in DOM) */}\n\t\t\t<div style={{ flex: '1 0 auto' }} />\n\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tflexDirection: 'column',\n\t\t\t\t\tflex: '0 0 auto',\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{dayGroups.map((group, groupIndex) => (\n\t\t\t\t\t<div key={`day-group-${groupIndex}`}>\n\t\t\t\t\t\t{/* Day separator — sticks to top while this day scrolls past */}\n\t\t\t\t\t\t{renderDay ? (\n\t\t\t\t\t\t\t<div style={{ position: 'sticky', top: 0, zIndex: 2 }}>\n\t\t\t\t\t\t\t\t{renderDay({ createdAt: group.createdAt })}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<Day\n\t\t\t\t\t\t\t\tcreatedAt={group.createdAt}\n\t\t\t\t\t\t\t\tappType={appType}\n\t\t\t\t\t\t\t\tscrollRootRef={scrollRef}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{group.indices.map((index) => {\n\t\t\t\t\t\t\tconst message = reversedMessages[index];\n\t\t\t\t\t\t\tconst isSmtp =\n\t\t\t\t\t\t\t\tmessage?.['channelId'] === MESSAGE_CHANNELS.SMTP ||\n\t\t\t\t\t\t\t\tmessage?.['channelName'] === MESSAGE_CHANNELS.SMTP;\n\t\t\t\t\t\t\tconst position = isSmtp\n\t\t\t\t\t\t\t\t? 'left'\n\t\t\t\t\t\t\t\t: isUserMessage(message)\n\t\t\t\t\t\t\t\t? 'right'\n\t\t\t\t\t\t\t\t: 'left';\n\t\t\t\t\t\t\tconst previousMessage = reversedMessages[index - 1];\n\t\t\t\t\t\t\tconst nextMessage = reversedMessages[index + 1];\n\t\t\t\t\t\t\tconst placement = getMessagePlacement(message, position);\n\t\t\t\t\t\t\tconst isCentered = shouldCenterAlign(message);\n\t\t\t\t\t\t\t// Check if message is a private note\n\t\t\t\t\t\t\tconst isPrivateNote =\n\t\t\t\t\t\t\t\tmessage['category'] ===\n\t\t\t\t\t\t\t\t\tConstants.ChatActivity.Category.ACTIVITY &&\n\t\t\t\t\t\t\t\tmessage['activityType'] ===\n\t\t\t\t\t\t\t\t\tConstants.ChatActivity.Type.PRIVATE_NOTE;\n\t\t\t\t\t\t\tconst isActivity =\n\t\t\t\t\t\t\t\tmessage['category'] ===\n\t\t\t\t\t\t\t\t\tConstants.ChatActivity.Category.ACTIVITY && !isPrivateNote;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<React.Fragment\n\t\t\t\t\t\t\t\t\tkey={\n\t\t\t\t\t\t\t\t\t\tmessage._id ?? `${index}-${messageIdGenerator?.() ?? 'id'}`\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{/* Message container */}\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t...(isMobile ? { margin: '0 4px' } : {}),\n\t\t\t\t\t\t\t\t\t\t\t...(isCentered\n\t\t\t\t\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t\t\t\t\t: { display: 'flex', alignItems: 'flex-start' }),\n\t\t\t\t\t\t\t\t\t\t\t...(appType !== GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t\t\t\t\t\t? !isMobile && position === 'right'\n\t\t\t\t\t\t\t\t\t\t\t\t\t? { marginLeft: 8 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t: { marginRight: 8 }\n\t\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t\t\t...(isSmtp && !isPrivateNote && isMobile\n\t\t\t\t\t\t\t\t\t\t\t\t? { marginLeft: 8, marginRight: 8 }\n\t\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t\t\t...(isSmtp && isPrivateNote ? { marginRight: 16 } : {}),\n\t\t\t\t\t\t\t\t\t\t\tjustifyContent: placement,\n\t\t\t\t\t\t\t\t\t\t\tmarginBottom: isSmtp\n\t\t\t\t\t\t\t\t\t\t\t\t? // SMTP: flat 24px between mails, no same/different-user split.\n\t\t\t\t\t\t\t\t\t\t\t\t nextMessage\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 24\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 0\n\t\t\t\t\t\t\t\t\t\t\t\t: nextMessage\n\t\t\t\t\t\t\t\t\t\t\t\t? nextMessage?.user?._id === message?.user?._id\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 4\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 20\n\t\t\t\t\t\t\t\t\t\t\t\t: 0,\n\t\t\t\t\t\t\t\t\t\t\t// Activity cards: no left/bottom margin.\n\t\t\t\t\t\t\t\t\t\t\t...(isActivity ? { marginLeft: 0, marginBottom: 0 } : {}),\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{/* Left avatar or placeholder (for mobile, avatar is hidden) */}\n\t\t\t\t\t\t\t\t\t\t{!isMobile && position === 'left' && (\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\t\tmarginRight: '4px',\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\tflexShrink: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{renderMessageAvatar(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpreviousMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnextMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t)}\n\n\t\t\t\t\t\t\t\t\t\t{/* Message bubble */}\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tid={`message-bubble-${\n\t\t\t\t\t\t\t\t\t\t\t\tmessage._id ??\n\t\t\t\t\t\t\t\t\t\t\t\t`${index}-${messageIdGenerator?.() ?? 'id'}`\n\t\t\t\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\tappType === GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t\t\t\t\t\t\t? { width: '100%' }\n\t\t\t\t\t\t\t\t\t\t\t\t\t: isMobile || isSmtp\n\t\t\t\t\t\t\t\t\t\t\t\t\t? { display: 'flex', flexGrow: 1, width: '100%' }\n\t\t\t\t\t\t\t\t\t\t\t\t\t: {}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{renderMessageBubble(\n\t\t\t\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\t\tpreviousMessage,\n\t\t\t\t\t\t\t\t\t\t\t\tnextMessage,\n\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t\t{/* Right avatar or placeholder (for mobile, avatar is hidden) */}\n\t\t\t\t\t\t\t\t\t\t{!isMobile && position === 'right' && (\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\t\tmarginLeft: '4px',\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\tflexShrink: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\talignSelf: 'flex-start',\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{renderMessageAvatar(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpreviousMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnextMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</React.Fragment>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t})}\n\t\t\t\t\t</div>\n\t\t\t\t))}\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default forwardRef<HTMLDivElement, GiftedChatProps<IMessage>>(\n\tGiftedChatInner,\n);\n"],"names":["COLLAPSED_MAX_HEIGHT","CollapsibleBubbleText","text","isExpanded","onToggle","textRef","useRef","isOverflowing","setIsOverflowing","useState","useEffect","el","overflows","jsxs","Fragment","jsx","BodySecondary","Button","GiftedChatInner","props","forwardedRef","messages","user","renderBubble","renderAvatar","renderDay","renderLoading","renderChatEmpty","listViewProps","renderAvatarOnTop","showUserAvatar","showAvatarForEveryMessage","inverted","messageIdGenerator","topThreshold","TOP_THRESHOLD","appType","GiftedChatAppType","maxHeight","isActivityMessage","extraProps","isMobile","useWindowSize","internalScrollRef","scrollRef","normalizeRef","scrollState","expandedMessages","setExpandedMessages","reversedMessages","useMemo","dayGroups","groups","message","index","previousMessage","isSameDay","scrollToBottom","useScrollToBottom","useImperativeHandle","useInitialMountScroll","useScrollCleanup","useRestoreScrollPosition","useAutoScrollOnNewMessages","useResizeObserverForFirstMessage","handleScroll","useScrollHandler","isUserMessage","useCallback","shouldShowAvatar","renderMessageBubble","nextMessage","position","isTopOfStack","isBottomOfStack","bubbleProps","messageId","COLORS","prev","next","renderMessageAvatar","group","groupIndex","Day","isSmtp","MESSAGE_CHANNELS","placement","getMessagePlacement","isCentered","shouldCenterAlign","isPrivateNote","Constants","isActivity","React","GiftedChat","forwardRef"],"mappings":";;;;;;;;;;;;AA8BA,MAAMA,IAAuB,KAEvBC,KAID,CAAC,EAAE,MAAAC,GAAM,YAAAC,GAAY,UAAAC,QAAe;AACxC,QAAMC,IAAUC,EAAuB,IAAI,GACrC,CAACC,GAAeC,CAAgB,IAAIC,EAAS,EAAK;AAExD,SAAAC,GAAU,MAAM;AACf,UAAMC,IAAKN,EAAQ;AACnB,QAAIM,GAAI;AAEP,MAAAA,EAAG,MAAM,YAAY;AACrB,YAAMC,IAAYD,EAAG,eAAeX;AACpC,MAAAW,EAAG,MAAM,YAAYR,IAAa,SAAS,GAAGH,CAAoB,MAClEQ,EAAiBI,CAAS;AAAA,IAC3B;AAAA,EACD,GAAG,CAACV,GAAMC,CAAU,CAAC,GAGpB,gBAAAU,EAAAC,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,KAAKV;AAAA,QACL,OAAO;AAAA,UACN,WAAWF,IAAa,SAASH;AAAA,UACjC,UAAU;AAAA,QAAA;AAAA,QAGX,UAAA,gBAAAe,EAACC,MAAe,UAAAd,EAAA,CAAK;AAAA,MAAA;AAAA,IAAA;AAAA,IAErBK,KACA,gBAAAQ;AAAA,MAACE;AAAA,MAAA;AAAA,QACA,YAAW;AAAA,QACX,MAAK;AAAA,QACL,YAAYd,IAAa,cAAc;AAAA,QACvC,SAASC;AAAA,MAAA;AAAA,IAAA;AAAA,EACV,GAEF;AAEF,GAEMc,KAAkB,CACvBC,GACAC,MACI;AACJ,QAAM;AAAA,IACL,UAAAC,IAAW,CAAA;AAAA,IACX,MAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC;AAAA,IACA,WAAAC;AAAA,IACA,eAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,eAAAC,IAAgB,CAAA;AAAA,IAChB,mBAAAC,IAAoB;AAAA,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0B,IAAI;AAAA,gBAAA;AAAA,cA4F7D,CAAC;AAAA,YAAA,EAAA,GAnIQ,aAAaiD,CAAU,EAoIjC,CACA;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGH,GAEAY,KAAeC;AAAA,EACd7E;AACD;"}
|
|
1
|
+
{"version":3,"file":"GiftedChat.js","sources":["../../../../../src/components/BikGiftedChat/GiftedChat/GiftedChat.tsx"],"sourcesContent":["import React, {\n\tforwardRef,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { COLORS } from '../../../constants/Theme';\nimport { useWindowSize } from '../../../hooks/useWindowSize';\nimport { Button } from '../../button';\nimport { BodySecondary } from '../../TypographyStyle';\nimport { BubbleProps, GiftedChatAppType } from '../Bubble/types';\nimport { IMessage } from '../types';\nimport { Day } from './Day';\nimport { getMessagePlacement, shouldCenterAlign } from './messageHelpers';\nimport {\n\tuseAutoScrollOnNewMessages,\n\tuseInitialMountScroll,\n\tuseResizeObserverForFirstMessage,\n\tuseRestoreScrollPosition,\n\tuseScrollCleanup,\n\tuseScrollHandler,\n\tuseScrollToBottom,\n} from './scrollHooks';\nimport { AvatarProps, GiftedChatProps, MESSAGE_CHANNELS } from './types';\nimport { isSameDay, normalizeRef } from './utils';\nimport { Constants, TOP_THRESHOLD } from './utils';\n\nconst COLLAPSED_MAX_HEIGHT = 204;\n\nconst CollapsibleBubbleText: React.FC<{\n\ttext: string;\n\tisExpanded: boolean;\n\tonToggle: () => void;\n}> = ({ text, isExpanded, onToggle }) => {\n\tconst textRef = useRef<HTMLDivElement>(null);\n\tconst [isOverflowing, setIsOverflowing] = useState(false);\n\n\tuseEffect(() => {\n\t\tconst el = textRef.current;\n\t\tif (el) {\n\t\t\t// Temporarily remove max-height to measure true scroll height\n\t\t\tel.style.maxHeight = 'none';\n\t\t\tconst overflows = el.scrollHeight > COLLAPSED_MAX_HEIGHT;\n\t\t\tel.style.maxHeight = isExpanded ? 'none' : `${COLLAPSED_MAX_HEIGHT}px`;\n\t\t\tsetIsOverflowing(overflows);\n\t\t}\n\t}, [text, isExpanded]);\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tref={textRef}\n\t\t\t\tstyle={{\n\t\t\t\t\tmaxHeight: isExpanded ? 'none' : COLLAPSED_MAX_HEIGHT,\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<BodySecondary>{text}</BodySecondary>\n\t\t\t</div>\n\t\t\t{isOverflowing && (\n\t\t\t\t<Button\n\t\t\t\t\tbuttonType=\"text\"\n\t\t\t\t\tsize=\"xs\"\n\t\t\t\t\tbuttonText={isExpanded ? 'Show less' : 'Read more'}\n\t\t\t\t\tonClick={onToggle}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</>\n\t);\n};\n\nconst GiftedChatInner = (\n\tprops: Omit<GiftedChatProps<IMessage>, 'ref'>,\n\tforwardedRef: React.Ref<HTMLDivElement>,\n) => {\n\tconst {\n\t\tmessages = [],\n\t\tuser,\n\t\trenderBubble,\n\t\trenderAvatar,\n\t\trenderDay,\n\t\trenderLoading,\n\t\trenderChatEmpty,\n\t\tlistViewProps = {},\n\t\trenderAvatarOnTop = false,\n\t\tshowUserAvatar = false,\n\t\tshowAvatarForEveryMessage = false,\n\t\tinverted = false,\n\t\tmessageIdGenerator,\n\t\ttopThreshold = TOP_THRESHOLD,\n\t\tappType = GiftedChatAppType.Bik,\n\t\tmaxHeight,\n\t\tisActivityMessage,\n\t\t...extraProps\n\t} = props || {};\n\n\tconst isMobile = useWindowSize();\n\n\tconst internalScrollRef = useRef<HTMLDivElement | null>(null);\n\tconst scrollRef = normalizeRef(\n\t\tlistViewProps.ref || forwardedRef,\n\t\tinternalScrollRef,\n\t);\n\n\tconst scrollState = useRef({\n\t\tisInitialMount: true,\n\t\tisUserScrolling: false,\n\t\tisLoadingOldMessages: false,\n\t\tisAtBottom: true,\n\t\thasTriggeredEndReached: false,\n\t\tlastMessagesLength: messages?.length ?? 0,\n\t\tpreviousScrollHeight: 0,\n\t\tpreviousScrollTop: 0,\n\t\tscrollTimeout: null,\n\t});\n\n\tconst [expandedMessages, setExpandedMessages] = useState<\n\t\tSet<string | number>\n\t>(new Set());\n\n\t// Reverse messages so newest appears last in DOM (natural reading order)\n\tconst reversedMessages = useMemo(() => {\n\t\tif (!messages || messages.length === 0) return [] as IMessage[];\n\t\treturn [...messages].reverse() as IMessage[];\n\t}, [messages]);\n\n\t// Group consecutive same-day messages so each day separator can stick\n\t// within its own section and get pushed out by the next day's separator.\n\tconst dayGroups = useMemo(() => {\n\t\tconst groups: { createdAt: IMessage['createdAt']; indices: number[] }[] =\n\t\t\t[];\n\t\treversedMessages.forEach((message, index) => {\n\t\t\tconst previousMessage = reversedMessages[index - 1];\n\t\t\tif (index === 0 || !isSameDay(message, previousMessage)) {\n\t\t\t\tgroups.push({ createdAt: message.createdAt, indices: [index] });\n\t\t\t} else {\n\t\t\t\tgroups[groups.length - 1].indices.push(index);\n\t\t\t}\n\t\t});\n\t\treturn groups;\n\t}, [reversedMessages]);\n\n\tconst scrollToBottom = useScrollToBottom(scrollRef, scrollState);\n\n\tuseImperativeHandle(forwardedRef, () => scrollRef.current!);\n\n\tuseInitialMountScroll(\n\t\tscrollRef,\n\t\tscrollState,\n\t\treversedMessages.length,\n\t\tscrollToBottom,\n\t);\n\n\tuseScrollCleanup(scrollState);\n\n\tuseRestoreScrollPosition(scrollRef, scrollState, reversedMessages.length);\n\n\tuseAutoScrollOnNewMessages(\n\t\tscrollRef,\n\t\tscrollState,\n\t\tmessages.length,\n\t\tscrollToBottom,\n\t);\n\n\tuseResizeObserverForFirstMessage(\n\t\tmessages?.[0],\n\t\tscrollState,\n\t\tscrollToBottom,\n\t\tmessageIdGenerator,\n\t);\n\n\tconst handleScroll = useScrollHandler(\n\t\tscrollState,\n\t\tlistViewProps.onEndReached,\n\t\tlistViewProps.onScroll,\n\t\ttopThreshold,\n\t);\n\n\t// Check if a message belongs to the current user\n\tconst isUserMessage = useCallback(\n\t\t(message: IMessage) => {\n\t\t\treturn Boolean(message && user && message.user?._id === user._id);\n\t\t},\n\t\t[user],\n\t);\n\n\t// Determine if avatar should be shown for this message\n\tconst shouldShowAvatar = useCallback(\n\t\t(message: IMessage, previousMessage?: IMessage) => {\n\t\t\tif (!showUserAvatar) return false;\n\t\t\tif (showAvatarForEveryMessage) return true;\n\n\t\t\tif (isUserMessage(message)) return true;\n\n\t\t\t// Show avatar on the first message in a consecutive sender stack,\n\t\t\t// or when an activity interrupts the stack, or when the current message itself is an activity\n\t\t\treturn (\n\t\t\t\t!previousMessage ||\n\t\t\t\t(isActivityMessage ? isActivityMessage(message) : false) ||\n\t\t\t\t(isActivityMessage ? isActivityMessage(previousMessage) : false) ||\n\t\t\t\tpreviousMessage.user._id !== message.user._id\n\t\t\t);\n\t\t},\n\t\t[\n\t\t\tshowUserAvatar,\n\t\t\tshowAvatarForEveryMessage,\n\t\t\tisActivityMessage,\n\t\t\tisUserMessage,\n\t\t],\n\t);\n\n\t// Render a message bubble (or call custom renderBubble)\n\tconst renderMessageBubble = useCallback(\n\t\t(message: IMessage, previousMessage?: IMessage, nextMessage?: IMessage) => {\n\t\t\tconst position = isUserMessage(message) ? 'right' : 'left';\n\t\t\tconst isTopOfStack = previousMessage?.user?._id !== message?.user?._id;\n\t\t\tconst isBottomOfStack = nextMessage?.user?._id !== message?.user?._id;\n\n\t\t\tconst bubbleProps: BubbleProps<IMessage> = {\n\t\t\t\tcurrentMessage: message,\n\t\t\t\tpreviousMessage,\n\t\t\t\tnextMessage,\n\t\t\t\tposition,\n\t\t\t\tuser,\n\t\t\t\t...extraProps,\n\t\t\t};\n\n\t\t\t// Use custom render function if provided\n\t\t\tif (renderBubble) {\n\t\t\t\treturn renderBubble(bubbleProps);\n\t\t\t}\n\n\t\t\t// Default bubble rendering\n\t\t\tconst messageId = message._id;\n\t\t\tconst isExpanded = expandedMessages.has(messageId);\n\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tmaxWidth: appType === GiftedChatAppType.Manifest ? '50%' : '70%',\n\t\t\t\t\t\twidth: 'fit-content',\n\t\t\t\t\t\t...(appType === GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t? { minWidth: '130px' }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\tpadding: '8px 12px',\n\t\t\t\t\t\tborderTopLeftRadius:\n\t\t\t\t\t\t\tposition === 'left' ? (isTopOfStack ? 12 : 2) : 12,\n\t\t\t\t\t\tborderTopRightRadius: 12,\n\t\t\t\t\t\tborderBottomLeftRadius:\n\t\t\t\t\t\t\tposition === 'left' ? (isBottomOfStack ? 12 : 2) : 12,\n\t\t\t\t\t\tborderBottomRightRadius: 12,\n\t\t\t\t\t\tborder:\n\t\t\t\t\t\t\tposition === 'left' && appType === GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t\t? '1px solid rgb(224, 224, 224)'\n\t\t\t\t\t\t\t\t: 'none',\n\t\t\t\t\t\tbackgroundColor:\n\t\t\t\t\t\t\tposition === 'right'\n\t\t\t\t\t\t\t\t? appType === GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t\t\t? COLORS.background.brandTint\n\t\t\t\t\t\t\t\t\t: COLORS.background.brandLight\n\t\t\t\t\t\t\t\t: appType === GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t\t? COLORS.background.pureWhite\n\t\t\t\t\t\t\t\t: COLORS.background.inactive,\n\t\t\t\t\t\tcolor: COLORS.content.primary,\n\t\t\t\t\t\twordBreak: 'break-word',\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<CollapsibleBubbleText\n\t\t\t\t\t\ttext={message.text ?? ''}\n\t\t\t\t\t\tisExpanded={isExpanded}\n\t\t\t\t\t\tonToggle={() =>\n\t\t\t\t\t\t\tsetExpandedMessages((prev) => {\n\t\t\t\t\t\t\t\tconst next = new Set(prev);\n\t\t\t\t\t\t\t\tif (isExpanded) next.delete(messageId);\n\t\t\t\t\t\t\t\telse next.add(messageId);\n\t\t\t\t\t\t\t\treturn next;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t);\n\t\t},\n\t\t[isUserMessage, user, renderBubble, extraProps, expandedMessages],\n\t);\n\n\t// Render a message avatar (or call custom renderAvatar)\n\tconst renderMessageAvatar = useCallback(\n\t\t(message: IMessage, previousMessage?: IMessage, nextMessage?: IMessage) => {\n\t\t\tconst shouldShow = shouldShowAvatar(message, previousMessage);\n\n\t\t\tif (!shouldShow) return null;\n\n\t\t\tconst position = isUserMessage(message) ? 'right' : 'left';\n\n\t\t\tconst avatarProps: AvatarProps<IMessage> = {\n\t\t\t\tcurrentMessage: message,\n\t\t\t\tpreviousMessage,\n\t\t\t\tnextMessage,\n\t\t\t\tposition,\n\t\t\t\tuser,\n\t\t\t\trenderAvatarOnTop,\n\t\t\t\tshowUserAvatar,\n\t\t\t\tshowAvatarForEveryMessage,\n\t\t\t};\n\n\t\t\treturn renderAvatar ? renderAvatar(avatarProps) : null;\n\t\t},\n\t\t[\n\t\t\tshouldShowAvatar,\n\t\t\tisUserMessage,\n\t\t\tuser,\n\t\t\trenderAvatarOnTop,\n\t\t\tshowUserAvatar,\n\t\t\tshowAvatarForEveryMessage,\n\t\t\trenderAvatar,\n\t\t],\n\t);\n\n\t// Render: Empty State\n\tif (!messages || messages.length === 0) {\n\t\treturn renderChatEmpty ? <>{renderChatEmpty()}</> : null;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={scrollRef as React.RefObject<HTMLDivElement>}\n\t\t\tstyle={{\n\t\t\t\tflex: 1,\n\t\t\t\toverflowY: 'auto',\n\t\t\t\toverflowX: 'hidden',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\tflexDirection: 'column',\n\t\t\t\t...(maxHeight ? { maxHeight, height: maxHeight } : {}),\n\t\t\t\t...listViewProps.style,\n\t\t\t}}\n\t\t\tonScroll={handleScroll}\n\t\t>\n\t\t\t{/* Spacer to push messages to bottom (newest appears last in DOM) */}\n\t\t\t<div style={{ flex: '1 0 auto' }} />\n\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tflexDirection: 'column',\n\t\t\t\t\tflex: '0 0 auto',\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{dayGroups.map((group, groupIndex) => (\n\t\t\t\t\t<div key={`day-group-${groupIndex}`}>\n\t\t\t\t\t\t{/* Day separator — sticks to top while this day scrolls past */}\n\t\t\t\t\t\t{renderDay ? (\n\t\t\t\t\t\t\t<div style={{ position: 'sticky', top: 0, zIndex: 2 }}>\n\t\t\t\t\t\t\t\t{renderDay({ createdAt: group.createdAt })}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<Day\n\t\t\t\t\t\t\t\tcreatedAt={group.createdAt}\n\t\t\t\t\t\t\t\tappType={appType}\n\t\t\t\t\t\t\t\tscrollRootRef={scrollRef}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{group.indices.map((index) => {\n\t\t\t\t\t\t\tconst message = reversedMessages[index];\n\t\t\t\t\t\t\tconst isSmtp =\n\t\t\t\t\t\t\t\tmessage?.['channelId'] === MESSAGE_CHANNELS.SMTP ||\n\t\t\t\t\t\t\t\tmessage?.['channelName'] === MESSAGE_CHANNELS.SMTP;\n\t\t\t\t\t\t\tconst position = isSmtp\n\t\t\t\t\t\t\t\t? 'left'\n\t\t\t\t\t\t\t\t: isUserMessage(message)\n\t\t\t\t\t\t\t\t? 'right'\n\t\t\t\t\t\t\t\t: 'left';\n\t\t\t\t\t\t\tconst previousMessage = reversedMessages[index - 1];\n\t\t\t\t\t\t\tconst nextMessage = reversedMessages[index + 1];\n\t\t\t\t\t\t\tconst placement = getMessagePlacement(message, position);\n\t\t\t\t\t\t\tconst isCentered = shouldCenterAlign(message);\n\t\t\t\t\t\t\t// Check if message is a private note\n\t\t\t\t\t\t\tconst isPrivateNote =\n\t\t\t\t\t\t\t\tmessage['category'] ===\n\t\t\t\t\t\t\t\t\tConstants.ChatActivity.Category.ACTIVITY &&\n\t\t\t\t\t\t\t\tmessage['activityType'] ===\n\t\t\t\t\t\t\t\t\tConstants.ChatActivity.Type.PRIVATE_NOTE;\n\t\t\t\t\t\t\tconst isActivity =\n\t\t\t\t\t\t\t\tmessage['category'] ===\n\t\t\t\t\t\t\t\t\tConstants.ChatActivity.Category.ACTIVITY && !isPrivateNote;\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<React.Fragment\n\t\t\t\t\t\t\t\t\tkey={\n\t\t\t\t\t\t\t\t\t\tmessage._id ?? `${index}-${messageIdGenerator?.() ?? 'id'}`\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{/* Message container */}\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t...(isMobile ? { margin: '0 4px' } : {}),\n\t\t\t\t\t\t\t\t\t\t\t...(isCentered\n\t\t\t\t\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t\t\t\t\t: { display: 'flex', alignItems: 'flex-start' }),\n\t\t\t\t\t\t\t\t\t\t\t...(appType !== GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t\t\t\t\t\t? !isMobile && position === 'right'\n\t\t\t\t\t\t\t\t\t\t\t\t\t? { marginLeft: 8 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t: { marginRight: 8 }\n\t\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t\t\t...(isSmtp && !isPrivateNote && isMobile\n\t\t\t\t\t\t\t\t\t\t\t\t? { marginLeft: 8, marginRight: 8 }\n\t\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t\t\t...(isSmtp && isPrivateNote ? { marginRight: 16 } : {}),\n\t\t\t\t\t\t\t\t\t\t\tjustifyContent: placement,\n\t\t\t\t\t\t\t\t\t\t\tmarginBottom: isSmtp\n\t\t\t\t\t\t\t\t\t\t\t\t? // SMTP: flat 24px between mails, no same/different-user split.\n\t\t\t\t\t\t\t\t\t\t\t\t nextMessage\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 24\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 0\n\t\t\t\t\t\t\t\t\t\t\t\t: nextMessage\n\t\t\t\t\t\t\t\t\t\t\t\t? nextMessage?.user?._id === message?.user?._id\n\t\t\t\t\t\t\t\t\t\t\t\t\t? isUserMessage(message)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 20\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 4\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 20\n\t\t\t\t\t\t\t\t\t\t\t\t: 0,\n\t\t\t\t\t\t\t\t\t\t\t// Activity cards: no left/bottom margin.\n\t\t\t\t\t\t\t\t\t\t\t...(isActivity ? { marginLeft: 0, marginBottom: 0 } : {}),\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{/* Left avatar or placeholder (for mobile, avatar is hidden) */}\n\t\t\t\t\t\t\t\t\t\t{!isMobile && position === 'left' && (\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\t\tmarginRight: '4px',\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\tflexShrink: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{renderMessageAvatar(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpreviousMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnextMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t)}\n\n\t\t\t\t\t\t\t\t\t\t{/* Message bubble */}\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tid={`message-bubble-${\n\t\t\t\t\t\t\t\t\t\t\t\tmessage._id ??\n\t\t\t\t\t\t\t\t\t\t\t\t`${index}-${messageIdGenerator?.() ?? 'id'}`\n\t\t\t\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\tappType === GiftedChatAppType.Manifest\n\t\t\t\t\t\t\t\t\t\t\t\t\t? { width: '100%' }\n\t\t\t\t\t\t\t\t\t\t\t\t\t: isMobile || isSmtp\n\t\t\t\t\t\t\t\t\t\t\t\t\t? { display: 'flex', flexGrow: 1, width: '100%' }\n\t\t\t\t\t\t\t\t\t\t\t\t\t: {}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{renderMessageBubble(\n\t\t\t\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\t\tpreviousMessage,\n\t\t\t\t\t\t\t\t\t\t\t\tnextMessage,\n\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t\t{/* Right avatar or placeholder (for mobile, avatar is hidden) */}\n\t\t\t\t\t\t\t\t\t\t{!isMobile && position === 'right' && (\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\t\tmarginLeft: '4px',\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\tflexShrink: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\talignSelf: 'flex-start',\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{renderMessageAvatar(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpreviousMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnextMessage,\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</React.Fragment>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t})}\n\t\t\t\t\t</div>\n\t\t\t\t))}\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default forwardRef<HTMLDivElement, GiftedChatProps<IMessage>>(\n\tGiftedChatInner,\n);\n"],"names":["COLLAPSED_MAX_HEIGHT","CollapsibleBubbleText","text","isExpanded","onToggle","textRef","useRef","isOverflowing","setIsOverflowing","useState","useEffect","el","overflows","jsxs","Fragment","jsx","BodySecondary","Button","GiftedChatInner","props","forwardedRef","messages","user","renderBubble","renderAvatar","renderDay","renderLoading","renderChatEmpty","listViewProps","renderAvatarOnTop","showUserAvatar","showAvatarForEveryMessage","inverted","messageIdGenerator","topThreshold","TOP_THRESHOLD","appType","GiftedChatAppType","maxHeight","isActivityMessage","extraProps","isMobile","useWindowSize","internalScrollRef","scrollRef","normalizeRef","scrollState","expandedMessages","setExpandedMessages","reversedMessages","useMemo","dayGroups","groups","message","index","previousMessage","isSameDay","scrollToBottom","useScrollToBottom","useImperativeHandle","useInitialMountScroll","useScrollCleanup","useRestoreScrollPosition","useAutoScrollOnNewMessages","useResizeObserverForFirstMessage","handleScroll","useScrollHandler","isUserMessage","useCallback","shouldShowAvatar","renderMessageBubble","nextMessage","position","isTopOfStack","isBottomOfStack","bubbleProps","messageId","COLORS","prev","next","renderMessageAvatar","group","groupIndex","Day","isSmtp","MESSAGE_CHANNELS","placement","getMessagePlacement","isCentered","shouldCenterAlign","isPrivateNote","Constants","isActivity","React","GiftedChat","forwardRef"],"mappings":";;;;;;;;;;;;AA8BA,MAAMA,IAAuB,KAEvBC,KAID,CAAC,EAAE,MAAAC,GAAM,YAAAC,GAAY,UAAAC,QAAe;AACxC,QAAMC,IAAUC,EAAuB,IAAI,GACrC,CAACC,GAAeC,CAAgB,IAAIC,EAAS,EAAK;AAExD,SAAAC,GAAU,MAAM;AACf,UAAMC,IAAKN,EAAQ;AACnB,QAAIM,GAAI;AAEP,MAAAA,EAAG,MAAM,YAAY;AACrB,YAAMC,IAAYD,EAAG,eAAeX;AACpC,MAAAW,EAAG,MAAM,YAAYR,IAAa,SAAS,GAAGH,CAAoB,MAClEQ,EAAiBI,CAAS;AAAA,IAC3B;AAAA,EACD,GAAG,CAACV,GAAMC,CAAU,CAAC,GAGpB,gBAAAU,EAAAC,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,KAAKV;AAAA,QACL,OAAO;AAAA,UACN,WAAWF,IAAa,SAASH;AAAA,UACjC,UAAU;AAAA,QAAA;AAAA,QAGX,UAAA,gBAAAe,EAACC,MAAe,UAAAd,EAAA,CAAK;AAAA,MAAA;AAAA,IAAA;AAAA,IAErBK,KACA,gBAAAQ;AAAA,MAACE;AAAA,MAAA;AAAA,QACA,YAAW;AAAA,QACX,MAAK;AAAA,QACL,YAAYd,IAAa,cAAc;AAAA,QACvC,SAASC;AAAA,MAAA;AAAA,IAAA;AAAA,EACV,GAEF;AAEF,GAEMc,KAAkB,CACvBC,GACAC,MACI;AACJ,QAAM;AAAA,IACL,UAAAC,IAAW,CAAA;AAAA,IACX,MAAAC;AAAA,IACA,cAAAC;AAAA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,8BAAA;AAAA,4BACD;AAAA,0BAAA;AAAA,wBACD;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBAEF;AAAA,kBA3FClB,EAAQ,OAAO,GAAGC,CAAK,IAAIrB,IAAA,KAA0B,IAAI;AAAA,gBAAA;AAAA,cA8F7D,CAAC;AAAA,YAAA,EAAA,GArIQ,aAAaiD,CAAU,EAsIjC,CACA;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGH,GAEAY,KAAeC;AAAA,EACd7E;AACD;"}
|
|
@@ -6,13 +6,13 @@ import { FilterType as p } from "./types/SearchFilter.type.js";
|
|
|
6
6
|
import { SearchBar as R } from "../searchBar/searchBar.js";
|
|
7
7
|
const L = ({
|
|
8
8
|
direction: s = "row",
|
|
9
|
-
schema:
|
|
9
|
+
schema: d,
|
|
10
10
|
variant: w,
|
|
11
11
|
onChange: u,
|
|
12
12
|
showSelectedChips: v
|
|
13
13
|
}) => {
|
|
14
14
|
const i = D(
|
|
15
|
-
|
|
15
|
+
d?.filter((e) => e.defaultValue).map(
|
|
16
16
|
(e) => ({
|
|
17
17
|
id: e.id,
|
|
18
18
|
value: e.defaultValue,
|
|
@@ -20,12 +20,12 @@ const L = ({
|
|
|
20
20
|
text: e.text
|
|
21
21
|
})
|
|
22
22
|
) ?? []
|
|
23
|
-
), [x, y] = F([]),
|
|
23
|
+
), [x, y] = F([]), f = d.find(
|
|
24
24
|
(e) => e.type === p.Search
|
|
25
25
|
), h = (e) => {
|
|
26
|
-
|
|
26
|
+
f && typeof e == "string" && S(f.id, e);
|
|
27
27
|
}, S = (e, l) => {
|
|
28
|
-
const n =
|
|
28
|
+
const n = d.find((t) => t.id === e), a = [...x];
|
|
29
29
|
if (n) {
|
|
30
30
|
const t = a.findIndex((r) => r.id === e);
|
|
31
31
|
t !== -1 ? a[t] = { id: n.id, value: l } : a.push({ id: n.id, value: l }), i.current.find(
|
|
@@ -48,7 +48,7 @@ const L = ({
|
|
|
48
48
|
], u(n.id, i.current, l), y([...a]);
|
|
49
49
|
}
|
|
50
50
|
}, m = (e, l) => {
|
|
51
|
-
const n =
|
|
51
|
+
const n = d.find((t) => t.id === e);
|
|
52
52
|
let a = [...x];
|
|
53
53
|
n && (n.type === p.Multiple ? (a = a.map((t) => {
|
|
54
54
|
if (t.id === e) {
|
|
@@ -82,6 +82,7 @@ const L = ({
|
|
|
82
82
|
/* @__PURE__ */ g(
|
|
83
83
|
"div",
|
|
84
84
|
{
|
|
85
|
+
"data-testid": "search-filter-row",
|
|
85
86
|
style: {
|
|
86
87
|
display: "flex",
|
|
87
88
|
flexDirection: s,
|
|
@@ -90,14 +91,14 @@ const L = ({
|
|
|
90
91
|
alignItems: s === "row" ? "center" : "self-start"
|
|
91
92
|
},
|
|
92
93
|
children: [
|
|
93
|
-
|
|
94
|
+
f && /* @__PURE__ */ c(
|
|
94
95
|
R,
|
|
95
96
|
{
|
|
96
|
-
width:
|
|
97
|
+
width: f.width?.toString() ?? "100%",
|
|
97
98
|
isEnabled: !0,
|
|
98
99
|
onChange: h,
|
|
99
100
|
onEnter: h,
|
|
100
|
-
placeholder:
|
|
101
|
+
placeholder: f.text,
|
|
101
102
|
variant: "small"
|
|
102
103
|
}
|
|
103
104
|
),
|
|
@@ -111,7 +112,7 @@ const L = ({
|
|
|
111
112
|
flexWrap: "wrap",
|
|
112
113
|
alignItems: s === "row" ? "center" : "self-start"
|
|
113
114
|
},
|
|
114
|
-
children:
|
|
115
|
+
children: d.filter((e) => e.type !== p.Search).map((e, l) => /* @__PURE__ */ V(
|
|
115
116
|
E,
|
|
116
117
|
{
|
|
117
118
|
...e,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/SearchFilter/index.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\nimport { SingleOption } from '../dropdown/type';\nimport { SearchBar } from '../searchBar';\nimport { FilterChipListRenderer } from './components/FilterChipListRenderer';\nimport { SearchFilterItem } from './components/SearchFilterItem';\nimport {\n\tFilterType,\n\tFilterValueType,\n\tSearchFilterOutputState,\n\tSearchFilterProps,\n} from './types/SearchFilter.type';\n\nexport const SearchFilter: React.FC<SearchFilterProps> = ({\n\tdirection = 'row',\n\tschema,\n\tvariant,\n\tonChange,\n\tshowSelectedChips,\n}) => {\n\t/** this will always have the latest value and all the selected ids */\n\tconst selectedStateRef = useRef<SearchFilterOutputState[]>(\n\t\tschema\n\t\t\t?.filter((filterItem) => filterItem.defaultValue)\n\t\t\t.map(\n\t\t\t\t(filterItem) =>\n\t\t\t\t\t({\n\t\t\t\t\t\tid: filterItem.id,\n\t\t\t\t\t\tvalue: filterItem.defaultValue,\n\t\t\t\t\t\ttype: filterItem.type,\n\t\t\t\t\t\ttext: filterItem.text,\n\t\t\t\t\t} as SearchFilterOutputState),\n\t\t\t) ?? [],\n\t);\n\n\tconst [selectedIds, setSelectedIds] = useState<\n\t\t{ id: string; value: FilterValueType }[]\n\t>([]);\n\n\tconst searchSchema = schema.find(\n\t\t(filterItem) => filterItem.type === FilterType.Search,\n\t);\n\n\tconst onSearchChange = (searchText: string) => {\n\t\tif (searchSchema && typeof searchText === 'string') {\n\t\t\tselect(searchSchema.id, searchText);\n\t\t}\n\t};\n\n\tconst select = (id: string, value: FilterValueType) => {\n\t\tconst selectedSchema = schema.find((schemaItem) => schemaItem.id === id);\n\t\tconst localSelectedIds = [...selectedIds];\n\n\t\tif (selectedSchema) {\n\t\t\tconst idx = localSelectedIds.findIndex((el) => el.id === id);\n\t\t\tif (idx !== -1) {\n\t\t\t\tlocalSelectedIds[idx] = { id: selectedSchema.id, value };\n\t\t\t} else {\n\t\t\t\tlocalSelectedIds.push({ id: selectedSchema.id, value });\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * loop through selectedStateRef.current and if `id` present (1), update the value\n\t\t\t * and if id not present (2), push\n\t\t\t */\n\n\t\t\tconst idPresent = selectedStateRef.current.find(\n\t\t\t\t(selectedSchemaItem) => selectedSchemaItem.id === id,\n\t\t\t);\n\n\t\t\tif (idPresent) {\n\t\t\t\t/** (1) */\n\t\t\t\tselectedStateRef.current = selectedStateRef.current.map(\n\t\t\t\t\t(selectedSchemaItem) => {\n\t\t\t\t\t\tif (selectedSchemaItem.id === id) {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tid: selectedSchemaItem.id,\n\t\t\t\t\t\t\t\tvalue: value,\n\t\t\t\t\t\t\t\ttype: selectedSchemaItem.type,\n\t\t\t\t\t\t\t\ttext: selectedSchemaItem.text,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn selectedSchemaItem;\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t/** (2) */\n\t\t\t\tselectedStateRef.current = [\n\t\t\t\t\t...selectedStateRef.current,\n\t\t\t\t\t{\n\t\t\t\t\t\tid: id,\n\t\t\t\t\t\tvalue: value,\n\t\t\t\t\t\ttype: selectedSchema.type,\n\t\t\t\t\t\ttext: selectedSchema.text,\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\n\t\t\tonChange(selectedSchema.id, selectedStateRef.current, value);\n\n\t\t\tsetSelectedIds([...localSelectedIds]);\n\t\t}\n\t};\n\n\tconst deSelect = (id: string, value?: FilterValueType) => {\n\t\tconst selectedSchema = schema.find((schemaItem) => schemaItem.id === id);\n\t\tlet localSelectedIds = [...selectedIds];\n\t\tif (selectedSchema) {\n\t\t\t/**\n\t\t\t * only FilterType.Multiple, id can be present in selectedIds and selectedStateRef, so\n\t\t\t * delete id always except for FilterType.Multiple,\n\t\t\t *\n\t\t\t * for FilterType.Multiple,\n\t\t\t * \t\tif value.length === 0, delete id\n\t\t\t * \t\telse\n\t\t\t * \t\t\tjust update the value\n\t\t\t *\n\t\t\t */\n\n\t\t\tif (selectedSchema.type === FilterType.Multiple) {\n\t\t\t\t/** only update value i.e remove value from selectedItem.value */\n\t\t\t\tlocalSelectedIds = localSelectedIds\n\t\t\t\t\t.map((selected) => {\n\t\t\t\t\t\tif (selected.id === id) {\n\t\t\t\t\t\t\tconst newVal = (selected.value as SingleOption[]).filter(\n\t\t\t\t\t\t\t\t(val) => val.value !== (value as SingleOption).value,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (newVal.length) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...selected,\n\t\t\t\t\t\t\t\t\tvalue: newVal,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn selected;\n\t\t\t\t\t})\n\t\t\t\t\t.filter((selected) => !!selected) as {\n\t\t\t\t\tid: string;\n\t\t\t\t\tvalue: FilterValueType;\n\t\t\t\t}[];\n\n\t\t\t\tselectedStateRef.current = selectedStateRef.current\n\t\t\t\t\t.map((selectedItem) => {\n\t\t\t\t\t\tif (selectedItem.id === id) {\n\t\t\t\t\t\t\tconst newVal = (selectedItem.value as SingleOption[])?.filter(\n\t\t\t\t\t\t\t\t(val) => val.value !== (value as SingleOption).value,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (newVal.length) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...selectedItem,\n\t\t\t\t\t\t\t\t\tvalue: newVal,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn selectedItem;\n\t\t\t\t\t})\n\t\t\t\t\t.filter((selected) => !!selected) as SearchFilterOutputState[];\n\t\t\t} else {\n\t\t\t\t/** Delete */\n\t\t\t\tlocalSelectedIds = localSelectedIds.filter(\n\t\t\t\t\t(selected) => selected.id !== id,\n\t\t\t\t);\n\n\t\t\t\tselectedStateRef.current = selectedStateRef.current.filter(\n\t\t\t\t\t(selectedItem) => selectedItem.id !== id,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tonChange(selectedSchema.id, selectedStateRef.current, value);\n\n\t\t\tsetSelectedIds([...localSelectedIds]);\n\t\t}\n\t};\n\n\treturn (\n\t\t<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tflexDirection: direction,\n\t\t\t\t\tgap: 8,\n\t\t\t\t\tflexWrap: 'wrap',\n\t\t\t\t\talignItems: direction === 'row' ? 'center' : 'self-start',\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{searchSchema && (\n\t\t\t\t\t<SearchBar\n\t\t\t\t\t\twidth={searchSchema.width?.toString() ?? '100%'}\n\t\t\t\t\t\tisEnabled={true}\n\t\t\t\t\t\tonChange={onSearchChange}\n\t\t\t\t\t\tonEnter={onSearchChange}\n\t\t\t\t\t\tplaceholder={searchSchema.text}\n\t\t\t\t\t\tvariant={'small'}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<div\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\tflexDirection: 'row',\n\t\t\t\t\t\tgap: 8,\n\t\t\t\t\t\tflexWrap: 'wrap',\n\t\t\t\t\t\talignItems: direction === 'row' ? 'center' : 'self-start',\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{schema\n\t\t\t\t\t\t.filter((filterItem) => filterItem.type !== FilterType.Search)\n\t\t\t\t\t\t.map((filterItem, i) => (\n\t\t\t\t\t\t\t<SearchFilterItem\n\t\t\t\t\t\t\t\t{...filterItem}\n\t\t\t\t\t\t\t\tkey={i}\n\t\t\t\t\t\t\t\tvariant={variant}\n\t\t\t\t\t\t\t\tonChange={(val) => {\n\t\t\t\t\t\t\t\t\tselect(filterItem.id, val);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t))}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{showSelectedChips && (\n\t\t\t\t<div\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\tflexDirection: 'row',\n\t\t\t\t\t\tgap: 8,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<FilterChipListRenderer\n\t\t\t\t\t\tselectedState={selectedStateRef.current}\n\t\t\t\t\t\tonDeSelect={deSelect}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"names":["SearchFilter","direction","schema","variant","onChange","showSelectedChips","selectedStateRef","useRef","filterItem","selectedIds","setSelectedIds","useState","searchSchema","FilterType","onSearchChange","searchText","select","id","value","selectedSchema","schemaItem","localSelectedIds","idx","el","selectedSchemaItem","deSelect","selected","newVal","val","selectedItem","jsxs","jsx","SearchBar","i","createElement","SearchFilterItem","FilterChipListRenderer"],"mappings":";;;;;;AAYO,MAAMA,IAA4C,CAAC;AAAA,EACzD,WAAAC,IAAY;AAAA,EACZ,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,mBAAAC;AACD,MAAM;AAEL,QAAMC,IAAmBC;AAAA,IACxBL,GACG,OAAO,CAACM,MAAeA,EAAW,YAAY,EAC/C;AAAA,MACA,CAACA,OACC;AAAA,QACA,IAAIA,EAAW;AAAA,QACf,OAAOA,EAAW;AAAA,QAClB,MAAMA,EAAW;AAAA,QACjB,MAAMA,EAAW;AAAA,MAAA;AAAA,IAClB,KACG,CAAA;AAAA,EAAC,GAGF,CAACC,GAAaC,CAAc,IAAIC,EAEpC,CAAA,CAAE,GAEEC,IAAeV,EAAO;AAAA,IAC3B,CAACM,MAAeA,EAAW,SAASK,EAAW;AAAA,EAAA,GAG1CC,IAAiB,CAACC,MAAuB;AAC9C,IAAIH,KAAgB,OAAOG,KAAe,YACzCC,EAAOJ,EAAa,IAAIG,CAAU;AAAA,EAEpC,GAEMC,IAAS,CAACC,GAAYC,MAA2B;AACtD,UAAM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A;AAAA,cACT,aAAaF,EAAa;AAAA,cAC1B,SAAS;AAAA,YAAA;AAAA,UAAA;AAAA,UAGX,gBAAAmB;AAAA,YAAC;AAAA,YAAA;AAAA,cACA,OAAO;AAAA,gBACN,SAAS;AAAA,gBACT,eAAe;AAAA,gBACf,KAAK;AAAA,gBACL,UAAU;AAAA,gBACV,YAAY9B,MAAc,QAAQ,WAAW;AAAA,cAAA;AAAA,cAG7C,UAAAC,EACC,OAAO,CAACM,MAAeA,EAAW,SAASK,EAAW,MAAM,EAC5D,IAAI,CAACL,GAAYyB,MACjB,gBAAAC;AAAA,gBAACC;AAAA,gBAAA;AAAA,kBACC,GAAG3B;AAAA,kBACJ,KAAKyB;AAAA,kBACL,SAAA9B;AAAA,kBACA,UAAU,CAACyB,MAAQ;AAClB,oBAAAZ,EAAOR,EAAW,IAAIoB,CAAG;AAAA,kBAC1B;AAAA,gBAAA;AAAA,cAAA,CAED;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,IAEAvB,KACA,gBAAA0B;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,OAAO;AAAA,UACN,SAAS;AAAA,UACT,eAAe;AAAA,UACf,KAAK;AAAA,QAAA;AAAA,QAGN,UAAA,gBAAAA;AAAA,UAACK;AAAA,UAAA;AAAA,YACA,eAAe9B,EAAiB;AAAA,YAChC,YAAYmB;AAAA,UAAA;AAAA,QAAA;AAAA,MACb;AAAA,IAAA;AAAA,EACD,GAEF;AAEF;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/SearchFilter/index.tsx"],"sourcesContent":["import React, { useRef, useState } from 'react';\nimport { SingleOption } from '../dropdown/type';\nimport { SearchBar } from '../searchBar';\nimport { FilterChipListRenderer } from './components/FilterChipListRenderer';\nimport { SearchFilterItem } from './components/SearchFilterItem';\nimport {\n\tFilterType,\n\tFilterValueType,\n\tSearchFilterOutputState,\n\tSearchFilterProps,\n} from './types/SearchFilter.type';\n\nexport const SearchFilter: React.FC<SearchFilterProps> = ({\n\tdirection = 'row',\n\tschema,\n\tvariant,\n\tonChange,\n\tshowSelectedChips,\n}) => {\n\t/** this will always have the latest value and all the selected ids */\n\tconst selectedStateRef = useRef<SearchFilterOutputState[]>(\n\t\tschema\n\t\t\t?.filter((filterItem) => filterItem.defaultValue)\n\t\t\t.map(\n\t\t\t\t(filterItem) =>\n\t\t\t\t\t({\n\t\t\t\t\t\tid: filterItem.id,\n\t\t\t\t\t\tvalue: filterItem.defaultValue,\n\t\t\t\t\t\ttype: filterItem.type,\n\t\t\t\t\t\ttext: filterItem.text,\n\t\t\t\t\t} as SearchFilterOutputState),\n\t\t\t) ?? [],\n\t);\n\n\tconst [selectedIds, setSelectedIds] = useState<\n\t\t{ id: string; value: FilterValueType }[]\n\t>([]);\n\n\tconst searchSchema = schema.find(\n\t\t(filterItem) => filterItem.type === FilterType.Search,\n\t);\n\n\tconst onSearchChange = (searchText: string) => {\n\t\tif (searchSchema && typeof searchText === 'string') {\n\t\t\tselect(searchSchema.id, searchText);\n\t\t}\n\t};\n\n\tconst select = (id: string, value: FilterValueType) => {\n\t\tconst selectedSchema = schema.find((schemaItem) => schemaItem.id === id);\n\t\tconst localSelectedIds = [...selectedIds];\n\n\t\tif (selectedSchema) {\n\t\t\tconst idx = localSelectedIds.findIndex((el) => el.id === id);\n\t\t\tif (idx !== -1) {\n\t\t\t\tlocalSelectedIds[idx] = { id: selectedSchema.id, value };\n\t\t\t} else {\n\t\t\t\tlocalSelectedIds.push({ id: selectedSchema.id, value });\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * loop through selectedStateRef.current and if `id` present (1), update the value\n\t\t\t * and if id not present (2), push\n\t\t\t */\n\n\t\t\tconst idPresent = selectedStateRef.current.find(\n\t\t\t\t(selectedSchemaItem) => selectedSchemaItem.id === id,\n\t\t\t);\n\n\t\t\tif (idPresent) {\n\t\t\t\t/** (1) */\n\t\t\t\tselectedStateRef.current = selectedStateRef.current.map(\n\t\t\t\t\t(selectedSchemaItem) => {\n\t\t\t\t\t\tif (selectedSchemaItem.id === id) {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tid: selectedSchemaItem.id,\n\t\t\t\t\t\t\t\tvalue: value,\n\t\t\t\t\t\t\t\ttype: selectedSchemaItem.type,\n\t\t\t\t\t\t\t\ttext: selectedSchemaItem.text,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn selectedSchemaItem;\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t/** (2) */\n\t\t\t\tselectedStateRef.current = [\n\t\t\t\t\t...selectedStateRef.current,\n\t\t\t\t\t{\n\t\t\t\t\t\tid: id,\n\t\t\t\t\t\tvalue: value,\n\t\t\t\t\t\ttype: selectedSchema.type,\n\t\t\t\t\t\ttext: selectedSchema.text,\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\n\t\t\tonChange(selectedSchema.id, selectedStateRef.current, value);\n\n\t\t\tsetSelectedIds([...localSelectedIds]);\n\t\t}\n\t};\n\n\tconst deSelect = (id: string, value?: FilterValueType) => {\n\t\tconst selectedSchema = schema.find((schemaItem) => schemaItem.id === id);\n\t\tlet localSelectedIds = [...selectedIds];\n\t\tif (selectedSchema) {\n\t\t\t/**\n\t\t\t * only FilterType.Multiple, id can be present in selectedIds and selectedStateRef, so\n\t\t\t * delete id always except for FilterType.Multiple,\n\t\t\t *\n\t\t\t * for FilterType.Multiple,\n\t\t\t * \t\tif value.length === 0, delete id\n\t\t\t * \t\telse\n\t\t\t * \t\t\tjust update the value\n\t\t\t *\n\t\t\t */\n\n\t\t\tif (selectedSchema.type === FilterType.Multiple) {\n\t\t\t\t/** only update value i.e remove value from selectedItem.value */\n\t\t\t\tlocalSelectedIds = localSelectedIds\n\t\t\t\t\t.map((selected) => {\n\t\t\t\t\t\tif (selected.id === id) {\n\t\t\t\t\t\t\tconst newVal = (selected.value as SingleOption[]).filter(\n\t\t\t\t\t\t\t\t(val) => val.value !== (value as SingleOption).value,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (newVal.length) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...selected,\n\t\t\t\t\t\t\t\t\tvalue: newVal,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn selected;\n\t\t\t\t\t})\n\t\t\t\t\t.filter((selected) => !!selected) as {\n\t\t\t\t\tid: string;\n\t\t\t\t\tvalue: FilterValueType;\n\t\t\t\t}[];\n\n\t\t\t\tselectedStateRef.current = selectedStateRef.current\n\t\t\t\t\t.map((selectedItem) => {\n\t\t\t\t\t\tif (selectedItem.id === id) {\n\t\t\t\t\t\t\tconst newVal = (selectedItem.value as SingleOption[])?.filter(\n\t\t\t\t\t\t\t\t(val) => val.value !== (value as SingleOption).value,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (newVal.length) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...selectedItem,\n\t\t\t\t\t\t\t\t\tvalue: newVal,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn selectedItem;\n\t\t\t\t\t})\n\t\t\t\t\t.filter((selected) => !!selected) as SearchFilterOutputState[];\n\t\t\t} else {\n\t\t\t\t/** Delete */\n\t\t\t\tlocalSelectedIds = localSelectedIds.filter(\n\t\t\t\t\t(selected) => selected.id !== id,\n\t\t\t\t);\n\n\t\t\t\tselectedStateRef.current = selectedStateRef.current.filter(\n\t\t\t\t\t(selectedItem) => selectedItem.id !== id,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tonChange(selectedSchema.id, selectedStateRef.current, value);\n\n\t\t\tsetSelectedIds([...localSelectedIds]);\n\t\t}\n\t};\n\n\treturn (\n\t\t<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>\n\t\t\t<div\n\t\t\t\tdata-testid=\"search-filter-row\"\n\t\t\t\tstyle={{\n\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\tflexDirection: direction,\n\t\t\t\t\tgap: 8,\n\t\t\t\t\tflexWrap: 'wrap',\n\t\t\t\t\talignItems: direction === 'row' ? 'center' : 'self-start',\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{searchSchema && (\n\t\t\t\t\t<SearchBar\n\t\t\t\t\t\twidth={searchSchema.width?.toString() ?? '100%'}\n\t\t\t\t\t\tisEnabled={true}\n\t\t\t\t\t\tonChange={onSearchChange}\n\t\t\t\t\t\tonEnter={onSearchChange}\n\t\t\t\t\t\tplaceholder={searchSchema.text}\n\t\t\t\t\t\tvariant={'small'}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<div\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\tflexDirection: 'row',\n\t\t\t\t\t\tgap: 8,\n\t\t\t\t\t\tflexWrap: 'wrap',\n\t\t\t\t\t\talignItems: direction === 'row' ? 'center' : 'self-start',\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{schema\n\t\t\t\t\t\t.filter((filterItem) => filterItem.type !== FilterType.Search)\n\t\t\t\t\t\t.map((filterItem, i) => (\n\t\t\t\t\t\t\t<SearchFilterItem\n\t\t\t\t\t\t\t\t{...filterItem}\n\t\t\t\t\t\t\t\tkey={i}\n\t\t\t\t\t\t\t\tvariant={variant}\n\t\t\t\t\t\t\t\tonChange={(val) => {\n\t\t\t\t\t\t\t\t\tselect(filterItem.id, val);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t))}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{showSelectedChips && (\n\t\t\t\t<div\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\tflexDirection: 'row',\n\t\t\t\t\t\tgap: 8,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<FilterChipListRenderer\n\t\t\t\t\t\tselectedState={selectedStateRef.current}\n\t\t\t\t\t\tonDeSelect={deSelect}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"names":["SearchFilter","direction","schema","variant","onChange","showSelectedChips","selectedStateRef","useRef","filterItem","selectedIds","setSelectedIds","useState","searchSchema","FilterType","onSearchChange","searchText","select","id","value","selectedSchema","schemaItem","localSelectedIds","idx","el","selectedSchemaItem","deSelect","selected","newVal","val","selectedItem","jsxs","jsx","SearchBar","i","createElement","SearchFilterItem","FilterChipListRenderer"],"mappings":";;;;;;AAYO,MAAMA,IAA4C,CAAC;AAAA,EACzD,WAAAC,IAAY;AAAA,EACZ,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,mBAAAC;AACD,MAAM;AAEL,QAAMC,IAAmBC;AAAA,IACxBL,GACG,OAAO,CAACM,MAAeA,EAAW,YAAY,EAC/C;AAAA,MACA,CAACA,OACC;AAAA,QACA,IAAIA,EAAW;AAAA,QACf,OAAOA,EAAW;AAAA,QAClB,MAAMA,EAAW;AAAA,QACjB,MAAMA,EAAW;AAAA,MAAA;AAAA,IAClB,KACG,CAAA;AAAA,EAAC,GAGF,CAACC,GAAaC,CAAc,IAAIC,EAEpC,CAAA,CAAE,GAEEC,IAAeV,EAAO;AAAA,IAC3B,CAACM,MAAeA,EAAW,SAASK,EAAW;AAAA,EAAA,GAG1CC,IAAiB,CAACC,MAAuB;AAC9C,IAAIH,KAAgB,OAAOG,KAAe,YACzCC,EAAOJ,EAAa,IAAIG,CAAU;AAAA,EAEpC,GAEMC,IAAS,CAACC,GAAYC,MAA2B;AACtD,UAAMC,IAAiBjB,EAAO,KAAK,CAACkB,MAAeA,EAAW,OAAOH,CAAE,GACjEI,IA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A,YAAA;AAAA,UAAA;AAAA,UAGX,gBAAAmB;AAAA,YAAC;AAAA,YAAA;AAAA,cACA,OAAO;AAAA,gBACN,SAAS;AAAA,gBACT,eAAe;AAAA,gBACf,KAAK;AAAA,gBACL,UAAU;AAAA,gBACV,YAAY9B,MAAc,QAAQ,WAAW;AAAA,cAAA;AAAA,cAG7C,UAAAC,EACC,OAAO,CAACM,MAAeA,EAAW,SAASK,EAAW,MAAM,EAC5D,IAAI,CAACL,GAAYyB,MACjB,gBAAAC;AAAA,gBAACC;AAAA,gBAAA;AAAA,kBACC,GAAG3B;AAAA,kBACJ,KAAKyB;AAAA,kBACL,SAAA9B;AAAA,kBACA,UAAU,CAACyB,MAAQ;AAClB,oBAAAZ,EAAOR,EAAW,IAAIoB,CAAG;AAAA,kBAC1B;AAAA,gBAAA;AAAA,cAAA,CAED;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,IAEAvB,KACA,gBAAA0B;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,OAAO;AAAA,UACN,SAAS;AAAA,UACT,eAAe;AAAA,UACf,KAAK;AAAA,QAAA;AAAA,QAGN,UAAA,gBAAAA;AAAA,UAACK;AAAA,UAAA;AAAA,YACA,eAAe9B,EAAiB;AAAA,YAChC,YAAYmB;AAAA,UAAA;AAAA,QAAA;AAAA,MACb;AAAA,IAAA;AAAA,EACD,GAEF;AAEF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sources":["../../../../../src/components/agent-builder/constants/tools.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"tools.js","sources":["../../../../../src/components/agent-builder/constants/tools.ts"],"sourcesContent":["import type { ToolSource as ModelToolSource } from '@bikdotai/bik-models/ai-agents/models/agent-tool';\nimport type { FunctionComponent, SVGAttributes } from 'react';\n\n/**\n * Static tool-related constants for the builder's Step 3 (tools & sub-agents):\n * the reference-picker category tabs and the per-source display labels. Kept here\n * (rather than inline in the picker / serialization utils) so the labels a user\n * sees are all in one obvious place.\n */\n\n/** A reference-picker category tab. */\nexport type Category = 'tool' | 'subagent';\n\n/** Category tabs shown at the root of the `@` reference picker. */\nexport const CATEGORIES: { key: Category; label: string }[] = [\n\t{ key: 'tool', label: 'Tools' },\n\t{ key: 'subagent', label: 'Sub-agent' },\n];\n\n/**\n * Every tool \"source\" the builder renders an icon / label / picker entry for.\n * Enum VALUES are the backend's canonical read-only `source` wire strings\n * (`app/agents/config/schema.py` → `ToolSource`, derived from `tool_key`): the\n * configurable tools are `email_handover` / `rest_api` / `slack`, every native\n * tool is `manifest`. `shopify` / `integration` are legacy bik-models sources\n * kept for back-compat (the backend now collapses natives to `manifest`).\n * Dynamic/unknown sources are looked up leniently — see `toolSourceLabel` and\n * `sourceIcon`.\n *\n * This is the RUNTIME mirror of the canonical `@bikdotai/bik-models` `ToolSource`\n * union (the shape the backend persists as `AgentToolDoc.source`). We keep an\n * enum — not a re-export of the type — because the members are needed at runtime\n * for labels, ranks, icons and `===` comparisons; a type-only union can't do\n * that. The two are kept in lock-step by {@link ToolSourceMatchesBikModels}\n * below, which fails to compile if they ever drift.\n */\nexport enum ToolSource {\n\tManifest = 'manifest',\n\tShopify = 'shopify',\n\tBigcommerce = 'bigcommerce',\n\tShipstation = 'shipstation',\n\tIntegration = 'integration',\n\tRestApi = 'rest_api',\n\tEmailHandover = 'email_handover',\n\tSlack = 'slack',\n}\n\n/**\n * Compile-time guard that {@link ToolSource} stays a faithful mirror of the\n * canonical `@bikdotai/bik-models` `ToolSource` union. If a source is added to\n * (or removed from) either side without the other, `AssertTrue` receives `false`\n * and this type stops compiling — so the runtime enum can never silently diverge\n * from what the backend persists as `AgentToolDoc.source`. The tuple wrappers\n * (`[…]`) stop the conditionals from distributing over the unions, so it checks\n * set-equality in both directions.\n *\n * Type-only (erased at build): a drift shows up as a compile error on\n * `ToolSourceMatchesBikModels` telling you to reconcile this enum with\n * `@bikdotai/bik-models` (bump the dep and/or the enum).\n */\ntype AssertTrue<T extends true> = T;\ntype ToolSourceMatchesBikModels = AssertTrue<\n\t[`${ToolSource}`] extends [ModelToolSource]\n\t\t? [ModelToolSource] extends [`${ToolSource}`]\n\t\t\t? true\n\t\t\t: false\n\t\t: false\n>;\n\n/**\n * Display labels for the known tool sources — the CATEGORY/integration name, used\n * for the picker's source headers (drill-in groups), the empty-state source\n * buttons and the mention-chip prefix. A source is a category (\"Slack\") you drill\n * into; the specific addable action inside it (\"Send Slack message\") is\n * `TOOL_ACTION_LABELS`. Unknown sources fall back to the raw key (see\n * `toolSourceLabel`).\n */\nexport const TOOL_SOURCE_LABELS: Record<ToolSource, string> = {\n\t[ToolSource.Manifest]: 'Manifest',\n\t[ToolSource.Shopify]: 'Shopify',\n\t[ToolSource.Bigcommerce]: 'BigCommerce',\n\t[ToolSource.Shipstation]: 'ShipStation',\n\t[ToolSource.Integration]: 'Integration',\n\t[ToolSource.RestApi]: 'Rest API',\n\t[ToolSource.EmailHandover]: 'Email',\n\t[ToolSource.Slack]: 'Slack',\n};\n\n/**\n * The addable action inside a configurable/rest source — shown as the \"add\" row\n * in the `@` picker (below any existing instances) and the empty-state button.\n * Distinct from `TOOL_SOURCE_LABELS`, which names the category the action lives in\n * (e.g. category \"Slack\" → action \"Send Slack message\").\n */\nexport const TOOL_ACTION_LABELS: Partial<Record<ToolSource, string>> = {\n\t[ToolSource.RestApi]: 'REST API',\n\t[ToolSource.EmailHandover]: 'Handover to email',\n\t[ToolSource.Slack]: 'Send Slack message',\n};\n\n/** A tool source's brand-glyph component. */\nexport type IconComp = FunctionComponent<SVGAttributes<SVGElement>>;\n\n/** Brand glyph for a tool source, with its own size so each keeps its aspect ratio. */\nexport interface SourceIcon {\n\tIcon: IconComp;\n\tw: number;\n\th: number;\n}\n\n/**\n * A built-in \"tool\" that opens a config drawer (Rest API / email handover /\n * Slack) rather than inserting a mention. Surfaced as an empty-state source\n * button in the Tools section and as a row in the `@`-picker Tools view; picking\n * it opens the drawer and never writes into the instructions text.\n */\nexport interface ToolAction {\n\tsource: ToolSource;\n\tlabel: string;\n\ticon?: SourceIcon;\n\t/** Open this tool's config drawer. */\n\tonSelect: () => void;\n\t/**\n\t * Integration connection state for this source. `undefined` = no connection\n\t * gating (default). `false` = the store hasn't connected this integration →\n\t * the `@` picker shows a \"Connect\" row that calls {@link onConnect} instead of\n\t * drilling in / offering \"Create new\". `true` = connected (renders normally).\n\t * Set by the consumer via `config.integrationStatus` (today: Slack only).\n\t */\n\tconnected?: boolean;\n\t/** Open the parent's connect flow for this source (used when `connected === false`). */\n\tonConnect?: () => void;\n}\n\n/** Sources of the built-in drawer tools, in display order. */\nexport const TOOL_ACTION_SOURCES: ToolSource[] = [\n\tToolSource.RestApi,\n\tToolSource.EmailHandover,\n\tToolSource.Slack,\n];\n\n/**\n * Fixed display rank for the `@`-picker's tool-source groups (lower = higher). The\n * picker sorts its source rows by this so adding/updating a tool never reshuffles\n * them. Any source not listed here (dynamic/unknown, e.g. Integration) sorts AFTER\n * Slack, keeping its discovery order among the rest (Array.sort is stable).\n */\nexport const TOOL_SOURCE_RANK: Partial<Record<ToolSource, number>> = {\n\t[ToolSource.Shopify]: 0,\n\t[ToolSource.Bigcommerce]: 1,\n\t[ToolSource.Shipstation]: 2,\n\t[ToolSource.RestApi]: 3,\n\t[ToolSource.EmailHandover]: 4,\n\t[ToolSource.Slack]: 5,\n\t// Manifest is intentionally omitted so it sorts AFTER the integration sources\n\t// (unknown/unranked → last). The generic \"Manifest\" group is being phased out.\n};\n\nconst UNRANKED_SOURCE_RANK = Object.keys(TOOL_SOURCE_RANK).length;\n\n/** Sort rank for a source string; unknown sources rank after all known ones. */\nexport const toolSourceRank = (source: string): number =>\n\tTOOL_SOURCE_RANK[source as ToolSource] ?? UNRANKED_SOURCE_RANK;\n\n/**\n * `tool_key` of a configurable shared-drawer tool (email / Slack). Lives here (not\n * in AgentBuilder.model) so this leaf constants file has no back-edge to the model\n * — the dependency stays one-way (model → constants), avoiding a circular import.\n */\nexport type ConfigToolKey = 'send_email' | 'send_slack_message';\n\n/**\n * Drawer sources rendered by the shared dynamic panel (`ConfigToolPanel`), each\n * mapped to its backend `tool_key`. Rest API is absent — it has a bespoke panel.\n */\nexport const CONFIG_TOOL_SOURCES: Partial<Record<ToolSource, ConfigToolKey>> = {\n\t[ToolSource.EmailHandover]: 'send_email',\n\t[ToolSource.Slack]: 'send_slack_message',\n};\n"],"names":["CATEGORIES","ToolSource","TOOL_SOURCE_LABELS","TOOL_ACTION_LABELS","TOOL_ACTION_SOURCES","TOOL_SOURCE_RANK","UNRANKED_SOURCE_RANK","toolSourceRank","source","CONFIG_TOOL_SOURCES"],"mappings":"AAcO,MAAMA,IAAiD;AAAA,EAC7D,EAAE,KAAK,QAAQ,OAAO,QAAA;AAAA,EACtB,EAAE,KAAK,YAAY,OAAO,YAAA;AAC3B;AAmBO,IAAKC,sBAAAA,OACXA,EAAA,WAAW,YACXA,EAAA,UAAU,WACVA,EAAA,cAAc,eACdA,EAAA,cAAc,eACdA,EAAA,cAAc,eACdA,EAAA,UAAU,YACVA,EAAA,gBAAgB,kBAChBA,EAAA,QAAQ,SARGA,IAAAA,KAAA,CAAA,CAAA;AAyCL,MAAMC,IAAiD;AAAA,EAC5D,UAAsB;AAAA,EACtB,SAAqB;AAAA,EACrB,aAAyB;AAAA,EACzB,aAAyB;AAAA,EACzB,aAAyB;AAAA,EACzB,UAAqB;AAAA,EACrB,gBAA2B;AAAA,EAC3B,OAAmB;AACrB,GAQaC,IAA0D;AAAA,EACrE,UAAqB;AAAA,EACrB,gBAA2B;AAAA,EAC3B,OAAmB;AACrB,GAqCaC,IAAoC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA;AACD,GAQaC,IAAwD;AAAA,EACnE,SAAqB;AAAA,EACrB,aAAyB;AAAA,EACzB,aAAyB;AAAA,EACzB,UAAqB;AAAA,EACrB,gBAA2B;AAAA,EAC3B,OAAmB;AAAA;AAAA;AAGrB,GAEMC,IAAuB,OAAO,KAAKD,CAAgB,EAAE,QAG9CE,IAAiB,CAACC,MAC9BH,EAAiBG,CAAoB,KAAKF,GAa9BG,IAAkE;AAAA,EAC7E,gBAA2B;AAAA,EAC3B,OAAmB;AACrB;"}
|