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.
- package/README.md +3 -5
- package/dist/esm/index.mjs +40 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +40 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/esm/index.mjs +168 -44
- package/dist/plugin/esm/index.mjs.map +1 -1
- package/dist/plugin/index.js +168 -44
- package/dist/plugin/index.js.map +1 -1
- package/package.json +5 -5
- package/src/plugin/optimizers/text/index.ts +99 -46
- package/src/plugin/optimizers/view/index.ts +9 -11
- package/src/plugin/types/index.ts +23 -0
- package/src/plugin/utils/common.ts +154 -1
- package/src/runtime/index.ts +57 -1
- package/src/runtime/types/react-native.d.ts +1 -1
package/src/runtime/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextStyle } from 'react-native';
|
|
2
|
-
import
|
|
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
|
}
|