@helsenorge/designsystem-react 11.1.0 → 11.2.0-beta.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/Button.js +8 -6
- package/Button.js.map +1 -1
- package/CHANGELOG.md +1496 -881
- package/PopOver.js +3589 -141
- package/PopOver.js.map +1 -1
- package/components/Drawer/Drawer.d.ts +0 -2
- package/components/Drawer/index.js +5 -3
- package/components/Drawer/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/PopMenu/index.js +15 -24
- 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/package.json +1 -1
- package/scss/_font-mixins.scss +22 -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
- package/hooks/useIsMobileBreakpoint.d.ts +0 -1
- package/hooks/useIsMobileBreakpoint.js +0 -10
- package/hooks/useIsMobileBreakpoint.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/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
|
+
}
|
|
@@ -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;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useIsMobileBreakpoint: () => boolean;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useBreakpoint } from "./useBreakpoint.js";
|
|
2
|
-
import { breakpoints } from "../theme/grid.js";
|
|
3
|
-
const useIsMobileBreakpoint = () => {
|
|
4
|
-
const breakpoint = useBreakpoint();
|
|
5
|
-
return breakpoint < breakpoints.md;
|
|
6
|
-
};
|
|
7
|
-
export {
|
|
8
|
-
useIsMobileBreakpoint
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=useIsMobileBreakpoint.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMobileBreakpoint.js","sources":["../../src/hooks/useIsMobileBreakpoint.ts"],"sourcesContent":["import { useBreakpoint } from './useBreakpoint';\nimport { breakpoints } from '../theme/grid';\n\nexport const useIsMobileBreakpoint = (): boolean => {\n const breakpoint = useBreakpoint();\n return breakpoint < breakpoints.md;\n};\n"],"names":[],"mappings":";;AAGO,MAAM,wBAAwB,MAAe;AAClD,QAAM,aAAa,cAAc;AACjC,SAAO,aAAa,YAAY;AAClC;"}
|