react-ui-basics 0.0.148 → 0.0.151

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.
Files changed (87) hide show
  1. package/Animated.js +3 -0
  2. package/Animated.js.map +1 -1
  3. package/AutocompleteSelect.js +17 -14
  4. package/AutocompleteSelect.js.map +1 -1
  5. package/Button.js +6 -3
  6. package/Button.js.map +1 -1
  7. package/Checkbox.js +5 -2
  8. package/Checkbox.js.map +1 -1
  9. package/CircleProgress.js +5 -2
  10. package/CircleProgress.js.map +1 -1
  11. package/DNDContainer.js +5 -2
  12. package/DNDContainer.js.map +1 -1
  13. package/DNDDraggable.js +4 -1
  14. package/DNDDraggable.js.map +1 -1
  15. package/DNDDroppable.js +4 -1
  16. package/DNDDroppable.js.map +1 -1
  17. package/Dialog.js +9 -6
  18. package/Dialog.js.map +1 -1
  19. package/DropFileInput.js +5 -2
  20. package/DropFileInput.js.map +1 -1
  21. package/DroppableHorizontalList.js +4 -1
  22. package/DroppableHorizontalList.js.map +1 -1
  23. package/DroppableList.js +4 -1
  24. package/DroppableList.js.map +1 -1
  25. package/Dropzone.js +8 -5
  26. package/Dropzone.js.map +1 -1
  27. package/FilteredList.js +6 -3
  28. package/FilteredList.js.map +1 -1
  29. package/FloatingActionButton.js +4 -1
  30. package/FloatingActionButton.js.map +1 -1
  31. package/FormUploadProgress.js +8 -5
  32. package/FormUploadProgress.js.map +1 -1
  33. package/ImageGallery.js +15 -12
  34. package/ImageGallery.js.map +1 -1
  35. package/MaterialIcon.js +5 -2
  36. package/MaterialIcon.js.map +1 -1
  37. package/Modal.js +8 -5
  38. package/Modal.js.map +1 -1
  39. package/ModalMenu.js +6 -3
  40. package/ModalMenu.js.map +1 -1
  41. package/ReactConstants.js +1 -1
  42. package/ReactConstants.js.map +1 -1
  43. package/ReactCreateElement.js.map +1 -1
  44. package/ReadyListener.js +3 -0
  45. package/ReadyListener.js.map +1 -1
  46. package/Scrollable.js +10 -7
  47. package/Scrollable.js.map +1 -1
  48. package/ScrollableTable.js +4 -1
  49. package/ScrollableTable.js.map +1 -1
  50. package/Size.js +4 -1
  51. package/Size.js.map +1 -1
  52. package/Snackbar.js +6 -3
  53. package/Snackbar.js.map +1 -1
  54. package/SpinningProgress.js +6 -3
  55. package/SpinningProgress.js.map +1 -1
  56. package/Switch.js +10 -7
  57. package/Switch.js.map +1 -1
  58. package/Table.d.ts +76 -0
  59. package/Table.js +138 -321
  60. package/Table.js.map +1 -1
  61. package/TextField.js +9 -6
  62. package/TextField.js.map +1 -1
  63. package/Tools.d.ts +2 -2
  64. package/Tools.js +4 -4
  65. package/Tools.js.map +1 -1
  66. package/_virtual/_commonjsHelpers.js +6 -0
  67. package/_virtual/_commonjsHelpers.js.map +1 -0
  68. package/_virtual/_react.js +3 -0
  69. package/_virtual/_react.js.map +1 -0
  70. package/_virtual/react-jsx-runtime.development.js +3 -0
  71. package/_virtual/react-jsx-runtime.development.js.map +1 -0
  72. package/bundle.css +508 -508
  73. package/index.js +3 -0
  74. package/package.json +3 -2
  75. package/router/HistoryTools.js.map +1 -1
  76. package/router/Link.js +4 -1
  77. package/router/Link.js.map +1 -1
  78. package/router/NavLink.js +4 -1
  79. package/router/NavLink.js.map +1 -1
  80. package/router/Route.js +6 -3
  81. package/router/Route.js.map +1 -1
  82. package/router/index.js +3 -0
  83. package/router/index.js.map +1 -1
  84. package/store/ProxyTools.js +3 -0
  85. package/store/ProxyTools.js.map +1 -1
  86. package/store/Store.js +3 -0
  87. package/store/Store.js.map +1 -1
