@etsoo/materialui 1.5.56 → 1.5.57

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.
@@ -40,7 +40,7 @@ export type ButtonPopupCheckboxProps<D extends DnDItemType> = Omit<ButtonProps,
40
40
  /**
41
41
  * Load data
42
42
  */
43
- loadData: () => Promise<D[]>;
43
+ loadData: D[] | (() => Promise<D[]>);
44
44
  /**
45
45
  * On add handler
46
46
  * @param ids Ids
@@ -90,12 +90,17 @@ function ButtonPopupCheckbox(props) {
90
90
  const [items, setItems] = react_1.default.useState([]);
91
91
  const [selectedIds, setSelectedIds] = react_1.default.useState();
92
92
  react_1.default.useEffect(() => {
93
- // Load data
94
- loadData().then((data) => {
95
- if (data != null) {
96
- setItems(data);
97
- }
98
- });
93
+ if (typeof loadData === "function") {
94
+ // Load data
95
+ loadData().then((data) => {
96
+ if (data != null) {
97
+ setItems(data);
98
+ }
99
+ });
100
+ }
101
+ else {
102
+ setItems(loadData);
103
+ }
99
104
  }, [loadData]);
100
105
  react_1.default.useEffect(() => {
101
106
  // Set selected ids
@@ -40,7 +40,7 @@ export type ButtonPopupRadioProps<D extends DnDItemType> = Omit<ButtonProps, "ch
40
40
  /**
41
41
  * Load data
42
42
  */
43
- loadData: () => Promise<D[]>;
43
+ loadData: D[] | (() => Promise<D[]>);
44
44
  /**
45
45
  * On add handler
46
46
  * @param ids Ids
@@ -86,12 +86,17 @@ function ButtonPopupRadio(props) {
86
86
  ? items.find((item) => item.id === currentValue)
87
87
  : undefined;
88
88
  react_1.default.useEffect(() => {
89
- // Load data
90
- loadData().then((data) => {
91
- if (data != null) {
92
- setItems(data);
93
- }
94
- });
89
+ if (typeof loadData === "function") {
90
+ // Load data
91
+ loadData().then((data) => {
92
+ if (data != null) {
93
+ setItems(data);
94
+ }
95
+ });
96
+ }
97
+ else {
98
+ setItems(loadData);
99
+ }
95
100
  }, [loadData]);
96
101
  react_1.default.useEffect(() => {
97
102
  setCurrentValue(value);
@@ -40,7 +40,7 @@ export type ButtonPopupCheckboxProps<D extends DnDItemType> = Omit<ButtonProps,
40
40
  /**
41
41
  * Load data
42
42
  */
43
- loadData: () => Promise<D[]>;
43
+ loadData: D[] | (() => Promise<D[]>);
44
44
  /**
45
45
  * On add handler
46
46
  * @param ids Ids
@@ -84,12 +84,17 @@ export function ButtonPopupCheckbox(props) {
84
84
  const [items, setItems] = React.useState([]);
85
85
  const [selectedIds, setSelectedIds] = React.useState();
86
86
  React.useEffect(() => {
87
- // Load data
88
- loadData().then((data) => {
89
- if (data != null) {
90
- setItems(data);
91
- }
92
- });
87
+ if (typeof loadData === "function") {
88
+ // Load data
89
+ loadData().then((data) => {
90
+ if (data != null) {
91
+ setItems(data);
92
+ }
93
+ });
94
+ }
95
+ else {
96
+ setItems(loadData);
97
+ }
93
98
  }, [loadData]);
94
99
  React.useEffect(() => {
95
100
  // Set selected ids
@@ -40,7 +40,7 @@ export type ButtonPopupRadioProps<D extends DnDItemType> = Omit<ButtonProps, "ch
40
40
  /**
41
41
  * Load data
42
42
  */
43
- loadData: () => Promise<D[]>;
43
+ loadData: D[] | (() => Promise<D[]>);
44
44
  /**
45
45
  * On add handler
46
46
  * @param ids Ids
@@ -80,12 +80,17 @@ export function ButtonPopupRadio(props) {
80
80
  ? items.find((item) => item.id === currentValue)
81
81
  : undefined;
82
82
  React.useEffect(() => {
83
- // Load data
84
- loadData().then((data) => {
85
- if (data != null) {
86
- setItems(data);
87
- }
88
- });
83
+ if (typeof loadData === "function") {
84
+ // Load data
85
+ loadData().then((data) => {
86
+ if (data != null) {
87
+ setItems(data);
88
+ }
89
+ });
90
+ }
91
+ else {
92
+ setItems(loadData);
93
+ }
89
94
  }, [loadData]);
90
95
  React.useEffect(() => {
91
96
  setCurrentValue(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.5.56",
3
+ "version": "1.5.57",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -40,7 +40,7 @@
40
40
  "@dnd-kit/sortable": "^10.0.0",
41
41
  "@emotion/react": "^11.14.0",
42
42
  "@emotion/styled": "^11.14.0",
43
- "@etsoo/appscript": "^1.6.36",
43
+ "@etsoo/appscript": "^1.6.38",
44
44
  "@etsoo/notificationbase": "^1.1.62",
45
45
  "@etsoo/react": "^1.8.45",
46
46
  "@etsoo/shared": "^1.2.74",
@@ -67,7 +67,7 @@ export type ButtonPopupCheckboxProps<D extends DnDItemType> = Omit<
67
67
  /**
68
68
  * Load data
69
69
  */
70
- loadData: () => Promise<D[]>;
70
+ loadData: D[] | (() => Promise<D[]>);
71
71
 
72
72
  /**
73
73
  * On add handler
@@ -296,12 +296,16 @@ export function ButtonPopupCheckbox<D extends DnDItemType>(
296
296
  const [selectedIds, setSelectedIds] = React.useState<D["id"][]>();
297
297
 
298
298
  React.useEffect(() => {
299
- // Load data
300
- loadData().then((data) => {
301
- if (data != null) {
302
- setItems(data);
303
- }
304
- });
299
+ if (typeof loadData === "function") {
300
+ // Load data
301
+ loadData().then((data) => {
302
+ if (data != null) {
303
+ setItems(data);
304
+ }
305
+ });
306
+ } else {
307
+ setItems(loadData);
308
+ }
305
309
  }, [loadData]);
306
310
 
307
311
  React.useEffect(() => {
@@ -64,7 +64,7 @@ export type ButtonPopupRadioProps<D extends DnDItemType> = Omit<
64
64
  /**
65
65
  * Load data
66
66
  */
67
- loadData: () => Promise<D[]>;
67
+ loadData: D[] | (() => Promise<D[]>);
68
68
 
69
69
  /**
70
70
  * On add handler
@@ -270,12 +270,16 @@ export function ButtonPopupRadio<D extends DnDItemType>(
270
270
  : undefined;
271
271
 
272
272
  React.useEffect(() => {
273
- // Load data
274
- loadData().then((data) => {
275
- if (data != null) {
276
- setItems(data);
277
- }
278
- });
273
+ if (typeof loadData === "function") {
274
+ // Load data
275
+ loadData().then((data) => {
276
+ if (data != null) {
277
+ setItems(data);
278
+ }
279
+ });
280
+ } else {
281
+ setItems(loadData);
282
+ }
279
283
  }, [loadData]);
280
284
 
281
285
  React.useEffect(() => {