@dloizides/ui-layout 1.2.0 → 1.4.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,5 +1,5 @@
1
- import React, { useMemo, useRef, useEffect, useState, useCallback } from 'react';
2
- import { StyleSheet, View, Text, TouchableOpacity, Platform, Modal, FlatList, ScrollView, useWindowDimensions } from 'react-native';
1
+ import React8, { createContext, useMemo, useRef, useEffect, useState, useCallback, useContext } from 'react';
2
+ import { StyleSheet, View, Text, Pressable, TouchableOpacity, Platform, Modal, FlatList, ScrollView, Animated, Easing, useWindowDimensions, LayoutAnimation, UIManager } from 'react-native';
3
3
  import { MODAL_OVERLAY_COLOR, useUi } from '@dloizides/ui-feedback';
4
4
  import { jsx, jsxs } from 'react/jsx-runtime';
5
5
  import { SvgIcon } from '@dloizides/ui-icons';
@@ -14,7 +14,7 @@ var styles = StyleSheet.create({
14
14
  });
15
15
  var Section = ({ children, style }) => {
16
16
  const { theme } = useUi();
17
- const containerStyle = React.useMemo(
17
+ const containerStyle = React8.useMemo(
18
18
  () => [styles.card, { borderColor: theme.colors.border, backgroundColor: theme.colors.surface }, style],
19
19
  [theme.colors.border, theme.colors.surface, style]
20
20
  );
@@ -29,7 +29,8 @@ var LAYOUT_TEST_IDS = {
29
29
  upgradePromptCta: "upgrade-prompt-cta",
30
30
  upgradePromptDismiss: "upgrade-prompt-dismiss",
31
31
  modalShell: "template-modal",
32
- modalShellClose: "cancel-button"
32
+ modalShellClose: "cancel-button",
33
+ accordion: "accordion"
33
34
  };
34
35
  var DEFAULT_BILLING_ROUTE = "/settings/billing";
35
36
  var styles2 = StyleSheet.create({
@@ -40,7 +41,7 @@ var styles2 = StyleSheet.create({
40
41
  });
41
42
  var Heading = ({ text, children }) => {
42
43
  const { theme } = useUi();
43
- const headingStyle = React.useMemo(
44
+ const headingStyle = React8.useMemo(
44
45
  () => [styles2.heading, { color: theme.colors.text }],
45
46
  [theme.colors.text]
46
47
  );
@@ -84,6 +85,93 @@ var StatusBadge = ({
84
85
  }
85
86
  );
86
87
  };
88
+ var TRACK_PADDING = 3;
89
+ var TRACK_RADIUS = 999;
90
+ var SEGMENT_RADIUS = 999;
91
+ var SEGMENT_PAD_H = 15;
92
+ var SEGMENT_PAD_V = 7;
93
+ var SEGMENT_FONT = 14;
94
+ var SEGMENT_WEIGHT = "600";
95
+ var BORDER_WIDTH = 1;
96
+ var SHADOW_COLOR = "#141e32";
97
+ var SHADOW_OPACITY = 0.1;
98
+ var SHADOW_RADIUS = 3;
99
+ var SHADOW_OFFSET = { width: 0, height: 1 };
100
+ var SHADOW_ELEVATION = 2;
101
+ var TRANSPARENT = "transparent";
102
+ var styles4 = StyleSheet.create({
103
+ track: {
104
+ flexDirection: "row",
105
+ alignSelf: "flex-start",
106
+ alignItems: "center",
107
+ gap: TRACK_PADDING + 1,
108
+ padding: TRACK_PADDING,
109
+ borderRadius: TRACK_RADIUS,
110
+ borderWidth: BORDER_WIDTH
111
+ },
112
+ segment: {
113
+ paddingHorizontal: SEGMENT_PAD_H,
114
+ paddingVertical: SEGMENT_PAD_V,
115
+ borderRadius: SEGMENT_RADIUS
116
+ },
117
+ segmentSelected: {
118
+ shadowColor: SHADOW_COLOR,
119
+ shadowOpacity: SHADOW_OPACITY,
120
+ shadowRadius: SHADOW_RADIUS,
121
+ shadowOffset: SHADOW_OFFSET,
122
+ elevation: SHADOW_ELEVATION
123
+ },
124
+ label: {
125
+ fontSize: SEGMENT_FONT,
126
+ fontWeight: SEGMENT_WEIGHT,
127
+ textAlign: "center"
128
+ }
129
+ });
130
+ function ariaSelectedProps(selected) {
131
+ return { "aria-selected": selected };
132
+ }
133
+ function SegmentedControl({
134
+ options,
135
+ value,
136
+ onChange,
137
+ accessibilityLabel,
138
+ style,
139
+ testID
140
+ }) {
141
+ const { theme } = useUi();
142
+ const { colors } = theme;
143
+ return /* @__PURE__ */ jsx(
144
+ View,
145
+ {
146
+ accessibilityRole: "tablist",
147
+ "aria-label": accessibilityLabel,
148
+ style: [styles4.track, { backgroundColor: colors.background, borderColor: colors.border }, style],
149
+ testID,
150
+ children: options.map((opt) => {
151
+ const selected = opt.value === value;
152
+ return /* @__PURE__ */ jsx(
153
+ Pressable,
154
+ {
155
+ accessibilityRole: "tab",
156
+ accessibilityState: { selected },
157
+ accessibilityLabel: opt.accessibilityLabel ?? opt.label,
158
+ accessibilityHint: opt.accessibilityHint,
159
+ onPress: () => onChange(opt.value),
160
+ style: [
161
+ styles4.segment,
162
+ selected ? styles4.segmentSelected : null,
163
+ { backgroundColor: selected ? colors.surface : TRANSPARENT }
164
+ ],
165
+ testID: opt.testID,
166
+ ...ariaSelectedProps(selected),
167
+ children: /* @__PURE__ */ jsx(Text, { style: [styles4.label, { color: selected ? colors.text : colors.textSecondary }], children: opt.label })
168
+ },
169
+ opt.value
170
+ );
171
+ })
172
+ }
173
+ );
174
+ }
87
175
  var PROMPT_PADDING = 20;
88
176
  var PROMPT_BORDER_RADIUS = 12;
89
177
  var PROMPT_BORDER_WIDTH = 1;
@@ -96,7 +184,7 @@ var DISMISS_FONT_SIZE = 13;
96
184
  var TITLE_MARGIN_BOTTOM = 8;
97
185
  var MESSAGE_MARGIN_BOTTOM = 16;
98
186
  var CTA_MARGIN_BOTTOM = 8;
99
- var styles4 = StyleSheet.create({
187
+ var styles5 = StyleSheet.create({
100
188
  container: {
101
189
  padding: PROMPT_PADDING,
102
190
  borderRadius: PROMPT_BORDER_RADIUS,
@@ -124,21 +212,21 @@ var UpgradePrompt = ({
124
212
  return /* @__PURE__ */ jsxs(
125
213
  View,
126
214
  {
127
- style: [styles4.container, { borderColor: primary, backgroundColor: colors.surface }],
215
+ style: [styles5.container, { borderColor: primary, backgroundColor: colors.surface }],
128
216
  testID: LAYOUT_TEST_IDS.upgradePrompt,
129
217
  children: [
130
- /* @__PURE__ */ jsx(Text, { style: [styles4.title, { color: colors.text }], children: t("settings.billing.upgradePrompt.title") }),
131
- /* @__PURE__ */ jsx(Text, { style: [styles4.message, { color: colors.textSecondary }], children: t("settings.billing.upgradePrompt.message", requiredTier, currentTier) }),
218
+ /* @__PURE__ */ jsx(Text, { style: [styles5.title, { color: colors.text }], children: t("settings.billing.upgradePrompt.title") }),
219
+ /* @__PURE__ */ jsx(Text, { style: [styles5.message, { color: colors.textSecondary }], children: t("settings.billing.upgradePrompt.message", requiredTier, currentTier) }),
132
220
  /* @__PURE__ */ jsx(
133
221
  TouchableOpacity,
134
222
  {
135
223
  accessibilityHint: t("settings.billing.upgradePrompt.ctaHint"),
136
224
  accessibilityLabel: t("settings.billing.upgradePrompt.cta"),
137
225
  accessibilityRole: "button",
138
- style: [styles4.cta, { backgroundColor: primary }],
226
+ style: [styles5.cta, { backgroundColor: primary }],
139
227
  testID: LAYOUT_TEST_IDS.upgradePromptCta,
140
228
  onPress: handleUpgradePress,
141
- children: /* @__PURE__ */ jsx(Text, { style: [styles4.ctaText, { color: colors.surface }], children: t("settings.billing.upgradePrompt.cta") })
229
+ children: /* @__PURE__ */ jsx(Text, { style: [styles5.ctaText, { color: colors.surface }], children: t("settings.billing.upgradePrompt.cta") })
142
230
  }
143
231
  ),
144
232
  onDismiss ? /* @__PURE__ */ jsx(
@@ -147,10 +235,10 @@ var UpgradePrompt = ({
147
235
  accessibilityHint: t("settings.billing.upgradePrompt.dismissHint"),
148
236
  accessibilityLabel: t("settings.billing.upgradePrompt.dismiss"),
149
237
  accessibilityRole: "button",
150
- style: styles4.dismiss,
238
+ style: styles5.dismiss,
151
239
  testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
152
240
  onPress: onDismiss,
153
- children: /* @__PURE__ */ jsx(Text, { style: [styles4.dismissText, { color: colors.textSecondary }], children: t("settings.billing.upgradePrompt.dismiss") })
241
+ children: /* @__PURE__ */ jsx(Text, { style: [styles5.dismissText, { color: colors.textSecondary }], children: t("settings.billing.upgradePrompt.dismiss") })
154
242
  }
155
243
  ) : null
156
244
  ]
@@ -222,7 +310,7 @@ var BODY_FONT_SIZE = 14;
222
310
  var SELECTED_FONT_WEIGHT = "600";
223
311
  var OPTION_PADDING_H = 16;
224
312
  var OPTION_PADDING_V = 12;
225
- var styles5 = StyleSheet.create({
313
+ var styles6 = StyleSheet.create({
226
314
  option: {
227
315
  paddingHorizontal: OPTION_PADDING_H,
228
316
  paddingVertical: OPTION_PADDING_V,
@@ -244,8 +332,8 @@ var OptionRow = ({
244
332
  onSelect();
245
333
  }, [onSelect]);
246
334
  const isActive = isSelected || isHighlighted;
247
- const rowStyle = [styles5.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
248
- const textStyle = [styles5.optionText, { color: colors.text }, isSelected ? styles5.selectedText : null];
335
+ const rowStyle = [styles6.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
336
+ const textStyle = [styles6.optionText, { color: colors.text }, isSelected ? styles6.selectedText : null];
249
337
  return /* @__PURE__ */ jsx(
250
338
  TouchableOpacity,
251
339
  {
@@ -317,14 +405,14 @@ function useMenuKeyboard(params) {
317
405
  }, [containerRef, enabled, onClose, params]);
318
406
  }
319
407
  var BORDER_RADIUS = 8;
320
- var BORDER_WIDTH = 1;
408
+ var BORDER_WIDTH2 = 1;
321
409
  var MENU_PADDING = 4;
322
410
  var MENU_MAX_HEIGHT = 300;
323
411
  var MENU_TOP_GAP = 4;
324
412
  var MENU_Z_INDEX = 1e3;
325
413
  var MENU_ELEVATION = 8;
326
414
  var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
327
- var styles6 = StyleSheet.create({
415
+ var styles7 = StyleSheet.create({
328
416
  popover: {
329
417
  position: "absolute",
330
418
  top: "100%",
@@ -332,7 +420,7 @@ var styles6 = StyleSheet.create({
332
420
  right: 0,
333
421
  marginTop: MENU_TOP_GAP,
334
422
  zIndex: MENU_Z_INDEX,
335
- borderWidth: BORDER_WIDTH,
423
+ borderWidth: BORDER_WIDTH2,
336
424
  borderRadius: BORDER_RADIUS,
337
425
  padding: MENU_PADDING,
338
426
  maxHeight: MENU_MAX_HEIGHT,
@@ -378,7 +466,7 @@ var InlineMenu = ({
378
466
  onClose
379
467
  });
380
468
  const popoverStyle = useMemo(
381
- () => [styles6.popover, { borderColor: colors.border, backgroundColor: colors.surface }],
469
+ () => [styles7.popover, { borderColor: colors.border, backgroundColor: colors.surface }],
382
470
  [colors.border, colors.surface]
383
471
  );
384
472
  return /* @__PURE__ */ jsx(
@@ -414,17 +502,17 @@ function useResolvedDropdownVariant(explicit) {
414
502
  return resolveDropdownVariant(explicit, width, Platform.OS);
415
503
  }
416
504
  var BORDER_RADIUS2 = 8;
417
- var BORDER_WIDTH2 = 1;
505
+ var BORDER_WIDTH3 = 1;
418
506
  var BODY_FONT_SIZE2 = 14;
419
507
  var MODAL_PADDING = 8;
420
508
  var MODAL_MIN_WIDTH = 200;
421
509
  var MODAL_MAX_HEIGHT = 300;
422
510
  var CONTAINER_PADDING_H = 12;
423
511
  var CONTAINER_PADDING_V = 10;
424
- var styles7 = StyleSheet.create({
512
+ var styles8 = StyleSheet.create({
425
513
  anchor: { position: "relative" },
426
514
  container: {
427
- borderWidth: BORDER_WIDTH2,
515
+ borderWidth: BORDER_WIDTH3,
428
516
  borderRadius: BORDER_RADIUS2,
429
517
  paddingHorizontal: CONTAINER_PADDING_H,
430
518
  paddingVertical: CONTAINER_PADDING_V
@@ -478,11 +566,11 @@ var ModalDropdown = ({
478
566
  [onChange]
479
567
  );
480
568
  const containerStyle = useMemo(
481
- () => [styles7.container, { borderColor: colors.border, backgroundColor: colors.surface }],
569
+ () => [styles8.container, { borderColor: colors.border, backgroundColor: colors.surface }],
482
570
  [colors.border, colors.surface]
483
571
  );
484
572
  const modalContentStyle = useMemo(
485
- () => [styles7.modalContent, { backgroundColor: colors.surface }],
573
+ () => [styles8.modalContent, { backgroundColor: colors.surface }],
486
574
  [colors.surface]
487
575
  );
488
576
  const renderModalOption = useCallback(
@@ -498,7 +586,7 @@ var ModalDropdown = ({
498
586
  [handleSelect, testID, value]
499
587
  );
500
588
  const keyExtractor = useCallback((item) => String(item.value), []);
501
- return /* @__PURE__ */ jsxs(View, { ref: anchorRef, style: styles7.anchor, children: [
589
+ return /* @__PURE__ */ jsxs(View, { ref: anchorRef, style: styles8.anchor, children: [
502
590
  /* @__PURE__ */ jsx(
503
591
  TouchableOpacity,
504
592
  {
@@ -510,7 +598,7 @@ var ModalDropdown = ({
510
598
  style: containerStyle,
511
599
  testID,
512
600
  onPress: handleToggle,
513
- children: /* @__PURE__ */ jsx(Text, { style: [styles7.selectedText, { color: colors.text }], children: selectedLabel })
601
+ children: /* @__PURE__ */ jsx(Text, { style: [styles8.selectedText, { color: colors.text }], children: selectedLabel })
514
602
  }
515
603
  ),
516
604
  isMenu && isOpen ? /* @__PURE__ */ jsx(
@@ -533,7 +621,7 @@ var ModalDropdown = ({
533
621
  accessibilityLabel: t("common.dismissDropdown"),
534
622
  accessibilityRole: "button",
535
623
  activeOpacity: 1,
536
- style: styles7.modalOverlay,
624
+ style: styles8.modalOverlay,
537
625
  testID: `${testID}-backdrop`,
538
626
  onPress: handleClose,
539
627
  children: /* @__PURE__ */ jsx(
@@ -552,7 +640,7 @@ var ModalDropdown = ({
552
640
  ] });
553
641
  };
554
642
  var CLOSE_ICON_SIZE = 18;
555
- var styles8 = StyleSheet.create({
643
+ var styles9 = StyleSheet.create({
556
644
  container: {
557
645
  flex: 1,
558
646
  padding: 16
@@ -576,8 +664,8 @@ var ModalShell = ({
576
664
  showClose = true
577
665
  }) => {
578
666
  const { theme, t } = useUi();
579
- const containerStyle = React.useMemo(
580
- () => [styles8.container, { backgroundColor: theme.colors.background }, contentStyle],
667
+ const containerStyle = React8.useMemo(
668
+ () => [styles9.container, { backgroundColor: theme.colors.background }, contentStyle],
581
669
  [theme.colors.background, contentStyle]
582
670
  );
583
671
  const closeA11yLabel = t("quizTemplates.cancel");
@@ -597,7 +685,7 @@ var ModalShell = ({
597
685
  role: "dialog",
598
686
  style: containerStyle,
599
687
  children: [
600
- /* @__PURE__ */ jsxs(View, { style: styles8.headerRow, children: [
688
+ /* @__PURE__ */ jsxs(View, { style: styles9.headerRow, children: [
601
689
  /* @__PURE__ */ jsx(Heading, { children: title ?? t("close") }),
602
690
  showClose ? /* @__PURE__ */ jsx(
603
691
  TouchableOpacity,
@@ -605,7 +693,7 @@ var ModalShell = ({
605
693
  accessibilityHint: t("common.closeDialogHint"),
606
694
  accessibilityLabel: closeA11yLabel,
607
695
  accessibilityRole: "button",
608
- style: styles8.closeButton,
696
+ style: styles9.closeButton,
609
697
  testID: LAYOUT_TEST_IDS.modalShellClose,
610
698
  onPress: onCancel,
611
699
  children: /* @__PURE__ */ jsx(SvgIcon, { color: theme.colors.textSecondary, name: "close", size: CLOSE_ICON_SIZE })
@@ -619,7 +707,210 @@ var ModalShell = ({
619
707
  }
620
708
  );
621
709
  };
710
+ var AccordionContext = createContext(null);
711
+ function useAccordionContext() {
712
+ const value = useContext(AccordionContext);
713
+ if (value === null) {
714
+ throw new Error("AccordionItem must be rendered inside an <Accordion>.");
715
+ }
716
+ return value;
717
+ }
718
+ var androidEnabled = false;
719
+ function enableAndroidLayoutAnimationOnce() {
720
+ if (androidEnabled) return;
721
+ androidEnabled = true;
722
+ const isAndroid = Platform.OS === "android";
723
+ const setter = UIManager.setLayoutAnimationEnabledExperimental;
724
+ if (isAndroid && typeof setter === "function") {
725
+ setter(true);
726
+ }
727
+ }
728
+ function animateNextLayout() {
729
+ enableAndroidLayoutAnimationOnce();
730
+ const configure = LayoutAnimation.configureNext;
731
+ if (typeof configure !== "function") return;
732
+ try {
733
+ configure(LayoutAnimation.Presets.easeInEaseOut);
734
+ } catch {
735
+ }
736
+ }
737
+ var styles10 = StyleSheet.create({
738
+ container: { alignSelf: "stretch" }
739
+ });
740
+ function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
741
+ const ids = new Set(defaultOpenIds ?? []);
742
+ React8.Children.forEach(children, (child) => {
743
+ if (!React8.isValidElement(child)) return;
744
+ const props = child.props;
745
+ if (props.defaultOpen === true && typeof props.id === "string") {
746
+ ids.add(props.id);
747
+ }
748
+ });
749
+ if (!allowMultiple && ids.size > 1) {
750
+ const first = ids.values().next().value;
751
+ return new Set(first === void 0 ? [] : [first]);
752
+ }
753
+ return ids;
754
+ }
755
+ var Accordion = ({
756
+ children,
757
+ openIds,
758
+ defaultOpenIds,
759
+ onOpenChange,
760
+ allowMultiple = true,
761
+ testID = "accordion",
762
+ style
763
+ }) => {
764
+ const isControlled = openIds !== void 0;
765
+ const [internalOpen, setInternalOpen] = useState(
766
+ () => computeInitialOpen(children, defaultOpenIds, allowMultiple)
767
+ );
768
+ const openSet = useMemo(
769
+ () => isControlled ? new Set(openIds) : internalOpen,
770
+ [isControlled, openIds, internalOpen]
771
+ );
772
+ const toggle = useCallback(
773
+ (id) => {
774
+ animateNextLayout();
775
+ const next = new Set(openSet);
776
+ const willOpen = !next.has(id);
777
+ if (!allowMultiple) next.clear();
778
+ if (willOpen) {
779
+ next.add(id);
780
+ } else {
781
+ next.delete(id);
782
+ }
783
+ if (!isControlled) setInternalOpen(next);
784
+ if (onOpenChange !== void 0) onOpenChange(Array.from(next));
785
+ },
786
+ [allowMultiple, isControlled, onOpenChange, openSet]
787
+ );
788
+ const contextValue = useMemo(
789
+ () => ({ openIds: openSet, toggle, allowMultiple }),
790
+ [openSet, toggle, allowMultiple]
791
+ );
792
+ const containerStyle = useMemo(
793
+ () => style === void 0 ? [styles10.container] : [styles10.container, ...Array.isArray(style) ? style : [style]],
794
+ [style]
795
+ );
796
+ return /* @__PURE__ */ jsx(AccordionContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(View, { style: containerStyle, testID, children }) });
797
+ };
798
+ var HEADER_PADDING_H = 16;
799
+ var HEADER_PADDING_V = 12;
800
+ var BODY_PADDING_H = 16;
801
+ var BODY_PADDING_V = 12;
802
+ var HEADER_GAP = 8;
803
+ var TITLE_FONT_SIZE2 = 15;
804
+ var TITLE_FONT_WEIGHT = "600";
805
+ var CHEVRON_SIZE = 18;
806
+ var ROTATE_DURATION_MS = 160;
807
+ var ROTATE_COLLAPSED = 0;
808
+ var ROTATE_EXPANDED = 1;
809
+ var COLLAPSED_DEG = "0deg";
810
+ var EXPANDED_DEG = "180deg";
811
+ var DISABLED_OPACITY = 0.5;
812
+ var FULL_OPACITY = 1;
813
+ var ROLE_REGION = "region";
814
+ var styles11 = StyleSheet.create({
815
+ item: { borderTopWidth: StyleSheet.hairlineWidth },
816
+ header: {
817
+ flexDirection: "row",
818
+ alignItems: "center",
819
+ justifyContent: "space-between",
820
+ paddingHorizontal: HEADER_PADDING_H,
821
+ paddingVertical: HEADER_PADDING_V
822
+ },
823
+ headerLeft: { flexShrink: 1, flexGrow: 1 },
824
+ headerRight: { flexDirection: "row", alignItems: "center", marginLeft: HEADER_GAP },
825
+ title: { fontSize: TITLE_FONT_SIZE2, fontWeight: TITLE_FONT_WEIGHT },
826
+ chevron: { marginLeft: HEADER_GAP },
827
+ body: { paddingHorizontal: BODY_PADDING_H, paddingBottom: BODY_PADDING_V }
828
+ });
829
+ var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
830
+ var AccordionItem = ({
831
+ id,
832
+ title,
833
+ right,
834
+ children,
835
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- read by the container's initial-open scan, not here
836
+ defaultOpen: _defaultOpen,
837
+ disabled = false,
838
+ testID,
839
+ accessibilityLabel,
840
+ accessibilityHint
841
+ }) => {
842
+ const { theme, t } = useUi();
843
+ const { colors } = theme;
844
+ const { openIds, toggle } = useAccordionContext();
845
+ const expanded = openIds.has(id);
846
+ const headerTestID = testID ?? `accordion-item-${id}`;
847
+ const bodyTestID = `${headerTestID}-body`;
848
+ const chevronTestID = `${headerTestID}-chevron`;
849
+ const [rotation] = useState(() => new Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
850
+ useEffect(() => {
851
+ Animated.timing(rotation, {
852
+ toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
853
+ duration: ROTATE_DURATION_MS,
854
+ easing: Easing.out(Easing.ease),
855
+ useNativeDriver: Platform.OS !== "web"
856
+ }).start();
857
+ }, [expanded, rotation]);
858
+ const rotate = rotation.interpolate({
859
+ inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
860
+ outputRange: [COLLAPSED_DEG, EXPANDED_DEG]
861
+ });
862
+ const handlePress = useCallback(() => {
863
+ if (!disabled) toggle(id);
864
+ }, [disabled, id, toggle]);
865
+ const handleKeyDown2 = useCallback(
866
+ (event) => {
867
+ if (disabled) return;
868
+ const key = event.key ?? "";
869
+ const isActivation = ACTIVATION_KEYS.includes(key);
870
+ if (!isActivation) return;
871
+ if (typeof event.preventDefault === "function") event.preventDefault();
872
+ toggle(id);
873
+ },
874
+ [disabled, id, toggle]
875
+ );
876
+ const keyboardProps = Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
877
+ const itemStyle = useMemo(
878
+ () => [styles11.item, { borderTopColor: colors.border }],
879
+ [colors.border]
880
+ );
881
+ const headerStyle = useMemo(
882
+ () => [styles11.header, { opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }],
883
+ [disabled]
884
+ );
885
+ const resolvedLabel = accessibilityLabel ?? (typeof title === "string" ? title : void 0);
886
+ return /* @__PURE__ */ jsxs(View, { style: itemStyle, children: [
887
+ /* @__PURE__ */ jsxs(
888
+ Pressable,
889
+ {
890
+ accessibilityHint: accessibilityHint ?? t("common.accordionToggleHint"),
891
+ accessibilityLabel: resolvedLabel,
892
+ accessibilityRole: "button",
893
+ accessibilityState: { expanded, disabled },
894
+ "aria-controls": bodyTestID,
895
+ "aria-expanded": expanded,
896
+ disabled,
897
+ style: headerStyle,
898
+ testID: headerTestID,
899
+ onPress: handlePress,
900
+ ...keyboardProps,
901
+ children: [
902
+ /* @__PURE__ */ jsx(View, { style: styles11.headerLeft, children: typeof title === "string" ? /* @__PURE__ */ jsx(Text, { style: [styles11.title, { color: colors.text }], children: title }) : title }),
903
+ /* @__PURE__ */ jsxs(View, { style: styles11.headerRight, children: [
904
+ right,
905
+ /* @__PURE__ */ jsx(Animated.View, { style: [styles11.chevron, { transform: [{ rotate }] }], children: /* @__PURE__ */ jsx(SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID }) })
906
+ ] })
907
+ ]
908
+ }
909
+ ),
910
+ expanded ? /* @__PURE__ */ jsx(View, { accessibilityLabel: resolvedLabel, nativeID: bodyTestID, role: ROLE_REGION, style: styles11.body, testID: bodyTestID, children }) : null
911
+ ] });
912
+ };
622
913
 
623
- export { DEFAULT_BILLING_ROUTE, DropdownVariant, Heading, LAYOUT_TEST_IDS, ModalDropdown, ModalShell, Section, StatusBadge, UpgradePrompt, useFocusTrap };
914
+ export { Accordion, AccordionItem, DEFAULT_BILLING_ROUTE, DropdownVariant, Heading, LAYOUT_TEST_IDS, ModalDropdown, ModalShell, Section, SegmentedControl, StatusBadge, UpgradePrompt, useFocusTrap };
624
915
  //# sourceMappingURL=index.mjs.map
625
916
  //# sourceMappingURL=index.mjs.map