@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/CHANGELOG.md +38 -0
- package/README.md +54 -0
- package/dist/index.d.mts +99 -1
- package/dist/index.d.ts +99 -1
- package/dist/index.js +349 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +325 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React8 = require('react');
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
var uiFeedback = require('@dloizides/ui-feedback');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -8,7 +8,7 @@ var uiIcons = require('@dloizides/ui-icons');
|
|
|
8
8
|
|
|
9
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var React8__default = /*#__PURE__*/_interopDefault(React8);
|
|
12
12
|
|
|
13
13
|
// src/Section/Section.tsx
|
|
14
14
|
var styles = reactNative.StyleSheet.create({
|
|
@@ -20,7 +20,7 @@ var styles = reactNative.StyleSheet.create({
|
|
|
20
20
|
});
|
|
21
21
|
var Section = ({ children, style }) => {
|
|
22
22
|
const { theme } = uiFeedback.useUi();
|
|
23
|
-
const containerStyle =
|
|
23
|
+
const containerStyle = React8__default.default.useMemo(
|
|
24
24
|
() => [styles.card, { borderColor: theme.colors.border, backgroundColor: theme.colors.surface }, style],
|
|
25
25
|
[theme.colors.border, theme.colors.surface, style]
|
|
26
26
|
);
|
|
@@ -35,7 +35,8 @@ var LAYOUT_TEST_IDS = {
|
|
|
35
35
|
upgradePromptCta: "upgrade-prompt-cta",
|
|
36
36
|
upgradePromptDismiss: "upgrade-prompt-dismiss",
|
|
37
37
|
modalShell: "template-modal",
|
|
38
|
-
modalShellClose: "cancel-button"
|
|
38
|
+
modalShellClose: "cancel-button",
|
|
39
|
+
accordion: "accordion"
|
|
39
40
|
};
|
|
40
41
|
var DEFAULT_BILLING_ROUTE = "/settings/billing";
|
|
41
42
|
var styles2 = reactNative.StyleSheet.create({
|
|
@@ -46,7 +47,7 @@ var styles2 = reactNative.StyleSheet.create({
|
|
|
46
47
|
});
|
|
47
48
|
var Heading = ({ text, children }) => {
|
|
48
49
|
const { theme } = uiFeedback.useUi();
|
|
49
|
-
const headingStyle =
|
|
50
|
+
const headingStyle = React8__default.default.useMemo(
|
|
50
51
|
() => [styles2.heading, { color: theme.colors.text }],
|
|
51
52
|
[theme.colors.text]
|
|
52
53
|
);
|
|
@@ -77,8 +78,8 @@ var StatusBadge = ({
|
|
|
77
78
|
accessibilityHint
|
|
78
79
|
}) => {
|
|
79
80
|
const { t } = uiFeedback.useUi();
|
|
80
|
-
const dynamicBadge =
|
|
81
|
-
const dynamicText =
|
|
81
|
+
const dynamicBadge = React8.useMemo(() => ({ backgroundColor }), [backgroundColor]);
|
|
82
|
+
const dynamicText = React8.useMemo(() => ({ color }), [color]);
|
|
82
83
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
83
84
|
reactNative.View,
|
|
84
85
|
{
|
|
@@ -90,6 +91,93 @@ var StatusBadge = ({
|
|
|
90
91
|
}
|
|
91
92
|
);
|
|
92
93
|
};
|
|
94
|
+
var TRACK_PADDING = 3;
|
|
95
|
+
var TRACK_RADIUS = 999;
|
|
96
|
+
var SEGMENT_RADIUS = 999;
|
|
97
|
+
var SEGMENT_PAD_H = 15;
|
|
98
|
+
var SEGMENT_PAD_V = 7;
|
|
99
|
+
var SEGMENT_FONT = 14;
|
|
100
|
+
var SEGMENT_WEIGHT = "600";
|
|
101
|
+
var BORDER_WIDTH = 1;
|
|
102
|
+
var SHADOW_COLOR = "#141e32";
|
|
103
|
+
var SHADOW_OPACITY = 0.1;
|
|
104
|
+
var SHADOW_RADIUS = 3;
|
|
105
|
+
var SHADOW_OFFSET = { width: 0, height: 1 };
|
|
106
|
+
var SHADOW_ELEVATION = 2;
|
|
107
|
+
var TRANSPARENT = "transparent";
|
|
108
|
+
var styles4 = reactNative.StyleSheet.create({
|
|
109
|
+
track: {
|
|
110
|
+
flexDirection: "row",
|
|
111
|
+
alignSelf: "flex-start",
|
|
112
|
+
alignItems: "center",
|
|
113
|
+
gap: TRACK_PADDING + 1,
|
|
114
|
+
padding: TRACK_PADDING,
|
|
115
|
+
borderRadius: TRACK_RADIUS,
|
|
116
|
+
borderWidth: BORDER_WIDTH
|
|
117
|
+
},
|
|
118
|
+
segment: {
|
|
119
|
+
paddingHorizontal: SEGMENT_PAD_H,
|
|
120
|
+
paddingVertical: SEGMENT_PAD_V,
|
|
121
|
+
borderRadius: SEGMENT_RADIUS
|
|
122
|
+
},
|
|
123
|
+
segmentSelected: {
|
|
124
|
+
shadowColor: SHADOW_COLOR,
|
|
125
|
+
shadowOpacity: SHADOW_OPACITY,
|
|
126
|
+
shadowRadius: SHADOW_RADIUS,
|
|
127
|
+
shadowOffset: SHADOW_OFFSET,
|
|
128
|
+
elevation: SHADOW_ELEVATION
|
|
129
|
+
},
|
|
130
|
+
label: {
|
|
131
|
+
fontSize: SEGMENT_FONT,
|
|
132
|
+
fontWeight: SEGMENT_WEIGHT,
|
|
133
|
+
textAlign: "center"
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
function ariaSelectedProps(selected) {
|
|
137
|
+
return { "aria-selected": selected };
|
|
138
|
+
}
|
|
139
|
+
function SegmentedControl({
|
|
140
|
+
options,
|
|
141
|
+
value,
|
|
142
|
+
onChange,
|
|
143
|
+
accessibilityLabel,
|
|
144
|
+
style,
|
|
145
|
+
testID
|
|
146
|
+
}) {
|
|
147
|
+
const { theme } = uiFeedback.useUi();
|
|
148
|
+
const { colors } = theme;
|
|
149
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
150
|
+
reactNative.View,
|
|
151
|
+
{
|
|
152
|
+
accessibilityRole: "tablist",
|
|
153
|
+
"aria-label": accessibilityLabel,
|
|
154
|
+
style: [styles4.track, { backgroundColor: colors.background, borderColor: colors.border }, style],
|
|
155
|
+
testID,
|
|
156
|
+
children: options.map((opt) => {
|
|
157
|
+
const selected = opt.value === value;
|
|
158
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
159
|
+
reactNative.Pressable,
|
|
160
|
+
{
|
|
161
|
+
accessibilityRole: "tab",
|
|
162
|
+
accessibilityState: { selected },
|
|
163
|
+
accessibilityLabel: opt.accessibilityLabel ?? opt.label,
|
|
164
|
+
accessibilityHint: opt.accessibilityHint,
|
|
165
|
+
onPress: () => onChange(opt.value),
|
|
166
|
+
style: [
|
|
167
|
+
styles4.segment,
|
|
168
|
+
selected ? styles4.segmentSelected : null,
|
|
169
|
+
{ backgroundColor: selected ? colors.surface : TRANSPARENT }
|
|
170
|
+
],
|
|
171
|
+
testID: opt.testID,
|
|
172
|
+
...ariaSelectedProps(selected),
|
|
173
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles4.label, { color: selected ? colors.text : colors.textSecondary }], children: opt.label })
|
|
174
|
+
},
|
|
175
|
+
opt.value
|
|
176
|
+
);
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
}
|
|
93
181
|
var PROMPT_PADDING = 20;
|
|
94
182
|
var PROMPT_BORDER_RADIUS = 12;
|
|
95
183
|
var PROMPT_BORDER_WIDTH = 1;
|
|
@@ -102,7 +190,7 @@ var DISMISS_FONT_SIZE = 13;
|
|
|
102
190
|
var TITLE_MARGIN_BOTTOM = 8;
|
|
103
191
|
var MESSAGE_MARGIN_BOTTOM = 16;
|
|
104
192
|
var CTA_MARGIN_BOTTOM = 8;
|
|
105
|
-
var
|
|
193
|
+
var styles5 = reactNative.StyleSheet.create({
|
|
106
194
|
container: {
|
|
107
195
|
padding: PROMPT_PADDING,
|
|
108
196
|
borderRadius: PROMPT_BORDER_RADIUS,
|
|
@@ -130,21 +218,21 @@ var UpgradePrompt = ({
|
|
|
130
218
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
131
219
|
reactNative.View,
|
|
132
220
|
{
|
|
133
|
-
style: [
|
|
221
|
+
style: [styles5.container, { borderColor: primary, backgroundColor: colors.surface }],
|
|
134
222
|
testID: LAYOUT_TEST_IDS.upgradePrompt,
|
|
135
223
|
children: [
|
|
136
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
137
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
224
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.title, { color: colors.text }], children: t("settings.billing.upgradePrompt.title") }),
|
|
225
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.message, { color: colors.textSecondary }], children: t("settings.billing.upgradePrompt.message", requiredTier, currentTier) }),
|
|
138
226
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
139
227
|
reactNative.TouchableOpacity,
|
|
140
228
|
{
|
|
141
229
|
accessibilityHint: t("settings.billing.upgradePrompt.ctaHint"),
|
|
142
230
|
accessibilityLabel: t("settings.billing.upgradePrompt.cta"),
|
|
143
231
|
accessibilityRole: "button",
|
|
144
|
-
style: [
|
|
232
|
+
style: [styles5.cta, { backgroundColor: primary }],
|
|
145
233
|
testID: LAYOUT_TEST_IDS.upgradePromptCta,
|
|
146
234
|
onPress: handleUpgradePress,
|
|
147
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
235
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.ctaText, { color: colors.surface }], children: t("settings.billing.upgradePrompt.cta") })
|
|
148
236
|
}
|
|
149
237
|
),
|
|
150
238
|
onDismiss ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -153,10 +241,10 @@ var UpgradePrompt = ({
|
|
|
153
241
|
accessibilityHint: t("settings.billing.upgradePrompt.dismissHint"),
|
|
154
242
|
accessibilityLabel: t("settings.billing.upgradePrompt.dismiss"),
|
|
155
243
|
accessibilityRole: "button",
|
|
156
|
-
style:
|
|
244
|
+
style: styles5.dismiss,
|
|
157
245
|
testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
|
|
158
246
|
onPress: onDismiss,
|
|
159
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
247
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.dismissText, { color: colors.textSecondary }], children: t("settings.billing.upgradePrompt.dismiss") })
|
|
160
248
|
}
|
|
161
249
|
) : null
|
|
162
250
|
]
|
|
@@ -200,8 +288,8 @@ function handleKeyDown(domNode, event) {
|
|
|
200
288
|
}
|
|
201
289
|
}
|
|
202
290
|
function useFocusTrap(containerRef, enabled) {
|
|
203
|
-
const previousFocusRef =
|
|
204
|
-
|
|
291
|
+
const previousFocusRef = React8.useRef(null);
|
|
292
|
+
React8.useEffect(() => {
|
|
205
293
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
206
294
|
const domNode = containerRef.current;
|
|
207
295
|
if (!domNode) return;
|
|
@@ -228,7 +316,7 @@ var BODY_FONT_SIZE = 14;
|
|
|
228
316
|
var SELECTED_FONT_WEIGHT = "600";
|
|
229
317
|
var OPTION_PADDING_H = 16;
|
|
230
318
|
var OPTION_PADDING_V = 12;
|
|
231
|
-
var
|
|
319
|
+
var styles6 = reactNative.StyleSheet.create({
|
|
232
320
|
option: {
|
|
233
321
|
paddingHorizontal: OPTION_PADDING_H,
|
|
234
322
|
paddingVertical: OPTION_PADDING_V,
|
|
@@ -246,12 +334,12 @@ var OptionRow = ({
|
|
|
246
334
|
}) => {
|
|
247
335
|
const { theme, t } = uiFeedback.useUi();
|
|
248
336
|
const { colors } = theme;
|
|
249
|
-
const handlePress =
|
|
337
|
+
const handlePress = React8.useCallback(() => {
|
|
250
338
|
onSelect();
|
|
251
339
|
}, [onSelect]);
|
|
252
340
|
const isActive = isSelected || isHighlighted;
|
|
253
|
-
const rowStyle = [
|
|
254
|
-
const textStyle = [
|
|
341
|
+
const rowStyle = [styles6.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
|
|
342
|
+
const textStyle = [styles6.optionText, { color: colors.text }, isSelected ? styles6.selectedText : null];
|
|
255
343
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
256
344
|
reactNative.TouchableOpacity,
|
|
257
345
|
{
|
|
@@ -305,7 +393,7 @@ function buildKeyHandler(params) {
|
|
|
305
393
|
}
|
|
306
394
|
function useMenuKeyboard(params) {
|
|
307
395
|
const { containerRef, enabled, onClose } = params;
|
|
308
|
-
|
|
396
|
+
React8.useEffect(() => {
|
|
309
397
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
310
398
|
const onKeyDown = buildKeyHandler(params);
|
|
311
399
|
const onMouseDown = (event) => {
|
|
@@ -323,14 +411,14 @@ function useMenuKeyboard(params) {
|
|
|
323
411
|
}, [containerRef, enabled, onClose, params]);
|
|
324
412
|
}
|
|
325
413
|
var BORDER_RADIUS = 8;
|
|
326
|
-
var
|
|
414
|
+
var BORDER_WIDTH2 = 1;
|
|
327
415
|
var MENU_PADDING = 4;
|
|
328
416
|
var MENU_MAX_HEIGHT = 300;
|
|
329
417
|
var MENU_TOP_GAP = 4;
|
|
330
418
|
var MENU_Z_INDEX = 1e3;
|
|
331
419
|
var MENU_ELEVATION = 8;
|
|
332
420
|
var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
|
|
333
|
-
var
|
|
421
|
+
var styles7 = reactNative.StyleSheet.create({
|
|
334
422
|
popover: {
|
|
335
423
|
position: "absolute",
|
|
336
424
|
top: "100%",
|
|
@@ -338,7 +426,7 @@ var styles6 = reactNative.StyleSheet.create({
|
|
|
338
426
|
right: 0,
|
|
339
427
|
marginTop: MENU_TOP_GAP,
|
|
340
428
|
zIndex: MENU_Z_INDEX,
|
|
341
|
-
borderWidth:
|
|
429
|
+
borderWidth: BORDER_WIDTH2,
|
|
342
430
|
borderRadius: BORDER_RADIUS,
|
|
343
431
|
padding: MENU_PADDING,
|
|
344
432
|
maxHeight: MENU_MAX_HEIGHT,
|
|
@@ -357,19 +445,19 @@ var InlineMenu = ({
|
|
|
357
445
|
}) => {
|
|
358
446
|
const { theme } = uiFeedback.useUi();
|
|
359
447
|
const { colors } = theme;
|
|
360
|
-
const selectedIndex =
|
|
448
|
+
const selectedIndex = React8.useMemo(
|
|
361
449
|
() => Math.max(0, options.findIndex((opt) => opt.value === value)),
|
|
362
450
|
[options, value]
|
|
363
451
|
);
|
|
364
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
365
|
-
const selectAt =
|
|
452
|
+
const [highlightedIndex, setHighlightedIndex] = React8.useState(() => selectedIndex);
|
|
453
|
+
const selectAt = React8.useCallback(
|
|
366
454
|
(index) => {
|
|
367
455
|
const option = options[index];
|
|
368
456
|
if (option !== void 0) onSelect(option.value);
|
|
369
457
|
},
|
|
370
458
|
[options, onSelect]
|
|
371
459
|
);
|
|
372
|
-
const selectHighlighted =
|
|
460
|
+
const selectHighlighted = React8.useCallback(
|
|
373
461
|
() => {
|
|
374
462
|
selectAt(highlightedIndex);
|
|
375
463
|
},
|
|
@@ -383,8 +471,8 @@ var InlineMenu = ({
|
|
|
383
471
|
onSelectHighlighted: selectHighlighted,
|
|
384
472
|
onClose
|
|
385
473
|
});
|
|
386
|
-
const popoverStyle =
|
|
387
|
-
() => [
|
|
474
|
+
const popoverStyle = React8.useMemo(
|
|
475
|
+
() => [styles7.popover, { borderColor: colors.border, backgroundColor: colors.surface }],
|
|
388
476
|
[colors.border, colors.surface]
|
|
389
477
|
);
|
|
390
478
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -420,17 +508,17 @@ function useResolvedDropdownVariant(explicit) {
|
|
|
420
508
|
return resolveDropdownVariant(explicit, width, reactNative.Platform.OS);
|
|
421
509
|
}
|
|
422
510
|
var BORDER_RADIUS2 = 8;
|
|
423
|
-
var
|
|
511
|
+
var BORDER_WIDTH3 = 1;
|
|
424
512
|
var BODY_FONT_SIZE2 = 14;
|
|
425
513
|
var MODAL_PADDING = 8;
|
|
426
514
|
var MODAL_MIN_WIDTH = 200;
|
|
427
515
|
var MODAL_MAX_HEIGHT = 300;
|
|
428
516
|
var CONTAINER_PADDING_H = 12;
|
|
429
517
|
var CONTAINER_PADDING_V = 10;
|
|
430
|
-
var
|
|
518
|
+
var styles8 = reactNative.StyleSheet.create({
|
|
431
519
|
anchor: { position: "relative" },
|
|
432
520
|
container: {
|
|
433
|
-
borderWidth:
|
|
521
|
+
borderWidth: BORDER_WIDTH3,
|
|
434
522
|
borderRadius: BORDER_RADIUS2,
|
|
435
523
|
paddingHorizontal: CONTAINER_PADDING_H,
|
|
436
524
|
paddingVertical: CONTAINER_PADDING_V
|
|
@@ -462,36 +550,36 @@ var ModalDropdown = ({
|
|
|
462
550
|
const { colors } = theme;
|
|
463
551
|
const resolvedVariant = useResolvedDropdownVariant(variant);
|
|
464
552
|
const isMenu = resolvedVariant === "menu" /* Menu */;
|
|
465
|
-
const [isOpen, setIsOpen] =
|
|
466
|
-
const anchorRef =
|
|
467
|
-
const dialogRef =
|
|
553
|
+
const [isOpen, setIsOpen] = React8.useState(false);
|
|
554
|
+
const anchorRef = React8.useRef(null);
|
|
555
|
+
const dialogRef = React8.useRef(null);
|
|
468
556
|
useFocusTrap(dialogRef, isOpen && !isMenu);
|
|
469
|
-
const selectedLabel =
|
|
557
|
+
const selectedLabel = React8.useMemo(() => {
|
|
470
558
|
const found = options.find((opt) => opt.value === value);
|
|
471
559
|
return found?.label ?? t("common.selectPlaceholder");
|
|
472
560
|
}, [options, value, t]);
|
|
473
|
-
const handleToggle =
|
|
561
|
+
const handleToggle = React8.useCallback(() => {
|
|
474
562
|
setIsOpen((prev) => !prev);
|
|
475
563
|
}, []);
|
|
476
|
-
const handleClose =
|
|
564
|
+
const handleClose = React8.useCallback(() => {
|
|
477
565
|
setIsOpen(false);
|
|
478
566
|
}, []);
|
|
479
|
-
const handleSelect =
|
|
567
|
+
const handleSelect = React8.useCallback(
|
|
480
568
|
(optionValue) => {
|
|
481
569
|
onChange(optionValue);
|
|
482
570
|
setIsOpen(false);
|
|
483
571
|
},
|
|
484
572
|
[onChange]
|
|
485
573
|
);
|
|
486
|
-
const containerStyle =
|
|
487
|
-
() => [
|
|
574
|
+
const containerStyle = React8.useMemo(
|
|
575
|
+
() => [styles8.container, { borderColor: colors.border, backgroundColor: colors.surface }],
|
|
488
576
|
[colors.border, colors.surface]
|
|
489
577
|
);
|
|
490
|
-
const modalContentStyle =
|
|
491
|
-
() => [
|
|
578
|
+
const modalContentStyle = React8.useMemo(
|
|
579
|
+
() => [styles8.modalContent, { backgroundColor: colors.surface }],
|
|
492
580
|
[colors.surface]
|
|
493
581
|
);
|
|
494
|
-
const renderModalOption =
|
|
582
|
+
const renderModalOption = React8.useCallback(
|
|
495
583
|
({ item }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
496
584
|
OptionRow,
|
|
497
585
|
{
|
|
@@ -503,8 +591,8 @@ var ModalDropdown = ({
|
|
|
503
591
|
),
|
|
504
592
|
[handleSelect, testID, value]
|
|
505
593
|
);
|
|
506
|
-
const keyExtractor =
|
|
507
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style:
|
|
594
|
+
const keyExtractor = React8.useCallback((item) => String(item.value), []);
|
|
595
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles8.anchor, children: [
|
|
508
596
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
509
597
|
reactNative.TouchableOpacity,
|
|
510
598
|
{
|
|
@@ -516,7 +604,7 @@ var ModalDropdown = ({
|
|
|
516
604
|
style: containerStyle,
|
|
517
605
|
testID,
|
|
518
606
|
onPress: handleToggle,
|
|
519
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
607
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.selectedText, { color: colors.text }], children: selectedLabel })
|
|
520
608
|
}
|
|
521
609
|
),
|
|
522
610
|
isMenu && isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -539,7 +627,7 @@ var ModalDropdown = ({
|
|
|
539
627
|
accessibilityLabel: t("common.dismissDropdown"),
|
|
540
628
|
accessibilityRole: "button",
|
|
541
629
|
activeOpacity: 1,
|
|
542
|
-
style:
|
|
630
|
+
style: styles8.modalOverlay,
|
|
543
631
|
testID: `${testID}-backdrop`,
|
|
544
632
|
onPress: handleClose,
|
|
545
633
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -558,7 +646,7 @@ var ModalDropdown = ({
|
|
|
558
646
|
] });
|
|
559
647
|
};
|
|
560
648
|
var CLOSE_ICON_SIZE = 18;
|
|
561
|
-
var
|
|
649
|
+
var styles9 = reactNative.StyleSheet.create({
|
|
562
650
|
container: {
|
|
563
651
|
flex: 1,
|
|
564
652
|
padding: 16
|
|
@@ -582,8 +670,8 @@ var ModalShell = ({
|
|
|
582
670
|
showClose = true
|
|
583
671
|
}) => {
|
|
584
672
|
const { theme, t } = uiFeedback.useUi();
|
|
585
|
-
const containerStyle =
|
|
586
|
-
() => [
|
|
673
|
+
const containerStyle = React8__default.default.useMemo(
|
|
674
|
+
() => [styles9.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
587
675
|
[theme.colors.background, contentStyle]
|
|
588
676
|
);
|
|
589
677
|
const closeA11yLabel = t("quizTemplates.cancel");
|
|
@@ -603,7 +691,7 @@ var ModalShell = ({
|
|
|
603
691
|
role: "dialog",
|
|
604
692
|
style: containerStyle,
|
|
605
693
|
children: [
|
|
606
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
694
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles9.headerRow, children: [
|
|
607
695
|
/* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title ?? t("close") }),
|
|
608
696
|
showClose ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
609
697
|
reactNative.TouchableOpacity,
|
|
@@ -611,7 +699,7 @@ var ModalShell = ({
|
|
|
611
699
|
accessibilityHint: t("common.closeDialogHint"),
|
|
612
700
|
accessibilityLabel: closeA11yLabel,
|
|
613
701
|
accessibilityRole: "button",
|
|
614
|
-
style:
|
|
702
|
+
style: styles9.closeButton,
|
|
615
703
|
testID: LAYOUT_TEST_IDS.modalShellClose,
|
|
616
704
|
onPress: onCancel,
|
|
617
705
|
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: theme.colors.textSecondary, name: "close", size: CLOSE_ICON_SIZE })
|
|
@@ -625,7 +713,212 @@ var ModalShell = ({
|
|
|
625
713
|
}
|
|
626
714
|
);
|
|
627
715
|
};
|
|
716
|
+
var AccordionContext = React8.createContext(null);
|
|
717
|
+
function useAccordionContext() {
|
|
718
|
+
const value = React8.useContext(AccordionContext);
|
|
719
|
+
if (value === null) {
|
|
720
|
+
throw new Error("AccordionItem must be rendered inside an <Accordion>.");
|
|
721
|
+
}
|
|
722
|
+
return value;
|
|
723
|
+
}
|
|
724
|
+
var androidEnabled = false;
|
|
725
|
+
function enableAndroidLayoutAnimationOnce() {
|
|
726
|
+
if (androidEnabled) return;
|
|
727
|
+
androidEnabled = true;
|
|
728
|
+
const isAndroid = reactNative.Platform.OS === "android";
|
|
729
|
+
const setter = reactNative.UIManager.setLayoutAnimationEnabledExperimental;
|
|
730
|
+
if (isAndroid && typeof setter === "function") {
|
|
731
|
+
setter(true);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
function animateNextLayout() {
|
|
735
|
+
enableAndroidLayoutAnimationOnce();
|
|
736
|
+
const configure = reactNative.LayoutAnimation.configureNext;
|
|
737
|
+
if (typeof configure !== "function") return;
|
|
738
|
+
try {
|
|
739
|
+
configure(reactNative.LayoutAnimation.Presets.easeInEaseOut);
|
|
740
|
+
} catch {
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
var styles10 = reactNative.StyleSheet.create({
|
|
744
|
+
container: { alignSelf: "stretch" }
|
|
745
|
+
});
|
|
746
|
+
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
747
|
+
const ids = new Set(defaultOpenIds ?? []);
|
|
748
|
+
React8__default.default.Children.forEach(children, (child) => {
|
|
749
|
+
if (!React8__default.default.isValidElement(child)) return;
|
|
750
|
+
const props = child.props;
|
|
751
|
+
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
752
|
+
ids.add(props.id);
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
if (!allowMultiple && ids.size > 1) {
|
|
756
|
+
const first = ids.values().next().value;
|
|
757
|
+
return new Set(first === void 0 ? [] : [first]);
|
|
758
|
+
}
|
|
759
|
+
return ids;
|
|
760
|
+
}
|
|
761
|
+
var Accordion = ({
|
|
762
|
+
children,
|
|
763
|
+
openIds,
|
|
764
|
+
defaultOpenIds,
|
|
765
|
+
onOpenChange,
|
|
766
|
+
allowMultiple = true,
|
|
767
|
+
testID = "accordion",
|
|
768
|
+
style
|
|
769
|
+
}) => {
|
|
770
|
+
const isControlled = openIds !== void 0;
|
|
771
|
+
const [internalOpen, setInternalOpen] = React8.useState(
|
|
772
|
+
() => computeInitialOpen(children, defaultOpenIds, allowMultiple)
|
|
773
|
+
);
|
|
774
|
+
const openSet = React8.useMemo(
|
|
775
|
+
() => isControlled ? new Set(openIds) : internalOpen,
|
|
776
|
+
[isControlled, openIds, internalOpen]
|
|
777
|
+
);
|
|
778
|
+
const toggle = React8.useCallback(
|
|
779
|
+
(id) => {
|
|
780
|
+
animateNextLayout();
|
|
781
|
+
const next = new Set(openSet);
|
|
782
|
+
const willOpen = !next.has(id);
|
|
783
|
+
if (!allowMultiple) next.clear();
|
|
784
|
+
if (willOpen) {
|
|
785
|
+
next.add(id);
|
|
786
|
+
} else {
|
|
787
|
+
next.delete(id);
|
|
788
|
+
}
|
|
789
|
+
if (!isControlled) setInternalOpen(next);
|
|
790
|
+
if (onOpenChange !== void 0) onOpenChange(Array.from(next));
|
|
791
|
+
},
|
|
792
|
+
[allowMultiple, isControlled, onOpenChange, openSet]
|
|
793
|
+
);
|
|
794
|
+
const contextValue = React8.useMemo(
|
|
795
|
+
() => ({ openIds: openSet, toggle, allowMultiple }),
|
|
796
|
+
[openSet, toggle, allowMultiple]
|
|
797
|
+
);
|
|
798
|
+
const containerStyle = React8.useMemo(
|
|
799
|
+
() => style === void 0 ? [styles10.container] : [styles10.container, ...Array.isArray(style) ? style : [style]],
|
|
800
|
+
[style]
|
|
801
|
+
);
|
|
802
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AccordionContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: containerStyle, testID, children }) });
|
|
803
|
+
};
|
|
804
|
+
var HEADER_PADDING_H = 16;
|
|
805
|
+
var HEADER_PADDING_V = 12;
|
|
806
|
+
var BODY_PADDING_H = 16;
|
|
807
|
+
var BODY_PADDING_V = 12;
|
|
808
|
+
var HEADER_GAP = 8;
|
|
809
|
+
var TITLE_FONT_SIZE2 = 15;
|
|
810
|
+
var TITLE_FONT_WEIGHT = "600";
|
|
811
|
+
var CHEVRON_SIZE = 18;
|
|
812
|
+
var ROTATE_DURATION_MS = 160;
|
|
813
|
+
var ROTATE_COLLAPSED = 0;
|
|
814
|
+
var ROTATE_EXPANDED = 1;
|
|
815
|
+
var COLLAPSED_DEG = "0deg";
|
|
816
|
+
var EXPANDED_DEG = "180deg";
|
|
817
|
+
var DISABLED_OPACITY = 0.5;
|
|
818
|
+
var FULL_OPACITY = 1;
|
|
819
|
+
var ROLE_REGION = "region";
|
|
820
|
+
var styles11 = reactNative.StyleSheet.create({
|
|
821
|
+
item: { borderTopWidth: reactNative.StyleSheet.hairlineWidth },
|
|
822
|
+
header: {
|
|
823
|
+
flexDirection: "row",
|
|
824
|
+
alignItems: "center",
|
|
825
|
+
justifyContent: "space-between",
|
|
826
|
+
paddingHorizontal: HEADER_PADDING_H,
|
|
827
|
+
paddingVertical: HEADER_PADDING_V
|
|
828
|
+
},
|
|
829
|
+
headerLeft: { flexShrink: 1, flexGrow: 1 },
|
|
830
|
+
headerRight: { flexDirection: "row", alignItems: "center", marginLeft: HEADER_GAP },
|
|
831
|
+
title: { fontSize: TITLE_FONT_SIZE2, fontWeight: TITLE_FONT_WEIGHT },
|
|
832
|
+
chevron: { marginLeft: HEADER_GAP },
|
|
833
|
+
body: { paddingHorizontal: BODY_PADDING_H, paddingBottom: BODY_PADDING_V }
|
|
834
|
+
});
|
|
835
|
+
var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
|
|
836
|
+
var AccordionItem = ({
|
|
837
|
+
id,
|
|
838
|
+
title,
|
|
839
|
+
right,
|
|
840
|
+
children,
|
|
841
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- read by the container's initial-open scan, not here
|
|
842
|
+
defaultOpen: _defaultOpen,
|
|
843
|
+
disabled = false,
|
|
844
|
+
testID,
|
|
845
|
+
accessibilityLabel,
|
|
846
|
+
accessibilityHint
|
|
847
|
+
}) => {
|
|
848
|
+
const { theme, t } = uiFeedback.useUi();
|
|
849
|
+
const { colors } = theme;
|
|
850
|
+
const { openIds, toggle } = useAccordionContext();
|
|
851
|
+
const expanded = openIds.has(id);
|
|
852
|
+
const headerTestID = testID ?? `accordion-item-${id}`;
|
|
853
|
+
const bodyTestID = `${headerTestID}-body`;
|
|
854
|
+
const chevronTestID = `${headerTestID}-chevron`;
|
|
855
|
+
const [rotation] = React8.useState(() => new reactNative.Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
|
|
856
|
+
React8.useEffect(() => {
|
|
857
|
+
reactNative.Animated.timing(rotation, {
|
|
858
|
+
toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
|
|
859
|
+
duration: ROTATE_DURATION_MS,
|
|
860
|
+
easing: reactNative.Easing.out(reactNative.Easing.ease),
|
|
861
|
+
useNativeDriver: reactNative.Platform.OS !== "web"
|
|
862
|
+
}).start();
|
|
863
|
+
}, [expanded, rotation]);
|
|
864
|
+
const rotate = rotation.interpolate({
|
|
865
|
+
inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
|
|
866
|
+
outputRange: [COLLAPSED_DEG, EXPANDED_DEG]
|
|
867
|
+
});
|
|
868
|
+
const handlePress = React8.useCallback(() => {
|
|
869
|
+
if (!disabled) toggle(id);
|
|
870
|
+
}, [disabled, id, toggle]);
|
|
871
|
+
const handleKeyDown2 = React8.useCallback(
|
|
872
|
+
(event) => {
|
|
873
|
+
if (disabled) return;
|
|
874
|
+
const key = event.key ?? "";
|
|
875
|
+
const isActivation = ACTIVATION_KEYS.includes(key);
|
|
876
|
+
if (!isActivation) return;
|
|
877
|
+
if (typeof event.preventDefault === "function") event.preventDefault();
|
|
878
|
+
toggle(id);
|
|
879
|
+
},
|
|
880
|
+
[disabled, id, toggle]
|
|
881
|
+
);
|
|
882
|
+
const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
883
|
+
const itemStyle = React8.useMemo(
|
|
884
|
+
() => [styles11.item, { borderTopColor: colors.border }],
|
|
885
|
+
[colors.border]
|
|
886
|
+
);
|
|
887
|
+
const headerStyle = React8.useMemo(
|
|
888
|
+
() => [styles11.header, { opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }],
|
|
889
|
+
[disabled]
|
|
890
|
+
);
|
|
891
|
+
const resolvedLabel = accessibilityLabel ?? (typeof title === "string" ? title : void 0);
|
|
892
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: itemStyle, children: [
|
|
893
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
894
|
+
reactNative.Pressable,
|
|
895
|
+
{
|
|
896
|
+
accessibilityHint: accessibilityHint ?? t("common.accordionToggleHint"),
|
|
897
|
+
accessibilityLabel: resolvedLabel,
|
|
898
|
+
accessibilityRole: "button",
|
|
899
|
+
accessibilityState: { expanded, disabled },
|
|
900
|
+
"aria-controls": bodyTestID,
|
|
901
|
+
"aria-expanded": expanded,
|
|
902
|
+
disabled,
|
|
903
|
+
style: headerStyle,
|
|
904
|
+
testID: headerTestID,
|
|
905
|
+
onPress: handlePress,
|
|
906
|
+
...keyboardProps,
|
|
907
|
+
children: [
|
|
908
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles11.headerLeft, children: typeof title === "string" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles11.title, { color: colors.text }], children: title }) : title }),
|
|
909
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles11.headerRight, children: [
|
|
910
|
+
right,
|
|
911
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles11.chevron, { transform: [{ rotate }] }], children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID }) })
|
|
912
|
+
] })
|
|
913
|
+
]
|
|
914
|
+
}
|
|
915
|
+
),
|
|
916
|
+
expanded ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityLabel: resolvedLabel, nativeID: bodyTestID, role: ROLE_REGION, style: styles11.body, testID: bodyTestID, children }) : null
|
|
917
|
+
] });
|
|
918
|
+
};
|
|
628
919
|
|
|
920
|
+
exports.Accordion = Accordion;
|
|
921
|
+
exports.AccordionItem = AccordionItem;
|
|
629
922
|
exports.DEFAULT_BILLING_ROUTE = DEFAULT_BILLING_ROUTE;
|
|
630
923
|
exports.DropdownVariant = DropdownVariant;
|
|
631
924
|
exports.Heading = Heading;
|
|
@@ -633,6 +926,7 @@ exports.LAYOUT_TEST_IDS = LAYOUT_TEST_IDS;
|
|
|
633
926
|
exports.ModalDropdown = ModalDropdown;
|
|
634
927
|
exports.ModalShell = ModalShell;
|
|
635
928
|
exports.Section = Section;
|
|
929
|
+
exports.SegmentedControl = SegmentedControl;
|
|
636
930
|
exports.StatusBadge = StatusBadge;
|
|
637
931
|
exports.UpgradePrompt = UpgradePrompt;
|
|
638
932
|
exports.useFocusTrap = useFocusTrap;
|