@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.
Files changed (43) hide show
  1. package/build/cjs/components/Carousel/Carousel.d.ts +188 -0
  2. package/build/cjs/components/Carousel/Carousel.js +23 -10
  3. package/build/cjs/components/Divider/Divider.d.ts +4 -0
  4. package/build/cjs/components/Divider/Divider.js +2 -1
  5. package/build/cjs/components/InfoDialog/InfoDialog.d.ts +4 -0
  6. package/build/cjs/components/InfoDialog/InfoDialog.js +1 -1
  7. package/build/cjs/components/Input/Input.js +1 -2
  8. package/build/cjs/components/LabelText/LabelText.d.ts +5 -3
  9. package/build/cjs/components/LabelText/LabelText.js +1 -1
  10. package/build/cjs/components/Notification/Notification.d.ts +18 -4
  11. package/build/cjs/components/Notification/Notification.js +25 -10
  12. package/build/cjs/components/Pill/Pill.d.ts +4 -0
  13. package/build/cjs/components/Pill/Pill.js +52 -16
  14. package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +1 -1
  15. package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.js +7 -8
  16. package/build/cjs/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
  17. package/build/cjs/components/ProgressIndicator/ProgressIndicator.js +13 -6
  18. package/build/cjs/components/ReadMore/ReadMore.d.ts +4 -0
  19. package/build/cjs/components/ReadMore/ReadMore.js +30 -3
  20. package/build/cjs/components/Tooltip/Tooltip.d.ts +5 -1
  21. package/build/cjs/components/Tooltip/Tooltip.js +46 -6
  22. package/build/es/components/Carousel/Carousel.d.ts +188 -0
  23. package/build/es/components/Carousel/Carousel.js +23 -11
  24. package/build/es/components/Divider/Divider.d.ts +4 -0
  25. package/build/es/components/Divider/Divider.js +2 -1
  26. package/build/es/components/InfoDialog/InfoDialog.d.ts +4 -0
  27. package/build/es/components/InfoDialog/InfoDialog.js +1 -1
  28. package/build/es/components/Input/Input.js +1 -2
  29. package/build/es/components/LabelText/LabelText.d.ts +5 -3
  30. package/build/es/components/LabelText/LabelText.js +1 -1
  31. package/build/es/components/Notification/Notification.d.ts +18 -4
  32. package/build/es/components/Notification/Notification.js +26 -11
  33. package/build/es/components/Pill/Pill.d.ts +4 -0
  34. package/build/es/components/Pill/Pill.js +52 -16
  35. package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +1 -1
  36. package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.js +7 -8
  37. package/build/es/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
  38. package/build/es/components/ProgressIndicator/ProgressIndicator.js +13 -6
  39. package/build/es/components/ReadMore/ReadMore.d.ts +4 -0
  40. package/build/es/components/ReadMore/ReadMore.js +31 -4
  41. package/build/es/components/Tooltip/Tooltip.d.ts +5 -1
  42. package/build/es/components/Tooltip/Tooltip.js +46 -6
  43. package/package.json +10 -10
@@ -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 };
@@ -146,6 +146,7 @@ const Counter = styled.default.span `
146
146
  `;
147
147
  /** @visibleName Carousel */
148
148
  const Carousel = (_a) => {
149
+ var _b;
149
150
  var { 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ['data-testid']);
150
151
  const slidesWrapperRef = React.useRef(null);
151
152
  const scrollbarRef = React.useRef(null);
@@ -175,9 +176,18 @@ const Carousel = (_a) => {
175
176
  }, 100);
176
177
  return () => clearTimeout(timeoutId);
177
178
  }, [width, isMobile, props.responsive, props.visibleItems, props.children]);
179
+ const getStep = (step, visibleItems) => {
180
+ if (step > visibleItems) {
181
+ return Math.floor(visibleItems);
182
+ }
183
+ return Math.floor(step);
184
+ };
178
185
  const visibleItems = props.visibleItems || calculatedItems;
179
186
  const slidesWrapperGapSizePx = 20;
180
187
  const slideScreensCount = React.Children.count(props.children) - Math.floor(visibleItems) + 1;
188
+ const step = getStep((_b = props.swipeStep) !== null && _b !== void 0 ? _b : 1, visibleItems);
189
+ const currentStepIndex = Math.ceil(currentIndex / step);
190
+ const totalSwipeSteps = Math.ceil(slideScreensCount / step + ((slideScreensCount - 1) % step !== 0 ? 1 : 0));
181
191
  const itemWidthCorrectionRatio = (slidesWrapperGapSizePx * visibleItems) % Math.floor(visibleItems) === 0
