@applicaster/zapp-react-native-ui-components 12.0.2-rc.1 → 12.0.3-alpha.5953460913

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,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import * as R from "ramda";
2
3
 
3
4
  import {
4
5
  BaseFocusable as BaseFocusableInterface,
@@ -7,7 +8,6 @@ import {
7
8
 
8
9
  import { createReactRef } from "@applicaster/zapp-react-native-utils/reactUtils";
9
10
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
10
- import * as FOCUS_EVENTS from "@applicaster/zapp-react-native-utils/appUtils/focusManager/events";
11
11
  import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
12
12
 
13
13
  type ScrollDirection = FocusManager.IOS.Direction | FocusManager.Web.Direction;
@@ -131,12 +131,6 @@ export class BaseFocusable<
131
131
  willLoseFocus: FocusManager.FocusEventCB = (focusable, scrollDirection) => {
132
132
  const { willLoseFocus = noop } = this.props;
133
133
  willLoseFocus(focusable, scrollDirection);
134
-
135
- focusManager.invokeHandler?.(
136
- FOCUS_EVENTS.WILL_LOSE_FOCUS,
137
- this,
138
- scrollDirection
139
- );
140
134
  };
141
135
 
142
136
  willReceiveFocus: FocusManager.FocusEventCB = (
@@ -145,12 +139,6 @@ export class BaseFocusable<
145
139
  ) => {
146
140
  const { willReceiveFocus = noop } = this.props;
147
141
  willReceiveFocus(focusable, scrollDirection);
148
-
149
- focusManager.invokeHandler?.(
150
- FOCUS_EVENTS.WILL_RECEIVE_FOCUS,
151
- this,
152
- scrollDirection
153
- );
154
142
  };
155
143
 
156
144
  /**
@@ -163,8 +151,6 @@ export class BaseFocusable<
163
151
  const { onFocus = noop } = this.props;
164
152
  this.setFocusedState(true);
165
153
  onFocus(focusable, scrollDirection);
166
-
167
- focusManager.invokeHandler?.(FOCUS_EVENTS.FOCUS, this, scrollDirection);
168
154
  };
169
155
 
170
156
  /**
@@ -179,12 +165,6 @@ export class BaseFocusable<
179
165
  ) => {
180
166
  const { hasReceivedFocus = noop } = this.props;
181
167
  hasReceivedFocus(focusable, scrollDirection);
182
-
183
- focusManager.invokeHandler?.(
184
- FOCUS_EVENTS.HAS_RECEIVED_FOCUS,
185
- this,
186
- scrollDirection
187
- );
188
168
  };
189
169
 
190
170
  /**
@@ -196,12 +176,6 @@ export class BaseFocusable<
196
176
  hasLostFocus: FocusManager.FocusEventCB = (focusable, scrollDirection) => {
197
177
  const { hasLostFocus = noop } = this.props;
198
178
  hasLostFocus(focusable, scrollDirection);
199
-
200
- focusManager.invokeHandler?.(
201
- FOCUS_EVENTS.HAS_LOST_FOCUS,
202
- this,
203
- scrollDirection
204
- );
205
179
  };
206
180
 
207
181
  /**
@@ -228,7 +202,6 @@ export class BaseFocusable<
228
202
  const { onBlur = noop } = this.props;
229
203
  this.setFocusedState(false);
230
204
  onBlur(focusable, scrollDirection);
231
- focusManager.invokeHandler?.(FOCUS_EVENTS.BLUR, this, scrollDirection);
232
205
  };
233
206
 
234
207
  onPress = (keyEvent?: Nullable<React.MouseEvent>) => {
@@ -269,4 +242,68 @@ export class BaseFocusable<
269
242
  this.setState({ focused });
270
243
  }
271
244
  };
245
+
246
+ /**
247
+ * will invoke the underlying component's focus method
248
+ * @param {Object} scrollDirection
249
+ * @returns {Promise}
250
+ */
251
+ focus(_, scrollDirection) {
252
+ return this.onFocus(this, scrollDirection); // invokeComponentMethod(this, "onFocus", scrollDirection);
253
+ }
254
+
255
+ /**
256
+ * will invoke the underlying component's blur method
257
+ * @param {Object} scrollDirection
258
+ * @returns {Promise}
259
+ */
260
+ blur(
261
+ _,
262
+ scrollDirection?: FocusManager.Web.Direction | FocusManager.IOS.Direction
263
+ ) {
264
+ return this.onBlur(this, scrollDirection);
265
+ }
266
+
267
+ /**
268
+ * Sets the focus on this item. Will trigger sequentially a sequence of
269
+ * functions (willReceiveFocus, focus, hasReceivedFocus). If these functions (defined in the Focusable
270
+ * Item underlying component) return promises, execution will wait before it proceeds to the next. This
271
+ * is useful for triggering sequential operations that specifically require to fully run before or after
272
+ * focus is actually set on that item.
273
+ * @param {string} scrollDirection string representation of the direction of the navigation which landed
274
+ * to this item being focused
275
+ */
276
+ _executeFocusSequence(methodNames, scrollDirection) {
277
+ return R.reduce(
278
+ (sequence, methodName) => {
279
+ const method = this[methodName]; // Access the method by name
280
+
281
+ if (typeof method !== "function") {
282
+ throw new Error(
283
+ `Method '${methodName}' not found or not a function.`
284
+ );
285
+ }
286
+
287
+ return sequence
288
+ .then(() => method.call(this, scrollDirection))
289
+ .catch((e) => {
290
+ throw e; // Re-throw for consistent error handling
291
+ });
292
+ },
293
+ Promise.resolve(),
294
+ methodNames
295
+ );
296
+ }
297
+
298
+ setFocus(scrollDirection) {
299
+ const focusMethods = ["willReceiveFocus", "focus", "hasReceivedFocus"];
300
+
301
+ return this._executeFocusSequence(focusMethods, scrollDirection);
302
+ }
303
+
304
+ setBlur(scrollDirection) {
305
+ const blurMethods = ["willLoseFocus", "blur", "hasLostFocus"];
306
+
307
+ return this._executeFocusSequence(blurMethods, scrollDirection);
308
+ }
272
309
  }
@@ -276,7 +276,12 @@ export class CellComponent extends React.Component<Props, State> {
276
276
 
277
277
  if (isFocused) {
278
278
  const accessibilityManager = AccessibilityManager.getInstance();
279
- accessibilityManager.readText({ text: item.title });
279
+
280
+ accessibilityManager.readText({
281
+ text: String(
282
+ item.extensions?.accessibility?.label || item.title
283
+ ),
284
+ });
280
285
  }
281
286
 
282
287
  return (
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
- import * as R from "ramda";
3
2
 
4
3
  import { BaseFocusable } from "../BaseFocusable";
5
4
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
@@ -42,8 +41,6 @@ class Focusable extends BaseFocusable<Props> {
42
41
  this.resetLongPressTimeout = this.resetLongPressTimeout.bind(this);
43
42
  this.longPress = this.longPress.bind(this);
44
43
  this.press = this.press.bind(this);
45
- this.focus = this.focus.bind(this);
46
- this.blur = this.blur.bind(this);
47
44
  }
48
45
 
49
46
  /**
@@ -55,37 +52,6 @@ class Focusable extends BaseFocusable<Props> {
55
52
  return this.preferredFocus();
56
53
  }
57
54
 
58
- /**
59
- * Sets the focus on this item. Will trigger sequentially a sequence of
60
- * functions (willReceiveFocus, focus, hasReceivedFocus). If these functions (defined in the Focusable
61
- * Item underlying component) return promises, execution will wait before it proceeds to the next. This
62
- * is useful for triggering sequential operations that specifically require to fully run before or after
63
- * focus is actually set on that item.
64
- * @param {string} scrollDirection string representation of the direction of the navigation which landed
65
- * to this item being focused
66
- */
67
- setFocus(scrollDirection) {
68
- const focusMethods = [
69
- this.willReceiveFocus,
70
- this.focus,
71
- this.hasReceivedFocus,
72
- ];
73
-
74
- const self = this;
75
-
76
- return R.reduce(
77
- (sequence, method) => {
78
- return sequence
79
- .then(() => method.apply(self, [scrollDirection]))
80
- .catch((e) => {
81
- throw e;
82
- });
83
- },
84
- Promise.resolve(),
85
- focusMethods
86
- );
87
- }
88
-
89
55
  startLongPressTimeout() {
90
56
  this.longPressTimeout = setTimeout(() => {
91
57
  this.longPress(null);
@@ -102,26 +68,6 @@ class Focusable extends BaseFocusable<Props> {
102
68
  }
103
69
  }
104
70
 
105
- /**
106
- * will invoke the underlying component's focus method
107
- * @param {Object} scrollDirection
108
- * @returns {Promise}
109
- */
110
- focus(scrollDirection) {
111
- return this.onFocus(this, scrollDirection); // invokeComponentMethod(this, "onFocus", scrollDirection);
112
- }
113
-
114
- /**
115
- * will invoke the underlying component's blur method
116
- * @param {Object} scrollDirection
117
- * @returns {Promise}
118
- */
119
- blur(
120
- scrollDirection?: FocusManager.Web.Direction | FocusManager.IOS.Direction
121
- ) {
122
- return this.onBlur(this, scrollDirection);
123
- }
124
-
125
71
  /**
126
72
  * will invoke the underlying component's press method
127
73
  * @param {Object} keyEvent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "12.0.2-rc.1",
3
+ "version": "12.0.3-alpha.5953460913",
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",
@@ -34,10 +34,10 @@
34
34
  "redux-mock-store": "^1.5.3"
35
35
  },
36
36
  "dependencies": {
37
- "@applicaster/applicaster-types": "12.0.2-rc.1",
38
- "@applicaster/zapp-react-native-bridge": "12.0.2-rc.1",
39
- "@applicaster/zapp-react-native-redux": "12.0.2-rc.1",
40
- "@applicaster/zapp-react-native-utils": "12.0.2-rc.1",
37
+ "@applicaster/applicaster-types": "12.0.3-alpha.5953460913",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.3-alpha.5953460913",
39
+ "@applicaster/zapp-react-native-redux": "12.0.3-alpha.5953460913",
40
+ "@applicaster/zapp-react-native-utils": "12.0.3-alpha.5953460913",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",