@navikt/ds-react 7.1.0 → 7.1.2
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/combobox/Combobox.js +5 -2
- package/cjs/form/combobox/Combobox.js.map +1 -1
- package/cjs/form/combobox/ComboboxProvider.js +2 -1
- package/cjs/form/combobox/ComboboxProvider.js.map +1 -1
- package/cjs/form/combobox/ComboboxWrapper.d.ts +1 -0
- package/cjs/form/combobox/ComboboxWrapper.js +3 -1
- package/cjs/form/combobox/ComboboxWrapper.js.map +1 -1
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +6 -1
- package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/cjs/form/combobox/Input/Input.context.d.ts +1 -0
- package/cjs/form/combobox/Input/Input.context.js +2 -1
- package/cjs/form/combobox/Input/Input.context.js.map +1 -1
- package/cjs/form/combobox/Input/Input.js +6 -2
- package/cjs/form/combobox/Input/Input.js.map +1 -1
- package/cjs/form/combobox/Input/InputController.js +3 -3
- package/cjs/form/combobox/Input/InputController.js.map +1 -1
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +2 -2
- package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/cjs/list/List.d.ts +4 -1
- package/cjs/list/List.js +6 -12
- package/cjs/list/List.js.map +1 -1
- package/cjs/list/ListItem.d.ts +1 -1
- package/cjs/list/ListItem.js +3 -3
- package/cjs/list/ListItem.js.map +1 -1
- package/cjs/list/context.d.ts +2 -3
- package/cjs/list/context.js +0 -1
- package/cjs/list/context.js.map +1 -1
- package/cjs/list/types.d.ts +1 -1
- package/esm/form/combobox/Combobox.js +5 -2
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/ComboboxProvider.js +2 -1
- package/esm/form/combobox/ComboboxProvider.js.map +1 -1
- package/esm/form/combobox/ComboboxWrapper.d.ts +1 -0
- package/esm/form/combobox/ComboboxWrapper.js +3 -1
- package/esm/form/combobox/ComboboxWrapper.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +6 -1
- package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
- package/esm/form/combobox/Input/Input.context.d.ts +1 -0
- package/esm/form/combobox/Input/Input.context.js +2 -1
- package/esm/form/combobox/Input/Input.context.js.map +1 -1
- package/esm/form/combobox/Input/Input.js +6 -2
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/combobox/Input/InputController.js +3 -3
- package/esm/form/combobox/Input/InputController.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js +2 -2
- package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
- package/esm/list/List.d.ts +4 -1
- package/esm/list/List.js +7 -13
- package/esm/list/List.js.map +1 -1
- package/esm/list/ListItem.d.ts +1 -1
- package/esm/list/ListItem.js +3 -3
- package/esm/list/ListItem.js.map +1 -1
- package/esm/list/context.d.ts +2 -3
- package/esm/list/context.js +0 -1
- package/esm/list/context.js.map +1 -1
- package/esm/list/types.d.ts +1 -1
- package/package.json +3 -3
- package/src/form/combobox/Combobox.tsx +3 -0
- package/src/form/combobox/ComboboxProvider.tsx +2 -0
- package/src/form/combobox/ComboboxWrapper.tsx +4 -1
- package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +7 -1
- package/src/form/combobox/Input/Input.context.tsx +3 -0
- package/src/form/combobox/Input/Input.tsx +6 -0
- package/src/form/combobox/Input/InputController.tsx +3 -0
- package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +8 -2
- package/src/list/List.tsx +15 -25
- package/src/list/ListItem.tsx +6 -6
- package/src/list/context.ts +2 -4
- package/src/list/types.ts +1 -1
package/src/list/List.tsx
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
2
|
import React, { forwardRef, useContext } from "react";
|
|
3
|
-
import { BodyShort, Heading } from "../typography";
|
|
4
|
-
import { useId } from "../util/hooks";
|
|
3
|
+
import { BodyLong, BodyShort, Heading } from "../typography";
|
|
5
4
|
import { ListItem } from "./ListItem";
|
|
6
5
|
import { ListContext } from "./context";
|
|
7
|
-
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
|
+
import type { ListItemProps, ListProps } from "./types";
|
|
8
8
|
|
|
9
9
|
export interface ListComponent
|
|
10
10
|
extends React.ForwardRefExoticComponent<
|
|
11
11
|
ListProps & React.RefAttributes<HTMLDivElement>
|
|
12
12
|
> {
|
|
13
|
+
/**
|
|
14
|
+
* @see 🏷️ {@link ListItemProps}
|
|
15
|
+
*/
|
|
13
16
|
Item: typeof ListItem;
|
|
14
17
|
}
|
|
15
18
|
|
|
@@ -42,47 +45,34 @@ export const List = forwardRef<HTMLDivElement, ListProps>(
|
|
|
42
45
|
},
|
|
43
46
|
ref,
|
|
44
47
|
) => {
|
|
45
|
-
const
|
|
48
|
+
const { size: contextSize } = useContext(ListContext);
|
|
46
49
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const listSize = size ?? _size ?? "medium";
|
|
50
|
+
const listSize = size ?? contextSize;
|
|
50
51
|
return (
|
|
51
52
|
<ListContext.Provider
|
|
52
53
|
value={{
|
|
53
54
|
listType: ListTag,
|
|
54
|
-
isNested: isNested === null ? false : true,
|
|
55
55
|
size: listSize,
|
|
56
56
|
}}
|
|
57
57
|
>
|
|
58
|
-
<
|
|
58
|
+
<BodyLong
|
|
59
|
+
as="div"
|
|
59
60
|
{...rest}
|
|
61
|
+
size={size}
|
|
60
62
|
ref={ref}
|
|
61
|
-
className={cl("navds-list", `navds-list--${listSize}`, className
|
|
62
|
-
"navds-list--nested": isNested === null ? false : true,
|
|
63
|
-
})}
|
|
63
|
+
className={cl("navds-list", `navds-list--${listSize}`, className)}
|
|
64
64
|
>
|
|
65
65
|
{title && (
|
|
66
66
|
<Heading
|
|
67
|
-
id={`tittel-${ariaId}`}
|
|
68
67
|
size={listSize === "medium" ? "small" : "xsmall"}
|
|
69
68
|
as={headingTag}
|
|
70
69
|
>
|
|
71
70
|
{title}
|
|
72
71
|
</Heading>
|
|
73
72
|
)}
|
|
74
|
-
{description &&
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
</BodyShort>
|
|
78
|
-
)}
|
|
79
|
-
<ListTag
|
|
80
|
-
aria-labelledby={title && `tittel-${ariaId}`}
|
|
81
|
-
aria-describedby={description && `description-${ariaId}`}
|
|
82
|
-
>
|
|
83
|
-
{children}
|
|
84
|
-
</ListTag>
|
|
85
|
-
</div>
|
|
73
|
+
{description && <BodyShort size={listSize}>{description}</BodyShort>}
|
|
74
|
+
<ListTag role="list">{children}</ListTag>
|
|
75
|
+
</BodyLong>
|
|
86
76
|
</ListContext.Provider>
|
|
87
77
|
);
|
|
88
78
|
},
|
package/src/list/ListItem.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import cl from "clsx";
|
|
|
2
2
|
import React, { forwardRef, useContext } from "react";
|
|
3
3
|
import { BodyLong } from "../typography";
|
|
4
4
|
import { ListContext } from "./context";
|
|
5
|
-
import { ListItemProps } from "./types";
|
|
5
|
+
import type { ListItemProps } from "./types";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @see 🏷️ {@link ListItemProps}
|
|
@@ -21,7 +21,7 @@ export const ListItem = forwardRef<HTMLLIElement, ListItemProps>(
|
|
|
21
21
|
<li {...rest} ref={ref} className={cl("navds-list__item", className)}>
|
|
22
22
|
{listType === "ul" && (
|
|
23
23
|
<div
|
|
24
|
-
className={cl({
|
|
24
|
+
className={cl("navds-list__item-marker", {
|
|
25
25
|
"navds-list__item-marker--icon": icon,
|
|
26
26
|
"navds-list__item-marker--bullet": !icon,
|
|
27
27
|
})}
|
|
@@ -30,8 +30,8 @@ export const ListItem = forwardRef<HTMLLIElement, ListItemProps>(
|
|
|
30
30
|
icon
|
|
31
31
|
) : (
|
|
32
32
|
<svg
|
|
33
|
-
width="
|
|
34
|
-
height="
|
|
33
|
+
width="0.375rem"
|
|
34
|
+
height="0.375rem"
|
|
35
35
|
viewBox="0 0 6 6"
|
|
36
36
|
fill="none"
|
|
37
37
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -45,14 +45,14 @@ export const ListItem = forwardRef<HTMLLIElement, ListItemProps>(
|
|
|
45
45
|
</div>
|
|
46
46
|
)}
|
|
47
47
|
|
|
48
|
-
<
|
|
48
|
+
<div>
|
|
49
49
|
{title && (
|
|
50
50
|
<BodyLong as="p" size={size} weight="semibold">
|
|
51
51
|
{title}
|
|
52
52
|
</BodyLong>
|
|
53
53
|
)}
|
|
54
54
|
{children}
|
|
55
|
-
</
|
|
55
|
+
</div>
|
|
56
56
|
</li>
|
|
57
57
|
);
|
|
58
58
|
},
|
package/src/list/context.ts
CHANGED
|
@@ -2,13 +2,11 @@ import { createContext } from "react";
|
|
|
2
2
|
import { ListProps } from "./types";
|
|
3
3
|
|
|
4
4
|
interface ListContextProps {
|
|
5
|
-
listType: ListProps["as"]
|
|
6
|
-
|
|
7
|
-
size: ListProps["size"];
|
|
5
|
+
listType: Exclude<ListProps["as"], undefined>;
|
|
6
|
+
size: Exclude<ListProps["size"], undefined>;
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
export const ListContext = createContext<ListContextProps>({
|
|
11
10
|
listType: "ul",
|
|
12
|
-
isNested: null,
|
|
13
11
|
size: "medium",
|
|
14
12
|
});
|
package/src/list/types.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface ListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
19
19
|
*/
|
|
20
20
|
headingTag?: React.ElementType<any>;
|
|
21
21
|
/**
|
|
22
|
-
* Changes
|
|
22
|
+
* Changes margin-block on list and font size on items.
|
|
23
23
|
* @default "medium"
|
|
24
24
|
*/
|
|
25
25
|
size?: "medium" | "small";
|