182
192
  ? (visibleItems - 1) / visibleItems
183
193
  : Math.floor(visibleItems) / visibleItems;
@@ -224,14 +234,15 @@ const Carousel = (_a) => {
224
234
  }
225
235
  };
226
236
  const handleNavigationButtonPreviousClick = () => {
227
- handleSetCurrentIndex(currentIndex - 1);
237
+ handleSetCurrentIndex(currentIndex - step);
228
238
  };
229
239
  const handleNavigationButtonNextClick = () => {
230
- handleSetCurrentIndex(currentIndex + 1);
240
+ handleSetCurrentIndex(currentIndex + step);
231
241
  };
232
242
  const handlePaginationItemClick = (e) => {
233
243
  if (e.currentTarget.parentElement) {
234
- handleSetCurrentIndex([...e.currentTarget.parentElement.children].indexOf(e.currentTarget));
244
+ const index = [...e.currentTarget.parentElement.children].indexOf(e.currentTarget);
245
+ handleSetCurrentIndex(index * step);
235
246
  }
236
247
  };
237
248
  const handlePointerMove = (e) => {
@@ -272,14 +283,14 @@ const Carousel = (_a) => {
272
283
  if (endTime - data.startTime > 300) {
273
284
  const swipeRatio = Math.abs(data.currentTransform - data.startTransform) / data.itemWidth;
274
285
  if (swipeRatio >= 0.5) {
275
- handleSetCurrentIndex(currentIndex + Math.round(data.direction > 0 ? swipeRatio : -swipeRatio));
286
+ handleSetCurrentIndex(currentIndex + Math.round(data.direction > 0 ? swipeRatio : -swipeRatio) * step);
276
287
  }
277
288
  else {
278
289
  handleSetCurrentIndex(currentIndex);
279
290
  }
280
291
  }
281
292
  else {
282
- handleSetCurrentIndex(currentIndex + data.direction);
293
+ handleSetCurrentIndex(currentIndex + data.direction * step);
283
294
  }
284
295
  if (data.scrollbarNavigation && data.direction === 0) {
285
296
  if (knobRef.current) {
@@ -341,19 +352,21 @@ const Carousel = (_a) => {
341
352
  props.title && React__default.default.createElement(Title, null, props.title),
342
353
  React__default.default.createElement(Navigation, null,
343
354
  props.hasCounter && (React__default.default.createElement(Counter, null,
344
- slideScreensCount === 0 ? 0 : currentIndex + 1,
355
+ slideScreensCount === 0 ? 0 : currentStepIndex + 1,
345
356
  "/",
346
- slideScreensCount)),
347
- React__default.default.createElement(ButtonArrow.default, { direction: "left", "aria-label": "Previous", onClick: handleNavigationButtonPreviousClick, disabled: currentIndex <= 0 }),
348
- React__default.default.createElement(ButtonArrow.default, { direction: "right", "aria-label": "Next", onClick: handleNavigationButtonNextClick, disabled: currentIndex + visibleItems >= React.Children.count(props.children) }))),
357
+ totalSwipeSteps)),
358
+ React__default.default.createElement(ButtonArrow.default, { direction: "left", "aria-label": props.previousAriaLabel, onClick: handleNavigationButtonPreviousClick, disabled: currentIndex <= 0, type: "button" }),
359
+ React__default.default.createElement(ButtonArrow.default, { direction: "right", "aria-label": props.nextAriaLabel, onClick: handleNavigationButtonNextClick, disabled: currentIndex + visibleItems >= React.Children.count(props.children), type: "button" }))),
349
360
  React__default.default.createElement(Content, { "data-testid": dataTestId && `${dataTestId}-content` },
350
361
  React__default.default.createElement(SlidesWrapper, { ref: slidesWrapperRef, onPointerDown: handleSlidesPointerDown, gap: slidesWrapperGapSizePx / 16 }, React.Children.map(props.children, child => (React__default.default.createElement(SlideItem, { visibleItems: visibleItems, itemWidthCorrection: itemWidthCorrection, isSwiping: isSwiping, onPointerDown: handlePointerDown }, child))))),
