@adaptabletools/adaptable 21.0.0-canary.2 → 21.0.0-canary.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable",
3
- "version": "21.0.0-canary.2",
3
+ "version": "21.0.0-canary.4",
4
4
  "description": "Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
5
5
  "keywords": [
6
6
  "web-components",
@@ -26,7 +26,7 @@ export interface FilterOptions<TData = any> {
26
26
  */
27
27
  clearFiltersOnStartUp?: boolean;
28
28
  /**
29
- * Provide custom values (or sorting / count info) when using the `In` Filter
29
+ * Provide custom values (or sorting / count info) when using `In` Predicate in Column or Grid Filter
30
30
  * @param context
31
31
  * @returns
32
32
  */
@@ -208,17 +208,16 @@ export interface InFilterValue<ValueType = any> {
208
208
  /**
209
209
  * Result when providing custom values for the IN Column Filter
210
210
  */
211
- export type InFilterValueResult = {
211
+ export interface InFilterValueResult {
212
212
  /**
213
213
  * List of Items to display in the IN Column Filter
214
214
  */
215
- values: InFilterValueInfo[];
215
+ values: InFilterValue[];
216
216
  /**
217
- * When TRUE, displays the provided values without any filtering.
218
- * When FALSE, the values are filtered based on the current search text.
217
+ * If true, AdapTable will not filter the list using the current search value
219
218
  */
220
219
  skipDefaultSearch?: boolean;
221
- };
220
+ }
222
221
  /**
223
222
  * Information about items in the IN Column Filter
224
223
  */
@@ -249,11 +248,11 @@ export interface CustomInFilterValuesContext<TData = any> extends AdaptableColum
249
248
  */
250
249
  defaultValues: Required<InFilterValueInfo>[];
251
250
  /**
252
- * Default values but Sorted based on Column's sort
251
+ * Default values but sorted (if Column is sorted)
253
252
  */
254
253
  sortedValues: Required<InFilterValueInfo>[];
255
254
  /**
256
- * Default values but in the order in which they are currently listed in the grid - (after all the sorting has been applied, or, if no sorting, in their natural order)
255
+ * Default values in order which currently listed in the grid
257
256
  */
258
257
  orderedValues: Required<InFilterValueInfo>[];
259
258
  /**
@@ -261,8 +260,7 @@ export interface CustomInFilterValuesContext<TData = any> extends AdaptableColum
261
260
  */
262
261
  currentSearchValue: string;
263
262
  /**
264
- * Memoized result from previous invocation. Helps avoid expensive recomputations,
265
- * especially for async operations (e.g. server-side filtering).
263
+ * Previous filter result; avoids expensive recomputations (e.g for async op or server-side filtering)
266
264
  */
267
265
  previousFilterResult?: InFilterValueResult;
268
266
  }
@@ -55,5 +55,6 @@ export declare class ColumnFilterInternalApi extends ApiBase {
55
55
  currentSearchValue: string;
56
56
  }): Promise<InFilterValueResult>;
57
57
  shouldAutoApplyColumnFilter(columnId: string): boolean;
58
+ getAdaptableFilterHandler(columnId: string): AdaptableFilterHandler | undefined;
58
59
  getAllAdaptableFilterHandlers(): AdaptableFilterHandler[];
59
60
  }
@@ -254,14 +254,14 @@ export class ColumnFilterInternalApi extends ApiBase {
254
254
  this.logWarn(`No ColumnFilterHandler found for columnId: ${options.columnId}!`);
255
255
  return this.getGridApi().internalApi.getDistinctFilterDisplayValuesForColumn(newOptions);
256
256
  }
257
- if (typeof columnFilterHandler.getFilterDisplayValuesFromCache !== 'function') {
258
- this.logWarn(`ColumnFilterHandler for columnId: ${options.columnId} does not have getFilterDisplayValuesFromCache method!`);
257
+ if (typeof columnFilterHandler.getFromCacheOrFetchFilterDisplayValues !== 'function') {
258
+ this.logWarn(`ColumnFilterHandler for columnId: ${options.columnId} does not have getFromCacheOrFetchFilterDisplayValues method!`);
259
259
  return this.getGridApi().internalApi.getDistinctFilterDisplayValuesForColumn(newOptions);
260
260
  }
261
261
  if (filterOptions.customInFilterValues) {
262
262
  return columnFilterHandler.fetchFilterDisplayValues(newOptions);
263
263
  }
264
- return columnFilterHandler.getFilterDisplayValuesFromCache(newOptions);
264
+ return columnFilterHandler.getFromCacheOrFetchFilterDisplayValues(newOptions);
265
265
  }
