@dnanpm/styleguide 3.9.8 → 3.9.10
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/Carousel/Carousel.d.ts +188 -0
- package/build/cjs/components/Carousel/Carousel.js +23 -10
- package/build/cjs/components/Divider/Divider.d.ts +4 -0
- package/build/cjs/components/Divider/Divider.js +2 -1
- package/build/cjs/components/InfoDialog/InfoDialog.d.ts +4 -0
- package/build/cjs/components/InfoDialog/InfoDialog.js +1 -1
- package/build/cjs/components/Input/Input.js +1 -2
- package/build/cjs/components/LabelText/LabelText.d.ts +5 -3
- package/build/cjs/components/LabelText/LabelText.js +1 -1
- package/build/cjs/components/Notification/Notification.d.ts +18 -4
- package/build/cjs/components/Notification/Notification.js +25 -10
- package/build/cjs/components/Pill/Pill.d.ts +4 -0
- package/build/cjs/components/Pill/Pill.js +52 -16
- package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +1 -1
- package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.js +7 -8
- package/build/cjs/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
- package/build/cjs/components/ProgressIndicator/ProgressIndicator.js +13 -6
- package/build/cjs/components/ReadMore/ReadMore.d.ts +4 -0
- package/build/cjs/components/ReadMore/ReadMore.js +30 -3
- package/build/cjs/components/Tooltip/Tooltip.d.ts +5 -1
- package/build/cjs/components/Tooltip/Tooltip.js +46 -6
- package/build/es/components/Carousel/Carousel.d.ts +188 -0
- package/build/es/components/Carousel/Carousel.js +23 -11
- package/build/es/components/Divider/Divider.d.ts +4 -0
- package/build/es/components/Divider/Divider.js +2 -1
- package/build/es/components/InfoDialog/InfoDialog.d.ts +4 -0
- package/build/es/components/InfoDialog/InfoDialog.js +1 -1
- package/build/es/components/Input/Input.js +1 -2
- package/build/es/components/LabelText/LabelText.d.ts +5 -3
- package/build/es/components/LabelText/LabelText.js +1 -1
- package/build/es/components/Notification/Notification.d.ts +18 -4
- package/build/es/components/Notification/Notification.js +26 -11
- package/build/es/components/Pill/Pill.d.ts +4 -0
- package/build/es/components/Pill/Pill.js +52 -16
- package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +1 -1
- package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.js +7 -8
- package/build/es/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
- package/build/es/components/ProgressIndicator/ProgressIndicator.js +13 -6
- package/build/es/components/ReadMore/ReadMore.d.ts +4 -0
- package/build/es/components/ReadMore/ReadMore.js +31 -4
- package/build/es/components/Tooltip/Tooltip.d.ts +5 -1
- package/build/es/components/Tooltip/Tooltip.js +46 -6
- package/package.json +10 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MouseEvent } from 'react';
|
|
1
|
+
import type { MouseEvent, KeyboardEvent } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type ProgressIndicatorStatus = 'error';
|
|
4
4
|
interface Props {
|
|
@@ -15,7 +15,7 @@ interface Props {
|
|
|
15
15
|
* On Progress Indicator Item label or number click callback
|
|
16
16
|
* Use `e.currentTarget.parentElement` to get Progress Indicator Item element
|
|
17
17
|
*/
|
|
18
|
-
onStepClick?: (stepIndex: number, e: MouseEvent<HTMLElement>) => void;
|
|
18
|
+
onStepClick?: (stepIndex: number, e: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>) => void;
|
|
19
19
|
/**
|
|
20
20
|
* Allows to change version of component to small
|
|
21
21
|
*/
|
|
@@ -126,14 +126,21 @@ const ProgressIndicator = (_a) => {
|
|
|
126
126
|
props.onStepClick(index, e);
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
|
-
|
|
129
|
+
const handleKeyDown = (e) => {
|
|
130
|
+
if ((e.key === 'Enter' || e.key === ' ') && props.onStepClick) {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
props.onStepClick(index, e);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const isClickable = isCompleted && Boolean(props.onStepClick);
|
|
136
|
+
return (React__default.default.createElement(ProgressIndicatorItem, { key: id, small: props.small },
|
|
130
137
|
index > 0 && (React__default.default.createElement(ProgressIndicatorItemConnector, { small: props.small, isActive: isActive, isCompleted: isCompleted })),
|
|
131
|
-
React__default.default.createElement(ProgressIndicatorItemNumber, { small: props.small, onClick: handleClick, isActive: isActive, isCompleted: isCompleted, isError: isError, isClickable:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
label && (React__default.default.createElement(ProgressIndicatorItemLabel, { small: props.small, onClick: handleClick, isActive: isActive, className: "visually-hidden" }, label))));
|
|
138
|
+
React__default.default.createElement(ProgressIndicatorItemNumber, { small: props.small, onClick: handleClick, isActive: isActive, isCompleted: isCompleted, isError: isError, onKeyDown: handleKeyDown, tabIndex: isClickable || isActive ? 0 : -1, isClickable: isClickable, role: "tab", "aria-current": isActive ? 'step' : 'false', "aria-label": isCompleted && props.completedStepLabel
|
|
139
|
+
? `${label}, ${props.completedStepLabel}`
|
|
140
|
+
: label }, isCompleted || isError ? (React__default.default.createElement(Icon.default, { icon: isError ? icons.Warning : icons.Check, color: isError ? theme.default.color.text.white : theme.default.color.text.pink, size: "1rem", "aria-hidden": true })) : (stepNumber)),
|
|
141
|
+
label && (React__default.default.createElement(ProgressIndicatorItemLabel, { "aria-hidden": true, small: props.small, onClick: handleClick, isActive: isActive, className: "visually-hidden" }, label))));
|
|
135
142
|
});
|
|
136
|
-
return (React__default.default.createElement(ProgressIndicatorWrapper, { className: props.className, "data-testid": dataTestId, "aria-label": props.ariaLabel, role: "
|
|
143
|
+
return (React__default.default.createElement(ProgressIndicatorWrapper, { className: props.className, "data-testid": dataTestId, "aria-label": props.ariaLabel, role: "tablist" }, progressIndicatorItems));
|
|
137
144
|
};
|
|
138
145
|
|
|
139
146
|
exports.default = ProgressIndicator;
|
|
@@ -68,6 +68,10 @@ interface Props {
|
|
|
68
68
|
* Allows to pass testid string for testing purposes
|
|
69
69
|
*/
|
|
70
70
|
'data-testid'?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Allows to pass an accessible label for the component, enhancing screen reader support.
|
|
73
|
+
*/
|
|
74
|
+
ariaLabel?: string;
|
|
71
75
|
}
|
|
72
76
|
/** @visibleName Read More */
|
|
73
77
|
declare const ReadMore: ({ collapsedSize, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
@@ -45,6 +45,9 @@ const StyledButtonIcon = styled.default(ButtonIcon.default) `
|
|
|
45
45
|
const ReadMore = (_a) => {
|
|
46
46
|
var { collapsedSize = '10rem', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["collapsedSize", 'data-testid']);
|
|
47
47
|
const [expanded, setExpanded] = React.useState(props.seoInitExpanded === true || false);
|
|
48
|
+
const contentRef = React.useRef(null);
|
|
49
|
+
const buttonRef = React.useRef(null);
|
|
50
|
+
const userInteractedRef = React.useRef(false);
|
|
48
51
|
// TODO: Remove once https://jira.dna.fi/browse/STYLE-662 is done
|
|
49
52
|
const temporaryIsStatelessFlag = typeof props.isExpanded !== 'undefined';
|
|
50
53
|
const temporaryStateManagement = temporaryIsStatelessFlag ? props.isExpanded : expanded;
|
|
@@ -56,16 +59,40 @@ const ReadMore = (_a) => {
|
|
|
56
59
|
if (!temporaryIsStatelessFlag) {
|
|
57
60
|
setExpanded(!expanded);
|
|
58
61
|
}
|
|
62
|
+
userInteractedRef.current = true;
|
|
59
63
|
};
|
|
60
64
|
React.useEffect(() => {
|
|
61
65
|
if (props.seoInitExpanded) {
|
|
62
66
|
setExpanded(false);
|
|
63
67
|
}
|
|
64
68
|
}, [props.seoInitExpanded]);
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
if (userInteractedRef.current) {
|
|
72
|
+
if (temporaryStateManagement) {
|
|
73
|
+
(_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
(_b = buttonRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, [temporaryStateManagement]);
|
|
80
|
+
// Function to apply tabIndex to all links elements of children (since we don't control what is passed as children)
|
|
81
|
+
const forceTabIndexOnTextLinks = (child) => {
|
|
82
|
+
if (!React.isValidElement(child)) {
|
|
83
|
+
return child;
|
|
84
|
+
}
|
|
85
|
+
if (child.type === 'a') {
|
|
86
|
+
return React.cloneElement(child, {
|
|
87
|
+
tabIndex: temporaryStateManagement ? 0 : -1,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return child;
|
|
91
|
+
};
|
|
92
|
+
return (React__default.default.createElement(Container, { id: props.id, className: props.className, "data-testid": dataTestId, "aria-label": props.ariaLabel, role: "region" },
|
|
93
|
+
React__default.default.createElement(Content, { ref: contentRef, isExpanded: temporaryStateManagement, collapsedSize: collapsedSize, "data-testid": dataTestId && `${dataTestId}-content`, "aria-hidden": temporaryStateManagement ? 'false' : 'true', tabIndex: temporaryStateManagement ? 0 : -1 }, React.Children.map(props.children, forceTabIndexOnTextLinks)),
|
|
67
94
|
React__default.default.createElement(ButtonWrapper, { buttonPosition: props.buttonPosition },
|
|
68
|
-
React__default.default.createElement(StyledButtonIcon, { icon: temporaryStateManagement ? icons.ChevronUp : icons.ChevronDown, onClick: handleOnClick }, temporaryButtonLabel || props.buttonLabel))));
|
|
95
|
+
React__default.default.createElement(StyledButtonIcon, { ref: buttonRef, icon: temporaryStateManagement ? icons.ChevronUp : icons.ChevronDown, onClick: handleOnClick, ariaHidden: true, "aria-expanded": temporaryStateManagement }, temporaryButtonLabel || props.buttonLabel))));
|
|
69
96
|
};
|
|
70
97
|
|
|
71
98
|
exports.default = ReadMore;
|
|
@@ -46,10 +46,14 @@ interface Props {
|
|
|
46
46
|
closeWithEsc?: boolean;
|
|
47
47
|
/**
|
|
48
48
|
* Allows to open Tooltip by clicking the trigger element instead of hovering it
|
|
49
|
+
*
|
|
50
|
+
* @default false
|
|
49
51
|
*/
|
|
50
52
|
isClickable?: boolean;
|
|
51
53
|
/**
|
|
52
54
|
* Allows to keep Tooltip open when hovered. Useful when it contains interactive elements
|
|
55
|
+
*
|
|
56
|
+
* @default false
|
|
53
57
|
*/
|
|
54
58
|
isHoverable?: boolean;
|
|
55
59
|
/**
|
|
@@ -66,6 +70,6 @@ interface Props {
|
|
|
66
70
|
*/
|
|
67
71
|
'data-testid'?: string;
|
|
68
72
|
}
|
|
69
|
-
declare const Tooltip: ({ "data-testid": dataTestId, closeWithEsc, ...props }: Props) => React.JSX.Element;
|
|
73
|
+
declare const Tooltip: ({ "data-testid": dataTestId, closeWithEsc, isClickable, isHoverable, ...props }: Props) => React.JSX.Element;
|
|
70
74
|
/** @component */
|
|
71
75
|
export default Tooltip;
|
|
@@ -16,9 +16,28 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
16
16
|
|
|
17
17
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
18
18
|
|
|
19
|
-
const Helper = styled.default.
|
|
20
|
-
display: inline;
|
|
19
|
+
const Helper = styled.default.button `
|
|
20
|
+
display: inline-block;
|
|
21
21
|
vertical-align: middle;
|
|
22
|
+
background: transparent;
|
|
23
|
+
border: none;
|
|
24
|
+
padding: 0;
|
|
25
|
+
margin: 0;
|
|
26
|
+
color: inherit;
|
|
27
|
+
font: inherit;
|
|
28
|
+
text-align: inherit;
|
|
29
|
+
text-decoration: none;
|
|
30
|
+
outline: inherit;
|
|
31
|
+
pointer-events: auto;
|
|
32
|
+
height: 1rem;
|
|
33
|
+
|
|
34
|
+
&:focus-visible {
|
|
35
|
+
outline: none;
|
|
36
|
+
box-shadow: 0px 0px 0px 2px ${theme.default.color.focus.light},
|
|
37
|
+
0px 0px 0px 4px ${theme.default.color.focus.dark};
|
|
38
|
+
border-radius: 100%;
|
|
39
|
+
}
|
|
40
|
+
|
|
22
41
|
${({ isClickable }) => isClickable && `cursor: pointer`};
|
|
23
42
|
`;
|
|
24
43
|
const getArrowOverrides = () => {
|
|
@@ -65,11 +84,32 @@ const StyledReactTooltip = styled.default(reactTooltip.Tooltip) `
|
|
|
65
84
|
${getArrowOverrides()}
|
|
66
85
|
`;
|
|
67
86
|
const Tooltip = (_a) => {
|
|
68
|
-
var { 'data-testid': dataTestId, closeWithEsc = true } = _a, props = tslib.__rest(_a, ['data-testid', "closeWithEsc"]);
|
|
87
|
+
var { 'data-testid': dataTestId, closeWithEsc = true, isClickable = false, isHoverable = false } = _a, props = tslib.__rest(_a, ['data-testid', "closeWithEsc", "isClickable", "isHoverable"]);
|
|
88
|
+
const handleReactTooltipOpenEvents = {
|
|
89
|
+
mouseover: !isClickable,
|
|
90
|
+
focus: !isClickable,
|
|
91
|
+
mouseenter: !isClickable,
|
|
92
|
+
mousedown: !isClickable && !isHoverable,
|
|
93
|
+
click: isClickable,
|
|
94
|
+
dblclick: isClickable,
|
|
95
|
+
};
|
|
96
|
+
const handleReactTooltipCloseEvents = {
|
|
97
|
+
mouseout: !isClickable && !isHoverable,
|
|
98
|
+
blur: !isClickable && !isHoverable,
|
|
99
|
+
mouseleave: !isClickable,
|
|
100
|
+
mouseup: !isClickable,
|
|
101
|
+
click: isClickable,
|
|
102
|
+
dblclick: isClickable,
|
|
103
|
+
};
|
|
104
|
+
const handleReactTooltipGlobalCloseEvents = {
|
|
105
|
+
escape: closeWithEsc,
|
|
106
|
+
clickOutsideAnchor: true,
|
|
107
|
+
scroll: true,
|
|
108
|
+
};
|
|
69
109
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
70
|
-
!props.hideTriggerElement && (React__default.default.createElement(Helper, { "data-tooltip-id": props.id, isClickable:
|
|
71
|
-
React__default.default.createElement(Icon.default, { icon: icons.Info, size: "1rem", position: props.position }))),
|
|
72
|
-
React__default.default.createElement(StyledReactTooltip, { id: props.id, place: props.placement,
|
|
110
|
+
!props.hideTriggerElement && (React__default.default.createElement(Helper, { "data-tooltip-id": props.id, isClickable: isClickable, className: props.className, "data-testid": dataTestId, type: "button", "data-tooltip-delay-hide": 500, "aria-describedby": props.id },
|
|
111
|
+
React__default.default.createElement(Icon.default, { icon: icons.Info, size: "1rem", position: props.position, "aria-hidden": true }))),
|
|
112
|
+
React__default.default.createElement(StyledReactTooltip, { id: props.id, place: props.placement, openOnClick: isClickable, clickable: isHoverable, isMultiline: props.isMultiline, disableStyleInjection: true, role: isHoverable ? 'dialog' : 'tooltip', openEvents: handleReactTooltipOpenEvents, globalCloseEvents: handleReactTooltipGlobalCloseEvents, closeEvents: handleReactTooltipCloseEvents, "data-testid": dataTestId && `${dataTestId}-content` }, props.children)));
|
|
73
113
|
};
|
|
74
114
|
|
|
75
115
|
exports.default = Tooltip;
|
|
@@ -54,8 +54,196 @@ interface Props {
|
|
|
54
54
|
* If not provided, visibleItems property will be used
|
|
55
55
|
*/
|
|
56
56
|
responsive?: Partial<Responsive>;
|
|
57
|
+
/**
|
|
58
|
+
* Allows to pass a screen reader label for the pagination item next to the current slide number
|
|
59
|
+
*/
|
|
60
|
+
paginationAriaLabel?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Allows to pass a screen reader label for the next arrow button
|
|
63
|
+
*/
|
|
64
|
+
nextAriaLabel?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Allows to pass a screen reader label for the previous arrow button
|
|
67
|
+
*/
|
|
68
|
+
previousAriaLabel?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Number of items to move when navigating the carousel
|
|
71
|
+
*
|
|
72
|
+
* @default 1
|
|
73
|
+
*/
|
|
74
|
+
swipeStep?: number;
|
|
57
75
|
}
|
|
76
|
+
declare const SlideItem: import("styled-components").StyledComponent<"div", {
|
|
77
|
+
base: {
|
|
78
|
+
baseHeight: {
|
|
79
|
+
value: number;
|
|
80
|
+
unit: string;
|
|
81
|
+
};
|
|
82
|
+
baseWidth: {
|
|
83
|
+
value: number;
|
|
84
|
+
unit: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
breakpoints: import("../../themes/themeComponents/breakpoints").ViewBreakpoints;
|
|
88
|
+
color: {
|
|
89
|
+
default: {
|
|
90
|
+
pink: string;
|
|
91
|
+
plum: string;
|
|
92
|
+
white: string;
|
|
93
|
+
black: string;
|
|
94
|
+
};
|
|
95
|
+
accent: {
|
|
96
|
+
lemon: string;
|
|
97
|
+
sky: string;
|
|
98
|
+
orange: string;
|
|
99
|
+
};
|
|
100
|
+
active: {
|
|
101
|
+
pink: string;
|
|
102
|
+
};
|
|
103
|
+
hover: {
|
|
104
|
+
pink: string;
|
|
105
|
+
};
|
|
106
|
+
text: {
|
|
107
|
+
gray: string;
|
|
108
|
+
pink: string;
|
|
109
|
+
plum: string;
|
|
110
|
+
white: string;
|
|
111
|
+
black: string;
|
|
112
|
+
};
|
|
113
|
+
line: {
|
|
114
|
+
L01: string;
|
|
115
|
+
L02: string;
|
|
116
|
+
L03: string;
|
|
117
|
+
L04: string;
|
|
118
|
+
};
|
|
119
|
+
notification: {
|
|
120
|
+
info: string;
|
|
121
|
+
success: string;
|
|
122
|
+
warning: string;
|
|
123
|
+
error: string;
|
|
124
|
+
};
|
|
125
|
+
background: {
|
|
126
|
+
sand: {
|
|
127
|
+
default: string;
|
|
128
|
+
E01: string;
|
|
129
|
+
E02: string;
|
|
130
|
+
};
|
|
131
|
+
pink: {
|
|
132
|
+
default: string;
|
|
133
|
+
E01: string;
|
|
134
|
+
E02: string;
|
|
135
|
+
};
|
|
136
|
+
plum: {
|
|
137
|
+
default: string;
|
|
138
|
+
E01: string;
|
|
139
|
+
E02: string;
|
|
140
|
+
};
|
|
141
|
+
lemon: {
|
|
142
|
+
default: string;
|
|
143
|
+
E01: string;
|
|
144
|
+
E02: string;
|
|
145
|
+
};
|
|
146
|
+
sky: {
|
|
147
|
+
default: string;
|
|
148
|
+
E01: string;
|
|
149
|
+
E02: string;
|
|
150
|
+
};
|
|
151
|
+
orange: {
|
|
152
|
+
default: string;
|
|
153
|
+
E01: string;
|
|
154
|
+
E02: string;
|
|
155
|
+
};
|
|
156
|
+
white: {
|
|
157
|
+
default: string;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
focus: {
|
|
161
|
+
dark: string;
|
|
162
|
+
light: string;
|
|
163
|
+
};
|
|
164
|
+
transparency: {
|
|
165
|
+
T0: string;
|
|
166
|
+
T10: string;
|
|
167
|
+
T20: string;
|
|
168
|
+
T30: string;
|
|
169
|
+
T40: string;
|
|
170
|
+
T50: string;
|
|
171
|
+
T60: string;
|
|
172
|
+
T70: string;
|
|
173
|
+
T80: string;
|
|
174
|
+
T90: string;
|
|
175
|
+
T100: string;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
fontFamily: {
|
|
179
|
+
default: string;
|
|
180
|
+
heading: string;
|
|
181
|
+
numerals: string;
|
|
182
|
+
};
|
|
183
|
+
fontSize: {
|
|
184
|
+
default: string;
|
|
185
|
+
xl: string;
|
|
186
|
+
l: string;
|
|
187
|
+
s: string;
|
|
188
|
+
xs: string;
|
|
189
|
+
h1XL: string;
|
|
190
|
+
h1L: string;
|
|
191
|
+
h1M: string;
|
|
192
|
+
h1S: string;
|
|
193
|
+
h2M: string;
|
|
194
|
+
h2S: string;
|
|
195
|
+
h3: string;
|
|
196
|
+
h4: string;
|
|
197
|
+
h5: string;
|
|
198
|
+
h1: string;
|
|
199
|
+
h2: string;
|
|
200
|
+
};
|
|
201
|
+
fontWeight: {
|
|
202
|
+
book: number;
|
|
203
|
+
medium: number;
|
|
204
|
+
bold: number;
|
|
205
|
+
black: number;
|
|
206
|
+
};
|
|
207
|
+
form: {
|
|
208
|
+
smallSelectWidth: string;
|
|
209
|
+
smallSelectHeight: string;
|
|
210
|
+
};
|
|
211
|
+
grid: {
|
|
212
|
+
gutter: string;
|
|
213
|
+
};
|
|
214
|
+
lineHeight: {
|
|
215
|
+
default: string;
|
|
216
|
+
xl: string;
|
|
217
|
+
s: string;
|
|
218
|
+
xs: string;
|
|
219
|
+
xxs: string;
|
|
220
|
+
auto: string;
|
|
221
|
+
h1XL: string;
|
|
222
|
+
h1L: string;
|
|
223
|
+
h1M: string;
|
|
224
|
+
h1S: string;
|
|
225
|
+
h2M: string;
|
|
226
|
+
h2S: string;
|
|
227
|
+
h3: string;
|
|
228
|
+
h4: string;
|
|
229
|
+
h5: string;
|
|
230
|
+
h1: string;
|
|
231
|
+
h2: string;
|
|
232
|
+
};
|
|
233
|
+
media: Record<string | number, (l: TemplateStringsArray, ...p: (string | number)[]) => string>;
|
|
234
|
+
radius: {
|
|
235
|
+
default: string;
|
|
236
|
+
s: string;
|
|
237
|
+
xs: string;
|
|
238
|
+
circle: string;
|
|
239
|
+
pill: string;
|
|
240
|
+
};
|
|
241
|
+
}, Required<Pick<Props, "visibleItems">> & {
|
|
242
|
+
itemWidthCorrection: number;
|
|
243
|
+
isSwiping: boolean;
|
|
244
|
+
}, never>;
|
|
58
245
|
/** @visibleName Carousel */
|
|
59
246
|
declare const Carousel: ({ "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
60
247
|
/** @component */
|
|
61
248
|
export default Carousel;
|
|
249
|
+
export { SlideItem };
|
|
@@ -138,6 +138,7 @@ const Counter = styled.span `
|
|
|
138
138
|
`;
|
|
139
139
|
/** @visibleName Carousel */
|
|
140
140
|
const Carousel = (_a) => {
|
|
141
|
+
var _b;
|
|
141
142
|
var { 'data-testid': dataTestId } = _a, props = __rest(_a, ['data-testid']);
|
|
142
143
|
const slidesWrapperRef = useRef(null);
|
|
143
144
|
const scrollbarRef = useRef(null);
|
|
@@ -167,9 +168,18 @@ const Carousel = (_a) => {
|
|
|
167
168
|
}, 100);
|
|
168
169
|
return () => clearTimeout(timeoutId);
|
|
169
170
|
}, [width, isMobile, props.responsive, props.visibleItems, props.children]);
|
|
171
|
+
const getStep = (step, visibleItems) => {
|
|
172
|
+
if (step > visibleItems) {
|
|
173
|
+
return Math.floor(visibleItems);
|
|
174
|
+
}
|
|
175
|
+
return Math.floor(step);
|
|
176
|
+
};
|
|
170
177
|
const visibleItems = props.visibleItems || calculatedItems;
|
|
171
178
|
const slidesWrapperGapSizePx = 20;
|
|
172
179
|
const slideScreensCount = Children.count(props.children) - Math.floor(visibleItems) + 1;
|
|
180
|
+
const step = getStep((_b = props.swipeStep) !== null && _b !== void 0 ? _b : 1, visibleItems);
|
|
181
|
+
const currentStepIndex = Math.ceil(currentIndex / step);
|
|
182
|
+
const totalSwipeSteps = Math.ceil(slideScreensCount / step + ((slideScreensCount - 1) % step !== 0 ? 1 : 0));
|
|
173
183
|
const itemWidthCorrectionRatio = (slidesWrapperGapSizePx * visibleItems) % Math.floor(visibleItems) === 0
|
|
174
184
|
? (visibleItems - 1) / visibleItems
|
|
175
185
|
: Math.floor(visibleItems) / visibleItems;
|
|
@@ -216,14 +226,15 @@ const Carousel = (_a) => {
|
|
|
216
226
|
}
|
|
217
227
|
};
|
|
218
228
|
const handleNavigationButtonPreviousClick = () => {
|
|
219
|
-
handleSetCurrentIndex(currentIndex -
|
|
229
|
+
handleSetCurrentIndex(currentIndex - step);
|
|
220
230
|
};
|
|
221
231
|
const handleNavigationButtonNextClick = () => {
|
|
222
|
-
handleSetCurrentIndex(currentIndex +
|
|
232
|
+
handleSetCurrentIndex(currentIndex + step);
|
|
223
233
|
};
|
|
224
234
|
const handlePaginationItemClick = (e) => {
|
|
225
235
|
if (e.currentTarget.parentElement) {
|
|
226
|
-
|
|
236
|
+
const index = [...e.currentTarget.parentElement.children].indexOf(e.currentTarget);
|
|
237
|
+
handleSetCurrentIndex(index * step);
|
|
227
238
|
}
|
|
228
239
|
};
|
|
229
240
|
const handlePointerMove = (e) => {
|
|
@@ -264,14 +275,14 @@ const Carousel = (_a) => {
|
|
|
264
275
|
if (endTime - data.startTime > 300) {
|
|
265
276
|
const swipeRatio = Math.abs(data.currentTransform - data.startTransform) / data.itemWidth;
|
|
266
277
|
if (swipeRatio >= 0.5) {
|
|
267
|
-
handleSetCurrentIndex(currentIndex + Math.round(data.direction > 0 ? swipeRatio : -swipeRatio));
|
|
278
|
+
handleSetCurrentIndex(currentIndex + Math.round(data.direction > 0 ? swipeRatio : -swipeRatio) * step);
|
|
268
279
|
}
|
|
269
280
|
else {
|
|
270
281
|
handleSetCurrentIndex(currentIndex);
|
|
271
282
|
}
|
|
272
283
|
}
|
|
273
284
|
else {
|
|
274
|
-
handleSetCurrentIndex(currentIndex + data.direction);
|
|
285
|
+
handleSetCurrentIndex(currentIndex + data.direction * step);
|
|
275
286
|
}
|
|
276
287
|
if (data.scrollbarNavigation && data.direction === 0) {
|
|
277
288
|
if (knobRef.current) {
|
|
@@ -333,19 +344,20 @@ const Carousel = (_a) => {
|
|
|
333
344
|
props.title && React__default.createElement(Title, null, props.title),
|
|
334
345
|
React__default.createElement(Navigation, null,
|
|
335
346
|
props.hasCounter && (React__default.createElement(Counter, null,
|
|
336
|
-
slideScreensCount === 0 ? 0 :
|
|
347
|
+
slideScreensCount === 0 ? 0 : currentStepIndex + 1,
|
|
337
348
|
"/",
|
|
338
|
-
|
|
339
|
-
React__default.createElement(ButtonArrow, { direction: "left", "aria-label":
|
|
340
|
-
React__default.createElement(ButtonArrow, { direction: "right", "aria-label":
|
|
349
|
+
totalSwipeSteps)),
|
|
350
|
+
React__default.createElement(ButtonArrow, { direction: "left", "aria-label": props.previousAriaLabel, onClick: handleNavigationButtonPreviousClick, disabled: currentIndex <= 0, type: "button" }),
|
|
351
|
+
React__default.createElement(ButtonArrow, { direction: "right", "aria-label": props.nextAriaLabel, onClick: handleNavigationButtonNextClick, disabled: currentIndex + visibleItems >= Children.count(props.children), type: "button" }))),
|
|
341
352
|
React__default.createElement(Content, { "data-testid": dataTestId && `${dataTestId}-content` },
|
|
342
353
|
React__default.createElement(SlidesWrapper, { ref: slidesWrapperRef, onPointerDown: handleSlidesPointerDown, gap: slidesWrapperGapSizePx / 16 }, Children.map(props.children, child => (React__default.createElement(SlideItem, { visibleItems: visibleItems, itemWidthCorrection: itemWidthCorrection, isSwiping: isSwiping, onPointerDown: handlePointerDown }, child))))),
|
|
343
354
|
React__default.createElement(Footer, { "data-testid": dataTestId && `${dataTestId}-footer` },
|
|
344
|
-
React__default.createElement(Pagination, null, [...Array(
|
|
355
|
+
React__default.createElement(Pagination, null, [...Array(totalSwipeSteps).keys()].map((value, index) => (React__default.createElement(PaginationItem, { key: value, "aria-label": props.paginationAriaLabel &&
|
|
356
|
+
`${props.paginationAriaLabel} ${index + 1}`, "aria-current": Math.ceil(currentIndex / step) === index, isActive: Math.ceil(currentIndex / step) === index, onClick: handlePaginationItemClick, type: "button" })))),
|
|
345
357
|
React__default.createElement(Scrollbar, { ref: scrollbarRef, onPointerDown: handleScrollbarPointerDown },
|
|
346
358
|
React__default.createElement(Knob, { ref: knobRef, knobSize: slideScreensCount })),
|
|
347
359
|
props.footerButton && (React__default.createElement(FooterButton, null,
|
|
348
360
|
React__default.createElement(ButtonIcon, { icon: ArrowRight, onClick: props.onFooterButtonClick }, props.footerButton))))));
|
|
349
361
|
};
|
|
350
362
|
|
|
351
|
-
export { Carousel as default };
|
|
363
|
+
export { SlideItem, Carousel as default };
|
|
@@ -29,6 +29,10 @@ interface Props {
|
|
|
29
29
|
* Allows to pass a custom className
|
|
30
30
|
*/
|
|
31
31
|
className?: string;
|
|
32
|
+
/**
|
|
33
|
+
* An aria-label to the focusable separator should be included if there is more than one focusable separator
|
|
34
|
+
*/
|
|
35
|
+
ariaLabelFocusableSeparator?: string;
|
|
32
36
|
}
|
|
33
37
|
declare const Divider: ({ "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
34
38
|
/** @component */
|
|
@@ -17,7 +17,8 @@ const DividerWrapper = styled__default.div `
|
|
|
17
17
|
`;
|
|
18
18
|
const Divider = (_a) => {
|
|
19
19
|
var { 'data-testid': dataTestId } = _a, props = __rest(_a, ['data-testid']);
|
|
20
|
-
|
|
20
|
+
const isFocusableSeparator = Boolean(props.children);
|
|
21
|
+
return (React__default.createElement(DividerWrapper, { id: props.id, margin: props.margin, padding: props.padding, className: props.className, "data-testid": dataTestId, as: isFocusableSeparator ? 'div' : 'hr', role: isFocusableSeparator ? 'separator' : undefined, "aria-orientation": "horizontal", "aria-label": props.ariaLabelFocusableSeparator, "aria-hidden": !isFocusableSeparator, tabIndex: isFocusableSeparator ? 0 : -1 }, props.children));
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
export { Divider as default };
|
|
@@ -37,6 +37,10 @@ interface Props {
|
|
|
37
37
|
* Allows to pass testid string for testing purposes
|
|
38
38
|
*/
|
|
39
39
|
'data-testid'?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Allows to pass a screen reader label to the component
|
|
42
|
+
*/
|
|
43
|
+
ariaLabel?: string;
|
|
40
44
|
}
|
|
41
45
|
/** @visibleName Info Dialog */
|
|
42
46
|
declare const InfoDialog: ({ position, type, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
@@ -54,7 +54,7 @@ const InfoDialogContainer = styled.div `
|
|
|
54
54
|
/** @visibleName Info Dialog */
|
|
55
55
|
const InfoDialog = (_a) => {
|
|
56
56
|
var { position = 'middle', type = 'default', 'data-testid': dataTestId } = _a, props = __rest(_a, ["position", "type", 'data-testid']);
|
|
57
|
-
return (React__default.createElement(InfoDialogContainer, { id: props.id, "data-testid": dataTestId, className: props.className, position: position, type: type }, props.children));
|
|
57
|
+
return (React__default.createElement(InfoDialogContainer, { id: props.id, "data-testid": dataTestId, className: props.className, position: position, type: type, role: "region", "aria-label": props.ariaLabel }, props.children));
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
export { InfoDialog as default };
|
|
@@ -158,8 +158,7 @@ const Input = (_a) => {
|
|
|
158
158
|
return (React__default.createElement(FieldContainer, { className: props.className },
|
|
159
159
|
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)),
|
|
160
160
|
React__default.createElement(FieldWrapper, { status: props.status, "$type": type, "$disabled": props.disabled },
|
|
161
|
-
React__default.createElement(StyledInput, { id: props.id, name: props.name, type:
|
|
162
|
-
props.readonly && React__default.createElement("div", null, props.value),
|
|
161
|
+
React__default.createElement(StyledInput, { id: props.id, name: props.name, type: type, value: props.value, placeholder: props.placeholder, onChange: handleChange, onBlur: handleOnBlur, onFocus: props.onFocus, onClick: onClick, onKeyDown: props.onKeyDown, onKeyPress: props.onKeyPress, required: props.required, disabled: props.disabled, autoComplete: props.autocomplete, "aria-disabled": props.disabled, "aria-label": !props.label ? (_b = props.ariaLabel) !== null && _b !== void 0 ? _b : props.id : undefined, ref: inputRef, tabIndex: props.tabIndex, "aria-describedby": getDescribedBy(), "data-testid": dataTestId, readOnly: props.readonly }),
|
|
163
162
|
((props.status && props.status !== 'comment') ||
|
|
164
163
|
props.showPasswordToggle ||
|
|
165
164
|
props.disabled ||
|
|
@@ -18,10 +18,12 @@ interface Props {
|
|
|
18
18
|
* Styling of `label` element changes depending on the passed status
|
|
19
19
|
*
|
|
20
20
|
* @param {LabelTextStatus} undefined Default styling
|
|
21
|
-
* @param {LabelTextStatus} info Changes color to
|
|
22
|
-
* @param {LabelTextStatus} success Changes color to
|
|
23
|
-
* @param {LabelTextStatus} warning Changes color to
|
|
21
|
+
* @param {LabelTextStatus} info Changes color to default color (this type will be deprecated in the future)
|
|
22
|
+
* @param {LabelTextStatus} success Changes color to default color (this type will be deprecated in the future)
|
|
23
|
+
* @param {LabelTextStatus} warning Changes color to default color (this type will be deprecated in the future)
|
|
24
24
|
* @param {LabelTextStatus} error Changes color to `theme.color.notification.error`
|
|
25
|
+
*
|
|
26
|
+
* @deprecated info, success and warning are deprecated, please switch to default or error status
|
|
25
27
|
*/
|
|
26
28
|
status?: LabelTextStatus;
|
|
27
29
|
/**
|
|
@@ -6,7 +6,7 @@ import { getDividedSize } from '../../utils/styledUtils.js';
|
|
|
6
6
|
|
|
7
7
|
const Label = styled.label `
|
|
8
8
|
display: block;
|
|
9
|
-
color: ${({ status }) =>
|
|
9
|
+
color: ${({ status }) => status === 'error' ? theme.color.notification.error : theme.color.text.gray};
|
|
10
10
|
font-weight: ${theme.fontWeight.medium};
|
|
11
11
|
font-size: ${theme.fontSize.default};
|
|
12
12
|
line-height: ${theme.lineHeight.default};
|
|
@@ -16,13 +16,17 @@ interface Props {
|
|
|
16
16
|
/**
|
|
17
17
|
* Content of the component
|
|
18
18
|
*/
|
|
19
|
-
children
|
|
19
|
+
children: ReactNode;
|
|
20
20
|
/**
|
|
21
21
|
* Allows to show and hide close button
|
|
22
22
|
*
|
|
23
23
|
* @default false
|
|
24
24
|
*/
|
|
25
25
|
closeButton?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Label for the close button
|
|
28
|
+
*/
|
|
29
|
+
closeButtonLabel?: string;
|
|
26
30
|
/**
|
|
27
31
|
* On close button click callback
|
|
28
32
|
*/
|
|
@@ -41,8 +45,18 @@ interface Props {
|
|
|
41
45
|
* Allows to pass testid string for testing purposes
|
|
42
46
|
*/
|
|
43
47
|
'data-testid'?: string;
|
|
48
|
+
/**
|
|
49
|
+
* If true, the component is treated as static (non-interactive),
|
|
50
|
+
* and uses `aria-label` instead of `role="alert"`.
|
|
51
|
+
*
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
isStatic?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Accessible label for the notification. Required when `isStatic` is true
|
|
57
|
+
* and no type-based default label is desired.
|
|
58
|
+
*/
|
|
59
|
+
ariaLabel?: string;
|
|
44
60
|
}
|
|
45
|
-
|
|
46
|
-
declare const Notification: ({ type, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element | null;
|
|
47
|
-
/** @component */
|
|
61
|
+
declare const Notification: ({ type, "data-testid": dataTestId, isStatic, className, children, closeButton, closeButtonLabel, onClickCloseButton, dismissed, ariaLabel, }: Props) => React.JSX.Element | null;
|
|
48
62
|
export default Notification;
|