351
362
  React__default.default.createElement(Footer, { "data-testid": dataTestId && `${dataTestId}-footer` },
352
- React__default.default.createElement(Pagination, null, [...Array(slideScreensCount).keys()].map((value, index) => (React__default.default.createElement(PaginationItem, { key: value, "aria-label": `Move to step ${index + 1}`, "aria-current": index === currentIndex, isActive: index === currentIndex, onClick: handlePaginationItemClick })))),
363
+ React__default.default.createElement(Pagination, null, [...Array(totalSwipeSteps).keys()].map((value, index) => (React__default.default.createElement(PaginationItem, { key: value, "aria-label": props.paginationAriaLabel &&
364
+ `${props.paginationAriaLabel} ${index + 1}`, "aria-current": Math.ceil(currentIndex / step) === index, isActive: Math.ceil(currentIndex / step) === index, onClick: handlePaginationItemClick, type: "button" })))),
353
365
  React__default.default.createElement(Scrollbar, { ref: scrollbarRef, onPointerDown: handleScrollbarPointerDown },
354
366
  React__default.default.createElement(Knob, { ref: knobRef, knobSize: slideScreensCount })),
355
367
  props.footerButton && (React__default.default.createElement(FooterButton, null,
356
368
  React__default.default.createElement(ButtonIcon.default, { icon: icons.ArrowRight, onClick: props.onFooterButtonClick }, props.footerButton))))));
357
369
  };
358
370
 
371
+ exports.SlideItem = SlideItem;
359
372
  exports.default = Carousel;
@@ -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 */
@@ -26,7 +26,8 @@ const DividerWrapper = styled__default.default.div `
26
26
  `;
27
27
  const Divider = (_a) => {
28
28
  var { 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ['data-testid']);
29
- return (React__default.default.createElement(DividerWrapper, { id: props.id, margin: props.margin, padding: props.padding, className: props.className, "data-testid": dataTestId }, props.children));
29
+ const isFocusableSeparator = Boolean(props.children);
30
+ return (React__default.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));
30
31
  };
31
32
 
32
33
  exports.default = Divider;
@@ -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;
@@ -62,7 +62,7 @@ const InfoDialogContainer = styled.default.div `
62
62
  /** @visibleName Info Dialog */
63
63
  const InfoDialog = (_a) => {
64
64
  var { position = 'middle', type = 'default', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["position", "type", 'data-testid']);
65
- return (React__default.default.createElement(InfoDialogContainer, { id: props.id, "data-testid": dataTestId, className: props.className, position: position, type: type }, props.children));
65
+ return (React__default.default.createElement(InfoDialogContainer, { id: props.id, "data-testid": dataTestId, className: props.className, position: position, type: type, role: "region", "aria-label": props.ariaLabel }, props.children));
66
66
  };
67
67
 
68
68
  exports.default = InfoDialog;
@@ -166,8 +166,7 @@ const Input = (_a) => {
166
166
  return (React__default.default.createElement(FieldContainer, { className: props.className },
167
167
  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)),
168
168
  React__default.default.createElement(FieldWrapper, { status: props.status, "$type": type, "$disabled": props.disabled },
169
- React__default.default.createElement(StyledInput, { id: props.id, name: props.name, type: props.readonly ? 'hidden' : 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 }),
170
- props.readonly && React__default.default.createElement("div", null, props.value),
169
+ React__default.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 }),
171
170
  ((props.status && props.status !== 'comment') ||
172
171
  props.showPasswordToggle ||
173
172
  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 `theme.color.notification.info`
22
- * @param {LabelTextStatus} success Changes color to `theme.color.notification.success`
23
- * @param {LabelTextStatus} warning Changes color to `theme.color.notification.warning`
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
  /**
@@ -14,7 +14,7 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
14
14
 
15
15
  const Label = styled.default.label `
16
16
  display: block;
17
- color: ${({ status }) => (status ? theme.default.color.notification[status] : theme.default.color.text.gray)};
17
+ color: ${({ status }) => status === 'error' ? theme.default.color.notification.error : theme.default.color.text.gray};
18
18
  font-weight: ${theme.default.fontWeight.medium};
19
19
  font-size: ${theme.default.fontSize.default};
20
20
  line-height: ${theme.default.lineHeight.default};
