@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.
Files changed (125) hide show
  1. package/build/cjs/components/Accordion/Accordion.d.ts +38 -0
  2. package/build/cjs/components/Accordion/Accordion.js +35 -0
  3. package/build/cjs/components/Accordion/AccordionItem.d.ts +45 -0
  4. package/build/cjs/components/Accordion/AccordionItem.js +100 -0
  5. package/build/cjs/components/Accordion/index.d.ts +2 -0
  6. package/build/cjs/components/AmountSelector/AmountSelector.d.ts +66 -0
  7. package/build/cjs/components/AmountSelector/AmountSelector.js +84 -0
  8. package/build/cjs/components/Card/Card.js +1 -2
  9. package/build/cjs/components/Card/CardRow.js +0 -1
  10. package/build/cjs/components/Checkbox/Checkbox.d.ts +1 -0
  11. package/build/cjs/components/Checkbox/Checkbox.js +7 -2
  12. package/build/cjs/components/Footer/{index.d.ts → Footer.d.ts} +0 -1
  13. package/build/cjs/components/Footer/{index.js → Footer.js} +3 -2
  14. package/build/cjs/components/Footer/context/FooterContext.d.ts +1 -1
  15. package/build/{es/components/Helper/index.d.ts → cjs/components/Helper/Helper.d.ts} +1 -1
  16. package/build/cjs/components/Helper/{index.js → Helper.js} +0 -0
  17. package/build/cjs/components/Icon/Icons.d.ts +1 -0
  18. package/build/cjs/components/Icon/Icons.js +3 -0
  19. package/build/cjs/components/Image/{index.d.ts → Image.d.ts} +0 -0
  20. package/build/cjs/components/Image/{index.js → Image.js} +0 -0
  21. package/build/cjs/components/Input/Input.js +4 -4
  22. package/build/cjs/components/LabelText/LabelText.d.ts +2 -2
  23. package/build/cjs/components/LabelText/LabelText.js +1 -1
  24. package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.js +3 -9
  25. package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.js +9 -9
  26. package/build/cjs/components/MainNavigation/ChildComponents/LinkModifier.js +2 -2
  27. package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +7 -5
  28. package/build/cjs/components/MainNavigation/ChildComponents/MinicartTooltip.js +6 -6
  29. package/build/cjs/components/MainNavigation/{index.d.ts → MainNavigation.d.ts} +0 -1
  30. package/build/cjs/components/MainNavigation/{index.js → MainNavigation.js} +3 -2
  31. package/build/cjs/components/Notification/Notification.d.ts +40 -17
  32. package/build/cjs/components/Notification/Notification.js +28 -48
  33. package/build/cjs/components/NotificationBadge/{index.d.ts → NotificationBadge.d.ts} +0 -0
  34. package/build/cjs/components/NotificationBadge/{index.js → NotificationBadge.js} +0 -0
  35. package/build/cjs/components/PixelLoader/PixelLoader.d.ts +1 -1
  36. package/build/cjs/components/PixelLoader/PixelLoader.js +1 -1
  37. package/build/cjs/components/ProgressIndicator/{index.d.ts → ProgressIndicator.d.ts} +2 -2
  38. package/build/cjs/components/ProgressIndicator/{index.js → ProgressIndicator.js} +1 -1
  39. package/build/cjs/components/RadioButton/RadioButton.d.ts +1 -1
  40. package/build/cjs/components/RadioButton/RadioButton.js +1 -1
  41. package/build/{es/components/ReadMore/index.d.ts → cjs/components/ReadMore/ReadMore.d.ts} +1 -1
  42. package/build/cjs/components/ReadMore/{index.js → ReadMore.js} +1 -1
  43. package/build/cjs/components/Ribbon/Ribbon.d.ts +57 -0
  44. package/build/cjs/components/Ribbon/Ribbon.js +80 -0
  45. package/build/cjs/components/Search/Search.d.ts +44 -5
  46. package/build/cjs/components/Search/Search.js +3 -3
  47. package/build/cjs/components/SecondaryNavigation/{index.d.ts → SecondaryNavigation.d.ts} +1 -0
  48. package/build/cjs/components/SecondaryNavigation/{index.js → SecondaryNavigation.js} +3 -2
  49. package/build/cjs/components/Selectbox/Selectbox.d.ts +8 -4
  50. package/build/cjs/components/Selectbox/Selectbox.js +8 -8
  51. package/build/cjs/components/Textarea/Textarea.d.ts +25 -0
  52. package/build/cjs/components/Textarea/Textarea.js +83 -0
  53. package/build/{es/components/Tooltip/index.d.ts → cjs/components/Tooltip/Tooltip.d.ts} +2 -1
  54. package/build/cjs/components/Tooltip/{index.js → Tooltip.js} +0 -1
  55. package/build/cjs/components/index.d.ts +14 -10
  56. package/build/cjs/hooks/useDebounceFunc.d.ts +1 -0
  57. package/build/cjs/hooks/useDebounceFunc.js +19 -0
  58. package/build/cjs/hooks/useDocHeight.d.ts +1 -0
  59. package/build/cjs/hooks/useDocHeight.js +25 -0
  60. package/build/cjs/hooks/useElementDimensions.d.ts +5 -0
  61. package/build/cjs/hooks/useElementDimensions.js +37 -0
  62. package/build/cjs/index.js +28 -18
  63. package/build/es/components/Accordion/Accordion.d.ts +38 -0
  64. package/build/es/components/Accordion/Accordion.js +27 -0
  65. package/build/es/components/Accordion/AccordionItem.d.ts +45 -0
  66. package/build/es/components/Accordion/AccordionItem.js +91 -0
  67. package/build/es/components/Accordion/index.d.ts +2 -0
  68. package/build/es/components/AmountSelector/AmountSelector.d.ts +66 -0
  69. package/build/es/components/AmountSelector/AmountSelector.js +76 -0
  70. package/build/es/components/Card/Card.js +1 -2
  71. package/build/es/components/Card/CardRow.js +0 -1
  72. package/build/es/components/Checkbox/Checkbox.d.ts +1 -0
  73. package/build/es/components/Checkbox/Checkbox.js +7 -2
  74. package/build/es/components/Footer/{index.d.ts → Footer.d.ts} +0 -1
  75. package/build/es/components/Footer/{index.js → Footer.js} +3 -2
  76. package/build/es/components/Footer/context/FooterContext.d.ts +1 -1
  77. package/build/{cjs/components/Helper/index.d.ts → es/components/Helper/Helper.d.ts} +1 -1
  78. package/build/es/components/Helper/{index.js → Helper.js} +0 -0
  79. package/build/es/components/Icon/Icons.d.ts +1 -0
  80. package/build/es/components/Icon/Icons.js +3 -1
  81. package/build/es/components/Image/{index.d.ts → Image.d.ts} +0 -0
  82. package/build/es/components/Image/{index.js → Image.js} +0 -0
  83. package/build/es/components/Input/Input.js +4 -4
  84. package/build/es/components/LabelText/LabelText.d.ts +2 -2
  85. package/build/es/components/LabelText/LabelText.js +1 -1
  86. package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.js +3 -9
  87. package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.js +9 -9
  88. package/build/es/components/MainNavigation/ChildComponents/LinkModifier.js +2 -2
  89. package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +7 -5
  90. package/build/es/components/MainNavigation/ChildComponents/MinicartTooltip.js +5 -5
  91. package/build/es/components/MainNavigation/{index.d.ts → MainNavigation.d.ts} +0 -1
  92. package/build/es/components/MainNavigation/{index.js → MainNavigation.js} +3 -2
  93. package/build/es/components/Notification/Notification.d.ts +40 -17
  94. package/build/es/components/Notification/Notification.js +28 -48
  95. package/build/es/components/NotificationBadge/{index.d.ts → NotificationBadge.d.ts} +0 -0
  96. package/build/es/components/NotificationBadge/{index.js → NotificationBadge.js} +0 -0
  97. package/build/es/components/PixelLoader/PixelLoader.d.ts +1 -1
  98. package/build/es/components/PixelLoader/PixelLoader.js +1 -1
  99. package/build/es/components/ProgressIndicator/{index.d.ts → ProgressIndicator.d.ts} +2 -2
  100. package/build/es/components/ProgressIndicator/{index.js → ProgressIndicator.js} +1 -1
  101. package/build/es/components/RadioButton/RadioButton.d.ts +1 -1
  102. package/build/es/components/RadioButton/RadioButton.js +1 -1
  103. package/build/{cjs/components/ReadMore/index.d.ts → es/components/ReadMore/ReadMore.d.ts} +1 -1
  104. package/build/es/components/ReadMore/{index.js → ReadMore.js} +1 -1
  105. package/build/es/components/Ribbon/Ribbon.d.ts +57 -0
  106. package/build/es/components/Ribbon/Ribbon.js +71 -0
  107. package/build/es/components/Search/Search.d.ts +44 -5
  108. package/build/es/components/Search/Search.js +3 -3
  109. package/build/es/components/SecondaryNavigation/{index.d.ts → SecondaryNavigation.d.ts} +1 -0
  110. package/build/es/components/SecondaryNavigation/{index.js → SecondaryNavigation.js} +3 -2
  111. package/build/es/components/Selectbox/Selectbox.d.ts +8 -4
  112. package/build/es/components/Selectbox/Selectbox.js +8 -8
  113. package/build/es/components/Textarea/Textarea.d.ts +25 -0
  114. package/build/es/components/Textarea/Textarea.js +75 -0
  115. package/build/{cjs/components/Tooltip/index.d.ts → es/components/Tooltip/Tooltip.d.ts} +2 -1
  116. package/build/es/components/Tooltip/{index.js → Tooltip.js} +0 -1
  117. package/build/es/components/index.d.ts +14 -10
  118. package/build/es/hooks/useDebounceFunc.d.ts +1 -0
  119. package/build/es/hooks/useDebounceFunc.js +15 -0
  120. package/build/es/hooks/useDocHeight.d.ts +1 -0
  121. package/build/es/hooks/useDocHeight.js +21 -0
  122. package/build/es/hooks/useElementDimensions.d.ts +5 -0
  123. package/build/es/hooks/useElementDimensions.js +33 -0
  124. package/build/es/index.js +14 -9
  125. package/package.json +1 -1
