@dloizides/ui-forms 1.20.0 → 1.21.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.js CHANGED
@@ -1437,12 +1437,18 @@ var FormSwitch = ({
1437
1437
  )
1438
1438
  );
1439
1439
  };
1440
+
1441
+ // src/FormCheckbox/checkboxColors.ts
1442
+ var checkboxBoxColors = (colors, brand, checked) => checked ? { backgroundColor: brand, borderColor: brand } : { backgroundColor: "transparent", borderColor: colors.textSecondary };
1440
1443
  var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
1441
1444
  var HINT_FONT_SIZE2 = 12;
1442
1445
  var BOX_SIZE = 20;
1443
1446
  var BOX_RADIUS = 5;
1444
1447
  var CHECK_FONT_SIZE = 14;
1445
1448
  var DISABLED_OPACITY = 0.5;
1449
+ var FOCUS_RING_WIDTH = 2;
1450
+ var WEB_NO_DEFAULT_OUTLINE = { outlineStyle: "none" };
1451
+ var FOCUS_RING_INSET = -6;
1446
1452
  var styles9 = reactNative.StyleSheet.create({
1447
1453
  container: {
1448
1454
  flexDirection: "row",
@@ -1467,6 +1473,15 @@ var styles9 = reactNative.StyleSheet.create({
1467
1473
  // Nudge the box to sit on the label's first text line.
1468
1474
  marginTop: 1
1469
1475
  },
1476
+ focusRing: {
1477
+ position: "absolute",
1478
+ top: FOCUS_RING_INSET,
1479
+ left: FOCUS_RING_INSET,
1480
+ right: FOCUS_RING_INSET,
1481
+ bottom: FOCUS_RING_INSET,
1482
+ borderWidth: FOCUS_RING_WIDTH,
1483
+ borderRadius: BOX_RADIUS - FOCUS_RING_INSET
1484
+ },
1470
1485
  check: {
1471
1486
  fontSize: CHECK_FONT_SIZE,
1472
1487
  fontWeight: "700",
@@ -1502,13 +1517,15 @@ var FormCheckbox = ({
1502
1517
  const hintText = typeof hint === "string" && hint !== "" ? hint : description;
1503
1518
  const hasHint = typeof hintText === "string" && hintText !== "";
1504
1519
  const { hintId } = useFieldIds();
1520
+ const [focused, setFocused] = React2__default.default.useState(false);
1505
1521
  const themeStyles = React2__default.default.useMemo(() => {
1506
- const boxOn = { backgroundColor: brand, borderColor: brand };
1507
- const boxOff = { backgroundColor: "transparent", borderColor: colors.border };
1522
+ const boxOn = checkboxBoxColors(colors, brand, true);
1523
+ const boxOff = checkboxBoxColors(colors, brand, false);
1524
+ const ring = { borderColor: brand };
1508
1525
  const labelStyle = { color: colors.text };
1509
1526
  const hintStyle = { color: colors.textSecondary };
1510
- return { boxOn, boxOff, label: labelStyle, hint: hintStyle };
1511
- }, [brand, colors.border, colors.text, colors.textSecondary]);
1527
+ return { boxOn, boxOff, ring, label: labelStyle, hint: hintStyle };
1528
+ }, [brand, colors]);
1512
1529
  const toggle = () => {
1513
1530
  const next = !value;
1514
1531
  if (onValueChange) onValueChange(next);
@@ -1532,18 +1549,24 @@ var FormCheckbox = ({
1532
1549
  "aria-checked": value,
1533
1550
  "aria-describedby": hasHint ? hintId : void 0,
1534
1551
  disabled,
1552
+ onBlur: () => setFocused(false),
1553
+ onFocus: () => setFocused(true),
1535
1554
  onPress: toggle,
1536
1555
  role: "checkbox",
1537
1556
  style: [
1538
1557
  styles9.container,
1539
1558
  hasHint ? null : styles9.centered,
1540
1559
  containerStyle,
1541
- disabled ? { opacity: DISABLED_OPACITY } : null
1560
+ disabled ? { opacity: DISABLED_OPACITY } : null,
1561
+ reactNative.Platform.OS === "web" ? WEB_NO_DEFAULT_OUTLINE : null
1542
1562
  ],
1543
1563
  testID,
1544
1564
  ...keyboardProps,
1545
1565
  children: [
1546
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles9.box, value ? themeStyles.boxOn : themeStyles.boxOff], children: value ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.check, { color: colors.surface }], accessibilityElementsHidden: true, children: "\u2713" }) : null }),
1566
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles9.box, value ? themeStyles.boxOn : themeStyles.boxOff], testID: `${testID}-box`, children: [
1567
+ focused ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { pointerEvents: "none", style: [styles9.focusRing, themeStyles.ring], testID: `${testID}-focus-ring` }) : null,
1568
+ value ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.check, { color: colors.surface }], accessibilityElementsHidden: true, children: "\u2713" }) : null
1569
+ ] }),
1547
1570
  /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles9.textColumn, children: [
1548
1571
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles9.label, themeStyles.label], children: label }),
1549
1572
  hasHint ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { nativeID: hintId, style: [styles9.hint, themeStyles.hint], children: hintText }) : null