@dloizides/ui-layout 1.18.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +1 -0
- package/dist/index.d.mts +43 -25
- package/dist/index.d.ts +43 -25
- package/dist/index.js +373 -261
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +319 -207
- 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,22 +633,41 @@ 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 MIN_TOUCH_TARGET = 44;
|
|
644
|
+
var CARET_FONT_SIZE = 12;
|
|
645
|
+
var CARET_GAP = 8;
|
|
646
|
+
var CARET_GLYPH = "\u25BE";
|
|
647
|
+
var CARET_OPEN_ROTATION = "180deg";
|
|
648
|
+
var CARET_CLOSED_ROTATION = "0deg";
|
|
649
|
+
var styles7 = reactNative.StyleSheet.create({
|
|
819
650
|
anchor: { position: "relative" },
|
|
820
651
|
container: {
|
|
821
|
-
borderWidth:
|
|
652
|
+
borderWidth: BORDER_WIDTH4,
|
|
822
653
|
borderRadius: BORDER_RADIUS3,
|
|
823
654
|
paddingHorizontal: CONTAINER_PADDING_H,
|
|
824
655
|
paddingVertical: CONTAINER_PADDING_V
|
|
825
656
|
},
|
|
657
|
+
// Caret variant: a row with the label leading and the caret pinned to the trailing edge, at a
|
|
658
|
+
// phone-friendly minimum height. Only applied when `showCaret` is set, so field dropdowns are
|
|
659
|
+
// untouched.
|
|
660
|
+
containerMenu: {
|
|
661
|
+
minHeight: MIN_TOUCH_TARGET,
|
|
662
|
+
flexDirection: "row",
|
|
663
|
+
alignItems: "center",
|
|
664
|
+
justifyContent: "space-between",
|
|
665
|
+
columnGap: CARET_GAP
|
|
666
|
+
},
|
|
826
667
|
selectedText: { fontSize: BODY_FONT_SIZE2 },
|
|
668
|
+
// The label may shrink/ellipsize; the caret never does.
|
|
669
|
+
selectedTextMenu: { flexShrink: 1 },
|
|
670
|
+
caret: { fontSize: CARET_FONT_SIZE, flexShrink: 0 },
|
|
827
671
|
modalOverlay: {
|
|
828
672
|
flex: 1,
|
|
829
673
|
justifyContent: "center",
|
|
@@ -847,13 +691,14 @@ var ModalDropdown = ({
|
|
|
847
691
|
variant,
|
|
848
692
|
renderTrigger,
|
|
849
693
|
optionTestID,
|
|
850
|
-
menuMinWidth
|
|
694
|
+
menuMinWidth,
|
|
695
|
+
showCaret = false
|
|
851
696
|
}) => {
|
|
852
697
|
const { theme, t } = uiFeedback.useUi();
|
|
853
698
|
const { colors } = theme;
|
|
854
699
|
const resolvedVariant = useResolvedDropdownVariant(variant);
|
|
855
700
|
const isMenu = resolvedVariant === "menu" /* Menu */;
|
|
856
|
-
const [isOpen, setIsOpen] =
|
|
701
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
857
702
|
const { a11yProps, hintNode } = a11y.useA11y({
|
|
858
703
|
label: accessibilityLabel,
|
|
859
704
|
hint: accessibilityHint,
|
|
@@ -861,43 +706,54 @@ var ModalDropdown = ({
|
|
|
861
706
|
state: { expanded: isOpen },
|
|
862
707
|
testID
|
|
863
708
|
});
|
|
864
|
-
const anchorRef =
|
|
865
|
-
const dialogRef =
|
|
709
|
+
const anchorRef = React9.useRef(null);
|
|
710
|
+
const dialogRef = React9.useRef(null);
|
|
866
711
|
useFocusTrap(dialogRef, isOpen && !isMenu);
|
|
867
|
-
const selectedLabel =
|
|
712
|
+
const selectedLabel = React9.useMemo(() => {
|
|
868
713
|
const found = options.find((opt) => opt.value === value);
|
|
869
714
|
return found?.label ?? t(LAYOUT_I18N.selectPlaceholder);
|
|
870
715
|
}, [options, value, t]);
|
|
871
|
-
const handleToggle =
|
|
716
|
+
const handleToggle = React9.useCallback(() => {
|
|
872
717
|
setIsOpen((prev) => !prev);
|
|
873
718
|
}, []);
|
|
874
|
-
const handleClose =
|
|
719
|
+
const handleClose = React9.useCallback(() => {
|
|
875
720
|
setIsOpen(false);
|
|
876
721
|
}, []);
|
|
877
|
-
const handleSelect =
|
|
722
|
+
const handleSelect = React9.useCallback(
|
|
878
723
|
(optionValue) => {
|
|
879
724
|
onChange(optionValue);
|
|
880
725
|
setIsOpen(false);
|
|
881
726
|
},
|
|
882
727
|
[onChange]
|
|
883
728
|
);
|
|
884
|
-
const containerStyle =
|
|
885
|
-
() => renderTrigger !== void 0 ? void 0 : [
|
|
886
|
-
|
|
729
|
+
const containerStyle = React9.useMemo(
|
|
730
|
+
() => renderTrigger !== void 0 ? void 0 : [
|
|
731
|
+
styles7.container,
|
|
732
|
+
showCaret ? styles7.containerMenu : null,
|
|
733
|
+
{ borderColor: colors.border, backgroundColor: colors.surface }
|
|
734
|
+
],
|
|
735
|
+
[colors.border, colors.surface, renderTrigger, showCaret]
|
|
736
|
+
);
|
|
737
|
+
const caretStyle = React9.useMemo(
|
|
738
|
+
() => [
|
|
739
|
+
styles7.caret,
|
|
740
|
+
{ color: colors.textSecondary, transform: [{ rotate: isOpen ? CARET_OPEN_ROTATION : CARET_CLOSED_ROTATION }] }
|
|
741
|
+
],
|
|
742
|
+
[colors.textSecondary, isOpen]
|
|
887
743
|
);
|
|
888
|
-
const optionTestIDFor =
|
|
744
|
+
const optionTestIDFor = React9.useCallback(
|
|
889
745
|
(optionValue) => optionTestID !== void 0 ? optionTestID(optionValue) : `${testID}-option-${String(optionValue)}`,
|
|
890
746
|
[optionTestID, testID]
|
|
891
747
|
);
|
|
892
|
-
const anchorStyle =
|
|
893
|
-
() => [
|
|
748
|
+
const anchorStyle = React9.useMemo(
|
|
749
|
+
() => [styles7.anchor, buildAnchorStackStyle(isMenu && isOpen)],
|
|
894
750
|
[isMenu, isOpen]
|
|
895
751
|
);
|
|
896
|
-
const modalContentStyle =
|
|
897
|
-
() => [
|
|
752
|
+
const modalContentStyle = React9.useMemo(
|
|
753
|
+
() => [styles7.modalContent, { backgroundColor: colors.surface }],
|
|
898
754
|
[colors.surface]
|
|
899
755
|
);
|
|
900
|
-
const renderModalOption =
|
|
756
|
+
const renderModalOption = React9.useCallback(
|
|
901
757
|
({ item }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
902
758
|
OptionRow,
|
|
903
759
|
{
|
|
@@ -909,10 +765,13 @@ var ModalDropdown = ({
|
|
|
909
765
|
),
|
|
910
766
|
[handleSelect, optionTestIDFor, value]
|
|
911
767
|
);
|
|
912
|
-
const keyExtractor =
|
|
768
|
+
const keyExtractor = React9.useCallback((item) => String(item.value), []);
|
|
913
769
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyle, children: [
|
|
914
770
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, style: containerStyle, onPress: handleToggle, children: [
|
|
915
|
-
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : /* @__PURE__ */ jsxRuntime.
|
|
771
|
+
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : showCaret ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
772
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles7.selectedText, styles7.selectedTextMenu, { color: colors.text }], children: selectedLabel }),
|
|
773
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: caretStyle, children: CARET_GLYPH })
|
|
774
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles7.selectedText, { color: colors.text }], children: selectedLabel }),
|
|
916
775
|
hintNode
|
|
917
776
|
] }),
|
|
918
777
|
isMenu && isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -929,7 +788,7 @@ var ModalDropdown = ({
|
|
|
929
788
|
onSelect: handleSelect
|
|
930
789
|
}
|
|
931
790
|
) : null,
|
|
932
|
-
!isMenu ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, animationType: "fade", visible: isOpen, onRequestClose: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
791
|
+
!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
792
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
934
793
|
reactNative.TouchableOpacity,
|
|
935
794
|
{
|
|
@@ -957,6 +816,259 @@ var ModalDropdown = ({
|
|
|
957
816
|
] }) }) : null
|
|
958
817
|
] });
|
|
959
818
|
};
|
|
819
|
+
var TabsMenu = ({
|
|
820
|
+
tabs,
|
|
821
|
+
activeKey,
|
|
822
|
+
onChange,
|
|
823
|
+
accessibilityLabel,
|
|
824
|
+
idPrefix,
|
|
825
|
+
testID
|
|
826
|
+
}) => {
|
|
827
|
+
const { t } = uiFeedback.useUi();
|
|
828
|
+
const options = React9.useMemo(
|
|
829
|
+
() => tabs.map((tab) => ({ label: tab.label, value: tab.key })),
|
|
830
|
+
[tabs]
|
|
831
|
+
);
|
|
832
|
+
const optionTestID = React9.useCallback(
|
|
833
|
+
(key) => {
|
|
834
|
+
const found = tabs.find((tab) => tab.key === key);
|
|
835
|
+
return found?.testID ?? `${idPrefix}-tab-${key}`;
|
|
836
|
+
},
|
|
837
|
+
[tabs, idPrefix]
|
|
838
|
+
);
|
|
839
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
840
|
+
ModalDropdown,
|
|
841
|
+
{
|
|
842
|
+
accessibilityHint: t(LAYOUT_I18N.tabsMenuHint),
|
|
843
|
+
accessibilityLabel,
|
|
844
|
+
optionTestID,
|
|
845
|
+
options,
|
|
846
|
+
showCaret: true,
|
|
847
|
+
testID,
|
|
848
|
+
value: activeKey,
|
|
849
|
+
onChange
|
|
850
|
+
}
|
|
851
|
+
);
|
|
852
|
+
};
|
|
853
|
+
var TABS_COLLAPSE_BREAKPOINT = MENU_BREAKPOINT;
|
|
854
|
+
var WEB_PLATFORM2 = "web";
|
|
855
|
+
function shouldCollapseTabs(width, platformOS, breakpoint) {
|
|
856
|
+
const isWideWeb = platformOS === WEB_PLATFORM2 && width >= breakpoint;
|
|
857
|
+
return !isWideWeb;
|
|
858
|
+
}
|
|
859
|
+
function useTabsCollapsed(breakpoint) {
|
|
860
|
+
const { width } = reactNative.useWindowDimensions();
|
|
861
|
+
return shouldCollapseTabs(width, reactNative.Platform.OS, breakpoint);
|
|
862
|
+
}
|
|
863
|
+
var PILL_RADIUS = 999;
|
|
864
|
+
var PILL_PAD_H = 16;
|
|
865
|
+
var PILL_PAD_V = 8;
|
|
866
|
+
var PILL_MIN_HEIGHT = 40;
|
|
867
|
+
var PILL_FONT = 14;
|
|
868
|
+
var PILL_WEIGHT = "600";
|
|
869
|
+
var ROW_GAP = 8;
|
|
870
|
+
var COLUMN_GAP = 8;
|
|
871
|
+
var ROW_PAD_V = 8;
|
|
872
|
+
var PANEL_PAD_TOP = 16;
|
|
873
|
+
var BORDER_WIDTH5 = 1;
|
|
874
|
+
var TEXT_ON_PRIMARY = "#ffffff";
|
|
875
|
+
var styles8 = reactNative.StyleSheet.create({
|
|
876
|
+
root: {
|
|
877
|
+
width: "100%"
|
|
878
|
+
},
|
|
879
|
+
// The full-width rule under the row lives here (not on the strip) so it spans the
|
|
880
|
+
// whole width even when the tabs are narrower than the viewport (desktop) and is
|
|
881
|
+
// not clipped to the scroll content width.
|
|
882
|
+
stripOuter: {
|
|
883
|
+
width: "100%",
|
|
884
|
+
borderBottomWidth: BORDER_WIDTH5
|
|
885
|
+
},
|
|
886
|
+
strip: {
|
|
887
|
+
flexDirection: "row",
|
|
888
|
+
flexWrap: "nowrap",
|
|
889
|
+
alignItems: "center",
|
|
890
|
+
columnGap: COLUMN_GAP,
|
|
891
|
+
rowGap: ROW_GAP,
|
|
892
|
+
paddingVertical: ROW_PAD_V
|
|
893
|
+
},
|
|
894
|
+
pill: {
|
|
895
|
+
// Keep each pill at its natural size so the row scrolls instead of squashing
|
|
896
|
+
// the tabs when they don't all fit.
|
|
897
|
+
flexShrink: 0,
|
|
898
|
+
paddingHorizontal: PILL_PAD_H,
|
|
899
|
+
paddingVertical: PILL_PAD_V,
|
|
900
|
+
borderRadius: PILL_RADIUS,
|
|
901
|
+
minHeight: PILL_MIN_HEIGHT,
|
|
902
|
+
flexDirection: "row",
|
|
903
|
+
alignItems: "center",
|
|
904
|
+
justifyContent: "center"
|
|
905
|
+
},
|
|
906
|
+
pillText: {
|
|
907
|
+
fontSize: PILL_FONT,
|
|
908
|
+
fontWeight: PILL_WEIGHT,
|
|
909
|
+
textAlign: "center"
|
|
910
|
+
},
|
|
911
|
+
panel: {
|
|
912
|
+
paddingTop: PANEL_PAD_TOP
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
function ariaTabProps(selected, panelId, tabId) {
|
|
916
|
+
return { "aria-selected": selected, "aria-controls": panelId, id: tabId };
|
|
917
|
+
}
|
|
918
|
+
var WideTabStrip = ({
|
|
919
|
+
tabs,
|
|
920
|
+
activeKey,
|
|
921
|
+
onChange,
|
|
922
|
+
accessibilityLabel,
|
|
923
|
+
idPrefix,
|
|
924
|
+
borderColor,
|
|
925
|
+
primaryColor,
|
|
926
|
+
textSecondary,
|
|
927
|
+
surfaceElevated,
|
|
928
|
+
stripStyle
|
|
929
|
+
}) => /* @__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) => {
|
|
930
|
+
const selected = tab.key === activeKey;
|
|
931
|
+
const textColor = selected ? TEXT_ON_PRIMARY : textSecondary;
|
|
932
|
+
const pillColor = selected ? primaryColor : surfaceElevated;
|
|
933
|
+
const tabId = `${idPrefix}-tab-${tab.key}`;
|
|
934
|
+
const panelId = `${idPrefix}-panel-${tab.key}`;
|
|
935
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
936
|
+
reactNative.Pressable,
|
|
937
|
+
{
|
|
938
|
+
accessibilityRole: "tab",
|
|
939
|
+
accessibilityState: { selected },
|
|
940
|
+
accessibilityLabel: tab.accessibilityLabel ?? tab.label,
|
|
941
|
+
accessibilityHint: tab.accessibilityHint,
|
|
942
|
+
onPress: () => onChange(tab.key),
|
|
943
|
+
style: [styles8.pill, { backgroundColor: pillColor }],
|
|
944
|
+
testID: tab.testID,
|
|
945
|
+
...ariaTabProps(selected, panelId, tabId),
|
|
946
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.pillText, { color: textColor }], children: tab.label })
|
|
947
|
+
},
|
|
948
|
+
tab.key
|
|
949
|
+
);
|
|
950
|
+
}) }) }) });
|
|
951
|
+
var Tabs = ({
|
|
952
|
+
tabs,
|
|
953
|
+
activeKey,
|
|
954
|
+
onChange,
|
|
955
|
+
accessibilityLabel,
|
|
956
|
+
children,
|
|
957
|
+
idPrefix = "tabs",
|
|
958
|
+
collapseBelow = TABS_COLLAPSE_BREAKPOINT,
|
|
959
|
+
style,
|
|
960
|
+
stripStyle,
|
|
961
|
+
panelStyle,
|
|
962
|
+
testID
|
|
963
|
+
}) => {
|
|
964
|
+
const { theme } = uiFeedback.useUi();
|
|
965
|
+
const { colors } = theme;
|
|
966
|
+
const collapsed = useTabsCollapsed(collapseBelow);
|
|
967
|
+
const activePanelId = `${idPrefix}-panel-${activeKey}`;
|
|
968
|
+
const activeTabId = `${idPrefix}-tab-${activeKey}`;
|
|
969
|
+
const panelAria = { "aria-labelledby": activeTabId, id: activePanelId };
|
|
970
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles8.root, style], testID, children: [
|
|
971
|
+
collapsed ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
972
|
+
TabsMenu,
|
|
973
|
+
{
|
|
974
|
+
accessibilityLabel,
|
|
975
|
+
activeKey,
|
|
976
|
+
idPrefix,
|
|
977
|
+
tabs,
|
|
978
|
+
testID: `${idPrefix}-menu`,
|
|
979
|
+
onChange
|
|
980
|
+
}
|
|
981
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
982
|
+
WideTabStrip,
|
|
983
|
+
{
|
|
984
|
+
accessibilityLabel,
|
|
985
|
+
activeKey,
|
|
986
|
+
borderColor: colors.border,
|
|
987
|
+
idPrefix,
|
|
988
|
+
primaryColor: theme.palette.primary["500"],
|
|
989
|
+
stripStyle,
|
|
990
|
+
surfaceElevated: colors.surfaceElevated,
|
|
991
|
+
tabs,
|
|
992
|
+
textSecondary: colors.textSecondary,
|
|
993
|
+
onChange
|
|
994
|
+
}
|
|
995
|
+
),
|
|
996
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "none", style: [styles8.panel, panelStyle], ...panelAria, children })
|
|
997
|
+
] });
|
|
998
|
+
};
|
|
999
|
+
var PROMPT_PADDING = 20;
|
|
1000
|
+
var PROMPT_BORDER_RADIUS = 12;
|
|
1001
|
+
var PROMPT_BORDER_WIDTH = 1;
|
|
1002
|
+
var TITLE_FONT_SIZE = 16;
|
|
1003
|
+
var MESSAGE_FONT_SIZE = 14;
|
|
1004
|
+
var BUTTON_PADDING_V = 12;
|
|
1005
|
+
var BUTTON_BORDER_RADIUS = 8;
|
|
1006
|
+
var BUTTON_FONT_SIZE = 14;
|
|
1007
|
+
var DISMISS_FONT_SIZE = 13;
|
|
1008
|
+
var TITLE_MARGIN_BOTTOM = 8;
|
|
1009
|
+
var MESSAGE_MARGIN_BOTTOM = 16;
|
|
1010
|
+
var CTA_MARGIN_BOTTOM = 8;
|
|
1011
|
+
var styles9 = reactNative.StyleSheet.create({
|
|
1012
|
+
container: {
|
|
1013
|
+
padding: PROMPT_PADDING,
|
|
1014
|
+
borderRadius: PROMPT_BORDER_RADIUS,
|
|
1015
|
+
borderWidth: PROMPT_BORDER_WIDTH
|
|
1016
|
+
},
|
|
1017
|
+
title: { fontSize: TITLE_FONT_SIZE, fontWeight: "700", marginBottom: TITLE_MARGIN_BOTTOM },
|
|
1018
|
+
message: { fontSize: MESSAGE_FONT_SIZE, marginBottom: MESSAGE_MARGIN_BOTTOM },
|
|
1019
|
+
cta: { paddingVertical: BUTTON_PADDING_V, borderRadius: BUTTON_BORDER_RADIUS, alignItems: "center", marginBottom: CTA_MARGIN_BOTTOM },
|
|
1020
|
+
ctaText: { fontSize: BUTTON_FONT_SIZE, fontWeight: "700" },
|
|
1021
|
+
dismiss: { alignItems: "center", paddingVertical: BUTTON_PADDING_V },
|
|
1022
|
+
dismissText: { fontSize: DISMISS_FONT_SIZE }
|
|
1023
|
+
});
|
|
1024
|
+
var UpgradePrompt = ({
|
|
1025
|
+
requiredTier,
|
|
1026
|
+
currentTier,
|
|
1027
|
+
onDismiss,
|
|
1028
|
+
billingRoute = DEFAULT_BILLING_ROUTE
|
|
1029
|
+
}) => {
|
|
1030
|
+
const { theme, t, navigate } = uiFeedback.useUi();
|
|
1031
|
+
const colors = theme.colors;
|
|
1032
|
+
const primary = theme.palette.primary["500"];
|
|
1033
|
+
function handleUpgradePress() {
|
|
1034
|
+
if (typeof navigate === "function") navigate(billingRoute);
|
|
1035
|
+
}
|
|
1036
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1037
|
+
reactNative.View,
|
|
1038
|
+
{
|
|
1039
|
+
style: [styles9.container, { borderColor: primary, backgroundColor: colors.surface }],
|
|
1040
|
+
testID: LAYOUT_TEST_IDS.upgradePrompt,
|
|
1041
|
+
children: [
|
|
1042
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
|
|
1043
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
|
|
1044
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1045
|
+
reactNative.TouchableOpacity,
|
|
1046
|
+
{
|
|
1047
|
+
accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
|
|
1048
|
+
accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
|
|
1049
|
+
accessibilityRole: "button",
|
|
1050
|
+
style: [styles9.cta, { backgroundColor: primary }],
|
|
1051
|
+
testID: LAYOUT_TEST_IDS.upgradePromptCta,
|
|
1052
|
+
onPress: handleUpgradePress,
|
|
1053
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
|
|
1054
|
+
}
|
|
1055
|
+
),
|
|
1056
|
+
onDismiss ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1057
|
+
reactNative.TouchableOpacity,
|
|
1058
|
+
{
|
|
1059
|
+
accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
|
|
1060
|
+
accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
|
|
1061
|
+
accessibilityRole: "button",
|
|
1062
|
+
style: styles9.dismiss,
|
|
1063
|
+
testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
|
|
1064
|
+
onPress: onDismiss,
|
|
1065
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
|
|
1066
|
+
}
|
|
1067
|
+
) : null
|
|
1068
|
+
]
|
|
1069
|
+
}
|
|
1070
|
+
);
|
|
1071
|
+
};
|
|
960
1072
|
var CLOSE_ICON_SIZE = 18;
|
|
961
1073
|
var styles10 = reactNative.StyleSheet.create({
|
|
962
1074
|
container: {
|
|
@@ -982,7 +1094,7 @@ var ModalShell = ({
|
|
|
982
1094
|
showClose = true
|
|
983
1095
|
}) => {
|
|
984
1096
|
const { theme, t } = uiFeedback.useUi();
|
|
985
|
-
const containerStyle =
|
|
1097
|
+
const containerStyle = React9__default.default.useMemo(
|
|
986
1098
|
() => [styles10.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
987
1099
|
[theme.colors.background, contentStyle]
|
|
988
1100
|
);
|
|
@@ -1025,9 +1137,9 @@ var ModalShell = ({
|
|
|
1025
1137
|
}
|
|
1026
1138
|
);
|
|
1027
1139
|
};
|
|
1028
|
-
var AccordionContext =
|
|
1140
|
+
var AccordionContext = React9.createContext(null);
|
|
1029
1141
|
function useAccordionContext() {
|
|
1030
|
-
const value =
|
|
1142
|
+
const value = React9.useContext(AccordionContext);
|
|
1031
1143
|
if (value === null) {
|
|
1032
1144
|
throw new Error("AccordionItem must be rendered inside an <Accordion>.");
|
|
1033
1145
|
}
|
|
@@ -1060,8 +1172,8 @@ var styles11 = reactNative.StyleSheet.create({
|
|
|
1060
1172
|
});
|
|
1061
1173
|
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
1062
1174
|
const ids = new Set(defaultOpenIds ?? []);
|
|
1063
|
-
|
|
1064
|
-
if (!
|
|
1175
|
+
React9__default.default.Children.forEach(children, (child) => {
|
|
1176
|
+
if (!React9__default.default.isValidElement(child)) return;
|
|
1065
1177
|
const props = child.props;
|
|
1066
1178
|
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
1067
1179
|
ids.add(props.id);
|
|
@@ -1084,14 +1196,14 @@ var Accordion = ({
|
|
|
1084
1196
|
style
|
|
1085
1197
|
}) => {
|
|
1086
1198
|
const isControlled = openIds !== void 0;
|
|
1087
|
-
const [internalOpen, setInternalOpen] =
|
|
1199
|
+
const [internalOpen, setInternalOpen] = React9.useState(
|
|
1088
1200
|
() => computeInitialOpen(children, defaultOpenIds, allowMultiple)
|
|
1089
1201
|
);
|
|
1090
|
-
const openSet =
|
|
1202
|
+
const openSet = React9.useMemo(
|
|
1091
1203
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
1092
1204
|
[isControlled, openIds, internalOpen]
|
|
1093
1205
|
);
|
|
1094
|
-
const toggle =
|
|
1206
|
+
const toggle = React9.useCallback(
|
|
1095
1207
|
(id) => {
|
|
1096
1208
|
animateNextLayout();
|
|
1097
1209
|
const next = new Set(openSet);
|
|
@@ -1107,11 +1219,11 @@ var Accordion = ({
|
|
|
1107
1219
|
},
|
|
1108
1220
|
[allowMultiple, isControlled, onOpenChange, openSet]
|
|
1109
1221
|
);
|
|
1110
|
-
const contextValue =
|
|
1222
|
+
const contextValue = React9.useMemo(
|
|
1111
1223
|
() => ({ openIds: openSet, toggle, allowMultiple, variant }),
|
|
1112
1224
|
[openSet, toggle, allowMultiple, variant]
|
|
1113
1225
|
);
|
|
1114
|
-
const containerStyle =
|
|
1226
|
+
const containerStyle = React9.useMemo(() => {
|
|
1115
1227
|
const base = variant === "boxed" ? [styles11.container, styles11.boxed] : [styles11.container];
|
|
1116
1228
|
if (style === void 0) return base;
|
|
1117
1229
|
return [...base, ...Array.isArray(style) ? style : [style]];
|
|
@@ -1188,9 +1300,9 @@ var AccordionItem = ({
|
|
|
1188
1300
|
const headerTestID = testID ?? `accordion-item-${id}`;
|
|
1189
1301
|
const bodyTestID = `${headerTestID}-body`;
|
|
1190
1302
|
const chevronTestID = `${headerTestID}-chevron`;
|
|
1191
|
-
const [rotation] =
|
|
1303
|
+
const [rotation] = React9.useState(() => new reactNative.Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
|
|
1192
1304
|
const reducedMotion = rnWebHooks.useReducedMotion();
|
|
1193
|
-
|
|
1305
|
+
React9.useEffect(() => {
|
|
1194
1306
|
reactNative.Animated.timing(rotation, {
|
|
1195
1307
|
toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
|
|
1196
1308
|
duration: reducedMotion ? INSTANT_DURATION_MS : ROTATE_DURATION_MS,
|
|
@@ -1202,10 +1314,10 @@ var AccordionItem = ({
|
|
|
1202
1314
|
inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
|
|
1203
1315
|
outputRange: [COLLAPSED_DEG, boxed ? BOXED_EXPANDED_DEG : PLAIN_EXPANDED_DEG]
|
|
1204
1316
|
});
|
|
1205
|
-
const handlePress =
|
|
1317
|
+
const handlePress = React9.useCallback(() => {
|
|
1206
1318
|
if (!disabled) toggle(id);
|
|
1207
1319
|
}, [disabled, id, toggle]);
|
|
1208
|
-
const handleKeyDown2 =
|
|
1320
|
+
const handleKeyDown2 = React9.useCallback(
|
|
1209
1321
|
(event) => {
|
|
1210
1322
|
if (disabled) return;
|
|
1211
1323
|
const key = event.key ?? "";
|
|
@@ -1217,11 +1329,11 @@ var AccordionItem = ({
|
|
|
1217
1329
|
[disabled, id, toggle]
|
|
1218
1330
|
);
|
|
1219
1331
|
const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
1220
|
-
const itemStyle =
|
|
1332
|
+
const itemStyle = React9.useMemo(
|
|
1221
1333
|
() => boxed ? [styles12.boxItem, { borderColor: colors.border }] : [styles12.item, { borderTopColor: colors.border }],
|
|
1222
1334
|
[boxed, colors.border]
|
|
1223
1335
|
);
|
|
1224
|
-
const headerStyle =
|
|
1336
|
+
const headerStyle = React9.useMemo(
|
|
1225
1337
|
() => [
|
|
1226
1338
|
styles12.header,
|
|
1227
1339
|
...boxed ? [styles12.boxHeader] : [],
|
|
@@ -1324,14 +1436,14 @@ function measureParentInnerWidth(node) {
|
|
|
1324
1436
|
return Math.max(UNMEASURED, parent.clientWidth - padding);
|
|
1325
1437
|
}
|
|
1326
1438
|
function useAvailableWidth() {
|
|
1327
|
-
const [width, setWidth] =
|
|
1328
|
-
const nodeRef =
|
|
1329
|
-
const measureRef =
|
|
1439
|
+
const [width, setWidth] = React9.useState(UNMEASURED);
|
|
1440
|
+
const nodeRef = React9.useRef(null);
|
|
1441
|
+
const measureRef = React9.useCallback((node) => {
|
|
1330
1442
|
if (!IS_WEB3) return;
|
|
1331
1443
|
nodeRef.current = node;
|
|
1332
1444
|
if (nodeRef.current !== null) setWidth(measureParentInnerWidth(nodeRef.current));
|
|
1333
1445
|
}, []);
|
|
1334
|
-
|
|
1446
|
+
React9.useEffect(() => {
|
|
1335
1447
|
if (!IS_WEB3) return void 0;
|
|
1336
1448
|
const remeasure = () => {
|
|
1337
1449
|
const node = nodeRef.current;
|
|
@@ -1340,7 +1452,7 @@ function useAvailableWidth() {
|
|
|
1340
1452
|
window.addEventListener("resize", remeasure);
|
|
1341
1453
|
return () => window.removeEventListener("resize", remeasure);
|
|
1342
1454
|
}, []);
|
|
1343
|
-
const onLayout =
|
|
1455
|
+
const onLayout = React9.useCallback((event) => {
|
|
1344
1456
|
if (IS_WEB3) return;
|
|
1345
1457
|
setWidth(event.nativeEvent.layout.width);
|
|
1346
1458
|
}, []);
|
|
@@ -1369,8 +1481,8 @@ var TruncatedText = ({
|
|
|
1369
1481
|
accessibilityHint
|
|
1370
1482
|
}) => {
|
|
1371
1483
|
const { width, measureRef, onLayout } = useAvailableWidth();
|
|
1372
|
-
const hostRef =
|
|
1373
|
-
const attachRef =
|
|
1484
|
+
const hostRef = React9.useRef(null);
|
|
1485
|
+
const attachRef = React9.useCallback(
|
|
1374
1486
|
(node) => {
|
|
1375
1487
|
hostRef.current = node;
|
|
1376
1488
|
measureRef(node);
|
|
@@ -1379,12 +1491,12 @@ var TruncatedText = ({
|
|
|
1379
1491
|
},
|
|
1380
1492
|
[value, measureRef]
|
|
1381
1493
|
);
|
|
1382
|
-
const flatStyle =
|
|
1494
|
+
const flatStyle = React9.useMemo(
|
|
1383
1495
|
() => reactNative.StyleSheet.flatten([styles13.base, style]),
|
|
1384
1496
|
[style]
|
|
1385
1497
|
);
|
|
1386
1498
|
const fontSize = flatStyle.fontSize ?? DEFAULT_FONT_SIZE2;
|
|
1387
|
-
const display =
|
|
1499
|
+
const display = React9.useMemo(() => {
|
|
1388
1500
|
const source = isUrl ? formatUrlForDisplay(value) : value;
|
|
1389
1501
|
const budget = charBudget(width, fontSize);
|
|
1390
1502
|
return budget === UNMEASURED2 ? source : truncateMiddle(source, budget);
|
|
@@ -1466,17 +1578,17 @@ async function copyText(value, writer) {
|
|
|
1466
1578
|
// src/CopyableId/useCopyToClipboard.ts
|
|
1467
1579
|
var COPY_FEEDBACK_MS = 2e3;
|
|
1468
1580
|
function useCopyToClipboard(value, writer) {
|
|
1469
|
-
const [status, setStatus] =
|
|
1470
|
-
const timerRef =
|
|
1471
|
-
const mountedRef =
|
|
1472
|
-
|
|
1581
|
+
const [status, setStatus] = React9.useState("idle" /* Idle */);
|
|
1582
|
+
const timerRef = React9.useRef(null);
|
|
1583
|
+
const mountedRef = React9.useRef(true);
|
|
1584
|
+
React9.useEffect(() => {
|
|
1473
1585
|
mountedRef.current = true;
|
|
1474
1586
|
return () => {
|
|
1475
1587
|
mountedRef.current = false;
|
|
1476
1588
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
1477
1589
|
};
|
|
1478
1590
|
}, []);
|
|
1479
|
-
const copy =
|
|
1591
|
+
const copy = React9.useCallback(() => {
|
|
1480
1592
|
void (async () => {
|
|
1481
1593
|
const ok = await copyText(value, writer);
|
|
1482
1594
|
if (!mountedRef.current) return;
|
|
@@ -1534,7 +1646,7 @@ var styles14 = reactNative.StyleSheet.create({
|
|
|
1534
1646
|
var TONE_STEP = "500";
|
|
1535
1647
|
function useActionState(status) {
|
|
1536
1648
|
const { theme } = uiFeedback.useUi();
|
|
1537
|
-
return
|
|
1649
|
+
return React9.useMemo(() => {
|
|
1538
1650
|
const primary = theme.palette.primary[TONE_STEP];
|
|
1539
1651
|
if (status === "copied" /* Copied */) {
|
|
1540
1652
|
return { key: LAYOUT_I18N.copied, color: theme.semantic.success?.[TONE_STEP] ?? primary };
|