@xqmsg/ui-core 0.15.4 → 0.16.1

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.
@@ -5,6 +5,7 @@ export interface BannerProps {
5
5
  message: ReactNode;
6
6
  buttonText?: string;
7
7
  onClick?: () => void;
8
+ type?: 'condensed' | 'expanded';
8
9
  }
9
10
  /**
10
11
  * A functional React component utilized to render the `Banner` component
@@ -5,6 +5,7 @@ export interface DropdownProps {
5
5
  options: FieldOptions;
6
6
  dropdownRef: RefObject<HTMLDivElement>;
7
7
  position: 'top' | 'bottom';
8
+ optionIndex?: number | null;
8
9
  }
9
10
  /**
10
11
  * A functional React component utilized to render the `Dropdown` component
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  fontSize: string;
5
5
  bg: string;
6
6
  color: string;
7
+ h: string;
7
8
  border: string;
8
9
  px: string;
9
10
  py: string;
@@ -34,6 +35,7 @@ declare const _default: {
34
35
  fontSize: string;
35
36
  bg: string;
36
37
  color: string;
38
+ h: string;
37
39
  border: string;
38
40
  px: string;
39
41
  py: string;
@@ -74,6 +76,7 @@ declare const _default: {
74
76
  };
75
77
  borderRadius: string;
76
78
  fontSize: string;
79
+ h: string;
77
80
  border: string;
78
81
  px: string;
79
82
  py: string;
@@ -11,8 +11,12 @@ declare const _default: {
11
11
  };
12
12
  tr: {
13
13
  fontSize: string;
14
+ h: string;
15
+ lineHeight: string;
14
16
  _odd: {
15
17
  td: {
18
+ h: string;
19
+ lineHeight: string;
16
20
  bg: string;
17
21
  _first: {
18
22
  borderTopLeftRadius: string;
@@ -27,6 +31,8 @@ declare const _default: {
27
31
  };
28
32
  td: {
29
33
  padding: string;
34
+ lineHeight: string;
35
+ h: string;
30
36
  };
31
37
  };
32
38
  };
@@ -8,6 +8,7 @@ declare const _default: {
8
8
  base: string;
9
9
  lg: string;
10
10
  };
11
+ lineHeight: string;
11
12
  };
12
13
  '*, *::before, *::after': {
13
14
  borderColor: string;
@@ -57,7 +57,9 @@ var Banner = function Banner(_ref) {
57
57
  var variant = _ref.variant,
58
58
  message = _ref.message,
59
59
  buttonText = _ref.buttonText,
60
- onClick = _ref.onClick;
60
+ onClick = _ref.onClick,
61
+ _ref$type = _ref.type,
62
+ type = _ref$type === void 0 ? 'expanded' : _ref$type;
61
63
  var Icon = React.useMemo(function () {
62
64
  switch (variant) {
63
65
  case 'error':
@@ -94,18 +96,24 @@ var Banner = function Banner(_ref) {
94
96
  }, [variant]);
95
97
  return /*#__PURE__*/React__default.createElement(react.Alert, {
96
98
  variant: variant
97
- }, /*#__PURE__*/React__default.createElement(react.AlertDescription, null, /*#__PURE__*/React__default.createElement(react.Box, {
98
- pb: "8px"
99
- }, Icon), message, onClick && buttonText && /*#__PURE__*/React__default.createElement(react.Flex, {
100
- pt: "8px",
101
- justifyContent: "flex-end"
99
+ }, /*#__PURE__*/React__default.createElement(react.AlertDescription, null, /*#__PURE__*/React__default.createElement(react.Flex, {
100
+ flexDirection: type === 'condensed' ? 'row' : 'column',
101
+ alignItems: type === 'condensed' ? 'center' : ''
102
+ }, /*#__PURE__*/React__default.createElement(react.Box, {
103
+ pr: "8px"
104
+ }, Icon), /*#__PURE__*/React__default.createElement(react.Box, {
105
+ pt: type === 'condensed' ? 0 : '8px'
106
+ }, " ", message), onClick && buttonText && /*#__PURE__*/React__default.createElement(react.Flex, {
107
+ ml: type === 'condensed' ? 'auto' : '',
108
+ pt: type === 'condensed' ? 0 : '8px',
109
+ justifyContent: type === 'condensed' ? 'flex-end' : 'flex-end'
102
110
  }, /*#__PURE__*/React__default.createElement(Button, {
103
111
  variant: "secondary",
104
112
  onClick: onClick,
105
113
  text: buttonText,
106
114
  width: "variable",
107
115
  ariaLabel: "banner button"
108
- }))));
116
+ })))));
109
117
  };
