@helsenorge/designsystem-react 7.3.1 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/components/Checkbox/Checkbox.js +24 -23
- package/components/Checkbox/Checkbox.js.map +1 -1
- package/components/HighlightBox/styles.module.scss +11 -7
- package/components/Input/Input.js +25 -24
- package/components/Input/Input.js.map +1 -1
- package/components/LinkList/LinkList.js +25 -24
- package/components/LinkList/LinkList.js.map +1 -1
- package/components/PopMenu/PopMenu.d.ts +12 -0
- package/components/PopMenu/PopMenu.js +74 -74
- package/components/PopMenu/PopMenu.js.map +1 -1
- package/components/PopMenu/PopMenu.stories.d.ts +7 -1
- package/components/PopMenu/index.js +3 -2
- package/components/PopMenu/styles.module.scss +1 -1
- package/components/PromoPanel/PromoPanel.stories.d.ts +1 -0
- package/components/RadioButton/RadioButton.js +27 -26
- package/components/RadioButton/RadioButton.js.map +1 -1
- package/components/Select/Select.js +23 -22
- package/components/Select/Select.js.map +1 -1
- package/components/ServiceMessage/ServiceMessage.stories.d.ts +1 -1
- package/components/Textarea/Textarea.js +34 -33
- package/components/Textarea/Textarea.js.map +1 -1
- package/package.json +1 -1
- package/scss/supernova/index.css +3 -0
- package/scss/supernova/styles/colors.css +173 -0
- package/utils/accessibility.d.ts +12 -0
- package/utils/accessibility.js +17 -8
- package/utils/accessibility.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [7.3.1](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.3.0&targetVersion=GTv7.3.1) (2024-04-22)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- arrow får egen klasse for å toggle visibility
|
|
6
|
+
([52525a4](https://github.com/helsenorge/designsystem/commit/52525a4d45b6b2e97ac553922fa1ec41032cc778)), closes
|
|
7
|
+
[#323182](https://github.com/helsenorge/designsystem/issues/323182)
|
|
8
|
+
- wrapperclassname fikser type ([fe42184](https://github.com/helsenorge/designsystem/commit/fe42184cc3bbffbcdc106def06a1a283f70bb32a))
|
|
9
|
+
|
|
1
10
|
## [7.3.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.2.1&targetVersion=GTv7.3.0) (2024-04-22)
|
|
2
11
|
|
|
3
12
|
### Features
|
|
@@ -4,11 +4,12 @@ import { FormMode as i, FormSize as J, AnalyticsId as K, IconSize as Q } from ".
|
|
|
4
4
|
import { usePseudoClasses as V } from "../../hooks/usePseudoClasses.js";
|
|
5
5
|
import { useUuid as Y } from "../../hooks/useUuid.js";
|
|
6
6
|
import { getColor as h } from "../../theme/currys/color.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import oe from "../
|
|
11
|
-
import
|
|
7
|
+
import { getAriaDescribedBy as Z } from "../../utils/accessibility.js";
|
|
8
|
+
import { isMutableRefObject as ee, mergeRefs as ce } from "../../utils/refs.js";
|
|
9
|
+
import { uuid as re } from "../../utils/uuid.js";
|
|
10
|
+
import { Icon as oe } from "../Icon/Icon.js";
|
|
11
|
+
import ae from "../Icons/Check.js";
|
|
12
|
+
import { getLabelText as le, renderLabelAsParent as ne } from "../Label/Label.js";
|
|
12
13
|
import e from "../Checkbox/styles.module.scss";
|
|
13
14
|
const I = l.forwardRef((x, d) => {
|
|
14
15
|
const {
|
|
@@ -16,22 +17,22 @@ const I = l.forwardRef((x, d) => {
|
|
|
16
17
|
checked: k = !1,
|
|
17
18
|
disabled: a,
|
|
18
19
|
label: m,
|
|
19
|
-
inputId: p =
|
|
20
|
+
inputId: p = re(),
|
|
20
21
|
mode: n = i.onwhite,
|
|
21
22
|
name: E = p,
|
|
22
23
|
size: S,
|
|
23
24
|
errorText: s,
|
|
24
25
|
error: g = !!s,
|
|
25
26
|
errorTextId: R,
|
|
26
|
-
value: T =
|
|
27
|
+
value: T = le(m),
|
|
27
28
|
testId: z,
|
|
28
29
|
required: F,
|
|
29
30
|
onChange: u,
|
|
30
31
|
...L
|
|
31
|
-
} = x, [r, w] = X(k), f = Y(R), C = n === i.onwhite, y = n === i.ongrey, v = n === i.onblueberry, o = g || n === i.oninvalid, b = n === i.ondark, c = S === J.large, { refObject:
|
|
32
|
+
} = x, [r, w] = X(k), f = Y(R), C = n === i.onwhite, y = n === i.ongrey, v = n === i.onblueberry, o = g || n === i.oninvalid, b = n === i.ondark, c = S === J.large, { refObject: A, isFocused: W } = V(ee(d) ? d : null), j = ce([d, A]), B = t(e["checkbox-wrapper"], {
|
|
32
33
|
[e["checkbox-wrapper--with-error"]]: s,
|
|
33
34
|
[e["checkbox-wrapper--large"]]: c
|
|
34
|
-
}),
|
|
35
|
+
}), D = t(e["checkbox-label"], {
|
|
35
36
|
[e["checkbox-label--disabled"]]: a,
|
|
36
37
|
[e["checkbox-label--on-dark"]]: b,
|
|
37
38
|
[e["checkbox-label--large"]]: c,
|
|
@@ -42,7 +43,7 @@ const I = l.forwardRef((x, d) => {
|
|
|
42
43
|
[e["checkbox-label__large--on-blueberry"]]: c && v,
|
|
43
44
|
[e["checkbox-label__large--on-invalid"]]: c && o,
|
|
44
45
|
[e["checkbox-label__large--disabled"]]: c && a
|
|
45
|
-
}),
|
|
46
|
+
}), M = t(e.checkbox, N), O = t(e["checkbox__icon-wrapper"], {
|
|
46
47
|
[e["checkbox__icon-wrapper--on-white"]]: C,
|
|
47
48
|
[e["checkbox__icon-wrapper--on-grey"]]: y,
|
|
48
49
|
[e["checkbox__icon-wrapper--on-invalid"]]: o,
|
|
@@ -59,51 +60,51 @@ const I = l.forwardRef((x, d) => {
|
|
|
59
60
|
[e["checkbox__icon-wrapper__large--disabled"]]: a && c && r,
|
|
60
61
|
[e["checkbox__icon-wrapper__large--checked--invalid"]]: c && r && o,
|
|
61
62
|
[e["checkbox__icon-wrapper__large--checked--disabled"]]: a && c && r
|
|
62
|
-
}),
|
|
63
|
+
}), P = t(e["checkbox-label__text"], {
|
|
63
64
|
[e["checkbox-label__text__large--checked"]]: c && r,
|
|
64
65
|
[e["checkbox-label__text__large--invalid"]]: c && r && o,
|
|
65
66
|
[e["checkbox-label__text--on-dark"]]: b,
|
|
66
67
|
[e["checkbox-label__text--disabled"]]: a
|
|
67
|
-
}),
|
|
68
|
+
}), U = t(e["checkbox-errors"]);
|
|
68
69
|
let _ = h("white");
|
|
69
70
|
(b || c && r) && (_ = h("blueberry", 900)), o && c && r && (_ = h("white")), a && (_ = h("neutral", 400)), $(() => {
|
|
70
71
|
w(k);
|
|
71
72
|
}, [k]);
|
|
72
|
-
const
|
|
73
|
+
const q = (H) => {
|
|
73
74
|
u && u(H), w(!r);
|
|
74
75
|
}, G = () => /* @__PURE__ */ l.createElement(l.Fragment, null, /* @__PURE__ */ l.createElement(
|
|
75
76
|
"input",
|
|
76
77
|
{
|
|
77
78
|
id: p,
|
|
78
79
|
name: E,
|
|
79
|
-
className:
|
|
80
|
+
className: M,
|
|
80
81
|
type: "checkbox",
|
|
81
82
|
checked: r,
|
|
82
83
|
disabled: a,
|
|
83
84
|
value: T,
|
|
84
|
-
ref:
|
|
85
|
-
"aria-describedby":
|
|
85
|
+
ref: j,
|
|
86
|
+
"aria-describedby": Z(x, f),
|
|
86
87
|
"aria-invalid": g,
|
|
87
88
|
required: F,
|
|
88
|
-
onChange:
|
|
89
|
+
onChange: q,
|
|
89
90
|
...L
|
|
90
91
|
}
|
|
91
|
-
), /* @__PURE__ */ l.createElement("span", { className:
|
|
92
|
-
return /* @__PURE__ */ l.createElement("div", { "data-testid": z, "data-analyticsid": K.Checkbox, className:
|
|
92
|
+
), /* @__PURE__ */ l.createElement("span", { className: O }, r && /* @__PURE__ */ l.createElement(oe, { color: _, className: e.checkbox__icon, svgIcon: ae, size: Q.XSmall })));
|
|
93
|
+
return /* @__PURE__ */ l.createElement("div", { "data-testid": z, "data-analyticsid": K.Checkbox, className: B }, s && /* @__PURE__ */ l.createElement("p", { className: U, id: f }, s), ne(
|
|
93
94
|
m,
|
|
94
95
|
G(),
|
|
95
96
|
p,
|
|
96
97
|
n,
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
D,
|
|
99
|
+
P,
|
|
99
100
|
e["checkbox-sublabel-wrapper"],
|
|
100
101
|
c
|
|
101
102
|
));
|
|
102
103
|
});
|
|
103
104
|
I.displayName = "Checkbox";
|
|
104
|
-
const
|
|
105
|
+
const we = I;
|
|
105
106
|
export {
|
|
106
107
|
I as Checkbox,
|
|
107
|
-
|
|
108
|
+
we as default
|
|
108
109
|
};
|
|
109
110
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormMode, FormSize, IconSize } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys/color';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport Icon from '../Icon';\nimport Check from '../Icons/Check';\nimport { getLabelText, renderLabelAsParent } from '../Label';\n\nimport checkboxStyles from './styles.module.scss';\n\nexport interface CheckboxProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the checkbox - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** input id of the checkbox */\n inputId?: string;\n /** Changes the visuals of the checkbox */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the checkbox */\n size?: keyof typeof FormSize;\n /** Activates Error style for the checkbox - This is can be true while errorText is empty, when in a FormGroup */\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}\n\nexport const Checkbox = React.forwardRef((props: CheckboxProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n checked = false,\n disabled,\n label,\n inputId = uuid(),\n mode = FormMode.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId,\n value = getLabelText(label),\n testId,\n required,\n onChange,\n ...rest\n } = props;\n const [isChecked, setIsChecked] = useState(checked);\n const errorTextUuid = useUuid(errorTextId);\n const onWhite = mode === FormMode.onwhite;\n const onGrey = mode === FormMode.ongrey;\n const onBlueberry = mode === FormMode.onblueberry;\n const onInvalid = error || mode === FormMode.oninvalid;\n const onDark = mode === FormMode.ondark;\n const large = size === FormSize.large;\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const checkboxWrapperClasses = classNames(checkboxStyles['checkbox-wrapper'], {\n [checkboxStyles['checkbox-wrapper--with-error']]: errorText,\n [checkboxStyles['checkbox-wrapper--large']]: large,\n });\n const checkboxLabelClasses = classNames(checkboxStyles['checkbox-label'], {\n [checkboxStyles['checkbox-label--disabled']]: disabled,\n [checkboxStyles['checkbox-label--on-dark']]: onDark,\n [checkboxStyles['checkbox-label--large']]: large,\n [checkboxStyles['checkbox-label__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__large--focus']]: large && isFocused,\n [checkboxStyles['checkbox-label__large--on-white']]: large && onWhite,\n [checkboxStyles['checkbox-label__large--on-grey']]: large && onGrey,\n [checkboxStyles['checkbox-label__large--on-blueberry']]: large && onBlueberry,\n [checkboxStyles['checkbox-label__large--on-invalid']]: large && onInvalid,\n [checkboxStyles['checkbox-label__large--disabled']]: large && disabled,\n });\n const checkboxClasses = classNames(checkboxStyles.checkbox, className);\n const checkboxIconWrapperClasses = classNames(checkboxStyles['checkbox__icon-wrapper'], {\n [checkboxStyles['checkbox__icon-wrapper--on-white']]: onWhite,\n [checkboxStyles['checkbox__icon-wrapper--on-grey']]: onGrey,\n [checkboxStyles['checkbox__icon-wrapper--on-invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--disabled']]: disabled,\n [checkboxStyles['checkbox__icon-wrapper__regular--checked']]: !large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__regular--invalid']]: !large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__regular--on-dark']]: !large && isChecked && onDark,\n [checkboxStyles['checkbox__icon-wrapper__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--on-dark']]: onDark,\n [checkboxStyles['checkbox__icon-wrapper--on-blueberry']]: onBlueberry,\n [checkboxStyles['checkbox__icon-wrapper--invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--disabled']]: disabled && large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--disabled']]: disabled && large && isChecked,\n });\n const labelTextClasses = classNames(checkboxStyles['checkbox-label__text'], {\n [checkboxStyles['checkbox-label__text__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__text__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox-label__text--on-dark']]: onDark,\n [checkboxStyles['checkbox-label__text--disabled']]: disabled,\n });\n const errorStyles = classNames(checkboxStyles['checkbox-errors']);\n\n let iconColor = getColor('white');\n if (onDark || (large && isChecked)) iconColor = getColor('blueberry', 900);\n if (onInvalid && large && isChecked) iconColor = getColor('white');\n if (disabled) iconColor = getColor('neutral', 400);\n\n useEffect(() => {\n setIsChecked(checked);\n }, [checked]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (onChange) {\n onChange(e);\n }\n\n setIsChecked(!isChecked);\n };\n\n const getLabelContent = (): React.ReactNode => {\n return (\n <>\n <input\n id={inputId}\n name={name}\n className={checkboxClasses}\n type=\"checkbox\"\n checked={isChecked}\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n aria-describedby={[props['aria-describedby'] || '', errorTextUuid].join(' ')}\n aria-invalid={error}\n required={required}\n onChange={onChangeHandler}\n {...rest}\n />\n <span className={checkboxIconWrapperClasses}>\n {isChecked && <Icon color={iconColor} className={checkboxStyles['checkbox__icon']} svgIcon={Check} size={IconSize.XSmall} />}\n </span>\n </>\n );\n };\n\n return (\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\n {errorText && (\n <p className={errorStyles} id={errorTextUuid}>\n {errorText}\n </p>\n )}\n {renderLabelAsParent(\n label,\n getLabelContent(),\n inputId,\n mode as FormMode,\n checkboxLabelClasses,\n labelTextClasses,\n checkboxStyles['checkbox-sublabel-wrapper'],\n large\n )}\n </div>\n );\n});\n\nCheckbox.displayName = 'Checkbox';\n\nexport default Checkbox;\n"],"names":["Checkbox","React","props","ref","className","checked","disabled","label","inputId","uuid","mode","FormMode","name","size","errorText","error","errorTextId","value","getLabelText","testId","required","onChange","rest","isChecked","setIsChecked","useState","errorTextUuid","useUuid","onWhite","onGrey","onBlueberry","onInvalid","onDark","large","FormSize","refObject","isFocused","usePseudoClasses","isMutableRefObject","mergedRefs","mergeRefs","checkboxWrapperClasses","classNames","checkboxStyles","checkboxLabelClasses","checkboxClasses","checkboxIconWrapperClasses","labelTextClasses","errorStyles","iconColor","getColor","useEffect","onChangeHandler","e","getLabelContent","Icon","Check","IconSize","AnalyticsId","renderLabelAsParent","Checkbox$1"],"mappings":";;;;;;;;;;;;AAyCO,MAAMA,IAAWC,EAAM,WAAW,CAACC,GAAsBC,MAAqC;AAC7F,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC,IAAUC,GAAK;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C,GAAQ,oBAAkBuC,EAAY,UAAU,WAAWjB,EAC1E,GAAA3B,qCACE,KAAE,EAAA,WAAWkC,GAAa,IAAItB,EAAA,GAC5BZ,CACH,GAED6C;AAAA,IACCpD;AAAA,IACA+C,EAAgB;AAAA,IAChB9C;AAAA,IACAE;AAAA,IACAkC;AAAA,IACAG;AAAA,IACAJ,EAAe,2BAA2B;AAAA,IAC1CV;AAAA,EAAA,CAEJ;AAEJ,CAAC;AAEDjC,EAAS,cAAc;AAEvB,MAAA4D,KAAe5D;"}
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormMode, FormSize, IconSize } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys/color';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport Icon from '../Icon';\nimport Check from '../Icons/Check';\nimport { getLabelText, renderLabelAsParent } from '../Label';\n\nimport checkboxStyles from './styles.module.scss';\n\nexport interface CheckboxProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the checkbox - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** input id of the checkbox */\n inputId?: string;\n /** Changes the visuals of the checkbox */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the checkbox */\n size?: keyof typeof FormSize;\n /** Activates Error style for the checkbox - This is can be true while errorText is empty, when in a FormGroup */\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}\n\nexport const Checkbox = React.forwardRef((props: CheckboxProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n checked = false,\n disabled,\n label,\n inputId = uuid(),\n mode = FormMode.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId,\n value = getLabelText(label),\n testId,\n required,\n onChange,\n ...rest\n } = props;\n const [isChecked, setIsChecked] = useState(checked);\n const errorTextUuid = useUuid(errorTextId);\n const onWhite = mode === FormMode.onwhite;\n const onGrey = mode === FormMode.ongrey;\n const onBlueberry = mode === FormMode.onblueberry;\n const onInvalid = error || mode === FormMode.oninvalid;\n const onDark = mode === FormMode.ondark;\n const large = size === FormSize.large;\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const checkboxWrapperClasses = classNames(checkboxStyles['checkbox-wrapper'], {\n [checkboxStyles['checkbox-wrapper--with-error']]: errorText,\n [checkboxStyles['checkbox-wrapper--large']]: large,\n });\n const checkboxLabelClasses = classNames(checkboxStyles['checkbox-label'], {\n [checkboxStyles['checkbox-label--disabled']]: disabled,\n [checkboxStyles['checkbox-label--on-dark']]: onDark,\n [checkboxStyles['checkbox-label--large']]: large,\n [checkboxStyles['checkbox-label__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__large--focus']]: large && isFocused,\n [checkboxStyles['checkbox-label__large--on-white']]: large && onWhite,\n [checkboxStyles['checkbox-label__large--on-grey']]: large && onGrey,\n [checkboxStyles['checkbox-label__large--on-blueberry']]: large && onBlueberry,\n [checkboxStyles['checkbox-label__large--on-invalid']]: large && onInvalid,\n [checkboxStyles['checkbox-label__large--disabled']]: large && disabled,\n });\n const checkboxClasses = classNames(checkboxStyles.checkbox, className);\n const checkboxIconWrapperClasses = classNames(checkboxStyles['checkbox__icon-wrapper'], {\n [checkboxStyles['checkbox__icon-wrapper--on-white']]: onWhite,\n [checkboxStyles['checkbox__icon-wrapper--on-grey']]: onGrey,\n [checkboxStyles['checkbox__icon-wrapper--on-invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--disabled']]: disabled,\n [checkboxStyles['checkbox__icon-wrapper__regular--checked']]: !large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__regular--invalid']]: !large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__regular--on-dark']]: !large && isChecked && onDark,\n [checkboxStyles['checkbox__icon-wrapper__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--on-dark']]: onDark,\n [checkboxStyles['checkbox__icon-wrapper--on-blueberry']]: onBlueberry,\n [checkboxStyles['checkbox__icon-wrapper--invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--disabled']]: disabled && large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--disabled']]: disabled && large && isChecked,\n });\n const labelTextClasses = classNames(checkboxStyles['checkbox-label__text'], {\n [checkboxStyles['checkbox-label__text__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__text__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox-label__text--on-dark']]: onDark,\n [checkboxStyles['checkbox-label__text--disabled']]: disabled,\n });\n const errorStyles = classNames(checkboxStyles['checkbox-errors']);\n\n let iconColor = getColor('white');\n if (onDark || (large && isChecked)) iconColor = getColor('blueberry', 900);\n if (onInvalid && large && isChecked) iconColor = getColor('white');\n if (disabled) iconColor = getColor('neutral', 400);\n\n useEffect(() => {\n setIsChecked(checked);\n }, [checked]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (onChange) {\n onChange(e);\n }\n\n setIsChecked(!isChecked);\n };\n\n const getLabelContent = (): React.ReactNode => {\n return (\n <>\n <input\n id={inputId}\n name={name}\n className={checkboxClasses}\n type=\"checkbox\"\n checked={isChecked}\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-invalid={error}\n required={required}\n onChange={onChangeHandler}\n {...rest}\n />\n <span className={checkboxIconWrapperClasses}>\n {isChecked && <Icon color={iconColor} className={checkboxStyles['checkbox__icon']} svgIcon={Check} size={IconSize.XSmall} />}\n </span>\n </>\n );\n };\n\n return (\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\n {errorText && (\n <p className={errorStyles} id={errorTextUuid}>\n {errorText}\n </p>\n )}\n {renderLabelAsParent(\n label,\n getLabelContent(),\n inputId,\n mode as FormMode,\n checkboxLabelClasses,\n labelTextClasses,\n checkboxStyles['checkbox-sublabel-wrapper'],\n large\n )}\n </div>\n );\n});\n\nCheckbox.displayName = 'Checkbox';\n\nexport default Checkbox;\n"],"names":["Checkbox","React","props","ref","className","checked","disabled","label","inputId","uuid","mode","FormMode","name","size","errorText","error","errorTextId","value","getLabelText","testId","required","onChange","rest","isChecked","setIsChecked","useState","errorTextUuid","useUuid","onWhite","onGrey","onBlueberry","onInvalid","onDark","large","FormSize","refObject","isFocused","usePseudoClasses","isMutableRefObject","mergedRefs","mergeRefs","checkboxWrapperClasses","classNames","checkboxStyles","checkboxLabelClasses","checkboxClasses","checkboxIconWrapperClasses","labelTextClasses","errorStyles","iconColor","getColor","useEffect","onChangeHandler","e","getLabelContent","getAriaDescribedBy","Icon","Check","IconSize","AnalyticsId","renderLabelAsParent","Checkbox$1"],"mappings":";;;;;;;;;;;;;AA0CO,MAAMA,IAAWC,EAAM,WAAW,CAACC,GAAsBC,MAAqC;AAC7F,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC,IAAUC,GAAK;AAAA,IACf,MAAAC,IA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B,qCACE,KAAE,EAAA,WAAWkC,GAAa,IAAItB,EAAA,GAC5BZ,CACH,GAED8C;AAAA,IACCrD;AAAA,IACA+C,EAAgB;AAAA,IAChB9C;AAAA,IACAE;AAAA,IACAkC;AAAA,IACAG;AAAA,IACAJ,EAAe,2BAA2B;AAAA,IAC1CV;AAAA,EAAA,CAEJ;AAEJ,CAAC;AAEDjC,EAAS,cAAc;AAEvB,MAAA6D,KAAe7D;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
@use 'sass:map';
|
|
2
2
|
@import '../../scss/spacers';
|
|
3
3
|
@import '../../scss/breakpoints';
|
|
4
|
-
@import '../../scss/palette';
|
|
5
4
|
@import '../../scss/grid';
|
|
6
5
|
@import '../../scss/screen-reader';
|
|
6
|
+
@import '../../scss/supernova/styles/colors';
|
|
7
7
|
|
|
8
8
|
@mixin content-wrapper-with-icon-flex {
|
|
9
9
|
display: flex;
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
@each $color in $colors {
|
|
34
34
|
&#{$box}--#{$color} {
|
|
35
35
|
#{$box}__content-wrapper {
|
|
36
|
-
background-color:
|
|
36
|
+
background-color: var(--color-base-background-#{$color});
|
|
37
|
+
border: 1px solid var(--color-base-border-#{$color});
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -41,7 +42,8 @@
|
|
|
41
42
|
// Hvit har sin egen regel siden den ikke har valører
|
|
42
43
|
&#{$box}--white {
|
|
43
44
|
#{$box}__content-wrapper {
|
|
44
|
-
background-color:
|
|
45
|
+
background-color: var(--color-base-background-white);
|
|
46
|
+
border: 1px solid var(--color-base-border-onlight-subtle);
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
}
|
|
@@ -52,14 +54,14 @@
|
|
|
52
54
|
@each $color in $colors {
|
|
53
55
|
&#{$box}--#{$color} {
|
|
54
56
|
@include media-breakpoint-down(xs) {
|
|
55
|
-
background-color:
|
|
57
|
+
background-color: var(--color-base-background-#{$color});
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
&#{$box}--white {
|
|
61
63
|
@include media-breakpoint-down(xs) {
|
|
62
|
-
background-color:
|
|
64
|
+
background-color: var(--color-base-background-white);
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
#{$box}__content-wrapper {
|
|
@@ -97,11 +99,13 @@
|
|
|
97
99
|
|
|
98
100
|
@each $color in $colors {
|
|
99
101
|
&#{$box}--#{$color} {
|
|
100
|
-
background-color:
|
|
102
|
+
background-color: var(--color-base-background-#{$color});
|
|
103
|
+
border: 1px solid var(--color-base-border-#{$color});
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
&#{$box}--white {
|
|
104
|
-
background-color:
|
|
107
|
+
background-color: var(--color-base-background-white);
|
|
108
|
+
border: 1px solid var(--color-base-border-onlight-subtle);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import r, { useRef as
|
|
1
|
+
import r, { useRef as D, useState as K, useEffect as Ce } from "react";
|
|
2
2
|
import v from "classnames";
|
|
3
|
-
import { FormMode as l, FormSize as _e, IconSize as
|
|
3
|
+
import { FormMode as l, FormSize as _e, IconSize as B, AnalyticsId as ve, AVERAGE_CHARACTER_WIDTH_PX as ye } from "../../constants.js";
|
|
4
4
|
import { useBreakpoint as Ee, Breakpoint as ke } from "../../hooks/useBreakpoint.js";
|
|
5
|
-
import { useUuid as
|
|
5
|
+
import { useUuid as U } from "../../hooks/useUuid.js";
|
|
6
6
|
import { getColor as F } from "../../theme/currys/color.js";
|
|
7
|
-
import we from "
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import Re from "../
|
|
11
|
-
import We from "../
|
|
7
|
+
import { getAriaDescribedBy as we } from "../../utils/accessibility.js";
|
|
8
|
+
import Ie from "../ErrorWrapper/ErrorWrapper.js";
|
|
9
|
+
import { Icon as Ne } from "../Icon/Icon.js";
|
|
10
|
+
import { renderLabel as Re } from "../Label/Label.js";
|
|
11
|
+
import We from "../LazyIcon/LazyIcon.js";
|
|
12
|
+
import Se from "../MaxCharacters/MaxCharacters.js";
|
|
12
13
|
import t from "../Input/styles.module.scss";
|
|
13
|
-
var
|
|
14
|
-
const
|
|
14
|
+
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 || {});
|
|
15
|
+
const Ae = (e, s, p) => {
|
|
15
16
|
const i = s ? "1.5rem" : "2rem", f = s ? `${p}px` : "0px";
|
|
16
17
|
return `calc(${e * ye}px + ${i} + ${f} + 4px)`;
|
|
17
18
|
}, L = r.forwardRef((e, s) => {
|
|
@@ -29,10 +30,10 @@ const ze = (e, s, p) => {
|
|
|
29
30
|
mode: c = l.onwhite,
|
|
30
31
|
size: X,
|
|
31
32
|
baseIncrementValue: y,
|
|
32
|
-
label:
|
|
33
|
-
error:
|
|
33
|
+
label: q,
|
|
34
|
+
error: G,
|
|
34
35
|
errorText: E,
|
|
35
|
-
errorTextId:
|
|
36
|
+
errorTextId: j,
|
|
36
37
|
testId: J,
|
|
37
38
|
disabled: u,
|
|
38
39
|
readOnly: Q,
|
|
@@ -47,11 +48,11 @@ const ze = (e, s, p) => {
|
|
|
47
48
|
maxCharacters: d,
|
|
48
49
|
maxText: ne,
|
|
49
50
|
...re
|
|
50
|
-
} = e, ae = Ee(), m =
|
|
51
|
+
} = e, ae = Ee(), m = D(null), N = U(H), [R, W] = K(i || ""), [oe, ie] = K(void 0), g = D(!1), S = U(j), z = /^[0-9]$/;
|
|
51
52
|
Ce(() => {
|
|
52
53
|
W(i || "");
|
|
53
54
|
}, [i]);
|
|
54
|
-
const ce = c === l.ondark, le = c === l.onblueberry, se = !!d && R.toString().length > d, x = c === l.oninvalid || !!E || !!
|
|
55
|
+
const ce = c === l.ondark, le = c === l.onblueberry, se = !!d && R.toString().length > d, x = c === l.oninvalid || !!E || !!G || se, C = X === _e.large, ue = P && c !== l.ondark && !x, de = v(t["input-wrapper"], p), me = v(t["input-container"], {
|
|
55
56
|
[t["input-container--transparent"]]: ue,
|
|
56
57
|
[t["input-container--on-blueberry"]]: le,
|
|
57
58
|
[t["input-container--on-dark"]]: ce,
|
|
@@ -62,9 +63,9 @@ const ze = (e, s, p) => {
|
|
|
62
63
|
}), pe = v(t["input-container__input"], {
|
|
63
64
|
[t["input-container__input--large"]]: C,
|
|
64
65
|
[t["input-container__input--disabled"]]: u
|
|
65
|
-
}),
|
|
66
|
+
}), A = u ? F("neutral", 700) : F("black"), _ = ae === ke.xs || !C ? B.XSmall : B.Small, V = () => {
|
|
66
67
|
if (a)
|
|
67
|
-
return typeof a == "string" ? /* @__PURE__ */ r.createElement(
|
|
68
|
+
return typeof a == "string" ? /* @__PURE__ */ r.createElement(We, { 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 });
|
|
68
69
|
}, fe = (n) => {
|
|
69
70
|
if (m && m.current && a) {
|
|
70
71
|
const o = b ? 0 : 1;
|
|
@@ -82,8 +83,8 @@ const ze = (e, s, p) => {
|
|
|
82
83
|
z.test(n.key) && (g.current = !0), I && I(n);
|
|
83
84
|
}, xe = (n) => {
|
|
84
85
|
z.test(n.key) && (g.current = !1);
|
|
85
|
-
},
|
|
86
|
-
return /* @__PURE__ */ r.createElement(
|
|
86
|
+
}, $ = k ? Ae(k, !!a, _) : void 0;
|
|
87
|
+
return /* @__PURE__ */ r.createElement(Ie, { errorText: E, errorTextId: S }, /* @__PURE__ */ r.createElement("div", { "data-testid": J, "data-analyticsid": ve.Input, className: de, ref: O }, Re(q, N, c), /* @__PURE__ */ r.createElement("div", { className: t["content-wrapper"] }, /* @__PURE__ */ r.createElement("div", { onClick: fe, ref: m, className: me, style: { maxWidth: $ } }, !b && V(), /* @__PURE__ */ r.createElement(
|
|
87
88
|
"input",
|
|
88
89
|
{
|
|
89
90
|
onChange: he,
|
|
@@ -96,7 +97,7 @@ const ze = (e, s, p) => {
|
|
|
96
97
|
className: pe,
|
|
97
98
|
ref: s,
|
|
98
99
|
"aria-labelledby": e["aria-labelledby"] ?? void 0,
|
|
99
|
-
"aria-describedby":
|
|
100
|
+
"aria-describedby": we(e, S),
|
|
100
101
|
"aria-invalid": !!x,
|
|
101
102
|
disabled: u,
|
|
102
103
|
placeholder: f,
|
|
@@ -106,12 +107,12 @@ const ze = (e, s, p) => {
|
|
|
106
107
|
autoFocus: te,
|
|
107
108
|
...re
|
|
108
109
|
}
|
|
109
|
-
), b &&
|
|
110
|
+
), b && V()), /* @__PURE__ */ r.createElement("div", { className: t["content-wrapper__right-of-input"] }, Z)), d && /* @__PURE__ */ r.createElement(Se, { maxCharacters: d, length: R.toString().length, maxText: ne, mode: c, maxWidth: $ }), Y));
|
|
110
111
|
});
|
|
111
112
|
L.displayName = "Input";
|
|
112
|
-
const
|
|
113
|
+
const Ge = L;
|
|
113
114
|
export {
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
ze as InputTypes,
|
|
116
|
+
Ge as default
|
|
116
117
|
};
|
|
117
118
|
//# 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 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={[props['aria-describedby'] || '', errorTextUuid].join(' ')}\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","MaxCharacters","Input$1"],"mappings":";;;;;;;;;;;;AAiFY,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,IAAQC,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,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,oBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,eAAAC;AAAA,IACA,SAAAC;AAAA,IACA,GAAGC;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ACChC,gBAAAA,EAAA,cAACkF,IAAc,EAAA,eAAAlD,GAA8B,QAAQS,EAAM,SAAS,EAAE,QAAQ,SAAAR,IAAkB,MAAApB,GAAY,UAAAiE,EAAoB,CAAA,GAEjIrD,CACH,CACF;AAEJ,CAAC;AAED1B,EAAM,cAAc;AAEpB,MAAAoF,KAAepF;"}
|
|
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","Input$1"],"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,E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,UAAAkB,OACpF,CAACpE,KAAawD,EACf,GAAAlE,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,UAAUwE;AAAA,MACV,WAAWI;AAAA,MACX,SAASC;AAAA,MACT,MAAAtE;AAAA,MACA,MAAAD;AAAA,MACA,cAAAF;AAAA,MACA,IAAImC;AAAA,MACJ,WAAWsB;AAAA,MACX,KAAA3D;AAAA,MACA,mBAAiBD,EAAM,iBAAiB,KAAK;AAAA,MAC7C,oBAAkBiF,GAAmBjF,GAAO8C,CAAa;AAAA,MACzD,gBAAc,CAAC,CAACM;AAAA,MAChB,UAAA/B;AAAA,MACA,aAAAjB;AAAA,MACA,UAAAkB;AAAA,MACA,cAAcC,KAAgB;AAAA,MAC9B,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,EAAM,cAAc;AAEpB,MAAAqF,KAAerF;"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import e from "react";
|
|
2
2
|
import u from "classnames";
|
|
3
|
-
import { AnalyticsId as
|
|
3
|
+
import { AnalyticsId as E } from "../../constants.js";
|
|
4
4
|
import { useHover as w } from "../../hooks/useHover.js";
|
|
5
|
-
import
|
|
6
|
-
import { renderListHeader as
|
|
5
|
+
import R from "../Icons/ChevronRight.js";
|
|
6
|
+
import { renderListHeader as b } from "../ListHeader/ListHeader.js";
|
|
7
7
|
import t from "../LinkList/styles.module.scss";
|
|
8
|
-
const
|
|
8
|
+
const L = e.forwardRef((_, r) => {
|
|
9
9
|
const {
|
|
10
10
|
children: s,
|
|
11
11
|
className: o = "",
|
|
12
12
|
color: c = "neutral",
|
|
13
|
-
icon:
|
|
13
|
+
icon: a,
|
|
14
14
|
size: i = "medium",
|
|
15
|
-
chevron:
|
|
15
|
+
chevron: l = !1,
|
|
16
16
|
linkRef: m,
|
|
17
17
|
testId: d,
|
|
18
18
|
target: n,
|
|
19
19
|
variant: f,
|
|
20
20
|
htmlMarkup: k = "a",
|
|
21
|
-
...
|
|
22
|
-
} =
|
|
21
|
+
...h
|
|
22
|
+
} = _, { hoverRef: v, isHovered: N } = w(m), C = u({
|
|
23
23
|
[t["link-list__list-item--line"]]: f === "line",
|
|
24
24
|
[t["link-list__list-item--outline"]]: f === "outline"
|
|
25
|
-
}),
|
|
25
|
+
}), y = u(
|
|
26
26
|
t["link-list__anchor"],
|
|
27
27
|
t[`link-list__anchor--${c}`],
|
|
28
28
|
{
|
|
@@ -32,29 +32,30 @@ const p = e.forwardRef((L, l) => {
|
|
|
32
32
|
},
|
|
33
33
|
o
|
|
34
34
|
);
|
|
35
|
-
return /* @__PURE__ */ e.createElement("li", { className: C, ref:
|
|
35
|
+
return /* @__PURE__ */ e.createElement("li", { className: C, ref: r, "data-testid": d, "data-analyticsid": E.Link }, k === "a" && /* @__PURE__ */ e.createElement(
|
|
36
36
|
"a",
|
|
37
37
|
{
|
|
38
|
-
className:
|
|
39
|
-
ref:
|
|
38
|
+
className: y,
|
|
39
|
+
ref: v,
|
|
40
40
|
rel: n === "_blank" ? "noopener noreferrer" : void 0,
|
|
41
41
|
target: n,
|
|
42
|
-
...
|
|
42
|
+
...h
|
|
43
43
|
},
|
|
44
|
-
|
|
45
|
-
), k === "button" && /* @__PURE__ */ e.createElement("button", { className:
|
|
46
|
-
}),
|
|
47
|
-
const { children: o, className: c = "", chevron:
|
|
48
|
-
return /* @__PURE__ */ e.createElement("ul", { ref: s, className: u(t["link-list"], c), "data-testid": m, "data-analyticsid":
|
|
49
|
-
if (n.type ===
|
|
50
|
-
return e.cloneElement(n, { color:
|
|
44
|
+
b(s, "span", N, i, l ? R : void 0, a)
|
|
45
|
+
), k === "button" && /* @__PURE__ */ e.createElement("button", { className: y, ref: v, type: "button", ...h }, b(s, "span", N, i, l ? R : void 0, a)));
|
|
46
|
+
}), p = e.forwardRef(function(r, s) {
|
|
47
|
+
const { children: o, className: c = "", chevron: a = !1, size: i = "medium", color: l, testId: m, variant: d = "line" } = r;
|
|
48
|
+
return /* @__PURE__ */ e.createElement("ul", { ref: s, className: u(t["link-list"], c), "data-testid": m, "data-analyticsid": E.LinkList }, e.Children.map(o, (n) => {
|
|
49
|
+
if (n.type === L)
|
|
50
|
+
return e.cloneElement(n, { color: l, size: i, chevron: a, variant: d });
|
|
51
51
|
}));
|
|
52
52
|
});
|
|
53
|
-
|
|
54
|
-
p.
|
|
55
|
-
|
|
53
|
+
p.displayName = "LinkList";
|
|
54
|
+
p.Link = L;
|
|
55
|
+
L.displayName = "LinkList.Link";
|
|
56
|
+
const F = p;
|
|
56
57
|
export {
|
|
57
|
-
|
|
58
|
+
p as LinkList,
|
|
58
59
|
F as default
|
|
59
60
|
};
|
|
60
61
|
//# sourceMappingURL=LinkList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkList.js","sources":["../../../src/components/LinkList/LinkList.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { PaletteNames } from '../../theme/palette';\nimport ChevronRight from '../Icons/ChevronRight';\nimport { ListHeaderType, renderListHeader } from '../ListHeader/ListHeader';\n\nimport LinkListStyles from './styles.module.scss';\n\nexport type LinkListSize = 'small' | 'medium' | 'large';\n\nexport type LinkAnchorTargets = '_self' | '_blank' | '_parent';\n\nexport type LinkListColors = PaletteNames;\nexport type LinkListVariant = 'line' | 'outline' | 'fill';\n\nexport interface LinkType extends React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLLIElement>> {\n ListHeader?: ListHeaderType;\n}\n\nexport type LinkTags = 'button' | 'a';\nexport interface CompoundComponent extends React.ForwardRefExoticComponent<LinkListProps & React.RefAttributes<HTMLUListElement>> {\n Link: LinkType;\n}\n\nexport interface LinkListProps {\n /** Items in the LinkList */\n children: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the link list background color on hover. */\n color?: LinkListColors;\n /** Toggles chevron icon on or off. */\n chevron?: boolean;\n /** Changes size of the LinkList. */\n size?: LinkListSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets visual priority */\n variant?: LinkListVariant;\n}\n\ntype Modify<T, R> = Omit<T, keyof R> & R;\n\nexport type LinkProps = Modify<\n React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>,\n {\n children: React.ReactNode;\n chevron?: boolean;\n className?: string;\n icon?: React.ReactElement;\n href?: string;\n target?: LinkAnchorTargets;\n /** HTML markup for link. Default: a */\n htmlMarkup?: LinkTags;\n /**\n * Ref for lenke/knapp\n */\n linkRef?: React.RefObject<HTMLButtonElement | HTMLAnchorElement>;\n /** Sets the data-testid attribute. */\n testId?: string;\n }\n> &\n Pick<LinkListProps, 'color' | 'size' | 'variant'>;\n\nconst Link: LinkType = React.forwardRef((props: LinkProps, ref: React.Ref<HTMLLIElement>) => {\n const {\n children,\n className = '',\n color = 'neutral',\n icon,\n size = 'medium',\n chevron = false,\n linkRef,\n testId,\n target,\n variant,\n htmlMarkup = 'a',\n ...restProps\n } = props;\n const { hoverRef, isHovered } = useHover<HTMLButtonElement | HTMLAnchorElement>(linkRef);\n\n const liClasses = cn({\n [LinkListStyles['link-list__list-item--line']]: variant === 'line',\n [LinkListStyles['link-list__list-item--outline']]: variant === 'outline',\n });\n const linkClasses = cn(\n LinkListStyles['link-list__anchor'],\n LinkListStyles[`link-list__anchor--${color}`],\n {\n [LinkListStyles['link-list__anchor--fill']]: variant === 'fill',\n [LinkListStyles[`link-list__anchor--${size}`]]: size,\n [LinkListStyles['link-list__anchor--button']]: htmlMarkup === 'button',\n },\n className\n );\n return (\n <li className={liClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Link}>\n {htmlMarkup === 'a' && (\n <a\n className={linkClasses}\n ref={hoverRef as React.RefObject<HTMLAnchorElement>}\n rel={target === '_blank' ? 'noopener noreferrer' : undefined}\n target={target}\n {...restProps}\n >\n {renderListHeader(children, 'span', isHovered, size, chevron ? ChevronRight : undefined, icon)}\n </a>\n )}\n {htmlMarkup === 'button' && (\n <button className={linkClasses} ref={hoverRef as React.RefObject<HTMLButtonElement>} type=\"button\" {...restProps}>\n {renderListHeader(children, 'span', isHovered, size, chevron ? ChevronRight : undefined, icon)}\n </button>\n )}\n </li>\n );\n});\n\nexport const LinkList = React.forwardRef(function LinkListForwardedRef(props: LinkListProps, ref: React.Ref<HTMLUListElement>) {\n const { children, className = '', chevron = false, size = 'medium', color, testId, variant = 'line' } = props;\n return (\n <ul ref={ref} className={cn(LinkListStyles['link-list'], className)} data-testid={testId} data-analyticsid={AnalyticsId.LinkList}>\n {React.Children.map(children, (child: React.ReactNode | React.ReactElement<LinkProps>) => {\n if ((child as React.ReactElement<LinkProps>).type === Link) {\n return React.cloneElement(child as React.ReactElement<LinkProps>, { color, size, chevron, variant });\n }\n })}\n </ul>\n );\n}) as CompoundComponent;\n\nLinkList.Link = Link;\nLink.displayName = 'LinkList.Link';\n\nexport default LinkList;\n"],"names":["Link","React","props","ref","children","className","color","icon","size","chevron","linkRef","testId","target","variant","htmlMarkup","restProps","hoverRef","isHovered","useHover","liClasses","cn","LinkListStyles","linkClasses","AnalyticsId","renderListHeader","ChevronRight","LinkList","child","LinkList$1"],"mappings":";;;;;;;AAoEA,MAAMA,IAAiBC,EAAM,WAAW,CAACC,GAAkBC,MAAkC;AACrF,QAAA;AAAA,IACJ,UAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,OAAAC,IAAQ;AAAA,IACR,MAAAC;A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lB,CAAI,CAC/F,CAEJ;AAEJ,CAAC,GAEYmB,IAAWzB,EAAM,WAAW,SAA8BC,GAAsBC,GAAkC;AAC7H,QAAM,EAAE,UAAAC,GAAU,WAAAC,IAAY,IAAI,SAAAI,IAAU,IAAO,MAAAD,IAAO,UAAU,OAAAF,GAAO,QAAAK,GAAQ,SAAAE,IAAU,OAAA,IAAWX;AAEtG,SAAAD,gBAAAA,EAAA,cAAC,QAAG,KAAAE,GAAU,WAAWiB,EAAGC,EAAe,WAAW,GAAGhB,CAAS,GAAG,eAAaM,GAAQ,oBAAkBY,EAAY,SACrH,GAAAtB,EAAM,SAAS,IAAIG,GAAU,CAACuB,MAA2D;AACnF,QAAAA,EAAwC,SAAS3B;AAC7C,aAAAC,EAAM,aAAa0B,GAAwC,EAAE,OAAArB,GAAO,MAAAE,GAAM,SAAAC,GAAS,SAAAI,GAAS;AAAA,EAEtG,CAAA,CACH;AAEJ,CAAC;AAEDa,EAAS,OAAO1B;AAChBA,EAAK,cAAc;AAEnB,MAAA4B,IAAeF;"}
|
|
1
|
+
{"version":3,"file":"LinkList.js","sources":["../../../src/components/LinkList/LinkList.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { PaletteNames } from '../../theme/palette';\nimport ChevronRight from '../Icons/ChevronRight';\nimport { ListHeaderType, renderListHeader } from '../ListHeader/ListHeader';\n\nimport LinkListStyles from './styles.module.scss';\n\nexport type LinkListSize = 'small' | 'medium' | 'large';\n\nexport type LinkAnchorTargets = '_self' | '_blank' | '_parent';\n\nexport type LinkListColors = PaletteNames;\nexport type LinkListVariant = 'line' | 'outline' | 'fill';\n\nexport interface LinkType extends React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLLIElement>> {\n ListHeader?: ListHeaderType;\n}\n\nexport type LinkTags = 'button' | 'a';\nexport interface CompoundComponent extends React.ForwardRefExoticComponent<LinkListProps & React.RefAttributes<HTMLUListElement>> {\n Link: LinkType;\n}\n\nexport interface LinkListProps {\n /** Items in the LinkList */\n children: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the link list background color on hover. */\n color?: LinkListColors;\n /** Toggles chevron icon on or off. */\n chevron?: boolean;\n /** Changes size of the LinkList. */\n size?: LinkListSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets visual priority */\n variant?: LinkListVariant;\n}\n\ntype Modify<T, R> = Omit<T, keyof R> & R;\n\nexport type LinkProps = Modify<\n React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>,\n {\n children: React.ReactNode;\n chevron?: boolean;\n className?: string;\n icon?: React.ReactElement;\n href?: string;\n target?: LinkAnchorTargets;\n /** HTML markup for link. Default: a */\n htmlMarkup?: LinkTags;\n /**\n * Ref for lenke/knapp\n */\n linkRef?: React.RefObject<HTMLButtonElement | HTMLAnchorElement>;\n /** Sets the data-testid attribute. */\n testId?: string;\n }\n> &\n Pick<LinkListProps, 'color' | 'size' | 'variant'>;\n\nconst Link: LinkType = React.forwardRef((props: LinkProps, ref: React.Ref<HTMLLIElement>) => {\n const {\n children,\n className = '',\n color = 'neutral',\n icon,\n size = 'medium',\n chevron = false,\n linkRef,\n testId,\n target,\n variant,\n htmlMarkup = 'a',\n ...restProps\n } = props;\n const { hoverRef, isHovered } = useHover<HTMLButtonElement | HTMLAnchorElement>(linkRef);\n\n const liClasses = cn({\n [LinkListStyles['link-list__list-item--line']]: variant === 'line',\n [LinkListStyles['link-list__list-item--outline']]: variant === 'outline',\n });\n const linkClasses = cn(\n LinkListStyles['link-list__anchor'],\n LinkListStyles[`link-list__anchor--${color}`],\n {\n [LinkListStyles['link-list__anchor--fill']]: variant === 'fill',\n [LinkListStyles[`link-list__anchor--${size}`]]: size,\n [LinkListStyles['link-list__anchor--button']]: htmlMarkup === 'button',\n },\n className\n );\n return (\n <li className={liClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Link}>\n {htmlMarkup === 'a' && (\n <a\n className={linkClasses}\n ref={hoverRef as React.RefObject<HTMLAnchorElement>}\n rel={target === '_blank' ? 'noopener noreferrer' : undefined}\n target={target}\n {...restProps}\n >\n {renderListHeader(children, 'span', isHovered, size, chevron ? ChevronRight : undefined, icon)}\n </a>\n )}\n {htmlMarkup === 'button' && (\n <button className={linkClasses} ref={hoverRef as React.RefObject<HTMLButtonElement>} type=\"button\" {...restProps}>\n {renderListHeader(children, 'span', isHovered, size, chevron ? ChevronRight : undefined, icon)}\n </button>\n )}\n </li>\n );\n});\n\nexport const LinkList = React.forwardRef(function LinkListForwardedRef(props: LinkListProps, ref: React.Ref<HTMLUListElement>) {\n const { children, className = '', chevron = false, size = 'medium', color, testId, variant = 'line' } = props;\n return (\n <ul ref={ref} className={cn(LinkListStyles['link-list'], className)} data-testid={testId} data-analyticsid={AnalyticsId.LinkList}>\n {React.Children.map(children, (child: React.ReactNode | React.ReactElement<LinkProps>) => {\n if ((child as React.ReactElement<LinkProps>).type === Link) {\n return React.cloneElement(child as React.ReactElement<LinkProps>, { color, size, chevron, variant });\n }\n })}\n </ul>\n );\n}) as CompoundComponent;\n\nLinkList.displayName = 'LinkList';\nLinkList.Link = Link;\nLink.displayName = 'LinkList.Link';\n\nexport default LinkList;\n"],"names":["Link","React","props","ref","children","className","color","icon","size","chevron","linkRef","testId","target","variant","htmlMarkup","restProps","hoverRef","isHovered","useHover","liClasses","cn","LinkListStyles","linkClasses","AnalyticsId","renderListHeader","ChevronRight","LinkList","child","LinkList$1"],"mappings":";;;;;;;AAoEA,MAAMA,IAAiBC,EAAM,WAAW,CAACC,GAAkBC,MAAkC;AACrF,QAAA;AAAA,IACJ,UAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,OAAAC,IAAQ;AAAA,IACR,MAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,SAAAC,IAAU;AAAA,IACV,SAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,SAA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,GAAU,WAAAC,IAAY,IAAI,SAAAI,IAAU,IAAO,MAAAD,IAAO,UAAU,OAAAF,GAAO,QAAAK,GAAQ,SAAAE,IAAU,OAAA,IAAWX;AAEtG,SAAAD,gBAAAA,EAAA,cAAC,QAAG,KAAAE,GAAU,WAAWiB,EAAGC,EAAe,WAAW,GAAGhB,CAAS,GAAG,eAAaM,GAAQ,oBAAkBY,EAAY,SACrH,GAAAtB,EAAM,SAAS,IAAIG,GAAU,CAACuB,MAA2D;AACnF,QAAAA,EAAwC,SAAS3B;AAC7C,aAAAC,EAAM,aAAa0B,GAAwC,EAAE,OAAArB,GAAO,MAAAE,GAAM,SAAAC,GAAS,SAAAI,GAAS;AAAA,EAEtG,CAAA,CACH;AAEJ,CAAC;AAEDa,EAAS,cAAc;AACvBA,EAAS,OAAO1B;AAChBA,EAAK,cAAc;AAEnB,MAAA4B,IAAeF;"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { SvgIcon } from '../Icon';
|
|
3
|
+
import { IconName } from '../Icons/IconNames';
|
|
2
4
|
import { LinkListProps } from '../LinkList';
|
|
3
5
|
export declare enum PopMenuVariant {
|
|
4
6
|
onWhite = "on-white",
|
|
5
7
|
onGray = "on-gray",
|
|
6
8
|
onBlueberry = "on-blueberry"
|
|
7
9
|
}
|
|
10
|
+
export declare enum PopMenuLabelPosition {
|
|
11
|
+
right = "right",
|
|
12
|
+
left = "left"
|
|
13
|
+
}
|
|
8
14
|
export interface PopMenuProps {
|
|
9
15
|
/** Content shown inside PopOver. Can only be a LinkList */
|
|
10
16
|
children: React.ReactElement<LinkListProps>;
|
|
@@ -24,6 +30,12 @@ export interface PopMenuProps {
|
|
|
24
30
|
openButtonAriaLabel?: string;
|
|
25
31
|
/** Sets the arial-label attribute for the closeButton. */
|
|
26
32
|
closeButtonAriaLabel?: string;
|
|
33
|
+
/** Sets the icon on the trigger button. */
|
|
34
|
+
svgIcon?: SvgIcon | IconName;
|
|
35
|
+
/** Optional text next to the trigger button. */
|
|
36
|
+
labelText?: string;
|
|
37
|
+
/** Placement of the label text relative to the trigger button. */
|
|
38
|
+
labelTextPosition?: PopMenuLabelPosition;
|
|
27
39
|
}
|
|
28
40
|
export declare const PopMenu: React.FC<PopMenuProps>;
|
|
29
41
|
export default PopMenu;
|