@dloizides/ui-layout 1.0.1 → 1.2.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 +23 -0
- package/README.md +30 -1
- package/dist/index.d.mts +53 -5
- package/dist/index.d.ts +53 -5
- package/dist/index.js +325 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +326 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var React = 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');
|
|
7
|
+
var uiIcons = require('@dloizides/ui-icons');
|
|
7
8
|
|
|
8
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
|
|
@@ -32,7 +33,9 @@ var LAYOUT_TEST_IDS = {
|
|
|
32
33
|
statusLabel: "status-label",
|
|
33
34
|
upgradePrompt: "upgrade-prompt",
|
|
34
35
|
upgradePromptCta: "upgrade-prompt-cta",
|
|
35
|
-
upgradePromptDismiss: "upgrade-prompt-dismiss"
|
|
36
|
+
upgradePromptDismiss: "upgrade-prompt-dismiss",
|
|
37
|
+
modalShell: "template-modal",
|
|
38
|
+
modalShellClose: "cancel-button"
|
|
36
39
|
};
|
|
37
40
|
var DEFAULT_BILLING_ROUTE = "/settings/billing";
|
|
38
41
|
var styles2 = reactNative.StyleSheet.create({
|
|
@@ -213,24 +216,226 @@ function useFocusTrap(containerRef, enabled) {
|
|
|
213
216
|
};
|
|
214
217
|
}, [containerRef, enabled]);
|
|
215
218
|
}
|
|
216
|
-
|
|
217
|
-
|
|
219
|
+
|
|
220
|
+
// src/ModalDropdown/DropdownVariant.ts
|
|
221
|
+
var DropdownVariant = /* @__PURE__ */ ((DropdownVariant2) => {
|
|
222
|
+
DropdownVariant2["Menu"] = "menu";
|
|
223
|
+
DropdownVariant2["Modal"] = "modal";
|
|
224
|
+
return DropdownVariant2;
|
|
225
|
+
})(DropdownVariant || {});
|
|
218
226
|
var OPTION_BORDER_RADIUS = 4;
|
|
219
227
|
var BODY_FONT_SIZE = 14;
|
|
220
228
|
var SELECTED_FONT_WEIGHT = "600";
|
|
229
|
+
var OPTION_PADDING_H = 16;
|
|
230
|
+
var OPTION_PADDING_V = 12;
|
|
231
|
+
var styles5 = reactNative.StyleSheet.create({
|
|
232
|
+
option: {
|
|
233
|
+
paddingHorizontal: OPTION_PADDING_H,
|
|
234
|
+
paddingVertical: OPTION_PADDING_V,
|
|
235
|
+
borderRadius: OPTION_BORDER_RADIUS
|
|
236
|
+
},
|
|
237
|
+
optionText: { fontSize: BODY_FONT_SIZE },
|
|
238
|
+
selectedText: { fontWeight: SELECTED_FONT_WEIGHT }
|
|
239
|
+
});
|
|
240
|
+
var OptionRow = ({
|
|
241
|
+
testID,
|
|
242
|
+
label,
|
|
243
|
+
isSelected,
|
|
244
|
+
isHighlighted = false,
|
|
245
|
+
onSelect
|
|
246
|
+
}) => {
|
|
247
|
+
const { theme, t } = uiFeedback.useUi();
|
|
248
|
+
const { colors } = theme;
|
|
249
|
+
const handlePress = React.useCallback(() => {
|
|
250
|
+
onSelect();
|
|
251
|
+
}, [onSelect]);
|
|
252
|
+
const isActive = isSelected || isHighlighted;
|
|
253
|
+
const rowStyle = [styles5.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
|
|
254
|
+
const textStyle = [styles5.optionText, { color: colors.text }, isSelected ? styles5.selectedText : null];
|
|
255
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
256
|
+
reactNative.TouchableOpacity,
|
|
257
|
+
{
|
|
258
|
+
accessible: true,
|
|
259
|
+
accessibilityHint: t("common.selectOptionHint"),
|
|
260
|
+
accessibilityLabel: label,
|
|
261
|
+
accessibilityRole: "button",
|
|
262
|
+
"aria-selected": isSelected,
|
|
263
|
+
style: rowStyle,
|
|
264
|
+
testID,
|
|
265
|
+
onPress: handlePress,
|
|
266
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: textStyle, children: label })
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
var clampIndex = (index, itemCount) => {
|
|
271
|
+
if (index < 0) return 0;
|
|
272
|
+
const lastIndex = itemCount - 1;
|
|
273
|
+
return index > lastIndex ? lastIndex : index;
|
|
274
|
+
};
|
|
275
|
+
function buildKeyHandler(params) {
|
|
276
|
+
const { itemCount, onHighlightChange, onSelectHighlighted, onClose } = params;
|
|
277
|
+
return (event) => {
|
|
278
|
+
switch (event.key) {
|
|
279
|
+
case "ArrowDown":
|
|
280
|
+
event.preventDefault();
|
|
281
|
+
onHighlightChange((prev) => clampIndex(prev + 1, itemCount));
|
|
282
|
+
return;
|
|
283
|
+
case "ArrowUp":
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
onHighlightChange((prev) => clampIndex(prev - 1, itemCount));
|
|
286
|
+
return;
|
|
287
|
+
case "Home":
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
onHighlightChange(() => 0);
|
|
290
|
+
return;
|
|
291
|
+
case "End":
|
|
292
|
+
event.preventDefault();
|
|
293
|
+
onHighlightChange(() => clampIndex(itemCount - 1, itemCount));
|
|
294
|
+
return;
|
|
295
|
+
case "Enter":
|
|
296
|
+
event.preventDefault();
|
|
297
|
+
onSelectHighlighted();
|
|
298
|
+
return;
|
|
299
|
+
case "Escape":
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
onClose();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function useMenuKeyboard(params) {
|
|
307
|
+
const { containerRef, enabled, onClose } = params;
|
|
308
|
+
React.useEffect(() => {
|
|
309
|
+
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
310
|
+
const onKeyDown = buildKeyHandler(params);
|
|
311
|
+
const onMouseDown = (event) => {
|
|
312
|
+
const node = containerRef.current;
|
|
313
|
+
const target = event.target instanceof Node ? event.target : null;
|
|
314
|
+
const clickedOutside = node !== null && (target === null || !node.contains(target));
|
|
315
|
+
if (clickedOutside) onClose();
|
|
316
|
+
};
|
|
317
|
+
document.addEventListener("keydown", onKeyDown);
|
|
318
|
+
document.addEventListener("mousedown", onMouseDown);
|
|
319
|
+
return () => {
|
|
320
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
321
|
+
document.removeEventListener("mousedown", onMouseDown);
|
|
322
|
+
};
|
|
323
|
+
}, [containerRef, enabled, onClose, params]);
|
|
324
|
+
}
|
|
325
|
+
var BORDER_RADIUS = 8;
|
|
326
|
+
var BORDER_WIDTH = 1;
|
|
327
|
+
var MENU_PADDING = 4;
|
|
328
|
+
var MENU_MAX_HEIGHT = 300;
|
|
329
|
+
var MENU_TOP_GAP = 4;
|
|
330
|
+
var MENU_Z_INDEX = 1e3;
|
|
331
|
+
var MENU_ELEVATION = 8;
|
|
332
|
+
var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
|
|
333
|
+
var styles6 = reactNative.StyleSheet.create({
|
|
334
|
+
popover: {
|
|
335
|
+
position: "absolute",
|
|
336
|
+
top: "100%",
|
|
337
|
+
left: 0,
|
|
338
|
+
right: 0,
|
|
339
|
+
marginTop: MENU_TOP_GAP,
|
|
340
|
+
zIndex: MENU_Z_INDEX,
|
|
341
|
+
borderWidth: BORDER_WIDTH,
|
|
342
|
+
borderRadius: BORDER_RADIUS,
|
|
343
|
+
padding: MENU_PADDING,
|
|
344
|
+
maxHeight: MENU_MAX_HEIGHT,
|
|
345
|
+
boxShadow: MENU_BOX_SHADOW,
|
|
346
|
+
elevation: MENU_ELEVATION
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
var InlineMenu = ({
|
|
350
|
+
testID,
|
|
351
|
+
accessibilityLabel,
|
|
352
|
+
value,
|
|
353
|
+
options,
|
|
354
|
+
containerRef,
|
|
355
|
+
onSelect,
|
|
356
|
+
onClose
|
|
357
|
+
}) => {
|
|
358
|
+
const { theme } = uiFeedback.useUi();
|
|
359
|
+
const { colors } = theme;
|
|
360
|
+
const selectedIndex = React.useMemo(
|
|
361
|
+
() => Math.max(0, options.findIndex((opt) => opt.value === value)),
|
|
362
|
+
[options, value]
|
|
363
|
+
);
|
|
364
|
+
const [highlightedIndex, setHighlightedIndex] = React.useState(() => selectedIndex);
|
|
365
|
+
const selectAt = React.useCallback(
|
|
366
|
+
(index) => {
|
|
367
|
+
const option = options[index];
|
|
368
|
+
if (option !== void 0) onSelect(option.value);
|
|
369
|
+
},
|
|
370
|
+
[options, onSelect]
|
|
371
|
+
);
|
|
372
|
+
const selectHighlighted = React.useCallback(
|
|
373
|
+
() => {
|
|
374
|
+
selectAt(highlightedIndex);
|
|
375
|
+
},
|
|
376
|
+
[selectAt, highlightedIndex]
|
|
377
|
+
);
|
|
378
|
+
useMenuKeyboard({
|
|
379
|
+
containerRef,
|
|
380
|
+
enabled: true,
|
|
381
|
+
itemCount: options.length,
|
|
382
|
+
onHighlightChange: setHighlightedIndex,
|
|
383
|
+
onSelectHighlighted: selectHighlighted,
|
|
384
|
+
onClose
|
|
385
|
+
});
|
|
386
|
+
const popoverStyle = React.useMemo(
|
|
387
|
+
() => [styles6.popover, { borderColor: colors.border, backgroundColor: colors.surface }],
|
|
388
|
+
[colors.border, colors.surface]
|
|
389
|
+
);
|
|
390
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
391
|
+
reactNative.View,
|
|
392
|
+
{
|
|
393
|
+
accessibilityRole: "menu",
|
|
394
|
+
"aria-label": accessibilityLabel,
|
|
395
|
+
style: popoverStyle,
|
|
396
|
+
testID: `${testID}-menu`,
|
|
397
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
398
|
+
OptionRow,
|
|
399
|
+
{
|
|
400
|
+
isHighlighted: index === highlightedIndex,
|
|
401
|
+
isSelected: option.value === value,
|
|
402
|
+
label: option.label,
|
|
403
|
+
testID: `${testID}-option-${String(option.value)}`,
|
|
404
|
+
onSelect: () => onSelect(option.value)
|
|
405
|
+
},
|
|
406
|
+
String(option.value)
|
|
407
|
+
)) })
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
};
|
|
411
|
+
var MENU_BREAKPOINT = 768;
|
|
412
|
+
var WEB_PLATFORM = "web";
|
|
413
|
+
function resolveDropdownVariant(explicit, width, platformOS) {
|
|
414
|
+
if (explicit !== void 0) return explicit;
|
|
415
|
+
const isWideWeb = platformOS === WEB_PLATFORM && width >= MENU_BREAKPOINT;
|
|
416
|
+
return isWideWeb ? "menu" /* Menu */ : "modal" /* Modal */;
|
|
417
|
+
}
|
|
418
|
+
function useResolvedDropdownVariant(explicit) {
|
|
419
|
+
const { width } = reactNative.useWindowDimensions();
|
|
420
|
+
return resolveDropdownVariant(explicit, width, reactNative.Platform.OS);
|
|
421
|
+
}
|
|
422
|
+
var BORDER_RADIUS2 = 8;
|
|
423
|
+
var BORDER_WIDTH2 = 1;
|
|
424
|
+
var BODY_FONT_SIZE2 = 14;
|
|
221
425
|
var MODAL_PADDING = 8;
|
|
222
426
|
var MODAL_MIN_WIDTH = 200;
|
|
223
427
|
var MODAL_MAX_HEIGHT = 300;
|
|
224
428
|
var CONTAINER_PADDING_H = 12;
|
|
225
429
|
var CONTAINER_PADDING_V = 10;
|
|
226
|
-
var
|
|
430
|
+
var styles7 = reactNative.StyleSheet.create({
|
|
431
|
+
anchor: { position: "relative" },
|
|
227
432
|
container: {
|
|
228
|
-
borderWidth:
|
|
229
|
-
borderRadius:
|
|
433
|
+
borderWidth: BORDER_WIDTH2,
|
|
434
|
+
borderRadius: BORDER_RADIUS2,
|
|
230
435
|
paddingHorizontal: CONTAINER_PADDING_H,
|
|
231
436
|
paddingVertical: CONTAINER_PADDING_V
|
|
232
437
|
},
|
|
233
|
-
selectedText: { fontSize:
|
|
438
|
+
selectedText: { fontSize: BODY_FONT_SIZE2 },
|
|
234
439
|
modalOverlay: {
|
|
235
440
|
flex: 1,
|
|
236
441
|
justifyContent: "center",
|
|
@@ -238,18 +443,11 @@ var styles5 = reactNative.StyleSheet.create({
|
|
|
238
443
|
backgroundColor: uiFeedback.MODAL_OVERLAY_COLOR
|
|
239
444
|
},
|
|
240
445
|
modalContent: {
|
|
241
|
-
borderRadius:
|
|
446
|
+
borderRadius: BORDER_RADIUS2,
|
|
242
447
|
padding: MODAL_PADDING,
|
|
243
448
|
minWidth: MODAL_MIN_WIDTH,
|
|
244
449
|
maxHeight: MODAL_MAX_HEIGHT
|
|
245
|
-
}
|
|
246
|
-
option: {
|
|
247
|
-
paddingHorizontal: 16,
|
|
248
|
-
paddingVertical: 12,
|
|
249
|
-
borderRadius: OPTION_BORDER_RADIUS
|
|
250
|
-
},
|
|
251
|
-
optionText: { fontSize: BODY_FONT_SIZE },
|
|
252
|
-
selectedOption: { fontWeight: SELECTED_FONT_WEIGHT }
|
|
450
|
+
}
|
|
253
451
|
});
|
|
254
452
|
var ModalDropdown = ({
|
|
255
453
|
testID,
|
|
@@ -257,19 +455,23 @@ var ModalDropdown = ({
|
|
|
257
455
|
accessibilityHint,
|
|
258
456
|
value,
|
|
259
457
|
options,
|
|
260
|
-
onChange
|
|
458
|
+
onChange,
|
|
459
|
+
variant
|
|
261
460
|
}) => {
|
|
262
461
|
const { theme, t } = uiFeedback.useUi();
|
|
263
462
|
const { colors } = theme;
|
|
463
|
+
const resolvedVariant = useResolvedDropdownVariant(variant);
|
|
464
|
+
const isMenu = resolvedVariant === "menu" /* Menu */;
|
|
264
465
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
466
|
+
const anchorRef = React.useRef(null);
|
|
265
467
|
const dialogRef = React.useRef(null);
|
|
266
|
-
useFocusTrap(dialogRef, isOpen);
|
|
468
|
+
useFocusTrap(dialogRef, isOpen && !isMenu);
|
|
267
469
|
const selectedLabel = React.useMemo(() => {
|
|
268
470
|
const found = options.find((opt) => opt.value === value);
|
|
269
471
|
return found?.label ?? t("common.selectPlaceholder");
|
|
270
472
|
}, [options, value, t]);
|
|
271
|
-
const
|
|
272
|
-
setIsOpen(
|
|
473
|
+
const handleToggle = React.useCallback(() => {
|
|
474
|
+
setIsOpen((prev) => !prev);
|
|
273
475
|
}, []);
|
|
274
476
|
const handleClose = React.useCallback(() => {
|
|
275
477
|
setIsOpen(false);
|
|
@@ -282,44 +484,27 @@ var ModalDropdown = ({
|
|
|
282
484
|
[onChange]
|
|
283
485
|
);
|
|
284
486
|
const containerStyle = React.useMemo(
|
|
285
|
-
() => [
|
|
487
|
+
() => [styles7.container, { borderColor: colors.border, backgroundColor: colors.surface }],
|
|
286
488
|
[colors.border, colors.surface]
|
|
287
489
|
);
|
|
288
490
|
const modalContentStyle = React.useMemo(
|
|
289
|
-
() => [
|
|
491
|
+
() => [styles7.modalContent, { backgroundColor: colors.surface }],
|
|
290
492
|
[colors.surface]
|
|
291
493
|
);
|
|
292
|
-
const
|
|
293
|
-
({ item }) =>
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
testID: `${testID}-option-${String(item.value)}`,
|
|
304
|
-
onPress: () => handleSelect(item.value),
|
|
305
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
306
|
-
reactNative.Text,
|
|
307
|
-
{
|
|
308
|
-
style: [
|
|
309
|
-
styles5.optionText,
|
|
310
|
-
{ color: colors.text },
|
|
311
|
-
isSelected ? styles5.selectedOption : null
|
|
312
|
-
],
|
|
313
|
-
children: item.label
|
|
314
|
-
}
|
|
315
|
-
)
|
|
316
|
-
}
|
|
317
|
-
);
|
|
318
|
-
},
|
|
319
|
-
[colors.surfaceElevated, colors.text, handleSelect, testID, value, t]
|
|
494
|
+
const renderModalOption = React.useCallback(
|
|
495
|
+
({ item }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
496
|
+
OptionRow,
|
|
497
|
+
{
|
|
498
|
+
isSelected: item.value === value,
|
|
499
|
+
label: item.label,
|
|
500
|
+
testID: `${testID}-option-${String(item.value)}`,
|
|
501
|
+
onSelect: () => handleSelect(item.value)
|
|
502
|
+
}
|
|
503
|
+
),
|
|
504
|
+
[handleSelect, testID, value]
|
|
320
505
|
);
|
|
321
506
|
const keyExtractor = React.useCallback((item) => String(item.value), []);
|
|
322
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
507
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles7.anchor, children: [
|
|
323
508
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
324
509
|
reactNative.TouchableOpacity,
|
|
325
510
|
{
|
|
@@ -327,13 +512,26 @@ var ModalDropdown = ({
|
|
|
327
512
|
accessibilityHint,
|
|
328
513
|
accessibilityLabel,
|
|
329
514
|
accessibilityRole: "button",
|
|
515
|
+
"aria-expanded": isOpen,
|
|
330
516
|
style: containerStyle,
|
|
331
517
|
testID,
|
|
332
|
-
onPress:
|
|
333
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
518
|
+
onPress: handleToggle,
|
|
519
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles7.selectedText, { color: colors.text }], children: selectedLabel })
|
|
334
520
|
}
|
|
335
521
|
),
|
|
336
|
-
|
|
522
|
+
isMenu && isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
523
|
+
InlineMenu,
|
|
524
|
+
{
|
|
525
|
+
accessibilityLabel,
|
|
526
|
+
containerRef: anchorRef,
|
|
527
|
+
options,
|
|
528
|
+
testID,
|
|
529
|
+
value,
|
|
530
|
+
onClose: handleClose,
|
|
531
|
+
onSelect: handleSelect
|
|
532
|
+
}
|
|
533
|
+
) : null,
|
|
534
|
+
!isMenu ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, animationType: "fade", visible: isOpen, onRequestClose: handleClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
337
535
|
reactNative.TouchableOpacity,
|
|
338
536
|
{
|
|
339
537
|
accessible: true,
|
|
@@ -341,7 +539,7 @@ var ModalDropdown = ({
|
|
|
341
539
|
accessibilityLabel: t("common.dismissDropdown"),
|
|
342
540
|
accessibilityRole: "button",
|
|
343
541
|
activeOpacity: 1,
|
|
344
|
-
style:
|
|
542
|
+
style: styles7.modalOverlay,
|
|
345
543
|
testID: `${testID}-backdrop`,
|
|
346
544
|
onPress: handleClose,
|
|
347
545
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -352,25 +550,88 @@ var ModalDropdown = ({
|
|
|
352
550
|
"aria-label": accessibilityLabel,
|
|
353
551
|
role: "dialog",
|
|
354
552
|
style: modalContentStyle,
|
|
355
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
356
|
-
reactNative.FlatList,
|
|
357
|
-
{
|
|
358
|
-
data: [...options],
|
|
359
|
-
keyExtractor,
|
|
360
|
-
renderItem: renderOption
|
|
361
|
-
}
|
|
362
|
-
)
|
|
553
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.FlatList, { data: [...options], keyExtractor, renderItem: renderModalOption })
|
|
363
554
|
}
|
|
364
555
|
)
|
|
365
556
|
}
|
|
366
|
-
) })
|
|
557
|
+
) }) : null
|
|
367
558
|
] });
|
|
368
559
|
};
|
|
560
|
+
var CLOSE_ICON_SIZE = 18;
|
|
561
|
+
var styles8 = reactNative.StyleSheet.create({
|
|
562
|
+
container: {
|
|
563
|
+
flex: 1,
|
|
564
|
+
padding: 16
|
|
565
|
+
},
|
|
566
|
+
headerRow: {
|
|
567
|
+
flexDirection: "row",
|
|
568
|
+
alignItems: "center",
|
|
569
|
+
justifyContent: "space-between"
|
|
570
|
+
},
|
|
571
|
+
closeButton: {
|
|
572
|
+
padding: 6,
|
|
573
|
+
borderRadius: 6
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
var ModalShell = ({
|
|
577
|
+
visible,
|
|
578
|
+
onCancel,
|
|
579
|
+
title,
|
|
580
|
+
children,
|
|
581
|
+
contentStyle,
|
|
582
|
+
showClose = true
|
|
583
|
+
}) => {
|
|
584
|
+
const { theme, t } = uiFeedback.useUi();
|
|
585
|
+
const containerStyle = React__default.default.useMemo(
|
|
586
|
+
() => [styles8.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
587
|
+
[theme.colors.background, contentStyle]
|
|
588
|
+
);
|
|
589
|
+
const closeA11yLabel = t("quizTemplates.cancel");
|
|
590
|
+
const accessibleTitle = typeof title === "string" ? title : t("common.dialog");
|
|
591
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
592
|
+
reactNative.Modal,
|
|
593
|
+
{
|
|
594
|
+
animationType: "slide",
|
|
595
|
+
testID: LAYOUT_TEST_IDS.modalShell,
|
|
596
|
+
visible,
|
|
597
|
+
onRequestClose: onCancel,
|
|
598
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
599
|
+
reactNative.ScrollView,
|
|
600
|
+
{
|
|
601
|
+
accessibilityViewIsModal: true,
|
|
602
|
+
"aria-label": accessibleTitle,
|
|
603
|
+
role: "dialog",
|
|
604
|
+
style: containerStyle,
|
|
605
|
+
children: [
|
|
606
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles8.headerRow, children: [
|
|
607
|
+
/* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title ?? t("close") }),
|
|
608
|
+
showClose ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
609
|
+
reactNative.TouchableOpacity,
|
|
610
|
+
{
|
|
611
|
+
accessibilityHint: t("common.closeDialogHint"),
|
|
612
|
+
accessibilityLabel: closeA11yLabel,
|
|
613
|
+
accessibilityRole: "button",
|
|
614
|
+
style: styles8.closeButton,
|
|
615
|
+
testID: LAYOUT_TEST_IDS.modalShellClose,
|
|
616
|
+
onPress: onCancel,
|
|
617
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: theme.colors.textSecondary, name: "close", size: CLOSE_ICON_SIZE })
|
|
618
|
+
}
|
|
619
|
+
) : null
|
|
620
|
+
] }),
|
|
621
|
+
children
|
|
622
|
+
]
|
|
623
|
+
}
|
|
624
|
+
)
|
|
625
|
+
}
|
|
626
|
+
);
|
|
627
|
+
};
|
|
369
628
|
|
|
370
629
|
exports.DEFAULT_BILLING_ROUTE = DEFAULT_BILLING_ROUTE;
|
|
630
|
+
exports.DropdownVariant = DropdownVariant;
|
|
371
631
|
exports.Heading = Heading;
|
|
372
632
|
exports.LAYOUT_TEST_IDS = LAYOUT_TEST_IDS;
|
|
373
633
|
exports.ModalDropdown = ModalDropdown;
|
|
634
|
+
exports.ModalShell = ModalShell;
|
|
374
635
|
exports.Section = Section;
|
|
375
636
|
exports.StatusBadge = StatusBadge;
|
|
376
637
|
exports.UpgradePrompt = UpgradePrompt;
|