@etsoo/materialui 1.0.27 → 1.0.28

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.d.ts CHANGED
@@ -45,10 +45,6 @@ export declare type SelectExProps<T extends object, D extends DataTypes.Keys<T>
45
45
  * Item click handler
46
46
  */
47
47
  onItemClick?: (event: React.MouseEvent, option: T) => void;
48
- /**
49
- * Item mouse down handler
50
- */
51
- onItemMouseDown?: (event: React.MouseEvent, option: T) => void;
52
48
  /**
53
49
  * On load data handler
54
50
  */
package/lib/SelectEx.js CHANGED
@@ -11,7 +11,7 @@ import { Utils } from '@etsoo/shared';
11
11
  export function SelectEx(props) {
12
12
  var _a;
13
13
  // Destruct
14
- const { defaultValue, idField = 'id', error, helperText, inputRequired, itemIconRenderer, itemStyle, label, labelField = 'label', loadData, onItemChange, onItemClick, onItemMouseDown, onLoadData, multiple = false, name, options, search = false, autoAddBlankItem = search, value, onChange, fullWidth, ...rest } = props;
14
+ const { defaultValue, idField = 'id', error, helperText, inputRequired, itemIconRenderer, itemStyle, label, labelField = 'label', loadData, onItemChange, onItemClick, onLoadData, multiple = false, name, options, search = false, autoAddBlankItem = search, value, onChange, fullWidth, ...rest } = props;
15
15
  // Options state
16
16
  const [localOptions, setOptions] = React.useState([]);
17
17
  const isMounted = React.useRef(true);
@@ -135,8 +135,12 @@ export function SelectEx(props) {
135
135
  React.createElement(Select, { ref: divRef, value: localOptions.some((option) => itemChecked(getId(option)))
136
136
  ? valueState !== null && valueState !== void 0 ? valueState : ''
137
137
  : '', input: React.createElement(OutlinedInput, { notched: true, label: label, required: inputRequired }), labelId: labelId, name: name, multiple: multiple, onChange: (event, child) => {
138
- if (onChange)
138
+ if (onChange) {
139
139
  onChange(event, child);
140
+ // event.preventDefault() will block executing
141
+ if (event.defaultPrevented)
142
+ return;
143
+ }
140
144
  doItemChange(localOptions, event.target.value, true);
141
145
  handleChange(event);
142
146
  }, renderValue: (selected) => {
@@ -160,10 +164,6 @@ export function SelectEx(props) {
160
164
  if (onItemClick) {
161
165
  onItemClick(event, option);
162
166
  }
163
- }, onMouseDown: (event) => {
164
- if (onItemMouseDown) {
165
- onItemMouseDown(event, option);
166
- }
167
167
  }, style: itemStyle == null
168
168
  ? undefined
169
169
  : itemStyle(option) },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
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
@@ -79,11 +79,6 @@ export type SelectExProps<
79
79
  */
80
80
  onItemClick?: (event: React.MouseEvent, option: T) => void;
81
81
 
82
- /**
83
- * Item mouse down handler
84
- */
85
- onItemMouseDown?: (event: React.MouseEvent, option: T) => void;
86
-
87
82
  /**
88
83
  * On load data handler
89
84
  */
@@ -124,7 +119,6 @@ export function SelectEx<
124
119
  loadData,
125
120
  onItemChange,
126
121
  onItemClick,
127
- onItemMouseDown,
128
122
  onLoadData,
129
123
  multiple = false,
130
124
  name,
@@ -296,7 +290,12 @@ export function SelectEx<
296
290
  name={name}
297
291
  multiple={multiple}
298
292
  onChange={(event, child) => {
299
- if (onChange) onChange(event, child);
293
+ if (onChange) {
294
+ onChange(event, child);
295
+
296
+ // event.preventDefault() will block executing
297
+ if (event.defaultPrevented) return;
298
+ }
300
299
  doItemChange(localOptions, event.target.value, true);
301
300
  handleChange(event);
302
301
  }}
@@ -333,11 +332,6 @@ export function SelectEx<
333
332
  onItemClick(event, option);
334
333
  }
335
334
  }}
336
- onMouseDown={(event) => {
337
- if (onItemMouseDown) {
338
- onItemMouseDown(event, option);
339
- }
340
- }}
341
335
  style={
342
336
  itemStyle == null
343
337
  ? undefined