@dloizides/ui-feedback 1.26.0 → 1.26.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.js CHANGED
@@ -626,6 +626,32 @@ function confirmFill(theme, destructive) {
626
626
  function confirmInk(theme, destructive) {
627
627
  return designTokens.resolveOnBrand(confirmFill(theme, destructive));
628
628
  }
629
+ var LIGHT_BRAND_STEP = "300";
630
+ var NO_RING = { outlineWidth: 0 };
631
+ var NATIVE_RING = {};
632
+ function buildDialogRingStyle(visible, color, isWeb) {
633
+ if (!isWeb) return NATIVE_RING;
634
+ return visible ? designTokens.focusRingOutline(color) : NO_RING;
635
+ }
636
+ function dialogRingColor(theme) {
637
+ const colors = theme.colors;
638
+ return designTokens.resolveFocusRingColor({
639
+ focusRing: colors.focusRing,
640
+ primary: theme.palette.primary["500"],
641
+ primaryLight: theme.palette.primary[LIGHT_BRAND_STEP],
642
+ text: colors.text,
643
+ background: colors.background
644
+ });
645
+ }
646
+ function useDialogFocusRing(color) {
647
+ const [visible, setVisible] = react.useState(false);
648
+ const onFocus = react.useCallback((event) => {
649
+ setVisible(designTokens.isFocusVisible(event?.target));
650
+ }, []);
651
+ const onBlur = react.useCallback(() => setVisible(false), []);
652
+ const ringStyle = react.useMemo(() => buildDialogRingStyle(visible, color, reactNative.Platform.OS === "web"), [visible, color]);
653
+ return { ringStyle, onFocus, onBlur };
654
+ }
629
655
  var DIALOG_MAX_WIDTH = 400;
630
656
  var styles8 = reactNative.StyleSheet.create({
631
657
  overlay: {
@@ -694,6 +720,8 @@ var ConfirmDialog = ({
694
720
  const { theme, t } = useFeedbackUi();
695
721
  const titleId = react.useId();
696
722
  const innerDialogRole = reactNative.Platform.OS === "web" ? void 0 : "dialog";
723
+ const cancelRing = useDialogFocusRing(dialogRingColor(theme));
724
+ const confirmRing = useDialogFocusRing(dialogRingColor(theme));
697
725
  const colorStyles = react.useMemo(
698
726
  () => ({
699
727
  dialog: { backgroundColor: theme.colors.surfaceElevated },
@@ -739,9 +767,12 @@ var ConfirmDialog = ({
739
767
  style: [
740
768
  styles8.button,
741
769
  styles8.cancelButton,
742
- colorStyles.cancelButton
770
+ colorStyles.cancelButton,
771
+ cancelRing.ringStyle
743
772
  ],
744
773
  testID: FEEDBACK_TEST_IDS.cancelConfirmButton,
774
+ onBlur: cancelRing.onBlur,
775
+ onFocus: cancelRing.onFocus,
745
776
  onPress: onCancel,
746
777
  children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.buttonText, colorStyles.cancelButtonText], children: resolvedCancelLabel })
747
778
  }
@@ -758,9 +789,12 @@ var ConfirmDialog = ({
758
789
  styles8.button,
759
790
  styles8.confirmButton,
760
791
  colorStyles.confirmButton,
761
- isConfirmDisabled && styles8.disabledButton
792
+ isConfirmDisabled && styles8.disabledButton,
793
+ confirmRing.ringStyle
762
794
  ],
763
795
  testID: FEEDBACK_TEST_IDS.confirmButton,
796
+ onBlur: confirmRing.onBlur,
797
+ onFocus: confirmRing.onFocus,
764
798
  onPress: onConfirm,
765
799
  children: loading ? /* @__PURE__ */ jsxRuntime.jsx(
766
800
  reactNative.ActivityIndicator,