@helsenorge/designsystem-react 7.13.4 → 8.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +70 -3
  2. package/__mocks__/matchMedia.d.ts +1 -1
  3. package/components/Checkbox/Checkbox.js +47 -46
  4. package/components/Checkbox/Checkbox.js.map +1 -1
  5. package/components/Checkbox/styles.module.scss +101 -29
  6. package/components/Checkbox/styles.module.scss.d.ts +0 -1
  7. package/components/Chip/Chip.d.ts +31 -0
  8. package/components/Chip/Chip.js +30 -0
  9. package/components/Chip/Chip.js.map +1 -0
  10. package/components/Chip/index.d.ts +3 -0
  11. package/components/Chip/index.js +9 -0
  12. package/components/Chip/styles.module.scss +98 -0
  13. package/components/Chip/styles.module.scss.d.ts +21 -0
  14. package/components/ErrorWrapper/ErrorWrapper.js +5 -5
  15. package/components/ErrorWrapper/ErrorWrapper.js.map +1 -1
  16. package/components/ErrorWrapper/styles.module.scss +0 -5
  17. package/components/EyebrowHeader/EyebrowHeader.d.ts +17 -0
  18. package/components/EyebrowHeader/EyebrowHeader.js +12 -0
  19. package/components/EyebrowHeader/EyebrowHeader.js.map +1 -0
  20. package/components/EyebrowHeader/index.d.ts +3 -0
  21. package/components/EyebrowHeader/index.js +5 -0
  22. package/components/EyebrowHeader/styles.module.scss +5 -0
  23. package/components/FormGroup/styles.module.scss +3 -0
  24. package/components/GridExample/GridExample.d.ts +1 -0
  25. package/components/GridExample/GridExample.js.map +1 -1
  26. package/components/HelpPanel/HelpPanel.d.ts +2 -2
  27. package/components/HelpPanel/HelpPanel.js +10 -10
  28. package/components/HelpPanel/HelpPanel.js.map +1 -1
  29. package/components/{HighlightBox/HighlightBox.d.ts → HighlightPanel/HighlightPanel.d.ts} +10 -10
  30. package/components/HighlightPanel/HighlightPanel.js +61 -0
  31. package/components/HighlightPanel/HighlightPanel.js.map +1 -0
  32. package/components/HighlightPanel/index.d.ts +3 -0
  33. package/components/HighlightPanel/index.js +7 -0
  34. package/components/HighlightPanel/index.js.map +1 -0
  35. package/components/{HighlightBox → HighlightPanel}/styles.module.scss +17 -17
  36. package/components/HighlightPanel/styles.module.scss.d.ts +25 -0
  37. package/components/HorizontalScroll/HorizontalScroll.d.ts +1 -0
  38. package/components/HorizontalScroll/HorizontalScroll.js.map +1 -1
  39. package/components/NotificationPanel/NotificationPanel.d.ts +1 -1
  40. package/components/NotificationPanel/NotificationPanel.js +23 -23
  41. package/components/NotificationPanel/NotificationPanel.js.map +1 -1
  42. package/components/NotificationPanel/styles.module.scss +0 -14
  43. package/components/NotificationPanel/styles.module.scss.d.ts +0 -1
  44. package/components/RadioButton/RadioButton.js +42 -41
  45. package/components/RadioButton/RadioButton.js.map +1 -1
  46. package/components/RadioButton/styles.module.scss +41 -35
  47. package/components/ServiceMessage/ServiceMessage.js +25 -25
  48. package/components/ServiceMessage/ServiceMessage.js.map +1 -1
  49. package/components/ServiceMessage/styles.module.scss +0 -13
  50. package/components/ServiceMessage/styles.module.scss.d.ts +0 -1
  51. package/components/Tabs/Tabs.d.ts +1 -0
  52. package/components/Tabs/Tabs.js.map +1 -1
  53. package/components/Tag/Tag.d.ts +3 -9
  54. package/components/Tag/Tag.js +16 -42
  55. package/components/Tag/Tag.js.map +1 -1
  56. package/components/Tag/index.js +5 -6
  57. package/components/Tag/styles.module.scss +5 -105
  58. package/components/Tag/styles.module.scss.d.ts +0 -4
  59. package/components/TagList/TagList.d.ts +1 -0
  60. package/components/TagList/TagList.js.map +1 -1
  61. package/components/Tooltip/Tooltip.d.ts +4 -1
  62. package/components/Tooltip/Tooltip.js.map +1 -1
  63. package/components/Validation/Validation.d.ts +0 -5
  64. package/components/Validation/Validation.js +11 -12
  65. package/components/Validation/Validation.js.map +1 -1
  66. package/components/Validation/ValidationSummary.js +2 -2
  67. package/components/Validation/ValidationSummary.js.map +1 -1
  68. package/components/Validation/styles.module.scss +20 -14
  69. package/components/Validation/styles.module.scss.d.ts +5 -5
  70. package/constants.d.ts +5 -2
  71. package/constants.js +2 -2
  72. package/constants.js.map +1 -1
  73. package/package.json +3 -3
  74. package/scss/supernova/index.css +2 -2
  75. package/scss/supernova/styles/colors.css +1 -1
  76. package/utils/tests/setup-test.d.ts +1 -1
  77. package/_virtual/assert.js +0 -5
  78. package/_virtual/assert.js.map +0 -1
  79. package/_virtual/ast.js +0 -5
  80. package/_virtual/ast.js.map +0 -1
  81. package/_virtual/code.js +0 -5
  82. package/_virtual/code.js.map +0 -1
  83. package/_virtual/doctrine.js +0 -5
  84. package/_virtual/doctrine.js.map +0 -1
  85. package/_virtual/errors.js +0 -5
  86. package/_virtual/errors.js.map +0 -1
  87. package/_virtual/index.js +0 -5
  88. package/_virtual/inherits_browser.js +0 -5
  89. package/_virtual/inherits_browser.js.map +0 -1
  90. package/_virtual/keyword.js +0 -5
  91. package/_virtual/keyword.js.map +0 -1
  92. package/_virtual/typed.js +0 -5
  93. package/_virtual/typed.js.map +0 -1
  94. package/_virtual/types.js +0 -5
  95. package/_virtual/types.js.map +0 -1
  96. package/_virtual/util.js +0 -5
  97. package/_virtual/util.js.map +0 -1
  98. package/_virtual/utility.js +0 -5
  99. package/_virtual/utility.js.map +0 -1
  100. package/_virtual/utils.js +0 -5
  101. package/_virtual/utils.js.map +0 -1
  102. package/components/HighlightBox/HighlightBox.js +0 -61
  103. package/components/HighlightBox/HighlightBox.js.map +0 -1
  104. package/components/HighlightBox/index.d.ts +0 -3
  105. package/components/HighlightBox/index.js +0 -7
  106. package/components/HighlightBox/styles.module.scss.d.ts +0 -25
  107. /package/components/{HighlightBox → Chip}/index.js.map +0 -0
  108. /package/{_virtual → components/EyebrowHeader}/index.js.map +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,70 @@
