@navikt/ds-react 7.30.1 → 7.32.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 (174) hide show
  1. package/cjs/chat/Chat.d.ts +1 -1
  2. package/cjs/chat/Chat.js.map +1 -1
  3. package/cjs/copybutton/CopyButton.js +1 -1
  4. package/cjs/copybutton/CopyButton.js.map +1 -1
  5. package/cjs/form/checkbox/Checkbox.js +1 -1
  6. package/cjs/form/checkbox/Checkbox.js.map +1 -1
  7. package/cjs/form/combobox/Combobox.js +15 -13
  8. package/cjs/form/combobox/Combobox.js.map +1 -1
  9. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +53 -3
  10. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  11. package/cjs/form/combobox/FilteredOptions/useVirtualFocus.js.map +1 -1
  12. package/cjs/form/combobox/Input/Input.context.d.ts +2 -2
  13. package/cjs/form/combobox/Input/InputController.js +15 -14
  14. package/cjs/form/combobox/Input/InputController.js.map +1 -1
  15. package/cjs/form/file-upload/useFileUpload.d.ts +1 -1
  16. package/cjs/form/radio/Radio.js +1 -1
  17. package/cjs/form/radio/Radio.js.map +1 -1
  18. package/cjs/form/useFormField.js.map +1 -1
  19. package/cjs/modal/ModalUtils.d.ts +2 -2
  20. package/cjs/modal/ModalUtils.js.map +1 -1
  21. package/cjs/overlays/dismissablelayer/DismissableLayer.d.ts +1 -1
  22. package/cjs/overlays/floating/Floating.d.ts +11 -0
  23. package/cjs/overlays/floating/Floating.js +32 -8
  24. package/cjs/overlays/floating/Floating.js.map +1 -1
  25. package/cjs/overlays/overlay/hooks/useAnimationsFinished.d.ts +27 -0
  26. package/cjs/overlays/overlay/hooks/useAnimationsFinished.js +138 -0
  27. package/cjs/overlays/overlay/hooks/useAnimationsFinished.js.map +1 -0
  28. package/cjs/overlays/overlay/hooks/useEventCallback.d.ts +6 -0
  29. package/cjs/overlays/overlay/hooks/useEventCallback.js +89 -0
  30. package/cjs/overlays/overlay/hooks/useEventCallback.js.map +1 -0
  31. package/cjs/overlays/overlay/hooks/useLatestRef.d.ts +5 -0
  32. package/cjs/overlays/overlay/hooks/useLatestRef.js +23 -0
  33. package/cjs/overlays/overlay/hooks/useLatestRef.js.map +1 -0
  34. package/cjs/overlays/overlay/hooks/useOpenChangeAnimationComplete.d.ts +31 -0
  35. package/cjs/overlays/overlay/hooks/useOpenChangeAnimationComplete.js +35 -0
  36. package/cjs/overlays/overlay/hooks/useOpenChangeAnimationComplete.js.map +1 -0
  37. package/cjs/overlays/overlay/hooks/useRefWithInit.d.ts +7 -0
  38. package/cjs/overlays/overlay/hooks/useRefWithInit.js +14 -0
  39. package/cjs/overlays/overlay/hooks/useRefWithInit.js.map +1 -0
  40. package/cjs/overlays/overlay/hooks/useTransitionStatus.d.ts +38 -0
  41. package/cjs/overlays/overlay/hooks/useTransitionStatus.js +118 -0
  42. package/cjs/overlays/overlay/hooks/useTransitionStatus.js.map +1 -0
  43. package/cjs/progress-bar/ProgressBar.js +1 -1
  44. package/cjs/progress-bar/ProgressBar.js.map +1 -1
  45. package/cjs/read-more/ReadMore.d.ts +2 -9
  46. package/cjs/read-more/ReadMore.js +1 -8
  47. package/cjs/read-more/ReadMore.js.map +1 -1
  48. package/cjs/table/AnimateHeight.js +2 -2
  49. package/cjs/table/AnimateHeight.js.map +1 -1
  50. package/cjs/table/ExpandableRow.d.ts +1 -1
  51. package/cjs/table/ExpandableRow.js +2 -10
  52. package/cjs/table/ExpandableRow.js.map +1 -1
  53. package/cjs/table/Row.d.ts +7 -0
  54. package/cjs/table/Row.js +13 -2
  55. package/cjs/table/Row.js.map +1 -1
  56. package/cjs/table/Table.utils.d.ts +9 -0
  57. package/cjs/table/Table.utils.js +57 -0
  58. package/cjs/table/Table.utils.js.map +1 -0
  59. package/cjs/tabs/Tabs.context.d.ts +1 -1
  60. package/cjs/tabs/parts/tab/useTab.d.ts +1 -1
  61. package/cjs/tabs/parts/tablist/useScrollButtons.d.ts +1 -1
  62. package/cjs/tabs/parts/tablist/useScrollButtons.js.map +1 -1
  63. package/cjs/toggle-group/ToggleGroup.context.d.ts +1 -1
  64. package/cjs/toggle-group/parts/useToggleItem.d.ts +1 -1
  65. package/cjs/util/hooks/descendants/useDescendant.d.ts +1 -1
  66. package/cjs/util/hooks/useMergeRefs.d.ts +3 -3
  67. package/cjs/util/hooks/useMergeRefs.js +3 -3
  68. package/cjs/util/hooks/useMergeRefs.js.map +1 -1
  69. package/cjs/util/renderStoriesForChromatic.d.ts +2 -2
  70. package/cjs/util/renderStoriesForChromatic.js +2 -2
  71. package/cjs/util/renderStoriesForChromatic.js.map +1 -1
  72. package/cjs/util/virtualfocus/Context.d.ts +1 -1
  73. package/esm/chat/Chat.d.ts +1 -1
  74. package/esm/chat/Chat.js.map +1 -1
  75. package/esm/copybutton/CopyButton.js +1 -1
  76. package/esm/copybutton/CopyButton.js.map +1 -1
  77. package/esm/form/checkbox/Checkbox.js +1 -1
  78. package/esm/form/checkbox/Checkbox.js.map +1 -1
  79. package/esm/form/combobox/Combobox.js +15 -13
  80. package/esm/form/combobox/Combobox.js.map +1 -1
  81. package/esm/form/combobox/FilteredOptions/FilteredOptions.js +21 -4
  82. package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  83. package/esm/form/combobox/FilteredOptions/useVirtualFocus.js.map +1 -1
  84. package/esm/form/combobox/Input/Input.context.d.ts +2 -2
  85. package/esm/form/combobox/Input/InputController.js +15 -14
  86. package/esm/form/combobox/Input/InputController.js.map +1 -1
  87. package/esm/form/file-upload/useFileUpload.d.ts +1 -1
  88. package/esm/form/radio/Radio.js +1 -1
  89. package/esm/form/radio/Radio.js.map +1 -1
  90. package/esm/form/useFormField.js.map +1 -1
  91. package/esm/modal/ModalUtils.d.ts +2 -2
  92. package/esm/modal/ModalUtils.js.map +1 -1
  93. package/esm/overlays/dismissablelayer/DismissableLayer.d.ts +1 -1
  94. package/esm/overlays/floating/Floating.d.ts +11 -0
  95. package/esm/overlays/floating/Floating.js +32 -8
  96. package/esm/overlays/floating/Floating.js.map +1 -1
  97. package/esm/overlays/overlay/hooks/useAnimationsFinished.d.ts +27 -0
  98. package/esm/overlays/overlay/hooks/useAnimationsFinished.js +99 -0
  99. package/esm/overlays/overlay/hooks/useAnimationsFinished.js.map +1 -0
  100. package/esm/overlays/overlay/hooks/useEventCallback.d.ts +6 -0
  101. package/esm/overlays/overlay/hooks/useEventCallback.js +53 -0
  102. package/esm/overlays/overlay/hooks/useEventCallback.js.map +1 -0
  103. package/esm/overlays/overlay/hooks/useLatestRef.d.ts +5 -0
  104. package/esm/overlays/overlay/hooks/useLatestRef.js +20 -0
  105. package/esm/overlays/overlay/hooks/useLatestRef.js.map +1 -0
  106. package/esm/overlays/overlay/hooks/useOpenChangeAnimationComplete.d.ts +31 -0
  107. package/esm/overlays/overlay/hooks/useOpenChangeAnimationComplete.js +32 -0
  108. package/esm/overlays/overlay/hooks/useOpenChangeAnimationComplete.js.map +1 -0
  109. package/esm/overlays/overlay/hooks/useRefWithInit.d.ts +7 -0
  110. package/esm/overlays/overlay/hooks/useRefWithInit.js +12 -0
  111. package/esm/overlays/overlay/hooks/useRefWithInit.js.map +1 -0
  112. package/esm/overlays/overlay/hooks/useTransitionStatus.d.ts +38 -0
  113. package/esm/overlays/overlay/hooks/useTransitionStatus.js +113 -0
  114. package/esm/overlays/overlay/hooks/useTransitionStatus.js.map +1 -0
  115. package/esm/progress-bar/ProgressBar.js +1 -1
  116. package/esm/progress-bar/ProgressBar.js.map +1 -1
  117. package/esm/read-more/ReadMore.d.ts +2 -9
  118. package/esm/read-more/ReadMore.js +1 -8
  119. package/esm/read-more/ReadMore.js.map +1 -1
  120. package/esm/table/AnimateHeight.js +2 -2
  121. package/esm/table/AnimateHeight.js.map +1 -1
  122. package/esm/table/ExpandableRow.d.ts +1 -1
  123. package/esm/table/ExpandableRow.js +2 -10
  124. package/esm/table/ExpandableRow.js.map +1 -1
  125. package/esm/table/Row.d.ts +7 -0
  126. package/esm/table/Row.js +13 -2
  127. package/esm/table/Row.js.map +1 -1
  128. package/esm/table/Table.utils.d.ts +9 -0
  129. package/esm/table/Table.utils.js +55 -0
  130. package/esm/table/Table.utils.js.map +1 -0
  131. package/esm/tabs/Tabs.context.d.ts +1 -1
  132. package/esm/tabs/parts/tab/useTab.d.ts +1 -1
  133. package/esm/tabs/parts/tablist/useScrollButtons.d.ts +1 -1
  134. package/esm/tabs/parts/tablist/useScrollButtons.js.map +1 -1
  135. package/esm/toggle-group/ToggleGroup.context.d.ts +1 -1
  136. package/esm/toggle-group/parts/useToggleItem.d.ts +1 -1
  137. package/esm/util/hooks/descendants/useDescendant.d.ts +1 -1
  138. package/esm/util/hooks/useMergeRefs.d.ts +3 -3
  139. package/esm/util/hooks/useMergeRefs.js +3 -3
  140. package/esm/util/hooks/useMergeRefs.js.map +1 -1
  141. package/esm/util/renderStoriesForChromatic.d.ts +2 -2
  142. package/esm/util/renderStoriesForChromatic.js +2 -2
  143. package/esm/util/renderStoriesForChromatic.js.map +1 -1
  144. package/esm/util/virtualfocus/Context.d.ts +1 -1
  145. package/package.json +4 -4
  146. package/src/chat/Chat.tsx +3 -3
  147. package/src/copybutton/CopyButton.tsx +1 -1
  148. package/src/form/checkbox/Checkbox.tsx +5 -3
  149. package/src/form/combobox/Combobox.tsx +44 -41
  150. package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +29 -4
  151. package/src/form/combobox/FilteredOptions/useVirtualFocus.ts +1 -0
  152. package/src/form/combobox/Input/Input.context.tsx +2 -2
  153. package/src/form/combobox/Input/InputController.tsx +33 -29
  154. package/src/form/radio/Radio.tsx +5 -3
  155. package/src/form/useFormField.ts +1 -1
  156. package/src/modal/ModalUtils.ts +2 -2
  157. package/src/overlays/action-menu/ActionMenu.tsx +1 -1
  158. package/src/overlays/floating/Floating.tsx +110 -59
  159. package/src/overlays/overlay/hooks/useAnimationsFinished.ts +117 -0
  160. package/src/overlays/overlay/hooks/useEventCallback.ts +73 -0
  161. package/src/overlays/overlay/hooks/useLatestRef.ts +25 -0
  162. package/src/overlays/overlay/hooks/useOpenChangeAnimationComplete.ts +66 -0
  163. package/src/overlays/overlay/hooks/useRefWithInit.ts +25 -0
  164. package/src/overlays/overlay/hooks/useTransitionStatus.ts +145 -0
  165. package/src/progress-bar/ProgressBar.tsx +1 -1
  166. package/src/read-more/ReadMore.tsx +4 -11
  167. package/src/table/AnimateHeight.tsx +2 -2
  168. package/src/table/ExpandableRow.tsx +4 -17
  169. package/src/table/Row.tsx +33 -1
  170. package/src/table/Table.utils.ts +65 -0
  171. package/src/tabs/parts/tablist/useScrollButtons.ts +3 -1
  172. package/src/util/hooks/useMergeRefs.ts +5 -5
  173. package/src/util/link-anchor/LinkAnchor.tsx +1 -1
  174. package/src/util/renderStoriesForChromatic.tsx +4 -5
