@etsoo/materialui 1.3.71 → 1.3.73

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/lib/SelectEx.js CHANGED
@@ -32,11 +32,14 @@ export function SelectEx(props) {
32
32
  }
33
33
  onItemChange(option, userAction);
34
34
  };
35
- const setOptionsAdd = (options) => {
35
+ // Local value
36
+ const v = defaultValue ?? value;
37
+ const valueSource = React.useMemo(() => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""), [multiple, v]);
38
+ const setOptionsAdd = React.useCallback((options) => {
36
39
  setOptions(options);
37
40
  if (valueSource != null)
38
41
  doItemChange(options, valueSource, false);
39
- };
42
+ }, [valueSource]);
40
43
  // When options change
41
44
  // [options] will cause infinite loop
42
45
  const propertyWay = loadData == null;
@@ -44,10 +47,7 @@ export function SelectEx(props) {
44
47
  if (options == null || !propertyWay)
45
48
  return;
46
49
  setOptionsAdd(options);
47
- }, [options, propertyWay]);
48
- // Local value
49
- const v = defaultValue ?? value;
50
- const valueSource = React.useMemo(() => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""), [multiple, v]);
50
+ }, [options, propertyWay, setOptionsAdd]);
51
51
  // Value state
52
52
  const [valueState, setValueStateBase] = React.useState(valueSource);
53
53
  const valueRef = React.useRef();
@@ -1,4 +1,4 @@
1
- import { CoreApp, IApp, IAppSettings, ICoreApp, IUser } from "@etsoo/appscript";
1
+ import { CoreApp, FormatResultCustomCallback, IApp, IAppSettings, ICoreApp, IUser } from "@etsoo/appscript";
2
2
  import { INotifier, NotificationReturn } from "@etsoo/notificationbase";
3
3
  import { DataTypes, IActionResult } from "@etsoo/shared";
4
4
  import React from "react";
@@ -143,8 +143,9 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
143
143
  * Override alert action result
144
144
  * @param result Action result
145
145
  * @param callback Callback
146
+ * @param forceToLocal Force to local labels
146
147
  */
147
- alertResult(result: IActionResult | string, callback?: NotificationReturn<void>): void;
148
+ alertResult(result: IActionResult | string, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
148
149
  /**
149
150
  * Change culture
150
151
  * @param culture New culture definition
@@ -86,9 +86,12 @@ export class ReactApp extends CoreApp {
86
86
  * Override alert action result
87
87
  * @param result Action result
88
88
  * @param callback Callback
89
+ * @param forceToLocal Force to local labels
89
90
  */
90
- alertResult(result, callback) {
91
- const message = typeof result === "string" ? result : this.formatResult(result);
91
+ alertResult(result, callback, forceToLocal) {
92
+ const message = typeof result === "string"
93
+ ? result
94
+ : this.formatResult(result, forceToLocal);
92
95
  if (message.endsWith(")")) {
93
96
  const startPos = message.lastIndexOf("(");
94
97
  if (startPos > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.3.71",
3
+ "version": "1.3.73",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/SelectEx.tsx CHANGED
@@ -171,10 +171,20 @@ export function SelectEx<
171
171
  onItemChange(option, userAction);
172
172
  };
173
173
 
174
- const setOptionsAdd = (options: readonly T[]) => {
175
- setOptions(options);
176
- if (valueSource != null) doItemChange(options, valueSource, false);
177
- };
174
+ // Local value
175
+ const v = defaultValue ?? value;
176
+ const valueSource = React.useMemo(
177
+ () => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""),
178
+ [multiple, v]
179
+ );
180
+
181
+ const setOptionsAdd = React.useCallback(
182
+ (options: readonly T[]) => {
183
+ setOptions(options);
184
+ if (valueSource != null) doItemChange(options, valueSource, false);
185
+ },
186
+ [valueSource]
187
+ );
178
188
 
179
189
  // When options change
180
190
  // [options] will cause infinite loop
@@ -182,14 +192,7 @@ export function SelectEx<
182
192
  React.useEffect(() => {
183
193
  if (options == null || !propertyWay) return;
184
194
  setOptionsAdd(options);
185
- }, [options, propertyWay]);
186
-
187
- // Local value
188
- const v = defaultValue ?? value;
189
- const valueSource = React.useMemo(
190
- () => (multiple ? (v ? (Array.isArray(v) ? v : [v]) : []) : v ?? ""),
191
- [multiple, v]
192
- );
195
+ }, [options, propertyWay, setOptionsAdd]);
193
196
 
194
197
  // Value state
195
198
  const [valueState, setValueStateBase] = React.useState<unknown>(valueSource);
@@ -2,6 +2,7 @@ import {
2
2
  BridgeUtils,
3
3
  CoreApp,
4
4
  createClient,
5
+ FormatResultCustomCallback,
5
6
  IApp,
6
7
  IAppSettings,
7
8
  ICoreApp,
@@ -278,13 +279,17 @@ export class ReactApp<
278
279
  * Override alert action result
279
280
  * @param result Action result
280
281
  * @param callback Callback
282
+ * @param forceToLocal Force to local labels
281
283
  */
282
284
  override alertResult(
283
285
  result: IActionResult | string,
284
- callback?: NotificationReturn<void>
286
+ callback?: NotificationReturn<void>,
287
+ forceToLocal?: FormatResultCustomCallback
285
288
  ) {
286
289
  const message =
287
- typeof result === "string" ? result : this.formatResult(result);
290
+ typeof result === "string"
291
+ ? result
292
+ : this.formatResult(result, forceToLocal);
288
293
  if (message.endsWith(")")) {
289
294
  const startPos = message.lastIndexOf("(");
290
295
  if (startPos > 0) {