@adaptabletools/adaptable-cjs 21.0.1 → 21.0.3

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.
@@ -14,6 +14,7 @@ const join_1 = tslib_1.__importDefault(require("../utils/join"));
14
14
  const re_resizable_1 = require("re-resizable");
15
15
  const Tooltip_1 = tslib_1.__importDefault(require("../Tooltip"));
16
16
  const OverlayTrigger_1 = require("../OverlayTrigger");
17
+ const CSSNumericVariableWatch_1 = require("./CSSNumericVariableWatch");
17
18
  const resizableDirections = {
18
19
  right: true,
19
20
  bottom: true,
@@ -28,8 +29,8 @@ const checkboxStyle = {
28
29
  };
29
30
  const INFINITE_DOM_PROPS = {
30
31
  style: {
31
- height: '100%',
32
- minHeight: `var(--ab-cmp-select-menu__min-height, 25rem)`,
32
+ // height: '100%',
33
+ flex: 1,
33
34
  // maxHeight: '50vh',
34
35
  width: '100%',
35
36
  },
@@ -105,6 +106,16 @@ const doesOptionMatchValue = function (value) {
105
106
  };
106
107
  const Select = function (props) {
107
108
  let maxLabelLength = 0;
109
+ const cssVarsValuesRef = React.useRef({
110
+ '--ab-cmp-select-menu__max-width': 0,
111
+ '--ab-cmp-select-menu__min-width': 0,
112
+ '--ab-cmp-select-menu__max-height': 0,
113
+ });
114
+ const CSS_VARS_VALUES = {
115
+ '--ab-cmp-select-menu__max-width': cssVarsValuesRef.current['--ab-cmp-select-menu__max-width'] || '60vw',
116
+ '--ab-cmp-select-menu__min-width': cssVarsValuesRef.current['--ab-cmp-select-menu__min-width'] || 150,
117
+ '--ab-cmp-select-menu__max-height': cssVarsValuesRef.current['--ab-cmp-select-menu__max-height'] || '60vh',
118
+ };
108
119
  const searchableInMenulist = props.searchable === 'menulist';
109
120
  const searchableInline = props.searchable === 'inline';
110
121
  // relevant for menulist search only
@@ -257,6 +268,7 @@ const Select = function (props) {
257
268
  React.createElement(react_select_1.components.Menu, { ...menuProps, innerProps: {
258
269
  // @ts-ignore
259
270
  'data-name': 'menu-container',
271
+ 'data-resizable': resizable,
260
272
  ...menuProps.innerProps,
261
273
  onBlur: (e) => {
262
274
  if (!searchableInMenulist) {
@@ -272,11 +284,14 @@ const Select = function (props) {
272
284
  return;
273
285
  }
274
286
  setTimeout(() => {
275
- // wee need to wait for the single value selectio to complete before closing
287
+ // wee need to wait for the single value selection to complete before closing
276
288
  closeSelectMenu();
277
289
  }, 100);
278
290
  },
279
- onMouseDownCapture: (event) => {
291
+ onMouseDown: (event) => {
292
+ if (!props.isMulti) {
293
+ menuProps.innerProps?.onMouseDown?.(event);
294
+ }
280
295
  if (!searchableInMenulist) {
281
296
  return;
282
297
  }
@@ -285,9 +300,17 @@ const Select = function (props) {
285
300
  event.stopPropagation();
286
301
  }
287
302
  },
288
- } }, resizable ? (React.createElement(re_resizable_1.Resizable, { enable: resizableDirections, minWidth: '100%', maxHeight: '60vh', maxWidth: '60vw', defaultSize: sizeRef.current, onResizeStop: onResizeStop }, theChildren)) : (theChildren))));
303
+ } }, resizable ? (React.createElement(re_resizable_1.Resizable, { className: "ab-Select-MenuContainer-Resizable", enable: resizableDirections,
304
+ // ideally we wouldn't need those to be computed values
305
+ // and instead pass the CSS var name, like `var(--ab-cmp-select-menu__min-width)`
306
+ // to the Resizable component, but it won't respect them
307
+ // so we needed to read the CSS variables from the DOM, using CSSNumericVariableWatch
308
+ // and then pass the actual values to Resizable
309
+ minWidth: CSS_VARS_VALUES['--ab-cmp-select-menu__min-width'], maxHeight: CSS_VARS_VALUES['--ab-cmp-select-menu__max-height'], maxWidth: CSS_VARS_VALUES['--ab-cmp-select-menu__max-width'], defaultSize: sizeRef.current, onResizeStop: onResizeStop, onResizeStart: (e) => {
310
+ e.preventDefault();
311
+ } }, theChildren)) : (theChildren))));
289
312
  };