@@ -16,13 +16,17 @@ interface Props {
16
16
  /**
17
17
  * Content of the component
18
18
  */
19
- children?: ReactNode;
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
- /** @visibleName Notification */
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;
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var icons = require('@dnanpm/icons');
7
6
  var React = require('react');
8
7
  var styled = require('styled-components');
@@ -21,7 +20,7 @@ const iconsMap = {
21
20
  warning: icons.Warning,
22
21
  error: icons.Error,
23
22
  };
24
- const NotificationWrapper = styled__default.default.div `
23
+ const sharedStyles = styled.css `
25
24
  display: flex;
26
25
  gap: 1rem;
27
26
  line-height: ${theme.default.lineHeight.default};
@@ -30,6 +29,14 @@ const NotificationWrapper = styled__default.default.div `
30
29
  border-radius: ${theme.default.radius.s};
31
30
  border: 2px solid ${({ $type }) => theme.default.color.notification[$type]};
32
31
  `;
32
+ const NotificationWrapper = styled__default.default.div `
33
+ ${sharedStyles}
34
+ border-color: ${({ $type }) => theme.default.color.notification[$type]};
35
+ `;
36
+ const StaticWrapper = styled__default.default.section `
37
+ ${sharedStyles}
38
+ border-color: ${({ $type }) => theme.default.color.notification[$type]};
39
+ `;
33
40
  const IconWrapper = styled__default.default.div `
34
41
  display: flex;
35
42
  align-items: center;
@@ -44,16 +51,24 @@ const ContentWrapper = styled__default.default.span `
44
51
  const ButtonCloseStyled = styled__default.default(ButtonClose.default) `
45
52
  position: static;
46
53
  margin: auto 0.5rem;
54
+
55
+ &:focus-visible {
56
+ outline: none;
57
+ box-shadow: 0px 0px 0px 2px ${theme.default.color.focus.light},
58
+ 0px 0px 0px 4px ${theme.default.color.focus.dark};
59
+ }
47
60
  `;
48
- /** @visibleName Notification */
49
- const Notification = (_a) => {
50
- var { type = 'info', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["type", 'data-testid']);
51
- return !props.dismissed ? (React__default.default.createElement(NotificationWrapper, { "$type": type, className: props.className, "data-testid": dataTestId },
61
+ const Notification = ({ type = 'info', 'data-testid': dataTestId, isStatic = false, className, children, closeButton = false, closeButtonLabel, onClickCloseButton, dismissed = false, ariaLabel, }) => {
62
+ if (dismissed)
63
+ return null;
64
+ const IconToUse = iconsMap[type];
65
+ const renderContent = () => (React__default.default.createElement(React__default.default.Fragment, null,
52
66
  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 })),
54
- React__default.default.createElement(ContentWrapper, null, props.children),
55
- props.closeButton && (React__default.default.createElement(ButtonCloseStyled, { onClick: props.onClickCloseButton },
56
- React__default.default.createElement(Icon.default, { icon: icons.Close, color: "currentColor" }))))) : null;
67
+ React__default.default.createElement(Icon.default, { icon: IconToUse, size: "2rem", color: theme.default.color.default.white, "aria-hidden": true })),
68
+ React__default.default.createElement(ContentWrapper, null, children),
69
+ closeButton && (React__default.default.createElement(ButtonCloseStyled, { onClick: onClickCloseButton, "aria-label": closeButtonLabel },
70
+ React__default.default.createElement(Icon.default, { icon: icons.Close, color: "currentColor", "aria-hidden": true })))));
71
+ return isStatic ? (React__default.default.createElement(StaticWrapper, { "$type": type, className: className, "data-testid": dataTestId, "aria-label": ariaLabel }, renderContent())) : (React__default.default.createElement(NotificationWrapper, { "$type": type, className: className, "data-testid": dataTestId, role: "alert" }, renderContent()));
57
72
  };
58
73
 
59
74
  exports.default = Notification;
@@ -72,6 +72,10 @@ interface Props {
72
72
  * Allows to pass a custom className
73
73
  */
74
74
  className?: string;
75
+ /**
76
+ * A styled version that is designed to look like the default Button component
77
+ */
78
+ isDefaultButtonStyle?: boolean;
75
79
  }
