@bikdotai/bik-component-library 0.0.863-beta.6 → 0.0.863
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/agent-builder/AgentBuilder.js +1 -1
- package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js +42 -174
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionPicker.js +1 -1
- package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js +3 -3
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/cjs/components/agent-builder/constants/steps.js +1 -1
- package/dist/cjs/components/agent-builder/constants/steps.js.map +1 -1
- package/dist/cjs/components/agent-builder/constants/tools.js +1 -1
- package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -1
- package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
- package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step1About.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step1About.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js +2 -2
- package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
- package/dist/cjs/components/agent-builder/utils/sourceIcons.js.map +1 -1
- package/dist/cjs/components/agent-listing/AgentTableRow.js +1 -1
- package/dist/cjs/components/agent-listing/AgentTableRow.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.js +99 -105
- package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.model.d.ts +0 -76
- package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +0 -91
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js +93 -271
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.js +27 -27
- package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/esm/components/agent-builder/components/SelectableListSection.js +42 -34
- package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/esm/components/agent-builder/constants/steps.d.ts +1 -31
- package/dist/esm/components/agent-builder/constants/steps.js +6 -15
- package/dist/esm/components/agent-builder/constants/steps.js.map +1 -1
- package/dist/esm/components/agent-builder/constants/tools.d.ts +6 -5
- package/dist/esm/components/agent-builder/constants/tools.js +24 -21
- package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +1 -13
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +175 -192
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/esm/components/agent-builder/index.d.ts +2 -7
- package/dist/esm/components/agent-builder/steps/Step1About.js +13 -15
- package/dist/esm/components/agent-builder/steps/Step1About.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js +49 -54
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step4HandoverRules.d.ts +0 -11
- package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js +23 -127
- package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/sourceIcons.d.ts +4 -0
- package/dist/esm/components/agent-builder/utils/sourceIcons.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentTableRow.js +38 -71
- package/dist/esm/components/agent-listing/AgentTableRow.js.map +1 -1
- package/dist/esm/index.js +634 -644
- package/dist/esm/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/cjs/components/agent-builder/components/AgentStateModal.js +0 -2
- package/dist/cjs/components/agent-builder/components/AgentStateModal.js.map +0 -1
- package/dist/cjs/components/agent-builder/components/ChannelSelectModal.js +0 -2
- package/dist/cjs/components/agent-builder/components/ChannelSelectModal.js.map +0 -1
- package/dist/cjs/components/agent-builder/components/ChannelsSection.js +0 -2
- package/dist/cjs/components/agent-builder/components/ChannelsSection.js.map +0 -1
- package/dist/cjs/components/agent-builder/constants/channels.js +0 -2
- package/dist/cjs/components/agent-builder/constants/channels.js.map +0 -1
- package/dist/esm/components/agent-builder/components/AgentStateModal.d.ts +0 -47
- package/dist/esm/components/agent-builder/components/AgentStateModal.js +0 -82
- package/dist/esm/components/agent-builder/components/AgentStateModal.js.map +0 -1
- package/dist/esm/components/agent-builder/components/ChannelSelectModal.d.ts +0 -26
- package/dist/esm/components/agent-builder/components/ChannelSelectModal.js +0 -121
- package/dist/esm/components/agent-builder/components/ChannelSelectModal.js.map +0 -1
- package/dist/esm/components/agent-builder/components/ChannelsSection.d.ts +0 -10
- package/dist/esm/components/agent-builder/components/ChannelsSection.js +0 -183
- package/dist/esm/components/agent-builder/components/ChannelsSection.js.map +0 -1
- package/dist/esm/components/agent-builder/constants/channels.d.ts +0 -56
- package/dist/esm/components/agent-builder/constants/channels.js +0 -41
- package/dist/esm/components/agent-builder/constants/channels.js.map +0 -1
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { jsxs as d, jsx as n, Fragment as E } from "react/jsx-runtime";
|
|
2
|
-
import w from "../../../assets/icons/edit.svg.js";
|
|
3
|
-
import A from "../../../assets/icons/errorInfo.svg.js";
|
|
4
|
-
import { useState as M, useMemo as N } from "react";
|
|
5
|
-
import { TitleSmall as v } from "../../TypographyStyle.js";
|
|
6
|
-
import { COLORS as T } from "../../../constants/Theme.js";
|
|
7
|
-
import { ChannelsSectionRoot as B, ChannelCard as L, ChannelRow as O, ChannelRowMain as R, CHECKBOX_SLOT as k, ChannelIdentity as P, ChannelGlyph as j, ChannelChips as D, ChipTooltipTarget as f } from "../AgentBuilder.styled.js";
|
|
8
|
-
import { channelPresentation as _, selectedAccounts as z, isAccountDisconnected as S } from "../constants/channels.js";
|
|
9
|
-
import { useAgentBuilderContext as F } from "../context/AgentBuilderContext.js";
|
|
10
|
-
import { ChannelSelectModal as H } from "./ChannelSelectModal.js";
|
|
11
|
-
import { CheckBox as V } from "../../checkBox/CheckBox.js";
|
|
12
|
-
import { Tooltip as I } from "../../tooltips/Tooltip.js";
|
|
13
|
-
import { Tag as C } from "../../tag/Tag.js";
|
|
14
|
-
import { IconButton as X } from "../../icon-button/IconButton.js";
|
|
15
|
-
const b = 3, G = (e) => [
|
|
16
|
-
...e.filter(S),
|
|
17
|
-
...e.filter((i) => !S(i))
|
|
18
|
-
], K = () => {
|
|
19
|
-
const { value: e, updateField: i, availableChannels: r, onManageChannels: p } = F(), [a, c] = M(null), m = N(() => {
|
|
20
|
-
const t = /* @__PURE__ */ new Map();
|
|
21
|
-
return (e.channels ?? []).forEach((l) => t.set(l.type, l.channelIds)), t;
|
|
22
|
-
}, [e.channels]);
|
|
23
|
-
if (!r || r.length === 0)
|
|
24
|
-
return null;
|
|
25
|
-
const g = (t, l) => {
|
|
26
|
-
const h = (e.channels ?? []).filter((u) => u.type !== t);
|
|
27
|
-
i(
|
|
28
|
-
"channels",
|
|
29
|
-
l.length > 0 ? [...h, { type: t, channelIds: l }] : h
|
|
30
|
-
);
|
|
31
|
-
}, o = r.find((t) => t.type === a) ?? null;
|
|
32
|
-
return /* @__PURE__ */ d(B, { children: [
|
|
33
|
-
/* @__PURE__ */ n(v, { color: T.content.primary, children: "Channels to activate it on" }),
|
|
34
|
-
r.map((t) => /* @__PURE__ */ n(
|
|
35
|
-
U,
|
|
36
|
-
{
|
|
37
|
-
channel: t,
|
|
38
|
-
selectedIds: m.get(t.type) ?? [],
|
|
39
|
-
onSelectionChange: (l) => g(t.type, l),
|
|
40
|
-
onEdit: () => c(t.type)
|
|
41
|
-
},
|
|
42
|
-
String(t.type)
|
|
43
|
-
)),
|
|
44
|
-
/* @__PURE__ */ n(
|
|
45
|
-
H,
|
|
46
|
-
{
|
|
47
|
-
channel: o,
|
|
48
|
-
selectedIds: o ? m.get(o.type) ?? [] : [],
|
|
49
|
-
onClose: () => c(null),
|
|
50
|
-
onApply: (t) => {
|
|
51
|
-
o && g(o.type, t), c(null);
|
|
52
|
-
},
|
|
53
|
-
onManageChannels: p && o ? () => p(o.type) : void 0
|
|
54
|
-
}
|
|
55
|
-
)
|
|
56
|
-
] });
|
|
57
|
-
};
|
|
58
|
-
K.displayName = "ChannelsSection";
|
|
59
|
-
const U = ({
|
|
60
|
-
channel: e,
|
|
61
|
-
selectedIds: i,
|
|
62
|
-
onSelectionChange: r,
|
|
63
|
-
onEdit: p
|
|
64
|
-
}) => {
|
|
65
|
-
const { label: a, Icon: c, tint: m, accountsNoun: g } = _(
|
|
66
|
-
e.type,
|
|
67
|
-
e.label
|
|
68
|
-
), o = e.accounts.length === 0, t = z(e, i), l = !o && t.length === e.accounts.length, h = t.length > 0 && !l, u = G(t.length > 0 ? t : e.accounts), x = u.slice(0, b), y = u.slice(b), $ = () => r(
|
|
69
|
-
l ? [] : e.accounts.map((s) => s.channelId)
|
|
70
|
-
);
|
|
71
|
-
return /* @__PURE__ */ n(
|
|
72
|
-
L,
|
|
73
|
-
{
|
|
74
|
-
"data-test": `agent-channel-${e.type}`,
|
|
75
|
-
role: "group",
|
|
76
|
-
"aria-label": a,
|
|
77
|
-
children: /* @__PURE__ */ d(O, { children: [
|
|
78
|
-
/* @__PURE__ */ d(R, { children: [
|
|
79
|
-
/* @__PURE__ */ n(
|
|
80
|
-
V,
|
|
81
|
-
{
|
|
82
|
-
isChecked: l || h,
|
|
83
|
-
isPartiallyChecked: h,
|
|
84
|
-
isDisabled: o,
|
|
85
|
-
ariaLabel: a,
|
|
86
|
-
onValueChange: $,
|
|
87
|
-
style: k
|
|
88
|
-
}
|
|
89
|
-
),
|
|
90
|
-
/* @__PURE__ */ d(P, { children: [
|
|
91
|
-
/* @__PURE__ */ n(j, { tint: m, children: c && /* @__PURE__ */ n(c, { size: 16 }) }),
|
|
92
|
-
/* @__PURE__ */ n(v, { color: T.content.primary, children: a })
|
|
93
|
-
] }),
|
|
94
|
-
/* @__PURE__ */ n(D, { children: o ? /* @__PURE__ */ n(
|
|
95
|
-
I,
|
|
96
|
-
{
|
|
97
|
-
body: `No ${g} are connected to this store yet. Connect one from channel management to activate this agent on ${a}.`,
|
|
98
|
-
placement: "top",
|
|
99
|
-
children: /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n(
|
|
100
|
-
C,
|
|
101
|
-
{
|
|
102
|
-
tagText: "Disabled",
|
|
103
|
-
type: "neutral",
|
|
104
|
-
variant: "regular",
|
|
105
|
-
height: 24,
|
|
106
|
-
cursor: "default"
|
|
107
|
-
}
|
|
108
|
-
) })
|
|
109
|
-
}
|
|
110
|
-
) : /* @__PURE__ */ d(E, { children: [
|
|
111
|
-
x.map((s) => /* @__PURE__ */ n(
|
|
112
|
-
q,
|
|
113
|
-
{
|
|
114
|
-
account: s,
|
|
115
|
-
channelLabel: a
|
|
116
|
-
},
|
|
117
|
-
s.channelId
|
|
118
|
-
)),
|
|
119
|
-
y.length > 0 && /* @__PURE__ */ n(
|
|
120
|
-
I,
|
|
121
|
-
{
|
|
122
|
-
body: y.map((s) => s.channelName).join(", "),
|
|
123
|
-
placement: "top",
|
|
124
|
-
children: /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n(
|
|
125
|
-
C,
|
|
126
|
-
{
|
|
127
|
-
tagText: `+${y.length}`,
|
|
128
|
-
type: "purple",
|
|
129
|
-
variant: "regular",
|
|
130
|
-
height: 24,
|
|
131
|
-
cursor: "default"
|
|
132
|
-
}
|
|
133
|
-
) })
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
] }) })
|
|
137
|
-
] }),
|
|
138
|
-
/* @__PURE__ */ n(
|
|
139
|
-
X,
|
|
140
|
-
{
|
|
141
|
-
"data-test": `agent-channel-${e.type}-edit`,
|
|
142
|
-
"aria-label": `Edit ${a} channels`,
|
|
143
|
-
Icon: w,
|
|
144
|
-
size: "xs",
|
|
145
|
-
iconPadding: 4,
|
|
146
|
-
disabled: o,
|
|
147
|
-
onClick: p
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
] })
|
|
151
|
-
}
|
|
152
|
-
);
|
|
153
|
-
}, q = ({ account: e, channelLabel: i }) => S(e) ? /* @__PURE__ */ n(
|
|
154
|
-
I,
|
|
155
|
-
{
|
|
156
|
-
body: `${e.channelName} is disconnected. This agent won't run on it until you reconnect it from ${i} channel management.`,
|
|
157
|
-
placement: "top",
|
|
158
|
-
children: /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n(
|
|
159
|
-
C,
|
|
160
|
-
{
|
|
161
|
-
tagText: e.channelName,
|
|
162
|
-
type: "negative",
|
|
163
|
-
variant: "regular",
|
|
164
|
-
height: 24,
|
|
165
|
-
LeadingIcon: A,
|
|
166
|
-
leadingIconId: `channel-error-${e.channelId}`,
|
|
167
|
-
cursor: "default"
|
|
168
|
-
}
|
|
169
|
-
) })
|
|
170
|
-
}
|
|
171
|
-
) : /* @__PURE__ */ n(
|
|
172
|
-
C,
|
|
173
|
-
{
|
|
174
|
-
tagText: e.channelName,
|
|
175
|
-
type: "purple",
|
|
176
|
-
variant: "regular",
|
|
177
|
-
height: 24
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
export {
|
|
181
|
-
K as ChannelsSection
|
|
182
|
-
};
|
|
183
|
-
//# sourceMappingURL=ChannelsSection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChannelsSection.js","sources":["../../../../../src/components/agent-builder/components/ChannelsSection.tsx"],"sourcesContent":["import EditIcon from '@src/assets/icons/edit.svg';\nimport ErrorInfoIcon from '@src/assets/icons/errorInfo.svg';\nimport React, { useMemo, useState } from 'react';\nimport { CheckBox } from '@src/components/checkBox';\nimport { IconButton } from '@src/components/icon-button';\nimport { Tag } from '@src/components/tag';\nimport { Tooltip } from '@src/components/tooltips';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport type {\n\tAgentChannel,\n\tAgentChannelAccount,\n\tAgentChannelType,\n} from '../AgentBuilder.model';\nimport {\n\tChannelCard,\n\tChannelChips,\n\tChannelGlyph,\n\tChannelIdentity,\n\tChannelRow,\n\tChannelRowMain,\n\tChannelsSectionRoot,\n\tCHECKBOX_SLOT,\n\tChipTooltipTarget,\n} from '../AgentBuilder.styled';\nimport {\n\tchannelPresentation,\n\tisAccountDisconnected,\n\tselectedAccounts,\n} from '../constants/channels';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\nimport { ChannelSelectModal } from './ChannelSelectModal';\n\n/**\n * How many account chips a row shows before collapsing the rest into \"+N\". The\n * design draws three; without a cap a store with a dozen numbers pushes the row\n * well past its 48px height.\n */\nconst MAX_VISIBLE_CHIPS = 3;\n\n/**\n * Chips for a row: disconnected accounts first so a cap can never hide the very\n * thing the merchant needs to act on, then the rest in their original order.\n */\nconst chipOrder = (accounts: AgentChannelAccount[]): AgentChannelAccount[] => [\n\t...accounts.filter(isAccountDisconnected),\n\t...accounts.filter((a) => !isAccountDisconnected(a)),\n];\n\n/**\n * Step 1's \"Channels to activate it on\" — one card per connected channel, each\n * with a select-all checkbox, the accounts it covers as chips, and an edit\n * button that opens the per-account picker.\n *\n * Renders nothing when the consumer passes no `availableChannels`, so a host\n * that hasn't wired channels up yet sees the step exactly as it was.\n */\nexport const ChannelsSection: React.FC = () => {\n\tconst { value, updateField, availableChannels, onManageChannels } =\n\t\tuseAgentBuilderContext();\n\n\t// Which channel's picker is open (by type); null = closed.\n\tconst [editingType, setEditingType] = useState<AgentChannelType | null>(null);\n\n\t// Selection is stored as a list; index it once so each row is a lookup.\n\tconst selectionByType = useMemo(() => {\n\t\tconst map = new Map<AgentChannelType, string[]>();\n\t\t(value.channels ?? []).forEach((c) => map.set(c.type, c.channelIds));\n\t\treturn map;\n\t}, [value.channels]);\n\n\tif (!availableChannels || availableChannels.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst setSelection = (type: AgentChannelType, channelIds: string[]) => {\n\t\tconst rest = (value.channels ?? []).filter((c) => c.type !== type);\n\t\t// An empty selection drops the channel entirely rather than persisting a\n\t\t// `{ type, channelIds: [] }` no-op the backend would have to filter out.\n\t\tupdateField(\n\t\t\t'channels',\n\t\t\tchannelIds.length > 0 ? [...rest, { type, channelIds }] : rest,\n\t\t);\n\t};\n\n\tconst editingChannel =\n\t\tavailableChannels.find((c) => c.type === editingType) ?? null;\n\n\treturn (\n\t\t<ChannelsSectionRoot>\n\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\tChannels to activate it on\n\t\t\t</TitleSmall>\n\n\t\t\t{availableChannels.map((channel) => (\n\t\t\t\t<ChannelCardRow\n\t\t\t\t\tkey={String(channel.type)}\n\t\t\t\t\tchannel={channel}\n\t\t\t\t\tselectedIds={selectionByType.get(channel.type) ?? []}\n\t\t\t\t\tonSelectionChange={(ids) => setSelection(channel.type, ids)}\n\t\t\t\t\tonEdit={() => setEditingType(channel.type)}\n\t\t\t\t/>\n\t\t\t))}\n\n\t\t\t<ChannelSelectModal\n\t\t\t\tchannel={editingChannel}\n\t\t\t\tselectedIds={\n\t\t\t\t\teditingChannel ? selectionByType.get(editingChannel.type) ?? [] : []\n\t\t\t\t}\n\t\t\t\tonClose={() => setEditingType(null)}\n\t\t\t\tonApply={(ids) => {\n\t\t\t\t\tif (editingChannel) {\n\t\t\t\t\t\tsetSelection(editingChannel.type, ids);\n\t\t\t\t\t}\n\t\t\t\t\tsetEditingType(null);\n\t\t\t\t}}\n\t\t\t\tonManageChannels={\n\t\t\t\t\tonManageChannels && editingChannel\n\t\t\t\t\t\t? () => onManageChannels(editingChannel.type)\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t/>\n\t\t</ChannelsSectionRoot>\n\t);\n};\n\nChannelsSection.displayName = 'ChannelsSection';\n\ninterface ChannelCardRowProps {\n\tchannel: AgentChannel;\n\tselectedIds: string[];\n\tonSelectionChange: (channelIds: string[]) => void;\n\tonEdit: () => void;\n}\n\nconst ChannelCardRow: React.FC<ChannelCardRowProps> = ({\n\tchannel,\n\tselectedIds,\n\tonSelectionChange,\n\tonEdit,\n}) => {\n\tconst { label, Icon, tint, accountsNoun } = channelPresentation(\n\t\tchannel.type,\n\t\tchannel.label,\n\t);\n\n\t/**\n\t * Zero state — the store supports this channel but has nothing connected\n\t * under it. Nothing on the row is actionable, so the checkbox and the edit\n\t * button are both inert and a \"Disabled\" chip stands in for the accounts.\n\t */\n\tconst isUnavailable = channel.accounts.length === 0;\n\n\tconst selected = selectedAccounts(channel, selectedIds);\n\tconst allSelected =\n\t\t!isUnavailable && selected.length === channel.accounts.length;\n\tconst someSelected = selected.length > 0 && !allSelected;\n\n\t// With nothing picked yet the row shows the store's inventory — that's the\n\t// state the design draws, and it tells the merchant what's on offer. Once\n\t// they've picked, the chips narrow to what the agent actually runs on.\n\tconst shown = chipOrder(selected.length > 0 ? selected : channel.accounts);\n\tconst visible = shown.slice(0, MAX_VISIBLE_CHIPS);\n\tconst overflow = shown.slice(MAX_VISIBLE_CHIPS);\n\n\tconst toggleAll = () =>\n\t\tonSelectionChange(\n\t\t\tallSelected ? [] : channel.accounts.map((a) => a.channelId),\n\t\t);\n\n\treturn (\n\t\t<ChannelCard\n\t\t\tdata-test={`agent-channel-${channel.type}`}\n\t\t\t// A card groups a channel's checkbox, chips and edit button; naming the\n\t\t\t// group lets assistive tech (and tests) address one channel at a time.\n\t\t\trole=\"group\"\n\t\t\taria-label={label}\n\t\t>\n\t\t\t<ChannelRow>\n\t\t\t\t<ChannelRowMain>\n\t\t\t\t\t<CheckBox\n\t\t\t\t\t\tisChecked={allSelected || someSelected}\n\t\t\t\t\t\tisPartiallyChecked={someSelected}\n\t\t\t\t\t\tisDisabled={isUnavailable}\n\t\t\t\t\t\tariaLabel={label}\n\t\t\t\t\t\tonValueChange={toggleAll}\n\t\t\t\t\t\tstyle={CHECKBOX_SLOT}\n\t\t\t\t\t/>\n\t\t\t\t\t<ChannelIdentity>\n\t\t\t\t\t\t<ChannelGlyph tint={tint}>\n\t\t\t\t\t\t\t{Icon && <Icon size={16} />}\n\t\t\t\t\t\t</ChannelGlyph>\n\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t\t\t</ChannelIdentity>\n\n\t\t\t\t\t<ChannelChips>\n\t\t\t\t\t\t{isUnavailable ? (\n\t\t\t\t\t\t\t<Tooltip\n\t\t\t\t\t\t\t\tbody={`No ${accountsNoun} are connected to this store yet. Connect one from channel management to activate this agent on ${label}.`}\n\t\t\t\t\t\t\t\tplacement=\"top\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ChipTooltipTarget>\n\t\t\t\t\t\t\t\t\t<Tag\n\t\t\t\t\t\t\t\t\t\ttagText=\"Disabled\"\n\t\t\t\t\t\t\t\t\t\ttype=\"neutral\"\n\t\t\t\t\t\t\t\t\t\tvariant=\"regular\"\n\t\t\t\t\t\t\t\t\t\theight={24}\n\t\t\t\t\t\t\t\t\t\tcursor=\"default\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ChipTooltipTarget>\n\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{visible.map((account) => (\n\t\t\t\t\t\t\t\t\t<AccountChip\n\t\t\t\t\t\t\t\t\t\tkey={account.channelId}\n\t\t\t\t\t\t\t\t\t\taccount={account}\n\t\t\t\t\t\t\t\t\t\tchannelLabel={label}\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{overflow.length > 0 && (\n\t\t\t\t\t\t\t\t\t<Tooltip\n\t\t\t\t\t\t\t\t\t\tbody={overflow.map((a) => a.channelName).join(', ')}\n\t\t\t\t\t\t\t\t\t\tplacement=\"top\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<ChipTooltipTarget>\n\t\t\t\t\t\t\t\t\t\t\t<Tag\n\t\t\t\t\t\t\t\t\t\t\t\ttagText={`+${overflow.length}`}\n\t\t\t\t\t\t\t\t\t\t\t\ttype=\"purple\"\n\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"regular\"\n\t\t\t\t\t\t\t\t\t\t\t\theight={24}\n\t\t\t\t\t\t\t\t\t\t\t\tcursor=\"default\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</ChipTooltipTarget>\n\t\t\t\t\t\t\t\t\t</Tooltip>\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\t</ChannelChips>\n\t\t\t\t</ChannelRowMain>\n\n\t\t\t\t<IconButton\n\t\t\t\t\tdata-test={`agent-channel-${channel.type}-edit`}\n\t\t\t\t\taria-label={`Edit ${label} channels`}\n\t\t\t\t\tIcon={EditIcon}\n\t\t\t\t\tsize=\"xs\"\n\t\t\t\t\ticonPadding={4}\n\t\t\t\t\tdisabled={isUnavailable}\n\t\t\t\t\tonClick={onEdit}\n\t\t\t\t/>\n\t\t\t</ChannelRow>\n\t\t</ChannelCard>\n\t);\n};\n\n/**\n * One account chip. A healthy account reads as a brand chip; a disconnected one\n * turns negative and gains the error glyph.\n *\n * The tooltip is NOT in the design — but a bare red chip tells the merchant\n * something is broken and nothing about what to do, so it names the account and\n * the fix.\n */\nconst AccountChip: React.FC<{\n\taccount: AgentChannelAccount;\n\tchannelLabel: string;\n}> = ({ account, channelLabel }) => {\n\tif (!isAccountDisconnected(account)) {\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\ttagText={account.channelName}\n\t\t\t\ttype=\"purple\"\n\t\t\t\tvariant=\"regular\"\n\t\t\t\theight={24}\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Tooltip\n\t\t\tbody={`${account.channelName} is disconnected. This agent won't run on it until you reconnect it from ${channelLabel} channel management.`}\n\t\t\tplacement=\"top\"\n\t\t>\n\t\t\t<ChipTooltipTarget>\n\t\t\t\t<Tag\n\t\t\t\t\ttagText={account.channelName}\n\t\t\t\t\ttype=\"negative\"\n\t\t\t\t\tvariant=\"regular\"\n\t\t\t\t\theight={24}\n\t\t\t\t\tLeadingIcon={ErrorInfoIcon}\n\t\t\t\t\t// Tag doesn't spread rest props, so `data-test` would be dropped —\n\t\t\t\t\t// `leadingIconId` is the one hook it does put on the DOM, which gives\n\t\t\t\t\t// the error glyph a stable handle for tests and e2e.\n\t\t\t\t\tleadingIconId={`channel-error-${account.channelId}`}\n\t\t\t\t\tcursor=\"default\"\n\t\t\t\t/>\n\t\t\t</ChipTooltipTarget>\n\t\t</Tooltip>\n\t);\n};\n"],"names":["MAX_VISIBLE_CHIPS","chipOrder","accounts","isAccountDisconnected","a","ChannelsSection","value","updateField","availableChannels","onManageChannels","useAgentBuilderContext","editingType","setEditingType","useState","selectionByType","useMemo","map","c","setSelection","type","channelIds","rest","editingChannel","ChannelsSectionRoot","jsx","TitleSmall","COLORS","channel","ChannelCardRow","ids","ChannelSelectModal","selectedIds","onSelectionChange","onEdit","label","Icon","tint","accountsNoun","channelPresentation","isUnavailable","selected","selectedAccounts","allSelected","someSelected","shown","visible","overflow","toggleAll","ChannelCard","ChannelRow","jsxs","ChannelRowMain","CheckBox","CHECKBOX_SLOT","ChannelIdentity","ChannelGlyph","ChannelChips","Tooltip","ChipTooltipTarget","Tag","Fragment","account","AccountChip","IconButton","EditIcon","channelLabel","ErrorInfoIcon"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAMA,IAAoB,GAMpBC,IAAY,CAACC,MAA2D;AAAA,EAC7E,GAAGA,EAAS,OAAOC,CAAqB;AAAA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default as React } from 'react';
|
|
2
|
-
import { AgentChannel, AgentChannelAccount, AgentChannelType } from '../AgentBuilder.model';
|
|
3
|
-
/** How one channel type renders: its label, brand glyph, tint and copy noun. */
|
|
4
|
-
export interface ChannelPresentation {
|
|
5
|
-
/** Row label ("WhatsApp", "Email", …). */
|
|
6
|
-
label: string;
|
|
7
|
-
/** Brand glyph. Undefined for an unknown type — the row renders label-only. */
|
|
8
|
-
Icon?: React.FC<React.SVGProps<SVGSVGElement> & {
|
|
9
|
-
size?: number | string;
|
|
10
|
-
}>;
|
|
11
|
-
/** Tint behind the glyph. */
|
|
12
|
-
tint: string;
|
|
13
|
-
/**
|
|
14
|
-
* What an account IS on this channel, plural — drives the picker's copy
|
|
15
|
-
* ("Select from available WhatsApp numbers"). Kept per-channel because the
|
|
16
|
-
* design's WhatsApp-only wording has to generalise once the same picker opens
|
|
17
|
-
* for Email and Instagram.
|
|
18
|
-
*/
|
|
19
|
-
accountsNoun: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Keyed by the shared `Channels` enum, so a channel key can never drift from the
|
|
23
|
-
* platform's spelling.
|
|
24
|
-
*
|
|
25
|
-
* Typed `Record<AgentChannelType, …>` rather than `Record<string, …>`: that makes
|
|
26
|
-
* the map EXHAUSTIVE, so widening {@link AgentChannelType} without adding the
|
|
27
|
-
* matching presentation here is a compile error rather than a channel that
|
|
28
|
-
* silently renders with no glyph.
|
|
29
|
-
*/
|
|
30
|
-
export declare const CHANNEL_PRESENTATION: Record<AgentChannelType, ChannelPresentation>;
|
|
31
|
-
/** The channel types the builder supports, in display order. */
|
|
32
|
-
export declare const AGENT_CHANNEL_TYPES: AgentChannelType[];
|
|
33
|
-
/**
|
|
34
|
-
* Presentation for a channel.
|
|
35
|
-
*
|
|
36
|
-
* `AgentChannelType` makes the registry hit total at compile time, but the
|
|
37
|
-
* `availableChannels` a consumer passes come off a backend response — so an
|
|
38
|
-
* unrecognised `type` is still handled defensively (the consumer's `label`, then
|
|
39
|
-
* the raw value, with no glyph) rather than rendering `undefined`.
|
|
40
|
-
*/
|
|
41
|
-
export declare const channelPresentation: (type: AgentChannelType, labelOverride?: string) => ChannelPresentation;
|
|
42
|
-
/** True when the store hasn't got a healthy connection to this account. */
|
|
43
|
-
export declare const isAccountDisconnected: (account: AgentChannelAccount) => boolean;
|
|
44
|
-
/**
|
|
45
|
-
* The accounts the agent is actually activated on, in the channel's own order.
|
|
46
|
-
* Selection is stored as backend ids, so an id that no longer exists on the
|
|
47
|
-
* store (channel removed since the agent was saved) simply drops out here.
|
|
48
|
-
*/
|
|
49
|
-
export declare const selectedAccounts: (channel: AgentChannel, selectedIds: string[]) => AgentChannelAccount[];
|
|
50
|
-
/**
|
|
51
|
-
* Selected accounts the store can no longer reach. Drives the row alert and the
|
|
52
|
-
* chips' negative styling. A disconnected account is deliberately NOT dropped
|
|
53
|
-
* from the selection — silently editing a merchant's saved config would hide the
|
|
54
|
-
* very problem they need to go fix.
|
|
55
|
-
*/
|
|
56
|
-
export declare const disconnectedSelectedAccounts: (channel: AgentChannel, selectedIds: string[]) => AgentChannelAccount[];
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Channels as c } from "@bikdotai/bik-models/campaigns/models/Channel";
|
|
2
|
-
import { COLORS as s } from "../../../constants/Theme.js";
|
|
3
|
-
import i from "../../../icons/Social/Channels/InstagramV2.js";
|
|
4
|
-
import r from "../../../icons/Social/Channels/EmailV2.js";
|
|
5
|
-
import u from "../../../icons/Social/Channels/WhatsAppV2.js";
|
|
6
|
-
const l = "#FFEAF7", N = s.surface.subdued, e = {
|
|
7
|
-
[c.WHATSAPP]: {
|
|
8
|
-
label: "WhatsApp",
|
|
9
|
-
Icon: u,
|
|
10
|
-
tint: s.background.positive.light,
|
|
11
|
-
accountsNoun: "WhatsApp numbers"
|
|
12
|
-
},
|
|
13
|
-
[c.EMAIL]: {
|
|
14
|
-
label: "Email",
|
|
15
|
-
Icon: r,
|
|
16
|
-
tint: s.background.negative.light,
|
|
17
|
-
accountsNoun: "email addresses"
|
|
18
|
-
},
|
|
19
|
-
[c.INSTAGRAM]: {
|
|
20
|
-
label: "Instagram",
|
|
21
|
-
Icon: i,
|
|
22
|
-
tint: l,
|
|
23
|
-
accountsNoun: "Instagram accounts"
|
|
24
|
-
}
|
|
25
|
-
}, S = Object.keys(
|
|
26
|
-
e
|
|
27
|
-
), T = (n, t) => {
|
|
28
|
-
const o = e[String(n).toLowerCase()];
|
|
29
|
-
if (o)
|
|
30
|
-
return t ? { ...o, label: t } : o;
|
|
31
|
-
const a = t || String(n);
|
|
32
|
-
return { label: a, tint: N, accountsNoun: `${a} channels` };
|
|
33
|
-
}, d = (n) => n.status === "disconnected", E = (n, t) => n.accounts.filter((o) => t.includes(o.channelId));
|
|
34
|
-
export {
|
|
35
|
-
S as AGENT_CHANNEL_TYPES,
|
|
36
|
-
e as CHANNEL_PRESENTATION,
|
|
37
|
-
T as channelPresentation,
|
|
38
|
-
d as isAccountDisconnected,
|
|
39
|
-
E as selectedAccounts
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=channels.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channels.js","sources":["../../../../../src/components/agent-builder/constants/channels.ts"],"sourcesContent":["import { Channels } from '@bikdotai/bik-models/campaigns/models/Channel';\nimport { EmailV2, InstagramV2, WhatsAppV2 } from '@src/icons/Social/Channels';\nimport type React from 'react';\nimport { COLORS } from '@src/constants/Theme';\nimport type {\n\tAgentChannel,\n\tAgentChannelAccount,\n\tAgentChannelType,\n} from '../AgentBuilder.model';\n\n/** How one channel type renders: its label, brand glyph, tint and copy noun. */\nexport interface ChannelPresentation {\n\t/** Row label (\"WhatsApp\", \"Email\", …). */\n\tlabel: string;\n\t/** Brand glyph. Undefined for an unknown type — the row renders label-only. */\n\tIcon?: React.FC<React.SVGProps<SVGSVGElement> & { size?: number | string }>;\n\t/** Tint behind the glyph. */\n\ttint: string;\n\t/**\n\t * What an account IS on this channel, plural — drives the picker's copy\n\t * (\"Select from available WhatsApp numbers\"). Kept per-channel because the\n\t * design's WhatsApp-only wording has to generalise once the same picker opens\n\t * for Email and Instagram.\n\t */\n\taccountsNoun: string;\n}\n\n/**\n * Instagram's tint has no theme token (Figma ships it as a one-off pink under\n * \"Intent Colors\"); the other two map onto the standard positive / negative\n * light backgrounds.\n */\nconst INSTAGRAM_TINT = '#FFEAF7';\n\n/** Tint used for an unknown channel type, whose glyph we don't have. */\nconst UNKNOWN_TINT = COLORS.surface.subdued;\n\n/**\n * Keyed by the shared `Channels` enum, so a channel key can never drift from the\n * platform's spelling.\n *\n * Typed `Record<AgentChannelType, …>` rather than `Record<string, …>`: that makes\n * the map EXHAUSTIVE, so widening {@link AgentChannelType} without adding the\n * matching presentation here is a compile error rather than a channel that\n * silently renders with no glyph.\n */\nexport const CHANNEL_PRESENTATION: Record<\n\tAgentChannelType,\n\tChannelPresentation\n> = {\n\t[Channels.WHATSAPP]: {\n\t\tlabel: 'WhatsApp',\n\t\tIcon: WhatsAppV2,\n\t\ttint: COLORS.background.positive.light,\n\t\taccountsNoun: 'WhatsApp numbers',\n\t},\n\t[Channels.EMAIL]: {\n\t\tlabel: 'Email',\n\t\tIcon: EmailV2,\n\t\ttint: COLORS.background.negative.light,\n\t\taccountsNoun: 'email addresses',\n\t},\n\t[Channels.INSTAGRAM]: {\n\t\tlabel: 'Instagram',\n\t\tIcon: InstagramV2,\n\t\ttint: INSTAGRAM_TINT,\n\t\taccountsNoun: 'Instagram accounts',\n\t},\n};\n\n/** The channel types the builder supports, in display order. */\nexport const AGENT_CHANNEL_TYPES = Object.keys(\n\tCHANNEL_PRESENTATION,\n) as AgentChannelType[];\n\n/**\n * Presentation for a channel.\n *\n * `AgentChannelType` makes the registry hit total at compile time, but the\n * `availableChannels` a consumer passes come off a backend response — so an\n * unrecognised `type` is still handled defensively (the consumer's `label`, then\n * the raw value, with no glyph) rather than rendering `undefined`.\n */\nexport const channelPresentation = (\n\ttype: AgentChannelType,\n\tlabelOverride?: string,\n): ChannelPresentation => {\n\tconst known = CHANNEL_PRESENTATION[\n\t\tString(type).toLowerCase() as AgentChannelType\n\t] as ChannelPresentation | undefined;\n\tif (known) {\n\t\treturn labelOverride ? { ...known, label: labelOverride } : known;\n\t}\n\tconst label = labelOverride || String(type);\n\treturn { label, tint: UNKNOWN_TINT, accountsNoun: `${label} channels` };\n};\n\n/** True when the store hasn't got a healthy connection to this account. */\nexport const isAccountDisconnected = (account: AgentChannelAccount): boolean =>\n\taccount.status === 'disconnected';\n\n/**\n * The accounts the agent is actually activated on, in the channel's own order.\n * Selection is stored as backend ids, so an id that no longer exists on the\n * store (channel removed since the agent was saved) simply drops out here.\n */\nexport const selectedAccounts = (\n\tchannel: AgentChannel,\n\tselectedIds: string[],\n): AgentChannelAccount[] =>\n\tchannel.accounts.filter((a) => selectedIds.includes(a.channelId));\n\n/**\n * Selected accounts the store can no longer reach. Drives the row alert and the\n * chips' negative styling. A disconnected account is deliberately NOT dropped\n * from the selection — silently editing a merchant's saved config would hide the\n * very problem they need to go fix.\n */\nexport const disconnectedSelectedAccounts = (\n\tchannel: AgentChannel,\n\tselectedIds: string[],\n): AgentChannelAccount[] =>\n\tselectedAccounts(channel, selectedIds).filter(isAccountDisconnected);\n"],"names":["INSTAGRAM_TINT","UNKNOWN_TINT","COLORS","CHANNEL_PRESENTATION","Channels","WhatsAppV2","EmailV2","InstagramV2","AGENT_CHANNEL_TYPES","channelPresentation","type","labelOverride","known","label","isAccountDisconnected","account","selectedAccounts","channel","selectedIds","a"],"mappings":";;;;;AAgCA,MAAMA,IAAiB,WAGjBC,IAAeC,EAAO,QAAQ,SAWvBC,IAGT;AAAA,EACH,CAACC,EAAS,QAAQ,GAAG;AAAA,IACpB,OAAO;AAAA,IACP,MAAMC;AAAAA,IACN,MAAMH,EAAO,WAAW,SAAS;AAAA,IACjC,cAAc;AAAA,EAAA;AAAA,EAEf,CAACE,EAAS,KAAK,GAAG;AAAA,IACjB,OAAO;AAAA,IACP,MAAME;AAAAA,IACN,MAAMJ,EAAO,WAAW,SAAS;AAAA,IACjC,cAAc;AAAA,EAAA;AAAA,EAEf,CAACE,EAAS,SAAS,GAAG;AAAA,IACrB,OAAO;AAAA,IACP,MAAMG;AAAAA,IACN,MAAMP;AAAA,IACN,cAAc;AAAA,EAAA;AAEhB,GAGaQ,IAAsB,OAAO;AAAA,EACzCL;AACD,GAUaM,IAAsB,CAClCC,GACAC,MACyB;AACzB,QAAMC,IAAQT,EACb,OAAOO,CAAI,EAAE,aACd;AACA,MAAIE;AACH,WAAOD,IAAgB,EAAE,GAAGC,GAAO,OAAOD,MAAkBC;AAE7D,QAAMC,IAAQF,KAAiB,OAAOD,CAAI;AAC1C,SAAO,EAAE,OAAAG,GAAO,MAAMZ,GAAc,cAAc,GAAGY,CAAK,YAAA;AAC3D,GAGaC,IAAwB,CAACC,MACrCA,EAAQ,WAAW,gBAOPC,IAAmB,CAC/BC,GACAC,MAEAD,EAAQ,SAAS,OAAO,CAACE,MAAMD,EAAY,SAASC,EAAE,SAAS,CAAC;"}
|