@applicaster/zapp-react-native-ui-components 13.0.10-alpha.9045951059 → 13.0.10-rc.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.
@@ -8,7 +8,6 @@ import { getItemType } from "@applicaster/zapp-react-native-utils/navigationUtil
8
8
  import { SCREEN_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/itemTypes";
9
9
  import { sendSelectCellEvent } from "@applicaster/zapp-react-native-utils/analyticsUtils";
10
10
  import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
11
- import { CellFocusedStateContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/CellFocusedStateContext";
12
11
 
13
12
  import { CellWithFocusable } from "./CellWithFocusable";
14
13
  import { BaseFocusable } from "../BaseFocusable";
@@ -16,7 +15,6 @@ import { AccessibilityManager } from "@applicaster/zapp-react-native-utils/appUt
16
15
  import { styles } from "./styles";
17
16
 
18
17
  type Props = {
19
- dataLength: number;
20
18
  item: ZappEntry;
21
19
  index: number;
22
20
  shouldScrollHorizontally: (arg1: [any]) => boolean | null | undefined;
@@ -69,12 +67,9 @@ type Props = {
69
67
 
70
68
  type State = {
71
69
  hasFocusableInside: boolean;
72
- cellFocused: boolean;
73
70
  };
74
71
 
75
72
  export class CellComponent extends React.Component<Props, State> {
76
- accessibilityManager: AccessibilityManager;
77
-
78
73
  constructor(props) {
79
74
  super(props);
80
75
  this.onPress = this.onPress.bind(this);
@@ -84,14 +79,10 @@ export class CellComponent extends React.Component<Props, State> {
84
79
  this.hasReceivedFocus = this.hasReceivedFocus.bind(this);
85
80
  this.scrollVertically = this.scrollVertically.bind(this);
86
81
  this.scrollToIndex = this.scrollToIndex.bind(this);
87
- this.handleAccessibilityFocus = this.handleAccessibilityFocus.bind(this);
88
82
 
89
83
  this.state = {
90
84
  hasFocusableInside: props.CellRenderer.hasFocusableInside?.(props.item),
91
- cellFocused: false,
92
85
  };
93
-
94
- this.accessibilityManager = AccessibilityManager.getInstance();
95
86
  }
96
87
 
97
88
  setScreenLayout(componentAnchorPointY, screenLayout) {
@@ -139,8 +130,6 @@ export class CellComponent extends React.Component<Props, State> {
139
130
  } = this.props;
140
131
 
141
132
  if (isFocusable) {
142
- this.setState({ cellFocused: true });
143
-
144
133
  if (
145
134
  shouldUpdate &&
146
135
  shouldScrollVertically?.(mouse, focusable, id, title)
@@ -150,9 +139,7 @@ export class CellComponent extends React.Component<Props, State> {
150
139
  }
151
140
  }
152
141
 
153
- onBlur() {
154
- this.setState({ cellFocused: false });
155
- }
142
+ onBlur() {}
156
143
 
157
144
  willReceiveFocus() {}
158
145
 
@@ -196,25 +183,6 @@ export class CellComponent extends React.Component<Props, State> {
196
183
  return !isFocusable ? false : focused || focusableFocused;
197
184
  }
198
185
 
199
- handleAccessibilityFocus(index, dataLength) {
200
- // For loop scrolling, calculate the correct logical index
201
- const logicalIndex = dataLength ? index % dataLength : index;
202
-
203
- const positionLabel = dataLength
204
- ? `item ${logicalIndex + 1} of ${dataLength}`
205
- : "";
206
-
207
- if (this.state.hasFocusableInside) {
208
- this.accessibilityManager.readText({
209
- text: " ",
210
- });
211
- } else {
212
- this.accessibilityManager.readText({
213
- text: `${positionLabel}`,
214
- });
215
- }
216
- }
217
-
218
186
  componentDidUpdate(prevProps: Readonly<Props>) {
219
187
  if (prevProps.item !== this.props.item) {
220
188
  this.setState({
@@ -223,8 +191,6 @@ export class CellComponent extends React.Component<Props, State> {
223
191
  ),
224
192
  });
225
193
  }
226
-
227
- this.handleAccessibilityFocus(this.props.index, this.props.dataLength);
228
194
  }
229
195
 
230
196
  render() {
@@ -246,6 +212,7 @@ export class CellComponent extends React.Component<Props, State> {
246
212
  } = this.props;
247
213
 
248
214
  const { id } = item;
215
+
249
216
  const focusableId = join("-", [component?.id, id, index]);
250
217
 
251
218
  const handleFocus = (focusable, mouse) => {
@@ -256,67 +223,73 @@ export class CellComponent extends React.Component<Props, State> {
256
223
 
257
224
  if (this.state.hasFocusableInside) {
258
225
  return (
259
- <CellFocusedStateContextProvider cellFocused={this.state.cellFocused}>
260
- <CellWithFocusable
261
- CellRenderer={CellRenderer}
262
- item={item}
263
- id={focusableId}
264
- groupId={groupId || component?.id}
265
- onFocus={handleFocus}
266
- onBlur={onBlur || this.onBlur}
267
- index={index}
268
- scrollTo={this.scrollToIndex()}
269
- isFocusable={isFocusable}
270
- skipFocusManagerRegistration={skipFocusManagerRegistration}
271
- behavior={behavior}
272
- />
273
- </CellFocusedStateContextProvider>
226
+ <CellWithFocusable
227
+ CellRenderer={CellRenderer}
228
+ item={item}
229
+ id={focusableId}
230
+ groupId={groupId || component?.id}
231
+ onFocus={handleFocus}
232
+ index={index}
233
+ scrollTo={this.scrollToIndex()}
234
+ isFocusable={isFocusable}
235
+ skipFocusManagerRegistration={skipFocusManagerRegistration}
236
+ behavior={behavior}
237
+ />
274
238
  );
275
239
  }
276
240
 
277
241
  return (
278
- <CellFocusedStateContextProvider cellFocused={this.state.cellFocused}>
279
- <View
280
- testID={`${component?.id}-${id}`}
281
- accessible={false}
282
- style={styles.touchableCell}
242
+ <View
243
+ testID={`${component?.id}-${id}`}
244
+ accessible={false}
245
+ style={styles.touchableCell}
246
+ >
247
+ <Focusable
248
+ id={focusableId}
249
+ groupId={groupId || component?.id}
250
+ onFocus={handleFocus}
251
+ onBlur={onBlur || this.onBlur}
252
+ onPress={this.onPress}
253
+ willReceiveFocus={willReceiveFocus || this.willReceiveFocus}
254
+ hasReceivedFocus={hasReceivedFocus || this.hasReceivedFocus}
255
+ preferredFocus={preferredFocus}
256
+ offsetUpdater={offsetUpdater}
257
+ style={styles.baseCell}
258
+ isFocusable={isFocusable}
259
+ skipFocusManagerRegistration={skipFocusManagerRegistration}
283
260
  >
284
- <Focusable
285
- id={focusableId}
286
- groupId={groupId || component?.id}
287
- onFocus={handleFocus}
288
- onBlur={onBlur || this.onBlur}
289
- onPress={this.onPress}
290
- willReceiveFocus={willReceiveFocus || this.willReceiveFocus}
291
- hasReceivedFocus={hasReceivedFocus || this.hasReceivedFocus}
292
- preferredFocus={preferredFocus}
293
- offsetUpdater={offsetUpdater}
294
- style={styles.baseCell}
295
- isFocusable={isFocusable}
296
- skipFocusManagerRegistration={skipFocusManagerRegistration}
297
- {...this.accessibilityManager.getButtonAccessibilityProps(
298
- item?.extensions?.accessibility?.label || item?.title
299
- )}
300
- >
301
- {(focused, event) => {
302
- const isFocused = this.isCellFocused(focused);
303
-
304
- return (
305
- <FocusableCell
306
- {...{
307
- index,
308
- CellRenderer,
309
- item,
310
- focused: isFocused,
311
- scrollTo: this.scrollToIndex(event),
312
- behavior,
313
- }}
314
- />
315
- );
316
- }}
317
- </Focusable>
318
- </View>
319
- </CellFocusedStateContextProvider>
261
+ {(focused, event) => {
262
+ const isFocused = this.isCellFocused(focused);
263
+
264
+ if (isFocused) {
265
+ const accessibilityManager = AccessibilityManager.getInstance();
266
+
267
+ const accessibilityTitle =
268
+ item?.extensions?.accessibility?.label || item?.title || "";
269
+
270
+ const accessibilityHint =
271
+ item?.extensions?.accessibility?.hint || "";
272
+
273
+ accessibilityManager.readText({
274
+ text: `${accessibilityTitle} ${accessibilityHint}`,
275
+ });
276
+ }
277
+
278
+ return (
279
+ <FocusableCell
280
+ {...{
281
+ index,
282
+ CellRenderer,
283
+ item,
284
+ focused: isFocused,
285
+ scrollTo: this.scrollToIndex(event),
286
+ behavior,
287
+ }}
288
+ />
289
+ );
290
+ }}
291
+ </Focusable>
292
+ </View>
320
293
  );
321
294
  }
322
295
  }
@@ -14,7 +14,6 @@ type Props = {
14
14
  id: string;
15
15
  groupId: string;
16
16
  onFocus: Function;
17
- onBlur?: Function;
18
17
  index: number;
19
18
  scrollTo: Function;
20
19
  preferredFocus?: boolean;
@@ -34,7 +33,6 @@ export function CellWithFocusable(props: Props) {
34
33
  id,
35
34
  groupId,
36
35
  onFocus,
37
- onBlur = noop,
38
36
  scrollTo = noop,
39
37
  preferredFocus,
40
38
  skipFocusManagerRegistration,
@@ -80,7 +78,6 @@ export function CellWithFocusable(props: Props) {
80
78
  const onGroupBlur = React.useCallback(() => {
81
79
  if (!skipFocusManagerRegistration) {
82
80
  setIsFocused(false);
83
- onBlur?.();
84
81
  }
85
82
  }, [skipFocusManagerRegistration]);
86
83
 
@@ -5,7 +5,6 @@ import { BaseFocusable } from "../BaseFocusable";
5
5
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
6
6
  import { LONG_KEY_PRESS_TIMEOUT } from "@applicaster/quick-brick-core/const";
7
7
  import { withFocusableContext } from "../../Contexts/FocusableGroupContext/withFocusableContext";
8
- import { AccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager";
9
8
 
10
9
  type Props = {
11
10
  initialFocus?: boolean;
@@ -29,7 +28,6 @@ class Focusable extends BaseFocusable<Props> {
29
28
  isGroup: boolean;
30
29
  mouse: boolean;
31
30
  longPressTimeout = null;
32
- accessibilityManager: AccessibilityManager;
33
31
 
34
32
  constructor(props) {
35
33
  super(props);
@@ -44,8 +42,6 @@ class Focusable extends BaseFocusable<Props> {
44
42
  this.resetLongPressTimeout = this.resetLongPressTimeout.bind(this);
45
43
  this.longPress = this.longPress.bind(this);
46
44
  this.press = this.press.bind(this);
47
-
48
- this.accessibilityManager = AccessibilityManager.getInstance();
49
45
  }
50
46
 
51
47
  /**
@@ -132,9 +128,6 @@ class Focusable extends BaseFocusable<Props> {
132
128
  const id = this.getId();
133
129
  const focusableId = `focusable-${id}`;
134
130
 
135
- const accessibilityProps =
136
- this.accessibilityManager.getWebAccessibilityProps(this.props);
137
-
138
131
  return (
139
132
  <div
140
133
  id={focusableId}
@@ -147,7 +140,6 @@ class Focusable extends BaseFocusable<Props> {
147
140
  data-testid={focusableId}
148
141
  focused-teststate={focused ? "focused" : "default"}
149
142
  style={style}
150
- {...accessibilityProps}
151
143
  >
152
144
  {children(focused, { mouse: this.mouse })}
153
145
  </div>
@@ -5,6 +5,7 @@ import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/acti
5
5
  import * as R from "ramda";
6
6
  import { getXray } from "@applicaster/zapp-react-native-utils/logger";
7
7
  import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
8
+ import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
8
9
 
9
10
  const { Logger } = getXray();
10
11
 
@@ -44,6 +45,11 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
44
45
 
45
46
  const actionContext = useActions(pluginIdentifier);
46
47
 
48
+ const accessibilityManager = useAccessibilityManager({});
49
+
50
+ const { ttsLabel = "" } =
51
+ actionContext?.initialEntryState(item)?.getAccessibility?.(item) || {};
52
+
47
53
  const onPress = (event) => {
48
54
  event?.preventDefault?.();
49
55
 
@@ -88,6 +94,12 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
88
94
  mouse: focusable.mouse,
89
95
  });
90
96
  });
97
+
98
+ if (ttsLabel) {
99
+ accessibilityManager.readText({
100
+ text: ttsLabel,
101
+ });
102
+ }
91
103
  };
92
104
 
93
105
  const handleBlur = (_focusable, _direction) => {
@@ -11,8 +11,6 @@ import { withScaledLineHeight } from "./utils";
11
11
  import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
12
12
  import { MeasurementPortalContext } from "../../../MeasurmentsPortal";
13
13
  import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
14
- import { CellFocusedStateContext } from "@applicaster/zapp-react-native-ui-components/Contexts/CellFocusedStateContext";
15
- import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
16
14
 
17
15
  type Props = {
18
16
  style: any;
@@ -37,9 +35,10 @@ const _Text = ({
37
35
  }: Props) => {
38
36
  const _label = useTextLabel({ label, entry });
39
37
  const isMeasurement = React.useContext(MeasurementPortalContext);
40
- const cellFocused = React.useContext(CellFocusedStateContext);
41
38
 
42
- const accessibilityManager = useAccessibilityManager({});
39
+ if (isNilOrEmpty(_label)) {
40
+ return null;
41
+ }
43
42
 
44
43
  // set maximum possible height for the text in case of measurement
45
44
  const height =
@@ -47,27 +46,6 @@ const _Text = ({
47
46
  ? toNumber(otherProps.numberOfLines) * toNumber(style.lineHeight)
48
47
  : undefined;
49
48
 
50
- const textLabel = dateTransformEnabled
51
- ? dateFormat(dateTransform, label)
52
- : textTransform(transformText, _label);
53
-
54
- React.useLayoutEffect(() => {
55
- // For FocusableCells with action buttons
56
- if (otherProps.state) {
57
- if (otherProps.state === "focused" && cellFocused === true) {
58
- accessibilityManager.addHeading(textLabel);
59
- }
60
- } else {
61
- if (cellFocused === true) {
62
- accessibilityManager.addHeading(textLabel);
63
- }
64
- }
65
- }, [cellFocused, otherProps.state, textLabel]);
66
-
67
- if (isNilOrEmpty(_label)) {
68
- return null;
69
- }
70
-
71
49
  return (
72
50
  <Text
73
51
  style={[
@@ -76,7 +54,9 @@ const _Text = ({
76
54
  ]}
77
55
  {...withoutLabel(otherProps)}
78
56
  >
79
- {textLabel}
57
+ {dateTransformEnabled
58
+ ? dateFormat(dateTransform, label)
59
+ : textTransform(transformText, _label)}
80
60
  </Text>
81
61
  );
82
62
  };
@@ -2,19 +2,6 @@
2
2
 
3
3
  exports[`<TextInputTv /> renders 1`] = `
4
4
  <input
5
- accessibilityProps={
6
- {
7
- "accessibilityHint": "Enter text into Search",
8
- "accessibilityLabel": "Search",
9
- "accessibilityRole": "text",
10
- "accessible": true,
11
- "aria-description": "Enter text into Search",
12
- "aria-label": "Search",
13
- "aria-role": "text",
14
- "role": "text",
15
- "tabindex": 0,
16
- }
17
- }
18
5
  testID="TextInput-tv"
19
6
  />
20
7
  `;
@@ -4,7 +4,6 @@ import { Appearance, Platform, StyleSheet, TextInput } from "react-native";
4
4
  import { isFunction } from "@applicaster/zapp-react-native-utils/functionUtils";
5
5
  import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
6
6
  import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
7
- import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
8
7
 
9
8
  type Props = Partial<{
10
9
  style: any;
@@ -43,8 +42,6 @@ function TextInputTV(props: Props, ref) {
43
42
  const [colorScheme, setColorScheme] = useState(getInitialColorScheme());
44
43
  const isRTL = useIsRTL();
45
44
 
46
- const accessibilityManager = useAccessibilityManager({});
47
-
48
45
  const onColorChange = useCallback(
49
46
  ({ colorScheme: color }) => {
50
47
  if (color !== colorScheme) {
@@ -156,13 +153,6 @@ function TextInputTV(props: Props, ref) {
156
153
  ])
157
154
  )(props);
158
155
 
159
- const getAccessibilityProps = () => {
160
- return {
161
- accessibilityProps:
162
- accessibilityManager.getInputAccessibilityProps("Search"),
163
- };
164
- };
165
-
166
156
  const inputProps = {
167
157
  ...getProps(),
168
158
  ...getStyle(),
@@ -171,7 +161,6 @@ function TextInputTV(props: Props, ref) {
171
161
  ...getSecureTextEntry(),
172
162
  ...getOnEndEditing(),
173
163
  ...getOnPress(),
174
- ...getAccessibilityProps(),
175
164
  };
176
165
 
177
166
  if (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "13.0.10-alpha.9045951059",
3
+ "version": "13.0.10-rc.0",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -31,10 +31,10 @@
31
31
  "redux-mock-store": "^1.5.3"
32
32
  },
33
33
  "dependencies": {
34
- "@applicaster/applicaster-types": "13.0.10-alpha.9045951059",
35
- "@applicaster/zapp-react-native-bridge": "13.0.10-alpha.9045951059",
36
- "@applicaster/zapp-react-native-redux": "13.0.10-alpha.9045951059",
37
- "@applicaster/zapp-react-native-utils": "13.0.10-alpha.9045951059",
34
+ "@applicaster/applicaster-types": "13.0.10-rc.0",
35
+ "@applicaster/zapp-react-native-bridge": "13.0.10-rc.0",
36
+ "@applicaster/zapp-react-native-redux": "13.0.10-rc.0",
37
+ "@applicaster/zapp-react-native-utils": "13.0.10-rc.0",
38
38
  "promise": "^8.3.0",
39
39
  "react-router-native": "^5.1.2",
40
40
  "url": "^0.11.0",
@@ -1,27 +0,0 @@
1
- import React, { ReactNode } from "react";
2
-
3
- export const CellFocusedStateContext = React.createContext<boolean>(false);
4
-
5
- export const CellFocusedStateContextProvider = ({
6
- cellFocused,
7
- children,
8
- }: {
9
- cellFocused: boolean;
10
- children: ReactNode;
11
- }) => {
12
- return (
13
- <CellFocusedStateContext.Provider value={cellFocused}>
14
- {children}
15
- </CellFocusedStateContext.Provider>
16
- );
17
- };
18
-
19
- export function withCellFocusedStateContext(
20
- Component: React.ComponentType<any>
21
- ) {
22
- return function WithCellFocusedStateContextWrapper(props) {
23
- const cellFocusedState = React.useContext(CellFocusedStateContext);
24
-
25
- return <Component {...props} cellFocusedState={cellFocusedState} />;
26
- };
27
- }