76
80
  declare const Pill: ({ type, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
77
81
  /** @component */
@@ -7,6 +7,7 @@ var React = require('react');
7
7
  var styled = require('styled-components');
8
8
  var theme = require('../../themes/theme.js');
9
9
  var styledUtils = require('../../utils/styledUtils.js');
10
+ var Button = require('../Button/Button.js');
10
11
 
11
12
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
12
13
 
@@ -14,34 +15,69 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
14
15
  var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
15
16
 
16
17
  const getCursor = ({ isDisabled, as }) => as !== 'div' && `cursor: ${isDisabled ? 'not-allowed' : 'pointer'};`;
17
- const getBackgroundColor = ({ isChecked, isDisabled }) => {
18
+ const getStandardPillStyles = ({ isChecked, isDisabled, }) => {
18
19
  const alphaValue = isDisabled ? theme.default.color.transparency.T30 : theme.default.color.transparency.T100;
19
- const colorValue = isChecked
20
+ const bgColor = isChecked
20
21
  ? theme.default.color.background.plum.default
21
22
  : theme.default.color.background.orange.E02;
22
- // Only Pill component specific colors to be used on user interaction styles
23
- const hoverValue = isChecked ? '#441632' : '#FFB557';
24
- const backgroundColor = `background-color: ${colorValue}${alphaValue};`;
25
- const hoverBackgroundColor = !isDisabled ? `&:hover { background-color: ${hoverValue}}` : '';
26
- return backgroundColor + hoverBackgroundColor;
23
+ const hoverBgColor = isChecked ? '#441632' : '#FFB557'; // Only Pill component specific colors to be used on user interaction styles
24
+ const textColor = isChecked ? theme.default.color.default.white : theme.default.color.default.black;
25
+ const disabledTextColor = isDisabled ? theme.default.color.text.gray : textColor;
26
+ return `
27
+ font-size: ${theme.default.fontSize.s};
28
+ font-weight: ${theme.default.fontWeight.medium};
29
+ padding: 2px ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2.5)};
30
+ background-color: ${bgColor}${alphaValue};
31
+ color: ${disabledTextColor};
32
+ border: 2px solid transparent;
33
+ ${!isDisabled ? `&:hover { background-color: ${hoverBgColor}; }` : ''}
34
+ `;
35
+ };
36
+ const getDefaultButtonStyles = ({ isChecked, isDisabled, }) => {
37
+ const alphaValue = isDisabled ? theme.default.color.transparency.T30 : theme.default.color.transparency.T100;
38
+ const hoverColor = '#441632'; // Only Pill component specific colors to be used on user interaction styles
39
+ const disabledBgColor = isDisabled ? theme.default.color.default.plum : Button.shade.plum.lighter;
40
+ const bgColor = isChecked ? disabledBgColor : 'transparent';
41
+ const textColor = isChecked ? theme.default.color.default.white : theme.default.color.default.plum;
42
+ const disabledTextColor = isDisabled ? theme.default.color.text.gray : textColor;
43
+ const disabledBorderColor = isDisabled ? 'transparent' : Button.shade.plum.lighter;
44
+ const borderColor = isChecked
45
+ ? disabledBorderColor
46
+ : `${theme.default.color.default.plum}${alphaValue}`;
47
+ return `
48
+ font-size: ${theme.default.fontSize.default};
49
+ font-weight: ${theme.default.fontWeight.bold};
50
+ padding: 6px ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2.5)};
51
+ background-color: ${bgColor}${alphaValue};
52
+ color: ${disabledTextColor};
53
+ border: 2px solid ${borderColor};
54
+ ${!isDisabled
55
+ ? `
56
+ &:hover {
57
+ border: 2px solid ${hoverColor};
58
+ color: ${theme.default.color.default.white};
59
+ background-color: ${hoverColor};
60
+ }`
61
+ : ''}
62
+ `;
27
63
  };
28
64
  const Label = styled__default.default.label `
29
65
  display: inline-block;
30
66
  border-radius: ${theme.default.radius.pill};
31
- font-size: ${theme.default.fontSize.s};
32
67
  line-height: ${theme.default.lineHeight.default};
33
- font-weight: ${theme.default.fontWeight.medium};
34
- color: ${({ isChecked }) => isChecked ? theme.default.color.default.white : theme.default.color.default.black};
35
- border: 2px solid transparent;
36
- padding: 2px ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2.5)};
37
68
  text-align: center;
69
+ transition: all 0.2s ease-in-out;
70
+
71
+ ${({ isChecked, isDisabled, isDefaultButtonStyle }) => isDefaultButtonStyle
72
+ ? getDefaultButtonStyles({ isChecked, isDisabled })
73
+ : getStandardPillStyles({ isChecked, isDisabled })}
38
74
 
39
75
  ${({ isDisabled, as }) => getCursor({ isDisabled, as })}
40
- ${({ isChecked, isDisabled }) => getBackgroundColor({ isChecked, isDisabled })}
41
76
 
42
77
  &:focus-within, *:focus > & {
43
- box-shadow: 0px 0px 0px 2px ${theme.default.color.focus.dark};
44
- border: 2px solid ${theme.default.color.focus.light};
78
+ outline: none;
79
+ box-shadow: 0px 0px 0px 2px ${theme.default.color.focus.light},
80
+ 0px 0px 0px 4px ${theme.default.color.focus.dark};
45
81
  }
46
82
 
47
83
  ${({ position }) => (position === 'right' || position === 'middle') &&
@@ -81,7 +117,7 @@ const Input = styled__default.default.input `
81
117
  `;
82
118
  const Pill = (_a) => {
83
119
  var { type = 'none', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["type", 'data-testid']);
84
- return (React__default.default.createElement(Label, { as: type === 'none' ? 'div' : undefined, position: props.position, isChecked: props.isChecked || props.isDefaultChecked, isDisabled: props.isDisabled, className: props.className, "data-testid": dataTestId },
120
+ return (React__default.default.createElement(Label, { as: type === 'none' ? 'div' : undefined, position: props.position, isChecked: props.isChecked || props.isDefaultChecked, isDisabled: props.isDisabled, className: props.className, "data-testid": dataTestId, isDefaultButtonStyle: props.isDefaultButtonStyle },
85
121
  props.children,
86
122
  type !== 'none' && (React__default.default.createElement(Input, { id: props.id, name: props.name, type: type, role: type, defaultChecked: props.isDefaultChecked, checked: props.isChecked, "aria-checked": props.isChecked || props.isDefaultChecked, value: props.value, onChange: props.onChange, disabled: props.isDisabled, readOnly: !props.onChange }))));
87
123
  };
@@ -37,6 +37,6 @@ export interface Props {
37
37
  /**
38
38
  * @visibleName Priority NavigationItem
39
39
  */
40
- declare const PriorityNavigationItem: ({ "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
40
+ declare const PriorityNavigationItem: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLLIElement>>;
41
41
  /** @component */
42
42
  export default PriorityNavigationItem;
@@ -21,10 +21,7 @@ const Element = styled.default.li `
21
21
  padding: 0.75rem 1.25rem;
22
22
  flex-shrink: 0;
23
23
 
24
- ${({ onClick }) => onClick &&
25
- `
26
- cursor: pointer;
27
- `};
24
+ ${({ onClick }) => onClick && `cursor: pointer;`}
28
25
 
29
26
  &:focus-within {
30
27
  & > *:not(a, span.dnasg-icon) {
@@ -45,6 +42,7 @@ const Element = styled.default.li `
45
42
 
46
43
  & > a {
47
44
  text-decoration: none;
45
+
48
46
  &:focus-visible {
49
47
  border-radius: ${theme.default.radius.s};
50
48
  border: 2px solid ${theme.default.color.focus.light};
@@ -56,7 +54,7 @@ const Element = styled.default.li `
56
54
  & > * {
57
55
  display: block;
58
56
  color: ${({ isActive }) => (isActive ? theme.default.color.text.pink : theme.default.color.text.black)};
59
- ${({ isActive }) => isActive && `font-weight: ${theme.default.fontWeight.bold}`};
57
+ ${({ isActive }) => isActive && `font-weight: ${theme.default.fontWeight.bold};`}
60
58
  border: 2px solid transparent;
61
59
 
62
60
  &:hover {
@@ -68,9 +66,10 @@ const Element = styled.default.li `
68
66
  /**
69
67
  * @visibleName Priority NavigationItem
70
68
  */
71
- const PriorityNavigationItem = (_a) => {
69
+ const PriorityNavigationItem = React__default.default.forwardRef((_a, ref) => {
72
70
  var { 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ['data-testid']);
73
- return (React__default.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));
74
- };
71
+ return (React__default.default.createElement(Element, { id: props.id, ref: ref, onClick: props.onClick, onKeyDown: props.onKeyDown, isActive: props.isActive, className: props.className, "data-testid": dataTestId }, props.children));
72
+ });
73
+ PriorityNavigationItem.displayName = 'PriorityNavigationItem';
75
74
 
76
75
  exports.default = PriorityNavigationItem;