@navikt/ds-react 0.19.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,11 +46,12 @@ const ErrorMessage_1 = __importDefault(require("./ErrorMessage"));
46
46
  const useFormField_1 = require("./useFormField");
47
47
  const __2 = require("..");
48
48
  exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
49
- var _a;
49
+ var _a, _b, _c;
50
50
  const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = (0, useFormField_1.useFormField)(props, "textarea");
51
51
  const { label, className, description, maxLength, hideLabel = false } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel"]);
52
52
  const maxLengthId = `TextareaMaxLength-${(0, __2.useId)()}`;
53
53
  const hasMaxLength = maxLength !== undefined && maxLength > 0;
54
+ const [controlledValue, setControlledValue] = (0, react_1.useState)((_a = props === null || props === void 0 ? void 0 : props.defaultValue) !== null && _a !== void 0 ? _a : "");
54
55
  return (react_1.default.createElement("div", { className: (0, classnames_1.default)(className, "navds-form-field", `navds-form-field--${size}`, {
55
56
  "navds-textarea--error": hasError,
56
57
  "navds-textarea--disabled": !!inputProps.disabled,
@@ -62,7 +63,9 @@ exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
62
63
  "navds-sr-only": hideLabel,
63
64
  }), id: inputDescriptionId, size: size }, description)),
