react-ui-basics 0.0.249 → 0.0.251
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/FilteredList.d.ts +1 -1
- package/FilteredList.js +3 -3
- package/FilteredList.js.map +1 -1
- package/Tools.d.ts +2 -2
- package/Tools.js +4 -4
- package/Tools.js.map +1 -1
- package/bundle.css +611 -611
- package/package.json +1 -1
- package/src/FilteredList.tsx +5 -5
- package/src/Tools.ts +5 -5
package/package.json
CHANGED
package/src/FilteredList.tsx
CHANGED
|
@@ -17,7 +17,7 @@ export interface FilteredListProps<T> {
|
|
|
17
17
|
selectedProvider?: (cb: () => void) => void
|
|
18
18
|
data: T[]
|
|
19
19
|
labels?: Labels<T>
|
|
20
|
-
filter?: (item: T) => boolean
|
|
20
|
+
filter?: (item: any, id: T) => boolean
|
|
21
21
|
className?: string
|
|
22
22
|
selected?: T | { [key: string]: boolean } | { [key: number]: boolean }
|
|
23
23
|
inline?: boolean
|
|
@@ -99,8 +99,8 @@ class FilteredList<T extends string|number> extends PureComponent<FilteredListPr
|
|
|
99
99
|
onMouseEnter={e => this.setState({selected: id})}
|
|
100
100
|
onMouseLeave={e => id === this.state.selected && this.setState({selected: null})}
|
|
101
101
|
className={classNames('child', this.state.selected === id && 'active', selected === id || (isObject(selected) && selected[id as (string | number)]) && 'selected')}
|
|
102
|
-
classProvider={it => {
|
|
103
|
-
const hidden = !filter(it);
|
|
102
|
+
classProvider={(it, id) => {
|
|
103
|
+
const hidden = !filter(it, id);
|
|
104
104
|
this.hidden.set(id, hidden)
|
|
105
105
|
return hidden && 'hidden';
|
|
106
106
|
}}
|
|
@@ -191,7 +191,7 @@ interface ItemWrapperProps {
|
|
|
191
191
|
onMouseDown?: MouseEventHandler
|
|
192
192
|
onMouseEnter?: MouseEventHandler
|
|
193
193
|
onMouseLeave?: MouseEventHandler
|
|
194
|
-
classProvider?: (data) => string
|
|
194
|
+
classProvider?: (data, id) => string
|
|
195
195
|
className?: string
|
|
196
196
|
childComponent
|
|
197
197
|
childProps
|
|
@@ -211,7 +211,7 @@ class ItemWrapper extends React.Component<ItemWrapperProps> {
|
|
|
211
211
|
dataConsumer: (data) => this.data = data,
|
|
212
212
|
});
|
|
213
213
|
|
|
214
|
-
const cssClass = orNoop(classProvider)(this.data);
|
|
214
|
+
const cssClass = orNoop(classProvider)(this.data, id);
|
|
215
215
|
return (
|
|
216
216
|
<div className={classNames('ItemWrapper', cssClass, className)}
|
|
217
217
|
onMouseEnter={onMouseEnter}
|
package/src/Tools.ts
CHANGED
|
@@ -2,6 +2,9 @@ var global = global || window;
|
|
|
2
2
|
export const WINDOW: Window = global as Window;
|
|
3
3
|
export const DOCUMENT = WINDOW.document;
|
|
4
4
|
|
|
5
|
+
export const UNDEFINED = undefined;
|
|
6
|
+
export const isUndefined = a => a === UNDEFINED;
|
|
7
|
+
|
|
5
8
|
export function classNames(...classes: Array<string | number | boolean | null | void>) {
|
|
6
9
|
const filtered = [];
|
|
7
10
|
const length = classes.length;
|
|
@@ -27,14 +30,14 @@ export const ref = (name, component) => {
|
|
|
27
30
|
export const createRef = <T>(initialValue?: T) => {
|
|
28
31
|
let v = initialValue;
|
|
29
32
|
return (value?: any) => {
|
|
30
|
-
if (value
|
|
33
|
+
if (!isUndefined(value))
|
|
31
34
|
v = value
|
|
32
35
|
return v;
|
|
33
36
|
};
|
|
34
37
|
};
|
|
35
38
|
|
|
36
39
|
export const createAccessor = (field: string) => (o: any, value?: any) => {
|
|
37
|
-
return !o ? null : value
|
|
40
|
+
return !o ? null : isUndefined(value) ? o[field] : o[field] = value
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
export const setOf = (list) => (list || []).reduce((map, key) => {
|
|
@@ -167,9 +170,6 @@ export const removeEventListener = (el, type, listener, options?) => {
|
|
|
167
170
|
el && el.removeEventListener(type, listener, options);
|
|
168
171
|
};
|
|
169
172
|
|
|
170
|
-
export const UNDEFINED = undefined;
|
|
171
|
-
export const isUndefined = a => a === UNDEFINED;
|
|
172
|
-
|
|
173
173
|
export type ComparatorFunction<T> = (a: T, b: T) => number;
|
|
174
174
|
export interface Comparator<T> extends ComparatorFunction<T>{
|
|
175
175
|
inverse : <T>() => Comparator<T>
|