@servicetitan/table 23.4.0 → 24.1.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/multiselect-filter.d.ts +3 -0
- package/dist/demo/filters/multiselect-filter.d.ts.map +1 -0
- package/dist/demo/filters/multiselect-filter.js +14 -0
- package/dist/demo/filters/multiselect-filter.js.map +1 -0
- package/dist/demo/filters/range-filter.d.ts +5 -0
- package/dist/demo/filters/range-filter.d.ts.map +1 -0
- package/dist/demo/filters/range-filter.js +24 -0
- package/dist/demo/filters/range-filter.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/demo/overview/products.js +10 -10
- 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 +3 -1
- package/dist/filters/index.d.ts.map +1 -1
- package/dist/filters/index.js +3 -1
- package/dist/filters/index.js.map +1 -1
- package/dist/filters/multiselect-filter/multiselect-filter.d.ts.map +1 -0
- package/dist/filters/{multiselect-filter.js → multiselect-filter/multiselect-filter.js} +1 -1
- package/dist/filters/multiselect-filter/multiselect-filter.js.map +1 -0
- package/dist/filters/multiselect-filter/multiselect-filter.stories.d.ts +7 -0
- package/dist/filters/multiselect-filter/multiselect-filter.stories.d.ts.map +1 -0
- package/dist/filters/multiselect-filter/multiselect-filter.stories.js +7 -0
- package/dist/filters/multiselect-filter/multiselect-filter.stories.js.map +1 -0
- package/dist/filters/range-filter/range-filter.stories.d.ts +9 -0
- package/dist/filters/range-filter/range-filter.stories.d.ts.map +1 -0
- package/dist/filters/range-filter/range-filter.stories.js +9 -0
- package/dist/filters/range-filter/range-filter.stories.js.map +1 -0
- 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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- 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 +6 -6
- package/src/demo/filters/async-select-filter.tsx +53 -0
- package/src/demo/filters/categories.tsx +40 -0
- package/src/demo/filters/multiselect-filter.tsx +32 -0
- package/src/demo/filters/range-filter.tsx +72 -0
- package/src/demo/filters/single-select-filter.tsx +51 -0
- package/src/demo/filters/table.store.ts +45 -0
- package/src/demo/overview/products.ts +10 -10
- 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 +3 -1
- package/src/filters/multiselect-filter/multiselect-filter.stories.tsx +7 -0
- package/src/filters/{multiselect-filter.tsx → multiselect-filter/multiselect-filter.tsx} +1 -1
- package/src/filters/range-filter/range-filter.stories.tsx +13 -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 +1 -0
- package/src/utils/__tests__/filters.test.ts +31 -0
- package/src/utils/filters.ts +33 -0
- package/dist/filters/multiselect-filter.d.ts.map +0 -1
- package/dist/filters/multiselect-filter.js.map +0 -1
- /package/dist/filters/{multiselect-filter.d.ts → multiselect-filter/multiselect-filter.d.ts} +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qEAAqE,CAAC;AACpF,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qEAAqE,CAAC;AACpF,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yCAAyC,CAAC;AACxD,cAAc,mDAAmD,CAAC;AAClE,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC"}
|
package/dist/filters/index.js
CHANGED
@@ -4,6 +4,8 @@ export * from './standard-filter-with-multiselect/standard-filter-with-multisele
|
|
4
4
|
export * from './time-filter/time-filter';
|
5
5
|
export * from './column-menu-filters';
|
6
6
|
export * from './field-values-filter';
|
7
|
-
export * from './multiselect-filter';
|
7
|
+
export * from './multiselect-filter/multiselect-filter';
|
8
8
|
export * from './numeric-filter-extended/numeric-filter-extended';
|
9
|
+
export * from './single-select/single-select-filter';
|
10
|
+
export * from './async-select/async-select-filter';
|
9
11
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qEAAqE,CAAC;AACpF,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qEAAqE,CAAC;AACpF,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yCAAyC,CAAC;AACxD,cAAc,mDAAmD,CAAC;AAClE,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"multiselect-filter.d.ts","sourceRoot":"","sources":["../../../src/filters/multiselect-filter/multiselect-filter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,SAAS,EAAM,MAAM,OAAO,CAAC;AAuCjE,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,sFAqB5F;AAED,wBAAgB,sCAAsC,CAAC,CAAC,EACpD,IAAI,EAAE,CAAC,EAAE,EACT,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,sFAgCtC;AAED,wBAAgB,oCAAoC,CAAC,CAAC,EAClD,IAAI,EAAE,CAAC,EAAE,EACT,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,sFAgCtC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import { Component } from 'react';
|
3
3
|
import { Checkbox } from '@servicetitan/design-system';
|
4
|
-
import { renderCustomColumnMenuFilter } from '
|
4
|
+
import { renderCustomColumnMenuFilter } from '../column-menu-filters';
|
5
5
|
class Selector extends Component {
|
6
6
|
constructor() {
|
7
7
|
super(...arguments);
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"multiselect-filter.js","sourceRoot":"","sources":["../../../src/filters/multiselect-filter/multiselect-filter.tsx"],"names":[],"mappings":"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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"multiselect-filter.stories.d.ts","sourceRoot":"","sources":["../../../src/filters/multiselect-filter/multiselect-filter.stories.tsx"],"names":[],"mappings":";;;;AAEA,wBAEE;AAEF,eAAO,MAAM,kBAAkB,mBAA+B,CAAC"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { TableExampleSimple } from '../../demo/filters/multiselect-filter';
|
3
|
+
export default {
|
4
|
+
title: 'Table/Filters/MultiSelect',
|
5
|
+
};
|
6
|
+
export const DefaultMultiSelect = () => _jsx(TableExampleSimple, {});
|
7
|
+
//# sourceMappingURL=multiselect-filter.stories.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"multiselect-filter.stories.js","sourceRoot":"","sources":["../../../src/filters/multiselect-filter/multiselect-filter.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAE3E,eAAe;IACX,KAAK,EAAE,2BAA2B;CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,KAAC,kBAAkB,KAAG,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
declare const _default: {
|
3
|
+
title: string;
|
4
|
+
};
|
5
|
+
export default _default;
|
6
|
+
export declare const DateRange: () => JSX.Element;
|
7
|
+
export declare const NumericRange: () => JSX.Element;
|
8
|
+
export declare const CurrencyRange: () => JSX.Element;
|
9
|
+
//# sourceMappingURL=range-filter.stories.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"range-filter.stories.d.ts","sourceRoot":"","sources":["../../../src/filters/range-filter/range-filter.stories.tsx"],"names":[],"mappings":";;;;AAMA,wBAEE;AAEF,eAAO,MAAM,SAAS,mBAA6B,CAAC;AACpD,eAAO,MAAM,YAAY,mBAA+B,CAAC;AACzD,eAAO,MAAM,aAAa,mBAAiC,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { TableExampleCurrency, TableExampleDate, TableExampleNumber, } from '../../demo/filters/range-filter';
|
3
|
+
export default {
|
4
|
+
title: 'Table/Filters/Range',
|
5
|
+
};
|
6
|
+
export const DateRange = () => _jsx(TableExampleDate, {});
|
7
|
+
export const NumericRange = () => _jsx(TableExampleNumber, {});
|
8
|
+
export const CurrencyRange = () => _jsx(TableExampleCurrency, {});
|
9
|
+
//# sourceMappingURL=range-filter.stories.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"range-filter.stories.js","sourceRoot":"","sources":["../../../src/filters/range-filter/range-filter.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EACH,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,GACrB,MAAM,iCAAiC,CAAC;AAEzC,eAAe;IACX,KAAK,EAAE,qBAAqB;CAC/B,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,KAAC,gBAAgB,KAAG,CAAC;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,KAAC,kBAAkB,KAAG,CAAC;AACzD,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,KAAC,oBAAoB,KAAG,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { ReactNode } from 'react';
|
2
|
+
import { IdType } from '@servicetitan/data-query';
|
3
|
+
export interface SingleSelectColumnMenuOptions<TV, TO = TV> {
|
4
|
+
options: TO[];
|
5
|
+
valueSelector?: (item: TO) => TV;
|
6
|
+
renderItem?: (item: TO) => ReactNode | string;
|
7
|
+
}
|
8
|
+
export declare function singleSelectColumnMenuFilter<TV extends IdType, TO = TV>(props: SingleSelectColumnMenuOptions<TV, TO>): (props: import("@servicetitan/design-system").TableColumnMenuProps) => JSX.Element;
|
9
|
+
//# sourceMappingURL=single-select-filter.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"single-select-filter.d.ts","sourceRoot":"","sources":["../../../src/filters/single-select/single-select-filter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,SAAS,EAAM,MAAM,OAAO,CAAC;AAKjE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AA8BlD,MAAM,WAAW,6BAA6B,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE;IACtD,OAAO,EAAE,EAAE,EAAE,CAAC;IACd,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC;IACjC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,SAAS,GAAG,MAAM,CAAC;CACjD;AAED,wBAAgB,4BAA4B,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,EACnE,KAAK,EAAE,6BAA6B,CAAC,EAAE,EAAE,EAAE,CAAC,sFAuB/C"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { Component } from 'react';
|
3
|
+
import { Radio } from '@servicetitan/design-system';
|
4
|
+
import { renderCustomColumnMenuFilter } from '../column-menu-filters';
|
5
|
+
class SelectorRadio extends Component {
|
6
|
+
render() {
|
7
|
+
const { options, value, renderer } = this.props;
|
8
|
+
return options.map((option, index) => {
|
9
|
+
const optionValue = this.props.valueSelector(option);
|
10
|
+
return (
|
11
|
+
// eslint-disable-next-line react/no-array-index-key
|
12
|
+
_jsx("span", Object.assign({ className: "k-widget m-b-1-i d-b" }, { children: _jsx(Radio, { label: renderer ? renderer(option) : `${option}`, checked: value === optionValue, onChange: (_, event) => this.props.onChange(optionValue, event) }) }), index));
|
13
|
+
});
|
14
|
+
}
|
15
|
+
}
|
16
|
+
export function singleSelectColumnMenuFilter(props) {
|
17
|
+
const FilterCell = ({ value, onChange }) => {
|
18
|
+
var _a;
|
19
|
+
const handleChange = (value, event) => {
|
20
|
+
onChange({
|
21
|
+
value: value !== null && value !== void 0 ? value : '',
|
22
|
+
operator: value ? 'equals' : '',
|
23
|
+
syntheticEvent: event,
|
24
|
+
});
|
25
|
+
};
|
26
|
+
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) }));
|
27
|
+
};
|
28
|
+
return renderCustomColumnMenuFilter(FilterCell);
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=single-select-filter.js.map
|
@@ -0,0 +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;AAEjE,OAAO,EAAwB,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAWtE,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;AAQD,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,QAAQ,CAAC;gBACL,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE;gBAClB,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;gBAC/B,cAAc,EAAE,KAAK;aACxB,CAAC,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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"single-select-filter.stories.d.ts","sourceRoot":"","sources":["../../../src/filters/single-select/single-select-filter.stories.tsx"],"names":[],"mappings":";;;;AAEA,wBAEE;AAEF,eAAO,MAAM,YAAY,mBAAyB,CAAC"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { TableExample } from '../../demo/filters/single-select-filter';
|
3
|
+
export default {
|
4
|
+
title: 'Table/Filters',
|
5
|
+
};
|
6
|
+
export const SingleSelect = () => _jsx(TableExample, {});
|
7
|
+
//# sourceMappingURL=single-select-filter.stories.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"single-select-filter.stories.js","sourceRoot":"","sources":["../../../src/filters/single-select/single-select-filter.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,eAAe;IACX,KAAK,EAAE,eAAe;CACzB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,KAAC,YAAY,KAAG,CAAC"}
|
package/dist/index.d.ts
CHANGED
@@ -5,6 +5,7 @@ export * from './filters';
|
|
5
5
|
export * from './export';
|
6
6
|
export * from './select-cell';
|
7
7
|
export * from './use-observing-table-state';
|
8
|
+
export * from './utils/filters';
|
8
9
|
export { TableColumn, TableColumnProps, TableColumnMenuProps, TableColumnMenuFilter, TableColumnReorderEvent, TableCell, TableHeaderCellProps, TableRowProps, TableRowClickEvent, TableDetailRow, TableDetailRowProps, TableExpandChangeEvent, TableToolbar, TableNoRecords, TableFilterCellProps, TableFilterChangeEvent, } from '@servicetitan/design-system';
|
9
10
|
export { GridColumnMenuFilterUIProps as TableColumnMenuFilterUIProps } from '@progress/kendo-react-grid/dist/npm/interfaces/GridColumnMenuFilterUIProps';
|
10
11
|
export { IdType, DataSource, InMemoryDataSource, AsyncDataSource } from '@servicetitan/data-query';
|
package/dist/index.d.ts.map
CHANGED
@@ -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;
|
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"}
|
package/dist/index.js
CHANGED
@@ -5,6 +5,7 @@ export * from './filters';
|
|
5
5
|
export * from './export';
|
6
6
|
export * from './select-cell';
|
7
7
|
export * from './use-observing-table-state';
|
8
|
+
export * from './utils/filters';
|
8
9
|
export { TableColumn, TableColumnMenuFilter, TableCell, TableDetailRow, TableToolbar, TableNoRecords, } from '@servicetitan/design-system';
|
9
10
|
export { InMemoryDataSource, AsyncDataSource } from '@servicetitan/data-query';
|
10
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;
|
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"}
|
@@ -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.1.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": "^
|
40
|
+
"@servicetitan/data-query": "^24.1.0",
|
41
41
|
"@servicetitan/design-system": ">=12.4.1",
|
42
|
-
"@servicetitan/form": "^
|
42
|
+
"@servicetitan/form": "^24.1.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": "^
|
56
|
+
"@servicetitan/data-query": "^24.1.0",
|
57
57
|
"@servicetitan/design-system": ">=12.4.1",
|
58
|
-
"@servicetitan/form": "^
|
58
|
+
"@servicetitan/form": "^24.1.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": "
|
75
|
+
"gitHead": "23bc9627f403faf6464f5c5db0c1973308d761c6"
|
76
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,32 @@
|
|
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, multiSelectColumnMenuFilter } from '../..';
|
8
|
+
|
9
|
+
import { TableStore } from './table.store';
|
10
|
+
|
11
|
+
export const TableExampleSimple: FC = provide({
|
12
|
+
singletons: [TableStore],
|
13
|
+
})(
|
14
|
+
observer(() => {
|
15
|
+
const [{ tableState, madeInOptions }] = useDependencies(TableStore);
|
16
|
+
|
17
|
+
const madeInColumnMenu = useMemo(
|
18
|
+
() => multiSelectColumnMenuFilter(madeInOptions),
|
19
|
+
[madeInOptions]
|
20
|
+
);
|
21
|
+
|
22
|
+
return (
|
23
|
+
<Table tableState={tableState}>
|
24
|
+
<TableColumn field="ProductID" title="ID" editable={false} width="100px" />
|
25
|
+
|
26
|
+
<TableColumn field="ProductName" title="Product Name" width="240px" />
|
27
|
+
|
28
|
+
<TableColumn field="MadeIn" title="Made In" columnMenu={madeInColumnMenu} />
|
29
|
+
</Table>
|
30
|
+
);
|
31
|
+
})
|
32
|
+
);
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { FC } from 'react';
|
2
|
+
import { observer } from 'mobx-react';
|
3
|
+
import { provide, useDependencies } from '@servicetitan/react-ioc';
|
4
|
+
|
5
|
+
import {
|
6
|
+
Table,
|
7
|
+
TableColumn,
|
8
|
+
DateRangeColumnMenuFilter,
|
9
|
+
NumericRangeColumnMenuFilter,
|
10
|
+
CurrencyRangeColumnMenuFilter,
|
11
|
+
} from '../..';
|
12
|
+
import { TableStore } from './table.store';
|
13
|
+
|
14
|
+
export const TableExampleDate: FC = provide({
|
15
|
+
singletons: [TableStore],
|
16
|
+
})(
|
17
|
+
observer(() => {
|
18
|
+
const [{ tableState }] = useDependencies(TableStore);
|
19
|
+
|
20
|
+
return (
|
21
|
+
<Table tableState={tableState}>
|
22
|
+
<TableColumn field="ProductID" title="ID" editable={false} width="100px" />
|
23
|
+
<TableColumn field="ProductName" title="Product Name" width="240px" />
|
24
|
+
<TableColumn
|
25
|
+
field="UnitsOnOrder"
|
26
|
+
title="Units On Order"
|
27
|
+
columnMenu={DateRangeColumnMenuFilter}
|
28
|
+
/>
|
29
|
+
</Table>
|
30
|
+
);
|
31
|
+
})
|
32
|
+
);
|
33
|
+
|
34
|
+
export const TableExampleNumber: FC = provide({
|
35
|
+
singletons: [TableStore],
|
36
|
+
})(
|
37
|
+
observer(() => {
|
38
|
+
const [{ tableState }] = useDependencies(TableStore);
|
39
|
+
|
40
|
+
return (
|
41
|
+
<Table tableState={tableState}>
|
42
|
+
<TableColumn field="ProductID" title="ID" editable={false} width="100px" />
|
43
|
+
<TableColumn field="ProductName" title="Product Name" width="240px" />
|
44
|
+
<TableColumn
|
45
|
+
field="UnitsInStock"
|
46
|
+
title="Units In Stock"
|
47
|
+
columnMenu={NumericRangeColumnMenuFilter}
|
48
|
+
/>
|
49
|
+
</Table>
|
50
|
+
);
|
51
|
+
})
|
52
|
+
);
|
53
|
+
|
54
|
+
export const TableExampleCurrency: FC = provide({
|
55
|
+
singletons: [TableStore],
|
56
|
+
})(
|
57
|
+
observer(() => {
|
58
|
+
const [{ tableState }] = useDependencies(TableStore);
|
59
|
+
|
60
|
+
return (
|
61
|
+
<Table tableState={tableState}>
|
62
|
+
<TableColumn field="ProductID" title="ID" editable={false} width="100px" />
|
63
|
+
<TableColumn field="ProductName" title="Product Name" width="240px" />
|
64
|
+
<TableColumn
|
65
|
+
field="UnitPrice"
|
66
|
+
title="Unit Price"
|
67
|
+
columnMenu={CurrencyRangeColumnMenuFilter}
|
68
|
+
/>
|
69
|
+
</Table>
|
70
|
+
);
|
71
|
+
})
|
72
|
+
);
|
@@ -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
|
+
}
|