@ordinatio/ui 1.8.0 → 1.9.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/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ Entries start at 1.9.0 (older history is in git).
4
+
5
+ ## 1.9.0
6
+
7
+ - New `Pager` component (and the `PagerProps`, `PagerClassNames`, `PagerLabels`, `PagerLinkProps` types): the "Showing X to Y of Z" line with Previous and Next links. Contract: the caller passes a `page` already inside [1, last page] and builds `hrefs: { previous, next }` from that same number; Pager decides which links show and never renders a link for a page out of range. If `page` was not in range (NaN, 0, negative, fractional, past the end) Pager shows the text for the nearest real page and NO links. No prop is a function except `LinkComponent`, which across a server-to-client boundary must be a client component or client reference (`next/link` works). Also `classNames`, `labels` (strings only; `showing` is a `{start}`/`{end}`/`{total}` template, for example an en dash form `'Showing {start}–{end} of {total}'`) and `hideWhenSinglePage` (default true: renders nothing when everything fits on one page; false shows the "Showing" line whenever the list is not empty). Tolerates NaN, Infinity, negative and fractional numbers.
8
+ - Additive: no existing export changes.
package/README.md CHANGED
@@ -258,6 +258,26 @@ Presentation for a soft-delete flow. None of them knows a route, a router or a d
258
258
  - `TrashedBanner`: amber "In the Trash since DATE by NAME." strip with a `restore` slot. `since` null reads "earlier". Dates use `formatTrashedDate(date, locale = 'en-US', timeZone?)` or your `formatDate`. `labels` `{ intro, since, by, earlier }`.
259
259
  - Styling: plain elements with inline defaults; `classNames.<part>` REPLACES that part's look. Parts: RestoreButton `root, button, error`; UndoNotice `root, message, link, undo, dismiss, error`; TrashedBanner `root, text, action`.
260
260
 
261
+ ### `Pager` (1.9.0)
262
+
263
+ The "Showing X to Y of Z" line with Previous and Next links under a paged list. No hooks, state or router: the app owns the page number and passes the two link targets in `hrefs`.
264
+
265
+ ```tsx
266
+ // Clamp FIRST, then build the hrefs from that same number.
267
+ const { page } = pageWindow({ total, page: requestedPage, pageSize: 50 }); // or your own clamp into [1, lastPage]
268
+ <Pager total={total} page={page} pageSize={50} hrefs={{ previous: `?page=${page - 1}`, next: `?page=${page + 1}` }} LinkComponent={Link} />
269
+ // An en dash instead of "to":
270
+ <Pager ... labels={{ showing: 'Showing {start}–{end} of {total}' }} />
271
+ ```
272
+
273
+ - Props: `total`, `page` (1-based), `pageSize`, `hrefs` `{ previous, next }`, `LinkComponent` (default a plain `<a>`; gets `href`, `className`, `children`), `classNames` `{ root, summary, links, link }`, `labels` `{ previous, next, showing }` (strings only; `showing` is a template with `{start}`, `{end}` and `{total}`; defaults "← Previous", "Next →", "Showing {start} to {end} of {total}"), `hideWhenSinglePage` (default true). The en dash form above is what Cranberry's old hand-written Tasks and Inbox bars used.
274
+ - Contract: you MUST pass a `page` already inside `[1, last page]` (for example from `@ordinatio/core/paging` `pageWindow().page`) and build `hrefs` from that same number (`previous` = page - 1, `next` = page + 1). Pager decides which links show (no Previous on page 1, no Next on the last page) and never renders a link for a page out of range.
275
+ - Last-resort guard: if `page` is NOT already a whole number inside `[1, last page]` (NaN, 0, negative, fractional, past the end), Pager shows the "Showing" text for the nearest real page and renders NO links, because it cannot vouch for where your `hrefs` point.
276
+ - Single page: by default it renders nothing when `total <= pageSize`. With `hideWhenSinglePage={false}` it shows the "Showing" line (no links) whenever `total > 0`. An empty list (`total` 0) always renders nothing.
277
+ - Bad numbers (NaN, Infinity, negative, fractional `total`, `page` or `pageSize`) never print NaN or make an empty link: `total` and `page` are floored, `pageSize` is at least 1.
278
+ - Server-safe: the only function prop is `LinkComponent` (a component reference). Across a server-to-client boundary it must be a client component or a client reference (`next/link` works; a plain function component defined in a server file does not). Every other prop is a string, number, boolean or plain object, so a server page (Tasks, Inbox, Trash) can render it.
279
+ - Styling: `classNames.<part>` REPLACES that part's look (the root and links wrapper have small inline defaults, the summary and links have none).
280
+
261
281
  ### `ShowOnceSecret` and `useCopyToClipboard`
262
282
 
263
283
  A box for something that is readable only right now (an API key, a signing secret, an invite link).
