@dnanpm/styleguide 1.7.0 → 1.9.0
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/build/cjs/components/Accordion/Accordion.d.ts +38 -0
- package/build/cjs/components/Accordion/Accordion.js +35 -0
- package/build/cjs/components/Accordion/AccordionItem.d.ts +45 -0
- package/build/cjs/components/Accordion/AccordionItem.js +100 -0
- package/build/cjs/components/Accordion/index.d.ts +2 -0
- package/build/cjs/components/AmountSelector/AmountSelector.d.ts +66 -0
- package/build/cjs/components/AmountSelector/AmountSelector.js +84 -0
- package/build/cjs/components/Card/Card.js +1 -2
- package/build/cjs/components/Card/CardRow.js +0 -1
- package/build/cjs/components/Checkbox/Checkbox.d.ts +1 -0
- package/build/cjs/components/Checkbox/Checkbox.js +7 -2
- package/build/cjs/components/Footer/{index.d.ts → Footer.d.ts} +0 -1
- package/build/cjs/components/Footer/{index.js → Footer.js} +3 -2
- package/build/cjs/components/Footer/context/FooterContext.d.ts +1 -1
- package/build/{es/components/Helper/index.d.ts → cjs/components/Helper/Helper.d.ts} +1 -1
- package/build/cjs/components/Helper/{index.js → Helper.js} +0 -0
- package/build/cjs/components/Icon/Icons.d.ts +1 -0
- package/build/cjs/components/Icon/Icons.js +3 -0
- package/build/cjs/components/Image/{index.d.ts → Image.d.ts} +0 -0
- package/build/cjs/components/Image/{index.js → Image.js} +0 -0
- package/build/cjs/components/Input/Input.js +4 -4
- package/build/cjs/components/LabelText/LabelText.d.ts +2 -2
- package/build/cjs/components/LabelText/LabelText.js +1 -1
- package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.js +3 -9
- package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.js +9 -9
- package/build/cjs/components/MainNavigation/ChildComponents/LinkModifier.js +2 -2
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +7 -5
- package/build/cjs/components/MainNavigation/ChildComponents/MinicartTooltip.js +6 -6
- package/build/cjs/components/MainNavigation/{index.d.ts → MainNavigation.d.ts} +0 -1
- package/build/cjs/components/MainNavigation/{index.js → MainNavigation.js} +3 -2
- package/build/cjs/components/Notification/Notification.d.ts +40 -17
- package/build/cjs/components/Notification/Notification.js +28 -48
- package/build/cjs/components/NotificationBadge/{index.d.ts → NotificationBadge.d.ts} +0 -0
- package/build/cjs/components/NotificationBadge/{index.js → NotificationBadge.js} +0 -0
- package/build/cjs/components/PixelLoader/PixelLoader.d.ts +1 -1
- package/build/cjs/components/PixelLoader/PixelLoader.js +1 -1
- package/build/cjs/components/ProgressIndicator/{index.d.ts → ProgressIndicator.d.ts} +2 -2
- package/build/cjs/components/ProgressIndicator/{index.js → ProgressIndicator.js} +1 -1
- package/build/cjs/components/RadioButton/RadioButton.d.ts +1 -1
- package/build/cjs/components/RadioButton/RadioButton.js +1 -1
- package/build/{es/components/ReadMore/index.d.ts → cjs/components/ReadMore/ReadMore.d.ts} +1 -1
- package/build/cjs/components/ReadMore/{index.js → ReadMore.js} +1 -1
- package/build/cjs/components/Ribbon/Ribbon.d.ts +57 -0
- package/build/cjs/components/Ribbon/Ribbon.js +80 -0
- package/build/cjs/components/Search/Search.d.ts +44 -5
- package/build/cjs/components/Search/Search.js +3 -3
- package/build/cjs/components/SecondaryNavigation/{index.d.ts → SecondaryNavigation.d.ts} +1 -0
- package/build/cjs/components/SecondaryNavigation/{index.js → SecondaryNavigation.js} +3 -2
- package/build/cjs/components/Selectbox/Selectbox.d.ts +8 -4
- package/build/cjs/components/Selectbox/Selectbox.js +8 -8
- package/build/cjs/components/Textarea/Textarea.d.ts +25 -0
- package/build/cjs/components/Textarea/Textarea.js +83 -0
- package/build/{es/components/Tooltip/index.d.ts → cjs/components/Tooltip/Tooltip.d.ts} +2 -1
- package/build/cjs/components/Tooltip/{index.js → Tooltip.js} +0 -1
- package/build/cjs/components/index.d.ts +14 -10
- package/build/cjs/hooks/useDebounceFunc.d.ts +1 -0
- package/build/cjs/hooks/useDebounceFunc.js +19 -0
- package/build/cjs/hooks/useDocHeight.d.ts +1 -0
- package/build/cjs/hooks/useDocHeight.js +25 -0
- package/build/cjs/hooks/useElementDimensions.d.ts +5 -0
- package/build/cjs/hooks/useElementDimensions.js +37 -0
- package/build/cjs/index.js +28 -18
- package/build/es/components/Accordion/Accordion.d.ts +38 -0
- package/build/es/components/Accordion/Accordion.js +27 -0
- package/build/es/components/Accordion/AccordionItem.d.ts +45 -0
- package/build/es/components/Accordion/AccordionItem.js +91 -0
- package/build/es/components/Accordion/index.d.ts +2 -0
- package/build/es/components/AmountSelector/AmountSelector.d.ts +66 -0
- package/build/es/components/AmountSelector/AmountSelector.js +76 -0
- package/build/es/components/Card/Card.js +1 -2
- package/build/es/components/Card/CardRow.js +0 -1
- package/build/es/components/Checkbox/Checkbox.d.ts +1 -0
- package/build/es/components/Checkbox/Checkbox.js +7 -2
- package/build/es/components/Footer/{index.d.ts → Footer.d.ts} +0 -1
- package/build/es/components/Footer/{index.js → Footer.js} +3 -2
- package/build/es/components/Footer/context/FooterContext.d.ts +1 -1
- package/build/{cjs/components/Helper/index.d.ts → es/components/Helper/Helper.d.ts} +1 -1
- package/build/es/components/Helper/{index.js → Helper.js} +0 -0
- package/build/es/components/Icon/Icons.d.ts +1 -0
- package/build/es/components/Icon/Icons.js +3 -1
- package/build/es/components/Image/{index.d.ts → Image.d.ts} +0 -0
- package/build/es/components/Image/{index.js → Image.js} +0 -0
- package/build/es/components/Input/Input.js +4 -4
- package/build/es/components/LabelText/LabelText.d.ts +2 -2
- package/build/es/components/LabelText/LabelText.js +1 -1
- package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.js +3 -9
- package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.js +9 -9
- package/build/es/components/MainNavigation/ChildComponents/LinkModifier.js +2 -2
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +7 -5
- package/build/es/components/MainNavigation/ChildComponents/MinicartTooltip.js +5 -5
- package/build/es/components/MainNavigation/{index.d.ts → MainNavigation.d.ts} +0 -1
- package/build/es/components/MainNavigation/{index.js → MainNavigation.js} +3 -2
- package/build/es/components/Notification/Notification.d.ts +40 -17
- package/build/es/components/Notification/Notification.js +28 -48
- package/build/es/components/NotificationBadge/{index.d.ts → NotificationBadge.d.ts} +0 -0
- package/build/es/components/NotificationBadge/{index.js → NotificationBadge.js} +0 -0
- package/build/es/components/PixelLoader/PixelLoader.d.ts +1 -1
- package/build/es/components/PixelLoader/PixelLoader.js +1 -1
- package/build/es/components/ProgressIndicator/{index.d.ts → ProgressIndicator.d.ts} +2 -2
- package/build/es/components/ProgressIndicator/{index.js → ProgressIndicator.js} +1 -1
- package/build/es/components/RadioButton/RadioButton.d.ts +1 -1
- package/build/es/components/RadioButton/RadioButton.js +1 -1
- package/build/{cjs/components/ReadMore/index.d.ts → es/components/ReadMore/ReadMore.d.ts} +1 -1
- package/build/es/components/ReadMore/{index.js → ReadMore.js} +1 -1
- package/build/es/components/Ribbon/Ribbon.d.ts +57 -0
- package/build/es/components/Ribbon/Ribbon.js +71 -0
- package/build/es/components/Search/Search.d.ts +44 -5
- package/build/es/components/Search/Search.js +3 -3
- package/build/es/components/SecondaryNavigation/{index.d.ts → SecondaryNavigation.d.ts} +1 -0
- package/build/es/components/SecondaryNavigation/{index.js → SecondaryNavigation.js} +3 -2
- package/build/es/components/Selectbox/Selectbox.d.ts +8 -4
- package/build/es/components/Selectbox/Selectbox.js +8 -8
- package/build/es/components/Textarea/Textarea.d.ts +25 -0
- package/build/es/components/Textarea/Textarea.js +75 -0
- package/build/{cjs/components/Tooltip/index.d.ts → es/components/Tooltip/Tooltip.d.ts} +2 -1
- package/build/es/components/Tooltip/{index.js → Tooltip.js} +0 -1
- package/build/es/components/index.d.ts +14 -10
- package/build/es/hooks/useDebounceFunc.d.ts +1 -0
- package/build/es/hooks/useDebounceFunc.js +15 -0
- package/build/es/hooks/useDocHeight.d.ts +1 -0
- package/build/es/hooks/useDocHeight.js +21 -0
- package/build/es/hooks/useElementDimensions.d.ts +5 -0
- package/build/es/hooks/useElementDimensions.js +33 -0
- package/build/es/index.js +14 -9
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ const selectBoxStyles = {
|
|
|
36
36
|
control: (styles, state) => {
|
|
37
37
|
const customControlStyles = {
|
|
38
38
|
...borderStyles,
|
|
39
|
-
height:
|
|
39
|
+
height: getMultipliedSize(theme.base.baseHeight, 4),
|
|
40
40
|
borderBottomColor: state.menuIsOpen ? theme.color.white : 'inherit',
|
|
41
41
|
'&:hover': {
|
|
42
42
|
borderColor: theme.color.gray25,
|
|
@@ -80,7 +80,7 @@ const selectBoxStyles = {
|
|
|
80
80
|
return { ...styles, ...customOptionStyles };
|
|
81
81
|
},
|
|
82
82
|
};
|
|
83
|
-
const SelectBox = ({
|
|
83
|
+
const SelectBox = ({ dropDownIndicator, 'data-testid': dataTestId, isSearchable = false, isClearable = false, isMulti = false, noOptionsText = '', isLoading = false, isDisabled = false, isRequired = false, error = false, ...props }) => {
|
|
84
84
|
const getNoOptionsText = () => noOptionsText;
|
|
85
85
|
const DropdownIndicator = (dropdownIndicatorProps) => {
|
|
86
86
|
const { color = isDisabled ? theme.color.gray40 : theme.color.black, iconSize = '1rem' } = {
|
|
@@ -91,19 +91,19 @@ const SelectBox = ({ className, label, onChange, options, value, dropDownIndicat
|
|
|
91
91
|
return 'hlMagnifyingGlass';
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
|
-
return dropdownIndicatorProps.selectProps.menuIsOpen ? '
|
|
94
|
+
return dropdownIndicatorProps.selectProps.menuIsOpen ? 'chevronUp' : 'chevronDown';
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
return (components.DropdownIndicator && (React.createElement(components.DropdownIndicator, Object.assign({}, dropdownIndicatorProps),
|
|
98
98
|
React.createElement(Icon, { color: color, name: getIconName(), size: iconSize }))));
|
|
99
99
|
};
|
|
100
|
-
return (React.createElement("div", { className: className, "data-testid": dataTestId }, !isLoading ? (React.createElement(FieldContainer, { disabled: isDisabled, error: error },
|
|
101
|
-
label && (React.createElement(LabelText,
|
|
102
|
-
label,
|
|
100
|
+
return (React.createElement("div", { className: props.className, "data-testid": dataTestId }, !isLoading ? (React.createElement(FieldContainer, { disabled: isDisabled, error: error },
|
|
101
|
+
props.label && (React.createElement(LabelText, { htmlFor: props.inputId },
|
|
102
|
+
props.label,
|
|
103
103
|
" ",
|
|
104
104
|
isRequired && React.createElement(Mandatory, null, "*"))),
|
|
105
|
-
React.createElement(Select, { styles: selectBoxStyles, components: { DropdownIndicator }, options: options, classNamePrefix: "react_select", onChange: onChange, value: value, placeholder: placeholder, noOptionsMessage: getNoOptionsText, isSearchable: isSearchable, isDisabled: isDisabled }),
|
|
106
|
-
error && errorMessage && React.createElement(ErrorMessage, null, errorMessage))) : (React.createElement(PixelLoader, null))));
|
|
105
|
+
React.createElement(Select, { inputId: props.inputId, styles: selectBoxStyles, components: { DropdownIndicator }, options: props.options, classNamePrefix: "react_select", onChange: props.onChange, onInputChange: props.onInputChange, value: props.value, placeholder: props.placeholder, noOptionsMessage: getNoOptionsText, isSearchable: isSearchable, isClearable: isClearable, isMulti: isMulti, isDisabled: isDisabled }),
|
|
106
|
+
error && props.errorMessage && (React.createElement(ErrorMessage, null, props.errorMessage)))) : (React.createElement(PixelLoader, null))));
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
export default SelectBox;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TextareaProps {
|
|
3
|
+
label?: string;
|
|
4
|
+
name: string;
|
|
5
|
+
value?: string | number;
|
|
6
|
+
onBlur?: (value: string, event: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
7
|
+
onChange?: (value: string, event: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
8
|
+
onFocus?: (event: React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
9
|
+
onKeyPress?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
10
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
11
|
+
/**
|
|
12
|
+
* @default 'text'
|
|
13
|
+
*/
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
height?: number;
|
|
19
|
+
tabIndex?: number;
|
|
20
|
+
commentMessage?: string;
|
|
21
|
+
'data-testid'?: string;
|
|
22
|
+
}
|
|
23
|
+
declare const Textarea: React.FunctionComponent<TextareaProps>;
|
|
24
|
+
/** @component */
|
|
25
|
+
export default Textarea;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from '../../themes/styled.js';
|
|
3
|
+
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
4
|
+
import { LabelText } from '../LabelText/LabelText.js';
|
|
5
|
+
|
|
6
|
+
const Tag = styled.textarea `
|
|
7
|
+
display: block;
|
|
8
|
+
padding: ${props => getMultipliedSize(props.theme.base.baseWidth, 1)};
|
|
9
|
+
font-family: ${props => props.theme.fontFamily.baseFontFamily};
|
|
10
|
+
font-size: ${props => props.theme.fontSize.defaultFontSize};
|
|
11
|
+
width: 100%;
|
|
12
|
+
border: 1px solid ${props => props.theme.color.gray15};
|
|
13
|
+
&::-ms-clear,
|
|
14
|
+
&::-ms-reveal {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
&:disabled,
|
|
18
|
+
&[disabled] {
|
|
19
|
+
background-color: ${props => props.theme.color.gray5};
|
|
20
|
+
color: ${props => props.theme.color.gray40};
|
|
21
|
+
}
|
|
22
|
+
&:focus {
|
|
23
|
+
outline: 0;
|
|
24
|
+
box-shadow: 0 0 5px ${props => props.theme.color.gray25};
|
|
25
|
+
}
|
|
26
|
+
&:placeholder {
|
|
27
|
+
color: ${props => props.theme.color.gray25};
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
const Mandatory = styled.span `
|
|
31
|
+
color: ${props => props.theme.color.hotPink};
|
|
32
|
+
`;
|
|
33
|
+
const FieldWrapper = styled.div `
|
|
34
|
+
position: relative;
|
|
35
|
+
`;
|
|
36
|
+
const FieldContainer = styled.div `
|
|
37
|
+
color: ${props => props && props.disabled ? props.theme.color.gray40 : props.theme.color.text};
|
|
38
|
+
margin-bottom: ${props => getMultipliedSize(props.theme.base.baseWidth, 1)};
|
|
39
|
+
`;
|
|
40
|
+
const CommentMessage = styled.div `
|
|
41
|
+
line-height: 1.125rem;
|
|
42
|
+
font-size: ${props => props.theme.fontSize.smallFontSize};
|
|
43
|
+
color: ${props => props.theme.color.gray40};
|
|
44
|
+
margin-top: ${props => getMultipliedSize(props.theme.base.baseHeight, 0.5)};
|
|
45
|
+
`;
|
|
46
|
+
const Textarea = ({ id, label, name, required, disabled, onBlur, onFocus, onChange, onKeyPress, onKeyDown, value, placeholder, commentMessage, height = 3, 'data-testid': dataTestId, ...props }) => {
|
|
47
|
+
const inputId = id || name;
|
|
48
|
+
const inputRef = React.useRef(null);
|
|
49
|
+
const handleOnBlur = React.useCallback((e) => {
|
|
50
|
+
if (onBlur) {
|
|
51
|
+
onBlur(e.target.value, e);
|
|
52
|
+
}
|
|
53
|
+
}, [onBlur]);
|
|
54
|
+
const handleChange = React.useCallback((e) => {
|
|
55
|
+
if (onChange) {
|
|
56
|
+
onChange(e.target.value, e);
|
|
57
|
+
}
|
|
58
|
+
}, [onChange]);
|
|
59
|
+
const onClick = React.useCallback((e) => {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
if (inputRef && inputRef.current) {
|
|
62
|
+
inputRef.current.focus();
|
|
63
|
+
}
|
|
64
|
+
}, []);
|
|
65
|
+
const renderField = () => (React.createElement(Tag, Object.assign({ name: name, id: inputId, value: value, rows: height, placeholder: placeholder, onChange: handleChange, onBlur: handleOnBlur, onFocus: onFocus, onClick: onClick, onKeyDown: onKeyDown, onKeyPress: onKeyPress, required: required, disabled: disabled, "aria-disabled": disabled, "aria-label": inputId, ref: inputRef, "data-testid": dataTestId }, props)));
|
|
66
|
+
return (React.createElement(FieldContainer, { disabled: disabled },
|
|
67
|
+
label && (React.createElement(LabelText, { htmlFor: id, "data-testid": dataTestId && `${dataTestId}-label` },
|
|
68
|
+
label,
|
|
69
|
+
" ",
|
|
70
|
+
required && React.createElement(Mandatory, null, "*"))),
|
|
71
|
+
React.createElement(FieldWrapper, null, renderField()),
|
|
72
|
+
commentMessage && (React.createElement(CommentMessage, { "data-testid": dataTestId && `${dataTestId}-comment` }, commentMessage))));
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default Textarea;
|
|
@@ -5,7 +5,7 @@ interface TooltipProps {
|
|
|
5
5
|
children?: string;
|
|
6
6
|
width?: string;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
declare const Tooltip: import("styled-components").StyledComponent<typeof ReactTooltip, {
|
|
9
9
|
base: {
|
|
10
10
|
baseHeight: {
|
|
11
11
|
value: number;
|
|
@@ -100,4 +100,5 @@ export declare const Tooltip: import("styled-components").StyledComponent<typeof
|
|
|
100
100
|
}, {
|
|
101
101
|
suppressClassNameWarning: boolean;
|
|
102
102
|
} & TooltipProps, "suppressClassNameWarning">;
|
|
103
|
+
/** @component */
|
|
103
104
|
export default Tooltip;
|
|
@@ -1,28 +1,32 @@
|
|
|
1
|
+
export * from './Accordion';
|
|
2
|
+
export { default as AmountSelector } from './AmountSelector/AmountSelector';
|
|
1
3
|
export * from './Buttons';
|
|
2
4
|
export * from './Card';
|
|
3
5
|
export { default as Checkbox } from './Checkbox/Checkbox';
|
|
4
6
|
export { default as DnaLogo } from './DnaLogo/DnaLogo';
|
|
5
7
|
export { default as EmptyState } from './EmptyState/EmptyState';
|
|
6
|
-
export { default as Footer } from './Footer';
|
|
7
|
-
export { default as Helper } from './Helper';
|
|
8
|
+
export { default as Footer } from './Footer/Footer';
|
|
9
|
+
export { default as Helper } from './Helper/Helper';
|
|
8
10
|
export { default as Icon } from './Icon/Icon';
|
|
9
|
-
export { default as Image } from './Image';
|
|
10
|
-
export { default as Input } from './Input/Input';
|
|
11
|
+
export { default as Image } from './Image/Image';
|
|
12
|
+
export { default as Input, InputFieldProps } from './Input/Input';
|
|
11
13
|
export { default as Label } from './Label/Label';
|
|
12
14
|
export { default as LabelText } from './LabelText/LabelText';
|
|
13
|
-
export { default as MainNavigation } from './MainNavigation';
|
|
15
|
+
export { default as MainNavigation } from './MainNavigation/MainNavigation';
|
|
14
16
|
export { default as Modal } from './Modal/Modal';
|
|
15
17
|
export { default as Notification } from './Notification/Notification';
|
|
16
|
-
export { default as NotificationBadge } from './NotificationBadge';
|
|
18
|
+
export { default as NotificationBadge } from './NotificationBadge/NotificationBadge';
|
|
17
19
|
export { default as PixelLoader } from './PixelLoader/PixelLoader';
|
|
18
|
-
export { default as ProgressIndicator } from './ProgressIndicator';
|
|
20
|
+
export { default as ProgressIndicator } from './ProgressIndicator/ProgressIndicator';
|
|
19
21
|
export { default as RadioButton } from './RadioButton/RadioButton';
|
|
20
|
-
export { default as ReadMore } from './ReadMore';
|
|
22
|
+
export { default as ReadMore } from './ReadMore/ReadMore';
|
|
23
|
+
export { default as Ribbon } from './Ribbon/Ribbon';
|
|
21
24
|
export { default as Search } from './Search/Search';
|
|
22
|
-
export { default as SecondaryNavigation } from './SecondaryNavigation';
|
|
25
|
+
export { default as SecondaryNavigation } from './SecondaryNavigation/SecondaryNavigation';
|
|
23
26
|
export { default as Selectbox } from './Selectbox/Selectbox';
|
|
24
27
|
export { default as Switch } from './Switch/Switch';
|
|
25
28
|
export { default as Tab, TabStyle } from './Tabs/Tab';
|
|
26
29
|
export { default as Tabs, Tablist } from './Tabs/Tabs';
|
|
27
|
-
export { default as
|
|
30
|
+
export { default as Textarea, TextareaProps } from './Textarea/Textarea';
|
|
31
|
+
export { default as Tooltip } from './Tooltip/Tooltip';
|
|
28
32
|
export { default as TooltipMenu } from './TooltipMenu/TooltipMenu';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useDebounceFunc: (func: (...args: any[]) => any, delay?: number) => (...args: any[]) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_DELAY = 400;
|
|
4
|
+
const useDebounceFunc = (func, delay = DEFAULT_DELAY) => {
|
|
5
|
+
const debounce = useRef();
|
|
6
|
+
return useCallback((...args) => {
|
|
7
|
+
if (debounce.current)
|
|
8
|
+
clearTimeout(debounce.current);
|
|
9
|
+
debounce.current = setTimeout(() => {
|
|
10
|
+
func(args);
|
|
11
|
+
}, delay);
|
|
12
|
+
}, [func, delay]);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { useDebounceFunc };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useDocHeight: () => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
import { useDebounceFunc } from './useDebounceFunc.js';
|
|
3
|
+
|
|
4
|
+
const DEBOUNCE_DELAY = 100;
|
|
5
|
+
const useDocHeight = () => {
|
|
6
|
+
const setDocHeight = useCallback(() => {
|
|
7
|
+
document.documentElement.style.setProperty('--vh100', window.innerHeight + 'px');
|
|
8
|
+
}, []);
|
|
9
|
+
const debounceSetDocHeight = useDebounceFunc(setDocHeight, DEBOUNCE_DELAY);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setDocHeight();
|
|
12
|
+
window.addEventListener('resize', debounceSetDocHeight);
|
|
13
|
+
window.addEventListener('orientationchange', debounceSetDocHeight);
|
|
14
|
+
return () => {
|
|
15
|
+
window.removeEventListener('resize', debounceSetDocHeight);
|
|
16
|
+
window.removeEventListener('orientationchange', debounceSetDocHeight);
|
|
17
|
+
};
|
|
18
|
+
}, [debounceSetDocHeight, setDocHeight]);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { useDocHeight };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get element dimensions when layout changes
|
|
5
|
+
*/
|
|
6
|
+
const ResizeObserver = typeof window !== 'undefined' && window.ResizeObserver;
|
|
7
|
+
function useResizeObserver() {
|
|
8
|
+
const [size, setSize] = useState({ width: 0, height: 0 });
|
|
9
|
+
const resizeObserver = useRef(null);
|
|
10
|
+
const onResize = useCallback(entries => {
|
|
11
|
+
const { width, height } = entries[0].contentRect;
|
|
12
|
+
setSize({ width, height });
|
|
13
|
+
}, []);
|
|
14
|
+
const ref = useCallback(node => {
|
|
15
|
+
if (node !== null && ResizeObserver) {
|
|
16
|
+
if (resizeObserver.current) {
|
|
17
|
+
resizeObserver.current.disconnect();
|
|
18
|
+
}
|
|
19
|
+
resizeObserver.current = new ResizeObserver(onResize);
|
|
20
|
+
if (resizeObserver.current) {
|
|
21
|
+
resizeObserver.current.observe(node);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}, [onResize]);
|
|
25
|
+
useEffect(() => () => {
|
|
26
|
+
if (resizeObserver.current) {
|
|
27
|
+
resizeObserver.current.disconnect();
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
return { ref, width: size.width, height: size.height };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default useResizeObserver;
|
package/build/es/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export { default as AccordionItem } from './components/Accordion/AccordionItem.js';
|
|
2
|
+
export { default as Accordion } from './components/Accordion/Accordion.js';
|
|
3
|
+
export { default as AmountSelector } from './components/AmountSelector/AmountSelector.js';
|
|
1
4
|
export { Button } from './components/Buttons/ButtonDefault.js';
|
|
2
5
|
export { default as ButtonPrimary } from './components/Buttons/ButtonPrimary.js';
|
|
3
6
|
export { default as ButtonSecondary } from './components/Buttons/ButtonSecondary.js';
|
|
@@ -11,28 +14,30 @@ export { default as CardRow } from './components/Card/CardRow.js';
|
|
|
11
14
|
export { default as Checkbox } from './components/Checkbox/Checkbox.js';
|
|
12
15
|
export { default as DnaLogo } from './components/DnaLogo/DnaLogo.js';
|
|
13
16
|
export { default as EmptyState } from './components/EmptyState/EmptyState.js';
|
|
14
|
-
export { default as Footer } from './components/Footer/
|
|
15
|
-
export { default as Helper } from './components/Helper/
|
|
17
|
+
export { default as Footer } from './components/Footer/Footer.js';
|
|
18
|
+
export { default as Helper } from './components/Helper/Helper.js';
|
|
16
19
|
export { default as Icon } from './components/Icon/Icon.js';
|
|
17
|
-
export { default as Image } from './components/Image/
|
|
20
|
+
export { default as Image } from './components/Image/Image.js';
|
|
18
21
|
export { default as Input } from './components/Input/Input.js';
|
|
19
22
|
export { default as Label } from './components/Label/Label.js';
|
|
20
23
|
export { LabelText } from './components/LabelText/LabelText.js';
|
|
21
|
-
export { default as MainNavigation } from './components/MainNavigation/
|
|
24
|
+
export { default as MainNavigation } from './components/MainNavigation/MainNavigation.js';
|
|
22
25
|
export { default as Modal } from './components/Modal/Modal.js';
|
|
23
26
|
export { default as Notification } from './components/Notification/Notification.js';
|
|
24
|
-
export { NotificationBadge } from './components/NotificationBadge/
|
|
27
|
+
export { NotificationBadge } from './components/NotificationBadge/NotificationBadge.js';
|
|
25
28
|
export { PixelLoader } from './components/PixelLoader/PixelLoader.js';
|
|
26
|
-
export { default as ProgressIndicator } from './components/ProgressIndicator/
|
|
29
|
+
export { default as ProgressIndicator } from './components/ProgressIndicator/ProgressIndicator.js';
|
|
27
30
|
export { default as RadioButton } from './components/RadioButton/RadioButton.js';
|
|
28
|
-
export { default as ReadMore } from './components/ReadMore/
|
|
31
|
+
export { default as ReadMore } from './components/ReadMore/ReadMore.js';
|
|
32
|
+
export { default as Ribbon } from './components/Ribbon/Ribbon.js';
|
|
29
33
|
export { default as Search } from './components/Search/Search.js';
|
|
30
|
-
export { default as SecondaryNavigation } from './components/SecondaryNavigation/
|
|
34
|
+
export { default as SecondaryNavigation } from './components/SecondaryNavigation/SecondaryNavigation.js';
|
|
31
35
|
export { default as Selectbox } from './components/Selectbox/Selectbox.js';
|
|
32
36
|
export { default as Switch } from './components/Switch/Switch.js';
|
|
33
37
|
export { default as Tab, TabStyle } from './components/Tabs/Tab.js';
|
|
34
38
|
export { Tablist, default as Tabs } from './components/Tabs/Tabs.js';
|
|
35
|
-
export {
|
|
39
|
+
export { default as Textarea } from './components/Textarea/Textarea.js';
|
|
40
|
+
export { default as Tooltip } from './components/Tooltip/Tooltip.js';
|
|
36
41
|
export { default as TooltipMenu } from './components/TooltipMenu/TooltipMenu.js';
|
|
37
42
|
export { default as createStyled } from './utils/createStyled.js';
|
|
38
43
|
export { default as styled } from './themes/styled.js';
|