@dloizides/ui-layout 1.9.1 → 1.11.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,68 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.11.0
4
+
5
+ - **Fix (HIGH — 1.10.0's out-of-view close never fired in the real runtime).** 1.10.0 added
6
+ "close the menu once the trigger leaves the viewport". Repositioning worked, but the close was
7
+ measured **against the viewport**, and **RN-web apps never scroll the document** — every screen
8
+ renders inside a `ScrollView`, so scrolling happens in an inner `<div>` and `window.scrollY`
9
+ stays 0 forever. A trigger scrolled out of that inner scroller is invisible to the user while its
10
+ rect sits comfortably inside the viewport, so the check could not fire on any screen of any
11
+ portal. Measured in Chrome: trigger at `top: -37` (fully above the scroller), menu still rendered.
12
+ Visibility is now measured against the **clip window** — the viewport intersected with every
13
+ clipping ancestor — which is what makes it work inside an inner scroll container.
14
+ - **Fix: "entirely out of view" was also the wrong threshold.** When a scroll container reaches the
15
+ end of its range the trigger stops with a few pixels still showing (4px in the reported case), so
16
+ "fully out" was *unreachable* and the menu never closed however far the user scrolled. There is
17
+ now a minimum-visible-pixel floor (`MIN_VISIBLE_PX`).
18
+ - **Guard: the menu never closes on its FIRST measurement**, so opening a dropdown whose trigger is
19
+ already partly clipped still works; only movement after opening can close it.
20
+ - **The zero-area "not laid out yet" guard is unchanged in intent but now provably size-only** — it
21
+ asks about the element's own box, never its position, so it cannot swallow a genuine hidden case.
22
+ - **New: `LAYOUT_I18N`** — the manifest of every translation key this package resolves, mirroring
23
+ `TABLE_I18N` / `FILTERS_I18N` from `@dloizides/ui-tables` so hosts can bind an existing
24
+ missing-key guard to it with no new pattern. The kit is fallback-free, so a key a host forgets
25
+ reaches users as a raw dotted name; hand-maintained key lists rot (one portal was found missing
26
+ 26 kit keys, another had `common.accordionToggleHint` undefined while `Accordion` was mounted).
27
+ Every `t(...)` call in the package now references the map, and the suite fails on a raw key
28
+ literal or a stale entry — so the manifest cannot drift from the code.
29
+ - **Fix: the 1.10.0 CHANGELOG entry was written in cp1252**, leaving the published file invalid
30
+ UTF-8. Re-encoded.
31
+ - **No breaking change.** `LAYOUT_I18N` is additive and the key strings are unchanged, so existing
32
+ translation files keep working untouched.
33
+
34
+ ## 1.10.0
35
+
36
+ Two defects found by browser visual QA of the inline dropdown menu against a live app.
37
+
38
+ - **Fix (HIGH, affects every consumer): the open inline menu detached from its trigger.** On web the
39
+ menu is portalled to `document.body` with `position: fixed` at the trigger's measured rect.
40
+ `fixed` is viewport-relative, so that coordinate is only valid until something moves the trigger.
41
+ A `scroll`/`resize` listener on `window` was already in place (since 1.7.0) and does handle plain
42
+ scrolling — but it left three real gaps:
43
+ - **Layout changes that fire no scroll event at all** — an accordion above the trigger expanding,
44
+ a sticky header resizing, a banner appearing, an async list rendering. The trigger moved, nothing
45
+ scrolled, no listener fired, and the menu stayed behind. Now covered by a `ResizeObserver` on the
46
+ anchor and on `document.body`.
47
+ - **The trigger leaving the viewport.** Repositioning cannot help here — the menu just follows its
48
+ trigger off-screen and hangs over unrelated content with nothing on screen explaining it. The
49
+ menu now **closes** once the trigger is fully out of view.
50
+ - **Layout thrash.** The handler ran a synchronous `getBoundingClientRect()` (a forced reflow) plus
51
+ a React state update on *every* scroll event. Work is now coalesced into one
52
+ `requestAnimationFrame` per frame.
53
+ Scroll is now observed in the **capture** phase on `document` rather than `window`, so a scroll in
54
+ any ancestor scroll container counts. Tracking moved into a dedicated `useAnchorTracking` hook.
55
+ Native is unaffected (the popover is in-tree and moves with its anchor).
56
+ - **Fix (a11y): `accessibilityHint` never reached a screen reader.** The prop is part of the public
57
+ API and every caller passes one, but react-native-web does not map it — the trigger carried
58
+ `aria-label` and `aria-expanded` and **no hint of any kind**, so the text was silently thrown away
59
+ (older react-native-web versions additionally leaked it to the DOM, logging
60
+ `React does not recognize the accessibilityHint prop on a DOM element`). On web the hint is now
61
+ rendered into a visually-hidden node referenced by `aria-describedby` — the same wiring
62
+ `@dloizides/ui-forms`' `Field` uses for its error line — and the RN-only prop is no longer passed
63
+ on web at all. Native still receives `accessibilityHint` unchanged.
64
+ - **No API change.** Both fixes are internal; every existing caller benefits without edits.
65
+
3
66
  ## 1.9.1
4
67
 
5
68
  - **Fix (keyboard a11y, affects every consumer): Enter CLOSED the inline menu instead of SELECTING
package/README.md CHANGED
@@ -76,6 +76,12 @@ The apps supply the header hint string via the shared translate: key `common.acc
76
76
  - **Wide / desktop web** (viewport ≥ 768px) → an **inline anchored menu** that opens directly
77
77
  under the trigger (native `<select>` feel): dismissible via click-outside / `Esc`,
78
78
  keyboard-navigable (↑/↓, `Home`/`End`, `Enter`), scrolls when long, and never pushes layout.
79
+ It is portalled to `document.body` so no ancestor stacking context or `overflow` can trap or
80
+ clip it, and it **stays glued to its trigger**: it re-anchors on scroll (in any ancestor scroll
81
+ container), on resize, and on layout changes that fire no scroll event at all, then **closes**
82
+ once the trigger is no longer meaningfully visible. Visibility is measured against the viewport
83
+ intersected with every clipping ancestor — RN-web apps scroll an inner `ScrollView`, never the
84
+ document, so a viewport-only test would never fire.
79
85
  - **Narrow / mobile, or any native platform** → the original **modal** / bottom-sheet.
80
86
 
81
87
  Pass `variant` to force either behaviour regardless of viewport — the prop overrides the auto choice:
@@ -94,6 +100,10 @@ import { ModalDropdown, DropdownVariant } from '@dloizides/ui-layout';
94
100
  <ModalDropdown /* …props… */ variant={DropdownVariant.Modal} />
95
101
  ```
96
102
 
103
+ `accessibilityHint` reaches assistive tech on both platforms: natively via `accessibilityHint`, and
104
+ on web via a visually-hidden node referenced by the trigger's `aria-describedby` (react-native-web
105
+ does not map the RN prop, so the hint would otherwise be silently dropped).
106
+
97
107
  The public API is additive — callers that never pass `variant` keep working and now
98
108
  get the inline-on-desktop menu for free.
99
109
 
@@ -111,3 +121,22 @@ translations, and navigation.
111
121
  ## License
112
122
 
113
123
  MIT
124
+
125
+ ## i18n contract (required)
126
+
127
+ The kit is **fallback-free**: the neutral default `t` returns the key itself, so a host that forgets
128
+ a key does not silently show English — it renders the raw dotted name to users, or announces it to
129
+ screen readers. `LAYOUT_I18N` is the machine-readable manifest of every key this package resolves;
130
+ bind your missing-key guard to it exactly as you already do for `TABLE_I18N` / `FILTERS_I18N` from
131
+ `@dloizides/ui-tables`, and an upgrade can never add a key your app silently fails to define.
132
+
133
+ ```ts
134
+ import { LAYOUT_I18N } from '@dloizides/ui-layout';
135
+ import { TABLE_I18N } from '@dloizides/ui-tables';
136
+
137
+ // Every value is a translation key this package will call `t(...)` with.
138
+ const REQUIRED_KIT_KEYS = [...Object.values(LAYOUT_I18N), ...Object.values(TABLE_I18N)];
139
+ ```
140
+
141
+ The manifest cannot drift: every `t(...)` call in the package references `LAYOUT_I18N`, and the test
142
+ suite fails on a raw key literal in a component or a stale entry in the map.
package/dist/index.d.mts CHANGED
@@ -281,5 +281,47 @@ declare const LAYOUT_TEST_IDS: {
281
281
  };
282
282
  /** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
283
283
  declare const DEFAULT_BILLING_ROUTE = "/settings/billing";
284
+ /**
285
+ * Every translation key this package resolves through `t(...)` — the host app's i18n contract.
286
+ *
287
+ * WHY THIS EXISTS: the kit is deliberately fallback-free. The neutral default `t` returns the key
288
+ * itself, so a host that forgets a key does not silently show English — it shows the raw dotted
289
+ * name to users, or announces it to screen readers. Without a machine-readable manifest each
290
+ * portal had to hand-maintain its ui-layout key list, and hand-maintained lists rot: one app was
291
+ * found missing 26 kit keys (rendering raw names to users), another had `accordionToggleHint`
292
+ * undefined while `Accordion` was mounted, announcing the raw key to assistive tech.
293
+ *
294
+ * Bind a missing-key guard to this map (the same way apps already bind `TABLE_I18N` /
295
+ * `FILTERS_I18N` from `@dloizides/ui-tables`) and an upgrade can never drift unnoticed. Every
296
+ * `t(...)` call in this package references this map, so it cannot fall out of date.
297
+ */
298
+ declare const LAYOUT_I18N: {
299
+ /** Placeholder shown by `ModalDropdown` when no option matches the current value. */
300
+ readonly selectPlaceholder: "common.selectPlaceholder";
301
+ /** Accessible name + hint of the modal-variant dropdown's dismiss backdrop. */
302
+ readonly dismissDropdown: "common.dismissDropdown";
303
+ readonly dismissDropdownHint: "common.dismissDropdownHint";
304
+ /** Accessible hint on a single dropdown option row. */
305
+ readonly selectOptionHint: "common.selectOptionHint";
306
+ /** Default accessible hint on an `AccordionItem` header when the caller supplies none. */
307
+ readonly accordionToggleHint: "common.accordionToggleHint";
308
+ /** Default accessible hint on a `StatusBadge` when the caller supplies none. */
309
+ readonly statusBadgeHint: "common.statusBadgeHint";
310
+ /** `ModalShell`: accessible name of the dialog when its title is not a plain string. */
311
+ readonly dialog: "common.dialog";
312
+ /** `ModalShell`: accessible hint on the close button. */
313
+ readonly closeDialogHint: "common.closeDialogHint";
314
+ /** `ModalShell`: accessible name of the close button. */
315
+ readonly close: "quizTemplates.cancel";
316
+ /** `ModalShell`: heading fallback when no title is supplied. */
317
+ readonly closeHeading: "close";
318
+ readonly upgradePromptTitle: "settings.billing.upgradePrompt.title";
319
+ /** Body copy, parameterised: "…requires {{p1}}, you are on {{p2}}." */
320
+ readonly upgradePromptMessage: "settings.billing.upgradePrompt.message";
321
+ readonly upgradePromptCta: "settings.billing.upgradePrompt.cta";
322
+ readonly upgradePromptCtaHint: "settings.billing.upgradePrompt.ctaHint";
323
+ readonly upgradePromptDismiss: "settings.billing.upgradePrompt.dismiss";
324
+ readonly upgradePromptDismissHint: "settings.billing.upgradePrompt.dismissHint";
325
+ };
284
326
 
285
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
327
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, Heading, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
package/dist/index.d.ts CHANGED
@@ -281,5 +281,47 @@ declare const LAYOUT_TEST_IDS: {
281
281
  };
282
282
  /** Route the UpgradePrompt CTA navigates to by default (the apps' billing settings path). */
283
283
  declare const DEFAULT_BILLING_ROUTE = "/settings/billing";
284
+ /**
285
+ * Every translation key this package resolves through `t(...)` — the host app's i18n contract.
286
+ *
287
+ * WHY THIS EXISTS: the kit is deliberately fallback-free. The neutral default `t` returns the key
288
+ * itself, so a host that forgets a key does not silently show English — it shows the raw dotted
289
+ * name to users, or announces it to screen readers. Without a machine-readable manifest each
290
+ * portal had to hand-maintain its ui-layout key list, and hand-maintained lists rot: one app was
291
+ * found missing 26 kit keys (rendering raw names to users), another had `accordionToggleHint`
292
+ * undefined while `Accordion` was mounted, announcing the raw key to assistive tech.
293
+ *
294
+ * Bind a missing-key guard to this map (the same way apps already bind `TABLE_I18N` /
295
+ * `FILTERS_I18N` from `@dloizides/ui-tables`) and an upgrade can never drift unnoticed. Every
296
+ * `t(...)` call in this package references this map, so it cannot fall out of date.
297
+ */
298
+ declare const LAYOUT_I18N: {
299
+ /** Placeholder shown by `ModalDropdown` when no option matches the current value. */
300
+ readonly selectPlaceholder: "common.selectPlaceholder";
301
+ /** Accessible name + hint of the modal-variant dropdown's dismiss backdrop. */
302
+ readonly dismissDropdown: "common.dismissDropdown";
303
+ readonly dismissDropdownHint: "common.dismissDropdownHint";
304
+ /** Accessible hint on a single dropdown option row. */
305
+ readonly selectOptionHint: "common.selectOptionHint";
306
+ /** Default accessible hint on an `AccordionItem` header when the caller supplies none. */
307
+ readonly accordionToggleHint: "common.accordionToggleHint";
308
+ /** Default accessible hint on a `StatusBadge` when the caller supplies none. */
309
+ readonly statusBadgeHint: "common.statusBadgeHint";
310
+ /** `ModalShell`: accessible name of the dialog when its title is not a plain string. */
311
+ readonly dialog: "common.dialog";
312
+ /** `ModalShell`: accessible hint on the close button. */
313
+ readonly closeDialogHint: "common.closeDialogHint";
314
+ /** `ModalShell`: accessible name of the close button. */
315
+ readonly close: "quizTemplates.cancel";
316
+ /** `ModalShell`: heading fallback when no title is supplied. */
317
+ readonly closeHeading: "close";
318
+ readonly upgradePromptTitle: "settings.billing.upgradePrompt.title";
319
+ /** Body copy, parameterised: "…requires {{p1}}, you are on {{p2}}." */
320
+ readonly upgradePromptMessage: "settings.billing.upgradePrompt.message";
321
+ readonly upgradePromptCta: "settings.billing.upgradePrompt.cta";
322
+ readonly upgradePromptCtaHint: "settings.billing.upgradePrompt.ctaHint";
323
+ readonly upgradePromptDismiss: "settings.billing.upgradePrompt.dismiss";
324
+ readonly upgradePromptDismissHint: "settings.billing.upgradePrompt.dismissHint";
325
+ };
284
326
 
285
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, Heading, type HeadingProps, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
327
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, Heading, type HeadingProps, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, type ModalDropdownProps, ModalShell, type ModalShellProps, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, UpgradePrompt, type UpgradePromptProps, useFocusTrap };
package/dist/index.js CHANGED
@@ -40,6 +40,34 @@ var LAYOUT_TEST_IDS = {
40
40
  accordion: "accordion"
41
41
  };
42
42
  var DEFAULT_BILLING_ROUTE = "/settings/billing";
43
+ var LAYOUT_I18N = {
44
+ /** Placeholder shown by `ModalDropdown` when no option matches the current value. */
45
+ selectPlaceholder: "common.selectPlaceholder",
46
+ /** Accessible name + hint of the modal-variant dropdown's dismiss backdrop. */
47
+ dismissDropdown: "common.dismissDropdown",
48
+ dismissDropdownHint: "common.dismissDropdownHint",
49
+ /** Accessible hint on a single dropdown option row. */
50
+ selectOptionHint: "common.selectOptionHint",
51
+ /** Default accessible hint on an `AccordionItem` header when the caller supplies none. */
52
+ accordionToggleHint: "common.accordionToggleHint",
53
+ /** Default accessible hint on a `StatusBadge` when the caller supplies none. */
54
+ statusBadgeHint: "common.statusBadgeHint",
55
+ /** `ModalShell`: accessible name of the dialog when its title is not a plain string. */
56
+ dialog: "common.dialog",
57
+ /** `ModalShell`: accessible hint on the close button. */
58
+ closeDialogHint: "common.closeDialogHint",
59
+ /** `ModalShell`: accessible name of the close button. */
60
+ close: "quizTemplates.cancel",
61
+ /** `ModalShell`: heading fallback when no title is supplied. */
62
+ closeHeading: "close",
63
+ upgradePromptTitle: "settings.billing.upgradePrompt.title",
64
+ /** Body copy, parameterised: "…requires {{p1}}, you are on {{p2}}." */
65
+ upgradePromptMessage: "settings.billing.upgradePrompt.message",
66
+ upgradePromptCta: "settings.billing.upgradePrompt.cta",
67
+ upgradePromptCtaHint: "settings.billing.upgradePrompt.ctaHint",
68
+ upgradePromptDismiss: "settings.billing.upgradePrompt.dismiss",
69
+ upgradePromptDismissHint: "settings.billing.upgradePrompt.dismissHint"
70
+ };
43
71
  var styles2 = reactNative.StyleSheet.create({
44
72
  heading: {
45
73
  fontWeight: "700",
@@ -84,7 +112,7 @@ var StatusBadge = ({
84
112
  return /* @__PURE__ */ jsxRuntime.jsx(
85
113
  reactNative.View,
86
114
  {
87
- accessibilityHint: accessibilityHint ?? t("common.statusBadgeHint"),
115
+ accessibilityHint: accessibilityHint ?? t(LAYOUT_I18N.statusBadgeHint),
88
116
  accessibilityLabel: accessibilityLabel ?? label,
89
117
  style: [styles3.badge, dynamicBadge],
90
118
  testID,
@@ -100,10 +128,7 @@ var SEGMENT_PAD_V = 7;
100
128
  var SEGMENT_FONT = 14;
101
129
  var SEGMENT_WEIGHT = "600";
102
130
  var BORDER_WIDTH = 1;
103
- var SHADOW_COLOR = "#141e32";
104
- var SHADOW_OPACITY = 0.1;
105
- var SHADOW_RADIUS = 3;
106
- var SHADOW_OFFSET = { width: 0, height: 1 };
131
+ var SEGMENT_BOX_SHADOW = "0px 1px 3px rgba(20, 30, 50, 0.1)";
107
132
  var SHADOW_ELEVATION = 2;
108
133
  var TRANSPARENT = "transparent";
109
134
  var styles4 = reactNative.StyleSheet.create({
@@ -122,10 +147,7 @@ var styles4 = reactNative.StyleSheet.create({
122
147
  borderRadius: SEGMENT_RADIUS
123
148
  },
124
149
  segmentSelected: {
125
- shadowColor: SHADOW_COLOR,
126
- shadowOpacity: SHADOW_OPACITY,
127
- shadowRadius: SHADOW_RADIUS,
128
- shadowOffset: SHADOW_OFFSET,
150
+ boxShadow: SEGMENT_BOX_SHADOW,
129
151
  elevation: SHADOW_ELEVATION
130
152
  },
131
153
  label: {
@@ -222,30 +244,30 @@ var UpgradePrompt = ({
222
244
  style: [styles5.container, { borderColor: primary, backgroundColor: colors.surface }],
223
245
  testID: LAYOUT_TEST_IDS.upgradePrompt,
224
246
  children: [
225
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.title, { color: colors.text }], children: t("settings.billing.upgradePrompt.title") }),
226
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.message, { color: colors.textSecondary }], children: t("settings.billing.upgradePrompt.message", requiredTier, currentTier) }),
247
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
248
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
227
249
  /* @__PURE__ */ jsxRuntime.jsx(
228
250
  reactNative.TouchableOpacity,
229
251
  {
230
- accessibilityHint: t("settings.billing.upgradePrompt.ctaHint"),
231
- accessibilityLabel: t("settings.billing.upgradePrompt.cta"),
252
+ accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
253
+ accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
232
254
  accessibilityRole: "button",
233
255
  style: [styles5.cta, { backgroundColor: primary }],
234
256
  testID: LAYOUT_TEST_IDS.upgradePromptCta,
235
257
  onPress: handleUpgradePress,
236
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.ctaText, { color: colors.surface }], children: t("settings.billing.upgradePrompt.cta") })
258
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
237
259
  }
238
260
  ),
239
261
  onDismiss ? /* @__PURE__ */ jsxRuntime.jsx(
240
262
  reactNative.TouchableOpacity,
241
263
  {
242
- accessibilityHint: t("settings.billing.upgradePrompt.dismissHint"),
243
- accessibilityLabel: t("settings.billing.upgradePrompt.dismiss"),
264
+ accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
265
+ accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
244
266
  accessibilityRole: "button",
245
267
  style: styles5.dismiss,
246
268
  testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
247
269
  onPress: onDismiss,
248
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.dismissText, { color: colors.textSecondary }], children: t("settings.billing.upgradePrompt.dismiss") })
270
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
249
271
  }
250
272
  ) : null
251
273
  ]
@@ -343,6 +365,15 @@ function buildPortalPopoverStyle(rect, minWidth = 0) {
343
365
  function buildAnchorStackStyle(isMenuOpen) {
344
366
  return isMenuOpen ? { zIndex: ANCHOR_OPEN_Z_INDEX, elevation: MENU_ELEVATION } : null;
345
367
  }
368
+ var MIN_VISIBLE_PX = 8;
369
+ function isAnchorHidden(rect, clip, minVisiblePx) {
370
+ const hasLayout = rect.width > 0 && rect.bottom > rect.top;
371
+ const hasClip = clip.bottom > clip.top && clip.right > clip.left;
372
+ if (!hasLayout || !hasClip) return false;
373
+ const visibleHeight = Math.min(rect.bottom, clip.bottom) - Math.max(rect.top, clip.top);
374
+ const visibleWidth = Math.min(rect.left + rect.width, clip.right) - Math.max(rect.left, clip.left);
375
+ return visibleHeight < minVisiblePx || visibleWidth < minVisiblePx;
376
+ }
346
377
  var OPTION_BORDER_RADIUS = 4;
347
378
  var BODY_FONT_SIZE = 14;
348
379
  var SELECTED_FONT_WEIGHT = "600";
@@ -376,7 +407,7 @@ var OptionRow = ({
376
407
  reactNative.TouchableOpacity,
377
408
  {
378
409
  accessible: true,
379
- accessibilityHint: t("common.selectOptionHint"),
410
+ accessibilityHint: t(LAYOUT_I18N.selectOptionHint),
380
411
  accessibilityLabel: label,
381
412
  accessibilityRole: "button",
382
413
  "aria-selected": isSelected,
@@ -387,6 +418,87 @@ var OptionRow = ({
387
418
  }
388
419
  );
389
420
  };
421
+ var IS_WEB = reactNative.Platform.OS === "web";
422
+ function toDomNode(containerRef) {
423
+ const node = containerRef.current;
424
+ if (node === null || typeof node.getBoundingClientRect !== "function") return null;
425
+ return node;
426
+ }
427
+ function readAnchorRect(containerRef) {
428
+ if (!IS_WEB) return null;
429
+ const node = toDomNode(containerRef);
430
+ if (node === null) return null;
431
+ const r = node.getBoundingClientRect();
432
+ return { top: r.top, left: r.left, width: r.width, bottom: r.bottom };
433
+ }
434
+ function clipsAxis(overflow) {
435
+ return overflow !== "" && overflow !== "visible";
436
+ }
437
+ function clipToAncestor(bounds, el) {
438
+ const style = window.getComputedStyle(el);
439
+ const clipsY = clipsAxis(style.overflowY) || clipsAxis(style.overflow);
440
+ const clipsX = clipsAxis(style.overflowX) || clipsAxis(style.overflow);
441
+ if (!clipsY && !clipsX) return;
442
+ const r = el.getBoundingClientRect();
443
+ if (clipsY) {
444
+ bounds.top = Math.max(bounds.top, r.top);
445
+ bounds.bottom = Math.min(bounds.bottom, r.bottom);
446
+ }
447
+ if (clipsX) {
448
+ bounds.left = Math.max(bounds.left, r.left);
449
+ bounds.right = Math.min(bounds.right, r.right);
450
+ }
451
+ }
452
+ function readClipBounds(node) {
453
+ const bounds = { top: 0, left: 0, bottom: window.innerHeight, right: window.innerWidth };
454
+ let el = node?.parentElement ?? null;
455
+ while (el !== null && el !== document.body && el !== document.documentElement) {
456
+ clipToAncestor(bounds, el);
457
+ el = el.parentElement;
458
+ }
459
+ return bounds;
460
+ }
461
+ function observeLayout(node, onChange) {
462
+ if (typeof ResizeObserver !== "function") return null;
463
+ const observer = new ResizeObserver(onChange);
464
+ if (node !== null) observer.observe(node);
465
+ observer.observe(document.body);
466
+ return observer;
467
+ }
468
+ function useAnchorTracking(containerRef, onOutOfView) {
469
+ const [rect, setRect] = React8.useState(() => readAnchorRect(containerRef));
470
+ React8.useLayoutEffect(() => {
471
+ if (!IS_WEB) return void 0;
472
+ let frame = null;
473
+ let isDisposed = false;
474
+ let hasMeasured = false;
475
+ const apply = () => {
476
+ frame = null;
477
+ if (isDisposed) return;
478
+ const next = readAnchorRect(containerRef);
479
+ setRect(next);
480
+ const isHidden = next !== null && isAnchorHidden(next, readClipBounds(toDomNode(containerRef)), MIN_VISIBLE_PX);
481
+ if (hasMeasured && isHidden) onOutOfView();
482
+ hasMeasured = true;
483
+ };
484
+ const schedule = () => {
485
+ if (frame !== null) return;
486
+ frame = window.requestAnimationFrame(apply);
487
+ };
488
+ apply();
489
+ document.addEventListener("scroll", schedule, true);
490
+ window.addEventListener("resize", schedule);
491
+ const observer = observeLayout(toDomNode(containerRef), schedule);
492
+ return () => {
493
+ isDisposed = true;
494
+ if (frame !== null) window.cancelAnimationFrame(frame);
495
+ document.removeEventListener("scroll", schedule, true);
496
+ window.removeEventListener("resize", schedule);
497
+ if (observer !== null) observer.disconnect();
498
+ };
499
+ }, [containerRef, onOutOfView]);
500
+ return rect;
501
+ }
390
502
  function refContains(ref, target) {
391
503
  if (ref === void 0) return false;
392
504
  const node = ref.current;
@@ -451,7 +563,7 @@ function useMenuKeyboard(params) {
451
563
  };
452
564
  }, [containerRef, menuRef, enabled, onClose, params]);
453
565
  }
454
- var IS_WEB = reactNative.Platform.OS === "web";
566
+ var IS_WEB2 = reactNative.Platform.OS === "web";
455
567
  var BORDER_RADIUS2 = 8;
456
568
  var BORDER_WIDTH3 = 1;
457
569
  var MENU_PADDING2 = 4;
@@ -472,30 +584,6 @@ var styles7 = reactNative.StyleSheet.create({
472
584
  elevation: MENU_ELEVATION
473
585
  }
474
586
  });
475
- function readAnchorRect(containerRef) {
476
- if (!IS_WEB) return null;
477
- const node = containerRef.current;
478
- if (node === null || typeof node.getBoundingClientRect !== "function") return null;
479
- const r = node.getBoundingClientRect();
480
- return { top: r.top, left: r.left, width: r.width, bottom: r.bottom };
481
- }
482
- function useAnchorRect(containerRef) {
483
- const [rect, setRect] = React8.useState(() => readAnchorRect(containerRef));
484
- React8.useLayoutEffect(() => {
485
- if (!IS_WEB) return void 0;
486
- const measure = () => {
487
- setRect(readAnchorRect(containerRef));
488
- };
489
- measure();
490
- window.addEventListener("scroll", measure, true);
491
- window.addEventListener("resize", measure);
492
- return () => {
493
- window.removeEventListener("scroll", measure, true);
494
- window.removeEventListener("resize", measure);
495
- };
496
- }, [containerRef]);
497
- return rect;
498
- }
499
587
  var InlineMenu = ({
500
588
  testID,
501
589
  accessibilityLabel,
@@ -510,7 +598,7 @@ var InlineMenu = ({
510
598
  const { theme } = uiFeedback.useUi();
511
599
  const { colors } = theme;
512
600
  const menuRef = React8.useRef(null);
513
- const rect = useAnchorRect(containerRef);
601
+ const rect = useAnchorTracking(containerRef, onClose);
514
602
  const selectedIndex = React8.useMemo(
515
603
  () => Math.max(0, options.findIndex((opt) => opt.value === value)),
516
604
  [options, value]
@@ -540,7 +628,7 @@ var InlineMenu = ({
540
628
  });
541
629
  const popoverStyle = React8.useMemo(() => {
542
630
  const themed = { borderColor: colors.border, backgroundColor: colors.surface };
543
- if (IS_WEB)
631
+ if (IS_WEB2)
544
632
  return [
545
633
  buildPortalPopoverStyle(rect ?? { left: 0, width: 0, bottom: 0 }, menuMinWidth),
546
634
  themed
@@ -568,7 +656,7 @@ var InlineMenu = ({
568
656
  )) })
569
657
  }
570
658
  );
571
- if (IS_WEB) return reactDom.createPortal(menu, document.body);
659
+ if (IS_WEB2) return reactDom.createPortal(menu, document.body);
572
660
  return menu;
573
661
  };
574
662
  var MENU_BREAKPOINT = 768;
@@ -582,6 +670,7 @@ function useResolvedDropdownVariant(explicit) {
582
670
  const { width } = reactNative.useWindowDimensions();
583
671
  return resolveDropdownVariant(explicit, width, reactNative.Platform.OS);
584
672
  }
673
+ var IS_WEB3 = reactNative.Platform.OS === "web";
585
674
  var BORDER_RADIUS3 = 8;
586
675
  var BORDER_WIDTH4 = 1;
587
676
  var BODY_FONT_SIZE2 = 14;
@@ -590,8 +679,21 @@ var MODAL_MIN_WIDTH = 200;
590
679
  var MODAL_MAX_HEIGHT = 300;
591
680
  var CONTAINER_PADDING_H = 12;
592
681
  var CONTAINER_PADDING_V = 10;
682
+ var SR_ONLY_SIZE = 1;
683
+ var SR_ONLY_OFFSET = -1;
684
+ function buildHintProps(hint, hintId) {
685
+ return IS_WEB3 ? { "aria-describedby": hintId } : { accessibilityHint: hint };
686
+ }
593
687
  var styles8 = reactNative.StyleSheet.create({
594
688
  anchor: { position: "relative" },
689
+ srOnly: {
690
+ position: "absolute",
691
+ width: SR_ONLY_SIZE,
692
+ height: SR_ONLY_SIZE,
693
+ margin: SR_ONLY_OFFSET,
694
+ padding: 0,
695
+ overflow: "hidden"
696
+ },
595
697
  container: {
596
698
  borderWidth: BORDER_WIDTH4,
597
699
  borderRadius: BORDER_RADIUS3,
@@ -629,12 +731,13 @@ var ModalDropdown = ({
629
731
  const resolvedVariant = useResolvedDropdownVariant(variant);
630
732
  const isMenu = resolvedVariant === "menu" /* Menu */;
631
733
  const [isOpen, setIsOpen] = React8.useState(false);
734
+ const hintId = `${testID}-hint`;
632
735
  const anchorRef = React8.useRef(null);
633
736
  const dialogRef = React8.useRef(null);
634
737
  useFocusTrap(dialogRef, isOpen && !isMenu);
635
738
  const selectedLabel = React8.useMemo(() => {
636
739
  const found = options.find((opt) => opt.value === value);
637
- return found?.label ?? t("common.selectPlaceholder");
740
+ return found?.label ?? t(LAYOUT_I18N.selectPlaceholder);
638
741
  }, [options, value, t]);
639
742
  const handleToggle = React8.useCallback(() => {
640
743
  setIsOpen((prev) => !prev);
@@ -683,7 +786,7 @@ var ModalDropdown = ({
683
786
  reactNative.TouchableOpacity,
684
787
  {
685
788
  accessible: true,
686
- accessibilityHint,
789
+ ...buildHintProps(accessibilityHint, hintId),
687
790
  accessibilityLabel,
688
791
  accessibilityRole: "button",
689
792
  accessibilityState: { expanded: isOpen },
@@ -694,6 +797,7 @@ var ModalDropdown = ({
694
797
  children: renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.selectedText, { color: colors.text }], children: selectedLabel })
695
798
  }
696
799
  ),
800
+ IS_WEB3 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { nativeID: hintId, style: styles8.srOnly, testID: `${testID}-hint`, children: accessibilityHint }) : null,
697
801
  isMenu && isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
698
802
  InlineMenu,
699
803
  {
@@ -713,8 +817,8 @@ var ModalDropdown = ({
713
817
  reactNative.TouchableOpacity,
714
818
  {
715
819
  accessible: true,
716
- accessibilityHint: t("common.dismissDropdownHint"),
717
- accessibilityLabel: t("common.dismissDropdown"),
820
+ accessibilityHint: t(LAYOUT_I18N.dismissDropdownHint),
821
+ accessibilityLabel: t(LAYOUT_I18N.dismissDropdown),
718
822
  accessibilityRole: "button",
719
823
  activeOpacity: 1,
720
824
  style: reactNative.StyleSheet.absoluteFill,
@@ -765,8 +869,8 @@ var ModalShell = ({
765
869
  () => [styles9.container, { backgroundColor: theme.colors.background }, contentStyle],
766
870
  [theme.colors.background, contentStyle]
767
871
  );
768
- const closeA11yLabel = t("quizTemplates.cancel");
769
- const accessibleTitle = typeof title === "string" ? title : t("common.dialog");
872
+ const closeA11yLabel = t(LAYOUT_I18N.close);
873
+ const accessibleTitle = typeof title === "string" ? title : t(LAYOUT_I18N.dialog);
770
874
  return /* @__PURE__ */ jsxRuntime.jsx(
771
875
  reactNative.Modal,
772
876
  {
@@ -783,11 +887,11 @@ var ModalShell = ({
783
887
  style: containerStyle,
784
888
  children: [
785
889
  /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles9.headerRow, children: [
786
- /* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title ?? t("close") }),
890
+ /* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title ?? t(LAYOUT_I18N.closeHeading) }),
787
891
  showClose ? /* @__PURE__ */ jsxRuntime.jsx(
788
892
  reactNative.TouchableOpacity,
789
893
  {
790
- accessibilityHint: t("common.closeDialogHint"),
894
+ accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
791
895
  accessibilityLabel: closeA11yLabel,
792
896
  accessibilityRole: "button",
793
897
  style: styles9.closeButton,
@@ -1021,7 +1125,7 @@ var AccordionItem = ({
1021
1125
  /* @__PURE__ */ jsxRuntime.jsxs(
1022
1126
  reactNative.Pressable,
1023
1127
  {
1024
- accessibilityHint: accessibilityHint ?? t("common.accordionToggleHint"),
1128
+ accessibilityHint: accessibilityHint ?? t(LAYOUT_I18N.accordionToggleHint),
1025
1129
  accessibilityLabel: resolvedLabel,
1026
1130
  accessibilityRole: "button",
1027
1131
  accessibilityState: { expanded, disabled },
@@ -1085,6 +1189,7 @@ exports.AccordionItem = AccordionItem;
1085
1189
  exports.DEFAULT_BILLING_ROUTE = DEFAULT_BILLING_ROUTE;
1086
1190
  exports.DropdownVariant = DropdownVariant;
1087
1191
  exports.Heading = Heading;
1192
+ exports.LAYOUT_I18N = LAYOUT_I18N;
1088
1193
  exports.LAYOUT_TEST_IDS = LAYOUT_TEST_IDS;
1089
1194
  exports.ModalDropdown = ModalDropdown;
1090
1195
  exports.ModalShell = ModalShell;