110
118
 
111
119
  var blue = {
@@ -373,12 +381,12 @@ var SpinnerButton = function SpinnerButton(_ref) {
373
381
  type = _ref.type,
374
382
  ariaLabel = _ref.ariaLabel,
375
383
  _ref$variant = _ref.variant,
376
- variant = _ref$variant === void 0 ? 'solid' : _ref$variant,
384
+ variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
377
385
  disabled = _ref.disabled,
378
386
  className = _ref.className;
379
387
  return /*#__PURE__*/React__default.createElement(react.Button, {
380
388
  spinner: /*#__PURE__*/React__default.createElement(react.Spinner, {
381
- size: 'md'
389
+ size: 'sm'
382
390
  }),
383
391
  isLoading: isLoading,
384
392
  onClick: onClick,
@@ -505,7 +513,8 @@ var Dropdown = function Dropdown(_ref) {
505
513
  var onSelectItem = _ref.onSelectItem,
506
514
  options = _ref.options,
507
515
  dropdownRef = _ref.dropdownRef,
508
- position = _ref.position;
516
+ position = _ref.position,
517
+ optionIndex = _ref.optionIndex;
509
518
  var DropdownContent = React.useMemo(function () {
510
519
  return options.map(function (option, idx) {
511
520
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, option.value === 'section_header' && options[idx + 1] && options[idx + 1].value !== 'section_header' && /*#__PURE__*/React__default.createElement(react.Box, {
@@ -532,18 +541,19 @@ var Dropdown = function Dropdown(_ref) {
532
541
  px: "8px",
533
542
  py: "4px",
534
543
  width: "100%",
535
- color: colors.label.primary.light,
544
+ color: optionIndex === idx ? colors.label.primary.dark : colors.label.primary.light,
536
545
  _hover: {
537
546
  color: colors.label.primary.dark,
538
547
  bg: colors.fill.action,
539
548
  borderRadius: '4px',
540
549
  width: '100%'
541
550
  },
542
- bg: "inherit",
543
- whiteSpace: "nowrap"
551
+ bg: optionIndex === idx ? colors.fill.action : 'inherit',
552
+ whiteSpace: "nowrap",
553
+ id: option.value
544
554
  }, option.label));
545
555
  });
546
- }, [onSelectItem, options]);
556
+ }, [onSelectItem, optionIndex, options]);
547
557
  return /*#__PURE__*/React__default.createElement(react.Flex, {
548
558
  flexDirection: "column",
549
559
  ref: dropdownRef,
@@ -602,7 +612,7 @@ function useOnClickOutside(ref, handler) {
602
612
  [ref, handler]);
603
613
  }
604
614
 
605
- var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "value"];
615
+ var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "disabled", "value"];
606
616
  /**
607
617
  * A functional React component utilized to render the `StackedSelect` component.
608
618
  */
@@ -615,6 +625,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
615
625
  name = _ref2.name,
616
626
  setValue = _ref2.setValue,
617
627
  handleOnChange = _ref2.handleOnChange,
628
+ disabled = _ref2.disabled,
618
629
  value = _ref2.value,
619
630
  props = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
620
631
 
@@ -631,9 +642,21 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
631
642
  selectedOption = _useState2[0],
632
643
  setSelectedOption = _useState2[1];
633
644
 
634
- var _useState3 = React.useState('top'),
635
- position = _useState3[0],
636
- setPosition = _useState3[1];
645
+ var _useState3 = React.useState(null),
646
+ optionIndex = _useState3[0],
647
+ setOptionIndex = _useState3[1];
648
+
649
+ var _useState4 = React.useState('top'),
650
+ position = _useState4[0],
651
+ setPosition = _useState4[1];
652
+
653
+ var _useState5 = React.useState(''),
654
+ searchValue = _useState5[0],
655
+ setSearchValue = _useState5[1];
656
+
657
+ var _useState6 = React.useState(''),
658
+ debouncedSearchValue = _useState6[0],
659
+ setDebouncedSearchValue = _useState6[1];
637
660
 
638
661
  var boundingClientRect = (_dropdownRef$current = dropdownRef.current) == null ? void 0 : _dropdownRef$current.getBoundingClientRect();
639
662
  React.useEffect(function () {
@@ -668,6 +691,92 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
668
691
  setIsFocussed(false);
669
692
  };
670
693
 
694
+ var handleOnKeyDown = function handleOnKeyDown(e) {
695
+ var initialOptionIndex = options[0].value === 'section_header' ? 1 : 0;
696
+
697
+ if (!isFocussed && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
698
+ setIsFocussed(true);
699
+ return setOptionIndex(initialOptionIndex);
700
+ }
701
+
702
+ if (isFocussed) {
703
+ if (optionIndex === null && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
704
+ return setOptionIndex(initialOptionIndex);
705
+ }
706
+
707
+ if (e.key === 'ArrowUp' && optionIndex !== null && optionIndex > 0) {
708
+ var _dropdownMenuRef$curr;
709
+
710
+ var incrementValue = options[optionIndex - 1] && options[optionIndex - 1].value === 'section_header' ? 2 : 1;
711
+ setOptionIndex(optionIndex - incrementValue);
712
+ return (_dropdownMenuRef$curr = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr.scrollTo({
713
+ top: optionIndex * 24,
714
+ behavior: 'smooth'
715
+ });
716
+ }
717
+
718
+ if (e.key === 'ArrowDown' && optionIndex !== null && optionIndex < options.length) {
719
+ var _dropdownMenuRef$curr2;
720
+
721
+ var _incrementValue = options[optionIndex + 1] && options[optionIndex + 1].value === 'section_header' ? 2 : 1;
722
+
723
+ setOptionIndex(optionIndex + _incrementValue);
724
+ return (_dropdownMenuRef$curr2 = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr2.scrollTo({
725
+ top: optionIndex * 24,
726
+ behavior: 'smooth'
727
+ });
728
+ }
729
+
730
+ if (e.key === 'Enter' && optionIndex !== null) {
731
+ var option = options.find(function (_, idx) {
732
+ return optionIndex === idx;
733
+ });
734
+ if (!option) return;
735
+
736
+ if (handleOnChange) {
737
+ handleOnChange(option.value);
738
+ }
739
+
740
+ setSelectedOption(option == null ? void 0 : option.label);
741
+ setValue(name, option.value, {
742
+ shouldDirty: true,
743
+ shouldValidate: true
744
+ });
745
+ return setIsFocussed(false);
746
+ }
747
+
748
+ if (e.key === 'Tab') {
749
+ return setIsFocussed(false);
750
+ }
751
+ }
752
+ };
753
+
754
+ React.useEffect(function () {
755
+ if (searchValue.length) {
756
+ var _dropdownMenuRef$curr3;
757
+
758
+ var idx = options.findIndex(function (option) {
759
+ return option.label.substring(0, searchValue.length).toLowerCase() === searchValue.toLowerCase();
760
+ });
761
+ (_dropdownMenuRef$curr3 = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr3.scrollTo({
762
+ top: idx * 24,
763
+ behavior: 'smooth'
764
+ });
765
+ setSearchValue('');
766
+ setDebouncedSearchValue('');
767
+ }
768
+ }, [options, searchValue]);
769
+ var updateSearchValue = React.useMemo(function () {
770
+ return lodash.debounce(function (val) {
771
+ setSearchValue(val);
772
+ }, 1000);
773
+ }, []);
774
+
775
+ var update = function update(value) {
776
+ updateSearchValue(value);
777
+ setDebouncedSearchValue(value);
778
+ };
779
+
671
780
  return /*#__PURE__*/React__default.createElement(react.Box, {
672
781
  ref: dropdownRef,
673
782
  position: "relative"
@@ -683,29 +792,16 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
683
792
  fontSize: "13px",
684
793
  textShadow: "0 0 0 " + colors.label.primary.light,
685
794
  value: selectedOption,
795
+ disabled: disabled,
686
796
  autoComplete: "off",
687
- onKeyDown: function onKeyDown(e) {
688
- if (isFocussed) {
689
- var _dropdownMenuRef$curr;
690
-
691
- if (e.key === 'Tab') {
692
- return setIsFocussed(false);
693
- }
694
-
695
- var idx = options.findIndex(function (option) {
696
- return option.label[0].toLocaleLowerCase() === e.key;
697
- });
698
- console.log(idx);
699
- (_dropdownMenuRef$curr = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr.scrollTo({
700
- top: idx * 27,
701
- behavior: 'smooth'
702
- });
703
- }
704
- }
797
+ onChange: function onChange(e) {
798
+ return update(debouncedSearchValue.concat(e.target.value));
799
+ },
800
+ onKeyDown: handleOnKeyDown
705
801
  })), /*#__PURE__*/React__default.createElement(react.InputRightElement, {
706
- cursor: "pointer",
802
+ cursor: disabled ? 'not-allowed' : 'pointer',
707
803
  onClick: function onClick() {
708
- return setIsFocussed(!isFocussed);
804
+ return !disabled && setIsFocussed(!isFocussed);
709
805
  }
710
806
  }, /*#__PURE__*/React__default.createElement(react.Image, {
711
807
  src: SubtractIcon,
@@ -717,7 +813,8 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
717
813
  onSelectItem: function onSelectItem(option) {
718
814
  return handleOnSelectItem(option);
719
815
  },
720
- options: options
816
+ options: options,
817
+ optionIndex: optionIndex
721
818
  }));
722
819
  });
723
820
 
@@ -823,10 +920,26 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
823
920
  shouldSideScroll = _useState4[0],
824
921
  setShouldSideScroll = _useState4[1];
825
922
 
826
- var _useState5 = React.useState('top'),
827
- position = _useState5[0],
828
- setPosition = _useState5[1];
923
+ var _useState5 = React.useState(null),
924
+ optionIndex = _useState5[0],
925
+ setOptionIndex = _useState5[1];
926
+
927
+ var _useState6 = React.useState('top'),
928
+ position = _useState6[0],
929
+ setPosition = _useState6[1];
930
+
931
+ var _useState7 = React.useState(''),
932
+ searchValue = _useState7[0],
933
+ setSearchValue = _useState7[1];
934
+
935
+ var _useState8 = React.useState(''),
936
+ debouncedSearchValue = _useState8[0],
937
+ setDebouncedSearchValue = _useState8[1];
829
938
 
939
+ console.log({
940
+ searchValue: searchValue,
941
+ debouncedSearchValue: debouncedSearchValue
942
+ });
830
943
  var boundingClientRect = (_dropdownRef$current = dropdownRef.current) == null ? void 0 : _dropdownRef$current.getBoundingClientRect();
831
944
  React.useEffect(function () {
832
945
  if (window.innerHeight - ((boundingClientRect == null ? void 0 : boundingClientRect.y) + 240) >= 0) {
@@ -906,26 +1019,89 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
906
1019
  });
907
1020
  };
908
1021
 
909
- return /*#__PURE__*/React__default.createElement(react.Box, {
910
- ref: dropdownRef,
911
- position: "relative",
912
- onKeyDown: function onKeyDown(e) {
913
- if (isFocussed) {
914
- var _dropdownMenuRef$curr;
1022
+ var handleOnKeyDown = function handleOnKeyDown(e) {
1023
+ var initialOptionIndex = options[0].value === 'section_header' ? 1 : 0;
915
1024
 
916
- if (e.key === 'Tab') {
917
- return setIsFocussed(false);
918
- }
1025
+ if (!isFocussed && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
1026
+ setIsFocussed(true);
1027
+ return setOptionIndex(initialOptionIndex);
1028
+ }
1029
+
1030
+ if (isFocussed) {
1031
+ if (optionIndex === null && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
1032
+ return setOptionIndex(initialOptionIndex);
1033
+ }
919
1034
 
920
- var idx = options.findIndex(function (option) {
921
- return option.label[0].toLocaleLowerCase() === e.key;
1035
+ if (e.key === 'ArrowUp' && optionIndex !== null && optionIndex > 0) {
1036
+ var _dropdownMenuRef$curr;
1037
+
1038
+ var incrementValue = localOptions[optionIndex - 1] && localOptions[optionIndex - 1].value === 'section_header' ? 2 : 1;
1039
+ setOptionIndex(optionIndex - incrementValue);
1040
+ return (_dropdownMenuRef$curr = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr.scrollTo({
1041
+ top: optionIndex * 24,
1042
+ behavior: 'smooth'
922
1043
  });
923
- (_dropdownMenuRef$curr = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr.scrollTo({
924
- top: idx * 27,
1044
+ }
1045
+
1046
+ if (e.key === 'ArrowDown' && optionIndex !== null && optionIndex < localOptions.length) {
1047
+ var _dropdownMenuRef$curr2;
1048
+
1049
+ var _incrementValue = localOptions[optionIndex + 1] && localOptions[optionIndex + 1].value === 'section_header' ? 2 : 1;
1050
+
1051
+ setOptionIndex(optionIndex + _incrementValue);
1052
+ return (_dropdownMenuRef$curr2 = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr2.scrollTo({
1053
+ top: optionIndex * 24,
925
1054
  behavior: 'smooth'
926
1055
  });
927
1056
  }
1057
+
1058
+ if (e.key === 'Enter' && optionIndex !== null) {
1059
+ var option = localOptions.find(function (_, idx) {
1060
+ return optionIndex === idx;
1061
+ });
1062
+ if (!option) return;
1063
+ handleChange(option);
1064
+ return setIsFocussed(false);
1065
+ }
1066
+
1067
+ if (e.key === 'Tab') {
1068
+ return setIsFocussed(false);
1069
+ }
1070
+
1071
+ return update(debouncedSearchValue.concat(e.key));
1072
+ }
1073
+ };
1074
+
1075
+ React.useEffect(function () {
1076
+ if (searchValue.length) {
1077
+ var _dropdownMenuRef$curr3;
1078
+
1079
+ var idx = options.findIndex(function (option) {
1080
+ return option.label.substring(0, searchValue.length).toLowerCase() === searchValue.toLowerCase();
1081
+ });
1082
+ (_dropdownMenuRef$curr3 = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr3.scrollTo({
1083
+ top: idx * 24,
1084
+ behavior: 'smooth'
1085
+ });
1086
+ setSearchValue('');
1087
+ setDebouncedSearchValue('');
928
1088
  }
1089
+ }, [options, searchValue]);
1090
+ var updateSearchValue = React.useMemo(function () {
1091
+ return lodash.debounce(function (val) {
1092
+ setSearchValue(val);
1093
+ }, 1000);
1094
+ }, []);
1095
+
1096
+ var update = function update(value) {
1097
+ updateSearchValue(value);
1098
+ setDebouncedSearchValue(value);
1099
+ };
1100
+
1101
+ return /*#__PURE__*/React__default.createElement(react.Box, {
1102
+ ref: dropdownRef,
1103
+ position: "relative",
1104
+ onKeyDown: handleOnKeyDown
929
1105
  }, /*#__PURE__*/React__default.createElement(react.Flex, {
930
1106
  fontSize: "13px",
931
1107
  h: "26px",
@@ -1008,7 +1184,8 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1008
1184
  return handleChange(option);
1009
1185
  },
1010
1186
  options: localOptions,
1011
- position: position
1187
+ position: position,
1188
+ optionIndex: optionIndex
1012
1189
  }));
1013
1190
  });
1014
1191
 
@@ -1812,7 +1989,7 @@ var EmptyTable = function EmptyTable() {
1812
1989
  return i + 1;
1813
1990
  }).map(function (i) {
1814
1991
  return /*#__PURE__*/React__default.createElement(react.Tr, null, /*#__PURE__*/React__default.createElement(react.Td, {
1815
- height: "23px",
1992
+ height: "26px",
1816
1993
  opacity: getOpacity(i)
1817
1994
  }));
1818
1995
  })));
@@ -2074,6 +2251,7 @@ var baseStyle$2 = /*#__PURE__*/system.defineStyle({
2074
2251
  fontSize: '13px',
2075
2252
  bg: colors.fill.action,
2076
2253
  color: colors.label.primary.dark,
2254
+ h: '26px',
2077
2255
  border: 'none',
2078
2256
  px: '8px',
2079
2257
  py: '4px',
@@ -2717,8 +2895,12 @@ var baseStyle$c = {
2717
2895
  },
2718
2896
  tr: {
2719
2897
  fontSize: '13px',
2898
+ h: '26px',
2899
+ lineHeight: 'normal',
2720
2900
  _odd: {
2721
2901
  td: {
2902
+ h: '26px ',
2903
+ lineHeight: 'normal',
2722
2904
  bg: colors.fill.light.tertiary,
2723
2905
  _first: {
2724
2906
  borderTopLeftRadius: 'md',
@@ -2732,7 +2914,9 @@ var baseStyle$c = {
2732
2914
  }
2733
2915
  },
2734
2916
  td: {
2735
- padding: '5px 8px !important'
2917
+ padding: '5px 8px !important',
2918
+ lineHeight: 'normal',
2919
+ h: '26px'
2736
2920
  }
2737
2921
  };
2738
2922
  var Table$1 = {
@@ -3003,7 +3187,7 @@ var baseStyle$f = {
3003
3187
  fontWeight: typography.fontWeights.normal,
3004
3188
  fontFamily: typography.fonts.base,
3005
3189
  fontSize: typography.fontSizes.sm,
3006
- lineHeight: typography.lineHeights.base,
3190
+ lineHeight: typography.lineHeights.normal,
3007
3191
  letterSpacing: typography.letterSpacings.wide
3008
3192
  };
3009
3193
 
@@ -3051,7 +3235,8 @@ var styles = {
3051
3235
  overflow: {
3052
3236
  base: 'visible',
3053
3237
  lg: 'hidden'
3054
- }
3238
+ },
3239
+ lineHeight: 'normal'
3055
3240
  },
3056
3241
  '*, *::before, *::after': {
3057
3242
  borderColor: 'gray.200'