@dloizides/ui-layout 1.1.0 → 1.2.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,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0
4
+
5
+ - `ModalDropdown` can now render as an **inline anchored menu** (native `<select>` feel), not only a
6
+ modal. New `variant?: DropdownVariant` prop (`Menu` | `Modal`) selects the presentation per screen.
7
+ - **Responsive default** (when `variant` is omitted): inline `Menu` on wide/desktop web
8
+ (viewport ≥ 768px), `Modal` on narrow/mobile and on any native platform. An explicit `variant`
9
+ overrides the auto choice.
10
+ - The inline menu anchors under the trigger, is dismissible via click-outside / `Esc`, is
11
+ keyboard-navigable (↑/↓, `Home`/`End`, `Enter`), scrolls when long, and does not push layout.
12
+ The modal path is unchanged. Both variants share the same option-rendering/selection logic
13
+ (`OptionRow`), so nothing is duplicated.
14
+ - **Additive / backward-compatible**: existing `ModalDropdown` callers (erevna / katalogos / aml-v2)
15
+ keep their exact API and now get the inline-on-desktop menu automatically. New export:
16
+ `DropdownVariant` (a runtime enum — deliberately not `const enum`, which cannot cross a published
17
+ package boundary under `isolatedModules`).
18
+
3
19
  ## 1.1.0
4
20
 
5
21
  - Add `ModalShell` — slide-up full-screen modal with a themed header (title + close) and scrollable body.
package/README.md CHANGED
@@ -11,9 +11,38 @@ 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
- | `ModalDropdown` | Generic modal-based dropdown selector (with web focus-trap). |
14
+ | `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`. |
15
+ | `DropdownVariant` | Enum (`Menu` / `Modal`) to force a `ModalDropdown` rendering variant. |
15
16
  | `useFocusTrap` | Web keyboard focus-trap hook (no-op on native). |
16
17
 
18
+ ### `ModalDropdown` variants
19
+
20
+ `ModalDropdown` picks its presentation automatically:
21
+
22
+ - **Wide / desktop web** (viewport ≥ 768px) → an **inline anchored menu** that opens directly
23
+ under the trigger (native `<select>` feel): dismissible via click-outside / `Esc`,
24
+ keyboard-navigable (↑/↓, `Home`/`End`, `Enter`), scrolls when long, and never pushes layout.
25
+ - **Narrow / mobile, or any native platform** → the original **modal** / bottom-sheet.
26
+
27
+ Pass `variant` to force either behaviour regardless of viewport — the prop overrides the auto choice:
28
+
29
+ ```tsx
30
+ import { ModalDropdown, DropdownVariant } from '@dloizides/ui-layout';
31
+
32
+ // Responsive (default): inline menu on desktop, modal on mobile.
33
+ <ModalDropdown testID="risk" accessibilityLabel="Risk" accessibilityHint="Pick a risk level"
34
+ value={risk} options={riskOptions} onChange={setRisk} />
35
+
36
+ // Force the inline menu everywhere:
37
+ <ModalDropdown /* …props… */ variant={DropdownVariant.Menu} />
38
+
39
+ // Force the modal everywhere:
40
+ <ModalDropdown /* …props… */ variant={DropdownVariant.Modal} />
41
+ ```
42
+
43
+ The public API is additive — callers that never pass `variant` keep working and now
44
+ get the inline-on-desktop menu for free.
45
+
17
46
  ## Install
18
47
 
