@visns-studio/visns-components 6.20.1 → 6.23.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/package.json +1 -1
- package/src/components/DataGrid.jsx +15 -2
- package/src/components/Navigation.jsx +10 -1
- package/src/components/columns/SelectFilterEditor.jsx +372 -0
- package/src/components/controls/DataGridSearch.jsx +6 -1
- package/src/components/layout/AnchoredMenu.jsx +131 -0
- package/src/components/layout/BandedList.jsx +158 -0
- package/src/components/layout/FactsBand.jsx +150 -0
- package/src/components/layout/PageHeader.jsx +90 -0
- package/src/components/layout/ScrollRegion.jsx +53 -0
- package/src/components/layout/StatStrip.jsx +170 -0
- package/src/components/layout/useContainedHeight.js +82 -0
- package/src/components/navigation/TabStrip.jsx +156 -0
- package/src/components/phone/ZoomPhoneBadge.jsx +625 -0
- package/src/components/phone/phonePresenceEndpoints.js +34 -0
- package/src/components/phone/phonePresenceHelpers.js +298 -0
- package/src/components/phone/useZoomPhoneLive.js +165 -0
- package/src/components/sms/SmsClientConversations.jsx +8 -0
- package/src/components/sms/SmsInbox.jsx +11 -0
- package/src/components/sms/SmsThreadPanel.jsx +258 -29
- package/src/components/sms/smsHelpers.js +95 -0
- package/src/components/styles/AnchoredMenu.module.scss +43 -0
- package/src/components/styles/BandedList.module.scss +278 -0
- package/src/components/styles/DataGrid.module.scss +10 -0
- package/src/components/styles/FactsBand.module.scss +108 -0
- package/src/components/styles/GenericDetail.module.scss +12 -2
- package/src/components/styles/PageHeader.module.scss +98 -0
- package/src/components/styles/ScrollRegion.module.scss +20 -0
- package/src/components/styles/Sms.module.scss +131 -0
- package/src/components/styles/StatStrip.module.scss +183 -0
- package/src/components/styles/TabStrip.module.scss +96 -0
- package/src/components/styles/Vault.module.scss +46 -0
- package/src/components/styles/ZoomPhone.module.scss +550 -0
- package/src/components/styles/_surface.scss +49 -0
- package/src/components/styles/global-datagrid.css +23 -0
- package/src/components/vault/VaultAccessLog.jsx +24 -0
- package/src/components/vault/VaultShareModal.jsx +126 -5
- package/src/components/vault/vaultShares.js +67 -3
- package/src/index.js +88 -2
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
Archive,
|
|
11
11
|
ArchiveRestore,
|
|
12
12
|
ArrowLeft,
|
|
13
|
+
CheckSquare,
|
|
13
14
|
ChevronUp,
|
|
14
15
|
ExternalLink,
|
|
15
16
|
FileText,
|
|
@@ -30,6 +31,7 @@ import useSmsLive, { defaultChannelFor } from './useSmsLive';
|
|
|
30
31
|
import useDebouncedValue from '../vault/useDebouncedValue';
|
|
31
32
|
import {
|
|
32
33
|
MAX_SEGMENTS,
|
|
34
|
+
annotationsForMessage,
|
|
33
35
|
clockTime,
|
|
34
36
|
composerPlaceholder,
|
|
35
37
|
counterLabel,
|
|
@@ -42,6 +44,7 @@ import {
|
|
|
42
44
|
nextPlaceholder,
|
|
43
45
|
normaliseNumberForDisplay,
|
|
44
46
|
prependMessages,
|
|
47
|
+
resolveAnnotations,
|
|
45
48
|
segmentCount,
|
|
46
49
|
statusLabel,
|
|
47
50
|
threadDisplayName,
|
|
@@ -83,6 +86,13 @@ let temporaryId = 0;
|
|
|
83
86
|
* subscription, in which case the parent passes `subscribe={false}` and feeds
|
|
84
87
|
* it events. Two subscriptions to one channel is not an error, but it is two
|
|
85
88
|
* websocket authorisations and two copies of every message to reconcile.
|
|
89
|
+
*
|
|
90
|
+
* `messageSelection` and `messageAnnotations` are the two hooks a host has into
|
|
91
|
+
* the timeline. Both are opt-in and both are deliberately nameless about what
|
|
92
|
+
* the host does with them: this module knows about messages, and an application
|
|
93
|
+
* that wants to file them against something of its own (a task, a complaint, a
|
|
94
|
+
* file note) supplies the verb and the badges. Absent, the panel behaves
|
|
95
|
+
* exactly as it did before they existed.
|
|
86
96
|
*/
|
|
87
97
|
const SmsThreadPanel = ({
|
|
88
98
|
threadId,
|
|
@@ -107,6 +117,23 @@ const SmsThreadPanel = ({
|
|
|
107
117
|
lines = null,
|
|
108
118
|
canManage = false,
|
|
109
119
|
clientUrl = (id) => `/clients/${id}`,
|
|
120
|
+
// `{label, onSelect}` — turns on a Select mode over the timeline. `label` is
|
|
121
|
+
// the verb printed on the confirm button ("Attach to task…"), `onSelect` is
|
|
122
|
+
// called as `onSelect(messages, thread)` and may return a promise; the mode
|
|
123
|
+
// closes when it settles.
|
|
124
|
+
//
|
|
125
|
+
// The thread is the SECOND argument, so a host that already knows which
|
|
126
|
+
// conversation it mounted (a client's own page) can ignore it. A host that
|
|
127
|
+
// does not — an inbox, where the pane chooses the thread — has no other way
|
|
128
|
+
// to know which one is open or which client it is linked to.
|
|
129
|
+
messageSelection = null,
|
|
130
|
+
// `{[messageId]: [{id, label, onClick}]}` — small chips under the matching
|
|
131
|
+
// bubble. The host owns what they say and what a click does.
|
|
132
|
+
//
|
|
133
|
+
// May also be a function `(thread) => map`, for the same reason: chips in an
|
|
134
|
+
// inbox depend on which conversation is open, and no host can hold one map
|
|
135
|
+
// for every thread in the practice.
|
|
136
|
+
messageAnnotations = null,
|
|
110
137
|
onThreadChange,
|
|
111
138
|
onMessage,
|
|
112
139
|
onBack = null,
|
|
@@ -130,6 +157,10 @@ const SmsThreadPanel = ({
|
|
|
130
157
|
const [linkOpen, setLinkOpen] = useState(false);
|
|
131
158
|
const [simulateOpen, setSimulateOpen] = useState(false);
|
|
132
159
|
|
|
160
|
+
const [selecting, setSelecting] = useState(false);
|
|
161
|
+
const [selectedIds, setSelectedIds] = useState([]);
|
|
162
|
+
const [confirmingSelection, setConfirmingSelection] = useState(false);
|
|
163
|
+
|
|
133
164
|
const mountedRef = useRef(true);
|
|
134
165
|
const timelineRef = useRef(null);
|
|
135
166
|
const composerRef = useRef(null);
|
|
@@ -445,6 +476,97 @@ const SmsThreadPanel = ({
|
|
|
445
476
|
[enterSends, submit]
|
|
446
477
|
);
|
|
447
478
|
|
|
479
|
+
/* ------------------------------------------------------------ selection */
|
|
480
|
+
|
|
481
|
+
const selectionEnabled =
|
|
482
|
+
Boolean(messageSelection) && typeof messageSelection.onSelect === 'function';
|
|
483
|
+
|
|
484
|
+
// Moving to another conversation abandons whatever was ticked in the last
|
|
485
|
+
// one: the selection is a list of ids from a timeline that is no longer on
|
|
486
|
+
// screen, and carrying it across would file one client's messages from
|
|
487
|
+
// another client's page.
|
|
488
|
+
useEffect(() => {
|
|
489
|
+
setSelecting(false);
|
|
490
|
+
setSelectedIds([]);
|
|
491
|
+
}, [threadId]);
|
|
492
|
+
|
|
493
|
+
// Withdrawing the prop has to close the mode with it, or a host that turns
|
|
494
|
+
// selection off mid-render leaves the bar stranded with no way out.
|
|
495
|
+
useEffect(() => {
|
|
496
|
+
if (!selectionEnabled) {
|
|
497
|
+
setSelecting(false);
|
|
498
|
+
setSelectedIds([]);
|
|
499
|
+
}
|
|
500
|
+
}, [selectionEnabled]);
|
|
501
|
+
|
|
502
|
+
const isSelected = useCallback(
|
|
503
|
+
(id) => selectedIds.some((one) => String(one) === String(id)),
|
|
504
|
+
[selectedIds]
|
|
505
|
+
);
|
|
506
|
+
|
|
507
|
+
const toggleSelected = useCallback((id) => {
|
|
508
|
+
setSelectedIds((prev) =>
|
|
509
|
+
prev.some((one) => String(one) === String(id))
|
|
510
|
+
? prev.filter((one) => String(one) !== String(id))
|
|
511
|
+
: [...prev, id]
|
|
512
|
+
);
|
|
513
|
+
}, []);
|
|
514
|
+
|
|
515
|
+
const cancelSelection = useCallback(() => {
|
|
516
|
+
setSelecting(false);
|
|
517
|
+
setSelectedIds([]);
|
|
518
|
+
}, []);
|
|
519
|
+
|
|
520
|
+
const confirmSelection = useCallback(() => {
|
|
521
|
+
if (!selectionEnabled || selectedIds.length === 0 || confirmingSelection) return;
|
|
522
|
+
|
|
523
|
+
// The host is handed the message objects, not the ids: it should not
|
|
524
|
+
// have to hold a second copy of the timeline to know what it was given.
|
|
525
|
+
// Timeline order, not tick order — a conversation extract only reads
|
|
526
|
+
// correctly in the order it happened.
|
|
527
|
+
const chosen = messages.filter((one) => isSelected(one.id));
|
|
528
|
+
|
|
529
|
+
setConfirmingSelection(true);
|
|
530
|
+
|
|
531
|
+
Promise.resolve(messageSelection.onSelect(chosen, thread))
|
|
532
|
+
.then(() => {
|
|
533
|
+
if (!mountedRef.current) return;
|
|
534
|
+
|
|
535
|
+
setSelecting(false);
|
|
536
|
+
setSelectedIds([]);
|
|
537
|
+
})
|
|
538
|
+
.catch(() => {
|
|
539
|
+
// A failed hand-off leaves the ticks where they are so the user
|
|
540
|
+
// can try again; the host is the one that says what went wrong.
|
|
541
|
+
})
|
|
542
|
+
.then(() => {
|
|
543
|
+
if (mountedRef.current) setConfirmingSelection(false);
|
|
544
|
+
});
|
|
545
|
+
}, [
|
|
546
|
+
selectionEnabled,
|
|
547
|
+
selectedIds,
|
|
548
|
+
confirmingSelection,
|
|
549
|
+
messages,
|
|
550
|
+
isSelected,
|
|
551
|
+
messageSelection,
|
|
552
|
+
thread,
|
|
553
|
+
]);
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* The chip map for the conversation on screen. A function form is called
|
|
557
|
+
* with the whole thread rather than its id, because what a host looks chips
|
|
558
|
+
* up by is usually the client on it.
|
|
559
|
+
*/
|
|
560
|
+
const annotations = useMemo(
|
|
561
|
+
() => resolveAnnotations(messageAnnotations, thread),
|
|
562
|
+
[messageAnnotations, thread]
|
|
563
|
+
);
|
|
564
|
+
|
|
565
|
+
const annotationsFor = useCallback(
|
|
566
|
+
(id) => annotationsForMessage(annotations, id),
|
|
567
|
+
[annotations]
|
|
568
|
+
);
|
|
569
|
+
|
|
448
570
|
/* -------------------------------------------------------------- actions */
|
|
449
571
|
|
|
450
572
|
const patchThread = useCallback(
|
|
@@ -589,6 +711,44 @@ const SmsThreadPanel = ({
|
|
|
589
711
|
const attachments = Array.isArray(message.attachments) ? message.attachments : [];
|
|
590
712
|
// A failure is never silent, whatever else the run is doing.
|
|
591
713
|
const showMeta = lastOfRun || failed || heldMessage;
|
|
714
|
+
const chips = annotationsFor(message.id);
|
|
715
|
+
// A message still on its way to the server has a temporary id, so there
|
|
716
|
+
// is nothing a host could file it against yet.
|
|
717
|
+
const tickable = selecting && !message.pending;
|
|
718
|
+
const ticked = tickable && isSelected(message.id);
|
|
719
|
+
|
|
720
|
+
const bubble = (
|
|
721
|
+
<div
|
|
722
|
+
className={[
|
|
723
|
+
styles.bubble,
|
|
724
|
+
outgoing ? styles.bubbleBodyOut : styles.bubbleBodyIn,
|
|
725
|
+
heldMessage ? styles.bubbleHeld : '',
|
|
726
|
+
failed ? styles.bubbleFailed : '',
|
|
727
|
+
message.pending ? styles.bubblePending : '',
|
|
728
|
+
]
|
|
729
|
+
.filter(Boolean)
|
|
730
|
+
.join(' ')}
|
|
731
|
+
>
|
|
732
|
+
{message.body}
|
|
733
|
+
|
|
734
|
+
{attachments.length > 0 && (
|
|
735
|
+
<div className={styles.attachments}>
|
|
736
|
+
{attachments.map((file) => (
|
|
737
|
+
<a
|
|
738
|
+
key={file.id}
|
|
739
|
+
className={styles.attachment}
|
|
740
|
+
href={file.download_url}
|
|
741
|
+
target="_blank"
|
|
742
|
+
rel="noopener noreferrer"
|
|
743
|
+
>
|
|
744
|
+
<FileText size={12} strokeWidth={2} aria-hidden="true" />
|
|
745
|
+
<span>{file.name}</span>
|
|
746
|
+
</a>
|
|
747
|
+
))}
|
|
748
|
+
</div>
|
|
749
|
+
)}
|
|
750
|
+
</div>
|
|
751
|
+
);
|
|
592
752
|
|
|
593
753
|
return (
|
|
594
754
|
<div
|
|
@@ -601,36 +761,52 @@ const SmsThreadPanel = ({
|
|
|
601
761
|
.filter(Boolean)
|
|
602
762
|
.join(' ')}
|
|
603
763
|
>
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
{
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
764
|
+
{selecting ? (
|
|
765
|
+
// The whole row is the hit target while selecting: ticking
|
|
766
|
+
// a message by aiming at a 14px box is not how anybody
|
|
767
|
+
// picks three texts out of a conversation.
|
|
768
|
+
<label
|
|
769
|
+
className={[
|
|
770
|
+
styles.pickRow,
|
|
771
|
+
ticked ? styles.pickRowOn : '',
|
|
772
|
+
message.pending ? styles.pickRowOff : '',
|
|
773
|
+
]
|
|
774
|
+
.filter(Boolean)
|
|
775
|
+
.join(' ')}
|
|
776
|
+
>
|
|
777
|
+
<input
|
|
778
|
+
type="checkbox"
|
|
779
|
+
className={styles.pickBox}
|
|
780
|
+
checked={ticked}
|
|
781
|
+
disabled={!tickable}
|
|
782
|
+
onChange={() => toggleSelected(message.id)}
|
|
783
|
+
/>
|
|
784
|
+
{bubble}
|
|
785
|
+
</label>
|
|
786
|
+
) : (
|
|
787
|
+
bubble
|
|
788
|
+
)}
|
|
789
|
+
|
|
790
|
+
{chips.length > 0 && (
|
|
791
|
+
<div className={styles.annotations}>
|
|
792
|
+
{chips.map((annotation) =>
|
|
793
|
+
typeof annotation.onClick === 'function' ? (
|
|
794
|
+
<button
|
|
795
|
+
key={annotation.id}
|
|
796
|
+
type="button"
|
|
797
|
+
className={`${styles.annotation} ${styles.annotationAction}`}
|
|
798
|
+
onClick={() => annotation.onClick(annotation)}
|
|
626
799
|
>
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
800
|
+
{annotation.label}
|
|
801
|
+
</button>
|
|
802
|
+
) : (
|
|
803
|
+
<span key={annotation.id} className={styles.annotation}>
|
|
804
|
+
{annotation.label}
|
|
805
|
+
</span>
|
|
806
|
+
)
|
|
807
|
+
)}
|
|
808
|
+
</div>
|
|
809
|
+
)}
|
|
634
810
|
|
|
635
811
|
{showMeta && (
|
|
636
812
|
<div
|
|
@@ -703,6 +879,22 @@ const SmsThreadPanel = ({
|
|
|
703
879
|
</a>
|
|
704
880
|
) : null}
|
|
705
881
|
|
|
882
|
+
{selectionEnabled && (
|
|
883
|
+
<button
|
|
884
|
+
type="button"
|
|
885
|
+
className={`${styles.ghostButton} ${
|
|
886
|
+
selecting ? styles.ghostButtonOn : ''
|
|
887
|
+
}`.trim()}
|
|
888
|
+
aria-pressed={selecting}
|
|
889
|
+
onClick={() =>
|
|
890
|
+
selecting ? cancelSelection() : setSelecting(true)
|
|
891
|
+
}
|
|
892
|
+
>
|
|
893
|
+
<CheckSquare size={14} strokeWidth={2} aria-hidden="true" />
|
|
894
|
+
{selecting ? 'Done' : 'Select'}
|
|
895
|
+
</button>
|
|
896
|
+
)}
|
|
897
|
+
|
|
706
898
|
<button
|
|
707
899
|
type="button"
|
|
708
900
|
className={styles.ghostButton}
|
|
@@ -797,6 +989,42 @@ const SmsThreadPanel = ({
|
|
|
797
989
|
))}
|
|
798
990
|
</div>
|
|
799
991
|
|
|
992
|
+
{/*
|
|
993
|
+
* While selecting, the action bar stands where the composer does.
|
|
994
|
+
* Both at once would be a pane with two footers and two primary
|
|
995
|
+
* buttons, and picking messages out of a conversation is not
|
|
996
|
+
* something anybody does halfway through writing a reply.
|
|
997
|
+
*/}
|
|
998
|
+
{selecting ? (
|
|
999
|
+
<div className={styles.selectBar}>
|
|
1000
|
+
<span className={styles.selectCount}>
|
|
1001
|
+
{selectedIds.length === 0
|
|
1002
|
+
? 'Pick the messages you want'
|
|
1003
|
+
: `${selectedIds.length} selected`}
|
|
1004
|
+
</span>
|
|
1005
|
+
|
|
1006
|
+
<div className={styles.selectActions}>
|
|
1007
|
+
<button
|
|
1008
|
+
type="button"
|
|
1009
|
+
className={styles.ghostButton}
|
|
1010
|
+
onClick={cancelSelection}
|
|
1011
|
+
>
|
|
1012
|
+
Cancel
|
|
1013
|
+
</button>
|
|
1014
|
+
<button
|
|
1015
|
+
type="button"
|
|
1016
|
+
className={styles.primaryButton}
|
|
1017
|
+
onClick={confirmSelection}
|
|
1018
|
+
disabled={selectedIds.length === 0 || confirmingSelection}
|
|
1019
|
+
>
|
|
1020
|
+
{confirmingSelection && (
|
|
1021
|
+
<Loader2 size={14} className={styles.spin} aria-hidden="true" />
|
|
1022
|
+
)}
|
|
1023
|
+
{messageSelection.label || 'Select'} ({selectedIds.length})
|
|
1024
|
+
</button>
|
|
1025
|
+
</div>
|
|
1026
|
+
</div>
|
|
1027
|
+
) : (
|
|
800
1028
|
<div className={styles.composer}>
|
|
801
1029
|
<div className={styles.composerBox}>
|
|
802
1030
|
<textarea
|
|
@@ -905,6 +1133,7 @@ const SmsThreadPanel = ({
|
|
|
905
1133
|
</div>
|
|
906
1134
|
</div>
|
|
907
1135
|
</div>
|
|
1136
|
+
)}
|
|
908
1137
|
|
|
909
1138
|
<LinkClientModal
|
|
910
1139
|
open={linkOpen}
|
|
@@ -157,6 +157,61 @@ export const toE164 = (value, countryCode = '61') => {
|
|
|
157
157
|
return null;
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
+
/* ------------------------------------------------------- dialling a number */
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* A number as a person would write it, or '' when there is nothing to show.
|
|
164
|
+
*
|
|
165
|
+
* A thin wrapper on `normaliseNumberForDisplay`, and the reason it exists is the
|
|
166
|
+
* empty case: the formatter returns whatever it was given when it cannot parse
|
|
167
|
+
* it, including `undefined`, and a display slot wants a string it can render.
|
|
168
|
+
*
|
|
169
|
+
* Use THIS rather than the data grid's `renderPhoneColumn` for anything that is
|
|
170
|
+
* not a grid cell. The grid's formatter collapses `+61` through the guard
|
|
171
|
+
* `/^61[2-9]\d{8}$/`, which excludes `4` and therefore silently fails to format
|
|
172
|
+
* the one case a contact screen cares about most — a stored `+61412345678`
|
|
173
|
+
* mobile falls through to its generic branch and renders unformatted.
|
|
174
|
+
*/
|
|
175
|
+
export const displayNumber = (value) => normaliseNumberForDisplay(value) || '';
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The `href` for a phone number, or null when it is not dialable.
|
|
179
|
+
*
|
|
180
|
+
* `tel:` wants an unambiguous number, not a pretty one: a tablet handing
|
|
181
|
+
* `(08) 9375 2549` to a dialler is handing it a string with brackets in it. So
|
|
182
|
+
* E.164 is preferred, and `toE164` produces it.
|
|
183
|
+
*
|
|
184
|
+
* THE 13 / 1300 / 1800 CAVEAT. `toE164` answers null for the Australian service
|
|
185
|
+
* prefixes, because they genuinely have no country-code form. They are still
|
|
186
|
+
* perfectly dialable, so rather than drop the link they fall back to the bare
|
|
187
|
+
* digits, which is what a handset expects for them.
|
|
188
|
+
*
|
|
189
|
+
* Anything with no digits at all — "ask reception", and it IS in this column in
|
|
190
|
+
* real data — gets no link, because an anchor that dials nothing is worse than
|
|
191
|
+
* plain text.
|
|
192
|
+
*/
|
|
193
|
+
export const telHref = (value) => {
|
|
194
|
+
const e164 = toE164(value);
|
|
195
|
+
|
|
196
|
+
if (e164) return `tel:${e164}`;
|
|
197
|
+
|
|
198
|
+
const digits = String(value ?? '').replace(/[^\d]/g, '');
|
|
199
|
+
|
|
200
|
+
return /^1[38]00\d{6}$|^13\d{4}$/.test(digits) ? `tel:${digits}` : null;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* As above, for the text action on a mobile.
|
|
205
|
+
*
|
|
206
|
+
* No service-prefix fallback here, deliberately: 13/1300/1800 numbers cannot
|
|
207
|
+
* receive an SMS at all, so a link to one is a promise that would be broken.
|
|
208
|
+
*/
|
|
209
|
+
export const smsHref = (value) => {
|
|
210
|
+
const e164 = toE164(value);
|
|
211
|
+
|
|
212
|
+
return e164 ? `sms:${e164}` : null;
|
|
213
|
+
};
|
|
214
|
+
|
|
160
215
|
/* ----------------------------------------------------------------- segments */
|
|
161
216
|
|
|
162
217
|
/**
|
|
@@ -1147,7 +1202,43 @@ export const describeRecipient = (input) => {
|
|
|
1147
1202
|
};
|
|
1148
1203
|
};
|
|
1149
1204
|
|
|
1205
|
+
/* -------------------------------------------------------------------------- *
|
|
1206
|
+
* Host annotations
|
|
1207
|
+
*
|
|
1208
|
+
* A host may hand the conversation pane chips to draw under particular
|
|
1209
|
+
* messages. Two shapes, because two kinds of host need it:
|
|
1210
|
+
*
|
|
1211
|
+
* - a MAP, `{[messageId]: [chip]}`, for a screen that already knows which
|
|
1212
|
+
* conversation it mounted — a client's own page;
|
|
1213
|
+
* - a FUNCTION of the open thread, for a screen that does not — an inbox,
|
|
1214
|
+
* where the pane chooses the thread and no host could hold one map for
|
|
1215
|
+
* every conversation in the practice.
|
|
1216
|
+
*
|
|
1217
|
+
* Both live here rather than inside the component so the shape has a test.
|
|
1218
|
+
* -------------------------------------------------------------------------- */
|
|
1219
|
+
|
|
1220
|
+
/** The chip map for one conversation, whichever shape the host passed. */
|
|
1221
|
+
export const resolveAnnotations = (annotations, thread) => {
|
|
1222
|
+
const resolved =
|
|
1223
|
+
typeof annotations === 'function' ? annotations(thread) : annotations;
|
|
1224
|
+
|
|
1225
|
+
return resolved && typeof resolved === 'object' ? resolved : null;
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* The chips for one message. Looked up by the id as given AND as a string: a
|
|
1230
|
+
* map parsed out of JSON has string keys, and the timeline's ids are numbers.
|
|
1231
|
+
*/
|
|
1232
|
+
export const annotationsForMessage = (annotations, id) => {
|
|
1233
|
+
if (!annotations) return [];
|
|
1234
|
+
|
|
1235
|
+
const found = annotations[id] ?? annotations[String(id)];
|
|
1236
|
+
|
|
1237
|
+
return Array.isArray(found) ? found : [];
|
|
1238
|
+
};
|
|
1239
|
+
|
|
1150
1240
|
export default {
|
|
1241
|
+
annotationsForMessage,
|
|
1151
1242
|
badgeCount,
|
|
1152
1243
|
clientRecipient,
|
|
1153
1244
|
clockTime,
|
|
@@ -1159,6 +1250,7 @@ export default {
|
|
|
1159
1250
|
dayLabel,
|
|
1160
1251
|
describeRecipient,
|
|
1161
1252
|
describeTransport,
|
|
1253
|
+
displayNumber,
|
|
1162
1254
|
fillTemplate,
|
|
1163
1255
|
groupMessagesByDay,
|
|
1164
1256
|
initialsFor,
|
|
@@ -1173,10 +1265,13 @@ export default {
|
|
|
1173
1265
|
prependMessages,
|
|
1174
1266
|
RECIPIENT_HINTS,
|
|
1175
1267
|
relativeTime,
|
|
1268
|
+
resolveAnnotations,
|
|
1176
1269
|
segmentCount,
|
|
1270
|
+
smsHref,
|
|
1177
1271
|
splitPersonName,
|
|
1178
1272
|
statusLabel,
|
|
1179
1273
|
sumUnread,
|
|
1274
|
+
telHref,
|
|
1180
1275
|
threadDisplayName,
|
|
1181
1276
|
threadIdFromSearch,
|
|
1182
1277
|
threadSubtitle,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@use 'surface' as *;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AnchoredMenu — the row menu, portalled out of everything that would clip it.
|
|
5
|
+
*
|
|
6
|
+
* It renders into `document.body`, which means it is OUTSIDE the page's own
|
|
7
|
+
* token block: a `--vs-line` declared on `.page` does not inherit to a sibling
|
|
8
|
+
* of `<div id="app">`. So this is the one module in the set that reads the app's
|
|
9
|
+
* tokens directly and offers no page-level override — a menu is neutral chrome
|
|
10
|
+
* anyway, and a per-page menu skin was never a thing anybody wanted.
|
|
11
|
+
*
|
|
12
|
+
* `z-index` sits above a page's own furniture and below the modal layer (1051+
|
|
13
|
+
* in this library's stack), because a menu must not float over the sheet a
|
|
14
|
+
* click on it opens.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
.scrim {
|
|
18
|
+
position: fixed;
|
|
19
|
+
inset: 0;
|
|
20
|
+
z-index: 900;
|
|
21
|
+
padding: 0;
|
|
22
|
+
background: transparent;
|
|
23
|
+
border: 0;
|
|
24
|
+
cursor: default;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.menu {
|
|
28
|
+
@include surface-tokens;
|
|
29
|
+
|
|
30
|
+
position: fixed;
|
|
31
|
+
z-index: 901;
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
min-width: 11rem;
|
|
35
|
+
max-width: min(20rem, calc(100vw - 1rem));
|
|
36
|
+
padding: 4px;
|
|
37
|
+
background: var(--pr-surface);
|
|
38
|
+
border: 1px solid var(--pr-line);
|
|
39
|
+
border-radius: var(--btn-br, 5px);
|
|
40
|
+
box-shadow:
|
|
41
|
+
0 1px 2px rgb(0 0 0 / 8%),
|
|
42
|
+
0 8px 24px -12px rgb(0 0 0 / 35%);
|
|
43
|
+
}
|