@dnanpm/styleguide 3.4.0 → 3.5.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/DateTimePicker/DateTimePicker.d.ts +12 -0
- package/build/cjs/components/DateTimePicker/DateTimePicker.js +15 -4
- package/build/cjs/components/Notification/Notification.d.ts +1 -0
- package/build/cjs/components/Notification/Notification.js +14 -7
- package/build/cjs/components/Textarea/Textarea.d.ts +14 -0
- package/build/cjs/components/Textarea/Textarea.js +7 -2
- package/build/es/components/DateTimePicker/DateTimePicker.d.ts +12 -0
- package/build/es/components/DateTimePicker/DateTimePicker.js +15 -4
- package/build/es/components/Notification/Notification.d.ts +1 -0
- package/build/es/components/Notification/Notification.js +14 -7
- package/build/es/components/Textarea/Textarea.d.ts +14 -0
- package/build/es/components/Textarea/Textarea.js +7 -2
- package/package.json +1 -1
|
@@ -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
|
*
|
|
@@ -57,6 +57,7 @@ const localeData = {
|
|
|
57
57
|
'en-GB': undefined,
|
|
58
58
|
};
|
|
59
59
|
const sentenceCase = (string) => `${string[0].toUpperCase()}${string.slice(1)}`;
|
|
60
|
+
// TODO: change `& .react-datepicker` value back to `1` after z-index of Footer removed
|
|
60
61
|
const Wrapper = styled__default["default"].div `
|
|
61
62
|
position: relative;
|
|
62
63
|
|
|
@@ -67,7 +68,7 @@ const Wrapper = styled__default["default"].div `
|
|
|
67
68
|
border-radius: ${theme["default"].radius.default};
|
|
68
69
|
border: 1px solid ${theme["default"].color.line.L03};
|
|
69
70
|
background-color: ${theme["default"].color.background.white.default};
|
|
70
|
-
z-index:
|
|
71
|
+
z-index: 2;
|
|
71
72
|
|
|
72
73
|
.react-datepicker__aria-live {
|
|
73
74
|
display: none;
|
|
@@ -135,7 +136,17 @@ const Wrapper = styled__default["default"].div `
|
|
|
135
136
|
color: ${theme["default"].color.text.pink};
|
|
136
137
|
font-weight: ${theme["default"].fontWeight.bold};
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
+
&.react-datepicker__day--disabled {
|
|
140
|
+
color: ${theme["default"].color.text.gray + theme["default"].color.transparency.T40};
|
|
141
|
+
font-weight: ${theme["default"].fontWeight.book};
|
|
142
|
+
&:hover {
|
|
143
|
+
cursor: default;
|
|
144
|
+
color: ${theme["default"].color.text.gray + theme["default"].color.transparency.T40};
|
|
145
|
+
font-weight: ${theme["default"].fontWeight.book};
|
|
146
|
+
background-color: transparent;
|
|
147
|
+
border: 1px solid transparent;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
139
150
|
&.react-datepicker__day--in-selecting-range {
|
|
140
151
|
color: ${theme["default"].color.text.white};
|
|
141
152
|
font-weight: ${theme["default"].fontWeight.bold};
|
|
@@ -271,8 +282,8 @@ const DateTimePicker = (_a) => {
|
|
|
271
282
|
.join(' - ');
|
|
272
283
|
const getDateTimePickerCustomHeader = (args) => DateTimePickerCustomHeader(Object.assign(Object.assign({}, args), { locale }));
|
|
273
284
|
return (React__default["default"].createElement(Wrapper, { id: props.id, className: props.className, "data-testid": dataTestId },
|
|
274
|
-
React__default["default"].createElement(Input["default"], { 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 }),
|
|
275
|
-
showReactDatePicker && (React__default["default"].createElement(ReactDatePicker__default["default"], { 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],
|
|
285
|
+
React__default["default"].createElement(Input["default"], { 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 }),
|
|
286
|
+
showReactDatePicker && (React__default["default"].createElement(ReactDatePicker__default["default"], { 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],
|
|
276
287
|
// Used to format the date/time in internal ReactDatePicker input
|
|
277
288
|
// Currently ignored as date/time is shown in Styleguide Input instead, and formatted by using Intl.DateTimeFormat
|
|
278
289
|
dateFormat: [isDatePicker && 'P', isTimePicker && 'p'].filter(Boolean).join(''), renderCustomHeader: getDateTimePickerCustomHeader }))));
|
|
@@ -7,7 +7,6 @@ var icons = require('@dnanpm/icons');
|
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var styled = require('styled-components');
|
|
9
9
|
var theme = require('../../themes/theme.js');
|
|
10
|
-
var styledUtils = require('../../utils/styledUtils.js');
|
|
11
10
|
var ButtonClose = require('../Button/ButtonClose.js');
|
|
12
11
|
var Icon = require('../Icon/Icon.js');
|
|
13
12
|
|
|
@@ -24,26 +23,34 @@ const iconsMap = {
|
|
|
24
23
|
};
|
|
25
24
|
const NotificationWrapper = styled__default["default"].div `
|
|
26
25
|
display: flex;
|
|
27
|
-
|
|
28
|
-
padding: ${styledUtils.getMultipliedSize(theme["default"].base.baseHeight, 1)}
|
|
29
|
-
${styledUtils.getMultipliedSize(theme["default"].base.baseHeight, 2)};
|
|
26
|
+
gap: 1rem;
|
|
30
27
|
line-height: ${theme["default"].lineHeight.default};
|
|
31
28
|
color: ${theme["default"].color.text.black};
|
|
32
29
|
background-color: ${theme["default"].color.background.white.default};
|
|
33
30
|
border-radius: ${theme["default"].radius.s};
|
|
34
31
|
border: 2px solid ${({ $type }) => theme["default"].color.notification[$type]};
|
|
35
32
|
`;
|
|
33
|
+
const IconWrapper = styled__default["default"].div `
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
padding: 0.5rem;
|
|
37
|
+
background-color: ${({ $type }) => theme["default"].color.notification[$type]};
|
|
38
|
+
`;
|
|
36
39
|
const ContentWrapper = styled__default["default"].span `
|
|
37
|
-
margin: 0
|
|
40
|
+
margin: auto 0;
|
|
41
|
+
padding: 0.5rem 0;
|
|
42
|
+
width: 100%;
|
|
38
43
|
`;
|
|
39
44
|
const ButtonCloseStyled = styled__default["default"](ButtonClose["default"]) `
|
|
40
45
|
position: static;
|
|
41
|
-
margin:
|
|
46
|
+
margin: auto 0.5rem;
|
|
42
47
|
`;
|
|
48
|
+
/** @visibleName Notification */
|
|
43
49
|
const Notification = (_a) => {
|
|
44
50
|
var { type = 'info', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["type", 'data-testid']);
|
|
45
51
|
return !props.dismissed ? (React__default["default"].createElement(NotificationWrapper, { "$type": type, className: props.className, "data-testid": dataTestId },
|
|
46
|
-
React__default["default"].createElement(
|
|
52
|
+
React__default["default"].createElement(IconWrapper, { "$type": type },
|
|
53
|
+
React__default["default"].createElement(Icon["default"], { icon: iconsMap[type], size: "2rem", color: theme["default"].color.default.white })),
|
|
47
54
|
React__default["default"].createElement(ContentWrapper, null, props.children),
|
|
48
55
|
props.closeButton && (React__default["default"].createElement(ButtonCloseStyled, { onClick: props.onClickCloseButton },
|
|
49
56
|
React__default["default"].createElement(Icon["default"], { icon: icons.Close, color: "currentColor" }))))) : null;
|
|
@@ -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
|
*/
|
|
@@ -57,6 +57,10 @@ const Message = styled["default"].div `
|
|
|
57
57
|
color: ${theme["default"].color.text.gray};
|
|
58
58
|
margin-top: ${styledUtils.getMultipliedSize(theme["default"].base.baseHeight, 0.5)};
|
|
59
59
|
`;
|
|
60
|
+
const ErrorMessage = styled["default"](Message) `
|
|
61
|
+
font-weight: ${theme["default"].fontWeight.medium};
|
|
62
|
+
color: ${theme["default"].color.notification.error};
|
|
63
|
+
`;
|
|
60
64
|
const Textarea = (_a) => {
|
|
61
65
|
var { height = 3, 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["height", 'data-testid']);
|
|
62
66
|
const inputRef = React.useRef(null);
|
|
@@ -77,9 +81,10 @@ const Textarea = (_a) => {
|
|
|
77
81
|
}
|
|
78
82
|
};
|
|
79
83
|
return (React__default["default"].createElement(FieldContainer, { className: props.className },
|
|
80
|
-
props.label && (React__default["default"].createElement(LabelText["default"], { htmlFor: props.id, "data-testid": dataTestId && `${dataTestId}-label`, isMandatory: props.required }, props.label)),
|
|
84
|
+
props.label && (React__default["default"].createElement(LabelText["default"], { htmlFor: props.id, "data-testid": dataTestId && `${dataTestId}-label`, status: props.status === 'error' ? props.status : undefined, isMandatory: props.required }, props.label)),
|
|
81
85
|
React__default["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 }),
|
|
82
|
-
props.commentMessage && (React__default["default"].createElement(Message, { "data-testid": dataTestId && `${dataTestId}-comment` }, props.commentMessage))
|
|
86
|
+
props.commentMessage && (React__default["default"].createElement(Message, { "data-testid": dataTestId && `${dataTestId}-comment` }, props.commentMessage)),
|
|
87
|
+
props.status === 'error' && props.errorMessage && (React__default["default"].createElement(ErrorMessage, { "data-testid": dataTestId && `${dataTestId}-error` }, props.errorMessage))));
|
|
83
88
|
};
|
|
84
89
|
|
|
85
90
|
exports["default"] = Textarea;
|
|
@@ -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:
|
|
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 }))));
|
|
@@ -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
|
-
|
|
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
|
|
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:
|
|
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(
|
|
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,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 };
|