@navikt/ds-react 0.12.3 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/form/Fieldset/Fieldset.js +6 -3
- package/cjs/form/Select.js +5 -2
- package/cjs/form/TextField.js +8 -3
- package/cjs/form/Textarea.js +5 -2
- package/cjs/form/checkbox/Checkbox.js +9 -8
- package/cjs/form/checkbox/useCheckbox.js +2 -1
- package/cjs/form/radio/Radio.js +8 -14
- package/cjs/form/radio/useRadio.js +2 -1
- package/cjs/form/search-field/SearchField.js +5 -2
- package/esm/form/Fieldset/Fieldset.js +7 -4
- package/esm/form/Fieldset/Fieldset.js.map +1 -1
- package/esm/form/Select.js +5 -2
- package/esm/form/Select.js.map +1 -1
- package/esm/form/TextField.js +9 -4
- package/esm/form/TextField.js.map +1 -1
- package/esm/form/Textarea.js +5 -2
- package/esm/form/Textarea.js.map +1 -1
- package/esm/form/checkbox/Checkbox.d.ts +6 -1
- package/esm/form/checkbox/Checkbox.js +10 -9
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/checkbox/CheckboxGroup.d.ts +1 -1
- package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
- package/esm/form/checkbox/useCheckbox.js +2 -1
- package/esm/form/checkbox/useCheckbox.js.map +1 -1
- package/esm/form/radio/Radio.d.ts +4 -1
- package/esm/form/radio/Radio.js +9 -15
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/radio/RadioGroup.d.ts +1 -1
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/form/radio/useRadio.js +2 -1
- package/esm/form/radio/useRadio.js.map +1 -1
- package/esm/form/search-field/SearchField.js +5 -2
- package/esm/form/search-field/SearchField.js.map +1 -1
- package/esm/loader/Loader.d.ts +1 -1
- package/package.json +3 -3
- package/src/form/Fieldset/Fieldset.tsx +25 -12
- package/src/form/Select.tsx +5 -1
- package/src/form/TextField.tsx +30 -11
- package/src/form/Textarea.tsx +5 -1
- package/src/form/checkbox/Checkbox.test.tsx +7 -5
- package/src/form/checkbox/Checkbox.tsx +30 -37
- package/src/form/checkbox/CheckboxGroup.tsx +2 -1
- package/src/form/checkbox/stories/checkbox.stories.mdx +17 -45
- package/src/form/checkbox/stories/checkbox.stories.tsx +55 -82
- package/src/form/checkbox/useCheckbox.ts +5 -1
- package/src/form/radio/Radio.tsx +26 -40
- package/src/form/radio/RadioGroup.tsx +2 -1
- package/src/form/radio/stories/radio.stories.mdx +3 -29
- package/src/form/radio/stories/radio.stories.tsx +33 -61
- package/src/form/radio/useRadio.ts +5 -1
- package/src/form/search-field/SearchField.tsx +5 -1
- package/src/form/search-field/stories/search-field.stories.tsx +25 -1
- package/src/form/stories/fieldset.stories.tsx +6 -2
- package/src/form/stories/select.stories.tsx +1 -1
- package/src/form/stories/text-field.stories.tsx +23 -1
- package/src/form/stories/textarea.stories.tsx +12 -2
|
@@ -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>
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
|
|
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(
|
|
13
|
+
const { inputProps, ...rest } = useFormField(
|
|
14
|
+
omit(props, ["description"]),
|
|
15
|
+
"checkbox"
|
|
16
|
+
);
|
|
13
17
|
|
|
14
18
|
if (checkboxGroup) {
|
|
15
19
|
if (props.checked) {
|
package/src/form/radio/Radio.tsx
CHANGED
|
@@ -1,70 +1,56 @@
|
|
|
1
1
|
import React, { forwardRef, InputHTMLAttributes } from "react";
|
|
2
2
|
import cl from "classnames";
|
|
3
|
-
import { BodyShort, omit } from "../..";
|
|
4
|
-
import ErrorMessage from "../ErrorMessage";
|
|
3
|
+
import { BodyShort, Detail, omit } from "../..";
|
|
5
4
|
import { FormFieldProps } from "../useFormField";
|
|
6
5
|
import { useRadio } from "./useRadio";
|
|
7
6
|
|
|
8
7
|
export interface RadioProps
|
|
9
|
-
extends FormFieldProps,
|
|
8
|
+
extends Omit<FormFieldProps, "error" | "errorId">,
|
|
10
9
|
Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
11
10
|
/**
|
|
12
11
|
* Label for radio
|
|
13
12
|
*/
|
|
14
13
|
children: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* The value of the HTML element
|
|
16
|
+
*/
|
|
15
17
|
value: string;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
showErrorMsg,
|
|
23
|
-
size,
|
|
24
|
-
hasError,
|
|
25
|
-
inputDescriptionId,
|
|
26
|
-
} = useRadio(props);
|
|
21
|
+
const { inputProps, size, hasError } = useRadio(props);
|
|
22
|
+
|
|
23
|
+
const Description = size === "medium" ? BodyShort : Detail;
|
|
27
24
|
|
|
28
25
|
return (
|
|
29
26
|
<div
|
|
30
27
|
className={cl(props.className, "navds-radio", `navds-radio--${size}`, {
|
|
31
28
|
"navds-radio--error": hasError,
|
|
32
|
-
"navds-radio--
|
|
33
|
-
"navds-radio--with-description": !!props.description,
|
|
29
|
+
"navds-radio--disabled": inputProps.disabled,
|
|
34
30
|
})}
|
|
35
31
|
>
|
|
36
32
|
<input
|
|
37
|
-
{...omit(props, [
|
|
38
|
-
"children",
|
|
39
|
-
"size",
|
|
40
|
-
"error",
|
|
41
|
-
"errorId",
|
|
42
|
-
"description",
|
|
43
|
-
])}
|
|
33
|
+
{...omit(props, ["children", "size", "description"])}
|
|
44
34
|
{...inputProps}
|
|
45
35
|
className="navds-radio__input"
|
|
46
36
|
ref={ref}
|
|
47
37
|
/>
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)}
|
|
65
|
-
<div id={errorId} aria-relevant="additions removals" aria-live="polite">
|
|
66
|
-
{showErrorMsg && <ErrorMessage size={size}>{props.error}</ErrorMessage>}
|
|
67
|
-
</div>
|
|
38
|
+
<label htmlFor={inputProps.id} className="navds-radio__label">
|
|
39
|
+
<div className="navds-radio__content">
|
|
40
|
+
<BodyShort as="div" size={size}>
|
|
41
|
+
{props.children}
|
|
42
|
+
</BodyShort>
|
|
43
|
+
{props.description && (
|
|
44
|
+
<Description
|
|
45
|
+
as="div"
|
|
46
|
+
size="small"
|
|
47
|
+
className="navds-radio__description"
|
|
48
|
+
>
|
|
49
|
+
{props.description}
|
|
50
|
+
</Description>
|
|
51
|
+
)}
|
|
52
|
+
</div>
|
|
53
|
+
</label>
|
|
68
54
|
</div>
|
|
69
55
|
);
|
|
70
56
|
});
|
|
@@ -15,7 +15,8 @@ export const RadioGroupContext = React.createContext<RadioGroupContextProps | nu
|
|
|
15
15
|
null
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
-
export interface RadioGroupProps
|
|
18
|
+
export interface RadioGroupProps
|
|
19
|
+
extends Omit<FieldsetProps, "onChange" | "errorPropagation"> {
|
|
19
20
|
/**
|
|
20
21
|
* Collection of <Radio>-elements
|
|
21
22
|
*/
|
|
@@ -49,6 +49,8 @@ Man kan både sette en description på RadioGroup og selve Radio
|
|
|
49
49
|
|
|
50
50
|
## Errors
|
|
51
51
|
|
|
52
|
+
Feilmeldinger kan bare settes på gruppa
|
|
53
|
+
|
|
52
54
|
```jsx
|
|
53
55
|
<RadioGroup legend="Mollit eiusmod" error="Boks nr 2 må være valgt">
|
|
54
56
|
<Radio value="Apple">Apple</Radio>
|
|
@@ -65,37 +67,9 @@ Man kan både sette en description på RadioGroup og selve Radio
|
|
|
65
67
|
</RadioGroup>
|
|
66
68
|
</Canvas>
|
|
67
69
|
|
|
68
|
-
## Errors uten errorPropagation
|
|
69
|
-
|
|
70
|
-
```jsx
|
|
71
|
-
<RadioGroup
|
|
72
|
-
legend="Mollit eiusmod"
|
|
73
|
-
errorPropagation={false}
|
|
74
|
-
error="Boks nr 2 må være valgt"
|
|
75
|
-
>
|
|
76
|
-
<Radio value="Apple">Apple</Radio>
|
|
77
|
-
<Radio value="Orange">Orange</Radio>
|
|
78
|
-
<Radio value="Melon">Melon</Radio>
|
|
79
|
-
</RadioGroup>
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
<Canvas>
|
|
83
|
-
<RadioGroup
|
|
84
|
-
legend="Mollit eiusmod"
|
|
85
|
-
errorPropagation={false}
|
|
86
|
-
error="Boks nr 2 må være valgt"
|
|
87
|
-
>
|
|
88
|
-
<Radio value="Apple">Apple</Radio>
|
|
89
|
-
<Radio value="Orange" error="Boksen må være valgt">
|
|
90
|
-
Orange
|
|
91
|
-
</Radio>
|
|
92
|
-
<Radio value="Melon">Melon</Radio>
|
|
93
|
-
</RadioGroup>
|
|
94
|
-
</Canvas>
|
|
95
|
-
|
|
96
70
|
## Sizing
|
|
97
71
|
|
|
98
|
-
|
|
72
|
+
Radioknapper har default 48px høy klikkflate. Med size="small" blir klikkflaten 32px
|
|
99
73
|
|
|
100
74
|
```jsx
|
|
101
75
|
<RadioGroup
|
|
@@ -7,75 +7,47 @@ export default {
|
|
|
7
7
|
} as Meta;
|
|
8
8
|
|
|
9
9
|
export const All = () => {
|
|
10
|
+
const Radios = (props) => (
|
|
11
|
+
<RadioGroup
|
|
12
|
+
legend="Mollit eiusmod"
|
|
13
|
+
description={<div>"Exercitation do labore"</div>}
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
<Radio value="Apple">Apple</Radio>
|
|
17
|
+
<Radio value="Orange" description="Laborum ad">
|
|
18
|
+
Orange
|
|
19
|
+
</Radio>
|
|
20
|
+
<Radio value="Orange" description={<div>Laborum ad</div>}>
|
|
21
|
+
Orange
|
|
22
|
+
</Radio>
|
|
23
|
+
<Radio value="Melon">Melon</Radio>
|
|
24
|
+
</RadioGroup>
|
|
25
|
+
);
|
|
26
|
+
|
|
10
27
|
return (
|
|
11
28
|
<>
|
|
12
|
-
<h1>
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<h2>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Orange
|
|
23
|
-
</Radio>
|
|
24
|
-
<Radio value="Melon">Melon</Radio>
|
|
25
|
-
</RadioGroup>
|
|
26
|
-
<h2>error</h2>
|
|
27
|
-
<RadioGroup legend="Mollit eiusmod" error="Boks nr 2 må være valgt">
|
|
28
|
-
<Radio value="Apple">Apple</Radio>
|
|
29
|
-
<Radio value="Orange">Orange</Radio>
|
|
30
|
-
<Radio value="Melon">Melon</Radio>
|
|
31
|
-
</RadioGroup>
|
|
32
|
-
<h2>error uten errorPropagation</h2>
|
|
33
|
-
<RadioGroup
|
|
34
|
-
legend="Mollit eiusmod"
|
|
35
|
-
errorPropagation={false}
|
|
36
|
-
error="Boks nr 2 må være valgt"
|
|
37
|
-
>
|
|
38
|
-
<Radio value="Apple">Apple</Radio>
|
|
39
|
-
<Radio value="Orange" error="Boksen må være valgt">
|
|
40
|
-
Orange
|
|
41
|
-
</Radio>
|
|
42
|
-
<Radio value="Melon">Melon</Radio>
|
|
43
|
-
</RadioGroup>
|
|
44
|
-
<h2>Sizing</h2>
|
|
45
|
-
<RadioGroup
|
|
46
|
-
legend="Mollit eiusmod"
|
|
47
|
-
error="Boks nr 2 må være valgt"
|
|
48
|
-
size="small"
|
|
49
|
-
>
|
|
50
|
-
<Radio value="Apple">Apple</Radio>
|
|
51
|
-
<Radio value="Orange">Orange</Radio>
|
|
52
|
-
<Radio value="Melon">Melon</Radio>
|
|
53
|
-
</RadioGroup>
|
|
54
|
-
<h2>defaultValue</h2>
|
|
55
|
-
<RadioGroup legend="Mollit eiusmod" defaultValue="Orange">
|
|
56
|
-
<Radio value="Apple">Apple</Radio>
|
|
57
|
-
<Radio value="Orange">Orange</Radio>
|
|
58
|
-
<Radio value="Melon">Melon</Radio>
|
|
59
|
-
</RadioGroup>
|
|
60
|
-
<h2>hideLenged</h2>
|
|
61
|
-
<RadioGroup legend="Mollit eiusmod" hideLegend>
|
|
62
|
-
<Radio value="Apple">Apple</Radio>
|
|
63
|
-
<Radio value="Orange">Orange</Radio>
|
|
64
|
-
<Radio value="Melon">Melon</Radio>
|
|
65
|
-
</RadioGroup>
|
|
29
|
+
<h1>Radio group</h1>
|
|
30
|
+
<Radios />
|
|
31
|
+
<h2>Error</h2>
|
|
32
|
+
<Radios error="Dette er en feilmelding" />
|
|
33
|
+
<h2>Small</h2>
|
|
34
|
+
<Radios size="small" />
|
|
35
|
+
<h2>Small + error</h2>
|
|
36
|
+
<Radios size="small" error="Dette er en feilmelding" />
|
|
37
|
+
<h2>Default value</h2>
|
|
38
|
+
<Radios defaultValue="Orange" />
|
|
66
39
|
<h2>Disabled</h2>
|
|
67
|
-
<RadioGroup legend="Mollit eiusmod"
|
|
68
|
-
<Radio value="Apple">Apple</Radio>
|
|
69
|
-
<Radio value="Orange">Orange</Radio>
|
|
70
|
-
<Radio value="Melon">Melon</Radio>
|
|
71
|
-
</RadioGroup>
|
|
72
|
-
<RadioGroup legend="Mollit eiusmod">
|
|
40
|
+
<RadioGroup legend="Mollit eiusmod" description="Exercitation do labore">
|
|
73
41
|
<Radio value="Apple" disabled>
|
|
74
42
|
Apple
|
|
75
43
|
</Radio>
|
|
76
|
-
<Radio value="Orange">
|
|
44
|
+
<Radio value="Orange" description="Laborum ad" disabled>
|
|
45
|
+
Orange
|
|
46
|
+
</Radio>
|
|
77
47
|
<Radio value="Melon">Melon</Radio>
|
|
78
48
|
</RadioGroup>
|
|
49
|
+
<h2>Disabled group</h2>
|
|
50
|
+
<Radios disabled />
|
|
79
51
|
</>
|
|
80
52
|
);
|
|
81
53
|
};
|
|
@@ -2,6 +2,7 @@ import { useContext } from "react";
|
|
|
2
2
|
import { useFormField } from "../useFormField";
|
|
3
3
|
import { RadioProps } from "./Radio";
|
|
4
4
|
import { RadioGroupContext } from "./RadioGroup";
|
|
5
|
+
import { omit } from "../..";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Handles props for Radios in context with Fieldset and RadioGroup
|
|
@@ -9,7 +10,10 @@ import { RadioGroupContext } from "./RadioGroup";
|
|
|
9
10
|
export const useRadio = (props: RadioProps) => {
|
|
10
11
|
const radioGroup = useContext(RadioGroupContext);
|
|
11
12
|
|
|
12
|
-
const { inputProps, ...rest } = useFormField(
|
|
13
|
+
const { inputProps, ...rest } = useFormField(
|
|
14
|
+
omit(props, ["description"]),
|
|
15
|
+
"radio"
|
|
16
|
+
);
|
|
13
17
|
|
|
14
18
|
if (!radioGroup) {
|
|
15
19
|
console.warn("<Radio> must be used inside <RadioGroup>.");
|
|
@@ -79,7 +79,10 @@ const SearchField = forwardRef<HTMLDivElement, SearchFieldProps>(
|
|
|
79
79
|
"navds-form-field",
|
|
80
80
|
`navds-form-field--${size ?? "medium"}`,
|
|
81
81
|
"navds-search-field",
|
|
82
|
-
{
|
|
82
|
+
{
|
|
83
|
+
"navds-search-field--error": hasError,
|
|
84
|
+
"navds-search-field--disabled": !!inputProps.disabled,
|
|
85
|
+
}
|
|
83
86
|
)}
|
|
84
87
|
>
|
|
85
88
|
<Label
|
|
@@ -94,6 +97,7 @@ const SearchField = forwardRef<HTMLDivElement, SearchFieldProps>(
|
|
|
94
97
|
</Label>
|
|
95
98
|
{!!description && (
|
|
96
99
|
<BodyShort
|
|
100
|
+
as="div"
|
|
97
101
|
className={cl("navds-text-field__description", {
|
|
98
102
|
"sr-only": hideLabel,
|
|
99
103
|
})}
|
|
@@ -15,7 +15,7 @@ export const All = () => {
|
|
|
15
15
|
<h1>SearchField</h1>
|
|
16
16
|
<SearchField
|
|
17
17
|
label="Mollit eiusmod"
|
|
18
|
-
description=
|
|
18
|
+
description={<div>Ea cupidatat eu sunt commodo</div>}
|
|
19
19
|
>
|
|
20
20
|
<SearchField.Input />
|
|
21
21
|
<SearchField.Button>
|
|
@@ -170,6 +170,30 @@ export const All = () => {
|
|
|
170
170
|
<SearchField.Input />
|
|
171
171
|
</SearchField>
|
|
172
172
|
</Fieldset>
|
|
173
|
+
|
|
174
|
+
<h2>Disabled </h2>
|
|
175
|
+
<SearchField
|
|
176
|
+
disabled
|
|
177
|
+
label="Mollit eiusmod"
|
|
178
|
+
description="Ea cupidatat eu sunt commodo"
|
|
179
|
+
>
|
|
180
|
+
<SearchField.Input />
|
|
181
|
+
<SearchField.Button>
|
|
182
|
+
<Search /> Søk
|
|
183
|
+
</SearchField.Button>
|
|
184
|
+
</SearchField>
|
|
185
|
+
<Fieldset legend="Filter" disabled>
|
|
186
|
+
<SearchField
|
|
187
|
+
label="Mollit eiusmod"
|
|
188
|
+
description="Ea cupidatat eu sunt commodo"
|
|
189
|
+
error="Errormsg"
|
|
190
|
+
>
|
|
191
|
+
<SearchField.Input />
|
|
192
|
+
<SearchField.Button>
|
|
193
|
+
<Search /> Søk
|
|
194
|
+
</SearchField.Button>
|
|
195
|
+
</SearchField>
|
|
196
|
+
</Fieldset>
|
|
173
197
|
</>
|
|
174
198
|
);
|
|
175
199
|
};
|
|
@@ -21,9 +21,13 @@ export const All = () => {
|
|
|
21
21
|
|
|
22
22
|
<Fieldset
|
|
23
23
|
legend="Mollit eiusmod"
|
|
24
|
-
description=
|
|
24
|
+
description={<div>Quis reprehenderit esse cillum</div>}
|
|
25
25
|
>
|
|
26
|
-
<TextField
|
|
26
|
+
<TextField
|
|
27
|
+
label="Textfield label"
|
|
28
|
+
hideLabel
|
|
29
|
+
description={<div>Quis reprehenderit esse cillum</div>}
|
|
30
|
+
/>
|
|
27
31
|
<TextField label="Textfield label" hideLabel />
|
|
28
32
|
</Fieldset>
|
|
29
33
|
|
|
@@ -19,7 +19,7 @@ export const All = () => {
|
|
|
19
19
|
|
|
20
20
|
<h2>Description</h2>
|
|
21
21
|
|
|
22
|
-
<Select label="Ipsum enim quis culpa" description=
|
|
22
|
+
<Select label="Ipsum enim quis culpa" description={<div>Aute enim</div>}>
|
|
23
23
|
<option value="">Velg land</option>
|
|
24
24
|
<option value="norge">Norge</option>
|
|
25
25
|
<option value="sverige">Sverige</option>
|
|
@@ -15,7 +15,10 @@ export const All = () => {
|
|
|
15
15
|
|
|
16
16
|
<h2>Description</h2>
|
|
17
17
|
|
|
18
|
-
<TextField
|
|
18
|
+
<TextField
|
|
19
|
+
label="Laborum excepteur"
|
|
20
|
+
description={<div>Cillum mollit</div>}
|
|
21
|
+
/>
|
|
19
22
|
|
|
20
23
|
<h2>Passord-type</h2>
|
|
21
24
|
<TextField label="Passord" type="password" />
|
|
@@ -52,6 +55,25 @@ export const All = () => {
|
|
|
52
55
|
description="Cillum mollit"
|
|
53
56
|
disabled
|
|
54
57
|
/>
|
|
58
|
+
<TextField
|
|
59
|
+
size="small"
|
|
60
|
+
label="Laborum excepteur"
|
|
61
|
+
description="Cillum mollit"
|
|
62
|
+
disabled
|
|
63
|
+
/>
|
|
64
|
+
<h2>Readonly</h2>
|
|
65
|
+
|
|
66
|
+
<TextField
|
|
67
|
+
label="Laborum excepteur"
|
|
68
|
+
description="Cillum mollit"
|
|
69
|
+
readOnly
|
|
70
|
+
/>
|
|
71
|
+
<TextField
|
|
72
|
+
label="Laborum excepteur"
|
|
73
|
+
description="Cillum mollit"
|
|
74
|
+
size="small"
|
|
75
|
+
readOnly
|
|
76
|
+
/>
|
|
55
77
|
</div>
|
|
56
78
|
);
|
|
57
79
|
};
|
|
@@ -23,7 +23,7 @@ export const All = () => {
|
|
|
23
23
|
|
|
24
24
|
<Textarea
|
|
25
25
|
label="In anim elit"
|
|
26
|
-
description=
|
|
26
|
+
description={<div>Reprehenderit esse proident</div>}
|
|
27
27
|
value={value}
|
|
28
28
|
onChange={handleChange}
|
|
29
29
|
/>
|
|
@@ -78,7 +78,17 @@ export const All = () => {
|
|
|
78
78
|
description="Reprehenderit esse proident"
|
|
79
79
|
maxLength={400}
|
|
80
80
|
disabled
|
|
81
|
-
value=
|
|
81
|
+
value="Consectetur commodo mollit voluptate esse minim elit deserunt fugiat consectetur laboris."
|
|
82
|
+
onChange={handleChange}
|
|
83
|
+
/>
|
|
84
|
+
<h2>Readonly</h2>
|
|
85
|
+
|
|
86
|
+
<Textarea
|
|
87
|
+
label="In anim elit"
|
|
88
|
+
description="Reprehenderit esse proident"
|
|
89
|
+
maxLength={400}
|
|
90
|
+
readOnly
|
|
91
|
+
value="Consectetur commodo mollit voluptate esse minim elit deserunt fugiat consectetur laboris."
|
|
82
92
|
onChange={handleChange}
|
|
83
93
|
/>
|
|
84
94
|
</div>
|