@@ -1,15 +1,54 @@
1
1
  import React from 'react';
2
2
  export interface SearchProps {
3
- /** Allows to pass a custom className */
4
- className?: string;
3
+ /**
4
+ * The input element's name
5
+ * Submitted with the form as part of a name/value pair
6
+ */
5
7
  name: string;
6
- onChange?: (...args: any[]) => any;
7
- onClick?: (...args: any[]) => any;
8
+ /**
9
+ * The input element unique identifier
10
+ * Must be unique in the whole document
11
+ */
8
12
  id?: string;
13
+ /**
14
+ * The input element's value
15
+ * When specified, it represents the initial value
16
+ */
9
17
  value?: string;
18
+ /**
19
+ * Provides a brief information as to what kind of value is expected in the field
20
+ */
10
21
  placeholder?: string;
11
- iconSize?: string;
22
+ /**
23
+ * If defined, input element will automatically have focus when the page has finished loading
24
+ * In cases when more than one element in the document has the autofocus attribute defined,
25
+ * only first one receives focus
26
+ */
27
+ autoFocus?: boolean;
28
+ /**
29
+ * Icon from Icons component shown next to input element
30
+ *
31
+ * @default 'hlMagnifyingGlass'
32
+ */
12
33
  iconName?: string;
34
+ /**
35
+ * Size of the icon shown next to input element
36
+ *
37
+ * @default '1.6em'
38
+ */
39
+ iconSize?: string;
40
+ /**
41
+ * Allows to pass a custom className
42
+ */
43
+ className?: string;
44
+ /**
45
+ * On input element change callback
46
+ */
47
+ onChange?: (...args: any[]) => any;
48
+ /**
49
+ * On icon element click callback
50
+ */
51
+ onClick?: (...args: any[]) => any;
13
52
  }
