glints-aries 4.0.245 → 4.0.247

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.
Files changed (49) hide show
  1. package/es/@next/Bar/Bar.d.ts +3 -0
  2. package/es/@next/Bar/Bar.js +12 -3
  3. package/es/@next/Bar/Bar.stories.d.ts +2 -0
  4. package/es/@next/Bar/BarStyle.d.ts +1 -0
  5. package/es/@next/Bar/BarStyle.js +7 -3
  6. package/es/@next/Select/Select.d.ts +2 -1
  7. package/es/@next/Select/Select.js +19 -0
  8. package/es/@next/Select/Select.stories.d.ts +2 -0
  9. package/es/@next/Select/components/Activator/ActivatorTextInput.js +2 -0
  10. package/es/@next/Select/components/OptionList/OptionList.d.ts +3 -2
  11. package/es/@next/Select/components/OptionList/OptionList.js +22 -3
  12. package/es/@next/Select/components/SearchableSelectInput/SearchableSelectInput.d.ts +2 -0
  13. package/es/@next/Select/components/SearchableSelectInput/SearchableSelectInput.js +6 -1
  14. package/es/@next/Select/selectStoryHelper/SearchableSingleSelect.d.ts +2 -0
  15. package/es/@next/Select/selectStoryHelper/SearchableSingleSelect.js +143 -2
  16. package/es/@next/SideSheet/SideSheet.d.ts +17 -0
  17. package/es/@next/SideSheet/SideSheet.js +100 -0
  18. package/es/@next/SideSheet/SideSheet.stories.d.ts +6 -0
  19. package/es/@next/SideSheet/SideSheetStyle.d.ts +8 -0
  20. package/es/@next/SideSheet/SideSheetStyle.js +35 -0
  21. package/es/@next/SideSheet/index.d.ts +1 -0
  22. package/es/@next/SideSheet/index.js +1 -0
  23. package/es/helpers/debounce.d.ts +1 -0
  24. package/es/helpers/debounce.js +16 -0
  25. package/lib/@next/Bar/Bar.d.ts +3 -0
  26. package/lib/@next/Bar/Bar.js +11 -2
  27. package/lib/@next/Bar/Bar.stories.d.ts +2 -0
  28. package/lib/@next/Bar/BarStyle.d.ts +1 -0
  29. package/lib/@next/Bar/BarStyle.js +9 -4
  30. package/lib/@next/Select/Select.d.ts +2 -1
  31. package/lib/@next/Select/Select.js +19 -0
  32. package/lib/@next/Select/Select.stories.d.ts +2 -0
  33. package/lib/@next/Select/components/Activator/ActivatorTextInput.js +2 -0
  34. package/lib/@next/Select/components/OptionList/OptionList.d.ts +3 -2
  35. package/lib/@next/Select/components/OptionList/OptionList.js +23 -3
  36. package/lib/@next/Select/components/SearchableSelectInput/SearchableSelectInput.d.ts +2 -0
  37. package/lib/@next/Select/components/SearchableSelectInput/SearchableSelectInput.js +6 -1
  38. package/lib/@next/Select/selectStoryHelper/SearchableSingleSelect.d.ts +2 -0
  39. package/lib/@next/Select/selectStoryHelper/SearchableSingleSelect.js +146 -3
  40. package/lib/@next/SideSheet/SideSheet.d.ts +17 -0
  41. package/lib/@next/SideSheet/SideSheet.js +107 -0
  42. package/lib/@next/SideSheet/SideSheet.stories.d.ts +6 -0
  43. package/lib/@next/SideSheet/SideSheetStyle.d.ts +8 -0
  44. package/lib/@next/SideSheet/SideSheetStyle.js +50 -0
  45. package/lib/@next/SideSheet/index.d.ts +1 -0
  46. package/lib/@next/SideSheet/index.js +9 -0
  47. package/lib/helpers/debounce.d.ts +1 -0
  48. package/lib/helpers/debounce.js +21 -0
  49. package/package.json +1 -1
@@ -7,5 +7,8 @@ export declare type BarProps = {
7
7
  secondaryAction?: ComponentAction;
8
8
  tertiaryAction?: ComponentAction;
9
9
  position?: 'top' | 'bottom';
10
+ showBackButton?: boolean;
11
+ onBack?: () => void;
12
+ customActionGroup?: React.ReactNode;
10
13
  };
11
14
  export declare const Bar: React.ForwardRefExoticComponent<BarProps & React.RefAttributes<HTMLDivElement>>;
@@ -2,8 +2,9 @@ import React from 'react';
2
2
  import { Breakpoints, Colors } from '..';
3
3
  import { Button, PrimaryButton } from '../Button';
4
4
  import { ButtonGroup } from '../ButtonGroup';
5
+ import { Icon } from '../Icon';
5
6
  import { Typography } from '../Typography';
6
- import { StyledBarActionWrapper, StyledBar, StyledBarHeaderWrapper, StyledBarContainer } from './BarStyle';
7
+ import { StyledBarActionWrapper, StyledBar, StyledBarHeaderWrapper, StyledBarContainer, StyledButtonContainer } from './BarStyle';
7
8
  import { useWindowSize } from './useWindowSize';