package/dist/index.d.mts CHANGED
@@ -366,6 +366,46 @@ interface TrashedBannerProps {
366
366
  */
367
367
  declare function TrashedBanner({ since, by, restore, formatDate, labels, classNames }: TrashedBannerProps): react_jsx_runtime.JSX.Element;
368
368
 
369
+ interface PagerClassNames {
370
+ root?: string;
371
+ summary?: string;
372
+ /** The wrapper around the Previous and Next links. */
373
+ links?: string;
374
+ /** Each link; passed to `LinkComponent` as `className`. */
375
+ link?: string;
376
+ }
377
+ interface PagerLabels {
378
+ /** Default "← Previous". */
379
+ previous?: string;
380
+ /** Default "Next →". */
381
+ next?: string;
382
+ /** Template with {start}, {end} and {total}. Default "Showing {start} to {end} of {total}". */
383
+ showing?: string;
384
+ }
385
+ interface PagerLinkProps {
386
+ href: string;
387
+ className?: string;
388
+ children: ReactNode;
389
+ }
390
+ interface PagerProps {
391
+ /** Rows in the whole list. */
392
+ total: number;
393
+ /** The current page, 1-based. The caller passes one already inside [1, last page]; a corrected page shows its text but no links. */
394
+ page: number;
395
+ pageSize: number;
396
+ /** Link targets for page-1 and page+1, built from the same in-range `page` passed above. */
397
+ hrefs: {
398
+ previous: string;
399
+ next: string;
400
+ };
401
+ LinkComponent?: ComponentType<PagerLinkProps>;
402
+ classNames?: PagerClassNames;
403
+ labels?: PagerLabels;
404
+ /** Render nothing when everything fits on one page. Default true. */
405
+ hideWhenSinglePage?: boolean;
406
+ }
407
+ declare function Pager({ total: rawTotal, page: rawPage, pageSize: rawSize, hrefs, LinkComponent, classNames, labels, hideWhenSinglePage, }: PagerProps): react_jsx_runtime.JSX.Element | null;
408
+
369
409
  interface ShowOnceSecretClassNames {
370
410
  root?: string;
371
411
  title?: string;
@@ -1283,4 +1323,4 @@ declare const ACTIVITY_ICONS: Record<string, IconComponent>;
1283
1323
  /** Return the icon component for a given icon name, or Activity as fallback. */
1284
1324
  declare function resolveActivityIcon(name: string): IconComponent;
1285
1325
 
1286
- export { ACTIVITY_ICONS, ALL_SHORTCUT_CONTEXTS, ARRIVAL_FADE_MS, type ActivityFeedChip, ActivityFeedRow, type ActivityFeedRowClassNames, type ActivityFeedRowProps, ArchiveButton, type ArchiveButtonProps, CLIENT_PROFILE_SHORTCUTS, COPY_NOTE_COPIED, COPY_NOTE_FAILED, 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, GUARDED_ACTION_FAILURE, INBOX_SHORTCUTS, type KeyboardShortcut, KeyboardShortcutsPanel, PICKER_SEARCH_FAILURE, type PickerSearchResult, RENDER_ERRORS, REPLY_LAYOUT_OPTIONS, type RenderErrorResult, type ReplyLayout, ReplyPanel, type ReplyPanelProps, type ReplySendOverrides, RestoreButton, type RestoreButtonClassNames, type RestoreButtonLabels, type RestoreButtonProps, RichTextEditor, type RichTextEditorProps, type SchedulePreset, type ShortcutContext, type ShortcutDefinition, ShowOnceSecret, type ShowOnceSecretClassNames, type ShowOnceSecretLabels, type ShowOnceSecretProps, type ThreadMessage, TrashedBanner, type TrashedBannerClassNames, type TrashedBannerLabels, type TrashedBannerProps, UndoNotice, type UndoNoticeClassNames, type UndoNoticeLabels, type UndoNoticeProps, type UseAutoSaveOptions, type UseAutoSaveResult, type UseCopyToClipboardOptions, type UseCopyToClipboardResult, type UseGuardedActionOptions, type UseGuardedActionResult, type UseKeyboardShortcutsOptions, type UsePickerSessionOptions, type UsePickerSessionResult, type UsePollingOptions, type UsePollingResult, type UsePreferencesOptions, type UsePreferencesResult, type UseServerSearchOptions, type UseServerSearchResult, type UseSignedAnswerOptions, type UseSignedAnswerResult, cachedFetch, canViewInline, clearCache, formatDateGroup, formatFileSize, formatPhone, formatPhoneInput, formatTrashedDate, 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, useArrival, useAutoSave, useContextShortcuts, useCopyToClipboard, useFormActionKeepingInput, useGuardedAction, useIframeFocusReclaim, useKeyboardShortcuts, usePickerSession, usePolling, usePreferences, useSavedNotice, useServerSearch, useSignedAnswer, useSyncedSelect, withErrorBoundary };
1326
+ export { ACTIVITY_ICONS, ALL_SHORTCUT_CONTEXTS, ARRIVAL_FADE_MS, type ActivityFeedChip, ActivityFeedRow, type ActivityFeedRowClassNames, type ActivityFeedRowProps, ArchiveButton, type ArchiveButtonProps, CLIENT_PROFILE_SHORTCUTS, COPY_NOTE_COPIED, COPY_NOTE_FAILED, 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, GUARDED_ACTION_FAILURE, INBOX_SHORTCUTS, type KeyboardShortcut, KeyboardShortcutsPanel, PICKER_SEARCH_FAILURE, Pager, type PagerClassNames, type PagerLabels, type PagerLinkProps, type PagerProps, type PickerSearchResult, RENDER_ERRORS, REPLY_LAYOUT_OPTIONS, type RenderErrorResult, type ReplyLayout, ReplyPanel, type ReplyPanelProps, type ReplySendOverrides, RestoreButton, type RestoreButtonClassNames, type RestoreButtonLabels, type RestoreButtonProps, RichTextEditor, type RichTextEditorProps, type SchedulePreset, type ShortcutContext, type ShortcutDefinition, ShowOnceSecret, type ShowOnceSecretClassNames, type ShowOnceSecretLabels, type ShowOnceSecretProps, type ThreadMessage, TrashedBanner, type TrashedBannerClassNames, type TrashedBannerLabels, type TrashedBannerProps, UndoNotice, type UndoNoticeClassNames, type UndoNoticeLabels, type UndoNoticeProps, type UseAutoSaveOptions, type UseAutoSaveResult, type UseCopyToClipboardOptions, type UseCopyToClipboardResult, type UseGuardedActionOptions, type UseGuardedActionResult, type UseKeyboardShortcutsOptions, type UsePickerSessionOptions, type UsePickerSessionResult, type UsePollingOptions, type UsePollingResult, type UsePreferencesOptions, type UsePreferencesResult, type UseServerSearchOptions, type UseServerSearchResult, type UseSignedAnswerOptions, type UseSignedAnswerResult, cachedFetch, canViewInline, clearCache, formatDateGroup, formatFileSize, formatPhone, formatPhoneInput, formatTrashedDate, 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, useArrival, useAutoSave, useContextShortcuts, useCopyToClipboard, useFormActionKeepingInput, useGuardedAction, useIframeFocusReclaim, useKeyboardShortcuts, usePickerSession, usePolling, usePreferences, useSavedNotice, useServerSearch, useSignedAnswer, useSyncedSelect, withErrorBoundary };
package/dist/index.mjs CHANGED
@@ -1005,6 +1005,48 @@ function TrashedBanner({ since, by, restore, formatDate: formatDate2 = formatTra
1005
1005
  ] });
1006
1006
  }
