@servicetitan/table 25.0.1 → 25.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. package/dist/demo/filters/async-select-filter.js +1 -1
  2. package/dist/demo/filters/async-select-filter.js.map +1 -1
  3. package/dist/demo/filters/categories.d.ts.map +1 -1
  4. package/dist/demo/filters/categories.js +24 -0
  5. package/dist/demo/filters/categories.js.map +1 -1
  6. package/dist/demo/filters/multiselect-filter.d.ts.map +1 -1
  7. package/dist/demo/filters/multiselect-filter.js +2 -1
  8. package/dist/demo/filters/multiselect-filter.js.map +1 -1
  9. package/dist/demo/filters/select-filter.d.ts +6 -0
  10. package/dist/demo/filters/select-filter.d.ts.map +1 -0
  11. package/dist/demo/filters/select-filter.js +58 -0
  12. package/dist/demo/filters/select-filter.js.map +1 -0
  13. package/dist/demo/filters/single-select-filter.d.ts.map +1 -1
  14. package/dist/demo/filters/single-select-filter.js +2 -1
  15. package/dist/demo/filters/single-select-filter.js.map +1 -1
  16. package/dist/demo/filters/table.store.d.ts +8 -1
  17. package/dist/demo/filters/table.store.d.ts.map +1 -1
  18. package/dist/demo/filters/table.store.js +35 -1
  19. package/dist/demo/filters/table.store.js.map +1 -1
  20. package/dist/demo/footer-page-size/index.d.ts +2 -0
  21. package/dist/demo/footer-page-size/index.d.ts.map +1 -0
  22. package/dist/demo/footer-page-size/index.js +2 -0
  23. package/dist/demo/footer-page-size/index.js.map +1 -0
  24. package/dist/demo/footer-page-size/table.d.ts +3 -0
  25. package/dist/demo/footer-page-size/table.d.ts.map +1 -0
  26. package/dist/demo/footer-page-size/table.js +18 -0
  27. package/dist/demo/footer-page-size/table.js.map +1 -0
  28. package/dist/demo/index.d.ts +1 -0
  29. package/dist/demo/index.d.ts.map +1 -1
  30. package/dist/demo/index.js +1 -0
  31. package/dist/demo/index.js.map +1 -1
  32. package/dist/demo/overview/product.d.ts +5 -0
  33. package/dist/demo/overview/product.d.ts.map +1 -1
  34. package/dist/demo/overview/products.d.ts.map +1 -1
  35. package/dist/demo/overview/products.js +12 -0
  36. package/dist/demo/overview/products.js.map +1 -1
  37. package/dist/demo/overview/table.store.d.ts.map +1 -1
  38. package/dist/demo/overview/table.store.js +1 -0
  39. package/dist/demo/overview/table.store.js.map +1 -1
  40. package/dist/filters/async-select/async-select-filter.d.ts +7 -3
  41. package/dist/filters/async-select/async-select-filter.d.ts.map +1 -1
  42. package/dist/filters/async-select/async-select-filter.js +21 -6
  43. package/dist/filters/async-select/async-select-filter.js.map +1 -1
  44. package/dist/filters/column-menu-filters.d.ts +10 -1
  45. package/dist/filters/column-menu-filters.d.ts.map +1 -1
  46. package/dist/filters/column-menu-filters.js +11 -3
  47. package/dist/filters/column-menu-filters.js.map +1 -1
  48. package/dist/filters/index.d.ts +1 -0
  49. package/dist/filters/index.d.ts.map +1 -1
  50. package/dist/filters/index.js +1 -0
  51. package/dist/filters/index.js.map +1 -1
  52. package/dist/filters/multiselect-filter/multiselect-filter.d.ts +4 -3
  53. package/dist/filters/multiselect-filter/multiselect-filter.d.ts.map +1 -1
  54. package/dist/filters/multiselect-filter/multiselect-filter.js +7 -7
  55. package/dist/filters/multiselect-filter/multiselect-filter.js.map +1 -1
  56. package/dist/filters/select-filter/object-search.d.ts +2 -0
  57. package/dist/filters/select-filter/object-search.d.ts.map +1 -0
  58. package/dist/filters/select-filter/object-search.js +19 -0
  59. package/dist/filters/select-filter/object-search.js.map +1 -0
  60. package/dist/filters/select-filter/select-filter.d.ts +32 -0
  61. package/dist/filters/select-filter/select-filter.d.ts.map +1 -0
  62. package/dist/filters/select-filter/select-filter.js +214 -0
  63. package/dist/filters/select-filter/select-filter.js.map +1 -0
  64. package/dist/filters/select-filter/select-filter.stories.d.ts +8 -0
  65. package/dist/filters/select-filter/select-filter.stories.d.ts.map +1 -0
  66. package/dist/filters/select-filter/select-filter.stories.js +8 -0
  67. package/dist/filters/select-filter/select-filter.stories.js.map +1 -0
  68. package/dist/filters/select-filter/value-getter.d.ts +3 -0
  69. package/dist/filters/select-filter/value-getter.d.ts.map +1 -0
  70. package/dist/filters/select-filter/value-getter.js +10 -0
  71. package/dist/filters/select-filter/value-getter.js.map +1 -0
  72. package/dist/filters/single-select/single-select-filter.d.ts +3 -2
  73. package/dist/filters/single-select/single-select-filter.d.ts.map +1 -1
  74. package/dist/filters/single-select/single-select-filter.js +17 -7
  75. package/dist/filters/single-select/single-select-filter.js.map +1 -1
  76. package/dist/index.d.ts +1 -1
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +1 -1
  79. package/dist/index.js.map +1 -1
  80. package/package.json +6 -6
  81. package/src/demo/filters/async-select-filter.tsx +1 -1
  82. package/src/demo/filters/categories.tsx +24 -0
  83. package/src/demo/filters/multiselect-filter.tsx +15 -0
  84. package/src/demo/filters/select-filter.tsx +147 -0
  85. package/src/demo/filters/single-select-filter.tsx +2 -1
  86. package/src/demo/filters/table.store.ts +45 -2
  87. package/src/demo/footer-page-size/index.ts +1 -0
  88. package/src/demo/footer-page-size/table.tsx +104 -0
  89. package/src/demo/index.ts +1 -0
  90. package/src/demo/overview/product.ts +6 -0
  91. package/src/demo/overview/products.ts +12 -0
  92. package/src/demo/overview/table.store.ts +1 -0
  93. package/src/filters/async-select/async-select-filter.tsx +26 -15
  94. package/src/filters/column-menu-filters.tsx +44 -21
  95. package/src/filters/index.ts +1 -0
  96. package/src/filters/multiselect-filter/multiselect-filter.tsx +16 -7
  97. package/src/filters/select-filter/__tests__/object-search.test.ts +32 -0
  98. package/src/filters/select-filter/object-search.ts +25 -0
  99. package/src/filters/select-filter/select-filter.stories.tsx +8 -0
  100. package/src/filters/select-filter/select-filter.tsx +320 -0
  101. package/src/filters/select-filter/value-getter.ts +13 -0
  102. package/src/filters/single-select/single-select-filter.tsx +18 -10
  103. package/src/index.ts +1 -0
  104. package/src/table.stories.tsx +4 -2
