@alfadocs/ui-kit 1.140.0 → 1.141.0
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/_chunks/{appointment-card-CaxFXtSn.js → appointment-card-r0OZm77v.js} +170 -168
- package/dist/_chunks/appointment-timeline-Bs-rTMzi.js +689 -0
- package/dist/_chunks/{appointment-tray-DPpeR9JT.js → appointment-tray-t_ltp-Yi.js} +2 -2
- package/dist/_chunks/{calendar-appointment-editor-dialog-BBrJlmyd.js → calendar-appointment-editor-dialog-CuXpgLCw.js} +4 -4
- package/dist/_chunks/{calendar-waiting-list-panel-Cdg9YssA.js → calendar-waiting-list-panel-BNQrUndD.js} +2 -2
- package/dist/_chunks/{calendar.sheets-DbMOO7YV.js → calendar.sheets-DcW8A3DI.js} +2 -2
- package/dist/_chunks/calls-panel-CJNQm7r8.js +1446 -0
- package/dist/_chunks/{notes-panel-CnmQqhwq.js → notes-panel-C4HSUudf.js} +2 -2
- package/dist/_chunks/{patient-account-settings-DfEPHmCh.js → patient-account-settings-nSvNKKOL.js} +2 -2
- package/dist/_chunks/{patient-check-in-resume-TWs8CPQr.js → patient-check-in-resume-Cj2wg_NQ.js} +4 -4
- package/dist/_chunks/{portal-details-VfeOI4PB.js → portal-details-Cnyqf9kY.js} +2 -2
- package/dist/_chunks/{portal-documents-hGHlwmbv.js → portal-documents-g109Dl0O.js} +2 -2
- package/dist/_chunks/{portal-parts-C99CreYO.js → portal-parts-DgDFuED8.js} +2 -2
- package/dist/_chunks/{rich-text-editor-DFsH5RAj.js → rich-text-editor-orJ-hPgm.js} +1323 -1308
- package/dist/agent-catalog.json +134 -3
- package/dist/agent-i18n/en.json +8 -2
- package/dist/appointment-editor-panel/index.js +1 -1
- package/dist/browser-support.js +1 -1
- package/dist/components/appointment-card/appointment-card.d.ts +4 -0
- package/dist/components/appointment-card/index.js +2 -2
- package/dist/components/appointment-timeline/appointment-timeline.d.ts +51 -0
- package/dist/components/appointment-timeline/index.d.ts +1 -1
- package/dist/components/appointment-timeline/index.js +1 -1
- package/dist/components/calls-panel/calls-panel.d.ts +91 -0
- package/dist/components/calls-panel/index.d.ts +1 -1
- package/dist/components/calls-panel/index.js +1 -1
- package/dist/components/notes-panel/index.js +1 -1
- package/dist/components/rich-text-editor/index.js +1 -1
- package/dist/core.css +1 -1
- package/dist/find-free-slots-panel/index.js +1 -1
- package/dist/host-compat.css +13 -1
- package/dist/i18n/locales/ar.d.ts +45 -0
- package/dist/i18n/locales/ar.js +44 -2
- package/dist/i18n/locales/de.d.ts +45 -0
- package/dist/i18n/locales/de.js +44 -2
- package/dist/i18n/locales/el.d.ts +45 -0
- package/dist/i18n/locales/el.js +47 -2
- package/dist/i18n/locales/en.d.ts +37 -0
- package/dist/i18n/locales/en.js +39 -2
- package/dist/i18n/locales/es.d.ts +45 -0
- package/dist/i18n/locales/es.js +44 -2
- package/dist/i18n/locales/fr.d.ts +45 -0
- package/dist/i18n/locales/fr.js +44 -2
- package/dist/i18n/locales/hi.d.ts +45 -0
- package/dist/i18n/locales/hi.js +47 -2
- package/dist/i18n/locales/it.d.ts +45 -0
- package/dist/i18n/locales/it.js +44 -2
- package/dist/i18n/locales/ja.d.ts +45 -0
- package/dist/i18n/locales/ja.js +47 -2
- package/dist/i18n/locales/nl.d.ts +45 -0
- package/dist/i18n/locales/nl.js +44 -2
- package/dist/i18n/locales/pl.d.ts +45 -0
- package/dist/i18n/locales/pl.js +47 -2
- package/dist/i18n/locales/pt.d.ts +45 -0
- package/dist/i18n/locales/pt.js +44 -2
- package/dist/i18n/locales/ro.d.ts +45 -0
- package/dist/i18n/locales/ro.js +44 -2
- package/dist/i18n/locales/ru.d.ts +45 -0
- package/dist/i18n/locales/ru.js +44 -2
- package/dist/i18n/locales/sq.d.ts +45 -0
- package/dist/i18n/locales/sq.js +47 -2
- package/dist/i18n/locales/sv.d.ts +45 -0
- package/dist/i18n/locales/sv.js +44 -2
- package/dist/i18n/locales/tr.d.ts +45 -0
- package/dist/i18n/locales/tr.js +44 -2
- package/dist/i18n/locales/zh.d.ts +45 -0
- package/dist/i18n/locales/zh.js +44 -2
- package/dist/index.js +12 -12
- package/dist/locales/ar.json +47 -2
- package/dist/locales/de.json +47 -2
- package/dist/locales/el.json +47 -2
- package/dist/locales/en.json +39 -2
- package/dist/locales/es.json +47 -2
- package/dist/locales/fr.json +47 -2
- package/dist/locales/hi.json +47 -2
- package/dist/locales/it.json +47 -2
- package/dist/locales/ja.json +47 -2
- package/dist/locales/nl.json +47 -2
- package/dist/locales/pl.json +47 -2
- package/dist/locales/pt.json +47 -2
- package/dist/locales/ro.json +47 -2
- package/dist/locales/ru.json +47 -2
- package/dist/locales/sq.json +47 -2
- package/dist/locales/sv.json +47 -2
- package/dist/locales/tr.json +47 -2
- package/dist/locales/zh.json +47 -2
- package/dist/online-bookings-panel/index.js +1 -1
- package/dist/patterns/calendar/index.js +2 -2
- package/dist/patterns/patient-account-settings/index.js +1 -1
- package/dist/patterns/patient-check-in/index.js +1 -1
- package/dist/patterns/patient-portal/index.js +2 -2
- package/dist/tokens.css +1 -1
- package/dist/waiting-list-panel/index.js +2 -2
- package/package.json +1 -1
- package/dist/_chunks/appointment-timeline-BEwgbYyG.js +0 -455
- package/dist/_chunks/calls-panel-CtxJAzkJ.js +0 -1094
|
@@ -0,0 +1,1446 @@
|
|
|
1
|
+
import { jsxs as m, jsx as r, Fragment as Qr } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Xr, useId as gt, useRef as d, useImperativeHandle as Wr, useEffect as Q, useMemo as ue, useCallback as pe, useState as g } from "react";
|
|
3
|
+
import { c as fr } from "./index-D2ZczOXr.js";
|
|
4
|
+
import { useTranslation as hr } from "react-i18next";
|
|
5
|
+
import { u as en } from "./registry-DvAUVLHh.js";
|
|
6
|
+
import { u as tn } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
|
|
7
|
+
import { g as dt } from "./get-error-message-DbFUzuja.js";
|
|
8
|
+
import { formatPhoneForDisplay as rn } from "../format-phone/index.js";
|
|
9
|
+
import { f as vt, c as nn } from "./intl-locale-FWh-Y5_3.js";
|
|
10
|
+
import { A as X } from "./alert-C4WKViaS.js";
|
|
11
|
+
import { B as D } from "./button-DohK_Ak_.js";
|
|
12
|
+
import { I as nr } from "./icon-button-S8_weU3g.js";
|
|
13
|
+
import { C as ut } from "./call-status-chip-pajxN5eZ.js";
|
|
14
|
+
import { D as on } from "./date-range-picker-2Up_FRrM.js";
|
|
15
|
+
import { D as sn } from "./date-time-picker-C6b_Vymc.js";
|
|
16
|
+
import { D as L } from "./dialog-CVTxyR0v.js";
|
|
17
|
+
import { E as Oe } from "./empty-state-DwJ5YNzz.js";
|
|
18
|
+
import { F as Ye } from "./form-field-CyHfOVKF.js";
|
|
19
|
+
import { L as or } from "./link-CeV7FoI6.js";
|
|
20
|
+
import { P as sr } from "./panel-header-CbtlTe85.js";
|
|
21
|
+
import { P as lr } from "./panel-subview-DCyvn-49.js";
|
|
22
|
+
import { S as me } from "./select-Bm8s3q-X.js";
|
|
23
|
+
import { S as pt } from "./skeleton-tTWJpvAq.js";
|
|
24
|
+
import { T as ar } from "./text-area-COMVJ1yE.js";
|
|
25
|
+
import { P as mt } from "./phone-FceYcIFQ.js";
|
|
26
|
+
import { P as ln } from "./pencil-B1sKKyuT.js";
|
|
27
|
+
import { T as ir } from "./trash-2-uumy3fy1.js";
|
|
28
|
+
import { P as an } from "./plus-DzMQ_c6b.js";
|
|
29
|
+
const cn = {
|
|
30
|
+
id: "calls-panel",
|
|
31
|
+
capabilities: ["open", "close", "submit", "edit_inline", "filter"],
|
|
32
|
+
state: {
|
|
33
|
+
callCount: {
|
|
34
|
+
type: "number",
|
|
35
|
+
descriptionKey: "ui.agent.callsPanel.state.callCount",
|
|
36
|
+
description: "How many logged calls the list holds. A count only, never a call. Zero under privacy.",
|
|
37
|
+
read: (n) => n.getState().callCount
|
|
38
|
+
},
|
|
39
|
+
automaticCount: {
|
|
40
|
+
type: "number",
|
|
41
|
+
descriptionKey: "ui.agent.callsPanel.state.automaticCount",
|
|
42
|
+
description: "How many calls were logged by other software, such as a phone system. A count only: never a number, a name or a link. Zero under privacy.",
|
|
43
|
+
read: (n) => n.getState().automaticCount
|
|
44
|
+
},
|
|
45
|
+
missedCount: {
|
|
46
|
+
type: "number",
|
|
47
|
+
descriptionKey: "ui.agent.callsPanel.state.missedCount",
|
|
48
|
+
description: "How many incoming calls nobody answered. A count only. Zero under privacy.",
|
|
49
|
+
read: (n) => n.getState().missedCount
|
|
50
|
+
},
|
|
51
|
+
status: {
|
|
52
|
+
type: "'ready' | 'loading' | 'error'",
|
|
53
|
+
descriptionKey: "ui.agent.callsPanel.state.status",
|
|
54
|
+
description: "The state of the host's read of the calls.",
|
|
55
|
+
read: (n) => n.getState().status
|
|
56
|
+
},
|
|
57
|
+
formOpen: {
|
|
58
|
+
type: "boolean",
|
|
59
|
+
descriptionKey: "ui.agent.callsPanel.state.formOpen",
|
|
60
|
+
description: 'Whether the "Log a call" form is showing.',
|
|
61
|
+
read: (n) => n.getState().formOpen
|
|
62
|
+
},
|
|
63
|
+
privacy: {
|
|
64
|
+
type: "{ masked: true } | null",
|
|
65
|
+
descriptionKey: "ui.agent.callsPanel.state.privacy",
|
|
66
|
+
description: "Reads { masked: true } when privacy mode withholds the calls, else null.",
|
|
67
|
+
read: (n) => n.getState().privacy ? { masked: !0 } : null
|
|
68
|
+
},
|
|
69
|
+
filters: {
|
|
70
|
+
type: "{ outcome: string | null; purpose: string | null; direction: 'all' | 'outgoing' | 'incoming' | 'missed'; from: string | null; to: string | null }",
|
|
71
|
+
descriptionKey: "ui.agent.callsPanel.state.filters",
|
|
72
|
+
description: "The filters now set: an outcome id, a purpose id, a direction, and a first and last day as YYYY-MM-DD (local, inclusive). Ids and days only, never a call.",
|
|
73
|
+
read: (n) => n.getState().filters
|
|
74
|
+
},
|
|
75
|
+
activeFilterCount: {
|
|
76
|
+
type: "number",
|
|
77
|
+
descriptionKey: "ui.agent.callsPanel.state.activeFilterCount",
|
|
78
|
+
description: "How many filters differ from the host's default query. The two days count as one.",
|
|
79
|
+
read: (n) => n.getState().activeFilterCount
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
actions: {
|
|
83
|
+
set_filter: {
|
|
84
|
+
// A view change, not a write: the same class as TasksPanel's set_filter.
|
|
85
|
+
safety: "read",
|
|
86
|
+
argsType: "{ outcome?: string | null; purpose?: string | null; direction?: 'all' | 'outgoing' | 'incoming' | 'missed'; from?: string | null; to?: string | null }",
|
|
87
|
+
argsSchema: {
|
|
88
|
+
type: "object",
|
|
89
|
+
properties: {
|
|
90
|
+
outcome: { type: ["string", "null"] },
|
|
91
|
+
purpose: { type: ["string", "null"] },
|
|
92
|
+
direction: {
|
|
93
|
+
type: "string",
|
|
94
|
+
enum: ["all", "outgoing", "incoming", "missed"]
|
|
95
|
+
},
|
|
96
|
+
from: {
|
|
97
|
+
type: ["string", "null"],
|
|
98
|
+
description: "First day, YYYY-MM-DD, local time, inclusive."
|
|
99
|
+
},
|
|
100
|
+
to: {
|
|
101
|
+
type: ["string", "null"],
|
|
102
|
+
description: "Last day, YYYY-MM-DD, local time, inclusive."
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
idempotent: !0,
|
|
107
|
+
errors: [
|
|
108
|
+
"Privacy mode is on.",
|
|
109
|
+
"The outcome or purpose is not one the host offered.",
|
|
110
|
+
"The direction is not one of the four.",
|
|
111
|
+
"A day is not a real date written as YYYY-MM-DD."
|
|
112
|
+
],
|
|
113
|
+
descriptionKey: "ui.agent.callsPanel.actions.setFilter",
|
|
114
|
+
description: "Set the call filters (outcome, purpose, direction, first and last day). Omitted keys are left unchanged. A filter the panel cannot honour is ignored. Unchanged values are not re-sent.",
|
|
115
|
+
examples: [
|
|
116
|
+
{
|
|
117
|
+
args: { direction: "missed", from: "2026-06-01", to: "2026-06-30" },
|
|
118
|
+
note: "Missed calls in June."
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
invoke: (n, s) => n.setFilter(s)
|
|
122
|
+
},
|
|
123
|
+
clear_filters: {
|
|
124
|
+
safety: "read",
|
|
125
|
+
idempotent: !0,
|
|
126
|
+
errors: ["Privacy mode is on."],
|
|
127
|
+
descriptionKey: "ui.agent.callsPanel.actions.clearFilters",
|
|
128
|
+
description: "Return every filter to the host's default query, as the Clear filters button does.",
|
|
129
|
+
invoke: (n) => n.clearFilters()
|
|
130
|
+
},
|
|
131
|
+
open_form: {
|
|
132
|
+
safety: "write",
|
|
133
|
+
idempotent: !0,
|
|
134
|
+
errors: [
|
|
135
|
+
"The panel is read-only, privacy mode is on, or the host gave no way to log a call."
|
|
136
|
+
],
|
|
137
|
+
descriptionKey: "ui.agent.callsPanel.actions.openForm",
|
|
138
|
+
description: 'Open the "Log a call" form, as the button does.',
|
|
139
|
+
invoke: (n) => n.openForm()
|
|
140
|
+
},
|
|
141
|
+
close_form: {
|
|
142
|
+
// A dismiss, classed as select and dialog class their `close`.
|
|
143
|
+
safety: "read",
|
|
144
|
+
idempotent: !0,
|
|
145
|
+
errors: ["A call is being saved."],
|
|
146
|
+
descriptionKey: "ui.agent.callsPanel.actions.closeForm",
|
|
147
|
+
description: "Close the form and discard what was typed in it.",
|
|
148
|
+
invoke: (n) => n.closeForm()
|
|
149
|
+
},
|
|
150
|
+
submit_call: {
|
|
151
|
+
// A call note is patient-identifiable. PHI.
|
|
152
|
+
safety: "phi",
|
|
153
|
+
argsType: "{ dateIso: string; purposeId?: string | null; outcomeId?: string | null; description?: string }",
|
|
154
|
+
argsSchema: {
|
|
155
|
+
type: "object",
|
|
156
|
+
properties: {
|
|
157
|
+
dateIso: {
|
|
158
|
+
type: "string",
|
|
159
|
+
description: "ISO-8601 instant the call took place."
|
|
160
|
+
},
|
|
161
|
+
purposeId: { type: ["string", "null"] },
|
|
162
|
+
outcomeId: { type: ["string", "null"] },
|
|
163
|
+
description: { type: "string" }
|
|
164
|
+
},
|
|
165
|
+
required: ["dateIso"]
|
|
166
|
+
},
|
|
167
|
+
openWorld: !0,
|
|
168
|
+
errors: [
|
|
169
|
+
"The date is missing or not a date.",
|
|
170
|
+
"The purpose or outcome is not one the host offered.",
|
|
171
|
+
"The panel is read-only, privacy mode is on, or the host gave no way to log a call.",
|
|
172
|
+
"A write is already in progress.",
|
|
173
|
+
"The host refused the call. The panel keeps the form and shows the host's message."
|
|
174
|
+
],
|
|
175
|
+
descriptionKey: "ui.agent.callsPanel.actions.logCall",
|
|
176
|
+
description: "Log a call made to the patient. Settles with the host's answer; a refusal rejects.",
|
|
177
|
+
examples: [
|
|
178
|
+
{
|
|
179
|
+
args: {
|
|
180
|
+
dateIso: "2026-06-24T09:30:00Z",
|
|
181
|
+
outcomeId: "connected",
|
|
182
|
+
description: "Confirmed the visit."
|
|
183
|
+
},
|
|
184
|
+
note: "Log a connected call."
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
invoke: (n, s) => n.logCall(s)
|
|
188
|
+
},
|
|
189
|
+
edit_call: {
|
|
190
|
+
safety: "phi",
|
|
191
|
+
argsType: "{ id: string; description: string }",
|
|
192
|
+
argsSchema: {
|
|
193
|
+
type: "object",
|
|
194
|
+
properties: {
|
|
195
|
+
id: { type: "string" },
|
|
196
|
+
description: { type: "string", minLength: 1 }
|
|
197
|
+
},
|
|
198
|
+
required: ["id", "description"]
|
|
199
|
+
},
|
|
200
|
+
idempotent: !0,
|
|
201
|
+
openWorld: !0,
|
|
202
|
+
errors: [
|
|
203
|
+
"No call has that id.",
|
|
204
|
+
"The description is empty.",
|
|
205
|
+
"The panel is read-only, privacy mode is on, or the host gave no way to edit a call.",
|
|
206
|
+
"A write is already in progress.",
|
|
207
|
+
"The host refused the edit. The panel keeps the text and shows the host's message."
|
|
208
|
+
],
|
|
209
|
+
descriptionKey: "ui.agent.callsPanel.actions.updateCall",
|
|
210
|
+
description: "Replace the description of a logged call. Only the description can change. Settles with the host's answer.",
|
|
211
|
+
invoke: (n, s) => n.updateCall(s.id, { description: s.description })
|
|
212
|
+
},
|
|
213
|
+
delete_call: {
|
|
214
|
+
safety: "destructive",
|
|
215
|
+
argsType: "{ id: string }",
|
|
216
|
+
argsSchema: {
|
|
217
|
+
type: "object",
|
|
218
|
+
properties: { id: { type: "string" } },
|
|
219
|
+
required: ["id"]
|
|
220
|
+
},
|
|
221
|
+
openWorld: !0,
|
|
222
|
+
errors: [
|
|
223
|
+
"No call has that id.",
|
|
224
|
+
"The panel is read-only, privacy mode is on, or the host gave no way to delete a call.",
|
|
225
|
+
"A write is already in progress.",
|
|
226
|
+
"The host refused the delete."
|
|
227
|
+
],
|
|
228
|
+
descriptionKey: "ui.agent.callsPanel.actions.deleteCall",
|
|
229
|
+
description: "Delete a logged call. Settles with the host's answer; a refusal rejects.",
|
|
230
|
+
invoke: (n, s) => n.deleteCall(s.id)
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
domHooks: {
|
|
234
|
+
root: {
|
|
235
|
+
attr: "data-component",
|
|
236
|
+
value: "calls-panel",
|
|
237
|
+
description: "Marks the CallsPanel region."
|
|
238
|
+
},
|
|
239
|
+
instanceId: {
|
|
240
|
+
attr: "data-component-id",
|
|
241
|
+
sourceProp: "id",
|
|
242
|
+
description: "Sourced from the id prop. Required to address a specific panel from the agent."
|
|
243
|
+
},
|
|
244
|
+
item: {
|
|
245
|
+
attr: "data-call-id",
|
|
246
|
+
description: "Stable call id on each rendered call. Never a description, a purpose or a date."
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}, cr = fr(
|
|
250
|
+
"ds:flex ds:h-full ds:min-h-0 ds:min-w-0 ds:flex-col ds:bg-[color:var(--card)]"
|
|
251
|
+
), dr = fr(
|
|
252
|
+
[
|
|
253
|
+
"ds:flex ds:min-w-0 ds:flex-col ds:gap-[var(--spacing-xs)]",
|
|
254
|
+
"ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--card-border)]",
|
|
255
|
+
"ds:bg-[color:var(--card)] ds:p-[var(--spacing-sm)]"
|
|
256
|
+
].join(" ")
|
|
257
|
+
), gr = {
|
|
258
|
+
connected: "positive",
|
|
259
|
+
no_answer: "caution",
|
|
260
|
+
busy: "caution",
|
|
261
|
+
left_voicemail: "caution",
|
|
262
|
+
wrong_number: "negative"
|
|
263
|
+
}, dn = new Set(Object.keys(gr));
|
|
264
|
+
function ur(n) {
|
|
265
|
+
if (n)
|
|
266
|
+
try {
|
|
267
|
+
const s = new URL(n.trim());
|
|
268
|
+
return s.protocol === "http:" || s.protocol === "https:" ? s.href : void 0;
|
|
269
|
+
} catch {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function un(n, s) {
|
|
274
|
+
const u = vt(nn(s)), w = Math.round(n), f = [
|
|
275
|
+
[Math.floor(w / 3600), "hour"],
|
|
276
|
+
[Math.floor(w % 3600 / 60), "minute"],
|
|
277
|
+
[w % 60, "second"]
|
|
278
|
+
].filter(([A]) => A > 0);
|
|
279
|
+
f.length === 0 && f.push([0, "second"]);
|
|
280
|
+
const N = f.map(
|
|
281
|
+
([A, k]) => new Intl.NumberFormat(u, {
|
|
282
|
+
style: "unit",
|
|
283
|
+
unit: k,
|
|
284
|
+
unitDisplay: "short"
|
|
285
|
+
}).format(A)
|
|
286
|
+
);
|
|
287
|
+
return new Intl.ListFormat(u, { type: "unit", style: "narrow" }).format(
|
|
288
|
+
N
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
function Le(n) {
|
|
292
|
+
return !!n && !Number.isNaN(n.getTime());
|
|
293
|
+
}
|
|
294
|
+
const pn = {
|
|
295
|
+
outcome: null,
|
|
296
|
+
purpose: null,
|
|
297
|
+
direction: "all",
|
|
298
|
+
from: null,
|
|
299
|
+
to: null
|
|
300
|
+
}, ft = [
|
|
301
|
+
"all",
|
|
302
|
+
"outgoing",
|
|
303
|
+
"incoming",
|
|
304
|
+
"missed"
|
|
305
|
+
], fe = "__any__", mn = /^\d{4}-\d{2}-\d{2}$/;
|
|
306
|
+
function ht(n) {
|
|
307
|
+
if (!n || !mn.test(n)) return;
|
|
308
|
+
const [s, u, w] = n.split("-").map(Number), b = new Date(s, u - 1, w);
|
|
309
|
+
return b.getFullYear() === s && b.getMonth() === u - 1 && b.getDate() === w ? b : void 0;
|
|
310
|
+
}
|
|
311
|
+
function yt(n) {
|
|
312
|
+
const s = (u) => String(u).padStart(2, "0");
|
|
313
|
+
return `${n.getFullYear()}-${s(n.getMonth() + 1)}-${s(n.getDate())}`;
|
|
314
|
+
}
|
|
315
|
+
function fn(n) {
|
|
316
|
+
const s = new Date(n);
|
|
317
|
+
return Number.isNaN(s.getTime()) ? null : yt(s);
|
|
318
|
+
}
|
|
319
|
+
function hn(n, s) {
|
|
320
|
+
return (n.outcome || null) === (s.outcome || null) && (n.purpose || null) === (s.purpose || null) && n.direction === s.direction && (n.from || null) === (s.from || null) && (n.to || null) === (s.to || null);
|
|
321
|
+
}
|
|
322
|
+
function gn(n, s) {
|
|
323
|
+
return [
|
|
324
|
+
(n.outcome || null) !== (s.outcome || null),
|
|
325
|
+
(n.purpose || null) !== (s.purpose || null),
|
|
326
|
+
n.direction !== s.direction,
|
|
327
|
+
(n.from || null) !== (s.from || null) || (n.to || null) !== (s.to || null)
|
|
328
|
+
].filter(Boolean).length;
|
|
329
|
+
}
|
|
330
|
+
function pr(n) {
|
|
331
|
+
return n.missed === !0 && n.direction !== "outgoing";
|
|
332
|
+
}
|
|
333
|
+
function vn(n, s) {
|
|
334
|
+
if (s.outcome && n.outcomeId !== s.outcome || s.purpose && n.purposeId !== s.purpose || s.direction === "missed" && !pr(n) || s.direction === "outgoing" && n.direction !== "outgoing" || s.direction === "incoming" && (n.direction !== "incoming" || pr(n)))
|
|
335
|
+
return !1;
|
|
336
|
+
if (s.from || s.to) {
|
|
337
|
+
const u = fn(n.dateIso);
|
|
338
|
+
if (!u || s.from && u < s.from || s.to && u > s.to) return !1;
|
|
339
|
+
}
|
|
340
|
+
return !0;
|
|
341
|
+
}
|
|
342
|
+
function mr(n) {
|
|
343
|
+
const s = new Date(n).getTime();
|
|
344
|
+
return Number.isNaN(s) ? 0 : s;
|
|
345
|
+
}
|
|
346
|
+
function yn({ text: n }) {
|
|
347
|
+
const { t: s } = hr("ui"), u = gt(), w = d(null), [b, f] = g(!1), [N, A] = g(!1);
|
|
348
|
+
return tn(() => {
|
|
349
|
+
const k = w.current;
|
|
350
|
+
if (!k || b) return;
|
|
351
|
+
const he = () => A(k.scrollHeight > k.clientHeight + 1);
|
|
352
|
+
if (he(), typeof ResizeObserver > "u") return;
|
|
353
|
+
const p = new ResizeObserver(he);
|
|
354
|
+
return p.observe(k), () => p.disconnect();
|
|
355
|
+
}, [n, b]), /* @__PURE__ */ m("div", { className: "ds:flex ds:min-w-0 ds:flex-col ds:items-start ds:gap-[var(--spacing-2xs)]", children: [
|
|
356
|
+
/* @__PURE__ */ r(
|
|
357
|
+
"p",
|
|
358
|
+
{
|
|
359
|
+
ref: w,
|
|
360
|
+
id: u,
|
|
361
|
+
dir: "auto",
|
|
362
|
+
"data-calls-description": "",
|
|
363
|
+
className: [
|
|
364
|
+
"ds:m-0 ds:w-full type-body-sm ds:whitespace-pre-line ds:text-[color:var(--foreground)] ds:[overflow-wrap:anywhere]",
|
|
365
|
+
b ? "" : "ds:line-clamp-3"
|
|
366
|
+
].join(" "),
|
|
367
|
+
children: n
|
|
368
|
+
}
|
|
369
|
+
),
|
|
370
|
+
N || b ? /* @__PURE__ */ r(
|
|
371
|
+
D,
|
|
372
|
+
{
|
|
373
|
+
type: "button",
|
|
374
|
+
intent: "link",
|
|
375
|
+
size: "sm",
|
|
376
|
+
className: "ds:data-[component=button]:ps-0 ds:data-[component=button]:pe-0",
|
|
377
|
+
"aria-expanded": b,
|
|
378
|
+
"aria-controls": u,
|
|
379
|
+
onClick: () => f((k) => !k),
|
|
380
|
+
children: s(b ? "callsPanel.showLess" : "callsPanel.showMore")
|
|
381
|
+
}
|
|
382
|
+
) : null
|
|
383
|
+
] });
|
|
384
|
+
}
|
|
385
|
+
const wn = Xr(
|
|
386
|
+
({
|
|
387
|
+
id: n,
|
|
388
|
+
title: s,
|
|
389
|
+
"aria-label": u,
|
|
390
|
+
nowIso: w,
|
|
391
|
+
locale: b,
|
|
392
|
+
calls: f,
|
|
393
|
+
status: N = "ready",
|
|
394
|
+
onRetry: A,
|
|
395
|
+
purposes: k,
|
|
396
|
+
outcomes: he,
|
|
397
|
+
privacy: p = !1,
|
|
398
|
+
readOnly: W = !1,
|
|
399
|
+
onCreate: Me,
|
|
400
|
+
onUpdate: Ke,
|
|
401
|
+
onDelete: _e,
|
|
402
|
+
onWriteError: wt,
|
|
403
|
+
filtering: vr = "client",
|
|
404
|
+
showFilters: yr = !0,
|
|
405
|
+
defaultFilters: wr,
|
|
406
|
+
onFiltersChange: R,
|
|
407
|
+
outcomeFilter: je,
|
|
408
|
+
onOutcomeFilterChange: ge,
|
|
409
|
+
purposeFilter: Fe,
|
|
410
|
+
onPurposeFilterChange: ve,
|
|
411
|
+
directionFilter: bt,
|
|
412
|
+
showDirectionFilter: br,
|
|
413
|
+
defaultDirectionFilter: Pr,
|
|
414
|
+
onDirectionFilterChange: ye,
|
|
415
|
+
fromDateFilter: He,
|
|
416
|
+
onFromDateFilterChange: we,
|
|
417
|
+
toDateFilter: ze,
|
|
418
|
+
onToDateFilterChange: be,
|
|
419
|
+
className: Pt,
|
|
420
|
+
...It
|
|
421
|
+
}, Ir) => {
|
|
422
|
+
const { t: o, i18n: Nr } = hr("ui"), Pe = gt(), Sr = gt(), Nt = s ?? o("callsPanel.title"), Ie = b ?? Nr.language, M = d(null);
|
|
423
|
+
Wr(Ir, () => M.current, []);
|
|
424
|
+
const Be = d(null), St = d(null), Ne = d(!1), q = !W && !p && !!Me, $ = !W && !p && !!Ke, K = !W && !p && !!_e, _ = k ?? [], O = he ?? [], U = d(Me);
|
|
425
|
+
U.current = Me;
|
|
426
|
+
const ee = d(Ke);
|
|
427
|
+
ee.current = Ke;
|
|
428
|
+
const te = d(_e);
|
|
429
|
+
te.current = _e;
|
|
430
|
+
const E = d(wt);
|
|
431
|
+
E.current = wt;
|
|
432
|
+
const P = d(!0);
|
|
433
|
+
Q(() => (P.current = !0, () => {
|
|
434
|
+
P.current = !1;
|
|
435
|
+
}), []);
|
|
436
|
+
const xt = ue(
|
|
437
|
+
() => new Date(w ?? Date.now()).getFullYear(),
|
|
438
|
+
[w]
|
|
439
|
+
), Ve = pe(
|
|
440
|
+
(e) => {
|
|
441
|
+
const t = new Date(e);
|
|
442
|
+
return Number.isNaN(t.getTime()) ? e : new Intl.DateTimeFormat(vt(Ie), {
|
|
443
|
+
calendar: "gregory",
|
|
444
|
+
hourCycle: "h23",
|
|
445
|
+
day: "numeric",
|
|
446
|
+
month: "short",
|
|
447
|
+
...t.getFullYear() === xt ? {} : { year: "numeric" },
|
|
448
|
+
hour: "2-digit",
|
|
449
|
+
minute: "2-digit"
|
|
450
|
+
}).format(t);
|
|
451
|
+
},
|
|
452
|
+
[Ie, xt]
|
|
453
|
+
), Se = ue(
|
|
454
|
+
() => [...f].sort((e, t) => mr(t.dateIso) - mr(e.dateIso)),
|
|
455
|
+
[f]
|
|
456
|
+
), Tt = (e, t) => {
|
|
457
|
+
var l;
|
|
458
|
+
return t ? (l = e.find((a) => a.id === t)) == null ? void 0 : l.label : void 0;
|
|
459
|
+
}, Y = vr === "server", j = {
|
|
460
|
+
outcome: !Y || !!R || !!ge,
|
|
461
|
+
purpose: !Y || !!R || !!ve,
|
|
462
|
+
direction: !Y || !!R || !!ye,
|
|
463
|
+
from: !Y || !!R || !!we,
|
|
464
|
+
to: !Y || !!R || !!be
|
|
465
|
+
}, C = wr ?? pn, [xr, Tr] = g(
|
|
466
|
+
C.outcome
|
|
467
|
+
), [kr, Er] = g(
|
|
468
|
+
C.purpose
|
|
469
|
+
), [Cr, Dr] = g(
|
|
470
|
+
Pr ?? C.direction
|
|
471
|
+
), [Ar, Rr] = g(C.from), [Or, Yr] = g(C.to), v = {
|
|
472
|
+
outcome: (je !== void 0 ? je : xr) || null,
|
|
473
|
+
purpose: (Fe !== void 0 ? Fe : kr) || null,
|
|
474
|
+
direction: bt ?? Cr,
|
|
475
|
+
from: (He !== void 0 ? He : Ar) || null,
|
|
476
|
+
to: (ze !== void 0 ? ze : Or) || null
|
|
477
|
+
}, F = gn(v, C), Lr = f.some(
|
|
478
|
+
(e) => e.direction !== void 0 || e.missed === !0
|
|
479
|
+
), kt = O.length > 0 && j.outcome, Et = _.length > 0 && j.purpose, Ct = (br ?? (Lr || v.direction !== "all")) && j.direction, Dt = j.from && j.to, At = yr && (kt || Et || Ct || Dt) && (f.length > 0 || F > 0), [Mr, Kr] = g(!1), qe = d(v);
|
|
480
|
+
qe.current = v;
|
|
481
|
+
const H = (e) => {
|
|
482
|
+
const t = Object.fromEntries(
|
|
483
|
+
Object.entries(e).filter(
|
|
484
|
+
([c]) => j[c]
|
|
485
|
+
)
|
|
486
|
+
);
|
|
487
|
+
if (Object.keys(t).length === 0) return;
|
|
488
|
+
const l = qe.current, a = { ...l, ...t };
|
|
489
|
+
qe.current = a, Kr(!0), S(null), je === void 0 && Tr(a.outcome), Fe === void 0 && Er(a.purpose), bt === void 0 && Dr(a.direction), He === void 0 && Rr(a.from), ze === void 0 && Yr(a.to), (l.outcome || null) !== (a.outcome || null) && (ge == null || ge(a.outcome)), (l.purpose || null) !== (a.purpose || null) && (ve == null || ve(a.purpose)), l.direction !== a.direction && (ye == null || ye(a.direction)), (l.from || null) !== (a.from || null) && (we == null || we(a.from)), (l.to || null) !== (a.to || null) && (be == null || be(a.to)), hn(l, a) || R == null || R(a);
|
|
490
|
+
}, Rt = () => H({ ...C }), $e = d(H);
|
|
491
|
+
$e.current = H;
|
|
492
|
+
const Ue = ue(
|
|
493
|
+
() => Y ? Se : Se.filter((e) => vn(e, v)),
|
|
494
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- `filters` is rebuilt every render; its fields are the inputs
|
|
495
|
+
[
|
|
496
|
+
Y,
|
|
497
|
+
Se,
|
|
498
|
+
v.outcome,
|
|
499
|
+
v.purpose,
|
|
500
|
+
v.direction,
|
|
501
|
+
v.from,
|
|
502
|
+
v.to
|
|
503
|
+
]
|
|
504
|
+
), [x, Z] = g(null), h = d(!1), z = d(null), re = d(null), [Ze, S] = g(null), [xe, B] = g(!1), [T, J] = g({
|
|
505
|
+
date: void 0,
|
|
506
|
+
purposeId: "",
|
|
507
|
+
outcomeId: "",
|
|
508
|
+
description: ""
|
|
509
|
+
}), [Ot, Te] = g(null), [_r, Je] = g(!1), Ge = pe(() => {
|
|
510
|
+
const e = new Date(w ?? Date.now());
|
|
511
|
+
J({
|
|
512
|
+
date: Le(e) ? e : void 0,
|
|
513
|
+
purposeId: "",
|
|
514
|
+
outcomeId: "",
|
|
515
|
+
description: ""
|
|
516
|
+
}), Te(null), Je(!1), S(null), B(!0);
|
|
517
|
+
}, [w]), Yt = ue(
|
|
518
|
+
() => ({
|
|
519
|
+
get current() {
|
|
520
|
+
var e;
|
|
521
|
+
return ((e = St.current) == null ? void 0 : e.querySelector(
|
|
522
|
+
"[data-calls-date] button"
|
|
523
|
+
)) ?? null;
|
|
524
|
+
}
|
|
525
|
+
}),
|
|
526
|
+
[]
|
|
527
|
+
), [y, V] = g(
|
|
528
|
+
null
|
|
529
|
+
), [ne, oe] = g(null), [ke, Ee] = g(!1), se = d(null), Qe = d(null), [le, ae] = g(null), [Lt, ie] = g(null), Xe = d(null), Ce = le ? f.find((e) => e.id === le) : void 0, G = d({
|
|
530
|
+
form: !1,
|
|
531
|
+
editingId: null,
|
|
532
|
+
deleteId: null
|
|
533
|
+
});
|
|
534
|
+
G.current = {
|
|
535
|
+
form: xe,
|
|
536
|
+
editingId: (y == null ? void 0 : y.id) ?? null,
|
|
537
|
+
deleteId: Ce ? le : null
|
|
538
|
+
}, Q(() => {
|
|
539
|
+
p && (B(!1), J({
|
|
540
|
+
date: void 0,
|
|
541
|
+
purposeId: "",
|
|
542
|
+
outcomeId: "",
|
|
543
|
+
description: ""
|
|
544
|
+
}), Te(null), V(null), oe(null), ae(null), ie(null), S(null));
|
|
545
|
+
}, [p]), Q(() => {
|
|
546
|
+
var l;
|
|
547
|
+
const e = G.current, t = !q && e.form || !$ && e.editingId !== null || !K && e.deleteId !== null;
|
|
548
|
+
if (q || B(!1), $ || V(null), K || ae(null), t && !p && Ne.current) {
|
|
549
|
+
const a = document.activeElement;
|
|
550
|
+
if (!a || a === document.body || !!a.closest(
|
|
551
|
+
'[data-calls-form],[data-calls-editor],[role="alertdialog"]'
|
|
552
|
+
)) {
|
|
553
|
+
const i = (l = M.current) == null ? void 0 : l.querySelector("h2");
|
|
554
|
+
i && (i.setAttribute("tabindex", "-1"), i.focus({
|
|
555
|
+
preventScroll: !0,
|
|
556
|
+
focusVisible: !1
|
|
557
|
+
}));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}, [q, $, K]);
|
|
561
|
+
const We = pe(
|
|
562
|
+
async (e, t = "ui") => {
|
|
563
|
+
var l, a;
|
|
564
|
+
if (!h.current) {
|
|
565
|
+
h.current = !0, z.current = "create", Z("create"), Te(null), S(null);
|
|
566
|
+
try {
|
|
567
|
+
await ((l = U.current) == null ? void 0 : l.call(U, e)), P.current && (t === "ui" && B(!1), S("saved"));
|
|
568
|
+
} catch (c) {
|
|
569
|
+
throw P.current && Te(dt(c, o("callsPanel.saveFailed"))), (a = E.current) == null || a.call(E, {
|
|
570
|
+
kind: "create",
|
|
571
|
+
error: c,
|
|
572
|
+
shown: P.current && (t === "ui" || G.current.form)
|
|
573
|
+
}), c;
|
|
574
|
+
} finally {
|
|
575
|
+
h.current = !1, z.current = null, P.current && Z(null);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
[o]
|
|
580
|
+
), et = pe(
|
|
581
|
+
async (e, t, l = "ui") => {
|
|
582
|
+
var a, c;
|
|
583
|
+
if (!h.current) {
|
|
584
|
+
h.current = !0, z.current = "update", Z("update"), oe(null), S(null);
|
|
585
|
+
try {
|
|
586
|
+
await ((a = ee.current) == null ? void 0 : a.call(ee, e, { description: t })), P.current && (l === "ui" && (se.current = e, V(null)), S("updated"));
|
|
587
|
+
} catch (i) {
|
|
588
|
+
throw P.current && oe(dt(i, o("callsPanel.updateFailed"))), (c = E.current) == null || c.call(E, {
|
|
589
|
+
kind: "update",
|
|
590
|
+
id: e,
|
|
591
|
+
error: i,
|
|
592
|
+
shown: P.current && (l === "ui" || G.current.editingId === e)
|
|
593
|
+
}), i;
|
|
594
|
+
} finally {
|
|
595
|
+
h.current = !1, z.current = null, P.current && Z(null);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
[o]
|
|
600
|
+
), tt = pe(
|
|
601
|
+
async (e, t = "ui") => {
|
|
602
|
+
var l, a;
|
|
603
|
+
if (!h.current) {
|
|
604
|
+
h.current = !0, z.current = "delete", Z("delete"), ie(null), S(null), re.current = null;
|
|
605
|
+
try {
|
|
606
|
+
if (await ((l = te.current) == null ? void 0 : l.call(te, e)), P.current) {
|
|
607
|
+
const c = G.current.deleteId === e;
|
|
608
|
+
ae((i) => i === e ? null : i), V((i) => (i == null ? void 0 : i.id) === e ? null : i), c ? re.current = "deleted" : S("deleted");
|
|
609
|
+
}
|
|
610
|
+
} catch (c) {
|
|
611
|
+
throw P.current && ie(
|
|
612
|
+
dt(c, o("callsPanel.deleteFailed"))
|
|
613
|
+
), (a = E.current) == null || a.call(E, {
|
|
614
|
+
kind: "delete",
|
|
615
|
+
id: e,
|
|
616
|
+
error: c,
|
|
617
|
+
shown: P.current && (t === "ui" || G.current.deleteId === e)
|
|
618
|
+
}), c;
|
|
619
|
+
} finally {
|
|
620
|
+
h.current = !1, z.current = null, P.current && Z(null);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
[o]
|
|
625
|
+
), Mt = () => {
|
|
626
|
+
var e;
|
|
627
|
+
if (!h.current) {
|
|
628
|
+
if (!Le(T.date)) {
|
|
629
|
+
Je(!0), (e = Yt.current) == null || e.focus();
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
We({
|
|
633
|
+
dateIso: T.date.toISOString(),
|
|
634
|
+
purposeId: T.purposeId || null,
|
|
635
|
+
outcomeId: T.outcomeId || null,
|
|
636
|
+
description: T.description.trim()
|
|
637
|
+
}).catch(() => {
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
}, Kt = () => {
|
|
641
|
+
if (!y || h.current) return;
|
|
642
|
+
const e = y.text.trim();
|
|
643
|
+
if (!e) {
|
|
644
|
+
Ee(!0);
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
et(y.id, e).catch(() => {
|
|
648
|
+
});
|
|
649
|
+
}, jr = (e) => {
|
|
650
|
+
h.current || (Qe.current = e.id, V({ id: e.id, text: e.description ?? "" }), oe(null), Ee(!1), S(null));
|
|
651
|
+
}, _t = () => {
|
|
652
|
+
h.current || (se.current = (y == null ? void 0 : y.id) ?? null, V(null), oe(null), Ee(!1));
|
|
653
|
+
};
|
|
654
|
+
Q(() => {
|
|
655
|
+
var t;
|
|
656
|
+
if (y || !se.current) return;
|
|
657
|
+
const e = (t = M.current) == null ? void 0 : t.querySelector(
|
|
658
|
+
`[data-call-id="${CSS.escape(se.current)}"] [data-calls-edit]`
|
|
659
|
+
);
|
|
660
|
+
se.current = null, e == null || e.focus();
|
|
661
|
+
}, [y, f]);
|
|
662
|
+
const jt = (e) => e.filter((t) => {
|
|
663
|
+
var l;
|
|
664
|
+
return ((l = t.source) == null ? void 0 : l.kind) === "integration";
|
|
665
|
+
}).length, Ft = (e) => e.filter((t) => t.missed === !0 && t.direction !== "outgoing").length, Ht = d({
|
|
666
|
+
callCount: f.length,
|
|
667
|
+
automaticCount: jt(f),
|
|
668
|
+
missedCount: Ft(f),
|
|
669
|
+
status: N,
|
|
670
|
+
formOpen: xe,
|
|
671
|
+
privacy: p,
|
|
672
|
+
filters: v,
|
|
673
|
+
activeFilterCount: F
|
|
674
|
+
});
|
|
675
|
+
Ht.current = {
|
|
676
|
+
callCount: p ? 0 : f.length,
|
|
677
|
+
automaticCount: p ? 0 : jt(f),
|
|
678
|
+
missedCount: p ? 0 : Ft(f),
|
|
679
|
+
status: N,
|
|
680
|
+
formOpen: xe && q,
|
|
681
|
+
privacy: p,
|
|
682
|
+
filters: { ...v },
|
|
683
|
+
activeFilterCount: F
|
|
684
|
+
};
|
|
685
|
+
const De = d({ readOnly: W, privacy: p });
|
|
686
|
+
De.current = { readOnly: W, privacy: p };
|
|
687
|
+
const rt = d(f);
|
|
688
|
+
rt.current = f;
|
|
689
|
+
const nt = d({
|
|
690
|
+
purposes: _,
|
|
691
|
+
outcomes: O
|
|
692
|
+
});
|
|
693
|
+
nt.current = { purposes: _, outcomes: O };
|
|
694
|
+
const zt = d(C);
|
|
695
|
+
zt.current = C;
|
|
696
|
+
const Bt = d(Ge);
|
|
697
|
+
Bt.current = Ge;
|
|
698
|
+
const Fr = ue(() => {
|
|
699
|
+
const e = async (t, l) => {
|
|
700
|
+
const a = De.current;
|
|
701
|
+
if (a.privacy) throw new Error("Calls are hidden by privacy mode.");
|
|
702
|
+
if (a.readOnly) throw new Error("The panel is read-only.");
|
|
703
|
+
if (!t) throw new Error(`The host gave the panel no way to ${l}.`);
|
|
704
|
+
};
|
|
705
|
+
return {
|
|
706
|
+
getState: () => ({ ...Ht.current }),
|
|
707
|
+
setFilter: async (t) => {
|
|
708
|
+
if (De.current.privacy)
|
|
709
|
+
throw new Error("Calls are hidden by privacy mode.");
|
|
710
|
+
const { purposes: l, outcomes: a } = nt.current;
|
|
711
|
+
if (t.outcome && !a.some((i) => i.id === t.outcome))
|
|
712
|
+
throw new Error("That outcome is not offered.");
|
|
713
|
+
if (t.purpose && !l.some((i) => i.id === t.purpose))
|
|
714
|
+
throw new Error("That purpose is not offered.");
|
|
715
|
+
if (t.direction !== void 0 && !ft.includes(t.direction))
|
|
716
|
+
throw new Error("That direction is not one of the four.");
|
|
717
|
+
for (const i of [t.from, t.to])
|
|
718
|
+
if (i && !ht(i))
|
|
719
|
+
throw new Error("A day must be a real date, as YYYY-MM-DD.");
|
|
720
|
+
const c = {};
|
|
721
|
+
t.outcome !== void 0 && (c.outcome = t.outcome || null), t.purpose !== void 0 && (c.purpose = t.purpose || null), t.direction !== void 0 && (c.direction = t.direction), t.from !== void 0 && (c.from = t.from || null), t.to !== void 0 && (c.to = t.to || null), $e.current(c);
|
|
722
|
+
},
|
|
723
|
+
clearFilters: async () => {
|
|
724
|
+
if (De.current.privacy)
|
|
725
|
+
throw new Error("Calls are hidden by privacy mode.");
|
|
726
|
+
$e.current({ ...zt.current });
|
|
727
|
+
},
|
|
728
|
+
openForm: async () => {
|
|
729
|
+
await e(!!U.current, "log a call"), Bt.current();
|
|
730
|
+
},
|
|
731
|
+
closeForm: async () => {
|
|
732
|
+
if (z.current === "create")
|
|
733
|
+
throw new Error("A call is being saved.");
|
|
734
|
+
B(!1);
|
|
735
|
+
},
|
|
736
|
+
logCall: async (t) => {
|
|
737
|
+
await e(!!U.current, "log a call");
|
|
738
|
+
const l = new Date(t.dateIso);
|
|
739
|
+
if (!Le(l)) throw new Error("The date is not a date.");
|
|
740
|
+
const { purposes: a, outcomes: c } = nt.current;
|
|
741
|
+
if (t.purposeId && !a.some((i) => i.id === t.purposeId))
|
|
742
|
+
throw new Error("That purpose is not offered.");
|
|
743
|
+
if (t.outcomeId && !c.some((i) => i.id === t.outcomeId))
|
|
744
|
+
throw new Error("That outcome is not offered.");
|
|
745
|
+
if (h.current) throw new Error("A write is in progress.");
|
|
746
|
+
await We(
|
|
747
|
+
{
|
|
748
|
+
dateIso: l.toISOString(),
|
|
749
|
+
purposeId: t.purposeId ?? null,
|
|
750
|
+
outcomeId: t.outcomeId ?? null,
|
|
751
|
+
description: (t.description ?? "").trim()
|
|
752
|
+
},
|
|
753
|
+
"agent"
|
|
754
|
+
);
|
|
755
|
+
},
|
|
756
|
+
updateCall: async (t, l) => {
|
|
757
|
+
if (await e(!!ee.current, "edit a call"), !rt.current.some((a) => a.id === t))
|
|
758
|
+
throw new Error("No call has that id.");
|
|
759
|
+
if (!l.description.trim())
|
|
760
|
+
throw new Error("The description is empty.");
|
|
761
|
+
if (h.current) throw new Error("A write is in progress.");
|
|
762
|
+
await et(t, l.description.trim(), "agent");
|
|
763
|
+
},
|
|
764
|
+
deleteCall: async (t) => {
|
|
765
|
+
if (await e(!!te.current, "delete a call"), !rt.current.some((l) => l.id === t))
|
|
766
|
+
throw new Error("No call has that id.");
|
|
767
|
+
if (h.current) throw new Error("A write is in progress.");
|
|
768
|
+
await tt(t, "agent");
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
}, [We, et, tt]);
|
|
772
|
+
en(cn, Fr, n);
|
|
773
|
+
const Vt = d(!1);
|
|
774
|
+
Q(() => {
|
|
775
|
+
const e = M.current;
|
|
776
|
+
if (!e) return;
|
|
777
|
+
const t = Ne.current && (!document.activeElement || document.activeElement === document.body);
|
|
778
|
+
if (Vt.current && !t || !t && !p && N !== "ready") return;
|
|
779
|
+
Vt.current = !0;
|
|
780
|
+
const l = p || N !== "ready" ? null : Be.current;
|
|
781
|
+
if (l) {
|
|
782
|
+
l.focus({ preventScroll: !0 });
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
const a = e.querySelector("h2");
|
|
786
|
+
a && (a.setAttribute("tabindex", "-1"), a.focus({ preventScroll: !0, focusVisible: !1 }));
|
|
787
|
+
}, [p, N]);
|
|
788
|
+
const qt = {
|
|
789
|
+
onFocusCapture: () => {
|
|
790
|
+
Ne.current = !0;
|
|
791
|
+
},
|
|
792
|
+
onBlurCapture: (e) => {
|
|
793
|
+
e.relatedTarget && (Ne.current = !1);
|
|
794
|
+
}
|
|
795
|
+
}, $t = N === "loading" ? o("callsPanel.loading") : x === "create" || x === "update" ? o("callsPanel.saving") : x === "delete" ? o("callsPanel.deleting") : Ze === "saved" ? o("callsPanel.saved") : Ze === "updated" ? o("callsPanel.updated") : Ze === "deleted" ? o("callsPanel.deleted") : (
|
|
796
|
+
// How many calls match, once the reader has changed a filter.
|
|
797
|
+
Mr && !p ? o("callsPanel.filteredCount", { count: Ue.length }) : ""
|
|
798
|
+
), [Hr, zr] = g("");
|
|
799
|
+
if (Q(() => {
|
|
800
|
+
zr($t);
|
|
801
|
+
}, [$t]), p)
|
|
802
|
+
return /* @__PURE__ */ m(
|
|
803
|
+
"section",
|
|
804
|
+
{
|
|
805
|
+
ref: M,
|
|
806
|
+
"data-component": "calls-panel",
|
|
807
|
+
"data-component-id": n,
|
|
808
|
+
"data-privacy": "masked",
|
|
809
|
+
"aria-labelledby": u ? void 0 : Pe,
|
|
810
|
+
"aria-label": u,
|
|
811
|
+
className: [cr(), Pt].filter(Boolean).join(" "),
|
|
812
|
+
...qt,
|
|
813
|
+
...It,
|
|
814
|
+
children: [
|
|
815
|
+
/* @__PURE__ */ r(
|
|
816
|
+
sr,
|
|
817
|
+
{
|
|
818
|
+
title: Nt,
|
|
819
|
+
icon: /* @__PURE__ */ r(mt, { "aria-hidden": "true" }),
|
|
820
|
+
headingId: u ? void 0 : Pe,
|
|
821
|
+
divider: !0
|
|
822
|
+
}
|
|
823
|
+
),
|
|
824
|
+
/* @__PURE__ */ r("div", { className: "ds:p-[var(--spacing-md)]", children: /* @__PURE__ */ r(
|
|
825
|
+
Oe,
|
|
826
|
+
{
|
|
827
|
+
variant: "first-use",
|
|
828
|
+
size: "sm",
|
|
829
|
+
title: o("callsPanel.privacyTitle"),
|
|
830
|
+
description: o("callsPanel.privacyDescription")
|
|
831
|
+
}
|
|
832
|
+
) })
|
|
833
|
+
]
|
|
834
|
+
}
|
|
835
|
+
);
|
|
836
|
+
let ce;
|
|
837
|
+
if (N === "loading")
|
|
838
|
+
ce = /* @__PURE__ */ r(
|
|
839
|
+
"div",
|
|
840
|
+
{
|
|
841
|
+
"data-calls-state": "loading",
|
|
842
|
+
className: "ds:flex ds:min-h-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-sm)] ds:overflow-y-auto ds:p-[var(--spacing-md)]",
|
|
843
|
+
"aria-hidden": "true",
|
|
844
|
+
children: ["a", "b", "c"].map((e, t) => /* @__PURE__ */ m("div", { className: dr(), children: [
|
|
845
|
+
/* @__PURE__ */ r(pt, { variant: "text", size: "md", width: "60%", stagger: t }),
|
|
846
|
+
/* @__PURE__ */ r(pt, { variant: "text", size: "sm", width: "90%", stagger: t }),
|
|
847
|
+
/* @__PURE__ */ r(pt, { variant: "text", size: "sm", width: "40%", stagger: t })
|
|
848
|
+
] }, e))
|
|
849
|
+
}
|
|
850
|
+
);
|
|
851
|
+
else if (N === "error")
|
|
852
|
+
ce = /* @__PURE__ */ r(
|
|
853
|
+
"div",
|
|
854
|
+
{
|
|
855
|
+
"data-calls-state": "error",
|
|
856
|
+
className: "ds:min-h-0 ds:flex-1 ds:overflow-y-auto ds:p-[var(--spacing-md)]",
|
|
857
|
+
children: /* @__PURE__ */ r(
|
|
858
|
+
Oe,
|
|
859
|
+
{
|
|
860
|
+
variant: "error",
|
|
861
|
+
size: "sm",
|
|
862
|
+
title: o("callsPanel.errorTitle"),
|
|
863
|
+
primaryAction: A ? { label: o("callsPanel.retry"), onClick: A } : void 0
|
|
864
|
+
}
|
|
865
|
+
)
|
|
866
|
+
}
|
|
867
|
+
);
|
|
868
|
+
else if (Ue.length === 0) {
|
|
869
|
+
const e = Y ? F > 0 : Se.length > 0, t = Object.values(j).some(Boolean);
|
|
870
|
+
ce = e ? /* @__PURE__ */ r(
|
|
871
|
+
"div",
|
|
872
|
+
{
|
|
873
|
+
"data-calls-state": "filtered-empty",
|
|
874
|
+
className: "ds:min-h-0 ds:flex-1 ds:overflow-y-auto ds:p-[var(--spacing-md)]",
|
|
875
|
+
children: /* @__PURE__ */ r(
|
|
876
|
+
Oe,
|
|
877
|
+
{
|
|
878
|
+
variant: "no-results",
|
|
879
|
+
size: "sm",
|
|
880
|
+
title: o("callsPanel.filteredEmptyTitle"),
|
|
881
|
+
description: o("callsPanel.filteredEmptyDescription"),
|
|
882
|
+
primaryAction: (
|
|
883
|
+
/* The "filters on" row in the header already offers Clear
|
|
884
|
+
filters while it shows: offer it once. */
|
|
885
|
+
t && !(At && F > 0) ? {
|
|
886
|
+
label: o("callsPanel.clearFilters"),
|
|
887
|
+
onClick: Rt
|
|
888
|
+
} : void 0
|
|
889
|
+
)
|
|
890
|
+
}
|
|
891
|
+
)
|
|
892
|
+
}
|
|
893
|
+
) : /* @__PURE__ */ r(
|
|
894
|
+
"div",
|
|
895
|
+
{
|
|
896
|
+
"data-calls-state": "empty",
|
|
897
|
+
className: "ds:min-h-0 ds:flex-1 ds:overflow-y-auto ds:p-[var(--spacing-md)]",
|
|
898
|
+
children: /* @__PURE__ */ r(
|
|
899
|
+
Oe,
|
|
900
|
+
{
|
|
901
|
+
variant: "first-use",
|
|
902
|
+
size: "sm",
|
|
903
|
+
title: o("callsPanel.emptyTitle"),
|
|
904
|
+
description: o("callsPanel.emptyDescription")
|
|
905
|
+
}
|
|
906
|
+
)
|
|
907
|
+
}
|
|
908
|
+
);
|
|
909
|
+
} else
|
|
910
|
+
ce = /* @__PURE__ */ r(
|
|
911
|
+
"div",
|
|
912
|
+
{
|
|
913
|
+
tabIndex: $ || K ? void 0 : 0,
|
|
914
|
+
className: "ds:min-h-0 ds:flex-1 ds:overflow-y-auto ds:p-[var(--spacing-md)] ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid ds:focus-visible:outline-ring ds:focus-visible:-outline-offset-[length:var(--focus-ring-width)]",
|
|
915
|
+
children: /* @__PURE__ */ r(
|
|
916
|
+
"ul",
|
|
917
|
+
{
|
|
918
|
+
"aria-label": o("callsPanel.listLabel"),
|
|
919
|
+
className: "ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-0",
|
|
920
|
+
children: Ue.map((e) => {
|
|
921
|
+
var Qt, Xt, Wt, er, tr, rr;
|
|
922
|
+
const t = Ve(e.dateIso), l = Tt(O, e.outcomeId), a = Tt(_, e.purposeId), c = ((Qt = O.find((I) => I.id === e.outcomeId)) == null ? void 0 : Qt.tone) ?? gr[e.outcomeId ?? ""] ?? "neutral", i = (y == null ? void 0 : y.id) === e.id, Zt = (e.description ?? "").trim(), Jr = e.missed === !0 && e.direction !== "outgoing", ot = typeof e.durationSeconds == "number" && Number.isFinite(e.durationSeconds) && e.durationSeconds >= 0 ? un(e.durationSeconds, Ie) : void 0, st = (Xt = e.phoneNumber) != null && Xt.trim() ? rn(e.phoneNumber.trim()) : void 0, lt = (Wt = e.handledBy) == null ? void 0 : Wt.trim(), Gr = ((er = e.source) == null ? void 0 : er.kind) === "integration", Jt = (rr = (tr = e.source) == null ? void 0 : tr.name) == null ? void 0 : rr.trim(), at = ur(e.recordingHref), it = ur(e.transcriptHref), Gt = `${Sr}-edit-${e.id}`, ct = `${Gt}-msg`;
|
|
923
|
+
return /* @__PURE__ */ m(
|
|
924
|
+
"li",
|
|
925
|
+
{
|
|
926
|
+
"data-call-id": e.id,
|
|
927
|
+
"data-outcome": e.outcomeId || void 0,
|
|
928
|
+
className: dr(),
|
|
929
|
+
children: [
|
|
930
|
+
/* @__PURE__ */ m("div", { className: "ds:flex ds:min-w-0 ds:items-start ds:gap-[var(--spacing-xs)]", children: [
|
|
931
|
+
/* @__PURE__ */ m("div", { className: "ds:flex ds:min-w-0 ds:flex-1 ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-sm)] ds:gap-y-[var(--spacing-2xs)] ds:py-[var(--spacing-xs)]", children: [
|
|
932
|
+
/* @__PURE__ */ r(
|
|
933
|
+
"time",
|
|
934
|
+
{
|
|
935
|
+
dateTime: e.dateIso,
|
|
936
|
+
className: "type-body-sm ds:font-semibold ds:text-[color:var(--foreground)]",
|
|
937
|
+
children: t
|
|
938
|
+
}
|
|
939
|
+
),
|
|
940
|
+
Jr ? /* @__PURE__ */ r(
|
|
941
|
+
ut,
|
|
942
|
+
{
|
|
943
|
+
status: "missed",
|
|
944
|
+
label: o("callsPanel.missedCall"),
|
|
945
|
+
"data-calls-direction": "missed"
|
|
946
|
+
}
|
|
947
|
+
) : e.direction ? /* @__PURE__ */ r(
|
|
948
|
+
ut,
|
|
949
|
+
{
|
|
950
|
+
status: e.direction,
|
|
951
|
+
label: e.direction === "incoming" ? o("callsPanel.incoming") : o("callsPanel.outgoing"),
|
|
952
|
+
"data-calls-direction": e.direction
|
|
953
|
+
}
|
|
954
|
+
) : null,
|
|
955
|
+
l ? /* @__PURE__ */ r(
|
|
956
|
+
ut,
|
|
957
|
+
{
|
|
958
|
+
status: dn.has(e.outcomeId ?? "") ? e.outcomeId : "custom",
|
|
959
|
+
label: l,
|
|
960
|
+
tone: c,
|
|
961
|
+
"data-calls-outcome": ""
|
|
962
|
+
}
|
|
963
|
+
) : null,
|
|
964
|
+
a ? /* @__PURE__ */ r(
|
|
965
|
+
"span",
|
|
966
|
+
{
|
|
967
|
+
"data-calls-purpose": "",
|
|
968
|
+
className: "type-meta ds:min-w-0 ds:text-[color:var(--muted-foreground)] ds:[overflow-wrap:anywhere]",
|
|
969
|
+
children: a
|
|
970
|
+
}
|
|
971
|
+
) : null
|
|
972
|
+
] }),
|
|
973
|
+
!i && ($ || K) ? /* @__PURE__ */ m("div", { className: "ds:-me-[var(--spacing-xs)] ds:flex ds:shrink-0 ds:items-center", children: [
|
|
974
|
+
$ ? /* @__PURE__ */ r(
|
|
975
|
+
nr,
|
|
976
|
+
{
|
|
977
|
+
"data-calls-edit": "",
|
|
978
|
+
icon: /* @__PURE__ */ r(ln, {}),
|
|
979
|
+
intent: "ghost",
|
|
980
|
+
"aria-label": o("callsPanel.editNamed", {
|
|
981
|
+
date: t
|
|
982
|
+
}),
|
|
983
|
+
tooltip: o("callsPanel.edit"),
|
|
984
|
+
"aria-disabled": x ? !0 : void 0,
|
|
985
|
+
onClick: () => jr(e)
|
|
986
|
+
}
|
|
987
|
+
) : null,
|
|
988
|
+
K ? /* @__PURE__ */ r(
|
|
989
|
+
nr,
|
|
990
|
+
{
|
|
991
|
+
"data-calls-delete": "",
|
|
992
|
+
icon: /* @__PURE__ */ r(ir, {}),
|
|
993
|
+
intent: "ghost",
|
|
994
|
+
"aria-label": o("callsPanel.deleteNamed", {
|
|
995
|
+
date: t
|
|
996
|
+
}),
|
|
997
|
+
tooltip: o("callsPanel.delete"),
|
|
998
|
+
"aria-disabled": x ? !0 : void 0,
|
|
999
|
+
onClick: () => {
|
|
1000
|
+
h.current || (ie(null), S(null), Xe.current = e.id, ae(e.id));
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
) : null
|
|
1004
|
+
] }) : null
|
|
1005
|
+
] }),
|
|
1006
|
+
i && y ? /* @__PURE__ */ m(
|
|
1007
|
+
"div",
|
|
1008
|
+
{
|
|
1009
|
+
"data-calls-editor": "",
|
|
1010
|
+
className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
|
|
1011
|
+
children: [
|
|
1012
|
+
/* @__PURE__ */ r(
|
|
1013
|
+
ar,
|
|
1014
|
+
{
|
|
1015
|
+
id: Gt,
|
|
1016
|
+
"aria-label": o("callsPanel.editLabel", { date: t }),
|
|
1017
|
+
value: y.text,
|
|
1018
|
+
minRows: 3,
|
|
1019
|
+
autoResize: !0,
|
|
1020
|
+
ref: (I) => {
|
|
1021
|
+
I && Qe.current === e.id && (Qe.current = null, I.focus());
|
|
1022
|
+
},
|
|
1023
|
+
tone: ke || ne ? "error" : "default",
|
|
1024
|
+
"aria-invalid": ke || !!ne || void 0,
|
|
1025
|
+
"aria-describedby": ke || ne ? ct : void 0,
|
|
1026
|
+
onChange: (I) => {
|
|
1027
|
+
V({ id: e.id, text: I.target.value }), Ee(!1);
|
|
1028
|
+
},
|
|
1029
|
+
onKeyDown: (I) => {
|
|
1030
|
+
I.key === "Enter" && (I.ctrlKey || I.metaKey) && y.text.trim() ? (I.preventDefault(), Kt()) : I.key === "Escape" && (I.preventDefault(), I.stopPropagation(), _t());
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
),
|
|
1034
|
+
ke ? /* @__PURE__ */ r(
|
|
1035
|
+
"p",
|
|
1036
|
+
{
|
|
1037
|
+
id: ct,
|
|
1038
|
+
role: "alert",
|
|
1039
|
+
"data-calls-edit-error": "",
|
|
1040
|
+
className: "ds:m-0 type-meta ds:text-[color:var(--destructive)]",
|
|
1041
|
+
children: o("callsPanel.editRequired")
|
|
1042
|
+
}
|
|
1043
|
+
) : null,
|
|
1044
|
+
ne ? /* @__PURE__ */ r(X, { variant: "error", "data-calls-edit-refused": "", children: /* @__PURE__ */ r(X.Description, { id: ct, children: ne }) }) : null,
|
|
1045
|
+
/* @__PURE__ */ m("div", { className: "ds:flex ds:flex-wrap ds:justify-end ds:gap-[var(--spacing-sm)]", children: [
|
|
1046
|
+
/* @__PURE__ */ r(
|
|
1047
|
+
D,
|
|
1048
|
+
{
|
|
1049
|
+
type: "button",
|
|
1050
|
+
intent: "outline",
|
|
1051
|
+
size: "sm",
|
|
1052
|
+
"aria-disabled": x ? !0 : void 0,
|
|
1053
|
+
onClick: _t,
|
|
1054
|
+
children: o("callsPanel.editCancel")
|
|
1055
|
+
}
|
|
1056
|
+
),
|
|
1057
|
+
/* @__PURE__ */ r(
|
|
1058
|
+
D,
|
|
1059
|
+
{
|
|
1060
|
+
type: "button",
|
|
1061
|
+
size: "sm",
|
|
1062
|
+
"aria-disabled": x ? !0 : void 0,
|
|
1063
|
+
"aria-busy": x === "update" || void 0,
|
|
1064
|
+
onClick: Kt,
|
|
1065
|
+
children: o(x === "update" ? "callsPanel.saving" : "callsPanel.editSave")
|
|
1066
|
+
}
|
|
1067
|
+
)
|
|
1068
|
+
] })
|
|
1069
|
+
]
|
|
1070
|
+
}
|
|
1071
|
+
) : Zt ? /* @__PURE__ */ r(yn, { text: Zt }) : /* @__PURE__ */ r("p", { className: "ds:m-0 type-body-sm ds:text-[color:var(--muted-foreground)]", children: o("callsPanel.noDescription") }),
|
|
1072
|
+
ot || st || lt ? /* @__PURE__ */ m(
|
|
1073
|
+
"div",
|
|
1074
|
+
{
|
|
1075
|
+
"data-calls-details": "",
|
|
1076
|
+
className: "ds:flex ds:min-w-0 ds:flex-wrap ds:items-baseline ds:gap-x-[var(--spacing-sm)] ds:gap-y-[var(--spacing-2xs)] type-meta ds:text-[color:var(--muted-foreground)]",
|
|
1077
|
+
children: [
|
|
1078
|
+
ot ? /* @__PURE__ */ r("span", { "data-calls-duration": "", children: ot }) : null,
|
|
1079
|
+
st ? /* @__PURE__ */ r(
|
|
1080
|
+
"span",
|
|
1081
|
+
{
|
|
1082
|
+
"data-calls-phone": "",
|
|
1083
|
+
dir: "ltr",
|
|
1084
|
+
className: "ds:[overflow-wrap:anywhere]",
|
|
1085
|
+
children: st
|
|
1086
|
+
}
|
|
1087
|
+
) : null,
|
|
1088
|
+
lt ? /* @__PURE__ */ r(
|
|
1089
|
+
"span",
|
|
1090
|
+
{
|
|
1091
|
+
"data-calls-handled-by": "",
|
|
1092
|
+
className: "ds:[overflow-wrap:anywhere]",
|
|
1093
|
+
children: o("callsPanel.takenBy", { name: lt })
|
|
1094
|
+
}
|
|
1095
|
+
) : null
|
|
1096
|
+
]
|
|
1097
|
+
}
|
|
1098
|
+
) : null,
|
|
1099
|
+
Gr ? /* @__PURE__ */ r(
|
|
1100
|
+
"p",
|
|
1101
|
+
{
|
|
1102
|
+
"data-calls-source": "",
|
|
1103
|
+
className: "ds:m-0 type-meta ds:text-[color:var(--muted-foreground)] ds:[overflow-wrap:anywhere]",
|
|
1104
|
+
children: Jt ? o("callsPanel.loggedAutomaticallyBy", {
|
|
1105
|
+
app: Jt
|
|
1106
|
+
}) : o("callsPanel.loggedAutomatically")
|
|
1107
|
+
}
|
|
1108
|
+
) : null,
|
|
1109
|
+
at || it ? /* @__PURE__ */ m(
|
|
1110
|
+
"div",
|
|
1111
|
+
{
|
|
1112
|
+
"data-calls-links": "",
|
|
1113
|
+
className: "ds:flex ds:min-w-0 ds:flex-wrap ds:gap-x-[var(--spacing-md)] ds:gap-y-[var(--spacing-2xs)] type-meta",
|
|
1114
|
+
children: [
|
|
1115
|
+
at ? /* @__PURE__ */ r(or, { href: at, external: !0, children: o("callsPanel.recording") }) : null,
|
|
1116
|
+
it ? /* @__PURE__ */ r(or, { href: it, external: !0, children: o("callsPanel.transcript") }) : null
|
|
1117
|
+
]
|
|
1118
|
+
}
|
|
1119
|
+
) : null,
|
|
1120
|
+
e.createdAtIso ? /* @__PURE__ */ r("p", { className: "ds:m-0 type-meta ds:text-[color:var(--muted-foreground)]", children: o("callsPanel.addedOn", {
|
|
1121
|
+
date: Ve(e.createdAtIso)
|
|
1122
|
+
}) }) : null
|
|
1123
|
+
]
|
|
1124
|
+
},
|
|
1125
|
+
e.id
|
|
1126
|
+
);
|
|
1127
|
+
})
|
|
1128
|
+
}
|
|
1129
|
+
)
|
|
1130
|
+
}
|
|
1131
|
+
);
|
|
1132
|
+
const Br = {
|
|
1133
|
+
all: o("callsPanel.allDirections"),
|
|
1134
|
+
outgoing: o("callsPanel.outgoing"),
|
|
1135
|
+
incoming: o("callsPanel.incoming"),
|
|
1136
|
+
missed: o("callsPanel.directionMissed")
|
|
1137
|
+
}, Ae = {
|
|
1138
|
+
from: ht(v.from),
|
|
1139
|
+
to: ht(v.to)
|
|
1140
|
+
}, Vr = Ae.to && !Ae.from ? o("callsPanel.dateUntil", {
|
|
1141
|
+
date: new Intl.DateTimeFormat(vt(Ie), {
|
|
1142
|
+
calendar: "gregory",
|
|
1143
|
+
day: "numeric",
|
|
1144
|
+
month: "short",
|
|
1145
|
+
year: "numeric"
|
|
1146
|
+
}).format(Ae.to)
|
|
1147
|
+
}) : o("callsPanel.dateRangePlaceholder"), Ut = (e, t) => [
|
|
1148
|
+
{ value: fe, label: t },
|
|
1149
|
+
...e.map((l) => ({ value: l.id, label: l.label }))
|
|
1150
|
+
], qr = At ? /* @__PURE__ */ m(
|
|
1151
|
+
"div",
|
|
1152
|
+
{
|
|
1153
|
+
role: "group",
|
|
1154
|
+
"aria-label": o("callsPanel.filtersLabel"),
|
|
1155
|
+
"data-calls-filters": "",
|
|
1156
|
+
className: "ds:flex ds:w-full ds:flex-col ds:gap-[var(--spacing-sm)]",
|
|
1157
|
+
children: [
|
|
1158
|
+
/* @__PURE__ */ m("div", { className: "ds:grid ds:grid-cols-[repeat(auto-fit,minmax(min(100%,8rem),1fr))] ds:items-center ds:gap-[var(--spacing-sm)]", children: [
|
|
1159
|
+
kt ? /* @__PURE__ */ r("div", { className: "ds:min-w-0", children: /* @__PURE__ */ r(
|
|
1160
|
+
me,
|
|
1161
|
+
{
|
|
1162
|
+
"aria-label": o("callsPanel.outcomeFilterLabel"),
|
|
1163
|
+
"data-calls-filter": "outcome",
|
|
1164
|
+
options: Ut(O, o("callsPanel.allOutcomes")),
|
|
1165
|
+
value: v.outcome ?? fe,
|
|
1166
|
+
onValueChange: (e) => H({
|
|
1167
|
+
outcome: !e || e === fe ? null : e
|
|
1168
|
+
})
|
|
1169
|
+
}
|
|
1170
|
+
) }) : null,
|
|
1171
|
+
Et ? /* @__PURE__ */ r("div", { className: "ds:min-w-0", children: /* @__PURE__ */ r(
|
|
1172
|
+
me,
|
|
1173
|
+
{
|
|
1174
|
+
"aria-label": o("callsPanel.purposeFilterLabel"),
|
|
1175
|
+
"data-calls-filter": "purpose",
|
|
1176
|
+
options: Ut(_, o("callsPanel.allPurposes")),
|
|
1177
|
+
value: v.purpose ?? fe,
|
|
1178
|
+
onValueChange: (e) => H({
|
|
1179
|
+
purpose: !e || e === fe ? null : e
|
|
1180
|
+
})
|
|
1181
|
+
}
|
|
1182
|
+
) }) : null,
|
|
1183
|
+
Ct ? /* @__PURE__ */ r("div", { className: "ds:min-w-0", children: /* @__PURE__ */ r(
|
|
1184
|
+
me,
|
|
1185
|
+
{
|
|
1186
|
+
"aria-label": o("callsPanel.directionFilterLabel"),
|
|
1187
|
+
"data-calls-filter": "direction",
|
|
1188
|
+
options: ft.map((e) => ({
|
|
1189
|
+
value: e,
|
|
1190
|
+
label: Br[e]
|
|
1191
|
+
})),
|
|
1192
|
+
value: v.direction,
|
|
1193
|
+
onValueChange: (e) => H({
|
|
1194
|
+
direction: ft.includes(
|
|
1195
|
+
e
|
|
1196
|
+
) ? e : "all"
|
|
1197
|
+
})
|
|
1198
|
+
}
|
|
1199
|
+
) }) : null,
|
|
1200
|
+
Dt ? /* @__PURE__ */ r(
|
|
1201
|
+
"div",
|
|
1202
|
+
{
|
|
1203
|
+
role: "group",
|
|
1204
|
+
"aria-label": o("callsPanel.dateRangeLabel"),
|
|
1205
|
+
"data-calls-filter": "date",
|
|
1206
|
+
className: "ds:min-w-0",
|
|
1207
|
+
children: /* @__PURE__ */ r(
|
|
1208
|
+
on,
|
|
1209
|
+
{
|
|
1210
|
+
compact: !0,
|
|
1211
|
+
value: Ae,
|
|
1212
|
+
placeholder: Vr,
|
|
1213
|
+
onChange: (e) => H({
|
|
1214
|
+
from: e.from ? yt(e.from) : null,
|
|
1215
|
+
to: e.to ? yt(e.to) : null
|
|
1216
|
+
})
|
|
1217
|
+
}
|
|
1218
|
+
)
|
|
1219
|
+
}
|
|
1220
|
+
) : null
|
|
1221
|
+
] }),
|
|
1222
|
+
F > 0 ? /* @__PURE__ */ m("div", { className: "ds:flex ds:flex-wrap ds:items-center ds:justify-between ds:gap-x-[var(--spacing-sm)]", children: [
|
|
1223
|
+
/* @__PURE__ */ r(
|
|
1224
|
+
"span",
|
|
1225
|
+
{
|
|
1226
|
+
"data-calls-filter-count": "",
|
|
1227
|
+
className: "type-body-sm ds:text-[color:var(--muted-foreground)]",
|
|
1228
|
+
children: o("callsPanel.filtersActive", { count: F })
|
|
1229
|
+
}
|
|
1230
|
+
),
|
|
1231
|
+
/* @__PURE__ */ r(
|
|
1232
|
+
D,
|
|
1233
|
+
{
|
|
1234
|
+
type: "button",
|
|
1235
|
+
intent: "ghost",
|
|
1236
|
+
size: "sm",
|
|
1237
|
+
"data-calls-clear-filters": "",
|
|
1238
|
+
onClick: Rt,
|
|
1239
|
+
children: o("callsPanel.clearFilters")
|
|
1240
|
+
}
|
|
1241
|
+
)
|
|
1242
|
+
] }) : null
|
|
1243
|
+
]
|
|
1244
|
+
}
|
|
1245
|
+
) : void 0, Re = x === "create", $r = _r && !Le(T.date) ? o("callsPanel.dateRequired") : void 0, Ur = /* @__PURE__ */ m(Qr, { children: [
|
|
1246
|
+
/* @__PURE__ */ r(
|
|
1247
|
+
D,
|
|
1248
|
+
{
|
|
1249
|
+
type: "button",
|
|
1250
|
+
intent: "outline",
|
|
1251
|
+
"aria-disabled": Re || void 0,
|
|
1252
|
+
onClick: () => {
|
|
1253
|
+
h.current || B(!1);
|
|
1254
|
+
},
|
|
1255
|
+
children: o("callsPanel.cancel")
|
|
1256
|
+
}
|
|
1257
|
+
),
|
|
1258
|
+
/* @__PURE__ */ r(
|
|
1259
|
+
D,
|
|
1260
|
+
{
|
|
1261
|
+
type: "button",
|
|
1262
|
+
"aria-disabled": Re || void 0,
|
|
1263
|
+
"aria-busy": Re || void 0,
|
|
1264
|
+
onClick: Mt,
|
|
1265
|
+
children: o(Re ? "callsPanel.saving" : "callsPanel.save")
|
|
1266
|
+
}
|
|
1267
|
+
)
|
|
1268
|
+
] }), Zr = Ce ? Ve(Ce.dateIso) : "", de = x === "delete";
|
|
1269
|
+
return /* @__PURE__ */ m(
|
|
1270
|
+
"section",
|
|
1271
|
+
{
|
|
1272
|
+
ref: M,
|
|
1273
|
+
"data-component": "calls-panel",
|
|
1274
|
+
"data-component-id": n,
|
|
1275
|
+
"aria-labelledby": u ? void 0 : Pe,
|
|
1276
|
+
"aria-label": u,
|
|
1277
|
+
className: [cr(), Pt].filter(Boolean).join(" "),
|
|
1278
|
+
...qt,
|
|
1279
|
+
...It,
|
|
1280
|
+
children: [
|
|
1281
|
+
/* @__PURE__ */ m(lr.Host, { className: "ds:flex-1", children: [
|
|
1282
|
+
/* @__PURE__ */ r(
|
|
1283
|
+
sr,
|
|
1284
|
+
{
|
|
1285
|
+
title: Nt,
|
|
1286
|
+
icon: /* @__PURE__ */ r(mt, { "aria-hidden": "true" }),
|
|
1287
|
+
headingId: u ? void 0 : Pe,
|
|
1288
|
+
filters: qr,
|
|
1289
|
+
divider: !0
|
|
1290
|
+
}
|
|
1291
|
+
),
|
|
1292
|
+
/* @__PURE__ */ r("span", { role: "status", className: "ds:sr-only", children: Hr }),
|
|
1293
|
+
q && N === "ready" ? /* @__PURE__ */ r("div", { className: "ds:shrink-0 ds:px-[var(--spacing-md)] ds:pt-[var(--spacing-md)]", children: /* @__PURE__ */ r(
|
|
1294
|
+
D,
|
|
1295
|
+
{
|
|
1296
|
+
ref: Be,
|
|
1297
|
+
type: "button",
|
|
1298
|
+
className: "ds:w-full",
|
|
1299
|
+
startIcon: /* @__PURE__ */ r(an, { "aria-hidden": "true" }),
|
|
1300
|
+
onClick: Ge,
|
|
1301
|
+
children: o("callsPanel.logCall")
|
|
1302
|
+
}
|
|
1303
|
+
) }) : null,
|
|
1304
|
+
ce,
|
|
1305
|
+
q ? /* @__PURE__ */ r(
|
|
1306
|
+
lr,
|
|
1307
|
+
{
|
|
1308
|
+
ref: St,
|
|
1309
|
+
open: xe,
|
|
1310
|
+
title: o("callsPanel.formTitle"),
|
|
1311
|
+
icon: /* @__PURE__ */ r(mt, { "aria-hidden": "true" }),
|
|
1312
|
+
backLabel: o("callsPanel.back"),
|
|
1313
|
+
headingLevel: 2,
|
|
1314
|
+
initialFocusRef: Yt,
|
|
1315
|
+
onBack: () => {
|
|
1316
|
+
h.current || B(!1);
|
|
1317
|
+
},
|
|
1318
|
+
footer: Ur,
|
|
1319
|
+
"data-calls-form": "",
|
|
1320
|
+
children: /* @__PURE__ */ m("div", { className: "ds:-m-[var(--panel-subview-inset)] ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]", children: [
|
|
1321
|
+
Ot ? /* @__PURE__ */ r(X, { variant: "error", "data-calls-form-error": "", children: /* @__PURE__ */ r(X.Description, { children: Ot }) }) : null,
|
|
1322
|
+
/* @__PURE__ */ r("div", { "data-calls-date": "", children: /* @__PURE__ */ r(
|
|
1323
|
+
Ye,
|
|
1324
|
+
{
|
|
1325
|
+
label: o("callsPanel.dateLabel"),
|
|
1326
|
+
required: !0,
|
|
1327
|
+
error: $r,
|
|
1328
|
+
children: /* @__PURE__ */ r(
|
|
1329
|
+
sn,
|
|
1330
|
+
{
|
|
1331
|
+
value: T.date,
|
|
1332
|
+
onChange: (e) => {
|
|
1333
|
+
J((t) => ({ ...t, date: e })), e && Je(!1);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
)
|
|
1337
|
+
}
|
|
1338
|
+
) }),
|
|
1339
|
+
_.length > 0 ? /* @__PURE__ */ r(Ye, { label: o("callsPanel.purposeLabel"), optional: !0, children: /* @__PURE__ */ r(
|
|
1340
|
+
me,
|
|
1341
|
+
{
|
|
1342
|
+
options: _.map((e) => ({
|
|
1343
|
+
value: e.id,
|
|
1344
|
+
label: e.label
|
|
1345
|
+
})),
|
|
1346
|
+
value: T.purposeId,
|
|
1347
|
+
placeholder: o("callsPanel.notSet"),
|
|
1348
|
+
clearable: !0,
|
|
1349
|
+
onValueChange: (e) => J((t) => ({ ...t, purposeId: e }))
|
|
1350
|
+
}
|
|
1351
|
+
) }) : null,
|
|
1352
|
+
O.length > 0 ? /* @__PURE__ */ r(Ye, { label: o("callsPanel.outcomeLabel"), optional: !0, children: /* @__PURE__ */ r(
|
|
1353
|
+
me,
|
|
1354
|
+
{
|
|
1355
|
+
options: O.map((e) => ({
|
|
1356
|
+
value: e.id,
|
|
1357
|
+
label: e.label
|
|
1358
|
+
})),
|
|
1359
|
+
value: T.outcomeId,
|
|
1360
|
+
placeholder: o("callsPanel.notSet"),
|
|
1361
|
+
clearable: !0,
|
|
1362
|
+
onValueChange: (e) => J((t) => ({ ...t, outcomeId: e }))
|
|
1363
|
+
}
|
|
1364
|
+
) }) : null,
|
|
1365
|
+
/* @__PURE__ */ r(Ye, { label: o("callsPanel.descriptionLabel"), optional: !0, children: /* @__PURE__ */ r(
|
|
1366
|
+
ar,
|
|
1367
|
+
{
|
|
1368
|
+
value: T.description,
|
|
1369
|
+
placeholder: o("callsPanel.descriptionPlaceholder"),
|
|
1370
|
+
minRows: 4,
|
|
1371
|
+
autoResize: !0,
|
|
1372
|
+
onChange: (e) => J((t) => ({ ...t, description: e.target.value })),
|
|
1373
|
+
onKeyDown: (e) => {
|
|
1374
|
+
e.key === "Enter" && (e.ctrlKey || e.metaKey) && T.description.trim() && (e.preventDefault(), Mt());
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
) })
|
|
1378
|
+
] })
|
|
1379
|
+
}
|
|
1380
|
+
) : null
|
|
1381
|
+
] }),
|
|
1382
|
+
K ? /* @__PURE__ */ r(
|
|
1383
|
+
L,
|
|
1384
|
+
{
|
|
1385
|
+
open: !!Ce,
|
|
1386
|
+
onOpenChange: (e) => {
|
|
1387
|
+
de || e || (ae(null), ie(null));
|
|
1388
|
+
},
|
|
1389
|
+
children: /* @__PURE__ */ m(
|
|
1390
|
+
L.Content,
|
|
1391
|
+
{
|
|
1392
|
+
size: "sm",
|
|
1393
|
+
variant: "alert",
|
|
1394
|
+
onCloseAutoFocus: (e) => {
|
|
1395
|
+
e.preventDefault(), re.current && (S(re.current), re.current = null);
|
|
1396
|
+
const t = M.current, l = (Xe.current ? t == null ? void 0 : t.querySelector(
|
|
1397
|
+
`[data-call-id="${CSS.escape(Xe.current)}"] [data-calls-delete]`
|
|
1398
|
+
) : null) ?? Be.current ?? (t == null ? void 0 : t.querySelector("h2"));
|
|
1399
|
+
l && (l.tagName === "H2" && l.setAttribute("tabindex", "-1"), l.focus({ preventScroll: !0 }));
|
|
1400
|
+
},
|
|
1401
|
+
children: [
|
|
1402
|
+
/* @__PURE__ */ m(L.Header, { children: [
|
|
1403
|
+
/* @__PURE__ */ r(L.Title, { children: o("callsPanel.deleteTitle") }),
|
|
1404
|
+
/* @__PURE__ */ r(L.Description, { children: o("callsPanel.deleteBody", { date: Zr }) })
|
|
1405
|
+
] }),
|
|
1406
|
+
Lt ? /* @__PURE__ */ r(L.Body, { children: /* @__PURE__ */ r(X, { variant: "error", "data-calls-delete-error": "", children: /* @__PURE__ */ r(X.Description, { children: Lt }) }) }) : null,
|
|
1407
|
+
/* @__PURE__ */ m(L.Footer, { divider: !0, children: [
|
|
1408
|
+
/* @__PURE__ */ r(L.Close, { asChild: !0, children: /* @__PURE__ */ r(
|
|
1409
|
+
D,
|
|
1410
|
+
{
|
|
1411
|
+
intent: "outline",
|
|
1412
|
+
"aria-disabled": de || void 0,
|
|
1413
|
+
children: o("callsPanel.deleteCancel")
|
|
1414
|
+
}
|
|
1415
|
+
) }),
|
|
1416
|
+
/* @__PURE__ */ r(
|
|
1417
|
+
D,
|
|
1418
|
+
{
|
|
1419
|
+
intent: "destructive",
|
|
1420
|
+
startIcon: /* @__PURE__ */ r(ir, { "aria-hidden": "true" }),
|
|
1421
|
+
"aria-disabled": de || void 0,
|
|
1422
|
+
"aria-busy": de || void 0,
|
|
1423
|
+
onClick: () => {
|
|
1424
|
+
le && !h.current && tt(le).catch(() => {
|
|
1425
|
+
});
|
|
1426
|
+
},
|
|
1427
|
+
children: o(de ? "callsPanel.deleting" : "callsPanel.deleteConfirm")
|
|
1428
|
+
}
|
|
1429
|
+
)
|
|
1430
|
+
] })
|
|
1431
|
+
]
|
|
1432
|
+
}
|
|
1433
|
+
)
|
|
1434
|
+
}
|
|
1435
|
+
) : null
|
|
1436
|
+
]
|
|
1437
|
+
}
|
|
1438
|
+
);
|
|
1439
|
+
}
|
|
1440
|
+
);
|
|
1441
|
+
wn.displayName = "CallsPanel";
|
|
1442
|
+
export {
|
|
1443
|
+
wn as C,
|
|
1444
|
+
cn as c
|
|
1445
|
+
};
|
|
1446
|
+
//# sourceMappingURL=calls-panel-CJNQm7r8.js.map
|