@dloizides/ui-feedback 1.16.0 → 1.16.2

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
@@ -1,4 +1,4 @@
1
- import { createContext, useMemo, useContext, useCallback, useState, useEffect, useSyncExternalStore, Component, useRef } from 'react';
1
+ import { createContext, useMemo, useContext, useCallback, useId, useState, useEffect, useSyncExternalStore, Component, useRef } from 'react';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { StyleSheet, Platform, TouchableOpacity, Text, View, ActivityIndicator, Modal, useWindowDimensions, Animated, Pressable } from 'react-native';
4
4
  import { MIN_TOUCH_TARGET_PX } from '@dloizides/a11y';
@@ -62,6 +62,7 @@ var FEEDBACK_TEST_IDS = {
62
62
  errorBoundary: "error-boundary",
63
63
  progressBar: "progress-bar"
64
64
  };
65
+ var MIN_TOUCH_TARGET = 44;
65
66
  var WELL_SIZE = 56;
66
67
  var WELL_MARGIN_BOTTOM = 16;
67
68
  var WELL_TINT_OPACITY = 0.12;
@@ -464,6 +465,7 @@ var styles6 = StyleSheet.create({
464
465
  paddingHorizontal: 20,
465
466
  borderRadius: 6,
466
467
  minWidth: 80,
468
+ minHeight: MIN_TOUCH_TARGET,
467
469
  alignItems: "center",
468
470
  justifyContent: "center"
469
471
  },
@@ -492,6 +494,8 @@ var ConfirmDialog = ({
492
494
  destructive = false
493
495
  }) => {
494
496
  const { theme, t } = useFeedbackUi();
497
+ const titleId = useId();
498
+ const innerDialogRole = Platform.OS === "web" ? void 0 : "dialog";
495
499
  const colorStyles = useMemo(
496
500
  () => ({
497
501
  dialog: { backgroundColor: theme.colors.surfaceElevated },
@@ -515,6 +519,7 @@ var ConfirmDialog = ({
515
519
  Modal,
516
520
  {
517
521
  transparent: true,
522
+ "aria-labelledby": titleId,
518
523
  animationType: "fade",
519
524
  visible,
520
525
  onRequestClose: onCancel,
@@ -522,11 +527,11 @@ var ConfirmDialog = ({
522
527
  View,
523
528
  {
524
529
  accessibilityViewIsModal: true,
525
- "aria-label": title,
526
- role: "dialog",
530
+ "aria-label": innerDialogRole === void 0 ? void 0 : title,
531
+ role: innerDialogRole,
527
532
  style: [styles6.dialog, colorStyles.dialog],
528
533
  children: [
529
- /* @__PURE__ */ jsx(Text, { style: [styles6.title, colorStyles.title], children: title }),
534
+ /* @__PURE__ */ jsx(Text, { nativeID: titleId, style: [styles6.title, colorStyles.title], children: title }),
530
535
  /* @__PURE__ */ jsx(Text, { style: [styles6.message, colorStyles.message], children: message }),
531
536
  /* @__PURE__ */ jsxs(View, { style: styles6.buttonRow, children: [
532
537
  /* @__PURE__ */ jsx(
@@ -1334,19 +1339,24 @@ function RunGroupSummary({ groups, labels, testID }) {
1334
1339
  ] });
1335
1340
  }
1336
1341
  var BAR_HEIGHT2 = 8;
1337
- var LABEL_BASIS = 150;
1342
+ var LABEL_MIN_WIDTH = 220;
1343
+ var LABEL_SHARE = "35%";
1344
+ var LABEL_LINES = 2;
1338
1345
  var DURATION_WIDTH = 64;
1339
1346
  var PERCENT = 100;
1340
1347
  var styles14 = StyleSheet.create({
1341
1348
  list: { gap: 6 },
1342
- row: { flexDirection: "row", alignItems: "center", gap: 8, flexWrap: "wrap" },
1343
- label: { fontSize: 13, flexBasis: LABEL_BASIS, flexGrow: 0, flexShrink: 1, minWidth: 0 },
1349
+ row: { flexDirection: "row", alignItems: "center", gap: 8 },
1350
+ stack: { gap: 4 },
1351
+ label: { fontSize: 13, flexBasis: LABEL_SHARE, flexGrow: 0, flexShrink: 0, minWidth: LABEL_MIN_WIDTH },
1352
+ compactLabel: { fontSize: 13, flexGrow: 1, flexShrink: 1, minWidth: 0 },
1344
1353
  track: { flexGrow: 1, flexShrink: 1, flexBasis: 80, height: BAR_HEIGHT2, borderRadius: 2, overflow: "hidden" },
1354
+ fullTrack: { height: BAR_HEIGHT2, borderRadius: 2, overflow: "hidden" },
1345
1355
  fill: { height: "100%", borderRadius: 2 },
1346
1356
  duration: { fontSize: 13, width: DURATION_WIDTH, textAlign: "right", fontVariant: ["tabular-nums"] },
1347
1357
  strong: { fontWeight: "700" }
1348
1358
  });
1349
- function RunStepBars({ steps, maxBars, labels, testID }) {
1359
+ function RunStepBars({ steps, maxBars, labels, compact, testID }) {
1350
1360
  const { theme } = useFeedbackUi();
1351
1361
  const [all, setAll] = useState(false);
1352
1362
  const split = splitShorterSteps(steps, all ? steps.length : maxBars);
@@ -1358,10 +1368,20 @@ function RunStepBars({ steps, maxBars, labels, testID }) {
1358
1368
  const color = runToneColor(theme, step.state);
1359
1369
  const duration = labels.formatDuration(step.durationSec);
1360
1370
  const strong = step.state === "running" ? styles14.strong : null;
1361
- return /* @__PURE__ */ jsxs(View, { style: styles14.row, accessible: true, accessibilityLabel: labels.stepA11y(step.label, duration), testID: `${testID}-row-${String(i)}`, children: [
1362
- /* @__PURE__ */ jsx(Text, { style: [styles14.label, { color: theme.colors.text }, strong], numberOfLines: 1, children: step.label }),
1363
- /* @__PURE__ */ jsx(View, { style: [styles14.track, { backgroundColor: theme.colors.border }], children: /* @__PURE__ */ jsx(View, { style: [styles14.fill, { backgroundColor: color, width: `${barFraction(step.durationSec, maxSec) * PERCENT}%` }] }) }),
1364
- /* @__PURE__ */ jsx(Text, { style: [styles14.duration, { color: theme.colors.textSecondary }, strong], children: duration })
1371
+ const name = /* @__PURE__ */ jsx(Text, { style: [compact ? styles14.compactLabel : styles14.label, { color: theme.colors.text }, strong], numberOfLines: LABEL_LINES, testID: `${testID}-name-${String(i)}`, children: step.label });
1372
+ const time = /* @__PURE__ */ jsx(Text, { style: [styles14.duration, { color: theme.colors.textSecondary }, strong], children: duration });
1373
+ const bar = /* @__PURE__ */ jsx(View, { style: [compact ? styles14.fullTrack : styles14.track, { backgroundColor: theme.colors.border }], children: /* @__PURE__ */ jsx(View, { style: [styles14.fill, { backgroundColor: color, width: `${barFraction(step.durationSec, maxSec) * PERCENT}%` }] }) });
1374
+ const a11y = { accessible: true, accessibilityLabel: labels.stepA11y(step.label, duration), testID: `${testID}-row-${String(i)}` };
1375
+ return compact ? /* @__PURE__ */ jsxs(View, { style: styles14.stack, ...a11y, children: [
1376
+ /* @__PURE__ */ jsxs(View, { style: styles14.row, children: [
1377
+ name,
1378
+ time
1379
+ ] }),
1380
+ bar
1381
+ ] }, `${step.label}-${String(i)}`) : /* @__PURE__ */ jsxs(View, { style: styles14.row, ...a11y, children: [
1382
+ name,
1383
+ bar,
1384
+ time
1365
1385
  ] }, `${step.label}-${String(i)}`);
1366
1386
  }),
1367
1387
  folded || canFold ? /* @__PURE__ */ jsx(
@@ -1415,10 +1435,10 @@ function LiveRunCard(props) {
1415
1435
  currentStep !== null && currentStep !== "" ? /* @__PURE__ */ jsx(Text, { style: [styles15.step, { color: theme.colors.text }], testID: `${testID}-step`, children: currentStep }) : null,
1416
1436
  percent !== null ? /* @__PURE__ */ jsx(ProgressBar, { percent, label: labels.progress, accessibilityLabel: labels.progressA11y, color: tone, testID: `${testID}-progress` }) : null,
1417
1437
  percent === null && labels.progress !== void 0 ? /* @__PURE__ */ jsx(Text, { style: [styles15.meta, muted], testID: `${testID}-progress-text`, children: labels.progress }) : null,
1418
- compact ? /* @__PURE__ */ jsx(RunGroupSummary, { groups, labels, testID: `${testID}-summary` }) : null,
1438
+ compact && !open ? /* @__PURE__ */ jsx(RunGroupSummary, { groups, labels, testID: `${testID}-summary` }) : null,
1419
1439
  compact ? /* @__PURE__ */ jsx(RunCardButton, { label: labels.stepTimings, hint: labels.stepTimingsHint, color: theme.colors.textSecondary, onPress: () => setOpen(!open), expanded: open, testID: `${testID}-timings-toggle` }) : null,
1420
1440
  showTimings ? /* @__PURE__ */ jsx(RunGroupChips, { groups, labels, selectedId, onSelect: setPicked, testID: `${testID}-groups` }) : null,
1421
- showTimings && selected !== void 0 && selected.steps.length > 0 ? /* @__PURE__ */ jsx(RunStepBars, { steps: selected.steps, maxBars, labels, testID: `${testID}-steps` }, selected.id) : null
1441
+ showTimings && selected !== void 0 && selected.steps.length > 0 ? /* @__PURE__ */ jsx(RunStepBars, { steps: selected.steps, maxBars, labels, compact, testID: `${testID}-steps` }, selected.id) : null
1422
1442
  ] });
1423
1443
  }
1424
1444