@dloizides/ui-tables 1.18.1 → 1.19.1

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,13 +265,21 @@ 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({
266
272
  filters: { flexDirection: "row", flexWrap: "wrap", alignItems: "flex-end", columnGap: COLUMN_GAP, rowGap: PAGER_GAP, borderWidth: BORDER_WIDTH, borderRadius: BORDER_RADIUS, paddingHorizontal: ROW_PAD_H, paddingVertical: ROW_PAD_V },
267
273
  filtersSpacer: { flexGrow: 1 },
268
274
  results: { fontSize: RESULTS_FONT },
269
- filtersActions: { flexDirection: "row", gap: PAGER_SIZE_GAP, alignItems: "center" },
275
+ /**
276
+ * The actions cluster WRAPS and is capped at the bar's width (TABLES-MOBILE-1 "Filter bar and
277
+ * pager overflow at 360"). A nowrap row is one unbreakable flex item: at 360 on aml-v2 Leaders
278
+ * it measured 431px inside a 255px bar and pushed Apply off-screen. `maxWidth: 100%` +
279
+ * `flexShrink` fit the cluster to its line; its own `flexWrap` then breaks the buttons onto
280
+ * further lines instead of overflowing (flex-shrink alone cannot: it never wraps a line).
281
+ */
282
+ filtersActions: { flexDirection: "row", flexWrap: "wrap", flexShrink: 1, maxWidth: "100%", rowGap: PAGER_GAP, columnGap: PAGER_SIZE_GAP, alignItems: "center" },
270
283
  pager: { flexDirection: "row", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: PAGER_GAP },
271
284
  pagerInfo: { fontSize: CONTROL_FONT, fontVariant: ["tabular-nums"] },
272
285
  pagerNav: { flexDirection: "row", alignItems: "center", gap: PAGER_SIZE_GAP, flexWrap: "wrap" },
@@ -274,19 +287,19 @@ var chromeStyles = StyleSheet.create({
274
287
  /** Mixed-case "Rows" caption for the dropdown variant (v1's muted `.hint` label — no uppercase transform). */
275
288
  pagerRowsLabelPlain: { fontSize: HEAD_FONT, letterSpacing: LABEL_LETTER_SPACING },
276
289
  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 },
290
+ 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
291
  controlText: { fontSize: CONTROL_FONT, fontWeight: "600" },
279
- sizePill: { paddingHorizontal: CONTROL_PAD_H, paddingVertical: CONTROL_PAD_V, borderRadius: PILL_RADIUS, borderWidth: BORDER_WIDTH },
292
+ 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
293
  sizePillText: { fontSize: HEAD_FONT, fontWeight: "600", fontVariant: ["tabular-nums"] },
281
294
  /** Dropdown variant: relatively-positioned wrapper holding the trigger + the anchored popover. */
282
295
  sizeAnchor: { position: "relative" },
283
296
  /** 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 },
297
+ 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
298
  sizeTriggerText: { fontSize: CONTROL_FONT, fontWeight: "600", fontVariant: ["tabular-nums"] },
286
299
  sizeChevron: { fontSize: CHEVRON_FONT },
287
300
  /** Dropdown variant: the anchored popover listing the rows-per-page options. */
288
301
  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 },
302
+ sizeOption: { minHeight: MIN_TARGET_PX, justifyContent: "center", paddingHorizontal: CONTROL_PAD_H, paddingVertical: MENU_OPT_PAD_V },
290
303
  sizeOptionText: { fontSize: CONTROL_FONT, fontVariant: ["tabular-nums"] }
291
304
  });
