@servicetitan/table 22.1.0 → 22.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/demo/index.d.ts +4 -0
- package/dist/demo/index.d.ts.map +1 -0
- package/dist/demo/index.js +4 -0
- package/dist/demo/index.js.map +1 -0
- package/dist/demo/master-detail/detail-table.d.ts +4 -0
- package/dist/demo/master-detail/detail-table.d.ts.map +1 -0
- package/dist/demo/master-detail/detail-table.js +28 -0
- package/dist/demo/master-detail/detail-table.js.map +1 -0
- package/dist/demo/master-detail/detail-table.store.d.ts +14 -0
- package/dist/demo/master-detail/detail-table.store.d.ts.map +1 -0
- package/dist/demo/master-detail/detail-table.store.js +104 -0
- package/dist/demo/master-detail/detail-table.store.js.map +1 -0
- package/dist/demo/master-detail/index.d.ts +2 -0
- package/dist/demo/master-detail/index.d.ts.map +1 -0
- package/dist/demo/master-detail/index.js +2 -0
- package/dist/demo/master-detail/index.js.map +1 -0
- package/dist/demo/master-detail/master-table.store.d.ts +14 -0
- package/dist/demo/master-detail/master-table.store.d.ts.map +1 -0
- package/dist/demo/master-detail/master-table.store.js +103 -0
- package/dist/demo/master-detail/master-table.store.js.map +1 -0
- package/dist/demo/master-detail/product-detail.d.ts +8 -0
- package/dist/demo/master-detail/product-detail.d.ts.map +1 -0
- package/dist/demo/master-detail/product-detail.js +2 -0
- package/dist/demo/master-detail/product-detail.js.map +1 -0
- package/dist/demo/master-detail/product-details.d.ts +3 -0
- package/dist/demo/master-detail/product-details.d.ts.map +1 -0
- package/dist/demo/master-detail/product-details.js +55 -0
- package/dist/demo/master-detail/product-details.js.map +1 -0
- package/dist/demo/master-detail/product.d.ts +26 -0
- package/dist/demo/master-detail/product.d.ts.map +1 -0
- package/dist/demo/master-detail/product.js +16 -0
- package/dist/demo/master-detail/product.js.map +1 -0
- package/dist/demo/master-detail/products.d.ts +3 -0
- package/dist/demo/master-detail/products.d.ts.map +1 -0
- package/dist/demo/master-detail/products.js +117 -0
- package/dist/demo/master-detail/products.js.map +1 -0
- package/dist/demo/master-detail/table-master-detail.d.ts +3 -0
- package/dist/demo/master-detail/table-master-detail.d.ts.map +1 -0
- package/dist/demo/master-detail/table-master-detail.js +24 -0
- package/dist/demo/master-detail/table-master-detail.js.map +1 -0
- package/dist/demo/overview/actions-cell.d.ts +5 -0
- package/dist/demo/overview/actions-cell.d.ts.map +1 -0
- package/dist/demo/overview/actions-cell.js +38 -0
- package/dist/demo/overview/actions-cell.js.map +1 -0
- package/dist/demo/overview/index.d.ts +2 -0
- package/dist/demo/overview/index.d.ts.map +1 -0
- package/dist/demo/overview/index.js +2 -0
- package/dist/demo/overview/index.js.map +1 -0
- package/dist/demo/overview/product.d.ts +27 -0
- package/dist/demo/overview/product.d.ts.map +1 -0
- package/dist/demo/overview/product.js +16 -0
- package/dist/demo/overview/product.js.map +1 -0
- package/dist/demo/overview/products.d.ts +3 -0
- package/dist/demo/overview/products.d.ts.map +1 -0
- package/dist/demo/overview/products.js +127 -0
- package/dist/demo/overview/products.js.map +1 -0
- package/dist/demo/overview/table.d.ts +6 -0
- package/dist/demo/overview/table.d.ts.map +1 -0
- package/dist/demo/overview/table.js +44 -0
- package/dist/demo/overview/table.js.map +1 -0
- package/dist/demo/overview/table.store.d.ts +15 -0
- package/dist/demo/overview/table.store.d.ts.map +1 -0
- package/dist/demo/overview/table.store.js +92 -0
- package/dist/demo/overview/table.store.js.map +1 -0
- package/dist/demo/state-caching/beverages.d.ts +3 -0
- package/dist/demo/state-caching/beverages.d.ts.map +1 -0
- package/dist/demo/state-caching/beverages.js +48 -0
- package/dist/demo/state-caching/beverages.js.map +1 -0
- package/dist/demo/state-caching/index.d.ts +2 -0
- package/dist/demo/state-caching/index.d.ts.map +1 -0
- package/dist/demo/state-caching/index.js +2 -0
- package/dist/demo/state-caching/index.js.map +1 -0
- package/dist/demo/state-caching/product.d.ts +6 -0
- package/dist/demo/state-caching/product.d.ts.map +1 -0
- package/dist/demo/state-caching/product.js +2 -0
- package/dist/demo/state-caching/product.js.map +1 -0
- package/dist/demo/state-caching/products.d.ts +3 -0
- package/dist/demo/state-caching/products.d.ts.map +1 -0
- package/dist/demo/state-caching/products.js +53 -0
- package/dist/demo/state-caching/products.js.map +1 -0
- package/dist/demo/state-caching/state-caching-table.d.ts +3 -0
- package/dist/demo/state-caching/state-caching-table.d.ts.map +1 -0
- package/dist/demo/state-caching/state-caching-table.js +14 -0
- package/dist/demo/state-caching/state-caching-table.js.map +1 -0
- package/dist/demo/state-caching/state-caching-table.store.d.ts +13 -0
- package/dist/demo/state-caching/state-caching-table.store.d.ts.map +1 -0
- package/dist/demo/state-caching/state-caching-table.store.js +70 -0
- package/dist/demo/state-caching/state-caching-table.store.js.map +1 -0
- package/dist/editable-cell/boolean-editable-cell.d.ts +3 -0
- package/dist/editable-cell/boolean-editable-cell.d.ts.map +1 -0
- package/dist/editable-cell/boolean-editable-cell.js +14 -0
- package/dist/editable-cell/boolean-editable-cell.js.map +1 -0
- package/dist/editable-cell/date-editable-cell.d.ts +3 -0
- package/dist/editable-cell/date-editable-cell.d.ts.map +1 -0
- package/dist/editable-cell/date-editable-cell.js +14 -0
- package/dist/editable-cell/date-editable-cell.js.map +1 -0
- package/dist/editable-cell/get-action-cell.d.ts +13 -0
- package/dist/editable-cell/get-action-cell.d.ts.map +1 -0
- package/dist/editable-cell/get-action-cell.js +18 -0
- package/dist/editable-cell/get-action-cell.js.map +1 -0
- package/dist/editable-cell/get-editable-cell.d.ts +13 -0
- package/dist/editable-cell/get-editable-cell.d.ts.map +1 -0
- package/dist/editable-cell/get-editable-cell.js +18 -0
- package/dist/editable-cell/get-editable-cell.js.map +1 -0
- package/dist/editable-cell/get-select-editable-cell.d.ts +10 -0
- package/dist/editable-cell/get-select-editable-cell.d.ts.map +1 -0
- package/dist/editable-cell/get-select-editable-cell.js +19 -0
- package/dist/editable-cell/get-select-editable-cell.js.map +1 -0
- package/dist/editable-cell/index.d.ts +8 -0
- package/dist/editable-cell/index.d.ts.map +1 -0
- package/dist/editable-cell/index.js +8 -0
- package/dist/editable-cell/index.js.map +1 -0
- package/dist/editable-cell/numeric-editable-cell.d.ts +3 -0
- package/dist/editable-cell/numeric-editable-cell.d.ts.map +1 -0
- package/dist/editable-cell/numeric-editable-cell.js +15 -0
- package/dist/editable-cell/numeric-editable-cell.js.map +1 -0
- package/dist/editable-cell/text-editable-cell.d.ts +9 -0
- package/dist/editable-cell/text-editable-cell.d.ts.map +1 -0
- package/dist/editable-cell/text-editable-cell.js +20 -0
- package/dist/editable-cell/text-editable-cell.js.map +1 -0
- package/dist/export/export.d.ts +10 -0
- package/dist/export/export.d.ts.map +1 -0
- package/dist/export/export.js +6 -0
- package/dist/export/export.js.map +1 -0
- package/dist/export/index.d.ts +2 -0
- package/dist/export/index.d.ts.map +1 -0
- package/dist/export/index.js +2 -0
- package/dist/export/index.js.map +1 -0
- package/dist/filters/column-menu-filters.d.ts +5 -0
- package/dist/filters/column-menu-filters.d.ts.map +1 -0
- package/dist/filters/column-menu-filters.js +9 -0
- package/dist/filters/column-menu-filters.js.map +1 -0
- package/dist/filters/datetime-filter/datetime-filter.d.ts +3 -0
- package/dist/filters/datetime-filter/datetime-filter.d.ts.map +1 -0
- package/dist/filters/datetime-filter/datetime-filter.js +71 -0
- package/dist/filters/datetime-filter/datetime-filter.js.map +1 -0
- package/dist/filters/field-values-filter.d.ts +6 -0
- package/dist/filters/field-values-filter.d.ts.map +1 -0
- package/dist/filters/field-values-filter.js +155 -0
- package/dist/filters/field-values-filter.js.map +1 -0
- package/dist/filters/index.d.ts +9 -0
- package/dist/filters/index.d.ts.map +1 -0
- package/dist/filters/index.js +9 -0
- package/dist/filters/index.js.map +1 -0
- package/dist/filters/multiselect-filter.d.ts +5 -0
- package/dist/filters/multiselect-filter.d.ts.map +1 -0
- package/dist/filters/multiselect-filter.js +107 -0
- package/dist/filters/multiselect-filter.js.map +1 -0
- package/dist/filters/numeric-filter-extended/numeric-extended-operators.d.ts +6 -0
- package/dist/filters/numeric-filter-extended/numeric-extended-operators.d.ts.map +1 -0
- package/dist/filters/numeric-filter-extended/numeric-extended-operators.js +6 -0
- package/dist/filters/numeric-filter-extended/numeric-extended-operators.js.map +1 -0
- package/dist/filters/numeric-filter-extended/numeric-filter-extended.d.ts +3 -0
- package/dist/filters/numeric-filter-extended/numeric-filter-extended.d.ts.map +1 -0
- package/dist/filters/numeric-filter-extended/numeric-filter-extended.js +27 -0
- package/dist/filters/numeric-filter-extended/numeric-filter-extended.js.map +1 -0
- package/dist/filters/range-filter/range-filter.d.ts +6 -0
- package/dist/filters/range-filter/range-filter.d.ts.map +1 -0
- package/dist/filters/range-filter/range-filter.js +117 -0
- package/dist/filters/range-filter/range-filter.js.map +1 -0
- package/dist/filters/standard-filter-with-multiselect/filter-cell-ext.d.ts +21 -0
- package/dist/filters/standard-filter-with-multiselect/filter-cell-ext.d.ts.map +1 -0
- package/dist/filters/standard-filter-with-multiselect/filter-cell-ext.js +82 -0
- package/dist/filters/standard-filter-with-multiselect/filter-cell-ext.js.map +1 -0
- package/dist/filters/standard-filter-with-multiselect/multiselect-operators.d.ts +6 -0
- package/dist/filters/standard-filter-with-multiselect/multiselect-operators.d.ts.map +1 -0
- package/dist/filters/standard-filter-with-multiselect/multiselect-operators.js +6 -0
- package/dist/filters/standard-filter-with-multiselect/multiselect-operators.js.map +1 -0
- package/dist/filters/standard-filter-with-multiselect/standard-filter-with-multiselect.d.ts +26 -0
- package/dist/filters/standard-filter-with-multiselect/standard-filter-with-multiselect.d.ts.map +1 -0
- package/dist/filters/standard-filter-with-multiselect/standard-filter-with-multiselect.js +69 -0
- package/dist/filters/standard-filter-with-multiselect/standard-filter-with-multiselect.js.map +1 -0
- package/dist/filters/standard-filter-with-multiselect/table-column-menu-filter-ext.d.ts +6 -0
- package/dist/filters/standard-filter-with-multiselect/table-column-menu-filter-ext.d.ts.map +1 -0
- package/dist/filters/standard-filter-with-multiselect/table-column-menu-filter-ext.js +30 -0
- package/dist/filters/standard-filter-with-multiselect/table-column-menu-filter-ext.js.map +1 -0
- package/dist/filters/time-filter/time-filter.d.ts +3 -0
- package/dist/filters/time-filter/time-filter.d.ts.map +1 -0
- package/dist/filters/time-filter/time-filter.js +71 -0
- package/dist/filters/time-filter/time-filter.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/select-cell/index.d.ts +2 -0
- package/dist/select-cell/index.d.ts.map +1 -0
- package/dist/select-cell/index.js +2 -0
- package/dist/select-cell/index.js.map +1 -0
- package/dist/select-cell/select-cell.d.ts +25 -0
- package/dist/select-cell/select-cell.d.ts.map +1 -0
- package/dist/select-cell/select-cell.js +42 -0
- package/dist/select-cell/select-cell.js.map +1 -0
- package/dist/table-state.d.ts +161 -0
- package/dist/table-state.d.ts.map +1 -0
- package/dist/table-state.js +1106 -0
- package/dist/table-state.js.map +1 -0
- package/dist/table.d.ts +40 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +231 -0
- package/dist/table.js.map +1 -0
- package/package.json +6 -6
@@ -0,0 +1,21 @@
|
|
1
|
+
import { ReactElement, ReactNode, FC } from 'react';
|
2
|
+
import { ListItemProps, MultiSelectTagData } from '@progress/kendo-react-dropdowns';
|
3
|
+
import { GridColumnMenuFilterCellProps as TableColumnMenuFilterCellProps } from '@progress/kendo-react-grid/dist/npm/columnMenu/GridColumnMenuFilterCell';
|
4
|
+
interface ValueWithLowerCase {
|
5
|
+
value: any;
|
6
|
+
text: string;
|
7
|
+
textLC: string;
|
8
|
+
}
|
9
|
+
export interface FilterCellExtProps extends TableColumnMenuFilterCellProps {
|
10
|
+
options: ValueWithLowerCase[];
|
11
|
+
maxFoundValues?: number;
|
12
|
+
allowCustomValues?: boolean;
|
13
|
+
onlyMultiselectAndEmptyOperators?: boolean;
|
14
|
+
handleCustomValuesAsNumber?: boolean;
|
15
|
+
multiselectItemRender?(li: ReactElement<HTMLLIElement>, itemProps: ListItemProps): ReactNode;
|
16
|
+
multiselectTagRender?(tagData: MultiSelectTagData, li: ReactElement<HTMLLIElement>): ReactElement<HTMLLIElement> | null;
|
17
|
+
multiselectListNoDataRender?(element: ReactElement<HTMLDivElement>): ReactNode;
|
18
|
+
}
|
19
|
+
export declare const FilterCellExt: FC<FilterCellExtProps>;
|
20
|
+
export {};
|
21
|
+
//# sourceMappingURL=filter-cell-ext.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"filter-cell-ext.d.ts","sourceRoot":"","sources":["../../../src/filters/standard-filter-with-multiselect/filter-cell-ext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAe,MAAM,OAAO,CAAC;AAKjE,OAAO,EAMH,aAAa,EACb,kBAAkB,EACrB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,6BAA6B,IAAI,8BAA8B,EAAE,MAAM,yEAAyE,CAAC;AAS1J,UAAU,kBAAkB;IACxB,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAmB,SAAQ,8BAA8B;IACtE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,qBAAqB,CAAC,CAAC,EAAE,EAAE,YAAY,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7F,oBAAoB,CAAC,CACjB,OAAO,EAAE,kBAAkB,EAC3B,EAAE,EAAE,YAAY,CAAC,aAAa,CAAC,GAChC,YAAY,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IACtC,2BAA2B,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;CAClF;AAGD,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAuI/C,CAAC"}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { runInAction } from 'mobx';
|
3
|
+
import { observer, useLocalStore } from 'mobx-react';
|
4
|
+
import { multiselectOperators, isMultiselectOperator } from './multiselect-operators';
|
5
|
+
import { DropDownList, MultiSelect, } from '@progress/kendo-react-dropdowns';
|
6
|
+
import { IsUnaryFilter, cellOperatorChange, } from '@progress/kendo-react-grid/dist/npm/filterCommon';
|
7
|
+
import { Icon } from '@servicetitan/design-system';
|
8
|
+
import * as Styles from './filter-cell-ext.module.css';
|
9
|
+
// like standard filter cell (rendered for string type), but with support of multiselect operators
|
10
|
+
export const FilterCellExt = observer(props => {
|
11
|
+
const store = useLocalStore(oprops => ({
|
12
|
+
get operators() {
|
13
|
+
return multiselectOperators.concat(oprops.onlyMultiselectAndEmptyOperators
|
14
|
+
? oprops.operators.filter(o => o.operator === 'isempty' || o.operator === 'isnotempty')
|
15
|
+
: oprops.operators);
|
16
|
+
},
|
17
|
+
get operatorValue() {
|
18
|
+
return this.operators.find(item => item.operator === oprops.operator);
|
19
|
+
},
|
20
|
+
searchQuery: '',
|
21
|
+
filterChange(event) {
|
22
|
+
runInAction(() => (this.searchQuery = event.filter.value));
|
23
|
+
},
|
24
|
+
get filteredValuesSet() {
|
25
|
+
const queryLC = this.searchQuery.toLowerCase();
|
26
|
+
return oprops.options.filter(v => v.textLC.includes(queryLC));
|
27
|
+
},
|
28
|
+
get onlyFirstValues() {
|
29
|
+
return oprops.maxFoundValues &&
|
30
|
+
oprops.maxFoundValues < this.filteredValuesSet.length
|
31
|
+
? oprops.maxFoundValues
|
32
|
+
: false;
|
33
|
+
},
|
34
|
+
get filteredVisibleValues() {
|
35
|
+
return this.onlyFirstValues
|
36
|
+
? this.filteredValuesSet.slice(0, this.onlyFirstValues)
|
37
|
+
: this.filteredValuesSet;
|
38
|
+
},
|
39
|
+
get valueTextMap() {
|
40
|
+
return new Map(oprops.options.map(o => [o.value, o.text]));
|
41
|
+
},
|
42
|
+
get multiselectValue() {
|
43
|
+
return Array.isArray(oprops.value)
|
44
|
+
? oprops.value.map(v => {
|
45
|
+
var _a;
|
46
|
+
return ({
|
47
|
+
value: v,
|
48
|
+
text: (_a = this.valueTextMap.get(v)) !== null && _a !== void 0 ? _a : v.toString(),
|
49
|
+
});
|
50
|
+
})
|
51
|
+
: [];
|
52
|
+
},
|
53
|
+
}), props);
|
54
|
+
const { operator = '', onChange, allowCustomValues, multiselectItemRender, multiselectTagRender, multiselectListNoDataRender, } = props;
|
55
|
+
const handleInputChange = (e) => onChange({
|
56
|
+
operator,
|
57
|
+
value: e.target.value,
|
58
|
+
syntheticEvent: e,
|
59
|
+
});
|
60
|
+
const handleMultiselectChange = (e) => {
|
61
|
+
const newValue = e.value.map((v) => { var _a; return (_a = v.value) !== null && _a !== void 0 ? _a : (props.handleCustomValuesAsNumber ? +v.text : v.text); });
|
62
|
+
onChange({
|
63
|
+
operator,
|
64
|
+
value: newValue.length ? newValue : '',
|
65
|
+
syntheticEvent: e.syntheticEvent,
|
66
|
+
});
|
67
|
+
};
|
68
|
+
// conversions for better compatibility when switching plain/array operators
|
69
|
+
const handleOperatorChange = (event) => {
|
70
|
+
const newValue = isMultiselectOperator(operator) === isMultiselectOperator(event.target.value.operator)
|
71
|
+
? props.value
|
72
|
+
: '';
|
73
|
+
cellOperatorChange(event, newValue, onChange);
|
74
|
+
};
|
75
|
+
const allowCustomAdd = (allowCustomValues &&
|
76
|
+
store.searchQuery &&
|
77
|
+
(!props.handleCustomValuesAsNumber || !isNaN(+store.searchQuery))) ||
|
78
|
+
false;
|
79
|
+
return (_jsxs("div", { children: [_jsx(DropDownList, { value: store.operatorValue, onChange: handleOperatorChange, data: store.operators, textField: "text" }), (typeof operator !== 'string' || !IsUnaryFilter(operator)) &&
|
80
|
+
(isMultiselectOperator(operator) ? (_jsx(MultiSelect, { value: store.multiselectValue, onChange: handleMultiselectChange, filterable: true, onFilterChange: store.filterChange, allowCustom: allowCustomAdd, data: store.filteredVisibleValues, textField: "text", dataItemKey: "value", header: allowCustomAdd && _jsx("div", { className: Styles.customItemAddMarker }), footer: allowCustomAdd ? (_jsxs("div", Object.assign({ className: Styles.returnToUse }, { children: [_jsx(Icon, { name: "keyboard_return" }), "to create filter"] }))) : (store.onlyFirstValues && (_jsxs("div", Object.assign({ className: Styles.returnToUse }, { children: ["First ", store.onlyFirstValues, " values are shown. ", _jsx("br", {}), "Type to search for other values."] })))), itemRender: multiselectItemRender, tagRender: multiselectTagRender, listNoDataRender: multiselectListNoDataRender })) : (_jsx("input", { className: "k-textbox", value: props.value, onChange: handleInputChange })))] }));
|
81
|
+
});
|
82
|
+
//# sourceMappingURL=filter-cell-ext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"filter-cell-ext.js","sourceRoot":"","sources":["../../../src/filters/standard-filter-with-multiselect/filter-cell-ext.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEtF,OAAO,EACH,YAAY,EAEZ,WAAW,GAKd,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACH,aAAa,EACb,kBAAkB,GACrB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,8BAA8B,CAAC;AAuBvD,kGAAkG;AAClG,MAAM,CAAC,MAAM,aAAa,GAA2B,QAAQ,CAAC,KAAK,CAAC,EAAE;IAClE,MAAM,KAAK,GAAG,aAAa,CACvB,MAAM,CAAC,EAAE,CAAC,CAAC;QACP,IAAI,SAAS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AAW,EAAC,OAAO,EACnB,MAAM,EAAE,cAAc,IAAI,cAAK,SAAS,EAAE,MAAM,CAAC,mBAAmB,GAAI,EACxE,MAAM,EACF,cAAc,CAAC,CAAC,CAAC,CACb,6BAAK,SAAS,EAAE,MAAM,CAAC,WAAW,iBAC9B,KAAC,IAAI,IAAC,IAAI,EAAC,iBAAiB,GAAG,yBAE7B,CACT,CAAC,CAAC,CAAC,CACA,KAAK,CAAC,eAAe,IAAI,CACrB,6BAAK,SAAS,EAAE,MAAM,CAAC,WAAW,2BACvB,KAAK,CAAC,eAAe,yBAAoB,cAAM,yCAEpD,CACT,CACJ,EAEL,UAAU,EAAE,qBAAqB,EACjC,SAAS,EAAE,oBAAoB,EAC/B,gBAAgB,EAAE,2BAA2B,GAC/C,CACL,CAAC,CAAC,CAAC,CACA,gBAAO,SAAS,EAAC,WAAW,EAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,iBAAiB,GAAI,CACnF,CAAC,IACJ,CACT,CAAC;AACN,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"multiselect-operators.d.ts","sourceRoot":"","sources":["../../../src/filters/standard-filter-with-multiselect/multiselect-operators.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;GAGhC,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,GAAG,QAAQ,YACN,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export const multiselectOperators = [
|
2
|
+
{ text: 'Is one of', operator: 'in' },
|
3
|
+
{ text: 'Is not one of', operator: 'notin' },
|
4
|
+
];
|
5
|
+
export const isMultiselectOperator = (operator) => multiselectOperators.some(o => o.operator === operator);
|
6
|
+
//# sourceMappingURL=multiselect-operators.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"multiselect-operators.js","sourceRoot":"","sources":["../../../src/filters/standard-filter-with-multiselect/multiselect-operators.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE;IACrC,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE;CAC/C,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAA2B,EAAE,EAAE,CACjE,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { TableColumnMenuProps } from '@servicetitan/design-system';
|
3
|
+
import { IdType } from '@servicetitan/data-query';
|
4
|
+
import { TableState } from '../../table-state';
|
5
|
+
import { FilterCellExtProps } from './filter-cell-ext';
|
6
|
+
declare type AcceptableOption = string | number | {
|
7
|
+
value: any;
|
8
|
+
text: string;
|
9
|
+
};
|
10
|
+
interface OptionsConfig<T, TId extends IdType = never> {
|
11
|
+
tableState?: TableState<T, TId>;
|
12
|
+
maxExtractedLength?: number;
|
13
|
+
options?: AcceptableOption[];
|
14
|
+
}
|
15
|
+
interface FilterCellConfig {
|
16
|
+
maxFoundValues?: number;
|
17
|
+
allowCustomValues?: boolean;
|
18
|
+
handleCustomValuesAsNumber?: boolean;
|
19
|
+
onlyMultiselectAndEmptyOperators?: boolean;
|
20
|
+
multiselectItemRender?: FilterCellExtProps['multiselectItemRender'];
|
21
|
+
multiselectTagRender?: FilterCellExtProps['multiselectTagRender'];
|
22
|
+
multiselectListNoDataRender?: FilterCellExtProps['multiselectListNoDataRender'];
|
23
|
+
}
|
24
|
+
export declare function standardFilterWithMultiselect<T, TId extends IdType = never>(optionsConfig?: OptionsConfig<T, TId>, filterCellConfig?: FilterCellConfig): (props: TableColumnMenuProps) => JSX.Element;
|
25
|
+
export {};
|
26
|
+
//# sourceMappingURL=standard-filter-with-multiselect.d.ts.map
|
package/dist/filters/standard-filter-with-multiselect/standard-filter-with-multiselect.d.ts.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"standard-filter-with-multiselect.d.ts","sourceRoot":"","sources":["../../../src/filters/standard-filter-with-multiselect/standard-filter-with-multiselect.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAiB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGtE,aAAK,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,UAAU,aAAa,CAAC,CAAC,EAAE,GAAG,SAAS,MAAM,GAAG,KAAK;IAEjD,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAEhC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED,UAAU,gBAAgB;IAEtB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAErC,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAE3C,qBAAqB,CAAC,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;IAEpE,oBAAoB,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IAElE,2BAA2B,CAAC,EAAE,kBAAkB,CAAC,6BAA6B,CAAC,CAAC;CACnF;AAOD,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,GAAG,SAAS,MAAM,GAAG,KAAK,EACvE,aAAa,GAAE,aAAa,CAAC,CAAC,EAAE,GAAG,CAAM,EACzC,gBAAgB,GAAE,gBAAqB,WA8GxB,oBAAoB,iBAGtC"}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { observer, useLocalStore } from 'mobx-react';
|
3
|
+
import { fromPromise } from 'mobx-utils';
|
4
|
+
import { DropDownList } from '@progress/kendo-react-dropdowns';
|
5
|
+
import { TableColumnMenuFilterExt } from './table-column-menu-filter-ext';
|
6
|
+
import { FilterCellExt } from './filter-cell-ext';
|
7
|
+
/*
|
8
|
+
* StandardFilterWithMultiselect is like standard Kendo filter, but with additional operators 'Is one of' / 'Is not one of'.
|
9
|
+
* Intended to be used with string fields (though it's possible to adopt for number fields as well, if someone will have a need).
|
10
|
+
*/
|
11
|
+
export function standardFilterWithMultiselect(optionsConfig = {}, filterCellConfig = {}) {
|
12
|
+
const optionsConfigFull = Object.assign({ maxExtractedLength: 64, options: [] }, optionsConfig);
|
13
|
+
const filterCellConfigFull = Object.assign({ allowCustomValues: true, maxFoundValues: 1000 }, filterCellConfig);
|
14
|
+
// Filter UI with data fetcher
|
15
|
+
const FilterUIWithValues = observer(props => {
|
16
|
+
const store = useLocalStore(oprops => ({
|
17
|
+
get field() {
|
18
|
+
return oprops.firstFilterProps.field;
|
19
|
+
},
|
20
|
+
get itemsFromDataSource() {
|
21
|
+
var _a;
|
22
|
+
const dataSource = (_a = optionsConfigFull.tableState) === null || _a === void 0 ? void 0 : _a.dataSource;
|
23
|
+
return dataSource && this.field && fromPromise(dataSource.getData({}));
|
24
|
+
},
|
25
|
+
get valuesfromTableState() {
|
26
|
+
if (!this.itemsFromDataSource ||
|
27
|
+
!(this.itemsFromDataSource.state === 'fulfilled')) {
|
28
|
+
return [];
|
29
|
+
}
|
30
|
+
return this.itemsFromDataSource.value.data
|
31
|
+
.map(i => i[this.field])
|
32
|
+
.filter(v => typeof v === 'number' ||
|
33
|
+
(typeof v === 'string' &&
|
34
|
+
v.length > 0 &&
|
35
|
+
v.length <= optionsConfigFull.maxExtractedLength));
|
36
|
+
},
|
37
|
+
get options() {
|
38
|
+
return Array.from(new Set(this.valuesfromTableState.concat(optionsConfigFull.options))).map(v => {
|
39
|
+
switch (typeof v) {
|
40
|
+
case 'string':
|
41
|
+
return {
|
42
|
+
value: v,
|
43
|
+
text: v,
|
44
|
+
textLC: v.toLowerCase(),
|
45
|
+
};
|
46
|
+
case 'number':
|
47
|
+
return {
|
48
|
+
value: v,
|
49
|
+
text: v.toString(),
|
50
|
+
textLC: v.toString().toLowerCase(),
|
51
|
+
};
|
52
|
+
case 'object':
|
53
|
+
return {
|
54
|
+
value: v.value,
|
55
|
+
text: v.text,
|
56
|
+
textLC: v.text.toLowerCase(),
|
57
|
+
};
|
58
|
+
default:
|
59
|
+
throw 'Incompatible option type.';
|
60
|
+
}
|
61
|
+
});
|
62
|
+
},
|
63
|
+
}), props);
|
64
|
+
const { firstFilterProps, secondFilterProps, hideSecondFilter, logicData, logicValue, onLogicChange, } = props;
|
65
|
+
return (_jsxs("div", { children: [_jsx(FilterCellExt, Object.assign({}, firstFilterProps, { options: store.options }, filterCellConfigFull)), !hideSecondFilter && (_jsxs("div", { children: [_jsx(DropDownList, { data: logicData, value: logicValue, onChange: onLogicChange, className: "k-filter-and", textField: "text" }), _jsx(FilterCellExt, Object.assign({}, secondFilterProps, { options: store.options }, filterCellConfigFull))] }))] }));
|
66
|
+
});
|
67
|
+
return (props) => (_jsx(TableColumnMenuFilterExt, Object.assign({}, props, { filterUI: FilterUIWithValues, expanded: true })));
|
68
|
+
}
|
69
|
+
//# sourceMappingURL=standard-filter-with-multiselect.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"standard-filter-with-multiselect.js","sourceRoot":"","sources":["../../../src/filters/standard-filter-with-multiselect/standard-filter-with-multiselect.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,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,EAC1B,EACD,CAAC,gBAAgB,IAAI,CAClB,0BACI,KAAC,YAAY,IACT,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAC,cAAc,EACxB,SAAS,EAAC,MAAM,GAClB,EACF,KAAC,aAAa,oBACN,iBAAiB,IACrB,OAAO,EAAE,KAAK,CAAC,OAAO,IAClB,oBAAoB,EAC1B,IACA,CACT,IACC,CACT,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,KAA2B,EAAE,EAAE,CAAC,CACpC,KAAC,wBAAwB,oBAAK,KAAK,IAAE,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,UAAG,CACjF,CAAC;AACN,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { TableColumnMenuFilter } from '@servicetitan/design-system';
|
2
|
+
import { GridColumnMenuFilterProps as TableColumnMenuFilterProps } from '@progress/kendo-react-grid/dist/npm/columnMenu/GridColumnMenuFilter';
|
3
|
+
export declare class TableColumnMenuFilterExt extends TableColumnMenuFilter {
|
4
|
+
constructor(props: TableColumnMenuFilterProps);
|
5
|
+
}
|
6
|
+
//# sourceMappingURL=table-column-menu-filter-ext.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"table-column-menu-filter-ext.d.ts","sourceRoot":"","sources":["../../../src/filters/standard-filter-with-multiselect/table-column-menu-filter-ext.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,yBAAyB,IAAI,0BAA0B,EAAE,MAAM,qEAAqE,CAAC;AAM9I,qBAAa,wBAAyB,SAAQ,qBAAqB;gBACnD,KAAK,EAAE,0BAA0B;CA8BhD"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { comparer } from 'mobx';
|
2
|
+
import { TableColumnMenuFilter } from '@servicetitan/design-system';
|
3
|
+
import { getDefaultOperator } from '@progress/kendo-react-grid/dist/npm/filterCommon';
|
4
|
+
import { multiselectOperators } from './multiselect-operators';
|
5
|
+
// constructor override: if state.filterGroup was filled with default, we override it with new default
|
6
|
+
export class TableColumnMenuFilterExt extends TableColumnMenuFilter {
|
7
|
+
constructor(props) {
|
8
|
+
var _a;
|
9
|
+
super(props);
|
10
|
+
const defaultOperator = getDefaultOperator(props.filterOperators, (_a = props.column.filter) !== null && _a !== void 0 ? _a : 'text');
|
11
|
+
// I know the check is a bit hacky, but that's compensated with its low criticality: even if it fails, nothing really bad happens
|
12
|
+
if (comparer.structural(this.state.filterGroup, {
|
13
|
+
logic: 'and',
|
14
|
+
filters: [
|
15
|
+
{ field: props.column.field, operator: defaultOperator },
|
16
|
+
{ field: props.column.field, operator: defaultOperator },
|
17
|
+
],
|
18
|
+
})) {
|
19
|
+
const newDefaultOperator = multiselectOperators[0].operator;
|
20
|
+
this.state = Object.assign(Object.assign({}, this.state), { filterGroup: {
|
21
|
+
logic: 'and',
|
22
|
+
filters: [
|
23
|
+
{ field: props.column.field, operator: newDefaultOperator },
|
24
|
+
{ field: props.column.field, operator: newDefaultOperator },
|
25
|
+
],
|
26
|
+
} });
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=table-column-menu-filter-ext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"table-column-menu-filter-ext.js","sourceRoot":"","sources":["../../../src/filters/standard-filter-with-multiselect/table-column-menu-filter-ext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AAEtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,sGAAsG;AACtG,MAAM,OAAO,wBAAyB,SAAQ,qBAAqB;IAC/D,YAAY,KAAiC;;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,MAAM,eAAe,GAAG,kBAAkB,CACtC,KAAK,CAAC,eAAe,EACrB,MAAA,KAAK,CAAC,MAAM,CAAC,MAAM,mCAAI,MAAM,CAChC,CAAC;QACF,iIAAiI;QACjI,IACI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YACxC,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE;gBACL,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE;gBACxD,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE;aAC3D;SACJ,CAAC,EACJ;YACE,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YAC5D,IAAI,CAAC,KAAK,mCACH,IAAI,CAAC,KAAK,KACb,WAAW,EAAE;oBACT,KAAK,EAAE,KAAK;oBACZ,OAAO,EAAE;wBACL,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE;wBAC3D,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE;qBAC9D;iBACJ,GACJ,CAAC;SACL;IACL,CAAC;CACJ"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"time-filter.d.ts","sourceRoot":"","sources":["../../../src/filters/time-filter/time-filter.tsx"],"names":[],"mappings":";AAoEA,eAAO,MAAM,oBAAoB,oFAAqD,CAAC"}
|
@@ -0,0 +1,71 @@
|
|
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
11
|
+
import { Component, Fragment } from 'react';
|
12
|
+
import { observer } from 'mobx-react';
|
13
|
+
import { observable, action, makeObservable } from 'mobx';
|
14
|
+
import { DropDownList } from '@progress/kendo-react-dropdowns';
|
15
|
+
import { TimePicker } from '@progress/kendo-react-dateinputs';
|
16
|
+
import { IsUnaryFilter, cellOperatorChange, } from '@progress/kendo-react-grid/dist/npm/filterCommon';
|
17
|
+
import { renderCustomColumnMenuFilter } from '../column-menu-filters';
|
18
|
+
import * as Styles from './time-filter.module.css';
|
19
|
+
let TimeFilterCell = class TimeFilterCell extends Component {
|
20
|
+
constructor(props) {
|
21
|
+
var _a;
|
22
|
+
super(props);
|
23
|
+
Object.defineProperty(this, "operator", {
|
24
|
+
enumerable: true,
|
25
|
+
configurable: true,
|
26
|
+
writable: true,
|
27
|
+
value: (_a = this.props.operators.find(o => o.operator === this.props.operator)) !== null && _a !== void 0 ? _a : this.props.operators[0]
|
28
|
+
});
|
29
|
+
Object.defineProperty(this, "handleOperatorChange", {
|
30
|
+
enumerable: true,
|
31
|
+
configurable: true,
|
32
|
+
writable: true,
|
33
|
+
value: (event) => {
|
34
|
+
this.operator = event.target.value;
|
35
|
+
cellOperatorChange(event, this.props.value, this.props.onChange);
|
36
|
+
}
|
37
|
+
});
|
38
|
+
Object.defineProperty(this, "handleChange", {
|
39
|
+
enumerable: true,
|
40
|
+
configurable: true,
|
41
|
+
writable: true,
|
42
|
+
value: (event) => {
|
43
|
+
var _a;
|
44
|
+
const value = event.value;
|
45
|
+
this.props.onChange({
|
46
|
+
value: value ? new Date(2000, 0, 1, value.getHours(), value.getMinutes()) : null,
|
47
|
+
operator: (_a = this.props.operator) !== null && _a !== void 0 ? _a : '',
|
48
|
+
syntheticEvent: event.syntheticEvent,
|
49
|
+
});
|
50
|
+
}
|
51
|
+
});
|
52
|
+
makeObservable(this);
|
53
|
+
}
|
54
|
+
render() {
|
55
|
+
return (_jsxs(Fragment, { children: [_jsx(DropDownList, { value: this.operator, onChange: this.handleOperatorChange, data: this.props.operators, dataItemKey: "operator", textField: "text" }), !IsUnaryFilter(this.operator.operator) && (_jsx(TimePicker, { value: this.props.value, onChange: this.handleChange, className: Styles.timePicker }))] }));
|
56
|
+
}
|
57
|
+
};
|
58
|
+
__decorate([
|
59
|
+
observable,
|
60
|
+
__metadata("design:type", Object)
|
61
|
+
], TimeFilterCell.prototype, "operator", void 0);
|
62
|
+
__decorate([
|
63
|
+
action,
|
64
|
+
__metadata("design:type", Object)
|
65
|
+
], TimeFilterCell.prototype, "handleOperatorChange", void 0);
|
66
|
+
TimeFilterCell = __decorate([
|
67
|
+
observer,
|
68
|
+
__metadata("design:paramtypes", [Object])
|
69
|
+
], TimeFilterCell);
|
70
|
+
export const TimeColumnMenuFilter = renderCustomColumnMenuFilter(TimeFilterCell, true);
|
71
|
+
//# sourceMappingURL=time-filter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"time-filter.js","sourceRoot":"","sources":["../../../src/filters/time-filter/time-filter.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE1D,OAAO,EAAE,YAAY,EAA2B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cAAc;iBACvC,CAAC,CAAC;YACP,CAAC;WAAC;QAjBE,cAAc,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAkBD,MAAM;QACF,OAAO,CACH,MAAC,QAAQ,eACL,KAAC,YAAY,IACT,KAAK,EAAE,IAAI,CAAC,QAAQ,EACpB,QAAQ,EAAE,IAAI,CAAC,oBAAoB,EACnC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC1B,WAAW,EAAC,UAAU,EACtB,SAAS,EAAC,MAAM,GAClB,EACD,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CACvC,KAAC,UAAU,IACP,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,SAAS,EAAE,MAAM,CAAC,UAAU,GAC9B,CACL,IACM,CACd,CAAC;IACN,CAAC;CACJ,CAAA;AA7Ce;IAAX,UAAU;;gDAEiB;AAQ5B;IADC,MAAM;;4DAIL;AAdA,cAAc;IADnB,QAAQ;;GACH,cAAc,CA8CnB;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
export * from './table';
|
2
|
+
export * from './table-state';
|
3
|
+
export * from './editable-cell';
|
4
|
+
export * from './filters';
|
5
|
+
export * from './export';
|
6
|
+
export * from './select-cell';
|
7
|
+
export { TableColumn, TableColumnProps, TableColumnMenuProps, TableColumnMenuFilter, TableColumnReorderEvent, TableCell, TableHeaderCellProps, TableRowProps, TableRowClickEvent, TableDetailRow, TableDetailRowProps, TableExpandChangeEvent, TableToolbar, TableNoRecords, TableFilterCellProps, TableFilterChangeEvent, } from '@servicetitan/design-system';
|
8
|
+
export { GridColumnMenuFilterUIProps as TableColumnMenuFilterUIProps } from '@progress/kendo-react-grid/dist/npm/interfaces/GridColumnMenuFilterUIProps';
|
9
|
+
export { IdType, DataSource, InMemoryDataSource, AsyncDataSource } from '@servicetitan/data-query';
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +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;AAE9B,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
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
export * from './table';
|
2
|
+
export * from './table-state';
|
3
|
+
export * from './editable-cell';
|
4
|
+
export * from './filters';
|
5
|
+
export * from './export';
|
6
|
+
export * from './select-cell';
|
7
|
+
export { TableColumn, TableColumnMenuFilter, TableCell, TableDetailRow, TableToolbar, TableNoRecords, } from '@servicetitan/design-system';
|
8
|
+
export { InMemoryDataSource, AsyncDataSource } from '@servicetitan/data-query';
|
9
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +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;AAE9B,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 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/select-cell/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/select-cell/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { ComponentType, SyntheticEvent, FC } from 'react';
|
2
|
+
import { TableCellProps, TableHeaderCellProps, CheckboxProps } from '@servicetitan/design-system';
|
3
|
+
export declare type SelectionControlType = ComponentType<CheckboxProps<never>>;
|
4
|
+
interface SelectColumnCellProps extends TableCellProps {
|
5
|
+
isRowSelectable?: boolean;
|
6
|
+
control?: SelectionControlType;
|
7
|
+
}
|
8
|
+
interface SelectHeaderCellProps extends TableHeaderCellProps {
|
9
|
+
isSomeRowsSelected?: boolean;
|
10
|
+
control?: SelectionControlType;
|
11
|
+
}
|
12
|
+
interface SelectCellProps {
|
13
|
+
checked: boolean;
|
14
|
+
disabled?: boolean;
|
15
|
+
indeterminate?: boolean;
|
16
|
+
selectionChange?: (event: {
|
17
|
+
syntheticEvent: SyntheticEvent<any>;
|
18
|
+
}) => void;
|
19
|
+
control?: SelectionControlType;
|
20
|
+
}
|
21
|
+
export declare const SelectCell: FC<SelectCellProps>;
|
22
|
+
export declare const SelectColumnCell: FC<SelectColumnCellProps>;
|
23
|
+
export declare const SelectHeaderCell: FC<SelectHeaderCellProps>;
|
24
|
+
export {};
|
25
|
+
//# sourceMappingURL=select-cell.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"select-cell.d.ts","sourceRoot":"","sources":["../../src/select-cell/select-cell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE,EAAe,MAAM,OAAO,CAAC;AACvE,OAAO,EACH,cAAc,EACd,oBAAoB,EAEpB,aAAa,EAChB,MAAM,6BAA6B,CAAC;AAIrC,oBAAY,oBAAoB,GAAG,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AAEvE,UAAU,qBAAsB,SAAQ,cAAc;IAClD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED,UAAU,qBAAsB,SAAQ,oBAAoB;IACxD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED,UAAU,eAAe;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3E,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAgB1C,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CA4CtD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAOtD,CAAC"}
|
@@ -0,0 +1,42 @@
|
|
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
|
+
};
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
+
import { useCallback } from 'react';
|
14
|
+
import { Checkbox, } from '@servicetitan/design-system';
|
15
|
+
import classNames from 'classnames';
|
16
|
+
import * as Styles from './select-cell.module.css';
|
17
|
+
export const SelectCell = (_a) => {
|
18
|
+
var { selectionChange, control: Control = Checkbox } = _a, props = __rest(_a, ["selectionChange", "control"]);
|
19
|
+
const onChange = useCallback((_0, _1, event) => {
|
20
|
+
if (!selectionChange) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
selectionChange({ syntheticEvent: event });
|
24
|
+
}, [selectionChange]);
|
25
|
+
return _jsx(Control, Object.assign({ className: Styles.checkbox, onChange: onChange }, props));
|
26
|
+
};
|
27
|
+
export const SelectColumnCell = ({ style, rowType, dataItem, control, isRowSelectable, selectionChange, className, }) => {
|
28
|
+
const onSelectionChange = useCallback((event) => {
|
29
|
+
if (isRowSelectable && selectionChange) {
|
30
|
+
selectionChange({ syntheticEvent: event });
|
31
|
+
}
|
32
|
+
}, [selectionChange, isRowSelectable]);
|
33
|
+
if (rowType === 'groupHeader') {
|
34
|
+
return null;
|
35
|
+
}
|
36
|
+
if (rowType === 'groupFooter') {
|
37
|
+
return _jsx("td", {});
|
38
|
+
}
|
39
|
+
return (_jsx("td", Object.assign({ style: style, className: classNames(isRowSelectable && selectionChange && 'cursor-pointer', className), onClick: onSelectionChange }, { children: _jsx(SelectCell, { checked: dataItem.selected, disabled: !isRowSelectable, selectionChange: selectionChange, indeterminate: dataItem.indeterminate, control: control }) })));
|
40
|
+
};
|
41
|
+
export const SelectHeaderCell = (props) => (_jsx(SelectCell, { checked: props.selectionValue, indeterminate: props.isSomeRowsSelected, selectionChange: props.selectionChange, control: props.control }));
|
42
|
+
//# sourceMappingURL=select-cell.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"select-cell.js","sourceRoot":"","sources":["../../src/select-cell/select-cell.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAqC,WAAW,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EAGH,QAAQ,GAEX,MAAM,6BAA6B,CAAC;AACrC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AAsBnD,MAAM,CAAC,MAAM,UAAU,GAAwB,CAAC,EAI9B,EAAE,EAAE;QAJ0B,EAC5C,eAAe,EACf,OAAO,EAAE,OAAO,GAAG,QAAQ,OAEb,EADX,KAAK,cAHoC,8BAI/C,CADW;IAER,MAAM,QAAQ,GAAG,WAAW,CACxB,CAAC,EAAS,EAAE,EAAW,EAAE,KAAuC,EAAE,EAAE;QAChE,IAAI,CAAC,eAAe,EAAE;YAClB,OAAO;SACV;QACD,eAAe,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/C,CAAC,EACD,CAAC,eAAe,CAAC,CACpB,CAAC;IAEF,OAAO,KAAC,OAAO,kBAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,IAAM,KAAK,EAAI,CAAC;AAClF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,EACxD,KAAK,EACL,OAAO,EACP,QAAQ,EACR,OAAO,EACP,eAAe,EACf,eAAe,EACf,SAAS,GACW,EAAE,EAAE;IACxB,MAAM,iBAAiB,GAAG,WAAW,CACjC,CAAC,KAA2C,EAAE,EAAE;QAC5C,IAAI,eAAe,IAAI,eAAe,EAAE;YACpC,eAAe,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