@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.
Files changed (69) hide show
  1. package/cjs/form/combobox/Combobox.js +5 -2
  2. package/cjs/form/combobox/Combobox.js.map +1 -1
  3. package/cjs/form/combobox/ComboboxProvider.js +2 -1
  4. package/cjs/form/combobox/ComboboxProvider.js.map +1 -1
  5. package/cjs/form/combobox/ComboboxWrapper.d.ts +1 -0
  6. package/cjs/form/combobox/ComboboxWrapper.js +3 -1
  7. package/cjs/form/combobox/ComboboxWrapper.js.map +1 -1
  8. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +6 -1
  9. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  10. package/cjs/form/combobox/Input/Input.context.d.ts +1 -0
  11. package/cjs/form/combobox/Input/Input.context.js +2 -1
  12. package/cjs/form/combobox/Input/Input.context.js.map +1 -1
  13. package/cjs/form/combobox/Input/Input.js +6 -2
  14. package/cjs/form/combobox/Input/Input.js.map +1 -1
  15. package/cjs/form/combobox/Input/InputController.js +3 -3
  16. package/cjs/form/combobox/Input/InputController.js.map +1 -1
  17. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +2 -2
  18. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  19. package/cjs/list/List.d.ts +4 -1
  20. package/cjs/list/List.js +6 -12
  21. package/cjs/list/List.js.map +1 -1
  22. package/cjs/list/ListItem.d.ts +1 -1
  23. package/cjs/list/ListItem.js +3 -3
  24. package/cjs/list/ListItem.js.map +1 -1
  25. package/cjs/list/context.d.ts +2 -3
  26. package/cjs/list/context.js +0 -1
  27. package/cjs/list/context.js.map +1 -1
  28. package/cjs/list/types.d.ts +1 -1
  29. package/esm/form/combobox/Combobox.js +5 -2
  30. package/esm/form/combobox/Combobox.js.map +1 -1
  31. package/esm/form/combobox/ComboboxProvider.js +2 -1
  32. package/esm/form/combobox/ComboboxProvider.js.map +1 -1
  33. package/esm/form/combobox/ComboboxWrapper.d.ts +1 -0
  34. package/esm/form/combobox/ComboboxWrapper.js +3 -1
  35. package/esm/form/combobox/ComboboxWrapper.js.map +1 -1
  36. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +6 -1
  37. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  38. package/esm/form/combobox/Input/Input.context.d.ts +1 -0
  39. package/esm/form/combobox/Input/Input.context.js +2 -1
  40. package/esm/form/combobox/Input/Input.context.js.map +1 -1
  41. package/esm/form/combobox/Input/Input.js +6 -2
  42. package/esm/form/combobox/Input/Input.js.map +1 -1
  43. package/esm/form/combobox/Input/InputController.js +3 -3
  44. package/esm/form/combobox/Input/InputController.js.map +1 -1
  45. package/esm/form/combobox/SelectedOptions/SelectedOptions.js +2 -2
  46. package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  47. package/esm/list/List.d.ts +4 -1
  48. package/esm/list/List.js +7 -13
  49. package/esm/list/List.js.map +1 -1
  50. package/esm/list/ListItem.d.ts +1 -1
  51. package/esm/list/ListItem.js +3 -3
  52. package/esm/list/ListItem.js.map +1 -1
  53. package/esm/list/context.d.ts +2 -3
  54. package/esm/list/context.js +0 -1
  55. package/esm/list/context.js.map +1 -1
  56. package/esm/list/types.d.ts +1 -1
  57. package/package.json +3 -3
  58. package/src/form/combobox/Combobox.tsx +3 -0
  59. package/src/form/combobox/ComboboxProvider.tsx +2 -0
  60. package/src/form/combobox/ComboboxWrapper.tsx +4 -1
  61. package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +7 -1
  62. package/src/form/combobox/Input/Input.context.tsx +3 -0
  63. package/src/form/combobox/Input/Input.tsx +6 -0
  64. package/src/form/combobox/Input/InputController.tsx +3 -0
  65. package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +8 -2
  66. package/src/list/List.tsx +15 -25
  67. package/src/list/ListItem.tsx +6 -6
  68. package/src/list/context.ts +2 -4
  69. 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
- import { ListProps } from "./types";
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 ariaId = useId();
48
+ const { size: contextSize } = useContext(ListContext);
46
49
 
47
- const { isNested, size: _size } = useContext(ListContext);
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
- <div
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
- <BodyShort size={listSize} id={`description-${ariaId}`}>
76
- {description}
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
  },
@@ -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="6"
34
- height="6"
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
- <BodyLong as="div" size={size} className="navds-list__item-content">
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
- </BodyLong>
55
+ </div>
56
56
  </li>
57
57
  );
58
58
  },
@@ -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
- isNested: boolean | null;
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 padding, height and font-size.
22
+ * Changes margin-block on list and font size on items.
23
23
  * @default "medium"
24
24
  */
25
25
  size?: "medium" | "small";