266
266
  shouldAutoApplyColumnFilter(columnId) {
267
267
  const autoApplyColumnFilterOpt = this.getOptionsApi().getFilterOptions().columnFilterOptions?.autoApplyColumnFilter;
@@ -279,6 +279,9 @@ export class ColumnFilterInternalApi extends ApiBase {
279
279
  // fallback, should never happen
280
280
  return true;
281
281
  }
282
+ getAdaptableFilterHandler(columnId) {
283
+ return this.getAgGridApi().getColumnFilterHandler(columnId);
284
+ }
282
285
  getAllAdaptableFilterHandlers() {
283
286
  const allFilterableColumns = this.getColumnApi().getFilterableColumns();
284
287
  const filterHandlers = allFilterableColumns
@@ -37,7 +37,9 @@ export declare function useDistinctFilterColumnValues(options: {
37
37
  skipDefaultSearch: boolean;
38
38
  searchValueUsedInFilterValue: boolean;
39
39
  }>>;
40
- triggerValuesLoad: () => void;
40
+ triggerValuesLoad: (options?: {
41
+ usePrevious: boolean;
42
+ }) => void;
41
43
  };
42
44
  /**
43
45
  * This component was ported and modified to not know about colum filter and predicates.
@@ -20,7 +20,10 @@ export function useDistinctFilterColumnValues(options) {
20
20
  const { columnId, searchValueRef } = options;
21
21
  const { api } = useAdaptable();
22
22
  const [valuesLoadTrigger, setValuesLoadTrigger] = React.useState(0);
23
- const triggerValuesLoad = React.useCallback(() => {
23
+ const usePreviousValuesProbablyBecauseOfAGGridUnnecessaryFilterRemountRef = React.useRef(false);
24
+ const triggerValuesLoad = React.useCallback((options) => {
25
+ usePreviousValuesProbablyBecauseOfAGGridUnnecessaryFilterRemountRef.current =
26
+ !!options?.usePrevious;
24
27
  setValuesLoadTrigger((prev) => prev + 1);
25
28
  }, []);
26
29
  const [quickFilterValues, setQuickFilterValues] = React.useState({
@@ -38,15 +41,27 @@ export function useDistinctFilterColumnValues(options) {
38
41
  let ignore = false;
39
42
  setIsDistinctColumnValuesLoading(true);
40
43
  let searchValueUsedInFilterValue = false;
41
- api.filterApi.columnFilterApi.internalApi
42
- .getColumnFilterValues({
43
- columnId,
44
- get currentSearchValue() {
45
- searchValueUsedInFilterValue = true;
46
- return searchValueRef ? searchValueRef.current : '';
47
- },
48
- })
49
- .then((distinctFilterDisplayValues) => {
44
+ const columnFilterinternalApi = api.filterApi.columnFilterApi.internalApi;
45
+ let promise = undefined;
46
+ if (usePreviousValuesProbablyBecauseOfAGGridUnnecessaryFilterRemountRef.current) {
47
+ const previousResult = columnFilterinternalApi
48
+ .getAdaptableFilterHandler(columnId)
49
+ ?.getLastCachedFilterDisplayValues();
50
+ if (previousResult) {
51
+ promise = Promise.resolve(previousResult);
52
+ }
53
+ }
54
+ usePreviousValuesProbablyBecauseOfAGGridUnnecessaryFilterRemountRef.current = false;
55
+ if (!promise) {
56
+ promise = columnFilterinternalApi.getColumnFilterValues({
57
+ columnId,
58
+ get currentSearchValue() {
59
+ searchValueUsedInFilterValue = true;
60
+ return searchValueRef ? searchValueRef.current : '';
61
+ },
62
+ });
63
+ }
64
+ promise.then((distinctFilterDisplayValues) => {
50
65
  if (ignore) {
51
66
  return;
52
67
  }
@@ -91,9 +106,15 @@ export const FloatingFilterValues = (props) => {
91
106
  if (!value || !Array.isArray(value) || value.length === 0) {
92
107
  return;
93
108
  }
109
+ // see 😅 usePreviousValuesProbablyBecauseOfAGGridUnnecessaryFilterRemountRef 😅
110
+ const usePrevious = !!api.filterApi.columnFilterApi.internalApi
111
+ .getAdaptableFilterHandler(props.columnId)
112
+ ?.getLastCachedFilterDisplayValues();
94
113
  // however, if the `value` prop is a non-empty array, we need to load the values
95
114
  // so we know which labels to show
96
- triggerValuesLoad();
115
+ triggerValuesLoad({
116
+ usePrevious,
117
+ });
97
118
  }, []);
98
119
  const quickFilterValuesRef = React.useRef(quickFilterValues);
99
120
  quickFilterValuesRef.current = quickFilterValues;
@@ -9,7 +9,7 @@ export const ColumnValuesSelect = (props) => {
9
9
  const column = props.column;
10
10
  const selectedColumnValues = props.value || [];
11
11
  const value = [];
12
- const options = props.options.filter((distinctValue, index) => {
12
+ const options = (Array.isArray(props.options) ? props.options : []).filter((distinctValue) => {
13
13
  let isActive = selectedColumnValues.indexOf(distinctValue.value) >= 0;
14
14
  // special case for date objects, need to check against string values
15
15
  if (!isActive && distinctValue.value && distinctValue.value instanceof Date) {
@@ -6,9 +6,12 @@ export declare class AdaptableFilterHandler implements FilterHandler {
6
6
  private adaptableApi;
7
7
  readonly colId: string;
8
8
  private filterDisplayValuesResult;
9
+ private previousFilterDisplayValuesResult;
9
10
  constructor(adaptableApi: AdaptableApi, columnSetup: ColumnSetupInfo);
10
11
  doesFilterPass(params: DoesFilterPassParams): boolean;
11
- getFilterDisplayValuesFromCache(options: {
12
+ getCachedFilterDisplayValues(): InFilterValueResult | undefined;
13
+ getLastCachedFilterDisplayValues(): InFilterValueResult | undefined;
14
+ getFromCacheOrFetchFilterDisplayValues(options: {
12
15
  currentSearchValue: string;
13
16
  }): Promise<InFilterValueResult>;
14
17
  fetchFilterDisplayValues(options: {
@@ -27,7 +27,13 @@ export class AdaptableFilterHandler {
27
27
  return false;
28
28
  }
29
29
  }
30
- getFilterDisplayValuesFromCache(options) {
30
+ getCachedFilterDisplayValues() {
31
+ return this.filterDisplayValuesResult;
32
+ }
33
+ getLastCachedFilterDisplayValues() {
34
+ return this.filterDisplayValuesResult ?? this.previousFilterDisplayValuesResult;
35
+ }
36
+ getFromCacheOrFetchFilterDisplayValues(options) {
31
37
  if (this.filterDisplayValuesResult) {
32
38
  return Promise.resolve(this.filterDisplayValuesResult);
33
39
  }
@@ -61,12 +67,15 @@ export class AdaptableFilterHandler {
61
67
  this.resetFilterDisplayValues();
62
68
  }
63
69
  resetFilterDisplayValues() {
70
+ if (this.filterDisplayValuesResult) {
71
+ this.previousFilterDisplayValuesResult = this.filterDisplayValuesResult;
72
+ }
64
73
  // Reset the filter display values manually
65
74
  this.filterDisplayValuesResult = undefined;
66
75
  }
67
76
  async refreshFilterDisplayValues() {
68
77
  this.resetFilterDisplayValues();
69
- return this.getFilterDisplayValuesFromCache({ currentSearchValue: '' });
78
+ return this.getFromCacheOrFetchFilterDisplayValues({ currentSearchValue: '' });
70
79
  }
71
80
  refresh(params) {
72
81
  // No specific refresh logic needed for this handler
@@ -74,5 +83,6 @@ export class AdaptableFilterHandler {
74
83
  }
75
84
  destroy() {
76
85
  this.filterDisplayValuesResult = undefined;
86
+ this.previousFilterDisplayValuesResult = undefined;
77
87
  }
78
88
  }
@@ -5,7 +5,6 @@ export declare const ensureLoadingScreenPortalElement: () => HTMLElement;
5
5
  export interface ModalProps extends FlexProps {
6
6
  isOpen?: boolean;
7
7
  baseZIndex?: number;
8
- backdropZIndexOffset?: number;
9
8
  onBringToFront?: () => void;
10
9
  }
11
10
  export declare const Modal: React.FunctionComponent<React.PropsWithChildren<ModalProps>>;
@@ -7,6 +7,7 @@ import { Flex } from 'rebass';
7
7
  import { baseClassName, default as Backdrop } from './Backdrop';
8
8
  import { createUuid } from '../utils/uuid';
9
9
  import { isBrowserDocumentAvailable } from '../../View/UIHelper';
10
+ import { useStacking } from '../WindowModal/useStacking';
10
11
  let portalElement;
11
12
  let loadingScreenPortalElement;
12
13
  export const ensurePortalElement = () => {
@@ -38,8 +39,9 @@ export const Modal = (props) => {
38
39
  const uuid = useMemo(() => createUuid(), []);
39
40
  const counter = useMemo(() => globalCounter++, [isOpen]);
40
41
  const openTimestamp = counter;
41
- const backdropZIndexOffset = props.backdropZIndexOffset || 1;
42
- const zIndex = (props.baseZIndex || 2000) + counter;
42
+ const backdropZIndexOffset = 1;
43
+ const stacking = useStacking();
44
+ const zIndex = stacking.zIndex;
43
45
  return createPortal(isOpen ? (React.createElement(React.Fragment, null,
44
46
  React.createElement(Backdrop, { timestamp: openTimestamp, uuid: uuid, zIndex: zIndex - backdropZIndexOffset, onBringToFront: onBringToFront }),
45
47
  React.createElement(RemoveScroll, null,
@@ -13,6 +13,7 @@ import contains from '../utils/contains';
13
13
  import { isBrowserDocumentAvailable } from '../../View/UIHelper';
14
14
  import { useOverlay } from '../InfiniteTable';
15
15
  import { useAdaptable } from '../../View/AdaptableContext';
16
+ import { OVERLAY_BASE_Z_INDEX } from '../overlayBaseZIndex';
16
17
  export const getConstrainElement = (target, constrainTo) => {
17
18
  let el = null;
18
19
  if (typeof constrainTo === 'string') {
@@ -31,6 +32,7 @@ export const getConstrainRect = (target, constrainTo) => {
31
32
  return getDocRect();
32
33
  };
33
34
  let portalElement;
35
+ const OVERLAY_TRIGGER_Z_INDEX = OVERLAY_BASE_Z_INDEX;
34
36
  const ensurePortalElement = () => {
35
37
  if (!isBrowserDocumentAvailable()) {
36
38
  return;
@@ -40,7 +42,7 @@ const ensurePortalElement = () => {
40
42
  }
41
43
  portalElement = document.createElement('div');
42
44
  portalElement.style.position = 'absolute';
43
- portalElement.style.zIndex = '9999999';
45
+ portalElement.style.zIndex = OVERLAY_TRIGGER_Z_INDEX.toString();
44
46
  portalElement.style.top = '0px';
45
47
  portalElement.style.left = '0px';
46
48
  document.body.appendChild(portalElement);
@@ -9,6 +9,7 @@ import { useCallback, useMemo, useState } from 'react';
9
9
  import join from '../utils/join';
10
10
  import { Resizable } from 're-resizable';
11
11
  import Tooltip from '../Tooltip';
12
+ import { OVERLAY_BASE_Z_INDEX } from '../overlayBaseZIndex';
12
13
  const resizableDirections = {
13
14
  right: true,
14
15
  bottom: true,
@@ -533,7 +534,7 @@ export const Select = function (props) {
533
534
  menuPortal: (baseStyle) => {
534
535
  return {
535
536
  ...baseStyle,
536
- zIndex: 999999,
537
+ zIndex: OVERLAY_BASE_Z_INDEX,
537
538
  textAlign: 'left',
538
539
  };
539
540
  },
@@ -541,7 +542,7 @@ export const Select = function (props) {
541
542
  menu: (baseStyle, state) => {
542
543
  return {
543
544
  ...baseStyle,
544
- zIndex: 999999,
545
+ zIndex: OVERLAY_BASE_Z_INDEX,
545
546
  boxShadow: 'var(--ab-cmp-select-menu__box-shadow)',
546
547
  minWidth: `var(--ab-cmp-select-menu__min-width)`,
547
548
  width: resizable ? '100%' : `${Math.max(maxLabelLength, 10)}ch`,
@@ -4,6 +4,15 @@ const setZIndexMap = {};
4
4
  const zIndexMap = [];
5
5
  // starts with 3000, to be above the default zIndex of the Modal component
6
6
  const BASE_Z_INDEX = 3000;
7
+ const Z_INDEX_GAP = 5;
8
+ let GLOBAL_COUNTER = 0;
9
+ const getNewOffset = () => {
10
+ const counter = GLOBAL_COUNTER++;
11
+ return counter * Z_INDEX_GAP;
12
+ };
13
+ const getNewZIndex = () => {
14
+ return BASE_Z_INDEX + getNewOffset();
15
+ };
7
16
  /**
8
17
  * Used to facilitate the stacking between multiple opened windows.
9
18
  * When calling 'bringToFront' brings caller to top.
@@ -11,7 +20,7 @@ const BASE_Z_INDEX = 3000;
11
20
  */
12
21
  export const useStacking = () => {
13
22
  const modalZIndexId = React.useMemo(() => createUuid(), []);
14
- const [zIndex, setZIndex] = React.useState(BASE_Z_INDEX);
23
+ const [zIndex, setZIndex] = React.useState(getNewZIndex);
15
24
  React.useEffect(() => {
16
25
  setZIndexMap[modalZIndexId] = setZIndex;
17
26
  return () => {
@@ -30,8 +39,8 @@ export const useStacking = () => {
30
39
  else {
31
40
  zIndexMap.push(modalZIndexId);
32
41
  }
33
- zIndexMap.forEach((id, index) => {
34
- setZIndexMap?.[id]?.(BASE_Z_INDEX + index * 10);
42
+ zIndexMap.forEach((id) => {
43
+ setZIndexMap?.[id]?.(getNewZIndex());
35
44
  });
36
45
  }, []);
37
46
  return {
@@ -0,0 +1 @@
1
+ export declare const OVERLAY_BASE_Z_INDEX = 9999999;
@@ -0,0 +1 @@
1
+ export const OVERLAY_BASE_Z_INDEX = 9999999;
package/src/env.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export default {
2
2
  NEXT_PUBLIC_INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
3
- PUBLISH_TIMESTAMP: 1756992459408 || Date.now(),
4
- VERSION: "21.0.0-canary.2" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1757087858380 || Date.now(),
4
+ VERSION: "21.0.0-canary.4" || '--current-version--',
5
5
  };
@@ -2464,11 +2464,19 @@ export declare const ADAPTABLE_METAMODEL: {
2464
2464
  name: string;
2465
2465
  kind: string;
2466
2466
  desc: string;
2467
- props: {
2467
+ props: ({
2468
2468
  name: string;
2469
2469
  kind: string;
2470
2470
  desc: string;
2471
- }[];
2471
+ isOpt?: undefined;
2472
+ ref?: undefined;
2473
+ } | {
2474
+ name: string;
2475
+ kind: string;
2476
+ desc: string;
2477
+ isOpt: boolean;
2478
+ ref: string;
2479
+ })[];
2472
2480
  };
2473
2481
  CustomQueryVariableContext: {
2474
2482
  name: string;
@@ -4086,6 +4094,22 @@ export declare const ADAPTABLE_METAMODEL: {
4086
4094
  isOpt: boolean;
4087
4095
  }[];
4088
4096
  };
4097
+ InFilterValueResult: {
4098
+ name: string;
4099
+ kind: string;
4100
+ desc: string;
4101
+ props: ({
4102
+ name: string;
4103
+ kind: string;
4104
+ desc: string;
4105
+ isOpt: boolean;
4106
+ } | {
4107
+ name: string;
4108
+ kind: string;
4109
+ desc: string;
4110
+ isOpt?: undefined;
4111
+ })[];
4112
+ };
4089
4113
  InitialState: {
4090
4114
  name: string;
4091
4115
  kind: string;