@dloizides/ui-layout 1.20.0 → 1.22.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 CHANGED
@@ -1,5 +1,74 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.22.0
4
+
5
+ **Two shared modal primitives: a themed centered `Modal` dialog and a `ConfirmDialog` popup.**
6
+
7
+ Until now the kit had no shared centered dialog — only `ModalShell` (a full-screen slide-up sheet)
8
+ and `ModalDropdown` (a selector). Each portal hand-rolled its own edit dialog (e.g. kefi-web's
9
+ `PromoterActionModal`) and confirmed destructive actions with an ugly inline table row. These two
10
+ primitives replace both, so all 7 portals share one accessible, themed implementation.
11
+
12
+ - **New component `Modal`** — a centered dialog overlay for RN + RN-web: a scrim, a rounded themed
13
+ surface, an optional header (`title` + a top-right **✕ close** — a 44dp `IconButton` with a web
14
+ `tooltip`/aria-label "Close"), a scrollable body (`children`), and an optional `footer`. Dismissal
15
+ funnels to `onClose` from four routes: the ✕, a **backdrop** press, **Escape** on web
16
+ (`useEscapeKey`), and the hardware back button on native (RN `Modal`'s `onRequestClose`). It is
17
+ `role="dialog"` + `aria-modal` (`accessibilityViewIsModal`), **focus-trapped** on web
18
+ (`useFocusTrap`, restoring focus to the opener on close) and **scroll-locked** (`useScrollLock`).
19
+ Props: `visible`, `onClose`, `title?`, `children?`, `footer?`, `size?` (`sm`/`md`/`lg`, default
20
+ `md`), `showClose?` (default `true`), `testID?` (default `modal`), `accessibilityLabel?`. testIDs:
21
+ `${testID}-close`, `${testID}-backdrop`. All colours read from `useUi()` — no raw literals.
22
+ - **New component `ConfirmDialog`** — built ON `Modal`, for confirmations. Renders the `message`
23
+ plus a Cancel + Confirm button row (from `@dloizides/ui-buttons`). `destructive` paints the
24
+ Confirm with the `danger` (red) variant for irreversible actions. **Cancel is first in the DOM so
25
+ the focus trap lands on the SAFE action**; the ✕ is hidden (Cancel is the explicit dismiss). While
26
+ `busy`, Confirm shows a spinner and Cancel is disabled. Cancel / backdrop / Escape → `onCancel`.
27
+ Props: `visible`, `title`, `message`, `confirmLabel?`, `cancelLabel?`, `destructive?`, `onConfirm`,
28
+ `onCancel`, `busy?`, `testID?` (default `confirm-dialog`). testIDs: `${testID}-confirm`,
29
+ `${testID}-cancel`, `${testID}-message`.
30
+ - **New exported type `ModalSize`** (`'sm' | 'md' | 'lg'`) — a plain string union (matching the
31
+ kit's `ButtonSize` convention; no `const enum` crosses the package boundary).
32
+ - **New i18n keys** the host must provide: `common.close` (✕ label), plus for `ConfirmDialog`
33
+ defaults `common.confirm` / `common.confirmHint` / `common.cancel` / `common.cancelHint`. Reuses the
34
+ existing `common.closeDialogHint`, `common.dialog`, `common.dismissDropdown(Hint)` keys.
35
+ - **New peer dependency `@dloizides/ui-buttons` (`>=1.8.0`)** — `ConfirmDialog` reuses its `Button`,
36
+ `Modal` reuses its `IconButton` for the ✕, rather than reinventing button chrome.
37
+
38
+ Additive: `ModalShell`, `ModalDropdown` and every existing export/selector are untouched. Covered by
39
+ `Modal.test.tsx`, `ConfirmDialog.test.tsx`, `useEscapeKey.test.ts`, `useScrollLock.test.ts`.
40
+
41
+ > Note: `@dloizides/ui-feedback` also exports a lighter `ConfirmDialog` (no ✕ / Escape / focus-trap,
42
+ > own buttons). This ui-layout one is the richer, `Modal`-based dialog the portals should adopt.
43
+
44
+ ## 1.21.0
45
+
46
+ **The collapsed `Tabs` menu can now present as a HAMBURGER (☰) — the universal mobile-nav affordance.**
47
+
48
+ The collapsed organizer nav reads better on a phone as a ☰ hamburger than as a caret field.
49
+ This adds an opt-in so a consumer can choose either presentation; the default is unchanged.
50
+
51
+ - **New opt-in prop `ModalDropdown.showHamburger?: boolean` (default `false`).** When set, the
52
+ DEFAULT trigger renders a ☰ glyph LEADING the active option's label, with the same bordered
53
+ field box, theme tokens and ≥44dp (`MIN_TOUCH_TARGET`) hit target as the caret variant. It
54
+ **takes precedence over `showCaret`** (a hamburger already IS the "this is a menu" cue, so the
55
+ trailing caret would be redundant) and, like `showCaret`, is ignored when a custom `renderTrigger`
56
+ is supplied. The glyph is a font character (U+2630) — no icon package enters this contract-pure
57
+ kit — and its colour comes from `colors.textSecondary` (no raw literals). It is decorative: the
58
+ trigger's `aria-label` still names the control, so screen readers do not announce the glyph.
59
+ - **New exported enum `TabsCollapsedTrigger { Caret, Hamburger }`** + new optional prop
60
+ **`Tabs.collapsedTrigger` / `TabsMenu.collapsedTrigger` (default `Caret`).** Selects how the
61
+ COLLAPSED (mobile) tab menu trigger presents; only affects the collapsed form, the wide pill
62
+ strip is identical either way. Exported as a regular (runtime) enum for the same reason as
63
+ `DropdownVariant` — a `const enum` cannot cross the published-package boundary under
64
+ `isolatedModules`.
65
+
66
+ Backward-compatible: two new optional props + one new enum, all defaulting to the prior behaviour;
67
+ no testID/selector changes. Per-tab E2E selectors (`{idPrefix}-menu` trigger, `{idPrefix}-tab-{key}`
68
+ / descriptor option testIDs) are untouched. No new i18n keys (the existing `common.tabsMenuHint`
69
+ serves both presentations). Covered by component tests (`ModalDropdown.test.tsx`,
70
+ `Tabs.collapsed.test.tsx`).
71
+
3
72
  ## 1.20.0
4
73
 
5
74
  **The collapsed `Tabs` menu now READS as a menu — a caret affordance + guaranteed focus.**
package/README.md CHANGED
@@ -11,12 +11,48 @@ Read theme + translations from the shared `@dloizides/ui-feedback` context (`use
11
11
  | `Heading` | Themed section heading text. |
12
12
  | `StatusBadge` | Status pill — caller supplies `label`/`color`/`backgroundColor`. |
13
13
  | `UpgradePrompt` | Free-tier upgrade nudge; CTA navigates to the billing route via `useUi().navigate`. |
14
- | `Tabs` | Controlled tabbed section shell. **Responsive**: a horizontal `role=tablist` pill strip on wide web, collapsing to a real mobile MENU (a trigger + vertical section list, via `ModalDropdown`) below `collapseBelow` (default 768) or on native. Per-tab `testID`s survive in both modes. Requires the `common.tabsMenuHint` key. |
15
- | `ModalDropdown` | Generic dropdown selector. **Responsive by default**: an inline anchored menu on wide/desktop web, a modal on narrow/mobile — override per screen with `variant`. |
14
+ | `Tabs` | Controlled tabbed section shell. **Responsive**: a horizontal `role=tablist` pill strip on wide web, collapsing to a real mobile MENU (a trigger + vertical section list, via `ModalDropdown`) below `collapseBelow` (default 768) or on native. The collapsed trigger presents as a caret field (default) or a ☰ hamburger via `collapsedTrigger`. Per-tab `testID`s survive in both modes. Requires the `common.tabsMenuHint` key. |
15
+ | `TabsCollapsedTrigger` | Enum (`Caret` / `Hamburger`) selecting how the collapsed `Tabs` menu trigger presents. Defaults to `Caret`. |
16
+ | `ModalDropdown` | Generic dropdown selector. **Responsive by default**: an inline anchored menu on wide/desktop web, a modal on narrow/mobile — override per screen with `variant`. Opt into a menu affordance on the default trigger with `showCaret` (trailing ▾) or `showHamburger` (leading ☰, wins over `showCaret`). |
16
17
  | `DropdownVariant` | Enum (`Menu` / `Modal`) to force a `ModalDropdown` rendering variant. |
18
+ | `ModalShell` | Full-screen **slide-up sheet** with a themed header (title + close). For a page-covering editor. Dismiss via `onCancel`. |
19
+ | `Modal` | Themed **centered dialog overlay**: scrim + rounded card, optional header with a top-right ✕ close, scrollable body, optional footer. Dismiss via ✕ / backdrop / Escape (web) / hardware back (native); focus-trapped + scroll-locked. `size` = `sm`/`md`/`lg`. |
20
+ | `ConfirmDialog` | Confirm/cancel popup built on `Modal`. Cancel + Confirm buttons (from `@dloizides/ui-buttons`); `destructive` paints the Confirm red. Cancel is focus-default (safe), and is disabled while `busy` (Confirm shows a spinner). Cancel / backdrop / Escape → `onCancel`. |
17
21
  | `Accordion` / `AccordionItem` | Themed expand/collapse disclosure group (replaces hand-rolled `<details>`/expanders). Controlled or uncontrolled, single- or multi-open, animated, keyboard + screen-reader accessible. |
18
22
  | `useFocusTrap` | Web keyboard focus-trap hook (no-op on native). |
19
23
 
24
+ ### `Modal` & `ConfirmDialog`
25
+
26
+ ```tsx
27
+ import { Modal, ConfirmDialog } from '@dloizides/ui-layout';
28
+
29
+ // A centered edit dialog with a top-right ✕:
30
+ <Modal visible={editing} title="Edit details" onClose={() => setEditing(false)} footer={<SaveRow />}>
31
+ <AttendeeForm />
32
+ </Modal>
33
+
34
+ // A destructive confirmation popup:
35
+ <ConfirmDialog
36
+ visible={confirming}
37
+ destructive
38
+ title="Remove attendee?"
39
+ message="This can't be undone."
40
+ busy={isDeleting}
41
+ onConfirm={remove}
42
+ onCancel={() => setConfirming(false)}
43
+ />
44
+ ```
45
+
46
+ - **Dismissal** — `Modal`: ✕ button, backdrop press, Escape (web), hardware back (native), all → `onClose`.
47
+ `ConfirmDialog`: Cancel, backdrop, Escape → `onCancel`; it hides the ✕ so the focus trap lands on the safe Cancel action.
48
+ - **testIDs** — `Modal` (default `modal`): `${testID}-close`, `${testID}-backdrop`.
49
+ `ConfirmDialog` (default `confirm-dialog`): `${testID}-confirm`, `${testID}-cancel`, `${testID}-message`.
50
+ - **i18n keys** the host must provide: `common.close` (✕ label), `common.closeDialogHint`, `common.dialog`
51
+ (fallback dialog name), and for `ConfirmDialog` defaults `common.confirm` / `common.confirmHint` /
52
+ `common.cancel` / `common.cancelHint`. Pass `confirmLabel`/`cancelLabel` (already-localized) to override.
53
+ - **a11y** — `role="dialog"` + `aria-modal`; focus trapped on web and restored to the opener on close.
54
+ Note (RN-web): `accessibilityHint` does not reach the DOM, so the ✕'s hover `tooltip` carries the visible helper text.
55
+
20
56
  ### `Accordion`
21
57
 
22
58
  A compound component: an `Accordion` container that owns the open state + `AccordionItem`
package/dist/index.d.mts CHANGED
@@ -106,6 +106,31 @@ interface SegmentedControlProps<V extends string = string> {
106
106
  */
107
107
  declare function SegmentedControl<V extends string = string>({ options, value, onChange, accessibilityLabel, style, testID, }: SegmentedControlProps<V>): React.ReactElement;
108
108
 
109
+ /**
110
+ * How the COLLAPSED (mobile) {@link import('./Tabs').Tabs} menu trigger presents.
111
+ *
112
+ * Below the collapse breakpoint the tab strip becomes a single trigger that opens
113
+ * the vertical section list. This selects that trigger's affordance:
114
+ *
115
+ * - `Caret` — a bordered field showing the active section's label + a rotating ▾
116
+ * caret. The default, so every existing consumer is visually unchanged.
117
+ * - `Hamburger` — a ☰ menu icon (the universal mobile-nav affordance) leading the
118
+ * active section's label. Opt in for a phone-first nav that reads as a menu.
119
+ *
120
+ * Exported as a regular (non-`const`) enum on purpose — the SAME reason as
121
+ * {@link import('../ModalDropdown/DropdownVariant').DropdownVariant}: a `const enum`
122
+ * is inlined at compile time and cannot cross a published-package boundary when the
123
+ * consumer bundles with `isolatedModules` (esbuild / vite / babel — i.e. every app
124
+ * that consumes this package). A regular enum emits a runtime object safe to import
125
+ * and compare in any consumer.
126
+ */
127
+ declare enum TabsCollapsedTrigger {
128
+ /** Bordered field with the active label + a rotating ▾ caret (default, unchanged). */
129
+ Caret = "caret",
130
+ /** A ☰ hamburger icon leading the active label — the mobile-nav affordance. */
131
+ Hamburger = "hamburger"
132
+ }
133
+
109
134
  /**
110
135
  * Tabs — a named-section shell for a long dashboard. On WIDE viewports it is a
111
136
  * horizontal strip of pill tabs (a single scrollable `nowrap` row) plus the
@@ -162,6 +187,13 @@ interface TabsProps {
162
187
  * force the menu, or `0` to keep the row on any web width.
163
188
  */
164
189
  collapseBelow?: number;
190
+ /**
191
+ * How the COLLAPSED (mobile) menu trigger presents — a caret field (default) or a
192
+ * ☰ hamburger. See {@link TabsCollapsedTrigger}. Defaults to `Caret`, so existing
193
+ * consumers are unchanged; a phone-first nav opts into `Hamburger`. Only affects the
194
+ * collapsed form — the wide pill strip is identical either way.
195
+ */
196
+ collapsedTrigger?: TabsCollapsedTrigger;
165
197
  /** Style override merged onto the root container. */
166
198
  style?: StyleProp<ViewStyle>;
167
199
  /** Style override merged onto the tab strip (wide mode only). */
@@ -175,7 +207,7 @@ interface TabsProps {
175
207
  * the wide pill strip or — below `collapseBelow` — the mobile menu. Generic-free
176
208
  * by design: tab identity is a plain string `key`.
177
209
  */
178
- declare const Tabs: ({ tabs, activeKey, onChange, accessibilityLabel, children, idPrefix, collapseBelow, style, stripStyle, panelStyle, testID, }: TabsProps) => React.ReactElement;
210
+ declare const Tabs: ({ tabs, activeKey, onChange, accessibilityLabel, children, idPrefix, collapseBelow, collapsedTrigger, style, stripStyle, panelStyle, testID, }: TabsProps) => React.ReactElement;
179
211
 
180
212
  /**
181
213
  * UpgradePrompt — shown when a free-tier user hits a feature limit. CTA navigates to the
@@ -278,8 +310,18 @@ interface ModalDropdownProps<T> {
278
310
  * its own visuals, affordance included.
279
311
  */
280
312
  showCaret?: boolean;
313
+ /**
314
+ * Present the DEFAULT trigger as a HAMBURGER (☰) menu: the universal mobile-nav glyph LEADING the
315
+ * active option's label, with the same bordered field box and ≥44dp hit target. Opt-in and OFF by
316
+ * default. When set it takes precedence over `showCaret` (a hamburger already IS the "this is a
317
+ * menu" cue, so the trailing caret is redundant), and — like `showCaret` — it is ignored when a
318
+ * custom `renderTrigger` is supplied. The glyph is a font character (U+2630), so no icon package
319
+ * enters this contract-pure kit, and it is decorative: the trigger's `aria-label` names the
320
+ * control, so screen readers do not announce it.
321
+ */
322
+ showHamburger?: boolean;
281
323
  }
282
- declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, renderTrigger, optionTestID, menuMinWidth, showCaret, }: ModalDropdownProps<T>) => React.ReactElement;
324
+ declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, renderTrigger, optionTestID, menuMinWidth, showCaret, showHamburger, }: ModalDropdownProps<T>) => React.ReactElement;
283
325
 
284
326
  /**
285
327
  * ModalShell — a slide-up full-screen modal with a themed header (title + close button)
@@ -296,6 +338,106 @@ interface ModalShellProps {
296
338
  }
297
339
  declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, showClose, }: ModalShellProps) => React.ReactElement;
298
340
 
341
+ /**
342
+ * Max-width preset for {@link Modal}.
343
+ *
344
+ * A plain string union (NOT a const enum), matching the kit's convention — see
345
+ * `@dloizides/ui-buttons`' `ButtonSize`. Call sites stay ergonomic (`size="md"`) and no
346
+ * const enum crosses the package boundary, where tsup/esbuild inline them unreliably.
347
+ *
348
+ * - `sm` — compact confirmations / short forms.
349
+ * - `md` (default) — the general dialog.
350
+ * - `lg` — wide editors.
351
+ */
352
+ type ModalSize = 'sm' | 'md' | 'lg';
353
+
354
+ /**
355
+ * Modal — a themed, CENTERED dialog overlay for RN + RN-web.
356
+ *
357
+ * Distinct from this package's {@link import('../ModalShell/ModalShell').ModalShell}, which is a
358
+ * full-screen slide-up sheet. `Modal` is the floating card an app opens over the current screen:
359
+ * a scrim, a rounded surface, an optional header (title + a top-right ✕ close), a scrollable body,
360
+ * and an optional footer (action buttons). It is the shared shell {@link ConfirmDialog} is built on,
361
+ * and the replacement for per-app dialogs like kefi-web's `PromoterActionModal`.
362
+ *
363
+ * DISMISSAL — four routes, all funnel to `onClose`:
364
+ * - the top-right ✕ button (web tooltip + aria-label "Close"; a 44dp `IconButton` target),
365
+ * - a press on the backdrop scrim (a SIBLING of the dialog, so option/action buttons are never
366
+ * nested inside a button — invalid DOM),
367
+ * - Escape on web (via {@link useEscapeKey}),
368
+ * - the hardware back button on native (RN `Modal`'s `onRequestClose`).
369
+ *
370
+ * ACCESSIBILITY: the dialog carries `role="dialog"` + `aria-modal` (via `accessibilityViewIsModal`)
371
+ * and an accessible name (`accessibilityLabel` → `title` → the neutral "dialog" key). Focus is
372
+ * trapped within the dialog on web ({@link useFocusTrap}) and restored to the opener on close, and
373
+ * page scroll behind the dialog is locked ({@link useScrollLock}).
374
+ *
375
+ * Every colour is read from the app's theme via `useUi()` — no raw literals.
376
+ */
377
+
378
+ interface ModalProps {
379
+ /** Whether the dialog is mounted + shown. */
380
+ visible: boolean;
381
+ /** Called by every dismissal route: ✕, backdrop, Escape (web), hardware back (native). */
382
+ onClose: () => void;
383
+ /** Header title. Omit for a chromeless dialog (the ✕ still shows unless `showClose` is false). */
384
+ title?: string;
385
+ /** Dialog body. Rendered inside a scroll view so long content scrolls within the dialog. */
386
+ children?: React.ReactNode;
387
+ /** Optional footer, typically an action-button row (see {@link ConfirmDialog}). */
388
+ footer?: React.ReactNode;
389
+ /** Max-width preset. Default `md`. */
390
+ size?: ModalSize;
391
+ /**
392
+ * Show the top-right ✕ close button. Default `true`. `ConfirmDialog` sets it `false` — it offers
393
+ * an explicit Cancel, and hiding the ✕ lets the web focus trap land on the SAFE Cancel action.
394
+ */
395
+ showClose?: boolean;
396
+ /** Base testID. Default `modal`. The ✕ is `${testID}-close`, the backdrop `${testID}-backdrop`. */
397
+ testID?: string;
398
+ /** Accessible name of the dialog. Falls back to `title`, then the neutral "dialog" key. */
399
+ accessibilityLabel?: string;
400
+ }
401
+ declare const Modal: ({ visible, onClose, title, children, footer, size, showClose, testID, accessibilityLabel, }: ModalProps) => React.ReactElement;
402
+
403
+ /**
404
+ * ConfirmDialog — a confirm/cancel popup built ON {@link Modal}, for the "are you sure?" moment.
405
+ *
406
+ * Replaces per-app inline confirms (e.g. kefi-web's inline attendee-delete row) with one shared,
407
+ * themed dialog reused across every portal. Renders the `message` in the body and a Cancel + Confirm
408
+ * button row (from `@dloizides/ui-buttons`) in the footer. When `destructive` is set the Confirm
409
+ * button uses the `danger` variant — the red, irreversible-action treatment.
410
+ *
411
+ * SAFE BY DEFAULT: Cancel is FIRST in the DOM, so the web focus trap lands on it — a keyboard user
412
+ * never has a destructive Confirm pre-focused. Cancel, the backdrop, and Escape all call `onCancel`;
413
+ * the ✕ is hidden (the explicit Cancel is the dismiss affordance). While `busy`, Confirm shows its
414
+ * spinner and Cancel is disabled, so a slow delete cannot be fired twice or cancelled mid-flight.
415
+ */
416
+
417
+ interface ConfirmDialogProps {
418
+ /** Whether the dialog is shown. */
419
+ visible: boolean;
420
+ /** Header title, e.g. "Remove attendee?". */
421
+ title: string;
422
+ /** Body copy, e.g. "This can't be undone." */
423
+ message: string;
424
+ /** Confirm button label. Defaults to the host's `common.confirm` translation. */
425
+ confirmLabel?: string;
426
+ /** Cancel button label. Defaults to the host's `common.cancel` translation. */
427
+ cancelLabel?: string;
428
+ /** Red `danger` Confirm for an irreversible action. Default `false` (blue `primary`). */
429
+ destructive?: boolean;
430
+ /** Called when the user presses Confirm. */
431
+ onConfirm: () => void;
432
+ /** Called by Cancel, the backdrop, and Escape. */
433
+ onCancel: () => void;
434
+ /** In-flight: Confirm shows a spinner and Cancel is disabled. Default `false`. */
435
+ busy?: boolean;
436
+ /** Base testID. Default `confirm-dialog`. Confirm is `${testID}-confirm`, Cancel `${testID}-cancel`. */
437
+ testID?: string;
438
+ }
439
+ declare const ConfirmDialog: ({ visible, title, message, confirmLabel, cancelLabel, destructive, onConfirm, onCancel, busy, testID, }: ConfirmDialogProps) => React.ReactElement;
440
+
299
441
  /**
300
442
  * AccordionVariant — the two visual treatments for an {@link Accordion}.
301
443
  *
@@ -575,6 +717,10 @@ declare const LAYOUT_TEST_IDS: {
575
717
  readonly upgradePromptDismiss: "upgrade-prompt-dismiss";
576
718
  readonly modalShell: "template-modal";
577
719
  readonly modalShellClose: "cancel-button";
720
+ /** Default base testID for the centered `Modal`; ✕ is `modal-close`, backdrop `modal-backdrop`. */
721
+ readonly modal: "modal";
722
+ /** Default base testID for `ConfirmDialog`; Confirm/Cancel are `confirm-dialog-{confirm,cancel}`. */
723
+ readonly confirmDialog: "confirm-dialog";
578
724
  readonly accordion: "accordion";
579
725
  };
580
726
  /** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
@@ -618,6 +764,14 @@ declare const LAYOUT_I18N: {
618
764
  readonly close: "quizTemplates.cancel";
619
765
  /** `ModalShell`: heading fallback when no title is supplied. */
620
766
  readonly closeHeading: "close";
767
+ /** `Modal`: accessible name + web tooltip of the top-right ✕ close button. */
768
+ readonly dialogClose: "common.close";
769
+ /** `ConfirmDialog`: default Confirm button label (overridable via `confirmLabel`) + its hint. */
770
+ readonly confirm: "common.confirm";
771
+ readonly confirmHint: "common.confirmHint";
772
+ /** `ConfirmDialog`: default Cancel button label (overridable via `cancelLabel`) + its hint. */
773
+ readonly cancel: "common.cancel";
774
+ readonly cancelHint: "common.cancelHint";
621
775
  readonly upgradePromptTitle: "settings.billing.upgradePrompt.title";
622
776
  /** Body copy, parameterised: "…requires {{p1}}, you are on {{p2}}." */
623
777
  readonly upgradePromptMessage: "settings.billing.upgradePrompt.message";
@@ -639,4 +793,4 @@ declare const LAYOUT_I18N: {
639
793
  readonly copyableIdHint: "common.copyableIdHint";
640
794
  };
641
795
 
642
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, COPY_FEEDBACK_MS, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, type TabDescriptor, Tabs, type TabsProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
796
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
package/dist/index.d.ts CHANGED
@@ -106,6 +106,31 @@ interface SegmentedControlProps<V extends string = string> {
106
106
  */
107
107
  declare function SegmentedControl<V extends string = string>({ options, value, onChange, accessibilityLabel, style, testID, }: SegmentedControlProps<V>): React.ReactElement;
108
108
 
109
+ /**
110
+ * How the COLLAPSED (mobile) {@link import('./Tabs').Tabs} menu trigger presents.
111
+ *
112
+ * Below the collapse breakpoint the tab strip becomes a single trigger that opens
113
+ * the vertical section list. This selects that trigger's affordance:
114
+ *
115
+ * - `Caret` — a bordered field showing the active section's label + a rotating ▾
116
+ * caret. The default, so every existing consumer is visually unchanged.
117
+ * - `Hamburger` — a ☰ menu icon (the universal mobile-nav affordance) leading the
118
+ * active section's label. Opt in for a phone-first nav that reads as a menu.
119
+ *
120
+ * Exported as a regular (non-`const`) enum on purpose — the SAME reason as
121
+ * {@link import('../ModalDropdown/DropdownVariant').DropdownVariant}: a `const enum`
122
+ * is inlined at compile time and cannot cross a published-package boundary when the
123
+ * consumer bundles with `isolatedModules` (esbuild / vite / babel — i.e. every app
124
+ * that consumes this package). A regular enum emits a runtime object safe to import
125
+ * and compare in any consumer.
126
+ */
127
+ declare enum TabsCollapsedTrigger {
128
+ /** Bordered field with the active label + a rotating ▾ caret (default, unchanged). */
129
+ Caret = "caret",
130
+ /** A ☰ hamburger icon leading the active label — the mobile-nav affordance. */
131
+ Hamburger = "hamburger"
132
+ }
133
+
109
134
  /**
110
135
  * Tabs — a named-section shell for a long dashboard. On WIDE viewports it is a
111
136
  * horizontal strip of pill tabs (a single scrollable `nowrap` row) plus the
@@ -162,6 +187,13 @@ interface TabsProps {
162
187
  * force the menu, or `0` to keep the row on any web width.
163
188
  */
164
189
  collapseBelow?: number;
190
+ /**
191
+ * How the COLLAPSED (mobile) menu trigger presents — a caret field (default) or a
192
+ * ☰ hamburger. See {@link TabsCollapsedTrigger}. Defaults to `Caret`, so existing
193
+ * consumers are unchanged; a phone-first nav opts into `Hamburger`. Only affects the
194
+ * collapsed form — the wide pill strip is identical either way.
195
+ */
196
+ collapsedTrigger?: TabsCollapsedTrigger;
165
197
  /** Style override merged onto the root container. */
166
198
  style?: StyleProp<ViewStyle>;
167
199
  /** Style override merged onto the tab strip (wide mode only). */
@@ -175,7 +207,7 @@ interface TabsProps {
175
207
  * the wide pill strip or — below `collapseBelow` — the mobile menu. Generic-free
176
208
  * by design: tab identity is a plain string `key`.
177
209
  */
178
- declare const Tabs: ({ tabs, activeKey, onChange, accessibilityLabel, children, idPrefix, collapseBelow, style, stripStyle, panelStyle, testID, }: TabsProps) => React.ReactElement;
210
+ declare const Tabs: ({ tabs, activeKey, onChange, accessibilityLabel, children, idPrefix, collapseBelow, collapsedTrigger, style, stripStyle, panelStyle, testID, }: TabsProps) => React.ReactElement;
179
211
 
180
212
  /**
181
213
  * UpgradePrompt — shown when a free-tier user hits a feature limit. CTA navigates to the
@@ -278,8 +310,18 @@ interface ModalDropdownProps<T> {
278
310
  * its own visuals, affordance included.
279
311
  */
280
312
  showCaret?: boolean;
313
+ /**
314
+ * Present the DEFAULT trigger as a HAMBURGER (☰) menu: the universal mobile-nav glyph LEADING the
315
+ * active option's label, with the same bordered field box and ≥44dp hit target. Opt-in and OFF by
316
+ * default. When set it takes precedence over `showCaret` (a hamburger already IS the "this is a
317
+ * menu" cue, so the trailing caret is redundant), and — like `showCaret` — it is ignored when a
318
+ * custom `renderTrigger` is supplied. The glyph is a font character (U+2630), so no icon package
319
+ * enters this contract-pure kit, and it is decorative: the trigger's `aria-label` names the
320
+ * control, so screen readers do not announce it.
321
+ */
322
+ showHamburger?: boolean;
281
323
  }
282
- declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, renderTrigger, optionTestID, menuMinWidth, showCaret, }: ModalDropdownProps<T>) => React.ReactElement;
324
+ declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, renderTrigger, optionTestID, menuMinWidth, showCaret, showHamburger, }: ModalDropdownProps<T>) => React.ReactElement;
283
325
 
284
326
  /**
285
327
  * ModalShell — a slide-up full-screen modal with a themed header (title + close button)
@@ -296,6 +338,106 @@ interface ModalShellProps {
296
338
  }
297
339
  declare const ModalShell: ({ visible, onCancel, title, children, contentStyle, showClose, }: ModalShellProps) => React.ReactElement;
298
340
 
341
+ /**
342
+ * Max-width preset for {@link Modal}.
343
+ *
344
+ * A plain string union (NOT a const enum), matching the kit's convention — see
345
+ * `@dloizides/ui-buttons`' `ButtonSize`. Call sites stay ergonomic (`size="md"`) and no
346
+ * const enum crosses the package boundary, where tsup/esbuild inline them unreliably.
347
+ *
348
+ * - `sm` — compact confirmations / short forms.
349
+ * - `md` (default) — the general dialog.
350
+ * - `lg` — wide editors.
351
+ */
352
+ type ModalSize = 'sm' | 'md' | 'lg';
353
+
354
+ /**
355
+ * Modal — a themed, CENTERED dialog overlay for RN + RN-web.
356
+ *
357
+ * Distinct from this package's {@link import('../ModalShell/ModalShell').ModalShell}, which is a
358
+ * full-screen slide-up sheet. `Modal` is the floating card an app opens over the current screen:
359
+ * a scrim, a rounded surface, an optional header (title + a top-right ✕ close), a scrollable body,
360
+ * and an optional footer (action buttons). It is the shared shell {@link ConfirmDialog} is built on,
361
+ * and the replacement for per-app dialogs like kefi-web's `PromoterActionModal`.
362
+ *
363
+ * DISMISSAL — four routes, all funnel to `onClose`:
364
+ * - the top-right ✕ button (web tooltip + aria-label "Close"; a 44dp `IconButton` target),
365
+ * - a press on the backdrop scrim (a SIBLING of the dialog, so option/action buttons are never
366
+ * nested inside a button — invalid DOM),
367
+ * - Escape on web (via {@link useEscapeKey}),
368
+ * - the hardware back button on native (RN `Modal`'s `onRequestClose`).
369
+ *
370
+ * ACCESSIBILITY: the dialog carries `role="dialog"` + `aria-modal` (via `accessibilityViewIsModal`)
371
+ * and an accessible name (`accessibilityLabel` → `title` → the neutral "dialog" key). Focus is
372
+ * trapped within the dialog on web ({@link useFocusTrap}) and restored to the opener on close, and
373
+ * page scroll behind the dialog is locked ({@link useScrollLock}).
374
+ *
375
+ * Every colour is read from the app's theme via `useUi()` — no raw literals.
376
+ */
377
+
378
+ interface ModalProps {
379
+ /** Whether the dialog is mounted + shown. */
380
+ visible: boolean;
381
+ /** Called by every dismissal route: ✕, backdrop, Escape (web), hardware back (native). */
382
+ onClose: () => void;
383
+ /** Header title. Omit for a chromeless dialog (the ✕ still shows unless `showClose` is false). */
384
+ title?: string;
385
+ /** Dialog body. Rendered inside a scroll view so long content scrolls within the dialog. */
386
+ children?: React.ReactNode;
387
+ /** Optional footer, typically an action-button row (see {@link ConfirmDialog}). */
388
+ footer?: React.ReactNode;
389
+ /** Max-width preset. Default `md`. */
390
+ size?: ModalSize;
391
+ /**
392
+ * Show the top-right ✕ close button. Default `true`. `ConfirmDialog` sets it `false` — it offers
393
+ * an explicit Cancel, and hiding the ✕ lets the web focus trap land on the SAFE Cancel action.
394
+ */
395
+ showClose?: boolean;
396
+ /** Base testID. Default `modal`. The ✕ is `${testID}-close`, the backdrop `${testID}-backdrop`. */
397
+ testID?: string;
398
+ /** Accessible name of the dialog. Falls back to `title`, then the neutral "dialog" key. */
399
+ accessibilityLabel?: string;
400
+ }
401
+ declare const Modal: ({ visible, onClose, title, children, footer, size, showClose, testID, accessibilityLabel, }: ModalProps) => React.ReactElement;
402
+
403
+ /**
404
+ * ConfirmDialog — a confirm/cancel popup built ON {@link Modal}, for the "are you sure?" moment.
405
+ *
406
+ * Replaces per-app inline confirms (e.g. kefi-web's inline attendee-delete row) with one shared,
407
+ * themed dialog reused across every portal. Renders the `message` in the body and a Cancel + Confirm
408
+ * button row (from `@dloizides/ui-buttons`) in the footer. When `destructive` is set the Confirm
409
+ * button uses the `danger` variant — the red, irreversible-action treatment.
410
+ *
411
+ * SAFE BY DEFAULT: Cancel is FIRST in the DOM, so the web focus trap lands on it — a keyboard user
412
+ * never has a destructive Confirm pre-focused. Cancel, the backdrop, and Escape all call `onCancel`;
413
+ * the ✕ is hidden (the explicit Cancel is the dismiss affordance). While `busy`, Confirm shows its
414
+ * spinner and Cancel is disabled, so a slow delete cannot be fired twice or cancelled mid-flight.
415
+ */
416
+
417
+ interface ConfirmDialogProps {
418
+ /** Whether the dialog is shown. */
419
+ visible: boolean;
420
+ /** Header title, e.g. "Remove attendee?". */
421
+ title: string;
422
+ /** Body copy, e.g. "This can't be undone." */
423
+ message: string;
424
+ /** Confirm button label. Defaults to the host's `common.confirm` translation. */
425
+ confirmLabel?: string;
426
+ /** Cancel button label. Defaults to the host's `common.cancel` translation. */
427
+ cancelLabel?: string;
428
+ /** Red `danger` Confirm for an irreversible action. Default `false` (blue `primary`). */
429
+ destructive?: boolean;
430
+ /** Called when the user presses Confirm. */
431
+ onConfirm: () => void;
432
+ /** Called by Cancel, the backdrop, and Escape. */
433
+ onCancel: () => void;
434
+ /** In-flight: Confirm shows a spinner and Cancel is disabled. Default `false`. */
435
+ busy?: boolean;
436
+ /** Base testID. Default `confirm-dialog`. Confirm is `${testID}-confirm`, Cancel `${testID}-cancel`. */
437
+ testID?: string;
438
+ }
439
+ declare const ConfirmDialog: ({ visible, title, message, confirmLabel, cancelLabel, destructive, onConfirm, onCancel, busy, testID, }: ConfirmDialogProps) => React.ReactElement;
440
+
299
441
  /**
300
442
  * AccordionVariant — the two visual treatments for an {@link Accordion}.
301
443
  *
@@ -575,6 +717,10 @@ declare const LAYOUT_TEST_IDS: {
575
717
  readonly upgradePromptDismiss: "upgrade-prompt-dismiss";
576
718
  readonly modalShell: "template-modal";
577
719
  readonly modalShellClose: "cancel-button";
720
+ /** Default base testID for the centered `Modal`; ✕ is `modal-close`, backdrop `modal-backdrop`. */
721
+ readonly modal: "modal";
722
+ /** Default base testID for `ConfirmDialog`; Confirm/Cancel are `confirm-dialog-{confirm,cancel}`. */
723
+ readonly confirmDialog: "confirm-dialog";
578
724
  readonly accordion: "accordion";
579
725
  };
580
726
  /** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
@@ -618,6 +764,14 @@ declare const LAYOUT_I18N: {
618
764
  readonly close: "quizTemplates.cancel";
619
765
  /** `ModalShell`: heading fallback when no title is supplied. */
620
766
  readonly closeHeading: "close";
767
+ /** `Modal`: accessible name + web tooltip of the top-right ✕ close button. */
768
+ readonly dialogClose: "common.close";
769
+ /** `ConfirmDialog`: default Confirm button label (overridable via `confirmLabel`) + its hint. */
770
+ readonly confirm: "common.confirm";
771
+ readonly confirmHint: "common.confirmHint";
772
+ /** `ConfirmDialog`: default Cancel button label (overridable via `cancelLabel`) + its hint. */
773
+ readonly cancel: "common.cancel";
774
+ readonly cancelHint: "common.cancelHint";
621
775
  readonly upgradePromptTitle: "settings.billing.upgradePrompt.title";
622
776
  /** Body copy, parameterised: "…requires {{p1}}, you are on {{p2}}." */
623
777
  readonly upgradePromptMessage: "settings.billing.upgradePrompt.message";
@@ -639,4 +793,4 @@ declare const LAYOUT_I18N: {
639
793
  readonly copyableIdHint: "common.copyableIdHint";
640
794
  };
641
795
 
642
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, COPY_FEEDBACK_MS, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, type TabDescriptor, Tabs, type TabsProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
796
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };