@dloizides/ui-layout 1.18.0 → 1.20.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/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import React8, { createContext, useMemo, useRef, useEffect, useState, useCallback, useContext, useLayoutEffect } from 'react';
2
- import { StyleSheet, Platform, View, Text, Pressable, ScrollView, TouchableOpacity, Modal, FlatList, Animated, Easing, useWindowDimensions, LayoutAnimation, UIManager } from 'react-native';
1
+ import React9, { createContext, useMemo, useRef, useEffect, useState, useCallback, useContext, useLayoutEffect } from 'react';
2
+ import { StyleSheet, Platform, View, Text, Pressable, TouchableOpacity, Modal, FlatList, ScrollView, Animated, Easing, useWindowDimensions, LayoutAnimation, UIManager } from 'react-native';
3
3
  import { MODAL_OVERLAY_COLOR, useUi } from '@dloizides/ui-feedback';
4
- import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import { useA11y } from '@dloizides/a11y';
6
6
  import { createPortal } from 'react-dom';
7
7
  import { SvgIcon } from '@dloizides/ui-icons';
@@ -17,7 +17,7 @@ var styles = StyleSheet.create({
17
17
  });
18
18
  var Section = ({ children, style }) => {
19
19
  const { theme } = useUi();
20
- const containerStyle = React8.useMemo(
20
+ const containerStyle = React9.useMemo(
21
21
  () => [styles.card, { borderColor: theme.colors.border, backgroundColor: theme.colors.surface }, style],
22
22
  [theme.colors.border, theme.colors.surface, style]
23
23
  );
@@ -39,6 +39,11 @@ var DEFAULT_BILLING_ROUTE = "/settings/billing";
39
39
  var LAYOUT_I18N = {
40
40
  /** Placeholder shown by `ModalDropdown` when no option matches the current value. */
41
41
  selectPlaceholder: "common.selectPlaceholder",
42
+ /**
43
+ * Accessible hint on the collapsed (mobile) `Tabs` menu trigger — the button
44
+ * that shows the active section and opens the vertical list of sections.
45
+ */
46
+ tabsMenuHint: "common.tabsMenuHint",
42
47
  /** Accessible name + hint of the modal-variant dropdown's dismiss backdrop. */
43
48
  dismissDropdown: "common.dismissDropdown",
44
49
  dismissDropdownHint: "common.dismissDropdownHint",
@@ -91,7 +96,7 @@ var Heading = ({
91
96
  testID
92
97
  }) => {
93
98
  const { theme } = useUi();
94
- const headingStyle = React8.useMemo(
99
+ const headingStyle = React9.useMemo(
95
100
  () => [styles2.heading, { color: theme.colors.text }, style],
96
101
  [theme.colors.text, style]
97
102
  );
@@ -225,186 +230,6 @@ function SegmentedControl({
225
230
  }
226
231
  );
227
232
  }
228
- var PILL_RADIUS = 999;
229
- var PILL_PAD_H = 16;
230
- var PILL_PAD_V = 8;
231
- var PILL_MIN_HEIGHT = 40;
232
- var PILL_FONT = 14;
233
- var PILL_WEIGHT = "600";
234
- var ROW_GAP = 8;
235
- var COLUMN_GAP = 8;
236
- var ROW_PAD_V = 8;
237
- var PANEL_PAD_TOP = 16;
238
- var BORDER_WIDTH2 = 1;
239
- var TEXT_ON_PRIMARY = "#ffffff";
240
- var styles5 = StyleSheet.create({
241
- root: {
242
- width: "100%"
243
- },
244
- // The full-width rule under the row lives here (not on the strip) so it spans the
245
- // whole width even when the tabs are narrower than the viewport (desktop) and is
246
- // not clipped to the scroll content width.
247
- stripOuter: {
248
- width: "100%",
249
- borderBottomWidth: BORDER_WIDTH2
250
- },
251
- strip: {
252
- flexDirection: "row",
253
- flexWrap: "nowrap",
254
- alignItems: "center",
255
- columnGap: COLUMN_GAP,
256
- rowGap: ROW_GAP,
257
- paddingVertical: ROW_PAD_V
258
- },
259
- pill: {
260
- // Keep each pill at its natural size so the row scrolls instead of squashing
261
- // the tabs when they don't all fit.
262
- flexShrink: 0,
263
- paddingHorizontal: PILL_PAD_H,
264
- paddingVertical: PILL_PAD_V,
265
- borderRadius: PILL_RADIUS,
266
- minHeight: PILL_MIN_HEIGHT,
267
- flexDirection: "row",
268
- alignItems: "center",
269
- justifyContent: "center"
270
- },
271
- pillText: {
272
- fontSize: PILL_FONT,
273
- fontWeight: PILL_WEIGHT,
274
- textAlign: "center"
275
- },
276
- panel: {
277
- paddingTop: PANEL_PAD_TOP
278
- }
279
- });
280
- function ariaTabProps(selected, panelId, tabId) {
281
- return { "aria-selected": selected, "aria-controls": panelId, id: tabId };
282
- }
283
- var Tabs = ({
284
- tabs,
285
- activeKey,
286
- onChange,
287
- accessibilityLabel,
288
- children,
289
- idPrefix = "tabs",
290
- style,
291
- stripStyle,
292
- panelStyle,
293
- testID
294
- }) => {
295
- const { theme } = useUi();
296
- const { colors } = theme;
297
- const primaryColor = theme.palette.primary["500"];
298
- const activePanelId = `${idPrefix}-panel-${activeKey}`;
299
- const activeTabId = `${idPrefix}-tab-${activeKey}`;
300
- const panelAria = { "aria-labelledby": activeTabId, id: activePanelId };
301
- return /* @__PURE__ */ jsxs(View, { style: [styles5.root, style], testID, children: [
302
- /* @__PURE__ */ jsx(View, { style: [styles5.stripOuter, { borderBottomColor: colors.border }], children: /* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, children: /* @__PURE__ */ jsx(
303
- View,
304
- {
305
- accessibilityRole: "tablist",
306
- "aria-label": accessibilityLabel,
307
- style: [styles5.strip, stripStyle],
308
- children: tabs.map((tab) => {
309
- const selected = tab.key === activeKey;
310
- const textColor = selected ? TEXT_ON_PRIMARY : colors.textSecondary;
311
- const pillColor = selected ? primaryColor : colors.surfaceElevated;
312
- const tabId = `${idPrefix}-tab-${tab.key}`;
313
- const panelId = `${idPrefix}-panel-${tab.key}`;
314
- return /* @__PURE__ */ jsx(
315
- Pressable,
316
- {
317
- accessibilityRole: "tab",
318
- accessibilityState: { selected },
319
- accessibilityLabel: tab.accessibilityLabel ?? tab.label,
320
- accessibilityHint: tab.accessibilityHint,
321
- onPress: () => onChange(tab.key),
322
- style: [styles5.pill, { backgroundColor: pillColor }],
323
- testID: tab.testID,
324
- ...ariaTabProps(selected, panelId, tabId),
325
- children: /* @__PURE__ */ jsx(Text, { style: [styles5.pillText, { color: textColor }], children: tab.label })
326
- },
327
- tab.key
328
- );
329
- })
330
- }
331
- ) }) }),
332
- /* @__PURE__ */ jsx(View, { accessibilityRole: "none", style: [styles5.panel, panelStyle], ...panelAria, children })
333
- ] });
334
- };
335
- var PROMPT_PADDING = 20;
336
- var PROMPT_BORDER_RADIUS = 12;
337
- var PROMPT_BORDER_WIDTH = 1;
338
- var TITLE_FONT_SIZE = 16;
339
- var MESSAGE_FONT_SIZE = 14;
340
- var BUTTON_PADDING_V = 12;
341
- var BUTTON_BORDER_RADIUS = 8;
342
- var BUTTON_FONT_SIZE = 14;
343
- var DISMISS_FONT_SIZE = 13;
344
- var TITLE_MARGIN_BOTTOM = 8;
345
- var MESSAGE_MARGIN_BOTTOM = 16;
346
- var CTA_MARGIN_BOTTOM = 8;
347
- var styles6 = StyleSheet.create({
348
- container: {
349
- padding: PROMPT_PADDING,
350
- borderRadius: PROMPT_BORDER_RADIUS,
351
- borderWidth: PROMPT_BORDER_WIDTH
352
- },
353
- title: { fontSize: TITLE_FONT_SIZE, fontWeight: "700", marginBottom: TITLE_MARGIN_BOTTOM },
354
- message: { fontSize: MESSAGE_FONT_SIZE, marginBottom: MESSAGE_MARGIN_BOTTOM },
355
- cta: { paddingVertical: BUTTON_PADDING_V, borderRadius: BUTTON_BORDER_RADIUS, alignItems: "center", marginBottom: CTA_MARGIN_BOTTOM },
356
- ctaText: { fontSize: BUTTON_FONT_SIZE, fontWeight: "700" },
357
- dismiss: { alignItems: "center", paddingVertical: BUTTON_PADDING_V },
358
- dismissText: { fontSize: DISMISS_FONT_SIZE }
359
- });
360
- var UpgradePrompt = ({
361
- requiredTier,
362
- currentTier,
363
- onDismiss,
364
- billingRoute = DEFAULT_BILLING_ROUTE
365
- }) => {
366
- const { theme, t, navigate } = useUi();
367
- const colors = theme.colors;
368
- const primary = theme.palette.primary["500"];
369
- function handleUpgradePress() {
370
- if (typeof navigate === "function") navigate(billingRoute);
371
- }
372
- return /* @__PURE__ */ jsxs(
373
- View,
374
- {
375
- style: [styles6.container, { borderColor: primary, backgroundColor: colors.surface }],
376
- testID: LAYOUT_TEST_IDS.upgradePrompt,
377
- children: [
378
- /* @__PURE__ */ jsx(Text, { style: [styles6.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
379
- /* @__PURE__ */ jsx(Text, { style: [styles6.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
380
- /* @__PURE__ */ jsx(
381
- TouchableOpacity,
382
- {
383
- accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
384
- accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
385
- accessibilityRole: "button",
386
- style: [styles6.cta, { backgroundColor: primary }],
387
- testID: LAYOUT_TEST_IDS.upgradePromptCta,
388
- onPress: handleUpgradePress,
389
- children: /* @__PURE__ */ jsx(Text, { style: [styles6.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
390
- }
391
- ),
392
- onDismiss ? /* @__PURE__ */ jsx(
393
- TouchableOpacity,
394
- {
395
- accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
396
- accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
397
- accessibilityRole: "button",
398
- style: styles6.dismiss,
399
- testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
400
- onPress: onDismiss,
401
- children: /* @__PURE__ */ jsx(Text, { style: [styles6.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
402
- }
403
- ) : null
404
- ]
405
- }
406
- );
407
- };
408
233
  var FOCUSABLE_SELECTOR = [
409
234
  "a[href]",
410
235
  "button:not([disabled])",
@@ -473,7 +298,7 @@ var MENU_ELEVATION = 8;
473
298
  var MENU_TOP_GAP = 4;
474
299
  var MENU_MAX_HEIGHT = 300;
475
300
  var BORDER_RADIUS = 8;
476
- var BORDER_WIDTH3 = 1;
301
+ var BORDER_WIDTH2 = 1;
477
302
  var MENU_PADDING = 4;
478
303
  var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
479
304
  function buildPortalPopoverStyle(rect, minWidth = 0) {
@@ -485,7 +310,7 @@ function buildPortalPopoverStyle(rect, minWidth = 0) {
485
310
  left: rect.left,
486
311
  width: Math.max(rect.width, minWidth),
487
312
  zIndex: MENU_Z_INDEX,
488
- borderWidth: BORDER_WIDTH3,
313
+ borderWidth: BORDER_WIDTH2,
489
314
  borderRadius: BORDER_RADIUS,
490
315
  padding: MENU_PADDING,
491
316
  maxHeight: MENU_MAX_HEIGHT,
@@ -510,7 +335,7 @@ var BODY_FONT_SIZE = 14;
510
335
  var SELECTED_FONT_WEIGHT = "600";
511
336
  var OPTION_PADDING_H = 16;
512
337
  var OPTION_PADDING_V = 12;
513
- var styles7 = StyleSheet.create({
338
+ var styles5 = StyleSheet.create({
514
339
  option: {
515
340
  paddingHorizontal: OPTION_PADDING_H,
516
341
  paddingVertical: OPTION_PADDING_V,
@@ -532,8 +357,8 @@ var OptionRow = ({
532
357
  onSelect();
533
358
  }, [onSelect]);
534
359
  const isActive = isSelected || isHighlighted;
535
- const rowStyle = [styles7.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
536
- const textStyle = [styles7.optionText, { color: colors.text }, isSelected ? styles7.selectedText : null];
360
+ const rowStyle = [styles5.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
361
+ const textStyle = [styles5.optionText, { color: colors.text }, isSelected ? styles5.selectedText : null];
537
362
  return /* @__PURE__ */ jsx(
538
363
  TouchableOpacity,
539
364
  {
@@ -696,9 +521,9 @@ function useMenuKeyboard(params) {
696
521
  }
697
522
  var IS_WEB2 = Platform.OS === "web";
698
523
  var BORDER_RADIUS2 = 8;
699
- var BORDER_WIDTH4 = 1;
524
+ var BORDER_WIDTH3 = 1;
700
525
  var MENU_PADDING2 = 4;
701
- var styles8 = StyleSheet.create({
526
+ var styles6 = StyleSheet.create({
702
527
  /** Native (in-tree) popover — anchored absolutely just under the trigger. */
703
528
  popover: {
704
529
  position: "absolute",
@@ -707,7 +532,7 @@ var styles8 = StyleSheet.create({
707
532
  right: 0,
708
533
  marginTop: MENU_TOP_GAP,
709
534
  zIndex: MENU_Z_INDEX,
710
- borderWidth: BORDER_WIDTH4,
535
+ borderWidth: BORDER_WIDTH3,
711
536
  borderRadius: BORDER_RADIUS2,
712
537
  padding: MENU_PADDING2,
713
538
  maxHeight: MENU_MAX_HEIGHT,
@@ -764,7 +589,7 @@ var InlineMenu = ({
764
589
  buildPortalPopoverStyle(rect ?? { left: 0, width: 0, bottom: 0 }, menuMinWidth),
765
590
  themed
766
591
  ];
767
- return [styles8.popover, { minWidth: menuMinWidth }, themed];
592
+ return [styles6.popover, { minWidth: menuMinWidth }, themed];
768
593
  }, [colors.border, colors.surface, menuMinWidth, rect]);
769
594
  const menu = /* @__PURE__ */ jsx(
770
595
  View,
@@ -802,22 +627,41 @@ function useResolvedDropdownVariant(explicit) {
802
627
  return resolveDropdownVariant(explicit, width, Platform.OS);
803
628
  }
804
629
  var BORDER_RADIUS3 = 8;
805
- var BORDER_WIDTH5 = 1;
630
+ var BORDER_WIDTH4 = 1;
806
631
  var BODY_FONT_SIZE2 = 14;
807
632
  var MODAL_PADDING = 8;
808
633
  var MODAL_MIN_WIDTH = 200;
809
634
  var MODAL_MAX_HEIGHT = 300;
810
635
  var CONTAINER_PADDING_H = 12;
811
636
  var CONTAINER_PADDING_V = 10;
812
- var styles9 = StyleSheet.create({
637
+ var MIN_TOUCH_TARGET = 44;
638
+ var CARET_FONT_SIZE = 12;
639
+ var CARET_GAP = 8;
640
+ var CARET_GLYPH = "\u25BE";
641
+ var CARET_OPEN_ROTATION = "180deg";
642
+ var CARET_CLOSED_ROTATION = "0deg";
643
+ var styles7 = StyleSheet.create({
813
644
  anchor: { position: "relative" },
814
645
  container: {
815
- borderWidth: BORDER_WIDTH5,
646
+ borderWidth: BORDER_WIDTH4,
816
647
  borderRadius: BORDER_RADIUS3,
817
648
  paddingHorizontal: CONTAINER_PADDING_H,
818
649
  paddingVertical: CONTAINER_PADDING_V
819
650
  },
651
+ // Caret variant: a row with the label leading and the caret pinned to the trailing edge, at a
652
+ // phone-friendly minimum height. Only applied when `showCaret` is set, so field dropdowns are
653
+ // untouched.
654
+ containerMenu: {
655
+ minHeight: MIN_TOUCH_TARGET,
656
+ flexDirection: "row",
657
+ alignItems: "center",
658
+ justifyContent: "space-between",
659
+ columnGap: CARET_GAP
660
+ },
820
661
  selectedText: { fontSize: BODY_FONT_SIZE2 },
662
+ // The label may shrink/ellipsize; the caret never does.
663
+ selectedTextMenu: { flexShrink: 1 },
664
+ caret: { fontSize: CARET_FONT_SIZE, flexShrink: 0 },
821
665
  modalOverlay: {
822
666
  flex: 1,
823
667
  justifyContent: "center",
@@ -841,7 +685,8 @@ var ModalDropdown = ({
841
685
  variant,
842
686
  renderTrigger,
843
687
  optionTestID,
844
- menuMinWidth
688
+ menuMinWidth,
689
+ showCaret = false
845
690
  }) => {
846
691
  const { theme, t } = useUi();
847
692
  const { colors } = theme;
@@ -876,19 +721,30 @@ var ModalDropdown = ({
876
721
  [onChange]
877
722
  );
878
723
  const containerStyle = useMemo(
879
- () => renderTrigger !== void 0 ? void 0 : [styles9.container, { borderColor: colors.border, backgroundColor: colors.surface }],
880
- [colors.border, colors.surface, renderTrigger]
724
+ () => renderTrigger !== void 0 ? void 0 : [
725
+ styles7.container,
726
+ showCaret ? styles7.containerMenu : null,
727
+ { borderColor: colors.border, backgroundColor: colors.surface }
728
+ ],
729
+ [colors.border, colors.surface, renderTrigger, showCaret]
730
+ );
731
+ const caretStyle = useMemo(
732
+ () => [
733
+ styles7.caret,
734
+ { color: colors.textSecondary, transform: [{ rotate: isOpen ? CARET_OPEN_ROTATION : CARET_CLOSED_ROTATION }] }
735
+ ],
736
+ [colors.textSecondary, isOpen]
881
737
  );
882
738
  const optionTestIDFor = useCallback(
883
739
  (optionValue) => optionTestID !== void 0 ? optionTestID(optionValue) : `${testID}-option-${String(optionValue)}`,
884
740
  [optionTestID, testID]
885
741
  );
886
742
  const anchorStyle = useMemo(
887
- () => [styles9.anchor, buildAnchorStackStyle(isMenu && isOpen)],
743
+ () => [styles7.anchor, buildAnchorStackStyle(isMenu && isOpen)],
888
744
  [isMenu, isOpen]
889
745
  );
890
746
  const modalContentStyle = useMemo(
891
- () => [styles9.modalContent, { backgroundColor: colors.surface }],
747
+ () => [styles7.modalContent, { backgroundColor: colors.surface }],
892
748
  [colors.surface]
893
749
  );
894
750
  const renderModalOption = useCallback(
@@ -906,7 +762,10 @@ var ModalDropdown = ({
906
762
  const keyExtractor = useCallback((item) => String(item.value), []);
907
763
  return /* @__PURE__ */ jsxs(View, { ref: anchorRef, style: anchorStyle, children: [
908
764
  /* @__PURE__ */ jsxs(TouchableOpacity, { ...a11yProps, style: containerStyle, onPress: handleToggle, children: [
909
- renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : /* @__PURE__ */ jsx(Text, { style: [styles9.selectedText, { color: colors.text }], children: selectedLabel }),
765
+ renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : showCaret ? /* @__PURE__ */ jsxs(Fragment, { children: [
766
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles7.selectedText, styles7.selectedTextMenu, { color: colors.text }], children: selectedLabel }),
767
+ /* @__PURE__ */ jsx(Text, { style: caretStyle, children: CARET_GLYPH })
768
+ ] }) : /* @__PURE__ */ jsx(Text, { style: [styles7.selectedText, { color: colors.text }], children: selectedLabel }),
910
769
  hintNode
911
770
  ] }),
912
771
  isMenu && isOpen ? /* @__PURE__ */ jsx(
@@ -923,7 +782,7 @@ var ModalDropdown = ({
923
782
  onSelect: handleSelect
924
783
  }
925
784
  ) : null,
926
- !isMenu ? /* @__PURE__ */ jsx(Modal, { transparent: true, animationType: "fade", visible: isOpen, onRequestClose: handleClose, children: /* @__PURE__ */ jsxs(View, { style: styles9.modalOverlay, children: [
785
+ !isMenu ? /* @__PURE__ */ jsx(Modal, { transparent: true, animationType: "fade", visible: isOpen, onRequestClose: handleClose, children: /* @__PURE__ */ jsxs(View, { style: styles7.modalOverlay, children: [
927
786
  /* @__PURE__ */ jsx(
928
787
  TouchableOpacity,
929
788
  {
@@ -951,6 +810,259 @@ var ModalDropdown = ({
951
810
  ] }) }) : null
952
811
  ] });
953
812
  };
813
+ var TabsMenu = ({
814
+ tabs,
815
+ activeKey,
816
+ onChange,
817
+ accessibilityLabel,
818
+ idPrefix,
819
+ testID
820
+ }) => {
821
+ const { t } = useUi();
822
+ const options = useMemo(
823
+ () => tabs.map((tab) => ({ label: tab.label, value: tab.key })),
824
+ [tabs]
825
+ );
826
+ const optionTestID = useCallback(
827
+ (key) => {
828
+ const found = tabs.find((tab) => tab.key === key);
829
+ return found?.testID ?? `${idPrefix}-tab-${key}`;
830
+ },
831
+ [tabs, idPrefix]
832
+ );
833
+ return /* @__PURE__ */ jsx(
834
+ ModalDropdown,
835
+ {
836
+ accessibilityHint: t(LAYOUT_I18N.tabsMenuHint),
837
+ accessibilityLabel,
838
+ optionTestID,
839
+ options,
840
+ showCaret: true,
841
+ testID,
842
+ value: activeKey,
843
+ onChange
844
+ }
845
+ );
846
+ };
847
+ var TABS_COLLAPSE_BREAKPOINT = MENU_BREAKPOINT;
848
+ var WEB_PLATFORM2 = "web";
849
+ function shouldCollapseTabs(width, platformOS, breakpoint) {
850
+ const isWideWeb = platformOS === WEB_PLATFORM2 && width >= breakpoint;
851
+ return !isWideWeb;
852
+ }
853
+ function useTabsCollapsed(breakpoint) {
854
+ const { width } = useWindowDimensions();
855
+ return shouldCollapseTabs(width, Platform.OS, breakpoint);
856
+ }
857
+ var PILL_RADIUS = 999;
858
+ var PILL_PAD_H = 16;
859
+ var PILL_PAD_V = 8;
860
+ var PILL_MIN_HEIGHT = 40;
861
+ var PILL_FONT = 14;
862
+ var PILL_WEIGHT = "600";
863
+ var ROW_GAP = 8;
864
+ var COLUMN_GAP = 8;
865
+ var ROW_PAD_V = 8;
866
+ var PANEL_PAD_TOP = 16;
867
+ var BORDER_WIDTH5 = 1;
868
+ var TEXT_ON_PRIMARY = "#ffffff";
869
+ var styles8 = StyleSheet.create({
870
+ root: {
871
+ width: "100%"
872
+ },
873
+ // The full-width rule under the row lives here (not on the strip) so it spans the
874
+ // whole width even when the tabs are narrower than the viewport (desktop) and is
875
+ // not clipped to the scroll content width.
876
+ stripOuter: {
877
+ width: "100%",
878
+ borderBottomWidth: BORDER_WIDTH5
879
+ },
880
+ strip: {
881
+ flexDirection: "row",
882
+ flexWrap: "nowrap",
883
+ alignItems: "center",
884
+ columnGap: COLUMN_GAP,
885
+ rowGap: ROW_GAP,
886
+ paddingVertical: ROW_PAD_V
887
+ },
888
+ pill: {
889
+ // Keep each pill at its natural size so the row scrolls instead of squashing
890
+ // the tabs when they don't all fit.
891
+ flexShrink: 0,
892
+ paddingHorizontal: PILL_PAD_H,
893
+ paddingVertical: PILL_PAD_V,
894
+ borderRadius: PILL_RADIUS,
895
+ minHeight: PILL_MIN_HEIGHT,
896
+ flexDirection: "row",
897
+ alignItems: "center",
898
+ justifyContent: "center"
899
+ },
900
+ pillText: {
901
+ fontSize: PILL_FONT,
902
+ fontWeight: PILL_WEIGHT,
903
+ textAlign: "center"
904
+ },
905
+ panel: {
906
+ paddingTop: PANEL_PAD_TOP
907
+ }
908
+ });
909
+ function ariaTabProps(selected, panelId, tabId) {
910
+ return { "aria-selected": selected, "aria-controls": panelId, id: tabId };
911
+ }
912
+ var WideTabStrip = ({
913
+ tabs,
914
+ activeKey,
915
+ onChange,
916
+ accessibilityLabel,
917
+ idPrefix,
918
+ borderColor,
919
+ primaryColor,
920
+ textSecondary,
921
+ surfaceElevated,
922
+ stripStyle
923
+ }) => /* @__PURE__ */ jsx(View, { style: [styles8.stripOuter, { borderBottomColor: borderColor }], children: /* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, children: /* @__PURE__ */ jsx(View, { accessibilityRole: "tablist", "aria-label": accessibilityLabel, style: [styles8.strip, stripStyle], children: tabs.map((tab) => {
924
+ const selected = tab.key === activeKey;
925
+ const textColor = selected ? TEXT_ON_PRIMARY : textSecondary;
926
+ const pillColor = selected ? primaryColor : surfaceElevated;
927
+ const tabId = `${idPrefix}-tab-${tab.key}`;
928
+ const panelId = `${idPrefix}-panel-${tab.key}`;
929
+ return /* @__PURE__ */ jsx(
930
+ Pressable,
931
+ {
932
+ accessibilityRole: "tab",
933
+ accessibilityState: { selected },
934
+ accessibilityLabel: tab.accessibilityLabel ?? tab.label,
935
+ accessibilityHint: tab.accessibilityHint,
936
+ onPress: () => onChange(tab.key),
937
+ style: [styles8.pill, { backgroundColor: pillColor }],
938
+ testID: tab.testID,
939
+ ...ariaTabProps(selected, panelId, tabId),
940
+ children: /* @__PURE__ */ jsx(Text, { style: [styles8.pillText, { color: textColor }], children: tab.label })
941
+ },
942
+ tab.key
943
+ );
944
+ }) }) }) });
945
+ var Tabs = ({
946
+ tabs,
947
+ activeKey,
948
+ onChange,
949
+ accessibilityLabel,
950
+ children,
951
+ idPrefix = "tabs",
952
+ collapseBelow = TABS_COLLAPSE_BREAKPOINT,
953
+ style,
954
+ stripStyle,
955
+ panelStyle,
956
+ testID
957
+ }) => {
958
+ const { theme } = useUi();
959
+ const { colors } = theme;
960
+ const collapsed = useTabsCollapsed(collapseBelow);
961
+ const activePanelId = `${idPrefix}-panel-${activeKey}`;
962
+ const activeTabId = `${idPrefix}-tab-${activeKey}`;
963
+ const panelAria = { "aria-labelledby": activeTabId, id: activePanelId };
964
+ return /* @__PURE__ */ jsxs(View, { style: [styles8.root, style], testID, children: [
965
+ collapsed ? /* @__PURE__ */ jsx(
966
+ TabsMenu,
967
+ {
968
+ accessibilityLabel,
969
+ activeKey,
970
+ idPrefix,
971
+ tabs,
972
+ testID: `${idPrefix}-menu`,
973
+ onChange
974
+ }
975
+ ) : /* @__PURE__ */ jsx(
976
+ WideTabStrip,
977
+ {
978
+ accessibilityLabel,
979
+ activeKey,
980
+ borderColor: colors.border,
981
+ idPrefix,
982
+ primaryColor: theme.palette.primary["500"],
983
+ stripStyle,
984
+ surfaceElevated: colors.surfaceElevated,
985
+ tabs,
986
+ textSecondary: colors.textSecondary,
987
+ onChange
988
+ }
989
+ ),
990
+ /* @__PURE__ */ jsx(View, { accessibilityRole: "none", style: [styles8.panel, panelStyle], ...panelAria, children })
991
+ ] });
992
+ };
993
+ var PROMPT_PADDING = 20;
994
+ var PROMPT_BORDER_RADIUS = 12;
995
+ var PROMPT_BORDER_WIDTH = 1;
996
+ var TITLE_FONT_SIZE = 16;
997
+ var MESSAGE_FONT_SIZE = 14;
998
+ var BUTTON_PADDING_V = 12;
999
+ var BUTTON_BORDER_RADIUS = 8;
1000
+ var BUTTON_FONT_SIZE = 14;
1001
+ var DISMISS_FONT_SIZE = 13;
1002
+ var TITLE_MARGIN_BOTTOM = 8;
1003
+ var MESSAGE_MARGIN_BOTTOM = 16;
1004
+ var CTA_MARGIN_BOTTOM = 8;
1005
+ var styles9 = StyleSheet.create({
1006
+ container: {
1007
+ padding: PROMPT_PADDING,
1008
+ borderRadius: PROMPT_BORDER_RADIUS,
1009
+ borderWidth: PROMPT_BORDER_WIDTH
1010
+ },
1011
+ title: { fontSize: TITLE_FONT_SIZE, fontWeight: "700", marginBottom: TITLE_MARGIN_BOTTOM },
1012
+ message: { fontSize: MESSAGE_FONT_SIZE, marginBottom: MESSAGE_MARGIN_BOTTOM },
1013
+ cta: { paddingVertical: BUTTON_PADDING_V, borderRadius: BUTTON_BORDER_RADIUS, alignItems: "center", marginBottom: CTA_MARGIN_BOTTOM },
1014
+ ctaText: { fontSize: BUTTON_FONT_SIZE, fontWeight: "700" },
1015
+ dismiss: { alignItems: "center", paddingVertical: BUTTON_PADDING_V },
1016
+ dismissText: { fontSize: DISMISS_FONT_SIZE }
1017
+ });
1018
+ var UpgradePrompt = ({
1019
+ requiredTier,
1020
+ currentTier,
1021
+ onDismiss,
1022
+ billingRoute = DEFAULT_BILLING_ROUTE
1023
+ }) => {
1024
+ const { theme, t, navigate } = useUi();
1025
+ const colors = theme.colors;
1026
+ const primary = theme.palette.primary["500"];
1027
+ function handleUpgradePress() {
1028
+ if (typeof navigate === "function") navigate(billingRoute);
1029
+ }
1030
+ return /* @__PURE__ */ jsxs(
1031
+ View,
1032
+ {
1033
+ style: [styles9.container, { borderColor: primary, backgroundColor: colors.surface }],
1034
+ testID: LAYOUT_TEST_IDS.upgradePrompt,
1035
+ children: [
1036
+ /* @__PURE__ */ jsx(Text, { style: [styles9.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
1037
+ /* @__PURE__ */ jsx(Text, { style: [styles9.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
1038
+ /* @__PURE__ */ jsx(
1039
+ TouchableOpacity,
1040
+ {
1041
+ accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
1042
+ accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
1043
+ accessibilityRole: "button",
1044
+ style: [styles9.cta, { backgroundColor: primary }],
1045
+ testID: LAYOUT_TEST_IDS.upgradePromptCta,
1046
+ onPress: handleUpgradePress,
1047
+ children: /* @__PURE__ */ jsx(Text, { style: [styles9.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
1048
+ }
1049
+ ),
1050
+ onDismiss ? /* @__PURE__ */ jsx(
1051
+ TouchableOpacity,
1052
+ {
1053
+ accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
1054
+ accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
1055
+ accessibilityRole: "button",
1056
+ style: styles9.dismiss,
1057
+ testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
1058
+ onPress: onDismiss,
1059
+ children: /* @__PURE__ */ jsx(Text, { style: [styles9.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
1060
+ }
1061
+ ) : null
1062
+ ]
1063
+ }
1064
+ );
1065
+ };
954
1066
  var CLOSE_ICON_SIZE = 18;
955
1067
  var styles10 = StyleSheet.create({
956
1068
  container: {
@@ -976,7 +1088,7 @@ var ModalShell = ({
976
1088
  showClose = true
977
1089
  }) => {
978
1090
  const { theme, t } = useUi();
979
- const containerStyle = React8.useMemo(
1091
+ const containerStyle = React9.useMemo(
980
1092
  () => [styles10.container, { backgroundColor: theme.colors.background }, contentStyle],
981
1093
  [theme.colors.background, contentStyle]
982
1094
  );
@@ -1054,8 +1166,8 @@ var styles11 = StyleSheet.create({
1054
1166
  });
1055
1167
  function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
1056
1168
  const ids = new Set(defaultOpenIds ?? []);
1057
- React8.Children.forEach(children, (child) => {
1058
- if (!React8.isValidElement(child)) return;
1169
+ React9.Children.forEach(children, (child) => {
1170
+ if (!React9.isValidElement(child)) return;
1059
1171
  const props = child.props;
1060
1172
  if (props.defaultOpen === true && typeof props.id === "string") {
1061
1173
  ids.add(props.id);