@servicetitan/table 23.3.2 → 24.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/demo/filters/async-select-filter.d.ts +3 -0
- package/dist/demo/filters/async-select-filter.d.ts.map +1 -0
- package/dist/demo/filters/async-select-filter.js +23 -0
- package/dist/demo/filters/async-select-filter.js.map +1 -0
- package/dist/demo/filters/categories.d.ts +9 -0
- package/dist/demo/filters/categories.d.ts.map +1 -0
- package/dist/demo/filters/categories.js +33 -0
- package/dist/demo/filters/categories.js.map +1 -0
- package/dist/demo/filters/single-select-filter.d.ts +3 -0
- package/dist/demo/filters/single-select-filter.d.ts.map +1 -0
- package/dist/demo/filters/single-select-filter.js +20 -0
- package/dist/demo/filters/single-select-filter.js.map +1 -0
- package/dist/demo/filters/table.store.d.ts +9 -0
- package/dist/demo/filters/table.store.d.ts.map +1 -0
- package/dist/demo/filters/table.store.js +73 -0
- package/dist/demo/filters/table.store.js.map +1 -0
- package/dist/filters/async-select/async-select-filter.d.ts +19 -0
- package/dist/filters/async-select/async-select-filter.d.ts.map +1 -0
- package/dist/filters/async-select/async-select-filter.js +168 -0
- package/dist/filters/async-select/async-select-filter.js.map +1 -0
- package/dist/filters/async-select/async-select-filter.stories.d.ts +7 -0
- package/dist/filters/async-select/async-select-filter.stories.d.ts.map +1 -0
- package/dist/filters/async-select/async-select-filter.stories.js +7 -0
- package/dist/filters/async-select/async-select-filter.stories.js.map +1 -0
- package/dist/filters/index.d.ts +2 -0
- package/dist/filters/index.d.ts.map +1 -1
- package/dist/filters/index.js +2 -0
- package/dist/filters/index.js.map +1 -1
- package/dist/filters/single-select/single-select-filter.d.ts +9 -0
- package/dist/filters/single-select/single-select-filter.d.ts.map +1 -0
- package/dist/filters/single-select/single-select-filter.js +30 -0
- package/dist/filters/single-select/single-select-filter.js.map +1 -0
- package/dist/filters/single-select/single-select-filter.stories.d.ts +7 -0
- package/dist/filters/single-select/single-select-filter.stories.d.ts.map +1 -0
- package/dist/filters/single-select/single-select-filter.stories.js +7 -0
- package/dist/filters/single-select/single-select-filter.stories.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/table-state.d.ts +1 -1
- package/dist/table-state.d.ts.map +1 -1
- package/dist/use-observing-table-state/demo/components/use-observing-table-state-demo.d.ts +7 -0
- package/dist/use-observing-table-state/demo/components/use-observing-table-state-demo.d.ts.map +1 -0
- package/dist/use-observing-table-state/demo/components/use-observing-table-state-demo.js +15 -0
- package/dist/use-observing-table-state/demo/components/use-observing-table-state-demo.js.map +1 -0
- package/dist/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.d.ts +15 -0
- package/dist/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.d.ts.map +1 -0
- package/dist/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.js +128 -0
- package/dist/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.js.map +1 -0
- package/dist/use-observing-table-state/index.d.ts +2 -0
- package/dist/use-observing-table-state/index.d.ts.map +1 -0
- package/dist/use-observing-table-state/index.js +2 -0
- package/dist/use-observing-table-state/index.js.map +1 -0
- package/dist/use-observing-table-state/use-observing-table-state.d.ts +13 -0
- package/dist/use-observing-table-state/use-observing-table-state.d.ts.map +1 -0
- package/dist/use-observing-table-state/use-observing-table-state.js +44 -0
- package/dist/use-observing-table-state/use-observing-table-state.js.map +1 -0
- package/dist/use-observing-table-state/use-observing-table-state.stories.d.ts +10 -0
- package/dist/use-observing-table-state/use-observing-table-state.stories.d.ts.map +1 -0
- package/dist/use-observing-table-state/use-observing-table-state.stories.js +11 -0
- package/dist/use-observing-table-state/use-observing-table-state.stories.js.map +1 -0
- package/dist/utils/filters.d.ts +4 -0
- package/dist/utils/filters.d.ts.map +1 -0
- package/dist/utils/filters.js +22 -0
- package/dist/utils/filters.js.map +1 -0
- package/package.json +7 -6
- package/src/demo/filters/async-select-filter.tsx +53 -0
- package/src/demo/filters/categories.tsx +40 -0
- package/src/demo/filters/single-select-filter.tsx +51 -0
- package/src/demo/filters/table.store.ts +45 -0
- package/src/filters/async-select/async-select-filter.stories.tsx +7 -0
- package/src/filters/async-select/async-select-filter.tsx +249 -0
- package/src/filters/index.ts +2 -0
- package/src/filters/single-select/single-select-filter.stories.tsx +7 -0
- package/src/filters/single-select/single-select-filter.tsx +66 -0
- package/src/index.ts +2 -0
- package/src/table-state.ts +1 -1
- package/src/use-observing-table-state/demo/components/use-observing-table-state-demo.tsx +82 -0
- package/src/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.ts +69 -0
- package/src/use-observing-table-state/index.ts +1 -0
- package/src/use-observing-table-state/use-observing-table-state.stories.tsx +20 -0
- package/src/use-observing-table-state/use-observing-table-state.ts +69 -0
- package/src/utils/__tests__/filters.test.ts +31 -0
- package/src/utils/filters.ts +33 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"table-state.d.ts","sourceRoot":"","sources":["../src/table-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAGrC,OAAO,EACH,mBAAmB,EACnB,yBAAyB,EACzB,eAAe,EACf,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACH,WAAW,EACX,eAAe,EACf,sBAAsB,EACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGlD,oBAAY,UAAU,CAAC,CAAC,IAAI;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAA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KP;IAEF,WAAW,UACA,GAAG,EAAE,GAAG,eAAe,GAAG,eAAe,YACtC,sBAAsB,EAAE,GAAG,aAAa,sBAAsB,CAAC,EAAE,mBAQ7E;IAEF,6BAA6B,+BAS3B;IAEF,cAAc,UAAW,WAAW,CAAC,CAAC,OAAO,WAAW,CAAC,CAAC,qBA6BxD;IAEF,WAAW,IAAI,eAAe,CAAC,GAAG,CAAC;IAcnC,WAAW,CAAC,IAAI,EAAE,eAAe,CAAC,GAAG,CAAC;CAUzC"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { FC } from 'react';
|
2
|
+
import { ResetPaginationMode } from '../../../';
|
3
|
+
export interface TableUseTableStateExampleProps {
|
4
|
+
resetPaginationMode: ResetPaginationMode;
|
5
|
+
}
|
6
|
+
export declare const TableUseTableStateExample: FC<TableUseTableStateExampleProps>;
|
7
|
+
//# sourceMappingURL=use-observing-table-state-demo.d.ts.map
|
package/dist/use-observing-table-state/demo/components/use-observing-table-state-demo.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-observing-table-state-demo.d.ts","sourceRoot":"","sources":["../../../../src/use-observing-table-state/demo/components/use-observing-table-state-demo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAKrC,OAAO,EAAS,mBAAmB,EAA0B,MAAM,WAAW,CAAC;AAI/E,MAAM,WAAW,8BAA8B;IAC3C,mBAAmB,EAAE,mBAAmB,CAAC;CAC5C;AACD,eAAO,MAAM,yBAAyB,EAAE,EAAE,CAAC,8BAA8B,CAqExE,CAAC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { Fragment } from 'react';
|
3
|
+
import { observer } from 'mobx-react';
|
4
|
+
import { provide, useDependencies } from '@servicetitan/react-ioc';
|
5
|
+
import { BodyText, Button, TableColumn } from '@servicetitan/design-system';
|
6
|
+
import { Table, useObservingTableState } from '../../../';
|
7
|
+
import { UseObservingTableStateDemoStore } from '../stores/use-observing-table-state-demo.store';
|
8
|
+
export const TableUseTableStateExample = provide({
|
9
|
+
singletons: [UseObservingTableStateDemoStore],
|
10
|
+
})(observer(({ resetPaginationMode }) => {
|
11
|
+
const [{ data, updateDataKeepRoot, updateDataChangeRoot, add5RowsWithKeepDataRoot, remove5RowsWithKeepDataRoot, add5RowsWithUpdateDataRoot, remove5RowsWithUpdateDataRoot, },] = useDependencies(UseObservingTableStateDemoStore);
|
12
|
+
const tableState = useObservingTableState(data, { pageSize: 5 }, { idSelector: p => p.ProductID }, resetPaginationMode);
|
13
|
+
return (_jsxs(Fragment, { children: [_jsxs("table", Object.assign({ className: "m-b-2", cellPadding: 4 }, { children: [_jsxs("tr", { children: [_jsx("td", { children: _jsx(BodyText, { children: "Keep data root:" }) }), _jsx("td", { children: _jsx(Button, Object.assign({ onClick: updateDataKeepRoot }, { children: "Update prices" })) }), _jsx("td", { children: _jsx(Button, Object.assign({ onClick: add5RowsWithKeepDataRoot }, { children: "Add 5 rows" })) }), _jsx("td", { children: _jsx(Button, Object.assign({ onClick: remove5RowsWithKeepDataRoot }, { children: "Remove 5 rows" })) })] }), _jsxs("tr", { children: [_jsx("td", { children: _jsx(BodyText, { children: "Update data root:" }) }), _jsx("td", { children: _jsx(Button, Object.assign({ onClick: updateDataChangeRoot }, { children: "Update prices" })) }), _jsx("td", { children: _jsx(Button, Object.assign({ onClick: add5RowsWithUpdateDataRoot }, { children: "Add 5 rows" })) }), _jsx("td", { children: _jsx(Button, Object.assign({ onClick: remove5RowsWithUpdateDataRoot }, { children: "Remove 5 rows" })) })] })] })), _jsxs(Table, Object.assign({ tableState: tableState, sortable: true, groupable: true }, { children: [_jsx(TableColumn, { field: "ProductID", title: "ID", width: "100px" }), _jsx(TableColumn, { field: "ProductName", title: "Product Name" }), _jsx(TableColumn, { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "125px" })] }))] }));
|
14
|
+
}));
|
15
|
+
//# sourceMappingURL=use-observing-table-state-demo.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-observing-table-state-demo.js","sourceRoot":"","sources":["../../../../src/use-observing-table-state/demo/components/use-observing-table-state-demo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE5E,OAAO,EAAE,KAAK,EAAuB,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,+BAA+B,EAAE,MAAM,gDAAgD,CAAC;AAMjG,MAAM,CAAC,MAAM,yBAAyB,GAAuC,OAAO,CAAC;IACjF,UAAU,EAAE,CAAC,+BAA+B,CAAC;CAChD,CAAC,CACE,QAAQ,CAAC,CAAC,EAAE,mBAAmB,EAAE,EAAE,EAAE;IACjC,MAAM,CACF,EACI,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC1B,6BAA6B,GAChC,EACJ,GAAG,eAAe,CAAC,+BAA+B,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,sBAAsB,CACrC,IAAI,EACJ,EAAE,QAAQ,EAAE,CAAC,EAAE,EACf,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,EAChC,mBAAmB,CACtB,CAAC;IAEF,OAAO,CACH,MAAC,QAAQ,eACL,+BAAO,SAAS,EAAC,OAAO,EAAC,WAAW,EAAE,CAAC,iBACnC,yBACI,uBACI,KAAC,QAAQ,kCAA2B,GACnC,EACL,uBACI,KAAC,MAAM,kBAAC,OAAO,EAAE,kBAAkB,mCAAwB,GAC1D,EACL,uBACI,KAAC,MAAM,kBAAC,OAAO,EAAE,wBAAwB,gCAAqB,GAC7D,EACL,uBACI,KAAC,MAAM,kBAAC,OAAO,EAAE,2BAA2B,mCAAwB,GACnE,IACJ,EACL,yBACI,uBACI,KAAC,QAAQ,oCAA6B,GACrC,EACL,uBACI,KAAC,MAAM,kBAAC,OAAO,EAAE,oBAAoB,mCAAwB,GAC5D,EACL,uBACI,KAAC,MAAM,kBAAC,OAAO,EAAE,0BAA0B,gCAAqB,GAC/D,EACL,uBACI,KAAC,MAAM,kBAAC,OAAO,EAAE,6BAA6B,mCAAwB,GACrE,IACJ,KACD,EACR,MAAC,KAAK,kBAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,QAAC,SAAS,uBAC7C,KAAC,WAAW,IAAC,KAAK,EAAC,WAAW,EAAC,KAAK,EAAC,IAAI,EAAC,KAAK,EAAC,OAAO,GAAG,EAE1D,KAAC,WAAW,IAAC,KAAK,EAAC,aAAa,EAAC,KAAK,EAAC,cAAc,GAAG,EAExD,KAAC,WAAW,IACR,KAAK,EAAC,WAAW,EACjB,KAAK,EAAC,YAAY,EAClB,MAAM,EAAC,OAAO,EACd,KAAK,EAAC,OAAO,GACf,KACE,IACD,CACd,CAAC;AACN,CAAC,CAAC,CACL,CAAC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export declare class UseObservingTableStateDemoStore {
|
2
|
+
data: {
|
3
|
+
ProductID: number;
|
4
|
+
ProductName: string;
|
5
|
+
UnitPrice: number;
|
6
|
+
}[];
|
7
|
+
constructor();
|
8
|
+
updateDataKeepRoot: () => void;
|
9
|
+
updateDataChangeRoot: () => void;
|
10
|
+
add5RowsWithUpdateDataRoot: () => void;
|
11
|
+
remove5RowsWithUpdateDataRoot: () => void;
|
12
|
+
add5RowsWithKeepDataRoot: () => void;
|
13
|
+
remove5RowsWithKeepDataRoot: () => void;
|
14
|
+
}
|
15
|
+
//# sourceMappingURL=use-observing-table-state-demo.store.d.ts.map
|
package/dist/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-observing-table-state-demo.store.d.ts","sourceRoot":"","sources":["../../../../src/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.ts"],"names":[],"mappings":"AAOA,qBACa,+BAA+B;IAC5B,IAAI;;;;QAIZ;;IAOJ,kBAAkB,aAEhB;IAGF,oBAAoB,aAKlB;IAGF,0BAA0B,aASxB;IAEF,6BAA6B,aAI3B;IAGF,wBAAwB,aAStB;IAGF,2BAA2B,aAIzB;CACL"}
|
@@ -0,0 +1,128 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { injectable } from '@servicetitan/react-ioc';
|
11
|
+
import { action, makeObservable, observable } from 'mobx';
|
12
|
+
import { products } from '../../../demo/overview/products';
|
13
|
+
const getRandomPrice = () => Math.round(Math.random() * 10000) / 100;
|
14
|
+
let UseObservingTableStateDemoStore = class UseObservingTableStateDemoStore {
|
15
|
+
constructor() {
|
16
|
+
Object.defineProperty(this, "data", {
|
17
|
+
enumerable: true,
|
18
|
+
configurable: true,
|
19
|
+
writable: true,
|
20
|
+
value: products.map(p => ({
|
21
|
+
ProductID: p.ProductID,
|
22
|
+
ProductName: p.ProductName,
|
23
|
+
UnitPrice: p.UnitPrice,
|
24
|
+
}))
|
25
|
+
});
|
26
|
+
Object.defineProperty(this, "updateDataKeepRoot", {
|
27
|
+
enumerable: true,
|
28
|
+
configurable: true,
|
29
|
+
writable: true,
|
30
|
+
value: () => {
|
31
|
+
this.data.forEach(p => (p.UnitPrice = getRandomPrice()));
|
32
|
+
}
|
33
|
+
});
|
34
|
+
Object.defineProperty(this, "updateDataChangeRoot", {
|
35
|
+
enumerable: true,
|
36
|
+
configurable: true,
|
37
|
+
writable: true,
|
38
|
+
value: () => {
|
39
|
+
this.data = this.data.map(p => (Object.assign(Object.assign({}, p), { UnitPrice: getRandomPrice() })));
|
40
|
+
}
|
41
|
+
});
|
42
|
+
Object.defineProperty(this, "add5RowsWithUpdateDataRoot", {
|
43
|
+
enumerable: true,
|
44
|
+
configurable: true,
|
45
|
+
writable: true,
|
46
|
+
value: () => {
|
47
|
+
this.data = [
|
48
|
+
...this.data,
|
49
|
+
...Array.from({ length: 5 }).map((v, i) => ({
|
50
|
+
ProductID: this.data.length + i + 1,
|
51
|
+
ProductName: `Product ${this.data.length + i + 1}`,
|
52
|
+
UnitPrice: getRandomPrice(),
|
53
|
+
})),
|
54
|
+
];
|
55
|
+
}
|
56
|
+
});
|
57
|
+
Object.defineProperty(this, "remove5RowsWithUpdateDataRoot", {
|
58
|
+
enumerable: true,
|
59
|
+
configurable: true,
|
60
|
+
writable: true,
|
61
|
+
value: () => {
|
62
|
+
if (this.data.length >= 5) {
|
63
|
+
this.data = this.data.slice(0, this.data.length - 5);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
});
|
67
|
+
Object.defineProperty(this, "add5RowsWithKeepDataRoot", {
|
68
|
+
enumerable: true,
|
69
|
+
configurable: true,
|
70
|
+
writable: true,
|
71
|
+
value: () => {
|
72
|
+
const length = this.data.length;
|
73
|
+
for (let i = this.data.length; i < length + 5; ++i) {
|
74
|
+
this.data.push({
|
75
|
+
ProductID: i,
|
76
|
+
ProductName: `Product ${i}`,
|
77
|
+
UnitPrice: getRandomPrice(),
|
78
|
+
});
|
79
|
+
}
|
80
|
+
}
|
81
|
+
});
|
82
|
+
Object.defineProperty(this, "remove5RowsWithKeepDataRoot", {
|
83
|
+
enumerable: true,
|
84
|
+
configurable: true,
|
85
|
+
writable: true,
|
86
|
+
value: () => {
|
87
|
+
if (this.data.length >= 5) {
|
88
|
+
this.data.splice(this.data.length - 5, 5);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
});
|
92
|
+
makeObservable(this);
|
93
|
+
}
|
94
|
+
};
|
95
|
+
__decorate([
|
96
|
+
observable,
|
97
|
+
__metadata("design:type", Object)
|
98
|
+
], UseObservingTableStateDemoStore.prototype, "data", void 0);
|
99
|
+
__decorate([
|
100
|
+
action,
|
101
|
+
__metadata("design:type", Object)
|
102
|
+
], UseObservingTableStateDemoStore.prototype, "updateDataKeepRoot", void 0);
|
103
|
+
__decorate([
|
104
|
+
action,
|
105
|
+
__metadata("design:type", Object)
|
106
|
+
], UseObservingTableStateDemoStore.prototype, "updateDataChangeRoot", void 0);
|
107
|
+
__decorate([
|
108
|
+
action,
|
109
|
+
__metadata("design:type", Object)
|
110
|
+
], UseObservingTableStateDemoStore.prototype, "add5RowsWithUpdateDataRoot", void 0);
|
111
|
+
__decorate([
|
112
|
+
action,
|
113
|
+
__metadata("design:type", Object)
|
114
|
+
], UseObservingTableStateDemoStore.prototype, "remove5RowsWithUpdateDataRoot", void 0);
|
115
|
+
__decorate([
|
116
|
+
action,
|
117
|
+
__metadata("design:type", Object)
|
118
|
+
], UseObservingTableStateDemoStore.prototype, "add5RowsWithKeepDataRoot", void 0);
|
119
|
+
__decorate([
|
120
|
+
action,
|
121
|
+
__metadata("design:type", Object)
|
122
|
+
], UseObservingTableStateDemoStore.prototype, "remove5RowsWithKeepDataRoot", void 0);
|
123
|
+
UseObservingTableStateDemoStore = __decorate([
|
124
|
+
injectable(),
|
125
|
+
__metadata("design:paramtypes", [])
|
126
|
+
], UseObservingTableStateDemoStore);
|
127
|
+
export { UseObservingTableStateDemoStore };
|
128
|
+
//# sourceMappingURL=use-observing-table-state-demo.store.js.map
|
package/dist/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-observing-table-state-demo.store.js","sourceRoot":"","sources":["../../../../src/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC;AAGrE,IAAa,+BAA+B,GAA5C,MAAa,+BAA+B;IAOxC;QANY;;;;mBAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAClC,SAAS,EAAE,CAAC,CAAC,SAAS;gBACtB,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,SAAS,EAAE,CAAC,CAAC,SAAS;aACzB,CAAC,CAAC;WAAC;QAOJ;;;;mBAAqB,GAAG,EAAE;gBACtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC;YAC7D,CAAC;WAAC;QAGF;;;;mBAAuB,GAAG,EAAE;gBACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,iCACxB,CAAC,KACJ,SAAS,EAAE,cAAc,EAAE,IAC7B,CAAC,CAAC;YACR,CAAC;WAAC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I,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;iBAC7C;YACL,CAAC;WAAC;QAnDE,cAAc,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CAmDJ,CAAA;AA3De;IAAX,UAAU;;6DAIP;AAOJ;IADC,MAAM;;2EAGL;AAGF;IADC,MAAM;;6EAML;AAGF;IADC,MAAM;;mFAUL;AAEF;IADC,MAAM;;sFAKL;AAGF;IADC,MAAM;;iFAUL;AAGF;IADC,MAAM;;oFAKL;AA3DO,+BAA+B;IAD3C,UAAU,EAAE;;GACA,+BAA+B,CA4D3C;SA5DY,+BAA+B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/use-observing-table-state/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/use-observing-table-state/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { IdType, Preprocessors } from '@servicetitan/data-query';
|
2
|
+
import { TableState, TableStateConstructorParams } from '../table-state';
|
3
|
+
export declare enum ResetPaginationMode {
|
4
|
+
Never = 0,
|
5
|
+
OnUpdateDataRoot = 1,
|
6
|
+
Always = 2
|
7
|
+
}
|
8
|
+
export interface DatasourceOptions<T, TID extends IdType = any> {
|
9
|
+
idSelector: (row: T) => TID;
|
10
|
+
datasourcePreprocessors?: Preprocessors<T>;
|
11
|
+
}
|
12
|
+
export declare const useObservingTableState: <T, TID extends IdType = any, P = never, PID extends IdType = never>(data: T[], tableArgs: TableStateConstructorParams<T, TID, P, PID>, datasourceOptions: DatasourceOptions<T, TID>, resetPagination?: ResetPaginationMode) => TableState<T, TID, P, PID>;
|
13
|
+
//# sourceMappingURL=use-observing-table-state.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-observing-table-state.d.ts","sourceRoot":"","sources":["../../src/use-observing-table-state/use-observing-table-state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAsB,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAErF,OAAO,EAAE,UAAU,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAGzE,oBAAY,mBAAmB;IAC3B,KAAK,IAAA;IACL,gBAAgB,IAAA;IAChB,MAAM,IAAA;CACT;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,EAAE,GAAG,SAAS,MAAM,GAAG,GAAG;IAC1D,UAAU,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC;IAC5B,uBAAuB,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;CAC9C;AAED,eAAO,MAAM,sBAAsB,0MASd,mBAAmB,+BAwCvC,CAAC"}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
2
|
+
import { autorun } from 'mobx';
|
3
|
+
import { InMemoryDataSource } from '@servicetitan/data-query';
|
4
|
+
import { useInitializedRef } from '@servicetitan/react-hooks';
|
5
|
+
import { TableState } from '../table-state';
|
6
|
+
//
|
7
|
+
export var ResetPaginationMode;
|
8
|
+
(function (ResetPaginationMode) {
|
9
|
+
ResetPaginationMode[ResetPaginationMode["Never"] = 0] = "Never";
|
10
|
+
ResetPaginationMode[ResetPaginationMode["OnUpdateDataRoot"] = 1] = "OnUpdateDataRoot";
|
11
|
+
ResetPaginationMode[ResetPaginationMode["Always"] = 2] = "Always";
|
12
|
+
})(ResetPaginationMode || (ResetPaginationMode = {}));
|
13
|
+
export const useObservingTableState = (data, tableArgs, datasourceOptions, resetPagination = ResetPaginationMode.OnUpdateDataRoot) => {
|
14
|
+
const tableStateRef = useInitializedRef(() => new TableState(tableArgs));
|
15
|
+
const datasourceDataRef = useRef();
|
16
|
+
const tableStateDataRef = useRef();
|
17
|
+
const [dataSource, setDataSource] = useState();
|
18
|
+
useEffect(() => {
|
19
|
+
const disposer = autorun(() => {
|
20
|
+
setDataSource(new InMemoryDataSource(data, datasourceOptions.idSelector, datasourceOptions.datasourcePreprocessors));
|
21
|
+
datasourceDataRef.current = data;
|
22
|
+
});
|
23
|
+
return () => disposer();
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
25
|
+
}, [data]);
|
26
|
+
useEffect(() => {
|
27
|
+
var _a, _b;
|
28
|
+
if (dataSource) {
|
29
|
+
if (tableStateRef.current.skip >= ((_b = (_a = datasourceDataRef.current) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) ||
|
30
|
+
resetPagination === ResetPaginationMode.Always ||
|
31
|
+
(resetPagination === ResetPaginationMode.OnUpdateDataRoot &&
|
32
|
+
tableStateDataRef.current !== datasourceDataRef.current)) {
|
33
|
+
tableStateRef.current.setDataSource(dataSource);
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
const state = tableStateRef.current.exportState();
|
37
|
+
tableStateRef.current.setDataSource(dataSource, { initialState: state });
|
38
|
+
}
|
39
|
+
tableStateDataRef.current = datasourceDataRef.current;
|
40
|
+
}
|
41
|
+
}, [dataSource, resetPagination, tableStateRef]);
|
42
|
+
return tableStateRef.current;
|
43
|
+
};
|
44
|
+
//# sourceMappingURL=use-observing-table-state.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-observing-table-state.js","sourceRoot":"","sources":["../../src/use-observing-table-state/use-observing-table-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAU,kBAAkB,EAAiB,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE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;oBACrD,iBAAiB,CAAC,OAAO,KAAK,iBAAiB,CAAC,OAAO,CAAC,EAC9D;gBACE,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;aACnD;iBAAM;gBACH,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;gBAClD,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;aAC5E;YACD,iBAAiB,CAAC,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;SACzD;IACL,CAAC,EAAE,CAAC,UAAU,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC;IAEjD,OAAO,aAAa,CAAC,OAAO,CAAC;AACjC,CAAC,CAAC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { FC } from 'react';
|
2
|
+
declare const _default: {
|
3
|
+
title: string;
|
4
|
+
parameters: {};
|
5
|
+
};
|
6
|
+
export default _default;
|
7
|
+
export declare const ResetPaginationOnUpdateDataRoot: FC;
|
8
|
+
export declare const ResetPaginationNever: FC;
|
9
|
+
export declare const ResetPaginationAlways: FC;
|
10
|
+
//# sourceMappingURL=use-observing-table-state.stories.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-observing-table-state.stories.d.ts","sourceRoot":"","sources":["../../src/use-observing-table-state/use-observing-table-state.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;;;;;AAI3B,wBAGE;AAEF,eAAO,MAAM,+BAA+B,EAAE,EAE7C,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,EAElC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,EAEnC,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { TableUseTableStateExample } from './demo/components/use-observing-table-state-demo';
|
3
|
+
import { ResetPaginationMode } from './';
|
4
|
+
export default {
|
5
|
+
title: 'Table/UseObservingTableState',
|
6
|
+
parameters: {},
|
7
|
+
};
|
8
|
+
export const ResetPaginationOnUpdateDataRoot = () => (_jsx(TableUseTableStateExample, { resetPaginationMode: ResetPaginationMode.OnUpdateDataRoot }));
|
9
|
+
export const ResetPaginationNever = () => (_jsx(TableUseTableStateExample, { resetPaginationMode: ResetPaginationMode.Never }));
|
10
|
+
export const ResetPaginationAlways = () => (_jsx(TableUseTableStateExample, { resetPaginationMode: ResetPaginationMode.Always }));
|
11
|
+
//# sourceMappingURL=use-observing-table-state.stories.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"use-observing-table-state.stories.js","sourceRoot":"","sources":["../../src/use-observing-table-state/use-observing-table-state.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAEzC,eAAe;IACX,KAAK,EAAE,8BAA8B;IACrC,UAAU,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAO,GAAG,EAAE,CAAC,CACrD,KAAC,yBAAyB,IAAC,mBAAmB,EAAE,mBAAmB,CAAC,gBAAgB,GAAI,CAC3F,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAO,GAAG,EAAE,CAAC,CAC1C,KAAC,yBAAyB,IAAC,mBAAmB,EAAE,mBAAmB,CAAC,KAAK,GAAI,CAChF,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAO,GAAG,EAAE,CAAC,CAC3C,KAAC,yBAAyB,IAAC,mBAAmB,EAAE,mBAAmB,CAAC,MAAM,GAAI,CACjF,CAAC"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { FilterDescriptor, State } from '@servicetitan/data-query';
|
2
|
+
export declare const getFiltersFlat: (filter: State['filter']) => FilterDescriptor[];
|
3
|
+
export declare const getFiltersMap: (filter: State['filter']) => Record<string, FilterDescriptor>;
|
4
|
+
//# sourceMappingURL=filters.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/utils/filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,gBAAgB,EAEhB,KAAK,EACR,MAAM,0BAA0B,CAAC;AAgBlC,eAAO,MAAM,cAAc,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,gBAAgB,EAExE,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,OAAO,MAAM,EAAE,gBAAgB,CAOtF,CAAC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { isCompositeFilterDescriptor, } from '@servicetitan/data-query';
|
2
|
+
const getFiltersFlatInner = (filter) => {
|
3
|
+
if (!filter) {
|
4
|
+
return [];
|
5
|
+
}
|
6
|
+
else if (isCompositeFilterDescriptor(filter)) {
|
7
|
+
return filter.filters.reduce((out, item) => [...out, ...getFiltersFlatInner(item)], []);
|
8
|
+
}
|
9
|
+
return [filter];
|
10
|
+
};
|
11
|
+
export const getFiltersFlat = (filter) => {
|
12
|
+
return getFiltersFlatInner(filter);
|
13
|
+
};
|
14
|
+
export const getFiltersMap = (filter) => {
|
15
|
+
return getFiltersFlatInner(filter).reduce((out, filter) => {
|
16
|
+
if (typeof filter.field === 'string') {
|
17
|
+
out[filter.field] = filter;
|
18
|
+
}
|
19
|
+
return out;
|
20
|
+
}, {});
|
21
|
+
};
|
22
|
+
//# sourceMappingURL=filters.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/utils/filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,2BAA2B,GAE9B,MAAM,0BAA0B,CAAC;AAElC,MAAM,mBAAmB,GAAG,CACxB,MAAqD,EACnC,EAAE;IACpB,IAAI,CAAC,MAAM,EAAE;QACT,OAAO,EAAE,CAAC;KACb;SAAM,IAAI,2BAA2B,CAAC,MAAM,CAAC,EAAE;QAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CACxB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,EACrD,EAAwB,CAC3B,CAAC;KACL;IACD,OAAO,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAuB,EAAsB,EAAE;IAC1E,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAuB,EAAoC,EAAE;IACvF,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACtD,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE;YAClC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;SAC9B;QACD,OAAO,GAAG,CAAC;IACf,CAAC,EAAE,EAAsC,CAAC,CAAC;AAC/C,CAAC,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@servicetitan/table",
|
3
|
-
"version": "
|
3
|
+
"version": "24.0.0",
|
4
4
|
"description": "",
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/table",
|
6
6
|
"repository": {
|
@@ -32,13 +32,14 @@
|
|
32
32
|
"@progress/kendo-react-pdf": "^5.5.0",
|
33
33
|
"@progress/kendo-react-popup": "^5.5.0",
|
34
34
|
"@progress/kendo-react-treeview": "^5.5.0",
|
35
|
+
"@servicetitan/react-hooks": "^2.9.0",
|
35
36
|
"classnames": "~2.3.1",
|
36
37
|
"memoize-one": "~6.0.0"
|
37
38
|
},
|
38
39
|
"devDependencies": {
|
39
|
-
"@servicetitan/data-query": "^
|
40
|
+
"@servicetitan/data-query": "^24.0.0",
|
40
41
|
"@servicetitan/design-system": ">=12.4.1",
|
41
|
-
"@servicetitan/form": "^
|
42
|
+
"@servicetitan/form": "^24.0.0",
|
42
43
|
"@servicetitan/react-ioc": "^21.6.0",
|
43
44
|
"@servicetitan/suppress-warnings": "^21.6.0",
|
44
45
|
"@types/accounting": "~0.4.2",
|
@@ -52,9 +53,9 @@
|
|
52
53
|
"react": "~17.0.2"
|
53
54
|
},
|
54
55
|
"peerDependencies": {
|
55
|
-
"@servicetitan/data-query": "^
|
56
|
+
"@servicetitan/data-query": "^24.0.0",
|
56
57
|
"@servicetitan/design-system": ">=12.4.1",
|
57
|
-
"@servicetitan/form": "^
|
58
|
+
"@servicetitan/form": "^24.0.0",
|
58
59
|
"@servicetitan/react-ioc": ">21.0.0",
|
59
60
|
"@servicetitan/suppress-warnings": ">21.0.0",
|
60
61
|
"accounting": "~0.4.1",
|
@@ -71,5 +72,5 @@
|
|
71
72
|
"cli": {
|
72
73
|
"webpack": false
|
73
74
|
},
|
74
|
-
"gitHead": "
|
75
|
+
"gitHead": "136cde3c32f5798d1c73dd456b16bd691d0cf257"
|
75
76
|
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { useMemo, FC } from 'react';
|
2
|
+
import { observer } from 'mobx-react';
|
3
|
+
import { provide, useDependencies } from '@servicetitan/react-ioc';
|
4
|
+
|
5
|
+
import { Table, TableColumn, asyncSelectColumnMenuFilter } from '../..';
|
6
|
+
|
7
|
+
import { TableStore } from './table.store';
|
8
|
+
import { CategoryCell } from './categories';
|
9
|
+
|
10
|
+
export const TableExample: FC = provide({
|
11
|
+
singletons: [TableStore],
|
12
|
+
})(
|
13
|
+
observer(() => {
|
14
|
+
const [{ categoryFetcher, madeInFetcher, tableState }] = useDependencies(TableStore);
|
15
|
+
|
16
|
+
const madeInColumnMenu = useMemo(
|
17
|
+
() =>
|
18
|
+
asyncSelectColumnMenuFilter({
|
19
|
+
dataFetcher: madeInFetcher,
|
20
|
+
placeholder: 'Search for made-ins',
|
21
|
+
}),
|
22
|
+
[madeInFetcher]
|
23
|
+
);
|
24
|
+
|
25
|
+
const categoryColumnMenu = useMemo(
|
26
|
+
() =>
|
27
|
+
asyncSelectColumnMenuFilter({
|
28
|
+
dataFetcher: categoryFetcher,
|
29
|
+
placeholder: 'Search for Categories',
|
30
|
+
multiple: true,
|
31
|
+
}),
|
32
|
+
[categoryFetcher]
|
33
|
+
);
|
34
|
+
|
35
|
+
return (
|
36
|
+
<Table tableState={tableState} striped={false}>
|
37
|
+
<TableColumn field="ProductID" title="ID" editable={false} width="100px" />
|
38
|
+
<TableColumn field="ProductName" title="Product Name" width="240px" />
|
39
|
+
<TableColumn
|
40
|
+
field="MadeIn"
|
41
|
+
title="Made In (async single-select filter)"
|
42
|
+
columnMenu={madeInColumnMenu}
|
43
|
+
/>
|
44
|
+
<TableColumn
|
45
|
+
field="CategoryID"
|
46
|
+
title="Category (async multi-select filter)"
|
47
|
+
columnMenu={categoryColumnMenu}
|
48
|
+
cell={CategoryCell}
|
49
|
+
/>
|
50
|
+
</Table>
|
51
|
+
);
|
52
|
+
})
|
53
|
+
);
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { FC } from 'react';
|
2
|
+
import { TableCellProps } from '../../table';
|
3
|
+
|
4
|
+
export interface Category {
|
5
|
+
CategoryID: number;
|
6
|
+
CategoryName: string;
|
7
|
+
}
|
8
|
+
|
9
|
+
export const categories: Category[] = [
|
10
|
+
{
|
11
|
+
CategoryID: 1,
|
12
|
+
CategoryName: 'Wok',
|
13
|
+
},
|
14
|
+
{
|
15
|
+
CategoryID: 2,
|
16
|
+
CategoryName: 'Sushi',
|
17
|
+
},
|
18
|
+
{
|
19
|
+
CategoryID: 6,
|
20
|
+
CategoryName: 'Gunkan',
|
21
|
+
},
|
22
|
+
{
|
23
|
+
CategoryID: 7,
|
24
|
+
CategoryName: 'Miso',
|
25
|
+
},
|
26
|
+
{
|
27
|
+
CategoryID: 8,
|
28
|
+
CategoryName: 'Roll',
|
29
|
+
},
|
30
|
+
{
|
31
|
+
CategoryID: 10,
|
32
|
+
CategoryName: 'Sashimi',
|
33
|
+
},
|
34
|
+
];
|
35
|
+
|
36
|
+
export const CategoryCell: FC<TableCellProps> = props => {
|
37
|
+
const { field, dataItem } = props;
|
38
|
+
|
39
|
+
return <td>{categories.find(c => c.CategoryID === dataItem[field!])?.CategoryName}</td>;
|
40
|
+
};
|
@@ -0,0 +1,51 @@
|
|
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 { Table, TableColumn, singleSelectColumnMenuFilter } from '../..';
|
8
|
+
|
9
|
+
import { TableStore } from './table.store';
|
10
|
+
import { categories, CategoryCell } from './categories';
|
11
|
+
|
12
|
+
export const TableExample: FC = provide({
|
13
|
+
singletons: [TableStore],
|
14
|
+
})(
|
15
|
+
observer(() => {
|
16
|
+
const [{ tableState, madeInOptions }] = useDependencies(TableStore);
|
17
|
+
|
18
|
+
const madeInColumnMenu = useMemo(
|
19
|
+
() => singleSelectColumnMenuFilter({ options: madeInOptions }),
|
20
|
+
[madeInOptions]
|
21
|
+
);
|
22
|
+
|
23
|
+
const categoryColumnMenu = useMemo(
|
24
|
+
() =>
|
25
|
+
singleSelectColumnMenuFilter({
|
26
|
+
options: categories,
|
27
|
+
renderItem: cat => cat.CategoryName,
|
28
|
+
valueSelector: cat => cat.CategoryID,
|
29
|
+
}),
|
30
|
+
[]
|
31
|
+
);
|
32
|
+
|
33
|
+
return (
|
34
|
+
<Table tableState={tableState} striped={false}>
|
35
|
+
<TableColumn field="ProductID" title="ID" editable={false} width="100px" />
|
36
|
+
<TableColumn field="ProductName" title="Product Name" width="240px" />
|
37
|
+
<TableColumn
|
38
|
+
field="MadeIn"
|
39
|
+
title="Made In (simple single-select filter)"
|
40
|
+
columnMenu={madeInColumnMenu}
|
41
|
+
/>
|
42
|
+
<TableColumn
|
43
|
+
field="CategoryID"
|
44
|
+
title="Category (simple single-select filter)"
|
45
|
+
columnMenu={categoryColumnMenu}
|
46
|
+
cell={CategoryCell}
|
47
|
+
/>
|
48
|
+
</Table>
|
49
|
+
);
|
50
|
+
})
|
51
|
+
);
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { injectable } from '@servicetitan/react-ioc';
|
2
|
+
|
3
|
+
import { InMemoryDataSource, TableState, AsyncSelectFilterDataFetcher } from '../..';
|
4
|
+
import { products } from '../overview/products';
|
5
|
+
import { categories } from './categories';
|
6
|
+
|
7
|
+
@injectable()
|
8
|
+
export class TableStore {
|
9
|
+
tableState = new TableState({
|
10
|
+
dataSource: this.getDataSource(),
|
11
|
+
pageSize: 5,
|
12
|
+
});
|
13
|
+
|
14
|
+
get madeInOptions() {
|
15
|
+
return Array.from(new Set(products.map(p => p.MadeIn)));
|
16
|
+
}
|
17
|
+
|
18
|
+
categoryFetcher: AsyncSelectFilterDataFetcher<number> = async opts => {
|
19
|
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
20
|
+
|
21
|
+
const sv = opts.search?.trim().toLowerCase();
|
22
|
+
|
23
|
+
return {
|
24
|
+
data: categories
|
25
|
+
.filter(cat => (sv ? cat.CategoryName.toLowerCase().includes(sv) : true))
|
26
|
+
.map(cat => ({ value: cat.CategoryID, text: cat.CategoryName })),
|
27
|
+
};
|
28
|
+
};
|
29
|
+
|
30
|
+
madeInFetcher: AsyncSelectFilterDataFetcher<string> = async opts => {
|
31
|
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
32
|
+
|
33
|
+
const sv = opts.search?.trim().toLowerCase();
|
34
|
+
|
35
|
+
return {
|
36
|
+
data: this.madeInOptions
|
37
|
+
.filter(opt => (sv ? opt.toLowerCase().includes(sv) : true))
|
38
|
+
.map(opt => ({ value: opt, text: opt })),
|
39
|
+
};
|
40
|
+
};
|
41
|
+
|
42
|
+
private getDataSource() {
|
43
|
+
return new InMemoryDataSource(products, row => row.ProductID);
|
44
|
+
}
|
45
|
+
}
|