@dloizides/ui-layout 1.30.0 → 1.31.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/dist/index.mjs CHANGED
@@ -408,11 +408,21 @@ var MenuHeading = ({ testID, text }) => {
408
408
  }
409
409
  );
410
410
  };
411
+
412
+ // src/ModalDropdown/SelectedMarker.ts
413
+ var SelectedMarker = /* @__PURE__ */ ((SelectedMarker2) => {
414
+ SelectedMarker2["Bold"] = "bold";
415
+ SelectedMarker2["AccentCheck"] = "accent-check";
416
+ return SelectedMarker2;
417
+ })(SelectedMarker || {});
411
418
  var OPTION_BORDER_RADIUS = 4;
412
419
  var BODY_FONT_SIZE = 14;
413
420
  var SELECTED_FONT_WEIGHT = "600";
414
421
  var OPTION_PADDING_H = 16;
415
422
  var OPTION_PADDING_V = 12;
423
+ var ACCENT_BAR_WIDTH = 3;
424
+ var CHECK_GAP = 8;
425
+ var CHECK_GLYPH = "\u2713";
416
426
  var styles6 = StyleSheet.create({
417
427
  option: {
418
428
  paddingHorizontal: OPTION_PADDING_H,
@@ -422,35 +432,63 @@ var styles6 = StyleSheet.create({
422
432
  borderRadius: OPTION_BORDER_RADIUS
423
433
  },
424
434
  optionText: { fontSize: BODY_FONT_SIZE },
425
- selectedText: { fontWeight: SELECTED_FONT_WEIGHT }
435
+ selectedText: { fontWeight: SELECTED_FONT_WEIGHT },
436
+ markedRow: {
437
+ flexDirection: "row",
438
+ alignItems: "center",
439
+ justifyContent: "space-between",
440
+ columnGap: CHECK_GAP,
441
+ borderLeftWidth: ACCENT_BAR_WIDTH,
442
+ borderLeftColor: "transparent",
443
+ paddingLeft: OPTION_PADDING_H - ACCENT_BAR_WIDTH
444
+ },
445
+ markedText: { flexShrink: 1 }
426
446
  });
427
447
  var OptionRow = ({
428
448
  testID,
429
449
  label,
430
450
  isSelected,
431
451
  isHighlighted = false,
432
- onSelect
452
+ onSelect,
453
+ selectedMarker = "bold" /* Bold */,
454
+ asMenuItem = false
433
455
  }) => {
434
456
  const { theme, t } = useUi();
435
457
  const { colors } = theme;
436
458
  const handlePress = useCallback(() => {
437
459
  onSelect();
438
460
  }, [onSelect]);
461
+ const accentColor = theme.palette.primary["500"];
462
+ const isMarked = selectedMarker === "accent-check" /* AccentCheck */;
439
463
  const isActive = isSelected || isHighlighted;
440
- const rowStyle = [styles6.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
441
- const textStyle = [styles6.optionText, { color: colors.text }, isSelected ? styles6.selectedText : null];
442
- return /* @__PURE__ */ jsx(
464
+ const rowStyle = [
465
+ styles6.option,
466
+ isMarked ? styles6.markedRow : null,
467
+ isActive ? { backgroundColor: colors.surfaceElevated } : null,
468
+ isMarked && isSelected ? { borderLeftColor: accentColor } : null
469
+ ];
470
+ const textStyle = [
471
+ styles6.optionText,
472
+ { color: colors.text },
473
+ isSelected ? styles6.selectedText : null,
474
+ isMarked ? styles6.markedText : null
475
+ ];
476
+ const selectionProps = asMenuItem ? { "aria-current": isSelected ? "true" : void 0 } : { "aria-selected": isSelected };
477
+ return /* @__PURE__ */ jsxs(
443
478
  TouchableOpacity,
444
479
  {
445
480
  accessible: true,
446
481
  accessibilityHint: t(LAYOUT_I18N.selectOptionHint),
447
482
  accessibilityLabel: label,
448
- accessibilityRole: "button",
449
- "aria-selected": isSelected,
483
+ accessibilityRole: asMenuItem ? "menuitem" : "button",
484
+ ...selectionProps,
450
485
  style: rowStyle,
451
486
  testID,
452
487
  onPress: handlePress,
453
- children: /* @__PURE__ */ jsx(Text, { style: textStyle, children: label })
488
+ children: [
489
+ /* @__PURE__ */ jsx(Text, { style: textStyle, children: label }),
490
+ isMarked && isSelected ? /* @__PURE__ */ jsx(View, { "aria-hidden": true, testID: `${testID}-check`, children: /* @__PURE__ */ jsx(Text, { style: [styles6.selectedText, { color: accentColor }], children: CHECK_GLYPH }) }) : null
491
+ ]
454
492
  }
455
493
  );
456
494
  };
@@ -644,6 +682,7 @@ var InlineMenu = ({
644
682
  menuMinWidth = 0,
645
683
  menuHeading,
646
684
  animatedStyle,
685
+ selectedMarker,
647
686
  onSelect,
648
687
  onClose
649
688
  }) => {
@@ -714,9 +753,11 @@ var InlineMenu = ({
714
753
  /* @__PURE__ */ jsx(ScrollView, { style: styles7.scroll, keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsx(
715
754
  OptionRow,
716
755
  {
756
+ asMenuItem: true,
717
757
  isHighlighted: index === highlightedIndex,
718
758
  isSelected: option.value === value,
719
759
  label: option.label,
760
+ selectedMarker,
720
761
  testID: optionTestID !== void 0 ? optionTestID(option.value) : `${testID}-option-${String(option.value)}`,
721
762
  onSelect: () => handleSelect(option.value)
722
763
  },
@@ -828,7 +869,8 @@ var ModalDropdown = ({
828
869
  menuMinWidth,
829
870
  showCaret = false,
830
871
  showHamburger = false,
831
- menuHeading
872
+ menuHeading,
873
+ selectedMarker
832
874
  }) => {
833
875
  const { theme, t } = useUi();
834
876
  const { colors } = theme;
@@ -843,6 +885,8 @@ var ModalDropdown = ({
843
885
  testID
844
886
  });
845
887
  const anchorRef = useRef(null);
888
+ const triggerRef = useRef(null);
889
+ const popupProps = { "aria-haspopup": isMenu ? "menu" : "dialog" };
846
890
  const dialogRef = useRef(null);
847
891
  useFocusTrap(dialogRef, isOpen && !isMenu);
848
892
  const menuAnim = useEnterExit({
@@ -869,6 +913,7 @@ var ModalDropdown = ({
869
913
  (optionValue) => {
870
914
  onChange(optionValue);
871
915
  setIsOpen(false);
916
+ triggerRef.current?.focus();
872
917
  },
873
918
  [onChange]
874
919
  );
@@ -911,15 +956,16 @@ var ModalDropdown = ({
911
956
  {
912
957
  isSelected: item.value === value,
913
958
  label: item.label,
959
+ selectedMarker,
914
960
  testID: optionTestIDFor(item.value),
915
961
  onSelect: () => handleSelect(item.value)
916
962
  }
917
963
  ),
918
- [handleSelect, optionTestIDFor, value]
964
+ [handleSelect, optionTestIDFor, selectedMarker, value]
919
965
  );
920
966
  const keyExtractor = useCallback((item) => String(item.value), []);
921
967
  return /* @__PURE__ */ jsxs(View, { ref: anchorRef, style: anchorStyle, children: [
922
- /* @__PURE__ */ jsxs(TouchableOpacity, { ...a11yProps, style: containerStyle, onPress: handleToggle, children: [
968
+ /* @__PURE__ */ jsxs(TouchableOpacity, { ...a11yProps, ...popupProps, ref: triggerRef, style: containerStyle, onPress: handleToggle, children: [
923
969
  renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : isHamburger ? /* @__PURE__ */ jsxs(Fragment, { children: [
924
970
  /* @__PURE__ */ jsx(Text, { style: hamburgerStyle, children: HAMBURGER_GLYPH }),
925
971
  /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles8.selectedText, styles8.selectedTextMenu, { color: colors.text }], children: selectedLabel })
@@ -940,6 +986,7 @@ var ModalDropdown = ({
940
986
  menuMinWidth,
941
987
  optionTestID: optionTestIDFor,
942
988
  options,
989
+ selectedMarker,
943
990
  testID,
944
991
  value,
945
992
  onClose: handleClose,
@@ -2156,6 +2203,6 @@ var BuildInfoFooter = ({
2156
2203
  );
2157
2204
  };
2158
2205
 
2159
- export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, BUILD_INFO_PREFIX, BuildInfoFooter, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, Heading, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, MIN_TARGET_PX, Modal3 as Modal, ModalDropdown, ModalShell, Section, SegmentedControl, StatusBadge, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TruncatedText, UpgradePrompt, copyText, formatBuildInfo, formatUrlForDisplay, isWideWebViewport, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap };
2206
+ export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, BUILD_INFO_PREFIX, BuildInfoFooter, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, Heading, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, MIN_TARGET_PX, Modal3 as Modal, ModalDropdown, ModalShell, Section, SegmentedControl, SelectedMarker, StatusBadge, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TruncatedText, UpgradePrompt, copyText, formatBuildInfo, formatUrlForDisplay, isWideWebViewport, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap };
2160
2207
  //# sourceMappingURL=index.mjs.map
2161
2208
  //# sourceMappingURL=index.mjs.map