@ordinatio/ui 1.4.0 → 1.5.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 CHANGED
@@ -180,6 +180,38 @@ 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
+
183
215
  ## Hooks
184
216
 
185
217
  ### `useKeyboardShortcuts()`
package/dist/index.d.mts CHANGED
@@ -156,6 +156,48 @@ 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
+
159
201
  interface EntityPickerClassNames {
160
202
  root?: string;
161
203
  input?: string;
@@ -874,4 +916,4 @@ declare const ACTIVITY_ICONS: Record<string, IconComponent>;
874
916
  /** Return the icon component for a given icon name, or Activity as fallback. */
875
917
  declare function resolveActivityIcon(name: string): IconComponent;
876
918
 
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 };
919
+ export { ACTIVITY_ICONS, ALL_SHORTCUT_CONTEXTS, 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,104 @@ 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";
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/entity-picker.tsx
791
+ import { useCallback as useCallback2, useEffect as useEffect3, useId as useId2, useRef as useRef3, useState as useState4 } from "react";
792
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
793
+ var defaults2 = {
700
794
  root: { position: "relative", display: "inline-flex", alignItems: "center", gap: "4px", width: "100%" },
701
795
  input: { flex: 1, minWidth: 0, padding: "8px 10px", fontSize: "14px", border: "1px solid #d4d4d4", borderRadius: "6px", backgroundColor: "#ffffff", color: "#171717" },
702
796
  clear: { padding: "4px 8px", fontSize: "14px", border: "1px solid transparent", borderRadius: "6px", backgroundColor: "transparent", color: "#525252", cursor: "pointer" },
@@ -730,20 +824,20 @@ function EntityPicker({
730
824
  classNames,
731
825
  style
732
826
  }) {
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);
827
+ const listId = useId2();
828
+ const listRef = useRef3(null);
829
+ const inputRef = useRef3(null);
830
+ const selectAfterRender = useRef3(null);
831
+ const [text, setText] = useState4("");
832
+ const [editing, setEditing] = useState4(false);
833
+ const [open, setOpen] = useState4(false);
834
+ const [results, setResults] = useState4([]);
835
+ const [status, setStatus] = useState4("idle");
836
+ const [searched, setSearched] = useState4(false);
837
+ const [activeIndex, setActiveIndex] = useState4(-1);
838
+ const timer = useRef3(null);
839
+ const controller = useRef3(null);
840
+ const latest = useRef3(0);
747
841
  const cancelSearch = useCallback2(() => {
748
842
  if (timer.current) clearTimeout(timer.current);
749
843
  timer.current = null;
@@ -751,7 +845,7 @@ function EntityPicker({
751
845
  controller.current = null;
752
846
  latest.current++;
753
847
  }, []);
754
- useEffect2(() => cancelSearch, [cancelSearch]);
848
+ useEffect3(() => cancelSearch, [cancelSearch]);
755
849
  const runSearch = useCallback2(
756
850
  (query) => {
757
851
  cancelSearch();
@@ -807,17 +901,17 @@ function EntityPicker({
807
901
  const showListbox = showPopup && results.length > 0;
808
902
  const activeId = showListbox && activeIndex >= 0 ? `${listId}-opt-${activeIndex}` : void 0;
809
903
  const announcement = !showPopup ? "" : status === "loading" ? loadingText : status === "error" ? errorText : results.length === 0 ? emptyText : "";
810
- useEffect2(() => {
904
+ useEffect3(() => {
811
905
  if (showListbox && activeIndex >= 0) listRef.current?.children[activeIndex]?.scrollIntoView?.({ block: "nearest" });
812
906
  }, [showListbox, activeIndex]);
813
- useEffect2(() => {
907
+ useEffect3(() => {
814
908
  const pending = selectAfterRender.current;
815
909
  if (!pending || editing) return;
816
910
  if ((value ? getKey(value) : null) !== pending.key) return;
817
911
  selectAfterRender.current = null;
818
912
  if (document.activeElement === inputRef.current) inputRef.current?.select();
819
913
  }, [value, editing, getKey]);
820
- useEffect2(() => {
914
+ useEffect3(() => {
821
915
  if (disabled) stopEditing();
822
916
  }, [disabled]);
823
917
  const onKeyDown = (event) => {
@@ -843,7 +937,7 @@ function EntityPicker({
843
937
  const partProps = (key) => {
844
938
  const className = classNames?.[key];
845
939
  if (className) return { className, style: key === "root" ? style : void 0 };
846
- return { style: key === "root" ? { ...defaults.root, ...style } : defaults[key] };
940
+ return { style: key === "root" ? { ...defaults2.root, ...style } : defaults2[key] };
847
941
  };
848
942
  const optionProps = (active) => {
849
943
  const optionClass = classNames?.option;
@@ -852,8 +946,8 @@ function EntityPicker({
852
946
  return { className, style: optionClass ? void 0 : { ...optionDefaults.base, ...active && !activeClass ? optionDefaults.active : {} } };
853
947
  };
854
948
  const shown = editing ? text : value ? getLabel(value) : "";
855
- return /* @__PURE__ */ jsxs4("div", { ...partProps("root"), children: [
856
- /* @__PURE__ */ jsx5(
949
+ return /* @__PURE__ */ jsxs5("div", { ...partProps("root"), children: [
950
+ /* @__PURE__ */ jsx6(
857
951
  "input",
858
952
  {
859
953
  ...partProps("input"),
@@ -885,19 +979,19 @@ function EntityPicker({
885
979
  }
886
980
  }
887
981
  ),
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: () => {
982
+ name !== void 0 ? /* @__PURE__ */ jsx6("input", { type: "hidden", name, value: value ? getKey(value) : "", disabled }) : null,
983
+ clearable && value && !disabled ? /* @__PURE__ */ jsx6("button", { type: "button", "aria-label": clearLabel, ...partProps("clear"), onClick: () => {
890
984
  onChange(null);
891
985
  inputRef.current?.focus();
892
986
  }, children: "\xD7" }) : null,
893
- /* @__PURE__ */ jsx5("div", { role: "status", "aria-live": "polite", style: visuallyHidden, children: announcement }),
987
+ /* @__PURE__ */ jsx6("div", { role: "status", "aria-live": "polite", style: visuallyHidden, children: announcement }),
894
988
  showPopup ? (
895
989
  // mousedown anywhere in the popup (an option, the scrollbar, a message) must not move focus out of the input, or its
896
990
  // 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) => {
991
+ /* @__PURE__ */ jsxs5("div", { ...partProps("list"), onMouseDown: (event) => event.preventDefault(), children: [
992
+ showListbox ? /* @__PURE__ */ jsx6("ul", { ref: listRef, id: listId, role: "listbox", "aria-label": ariaLabel, style: { listStyle: "none", margin: 0, padding: 0 }, children: results.map((item, index) => {
899
993
  const active = index === activeIndex;
900
- return /* @__PURE__ */ jsx5(
994
+ return /* @__PURE__ */ jsx6(
901
995
  "li",
902
996
  {
903
997
  id: `${listId}-opt-${index}`,
@@ -913,16 +1007,16 @@ function EntityPicker({
913
1007
  getKey(item)
914
1008
  );
915
1009
  }) }) : 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
1010
+ status === "loading" ? /* @__PURE__ */ jsx6("div", { "aria-hidden": "true", "data-entity-picker-message": "loading", ...partProps("message"), children: loadingText }) : null,
1011
+ status === "error" ? /* @__PURE__ */ jsx6("div", { "aria-hidden": "true", "data-entity-picker-message": "error", ...partProps("message"), children: errorText }) : null,
1012
+ status === "idle" && searched && results.length === 0 ? /* @__PURE__ */ jsx6("div", { "aria-hidden": "true", "data-entity-picker-message": "empty", ...partProps("message"), children: emptyText }) : null
919
1013
  ] })
920
1014
  ) : null
921
1015
  ] });
922
1016
  }
923
1017
 
924
1018
  // src/components/rich-text-editor.tsx
925
- import { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
1019
+ import { useCallback as useCallback3, useEffect as useEffect4, useRef as useRef4, useState as useState5 } from "react";
926
1020
 
927
1021
  // src/components/rich-text-editor-styles.ts
928
1022
  var containerStyle = {
@@ -975,7 +1069,7 @@ var editableStyle = {
975
1069
  };
976
1070
 
977
1071
  // src/components/rich-text-editor.tsx
978
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1072
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
979
1073
  var TOOLBAR_BUTTONS = [
980
1074
  { command: "bold", label: "B", ariaLabel: "Bold" },
981
1075
  { command: "italic", label: "I", ariaLabel: "Italic" },
@@ -1007,18 +1101,18 @@ function RichTextEditor({
1007
1101
  className,
1008
1102
  style
1009
1103
  }) {
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(() => {
1104
+ const editorRef = useRef4(null);
1105
+ const [isFocused, setIsFocused] = useState5(false);
1106
+ const [isEmpty, setIsEmpty] = useState5(isEmptyHtml(content));
1107
+ const [linkError, setLinkError] = useState5(null);
1108
+ useEffect4(() => {
1015
1109
  const el = editorRef.current;
1016
1110
  if (el && !isFocused && el.innerHTML !== content) {
1017
1111
  el.innerHTML = content;
1018
1112
  setIsEmpty(isEmptyHtml(content));
1019
1113
  }
1020
1114
  }, [content, isFocused, editable]);
1021
- useEffect3(() => {
1115
+ useEffect4(() => {
1022
1116
  if (autoFocus) editorRef.current?.focus();
1023
1117
  }, []);
1024
1118
  const handleInput = useCallback3(() => {
@@ -1045,7 +1139,7 @@ function RichTextEditor({
1045
1139
  runCommand("createLink", url);
1046
1140
  }, [runCommand]);
1047
1141
  if (!editable) {
1048
- return /* @__PURE__ */ jsx6(
1142
+ return /* @__PURE__ */ jsx7(
1049
1143
  "div",
1050
1144
  {
1051
1145
  className: [className, "ordinatio-rte", "ordinatio-rte-readonly"].filter(Boolean).join(" "),
@@ -1054,9 +1148,9 @@ function RichTextEditor({
1054
1148
  }
1055
1149
  );
1056
1150
  }
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(
1151
+ return /* @__PURE__ */ jsxs6("div", { className: [className, "ordinatio-rte"].filter(Boolean).join(" "), style: className ? style : { ...containerStyle, ...style }, children: [
1152
+ /* @__PURE__ */ jsxs6("div", { className: "ordinatio-rte-toolbar", style: toolbarStyle, children: [
1153
+ TOOLBAR_BUTTONS.map((btn) => /* @__PURE__ */ jsx7(
1060
1154
  "button",
1061
1155
  {
1062
1156
  type: "button",
@@ -1070,7 +1164,7 @@ function RichTextEditor({
1070
1164
  },
1071
1165
  btn.command
1072
1166
  )),
1073
- /* @__PURE__ */ jsx6(
1167
+ /* @__PURE__ */ jsx7(
1074
1168
  "button",
1075
1169
  {
1076
1170
  type: "button",
@@ -1083,10 +1177,10 @@ function RichTextEditor({
1083
1177
  children: "\u{1F517}"
1084
1178
  }
1085
1179
  ),
1086
- toolbarRight ? /* @__PURE__ */ jsx6("div", { className: "ordinatio-rte-toolbar-right", style: toolbarRightStyle, children: toolbarRight }) : null
1180
+ toolbarRight ? /* @__PURE__ */ jsx7("div", { className: "ordinatio-rte-toolbar-right", style: toolbarRightStyle, children: toolbarRight }) : null
1087
1181
  ] }),
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: [
1182
+ linkError ? /* @__PURE__ */ jsx7("div", { className: "ordinatio-rte-link-error", role: "alert", style: linkErrorStyle, children: linkError }) : null,
1183
+ /* @__PURE__ */ jsxs6("div", { className: "ordinatio-rte-editable-wrap", style: { position: "relative" }, children: [
1090
1184
  isEmpty ? (
1091
1185
  // Shown while empty REGARDLESS of focus — WorldClass cycle 1:
1092
1186
  // the prior `isEmpty && !isFocused` condition hid the
@@ -1095,7 +1189,7 @@ function RichTextEditor({
1095
1189
  // the click landed. Matches native `<textarea placeholder>`
1096
1190
  // behavior (visible while focused-and-empty, removed only once
1097
1191
  // the user types).
1098
- /* @__PURE__ */ jsx6(
1192
+ /* @__PURE__ */ jsx7(
1099
1193
  "div",
1100
1194
  {
1101
1195
  "aria-hidden": "true",
@@ -1105,7 +1199,7 @@ function RichTextEditor({
1105
1199
  }
1106
1200
  )
1107
1201
  ) : null,
1108
- /* @__PURE__ */ jsx6(
1202
+ /* @__PURE__ */ jsx7(
1109
1203
  "div",
1110
1204
  {
1111
1205
  ref: editorRef,
@@ -1127,7 +1221,7 @@ function RichTextEditor({
1127
1221
  }
1128
1222
 
1129
1223
  // src/components/reply-panel.tsx
1130
- import { useEffect as useEffect4, useId as useId2, useRef as useRef4, useState as useState5 } from "react";
1224
+ import { useEffect as useEffect5, useId as useId3, useRef as useRef5, useState as useState6 } from "react";
1131
1225
 
1132
1226
  // src/components/subject-prefix.ts
1133
1227
  function prefixSubject(subject, mode) {
@@ -1217,7 +1311,7 @@ var disabledButtonStyle = {
1217
1311
  };
1218
1312
 
1219
1313
  // src/components/reply-panel.tsx
1220
- import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1314
+ import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1221
1315
  function ReplyPanel({
1222
1316
  mode = "reply",
1223
1317
  subject,
@@ -1236,22 +1330,22 @@ function ReplyPanel({
1236
1330
  }) {
1237
1331
  const defaultTo = mode === "reply" ? toEmail || toName : "";
1238
1332
  const defaultSubject = prefixSubject(subject, mode);
1239
- const idPrefix = useId2();
1333
+ const idPrefix = useId3();
1240
1334
  const toId = `${idPrefix}-to`;
1241
1335
  const ccId = `${idPrefix}-cc`;
1242
1336
  const bccId = `${idPrefix}-bcc`;
1243
1337
  const subjectId = `${idPrefix}-subject`;
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(() => {
1338
+ const [to, setTo] = useState6(defaultTo);
1339
+ const [cc, setCc] = useState6(initialCc);
1340
+ const [bcc, setBcc] = useState6("");
1341
+ const [showCcBcc, setShowCcBcc] = useState6(initialShowCcBcc || !!initialCc);
1342
+ const [editedSubject, setEditedSubject] = useState6(defaultSubject);
1343
+ const [body, setBody] = useState6(initialBody);
1344
+ const [sending, setSending] = useState6(false);
1345
+ const [error, setError] = useState6(null);
1346
+ const [sent, setSent] = useState6(false);
1347
+ const isMountedRef = useRef5(true);
1348
+ useEffect5(() => {
1255
1349
  isMountedRef.current = true;
1256
1350
  return () => {
1257
1351
  isMountedRef.current = false;
@@ -1296,16 +1390,16 @@ function ReplyPanel({
1296
1390
  if (isMountedRef.current) setSending(false);
1297
1391
  }
1298
1392
  };
1299
- return /* @__PURE__ */ jsxs6(
1393
+ return /* @__PURE__ */ jsxs7(
1300
1394
  "div",
1301
1395
  {
1302
1396
  className: [className, "ordinatio-reply-panel"].filter(Boolean).join(" "),
1303
1397
  style: className ? style : { display: "flex", flexDirection: "column", gap: "8px", ...style },
1304
1398
  children: [
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(
1399
+ /* @__PURE__ */ jsxs7("div", { className: "ordinatio-reply-fields", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
1400
+ /* @__PURE__ */ jsxs7("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1401
+ /* @__PURE__ */ jsx8("label", { htmlFor: toId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "To" }),
1402
+ /* @__PURE__ */ jsx8(
1309
1403
  "input",
1310
1404
  {
1311
1405
  id: toId,
@@ -1333,7 +1427,7 @@ function ReplyPanel({
1333
1427
  // and aria-controls referenced ids (ccId/bccId) that don't
1334
1428
  // exist in the DOM until AFTER this button has already
1335
1429
  // unmounted. A one-directional reveal, not a toggle.
1336
- /* @__PURE__ */ jsx7(
1430
+ /* @__PURE__ */ jsx8(
1337
1431
  "button",
1338
1432
  {
1339
1433
  type: "button",
@@ -1346,10 +1440,10 @@ function ReplyPanel({
1346
1440
  )
1347
1441
  ) : null
1348
1442
  ] }),
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(
1443
+ showCcBcc ? /* @__PURE__ */ jsxs7(Fragment2, { children: [
1444
+ /* @__PURE__ */ jsxs7("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1445
+ /* @__PURE__ */ jsx8("label", { htmlFor: ccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Cc" }),
1446
+ /* @__PURE__ */ jsx8(
1353
1447
  "input",
1354
1448
  {
1355
1449
  id: ccId,
@@ -1367,9 +1461,9 @@ function ReplyPanel({
1367
1461
  }
1368
1462
  )
1369
1463
  ] }),
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(
1464
+ /* @__PURE__ */ jsxs7("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1465
+ /* @__PURE__ */ jsx8("label", { htmlFor: bccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Bcc" }),
1466
+ /* @__PURE__ */ jsx8(
1373
1467
  "input",
1374
1468
  {
1375
1469
  id: bccId,
@@ -1388,9 +1482,9 @@ function ReplyPanel({
1388
1482
  )
1389
1483
  ] })
1390
1484
  ] }) : null,
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(
1485
+ /* @__PURE__ */ jsxs7("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1486
+ /* @__PURE__ */ jsx8("label", { htmlFor: subjectId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Subject" }),
1487
+ /* @__PURE__ */ jsx8(
1394
1488
  "input",
1395
1489
  {
1396
1490
  id: subjectId,
@@ -1409,9 +1503,9 @@ function ReplyPanel({
1409
1503
  )
1410
1504
  ] })
1411
1505
  ] }),
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(
1506
+ error ? /* @__PURE__ */ jsx8("div", { className: "ordinatio-reply-error", role: "alert", style: errorStyle, children: error }) : null,
1507
+ sent && resolvedSuccessMessage ? /* @__PURE__ */ jsx8("div", { className: "ordinatio-reply-success", role: "status", style: successStyle, children: resolvedSuccessMessage }) : null,
1508
+ /* @__PURE__ */ jsx8(
1415
1509
  RichTextEditor,
1416
1510
  {
1417
1511
  content: body,
@@ -1425,8 +1519,8 @@ function ReplyPanel({
1425
1519
  locked: sending
1426
1520
  }
1427
1521
  ),
1428
- /* @__PURE__ */ jsxs6("div", { className: "ordinatio-reply-actions", style: actionsRowStyle, children: [
1429
- showCancel && onCancel ? /* @__PURE__ */ jsx7(
1522
+ /* @__PURE__ */ jsxs7("div", { className: "ordinatio-reply-actions", style: actionsRowStyle, children: [
1523
+ showCancel && onCancel ? /* @__PURE__ */ jsx8(
1430
1524
  "button",
1431
1525
  {
1432
1526
  type: "button",
@@ -1437,7 +1531,7 @@ function ReplyPanel({
1437
1531
  children: "Cancel"
1438
1532
  }
1439
1533
  ) : null,
1440
- /* @__PURE__ */ jsx7(
1534
+ /* @__PURE__ */ jsx8(
1441
1535
  "button",
1442
1536
  {
1443
1537
  type: "button",
@@ -1455,7 +1549,7 @@ function ReplyPanel({
1455
1549
  }
1456
1550
 
1457
1551
  // src/hooks/use-keyboard-shortcuts.ts
1458
- import { useEffect as useEffect5, useCallback as useCallback4 } from "react";
1552
+ import { useEffect as useEffect6, useCallback as useCallback4 } from "react";
1459
1553
 
1460
1554
  // src/hooks/is-typing-context.ts
1461
1555
  var TYPING_TAG_RE = /^(INPUT|TEXTAREA|SELECT)$/;
@@ -1480,7 +1574,7 @@ function useKeyboardShortcuts({
1480
1574
  ignoreTags = []
1481
1575
  }) {
1482
1576
  const malformed = !Array.isArray(shortcuts);
1483
- useEffect5(() => {
1577
+ useEffect6(() => {
1484
1578
  if (malformed) {
1485
1579
  console.error(
1486
1580
  "[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 +1609,7 @@ function useKeyboardShortcuts({
1515
1609
  },
1516
1610
  [shortcuts, enabled, ignoreTags, malformed]
1517
1611
  );
1518
- useEffect5(() => {
1612
+ useEffect6(() => {
1519
1613
  window.addEventListener("keydown", handleKeyDown);
1520
1614
  return () => window.removeEventListener("keydown", handleKeyDown);
1521
1615
  }, [handleKeyDown]);
@@ -1685,13 +1779,13 @@ function getShortcut(context, action) {
1685
1779
  }
1686
1780
 
1687
1781
  // src/components/keyboard-shortcuts-panel.tsx
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";
1782
+ import { useEffect as useEffect7, useState as useState7 } from "react";
1783
+ import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
1690
1784
  function KeyboardShortcutsPanel({
1691
1785
  contexts = ALL_SHORTCUT_CONTEXTS
1692
1786
  }) {
1693
- const [open, setOpen] = useState6(false);
1694
- useEffect6(() => {
1787
+ const [open, setOpen] = useState7(false);
1788
+ useEffect7(() => {
1695
1789
  function handleKey(e) {
1696
1790
  if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey) {
1697
1791
  const tag = e.target?.tagName;
@@ -1708,33 +1802,33 @@ function KeyboardShortcutsPanel({
1708
1802
  return () => window.removeEventListener("keydown", handleKey);
1709
1803
  }, [open]);
1710
1804
  if (!open) return null;
1711
- return /* @__PURE__ */ jsxs7(Fragment3, { children: [
1712
- /* @__PURE__ */ jsx8(
1805
+ return /* @__PURE__ */ jsxs8(Fragment3, { children: [
1806
+ /* @__PURE__ */ jsx9(
1713
1807
  "div",
1714
1808
  {
1715
1809
  className: "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",
1716
1810
  onClick: () => setOpen(false)
1717
1811
  }
1718
1812
  ),
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: [
1813
+ /* @__PURE__ */ jsx9("div", { className: "fixed inset-x-0 top-[10%] z-50 mx-auto w-full max-w-lg", children: /* @__PURE__ */ jsxs8("div", { className: "rounded-xl border bg-background shadow-2xl overflow-hidden", children: [
1814
+ /* @__PURE__ */ jsxs8("div", { className: "px-6 py-4 border-b", children: [
1815
+ /* @__PURE__ */ jsx9("h2", { className: "text-lg font-semibold", children: "Keyboard Shortcuts" }),
1816
+ /* @__PURE__ */ jsxs8("p", { className: "text-sm text-muted-foreground mt-0.5", children: [
1723
1817
  "Press ",
1724
- /* @__PURE__ */ jsx8("kbd", { className: "px-1.5 py-0.5 bg-muted rounded text-xs font-mono", children: "?" }),
1818
+ /* @__PURE__ */ jsx9("kbd", { className: "px-1.5 py-0.5 bg-muted rounded text-xs font-mono", children: "?" }),
1725
1819
  " to toggle this panel"
1726
1820
  ] })
1727
1821
  ] }),
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 })
1822
+ /* @__PURE__ */ jsx9("div", { className: "px-6 py-4 max-h-[60vh] overflow-y-auto space-y-6", children: contexts.map((ctx) => /* @__PURE__ */ jsxs8("div", { children: [
1823
+ /* @__PURE__ */ jsx9("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: ctx.label }),
1824
+ /* @__PURE__ */ jsx9("div", { className: "space-y-1", children: Object.entries(ctx.shortcuts).map(([key, def]) => /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between py-1", children: [
1825
+ /* @__PURE__ */ jsx9("span", { className: "text-sm", children: def.description }),
1826
+ /* @__PURE__ */ jsx9("kbd", { className: "px-2 py-0.5 bg-muted rounded text-xs font-mono min-w-[2rem] text-center", children: def.display })
1733
1827
  ] }, key)) })
1734
1828
  ] }, ctx.name)) }),
1735
- /* @__PURE__ */ jsxs7("div", { className: "px-6 py-3 border-t bg-muted/30 text-xs text-muted-foreground text-center", children: [
1829
+ /* @__PURE__ */ jsxs8("div", { className: "px-6 py-3 border-t bg-muted/30 text-xs text-muted-foreground text-center", children: [
1736
1830
  "Press ",
1737
- /* @__PURE__ */ jsx8("kbd", { className: "px-1 py-0.5 bg-muted rounded", children: "Esc" }),
1831
+ /* @__PURE__ */ jsx9("kbd", { className: "px-1 py-0.5 bg-muted rounded", children: "Esc" }),
1738
1832
  " to close"
1739
1833
  ] })
1740
1834
  ] }) })
@@ -1742,19 +1836,19 @@ function KeyboardShortcutsPanel({
1742
1836
  }
1743
1837
 
1744
1838
  // src/hooks/use-auto-save.ts
1745
- import { useEffect as useEffect7, useRef as useRef5, useCallback as useCallback5, useState as useState7 } from "react";
1839
+ import { useEffect as useEffect8, useRef as useRef6, useCallback as useCallback5, useState as useState8 } from "react";
1746
1840
  function useAutoSave({
1747
1841
  data,
1748
1842
  onSave,
1749
1843
  delay = 5e3,
1750
1844
  enabled = true
1751
1845
  }) {
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);
1846
+ const [lastSavedAt, setLastSavedAt] = useState8(null);
1847
+ const [isSaving, setIsSaving] = useState8(false);
1848
+ const [saveError, setSaveError] = useState8(null);
1849
+ const timerRef = useRef6(null);
1850
+ const dataRef = useRef6(data);
1851
+ const savedDataRef = useRef6(null);
1758
1852
  dataRef.current = data;
1759
1853
  const save = useCallback5(async () => {
1760
1854
  const currentJson = JSON.stringify(dataRef.current);
@@ -1771,7 +1865,7 @@ function useAutoSave({
1771
1865
  setIsSaving(false);
1772
1866
  }
1773
1867
  }, [onSave]);
1774
- useEffect7(() => {
1868
+ useEffect8(() => {
1775
1869
  if (!enabled) return;
1776
1870
  if (timerRef.current) clearTimeout(timerRef.current);
1777
1871
  timerRef.current = setTimeout(save, delay);
@@ -1783,18 +1877,18 @@ function useAutoSave({
1783
1877
  }
1784
1878
 
1785
1879
  // src/hooks/use-polling.ts
1786
- import { useEffect as useEffect8, useCallback as useCallback6, useRef as useRef6, useState as useState8 } from "react";
1880
+ import { useEffect as useEffect9, useCallback as useCallback6, useRef as useRef7, useState as useState9 } from "react";
1787
1881
  function usePolling({
1788
1882
  fetcher,
1789
1883
  interval = 3e4,
1790
1884
  enabled = true,
1791
1885
  onError
1792
1886
  }) {
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);
1887
+ const [data, setData] = useState9(null);
1888
+ const [isLoading, setIsLoading] = useState9(true);
1889
+ const [isRefreshing, setIsRefreshing] = useState9(false);
1890
+ const [error, setError] = useState9(null);
1891
+ const mountedRef = useRef7(true);
1798
1892
  const doFetch = useCallback6(async (isInitial = false) => {
1799
1893
  if (isInitial) setIsLoading(true);
1800
1894
  else setIsRefreshing(true);
@@ -1816,14 +1910,14 @@ function usePolling({
1816
1910
  }
1817
1911
  }
1818
1912
  }, [fetcher, onError]);
1819
- useEffect8(() => {
1913
+ useEffect9(() => {
1820
1914
  mountedRef.current = true;
1821
1915
  if (enabled) doFetch(true);
1822
1916
  return () => {
1823
1917
  mountedRef.current = false;
1824
1918
  };
1825
1919
  }, [doFetch, enabled]);
1826
- useEffect8(() => {
1920
+ useEffect9(() => {
1827
1921
  if (!enabled) return;
1828
1922
  const timer = setInterval(() => doFetch(false), interval);
1829
1923
  return () => clearInterval(timer);
@@ -1833,19 +1927,19 @@ function usePolling({
1833
1927
  }
1834
1928
 
1835
1929
  // src/hooks/use-server-search.ts
1836
- import { useEffect as useEffect9, useRef as useRef7, useState as useState9, useCallback as useCallback7 } from "react";
1930
+ import { useEffect as useEffect10, useRef as useRef8, useState as useState10, useCallback as useCallback7 } from "react";
1837
1931
  function useServerSearch({
1838
1932
  fetcher,
1839
1933
  debounce = 150,
1840
1934
  minChars = 1,
1841
1935
  enabled = true
1842
1936
  }) {
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(() => {
1937
+ const [query, setQuery] = useState10("");
1938
+ const [results, setResults] = useState10([]);
1939
+ const [isSearching, setIsSearching] = useState10(false);
1940
+ const [isOpen, setIsOpen] = useState10(false);
1941
+ const timerRef = useRef8(null);
1942
+ useEffect10(() => {
1849
1943
  if (!enabled || query.length < minChars) {
1850
1944
  setResults([]);
1851
1945
  return;
@@ -1875,9 +1969,9 @@ function useServerSearch({
1875
1969
  }
1876
1970
 
1877
1971
  // src/hooks/use-iframe-focus-reclaim.ts
1878
- import { useEffect as useEffect10 } from "react";
1972
+ import { useEffect as useEffect11 } from "react";
1879
1973
  function useIframeFocusReclaim(containerRef, enabled = true, iframeSelector = "iframe") {
1880
- useEffect10(() => {
1974
+ useEffect11(() => {
1881
1975
  if (!enabled) return;
1882
1976
  const el = containerRef.current;
1883
1977
  if (!el) return;
@@ -2058,21 +2152,21 @@ function clearCache() {
2058
2152
  }
2059
2153
 
2060
2154
  // src/hooks/use-preferences.ts
2061
- import { useState as useState10, useEffect as useEffect11, useCallback as useCallback8 } from "react";
2155
+ import { useState as useState11, useEffect as useEffect12, useCallback as useCallback8 } from "react";
2062
2156
  function usePreferences({
2063
2157
  endpoint,
2064
- defaults: defaults2
2158
+ defaults: defaults3
2065
2159
  }) {
2066
- const [preferences, setPreferences] = useState10(defaults2 ?? null);
2067
- const [loading, setLoading] = useState10(true);
2068
- const [error, setError] = useState10(null);
2160
+ const [preferences, setPreferences] = useState11(defaults3 ?? null);
2161
+ const [loading, setLoading] = useState11(true);
2162
+ const [error, setError] = useState11(null);
2069
2163
  const fetchPreferences = useCallback8(async () => {
2070
2164
  try {
2071
2165
  setError(null);
2072
2166
  const res = await fetch(endpoint);
2073
2167
  if (!res.ok) {
2074
2168
  if (res.status === 401) {
2075
- setPreferences(defaults2 ?? null);
2169
+ setPreferences(defaults3 ?? null);
2076
2170
  return;
2077
2171
  }
2078
2172
  throw new Error("Failed to fetch preferences");
@@ -2084,8 +2178,8 @@ function usePreferences({
2084
2178
  } finally {
2085
2179
  setLoading(false);
2086
2180
  }
2087
- }, [endpoint, defaults2]);
2088
- useEffect11(() => {
2181
+ }, [endpoint, defaults3]);
2182
+ useEffect12(() => {
2089
2183
  fetchPreferences();
2090
2184
  }, [fetchPreferences]);
2091
2185
  const updatePreferences = useCallback8(
@@ -2444,6 +2538,7 @@ export {
2444
2538
  ALL_SHORTCUT_CONTEXTS,
2445
2539
  ArchiveButton,
2446
2540
  CLIENT_PROFILE_SHORTCUTS,
2541
+ ConfirmAction,
2447
2542
  EmailBodyRenderer,
2448
2543
  EmailThreadView,
2449
2544
  EntityPicker,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordinatio/ui",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Reusable React components and hooks for Ordinatio applications",