@helsenorge/designsystem-react 8.1.0 → 8.1.1

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 CHANGED
@@ -1,3 +1,22 @@
1
+ ## [8.1.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv8.0.2&targetVersion=GTv8.1.0) (2024-08-23)
2
+
3
+ ### Features
4
+
5
+ - mulig å skru av swiping i tabs ([45aac8f](https://github.com/helsenorge/designsystem/commit/45aac8f7358e77fe85467d826b54c052b01b3086)),
6
+ closes [#330586](https://github.com/helsenorge/designsystem/issues/330586)
7
+
8
+ ### Bug Fixes
9
+
10
+ - table kan brukes i tabs uten problemer med scrolling på mobil
11
+ ([d28a280](https://github.com/helsenorge/designsystem/commit/d28a280d4afe56227a331334348d91aac5be6281)), closes
12
+ [#330555](https://github.com/helsenorge/designsystem/issues/330555)
13
+ - unngå blinking i tabs på mobil når man scroller
14
+ ([2bddf20](https://github.com/helsenorge/designsystem/commit/2bddf2017f1067ba1b17473006b2103de630054e)), closes
15
+ [#330597](https://github.com/helsenorge/designsystem/issues/330597)
16
+ - validationsummary er ikke labelled by ikke-eksisterende element
17
+ ([3ac0b88](https://github.com/helsenorge/designsystem/commit/3ac0b8822820ad47ac635da95b7d7377481f2f33)), closes
18
+ [#328895](https://github.com/helsenorge/designsystem/issues/328895)
19
+
1
20
  ## [8.0.2](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv8.0.1&targetVersion=GTv8.0.2) (2024-08-22)
2
21
 
3
22
  ### Bug Fixes
@@ -7,12 +7,6 @@
7
7
  display: flex;
8
8
  align-items: center;
9
9
  justify-content: center;
10
-
11
- @media (max-width: map.get($grid-breakpoints, sm)) {
12
- height: 2.375rem;
13
- width: 2.375rem;
14
- }
15
-
16
10
  height: 3rem;
17
11
  width: 3rem;
18
12
  padding: 0;
@@ -20,6 +14,11 @@
20
14
  background-color: transparent;
21
15
  cursor: pointer;
22
16
 
17
+ @media (max-width: map.get($grid-breakpoints, sm)) {
18
+ height: 2.375rem;
19
+ width: 2.375rem;
20
+ }
21
+
23
22
  &:hover,
24
23
  &:active {
25
24
  background-color: rgb(88 170 187 / 10%);
@@ -39,12 +39,6 @@
39
39
  position: relative;
40
40
  font-size: $font-size-sm;
41
41
  line-height: $lineheight-size-sm;
42
-
43
- @media (min-width: map.get($grid-breakpoints, md)) {
44
- font-size: $font-size-md;
45
- line-height: $lineheight-size-md;
46
- }
47
-
48
42
  display: flex;
49
43
  cursor: pointer;
50
44
  font-weight: 600;
@@ -58,6 +52,11 @@
58
52
  width: 100%;
59
53
  outline: none;
60
54
 
55
+ @media (min-width: map.get($grid-breakpoints, md)) {
56
+ font-size: $font-size-md;
57
+ line-height: $lineheight-size-md;
58
+ }
59
+
61
60
  &--banana {
62
61
  background-color: $banana100;
63
62
  }
@@ -1,4 +1,4 @@
1
- @import '@helsenorge/designsystem-react/scss/spacers';
1
+ @import '../../scss/spacers';
2
2
 
3
3
  .subtitle {
4
4
  margin: 0;
@@ -0,0 +1,9 @@
1
+ export type Styles = {
2
+ subtitle: string;
3
+ };
4
+
5
+ export type ClassNames = keyof Styles;
6
+
7
+ declare const styles: Styles;
8
+
9
+ export default styles;
@@ -28,11 +28,11 @@
28
28
  }
29
29
 
30
30
  &__legend {
31
- @include legend;
32
-
33
31
  margin-bottom: getSpacer(m);
34
32
  margin-top: 0;
35
33
 
34
+ @include legend;
35
+
36
36
  &--on-dark {
37
37
  color: $white;
38
38
  }
@@ -8,7 +8,9 @@
8
8
  @mixin content-wrapper-with-icon-flex {
9
9
  display: flex;
10
10
  flex-direction: column;
11
+ }
11
12
 
13
+ @mixin content-wrapper-with-icon-flex-responsive {
12
14
  @media (min-width: map.get($grid-breakpoints, md)) {
13
15
  flex-direction: row;
14
16
  }
@@ -113,6 +115,7 @@
113
115
  #{$panel}__content-wrapper {
114
116
  @include content-wrapper-with-icon-flex;
115
117
  @include content-wrapper-with-icon-padding;
118
+ @include content-wrapper-with-icon-flex-responsive;
116
119
 
117
120
  @media (min-width: map.get($grid-breakpoints, lg)) {
118
121
  padding-left: getSpacer(m);
@@ -123,6 +126,7 @@
123
126
  &--has-icon#{&}--large {
124
127
  #{$panel}__col {
125
128
  @include content-wrapper-with-icon-flex;
129
+ @include content-wrapper-with-icon-flex-responsive;
126
130
  }
127
131
  #{$panel}__content-wrapper {
128
132
  @include content-wrapper-with-icon-padding;
@@ -171,6 +175,7 @@
171
175
  &--has-icon#{&}--fluid {
172
176
  @include content-wrapper-with-icon-flex;
173
177
  @include content-wrapper-with-icon-padding;
178
+ @include content-wrapper-with-icon-flex-responsive;
174
179
  }
175
180
 
176
181
  &__icon {
@@ -19,6 +19,8 @@ export interface InputProps extends Pick<React.InputHTMLAttributes<HTMLInputElem
19
19
  icon?: SvgIcon | IconName;
20
20
  /** Places the icon to the right */
21
21
  iconRight?: boolean;
22
+ /** Ref that is placed on the inputContainerRef */
23
+ inputContainerRef?: React.RefObject<HTMLDivElement>;
22
24
  /** Ref that is placed on the inputWrapper */
23
25
  inputWrapperRef?: React.RefObject<HTMLDivElement>;
24
26
  /** Changes the color profile of the input */
@@ -1,21 +1,22 @@
1
- import r, { useRef as K, useState as $, useEffect as xe } from "react";
1
+ import r, { useRef as K, useState as $, useEffect as Ce } from "react";
2
2
  import v from "classnames";
3
- import { FormMode as l, FormSize as Ce, IconSize as B, AnalyticsId as _e, AVERAGE_CHARACTER_WIDTH_PX as ve } from "../../constants.js";
3
+ import { FormMode as l, FormSize as xe, IconSize as B, AnalyticsId as _e, AVERAGE_CHARACTER_WIDTH_PX as ve } from "../../constants.js";
4
4
  import { useBreakpoint as ye, Breakpoint as Ee } from "../../hooks/useBreakpoint.js";
5
5
  import { useUuid as U } from "../../hooks/useUuid.js";
6
6
  import { getColor as F } from "../../theme/currys/color.js";
7
7
  import { getAriaDescribedBy as ke } from "../../utils/accessibility.js";
8
- import { ErrorWrapper as we } from "../ErrorWrapper/ErrorWrapper.js";
9
- import { Icon as Ne } from "../Icon/Icon.js";
10
- import { renderLabel as Ie } from "../Label/Label.js";
11
- import { LazyIcon as Re } from "../LazyIcon/LazyIcon.js";
12
- import We from "../MaxCharacters/MaxCharacters.js";
8
+ import { mergeRefs as we } from "../../utils/refs.js";
9
+ import { ErrorWrapper as Ne } from "../ErrorWrapper/ErrorWrapper.js";
10
+ import { Icon as Ie } from "../Icon/Icon.js";
11
+ import { renderLabel as Re } from "../Label/Label.js";
12
+ import { LazyIcon as We } from "../LazyIcon/LazyIcon.js";
13
+ import Se from "../MaxCharacters/MaxCharacters.js";
13
14
  import t from "../Input/styles.module.scss";
14
- var Se = /* @__PURE__ */ ((e) => (e.text = "text", e.number = "number", e.email = "email", e.password = "password", e.search = "search", e.tel = "tel", e.url = "url", e.date = "date", e.time = "time", e))(Se || {});
15
- const ze = (e, s, p) => {
15
+ var ze = /* @__PURE__ */ ((e) => (e.text = "text", e.number = "number", e.email = "email", e.password = "password", e.search = "search", e.tel = "tel", e.url = "url", e.date = "date", e.time = "time", e))(ze || {});
16
+ const Ae = (e, s, p) => {
16
17
  const i = s ? "1.5rem" : "2rem", f = s ? `${p}px` : "0px";
17
18
  return `calc(${e * ve}px + ${i} + ${f} + 4px)`;
18
- }, Ae = r.forwardRef((e, s) => {
19
+ }, Ve = r.forwardRef((e, s) => {
19
20
  const {
20
21
  className: p,
21
22
  defaultValue: i,
@@ -24,7 +25,7 @@ const ze = (e, s, p) => {
24
25
  name: L,
25
26
  transparent: M = !1,
26
27
  icon: a,
27
- iconRight: b,
28
+ iconRight: g,
28
29
  inputId: P,
29
30
  inputWrapperRef: H,
30
31
  mode: c = l.onwhite,
@@ -48,27 +49,27 @@ const ze = (e, s, p) => {
48
49
  maxCharacters: d,
49
50
  maxText: te,
50
51
  ...ne
51
- } = e, re = ye(), m = K(null), I = U(P), [R, W] = $(i || ""), [ae, oe] = $(void 0), g = K(!1), S = U(G), z = /^[0-9]$/;
52
- xe(() => {
52
+ } = e, re = ye(), m = K(null), I = U(P), [R, W] = $(i || ""), [ae, oe] = $(void 0), b = K(!1), S = U(G), z = /^[0-9]$/;
53
+ Ce(() => {
53
54
  W(i || "");
54
55
  }, [i]);
55
- const ie = c === l.ondark, ce = c === l.onblueberry, le = !!d && R.toString().length > d, x = c === l.oninvalid || !!E || !!q || le, C = O === Ce.large, se = M && c !== l.ondark && !x, ue = v(t["input-wrapper"], p), de = v(t["input-container"], {
56
+ const ie = c === l.ondark, ce = c === l.onblueberry, le = !!d && R.toString().length > d, C = c === l.oninvalid || !!E || !!q || le, x = O === xe.large, se = M && c !== l.ondark && !C, ue = v(t["input-wrapper"], p), de = v(t["input-container"], {
56
57
  [t["input-container--transparent"]]: se,
57
58
  [t["input-container--on-blueberry"]]: ce,
58
59
  [t["input-container--on-dark"]]: ie,
59
- [t["input-container--invalid"]]: x,
60
- [t["input-container--large"]]: C,
60
+ [t["input-container--invalid"]]: C,
61
+ [t["input-container--large"]]: x,
61
62
  [t["input-container--disabled"]]: u,
62
63
  [t["input-container--with-icon"]]: a
63
64
  }), me = v(t["input-container__input"], {
64
- [t["input-container__input--large"]]: C,
65
+ [t["input-container__input--large"]]: x,
65
66
  [t["input-container__input--disabled"]]: u
66
- }), A = u ? F("neutral", 700) : F("black"), _ = re === Ee.xs || !C ? B.XSmall : B.Small, V = () => {
67
+ }), A = u ? F("neutral", 700) : F("black"), _ = re === Ee.xs || !x ? B.XSmall : B.Small, V = () => {
67
68
  if (a)
68
- return typeof a == "string" ? /* @__PURE__ */ r.createElement(Re, { className: t["input-container__input__icon"], color: A, size: _, iconName: a }) : /* @__PURE__ */ r.createElement(Ne, { className: t["input-container__input__icon"], color: A, size: _, svgIcon: a });
69
+ return typeof a == "string" ? /* @__PURE__ */ r.createElement(We, { className: t["input-container__input__icon"], color: A, size: _, iconName: a }) : /* @__PURE__ */ r.createElement(Ie, { className: t["input-container__input__icon"], color: A, size: _, svgIcon: a });
69
70
  }, pe = (n) => {
70
71
  if (m && m.current && a) {
71
- const o = b ? 0 : 1;
72
+ const o = g ? 0 : 1;
72
73
  m.current.children[o].focus(), e.onClick && e.onClick(n);
73
74
  }
74
75
  }, fe = (n) => {
@@ -77,40 +78,51 @@ const ze = (e, s, p) => {
77
78
  }, he = (n) => {
78
79
  if (typeof y > "u" || h !== "number") return n.target.value;
79
80
  const o = Number(n.target.value);
80
- return !ae && !g.current && (o === 1 || o === -1) && (n.target.value = y + ""), n.target.value;
81
- }, be = (n) => {
82
- z.test(n.key) && (g.current = !0), N && N(n);
81
+ return !ae && !b.current && (o === 1 || o === -1) && (n.target.value = y + ""), n.target.value;
83
82
  }, ge = (n) => {
84
- z.test(n.key) && (g.current = !1);
85
- }, D = k ? ze(k, !!a, _) : void 0;
86
- return /* @__PURE__ */ r.createElement(we, { errorText: E, errorTextId: S }, /* @__PURE__ */ r.createElement("div", { "data-testid": j, "data-analyticsid": _e.Input, className: ue, ref: H }, Ie(X, I, c), /* @__PURE__ */ r.createElement("div", { className: t["content-wrapper"] }, /* @__PURE__ */ r.createElement("div", { onClick: pe, ref: m, className: de, style: { maxWidth: D } }, !b && V(), /* @__PURE__ */ r.createElement(
87
- "input",
83
+ z.test(n.key) && (b.current = !0), N && N(n);
84
+ }, be = (n) => {
85
+ z.test(n.key) && (b.current = !1);
86
+ }, D = k ? Ae(k, !!a, _) : void 0;
87
+ return /* @__PURE__ */ r.createElement(Ne, { errorText: E, errorTextId: S }, /* @__PURE__ */ r.createElement("div", { "data-testid": j, "data-analyticsid": _e.Input, className: ue, ref: H }, Re(X, I, c), /* @__PURE__ */ r.createElement("div", { className: t["content-wrapper"] }, /* @__PURE__ */ r.createElement(
88
+ "div",
88
89
  {
89
- onChange: fe,
90
- onKeyDown: be,
91
- onKeyUp: ge,
92
- name: L,
93
- type: h,
94
- defaultValue: i,
95
- id: I,
96
- className: me,
97
- ref: s,
98
- "aria-labelledby": e["aria-labelledby"] ?? void 0,
99
- "aria-describedby": ke(e, S),
100
- "aria-invalid": !!x,
101
- disabled: u,
102
- placeholder: f,
103
- readOnly: J,
104
- autoComplete: Q || "off",
105
- required: Z,
106
- autoFocus: ee,
107
- ...ne
108
- }
109
- ), b && V()), /* @__PURE__ */ r.createElement("div", { className: t["content-wrapper__right-of-input"] }, Y)), d && /* @__PURE__ */ r.createElement(We, { maxCharacters: d, length: R.toString().length, maxText: te, mode: c, maxWidth: D }), T));
90
+ onClick: pe,
91
+ ref: we([m, e.inputContainerRef]),
92
+ className: de,
93
+ style: { maxWidth: D }
94
+ },
95
+ !g && V(),
96
+ /* @__PURE__ */ r.createElement(
97
+ "input",
98
+ {
99
+ onChange: fe,
100
+ onKeyDown: ge,
101
+ onKeyUp: be,
102
+ name: L,
103
+ type: h,
104
+ defaultValue: i,
105
+ id: I,
106
+ className: me,
107
+ ref: s,
108
+ "aria-labelledby": e["aria-labelledby"] ?? void 0,
109
+ "aria-describedby": ke(e, S),
110
+ "aria-invalid": !!C,
111
+ disabled: u,
112
+ placeholder: f,
113
+ readOnly: J,
114
+ autoComplete: Q || "off",
115
+ required: Z,
116
+ autoFocus: ee,
117
+ ...ne
118
+ }
119
+ ),
120
+ g && V()
121
+ ), /* @__PURE__ */ r.createElement("div", { className: t["content-wrapper__right-of-input"] }, Y)), d && /* @__PURE__ */ r.createElement(Se, { maxCharacters: d, length: R.toString().length, maxText: te, mode: c, maxWidth: D }), T));
110
122
  });
111
- Ae.displayName = "Input";
123
+ Ve.displayName = "Input";
112
124
  export {
113
- Se as InputTypes,
114
- Ae as default
125
+ ze as InputTypes,
126
+ Ve as default
115
127
  };
116
128
  //# sourceMappingURL=Input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","sources":["../../../src/components/Input/Input.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport cn from 'classnames';\n\nimport { FormMode, FormSize, AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport ErrorWrapper from '../ErrorWrapper';\nimport Icon, { IconSize, SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport { renderLabel } from '../Label';\nimport LazyIcon from '../LazyIcon';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface InputProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n | 'disabled'\n | 'readOnly'\n | 'autoComplete'\n | 'name'\n | 'placeholder'\n | 'defaultValue'\n | 'required'\n | 'value'\n | 'min'\n | 'max'\n | 'aria-describedby'\n | 'aria-labelledby'\n | 'onBlur'\n | 'onClick'\n | 'onChange'\n | 'onFocus'\n | 'onKeyDown'\n | 'autoFocus'\n > {\n /** The number at which the input field starts when you increment or decrement it */\n baseIncrementValue?: number;\n /** Adds custom classes to the element. */\n className?: string;\n /** HMTL Input type */\n type?: keyof typeof InputTypes;\n /** input id */\n inputId?: string;\n /** Width of input field in characters (approximate) */\n width?: number;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Icon to be displayed next to the input field */\n icon?: SvgIcon | IconName;\n /** Places the icon to the right */\n iconRight?: boolean;\n /** Ref that is placed on the inputWrapper */\n inputWrapperRef?: React.RefObject<HTMLDivElement>;\n /** Changes the color profile of the input */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the input */\n size?: keyof typeof FormSize;\n /** Label of the input */\n label?: React.ReactNode;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Component shown after input */\n afterInputChildren?: React.ReactNode;\n /** Component shown to the right of input */\n rightOfInput?: React.ReactNode;\n /** max character limit in input */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n}\n\nexport enum InputTypes {\n text = 'text',\n number = 'number',\n email = 'email',\n password = 'password',\n search = 'search',\n tel = 'tel',\n url = 'url',\n date = 'date',\n time = 'time',\n}\n\nconst getInputMaxWidth = (characters: number, hasIcon: boolean, iconSize: number): string => {\n const paddingWidth = hasIcon ? '1.5rem' : '2rem';\n const iconWidth = hasIcon ? `${iconSize}px` : '0px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${iconWidth} + ${borderWidth})`;\n};\n\nconst Input = React.forwardRef((props: InputProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n defaultValue,\n placeholder,\n type = InputTypes.text,\n name,\n transparent = false,\n icon,\n iconRight,\n inputId,\n inputWrapperRef,\n mode = FormMode.onwhite,\n size,\n baseIncrementValue,\n label,\n error,\n errorText,\n errorTextId,\n testId,\n disabled,\n readOnly,\n autoComplete = 'off',\n afterInputChildren,\n rightOfInput,\n width,\n required,\n onChange,\n onKeyDown,\n autoFocus,\n maxCharacters,\n maxText,\n ...rest\n } = props;\n const breakpoint = useBreakpoint();\n const inputContainerRef = useRef<HTMLDivElement>(null);\n const inputIdState = useUuid(inputId);\n const [input, setInput] = useState(defaultValue || '');\n const [prevValue, setPrevValue] = useState<string | number | undefined>(undefined);\n const numKeyPressed = useRef<boolean>(false);\n const errorTextUuid = useUuid(errorTextId);\n const numRegex = /^[0-9]$/;\n\n useEffect(() => {\n setInput(defaultValue || '');\n }, [defaultValue]);\n\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && input.toString().length > maxCharacters;\n const onError = mode === FormMode.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n const isLarge = size === FormSize.large;\n const isTransparent = transparent && mode !== FormMode.ondark && !onError;\n\n const inputWrapperClass = cn(styles['input-wrapper'], className);\n\n const inputContainer = cn(styles['input-container'], {\n [styles['input-container--transparent']]: isTransparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--large']]: isLarge,\n [styles['input-container--disabled']]: disabled,\n [styles['input-container--with-icon']]: icon,\n });\n\n const inputClass = cn(styles['input-container__input'], {\n [styles['input-container__input--large']]: isLarge,\n [styles['input-container__input--disabled']]: disabled,\n });\n\n const iconColor = disabled ? getColor('neutral', 700) : getColor('black');\n const iconSize = breakpoint === Breakpoint.xs || !isLarge ? IconSize.XSmall : IconSize.Small;\n\n const renderIcon = (): React.ReactNode => {\n if (!icon) {\n return;\n }\n\n if (typeof icon === 'string') {\n return <LazyIcon className={styles['input-container__input__icon']} color={iconColor} size={iconSize} iconName={icon} />;\n }\n\n return <Icon className={styles['input-container__input__icon']} color={iconColor} size={iconSize} svgIcon={icon} />;\n };\n\n // eslint-disable-next-line\n const handleClick = (e: React.MouseEvent<any>): void => {\n if (inputContainerRef && inputContainerRef.current && icon) {\n const selectedChild = iconRight ? 0 : 1;\n const input = inputContainerRef.current.children[selectedChild] as HTMLInputElement;\n input.focus();\n\n props.onClick && props.onClick(e);\n }\n };\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {\n const newValue = getIncrementValue(e);\n\n if (onChange) {\n onChange(e);\n }\n\n setInput(newValue);\n setPrevValue(newValue);\n };\n\n // Hvis bruker endrer number value med 1 og det skal startes på en annen verdi enn 0\n const getIncrementValue = (e: React.ChangeEvent<HTMLInputElement>): string => {\n if (typeof baseIncrementValue === 'undefined' || type !== 'number') return e.target.value;\n\n const valueAsNumber = Number(e.target.value);\n\n if (!prevValue && !numKeyPressed.current && (valueAsNumber === 1 || valueAsNumber === -1)) {\n e.target.value = baseIncrementValue + '';\n }\n\n return e.target.value;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>): void => {\n if (numRegex.test(e.key)) {\n numKeyPressed.current = true;\n }\n onKeyDown && onKeyDown(e);\n };\n\n const handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>): void => {\n if (numRegex.test(e.key)) {\n numKeyPressed.current = false;\n }\n };\n\n const maxWidth = width ? getInputMaxWidth(width, !!icon, iconSize) : undefined;\n\n return (\n <ErrorWrapper errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Input} className={inputWrapperClass} ref={inputWrapperRef}>\n {renderLabel(label, inputIdState, mode as FormMode)}\n {/* input-elementet tillater keyboard-interaksjon */}\n <div className={styles['content-wrapper']}>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div onClick={handleClick} ref={inputContainerRef} className={inputContainer} style={{ maxWidth }}>\n {!iconRight && renderIcon()}\n <input\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n name={name}\n type={type}\n defaultValue={defaultValue}\n id={inputIdState}\n className={inputClass}\n ref={ref}\n aria-labelledby={props['aria-labelledby'] ?? undefined}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-invalid={!!onError}\n disabled={disabled}\n placeholder={placeholder}\n readOnly={readOnly}\n autoComplete={autoComplete || 'off'}\n required={required}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n {...rest}\n />\n {iconRight && renderIcon()}\n </div>\n <div className={styles['content-wrapper__right-of-input']}>{rightOfInput}</div>\n </div>\n {maxCharacters && (\n <MaxCharacters maxCharacters={maxCharacters} length={input.toString().length} maxText={maxText} mode={mode} maxWidth={maxWidth} />\n )}\n {afterInputChildren}\n </div>\n </ErrorWrapper>\n );\n});\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"names":["InputTypes","getInputMaxWidth","characters","hasIcon","iconSize","paddingWidth","iconWidth","AVERAGE_CHARACTER_WIDTH_PX","Input","React","props","ref","className","defaultValue","placeholder","type","name","transparent","icon","iconRight","inputId","inputWrapperRef","mode","FormMode","size","baseIncrementValue","label","error","errorText","errorTextId","testId","disabled","readOnly","autoComplete","afterInputChildren","rightOfInput","width","required","onChange","onKeyDown","autoFocus","maxCharacters","maxText","rest","breakpoint","useBreakpoint","inputContainerRef","useRef","inputIdState","useUuid","input","setInput","useState","prevValue","setPrevValue","numKeyPressed","errorTextUuid","numRegex","useEffect","onDark","onBlueberry","maxCharactersExceeded","onError","isLarge","FormSize","isTransparent","inputWrapperClass","cn","styles","inputContainer","inputClass","iconColor","getColor","Breakpoint","IconSize","renderIcon","LazyIcon","Icon","handleClick","e","selectedChild","handleChange","newValue","getIncrementValue","valueAsNumber","handleKeyDown","handleKeyUp","maxWidth","ErrorWrapper","AnalyticsId","renderLabel","getAriaDescribedBy","MaxCharacters"],"mappings":";;;;;;;;;;;;;AAkFY,IAAAA,uBAAAA,OACVA,EAAA,OAAO,QACPA,EAAA,SAAS,UACTA,EAAA,QAAQ,SACRA,EAAA,WAAW,YACXA,EAAA,SAAS,UACTA,EAAA,MAAM,OACNA,EAAA,MAAM,OACNA,EAAA,OAAO,QACPA,EAAA,OAAO,QATGA,IAAAA,MAAA,CAAA,CAAA;AAYZ,MAAMC,KAAmB,CAACC,GAAoBC,GAAkBC,MAA6B;AACrF,QAAAC,IAAeF,IAAU,WAAW,QACpCG,IAAYH,IAAU,GAAGC,CAAQ,OAAO;AAGvC,SAAA,QAAQF,IAAaK,EAA0B,QAAQF,CAAY,MAAMC,CAAS;AAC3F,GAEME,KAAQC,EAAM,WAAW,CAACC,GAAmBC,MAAqC;AAChF,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,aAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,MAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,MAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,MAAAC,IAAOC,EAAS;AAAA,IAChB,MAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,aAAAC;AAAA,IACA,QAAAC;AAAA,IACA,UA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,UAAAI;AAAA,MAEA,WAAAG;AAAA,MACC,GAAGG;AAAA,IAAA;AAAA,EAEL,GAAAxB,KAAawD,EAAW,CAC3B,GACAlE,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAW2D,EAAO,iCAAiC,EAAI,GAAAjC,CAAa,CAC3E,GACCM,KACChC,gBAAAA,EAAA,cAACmF,IAAc,EAAA,eAAAnD,GAA8B,QAAQS,EAAM,SAAS,EAAE,QAAQ,SAAAR,IAAkB,MAAApB,GAAY,UAAAiE,EAAoB,CAAA,GAEjIrD,CACH,CACF;AAEJ,CAAC;AAED1B,GAAM,cAAc;"}
1
+ {"version":3,"file":"Input.js","sources":["../../../src/components/Input/Input.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport cn from 'classnames';\n\nimport { FormMode, FormSize, AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { mergeRefs } from '../../utils/refs';\nimport ErrorWrapper from '../ErrorWrapper';\nimport Icon, { IconSize, SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport { renderLabel } from '../Label';\nimport LazyIcon from '../LazyIcon';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface InputProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n | 'disabled'\n | 'readOnly'\n | 'autoComplete'\n | 'name'\n | 'placeholder'\n | 'defaultValue'\n | 'required'\n | 'value'\n | 'min'\n | 'max'\n | 'aria-describedby'\n | 'aria-labelledby'\n | 'onBlur'\n | 'onClick'\n | 'onChange'\n | 'onFocus'\n | 'onKeyDown'\n | 'autoFocus'\n > {\n /** The number at which the input field starts when you increment or decrement it */\n baseIncrementValue?: number;\n /** Adds custom classes to the element. */\n className?: string;\n /** HMTL Input type */\n type?: keyof typeof InputTypes;\n /** input id */\n inputId?: string;\n /** Width of input field in characters (approximate) */\n width?: number;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Icon to be displayed next to the input field */\n icon?: SvgIcon | IconName;\n /** Places the icon to the right */\n iconRight?: boolean;\n /** Ref that is placed on the inputContainerRef */\n inputContainerRef?: React.RefObject<HTMLDivElement>;\n /** Ref that is placed on the inputWrapper */\n inputWrapperRef?: React.RefObject<HTMLDivElement>;\n /** Changes the color profile of the input */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the input */\n size?: keyof typeof FormSize;\n /** Label of the input */\n label?: React.ReactNode;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Component shown after input */\n afterInputChildren?: React.ReactNode;\n /** Component shown to the right of input */\n rightOfInput?: React.ReactNode;\n /** max character limit in input */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n}\n\nexport enum InputTypes {\n text = 'text',\n number = 'number',\n email = 'email',\n password = 'password',\n search = 'search',\n tel = 'tel',\n url = 'url',\n date = 'date',\n time = 'time',\n}\n\nconst getInputMaxWidth = (characters: number, hasIcon: boolean, iconSize: number): string => {\n const paddingWidth = hasIcon ? '1.5rem' : '2rem';\n const iconWidth = hasIcon ? `${iconSize}px` : '0px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${iconWidth} + ${borderWidth})`;\n};\n\nconst Input = React.forwardRef((props: InputProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n defaultValue,\n placeholder,\n type = InputTypes.text,\n name,\n transparent = false,\n icon,\n iconRight,\n inputId,\n inputWrapperRef,\n mode = FormMode.onwhite,\n size,\n baseIncrementValue,\n label,\n error,\n errorText,\n errorTextId,\n testId,\n disabled,\n readOnly,\n autoComplete = 'off',\n afterInputChildren,\n rightOfInput,\n width,\n required,\n onChange,\n onKeyDown,\n autoFocus,\n maxCharacters,\n maxText,\n ...rest\n } = props;\n const breakpoint = useBreakpoint();\n const inputContainerRef = useRef<HTMLDivElement>(null);\n const inputIdState = useUuid(inputId);\n const [input, setInput] = useState(defaultValue || '');\n const [prevValue, setPrevValue] = useState<string | number | undefined>(undefined);\n const numKeyPressed = useRef<boolean>(false);\n const errorTextUuid = useUuid(errorTextId);\n const numRegex = /^[0-9]$/;\n\n useEffect(() => {\n setInput(defaultValue || '');\n }, [defaultValue]);\n\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && input.toString().length > maxCharacters;\n const onError = mode === FormMode.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n const isLarge = size === FormSize.large;\n const isTransparent = transparent && mode !== FormMode.ondark && !onError;\n\n const inputWrapperClass = cn(styles['input-wrapper'], className);\n\n const inputContainer = cn(styles['input-container'], {\n [styles['input-container--transparent']]: isTransparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--large']]: isLarge,\n [styles['input-container--disabled']]: disabled,\n [styles['input-container--with-icon']]: icon,\n });\n\n const inputClass = cn(styles['input-container__input'], {\n [styles['input-container__input--large']]: isLarge,\n [styles['input-container__input--disabled']]: disabled,\n });\n\n const iconColor = disabled ? getColor('neutral', 700) : getColor('black');\n const iconSize = breakpoint === Breakpoint.xs || !isLarge ? IconSize.XSmall : IconSize.Small;\n\n const renderIcon = (): React.ReactNode => {\n if (!icon) {\n return;\n }\n\n if (typeof icon === 'string') {\n return <LazyIcon className={styles['input-container__input__icon']} color={iconColor} size={iconSize} iconName={icon} />;\n }\n\n return <Icon className={styles['input-container__input__icon']} color={iconColor} size={iconSize} svgIcon={icon} />;\n };\n\n // eslint-disable-next-line\n const handleClick = (e: React.MouseEvent<any>): void => {\n if (inputContainerRef && inputContainerRef.current && icon) {\n const selectedChild = iconRight ? 0 : 1;\n const input = inputContainerRef.current.children[selectedChild] as HTMLInputElement;\n input.focus();\n\n props.onClick && props.onClick(e);\n }\n };\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {\n const newValue = getIncrementValue(e);\n\n if (onChange) {\n onChange(e);\n }\n\n setInput(newValue);\n setPrevValue(newValue);\n };\n\n // Hvis bruker endrer number value med 1 og det skal startes på en annen verdi enn 0\n const getIncrementValue = (e: React.ChangeEvent<HTMLInputElement>): string => {\n if (typeof baseIncrementValue === 'undefined' || type !== 'number') return e.target.value;\n\n const valueAsNumber = Number(e.target.value);\n\n if (!prevValue && !numKeyPressed.current && (valueAsNumber === 1 || valueAsNumber === -1)) {\n e.target.value = baseIncrementValue + '';\n }\n\n return e.target.value;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>): void => {\n if (numRegex.test(e.key)) {\n numKeyPressed.current = true;\n }\n onKeyDown && onKeyDown(e);\n };\n\n const handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>): void => {\n if (numRegex.test(e.key)) {\n numKeyPressed.current = false;\n }\n };\n\n const maxWidth = width ? getInputMaxWidth(width, !!icon, iconSize) : undefined;\n\n return (\n <ErrorWrapper errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Input} className={inputWrapperClass} ref={inputWrapperRef}>\n {renderLabel(label, inputIdState, mode as FormMode)}\n {/* input-elementet tillater keyboard-interaksjon */}\n <div className={styles['content-wrapper']}>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div\n onClick={handleClick}\n ref={mergeRefs([inputContainerRef, props.inputContainerRef])}\n className={inputContainer}\n style={{ maxWidth }}\n >\n {!iconRight && renderIcon()}\n <input\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n name={name}\n type={type}\n defaultValue={defaultValue}\n id={inputIdState}\n className={inputClass}\n ref={ref}\n aria-labelledby={props['aria-labelledby'] ?? undefined}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-invalid={!!onError}\n disabled={disabled}\n placeholder={placeholder}\n readOnly={readOnly}\n autoComplete={autoComplete || 'off'}\n required={required}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n {...rest}\n />\n {iconRight && renderIcon()}\n </div>\n <div className={styles['content-wrapper__right-of-input']}>{rightOfInput}</div>\n </div>\n {maxCharacters && (\n <MaxCharacters maxCharacters={maxCharacters} length={input.toString().length} maxText={maxText} mode={mode} maxWidth={maxWidth} />\n )}\n {afterInputChildren}\n </div>\n </ErrorWrapper>\n );\n});\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"names":["InputTypes","getInputMaxWidth","characters","hasIcon","iconSize","paddingWidth","iconWidth","AVERAGE_CHARACTER_WIDTH_PX","Input","React","props","ref","className","defaultValue","placeholder","type","name","transparent","icon","iconRight","inputId","inputWrapperRef","mode","FormMode","size","baseIncrementValue","label","error","errorText","errorTextId","testId","disabled","readOnly","autoComplete","afterInputChildren","rightOfInput","width","required","onChange","onKeyDown","autoFocus","maxCharacters","maxText","rest","breakpoint","useBreakpoint","inputContainerRef","useRef","inputIdState","useUuid","input","setInput","useState","prevValue","setPrevValue","numKeyPressed","errorTextUuid","numRegex","useEffect","onDark","onBlueberry","maxCharactersExceeded","onError","isLarge","FormSize","isTransparent","inputWrapperClass","cn","styles","inputContainer","inputClass","iconColor","getColor","Breakpoint","IconSize","renderIcon","LazyIcon","Icon","handleClick","e","selectedChild","handleChange","newValue","getIncrementValue","valueAsNumber","handleKeyDown","handleKeyUp","maxWidth","ErrorWrapper","AnalyticsId","renderLabel","mergeRefs","getAriaDescribedBy","MaxCharacters"],"mappings":";;;;;;;;;;;;;;AAqFY,IAAAA,uBAAAA,OACVA,EAAA,OAAO,QACPA,EAAA,SAAS,UACTA,EAAA,QAAQ,SACRA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AAoB,GAEjIrD,CACH,CACF;AAEJ,CAAC;AAED1B,GAAM,cAAc;"}
@@ -32,13 +32,13 @@
32
32
  }
33
33
 
34
34
  .input-container {
35
- @include input-container;
36
-
37
35
  $container: &;
38
36
 
39
37
  padding: 0.5rem 0;
40
38
  align-items: center;
41
39
 
40
+ @include input-container;
41
+
42
42
  &--with-icon {
43
43
  padding: 1px 0;
44
44
 
@@ -7,7 +7,7 @@ export declare enum Overlay {
7
7
  parent = "parent"
8
8
  }
9
9
  export interface LoaderProps {
10
- /** Sets the color of the loader */
10
+ /** Sets the color of the loader. If overlay is used, the color will always be white. */
11
11
  color?: LoaderColors;
12
12
  /** Adds custom classes to the element. */
13
13
  className?: string;
@@ -23,9 +23,9 @@ export interface LoaderProps {
23
23
  inline?: boolean;
24
24
  /** Loader is displayed with grey background covering the entire screen */
25
25
  overlay?: keyof typeof Overlay;
26
- /** Individual id for loading icon (aria-labelledby). */
26
+ /** Individual id for loading icon (aria-labelledby). */
27
27
  ariaLabelledById?: string;
28
- /** String that labels the current loading element */
28
+ /** String that labels the current loading element */
29
29
  ariaLabel?: string;
30
30
  }
31
31
  declare const Loader: React.FC<LoaderProps>;
@@ -3,26 +3,25 @@ import i from "classnames";
3
3
  import { ZIndex as z, AnalyticsId as D } from "../../constants.js";
4
4
  import { uuid as A } from "../../utils/uuid.js";
5
5
  import e from "../Loader/styles.module.scss";
6
- var B = /* @__PURE__ */ ((t) => (t.screen = "screen", t.parent = "parent", t))(B || {});
7
- const F = (t) => {
6
+ var B = /* @__PURE__ */ ((a) => (a.screen = "screen", a.parent = "parent", a))(B || {});
7
+ const F = (a) => {
8
8
  const {
9
- overlay: a,
10
- color: r = a ? "black" : "neutral",
11
- size: d = "small",
9
+ overlay: t,
10
+ size: n = "small",
12
11
  className: N = "",
13
12
  labelId: m = A(),
14
- testId: L,
15
- center: h,
16
- inline: n,
13
+ testId: h,
14
+ center: L,
15
+ inline: d,
17
16
  ariaLabelledById: p,
18
17
  ariaLabel: I = "Laster inn"
19
- } = t, g = () => !(a === "parent" || n), [c, u] = S(g()), _ = d === "small", y = d === "medium", f = d === "large", k = i({
20
- [e["loader-wrapper--center"]]: h,
21
- [e["loader-wrapper--overlay"]]: a,
22
- [e["loader-wrapper--overlay-screen"]]: a === "screen",
23
- [e["loader-wrapper--overlay-parent"]]: a === "parent" && c,
24
- [e["loader-wrapper--inline"]]: n && c
25
- }), x = i(
18
+ } = a, r = a.overlay ? "white" : a.color || "neutral", g = () => !(t === "parent" || d), [c, u] = S(g()), _ = n === "small", y = n === "medium", f = n === "large", x = i({
19
+ [e["loader-wrapper--center"]]: L,
20
+ [e["loader-wrapper--overlay"]]: t,
21
+ [e["loader-wrapper--overlay-screen"]]: t === "screen",
22
+ [e["loader-wrapper--overlay-parent"]]: t === "parent" && c,
23
+ [e["loader-wrapper--inline"]]: d && c
24
+ }), k = i(
26
25
  e.loader,
27
26
  {
28
27
  [e["loader--small"]]: _,
@@ -43,16 +42,16 @@ const F = (t) => {
43
42
  [e["loader__dot--white"]]: r === "white"
44
43
  }), s = C(null);
45
44
  return R(() => {
46
- var v, E, b, w;
47
- a === "parent" && ((E = (v = s.current) == null ? void 0 : v.parentElement) != null && E.style) && (s.current.parentElement.style.position = "relative", u(!0)), n && ((w = (b = s.current) == null ? void 0 : b.parentElement) != null && w.style) && (s.current.parentElement.style.display = "flex", u(!0));
48
- }, []), /* @__PURE__ */ l.createElement("div", { className: k, ref: s, style: a === "screen" ? { zIndex: z.OverlayScreen } : {} }, c && /* @__PURE__ */ l.createElement(
45
+ var v, w, E, b;
46
+ t === "parent" && ((w = (v = s.current) == null ? void 0 : v.parentElement) != null && w.style) && (s.current.parentElement.style.position = "relative", u(!0)), d && ((b = (E = s.current) == null ? void 0 : E.parentElement) != null && b.style) && (s.current.parentElement.style.display = "flex", u(!0));
47
+ }, []), /* @__PURE__ */ l.createElement("div", { className: x, ref: s, style: t === "screen" ? { zIndex: z.OverlayScreen } : {} }, c && /* @__PURE__ */ l.createElement(
49
48
  "div",
50
49
  {
51
- "data-testid": L,
50
+ "data-testid": h,
52
51
  "data-analyticsid": D.Loader,
53
52
  role: "progressbar",
54
53
  "aria-labelledby": p || m,
55
- className: x
54
+ className: k
56
55
  },
57
56
  /* @__PURE__ */ l.createElement("div", { className: o }),
58
57
  /* @__PURE__ */ l.createElement("div", { className: o }),
@@ -1 +1 @@
1
- {"version":3,"file":"Loader.js","sources":["../../../src/components/Loader/Loader.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport { PaletteNames } from '../../theme/palette';\nimport { uuid } from '../../utils/uuid';\n\nimport loaderStyles from './styles.module.scss';\n\nexport type LoaderColors = PaletteNames;\nexport type LoaderSizes = 'tiny' | 'small' | 'medium' | 'large';\nexport enum Overlay {\n screen = 'screen',\n parent = 'parent',\n}\n\nexport interface LoaderProps {\n /** Sets the color of the loader */\n color?: LoaderColors;\n /**\tAdds custom classes to the element. */\n className?: string;\n /** Changes the size of the loader. */\n size?: LoaderSizes;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** id of the label */\n labelId?: string;\n /** Centers the loader in a container */\n center?: boolean;\n /** Inline the loader so it can be used in a span or paragraph */\n inline?: boolean;\n /** Loader is displayed with grey background covering the entire screen */\n overlay?: keyof typeof Overlay;\n /** Individual id for loading icon (aria-labelledby). */\n ariaLabelledById?: string;\n /** String that labels the current loading element */\n ariaLabel?: string;\n}\n\nconst Loader: React.FC<LoaderProps> = props => {\n const {\n overlay,\n color = overlay ? 'black' : 'neutral',\n size = 'small',\n className = '',\n labelId = uuid(),\n testId,\n center,\n inline,\n ariaLabelledById,\n ariaLabel = 'Laster inn',\n } = props;\n\n const showLoader = (): boolean => {\n if (overlay === Overlay.parent || inline) {\n return false;\n }\n\n return true;\n };\n\n const [display, setDisplay] = useState(showLoader());\n\n const isSmall = size === 'small';\n const isMedium = size === 'medium';\n const isLarge = size === 'large';\n\n const loaderWrapperClasses = classNames({\n [loaderStyles['loader-wrapper--center']]: center,\n [loaderStyles['loader-wrapper--overlay']]: overlay,\n [loaderStyles['loader-wrapper--overlay-screen']]: overlay === Overlay.screen,\n [loaderStyles['loader-wrapper--overlay-parent']]: overlay === Overlay.parent && display,\n [loaderStyles['loader-wrapper--inline']]: inline && display,\n });\n const loaderClasses = classNames(\n loaderStyles.loader,\n {\n [loaderStyles['loader--small']]: isSmall,\n [loaderStyles['loader--medium']]: isMedium,\n [loaderStyles['loader--large']]: isLarge,\n },\n className\n );\n const loaderDotClasses = classNames(loaderStyles.loader__dot, {\n [loaderStyles['loader__dot--small']]: isSmall,\n [loaderStyles['loader__dot--medium']]: isMedium,\n [loaderStyles['loader__dot--large']]: isLarge,\n [loaderStyles['loader__dot--banana']]: color === 'banana',\n [loaderStyles['loader__dot--cherry']]: color === 'cherry',\n [loaderStyles['loader__dot--kiwi']]: color === 'kiwi',\n [loaderStyles['loader__dot--neutral']]: color === 'neutral',\n [loaderStyles['loader__dot--plum']]: color === 'plum',\n [loaderStyles['loader__dot--black']]: color === 'black',\n [loaderStyles['loader__dot--white']]: color === 'white',\n });\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (overlay === Overlay.parent && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.position = 'relative';\n setDisplay(true);\n }\n\n if (inline && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.display = 'flex';\n setDisplay(true);\n }\n }, []);\n\n return (\n <div className={loaderWrapperClasses} ref={wrapperRef} style={overlay === Overlay.screen ? { zIndex: ZIndex.OverlayScreen } : {}}>\n {display && (\n <div\n data-testid={testId}\n data-analyticsid={AnalyticsId.Loader}\n role=\"progressbar\"\n aria-labelledby={ariaLabelledById || labelId}\n className={loaderClasses}\n >\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n {!ariaLabelledById && (\n <span id={labelId} className={loaderStyles['loader__hidden-text']}>\n {ariaLabel}\n </span>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Loader;\n"],"names":["Overlay","Loader","props","overlay","color","size","className","labelId","uuid","testId","center","inline","ariaLabelledById","ariaLabel","showLoader","display","setDisplay","useState","isSmall","isMedium","isLarge","loaderWrapperClasses","classNames","loaderStyles","loaderClasses","loaderDotClasses","wrapperRef","useRef","useEffect","_b","_a","_d","_c","ZIndex","React","AnalyticsId"],"mappings":";;;;;AAYY,IAAAA,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,SAAS,UAFCA,IAAAA,KAAA,CAAA,CAAA;AA4BZ,MAAMC,IAAgC,CAASC,MAAA;AACvC,QAAA;AAAA,IACJ,SAAAC;AAAA,IACA,OAAAC,IAAQD,IAAU,UAAU;AAAA,IAC5B,MAAAE,IAAO;AAAA,IACP,WAAAC,IAAY;AAAA,IACZ,SAAAC,IAAUC,EAAK;AAAA,IACf,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,EACV,IAAAX,GAEEY,IAAa,MACb,EAAAX,MAAY,YAAkBQ,IAO9B,CAACI,GAASC,CAAU,IAAIC,EAASH,EAAY,CAAA,GAE7CI,IAAUb,MAAS,SACnBc,IAAWd,MAAS,UACpBe,IAAUf,MAAS,SAEnBgB,IAAuBC,EAAW;AAAA,IACtC,CAACC,EAAa,wBAAwB,CAAC,GAAGb;AAAA,IAC1C,CAACa,EAAa,yBAAyB,CAAC,GAAGpB;AAAA,IAC3C,CAACoB,EAAa,gCAAgC,CAAC,GAAGpB,MAAY;AAAA,IAC9D,CAACoB,EAAa,gCAAgC,CAAC,GAAGpB,MAAY,YAAkBY;AAAA,IAChF,CAACQ,EAAa,wBAAwB,CAAC,GAAGZ,KAAUI;AAAA,EAAA,CACrD,GACKS,IAAgBF;AAAA,IACpBC,EAAa;AAAA,IACb;AAAA,MACE,CAACA,EAA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AAAA,IAAC;AAAA,IAAA;AAAA,MACC,eAAazB;AAAA,MACb,oBAAkB0B,EAAY;AAAA,MAC9B,MAAK;AAAA,MACL,mBAAiBvB,KAAoBL;AAAA,MACrC,WAAWiB;AAAA,IAAA;AAAA,IAEXU,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAWT,EAAkB,CAAA;AAAA,IAClCS,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAWT,EAAkB,CAAA;AAAA,IAClCS,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAWT,EAAkB,CAAA;AAAA,IAClCS,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAWT,EAAkB,CAAA;AAAA,IACjC,CAACb,KACAsB,gBAAAA,EAAA,cAAC,QAAK,EAAA,IAAI3B,GAAS,WAAWgB,EAAa,qBAAqB,EAAA,GAC7DV,CACH;AAAA,EAAA,CAIR;AAEJ;"}
1
+ {"version":3,"file":"Loader.js","sources":["../../../src/components/Loader/Loader.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport { PaletteNames } from '../../theme/palette';\nimport { uuid } from '../../utils/uuid';\n\nimport loaderStyles from './styles.module.scss';\n\nexport type LoaderColors = PaletteNames;\nexport type LoaderSizes = 'tiny' | 'small' | 'medium' | 'large';\nexport enum Overlay {\n screen = 'screen',\n parent = 'parent',\n}\n\nexport interface LoaderProps {\n /** Sets the color of the loader. If overlay is used, the color will always be white. */\n color?: LoaderColors;\n /**\tAdds custom classes to the element. */\n className?: string;\n /** Changes the size of the loader. */\n size?: LoaderSizes;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** id of the label */\n labelId?: string;\n /** Centers the loader in a container */\n center?: boolean;\n /** Inline the loader so it can be used in a span or paragraph */\n inline?: boolean;\n /** Loader is displayed with grey background covering the entire screen */\n overlay?: keyof typeof Overlay;\n /** Individual id for loading icon (aria-labelledby). */\n ariaLabelledById?: string;\n /** String that labels the current loading element */\n ariaLabel?: string;\n}\n\nconst Loader: React.FC<LoaderProps> = props => {\n const {\n overlay,\n size = 'small',\n className = '',\n labelId = uuid(),\n testId,\n center,\n inline,\n ariaLabelledById,\n ariaLabel = 'Laster inn',\n } = props;\n const color = props.overlay ? 'white' : props.color || 'neutral';\n\n const showLoader = (): boolean => {\n if (overlay === Overlay.parent || inline) {\n return false;\n }\n\n return true;\n };\n\n const [display, setDisplay] = useState(showLoader());\n\n const isSmall = size === 'small';\n const isMedium = size === 'medium';\n const isLarge = size === 'large';\n\n const loaderWrapperClasses = classNames({\n [loaderStyles['loader-wrapper--center']]: center,\n [loaderStyles['loader-wrapper--overlay']]: overlay,\n [loaderStyles['loader-wrapper--overlay-screen']]: overlay === Overlay.screen,\n [loaderStyles['loader-wrapper--overlay-parent']]: overlay === Overlay.parent && display,\n [loaderStyles['loader-wrapper--inline']]: inline && display,\n });\n const loaderClasses = classNames(\n loaderStyles.loader,\n {\n [loaderStyles['loader--small']]: isSmall,\n [loaderStyles['loader--medium']]: isMedium,\n [loaderStyles['loader--large']]: isLarge,\n },\n className\n );\n const loaderDotClasses = classNames(loaderStyles.loader__dot, {\n [loaderStyles['loader__dot--small']]: isSmall,\n [loaderStyles['loader__dot--medium']]: isMedium,\n [loaderStyles['loader__dot--large']]: isLarge,\n [loaderStyles['loader__dot--banana']]: color === 'banana',\n [loaderStyles['loader__dot--cherry']]: color === 'cherry',\n [loaderStyles['loader__dot--kiwi']]: color === 'kiwi',\n [loaderStyles['loader__dot--neutral']]: color === 'neutral',\n [loaderStyles['loader__dot--plum']]: color === 'plum',\n [loaderStyles['loader__dot--black']]: color === 'black',\n [loaderStyles['loader__dot--white']]: color === 'white',\n });\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (overlay === Overlay.parent && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.position = 'relative';\n setDisplay(true);\n }\n\n if (inline && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.display = 'flex';\n setDisplay(true);\n }\n }, []);\n\n return (\n <div className={loaderWrapperClasses} ref={wrapperRef} style={overlay === Overlay.screen ? { zIndex: ZIndex.OverlayScreen } : {}}>\n {display && (\n <div\n data-testid={testId}\n data-analyticsid={AnalyticsId.Loader}\n role=\"progressbar\"\n aria-labelledby={ariaLabelledById || labelId}\n className={loaderClasses}\n >\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n {!ariaLabelledById && (\n <span id={labelId} className={loaderStyles['loader__hidden-text']}>\n {ariaLabel}\n </span>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Loader;\n"],"names":["Overlay","Loader","props","overlay","size","className","labelId","uuid","testId","center","inline","ariaLabelledById","ariaLabel","color","showLoader","display","setDisplay","useState","isSmall","isMedium","isLarge","loaderWrapperClasses","classNames","loaderStyles","loaderClasses","loaderDotClasses","wrapperRef","useRef","useEffect","_b","_a","_d","_c","ZIndex","React","AnalyticsId"],"mappings":";;;;;AAYY,IAAAA,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,SAAS,UAFCA,IAAAA,KAAA,CAAA,CAAA;AA4BZ,MAAMC,IAAgC,CAASC,MAAA;AACvC,QAAA;AAAA,IACJ,SAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,WAAAC,IAAY;AAAA,IACZ,SAAAC,IAAUC,EAAK;AAAA,IACf,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,EACV,IAAAV,GACEW,IAAQX,EAAM,UAAU,UAAUA,EAAM,SAAS,WAEjDY,IAAa,MACb,EAAAX,MAAY,YAAkBO,IAO9B,CAACK,GAASC,CAAU,IAAIC,EAASH,EAAY,CAAA,GAE7CI,IAAUd,MAAS,SACnBe,IAAWf,MAAS,UACpBgB,IAAUhB,MAAS,SAEnBiB,IAA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AQ,cAAc,MAAM,WAAW,YAClDV,EAAW,EAAI,IAGbN,OAAUqB,KAAAC,IAAAN,EAAW,YAAX,gBAAAM,EAAoB,kBAApB,QAAAD,EAAmC,WACpCL,EAAA,QAAQ,cAAc,MAAM,UAAU,QACjDV,EAAW,EAAI;AAAA,EAEnB,GAAG,CAAE,CAAA,mCAGF,OAAI,EAAA,WAAWK,GAAsB,KAAKK,GAAY,OAAOvB,MAAY,WAAiB,EAAE,QAAQ8B,EAAO,cAAkB,IAAA,MAC3HlB,KACCmB,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,eAAa1B;AAAA,MACb,oBAAkB2B,EAAY;AAAA,MAC9B,MAAK;AAAA,MACL,mBAAiBxB,KAAoBL;AAAA,MACrC,WAAWkB;AAAA,IAAA;AAAA,IAEXU,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAWT,EAAkB,CAAA;AAAA,IAClCS,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAWT,EAAkB,CAAA;AAAA,IAClCS,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAWT,EAAkB,CAAA;AAAA,IAClCS,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAWT,EAAkB,CAAA;AAAA,IACjC,CAACd,KACAuB,gBAAAA,EAAA,cAAC,QAAK,EAAA,IAAI5B,GAAS,WAAWiB,EAAa,qBAAqB,EAAA,GAC7DX,CACH;AAAA,EAAA,CAIR;AAEJ;"}
@@ -14,6 +14,8 @@
14
14
  }
15
15
 
16
16
  @mixin loader-dot-scale($name, $scale-start, $scale-end) {
17
+ @include animate($name, scale, 0.6s, infinite);
18
+
17
19
  @include keyframes($name) {
18
20
  0% {
19
21
  transform: scale($scale-start);
@@ -23,11 +25,11 @@
23
25
  transform: scale($scale-end);
24
26
  }
25
27
  }
26
-
27
- @include animate($name, scale, 0.6s, infinite);
28
28
  }
29
29
 
30
30
  @mixin loader-dot-translate($name, $distance) {
31
+ @include animate($name, translate, 0.6s, infinite);
32
+
31
33
  @include keyframes($name) {
32
34
  0% {
33
35
  transform: translate(0, 0);
@@ -37,8 +39,6 @@
37
39
  transform: translate($distance, 0);
38
40
  }
39
41
  }
40
-
41
- @include animate($name, translate, 0.6s, infinite);
42
42
  }
43
43
 
44
44
  .loader-wrapper {
@@ -105,6 +105,9 @@
105
105
  background-color: $blueberry500;
106
106
  border-radius: 50%;
107
107
 
108
+ // Sets a form of easing animation curve
109
+ animation-timing-function: cubic-bezier(0, 1, 1, 0);
110
+
108
111
  &--small {
109
112
  width: 12px;
110
113
  height: 12px;
@@ -148,9 +151,6 @@
148
151
  background-color: $white;
149
152
  }
150
153
 
151
- // Sets a form of easing animation curve
152
- animation-timing-function: cubic-bezier(0, 1, 1, 0);
153
-
154
154
  // Scales up the first dot
155
155
  &:nth-child(1) {
156
156
  @include loader-dot-scale(scale-regular, 0, 1);
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { ZIndex } from '../../constants';
3
2
  export declare enum ModalVariants {
4
3
  normal = "normal",
5
4
  warning = "warning",
@@ -55,15 +54,5 @@ export interface ModalProps {
55
54
  /** If disabled, clicking escape or outside the modal will not close it */
56
55
  disableCloseEvents?: boolean;
57
56
  }
58
- declare const Modal: {
59
- (props: ModalProps): JSX.Element;
60
- defaultProps: {
61
- variant: ModalVariants;
62
- primaryButtonText: string;
63
- titleId: string;
64
- className: string;
65
- size: ModalSize;
66
- zIndex: ZIndex;
67
- };
68
- };
57
+ declare const Modal: React.FC<ModalProps>;
69
58
  export default Modal;
@@ -1,142 +1,145 @@
1
- import t, { useEffect as N } from "react";
2
- import n from "classnames";
3
- import { ZIndex as W, AnalyticsId as R, IconSize as c } from "../../constants.js";
4
- import { useFocusTrap as P } from "../../hooks/useFocusTrap.js";
5
- import { useIsVisible as I } from "../../hooks/useIsVisible.js";
6
- import { palette as u } from "../../theme/palette.js";
7
- import { uuid as $ } from "../../utils/uuid.js";
8
- import w from "../Button/Button.js";
9
- import A from "../Close/Close.js";
10
- import { Icon as _ } from "../Icon/Icon.js";
11
- import F from "../Icons/AlertSignFill.js";
12
- import H from "../Icons/AlertSignStroke.js";
13
- import K from "../Icons/CheckOutline.js";
14
- import O from "../Portal/index.js";
15
- import { Title as D } from "../Title/Title.js";
1
+ import t, { useEffect as k } from "react";
2
+ import o from "classnames";
3
+ import { ZIndex as H, AnalyticsId as K, IconSize as d } from "../../constants.js";
4
+ import { useFocusTrap as O } from "../../hooks/useFocusTrap.js";
5
+ import { useIsVisible as L } from "../../hooks/useIsVisible.js";
6
+ import { palette as v } from "../../theme/palette.js";
7
+ import { uuid as D } from "../../utils/uuid.js";
8
+ import S from "../Button/Button.js";
9
+ import V from "../Close/Close.js";
10
+ import { Icon as E } from "../Icon/Icon.js";
11
+ import Z from "../Icons/AlertSignFill.js";
12
+ import j from "../Icons/AlertSignStroke.js";
13
+ import q from "../Icons/CheckOutline.js";
14
+ import G from "../Portal/index.js";
15
+ import { Title as J } from "../Title/Title.js";
16
16
  import a from "../Modal/styles.module.scss";
17
- var V = /* @__PURE__ */ ((e) => (e.normal = "normal", e.warning = "warning", e.error = "error", e.success = "success", e.image = "image", e))(V || {}), Z = /* @__PURE__ */ ((e) => (e.large = "large", e.medium = "medium", e))(Z || {});
18
- const j = {
19
- variant: "normal",
20
- primaryButtonText: "OK",
21
- titleId: $(),
22
- className: "",
23
- size: "large",
24
- zIndex: W.Modal
25
- }, q = (e) => e === "error" ? /* @__PURE__ */ t.createElement(_, { size: c.Small, svgIcon: F, color: u.cherry500 }) : e === "warning" ? /* @__PURE__ */ t.createElement(_, { size: c.Small, svgIcon: H, color: u.black }) : e === "success" ? /* @__PURE__ */ t.createElement(_, { size: c.Small, svgIcon: K, color: u.kiwi900 }) : null, G = (e, r) => {
26
- const o = q(e);
27
- return o ? /* @__PURE__ */ t.createElement("div", { className: a.modal__iconWrapper }, o) : r ? /* @__PURE__ */ t.createElement("div", { className: a.modal__iconWrapper }, t.cloneElement(r, {
28
- size: c.Small
17
+ var M = /* @__PURE__ */ ((e) => (e.normal = "normal", e.warning = "warning", e.error = "error", e.success = "success", e.image = "image", e))(M || {}), Q = /* @__PURE__ */ ((e) => (e.large = "large", e.medium = "medium", e))(Q || {});
18
+ const U = (e) => e === "error" ? /* @__PURE__ */ t.createElement(E, { size: d.Small, svgIcon: Z, color: v.cherry500 }) : e === "warning" ? /* @__PURE__ */ t.createElement(E, { size: d.Small, svgIcon: j, color: v.black }) : e === "success" ? /* @__PURE__ */ t.createElement(E, { size: d.Small, svgIcon: q, color: v.kiwi900 }) : null, X = (e, n) => {
19
+ const m = U(e);
20
+ return m ? /* @__PURE__ */ t.createElement("div", { className: a.modal__iconWrapper }, m) : n ? /* @__PURE__ */ t.createElement("div", { className: a.modal__iconWrapper }, t.cloneElement(n, {
21
+ size: d.Small
29
22
  })) : null;
30
- }, J = (e) => {
31
- var C, h;
32
- const r = t.useRef(null), o = t.useRef(null), m = t.useRef(null);
33
- P(m, !0);
34
- const B = I(r), f = t.useRef(null), k = I(f), s = o.current && o.current.scrollHeight > o.current.clientHeight;
35
- function v(l) {
23
+ }, fe = (e) => {
24
+ var I, B;
25
+ const {
26
+ variant: n = "normal",
27
+ primaryButtonText: m = "OK",
28
+ titleId: W = D(),
29
+ className: x = "",
30
+ size: c = "large",
31
+ zIndex: T = H.Modal
32
+ } = e, b = t.useRef(null), s = t.useRef(null), u = t.useRef(null);
33
+ O(u, !0);
34
+ const R = L(b), g = t.useRef(null), z = L(g), r = s.current && s.current.scrollHeight > s.current.clientHeight;
35
+ function y(l) {
36
36
  l.key === "Escape" && e.onClose && (l.stopPropagation(), e.onClose());
37
37
  }
38
- function E(l) {
39
- l.target && d.current === l.target && e.onClose && (l.stopPropagation(), e.onClose());
38
+ function C(l) {
39
+ l.target && _.current === l.target && e.onClose && (l.stopPropagation(), e.onClose());
40
40
  }
41
- function z() {
41
+ function $() {
42
42
  document.body.style.overflow = "hidden";
43
43
  }
44
- function x() {
44
+ function A() {
45
45
  document.body.style.removeProperty("overflow");
46
46
  }
47
- const i = e.variant === "image", d = t.useRef(null), g = e.secondaryButtonText && ((C = e.secondaryButtonText) == null ? void 0 : C.length) > 0 || e.onSuccess, L = e.ariaLabelledBy ? void 0 : e.ariaLabel, y = e.ariaLabelledBy ? e.ariaLabelledBy : e.ariaLabel ? void 0 : e.titleId;
48
- N(() => {
49
- const l = d.current;
50
- return z(), !e.disableCloseEvents && l && (l.addEventListener("keydown", v), l.addEventListener("click", E)), () => {
51
- x(), !e.disableCloseEvents && l && (l.removeEventListener("keydown", v), l.removeEventListener("click", E));
47
+ const i = n === "image", _ = t.useRef(null), h = e.secondaryButtonText && ((I = e.secondaryButtonText) == null ? void 0 : I.length) > 0 || e.onSuccess, N = e.ariaLabelledBy ? void 0 : e.ariaLabel, f = e.ariaLabelledBy ? e.ariaLabelledBy : e.ariaLabel ? void 0 : W;
48
+ k(() => {
49
+ const l = _.current;
50
+ return $(), !e.disableCloseEvents && l && (l.addEventListener("keydown", y), l.addEventListener("click", C)), () => {
51
+ A(), !e.disableCloseEvents && l && (l.removeEventListener("keydown", y), l.removeEventListener("click", C));
52
52
  };
53
- }, [e.disableCloseEvents]), N(() => {
53
+ }, [e.disableCloseEvents]), k(() => {
54
54
  var l;
55
- (l = m.current) == null || l.focus();
55
+ (l = u.current) == null || l.focus();
56
56
  }, []);
57
- const S = n(
58
- e.className,
57
+ const P = o(
58
+ x,
59
59
  a.modal,
60
- e.variant && a[`modal--${e.variant}`],
61
- e.size && a[`modal--${e.size}`],
62
- s && !g && a["modal--no-actions"]
63
- ), T = n({
64
- [a["modal__title--error"]]: e.variant === "error",
65
- [a["modal__title--success"]]: e.variant === "success"
60
+ n && a[`modal--${n}`],
61
+ c && a[`modal--${c}`],
62
+ r && !h && a["modal--no-actions"]
63
+ ), F = o({
64
+ [a["modal__title--error"]]: n === "error",
65
+ [a["modal__title--success"]]: n === "success"
66
66
  /* success */
67
- }), b = /* @__PURE__ */ t.createElement("div", { "data-testid": "dialog-container" }, /* @__PURE__ */ t.createElement(
67
+ }), w = /* @__PURE__ */ t.createElement("div", { "data-testid": "dialog-container" }, /* @__PURE__ */ t.createElement(
68
68
  "div",
69
69
  {
70
- ref: d,
70
+ ref: _,
71
71
  className: a["modal-overlay"],
72
72
  "data-testid": e.testId,
73
- "data-analyticsid": R.Modal,
74
- style: { zIndex: e.zIndex }
73
+ "data-analyticsid": K.Modal,
74
+ style: { zIndex: T }
75
75
  },
76
76
  /* @__PURE__ */ t.createElement("div", { className: a.align }, /* @__PURE__ */ t.createElement(
77
77
  "div",
78
78
  {
79
- className: S,
79
+ className: P,
80
80
  role: "dialog",
81
81
  "aria-modal": "true",
82
82
  tabIndex: -1,
83
- "aria-label": L,
84
- "aria-labelledby": y,
85
- ref: m
83
+ "aria-label": N,
84
+ "aria-labelledby": f,
85
+ ref: u
86
86
  },
87
87
  /* @__PURE__ */ t.createElement(
88
88
  "div",
89
89
  {
90
- className: n(a.modal__shadow, a["modal__shadow--top"], {
91
- [a["modal__shadow--show"]]: !B && s
90
+ className: o(a.modal__shadow, a["modal__shadow--top"], {
91
+ [a["modal__shadow--show"]]: !R && r
92
92
  })
93
93
  }
94
94
  ),
95
95
  /* @__PURE__ */ t.createElement(
96
96
  "div",
97
97
  {
98
- className: n(a.modal__contentWrapper, {
98
+ className: o(a.modal__contentWrapper, {
99
99
  [a["modal__contentWrapper--image"]]: i
100
100
  }),
101
- ref: o
101
+ tabIndex: r ? 0 : void 0,
102
+ role: r ? "region" : void 0,
103
+ "aria-label": r ? N : void 0,
104
+ "aria-labelledby": r ? f : void 0,
105
+ ref: s
102
106
  },
103
- !e.noCloseButton && /* @__PURE__ */ t.createElement("div", { className: a.modal__closeWrapper }, /* @__PURE__ */ t.createElement("div", { className: n(a.modal__closeWrapper__close) }, /* @__PURE__ */ t.createElement(A, { onClick: e.onClose, ariaLabel: e.ariaLabelCloseBtn }))),
107
+ !e.noCloseButton && /* @__PURE__ */ t.createElement("div", { className: a.modal__closeWrapper }, /* @__PURE__ */ t.createElement("div", { className: o(a.modal__closeWrapper__close) }, /* @__PURE__ */ t.createElement(V, { onClick: e.onClose, ariaLabel: e.ariaLabelCloseBtn }))),
104
108
  /* @__PURE__ */ t.createElement(
105
109
  "div",
106
110
  {
107
- className: n(e.size && a[`modal__contentWrapper__scroll--${e.size}`], {
111
+ className: o(c && a[`modal__contentWrapper__scroll--${c}`], {
108
112
  [a["modal__contentWrapper__scroll--image"]]: i
109
113
  })
110
114
  },
111
- /* @__PURE__ */ t.createElement("div", { ref: r }),
112
- /* @__PURE__ */ t.createElement("div", { className: a.modal__contentWrapper__title }, G(e.variant, e.icon), /* @__PURE__ */ t.createElement(D, { id: y, htmlMarkup: "h3", appearance: "title3", className: T }, e.title), e.afterTitleChildren && /* @__PURE__ */ t.createElement("div", { className: a.modal__afterTitleChildren }, e.afterTitleChildren)),
115
+ /* @__PURE__ */ t.createElement("div", { ref: b }),
116
+ /* @__PURE__ */ t.createElement("div", { className: a.modal__contentWrapper__title }, X(n, e.icon), /* @__PURE__ */ t.createElement(J, { id: f, htmlMarkup: "h3", appearance: "title3", className: F }, e.title), e.afterTitleChildren && /* @__PURE__ */ t.createElement("div", { className: a.modal__afterTitleChildren }, e.afterTitleChildren)),
113
117
  i && /* @__PURE__ */ t.createElement("div", null, /* @__PURE__ */ t.createElement("div", { className: a.modal__contentWrapper__imageWrapper }, e.children), /* @__PURE__ */ t.createElement("span", { className: a.modal__contentWrapper__imageDescription }, e.description)),
114
118
  !i && e.children && /* @__PURE__ */ t.createElement("div", null, e.children),
115
119
  !i && !e.children && /* @__PURE__ */ t.createElement("p", { className: a.modal__description }, e.description),
116
- /* @__PURE__ */ t.createElement("div", { ref: f })
120
+ /* @__PURE__ */ t.createElement("div", { ref: g })
117
121
  )
118
122
  ),
119
123
  /* @__PURE__ */ t.createElement(
120
124
  "div",
121
125
  {
122
- className: n(a.modal__shadow, a["modal__shadow--bottom"], {
123
- [a["modal__shadow--show"]]: !k && s
126
+ className: o(a.modal__shadow, a["modal__shadow--bottom"], {
127
+ [a["modal__shadow--show"]]: !z && r
124
128
  })
125
129
  }
126
130
  ),
127
- g && /* @__PURE__ */ t.createElement("div", { className: n(a["modal__call-to-action"], e.size && a[`modal__call-to-action--${e.size}`]) }, e.onSuccess && /* @__PURE__ */ t.createElement(w, { onClick: e.onSuccess }, e.primaryButtonText), e.secondaryButtonText && ((h = e.secondaryButtonText) == null ? void 0 : h.length) > 0 && /* @__PURE__ */ t.createElement(w, { variant: "borderless", onClick: e.onClose }, e.secondaryButtonText))
131
+ h && /* @__PURE__ */ t.createElement("div", { className: o(a["modal__call-to-action"], c && a[`modal__call-to-action--${c}`]) }, e.onSuccess && /* @__PURE__ */ t.createElement(S, { onClick: e.onSuccess }, m), e.secondaryButtonText && ((B = e.secondaryButtonText) == null ? void 0 : B.length) > 0 && /* @__PURE__ */ t.createElement(S, { variant: "borderless", onClick: e.onClose }, e.secondaryButtonText))
128
132
  ))
129
133
  ));
130
134
  if (e.printable) {
131
135
  const l = "print-modal";
132
- return /* @__PURE__ */ t.createElement(O, { className: l, testId: "print-modal" }, /* @__PURE__ */ t.createElement("style", { media: "print" }, `body > *:not(.${l}) {display: none;}`), b);
136
+ return /* @__PURE__ */ t.createElement(G, { className: l, testId: "print-modal" }, /* @__PURE__ */ t.createElement("style", { media: "print" }, `body > *:not(.${l}) {display: none;}`), w);
133
137
  }
134
- return b;
138
+ return w;
135
139
  };
136
- J.defaultProps = j;
137
140
  export {
138
- Z as ModalSize,
139
- V as ModalVariants,
140
- J as default
141
+ Q as ModalSize,
142
+ M as ModalVariants,
143
+ fe as default
141
144
  };
142
145
  //# sourceMappingURL=Modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { palette } from '../../theme/palette';\nimport { uuid } from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport AlertSignFill from '../Icons/AlertSignFill';\nimport AlertSignStroke from '../Icons/AlertSignStroke';\nimport CheckOutline from '../Icons/CheckOutline';\nimport Portal from '../Portal';\nimport Title from '../Title/Title';\n\nimport styles from './styles.module.scss';\n\nexport enum ModalVariants {\n normal = 'normal',\n warning = 'warning',\n error = 'error',\n success = 'success',\n image = 'image',\n}\n\nexport enum ModalSize {\n large = 'large',\n medium = 'medium',\n}\n\nexport interface ModalProps {\n /** Title of the modal */\n title: string;\n /** id of the modal title */\n titleId?: string;\n /** Description of the modal. Will not render if the modal has children. */\n description?: string;\n /** Changes the visual representation of the modal */\n variant?: keyof typeof ModalVariants;\n /** Change width of the modal (default: large) */\n size?: keyof typeof ModalSize;\n /** Icon displayed in title */\n icon?: React.ReactElement;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Primary button text */\n primaryButtonText?: string;\n /** Secondary button text */\n secondaryButtonText?: string;\n /** Sets the aria-label of the modal */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the modal */\n ariaLabelledBy?: string;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Alternative component to modal */\n children?: React.ReactNode;\n /** Component shown after title */\n afterTitleChildren?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Customize the z-index of the modal */\n zIndex?: number;\n /** Function is called when user clicks primary button */\n onSuccess?: () => void;\n /** Function is called when user clicks secondary button, clicks escape or outside the modal */\n onClose?: () => void;\n /** When enabled the component will be rendered in the bottom of document.body */\n printable?: boolean;\n /** If disabled, clicking escape or outside the modal will not close it */\n disableCloseEvents?: boolean;\n}\n\nconst defaultProps = {\n variant: ModalVariants.normal,\n primaryButtonText: 'OK',\n titleId: uuid(),\n className: '',\n size: ModalSize.large,\n zIndex: ZIndex.Modal,\n};\n\nconst getVariantIcon = (variant?: ModalProps['variant']): JSX.Element | null => {\n if (variant === ModalVariants.error) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignFill} color={palette.cherry500} />;\n } else if (variant === ModalVariants.warning) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignStroke} color={palette.black} />;\n } else if (variant === ModalVariants.success) {\n return <Icon size={IconSize.Small} svgIcon={CheckOutline} color={palette.kiwi900} />;\n }\n return null;\n};\n\nconst getIcon = (variant?: ModalProps['variant'], icon?: ModalProps['icon']): JSX.Element | null => {\n const variantIcon = getVariantIcon(variant);\n if (variantIcon) {\n return <div className={styles.modal__iconWrapper}>{variantIcon}</div>;\n }\n if (icon) {\n return (\n <div className={styles.modal__iconWrapper}>\n {React.cloneElement(icon, {\n size: IconSize.Small,\n })}\n </div>\n );\n }\n return null;\n};\n\nconst Modal = (props: ModalProps): JSX.Element => {\n const topContent = React.useRef<HTMLDivElement>(null);\n const modalContentRef = React.useRef<HTMLDivElement>(null);\n const dialogRef = React.useRef<HTMLDivElement>(null);\n useFocusTrap(dialogRef, true);\n const topContentVisible = useIsVisible(topContent);\n const bottomContent = React.useRef<HTMLDivElement>(null);\n const bottomContentVisible = useIsVisible(bottomContent);\n const contentIsScrollable = modalContentRef.current && modalContentRef.current.scrollHeight > modalContentRef.current.clientHeight;\n\n function handleKeyboardEvent(e: KeyboardEvent): void {\n if (e.key === 'Escape' && props.onClose) {\n e.stopPropagation();\n props.onClose();\n }\n }\n\n function handleClickEvent(event: MouseEvent): void {\n if (event.target && overlayRef.current === event.target && props.onClose) {\n event.stopPropagation();\n props.onClose();\n }\n }\n\n function disableBodyScroll(): void {\n document.body.style.overflow = 'hidden';\n }\n\n function enableBodyScroll(): void {\n document.body.style.removeProperty('overflow');\n }\n\n /* Displays a full window size modal with image */\n const imageView = props.variant === ModalVariants.image;\n\n const overlayRef = React.useRef<HTMLDivElement>(null);\n\n const showActions = (props.secondaryButtonText && props.secondaryButtonText?.length > 0) || props.onSuccess;\n\n // ariaLabelledBy prioriteres over ariaLabel, men dersom ariaLabel brukes trengs ikke ariaLabelledBy\n const ariaLabel = !props.ariaLabelledBy ? props.ariaLabel : undefined;\n const ariaLabelledBy = props.ariaLabelledBy ? props.ariaLabelledBy : !props.ariaLabel ? props.titleId : undefined;\n\n useEffect(() => {\n const overlayElement = overlayRef.current;\n disableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.addEventListener('keydown', handleKeyboardEvent);\n overlayElement.addEventListener('click', handleClickEvent);\n }\n return (): void => {\n enableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.removeEventListener('keydown', handleKeyboardEvent);\n overlayElement.removeEventListener('click', handleClickEvent);\n }\n };\n }, [props.disableCloseEvents]);\n\n useEffect(() => {\n dialogRef.current?.focus();\n }, []);\n\n const dialogClasses = cn(\n props.className,\n styles.modal,\n props.variant && styles[`modal--${props.variant}`],\n props.size && styles[`modal--${props.size}`],\n contentIsScrollable && !showActions && styles['modal--no-actions']\n );\n\n const titleClasses = cn({\n [styles['modal__title--error']]: props.variant === ModalVariants.error,\n [styles['modal__title--success']]: props.variant === ModalVariants.success,\n });\n\n const Component = (\n <div data-testid=\"dialog-container\">\n <div\n ref={overlayRef}\n className={styles['modal-overlay']}\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.Modal}\n style={{ zIndex: props.zIndex }}\n >\n <div className={styles.align}>\n <div\n className={dialogClasses}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n ref={dialogRef}\n >\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--top'], {\n [styles['modal__shadow--show']]: !topContentVisible && contentIsScrollable,\n })}\n />\n <div\n className={cn(styles.modal__contentWrapper, {\n [styles['modal__contentWrapper--image']]: imageView,\n })}\n ref={modalContentRef}\n >\n {!props.noCloseButton && (\n <div className={styles.modal__closeWrapper}>\n <div className={cn(styles.modal__closeWrapper__close)}>\n <Close onClick={props.onClose} ariaLabel={props.ariaLabelCloseBtn} />\n </div>\n </div>\n )}\n <div\n className={cn(props.size && styles[`modal__contentWrapper__scroll--${props.size}`], {\n [styles['modal__contentWrapper__scroll--image']]: imageView,\n })}\n >\n <div ref={topContent} />\n <div className={styles.modal__contentWrapper__title}>\n {getIcon(props.variant, props.icon)}\n <Title id={ariaLabelledBy} htmlMarkup=\"h3\" appearance=\"title3\" className={titleClasses}>\n {props.title}\n </Title>\n {props.afterTitleChildren && <div className={styles['modal__afterTitleChildren']}>{props.afterTitleChildren}</div>}\n </div>\n {imageView && (\n <div>\n <div className={styles['modal__contentWrapper__imageWrapper']}>{props.children}</div>\n <span className={styles['modal__contentWrapper__imageDescription']}>{props.description}</span>\n </div>\n )}\n {!imageView && props.children && <div>{props.children}</div>}\n {!imageView && !props.children && <p className={styles.modal__description}>{props.description}</p>}\n <div ref={bottomContent} />\n </div>\n </div>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--bottom'], {\n [styles['modal__shadow--show']]: !bottomContentVisible && contentIsScrollable,\n })}\n />\n {showActions && (\n <div className={cn(styles['modal__call-to-action'], props.size && styles[`modal__call-to-action--${props.size}`])}>\n {props.onSuccess && <Button onClick={props.onSuccess}>{props.primaryButtonText}</Button>}\n {props.secondaryButtonText && props.secondaryButtonText?.length > 0 && (\n <Button variant=\"borderless\" onClick={props.onClose}>\n {props.secondaryButtonText}\n </Button>\n )}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n\n if (props.printable) {\n const printModal = 'print-modal';\n return (\n <Portal className={printModal} testId=\"print-modal\">\n <style media=\"print\">{`body > *:not(.${printModal}) {display: none;}`}</style>\n {Component}\n </Portal>\n );\n }\n\n return Component;\n};\n\nModal.defaultProps = defaultProps;\n\nexport default Modal;\n"],"names":["ModalVariants","ModalSize","defaultProps","uuid","ZIndex","getVariantIcon","variant","React","Icon","IconSize","AlertSignFill","palette","AlertSignStroke","CheckOutline","getIcon","icon","variantIcon","styles","Modal","props","topContent","modalContentRef","dialogRef","useFocusTrap","topContentVisible","useIsVisible","bottomContent","bottomContentVisible","contentIsScrollable","handleKeyboardEvent","e","handleClickEvent","event","overlayRef","disableBodyScroll","enableBodyScroll","imageView","showActions","_a","ariaLabel","ariaLabelledBy","useEffect","overlayElement","dialogClasses","cn","titleClasses","Component","AnalyticsId","Close","Title","Button","_b","printModal","Portal"],"mappings":";;;;;;;;;;;;;;;;AAoBY,IAAAA,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,UAAU,WACVA,EAAA,QAAQ,SACRA,EAAA,UAAU,WACVA,EAAA,QAAQ,SALEA,IAAAA,KAAA,CAAA,CAAA,GAQAC,sBAAAA,OACVA,EAAA,QAAQ,SACRA,EAAA,SAAS,UAFCA,IAAAA,KAAA,CAAA,CAAA;AAkDZ,MAAMC,IAAe;AAAA,EACnB,SAAS;AAAA,EACT,mBAAmB;AAAA,EACnB,SAASC,EAAK;AAAA,EACd,WAAW;AAAA,EACX,MAAM;AAAA,EACN,QAAQC,EAAO;AACjB,GAEMC,IAAiB,CAACC,MAClBA,MAAY,UACPC,gBAAAA,EAAA,cAACC,KAAK,MAAMC,EAAS,OAAO,SAASC,GAAe,OAAOC,EAAQ,UAAW,CAAA,IAC5EL,MAAY,YACdC,gBAAAA,EAAA,cAACC,KAAK,MAAMC,EAAS,OAAO,SAASG,GAAiB,OAAOD,EAAQ,MAAO,CAAA,IAC1EL,MAAY,YACdC,gBAAAA,EAAA,cAACC,KAAK,MAAMC,EAAS,OAAO,SAASI,GAAc,OAAOF,EAAQ,QAAS,CAAA,IAE7E,MAGHG,IAAU,CAACR,GAAiCS,MAAkD;AAC5F,QAAAC,IAAcX,EAAeC,CAAO;AAC1C,SAAIU,IACMT,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAWU,EAAO,sBAAqBD,CAAY,IAE7DD,oCAEC,OAAI,EAAA,WAAWE,EAAO,sBACpBV,EAAM,aAAaQ,GAAM;AAAA,IACxB,MAAMN,EAAS;A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AAO,WAAWD,GAAY,QAAO,cACpC,GAAA7C,gBAAAA,EAAA,cAAC,SAAM,EAAA,OAAM,QAAS,GAAA,iBAAiB6C,CAAU,oBAAqB,GACrEN,CACH;AAAA,EAEJ;AAEO,SAAAA;AACT;AAEA5B,EAAM,eAAehB;"}
1
+ {"version":3,"file":"Modal.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport useFocusTrap from '../../hooks/useFocusTrap';\nimport { useIsVisible } from '../../hooks/useIsVisible';\nimport { palette } from '../../theme/palette';\nimport { uuid } from '../../utils/uuid';\nimport Button from '../Button';\nimport Close from '../Close';\nimport Icon, { IconSize } from '../Icon';\nimport AlertSignFill from '../Icons/AlertSignFill';\nimport AlertSignStroke from '../Icons/AlertSignStroke';\nimport CheckOutline from '../Icons/CheckOutline';\nimport Portal from '../Portal';\nimport Title from '../Title/Title';\n\nimport styles from './styles.module.scss';\n\nexport enum ModalVariants {\n normal = 'normal',\n warning = 'warning',\n error = 'error',\n success = 'success',\n image = 'image',\n}\n\nexport enum ModalSize {\n large = 'large',\n medium = 'medium',\n}\n\nexport interface ModalProps {\n /** Title of the modal */\n title: string;\n /** id of the modal title */\n titleId?: string;\n /** Description of the modal. Will not render if the modal has children. */\n description?: string;\n /** Changes the visual representation of the modal */\n variant?: keyof typeof ModalVariants;\n /** Change width of the modal (default: large) */\n size?: keyof typeof ModalSize;\n /** Icon displayed in title */\n icon?: React.ReactElement;\n /** Hides the close button */\n noCloseButton?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Primary button text */\n primaryButtonText?: string;\n /** Secondary button text */\n secondaryButtonText?: string;\n /** Sets the aria-label of the modal */\n ariaLabel?: string;\n /** Sets the aria-labelledby of the modal */\n ariaLabelledBy?: string;\n /** Close button aria-label */\n ariaLabelCloseBtn?: string;\n /** Alternative component to modal */\n children?: React.ReactNode;\n /** Component shown after title */\n afterTitleChildren?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Customize the z-index of the modal */\n zIndex?: number;\n /** Function is called when user clicks primary button */\n onSuccess?: () => void;\n /** Function is called when user clicks secondary button, clicks escape or outside the modal */\n onClose?: () => void;\n /** When enabled the component will be rendered in the bottom of document.body */\n printable?: boolean;\n /** If disabled, clicking escape or outside the modal will not close it */\n disableCloseEvents?: boolean;\n}\n\nconst getVariantIcon = (variant?: ModalProps['variant']): JSX.Element | null => {\n if (variant === ModalVariants.error) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignFill} color={palette.cherry500} />;\n } else if (variant === ModalVariants.warning) {\n return <Icon size={IconSize.Small} svgIcon={AlertSignStroke} color={palette.black} />;\n } else if (variant === ModalVariants.success) {\n return <Icon size={IconSize.Small} svgIcon={CheckOutline} color={palette.kiwi900} />;\n }\n return null;\n};\n\nconst getIcon = (variant?: ModalProps['variant'], icon?: ModalProps['icon']): JSX.Element | null => {\n const variantIcon = getVariantIcon(variant);\n if (variantIcon) {\n return <div className={styles.modal__iconWrapper}>{variantIcon}</div>;\n }\n if (icon) {\n return (\n <div className={styles.modal__iconWrapper}>\n {React.cloneElement(icon, {\n size: IconSize.Small,\n })}\n </div>\n );\n }\n return null;\n};\n\nconst Modal: React.FC<ModalProps> = props => {\n const {\n variant = ModalVariants.normal,\n primaryButtonText = 'OK',\n titleId = uuid(),\n className = '',\n size = ModalSize.large,\n zIndex = ZIndex.Modal,\n } = props;\n\n const topContent = React.useRef<HTMLDivElement>(null);\n const modalContentRef = React.useRef<HTMLDivElement>(null);\n const dialogRef = React.useRef<HTMLDivElement>(null);\n useFocusTrap(dialogRef, true);\n const topContentVisible = useIsVisible(topContent);\n const bottomContent = React.useRef<HTMLDivElement>(null);\n const bottomContentVisible = useIsVisible(bottomContent);\n const contentIsScrollable = modalContentRef.current && modalContentRef.current.scrollHeight > modalContentRef.current.clientHeight;\n\n function handleKeyboardEvent(e: KeyboardEvent): void {\n if (e.key === 'Escape' && props.onClose) {\n e.stopPropagation();\n props.onClose();\n }\n }\n\n function handleClickEvent(event: MouseEvent): void {\n if (event.target && overlayRef.current === event.target && props.onClose) {\n event.stopPropagation();\n props.onClose();\n }\n }\n\n function disableBodyScroll(): void {\n document.body.style.overflow = 'hidden';\n }\n\n function enableBodyScroll(): void {\n document.body.style.removeProperty('overflow');\n }\n\n /* Displays a full window size modal with image */\n const imageView = variant === ModalVariants.image;\n\n const overlayRef = React.useRef<HTMLDivElement>(null);\n\n const showActions = (props.secondaryButtonText && props.secondaryButtonText?.length > 0) || props.onSuccess;\n\n // ariaLabelledBy prioriteres over ariaLabel, men dersom ariaLabel brukes trengs ikke ariaLabelledBy\n const ariaLabel = !props.ariaLabelledBy ? props.ariaLabel : undefined;\n const ariaLabelledBy = props.ariaLabelledBy ? props.ariaLabelledBy : !props.ariaLabel ? titleId : undefined;\n\n useEffect(() => {\n const overlayElement = overlayRef.current;\n disableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.addEventListener('keydown', handleKeyboardEvent);\n overlayElement.addEventListener('click', handleClickEvent);\n }\n return (): void => {\n enableBodyScroll();\n if (!props.disableCloseEvents && overlayElement) {\n overlayElement.removeEventListener('keydown', handleKeyboardEvent);\n overlayElement.removeEventListener('click', handleClickEvent);\n }\n };\n }, [props.disableCloseEvents]);\n\n useEffect(() => {\n dialogRef.current?.focus();\n }, []);\n\n const dialogClasses = cn(\n className,\n styles.modal,\n variant && styles[`modal--${variant}`],\n size && styles[`modal--${size}`],\n contentIsScrollable && !showActions && styles['modal--no-actions']\n );\n\n const titleClasses = cn({\n [styles['modal__title--error']]: variant === ModalVariants.error,\n [styles['modal__title--success']]: variant === ModalVariants.success,\n });\n\n const Component = (\n <div data-testid=\"dialog-container\">\n <div\n ref={overlayRef}\n className={styles['modal-overlay']}\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.Modal}\n style={{ zIndex }}\n >\n <div className={styles.align}>\n <div\n className={dialogClasses}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n ref={dialogRef}\n >\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--top'], {\n [styles['modal__shadow--show']]: !topContentVisible && contentIsScrollable,\n })}\n />\n <div\n className={cn(styles.modal__contentWrapper, {\n [styles['modal__contentWrapper--image']]: imageView,\n })}\n tabIndex={contentIsScrollable ? 0 : undefined}\n role={contentIsScrollable ? 'region' : undefined}\n aria-label={contentIsScrollable ? ariaLabel : undefined}\n aria-labelledby={contentIsScrollable ? ariaLabelledBy : undefined}\n ref={modalContentRef}\n >\n {!props.noCloseButton && (\n <div className={styles.modal__closeWrapper}>\n <div className={cn(styles.modal__closeWrapper__close)}>\n <Close onClick={props.onClose} ariaLabel={props.ariaLabelCloseBtn} />\n </div>\n </div>\n )}\n <div\n className={cn(size && styles[`modal__contentWrapper__scroll--${size}`], {\n [styles['modal__contentWrapper__scroll--image']]: imageView,\n })}\n >\n <div ref={topContent} />\n <div className={styles.modal__contentWrapper__title}>\n {getIcon(variant, props.icon)}\n <Title id={ariaLabelledBy} htmlMarkup=\"h3\" appearance=\"title3\" className={titleClasses}>\n {props.title}\n </Title>\n {props.afterTitleChildren && <div className={styles['modal__afterTitleChildren']}>{props.afterTitleChildren}</div>}\n </div>\n {imageView && (\n <div>\n <div className={styles['modal__contentWrapper__imageWrapper']}>{props.children}</div>\n <span className={styles['modal__contentWrapper__imageDescription']}>{props.description}</span>\n </div>\n )}\n {!imageView && props.children && <div>{props.children}</div>}\n {!imageView && !props.children && <p className={styles.modal__description}>{props.description}</p>}\n <div ref={bottomContent} />\n </div>\n </div>\n <div\n className={cn(styles['modal__shadow'], styles['modal__shadow--bottom'], {\n [styles['modal__shadow--show']]: !bottomContentVisible && contentIsScrollable,\n })}\n />\n {showActions && (\n <div className={cn(styles['modal__call-to-action'], size && styles[`modal__call-to-action--${size}`])}>\n {props.onSuccess && <Button onClick={props.onSuccess}>{primaryButtonText}</Button>}\n {props.secondaryButtonText && props.secondaryButtonText?.length > 0 && (\n <Button variant=\"borderless\" onClick={props.onClose}>\n {props.secondaryButtonText}\n </Button>\n )}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n\n if (props.printable) {\n const printModal = 'print-modal';\n return (\n <Portal className={printModal} testId=\"print-modal\">\n <style media=\"print\">{`body > *:not(.${printModal}) {display: none;}`}</style>\n {Component}\n </Portal>\n );\n }\n\n return Component;\n};\n\nexport default Modal;\n"],"names":["ModalVariants","ModalSize","getVariantIcon","variant","React","Icon","IconSize","AlertSignFill","palette","AlertSignStroke","CheckOutline","getIcon","icon","variantIcon","styles","Modal","props","primaryButtonText","titleId","uuid","className","size","zIndex","ZIndex","topContent","modalContentRef","dialogRef","useFocusTrap","topContentVisible","useIsVisible","bottomContent","bottomContentVisible","contentIsScrollable","handleKeyboardEvent","e","handleClickEvent","event","overlayRef","disableBodyScroll","enableBodyScroll","imageView","showActions","_a","ariaLabel","ariaLabelledBy","useEffect","overlayElement","dialogClasses","cn","titleClasses","Component","AnalyticsId","Close","Title","Button","_b","printModal","Portal"],"mappings":";;;;;;;;;;;;;;;;AAoBY,IAAAA,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,UAAU,WACVA,EAAA,QAAQ,SACRA,EAAA,UAAU,WACVA,EAAA,QAAQ,SALEA,IAAAA,KAAA,CAAA,CAAA,GAQAC,sBAAAA,OACVA,EAAA,QAAQ,SACRA,EAAA,SAAS,UAFCA,IAAAA,KAAA,CAAA,CAAA;AAkDZ,MAAMC,IAAiB,CAACC,MAClBA,MAAY,UACPC,gBAAAA,EAAA,cAACC,KAAK,MAAMC,EAAS,OAAO,SAASC,GAAe,OAAOC,EAAQ,UAAW,CAAA,IAC5EL,MAAY,YACdC,gBAAAA,EAAA,cAACC,KAAK,MAAMC,EAAS,OAAO,SAASG,GAAiB,OAAOD,EAAQ,MAAO,CAAA,IAC1EL,MAAY,YACdC,gBAAAA,EAAA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wBC;AAAA,UAAA,CAC3D;AAAA,QAAA;AAAA,MACH;AAAA,MACCS,KACErC,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAW4C,EAAGlC,EAAO,uBAAuB,GAAGO,KAAQP,EAAO,0BAA0BO,CAAI,EAAE,CAAC,EACjG,GAAAL,EAAM,aAAcZ,gBAAAA,EAAA,cAAAkD,GAAA,EAAO,SAAStC,EAAM,aAAYC,CAAkB,GACxED,EAAM,yBAAuBuC,IAAAvC,EAAM,wBAAN,gBAAAuC,EAA2B,UAAS,KAC/DnD,gBAAAA,EAAA,cAAAkD,GAAA,EAAO,SAAQ,cAAa,SAAStC,EAAM,QACzC,GAAAA,EAAM,mBACT,CAEJ;AAAA,IAAA,CAGN;AAAA,EAAA,CAEJ;AAGF,MAAIA,EAAM,WAAW;AACnB,UAAMwC,IAAa;AACnB,WACGpD,gBAAAA,EAAA,cAAAqD,GAAA,EAAO,WAAWD,GAAY,QAAO,cACpC,GAAApD,gBAAAA,EAAA,cAAC,SAAM,EAAA,OAAM,QAAS,GAAA,iBAAiBoD,CAAU,oBAAqB,GACrEN,CACH;AAAA,EAEJ;AAEO,SAAAA;AACT;"}
@@ -144,13 +144,13 @@
144
144
  }
145
145
 
146
146
  &__closeWrapper {
147
+ position: relative;
148
+ width: 100%;
149
+
147
150
  @media print {
148
151
  display: none;
149
152
  }
150
153
 
151
- position: relative;
152
- width: 100%;
153
-
154
154
  &__close {
155
155
  position: absolute;
156
156
  right: getSpacer(3xs);
@@ -39,8 +39,6 @@ $layout-md-col-gap: getSpacer(m);
39
39
  }
40
40
 
41
41
  .panel {
42
- @include panel-padding;
43
-
44
42
  display: flex;
45
43
  flex-direction: column;
46
44
  justify-content: flex-start;
@@ -49,6 +47,8 @@ $layout-md-col-gap: getSpacer(m);
49
47
  width: 100%;
50
48
  box-sizing: border-box;
51
49
 
50
+ @include panel-padding;
51
+
52
52
  &__layout-1,
53
53
  &__layout-2,
54
54
  &__layout-3 {
@@ -19,11 +19,6 @@
19
19
  background-color: $white;
20
20
  z-index: 3;
21
21
  visibility: hidden;
22
-
23
- &--visible {
24
- visibility: visible;
25
- }
26
-
27
22
  border: getSpacer(4xs) solid $plum600;
28
23
  border-radius: 0.5625rem;
29
24
  box-shadow: 0 0.125rem 1.125rem 0 rgb(0 0 0 / 15%);
@@ -33,6 +28,10 @@
33
28
  line-height: $lineheight-size-md;
34
29
  }
35
30
 
31
+ &--visible {
32
+ visibility: visible;
33
+ }
34
+
36
35
  &__arrow {
37
36
  --drop-shadow-color: #{$plum600};
38
37
 
@@ -17,13 +17,13 @@ table .table-body .table-row {
17
17
  }
18
18
 
19
19
  @mixin block {
20
+ display: block;
21
+ clear: both;
22
+
20
23
  .table__head {
21
24
  display: none;
22
25
  }
23
26
 
24
- display: block;
25
- clear: both;
26
-
27
27
  .table-body,
28
28
  .table-row,
29
29
  .table__head-cell,
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "git+https://github.com/helsenorge/designsystem.git"
8
8
  },
9
9
  "homepage": "https://helsenorge.design",
10
- "version": "8.1.0",
10
+ "version": "8.1.1",
11
11
  "author": "Helsenorge",
12
12
  "license": "MIT",
13
13
  "peerDependencies": {
package/utils/refs.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @param refs array med refs som skal slås sammen
5
5
  * @returns refcallback som kan brukes på komponent
6
6
  */
7
- export declare const mergeRefs: <T>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>) => React.RefCallback<T>;
7
+ export declare const mergeRefs: <T>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T> | null | undefined>) => React.RefCallback<T>;
8
8
  /**
9
9
  * Sjekker om ref er et objekt (og ikke en funksjon)
10
10
  * @param ref
package/utils/refs.js CHANGED
@@ -1,10 +1,10 @@
1
- const o = (t) => (e) => {
2
- t.forEach((n) => {
3
- typeof n == "function" ? n(e) : n != null && (n.current = e);
1
+ const e = (n) => (o) => {
2
+ n.forEach((t) => {
3
+ typeof t == "function" ? t(o) : t != null && t !== void 0 && (t.current = o);
4
4
  });
5
- }, c = (t) => typeof t != "function" && t !== null;
5
+ }, c = (n) => typeof n != "function" && n !== null;
6
6
  export {
7
7
  c as isMutableRefObject,
8
- o as mergeRefs
8
+ e as mergeRefs
9
9
  };
10
10
  //# sourceMappingURL=refs.js.map
package/utils/refs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"refs.js","sources":["../../src/utils/refs.ts"],"sourcesContent":["/**\n * Slår sammen refs fra forwardRef og useRef slik at begge deler kan brukes\n * Fra https://github.com/gregberge/react-merge-refs\n * @param refs array med refs som skal slås sammen\n * @returns refcallback som kan brukes på komponent\n */\nexport const mergeRefs = <T>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>): React.RefCallback<T> => {\n return value => {\n refs.forEach(ref => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n });\n };\n};\n\n/**\n * Sjekker om ref er et objekt (og ikke en funksjon)\n * @param ref\n * @returns type predicate\n */\nexport const isMutableRefObject = <T>(ref: React.ForwardedRef<T>): ref is React.MutableRefObject<T> => {\n return typeof ref !== 'function' && ref !== null;\n};\n"],"names":["mergeRefs","refs","value","ref","isMutableRefObject"],"mappings":"AAMa,MAAAA,IAAY,CAAIC,MACpB,CAASC,MAAA;AACd,EAAAD,EAAK,QAAQ,CAAOE,MAAA;AACd,IAAA,OAAOA,KAAQ,aACjBA,EAAID,CAAK,IACAC,KAAO,SACfA,EAAyC,UAAUD;AAAA,EACtD,CACD;AAAA,GASQE,IAAqB,CAAID,MAC7B,OAAOA,KAAQ,cAAcA,MAAQ;"}
1
+ {"version":3,"file":"refs.js","sources":["../../src/utils/refs.ts"],"sourcesContent":["/**\n * Slår sammen refs fra forwardRef og useRef slik at begge deler kan brukes\n * Fra https://github.com/gregberge/react-merge-refs\n * @param refs array med refs som skal slås sammen\n * @returns refcallback som kan brukes på komponent\n */\nexport const mergeRefs = <T>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T> | null | undefined>): React.RefCallback<T> => {\n return value => {\n refs.forEach(ref => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null && ref !== undefined) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n });\n };\n};\n\n/**\n * Sjekker om ref er et objekt (og ikke en funksjon)\n * @param ref\n * @returns type predicate\n */\nexport const isMutableRefObject = <T>(ref: React.ForwardedRef<T>): ref is React.MutableRefObject<T> => {\n return typeof ref !== 'function' && ref !== null;\n};\n"],"names":["mergeRefs","refs","value","ref","isMutableRefObject"],"mappings":"AAMa,MAAAA,IAAY,CAAIC,MACpB,CAASC,MAAA;AACd,EAAAD,EAAK,QAAQ,CAAOE,MAAA;AACd,IAAA,OAAOA,KAAQ,aACjBA,EAAID,CAAK,IACAC,KAAO,QAAQA,MAAQ,WAC/BA,EAAyC,UAAUD;AAAA,EACtD,CACD;AAAA,GASQE,IAAqB,CAAID,MAC7B,OAAOA,KAAQ,cAAcA,MAAQ;"}