glints-aries 4.0.246 → 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.
- package/es/@next/Bar/Bar.d.ts +3 -0
- package/es/@next/Bar/Bar.js +12 -3
- package/es/@next/Bar/Bar.stories.d.ts +2 -0
- package/es/@next/Bar/BarStyle.d.ts +1 -0
- package/es/@next/Bar/BarStyle.js +7 -3
- package/es/@next/Select/Select.d.ts +2 -1
- package/es/@next/Select/Select.js +19 -0
- package/es/@next/Select/Select.stories.d.ts +1 -0
- package/es/@next/Select/components/Activator/ActivatorTextInput.js +1 -0
- package/es/@next/Select/components/OptionList/OptionList.d.ts +3 -2
- package/es/@next/Select/components/OptionList/OptionList.js +22 -3
- package/es/@next/Select/components/SearchableSelectInput/SearchableSelectInput.js +1 -0
- package/es/@next/Select/selectStoryHelper/SearchableSingleSelect.d.ts +1 -0
- package/es/@next/Select/selectStoryHelper/SearchableSingleSelect.js +112 -2
- package/es/@next/SideSheet/SideSheet.d.ts +17 -0
- package/es/@next/SideSheet/SideSheet.js +100 -0
- package/es/@next/SideSheet/SideSheet.stories.d.ts +6 -0
- package/es/@next/SideSheet/SideSheetStyle.d.ts +8 -0
- package/es/@next/SideSheet/SideSheetStyle.js +35 -0
- package/es/@next/SideSheet/index.d.ts +1 -0
- package/es/@next/SideSheet/index.js +1 -0
- package/es/helpers/debounce.d.ts +1 -0
- package/es/helpers/debounce.js +16 -0
- package/lib/@next/Bar/Bar.d.ts +3 -0
- package/lib/@next/Bar/Bar.js +11 -2
- package/lib/@next/Bar/Bar.stories.d.ts +2 -0
- package/lib/@next/Bar/BarStyle.d.ts +1 -0
- package/lib/@next/Bar/BarStyle.js +9 -4
- package/lib/@next/Select/Select.d.ts +2 -1
- package/lib/@next/Select/Select.js +19 -0
- package/lib/@next/Select/Select.stories.d.ts +1 -0
- package/lib/@next/Select/components/Activator/ActivatorTextInput.js +1 -0
- package/lib/@next/Select/components/OptionList/OptionList.d.ts +3 -2
- package/lib/@next/Select/components/OptionList/OptionList.js +23 -3
- package/lib/@next/Select/components/SearchableSelectInput/SearchableSelectInput.js +1 -0
- package/lib/@next/Select/selectStoryHelper/SearchableSingleSelect.d.ts +1 -0
- package/lib/@next/Select/selectStoryHelper/SearchableSingleSelect.js +114 -3
- package/lib/@next/SideSheet/SideSheet.d.ts +17 -0
- package/lib/@next/SideSheet/SideSheet.js +107 -0
- package/lib/@next/SideSheet/SideSheet.stories.d.ts +6 -0
- package/lib/@next/SideSheet/SideSheetStyle.d.ts +8 -0
- package/lib/@next/SideSheet/SideSheetStyle.js +50 -0
- package/lib/@next/SideSheet/index.d.ts +1 -0
- package/lib/@next/SideSheet/index.js +9 -0
- package/lib/helpers/debounce.d.ts +1 -0
- package/lib/helpers/debounce.js +21 -0
- package/package.json +1 -1
package/es/@next/Bar/Bar.d.ts
CHANGED
|
@@ -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>>;
|
package/es/@next/Bar/Bar.js
CHANGED
|
@@ -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,
|
|
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, {
|
|
@@ -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>;
|
package/es/@next/Bar/BarStyle.js
CHANGED
|
@@ -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:
|
|
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
|
|
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,
|
|
@@ -8,6 +8,7 @@ export declare const NonSearchableDisabled: any;
|
|
|
8
8
|
export declare const SearchableMultiSelect: any;
|
|
9
9
|
export declare const SearchableSingleSelect: any;
|
|
10
10
|
export declare const SearchableSingleWithInputState: any;
|
|
11
|
+
export declare const AsyncSearchableSingleWithInputState: any;
|
|
11
12
|
export declare const MultiSelectScrollable: any;
|
|
12
13
|
export declare const WithInlineError: any;
|
|
13
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) {
|
|
@@ -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
|
-
|
|
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,
|
|
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,
|
|
@@ -101,6 +101,7 @@ export var SearchableSelectInput = /*#__PURE__*/forwardRef(function SearchableSe
|
|
|
101
101
|
setShowClear(false);
|
|
102
102
|
}, [selectedValue]);
|
|
103
103
|
return /*#__PURE__*/React.createElement(StyledContainer, {
|
|
104
|
+
className: "select-input-container",
|
|
104
105
|
ref: ref,
|
|
105
106
|
"data-error": error,
|
|
106
107
|
"data-disabled": disabled,
|
|
@@ -5,4 +5,5 @@ interface SearchableSingleSelectProps {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const SearchableSingle: ({ data, ...args }: SearchableSingleSelectProps) => JSX.Element;
|
|
7
7
|
export declare const SearchableSingleWithInputState: ({ data, ...args }: SearchableSingleSelectProps) => JSX.Element;
|
|
8
|
+
export declare const AsyncSearchableSingleWithInputState: ({ data, ...args }: SearchableSingleSelectProps) => JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -1,8 +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
4
|
var _excluded = ["data"],
|
|
4
|
-
_excluded2 = ["data"]
|
|
5
|
-
|
|
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';
|
|
6
10
|
import { Select } from '../Select';
|
|
7
11
|
export var SearchableSingle = function SearchableSingle(_ref) {
|
|
8
12
|
var data = _ref.data,
|
|
@@ -52,4 +56,110 @@ export var SearchableSingleWithInputState = function SearchableSingleWithInputSt
|
|
|
52
56
|
width: "600px",
|
|
53
57
|
label: "Label"
|
|
54
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
|
+
}));
|
|
55
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var _this = this;
|
|
2
|
+
export var debounce = function debounce(func, delay) {
|
|
3
|
+
if (delay === void 0) {
|
|
4
|
+
delay = 500;
|
|
5
|
+
}
|
|
6
|
+
var timeoutID;
|
|
7
|
+
return function () {
|
|
8
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
|
+
args[_key] = arguments[_key];
|
|
10
|
+
}
|
|
11
|
+
clearTimeout(timeoutID);
|
|
12
|
+
timeoutID = setTimeout(function () {
|
|
13
|
+
func.apply(_this, args);
|
|
14
|
+
}, delay);
|
|
15
|
+
};
|
|
16
|
+
};
|
package/lib/@next/Bar/Bar.d.ts
CHANGED
|
@@ -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>>;
|
package/lib/@next/Bar/Bar.js
CHANGED
|
@@ -7,6 +7,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
7
7
|
var _ = require("..");
|
|
8
8
|
var _Button = require("../Button");
|
|
9
9
|
var _ButtonGroup = require("../ButtonGroup");
|
|
10
|
+
var _Icon = require("../Icon");
|
|
10
11
|
var _Typography = require("../Typography");
|
|
11
12
|
var _BarStyle = require("./BarStyle");
|
|
12
13
|
var _useWindowSize2 = require("./useWindowSize");
|
|
@@ -16,7 +17,11 @@ var Bar = /*#__PURE__*/_react["default"].forwardRef(function Bar(_ref, ref) {
|
|
|
16
17
|
primaryAction = _ref.primaryAction,
|
|
17
18
|
secondaryAction = _ref.secondaryAction,
|
|
18
19
|
tertiaryAction = _ref.tertiaryAction,
|
|
19
|
-
position = _ref.position
|
|
20
|
+
position = _ref.position,
|
|
21
|
+
_ref$showBackButton = _ref.showBackButton,
|
|
22
|
+
showBackButton = _ref$showBackButton === void 0 ? false : _ref$showBackButton,
|
|
23
|
+
onBack = _ref.onBack,
|
|
24
|
+
customActionGroup = _ref.customActionGroup;
|
|
20
25
|
var headerMarkup = function headerMarkup() {
|
|
21
26
|
if (subheading) {
|
|
22
27
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Typography.Typography, {
|
|
@@ -42,7 +47,11 @@ var Bar = /*#__PURE__*/_react["default"].forwardRef(function Bar(_ref, ref) {
|
|
|
42
47
|
return /*#__PURE__*/_react["default"].createElement(_BarStyle.StyledBar, {
|
|
43
48
|
"data-align": position,
|
|
44
49
|
ref: ref
|
|
45
|
-
}, /*#__PURE__*/_react["default"].createElement(_BarStyle.StyledBarContainer, null,
|
|
50
|
+
}, /*#__PURE__*/_react["default"].createElement(_BarStyle.StyledBarContainer, null, showBackButton && /*#__PURE__*/_react["default"].createElement(_BarStyle.StyledButtonContainer, {
|
|
51
|
+
onClick: onBack
|
|
52
|
+
}, /*#__PURE__*/_react["default"].createElement(_Icon.Icon, {
|
|
53
|
+
name: "ri-arrow-left-line"
|
|
54
|
+
})), /*#__PURE__*/_react["default"].createElement(_BarStyle.StyledBarHeaderWrapper, null, headerMarkup(), " "), /*#__PURE__*/_react["default"].createElement(_BarStyle.StyledBarActionWrapper, null, customActionGroup ? customActionGroup : /*#__PURE__*/_react["default"].createElement(_ButtonGroup.ButtonGroup, null, tertiaryAction && /*#__PURE__*/_react["default"].createElement(_Button.Button, {
|
|
46
55
|
onClick: tertiaryAction.action,
|
|
47
56
|
size: buttonSize
|
|
48
57
|
}, tertiaryAction.label), secondaryAction && /*#__PURE__*/_react["default"].createElement(_Button.Button, {
|
|
@@ -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>;
|