@dloizides/ui-forms 1.49.0 → 1.51.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
@@ -1437,6 +1437,11 @@ var chipSizeStyles = StyleSheet.create({
1437
1437
  }
1438
1438
  });
1439
1439
 
1440
+ // src/ChipSelector/ChipSize.ts
1441
+ function isCompactSize(size) {
1442
+ return size === "compact" || size === "dense";
1443
+ }
1444
+
1440
1445
  // src/ChipSelector/utils/chipLook.ts
1441
1446
  function chipFill({ selected, selectedFill, ink, rest }) {
1442
1447
  if (!selected || selectedFill === void 0)
@@ -1444,10 +1449,17 @@ function chipFill({ selected, selectedFill, ink, rest }) {
1444
1449
  return { backgroundColor: selectedFill, textColor: ink, checkColor: ink };
1445
1450
  }
1446
1451
  function chipSizeLook(size) {
1447
- if (size !== "compact")
1452
+ if (!isCompactSize(size))
1448
1453
  return { hitBox: void 0, visual: void 0, text: void 0 };
1449
1454
  return { hitBox: chipSizeStyles.compactHitBox, visual: chipSizeStyles.compactVisual, text: chipSizeStyles.compactText };
1450
1455
  }
1456
+ var DENSE_ROW_GAP = { rowGap: 0 };
1457
+ function chipRowGap(size) {
1458
+ return size === "dense" ? DENSE_ROW_GAP : void 0;
1459
+ }
1460
+ function restBorderColor(colors, tone) {
1461
+ return tone === "strong" ? colors.borderStrong : colors.border;
1462
+ }
1451
1463
  var SOLID_RADIUS = 20;
1452
1464
  var OUTLINE_RADIUS = 999;
1453
1465
  var OUTLINE_PAD_H = 12;
@@ -1496,7 +1508,7 @@ function OutlineChip(props) {
1496
1508
  const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
1497
1509
  const [hovered, setHovered] = React39.useState(false);
1498
1510
  const active = selected || hovered;
1499
- const borderColor = active ? colors.primary : colors.border;
1511
+ const borderColor = active ? colors.primary : restBorderColor(colors, props.outlineTone);
1500
1512
  const fill = chipFill({
1501
1513
  selected,
1502
1514
  selectedFill: props.selectedFill,
@@ -1564,7 +1576,7 @@ function SolidChip(props) {
1564
1576
  testID,
1565
1577
  onPress,
1566
1578
  ...rovingTabStop,
1567
- children: /* @__PURE__ */ jsx(View, { style: [chipStyles.chip, sized.visual, { borderColor: colors.border, backgroundColor: fill.backgroundColor }, layout.boxStyle], children: /* @__PURE__ */ jsx(
1579
+ children: /* @__PURE__ */ jsx(View, { style: [chipStyles.chip, sized.visual, { borderColor: selected ? colors.border : restBorderColor(colors, props.outlineTone), backgroundColor: fill.backgroundColor }, layout.boxStyle], children: /* @__PURE__ */ jsx(
1568
1580
  ChipContent,
1569
1581
  {
1570
1582
  checkColor: fill.checkColor,
@@ -1662,6 +1674,7 @@ function buildChipColors(colors, palette) {
1662
1674
  const primary = palette.primary[500];
1663
1675
  return {
1664
1676
  border: colors.border,
1677
+ borderStrong: colors.textSecondary,
1665
1678
  textStrong: colors.text,
1666
1679
  textMuted: colors.textSecondary,
1667
1680
  primary,
@@ -1719,7 +1732,8 @@ var ChipSelector = ({
1719
1732
  optionAccessibilityHint,
1720
1733
  singleSelectRole = "button",
1721
1734
  size = "default",
1722
- selectedFill
1735
+ selectedFill,
1736
+ outlineTone = "default"
1723
1737
  }) => {
1724
1738
  const isRadioGroup = !multiple && singleSelectRole === "radio";
1725
1739
  const { theme } = useUi();
@@ -1746,6 +1760,7 @@ var ChipSelector = ({
1746
1760
  selected,
1747
1761
  size,
1748
1762
  selectedFill,
1763
+ outlineTone,
1749
1764
  ...chipIdentity(option, selected, {
1750
1765
  prefix: chipTestIDPrefix,
1751
1766
  hint: optionAccessibilityHint,
@@ -1774,7 +1789,7 @@ var ChipSelector = ({
1774
1789
  View,
1775
1790
  {
1776
1791
  accessibilityRole: isRadioGroup ? "radiogroup" : void 0,
1777
- style: styles13.chipContainer,
1792
+ style: [styles13.chipContainer, chipRowGap(size)],
1778
1793
  ...webFieldA11y({ describedById, hasError }),
1779
1794
  ...radio.groupProps,
1780
1795
  children: options.map(renderChip)
@@ -2109,11 +2124,18 @@ var NATIVE_SELECT_BOX = {
2109
2124
  fontFamily: "inherit",
2110
2125
  width: "100%"
2111
2126
  };
2112
- function nativeSelectStyle(borderColor, backgroundColor, color) {
2127
+ var FIT_SELECT_BOX = { width: "auto", maxWidth: "none" };
2128
+ var fitStyles = StyleSheet.create({
2129
+ anchor: { alignSelf: "flex-start", flexShrink: 0 }
2130
+ });
2131
+ function nativeSelectBox(fit) {
2132
+ return fit ? { ...NATIVE_SELECT_BOX, ...FIT_SELECT_BOX } : NATIVE_SELECT_BOX;
2133
+ }
2134
+ function nativeSelectStyle(fit, borderColor, backgroundColor, color) {
2113
2135
  const trigger = StyleSheet.flatten(controlStyles.selectTrigger);
2114
2136
  const text = StyleSheet.flatten(controlStyles.selectTriggerText);
2115
2137
  return {
2116
- ...NATIVE_SELECT_BOX,
2138
+ ...nativeSelectBox(fit),
2117
2139
  minHeight: trigger.minHeight,
2118
2140
  borderWidth: trigger.borderWidth,
2119
2141
  borderRadius: trigger.borderRadius,
@@ -2134,20 +2156,22 @@ function NativeSelect({
2134
2156
  accessibilityHint,
2135
2157
  labelledById,
2136
2158
  style,
2137
- testID
2159
+ testID,
2160
+ native
2138
2161
  }) {
2139
2162
  const { theme } = useUi();
2140
2163
  const { colors } = theme;
2141
2164
  const hasMatch = options.some((o) => o.value === value);
2142
2165
  const textColor = hasMatch ? colors.text : colors.textSecondary;
2166
+ const fit = native === "fit";
2143
2167
  const handleChange = (event) => onChange(event.target.value);
2144
- return /* @__PURE__ */ jsx(View, { style: [controlStyles.anchor, style], children: /* @__PURE__ */ jsxs(
2168
+ return /* @__PURE__ */ jsx(View, { style: [controlStyles.anchor, fit ? fitStyles.anchor : void 0, style], children: /* @__PURE__ */ jsxs(
2145
2169
  "select",
2146
2170
  {
2147
2171
  "aria-label": accessibilityLabel,
2148
2172
  "aria-labelledby": labelledById,
2149
2173
  "data-testid": testID,
2150
- style: nativeSelectStyle(colors.border, colors.surfaceElevated, textColor),
2174
+ style: nativeSelectStyle(fit, colors.border, colors.surfaceElevated, textColor),
2151
2175
  title: accessibilityHint,
2152
2176
  value,
2153
2177
  onChange: handleChange,
@@ -2201,7 +2225,7 @@ function listboxTriggerAria(testID, hasList, highlighted) {
2201
2225
  };
2202
2226
  }
2203
2227
  function SelectControl(props) {
2204
- return props.native === true && IS_WEB7 ? /* @__PURE__ */ jsx(NativeSelect, { ...props }) : /* @__PURE__ */ jsx(MenuSelectControl, { ...props });
2228
+ return (props.native === true || props.native === "fit") && IS_WEB7 ? /* @__PURE__ */ jsx(NativeSelect, { ...props }) : /* @__PURE__ */ jsx(MenuSelectControl, { ...props });
2205
2229
  }
2206
2230
  function MenuSelectControl({
2207
2231
  options,