@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.
- package/dist/demo/filters/async-select-filter.js +1 -1
- package/dist/demo/filters/async-select-filter.js.map +1 -1
- package/dist/demo/filters/categories.d.ts.map +1 -1
- package/dist/demo/filters/categories.js +24 -0
- package/dist/demo/filters/categories.js.map +1 -1
- package/dist/demo/filters/multiselect-filter.d.ts.map +1 -1
- package/dist/demo/filters/multiselect-filter.js +2 -1
- package/dist/demo/filters/multiselect-filter.js.map +1 -1
- package/dist/demo/filters/select-filter.d.ts +6 -0
- package/dist/demo/filters/select-filter.d.ts.map +1 -0
- package/dist/demo/filters/select-filter.js +58 -0
- package/dist/demo/filters/select-filter.js.map +1 -0
- package/dist/demo/filters/single-select-filter.d.ts.map +1 -1
- package/dist/demo/filters/single-select-filter.js +2 -1
- package/dist/demo/filters/single-select-filter.js.map +1 -1
- package/dist/demo/filters/table.store.d.ts +8 -1
- package/dist/demo/filters/table.store.d.ts.map +1 -1
- package/dist/demo/filters/table.store.js +35 -1
- package/dist/demo/filters/table.store.js.map +1 -1
- package/dist/demo/footer-page-size/index.d.ts +2 -0
- package/dist/demo/footer-page-size/index.d.ts.map +1 -0
- package/dist/demo/footer-page-size/index.js +2 -0
- package/dist/demo/footer-page-size/index.js.map +1 -0
- package/dist/demo/footer-page-size/table.d.ts +3 -0
- package/dist/demo/footer-page-size/table.d.ts.map +1 -0
- package/dist/demo/footer-page-size/table.js +18 -0
- package/dist/demo/footer-page-size/table.js.map +1 -0
- package/dist/demo/index.d.ts +1 -0
- package/dist/demo/index.d.ts.map +1 -1
- package/dist/demo/index.js +1 -0
- package/dist/demo/index.js.map +1 -1
- package/dist/demo/overview/product.d.ts +5 -0
- package/dist/demo/overview/product.d.ts.map +1 -1
- package/dist/demo/overview/products.d.ts.map +1 -1
- package/dist/demo/overview/products.js +12 -0
- package/dist/demo/overview/products.js.map +1 -1
- package/dist/demo/overview/table.store.d.ts.map +1 -1
- package/dist/demo/overview/table.store.js +1 -0
- package/dist/demo/overview/table.store.js.map +1 -1
- package/dist/filters/async-select/async-select-filter.d.ts +7 -3
- package/dist/filters/async-select/async-select-filter.d.ts.map +1 -1
- package/dist/filters/async-select/async-select-filter.js +21 -6
- package/dist/filters/async-select/async-select-filter.js.map +1 -1
- package/dist/filters/column-menu-filters.d.ts +10 -1
- package/dist/filters/column-menu-filters.d.ts.map +1 -1
- package/dist/filters/column-menu-filters.js +11 -3
- package/dist/filters/column-menu-filters.js.map +1 -1
- package/dist/filters/index.d.ts +1 -0
- package/dist/filters/index.d.ts.map +1 -1
- package/dist/filters/index.js +1 -0
- package/dist/filters/index.js.map +1 -1
- package/dist/filters/multiselect-filter/multiselect-filter.d.ts +4 -3
- package/dist/filters/multiselect-filter/multiselect-filter.d.ts.map +1 -1
- package/dist/filters/multiselect-filter/multiselect-filter.js +7 -7
- package/dist/filters/multiselect-filter/multiselect-filter.js.map +1 -1
- package/dist/filters/select-filter/object-search.d.ts +2 -0
- package/dist/filters/select-filter/object-search.d.ts.map +1 -0
- package/dist/filters/select-filter/object-search.js +19 -0
- package/dist/filters/select-filter/object-search.js.map +1 -0
- package/dist/filters/select-filter/select-filter.d.ts +32 -0
- package/dist/filters/select-filter/select-filter.d.ts.map +1 -0
- package/dist/filters/select-filter/select-filter.js +214 -0
- package/dist/filters/select-filter/select-filter.js.map +1 -0
- package/dist/filters/select-filter/select-filter.stories.d.ts +8 -0
- package/dist/filters/select-filter/select-filter.stories.d.ts.map +1 -0
- package/dist/filters/select-filter/select-filter.stories.js +8 -0
- package/dist/filters/select-filter/select-filter.stories.js.map +1 -0
- package/dist/filters/select-filter/value-getter.d.ts +3 -0
- package/dist/filters/select-filter/value-getter.d.ts.map +1 -0
- package/dist/filters/select-filter/value-getter.js +10 -0
- package/dist/filters/select-filter/value-getter.js.map +1 -0
- package/dist/filters/single-select/single-select-filter.d.ts +3 -2
- package/dist/filters/single-select/single-select-filter.d.ts.map +1 -1
- package/dist/filters/single-select/single-select-filter.js +17 -7
- package/dist/filters/single-select/single-select-filter.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/demo/filters/async-select-filter.tsx +1 -1
- package/src/demo/filters/categories.tsx +24 -0
- package/src/demo/filters/multiselect-filter.tsx +15 -0
- package/src/demo/filters/select-filter.tsx +147 -0
- package/src/demo/filters/single-select-filter.tsx +2 -1
- package/src/demo/filters/table.store.ts +45 -2
- package/src/demo/footer-page-size/index.ts +1 -0
- package/src/demo/footer-page-size/table.tsx +104 -0
- package/src/demo/index.ts +1 -0
- package/src/demo/overview/product.ts +6 -0
- package/src/demo/overview/products.ts +12 -0
- package/src/demo/overview/table.store.ts +1 -0
- package/src/filters/async-select/async-select-filter.tsx +26 -15
- package/src/filters/column-menu-filters.tsx +44 -21
- package/src/filters/index.ts +1 -0
- package/src/filters/multiselect-filter/multiselect-filter.tsx +16 -7
- package/src/filters/select-filter/__tests__/object-search.test.ts +32 -0
- package/src/filters/select-filter/object-search.ts +25 -0
- package/src/filters/select-filter/select-filter.stories.tsx +8 -0
- package/src/filters/select-filter/select-filter.tsx +320 -0
- package/src/filters/select-filter/value-getter.ts +13 -0
- package/src/filters/single-select/single-select-filter.tsx +18 -10
- package/src/index.ts +1 -0
- package/src/table.stories.tsx +4 -2
@@ -3,7 +3,10 @@ import { Component, SyntheticEvent, ReactNode, FC } from 'react';
|
|
3
3
|
import { IdType } from '@servicetitan/data-query';
|
4
4
|
import { TableFilterCellProps, Radio } from '@servicetitan/design-system';
|
5
5
|
|
6
|
-
import {
|
6
|
+
import {
|
7
|
+
CustomColumnMenuFilterSingleOpts,
|
8
|
+
renderCustomColumnMenuFilter,
|
9
|
+
} from '../column-menu-filters';
|
7
10
|
|
8
11
|
interface SelectorProps<TV, TO> {
|
9
12
|
options: TO[];
|
@@ -33,16 +36,21 @@ class SelectorRadio<TV, TO> extends Component<SelectorProps<TV, TO>> {
|
|
33
36
|
}
|
34
37
|
}
|
35
38
|
|
36
|
-
export interface SingleSelectColumnMenuOptions<TV, TO = TV>
|
39
|
+
export interface SingleSelectColumnMenuOptions<TV, TO = TV>
|
40
|
+
extends CustomColumnMenuFilterSingleOpts {
|
37
41
|
options: TO[];
|
38
42
|
valueSelector?: (item: TO) => TV;
|
39
43
|
renderItem?: (item: TO) => ReactNode | string;
|
40
44
|
filterOperator?: (listItem: any, value: TV) => boolean;
|
41
45
|
}
|
42
46
|
|
43
|
-
export function singleSelectColumnMenuFilter<TV extends IdType, TO = TV>(
|
44
|
-
|
45
|
-
|
47
|
+
export function singleSelectColumnMenuFilter<TV extends IdType, TO = TV>({
|
48
|
+
options,
|
49
|
+
valueSelector,
|
50
|
+
renderItem,
|
51
|
+
filterOperator,
|
52
|
+
...opts
|
53
|
+
}: SingleSelectColumnMenuOptions<TV, TO>) {
|
46
54
|
const FilterCell: FC<TableFilterCellProps> = ({ value, onChange }) => {
|
47
55
|
const handleChange = (value: TV | undefined, event: SyntheticEvent<HTMLInputElement>) => {
|
48
56
|
const filter =
|
@@ -50,7 +58,7 @@ export function singleSelectColumnMenuFilter<TV extends IdType, TO = TV>(
|
|
50
58
|
? { value: '', operator: '' }
|
51
59
|
: {
|
52
60
|
value,
|
53
|
-
operator:
|
61
|
+
operator: filterOperator ?? 'equals',
|
54
62
|
};
|
55
63
|
|
56
64
|
onChange({
|
@@ -61,14 +69,14 @@ export function singleSelectColumnMenuFilter<TV extends IdType, TO = TV>(
|
|
61
69
|
|
62
70
|
return (
|
63
71
|
<SelectorRadio
|
64
|
-
options={
|
72
|
+
options={options}
|
65
73
|
value={value === '' ? undefined : value}
|
66
74
|
onChange={handleChange}
|
67
|
-
renderer={
|
68
|
-
valueSelector={
|
75
|
+
renderer={renderItem}
|
76
|
+
valueSelector={valueSelector ?? (option => option)}
|
69
77
|
/>
|
70
78
|
);
|
71
79
|
};
|
72
80
|
|
73
|
-
return renderCustomColumnMenuFilter(FilterCell);
|
81
|
+
return renderCustomColumnMenuFilter(FilterCell, opts);
|
74
82
|
}
|
package/src/index.ts
CHANGED
package/src/table.stories.tsx
CHANGED
@@ -2,14 +2,16 @@ import {
|
|
2
2
|
TableExample,
|
3
3
|
TableMasterDetailExample,
|
4
4
|
TableStateCachingExample,
|
5
|
-
TableColumnHidingExample
|
5
|
+
TableColumnHidingExample,
|
6
|
+
TableFooterPageSizeExample,
|
6
7
|
} from './demo';
|
7
8
|
|
8
9
|
export default {
|
9
|
-
title: 'Table/Demos'
|
10
|
+
title: 'Table/Demos',
|
10
11
|
};
|
11
12
|
|
12
13
|
export const Table = () => <TableExample />;
|
13
14
|
export const TableMasterDetail = () => <TableMasterDetailExample />;
|
14
15
|
export const TableStateCaching = () => <TableStateCachingExample />;
|
15
16
|
export const TableColumnHiding = () => <TableColumnHidingExample />;
|
17
|
+
export const TableFooterPageSize = () => <TableFooterPageSizeExample />;
|