14
53
  declare const Search: React.FunctionComponent<SearchProps>;
15
54
  /** @component */
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
  var styled = require('../../themes/styled.js');
7
- var Icon = require('../Icon/Icon.js');
8
7
  var colors = require('../../themes/themeComponents/colors.js');
8
+ var Icon = require('../Icon/Icon.js');
9
9
 
10
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
11
 
@@ -43,7 +43,7 @@ const Input = styled['default'].input `
43
43
  display: none;
44
44
  }
45
45
  `;
46
- const Search = ({ id, className, name, onChange, onClick, value = '', placeholder, iconSize = '1.6em', iconName = 'hlMagnifyingGlass', ...props }) => {
46
+ const Search = ({ value = '', iconName = 'hlMagnifyingGlass', iconSize = '1.6em', className, onChange, onClick, ...props }) => {
47
47
  const [text, setText] = React.useState(value);
48
48
  const handleChange = (e) => {
49
49
  setText(e.target.value);
@@ -58,7 +58,7 @@ const Search = ({ id, className, name, onChange, onClick, value = '', placeholde
58
58
  }
59
59
  };
60
60
  return (React__default['default'].createElement(Container, { className: className },
61
- React__default['default'].createElement(Input, Object.assign({ type: "search", name: name, value: text, placeholder: placeholder, onChange: handleChange }, props)),
61
+ React__default['default'].createElement(Input, Object.assign({ type: "search", value: text, onChange: handleChange }, props)),
62
62
  React__default['default'].createElement(Icon['default'], { name: text.length ? 'hlX' : iconName, size: iconSize, color: colors['default'].hotPink, onClick: onIconClick })));
63
63
  };
64
64
 
@@ -23,6 +23,7 @@ interface SecondaryNavigationProps {
23
23
  /** Highlighted ids */
24
24
  highlightIds?: string[];
25
25
  }
26
+ /** @visibleName Secondary Navigation */
26
27
  declare const SecondaryNavigation: ({ currentUrl, data, lang, nextJSSecondaryNavLink: NextJSSecondaryNavLink, collapseSize, "data-testid": dataTestId, "max-width": componentMaxWidth, className, matchFullUrl, mobileOnly, highlightIds, }: SecondaryNavigationProps) => JSX.Element;
27
28
  /** @component */
28
29
  export default SecondaryNavigation;
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
+ var useOutsideClick = require('../../hooks/useOutsideClick.js');
6
7
  var styled = require('../../themes/styled.js');
7
8
  var theme = require('../../themes/theme.js');
8
- var Icon = require('../Icon/Icon.js');
9
- var useOutsideClick = require('../../hooks/useOutsideClick.js');
10
9
  var styledUtils = require('../../utils/styledUtils.js');
10
+ var Icon = require('../Icon/Icon.js');
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
13
 
@@ -157,6 +157,7 @@ const IconWrapper = styled['default'].span `
157
157
  }
158
158
  `;
159
159
  const isMenuItemLinkAbsolute = (menuItemLink) => menuItemLink.includes('http');
160
+ /** @visibleName Secondary Navigation */
160
161
  const SecondaryNavigation = ({ currentUrl = '', data, lang = 'fi', nextJSSecondaryNavLink: NextJSSecondaryNavLink = false, collapseSize = 767, 'data-testid': dataTestId, 'max-width': componentMaxWidth, className, matchFullUrl = true, mobileOnly = false, highlightIds = [], }) => {
161
162
  const [isSecondaryNavOpen, setIsSecondaryNavOpen] = React.useState(false);
162
163
  const toggleNav = () => {
@@ -9,22 +9,26 @@ interface DropDownIndicator {
9
9
  iconSize?: string;
10
10
  }
11
11
  interface Props {
12
+ options: ReactSelectProps['options'];
13
+ onChange: (selectedItem: SelectboxItem) => void;
12
14
  /** Allows to pass a custom className */
13
15
  className?: string;
16
+ 'data-testid'?: string;
14
17
  label?: string;
18
+ inputId?: ReactSelectProps['inputId'];
15
19
  placeholder?: ReactSelectProps['placeholder'];
16
- onChange: (selectedItem: SelectboxItem) => void;
17
- options: ReactSelectProps['options'];
20
+ onInputChange?: ReactSelectProps['onInputChange'];
18
21
  value?: ReactSelectProps['value'];
19
- 'data-testid'?: string;
20
22
  dropDownIndicator?: DropDownIndicator;
21
23
  noOptionsText?: string;
22
24
  isSearchable?: boolean;
25
+ isClearable?: boolean;
26
+ isMulti?: boolean;
23
27
  isLoading?: boolean;
24
28
  isDisabled?: boolean;
25
29
  isRequired?: boolean;
26
30
  error?: boolean;
27
31
  errorMessage?: string;
28
32
  }
29
- declare const SelectBox: ({ className, label, onChange, options, value, dropDownIndicator, placeholder, "data-testid": dataTestId, isSearchable, noOptionsText, isLoading, isDisabled, isRequired, error, errorMessage, }: Props) => JSX.Element;
33
+ declare const SelectBox: ({ dropDownIndicator, "data-testid": dataTestId, isSearchable, isClearable, isMulti, noOptionsText, isLoading, isDisabled, isRequired, error, ...props }: Props) => JSX.Element;
30
34
  export default SelectBox;
@@ -45,7 +45,7 @@ const selectBoxStyles = {
45
45
  control: (styles, state) => {
46
46
  const customControlStyles = {
47
47
  ...borderStyles,
48
- height: '2.625rem',
48
+ height: styledUtils.getMultipliedSize(theme['default'].base.baseHeight, 4),
49
49
  borderBottomColor: state.menuIsOpen ? theme['default'].color.white : 'inherit',
50
50
  '&:hover': {
51
51
  borderColor: theme['default'].color.gray25,
@@ -89,7 +89,7 @@ const selectBoxStyles = {
89
89
  return { ...styles, ...customOptionStyles };
90
90
  },
91
91
  };
92
- const SelectBox = ({ className, label, onChange, options, value, dropDownIndicator, placeholder, 'data-testid': dataTestId, isSearchable = false, noOptionsText = '', isLoading = false, isDisabled = false, isRequired = false, error = false, errorMessage, }) => {
92
+ const SelectBox = ({ dropDownIndicator, 'data-testid': dataTestId, isSearchable = false, isClearable = false, isMulti = false, noOptionsText = '', isLoading = false, isDisabled = false, isRequired = false, error = false, ...props }) => {
93
93
  const getNoOptionsText = () => noOptionsText;
94
94
  const DropdownIndicator = (dropdownIndicatorProps) => {
95
95
  const { color = isDisabled ? theme['default'].color.gray40 : theme['default'].color.black, iconSize = '1rem' } = {
@@ -100,19 +100,19 @@ const SelectBox = ({ className, label, onChange, options, value, dropDownIndicat
100
100
  return 'hlMagnifyingGlass';
101
101
  }
102
102
  else {
103
- return dropdownIndicatorProps.selectProps.menuIsOpen ? 'chevronDown' : 'chevronUp';
103
+ return dropdownIndicatorProps.selectProps.menuIsOpen ? 'chevronUp' : 'chevronDown';
104
104
  }
105
105
  };
106
106
  return (Select.components.DropdownIndicator && (React__default['default'].createElement(Select.components.DropdownIndicator, Object.assign({}, dropdownIndicatorProps),
107
107
  React__default['default'].createElement(Icon['default'], { color: color, name: getIconName(), size: iconSize }))));
108
108
  };
109
- return (React__default['default'].createElement("div", { className: className, "data-testid": dataTestId }, !isLoading ? (React__default['default'].createElement(FieldContainer, { disabled: isDisabled, error: error },
110
- label && (React__default['default'].createElement(LabelText.LabelText, null,
111
- label,
109
+ return (React__default['default'].createElement("div", { className: props.className, "data-testid": dataTestId }, !isLoading ? (React__default['default'].createElement(FieldContainer, { disabled: isDisabled, error: error },
110
+ props.label && (React__default['default'].createElement(LabelText.LabelText, { htmlFor: props.inputId },
111
+ props.label,
112
112
  " ",
113
113
  isRequired && React__default['default'].createElement(Mandatory, null, "*"))),
114
- React__default['default'].createElement(Select__default['default'], { styles: selectBoxStyles, components: { DropdownIndicator }, options: options, classNamePrefix: "react_select", onChange: onChange, value: value, placeholder: placeholder, noOptionsMessage: getNoOptionsText, isSearchable: isSearchable, isDisabled: isDisabled }),
115
- error && errorMessage && React__default['default'].createElement(ErrorMessage, null, errorMessage))) : (React__default['default'].createElement(PixelLoader.PixelLoader, null))));
114
+ React__default['default'].createElement(Select__default['default'], { 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 }),
115
+ error && props.errorMessage && (React__default['default'].createElement(ErrorMessage, null, props.errorMessage)))) : (React__default['default'].createElement(PixelLoader.PixelLoader, null))));
116
116
  };
117
117
 
118
118
  exports.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,83 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var styled = require('../../themes/styled.js');
7
+ var styledUtils = require('../../utils/styledUtils.js');
8
+ var LabelText = require('../LabelText/LabelText.js');
9
+
10
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
+
12
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
13
+
14
+ const Tag = styled['default'].textarea `
15
+ display: block;
16
+ padding: ${props => styledUtils.getMultipliedSize(props.theme.base.baseWidth, 1)};
17
+ font-family: ${props => props.theme.fontFamily.baseFontFamily};
18
+ font-size: ${props => props.theme.fontSize.defaultFontSize};
19
+ width: 100%;
20
+ border: 1px solid ${props => props.theme.color.gray15};
21
+ &::-ms-clear,
22
+ &::-ms-reveal {
23
+ display: none;
24
+ }
25
+ &:disabled,
26
+ &[disabled] {
27
+ background-color: ${props => props.theme.color.gray5};
28
+ color: ${props => props.theme.color.gray40};
29
+ }
30
+ &:focus {
31
+ outline: 0;
32
+ box-shadow: 0 0 5px ${props => props.theme.color.gray25};
33
+ }
34
+ &:placeholder {
35
+ color: ${props => props.theme.color.gray25};
36
+ }
37
+ `;
38
+ const Mandatory = styled['default'].span `
39
+ color: ${props => props.theme.color.hotPink};
40
+ `;
41
+ const FieldWrapper = styled['default'].div `
42
+ position: relative;
43
+ `;
44
+ const FieldContainer = styled['default'].div `
45
+ color: ${props => props && props.disabled ? props.theme.color.gray40 : props.theme.color.text};
46
+ margin-bottom: ${props => styledUtils.getMultipliedSize(props.theme.base.baseWidth, 1)};
47
+ `;
48
+ const CommentMessage = styled['default'].div `
49
+ line-height: 1.125rem;
50
+ font-size: ${props => props.theme.fontSize.smallFontSize};
51
+ color: ${props => props.theme.color.gray40};
52
+ margin-top: ${props => styledUtils.getMultipliedSize(props.theme.base.baseHeight, 0.5)};
53
+ `;
54
+ const Textarea = ({ id, label, name, required, disabled, onBlur, onFocus, onChange, onKeyPress, onKeyDown, value, placeholder, commentMessage, height = 3, 'data-testid': dataTestId, ...props }) => {
55
+ const inputId = id || name;
56
+ const inputRef = React__default['default'].useRef(null);
57
+ const handleOnBlur = React__default['default'].useCallback((e) => {
58
+ if (onBlur) {
59
+ onBlur(e.target.value, e);
60
+ }
61
+ }, [onBlur]);
62
+ const handleChange = React__default['default'].useCallback((e) => {
63
+ if (onChange) {
64
+ onChange(e.target.value, e);
65
+ }
66
+ }, [onChange]);
67
+ const onClick = React__default['default'].useCallback((e) => {
68
+ e.preventDefault();
69
+ if (inputRef && inputRef.current) {
70
+ inputRef.current.focus();
71
+ }
72
+ }, []);
73
+ const renderField = () => (React__default['default'].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)));
74
+ return (React__default['default'].createElement(FieldContainer, { disabled: disabled },
75
+ label && (React__default['default'].createElement(LabelText.LabelText, { htmlFor: id, "data-testid": dataTestId && `${dataTestId}-label` },
76
+ label,
77
+ " ",
78
+ required && React__default['default'].createElement(Mandatory, null, "*"))),
79
+ React__default['default'].createElement(FieldWrapper, null, renderField()),
80
+ commentMessage && (React__default['default'].createElement(CommentMessage, { "data-testid": dataTestId && `${dataTestId}-comment` }, commentMessage))));
81
+ };
82
+
83
+ exports.default = Textarea;
@@ -5,7 +5,7 @@ interface TooltipProps {
5
5
  children?: string;
6
6
  width?: string;
7
7
  }
8
- export declare const Tooltip: import("styled-components").StyledComponent<typeof ReactTooltip, {
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;
@@ -59,5 +59,4 @@ const Tooltip = styled['default'](ReactTooltip__default['default']).attrs({ supp
59
59
  }
60
60
  `;
61
61
 
62
- exports.Tooltip = Tooltip;
63
62
  exports.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 Tooltip } from './Tooltip';
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,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ const DEFAULT_DELAY = 400;
8
+ const useDebounceFunc = (func, delay = DEFAULT_DELAY) => {
9
+ const debounce = React.useRef();
10
+ return React.useCallback((...args) => {
11
+ if (debounce.current)
12
+ clearTimeout(debounce.current);
13
+ debounce.current = setTimeout(() => {
14
+ func(args);
15
+ }, delay);
16
+ }, [func, delay]);
17
+ };
18
+
19
+ exports.useDebounceFunc = useDebounceFunc;
@@ -0,0 +1 @@
1
+ export declare const useDocHeight: () => void;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var useDebounceFunc = require('./useDebounceFunc.js');
7
+
8
+ const DEBOUNCE_DELAY = 100;
9
+ const useDocHeight = () => {
10
+ const setDocHeight = React.useCallback(() => {
11
+ document.documentElement.style.setProperty('--vh100', window.innerHeight + 'px');
12
+ }, []);
13
+ const debounceSetDocHeight = useDebounceFunc.useDebounceFunc(setDocHeight, DEBOUNCE_DELAY);
14
+ React.useEffect(() => {
15
+ setDocHeight();
16
+ window.addEventListener('resize', debounceSetDocHeight);
17
+ window.addEventListener('orientationchange', debounceSetDocHeight);
18
+ return () => {
19
+ window.removeEventListener('resize', debounceSetDocHeight);
20
+ window.removeEventListener('orientationchange', debounceSetDocHeight);
21
+ };
22
+ }, [debounceSetDocHeight, setDocHeight]);
23
+ };
24
+
25
+ exports.useDocHeight = useDocHeight;
@@ -0,0 +1,5 @@
1
+ export default function useResizeObserver(): {
2
+ ref: (node: any) => void;
3
+ width: number;
4
+ height: number;
5
+ };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ /**
8
+ * Hook to get element dimensions when layout changes
9
+ */
10
+ const ResizeObserver = typeof window !== 'undefined' && window.ResizeObserver;
11
+ function useResizeObserver() {
12
+ const [size, setSize] = React.useState({ width: 0, height: 0 });
13
+ const resizeObserver = React.useRef(null);
14
+ const onResize = React.useCallback(entries => {
15
+ const { width, height } = entries[0].contentRect;
16
+ setSize({ width, height });
17
+ }, []);
18
+ const ref = React.useCallback(node => {
19
+ if (node !== null && ResizeObserver) {
20
+ if (resizeObserver.current) {
21
+ resizeObserver.current.disconnect();
22
+ }
23
+ resizeObserver.current = new ResizeObserver(onResize);
24
+ if (resizeObserver.current) {
25
+ resizeObserver.current.observe(node);
26
+ }
27
+ }
28
+ }, [onResize]);
29
+ React.useEffect(() => () => {
30
+ if (resizeObserver.current) {
31
+ resizeObserver.current.disconnect();
32
+ }
33
+ }, []);
34
+ return { ref, width: size.width, height: size.height };
35
+ }
36
+
37
+ exports.default = useResizeObserver;
@@ -2,6 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var AccordionItem = require('./components/Accordion/AccordionItem.js');
6
+ var Accordion = require('./components/Accordion/Accordion.js');
7
+ var AmountSelector = require('./components/AmountSelector/AmountSelector.js');
5
8
  var ButtonDefault = require('./components/Buttons/ButtonDefault.js');
6
9
  var ButtonPrimary = require('./components/Buttons/ButtonPrimary.js');
7
10
  var ButtonSecondary = require('./components/Buttons/ButtonSecondary.js');
@@ -15,28 +18,30 @@ var CardRow = require('./components/Card/CardRow.js');
15
18
  var Checkbox = require('./components/Checkbox/Checkbox.js');
16
19
  var DnaLogo = require('./components/DnaLogo/DnaLogo.js');
17
20
  var EmptyState = require('./components/EmptyState/EmptyState.js');
18
- var index = require('./components/Footer/index.js');
19
- var index$1 = require('./components/Helper/index.js');
21
+ var Footer = require('./components/Footer/Footer.js');
22
+ var Helper = require('./components/Helper/Helper.js');
20
23
  var Icon = require('./components/Icon/Icon.js');
21
- var index$2 = require('./components/Image/index.js');
24
+ var Image = require('./components/Image/Image.js');
22
25
  var Input = require('./components/Input/Input.js');
23
26
  var Label = require('./components/Label/Label.js');
24
27
  var LabelText = require('./components/LabelText/LabelText.js');
25
- var index$3 = require('./components/MainNavigation/index.js');
28
+ var MainNavigation = require('./components/MainNavigation/MainNavigation.js');
26
29
  var Modal = require('./components/Modal/Modal.js');
27
30
  var Notification = require('./components/Notification/Notification.js');
28
- var index$4 = require('./components/NotificationBadge/index.js');
31
+ var NotificationBadge = require('./components/NotificationBadge/NotificationBadge.js');
29
32
  var PixelLoader = require('./components/PixelLoader/PixelLoader.js');
30
- var index$5 = require('./components/ProgressIndicator/index.js');
33
+ var ProgressIndicator = require('./components/ProgressIndicator/ProgressIndicator.js');
31
34
  var RadioButton = require('./components/RadioButton/RadioButton.js');
32
- var index$6 = require('./components/ReadMore/index.js');
35
+ var ReadMore = require('./components/ReadMore/ReadMore.js');
36
+ var Ribbon = require('./components/Ribbon/Ribbon.js');
33
37
  var Search = require('./components/Search/Search.js');
34
- var index$7 = require('./components/SecondaryNavigation/index.js');
38
+ var SecondaryNavigation = require('./components/SecondaryNavigation/SecondaryNavigation.js');
35
39
  var Selectbox = require('./components/Selectbox/Selectbox.js');
36
40
  var Switch = require('./components/Switch/Switch.js');
37
41
  var Tab = require('./components/Tabs/Tab.js');
38
42
  var Tabs = require('./components/Tabs/Tabs.js');
39
- var index$8 = require('./components/Tooltip/index.js');
43
+ var Textarea = require('./components/Textarea/Textarea.js');
44
+ var Tooltip = require('./components/Tooltip/Tooltip.js');
40
45
  var TooltipMenu = require('./components/TooltipMenu/TooltipMenu.js');
41
46
  var createStyled = require('./utils/createStyled.js');
42
47
  var styled = require('./themes/styled.js');
@@ -46,6 +51,9 @@ var navigation = require('./themes/themeComponents/navigation.js');
46
51
 
47
52
 
48
53
 
54
+ exports.AccordionItem = AccordionItem['default'];
55
+ exports.Accordion = Accordion['default'];
56
+ exports.AmountSelector = AmountSelector['default'];
49
57
  exports.Button = ButtonDefault.Button;
50
58
  exports.ButtonPrimary = ButtonPrimary['default'];
51
59
  exports.ButtonSecondary = ButtonSecondary['default'];
@@ -59,30 +67,32 @@ exports.CardRow = CardRow['default'];
59
67
  exports.Checkbox = Checkbox['default'];
60
68
  exports.DnaLogo = DnaLogo['default'];
61
69
  exports.EmptyState = EmptyState['default'];
62
- exports.Footer = index['default'];
63
- exports.Helper = index$1['default'];
70
+ exports.Footer = Footer['default'];
71
+ exports.Helper = Helper['default'];
64
72
  exports.Icon = Icon['default'];
65
- exports.Image = index$2['default'];
73
+ exports.Image = Image['default'];
66
74
  exports.Input = Input['default'];
67
75
  exports.Label = Label['default'];
68
76
  exports.LabelText = LabelText.LabelText;
69
- exports.MainNavigation = index$3['default'];
77
+ exports.MainNavigation = MainNavigation['default'];
70
78
  exports.Modal = Modal['default'];
71
79
  exports.Notification = Notification['default'];
72
- exports.NotificationBadge = index$4.NotificationBadge;
80
+ exports.NotificationBadge = NotificationBadge.NotificationBadge;
73
81
  exports.PixelLoader = PixelLoader.PixelLoader;
74
- exports.ProgressIndicator = index$5['default'];
82
+ exports.ProgressIndicator = ProgressIndicator['default'];
75
83
  exports.RadioButton = RadioButton['default'];
76
- exports.ReadMore = index$6['default'];
84
+ exports.ReadMore = ReadMore['default'];
85
+ exports.Ribbon = Ribbon['default'];
77
86
  exports.Search = Search['default'];
78
- exports.SecondaryNavigation = index$7['default'];
87
+ exports.SecondaryNavigation = SecondaryNavigation['default'];
79
88
  exports.Selectbox = Selectbox['default'];
80
89
  exports.Switch = Switch['default'];
81
90
  exports.Tab = Tab['default'];
82
91
  exports.TabStyle = Tab.TabStyle;
83
92
  exports.Tablist = Tabs.Tablist;
84
93
  exports.Tabs = Tabs['default'];
85
- exports.Tooltip = index$8.Tooltip;
94
+ exports.Textarea = Textarea['default'];
95
+ exports.Tooltip = Tooltip['default'];
86
96
  exports.TooltipMenu = TooltipMenu['default'];
87
97
  exports.createStyled = createStyled['default'];
88
98
  exports.styled = styled['default'];
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ interface AccordionProps {
3
+ /**
4
+ * Allows to pass a custom className
5
+ */
6
+ className?: string;
7
+ /**
8
+ * The actual content
9
+ * @type AccordionItem
10
+ */
11
+ children: React.ReactNode;
12
+ /** Allow multiple accordion items to be open
13
+ * @default true
14
+ */
15
+ allowMultiOpen?: boolean;
16
+ /**
17
+ * Display close button in the item content
18
+ * @default false
19
+ */
20
+ hasCloseButton?: boolean;
21
+ /**
22
+ * Title has color when item is open, hovered or focused
23
+ * @default true
24
+ */
25
+ highlightSelected?: boolean;
26
+ /**
27
+ * Label to show for the close button in the content
28
+ */
29
+ openLabel?: string;
30
+ /**
31
+ * Label to show for the close button in the content
32
+ */
33
+ closeLabel?: string;
34
+ }
35
+ /** @visibleName Accordion */
36
+ declare const Accordion: ({ className, children, allowMultiOpen, highlightSelected, hasCloseButton, openLabel, closeLabel, }: AccordionProps) => JSX.Element;
37
+ /** @component */
38
+ export default Accordion;
@@ -0,0 +1,27 @@
1
+ import React, { useState } from 'react';
2
+ import AccordionItem from './AccordionItem.js';
3
+
4
+ /** @visibleName Accordion */
5
+ const Accordion = ({ className, children, allowMultiOpen = true, highlightSelected = true, hasCloseButton = false, openLabel, closeLabel, }) => {
6
+ const [activeItem, setActiveItem] = useState(null);
7
+ const handleItemOpen = (index) => {
8
+ if (allowMultiOpen) {
9
+ return;
10
+ }
11
+ setActiveItem(index);
12
+ };
13
+ /** filter out immediate children that are not AccordionItems */
14
+ const accordionItems = React.Children.map(children, (child, index) => {
15
+ if (React.isValidElement(child) && child.type === AccordionItem) {
16
+ return (React.createElement(AccordionItem, Object.assign({ closeFromParent: !allowMultiOpen && activeItem !== index, key: index + child.props.title, hasCloseButton: hasCloseButton, highlightSelected: highlightSelected, openLabel: openLabel, closeLabel: closeLabel,
17
+ // tslint:disable-next-line: jsx-no-lambda
18
+ onOpen: () => handleItemOpen(index) }, child.props), child.props.children));
19
+ }
20
+ });
21
+ if (!accordionItems) {
22
+ return React.createElement(React.Fragment, null);
23
+ }
24
+ return React.createElement("div", { className: className }, accordionItems);
25
+ };
26
+
27
+ export default Accordion;