8
9
  export var Bar = /*#__PURE__*/React.forwardRef(function Bar(_ref, ref) {
9
10
  var heading = _ref.heading,
@@ -11,7 +12,11 @@ export var Bar = /*#__PURE__*/React.forwardRef(function Bar(_ref, ref) {
11
12
  primaryAction = _ref.primaryAction,
12
13
  secondaryAction = _ref.secondaryAction,
13
14
  tertiaryAction = _ref.tertiaryAction,
14
- position = _ref.position;
15
+ position = _ref.position,
16
+ _ref$showBackButton = _ref.showBackButton,
17
+ showBackButton = _ref$showBackButton === void 0 ? false : _ref$showBackButton,
18
+ onBack = _ref.onBack,
19
+ customActionGroup = _ref.customActionGroup;
15
20
  var headerMarkup = function headerMarkup() {
16
21
  if (subheading) {
17
22
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
@@ -37,7 +42,11 @@ export var Bar = /*#__PURE__*/React.forwardRef(function Bar(_ref, ref) {
37
42
  return /*#__PURE__*/React.createElement(StyledBar, {
38
43
  "data-align": position,
39
44
  ref: ref
40
- }, /*#__PURE__*/React.createElement(StyledBarContainer, null, /*#__PURE__*/React.createElement(StyledBarHeaderWrapper, null, headerMarkup(), " "), /*#__PURE__*/React.createElement(StyledBarActionWrapper, null, /*#__PURE__*/React.createElement(ButtonGroup, null, tertiaryAction && /*#__PURE__*/React.createElement(Button, {
45
+ }, /*#__PURE__*/React.createElement(StyledBarContainer, null, showBackButton && /*#__PURE__*/React.createElement(StyledButtonContainer, {
46
+ onClick: onBack
47
+ }, /*#__PURE__*/React.createElement(Icon, {
48
+ name: "ri-arrow-left-line"
49
+ })), /*#__PURE__*/React.createElement(StyledBarHeaderWrapper, null, headerMarkup(), " "), /*#__PURE__*/React.createElement(StyledBarActionWrapper, null, customActionGroup ? customActionGroup : /*#__PURE__*/React.createElement(ButtonGroup, null, tertiaryAction && /*#__PURE__*/React.createElement(Button, {
41
50
  onClick: tertiaryAction.action,
42
51
  size: buttonSize
43
52
  }, tertiaryAction.label), secondaryAction && /*#__PURE__*/React.createElement(Button, {
@@ -4,3 +4,5 @@ export default _default;
4
4
  export declare const Interactive: any;
5
5
  export declare const PrimaryActionOnly: any;
6
6
  export declare const CustomHeading: any;
7
+ export declare const BackButton: any;
8
+ export declare const customActionGroup: any;
@@ -3,3 +3,4 @@ export declare const StyledBarHeaderWrapper: import("styled-components").StyledC
3
3
  export declare const StyledBarActionWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
4
4
  export declare const StyledBarContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
5
5
  export declare const StyledCustomHeadingWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
6
+ export declare const StyledButtonContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -5,7 +5,7 @@ import { space8 } from '../utilities/spacing';
5
5
  export var StyledBar = styled.div.withConfig({
6
6
  displayName: "BarStyle__StyledBar",
7
7
  componentId: "sc-1m51mld-0"
8
- })(["display:flex;flex-direction:row;padding:20px 0;width:100%;position:absolute;height:90px;@media (max-width:", "){height:70px;}&[data-align='bottom']{bottom:0;}&[data-align='top']{top:0;}box-shadow:0px 0px 0px 1px rgba(63,63,68,0.05),0px 1px 3px rgba(63,63,68,0.15);background:", ";"], Breakpoints.large, Neutral.B100);
8
+ })(["display:flex;flex-direction:row;padding:12px 0;width:100%;position:absolute;min-height:90px;height:fit-content;&[data-align='bottom']{bottom:0;}&[data-align='top']{top:0;}box-shadow:0px 0px 0px 1px rgba(63,63,68,0.05),0px 1px 3px rgba(63,63,68,0.15);background:", ";@media (max-width:", "){padding:8px 0;min-height:70px;}"], Neutral.B100, Breakpoints.large);
9
9
  export var StyledBarHeaderWrapper = styled.div.withConfig({
10
10
  displayName: "BarStyle__StyledBarHeaderWrapper",
11
11
  componentId: "sc-1m51mld-1"
@@ -17,8 +17,12 @@ export var StyledBarActionWrapper = styled.div.withConfig({
17
17
  export var StyledBarContainer = styled.div.withConfig({
18
18
  displayName: "BarStyle__StyledBarContainer",
19
19
  componentId: "sc-1m51mld-3"
20
- })(["position:relative;margin:0 auto;padding:0 50px;width:100%;*,*:before,*:after{box-sizing:border-box;}justify-content:space-between;align-items:center;flex-direction:row;display:flex;@media (max-width:", "){gap:16px;padding:0 24px;}"], Breakpoints.large);
20
+ })(["position:relative;margin:0 auto;padding:0 50px;width:100%;*,*:before,*:after{box-sizing:border-box;}justify-content:space-between;align-items:center;flex-direction:row;display:flex;@media (max-width:", "){gap:16px;padding:0 16px;}"], Breakpoints.large);
21
21
  export var StyledCustomHeadingWrapper = styled.div.withConfig({
22
22
  displayName: "BarStyle__StyledCustomHeadingWrapper",
23
23
  componentId: "sc-1m51mld-4"
24
- })(["display:flex;flex-direction:row;gap:", ";"], space8);
24
+ })(["display:flex;flex-direction:row;gap:", ";"], space8);
25
+ export var StyledButtonContainer = styled.div.withConfig({
26
+ displayName: "BarStyle__StyledButtonContainer",
27
+ componentId: "sc-1m51mld-5"
28
+ })(["cursor:pointer;margin-right:24px;svg{width:24px;fill:", ";}@media (max-width:", "){margin-right:16px;svg{width:16px;}}"], Neutral.B40, Breakpoints.large);
@@ -14,6 +14,7 @@ export interface SelectProps {
14
14
  label?: React.ReactNode;
15
15
  /** Margin Top = 8 ; Option height = 48 ; optionListHeight = (n options * option height) + margin top; */
16
16
  listHeight?: number;
17
+ loadingOptions?: boolean;
17
18
  onClose?: () => void;
18
19
  onRemoveTag?({ option }: {
19
20
  option: string;
@@ -35,5 +36,5 @@ export interface SelectProps {
35
36
  /** sets a width for the Select component*/
36
37
  width: string;
37
38
  }
38
- export declare const Select: ({ allowMultiple, disabled, hasError, helpText, label, onClose, onRemoveTag, onSelect, options, placeholder, listHeight, prefix, searchable, searchableProps, scrollable, sections, selectedValues, width, }: SelectProps) => JSX.Element;
39
+ export declare const Select: ({ allowMultiple, disabled, hasError, helpText, label, loadingOptions, onClose, onRemoveTag, onSelect, options, placeholder, listHeight, prefix, searchable, searchableProps, scrollable, sections, selectedValues, width, }: SelectProps) => JSX.Element;
39
40
  export {};
@@ -15,6 +15,8 @@ export var Select = function Select(_ref) {
15
15
  hasError = _ref$hasError === void 0 ? false : _ref$hasError,
16
16
  helpText = _ref.helpText,
17
17
  label = _ref.label,
18
+ _ref$loadingOptions = _ref.loadingOptions,
19
+ loadingOptions = _ref$loadingOptions === void 0 ? false : _ref$loadingOptions,
18
20
  onClose = _ref.onClose,
19
21
  onRemoveTag = _ref.onRemoveTag,
20
22
  onSelect = _ref.onSelect,
@@ -40,6 +42,7 @@ export var Select = function Select(_ref) {
40
42
  var _useState3 = useState(options),
41
43
  menuOptions = _useState3[0],
42
44
  setMenuOptions = _useState3[1];
45
+ var optionsLength = options.length;
43
46
  var _useState4 = useState((searchableProps == null ? void 0 : searchableProps.inputValue) || ''),
44
47
  inputValue = _useState4[0],
45
48
  setInputValue = _useState4[1];
@@ -64,11 +67,26 @@ export var Select = function Select(_ref) {
64
67
  onClose == null ? void 0 : onClose();
65
68
  };
66
69
  var handleFocus = function handleFocus() {
70
+ if (options.length < 1) {
71
+ setPopoverActive(false);
72
+ return;
73
+ }
67
74
  setPopoverActive(true);
68
75
  };
69
76
  var handleSelectClick = function handleSelectClick() {
70
77
  setPopoverActive(!popoverActive);
71
78
  };
79
+ useEffect(function () {
80
+ setMenuOptions(options);
81
+ }, [options]);
82
+ useEffect(function () {
83
+ if (inputValue != '' && optionsLength > 0) {
84
+ setPopoverActive(true);
85
+ }
86
+ if (inputValue === '' && optionsLength < 1) {
87
+ setPopoverActive(false);
88
+ }
89
+ }, [inputValue, optionsLength]);
72
90
  useEffect(function () {
73
91
  if (listHeight) {
74
92
  setOptionListHeight(listHeight + 24 + "px");
@@ -129,6 +147,7 @@ export var Select = function Select(_ref) {
129
147
  }, !disabled && /*#__PURE__*/React.createElement(Popover.Pane, {
130
148
  height: optionListHeight
131
149
  }, /*#__PURE__*/React.createElement(OptionList, {
150
+ loading: loadingOptions,
132
151
  menuOptions: menuOptions,
133
152
  allowMultiple: allowMultiple,
134
153
  onSelect: onSelect,
@@ -7,6 +7,8 @@ export declare const WithErrorNonSearchable: any;
7
7
  export declare const NonSearchableDisabled: any;
8
8
  export declare const SearchableMultiSelect: any;
9
9
  export declare const SearchableSingleSelect: any;
10
+ export declare const SearchableSingleWithInputState: any;
11
+ export declare const AsyncSearchableSingleWithInputState: any;
10
12
  export declare const MultiSelectScrollable: any;
11
13
  export declare const WithInlineError: any;
12
14
  export declare const SearchableDisabled: any;
@@ -55,6 +55,7 @@ export var ActivatorTextInput = function ActivatorTextInput(_ref) {
55
55
  }).length > 0);
56
56
  }, [selectedValues]);
57
57
  return /*#__PURE__*/React.createElement(React.Fragment, null, allowMultiple ? /*#__PURE__*/React.createElement(StyledTextInput, _extends({}, props, {
58
+ className: "select-input",
58
59
  ref: activatorRef,
59
60
  prefix: prefix,
60
61
  onChange: function onChange(value) {
@@ -71,6 +72,7 @@ export var ActivatorTextInput = function ActivatorTextInput(_ref) {
71
72
  prefix: prefix,
72
73
  filterOptions: filterOptions,
73
74
  onFocus: onFocus,
75
+ onInputChange: onChange,
74
76
  onSelect: onSelect,
75
77
  error: hasError,
76
78
  disabled: disabled,
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { MenuProps, Option } from '../../../Menu';
3
3
  import { SearchableSelectState } from '../SearchableSelectInput/SearchableSelectInput';
4
4
  export interface OptionListProps extends MenuProps {
5
- isEmpty?: boolean;
5
+ loading?: boolean;
6
6
  noOptionsMessage?: React.ReactNode;
7
7
  onMenuClose?: () => void;
8
8
  onSelect?({ value }: {
@@ -12,8 +12,9 @@ export interface OptionListProps extends MenuProps {
12
12
  updateSearchableSelectState?: (newState: SearchableSelectState) => void;
13
13
  menuOptions?: Option[];
14
14
  }
15
+ export declare const MenuOptionLoading: () => JSX.Element;
15
16
  export interface NoOptionListProps {
16
17
  noOptionsMessage?: React.ReactNode;
17
18
  }
18
19
  export declare const NoOptionList: ({ noOptionsMessage, }: NoOptionListProps) => JSX.Element;
19
- export declare const OptionList: ({ allowMultiple, noOptionsMessage, onMenuClose, onSelect, sections, selectedValues, title, updateSearchableSelectState, width, menuOptions, }: OptionListProps) => JSX.Element;
20
+ export declare const OptionList: ({ allowMultiple, loading, noOptionsMessage, onMenuClose, onSelect, sections, selectedValues, title, updateSearchableSelectState, width, menuOptions, }: OptionListProps) => JSX.Element;
@@ -1,12 +1,23 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { Menu } from '../../../Menu';
3
+ import { Spinner } from '../../../Spinner';
3
4
  import { Typography } from '../../../Typography';
4
- import { Neutral } from '../../../utilities/colors';
5
+ import { Blue, Neutral } from '../../../utilities/colors';
5
6
  import { EmptyOptionContainer, OptionListContainer } from './OptionListStyle';
7
+ export var MenuOptionLoading = function MenuOptionLoading() {
8
+ return /*#__PURE__*/React.createElement(EmptyOptionContainer, {
9
+ className: "menu-option-loading"
10
+ }, /*#__PURE__*/React.createElement(Spinner, {
11
+ size: "small",
12
+ fill: Blue.S99
13
+ }));
14
+ };
6
15
  export var NoOptionList = function NoOptionList(_ref) {
7
16
  var _ref$noOptionsMessage = _ref.noOptionsMessage,
8
17
  noOptionsMessage = _ref$noOptionsMessage === void 0 ? 'No matching results' : _ref$noOptionsMessage;
9
- return /*#__PURE__*/React.createElement(EmptyOptionContainer, null, /*#__PURE__*/React.createElement(Typography, {
18
+ return /*#__PURE__*/React.createElement(EmptyOptionContainer, {
19
+ className: "menu-option-empty"
20
+ }, /*#__PURE__*/React.createElement(Typography, {
10
21
  as: "span",
11
22
  variant: "body2",
12
23
  color: Neutral.B40
@@ -14,6 +25,8 @@ export var NoOptionList = function NoOptionList(_ref) {
14
25
  };
15
26
  export var OptionList = function OptionList(_ref2) {
16
27
  var allowMultiple = _ref2.allowMultiple,
28
+ _ref2$loading = _ref2.loading,
29
+ loading = _ref2$loading === void 0 ? false : _ref2$loading,
17
30
  noOptionsMessage = _ref2.noOptionsMessage,
18
31
  onMenuClose = _ref2.onMenuClose,
19
32
  onSelect = _ref2.onSelect,
@@ -44,8 +57,14 @@ export var OptionList = function OptionList(_ref2) {
44
57
  onMenuClose();
45
58
  }
46
59
  };
60
+ if (loading) {
61
+ return /*#__PURE__*/React.createElement(OptionListContainer, {
62
+ width: width
63
+ }, /*#__PURE__*/React.createElement(MenuOptionLoading, null));
64
+ }
47
65
  return /*#__PURE__*/React.createElement(OptionListContainer, {
48
- width: width
66
+ width: width,
67
+ className: "menu-option-list"
49
68
  }, hasMenuOptions ? /*#__PURE__*/React.createElement(Menu, {
50
69
  allowMultiple: allowMultiple,
51
70
  options: menuOptions,
@@ -9,6 +9,7 @@ export interface SearchableSelectState {
9
9
  export declare type SearchableSelectInputProps = Omit<InputProps, 'type' | 'onChange' | 'onSelect'> & {
10
10
  canClear?: boolean;
11
11
  filterOptions?: (str: string) => Option[];
12
+ onInputChange?(value: string): void;
12
13
  onSelect?({ value }: {
13
14
  value: string;
14
15
  }): void;
@@ -23,6 +24,7 @@ export declare type SearchableSelectInputProps = Omit<InputProps, 'type' | 'onCh
23
24
  export declare const SearchableSelectInput: React.ForwardRefExoticComponent<Omit<InputProps, "type" | "onChange" | "onSelect"> & {
24
25
  canClear?: boolean;
25
26
  filterOptions?: (str: string) => Option[];
27
+ onInputChange?(value: string): void;
26
28
  onSelect?({ value }: {
27
29
  value: string;
28
30
  }): void;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["disabled", "error", "filterOptions", "onSelect", "placeholder", "prefix", "selectedValue", "width", "inputValue", "updateInputValue", "onFocus", "searchableSelectState", "updateSearchableSelectState", "options", "updateMenuOptions"];
3
+ var _excluded = ["disabled", "error", "filterOptions", "onSelect", "placeholder", "prefix", "selectedValue", "width", "inputValue", "updateInputValue", "onInputChange", "onFocus", "searchableSelectState", "updateSearchableSelectState", "options", "updateMenuOptions"];
4
4
  import React, { forwardRef, useEffect, useRef, useState } from 'react';
5
5
  import { StyledInput, StyledPrefixContainer } from '../../../Input/InputStyle';
6
6
  import { ClearSelected } from './ClearSelected';
@@ -17,6 +17,7 @@ export var SearchableSelectInput = /*#__PURE__*/forwardRef(function SearchableSe
17
17
  width = _ref.width,
18
18
  inputValue = _ref.inputValue,
19
19
  updateInputValue = _ref.updateInputValue,
20
+ onInputChange = _ref.onInputChange,
20
21
  onFocus = _ref.onFocus,
21
22
  _ref$searchableSelect = _ref.searchableSelectState,
22
23
  showInput = _ref$searchableSelect.showInput,
@@ -49,6 +50,9 @@ export var SearchableSelectInput = /*#__PURE__*/forwardRef(function SearchableSe
49
50
  };
50
51
  var handleInputChange = function handleInputChange(e) {
51
52
  var str = e.currentTarget.value;
53
+ if (onInputChange) {
54
+ onInputChange(str);
55
+ }
52
56
  updateInputValue(str);
53
57
  var filteredOptions = filterOptions(str);
54
58
  updateMenuOptions(filteredOptions);
@@ -97,6 +101,7 @@ export var SearchableSelectInput = /*#__PURE__*/forwardRef(function SearchableSe
97
101
  setShowClear(false);
98
102
  }, [selectedValue]);
99
103
  return /*#__PURE__*/React.createElement(StyledContainer, {
104
+ className: "select-input-container",
100
105
  ref: ref,
101
106
  "data-error": error,
102
107
  "data-disabled": disabled,
@@ -4,4 +4,6 @@ interface SearchableSingleSelectProps {
4
4
  data?: Option[];
5
5
  }
6
6
  export declare const SearchableSingle: ({ data, ...args }: SearchableSingleSelectProps) => JSX.Element;
7
+ export declare const SearchableSingleWithInputState: ({ data, ...args }: SearchableSingleSelectProps) => JSX.Element;
8
+ export declare const AsyncSearchableSingleWithInputState: ({ data, ...args }: SearchableSingleSelectProps) => JSX.Element;
7
9
  export {};
@@ -1,7 +1,12 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
1
2
  import _extends from "@babel/runtime/helpers/extends";
2
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["data"];
4
- import React, { useState } from 'react';
4
+ var _excluded = ["data"],
5
+ _excluded2 = ["data"],
6
+ _excluded3 = ["data"];
7
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
+ import React, { useEffect, useState } from 'react';
9
+ import { debounce } from '../../../helpers/debounce';
5
10
  import { Select } from '../Select';
6
11
  export var SearchableSingle = function SearchableSingle(_ref) {
7
12
  var data = _ref.data,
@@ -21,4 +26,140 @@ export var SearchableSingle = function SearchableSingle(_ref) {
21
26
  searchable: true,
22
27
  label: "Label"
23
28
  }));
29
+ };
30
+ export var SearchableSingleWithInputState = function SearchableSingleWithInputState(_ref3) {
31
+ var data = _ref3.data,
32
+ args = _objectWithoutPropertiesLoose(_ref3, _excluded2);
33
+ var _useState2 = useState(''),
34
+ inputValue = _useState2[0],
35
+ setInputValue = _useState2[1];
36
+ var _useState3 = useState(''),
37
+ selected = _useState3[0],
38
+ setSelected = _useState3[1];
39
+ var handleInputChange = function handleInputChange(value) {
40
+ setInputValue(value);
41
+ };
42
+ var handleSelect = function handleSelect(_ref4) {
43
+ var value = _ref4.value;
44
+ setSelected(value);
45
+ };
46
+ return /*#__PURE__*/React.createElement(Select, _extends({}, args, {
47
+ onSelect: handleSelect,
48
+ options: data,
49
+ selectedValues: [selected],
50
+ searchableProps: {
51
+ inputValue: inputValue,
52
+ onInputChange: function onInputChange(value) {
53
+ return handleInputChange(value);
54
+ }
55
+ },
56
+ width: "600px",
57
+ label: "Label"
58
+ }));
59
+ };
60
+ var filterOptions = function filterOptions(str, data) {
61
+ if (str === '') {
62
+ return data;
63
+ }
64
+ var filterRegex = new RegExp(str, 'i');
65
+ var filterOptions = data.filter(function (option) {
66
+ return option.label.match(filterRegex);
67
+ });
68
+ return filterOptions;
69
+ };
70
+ var mockAsyncOptions = function mockAsyncOptions(str, data) {
71
+ return new Promise(function (resolve) {
72
+ setTimeout(function () {
73
+ var filteredOptions = filterOptions(str, data);
74
+ resolve(filteredOptions);
75
+ }, 1000);
76
+ });
77
+ };
78
+ export var AsyncSearchableSingleWithInputState = function AsyncSearchableSingleWithInputState(_ref5) {
79
+ var data = _ref5.data,
80
+ args = _objectWithoutPropertiesLoose(_ref5, _excluded3);
81
+ var _useState4 = useState(false),
82
+ loading = _useState4[0],
83
+ setLoading = _useState4[1];
84
+ var _useState5 = useState([]),
85
+ mockData = _useState5[0],
86
+ setMockData = _useState5[1];
87
+ var _useState6 = useState(''),
88
+ inputValue = _useState6[0],
89
+ setInputValue = _useState6[1];
90
+ var _useState7 = useState(''),
91
+ selected = _useState7[0],
92
+ setSelected = _useState7[1];
93
+ var handleInputChange = /*#__PURE__*/function () {
94
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
95
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
96
+ while (1) switch (_context.prev = _context.next) {
97
+ case 0:
98
+ setInputValue(value);
99
+ case 1:
100
+ case "end":
101
+ return _context.stop();
102
+ }
103
+ }, _callee);
104
+ }));
105
+ return function handleInputChange(_x) {
106
+ return _ref6.apply(this, arguments);
107
+ };
108
+ }();
109
+ var debounceHandleInputChange = debounce(handleInputChange);
110
+ var handleSelect = function handleSelect(_ref7) {
111
+ var value = _ref7.value;
112
+ setSelected(value);
113
+ };
114
+ useEffect(function () {
115
+ var fetchMockData = /*#__PURE__*/function () {
116
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
117
+ var response;
118
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
119
+ while (1) switch (_context2.prev = _context2.next) {
120
+ case 0:
121
+ _context2.prev = 0;
122
+ setLoading(true);
123
+ _context2.next = 4;
124
+ return mockAsyncOptions(inputValue, data);
125
+ case 4:
126
+ response = _context2.sent;
127
+ setMockData(response);
128
+ setLoading(false);
129
+ _context2.next = 12;
130
+ break;
131
+ case 9:
132
+ _context2.prev = 9;
133
+ _context2.t0 = _context2["catch"](0);
134
+ setLoading(false);
135
+ case 12:
136
+ case "end":
137
+ return _context2.stop();
138
+ }
139
+ }, _callee2, null, [[0, 9]]);
140
+ }));
141
+ return function fetchMockData() {
142
+ return _ref8.apply(this, arguments);
143
+ };
144
+ }();
145
+ if (inputValue === '') {
146
+ setMockData([]);
147
+ return;
148
+ }
149
+ fetchMockData();
150
+ }, [data, inputValue]);
151
+ return /*#__PURE__*/React.createElement(Select, _extends({}, args, {
152
+ loadingOptions: loading,
153
+ onSelect: handleSelect,
154
+ options: mockData,
155
+ selectedValues: [selected],
156
+ searchableProps: {
157
+ inputValue: inputValue,
158
+ onInputChange: function onInputChange(value) {
159
+ return debounceHandleInputChange(value);
160
+ }
161
+ },
162
+ width: "600px",
163
+ label: "Label"
164
+ }));
24
165
  };
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { ComponentAction } from '../../types/componentAction';
3
+ export interface SideSheetProps {
4
+ isOpen: boolean;
5
+ title: string;
6
+ description?: string;
7
+ showHorizontalLine?: boolean;
8
+ children?: React.ReactNode;
9
+ basicButtonAction?: ComponentAction;
10
+ primaryButtonAction?: ComponentAction;
11
+ showBackButton?: boolean;
12
+ onBack?: () => void;
13
+ showCloseButton?: boolean;
14
+ onClose?: () => void;
15
+ }
16
+ declare const SideSheet: React.ForwardRefExoticComponent<SideSheetProps & React.RefAttributes<HTMLDivElement>>;
17
+ export { SideSheet };
@@ -0,0 +1,100 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ var _excluded = ["isOpen", "title", "description", "showHorizontalLine", "children", "basicButtonAction", "primaryButtonAction", "showBackButton", "onBack", "showCloseButton", "onClose"];
4
+ import React, { useEffect, useState, useRef } from 'react';
5
+ import { Button, PrimaryButton } from '../Button';
6
+ import { ButtonGroup } from '../ButtonGroup';
7
+ import { Icon } from '../Icon';
8
+ import { Neutral } from '../utilities/colors';
9
+ import { Portal } from '../Portal/Portal';
10
+ import { StyledSideSheetContainer, StyledSideSheetWrapper, StyledSideSheetHeader, StyledButtonContainer, StyledRightContainer, StyledHorizontalLine, StyledSideSheetFooter, StyledButtonGroupContainer } from './SideSheetStyle';
11
+ import { Typography } from '../Typography';
12
+ var SideSheet = /*#__PURE__*/React.forwardRef(function SideSheet(_ref, ref) {
13
+ var isOpen = _ref.isOpen,
14
+ title = _ref.title,
15
+ description = _ref.description,
16
+ _ref$showHorizontalLi = _ref.showHorizontalLine,
17
+ showHorizontalLine = _ref$showHorizontalLi === void 0 ? true : _ref$showHorizontalLi,
18
+ children = _ref.children,
19
+ basicButtonAction = _ref.basicButtonAction,
20
+ primaryButtonAction = _ref.primaryButtonAction,
21
+ _ref$showBackButton = _ref.showBackButton,
22
+ showBackButton = _ref$showBackButton === void 0 ? true : _ref$showBackButton,
23
+ onBack = _ref.onBack,
24
+ _ref$showCloseButton = _ref.showCloseButton,
25
+ showCloseButton = _ref$showCloseButton === void 0 ? true : _ref$showCloseButton,
26
+ onClose = _ref.onClose,
27
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
28
+ useEffect(function () {
29
+ if (typeof window === 'undefined' || !window.document) return;
30
+ var enableScroll = function enableScroll() {
31
+ return document.body.style.overflow = 'unset';
32
+ };
33
+ isOpen ? document.body.style.overflow = 'hidden' : enableScroll();
34
+ return function () {
35
+ enableScroll();
36
+ };
37
+ }, [isOpen]);
38
+
39
+ // store state for closing animation, and cleanup when unmounting
40
+ var _useState = useState(false),
41
+ isClosedAnimation = _useState[0],
42
+ setIsClosedAnimation = _useState[1];
43
+ var timeoutId = useRef(null);
44
+ useEffect(function () {
45
+ return function () {
46
+ if (timeoutId.current) {
47
+ clearTimeout(timeoutId.current);
48
+ }
49
+ };
50
+ }, []);
51
+
52
+ // fade out effect for 0.2seconds when closed
53
+ var handleClose = function handleClose() {
54
+ setIsClosedAnimation(true);
55
+ timeoutId.current = setTimeout(function () {
56
+ setIsClosedAnimation(false);
57
+ onClose();
58
+ }, 190); // purposefully made this 0.19sec (to prevent rare animation glitch)
59
+ };
60
+
61
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isOpen && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(StyledSideSheetWrapper, {
62
+ className: "side-sheet-wrapper " + (isClosedAnimation ? 'closed' : ''),
63
+ onClick: handleClose
64
+ }, /*#__PURE__*/React.createElement(StyledSideSheetContainer, _extends({
65
+ className: "" + (isClosedAnimation ? 'closed' : ''),
66
+ ref: ref,
67
+ onClick: function onClick(e) {
68
+ return e.stopPropagation();
69
+ }
70
+ }, props), /*#__PURE__*/React.createElement(StyledSideSheetHeader, null, showBackButton && /*#__PURE__*/React.createElement(StyledButtonContainer, {
71
+ onClick: onBack
72
+ }, /*#__PURE__*/React.createElement(Icon, {
73
+ name: "ri-arrow-left-line"
74
+ })), /*#__PURE__*/React.createElement(Typography, {
75
+ as: "div",
76
+ variant: "subtitle1",
77
+ style: {
78
+ color: Neutral.B18
79
+ }
80
+ }, title, /*#__PURE__*/React.createElement(Typography, {
81
+ as: "div",
82
+ variant: "body1",
83
+ style: {
84
+ color: Neutral.B18
85
+ }
86
+ }, description)), showCloseButton && /*#__PURE__*/React.createElement(StyledRightContainer, null, /*#__PURE__*/React.createElement(StyledButtonContainer, {
87
+ "data-testid": "sidesheet-close-btn",
88
+ onClick: handleClose
89
+ }, /*#__PURE__*/React.createElement(Icon, {
90
+ name: "ri-close"
91
+ })))), showHorizontalLine && /*#__PURE__*/React.createElement(StyledHorizontalLine, null), children, /*#__PURE__*/React.createElement(StyledSideSheetFooter, null, /*#__PURE__*/React.createElement(StyledHorizontalLine, null), /*#__PURE__*/React.createElement(StyledButtonGroupContainer, null, /*#__PURE__*/React.createElement(ButtonGroup, {
92
+ fullWidth: true
93
+ }, basicButtonAction && /*#__PURE__*/React.createElement(Button, {
94
+ onClick: basicButtonAction.action,
95
+ fullWidth: true
96
+ }, basicButtonAction.label), primaryButtonAction && /*#__PURE__*/React.createElement(PrimaryButton, {
97
+ onClick: primaryButtonAction.action
98
+ }, primaryButtonAction.label))))))));
99
+ });
100
+ export { SideSheet };
@@ -0,0 +1,6 @@
1
+ import { Meta } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const Interactive: any;
5
+ export declare const WithTabsInteractive: any;
6
+ export declare const WithLockedScrollableBackdrop: any;
@@ -0,0 +1,8 @@
1
+ export declare const StyledSideSheetWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const StyledSideSheetContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const StyledSideSheetHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ export declare const StyledButtonContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
5
+ export declare const StyledRightContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
6
+ export declare const StyledHorizontalLine: import("styled-components").StyledComponent<"hr", any, {}, never>;
7
+ export declare const StyledSideSheetFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
8
+ export declare const StyledButtonGroupContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,35 @@
1
+ import styled from 'styled-components';
2
+ import { Neutral } from '../utilities/colors';
3
+ import * as Breakpoints from '../utilities/breakpoints';
4
+ export var StyledSideSheetWrapper = styled.div.withConfig({
5
+ displayName: "SideSheetStyle__StyledSideSheetWrapper",
6
+ componentId: "sc-z0rzf0-0"
7
+ })(["position:fixed;inset:0;background-color:rgba(45,45,45,0.5);display:flex;align-items:center;justify-content:center;overflow:hidden;z-index:999;animation:fade-in2 0.2s;&.closed{animation:fade-out2 0.2s;}@keyframes fade-in2{0%{opacity:0;}100%{opacity:1;}}@keyframes fade-out2{0%{opacity:1;}100%{opacity:0;}}"]);
8
+ export var StyledSideSheetContainer = styled.div.withConfig({
9
+ displayName: "SideSheetStyle__StyledSideSheetContainer",
10
+ componentId: "sc-z0rzf0-1"
11
+ })(["position:absolute;display:flex;flex-direction:column;width:480px;height:100vh;background:", ";box-shadow:0px 26px 80px rgba(0,0,0,0.2),0px 0px 1px rgba(0,0,0,0.2);overflow:hidden;animation:slide-in 0.2s;top:0;right:0;&.closed{animation:slide-out 0.2s;}@keyframes slide-in{0%{opacity:0;transform:translateX(100%);}100%{opacity:1;}}@keyframes slide-out{0%{opacity:0;}100%{opacity:1;transform:translateX(100%);}}@media (max-width:", "){width:100vw;}"], Neutral.B100, Breakpoints.large);
12
+ export var StyledSideSheetHeader = styled.div.withConfig({
13
+ displayName: "SideSheetStyle__StyledSideSheetHeader",
14
+ componentId: "sc-z0rzf0-2"
15
+ })(["display:flex;align-items:top;padding:16px 20px;"]);
16
+ export var StyledButtonContainer = styled.div.withConfig({
17
+ displayName: "SideSheetStyle__StyledButtonContainer",
18
+ componentId: "sc-z0rzf0-3"
19
+ })(["cursor:pointer;margin:4px 8px 4px 0px;svg{width:24px;fill:", ";}"], Neutral.B40);
20
+ export var StyledRightContainer = styled.div.withConfig({
21
+ displayName: "SideSheetStyle__StyledRightContainer",
22
+ componentId: "sc-z0rzf0-4"
23
+ })(["margin-left:auto;"]);
24
+ export var StyledHorizontalLine = styled.hr.withConfig({
25
+ displayName: "SideSheetStyle__StyledHorizontalLine",
26
+ componentId: "sc-z0rzf0-5"
27
+ })(["height:1px;background-color:", ";margin:0px 0px;border:none;"], Neutral.B95);
28
+ export var StyledSideSheetFooter = styled.div.withConfig({
29
+ displayName: "SideSheetStyle__StyledSideSheetFooter",
30
+ componentId: "sc-z0rzf0-6"
31
+ })(["margin-top:auto;"]);
32
+ export var StyledButtonGroupContainer = styled.div.withConfig({
33
+ displayName: "SideSheetStyle__StyledButtonGroupContainer",
34
+ componentId: "sc-z0rzf0-7"
35
+ })(["margin:16px 20px;"]);
@@ -0,0 +1 @@
1
+ export * from './SideSheet';
@@ -0,0 +1 @@
1
+ export * from './SideSheet';
@@ -0,0 +1 @@
1
+ export declare const debounce: (func: any, delay?: number) => (...args: any) => void;