@helsenorge/designsystem-react 11.0.0 → 11.1.0-alpha.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/CHANGELOG.md +1502 -873
- package/PopOver.js +3589 -141
- package/PopOver.js.map +1 -1
- package/components/Dropdown/index.js +3 -1
- package/components/Dropdown/index.js.map +1 -1
- package/components/HelpBubble/HelpBubble.d.ts +7 -9
- package/components/HelpBubble/index.js +47 -3
- package/components/HelpBubble/index.js.map +1 -1
- package/components/HelpBubble/styles.module.scss +5 -7
- package/components/HelpBubble/styles.module.scss.d.ts +0 -1
- package/components/HelpPanel/styles.module.scss +3 -2
- package/components/HelpTooltip/index.js +2 -2
- package/components/HelpTooltip/index.js.map +1 -1
- package/components/HighlightPanel/styles.module.scss +1 -0
- package/components/Modal/Modal.d.ts +2 -0
- package/components/Modal/index.js +5 -3
- package/components/Modal/index.js.map +1 -1
- package/components/Modal/styles.module.scss +2 -4
- package/components/PopMenu/index.js +10 -21
- package/components/PopMenu/index.js.map +1 -1
- package/components/PopMenu/styles.module.scss +9 -10
- package/components/PopMenu/styles.module.scss.d.ts +0 -1
- package/components/PopOver/PopOver.d.ts +9 -5
- package/components/PopOver/index.js +3 -3
- package/components/PopOver/styles.module.scss +11 -53
- package/components/PopOver/styles.module.scss.d.ts +0 -5
- package/designsystem-react.css +7 -1
- package/package.json +1 -1
- package/resources/HN.Designsystem.Dropdown.nb-NO.json.d.ts +2 -1
- package/scss/_font-mixins.scss +22 -0
- package/scss/supernova/index.css +4 -3
- package/scss/supernova/styles/colors.css +7 -1
- package/scss/supernova/styles/spacers.css +24 -0
- package/scss/supernova/styles/typography.css +111 -0
- package/scss/typography.module.scss +8 -0
- package/scss/typography.module.scss.d.ts +2 -0
- package/scss/typography.stories.tsx +8 -0
- package/HelpBubble.js +0 -78
- package/HelpBubble.js.map +0 -1
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { Placement } from '@floating-ui/react';
|
|
2
3
|
export declare enum PopOverVariant {
|
|
3
4
|
positionautomatic = "positionautomatic",
|
|
4
5
|
positionbelow = "positionbelow",
|
|
5
6
|
positionabove = "positionabove"
|
|
6
7
|
}
|
|
7
|
-
export type PopOverRole = 'tooltip';
|
|
8
|
+
export type PopOverRole = 'dialog' | 'tooltip';
|
|
9
|
+
export type PopOverPlacement = Placement;
|
|
8
10
|
export interface PopOverProps {
|
|
9
11
|
/** Id of the PopOver */
|
|
10
12
|
id?: string;
|
|
11
|
-
/** Content shown inside PopOver.
|
|
13
|
+
/** Content shown inside PopOver. */
|
|
12
14
|
children: React.ReactNode;
|
|
13
15
|
/** Ref for the element the PopOver is placed upon */
|
|
14
16
|
controllerRef: React.RefObject<HTMLElement | SVGSVGElement>;
|
|
15
17
|
/** Ref for the element the PopOver is placed upon */
|
|
16
18
|
popOverRef?: React.RefObject<HTMLDivElement>;
|
|
17
|
-
/** Show the popover. Only applies when role=tooltip. Default: false. */
|
|
19
|
+
/** @deprecated Show the popover. Only applies when role=tooltip. Default: false. */
|
|
18
20
|
show?: boolean;
|
|
19
21
|
/** Adds custom classes to the element. */
|
|
20
22
|
className?: string;
|
|
21
|
-
/** Adds custom classes to the arrow element. */
|
|
23
|
+
/** @deprecated Adds custom classes to the arrow element. */
|
|
22
24
|
arrowClassName?: string;
|
|
23
|
-
/** Determines the placement of the popover. Default: automatic positioning. */
|
|
25
|
+
/** @deprecated Determines the placement of the popover. Default: automatic positioning. */
|
|
24
26
|
variant?: keyof typeof PopOverVariant;
|
|
27
|
+
/** Sets the placement of the popover relative to the trigger. */
|
|
28
|
+
placement?: PopOverPlacement;
|
|
25
29
|
/** Sets role of the PopOver element */
|
|
26
30
|
role?: PopOverRole;
|
|
27
31
|
/** Sets the data-testid attribute. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { P as PopOver } from "../../PopOver.js";
|
|
2
|
+
import { a } from "../../PopOver.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
4
|
+
a as PopOverVariant,
|
|
5
5
|
PopOver as default
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,63 +1,21 @@
|
|
|
1
1
|
@use 'sass:map';
|
|
2
2
|
@use '../../scss/spacers' as spacers;
|
|
3
|
-
@use '../../scss/
|
|
4
|
-
@
|
|
5
|
-
@
|
|
3
|
+
@use '../../scss/font-mixins' as fonts;
|
|
4
|
+
@import '../../scss/supernova/styles/colors.css';
|
|
5
|
+
@import '../../scss/supernova/styles/spacers.css';
|
|
6
6
|
|
|
7
7
|
.popover {
|
|
8
8
|
$popover: &;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
align-items: flex-start !important;
|
|
13
|
-
max-width: 23.3125rem;
|
|
10
|
+
width: max-content;
|
|
11
|
+
max-width: min(23.3125rem, 100vw);
|
|
14
12
|
text-align: start;
|
|
15
|
-
|
|
16
|
-
font-size: font-settings.$font-size-sm;
|
|
17
|
-
line-height: font-settings.$lineheight-size-sm;
|
|
18
|
-
background-color: palette.$white;
|
|
13
|
+
background-color: var(--core-color-white);
|
|
19
14
|
z-index: 3;
|
|
20
|
-
|
|
21
|
-
border:
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
border: 1px solid var(--color-base-border-onlight);
|
|
16
|
+
border-radius: 4px;
|
|
17
|
+
filter: drop-shadow(0 4px 16px rgba(0 0 0 / 30%));
|
|
18
|
+
padding: var(--core-space-s);
|
|
24
19
|
|
|
25
|
-
@
|
|
26
|
-
font-size: font-settings.$font-size-md;
|
|
27
|
-
line-height: font-settings.$lineheight-size-md;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
&--visible {
|
|
31
|
-
visibility: visible;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&__arrow {
|
|
35
|
-
--drop-shadow-color: #{palette.$plum600};
|
|
36
|
-
|
|
37
|
-
width: 0;
|
|
38
|
-
height: 0;
|
|
39
|
-
position: fixed;
|
|
40
|
-
border-style: solid;
|
|
41
|
-
border-color: transparent;
|
|
42
|
-
z-index: 3;
|
|
43
|
-
visibility: hidden;
|
|
44
|
-
|
|
45
|
-
&--over {
|
|
46
|
-
border-width: 0.625rem;
|
|
47
|
-
border-bottom-color: palette.$white;
|
|
48
|
-
filter: drop-shadow(var(--drop-shadow-color) 0 0.125rem 0.375rem 0.125rem);
|
|
49
|
-
filter: drop-shadow(0 -0.185rem 0 var(--drop-shadow-color));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
&--under {
|
|
53
|
-
border-width: 0.625rem;
|
|
54
|
-
border-top-color: palette.$white;
|
|
55
|
-
filter: drop-shadow(var(--drop-shadow-color) 0 0.125rem 0.375rem 0.125rem);
|
|
56
|
-
filter: drop-shadow(0 0.2rem 0 var(--drop-shadow-color));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
&--visible {
|
|
60
|
-
visibility: visible;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
20
|
+
@include fonts.help-text;
|
|
63
21
|
}
|
package/designsystem-react.css
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/* stylelint-disable color-hex-length */
|
|
2
|
+
/* stylelint-disable comment-empty-line-before */
|
|
3
|
+
/* stylelint-disable scss/operator-no-unspaced */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This file was generated automatically by Supernova.io and should not be changed manually.
|
|
7
|
+
* To modify the format or content of this file, please contact your design system team.
|
|
8
|
+
*/
|
|
2
9
|
|
|
3
|
-
/* This file was generated by Supernova and should not be changed manually */
|
|
4
10
|
:root {
|
|
5
11
|
--core-color-black: #000000;
|
|
6
12
|
--core-color-white: #ffffff;
|
package/package.json
CHANGED
package/scss/_font-mixins.scss
CHANGED
|
@@ -238,3 +238,25 @@
|
|
|
238
238
|
line-height: 1.625rem;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
+
|
|
242
|
+
@mixin help-text {
|
|
243
|
+
font-size: 1rem;
|
|
244
|
+
line-height: 1.5rem;
|
|
245
|
+
font-weight: 400;
|
|
246
|
+
|
|
247
|
+
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
248
|
+
font-size: 1.125rem;
|
|
249
|
+
line-height: 1.575rem;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@mixin help-trigger-text {
|
|
254
|
+
font-size: 1rem;
|
|
255
|
+
line-height: 1.2rem;
|
|
256
|
+
font-weight: 600;
|
|
257
|
+
|
|
258
|
+
@media (min-width: map.get(breakpoints.$grid-breakpoints, md)) {
|
|
259
|
+
font-size: 1.125rem;
|
|
260
|
+
line-height: 1.463rem;
|
|
261
|
+
}
|
|
262
|
+
}
|
package/scss/supernova/index.css
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
/*
|
|
2
|
-
@import
|
|
3
|
-
@import
|
|
1
|
+
/* Base tokens */
|
|
2
|
+
@import './styles/spacers.css';
|
|
3
|
+
@import './styles/colors.css';
|
|
4
|
+
@import './styles/typography.css';
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/* stylelint-disable color-hex-length */
|
|
2
|
+
/* stylelint-disable comment-empty-line-before */
|
|
3
|
+
/* stylelint-disable scss/operator-no-unspaced */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This file was generated automatically by Supernova.io and should not be changed manually.
|
|
7
|
+
* To modify the format or content of this file, please contact your design system team.
|
|
8
|
+
*/
|
|
2
9
|
|
|
3
|
-
/* This file was generated by Supernova and should not be changed manually */
|
|
4
10
|
:root {
|
|
5
11
|
--core-color-black: #000000;
|
|
6
12
|
--core-color-white: #ffffff;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* stylelint-disable color-hex-length */
|
|
2
|
+
/* stylelint-disable comment-empty-line-before */
|
|
3
|
+
/* stylelint-disable scss/operator-no-unspaced */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This file was generated automatically by Supernova.io and should not be changed manually.
|
|
7
|
+
* To modify the format or content of this file, please contact your design system team.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
:root {
|
|
11
|
+
--core-space-4xs: 0.125rem;
|
|
12
|
+
--core-space-3xs: 0.25rem;
|
|
13
|
+
--core-space-2xs: 0.5rem;
|
|
14
|
+
--core-space-xs: 0.75rem;
|
|
15
|
+
--core-space-s: 1rem;
|
|
16
|
+
--core-space-m: 1.5rem;
|
|
17
|
+
--core-space-l: 2rem;
|
|
18
|
+
--core-space-xl: 3rem;
|
|
19
|
+
--core-space-2xl: 4rem;
|
|
20
|
+
--core-space-3xl: 5rem;
|
|
21
|
+
--core-space-4xl: 6rem;
|
|
22
|
+
--core-space-5xl: 7rem;
|
|
23
|
+
--core-space-6xl: 8rem;
|
|
24
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* stylelint-disable color-hex-length */
|
|
2
|
+
/* stylelint-disable comment-empty-line-before */
|
|
3
|
+
/* stylelint-disable scss/operator-no-unspaced */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This file was generated automatically by Supernova.io and should not be changed manually.
|
|
7
|
+
* To modify the format or content of this file, please contact your design system team.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
:root {
|
|
11
|
+
|
|
12
|
+
/* Hovedtittel H1 */
|
|
13
|
+
--desktop-h1-title1: 600 3rem/120% "Source Sans Pro";
|
|
14
|
+
|
|
15
|
+
/* Sekundærtittel H2 */
|
|
16
|
+
--desktop-h2-title2: 600 2rem/120% "Source Sans Pro";
|
|
17
|
+
|
|
18
|
+
/* Tertiærtittel H3 */
|
|
19
|
+
--desktop-h3-title3: 600 1.625rem/120% "Source Sans Pro";
|
|
20
|
+
--desktop-h4-title4: 600 1.375rem/130% "Source Sans Pro";
|
|
21
|
+
--desktop-h5-title5: 700 1.125rem/140% "Source Sans Pro";
|
|
22
|
+
--desktop-preamble: 400 1.5rem/130% "Source Sans Pro";
|
|
23
|
+
--desktop-legend: 600 1.5rem/130% "Source Sans Pro";
|
|
24
|
+
--desktop-label: 600 1.25rem/130% "Source Sans Pro";
|
|
25
|
+
--desktop-body: 400 1.25rem/150% "Source Sans Pro";
|
|
26
|
+
|
|
27
|
+
/* Display of condensed textual data, such as metadata or information that is useful, but perhaps not essential for the use of a service. */
|
|
28
|
+
--desktop-compact-data: 400 1.125rem/140% "Source Sans Pro";
|
|
29
|
+
|
|
30
|
+
/* Tekst i tabellceller. Mer kompakt enn brødtekst (body) */
|
|
31
|
+
--desktop-tablecell: 400 1.125rem/130% "Source Sans Pro";
|
|
32
|
+
--desktop-body-strong: 600 1.25rem/150% "Source Sans Pro";
|
|
33
|
+
|
|
34
|
+
/* Text inside input-fields, textarea fields and numeric steppers, etc. Not to be used as the Label for Radiogroup or Checkbox - use Label. */
|
|
35
|
+
--desktop-form-input: 400 1.25rem/140% "Source Sans Pro";
|
|
36
|
+
|
|
37
|
+
/* Bildetekst - plasseres nedenfor bilde eller figur */
|
|
38
|
+
--desktop-image-caption: 400 1rem/150% "Source Sans Pro";
|
|
39
|
+
|
|
40
|
+
/* Supply copyright information for images */
|
|
41
|
+
--desktop-image-credit: 400 0.75rem/130% "Source Sans Pro";
|
|
42
|
+
|
|
43
|
+
/* Vis status/tidskoder - lav linjehøyde for kompakt visning */
|
|
44
|
+
--desktop-status-time-stamp-time: 400 1.125rem/110% "Source Sans Pro";
|
|
45
|
+
|
|
46
|
+
/* Hovedtittel H1 */
|
|
47
|
+
--mobile-h1-title1: 600 2rem/120% "Source Sans Pro";
|
|
48
|
+
|
|
49
|
+
/* Sekundærtittel H2 */
|
|
50
|
+
--mobile-h2-title2: 600 1.625rem/120% "Source Sans Pro";
|
|
51
|
+
|
|
52
|
+
/* Tertiærtittel H3 */
|
|
53
|
+
--mobile-h3-title3: 600 1.375rem/136% "Source Sans Pro";
|
|
54
|
+
--mobile-h4-title4: 600 1.25rem/130% "Source Sans Pro";
|
|
55
|
+
--mobile-preamble: 400 1.25rem/130% "Source Sans Pro";
|
|
56
|
+
--mobile-legend: 600 1.125rem/130% "Source Sans Pro";
|
|
57
|
+
--mobile-label: 600 1.125rem/120% "Source Sans Pro";
|
|
58
|
+
--mobile-body: 400 1.125rem/150% "Source Sans Pro";
|
|
59
|
+
|
|
60
|
+
/* Tekst i tabellceller. Mer kompakt enn brødtekst (body) */
|
|
61
|
+
--mobile-tablecell: 400 1.125rem/128% "Source Sans Pro";
|
|
62
|
+
|
|
63
|
+
/* Text in Input and Textarea - widgets */
|
|
64
|
+
--mobile-form-input: 400 1.125rem/150% "Source Sans Pro";
|
|
65
|
+
--mobile-image-caption: 400 1rem/150% "Source Sans Pro";
|
|
66
|
+
--mobile-image-credit: 400 0.75rem/133% "Source Sans Pro";
|
|
67
|
+
|
|
68
|
+
/* Vis status/tidskoder - lav linjehøyde for kompakt visning */
|
|
69
|
+
--mobile-status-time-stamp-time: 400 1rem/110% "Source Sans Pro";
|
|
70
|
+
--mobile-h5-title5: 700 1rem/140% "Source Sans Pro";
|
|
71
|
+
--desktop-h6-title6: 700 1.125rem/140% "Source Sans Pro";
|
|
72
|
+
--desktop-label-subdued: 400 1.25rem/130% "Source Sans Pro";
|
|
73
|
+
--desktop-sublabel: 600 1.125rem/130% "Source Sans 3";
|
|
74
|
+
--desktop-sublabel-subdued: 400 1.125rem/130% "Source Sans 3";
|
|
75
|
+
--mobile-h6-title6: 700 1rem/140% "Source Sans Pro";
|
|
76
|
+
--mobile-label-subdued: 400 1.125rem/120% "Source Sans Pro";
|
|
77
|
+
--mobile-sublabel: 600 1rem/120% "Source Sans 3";
|
|
78
|
+
|
|
79
|
+
/* <label> */
|
|
80
|
+
--mobile-sublabel-subdued: 400 1rem/120% "Source Sans 3";
|
|
81
|
+
--mobile-body-strong: 600 1.125rem/150% "Source Sans Pro";
|
|
82
|
+
--mobile-compact-data: 400 1rem/150% "Source Sans Pro";
|
|
83
|
+
|
|
84
|
+
/* Name-value pairs as rendered by an HTML <DT>-tag */
|
|
85
|
+
--desktop-definitionlist-type: 600 1.25rem/130% "Source Sans Pro";
|
|
86
|
+
|
|
87
|
+
/* Data-value in Name-Value-pairs as rendered by a <DD>-tag (definition-data) */
|
|
88
|
+
--desktop-definition-list-data: 400 1.25rem/130% "Source Sans Pro";
|
|
89
|
+
|
|
90
|
+
/* Use for inherent "chunking" of text in hmtl lists <LI>, ie. bullet-lists and ordered lists. */
|
|
91
|
+
--desktop-textlist: 400 1.25rem/130% "Source Sans Pro";
|
|
92
|
+
|
|
93
|
+
/* Use for the Name part in name-value pairs, the equivalent of html <DT> */
|
|
94
|
+
--mobile-definitionlist-type: 600 1.125rem/120% "Source Sans Pro";
|
|
95
|
+
--mobile-definitionlist-data: 400 1.125rem/120% "Source Sans Pro";
|
|
96
|
+
|
|
97
|
+
/* Renders clumping in ordinary clumps */
|
|
98
|
+
--mobile-textlist: 400 1.125rem/120% "Source Sans Pro";
|
|
99
|
+
|
|
100
|
+
/* For use as body text in help components */
|
|
101
|
+
--desktop-help-text: 400 1.125rem/140% "Source Sans Pro";
|
|
102
|
+
|
|
103
|
+
/* For use in Help trigger components */
|
|
104
|
+
--desktop-help-trigger-text: 600 1.125rem/130% "Source Sans 3";
|
|
105
|
+
|
|
106
|
+
/* For use as body text in help components */
|
|
107
|
+
--mobile-help-text: 400 1rem/150% "Source Sans Pro";
|
|
108
|
+
|
|
109
|
+
/* For use in Help trigger components */
|
|
110
|
+
--mobile-help-trigger-text: 600 1rem/120% "Source Sans 3";
|
|
111
|
+
}
|
|
@@ -132,6 +132,14 @@ import designsystemtypography from './scss/typography.scss'
|
|
|
132
132
|
@include fonts.definition-list-data;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
.help-text {
|
|
136
|
+
@include fonts.help-text;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.help-trigger-text {
|
|
140
|
+
@include fonts.help-trigger-text;
|
|
141
|
+
}
|
|
142
|
+
|
|
135
143
|
.anchorlink-wrapper {
|
|
136
144
|
a {
|
|
137
145
|
display: inline;
|
|
@@ -121,6 +121,14 @@ export const DefinitionListData: Story = {
|
|
|
121
121
|
render: args => <div className={designsystemtypography['definition-list-data']}>{args.tekst}</div>,
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
+
export const HelpText: Story = {
|
|
125
|
+
render: args => <div className={designsystemtypography['help-text']}>{args.tekst}</div>,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const HelpTriggerText: Story = {
|
|
129
|
+
render: args => <div className={designsystemtypography['help-trigger-text']}>{args.tekst}</div>,
|
|
130
|
+
};
|
|
131
|
+
|
|
124
132
|
export const AnchorlinkWrapper: Story = {
|
|
125
133
|
render: args => (
|
|
126
134
|
<div className={designsystemtypography['anchorlink-wrapper']}>
|
package/HelpBubble.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React__default from "react";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
import { AnalyticsId } from "./constants.js";
|
|
5
|
-
import { A as AnchorLink } from "./AnchorLink.js";
|
|
6
|
-
import { C as Close } from "./Close.js";
|
|
7
|
-
import { P as PopOverVariant, a as PopOver } from "./PopOver.js";
|
|
8
|
-
import styles from "./components/HelpBubble/styles.module.scss";
|
|
9
|
-
const HelpBubbleVariant = PopOverVariant;
|
|
10
|
-
const HelpBubble = React__default.forwardRef((props, ref) => {
|
|
11
|
-
const {
|
|
12
|
-
children,
|
|
13
|
-
className = "",
|
|
14
|
-
noCloseButton,
|
|
15
|
-
linkText = "Mer hjelp",
|
|
16
|
-
linkUrl,
|
|
17
|
-
linkTarget,
|
|
18
|
-
onLinkClick,
|
|
19
|
-
onClose,
|
|
20
|
-
closeAriaLabel,
|
|
21
|
-
// Props passed on to PopOver
|
|
22
|
-
showBubble,
|
|
23
|
-
helpBubbleId,
|
|
24
|
-
variant,
|
|
25
|
-
controllerRef,
|
|
26
|
-
role,
|
|
27
|
-
testId
|
|
28
|
-
} = props;
|
|
29
|
-
const isTooltip = role === "tooltip";
|
|
30
|
-
if (!showBubble && !isTooltip) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const helpBubbleClasses = classNames(styles.helpbubble, className);
|
|
34
|
-
const contentClasses = classNames(styles.helpbubble__content, {
|
|
35
|
-
[styles["helpbubble__content--close"]]: !noCloseButton && !isTooltip
|
|
36
|
-
});
|
|
37
|
-
const renderLink = () => {
|
|
38
|
-
if (isTooltip) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (onLinkClick && linkText) {
|
|
42
|
-
return /* @__PURE__ */ jsx("button", { className: styles.helpbubble__link, onClick: onLinkClick, type: "button", children: linkText });
|
|
43
|
-
} else if (linkUrl && linkText) {
|
|
44
|
-
return /* @__PURE__ */ jsx(AnchorLink, { href: linkUrl, target: linkTarget, children: linkText });
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const renderCloseButton = () => {
|
|
48
|
-
if (noCloseButton || isTooltip) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
return /* @__PURE__ */ jsx("div", { className: styles.helpbubble__close, children: /* @__PURE__ */ jsx(Close, { small: true, onClick: onClose, ariaLabel: closeAriaLabel }) });
|
|
52
|
-
};
|
|
53
|
-
return /* @__PURE__ */ jsx(
|
|
54
|
-
PopOver,
|
|
55
|
-
{
|
|
56
|
-
id: helpBubbleId,
|
|
57
|
-
variant,
|
|
58
|
-
controllerRef,
|
|
59
|
-
role,
|
|
60
|
-
ref,
|
|
61
|
-
show: isTooltip && showBubble,
|
|
62
|
-
testId,
|
|
63
|
-
children: /* @__PURE__ */ jsxs("div", { className: helpBubbleClasses, "data-analyticsid": AnalyticsId.HelpBubble, children: [
|
|
64
|
-
renderCloseButton(),
|
|
65
|
-
/* @__PURE__ */ jsxs("div", { className: contentClasses, children: [
|
|
66
|
-
children,
|
|
67
|
-
renderLink()
|
|
68
|
-
] })
|
|
69
|
-
] })
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
HelpBubble.displayName = "HelpBubble";
|
|
74
|
-
export {
|
|
75
|
-
HelpBubble as H,
|
|
76
|
-
HelpBubbleVariant as a
|
|
77
|
-
};
|
|
78
|
-
//# sourceMappingURL=HelpBubble.js.map
|
package/HelpBubble.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HelpBubble.js","sources":["../src/components/HelpBubble/HelpBubble.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport AnchorLink, { AnchorLinkTargets } from '../AnchorLink';\nimport Close from '../Close';\nimport PopOver, { PopOverProps, PopOverVariant } from '../PopOver';\n\nimport styles from './styles.module.scss';\n\nexport const HelpBubbleVariant = PopOverVariant;\n\ntype HelpBubbleRole = 'tooltip';\n\nexport interface HelpBubbleProps extends Pick<PopOverProps, 'children' | 'variant' | 'controllerRef' | 'role'> {\n /** Id of the HelpBubble */\n helpBubbleId?: string;\n /** Content shown inside HelpBubble. Note that if role=\"tooltip\", you must not include interactive/focusable elements. */\n children: React.ReactNode;\n /** Ref for the element the HelpBubble is placed upon */\n controllerRef: React.RefObject<HTMLElement | SVGSVGElement>;\n /** Adds custom classes to the element. */\n className?: string;\n /** Determines the placement of the helpbubble. Default: automatic positioning. */\n variant?: keyof typeof HelpBubbleVariant;\n /** Show the bubble. Default: false. */\n showBubble?: boolean;\n /** Hide the close button in the bubble. Close button is never rendered if role=\"tooltip\". */\n noCloseButton?: boolean;\n /** Visible text on the link. Link is never rendered if role=\"tooltip\". */\n linkText?: string;\n /** Url the link leads to */\n linkUrl?: string;\n /** Sets the target type of the link. _blank adds an arrow icon at the end of the link */\n linkTarget?: AnchorLinkTargets;\n /** Function is called when link is clicked */\n onLinkClick?: () => void;\n /** Function is called when user clicks the button */\n onClose?: () => void;\n /** aria-label to be passed onto Close */\n closeAriaLabel?: string;\n /** Sets role of the HelpBubble element. If set to \"tooltip\", */\n role?: HelpBubbleRole;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst HelpBubble = React.forwardRef<HTMLDivElement | SVGSVGElement, HelpBubbleProps>((props, ref) => {\n const {\n children,\n className = '',\n noCloseButton,\n linkText = 'Mer hjelp',\n linkUrl,\n linkTarget,\n onLinkClick,\n onClose,\n closeAriaLabel,\n // Props passed on to PopOver\n showBubble,\n helpBubbleId,\n variant,\n controllerRef,\n role,\n testId,\n } = props;\n\n const isTooltip = role === 'tooltip';\n\n if (!showBubble && !isTooltip) {\n return null;\n }\n\n const helpBubbleClasses = classNames(styles.helpbubble, className);\n\n const contentClasses = classNames(styles.helpbubble__content, {\n [styles['helpbubble__content--close']]: !noCloseButton && !isTooltip,\n });\n\n const renderLink = (): JSX.Element | undefined => {\n // Det er ikke tillatt med interaktive/fokuserbare elementer i role=\"tooltip\"\n if (isTooltip) {\n return;\n }\n if (onLinkClick && linkText) {\n return (\n <button className={styles.helpbubble__link} onClick={onLinkClick} type=\"button\">\n {linkText}\n </button>\n );\n } else if (linkUrl && linkText) {\n return (\n <AnchorLink href={linkUrl} target={linkTarget}>\n {linkText}\n </AnchorLink>\n );\n }\n };\n\n const renderCloseButton = (): JSX.Element | undefined => {\n if (noCloseButton || isTooltip) {\n return;\n }\n return (\n <div className={styles.helpbubble__close}>\n <Close small onClick={onClose} ariaLabel={closeAriaLabel} />\n </div>\n );\n };\n\n return (\n <PopOver\n id={helpBubbleId}\n variant={variant}\n controllerRef={controllerRef}\n role={role}\n ref={ref}\n show={isTooltip && showBubble}\n testId={testId}\n >\n <div className={helpBubbleClasses} data-analyticsid={AnalyticsId.HelpBubble}>\n {renderCloseButton()}\n <div className={contentClasses}>\n {children}\n {renderLink()}\n </div>\n </div>\n </PopOver>\n );\n});\n\nHelpBubble.displayName = 'HelpBubble';\n\nexport default HelpBubble;\n"],"names":["React"],"mappings":";;;;;;;;AAWO,MAAM,oBAAoB;AAqCjC,MAAM,aAAaA,eAAM,WAA4D,CAAC,OAAO,QAAQ;AAC7F,QAAA;AAAA,IACJ;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AAEJ,QAAM,YAAY,SAAS;AAEvB,MAAA,CAAC,cAAc,CAAC,WAAW;AACtB,WAAA;AAAA,EAAA;AAGT,QAAM,oBAAoB,WAAW,OAAO,YAAY,SAAS;AAE3D,QAAA,iBAAiB,WAAW,OAAO,qBAAqB;AAAA,IAC5D,CAAC,OAAO,4BAA4B,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAAA,EAAA,CAC5D;AAED,QAAM,aAAa,MAA+B;AAEhD,QAAI,WAAW;AACb;AAAA,IAAA;AAEF,QAAI,eAAe,UAAU;AAEzB,aAAA,oBAAC,YAAO,WAAW,OAAO,kBAAkB,SAAS,aAAa,MAAK,UACpE,UACH,SAAA,CAAA;AAAA,IAAA,WAEO,WAAW,UAAU;AAC9B,iCACG,YAAW,EAAA,MAAM,SAAS,QAAQ,YAChC,UACH,UAAA;AAAA,IAAA;AAAA,EAGN;AAEA,QAAM,oBAAoB,MAA+B;AACvD,QAAI,iBAAiB,WAAW;AAC9B;AAAA,IAAA;AAEF,WACG,oBAAA,OAAA,EAAI,WAAW,OAAO,mBACrB,UAAA,oBAAC,OAAM,EAAA,OAAK,MAAC,SAAS,SAAS,WAAW,eAAgB,CAAA,GAC5D;AAAA,EAEJ;AAGE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,aAAa;AAAA,MACnB;AAAA,MAEA,+BAAC,OAAI,EAAA,WAAW,mBAAmB,oBAAkB,YAAY,YAC9D,UAAA;AAAA,QAAkB,kBAAA;AAAA,QACnB,qBAAC,OAAI,EAAA,WAAW,gBACb,UAAA;AAAA,UAAA;AAAA,UACA,WAAW;AAAA,QAAA,EACd,CAAA;AAAA,MAAA,EACF,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ,CAAC;AAED,WAAW,cAAc;"}
|