aio-table 11.0.1 → 11.1.0

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 (2) hide show
  1. package/index.js +18 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -34,6 +34,9 @@ const AIOTable = (props) => {
34
34
  propsRef.current = props;
35
35
  const pagingHook = UT.usePaging({ rows: props.value, paging: props.paging, onChange: props.onChangePaging });
36
36
  const getColumnOption = (key, cellDetails) => {
37
+ if (key === 'id') {
38
+ return cellDetails.column.id;
39
+ }
37
40
  const columnValue = cellDetails.column[key];
38
41
  if (columnValue !== undefined) {
39
42
  const { getValue = {} } = props;
@@ -62,7 +65,7 @@ const AIOTable = (props) => {
62
65
  if (props.onChangeColumns) {
63
66
  props.onChangeColumns(newColumns);
64
67
  }
65
- }, 'aio-table-title', 'aio-table-unit');
68
+ }, 'aio-table-title');
66
69
  const getGetValue = (sort, column) => {
67
70
  if (sort.getValue) {
68
71
  return sort.getValue;
@@ -134,9 +137,6 @@ const AIOTable = (props) => {
134
137
  }
135
138
  return column;
136
139
  });
137
- if (props.onChangeColumns) {
138
- props.onChangeColumns(updatedColumns);
139
- }
140
140
  setSearchColumns(searchColumns);
141
141
  setExcelColumns(excelColumns);
142
142
  setFilterColumns(filterColumns);
@@ -309,7 +309,7 @@ const TableRows = () => {
309
309
  };
310
310
  const TableToolbar = () => {
311
311
  let { add, exportToExcel, search, rootProps, excelColumns, toggleColumns, getIcon, sortHook, getColumnOption, tableHook } = useProvider();
312
- let { toolbarAttrs, toolbar, onAdd, onSearch, value, onChangeColumns, columns } = rootProps;
312
+ let { toolbarAttrs, toolbar, onAdd, onSearch, value, onChangeColumns, columns = [] } = rootProps;
313
313
  const columnsRef = useRef(columns);
314
314
  columnsRef.current = columns;
315
315
  toolbarAttrs = UT.AddToAttrs(toolbarAttrs, { className: 'aio-table-toolbar' });
@@ -329,8 +329,8 @@ const TableToolbar = () => {
329
329
  return getColumnOption(key, tableHook.getCellDetail({ column }));
330
330
  };
331
331
  return (_jsxs("div", Object.assign({}, toolbarAttrs, { children: [toolbar && _jsx("div", { className: 'aio-table-toolbar-content', children: typeof toolbar === 'function' ? toolbar() : toolbar }), !!onSearch &&
332
- _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', onClick: () => exportToExcel(), children: getIcon('mdiFileExcel', 0.8) }), !!toggleColumns.length &&
333
- _jsx("div", { className: 'aio-table-toolbar-button', children: _jsx(AISelect, { text: getIcon('mdiEye', 0.8), hideTags: true, options: toggleColumns, caret: false, option: {
332
+ _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 &&
333
+ _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: {
334
334
  text: (column) => getColumnOptionWrapper(column.id, 'title'),
335
335
  checked: (column) => getColumnOptionWrapper(column.id, 'show'),
336
336
  onClick: (column) => {
@@ -341,7 +341,7 @@ const TableToolbar = () => {
341
341
  onChangeColumns(columns.map((o) => column.id === o.id ? Object.assign(Object.assign({}, o), { show: !getColumnOptionWrapper(o.id, 'show') }) : o));
342
342
  },
343
343
  close: () => false
344
- } }) }), !!onAdd && _jsx("div", { className: 'aio-table-toolbar-button', onClick: () => add(), children: getAddText() })] })));
344
+ } }) }), !!onAdd && _jsx("div", { className: 'aio-table-toolbar-button aio-table-add-button', onClick: () => add(), children: getAddText() })] })));
345
345
  };
346
346
  const TableHeader = () => {
347
347
  let { rootProps, getColumnOption, tableHook } = useProvider();
@@ -412,13 +412,16 @@ const TableCell = (props) => {
412
412
  return columnOption.template(cellDetail);
413
413
  }
414
414
  const pattern = getColumnOption('pattern', cellDetail);
415
- if (pattern) {
416
- if (type === 'date') {
417
- return new AIODate().getDateByPattern(cellValue, pattern);
418
- }
419
- else {
420
- return pattern.replace('{value}', cellValue);
415
+ if (pattern && cellValue) {
416
+ try {
417
+ if (type === 'date') {
418
+ return new AIODate().getDateByPattern(cellValue, pattern);
419
+ }
420
+ else {
421
+ return pattern.replace('{value}', cellValue);
422
+ }
421
423
  }
424
+ catch (_a) { }
422
425
  }
423
426
  };
424
427
  const templateValue = getTemplateValue();
@@ -439,7 +442,7 @@ const useTable = (getProps, getPaging, getColumnOption) => {
439
442
  else if (onChange) {
440
443
  onChange(newRows);
441
444
  }
442
- }, 'aio-table-row', 'aio-table-rows');
445
+ }, 'aio-table-row');
443
446
  const getCellValue = (cellDetail, cellValue, def) => {
444
447
  const { getValue = {} } = getProps();
445
448
  const paging = getPaging();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-table",
3
- "version": "11.0.1",
3
+ "version": "11.1.0",
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",