290
- }, [resizable]);
313
+ }, [resizable, JSON.stringify(CSS_VARS_VALUES)]);
291
314
  const SelectComponent = props.isCreatable ? creatable_1.default : react_select_1.default;
292
315
  const ClearIndicator = React.useMemo(() => {
293
316
  return (clearIndicatorProps) => {
@@ -320,8 +343,11 @@ const Select = function (props) {
320
343
  const focusedOptionIndex = options
321
344
  .filter((option) => filterFunction({ data: option }))
322
345
  .indexOf(focusedOption);
323
- const valueStr = getValue()
324
- .map((option) => option.value)
346
+ const valueStrKey = getValue()
347
+ // if we simply map, then if we have [] or [''], they will map to the same value
348
+ // but we need it to be different
349
+ // so we can trigger a change when the value changes
350
+ .map((option, index) => `${index}-${option.value}`)
325
351
  .join(',');
326
352
  const selectedRows = (0, react_1.useMemo)(() => {
327
353
  const selectedRows = [];
@@ -335,7 +361,7 @@ const Select = function (props) {
335
361
  }
336
362
  });
337
363
  return selectedRows;
338
- }, [valueStr, inputValue, hasFilter]);
364
+ }, [valueStrKey, inputValue, hasFilter]);
339
365
  const rowSelection = React.useMemo(() => {
340
366
  return isMulti
341
367
  ? {
@@ -415,7 +441,7 @@ const Select = function (props) {
415
441
  }
416
442
  //@ts-ignore
417
443
  setValue(selection, 'select-option');
418
- }, [setValue, filterOption, inputValue, hasFilter, filteredOptions, rowSelection, valueStr]);
444
+ }, [setValue, filterOption, inputValue, hasFilter, filteredOptions, rowSelection, valueStrKey]);
419
445
  const onSingleRowSelectionChange = React.useCallback((value) => {
420
446
  if (value == undefined && rowSelection != undefined) {
421
447
  return;
@@ -442,7 +468,7 @@ const Select = function (props) {
442
468
  data: filteredOptions, primaryKey: "value", selectionMode: isMulti ? 'multi-row' : 'single-row',
443
469
  // @ts-ignore
444
470
  onRowSelectionChange: isLoading ? null : isMulti ? onRowSelectionChange : onSingleRowSelectionChange, rowSelection: rowSelection, isRowDisabled: isRowDisabled },
445
- searchableInMenulist && (React.createElement(rebass_1.Flex, { p: 1 },
471
+ searchableInMenulist && (React.createElement(rebass_1.Flex, { p: 1, className: "ab-Select-MenulistSearchContainer" },
446
472
  React.createElement("input", { ref: menulistInputRef, "data-name": "menulist-search-input", style: {
447
473
  width: '100%',
448
474
  }, className: 'ab-Select-MenulistSearch ab-Input ab-Input--type-text', autoCorrect: "off", autoComplete: "off", spellCheck: "false", type: "text", value: inputValue, onChange: (e) => {
@@ -490,166 +516,175 @@ const Select = function (props) {
490
516
  setInputValue(value);
491
517
  props.onInputChange?.(value);
492
518
  }, [props.onInputChange, isMulti]);
493
- return (React.createElement(SelectComponent, { ref: ref, openMenuOnClick: searchableInMenulist ? false : undefined, openMenuOnFocus: searchableInMenulist ? false : undefined, menuIsOpen: searchableInMenulist ? isSelectMenuOpen : undefined, isSearchable: searchableInline, "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: (0, join_1.default)(props.className, 'ab-Select'), isDisabled: disabled, menuPlacement: props.menuPlacement ?? 'auto', hideSelectedOptions: false, isMulti: isMulti, value: selectedOption, blurInputOnSelect: false, menuPosition: props.menuPosition ?? 'absolute',
494
- // This needed so the menu is not clipped by overflow: hidden
495
- menuPortalTarget: (0, OverlayTrigger_1.ensurePortalElement)(), isClearable: props.isClearable, closeMenuOnSelect: props.closeMenuOnSelect, onChange: (option) => {
496
- if (isMulti) {
497
- const value = option.map((x) => x?.value);
498
- props.onChange(value);
499
- }
500
- else {
501
- props.onChange(option?.value);
502
- }
503
- if (searchableInMenulist) {
504
- // ensure element keeps focus
505
- requestAnimationFrame(() => {
506
- menulistInputRef.current?.focus();
507
- });
508
- }
509
- }, placeholder: props.placeholder, createOptionPosition: 'first',
510
- // formatCreateLabel={(inputValue) => inputValue} // can we make this auto??
511
- // we use this: https://react-select.com/creatable
512
- components: {
513
- SelectContainer,
514
- ValueContainer,
515
- Menu: MenuComponent,
516
- SingleValue: React.useCallback((singleValueProps) => {
517
- return (React.createElement(react_select_1.components.SingleValue, { ...singleValueProps }, props.renderSingleValue
518
- ? props.renderSingleValue(selectedOption)
519
- : singleValueProps.children));
520
- }, [selectedOption]),
521
- ClearIndicator,
522
- DropdownIndicator,
523
- MenuList,
524
- },
525
- /**
526
- * Using styles is the preferred way to style react-select.
527
- * https://react-select.com/styles#the-styles-prop
528
- */
529
- styles: {
530
- // Typescript issue with csstype@3.1.3
531
- // https://github.com/JedWatson/react-select/issues/5825#issuecomment-1850472549
532
- // Remove
533
- container: (baseStyle) => {
534
- return {
535
- ...baseStyle,
536
- ...props.style,
537
- ...props.styles?.container,
538
- };
539
- },
540
- // @ts-ignorets-ignore when fixed
541
- menuPortal: (baseStyle) => {
542
- return {
543
- ...baseStyle,
544
- // needed to avoid tooltips from being displayed under this menu
545
- // as otherwise react-select uses zIndex 1
546
- zIndex: 'auto',
547
- textAlign: 'left',
548
- };
549
- },
550
- // @ts-ignore
551
- menu: (baseStyle, state) => {
552
- return {
553
- ...baseStyle,
554
- // needed to avoid tooltips from being displayed under this menu
555
- // as otherwise react-select uses zIndex 1
556
- zIndex: 'auto',
557
- boxShadow: 'var(--ab-cmp-select-menu__box-shadow)',
558
- minWidth: `var(--ab-cmp-select-menu__min-width)`,
559
- width: resizable ? '100%' : `${Math.max(maxLabelLength, 10)}ch`,
560
- '--ab-cmp-select-menu__min-height': `min(${(props.options || []).length + (showHeaderSelectionCheckbox ? 1 : 0)} * var(--ab-grid-row-height), 20rem)`,
561
- maxHeight: 'var(--ab-cmp-select-menu__max-height)',
562
- maxWidth: 'var(--ab-cmp-select-menu__max-width)',
563
- ...commonStyles(state),
564
- ...props.menuStyle,
565
- };
566
- },
567
- // @ts-ignore
568
- option: (baseStyle, state) => {
569
- const style = {
570
- ...baseStyle,
571
- ...commonStyles(state),
572
- '&:active': {
573
- background: 'var(--ab-cmp-select-option-active__background)',
574
- },
575
- };
576
- if (state.isSelected) {
577
- style.background = 'var(--ab-cmp-select-option-active__background)';
578
- style.color = 'var(--ab-cmp-select-option-active__color)';
519
+ return (React.createElement(React.Fragment, null,
520
+ React.createElement(CSSNumericVariableWatch_1.CSSNumericVariableWatch, { varName: "--ab-cmp-select-menu__max-width", onChange: (value) => {
521
+ cssVarsValuesRef.current['--ab-cmp-select-menu__max-width'] = value;
522
+ } }),
523
+ React.createElement(CSSNumericVariableWatch_1.CSSNumericVariableWatch, { varName: "--ab-cmp-select-menu__min-width", onChange: (value) => {
524
+ cssVarsValuesRef.current['--ab-cmp-select-menu__min-width'] = value;
525
+ } }),
526
+ React.createElement(CSSNumericVariableWatch_1.CSSNumericVariableWatch, { varName: "--ab-cmp-select-menu__max-height", onChange: (value) => {
527
+ cssVarsValuesRef.current['--ab-cmp-select-menu__max-height'] = value;
528
+ } }),
529
+ React.createElement(SelectComponent, { ref: ref, openMenuOnClick: searchableInMenulist ? false : undefined, openMenuOnFocus: searchableInMenulist ? false : undefined, menuIsOpen: searchableInMenulist ? isSelectMenuOpen : undefined, isSearchable: searchableInline, "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: (0, join_1.default)(props.className, 'ab-Select'), isDisabled: disabled, menuPlacement: props.menuPlacement ?? 'auto', hideSelectedOptions: false, isMulti: isMulti, value: selectedOption, blurInputOnSelect: false, menuPosition: props.menuPosition ?? 'absolute',
530
+ // This needed so the menu is not clipped by overflow: hidden
531
+ menuPortalTarget: (0, OverlayTrigger_1.ensurePortalElement)(), isClearable: props.isClearable, closeMenuOnSelect: props.closeMenuOnSelect, onChange: (option) => {
532
+ if (isMulti) {
533
+ const value = option.map((x) => x?.value);
534
+ props.onChange(value);
579
535
  }
580
- if (state.isFocused) {
581
- style.background = 'var(--ab-cmp-select-option-focused__background)';
536
+ else {
537
+ props.onChange(option?.value);
582
538
  }
583
- return style;
584
- },
585
- // @ts-ignore
586
- input: (baseStyle, state) => {
587
- return {
588
- ...baseStyle,
589
- padding: props.size === 'small' ? 0 : baseStyle.padding,
590
- color: 'var(--ab-cmp-select__color)',
591
- };
592
- },
593
- valueContainer: (baseStyle) => {
594
- return {
595
- ...baseStyle,
596
- padding: props.size === 'small' ? `0 var(--ab-space-1)` : baseStyle.padding,
597
- ...props.styles?.valueContainer,
598
- };
599
- },
600
- // @ts-ignore
601
- singleValue: (baseStyle, state) => {
602
- return {
603
- ...baseStyle,
604
- ...commonStyles(state),
605
- };
606
- },
607
- // @ts-ignore
608
- control: (baseStyle, state) => {
609
- return {
610
- ...baseStyle,
611
- ...commonStyles(state), // height: 30,
612
- minHeight: props.size === 'small' ? 0 : '100%',
613
- boxShadow: state.isFocused ? 'var(--ab-cmp-select-focused__box-shadow)' : 'none',
614
- outline: state.isFocused ? 'var(--ab-cmp-select-focused__outline)' : 'none',
615
- border: 'var(--ab-cmp-select__border)',
616
- borderRadius: 'var(--ab-cmp-select__border-radius)',
617
- '&:hover': {
539
+ if (searchableInMenulist) {
540
+ // ensure element keeps focus
541
+ requestAnimationFrame(() => {
542
+ menulistInputRef.current?.focus();
543
+ });
544
+ }
545
+ }, placeholder: props.placeholder, createOptionPosition: 'first',
546
+ // formatCreateLabel={(inputValue) => inputValue} // can we make this auto??
547
+ // we use this: https://react-select.com/creatable
548
+ components: {
549
+ SelectContainer,
550
+ ValueContainer,
551
+ Menu: MenuComponent,
552
+ SingleValue: React.useCallback((singleValueProps) => {
553
+ return (React.createElement(react_select_1.components.SingleValue, { ...singleValueProps }, props.renderSingleValue
554
+ ? props.renderSingleValue(selectedOption)
555
+ : singleValueProps.children));
556
+ }, [selectedOption]),
557
+ ClearIndicator,
558
+ DropdownIndicator,
559
+ MenuList,
560
+ },
561
+ /**
562
+ * Using styles is the preferred way to style react-select.
563
+ * https://react-select.com/styles#the-styles-prop
564
+ */
565
+ styles: {
566
+ // Typescript issue with csstype@3.1.3
567
+ // https://github.com/JedWatson/react-select/issues/5825#issuecomment-1850472549
568
+ // Remove
569
+ container: (baseStyle) => {
570
+ return {
571
+ ...baseStyle,
572
+ ...props.style,
573
+ ...props.styles?.container,
574
+ };
575
+ },
576
+ // @ts-ignorets-ignore when fixed
577
+ menuPortal: (baseStyle) => {
578
+ return {
579
+ ...baseStyle,
580
+ // needed to avoid tooltips from being displayed under this menu
581
+ // as otherwise react-select uses zIndex 1
582
+ zIndex: 'auto',
583
+ textAlign: 'left',
584
+ };
585
+ },
586
+ // @ts-ignore
587
+ menu: (baseStyle, state) => {
588
+ return {
589
+ ...baseStyle,
590
+ // needed to avoid tooltips from being displayed under this menu
591
+ // as otherwise react-select uses zIndex 1
592
+ zIndex: 'auto',
593
+ width: resizable ? '100%' : `${Math.max(maxLabelLength, 10)}ch`,
594
+ '--ab-cmp-select-menu__min-height': `min(${(props.options || []).length + (showHeaderSelectionCheckbox ? 1 : 0)} * var(--ab-grid-row-height) + ${searchableInMenulist ? 40 : 0}px, ${searchableInMenulist ? 22 : 20}rem)`,
595
+ maxHeight: 'var(--ab-cmp-select-menu__max-height)',
596
+ minWidth: 'var(--ab-cmp-select-menu__min-width)',
597
+ maxWidth: 'var(--ab-cmp-select-menu__max-width)',
598
+ ...commonStyles(state),
599
+ ...props.menuStyle,
600
+ };
601
+ },
602
+ // @ts-ignore
603
+ option: (baseStyle, state) => {
604
+ const style = {
605
+ ...baseStyle,
606
+ ...commonStyles(state),
607
+ '&:active': {
608
+ background: 'var(--ab-cmp-select-option-active__background)',
609
+ },
610
+ };
611
+ if (state.isSelected) {
612
+ style.background = 'var(--ab-cmp-select-option-active__background)';
613
+ style.color = 'var(--ab-cmp-select-option-active__color)';
614
+ }
615
+ if (state.isFocused) {
616
+ style.background = 'var(--ab-cmp-select-option-focused__background)';
617
+ }
618
+ return style;
619
+ },
620
+ // @ts-ignore
621
+ input: (baseStyle, state) => {
622
+ return {
623
+ ...baseStyle,
624
+ padding: props.size === 'small' ? 0 : baseStyle.padding,
625
+ color: 'var(--ab-cmp-select__color)',
626
+ };
627
+ },
628
+ valueContainer: (baseStyle) => {
629
+ return {
630
+ ...baseStyle,
631
+ padding: props.size === 'small' ? `0 var(--ab-space-1)` : baseStyle.padding,
632
+ ...props.styles?.valueContainer,
633
+ };
634
+ },
635
+ // @ts-ignore
636
+ singleValue: (baseStyle, state) => {
637
+ return {
638
+ ...baseStyle,
639
+ ...commonStyles(state),
640
+ };
641
+ },
642
+ // @ts-ignore
643
+ control: (baseStyle, state) => {
644
+ return {
645
+ ...baseStyle,
646
+ ...commonStyles(state), // height: 30,
647
+ minHeight: props.size === 'small' ? 0 : '100%',
648
+ boxShadow: state.isFocused ? 'var(--ab-cmp-select-focused__box-shadow)' : 'none',
649
+ outline: state.isFocused ? 'var(--ab-cmp-select-focused__outline)' : 'none',
618
650
  border: 'var(--ab-cmp-select__border)',
619
- },
620
- ...props.styles?.control,
621
- };
622
- },
623
- // @ts-ignore
624
- dropdownIndicator: (baseStyle) => {
625
- return {
626
- ...baseStyle,
627
- padding: 0,
628
- ...props.styles?.dropdownIndicator,
629
- };
630
- },
631
- // @ts-ignore
632
- clearIndicator: (baseStyle) => {
633
- return {
634
- ...baseStyle,
635
- padding: '2px 3px',
636
- };
637
- },
638
- multiValue: (baseStyle) => {
639
- return {
640
- ...baseStyle,
641
- color: 'var(--ab-cmp-select__color)',
642
- background: 'var(--ab-cmp-select-multi-value__background)',
643
- border: 'var(--ab-cmp-select__border)',
644
- };
645
- },
646
- multiValueLabel: (baseStyle) => {
647
- return {
648
- ...baseStyle,
649
- ...fontCommonStyles,
650
- color: 'var(--ab-cmp-select__color)',
651
- };
652
- },
653
- } }));
651
+ borderRadius: 'var(--ab-cmp-select__border-radius)',
652
+ '&:hover': {
653
+ border: 'var(--ab-cmp-select__border)',
654
+ },
655
+ ...props.styles?.control,
656
+ };
657
+ },
658
+ // @ts-ignore
659
+ dropdownIndicator: (baseStyle) => {
660
+ return {
661
+ ...baseStyle,
662
+ padding: 0,
663
+ ...props.styles?.dropdownIndicator,
664
+ };
665
+ },
666
+ // @ts-ignore
667
+ clearIndicator: (baseStyle) => {
668
+ return {
669
+ ...baseStyle,
670
+ padding: '2px 3px',
671
+ };
672
+ },
673
+ multiValue: (baseStyle) => {
674
+ return {
675
+ ...baseStyle,
676
+ color: 'var(--ab-cmp-select__color)',
677
+ background: 'var(--ab-cmp-select-multi-value__background)',
678
+ border: 'var(--ab-cmp-select__border)',
679
+ };
680
+ },
681
+ multiValueLabel: (baseStyle) => {
682
+ return {
683
+ ...baseStyle,
684
+ ...fontCommonStyles,
685
+ color: 'var(--ab-cmp-select__color)',
686
+ };
687
+ },
688
+ } })));
654
689
  };
655
690
  exports.Select = Select;
package/src/env.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  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" || '',
5
- PUBLISH_TIMESTAMP: 1758028392936 || Date.now(),
6
- VERSION: "21.0.1" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1758882713103 || Date.now(),
6
+ VERSION: "21.0.3" || '--current-version--',
7
7
  };