@navikt/ds-react 0.13.0 → 0.14.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.
Files changed (67) hide show
  1. package/cjs/form/Fieldset/Fieldset.js +6 -3
  2. package/cjs/form/Select.js +5 -2
  3. package/cjs/form/TextField.js +8 -3
  4. package/cjs/form/Textarea.js +5 -2
  5. package/cjs/form/checkbox/Checkbox.js +9 -8
  6. package/cjs/form/checkbox/useCheckbox.js +2 -1
  7. package/cjs/form/radio/Radio.js +8 -14
  8. package/cjs/form/radio/useRadio.js +2 -1
  9. package/cjs/form/search-field/SearchField.js +5 -2
  10. package/cjs/loader/Loader.js +1 -1
  11. package/esm/form/Fieldset/Fieldset.js +7 -4
  12. package/esm/form/Fieldset/Fieldset.js.map +1 -1
  13. package/esm/form/Select.js +5 -2
  14. package/esm/form/Select.js.map +1 -1
  15. package/esm/form/TextField.js +9 -4
  16. package/esm/form/TextField.js.map +1 -1
  17. package/esm/form/Textarea.js +5 -2
  18. package/esm/form/Textarea.js.map +1 -1
  19. package/esm/form/checkbox/Checkbox.d.ts +6 -1
  20. package/esm/form/checkbox/Checkbox.js +10 -9
  21. package/esm/form/checkbox/Checkbox.js.map +1 -1
  22. package/esm/form/checkbox/CheckboxGroup.d.ts +1 -1
  23. package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
  24. package/esm/form/checkbox/useCheckbox.js +2 -1
  25. package/esm/form/checkbox/useCheckbox.js.map +1 -1
  26. package/esm/form/radio/Radio.d.ts +4 -1
  27. package/esm/form/radio/Radio.js +9 -15
  28. package/esm/form/radio/Radio.js.map +1 -1
  29. package/esm/form/radio/RadioGroup.d.ts +1 -1
  30. package/esm/form/radio/RadioGroup.js.map +1 -1
  31. package/esm/form/radio/useRadio.js +2 -1
  32. package/esm/form/radio/useRadio.js.map +1 -1
  33. package/esm/form/search-field/SearchField.js +5 -2
  34. package/esm/form/search-field/SearchField.js.map +1 -1
  35. package/esm/loader/Loader.js +1 -1
  36. package/esm/loader/Loader.js.map +1 -1
  37. package/package.json +5 -4
  38. package/src/form/Fieldset/Fieldset.tsx +25 -12
  39. package/src/form/Select.tsx +5 -1
  40. package/src/form/TextField.tsx +30 -11
  41. package/src/form/Textarea.tsx +5 -1
  42. package/src/form/checkbox/Checkbox.tsx +30 -37
  43. package/src/form/checkbox/CheckboxGroup.tsx +2 -1
  44. package/src/form/checkbox/stories/checkbox.stories.mdx +17 -45
  45. package/src/form/checkbox/stories/checkbox.stories.tsx +55 -82
  46. package/src/form/checkbox/useCheckbox.ts +5 -1
  47. package/src/form/radio/Radio.tsx +26 -40
  48. package/src/form/radio/RadioGroup.tsx +2 -1
  49. package/src/form/radio/stories/radio.stories.mdx +3 -29
  50. package/src/form/radio/stories/radio.stories.tsx +33 -61
  51. package/src/form/radio/useRadio.ts +5 -1
  52. package/src/form/search-field/SearchField.tsx +5 -1
  53. package/src/form/search-field/stories/search-field.stories.tsx +25 -1
  54. package/src/form/stories/fieldset.stories.tsx +6 -2
  55. package/src/form/stories/select.stories.tsx +1 -1
  56. package/src/form/stories/text-field.stories.tsx +23 -1
  57. package/src/form/stories/textarea.stories.tsx +12 -2
  58. package/src/grid/stories/grid.stories.mdx +3 -3
  59. package/src/guide-panel/stories/example.css +4 -4
  60. package/src/guide-panel/stories/guidepanel.stories.mdx +7 -7
  61. package/src/guide-panel/stories/guidepanel.stories.tsx +6 -6
  62. package/src/loader/Loader.tsx +1 -1
  63. package/src/loader/stories/loader.stories.mdx +0 -16
  64. package/src/popover/stories/popover.stories.tsx +1 -1
  65. package/src/speech-bubble/stories/speechbubble.stories.mdx +4 -4
  66. package/src/speech-bubble/stories/speechbubble.stories.tsx +2 -2
  67. package/src/typography/stories/index.css +1 -1
