react-native-boost 0.4.1 → 0.5.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.
@@ -1,5 +1,5 @@
1
1
  import { TextStyle } from 'react-native';
2
- import { flattenStyle } from 'react-native/Libraries/StyleSheet/flattenStyle';
2
+ import flattenStyle from 'react-native/Libraries/StyleSheet/flattenStyle';
3
3
  import { GenericStyleProp } from './types';
4
4
 
5
5
  const propsCache = new WeakMap();
@@ -55,4 +55,60 @@ export const verticalAlignToTextAlignVerticalMap = {
55
55
  middle: 'center',
56
56
  };
57
57
 
58
+ /**
59
+ * Normalizes accessibility props.
60
+ *
61
+ * @param props - The props to normalize.
62
+ * @returns The normalized props.
63
+ */
64
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
+ export function normalizeAccessibilityProperties(props: Record<string, any>): Record<string, any> {
66
+ const {
67
+ accessibilityLabel,
68
+ ['aria-label']: ariaLabel,
69
+ accessibilityState,
70
+ ['aria-busy']: ariaBusy,
71
+ ['aria-checked']: ariaChecked,
72
+ ['aria-disabled']: ariaDisabled,
73
+ ['aria-expanded']: ariaExpanded,
74
+ ['aria-selected']: ariaSelected,
75
+ accessible,
76
+ ...restProperties
77
+ } = props;
78
+
79
+ // Merge label props: prefer the aria-label if defined.
80
+ const normalizedLabel = ariaLabel ?? accessibilityLabel;
81
+
82
+ // Merge the accessibilityState with any provided ARIA properties.
83
+ let normalizedState = accessibilityState;
84
+ if (ariaBusy != null || ariaChecked != null || ariaDisabled != null || ariaExpanded != null || ariaSelected != null) {
85
+ normalizedState =
86
+ normalizedState == null
87
+ ? {
88
+ busy: ariaBusy,
89
+ checked: ariaChecked,
90
+ disabled: ariaDisabled,
91
+ expanded: ariaExpanded,
92
+ selected: ariaSelected,
93
+ }
94
+ : {
95
+ busy: ariaBusy ?? normalizedState.busy,
96
+ checked: ariaChecked ?? normalizedState.checked,
97
+ disabled: ariaDisabled ?? normalizedState.disabled,
98
+ expanded: ariaExpanded ?? normalizedState.expanded,
99
+ selected: ariaSelected ?? normalizedState.selected,
100
+ };
101
+ }
102
+
103
+ // For the accessible prop, if not provided, default to `true`
104
+ const normalizedAccessible = accessible == null ? true : accessible;
105
+
106
+ return {
107
+ ...restProperties,
108
+ accessibilityLabel: normalizedLabel,
109
+ accessibilityState: normalizedState,
110
+ accessible: normalizedAccessible,
111
+ };
112
+ }
113
+
58
114
  export * from './types';
@@ -1,5 +1,5 @@
1
1
  declare module 'react-native/Libraries/StyleSheet/flattenStyle' {
2
2
  type GenericStyleProp<T> = null | void | T | false | '' | ReadonlyArray<GenericStyleProp<T>>;
3
3
 
4
- export function flattenStyle<T>(style: T): T extends GenericStyleProp<infer U> ? U : never;
4
+ export default function flattenStyle<T>(style: T): T extends GenericStyleProp<infer U> ? U : never;
5
5
  }