64
65
  react_1.default.createElement("div", { className: "navds-textarea__wrapper" },
65
- react_1.default.createElement(TextareaAutosize_1.default, Object.assign({}, (0, __1.omit)(rest, ["error", "errorId", "size"]), inputProps, { ref: ref, className: (0, classnames_1.default)("navds-textarea__input", "navds-body-short", `navds-body-${size !== null && size !== void 0 ? size : "medium"}`, {
66
+ react_1.default.createElement(TextareaAutosize_1.default, Object.assign({}, (0, __1.omit)(rest, ["error", "errorId", "size"]), inputProps, { onChange: (e) => props.onChange
67
+ ? props.onChange(e)
68
+ : setControlledValue(e.target.value), ref: ref, className: (0, classnames_1.default)("navds-textarea__input", "navds-body-short", `navds-body-${size !== null && size !== void 0 ? size : "medium"}`, {
66
69
  "navds-textarea--counter": hasMaxLength,
67
70
  }), "aria-describedby": (0, classnames_1.default)(inputProps["aria-describedby"], {
68
71
  [maxLengthId]: hasMaxLength,
@@ -75,7 +78,7 @@ exports.Textarea = (0, react_1.forwardRef)((props, ref) => {
75
78
  " ",
76
79
  maxLength,
77
80
  " signs."),
78
- react_1.default.createElement(exports.Counter, { maxLength: maxLength, currentLength: (_a = props.value) === null || _a === void 0 ? void 0 : _a.length, size: size })))),
81
+ react_1.default.createElement(exports.Counter, { maxLength: maxLength, currentLength: (_c = (_b = props.value) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : controlledValue === null || controlledValue === void 0 ? void 0 : controlledValue.length, size: size })))),
79
82
  react_1.default.createElement("div", { id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (react_1.default.createElement(ErrorMessage_1.default, { size: size }, props.error)))));
80
83
  });
81
84
  const Counter = ({ maxLength, currentLength, size }) => {
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import React, { forwardRef } from "react";
12
+ import React, { forwardRef, useState } from "react";
13
13
  import cl from "classnames";
14
14
  import TextareaAutosize from "@material-ui/core/TextareaAutosize";
15
15
  import { BodyShort, Label, omit } from "..";
@@ -17,11 +17,12 @@ import ErrorMessage from "./ErrorMessage";
17
17
  import { useFormField } from "./useFormField";
18
18
  import { useId } from "..";
19
19
  export const Textarea = forwardRef((props, ref) => {
20
- var _a;
20
+ var _a, _b, _c;
21
21
  const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = useFormField(props, "textarea");
22
22
  const { label, className, description, maxLength, hideLabel = false } = props, rest = __rest(props, ["label", "className", "description", "maxLength", "hideLabel"]);
23
23
  const maxLengthId = `TextareaMaxLength-${useId()}`;
24
24
  const hasMaxLength = maxLength !== undefined && maxLength > 0;
25
+ const [controlledValue, setControlledValue] = useState((_a = props === null || props === void 0 ? void 0 : props.defaultValue) !== null && _a !== void 0 ? _a : "");
25
26
  return (React.createElement("div", { className: cl(className, "navds-form-field", `navds-form-field--${size}`, {
26
27
  "navds-textarea--error": hasError,
27
28
  "navds-textarea--disabled": !!inputProps.disabled,
@@ -33,7 +34,9 @@ export const Textarea = forwardRef((props, ref) => {
33
34
  "navds-sr-only": hideLabel,
34
35
  }), id: inputDescriptionId, size: size }, description)),
35
36
  React.createElement("div", { className: "navds-textarea__wrapper" },
36
- React.createElement(TextareaAutosize, Object.assign({}, omit(rest, ["error", "errorId", "size"]), inputProps, { ref: ref, className: cl("navds-textarea__input", "navds-body-short", `navds-body-${size !== null && size !== void 0 ? size : "medium"}`, {
37
+ React.createElement(TextareaAutosize, Object.assign({}, omit(rest, ["error", "errorId", "size"]), inputProps, { onChange: (e) => props.onChange
38
+ ? props.onChange(e)
39
+ : setControlledValue(e.target.value), ref: ref, className: cl("navds-textarea__input", "navds-body-short", `navds-body-${size !== null && size !== void 0 ? size : "medium"}`, {
37
40
  "navds-textarea--counter": hasMaxLength,
38
41
  }), "aria-describedby": cl(inputProps["aria-describedby"], {
39
42
  [maxLengthId]: hasMaxLength,
@@ -46,7 +49,7 @@ export const Textarea = forwardRef((props, ref) => {
46
49
  " ",
47
50
  maxLength,
48
51
  " signs."),
49
- React.createElement(Counter, { maxLength: maxLength, currentLength: (_a = props.value) === null || _a === void 0 ? void 0 : _a.length, size: size })))),
52
+ React.createElement(Counter, { maxLength: maxLength, currentLength: (_c = (_b = props.value) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : controlledValue === null || controlledValue === void 0 ? void 0 : controlledValue.length, size: size })))),
50
53
  React.createElement("div", { id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (React.createElement(ErrorMessage, { size: size }, props.error)))));
51
54
  });
52
55
  export const Counter = ({ maxLength, currentLength, size }) => {
@@ -1 +1 @@
1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AAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,EAC7C,IAAI,EAAE,IAAI,IAET,UAAU,GAAG,CAAC;QACb,CAAC,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe;QAC/C,CAAC,CAAC,UAAU,UAAU,aAAa,CAC3B,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "private": false,
5
5
  "description": "NAV designsystem react components",
6
6
  "author": "NAV Designsystem team",
@@ -74,5 +74,5 @@
74
74
  "@types/react": "^17.0.30 || ^18.0.0",
75
75
  "react": "^17.0.0 || ^18.0.0"
76
76
  },
77
- "gitHead": "17f35836538a5956def85cefe08ba956c71ba3b2"
77
+ "gitHead": "aa987b1c01408b07faa91e07ee1d36635e006bc3"
78
78
  }
@@ -1,4 +1,4 @@
1
- import React, { forwardRef } from "react";
1
+ import React, { forwardRef, useState } from "react";
2
2
  import cl from "classnames";
3
3
  import TextareaAutosize from "@material-ui/core/TextareaAutosize";
4
4
  import { BodyShort, Label, omit } from "..";
@@ -67,6 +67,10 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
67
67
  const maxLengthId = `TextareaMaxLength-${useId()}`;
68
68
  const hasMaxLength = maxLength !== undefined && maxLength > 0;
69
69
 
70
+ const [controlledValue, setControlledValue] = useState<string>(
71
+ props?.defaultValue ?? ""
72
+ );
73
+
70
74
  return (
71
75
  <div
72
76
  className={cl(
@@ -105,6 +109,11 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
105
109
  <TextareaAutosize
106
110
  {...omit(rest, ["error", "errorId", "size"])}
107
111
  {...inputProps}
112
+ onChange={(e) =>
113
+ props.onChange
114
+ ? props.onChange(e)
115
+ : setControlledValue(e.target.value)
116
+ }
108
117
  ref={ref}
109
118
  className={cl(
110
119
  "navds-textarea__input",
@@ -126,7 +135,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
126
135
  </span>
127
136
  <Counter
128
137
  maxLength={maxLength}
129
- currentLength={props.value?.length}
138
+ currentLength={props.value?.length ?? controlledValue?.length}
130
139
  size={size}
131
140
  />
132
141
  </>
@@ -3,67 +3,92 @@ import { ConfirmationPanel } from "../index";
3
3
  import { Meta } from "@storybook/react/types-6-0";
4
4
  import { Link } from "../..";
5
5
  export default {
6
- title: "ds-react/form/confirmation-panel",
6
+ title: "ds-react/form/ConfirmationPanel",
7
7
  component: ConfirmationPanel,
8
+ argTypes: {
9
+ size: {
10
+ control: {
11
+ type: "radio",
12
+ options: ["medium", "small"],
13
+ },
14
+ },
15
+ error: {
16
+ type: "string",
17
+ },
18
+ },
8
19
  } as Meta;
9
20
 
10
- export const All = () => {
21
+ const content = (
22
+ <>
23
+ Ipsum voluptate pariatur <Link href="#123">testlink</Link> anim officia
24
+ minim ut mollit voluptate exercitation nulla mollit.
25
+ </>
26
+ );
27
+
28
+ export const Default = (props) => {
29
+ return (
30
+ <ConfirmationPanel
31
+ error={props?.error}
32
+ size={props?.size}
33
+ checked={props?.checked ?? undefined}
34
+ label={props?.label ?? "Checkbox label text"}
35
+ >
36
+ {content}
37
+ </ConfirmationPanel>
38
+ );
39
+ };
40
+
41
+ Default.args = {
42
+ label: "Checkbox label text",
43
+ checked: false,
44
+ };
45
+
46
+ export const Small = () => {
11
47
  const [checked, setChecked] = useState(false);
12
48
  return (
13
- <div>
14
- <h1>ConfirmationPanel</h1>
15
- <ConfirmationPanel
16
- checked={checked}
17
- onChange={() => setChecked(!checked)}
18
- label="Checkbox label text"
19
- >
20
- Ipsum voluptate pariatur <Link href="#123">testlink</Link> anim officia
21
- minim ut mollit voluptate exercitation nulla mollit.
22
- </ConfirmationPanel>
23
- <h2>size small</h2>
24
- <ConfirmationPanel
25
- checked={checked}
26
- onChange={() => setChecked(!checked)}
27
- label="Checkbox label text"
28
- size="small"
29
- >
30
- Ipsum voluptate pariatur <Link href="#123">testlink</Link> anim officia
31
- minim ut mollit voluptate exercitation nulla mollit.
32
- </ConfirmationPanel>
33
- <h3>error</h3>
49
+ <ConfirmationPanel
50
+ checked={checked}
51
+ onChange={() => setChecked(!checked)}
52
+ label="Checkbox label text"
53
+ size="small"
54
+ >
55
+ {content}
56
+ </ConfirmationPanel>
57
+ );
58
+ };
59
+
60
+ export const NoContent = () => {
61
+ const [checked, setChecked] = useState(false);
62
+ return (
63
+ <ConfirmationPanel
64
+ checked={checked}
65
+ onChange={() => setChecked(!checked)}
66
+ label="Checkbox label text"
67
+ />
68
+ );
69
+ };
70
+
71
+ export const Error = () => {
72
+ const [checked, setChecked] = useState(false);
73
+ return (
74
+ <div className="colgap">
34
75
  <ConfirmationPanel
35
76
  checked={checked}
36
77
  onChange={() => setChecked(!checked)}
37
78
  label="Checkbox label text"
38
- error="Ex cupidatat do do do"
79
+ error="Adipisicing sint aute quis veniam incididunt duis est sint aute cillum."
39
80
  >
40
- Ipsum voluptate pariatur <Link href="#123">testlink</Link> anim officia
41
- minim ut mollit voluptate exercitation nulla mollit.
81
+ {content}
42
82
  </ConfirmationPanel>
43
- <h3>error small</h3>
44
83
  <ConfirmationPanel
45
84
  checked={checked}
46
85
  onChange={() => setChecked(!checked)}
47
86
  label="Checkbox label text"
48
- error="Ex cupidatat do do do"
87
+ error="Adipisicing sint aute quis veniam incididunt duis est sint aute cillum."
49
88
  size="small"
50
89
  >
51
- Ipsum voluptate pariatur <Link href="#123">testlink</Link> anim officia
52
- minim ut mollit voluptate exercitation nulla mollit.
90
+ {content}
53
91
  </ConfirmationPanel>
54
- <h2>Empty</h2>
55
- <ConfirmationPanel
56
- checked={checked}
57
- onChange={() => setChecked(!checked)}
58
- label="Checkbox label text"
59
- ></ConfirmationPanel>
60
- <h2>Uncontrolled</h2>
61
- <ConfirmationPanel label="Checkbox label text"></ConfirmationPanel>
62
- <h3>defaultChecked</h3>
63
- <ConfirmationPanel
64
- defaultChecked
65
- label="Checkbox label text"
66
- ></ConfirmationPanel>
67
92
  </div>
68
93
  );
69
94
  };
@@ -3,72 +3,111 @@ import { Fieldset } from "../index";
3
3
  import { Meta } from "@storybook/react/types-6-0";
4
4
  import { TextField } from "../../index";
5
5
  export default {
6
- title: "ds-react/form/fieldset",
6
+ title: "ds-react/form/Fieldset",
7
7
  component: Fieldset,
8
+ argTypes: {
9
+ size: {
10
+ control: {
11
+ type: "radio",
12
+ options: ["medium", "small"],
13
+ },
14
+ },
15
+ description: {
16
+ type: "string",
17
+ },
18
+ error: {
19
+ type: "string",
20
+ },
21
+ hideLegend: {
22
+ type: "boolean",
23
+ },
24
+ disabled: {
25
+ type: "boolean",
26
+ },
27
+ },
8
28
  } as Meta;
9
29
 
10
- export const All = () => {
11
- return (
12
- <div>
13
- <h1>Fieldset</h1>
14
-
15
- <Fieldset legend="Mollit eiusmod">
16
- <TextField label="Textfield label" hideLabel />
17
- <TextField label="Textfield label" hideLabel />
18
- </Fieldset>
19
-
20
- <h2>Description</h2>
21
-
22
- <Fieldset
23
- legend="Mollit eiusmod"
24
- description={<div>Quis reprehenderit esse cillum</div>}
25
- >
26
- <TextField
27
- label="Textfield label"
28
- hideLabel
29
- description={<div>Quis reprehenderit esse cillum</div>}
30
- />
31
- <TextField label="Textfield label" hideLabel />
32
- </Fieldset>
33
-
34
- <h2>Errors</h2>
35
-
36
- <Fieldset legend="Mollit eiusmod" error="Fieldsett error">
37
- <TextField label="Textfield label" hideLabel />
38
- <TextField label="Textfield label" hideLabel />
39
- </Fieldset>
30
+ const content = (
31
+ <>
32
+ <TextField label="Textfield label" hideLabel />
33
+ <TextField label="Textfield label" hideLabel />
34
+ </>
35
+ );
40
36
 
41
- <h2>Errors uten errorPropagation</h2>
37
+ export const Default = (props) => {
38
+ return (
39
+ <Fieldset legend="Mollit eiusmod" {...props}>
40
+ {content}
41
+ </Fieldset>
42
+ );
43
+ };
42
44
 
43
- <Fieldset
44
- legend="Mollit eiusmod"
45
- error="Fieldsett error"
46
- errorPropagation={false}
47
- >
48
- <TextField label="Textfield label" hideLabel error="Må være fylt ut" />
49
- <TextField label="Textfield label" hideLabel />
50
- </Fieldset>
45
+ Default.args = {
46
+ errorPropagation: true,
47
+ };
51
48
 
52
- <h2>Sizing</h2>
49
+ export const Small = () => (
50
+ <Fieldset
51
+ size="small"
52
+ legend="Mollit eiusmod"
53
+ description="Do ullamco amet mollit labore tempor minim cupidatat dolore voluptate velit irure."
54
+ >
55
+ {content}
56
+ </Fieldset>
57
+ );
53
58
 
54
- <Fieldset size="small" legend="Mollit eiusmod" description="Dolore minim">
55
- <TextField label="Textfield label" hideLabel />
56
- <TextField label="Textfield label" hideLabel />
57
- </Fieldset>
59
+ export const Description = () => (
60
+ <Fieldset
61
+ legend="Mollit eiusmod"
62
+ description="Esse cupidatat reprehenderit est culpa consectetur sit dolor esse."
63
+ >
64
+ <TextField label="Textfield label" hideLabel />
65
+ <TextField label="Textfield label" hideLabel />
66
+ </Fieldset>
67
+ );
58
68
 
59
- <h2>hideLegend</h2>
69
+ export const ErrorPropagation = () => (
70
+ <Fieldset
71
+ legend="Mollit eiusmod"
72
+ error="Fieldsett error"
73
+ errorPropagation={false}
74
+ >
75
+ <TextField label="Textfield label" hideLabel error="Må være fylt ut" />
76
+ <TextField label="Textfield label" hideLabel />
77
+ </Fieldset>
78
+ );
60
79
 
61
- <Fieldset legend="Mollit eiusmod" description="Dolore minim" hideLegend>
62
- <TextField label="Textfield label" hideLabel />
63
- <TextField label="Textfield label" hideLabel />
64
- </Fieldset>
80
+ export const Error = () => (
81
+ <div className="colgap">
82
+ <Fieldset
83
+ legend="Mollit eiusmod"
84
+ error="Laborum officia nisi aliqua esse minim in amet."
85
+ >
86
+ {content}
87
+ </Fieldset>
88
+ <Fieldset
89
+ size="small"
90
+ legend="Mollit eiusmod"
91
+ error="Laborum officia nisi aliqua esse minim in amet."
92
+ >
93
+ {content}
94
+ </Fieldset>
95
+ </div>
96
+ );
65
97
 
66
- <h2>Disabled</h2>
98
+ export const Disabled = () => (
99
+ <div className="colgap">
100
+ <Fieldset legend="Mollit eiusmod" disabled>
101
+ {content}
102
+ </Fieldset>
103
+ <Fieldset size="small" legend="Mollit eiusmod" disabled>
104
+ {content}
105
+ </Fieldset>
106
+ </div>
107
+ );
67
108
 
68
- <Fieldset legend="Mollit eiusmod" description="Dolore minim" disabled>
69
- <TextField label="Textfield label" hideLabel />
70
- <TextField label="Textfield label" hideLabel />
71
- </Fieldset>
72
- </div>
73
- );
74
- };
109
+ export const hideLegend = () => (
110
+ <Fieldset legend="Mollit eiusmod" hideLegend>
111
+ {content}
112
+ </Fieldset>
113
+ );
@@ -2,69 +2,113 @@ import React from "react";
2
2
  import { Select } from "../index";
3
3
  import { Meta } from "@storybook/react/types-6-0";
4
4
  export default {
5
- title: "ds-react/form/select",
5
+ title: "ds-react/form/Select",
6
6
  component: Select,
7
+ argTypes: {
8
+ size: {
9
+ control: {
10
+ type: "radio",
11
+ options: ["medium", "small"],
12
+ },
13
+ },
14
+ description: {
15
+ type: "string",
16
+ },
17
+ error: {
18
+ type: "string",
19
+ },
20
+ hideLabel: {
21
+ type: "boolean",
22
+ },
23
+ disabled: {
24
+ type: "boolean",
25
+ },
26
+ },
7
27
  } as Meta;
8
28
 
9
- export const All = () => {
29
+ const content = (
30
+ <>
31
+ <option value="">Velg land</option>
32
+ <option value="norge">Norge</option>
33
+ <option value="sverige">Sverige</option>
34
+ </>
35
+ );
36
+
37
+ export const Default = (props) => {
10
38
  return (
11
- <div>
12
- <h1>Select</h1>
39
+ <Select {...props} label="Ipsum enim quis culpa">
40
+ {content}
41
+ </Select>
42
+ );
43
+ };
13
44
 
14
- <Select label="Ipsum enim quis culpa">
15
- <option value="">Velg land</option>
16
- <option value="norge">Norge</option>
17
- <option value="sverige">Sverige</option>
18
- </Select>
45
+ Default.args = {};
19
46
 
20
- <h2>Description</h2>
47
+ export const Small = () => {
48
+ return (
49
+ <Select size="small" label="Ipsum enim quis culpa">
50
+ {content}
51
+ </Select>
52
+ );
53
+ };
21
54
 
22
- <Select label="Ipsum enim quis culpa" description={<div>Aute enim</div>}>
23
- <option value="">Velg land</option>
24
- <option value="norge">Norge</option>
25
- <option value="sverige">Sverige</option>
55
+ export const Description = () => {
56
+ return (
57
+ <div className="colgap">
58
+ <Select
59
+ label="Ipsum enim quis culpa"
60
+ description="Consectetur labore velit eiusmod Lorem ut nostrud mollit labore ullamco laboris laboris in."
61
+ >
62
+ {content}
26
63
  </Select>
27
-
28
- <h2>Errors</h2>
29
-
30
64
  <Select
31
65
  label="Ipsum enim quis culpa"
32
- description="Aute enim"
33
- error="Select error message"
66
+ description="Consectetur labore velit eiusmod Lorem ut nostrud mollit labore ullamco laboris laboris in."
67
+ size="small"
34
68
  >
35
- <option value="">Velg land</option>
36
- <option value="norge">Norge</option>
37
- <option value="sverige">Sverige</option>
69
+ {content}
38
70
  </Select>
71
+ </div>
72
+ );
73
+ };
39
74
 
40
- <h2>Sizing</h2>
41
-
75
+ export const Error = () => {
76
+ return (
77
+ <div className="colgap">
42
78
  <Select
43
79
  label="Ipsum enim quis culpa"
44
- description="Aute enim"
45
- error="Select error message"
80
+ error="Consectetur labore velit eiusmod Lorem ut nostrud mollit labore ullamco laboris laboris in."
81
+ >
82
+ {content}
83
+ </Select>
84
+ <Select
85
+ label="Ipsum enim quis culpa"
86
+ error="Consectetur labore velit eiusmod Lorem ut nostrud mollit labore ullamco laboris laboris in."
46
87
  size="small"
47
88
  >
48
- <option value="">Velg land</option>
49
- <option value="norge">Norge</option>
50
- <option value="sverige">Sverige</option>
89
+ {content}
51
90
  </Select>
91
+ </div>
92
+ );
93
+ };
52
94
 
53
- <h2>hideLabel</h2>
54
-
55
- <Select label="Ipsum enim quis culpa" description="Aute enim" hideLabel>
56
- <option value="">Velg land</option>
57
- <option value="norge">Norge</option>
58
- <option value="sverige">Sverige</option>
95
+ export const Disabled = () => {
96
+ return (
97
+ <div className="colgap">
98
+ <Select label="Ipsum enim quis culpa" disabled>
99
+ {content}
59
100
  </Select>
60
-
61
- <h2>Disabled</h2>
62
-
63
- <Select label="Ipsum enim quis culpa" description="Aute enim" disabled>
64
- <option value="">Velg land</option>
65
- <option value="norge">Norge</option>
66
- <option value="sverige">Sverige</option>
101
+ <Select label="Ipsum enim quis culpa" disabled size="small">
102
+ {content}
67
103
  </Select>
68
104
  </div>
69
105
  );
70
106
  };
107
+
108
+ export const HideLabel = () => {
109
+ return (
110
+ <Select label="Ipsum enim quis culpa" hideLabel>
111
+ {content}
112
+ </Select>
113
+ );
114
+ };