@adaptabletools/adaptable-cjs 21.0.11 → 21.1.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base.css +1811 -2336
- package/base.css.map +1 -1
- package/index.css +1768 -1413
- package/index.css.map +1 -1
- package/package.json +3 -3
- package/src/AdaptableInterfaces/IAdaptable.d.ts +2 -1
- package/src/AdaptableOptions/FilterOptions.d.ts +7 -0
- package/src/AdaptableOptions/PredicateOptions.d.ts +4 -3
- package/src/AdaptableState/Common/AdaptableColumn.d.ts +1 -1
- package/src/AdaptableState/Common/AdaptablePredicate.d.ts +12 -0
- package/src/AdaptableState/Common/AdaptablePredicate.js +132 -18
- package/src/AdaptableState/Selection/GridCell.d.ts +10 -0
- package/src/Api/Implementation/ExportApiImpl.js +1 -7
- package/src/Api/Implementation/PredicateApiImpl.d.ts +3 -1
- package/src/Api/Implementation/PredicateApiImpl.js +27 -3
- package/src/Api/Internal/AdaptableInternalApi.d.ts +2 -1
- package/src/Api/Internal/AdaptableInternalApi.js +6 -0
- package/src/Api/Internal/PredicateInternalApi.d.ts +3 -1
- package/src/Api/Internal/PredicateInternalApi.js +14 -0
- package/src/Api/PredicateApi.d.ts +1 -1
- package/src/Redux/Store/AdaptableStore.js +111 -3
- package/src/Utilities/Helpers/Helper.js +26 -2
- package/src/Utilities/Hooks/index.d.ts +4 -0
- package/src/Utilities/Hooks/index.js +9 -0
- package/src/Utilities/Hooks/useAdaptableColumn.d.ts +2 -0
- package/src/Utilities/Hooks/useAdaptableColumn.js +10 -0
- package/src/Utilities/Hooks/useAdaptableOptions.d.ts +2 -0
- package/src/Utilities/Hooks/useAdaptableOptions.js +9 -0
- package/src/Utilities/Hooks/useAdaptableState.d.ts +3 -0
- package/src/Utilities/Hooks/useAdaptableState.js +43 -0
- package/src/Utilities/adaptableQlUtils.js +3 -0
- package/src/View/AdaptableComputedCSSVarsContext.d.ts +12 -0
- package/src/View/AdaptableComputedCSSVarsContext.js +32 -0
- package/src/View/Components/AdaptableInput/AdaptableDateInlineInput.d.ts +1 -1
- package/src/View/Components/ColumnFilter/FloatingFilter.js +5 -1
- package/src/View/Components/ColumnFilter/components/FloatingFilterInputList.js +1 -1
- package/src/View/Components/ColumnFilter/components/FloatingFilterValues.js +34 -9
- package/src/View/Components/FilterForm/ListBoxFilterForm.d.ts +1 -0
- package/src/View/Components/FilterForm/ListBoxFilterForm.js +93 -16
- package/src/View/Layout/Wizard/sections/ColumnsSection.js +1 -1
- package/src/View/renderWithAdaptableContext.js +3 -1
- package/src/agGrid/AdaptableAgGrid.d.ts +3 -1
- package/src/agGrid/AdaptableAgGrid.js +360 -23
- package/src/agGrid/AdaptableFilterHandler.d.ts +3 -1
- package/src/agGrid/AdaptableFilterHandler.js +16 -12
- package/src/agGrid/AgGridAdapter.js +12 -6
- package/src/agGrid/AgGridColumnAdapter.js +19 -13
- package/src/components/OverlayTrigger/index.js +1 -1
- package/src/components/Select/Select.js +21 -21
- package/src/components/Tree/TreeDropdown/index.d.ts +27 -0
- package/src/components/Tree/TreeDropdown/index.js +256 -0
- package/src/components/Tree/TreeList/index.d.ts +25 -0
- package/src/components/Tree/TreeList/index.js +40 -0
- package/src/devTools/DevToolsTracks.d.ts +31 -0
- package/src/devTools/DevToolsTracks.js +34 -0
- package/src/devTools/PerfMarker.d.ts +12 -0
- package/src/devTools/PerfMarker.js +2 -0
- package/src/devTools/index.d.ts +102 -0
- package/src/devTools/index.js +165 -0
- package/src/env.js +2 -2
- package/src/layout-manager/src/index.d.ts +2 -0
- package/src/layout-manager/src/index.js +24 -0
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAdaptableColumn = void 0;
|
|
4
|
+
const AdaptableContext_1 = require("../../View/AdaptableContext");
|
|
5
|
+
function useAdaptableColumn(columnId) {
|
|
6
|
+
const api = (0, AdaptableContext_1.useAdaptable)().api;
|
|
7
|
+
const column = api.columnApi.getColumnWithColumnId(columnId);
|
|
8
|
+
return column;
|
|
9
|
+
}
|
|
10
|
+
exports.useAdaptableColumn = useAdaptableColumn;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAdaptableOptions = void 0;
|
|
4
|
+
const AdaptableContext_1 = require("../../View/AdaptableContext");
|
|
5
|
+
const useAdaptableOptions = (fn) => {
|
|
6
|
+
const adaptableOptions = (0, AdaptableContext_1.useAdaptable)().adaptableOptions;
|
|
7
|
+
return fn ? fn(adaptableOptions) : adaptableOptions;
|
|
8
|
+
};
|
|
9
|
+
exports.useAdaptableOptions = useAdaptableOptions;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAdaptableState = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const AdaptableContext_1 = require("../../View/AdaptableContext");
|
|
6
|
+
function useAdaptableState(selector) {
|
|
7
|
+
const adaptable = (0, AdaptableContext_1.useAdaptable)();
|
|
8
|
+
const store = adaptable.adaptableStore;
|
|
9
|
+
const [_refreshKey, setRefreshKey] = (0, react_1.useState)(0);
|
|
10
|
+
const resultRef = (0, react_1.useRef)(null);
|
|
11
|
+
const getResult = () => {
|
|
12
|
+
if (!store) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const state = store.getCurrentStorageState();
|
|
16
|
+
if (!state) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return selector ? selector(state) : state;
|
|
20
|
+
};
|
|
21
|
+
// don't refresh when the state changes
|
|
22
|
+
// as we're under the adaptable context
|
|
23
|
+
// and this means it will be refreshed automatically
|
|
24
|
+
// useEffect(() => {
|
|
25
|
+
// if (!store) {
|
|
26
|
+
// return;
|
|
27
|
+
// }
|
|
28
|
+
// return store.onAny(() => {
|
|
29
|
+
// const newResult = getResult();
|
|
30
|
+
// if (newResult !== resultRef.current) {
|
|
31
|
+
// //only refresh when the result has changed
|
|
32
|
+
// setRefreshKey((prev) => prev + 1);
|
|
33
|
+
// }
|
|
34
|
+
// });
|
|
35
|
+
// }, [store]);
|
|
36
|
+
if (!adaptable || !adaptable.isReady) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const res = getResult();
|
|
40
|
+
resultRef.current = res;
|
|
41
|
+
return res;
|
|
42
|
+
}
|
|
43
|
+
exports.useAdaptableState = useAdaptableState;
|
|
@@ -20,6 +20,9 @@ const mapColumnDataTypeToExpressionFunctionType = (dataType) => {
|
|
|
20
20
|
if (dataType === 'textArray') {
|
|
21
21
|
return 'text[]';
|
|
22
22
|
}
|
|
23
|
+
if (dataType === 'groupColumn') {
|
|
24
|
+
return 'text';
|
|
25
|
+
}
|
|
23
26
|
};
|
|
24
27
|
exports.mapColumnDataTypeToExpressionFunctionType = mapColumnDataTypeToExpressionFunctionType;
|
|
25
28
|
const mapExpressionFunctionTypeToColumnDataType = (type) => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
declare const computedCSSVarNames: readonly ["--ab-cmp-select-menu__max-width", "--ab-cmp-select-menu__min-width", "--ab-cmp-select-menu__max-height"];
|
|
3
|
+
type AdaptableComputedCSSVars = {
|
|
4
|
+
[key in (typeof computedCSSVarNames)[number]]: string | number;
|
|
5
|
+
};
|
|
6
|
+
export declare const AdaptableComputedCSSVarsContext: React.Context<AdaptableComputedCSSVars>;
|
|
7
|
+
export declare const WithAdaptableComputedCSSVars: ({ children }: {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}) => React.JSX.Element;
|
|
10
|
+
export declare const useAdaptableComputedCSSVars: () => AdaptableComputedCSSVars;
|
|
11
|
+
export declare const useAdaptableComputedCSSVar: (varName: (typeof computedCSSVarNames)[number]) => string | number;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAdaptableComputedCSSVar = exports.useAdaptableComputedCSSVars = exports.WithAdaptableComputedCSSVars = exports.AdaptableComputedCSSVarsContext = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const React = tslib_1.__importStar(require("react"));
|
|
6
|
+
const CSSNumericVariableWatch_1 = require("../components/Select/CSSNumericVariableWatch");
|
|
7
|
+
const computedCSSVarNames = [
|
|
8
|
+
'--ab-cmp-select-menu__max-width',
|
|
9
|
+
'--ab-cmp-select-menu__min-width',
|
|
10
|
+
'--ab-cmp-select-menu__max-height',
|
|
11
|
+
];
|
|
12
|
+
const defaultValues = Object.fromEntries(computedCSSVarNames.map((varName) => [varName, 0]));
|
|
13
|
+
exports.AdaptableComputedCSSVarsContext = React.createContext(defaultValues);
|
|
14
|
+
const WithAdaptableComputedCSSVars = ({ children }) => {
|
|
15
|
+
const [computedCSSVars, setComputedCSSVars] = React.useState(defaultValues);
|
|
16
|
+
return (React.createElement(exports.AdaptableComputedCSSVarsContext.Provider, { value: computedCSSVars },
|
|
17
|
+
children,
|
|
18
|
+
computedCSSVarNames.map((varName) => (React.createElement(CSSNumericVariableWatch_1.CSSNumericVariableWatch, { key: varName, varName: varName, onChange: (value) => {
|
|
19
|
+
setComputedCSSVars((prev) => ({ ...prev, [varName]: value }));
|
|
20
|
+
} })))));
|
|
21
|
+
};
|
|
22
|
+
exports.WithAdaptableComputedCSSVars = WithAdaptableComputedCSSVars;
|
|
23
|
+
const useAdaptableComputedCSSVars = () => {
|
|
24
|
+
const context = React.useContext(exports.AdaptableComputedCSSVarsContext);
|
|
25
|
+
return context;
|
|
26
|
+
};
|
|
27
|
+
exports.useAdaptableComputedCSSVars = useAdaptableComputedCSSVars;
|
|
28
|
+
const useAdaptableComputedCSSVar = (varName) => {
|
|
29
|
+
const context = React.useContext(exports.AdaptableComputedCSSVarsContext);
|
|
30
|
+
return context?.[varName];
|
|
31
|
+
};
|
|
32
|
+
exports.useAdaptableComputedCSSVar = useAdaptableComputedCSSVar;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { AdaptableInputProps } from '.';
|
|
3
|
-
export declare const AdaptableDateInlineInput: React.ForwardRefExoticComponent<Omit<Omit<AdaptableInputProps, "
|
|
3
|
+
export declare const AdaptableDateInlineInput: React.ForwardRefExoticComponent<Omit<Omit<AdaptableInputProps, "value" | "onChange"> & {
|
|
4
4
|
onChange: (value: string) => void;
|
|
5
5
|
value: string;
|
|
6
6
|
}, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -11,6 +11,7 @@ const AdaptableIconComponent_1 = require("../AdaptableIconComponent");
|
|
|
11
11
|
const ColumnFilterMenu_1 = require("./components/ColumnFilterMenu");
|
|
12
12
|
const FloatingFilterInputList_1 = require("./components/FloatingFilterInputList");
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
|
+
const GeneralConstants_1 = require("../../../Utilities/Constants/GeneralConstants");
|
|
14
15
|
const FloatingFilter = (props) => {
|
|
15
16
|
const adaptable = (0, AdaptableContext_1.useAdaptable)();
|
|
16
17
|
/**
|
|
@@ -26,7 +27,10 @@ const FloatingFilter = (props) => {
|
|
|
26
27
|
singleFilterPredicateDef = props.predicateDefs.find((predicateDef) => predicateDef.operator === props.predicate.args[0].operator);
|
|
27
28
|
}
|
|
28
29
|
const noInputs = !singleFilterPredicateDef?.inputs || singleFilterPredicateDef.inputs.length === 0;
|
|
29
|
-
|
|
30
|
+
let showLabel = isMultiple || noInputs || isManualApply;
|
|
31
|
+
if (props.columnId === GeneralConstants_1.AG_GRID_GROUPED_COLUMN) {
|
|
32
|
+
showLabel = false;
|
|
33
|
+
}
|
|
30
34
|
let label = (0, utils_1.qlPredicateToString)(props.predicate, props.predicateDefs);
|
|
31
35
|
if (isManualApply &&
|
|
32
36
|
singleFilterPredicateDef &&
|
|
@@ -37,7 +37,7 @@ const FloatingFilterInputList = (props) => {
|
|
|
37
37
|
});
|
|
38
38
|
}, value: props.predicate.args,
|
|
39
39
|
// are not known ql operators for now
|
|
40
|
-
// should change when porting, it has
|
|
40
|
+
// should change when porting, it has knowledge about predicates
|
|
41
41
|
type: props.predicate.operator === 'In' ? 'In' : 'NotIn' }));
|
|
42
42
|
}
|
|
43
43
|
return (React.createElement(React.Fragment, null, (matchingInputs ?? []).map((input, index) => {
|
|
@@ -6,6 +6,15 @@ const React = tslib_1.__importStar(require("react"));
|
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const AdaptableContext_1 = require("../../../AdaptableContext");
|
|
8
8
|
const ListBoxFilterForm_1 = require("../../FilterForm/ListBoxFilterForm");
|
|
9
|
+
const GeneralConstants_1 = require("../../../../Utilities/Constants/GeneralConstants");
|
|
10
|
+
const onceFlags = {};
|
|
11
|
+
const logOnce = (message, loggingFn) => {
|
|
12
|
+
if (onceFlags[message]) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
loggingFn(message);
|
|
16
|
+
onceFlags[message] = true;
|
|
17
|
+
};
|
|
9
18
|
const renderSingleValue = (option) => {
|
|
10
19
|
return option.label;
|
|
11
20
|
};
|
|
@@ -45,10 +54,10 @@ function useDistinctFilterColumnValues(options) {
|
|
|
45
54
|
let ignore = false;
|
|
46
55
|
setIsDistinctColumnValuesLoading(true);
|
|
47
56
|
let searchValueUsedInFilterValue = false;
|
|
48
|
-
const
|
|
57
|
+
const columnFilterInternalApi = api.filterApi.columnFilterApi.internalApi;
|
|
49
58
|
let promise = undefined;
|
|
50
59
|
if (usePreviousValuesProbablyBecauseOfAGGridUnnecessaryFilterRemountRef.current) {
|
|
51
|
-
const previousResult =
|
|
60
|
+
const previousResult = columnFilterInternalApi
|
|
52
61
|
.getAdaptableFilterHandler(columnId)
|
|
53
62
|
?.getLastCachedFilterDisplayValues();
|
|
54
63
|
if (previousResult) {
|
|
@@ -57,7 +66,7 @@ function useDistinctFilterColumnValues(options) {
|
|
|
57
66
|
}
|
|
58
67
|
usePreviousValuesProbablyBecauseOfAGGridUnnecessaryFilterRemountRef.current = false;
|
|
59
68
|
if (!promise) {
|
|
60
|
-
promise =
|
|
69
|
+
promise = columnFilterInternalApi.getColumnFilterValues({
|
|
61
70
|
columnId,
|
|
62
71
|
get currentSearchValue() {
|
|
63
72
|
searchValueUsedInFilterValue = true;
|
|
@@ -96,6 +105,9 @@ exports.useDistinctFilterColumnValues = useDistinctFilterColumnValues;
|
|
|
96
105
|
*/
|
|
97
106
|
const FloatingFilterValues = (props) => {
|
|
98
107
|
const { api } = (0, AdaptableContext_1.useAdaptable)();
|
|
108
|
+
// const evaluateInPredicateUsingTime = useAdaptableOptions(
|
|
109
|
+
// (options) => options.predicateOptions.evaluateInPredicateUsingTime
|
|
110
|
+
// );
|
|
99
111
|
const currentColumn = api.columnApi.getColumnWithColumnId(props.columnId);
|
|
100
112
|
const searchValueRef = React.useRef('');
|
|
101
113
|
const { isDistinctColumnValuesLoading, quickFilterValues, triggerValuesLoad } = useDistinctFilterColumnValues({
|
|
@@ -112,9 +124,10 @@ const FloatingFilterValues = (props) => {
|
|
|
112
124
|
return;
|
|
113
125
|
}
|
|
114
126
|
// see 😅 usePreviousValuesProbablyBecauseOfAGGridUnnecessaryFilterRemountRef 😅
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
const filterHandler = api.filterApi.columnFilterApi.internalApi.getAdaptableFilterHandler(props.columnId);
|
|
128
|
+
const usePrevious = filterHandler && typeof filterHandler.getLastCachedFilterDisplayValues === 'function'
|
|
129
|
+
? !!filterHandler.getLastCachedFilterDisplayValues()
|
|
130
|
+
: false;
|
|
118
131
|
// however, if the `value` prop is a non-empty array, we need to load the values
|
|
119
132
|
// so we know which labels to show
|
|
120
133
|
triggerValuesLoad({
|
|
@@ -155,6 +168,20 @@ const FloatingFilterValues = (props) => {
|
|
|
155
168
|
}
|
|
156
169
|
}, []);
|
|
157
170
|
const { skipDefaultSearch } = quickFilterValues;
|
|
171
|
+
if (props.columnId === GeneralConstants_1.AG_GRID_GROUPED_COLUMN) {
|
|
172
|
+
if (Array.isArray(props.value) && !props.value.every((value) => Array.isArray(value))) {
|
|
173
|
+
logOnce(`All the inputs for the IN predicate for the column "${props.columnId}" need to be arrays. Example:
|
|
174
|
+
{
|
|
175
|
+
PredicateId: 'In',
|
|
176
|
+
Inputs: [
|
|
177
|
+
['United States'],
|
|
178
|
+
['Canada'],
|
|
179
|
+
['United Kingdom', 'England'],
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
`, (msg) => console.warn(msg));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
158
185
|
return (React.createElement(ListBoxFilterForm_1.ColumnValuesSelect, { selectProps: props.inline
|
|
159
186
|
? {
|
|
160
187
|
...props.selectProps,
|
|
@@ -187,14 +214,12 @@ const FloatingFilterValues = (props) => {
|
|
|
187
214
|
}
|
|
188
215
|
: {}),
|
|
189
216
|
},
|
|
190
|
-
onMenuOpen,
|
|
191
217
|
onInputChange,
|
|
192
218
|
}
|
|
193
219
|
: {
|
|
194
220
|
...props.selectProps,
|
|
195
221
|
skipDefaultFiltering: skipDefaultSearch,
|
|
196
|
-
onMenuOpen,
|
|
197
222
|
onInputChange,
|
|
198
|
-
}, disabled: props.disabled, isLoading: isDistinctColumnValuesLoading, column: currentColumn, dataType: currentColumn.dataType, options: quickFilterValues.values, value: props.value, onChange: props.onChange }));
|
|
223
|
+
}, disabled: props.disabled, onMenuOpen: onMenuOpen, isLoading: isDistinctColumnValuesLoading, column: currentColumn, dataType: currentColumn.dataType, options: quickFilterValues.values, value: props.value, onChange: props.onChange }));
|
|
199
224
|
};
|
|
200
225
|
exports.FloatingFilterValues = FloatingFilterValues;
|
|
@@ -12,5 +12,6 @@ export interface ColumnValuesSelectProps {
|
|
|
12
12
|
dataType: AdaptableColumnDataType;
|
|
13
13
|
isLoading?: boolean;
|
|
14
14
|
selectProps?: Partial<SelectProps<any, false>>;
|
|
15
|
+
onMenuOpen?: () => void;
|
|
15
16
|
}
|
|
16
17
|
export declare const ColumnValuesSelect: (props: ColumnValuesSelectProps) => React.JSX.Element;
|
|
@@ -8,31 +8,108 @@ const date_fns_1 = require("date-fns");
|
|
|
8
8
|
const DateHelper_1 = require("../../../Utilities/Helpers/DateHelper");
|
|
9
9
|
const join_1 = tslib_1.__importDefault(require("../../../components/utils/join"));
|
|
10
10
|
const Select_1 = require("../../../components/Select");
|
|
11
|
+
const TreeDropdown_1 = require("../../../components/Tree/TreeDropdown");
|
|
12
|
+
const GeneralConstants_1 = require("../../../Utilities/Constants/GeneralConstants");
|
|
13
|
+
const AdaptableContext_1 = require("../../AdaptableContext");
|
|
14
|
+
const react_1 = require("react");
|
|
11
15
|
const baseClassName = 'ab-ListBoxFilterForm';
|
|
16
|
+
// used for displaying the date values in the input
|
|
17
|
+
function toDateDisplayValue(values) {
|
|
18
|
+
values = values.map((v) => {
|
|
19
|
+
if (!Array.isArray(v)) {
|
|
20
|
+
return v;
|
|
21
|
+
}
|
|
22
|
+
return v[v.length - 1];
|
|
23
|
+
});
|
|
24
|
+
return (0, TreeDropdown_1.toDisplayValueDefault)(values);
|
|
25
|
+
}
|
|
26
|
+
const dateOnChangeParser = (value) => {
|
|
27
|
+
/**
|
|
28
|
+
* the value looks like this:
|
|
29
|
+
* [
|
|
30
|
+
* ["2021","2021-01","2021-01-01"],
|
|
31
|
+
* ["2024","2024-02","2024-02-15T12:34:00"],
|
|
32
|
+
* ]
|
|
33
|
+
*/
|
|
34
|
+
// so first need to transfor the above to this:
|
|
35
|
+
/**
|
|
36
|
+
* [
|
|
37
|
+
* [2023, 12, 1, 1640668800000],
|
|
38
|
+
* [2023, 12, 3, 1738377600000]
|
|
39
|
+
* ]
|
|
40
|
+
*/
|
|
41
|
+
return value.map((v) => {
|
|
42
|
+
return v[v.length - 1];
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const EMPTY_ARRAY = [];
|
|
12
46
|
const ColumnValuesSelect = (props) => {
|
|
13
47
|
const column = props.column;
|
|
14
|
-
const
|
|
48
|
+
const { api } = (0, AdaptableContext_1.useAdaptable)();
|
|
49
|
+
let selectedColumnValues = props.value || EMPTY_ARRAY;
|
|
50
|
+
const optionsFromProps = Array.isArray(props.options) ? props.options : EMPTY_ARRAY;
|
|
15
51
|
const value = [];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
52
|
+
if (column.dataType === 'date') {
|
|
53
|
+
// we might have a use-case where users might want to get rid of a tree level
|
|
54
|
+
// because it may contain only one child. currently,
|
|
55
|
+
// the value is an array of strings that have this form (ISOish)
|
|
56
|
+
// ["2021-01-01", "2021-10-02", "2021-01-03T12:00:00"]
|
|
57
|
+
// but we want the full path to each value
|
|
58
|
+
// but we can't compute that by simply splitting the strings by '-' or 'T',
|
|
59
|
+
// as if we do that, then we won't support removing a tree level
|
|
60
|
+
// so we have to compute the paths based on the options
|
|
61
|
+
const valueToPath = (0, react_1.useMemo)(() => {
|
|
62
|
+
const valueToPath = new Map();
|
|
63
|
+
const withOption = (option, parentPath = []) => {
|
|
64
|
+
const optionPath = [...parentPath, option.value];
|
|
65
|
+
valueToPath.set(option.value, optionPath);
|
|
66
|
+
if (Array.isArray(option.children)) {
|
|
67
|
+
option.children.forEach((child) => withOption(child, optionPath));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
optionsFromProps.forEach((option) => withOption(option, []));
|
|
71
|
+
return valueToPath;
|
|
72
|
+
}, [optionsFromProps]);
|
|
73
|
+
selectedColumnValues = selectedColumnValues
|
|
74
|
+
.map((v) => {
|
|
75
|
+
return valueToPath.get(v);
|
|
76
|
+
})
|
|
77
|
+
.filter(Boolean);
|
|
78
|
+
}
|
|
79
|
+
const options = column.dataType === 'date' || column.columnId === GeneralConstants_1.AG_GRID_GROUPED_COLUMN
|
|
80
|
+
? optionsFromProps
|
|
81
|
+
: optionsFromProps.filter((distinctValue) => {
|
|
82
|
+
let isActive = selectedColumnValues.indexOf(distinctValue.value) >= 0;
|
|
83
|
+
// special case for date objects, need to check against string values
|
|
84
|
+
if (!isActive && distinctValue.value && distinctValue.value instanceof Date) {
|
|
85
|
+
isActive = selectedColumnValues.some((dateStr) => (0, date_fns_1.isEqual)((0, DateHelper_1.parseDateValue)(dateStr), (0, DateHelper_1.parseDateValue)(distinctValue.value)));
|
|
86
|
+
}
|
|
87
|
+
if (StringExtensions_1.StringExtensions.IsNullOrEmpty(distinctValue.value)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (isActive) {
|
|
91
|
+
value.push(distinctValue.value);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
});
|
|
30
95
|
const menuStyle = React.useMemo(() => {
|
|
31
96
|
return {
|
|
32
97
|
minWidth: `var(--ab-cmp-select-column-menu-${column.columnId}__min-width, var(--ab-cmp-select-column-menu__min-width, 160px))`,
|
|
33
98
|
};
|
|
34
99
|
}, [column.columnId]);
|
|
35
|
-
const component =
|
|
100
|
+
const component = column.dataType === 'date' || column.columnId === GeneralConstants_1.AG_GRID_GROUPED_COLUMN ? (React.createElement(TreeDropdown_1.TreeDropdown, { style: {
|
|
101
|
+
width: '100%',
|
|
102
|
+
height: '100%',
|
|
103
|
+
...props.selectProps?.styles?.container,
|
|
104
|
+
}, toDisplayValue: column.dataType === 'date' ? toDateDisplayValue : undefined, fieldStyle: {
|
|
105
|
+
boxShadow: 'none',
|
|
106
|
+
...props.selectProps?.styles?.control,
|
|
107
|
+
}, resizable: true, onChange: column.dataType === 'date'
|
|
108
|
+
? (value) => props.onChange(dateOnChangeParser(value))
|
|
109
|
+
: props.onChange, options: options,
|
|
110
|
+
// for dates, the treeDateOptions have ids that are numbers
|
|
111
|
+
// so we have to add the `toDateValue` function to convert the values to the correct format
|
|
112
|
+
value: selectedColumnValues, primaryKey: 'value', onMenuOpen: props.onMenuOpen, onMouseDown: (e) => e.stopPropagation() })) : (React.createElement(Select_1.Select, { key: "select", isMulti: true, resizable: true, showHeaderSelectionCheckbox: true, searchable: 'menulist', closeMenuOnSelect: false, menuStyle: menuStyle, ...props.selectProps, onMenuOpen: props.onMenuOpen, options: options, value: value, isLoading: props.isLoading, onChange: props.onChange }));
|
|
36
113
|
return (React.createElement("div", { className: (0, join_1.default)(baseClassName, props.isLoading && `${baseClassName}--loading`, !value.length && `${baseClassName}--empty`), onKeyDownCapture: (e) => {
|
|
37
114
|
const event = e.nativeEvent || e;
|
|
38
115
|
event.stopPropagation = () => {
|
|
@@ -255,7 +255,7 @@ const ColumnsSection = (props) => {
|
|
|
255
255
|
// however, changes in RowGroupedColumns done in the previous step
|
|
256
256
|
// are reflected into the layout, so we use the latest layout.RowGroupedColumns
|
|
257
257
|
// to create new columns
|
|
258
|
-
if (layout.RowGroupedColumns) {
|
|
258
|
+
if (layout.RowGroupedColumns && layout.RowGroupedColumns.length > 0) {
|
|
259
259
|
if (layout.RowGroupDisplayType === 'single') {
|
|
260
260
|
allColumns.unshift((0, ColumnApiImpl_1.generateAutoRowGroupSingleColumn)());
|
|
261
261
|
}
|
|
@@ -7,9 +7,11 @@ const react_redux_1 = require("react-redux");
|
|
|
7
7
|
const styled_components_1 = require("styled-components");
|
|
8
8
|
const theme_1 = tslib_1.__importDefault(require("../theme"));
|
|
9
9
|
const AdaptableContext_1 = tslib_1.__importDefault(require("./AdaptableContext"));
|
|
10
|
+
const AdaptableComputedCSSVarsContext_1 = require("./AdaptableComputedCSSVarsContext");
|
|
10
11
|
const renderWithAdaptableContext = (children, adaptable) => {
|
|
11
12
|
return (React.createElement(react_redux_1.Provider, { store: adaptable.adaptableStore.TheStore },
|
|
12
13
|
React.createElement(styled_components_1.ThemeProvider, { theme: theme_1.default },
|
|
13
|
-
React.createElement(
|
|
14
|
+
React.createElement(AdaptableComputedCSSVarsContext_1.WithAdaptableComputedCSSVars, null,
|
|
15
|
+
React.createElement(AdaptableContext_1.default.Provider, { value: adaptable }, children)))));
|
|
14
16
|
};
|
|
15
17
|
exports.renderWithAdaptableContext = renderWithAdaptableContext;
|
|
@@ -26,7 +26,7 @@ import { RenderReactRootFn } from '../renderReactRoot';
|
|
|
26
26
|
import { AgGridOptionsService } from './AgGridOptionsService';
|
|
27
27
|
import { AgGridColumnAdapter } from './AgGridColumnAdapter';
|
|
28
28
|
import { RowFormService } from '../Utilities/Services/RowFormService';
|
|
29
|
-
import { GridCellWithCount } from '../AdaptableState/Selection/GridCell';
|
|
29
|
+
import { GridCellWithCount, GridCellWithChildren } from '../AdaptableState/Selection/GridCell';
|
|
30
30
|
import { FlashingCellService } from '../Utilities/Services/FlashingCellService';
|
|
31
31
|
import { AgGridExportAdapter } from './AgGridExportAdapter';
|
|
32
32
|
import { PivotLayoutModel, TableLayoutModel } from '../layout-manager/src/LayoutManagerModel';
|
|
@@ -266,6 +266,8 @@ export declare class AdaptableAgGrid implements IAdaptable {
|
|
|
266
266
|
currentSearchValue: string;
|
|
267
267
|
gridCell?: GridCell;
|
|
268
268
|
}): Promise<EditColumnValueInfo[]>;
|
|
269
|
+
getDistinctGridCellsForGroupedColumn(rowNodes?: IRowNode[]): GridCellWithChildren[];
|
|
270
|
+
getDistinctGridCellsForDateColumn(column: AdaptableColumn, rowNodes?: IRowNode[]): GridCellWithChildren[];
|
|
269
271
|
getDistinctGridCellsForColumn(column: AdaptableColumn, rowNodes?: IRowNode[]): GridCellWithCount[];
|
|
270
272
|
private addDistinctColumnValue;
|
|
271
273
|
private getUniqueGridCells;
|