@dnanpm/styleguide 3.4.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/build/cjs/build/assets/fonts/fonts.css +129 -129
  2. package/build/cjs/components/Button/ButtonIcon.js +4 -0
  3. package/build/cjs/components/DateTimePicker/DateTimePicker.d.ts +12 -0
  4. package/build/cjs/components/DateTimePicker/DateTimePicker.js +15 -4
  5. package/build/cjs/components/Notification/Notification.d.ts +1 -0
  6. package/build/cjs/components/Notification/Notification.js +14 -7
  7. package/build/cjs/components/PriorityNavigation/PriorityNavigation.d.ts +9 -1
  8. package/build/cjs/components/PriorityNavigation/PriorityNavigation.js +23 -8
  9. package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +11 -3
  10. package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.js +19 -11
  11. package/build/cjs/components/Textarea/Textarea.d.ts +14 -0
  12. package/build/cjs/components/Textarea/Textarea.js +7 -2
  13. package/build/es/build/assets/fonts/fonts.css +129 -129
  14. package/build/es/components/Button/ButtonIcon.js +4 -0
  15. package/build/es/components/DateTimePicker/DateTimePicker.d.ts +12 -0
  16. package/build/es/components/DateTimePicker/DateTimePicker.js +15 -4
  17. package/build/es/components/Notification/Notification.d.ts +1 -0
  18. package/build/es/components/Notification/Notification.js +14 -7
  19. package/build/es/components/PriorityNavigation/PriorityNavigation.d.ts +9 -1
  20. package/build/es/components/PriorityNavigation/PriorityNavigation.js +25 -10
  21. package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +11 -3
  22. package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.js +19 -11
  23. package/build/es/components/Textarea/Textarea.d.ts +14 -0
  24. package/build/es/components/Textarea/Textarea.js +7 -2
  25. package/package.json +1 -1