1007
1007
 
1008
+ // src/components/pager.tsx
1009
+ import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
1010
+ var defaults6 = {
1011
+ root: { display: "flex", alignItems: "center", justifyContent: "space-between", marginTop: "16px", fontSize: "14px" },
1012
+ links: { display: "flex", gap: "12px" }
1013
+ };
1014
+ var DEFAULT_SHOWING = "Showing {start} to {end} of {total}";
1015
+ var whole = (value, fallback) => Number.isFinite(value) ? Math.floor(value) : fallback;
1016
+ var PlainLink = ({ href, className, children }) => /* @__PURE__ */ jsx10("a", { href, className, children });
1017
+ function Pager({
1018
+ total: rawTotal,
1019
+ page: rawPage,
1020
+ pageSize: rawSize,
1021
+ hrefs,
1022
+ LinkComponent = PlainLink,
1023
+ classNames,
1024
+ labels,
1025
+ hideWhenSinglePage = true
1026
+ }) {
1027
+ const total = Math.max(0, whole(rawTotal, 0));
1028
+ const size = Math.max(1, whole(rawSize, 1));
1029
+ if (total === 0) return null;
1030
+ if (hideWhenSinglePage && total <= size) return null;
1031
+ const lastPage = Math.max(1, Math.ceil(total / size));
1032
+ const page = Math.min(lastPage, Math.max(1, whole(rawPage, 1)));
1033
+ const trusted = rawPage === page;
1034
+ const rangeStart = (page - 1) * size + 1;
1035
+ const rangeEnd = Math.min(page * size, total);
1036
+ const hasPrev = trusted && page > 1;
1037
+ const hasNext = trusted && rangeEnd < total;
1038
+ const text = (labels?.showing ?? DEFAULT_SHOWING).replace(/\{start\}/g, String(rangeStart)).replace(/\{end\}/g, String(rangeEnd)).replace(/\{total\}/g, String(total));
1039
+ const rootProps = classNames?.root ? { className: classNames.root } : { style: defaults6.root };
1040
+ const linksProps = classNames?.links ? { className: classNames.links } : { style: defaults6.links };
1041
+ return /* @__PURE__ */ jsxs9("div", { ...rootProps, children: [
1042
+ /* @__PURE__ */ jsx10("span", { className: classNames?.summary, children: text }),
1043
+ /* @__PURE__ */ jsxs9("div", { ...linksProps, children: [
1044
+ hasPrev ? /* @__PURE__ */ jsx10(LinkComponent, { href: hrefs.previous, className: classNames?.link, children: labels?.previous ?? "\u2190 Previous" }) : null,
1045
+ hasNext ? /* @__PURE__ */ jsx10(LinkComponent, { href: hrefs.next, className: classNames?.link, children: labels?.next ?? "Next \u2192" }) : null
1046
+ ] })
1047
+ ] });
1048
+ }
1049
+
1008
1050
  // src/components/show-once-secret.tsx
1009
1051
  import { useEffect as useEffect5 } from "react";
1010
1052
 
@@ -1058,8 +1100,8 @@ function useCopyToClipboard(options = {}) {
1058
1100
  }
1059
1101
 
1060
1102
  // src/components/show-once-secret.tsx