@@ -1,7 +1,18 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx } from "react/jsx-runtime";
2
13
  import { Component } from 'react';
3
14
  import { Radio } from '@servicetitan/design-system';
4
- import { renderCustomColumnMenuFilter } from '../column-menu-filters';
15
+ import { renderCustomColumnMenuFilter, } from '../column-menu-filters';
5
16
  class SelectorRadio extends Component {
6
17
  render() {
7
18
  const { options, value, renderer } = this.props;
@@ -13,21 +24,20 @@ class SelectorRadio extends Component {
13
24
  });
14
25
  }
15
26
  }
16
- export function singleSelectColumnMenuFilter(props) {
27
+ export function singleSelectColumnMenuFilter(_a) {
28
+ var { options, valueSelector, renderItem, filterOperator } = _a, opts = __rest(_a, ["options", "valueSelector", "renderItem", "filterOperator"]);
17
29
  const FilterCell = ({ value, onChange }) => {
18
- var _a;
19
30
  const handleChange = (value, event) => {
20
- var _a;
21
31
  const filter = value === undefined
22
32
  ? { value: '', operator: '' }
23
33
  : {
24
34
  value,
25
- operator: (_a = props.filterOperator) !== null && _a !== void 0 ? _a : 'equals',
35
+ operator: filterOperator !== null && filterOperator !== void 0 ? filterOperator : 'equals',
26
36
  };
27
37
  onChange(Object.assign(Object.assign({}, filter), { syntheticEvent: event }));
28
38
  };
29
- return (_jsx(SelectorRadio, { options: props.options, value: value === '' ? undefined : value, onChange: handleChange, renderer: props.renderItem, valueSelector: (_a = props.valueSelector) !== null && _a !== void 0 ? _a : (option => option) }));
39
+ return (_jsx(SelectorRadio, { options: options, value: value === '' ? undefined : value, onChange: handleChange, renderer: renderItem, valueSelector: valueSelector !== null && valueSelector !== void 0 ? valueSelector : (option => option) }));
30
40
  };
31
- return renderCustomColumnMenuFilter(FilterCell);
41
+ return renderCustomColumnMenuFilter(FilterCell, opts);
32
42
  }
33
43
  //# sourceMappingURL=single-select-filter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"single-select-filter.js","sourceRoot":"","sources":["../../../src/filters/single-select/single-select-filter.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAiC,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAwB,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAUtE,MAAM,aAAsB,SAAQ,SAAgC;IAChE,MAAM;QACF,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAEhD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACjC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACrD,OAAO;YACH,oDAAoD;YACpD,6BAAkB,SAAS,EAAC,sBAAsB,gBAC9C,KAAC,KAAK,IACF,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,EAChD,OAAO,EAAE,KAAK,KAAK,WAAW,EAC9B,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,GACjE,KALK,KAAK,CAMT,CACV,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AASD,MAAM,UAAU,4BAA4B,CACxC,KAA4C;IAE5C,MAAM,UAAU,GAA6B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;;QACjE,MAAM,YAAY,GAAG,CAAC,KAAqB,EAAE,KAAuC,EAAE,EAAE;;YACpF,MAAM,MAAM,GACR,KAAK,KAAK,SAAS;gBACf,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBAC7B,CAAC,CAAC;oBACI,KAAK;oBACL,QAAQ,EAAE,MAAA,KAAK,CAAC,cAAc,mCAAI,QAAQ;iBAC7C,CAAC;YAEZ,QAAQ,iCACD,MAAM,KACT,cAAc,EAAE,KAAK,IACvB,CAAC;QACP,CAAC,CAAC;QAEF,OAAO,CACH,KAAC,aAAa,IACV,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,KAAK,EAAE,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EACvC,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,KAAK,CAAC,UAAU,EAC1B,aAAa,EAAE,MAAA,KAAK,CAAC,aAAa,mCAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,GAC1D,CACL,CAAC;IACN,CAAC,CAAC;IAEF,OAAO,4BAA4B,CAAC,UAAU,CAAC,CAAC;AACpD,CAAC"}
1
+ {"version":3,"file":"single-select-filter.js","sourceRoot":"","sources":["../../../src/filters/single-select/single-select-filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAiC,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAwB,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,EAEH,4BAA4B,GAC/B,MAAM,wBAAwB,CAAC;AAUhC,MAAM,aAAsB,SAAQ,SAAgC;IAChE,MAAM;QACF,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAEhD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACjC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACrD,OAAO;YACH,oDAAoD;YACpD,6BAAkB,SAAS,EAAC,sBAAsB,gBAC9C,KAAC,KAAK,IACF,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,EAChD,OAAO,EAAE,KAAK,KAAK,WAAW,EAC9B,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,GACjE,KALK,KAAK,CAMT,CACV,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAUD,MAAM,UAAU,4BAA4B,CAA6B,EAMjC;QANiC,EACrE,OAAO,EACP,aAAa,EACb,UAAU,EACV,cAAc,OAEsB,EADjC,IAAI,cAL8D,4DAMxE,CADU;IAEP,MAAM,UAAU,GAA6B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;QACjE,MAAM,YAAY,GAAG,CAAC,KAAqB,EAAE,KAAuC,EAAE,EAAE;YACpF,MAAM,MAAM,GACR,KAAK,KAAK,SAAS;gBACf,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;gBAC7B,CAAC,CAAC;oBACI,KAAK;oBACL,QAAQ,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,QAAQ;iBACvC,CAAC;YAEZ,QAAQ,iCACD,MAAM,KACT,cAAc,EAAE,KAAK,IACvB,CAAC;QACP,CAAC,CAAC;QAEF,OAAO,CACH,KAAC,aAAa,IACV,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EACvC,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,UAAU,EACpB,aAAa,EAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,GACpD,CACL,CAAC;IACN,CAAC,CAAC;IAEF,OAAO,4BAA4B,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAC1D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export * from './export';
6
6
  export * from './select-cell';
7
7
  export * from './use-observing-table-state';
8
8
  export * from './utils/filters';
9
- export { TableColumn, TableColumnProps, TableColumnMenuProps, TableColumnMenuFilter, TableColumnReorderEvent, TableCell, TableHeaderCellProps, TableRowProps, TableRowClickEvent, TableDetailRow, TableDetailRowProps, TableExpandChangeEvent, TableToolbar, TableNoRecords, TableFilterCellProps, TableFilterChangeEvent, } from '@servicetitan/design-system';
9
+ export { TableColumn, TableColumnProps, TableColumnMenuProps, TableColumnMenuFilter, TableColumnReorderEvent, TableCell, TableHeaderCellProps, TableHeaderCell, TableRowProps, TableRowClickEvent, TableDetailRow, TableDetailRowProps, TableExpandChangeEvent, TableToolbar, TableNoRecords, TableFilterCellProps, TableFilterChangeEvent, } from '@servicetitan/design-system';
10
10
  export { GridColumnMenuFilterUIProps as TableColumnMenuFilterUIProps } from '@progress/kendo-react-grid/dist/npm/interfaces/GridColumnMenuFilterUIProps';
11
11
  export { IdType, DataSource, InMemoryDataSource, AsyncDataSource } from '@servicetitan/data-query';
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EACH,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,sBAAsB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,2BAA2B,IAAI,4BAA4B,EAAE,MAAM,4EAA4E,CAAC;AAEzJ,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EACH,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,sBAAsB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,2BAA2B,IAAI,4BAA4B,EAAE,MAAM,4EAA4E,CAAC;AAEzJ,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -6,6 +6,6 @@ export * from './export';
6
6
  export * from './select-cell';
7
7
  export * from './use-observing-table-state';
8
8
  export * from './utils/filters';
9
- export { TableColumn, TableColumnMenuFilter, TableCell, TableDetailRow, TableToolbar, TableNoRecords, } from '@servicetitan/design-system';
9
+ export { TableColumn, TableColumnMenuFilter, TableCell, TableHeaderCell, TableDetailRow, TableToolbar, TableNoRecords, } from '@servicetitan/design-system';
10
10
  export { InMemoryDataSource, AsyncDataSource } from '@servicetitan/data-query';
11
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EACH,WAAW,EAGX,qBAAqB,EAErB,SAAS,EAIT,cAAc,EAGd,YAAY,EACZ,cAAc,GAGjB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAsB,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EACH,WAAW,EAGX,qBAAqB,EAErB,SAAS,EAET,eAAe,EAGf,cAAc,EAGd,YAAY,EACZ,cAAc,GAGjB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAsB,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/table",
3
- "version": "25.0.1",
3
+ "version": "25.2.0",
4
4
  "description": "",
5
5
  "homepage": "https://docs.st.dev/docs/frontend/table",
6
6
  "repository": {
@@ -37,9 +37,9 @@
37
37
  "memoize-one": "~6.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@servicetitan/data-query": "^25.0.1",
40
+ "@servicetitan/data-query": "^25.2.0",
41
41
  "@servicetitan/design-system": ">=12.4.1",
42
- "@servicetitan/form": "^25.0.1",
42
+ "@servicetitan/form": "^25.2.0",
43
43
  "@servicetitan/react-ioc": "^21.6.0",
44
44
  "@servicetitan/suppress-warnings": "^21.6.0",
45
45
  "@types/accounting": "~0.4.2",
@@ -53,9 +53,9 @@
53
53
  "react": "~17.0.2"
54
54
  },
55
55
  "peerDependencies": {
56
- "@servicetitan/data-query": "^25.0.1",
56
+ "@servicetitan/data-query": "^25.2.0",
57
57
  "@servicetitan/design-system": ">=12.4.1",
58
- "@servicetitan/form": "^25.0.1",
58
+ "@servicetitan/form": "^25.2.0",
59
59
  "@servicetitan/react-ioc": ">21.0.0",
60
60
  "@servicetitan/suppress-warnings": ">21.0.0",
61
61
  "accounting": "~0.4.1",
@@ -72,5 +72,5 @@
72
72
  "cli": {
73
73
  "webpack": false
74
74
  },
75
- "gitHead": "81ba2d8ecce891162d8d4de743c6b3fff9cf1982"
75
+ "gitHead": "5ce3b7761ea46df59cee9e036aec6eefadd3e0ad"
76
76
  }
@@ -27,8 +27,8 @@ export const AsyncSelectDefaultExample: FC = provide({
27
27
  () =>
28
28
  asyncSelectColumnMenuFilter({
29
29
  dataFetcher: categoryFetcher,
30
- placeholder: 'Search for Categories',
31
30
  multiple: true,
31
+ contentMaxHeight: '250px',
32
32
  }),
33
33
  [categoryFetcher]
34
34
  );
@@ -31,6 +31,30 @@ export const categories: Category[] = [
31
31
  CategoryID: 10,
32
32
  CategoryName: 'Sashimi',
33
33
  },
34
+ {
35
+ CategoryID: 21,
36
+ CategoryName: 'Borsh',
37
+ },
38
+ {
39
+ CategoryID: 22,
40
+ CategoryName: 'Pasta Carbonara',
41
+ },
42
+ {
43
+ CategoryID: 23,
44
+ CategoryName: 'Caesar salad',
45
+ },
46
+ {
47
+ CategoryID: 24,
48
+ CategoryName: 'Ravioli',
49
+ },
50
+ {
51
+ CategoryID: 25,
52
+ CategoryName: 'Pizza',
53
+ },
54
+ {
55
+ CategoryID: 26,
56
+ CategoryName: 'Steak',
57
+ },
34
58
  ];
35
59
 
36
60
  export const CategoryCell: FC<TableCellProps> = props => {
@@ -19,6 +19,16 @@ export const MultiSelectDefaultExample: FC = provide({
19
19
  [madeInOptions]
20
20
  );
21
21
 
22
+ const categoryColumnMenu = useMemo(
23
+ () =>
24
+ multiSelectColumnMenuFilter(
25
+ new Array(20).fill(0).map((_, index) => index),
26
+ undefined,
27
+ { contentMaxHeight: '250px' }
28
+ ),
29
+ []
30
+ );
31
+
22
32
  return (
23
33
  <Table tableState={tableState}>
24
34
  <TableColumn field="ProductID" title="ID" editable={false} width="100px" />
@@ -26,6 +36,11 @@ export const MultiSelectDefaultExample: FC = provide({
26
36
  <TableColumn field="ProductName" title="Product Name" width="240px" />
27
37
 
28
38
  <TableColumn field="MadeIn" title="Made In" columnMenu={madeInColumnMenu} />
39
+ <TableColumn
40
+ field="CategoryID"
41
+ title="CategoryID"
42
+ columnMenu={categoryColumnMenu}
43
+ />
29
44
  </Table>
30
45
  );
31
46
  })
@@ -0,0 +1,147 @@
1
+ import { useMemo, FC, Fragment } from 'react';
2
+ import { observer } from 'mobx-react';
3
+ import { Banner } from '@servicetitan/design-system';
4
+ import { provide, useDependencies } from '@servicetitan/react-ioc';
5
+
6
+ import { Table, TableColumn, selectColumnMenuFilter, TableCellProps } from '../..';
7
+
8
+ import { TableStore } from './table.store';
9
+ import { categories, CategoryCell } from './categories';
10
+ import { Product } from '../overview/product';
11
+
12
+ export const PackageCell: FC<TableCellProps> = props => {
13
+ const { dataItem } = props;
14
+
15
+ return <td>{dataItem?.Package?.PackageName}</td>;
16
+ };
17
+
18
+ export const SelectAsyncExample: FC = provide({
19
+ singletons: [TableStore],
20
+ })(
21
+ observer(() => {
22
+ const [{ categoryFetcherClean, madeInFetcherClean, tableState }] =
23
+ useDependencies(TableStore);
24
+
25
+ const madeInColumnMenu = useMemo(
26
+ () =>
27
+ selectColumnMenuFilter({
28
+ dataFetcher: madeInFetcherClean,
29
+ search: true,
30
+ }),
31
+ [madeInFetcherClean]
32
+ );
33
+
34
+ const categoryColumnMenu = useMemo(
35
+ () =>
36
+ selectColumnMenuFilter({
37
+ dataFetcher: categoryFetcherClean,
38
+ multiple: true,
39
+ contentMaxHeight: '250px',
40
+ valueSelector: item => item.CategoryID,
41
+ }),
42
+ [categoryFetcherClean]
43
+ );
44
+
45
+ return (
46
+ <Fragment>
47
+ <Banner title="Default filter with async select" className="m-b-2">
48
+ Async select filter allows to choose one or several option from the list that
49
+ will be fetched from BE. The list size is not limited, so you can also use
50
+ search to find desired option.
51
+ <br />
52
+ Use it when there can be greater than 20 possible options
53
+ </Banner>
54
+ <Table tableState={tableState} striped={false}>
55
+ <TableColumn field="ProductID" title="ID" editable={false} width="100px" />
56
+ <TableColumn field="ProductName" title="Product Name" width="240px" />
57
+ <TableColumn
58
+ field="MadeIn"
59
+ title="Made In (async single-select filter)"
60
+ columnMenu={madeInColumnMenu}
61
+ />
62
+ <TableColumn
63
+ field="CategoryID"
64
+ title="Category (async multi-select filter)"
65
+ columnMenu={categoryColumnMenu}
66
+ cell={CategoryCell}
67
+ />
68
+ </Table>
69
+ </Fragment>
70
+ );
71
+ })
72
+ );
73
+
74
+ export const SelectSyncExample: FC = provide({
75
+ singletons: [TableStore],
76
+ })(
77
+ observer(() => {
78
+ const [{ madeInOptions, packageOptions, tableState }] = useDependencies(TableStore);
79
+
80
+ const madeInColumnMenu = useMemo(
81
+ () =>
82
+ selectColumnMenuFilter({
83
+ data: madeInOptions,
84
+ search: {
85
+ placeholder: 'Search for made-ins',
86
+ filter: search => item => item.toLowerCase().includes(search),
87
+ },
88
+ }),
89
+ [madeInOptions]
90
+ );
91
+
92
+ const categoryColumnMenu = useMemo(
93
+ () =>
94
+ selectColumnMenuFilter({
95
+ data: categories,
96
+ multiple: true,
97
+ contentMaxHeight: '250px',
98
+ valueSelector: item => item.CategoryID,
99
+ renderItem: item => item.CategoryName,
100
+ search: true,
101
+ }),
102
+ []
103
+ );
104
+
105
+ const packageColumnMenu = useMemo(
106
+ () =>
107
+ selectColumnMenuFilter({
108
+ data: packageOptions,
109
+ multiple: false,
110
+ valueSelector: item => item.Id,
111
+ renderItem: item => item.Name,
112
+ rowValueSelector: (item: Product['Package']) => item?.PackageId,
113
+ }),
114
+ [packageOptions]
115
+ );
116
+
117
+ return (
118
+ <Fragment>
119
+ <Banner title="Default filter with sync select" className="m-b-2">
120
+ Select filter allows to choose one or multiple option(s) from the provided list.
121
+ You can pass simple options (string or number) or complex objects
122
+ </Banner>
123
+ <Table tableState={tableState} striped={false}>
124
+ <TableColumn field="ProductID" title="ID" editable={false} width="100px" />
125
+ <TableColumn field="ProductName" title="Product Name" width="240px" />
126
+ <TableColumn
127
+ field="MadeIn"
128
+ title="Made In (sync single-select filter)"
129
+ columnMenu={madeInColumnMenu}
130
+ />
131
+ <TableColumn
132
+ field="CategoryID"
133
+ title="Category (sync multi-select filter)"
134
+ columnMenu={categoryColumnMenu}
135
+ cell={CategoryCell}
136
+ />
137
+ <TableColumn
138
+ field="Package"
139
+ title="Package (sync single-select filter)"
140
+ columnMenu={packageColumnMenu}
141
+ cell={PackageCell}
142
+ />
143
+ </Table>
144
+ </Fragment>
145
+ );
146
+ })
147
+ );
@@ -27,10 +27,11 @@ export const SingleSelectDefaultExample: FC = provide({
27
27
  options: categories,
28
28
  renderItem: cat => (
29
29
  <BodyText>
30
- <span className="fw-bold">cat.CategoryName</span> (#{cat.CategoryID})
30
+ <span className="fw-bold">{cat.CategoryName}</span> (#{cat.CategoryID})
31
31
  </BodyText>
32
32
  ),
33
33
  valueSelector: cat => cat.CategoryID,
34
+ contentMaxHeight: '200px',
34
35
  }),
35
36
  []
36
37
  );
@@ -1,8 +1,13 @@
1
1
  import { injectable } from '@servicetitan/react-ioc';
2
2
 
3
- import { InMemoryDataSource, TableState, AsyncSelectFilterDataFetcher } from '../..';
3
+ import {
4
+ InMemoryDataSource,
5
+ TableState,
6
+ AsyncSelectFilterDataFetcher,
7
+ SelectFilterDataFetcher,
8
+ } from '../..';
4
9
  import { products } from '../overview/products';
5
- import { categories } from './categories';
10
+ import { categories, Category } from './categories';
6
11
 
7
12
  @injectable()
8
13
  export class TableStore {
@@ -15,6 +20,22 @@ export class TableStore {
15
20
  return Array.from(new Set(products.map(p => p.MadeIn)));
16
21
  }
17
22
 
23
+ get packageOptions() {
24
+ const map = products.reduce(
25
+ (out, product) => ({
26
+ ...out,
27
+ ...(product.Package
28
+ ? { [product.Package.PackageId]: product.Package.PackageName }
29
+ : {}),
30
+ }),
31
+ {} as Record<number, string>
32
+ );
33
+
34
+ return Object.keys(map)
35
+ .map(Number)
36
+ .map(id => ({ Id: id, Name: map[id] }));
37
+ }
38
+
18
39
  categoryFetcher: AsyncSelectFilterDataFetcher<number> = async opts => {
19
40
  await new Promise(resolve => setTimeout(resolve, 1500));
20
41
 
@@ -39,6 +60,28 @@ export class TableStore {
39
60
  };
40
61
  };
41
62
 
63
+ categoryFetcherClean: SelectFilterDataFetcher<Category> = async opts => {
64
+ await new Promise(resolve => setTimeout(resolve, 1500));
65
+
66
+ const sv = opts.search?.trim().toLowerCase();
67
+
68
+ return {
69
+ data: categories.filter(cat =>
70
+ sv ? cat.CategoryName.toLowerCase().includes(sv) : true
71
+ ),
72
+ };
73
+ };
74
+
75
+ madeInFetcherClean: SelectFilterDataFetcher<string> = async opts => {
76
+ await new Promise(resolve => setTimeout(resolve, 1500));
77
+
78
+ const sv = opts.search?.trim().toLowerCase();
79
+
80
+ return {
81
+ data: this.madeInOptions.filter(opt => (sv ? opt.toLowerCase().includes(sv) : true)),
82
+ };
83
+ };
84
+
42
85
  private getDataSource() {
43
86
  return new InMemoryDataSource(products, row => row.ProductID);
44
87
  }
@@ -0,0 +1 @@
1
+ export * from './table';
@@ -0,0 +1,104 @@
1
+ import { useMemo, FC } from 'react';
2
+
3
+ import { provide, useDependencies } from '@servicetitan/react-ioc';
4
+
5
+ import { observer } from 'mobx-react';
6
+
7
+ import { Tag } from '@servicetitan/design-system';
8
+ import { getEnumKeys } from '@servicetitan/form';
9
+
10
+ import {
11
+ Table,
12
+ TableColumn,
13
+ BooleanEditableCell,
14
+ DateRangeColumnMenuFilter,
15
+ StandardColumnMenuFilter,
16
+ standardFilterWithMultiselect,
17
+ multiSelectColumnMenuFilter,
18
+ CurrencyRangeColumnMenuFilter,
19
+ } from '../..';
20
+
21
+ import { TableStore } from '../overview/table.store';
22
+ import { UserRole } from '../overview/product';
23
+
24
+ const UserRoleColumnMenuFilter = multiSelectColumnMenuFilter(getEnumKeys(UserRole), userRole => (
25
+ <Tag compact color={UserRole[userRole] === UserRole.Owner ? 'success' : 'default'}>
26
+ {userRole}
27
+ </Tag>
28
+ ));
29
+
30
+ export const TableFooterPageSizeExample: FC = provide({
31
+ singletons: [TableStore],
32
+ })(
33
+ observer(() => {
34
+ const [{ tableState }] = useDependencies(TableStore);
35
+
36
+ const madeInColumnMenu = useMemo(
37
+ () => standardFilterWithMultiselect({ tableState }),
38
+ [tableState]
39
+ );
40
+
41
+ return (
42
+ <Table
43
+ tableState={tableState}
44
+ striped={false}
45
+ sortable
46
+ pager={{ pageSizes: [3, 5, 7, 10] }}
47
+ >
48
+ <TableColumn field="ProductID" title="ID" editable={false} width="100px" />
49
+
50
+ <TableColumn
51
+ field="ProductName"
52
+ title="Product Name"
53
+ columnMenu={StandardColumnMenuFilter}
54
+ width="240px"
55
+ />
56
+
57
+ <TableColumn
58
+ field="Supplier"
59
+ title="Supplier"
60
+ columnMenu={StandardColumnMenuFilter}
61
+ width="150px"
62
+ />
63
+
64
+ <TableColumn
65
+ field="MadeIn"
66
+ title="Made In"
67
+ columnMenu={madeInColumnMenu}
68
+ width="175px"
69
+ />
70
+
71
+ <TableColumn
72
+ field="UnitsOnOrder"
73
+ title="First Ordered On"
74
+ columnMenu={DateRangeColumnMenuFilter}
75
+ format="{0:MM/dd/yyyy}"
76
+ width="240px"
77
+ />
78
+
79
+ <TableColumn
80
+ field="UnitPrice"
81
+ title="Unit Price"
82
+ columnMenu={CurrencyRangeColumnMenuFilter}
83
+ format="{0:c}"
84
+ width="125px"
85
+ />
86
+
87
+ <TableColumn
88
+ field="Discontinued"
89
+ title="Discontinued"
90
+ cell={BooleanEditableCell}
91
+ sortable={false}
92
+ width="125px"
93
+ />
94
+
95
+ <TableColumn
96
+ field="AvailableFor"
97
+ title="Available For"
98
+ columnMenu={UserRoleColumnMenuFilter}
99
+ width="240px"
100
+ />
101
+ </Table>
102
+ );
103
+ })
104
+ );
package/src/demo/index.ts CHANGED
@@ -2,3 +2,4 @@ export * from './overview';
2
2
  export * from './master-detail';
3
3
  export * from './state-caching';
4
4
  export * from './column-hiding';
5
+ export * from './footer-page-size';
@@ -13,6 +13,11 @@ export enum Supplier {
13
13
  Benjamin,
14
14
  }
15
15
 
16
+ export interface ProductPackage {
17
+ PackageId: number;
18
+ PackageName: string;
19
+ }
20
+
16
21
  export interface Product {
17
22
  ProductID: number;
18
23
  ProductName: string;
@@ -25,4 +30,5 @@ export interface Product {
25
30
  UnitsOnOrder: Date;
26
31
  Discontinued: boolean;
27
32
  AvailableFor?: UserRole;
33
+ Package?: ProductPackage;
28
34
  }
@@ -13,6 +13,10 @@ export const products: Product[] = [
13
13
  UnitsOnOrder: new Date('1/11/2023'),
14
14
  Discontinued: false,
15
15
  AvailableFor: UserRole.Admin,
16
+ Package: {
17
+ PackageId: 1,
18
+ PackageName: 'Standard package',
19
+ },
16
20
  },
17
21
  {
18
22
  ProductID: 2,
@@ -25,6 +29,10 @@ export const products: Product[] = [
25
29
  UnitsInStock: 17,
26
30
  UnitsOnOrder: new Date('2/11/2023'),
27
31
  Discontinued: false,
32
+ Package: {
33
+ PackageId: 1,
34
+ PackageName: 'Standard package',
35
+ },
28
36
  },
29
37
  {
30
38
  ProductID: 3,
@@ -63,6 +71,10 @@ export const products: Product[] = [
63
71
  UnitsOnOrder: new Date('5/11/2023'),
64
72
  Discontinued: true,
65
73
  AvailableFor: UserRole.GeneralOffice,
74
+ Package: {
75
+ PackageId: 2,
76
+ PackageName: 'Extended package',
77
+ },
66
78
  },
67
79
  {
68
80
  ProductID: 6,
@@ -65,6 +65,7 @@ export class TableStore {
65
65
  ),
66
66
  Discontinued: new FieldState(false),
67
67
  AvailableFor: new FieldState<UserRole | undefined>(undefined),
68
+ Package: new FieldState<Product['Package'] | undefined>(undefined),
68
69
  }),
69
70
  row
70
71
  );