package/Table.d.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { Component, ReactElement } from 'react';
2
+ import './Table.css';
3
+ export declare const SORT_ASC: string;
4
+ export declare const SORT_DESC: string;
5
+ declare type SortOrder = typeof SORT_ASC | typeof SORT_DESC;
6
+ declare type Comparator = <T>(a: T, b: T) => number;
7
+ declare const editorSelect = "Select";
8
+ declare const editorSwitch = "Switch";
9
+ export interface RowProps {
10
+ item: any;
11
+ disabled?: <T>(e: T) => boolean;
12
+ editing: any;
13
+ onClick?: (e: MouseEvent) => void;
14
+ className?: string | (<T>(e: T) => string);
15
+ columns: TableColumn[];
16
+ editingContext: any;
17
+ }
18
+ export declare type Formatter<T, V> = ((value?: V, item?: T, format?: string) => ReactElement) | ((value: V, item: T) => ReactElement) | ((value: V) => ReactElement);
19
+ export interface TableColumn {
20
+ field?: string;
21
+ className?: string;
22
+ comparator?: Comparator;
23
+ header?: string | ReactElement;
24
+ sortable?: boolean;
25
+ displayEditor?: boolean;
26
+ formatter?: Formatter<any, any>;
27
+ editable?: boolean | any;
28
+ editor?: typeof editorSelect | typeof editorSwitch | any;
29
+ preEditor?: any;
30
+ }
31
+ export interface TableProps {
32
+ columns: TableColumn[];
33
+ data: any[];
34
+ className?: string;
35
+ sortOrder?: SortOrder;
36
+ sortBy?: string;
37
+ onSortChange?: (sortBy: string, sortOrder: SortOrder) => void;
38
+ onRowClick?: (e: MouseEvent) => void;
39
+ disabled?: <T>(e: T) => boolean;
40
+ toKey?: <T>(e: T) => number | string;
41
+ onChange?: <T>(e: T, cancel: () => void) => void;
42
+ rowClassName?: string | (<T>(e: T) => string);
43
+ }
44
+ export interface TableState {
45
+ sortOrder?: SortOrder;
46
+ sortBy?: string;
47
+ comparator?: Comparator;
48
+ data?: any[];
49
+ editing?: any;
50
+ }
51
+ declare class Table extends Component<TableProps, TableState> {
52
+ headers: () => any;
53
+ updateHeadersInterval: number;
54
+ constructor(props: any);
55
+ componentDidMount(): void;
56
+ setData: (data: any) => void;
57
+ componentDidUpdate(prevProps: any, prevState: any, snapshot: any): void;
58
+ render(): JSX.Element;
59
+ componentWillUnmount(): void;
60
+ updateHeaders: () => void;
61
+ cancelEditing: () => void;
62
+ setEditing: (item: any, columnIndex: any, field: any) => void;
63
+ prepareEditing: (item: any, field: any, columnIndex: any) => {
64
+ id: any;
65
+ value: any;
66
+ columnIndex: any;
67
+ item: any;
68
+ field: any;
69
+ };
70
+ handleInputChange: (event: any) => void;
71
+ extractValue: (event: any) => any;
72
+ selectNewValue: (value: any) => void;
73
+ onFinishEditing: () => void;
74
+ sort: (e: any, sortBy: any, comparator: any) => void;
75
+ }
76
+ export default Table;
package/Table.js CHANGED
@@ -1,337 +1,154 @@
1
- import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, toConsumableArray as _toConsumableArray, objectSpread2 as _objectSpread2, defineProperty as _defineProperty, createClass as _createClass } from './_virtual/_rollupPluginBabelHelpers.js';
1
+ import { jsx as jsxRuntime_2, jsxs as jsxRuntime_1 } from 'react/jsx-runtime';
2
+ import {extends as __extends} from "./_virtual/_rollupPluginBabelHelpers";
3
+ import {className as __className} from "./ReactConstants";
4
+ import {children as __children} from "./ReactConstants";
2
5
  import React, { Component } from 'react';
