@ordinatio/ui 1.4.0 → 1.6.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 +63 -0
- package/dist/index.d.mts +97 -2
- package/dist/index.mjs +326 -141
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -180,6 +180,69 @@ import { EntityPicker } from '@ordinatio/ui';
|
|
|
180
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
181
|
- Nothing outlives the component: an unmounted picker cancels its timer and aborts its request.
|
|
182
182
|
|
|
183
|
+
### `<ConfirmAction>`
|
|
184
|
+
|
|
185
|
+
An "Are you sure?" that stays **inside the page**: no browser pop-up (`confirm()`, `alert()`, `prompt()`), so it can be styled, tested and driven by automation. One button opens a question with two buttons; the safe one is focused.
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import { ConfirmAction } from '@ordinatio/ui';
|
|
189
|
+
|
|
190
|
+
<ConfirmAction
|
|
191
|
+
triggerLabel="Delete"
|
|
192
|
+
question={'Delete this note?\n\nThis cannot be undone.'} // line breaks are kept; any React content works
|
|
193
|
+
confirmLabel="Delete this note"
|
|
194
|
+
pendingLabel="Deleting…"
|
|
195
|
+
keepLabel="Keep it" // optional, the default
|
|
196
|
+
onConfirm={async () => { // must return a Promise (use an async function)
|
|
197
|
+
const result = await deleteNote(id); // RETURN errors: { error: 'Could not delete.' } stays open with the message
|
|
198
|
+
return result.ok ? undefined : { error: result.message }; // any object without `error` (for example { ok: true }) counts as success
|
|
199
|
+
}}
|
|
200
|
+
/>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Behaviour**
|
|
204
|
+
- Nothing runs until the confirm button is pressed. The question opens in place (`role="group"`), focus goes to the **safe** button, and again after a failed confirm (a disabled button loses focus, so Escape would otherwise be dead).
|
|
205
|
+
- Escape and the safe button close it, call nothing and give focus back to the trigger. Escape is never passed on to an enclosing dialog (one key closes only this question; while the action runs it closes nothing but still does not reach the dialog).
|
|
206
|
+
- While the action runs, focus is held on the group itself, so Escape is still caught here even if the browser drops focus from the disabled buttons.
|
|
207
|
+
- Results: return nothing, or an object. Only an object whose `error` is a non-empty string is a failure (anything else, such as `{ ok: true }` or a non-text `error`, is success). Use a type alias or an object literal for the result type: a TypeScript `interface` does not satisfy the open index signature.
|
|
208
|
+
- On success it closes, and focus goes back to the trigger only if nothing has taken it (the row is usually removed or the caller moves focus): focus the caller moved is left alone.
|
|
209
|
+
- The confirm button is disabled and shows `pendingLabel` while the action runs; two clicks in the same batch run it **once** (an in-flight ref, since React has not re-rendered between them).
|
|
210
|
+
- `{ error }` keeps the question open with the message in a `role="alert"`. A thrown rejection shows `errorFallback` (default "Something went wrong. Please try again.") instead of hanging open. Success closes it.
|
|
211
|
+
- `disabled` disables the trigger only (an open question stays answerable). `groupLabel` names the open group (default: the question itself, through `aria-labelledby`, whatever React content it is). A state update after the component unmounted (the row was removed) is harmless on React 18 and later, the package's peer range.
|
|
212
|
+
|
|
213
|
+
**Styling**: plain elements with default inline styles. `classNames.<part>` (`trigger`, `group`, `question`, `confirm`, `keep`, `error`) REPLACES that part's defaults entirely, so Tailwind or shadcn consumers restyle everything (including the pending look of the buttons: style `:disabled`).
|
|
214
|
+
|
|
215
|
+
### `ActivityFeedRow`
|
|
216
|
+
|
|
217
|
+
One line of an activity feed that is clickable and readable at a glance. Presentation only: it knows no routes, no database and no framework. The app decides where a line goes (`href`), what else is involved (`chips`), and which tags the thing has now (`tags`).
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
import Link from 'next/link';
|
|
221
|
+
import { ActivityFeedRow } from '@ordinatio/ui';
|
|
222
|
+
|
|
223
|
+
<ul>
|
|
224
|
+
<ActivityFeedRow
|
|
225
|
+
sentence="Max added a note to Ann Lee"
|
|
226
|
+
time={entry.createdAt}
|
|
227
|
+
href="/people/p1?note=n9"
|
|
228
|
+
chips={[{ label: 'Ann Lee', href: '/people/p1', kind: 'Person' }]}
|
|
229
|
+
tags={[{ label: 'Hot', href: '/tags/t1', kind: 'Tag' }]}
|
|
230
|
+
actions={<button type="button">Show full note</button>}
|
|
231
|
+
LinkComponent={Link}
|
|
232
|
+
/>
|
|
233
|
+
<ActivityFeedRow sentence="Max deleted Ann Lee" time={t} gone="Person removed" />
|
|
234
|
+
</ul>
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Structure (each point is a test):
|
|
238
|
+
- The `<li>` is the row. The sentence is the one link assistive technology reads; its accessible name is the sentence only.
|
|
239
|
+
- The whole row is clickable through an empty, `aria-hidden`, unfocusable anchor stretched over the row. It is a sibling of everything else: no anchor or button is ever inside an anchor.
|
|
240
|
+
- Chips, tag chips and `actions` are siblings stacked above that overlay (`position: relative; z-index: 1`), so clicking one does not follow the row's link. jsdom cannot test stacking: check it once in a real browser.
|
|
241
|
+
- Tab order: the sentence, then the chips, then the actions. The time is a `<time datetime>`.
|
|
242
|
+
- No `href`: a plain row (no link, no overlay, no arrow). `gone="Person removed"`: shows that word (never colour alone), no link, no chips; `actions` stay (a Resolve button).
|
|
243
|
+
- Tags: at most `maxTags` (default 3) then a plain "+N"; the "Tags now" label (`tagsLabel`) shows only when a tag chip shows.
|
|
244
|
+
- `classNames.<part>` REPLACES that part's look (the structural positioning and stacking stay inline). Inline styles cannot express `:hover` or `:focus-visible`: pass them through `classNames` (sentence, chip, tag).
|
|
245
|
+
|
|
183
246
|
## Hooks
|
|
184
247
|
|
|
185
248
|
### `useKeyboardShortcuts()`
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { Component, ReactNode, ErrorInfo, ComponentType, CSSProperties, RefObject } from 'react';
|
|
3
|
+
import { Component, ReactNode, ErrorInfo, ComponentType, CSSProperties, ElementType, RefObject } from 'react';
|
|
4
4
|
|
|
5
5
|
interface ErrorBoundaryProps {
|
|
6
6
|
children: ReactNode;
|
|
@@ -156,6 +156,101 @@ 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
|
+
/** What the action returns: nothing or any object WITHOUT an `error` (success), or an object with an `error` message (a failure a person can cause, shown in the open question). Extra properties are allowed, so `{ ok: true }` or a Server Action's own result type fits. */
|
|
160
|
+
type ConfirmActionResult = {
|
|
161
|
+
error?: string;
|
|
162
|
+
[extra: string]: unknown;
|
|
163
|
+
} | void;
|
|
164
|
+
interface ConfirmActionClassNames {
|
|
165
|
+
/** The button that opens the question. */
|
|
166
|
+
trigger?: string;
|
|
167
|
+
/** The wrapper (role="group") around the open question. */
|
|
168
|
+
group?: string;
|
|
169
|
+
/** The question text. */
|
|
170
|
+
question?: string;
|
|
171
|
+
/** The confirm (destructive) button. */
|
|
172
|
+
confirm?: string;
|
|
173
|
+
/** The safe ("Keep it") button. */
|
|
174
|
+
keep?: string;
|
|
175
|
+
/** The error message. */
|
|
176
|
+
error?: string;
|
|
177
|
+
}
|
|
178
|
+
interface ConfirmActionProps {
|
|
179
|
+
/** Label of the button that opens the question. */
|
|
180
|
+
triggerLabel: string;
|
|
181
|
+
/** The question; line breaks are kept. */
|
|
182
|
+
question: ReactNode;
|
|
183
|
+
/** Label of the confirm button. */
|
|
184
|
+
confirmLabel: string;
|
|
185
|
+
/** Label of the confirm button while the action runs. */
|
|
186
|
+
pendingLabel: string;
|
|
187
|
+
/** Label of the safe button. Default: "Keep it". */
|
|
188
|
+
keepLabel?: string;
|
|
189
|
+
/** Runs when the person confirms. Return `{ error }` for a failure; success returns nothing. */
|
|
190
|
+
onConfirm: () => Promise<ConfirmActionResult>;
|
|
191
|
+
/** Shown when `onConfirm` throws. Default: "Something went wrong. Please try again." */
|
|
192
|
+
errorFallback?: string;
|
|
193
|
+
/** Disables the trigger (the question cannot be opened). */
|
|
194
|
+
disabled?: boolean;
|
|
195
|
+
/** Accessible name of the open group. Default: the question itself (aria-labelledby), whatever React content it is. */
|
|
196
|
+
groupLabel?: string;
|
|
197
|
+
classNames?: ConfirmActionClassNames;
|
|
198
|
+
}
|
|
199
|
+
declare function ConfirmAction({ triggerLabel, question, confirmLabel, pendingLabel, keepLabel, onConfirm, errorFallback, disabled, groupLabel, classNames, }: ConfirmActionProps): react_jsx_runtime.JSX.Element;
|
|
200
|
+
|
|
201
|
+
/** A small linked (or plain) label under the sentence: the other thing involved, or a tag. */
|
|
202
|
+
interface ActivityFeedChip {
|
|
203
|
+
/** What it says: "Taft Law", "Hot". */
|
|
204
|
+
label: string;
|
|
205
|
+
/** Where it goes. Without it the chip is plain text. */
|
|
206
|
+
href?: string;
|
|
207
|
+
/** Names the kind for assistive technology: with `kind: 'Company'` the chip reads "Company: Taft Law". */
|
|
208
|
+
kind?: string;
|
|
209
|
+
}
|
|
210
|
+
interface ActivityFeedRowClassNames {
|
|
211
|
+
row?: string;
|
|
212
|
+
main?: string;
|
|
213
|
+
/** The sentence link (or the plain sentence). */
|
|
214
|
+
sentence?: string;
|
|
215
|
+
/** The empty stretched link that makes the whole row clickable. */
|
|
216
|
+
overlay?: string;
|
|
217
|
+
arrow?: string;
|
|
218
|
+
time?: string;
|
|
219
|
+
chips?: string;
|
|
220
|
+
chip?: string;
|
|
221
|
+
tagsLabel?: string;
|
|
222
|
+
tag?: string;
|
|
223
|
+
more?: string;
|
|
224
|
+
gone?: string;
|
|
225
|
+
actions?: string;
|
|
226
|
+
}
|
|
227
|
+
interface ActivityFeedRowProps {
|
|
228
|
+
/** The line: "Max added a note to Ann Lee". */
|
|
229
|
+
sentence: string;
|
|
230
|
+
/** When it happened (a Date or anything `new Date()` accepts). */
|
|
231
|
+
time: Date | string | number;
|
|
232
|
+
/** The time as shown. Default: the date's `toLocaleString()`. */
|
|
233
|
+
timeText?: string;
|
|
234
|
+
/** Where a click goes. Without it the row is plain. */
|
|
235
|
+
href?: string;
|
|
236
|
+
/** What the app calls this: set it when the thing is gone ("Person removed"): shown as a word, no link, no chips. */
|
|
237
|
+
gone?: string;
|
|
238
|
+
/** The other things involved, first the most important ("on Ann Lee", the company). */
|
|
239
|
+
chips?: ActivityFeedChip[];
|
|
240
|
+
/** The tags the thing has now. */
|
|
241
|
+
tags?: ActivityFeedChip[];
|
|
242
|
+
/** How many tag chips show before "+N". Default 3. */
|
|
243
|
+
maxTags?: number;
|
|
244
|
+
/** The label before the tag chips. Default "Tags now". */
|
|
245
|
+
tagsLabel?: string;
|
|
246
|
+
/** Buttons that belong to the row ("Show full note", "Resolve"): siblings above the overlay, never inside a link. */
|
|
247
|
+
actions?: ReactNode;
|
|
248
|
+
/** The component that renders every link (an `a` by default; give Next's Link in a Next app). It receives `href`, `className`, `style`, `children` and the aria props. */
|
|
249
|
+
LinkComponent?: ElementType;
|
|
250
|
+
classNames?: ActivityFeedRowClassNames;
|
|
251
|
+
}
|
|
252
|
+
declare function ActivityFeedRow({ sentence, time, timeText, href, gone, chips, tags, maxTags, tagsLabel, actions, LinkComponent, classNames, }: ActivityFeedRowProps): react_jsx_runtime.JSX.Element;
|
|
253
|
+
|
|
159
254
|
interface EntityPickerClassNames {
|
|
160
255
|
root?: string;
|
|
161
256
|
input?: string;
|
|
@@ -874,4 +969,4 @@ declare const ACTIVITY_ICONS: Record<string, IconComponent>;
|
|
|
874
969
|
/** Return the icon component for a given icon name, or Activity as fallback. */
|
|
875
970
|
declare function resolveActivityIcon(name: string): IconComponent;
|
|
876
971
|
|
|
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 };
|
|
972
|
+
export { ACTIVITY_ICONS, ALL_SHORTCUT_CONTEXTS, type ActivityFeedChip, ActivityFeedRow, type ActivityFeedRowClassNames, type ActivityFeedRowProps, ArchiveButton, type ArchiveButtonProps, CLIENT_PROFILE_SHORTCUTS, type CachedFetchOptions, type ComposeMode, ConfirmAction, type ConfirmActionClassNames, type ConfirmActionProps, type ConfirmActionResult, 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,10 +693,193 @@ function ArchiveButton({
|
|
|
693
693
|
);
|
|
694
694
|
}
|
|
695
695
|
|
|
696
|
-
// src/components/
|
|
697
|
-
import {
|
|
696
|
+
// src/components/confirm-action.tsx
|
|
697
|
+
import { useEffect as useEffect2, useId, useRef as useRef2, useState as useState3 } from "react";
|
|
698
698
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
699
699
|
var defaults = {
|
|
700
|
+
trigger: { padding: "4px 8px", fontSize: "14px", border: "1px solid transparent", borderRadius: "6px", backgroundColor: "transparent", color: "#b91c1c", cursor: "pointer" },
|
|
701
|
+
group: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: "8px", fontSize: "14px", outline: "none" },
|
|
702
|
+
question: { color: "#171717", whiteSpace: "pre-line" },
|
|
703
|
+
confirm: { padding: "4px 10px", fontSize: "14px", border: "1px solid #b91c1c", borderRadius: "6px", backgroundColor: "#b91c1c", color: "#ffffff", cursor: "pointer" },
|
|
704
|
+
keep: { padding: "4px 10px", fontSize: "14px", border: "1px solid #d4d4d4", borderRadius: "6px", backgroundColor: "#ffffff", color: "#404040", cursor: "pointer" },
|
|
705
|
+
error: { width: "100%", margin: 0, color: "#b91c1c" }
|
|
706
|
+
};
|
|
707
|
+
var disabledStyle2 = { opacity: 0.6, cursor: "not-allowed" };
|
|
708
|
+
function ConfirmAction({
|
|
709
|
+
triggerLabel,
|
|
710
|
+
question,
|
|
711
|
+
confirmLabel,
|
|
712
|
+
pendingLabel,
|
|
713
|
+
keepLabel = "Keep it",
|
|
714
|
+
onConfirm,
|
|
715
|
+
errorFallback = "Something went wrong. Please try again.",
|
|
716
|
+
disabled = false,
|
|
717
|
+
groupLabel,
|
|
718
|
+
classNames
|
|
719
|
+
}) {
|
|
720
|
+
const [open, setOpen] = useState3(false);
|
|
721
|
+
const [pending, setPending] = useState3(false);
|
|
722
|
+
const [error, setError] = useState3();
|
|
723
|
+
const triggerRef = useRef2(null);
|
|
724
|
+
const keepRef = useRef2(null);
|
|
725
|
+
const groupRef = useRef2(null);
|
|
726
|
+
const inFlight = useRef2(false);
|
|
727
|
+
const questionId = useId();
|
|
728
|
+
const restoreFocus = useRef2(null);
|
|
729
|
+
useEffect2(() => {
|
|
730
|
+
if (!open) return;
|
|
731
|
+
if (!pending) {
|
|
732
|
+
keepRef.current?.focus();
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
const active = document.activeElement;
|
|
736
|
+
if (!active || active === document.body || groupRef.current?.contains(active)) groupRef.current?.focus();
|
|
737
|
+
}, [open, pending]);
|
|
738
|
+
const part = (key, isDisabled = false) => {
|
|
739
|
+
const className = classNames?.[key];
|
|
740
|
+
return className ? { className } : { style: isDisabled ? { ...defaults[key], ...disabledStyle2 } : defaults[key] };
|
|
741
|
+
};
|
|
742
|
+
useEffect2(() => {
|
|
743
|
+
if (open || restoreFocus.current === null) return;
|
|
744
|
+
const mode = restoreFocus.current;
|
|
745
|
+
restoreFocus.current = null;
|
|
746
|
+
const active = document.activeElement;
|
|
747
|
+
if (mode === "always" || !active || active === document.body) triggerRef.current?.focus();
|
|
748
|
+
}, [open]);
|
|
749
|
+
const close = () => {
|
|
750
|
+
restoreFocus.current = "always";
|
|
751
|
+
setOpen(false);
|
|
752
|
+
setError(void 0);
|
|
753
|
+
};
|
|
754
|
+
const confirm = async () => {
|
|
755
|
+
if (inFlight.current) return;
|
|
756
|
+
inFlight.current = true;
|
|
757
|
+
setPending(true);
|
|
758
|
+
setError(void 0);
|
|
759
|
+
try {
|
|
760
|
+
const result = await onConfirm();
|
|
761
|
+
if (result && typeof result.error === "string" && result.error !== "") {
|
|
762
|
+
setError(result.error);
|
|
763
|
+
} else {
|
|
764
|
+
restoreFocus.current = "ifLost";
|
|
765
|
+
setOpen(false);
|
|
766
|
+
}
|
|
767
|
+
} catch {
|
|
768
|
+
setError(errorFallback);
|
|
769
|
+
} finally {
|
|
770
|
+
inFlight.current = false;
|
|
771
|
+
setPending(false);
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
if (!open) {
|
|
775
|
+
return /* @__PURE__ */ jsx5("button", { ref: triggerRef, type: "button", disabled, onClick: () => setOpen(true), ...part("trigger", disabled), children: triggerLabel });
|
|
776
|
+
}
|
|
777
|
+
const onKeyDown = (event) => {
|
|
778
|
+
if (event.key !== "Escape") return;
|
|
779
|
+
event.stopPropagation();
|
|
780
|
+
if (!pending) close();
|
|
781
|
+
};
|
|
782
|
+
return /* @__PURE__ */ jsxs4("div", { ref: groupRef, tabIndex: -1, role: "group", "aria-label": groupLabel, "aria-labelledby": groupLabel ? void 0 : questionId, onKeyDown, ...part("group"), children: [
|
|
783
|
+
/* @__PURE__ */ jsx5("span", { id: questionId, ...part("question"), children: question }),
|
|
784
|
+
/* @__PURE__ */ jsx5("button", { type: "button", disabled: pending, onClick: confirm, ...part("confirm", pending), children: pending ? pendingLabel : confirmLabel }),
|
|
785
|
+
/* @__PURE__ */ jsx5("button", { ref: keepRef, type: "button", disabled: pending, onClick: close, ...part("keep", pending), children: keepLabel }),
|
|
786
|
+
error ? /* @__PURE__ */ jsx5("p", { role: "alert", ...part("error"), children: error }) : null
|
|
787
|
+
] });
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// src/components/activity-feed-row.tsx
|
|
791
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
792
|
+
var defaults2 = {
|
|
793
|
+
row: { position: "relative", display: "flex", flexDirection: "column", gap: "4px", padding: "10px 0", borderBottom: "1px solid #f5f5f5", fontSize: "14px" },
|
|
794
|
+
main: { display: "flex", flexWrap: "wrap", alignItems: "baseline", justifyContent: "space-between", gap: "4px 16px", minWidth: 0 },
|
|
795
|
+
sentence: { color: "#171717", textDecoration: "none", overflowWrap: "anywhere", minWidth: 0 },
|
|
796
|
+
overlay: { position: "absolute", top: 0, right: 0, bottom: 0, left: 0 },
|
|
797
|
+
arrow: { marginLeft: "6px", color: "#737373" },
|
|
798
|
+
time: { flexShrink: 0, fontSize: "12px", color: "#737373" },
|
|
799
|
+
chips: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: "6px" },
|
|
800
|
+
chip: { padding: "1px 8px", fontSize: "12px", border: "1px solid #d4d4d4", borderRadius: "999px", color: "#404040", textDecoration: "none", backgroundColor: "#ffffff" },
|
|
801
|
+
tagsLabel: { fontSize: "12px", color: "#737373" },
|
|
802
|
+
tag: { padding: "1px 8px", fontSize: "12px", borderRadius: "999px", color: "#404040", textDecoration: "none", backgroundColor: "#f5f5f5" },
|
|
803
|
+
more: { fontSize: "12px", color: "#737373" },
|
|
804
|
+
gone: { padding: "1px 8px", fontSize: "12px", border: "1px solid #a3a3a3", borderRadius: "4px", color: "#525252" },
|
|
805
|
+
actions: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: "8px" }
|
|
806
|
+
};
|
|
807
|
+
var aboveOverlay = { position: "relative", zIndex: 1 };
|
|
808
|
+
var visuallyHidden = { position: "absolute", width: "1px", height: "1px", overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap" };
|
|
809
|
+
function ActivityFeedRow({
|
|
810
|
+
sentence,
|
|
811
|
+
time,
|
|
812
|
+
timeText,
|
|
813
|
+
href,
|
|
814
|
+
gone,
|
|
815
|
+
chips = [],
|
|
816
|
+
tags = [],
|
|
817
|
+
maxTags = 3,
|
|
818
|
+
tagsLabel = "Tags now",
|
|
819
|
+
actions,
|
|
820
|
+
LinkComponent = "a",
|
|
821
|
+
classNames
|
|
822
|
+
}) {
|
|
823
|
+
const Link = LinkComponent;
|
|
824
|
+
const part = (key, structural) => {
|
|
825
|
+
const className = classNames?.[key];
|
|
826
|
+
if (className) return structural ? { className, style: structural } : { className };
|
|
827
|
+
return { style: structural ? { ...defaults2[key], ...structural } : defaults2[key] };
|
|
828
|
+
};
|
|
829
|
+
const date = new Date(time);
|
|
830
|
+
const valid = !Number.isNaN(date.getTime());
|
|
831
|
+
const shownTime = timeText ?? (valid ? date.toLocaleString() : String(time));
|
|
832
|
+
const isGone = typeof gone === "string" && gone !== "";
|
|
833
|
+
const clickable = !isGone && typeof href === "string" && href !== "";
|
|
834
|
+
const shownTags = isGone ? [] : tags.slice(0, Math.max(0, maxTags));
|
|
835
|
+
const hiddenTags = isGone ? 0 : Math.max(0, tags.length - shownTags.length);
|
|
836
|
+
const shownChips = isGone ? [] : chips;
|
|
837
|
+
const chipNode = (chip, key, slot) => {
|
|
838
|
+
const content = /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
839
|
+
chip.kind ? /* @__PURE__ */ jsxs5("span", { style: visuallyHidden, children: [
|
|
840
|
+
chip.kind,
|
|
841
|
+
": "
|
|
842
|
+
] }) : null,
|
|
843
|
+
chip.label
|
|
844
|
+
] });
|
|
845
|
+
return chip.href ? /* @__PURE__ */ jsx6(Link, { href: chip.href, ...part(slot, aboveOverlay), children: content }, key) : /* @__PURE__ */ jsx6("span", { ...part(slot, aboveOverlay), children: content }, key);
|
|
846
|
+
};
|
|
847
|
+
return /* @__PURE__ */ jsxs5("li", { ...part("row", { position: "relative" }), children: [
|
|
848
|
+
/* @__PURE__ */ jsxs5("div", { ...part("main"), children: [
|
|
849
|
+
/* @__PURE__ */ jsxs5("span", { style: { minWidth: 0 }, children: [
|
|
850
|
+
clickable ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
851
|
+
/* @__PURE__ */ jsx6(Link, { href, ...part("sentence"), children: sentence }),
|
|
852
|
+
/* @__PURE__ */ jsx6("span", { "aria-hidden": "true", ...part("arrow"), children: "\u2192" })
|
|
853
|
+
] }) : /* @__PURE__ */ jsx6("span", { ...part("sentence"), children: sentence }),
|
|
854
|
+
isGone ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
855
|
+
" ",
|
|
856
|
+
/* @__PURE__ */ jsx6("span", { ...part("gone"), children: gone })
|
|
857
|
+
] }) : null
|
|
858
|
+
] }),
|
|
859
|
+
/* @__PURE__ */ jsx6("time", { dateTime: valid ? date.toISOString() : void 0, ...part("time"), children: shownTime })
|
|
860
|
+
] }),
|
|
861
|
+
shownChips.length > 0 || shownTags.length > 0 || hiddenTags > 0 ? /* @__PURE__ */ jsxs5("div", { ...part("chips", aboveOverlay), children: [
|
|
862
|
+
shownChips.map((chip, index) => chipNode(chip, `chip-${index}`, "chip")),
|
|
863
|
+
shownTags.length > 0 ? /* @__PURE__ */ jsx6("span", { ...part("tagsLabel"), children: tagsLabel }) : null,
|
|
864
|
+
shownTags.map((tag, index) => chipNode(tag, `tag-${index}`, "tag")),
|
|
865
|
+
hiddenTags > 0 ? /* @__PURE__ */ jsxs5("span", { ...part("more"), children: [
|
|
866
|
+
"+",
|
|
867
|
+
hiddenTags,
|
|
868
|
+
/* @__PURE__ */ jsxs5("span", { style: visuallyHidden, children: [
|
|
869
|
+
" more ",
|
|
870
|
+
hiddenTags === 1 ? "tag" : "tags"
|
|
871
|
+
] })
|
|
872
|
+
] }) : null
|
|
873
|
+
] }) : null,
|
|
874
|
+
actions ? /* @__PURE__ */ jsx6("div", { ...part("actions", aboveOverlay), children: actions }) : null,
|
|
875
|
+
clickable ? /* @__PURE__ */ jsx6(Link, { href, "aria-hidden": "true", tabIndex: -1, ...part("overlay", { position: "absolute", top: 0, right: 0, bottom: 0, left: 0 }) }) : null
|
|
876
|
+
] });
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// src/components/entity-picker.tsx
|
|
880
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useId as useId2, useRef as useRef3, useState as useState4 } from "react";
|
|
881
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
882
|
+
var defaults3 = {
|
|
700
883
|
root: { position: "relative", display: "inline-flex", alignItems: "center", gap: "4px", width: "100%" },
|
|
701
884
|
input: { flex: 1, minWidth: 0, padding: "8px 10px", fontSize: "14px", border: "1px solid #d4d4d4", borderRadius: "6px", backgroundColor: "#ffffff", color: "#171717" },
|
|
702
885
|
clear: { padding: "4px 8px", fontSize: "14px", border: "1px solid transparent", borderRadius: "6px", backgroundColor: "transparent", color: "#525252", cursor: "pointer" },
|
|
@@ -707,7 +890,7 @@ var optionDefaults = {
|
|
|
707
890
|
base: { padding: "6px 8px", fontSize: "14px", borderRadius: "4px", cursor: "pointer", color: "#171717" },
|
|
708
891
|
active: { backgroundColor: "#f5f5f5" }
|
|
709
892
|
};
|
|
710
|
-
var
|
|
893
|
+
var visuallyHidden2 = { position: "absolute", width: "1px", height: "1px", margin: "-1px", padding: 0, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap", border: 0 };
|
|
711
894
|
function EntityPicker({
|
|
712
895
|
value,
|
|
713
896
|
onChange,
|
|
@@ -730,20 +913,20 @@ function EntityPicker({
|
|
|
730
913
|
classNames,
|
|
731
914
|
style
|
|
732
915
|
}) {
|
|
733
|
-
const listId =
|
|
734
|
-
const listRef =
|
|
735
|
-
const inputRef =
|
|
736
|
-
const selectAfterRender =
|
|
737
|
-
const [text, setText] =
|
|
738
|
-
const [editing, setEditing] =
|
|
739
|
-
const [open, setOpen] =
|
|
740
|
-
const [results, setResults] =
|
|
741
|
-
const [status, setStatus] =
|
|
742
|
-
const [searched, setSearched] =
|
|
743
|
-
const [activeIndex, setActiveIndex] =
|
|
744
|
-
const timer =
|
|
745
|
-
const controller =
|
|
746
|
-
const latest =
|
|
916
|
+
const listId = useId2();
|
|
917
|
+
const listRef = useRef3(null);
|
|
918
|
+
const inputRef = useRef3(null);
|
|
919
|
+
const selectAfterRender = useRef3(null);
|
|
920
|
+
const [text, setText] = useState4("");
|
|
921
|
+
const [editing, setEditing] = useState4(false);
|
|
922
|
+
const [open, setOpen] = useState4(false);
|
|
923
|
+
const [results, setResults] = useState4([]);
|
|
924
|
+
const [status, setStatus] = useState4("idle");
|
|
925
|
+
const [searched, setSearched] = useState4(false);
|
|
926
|
+
const [activeIndex, setActiveIndex] = useState4(-1);
|
|
927
|
+
const timer = useRef3(null);
|
|
928
|
+
const controller = useRef3(null);
|
|
929
|
+
const latest = useRef3(0);
|
|
747
930
|
const cancelSearch = useCallback2(() => {
|
|
748
931
|
if (timer.current) clearTimeout(timer.current);
|
|
749
932
|
timer.current = null;
|
|
@@ -751,7 +934,7 @@ function EntityPicker({
|
|
|
751
934
|
controller.current = null;
|
|
752
935
|
latest.current++;
|
|
753
936
|
}, []);
|
|
754
|
-
|
|
937
|
+
useEffect3(() => cancelSearch, [cancelSearch]);
|
|
755
938
|
const runSearch = useCallback2(
|
|
756
939
|
(query) => {
|
|
757
940
|
cancelSearch();
|
|
@@ -807,17 +990,17 @@ function EntityPicker({
|
|
|
807
990
|
const showListbox = showPopup && results.length > 0;
|
|
808
991
|
const activeId = showListbox && activeIndex >= 0 ? `${listId}-opt-${activeIndex}` : void 0;
|
|
809
992
|
const announcement = !showPopup ? "" : status === "loading" ? loadingText : status === "error" ? errorText : results.length === 0 ? emptyText : "";
|
|
810
|
-
|
|
993
|
+
useEffect3(() => {
|
|
811
994
|
if (showListbox && activeIndex >= 0) listRef.current?.children[activeIndex]?.scrollIntoView?.({ block: "nearest" });
|
|
812
995
|
}, [showListbox, activeIndex]);
|
|
813
|
-
|
|
996
|
+
useEffect3(() => {
|
|
814
997
|
const pending = selectAfterRender.current;
|
|
815
998
|
if (!pending || editing) return;
|
|
816
999
|
if ((value ? getKey(value) : null) !== pending.key) return;
|
|
817
1000
|
selectAfterRender.current = null;
|
|
818
1001
|
if (document.activeElement === inputRef.current) inputRef.current?.select();
|
|
819
1002
|
}, [value, editing, getKey]);
|
|
820
|
-
|
|
1003
|
+
useEffect3(() => {
|
|
821
1004
|
if (disabled) stopEditing();
|
|
822
1005
|
}, [disabled]);
|
|
823
1006
|
const onKeyDown = (event) => {
|
|
@@ -843,7 +1026,7 @@ function EntityPicker({
|
|
|
843
1026
|
const partProps = (key) => {
|
|
844
1027
|
const className = classNames?.[key];
|
|
845
1028
|
if (className) return { className, style: key === "root" ? style : void 0 };
|
|
846
|
-
return { style: key === "root" ? { ...
|
|
1029
|
+
return { style: key === "root" ? { ...defaults3.root, ...style } : defaults3[key] };
|
|
847
1030
|
};
|
|
848
1031
|
const optionProps = (active) => {
|
|
849
1032
|
const optionClass = classNames?.option;
|
|
@@ -852,8 +1035,8 @@ function EntityPicker({
|
|
|
852
1035
|
return { className, style: optionClass ? void 0 : { ...optionDefaults.base, ...active && !activeClass ? optionDefaults.active : {} } };
|
|
853
1036
|
};
|
|
854
1037
|
const shown = editing ? text : value ? getLabel(value) : "";
|
|
855
|
-
return /* @__PURE__ */
|
|
856
|
-
/* @__PURE__ */
|
|
1038
|
+
return /* @__PURE__ */ jsxs6("div", { ...partProps("root"), children: [
|
|
1039
|
+
/* @__PURE__ */ jsx7(
|
|
857
1040
|
"input",
|
|
858
1041
|
{
|
|
859
1042
|
...partProps("input"),
|
|
@@ -885,19 +1068,19 @@ function EntityPicker({
|
|
|
885
1068
|
}
|
|
886
1069
|
}
|
|
887
1070
|
),
|
|
888
|
-
name !== void 0 ? /* @__PURE__ */
|
|
889
|
-
clearable && value && !disabled ? /* @__PURE__ */
|
|
1071
|
+
name !== void 0 ? /* @__PURE__ */ jsx7("input", { type: "hidden", name, value: value ? getKey(value) : "", disabled }) : null,
|
|
1072
|
+
clearable && value && !disabled ? /* @__PURE__ */ jsx7("button", { type: "button", "aria-label": clearLabel, ...partProps("clear"), onClick: () => {
|
|
890
1073
|
onChange(null);
|
|
891
1074
|
inputRef.current?.focus();
|
|
892
1075
|
}, children: "\xD7" }) : null,
|
|
893
|
-
/* @__PURE__ */
|
|
1076
|
+
/* @__PURE__ */ jsx7("div", { role: "status", "aria-live": "polite", style: visuallyHidden2, children: announcement }),
|
|
894
1077
|
showPopup ? (
|
|
895
1078
|
// mousedown anywhere in the popup (an option, the scrollbar, a message) must not move focus out of the input, or its
|
|
896
1079
|
// blur would close the list before the click lands (and make a long list impossible to scroll by dragging)
|
|
897
|
-
/* @__PURE__ */
|
|
898
|
-
showListbox ? /* @__PURE__ */
|
|
1080
|
+
/* @__PURE__ */ jsxs6("div", { ...partProps("list"), onMouseDown: (event) => event.preventDefault(), children: [
|
|
1081
|
+
showListbox ? /* @__PURE__ */ jsx7("ul", { ref: listRef, id: listId, role: "listbox", "aria-label": ariaLabel, style: { listStyle: "none", margin: 0, padding: 0 }, children: results.map((item, index) => {
|
|
899
1082
|
const active = index === activeIndex;
|
|
900
|
-
return /* @__PURE__ */
|
|
1083
|
+
return /* @__PURE__ */ jsx7(
|
|
901
1084
|
"li",
|
|
902
1085
|
{
|
|
903
1086
|
id: `${listId}-opt-${index}`,
|
|
@@ -913,16 +1096,16 @@ function EntityPicker({
|
|
|
913
1096
|
getKey(item)
|
|
914
1097
|
);
|
|
915
1098
|
}) }) : null,
|
|
916
|
-
status === "loading" ? /* @__PURE__ */
|
|
917
|
-
status === "error" ? /* @__PURE__ */
|
|
918
|
-
status === "idle" && searched && results.length === 0 ? /* @__PURE__ */
|
|
1099
|
+
status === "loading" ? /* @__PURE__ */ jsx7("div", { "aria-hidden": "true", "data-entity-picker-message": "loading", ...partProps("message"), children: loadingText }) : null,
|
|
1100
|
+
status === "error" ? /* @__PURE__ */ jsx7("div", { "aria-hidden": "true", "data-entity-picker-message": "error", ...partProps("message"), children: errorText }) : null,
|
|
1101
|
+
status === "idle" && searched && results.length === 0 ? /* @__PURE__ */ jsx7("div", { "aria-hidden": "true", "data-entity-picker-message": "empty", ...partProps("message"), children: emptyText }) : null
|
|
919
1102
|
] })
|
|
920
1103
|
) : null
|
|
921
1104
|
] });
|
|
922
1105
|
}
|
|
923
1106
|
|
|
924
1107
|
// src/components/rich-text-editor.tsx
|
|
925
|
-
import { useCallback as useCallback3, useEffect as
|
|
1108
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useRef as useRef4, useState as useState5 } from "react";
|
|
926
1109
|
|
|
927
1110
|
// src/components/rich-text-editor-styles.ts
|
|
928
1111
|
var containerStyle = {
|
|
@@ -975,7 +1158,7 @@ var editableStyle = {
|
|
|
975
1158
|
};
|
|
976
1159
|
|
|
977
1160
|
// src/components/rich-text-editor.tsx
|
|
978
|
-
import { jsx as
|
|
1161
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
979
1162
|
var TOOLBAR_BUTTONS = [
|
|
980
1163
|
{ command: "bold", label: "B", ariaLabel: "Bold" },
|
|
981
1164
|
{ command: "italic", label: "I", ariaLabel: "Italic" },
|
|
@@ -1007,18 +1190,18 @@ function RichTextEditor({
|
|
|
1007
1190
|
className,
|
|
1008
1191
|
style
|
|
1009
1192
|
}) {
|
|
1010
|
-
const editorRef =
|
|
1011
|
-
const [isFocused, setIsFocused] =
|
|
1012
|
-
const [isEmpty, setIsEmpty] =
|
|
1013
|
-
const [linkError, setLinkError] =
|
|
1014
|
-
|
|
1193
|
+
const editorRef = useRef4(null);
|
|
1194
|
+
const [isFocused, setIsFocused] = useState5(false);
|
|
1195
|
+
const [isEmpty, setIsEmpty] = useState5(isEmptyHtml(content));
|
|
1196
|
+
const [linkError, setLinkError] = useState5(null);
|
|
1197
|
+
useEffect4(() => {
|
|
1015
1198
|
const el = editorRef.current;
|
|
1016
1199
|
if (el && !isFocused && el.innerHTML !== content) {
|
|
1017
1200
|
el.innerHTML = content;
|
|
1018
1201
|
setIsEmpty(isEmptyHtml(content));
|
|
1019
1202
|
}
|
|
1020
1203
|
}, [content, isFocused, editable]);
|
|
1021
|
-
|
|
1204
|
+
useEffect4(() => {
|
|
1022
1205
|
if (autoFocus) editorRef.current?.focus();
|
|
1023
1206
|
}, []);
|
|
1024
1207
|
const handleInput = useCallback3(() => {
|
|
@@ -1045,7 +1228,7 @@ function RichTextEditor({
|
|
|
1045
1228
|
runCommand("createLink", url);
|
|
1046
1229
|
}, [runCommand]);
|
|
1047
1230
|
if (!editable) {
|
|
1048
|
-
return /* @__PURE__ */
|
|
1231
|
+
return /* @__PURE__ */ jsx8(
|
|
1049
1232
|
"div",
|
|
1050
1233
|
{
|
|
1051
1234
|
className: [className, "ordinatio-rte", "ordinatio-rte-readonly"].filter(Boolean).join(" "),
|
|
@@ -1054,9 +1237,9 @@ function RichTextEditor({
|
|
|
1054
1237
|
}
|
|
1055
1238
|
);
|
|
1056
1239
|
}
|
|
1057
|
-
return /* @__PURE__ */
|
|
1058
|
-
/* @__PURE__ */
|
|
1059
|
-
TOOLBAR_BUTTONS.map((btn) => /* @__PURE__ */
|
|
1240
|
+
return /* @__PURE__ */ jsxs7("div", { className: [className, "ordinatio-rte"].filter(Boolean).join(" "), style: className ? style : { ...containerStyle, ...style }, children: [
|
|
1241
|
+
/* @__PURE__ */ jsxs7("div", { className: "ordinatio-rte-toolbar", style: toolbarStyle, children: [
|
|
1242
|
+
TOOLBAR_BUTTONS.map((btn) => /* @__PURE__ */ jsx8(
|
|
1060
1243
|
"button",
|
|
1061
1244
|
{
|
|
1062
1245
|
type: "button",
|
|
@@ -1070,7 +1253,7 @@ function RichTextEditor({
|
|
|
1070
1253
|
},
|
|
1071
1254
|
btn.command
|
|
1072
1255
|
)),
|
|
1073
|
-
/* @__PURE__ */
|
|
1256
|
+
/* @__PURE__ */ jsx8(
|
|
1074
1257
|
"button",
|
|
1075
1258
|
{
|
|
1076
1259
|
type: "button",
|
|
@@ -1083,10 +1266,10 @@ function RichTextEditor({
|
|
|
1083
1266
|
children: "\u{1F517}"
|
|
1084
1267
|
}
|
|
1085
1268
|
),
|
|
1086
|
-
toolbarRight ? /* @__PURE__ */
|
|
1269
|
+
toolbarRight ? /* @__PURE__ */ jsx8("div", { className: "ordinatio-rte-toolbar-right", style: toolbarRightStyle, children: toolbarRight }) : null
|
|
1087
1270
|
] }),
|
|
1088
|
-
linkError ? /* @__PURE__ */
|
|
1089
|
-
/* @__PURE__ */
|
|
1271
|
+
linkError ? /* @__PURE__ */ jsx8("div", { className: "ordinatio-rte-link-error", role: "alert", style: linkErrorStyle, children: linkError }) : null,
|
|
1272
|
+
/* @__PURE__ */ jsxs7("div", { className: "ordinatio-rte-editable-wrap", style: { position: "relative" }, children: [
|
|
1090
1273
|
isEmpty ? (
|
|
1091
1274
|
// Shown while empty REGARDLESS of focus — WorldClass cycle 1:
|
|
1092
1275
|
// the prior `isEmpty && !isFocused` condition hid the
|
|
@@ -1095,7 +1278,7 @@ function RichTextEditor({
|
|
|
1095
1278
|
// the click landed. Matches native `<textarea placeholder>`
|
|
1096
1279
|
// behavior (visible while focused-and-empty, removed only once
|
|
1097
1280
|
// the user types).
|
|
1098
|
-
/* @__PURE__ */
|
|
1281
|
+
/* @__PURE__ */ jsx8(
|
|
1099
1282
|
"div",
|
|
1100
1283
|
{
|
|
1101
1284
|
"aria-hidden": "true",
|
|
@@ -1105,7 +1288,7 @@ function RichTextEditor({
|
|
|
1105
1288
|
}
|
|
1106
1289
|
)
|
|
1107
1290
|
) : null,
|
|
1108
|
-
/* @__PURE__ */
|
|
1291
|
+
/* @__PURE__ */ jsx8(
|
|
1109
1292
|
"div",
|
|
1110
1293
|
{
|
|
1111
1294
|
ref: editorRef,
|
|
@@ -1127,7 +1310,7 @@ function RichTextEditor({
|
|
|
1127
1310
|
}
|
|
1128
1311
|
|
|
1129
1312
|
// src/components/reply-panel.tsx
|
|
1130
|
-
import { useEffect as
|
|
1313
|
+
import { useEffect as useEffect5, useId as useId3, useRef as useRef5, useState as useState6 } from "react";
|
|
1131
1314
|
|
|
1132
1315
|
// src/components/subject-prefix.ts
|
|
1133
1316
|
function prefixSubject(subject, mode) {
|
|
@@ -1217,7 +1400,7 @@ var disabledButtonStyle = {
|
|
|
1217
1400
|
};
|
|
1218
1401
|
|
|
1219
1402
|
// src/components/reply-panel.tsx
|
|
1220
|
-
import { Fragment as
|
|
1403
|
+
import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1221
1404
|
function ReplyPanel({
|
|
1222
1405
|
mode = "reply",
|
|
1223
1406
|
subject,
|
|
@@ -1236,22 +1419,22 @@ function ReplyPanel({
|
|
|
1236
1419
|
}) {
|
|
1237
1420
|
const defaultTo = mode === "reply" ? toEmail || toName : "";
|
|
1238
1421
|
const defaultSubject = prefixSubject(subject, mode);
|
|
1239
|
-
const idPrefix =
|
|
1422
|
+
const idPrefix = useId3();
|
|
1240
1423
|
const toId = `${idPrefix}-to`;
|
|
1241
1424
|
const ccId = `${idPrefix}-cc`;
|
|
1242
1425
|
const bccId = `${idPrefix}-bcc`;
|
|
1243
1426
|
const subjectId = `${idPrefix}-subject`;
|
|
1244
|
-
const [to, setTo] =
|
|
1245
|
-
const [cc, setCc] =
|
|
1246
|
-
const [bcc, setBcc] =
|
|
1247
|
-
const [showCcBcc, setShowCcBcc] =
|
|
1248
|
-
const [editedSubject, setEditedSubject] =
|
|
1249
|
-
const [body, setBody] =
|
|
1250
|
-
const [sending, setSending] =
|
|
1251
|
-
const [error, setError] =
|
|
1252
|
-
const [sent, setSent] =
|
|
1253
|
-
const isMountedRef =
|
|
1254
|
-
|
|
1427
|
+
const [to, setTo] = useState6(defaultTo);
|
|
1428
|
+
const [cc, setCc] = useState6(initialCc);
|
|
1429
|
+
const [bcc, setBcc] = useState6("");
|
|
1430
|
+
const [showCcBcc, setShowCcBcc] = useState6(initialShowCcBcc || !!initialCc);
|
|
1431
|
+
const [editedSubject, setEditedSubject] = useState6(defaultSubject);
|
|
1432
|
+
const [body, setBody] = useState6(initialBody);
|
|
1433
|
+
const [sending, setSending] = useState6(false);
|
|
1434
|
+
const [error, setError] = useState6(null);
|
|
1435
|
+
const [sent, setSent] = useState6(false);
|
|
1436
|
+
const isMountedRef = useRef5(true);
|
|
1437
|
+
useEffect5(() => {
|
|
1255
1438
|
isMountedRef.current = true;
|
|
1256
1439
|
return () => {
|
|
1257
1440
|
isMountedRef.current = false;
|
|
@@ -1296,16 +1479,16 @@ function ReplyPanel({
|
|
|
1296
1479
|
if (isMountedRef.current) setSending(false);
|
|
1297
1480
|
}
|
|
1298
1481
|
};
|
|
1299
|
-
return /* @__PURE__ */
|
|
1482
|
+
return /* @__PURE__ */ jsxs8(
|
|
1300
1483
|
"div",
|
|
1301
1484
|
{
|
|
1302
1485
|
className: [className, "ordinatio-reply-panel"].filter(Boolean).join(" "),
|
|
1303
1486
|
style: className ? style : { display: "flex", flexDirection: "column", gap: "8px", ...style },
|
|
1304
1487
|
children: [
|
|
1305
|
-
/* @__PURE__ */
|
|
1306
|
-
/* @__PURE__ */
|
|
1307
|
-
/* @__PURE__ */
|
|
1308
|
-
/* @__PURE__ */
|
|
1488
|
+
/* @__PURE__ */ jsxs8("div", { className: "ordinatio-reply-fields", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
1489
|
+
/* @__PURE__ */ jsxs8("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1490
|
+
/* @__PURE__ */ jsx9("label", { htmlFor: toId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "To" }),
|
|
1491
|
+
/* @__PURE__ */ jsx9(
|
|
1309
1492
|
"input",
|
|
1310
1493
|
{
|
|
1311
1494
|
id: toId,
|
|
@@ -1333,7 +1516,7 @@ function ReplyPanel({
|
|
|
1333
1516
|
// and aria-controls referenced ids (ccId/bccId) that don't
|
|
1334
1517
|
// exist in the DOM until AFTER this button has already
|
|
1335
1518
|
// unmounted. A one-directional reveal, not a toggle.
|
|
1336
|
-
/* @__PURE__ */
|
|
1519
|
+
/* @__PURE__ */ jsx9(
|
|
1337
1520
|
"button",
|
|
1338
1521
|
{
|
|
1339
1522
|
type: "button",
|
|
@@ -1346,10 +1529,10 @@ function ReplyPanel({
|
|
|
1346
1529
|
)
|
|
1347
1530
|
) : null
|
|
1348
1531
|
] }),
|
|
1349
|
-
showCcBcc ? /* @__PURE__ */
|
|
1350
|
-
/* @__PURE__ */
|
|
1351
|
-
/* @__PURE__ */
|
|
1352
|
-
/* @__PURE__ */
|
|
1532
|
+
showCcBcc ? /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
1533
|
+
/* @__PURE__ */ jsxs8("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1534
|
+
/* @__PURE__ */ jsx9("label", { htmlFor: ccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Cc" }),
|
|
1535
|
+
/* @__PURE__ */ jsx9(
|
|
1353
1536
|
"input",
|
|
1354
1537
|
{
|
|
1355
1538
|
id: ccId,
|
|
@@ -1367,9 +1550,9 @@ function ReplyPanel({
|
|
|
1367
1550
|
}
|
|
1368
1551
|
)
|
|
1369
1552
|
] }),
|
|
1370
|
-
/* @__PURE__ */
|
|
1371
|
-
/* @__PURE__ */
|
|
1372
|
-
/* @__PURE__ */
|
|
1553
|
+
/* @__PURE__ */ jsxs8("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1554
|
+
/* @__PURE__ */ jsx9("label", { htmlFor: bccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Bcc" }),
|
|
1555
|
+
/* @__PURE__ */ jsx9(
|
|
1373
1556
|
"input",
|
|
1374
1557
|
{
|
|
1375
1558
|
id: bccId,
|
|
@@ -1388,9 +1571,9 @@ function ReplyPanel({
|
|
|
1388
1571
|
)
|
|
1389
1572
|
] })
|
|
1390
1573
|
] }) : null,
|
|
1391
|
-
/* @__PURE__ */
|
|
1392
|
-
/* @__PURE__ */
|
|
1393
|
-
/* @__PURE__ */
|
|
1574
|
+
/* @__PURE__ */ jsxs8("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
|
|
1575
|
+
/* @__PURE__ */ jsx9("label", { htmlFor: subjectId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Subject" }),
|
|
1576
|
+
/* @__PURE__ */ jsx9(
|
|
1394
1577
|
"input",
|
|
1395
1578
|
{
|
|
1396
1579
|
id: subjectId,
|
|
@@ -1409,9 +1592,9 @@ function ReplyPanel({
|
|
|
1409
1592
|
)
|
|
1410
1593
|
] })
|
|
1411
1594
|
] }),
|
|
1412
|
-
error ? /* @__PURE__ */
|
|
1413
|
-
sent && resolvedSuccessMessage ? /* @__PURE__ */
|
|
1414
|
-
/* @__PURE__ */
|
|
1595
|
+
error ? /* @__PURE__ */ jsx9("div", { className: "ordinatio-reply-error", role: "alert", style: errorStyle, children: error }) : null,
|
|
1596
|
+
sent && resolvedSuccessMessage ? /* @__PURE__ */ jsx9("div", { className: "ordinatio-reply-success", role: "status", style: successStyle, children: resolvedSuccessMessage }) : null,
|
|
1597
|
+
/* @__PURE__ */ jsx9(
|
|
1415
1598
|
RichTextEditor,
|
|
1416
1599
|
{
|
|
1417
1600
|
content: body,
|
|
@@ -1425,8 +1608,8 @@ function ReplyPanel({
|
|
|
1425
1608
|
locked: sending
|
|
1426
1609
|
}
|
|
1427
1610
|
),
|
|
1428
|
-
/* @__PURE__ */
|
|
1429
|
-
showCancel && onCancel ? /* @__PURE__ */
|
|
1611
|
+
/* @__PURE__ */ jsxs8("div", { className: "ordinatio-reply-actions", style: actionsRowStyle, children: [
|
|
1612
|
+
showCancel && onCancel ? /* @__PURE__ */ jsx9(
|
|
1430
1613
|
"button",
|
|
1431
1614
|
{
|
|
1432
1615
|
type: "button",
|
|
@@ -1437,7 +1620,7 @@ function ReplyPanel({
|
|
|
1437
1620
|
children: "Cancel"
|
|
1438
1621
|
}
|
|
1439
1622
|
) : null,
|
|
1440
|
-
/* @__PURE__ */
|
|
1623
|
+
/* @__PURE__ */ jsx9(
|
|
1441
1624
|
"button",
|
|
1442
1625
|
{
|
|
1443
1626
|
type: "button",
|
|
@@ -1455,7 +1638,7 @@ function ReplyPanel({
|
|
|
1455
1638
|
}
|
|
1456
1639
|
|
|
1457
1640
|
// src/hooks/use-keyboard-shortcuts.ts
|
|
1458
|
-
import { useEffect as
|
|
1641
|
+
import { useEffect as useEffect6, useCallback as useCallback4 } from "react";
|
|
1459
1642
|
|
|
1460
1643
|
// src/hooks/is-typing-context.ts
|
|
1461
1644
|
var TYPING_TAG_RE = /^(INPUT|TEXTAREA|SELECT)$/;
|
|
@@ -1480,7 +1663,7 @@ function useKeyboardShortcuts({
|
|
|
1480
1663
|
ignoreTags = []
|
|
1481
1664
|
}) {
|
|
1482
1665
|
const malformed = !Array.isArray(shortcuts);
|
|
1483
|
-
|
|
1666
|
+
useEffect6(() => {
|
|
1484
1667
|
if (malformed) {
|
|
1485
1668
|
console.error(
|
|
1486
1669
|
"[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."
|
|
@@ -1515,7 +1698,7 @@ function useKeyboardShortcuts({
|
|
|
1515
1698
|
},
|
|
1516
1699
|
[shortcuts, enabled, ignoreTags, malformed]
|
|
1517
1700
|
);
|
|
1518
|
-
|
|
1701
|
+
useEffect6(() => {
|
|
1519
1702
|
window.addEventListener("keydown", handleKeyDown);
|
|
1520
1703
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1521
1704
|
}, [handleKeyDown]);
|
|
@@ -1685,13 +1868,13 @@ function getShortcut(context, action) {
|
|
|
1685
1868
|
}
|
|
1686
1869
|
|
|
1687
1870
|
// src/components/keyboard-shortcuts-panel.tsx
|
|
1688
|
-
import { useEffect as
|
|
1689
|
-
import { Fragment as
|
|
1871
|
+
import { useEffect as useEffect7, useState as useState7 } from "react";
|
|
1872
|
+
import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1690
1873
|
function KeyboardShortcutsPanel({
|
|
1691
1874
|
contexts = ALL_SHORTCUT_CONTEXTS
|
|
1692
1875
|
}) {
|
|
1693
|
-
const [open, setOpen] =
|
|
1694
|
-
|
|
1876
|
+
const [open, setOpen] = useState7(false);
|
|
1877
|
+
useEffect7(() => {
|
|
1695
1878
|
function handleKey(e) {
|
|
1696
1879
|
if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
|
1697
1880
|
const tag = e.target?.tagName;
|
|
@@ -1708,33 +1891,33 @@ function KeyboardShortcutsPanel({
|
|
|
1708
1891
|
return () => window.removeEventListener("keydown", handleKey);
|
|
1709
1892
|
}, [open]);
|
|
1710
1893
|
if (!open) return null;
|
|
1711
|
-
return /* @__PURE__ */
|
|
1712
|
-
/* @__PURE__ */
|
|
1894
|
+
return /* @__PURE__ */ jsxs9(Fragment4, { children: [
|
|
1895
|
+
/* @__PURE__ */ jsx10(
|
|
1713
1896
|
"div",
|
|
1714
1897
|
{
|
|
1715
1898
|
className: "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",
|
|
1716
1899
|
onClick: () => setOpen(false)
|
|
1717
1900
|
}
|
|
1718
1901
|
),
|
|
1719
|
-
/* @__PURE__ */
|
|
1720
|
-
/* @__PURE__ */
|
|
1721
|
-
/* @__PURE__ */
|
|
1722
|
-
/* @__PURE__ */
|
|
1902
|
+
/* @__PURE__ */ jsx10("div", { className: "fixed inset-x-0 top-[10%] z-50 mx-auto w-full max-w-lg", children: /* @__PURE__ */ jsxs9("div", { className: "rounded-xl border bg-background shadow-2xl overflow-hidden", children: [
|
|
1903
|
+
/* @__PURE__ */ jsxs9("div", { className: "px-6 py-4 border-b", children: [
|
|
1904
|
+
/* @__PURE__ */ jsx10("h2", { className: "text-lg font-semibold", children: "Keyboard Shortcuts" }),
|
|
1905
|
+
/* @__PURE__ */ jsxs9("p", { className: "text-sm text-muted-foreground mt-0.5", children: [
|
|
1723
1906
|
"Press ",
|
|
1724
|
-
/* @__PURE__ */
|
|
1907
|
+
/* @__PURE__ */ jsx10("kbd", { className: "px-1.5 py-0.5 bg-muted rounded text-xs font-mono", children: "?" }),
|
|
1725
1908
|
" to toggle this panel"
|
|
1726
1909
|
] })
|
|
1727
1910
|
] }),
|
|
1728
|
-
/* @__PURE__ */
|
|
1729
|
-
/* @__PURE__ */
|
|
1730
|
-
/* @__PURE__ */
|
|
1731
|
-
/* @__PURE__ */
|
|
1732
|
-
/* @__PURE__ */
|
|
1911
|
+
/* @__PURE__ */ jsx10("div", { className: "px-6 py-4 max-h-[60vh] overflow-y-auto space-y-6", children: contexts.map((ctx) => /* @__PURE__ */ jsxs9("div", { children: [
|
|
1912
|
+
/* @__PURE__ */ jsx10("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: ctx.label }),
|
|
1913
|
+
/* @__PURE__ */ jsx10("div", { className: "space-y-1", children: Object.entries(ctx.shortcuts).map(([key, def]) => /* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between py-1", children: [
|
|
1914
|
+
/* @__PURE__ */ jsx10("span", { className: "text-sm", children: def.description }),
|
|
1915
|
+
/* @__PURE__ */ jsx10("kbd", { className: "px-2 py-0.5 bg-muted rounded text-xs font-mono min-w-[2rem] text-center", children: def.display })
|
|
1733
1916
|
] }, key)) })
|
|
1734
1917
|
] }, ctx.name)) }),
|
|
1735
|
-
/* @__PURE__ */
|
|
1918
|
+
/* @__PURE__ */ jsxs9("div", { className: "px-6 py-3 border-t bg-muted/30 text-xs text-muted-foreground text-center", children: [
|
|
1736
1919
|
"Press ",
|
|
1737
|
-
/* @__PURE__ */
|
|
1920
|
+
/* @__PURE__ */ jsx10("kbd", { className: "px-1 py-0.5 bg-muted rounded", children: "Esc" }),
|
|
1738
1921
|
" to close"
|
|
1739
1922
|
] })
|
|
1740
1923
|
] }) })
|
|
@@ -1742,19 +1925,19 @@ function KeyboardShortcutsPanel({
|
|
|
1742
1925
|
}
|
|
1743
1926
|
|
|
1744
1927
|
// src/hooks/use-auto-save.ts
|
|
1745
|
-
import { useEffect as
|
|
1928
|
+
import { useEffect as useEffect8, useRef as useRef6, useCallback as useCallback5, useState as useState8 } from "react";
|
|
1746
1929
|
function useAutoSave({
|
|
1747
1930
|
data,
|
|
1748
1931
|
onSave,
|
|
1749
1932
|
delay = 5e3,
|
|
1750
1933
|
enabled = true
|
|
1751
1934
|
}) {
|
|
1752
|
-
const [lastSavedAt, setLastSavedAt] =
|
|
1753
|
-
const [isSaving, setIsSaving] =
|
|
1754
|
-
const [saveError, setSaveError] =
|
|
1755
|
-
const timerRef =
|
|
1756
|
-
const dataRef =
|
|
1757
|
-
const savedDataRef =
|
|
1935
|
+
const [lastSavedAt, setLastSavedAt] = useState8(null);
|
|
1936
|
+
const [isSaving, setIsSaving] = useState8(false);
|
|
1937
|
+
const [saveError, setSaveError] = useState8(null);
|
|
1938
|
+
const timerRef = useRef6(null);
|
|
1939
|
+
const dataRef = useRef6(data);
|
|
1940
|
+
const savedDataRef = useRef6(null);
|
|
1758
1941
|
dataRef.current = data;
|
|
1759
1942
|
const save = useCallback5(async () => {
|
|
1760
1943
|
const currentJson = JSON.stringify(dataRef.current);
|
|
@@ -1771,7 +1954,7 @@ function useAutoSave({
|
|
|
1771
1954
|
setIsSaving(false);
|
|
1772
1955
|
}
|
|
1773
1956
|
}, [onSave]);
|
|
1774
|
-
|
|
1957
|
+
useEffect8(() => {
|
|
1775
1958
|
if (!enabled) return;
|
|
1776
1959
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
1777
1960
|
timerRef.current = setTimeout(save, delay);
|
|
@@ -1783,18 +1966,18 @@ function useAutoSave({
|
|
|
1783
1966
|
}
|
|
1784
1967
|
|
|
1785
1968
|
// src/hooks/use-polling.ts
|
|
1786
|
-
import { useEffect as
|
|
1969
|
+
import { useEffect as useEffect9, useCallback as useCallback6, useRef as useRef7, useState as useState9 } from "react";
|
|
1787
1970
|
function usePolling({
|
|
1788
1971
|
fetcher,
|
|
1789
1972
|
interval = 3e4,
|
|
1790
1973
|
enabled = true,
|
|
1791
1974
|
onError
|
|
1792
1975
|
}) {
|
|
1793
|
-
const [data, setData] =
|
|
1794
|
-
const [isLoading, setIsLoading] =
|
|
1795
|
-
const [isRefreshing, setIsRefreshing] =
|
|
1796
|
-
const [error, setError] =
|
|
1797
|
-
const mountedRef =
|
|
1976
|
+
const [data, setData] = useState9(null);
|
|
1977
|
+
const [isLoading, setIsLoading] = useState9(true);
|
|
1978
|
+
const [isRefreshing, setIsRefreshing] = useState9(false);
|
|
1979
|
+
const [error, setError] = useState9(null);
|
|
1980
|
+
const mountedRef = useRef7(true);
|
|
1798
1981
|
const doFetch = useCallback6(async (isInitial = false) => {
|
|
1799
1982
|
if (isInitial) setIsLoading(true);
|
|
1800
1983
|
else setIsRefreshing(true);
|
|
@@ -1816,14 +1999,14 @@ function usePolling({
|
|
|
1816
1999
|
}
|
|
1817
2000
|
}
|
|
1818
2001
|
}, [fetcher, onError]);
|
|
1819
|
-
|
|
2002
|
+
useEffect9(() => {
|
|
1820
2003
|
mountedRef.current = true;
|
|
1821
2004
|
if (enabled) doFetch(true);
|
|
1822
2005
|
return () => {
|
|
1823
2006
|
mountedRef.current = false;
|
|
1824
2007
|
};
|
|
1825
2008
|
}, [doFetch, enabled]);
|
|
1826
|
-
|
|
2009
|
+
useEffect9(() => {
|
|
1827
2010
|
if (!enabled) return;
|
|
1828
2011
|
const timer = setInterval(() => doFetch(false), interval);
|
|
1829
2012
|
return () => clearInterval(timer);
|
|
@@ -1833,19 +2016,19 @@ function usePolling({
|
|
|
1833
2016
|
}
|
|
1834
2017
|
|
|
1835
2018
|
// src/hooks/use-server-search.ts
|
|
1836
|
-
import { useEffect as
|
|
2019
|
+
import { useEffect as useEffect10, useRef as useRef8, useState as useState10, useCallback as useCallback7 } from "react";
|
|
1837
2020
|
function useServerSearch({
|
|
1838
2021
|
fetcher,
|
|
1839
2022
|
debounce = 150,
|
|
1840
2023
|
minChars = 1,
|
|
1841
2024
|
enabled = true
|
|
1842
2025
|
}) {
|
|
1843
|
-
const [query, setQuery] =
|
|
1844
|
-
const [results, setResults] =
|
|
1845
|
-
const [isSearching, setIsSearching] =
|
|
1846
|
-
const [isOpen, setIsOpen] =
|
|
1847
|
-
const timerRef =
|
|
1848
|
-
|
|
2026
|
+
const [query, setQuery] = useState10("");
|
|
2027
|
+
const [results, setResults] = useState10([]);
|
|
2028
|
+
const [isSearching, setIsSearching] = useState10(false);
|
|
2029
|
+
const [isOpen, setIsOpen] = useState10(false);
|
|
2030
|
+
const timerRef = useRef8(null);
|
|
2031
|
+
useEffect10(() => {
|
|
1849
2032
|
if (!enabled || query.length < minChars) {
|
|
1850
2033
|
setResults([]);
|
|
1851
2034
|
return;
|
|
@@ -1875,9 +2058,9 @@ function useServerSearch({
|
|
|
1875
2058
|
}
|
|
1876
2059
|
|
|
1877
2060
|
// src/hooks/use-iframe-focus-reclaim.ts
|
|
1878
|
-
import { useEffect as
|
|
2061
|
+
import { useEffect as useEffect11 } from "react";
|
|
1879
2062
|
function useIframeFocusReclaim(containerRef, enabled = true, iframeSelector = "iframe") {
|
|
1880
|
-
|
|
2063
|
+
useEffect11(() => {
|
|
1881
2064
|
if (!enabled) return;
|
|
1882
2065
|
const el = containerRef.current;
|
|
1883
2066
|
if (!el) return;
|
|
@@ -2058,21 +2241,21 @@ function clearCache() {
|
|
|
2058
2241
|
}
|
|
2059
2242
|
|
|
2060
2243
|
// src/hooks/use-preferences.ts
|
|
2061
|
-
import { useState as
|
|
2244
|
+
import { useState as useState11, useEffect as useEffect12, useCallback as useCallback8 } from "react";
|
|
2062
2245
|
function usePreferences({
|
|
2063
2246
|
endpoint,
|
|
2064
|
-
defaults:
|
|
2247
|
+
defaults: defaults4
|
|
2065
2248
|
}) {
|
|
2066
|
-
const [preferences, setPreferences] =
|
|
2067
|
-
const [loading, setLoading] =
|
|
2068
|
-
const [error, setError] =
|
|
2249
|
+
const [preferences, setPreferences] = useState11(defaults4 ?? null);
|
|
2250
|
+
const [loading, setLoading] = useState11(true);
|
|
2251
|
+
const [error, setError] = useState11(null);
|
|
2069
2252
|
const fetchPreferences = useCallback8(async () => {
|
|
2070
2253
|
try {
|
|
2071
2254
|
setError(null);
|
|
2072
2255
|
const res = await fetch(endpoint);
|
|
2073
2256
|
if (!res.ok) {
|
|
2074
2257
|
if (res.status === 401) {
|
|
2075
|
-
setPreferences(
|
|
2258
|
+
setPreferences(defaults4 ?? null);
|
|
2076
2259
|
return;
|
|
2077
2260
|
}
|
|
2078
2261
|
throw new Error("Failed to fetch preferences");
|
|
@@ -2084,8 +2267,8 @@ function usePreferences({
|
|
|
2084
2267
|
} finally {
|
|
2085
2268
|
setLoading(false);
|
|
2086
2269
|
}
|
|
2087
|
-
}, [endpoint,
|
|
2088
|
-
|
|
2270
|
+
}, [endpoint, defaults4]);
|
|
2271
|
+
useEffect12(() => {
|
|
2089
2272
|
fetchPreferences();
|
|
2090
2273
|
}, [fetchPreferences]);
|
|
2091
2274
|
const updatePreferences = useCallback8(
|
|
@@ -2442,8 +2625,10 @@ function resolveActivityIcon(name) {
|
|
|
2442
2625
|
export {
|
|
2443
2626
|
ACTIVITY_ICONS,
|
|
2444
2627
|
ALL_SHORTCUT_CONTEXTS,
|
|
2628
|
+
ActivityFeedRow,
|
|
2445
2629
|
ArchiveButton,
|
|
2446
2630
|
CLIENT_PROFILE_SHORTCUTS,
|
|
2631
|
+
ConfirmAction,
|
|
2447
2632
|
EmailBodyRenderer,
|
|
2448
2633
|
EmailThreadView,
|
|
2449
2634
|
EntityPicker,
|