@@ -1,5 +1,5 @@
1
- import { StoryObj } from "@storybook/react";
1
+ import { StoryObj } from "@storybook/react-vite";
2
2
  import React from "react";
3
3
  export declare function renderStoriesForChromatic(stories: Record<string, {
4
4
  render?: (...args: any[]) => React.ReactNode;
5
- } | React.FunctionComponent<void>>): StoryObj;
5
+ } | React.FunctionComponent>): StoryObj;
@@ -1,11 +1,11 @@
1
1
  import React from "react";
2
2
  export function renderStoriesForChromatic(stories) {
3
3
  return {
4
- render: (...args) => (React.createElement(React.Fragment, null, Object.entries(stories).map(([storyName, story]) => {
4
+ render: (...args) => (React.createElement(React.Fragment, null, Object.entries(stories).map(([storyName, Story]) => {
5
5
  var _a;
6
6
  return (React.createElement("div", { key: storyName },
7
7
  React.createElement("h2", { className: "storyheading" }, storyName),
8
- typeof story === "function" ? story() : (_a = story.render) === null || _a === void 0 ? void 0 : _a.call(story, ...args)));
8
+ typeof Story === "function" ? React.createElement(Story, null) : (_a = Story.render) === null || _a === void 0 ? void 0 : _a.call(Story, ...args)));
9
9
  }))),
10
10
  parameters: {
11
11
  chromatic: { disable: false },
@@ -1 +1 @@
1
- {"version":3,"file":"renderStoriesForChromatic.js","sourceRoot":"","sources":["../../src/util/renderStoriesForChromatic.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,UAAU,yBAAyB,CACvC,OAIC;IAED,OAAO;QACL,MAAM,EAAE,CAAC,GAAG,IAA0C,EAAE,EAAE,CAAC,CACzD,0CACG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE;;YAAC,OAAA,CACnD,6BAAK,GAAG,EAAE,SAAS;gBACjB,4BAAI,SAAS,EAAC,cAAc,IAAE,SAAS,CAAM;gBAC5C,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAA,KAAK,CAAC,MAAM,sDAAG,GAAG,IAAI,CAAC,CAC5D,CACP,CAAA;SAAA,CAAC,CACD,CACJ;QACD,UAAU,EAAE;YACV,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;SAC9B;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"renderStoriesForChromatic.js","sourceRoot":"","sources":["../../src/util/renderStoriesForChromatic.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,UAAU,yBAAyB,CACvC,OAGC;IAED,OAAO;QACL,MAAM,EAAE,CAAC,GAAG,IAA0C,EAAE,EAAE,CAAC,CACzD,0CACG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE;;YAAC,OAAA,CACnD,6BAAK,GAAG,EAAE,SAAS;gBACjB,4BAAI,SAAS,EAAC,cAAc,IAAE,SAAS,CAAM;gBAC5C,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,oBAAC,KAAK,OAAG,CAAC,CAAC,CAAC,MAAA,KAAK,CAAC,MAAM,sDAAG,GAAG,IAAI,CAAC,CAC9D,CACP,CAAA;SAAA,CAAC,CACD,CACJ;QACD,UAAU,EAAE;YACV,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;SAC9B;KACF,CAAC;AACJ,CAAC"}
@@ -21,7 +21,7 @@ export declare const VirtualFocusDescendantsProvider: import("react").Provider<i
21
21
  }>;
22
22
  index: number;
23
23
  enabledIndex: number;
24
- register: (instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES];
24
+ register: (instance: HTMLDivElement | null) => void;
25
25
  };
26
26
  export declare const VirtualFocusInternalContextProvider: import("react").ForwardRefExoticComponent<{
27
27
  virtualFocusIdx: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "7.30.1",
3
+ "version": "7.32.0",
4
4
  "description": "React components from the Norwegian Labour and Welfare Administration.",
5
5
  "author": "Aksel, a team part of the Norwegian Labour and Welfare Administration.",
6
6
  "license": "MIT",
@@ -650,8 +650,8 @@
650
650
  "dependencies": {
651
651
  "@floating-ui/react": "0.27.8",
652
652
  "@floating-ui/react-dom": "^2.0.9",
653
- "@navikt/aksel-icons": "^7.30.1",
654
- "@navikt/ds-tokens": "^7.30.1",
653
+ "@navikt/aksel-icons": "^7.32.0",
654
+ "@navikt/ds-tokens": "^7.32.0",
655
655
  "clsx": "^2.1.0",
656
656
  "date-fns": "^4.0.0",
657
657
  "react-day-picker": "9.7.0"
@@ -673,7 +673,7 @@
673
673
  "rimraf": "6.0.1",
674
674
  "swr": "^2.3.6",
675
675
  "tsc-alias": "1.8.16",
676
- "tsx": "^4.19.1",
676
+ "tsx": "^4.20.6",
677
677
  "typescript": "5.8.3",
678
678
  "vitest": "^2.1.9"
679
679
  },
package/src/chat/Chat.tsx CHANGED
@@ -2,7 +2,7 @@ import React, { HTMLAttributes, forwardRef } from "react";
2
2
  import { useRenameCSS } from "../theme/Theme";
3
3
  import { AkselColor } from "../types";
4
4
  import { BodyLong, HeadingProps } from "../typography";
5
- import Bubble from "./Bubble";
5
+ import Bubble, { type ChatBubbleProps } from "./Bubble";
6
6
 
7
7
  export const VARIANTS = ["subtle", "info", "neutral"] as const;
8
8
  export const POSITIONS = ["left", "right"] as const;
@@ -60,7 +60,7 @@ interface ChatComponent
60
60
  ChatProps & React.RefAttributes<HTMLDivElement>
61
61
  > {
62
62
  /**
63
- * @see 🏷️ {@link BubbleProps}
63
+ * @see 🏷️ {@link ChatBubbleProps}
64
64
  */
65
65
  Bubble: typeof Bubble;
66
66
  }
@@ -128,7 +128,7 @@ export const Chat = forwardRef<HTMLDivElement, ChatProps>(
128
128
  className={cn("navds-chat__bubble-wrapper")}
129
129
  >
130
130
  {React.Children.map(children, (child, i) => {
131
- if (!React.isValidElement(child)) {
131
+ if (!React.isValidElement<ChatBubbleProps>(child)) {
132
132
  return null;
133
133
  }
134
134
 
@@ -94,7 +94,7 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
94
94
  ref,
95
95
  ) => {
96
96
  const [active, setActive] = useState(false);
97
- const timeoutRef = useRef<number>();
97
+ const timeoutRef = useRef<number>(undefined);
98
98
  const translate = useI18n("CopyButton");
99
99
 
100
100
  const { cn } = useRenameCSS();
@@ -42,9 +42,11 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
42
42
  "readOnly",
43
43
  ])}
44
44
  {...omit(inputProps, ["aria-invalid", "aria-describedby"])}
45
- aria-describedby={cl(inputProps["aria-describedby"], {
46
- [descriptionId]: props.description,
47
- })}
45
+ aria-describedby={
46
+ cl(inputProps["aria-describedby"], {
47
+ [descriptionId]: props.description,
48
+ }) || undefined
49
+ }
48
50
  type="checkbox"
49
51
  className={cn("navds-checkbox__input")}
50
52
  ref={(el) => {
@@ -1,4 +1,5 @@
1
1
  import React, { forwardRef } from "react";
2
+ import { Floating } from "../../overlays/floating/Floating";
2
3
  import { useRenameCSS } from "../../theme/Theme";
3
4
  import { BodyShort, ErrorMessage, Label } from "../../typography";
4
5
  import { ReadOnlyIconWithTitle } from "../ReadOnlyIcon";
@@ -34,52 +35,54 @@ export const Combobox = forwardRef<
34
35
  } = useInputContext();
35
36
 
36
37
  return (
37
- <ComboboxWrapper
38
- className={className}
39
- hasError={hasError}
40
- inputProps={inputProps}
41
- inputSize={size}
42
- toggleIsListOpen={toggleIsListOpen}
43
- >
44
- <Label
45
- htmlFor={inputProps.id}
46
- size={size}
47
- className={cn("navds-form-field__label", {
48
- "navds-sr-only": hideLabel,
49
- })}
38
+ <Floating>
39
+ <ComboboxWrapper
40
+ className={className}
41
+ hasError={hasError}
42
+ inputProps={inputProps}
43
+ inputSize={size}
44
+ toggleIsListOpen={toggleIsListOpen}
50
45
  >
51
- {readOnly && <ReadOnlyIconWithTitle />}
52
- {label}
53
- </Label>
54
- {!!description && (
55
- <BodyShort
56
- as="div"
57
- className={cn("navds-form-field__description", {
46
+ <Label
47
+ htmlFor={inputProps.id}
48
+ size={size}
49
+ className={cn("navds-form-field__label", {
58
50
  "navds-sr-only": hideLabel,
59
51
  })}
60
- id={inputDescriptionId}
61
- size={size}
62
52
  >
63
- {description}
64
- </BodyShort>
65
- )}
66
- <div className={cn("navds-combobox__wrapper")}>
67
- <InputController ref={ref} {...rest} />
68
- <FilteredOptions />
69
- </div>
70
- <div
71
- className={cn("navds-form-field__error")}
72
- id={errorId}
73
- aria-relevant="additions removals"
74
- aria-live="polite"
75
- >
76
- {showErrorMsg && (
77
- <ErrorMessage size={size} showIcon>
78
- {error}
79
- </ErrorMessage>
53
+ {readOnly && <ReadOnlyIconWithTitle />}
54
+ {label}
55
+ </Label>
56
+ {!!description && (
57
+ <BodyShort
58
+ as="div"
59
+ className={cn("navds-form-field__description", {
60
+ "navds-sr-only": hideLabel,
61
+ })}
62
+ id={inputDescriptionId}
63
+ size={size}
64
+ >
65
+ {description}
66
+ </BodyShort>
80
67
  )}
81
- </div>
82
- </ComboboxWrapper>
68
+ <div className={cn("navds-combobox__wrapper")}>
69
+ <InputController ref={ref} {...rest} />
70
+ <FilteredOptions />
71
+ </div>
72
+ <div
73
+ className={cn("navds-form-field__error")}
74
+ id={errorId}
75
+ aria-relevant="additions removals"
76
+ aria-live="polite"
77
+ >
78
+ {showErrorMsg && (
79
+ <ErrorMessage size={size} showIcon>
80
+ {error}
81
+ </ErrorMessage>
82
+ )}
83
+ </div>
84
+ </ComboboxWrapper>
85
+ </Floating>
83
86
  );
84
87
  });
85
88
 
@@ -1,5 +1,7 @@
1
- import React from "react";
2
- import { useRenameCSS } from "../../../theme/Theme";
1
+ import React, { useState } from "react";
2
+ import { Floating } from "../../../overlays/floating/Floating";
3
+ import { useRenameCSS, useThemeInternal } from "../../../theme/Theme";
4
+ import { useClientLayoutEffect } from "../../../util";
3
5
  import { useInputContext } from "../Input/Input.context";
4
6
  import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
5
7
  import AddNewOption from "./AddNewOption";
@@ -12,6 +14,7 @@ import { useFilteredOptionsContext } from "./filteredOptionsContext";
12
14
 
13
15
  const FilteredOptions = () => {
14
16
  const { cn } = useRenameCSS();
17
+ const themeContext = useThemeInternal(false);
15
18
  const {
16
19
  inputProps: { id },
17
20
  } = useInputContext();
@@ -25,6 +28,16 @@ const FilteredOptions = () => {
25
28
  isMouseLastUsedInputDevice,
26
29
  isValueNew,
27
30
  } = useFilteredOptionsContext();
31
+ const [localOpen, setLocalOpen] = useState(isListOpen);
32
+
33
+ /**
34
+ * This is a dirty hack to make the positioning-logic in Floating base the "flip" on the static 290px max-height,
35
+ * instead of the dynamic one based on available space. Without this, the list won't flip to top when there's
36
+ * not enough space below the input.
37
+ */
38
+ useClientLayoutEffect(() => {
39
+ queueMicrotask(() => setLocalOpen(isListOpen));
40
+ }, [isListOpen]);
28
41
 
29
42
  const { maxSelected, isMultiSelect } = useSelectedOptionsContext();
30
43
 
@@ -37,14 +50,26 @@ const FilteredOptions = () => {
37
50
  (allowNewValues && isValueNew && !maxSelected.isLimitReached) || // Render add new option
38
51
  filteredOptions.length > 0; // Render filtered options
39
52
 
53
+ const height = themeContext?.isDarkside ? "316px" : "290px";
54
+
40
55
  return (
41
- <div
56
+ <Floating.Content
42
57
  className={cn("navds-combobox__list", {
43
58
  "navds-combobox__list--closed": !isListOpen,
44
59
  "navds-combobox__list--with-hover": isMouseLastUsedInputDevice,
45
60
  })}
46
61
  id={filteredOptionsUtil.getFilteredOptionsId(id)}
47
62
  tabIndex={-1}
63
+ sideOffset={8}
64
+ side="bottom"
65
+ fallbackPlacements={["top"]}
66
+ enabled={isListOpen}
67
+ style={{
68
+ maxHeight: localOpen
69
+ ? `min(${height}, var(--ac-floating-available-height))`
70
+ : `${height}`,
71
+ }}
72
+ autoUpdateWhileMounted={false}
48
73
  >
49
74
  {shouldRenderNonSelectables && (
50
75
  <div
@@ -74,7 +99,7 @@ const FilteredOptions = () => {
74
99
  ))}
75
100
  </ul>
76
101
  )}
77
- </div>
102
+ </Floating.Content>
78
103
  );
79
104
  };
80
105
 
@@ -64,6 +64,7 @@ const useVirtualFocus = (
64
64
 
65
65
  const moveFocusDown = () => {
66
66
  const elementsAbleToReceiveFocus = getElementsAbleToReceiveFocus();
67
+
67
68
  if (!activeElement) {
68
69
  setActiveAndScrollToElement(elementsAbleToReceiveFocus[0]);
69
70
  return;
@@ -8,14 +8,14 @@ interface InputContextValue extends FormFieldType {
8
8
  clearInput: NonNullable<ComboboxProps["onClear"]>;
9
9
  error?: ComboboxProps["error"];
10
10
  focusInput: () => void;
11
- inputRef: React.RefObject<HTMLInputElement>;
11
+ inputRef: React.RefObject<HTMLInputElement | null>;
12
12
  value: string;
13
13
  setValue: (text: string) => void;
14
14
  onChange: (newValue: string) => void;
15
15
  searchTerm: string;
16
16
  setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
17
17
  shouldAutocomplete?: boolean;
18
- toggleOpenButtonRef: React.RefObject<HTMLDivElement>;
18
+ toggleOpenButtonRef: React.MutableRefObject<HTMLDivElement | null>;
19
19
  hideCaret: boolean;
20
20
  setHideCaret: React.Dispatch<React.SetStateAction<boolean>>;
21
21
  }
@@ -1,5 +1,8 @@
1
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
2
+
1
3
  /* eslint-disable jsx-a11y/no-static-element-interactions */
2
4
  import React, { forwardRef } from "react";
5
+ import { Floating } from "../../../overlays/floating/Floating";
3
6
  import { useRenameCSS } from "../../../theme/Theme";
4
7
  import { useMergeRefs } from "../../../util/hooks";
5
8
  import { useFilteredOptionsContext } from "../FilteredOptions/filteredOptionsContext";
@@ -54,42 +57,43 @@ export const InputController = forwardRef<
54
57
  const mergedInputRef = useMergeRefs(inputRef, ref);
55
58
 
56
59
  return (
57
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events
58
- <div
59
- className={cn("navds-combobox__wrapper-inner navds-text-field__input", {
60
- "navds-combobox__wrapper-inner--virtually-unfocused":
61
- activeDecendantId !== undefined,
62
- })}
63
- onClick={() => {
64
- if (inputProps.disabled || readOnly) {
65
- return;
66
- }
60
+ <Floating.Anchor asChild>
61
+ <div
62
+ className={cn("navds-combobox__wrapper-inner navds-text-field__input", {
63
+ "navds-combobox__wrapper-inner--virtually-unfocused":
64
+ activeDecendantId !== undefined,
65
+ })}
66
+ onClick={() => {
67
+ if (inputProps.disabled || readOnly) {
68
+ return;
69
+ }
67
70
 
68
- toggleIsListOpen(true);
69
- focusInput();
70
- }}
71
- >
72
- {!shouldShowSelectedOptions ? (
73
- <Input
74
- id={inputProps.id}
75
- ref={mergedInputRef}
76
- inputClassName={inputClassName}
77
- readOnly={readOnly}
78
- {...rest}
79
- />
80
- ) : (
81
- <SelectedOptions selectedOptions={selectedOptions} size={size}>
71
+ toggleIsListOpen(true);
72
+ focusInput();
73
+ }}
74
+ >
75
+ {!shouldShowSelectedOptions ? (
82
76
  <Input
83
77
  id={inputProps.id}
84
78
  ref={mergedInputRef}
85
79
  inputClassName={inputClassName}
86
- shouldShowSelectedOptions={shouldShowSelectedOptions}
87
80
  readOnly={readOnly}
88
81
  {...rest}
89
82
  />
90
- </SelectedOptions>
91
- )}
92
- {toggleListButton && <ToggleListButton ref={toggleOpenButtonRef} />}
93
- </div>
83
+ ) : (
84
+ <SelectedOptions selectedOptions={selectedOptions} size={size}>
85
+ <Input
86
+ id={inputProps.id}
87
+ ref={mergedInputRef}
88
+ inputClassName={inputClassName}
89
+ shouldShowSelectedOptions={shouldShowSelectedOptions}
90
+ readOnly={readOnly}
91
+ {...rest}
92
+ />
93
+ </SelectedOptions>
94
+ )}
95
+ {toggleListButton && <ToggleListButton ref={toggleOpenButtonRef} />}
96
+ </div>
97
+ </Floating.Anchor>
94
98
  );
95
99
  });
@@ -25,9 +25,11 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
25
25
  <input
26
26
  {...omit(props, ["children", "size", "description", "readOnly"])}
27
27
  {...omit(inputProps, ["aria-invalid", "aria-describedby"])}
28
- aria-describedby={cl(inputProps["aria-describedby"], {
29
- [descriptionId]: props.description,
30
- })}
28
+ aria-describedby={
29
+ cl(inputProps["aria-describedby"], {
30
+ [descriptionId]: props.description,
31
+ }) || undefined
32
+ }
31
33
  className={cn("navds-radio__input")}
32
34
  ref={ref}
33
35
  />
@@ -116,7 +116,7 @@ export function containsReadMore(
116
116
  children: React.ReactNode,
117
117
  checkNested = true,
118
118
  ): boolean {
119
- if (React.isValidElement(children)) {
119
+ if (React.isValidElement<{ children?: any }>(children)) {
120
120
  if (children.type === ReadMore) {
121
121
  return true;
122
122
  }
@@ -16,7 +16,7 @@ export const coordsAreInside = (
16
16
  };
17
17
 
18
18
  export function getCloseHandler(
19
- modalRef: React.RefObject<HTMLDialogElement>,
19
+ modalRef: React.RefObject<HTMLDialogElement | null>,
20
20
  header: ModalProps["header"],
21
21
  onBeforeClose: ModalProps["onBeforeClose"],
22
22
  ) {
@@ -31,7 +31,7 @@ export const BODY_CLASS_LEGACY = "navds-modal__document-body";
31
31
  export const BODY_CLASS = "aksel-modal__document-body";
32
32
 
33
33
  export function useBodyScrollLock(
34
- modalRef: React.RefObject<HTMLDialogElement>,
34
+ modalRef: React.RefObject<HTMLDialogElement | null>,
35
35
  portalNode: HTMLElement | null,
36
36
  isNested: boolean,
37
37
  ) {
@@ -16,7 +16,7 @@ import { Menu, MenuPortalProps } from "../floating-menu/Menu";
16
16
  /* -------------------------------------------------------------------------- */
17
17
  type ActionMenuContextValue = {
18
18
  triggerId: string;
19
- triggerRef: React.RefObject<HTMLButtonElement>;
19
+ triggerRef: React.RefObject<HTMLButtonElement | null>;
20
20
  contentId: string;
21
21
  open: boolean;
22
22
  onOpenChange: (open: boolean) => void;