@@ -21,11 +21,14 @@ export const SearchFieldContext = React.createContext(null);
21
21
  const SearchField = forwardRef((props, ref) => {
22
22
  const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = useFormField(props, "searchfield");
23
23
  const { className, hideLabel, children, label, description, error } = props, rest = __rest(props, ["className", "hideLabel", "children", "label", "description", "error"]);
24
- return (React.createElement("div", Object.assign({ ref: ref }, omit(rest, ["id", "error", "errorId", "size", "disabled"]), { className: cl(className, "navds-form-field", `navds-form-field--${size !== null && size !== void 0 ? size : "medium"}`, "navds-search-field", { "navds-search-field--error": hasError }) }),
24
+ return (React.createElement("div", Object.assign({ ref: ref }, omit(rest, ["id", "error", "errorId", "size", "disabled"]), { className: cl(className, "navds-form-field", `navds-form-field--${size !== null && size !== void 0 ? size : "medium"}`, "navds-search-field", {
25
+ "navds-search-field--error": hasError,
26
+ "navds-search-field--disabled": !!inputProps.disabled,
27
+ }) }),
25
28
  React.createElement(Label, { htmlFor: inputProps.id, size: size, as: "label", className: cl("navds-text-field__label", {
26
29
  "sr-only": hideLabel,
27
30
  }) }, label),
28
- !!description && (React.createElement(BodyShort, { className: cl("navds-text-field__description", {
31
+ !!description && (React.createElement(BodyShort, { as: "div", className: cl("navds-text-field__description", {
29
32
  "sr-only": hideLabel,
30
33
  }), id: inputDescriptionId, size: size }, description)),
31
34
  React.createElement("div", { className: "navds-search-field__input-wrapper" },
@@ -1 +1 @@
1
- {"version":3,"file":"SearchField.js","sourceRoot":"","sources":["../../../src/form/search-field/SearchField.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAkB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,iBAA4C,MAAM,qBAAqB,CAAC;AAC/E,OAAO,sBAEN,MAAM,0BAA0B,CAAC;AAClC,OAAO,gBAA0C,MAAM,oBAAoB,CAAC;AAY5E,MAAM,CAAC,MAAM,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AAC,KAAK,GAAG,sBAAsB,CAAC;AAC3C,WAAW,CAAC,KAAK,GAAG,gBAAgB,CAAC;AAErC,eAAe,WAAW,CAAC"}
@@ -20,7 +20,7 @@ const Loader = forwardRef((_a, ref) => {
20
20
  }), focusable: "false", viewBox: "0 0 50 50", preserveAspectRatio: "xMidYMid" }, rest),
21
21
  React.createElement("title", { id: id !== null && id !== void 0 ? id : `loader-${internalId}` }, title),
22
22
  React.createElement("circle", { className: "navds-loader__background", xmlns: "http://www.w3.org/2000/svg", cx: "25", cy: "25", r: "20", fill: "none", strokeWidth: "5" }),
23
- React.createElement("circle", { className: "navds-loader__foreground", cx: "25", cy: "25", r: "20", stroke: "var(--navds-color-gray-40)", fill: "none", strokeWidth: "5", strokeDasharray: "50 155", strokeLinecap: "round" })));
23
+ React.createElement("circle", { className: "navds-loader__foreground", cx: "25", cy: "25", r: "20", stroke: "var(--navds-global-color-gray-400)", fill: "none", strokeWidth: "5", strokeDasharray: "50 155", strokeLinecap: "round" })));
24
24
  });
25
25
  export default Loader;
26
26
  //# sourceMappingURL=Loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Loader.js","sourceRoot":"","sources":["../../src/loader/Loader.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAY,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAyB3B,MAAM,MAAM,GAAG,UAAU,CACvB,CACE,EASC,EACD,GAAG,EACH,EAAE;QAXF,EACE,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,QAAQ,EACf,KAAK,GAAG,WAAW,EACnB,WAAW,GAAG,KAAK,EACnB,OAAO,GAAG,SAAS,EACnB,EAAE,OAEH,EADI,IAAI,cART,0EASC,CADQ;IAIT,MAAM,UAAU,GAAG,KAAK,EAAE,CAAC;IAE3B,OAAO,CACL,8DACmB,EAAE,aAA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,WAAW,EACnB,WAAW,GAAG,KAAK,EACnB,OAAO,GAAG,SAAS,EACnB,EAAE,OAEH,EADI,IAAI,cART,0EASC,CADQ;IAIT,MAAM,UAAU,GAAG,KAAK,EAAE,CAAC;IAE3B,OAAO,CACL,8DACmB,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,UAAU,UAAU,EAAE,EAC7C,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,cAAc,EACd,SAAS,EACT,iBAAiB,IAAI,EAAE,EACvB,iBAAiB,OAAO,EAAE,EAC1B;YACE,2BAA2B,EAAE,WAAW;SACzC,CACF,EACD,SAAS,EAAC,OAAO,EACjB,OAAO,EAAC,WAAW,EACnB,mBAAmB,EAAC,UAAU,IAC1B,IAAI;QAER,+BAAO,EAAE,EAAE,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,UAAU,UAAU,EAAE,IAAG,KAAK,CAAS;QACxD,gCACE,SAAS,EAAC,0BAA0B,EACpC,KAAK,EAAC,4BAA4B,EAClC,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,IAAI,EACP,CAAC,EAAC,IAAI,EACN,IAAI,EAAC,MAAM,EACX,WAAW,EAAC,GAAG,GACf;QACF,gCACE,SAAS,EAAC,0BAA0B,EACpC,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,IAAI,EACP,CAAC,EAAC,IAAI,EACN,MAAM,EAAE,oCAAoC,EAC5C,IAAI,EAAC,MAAM,EACX,WAAW,EAAC,GAAG,EACf,eAAe,EAAC,QAAQ,EACxB,aAAa,EAAC,OAAO,GACrB,CACE,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "private": false,
5
5
  "description": "NAV designsystem react components",
6
6
  "author": "NAV Designsystem team",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@material-ui/core": "^4.12.3",
38
- "@navikt/ds-icons": "^0.6.2",
38
+ "@navikt/ds-icons": "^0.7.0",
39
39
  "@popperjs/core": "^2.10.1",
40
40
  "classnames": "^2.2.6",
41
41
  "react-collapse": "^5.1.0",
@@ -61,7 +61,8 @@
61
61
  "ts-jest": "^27.0.5"
62
62
  },
63
63
  "peerDependencies": {
64
- "react": "^16.8.0 || ^17.0.0"
64
+ "@types/react": "^17.0.30",
65
+ "react": "^17.0.0"
65
66
  },
66
- "gitHead": "a06b27a218f9fdbfed2385eb90a602fae16d3a86"
67
+ "gitHead": "36d98e1d190652c21d78a259cf3d8942d271c167"
67
68
  }
@@ -1,6 +1,6 @@
1
1
  import cl from "classnames";
2
2
  import React, { FieldsetHTMLAttributes, forwardRef, useContext } from "react";
3
- import { BodyShort, Label, omit } from "../..";
3
+ import { BodyShort, Detail, Label, omit } from "../..";
4
4
  import ErrorMessage from "../ErrorMessage";
5
5
  import { FormFieldProps } from "../useFormField";
6
6
  import { useFieldset } from "./useFieldset";
@@ -101,17 +101,30 @@ const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(
101
101
  >
102
102
  {legend}
103
103
  </Label>
104
- {!!description && (
105
- <BodyShort
106
- className={cl("navds-fieldset__description", {
107
- "sr-only": !!hideLegend,
108
- })}
109
- id={inputDescriptionId}
110
- size={size}
111
- >
112
- {description}
113
- </BodyShort>
114
- )}
104
+ {!!description &&
105
+ (size === "medium" ? (
106
+ <BodyShort
107
+ className={cl("navds-fieldset__description", {
108
+ "sr-only": !!hideLegend,
109
+ })}
110
+ id={inputDescriptionId}
111
+ size="small"
112
+ as="div"
113
+ >
114
+ {props.description}
115
+ </BodyShort>
116
+ ) : (
117
+ <Detail
118
+ className={cl("navds-fieldset__description", {
119
+ "sr-only": !!hideLegend,
120
+ })}
121
+ id={inputDescriptionId}
122
+ size="small"
123
+ as="div"
124
+ >
125
+ {props.description}
126
+ </Detail>
127
+ ))}
115
128
  {children}
116
129
  <div
117
130
  id={errorId}
@@ -52,7 +52,10 @@ const Select = forwardRef<HTMLSelectElement, SelectProps>((props, ref) => {
52
52
  className,
53
53
  "navds-form-field",
54
54
  `navds-form-field--${size}`,
55
- { "navds-select--error": hasError }
55
+ {
56
+ "navds-select--error": hasError,
57
+ "navds-select--disabled": !!inputProps.disabled,
58
+ }
56
59
  )}
57
60
  >
58
61
  <Label
@@ -67,6 +70,7 @@ const Select = forwardRef<HTMLSelectElement, SelectProps>((props, ref) => {
67
70
  </Label>
68
71
  {!!description && (
69
72
  <BodyShort
73
+ as="div"
70
74
  className={cl("navds-select__description", {
71
75
  "sr-only": hideLabel,
72
76
  })}
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef, InputHTMLAttributes } from "react";
2
2
  import cl from "classnames";
3
- import { BodyShort, Label, omit } from "..";
3
+ import { BodyShort, Detail, Label, omit } from "..";
4
4
  import ErrorMessage from "./ErrorMessage";
5
5
  import { FormFieldProps, useFormField } from "./useFormField";
6
6
 
@@ -52,7 +52,10 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>((props, ref) => {
52
52
  className,
53
53
  "navds-form-field",
54
54
  `navds-form-field--${size}`,
55
- { "navds-text-field--error": hasError }
55
+ {
56
+ "navds-text-field--error": hasError,
57
+ "navds-text-field--disabled": !!inputProps.disabled,
58
+ }
56
59
  )}
57
60
  >
58
61
  <Label
@@ -65,15 +68,31 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>((props, ref) => {
65
68
  </Label>
66
69
 
67
70
  {!!description && (
68
- <BodyShort
69
- className={cl("navds-text-field__description", {
70
- "sr-only": hideLabel,
71
- })}
72
- id={inputDescriptionId}
73
- size={size}
74
- >
75
- {description}
76
- </BodyShort>
71
+ <>
72
+ {size === "medium" ? (
73
+ <BodyShort
74
+ className={cl("navds-text-field__description", {
75
+ "sr-only": hideLabel,
76
+ })}
77
+ id={inputDescriptionId}
78
+ size="small"
79
+ as="div"
80
+ >
81
+ {description}
82
+ </BodyShort>
83
+ ) : (
84
+ <Detail
85
+ className={cl("navds-text-field__description", {
86
+ "sr-only": hideLabel,
87
+ })}
88
+ id={inputDescriptionId}
89
+ size="small"
90
+ as="div"
91
+ >
92
+ {description}
93
+ </Detail>
94
+ )}
95
+ </>
77
96
  )}
78
97
  <input
79
98
  {...omit(rest, ["error", "errorId", "size"])}
@@ -66,7 +66,10 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
66
66
  className,
67
67
  "navds-form-field",
68
68
  `navds-form-field--${size}`,
69
- { "navds-textarea--error": hasError }
69
+ {
70
+ "navds-textarea--error": hasError,
71
+ "navds-textarea--disabled": !!inputProps.disabled,
72
+ }
70
73
  )}
71
74
  >
72
75
  <Label
@@ -81,6 +84,7 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
81
84
  </Label>
82
85
  {!!description && (
83
86
  <BodyShort
87
+ as="div"
84
88
  className={cl("navds-textarea__description", {
85
89
  "sr-only": hideLabel,
86
90
  })}
@@ -1,13 +1,17 @@
1
1
  import React, { forwardRef, InputHTMLAttributes } from "react";
2
2
  import cl from "classnames";
3
3
  import useCheckbox from "./useCheckbox";
4
- import ErrorMessage from "../ErrorMessage";
5
4
  import { FormFieldProps } from "../useFormField";
6
- import { BodyShort, omit } from "../..";
5
+ import { BodyShort, Detail, omit } from "../..";
7
6
 
8
7
  export interface CheckboxProps
9
- extends FormFieldProps,
8
+ extends Omit<FormFieldProps, "errorId">,
10
9
  Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
10
+ /**
11
+ * Checkbox has error
12
+ * @default false
13
+ */
14
+ error?: boolean;
11
15
  /**
12
16
  * Label for checkbox
13
17
  */
@@ -23,14 +27,9 @@ export interface CheckboxProps
23
27
  }
24
28
 
25
29
  const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
26
- const {
27
- inputProps,
28
- errorId,
29
- showErrorMsg,
30
- hasError,
31
- size,
32
- inputDescriptionId,
33
- } = useCheckbox(props);
30
+ const { inputProps, hasError, size } = useCheckbox(props);
31
+
32
+ const Description = size === "medium" ? BodyShort : Detail;
34
33
 
35
34
  return (
36
35
  <div
@@ -40,8 +39,7 @@ const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
40
39
  `navds-checkbox--${size}`,
41
40
  {
42
41
  "navds-checkbox--error": hasError,
43
- "navds-checkbox--with-error-message": showErrorMsg,
44
- "navds-checkbox--with-description": !!props.description,
42
+ "navds-checkbox--disabled": inputProps.disabled,
45
43
  }
46
44
  )}
47
45
  >
@@ -50,7 +48,6 @@ const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
50
48
  "children",
51
49
  "size",
52
50
  "error",
53
- "errorId",
54
51
  "description",
55
52
  "hideLabel",
56
53
  ])}
@@ -58,30 +55,26 @@ const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
58
55
  className="navds-checkbox__input"
59
56
  ref={ref}
60
57
  />
61
- <BodyShort
62
- as="label"
63
- htmlFor={inputProps.id}
64
- size={size}
65
- className="navds-checkbox__label"
66
- >
67
- {props.hideLabel ? (
68
- <span className="sr-only">{props.children}</span>
69
- ) : (
70
- props.children
71
- )}
72
- </BodyShort>
73
- {props.description && (
74
- <BodyShort
75
- size={size}
76
- id={inputDescriptionId}
77
- className="navds-checkbox__description"
58
+ <label htmlFor={inputProps.id} className="navds-checkbox__label">
59
+ <div
60
+ className={cl("navds-checkbox__content", {
61
+ "sr-only": props.hideLabel,
62
+ })}
78
63
  >
79
- {props.description}
80
- </BodyShort>
81
- )}
82
- <div id={errorId} aria-relevant="additions removals" aria-live="polite">
83
- {showErrorMsg && <ErrorMessage size={size}>{props.error}</ErrorMessage>}
84
- </div>
64
+ <BodyShort as="div" size={size}>
65
+ {props.children}
66
+ </BodyShort>
67
+ {props.description && (
68
+ <Description
69
+ as="div"
70
+ size="small"
71
+ className="navds-checkbox__description"
72
+ >
73
+ {props.description}
74
+ </Description>
75
+ )}
76
+ </div>
77
+ </label>
85
78
  </div>
86
79
  );
87
80
  });
@@ -12,7 +12,8 @@ export const CheckboxGroupContext = createContext<CheckboxGroupState | null>(
12
12
  null
13
13
  );
14
14
 
15
- export interface CheckboxGroupProps extends Omit<FieldsetProps, "onChange"> {
15
+ export interface CheckboxGroupProps
16
+ extends Omit<FieldsetProps, "onChange" | "errorPropagation"> {
16
17
  /**
17
18
  * Checkboxes
18
19
  */
@@ -49,6 +49,8 @@ Man kan både sette en description på CheckboxGroup og selve checkbox
49
49
 
50
50
  ## Errors
51
51
 
52
+ Feilmeldinger kan bare settes på gruppa
53
+
52
54
  ```jsx
53
55
  <CheckboxGroup legend="Mollit eiusmod" error="Boks nr 2 må være valgt">
54
56
  <Checkbox value="Apple">Apple</Checkbox>
@@ -65,37 +67,23 @@ Man kan både sette en description på CheckboxGroup og selve checkbox
65
67
  </CheckboxGroup>
66
68
  </Canvas>
67
69
 
68
- ## Errors uten errorPropagation
70
+ Enkelt-checkboxer tar en `boolean` error prop
69
71
 
70
72
  ```jsx
71
- <CheckboxGroup
72
- legend="Mollit eiusmod"
73
- errorPropagation={false}
74
- error="Boks nr 2 må være valgt"
75
- >
76
- <Checkbox value="Apple">Apple</Checkbox>
77
- <Checkbox value="Orange">Orange</Checkbox>
78
- <Checkbox value="Melon">Melon</Checkbox>
79
- </CheckboxGroup>
73
+ <Checkbox value="Apple" error>
74
+ Apple
75
+ </Checkbox>
80
76
  ```
81
77
 
82
78
  <Canvas>
83
- <CheckboxGroup
84
- legend="Mollit eiusmod"
85
- errorPropagation={false}
86
- error="Boks nr 2 må være valgt"
87
- >
88
- <Checkbox value="Apple">Apple</Checkbox>
89
- <Checkbox value="Orange" error="Boksen må være valgt">
90
- Orange
91
- </Checkbox>
92
- <Checkbox value="Melon">Melon</Checkbox>
93
- </CheckboxGroup>
79
+ <Checkbox value="Apple" error>
80
+ Apple
81
+ </Checkbox>
94
82
  </Canvas>
95
83
 
96
84
  ## Sizing
97
85
 
98
- Checkboxer har default 44px høy klikkflate. Med size="small" blir denne til 24px slik som før
86
+ Checkboxer har default 48px høy klikkflate. Med size="small" blir klikkflaten 32px
99
87
 
100
88
  ```jsx
101
89
  <CheckboxGroup
@@ -166,31 +154,15 @@ Ved bruk av `hideLegend` på CheckboxGroup kan man gjøre slik at legend/descrip
166
154
  Ved bruk av `hideLabel` kan man lettere ta i bruk checkbox internt i eks tabeller.
167
155
 
168
156
  ```jsx
169
- <CheckboxGroup legend="Mollit eiusmod" hideLegend>
170
- <Checkbox value="Apple" hideLabel>
171
- Apple
172
- </Checkbox>
173
- <Checkbox value="Orange" hideLabel>
174
- Orange
175
- </Checkbox>
176
- <Checkbox value="Melon" hideLabel>
177
- Melon
178
- </Checkbox>
179
- </CheckboxGroup>
157
+ <Checkbox value="Orange" hideLabel>
158
+ Orange
159
+ </Checkbox>
180
160
  ```
181
161
 
182
162
  <Canvas>
183
- <CheckboxGroup legend="Mollit eiusmod" hideLegend>
184
- <Checkbox value="Apple" hideLabel>
185
- Apple
186
- </Checkbox>
187
- <Checkbox value="Orange" hideLabel>
188
- Orange
189
- </Checkbox>
190
- <Checkbox value="Melon" hideLabel>
191
- Melon
192
- </Checkbox>
193
- </CheckboxGroup>
163
+ <Checkbox value="Orange" hideLabel>
164
+ Orange
165
+ </Checkbox>
194
166
  </Canvas>
195
167
 
196
168
  ## Disabled
@@ -206,7 +178,7 @@ NOTE: Husk at disabled bør unngås!
206
178
  <Checkbox value="Melon">Melon</Checkbox>
207
179
  </CheckboxGroup>
208
180
 
209
- <CheckboxGroup legend="Mollit eiusmod" >
181
+ <CheckboxGroup legend="Mollit eiusmod">
210
182
  <Checkbox value="Apple" disabled>Apple</Checkbox>
211
183
  <Checkbox value="Orange">Orange</Checkbox>
212
184
  <Checkbox value="Melon">Melon</Checkbox>
@@ -7,90 +7,63 @@ export default {
7
7
  } as Meta;
8
8
 
9
9
  export const All = () => {
10
+ const Checkboxes = (props) => (
11
+ <CheckboxGroup
12
+ legend="Mollit eiusmod"
13
+ description="Exercitation do labore"
14
+ {...props}
15
+ >
16
+ <Checkbox value="Apple">Apple</Checkbox>
17
+ <Checkbox value="Orange" description="Laborum ad">
18
+ Orange
19
+ </Checkbox>
20
+ <Checkbox value="Banana" description={<div>Laborum ad</div>}>
21
+ Banana
22
+ </Checkbox>
23
+ <Checkbox value="Melon">Melon</Checkbox>
24
+ </CheckboxGroup>
25
+ );
26
+
10
27
  return (
11
28
  <>
12
- <h1>Checkboxes</h1>
13
- <CheckboxGroup legend="Mollit eiusmod">
14
- <Checkbox value="Apple">Apple</Checkbox>
15
- <Checkbox value="Orange">Orange</Checkbox>
16
- <Checkbox value="Melon">Melon</Checkbox>
17
- </CheckboxGroup>
18
- <h2>description</h2>
19
- <CheckboxGroup
20
- legend="Mollit eiusmod"
21
- description="Exercitation do labore"
22
- >
23
- <Checkbox value="Apple">Apple</Checkbox>
24
- <Checkbox value="Orange" description="Laborum ad">
25
- Orange
26
- </Checkbox>
27
- <Checkbox value="Melon">Melon</Checkbox>
28
- </CheckboxGroup>
29
- <h2>error</h2>
30
- <CheckboxGroup legend="Mollit eiusmod" error="Boks nr 2 må være valgt">
31
- <Checkbox value="Apple">Apple</Checkbox>
32
- <Checkbox value="Orange">Orange</Checkbox>
33
- <Checkbox value="Melon">Melon</Checkbox>
34
- </CheckboxGroup>
35
- <h2>error uten errorPropagation</h2>
36
- <CheckboxGroup
37
- legend="Mollit eiusmod"
38
- errorPropagation={false}
39
- error="Boks nr 2 må være valgt"
40
- >
41
- <Checkbox value="Apple">Apple</Checkbox>
42
- <Checkbox value="Orange" error="Boksen må være valgt">
43
- Orange
44
- </Checkbox>
45
- <Checkbox value="Melon">Melon</Checkbox>
46
- </CheckboxGroup>
47
- <h2>Sizing</h2>
48
- <CheckboxGroup
49
- legend="Mollit eiusmod"
50
- error="Boks nr 2 må være valgt"
51
- size="small"
52
- >
53
- <Checkbox value="Apple">Apple</Checkbox>
54
- <Checkbox value="Orange">Orange</Checkbox>
55
- <Checkbox value="Melon">Melon</Checkbox>
56
- </CheckboxGroup>
57
- <h2>defaultValue</h2>
58
- <CheckboxGroup legend="Mollit eiusmod" defaultValue={["Orange", "Melon"]}>
59
- <Checkbox value="Apple">Apple</Checkbox>
60
- <Checkbox value="Orange">Orange</Checkbox>
61
- <Checkbox value="Melon">Melon</Checkbox>
62
- </CheckboxGroup>
63
- <h2>hideLenged</h2>
64
- <CheckboxGroup legend="Mollit eiusmod" hideLegend>
65
- <Checkbox value="Apple">Apple</Checkbox>
66
- <Checkbox value="Orange">Orange</Checkbox>
67
- <Checkbox value="Melon">Melon</Checkbox>
68
- </CheckboxGroup>
69
- <h2>hideLabel</h2>
70
- <CheckboxGroup legend="Mollit eiusmod">
71
- <Checkbox value="Apple" hideLabel>
72
- Apple
73
- </Checkbox>
74
- <Checkbox value="Orange" hideLabel>
75
- Orange
76
- </Checkbox>
77
- <Checkbox value="Melon" hideLabel>
78
- Melon
79
- </Checkbox>
80
- </CheckboxGroup>
81
- <h2>Disabled</h2>
82
- <CheckboxGroup legend="Mollit eiusmod" disabled>
83
- <Checkbox value="Apple">Apple</Checkbox>
84
- <Checkbox value="Orange">Orange</Checkbox>
85
- <Checkbox value="Melon">Melon</Checkbox>
86
- </CheckboxGroup>
87
- <CheckboxGroup legend="Mollit eiusmod">
88
- <Checkbox value="Apple" disabled>
89
- Apple
90
- </Checkbox>
91
- <Checkbox value="Orange">Orange</Checkbox>
92
- <Checkbox value="Melon">Melon</Checkbox>
93
- </CheckboxGroup>
29
+ <h1>Checkbox</h1>
30
+ <h2>Single checkbox</h2>
31
+ <Checkbox value="Apple">Apple</Checkbox>
32
+ <h3>Desription</h3>
33
+ <Checkbox value="Apple" description="Laborum ad" defaultChecked>
34
+ Apple
35
+ </Checkbox>
36
+ <h3>Error</h3>
37
+ <Checkbox value="Apple" error>
38
+ Apple
39
+ </Checkbox>
40
+ <Checkbox value="Apple" error defaultChecked>
41
+ Orange
42
+ </Checkbox>
43
+ <h3>Hide label</h3>
44
+ <Checkbox value="Apple" hideLabel description="Laborum ad">
45
+ Apple
46
+ </Checkbox>
47
+ <h3>Disabled</h3>
48
+ <Checkbox value="Apple" disabled>
49
+ Apple
50
+ </Checkbox>
51
+ <Checkbox value="Orange" description="Laborum ad" disabled defaultChecked>
52
+ Orange
53
+ </Checkbox>
54
+
55
+ <h2>Checkbox group</h2>
56
+ <Checkboxes />
57
+ <h3>Error</h3>
58
+ <Checkboxes error="Dette er en feilmelding" />
59
+ <h3>Small</h3>
60
+ <Checkboxes size="small" />
61
+ <h3>Small + error</h3>
62
+ <Checkboxes size="small" error="Dette er en feilmelding" />
63
+ <h3>Default value</h3>
64
+ <Checkboxes defaultValue={["Orange", "Melon"]} />
65
+ <h3>Disabled</h3>
66
+ <Checkboxes disabled />
94
67
  </>
95
68
  );
96
69
  };
@@ -2,6 +2,7 @@ import { useContext } from "react";
2
2
  import { CheckboxProps } from "../..";
3
3
  import { useFormField } from "../useFormField";
4
4
  import { CheckboxGroupContext } from "./CheckboxGroup";
5
+ import { omit } from "../..";
5
6
 
6
7
  /**
7
8
  * Handles props for Checkboxes in context with Fieldset and CheckboxGroup
@@ -9,7 +10,10 @@ import { CheckboxGroupContext } from "./CheckboxGroup";
9
10
  const useCheckbox = ({ children, ...props }: CheckboxProps) => {
10
11
  const checkboxGroup = useContext(CheckboxGroupContext);
11
12
 
12
- const { inputProps, ...rest } = useFormField(props, "checkbox");
13
+ const { inputProps, ...rest } = useFormField(
14
+ omit(props, ["description"]),
15
+ "checkbox"
16
+ );
13
17
 
14
18
  if (checkboxGroup) {
15
19
  if (props.checked) {