19
48
  ```bash
package/dist/index.d.mts CHANGED
@@ -54,14 +54,39 @@ interface UpgradePromptProps {
54
54
  declare const UpgradePrompt: ({ requiredTier, currentTier, onDismiss, billingRoute, }: UpgradePromptProps) => React.ReactElement;
55
55
 
56
56
  /**
57
- * ModalDropdown — generic modal-based dropdown selector (any value type via generics).
58
- * Shows the selected label inline; opens a modal FlatList on press, with web focus-trap.
57
+ * How a {@link ModalDropdown} renders its list of options.
58
+ *
59
+ * Exported as a regular (non-`const`) enum on purpose: `const enum` values are
60
+ * inlined at compile time and cannot cross a published-package boundary when the
61
+ * consumer bundles with `isolatedModules` (esbuild / vite / babel — i.e. every
62
+ * app that consumes this package). A regular enum emits a runtime object that is
63
+ * safe to import and compare in any consumer.
59
64
  */
65
+ declare enum DropdownVariant {
66
+ /** Inline popover anchored directly under the trigger — the native `<select>` feel. */
67
+ Menu = "menu",
68
+ /** Full modal / bottom-sheet overlay with a scrim (the original behaviour). */
69
+ Modal = "modal"
70
+ }
60
71
 
72
+ /** Shared option shape for the ModalDropdown family (kept separate to avoid import cycles). */
61
73
  interface DropdownOption<T> {
62
74
  readonly label: string;
63
75
  readonly value: T;
64
76
  }
77
+
78
+ /**
79
+ * ModalDropdown — generic dropdown selector (any value type via generics).
80
+ *
81
+ * Renders as either an inline anchored menu (web-native `<select>` feel) or a
82
+ * modal / bottom-sheet, selectable per screen via the `variant` prop. When
83
+ * `variant` is omitted the choice is **responsive**: inline menu on wide/desktop
84
+ * web, modal on narrow/mobile (and always modal on native). Existing callers that
85
+ * never passed `variant` therefore get the inline-on-desktop behaviour for free.
86
+ *
87
+ * Both variants share {@link OptionRow} for option rendering + selection.
88
+ */
89
+
65
90
  interface ModalDropdownProps<T> {
66
91
  testID: string;
67
92
  accessibilityLabel: string;
@@ -69,8 +94,14 @@ interface ModalDropdownProps<T> {
69
94
  value: T;
70
95
  options: ReadonlyArray<DropdownOption<T>>;
71
96
  onChange: (value: T) => void;
97
+ /**
98
+ * Force a rendering variant. When omitted the dropdown is **responsive**:
99
+ * an inline anchored menu on wide/desktop web, a modal on narrow/mobile
100
+ * (and always a modal on native). An explicit value overrides the auto choice.
101
+ */
102
+ variant?: DropdownVariant;
72
103
  }
73
- declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, }: ModalDropdownProps<T>) => React.ReactElement;
104
+ declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, }: ModalDropdownProps<T>) => React.ReactElement;
74
105
 
75
106
  /**
76
107
  * ModalShell — a slide-up full-screen modal with a themed header (title + close button)
@@ -102,4 +133,4 @@ declare const LAYOUT_TEST_IDS: {
102
133
  /** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
103
134
  declare const DEFAULT_BILLING_ROUTE = "/settings/billing";
104
135
 
105
- export { DEFAULT_BILLING_ROUTE, type DropdownOption, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
136
+ export { DEFAULT_BILLING_ROUTE, type DropdownOption, DropdownVariant, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
package/dist/index.d.ts CHANGED
@@ -54,14 +54,39 @@ interface UpgradePromptProps {
54
54
  declare const UpgradePrompt: ({ requiredTier, currentTier, onDismiss, billingRoute, }: UpgradePromptProps) => React.ReactElement;
55
55
 
56
56
  /**
57
- * ModalDropdown — generic modal-based dropdown selector (any value type via generics).
58
- * Shows the selected label inline; opens a modal FlatList on press, with web focus-trap.
57
+ * How a {@link ModalDropdown} renders its list of options.
58
+ *
59
+ * Exported as a regular (non-`const`) enum on purpose: `const enum` values are
60
+ * inlined at compile time and cannot cross a published-package boundary when the
61
+ * consumer bundles with `isolatedModules` (esbuild / vite / babel — i.e. every
62
+ * app that consumes this package). A regular enum emits a runtime object that is
63
+ * safe to import and compare in any consumer.
59
64
  */
65
+ declare enum DropdownVariant {
66
+ /** Inline popover anchored directly under the trigger — the native `<select>` feel. */
67
+ Menu = "menu",
68
+ /** Full modal / bottom-sheet overlay with a scrim (the original behaviour). */
69
+ Modal = "modal"
70
+ }
60
71
 
72
+ /** Shared option shape for the ModalDropdown family (kept separate to avoid import cycles). */
61
73
  interface DropdownOption<T> {
62
74
  readonly label: string;
63
75
  readonly value: T;
64
76
  }
77
+
78
+ /**
79
+ * ModalDropdown — generic dropdown selector (any value type via generics).
80
+ *
81
+ * Renders as either an inline anchored menu (web-native `<select>` feel) or a
82
+ * modal / bottom-sheet, selectable per screen via the `variant` prop. When
83
+ * `variant` is omitted the choice is **responsive**: inline menu on wide/desktop
84
+ * web, modal on narrow/mobile (and always modal on native). Existing callers that
85
+ * never passed `variant` therefore get the inline-on-desktop behaviour for free.
86
+ *
87
+ * Both variants share {@link OptionRow} for option rendering + selection.
88
+ */
89
+
65
90
  interface ModalDropdownProps<T> {
66
91
  testID: string;
67
92
  accessibilityLabel: string;
@@ -69,8 +94,14 @@ interface ModalDropdownProps<T> {
69
94
  value: T;
70
95
  options: ReadonlyArray<DropdownOption<T>>;
71
96
  onChange: (value: T) => void;
97
+ /**
98
+ * Force a rendering variant. When omitted the dropdown is **responsive**:
99
+ * an inline anchored menu on wide/desktop web, a modal on narrow/mobile
100
+ * (and always a modal on native). An explicit value overrides the auto choice.
101
+ */
102
+ variant?: DropdownVariant;
72
103
  }
73
- declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, }: ModalDropdownProps<T>) => React.ReactElement;
104
+ declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, }: ModalDropdownProps<T>) => React.ReactElement;
74
105
 
75
106
  /**
76
107
  * ModalShell — a slide-up full-screen modal with a themed header (title + close button)
@@ -102,4 +133,4 @@ declare const LAYOUT_TEST_IDS: {
102
133
  /** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
103
134
  declare const DEFAULT_BILLING_ROUTE = "/settings/billing";
104
135
 
105
- export { DEFAULT_BILLING_ROUTE, type DropdownOption, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
136
+ export { DEFAULT_BILLING_ROUTE, type DropdownOption, DropdownVariant, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
package/dist/index.js CHANGED
@@ -216,24 +216,226 @@ function useFocusTrap(containerRef, enabled) {
216
216
  };
217
217
  }, [containerRef, enabled]);
218
218
  }
219
- var BORDER_RADIUS = 8;
220
- var BORDER_WIDTH = 1;
219
+
220
+ // src/ModalDropdown/DropdownVariant.ts
221
+ var DropdownVariant = /* @__PURE__ */ ((DropdownVariant2) => {
222
+ DropdownVariant2["Menu"] = "menu";
223
+ DropdownVariant2["Modal"] = "modal";
224
+ return DropdownVariant2;
225
+ })(DropdownVariant || {});
221
226
  var OPTION_BORDER_RADIUS = 4;
222
227
  var BODY_FONT_SIZE = 14;
223
228
  var SELECTED_FONT_WEIGHT = "600";
229
+ var OPTION_PADDING_H = 16;
230
+ var OPTION_PADDING_V = 12;
231
+ var styles5 = reactNative.StyleSheet.create({
232
+ option: {
233
+ paddingHorizontal: OPTION_PADDING_H,
234
+ paddingVertical: OPTION_PADDING_V,
235
+ borderRadius: OPTION_BORDER_RADIUS
236
+ },
237
+ optionText: { fontSize: BODY_FONT_SIZE },
238
+ selectedText: { fontWeight: SELECTED_FONT_WEIGHT }
239
+ });
240
+ var OptionRow = ({
241
+ testID,
242
+ label,
243
+ isSelected,
244
+ isHighlighted = false,
245
+ onSelect
246
+ }) => {
247
+ const { theme, t } = uiFeedback.useUi();
248
+ const { colors } = theme;
249
+ const handlePress = React.useCallback(() => {
250
+ onSelect();
251
+ }, [onSelect]);
252
+ const isActive = isSelected || isHighlighted;
253
+ const rowStyle = [styles5.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
254
+ const textStyle = [styles5.optionText, { color: colors.text }, isSelected ? styles5.selectedText : null];
255
+ return /* @__PURE__ */ jsxRuntime.jsx(
256
+ reactNative.TouchableOpacity,
257
+ {
258
+ accessible: true,
259
+ accessibilityHint: t("common.selectOptionHint"),
260
+ accessibilityLabel: label,
261
+ accessibilityRole: "button",
262
+ "aria-selected": isSelected,
263
+ style: rowStyle,
264
+ testID,
265
+ onPress: handlePress,
266
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: textStyle, children: label })
267
+ }
268
+ );
269
+ };
270
+ var clampIndex = (index, itemCount) => {
271
+ if (index < 0) return 0;
272
+ const lastIndex = itemCount - 1;
273
+ return index > lastIndex ? lastIndex : index;
274
+ };
275
+ function buildKeyHandler(params) {
276
+ const { itemCount, onHighlightChange, onSelectHighlighted, onClose } = params;
277
+ return (event) => {
278
+ switch (event.key) {
279
+ case "ArrowDown":
280
+ event.preventDefault();
281
+ onHighlightChange((prev) => clampIndex(prev + 1, itemCount));
282
+ return;
283
+ case "ArrowUp":
284
+ event.preventDefault();
285
+ onHighlightChange((prev) => clampIndex(prev - 1, itemCount));
286
+ return;
287
+ case "Home":
288
+ event.preventDefault();
289
+ onHighlightChange(() => 0);
290
+ return;
291
+ case "End":
292
+ event.preventDefault();
293
+ onHighlightChange(() => clampIndex(itemCount - 1, itemCount));
294
+ return;
295
+ case "Enter":
296
+ event.preventDefault();
297
+ onSelectHighlighted();
298
+ return;
299
+ case "Escape":
300
+ event.preventDefault();
301
+ onClose();
302
+ return;
303
+ }
304
+ };
305
+ }
306
+ function useMenuKeyboard(params) {
307
+ const { containerRef, enabled, onClose } = params;
308
+ React.useEffect(() => {
309
+ if (reactNative.Platform.OS !== "web" || !enabled) return;
310
+ const onKeyDown = buildKeyHandler(params);
311
+ const onMouseDown = (event) => {
312
+ const node = containerRef.current;
313
+ const target = event.target instanceof Node ? event.target : null;
314
+ const clickedOutside = node !== null && (target === null || !node.contains(target));
315
+ if (clickedOutside) onClose();
316
+ };
317
+ document.addEventListener("keydown", onKeyDown);
318
+ document.addEventListener("mousedown", onMouseDown);
319
+ return () => {
320
+ document.removeEventListener("keydown", onKeyDown);
321
+ document.removeEventListener("mousedown", onMouseDown);
322
+ };
323
+ }, [containerRef, enabled, onClose, params]);
324
+ }
325
+ var BORDER_RADIUS = 8;
326
+ var BORDER_WIDTH = 1;
327
+ var MENU_PADDING = 4;
328
+ var MENU_MAX_HEIGHT = 300;
329
+ var MENU_TOP_GAP = 4;
330
+ var MENU_Z_INDEX = 1e3;
331
+ var MENU_ELEVATION = 8;
332
+ var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
333
+ var styles6 = reactNative.StyleSheet.create({
334
+ popover: {
335
+ position: "absolute",
336
+ top: "100%",
337
+ left: 0,
338
+ right: 0,
339
+ marginTop: MENU_TOP_GAP,
340
+ zIndex: MENU_Z_INDEX,
341
+ borderWidth: BORDER_WIDTH,
342
+ borderRadius: BORDER_RADIUS,
343
+ padding: MENU_PADDING,
344
+ maxHeight: MENU_MAX_HEIGHT,
345
+ boxShadow: MENU_BOX_SHADOW,
346
+ elevation: MENU_ELEVATION
347
+ }
348
+ });
349
+ var InlineMenu = ({
350
+ testID,
351
+ accessibilityLabel,
352
+ value,
353
+ options,
354
+ containerRef,
355
+ onSelect,
356
+ onClose
357
+ }) => {
358
+ const { theme } = uiFeedback.useUi();
359
+ const { colors } = theme;
360
+ const selectedIndex = React.useMemo(
361
+ () => Math.max(0, options.findIndex((opt) => opt.value === value)),
362
+ [options, value]
363
+ );
364
+ const [highlightedIndex, setHighlightedIndex] = React.useState(() => selectedIndex);
365
+ const selectAt = React.useCallback(
366
+ (index) => {
367
+ const option = options[index];
368
+ if (option !== void 0) onSelect(option.value);
369
+ },
370
+ [options, onSelect]
371
+ );
372
+ const selectHighlighted = React.useCallback(
373
+ () => {
374
+ selectAt(highlightedIndex);
375
+ },
376
+ [selectAt, highlightedIndex]
377
+ );
378
+ useMenuKeyboard({
379
+ containerRef,
380
+ enabled: true,
381
+ itemCount: options.length,
382
+ onHighlightChange: setHighlightedIndex,
383
+ onSelectHighlighted: selectHighlighted,
384
+ onClose
385
+ });
386
+ const popoverStyle = React.useMemo(
387
+ () => [styles6.popover, { borderColor: colors.border, backgroundColor: colors.surface }],
388
+ [colors.border, colors.surface]
389
+ );
390
+ return /* @__PURE__ */ jsxRuntime.jsx(
391
+ reactNative.View,
392
+ {
393
+ accessibilityRole: "menu",
394
+ "aria-label": accessibilityLabel,
395
+ style: popoverStyle,
396
+ testID: `${testID}-menu`,
397
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
398
+ OptionRow,
399
+ {
400
+ isHighlighted: index === highlightedIndex,
401
+ isSelected: option.value === value,
402
+ label: option.label,
403
+ testID: `${testID}-option-${String(option.value)}`,
404
+ onSelect: () => onSelect(option.value)
405
+ },
406
+ String(option.value)
407
+ )) })
408
+ }
409
+ );
410
+ };
411
+ var MENU_BREAKPOINT = 768;
412
+ var WEB_PLATFORM = "web";
413
+ function resolveDropdownVariant(explicit, width, platformOS) {
414
+ if (explicit !== void 0) return explicit;
415
+ const isWideWeb = platformOS === WEB_PLATFORM && width >= MENU_BREAKPOINT;
416
+ return isWideWeb ? "menu" /* Menu */ : "modal" /* Modal */;
417
+ }
418
+ function useResolvedDropdownVariant(explicit) {
419
+ const { width } = reactNative.useWindowDimensions();
420
+ return resolveDropdownVariant(explicit, width, reactNative.Platform.OS);
421
+ }
422
+ var BORDER_RADIUS2 = 8;
423
+ var BORDER_WIDTH2 = 1;
424
+ var BODY_FONT_SIZE2 = 14;
224
425
  var MODAL_PADDING = 8;
225
426
  var MODAL_MIN_WIDTH = 200;
226
427
  var MODAL_MAX_HEIGHT = 300;
227
428
  var CONTAINER_PADDING_H = 12;
228
429
  var CONTAINER_PADDING_V = 10;
229
- var styles5 = reactNative.StyleSheet.create({
430
+ var styles7 = reactNative.StyleSheet.create({
431
+ anchor: { position: "relative" },
230
432
  container: {
231
- borderWidth: BORDER_WIDTH,
232
- borderRadius: BORDER_RADIUS,
433
+ borderWidth: BORDER_WIDTH2,
434
+ borderRadius: BORDER_RADIUS2,
233
435
  paddingHorizontal: CONTAINER_PADDING_H,
234
436
  paddingVertical: CONTAINER_PADDING_V
235
437
  },
236
- selectedText: { fontSize: BODY_FONT_SIZE },
438
+ selectedText: { fontSize: BODY_FONT_SIZE2 },
237
439
  modalOverlay: {
238
440
  flex: 1,
239
441
  justifyContent: "center",
@@ -241,18 +443,11 @@ var styles5 = reactNative.StyleSheet.create({
241
443
  backgroundColor: uiFeedback.MODAL_OVERLAY_COLOR
242
444
  },
243
445
  modalContent: {
244
- borderRadius: BORDER_RADIUS,
446
+ borderRadius: BORDER_RADIUS2,
245
447
  padding: MODAL_PADDING,
246
448
  minWidth: MODAL_MIN_WIDTH,
247
449
  maxHeight: MODAL_MAX_HEIGHT
248
- },
249
- option: {
250
- paddingHorizontal: 16,
251
- paddingVertical: 12,
252
- borderRadius: OPTION_BORDER_RADIUS
253
- },
254
- optionText: { fontSize: BODY_FONT_SIZE },
255
- selectedOption: { fontWeight: SELECTED_FONT_WEIGHT }
450
+ }
256
451
  });
257
452
  var ModalDropdown = ({
258
453
  testID,
@@ -260,19 +455,23 @@ var ModalDropdown = ({
260
455
  accessibilityHint,
261
456
  value,
262
457
  options,
263
- onChange
458
+ onChange,
459
+ variant
264
460
  }) => {
265
461
  const { theme, t } = uiFeedback.useUi();
266
462
  const { colors } = theme;
463
+ const resolvedVariant = useResolvedDropdownVariant(variant);
464
+ const isMenu = resolvedVariant === "menu" /* Menu */;
267
465
  const [isOpen, setIsOpen] = React.useState(false);
466
+ const anchorRef = React.useRef(null);
268
467
  const dialogRef = React.useRef(null);
269
- useFocusTrap(dialogRef, isOpen);
468
+ useFocusTrap(dialogRef, isOpen && !isMenu);
270
469
  const selectedLabel = React.useMemo(() => {
271
470
  const found = options.find((opt) => opt.value === value);
272
471
  return found?.label ?? t("common.selectPlaceholder");
273
472
  }, [options, value, t]);
274
- const handleOpen = React.useCallback(() => {
275
- setIsOpen(true);
473
+ const handleToggle = React.useCallback(() => {
474
+ setIsOpen((prev) => !prev);
276
475
  }, []);
277
476
  const handleClose = React.useCallback(() => {
278
477
  setIsOpen(false);
@@ -285,44 +484,27 @@ var ModalDropdown = ({
285
484
  [onChange]
286
485
  );
287
486
  const containerStyle = React.useMemo(
288
- () => [styles5.container, { borderColor: colors.border, backgroundColor: colors.surface }],
487
+ () => [styles7.container, { borderColor: colors.border, backgroundColor: colors.surface }],
289
488
  [colors.border, colors.surface]
290
489
  );
291
490
  const modalContentStyle = React.useMemo(
292
- () => [styles5.modalContent, { backgroundColor: colors.surface }],
491
+ () => [styles7.modalContent, { backgroundColor: colors.surface }],
293
492
  [colors.surface]
294
493
  );
295
- const renderOption = React.useCallback(
296
- ({ item }) => {
297
- const isSelected = item.value === value;
298
- return /* @__PURE__ */ jsxRuntime.jsx(
299
- reactNative.TouchableOpacity,
300
- {
301
- accessible: true,
302
- accessibilityHint: t("common.selectOptionHint"),
303
- accessibilityLabel: item.label,
304
- accessibilityRole: "button",
305
- style: [styles5.option, isSelected ? { backgroundColor: colors.surfaceElevated } : null],
306
- testID: `${testID}-option-${String(item.value)}`,
307
- onPress: () => handleSelect(item.value),
308
- children: /* @__PURE__ */ jsxRuntime.jsx(
309
- reactNative.Text,
310
- {
311
- style: [
312
- styles5.optionText,
313
- { color: colors.text },
314
- isSelected ? styles5.selectedOption : null
315
- ],
316
- children: item.label
317
- }
318
- )
319
- }
320
- );
321
- },
322
- [colors.surfaceElevated, colors.text, handleSelect, testID, value, t]
494
+ const renderModalOption = React.useCallback(
495
+ ({ item }) => /* @__PURE__ */ jsxRuntime.jsx(
496
+ OptionRow,
497
+ {
498
+ isSelected: item.value === value,
499
+ label: item.label,
500
+ testID: `${testID}-option-${String(item.value)}`,
501
+ onSelect: () => handleSelect(item.value)
502
+ }
503
+ ),
504
+ [handleSelect, testID, value]
323
505
  );
324
506
  const keyExtractor = React.useCallback((item) => String(item.value), []);
325
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
507
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles7.anchor, children: [
326
508
  /* @__PURE__ */ jsxRuntime.jsx(
327
509
  reactNative.TouchableOpacity,
328
510
  {
@@ -330,13 +512,26 @@ var ModalDropdown = ({
330
512
  accessibilityHint,
331
513
  accessibilityLabel,
332
514
  accessibilityRole: "button",
515
+ "aria-expanded": isOpen,
333
516
  style: containerStyle,
334
517
  testID,
335
- onPress: handleOpen,
336
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.selectedText, { color: colors.text }], children: selectedLabel })
518
+ onPress: handleToggle,
519
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles7.selectedText, { color: colors.text }], children: selectedLabel })
337
520
  }
338
521
  ),
339
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, animationType: "fade", visible: isOpen, onRequestClose: handleClose, children: /* @__PURE__ */ jsxRuntime.jsx(
522
+ isMenu && isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
523
+ InlineMenu,
524
+ {
525
+ accessibilityLabel,
526
+ containerRef: anchorRef,
527
+ options,
528
+ testID,
529
+ value,
530
+ onClose: handleClose,
531
+ onSelect: handleSelect
532
+ }
533
+ ) : null,
534
+ !isMenu ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, animationType: "fade", visible: isOpen, onRequestClose: handleClose, children: /* @__PURE__ */ jsxRuntime.jsx(
340
535
  reactNative.TouchableOpacity,
341
536
  {
342
537
  accessible: true,
@@ -344,7 +539,7 @@ var ModalDropdown = ({
344
539
  accessibilityLabel: t("common.dismissDropdown"),
345
540
  accessibilityRole: "button",
346
541
  activeOpacity: 1,
347
- style: styles5.modalOverlay,
542
+ style: styles7.modalOverlay,
348
543
  testID: `${testID}-backdrop`,
349
544
  onPress: handleClose,
350
545
  children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -355,22 +550,15 @@ var ModalDropdown = ({
355
550
  "aria-label": accessibilityLabel,
356
551
  role: "dialog",
357
552
  style: modalContentStyle,
358
- children: /* @__PURE__ */ jsxRuntime.jsx(
359
- reactNative.FlatList,
360
- {
361
- data: [...options],
362
- keyExtractor,
363
- renderItem: renderOption
364
- }
365
- )
553
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.FlatList, { data: [...options], keyExtractor, renderItem: renderModalOption })
366
554
  }
367
555
  )
368
556
  }
369
- ) })
557
+ ) }) : null
370
558
  ] });
371
559
  };
372
560
  var CLOSE_ICON_SIZE = 18;
373
- var styles6 = reactNative.StyleSheet.create({
561
+ var styles8 = reactNative.StyleSheet.create({
374
562
  container: {
375
563
  flex: 1,
376
564
  padding: 16
@@ -395,7 +583,7 @@ var ModalShell = ({
395
583
  }) => {
396
584
  const { theme, t } = uiFeedback.useUi();
397
585
  const containerStyle = React__default.default.useMemo(
398
- () => [styles6.container, { backgroundColor: theme.colors.background }, contentStyle],
586
+ () => [styles8.container, { backgroundColor: theme.colors.background }, contentStyle],
399
587
  [theme.colors.background, contentStyle]
400
588
  );
401
589
  const closeA11yLabel = t("quizTemplates.cancel");
@@ -415,7 +603,7 @@ var ModalShell = ({
415
603
  role: "dialog",
416
604
  style: containerStyle,
417
605
  children: [
418
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles6.headerRow, children: [
606
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles8.headerRow, children: [
419
607
  /* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title ?? t("close") }),
420
608
  showClose ? /* @__PURE__ */ jsxRuntime.jsx(
421
609
  reactNative.TouchableOpacity,
@@ -423,7 +611,7 @@ var ModalShell = ({
423
611
  accessibilityHint: t("common.closeDialogHint"),
424
612
  accessibilityLabel: closeA11yLabel,
425
613
  accessibilityRole: "button",
426
- style: styles6.closeButton,
614
+ style: styles8.closeButton,
427
615
  testID: LAYOUT_TEST_IDS.modalShellClose,
428
616
  onPress: onCancel,
429
617
  children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: theme.colors.textSecondary, name: "close", size: CLOSE_ICON_SIZE })
@@ -439,6 +627,7 @@ var ModalShell = ({
439
627
  };
440
628
 
441
629
  exports.DEFAULT_BILLING_ROUTE = DEFAULT_BILLING_ROUTE;
630
+ exports.DropdownVariant = DropdownVariant;
442
631
  exports.Heading = Heading;
443
632
  exports.LAYOUT_TEST_IDS = LAYOUT_TEST_IDS;
444
633
  exports.ModalDropdown = ModalDropdown;