@etsoo/materialui 1.2.62 → 1.2.63

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/HiSelector.js CHANGED
@@ -17,7 +17,6 @@ export function HiSelector(props) {
17
17
  const doChange = (event, index) => {
18
18
  const value = event.target.value;
19
19
  const itemValue = value === "" ? undefined : value;
20
- updateValue(itemValue);
21
20
  const newValues = [...localValues.slice(0, index)];
22
21
  if (itemValue != null)
23
22
  newValues.push(itemValue);
@@ -33,12 +32,12 @@ export function HiSelector(props) {
33
32
  onItemChange(option, userAction);
34
33
  };
35
34
  React.useEffect(() => {
36
- if (values.length > 0) {
37
- setValues(values);
38
- updateValue(values.at(-1));
39
- }
35
+ setValues(values);
40
36
  }, [values]);
41
37
  const currentValue = localValues.at(-1);
38
+ React.useEffect(() => {
39
+ updateValue(currentValue);
40
+ }, [currentValue]);
42
41
  return (React.createElement(React.Fragment, null,
43
42
  label && (React.createElement(Grid, { item: true, xs: 12 },
44
43
  React.createElement(FormLabel, { required: required, sx: { fontSize: (theme) => theme.typography.caption } }, label))),
@@ -20,20 +20,18 @@ export function HiSelectorTL(props) {
20
20
  if (event.isDefaultPrevented())
21
21
  return;
22
22
  }
23
- const itemValue = value ? value[idField] : undefined;
24
- updateValue(itemValue);
25
23
  const newValues = [...localValues.slice(0, index)];
26
- if (itemValue != null)
27
- newValues.push(itemValue);
24
+ if (value)
25
+ newValues.push(value[idField]);
28
26
  setValues(newValues);
29
27
  };
30
28
  React.useEffect(() => {
31
- if (values.length > 0) {
32
- setValues(values);
33
- updateValue(values.at(-1));
34
- }
35
- }, [values.toString()]);
29
+ setValues(values);
30
+ }, [values]);
36
31
  const currentValue = localValues.at(-1);
32
+ React.useEffect(() => {
33
+ updateValue(currentValue);
34
+ }, [currentValue]);
37
35
  return (React.createElement(React.Fragment, null,
38
36
  label && (React.createElement(Grid, { item: true, xs: 12 },
39
37
  React.createElement(FormLabel, { required: required, sx: { fontSize: (theme) => theme.typography.caption } }, label))),
@@ -14,6 +14,10 @@ export interface ListChooserButtonProps<T extends object, D extends DataTypes.Ke
14
14
  * List chooser props
15
15
  */
16
16
  export type ListChooserProps<T extends object, D extends DataTypes.Keys<T>, Q extends object> = ListProps & {
17
+ /**
18
+ * Condition field name
19
+ */
20
+ conditionField?: string;
17
21
  /**
18
22
  * Condition renderer
19
23
  */
@@ -29,7 +29,7 @@ export function ListChooser(props) {
29
29
  }
30
30
  });
31
31
  // Destruct
32
- const { conditionRenderer = (rq, delayed) => (React.createElement(TextField, { autoFocus: true, margin: "dense", name: "title", label: title, fullWidth: true, variant: "standard", inputProps: { maxLength: 128 }, onChange: (event) => {
32
+ const { conditionField = "title", conditionRenderer = (rq, delayed) => (React.createElement(TextField, { autoFocus: true, margin: "dense", name: conditionField, label: title, fullWidth: true, variant: "standard", inputProps: { maxLength: 128 }, onChange: (event) => {
33
33
  Reflect.set(rq, "title", event.target.value);
34
34
  delayed.call();
35
35
  } })), itemRenderer = (item, selectProps) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.2.62",
3
+ "version": "1.2.63",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -55,11 +55,11 @@
55
55
  "@etsoo/react": "^1.6.94",
56
56
  "@etsoo/shared": "^1.2.7",
57
57
  "@mui/icons-material": "^5.11.16",
58
- "@mui/material": "^5.13.5",
59
- "@mui/x-data-grid": "^6.9.0",
58
+ "@mui/material": "^5.13.6",
59
+ "@mui/x-data-grid": "^6.9.1",
60
60
  "@types/pica": "^9.0.1",
61
61
  "@types/pulltorefreshjs": "^0.1.5",
62
- "@types/react": "^18.2.13",
62
+ "@types/react": "^18.2.14",
63
63
  "@types/react-avatar-editor": "^13.0.0",
64
64
  "@types/react-dom": "^18.2.6",
65
65
  "@types/react-input-mask": "^3.0.2",
@@ -85,8 +85,8 @@
85
85
  "@testing-library/jest-dom": "^5.16.5",
86
86
  "@testing-library/react": "^14.0.0",
87
87
  "@types/jest": "^29.5.2",
88
- "@typescript-eslint/eslint-plugin": "^5.60.0",
89
- "@typescript-eslint/parser": "^5.60.0",
88
+ "@typescript-eslint/eslint-plugin": "^5.60.1",
89
+ "@typescript-eslint/parser": "^5.60.1",
90
90
  "jest": "^29.5.0",
91
91
  "jest-environment-jsdom": "^29.5.0",
92
92
  "typescript": "^5.1.3"
@@ -126,7 +126,6 @@ export function HiSelector<
126
126
  const doChange = (event: SelectChangeEvent<unknown>, index: number) => {
127
127
  const value = event.target.value;
128
128
  const itemValue = value === "" ? undefined : (value as T[D]);
129
- updateValue(itemValue);
130
129
 
131
130
  const newValues = [...localValues.slice(0, index)];
132
131
  if (itemValue != null) newValues.push(itemValue);
@@ -143,13 +142,13 @@ export function HiSelector<
143
142
  };
144
143
 
145
144
  React.useEffect(() => {
146
- if (values.length > 0) {
147
- setValues(values);
148
- updateValue(values.at(-1));
149
- }
145
+ setValues(values);
150
146
  }, [values]);
151
147
 
152
148
  const currentValue = localValues.at(-1);
149
+ React.useEffect(() => {
150
+ updateValue(currentValue);
151
+ }, [currentValue]);
153
152
 
154
153
  return (
155
154
  <React.Fragment>
@@ -130,22 +130,20 @@ export function HiSelectorTL<
130
130
  if (event.isDefaultPrevented()) return;
131
131
  }
132
132
 
133
- const itemValue = value ? value[idField] : undefined;
134
- updateValue(itemValue);
135
-
136
133
  const newValues = [...localValues.slice(0, index)];
137
- if (itemValue != null) newValues.push(itemValue);
134
+ if (value) newValues.push(value[idField]);
135
+
138
136
  setValues(newValues);
139
137
  };
140
138
 
141
139
  React.useEffect(() => {
142
- if (values.length > 0) {
143
- setValues(values);
144
- updateValue(values.at(-1));
145
- }
146
- }, [values.toString()]);
140
+ setValues(values);
141
+ }, [values]);
147
142
 
148
143
  const currentValue = localValues.at(-1);
144
+ React.useEffect(() => {
145
+ updateValue(currentValue);
146
+ }, [currentValue]);
149
147
 
150
148
  return (
151
149
  <React.Fragment>
@@ -35,6 +35,11 @@ export type ListChooserProps<
35
35
  D extends DataTypes.Keys<T>,
36
36
  Q extends object
37
37
  > = ListProps & {
38
+ /**
39
+ * Condition field name
40
+ */
41
+ conditionField?: string;
42
+
38
43
  /**
39
44
  * Condition renderer
40
45
  */
@@ -116,11 +121,12 @@ export function ListChooser<
116
121
 
117
122
  // Destruct
118
123
  const {
124
+ conditionField = "title",
119
125
  conditionRenderer = (rq: Partial<Q>, delayed: DelayedExecutorType) => (
120
126
  <TextField
121
127
  autoFocus
122
128
  margin="dense"
123
- name="title"
129
+ name={conditionField}
124
130
  label={title}
125
131
  fullWidth
126
132
  variant="standard"