@@ -1,129 +1,129 @@
1
- /* "DNA Text" font definition */
2
- @font-face {
3
- font-family: 'DNA Text';
4
- font-style: normal;
5
- font-weight: 400;
6
- font-display: swap;
7
- src: url('https://banner.dna.fi/fonts/DNAText-Regular.woff2') format('woff2'),
8
- url('https://banner.dna.fi/fonts/DNAText-Regular.woff') format('woff');
9
- }
10
-
11
- @font-face {
12
- font-family: 'DNA Text';
13
- font-style: normal;
14
- font-weight: 500;
15
- font-display: swap;
16
- src: url('https://banner.dna.fi/fonts/DNAText-Medium.woff2') format('woff2'),
17
- url('https://banner.dna.fi/fonts/DNAText-Medium.woff') format('woff');
18
- }
19
-
20
- @font-face {
21
- font-family: 'DNA Text';
22
- font-style: normal;
23
- font-weight: 700;
24
- font-display: swap;
25
- src: url('https://banner.dna.fi/fonts/DNAText-Bold.woff2') format('woff2'),
26
- url('https://banner.dna.fi/fonts/DNAText-Bold.woff') format('woff');
27
- }
28
-
29
- /* "DNA Heading" font definition */
30
- @font-face {
31
- font-family: 'DNA Heading';
32
- font-style: normal;
33
- font-weight: 600;
34
- font-display: swap;
35
- src: url('https://banner.dna.fi/fonts/DNAHeading-DemiBold.woff2') format('woff2'),
36
- url('https://banner.dna.fi/fonts/DNAHeading-DemiBold.woff') format('woff');
37
- }
38
-
39
- @font-face {
40
- font-family: 'DNA Heading';
41
- font-style: normal;
42
- font-weight: 700;
43
- font-display: swap;
44
- src: url('https://banner.dna.fi/fonts/DNAHeading-Bold.woff2') format('woff2'),
45
- url('https://banner.dna.fi/fonts/DNAHeading-Bold.woff') format('woff');
46
- }
47
-
48
- @font-face {
49
- font-family: 'DNA Heading';
50
- font-style: normal;
51
- font-weight: 900;
52
- font-display: swap;
53
- src: url('https://banner.dna.fi/fonts/DNAHeading-Black.woff2') format('woff2'),
54
- url('https://banner.dna.fi/fonts/DNAHeading-Black.woff') format('woff');
55
- }
56
-
57
- /* "DNA Numerals" font definition */
58
- @font-face {
59
- font-family: 'DNA Numerals';
60
- font-style: normal;
61
- font-weight: 700;
62
- font-display: swap;
63
- src: url('https://banner.dna.fi/fonts/DNANumerals-Bold.woff2') format('woff2'),
64
- url('https://banner.dna.fi/fonts/DNANumerals-Bold.woff') format('woff');
65
- }
66
-
67
- /* Direct definitons of DNA fonts */
68
- @font-face {
69
- font-family: 'DNA Text Regular';
70
- font-style: normal;
71
- font-weight: 400;
72
- font-display: swap;
73
- src: url('https://banner.dna.fi/fonts/DNAText-Regular.woff2') format('woff2'),
74
- url('https://banner.dna.fi/fonts/DNAText-Regular.woff') format('woff');
75
- }
76
-
77
- @font-face {
78
- font-family: 'DNA Text Medium';
79
- font-style: normal;
80
- font-weight: 500;
81
- font-display: swap;
82
- src: url('https://banner.dna.fi/fonts/DNAText-Medium.woff2') format('woff2'),
83
- url('https://banner.dna.fi/fonts/DNAText-Medium.woff') format('woff');
84
- }
85
-
86
- @font-face {
87
- font-family: 'DNA Text Bold';
88
- font-style: normal;
89
- font-weight: 700;
90
- font-display: swap;
91
- src: url('https://banner.dna.fi/fonts/DNAText-Bold.woff2') format('woff2'),
92
- url('https://banner.dna.fi/fonts/DNAText-Bold.woff') format('woff');
93
- }
94
-
95
- @font-face {
96
- font-family: 'DNA Heading Demi Bold';
97
- font-style: normal;
98
- font-weight: 600;
99
- font-display: swap;
100
- src: url('https://banner.dna.fi/fonts/DNAHeading-DemiBold.woff2') format('woff2'),
101
- url('https://banner.dna.fi/fonts/DNAHeading-DemiBold.woff') format('woff');
102
- }
103
-
104
- @font-face {
105
- font-family: 'DNA Heading Bold';
106
- font-style: normal;
107
- font-weight: 700;
108
- font-display: swap;
109
- src: url('https://banner.dna.fi/fonts/DNAHeading-Bold.woff2') format('woff2'),
110
- url('https://banner.dna.fi/fonts/DNAHeading-Bold.woff') format('woff');
111
- }
112
-
113
- @font-face {
114
- font-family: 'DNA Heading Black';
115
- font-style: normal;
116
- font-weight: 900;
117
- font-display: swap;
118
- src: url('https://banner.dna.fi/fonts/DNAHeading-Black.woff2') format('woff2'),
119
- url('https://banner.dna.fi/fonts/DNAHeading-Black.woff') format('woff');
120
- }
121
-
122
- @font-face {
123
- font-family: 'DNA Numerals Bold';
124
- font-style: normal;
125
- font-weight: 700;
126
- font-display: swap;
127
- src: url('https://banner.dna.fi/fonts/DNANumerals-Bold.woff2') format('woff2'),
128
- url('https://banner.dna.fi/fonts/DNANumerals-Bold.woff') format('woff');
129
- }
1
+ /* "DNA Text" font definition */
2
+ @font-face {
3
+ font-family: 'DNA Text';
4
+ font-style: normal;
5
+ font-weight: 400;
6
+ font-display: swap;
7
+ src: url('https://www.dna.fi/fonts/DNAText-Regular.woff2') format('woff2'),
8
+ url('https://www.dna.fi/fonts/DNAText-Regular.woff') format('woff');
9
+ }
10
+
11
+ @font-face {
12
+ font-family: 'DNA Text';
13
+ font-style: normal;
14
+ font-weight: 500;
15
+ font-display: swap;
16
+ src: url('https://www.dna.fi/fonts/DNAText-Medium.woff2') format('woff2'),
17
+ url('https://www.dna.fi/fonts/DNAText-Medium.woff') format('woff');
18
+ }
19
+
20
+ @font-face {
21
+ font-family: 'DNA Text';
22
+ font-style: normal;
23
+ font-weight: 700;
24
+ font-display: swap;
25
+ src: url('https://www.dna.fi/fonts/DNAText-Bold.woff2') format('woff2'),
26
+ url('https://www.dna.fi/fonts/DNAText-Bold.woff') format('woff');
27
+ }
28
+
29
+ /* "DNA Heading" font definition */
30
+ @font-face {
31
+ font-family: 'DNA Heading';
32
+ font-style: normal;
33
+ font-weight: 600;
34
+ font-display: swap;
35
+ src: url('https://www.dna.fi/fonts/DNAHeading-DemiBold.woff2') format('woff2'),
36
+ url('https://www.dna.fi/fonts/DNAHeading-DemiBold.woff') format('woff');
37
+ }
38
+
39
+ @font-face {
40
+ font-family: 'DNA Heading';
41
+ font-style: normal;
42
+ font-weight: 700;
43
+ font-display: swap;
44
+ src: url('https://www.dna.fi/fonts/DNAHeading-Bold.woff2') format('woff2'),
45
+ url('https://www.dna.fi/fonts/DNAHeading-Bold.woff') format('woff');
46
+ }
47
+
48
+ @font-face {
49
+ font-family: 'DNA Heading';
50
+ font-style: normal;
51
+ font-weight: 900;
52
+ font-display: swap;
53
+ src: url('https://www.dna.fi/fonts/DNAHeading-Black.woff2') format('woff2'),
54
+ url('https://www.dna.fi/fonts/DNAHeading-Black.woff') format('woff');
55
+ }
56
+
57
+ /* "DNA Numerals" font definition */
58
+ @font-face {
59
+ font-family: 'DNA Numerals';
60
+ font-style: normal;
61
+ font-weight: 700;
62
+ font-display: swap;
63
+ src: url('https://www.dna.fi/fonts/DNANumerals-Bold.woff2') format('woff2'),
64
+ url('https://www.dna.fi/fonts/DNANumerals-Bold.woff') format('woff');
65
+ }
66
+
67
+ /* Direct definitons of DNA fonts */
68
+ @font-face {
69
+ font-family: 'DNA Text Regular';
70
+ font-style: normal;
71
+ font-weight: 400;
72
+ font-display: swap;
73
+ src: url('https://www.dna.fi/fonts/DNAText-Regular.woff2') format('woff2'),
74
+ url('https://www.dna.fi/fonts/DNAText-Regular.woff') format('woff');
75
+ }
76
+
77
+ @font-face {
78
+ font-family: 'DNA Text Medium';
79
+ font-style: normal;
80
+ font-weight: 500;
81
+ font-display: swap;
82
+ src: url('https://www.dna.fi/fonts/DNAText-Medium.woff2') format('woff2'),
83
+ url('https://www.dna.fi/fonts/DNAText-Medium.woff') format('woff');
84
+ }
85
+
86
+ @font-face {
87
+ font-family: 'DNA Text Bold';
88
+ font-style: normal;
89
+ font-weight: 700;
90
+ font-display: swap;
91
+ src: url('https://www.dna.fi/fonts/DNAText-Bold.woff2') format('woff2'),
92
+ url('https://www.dna.fi/fonts/DNAText-Bold.woff') format('woff');
93
+ }
94
+
95
+ @font-face {
96
+ font-family: 'DNA Heading Demi Bold';
97
+ font-style: normal;
98
+ font-weight: 600;
99
+ font-display: swap;
100
+ src: url('https://www.dna.fi/fonts/DNAHeading-DemiBold.woff2') format('woff2'),
101
+ url('https://www.dna.fi/fonts/DNAHeading-DemiBold.woff') format('woff');
102
+ }
103
+
104
+ @font-face {
105
+ font-family: 'DNA Heading Bold';
106
+ font-style: normal;
107
+ font-weight: 700;
108
+ font-display: swap;
109
+ src: url('https://www.dna.fi/fonts/DNAHeading-Bold.woff2') format('woff2'),
110
+ url('https://www.dna.fi/fonts/DNAHeading-Bold.woff') format('woff');
111
+ }
112
+
113
+ @font-face {
114
+ font-family: 'DNA Heading Black';
115
+ font-style: normal;
116
+ font-weight: 900;
117
+ font-display: swap;
118
+ src: url('https://www.dna.fi/fonts/DNAHeading-Black.woff2') format('woff2'),
119
+ url('https://www.dna.fi/fonts/DNAHeading-Black.woff') format('woff');
120
+ }
121
+
122
+ @font-face {
123
+ font-family: 'DNA Numerals Bold';
124
+ font-style: normal;
125
+ font-weight: 700;
126
+ font-display: swap;
127
+ src: url('https://www.dna.fi/fonts/DNANumerals-Bold.woff2') format('woff2'),
128
+ url('https://www.dna.fi/fonts/DNANumerals-Bold.woff') format('woff');
129
+ }
@@ -20,6 +20,10 @@ const ButtonElement = styled__default.button `
20
20
  border: 2px solid transparent;
21
21
  padding: ${getDividedSize(theme.base.baseWidth, 5)} 0;
22
22
 
23
+ & svg {
24
+ pointer-events: none;
25
+ }
26
+
23
27
  ${({ isReversed }) => isReversed && `flex-direction: row-reverse;`}
24
28
 
25
29
  &:focus {
@@ -41,6 +41,14 @@ interface Props {
41
41
  * On input change callback
42
42
  */
43
43
  onInputChange?: (e: ChangeEvent<HTMLInputElement>) => void;
44
+ /**
45
+ * Minimum selectable date
46
+ */
47
+ minDate?: ReactDatePickerProps['minDate'];
48
+ /**
49
+ * Maximum selectable date
50
+ */
51
+ maxDate?: ReactDatePickerProps['maxDate'];
44
52
  /**
45
53
  * Allows to define time intervals in time picker
46
54
  *
@@ -69,6 +77,10 @@ interface Props {
69
77
  * @default false
70
78
  */
71
79
  isEditable?: boolean;
80
+ /**
81
+ * Allows to clear the selected date
82
+ */
83
+ isClearable?: boolean;
72
84
  /**
73
85
  * Allows to disable the component functionality
74
86
  *
@@ -47,6 +47,7 @@ const localeData = {
47
47
  'en-GB': undefined,
48
48
  };
49
49
  const sentenceCase = (string) => `${string[0].toUpperCase()}${string.slice(1)}`;
50
+ // TODO: change `& .react-datepicker` value back to `1` after z-index of Footer removed
50
51
  const Wrapper = styled__default.div `
