@etsoo/react 1.7.9 → 1.7.10

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.
@@ -27,9 +27,9 @@ export declare namespace ReactUtils {
27
27
  * Update refs
28
28
  * @param refs Refs
29
29
  * @param data Data
30
- * @param callback Callback to update refs' value
30
+ * @param callback Callback to update refs' value, return false continue to process
31
31
  */
32
- function updateRefs<D, T = HTMLInputElement>(refs: Partial<DataTypes.DI<ReadonlyArray<keyof D & string>, React.MutableRefObject<T | undefined>>>, data: D, callback?: ((item: T, value: D[keyof D & string]) => void) | keyof T): void;
32
+ function updateRefs<D, T = HTMLInputElement>(refs: Partial<DataTypes.DI<ReadonlyArray<keyof D & string>, React.MutableRefObject<T | undefined>>>, data: D, callback?: ((item: T, value: D[keyof D & string]) => void | boolean) | keyof T): void;
33
33
  /**
34
34
  * Update data with refs
35
35
  * @param refs Refs
@@ -1,3 +1,4 @@
1
+ import { DomUtils } from '@etsoo/shared';
1
2
  /**
2
3
  * React utils
3
4
  */
@@ -88,7 +89,7 @@ export var ReactUtils;
88
89
  * Update refs
89
90
  * @param refs Refs
90
91
  * @param data Data
91
- * @param callback Callback to update refs' value
92
+ * @param callback Callback to update refs' value, return false continue to process
92
93
  */
93
94
  function updateRefs(refs, data, callback) {
94
95
  const local = callback == null
@@ -105,12 +106,14 @@ export var ReactUtils;
105
106
  if (item == null)
106
107
  continue;
107
108
  const value = data[k];
108
- if (local) {
109
- local(item, value);
109
+ if (local && local(item, value) !== false) {
110
+ continue;
111
+ }
112
+ else if (item instanceof HTMLInputElement) {
113
+ item.value = `${value !== null && value !== void 0 ? value : ''}`;
110
114
  }
111
115
  else {
112
- // Straightforward set string value to property "value"
113
- item.value = value !== null && value !== void 0 ? value : '';
116
+ item.value = value;
114
117
  }
115
118
  }
116
119
  }
@@ -136,6 +139,9 @@ export var ReactUtils;
136
139
  if (local) {
137
140
  data[k] = local(item);
138
141
  }
142
+ else if (item instanceof HTMLInputElement) {
143
+ data[k] = DomUtils.getInputValue(item);
144
+ }
139
145
  else {
140
146
  data[k] = item.value;
141
147
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.7.9",
3
+ "version": "1.7.10",
4
4
  "description": "TypeScript ReactJs UI Independent Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, DomUtils } from '@etsoo/shared';
2
2
  import React from 'react';
3
3
 
4
4
  /**
@@ -104,7 +104,7 @@ export namespace ReactUtils {
104
104
  * Update refs
105
105
  * @param refs Refs
106
106
  * @param data Data
107
- * @param callback Callback to update refs' value
107
+ * @param callback Callback to update refs' value, return false continue to process
108
108
  */
109
109
  export function updateRefs<D, T = HTMLInputElement>(
110
110
  refs: Partial<
@@ -114,7 +114,9 @@ export namespace ReactUtils {
114
114
  >
115
115
  >,
116
116
  data: D,
117
- callback?: ((item: T, value: D[keyof D & string]) => void) | keyof T
117
+ callback?:
118
+ | ((item: T, value: D[keyof D & string]) => void | boolean)
119
+ | keyof T
118
120
  ) {
119
121
  const local: typeof callback =
120
122
  callback == null
@@ -132,11 +134,12 @@ export namespace ReactUtils {
132
134
  if (item == null) continue;
133
135
  const value = data[k];
134
136
 
135
- if (local) {
136
- local(item, value);
137
+ if (local && local(item, value) !== false) {
138
+ continue;
139
+ } else if (item instanceof HTMLInputElement) {
140
+ item.value = `${value ?? ''}`;
137
141
  } else {
138
- // Straightforward set string value to property "value"
139
- (item as any).value = value ?? '';
142
+ (item as any).value = value;
140
143
  }
141
144
  }
142
145
  }
@@ -172,6 +175,8 @@ export namespace ReactUtils {
172
175
 
173
176
  if (local) {
174
177
  data[k] = local(item);
178
+ } else if (item instanceof HTMLInputElement) {
179
+ data[k] = DomUtils.getInputValue(item) as any;
175
180
  } else {
176
181
  data[k] = (item as any).value;
177
182
  }