@flamingo-stack/openframe-frontend-core 0.0.806 → 0.0.808
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/build/export-map.json +1 -1
- package/dist/{chunk-RIRIA3FO.cjs → chunk-5MTYKS2Q.cjs} +4 -4
- package/dist/{chunk-DN5YBJGC.cjs → chunk-5UTJARDM.cjs} +2 -2
- package/dist/{chunk-FZSL4KSW.cjs → chunk-6B5BDFZ6.cjs} +3 -3
- package/dist/{chunk-URZOWIR3.cjs → chunk-6BYSVWIS.cjs} +11 -11
- package/dist/{chunk-XAG7ABPI.cjs → chunk-A5TMKZRQ.cjs} +32 -32
- package/dist/{chunk-SC4RKSMW.cjs → chunk-BSF7E5EZ.cjs} +61 -61
- package/dist/{chunk-PYZTG3T5.cjs → chunk-BT53NHR7.cjs} +25 -25
- package/dist/{chunk-7NCNJXMK.cjs → chunk-DRTXDPWM.cjs} +32 -32
- package/dist/{chunk-3B6PFUL3.cjs → chunk-FRS2VO22.cjs} +71 -19
- package/dist/{chunk-RTUSHW7S.cjs → chunk-H6U3K5EX.cjs} +18 -18
- package/dist/{chunk-IN6SPMCB.cjs → chunk-HKYGJVTA.cjs} +41 -41
- package/dist/{chunk-THY2XVGY.cjs → chunk-I3RJLXEL.cjs} +23 -17
- package/dist/{chunk-PCHNBV73.cjs → chunk-K6YBHFWX.cjs} +71 -71
- package/dist/{chunk-F2VN3UUB.cjs → chunk-KS5V55HN.cjs} +37 -37
- package/dist/{chunk-QE7H4Y3F.cjs → chunk-LF7B3LJE.cjs} +24 -24
- package/dist/{chunk-76NE67PK.cjs → chunk-ML3DG4SS.cjs} +2 -2
- package/dist/{chunk-IMDOKSEG.cjs → chunk-OAJ3AL4V.cjs} +4 -4
- package/dist/{chunk-FQ4LYYBI.cjs → chunk-PIKHEBG5.cjs} +48 -48
- package/dist/{chunk-OETG7KV6.cjs → chunk-R2S22LDL.cjs} +3 -3
- package/dist/{chunk-5OFEH673.cjs → chunk-RZNRKWG5.cjs} +13 -13
- package/dist/{chunk-CRBG5HXA.cjs → chunk-SPS7TL7Z.cjs} +799 -761
- package/dist/{chunk-MR3LQUOW.cjs → chunk-T64MG3HS.cjs} +6 -6
- package/dist/{chunk-MHH7CHNI.cjs → chunk-TOWVMBAP.cjs} +4 -4
- package/dist/{chunk-3WNCFZGN.cjs → chunk-TUZV2ZQY.cjs} +2 -2
- package/dist/{chunk-V3T5MDJV.cjs → chunk-VHX4A4SA.cjs} +2 -2
- package/dist/{chunk-DTKHEHIQ.cjs → chunk-ZAXGW4KT.cjs} +14 -14
- package/dist/{cloud-tenants-6E27I6AY.cjs → cloud-tenants-H5TMGGDF.cjs} +7 -7
- package/dist/components/case-studies/index.cjs +21 -21
- package/dist/components/chat/index.cjs +5 -5
- package/dist/components/contact/index.cjs +8 -8
- package/dist/components/docs/index.cjs +11 -11
- package/dist/components/embeds/index.cjs +8 -8
- package/dist/components/faq/index.cjs +9 -9
- package/dist/components/features/index.cjs +7 -7
- package/dist/components/features/scripts/schedule-form/schedule-offline-fields.d.ts.map +1 -1
- package/dist/components/features/scripts/schedule-form/schedule-offline-fields.js +16 -4
- package/dist/components/features/scripts/schedule-form/schedule-timing-fields.d.ts +1 -1
- package/dist/components/features/scripts/schedule-form/schedule-timing-fields.d.ts.map +1 -1
- package/dist/components/features/scripts/schedule-form/schedule-timing-fields.js +9 -2
- package/dist/components/help-center-pages/index.cjs +88 -88
- package/dist/components/index.cjs +55 -53
- package/dist/components/meeting-scheduler/index.cjs +46 -46
- package/dist/components/navigation/index.cjs +10 -10
- package/dist/components/onboarding-guides/index.cjs +10 -10
- package/dist/components/product-demo/index.cjs +17 -17
- package/dist/components/related-content/index.cjs +5 -5
- package/dist/components/tickets/index.cjs +14 -14
- package/dist/components/ui/assignee-dropdown.d.ts +10 -0
- package/dist/components/ui/assignee-dropdown.d.ts.map +1 -1
- package/dist/components/ui/assignee-dropdown.js +14 -2
- package/dist/components/ui/autocomplete.d.ts +24 -0
- package/dist/components/ui/autocomplete.d.ts.map +1 -1
- package/dist/components/ui/autocomplete.js +26 -4
- package/dist/components/ui/index.cjs +9 -7
- package/dist/components/ui/modal.d.ts.map +1 -1
- package/dist/components/ui/modal.js +24 -18
- package/dist/components/ui/reopen-ticket-modal.d.ts +17 -1
- package/dist/components/ui/reopen-ticket-modal.d.ts.map +1 -1
- package/dist/components/ui/reopen-ticket-modal.js +8 -15
- package/dist/components/ui/searchable-select.d.ts +17 -0
- package/dist/components/ui/searchable-select.d.ts.map +1 -1
- package/dist/components/ui/searchable-select.js +24 -9
- package/dist/components/ui/server-search-options.d.ts +30 -0
- package/dist/components/ui/server-search-options.d.ts.map +1 -0
- package/dist/components/ui/server-search-options.js +30 -0
- package/dist/components/ui/take-over-ticket-modal.d.ts +25 -1
- package/dist/components/ui/take-over-ticket-modal.d.ts.map +1 -1
- package/dist/components/ui/take-over-ticket-modal.js +14 -14
- package/dist/components/ui/ticket-info-section.d.ts +2 -0
- package/dist/components/ui/ticket-info-section.d.ts.map +1 -1
- package/dist/components/ui/ticket-info-section.js +2 -1
- package/dist/{devices-HZVRGH3A.cjs → devices-4MF5B7WJ.cjs} +8 -8
- package/dist/{embeddable-chat-GHBCX2BY.cjs → embeddable-chat-XT6GMSBX.cjs} +62 -62
- package/dist/index.cjs +13 -11
- package/dist/{knowledge-EJG7YG7C.cjs → knowledge-MI7VMPRF.cjs} +8 -8
- package/dist/{logs-6N3ANKZK.cjs → logs-7TEU2UXV.cjs} +15 -15
- package/dist/{policies-CE7A66D7.cjs → policies-AR7B4LW5.cjs} +11 -11
- package/dist/{remote-session-HLGLKOGW.cjs → remote-session-LMUFV2RZ.cjs} +4 -4
- package/dist/{scripts-NREM2Y6Z.cjs → scripts-HTMYPV5Q.cjs} +14 -14
- package/dist/{software-update-CI4F3IRV.cjs → software-update-YMSYGYCM.cjs} +11 -11
- package/package.json +1 -1
- package/src/components/features/scripts/schedule-form/schedule-offline-fields.tsx +10 -1
- package/src/components/features/scripts/schedule-form/schedule-timing-fields.tsx +10 -4
- package/src/components/ui/assignee-dropdown.tsx +29 -1
- package/src/components/ui/autocomplete.tsx +68 -5
- package/src/components/ui/modal.tsx +14 -4
- package/src/components/ui/reopen-ticket-modal.tsx +22 -14
- package/src/components/ui/searchable-select.tsx +52 -8
- package/src/components/ui/server-search-options.ts +65 -0
- package/src/components/ui/take-over-ticket-modal.tsx +35 -13
- package/src/components/ui/ticket-info-section.tsx +3 -0
|
@@ -30,6 +30,7 @@ import { Button } from './button';
|
|
|
30
30
|
import { FieldWrapper } from './field-wrapper';
|
|
31
31
|
import { HiddenTagsPopup } from './hidden-tags-popup';
|
|
32
32
|
import { LoadingItems, useLoadingScope } from './loading-scope';
|
|
33
|
+
import { useRememberedSelection, useSettledOptions } from './server-search-options';
|
|
33
34
|
import { Tag } from './tag';
|
|
34
35
|
import { TruncateText } from './truncate-text';
|
|
35
36
|
|
|
@@ -124,6 +125,30 @@ interface AutocompleteBaseProps<T = string> {
|
|
|
124
125
|
isDeletingOption?: boolean;
|
|
125
126
|
/** When true, disables built-in client-side filtering (useful when options are filtered server-side via onInputChange) */
|
|
126
127
|
disableClientFilter?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Server search. When set, `options` is the server's answer to the query
|
|
130
|
+
* reported here, not a list to filter:
|
|
131
|
+
*
|
|
132
|
+
* - called with the raw query on every keystroke (debounce in the caller),
|
|
133
|
+
* and with `''` whenever the field resets — a pick, closing the dropdown,
|
|
134
|
+
* Escape, the clear button — so the caller can go back to its unfiltered
|
|
135
|
+
* first page. Repeats are not reported.
|
|
136
|
+
* - nothing is filtered locally (`filterOptions` / `disableClientFilter` are
|
|
137
|
+
* moot).
|
|
138
|
+
* - while `loading`, the options stay listed (the field's spinner still
|
|
139
|
+
* turns), and an `options` emptied mid-load falls back to the last list
|
|
140
|
+
* that settled; the loading rows show only with nothing to list yet.
|
|
141
|
+
* - a selected value missing from the current answer keeps the label and
|
|
142
|
+
* icon of the last option seen for it (see also `selectedOptions`).
|
|
143
|
+
*/
|
|
144
|
+
onSearchChange?: (query: string) => void;
|
|
145
|
+
/**
|
|
146
|
+
* Options for the current value(s) that `options` may not include — e.g. a
|
|
147
|
+
* pre-selected value the server's first page never returned. Consulted only
|
|
148
|
+
* to render the selection (field label, icon, tags) when `options` has no
|
|
149
|
+
* match; never listed.
|
|
150
|
+
*/
|
|
151
|
+
selectedOptions?: AutocompleteOption<T>[];
|
|
127
152
|
/** Whether to show the chevron icon. Default true */
|
|
128
153
|
showChevron?: boolean;
|
|
129
154
|
/** Whether to clear the input when the dropdown opens (single mode only). Default true */
|
|
@@ -231,9 +256,12 @@ function AutocompleteInner<T = string>(props: AutocompleteProps<T>, ref: Forward
|
|
|
231
256
|
onDeleteOption,
|
|
232
257
|
isDeletingOption = false,
|
|
233
258
|
disableClientFilter = false,
|
|
259
|
+
onSearchChange,
|
|
260
|
+
selectedOptions: selectedOptionsProp,
|
|
234
261
|
showChevron = true,
|
|
235
262
|
clearOnOpen = true,
|
|
236
263
|
} = props;
|
|
264
|
+
const serverSearch = onSearchChange !== undefined;
|
|
237
265
|
|
|
238
266
|
const multiple = props.multiple ?? false;
|
|
239
267
|
const placeholder = props.placeholder ?? (multiple ? 'Add More...' : 'Select...');
|
|
@@ -259,11 +287,26 @@ function AutocompleteInner<T = string>(props: AutocompleteProps<T>, ref: Forward
|
|
|
259
287
|
const isInputControlled = inputValueProp !== undefined;
|
|
260
288
|
const inputValue = isInputControlled ? inputValueProp : internalInputValue;
|
|
261
289
|
|
|
290
|
+
// The last query handed to `onSearchChange`: every close resets the field,
|
|
291
|
+
// and a reset of a field that was never searched is not news to the caller.
|
|
292
|
+
// Read and written from event handlers only.
|
|
293
|
+
const reportedQueryRef = useRef('');
|
|
294
|
+
const reportQuery = (value: string, reason: AutocompleteInputChangeReason) => {
|
|
295
|
+
if (!onSearchChange) return;
|
|
296
|
+
// A reset or clear is never a query, even when it refills the field with
|
|
297
|
+
// the selected label (`clearOnOpen={false}`).
|
|
298
|
+
const query = reason === 'input' ? value : '';
|
|
299
|
+
if (query === reportedQueryRef.current) return;
|
|
300
|
+
reportedQueryRef.current = query;
|
|
301
|
+
onSearchChange(query);
|
|
302
|
+
};
|
|
303
|
+
|
|
262
304
|
const updateInputValue = (value: string, reason: AutocompleteInputChangeReason) => {
|
|
263
305
|
if (!isInputControlled) {
|
|
264
306
|
setInternalInputValue(value);
|
|
265
307
|
}
|
|
266
308
|
onInputChange?.(value, reason);
|
|
309
|
+
reportQuery(value, reason);
|
|
267
310
|
};
|
|
268
311
|
|
|
269
312
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -277,10 +320,20 @@ function AutocompleteInner<T = string>(props: AutocompleteProps<T>, ref: Forward
|
|
|
277
320
|
// Combine refs
|
|
278
321
|
useImperativeHandle(ref, () => containerRef.current as HTMLDivElement);
|
|
279
322
|
|
|
323
|
+
// Server search: what to list (steady between keystrokes) and the last
|
|
324
|
+
// option seen per selected value. Both pass through untouched otherwise.
|
|
325
|
+
const listedOptions = useSettledOptions(options, loading, serverSearch);
|
|
326
|
+
const rememberedSelection = useRememberedSelection(listedOptions, valueArray, serverSearch);
|
|
327
|
+
|
|
280
328
|
// Get selected options
|
|
281
329
|
const selectedOptions = useMemo(() => {
|
|
282
|
-
return valueArray.map(
|
|
283
|
-
|
|
330
|
+
return valueArray.map(
|
|
331
|
+
v =>
|
|
332
|
+
listedOptions.find(opt => opt.value === v) ??
|
|
333
|
+
selectedOptionsProp?.find(opt => opt.value === v) ??
|
|
334
|
+
rememberedSelection.get(v) ?? { label: String(v), value: v },
|
|
335
|
+
);
|
|
336
|
+
}, [valueArray, listedOptions, selectedOptionsProp, rememberedSelection]);
|
|
284
337
|
|
|
285
338
|
// Single mode: the currently selected option
|
|
286
339
|
const selectedOption = !multiple && selectedOptions.length > 0 ? selectedOptions[0] : null;
|
|
@@ -349,6 +402,11 @@ function AutocompleteInner<T = string>(props: AutocompleteProps<T>, ref: Forward
|
|
|
349
402
|
|
|
350
403
|
// Filter options based on inputValue
|
|
351
404
|
const filteredOptions = useMemo(() => {
|
|
405
|
+
// The server already filtered: its answer is the list.
|
|
406
|
+
if (serverSearch) {
|
|
407
|
+
return listedOptions;
|
|
408
|
+
}
|
|
409
|
+
|
|
352
410
|
if (disableClientFilter) {
|
|
353
411
|
return options;
|
|
354
412
|
}
|
|
@@ -363,7 +421,11 @@ function AutocompleteInner<T = string>(props: AutocompleteProps<T>, ref: Forward
|
|
|
363
421
|
|
|
364
422
|
const lowerInput = inputValue.toLowerCase();
|
|
365
423
|
return options.filter(opt => opt.label.toLowerCase().includes(lowerInput));
|
|
366
|
-
}, [options, inputValue, filterOptions, disableClientFilter]);
|
|
424
|
+
}, [options, listedOptions, serverSearch, inputValue, filterOptions, disableClientFilter]);
|
|
425
|
+
|
|
426
|
+
// The list gives way to its loading rows while loading — except under server
|
|
427
|
+
// search with something to show, where the rows stay until the answer lands.
|
|
428
|
+
const showLoadingRows = loading && (!serverSearch || filteredOptions.length === 0);
|
|
367
429
|
|
|
368
430
|
// Show "+ Create" option when creatable is on, user typed something, and nothing matched
|
|
369
431
|
const showCreateOption = creatable && inputValue.trim().length > 0 && filteredOptions.length === 0;
|
|
@@ -447,6 +509,7 @@ function AutocompleteInner<T = string>(props: AutocompleteProps<T>, ref: Forward
|
|
|
447
509
|
setInternalInputValue('');
|
|
448
510
|
}
|
|
449
511
|
onInputChange?.('', 'clear');
|
|
512
|
+
reportQuery('', 'clear');
|
|
450
513
|
setIsOpen(false);
|
|
451
514
|
};
|
|
452
515
|
|
|
@@ -692,8 +755,8 @@ function AutocompleteInner<T = string>(props: AutocompleteProps<T>, ref: Forward
|
|
|
692
755
|
<ScrollAreaPrimitive.Viewport className="max-h-[240px] min-h-0 w-full [&>div]:!block">
|
|
693
756
|
{/* A listbox owns options only: while they are read the box is the loading region's (a status and
|
|
694
757
|
hidden rows), with no listbox role around it. */}
|
|
695
|
-
<div role={
|
|
696
|
-
{
|
|
758
|
+
<div role={showLoadingRows ? undefined : 'listbox'}>
|
|
759
|
+
{showLoadingRows ? (
|
|
697
760
|
// The options while they are read: the list's own rows, a label bar each (`loadingText` is what a
|
|
698
761
|
// screen reader hears).
|
|
699
762
|
<LoadingRegion label={loadingText}>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { usePreventScroll } from '@react-aria/overlays';
|
|
4
|
-
import { type ReactNode, forwardRef, useEffect } from 'react';
|
|
4
|
+
import { type ReactNode, forwardRef, useEffect, useLayoutEffect, useState } from 'react';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
5
6
|
import { ViewportBreakpoints } from '../../hooks/ui/use-content-breakpoint';
|
|
6
7
|
import { cn } from '../../utils/cn';
|
|
7
8
|
|
|
@@ -59,9 +60,17 @@ const Modal = forwardRef<HTMLDivElement, ModalProps>(({ isOpen, onClose, childre
|
|
|
59
60
|
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
60
61
|
}, [isOpen, onClose]);
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
// <body> is known only after mount (ModalV2's rule): an open modal renders nothing on the server.
|
|
64
|
+
const [portalTarget, setPortalTarget] = useState<HTMLElement | null>(null);
|
|
65
|
+
useLayoutEffect(() => setPortalTarget(document.body), []);
|
|
63
66
|
|
|
64
|
-
return
|
|
67
|
+
if (!isOpen || !portalTarget) return null;
|
|
68
|
+
|
|
69
|
+
// Rendered into <body>, never where the caller sits: a `fixed` element inside an ancestor with a
|
|
70
|
+
// transform, filter, `contain` or its own stacking context (a card strip, a marquee, a blurred
|
|
71
|
+
// header) is positioned and layered inside THAT box, so the site header and the next section
|
|
72
|
+
// painted over the dialog (the gathering gallery on /careers).
|
|
73
|
+
return createPortal(
|
|
65
74
|
<div className="ods-viewport-layer fixed inset-0 z-[1300] flex items-center justify-center">
|
|
66
75
|
<div className="absolute inset-0 bg-ods-overlay" onClick={onClose} aria-hidden="true" />
|
|
67
76
|
<div
|
|
@@ -75,7 +84,8 @@ const Modal = forwardRef<HTMLDivElement, ModalProps>(({ isOpen, onClose, childre
|
|
|
75
84
|
>
|
|
76
85
|
<ViewportBreakpoints>{children}</ViewportBreakpoints>
|
|
77
86
|
</div>
|
|
78
|
-
</div
|
|
87
|
+
</div>,
|
|
88
|
+
portalTarget,
|
|
79
89
|
);
|
|
80
90
|
});
|
|
81
91
|
Modal.displayName = 'Modal';
|
|
@@ -5,12 +5,12 @@ import { Autocomplete } from './autocomplete';
|
|
|
5
5
|
import { Button } from './button';
|
|
6
6
|
import { ColorSwatch } from './color-swatch';
|
|
7
7
|
import { ModalV2, ModalV2Footer, ModalV2Header, ModalV2Title } from './modal-v2';
|
|
8
|
-
import { SquareAvatar } from './square-avatar';
|
|
9
8
|
import {
|
|
10
9
|
renderTicketAssigneeOption,
|
|
11
10
|
renderTicketStatusOption,
|
|
12
11
|
type TakeOverAssigneeOption,
|
|
13
12
|
type TakeOverStatusOption,
|
|
13
|
+
withTicketAssigneeAvatars,
|
|
14
14
|
} from './take-over-ticket-modal';
|
|
15
15
|
import { Textarea } from './textarea';
|
|
16
16
|
|
|
@@ -44,6 +44,22 @@ export interface ReopenTicketModalProps {
|
|
|
44
44
|
initialAssigneeId?: string | null;
|
|
45
45
|
/** Confirm in-flight: buttons lock and the modal refuses to close. */
|
|
46
46
|
isPending?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Server search for the Assigned picker. When set, `assigneeOptions` is the
|
|
49
|
+
* server's answer to the query reported here and is not filtered locally:
|
|
50
|
+
* called with the raw query on every keystroke (debounce in the caller) and
|
|
51
|
+
* with `''` when the picker resets (a pick, closing it, the clear button).
|
|
52
|
+
* While `assigneesLoading`, the previous rows stay listed, and the picked
|
|
53
|
+
* assignee keeps their name and avatar after leaving `assigneeOptions`.
|
|
54
|
+
*/
|
|
55
|
+
onAssigneeSearchChange?: (query: string) => void;
|
|
56
|
+
/**
|
|
57
|
+
* The pre-selected assignee as an option, for when `assigneeOptions` does
|
|
58
|
+
* not include them (a server search's first page) — the field would read
|
|
59
|
+
* the raw id otherwise. Only renders the selection; `initialAssigneeId`
|
|
60
|
+
* still decides it.
|
|
61
|
+
*/
|
|
62
|
+
initialAssigneeOption?: TakeOverAssigneeOption;
|
|
47
63
|
onConfirm: (selection: ReopenTicketSelection) => void;
|
|
48
64
|
}
|
|
49
65
|
|
|
@@ -69,6 +85,8 @@ export function ReopenTicketModal({
|
|
|
69
85
|
initialAssigneeId,
|
|
70
86
|
isPending = false,
|
|
71
87
|
onConfirm,
|
|
88
|
+
onAssigneeSearchChange,
|
|
89
|
+
initialAssigneeOption,
|
|
72
90
|
}: ReopenTicketModalProps) {
|
|
73
91
|
const [statusId, setStatusId] = useState<string | null>(initialStatusId ?? null);
|
|
74
92
|
const [assigneeId, setAssigneeId] = useState<string | null>(initialAssigneeId ?? null);
|
|
@@ -95,7 +113,6 @@ export function ReopenTicketModal({
|
|
|
95
113
|
|
|
96
114
|
const selectedStatusId = statusId ?? statusOptions[0]?.value ?? null;
|
|
97
115
|
const selectedStatus = statusOptions.find(o => o.value === selectedStatusId);
|
|
98
|
-
const selectedAssignee = assigneeOptions.find(o => o.value === assigneeId);
|
|
99
116
|
|
|
100
117
|
const handleConfirm = () => {
|
|
101
118
|
if (!selectedStatusId || !assigneeId || isPending) return;
|
|
@@ -133,22 +150,13 @@ export function ReopenTicketModal({
|
|
|
133
150
|
<div className="min-w-0 flex-1">
|
|
134
151
|
<Autocomplete
|
|
135
152
|
label="Assigned"
|
|
136
|
-
options={assigneeOptions}
|
|
153
|
+
options={withTicketAssigneeAvatars(assigneeOptions)}
|
|
137
154
|
value={assigneeId}
|
|
138
155
|
onChange={setAssigneeId}
|
|
139
156
|
placeholder="Select Technician"
|
|
140
157
|
loading={assigneesLoading}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
<SquareAvatar
|
|
144
|
-
src={selectedAssignee.imageUrl}
|
|
145
|
-
alt={selectedAssignee.label}
|
|
146
|
-
fallback={selectedAssignee.label}
|
|
147
|
-
size="sm"
|
|
148
|
-
variant="round"
|
|
149
|
-
/>
|
|
150
|
-
) : undefined
|
|
151
|
-
}
|
|
158
|
+
onSearchChange={onAssigneeSearchChange}
|
|
159
|
+
selectedOptions={initialAssigneeOption ? withTicketAssigneeAvatars([initialAssigneeOption]) : undefined}
|
|
152
160
|
renderOption={renderTicketAssigneeOption}
|
|
153
161
|
/>
|
|
154
162
|
</div>
|
|
@@ -13,6 +13,7 @@ import { FieldWrapper } from './field-wrapper';
|
|
|
13
13
|
import { Input } from './input';
|
|
14
14
|
import { LoadingItems } from './loading-scope';
|
|
15
15
|
import { usePortalContainer } from './portal-container';
|
|
16
|
+
import { useRememberedSelection, useSettledOptions } from './server-search-options';
|
|
16
17
|
|
|
17
18
|
/** An option's frame (a list row, or a tile in the grid): the `row` button kind, read by the options and by their
|
|
18
19
|
* loading state so both draw one box. A tile is the row laid out as a column. */
|
|
@@ -88,6 +89,23 @@ export interface SearchableSelectProps {
|
|
|
88
89
|
className?: string;
|
|
89
90
|
/** Classes for the popover content (e.g. a fixed width for icon triggers). */
|
|
90
91
|
contentClassName?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Server search. When set, `options` is the server's answer to the query
|
|
94
|
+
* reported here, not a list to filter:
|
|
95
|
+
*
|
|
96
|
+
* - called with the raw query on every change of the search field (debounce
|
|
97
|
+
* in the caller), and with `''` when the dropdown closes on a non-empty
|
|
98
|
+
* query (a pick, Escape, a click outside) — the field clears on close, so
|
|
99
|
+
* the caller goes back to its unfiltered first page with it.
|
|
100
|
+
* - nothing is filtered locally (`keywords` are moot).
|
|
101
|
+
* - while `isLoading`, the options stay listed, and an `options` emptied
|
|
102
|
+
* mid-load falls back to the last list that settled; the loading rows show
|
|
103
|
+
* only with nothing to list yet.
|
|
104
|
+
* - the default trigger keeps the label and icon of the last option seen
|
|
105
|
+
* for `value` when the current answer does not include it. A custom
|
|
106
|
+
* `trigger` renders its own selection.
|
|
107
|
+
*/
|
|
108
|
+
onSearchChange?: (query: string) => void;
|
|
91
109
|
}
|
|
92
110
|
|
|
93
111
|
/**
|
|
@@ -119,7 +137,9 @@ export function SearchableSelect(allProps: SearchableSelectProps) {
|
|
|
119
137
|
align = 'start',
|
|
120
138
|
className,
|
|
121
139
|
contentClassName,
|
|
140
|
+
onSearchChange,
|
|
122
141
|
} = allProps;
|
|
142
|
+
const serverSearch = onSearchChange !== undefined;
|
|
123
143
|
// Wired for a message even while `error` is undefined — see `FieldWrapper.errorSlot`.
|
|
124
144
|
const errorSlot = 'error' in allProps;
|
|
125
145
|
const isInvalid = !!error;
|
|
@@ -140,22 +160,46 @@ export function SearchableSelect(allProps: SearchableSelectProps) {
|
|
|
140
160
|
// on `search`, so the extra render pass this schedules takes the early exit.
|
|
141
161
|
if (!isOpen && search !== '') setSearch('');
|
|
142
162
|
|
|
163
|
+
// Server search: what to list (steady between keystrokes) and the last
|
|
164
|
+
// option seen for the selected value. Both pass through untouched otherwise.
|
|
165
|
+
const listedOptions = useSettledOptions(options, isLoading, serverSearch);
|
|
166
|
+
const rememberedSelection = useRememberedSelection(listedOptions, value != null ? [value] : [], serverSearch);
|
|
167
|
+
|
|
143
168
|
const filtered = useMemo(() => {
|
|
169
|
+
// The server already filtered: its answer is the list.
|
|
170
|
+
if (serverSearch) return listedOptions;
|
|
144
171
|
const q = search.trim().toLowerCase();
|
|
145
172
|
if (!q) return options;
|
|
146
173
|
return options.filter(
|
|
147
174
|
o => o.label.toLowerCase().includes(q) || (o.keywords ?? []).some(k => k.toLowerCase().includes(q)),
|
|
148
175
|
);
|
|
149
|
-
}, [options, search]);
|
|
176
|
+
}, [options, listedOptions, serverSearch, search]);
|
|
150
177
|
|
|
151
178
|
const selectedOption = useMemo(
|
|
152
|
-
() => (value != null ?
|
|
153
|
-
[
|
|
179
|
+
() => (value != null ? (listedOptions.find(o => o.value === value) ?? rememberedSelection.get(value)) : undefined),
|
|
180
|
+
[listedOptions, rememberedSelection, value],
|
|
154
181
|
);
|
|
155
182
|
|
|
183
|
+
// The list gives way to its loading rows while loading — except under server
|
|
184
|
+
// search with something to show, where the rows stay until the answer lands.
|
|
185
|
+
const showLoadingRows = isLoading && (!serverSearch || filtered.length === 0);
|
|
186
|
+
|
|
187
|
+
const handleSearchChange = (query: string) => {
|
|
188
|
+
setSearch(query);
|
|
189
|
+
onSearchChange?.(query);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// Every close goes through here, so a server search hears that the query it
|
|
193
|
+
// filtered by is gone — the field itself is emptied by the render-time reset
|
|
194
|
+
// above. An already-empty field has nothing to report.
|
|
195
|
+
const handleOpenChange = (open: boolean) => {
|
|
196
|
+
setIsOpen(open);
|
|
197
|
+
if (!open && search !== '') onSearchChange?.('');
|
|
198
|
+
};
|
|
199
|
+
|
|
156
200
|
const handleSelect = (optionValue: string) => {
|
|
157
201
|
onValueChange(optionValue);
|
|
158
|
-
|
|
202
|
+
handleOpenChange(false);
|
|
159
203
|
};
|
|
160
204
|
|
|
161
205
|
const defaultTrigger = (
|
|
@@ -199,7 +243,7 @@ export function SearchableSelect(allProps: SearchableSelectProps) {
|
|
|
199
243
|
);
|
|
200
244
|
|
|
201
245
|
return (
|
|
202
|
-
<PopoverPrimitive.Root open={isOpen} onOpenChange={disabled ? undefined :
|
|
246
|
+
<PopoverPrimitive.Root open={isOpen} onOpenChange={disabled ? undefined : handleOpenChange} modal={false}>
|
|
203
247
|
{!trigger && (label !== undefined || errorSlot) ? (
|
|
204
248
|
<FieldWrapper label={label} htmlFor={triggerId} labelVariant={labelVariant} error={error} errorSlot={errorSlot}>
|
|
205
249
|
{triggerElement}
|
|
@@ -230,7 +274,7 @@ export function SearchableSelect(allProps: SearchableSelectProps) {
|
|
|
230
274
|
userValue
|
|
231
275
|
autoFocus
|
|
232
276
|
value={search}
|
|
233
|
-
onChange={e =>
|
|
277
|
+
onChange={e => handleSearchChange(e.target.value)}
|
|
234
278
|
placeholder={searchPlaceholder}
|
|
235
279
|
startAdornment={<SearchIcon className="size-4 text-ods-text-secondary" />}
|
|
236
280
|
className="rounded-none border-0"
|
|
@@ -248,9 +292,9 @@ export function SearchableSelect(allProps: SearchableSelectProps) {
|
|
|
248
292
|
)}
|
|
249
293
|
// A listbox owns options only: while they are read the box holds the loading region (a status and
|
|
250
294
|
// hidden rows), with no listbox role around it.
|
|
251
|
-
role={
|
|
295
|
+
role={showLoadingRows ? undefined : 'listbox'}
|
|
252
296
|
>
|
|
253
|
-
{
|
|
297
|
+
{showLoadingRows ? (
|
|
254
298
|
// The options while they are read: the list's own rows (or tiles), a label bar each; `loadingText` is
|
|
255
299
|
// what a screen reader hears.
|
|
256
300
|
<LoadingRegion label={loadingText} className="contents">
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Bookkeeping shared by the pickers that can search on the server
|
|
7
|
+
* (`Autocomplete` / `SearchableSelect` with `onSearchChange`). There the
|
|
8
|
+
* caller's `options` ARE the server's answer to the current query, so the
|
|
9
|
+
* picker filters nothing; what it still owes the user is a list that holds
|
|
10
|
+
* still between keystrokes and a selection that keeps its label.
|
|
11
|
+
*
|
|
12
|
+
* Both hooks take `enabled` and are inert without it, so a client-filtered
|
|
13
|
+
* picker pays nothing and behaves exactly as before.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The options to list. While the next answer is in flight (`isLoading`), a
|
|
18
|
+
* caller that already emptied `options` would blank the list — or flash its
|
|
19
|
+
* "no results" line — on every keystroke, so an empty list falls back to the
|
|
20
|
+
* last one that settled. A caller that keeps the previous answer through the
|
|
21
|
+
* load (a transition, a placeholder) passes through untouched, and an empty
|
|
22
|
+
* answer that has settled is shown as the empty state it is.
|
|
23
|
+
*/
|
|
24
|
+
export function useSettledOptions<O>(options: O[], isLoading: boolean, enabled: boolean): O[] {
|
|
25
|
+
const [settled, setSettled] = useState(options);
|
|
26
|
+
// Adjusted while rendering, not from an effect: the list is drawn from this
|
|
27
|
+
// render's value, so an effect would paint one frame of the stale snapshot.
|
|
28
|
+
// Guarded on identity, so the pass React schedules for it takes the exit.
|
|
29
|
+
if (enabled && !isLoading && settled !== options) setSettled(options);
|
|
30
|
+
return enabled && isLoading && options.length === 0 ? settled : options;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The last option seen for each selected value. A server search replaces
|
|
35
|
+
* `options` on every query, and a selection the current answer does not
|
|
36
|
+
* include would otherwise lose its label and icon. Holds the selected values
|
|
37
|
+
* only — a value that is deselected is forgotten — so it never outgrows the
|
|
38
|
+
* selection.
|
|
39
|
+
*/
|
|
40
|
+
export function useRememberedSelection<T, O extends { value: T }>(
|
|
41
|
+
options: readonly O[],
|
|
42
|
+
selected: readonly T[],
|
|
43
|
+
enabled: boolean,
|
|
44
|
+
): ReadonlyMap<T, O> {
|
|
45
|
+
const [remembered, setRemembered] = useState<ReadonlyMap<T, O>>(() => new Map());
|
|
46
|
+
if (enabled) {
|
|
47
|
+
const next = new Map<T, O>();
|
|
48
|
+
for (const value of selected) {
|
|
49
|
+
const option = options.find(o => o.value === value) ?? remembered.get(value);
|
|
50
|
+
if (option) next.set(value, option);
|
|
51
|
+
}
|
|
52
|
+
// Same render-time adjustment as above; identity-compared entries, so the
|
|
53
|
+
// re-run with the same props computes an equal map and stops.
|
|
54
|
+
if (!hasSameEntries(next, remembered)) setRemembered(next);
|
|
55
|
+
}
|
|
56
|
+
return remembered;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function hasSameEntries<K, V>(a: ReadonlyMap<K, V>, b: ReadonlyMap<K, V>): boolean {
|
|
60
|
+
if (a.size !== b.size) return false;
|
|
61
|
+
for (const [key, value] of a) {
|
|
62
|
+
if (b.get(key) !== value) return false;
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
@@ -39,6 +39,22 @@ export interface TakeOverTicketModalProps {
|
|
|
39
39
|
initialAssigneeId?: string | null;
|
|
40
40
|
/** Confirm in-flight: buttons lock and the modal refuses to close. */
|
|
41
41
|
isPending?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Server search for the Assigned picker. When set, `assigneeOptions` is the
|
|
44
|
+
* server's answer to the query reported here and is not filtered locally:
|
|
45
|
+
* called with the raw query on every keystroke (debounce in the caller) and
|
|
46
|
+
* with `''` when the picker resets (a pick, closing it, the clear button).
|
|
47
|
+
* While `assigneesLoading`, the previous rows stay listed, and the picked
|
|
48
|
+
* assignee keeps their name and avatar after leaving `assigneeOptions`.
|
|
49
|
+
*/
|
|
50
|
+
onAssigneeSearchChange?: (query: string) => void;
|
|
51
|
+
/**
|
|
52
|
+
* The pre-selected assignee as an option, for when `assigneeOptions` does
|
|
53
|
+
* not include them (a server search's first page) — the field would read
|
|
54
|
+
* the raw id otherwise. Only renders the selection; `initialAssigneeId`
|
|
55
|
+
* still decides it.
|
|
56
|
+
*/
|
|
57
|
+
initialAssigneeOption?: TakeOverAssigneeOption;
|
|
42
58
|
onConfirm: (selection: TakeOverTicketSelection) => void;
|
|
43
59
|
}
|
|
44
60
|
|
|
@@ -75,6 +91,20 @@ export function renderTicketAssigneeOption(option: AutocompleteOption, isSelecte
|
|
|
75
91
|
);
|
|
76
92
|
}
|
|
77
93
|
|
|
94
|
+
/**
|
|
95
|
+
* The assignee options with each avatar as the option's `icon` — shared by the
|
|
96
|
+
* ticket lifecycle modals. The Assigned field leads with the SELECTED option's
|
|
97
|
+
* icon, which `Autocomplete` resolves even after a server search has dropped
|
|
98
|
+
* that option from `assigneeOptions`; an adornment looked up in the current
|
|
99
|
+
* options lost the avatar the moment that happened.
|
|
100
|
+
*/
|
|
101
|
+
export function withTicketAssigneeAvatars(options: TakeOverAssigneeOption[]): TakeOverAssigneeOption[] {
|
|
102
|
+
return options.map(option => ({
|
|
103
|
+
...option,
|
|
104
|
+
icon: <SquareAvatar src={option.imageUrl} alt={option.label} fallback={option.label} size="sm" variant="round" />,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
|
|
78
108
|
/**
|
|
79
109
|
* Take Over Ticket confirmation dialog (Figma openframe---tickets 8482-112154 /
|
|
80
110
|
* 8482-112169): shown when a technician takes a ticket over from the AI
|
|
@@ -97,6 +127,8 @@ export function TakeOverTicketModal({
|
|
|
97
127
|
initialAssigneeId,
|
|
98
128
|
isPending = false,
|
|
99
129
|
onConfirm,
|
|
130
|
+
onAssigneeSearchChange,
|
|
131
|
+
initialAssigneeOption,
|
|
100
132
|
}: TakeOverTicketModalProps) {
|
|
101
133
|
const [statusId, setStatusId] = useState<string | null>(initialStatusId ?? null);
|
|
102
134
|
const [assigneeId, setAssigneeId] = useState<string | null>(initialAssigneeId ?? null);
|
|
@@ -121,7 +153,6 @@ export function TakeOverTicketModal({
|
|
|
121
153
|
|
|
122
154
|
const selectedStatusId = statusId ?? statusOptions[0]?.value ?? null;
|
|
123
155
|
const selectedStatus = statusOptions.find(o => o.value === selectedStatusId);
|
|
124
|
-
const selectedAssignee = assigneeOptions.find(o => o.value === assigneeId);
|
|
125
156
|
|
|
126
157
|
const handleConfirm = () => {
|
|
127
158
|
if (!selectedStatusId || !assigneeId || isPending) return;
|
|
@@ -155,22 +186,13 @@ export function TakeOverTicketModal({
|
|
|
155
186
|
<div className="min-w-0 flex-1">
|
|
156
187
|
<Autocomplete
|
|
157
188
|
label="Assigned"
|
|
158
|
-
options={assigneeOptions}
|
|
189
|
+
options={withTicketAssigneeAvatars(assigneeOptions)}
|
|
159
190
|
value={assigneeId}
|
|
160
191
|
onChange={setAssigneeId}
|
|
161
192
|
placeholder="Select Technician"
|
|
162
193
|
loading={assigneesLoading}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
<SquareAvatar
|
|
166
|
-
src={selectedAssignee.imageUrl}
|
|
167
|
-
alt={selectedAssignee.label}
|
|
168
|
-
fallback={selectedAssignee.label}
|
|
169
|
-
size="sm"
|
|
170
|
-
variant="round"
|
|
171
|
-
/>
|
|
172
|
-
) : undefined
|
|
173
|
-
}
|
|
194
|
+
onSearchChange={onAssigneeSearchChange}
|
|
195
|
+
selectedOptions={initialAssigneeOption ? withTicketAssigneeAvatars([initialAssigneeOption]) : undefined}
|
|
174
196
|
renderOption={renderTicketAssigneeOption}
|
|
175
197
|
/>
|
|
176
198
|
</div>
|
|
@@ -67,6 +67,8 @@ export interface TicketInfoSectionProps {
|
|
|
67
67
|
isLoading?: boolean;
|
|
68
68
|
isPending?: boolean;
|
|
69
69
|
onAssign: (userId: string | null) => void;
|
|
70
|
+
/** Server search for the picker — see `AssigneeDropdownProps.onSearchChange`. */
|
|
71
|
+
onSearchChange?: (query: string) => void;
|
|
70
72
|
};
|
|
71
73
|
/** Created date string */
|
|
72
74
|
createdAt?: string;
|
|
@@ -178,6 +180,7 @@ export function TicketInfoSection({
|
|
|
178
180
|
isLoading={assigned.isLoading}
|
|
179
181
|
isPending={assigned.isPending}
|
|
180
182
|
onAssign={assigned.onAssign}
|
|
183
|
+
onSearchChange={assigned.onSearchChange}
|
|
181
184
|
/>
|
|
182
185
|
) : (
|
|
183
186
|
<div className="min-w-0">
|