@etsoo/materialui 1.0.3 → 1.0.4
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 +4 -0
- package/lib/SelectEx.js +4 -2
- package/package.json +1 -1
- package/src/SelectEx.tsx +11 -0
package/lib/SelectEx.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export declare type SelectExProps<T extends object, D extends DataTypes.Keys<T>
|
|
|
17
17
|
* Item icon renderer
|
|
18
18
|
*/
|
|
19
19
|
itemIconRenderer?: (id: T[D]) => React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Item style
|
|
22
|
+
*/
|
|
23
|
+
itemStyle?: (option: T) => React.CSSProperties;
|
|
20
24
|
/**
|
|
21
25
|
* Label field
|
|
22
26
|
*/
|
package/lib/SelectEx.js
CHANGED
|
@@ -12,7 +12,7 @@ import { ReactUtils } from '@etsoo/react';
|
|
|
12
12
|
export function SelectEx(props) {
|
|
13
13
|
var _a;
|
|
14
14
|
// Destruct
|
|
15
|
-
const { defaultValue, idField = 'id', itemIconRenderer, label, labelField = 'label', loadData, onItemClick, onLoadData, multiple = false, name, options = [], search = false, autoAddBlankItem = search, value, onChange, fullWidth, ...rest } = props;
|
|
15
|
+
const { defaultValue, idField = 'id', itemIconRenderer, itemStyle, label, labelField = 'label', loadData, onItemClick, onLoadData, multiple = false, name, options = [], search = false, autoAddBlankItem = search, value, onChange, fullWidth, ...rest } = props;
|
|
16
16
|
// Options state
|
|
17
17
|
const [localOptions, setOptions] = React.useState(options);
|
|
18
18
|
const isMounted = React.useRef(true);
|
|
@@ -148,7 +148,9 @@ export function SelectEx(props) {
|
|
|
148
148
|
}
|
|
149
149
|
if (!multiple)
|
|
150
150
|
setItemValue(id);
|
|
151
|
-
}
|
|
151
|
+
}, style: itemStyle == null
|
|
152
|
+
? undefined
|
|
153
|
+
: itemStyle(option) },
|
|
152
154
|
multiple && React.createElement(Checkbox, { checked: itemChecked(id) }),
|
|
153
155
|
React.createElement(ListItemText, { primary: label }),
|
|
154
156
|
itemIconRenderer && (React.createElement(ListItemRightIcon, null, itemIconRenderer(option[idField])))));
|
package/package.json
CHANGED
package/src/SelectEx.tsx
CHANGED
|
@@ -44,6 +44,11 @@ export type SelectExProps<
|
|
|
44
44
|
*/
|
|
45
45
|
itemIconRenderer?: (id: T[D]) => React.ReactNode;
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Item style
|
|
49
|
+
*/
|
|
50
|
+
itemStyle?: (option: T) => React.CSSProperties;
|
|
51
|
+
|
|
47
52
|
/**
|
|
48
53
|
* Label field
|
|
49
54
|
*/
|
|
@@ -90,6 +95,7 @@ export function SelectEx<
|
|
|
90
95
|
defaultValue,
|
|
91
96
|
idField = 'id' as D,
|
|
92
97
|
itemIconRenderer,
|
|
98
|
+
itemStyle,
|
|
93
99
|
label,
|
|
94
100
|
labelField = 'label' as L,
|
|
95
101
|
loadData,
|
|
@@ -273,6 +279,11 @@ export function SelectEx<
|
|
|
273
279
|
}
|
|
274
280
|
if (!multiple) setItemValue(id);
|
|
275
281
|
}}
|
|
282
|
+
style={
|
|
283
|
+
itemStyle == null
|
|
284
|
+
? undefined
|
|
285
|
+
: itemStyle(option)
|
|
286
|
+
}
|
|
276
287
|
>
|
|
277
288
|
{multiple && <Checkbox checked={itemChecked(id)} />}
|
|
278
289
|
<ListItemText primary={label} />
|