aio-table 11.1.3 → 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 +16 -5
  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;
@@ -509,7 +513,14 @@ const useTable = (getProps, getPaging, getColumnOption) => {
509
513
  const width = getColumnOption('width', cellDetail);
510
514
  const minWidth = getColumnOption('minWidth', cellDetail);
511
515
  const className = `aio-table-cell` + (justify ? ` aio-table-cell-justify` : '');
512
- const style = { width, minWidth, flex: width ? undefined : 1, direction: typeof cellValue === 'number' ? 'ltr' : undefined };
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 };
513
524
  if (striped) {
514
525
  style.background = isOdd ? striped[0] : striped[1];
515
526
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-table",
3
- "version": "11.1.3",
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",