51
52
  position: relative;
52
53
 
@@ -57,7 +58,7 @@ const Wrapper = styled__default.div `
57
58
  border-radius: ${theme.radius.default};
58
59
  border: 1px solid ${theme.color.line.L03};
59
60
  background-color: ${theme.color.background.white.default};
60
- z-index: 1;
61
+ z-index: 2;
61
62
 
62
63
  .react-datepicker__aria-live {
63
64
  display: none;
@@ -125,7 +126,17 @@ const Wrapper = styled__default.div `
125
126
  color: ${theme.color.text.pink};
126
127
  font-weight: ${theme.fontWeight.bold};
127
128
  }
128
-
129
+ &.react-datepicker__day--disabled {
130
+ color: ${theme.color.text.gray + theme.color.transparency.T40};
131
+ font-weight: ${theme.fontWeight.book};
132
+ &:hover {
133
+ cursor: default;
134
+ color: ${theme.color.text.gray + theme.color.transparency.T40};
135
+ font-weight: ${theme.fontWeight.book};
136
+ background-color: transparent;
137
+ border: 1px solid transparent;
138
+ }
139
+ }
129
140
  &.react-datepicker__day--in-selecting-range {
130
141
  color: ${theme.color.text.white};
131
142
  font-weight: ${theme.fontWeight.bold};
@@ -261,8 +272,8 @@ const DateTimePicker = (_a) => {
261
272
  .join(' - ');
262
273
  const getDateTimePickerCustomHeader = (args) => DateTimePickerCustomHeader(Object.assign(Object.assign({}, args), { locale }));
263
274
  return (React__default.createElement(Wrapper, { id: props.id, className: props.className, "data-testid": dataTestId },
264
- React__default.createElement(Input, { id: `datetimepicker-input-${props.id}`, name: `datetimepicker-input-${props.id}`, label: props.label, placeholder: props.placeholder, value: formatInputValue, onFocus: handleOnInputFocus, onChange: handleOnInputChange, onKeyDown: handleOnKeyDown, onClearableButtonClick: handleClearable, className: "react-datepicker-ignore-onclickoutside", "data-testid": dataTestId && `${dataTestId}-datetimepicker-input`, disabled: props.isDisabled, required: props.isRequired, readonly: !props.isEditable, status: props.isInError ? 'error' : undefined, errorMessage: props.errorMessage }),
265
- showReactDatePicker && (React__default.createElement(ReactDatePicker, { inline: true, selected: startDate, startDate: startDate, endDate: props.endDate, onChange: handleOnReactDatePickerChange, selectsRange: props.endDate !== undefined, showTimeSelect: props.endDate === undefined && isTimePicker, showTimeSelectOnly: props.endDate === undefined && !isDatePicker && isTimePicker, timeCaption: (_b = localeData[locale]) === null || _b === void 0 ? void 0 : _b.localize.timeCaption, timeIntervals: timeInterval, onClickOutside: handleOnReactDatePickerClickOutside, locale: localeData[locale],
275
+ React__default.createElement(Input, { id: `datetimepicker-input-${props.id}`, name: `datetimepicker-input-${props.id}`, label: props.label, placeholder: props.placeholder, value: formatInputValue, onFocus: handleOnInputFocus, onChange: handleOnInputChange, onKeyDown: handleOnKeyDown, onClearableButtonClick: props.isClearable ? handleClearable : undefined, className: "react-datepicker-ignore-onclickoutside", "data-testid": dataTestId && `${dataTestId}-datetimepicker-input`, disabled: props.isDisabled, required: props.isRequired, readonly: !props.isEditable, status: props.isInError ? 'error' : undefined, errorMessage: props.errorMessage }),
276
+ showReactDatePicker && (React__default.createElement(ReactDatePicker, { inline: true, selected: startDate, startDate: startDate, maxDate: props.maxDate, minDate: props.minDate, endDate: props.endDate, onChange: handleOnReactDatePickerChange, selectsRange: props.endDate !== undefined, showTimeSelect: props.endDate === undefined && isTimePicker, showTimeSelectOnly: props.endDate === undefined && !isDatePicker && isTimePicker, timeCaption: (_b = localeData[locale]) === null || _b === void 0 ? void 0 : _b.localize.timeCaption, timeIntervals: timeInterval, onClickOutside: handleOnReactDatePickerClickOutside, locale: localeData[locale],
266
277
  // Used to format the date/time in internal ReactDatePicker input
267
278
  // Currently ignored as date/time is shown in Styleguide Input instead, and formatted by using Intl.DateTimeFormat
268
279
  dateFormat: [isDatePicker && 'P', isTimePicker && 'p'].filter(Boolean).join(''), renderCustomHeader: getDateTimePickerCustomHeader }))));
@@ -42,6 +42,7 @@ interface Props {
42
42
  */
43
43
  'data-testid'?: string;
44
44
  }
45
+ /** @visibleName Notification */
45
46
  declare const Notification: ({ type, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element | null;
46
47
  /** @component */
47
48
  export default Notification;
@@ -3,7 +3,6 @@ import { Close, Info, Check, Warning, Error } from '@dnanpm/icons';
3
3
  import React__default from 'react';
4
4
  import styled__default from 'styled-components';
5
5
  import theme from '../../themes/theme.js';
6
- import { getMultipliedSize } from '../../utils/styledUtils.js';
7
6
  import ButtonClose from '../Button/ButtonClose.js';
8
7
  import Icon from '../Icon/Icon.js';
9
8
 
@@ -15,26 +14,34 @@ const iconsMap = {
15
14
  };
16
15
  const NotificationWrapper = styled__default.div `
17
16
  display: flex;
18
- align-items: center;
19
- padding: ${getMultipliedSize(theme.base.baseHeight, 1)}
20
- ${getMultipliedSize(theme.base.baseHeight, 2)};
17
+ gap: 1rem;
21
18
  line-height: ${theme.lineHeight.default};
22
19
  color: ${theme.color.text.black};
23
20
  background-color: ${theme.color.background.white.default};
24
21
  border-radius: ${theme.radius.s};
25
22
  border: 2px solid ${({ $type }) => theme.color.notification[$type]};
26
23
  `;
24
+ const IconWrapper = styled__default.div `
25
+ display: flex;
26
+ align-items: center;
27
+ padding: 0.5rem;
28
+ background-color: ${({ $type }) => theme.color.notification[$type]};
29
+ `;
27
30
  const ContentWrapper = styled__default.span `
28
- margin: 0 ${getMultipliedSize(theme.base.baseHeight, 1.5)};
31
+ margin: auto 0;
32
+ padding: 0.5rem 0;
33
+ width: 100%;
29
34
  `;
30
35
  const ButtonCloseStyled = styled__default(ButtonClose) `
31
36
  position: static;
32
- margin: 0 0 0 auto;
37
+ margin: auto 0.5rem;
33
38
  `;
39
+ /** @visibleName Notification */
34
40
  const Notification = (_a) => {
35
41
  var { type = 'info', 'data-testid': dataTestId } = _a, props = __rest(_a, ["type", 'data-testid']);
36
42
  return !props.dismissed ? (React__default.createElement(NotificationWrapper, { "$type": type, className: props.className, "data-testid": dataTestId },
37
- React__default.createElement(Icon, { icon: iconsMap[type], size: "2rem", color: theme.color.notification[type] }),
43
+ React__default.createElement(IconWrapper, { "$type": type },
44
+ React__default.createElement(Icon, { icon: iconsMap[type], size: "2rem", color: theme.color.default.white })),
38
45
  React__default.createElement(ContentWrapper, null, props.children),
39
46
  props.closeButton && (React__default.createElement(ButtonCloseStyled, { onClick: props.onClickCloseButton },
40
47
  React__default.createElement(Icon, { icon: Close, color: "currentColor" }))))) : null;
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import type { KeyboardEvent, MouseEvent, ReactNode } from 'react';
2
2
  import React from 'react';
3
3
  interface Props {
4
4
  /**
@@ -9,6 +9,14 @@ interface Props {
9
9
  * Content of the component
10
10
  */
11
11
  children?: ReactNode;
12
+ /**
13
+ * Allows to pass common mouse click callback to all children
14
+ */
15
+ onClick?: (e: MouseEvent<HTMLElement>) => void;
16
+ /**
17
+ * Allows to pass common keyboard key down callback to all children
18
+ */
19
+ onKeyDown?: (e: KeyboardEvent<HTMLElement>) => void;
12
20
  /**
13
21
  * Allows to define aria-label attribute for nav HTML element
14
22
  */
@@ -1,6 +1,6 @@
1
1
  import { __rest } from 'tslib';
2
- import { Check, ChevronUp, ChevronDown } from '@dnanpm/icons';
3
- import React__default, { useRef, useState, useReducer, isValidElement, useEffect, Children } from 'react';
2
+ import { ChevronUp, ChevronDown, Check } from '@dnanpm/icons';
3
+ import React__default, { useRef, useState, Children, useReducer, isValidElement, useEffect } from 'react';
4
4
  import useDebounce from '../../hooks/useDebounce.js';
5
5
  import useOutsideClick from '../../hooks/useOutsideClick.js';
6
6
  import useResizeObserver from '../../hooks/useResizeObserver.js';
@@ -95,11 +95,15 @@ const DropdownList = styled(CoreULStyles) `
95
95
  ${getElevationShadow({ elevation: 'low' })}
96
96
  `;
97
97
  const reducer = (state, action) => {
98
- var _a;
98
+ var _a, _b;
99
99
  switch (action.type) {
100
+ case 'resetNavigationState': {
101
+ const navigationItems = Children.toArray((_a = action === null || action === void 0 ? void 0 : action.payload) === null || _a === void 0 ? void 0 : _a.navigationItems);
102
+ return Object.assign(Object.assign({}, state), { navigationItems: navigationItems.slice(0, navigationItems.length - state.lastItemWidth.length), dropdownItems: navigationItems.slice(navigationItems.length - state.lastItemWidth.length) });
103
+ }
100
104
  case 'moveItemToDropdown': {
101
105
  const lastChild = state.navigationItems[state.navigationItems.length - 1];
102
- return Object.assign(Object.assign(Object.assign({}, state), { navigationItems: state.navigationItems.slice(0, -1), dropdownItems: [lastChild, ...state.dropdownItems] }), (((_a = action === null || action === void 0 ? void 0 : action.payload) === null || _a === void 0 ? void 0 : _a.lastItem) && {
106
+ return Object.assign(Object.assign(Object.assign({}, state), { navigationItems: state.navigationItems.slice(0, -1), dropdownItems: [lastChild, ...state.dropdownItems] }), (((_b = action === null || action === void 0 ? void 0 : action.payload) === null || _b === void 0 ? void 0 : _b.lastItem) && {
103
107
  lastItemWidth: [...state.lastItemWidth, action.payload.lastItem.clientWidth],
104
108
  }));
105
109
  }
@@ -156,7 +160,7 @@ const PriorityNavigation = (_a) => {
156
160
  const toggleDropdown = () => setIsDropdownOpen(!isDropdownOpen);
157
161
  const navigationItems = useRef(new Map()).current;
158
162
  const initialState = {
159
- navigationItems: props.children,
163
+ navigationItems: Children.toArray(props.children),
160
164
  dropdownItems: [],
161
165
  lastItemWidth: [],
162
166
  };
@@ -189,6 +193,9 @@ const PriorityNavigation = (_a) => {
189
193
  child.type === PriorityNavigationItem &&
190
194
  child.props.isActive));
191
195
  useOutsideClick(listsContainerRef, () => {
196
+ if (isMobileNavigationOpen) {
197
+ setIsMobileNavigationOpen(false);
198
+ }
192
199
  if (isDropdownOpen) {
193
200
  setIsDropdownOpen(false);
194
201
  }
@@ -204,16 +211,24 @@ const PriorityNavigation = (_a) => {
204
211
  checkHorizontalOverflow,
205
212
  isMobile,
206
213
  ]);
207
- const navigationListItems = Children.map([...state.navigationItems, ...(isMobile ? state.dropdownItems : [])], (navigationItem, index) => isValidElement(navigationItem) &&
208
- navigationItem.type === PriorityNavigationItem && (React__default.createElement(PriorityNavigationItem, { id: navigationItem.props.id, key: navigationItem.key, isActive: navigationItem.props.isActive, className: navigationItem.props.className, "data-testid": navigationItem.props['data-testid'], innerRef: instance => instance && navigationItems.set(index, instance) },
209
- navigationItem.props.children,
210
- navigationItem.props.isActive && isMobile && (React__default.createElement(Icon, { icon: Check, color: theme.color.default.pink })))));
214
+ useEffect(() => {
215
+ dispatch({
216
+ type: 'resetNavigationState',
217
+ payload: {
218
+ navigationItems: props.children,
219
+ },
220
+ });
221
+ setIsMobileNavigationOpen(false);
222
+ }, [props.children]);
211
223
  return (React__default.createElement(Container, { id: props.id, "aria-label": props.navigationLabel, className: props.className, "data-testid": dataTestId },
212
224
  React__default.createElement(ListsContainer, { ref: listsContainerRef },
213
225
  isMobile && selectedItem && (React__default.createElement(MobileDropdown, { onClick: toggleMobileNavigation },
214
226
  selectedItem,
215
227
  React__default.createElement(Icon, { icon: isMobileNavigationOpen ? ChevronUp : ChevronDown }))),
216
- React__default.createElement(NavigationList, { ref: navigationListRef, isMobileNavigationOpen: isMobileNavigationOpen }, navigationListItems),
228
+ React__default.createElement(NavigationList, { ref: navigationListRef, isMobileNavigationOpen: isMobileNavigationOpen }, Children.map([...state.navigationItems, ...(isMobile ? state.dropdownItems : [])], (navigationItem, index) => isValidElement(navigationItem) &&
229
+ navigationItem.type === PriorityNavigationItem && (React__default.createElement(PriorityNavigationItem, { id: navigationItem.props.id, key: navigationItem.key, onClick: navigationItem.props.onClick || props.onClick, onKeyDown: navigationItem.props.onKeyDown || props.onKeyDown, isActive: navigationItem.props.isActive, className: navigationItem.props.className, "data-testid": navigationItem.props['data-testid'], innerRef: instance => instance && navigationItems.set(index, instance) },
230
+ navigationItem.props.children,
231
+ navigationItem.props.isActive && isMobile && (React__default.createElement(Icon, { icon: Check, color: theme.color.default.pink })))))),
217
232
  !isMobile && Boolean(state.dropdownItems.length) && (React__default.createElement(React__default.Fragment, null,
218
233
  React__default.createElement(ButtonIcon, { onClick: toggleDropdown, icon: isDropdownOpen ? ChevronUp : ChevronDown, isReversed: true }, dropdownButtonLabel),
219
234
  React__default.createElement(DropdownList, { isDropdownOpen: isDropdownOpen }, state.dropdownItems))))));
@@ -1,4 +1,4 @@
1
- import type { ReactNode, RefObject } from 'react';
1
+ import type { KeyboardEvent, MouseEvent, ReactNode, RefObject } from 'react';
2
2
  import React from 'react';
3
3
  export interface Props {
4
4
  /**
@@ -10,13 +10,21 @@ export interface Props {
10
10
  */
11
11
  children?: ReactNode;
12
12
  /**
13
- * A ref object, or a ref callback function
13
+ * On component mouse click callback
14
14
  */
15
- innerRef?: RefObject<HTMLLIElement> | ((instance: HTMLLIElement | null) => void) | null;
15
+ onClick?: (e: MouseEvent<HTMLElement>) => void;
16
+ /**
17
+ * On component keyboard key down callback
18
+ */
19
+ onKeyDown?: (e: KeyboardEvent<HTMLElement>) => void;
16
20
  /**
17
21
  * Allows to set component as active
18
22
  */
19
23
  isActive?: boolean;
24
+ /**
25
+ * A ref object, or a ref callback function
26
+ */
27
+ innerRef?: RefObject<HTMLLIElement> | ((instance: HTMLLIElement | null) => void) | null;
20
28
  /**
21
29
  * Allows to pass a custom className
22
30
  */
@@ -13,6 +13,20 @@ const Element = styled.li `
13
13
  padding: 1rem 1.25rem;
14
14
  flex-shrink: 0;
15
15
 
16
+ ${({ onClick }) => onClick &&
17
+ `
18
+ cursor: pointer;
19
+ `};
20
+
21
+ &:focus-within {
22
+ & > * {
23
+ border-radius: ${theme.radius.s};
24
+ border: 2px solid ${theme.color.focus.light};
25
+ box-shadow: 0px 0px 0px 2px ${theme.color.focus.dark};
26
+ outline: none;
27
+ }
28
+ }
29
+
16
30
  ${({ isActive }) => media.md `
17
31
  justify-content: center;
18
32
  padding: 1rem 0;
@@ -21,26 +35,20 @@ const Element = styled.li `
21
35
  border-bottom: 3px solid ${isActive ? theme.color.text.pink : 'transparent'};
22
36
  `}
23
37
 
24
- & a {
38
+ & > * {
25
39
  display: block;
26
40
  color: ${({ isActive }) => (isActive ? theme.color.text.pink : theme.color.text.black)};
27
41
  ${({ isActive }) => isActive && `font-weight: ${theme.fontWeight.bold}`};
28
42
  border: 2px solid transparent;
29
43
 
30
- &:focus {
31
- border-radius: ${theme.radius.s};
32
- border: 2px solid ${theme.color.focus.light};
33
- box-shadow: 0px 0px 0px 2px ${theme.color.focus.dark};
34
- outline: none;
44
+ &:hover {
45
+ color: ${theme.color.hover.pink};
46
+ text-decoration: none;
35
47
  }
36
48
 
37
49
  ${media.md `
38
50
  margin: auto;
39
51
  `}
40
-
41
- &:hover {
42
- color: ${theme.color.hover.pink};
43
- }
44
52
  }
45
53
  `;
46
54
  /**
@@ -48,7 +56,7 @@ const Element = styled.li `
48
56
  */
49
57
  const PriorityNavigationItem = (_a) => {
50
58
  var { 'data-testid': dataTestId } = _a, props = __rest(_a, ['data-testid']);
51
- return (React__default.createElement(Element, { id: props.id, ref: props.innerRef, isActive: props.isActive, className: props.className, "data-testid": dataTestId }, props.children));
59
+ return (React__default.createElement(Element, { id: props.id, ref: props.innerRef, onClick: props.onClick, onKeyDown: props.onKeyDown, isActive: props.isActive, className: props.className, "data-testid": dataTestId }, props.children));
52
60
  };
53
61
 
54
62
  export { PriorityNavigationItem as default };
@@ -1,5 +1,6 @@
1
1
  import type { ChangeEvent, FocusEvent, KeyboardEvent } from 'react';
2
2
  import React from 'react';
3
+ type InputStatus = 'none' | 'success' | 'error' | 'comment';
3
4
  interface Props {
4
5
  /**
5
6
  * Unique ID for the input element
@@ -67,6 +68,19 @@ interface Props {
67
68
  * @default 3
68
69
  */
69
70
  height?: number;
71
+ /**
72
+ * Depending on the passed status, the styling changes and additional elements are shown
73
+ *
74
+ * @param {InputStatus} none Default styling
75
+ * @param {InputStatus} success Displays `success` icon with `theme.color.notification.success` color in the input element
76
+ * @param {InputStatus} error Displays `error` icon with `theme.color.notification.error` color in the input element and error message underneath the input
77
+ * @param {InputStatus} comment Displays comment message underneath the input
78
+ */
79
+ status?: InputStatus;
80
+ /**
81
+ * Text of the error message when textarea is in error state
82
+ */
83
+ errorMessage?: string;
70
84
  /**
71
85
  * Allows to pass a custom className
72
86
  */
@@ -49,6 +49,10 @@ const Message = styled.div `
49
49
  color: ${theme.color.text.gray};
50
50
  margin-top: ${getMultipliedSize(theme.base.baseHeight, 0.5)};
51
51
  `;
52
+ const ErrorMessage = styled(Message) `
53
+ font-weight: ${theme.fontWeight.medium};
54
+ color: ${theme.color.notification.error};
55
+ `;
52
56
  const Textarea = (_a) => {
53
57
  var { height = 3, 'data-testid': dataTestId } = _a, props = __rest(_a, ["height", 'data-testid']);
54
58
  const inputRef = useRef(null);
@@ -69,9 +73,10 @@ const Textarea = (_a) => {
69
73
  }
70
74
  };
71
75
  return (React__default.createElement(FieldContainer, { className: props.className },
72
- props.label && (React__default.createElement(LabelText, { htmlFor: props.id, "data-testid": dataTestId && `${dataTestId}-label`, isMandatory: props.required }, props.label)),
76
+ props.label && (React__default.createElement(LabelText, { htmlFor: props.id, "data-testid": dataTestId && `${dataTestId}-label`, status: props.status === 'error' ? props.status : undefined, isMandatory: props.required }, props.label)),
73
77
  React__default.createElement(StyledTextarea, { id: props.id, name: props.name, ref: inputRef, value: props.value, rows: height, placeholder: props.placeholder, tabIndex: props.tabIndex, onChange: handleChange, onBlur: handleOnBlur, onFocus: props.onFocus, onClick: onClick, onKeyDown: props.onKeyDown, onKeyPress: props.onKeyPress, required: props.required, disabled: props.disabled, "aria-disabled": props.disabled, "aria-label": props.id, "data-testid": dataTestId }),
74
- props.commentMessage && (React__default.createElement(Message, { "data-testid": dataTestId && `${dataTestId}-comment` }, props.commentMessage))));
78
+ props.commentMessage && (React__default.createElement(Message, { "data-testid": dataTestId && `${dataTestId}-comment` }, props.commentMessage)),
79
+ props.status === 'error' && props.errorMessage && (React__default.createElement(ErrorMessage, { "data-testid": dataTestId && `${dataTestId}-error` }, props.errorMessage))));
75
80
  };
76
81
 
77
82
  export { Textarea as default };