react-ui-basics 0.0.173 → 0.0.174
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/AutocompleteSelect.js +23 -9
- package/FilteredList.d.ts +61 -0
- package/FilteredList.js +139 -234
- package/Table.d.ts +17 -2
- package/Table.js +27 -14
- package/TextField.js +4 -2
- package/bundle.css +515 -515
- package/package.json +4 -4
package/AutocompleteSelect.js
CHANGED
|
@@ -10,7 +10,7 @@ import ReactCreateElement from './ReactCreateElement.js';
|
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import TextField from './TextField.js';
|
|
12
12
|
import FilteredList, { getLabel } from './FilteredList.js';
|
|
13
|
-
import {
|
|
13
|
+
import { memo, isString, continuousIncludes, orNoop, isObject, preventDefault, stopPropagation, getRandomId, isFunction, addEventListener, DOCUMENT, removeEventListener, UNDEFINED, classNames, ref } from './Tools.js';
|
|
14
14
|
import Button from './Button.js';
|
|
15
15
|
import MaterialIcon from './MaterialIcon.js';
|
|
16
16
|
import { PureComponent } from './ReactConstants.js';
|
|
@@ -75,7 +75,7 @@ var AutocompleteSelect = function (_PureComponent) {
|
|
|
75
75
|
filterValue = _ref3$filterValue === void 0 ? '' : _ref3$filterValue;
|
|
76
76
|
_this.setState({
|
|
77
77
|
selected: prepareSelected(value),
|
|
78
|
-
filterValue: allowCustom &&
|
|
78
|
+
filterValue: allowCustom && !isMultipleSelect(mode) ? _this.getCustomValue(allowCustom, value, __props(_this).labels) : filterValue
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
81
|
_this.createFilter = memo(function (prefilter, filterValue, filterValueTrimmed, filter) {
|
|
@@ -117,7 +117,15 @@ var AutocompleteSelect = function (_PureComponent) {
|
|
|
117
117
|
currentSelection = _this$state.selected;
|
|
118
118
|
var _this$props$labels = __props(_this).labels,
|
|
119
119
|
labels = _this$props$labels === void 0 ? {} : _this$props$labels;
|
|
120
|
-
if (selectedId == null && (!!filterValue || !required) && allowCustom && (!_this.input || !_this.input.check()))
|
|
120
|
+
if (selectedId == null && (!!filterValue || !required) && allowCustom && (!_this.input || !_this.input.check())) {
|
|
121
|
+
var trimmedValue = filterValue.trim();
|
|
122
|
+
if (isObject(labels)) {
|
|
123
|
+
var key = Object.keys(labels).find(function (key) {
|
|
124
|
+
return labels[key] === trimmedValue;
|
|
125
|
+
});
|
|
126
|
+
if (key) selectedId = key;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
121
129
|
var isMultiSelect = isMultipleSelect(mode);
|
|
122
130
|
if (!selectedId && isMultiSelect) {
|
|
123
131
|
selectedId = null;
|
|
@@ -134,12 +142,7 @@ var AutocompleteSelect = function (_PureComponent) {
|
|
|
134
142
|
}
|
|
135
143
|
var errored = required && Object.keys(selected) === 0;
|
|
136
144
|
var isActive = mode === MODE_MULTIPLE_MINI_INLINE || isMultiSelect && isSelected;
|
|
137
|
-
var customValue = '';
|
|
138
|
-
if (allowCustom && selectedId) {
|
|
139
|
-
var label;
|
|
140
|
-
if (isFunction(labels)) label = labels(selectedId);else label = labels[selectedId];
|
|
141
|
-
if (label && isString(label)) customValue = label;
|
|
142
|
-
}
|
|
145
|
+
var customValue = _this.getCustomValue(allowCustom, selectedId, labels) || '';
|
|
143
146
|
var filterValueWithCustom = isMultiSelect ? '' : customValue;
|
|
144
147
|
_this.setState({
|
|
145
148
|
isActive: isActive,
|
|
@@ -439,6 +442,17 @@ var AutocompleteSelect = function (_PureComponent) {
|
|
|
439
442
|
labels: labels
|
|
440
443
|
}));
|
|
441
444
|
}
|
|
445
|
+
}, {
|
|
446
|
+
key: "getCustomValue",
|
|
447
|
+
value: function getCustomValue(allowCustom, selectedId) {
|
|
448
|
+
var labels = __length(arguments) > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
449
|
+
if (allowCustom && selectedId) {
|
|
450
|
+
var label;
|
|
451
|
+
if (isFunction(labels)) label = labels(selectedId);else label = labels[selectedId];
|
|
452
|
+
if (label && isString(label)) return label;
|
|
453
|
+
}
|
|
454
|
+
return '';
|
|
455
|
+
}
|
|
442
456
|
}]);
|
|
443
457
|
return AutocompleteSelect;
|
|
444
458
|
}(PureComponent);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ClassType, CSSProperties, DOMElement, FunctionComponent, MouseEventHandler, ReactElement } from 'react';
|
|
2
|
+
import './FilteredList.css';
|
|
3
|
+
import { SCROLLBAR_MODE_AUTO, SCROLLBAR_MODE_HIDDEN, SCROLLBAR_MODE_VISIBLE } from "./Scrollable";
|
|
4
|
+
import { PureComponent } from "./ReactConstants";
|
|
5
|
+
export declare const getLabel: (labels: any, id: any) => any;
|
|
6
|
+
export interface FilteredListProps<T extends (number | string | boolean)> {
|
|
7
|
+
data: T[];
|
|
8
|
+
labels: ((id: T) => string | ReactElement) | {
|
|
9
|
+
[id: string]: string | ReactElement;
|
|
10
|
+
};
|
|
11
|
+
selected: T | {
|
|
12
|
+
[id: string]: T;
|
|
13
|
+
};
|
|
14
|
+
inline: boolean;
|
|
15
|
+
selectSingle?: boolean;
|
|
16
|
+
childComponent: FunctionComponent | ClassType<any, any, any>;
|
|
17
|
+
scroll?: typeof SCROLLBAR_MODE_AUTO | typeof SCROLLBAR_MODE_HIDDEN | typeof SCROLLBAR_MODE_VISIBLE;
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
childProps?: any;
|
|
20
|
+
className?: string;
|
|
21
|
+
filter: (id: T) => boolean;
|
|
22
|
+
onSelect: (id: T) => void;
|
|
23
|
+
nextProvider: (next: () => void) => void;
|
|
24
|
+
prevProvider: (prev: () => void) => void;
|
|
25
|
+
resetProvider: (reset: () => void) => void;
|
|
26
|
+
selectedProvider: (reset: () => T) => void;
|
|
27
|
+
}
|
|
28
|
+
interface FilteredListState {
|
|
29
|
+
selected: number | string | boolean;
|
|
30
|
+
}
|
|
31
|
+
declare class FilteredList<T extends (number | string | boolean)> extends PureComponent<FilteredListProps<T>, FilteredListState> {
|
|
32
|
+
hidden: {};
|
|
33
|
+
list: any[];
|
|
34
|
+
elements: {};
|
|
35
|
+
el: any;
|
|
36
|
+
constructor(props: any);
|
|
37
|
+
componentDidMount(): void;
|
|
38
|
+
componentDidUpdate(prevProps: any, prevState: any, snapshot: any): void;
|
|
39
|
+
updateList: (props: any) => void;
|
|
40
|
+
render(): JSX.Element;
|
|
41
|
+
onSelect: (id: T) => void;
|
|
42
|
+
selected: () => any;
|
|
43
|
+
next: () => void;
|
|
44
|
+
prev: () => void;
|
|
45
|
+
updateScroll: (id: any) => void;
|
|
46
|
+
reset: () => void;
|
|
47
|
+
scrollTo: (id: any) => any;
|
|
48
|
+
}
|
|
49
|
+
export default FilteredList;
|
|
50
|
+
export interface ItemWrapperProps<T> {
|
|
51
|
+
id: number | string | boolean;
|
|
52
|
+
label: string | ReactElement;
|
|
53
|
+
onClick: MouseEventHandler;
|
|
54
|
+
onMouseEnter: MouseEventHandler;
|
|
55
|
+
onMouseLeave: MouseEventHandler;
|
|
56
|
+
classProvider: (data: any) => string;
|
|
57
|
+
className?: string;
|
|
58
|
+
childComponent: FunctionComponent | ClassType<any, any, any>;
|
|
59
|
+
childProps?: any;
|
|
60
|
+
element?: (el: DOMElement<any, any>) => void;
|
|
61
|
+
}
|
package/FilteredList.js
CHANGED
|
@@ -1,251 +1,156 @@
|
|
|
1
1
|
import ReactConstants from "./ReactConstants";
|
|
2
2
|
import {clientHeight as __clientHeight, clientWidth as __clientWidth, createAccessor as __createAccessor, data as __data, height as __height, left as __left, length as __length, pageX as __pageX, pageY as __pageY, props as __props, scrollLeft as __scrollLeft, scrollTop as __scrollTop, state as __state, style as __style, target as __target, top as __top, value as __value, width as __width} from "./CommonFields";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { jsx as jsxRuntime_2 } from 'react/jsx-runtime';
|
|
4
5
|
import {toConsumableArray as __toConsumableArray} from "./_virtual/_rollupPluginBabelHelpers";
|
|
5
6
|
import {extends as __extends} from "./_virtual/_rollupPluginBabelHelpers";
|
|
6
7
|
import {inherits as __inherits} from "./_virtual/_rollupPluginBabelHelpers";
|
|
7
8
|
import './FilteredList.css';
|
|
8
9
|
import React from 'react';
|
|
9
|
-
import ReactCreateElement from './ReactCreateElement.js';
|
|
10
10
|
import Scrollable from './Scrollable.js';
|
|
11
|
-
import { orNoop, classNames, ref, isFunction, stopPropagation, isObject } from './Tools.js';
|
|
11
|
+
import { UNDEFINED, orNoop, classNames, ref, isFunction, stopPropagation, isObject } from './Tools.js';
|
|
12
12
|
import { PureComponent } from './ReactConstants.js';
|
|
13
13
|
|
|
14
|
-
var getLabel = function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
selected
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
_this.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
14
|
+
var getLabel = function (labels, id) { return isFunction(labels) ? labels(id) : (labels ? labels[id] : id); };
|
|
15
|
+
var FilteredList = /** @class */ (function (_super) {
|
|
16
|
+
__inherits(FilteredList, _super);
|
|
17
|
+
function FilteredList(props) {
|
|
18
|
+
var _this = _super.call(this, props) || this;
|
|
19
|
+
_this.hidden = {};
|
|
20
|
+
_this.list = [];
|
|
21
|
+
_this.elements = {};
|
|
22
|
+
_this.el = null;
|
|
23
|
+
_this.updateList = function (props) {
|
|
24
|
+
var data = __data(props);
|
|
25
|
+
var selected = __state(_this).selected;
|
|
26
|
+
_this.list = data || [];
|
|
27
|
+
if (!_this.list.includes(selected))
|
|
28
|
+
_this.setState({ selected: -1 });
|
|
29
|
+
};
|
|
30
|
+
_this.onSelect = function (id) {
|
|
31
|
+
_this.setState({ selected: id });
|
|
32
|
+
__props(_this).onSelect(id);
|
|
33
|
+
};
|
|
34
|
+
_this.selected = function () {
|
|
35
|
+
var value = __state(_this).selected;
|
|
36
|
+
var selectSingle = __props(_this).selectSingle;
|
|
37
|
+
if (value === -1 || _this.hidden[value + '']) {
|
|
38
|
+
var filtered = _this.list.filter(function (id) { return !_this.hidden[id]; });
|
|
39
|
+
if ((selectSingle === UNDEFINED || selectSingle) && __length(filtered) === 1)
|
|
40
|
+
return filtered[0];
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
_this.next = function () {
|
|
48
|
+
var list = _this.list;
|
|
49
|
+
var selected = __state(_this).selected;
|
|
50
|
+
var position = list.findIndex(function (id) { return selected === id; });
|
|
51
|
+
if (_this.hidden[list[position]])
|
|
52
|
+
position = -1;
|
|
53
|
+
while (++position < __length(list)) {
|
|
54
|
+
if (!_this.hidden[list[position]])
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
if (position < __length(list)) {
|
|
58
|
+
var id = list[position];
|
|
59
|
+
_this.setState({ selected: id });
|
|
60
|
+
_this.updateScroll(id);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
_this.prev = function () {
|
|
64
|
+
var list = _this.list;
|
|
65
|
+
var selected = __state(_this).selected;
|
|
66
|
+
var position = list.findIndex(function (id) { return selected === id; });
|
|
67
|
+
if (_this.hidden[list[position]])
|
|
68
|
+
position = __length(list);
|
|
69
|
+
while (--position >= 0) {
|
|
70
|
+
if (!_this.hidden[list[position]])
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (position >= 0) {
|
|
74
|
+
var id = list[position];
|
|
75
|
+
_this.setState({ selected: id });
|
|
76
|
+
_this.updateScroll(id);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
_this.updateScroll = function (id) {
|
|
80
|
+
var child = _this.elements[id];
|
|
81
|
+
var container = _this.el;
|
|
82
|
+
var scrollTop = container.getScroll();
|
|
83
|
+
var height = container.getHeight();
|
|
84
|
+
var isVisible = scrollTop <= child.offsetTop && scrollTop + height >= child.offsetTop + __clientHeight(child);
|
|
85
|
+
if (!isVisible) {
|
|
86
|
+
var scrollToBottom = child.offsetTop + __clientHeight(child) - height;
|
|
87
|
+
var scrollToTop = child.offsetTop;
|
|
88
|
+
if (Math.abs(scrollTop - scrollToTop) < Math.abs(scrollTop - scrollToBottom)) {
|
|
89
|
+
container.setScroll(scrollToTop);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
container.setScroll(scrollToBottom);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
_this.reset = function () {
|
|
97
|
+
_this.setState({ selected: -1 });
|
|
98
|
+
_this.el.scrollTop = 0;
|
|
99
|
+
};
|
|
100
|
+
_this.scrollTo = function (id) { return _this.el.setScroll(_this.elements[id] && _this.elements[id].offsetTop); };
|
|
101
|
+
_this.state = { selected: -1 };
|
|
102
|
+
return _this;
|
|
103
|
+
}
|
|
104
|
+
FilteredList.prototype[ReactConstants[0]] = function () {
|
|
105
|
+
orNoop(__props(this).nextProvider)(this.next);
|
|
106
|
+
orNoop(__props(this).prevProvider)(this.prev);
|
|
107
|
+
orNoop(__props(this).selectedProvider)(this.selected);
|
|
108
|
+
orNoop(__props(this).resetProvider)(this.reset);
|
|
109
|
+
this.updateList(__props(this));
|
|
86
110
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var height = container.getHeight();
|
|
92
|
-
var isVisible = scrollTop <= child.offsetTop && scrollTop + height >= child.offsetTop + __clientHeight(child);
|
|
93
|
-
if (!isVisible) {
|
|
94
|
-
var scrollToBottom = child.offsetTop + __clientHeight(child) - height;
|
|
95
|
-
var scrollToTop = child.offsetTop;
|
|
96
|
-
if (Math.abs(scrollTop - scrollToTop) < Math.abs(scrollTop - scrollToBottom)) {
|
|
97
|
-
container.setScroll(scrollToTop);
|
|
98
|
-
} else {
|
|
99
|
-
container.setScroll(scrollToBottom);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
111
|
+
FilteredList.prototype[ReactConstants[2]] = function (prevProps, prevState, snapshot) {
|
|
112
|
+
if (__props(this).data === __data(prevProps))
|
|
113
|
+
return;
|
|
114
|
+
this.updateList(__props(this));
|
|
102
115
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
selected
|
|
106
|
-
|
|
107
|
-
|
|
116
|
+
FilteredList.prototype[ReactConstants[3]] = function () {
|
|
117
|
+
var _this = this;
|
|
118
|
+
var _a = __props(this), data = __data(_a), labels = _a.labels, filter = _a.filter, className = _a[ReactConstants[5]], selected = _a.selected, inline = _a.inline, childComponent = _a.childComponent, childProps = _a.childProps, style = __style(_a), scroll = _a.scroll;
|
|
119
|
+
return (jsxRuntime_2(Scrollable, __extends({ [ReactConstants[5]]: classNames('FilteredList', className, inline ? 'inline' : 'popup'), ref: ref('el', this), style: style, scrollBarMode: scroll }, { [ReactConstants[4]]: (data || []).filter(function (id) { return id !== false && id != null; }).map(function (id) {
|
|
120
|
+
var key = '' + id;
|
|
121
|
+
return jsxRuntime_2(ItemWrapper, { id: id, label: getLabel(labels, id), childComponent: childComponent, childProps: childProps, element: function (el) { return _this.elements[key] = el; }, [ReactConstants[6]]: function (e) {
|
|
122
|
+
stopPropagation(e);
|
|
123
|
+
_this.onSelect(id);
|
|
124
|
+
}, onMouseEnter: function (e) { return _this.setState({ selected: id }); }, onMouseLeave: function (e) { return id === __state(_this).selected && _this.setState({ selected: -1 }); }, [ReactConstants[5]]: classNames('child', __state(_this).selected === id && 'active', selected === id || (selected && isObject(selected) && selected[key]) && 'selected'), classProvider: function (it) { return (_this.hidden[key] = !(!filter || filter(it))) && 'hidden'; } }, key);
|
|
125
|
+
}) })));
|
|
108
126
|
};
|
|
109
|
-
|
|
110
|
-
|
|
127
|
+
return FilteredList;
|
|
128
|
+
}(PureComponent));
|
|
129
|
+
var ItemWrapper = /** @class */ (function (_super) {
|
|
130
|
+
__inherits(ItemWrapper, _super);
|
|
131
|
+
function ItemWrapper() {
|
|
132
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
133
|
+
_this.el = null;
|
|
134
|
+
_this.data = null;
|
|
135
|
+
return _this;
|
|
136
|
+
}
|
|
137
|
+
ItemWrapper.prototype[ReactConstants[3]] = function () {
|
|
138
|
+
var _this = this;
|
|
139
|
+
var _a = __props(this), id = _a.id, label = _a.label, onClick = _a[ReactConstants[6]], onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, classProvider = _a.classProvider, className = _a[ReactConstants[5]], childComponent = _a.childComponent, childProps = _a.childProps;
|
|
140
|
+
var child = React.createElement(childComponent, __extends(__extends({}, childProps), { id: id, label: label, dataConsumer: function (data) {
|
|
141
|
+
_this.data = data;
|
|
142
|
+
} }));
|
|
143
|
+
var cssClass = orNoop(classProvider)(__data(this));
|
|
144
|
+
return (jsxRuntime_2("div", __extends({ [ReactConstants[5]]: classNames('ItemWrapper', cssClass, className), onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave,
|
|
145
|
+
// onMouseDown={onMouseDown}
|
|
146
|
+
[ReactConstants[6]]: onClick, ref: ref('el', this) }, { [ReactConstants[4]]: child })));
|
|
111
147
|
};
|
|
112
|
-
|
|
113
|
-
|
|
148
|
+
ItemWrapper.prototype[ReactConstants[0]] = function () {
|
|
149
|
+
orNoop(__props(this).element)(this.el);
|
|
150
|
+
this.forceUpdate();
|
|
114
151
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return _this;
|
|
118
|
-
}
|
|
119
|
-
_createClass(FilteredList, [{
|
|
120
|
-
key: [ReactConstants[0]],
|
|
121
|
-
value: function componentDidMount() {
|
|
122
|
-
orNoop(__props(this).nextProvider)(this.next);
|
|
123
|
-
orNoop(__props(this).prevProvider)(this.prev);
|
|
124
|
-
orNoop(__props(this).selectedProvider)(this.selected);
|
|
125
|
-
orNoop(__props(this).resetProvider)(this.reset);
|
|
126
|
-
this.updateList(__props(this));
|
|
127
|
-
}
|
|
128
|
-
}, {
|
|
129
|
-
key: [ReactConstants[2]],
|
|
130
|
-
value: function componentDidUpdate(prevProps, prevState, snapshot) {
|
|
131
|
-
if (__props(this).data === __data(prevProps)) return;
|
|
132
|
-
this.updateList(__props(this));
|
|
133
|
-
}
|
|
134
|
-
}, {
|
|
135
|
-
key: [ReactConstants[3]],
|
|
136
|
-
value: function render() {
|
|
137
|
-
var _this2 = this;
|
|
138
|
-
var _this$props = __props(this),
|
|
139
|
-
data = __data(_this$props),
|
|
140
|
-
labels = _this$props.labels,
|
|
141
|
-
filter = _this$props.filter,
|
|
142
|
-
className = _this$props[ReactConstants[5]],
|
|
143
|
-
selected = _this$props.selected,
|
|
144
|
-
inline = _this$props.inline,
|
|
145
|
-
childComponent = _this$props.childComponent,
|
|
146
|
-
childProps = _this$props.childProps,
|
|
147
|
-
style = __style(_this$props),
|
|
148
|
-
scroll = _this$props.scroll;
|
|
149
|
-
return ReactCreateElement(Scrollable, {
|
|
150
|
-
[ReactConstants[5]]: classNames('FilteredList', className, inline ? 'inline' : 'popup'),
|
|
151
|
-
ref: ref('el', this),
|
|
152
|
-
style: style,
|
|
153
|
-
scrollBarMode: scroll
|
|
154
|
-
}, (data || []).filter(function (id) {
|
|
155
|
-
return id !== false && id != null;
|
|
156
|
-
}).map(function (id) {
|
|
157
|
-
return ReactCreateElement(ItemWrapper, {
|
|
158
|
-
id: id,
|
|
159
|
-
key: id,
|
|
160
|
-
label: getLabel(labels, id),
|
|
161
|
-
childComponent: childComponent,
|
|
162
|
-
childProps: childProps,
|
|
163
|
-
element: function element(el) {
|
|
164
|
-
return _this2.elements[id] = el;
|
|
165
|
-
},
|
|
166
|
-
[ReactConstants[6]]: function onClick(e) {
|
|
167
|
-
stopPropagation(e);
|
|
168
|
-
_this2.onSelect(id);
|
|
169
|
-
},
|
|
170
|
-
onMouseEnter: function onMouseEnter(e) {
|
|
171
|
-
return _this2.setState({
|
|
172
|
-
selected: id
|
|
173
|
-
});
|
|
174
|
-
},
|
|
175
|
-
onMouseLeave: function onMouseLeave(e) {
|
|
176
|
-
return id === __state(_this2).selected && _this2.setState({
|
|
177
|
-
selected: -1
|
|
178
|
-
});
|
|
179
|
-
},
|
|
180
|
-
[ReactConstants[5]]: classNames('child', __state(_this2).selected === id && 'active', selected === id || isObject(selected) && selected[id] && 'selected'),
|
|
181
|
-
classProvider: function classProvider(it) {
|
|
182
|
-
return (_this2.hidden[id] = !filter(it)) && 'hidden';
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
}));
|
|
186
|
-
}
|
|
187
|
-
}]);
|
|
188
|
-
return FilteredList;
|
|
189
|
-
}(PureComponent);
|
|
190
|
-
FilteredList.defaultProps = {
|
|
191
|
-
data: [],
|
|
192
|
-
labels: {},
|
|
193
|
-
selected: {},
|
|
194
|
-
inline: false,
|
|
195
|
-
selectSingle: true,
|
|
196
|
-
filter: function filter() {
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
var FilteredList$1 = FilteredList;
|
|
201
|
-
var ItemWrapper = function (_React$Component) {
|
|
202
|
-
_inherits(ItemWrapper, _React$Component);
|
|
203
|
-
var _super2 = _createSuper(ItemWrapper);
|
|
204
|
-
function ItemWrapper() {
|
|
205
|
-
_classCallCheck(this, ItemWrapper);
|
|
206
|
-
return _super2.apply(this, arguments);
|
|
207
|
-
}
|
|
208
|
-
_createClass(ItemWrapper, [{
|
|
209
|
-
key: [ReactConstants[3]],
|
|
210
|
-
value: function render() {
|
|
211
|
-
var _this3 = this;
|
|
212
|
-
var _this$props2 = __props(this),
|
|
213
|
-
id = _this$props2.id,
|
|
214
|
-
label = _this$props2.label,
|
|
215
|
-
onClick = _this$props2[ReactConstants[6]],
|
|
216
|
-
onMouseDown = _this$props2.onMouseDown,
|
|
217
|
-
onMouseEnter = _this$props2.onMouseEnter,
|
|
218
|
-
onMouseLeave = _this$props2.onMouseLeave,
|
|
219
|
-
classProvider = _this$props2.classProvider,
|
|
220
|
-
className = _this$props2[ReactConstants[5]],
|
|
221
|
-
childComponent = _this$props2.childComponent,
|
|
222
|
-
childProps = _this$props2.childProps;
|
|
223
|
-
var child = React.createElement(childComponent, _objectSpread2(_objectSpread2({}, childProps), {}, {
|
|
224
|
-
id: id,
|
|
225
|
-
label: label,
|
|
226
|
-
dataConsumer: function dataConsumer(data) {
|
|
227
|
-
return _this3.data = data;
|
|
228
|
-
}
|
|
229
|
-
}));
|
|
230
|
-
var cssClass = orNoop(classProvider)(__data(this));
|
|
231
|
-
return ReactCreateElement("div", {
|
|
232
|
-
[ReactConstants[5]]: classNames('ItemWrapper', cssClass, className),
|
|
233
|
-
onMouseEnter: onMouseEnter,
|
|
234
|
-
onMouseLeave: onMouseLeave,
|
|
235
|
-
onMouseDown: onMouseDown,
|
|
236
|
-
[ReactConstants[6]]: onClick,
|
|
237
|
-
ref: ref('el', this)
|
|
238
|
-
}, child);
|
|
239
|
-
}
|
|
240
|
-
}, {
|
|
241
|
-
key: [ReactConstants[0]],
|
|
242
|
-
value: function componentDidMount() {
|
|
243
|
-
orNoop(__props(this).element)(this.el);
|
|
244
|
-
this.forceUpdate();
|
|
245
|
-
}
|
|
246
|
-
}]);
|
|
247
|
-
return ItemWrapper;
|
|
248
|
-
}(React.Component);
|
|
152
|
+
return ItemWrapper;
|
|
153
|
+
}(React.Component));
|
|
249
154
|
|
|
250
|
-
export { FilteredList
|
|
155
|
+
export { FilteredList as default, getLabel };
|
|
251
156
|
//# sourceMappingURL=FilteredList.js.map
|
package/Table.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ declare type Comparator = <T>(a: T, b: T) => number;
|
|
|
7
7
|
declare const editorSelect = "Select";
|
|
8
8
|
declare const editorSwitch = "Switch";
|
|
9
9
|
export interface RowProps<T> {
|
|
10
|
+
i: number;
|
|
10
11
|
item: T;
|
|
11
12
|
disabled?: (t: T) => boolean;
|
|
12
13
|
editing: any;
|
|
@@ -17,12 +18,19 @@ export interface RowProps<T> {
|
|
|
17
18
|
onFinishEditing: () => void;
|
|
18
19
|
handleInputChange: (e: ChangeEvent) => void;
|
|
19
20
|
setValue: (v: any) => void;
|
|
20
|
-
setEditing: (t: T, i: number,
|
|
21
|
+
setEditing: (t: T, i: number, value?: any) => void;
|
|
22
|
+
onMouseDown?: (e: SyntheticEvent, row: number, column: number) => void;
|
|
23
|
+
onMouseUp?: (e: SyntheticEvent, row: number, column: number) => void;
|
|
24
|
+
onMouseEnter?: (e: SyntheticEvent, row: number, column: number) => void;
|
|
25
|
+
onMouseLeave?: (e: SyntheticEvent, row: number, column: number) => void;
|
|
21
26
|
}
|
|
22
27
|
export declare type Formatter<T, V> = ((value?: V, item?: T, format?: string) => ReactElement | string) | ((value: V, item: T) => ReactElement | string) | ((value: V) => ReactElement | string);
|
|
28
|
+
export declare type CellClassName<T> = (item: T, field: string, row: number, column: number) => string;
|
|
29
|
+
export declare type ColumnClassName<T> = string | CellClassName<T>;
|
|
23
30
|
export interface TableColumn<T> {
|
|
24
31
|
field?: string;
|
|
25
|
-
className?:
|
|
32
|
+
className?: ColumnClassName<T>;
|
|
33
|
+
onClick?: (e: SyntheticEvent, startEditing: () => void, item: T, field: string, row: number, column: number) => void;
|
|
26
34
|
comparator?: Comparator;
|
|
27
35
|
header?: string | ReactElement;
|
|
28
36
|
sortable?: boolean;
|
|
@@ -45,6 +53,10 @@ export interface TableProps<T> {
|
|
|
45
53
|
toKey?: (t: T) => number | string;
|
|
46
54
|
onChange?: (t: T, cancel: () => void) => void;
|
|
47
55
|
rowClassName?: string | ((t: T) => string);
|
|
56
|
+
onMouseDown?: (e: SyntheticEvent, row: number, column: number) => void;
|
|
57
|
+
onMouseUp?: (e: SyntheticEvent, row: number, column: number) => void;
|
|
58
|
+
onMouseEnter?: (e: SyntheticEvent, row: number, column: number) => void;
|
|
59
|
+
onMouseLeave?: (e: SyntheticEvent, row: number, column: number) => void;
|
|
48
60
|
}
|
|
49
61
|
export interface TableState<T> {
|
|
50
62
|
sortOrder?: SortOrder;
|
|
@@ -53,6 +65,9 @@ export interface TableState<T> {
|
|
|
53
65
|
data?: T[];
|
|
54
66
|
}
|
|
55
67
|
declare class Table<T> extends Component<TableProps<T>, TableState<T>> {
|
|
68
|
+
startEditing: (item: any, columnIndex: any, value?: any) => void;
|
|
69
|
+
finishEditing: () => void;
|
|
70
|
+
isEditing: () => boolean;
|
|
56
71
|
constructor(properties: any);
|
|
57
72
|
}
|
|
58
73
|
export interface TableColumnSelect extends TableColumn<any> {
|