aio-table 11.2.0 → 11.2.2
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/index.css +11 -2
- package/index.d.ts +2 -2
- package/index.js +22 -16
- package/package.json +1 -1
package/index.css
CHANGED
|
@@ -163,6 +163,8 @@
|
|
|
163
163
|
z-index: 100;
|
|
164
164
|
box-sizing: border-box;
|
|
165
165
|
min-height: 36px;
|
|
166
|
+
gap: 6px;
|
|
167
|
+
padding: 6px;
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
.aio-table-toolbar-content {
|
|
@@ -174,17 +176,24 @@
|
|
|
174
176
|
}
|
|
175
177
|
|
|
176
178
|
.aio-table-toolbar-button {
|
|
177
|
-
height:
|
|
179
|
+
height: 36px;
|
|
178
180
|
display: flex;
|
|
179
181
|
align-items: center;
|
|
180
182
|
justify-content: center;
|
|
181
|
-
|
|
183
|
+
width: 36px;
|
|
182
184
|
border: none;
|
|
183
185
|
background: none;
|
|
184
186
|
}
|
|
187
|
+
.aio-table-toolbar .aio-filter-icon-button{
|
|
188
|
+
border:none;
|
|
189
|
+
background: none;
|
|
190
|
+
}
|
|
185
191
|
.aio-table-toolbar-button .aio-input{
|
|
186
192
|
border:none;
|
|
187
193
|
background: none;
|
|
194
|
+
width:100%;
|
|
195
|
+
height:100%;
|
|
196
|
+
padding:0;
|
|
188
197
|
}
|
|
189
198
|
|
|
190
199
|
|
package/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type I_table_paging = UT.I_paging;
|
|
|
18
18
|
export type I_table_sort<T> = UT.I_sort<T>;
|
|
19
19
|
export type I_table_filter = UT.I_filter;
|
|
20
20
|
export type I_table_filter_item = UT.I_filter_item;
|
|
21
|
-
export type I_table_filter_saved_item = UT.
|
|
21
|
+
export type I_table_filter_saved_item = UT.I_filter_collection;
|
|
22
22
|
export type I_table_column<T> = {
|
|
23
23
|
title?: any;
|
|
24
24
|
sort?: true | I_table_sort<T>;
|
|
@@ -27,7 +27,7 @@ export type I_table_column<T> = {
|
|
|
27
27
|
operators?: UT.I_filter_operator[];
|
|
28
28
|
options?: {
|
|
29
29
|
text: string;
|
|
30
|
-
value:
|
|
30
|
+
value: any;
|
|
31
31
|
}[];
|
|
32
32
|
type?: I_table_column<any>["type"];
|
|
33
33
|
};
|
package/index.js
CHANGED
|
@@ -111,6 +111,20 @@ const AIOTable = (props) => {
|
|
|
111
111
|
onChangeRows: props.onChange,
|
|
112
112
|
onChangeSort: props.onChangeSort,
|
|
113
113
|
});
|
|
114
|
+
const filterHook = UT.useFilter({
|
|
115
|
+
columns: filterColumns,
|
|
116
|
+
filter: props.filter || { onChange: () => { } },
|
|
117
|
+
fa: props.fa,
|
|
118
|
+
columnOption: {
|
|
119
|
+
text: (column) => getColumnOption('title', tableHook.getCellDetail({ column })),
|
|
120
|
+
id: (column) => getColumnOption('id', tableHook.getCellDetail({ column })),
|
|
121
|
+
type: (column) => getColumnOption('type', tableHook.getCellDetail({ column })) || 'text',
|
|
122
|
+
options: (column) => {
|
|
123
|
+
const filter = getColumnOption('filter', tableHook.getCellDetail({ column }));
|
|
124
|
+
return filter === null || filter === void 0 ? void 0 : filter.options;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
114
128
|
function getColumns() {
|
|
115
129
|
let { columns = [] } = props;
|
|
116
130
|
let searchColumns = [], excelColumns = [], filterColumns = [], toggleColumns = [];
|
|
@@ -260,19 +274,10 @@ const AIOTable = (props) => {
|
|
|
260
274
|
const { gap = [0, 1] } = props;
|
|
261
275
|
let attrs = UT.AddToAttrs(props.attrs, { className: ['aio-table', props.className], style: Object.assign({ gap: gap[1] }, props.style), attrs: { ref: dom } });
|
|
262
276
|
const context = {
|
|
263
|
-
rootProps: props, excelColumns, filterColumns, tableHook, sortHook, ROWS, toggleColumns,
|
|
277
|
+
rootProps: props, excelColumns, filterColumns, tableHook, sortHook, ROWS, toggleColumns, filterHook,
|
|
264
278
|
getRowsIndexDic, add, remove, search, exportToExcel, DragColumns, getIcon, popup, getColumnOption
|
|
265
279
|
};
|
|
266
|
-
return (_jsxs(Provider, { value: context, children: [_jsxs("div", Object.assign({}, attrs, { children: [_jsx(TableToolbar, {}), !!props.filter &&
|
|
267
|
-
_jsx(UT.Filterbar, { columns: filterColumns, filter: props.filter, fa: props.fa, columnOption: {
|
|
268
|
-
text: (column) => getColumnOption('title', tableHook.getCellDetail({ column })),
|
|
269
|
-
id: (column) => getColumnOption('id', tableHook.getCellDetail({ column })),
|
|
270
|
-
type: (column) => getColumnOption('type', tableHook.getCellDetail({ column })) || 'text',
|
|
271
|
-
options: (column) => {
|
|
272
|
-
const filter = getColumnOption('filter', tableHook.getCellDetail({ column }));
|
|
273
|
-
return filter === null || filter === void 0 ? void 0 : filter.options;
|
|
274
|
-
},
|
|
275
|
-
} }), _jsxs("div", { className: 'aio-table-unit aio-table-scroll', style: { gap: gap[1] }, children: [_jsx(TableHeader, {}), _jsx(TableRows, {})] }), pagingHook.render()] })), popup.render()] }));
|
|
280
|
+
return (_jsxs(Provider, { value: context, children: [_jsxs("div", Object.assign({}, attrs, { children: [_jsx(TableToolbar, {}), !!props.filter && filterHook.renderTags(), _jsxs("div", { className: 'aio-table-unit aio-table-scroll', style: { gap: gap[1] }, children: [_jsx(TableHeader, {}), _jsx(TableRows, {})] }), pagingHook.render()] })), popup.render()] }));
|
|
276
281
|
};
|
|
277
282
|
export default AIOTable;
|
|
278
283
|
const TableRows = () => {
|
|
@@ -313,12 +318,12 @@ const TableRows = () => {
|
|
|
313
318
|
return _jsx("div", { className: 'aio-table-rows', style: { gap: gap[1] }, children: content });
|
|
314
319
|
};
|
|
315
320
|
const TableToolbar = () => {
|
|
316
|
-
let { add, exportToExcel, search, rootProps, excelColumns, toggleColumns, getIcon, sortHook, getColumnOption, tableHook } = useProvider();
|
|
321
|
+
let { add, exportToExcel, search, rootProps, excelColumns, toggleColumns, getIcon, sortHook, getColumnOption, tableHook, filterHook } = useProvider();
|
|
317
322
|
let { toolbarAttrs, toolbar, onAdd, onSearch, value, onChangeColumns, columns = [] } = rootProps;
|
|
318
323
|
const columnsRef = useRef(columns);
|
|
319
324
|
columnsRef.current = columns;
|
|
320
325
|
toolbarAttrs = UT.AddToAttrs(toolbarAttrs, { className: 'aio-table-toolbar' });
|
|
321
|
-
if (!onAdd && !toolbar && !onSearch && !sortHook.sorts.length && !excelColumns.length && !toggleColumns.length) {
|
|
326
|
+
if (!onAdd && !toolbar && !onSearch && !sortHook.sorts.length && !excelColumns.length && !toggleColumns.length && !rootProps.filter) {
|
|
322
327
|
return null;
|
|
323
328
|
}
|
|
324
329
|
function getAddText() {
|
|
@@ -333,9 +338,10 @@ const TableToolbar = () => {
|
|
|
333
338
|
const column = columns.find((o) => o.id === columnId);
|
|
334
339
|
return getColumnOption(key, tableHook.getCellDetail({ column }));
|
|
335
340
|
};
|
|
336
|
-
return (_jsxs("div", Object.assign({}, toolbarAttrs, { children: [toolbar && _jsx("div", { className: 'aio-table-toolbar-content', children: typeof toolbar === 'function' ? toolbar() : toolbar }), !!onSearch &&
|
|
337
|
-
_jsx("div", { className: 'aio-table-search', children: _jsx(AIOInput, { type: 'text', onChange: (value) => search(value), after: getIcon('mdiMagnify', 0.7) }) }), sortHook.
|
|
338
|
-
_jsx("div", { className: 'aio-table-toolbar-button aio-table-
|
|
341
|
+
return (_jsxs("div", Object.assign({}, toolbarAttrs, { children: [toolbar && _jsx("div", { className: 'aio-table-toolbar-content', children: typeof toolbar === 'function' ? toolbar() : toolbar }), !!rootProps.filter && filterHook.renderButton(), !!onSearch &&
|
|
342
|
+
_jsx("div", { className: 'aio-table-search', children: _jsx(AIOInput, { type: 'text', onChange: (value) => search(value), after: getIcon('mdiMagnify', 0.7) }) }), !!sortHook.sorts.length &&
|
|
343
|
+
_jsx("div", { className: 'aio-table-toolbar-button aio-table-sort-button', children: sortHook.renderSortButton() }), !!excelColumns.length && _jsx("div", { className: 'aio-table-toolbar-button aio-table-excel-button', onClick: () => exportToExcel(), children: getIcon('mdiFileExcel', 0.8) }), !!toggleColumns.length &&
|
|
344
|
+
_jsx("div", { className: 'aio-table-toolbar-button aio-table-toggle-button', children: _jsx(AISelect, { text: getIcon('mdiEye', 0.8), justify: true, hideTags: true, options: toggleColumns.map((o) => (Object.assign(Object.assign({}, o), { show: true }))), caret: false, option: {
|
|
339
345
|
text: (column) => getColumnOptionWrapper(column.id, 'title'),
|
|
340
346
|
checked: (column) => getColumnOptionWrapper(column.id, 'show'),
|
|
341
347
|
onClick: (column) => {
|