1
+ ## [8.0.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.13.4&targetVersion=GTv8.0.0) (2024-08-13)
2
+
3
+ ## 8.0.0-beta.5 (2024-08-12)
4
+
5
+ ## 8.0.0-beta.4 (2024-08-12)
6
+
7
+ ## 8.0.0-beta.3 (2024-08-12)
8
+
9
+ ### Features
10
+
11
+ - ny komponent lightbox ([283c06d](https://github.com/helsenorge/designsystem/commit/283c06dd0eee42e174d76646a43edb6001e69f4c)), closes
12
+ [#318675](https://github.com/helsenorge/designsystem/issues/318675)
13
+
14
+ ### Bug Fixes
15
+
16
+ - **datepicker:** popup skal ha fast storrelse
17
+ ([5f7a5cf](https://github.com/helsenorge/designsystem/commit/5f7a5cfc460d3e779ede02cbdaa476dacdc8d4fb)), closes
18
+ [#328505](https://github.com/helsenorge/designsystem/issues/328505)
19
+ - **lightbox:** legg til bedre universell utforming
20
+ ([40ad870](https://github.com/helsenorge/designsystem/commit/40ad870b180911227ad058c056ea8c96d84bf2e6)), closes
21
+ [#329100](https://github.com/helsenorge/designsystem/issues/329100)
22
+
23
+ ## 8.0.0-beta.2 (2024-06-24)
24
+
25
+ ## 8.0.0-beta.1 (2024-06-24)
26
+
27
+ ## 8.0.0-beta.0 (2024-06-24)
28
+
29
+ ### Features
30
+
31
+ - fjern deprecated prop errorSummary
32
+ ([eed040f](https://github.com/helsenorge/designsystem/commit/eed040f5470c5c430098edb8171f3256f6b8b26d)), closes
33
+ [#324890](https://github.com/helsenorge/designsystem/issues/324890)
34
+ - fjern variant alert ([0da88f3](https://github.com/helsenorge/designsystem/commit/0da88f33e2584650f8c2d9428197f62bc4ad7fb2)), closes
35
+ [#325898](https://github.com/helsenorge/designsystem/issues/325898)
36
+ - flytt padding-bottom fra ErrorWrapper til Validation
37
+ ([f92a3d6](https://github.com/helsenorge/designsystem/commit/f92a3d6e724a34a75416df04ae7419b78028a2ab)), closes
38
+ [#324890](https://github.com/helsenorge/designsystem/issues/324890)
39
+ - react 18 ([7a99c2a](https://github.com/helsenorge/designsystem/commit/7a99c2a0fa265aad351b5bca415e5977aef197f2)), closes
40
+ [#327791](https://github.com/helsenorge/designsystem/issues/327791)
41
+ - rename highlightbox til highlightpanel
42
+ ([138beea](https://github.com/helsenorge/designsystem/commit/138beea5c249c71e5b47d931fa910e25c91a070f)), closes
43
+ [#318438](https://github.com/helsenorge/designsystem/issues/318438)
44
+ - splitt Tag-komponent til Tag og Chip
45
+ ([7bac3bb](https://github.com/helsenorge/designsystem/commit/7bac3bbd99e9e2a474193c8f4d05b6b299017e73)), closes
46
+ [#314597](https://github.com/helsenorge/designsystem/issues/314597)
47
+ - ta i bruk errorwrapper i checkbox og radiobutton
48
+ ([c91d997](https://github.com/helsenorge/designsystem/commit/c91d99712844f024c0056e819a49af0a339d8c6a)), closes
49
+ [#287874](https://github.com/helsenorge/designsystem/issues/287874)
50
+
51
+ ### Bug Fixes
52
+
53
+ - chip large too large ([6fe2f2e](https://github.com/helsenorge/designsystem/commit/6fe2f2e17b26647e72163775cae219cc5c00ae7c)), closes
54
+ [#314597](https://github.com/helsenorge/designsystem/issues/314597)
55
+ - feil skråstrek på chip ([253ed93](https://github.com/helsenorge/designsystem/commit/253ed9330142bd1b52afdccc9b59170ef4be0b84)), closes
56
+ [#314597](https://github.com/helsenorge/designsystem/issues/314597)
57
+ - merge conflicts ([1b40d65](https://github.com/helsenorge/designsystem/commit/1b40d6594e6f8cf1f5b2570560dd79f2482b98a3))
58
+
59
+ ## 7.0.1-beta.0 (2024-04-09)
60
+
61
+ ## [7.13.4](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.13.3&targetVersion=GTv7.13.4) (2024-07-25)
62
+
63
+ ### Bug Fixes
64
+
65
+ - **tabs:** fjern zindex ([312d337](https://github.com/helsenorge/designsystem/commit/312d3370b7f288b28e60e189c829eff82b5ce2ac)), closes
66
+ [#328176](https://github.com/helsenorge/designsystem/issues/328176)
67
+
1
68
  ## [7.13.3](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.13.2&targetVersion=GTv7.13.3) (2024-07-25)
2
69
 
3
70
  ### Bug Fixes
@@ -1587,12 +1654,12 @@ Dette er fordi vi skal kunne dynamisk importere alt som ligger i Icons, så da b
1587
1654
 
1588
1655
  ### Bug Fixes
1589
1656
 
1590
- - økt kontrast på understreking av lenker
1591
- ([50b7fa4](https://github.com/helsenorge/designsystem/commit/50b7fa47fb44cb7d75fb877bd53e2309b35e1e21)), closes
1592
- [#229049](https://github.com/helsenorge/designsystem/issues/229049)
1593
1657
  - panel har avstand fra tittel til badge
1594
1658
  ([09034c4](https://github.com/helsenorge/designsystem/commit/09034c4844408c7cfe8f65d7a1a0d82a7828c2ef)), closes
1595
1659
  [#282359](https://github.com/helsenorge/designsystem/issues/282359)
1660
+ - økt kontrast på understreking av lenker
1661
+ ([50b7fa4](https://github.com/helsenorge/designsystem/commit/50b7fa47fb44cb7d75fb877bd53e2309b35e1e21)), closes
1662
+ [#229049](https://github.com/helsenorge/designsystem/issues/229049)
1596
1663
 
1597
1664
  ## [1.2.2](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv1.2.1&targetVersion=GTv1.2.2) (2022-08-31)
1598
1665
 
@@ -1 +1 @@
1
- export declare const mockWindowMatchMedia: import("vitest").Mock<any, any>;
1
+ export declare const mockWindowMatchMedia: import("vitest").Mock<(...args: any[]) => any>;
@@ -1,12 +1,13 @@
1
- import l, { useState as H, useEffect as X } from "react";
2
- import t from "classnames";
3
- import { FormMode as i, FormSize as J, AnalyticsId as K, IconSize as Q } from "../../constants.js";
4
- import { usePseudoClasses as V } from "../../hooks/usePseudoClasses.js";
5
- import { useUuid as Y } from "../../hooks/useUuid.js";
6
- import { getColor as h } from "../../theme/currys/color.js";
7
- import { getAriaDescribedBy as Z } from "../../utils/accessibility.js";
8
- import { isMutableRefObject as $, mergeRefs as ee } from "../../utils/refs.js";
9
- import { uuid as ce } from "../../utils/uuid.js";
1
+ import l, { useState as G, useEffect as H } from "react";
2
+ import b from "classnames";
3
+ import { FormMode as t, FormSize as X, AnalyticsId as J, IconSize as K } from "../../constants.js";
4
+ import { usePseudoClasses as Q } from "../../hooks/usePseudoClasses.js";
5
+ import { useUuid as V } from "../../hooks/useUuid.js";
6
+ import { getColor as _ } from "../../theme/currys/color.js";
7
+ import { getAriaDescribedBy as Y } from "../../utils/accessibility.js";
8
+ import { isMutableRefObject as Z, mergeRefs as $ } from "../../utils/refs.js";
9
+ import { uuid as ee } from "../../utils/uuid.js";
10
+ import { ErrorWrapper as ce } from "../ErrorWrapper/ErrorWrapper.js";
10
11
  import { Icon as re } from "../Icon/Icon.js";
11
12
  import oe from "../Icons/Check.js";
12
13
  import { getLabelText as ae, renderLabelAsParent as le } from "../Label/Label.js";
@@ -14,92 +15,92 @@ import e from "../Checkbox/styles.module.scss";
14
15
  const ne = l.forwardRef((x, d) => {
15
16
  const {
16
17
  className: I,
17
- checked: k = !1,
18
+ checked: h = !1,
18
19
  disabled: a,
19
20
  label: m,
20
- inputId: p = ce(),
21
- mode: n = i.onwhite,
22
- name: N = p,
23
- size: E,
24
- errorText: s,
25
- error: g = !!s,
26
- errorTextId: S,
21
+ inputId: k = ee(),
22
+ mode: n = t.onwhite,
23
+ name: E = k,
24
+ size: N,
25
+ errorText: p,
26
+ error: g = !!p,
27
+ errorTextId: T,
27
28
  value: R = ae(m),
28
- testId: T,
29
+ testId: S,
29
30
  required: z,
30
31
  onChange: u,
31
32
  ...F
32
- } = x, [r, w] = H(k), f = Y(S), C = n === i.onwhite, y = n === i.ongrey, v = n === i.onblueberry, o = g || n === i.oninvalid, b = n === i.ondark, c = E === J.large, { refObject: L, isFocused: A } = V($(d) ? d : null), W = ee([d, L]), j = t(e["checkbox-wrapper"], {
33
- [e["checkbox-wrapper--with-error"]]: s,
33
+ } = x, [r, f] = G(h), w = V(T), C = n === t.onwhite, y = n === t.ongrey, v = n === t.onblueberry, o = g || n === t.oninvalid, i = n === t.ondark, c = N === X.large, { refObject: L, isFocused: W } = Q(Z(d) ? d : null), A = $([d, L]), j = b({
34
+ [e["checkbox-wrapper--with-error"]]: p,
34
35
  [e["checkbox-wrapper--large"]]: c
35
- }), B = t(e["checkbox-label"], {
36
+ }), B = b(e["checkbox-label"], {
36
37
  [e["checkbox-label--disabled"]]: a,
37
- [e["checkbox-label--on-dark"]]: b,
38
+ [e["checkbox-label--on-dark"]]: i,
38
39
  [e["checkbox-label--large"]]: c,
39
40
  [e["checkbox-label__large--checked"]]: c && r,
40
- [e["checkbox-label__large--focus"]]: c && A,
41
+ [e["checkbox-label__large--focus"]]: c && W,
41
42
  [e["checkbox-label__large--on-white"]]: c && C,
42
43
  [e["checkbox-label__large--on-grey"]]: c && y,
43
44
  [e["checkbox-label__large--on-blueberry"]]: c && v,
44
45
  [e["checkbox-label__large--on-invalid"]]: c && o,
45
46
  [e["checkbox-label__large--disabled"]]: c && a
46
- }), D = t(e.checkbox, I), M = t(e["checkbox__icon-wrapper"], {
47
+ }), D = b(e.checkbox, I), M = b(e["checkbox__icon-wrapper"], {
47
48
  [e["checkbox__icon-wrapper--on-white"]]: C,
48
49
  [e["checkbox__icon-wrapper--on-grey"]]: y,
49
50
  [e["checkbox__icon-wrapper--on-invalid"]]: o,
50
51
  [e["checkbox__icon-wrapper--disabled"]]: a,
51
52
  [e["checkbox__icon-wrapper__regular--checked"]]: !c && r,
52
53
  [e["checkbox__icon-wrapper__regular--invalid"]]: !c && r && o,
53
- [e["checkbox__icon-wrapper__regular--on-dark"]]: !c && r && b,
54
+ [e["checkbox__icon-wrapper__regular--on-dark"]]: !c && r && i,
54
55
  [e["checkbox__icon-wrapper__large--checked"]]: c && r,
55
56
  [e["checkbox__icon-wrapper__large--invalid"]]: c && o,
56
- [e["checkbox__icon-wrapper--on-dark"]]: b,
57
+ [e["checkbox__icon-wrapper--on-dark"]]: i,
57
58
  [e["checkbox__icon-wrapper--on-blueberry"]]: v,
58
59
  [e["checkbox__icon-wrapper--invalid"]]: o,
59
60
  [e["checkbox__icon-wrapper__large--invalid"]]: c && r && o,
60
61
  [e["checkbox__icon-wrapper__large--disabled"]]: a && c && r,
61
62
  [e["checkbox__icon-wrapper__large--checked--invalid"]]: c && r && o,
62
63
  [e["checkbox__icon-wrapper__large--checked--disabled"]]: a && c && r
63
- }), O = t(e["checkbox-label__text"], {
64
+ }), O = b(e["checkbox-label__text"], {
64
65
  [e["checkbox-label__text__large--checked"]]: c && r,
65
66
  [e["checkbox-label__text__large--invalid"]]: c && r && o,
66
- [e["checkbox-label__text--on-dark"]]: b,
67
+ [e["checkbox-label__text--on-dark"]]: i,
67
68
  [e["checkbox-label__text--disabled"]]: a
68
- }), P = t(e["checkbox-errors"]);
69
- let _ = h("white");
70
- (b || c && r) && (_ = h("blueberry", 900)), o && c && r && (_ = h("white")), a && (_ = h("neutral", 400)), X(() => {
71
- w(k);
72
- }, [k]);
73
- const U = (G) => {
74
- u && u(G), w(!r);
75
- }, q = () => /* @__PURE__ */ l.createElement(l.Fragment, null, /* @__PURE__ */ l.createElement(
69
+ });
70
+ let s = _("white");
71
+ (i || c && r) && (s = _("blueberry", 900)), o && c && r && (s = _("white")), a && (s = _("neutral", 700)), H(() => {
72
+ f(h);
73
+ }, [h]);
74
+ const P = (q) => {
75
+ u && u(q), f(!r);
76
+ }, U = () => /* @__PURE__ */ l.createElement(l.Fragment, null, /* @__PURE__ */ l.createElement(
76
77
  "input",
77
78
  {
78
- id: p,
79
- name: N,
79
+ id: k,
80
+ name: E,
80
81
  className: D,
81
82
  type: "checkbox",
82
83
  checked: r,
83
84
  disabled: a,
84
85
  value: R,
85
- ref: W,
86
- "aria-describedby": Z(x, f),
86
+ ref: A,
87
+ "aria-describedby": Y(x, w),
87
88
  "aria-invalid": g,
88
89
  required: z,
89
- onChange: U,
90
+ onChange: P,
90
91
  ...F
91
92
  }
92
- ), /* @__PURE__ */ l.createElement("span", { className: M }, r && /* @__PURE__ */ l.createElement(re, { color: _, className: e.checkbox__icon, svgIcon: oe, size: Q.XSmall })));
93
- return /* @__PURE__ */ l.createElement("div", { "data-testid": T, "data-analyticsid": K.Checkbox, className: j }, s && /* @__PURE__ */ l.createElement("p", { className: P, id: f }, s), le(
93
+ ), /* @__PURE__ */ l.createElement("span", { className: M }, r && /* @__PURE__ */ l.createElement(re, { color: s, className: e.checkbox__icon, svgIcon: oe, size: K.XSmall })));
94
+ return /* @__PURE__ */ l.createElement(ce, { errorText: p, errorTextId: w }, /* @__PURE__ */ l.createElement("div", { "data-testid": S, "data-analyticsid": J.Checkbox, className: j }, le(
94
95
  m,
95
- q(),
96
- p,
96
+ U(),
97
+ k,
97
98
  n,
98
99
  B,
99
100
  O,
100
101
  e["checkbox-sublabel-wrapper"],
101
102
  c
102
- ));
103
+ )));
103
104
  });
104
105
  ne.displayName = "Checkbox";
105
106
  export {
@@ -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 { 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"],"mappings":";;;;;;;;;;;;;AA0CO,MAAMA,KAAWC,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;A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WlB,EAC1E,GAAA3B,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,GAAS,cAAc;"}
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 ErrorWrapper from '../ErrorWrapper';\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({\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\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', 700);\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 <ErrorWrapper errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\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 </ErrorWrapper>\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","iconColor","getColor","useEffect","onChangeHandler","e","getLabelContent","getAriaDescribedBy","Icon","Check","IconSize","ErrorWrapper","AnalyticsId","renderLabelAsParent"],"mappings":";;;;;;;;;;;;;;AA2CO,MAAMA,KAAWC,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,IAAOC,EAAS;AAAA,IAChB,MAAAC,IAAOJ;AAAA,IACP,MAAAK;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC,IAAQ,CAAC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AA,IACAG;AAAA,IACAJ,EAAe,2BAA2B;AAAA,IAC1CV;AAAA,EAEJ,CAAA,CACF;AAEJ,CAAC;AAEDjC,GAAS,cAAc;"}
@@ -5,6 +5,86 @@
5
5
  @import '../../scss/font-settings';
6
6
  @import '../../scss/screen-reader';
7
7
 
8
+ @mixin dashed-dotted-border() {
9
+ box-shadow: none;
10
+
11
+ --dot-size: 2px;
12
+ --dash-length: 5px;
13
+ --gap-length: 2px;
14
+ --corner-gap: 2px;
15
+
16
+ background-image:
17
+ // Square dots at corners
18
+ linear-gradient($neutral600, $neutral600),
19
+ linear-gradient($neutral600, $neutral600),
20
+ linear-gradient($neutral600, $neutral600),
21
+ linear-gradient($neutral600, $neutral600),
22
+ // Dashed lines
23
+ repeating-linear-gradient(
24
+ 0deg,
25
+ $neutral600,
26
+ $neutral600 var(--dash-length),
27
+ transparent var(--dash-length),
28
+ transparent calc(var(--dash-length) + var(--gap-length))
29
+ ),
30
+ repeating-linear-gradient(
31
+ 90deg,
32
+ $neutral600,
33
+ $neutral600 var(--dash-length),
34
+ transparent var(--dash-length),
35
+ transparent calc(var(--dash-length) + var(--gap-length))
36
+ ),
37
+ repeating-linear-gradient(
38
+ 180deg,
39
+ $neutral600,
40
+ $neutral600 var(--dash-length),
41
+ transparent var(--dash-length),
42
+ transparent calc(var(--dash-length) + var(--gap-length))
43
+ ),
44
+ repeating-linear-gradient(
45
+ 270deg,
46
+ $neutral600,
47
+ $neutral600 var(--dash-length),
48
+ transparent var(--dash-length),
49
+ transparent calc(var(--dash-length) + var(--gap-length))
50
+ );
51
+ background-size:
52
+ // Top-left dot
53
+ var(--dot-size) var(--dot-size),
54
+ // Top-right dot
55
+ var(--dot-size) var(--dot-size),
56
+ // Bottom-right dot
57
+ var(--dot-size) var(--dot-size),
58
+ // Bottom-left dot
59
+ var(--dot-size) var(--dot-size),
60
+ // Left border
61
+ 2px calc(100% - var(--dot-size) * 2 - var(--corner-gap) * 2),
62
+ // Top border
63
+ calc(100% - var(--dot-size) * 2 - var(--corner-gap) * 2) 2px,
64
+ // Right border
65
+ 2px calc(100% - var(--dot-size) * 2 - var(--corner-gap) * 2),
66
+ // Bottom border
67
+ calc(100% - var(--dot-size) * 2 - var(--corner-gap) * 2) 2px;
68
+ background-position:
69
+ // Top-left dot
70
+ 0 0,
71
+ // Top-right dot
72
+ 100% 0,
73
+ // Bottom-right dot
74
+ 100% 100%,
75
+ // Bottom-left dot
76
+ 0 100%,
77
+ // Left border
78
+ 0 calc(var(--dot-size) + var(--corner-gap)),
79
+ // Top border
80
+ calc(var(--dot-size) + var(--corner-gap)) 0,
81
+ // Right border
82
+ 100% calc(var(--dot-size) + var(--corner-gap)),
83
+ // Bottom border
84
+ calc(var(--dot-size) + var(--corner-gap)) 100%;
85
+ background-repeat: no-repeat;
86
+ }
87
+
8
88
  $checkbox-icon-size: 1.625rem;
9
89
 
10
90
  .checkbox-errors {
@@ -15,8 +95,6 @@ $checkbox-icon-size: 1.625rem;
15
95
  }
16
96
 
17
97
  .checkbox-wrapper {
18
- margin: getSpacer(s) 0;
19
-
20
98
  &--with-error {
21
99
  padding: getSpacer(s) getSpacer(2xs) getSpacer(m);
22
100
  background-color: $cherry100;
@@ -36,14 +114,6 @@ $checkbox-icon-size: 1.625rem;
36
114
  }
37
115
  }
38
116
 
39
- .checkbox-wrapper:first-of-type {
40
- margin-top: 0;
41
- }
42
-
43
- .checkbox-wrapper:last-of-type {
44
- margin-bottom: 0;
45
- }
46
-
47
117
  .checkbox-label {
48
118
  display: flex;
49
119
  align-items: flex-start;
@@ -52,10 +122,6 @@ $checkbox-icon-size: 1.625rem;
52
122
  &__text {
53
123
  color: $black;
54
124
 
55
- &--on-dark {
56
- color: $white;
57
- }
58
-
59
125
  &__large {
60
126
  &--checked {
61
127
  color: $white;
@@ -71,6 +137,10 @@ $checkbox-icon-size: 1.625rem;
71
137
  &--disabled {
72
138
  color: $neutral700;
73
139
  }
140
+
141
+ &--on-dark {
142
+ color: $white;
143
+ }
74
144
  }
75
145
 
76
146
  &--disabled {
@@ -163,9 +233,11 @@ $checkbox-icon-size: 1.625rem;
163
233
  }
164
234
 
165
235
  &--checked#{&}--disabled {
236
+ color: $neutral700;
166
237
  background-color: $neutral50;
167
238
 
168
239
  :hover > & {
240
+ color: $neutral700;
169
241
  background-color: $neutral50;
170
242
  }
171
243
  }
@@ -252,16 +324,6 @@ $checkbox-icon-size: 1.625rem;
252
324
  }
253
325
  }
254
326
 
255
- &--disabled {
256
- color: $neutral600;
257
- background-color: $neutral50;
258
-
259
- :hover > & {
260
- box-shadow: 0 0 0 getSpacer(4xs);
261
- background-color: $neutral50;
262
- }
263
- }
264
-
265
327
  &__regular {
266
328
  &--checked {
267
329
  background-color: $blueberry500;
@@ -317,15 +379,26 @@ $checkbox-icon-size: 1.625rem;
317
379
  }
318
380
  &--checked#{&}--disabled {
319
381
  color: $neutral600;
320
- background-color: $neutral50;
321
- box-shadow: 0 0 0 getSpacer(4xs);
382
+ background-color: transparent;
322
383
 
323
384
  :hover > & {
324
- background-color: $neutral50;
325
- box-shadow: 0 0 0 getSpacer(4xs);
385
+ background-color: transparent;
326
386
  }
327
387
  }
328
388
  }
389
+
390
+ &--disabled,
391
+ &--disabled#{&}--invalid,
392
+ &--disabled#{&}--on-dark {
393
+ @include dashed-dotted-border;
394
+
395
+ background-color: transparent;
396
+
397
+ :hover > & {
398
+ box-shadow: none;
399
+ background-color: transparent;
400
+ }
401
+ }
329
402
  }
330
403
 
331
404
  &__icon {
@@ -368,7 +441,6 @@ $checkbox-icon-size: 1.625rem;
368
441
 
369
442
  &--disabled {
370
443
  color: $neutral700;
371
- background-color: $neutral50;
372
444
  }
373
445
  }
374
446
  }
@@ -37,7 +37,6 @@ export type Styles = {
37
37
  'checkbox-label--large': string;
38
38
  'checkbox-label--on-dark': string;
39
39
  'checkbox-sublabel-wrapper': string;
40
- 'checkbox-wrapper': string;
41
40
  'checkbox-wrapper--large': string;
42
41
  'checkbox-wrapper--with-error': string;
43
42
  };
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { PaletteNames } from '../../theme/palette';
3
+ export declare enum ChipSize {
4
+ medium = "medium",
5
+ large = "large"
6
+ }
7
+ export declare enum ChipAction {
8
+ remove = "remove",
9
+ undo = "undo"
10
+ }
11
+ export declare enum ChipVariant {
12
+ normal = "normal",
13
+ oncolor = "oncolor",
14
+ emphasised = "emphasised"
15
+ }
16
+ export type ChipColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'cherry' | 'banana' | 'kiwi' | 'plum'>;
17
+ export interface ChipProps {
18
+ /** Sets the text of the chip */
19
+ children: string;
20
+ /** Sets the size of the chip. Default: medium */
21
+ size?: keyof typeof ChipSize;
22
+ /** Sets the background of the chip. Not used if action is "undo". Default: blueberry */
23
+ color?: ChipColors;
24
+ variant?: keyof typeof ChipVariant;
25
+ action: keyof typeof ChipAction;
26
+ onClick: () => void;
27
+ /** Sets the data-testid attribute on the expander button. */
28
+ testId?: string;
29
+ }
30
+ declare const Chip: React.FC<ChipProps>;
31
+ export default Chip;
@@ -0,0 +1,30 @@
1
+ import m from "react";
2
+ import f from "classnames";
3
+ import { AnalyticsId as v, IconSize as h } from "../../constants.js";
4
+ import { useHover as I } from "../../hooks/useHover.js";
5
+ import { palette as g } from "../../theme/palette.js";
6
+ import { Icon as y } from "../Icon/Icon.js";
7
+ import b from "../Icons/Undo.js";
8
+ import $ from "../Icons/X.js";
9
+ import o from "../Chip/styles.module.scss";
10
+ var X = /* @__PURE__ */ ((e) => (e.medium = "medium", e.large = "large", e))(X || {}), z = /* @__PURE__ */ ((e) => (e.remove = "remove", e.undo = "undo", e))(z || {}), E = /* @__PURE__ */ ((e) => (e.normal = "normal", e.oncolor = "oncolor", e.emphasised = "emphasised", e))(E || {});
11
+ const T = (e) => {
12
+ const { children: n, size: a = "medium", color: r = "blueberry", variant: c = "normal", action: t, onClick: s, testId: i } = e, { hoverRef: l, isHovered: d } = I(), u = f(o.chip, o[`chip--${a}`], o[`chip--${r}`], o[`chip--${c}`], {
13
+ [o["chip--undo"]]: t === "undo"
14
+ }), p = () => {
15
+ switch (t) {
16
+ case "undo":
17
+ return b;
18
+ case "remove":
19
+ return $;
20
+ }
21
+ };
22
+ return /* @__PURE__ */ m.createElement("button", { className: u, onClick: s, ref: l, type: "button", "data-testid": i, "data-analyticsid": v.Tag }, n, /* @__PURE__ */ m.createElement(y, { svgIcon: p(), size: h.XXSmall, color: g[`${r}800`], isHovered: d }));
23
+ };
24
+ export {
25
+ z as ChipAction,
26
+ X as ChipSize,
27
+ E as ChipVariant,
28
+ T as default
29
+ };
30
+ //# sourceMappingURL=Chip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chip.js","sources":["../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { palette, PaletteNames } from '../../theme/palette';\nimport Icon, { IconSize, SvgIcon } from '../Icon';\nimport Undo from '../Icons/Undo';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport enum ChipSize {\n medium = 'medium',\n large = 'large',\n}\n\nexport enum ChipAction {\n remove = 'remove',\n undo = 'undo',\n}\n\nexport enum ChipVariant {\n normal = 'normal',\n oncolor = 'oncolor',\n emphasised = 'emphasised',\n}\n\nexport type ChipColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'cherry' | 'banana' | 'kiwi' | 'plum'>;\n\nexport interface ChipProps {\n /** Sets the text of the chip */\n children: string;\n /** Sets the size of the chip. Default: medium */\n size?: keyof typeof ChipSize;\n /** Sets the background of the chip. Not used if action is \"undo\". Default: blueberry */\n color?: ChipColors;\n /* Changes the appearance of the chip. Not used if action is \"undo\". Default: normal */\n variant?: keyof typeof ChipVariant;\n /* Makes the chip a clickable button that performs an action. onClick must also be set. */\n action: keyof typeof ChipAction;\n /* Called when action is set and the chip is clicked on. action must also be set. */\n onClick: () => void;\n /** Sets the data-testid attribute on the expander button. */\n testId?: string;\n}\n\nconst Chip: React.FC<ChipProps> = props => {\n const { children, size = ChipSize.medium, color = 'blueberry', variant = 'normal', action, onClick, testId } = props;\n\n const { hoverRef, isHovered } = useHover<HTMLButtonElement>();\n\n const chipClasses = cn(styles.chip, styles[`chip--${size}`], styles[`chip--${color}`], styles[`chip--${variant}`], {\n [styles[`chip--undo`]]: action === 'undo',\n });\n\n const getActionIcon = (): SvgIcon => {\n switch (action) {\n case 'undo':\n return Undo;\n case 'remove':\n return X;\n }\n };\n\n return (\n <button className={chipClasses} onClick={onClick} ref={hoverRef} type=\"button\" data-testid={testId} data-analyticsid={AnalyticsId.Tag}>\n {children}\n <Icon svgIcon={getActionIcon()} size={IconSize.XXSmall} color={palette[`${color}800`]} isHovered={isHovered} />\n </button>\n );\n};\n\nexport default Chip;\n"],"names":["ChipSize","ChipAction","ChipVariant","Chip","props","children","size","color","variant","action","onClick","testId","hoverRef","isHovered","useHover","chipClasses","cn","styles","getActionIcon","Undo","X","React","AnalyticsId","Icon","IconSize","palette"],"mappings":";;;;;;;;;AAaY,IAAAA,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,QAAQ,SAFEA,IAAAA,KAAA,CAAA,CAAA,GAKAC,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,OAAO,QAFGA,IAAAA,KAAA,CAAA,CAAA,GAKAC,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,UAAU,WACVA,EAAA,aAAa,cAHHA,IAAAA,KAAA,CAAA,CAAA;AAyBZ,MAAMC,IAA4B,CAASC,MAAA;AACnC,QAAA,EAAE,UAAAC,GAAU,MAAAC,IAAO,UAAiB,OAAAC,IAAQ,aAAa,SAAAC,IAAU,UAAU,QAAAC,GAAQ,SAAAC,GAAS,QAAAC,EAAA,IAAWP,GAEzG,EAAE,UAAAQ,GAAU,WAAAC,EAAU,IAAIC,EAA4B,GAEtDC,IAAcC,EAAGC,EAAO,MAAMA,EAAO,SAASX,CAAI,EAAE,GAAGW,EAAO,SAASV,CAAK,EAAE,GAAGU,EAAO,SAAST,CAAO,EAAE,GAAG;AAAA,IACjH,CAACS,EAAO,YAAY,CAAC,GAAGR,MAAW;AAAA,EAAA,CACpC,GAEKS,IAAgB,MAAe;AACnC,YAAQT,GAAQ;AAAA,MACd,KAAK;AACI,eAAAU;AAAA,MACT,KAAK;AACI,eAAAC;AAAA,IACX;AAAA,EAAA;AAGF,SACGC,gBAAAA,EAAA,cAAA,UAAA,EAAO,WAAWN,GAAa,SAAAL,GAAkB,KAAKE,GAAU,MAAK,UAAS,eAAaD,GAAQ,oBAAkBW,EAAY,OAC/HjB,GACAgB,gBAAAA,EAAA,cAAAE,GAAA,EAAK,SAASL,EAAiB,GAAA,MAAMM,EAAS,SAAS,OAAOC,EAAQ,GAAGlB,CAAK,KAAK,GAAG,WAAAM,EAAsB,CAAA,CAC/G;AAEJ;"}
@@ -0,0 +1,3 @@
1
+ import Chip from './Chip';
2
+ export * from './Chip';
3
+ export default Chip;
@@ -0,0 +1,9 @@
1
+ import p from "./Chip.js";
2
+ import { ChipAction as t, ChipSize as a, ChipVariant as e } from "./Chip.js";
3
+ export {
4
+ t as ChipAction,
5
+ a as ChipSize,
6
+ e as ChipVariant,
7
+ p as default
8
+ };
9
+ //# sourceMappingURL=index.js.map