@dloizides/ui-tables 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/dist/index.mjs CHANGED
@@ -146,6 +146,11 @@ var StatCard = memo(({ label, value, testID }) => {
146
146
  );
147
147
  });
148
148
  StatCard.displayName = "StatCard";
149
+
150
+ // src/minTarget.ts
151
+ var MIN_TARGET_PX = 44;
152
+
153
+ // src/DataTable/styles.ts
149
154
  var BORDER_WIDTH = 1;
150
155
  var BORDER_RADIUS = 12;
151
156
  var COLUMN_GAP = 16;
@@ -177,7 +182,7 @@ var HEAD_LETTER_SPACING = 0.4;
177
182
  var LABEL_LETTER_SPACING = 0.3;
178
183
  var STICKY_Z = 2;
179
184
  var FULL_WIDTH = "100%";
180
- var SELECT_COL_WIDTH = 20;
185
+ var SELECT_COL_WIDTH = MIN_TARGET_PX;
181
186
  var CHECKBOX_SIZE = 18;
182
187
  var CHECKBOX_RADIUS = 4;
183
188
  var CHECKBOX_GLYPH_FONT = 11;
@@ -231,8 +236,8 @@ var tableStyles = StyleSheet.create({
231
236
  var selectionStyles = StyleSheet.create({
232
237
  /** The fixed-width gutter holding the checkbox, in both the header and every row. */
233
238
  selectCell: { width: SELECT_COL_WIDTH, alignItems: "flex-start", justifyContent: "center" },
234
- /** The checkbox's pressable area (the hit target is grown further with `hitSlop`). */
235
- checkboxHit: { alignItems: "center", justifyContent: "center" },
239
+ /** The checkbox's pressable area — a full 44x44 box around the 18px visual square. */
240
+ checkboxHit: { minWidth: MIN_TARGET_PX, minHeight: MIN_TARGET_PX, alignItems: "center", justifyContent: "center" },
236
241
  checkbox: {
237
242
  width: CHECKBOX_SIZE,
238
243
  height: CHECKBOX_SIZE,
@@ -260,6 +265,7 @@ var selectionStyles = StyleSheet.create({
260
265
  paddingVertical: BANNER_PAD_V
261
266
  },
262
267
  bannerText: { fontSize: BANNER_FONT },
268
+ bannerHit: { minHeight: MIN_TARGET_PX, justifyContent: "center" },
263
269
  bannerAction: { fontSize: BANNER_FONT, fontWeight: "700", textDecorationLine: "underline" }
264
270
  });
265
271
  var chromeStyles = StyleSheet.create({
@@ -274,19 +280,19 @@ var chromeStyles = StyleSheet.create({
274
280
  /** Mixed-case "Rows" caption for the dropdown variant (v1's muted `.hint` label — no uppercase transform). */
275
281
  pagerRowsLabelPlain: { fontSize: HEAD_FONT, letterSpacing: LABEL_LETTER_SPACING },
276
282
  sizeGroup: { flexDirection: "row", gap: PAGER_SIZE_GAP, alignItems: "center" },
277
- control: { paddingHorizontal: CONTROL_PAD_H, paddingVertical: CONTROL_PAD_V, borderRadius: BORDER_RADIUS, borderWidth: BORDER_WIDTH },
283
+ control: { minHeight: MIN_TARGET_PX, minWidth: MIN_TARGET_PX, alignItems: "center", justifyContent: "center", paddingHorizontal: CONTROL_PAD_H, paddingVertical: CONTROL_PAD_V, borderRadius: BORDER_RADIUS, borderWidth: BORDER_WIDTH },
278
284
  controlText: { fontSize: CONTROL_FONT, fontWeight: "600" },
279
- sizePill: { paddingHorizontal: CONTROL_PAD_H, paddingVertical: CONTROL_PAD_V, borderRadius: PILL_RADIUS, borderWidth: BORDER_WIDTH },
285
+ sizePill: { minHeight: MIN_TARGET_PX, minWidth: MIN_TARGET_PX, alignItems: "center", justifyContent: "center", paddingHorizontal: CONTROL_PAD_H, paddingVertical: CONTROL_PAD_V, borderRadius: PILL_RADIUS, borderWidth: BORDER_WIDTH },
280
286
  sizePillText: { fontSize: HEAD_FONT, fontWeight: "600", fontVariant: ["tabular-nums"] },
281
287
  /** Dropdown variant: relatively-positioned wrapper holding the trigger + the anchored popover. */
282
288
  sizeAnchor: { position: "relative" },
283
289
  /** Dropdown variant: the compact `<select>`-like trigger (bordered ghost look, height-matched to Prev/Next) + chevron. */
284
- sizeTrigger: { flexDirection: "row", alignItems: "center", gap: PAGER_SIZE_GAP, paddingHorizontal: CONTROL_PAD_H, paddingVertical: CONTROL_PAD_V, borderRadius: BORDER_RADIUS, borderWidth: BORDER_WIDTH },
290
+ sizeTrigger: { minHeight: MIN_TARGET_PX, minWidth: MIN_TARGET_PX, flexDirection: "row", alignItems: "center", justifyContent: "center", gap: PAGER_SIZE_GAP, paddingHorizontal: CONTROL_PAD_H, paddingVertical: CONTROL_PAD_V, borderRadius: BORDER_RADIUS, borderWidth: BORDER_WIDTH },
285
291
  sizeTriggerText: { fontSize: CONTROL_FONT, fontWeight: "600", fontVariant: ["tabular-nums"] },
286
292
  sizeChevron: { fontSize: CHEVRON_FONT },
287
293
  /** Dropdown variant: the anchored popover listing the rows-per-page options. */
288
294
  sizeMenu: { position: "absolute", top: "100%", right: 0, marginTop: MENU_TOP_GAP, minWidth: MENU_MIN_WIDTH, borderWidth: BORDER_WIDTH, borderRadius: BORDER_RADIUS, paddingVertical: MENU_PAD_V, zIndex: MENU_Z_INDEX, boxShadow: MENU_BOX_SHADOW, elevation: MENU_ELEVATION },
289
- sizeOption: { paddingHorizontal: CONTROL_PAD_H, paddingVertical: MENU_OPT_PAD_V },
295
+ sizeOption: { minHeight: MIN_TARGET_PX, justifyContent: "center", paddingHorizontal: CONTROL_PAD_H, paddingVertical: MENU_OPT_PAD_V },
290
296
  sizeOptionText: { fontSize: CONTROL_FONT, fontVariant: ["tabular-nums"] }
291
297
  });
292
298
  function cellContent(column, row, textColor, overrides) {
@@ -358,7 +364,6 @@ function RowCells({
358
364
  }
359
365
  var CHECK_GLYPH = "\u2713";
360
366
  var MIXED_GLYPH = "\u2013";
361
- var CHECKBOX_HIT_SLOP = { top: 12, bottom: 12, left: 12, right: 12 };
362
367
  var TRANSPARENT = "transparent";
363
368
  function toCheckedValue(state) {
364
369
  if (state === "all" /* All */) return true;
@@ -389,7 +394,6 @@ function SelectionCheckbox({
389
394
  accessibilityRole: "checkbox",
390
395
  accessibilityState: { checked },
391
396
  "aria-checked": checked,
392
- hitSlop: CHECKBOX_HIT_SLOP,
393
397
  style: selectionStyles.checkboxHit,
394
398
  testID,
395
399
  onPress: onToggle,
@@ -578,6 +582,7 @@ function SelectAllBanner({
578
582
  accessibilityRole: "button",
579
583
  testID: actionTestID,
580
584
  onPress: onAction,
585
+ style: selectionStyles.bannerHit,
581
586
  children: /* @__PURE__ */ jsx(Text, { style: [selectionStyles.bannerAction, { color: palette.primary["500"] }], children: actionLabel })
582
587
  }
583
588
  )
@@ -1160,7 +1165,6 @@ var FIRST_PAGE = 1;
1160
1165
  var DISABLED_OPACITY = 0.4;
1161
1166
  var FULL_OPACITY = 1;
1162
1167
  var TRANSPARENT2 = "transparent";
1163
- var PAGER_HIT_SLOP = { top: 10, bottom: 10 };
1164
1168
  function NavButton({ label, hint, disabled, onPress, color, border, testID, styleOverrides: o }) {
1165
1169
  return /* @__PURE__ */ jsx(
1166
1170
  Pressable,
@@ -1171,7 +1175,6 @@ function NavButton({ label, hint, disabled, onPress, color, border, testID, styl
1171
1175
  accessibilityHint: hint,
1172
1176
  accessibilityState: { disabled },
1173
1177
  disabled,
1174
- hitSlop: PAGER_HIT_SLOP,
1175
1178
  onPress,
1176
1179
  style: [chromeStyles.control, { borderColor: border, opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }, o?.control],
1177
1180
  children: /* @__PURE__ */ jsx(Text, { style: [chromeStyles.controlText, { color }, o?.controlText], children: label })
@@ -1221,7 +1224,6 @@ function RowsControl({ pageSize, pageSizeOptions, onPageSizeChange, isDropdown,
1221
1224
  accessibilityLabel: rowsOptionLabel(t, size),
1222
1225
  accessibilityHint: t(TABLE_I18N.pagerRowsOptionHint),
1223
1226
  accessibilityState: { selected: active },
1224
- hitSlop: PAGER_HIT_SLOP,
1225
1227
  onPress: () => onPageSizeChange(size),
1226
1228
  style: [chromeStyles.sizePill, { borderColor: active ? brand : colors.border, backgroundColor: active ? brand : TRANSPARENT2 }, o?.sizePill],
1227
1229
  children: /* @__PURE__ */ jsx(Text, { style: [chromeStyles.sizePillText, { color: active ? colors.surface : colors.textSecondary }, o?.sizePillText], children: size })
@@ -1398,11 +1400,14 @@ var filterStyles = StyleSheet.create({
1398
1400
  * six live portals, which this wave must not make.
1399
1401
  */
1400
1402
  fieldInBar: { marginBottom: NO_FORM_RHYTHM },
1401
- switchRow: { flexDirection: "row", alignItems: "center", gap: SWITCH_ROW_GAP, paddingVertical: FIELD_GAP },
1402
- action: { paddingHorizontal: ACTION_PAD_H, paddingVertical: ACTION_PAD_V, borderRadius: ACTION_RADIUS, borderWidth: ACTION_BORDER },
1403
+ switchRow: { minHeight: MIN_TARGET_PX, flexDirection: "row", alignItems: "center", gap: SWITCH_ROW_GAP, paddingVertical: FIELD_GAP },
1404
+ /** A 44x44 pressable around the switch: RN-web draws the Switch at 40x20 and that box IS its hit target. */
1405
+ switchHit: { minWidth: MIN_TARGET_PX, minHeight: MIN_TARGET_PX, alignItems: "center", justifyContent: "center" },
1406
+ /** The inner Switch takes no pointer events, so one tap toggles once (via `switchHit`), not twice. */
1407
+ switchInert: { pointerEvents: "none" },
1408
+ action: { minHeight: MIN_TARGET_PX, minWidth: MIN_TARGET_PX, alignItems: "center", justifyContent: "center", paddingHorizontal: ACTION_PAD_H, paddingVertical: ACTION_PAD_V, borderRadius: ACTION_RADIUS, borderWidth: ACTION_BORDER },
1403
1409
  actionText: { fontSize: ACTION_FONT, fontWeight: "600" }
1404
1410
  });
1405
- var FILTER_HIT_SLOP = { top: 8, bottom: 8 };
1406
1411
  var DISABLED_OPACITY2 = 0.4;
1407
1412
  var FULL_OPACITY2 = 1;
1408
1413
  var TRANSPARENT3 = "transparent";
@@ -1419,7 +1424,6 @@ function ActionButton({ label, hint, tone, disabled = false, onPress, testID })
1419
1424
  accessibilityHint: hint,
1420
1425
  accessibilityState: { disabled },
1421
1426
  disabled,
1422
- hitSlop: FILTER_HIT_SLOP,
1423
1427
  onPress,
1424
1428
  style: [
1425
1429
  filterStyles.action,
@@ -1471,17 +1475,28 @@ function BooleanField({ field, barTestID, value, onChange }) {
1471
1475
  return /* @__PURE__ */ jsxs(View, { style: filterStyles.switchRow, testID, children: [
1472
1476
  /* @__PURE__ */ jsx(Text, { style: [controlStyles.subLabel, { color: colors.text }], children: field.label }),
1473
1477
  /* @__PURE__ */ jsx(
1474
- Switch,
1478
+ Pressable,
1475
1479
  {
1476
- accessibilityLabel: field.label,
1477
- accessibilityHint: field.accessibilityHint,
1478
- accessibilityRole: "switch",
1479
- accessibilityState: { checked: value },
1480
- trackColor: { false: colors.border, true: palette.primary["500"] },
1481
- thumbColor: colors.surface,
1482
- value,
1483
- onValueChange: onChange,
1484
- testID: `${testID}-switch`
1480
+ accessible: false,
1481
+ focusable: false,
1482
+ onPress: () => onChange(!value),
1483
+ style: filterStyles.switchHit,
1484
+ testID: `${testID}-switch-hit`,
1485
+ children: /* @__PURE__ */ jsx(
1486
+ Switch,
1487
+ {
1488
+ accessibilityLabel: field.label,
1489
+ accessibilityHint: field.accessibilityHint,
1490
+ accessibilityRole: "switch",
1491
+ accessibilityState: { checked: value },
1492
+ trackColor: { false: colors.border, true: palette.primary["500"] },
1493
+ thumbColor: colors.surface,
1494
+ value,
1495
+ onValueChange: onChange,
1496
+ style: filterStyles.switchInert,
1497
+ testID: `${testID}-switch`
1498
+ }
1499
+ )
1485
1500
  }
1486
1501
  )
1487
1502
  ] });
@@ -1565,6 +1580,10 @@ function TypeaheadField({ field, barTestID, value, onChange, onSubmit, optionHin
1565
1580
  }
1566
1581
  );
1567
1582
  }
1583
+ function clampedMinWidth(minWidth) {
1584
+ if (Platform.OS !== "web") return minWidth;
1585
+ return `min(${minWidth}px, 100%)`;
1586
+ }
1568
1587
  var EMPTY_RANGE = { from: "", to: "" };
1569
1588
  var GROW_FLEX = 1;
1570
1589
  function asString(value) {
@@ -1648,7 +1667,7 @@ function FilterFieldView({ field, barTestID, values, setField, onSubmit, strings
1648
1667
  return /* @__PURE__ */ jsx(
1649
1668
  Field,
1650
1669
  {
1651
- containerStyle: [filterStyles.fieldInBar, { minWidth }, grow, field.style],
1670
+ containerStyle: [filterStyles.fieldInBar, { minWidth: clampedMinWidth(minWidth), maxWidth: "100%" }, grow, field.style],
1652
1671
  label: field.label,
1653
1672
  labelVariant: "control",
1654
1673
  testID: field.testID ?? fieldTestID(barTestID, field.key),