@dloizides/ui-layout 1.18.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 -24
- package/dist/index.d.ts +33 -24
- package/dist/index.js +336 -259
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +281 -204
- 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,186 +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
|
-
// The full-width rule under the row lives here (not on the strip) so it spans the
|
|
251
|
-
// whole width even when the tabs are narrower than the viewport (desktop) and is
|
|
252
|
-
// not clipped to the scroll content width.
|
|
253
|
-
stripOuter: {
|
|
254
|
-
width: "100%",
|
|
255
|
-
borderBottomWidth: BORDER_WIDTH2
|
|
256
|
-
},
|
|
257
|
-
strip: {
|
|
258
|
-
flexDirection: "row",
|
|
259
|
-
flexWrap: "nowrap",
|
|
260
|
-
alignItems: "center",
|
|
261
|
-
columnGap: COLUMN_GAP,
|
|
262
|
-
rowGap: ROW_GAP,
|
|
263
|
-
paddingVertical: ROW_PAD_V
|
|
264
|
-
},
|
|
265
|
-
pill: {
|
|
266
|
-
// Keep each pill at its natural size so the row scrolls instead of squashing
|
|
267
|
-
// the tabs when they don't all fit.
|
|
268
|
-
flexShrink: 0,
|
|
269
|
-
paddingHorizontal: PILL_PAD_H,
|
|
270
|
-
paddingVertical: PILL_PAD_V,
|
|
271
|
-
borderRadius: PILL_RADIUS,
|
|
272
|
-
minHeight: PILL_MIN_HEIGHT,
|
|
273
|
-
flexDirection: "row",
|
|
274
|
-
alignItems: "center",
|
|
275
|
-
justifyContent: "center"
|
|
276
|
-
},
|
|
277
|
-
pillText: {
|
|
278
|
-
fontSize: PILL_FONT,
|
|
279
|
-
fontWeight: PILL_WEIGHT,
|
|
280
|
-
textAlign: "center"
|
|
281
|
-
},
|
|
282
|
-
panel: {
|
|
283
|
-
paddingTop: PANEL_PAD_TOP
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
function ariaTabProps(selected, panelId, tabId) {
|
|
287
|
-
return { "aria-selected": selected, "aria-controls": panelId, id: tabId };
|
|
288
|
-
}
|
|
289
|
-
var Tabs = ({
|
|
290
|
-
tabs,
|
|
291
|
-
activeKey,
|
|
292
|
-
onChange,
|
|
293
|
-
accessibilityLabel,
|
|
294
|
-
children,
|
|
295
|
-
idPrefix = "tabs",
|
|
296
|
-
style,
|
|
297
|
-
stripStyle,
|
|
298
|
-
panelStyle,
|
|
299
|
-
testID
|
|
300
|
-
}) => {
|
|
301
|
-
const { theme } = uiFeedback.useUi();
|
|
302
|
-
const { colors } = theme;
|
|
303
|
-
const primaryColor = theme.palette.primary["500"];
|
|
304
|
-
const activePanelId = `${idPrefix}-panel-${activeKey}`;
|
|
305
|
-
const activeTabId = `${idPrefix}-tab-${activeKey}`;
|
|
306
|
-
const panelAria = { "aria-labelledby": activeTabId, id: activePanelId };
|
|
307
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles5.root, style], testID, children: [
|
|
308
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles5.stripOuter, { borderBottomColor: colors.border }], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
309
|
-
reactNative.View,
|
|
310
|
-
{
|
|
311
|
-
accessibilityRole: "tablist",
|
|
312
|
-
"aria-label": accessibilityLabel,
|
|
313
|
-
style: [styles5.strip, stripStyle],
|
|
314
|
-
children: tabs.map((tab) => {
|
|
315
|
-
const selected = tab.key === activeKey;
|
|
316
|
-
const textColor = selected ? TEXT_ON_PRIMARY : colors.textSecondary;
|
|
317
|
-
const pillColor = selected ? primaryColor : colors.surfaceElevated;
|
|
318
|
-
const tabId = `${idPrefix}-tab-${tab.key}`;
|
|
319
|
-
const panelId = `${idPrefix}-panel-${tab.key}`;
|
|
320
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
321
|
-
reactNative.Pressable,
|
|
322
|
-
{
|
|
323
|
-
accessibilityRole: "tab",
|
|
324
|
-
accessibilityState: { selected },
|
|
325
|
-
accessibilityLabel: tab.accessibilityLabel ?? tab.label,
|
|
326
|
-
accessibilityHint: tab.accessibilityHint,
|
|
327
|
-
onPress: () => onChange(tab.key),
|
|
328
|
-
style: [styles5.pill, { backgroundColor: pillColor }],
|
|
329
|
-
testID: tab.testID,
|
|
330
|
-
...ariaTabProps(selected, panelId, tabId),
|
|
331
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.pillText, { color: textColor }], children: tab.label })
|
|
332
|
-
},
|
|
333
|
-
tab.key
|
|
334
|
-
);
|
|
335
|
-
})
|
|
336
|
-
}
|
|
337
|
-
) }) }),
|
|
338
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "none", style: [styles5.panel, panelStyle], ...panelAria, children })
|
|
339
|
-
] });
|
|
340
|
-
};
|
|
341
|
-
var PROMPT_PADDING = 20;
|
|
342
|
-
var PROMPT_BORDER_RADIUS = 12;
|
|
343
|
-
var PROMPT_BORDER_WIDTH = 1;
|
|
344
|
-
var TITLE_FONT_SIZE = 16;
|
|
345
|
-
var MESSAGE_FONT_SIZE = 14;
|
|
346
|
-
var BUTTON_PADDING_V = 12;
|
|
347
|
-
var BUTTON_BORDER_RADIUS = 8;
|
|
348
|
-
var BUTTON_FONT_SIZE = 14;
|
|
349
|
-
var DISMISS_FONT_SIZE = 13;
|
|
350
|
-
var TITLE_MARGIN_BOTTOM = 8;
|
|
351
|
-
var MESSAGE_MARGIN_BOTTOM = 16;
|
|
352
|
-
var CTA_MARGIN_BOTTOM = 8;
|
|
353
|
-
var styles6 = reactNative.StyleSheet.create({
|
|
354
|
-
container: {
|
|
355
|
-
padding: PROMPT_PADDING,
|
|
356
|
-
borderRadius: PROMPT_BORDER_RADIUS,
|
|
357
|
-
borderWidth: PROMPT_BORDER_WIDTH
|
|
358
|
-
},
|
|
359
|
-
title: { fontSize: TITLE_FONT_SIZE, fontWeight: "700", marginBottom: TITLE_MARGIN_BOTTOM },
|
|
360
|
-
message: { fontSize: MESSAGE_FONT_SIZE, marginBottom: MESSAGE_MARGIN_BOTTOM },
|
|
361
|
-
cta: { paddingVertical: BUTTON_PADDING_V, borderRadius: BUTTON_BORDER_RADIUS, alignItems: "center", marginBottom: CTA_MARGIN_BOTTOM },
|
|
362
|
-
ctaText: { fontSize: BUTTON_FONT_SIZE, fontWeight: "700" },
|
|
363
|
-
dismiss: { alignItems: "center", paddingVertical: BUTTON_PADDING_V },
|
|
364
|
-
dismissText: { fontSize: DISMISS_FONT_SIZE }
|
|
365
|
-
});
|
|
366
|
-
var UpgradePrompt = ({
|
|
367
|
-
requiredTier,
|
|
368
|
-
currentTier,
|
|
369
|
-
onDismiss,
|
|
370
|
-
billingRoute = DEFAULT_BILLING_ROUTE
|
|
371
|
-
}) => {
|
|
372
|
-
const { theme, t, navigate } = uiFeedback.useUi();
|
|
373
|
-
const colors = theme.colors;
|
|
374
|
-
const primary = theme.palette.primary["500"];
|
|
375
|
-
function handleUpgradePress() {
|
|
376
|
-
if (typeof navigate === "function") navigate(billingRoute);
|
|
377
|
-
}
|
|
378
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
379
|
-
reactNative.View,
|
|
380
|
-
{
|
|
381
|
-
style: [styles6.container, { borderColor: primary, backgroundColor: colors.surface }],
|
|
382
|
-
testID: LAYOUT_TEST_IDS.upgradePrompt,
|
|
383
|
-
children: [
|
|
384
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
|
|
385
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
|
|
386
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
387
|
-
reactNative.TouchableOpacity,
|
|
388
|
-
{
|
|
389
|
-
accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
|
|
390
|
-
accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
|
|
391
|
-
accessibilityRole: "button",
|
|
392
|
-
style: [styles6.cta, { backgroundColor: primary }],
|
|
393
|
-
testID: LAYOUT_TEST_IDS.upgradePromptCta,
|
|
394
|
-
onPress: handleUpgradePress,
|
|
395
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
|
|
396
|
-
}
|
|
397
|
-
),
|
|
398
|
-
onDismiss ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
399
|
-
reactNative.TouchableOpacity,
|
|
400
|
-
{
|
|
401
|
-
accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
|
|
402
|
-
accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
|
|
403
|
-
accessibilityRole: "button",
|
|
404
|
-
style: styles6.dismiss,
|
|
405
|
-
testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
|
|
406
|
-
onPress: onDismiss,
|
|
407
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
|
|
408
|
-
}
|
|
409
|
-
) : null
|
|
410
|
-
]
|
|
411
|
-
}
|
|
412
|
-
);
|
|
413
|
-
};
|
|
414
239
|
var FOCUSABLE_SELECTOR = [
|
|
415
240
|
"a[href]",
|
|
416
241
|
"button:not([disabled])",
|
|
@@ -448,8 +273,8 @@ function handleKeyDown(domNode, event) {
|
|
|
448
273
|
}
|
|
449
274
|
}
|
|
450
275
|
function useFocusTrap(containerRef, enabled) {
|
|
451
|
-
const previousFocusRef =
|
|
452
|
-
|
|
276
|
+
const previousFocusRef = React9.useRef(null);
|
|
277
|
+
React9.useEffect(() => {
|
|
453
278
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
454
279
|
const domNode = containerRef.current;
|
|
455
280
|
if (!domNode) return;
|
|
@@ -479,7 +304,7 @@ var MENU_ELEVATION = 8;
|
|
|
479
304
|
var MENU_TOP_GAP = 4;
|
|
480
305
|
var MENU_MAX_HEIGHT = 300;
|
|
481
306
|
var BORDER_RADIUS = 8;
|
|
482
|
-
var
|
|
307
|
+
var BORDER_WIDTH2 = 1;
|
|
483
308
|
var MENU_PADDING = 4;
|
|
484
309
|
var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
|
|
485
310
|
function buildPortalPopoverStyle(rect, minWidth = 0) {
|
|
@@ -491,7 +316,7 @@ function buildPortalPopoverStyle(rect, minWidth = 0) {
|
|
|
491
316
|
left: rect.left,
|
|
492
317
|
width: Math.max(rect.width, minWidth),
|
|
493
318
|
zIndex: MENU_Z_INDEX,
|
|
494
|
-
borderWidth:
|
|
319
|
+
borderWidth: BORDER_WIDTH2,
|
|
495
320
|
borderRadius: BORDER_RADIUS,
|
|
496
321
|
padding: MENU_PADDING,
|
|
497
322
|
maxHeight: MENU_MAX_HEIGHT,
|
|
@@ -516,7 +341,7 @@ var BODY_FONT_SIZE = 14;
|
|
|
516
341
|
var SELECTED_FONT_WEIGHT = "600";
|
|
517
342
|
var OPTION_PADDING_H = 16;
|
|
518
343
|
var OPTION_PADDING_V = 12;
|
|
519
|
-
var
|
|
344
|
+
var styles5 = reactNative.StyleSheet.create({
|
|
520
345
|
option: {
|
|
521
346
|
paddingHorizontal: OPTION_PADDING_H,
|
|
522
347
|
paddingVertical: OPTION_PADDING_V,
|
|
@@ -534,12 +359,12 @@ var OptionRow = ({
|
|
|
534
359
|
}) => {
|
|
535
360
|
const { theme, t } = uiFeedback.useUi();
|
|
536
361
|
const { colors } = theme;
|
|
537
|
-
const handlePress =
|
|
362
|
+
const handlePress = React9.useCallback(() => {
|
|
538
363
|
onSelect();
|
|
539
364
|
}, [onSelect]);
|
|
540
365
|
const isActive = isSelected || isHighlighted;
|
|
541
|
-
const rowStyle = [
|
|
542
|
-
const textStyle = [
|
|
366
|
+
const rowStyle = [styles5.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
|
|
367
|
+
const textStyle = [styles5.optionText, { color: colors.text }, isSelected ? styles5.selectedText : null];
|
|
543
368
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
544
369
|
reactNative.TouchableOpacity,
|
|
545
370
|
{
|
|
@@ -603,8 +428,8 @@ function observeLayout(node, onChange) {
|
|
|
603
428
|
return observer;
|
|
604
429
|
}
|
|
605
430
|
function useAnchorTracking(containerRef, onOutOfView) {
|
|
606
|
-
const [rect, setRect] =
|
|
607
|
-
|
|
431
|
+
const [rect, setRect] = React9.useState(() => readAnchorRect(containerRef));
|
|
432
|
+
React9.useLayoutEffect(() => {
|
|
608
433
|
if (!IS_WEB) return void 0;
|
|
609
434
|
let frame = null;
|
|
610
435
|
let isDisposed = false;
|
|
@@ -683,7 +508,7 @@ function buildKeyHandler(params) {
|
|
|
683
508
|
}
|
|
684
509
|
function useMenuKeyboard(params) {
|
|
685
510
|
const { containerRef, menuRef, enabled, onClose } = params;
|
|
686
|
-
|
|
511
|
+
React9.useEffect(() => {
|
|
687
512
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
688
513
|
const onKeyDown = buildKeyHandler(params);
|
|
689
514
|
const onMouseDown = (event) => {
|
|
@@ -702,9 +527,9 @@ function useMenuKeyboard(params) {
|
|
|
702
527
|
}
|
|
703
528
|
var IS_WEB2 = reactNative.Platform.OS === "web";
|
|
704
529
|
var BORDER_RADIUS2 = 8;
|
|
705
|
-
var
|
|
530
|
+
var BORDER_WIDTH3 = 1;
|
|
706
531
|
var MENU_PADDING2 = 4;
|
|
707
|
-
var
|
|
532
|
+
var styles6 = reactNative.StyleSheet.create({
|
|
708
533
|
/** Native (in-tree) popover — anchored absolutely just under the trigger. */
|
|
709
534
|
popover: {
|
|
710
535
|
position: "absolute",
|
|
@@ -713,7 +538,7 @@ var styles8 = reactNative.StyleSheet.create({
|
|
|
713
538
|
right: 0,
|
|
714
539
|
marginTop: MENU_TOP_GAP,
|
|
715
540
|
zIndex: MENU_Z_INDEX,
|
|
716
|
-
borderWidth:
|
|
541
|
+
borderWidth: BORDER_WIDTH3,
|
|
717
542
|
borderRadius: BORDER_RADIUS2,
|
|
718
543
|
padding: MENU_PADDING2,
|
|
719
544
|
maxHeight: MENU_MAX_HEIGHT,
|
|
@@ -734,21 +559,21 @@ var InlineMenu = ({
|
|
|
734
559
|
}) => {
|
|
735
560
|
const { theme } = uiFeedback.useUi();
|
|
736
561
|
const { colors } = theme;
|
|
737
|
-
const menuRef =
|
|
562
|
+
const menuRef = React9.useRef(null);
|
|
738
563
|
const rect = useAnchorTracking(containerRef, onClose);
|
|
739
|
-
const selectedIndex =
|
|
564
|
+
const selectedIndex = React9.useMemo(
|
|
740
565
|
() => Math.max(0, options.findIndex((opt) => opt.value === value)),
|
|
741
566
|
[options, value]
|
|
742
567
|
);
|
|
743
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
744
|
-
const selectAt =
|
|
568
|
+
const [highlightedIndex, setHighlightedIndex] = React9.useState(() => selectedIndex);
|
|
569
|
+
const selectAt = React9.useCallback(
|
|
745
570
|
(index) => {
|
|
746
571
|
const option = options[index];
|
|
747
572
|
if (option !== void 0) onSelect(option.value);
|
|
748
573
|
},
|
|
749
574
|
[options, onSelect]
|
|
750
575
|
);
|
|
751
|
-
const selectHighlighted =
|
|
576
|
+
const selectHighlighted = React9.useCallback(
|
|
752
577
|
() => {
|
|
753
578
|
selectAt(highlightedIndex);
|
|
754
579
|
},
|
|
@@ -763,14 +588,14 @@ var InlineMenu = ({
|
|
|
763
588
|
onSelectHighlighted: selectHighlighted,
|
|
764
589
|
onClose
|
|
765
590
|
});
|
|
766
|
-
const popoverStyle =
|
|
591
|
+
const popoverStyle = React9.useMemo(() => {
|
|
767
592
|
const themed = { borderColor: colors.border, backgroundColor: colors.surface };
|
|
768
593
|
if (IS_WEB2)
|
|
769
594
|
return [
|
|
770
595
|
buildPortalPopoverStyle(rect ?? { left: 0, width: 0, bottom: 0 }, menuMinWidth),
|
|
771
596
|
themed
|
|
772
597
|
];
|
|
773
|
-
return [
|
|
598
|
+
return [styles6.popover, { minWidth: menuMinWidth }, themed];
|
|
774
599
|
}, [colors.border, colors.surface, menuMinWidth, rect]);
|
|
775
600
|
const menu = /* @__PURE__ */ jsxRuntime.jsx(
|
|
776
601
|
reactNative.View,
|
|
@@ -808,17 +633,17 @@ function useResolvedDropdownVariant(explicit) {
|
|
|
808
633
|
return resolveDropdownVariant(explicit, width, reactNative.Platform.OS);
|
|
809
634
|
}
|
|
810
635
|
var BORDER_RADIUS3 = 8;
|
|
811
|
-
var
|
|
636
|
+
var BORDER_WIDTH4 = 1;
|
|
812
637
|
var BODY_FONT_SIZE2 = 14;
|
|
813
638
|
var MODAL_PADDING = 8;
|
|
814
639
|
var MODAL_MIN_WIDTH = 200;
|
|
815
640
|
var MODAL_MAX_HEIGHT = 300;
|
|
816
641
|
var CONTAINER_PADDING_H = 12;
|
|
817
642
|
var CONTAINER_PADDING_V = 10;
|
|
818
|
-
var
|
|
643
|
+
var styles7 = reactNative.StyleSheet.create({
|
|
819
644
|
anchor: { position: "relative" },
|
|
820
645
|
container: {
|
|
821
|
-
borderWidth:
|
|
646
|
+
borderWidth: BORDER_WIDTH4,
|
|
822
647
|
borderRadius: BORDER_RADIUS3,
|
|
823
648
|
paddingHorizontal: CONTAINER_PADDING_H,
|
|
824
649
|
paddingVertical: CONTAINER_PADDING_V
|
|
@@ -853,7 +678,7 @@ var ModalDropdown = ({
|
|
|
853
678
|
const { colors } = theme;
|
|
854
679
|
const resolvedVariant = useResolvedDropdownVariant(variant);
|
|
855
680
|
const isMenu = resolvedVariant === "menu" /* Menu */;
|
|
856
|
-
const [isOpen, setIsOpen] =
|
|
681
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
857
682
|
const { a11yProps, hintNode } = a11y.useA11y({
|
|
858
683
|
label: accessibilityLabel,
|
|
859
684
|
hint: accessibilityHint,
|
|
@@ -861,43 +686,43 @@ var ModalDropdown = ({
|
|
|
861
686
|
state: { expanded: isOpen },
|
|
862
687
|
testID
|
|
863
688
|
});
|
|
864
|
-
const anchorRef =
|
|
865
|
-
const dialogRef =
|
|
689
|
+
const anchorRef = React9.useRef(null);
|
|
690
|
+
const dialogRef = React9.useRef(null);
|
|
866
691
|
useFocusTrap(dialogRef, isOpen && !isMenu);
|
|
867
|
-
const selectedLabel =
|
|
692
|
+
const selectedLabel = React9.useMemo(() => {
|
|
868
693
|
const found = options.find((opt) => opt.value === value);
|
|
869
694
|
return found?.label ?? t(LAYOUT_I18N.selectPlaceholder);
|
|
870
695
|
}, [options, value, t]);
|
|
871
|
-
const handleToggle =
|
|
696
|
+
const handleToggle = React9.useCallback(() => {
|
|
872
697
|
setIsOpen((prev) => !prev);
|
|
873
698
|
}, []);
|
|
874
|
-
const handleClose =
|
|
699
|
+
const handleClose = React9.useCallback(() => {
|
|
875
700
|
setIsOpen(false);
|
|
876
701
|
}, []);
|
|
877
|
-
const handleSelect =
|
|
702
|
+
const handleSelect = React9.useCallback(
|
|
878
703
|
(optionValue) => {
|
|
879
704
|
onChange(optionValue);
|
|
880
705
|
setIsOpen(false);
|
|
881
706
|
},
|
|
882
707
|
[onChange]
|
|
883
708
|
);
|
|
884
|
-
const containerStyle =
|
|
885
|
-
() => renderTrigger !== void 0 ? void 0 : [
|
|
709
|
+
const containerStyle = React9.useMemo(
|
|
710
|
+
() => renderTrigger !== void 0 ? void 0 : [styles7.container, { borderColor: colors.border, backgroundColor: colors.surface }],
|
|
886
711
|
[colors.border, colors.surface, renderTrigger]
|
|
887
712
|
);
|
|
888
|
-
const optionTestIDFor =
|
|
713
|
+
const optionTestIDFor = React9.useCallback(
|
|
889
714
|
(optionValue) => optionTestID !== void 0 ? optionTestID(optionValue) : `${testID}-option-${String(optionValue)}`,
|
|
890
715
|
[optionTestID, testID]
|
|
891
716
|
);
|
|
892
|
-
const anchorStyle =
|
|
893
|
-
() => [
|
|
717
|
+
const anchorStyle = React9.useMemo(
|
|
718
|
+
() => [styles7.anchor, buildAnchorStackStyle(isMenu && isOpen)],
|
|
894
719
|
[isMenu, isOpen]
|
|
895
720
|
);
|
|
896
|
-
const modalContentStyle =
|
|
897
|
-
() => [
|
|
721
|
+
const modalContentStyle = React9.useMemo(
|
|
722
|
+
() => [styles7.modalContent, { backgroundColor: colors.surface }],
|
|
898
723
|
[colors.surface]
|
|
899
724
|
);
|
|
900
|
-
const renderModalOption =
|
|
725
|
+
const renderModalOption = React9.useCallback(
|
|
901
726
|
({ item }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
902
727
|
OptionRow,
|
|
903
728
|
{
|
|
@@ -909,10 +734,10 @@ var ModalDropdown = ({
|
|
|
909
734
|
),
|
|
910
735
|
[handleSelect, optionTestIDFor, value]
|
|
911
736
|
);
|
|
912
|
-
const keyExtractor =
|
|
737
|
+
const keyExtractor = React9.useCallback((item) => String(item.value), []);
|
|
913
738
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyle, children: [
|
|
914
739
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, style: containerStyle, onPress: handleToggle, children: [
|
|
915
|
-
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 }),
|
|
916
741
|
hintNode
|
|
917
742
|
] }),
|
|
918
743
|
isMenu && isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -929,7 +754,7 @@ var ModalDropdown = ({
|
|
|
929
754
|
onSelect: handleSelect
|
|
930
755
|
}
|
|
931
756
|
) : null,
|
|
932
|
-
!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: [
|
|
933
758
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
934
759
|
reactNative.TouchableOpacity,
|
|
935
760
|
{
|
|
@@ -957,6 +782,258 @@ var ModalDropdown = ({
|
|
|
957
782
|
] }) }) : null
|
|
958
783
|
] });
|
|
959
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
|
+
};
|
|
960
1037
|
var CLOSE_ICON_SIZE = 18;
|
|
961
1038
|
var styles10 = reactNative.StyleSheet.create({
|
|
962
1039
|
container: {
|
|
@@ -982,7 +1059,7 @@ var ModalShell = ({
|
|
|
982
1059
|
showClose = true
|
|
983
1060
|
}) => {
|
|
984
1061
|
const { theme, t } = uiFeedback.useUi();
|
|
985
|
-
const containerStyle =
|
|
1062
|
+
const containerStyle = React9__default.default.useMemo(
|
|
986
1063
|
() => [styles10.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
987
1064
|
[theme.colors.background, contentStyle]
|
|
988
1065
|
);
|
|
@@ -1025,9 +1102,9 @@ var ModalShell = ({
|
|
|
1025
1102
|
}
|
|
1026
1103
|
);
|
|
1027
1104
|
};
|
|
1028
|
-
var AccordionContext =
|
|
1105
|
+
var AccordionContext = React9.createContext(null);
|
|
1029
1106
|
function useAccordionContext() {
|
|
1030
|
-
const value =
|
|
1107
|
+
const value = React9.useContext(AccordionContext);
|
|
1031
1108
|
if (value === null) {
|
|
1032
1109
|
throw new Error("AccordionItem must be rendered inside an <Accordion>.");
|
|
1033
1110
|
}
|
|
@@ -1060,8 +1137,8 @@ var styles11 = reactNative.StyleSheet.create({
|
|
|
1060
1137
|
});
|
|
1061
1138
|
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
1062
1139
|
const ids = new Set(defaultOpenIds ?? []);
|
|
1063
|
-
|
|
1064
|
-
if (!
|
|
1140
|
+
React9__default.default.Children.forEach(children, (child) => {
|
|
1141
|
+
if (!React9__default.default.isValidElement(child)) return;
|
|
1065
1142
|
const props = child.props;
|
|
1066
1143
|
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
1067
1144
|
ids.add(props.id);
|
|
@@ -1084,14 +1161,14 @@ var Accordion = ({
|
|
|
1084
1161
|
style
|
|
1085
1162
|
}) => {
|
|
1086
1163
|
const isControlled = openIds !== void 0;
|
|
1087
|
-
const [internalOpen, setInternalOpen] =
|
|
1164
|
+
const [internalOpen, setInternalOpen] = React9.useState(
|
|
1088
1165
|
() => computeInitialOpen(children, defaultOpenIds, allowMultiple)
|
|
1089
1166
|
);
|
|
1090
|
-
const openSet =
|
|
1167
|
+
const openSet = React9.useMemo(
|
|
1091
1168
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
1092
1169
|
[isControlled, openIds, internalOpen]
|
|
1093
1170
|
);
|
|
1094
|
-
const toggle =
|
|
1171
|
+
const toggle = React9.useCallback(
|
|
1095
1172
|
(id) => {
|
|
1096
1173
|
animateNextLayout();
|
|
1097
1174
|
const next = new Set(openSet);
|
|
@@ -1107,11 +1184,11 @@ var Accordion = ({
|
|
|
1107
1184
|
},
|
|
1108
1185
|
[allowMultiple, isControlled, onOpenChange, openSet]
|
|
1109
1186
|
);
|
|
1110
|
-
const contextValue =
|
|
1187
|
+
const contextValue = React9.useMemo(
|
|
1111
1188
|
() => ({ openIds: openSet, toggle, allowMultiple, variant }),
|
|
1112
1189
|
[openSet, toggle, allowMultiple, variant]
|
|
1113
1190
|
);
|
|
1114
|
-
const containerStyle =
|
|
1191
|
+
const containerStyle = React9.useMemo(() => {
|
|
1115
1192
|
const base = variant === "boxed" ? [styles11.container, styles11.boxed] : [styles11.container];
|
|
1116
1193
|
if (style === void 0) return base;
|
|
1117
1194
|
return [...base, ...Array.isArray(style) ? style : [style]];
|
|
@@ -1188,9 +1265,9 @@ var AccordionItem = ({
|
|
|
1188
1265
|
const headerTestID = testID ?? `accordion-item-${id}`;
|
|
1189
1266
|
const bodyTestID = `${headerTestID}-body`;
|
|
1190
1267
|
const chevronTestID = `${headerTestID}-chevron`;
|
|
1191
|
-
const [rotation] =
|
|
1268
|
+
const [rotation] = React9.useState(() => new reactNative.Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
|
|
1192
1269
|
const reducedMotion = rnWebHooks.useReducedMotion();
|
|
1193
|
-
|
|
1270
|
+
React9.useEffect(() => {
|
|
1194
1271
|
reactNative.Animated.timing(rotation, {
|
|
1195
1272
|
toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
|
|
1196
1273
|
duration: reducedMotion ? INSTANT_DURATION_MS : ROTATE_DURATION_MS,
|
|
@@ -1202,10 +1279,10 @@ var AccordionItem = ({
|
|
|
1202
1279
|
inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
|
|
1203
1280
|
outputRange: [COLLAPSED_DEG, boxed ? BOXED_EXPANDED_DEG : PLAIN_EXPANDED_DEG]
|
|
1204
1281
|
});
|
|
1205
|
-
const handlePress =
|
|
1282
|
+
const handlePress = React9.useCallback(() => {
|
|
1206
1283
|
if (!disabled) toggle(id);
|
|
1207
1284
|
}, [disabled, id, toggle]);
|
|
1208
|
-
const handleKeyDown2 =
|
|
1285
|
+
const handleKeyDown2 = React9.useCallback(
|
|
1209
1286
|
(event) => {
|
|
1210
1287
|
if (disabled) return;
|
|
1211
1288
|
const key = event.key ?? "";
|
|
@@ -1217,11 +1294,11 @@ var AccordionItem = ({
|
|
|
1217
1294
|
[disabled, id, toggle]
|
|
1218
1295
|
);
|
|
1219
1296
|
const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
1220
|
-
const itemStyle =
|
|
1297
|
+
const itemStyle = React9.useMemo(
|
|
1221
1298
|
() => boxed ? [styles12.boxItem, { borderColor: colors.border }] : [styles12.item, { borderTopColor: colors.border }],
|
|
1222
1299
|
[boxed, colors.border]
|
|
1223
1300
|
);
|
|
1224
|
-
const headerStyle =
|
|
1301
|
+
const headerStyle = React9.useMemo(
|
|
1225
1302
|
() => [
|
|
1226
1303
|
styles12.header,
|
|
1227
1304
|
...boxed ? [styles12.boxHeader] : [],
|
|
@@ -1324,14 +1401,14 @@ function measureParentInnerWidth(node) {
|
|
|
1324
1401
|
return Math.max(UNMEASURED, parent.clientWidth - padding);
|
|
1325
1402
|
}
|
|
1326
1403
|
function useAvailableWidth() {
|
|
1327
|
-
const [width, setWidth] =
|
|
1328
|
-
const nodeRef =
|
|
1329
|
-
const measureRef =
|
|
1404
|
+
const [width, setWidth] = React9.useState(UNMEASURED);
|
|
1405
|
+
const nodeRef = React9.useRef(null);
|
|
1406
|
+
const measureRef = React9.useCallback((node) => {
|
|
1330
1407
|
if (!IS_WEB3) return;
|
|
1331
1408
|
nodeRef.current = node;
|
|
1332
1409
|
if (nodeRef.current !== null) setWidth(measureParentInnerWidth(nodeRef.current));
|
|
1333
1410
|
}, []);
|
|
1334
|
-
|
|
1411
|
+
React9.useEffect(() => {
|
|
1335
1412
|
if (!IS_WEB3) return void 0;
|
|
1336
1413
|
const remeasure = () => {
|
|
1337
1414
|
const node = nodeRef.current;
|
|
@@ -1340,7 +1417,7 @@ function useAvailableWidth() {
|
|
|
1340
1417
|
window.addEventListener("resize", remeasure);
|
|
1341
1418
|
return () => window.removeEventListener("resize", remeasure);
|
|
1342
1419
|
}, []);
|
|
1343
|
-
const onLayout =
|
|
1420
|
+
const onLayout = React9.useCallback((event) => {
|
|
1344
1421
|
if (IS_WEB3) return;
|
|
1345
1422
|
setWidth(event.nativeEvent.layout.width);
|
|
1346
1423
|
}, []);
|
|
@@ -1369,8 +1446,8 @@ var TruncatedText = ({
|
|
|
1369
1446
|
accessibilityHint
|
|
1370
1447
|
}) => {
|
|
1371
1448
|
const { width, measureRef, onLayout } = useAvailableWidth();
|
|
1372
|
-
const hostRef =
|
|
1373
|
-
const attachRef =
|
|
1449
|
+
const hostRef = React9.useRef(null);
|
|
1450
|
+
const attachRef = React9.useCallback(
|
|
1374
1451
|
(node) => {
|
|
1375
1452
|
hostRef.current = node;
|
|
1376
1453
|
measureRef(node);
|
|
@@ -1379,12 +1456,12 @@ var TruncatedText = ({
|
|
|
1379
1456
|
},
|
|
1380
1457
|
[value, measureRef]
|
|
1381
1458
|
);
|
|
1382
|
-
const flatStyle =
|
|
1459
|
+
const flatStyle = React9.useMemo(
|
|
1383
1460
|
() => reactNative.StyleSheet.flatten([styles13.base, style]),
|
|
1384
1461
|
[style]
|
|
1385
1462
|
);
|
|
1386
1463
|
const fontSize = flatStyle.fontSize ?? DEFAULT_FONT_SIZE2;
|
|
1387
|
-
const display =
|
|
1464
|
+
const display = React9.useMemo(() => {
|
|
1388
1465
|
const source = isUrl ? formatUrlForDisplay(value) : value;
|
|
1389
1466
|
const budget = charBudget(width, fontSize);
|
|
1390
1467
|
return budget === UNMEASURED2 ? source : truncateMiddle(source, budget);
|
|
@@ -1466,17 +1543,17 @@ async function copyText(value, writer) {
|
|
|
1466
1543
|
// src/CopyableId/useCopyToClipboard.ts
|
|
1467
1544
|
var COPY_FEEDBACK_MS = 2e3;
|
|
1468
1545
|
function useCopyToClipboard(value, writer) {
|
|
1469
|
-
const [status, setStatus] =
|
|
1470
|
-
const timerRef =
|
|
1471
|
-
const mountedRef =
|
|
1472
|
-
|
|
1546
|
+
const [status, setStatus] = React9.useState("idle" /* Idle */);
|
|
1547
|
+
const timerRef = React9.useRef(null);
|
|
1548
|
+
const mountedRef = React9.useRef(true);
|
|
1549
|
+
React9.useEffect(() => {
|
|
1473
1550
|
mountedRef.current = true;
|
|
1474
1551
|
return () => {
|
|
1475
1552
|
mountedRef.current = false;
|
|
1476
1553
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
1477
1554
|
};
|
|
1478
1555
|
}, []);
|
|
1479
|
-
const copy =
|
|
1556
|
+
const copy = React9.useCallback(() => {
|
|
1480
1557
|
void (async () => {
|
|
1481
1558
|
const ok = await copyText(value, writer);
|
|
1482
1559
|
if (!mountedRef.current) return;
|
|
@@ -1534,7 +1611,7 @@ var styles14 = reactNative.StyleSheet.create({
|
|
|
1534
1611
|
var TONE_STEP = "500";
|
|
1535
1612
|
function useActionState(status) {
|
|
1536
1613
|
const { theme } = uiFeedback.useUi();
|
|
1537
|
-
return
|
|
1614
|
+
return React9.useMemo(() => {
|
|
1538
1615
|
const primary = theme.palette.primary[TONE_STEP];
|
|
1539
1616
|
if (status === "copied" /* Copied */) {
|
|
1540
1617
|
return { key: LAYOUT_I18N.copied, color: theme.semantic.success?.[TONE_STEP] ?? primary };
|