@adaptabletools/adaptable 20.1.3 → 20.1.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.
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import OverlayTrigger from '../OverlayTrigger';
3
- import { useEffect, useState } from 'react';
3
+ import { useCallback, useEffect, useRef, useState } from 'react';
4
4
  import useProperty from '../utils/useProperty';
5
5
  import FieldWrap from '../FieldWrap';
6
6
  import SimpleButton from '../SimpleButton';
@@ -10,9 +10,45 @@ import { useDatepickerContext } from './DatepickerContext';
10
10
  import { DayPicker } from 'react-day-picker';
11
11
  import { AdaptableDateInlineInput } from '../../View/Components/AdaptableInput/AdaptableDateInlineInput';
12
12
  import { isValid, addYears, endOfYear, startOfYear, addDays, addBusinessDays, } from 'date-fns';
13
- const DatepickerOverlay = ({ onHide, children, onKeyDown, onMouseDown, }) => {
13
+ import { Select } from '../Select';
14
+ const onDatePickerDropdownKeyDown = (e) => {
15
+ if (e.key === 'Escape' || e.key === 'Enter') {
16
+ e.stopPropagation();
17
+ }
18
+ };
19
+ const DatePickerComponents = {
20
+ YearsDropdown: (props) => {
21
+ const onChange = useCallback((value) => {
22
+ props.onChange?.({
23
+ target: {
24
+ value,
25
+ },
26
+ });
27
+ }, [props.onChange]);
28
+ return (React.createElement(Select, { onKeyDown: onDatePickerDropdownKeyDown, value: props.value, onChange: onChange, options: props.options }));
29
+ },
30
+ MonthsDropdown: (props) => {
31
+ const onChange = useCallback((value) => {
32
+ props.onChange?.({
33
+ target: {
34
+ value,
35
+ },
36
+ });
37
+ }, [props.onChange]);
38
+ return (React.createElement(Select, { onKeyDown: onDatePickerDropdownKeyDown, value: `${props.value}`, onChange: onChange, options: props.options.map((option) => {
39
+ return {
40
+ label: option.label,
41
+ value: `${option.value}`,
42
+ };
43
+ }) }));
44
+ },
45
+ };
46
+ const DatepickerOverlay = ({ onHide, children, onKeyDown, onMouseDown, overlayDOMRef, }) => {
14
47
  const domRef = React.useRef(null);
15
- return (React.createElement("div", { className: "ab-Datepicker-Overlay", ref: domRef, onKeyDown: onKeyDown, onMouseDown: onMouseDown, onBlur: (e) => {
48
+ return (React.createElement("div", { className: "ab-Datepicker-Overlay", tabIndex: -1, ref: (el) => {
49
+ domRef.current = el;
50
+ overlayDOMRef.current = el;
51
+ }, onKeyDown: onKeyDown, onMouseDown: onMouseDown, onBlur: (e) => {
16
52
  const { relatedTarget } = e;
17
53
  const node = domRef.current;
18
54
  // relatedTarget is the newly focused element as a result of this blur event
@@ -74,13 +110,14 @@ export const Datepicker = React.forwardRef((props, ref) => {
74
110
  clearValue();
75
111
  }, accessLevel: 'Full' })) : null;
76
112
  const calendarButton = (React.createElement(SimpleButton, { disabled: disabled, variant: "text", icon: "calendar", tooltip: "Date", iconSize: 20, px: 0, py: 0, onClick: () => setVisible(true) }));
113
+ const overlayDOMRef = useRef(null);
77
114
  return (React.createElement(Flex, null,
78
- React.createElement(OverlayTrigger, { visible: visible, render: () => (React.createElement(DatepickerOverlay, { onMouseDown: props.onMouseDown, onHide: () => setVisible(false), onKeyDown: (e) => {
115
+ React.createElement(OverlayTrigger, { visible: visible, render: () => (React.createElement(DatepickerOverlay, { overlayDOMRef: overlayDOMRef, onMouseDown: props.onMouseDown, onHide: () => setVisible(false), onKeyDown: (e) => {
79
116
  if (e.key === 'Escape' || e.key === 'Enter') {
80
117
  setVisible(false, e.key);
81
118
  }
82
119
  } },
83
- React.createElement(DayPicker, { fixedWeeks: true, autoFocus: autoFocus ?? true, showWeekNumber: showWeekNumber, showOutsideDays: showOutsideDays, mode: "single", captionLayout: "dropdown", month: isNaN(+month) ? new Date() : month, selected: value, onMonthChange: setMonth, onSelect: updateValue, startMonth: START_MONTH, endMonth: END_MONTH, footer: React.createElement(Flex, { justifyContent: "space-between", mt: 2, flexWrap: 'wrap' }, footerButtons) }))) },
120
+ React.createElement(DayPicker, { fixedWeeks: true, autoFocus: autoFocus ?? true, showWeekNumber: showWeekNumber, showOutsideDays: showOutsideDays, mode: "single", captionLayout: "dropdown", month: isNaN(+month) ? new Date() : month, selected: value, onMonthChange: setMonth, onSelect: updateValue, startMonth: START_MONTH, endMonth: END_MONTH, components: DatePickerComponents, footer: React.createElement(Flex, { justifyContent: "space-between", mt: 2, flexWrap: 'wrap' }, footerButtons) }))) },
84
121
  React.createElement(FieldWrap, { ...boxProps, style: {
85
122
  borderRadius: style?.borderRadius,
86
123
  width: style?.width,
@@ -90,6 +127,14 @@ export const Datepicker = React.forwardRef((props, ref) => {
90
127
  if (!visible) {
91
128
  setVisible(true);
92
129
  }
130
+ }, onBlur: (e) => {
131
+ const { relatedTarget } = e;
132
+ const overlayDOMNode = overlayDOMRef.current;
133
+ if ((overlayDOMNode && relatedTarget == overlayDOMNode) ||
134
+ overlayDOMNode?.contains(relatedTarget)) {
135
+ return;
136
+ }
137
+ setVisible(false);
93
138
  } },
94
139
  React.createElement(AdaptableDateInlineInput, { ref: ref, value: inputValue,
95
140
  // We do not want to show the format when the date-picker is visible
@@ -47,5 +47,6 @@ export type SelectProps<SelectValue extends unknown, IsMulti extends boolean = f
47
47
  size?: 'small' | 'normal';
48
48
  isCreatable?: boolean;
49
49
  menuPortalTarget?: HTMLElement;
50
+ onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
50
51
  };
51
52
  export declare const Select: <SelectValue extends unknown, IsMulti extends boolean = false>(props: SelectProps<SelectValue, IsMulti>) => React.JSX.Element;
@@ -365,7 +365,7 @@ export const Select = function (props) {
365
365
  setInputValue(value);
366
366
  props.onInputChange?.(value);
367
367
  }, [props.onInputChange, isMulti]);
368
- return (React.createElement(SelectComponent, { ref: ref, "aria-label": props['aria-label'], inputValue: inputValue, onInputChange: onInputChange, onFocus: onFocus, onBlur: onBlur, onMenuOpen: props.onMenuOpen, isLoading: props.isLoading, options: props.options, className: join(props.className, 'ab-Select'), isDisabled: disabled, menuPlacement: props.menuPlacement ?? 'auto', isSearchable: props.searchable, hideSelectedOptions: false, isMulti: isMulti, value: selectedOption, blurInputOnSelect: false, menuPosition: props.menuPosition ?? 'absolute',
368
+ return (React.createElement(SelectComponent, { ref: ref, "aria-label": props['aria-label'], onKeyDown: props.onKeyDown, inputValue: inputValue, onInputChange: onInputChange, onFocus: onFocus, onBlur: onBlur, onMenuOpen: props.onMenuOpen, isLoading: props.isLoading, options: props.options, className: join(props.className, 'ab-Select'), isDisabled: disabled, menuPlacement: props.menuPlacement ?? 'auto', isSearchable: props.searchable, hideSelectedOptions: false, isMulti: isMulti, value: selectedOption, blurInputOnSelect: false, menuPosition: props.menuPosition ?? 'absolute',
369
369
  // This needed so the menu is not clipped by overflow: hidden
370
370
  menuPortalTarget: props.menuPortalTarget === undefined ? document.body : null, isClearable: props.isClearable, closeMenuOnSelect: props.closeMenuOnSelect, onChange: (option) => {
371
371
  if (isMulti) {
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: 1747298992714 || Date.now(),
4
- VERSION: "20.1.3" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1747747693470 || Date.now(),
4
+ VERSION: "20.1.4" || '--current-version--',
5
5
  };
@@ -443,6 +443,16 @@ export declare const ADAPTABLE_METAMODEL: {
443
443
  kind: string;
444
444
  desc: string;
445
445
  };
446
+ AdaptableFilterState: {
447
+ name: string;
448
+ kind: string;
449
+ desc: string;
450
+ props: {
451
+ name: string;
452
+ kind: string;
453
+ desc: string;
454
+ }[];
455
+ };
446
456
  AdaptableFlashingCell: {
447
457
  name: string;
448
458
  kind: string;
@@ -879,16 +889,6 @@ export declare const ADAPTABLE_METAMODEL: {
879
889
  desc: string;
880
890
  }[];
881
891
  };
882
- AdaptableSearchState: {
883
- name: string;
884
- kind: string;
885
- desc: string;
886
- props: {
887
- name: string;
888
- kind: string;
889
- desc: string;
890
- }[];
891
- };
892
892
  AdaptableSettingsPanel: {
893
893
  name: string;
894
894
  kind: string;