@ordinatio/ui 1.3.0 → 1.4.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 +39 -0
- package/dist/index.d.mts +48 -1
- package/dist/index.mjs +347 -118
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -141,6 +141,45 @@ const messages: ThreadMessage[] = [...];
|
|
|
141
141
|
|
|
142
142
|
---
|
|
143
143
|
|
|
144
|
+
### `<EntityPicker>`
|
|
145
|
+
|
|
146
|
+
A searchable single-select for a collection too large to list (people, companies, products): type, search through an async callback, choose by mouse or keyboard, clear. It knows nothing about what the items are.
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { EntityPicker } from '@ordinatio/ui';
|
|
150
|
+
|
|
151
|
+
<EntityPicker<Person>
|
|
152
|
+
value={selected} // controlled: the picker calls onChange, it never changes the value itself
|
|
153
|
+
onChange={setSelected} // the chosen item, or null when cleared
|
|
154
|
+
search={(query, signal) => findPeople(query, { signal })} // reject to show errorText; honour `signal` when you can
|
|
155
|
+
getKey={(person) => person.id}
|
|
156
|
+
getLabel={(person) => person.name || person.email}
|
|
157
|
+
ariaLabel="Person" // names the input AND its list; or pass `id` and use an external <label> (which names only the input)
|
|
158
|
+
name="contactId" // optional: a hidden input with the selected key, for plain forms / Server Actions
|
|
159
|
+
renderOption={(person, { active }) => <PersonRow person={person} active={active} />} // optional
|
|
160
|
+
/>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Searching**
|
|
164
|
+
- Debounced (`debounceMs`, default 200); needs `minChars` typed (default 1; whitespace does not count, and the search receives the trimmed text).
|
|
165
|
+
- A superseded search is aborted, so a slow early answer can never overwrite a newer one.
|
|
166
|
+
- A failed search shows `errorText` (never silent: a `search` that rejects, throws, or resolves to something other than an array all count as failed); typing again retries.
|
|
167
|
+
|
|
168
|
+
**Keyboard, mouse and focus**
|
|
169
|
+
- The input shows the selected label until you type; leaving the field reverts a half-typed query to the selection (switching to another window does not). Focusing, choosing an option and Escape all leave the label selected, so typing replaces it instead of appending.
|
|
170
|
+
- Enter chooses the highlighted option and never submits an enclosing form while the popup (results or a status message) is showing. Arrow keys wrap and keep the highlight scrolled into view.
|
|
171
|
+
- While a new search is loading nothing is highlighted (hover included) and Enter and the arrow keys do nothing, so a result of an older query cannot be chosen by accident; clicking an option that is drawn still chooses it.
|
|
172
|
+
- Escape reverts typed text and closes the popup, and is not passed on to an enclosing dialog while there is either. Keys pressed while an IME is composing are ignored (`keyCode` 229 included; a few Android soft keyboards report 229 for every key, where Enter is then ignored but clicking still works).
|
|
173
|
+
- Options are chosen by click (so it works on touch); pressing anywhere in the popup, including its scrollbar, keeps focus in the input. Clearing returns focus to the input.
|
|
174
|
+
|
|
175
|
+
**Accessibility**
|
|
176
|
+
- Follows the WAI-ARIA 1.2 combobox pattern (role `combobox`, a `listbox` of `option`s that exists only when there are results; the loading, empty and error messages sit beside it, not inside). Those messages are announced through one always-mounted, visually hidden `role="status"` live region; the visible copies are `aria-hidden`.
|
|
177
|
+
|
|
178
|
+
**Forms, disabling and styling**
|
|
179
|
+
- `name` renders a hidden input with the selected key (`''` when none), for plain forms and Server Actions. `disabled` disables the input and the hidden input and removes the clear button; disabling while the user is typing reverts the text.
|
|
180
|
+
- Styling: plain elements with default inline styles. `classNames.<part>` (`root`, `input`, `clear`, `list`, `option`, `optionActive`, `message`) REPLACES that part's defaults entirely, so Tailwind or shadcn consumers can restyle everything; `style` layers onto the root defaults. Text props: `placeholder`, `clearLabel`, `loadingText`, `emptyText`, `errorText`. `clearable` (default true) shows a clear button while an item is selected.
|
|
181
|
+
- Nothing outlives the component: an unmounted picker cancels its timer and aborts its request.
|
|
182
|
+
|
|
144
183
|
## Hooks
|
|
145
184
|
|
|
146
185
|
### `useKeyboardShortcuts()`
|
package/dist/index.d.mts
CHANGED
|
@@ -156,6 +156,53 @@ interface ArchiveButtonProps {
|
|
|
156
156
|
*/
|
|
157
157
|
declare function ArchiveButton({ onArchive, archiving, disabled, label, archivingLabel, className, style, }: ArchiveButtonProps): react_jsx_runtime.JSX.Element;
|
|
158
158
|
|
|
159
|
+
interface EntityPickerClassNames {
|
|
160
|
+
root?: string;
|
|
161
|
+
input?: string;
|
|
162
|
+
clear?: string;
|
|
163
|
+
list?: string;
|
|
164
|
+
option?: string;
|
|
165
|
+
optionActive?: string;
|
|
166
|
+
message?: string;
|
|
167
|
+
}
|
|
168
|
+
interface EntityPickerProps<T> {
|
|
169
|
+
/** The selected item, or null. Controlled: the picker never changes it by itself, it calls `onChange`. */
|
|
170
|
+
value: T | null;
|
|
171
|
+
/** Called with the chosen item, or null when the selection is cleared. */
|
|
172
|
+
onChange: (item: T | null) => void;
|
|
173
|
+
/** Finds items for a query. Must honour `signal` when it can (a superseded search is aborted). Reject (or throw) to show `errorText`. */
|
|
174
|
+
search: (query: string, signal: AbortSignal) => Promise<T[]>;
|
|
175
|
+
/** A stable unique key for an item (used for list keys, the hidden input and ids). */
|
|
176
|
+
getKey: (item: T) => string;
|
|
177
|
+
/** The text for an item: shown in the input when selected, and the default option text. */
|
|
178
|
+
getLabel: (item: T) => string;
|
|
179
|
+
/** Draws an option row. Default: the label. */
|
|
180
|
+
renderOption?: (item: T, state: {
|
|
181
|
+
active: boolean;
|
|
182
|
+
}) => ReactNode;
|
|
183
|
+
/** Accessible name of the input AND its listbox. Pass this, or pass `id` and use an external <label> (which then names only the input). */
|
|
184
|
+
ariaLabel?: string;
|
|
185
|
+
id?: string;
|
|
186
|
+
/** When set, a hidden input with this name carries the selected key ('' when none), for plain forms. */
|
|
187
|
+
name?: string;
|
|
188
|
+
placeholder?: string;
|
|
189
|
+
disabled?: boolean;
|
|
190
|
+
/** Characters typed before a search runs (default 1). Typing fewer closes the list; nothing is searched on focus alone. */
|
|
191
|
+
minChars?: number;
|
|
192
|
+
/** Debounce in ms (default 200). */
|
|
193
|
+
debounceMs?: number;
|
|
194
|
+
/** Show a clear (×) button while an item is selected (default true). */
|
|
195
|
+
clearable?: boolean;
|
|
196
|
+
clearLabel?: string;
|
|
197
|
+
loadingText?: string;
|
|
198
|
+
emptyText?: string;
|
|
199
|
+
errorText?: string;
|
|
200
|
+
classNames?: EntityPickerClassNames;
|
|
201
|
+
/** Layered onto the ROOT's default styles only (to size or place the picker); other parts take `classNames`. */
|
|
202
|
+
style?: CSSProperties;
|
|
203
|
+
}
|
|
204
|
+
declare function EntityPicker<T>({ value, onChange, search, getKey, getLabel, renderOption, ariaLabel, id, name, placeholder, disabled, minChars, debounceMs, clearable, clearLabel, loadingText, emptyText, errorText, classNames, style, }: EntityPickerProps<T>): react_jsx_runtime.JSX.Element;
|
|
205
|
+
|
|
159
206
|
interface RichTextEditorProps {
|
|
160
207
|
/**
|
|
161
208
|
* Current HTML content. NOT sanitized by this component — see this
|
|
@@ -827,4 +874,4 @@ declare const ACTIVITY_ICONS: Record<string, IconComponent>;
|
|
|
827
874
|
/** Return the icon component for a given icon name, or Activity as fallback. */
|
|
828
875
|
declare function resolveActivityIcon(name: string): IconComponent;
|
|
829
876
|
|
|
830
|
-
export { ACTIVITY_ICONS, ALL_SHORTCUT_CONTEXTS, ArchiveButton, type ArchiveButtonProps, CLIENT_PROFILE_SHORTCUTS, type CachedFetchOptions, type ComposeMode, EmailBodyRenderer, type EmailBodyRendererProps, EmailThreadView, type EmailThreadViewProps, ErrorBoundary, type ErrorBoundaryProps, FORM_SHORTCUTS, GLOBAL_SHORTCUTS, INBOX_SHORTCUTS, type KeyboardShortcut, KeyboardShortcutsPanel, RENDER_ERRORS, REPLY_LAYOUT_OPTIONS, type RenderErrorResult, type ReplyLayout, ReplyPanel, type ReplyPanelProps, type ReplySendOverrides, RichTextEditor, type RichTextEditorProps, type SchedulePreset, type ShortcutContext, type ShortcutDefinition, type ThreadMessage, type UseAutoSaveOptions, type UseAutoSaveResult, type UseKeyboardShortcutsOptions, type UsePollingOptions, type UsePollingResult, type UsePreferencesOptions, type UsePreferencesResult, type UseServerSearchOptions, type UseServerSearchResult, cachedFetch, canViewInline, clearCache, formatDateGroup, formatFileSize, formatPhone, formatPhoneInput, getNextMondayMorning, getNextWeekday, getQuickScheduleOptions, getShortcut, getTomorrowMorning, groupByDate, invalidateCache, isAudio, isDocument, isEmptyHtml, isImage, isInlineLayout, isModalLayout, isPdf, isPopoutLayout, isSpreadsheet, isTypingContext, isValidScheduleDate, isVideo, opensInNewTab, parseCustomSchedule, prefetch, renderError, resolveActivityIcon, resolveContentType, stripHtml, stripPhone, truncatePreview, useAutoSave, useContextShortcuts, useIframeFocusReclaim, useKeyboardShortcuts, usePolling, usePreferences, useServerSearch, withErrorBoundary };
|
|
877
|
+
export { ACTIVITY_ICONS, ALL_SHORTCUT_CONTEXTS, ArchiveButton, type ArchiveButtonProps, CLIENT_PROFILE_SHORTCUTS, type CachedFetchOptions, type ComposeMode, EmailBodyRenderer, type EmailBodyRendererProps, EmailThreadView, type EmailThreadViewProps, EntityPicker, type EntityPickerClassNames, type EntityPickerProps, ErrorBoundary, type ErrorBoundaryProps, FORM_SHORTCUTS, GLOBAL_SHORTCUTS, INBOX_SHORTCUTS, type KeyboardShortcut, KeyboardShortcutsPanel, RENDER_ERRORS, REPLY_LAYOUT_OPTIONS, type RenderErrorResult, type ReplyLayout, ReplyPanel, type ReplyPanelProps, type ReplySendOverrides, RichTextEditor, type RichTextEditorProps, type SchedulePreset, type ShortcutContext, type ShortcutDefinition, type ThreadMessage, type UseAutoSaveOptions, type UseAutoSaveResult, type UseKeyboardShortcutsOptions, type UsePollingOptions, type UsePollingResult, type UsePreferencesOptions, type UsePreferencesResult, type UseServerSearchOptions, type UseServerSearchResult, cachedFetch, canViewInline, clearCache, formatDateGroup, formatFileSize, formatPhone, formatPhoneInput, getNextMondayMorning, getNextWeekday, getQuickScheduleOptions, getShortcut, getTomorrowMorning, groupByDate, invalidateCache, isAudio, isDocument, isEmptyHtml, isImage, isInlineLayout, isModalLayout, isPdf, isPopoutLayout, isSpreadsheet, isTypingContext, isValidScheduleDate, isVideo, opensInNewTab, parseCustomSchedule, prefetch, renderError, resolveActivityIcon, resolveContentType, stripHtml, stripPhone, truncatePreview, useAutoSave, useContextShortcuts, useIframeFocusReclaim, useKeyboardShortcuts, usePolling, usePreferences, useServerSearch, withErrorBoundary };
|
package/dist/index.mjs
CHANGED
|
@@ -693,8 +693,236 @@ function ArchiveButton({
|
|
|
693
693
|
);
|
|
694
694
|
}
|
|
695
695
|
|
|
696
|
+
// src/components/entity-picker.tsx
|
|
697
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useId, useRef as useRef2, useState as useState3 } from "react";
|
|
698
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
699
|
+
var defaults = {
|
|
700
|
+
root: { position: "relative", display: "inline-flex", alignItems: "center", gap: "4px", width: "100%" },
|
|
701
|
+
input: { flex: 1, minWidth: 0, padding: "8px 10px", fontSize: "14px", border: "1px solid #d4d4d4", borderRadius: "6px", backgroundColor: "#ffffff", color: "#171717" },
|
|
702
|
+
clear: { padding: "4px 8px", fontSize: "14px", border: "1px solid transparent", borderRadius: "6px", backgroundColor: "transparent", color: "#525252", cursor: "pointer" },
|
|
703
|
+
list: { position: "absolute", top: "100%", left: 0, right: 0, zIndex: 20, margin: "4px 0 0", padding: "4px", maxHeight: "240px", overflowY: "auto", border: "1px solid #d4d4d4", borderRadius: "6px", backgroundColor: "#ffffff", boxShadow: "0 4px 12px rgba(0,0,0,0.12)" },
|
|
704
|
+
message: { padding: "6px 8px", fontSize: "13px", color: "#525252" }
|
|
705
|
+
};
|
|
706
|
+
var optionDefaults = {
|
|
707
|
+
base: { padding: "6px 8px", fontSize: "14px", borderRadius: "4px", cursor: "pointer", color: "#171717" },
|
|
708
|
+
active: { backgroundColor: "#f5f5f5" }
|
|
709
|
+
};
|
|
710
|
+
var visuallyHidden = { position: "absolute", width: "1px", height: "1px", margin: "-1px", padding: 0, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap", border: 0 };
|
|
711
|
+
function EntityPicker({
|
|
712
|
+
value,
|
|
713
|
+
onChange,
|
|
714
|
+
search,
|
|
715
|
+
getKey,
|
|
716
|
+
getLabel,
|
|
717
|
+
renderOption,
|
|
718
|
+
ariaLabel,
|
|
719
|
+
id,
|
|
720
|
+
name,
|
|
721
|
+
placeholder,
|
|
722
|
+
disabled = false,
|
|
723
|
+
minChars = 1,
|
|
724
|
+
debounceMs = 200,
|
|
725
|
+
clearable = true,
|
|
726
|
+
clearLabel = "Clear selection",
|
|
727
|
+
loadingText = "Searching\u2026",
|
|
728
|
+
emptyText = "No matches",
|
|
729
|
+
errorText = "Search failed. Keep typing to try again.",
|
|
730
|
+
classNames,
|
|
731
|
+
style
|
|
732
|
+
}) {
|
|
733
|
+
const listId = useId();
|
|
734
|
+
const listRef = useRef2(null);
|
|
735
|
+
const inputRef = useRef2(null);
|
|
736
|
+
const selectAfterRender = useRef2(null);
|
|
737
|
+
const [text, setText] = useState3("");
|
|
738
|
+
const [editing, setEditing] = useState3(false);
|
|
739
|
+
const [open, setOpen] = useState3(false);
|
|
740
|
+
const [results, setResults] = useState3([]);
|
|
741
|
+
const [status, setStatus] = useState3("idle");
|
|
742
|
+
const [searched, setSearched] = useState3(false);
|
|
743
|
+
const [activeIndex, setActiveIndex] = useState3(-1);
|
|
744
|
+
const timer = useRef2(null);
|
|
745
|
+
const controller = useRef2(null);
|
|
746
|
+
const latest = useRef2(0);
|
|
747
|
+
const cancelSearch = useCallback2(() => {
|
|
748
|
+
if (timer.current) clearTimeout(timer.current);
|
|
749
|
+
timer.current = null;
|
|
750
|
+
controller.current?.abort();
|
|
751
|
+
controller.current = null;
|
|
752
|
+
latest.current++;
|
|
753
|
+
}, []);
|
|
754
|
+
useEffect2(() => cancelSearch, [cancelSearch]);
|
|
755
|
+
const runSearch = useCallback2(
|
|
756
|
+
(query) => {
|
|
757
|
+
cancelSearch();
|
|
758
|
+
const trimmed = query.trim();
|
|
759
|
+
if (trimmed.length < minChars) {
|
|
760
|
+
setResults([]);
|
|
761
|
+
setStatus("idle");
|
|
762
|
+
setSearched(false);
|
|
763
|
+
setActiveIndex(-1);
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
const ticket = latest.current;
|
|
767
|
+
setStatus("loading");
|
|
768
|
+
setActiveIndex(-1);
|
|
769
|
+
timer.current = setTimeout(() => {
|
|
770
|
+
const abort = new AbortController();
|
|
771
|
+
controller.current = abort;
|
|
772
|
+
const fail = () => {
|
|
773
|
+
if (ticket !== latest.current) return;
|
|
774
|
+
setResults([]);
|
|
775
|
+
setSearched(false);
|
|
776
|
+
setStatus("error");
|
|
777
|
+
setActiveIndex(-1);
|
|
778
|
+
};
|
|
779
|
+
Promise.resolve().then(() => search(trimmed, abort.signal)).then((items) => {
|
|
780
|
+
if (ticket !== latest.current) return;
|
|
781
|
+
if (!Array.isArray(items)) return fail();
|
|
782
|
+
setResults(items);
|
|
783
|
+
setSearched(true);
|
|
784
|
+
setStatus("idle");
|
|
785
|
+
setActiveIndex(items.length > 0 ? 0 : -1);
|
|
786
|
+
}).catch(fail);
|
|
787
|
+
}, debounceMs);
|
|
788
|
+
},
|
|
789
|
+
[cancelSearch, debounceMs, minChars, search]
|
|
790
|
+
);
|
|
791
|
+
const stopEditing = () => {
|
|
792
|
+
cancelSearch();
|
|
793
|
+
setEditing(false);
|
|
794
|
+
setOpen(false);
|
|
795
|
+
setText("");
|
|
796
|
+
setResults([]);
|
|
797
|
+
setStatus("idle");
|
|
798
|
+
setSearched(false);
|
|
799
|
+
setActiveIndex(-1);
|
|
800
|
+
};
|
|
801
|
+
const choose = (item) => {
|
|
802
|
+
selectAfterRender.current = { key: getKey(item) };
|
|
803
|
+
stopEditing();
|
|
804
|
+
onChange(item);
|
|
805
|
+
};
|
|
806
|
+
const showPopup = open && !disabled && (status !== "idle" || searched);
|
|
807
|
+
const showListbox = showPopup && results.length > 0;
|
|
808
|
+
const activeId = showListbox && activeIndex >= 0 ? `${listId}-opt-${activeIndex}` : void 0;
|
|
809
|
+
const announcement = !showPopup ? "" : status === "loading" ? loadingText : status === "error" ? errorText : results.length === 0 ? emptyText : "";
|
|
810
|
+
useEffect2(() => {
|
|
811
|
+
if (showListbox && activeIndex >= 0) listRef.current?.children[activeIndex]?.scrollIntoView?.({ block: "nearest" });
|
|
812
|
+
}, [showListbox, activeIndex]);
|
|
813
|
+
useEffect2(() => {
|
|
814
|
+
const pending = selectAfterRender.current;
|
|
815
|
+
if (!pending || editing) return;
|
|
816
|
+
if ((value ? getKey(value) : null) !== pending.key) return;
|
|
817
|
+
selectAfterRender.current = null;
|
|
818
|
+
if (document.activeElement === inputRef.current) inputRef.current?.select();
|
|
819
|
+
}, [value, editing, getKey]);
|
|
820
|
+
useEffect2(() => {
|
|
821
|
+
if (disabled) stopEditing();
|
|
822
|
+
}, [disabled]);
|
|
823
|
+
const onKeyDown = (event) => {
|
|
824
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
|
|
825
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
826
|
+
if (!showListbox || status === "loading") return;
|
|
827
|
+
event.preventDefault();
|
|
828
|
+
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
829
|
+
setActiveIndex((index) => (index + step + results.length) % results.length);
|
|
830
|
+
} else if (event.key === "Enter") {
|
|
831
|
+
if (!showPopup) return;
|
|
832
|
+
event.preventDefault();
|
|
833
|
+
if (status !== "loading" && activeIndex >= 0 && results[activeIndex]) choose(results[activeIndex]);
|
|
834
|
+
} else if (event.key === "Escape") {
|
|
835
|
+
if (open) {
|
|
836
|
+
event.preventDefault();
|
|
837
|
+
event.stopPropagation();
|
|
838
|
+
selectAfterRender.current = { key: value ? getKey(value) : null };
|
|
839
|
+
stopEditing();
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
const partProps = (key) => {
|
|
844
|
+
const className = classNames?.[key];
|
|
845
|
+
if (className) return { className, style: key === "root" ? style : void 0 };
|
|
846
|
+
return { style: key === "root" ? { ...defaults.root, ...style } : defaults[key] };
|
|
847
|
+
};
|
|
848
|
+
const optionProps = (active) => {
|
|
849
|
+
const optionClass = classNames?.option;
|
|
850
|
+
const activeClass = classNames?.optionActive;
|
|
851
|
+
const className = [optionClass, active ? activeClass : void 0].filter(Boolean).join(" ") || void 0;
|
|
852
|
+
return { className, style: optionClass ? void 0 : { ...optionDefaults.base, ...active && !activeClass ? optionDefaults.active : {} } };
|
|
853
|
+
};
|
|
854
|
+
const shown = editing ? text : value ? getLabel(value) : "";
|
|
855
|
+
return /* @__PURE__ */ jsxs4("div", { ...partProps("root"), children: [
|
|
856
|
+
/* @__PURE__ */ jsx5(
|
|
857
|
+
"input",
|
|
858
|
+
{
|
|
859
|
+
...partProps("input"),
|
|
860
|
+
ref: inputRef,
|
|
861
|
+
id,
|
|
862
|
+
type: "text",
|
|
863
|
+
role: "combobox",
|
|
864
|
+
"aria-label": ariaLabel,
|
|
865
|
+
"aria-expanded": showListbox,
|
|
866
|
+
"aria-controls": showListbox ? listId : void 0,
|
|
867
|
+
"aria-autocomplete": "list",
|
|
868
|
+
"aria-activedescendant": activeId,
|
|
869
|
+
autoComplete: "off",
|
|
870
|
+
placeholder,
|
|
871
|
+
disabled,
|
|
872
|
+
value: shown,
|
|
873
|
+
onChange: (event) => {
|
|
874
|
+
setEditing(true);
|
|
875
|
+
setText(event.target.value);
|
|
876
|
+
setOpen(true);
|
|
877
|
+
runSearch(event.target.value);
|
|
878
|
+
},
|
|
879
|
+
onKeyDown,
|
|
880
|
+
onFocus: (event) => {
|
|
881
|
+
if (!editing && value) event.target.select();
|
|
882
|
+
},
|
|
883
|
+
onBlur: () => {
|
|
884
|
+
if (document.hasFocus()) stopEditing();
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
),
|
|
888
|
+
name !== void 0 ? /* @__PURE__ */ jsx5("input", { type: "hidden", name, value: value ? getKey(value) : "", disabled }) : null,
|
|
889
|
+
clearable && value && !disabled ? /* @__PURE__ */ jsx5("button", { type: "button", "aria-label": clearLabel, ...partProps("clear"), onClick: () => {
|
|
890
|
+
onChange(null);
|
|
891
|
+
inputRef.current?.focus();
|
|
892
|
+
}, children: "\xD7" }) : null,
|
|
893
|
+
/* @__PURE__ */ jsx5("div", { role: "status", "aria-live": "polite", style: visuallyHidden, children: announcement }),
|
|
894
|
+
showPopup ? (
|
|
895
|
+
// mousedown anywhere in the popup (an option, the scrollbar, a message) must not move focus out of the input, or its
|
|
896
|
+
// blur would close the list before the click lands (and make a long list impossible to scroll by dragging)
|
|
897
|
+
/* @__PURE__ */ jsxs4("div", { ...partProps("list"), onMouseDown: (event) => event.preventDefault(), children: [
|
|
898
|
+
showListbox ? /* @__PURE__ */ jsx5("ul", { ref: listRef, id: listId, role: "listbox", "aria-label": ariaLabel, style: { listStyle: "none", margin: 0, padding: 0 }, children: results.map((item, index) => {
|
|
899
|
+
const active = index === activeIndex;
|
|
900
|
+
return /* @__PURE__ */ jsx5(
|
|
901
|
+
"li",
|
|
902
|
+
{
|
|
903
|
+
id: `${listId}-opt-${index}`,
|
|
904
|
+
role: "option",
|
|
905
|
+
"aria-selected": active,
|
|
906
|
+
...optionProps(active),
|
|
907
|
+
onClick: () => choose(item),
|
|
908
|
+
onMouseMove: () => {
|
|
909
|
+
if (status !== "loading" && index !== activeIndex) setActiveIndex(index);
|
|
910
|
+
},
|
|
911
|
+
children: renderOption ? renderOption(item, { active }) : getLabel(item)
|
|
912
|
+
},
|
|
913
|
+
getKey(item)
|
|
914
|
+
);
|
|
915
|
+
}) }) : null,
|
|
916
|
+
status === "loading" ? /* @__PURE__ */ jsx5("div", { "aria-hidden": "true", "data-entity-picker-message": "loading", ...partProps("message"), children: loadingText }) : null,
|
|
917
|
+
status === "error" ? /* @__PURE__ */ jsx5("div", { "aria-hidden": "true", "data-entity-picker-message": "error", ...partProps("message"), children: errorText }) : null,
|
|
918
|
+
status === "idle" && searched && results.length === 0 ? /* @__PURE__ */ jsx5("div", { "aria-hidden": "true", "data-entity-picker-message": "empty", ...partProps("message"), children: emptyText }) : null
|
|
919
|
+
] })
|
|
920
|
+
) : null
|
|
921
|
+
] });
|
|
922
|
+
}
|
|
923
|
+
|
|
696
924
|
// src/components/rich-text-editor.tsx
|
|
697
|
-
import { useCallback as
|
|
925
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
|
|
698
926
|
|
|
699
927
|
// src/components/rich-text-editor-styles.ts
|
|
700
928
|
var containerStyle = {
|
|
@@ -747,7 +975,7 @@ var editableStyle = {
|
|
|
747
975
|
};
|
|
748
976
|
|
|
749
977
|
// src/components/rich-text-editor.tsx
|
|
750
|
-
import { jsx as
|
|
978
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
751
979
|
var TOOLBAR_BUTTONS = [
|
|
752
980
|
{ command: "bold", label: "B", ariaLabel: "Bold" },
|
|
753
981
|
{ command: "italic", label: "I", ariaLabel: "Italic" },
|
|
@@ -779,26 +1007,26 @@ function RichTextEditor({
|
|
|
779
1007
|
className,
|
|
780
1008
|
style
|
|
781
1009
|
}) {
|
|
782
|
-
const editorRef =
|
|
783
|
-
const [isFocused, setIsFocused] =
|
|
784
|
-
const [isEmpty, setIsEmpty] =
|
|
785
|
-
const [linkError, setLinkError] =
|
|
786
|
-
|
|
1010
|
+
const editorRef = useRef3(null);
|
|
1011
|
+
const [isFocused, setIsFocused] = useState4(false);
|
|
1012
|
+
const [isEmpty, setIsEmpty] = useState4(isEmptyHtml(content));
|
|
1013
|
+
const [linkError, setLinkError] = useState4(null);
|
|
1014
|
+
useEffect3(() => {
|
|
787
1015
|
const el = editorRef.current;
|
|
788
1016
|
if (el && !isFocused && el.innerHTML !== content) {
|
|
789
1017
|
el.innerHTML = content;
|
|
790
1018
|
setIsEmpty(isEmptyHtml(content));
|
|
791
1019
|
}
|
|
792
1020
|
}, [content, isFocused, editable]);
|
|
793
|
-
|
|
1021
|
+
useEffect3(() => {
|
|
794
1022
|
if (autoFocus) editorRef.current?.focus();
|
|
795
1023
|
}, []);
|
|
796
|
-
const handleInput =
|
|
1024
|
+
const handleInput = useCallback3(() => {
|
|
797
1025
|
const html = editorRef.current?.innerHTML ?? "";
|
|
798
1026
|
setIsEmpty(isEmptyHtml(html));
|
|
799
1027
|
onChange(html);
|
|
800
1028
|
}, [onChange]);
|
|
801
|
-
const runCommand =
|
|
1029
|
+
const runCommand = useCallback3(
|
|
802
1030
|
(command, value) => {
|
|
803
1031
|
editorRef.current?.focus();
|
|
804
1032
|
document.execCommand(command, false, value);
|
|
@@ -806,7 +1034,7 @@ function RichTextEditor({
|
|
|
806
1034
|
},
|
|
807
1035
|
[handleInput]
|
|
808
1036
|
);
|
|
809
|
-
const handleLink =
|
|
1037
|
+
const handleLink = useCallback3(() => {
|
|
810
1038
|
const url = window.prompt("Link URL")?.trim();
|
|
811
1039
|
setLinkError(null);
|
|
812
1040
|
if (!url) return;
|
|
@@ -817,7 +1045,7 @@ function RichTextEditor({
|
|
|
817
1045
|
runCommand("createLink", url);
|
|
818
1046
|
}, [runCommand]);
|
|
819
1047
|
if (!editable) {
|
|
820
|
-
return /* @__PURE__ */
|
|
1048
|
+
return /* @__PURE__ */ jsx6(
|
|
821
1049
|
"div",
|
|
822
1050
|
{
|
|
823
1051
|
className: [className, "ordinatio-rte", "ordinatio-rte-readonly"].filter(Boolean).join(" "),
|
|
@@ -826,9 +1054,9 @@ function RichTextEditor({
|
|
|
826
1054
|
}
|
|
827
1055
|
);
|
|
828
1056
|
}
|
|
829
|
-
return /* @__PURE__ */
|
|
830
|
-
/* @__PURE__ */
|
|
831
|
-
TOOLBAR_BUTTONS.map((btn) => /* @__PURE__ */
|
|
1057
|
+
return /* @__PURE__ */ jsxs5("div", { className: [className, "ordinatio-rte"].filter(Boolean).join(" "), style: className ? style : { ...containerStyle, ...style }, children: [
|
|
1058
|
+
/* @__PURE__ */ jsxs5("div", { className: "ordinatio-rte-toolbar", style: toolbarStyle, children: [
|
|
1059
|
+
TOOLBAR_BUTTONS.map((btn) => /* @__PURE__ */ jsx6(
|
|
832
1060
|
"button",
|
|
833
1061
|
{
|
|
834
1062
|
type: "button",
|
|
@@ -842,7 +1070,7 @@ function RichTextEditor({
|
|
|
842
1070
|
},
|
|
843
1071
|
btn.command
|
|
844
1072
|
)),
|
|
845
|
-
/* @__PURE__ */
|
|
1073
|
+
/* @__PURE__ */ jsx6(
|
|
846
1074
|
"button",
|
|
847
1075
|
{
|
|
848
1076
|
type: "button",
|
|
@@ -855,10 +1083,10 @@ function RichTextEditor({
|
|
|
855
1083
|
children: "\u{1F517}"
|
|
856
1084
|
}
|
|
857
1085
|
),
|
|
858
|
-
toolbarRight ? /* @__PURE__ */
|
|
1086
|
+
toolbarRight ? /* @__PURE__ */ jsx6("div", { className: "ordinatio-rte-toolbar-right", style: toolbarRightStyle, children: toolbarRight }) : null
|
|
859
1087
|
] }),
|
|
860
|
-
linkError ? /* @__PURE__ */
|
|
861
|
-
/* @__PURE__ */
|
|
1088
|
+
linkError ? /* @__PURE__ */ jsx6("div", { className: "ordinatio-rte-link-error", role: "alert", style: linkErrorStyle, children: linkError }) : null,
|
|
1089
|
+
/* @__PURE__ */ jsxs5("div", { className: "ordinatio-rte-editable-wrap", style: { position: "relative" }, children: [
|
|
862
1090
|
isEmpty ? (
|
|
863
1091
|
// Shown while empty REGARDLESS of focus — WorldClass cycle 1:
|
|
864
1092
|
// the prior `isEmpty && !isFocused` condition hid the
|
|
@@ -867,7 +1095,7 @@ function RichTextEditor({
|
|
|
867
1095
|
// the click landed. Matches native `<textarea placeholder>`
|
|
868
1096
|
// behavior (visible while focused-and-empty, removed only once
|
|
869
1097
|
// the user types).
|
|
870
|
-
/* @__PURE__ */
|
|
1098
|
+
/* @__PURE__ */ jsx6(
|
|
871
1099
|
"div",
|
|
872
1100
|
{
|
|
873
1101
|
"aria-hidden": "true",
|
|
@@ -877,7 +1105,7 @@ function RichTextEditor({
|
|
|
877
1105
|
}
|
|
878
1106
|
)
|
|
879
1107
|
) : null,
|
|
880
|
-
/* @__PURE__ */
|
|
1108
|
+
/* @__PURE__ */ jsx6(
|
|
881
1109
|
"div",
|
|
882
1110
|
{
|
|
883
1111
|
ref: editorRef,
|
|
@@ -899,7 +1127,7 @@ function RichTextEditor({
|
|
|
899
1127
|
}
|
|
900
1128
|
|
|
901
1129
|
// src/components/reply-panel.tsx
|
|
902
|
-
import { useEffect as
|
|
1130
|
+
import { useEffect as useEffect4, useId as useId2, useRef as useRef4, useState as useState5 } from "react";
|
|
903
1131
|
|
|
904
1132
|
// src/components/subject-prefix.ts
|
|
905
1133
|
function prefixSubject(subject, mode) {
|
|
@@ -989,7 +1217,7 @@ var disabledButtonStyle = {
|
|
|
989
1217
|
};
|
|
990
1218
|
|
|
991
1219
|
// src/components/reply-panel.tsx
|
|
992
|
-
import { Fragment as Fragment2, jsx as
|
|
1220
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
993
1221
|
function ReplyPanel({
|
|
994
1222
|
mode = "reply",
|
|
995
1223
|
subject,
|
|
@@ -1008,22 +1236,22 @@ function ReplyPanel({
|
|
|
1008
1236
|
}) {
|
|
1009
1237
|
const defaultTo = mode === "reply" ? toEmail || toName : "";
|
|
1010
1238
|
const defaultSubject = prefixSubject(subject, mode);
|
|
1011
|
-
const idPrefix =
|
|
1239
|
+
const idPrefix = useId2();
|
|
1012
1240
|
const toId = `${idPrefix}-to`;
|
|
1013
1241
|
const ccId = `${idPrefix}-cc`;
|
|
1014
1242
|
const bccId = `${idPrefix}-bcc`;
|
|
1015
1243
|
const subjectId = `${idPrefix}-subject`;
|
|
1016
|
-
const [to, setTo] =
|
|
1017
|
-
const [cc, setCc] =
|
|
1018
|
-
const [bcc, setBcc] =
|
|
1019
|
-
const [showCcBcc, setShowCcBcc] =
|
|
1020
|
-
const [editedSubject, setEditedSubject] =
|
|
1021
|
-
const [body, setBody] =
|
|
1022
|
-
const [sending, setSending] =
|
|
1023
|
-
const [error, setError] =
|
|
1024
|
-
const [sent, setSent] =
|
|
1025
|
-
const isMountedRef =
|
|
1026
|
-
|
|
1244
|
+
const [to, setTo] = useState5(defaultTo);
|
|
1245
|
+
const [cc, setCc] = useState5(initialCc);
|
|
1246
|
+
const [bcc, setBcc] = useState5("");
|
|
1247
|
+
const [showCcBcc, setShowCcBcc] = useState5(initialShowCcBcc || !!initialCc);
|
|
1248
|
+
const [editedSubject, setEditedSubject] = useState5(defaultSubject);
|
|
1249
|
+
const [body, setBody] = useState5(initialBody);
|
|
1250
|
+
const [sending, setSending] = useState5(false);
|
|
1251
|
+
const [error, setError] = useState5(null);
|
|
1252
|
+
const [sent, setSent] = useState5(false);
|
|
1253
|
+
const isMountedRef = useRef4(true);
|
|
1254
|
+
useEffect4(() => {
|
|
1027
1255
|
isMountedRef.current = true;
|
|
1028
1256
|
return () => {
|
|
1029
1257
|
isMountedRef.current = false;
|
|
@@ -1068,16 +1296,16 @@ function ReplyPanel({
|
|
|
1068
1296
|
if (isMountedRef.current) setSending(false);
|
|
1069
1297
|
}
|
|
1070
1298
|
};
|
|
1071
|
-
return /* @__PURE__ */
|
|
1299
|
+
return /* @__PURE__ */ jsxs6(
|
|
1072
1300
|
"div",
|
|
1073
1301
|
{
|
|
1074
1302
|
className: [className, "ordinatio-reply-panel"].filter(Boolean).join(" "),
|
|
1075
1303
|
style: className ? style : { display: "flex", flexDirection: "column", gap: "8px", ...style },
|
|
1076
1304
|
children: [
|
|
1077
|
-
/* @__PURE__ */
|
|
1078
|
-
/* @__PURE__ */
|
|
1079
|
-
/* @__PURE__ */
|
|
1080
|
-
/* @__PURE__ */
|
|
1305
|
+
/* @__PURE__ */ jsxs6("div", { className: "ordinatio-reply-fields", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
1306
|
+
/* @__PURE__ */ jsxs6("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1307
|
+
/* @__PURE__ */ jsx7("label", { htmlFor: toId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "To" }),
|
|
1308
|
+
/* @__PURE__ */ jsx7(
|
|
1081
1309
|
"input",
|
|
1082
1310
|
{
|
|
1083
1311
|
id: toId,
|
|
@@ -1105,7 +1333,7 @@ function ReplyPanel({
|
|
|
1105
1333
|
// and aria-controls referenced ids (ccId/bccId) that don't
|
|
1106
1334
|
// exist in the DOM until AFTER this button has already
|
|
1107
1335
|
// unmounted. A one-directional reveal, not a toggle.
|
|
1108
|
-
/* @__PURE__ */
|
|
1336
|
+
/* @__PURE__ */ jsx7(
|
|
1109
1337
|
"button",
|
|
1110
1338
|
{
|
|
1111
1339
|
type: "button",
|
|
@@ -1118,10 +1346,10 @@ function ReplyPanel({
|
|
|
1118
1346
|
)
|
|
1119
1347
|
) : null
|
|
1120
1348
|
] }),
|
|
1121
|
-
showCcBcc ? /* @__PURE__ */
|
|
1122
|
-
/* @__PURE__ */
|
|
1123
|
-
/* @__PURE__ */
|
|
1124
|
-
/* @__PURE__ */
|
|
1349
|
+
showCcBcc ? /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
1350
|
+
/* @__PURE__ */ jsxs6("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1351
|
+
/* @__PURE__ */ jsx7("label", { htmlFor: ccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Cc" }),
|
|
1352
|
+
/* @__PURE__ */ jsx7(
|
|
1125
1353
|
"input",
|
|
1126
1354
|
{
|
|
1127
1355
|
id: ccId,
|
|
@@ -1139,9 +1367,9 @@ function ReplyPanel({
|
|
|
1139
1367
|
}
|
|
1140
1368
|
)
|
|
1141
1369
|
] }),
|
|
1142
|
-
/* @__PURE__ */
|
|
1143
|
-
/* @__PURE__ */
|
|
1144
|
-
/* @__PURE__ */
|
|
1370
|
+
/* @__PURE__ */ jsxs6("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1371
|
+
/* @__PURE__ */ jsx7("label", { htmlFor: bccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Bcc" }),
|
|
1372
|
+
/* @__PURE__ */ jsx7(
|
|
1145
1373
|
"input",
|
|
1146
1374
|
{
|
|
1147
1375
|
id: bccId,
|
|
@@ -1160,9 +1388,9 @@ function ReplyPanel({
|
|
|
1160
1388
|
)
|
|
1161
1389
|
] })
|
|
1162
1390
|
] }) : null,
|
|
1163
|
-
/* @__PURE__ */
|
|
1164
|
-
/* @__PURE__ */
|
|
1165
|
-
/* @__PURE__ */
|
|
1391
|
+
/* @__PURE__ */ jsxs6("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1392
|
+
/* @__PURE__ */ jsx7("label", { htmlFor: subjectId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Subject" }),
|
|
1393
|
+
/* @__PURE__ */ jsx7(
|
|
1166
1394
|
"input",
|
|
1167
1395
|
{
|
|
1168
1396
|
id: subjectId,
|
|
@@ -1181,9 +1409,9 @@ function ReplyPanel({
|
|
|
1181
1409
|
)
|
|
1182
1410
|
] })
|
|
1183
1411
|
] }),
|
|
1184
|
-
error ? /* @__PURE__ */
|
|
1185
|
-
sent && resolvedSuccessMessage ? /* @__PURE__ */
|
|
1186
|
-
/* @__PURE__ */
|
|
1412
|
+
error ? /* @__PURE__ */ jsx7("div", { className: "ordinatio-reply-error", role: "alert", style: errorStyle, children: error }) : null,
|
|
1413
|
+
sent && resolvedSuccessMessage ? /* @__PURE__ */ jsx7("div", { className: "ordinatio-reply-success", role: "status", style: successStyle, children: resolvedSuccessMessage }) : null,
|
|
1414
|
+
/* @__PURE__ */ jsx7(
|
|
1187
1415
|
RichTextEditor,
|
|
1188
1416
|
{
|
|
1189
1417
|
content: body,
|
|
@@ -1197,8 +1425,8 @@ function ReplyPanel({
|
|
|
1197
1425
|
locked: sending
|
|
1198
1426
|
}
|
|
1199
1427
|
),
|
|
1200
|
-
/* @__PURE__ */
|
|
1201
|
-
showCancel && onCancel ? /* @__PURE__ */
|
|
1428
|
+
/* @__PURE__ */ jsxs6("div", { className: "ordinatio-reply-actions", style: actionsRowStyle, children: [
|
|
1429
|
+
showCancel && onCancel ? /* @__PURE__ */ jsx7(
|
|
1202
1430
|
"button",
|
|
1203
1431
|
{
|
|
1204
1432
|
type: "button",
|
|
@@ -1209,7 +1437,7 @@ function ReplyPanel({
|
|
|
1209
1437
|
children: "Cancel"
|
|
1210
1438
|
}
|
|
1211
1439
|
) : null,
|
|
1212
|
-
/* @__PURE__ */
|
|
1440
|
+
/* @__PURE__ */ jsx7(
|
|
1213
1441
|
"button",
|
|
1214
1442
|
{
|
|
1215
1443
|
type: "button",
|
|
@@ -1227,7 +1455,7 @@ function ReplyPanel({
|
|
|
1227
1455
|
}
|
|
1228
1456
|
|
|
1229
1457
|
// src/hooks/use-keyboard-shortcuts.ts
|
|
1230
|
-
import { useEffect as
|
|
1458
|
+
import { useEffect as useEffect5, useCallback as useCallback4 } from "react";
|
|
1231
1459
|
|
|
1232
1460
|
// src/hooks/is-typing-context.ts
|
|
1233
1461
|
var TYPING_TAG_RE = /^(INPUT|TEXTAREA|SELECT)$/;
|
|
@@ -1252,14 +1480,14 @@ function useKeyboardShortcuts({
|
|
|
1252
1480
|
ignoreTags = []
|
|
1253
1481
|
}) {
|
|
1254
1482
|
const malformed = !Array.isArray(shortcuts);
|
|
1255
|
-
|
|
1483
|
+
useEffect5(() => {
|
|
1256
1484
|
if (malformed) {
|
|
1257
1485
|
console.error(
|
|
1258
1486
|
"[useKeyboardShortcuts] expected { shortcuts: KeyboardShortcut[] } \u2014 got a non-array `shortcuts` (legacy array call form?). All shortcuts for this caller are disabled until the call is fixed."
|
|
1259
1487
|
);
|
|
1260
1488
|
}
|
|
1261
1489
|
}, [malformed]);
|
|
1262
|
-
const handleKeyDown =
|
|
1490
|
+
const handleKeyDown = useCallback4(
|
|
1263
1491
|
(e) => {
|
|
1264
1492
|
if (!enabled || malformed) return;
|
|
1265
1493
|
if (e.isComposing || e.keyCode === 229) return;
|
|
@@ -1287,7 +1515,7 @@ function useKeyboardShortcuts({
|
|
|
1287
1515
|
},
|
|
1288
1516
|
[shortcuts, enabled, ignoreTags, malformed]
|
|
1289
1517
|
);
|
|
1290
|
-
|
|
1518
|
+
useEffect5(() => {
|
|
1291
1519
|
window.addEventListener("keydown", handleKeyDown);
|
|
1292
1520
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1293
1521
|
}, [handleKeyDown]);
|
|
@@ -1457,13 +1685,13 @@ function getShortcut(context, action) {
|
|
|
1457
1685
|
}
|
|
1458
1686
|
|
|
1459
1687
|
// src/components/keyboard-shortcuts-panel.tsx
|
|
1460
|
-
import { useEffect as
|
|
1461
|
-
import { Fragment as Fragment3, jsx as
|
|
1688
|
+
import { useEffect as useEffect6, useState as useState6 } from "react";
|
|
1689
|
+
import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1462
1690
|
function KeyboardShortcutsPanel({
|
|
1463
1691
|
contexts = ALL_SHORTCUT_CONTEXTS
|
|
1464
1692
|
}) {
|
|
1465
|
-
const [open, setOpen] =
|
|
1466
|
-
|
|
1693
|
+
const [open, setOpen] = useState6(false);
|
|
1694
|
+
useEffect6(() => {
|
|
1467
1695
|
function handleKey(e) {
|
|
1468
1696
|
if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
|
1469
1697
|
const tag = e.target?.tagName;
|
|
@@ -1480,33 +1708,33 @@ function KeyboardShortcutsPanel({
|
|
|
1480
1708
|
return () => window.removeEventListener("keydown", handleKey);
|
|
1481
1709
|
}, [open]);
|
|
1482
1710
|
if (!open) return null;
|
|
1483
|
-
return /* @__PURE__ */
|
|
1484
|
-
/* @__PURE__ */
|
|
1711
|
+
return /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
1712
|
+
/* @__PURE__ */ jsx8(
|
|
1485
1713
|
"div",
|
|
1486
1714
|
{
|
|
1487
1715
|
className: "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",
|
|
1488
1716
|
onClick: () => setOpen(false)
|
|
1489
1717
|
}
|
|
1490
1718
|
),
|
|
1491
|
-
/* @__PURE__ */
|
|
1492
|
-
/* @__PURE__ */
|
|
1493
|
-
/* @__PURE__ */
|
|
1494
|
-
/* @__PURE__ */
|
|
1719
|
+
/* @__PURE__ */ jsx8("div", { className: "fixed inset-x-0 top-[10%] z-50 mx-auto w-full max-w-lg", children: /* @__PURE__ */ jsxs7("div", { className: "rounded-xl border bg-background shadow-2xl overflow-hidden", children: [
|
|
1720
|
+
/* @__PURE__ */ jsxs7("div", { className: "px-6 py-4 border-b", children: [
|
|
1721
|
+
/* @__PURE__ */ jsx8("h2", { className: "text-lg font-semibold", children: "Keyboard Shortcuts" }),
|
|
1722
|
+
/* @__PURE__ */ jsxs7("p", { className: "text-sm text-muted-foreground mt-0.5", children: [
|
|
1495
1723
|
"Press ",
|
|
1496
|
-
/* @__PURE__ */
|
|
1724
|
+
/* @__PURE__ */ jsx8("kbd", { className: "px-1.5 py-0.5 bg-muted rounded text-xs font-mono", children: "?" }),
|
|
1497
1725
|
" to toggle this panel"
|
|
1498
1726
|
] })
|
|
1499
1727
|
] }),
|
|
1500
|
-
/* @__PURE__ */
|
|
1501
|
-
/* @__PURE__ */
|
|
1502
|
-
/* @__PURE__ */
|
|
1503
|
-
/* @__PURE__ */
|
|
1504
|
-
/* @__PURE__ */
|
|
1728
|
+
/* @__PURE__ */ jsx8("div", { className: "px-6 py-4 max-h-[60vh] overflow-y-auto space-y-6", children: contexts.map((ctx) => /* @__PURE__ */ jsxs7("div", { children: [
|
|
1729
|
+
/* @__PURE__ */ jsx8("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: ctx.label }),
|
|
1730
|
+
/* @__PURE__ */ jsx8("div", { className: "space-y-1", children: Object.entries(ctx.shortcuts).map(([key, def]) => /* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between py-1", children: [
|
|
1731
|
+
/* @__PURE__ */ jsx8("span", { className: "text-sm", children: def.description }),
|
|
1732
|
+
/* @__PURE__ */ jsx8("kbd", { className: "px-2 py-0.5 bg-muted rounded text-xs font-mono min-w-[2rem] text-center", children: def.display })
|
|
1505
1733
|
] }, key)) })
|
|
1506
1734
|
] }, ctx.name)) }),
|
|
1507
|
-
/* @__PURE__ */
|
|
1735
|
+
/* @__PURE__ */ jsxs7("div", { className: "px-6 py-3 border-t bg-muted/30 text-xs text-muted-foreground text-center", children: [
|
|
1508
1736
|
"Press ",
|
|
1509
|
-
/* @__PURE__ */
|
|
1737
|
+
/* @__PURE__ */ jsx8("kbd", { className: "px-1 py-0.5 bg-muted rounded", children: "Esc" }),
|
|
1510
1738
|
" to close"
|
|
1511
1739
|
] })
|
|
1512
1740
|
] }) })
|
|
@@ -1514,21 +1742,21 @@ function KeyboardShortcutsPanel({
|
|
|
1514
1742
|
}
|
|
1515
1743
|
|
|
1516
1744
|
// src/hooks/use-auto-save.ts
|
|
1517
|
-
import { useEffect as
|
|
1745
|
+
import { useEffect as useEffect7, useRef as useRef5, useCallback as useCallback5, useState as useState7 } from "react";
|
|
1518
1746
|
function useAutoSave({
|
|
1519
1747
|
data,
|
|
1520
1748
|
onSave,
|
|
1521
1749
|
delay = 5e3,
|
|
1522
1750
|
enabled = true
|
|
1523
1751
|
}) {
|
|
1524
|
-
const [lastSavedAt, setLastSavedAt] =
|
|
1525
|
-
const [isSaving, setIsSaving] =
|
|
1526
|
-
const [saveError, setSaveError] =
|
|
1527
|
-
const timerRef =
|
|
1528
|
-
const dataRef =
|
|
1529
|
-
const savedDataRef =
|
|
1752
|
+
const [lastSavedAt, setLastSavedAt] = useState7(null);
|
|
1753
|
+
const [isSaving, setIsSaving] = useState7(false);
|
|
1754
|
+
const [saveError, setSaveError] = useState7(null);
|
|
1755
|
+
const timerRef = useRef5(null);
|
|
1756
|
+
const dataRef = useRef5(data);
|
|
1757
|
+
const savedDataRef = useRef5(null);
|
|
1530
1758
|
dataRef.current = data;
|
|
1531
|
-
const save =
|
|
1759
|
+
const save = useCallback5(async () => {
|
|
1532
1760
|
const currentJson = JSON.stringify(dataRef.current);
|
|
1533
1761
|
if (currentJson === savedDataRef.current) return;
|
|
1534
1762
|
setIsSaving(true);
|
|
@@ -1543,7 +1771,7 @@ function useAutoSave({
|
|
|
1543
1771
|
setIsSaving(false);
|
|
1544
1772
|
}
|
|
1545
1773
|
}, [onSave]);
|
|
1546
|
-
|
|
1774
|
+
useEffect7(() => {
|
|
1547
1775
|
if (!enabled) return;
|
|
1548
1776
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
1549
1777
|
timerRef.current = setTimeout(save, delay);
|
|
@@ -1555,19 +1783,19 @@ function useAutoSave({
|
|
|
1555
1783
|
}
|
|
1556
1784
|
|
|
1557
1785
|
// src/hooks/use-polling.ts
|
|
1558
|
-
import { useEffect as
|
|
1786
|
+
import { useEffect as useEffect8, useCallback as useCallback6, useRef as useRef6, useState as useState8 } from "react";
|
|
1559
1787
|
function usePolling({
|
|
1560
1788
|
fetcher,
|
|
1561
1789
|
interval = 3e4,
|
|
1562
1790
|
enabled = true,
|
|
1563
1791
|
onError
|
|
1564
1792
|
}) {
|
|
1565
|
-
const [data, setData] =
|
|
1566
|
-
const [isLoading, setIsLoading] =
|
|
1567
|
-
const [isRefreshing, setIsRefreshing] =
|
|
1568
|
-
const [error, setError] =
|
|
1569
|
-
const mountedRef =
|
|
1570
|
-
const doFetch =
|
|
1793
|
+
const [data, setData] = useState8(null);
|
|
1794
|
+
const [isLoading, setIsLoading] = useState8(true);
|
|
1795
|
+
const [isRefreshing, setIsRefreshing] = useState8(false);
|
|
1796
|
+
const [error, setError] = useState8(null);
|
|
1797
|
+
const mountedRef = useRef6(true);
|
|
1798
|
+
const doFetch = useCallback6(async (isInitial = false) => {
|
|
1571
1799
|
if (isInitial) setIsLoading(true);
|
|
1572
1800
|
else setIsRefreshing(true);
|
|
1573
1801
|
try {
|
|
@@ -1588,36 +1816,36 @@ function usePolling({
|
|
|
1588
1816
|
}
|
|
1589
1817
|
}
|
|
1590
1818
|
}, [fetcher, onError]);
|
|
1591
|
-
|
|
1819
|
+
useEffect8(() => {
|
|
1592
1820
|
mountedRef.current = true;
|
|
1593
1821
|
if (enabled) doFetch(true);
|
|
1594
1822
|
return () => {
|
|
1595
1823
|
mountedRef.current = false;
|
|
1596
1824
|
};
|
|
1597
1825
|
}, [doFetch, enabled]);
|
|
1598
|
-
|
|
1826
|
+
useEffect8(() => {
|
|
1599
1827
|
if (!enabled) return;
|
|
1600
1828
|
const timer = setInterval(() => doFetch(false), interval);
|
|
1601
1829
|
return () => clearInterval(timer);
|
|
1602
1830
|
}, [doFetch, interval, enabled]);
|
|
1603
|
-
const refresh =
|
|
1831
|
+
const refresh = useCallback6(() => doFetch(false), [doFetch]);
|
|
1604
1832
|
return { data, isLoading, isRefreshing, error, refresh };
|
|
1605
1833
|
}
|
|
1606
1834
|
|
|
1607
1835
|
// src/hooks/use-server-search.ts
|
|
1608
|
-
import { useEffect as
|
|
1836
|
+
import { useEffect as useEffect9, useRef as useRef7, useState as useState9, useCallback as useCallback7 } from "react";
|
|
1609
1837
|
function useServerSearch({
|
|
1610
1838
|
fetcher,
|
|
1611
1839
|
debounce = 150,
|
|
1612
1840
|
minChars = 1,
|
|
1613
1841
|
enabled = true
|
|
1614
1842
|
}) {
|
|
1615
|
-
const [query, setQuery] =
|
|
1616
|
-
const [results, setResults] =
|
|
1617
|
-
const [isSearching, setIsSearching] =
|
|
1618
|
-
const [isOpen, setIsOpen] =
|
|
1619
|
-
const timerRef =
|
|
1620
|
-
|
|
1843
|
+
const [query, setQuery] = useState9("");
|
|
1844
|
+
const [results, setResults] = useState9([]);
|
|
1845
|
+
const [isSearching, setIsSearching] = useState9(false);
|
|
1846
|
+
const [isOpen, setIsOpen] = useState9(false);
|
|
1847
|
+
const timerRef = useRef7(null);
|
|
1848
|
+
useEffect9(() => {
|
|
1621
1849
|
if (!enabled || query.length < minChars) {
|
|
1622
1850
|
setResults([]);
|
|
1623
1851
|
return;
|
|
@@ -1638,7 +1866,7 @@ function useServerSearch({
|
|
|
1638
1866
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
1639
1867
|
};
|
|
1640
1868
|
}, [query, fetcher, debounce, minChars, enabled]);
|
|
1641
|
-
const clear =
|
|
1869
|
+
const clear = useCallback7(() => {
|
|
1642
1870
|
setQuery("");
|
|
1643
1871
|
setResults([]);
|
|
1644
1872
|
setIsOpen(false);
|
|
@@ -1647,9 +1875,9 @@ function useServerSearch({
|
|
|
1647
1875
|
}
|
|
1648
1876
|
|
|
1649
1877
|
// src/hooks/use-iframe-focus-reclaim.ts
|
|
1650
|
-
import { useEffect as
|
|
1878
|
+
import { useEffect as useEffect10 } from "react";
|
|
1651
1879
|
function useIframeFocusReclaim(containerRef, enabled = true, iframeSelector = "iframe") {
|
|
1652
|
-
|
|
1880
|
+
useEffect10(() => {
|
|
1653
1881
|
if (!enabled) return;
|
|
1654
1882
|
const el = containerRef.current;
|
|
1655
1883
|
if (!el) return;
|
|
@@ -1830,21 +2058,21 @@ function clearCache() {
|
|
|
1830
2058
|
}
|
|
1831
2059
|
|
|
1832
2060
|
// src/hooks/use-preferences.ts
|
|
1833
|
-
import { useState as
|
|
2061
|
+
import { useState as useState10, useEffect as useEffect11, useCallback as useCallback8 } from "react";
|
|
1834
2062
|
function usePreferences({
|
|
1835
2063
|
endpoint,
|
|
1836
|
-
defaults
|
|
2064
|
+
defaults: defaults2
|
|
1837
2065
|
}) {
|
|
1838
|
-
const [preferences, setPreferences] =
|
|
1839
|
-
const [loading, setLoading] =
|
|
1840
|
-
const [error, setError] =
|
|
1841
|
-
const fetchPreferences =
|
|
2066
|
+
const [preferences, setPreferences] = useState10(defaults2 ?? null);
|
|
2067
|
+
const [loading, setLoading] = useState10(true);
|
|
2068
|
+
const [error, setError] = useState10(null);
|
|
2069
|
+
const fetchPreferences = useCallback8(async () => {
|
|
1842
2070
|
try {
|
|
1843
2071
|
setError(null);
|
|
1844
2072
|
const res = await fetch(endpoint);
|
|
1845
2073
|
if (!res.ok) {
|
|
1846
2074
|
if (res.status === 401) {
|
|
1847
|
-
setPreferences(
|
|
2075
|
+
setPreferences(defaults2 ?? null);
|
|
1848
2076
|
return;
|
|
1849
2077
|
}
|
|
1850
2078
|
throw new Error("Failed to fetch preferences");
|
|
@@ -1856,11 +2084,11 @@ function usePreferences({
|
|
|
1856
2084
|
} finally {
|
|
1857
2085
|
setLoading(false);
|
|
1858
2086
|
}
|
|
1859
|
-
}, [endpoint,
|
|
1860
|
-
|
|
2087
|
+
}, [endpoint, defaults2]);
|
|
2088
|
+
useEffect11(() => {
|
|
1861
2089
|
fetchPreferences();
|
|
1862
2090
|
}, [fetchPreferences]);
|
|
1863
|
-
const updatePreferences =
|
|
2091
|
+
const updatePreferences = useCallback8(
|
|
1864
2092
|
async (updates) => {
|
|
1865
2093
|
setPreferences((prev) => prev ? { ...prev, ...updates } : updates);
|
|
1866
2094
|
setError(null);
|
|
@@ -2218,6 +2446,7 @@ export {
|
|
|
2218
2446
|
CLIENT_PROFILE_SHORTCUTS,
|
|
2219
2447
|
EmailBodyRenderer,
|
|
2220
2448
|
EmailThreadView,
|
|
2449
|
+
EntityPicker,
|
|
2221
2450
|
ErrorBoundary,
|
|
2222
2451
|
FORM_SHORTCUTS,
|
|
2223
2452
|
GLOBAL_SHORTCUTS,
|