292
305
  function cellContent(column, row, textColor, overrides) {
@@ -358,7 +371,6 @@ function RowCells({
358
371
  }
359
372
  var CHECK_GLYPH = "\u2713";
360
373
  var MIXED_GLYPH = "\u2013";
361
- var CHECKBOX_HIT_SLOP = { top: 12, bottom: 12, left: 12, right: 12 };
362
374
  var TRANSPARENT = "transparent";
363
375
  function toCheckedValue(state) {
364
376
  if (state === "all" /* All */) return true;
@@ -389,7 +401,6 @@ function SelectionCheckbox({
389
401
  accessibilityRole: "checkbox",
390
402
  accessibilityState: { checked },
391
403
  "aria-checked": checked,
392
- hitSlop: CHECKBOX_HIT_SLOP,
393
404
  style: selectionStyles.checkboxHit,
394
405
  testID,
395
406
  onPress: onToggle,
@@ -578,6 +589,7 @@ function SelectAllBanner({
578
589
  accessibilityRole: "button",
579
590
  testID: actionTestID,
580
591
  onPress: onAction,
592
+ style: selectionStyles.bannerHit,
581
593
  children: /* @__PURE__ */ jsx(Text, { style: [selectionStyles.bannerAction, { color: palette.primary["500"] }], children: actionLabel })
582
594
  }
583
595
  )
@@ -1160,7 +1172,6 @@ var FIRST_PAGE = 1;
1160
1172
  var DISABLED_OPACITY = 0.4;
1161
1173
  var FULL_OPACITY = 1;
1162
1174
  var TRANSPARENT2 = "transparent";
1163
- var PAGER_HIT_SLOP = { top: 10, bottom: 10 };
1164
1175
  function NavButton({ label, hint, disabled, onPress, color, border, testID, styleOverrides: o }) {
1165
1176
  return /* @__PURE__ */ jsx(
1166
1177
  Pressable,
@@ -1171,7 +1182,6 @@ function NavButton({ label, hint, disabled, onPress, color, border, testID, styl
1171
1182
  accessibilityHint: hint,
1172
1183
  accessibilityState: { disabled },
1173
1184
  disabled,
1174
- hitSlop: PAGER_HIT_SLOP,
1175
1185
  onPress,
1176
1186
  style: [chromeStyles.control, { borderColor: border, opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }, o?.control],
1177
1187
  children: /* @__PURE__ */ jsx(Text, { style: [chromeStyles.controlText, { color }, o?.controlText], children: label })
@@ -1221,7 +1231,6 @@ function RowsControl({ pageSize, pageSizeOptions, onPageSizeChange, isDropdown,
1221
1231
  accessibilityLabel: rowsOptionLabel(t, size),
1222
1232
  accessibilityHint: t(TABLE_I18N.pagerRowsOptionHint),
1223
1233
  accessibilityState: { selected: active },
1224
- hitSlop: PAGER_HIT_SLOP,
1225
1234
  onPress: () => onPageSizeChange(size),
1226
1235
  style: [chromeStyles.sizePill, { borderColor: active ? brand : colors.border, backgroundColor: active ? brand : TRANSPARENT2 }, o?.sizePill],
1227
1236
  children: /* @__PURE__ */ jsx(Text, { style: [chromeStyles.sizePillText, { color: active ? colors.surface : colors.textSecondary }, o?.sizePillText], children: size })
@@ -1398,11 +1407,14 @@ var filterStyles = StyleSheet.create({
1398
1407
  * six live portals, which this wave must not make.
1399
1408
  */
1400
1409
  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 },
1410
+ switchRow: { minHeight: MIN_TARGET_PX, flexDirection: "row", alignItems: "center", gap: SWITCH_ROW_GAP, paddingVertical: FIELD_GAP },
1411
+ /** A 44x44 pressable around the switch: RN-web draws the Switch at 40x20 and that box IS its hit target. */
1412
+ switchHit: { minWidth: MIN_TARGET_PX, minHeight: MIN_TARGET_PX, alignItems: "center", justifyContent: "center" },
1413
+ /** The inner Switch takes no pointer events, so one tap toggles once (via `switchHit`), not twice. */
1414
+ switchInert: { pointerEvents: "none" },
1415
+ 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
1416
  actionText: { fontSize: ACTION_FONT, fontWeight: "600" }
1404
1417
  });
1405
- var FILTER_HIT_SLOP = { top: 8, bottom: 8 };
1406
1418
  var DISABLED_OPACITY2 = 0.4;
1407
1419
  var FULL_OPACITY2 = 1;
1408
1420
  var TRANSPARENT3 = "transparent";
@@ -1419,7 +1431,6 @@ function ActionButton({ label, hint, tone, disabled = false, onPress, testID })
1419
1431
  accessibilityHint: hint,
1420
1432
  accessibilityState: { disabled },
1421
1433
  disabled,
1422
- hitSlop: FILTER_HIT_SLOP,
1423
1434
  onPress,
1424
1435
  style: [
1425
1436
  filterStyles.action,
@@ -1471,17 +1482,28 @@ function BooleanField({ field, barTestID, value, onChange }) {
1471
1482
  return /* @__PURE__ */ jsxs(View, { style: filterStyles.switchRow, testID, children: [
1472
1483
  /* @__PURE__ */ jsx(Text, { style: [controlStyles.subLabel, { color: colors.text }], children: field.label }),
1473
1484
  /* @__PURE__ */ jsx(
1474
- Switch,
1485
+ Pressable,
1475
1486
  {
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`
1487
+ accessible: false,
1488
+ focusable: false,
1489
+ onPress: () => onChange(!value),
1490
+ style: filterStyles.switchHit,
1491
+ testID: `${testID}-switch-hit`,
1492
+ children: /* @__PURE__ */ jsx(
1493
+ Switch,
1494
+ {
1495
+ accessibilityLabel: field.label,
1496
+ accessibilityHint: field.accessibilityHint,
1497
+ accessibilityRole: "switch",
1498
+ accessibilityState: { checked: value },
1499
+ trackColor: { false: colors.border, true: palette.primary["500"] },
1500
+ thumbColor: colors.surface,
1501
+ value,
1502
+ onValueChange: onChange,
1503
+ style: filterStyles.switchInert,
1504
+ testID: `${testID}-switch`
1505
+ }
1506
+ )
1485
1507
  }
1486
1508
  )
1487
1509
  ] });