@whooshbang/sdk 5.0.0 → 6.0.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/README.md +232 -83
- package/dist/cli/commands.js +2 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/client.d.ts +209 -1
- package/dist/client.js +540 -5
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interactions.js +18 -3
- package/dist/interactions.js.map +1 -1
- package/dist/recipient/element.js +641 -14
- package/dist/recipient/element.js.map +1 -1
- package/dist/recipient/i18n/ar.js +77 -0
- package/dist/recipient/i18n/ar.js.map +1 -1
- package/dist/recipient/i18n/catalog.d.ts +75 -0
- package/dist/recipient/i18n/catalog.js.map +1 -1
- package/dist/recipient/i18n/de.js +82 -0
- package/dist/recipient/i18n/de.js.map +1 -1
- package/dist/recipient/i18n/en.js +82 -0
- package/dist/recipient/i18n/en.js.map +1 -1
- package/dist/recipient/i18n/es.js +82 -0
- package/dist/recipient/i18n/es.js.map +1 -1
- package/dist/recipient/i18n/fa.js +77 -0
- package/dist/recipient/i18n/fa.js.map +1 -1
- package/dist/recipient/i18n/fr.js +82 -0
- package/dist/recipient/i18n/fr.js.map +1 -1
- package/dist/recipient/i18n/hi.js +82 -0
- package/dist/recipient/i18n/hi.js.map +1 -1
- package/dist/recipient/i18n/id.js +82 -0
- package/dist/recipient/i18n/id.js.map +1 -1
- package/dist/recipient/i18n/it.js +82 -0
- package/dist/recipient/i18n/it.js.map +1 -1
- package/dist/recipient/i18n/nl.js +82 -0
- package/dist/recipient/i18n/nl.js.map +1 -1
- package/dist/recipient/i18n/pl.js +82 -0
- package/dist/recipient/i18n/pl.js.map +1 -1
- package/dist/recipient/i18n/pt-BR.js +82 -0
- package/dist/recipient/i18n/pt-BR.js.map +1 -1
- package/dist/recipient/i18n/ru.js +82 -0
- package/dist/recipient/i18n/ru.js.map +1 -1
- package/dist/recipient/i18n/tr.js +82 -0
- package/dist/recipient/i18n/tr.js.map +1 -1
- package/dist/recipient/i18n/uk.js +82 -0
- package/dist/recipient/i18n/uk.js.map +1 -1
- package/dist/recipient/i18n/zh-Hans.js +77 -0
- package/dist/recipient/i18n/zh-Hans.js.map +1 -1
- package/dist/recipient/order-section.d.ts +41 -0
- package/dist/recipient/order-section.js +547 -0
- package/dist/recipient/order-section.js.map +1 -0
- package/dist/recipient/order-view.d.ts +123 -0
- package/dist/recipient/order-view.js +304 -0
- package/dist/recipient/order-view.js.map +1 -0
- package/dist/recipient/platform-mark.d.ts +1 -0
- package/dist/recipient/platform-mark.js +57 -0
- package/dist/recipient/platform-mark.js.map +1 -0
- package/dist/recipient/quiet-section.d.ts +47 -0
- package/dist/recipient/quiet-section.js +490 -0
- package/dist/recipient/quiet-section.js.map +1 -0
- package/dist/recipient/quiet-view.d.ts +84 -0
- package/dist/recipient/quiet-view.js +250 -0
- package/dist/recipient/quiet-view.js.map +1 -0
- package/dist/recipient/view.d.ts +2 -0
- package/dist/recipient/view.js.map +1 -1
- package/dist/webhooks.d.ts +30 -1
- package/dist/webhooks.js +57 -4
- package/dist/webhooks.js.map +1 -1
- package/package.json +12 -2
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { QUIET_DAYS, QUIET_WINDOWS_MAX, quietDayName, quietEndsText, quietOvernight, quietTimeZoneEditable, quietTimeZones, quietWithholds, } from "./quiet-view.js";
|
|
2
|
+
/**
|
|
3
|
+
* "Quiet hours" (FXO-2103): when the recipient would rather not be
|
|
4
|
+
* interrupted, what each channel does then, where a message a channel keeps
|
|
5
|
+
* back goes, and whether critical messages break through.
|
|
6
|
+
*
|
|
7
|
+
* Every control is a native one — toggle buttons, time inputs, radios, a
|
|
8
|
+
* select and a switch — so it works by keyboard, touch and screen reader with
|
|
9
|
+
* nothing to drag. Every value reaches the DOM through `textContent` or a
|
|
10
|
+
* typed property.
|
|
11
|
+
*/
|
|
12
|
+
export const QUIET_SECTION_STYLES = `
|
|
13
|
+
.quiet { container-type: inline-size; }
|
|
14
|
+
.quiet .intro { line-height: 1.45; margin: 0 0 1rem; opacity: .85; }
|
|
15
|
+
.quiet .now {
|
|
16
|
+
background: color-mix(in srgb, currentColor 6%, transparent);
|
|
17
|
+
border-radius: .5rem;
|
|
18
|
+
font-weight: 600;
|
|
19
|
+
margin: 0 0 1rem;
|
|
20
|
+
padding: .625rem .875rem;
|
|
21
|
+
}
|
|
22
|
+
.quiet .warning {
|
|
23
|
+
background: color-mix(in srgb, #c62828 8%, transparent);
|
|
24
|
+
border: 1px solid color-mix(in srgb, #c62828 40%, transparent);
|
|
25
|
+
border-radius: .5rem;
|
|
26
|
+
line-height: 1.45;
|
|
27
|
+
margin: 0 0 1rem;
|
|
28
|
+
padding: .75rem .875rem;
|
|
29
|
+
}
|
|
30
|
+
.quiet fieldset { border: 0; margin: 0 0 1.25rem; min-width: 0; padding: 0; }
|
|
31
|
+
.quiet legend { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; padding: 0; }
|
|
32
|
+
.quiet .period {
|
|
33
|
+
border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
|
|
34
|
+
border-radius: .5rem;
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
gap: .625rem;
|
|
38
|
+
margin-bottom: .625rem;
|
|
39
|
+
padding: .75rem;
|
|
40
|
+
}
|
|
41
|
+
.quiet .period-head { align-items: center; display: flex; justify-content: space-between; gap: .5rem; }
|
|
42
|
+
.quiet .period-head .label { font-size: .9rem; font-weight: 600; }
|
|
43
|
+
.quiet .period-head button.icon {
|
|
44
|
+
align-items: center;
|
|
45
|
+
background: transparent;
|
|
46
|
+
border-radius: .375rem;
|
|
47
|
+
color: inherit;
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
flex: 0 0 auto;
|
|
50
|
+
height: 2.25rem;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
padding: 0;
|
|
53
|
+
width: 2.25rem;
|
|
54
|
+
}
|
|
55
|
+
.quiet .period-head button.icon:disabled { opacity: .35; }
|
|
56
|
+
.quiet .days { display: grid; gap: .25rem; grid-template-columns: repeat(7, minmax(0, 1fr)); }
|
|
57
|
+
.quiet .days button {
|
|
58
|
+
background: transparent;
|
|
59
|
+
border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
|
|
60
|
+
color: inherit;
|
|
61
|
+
min-height: 2.75rem;
|
|
62
|
+
padding: 0 .125rem;
|
|
63
|
+
}
|
|
64
|
+
.quiet .days button[aria-pressed="true"] {
|
|
65
|
+
background: var(--whooshbang-accent, #EB001B);
|
|
66
|
+
border-color: var(--whooshbang-accent, #EB001B);
|
|
67
|
+
color: #fff;
|
|
68
|
+
font-weight: 600;
|
|
69
|
+
}
|
|
70
|
+
.quiet .times { align-items: flex-end; display: flex; flex-wrap: wrap; gap: .75rem; }
|
|
71
|
+
.quiet .times label, .quiet .zone label { display: flex; flex-direction: column; font-size: .85rem; gap: .25rem; }
|
|
72
|
+
.quiet input[type="time"], .quiet select {
|
|
73
|
+
background: Field;
|
|
74
|
+
border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
|
|
75
|
+
border-radius: .375rem;
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
color: inherit;
|
|
78
|
+
font: inherit;
|
|
79
|
+
min-height: 2.75rem;
|
|
80
|
+
padding: 0 .5rem;
|
|
81
|
+
}
|
|
82
|
+
.quiet select { max-width: 100%; }
|
|
83
|
+
.quiet input:focus-visible, .quiet select:focus-visible {
|
|
84
|
+
outline: 2px solid var(--whooshbang-accent, #EB001B);
|
|
85
|
+
outline-offset: 2px;
|
|
86
|
+
}
|
|
87
|
+
.quiet [aria-invalid="true"] { border-color: #b42318; }
|
|
88
|
+
.quiet .overnight { font-size: .85rem; opacity: .75; padding-bottom: .75rem; }
|
|
89
|
+
.quiet .overnight[hidden] { display: none; }
|
|
90
|
+
.quiet .error { color: #b42318; font-size: .85rem; margin: 0; }
|
|
91
|
+
.quiet .muted { font-size: .85rem; margin: 0 0 .5rem; opacity: .75; }
|
|
92
|
+
.quiet .zone { margin-top: .75rem; }
|
|
93
|
+
.quiet .choice {
|
|
94
|
+
border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
|
|
95
|
+
border-radius: .5rem;
|
|
96
|
+
margin-bottom: .5rem;
|
|
97
|
+
padding: .5rem .75rem;
|
|
98
|
+
}
|
|
99
|
+
.quiet .choice legend { font-size: .95rem; margin: 0; padding: .25rem 0; }
|
|
100
|
+
.quiet .options { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
|
|
101
|
+
.quiet .options label, .quiet .withheld label.radio {
|
|
102
|
+
align-items: center;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
display: inline-flex;
|
|
105
|
+
gap: .5rem;
|
|
106
|
+
min-height: 2.75rem;
|
|
107
|
+
}
|
|
108
|
+
.quiet input[type="radio"] { accent-color: var(--whooshbang-accent, #EB001B); height: 1.15rem; margin: 0; width: 1.15rem; }
|
|
109
|
+
.quiet .withheld { display: flex; flex-direction: column; }
|
|
110
|
+
.quiet .withheld .reroute { margin: 0 0 .5rem 1.65rem; }
|
|
111
|
+
.quiet .critical { align-items: center; display: flex; gap: .75rem; justify-content: space-between; }
|
|
112
|
+
.quiet .critical .text { display: flex; flex-direction: column; gap: .15rem; }
|
|
113
|
+
.quiet .critical .text .name { font-weight: 600; }
|
|
114
|
+
.quiet .critical .text .hint { font-size: .85rem; opacity: .75; }
|
|
115
|
+
.quiet .changes { display: flex; flex-wrap: wrap; gap: .625rem; margin-top: 1.25rem; }
|
|
116
|
+
.quiet .changes button { min-height: 2.75rem; padding: 0 1.1rem; }
|
|
117
|
+
.quiet .changes .save { font-weight: 600; }
|
|
118
|
+
.quiet button.link {
|
|
119
|
+
background: transparent;
|
|
120
|
+
color: var(--whooshbang-accent, #EB001B);
|
|
121
|
+
margin-top: 1rem;
|
|
122
|
+
min-height: 2.5rem;
|
|
123
|
+
padding: 0;
|
|
124
|
+
text-decoration: underline;
|
|
125
|
+
}
|
|
126
|
+
.quiet .quiet-status:empty { display: none; }
|
|
127
|
+
.quiet .quiet-status { margin: .75rem 0 0; }
|
|
128
|
+
@container (max-width: 30rem) {
|
|
129
|
+
.quiet .changes { flex-direction: column; }
|
|
130
|
+
.quiet .changes button { min-height: 3rem; width: 100%; }
|
|
131
|
+
.quiet .days button { font-size: .8rem; }
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
function errorId(field) {
|
|
135
|
+
return `quiet-error${field.replaceAll(/[^a-z0-9]+/giu, "-")}`;
|
|
136
|
+
}
|
|
137
|
+
function button(label, action, run, options = {}) {
|
|
138
|
+
const element = document.createElement("button");
|
|
139
|
+
element.type = "button";
|
|
140
|
+
element.dataset["action"] = action;
|
|
141
|
+
if (options.content) {
|
|
142
|
+
element.append(options.content);
|
|
143
|
+
element.title = label;
|
|
144
|
+
}
|
|
145
|
+
else
|
|
146
|
+
element.textContent = label;
|
|
147
|
+
if (options.className)
|
|
148
|
+
element.className = options.className;
|
|
149
|
+
if (options.ariaLabel)
|
|
150
|
+
element.setAttribute("aria-label", options.ariaLabel);
|
|
151
|
+
if (options.pressed !== undefined)
|
|
152
|
+
element.setAttribute("aria-pressed", String(options.pressed));
|
|
153
|
+
element.disabled = options.disabled ?? false;
|
|
154
|
+
element.addEventListener("click", run);
|
|
155
|
+
return element;
|
|
156
|
+
}
|
|
157
|
+
const SVG = "http://www.w3.org/2000/svg";
|
|
158
|
+
/** A trash can: the remove-period button's whole face. */
|
|
159
|
+
function trash() {
|
|
160
|
+
const svg = document.createElementNS(SVG, "svg");
|
|
161
|
+
for (const [name, value] of Object.entries({
|
|
162
|
+
"aria-hidden": "true",
|
|
163
|
+
fill: "none",
|
|
164
|
+
height: "16",
|
|
165
|
+
stroke: "currentColor",
|
|
166
|
+
"stroke-linecap": "round",
|
|
167
|
+
"stroke-linejoin": "round",
|
|
168
|
+
"stroke-width": "2",
|
|
169
|
+
viewBox: "0 0 24 24",
|
|
170
|
+
width: "16",
|
|
171
|
+
}))
|
|
172
|
+
svg.setAttribute(name, value);
|
|
173
|
+
for (const d of [
|
|
174
|
+
"M3 6h18",
|
|
175
|
+
"M8 6V4h8v2",
|
|
176
|
+
"M19 6l-1 14H6L5 6",
|
|
177
|
+
"M10 11v6M14 11v6",
|
|
178
|
+
]) {
|
|
179
|
+
const path = document.createElementNS(SVG, "path");
|
|
180
|
+
path.setAttribute("d", d);
|
|
181
|
+
svg.append(path);
|
|
182
|
+
}
|
|
183
|
+
return svg;
|
|
184
|
+
}
|
|
185
|
+
export function renderQuietSection(props) {
|
|
186
|
+
const { copy, draft, errors, on, quiet } = props;
|
|
187
|
+
const section = document.createElement("section");
|
|
188
|
+
section.className = "quiet";
|
|
189
|
+
/** The inline message for one field, linked to its control. */
|
|
190
|
+
const fieldError = (field, control) => {
|
|
191
|
+
const code = errors[field];
|
|
192
|
+
if (code === undefined)
|
|
193
|
+
return null;
|
|
194
|
+
const line = document.createElement("p");
|
|
195
|
+
line.className = "error";
|
|
196
|
+
line.id = errorId(field);
|
|
197
|
+
const messages = copy.quietErrors;
|
|
198
|
+
line.textContent = messages[code] ?? copy.quietSaveFailed;
|
|
199
|
+
if (control) {
|
|
200
|
+
control.setAttribute("aria-invalid", "true");
|
|
201
|
+
control.setAttribute("aria-describedby", line.id);
|
|
202
|
+
}
|
|
203
|
+
return line;
|
|
204
|
+
};
|
|
205
|
+
const intro = document.createElement("p");
|
|
206
|
+
intro.className = "intro";
|
|
207
|
+
intro.textContent = copy.quietIntro;
|
|
208
|
+
section.append(intro);
|
|
209
|
+
if (quiet.quiet_now.quiet && quiet.quiet_now.ends_at !== undefined) {
|
|
210
|
+
const now = document.createElement("p");
|
|
211
|
+
now.className = "now";
|
|
212
|
+
now.textContent = copy.quietNow(quietEndsText(props.locale, quiet.quiet_now.ends_at, quiet.effective_time_zone ?? draft.timeZone, props.now));
|
|
213
|
+
section.append(now);
|
|
214
|
+
}
|
|
215
|
+
if (quiet.when_withheld === "quiet_channel" &&
|
|
216
|
+
quiet.quiet_channel?.usable === false) {
|
|
217
|
+
const warning = document.createElement("p");
|
|
218
|
+
warning.className = "warning";
|
|
219
|
+
warning.setAttribute("role", "note");
|
|
220
|
+
warning.textContent = copy.quietChannelUnusable;
|
|
221
|
+
section.append(warning);
|
|
222
|
+
}
|
|
223
|
+
// When: the weekly periods and the time zone they are read in.
|
|
224
|
+
const when = document.createElement("fieldset");
|
|
225
|
+
const whenLegend = document.createElement("legend");
|
|
226
|
+
whenLegend.textContent = copy.quietWhenHeading;
|
|
227
|
+
when.append(whenLegend);
|
|
228
|
+
draft.windows.forEach((window, index) => {
|
|
229
|
+
const number = String(index + 1);
|
|
230
|
+
const period = document.createElement("div");
|
|
231
|
+
period.className = "period";
|
|
232
|
+
period.setAttribute("role", "group");
|
|
233
|
+
period.setAttribute("aria-label", copy.quietPeriod(number));
|
|
234
|
+
const head = document.createElement("div");
|
|
235
|
+
head.className = "period-head";
|
|
236
|
+
const label = document.createElement("span");
|
|
237
|
+
label.className = "label";
|
|
238
|
+
label.textContent = copy.quietPeriod(number);
|
|
239
|
+
head.append(label, button(copy.quietRemovePeriod(number), `quiet:remove:${String(index)}`, () => {
|
|
240
|
+
on.removeWindow(index);
|
|
241
|
+
}, {
|
|
242
|
+
ariaLabel: copy.quietRemovePeriod(number),
|
|
243
|
+
className: "icon",
|
|
244
|
+
content: trash(),
|
|
245
|
+
disabled: props.disabled,
|
|
246
|
+
}));
|
|
247
|
+
period.append(head);
|
|
248
|
+
const days = document.createElement("div");
|
|
249
|
+
days.className = "days";
|
|
250
|
+
days.setAttribute("role", "group");
|
|
251
|
+
days.setAttribute("aria-label", copy.quietDays);
|
|
252
|
+
for (const day of QUIET_DAYS)
|
|
253
|
+
days.append(button(quietDayName(props.locale, day, "short"), `quiet:day:${String(index)}:${String(day)}`, () => {
|
|
254
|
+
on.toggleDay(index, day);
|
|
255
|
+
}, {
|
|
256
|
+
ariaLabel: quietDayName(props.locale, day, "long"),
|
|
257
|
+
disabled: props.disabled,
|
|
258
|
+
pressed: window.days.includes(day),
|
|
259
|
+
}));
|
|
260
|
+
period.append(days);
|
|
261
|
+
const daysError = fieldError(`/windows/${String(index)}/days`, days);
|
|
262
|
+
if (daysError)
|
|
263
|
+
period.append(daysError);
|
|
264
|
+
const times = document.createElement("div");
|
|
265
|
+
times.className = "times";
|
|
266
|
+
const overnight = document.createElement("span");
|
|
267
|
+
overnight.className = "overnight";
|
|
268
|
+
overnight.textContent = copy.quietOvernight;
|
|
269
|
+
overnight.hidden = !quietOvernight(window);
|
|
270
|
+
const inputs = {};
|
|
271
|
+
const timeErrors = [];
|
|
272
|
+
for (const edge of ["start", "end"]) {
|
|
273
|
+
const field = document.createElement("label");
|
|
274
|
+
field.append(edge === "start" ? copy.quietFrom : copy.quietTo);
|
|
275
|
+
const input = document.createElement("input");
|
|
276
|
+
input.type = "time";
|
|
277
|
+
input.step = "60";
|
|
278
|
+
input.required = true;
|
|
279
|
+
input.value = window[edge];
|
|
280
|
+
input.disabled = props.disabled;
|
|
281
|
+
input.dataset["action"] = `quiet:${edge}:${String(index)}`;
|
|
282
|
+
// Typing updates the draft without rebuilding, so the box keeps its
|
|
283
|
+
// caret; only the "ends the next day" line changes here.
|
|
284
|
+
input.addEventListener("input", () => {
|
|
285
|
+
const start = inputs.start?.value ?? window.start;
|
|
286
|
+
const end = inputs.end?.value ?? window.end;
|
|
287
|
+
overnight.hidden = !quietOvernight({ days: [], end, start });
|
|
288
|
+
on.setTime(index, edge, input.value);
|
|
289
|
+
});
|
|
290
|
+
inputs[edge] = input;
|
|
291
|
+
field.append(input);
|
|
292
|
+
times.append(field);
|
|
293
|
+
const timeError = fieldError(`/windows/${String(index)}/${edge}`, input);
|
|
294
|
+
if (timeError)
|
|
295
|
+
timeErrors.push(timeError);
|
|
296
|
+
}
|
|
297
|
+
times.append(overnight);
|
|
298
|
+
period.append(times, ...timeErrors);
|
|
299
|
+
when.append(period);
|
|
300
|
+
});
|
|
301
|
+
if (draft.windows.length === 0) {
|
|
302
|
+
const none = document.createElement("p");
|
|
303
|
+
none.className = "muted";
|
|
304
|
+
none.textContent = copy.quietNoPeriods;
|
|
305
|
+
when.append(none);
|
|
306
|
+
}
|
|
307
|
+
const add = button(draft.windows.length === 0 ? copy.quietAdd : copy.quietAddAnother, "quiet:add", on.addWindow, {
|
|
308
|
+
className: "secondary",
|
|
309
|
+
disabled: props.disabled || draft.windows.length >= QUIET_WINDOWS_MAX,
|
|
310
|
+
});
|
|
311
|
+
when.append(add);
|
|
312
|
+
const limitError = fieldError("/windows", add);
|
|
313
|
+
if (limitError)
|
|
314
|
+
when.append(limitError);
|
|
315
|
+
const zone = document.createElement("div");
|
|
316
|
+
zone.className = "zone";
|
|
317
|
+
if (quietTimeZoneEditable(quiet)) {
|
|
318
|
+
const label = document.createElement("label");
|
|
319
|
+
label.append(copy.quietTimeZone);
|
|
320
|
+
const select = document.createElement("select");
|
|
321
|
+
select.dataset["action"] = "quiet:time-zone";
|
|
322
|
+
select.disabled = props.disabled;
|
|
323
|
+
for (const name of quietTimeZones(draft.timeZone)) {
|
|
324
|
+
const option = document.createElement("option");
|
|
325
|
+
option.value = name;
|
|
326
|
+
option.textContent = name.replaceAll("_", " ");
|
|
327
|
+
select.append(option);
|
|
328
|
+
}
|
|
329
|
+
select.value = draft.timeZone;
|
|
330
|
+
select.addEventListener("change", () => {
|
|
331
|
+
on.setTimeZone(select.value);
|
|
332
|
+
});
|
|
333
|
+
label.append(select);
|
|
334
|
+
zone.append(label);
|
|
335
|
+
const zoneError = fieldError("/time_zone", select);
|
|
336
|
+
if (zoneError)
|
|
337
|
+
zone.append(zoneError);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
const fixed = document.createElement("p");
|
|
341
|
+
fixed.className = "muted";
|
|
342
|
+
fixed.textContent = copy.quietTimeZoneFixed(draft.timeZone.replaceAll("_", " "));
|
|
343
|
+
zone.append(fixed);
|
|
344
|
+
}
|
|
345
|
+
when.append(zone);
|
|
346
|
+
section.append(when);
|
|
347
|
+
// During quiet hours: what each channel does.
|
|
348
|
+
const behaviours = document.createElement("fieldset");
|
|
349
|
+
const behavioursLegend = document.createElement("legend");
|
|
350
|
+
behavioursLegend.textContent = copy.quietChannelsHeading;
|
|
351
|
+
behaviours.append(behavioursLegend);
|
|
352
|
+
for (const channel of props.channels) {
|
|
353
|
+
const choice = document.createElement("fieldset");
|
|
354
|
+
choice.className = "choice";
|
|
355
|
+
const legend = document.createElement("legend");
|
|
356
|
+
legend.textContent = props.channelName(channel);
|
|
357
|
+
choice.append(legend);
|
|
358
|
+
const options = document.createElement("div");
|
|
359
|
+
options.className = "options";
|
|
360
|
+
const offered = quiet.channel_options[channel];
|
|
361
|
+
for (const behaviour of offered) {
|
|
362
|
+
const label = document.createElement("label");
|
|
363
|
+
const radio = document.createElement("input");
|
|
364
|
+
radio.type = "radio";
|
|
365
|
+
radio.name = `quiet-${channel}`;
|
|
366
|
+
radio.value = behaviour;
|
|
367
|
+
radio.checked = draft.channels[channel] === behaviour;
|
|
368
|
+
radio.disabled = props.disabled;
|
|
369
|
+
radio.dataset["action"] = `quiet:channel:${channel}:${behaviour}`;
|
|
370
|
+
radio.addEventListener("change", () => {
|
|
371
|
+
if (radio.checked)
|
|
372
|
+
on.setBehaviour(channel, behaviour);
|
|
373
|
+
});
|
|
374
|
+
label.append(radio, copy.quietBehaviours[behaviour]);
|
|
375
|
+
options.append(label);
|
|
376
|
+
}
|
|
377
|
+
choice.append(options);
|
|
378
|
+
const channelError = fieldError(`/channels/${channel}`, options);
|
|
379
|
+
if (channelError)
|
|
380
|
+
choice.append(channelError);
|
|
381
|
+
behaviours.append(choice);
|
|
382
|
+
}
|
|
383
|
+
section.append(behaviours);
|
|
384
|
+
// Where a message a channel keeps back goes. Only asked while a channel
|
|
385
|
+
// keeps messages back; never a digest.
|
|
386
|
+
const options = quiet.quiet_channel_options;
|
|
387
|
+
if (quietWithholds(draft) || draft.whenWithheld === "quiet_channel") {
|
|
388
|
+
const withheld = document.createElement("fieldset");
|
|
389
|
+
withheld.className = "withheld";
|
|
390
|
+
const legend = document.createElement("legend");
|
|
391
|
+
legend.textContent = copy.quietWithheldHeading;
|
|
392
|
+
withheld.append(legend);
|
|
393
|
+
const radio = (value, text) => {
|
|
394
|
+
const label = document.createElement("label");
|
|
395
|
+
label.className = "radio";
|
|
396
|
+
const input = document.createElement("input");
|
|
397
|
+
input.type = "radio";
|
|
398
|
+
input.name = "quiet-withheld";
|
|
399
|
+
input.value = value;
|
|
400
|
+
input.checked = draft.whenWithheld === value;
|
|
401
|
+
input.disabled = props.disabled;
|
|
402
|
+
input.dataset["action"] = `quiet:withheld:${value}`;
|
|
403
|
+
input.addEventListener("change", () => {
|
|
404
|
+
if (input.checked)
|
|
405
|
+
on.setWhenWithheld(value);
|
|
406
|
+
});
|
|
407
|
+
label.append(input, text);
|
|
408
|
+
return label;
|
|
409
|
+
};
|
|
410
|
+
withheld.append(radio("hold", copy.quietHold));
|
|
411
|
+
if (options.length > 0 || draft.whenWithheld === "quiet_channel") {
|
|
412
|
+
withheld.append(radio("quiet_channel", copy.quietReroute));
|
|
413
|
+
if (draft.whenWithheld === "quiet_channel") {
|
|
414
|
+
const reroute = document.createElement("div");
|
|
415
|
+
reroute.className = "reroute zone";
|
|
416
|
+
const label = document.createElement("label");
|
|
417
|
+
label.append(copy.quietRerouteChannel);
|
|
418
|
+
const select = document.createElement("select");
|
|
419
|
+
select.dataset["action"] = "quiet:quiet-channel";
|
|
420
|
+
select.disabled = props.disabled;
|
|
421
|
+
const placeholder = document.createElement("option");
|
|
422
|
+
placeholder.value = "";
|
|
423
|
+
placeholder.textContent = copy.quietChooseChannel;
|
|
424
|
+
select.append(placeholder);
|
|
425
|
+
for (const option of options) {
|
|
426
|
+
const element = document.createElement("option");
|
|
427
|
+
element.value = option.binding_id;
|
|
428
|
+
const name = props.channelName(option.channel);
|
|
429
|
+
element.textContent =
|
|
430
|
+
option.masked_address === undefined
|
|
431
|
+
? name
|
|
432
|
+
: `${name} · ${option.masked_address}`;
|
|
433
|
+
select.append(element);
|
|
434
|
+
}
|
|
435
|
+
select.value = draft.quietChannelBindingId ?? "";
|
|
436
|
+
select.addEventListener("change", () => {
|
|
437
|
+
on.setQuietChannel(select.value === "" ? undefined : select.value);
|
|
438
|
+
});
|
|
439
|
+
label.append(select);
|
|
440
|
+
reroute.append(label);
|
|
441
|
+
const channelError = fieldError("/quiet_channel_binding_id", select);
|
|
442
|
+
if (channelError)
|
|
443
|
+
reroute.append(channelError);
|
|
444
|
+
withheld.append(reroute);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
section.append(withheld);
|
|
448
|
+
}
|
|
449
|
+
// Critical messages break through.
|
|
450
|
+
const critical = document.createElement("label");
|
|
451
|
+
critical.className = "critical category-switch";
|
|
452
|
+
const text = document.createElement("span");
|
|
453
|
+
text.className = "text";
|
|
454
|
+
const name = document.createElement("span");
|
|
455
|
+
name.className = "name";
|
|
456
|
+
name.textContent = copy.quietCritical;
|
|
457
|
+
const hint = document.createElement("span");
|
|
458
|
+
hint.className = "hint";
|
|
459
|
+
hint.id = "quiet-critical-hint";
|
|
460
|
+
hint.textContent = copy.quietCriticalHint;
|
|
461
|
+
text.append(name, hint);
|
|
462
|
+
const toggle = document.createElement("input");
|
|
463
|
+
toggle.type = "checkbox";
|
|
464
|
+
toggle.setAttribute("role", "switch");
|
|
465
|
+
toggle.checked = draft.criticalBreakthrough;
|
|
466
|
+
toggle.disabled = props.disabled;
|
|
467
|
+
toggle.dataset["action"] = "quiet:critical";
|
|
468
|
+
toggle.setAttribute("aria-describedby", hint.id);
|
|
469
|
+
toggle.addEventListener("change", () => {
|
|
470
|
+
on.setCritical(toggle.checked);
|
|
471
|
+
});
|
|
472
|
+
critical.append(text, toggle);
|
|
473
|
+
section.append(critical);
|
|
474
|
+
// Save is always in place, so typing a time never moves it.
|
|
475
|
+
const changes = document.createElement("div");
|
|
476
|
+
changes.className = "changes";
|
|
477
|
+
changes.append(button(quiet.configured ? copy.quietSave : copy.quietTurnOn, "quiet:save", on.save, { className: "save", disabled: props.disabled || !props.changed }), button(copy.quietDiscard, "quiet:discard", on.discard, {
|
|
478
|
+
className: "secondary",
|
|
479
|
+
disabled: props.disabled || !props.edited,
|
|
480
|
+
}));
|
|
481
|
+
section.append(changes);
|
|
482
|
+
if (quiet.configured)
|
|
483
|
+
section.append(button(copy.quietTurnOff, "quiet:turn-off", on.turnOff, {
|
|
484
|
+
className: "link",
|
|
485
|
+
disabled: props.disabled,
|
|
486
|
+
}));
|
|
487
|
+
section.append(props.status);
|
|
488
|
+
return section;
|
|
489
|
+
}
|
|
490
|
+
//# sourceMappingURL=quiet-section.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quiet-section.js","sourceRoot":"","sources":["../../src/recipient/quiet-section.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,cAAc,GAKf,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHnC,CAAC;AA0CF,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,cAAc,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,SAAS,MAAM,CACb,KAAa,EACb,MAAc,EACd,GAAe,EACf,UAMI,EAAE;IAEN,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC;IACxB,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,MAA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O,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEzB,4DAA4D;IAC5D,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9C,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,CAAC,MAAM,CACZ,MAAM,CACJ,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EACpD,YAAY,EACZ,EAAE,CAAC,IAAI,EACP,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAClE,EACD,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE,EAAE,CAAC,OAAO,EAAE;QACrD,SAAS,EAAE,WAAW;QACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM;KAC1C,CAAC,CACH,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxB,IAAI,KAAK,CAAC,UAAU;QAClB,OAAO,CAAC,MAAM,CACZ,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,EAAE,EAAE,CAAC,OAAO,EAAE;YACtD,SAAS,EAAE,MAAM;YACjB,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC,CACH,CAAC;IAEJ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { QuietHours, SaveQuietHoursRequest } from "@whooshbang/contracts";
|
|
2
|
+
/**
|
|
3
|
+
* A person's quiet hours, as the "Quiet hours" tab edits them (FXO-2103).
|
|
4
|
+
*
|
|
5
|
+
* Pure, so the rules — what a save sends, what counts as a change, which
|
|
6
|
+
* field an error belongs to — are testable without a browser and shared by
|
|
7
|
+
* the subscriber panel and the dashboard, which cannot then drift apart.
|
|
8
|
+
*/
|
|
9
|
+
/** The channels quiet hours set a behaviour for, in the order they show. */
|
|
10
|
+
export declare const QUIET_CHANNELS: readonly ["telegram", "slack", "email"];
|
|
11
|
+
export type QuietChannel = (typeof QUIET_CHANNELS)[number];
|
|
12
|
+
export type QuietBehaviour = QuietHours["channels"][QuietChannel];
|
|
13
|
+
/** ISO weekdays, Monday first. */
|
|
14
|
+
export declare const QUIET_DAYS: readonly [1, 2, 3, 4, 5, 6, 7];
|
|
15
|
+
export declare const QUIET_WINDOWS_MAX = 7;
|
|
16
|
+
/** What a new period suggests: every night, 22:00 to 07:00. */
|
|
17
|
+
export declare const QUIET_SUGGESTED_WINDOW: QuietWindowDraft;
|
|
18
|
+
export interface QuietWindowDraft {
|
|
19
|
+
readonly days: readonly number[];
|
|
20
|
+
readonly start: string;
|
|
21
|
+
readonly end: string;
|
|
22
|
+
}
|
|
23
|
+
export interface QuietDraft {
|
|
24
|
+
readonly windows: readonly QuietWindowDraft[];
|
|
25
|
+
readonly channels: Readonly<Record<QuietChannel, QuietBehaviour>>;
|
|
26
|
+
readonly criticalBreakthrough: boolean;
|
|
27
|
+
readonly whenWithheld: QuietHours["when_withheld"];
|
|
28
|
+
/** Only one of `quiet_channel_options`; a saved one that went away is dropped. */
|
|
29
|
+
readonly quietChannelBindingId: string | undefined;
|
|
30
|
+
readonly timeZone: string;
|
|
31
|
+
}
|
|
32
|
+
/** Field errors by JSON Pointer, such as `/windows/0/days`, to their code. */
|
|
33
|
+
export type QuietFieldErrors = Readonly<Record<string, string>>;
|
|
34
|
+
/** The browser's own named time zone, or UTC when it has none. */
|
|
35
|
+
export declare function browserTimeZone(): string;
|
|
36
|
+
/** The zone the times are shown in: the one quiet hours follow, else the browser's. */
|
|
37
|
+
export declare function quietTimeZone(quiet: QuietHours, fallback: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the person picks their own time zone. One an administrator set, or
|
|
40
|
+
* one their application supplies, wins over a saved one, so a picker there
|
|
41
|
+
* would change nothing.
|
|
42
|
+
*/
|
|
43
|
+
export declare function quietTimeZoneEditable(quiet: QuietHours): boolean;
|
|
44
|
+
export declare function startQuietDraft(quiet: QuietHours, fallbackTimeZone: string): QuietDraft;
|
|
45
|
+
/** Whether the person changed anything since the tab showed what is saved. */
|
|
46
|
+
export declare function quietEdited(draft: QuietDraft | null, quiet: QuietHours, fallbackTimeZone: string): boolean;
|
|
47
|
+
/** Whether Save would change anything. Nothing saved yet always would. */
|
|
48
|
+
export declare function quietChanged(draft: QuietDraft | null, quiet: QuietHours, fallbackTimeZone: string): boolean;
|
|
49
|
+
/** Whether any channel keeps messages back, so "where they go" matters. */
|
|
50
|
+
export declare function quietWithholds(draft: QuietDraft): boolean;
|
|
51
|
+
export declare function quietSaveRequest(draft: QuietDraft): SaveQuietHoursRequest;
|
|
52
|
+
/**
|
|
53
|
+
* The mistakes the panel can see before asking: a period with no days, a
|
|
54
|
+
* missing time, a period that starts and ends together, and a quiet channel
|
|
55
|
+
* not chosen. The service checks everything again.
|
|
56
|
+
*/
|
|
57
|
+
export declare function quietDraftErrors(draft: QuietDraft): QuietFieldErrors;
|
|
58
|
+
/** The service's field errors, by field, from a `request_invalid` problem. */
|
|
59
|
+
export declare function quietProblemErrors(problem: {
|
|
60
|
+
readonly field_errors?: readonly {
|
|
61
|
+
readonly field: string;
|
|
62
|
+
readonly code: string;
|
|
63
|
+
}[];
|
|
64
|
+
}): QuietFieldErrors;
|
|
65
|
+
/**
|
|
66
|
+
* The control a field error belongs to, by the `data-action` both editors
|
|
67
|
+
* give it, so focus can go there after a refused save.
|
|
68
|
+
*/
|
|
69
|
+
export declare function quietErrorControl(field: string, draft: QuietDraft): string | null;
|
|
70
|
+
/** A period ending at or before its start runs past midnight. */
|
|
71
|
+
export declare function quietOvernight(window: QuietWindowDraft): boolean;
|
|
72
|
+
export declare function setQuietWindow(draft: QuietDraft, index: number, change: Partial<QuietWindowDraft>): QuietDraft;
|
|
73
|
+
export declare function toggleQuietDay(draft: QuietDraft, index: number, day: number): QuietDraft;
|
|
74
|
+
export declare function addQuietWindow(draft: QuietDraft): QuietDraft;
|
|
75
|
+
export declare function removeQuietWindow(draft: QuietDraft, index: number): QuietDraft;
|
|
76
|
+
/** Day names in the reader's language: short for the toggle, long for its name. */
|
|
77
|
+
export declare function quietDayName(locale: string, day: number, width: "short" | "long"): string;
|
|
78
|
+
/**
|
|
79
|
+
* When quiet hours end, as the person reads a clock in their zone: "07:00",
|
|
80
|
+
* or with the day when it is more than a day away.
|
|
81
|
+
*/
|
|
82
|
+
export declare function quietEndsText(locale: string, endsAt: string, timeZone: string, now?: Date): string;
|
|
83
|
+
/** Every named zone the browser knows, with the current one always included. */
|
|
84
|
+
export declare function quietTimeZones(current: string): string[];
|