aio-table 11.2.1 → 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.
Files changed (3) hide show
  1. package/index.css +11 -2
  2. package/index.js +22 -16
  3. 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: 100%;
179
+ height: 36px;
178
180
  display: flex;
179
181
  align-items: center;
180
182
  justify-content: center;
181
- min-width: 36px;
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.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.renderSortButton(), !!excelColumns.length && _jsx("div", { className: 'aio-table-toolbar-button aio-table-excel-button', onClick: () => exportToExcel(), children: getIcon('mdiFileExcel', 0.8) }), !!toggleColumns.length &&
338
- _jsx("div", { className: 'aio-table-toolbar-button aio-table-toggle-button', children: _jsx(AISelect, { text: getIcon('mdiEye', 0.8), hideTags: true, options: toggleColumns.map((o) => (Object.assign(Object.assign({}, o), { show: true }))), caret: false, option: {
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) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-table",
3
- "version": "11.2.1",
3
+ "version": "11.2.2",
4
4
  "description": "all in one table. tree mode , simple mode , tree mode, gantt mode , groupby mode, freeze mode.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",