aio-table 11.1.2 → 11.2.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 (3) hide show
  1. package/index.d.ts +8 -1
  2. package/index.js +24 -6
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -23,7 +23,14 @@ export type I_table_column<T> = {
23
23
  title?: any;
24
24
  sort?: true | I_table_sort<T>;
25
25
  jalali?: boolean;
26
- filterId?: string;
26
+ filter?: {
27
+ operators?: UT.I_filter_operator[];
28
+ options?: {
29
+ text: string;
30
+ value: string;
31
+ }[];
32
+ type?: I_table_column<any>["type"];
33
+ };
27
34
  search?: boolean;
28
35
  id: string;
29
36
  width?: any;
package/index.js CHANGED
@@ -116,7 +116,7 @@ const AIOTable = (props) => {
116
116
  let searchColumns = [], excelColumns = [], filterColumns = [], toggleColumns = [];
117
117
  let updatedColumns = columns.map((column, i) => {
118
118
  const cellDetail = tableHook.getCellDetail({ column });
119
- const filterId = getColumnOption('filterId', cellDetail);
119
+ const filter = getColumnOption('filter', cellDetail);
120
120
  const search = getColumnOption('search', cellDetail);
121
121
  const excel = getColumnOption('excel', cellDetail);
122
122
  const toggle = getColumnOption('toggle', cellDetail);
@@ -130,7 +130,7 @@ const AIOTable = (props) => {
130
130
  if (excel) {
131
131
  excelColumns.push(column);
132
132
  }
133
- if (filterId) {
133
+ if (filter) {
134
134
  filterColumns.push(column);
135
135
  }
136
136
  if (toggle) {
@@ -266,8 +266,12 @@ const AIOTable = (props) => {
266
266
  return (_jsxs(Provider, { value: context, children: [_jsxs("div", Object.assign({}, attrs, { children: [_jsx(TableToolbar, {}), !!props.filter &&
267
267
  _jsx(UT.Filterbar, { columns: filterColumns, filter: props.filter, fa: props.fa, columnOption: {
268
268
  text: (column) => getColumnOption('title', tableHook.getCellDetail({ column })),
269
- id: (column) => getColumnOption('filterId', tableHook.getCellDetail({ column })),
270
- type: (column) => getColumnOption('type', tableHook.getCellDetail({ column })) || 'text'
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
+ },
271
275
  } }), _jsxs("div", { className: 'aio-table-unit aio-table-scroll', style: { gap: gap[1] }, children: [_jsx(TableHeader, {}), _jsx(TableRows, {})] }), pagingHook.render()] })), popup.render()] }));
272
276
  };
273
277
  export default AIOTable;
@@ -431,7 +435,14 @@ const TableCell = (props) => {
431
435
  const beforeValue = tableHook.getCellValue(cellDetail, before, undefined);
432
436
  const afterValue = tableHook.getCellValue(cellDetail, after, undefined);
433
437
  const subtextValue = tableHook.getCellValue(cellDetail, subtext, undefined);
434
- return (_jsx(Fragment, { children: _jsxs("div", Object.assign({}, tableHook.getCellAttrs(props.cellDetail, props.cellValue, isOdd, rootProps.striped), { children: [beforeValue !== undefined && _jsx("div", { className: "aio-table-cell-before", children: beforeValue }), _jsxs("div", { className: `aio-table-cell-value${subtext !== undefined ? ' has-subtext' : ''}`, "data-subtext": subtextValue, children: [templateValue !== undefined && templateValue, templateValue === undefined && cellValue] }), afterValue !== undefined && _jsx("div", { className: "aio-table-cell-after", children: afterValue })] })) }, rowId + ' ' + colId));
438
+ let content;
439
+ if (templateValue !== undefined) {
440
+ content = templateValue;
441
+ }
442
+ else {
443
+ content = cellValue;
444
+ }
445
+ return (_jsx(Fragment, { children: _jsxs("div", Object.assign({}, tableHook.getCellAttrs(props.cellDetail, cellValue, isOdd, rootProps.striped), { children: [beforeValue !== undefined && _jsx("div", { className: "aio-table-cell-before", children: beforeValue }), _jsx("div", { className: `aio-table-cell-value${subtext !== undefined ? ' has-subtext' : ''}`, "data-subtext": subtextValue, children: content }), afterValue !== undefined && _jsx("div", { className: "aio-table-cell-after", children: afterValue })] })) }, rowId + ' ' + colId));
435
446
  };
436
447
  const useTable = (getProps, getPaging, getColumnOption) => {
437
448
  const DragRows = UT.useDrag((dragIndex, dropIndex, reOrder) => {
@@ -502,7 +513,14 @@ const useTable = (getProps, getPaging, getColumnOption) => {
502
513
  const width = getColumnOption('width', cellDetail);
503
514
  const minWidth = getColumnOption('minWidth', cellDetail);
504
515
  const className = `aio-table-cell` + (justify ? ` aio-table-cell-justify` : '');
505
- const style = { width, minWidth, flex: width ? undefined : 1 };
516
+ let isNumber = false;
517
+ try {
518
+ if (!isNaN(+cellValue)) {
519
+ isNumber = true;
520
+ }
521
+ }
522
+ catch (_a) { }
523
+ const style = { width, minWidth, flex: width ? undefined : 1, direction: isNumber ? 'ltr' : undefined };
506
524
  if (striped) {
507
525
  style.background = isOdd ? striped[0] : striped[1];
508
526
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-table",
3
- "version": "11.1.2",
3
+ "version": "11.2.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",