1061
- import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
1062
- var defaults6 = {
1103
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1104
+ var defaults7 = {
1063
1105
  root: { display: "flex", flexDirection: "column", gap: "8px", padding: "12px 16px", border: "1px solid #fcd34d", borderRadius: "6px", backgroundColor: "#fffbeb" },
1064
1106
  title: { margin: 0, fontSize: "14px", fontWeight: 500, color: "#78350f" },
1065
1107
  warning: { fontWeight: 400 },
@@ -1076,18 +1118,18 @@ function ShowOnceSecret({ secret, title, onDone, display = "text", secretTestId,
1076
1118
  }, [secret, reset]);
1077
1119
  const part = (key) => {
1078
1120
  const className = classNames?.[key];
1079
- return className ? { className } : { style: defaults6[key] };
1121
+ return className ? { className } : { style: defaults7[key] };
1080
1122
  };
1081
- return /* @__PURE__ */ jsxs9("div", { ...part("root"), children: [
1082
- /* @__PURE__ */ jsxs9("p", { ...part("title"), children: [
1123
+ return /* @__PURE__ */ jsxs10("div", { ...part("root"), children: [
1124
+ /* @__PURE__ */ jsxs10("p", { ...part("title"), children: [
1083
1125
  title,
1084
1126
  " ",
1085
- /* @__PURE__ */ jsx10("span", { ...part("warning"), children: labels?.warning ?? "Copy it now: you will not see it again." })
1127
+ /* @__PURE__ */ jsx11("span", { ...part("warning"), children: labels?.warning ?? "Copy it now: you will not see it again." })
1086
1128
  ] }),
1087
- display === "field" ? /* @__PURE__ */ jsx10("input", { readOnly: true, value: secret, "aria-label": labels?.secret ?? "Secret", "data-testid": secretTestId, onFocus: (event) => event.currentTarget.select(), ...part("secret") }) : /* @__PURE__ */ jsx10("code", { "data-testid": secretTestId, ...part("secret"), children: secret }),
1088
- /* @__PURE__ */ jsxs9("div", { ...part("actions"), children: [
1089
- /* @__PURE__ */ jsx10("button", { type: "button", onClick: () => void copy(secret), ...part("copy"), children: labels?.copy ?? "Copy" }),
1090
- /* @__PURE__ */ jsx10(
1129
+ display === "field" ? /* @__PURE__ */ jsx11("input", { readOnly: true, value: secret, "aria-label": labels?.secret ?? "Secret", "data-testid": secretTestId, onFocus: (event) => event.currentTarget.select(), ...part("secret") }) : /* @__PURE__ */ jsx11("code", { "data-testid": secretTestId, ...part("secret"), children: secret }),
1130
+ /* @__PURE__ */ jsxs10("div", { ...part("actions"), children: [
1131
+ /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => void copy(secret), ...part("copy"), children: labels?.copy ?? "Copy" }),
1132
+ /* @__PURE__ */ jsx11(
1091
1133
  "button",
1092
1134
  {
1093
1135
  type: "button",
@@ -1099,7 +1141,7 @@ function ShowOnceSecret({ secret, title, onDone, display = "text", secretTestId,
1099
1141
  children: labels?.done ?? "Done"
1100
1142
  }
1101
1143
  ),
1102
- /* @__PURE__ */ jsx10("span", { role: "status", "data-status": status ?? void 0, ...part("note"), children: note })
1144
+ /* @__PURE__ */ jsx11("span", { role: "status", "data-status": status ?? void 0, ...part("note"), children: note })
1103
1145
  ] }),
1104
1146
  children
1105
1147
  ] });
@@ -1107,8 +1149,8 @@ function ShowOnceSecret({ secret, title, onDone, display = "text", secretTestId,
1107
1149
 
1108
1150
  // src/components/entity-picker.tsx
1109
1151
  import { useCallback as useCallback4, useEffect as useEffect6, useId as useId2, useRef as useRef5, useState as useState7 } from "react";
1110
- import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1111
- var defaults7 = {
1152
+ import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1153
+ var defaults8 = {
1112
1154
  root: { position: "relative", display: "inline-flex", alignItems: "center", gap: "4px", width: "100%" },
1113
1155
  input: { flex: 1, minWidth: 0, padding: "8px 10px", fontSize: "14px", border: "1px solid #d4d4d4", borderRadius: "6px", backgroundColor: "#ffffff", color: "#171717" },
1114
1156
  clear: { padding: "4px 8px", fontSize: "14px", border: "1px solid transparent", borderRadius: "6px", backgroundColor: "transparent", color: "#525252", cursor: "pointer" },
@@ -1255,7 +1297,7 @@ function EntityPicker({
1255
1297
  const partProps = (key) => {
1256
1298
  const className = classNames?.[key];
1257
1299
  if (className) return { className, style: key === "root" ? style : void 0 };
1258
- return { style: key === "root" ? { ...defaults7.root, ...style } : defaults7[key] };
1300
+ return { style: key === "root" ? { ...defaults8.root, ...style } : defaults8[key] };
1259
1301
  };
1260
1302
  const optionProps = (active) => {
1261
1303
  const optionClass = classNames?.option;
@@ -1264,8 +1306,8 @@ function EntityPicker({
1264
1306
  return { className, style: optionClass ? void 0 : { ...optionDefaults.base, ...active && !activeClass ? optionDefaults.active : {} } };
1265
1307
  };
1266
1308
  const shown = editing ? text : value ? getLabel(value) : "";
1267
- return /* @__PURE__ */ jsxs10("div", { ...partProps("root"), children: [
1268
- /* @__PURE__ */ jsx11(
1309
+ return /* @__PURE__ */ jsxs11("div", { ...partProps("root"), children: [
1310
+ /* @__PURE__ */ jsx12(
1269
1311
  "input",
1270
1312
  {
1271
1313
  ...partProps("input"),
@@ -1297,19 +1339,19 @@ function EntityPicker({
1297
1339
  }
1298
1340
  }
1299
1341
  ),
1300
- name !== void 0 ? /* @__PURE__ */ jsx11("input", { type: "hidden", name, value: value ? getKey(value) : "", disabled }) : null,
1301
- clearable && value && !disabled ? /* @__PURE__ */ jsx11("button", { type: "button", "aria-label": clearLabel, ...partProps("clear"), onClick: () => {
1342
+ name !== void 0 ? /* @__PURE__ */ jsx12("input", { type: "hidden", name, value: value ? getKey(value) : "", disabled }) : null,
1343
+ clearable && value && !disabled ? /* @__PURE__ */ jsx12("button", { type: "button", "aria-label": clearLabel, ...partProps("clear"), onClick: () => {
1302
1344
  onChange(null);
1303
1345
  inputRef.current?.focus();
1304
1346
  }, children: "\xD7" }) : null,
1305
- /* @__PURE__ */ jsx11("div", { role: "status", "aria-live": "polite", style: visuallyHidden2, children: announcement }),
1347
+ /* @__PURE__ */ jsx12("div", { role: "status", "aria-live": "polite", style: visuallyHidden2, children: announcement }),
1306
1348
  showPopup ? (
1307
1349
  // mousedown anywhere in the popup (an option, the scrollbar, a message) must not move focus out of the input, or its
1308
1350
  // blur would close the list before the click lands (and make a long list impossible to scroll by dragging)
1309
- /* @__PURE__ */ jsxs10("div", { ...partProps("list"), onMouseDown: (event) => event.preventDefault(), children: [
1310
- showListbox ? /* @__PURE__ */ jsx11("ul", { ref: listRef, id: listId, role: "listbox", "aria-label": ariaLabel, style: { listStyle: "none", margin: 0, padding: 0 }, children: results.map((item, index) => {
1351
+ /* @__PURE__ */ jsxs11("div", { ...partProps("list"), onMouseDown: (event) => event.preventDefault(), children: [
1352
+ showListbox ? /* @__PURE__ */ jsx12("ul", { ref: listRef, id: listId, role: "listbox", "aria-label": ariaLabel, style: { listStyle: "none", margin: 0, padding: 0 }, children: results.map((item, index) => {
1311
1353
  const active = index === activeIndex;
1312
- return /* @__PURE__ */ jsx11(
1354
+ return /* @__PURE__ */ jsx12(
1313
1355
  "li",
1314
1356
  {
1315
1357
  id: `${listId}-opt-${index}`,
@@ -1325,9 +1367,9 @@ function EntityPicker({
1325
1367
  getKey(item)
1326
1368
  );
1327
1369
  }) }) : null,
1328
- status === "loading" ? /* @__PURE__ */ jsx11("div", { "aria-hidden": "true", "data-entity-picker-message": "loading", ...partProps("message"), children: loadingText }) : null,
1329
- status === "error" ? /* @__PURE__ */ jsx11("div", { "aria-hidden": "true", "data-entity-picker-message": "error", ...partProps("message"), children: errorText }) : null,
1330
- status === "idle" && searched && results.length === 0 ? /* @__PURE__ */ jsx11("div", { "aria-hidden": "true", "data-entity-picker-message": "empty", ...partProps("message"), children: emptyText }) : null
1370
+ status === "loading" ? /* @__PURE__ */ jsx12("div", { "aria-hidden": "true", "data-entity-picker-message": "loading", ...partProps("message"), children: loadingText }) : null,
1371
+ status === "error" ? /* @__PURE__ */ jsx12("div", { "aria-hidden": "true", "data-entity-picker-message": "error", ...partProps("message"), children: errorText }) : null,
1372
+ status === "idle" && searched && results.length === 0 ? /* @__PURE__ */ jsx12("div", { "aria-hidden": "true", "data-entity-picker-message": "empty", ...partProps("message"), children: emptyText }) : null
1331
1373
  ] })
1332
1374
  ) : null
1333
1375
  ] });
@@ -1387,7 +1429,7 @@ var editableStyle = {
1387
1429
  };
1388
1430
 
1389
1431
  // src/components/rich-text-editor.tsx
1390
- import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1432
+ import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1391
1433
  var TOOLBAR_BUTTONS = [
1392
1434
  { command: "bold", label: "B", ariaLabel: "Bold" },
1393
1435
  { command: "italic", label: "I", ariaLabel: "Italic" },
@@ -1457,7 +1499,7 @@ function RichTextEditor({
1457
1499
  runCommand("createLink", url);
1458
1500
  }, [runCommand]);
1459
1501
  if (!editable) {
1460
- return /* @__PURE__ */ jsx12(
1502
+ return /* @__PURE__ */ jsx13(
1461
1503
  "div",
1462
1504
  {
1463
1505
  className: [className, "ordinatio-rte", "ordinatio-rte-readonly"].filter(Boolean).join(" "),
@@ -1466,9 +1508,9 @@ function RichTextEditor({
1466
1508
  }
1467
1509
  );
1468
1510
  }
1469
- return /* @__PURE__ */ jsxs11("div", { className: [className, "ordinatio-rte"].filter(Boolean).join(" "), style: className ? style : { ...containerStyle, ...style }, children: [
1470
- /* @__PURE__ */ jsxs11("div", { className: "ordinatio-rte-toolbar", style: toolbarStyle, children: [
1471
- TOOLBAR_BUTTONS.map((btn) => /* @__PURE__ */ jsx12(
1511
+ return /* @__PURE__ */ jsxs12("div", { className: [className, "ordinatio-rte"].filter(Boolean).join(" "), style: className ? style : { ...containerStyle, ...style }, children: [
1512
+ /* @__PURE__ */ jsxs12("div", { className: "ordinatio-rte-toolbar", style: toolbarStyle, children: [
1513
+ TOOLBAR_BUTTONS.map((btn) => /* @__PURE__ */ jsx13(
1472
1514
  "button",
1473
1515
  {
1474
1516
  type: "button",
@@ -1482,7 +1524,7 @@ function RichTextEditor({
1482
1524
  },
1483
1525
  btn.command
1484
1526
  )),
1485
- /* @__PURE__ */ jsx12(
1527
+ /* @__PURE__ */ jsx13(
1486
1528
  "button",
1487
1529
  {
1488
1530
  type: "button",
@@ -1495,10 +1537,10 @@ function RichTextEditor({
1495
1537
  children: "\u{1F517}"
1496
1538
  }
1497
1539
  ),
1498
- toolbarRight ? /* @__PURE__ */ jsx12("div", { className: "ordinatio-rte-toolbar-right", style: toolbarRightStyle, children: toolbarRight }) : null
1540
+ toolbarRight ? /* @__PURE__ */ jsx13("div", { className: "ordinatio-rte-toolbar-right", style: toolbarRightStyle, children: toolbarRight }) : null
1499
1541
  ] }),
1500
- linkError ? /* @__PURE__ */ jsx12("div", { className: "ordinatio-rte-link-error", role: "alert", style: linkErrorStyle, children: linkError }) : null,
1501
- /* @__PURE__ */ jsxs11("div", { className: "ordinatio-rte-editable-wrap", style: { position: "relative" }, children: [
1542
+ linkError ? /* @__PURE__ */ jsx13("div", { className: "ordinatio-rte-link-error", role: "alert", style: linkErrorStyle, children: linkError }) : null,
1543
+ /* @__PURE__ */ jsxs12("div", { className: "ordinatio-rte-editable-wrap", style: { position: "relative" }, children: [
1502
1544
  isEmpty ? (
1503
1545
  // Shown while empty REGARDLESS of focus — WorldClass cycle 1:
1504
1546
  // the prior `isEmpty && !isFocused` condition hid the
@@ -1507,7 +1549,7 @@ function RichTextEditor({
1507
1549
  // the click landed. Matches native `<textarea placeholder>`
1508
1550
  // behavior (visible while focused-and-empty, removed only once
1509
1551
  // the user types).
1510
- /* @__PURE__ */ jsx12(
1552
+ /* @__PURE__ */ jsx13(
1511
1553
  "div",
1512
1554
  {
1513
1555
  "aria-hidden": "true",
@@ -1517,7 +1559,7 @@ function RichTextEditor({
1517
1559
  }
1518
1560
  )
1519
1561
  ) : null,
1520
- /* @__PURE__ */ jsx12(
1562
+ /* @__PURE__ */ jsx13(
1521
1563
  "div",
1522
1564
  {
1523
1565
  ref: editorRef,
@@ -1629,7 +1671,7 @@ var disabledButtonStyle = {
1629
1671
  };
1630
1672
 
1631
1673
  // src/components/reply-panel.tsx
1632
- import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1674
+ import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
1633
1675
  function ReplyPanel({
1634
1676
  mode = "reply",
1635
1677
  subject,
@@ -1708,16 +1750,16 @@ function ReplyPanel({
1708
1750
  if (isMountedRef.current) setSending(false);
1709
1751
  }
1710
1752
  };
1711
- return /* @__PURE__ */ jsxs12(
1753
+ return /* @__PURE__ */ jsxs13(
1712
1754
  "div",
1713
1755
  {
1714
1756
  className: [className, "ordinatio-reply-panel"].filter(Boolean).join(" "),
1715
1757
  style: className ? style : { display: "flex", flexDirection: "column", gap: "8px", ...style },
1716
1758
  children: [
1717
- /* @__PURE__ */ jsxs12("div", { className: "ordinatio-reply-fields", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
1718
- /* @__PURE__ */ jsxs12("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1719
- /* @__PURE__ */ jsx13("label", { htmlFor: toId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "To" }),
1720
- /* @__PURE__ */ jsx13(
1759
+ /* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-fields", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
1760
+ /* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1761
+ /* @__PURE__ */ jsx14("label", { htmlFor: toId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "To" }),
1762
+ /* @__PURE__ */ jsx14(
1721
1763
  "input",
1722
1764
  {
1723
1765
  id: toId,
@@ -1745,7 +1787,7 @@ function ReplyPanel({
1745
1787
  // and aria-controls referenced ids (ccId/bccId) that don't
1746
1788
  // exist in the DOM until AFTER this button has already
1747
1789
  // unmounted. A one-directional reveal, not a toggle.
1748
- /* @__PURE__ */ jsx13(
1790
+ /* @__PURE__ */ jsx14(
1749
1791
  "button",
1750
1792
  {
1751
1793
  type: "button",
@@ -1758,10 +1800,10 @@ function ReplyPanel({
1758
1800
  )
1759
1801
  ) : null
1760
1802
  ] }),
1761
- showCcBcc ? /* @__PURE__ */ jsxs12(Fragment3, { children: [
1762
- /* @__PURE__ */ jsxs12("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1763
- /* @__PURE__ */ jsx13("label", { htmlFor: ccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Cc" }),
1764
- /* @__PURE__ */ jsx13(
1803
+ showCcBcc ? /* @__PURE__ */ jsxs13(Fragment3, { children: [
1804
+ /* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1805
+ /* @__PURE__ */ jsx14("label", { htmlFor: ccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Cc" }),
1806
+ /* @__PURE__ */ jsx14(
1765
1807
  "input",
1766
1808
  {
1767
1809
  id: ccId,
@@ -1779,9 +1821,9 @@ function ReplyPanel({
1779
1821
  }
1780
1822
  )
1781
1823
  ] }),
1782
- /* @__PURE__ */ jsxs12("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1783
- /* @__PURE__ */ jsx13("label", { htmlFor: bccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Bcc" }),
1784
- /* @__PURE__ */ jsx13(
1824
+ /* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1825
+ /* @__PURE__ */ jsx14("label", { htmlFor: bccId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Bcc" }),
1826
+ /* @__PURE__ */ jsx14(
1785
1827
  "input",
1786
1828
  {
1787
1829
  id: bccId,
@@ -1800,9 +1842,9 @@ function ReplyPanel({
1800
1842
  )
1801
1843
  ] })
1802
1844
  ] }) : null,
1803
- /* @__PURE__ */ jsxs12("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1804
- /* @__PURE__ */ jsx13("label", { htmlFor: subjectId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Subject" }),
1805
- /* @__PURE__ */ jsx13(
1845
+ /* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-field-row", style: fieldRowStyle, children: [
1846
+ /* @__PURE__ */ jsx14("label", { htmlFor: subjectId, className: "ordinatio-reply-field-label", style: fieldLabelStyle, children: "Subject" }),
1847
+ /* @__PURE__ */ jsx14(
1806
1848
  "input",
1807
1849
  {
1808
1850
  id: subjectId,
@@ -1821,9 +1863,9 @@ function ReplyPanel({
1821
1863
  )
1822
1864
  ] })
1823
1865
  ] }),
1824
- error ? /* @__PURE__ */ jsx13("div", { className: "ordinatio-reply-error", role: "alert", style: errorStyle, children: error }) : null,
1825
- sent && resolvedSuccessMessage ? /* @__PURE__ */ jsx13("div", { className: "ordinatio-reply-success", role: "status", style: successStyle, children: resolvedSuccessMessage }) : null,
1826
- /* @__PURE__ */ jsx13(
1866
+ error ? /* @__PURE__ */ jsx14("div", { className: "ordinatio-reply-error", role: "alert", style: errorStyle, children: error }) : null,
1867
+ sent && resolvedSuccessMessage ? /* @__PURE__ */ jsx14("div", { className: "ordinatio-reply-success", role: "status", style: successStyle, children: resolvedSuccessMessage }) : null,
1868
+ /* @__PURE__ */ jsx14(
1827
1869
  RichTextEditor,
1828
1870
  {
1829
1871
  content: body,
@@ -1837,8 +1879,8 @@ function ReplyPanel({
1837
1879
  locked: sending
1838
1880
  }
1839
1881
  ),
1840
- /* @__PURE__ */ jsxs12("div", { className: "ordinatio-reply-actions", style: actionsRowStyle, children: [
1841
- showCancel && onCancel ? /* @__PURE__ */ jsx13(
1882
+ /* @__PURE__ */ jsxs13("div", { className: "ordinatio-reply-actions", style: actionsRowStyle, children: [
1883
+ showCancel && onCancel ? /* @__PURE__ */ jsx14(
1842
1884
  "button",
1843
1885
  {
1844
1886
  type: "button",
@@ -1849,7 +1891,7 @@ function ReplyPanel({
1849
1891
  children: "Cancel"
1850
1892
  }
1851
1893
  ) : null,
1852
- /* @__PURE__ */ jsx13(
1894
+ /* @__PURE__ */ jsx14(
1853
1895
  "button",
1854
1896
  {
1855
1897
  type: "button",
@@ -2098,7 +2140,7 @@ function getShortcut(context, action) {
2098
2140
 
2099
2141
  // src/components/keyboard-shortcuts-panel.tsx
2100
2142
  import { useEffect as useEffect10, useState as useState10 } from "react";
2101
- import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
2143
+ import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
2102
2144
  function KeyboardShortcutsPanel({
2103
2145
  contexts = ALL_SHORTCUT_CONTEXTS
2104
2146
  }) {
@@ -2120,33 +2162,33 @@ function KeyboardShortcutsPanel({
2120
2162
  return () => window.removeEventListener("keydown", handleKey);
2121
2163
  }, [open]);
2122
2164
  if (!open) return null;
2123
- return /* @__PURE__ */ jsxs13(Fragment4, { children: [
2124
- /* @__PURE__ */ jsx14(
2165
+ return /* @__PURE__ */ jsxs14(Fragment4, { children: [
2166
+ /* @__PURE__ */ jsx15(
2125
2167
  "div",
2126
2168
  {
2127
2169
  className: "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",
2128
2170
  onClick: () => setOpen(false)
2129
2171
  }
2130
2172
  ),
2131
- /* @__PURE__ */ jsx14("div", { className: "fixed inset-x-0 top-[10%] z-50 mx-auto w-full max-w-lg", children: /* @__PURE__ */ jsxs13("div", { className: "rounded-xl border bg-background shadow-2xl overflow-hidden", children: [
2132
- /* @__PURE__ */ jsxs13("div", { className: "px-6 py-4 border-b", children: [
2133
- /* @__PURE__ */ jsx14("h2", { className: "text-lg font-semibold", children: "Keyboard Shortcuts" }),
2134
- /* @__PURE__ */ jsxs13("p", { className: "text-sm text-muted-foreground mt-0.5", children: [
2173
+ /* @__PURE__ */ jsx15("div", { className: "fixed inset-x-0 top-[10%] z-50 mx-auto w-full max-w-lg", children: /* @__PURE__ */ jsxs14("div", { className: "rounded-xl border bg-background shadow-2xl overflow-hidden", children: [
2174
+ /* @__PURE__ */ jsxs14("div", { className: "px-6 py-4 border-b", children: [
2175
+ /* @__PURE__ */ jsx15("h2", { className: "text-lg font-semibold", children: "Keyboard Shortcuts" }),
2176
+ /* @__PURE__ */ jsxs14("p", { className: "text-sm text-muted-foreground mt-0.5", children: [
2135
2177
  "Press ",
2136
- /* @__PURE__ */ jsx14("kbd", { className: "px-1.5 py-0.5 bg-muted rounded text-xs font-mono", children: "?" }),
2178
+ /* @__PURE__ */ jsx15("kbd", { className: "px-1.5 py-0.5 bg-muted rounded text-xs font-mono", children: "?" }),
2137
2179
  " to toggle this panel"
2138
2180
  ] })
2139
2181
  ] }),
2140
- /* @__PURE__ */ jsx14("div", { className: "px-6 py-4 max-h-[60vh] overflow-y-auto space-y-6", children: contexts.map((ctx) => /* @__PURE__ */ jsxs13("div", { children: [
2141
- /* @__PURE__ */ jsx14("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: ctx.label }),
2142
- /* @__PURE__ */ jsx14("div", { className: "space-y-1", children: Object.entries(ctx.shortcuts).map(([key, def]) => /* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between py-1", children: [
2143
- /* @__PURE__ */ jsx14("span", { className: "text-sm", children: def.description }),
2144
- /* @__PURE__ */ jsx14("kbd", { className: "px-2 py-0.5 bg-muted rounded text-xs font-mono min-w-[2rem] text-center", children: def.display })
2182
+ /* @__PURE__ */ jsx15("div", { className: "px-6 py-4 max-h-[60vh] overflow-y-auto space-y-6", children: contexts.map((ctx) => /* @__PURE__ */ jsxs14("div", { children: [
2183
+ /* @__PURE__ */ jsx15("h3", { className: "text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2", children: ctx.label }),
2184
+ /* @__PURE__ */ jsx15("div", { className: "space-y-1", children: Object.entries(ctx.shortcuts).map(([key, def]) => /* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between py-1", children: [
2185
+ /* @__PURE__ */ jsx15("span", { className: "text-sm", children: def.description }),
2186
+ /* @__PURE__ */ jsx15("kbd", { className: "px-2 py-0.5 bg-muted rounded text-xs font-mono min-w-[2rem] text-center", children: def.display })
2145
2187
  ] }, key)) })
2146
2188
  ] }, ctx.name)) }),
2147
- /* @__PURE__ */ jsxs13("div", { className: "px-6 py-3 border-t bg-muted/30 text-xs text-muted-foreground text-center", children: [
2189
+ /* @__PURE__ */ jsxs14("div", { className: "px-6 py-3 border-t bg-muted/30 text-xs text-muted-foreground text-center", children: [
2148
2190
  "Press ",
2149
- /* @__PURE__ */ jsx14("kbd", { className: "px-1 py-0.5 bg-muted rounded", children: "Esc" }),
2191
+ /* @__PURE__ */ jsx15("kbd", { className: "px-1 py-0.5 bg-muted rounded", children: "Esc" }),
2150
2192
  " to close"
2151
2193
  ] })
2152
2194
  ] }) })
@@ -2633,9 +2675,9 @@ function clearCache() {
2633
2675
  import { useState as useState19, useEffect as useEffect18, useCallback as useCallback11 } from "react";
2634
2676
  function usePreferences({
2635
2677
  endpoint,
2636
- defaults: defaults8
2678
+ defaults: defaults9
2637
2679
  }) {
2638
- const [preferences, setPreferences] = useState19(defaults8 ?? null);
2680
+ const [preferences, setPreferences] = useState19(defaults9 ?? null);
2639
2681
  const [loading, setLoading] = useState19(true);
2640
2682
  const [error, setError] = useState19(null);
2641
2683
  const fetchPreferences = useCallback11(async () => {
@@ -2644,7 +2686,7 @@ function usePreferences({
2644
2686
  const res = await fetch(endpoint);
2645
2687
  if (!res.ok) {
2646
2688
  if (res.status === 401) {
2647
- setPreferences(defaults8 ?? null);
2689
+ setPreferences(defaults9 ?? null);
2648
2690
  return;
2649
2691
  }
2650
2692
  throw new Error("Failed to fetch preferences");
@@ -2656,7 +2698,7 @@ function usePreferences({
2656
2698
  } finally {
2657
2699
  setLoading(false);
2658
2700
  }
2659
- }, [endpoint, defaults8]);
2701
+ }, [endpoint, defaults9]);
2660
2702
  useEffect18(() => {
2661
2703
  fetchPreferences();
2662
2704
  }, [fetchPreferences]);
@@ -3031,6 +3073,7 @@ export {
3031
3073
  INBOX_SHORTCUTS,
3032
3074
  KeyboardShortcutsPanel,
3033
3075
  PICKER_SEARCH_FAILURE,
3076
+ Pager,
3034
3077
  RENDER_ERRORS,
3035
3078
  REPLY_LAYOUT_OPTIONS,
3036
3079
  ReplyPanel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordinatio/ui",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Reusable React components and hooks for Ordinatio applications",
@@ -21,6 +21,7 @@
21
21
  "files": [
22
22
  "dist",
23
23
  "README.md",
24
+ "CHANGELOG.md",
24
25
  "LICENSE"
25
26
  ],
26
27
  "peerDependencies": {