@ordinatio/ui 1.2.0 → 1.3.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.
Files changed (3) hide show
  1. package/dist/index.d.mts +169 -65
  2. package/dist/index.mjs +598 -62
  3. package/package.json +10 -13
package/dist/index.d.mts CHANGED
@@ -156,6 +156,174 @@ interface ArchiveButtonProps {
156
156
  */
157
157
  declare function ArchiveButton({ onArchive, archiving, disabled, label, archivingLabel, className, style, }: ArchiveButtonProps): react_jsx_runtime.JSX.Element;
158
158
 
159
+ interface RichTextEditorProps {
160
+ /**
161
+ * Current HTML content. NOT sanitized by this component — see this
162
+ * file's own top-of-file "SANITIZATION CONTRACT" comment before passing
163
+ * anything other than this component's own onChange output back in.
164
+ * Updated externally (e.g. loading a draft) only applies while the
165
+ * editor is not focused — an external update while the user is actively
166
+ * typing would otherwise clobber their cursor position/in-progress edit.
167
+ */
168
+ content: string;
169
+ /** Called with the editor's current innerHTML on every edit. */
170
+ onChange: (html: string) => void;
171
+ placeholder?: string;
172
+ minHeight?: string;
173
+ maxHeight?: string;
174
+ autoFocus?: boolean;
175
+ /** Disables editing and hides the toolbar — for a read-only/sent state. Still subject to this file's own sanitization contract. */
176
+ editable?: boolean;
177
+ /**
178
+ * Temporarily blocks typing/formatting WITHOUT switching to the
179
+ * `editable={false}` rendering (toolbar and the contentEditable region
180
+ * stay mounted and visible, just inert) — for a brief, in-progress state
181
+ * like "a send is in flight" where `editable={false}`'s structural
182
+ * remount (see that prop's own branch) is the wrong tool: toggling the
183
+ * whole JSX branch gives the contentEditable region a BRAND NEW DOM node
184
+ * on the way back to editable, and this component's content-sync effect
185
+ * only re-populates a node it already knows changed, which byte-for-byte
186
+ * reproduced a real bug (WorldClass cycle 2) — a user's own just-typed
187
+ * content silently emptying out the moment a brief lock-then-unlock
188
+ * cycle completed. `locked` sets the DOM `contentEditable` attribute to
189
+ * false on the SAME node instead, so there is nothing to re-sync.
190
+ * Ignored when `editable={false}` (WorldClass cycle 3) — the read-only
191
+ * branch already has nothing interactive to lock, so `editable={false}`
192
+ * always wins if both are set.
193
+ */
194
+ locked?: boolean;
195
+ /**
196
+ * Optional extra toolbar content, right-aligned (e.g. a template picker
197
+ * in a consuming app). NOT covered by `locked` (WorldClass cycle 3) —
198
+ * this is arbitrary consumer-supplied content, not one of this
199
+ * component's own buttons, so there's nothing here for `locked` to
200
+ * reach; a consumer whose own toolbarRight content should also go inert
201
+ * while `locked` is set needs to gate that itself.
202
+ */
203
+ toolbarRight?: ReactNode;
204
+ /**
205
+ * Root-element override, matching ArchiveButton's own established
206
+ * contract: when given, the component renders "naked" (no inline
207
+ * defaults) on the ROOT element only. Unlike ArchiveButton (a single
208
+ * `<button>` with no internal structure), this component has real
209
+ * internal structure — a toolbar, buttons, the editable region — none of
210
+ * which `className`/`style` reach. Every sub-element instead carries a
211
+ * stable `ordinatio-rte-*` class (see each one below) specifically so
212
+ * external CSS can retheme them regardless of whether `className` is
213
+ * also set; there is no prop-level override for each sub-element.
214
+ */
215
+ className?: string;
216
+ style?: CSSProperties;
217
+ }
218
+ /**
219
+ * True when HTML has no visible text content (an empty editor's own
220
+ * innerHTML, e.g. "<br>" or "<p></p>"). Decodes &nbsp; (WorldClass cycle
221
+ * 1 — many browsers render a typed space in a contentEditable as a literal
222
+ * &nbsp; entity, not U+0020; stripping tags without decoding it left an
223
+ * &nbsp;-only body reading as non-empty text, silently enabling Send on a
224
+ * visually blank reply). Exported so ReplyPanel reuses this exact
225
+ * definition instead of carrying its own, independently-driftable copy.
226
+ */
227
+ declare function isEmptyHtml(html: string): boolean;
228
+ declare function RichTextEditor({ content, onChange, placeholder, minHeight, maxHeight, autoFocus, editable, locked, toolbarRight, className, style, }: RichTextEditorProps): react_jsx_runtime.JSX.Element;
229
+
230
+ /**
231
+ * Email compose mode — reply pre-fills the recipient,
232
+ * forward starts with an empty To field.
233
+ */
234
+ type ComposeMode = 'reply' | 'forward';
235
+ /**
236
+ * Reply layout modes for email detail pages.
237
+ * Controls how the compose panel is rendered.
238
+ */
239
+ type ReplyLayout = 'MODAL' | 'SPLIT_HORIZONTAL' | 'SPLIT_VERTICAL' | 'POPOUT';
240
+ /**
241
+ * All available reply layout options with labels for dropdowns.
242
+ */
243
+ declare const REPLY_LAYOUT_OPTIONS: {
244
+ value: ReplyLayout;
245
+ label: string;
246
+ }[];
247
+ /**
248
+ * Check if the layout renders the compose panel inline (not in a dialog).
249
+ */
250
+ declare function isInlineLayout(layout: ReplyLayout): boolean;
251
+ /**
252
+ * Check if the layout renders the compose panel in a dialog/modal.
253
+ */
254
+ declare function isModalLayout(layout: ReplyLayout): boolean;
255
+ /**
256
+ * Check if the layout opens compose in a new browser window.
257
+ */
258
+ declare function isPopoutLayout(layout: ReplyLayout): boolean;
259
+ interface SchedulePreset {
260
+ label: string;
261
+ date: Date;
262
+ }
263
+ /**
264
+ * Get the next occurrence of a weekday (Mon=1 ... Sun=0) at a given hour.
265
+ * If today matches but the hour has passed, returns next week.
266
+ */
267
+ declare function getNextWeekday(dayOfWeek: number, hour: number): Date;
268
+ /** Tomorrow at 9:00 AM local time. */
269
+ declare function getTomorrowMorning(): Date;
270
+ /** Next Monday at 9:00 AM local time. */
271
+ declare function getNextMondayMorning(): Date;
272
+ /**
273
+ * Quick schedule presets for "Send Later" UIs.
274
+ * Returns relative options (1h, 2h, tomorrow 9am, etc.).
275
+ *
276
+ * @example
277
+ * const options = getQuickScheduleOptions();
278
+ * // [{ label: "In 1 hour", date: Date }, ...]
279
+ */
280
+ declare function getQuickScheduleOptions(): SchedulePreset[];
281
+ /**
282
+ * Validate that a scheduled date is in the future.
283
+ */
284
+ declare function isValidScheduleDate(date: Date): boolean;
285
+ /**
286
+ * Parse a custom schedule from separate date and time strings.
287
+ * Returns null if invalid or in the past.
288
+ *
289
+ * @param dateStr - Date in YYYY-MM-DD format
290
+ * @param timeStr - Time in HH:MM format (default: "09:00")
291
+ */
292
+ declare function parseCustomSchedule(dateStr: string, timeStr?: string): Date | null;
293
+
294
+ interface ReplySendOverrides {
295
+ to?: string;
296
+ cc?: string;
297
+ bcc?: string;
298
+ subject?: string;
299
+ }
300
+ interface ReplyPanelProps {
301
+ /** 'reply' pre-fills To with the original sender; 'forward' starts with an empty To. */
302
+ mode?: ComposeMode;
303
+ /** The original message's subject — the panel strips any existing Re:/Fwd: prefix (case-insensitively) and applies its own mode's prefix exactly once; see prefixSubject's own doc comment for what this does and doesn't cover. */
304
+ subject: string;
305
+ /** Default To value for reply mode — the original sender's display name or email. Ignored in forward mode. */
306
+ toName: string;
307
+ /** Default To value for reply mode, preferred over toName when both are given (a real address, not just a display string). */
308
+ toEmail?: string;
309
+ /** Initial Cc value — e.g. the other original recipients, for a reply-all entry point. */
310
+ initialCc?: string;
311
+ /** Show the Cc/Bcc fields expanded from the start (e.g. already arriving as a reply-all). */
312
+ initialShowCcBcc?: boolean;
313
+ /** Called with the body HTML and any overrides the user actually changed (each field is undefined, not an empty string, when left at its default — so the caller only need pass what's genuinely different). */
314
+ onSend: (body: string, overrides: ReplySendOverrides) => Promise<void>;
315
+ /** Shown briefly after a successful send. Default: a generic per-mode confirmation. Pass '' to suppress it entirely. */
316
+ successMessage?: string;
317
+ onCancel?: () => void;
318
+ showCancel?: boolean;
319
+ sendButtonText?: string;
320
+ initialBody?: string;
321
+ /** Root-element override — see RichTextEditor's own identical contract (stable `ordinatio-reply-*` classes on every sub-element, not just the one `className`-targeted root). */
322
+ className?: string;
323
+ style?: CSSProperties;
324
+ }
325
+ declare function ReplyPanel({ mode, subject, toName, toEmail, initialCc, initialShowCcBcc, onSend, successMessage, onCancel, showCancel, sendButtonText, initialBody, className, style, }: ReplyPanelProps): react_jsx_runtime.JSX.Element;
326
+
159
327
  interface KeyboardShortcut {
160
328
  /** Key to listen for (e.g., 'r', 'e', 'Escape'). Case-insensitive. */
161
329
  key: string;
@@ -554,70 +722,6 @@ declare function truncatePreview(text: string | null | undefined, limit?: number
554
722
  */
555
723
  declare function stripHtml(html: string): string;
556
724
 
557
- /**
558
- * Email compose mode — reply pre-fills the recipient,
559
- * forward starts with an empty To field.
560
- */
561
- type ComposeMode = 'reply' | 'forward';
562
- /**
563
- * Reply layout modes for email detail pages.
564
- * Controls how the compose panel is rendered.
565
- */
566
- type ReplyLayout = 'MODAL' | 'SPLIT_HORIZONTAL' | 'SPLIT_VERTICAL' | 'POPOUT';
567
- /**
568
- * All available reply layout options with labels for dropdowns.
569
- */
570
- declare const REPLY_LAYOUT_OPTIONS: {
571
- value: ReplyLayout;
572
- label: string;
573
- }[];
574
- /**
575
- * Check if the layout renders the compose panel inline (not in a dialog).
576
- */
577
- declare function isInlineLayout(layout: ReplyLayout): boolean;
578
- /**
579
- * Check if the layout renders the compose panel in a dialog/modal.
580
- */
581
- declare function isModalLayout(layout: ReplyLayout): boolean;
582
- /**
583
- * Check if the layout opens compose in a new browser window.
584
- */
585
- declare function isPopoutLayout(layout: ReplyLayout): boolean;
586
- interface SchedulePreset {
587
- label: string;
588
- date: Date;
589
- }
590
- /**
591
- * Get the next occurrence of a weekday (Mon=1 ... Sun=0) at a given hour.
592
- * If today matches but the hour has passed, returns next week.
593
- */
594
- declare function getNextWeekday(dayOfWeek: number, hour: number): Date;
595
- /** Tomorrow at 9:00 AM local time. */
596
- declare function getTomorrowMorning(): Date;
597
- /** Next Monday at 9:00 AM local time. */
598
- declare function getNextMondayMorning(): Date;
599
- /**
600
- * Quick schedule presets for "Send Later" UIs.
601
- * Returns relative options (1h, 2h, tomorrow 9am, etc.).
602
- *
603
- * @example
604
- * const options = getQuickScheduleOptions();
605
- * // [{ label: "In 1 hour", date: Date }, ...]
606
- */
607
- declare function getQuickScheduleOptions(): SchedulePreset[];
608
- /**
609
- * Validate that a scheduled date is in the future.
610
- */
611
- declare function isValidScheduleDate(date: Date): boolean;
612
- /**
613
- * Parse a custom schedule from separate date and time strings.
614
- * Returns null if invalid or in the past.
615
- *
616
- * @param dateStr - Date in YYYY-MM-DD format
617
- * @param timeStr - Time in HH:MM format (default: "09:00")
618
- */
619
- declare function parseCustomSchedule(dateStr: string, timeStr?: string): Date | null;
620
-
621
725
  /**
622
726
  * Check if a file is a PDF by MIME type or file extension.
623
727
  * Handles Gmail's `application/octet-stream` by checking `.pdf` extension.
@@ -723,4 +827,4 @@ declare const ACTIVITY_ICONS: Record<string, IconComponent>;
723
827
  /** Return the icon component for a given icon name, or Activity as fallback. */
724
828
  declare function resolveActivityIcon(name: string): IconComponent;
725
829
 
726
- export { ACTIVITY_ICONS, ALL_SHORTCUT_CONTEXTS, ArchiveButton, type ArchiveButtonProps, CLIENT_PROFILE_SHORTCUTS, type CachedFetchOptions, type ComposeMode, EmailBodyRenderer, type EmailBodyRendererProps, EmailThreadView, type EmailThreadViewProps, ErrorBoundary, type ErrorBoundaryProps, FORM_SHORTCUTS, GLOBAL_SHORTCUTS, INBOX_SHORTCUTS, type KeyboardShortcut, KeyboardShortcutsPanel, RENDER_ERRORS, REPLY_LAYOUT_OPTIONS, type RenderErrorResult, type ReplyLayout, 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, 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 };
830
+ export { ACTIVITY_ICONS, ALL_SHORTCUT_CONTEXTS, ArchiveButton, type ArchiveButtonProps, CLIENT_PROFILE_SHORTCUTS, type CachedFetchOptions, type ComposeMode, EmailBodyRenderer, type EmailBodyRendererProps, EmailThreadView, type EmailThreadViewProps, ErrorBoundary, type ErrorBoundaryProps, FORM_SHORTCUTS, GLOBAL_SHORTCUTS, INBOX_SHORTCUTS, type KeyboardShortcut, KeyboardShortcutsPanel, RENDER_ERRORS, REPLY_LAYOUT_OPTIONS, type RenderErrorResult, type ReplyLayout, ReplyPanel, type ReplyPanelProps, type ReplySendOverrides, RichTextEditor, type RichTextEditorProps, type SchedulePreset, type ShortcutContext, type ShortcutDefinition, type ThreadMessage, type UseAutoSaveOptions, type UseAutoSaveResult, type UseKeyboardShortcutsOptions, type UsePollingOptions, type UsePollingResult, type UsePreferencesOptions, type UsePreferencesResult, type UseServerSearchOptions, type UseServerSearchResult, cachedFetch, canViewInline, clearCache, formatDateGroup, formatFileSize, formatPhone, formatPhoneInput, getNextMondayMorning, getNextWeekday, getQuickScheduleOptions, getShortcut, getTomorrowMorning, groupByDate, invalidateCache, isAudio, isDocument, isEmptyHtml, isImage, isInlineLayout, isModalLayout, isPdf, isPopoutLayout, isSpreadsheet, isTypingContext, isValidScheduleDate, isVideo, opensInNewTab, parseCustomSchedule, prefetch, renderError, resolveActivityIcon, resolveContentType, stripHtml, stripPhone, truncatePreview, useAutoSave, useContextShortcuts, useIframeFocusReclaim, useKeyboardShortcuts, usePolling, usePreferences, useServerSearch, withErrorBoundary };
package/dist/index.mjs CHANGED
@@ -374,7 +374,7 @@ function EmailBodyRenderer({
374
374
  keyCleanupRef.current?.();
375
375
  };
376
376
  }, []);
377
- const containerStyle = {
377
+ const containerStyle2 = {
378
378
  border: "1px solid #e5e7eb",
379
379
  borderRadius: "8px",
380
380
  backgroundColor: "#ffffff",
@@ -416,7 +416,7 @@ function EmailBodyRenderer({
416
416
  const css = iframeStyles ?? DEFAULT_IFRAME_STYLES;
417
417
  const csp = buildIframeCSP(imagePolicy);
418
418
  const srcDoc = `<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${csp}"><base target="_blank"><style>${css}</style></head><body>${cleanHtml}</body></html>`;
419
- return /* @__PURE__ */ jsxs2("div", { className, style: containerStyle, children: [
419
+ return /* @__PURE__ */ jsxs2("div", { className, style: containerStyle2, children: [
420
420
  showPrivacyBanner && /* @__PURE__ */ jsxs2("div", { style: {
421
421
  display: "flex",
422
422
  alignItems: "center",
@@ -468,7 +468,7 @@ function EmailBodyRenderer({
468
468
  ] });
469
469
  }
470
470
  if (bodyText) {
471
- return /* @__PURE__ */ jsx2("div", { className, style: containerStyle, children: /* @__PURE__ */ jsx2("pre", { style: {
471
+ return /* @__PURE__ */ jsx2("div", { className, style: containerStyle2, children: /* @__PURE__ */ jsx2("pre", { style: {
472
472
  whiteSpace: "pre-wrap",
473
473
  fontFamily: "system-ui, sans-serif",
474
474
  padding: "16px",
@@ -477,7 +477,7 @@ function EmailBodyRenderer({
477
477
  }, children: bodyText }) });
478
478
  }
479
479
  if (snippet) {
480
- return /* @__PURE__ */ jsx2("div", { className, style: containerStyle, children: /* @__PURE__ */ jsx2("p", { style: { padding: "16px", margin: 0, color: "#6b7280", fontSize: "14px" }, children: snippet }) });
480
+ return /* @__PURE__ */ jsx2("div", { className, style: containerStyle2, children: /* @__PURE__ */ jsx2("p", { style: { padding: "16px", margin: 0, color: "#6b7280", fontSize: "14px" }, children: snippet }) });
481
481
  }
482
482
  return null;
483
483
  }
@@ -693,8 +693,541 @@ function ArchiveButton({
693
693
  );
694
694
  }
695
695
 
696
+ // src/components/rich-text-editor.tsx
697
+ import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
698
+
699
+ // src/components/rich-text-editor-styles.ts
700
+ var containerStyle = {
701
+ border: "1px solid #d4d4d4",
702
+ borderRadius: "6px",
703
+ backgroundColor: "#ffffff"
704
+ };
705
+ var toolbarStyle = {
706
+ display: "flex",
707
+ alignItems: "center",
708
+ gap: "4px",
709
+ padding: "6px 8px",
710
+ borderBottom: "1px solid #e5e5e5"
711
+ };
712
+ var toolbarButtonStyle = {
713
+ display: "inline-flex",
714
+ alignItems: "center",
715
+ justifyContent: "center",
716
+ minWidth: "28px",
717
+ height: "28px",
718
+ padding: "0 6px",
719
+ fontSize: "13px",
720
+ fontWeight: 600,
721
+ border: "1px solid transparent",
722
+ borderRadius: "4px",
723
+ backgroundColor: "transparent",
724
+ color: "#171717",
725
+ cursor: "pointer"
726
+ };
727
+ var lockedToolbarButtonStyle = {
728
+ opacity: 0.4,
729
+ cursor: "not-allowed"
730
+ };
731
+ var toolbarRightStyle = {
732
+ marginLeft: "auto"
733
+ };
734
+ var linkErrorStyle = {
735
+ padding: "6px 8px",
736
+ fontSize: "12px",
737
+ color: "#dc2626",
738
+ backgroundColor: "#fef2f2"
739
+ };
740
+ var editableStyle = {
741
+ padding: "8px 12px",
742
+ fontSize: "14px",
743
+ lineHeight: 1.5,
744
+ color: "#171717",
745
+ outline: "none",
746
+ overflowY: "auto"
747
+ };
748
+
749
+ // src/components/rich-text-editor.tsx
750
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
751
+ var TOOLBAR_BUTTONS = [
752
+ { command: "bold", label: "B", ariaLabel: "Bold" },
753
+ { command: "italic", label: "I", ariaLabel: "Italic" },
754
+ { command: "underline", label: "U", ariaLabel: "Underline" },
755
+ { command: "insertUnorderedList", label: "\u2022", ariaLabel: "Bulleted list" },
756
+ { command: "insertOrderedList", label: "1.", ariaLabel: "Numbered list" }
757
+ ];
758
+ var ALLOWED_LINK_SCHEMES = ["http:", "https:", "mailto:"];
759
+ function isSafeLinkUrl(url) {
760
+ try {
761
+ return ALLOWED_LINK_SCHEMES.includes(new URL(url).protocol);
762
+ } catch {
763
+ return true;
764
+ }
765
+ }
766
+ function isEmptyHtml(html) {
767
+ return !html.replace(/<[^>]*>/g, "").replace(/&nbsp;/gi, " ").trim();
768
+ }
769
+ function RichTextEditor({
770
+ content,
771
+ onChange,
772
+ placeholder = "Start typing\u2026",
773
+ minHeight = "120px",
774
+ maxHeight = "400px",
775
+ autoFocus = false,
776
+ editable = true,
777
+ locked = false,
778
+ toolbarRight,
779
+ className,
780
+ style
781
+ }) {
782
+ const editorRef = useRef2(null);
783
+ const [isFocused, setIsFocused] = useState3(false);
784
+ const [isEmpty, setIsEmpty] = useState3(isEmptyHtml(content));
785
+ const [linkError, setLinkError] = useState3(null);
786
+ useEffect2(() => {
787
+ const el = editorRef.current;
788
+ if (el && !isFocused && el.innerHTML !== content) {
789
+ el.innerHTML = content;
790
+ setIsEmpty(isEmptyHtml(content));
791
+ }
792
+ }, [content, isFocused, editable]);
793
+ useEffect2(() => {
794
+ if (autoFocus) editorRef.current?.focus();
795
+ }, []);
796
+ const handleInput = useCallback2(() => {
797
+ const html = editorRef.current?.innerHTML ?? "";
798
+ setIsEmpty(isEmptyHtml(html));
799
+ onChange(html);
800
+ }, [onChange]);
801
+ const runCommand = useCallback2(
802
+ (command, value) => {
803
+ editorRef.current?.focus();
804
+ document.execCommand(command, false, value);
805
+ handleInput();
806
+ },
807
+ [handleInput]
808
+ );
809
+ const handleLink = useCallback2(() => {
810
+ const url = window.prompt("Link URL")?.trim();
811
+ setLinkError(null);
812
+ if (!url) return;
813
+ if (!isSafeLinkUrl(url)) {
814
+ setLinkError("That link type is not allowed. Use an http(s) or mailto link.");
815
+ return;
816
+ }
817
+ runCommand("createLink", url);
818
+ }, [runCommand]);
819
+ if (!editable) {
820
+ return /* @__PURE__ */ jsx5(
821
+ "div",
822
+ {
823
+ className: [className, "ordinatio-rte", "ordinatio-rte-readonly"].filter(Boolean).join(" "),
824
+ style: className ? style : { ...editableStyle, ...style },
825
+ dangerouslySetInnerHTML: { __html: content }
826
+ }
827
+ );
828
+ }
829
+ return /* @__PURE__ */ jsxs4("div", { className: [className, "ordinatio-rte"].filter(Boolean).join(" "), style: className ? style : { ...containerStyle, ...style }, children: [
830
+ /* @__PURE__ */ jsxs4("div", { className: "ordinatio-rte-toolbar", style: toolbarStyle, children: [
831
+ TOOLBAR_BUTTONS.map((btn) => /* @__PURE__ */ jsx5(
832
+ "button",
833
+ {
834
+ type: "button",
835
+ className: "ordinatio-rte-toolbar-button",
836
+ "aria-label": btn.ariaLabel,
837
+ disabled: locked,
838
+ onMouseDown: (e) => e.preventDefault(),
839
+ onClick: () => runCommand(btn.command, btn.value),
840
+ style: locked ? { ...toolbarButtonStyle, ...lockedToolbarButtonStyle } : toolbarButtonStyle,
841
+ children: btn.label
842
+ },
843
+ btn.command
844
+ )),
845
+ /* @__PURE__ */ jsx5(
846
+ "button",
847
+ {
848
+ type: "button",
849
+ className: "ordinatio-rte-toolbar-button",
850
+ "aria-label": "Insert link",
851
+ disabled: locked,
852
+ onMouseDown: (e) => e.preventDefault(),
853
+ onClick: handleLink,
854
+ style: locked ? { ...toolbarButtonStyle, ...lockedToolbarButtonStyle } : toolbarButtonStyle,
855
+ children: "\u{1F517}"
856
+ }
857
+ ),
858
+ toolbarRight ? /* @__PURE__ */ jsx5("div", { className: "ordinatio-rte-toolbar-right", style: toolbarRightStyle, children: toolbarRight }) : null
859
+ ] }),
860
+ linkError ? /* @__PURE__ */ jsx5("div", { className: "ordinatio-rte-link-error", role: "alert", style: linkErrorStyle, children: linkError }) : null,
861
+ /* @__PURE__ */ jsxs4("div", { className: "ordinatio-rte-editable-wrap", style: { position: "relative" }, children: [
862
+ isEmpty ? (
863
+ // Shown while empty REGARDLESS of focus — WorldClass cycle 1:
864
+ // the prior `isEmpty && !isFocused` condition hid the
865
+ // placeholder the instant an empty editor was clicked, before
866
+ // any typing, leaving a totally blank box with no confirmation
867
+ // the click landed. Matches native `<textarea placeholder>`
868
+ // behavior (visible while focused-and-empty, removed only once
869
+ // the user types).
870
+ /* @__PURE__ */ jsx5(
871
+ "div",
872
+ {
873
+ "aria-hidden": "true",
874
+ className: "ordinatio-rte-placeholder",
875
+ style: { ...editableStyle, position: "absolute", inset: 0, color: "#a3a3a3", pointerEvents: "none" },
876
+ children: placeholder
877
+ }
878
+ )
879
+ ) : null,
880
+ /* @__PURE__ */ jsx5(
881
+ "div",
882
+ {
883
+ ref: editorRef,
884
+ role: "textbox",
885
+ "aria-multiline": "true",
886
+ "aria-label": placeholder,
887
+ "aria-disabled": locked,
888
+ className: "ordinatio-rte-editable",
889
+ contentEditable: !locked,
890
+ suppressContentEditableWarning: true,
891
+ onInput: handleInput,
892
+ onFocus: () => setIsFocused(true),
893
+ onBlur: () => setIsFocused(false),
894
+ style: locked ? { ...editableStyle, minHeight, maxHeight, opacity: 0.6 } : { ...editableStyle, minHeight, maxHeight }
895
+ }
896
+ )
897
+ ] })
898
+ ] });
899
+ }
900
+
901
+ // src/components/reply-panel.tsx
902
+ import { useEffect as useEffect3, useId, useRef as useRef3, useState as useState4 } from "react";
903
+
904
+ // src/components/subject-prefix.ts
905
+ function prefixSubject(subject, mode) {
906
+ const prefix = mode === "forward" ? "Fwd" : "Re";
907
+ let stripped = subject.trim();
908
+ let previous;
909
+ do {
910
+ previous = stripped;
911
+ stripped = stripped.replace(/^(re|fwd?)\s*:\s*/i, "").trim();
912
+ } while (stripped !== previous);
913
+ return `${prefix}: ${stripped}`;
914
+ }
915
+
916
+ // src/components/reply-panel-styles.ts
917
+ var fieldRowStyle = {
918
+ display: "flex",
919
+ alignItems: "center",
920
+ gap: "8px"
921
+ };
922
+ var fieldLabelStyle = {
923
+ fontSize: "12px",
924
+ color: "#737373",
925
+ width: "32px",
926
+ flexShrink: 0
927
+ };
928
+ var fieldInputStyle = {
929
+ flex: 1,
930
+ border: "1px solid #d4d4d4",
931
+ borderRadius: "4px",
932
+ padding: "6px 8px",
933
+ fontSize: "13px",
934
+ color: "#171717",
935
+ outline: "none"
936
+ };
937
+ var ccBccToggleStyle = {
938
+ fontSize: "12px",
939
+ color: "#2563eb",
940
+ background: "none",
941
+ border: "none",
942
+ cursor: "pointer",
943
+ marginLeft: "auto",
944
+ flexShrink: 0
945
+ };
946
+ var errorStyle = {
947
+ backgroundColor: "#fef2f2",
948
+ color: "#dc2626",
949
+ padding: "8px",
950
+ borderRadius: "6px",
951
+ fontSize: "13px"
952
+ };
953
+ var successStyle = {
954
+ backgroundColor: "#f0fdf4",
955
+ color: "#16a34a",
956
+ padding: "8px",
957
+ borderRadius: "6px",
958
+ fontSize: "13px"
959
+ };
960
+ var actionsRowStyle = {
961
+ display: "flex",
962
+ alignItems: "center",
963
+ justifyContent: "flex-end",
964
+ gap: "8px"
965
+ };
966
+ var cancelButtonStyle = {
967
+ padding: "8px 16px",
968
+ fontSize: "14px",
969
+ fontWeight: 500,
970
+ borderRadius: "6px",
971
+ border: "1px solid #d4d4d4",
972
+ backgroundColor: "#ffffff",
973
+ color: "#171717",
974
+ cursor: "pointer"
975
+ };
976
+ var sendButtonStyle = {
977
+ padding: "8px 16px",
978
+ fontSize: "14px",
979
+ fontWeight: 500,
980
+ borderRadius: "6px",
981
+ border: "1px solid transparent",
982
+ backgroundColor: "#171717",
983
+ color: "#ffffff",
984
+ cursor: "pointer"
985
+ };
986
+ var disabledButtonStyle = {
987
+ opacity: 0.5,
988
+ cursor: "not-allowed"
989
+ };
990
+
991
+ // src/components/reply-panel.tsx
992
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
993
+ function ReplyPanel({
994
+ mode = "reply",
995
+ subject,
996
+ toName,
997
+ toEmail,
998
+ initialCc = "",
999
+ initialShowCcBcc = false,
1000
+ onSend,
1001
+ successMessage,
1002
+ onCancel,
1003
+ showCancel = true,
1004
+ sendButtonText,
1005
+ initialBody = "",
1006
+ className,
1007
+ style
1008
+ }) {
1009
+ const defaultTo = mode === "reply" ? toEmail || toName : "";
1010
+ const defaultSubject = prefixSubject(subject, mode);
1011
+ const idPrefix = useId();
1012
+ const toId = `${idPrefix}-to`;
1013
+ const ccId = `${idPrefix}-cc`;
1014
+ const bccId = `${idPrefix}-bcc`;
1015
+ const subjectId = `${idPrefix}-subject`;
1016
+ const [to, setTo] = useState4(defaultTo);
1017
+ const [cc, setCc] = useState4(initialCc);
1018
+ const [bcc, setBcc] = useState4("");
1019
+ const [showCcBcc, setShowCcBcc] = useState4(initialShowCcBcc || !!initialCc);
1020
+ const [editedSubject, setEditedSubject] = useState4(defaultSubject);
1021
+ const [body, setBody] = useState4(initialBody);
1022
+ const [sending, setSending] = useState4(false);
1023
+ const [error, setError] = useState4(null);
1024
+ const [sent, setSent] = useState4(false);
1025
+ const isMountedRef = useRef3(true);
1026
+ useEffect3(() => {
1027
+ isMountedRef.current = true;
1028
+ return () => {
1029
+ isMountedRef.current = false;
1030
+ };
1031
+ }, []);
1032
+ const resolvedSendLabel = sendButtonText ?? (mode === "reply" ? "Send reply" : "Forward");
1033
+ const resolvedSuccessMessage = successMessage ?? (mode === "reply" ? "\u2713 Reply sent." : "\u2713 Forwarded.");
1034
+ const isSendDisabled = sending || mode === "reply" && isEmptyHtml(body) || mode === "forward" && !to.trim();
1035
+ const handleSend = async () => {
1036
+ if (mode === "forward" && !to.trim()) {
1037
+ setError("Please enter a recipient email address");
1038
+ return;
1039
+ }
1040
+ if (mode === "reply" && isEmptyHtml(body)) return;
1041
+ setSending(true);
1042
+ setError(null);
1043
+ setSent(false);
1044
+ try {
1045
+ await onSend(body, {
1046
+ to: to !== defaultTo ? to.trim() : void 0,
1047
+ cc: cc !== initialCc ? cc.trim() : void 0,
1048
+ // bcc's own default is always '' (no initialBcc prop exists) —
1049
+ // compared the same way as its siblings (WorldClass cycle 3: a
1050
+ // prior version checked `bcc.trim()` truthiness instead, which
1051
+ // reported a whitespace-only Bcc as "untouched" rather than
1052
+ // "deliberately cleared," an inconsistency with how to/cc/subject
1053
+ // treat the identical shape of edit).
1054
+ bcc: bcc !== "" ? bcc.trim() : void 0,
1055
+ subject: editedSubject !== defaultSubject ? editedSubject.trim() : void 0
1056
+ });
1057
+ if (!isMountedRef.current) return;
1058
+ setTo(defaultTo);
1059
+ setCc(initialCc);
1060
+ setBcc("");
1061
+ setEditedSubject(defaultSubject);
1062
+ setBody("");
1063
+ setSent(true);
1064
+ } catch (err) {
1065
+ if (!isMountedRef.current) return;
1066
+ setError(err instanceof Error ? err.message : `Failed to ${mode === "forward" ? "forward" : "send reply"}.`);
1067
+ } finally {
1068
+ if (isMountedRef.current) setSending(false);
1069
+ }
1070
+ };
1071
+ return /* @__PURE__ */ jsxs5(
1072
+ "div",
1073
+ {
1074
+ className: [className, "ordinatio-reply-panel"].filter(Boolean).join(" "),
1075
+ style: className ? style : { display: "flex", flexDirection: "column", gap: "8px", ...style },
1076
+ children: [
1077
+ /* @__PURE__ */ jsxs5("div", { className: "ordinatio-reply-fields", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
1078
+ /* @__PURE__ */ jsxs5("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1079
+ /* @__PURE__ */ jsx6("label", { htmlFor: toId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "To" }),
1080
+ /* @__PURE__ */ jsx6(
1081
+ "input",
1082
+ {
1083
+ id: toId,
1084
+ type: "text",
1085
+ className: "ordinatio-reply-field-input",
1086
+ value: to,
1087
+ onChange: (e) => {
1088
+ setTo(e.target.value);
1089
+ setSent(false);
1090
+ setError(null);
1091
+ },
1092
+ placeholder: "recipient@example.com",
1093
+ autoFocus: mode === "forward",
1094
+ disabled: sending,
1095
+ style: fieldInputStyle
1096
+ }
1097
+ ),
1098
+ !showCcBcc ? (
1099
+ // Deliberately no aria-expanded/aria-controls (WorldClass
1100
+ // cycle 5 — a cycle-4 version added both, then cycle 5's own
1101
+ // review found they asserted a bidirectional disclosure
1102
+ // relationship this button doesn't actually have: it only
1103
+ // ever renders in the collapsed state — see this ternary's own
1104
+ // condition — so aria-expanded could only ever read `false`,
1105
+ // and aria-controls referenced ids (ccId/bccId) that don't
1106
+ // exist in the DOM until AFTER this button has already
1107
+ // unmounted. A one-directional reveal, not a toggle.
1108
+ /* @__PURE__ */ jsx6(
1109
+ "button",
1110
+ {
1111
+ type: "button",
1112
+ className: "ordinatio-reply-ccbcc-toggle",
1113
+ onClick: () => setShowCcBcc(true),
1114
+ disabled: sending,
1115
+ style: ccBccToggleStyle,
1116
+ children: "Cc/Bcc"
1117
+ }
1118
+ )
1119
+ ) : null
1120
+ ] }),
1121
+ showCcBcc ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
1122
+ /* @__PURE__ */ jsxs5("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1123
+ /* @__PURE__ */ jsx6("label", { htmlFor: ccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Cc" }),
1124
+ /* @__PURE__ */ jsx6(
1125
+ "input",
1126
+ {
1127
+ id: ccId,
1128
+ type: "text",
1129
+ className: "ordinatio-reply-field-input",
1130
+ value: cc,
1131
+ onChange: (e) => {
1132
+ setCc(e.target.value);
1133
+ setSent(false);
1134
+ setError(null);
1135
+ },
1136
+ placeholder: "cc@example.com",
1137
+ disabled: sending,
1138
+ style: fieldInputStyle
1139
+ }
1140
+ )
1141
+ ] }),
1142
+ /* @__PURE__ */ jsxs5("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1143
+ /* @__PURE__ */ jsx6("label", { htmlFor: bccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Bcc" }),
1144
+ /* @__PURE__ */ jsx6(
1145
+ "input",
1146
+ {
1147
+ id: bccId,
1148
+ type: "text",
1149
+ className: "ordinatio-reply-field-input",
1150
+ value: bcc,
1151
+ onChange: (e) => {
1152
+ setBcc(e.target.value);
1153
+ setSent(false);
1154
+ setError(null);
1155
+ },
1156
+ placeholder: "bcc@example.com",
1157
+ disabled: sending,
1158
+ style: fieldInputStyle
1159
+ }
1160
+ )
1161
+ ] })
1162
+ ] }) : null,
1163
+ /* @__PURE__ */ jsxs5("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1164
+ /* @__PURE__ */ jsx6("label", { htmlFor: subjectId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Subject" }),
1165
+ /* @__PURE__ */ jsx6(
1166
+ "input",
1167
+ {
1168
+ id: subjectId,
1169
+ type: "text",
1170
+ className: "ordinatio-reply-field-input",
1171
+ value: editedSubject,
1172
+ onChange: (e) => {
1173
+ setEditedSubject(e.target.value);
1174
+ setSent(false);
1175
+ setError(null);
1176
+ },
1177
+ placeholder: "Subject",
1178
+ disabled: sending,
1179
+ style: fieldInputStyle
1180
+ }
1181
+ )
1182
+ ] })
1183
+ ] }),
1184
+ error ? /* @__PURE__ */ jsx6("div", { className: "ordinatio-reply-error", role: "alert", style: errorStyle, children: error }) : null,
1185
+ sent && resolvedSuccessMessage ? /* @__PURE__ */ jsx6("div", { className: "ordinatio-reply-success", role: "status", style: successStyle, children: resolvedSuccessMessage }) : null,
1186
+ /* @__PURE__ */ jsx6(
1187
+ RichTextEditor,
1188
+ {
1189
+ content: body,
1190
+ onChange: (html) => {
1191
+ setBody(html);
1192
+ setSent(false);
1193
+ setError(null);
1194
+ },
1195
+ placeholder: mode === "forward" ? "Add a message\u2026" : "Write your reply\u2026",
1196
+ autoFocus: mode !== "forward",
1197
+ locked: sending
1198
+ }
1199
+ ),
1200
+ /* @__PURE__ */ jsxs5("div", { className: "ordinatio-reply-actions", style: actionsRowStyle, children: [
1201
+ showCancel && onCancel ? /* @__PURE__ */ jsx6(
1202
+ "button",
1203
+ {
1204
+ type: "button",
1205
+ className: "ordinatio-reply-cancel-button",
1206
+ onClick: onCancel,
1207
+ disabled: sending,
1208
+ style: sending ? { ...cancelButtonStyle, ...disabledButtonStyle } : cancelButtonStyle,
1209
+ children: "Cancel"
1210
+ }
1211
+ ) : null,
1212
+ /* @__PURE__ */ jsx6(
1213
+ "button",
1214
+ {
1215
+ type: "button",
1216
+ className: "ordinatio-reply-send-button",
1217
+ onClick: handleSend,
1218
+ disabled: isSendDisabled,
1219
+ style: isSendDisabled ? { ...sendButtonStyle, ...disabledButtonStyle } : sendButtonStyle,
1220
+ children: sending ? "Sending\u2026" : resolvedSendLabel
1221
+ }
1222
+ )
1223
+ ] })
1224
+ ]
1225
+ }
1226
+ );
1227
+ }
1228
+
696
1229
  // src/hooks/use-keyboard-shortcuts.ts
697
- import { useEffect as useEffect2, useCallback as useCallback2 } from "react";
1230
+ import { useEffect as useEffect4, useCallback as useCallback3 } from "react";
698
1231
 
699
1232
  // src/hooks/is-typing-context.ts
700
1233
  var TYPING_TAG_RE = /^(INPUT|TEXTAREA|SELECT)$/;
@@ -719,14 +1252,14 @@ function useKeyboardShortcuts({
719
1252
  ignoreTags = []
720
1253
  }) {
721
1254
  const malformed = !Array.isArray(shortcuts);
722
- useEffect2(() => {
1255
+ useEffect4(() => {
723
1256
  if (malformed) {
724
1257
  console.error(
725
1258
  "[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."
726
1259
  );
727
1260
  }
728
1261
  }, [malformed]);
729
- const handleKeyDown = useCallback2(
1262
+ const handleKeyDown = useCallback3(
730
1263
  (e) => {
731
1264
  if (!enabled || malformed) return;
732
1265
  if (e.isComposing || e.keyCode === 229) return;
@@ -754,7 +1287,7 @@ function useKeyboardShortcuts({
754
1287
  },
755
1288
  [shortcuts, enabled, ignoreTags, malformed]
756
1289
  );
757
- useEffect2(() => {
1290
+ useEffect4(() => {
758
1291
  window.addEventListener("keydown", handleKeyDown);
759
1292
  return () => window.removeEventListener("keydown", handleKeyDown);
760
1293
  }, [handleKeyDown]);
@@ -924,13 +1457,13 @@ function getShortcut(context, action) {
924
1457
  }
925
1458
 
926
1459
  // src/components/keyboard-shortcuts-panel.tsx
927
- import { useEffect as useEffect3, useState as useState3 } from "react";
928
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1460
+ import { useEffect as useEffect5, useState as useState5 } from "react";
1461
+ import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
929
1462
  function KeyboardShortcutsPanel({
930
1463
  contexts = ALL_SHORTCUT_CONTEXTS
931
1464
  }) {
932
- const [open, setOpen] = useState3(false);
933
- useEffect3(() => {
1465
+ const [open, setOpen] = useState5(false);
1466
+ useEffect5(() => {
934
1467
  function handleKey(e) {
935
1468
  if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey) {
936
1469
  const tag = e.target?.tagName;
@@ -947,33 +1480,33 @@ function KeyboardShortcutsPanel({
947
1480
  return () => window.removeEventListener("keydown", handleKey);
948
1481
  }, [open]);
949
1482
  if (!open) return null;
950
- return /* @__PURE__ */ jsxs4(Fragment2, { children: [
951
- /* @__PURE__ */ jsx5(
1483
+ return /* @__PURE__ */ jsxs6(Fragment3, { children: [
1484
+ /* @__PURE__ */ jsx7(
952
1485
  "div",
953
1486
  {
954
1487
  className: "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",
955
1488
  onClick: () => setOpen(false)
956
1489
  }
957
1490
  ),
958
- /* @__PURE__ */ jsx5("div", { className: "fixed inset-x-0 top-[10%] z-50 mx-auto w-full max-w-lg", children: /* @__PURE__ */ jsxs4("div", { className: "rounded-xl border bg-background shadow-2xl overflow-hidden", children: [
959
- /* @__PURE__ */ jsxs4("div", { className: "px-6 py-4 border-b", children: [
960
- /* @__PURE__ */ jsx5("h2", { className: "text-lg font-semibold", children: "Keyboard Shortcuts" }),
961
- /* @__PURE__ */ jsxs4("p", { className: "text-sm text-muted-foreground mt-0.5", children: [
1491
+ /* @__PURE__ */ jsx7("div", { className: "fixed inset-x-0 top-[10%] z-50 mx-auto w-full max-w-lg", children: /* @__PURE__ */ jsxs6("div", { className: "rounded-xl border bg-background shadow-2xl overflow-hidden", children: [
1492
+ /* @__PURE__ */ jsxs6("div", { className: "px-6 py-4 border-b", children: [
1493
+ /* @__PURE__ */ jsx7("h2", { className: "text-lg font-semibold", children: "Keyboard Shortcuts" }),
1494
+ /* @__PURE__ */ jsxs6("p", { className: "text-sm text-muted-foreground mt-0.5", children: [
962
1495
  "Press ",
963
- /* @__PURE__ */ jsx5("kbd", { className: "px-1.5 py-0.5 bg-muted rounded text-xs font-mono", children: "?" }),
1496
+ /* @__PURE__ */ jsx7("kbd", { className: "px-1.5 py-0.5 bg-muted rounded text-xs font-mono", children: "?" }),
964
1497
  " to toggle this panel"
965
1498
  ] })
966
1499
  ] }),
967
- /* @__PURE__ */ jsx5("div", { className: "px-6 py-4 max-h-[60vh] overflow-y-auto space-y-6", children: contexts.map((ctx) => /* @__PURE__ */ jsxs4("div", { children: [
968
- /* @__PURE__ */ jsx5("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: ctx.label }),
969
- /* @__PURE__ */ jsx5("div", { className: "space-y-1", children: Object.entries(ctx.shortcuts).map(([key, def]) => /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between py-1", children: [
970
- /* @__PURE__ */ jsx5("span", { className: "text-sm", children: def.description }),
971
- /* @__PURE__ */ jsx5("kbd", { className: "px-2 py-0.5 bg-muted rounded text-xs font-mono min-w-[2rem] text-center", children: def.display })
1500
+ /* @__PURE__ */ jsx7("div", { className: "px-6 py-4 max-h-[60vh] overflow-y-auto space-y-6", children: contexts.map((ctx) => /* @__PURE__ */ jsxs6("div", { children: [
1501
+ /* @__PURE__ */ jsx7("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: ctx.label }),
1502
+ /* @__PURE__ */ jsx7("div", { className: "space-y-1", children: Object.entries(ctx.shortcuts).map(([key, def]) => /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between py-1", children: [
1503
+ /* @__PURE__ */ jsx7("span", { className: "text-sm", children: def.description }),
1504
+ /* @__PURE__ */ jsx7("kbd", { className: "px-2 py-0.5 bg-muted rounded text-xs font-mono min-w-[2rem] text-center", children: def.display })
972
1505
  ] }, key)) })
973
1506
  ] }, ctx.name)) }),
974
- /* @__PURE__ */ jsxs4("div", { className: "px-6 py-3 border-t bg-muted/30 text-xs text-muted-foreground text-center", children: [
1507
+ /* @__PURE__ */ jsxs6("div", { className: "px-6 py-3 border-t bg-muted/30 text-xs text-muted-foreground text-center", children: [
975
1508
  "Press ",
976
- /* @__PURE__ */ jsx5("kbd", { className: "px-1 py-0.5 bg-muted rounded", children: "Esc" }),
1509
+ /* @__PURE__ */ jsx7("kbd", { className: "px-1 py-0.5 bg-muted rounded", children: "Esc" }),
977
1510
  " to close"
978
1511
  ] })
979
1512
  ] }) })
@@ -981,21 +1514,21 @@ function KeyboardShortcutsPanel({
981
1514
  }
982
1515
 
983
1516
  // src/hooks/use-auto-save.ts
984
- import { useEffect as useEffect4, useRef as useRef2, useCallback as useCallback3, useState as useState4 } from "react";
1517
+ import { useEffect as useEffect6, useRef as useRef4, useCallback as useCallback4, useState as useState6 } from "react";
985
1518
  function useAutoSave({
986
1519
  data,
987
1520
  onSave,
988
1521
  delay = 5e3,
989
1522
  enabled = true
990
1523
  }) {
991
- const [lastSavedAt, setLastSavedAt] = useState4(null);
992
- const [isSaving, setIsSaving] = useState4(false);
993
- const [saveError, setSaveError] = useState4(null);
994
- const timerRef = useRef2(null);
995
- const dataRef = useRef2(data);
996
- const savedDataRef = useRef2(null);
1524
+ const [lastSavedAt, setLastSavedAt] = useState6(null);
1525
+ const [isSaving, setIsSaving] = useState6(false);
1526
+ const [saveError, setSaveError] = useState6(null);
1527
+ const timerRef = useRef4(null);
1528
+ const dataRef = useRef4(data);
1529
+ const savedDataRef = useRef4(null);
997
1530
  dataRef.current = data;
998
- const save = useCallback3(async () => {
1531
+ const save = useCallback4(async () => {
999
1532
  const currentJson = JSON.stringify(dataRef.current);
1000
1533
  if (currentJson === savedDataRef.current) return;
1001
1534
  setIsSaving(true);
@@ -1010,7 +1543,7 @@ function useAutoSave({
1010
1543
  setIsSaving(false);
1011
1544
  }
1012
1545
  }, [onSave]);
1013
- useEffect4(() => {
1546
+ useEffect6(() => {
1014
1547
  if (!enabled) return;
1015
1548
  if (timerRef.current) clearTimeout(timerRef.current);
1016
1549
  timerRef.current = setTimeout(save, delay);
@@ -1022,19 +1555,19 @@ function useAutoSave({
1022
1555
  }
1023
1556
 
1024
1557
  // src/hooks/use-polling.ts
1025
- import { useEffect as useEffect5, useCallback as useCallback4, useRef as useRef3, useState as useState5 } from "react";
1558
+ import { useEffect as useEffect7, useCallback as useCallback5, useRef as useRef5, useState as useState7 } from "react";
1026
1559
  function usePolling({
1027
1560
  fetcher,
1028
1561
  interval = 3e4,
1029
1562
  enabled = true,
1030
1563
  onError
1031
1564
  }) {
1032
- const [data, setData] = useState5(null);
1033
- const [isLoading, setIsLoading] = useState5(true);
1034
- const [isRefreshing, setIsRefreshing] = useState5(false);
1035
- const [error, setError] = useState5(null);
1036
- const mountedRef = useRef3(true);
1037
- const doFetch = useCallback4(async (isInitial = false) => {
1565
+ const [data, setData] = useState7(null);
1566
+ const [isLoading, setIsLoading] = useState7(true);
1567
+ const [isRefreshing, setIsRefreshing] = useState7(false);
1568
+ const [error, setError] = useState7(null);
1569
+ const mountedRef = useRef5(true);
1570
+ const doFetch = useCallback5(async (isInitial = false) => {
1038
1571
  if (isInitial) setIsLoading(true);
1039
1572
  else setIsRefreshing(true);
1040
1573
  try {
@@ -1055,36 +1588,36 @@ function usePolling({
1055
1588
  }
1056
1589
  }
1057
1590
  }, [fetcher, onError]);
1058
- useEffect5(() => {
1591
+ useEffect7(() => {
1059
1592
  mountedRef.current = true;
1060
1593
  if (enabled) doFetch(true);
1061
1594
  return () => {
1062
1595
  mountedRef.current = false;
1063
1596
  };
1064
1597
  }, [doFetch, enabled]);
1065
- useEffect5(() => {
1598
+ useEffect7(() => {
1066
1599
  if (!enabled) return;
1067
1600
  const timer = setInterval(() => doFetch(false), interval);
1068
1601
  return () => clearInterval(timer);
1069
1602
  }, [doFetch, interval, enabled]);
1070
- const refresh = useCallback4(() => doFetch(false), [doFetch]);
1603
+ const refresh = useCallback5(() => doFetch(false), [doFetch]);
1071
1604
  return { data, isLoading, isRefreshing, error, refresh };
1072
1605
  }
1073
1606
 
1074
1607
  // src/hooks/use-server-search.ts
1075
- import { useEffect as useEffect6, useRef as useRef4, useState as useState6, useCallback as useCallback5 } from "react";
1608
+ import { useEffect as useEffect8, useRef as useRef6, useState as useState8, useCallback as useCallback6 } from "react";
1076
1609
  function useServerSearch({
1077
1610
  fetcher,
1078
1611
  debounce = 150,
1079
1612
  minChars = 1,
1080
1613
  enabled = true
1081
1614
  }) {
1082
- const [query, setQuery] = useState6("");
1083
- const [results, setResults] = useState6([]);
1084
- const [isSearching, setIsSearching] = useState6(false);
1085
- const [isOpen, setIsOpen] = useState6(false);
1086
- const timerRef = useRef4(null);
1087
- useEffect6(() => {
1615
+ const [query, setQuery] = useState8("");
1616
+ const [results, setResults] = useState8([]);
1617
+ const [isSearching, setIsSearching] = useState8(false);
1618
+ const [isOpen, setIsOpen] = useState8(false);
1619
+ const timerRef = useRef6(null);
1620
+ useEffect8(() => {
1088
1621
  if (!enabled || query.length < minChars) {
1089
1622
  setResults([]);
1090
1623
  return;
@@ -1105,7 +1638,7 @@ function useServerSearch({
1105
1638
  if (timerRef.current) clearTimeout(timerRef.current);
1106
1639
  };
1107
1640
  }, [query, fetcher, debounce, minChars, enabled]);
1108
- const clear = useCallback5(() => {
1641
+ const clear = useCallback6(() => {
1109
1642
  setQuery("");
1110
1643
  setResults([]);
1111
1644
  setIsOpen(false);
@@ -1114,9 +1647,9 @@ function useServerSearch({
1114
1647
  }
1115
1648
 
1116
1649
  // src/hooks/use-iframe-focus-reclaim.ts
1117
- import { useEffect as useEffect7 } from "react";
1650
+ import { useEffect as useEffect9 } from "react";
1118
1651
  function useIframeFocusReclaim(containerRef, enabled = true, iframeSelector = "iframe") {
1119
- useEffect7(() => {
1652
+ useEffect9(() => {
1120
1653
  if (!enabled) return;
1121
1654
  const el = containerRef.current;
1122
1655
  if (!el) return;
@@ -1297,15 +1830,15 @@ function clearCache() {
1297
1830
  }
1298
1831
 
1299
1832
  // src/hooks/use-preferences.ts
1300
- import { useState as useState7, useEffect as useEffect8, useCallback as useCallback6 } from "react";
1833
+ import { useState as useState9, useEffect as useEffect10, useCallback as useCallback7 } from "react";
1301
1834
  function usePreferences({
1302
1835
  endpoint,
1303
1836
  defaults
1304
1837
  }) {
1305
- const [preferences, setPreferences] = useState7(defaults ?? null);
1306
- const [loading, setLoading] = useState7(true);
1307
- const [error, setError] = useState7(null);
1308
- const fetchPreferences = useCallback6(async () => {
1838
+ const [preferences, setPreferences] = useState9(defaults ?? null);
1839
+ const [loading, setLoading] = useState9(true);
1840
+ const [error, setError] = useState9(null);
1841
+ const fetchPreferences = useCallback7(async () => {
1309
1842
  try {
1310
1843
  setError(null);
1311
1844
  const res = await fetch(endpoint);
@@ -1324,10 +1857,10 @@ function usePreferences({
1324
1857
  setLoading(false);
1325
1858
  }
1326
1859
  }, [endpoint, defaults]);
1327
- useEffect8(() => {
1860
+ useEffect10(() => {
1328
1861
  fetchPreferences();
1329
1862
  }, [fetchPreferences]);
1330
- const updatePreferences = useCallback6(
1863
+ const updatePreferences = useCallback7(
1331
1864
  async (updates) => {
1332
1865
  setPreferences((prev) => prev ? { ...prev, ...updates } : updates);
1333
1866
  setError(null);
@@ -1692,6 +2225,8 @@ export {
1692
2225
  KeyboardShortcutsPanel,
1693
2226
  RENDER_ERRORS,
1694
2227
  REPLY_LAYOUT_OPTIONS,
2228
+ ReplyPanel,
2229
+ RichTextEditor,
1695
2230
  cachedFetch,
1696
2231
  canViewInline,
1697
2232
  clearCache,
@@ -1708,6 +2243,7 @@ export {
1708
2243
  invalidateCache,
1709
2244
  isAudio,
1710
2245
  isDocument,
2246
+ isEmptyHtml,
1711
2247
  isImage,
1712
2248
  isInlineLayout,
1713
2249
  isModalLayout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordinatio/ui",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Reusable React components and hooks for Ordinatio applications",
@@ -23,21 +23,11 @@
23
23
  "README.md",
24
24
  "LICENSE"
25
25
  ],
26
- "scripts": {
27
- "build": "tsup",
28
- "dev": "tsup --watch",
29
- "test": "vitest",
30
- "test:run": "vitest run"
31
- },
32
26
  "peerDependencies": {
33
27
  "react": ">=18.0.0",
34
28
  "lucide-react": ">=0.400.0"
35
29
  },
36
- "dependencies": {
37
- "@ordinatio/activities": "workspace:*"
38
- },
39
30
  "devDependencies": {
40
- "@ordinatio/activities": "workspace:*",
41
31
  "@testing-library/jest-dom": "6.9.1",
42
32
  "@testing-library/react": "16.3.2",
43
33
  "@types/react": "^19.0.0",
@@ -46,6 +36,13 @@
46
36
  "react": "^19.0.0",
47
37
  "tsup": "^8.5.1",
48
38
  "typescript": "5",
49
- "vitest": "4.0.18"
39
+ "vitest": "4.0.18",
40
+ "@ordinatio/activities": "1.0.4"
41
+ },
42
+ "scripts": {
43
+ "build": "tsup",
44
+ "dev": "tsup --watch",
45
+ "test": "vitest",
46
+ "test:run": "vitest run"
50
47
  }
51
- }
48
+ }