@dloizides/ui-layout 1.17.0 → 1.19.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 +28 -0
- package/README.md +1 -0
- package/dist/index.d.mts +33 -15
- package/dist/index.d.ts +33 -15
- package/dist/index.js +336 -250
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +281 -195
- 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 React9 = 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');
|
|
@@ -11,7 +11,7 @@ var rnWebHooks = require('@dloizides/rn-web-hooks');
|
|
|
11
11
|
|
|
12
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var React9__default = /*#__PURE__*/_interopDefault(React9);
|
|
15
15
|
|
|
16
16
|
// src/Section/Section.tsx
|
|
17
17
|
var styles = reactNative.StyleSheet.create({
|
|
@@ -23,7 +23,7 @@ var styles = reactNative.StyleSheet.create({
|
|
|
23
23
|
});
|
|
24
24
|
var Section = ({ children, style }) => {
|
|
25
25
|
const { theme } = uiFeedback.useUi();
|
|
26
|
-
const containerStyle =
|
|
26
|
+
const containerStyle = React9__default.default.useMemo(
|
|
27
27
|
() => [styles.card, { borderColor: theme.colors.border, backgroundColor: theme.colors.surface }, style],
|
|
28
28
|
[theme.colors.border, theme.colors.surface, style]
|
|
29
29
|
);
|
|
@@ -45,6 +45,11 @@ var DEFAULT_BILLING_ROUTE = "/settings/billing";
|
|
|
45
45
|
var LAYOUT_I18N = {
|
|
46
46
|
/** Placeholder shown by `ModalDropdown` when no option matches the current value. */
|
|
47
47
|
selectPlaceholder: "common.selectPlaceholder",
|
|
48
|
+
/**
|
|
49
|
+
* Accessible hint on the collapsed (mobile) `Tabs` menu trigger — the button
|
|
50
|
+
* that shows the active section and opens the vertical list of sections.
|
|
51
|
+
*/
|
|
52
|
+
tabsMenuHint: "common.tabsMenuHint",
|
|
48
53
|
/** Accessible name + hint of the modal-variant dropdown's dismiss backdrop. */
|
|
49
54
|
dismissDropdown: "common.dismissDropdown",
|
|
50
55
|
dismissDropdownHint: "common.dismissDropdownHint",
|
|
@@ -97,7 +102,7 @@ var Heading = ({
|
|
|
97
102
|
testID
|
|
98
103
|
}) => {
|
|
99
104
|
const { theme } = uiFeedback.useUi();
|
|
100
|
-
const headingStyle =
|
|
105
|
+
const headingStyle = React9__default.default.useMemo(
|
|
101
106
|
() => [styles2.heading, { color: theme.colors.text }, style],
|
|
102
107
|
[theme.colors.text, style]
|
|
103
108
|
);
|
|
@@ -137,8 +142,8 @@ var StatusBadge = ({
|
|
|
137
142
|
accessibilityHint
|
|
138
143
|
}) => {
|
|
139
144
|
const { t } = uiFeedback.useUi();
|
|
140
|
-
const dynamicBadge =
|
|
141
|
-
const dynamicText =
|
|
145
|
+
const dynamicBadge = React9.useMemo(() => ({ backgroundColor }), [backgroundColor]);
|
|
146
|
+
const dynamicText = React9.useMemo(() => ({ color }), [color]);
|
|
142
147
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
143
148
|
reactNative.View,
|
|
144
149
|
{
|
|
@@ -231,177 +236,6 @@ function SegmentedControl({
|
|
|
231
236
|
}
|
|
232
237
|
);
|
|
233
238
|
}
|
|
234
|
-
var PILL_RADIUS = 999;
|
|
235
|
-
var PILL_PAD_H = 16;
|
|
236
|
-
var PILL_PAD_V = 8;
|
|
237
|
-
var PILL_MIN_HEIGHT = 40;
|
|
238
|
-
var PILL_FONT = 14;
|
|
239
|
-
var PILL_WEIGHT = "600";
|
|
240
|
-
var ROW_GAP = 8;
|
|
241
|
-
var COLUMN_GAP = 8;
|
|
242
|
-
var ROW_PAD_V = 8;
|
|
243
|
-
var PANEL_PAD_TOP = 16;
|
|
244
|
-
var BORDER_WIDTH2 = 1;
|
|
245
|
-
var TEXT_ON_PRIMARY = "#ffffff";
|
|
246
|
-
var styles5 = reactNative.StyleSheet.create({
|
|
247
|
-
root: {
|
|
248
|
-
width: "100%"
|
|
249
|
-
},
|
|
250
|
-
strip: {
|
|
251
|
-
flexDirection: "row",
|
|
252
|
-
flexWrap: "wrap",
|
|
253
|
-
alignItems: "center",
|
|
254
|
-
columnGap: COLUMN_GAP,
|
|
255
|
-
rowGap: ROW_GAP,
|
|
256
|
-
paddingVertical: ROW_PAD_V,
|
|
257
|
-
borderBottomWidth: BORDER_WIDTH2
|
|
258
|
-
},
|
|
259
|
-
pill: {
|
|
260
|
-
paddingHorizontal: PILL_PAD_H,
|
|
261
|
-
paddingVertical: PILL_PAD_V,
|
|
262
|
-
borderRadius: PILL_RADIUS,
|
|
263
|
-
minHeight: PILL_MIN_HEIGHT,
|
|
264
|
-
flexDirection: "row",
|
|
265
|
-
alignItems: "center",
|
|
266
|
-
justifyContent: "center"
|
|
267
|
-
},
|
|
268
|
-
pillText: {
|
|
269
|
-
fontSize: PILL_FONT,
|
|
270
|
-
fontWeight: PILL_WEIGHT,
|
|
271
|
-
textAlign: "center"
|
|
272
|
-
},
|
|
273
|
-
panel: {
|
|
274
|
-
paddingTop: PANEL_PAD_TOP
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
function ariaTabProps(selected, panelId, tabId) {
|
|
278
|
-
return { "aria-selected": selected, "aria-controls": panelId, id: tabId };
|
|
279
|
-
}
|
|
280
|
-
var Tabs = ({
|
|
281
|
-
tabs,
|
|
282
|
-
activeKey,
|
|
283
|
-
onChange,
|
|
284
|
-
accessibilityLabel,
|
|
285
|
-
children,
|
|
286
|
-
idPrefix = "tabs",
|
|
287
|
-
style,
|
|
288
|
-
stripStyle,
|
|
289
|
-
panelStyle,
|
|
290
|
-
testID
|
|
291
|
-
}) => {
|
|
292
|
-
const { theme } = uiFeedback.useUi();
|
|
293
|
-
const { colors } = theme;
|
|
294
|
-
const primaryColor = theme.palette.primary["500"];
|
|
295
|
-
const activePanelId = `${idPrefix}-panel-${activeKey}`;
|
|
296
|
-
const activeTabId = `${idPrefix}-tab-${activeKey}`;
|
|
297
|
-
const panelAria = { "aria-labelledby": activeTabId, id: activePanelId };
|
|
298
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles5.root, style], testID, children: [
|
|
299
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
300
|
-
reactNative.View,
|
|
301
|
-
{
|
|
302
|
-
accessibilityRole: "tablist",
|
|
303
|
-
"aria-label": accessibilityLabel,
|
|
304
|
-
style: [styles5.strip, { borderBottomColor: colors.border }, stripStyle],
|
|
305
|
-
children: tabs.map((tab) => {
|
|
306
|
-
const selected = tab.key === activeKey;
|
|
307
|
-
const textColor = selected ? TEXT_ON_PRIMARY : colors.textSecondary;
|
|
308
|
-
const pillColor = selected ? primaryColor : colors.surfaceElevated;
|
|
309
|
-
const tabId = `${idPrefix}-tab-${tab.key}`;
|
|
310
|
-
const panelId = `${idPrefix}-panel-${tab.key}`;
|
|
311
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
312
|
-
reactNative.Pressable,
|
|
313
|
-
{
|
|
314
|
-
accessibilityRole: "tab",
|
|
315
|
-
accessibilityState: { selected },
|
|
316
|
-
accessibilityLabel: tab.accessibilityLabel ?? tab.label,
|
|
317
|
-
accessibilityHint: tab.accessibilityHint,
|
|
318
|
-
onPress: () => onChange(tab.key),
|
|
319
|
-
style: [styles5.pill, { backgroundColor: pillColor }],
|
|
320
|
-
testID: tab.testID,
|
|
321
|
-
...ariaTabProps(selected, panelId, tabId),
|
|
322
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.pillText, { color: textColor }], children: tab.label })
|
|
323
|
-
},
|
|
324
|
-
tab.key
|
|
325
|
-
);
|
|
326
|
-
})
|
|
327
|
-
}
|
|
328
|
-
) }),
|
|
329
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "none", style: [styles5.panel, panelStyle], ...panelAria, children })
|
|
330
|
-
] });
|
|
331
|
-
};
|
|
332
|
-
var PROMPT_PADDING = 20;
|
|
333
|
-
var PROMPT_BORDER_RADIUS = 12;
|
|
334
|
-
var PROMPT_BORDER_WIDTH = 1;
|
|
335
|
-
var TITLE_FONT_SIZE = 16;
|
|
336
|
-
var MESSAGE_FONT_SIZE = 14;
|
|
337
|
-
var BUTTON_PADDING_V = 12;
|
|
338
|
-
var BUTTON_BORDER_RADIUS = 8;
|
|
339
|
-
var BUTTON_FONT_SIZE = 14;
|
|
340
|
-
var DISMISS_FONT_SIZE = 13;
|
|
341
|
-
var TITLE_MARGIN_BOTTOM = 8;
|
|
342
|
-
var MESSAGE_MARGIN_BOTTOM = 16;
|
|
343
|
-
var CTA_MARGIN_BOTTOM = 8;
|
|
344
|
-
var styles6 = reactNative.StyleSheet.create({
|
|
345
|
-
container: {
|
|
346
|
-
padding: PROMPT_PADDING,
|
|
347
|
-
borderRadius: PROMPT_BORDER_RADIUS,
|
|
348
|
-
borderWidth: PROMPT_BORDER_WIDTH
|
|
349
|
-
},
|
|
350
|
-
title: { fontSize: TITLE_FONT_SIZE, fontWeight: "700", marginBottom: TITLE_MARGIN_BOTTOM },
|
|
351
|
-
message: { fontSize: MESSAGE_FONT_SIZE, marginBottom: MESSAGE_MARGIN_BOTTOM },
|
|
352
|
-
cta: { paddingVertical: BUTTON_PADDING_V, borderRadius: BUTTON_BORDER_RADIUS, alignItems: "center", marginBottom: CTA_MARGIN_BOTTOM },
|
|
353
|
-
ctaText: { fontSize: BUTTON_FONT_SIZE, fontWeight: "700" },
|
|
354
|
-
dismiss: { alignItems: "center", paddingVertical: BUTTON_PADDING_V },
|
|
355
|
-
dismissText: { fontSize: DISMISS_FONT_SIZE }
|
|
356
|
-
});
|
|
357
|
-
var UpgradePrompt = ({
|
|
358
|
-
requiredTier,
|
|
359
|
-
currentTier,
|
|
360
|
-
onDismiss,
|
|
361
|
-
billingRoute = DEFAULT_BILLING_ROUTE
|
|
362
|
-
}) => {
|
|
363
|
-
const { theme, t, navigate } = uiFeedback.useUi();
|
|
364
|
-
const colors = theme.colors;
|
|
365
|
-
const primary = theme.palette.primary["500"];
|
|
366
|
-
function handleUpgradePress() {
|
|
367
|
-
if (typeof navigate === "function") navigate(billingRoute);
|
|
368
|
-
}
|
|
369
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
370
|
-
reactNative.View,
|
|
371
|
-
{
|
|
372
|
-
style: [styles6.container, { borderColor: primary, backgroundColor: colors.surface }],
|
|
373
|
-
testID: LAYOUT_TEST_IDS.upgradePrompt,
|
|
374
|
-
children: [
|
|
375
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
|
|
376
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
|
|
377
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
378
|
-
reactNative.TouchableOpacity,
|
|
379
|
-
{
|
|
380
|
-
accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
|
|
381
|
-
accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
|
|
382
|
-
accessibilityRole: "button",
|
|
383
|
-
style: [styles6.cta, { backgroundColor: primary }],
|
|
384
|
-
testID: LAYOUT_TEST_IDS.upgradePromptCta,
|
|
385
|
-
onPress: handleUpgradePress,
|
|
386
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
|
|
387
|
-
}
|
|
388
|
-
),
|
|
389
|
-
onDismiss ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
390
|
-
reactNative.TouchableOpacity,
|
|
391
|
-
{
|
|
392
|
-
accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
|
|
393
|
-
accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
|
|
394
|
-
accessibilityRole: "button",
|
|
395
|
-
style: styles6.dismiss,
|
|
396
|
-
testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
|
|
397
|
-
onPress: onDismiss,
|
|
398
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
|
|
399
|
-
}
|
|
400
|
-
) : null
|
|
401
|
-
]
|
|
402
|
-
}
|
|
403
|
-
);
|
|
404
|
-
};
|
|
405
239
|
var FOCUSABLE_SELECTOR = [
|
|
406
240
|
"a[href]",
|
|
407
241
|
"button:not([disabled])",
|
|
@@ -439,8 +273,8 @@ function handleKeyDown(domNode, event) {
|
|
|
439
273
|
}
|
|
440
274
|
}
|
|
441
275
|
function useFocusTrap(containerRef, enabled) {
|
|
442
|
-
const previousFocusRef =
|
|
443
|
-
|
|
276
|
+
const previousFocusRef = React9.useRef(null);
|
|
277
|
+
React9.useEffect(() => {
|
|
444
278
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
445
279
|
const domNode = containerRef.current;
|
|
446
280
|
if (!domNode) return;
|
|
@@ -470,7 +304,7 @@ var MENU_ELEVATION = 8;
|
|
|
470
304
|
var MENU_TOP_GAP = 4;
|
|
471
305
|
var MENU_MAX_HEIGHT = 300;
|
|
472
306
|
var BORDER_RADIUS = 8;
|
|
473
|
-
var
|
|
307
|
+
var BORDER_WIDTH2 = 1;
|
|
474
308
|
var MENU_PADDING = 4;
|
|
475
309
|
var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
|
|
476
310
|
function buildPortalPopoverStyle(rect, minWidth = 0) {
|
|
@@ -482,7 +316,7 @@ function buildPortalPopoverStyle(rect, minWidth = 0) {
|
|
|
482
316
|
left: rect.left,
|
|
483
317
|
width: Math.max(rect.width, minWidth),
|
|
484
318
|
zIndex: MENU_Z_INDEX,
|
|
485
|
-
borderWidth:
|
|
319
|
+
borderWidth: BORDER_WIDTH2,
|
|
486
320
|
borderRadius: BORDER_RADIUS,
|
|
487
321
|
padding: MENU_PADDING,
|
|
488
322
|
maxHeight: MENU_MAX_HEIGHT,
|
|
@@ -507,7 +341,7 @@ var BODY_FONT_SIZE = 14;
|
|
|
507
341
|
var SELECTED_FONT_WEIGHT = "600";
|
|
508
342
|
var OPTION_PADDING_H = 16;
|
|
509
343
|
var OPTION_PADDING_V = 12;
|
|
510
|
-
var
|
|
344
|
+
var styles5 = reactNative.StyleSheet.create({
|
|
511
345
|
option: {
|
|
512
346
|
paddingHorizontal: OPTION_PADDING_H,
|
|
513
347
|
paddingVertical: OPTION_PADDING_V,
|
|
@@ -525,12 +359,12 @@ var OptionRow = ({
|
|
|
525
359
|
}) => {
|
|
526
360
|
const { theme, t } = uiFeedback.useUi();
|
|
527
361
|
const { colors } = theme;
|
|
528
|
-
const handlePress =
|
|
362
|
+
const handlePress = React9.useCallback(() => {
|
|
529
363
|
onSelect();
|
|
530
364
|
}, [onSelect]);
|
|
531
365
|
const isActive = isSelected || isHighlighted;
|
|
532
|
-
const rowStyle = [
|
|
533
|
-
const textStyle = [
|
|
366
|
+
const rowStyle = [styles5.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
|
|
367
|
+
const textStyle = [styles5.optionText, { color: colors.text }, isSelected ? styles5.selectedText : null];
|
|
534
368
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
535
369
|
reactNative.TouchableOpacity,
|
|
536
370
|
{
|
|
@@ -594,8 +428,8 @@ function observeLayout(node, onChange) {
|
|
|
594
428
|
return observer;
|
|
595
429
|
}
|
|
596
430
|
function useAnchorTracking(containerRef, onOutOfView) {
|
|
597
|
-
const [rect, setRect] =
|
|
598
|
-
|
|
431
|
+
const [rect, setRect] = React9.useState(() => readAnchorRect(containerRef));
|
|
432
|
+
React9.useLayoutEffect(() => {
|
|
599
433
|
if (!IS_WEB) return void 0;
|
|
600
434
|
let frame = null;
|
|
601
435
|
let isDisposed = false;
|
|
@@ -674,7 +508,7 @@ function buildKeyHandler(params) {
|
|
|
674
508
|
}
|
|
675
509
|
function useMenuKeyboard(params) {
|
|
676
510
|
const { containerRef, menuRef, enabled, onClose } = params;
|
|
677
|
-
|
|
511
|
+
React9.useEffect(() => {
|
|
678
512
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
679
513
|
const onKeyDown = buildKeyHandler(params);
|
|
680
514
|
const onMouseDown = (event) => {
|
|
@@ -693,9 +527,9 @@ function useMenuKeyboard(params) {
|
|
|
693
527
|
}
|
|
694
528
|
var IS_WEB2 = reactNative.Platform.OS === "web";
|
|
695
529
|
var BORDER_RADIUS2 = 8;
|
|
696
|
-
var
|
|
530
|
+
var BORDER_WIDTH3 = 1;
|
|
697
531
|
var MENU_PADDING2 = 4;
|
|
698
|
-
var
|
|
532
|
+
var styles6 = reactNative.StyleSheet.create({
|
|
699
533
|
/** Native (in-tree) popover — anchored absolutely just under the trigger. */
|
|
700
534
|
popover: {
|
|
701
535
|
position: "absolute",
|
|
@@ -704,7 +538,7 @@ var styles8 = reactNative.StyleSheet.create({
|
|
|
704
538
|
right: 0,
|
|
705
539
|
marginTop: MENU_TOP_GAP,
|
|
706
540
|
zIndex: MENU_Z_INDEX,
|
|
707
|
-
borderWidth:
|
|
541
|
+
borderWidth: BORDER_WIDTH3,
|
|
708
542
|
borderRadius: BORDER_RADIUS2,
|
|
709
543
|
padding: MENU_PADDING2,
|
|
710
544
|
maxHeight: MENU_MAX_HEIGHT,
|
|
@@ -725,21 +559,21 @@ var InlineMenu = ({
|
|
|
725
559
|
}) => {
|
|
726
560
|
const { theme } = uiFeedback.useUi();
|
|
727
561
|
const { colors } = theme;
|
|
728
|
-
const menuRef =
|
|
562
|
+
const menuRef = React9.useRef(null);
|
|
729
563
|
const rect = useAnchorTracking(containerRef, onClose);
|
|
730
|
-
const selectedIndex =
|
|
564
|
+
const selectedIndex = React9.useMemo(
|
|
731
565
|
() => Math.max(0, options.findIndex((opt) => opt.value === value)),
|
|
732
566
|
[options, value]
|
|
733
567
|
);
|
|
734
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
735
|
-
const selectAt =
|
|
568
|
+
const [highlightedIndex, setHighlightedIndex] = React9.useState(() => selectedIndex);
|
|
569
|
+
const selectAt = React9.useCallback(
|
|
736
570
|
(index) => {
|
|
737
571
|
const option = options[index];
|
|
738
572
|
if (option !== void 0) onSelect(option.value);
|
|
739
573
|
},
|
|
740
574
|
[options, onSelect]
|
|
741
575
|
);
|
|
742
|
-
const selectHighlighted =
|
|
576
|
+
const selectHighlighted = React9.useCallback(
|
|
743
577
|
() => {
|
|
744
578
|
selectAt(highlightedIndex);
|
|
745
579
|
},
|
|
@@ -754,14 +588,14 @@ var InlineMenu = ({
|
|
|
754
588
|
onSelectHighlighted: selectHighlighted,
|
|
755
589
|
onClose
|
|
756
590
|
});
|
|
757
|
-
const popoverStyle =
|
|
591
|
+
const popoverStyle = React9.useMemo(() => {
|
|
758
592
|
const themed = { borderColor: colors.border, backgroundColor: colors.surface };
|
|
759
593
|
if (IS_WEB2)
|
|
760
594
|
return [
|
|
761
595
|
buildPortalPopoverStyle(rect ?? { left: 0, width: 0, bottom: 0 }, menuMinWidth),
|
|
762
596
|
themed
|
|
763
597
|
];
|
|
764
|
-
return [
|
|
598
|
+
return [styles6.popover, { minWidth: menuMinWidth }, themed];
|
|
765
599
|
}, [colors.border, colors.surface, menuMinWidth, rect]);
|
|
766
600
|
const menu = /* @__PURE__ */ jsxRuntime.jsx(
|
|
767
601
|
reactNative.View,
|
|
@@ -799,17 +633,17 @@ function useResolvedDropdownVariant(explicit) {
|
|
|
799
633
|
return resolveDropdownVariant(explicit, width, reactNative.Platform.OS);
|
|
800
634
|
}
|
|
801
635
|
var BORDER_RADIUS3 = 8;
|
|
802
|
-
var
|
|
636
|
+
var BORDER_WIDTH4 = 1;
|
|
803
637
|
var BODY_FONT_SIZE2 = 14;
|
|
804
638
|
var MODAL_PADDING = 8;
|
|
805
639
|
var MODAL_MIN_WIDTH = 200;
|
|
806
640
|
var MODAL_MAX_HEIGHT = 300;
|
|
807
641
|
var CONTAINER_PADDING_H = 12;
|
|
808
642
|
var CONTAINER_PADDING_V = 10;
|
|
809
|
-
var
|
|
643
|
+
var styles7 = reactNative.StyleSheet.create({
|
|
810
644
|
anchor: { position: "relative" },
|
|
811
645
|
container: {
|
|
812
|
-
borderWidth:
|
|
646
|
+
borderWidth: BORDER_WIDTH4,
|
|
813
647
|
borderRadius: BORDER_RADIUS3,
|
|
814
648
|
paddingHorizontal: CONTAINER_PADDING_H,
|
|
815
649
|
paddingVertical: CONTAINER_PADDING_V
|
|
@@ -844,7 +678,7 @@ var ModalDropdown = ({
|
|
|
844
678
|
const { colors } = theme;
|
|
845
679
|
const resolvedVariant = useResolvedDropdownVariant(variant);
|
|
846
680
|
const isMenu = resolvedVariant === "menu" /* Menu */;
|
|
847
|
-
const [isOpen, setIsOpen] =
|
|
681
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
848
682
|
const { a11yProps, hintNode } = a11y.useA11y({
|
|
849
683
|
label: accessibilityLabel,
|
|
850
684
|
hint: accessibilityHint,
|
|
@@ -852,43 +686,43 @@ var ModalDropdown = ({
|
|
|
852
686
|
state: { expanded: isOpen },
|
|
853
687
|
testID
|
|
854
688
|
});
|
|
855
|
-
const anchorRef =
|
|
856
|
-
const dialogRef =
|
|
689
|
+
const anchorRef = React9.useRef(null);
|
|
690
|
+
const dialogRef = React9.useRef(null);
|
|
857
691
|
useFocusTrap(dialogRef, isOpen && !isMenu);
|
|
858
|
-
const selectedLabel =
|
|
692
|
+
const selectedLabel = React9.useMemo(() => {
|
|
859
693
|
const found = options.find((opt) => opt.value === value);
|
|
860
694
|
return found?.label ?? t(LAYOUT_I18N.selectPlaceholder);
|
|
861
695
|
}, [options, value, t]);
|
|
862
|
-
const handleToggle =
|
|
696
|
+
const handleToggle = React9.useCallback(() => {
|
|
863
697
|
setIsOpen((prev) => !prev);
|
|
864
698
|
}, []);
|
|
865
|
-
const handleClose =
|
|
699
|
+
const handleClose = React9.useCallback(() => {
|
|
866
700
|
setIsOpen(false);
|
|
867
701
|
}, []);
|
|
868
|
-
const handleSelect =
|
|
702
|
+
const handleSelect = React9.useCallback(
|
|
869
703
|
(optionValue) => {
|
|
870
704
|
onChange(optionValue);
|
|
871
705
|
setIsOpen(false);
|
|
872
706
|
},
|
|
873
707
|
[onChange]
|
|
874
708
|
);
|
|
875
|
-
const containerStyle =
|
|
876
|
-
() => renderTrigger !== void 0 ? void 0 : [
|
|
709
|
+
const containerStyle = React9.useMemo(
|
|
710
|
+
() => renderTrigger !== void 0 ? void 0 : [styles7.container, { borderColor: colors.border, backgroundColor: colors.surface }],
|
|
877
711
|
[colors.border, colors.surface, renderTrigger]
|
|
878
712
|
);
|
|
879
|
-
const optionTestIDFor =
|
|
713
|
+
const optionTestIDFor = React9.useCallback(
|
|
880
714
|
(optionValue) => optionTestID !== void 0 ? optionTestID(optionValue) : `${testID}-option-${String(optionValue)}`,
|
|
881
715
|
[optionTestID, testID]
|
|
882
716
|
);
|
|
883
|
-
const anchorStyle =
|
|
884
|
-
() => [
|
|
717
|
+
const anchorStyle = React9.useMemo(
|
|
718
|
+
() => [styles7.anchor, buildAnchorStackStyle(isMenu && isOpen)],
|
|
885
719
|
[isMenu, isOpen]
|
|
886
720
|
);
|
|
887
|
-
const modalContentStyle =
|
|
888
|
-
() => [
|
|
721
|
+
const modalContentStyle = React9.useMemo(
|
|
722
|
+
() => [styles7.modalContent, { backgroundColor: colors.surface }],
|
|
889
723
|
[colors.surface]
|
|
890
724
|
);
|
|
891
|
-
const renderModalOption =
|
|
725
|
+
const renderModalOption = React9.useCallback(
|
|
892
726
|
({ item }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
893
727
|
OptionRow,
|
|
894
728
|
{
|
|
@@ -900,10 +734,10 @@ var ModalDropdown = ({
|
|
|
900
734
|
),
|
|
901
735
|
[handleSelect, optionTestIDFor, value]
|
|
902
736
|
);
|
|
903
|
-
const keyExtractor =
|
|
737
|
+
const keyExtractor = React9.useCallback((item) => String(item.value), []);
|
|
904
738
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyle, children: [
|
|
905
739
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, style: containerStyle, onPress: handleToggle, children: [
|
|
906
|
-
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
740
|
+
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles7.selectedText, { color: colors.text }], children: selectedLabel }),
|
|
907
741
|
hintNode
|
|
908
742
|
] }),
|
|
909
743
|
isMenu && isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -920,7 +754,7 @@ var ModalDropdown = ({
|
|
|
920
754
|
onSelect: handleSelect
|
|
921
755
|
}
|
|
922
756
|
) : null,
|
|
923
|
-
!isMenu ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, animationType: "fade", visible: isOpen, onRequestClose: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
757
|
+
!isMenu ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, animationType: "fade", visible: isOpen, onRequestClose: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles7.modalOverlay, children: [
|
|
924
758
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
925
759
|
reactNative.TouchableOpacity,
|
|
926
760
|
{
|
|
@@ -948,6 +782,258 @@ var ModalDropdown = ({
|
|
|
948
782
|
] }) }) : null
|
|
949
783
|
] });
|
|
950
784
|
};
|
|
785
|
+
var TabsMenu = ({
|
|
786
|
+
tabs,
|
|
787
|
+
activeKey,
|
|
788
|
+
onChange,
|
|
789
|
+
accessibilityLabel,
|
|
790
|
+
idPrefix,
|
|
791
|
+
testID
|
|
792
|
+
}) => {
|
|
793
|
+
const { t } = uiFeedback.useUi();
|
|
794
|
+
const options = React9.useMemo(
|
|
795
|
+
() => tabs.map((tab) => ({ label: tab.label, value: tab.key })),
|
|
796
|
+
[tabs]
|
|
797
|
+
);
|
|
798
|
+
const optionTestID = React9.useCallback(
|
|
799
|
+
(key) => {
|
|
800
|
+
const found = tabs.find((tab) => tab.key === key);
|
|
801
|
+
return found?.testID ?? `${idPrefix}-tab-${key}`;
|
|
802
|
+
},
|
|
803
|
+
[tabs, idPrefix]
|
|
804
|
+
);
|
|
805
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
806
|
+
ModalDropdown,
|
|
807
|
+
{
|
|
808
|
+
accessibilityHint: t(LAYOUT_I18N.tabsMenuHint),
|
|
809
|
+
accessibilityLabel,
|
|
810
|
+
optionTestID,
|
|
811
|
+
options,
|
|
812
|
+
testID,
|
|
813
|
+
value: activeKey,
|
|
814
|
+
onChange
|
|
815
|
+
}
|
|
816
|
+
);
|
|
817
|
+
};
|
|
818
|
+
var TABS_COLLAPSE_BREAKPOINT = MENU_BREAKPOINT;
|
|
819
|
+
var WEB_PLATFORM2 = "web";
|
|
820
|
+
function shouldCollapseTabs(width, platformOS, breakpoint) {
|
|
821
|
+
const isWideWeb = platformOS === WEB_PLATFORM2 && width >= breakpoint;
|
|
822
|
+
return !isWideWeb;
|
|
823
|
+
}
|
|
824
|
+
function useTabsCollapsed(breakpoint) {
|
|
825
|
+
const { width } = reactNative.useWindowDimensions();
|
|
826
|
+
return shouldCollapseTabs(width, reactNative.Platform.OS, breakpoint);
|
|
827
|
+
}
|
|
828
|
+
var PILL_RADIUS = 999;
|
|
829
|
+
var PILL_PAD_H = 16;
|
|
830
|
+
var PILL_PAD_V = 8;
|
|
831
|
+
var PILL_MIN_HEIGHT = 40;
|
|
832
|
+
var PILL_FONT = 14;
|
|
833
|
+
var PILL_WEIGHT = "600";
|
|
834
|
+
var ROW_GAP = 8;
|
|
835
|
+
var COLUMN_GAP = 8;
|
|
836
|
+
var ROW_PAD_V = 8;
|
|
837
|
+
var PANEL_PAD_TOP = 16;
|
|
838
|
+
var BORDER_WIDTH5 = 1;
|
|
839
|
+
var TEXT_ON_PRIMARY = "#ffffff";
|
|
840
|
+
var styles8 = reactNative.StyleSheet.create({
|
|
841
|
+
root: {
|
|
842
|
+
width: "100%"
|
|
843
|
+
},
|
|
844
|
+
// The full-width rule under the row lives here (not on the strip) so it spans the
|
|
845
|
+
// whole width even when the tabs are narrower than the viewport (desktop) and is
|
|
846
|
+
// not clipped to the scroll content width.
|
|
847
|
+
stripOuter: {
|
|
848
|
+
width: "100%",
|
|
849
|
+
borderBottomWidth: BORDER_WIDTH5
|
|
850
|
+
},
|
|
851
|
+
strip: {
|
|
852
|
+
flexDirection: "row",
|
|
853
|
+
flexWrap: "nowrap",
|
|
854
|
+
alignItems: "center",
|
|
855
|
+
columnGap: COLUMN_GAP,
|
|
856
|
+
rowGap: ROW_GAP,
|
|
857
|
+
paddingVertical: ROW_PAD_V
|
|
858
|
+
},
|
|
859
|
+
pill: {
|
|
860
|
+
// Keep each pill at its natural size so the row scrolls instead of squashing
|
|
861
|
+
// the tabs when they don't all fit.
|
|
862
|
+
flexShrink: 0,
|
|
863
|
+
paddingHorizontal: PILL_PAD_H,
|
|
864
|
+
paddingVertical: PILL_PAD_V,
|
|
865
|
+
borderRadius: PILL_RADIUS,
|
|
866
|
+
minHeight: PILL_MIN_HEIGHT,
|
|
867
|
+
flexDirection: "row",
|
|
868
|
+
alignItems: "center",
|
|
869
|
+
justifyContent: "center"
|
|
870
|
+
},
|
|
871
|
+
pillText: {
|
|
872
|
+
fontSize: PILL_FONT,
|
|
873
|
+
fontWeight: PILL_WEIGHT,
|
|
874
|
+
textAlign: "center"
|
|
875
|
+
},
|
|
876
|
+
panel: {
|
|
877
|
+
paddingTop: PANEL_PAD_TOP
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
function ariaTabProps(selected, panelId, tabId) {
|
|
881
|
+
return { "aria-selected": selected, "aria-controls": panelId, id: tabId };
|
|
882
|
+
}
|
|
883
|
+
var WideTabStrip = ({
|
|
884
|
+
tabs,
|
|
885
|
+
activeKey,
|
|
886
|
+
onChange,
|
|
887
|
+
accessibilityLabel,
|
|
888
|
+
idPrefix,
|
|
889
|
+
borderColor,
|
|
890
|
+
primaryColor,
|
|
891
|
+
textSecondary,
|
|
892
|
+
surfaceElevated,
|
|
893
|
+
stripStyle
|
|
894
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles8.stripOuter, { borderBottomColor: borderColor }], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", "aria-label": accessibilityLabel, style: [styles8.strip, stripStyle], children: tabs.map((tab) => {
|
|
895
|
+
const selected = tab.key === activeKey;
|
|
896
|
+
const textColor = selected ? TEXT_ON_PRIMARY : textSecondary;
|
|
897
|
+
const pillColor = selected ? primaryColor : surfaceElevated;
|
|
898
|
+
const tabId = `${idPrefix}-tab-${tab.key}`;
|
|
899
|
+
const panelId = `${idPrefix}-panel-${tab.key}`;
|
|
900
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
901
|
+
reactNative.Pressable,
|
|
902
|
+
{
|
|
903
|
+
accessibilityRole: "tab",
|
|
904
|
+
accessibilityState: { selected },
|
|
905
|
+
accessibilityLabel: tab.accessibilityLabel ?? tab.label,
|
|
906
|
+
accessibilityHint: tab.accessibilityHint,
|
|
907
|
+
onPress: () => onChange(tab.key),
|
|
908
|
+
style: [styles8.pill, { backgroundColor: pillColor }],
|
|
909
|
+
testID: tab.testID,
|
|
910
|
+
...ariaTabProps(selected, panelId, tabId),
|
|
911
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.pillText, { color: textColor }], children: tab.label })
|
|
912
|
+
},
|
|
913
|
+
tab.key
|
|
914
|
+
);
|
|
915
|
+
}) }) }) });
|
|
916
|
+
var Tabs = ({
|
|
917
|
+
tabs,
|
|
918
|
+
activeKey,
|
|
919
|
+
onChange,
|
|
920
|
+
accessibilityLabel,
|
|
921
|
+
children,
|
|
922
|
+
idPrefix = "tabs",
|
|
923
|
+
collapseBelow = TABS_COLLAPSE_BREAKPOINT,
|
|
924
|
+
style,
|
|
925
|
+
stripStyle,
|
|
926
|
+
panelStyle,
|
|
927
|
+
testID
|
|
928
|
+
}) => {
|
|
929
|
+
const { theme } = uiFeedback.useUi();
|
|
930
|
+
const { colors } = theme;
|
|
931
|
+
const collapsed = useTabsCollapsed(collapseBelow);
|
|
932
|
+
const activePanelId = `${idPrefix}-panel-${activeKey}`;
|
|
933
|
+
const activeTabId = `${idPrefix}-tab-${activeKey}`;
|
|
934
|
+
const panelAria = { "aria-labelledby": activeTabId, id: activePanelId };
|
|
935
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles8.root, style], testID, children: [
|
|
936
|
+
collapsed ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
937
|
+
TabsMenu,
|
|
938
|
+
{
|
|
939
|
+
accessibilityLabel,
|
|
940
|
+
activeKey,
|
|
941
|
+
idPrefix,
|
|
942
|
+
tabs,
|
|
943
|
+
testID: `${idPrefix}-menu`,
|
|
944
|
+
onChange
|
|
945
|
+
}
|
|
946
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
947
|
+
WideTabStrip,
|
|
948
|
+
{
|
|
949
|
+
accessibilityLabel,
|
|
950
|
+
activeKey,
|
|
951
|
+
borderColor: colors.border,
|
|
952
|
+
idPrefix,
|
|
953
|
+
primaryColor: theme.palette.primary["500"],
|
|
954
|
+
stripStyle,
|
|
955
|
+
surfaceElevated: colors.surfaceElevated,
|
|
956
|
+
tabs,
|
|
957
|
+
textSecondary: colors.textSecondary,
|
|
958
|
+
onChange
|
|
959
|
+
}
|
|
960
|
+
),
|
|
961
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "none", style: [styles8.panel, panelStyle], ...panelAria, children })
|
|
962
|
+
] });
|
|
963
|
+
};
|
|
964
|
+
var PROMPT_PADDING = 20;
|
|
965
|
+
var PROMPT_BORDER_RADIUS = 12;
|
|
966
|
+
var PROMPT_BORDER_WIDTH = 1;
|
|
967
|
+
var TITLE_FONT_SIZE = 16;
|
|
968
|
+
var MESSAGE_FONT_SIZE = 14;
|
|
969
|
+
var BUTTON_PADDING_V = 12;
|
|
970
|
+
var BUTTON_BORDER_RADIUS = 8;
|
|
971
|
+
var BUTTON_FONT_SIZE = 14;
|
|
972
|
+
var DISMISS_FONT_SIZE = 13;
|
|
973
|
+
var TITLE_MARGIN_BOTTOM = 8;
|
|
974
|
+
var MESSAGE_MARGIN_BOTTOM = 16;
|
|
975
|
+
var CTA_MARGIN_BOTTOM = 8;
|
|
976
|
+
var styles9 = reactNative.StyleSheet.create({
|
|
977
|
+
container: {
|
|
978
|
+
padding: PROMPT_PADDING,
|
|
979
|
+
borderRadius: PROMPT_BORDER_RADIUS,
|
|
980
|
+
borderWidth: PROMPT_BORDER_WIDTH
|
|
981
|
+
},
|
|
982
|
+
title: { fontSize: TITLE_FONT_SIZE, fontWeight: "700", marginBottom: TITLE_MARGIN_BOTTOM },
|
|
983
|
+
message: { fontSize: MESSAGE_FONT_SIZE, marginBottom: MESSAGE_MARGIN_BOTTOM },
|
|
984
|
+
cta: { paddingVertical: BUTTON_PADDING_V, borderRadius: BUTTON_BORDER_RADIUS, alignItems: "center", marginBottom: CTA_MARGIN_BOTTOM },
|
|
985
|
+
ctaText: { fontSize: BUTTON_FONT_SIZE, fontWeight: "700" },
|
|
986
|
+
dismiss: { alignItems: "center", paddingVertical: BUTTON_PADDING_V },
|
|
987
|
+
dismissText: { fontSize: DISMISS_FONT_SIZE }
|
|
988
|
+
});
|
|
989
|
+
var UpgradePrompt = ({
|
|
990
|
+
requiredTier,
|
|
991
|
+
currentTier,
|
|
992
|
+
onDismiss,
|
|
993
|
+
billingRoute = DEFAULT_BILLING_ROUTE
|
|
994
|
+
}) => {
|
|
995
|
+
const { theme, t, navigate } = uiFeedback.useUi();
|
|
996
|
+
const colors = theme.colors;
|
|
997
|
+
const primary = theme.palette.primary["500"];
|
|
998
|
+
function handleUpgradePress() {
|
|
999
|
+
if (typeof navigate === "function") navigate(billingRoute);
|
|
1000
|
+
}
|
|
1001
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1002
|
+
reactNative.View,
|
|
1003
|
+
{
|
|
1004
|
+
style: [styles9.container, { borderColor: primary, backgroundColor: colors.surface }],
|
|
1005
|
+
testID: LAYOUT_TEST_IDS.upgradePrompt,
|
|
1006
|
+
children: [
|
|
1007
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
|
|
1008
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
|
|
1009
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1010
|
+
reactNative.TouchableOpacity,
|
|
1011
|
+
{
|
|
1012
|
+
accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
|
|
1013
|
+
accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
|
|
1014
|
+
accessibilityRole: "button",
|
|
1015
|
+
style: [styles9.cta, { backgroundColor: primary }],
|
|
1016
|
+
testID: LAYOUT_TEST_IDS.upgradePromptCta,
|
|
1017
|
+
onPress: handleUpgradePress,
|
|
1018
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
|
|
1019
|
+
}
|
|
1020
|
+
),
|
|
1021
|
+
onDismiss ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1022
|
+
reactNative.TouchableOpacity,
|
|
1023
|
+
{
|
|
1024
|
+
accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
|
|
1025
|
+
accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
|
|
1026
|
+
accessibilityRole: "button",
|
|
1027
|
+
style: styles9.dismiss,
|
|
1028
|
+
testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
|
|
1029
|
+
onPress: onDismiss,
|
|
1030
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
|
|
1031
|
+
}
|
|
1032
|
+
) : null
|
|
1033
|
+
]
|
|
1034
|
+
}
|
|
1035
|
+
);
|
|
1036
|
+
};
|
|
951
1037
|
var CLOSE_ICON_SIZE = 18;
|
|
952
1038
|
var styles10 = reactNative.StyleSheet.create({
|
|
953
1039
|
container: {
|
|
@@ -973,7 +1059,7 @@ var ModalShell = ({
|
|
|
973
1059
|
showClose = true
|
|
974
1060
|
}) => {
|
|
975
1061
|
const { theme, t } = uiFeedback.useUi();
|
|
976
|
-
const containerStyle =
|
|
1062
|
+
const containerStyle = React9__default.default.useMemo(
|
|
977
1063
|
() => [styles10.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
978
1064
|
[theme.colors.background, contentStyle]
|
|
979
1065
|
);
|
|
@@ -1016,9 +1102,9 @@ var ModalShell = ({
|
|
|
1016
1102
|
}
|
|
1017
1103
|
);
|
|
1018
1104
|
};
|
|
1019
|
-
var AccordionContext =
|
|
1105
|
+
var AccordionContext = React9.createContext(null);
|
|
1020
1106
|
function useAccordionContext() {
|
|
1021
|
-
const value =
|
|
1107
|
+
const value = React9.useContext(AccordionContext);
|
|
1022
1108
|
if (value === null) {
|
|
1023
1109
|
throw new Error("AccordionItem must be rendered inside an <Accordion>.");
|
|
1024
1110
|
}
|
|
@@ -1051,8 +1137,8 @@ var styles11 = reactNative.StyleSheet.create({
|
|
|
1051
1137
|
});
|
|
1052
1138
|
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
1053
1139
|
const ids = new Set(defaultOpenIds ?? []);
|
|
1054
|
-
|
|
1055
|
-
if (!
|
|
1140
|
+
React9__default.default.Children.forEach(children, (child) => {
|
|
1141
|
+
if (!React9__default.default.isValidElement(child)) return;
|
|
1056
1142
|
const props = child.props;
|
|
1057
1143
|
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
1058
1144
|
ids.add(props.id);
|
|
@@ -1075,14 +1161,14 @@ var Accordion = ({
|
|
|
1075
1161
|
style
|
|
1076
1162
|
}) => {
|
|
1077
1163
|
const isControlled = openIds !== void 0;
|
|
1078
|
-
const [internalOpen, setInternalOpen] =
|
|
1164
|
+
const [internalOpen, setInternalOpen] = React9.useState(
|
|
1079
1165
|
() => computeInitialOpen(children, defaultOpenIds, allowMultiple)
|
|
1080
1166
|
);
|
|
1081
|
-
const openSet =
|
|
1167
|
+
const openSet = React9.useMemo(
|
|
1082
1168
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
1083
1169
|
[isControlled, openIds, internalOpen]
|
|
1084
1170
|
);
|
|
1085
|
-
const toggle =
|
|
1171
|
+
const toggle = React9.useCallback(
|
|
1086
1172
|
(id) => {
|
|
1087
1173
|
animateNextLayout();
|
|
1088
1174
|
const next = new Set(openSet);
|
|
@@ -1098,11 +1184,11 @@ var Accordion = ({
|
|
|
1098
1184
|
},
|
|
1099
1185
|
[allowMultiple, isControlled, onOpenChange, openSet]
|
|
1100
1186
|
);
|
|
1101
|
-
const contextValue =
|
|
1187
|
+
const contextValue = React9.useMemo(
|
|
1102
1188
|
() => ({ openIds: openSet, toggle, allowMultiple, variant }),
|
|
1103
1189
|
[openSet, toggle, allowMultiple, variant]
|
|
1104
1190
|
);
|
|
1105
|
-
const containerStyle =
|
|
1191
|
+
const containerStyle = React9.useMemo(() => {
|
|
1106
1192
|
const base = variant === "boxed" ? [styles11.container, styles11.boxed] : [styles11.container];
|
|
1107
1193
|
if (style === void 0) return base;
|
|
1108
1194
|
return [...base, ...Array.isArray(style) ? style : [style]];
|
|
@@ -1179,9 +1265,9 @@ var AccordionItem = ({
|
|
|
1179
1265
|
const headerTestID = testID ?? `accordion-item-${id}`;
|
|
1180
1266
|
const bodyTestID = `${headerTestID}-body`;
|
|
1181
1267
|
const chevronTestID = `${headerTestID}-chevron`;
|
|
1182
|
-
const [rotation] =
|
|
1268
|
+
const [rotation] = React9.useState(() => new reactNative.Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
|
|
1183
1269
|
const reducedMotion = rnWebHooks.useReducedMotion();
|
|
1184
|
-
|
|
1270
|
+
React9.useEffect(() => {
|
|
1185
1271
|
reactNative.Animated.timing(rotation, {
|
|
1186
1272
|
toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
|
|
1187
1273
|
duration: reducedMotion ? INSTANT_DURATION_MS : ROTATE_DURATION_MS,
|
|
@@ -1193,10 +1279,10 @@ var AccordionItem = ({
|
|
|
1193
1279
|
inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
|
|
1194
1280
|
outputRange: [COLLAPSED_DEG, boxed ? BOXED_EXPANDED_DEG : PLAIN_EXPANDED_DEG]
|
|
1195
1281
|
});
|
|
1196
|
-
const handlePress =
|
|
1282
|
+
const handlePress = React9.useCallback(() => {
|
|
1197
1283
|
if (!disabled) toggle(id);
|
|
1198
1284
|
}, [disabled, id, toggle]);
|
|
1199
|
-
const handleKeyDown2 =
|
|
1285
|
+
const handleKeyDown2 = React9.useCallback(
|
|
1200
1286
|
(event) => {
|
|
1201
1287
|
if (disabled) return;
|
|
1202
1288
|
const key = event.key ?? "";
|
|
@@ -1208,11 +1294,11 @@ var AccordionItem = ({
|
|
|
1208
1294
|
[disabled, id, toggle]
|
|
1209
1295
|
);
|
|
1210
1296
|
const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
1211
|
-
const itemStyle =
|
|
1297
|
+
const itemStyle = React9.useMemo(
|
|
1212
1298
|
() => boxed ? [styles12.boxItem, { borderColor: colors.border }] : [styles12.item, { borderTopColor: colors.border }],
|
|
1213
1299
|
[boxed, colors.border]
|
|
1214
1300
|
);
|
|
1215
|
-
const headerStyle =
|
|
1301
|
+
const headerStyle = React9.useMemo(
|
|
1216
1302
|
() => [
|
|
1217
1303
|
styles12.header,
|
|
1218
1304
|
...boxed ? [styles12.boxHeader] : [],
|
|
@@ -1315,14 +1401,14 @@ function measureParentInnerWidth(node) {
|
|
|
1315
1401
|
return Math.max(UNMEASURED, parent.clientWidth - padding);
|
|
1316
1402
|
}
|
|
1317
1403
|
function useAvailableWidth() {
|
|
1318
|
-
const [width, setWidth] =
|
|
1319
|
-
const nodeRef =
|
|
1320
|
-
const measureRef =
|
|
1404
|
+
const [width, setWidth] = React9.useState(UNMEASURED);
|
|
1405
|
+
const nodeRef = React9.useRef(null);
|
|
1406
|
+
const measureRef = React9.useCallback((node) => {
|
|
1321
1407
|
if (!IS_WEB3) return;
|
|
1322
1408
|
nodeRef.current = node;
|
|
1323
1409
|
if (nodeRef.current !== null) setWidth(measureParentInnerWidth(nodeRef.current));
|
|
1324
1410
|
}, []);
|
|
1325
|
-
|
|
1411
|
+
React9.useEffect(() => {
|
|
1326
1412
|
if (!IS_WEB3) return void 0;
|
|
1327
1413
|
const remeasure = () => {
|
|
1328
1414
|
const node = nodeRef.current;
|
|
@@ -1331,7 +1417,7 @@ function useAvailableWidth() {
|
|
|
1331
1417
|
window.addEventListener("resize", remeasure);
|
|
1332
1418
|
return () => window.removeEventListener("resize", remeasure);
|
|
1333
1419
|
}, []);
|
|
1334
|
-
const onLayout =
|
|
1420
|
+
const onLayout = React9.useCallback((event) => {
|
|
1335
1421
|
if (IS_WEB3) return;
|
|
1336
1422
|
setWidth(event.nativeEvent.layout.width);
|
|
1337
1423
|
}, []);
|
|
@@ -1360,8 +1446,8 @@ var TruncatedText = ({
|
|
|
1360
1446
|
accessibilityHint
|
|
1361
1447
|
}) => {
|
|
1362
1448
|
const { width, measureRef, onLayout } = useAvailableWidth();
|
|
1363
|
-
const hostRef =
|
|
1364
|
-
const attachRef =
|
|
1449
|
+
const hostRef = React9.useRef(null);
|
|
1450
|
+
const attachRef = React9.useCallback(
|
|
1365
1451
|
(node) => {
|
|
1366
1452
|
hostRef.current = node;
|
|
1367
1453
|
measureRef(node);
|
|
@@ -1370,12 +1456,12 @@ var TruncatedText = ({
|
|
|
1370
1456
|
},
|
|
1371
1457
|
[value, measureRef]
|
|
1372
1458
|
);
|
|
1373
|
-
const flatStyle =
|
|
1459
|
+
const flatStyle = React9.useMemo(
|
|
1374
1460
|
() => reactNative.StyleSheet.flatten([styles13.base, style]),
|
|
1375
1461
|
[style]
|
|
1376
1462
|
);
|
|
1377
1463
|
const fontSize = flatStyle.fontSize ?? DEFAULT_FONT_SIZE2;
|
|
1378
|
-
const display =
|
|
1464
|
+
const display = React9.useMemo(() => {
|
|
1379
1465
|
const source = isUrl ? formatUrlForDisplay(value) : value;
|
|
1380
1466
|
const budget = charBudget(width, fontSize);
|
|
1381
1467
|
return budget === UNMEASURED2 ? source : truncateMiddle(source, budget);
|
|
@@ -1457,17 +1543,17 @@ async function copyText(value, writer) {
|
|
|
1457
1543
|
// src/CopyableId/useCopyToClipboard.ts
|
|
1458
1544
|
var COPY_FEEDBACK_MS = 2e3;
|
|
1459
1545
|
function useCopyToClipboard(value, writer) {
|
|
1460
|
-
const [status, setStatus] =
|
|
1461
|
-
const timerRef =
|
|
1462
|
-
const mountedRef =
|
|
1463
|
-
|
|
1546
|
+
const [status, setStatus] = React9.useState("idle" /* Idle */);
|
|
1547
|
+
const timerRef = React9.useRef(null);
|
|
1548
|
+
const mountedRef = React9.useRef(true);
|
|
1549
|
+
React9.useEffect(() => {
|
|
1464
1550
|
mountedRef.current = true;
|
|
1465
1551
|
return () => {
|
|
1466
1552
|
mountedRef.current = false;
|
|
1467
1553
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
1468
1554
|
};
|
|
1469
1555
|
}, []);
|
|
1470
|
-
const copy =
|
|
1556
|
+
const copy = React9.useCallback(() => {
|
|
1471
1557
|
void (async () => {
|
|
1472
1558
|
const ok = await copyText(value, writer);
|
|
1473
1559
|
if (!mountedRef.current) return;
|
|
@@ -1525,7 +1611,7 @@ var styles14 = reactNative.StyleSheet.create({
|
|
|
1525
1611
|
var TONE_STEP = "500";
|
|
1526
1612
|
function useActionState(status) {
|
|
1527
1613
|
const { theme } = uiFeedback.useUi();
|
|
1528
|
-
return
|
|
1614
|
+
return React9.useMemo(() => {
|
|
1529
1615
|
const primary = theme.palette.primary[TONE_STEP];
|
|
1530
1616
|
if (status === "copied" /* Copied */) {
|
|
1531
1617
|
return { key: LAYOUT_I18N.copied, color: theme.semantic.success?.[TONE_STEP] ?? primary };
|