@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.mjs CHANGED
@@ -3,7 +3,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { Platform, StyleSheet, TouchableOpacity, Text, View, ActivityIndicator, Modal, useWindowDimensions, Animated, Pressable } from 'react-native';
4
4
  import { MIN_TOUCH_TARGET_PX } from '@dloizides/a11y';
5
5
  import { Skeleton } from '@dloizides/ui-motion';
6
- import { Z_INDEX, resolveOnBrand, UI_DEEP_STEP, UI_MAIN_STEP, isHexColor, canCarryAccessibleInk } from '@dloizides/design-tokens';
6
+ import { Z_INDEX, isFocusVisible, resolveFocusRingColor, resolveOnBrand, UI_DEEP_STEP, UI_MAIN_STEP, focusRingOutline, isHexColor, canCarryAccessibleInk } from '@dloizides/design-tokens';
7
7
  import { createPortal } from 'react-dom';
8
8
  import { LocalModelPhase } from '@dloizides/text-generation';
9
9
 
@@ -624,6 +624,32 @@ function confirmFill(theme, destructive) {
624
624
  function confirmInk(theme, destructive) {
625
625
  return resolveOnBrand(confirmFill(theme, destructive));
626
626
  }
627
+ var LIGHT_BRAND_STEP = "300";
628
+ var NO_RING = { outlineWidth: 0 };
629
+ var NATIVE_RING = {};
630
+ function buildDialogRingStyle(visible, color, isWeb) {
631
+ if (!isWeb) return NATIVE_RING;
632
+ return visible ? focusRingOutline(color) : NO_RING;
633
+ }
634
+ function dialogRingColor(theme) {
635
+ const colors = theme.colors;
636
+ return resolveFocusRingColor({
637
+ focusRing: colors.focusRing,
638
+ primary: theme.palette.primary["500"],
639
+ primaryLight: theme.palette.primary[LIGHT_BRAND_STEP],
640
+ text: colors.text,
641
+ background: colors.background
642
+ });
643
+ }
644
+ function useDialogFocusRing(color) {
645
+ const [visible, setVisible] = useState(false);
646
+ const onFocus = useCallback((event) => {
647
+ setVisible(isFocusVisible(event?.target));
648
+ }, []);
649
+ const onBlur = useCallback(() => setVisible(false), []);
650
+ const ringStyle = useMemo(() => buildDialogRingStyle(visible, color, Platform.OS === "web"), [visible, color]);
651
+ return { ringStyle, onFocus, onBlur };
652
+ }
627
653
  var DIALOG_MAX_WIDTH = 400;
628
654
  var styles8 = StyleSheet.create({
629
655
  overlay: {
@@ -692,6 +718,8 @@ var ConfirmDialog = ({
692
718
  const { theme, t } = useFeedbackUi();
693
719
  const titleId = useId();
694
720
  const innerDialogRole = Platform.OS === "web" ? void 0 : "dialog";
721
+ const cancelRing = useDialogFocusRing(dialogRingColor(theme));
722
+ const confirmRing = useDialogFocusRing(dialogRingColor(theme));
695
723
  const colorStyles = useMemo(
696
724
  () => ({
697
725
  dialog: { backgroundColor: theme.colors.surfaceElevated },
@@ -737,9 +765,12 @@ var ConfirmDialog = ({
737
765
  style: [
738
766
  styles8.button,
739
767
  styles8.cancelButton,
740
- colorStyles.cancelButton
768
+ colorStyles.cancelButton,
769
+ cancelRing.ringStyle
741
770
  ],
742
771
  testID: FEEDBACK_TEST_IDS.cancelConfirmButton,
772
+ onBlur: cancelRing.onBlur,
773
+ onFocus: cancelRing.onFocus,
743
774
  onPress: onCancel,
744
775
  children: /* @__PURE__ */ jsx(Text, { style: [styles8.buttonText, colorStyles.cancelButtonText], children: resolvedCancelLabel })
745
776
  }
@@ -756,9 +787,12 @@ var ConfirmDialog = ({
756
787
  styles8.button,
757
788
  styles8.confirmButton,
758
789
  colorStyles.confirmButton,
759
- isConfirmDisabled && styles8.disabledButton
790
+ isConfirmDisabled && styles8.disabledButton,
791
+ confirmRing.ringStyle
760
792
  ],
761
793
  testID: FEEDBACK_TEST_IDS.confirmButton,
794
+ onBlur: confirmRing.onBlur,
795
+ onFocus: confirmRing.onFocus,
762
796
  onPress: onConfirm,
763
797
  children: loading ? /* @__PURE__ */ jsx(
764
798
  ActivityIndicator,