3
- import ReactCreateElement from './ReactCreateElement.js';
4
- import PropTypes from 'prop-types';
5
6
  import TextField from './TextField.js';
6
7
  import AutocompleteSelect, { MODE_MULTIPLE_MINI, MODE_DEFAULT } from './AutocompleteSelect.js';
7
8
  import Switch from './Switch.js';
8
- import { Comparators, orNoop, isString, preventDefault, classNames, isFunction, NOOP, stopPropagation } from './Tools.js';
9
+ import { classNames, isFunction, NOOP, preventDefault, stopPropagation, createRef, Comparators, orNoop, isString, setInterval } from './Tools.js';
9
10
  import MaterialIcon from './MaterialIcon.js';
10
11
 
11
- var SORT_ASC = Comparators.SORT_ASC;
12
- var SORT_DESC = Comparators.SORT_DESC;
13
- var getId = function getId(item) {
14
- return item.id;
15
- };
16
- var Table = function (_Component) {
17
- _inherits(Table, _Component);
18
- var _super = _createSuper(Table);
19
- function Table(props) {
20
- var _this;
21
- _classCallCheck(this, Table);
22
- _this = _super.call(this, props);
23
- _this.setData = function (data) {
24
- var _this$state = _this.state,
25
- sortBy = _this$state.sortBy,
26
- sortOrder = _this$state.sortOrder,
27
- comparator = _this$state.comparator;
28
- data = _toConsumableArray(data);
29
- if (sortBy) {
30
- var c = comparator;
31
- if (c && sortOrder === SORT_DESC) c = Comparators.inverse(c);
32
- data.sort(c || Comparators.of(sortBy, sortOrder, data));
33
- }
34
- _this.setState({
35
- data: data
36
- }, function () {
37
- orNoop(_this.props.onSortChange)(sortBy, sortOrder);
38
- });
39
- };
40
- _this.updateHeaders = function () {
41
- var headers = _this.headers;
42
- var hidden = headers.querySelectorAll('.hidden');
43
- var fixed = headers.querySelectorAll('.fixed');
44
- for (var i = 0; i < hidden.length; i++) {
45
- fixed[i].style.width = hidden[i].offsetWidth + 'px';
46
- }
47
- };
48
- _this.cancelEditing = function () {
49
- return _this.setState({
50
- editing: false
51
- });
52
- };
53
- _this.setEditing = function (item, columnIndex, field) {
54
- return _this.setState({
55
- editing: _this.prepareEditing(item, field, columnIndex)
56
- });
57
- };
58
- _this.prepareEditing = function (item, field, columnIndex) {
59
- return {
60
- id: item.id,
61
- value: item[field],
62
- columnIndex: columnIndex,
63
- item: item,
64
- field: field
65
- };
66
- };
67
- _this.handleInputChange = function (event) {
68
- var value = _this.extractValue(event);
69
- _this.setState({
70
- editing: _objectSpread2(_objectSpread2({}, _this.state.editing), {}, {
71
- value: value
72
- })
73
- });
74
- };
75
- _this.extractValue = function (event) {
76
- var target = event.target;
77
- return target.type === 'checkbox' ? target.checked : target.value;
78
- };
79
- _this.selectNewValue = function (value) {
80
- _this.setState({
81
- editing: _objectSpread2(_objectSpread2({}, _this.state.editing), {}, {
82
- value: value
83
- })
84
- }, _this.onFinishEditing);
85
- };
86
- _this.onFinishEditing = function (e) {
87
- var editing = _this.state.editing;
88
- if (editing.value === null) return;
89
- var value = editing.value;
90
- if (isString(value)) value = value.trim();
91
- if (value === editing.item[editing.field]) return _this.cancelEditing();
92
- var updated = _objectSpread2(_objectSpread2({}, editing.item), {}, _defineProperty({}, editing.field, value));
93
- _this.props.onChange(updated, _this.cancelEditing);
94
- };
95
- _this.sort = function (e, sortBy, comparator) {
96
- preventDefault(e);
97
- _this.setState({
98
- sortOrder: _this.state.sortBy === sortBy && _this.state.sortOrder === SORT_ASC ? SORT_DESC : SORT_ASC,
99
- comparator: comparator,
100
- sortBy: sortBy
101
- }, function () {
102
- return _this.setData(_this.state.data);
103
- });
104
- };
105
- _this.state = {};
106
- return _this;
107
- }
108
- _createClass(Table, [{
109
- key: "componentDidMount",
110
- value: function componentDidMount() {
111
- var _columns$find,
112
- _this2 = this;
113
- var _this$props = this.props,
114
- sortBy = _this$props.sortBy,
115
- _this$props$sortOrder = _this$props.sortOrder,
116
- sortOrder = _this$props$sortOrder === void 0 ? SORT_ASC : _this$props$sortOrder,
117
- columns = _this$props.columns;
118
- this.setState({
119
- sortBy: sortBy,
120
- sortOrder: sortOrder,
121
- comparator: (_columns$find = columns.find(function (it) {
122
- return it.field === sortBy;
123
- })) == null ? void 0 : _columns$find.comparator
124
- }, function () {
125
- return _this2.setData(_this2.props.data);
126
- });
127
- this.updateHeaders();
128
- this.updateHeadersInterval = setInterval(this.updateHeaders, 1000);
12
+ const SORT_ASC = Comparators.SORT_ASC;
13
+ const SORT_DESC = Comparators.SORT_DESC;
14
+ const getId = item => item.id;
15
+ const editorSelect = 'Select';
16
+ const editorSwitch = 'Switch';
17
+ class Table extends Component {
18
+ constructor(props) {
19
+ super(props);
20
+ this.headers = createRef();
21
+ this.updateHeadersInterval = 0;
22
+ this.setData = (data) => {
23
+ const { sortBy, sortOrder, comparator } = this.state;
24
+ data = [...data];
25
+ if (sortBy) {
26
+ let c = comparator;
27
+ if (c && sortOrder === SORT_DESC)
28
+ c = Comparators.inverse(c);
29
+ data.sort(c || Comparators.of(sortBy, sortOrder, data));
30
+ }
31
+ this.setState({ data }, () => {
32
+ orNoop(this.props.onSortChange)(sortBy, sortOrder);
33
+ });
34
+ };
35
+ this.updateHeaders = () => {
36
+ const headers = this.headers();
37
+ const hidden = headers.querySelectorAll('.hidden');
38
+ const fixed = headers.querySelectorAll('.fixed');
39
+ for (let i = 0; i < hidden.length; i++) {
40
+ fixed[i].style.width = hidden[i].offsetWidth + 'px';
41
+ }
42
+ };
43
+ this.cancelEditing = () => this.setState({ editing: false });
44
+ this.setEditing = (item, columnIndex, field) => this.setState({ editing: this.prepareEditing(item, field, columnIndex) });
45
+ this.prepareEditing = (item, field, columnIndex) => ({ id: item.id, value: item[field], columnIndex, item, field });
46
+ this.handleInputChange = (event) => {
47
+ const value = this.extractValue(event);
48
+ this.setState({ editing: __extends(__extends({}, this.state.editing), { value }) });
49
+ };
50
+ this.extractValue = (event) => {
51
+ const target = event.target;
52
+ return target.type === 'checkbox' ? target.checked : target.value;
53
+ };
54
+ this.selectNewValue = (value) => {
55
+ this.setState({ editing: __extends(__extends({}, this.state.editing), { value }) }, this.onFinishEditing);
56
+ };
57
+ this.onFinishEditing = () => {
58
+ const editing = this.state.editing;
59
+ if (editing.value === null)
60
+ return;
61
+ let value = editing.value;
62
+ if (isString(value))
63
+ value = value.trim();
64
+ if (value === editing.item[editing.field])
65
+ return this.cancelEditing();
66
+ let updated = __extends(__extends({}, editing.item), { [editing.field]: value });
67
+ this.props.onChange(updated, this.cancelEditing);
68
+ };
69
+ this.sort = (e, sortBy, comparator) => {
70
+ preventDefault(e);
71
+ this.setState({
72
+ sortOrder: this.state.sortBy === sortBy && this.state.sortOrder === SORT_ASC ? SORT_DESC : SORT_ASC,
73
+ comparator,
74
+ sortBy
75
+ }, () => this.setData(this.state.data));
76
+ };
77
+ this.state = {};
129
78
  }
130
- }, {
131
- key: "componentDidUpdate",
132
- value: function componentDidUpdate(prevProps, prevState, snapshot) {
133
- var _this3 = this;
134
- var _this$props2 = this.props,
135
- sortBy = _this$props2.sortBy,
136
- sortOrder = _this$props2.sortOrder,
137
- columns = _this$props2.columns,
138
- data = _this$props2.data;
139
- if (sortBy !== prevProps.sortBy || sortOrder !== prevProps.sortOrder) {
140
- var _columns$find2;
79
+ componentDidMount() {
80
+ var _a;
81
+ const { sortBy, sortOrder = SORT_ASC, columns } = this.props;
141
82
  this.setState({
142
- sortBy: sortBy,
143
- sortOrder: sortOrder || SORT_ASC,
144
- comparator: (_columns$find2 = columns.find(function (it) {
145
- return it.field === sortBy;
146
- })) == null ? void 0 : _columns$find2.comparator
147
- }, function () {
148
- return _this3.setData(data);
149
- });
150
- } else if (data !== prevProps.data) {
151
- this.setData(data);
152
- }
153
- this.updateHeaders();
83
+ sortBy,
84
+ sortOrder,
85
+ comparator: (_a = columns.find(it => it.field === sortBy)) === null || _a === void 0 ? void 0 : _a.comparator
86
+ }, () => this.setData(this.props.data));
87
+ this.updateHeaders();
88
+ this.updateHeadersInterval = setInterval(this.updateHeaders, 1000);
154
89
  }
155
- }, {
156
- key: "render",
157
- value: function render() {
158
- var _this4 = this;
159
- var _this$props3 = this.props,
160
- _this$props3$columns = _this$props3.columns,
161
- columns = _this$props3$columns === void 0 ? [] : _this$props3$columns,
162
- _this$props3$onRowCli = _this$props3.onRowClick,
163
- onRowClick = _this$props3$onRowCli === void 0 ? NOOP : _this$props3$onRowCli,
164
- disabled = _this$props3.disabled,
165
- className = _this$props3.className,
166
- rowClassName = _this$props3.rowClassName,
167
- _this$props3$toKey = _this$props3.toKey,
168
- toKey = _this$props3$toKey === void 0 ? getId : _this$props3$toKey;
169
- var _this$state2 = this.state,
170
- sortBy = _this$state2.sortBy,
171
- sortOrder = _this$state2.sortOrder,
172
- _this$state2$data = _this$state2.data,
173
- data = _this$state2$data === void 0 ? [] : _this$state2$data,
174
- editing = _this$state2.editing;
175
- return ReactCreateElement("table", {
176
- className: classNames("Table", className)
177
- }, ReactCreateElement("thead", null, ReactCreateElement("tr", {
178
- ref: function ref(headers) {
179
- return _this4.headers = headers;
90
+ ;
91
+ componentDidUpdate(prevProps, prevState, snapshot) {
92
+ var _a;
93
+ const { sortBy, sortOrder, columns, data } = this.props;
94
+ if (sortBy !== prevProps.sortBy || sortOrder !== prevProps.sortOrder) {
95
+ this.setState({
96
+ sortBy,
97
+ sortOrder: sortOrder || SORT_ASC,
98
+ comparator: (_a = columns.find(it => it.field === sortBy)) === null || _a === void 0 ? void 0 : _a.comparator
99
+ }, () => this.setData(data));
100
+ }
101
+ else if (data !== prevProps.data) {
102
+ this.setData(data);
180
103
  }
181
- }, columns.filter(function (it) {
182
- return !!it;
183
- }).map(function (column, i) {
184
- var sortable = column.sortable || column.sortable == null;
185
- return ReactCreateElement("th", {
186
- key: i,
187
- onClick: function onClick(e) {
188
- return sortable && _this4.sort(e, column.field, column.comparator);
189
- }
190
- }, ReactCreateElement("div", {
191
- className: classNames('hidden', sortable && 'sortable', sortBy === column.field && 'active')
192
- }, column.header, column.header && sortBy === column.field && sortOrder === SORT_ASC && ReactCreateElement(MaterialIcon, {
193
- icon: 'keyboard_arrow_up'
194
- }), column.header && sortBy === column.field && sortOrder === SORT_DESC && ReactCreateElement(MaterialIcon, {
195
- icon: 'keyboard_arrow_down'
196
- })), ReactCreateElement("div", {
197
- className: classNames('fixed', sortable && 'sortable', sortBy === column.field && 'active')
198
- }, column.header, column.header && sortBy === column.field && sortOrder === SORT_ASC && ReactCreateElement(MaterialIcon, {
199
- icon: 'keyboard_arrow_up'
200
- }), column.header && sortBy === column.field && sortOrder === SORT_DESC && ReactCreateElement(MaterialIcon, {
201
- icon: 'keyboard_arrow_down'
202
- })));
203
- }))), ReactCreateElement("tbody", null, data.map(function (item) {
204
- return ReactCreateElement(Row, {
205
- key: toKey(item),
206
- item: item,
207
- disabled: disabled,
208
- editing: editing && editing.id === item.id ? editing : null,
209
- onClick: onRowClick,
210
- className: rowClassName,
211
- columns: columns,
212
- editingContext: _this4
213
- });
214
- })));
104
+ this.updateHeaders();
105
+ }
106
+ ;
107
+ render() {
108
+ const { columns = [], onRowClick = NOOP, disabled, className, rowClassName, toKey = getId } = this.props;
109
+ const { sortBy, sortOrder, data = [], editing } = this.state;
110
+ return (jsxRuntime_1("table", __extends({ [__className]: classNames(`Table`, className) }, { [__children]: [jsxRuntime_2("thead", { [__children]: jsxRuntime_2("tr", __extends({ ref: this.headers }, { [__children]: columns.filter(it => !!it).map((column, i) => {
111
+ const sortable = column.sortable || column.sortable == null;
112
+ return (jsxRuntime_1("th", __extends({ onClick: e => sortable && this.sort(e, column.field, column.comparator) }, { [__children]: [jsxRuntime_1("div", __extends({ [__className]: classNames('hidden', sortable && 'sortable', sortBy === column.field && 'active') }, { [__children]: [column.header, column.header && sortBy === column.field && sortOrder === SORT_ASC && (jsxRuntime_2(MaterialIcon, { icon: 'keyboard_arrow_up' })), column.header && sortBy === column.field && sortOrder === SORT_DESC && (jsxRuntime_2(MaterialIcon, { icon: 'keyboard_arrow_down' }))] })), jsxRuntime_1("div", __extends({ [__className]: classNames('fixed', sortable && 'sortable', sortBy === column.field && 'active') }, { [__children]: [column.header, column.header && sortBy === column.field && sortOrder === SORT_ASC && (jsxRuntime_2(MaterialIcon, { icon: 'keyboard_arrow_up' })), column.header && sortBy === column.field && sortOrder === SORT_DESC && (jsxRuntime_2(MaterialIcon, { icon: 'keyboard_arrow_down' }))] }))] }), i));
113
+ }) })) }), jsxRuntime_2("tbody", { [__children]: data.map(item => (jsxRuntime_2(Row, { item: item, disabled: disabled, editing: editing && editing.id === item.id ? editing : null, onClick: onRowClick, [__className]: rowClassName, columns: columns, editingContext: this }, toKey(item)))) })] })));
114
+ }
115
+ ;
116
+ componentWillUnmount() {
117
+ clearInterval(this.updateHeadersInterval);
118
+ }
119
+ ;
120
+ }
121
+ const formatValue = (item, column) => {
122
+ const value = (column.value !== undefined) ? column.value : item[column.field];
123
+ if (column.formatter) {
124
+ return column.formatter(value, item, column.format);
215
125
  }
216
- }, {
217
- key: "componentWillUnmount",
218
- value: function componentWillUnmount() {
219
- clearInterval(this.updateHeadersInterval);
126
+ else {
127
+ return '' + value;
220
128
  }
221
- }]);
222
- return Table;
223
- }(Component);
224
- var formatValue = function formatValue(item, column) {
225
- var value = column.value !== undefined ? column.value : item[column.field];
226
- if (column.formatter) {
227
- return column.formatter(value, item, column.format);
228
- } else {
229
- return '' + value;
230
- }
231
129
  };
232
- var Row = React.memo(function (_ref) {
233
- var item = _ref.item,
234
- disabled = _ref.disabled,
235
- editing = _ref.editing,
236
- _onClick = _ref.onClick,
237
- className = _ref.className,
238
- columns = _ref.columns,
239
- editingContext = _ref.editingContext;
240
- return ReactCreateElement("tr", {
241
- onClick: function onClick(e) {
242
- return _onClick(item);
243
- },
244
- className: classNames(disabled && disabled(item) && 'disabled', className && (isFunction(className) ? className(item) : className))
245
- }, columns.filter(function (it) {
246
- return !!it;
247
- }).map(function (column, i) {
248
- var isEditing = editing && editing.id === item.id && editing.columnIndex === i;
249
- var editable = isFunction(column.editable) ? column.editable(item) : !!column.editable;
250
- return ReactCreateElement("td", {
251
- key: i,
252
- className: classNames(editable ? 'editable' : 'ro', isEditing && 'editing', column.className),
253
- onClick: !isEditing && editable ? function () {
254
- return editingContext.setEditing(item, i, column.field);
255
- } : NOOP
256
- }, (isEditing || column.displayEditor) && !column.editor && ReactCreateElement(TextField, {
257
- value: column.preEditor ? column.preEditor(editing.value) : editing.value,
258
- focused: true,
259
- onBlur: editingContext.cancelEditing,
260
- onChange: editingContext.handleInputChange,
261
- onKeyDown: function onKeyDown(e) {
262
- if (e.keyCode === 27
263
- ) {
264
- preventDefault(e);
265
- editingContext.cancelEditing();
266
- }
267
- if (e.keyCode === 13
268
- ) {
269
- preventDefault(e);
270
- editingContext.onFinishEditing();
271
- }
272
- }
273
- }), (isEditing || column.displayEditor) && column.editor === 'Select' && ReactCreateElement(AutocompleteSelect, {
274
- value: column.preEditor ? column.preEditor(editing.value) : editing.value,
275
- data: column.editorData,
276
- focused: true,
277
- withArrow: false,
278
- withFilter: false,
279
- selectedMode: 'inline',
280
- selectedComponent: column.editorSelectedComponent,
281
- mode: column.multiSelect ? MODE_MULTIPLE_MINI : MODE_DEFAULT,
282
- onChange: column.multiSelect && (column.onSelect ? function (value) {
283
- return editingContext.selectNewValue(column.onSelect(value));
284
- } : editingContext.selectNewValue),
285
- onSelect: !column.multiSelect && (column.onSelect ? function (value) {
286
- return editingContext.selectNewValue(column.onSelect(value));
287
- } : editingContext.selectNewValue),
288
- childComponent: column.editorChildCompononRowClickent,
289
- onCancel: editingContext.cancelEditing,
290
- prefilter: column.prefilter
291
- }), (isEditing || column.displayEditor) && column.editor === 'Switch' && ReactCreateElement(Switch, {
292
- onClick: function onClick(e) {
293
- stopPropagation(e);
294
- preventDefault(e);
295
- editingContext.setState({
296
- editing: _objectSpread2(_objectSpread2({}, editingContext.prepareEditing(item, column.field, i)), {}, {
297
- value: !item[column.field]
298
- })
299
- }, editingContext.onFinishEditing);
300
- },
301
- value: item[column.field]
302
- }), (isEditing || column.displayEditor) && isFunction(column.editor) && column.editor(item, editingContext.cancelEditing, isEditing), !isEditing && !column.displayEditor && formatValue(item, column));
303
- }));
130
+ const Row = React.memo(({ item, disabled, editing, onClick, className, columns, editingContext }) => {
131
+ return jsxRuntime_2("tr", __extends({ onClick: e => onClick(item), [__className]: classNames(disabled && disabled(item) && 'disabled', className && (isFunction(className) ? className(item) : className)) }, { [__children]: columns.filter(it => !!it).map((column, i) => {
132
+ const isEditing = editing && editing.id === item.id && editing.columnIndex === i;
133
+ const editable = isFunction(column.editable) ? column.editable(item) : !!column.editable;
134
+ return (jsxRuntime_1("td", __extends({ [__className]: classNames(editable ? 'editable' : 'ro', isEditing && 'editing', column.className), onClick: !isEditing && editable ? () => editingContext.setEditing(item, i, column.field) : NOOP }, { [__children]: [(isEditing || column.displayEditor) && !column.editor && (jsxRuntime_2(TextField, { value: column.preEditor ? column.preEditor(editing.value) : editing.value, focused: true, onBlur: editingContext.cancelEditing, onChange: editingContext.handleInputChange, onKeyDown: e => {
135
+ if (e.keyCode === 27 /*escape*/) {
136
+ preventDefault(e);
137
+ editingContext.cancelEditing();
138
+ }
139
+ if (e.keyCode === 13 /*enter*/) {
140
+ preventDefault(e);
141
+ editingContext.onFinishEditing();
142
+ }
143
+ } })), (isEditing || column.displayEditor) && column.editor === editorSelect && (jsxRuntime_2(AutocompleteSelect, { value: column.preEditor ? column.preEditor(editing.value) : editing.value, data: column.editorData, focused: true, withArrow: false, withFilter: false, selectedMode: 'inline', selectedComponent: column.editorSelectedComponent, mode: column.multiSelect ? MODE_MULTIPLE_MINI : MODE_DEFAULT, onChange: column.multiSelect && (column.onSelect ? (value => editingContext.selectNewValue(column.onSelect(value))) : editingContext.selectNewValue), onSelect: !column.multiSelect && (column.onSelect ? (value => editingContext.selectNewValue(column.onSelect(value))) : editingContext.selectNewValue), childComponent: column.editorChildCompononRowClickent, onCancel: editingContext.cancelEditing, prefilter: column.prefilter })), (isEditing || column.displayEditor) && column.editor === editorSwitch && (jsxRuntime_2(Switch, { onClick: e => {
144
+ stopPropagation(e);
145
+ preventDefault(e);
146
+ editingContext.setState({
147
+ editing: __extends(__extends({}, editingContext.prepareEditing(item, column.field, i)), { value: !item[column.field] })
148
+ }, editingContext.onFinishEditing);
149
+ }, value: item[column.field] })), (isEditing || column.displayEditor) && isFunction(column.editor) && column.editor(item, editingContext.cancelEditing, isEditing), !isEditing && !column.displayEditor && formatValue(item, column)] }), i));
150
+ }) }));
304
151
  });
305
- Table.defaultProps = {
306
- columns: [],
307
- onRowClick: NOOP,
308
- toKey: getId
309
- };
310
- if (process.env.NODE_ENV !== 'production') {
311
- Table.propTypes = {
312
- className: PropTypes.string,
313
- rowClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
314
- columns: PropTypes.arrayOf(PropTypes.shape({
315
- header: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
316
- className: PropTypes.string,
317
- sortable: PropTypes.bool,
318
- field: PropTypes.string,
319
- formatter: PropTypes.func,
320
- comparator: PropTypes.func,
321
- editable: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
322
- editor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
323
- displayEditor: PropTypes.bool,
324
- preEditor: PropTypes.func
325
- })),
326
- data: PropTypes.array,
327
- disabled: PropTypes.func,
328
- onRowClick: PropTypes.func,
329
- onSortChange: PropTypes.func,
330
- onChange: PropTypes.func,
331
- toKey: PropTypes.func
332
- };
333
- }
334
- var Table$1 = Table;
335
152
 
336
- export { SORT_ASC, SORT_DESC, Table$1 as default };
153
+ export { SORT_ASC, SORT_DESC, Table as default };
337
154
  //# sourceMappingURL=Table.js.map