@digdir/designsystemet-react 0.59.0 → 0.59.1-alpha.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 (91) hide show
  1. package/dist/cjs/components/DropdownMenu/DropdownMenuContent.js +4 -4
  2. package/dist/cjs/components/DropdownMenu/DropdownMenuTrigger.js +1 -1
  3. package/dist/cjs/components/Modal/ModalDialog.js +1 -1
  4. package/dist/cjs/components/Popover/PopoverContent.js +6 -6
  5. package/dist/cjs/components/Popover/PopoverTrigger.js +1 -1
  6. package/dist/cjs/components/Tooltip/Tooltip.js +6 -6
  7. package/dist/cjs/components/form/Checkbox/Checkbox.js +1 -1
  8. package/dist/cjs/components/form/Combobox/Combobox.js +60 -177
  9. package/dist/cjs/components/form/Combobox/ComboboxContext.js +8 -0
  10. package/dist/cjs/components/form/Combobox/ComboboxIdContext.js +42 -0
  11. package/dist/cjs/components/form/Combobox/Custom/Custom.js +14 -9
  12. package/dist/cjs/components/form/Combobox/Empty/Empty.js +4 -4
  13. package/dist/cjs/components/form/Combobox/Option/Option.js +15 -33
  14. package/dist/cjs/components/form/Combobox/Option/useComboboxOption.js +47 -0
  15. package/dist/cjs/components/form/Combobox/internal/ComboboxChips.js +14 -6
  16. package/dist/cjs/components/form/Combobox/internal/ComboboxClearButton.js +4 -4
  17. package/dist/cjs/components/form/Combobox/internal/ComboboxInput.js +40 -35
  18. package/dist/cjs/components/form/Combobox/internal/ComboboxNative.js +2 -2
  19. package/dist/cjs/components/form/Combobox/useCombobox.js +46 -32
  20. package/dist/cjs/components/form/Combobox/useComboboxKeyboard.js +79 -0
  21. package/dist/cjs/components/form/Combobox/useFloatingCombobox.js +78 -0
  22. package/dist/cjs/components/form/Search/Search.js +1 -1
  23. package/dist/cjs/node_modules/@floating-ui/utils/{dom/dist → dist}/floating-ui.utils.dom.js +7 -4
  24. package/dist/cjs/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +5 -0
  25. package/dist/cjs/{node_modules → packages/react/node_modules}/@floating-ui/core/dist/floating-ui.core.js +40 -16
  26. package/dist/cjs/{node_modules → packages/react/node_modules}/@floating-ui/dom/dist/floating-ui.dom.js +83 -31
  27. package/dist/cjs/{node_modules → packages/react/node_modules}/@floating-ui/react/dist/floating-ui.react.js +307 -157
  28. package/dist/cjs/{node_modules/@floating-ui/react/utils → packages/react/node_modules/@floating-ui/react}/dist/floating-ui.react.utils.js +9 -4
  29. package/dist/cjs/{node_modules → packages/react/node_modules}/@floating-ui/react-dom/dist/floating-ui.react-dom.js +22 -18
  30. package/dist/{esm → cjs/packages/react}/node_modules/tabbable/dist/index.esm.js +59 -13
  31. package/dist/cjs/utilities/RovingTabIndex/RovingTabindexItem.js +1 -1
  32. package/dist/cjs/utilities/RovingTabIndex/RovingTabindexRoot.js +1 -1
  33. package/dist/esm/components/DropdownMenu/DropdownMenuContent.js +3 -3
  34. package/dist/esm/components/DropdownMenu/DropdownMenuTrigger.js +1 -1
  35. package/dist/esm/components/Modal/ModalDialog.js +1 -1
  36. package/dist/esm/components/Popover/PopoverContent.js +4 -4
  37. package/dist/esm/components/Popover/PopoverTrigger.js +1 -1
  38. package/dist/esm/components/Tooltip/Tooltip.js +4 -4
  39. package/dist/esm/components/form/Checkbox/Checkbox.js +1 -1
  40. package/dist/esm/components/form/Combobox/Combobox.js +65 -182
  41. package/dist/esm/components/form/Combobox/ComboboxContext.js +6 -0
  42. package/dist/esm/components/form/Combobox/ComboboxIdContext.js +35 -0
  43. package/dist/esm/components/form/Combobox/Custom/Custom.js +13 -8
  44. package/dist/esm/components/form/Combobox/Empty/Empty.js +3 -3
  45. package/dist/esm/components/form/Combobox/Option/Option.js +15 -33
  46. package/dist/esm/components/form/Combobox/Option/useComboboxOption.js +45 -0
  47. package/dist/esm/components/form/Combobox/internal/ComboboxChips.js +13 -5
  48. package/dist/esm/components/form/Combobox/internal/ComboboxClearButton.js +3 -3
  49. package/dist/esm/components/form/Combobox/internal/ComboboxInput.js +39 -34
  50. package/dist/esm/components/form/Combobox/internal/ComboboxNative.js +2 -2
  51. package/dist/esm/components/form/Combobox/useCombobox.js +46 -32
  52. package/dist/esm/components/form/Combobox/useComboboxKeyboard.js +77 -0
  53. package/dist/esm/components/form/Combobox/useFloatingCombobox.js +76 -0
  54. package/dist/esm/components/form/Search/Search.js +1 -1
  55. package/dist/esm/node_modules/@floating-ui/utils/{dom/dist → dist}/floating-ui.utils.dom.js +7 -4
  56. package/dist/esm/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +5 -0
  57. package/dist/esm/{node_modules → packages/react/node_modules}/@floating-ui/core/dist/floating-ui.core.js +40 -16
  58. package/dist/esm/{node_modules → packages/react/node_modules}/@floating-ui/dom/dist/floating-ui.dom.js +82 -30
  59. package/dist/esm/{node_modules → packages/react/node_modules}/@floating-ui/react/dist/floating-ui.react.js +282 -135
  60. package/dist/esm/{node_modules/@floating-ui/react/utils → packages/react/node_modules/@floating-ui/react}/dist/floating-ui.react.utils.js +9 -5
  61. package/dist/esm/{node_modules → packages/react/node_modules}/@floating-ui/react-dom/dist/floating-ui.react-dom.js +19 -14
  62. package/dist/{cjs → esm/packages/react}/node_modules/tabbable/dist/index.esm.js +55 -15
  63. package/dist/esm/utilities/RovingTabIndex/RovingTabindexItem.js +1 -1
  64. package/dist/esm/utilities/RovingTabIndex/RovingTabindexRoot.js +1 -1
  65. package/dist/types/components/form/Combobox/Combobox.d.ts +104 -39
  66. package/dist/types/components/form/Combobox/Combobox.d.ts.map +1 -1
  67. package/dist/types/components/form/Combobox/ComboboxContext.d.ts +48 -0
  68. package/dist/types/components/form/Combobox/ComboboxContext.d.ts.map +1 -0
  69. package/dist/types/components/form/Combobox/ComboboxIdContext.d.ts +19 -0
  70. package/dist/types/components/form/Combobox/ComboboxIdContext.d.ts.map +1 -0
  71. package/dist/types/components/form/Combobox/Custom/Custom.d.ts.map +1 -1
  72. package/dist/types/components/form/Combobox/Option/Option.d.ts +2 -2
  73. package/dist/types/components/form/Combobox/Option/Option.d.ts.map +1 -1
  74. package/dist/types/components/form/Combobox/Option/useComboboxOption.d.ts +14 -0
  75. package/dist/types/components/form/Combobox/Option/useComboboxOption.d.ts.map +1 -0
  76. package/dist/types/components/form/Combobox/internal/ComboboxChips.d.ts.map +1 -1
  77. package/dist/types/components/form/Combobox/internal/ComboboxInput.d.ts +0 -1
  78. package/dist/types/components/form/Combobox/internal/ComboboxInput.d.ts.map +1 -1
  79. package/dist/types/components/form/Combobox/internal/ComboboxNative.d.ts +3 -1
  80. package/dist/types/components/form/Combobox/internal/ComboboxNative.d.ts.map +1 -1
  81. package/dist/types/components/form/Combobox/useCombobox.d.ts +13 -5
  82. package/dist/types/components/form/Combobox/useCombobox.d.ts.map +1 -1
  83. package/dist/types/components/form/Combobox/useComboboxKeyboard.d.ts +20 -0
  84. package/dist/types/components/form/Combobox/useComboboxKeyboard.d.ts.map +1 -0
  85. package/dist/types/components/form/Combobox/useFloatingCombobox.d.ts +41 -0
  86. package/dist/types/components/form/Combobox/useFloatingCombobox.d.ts.map +1 -0
  87. package/package.json +3 -3
  88. package/dist/cjs/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -6
  89. package/dist/cjs/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dom/dist/floating-ui.utils.dom.js +0 -68
  90. package/dist/esm/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -4
  91. package/dist/esm/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dom/dist/floating-ui.utils.dom.js +0 -57
@@ -6,7 +6,7 @@ export type UseComboboxProps = {
6
6
  children: ReactNode;
7
7
  inputValue: string;
8
8
  multiple: boolean;
9
- filter: NonNullable<ComboboxProps['filter']>;
9
+ filter?: NonNullable<ComboboxProps['filter']>;
10
10
  initialValue?: string[];
11
11
  };
12
12
  export type Option = {
@@ -19,14 +19,22 @@ export declare function isComboboxOption(child: ReactNode): child is ReactElemen
19
19
  export declare function isComboboxCustom(child: ReactNode): child is ReactElement<ComboboxCustomProps>;
20
20
  export declare function isInteractiveComboboxCustom(child: ReactNode): child is ReactElement<ComboboxCustomProps>;
21
21
  export default function useCombobox({ children, inputValue, multiple, filter, initialValue, }: UseComboboxProps): {
22
- optionsChildren: ReactElement<ComboboxOptionProps, string | import("react").JSXElementConstructor<any>>[];
22
+ filteredOptionsChildren: (ReactElement<ComboboxOptionProps, string | import("react").JSXElementConstructor<any>> | undefined)[];
23
+ filteredOptions: string[];
23
24
  optionValues: string[];
24
25
  restChildren: (string | number | ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | import("react").ReactPortal)[];
25
- options: Option[];
26
+ options: {
27
+ [key: string]: Option;
28
+ };
26
29
  customIds: string[];
27
- selectedOptions: Option[];
28
- setSelectedOptions: import("react").Dispatch<import("react").SetStateAction<Option[]>>;
30
+ selectedOptions: {
31
+ [key: string]: Option;
32
+ };
29
33
  prevSelectedHash: string;
34
+ interactiveChildren: ReactElement<ComboboxCustomProps, string | import("react").JSXElementConstructor<any>>[];
35
+ setSelectedOptions: import("react").Dispatch<import("react").SetStateAction<{
36
+ [key: string]: Option;
37
+ }>>;
30
38
  setPrevSelectedHash: import("react").Dispatch<import("react").SetStateAction<string>>;
31
39
  };
32
40
  //# sourceMappingURL=useCombobox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCombobox.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/Combobox/useCombobox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,GACf,KAAK,IAAI,YAAY,CAAC,mBAAmB,CAAC,CAE5C;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,GACf,KAAK,IAAI,YAAY,CAAC,mBAAmB,CAAC,CAE5C;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,SAAS,GACf,KAAK,IAAI,YAAY,CAAC,mBAAmB,CAAC,CAE5C;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,MAAM,EACN,YAAY,GACb,EAAE,gBAAgB;;;;;;;;;;EAmHlB"}
1
+ {"version":3,"file":"useCombobox.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/Combobox/useCombobox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,GACf,KAAK,IAAI,YAAY,CAAC,mBAAmB,CAAC,CAE5C;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,GACf,KAAK,IAAI,YAAY,CAAC,mBAAmB,CAAC,CAE5C;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,SAAS,GACf,KAAK,IAAI,YAAY,CAAC,mBAAmB,CAAC,CAE5C;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,MAEC,EACD,YAAY,GACb,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;EA0IlB"}
@@ -0,0 +1,20 @@
1
+ import type useCombobox from './useCombobox';
2
+ import type { Option } from './useCombobox';
3
+ type UseComboboxKeyboardProps = {
4
+ filteredOptions: ReturnType<typeof useCombobox>['filteredOptions'];
5
+ selectedOptions: ReturnType<typeof useCombobox>['selectedOptions'];
6
+ interactiveChildren: ReturnType<typeof useCombobox>['interactiveChildren'];
7
+ options: ReturnType<typeof useCombobox>['options'];
8
+ readOnly: boolean;
9
+ disabled: boolean;
10
+ inputValue: string;
11
+ multiple: boolean;
12
+ open: boolean;
13
+ setOpen: (value: boolean) => void;
14
+ setSelectedOptions: ReturnType<typeof useCombobox>['setSelectedOptions'];
15
+ setInputValue: (value: string) => void;
16
+ handleSelectOption: (option: Option) => void;
17
+ };
18
+ export declare const useComboboxKeyboard: ({ readOnly, disabled, interactiveChildren, filteredOptions, inputValue, selectedOptions, multiple, open, options, setOpen, setInputValue, setSelectedOptions, handleSelectOption, }: UseComboboxKeyboardProps) => (...args: import("react").KeyboardEvent<Element>[]) => void;
19
+ export {};
20
+ //# sourceMappingURL=useComboboxKeyboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComboboxKeyboard.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/Combobox/useComboboxKeyboard.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG5C,KAAK,wBAAwB,GAAG;IAC9B,eAAe,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACnE,eAAe,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACnE,mBAAmB,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,qBAAqB,CAAC,CAAC;IAC3E,OAAO,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC;IACnD,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,kBAAkB,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,oBAAoB,CAAC,CAAC;IACzE,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF,eAAO,MAAM,mBAAmB,wLAc7B,wBAAwB,gEAkF1B,CAAC"}
@@ -0,0 +1,41 @@
1
+ type UseFloatingComboboxProps = {
2
+ listRef: React.MutableRefObject<(HTMLElement | null)[]>;
3
+ };
4
+ export declare const useFloatingCombobox: ({ listRef }: UseFloatingComboboxProps) => {
5
+ open: boolean;
6
+ setOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
7
+ activeIndex: number;
8
+ refs: {
9
+ reference: import("react").MutableRefObject<import("@floating-ui/react-dom").ReferenceType | null>;
10
+ floating: import("react").MutableRefObject<HTMLElement | null>;
11
+ setReference: (node: import("@floating-ui/react-dom").ReferenceType | null) => void;
12
+ setFloating: (node: HTMLElement | null) => void;
13
+ } & import("@floating-ui/react").ExtendedRefs<HTMLInputElement>;
14
+ floatingStyles: import("react").CSSProperties;
15
+ context: {
16
+ x: number;
17
+ y: number;
18
+ placement: import("@floating-ui/utils").Placement;
19
+ strategy: import("@floating-ui/utils").Strategy;
20
+ middlewareData: import("@floating-ui/core").MiddlewareData;
21
+ isPositioned: boolean;
22
+ update: () => void;
23
+ floatingStyles: import("react").CSSProperties;
24
+ open: boolean;
25
+ onOpenChange: (open: boolean, event?: Event | undefined, reason?: import("@floating-ui/react").OpenChangeReason | undefined) => void;
26
+ events: import("@floating-ui/react").FloatingEvents;
27
+ dataRef: import("react").MutableRefObject<import("@floating-ui/react").ContextData>;
28
+ nodeId: string | undefined;
29
+ floatingId: string;
30
+ refs: import("@floating-ui/react").ExtendedRefs<HTMLInputElement>;
31
+ elements: import("@floating-ui/react").ExtendedElements<HTMLInputElement>;
32
+ };
33
+ getReferenceProps: (userProps?: import("react").HTMLProps<Element> | undefined) => Record<string, unknown>;
34
+ getFloatingProps: (userProps?: import("react").HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
35
+ getItemProps: (userProps?: (Omit<import("react").HTMLProps<HTMLElement>, "selected" | "active"> & {
36
+ active?: boolean | undefined;
37
+ selected?: boolean | undefined;
38
+ }) | undefined) => Record<string, unknown>;
39
+ };
40
+ export {};
41
+ //# sourceMappingURL=useFloatingCombobox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFloatingCombobox.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/Combobox/useFloatingCombobox.tsx"],"names":[],"mappings":"AAgBA,KAAK,wBAAwB,GAAG;IAC9B,OAAO,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;CACzD,CAAC;AAEF,eAAO,MAAM,mBAAmB,gBAAiB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuExE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digdir/designsystemet-react",
3
- "version": "0.59.0",
3
+ "version": "0.59.1-alpha.0",
4
4
  "description": "React components for Designsystemet",
5
5
  "author": "Designsystemet team",
6
6
  "repository": "https://github.com/digdir/designsystemet",
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@floating-ui/react": "0.26.4",
32
+ "@floating-ui/react": "0.26.12",
33
33
  "@navikt/aksel-icons": "^5.12.2",
34
34
  "@radix-ui/react-slot": "^1.0.2",
35
35
  "@tanstack/react-virtual": "^3.2.0"
@@ -43,5 +43,5 @@
43
43
  "rollup": "^4.12.1",
44
44
  "typescript": "^5.4.2"
45
45
  },
46
- "gitHead": "aeed6074c31e5e21c7ca9e83a883fe87cd1111d5"
46
+ "gitHead": "0006fe3820b071bb4b1e948263072af46cf2c604"
47
47
  }
@@ -1,6 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- const floor = Math.floor;
5
-
6
- exports.floor = floor;
@@ -1,68 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- function getNodeName(node) {
5
- if (isNode(node)) {
6
- return (node.nodeName || '').toLowerCase();
7
- }
8
- // Mocked nodes in testing environments may not be instances of Node. By
9
- // returning `#document` an infinite loop won't occur.
10
- // https://github.com/floating-ui/floating-ui/issues/2317
11
- return '#document';
12
- }
13
- function getWindow(node) {
14
- var _node$ownerDocument;
15
- return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
16
- }
17
- function getDocumentElement(node) {
18
- var _ref;
19
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
20
- }
21
- function isNode(value) {
22
- return value instanceof Node || value instanceof getWindow(value).Node;
23
- }
24
- function isElement(value) {
25
- return value instanceof Element || value instanceof getWindow(value).Element;
26
- }
27
- function isHTMLElement(value) {
28
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
29
- }
30
- function isShadowRoot(value) {
31
- // Browsers without `ShadowRoot` support.
32
- if (typeof ShadowRoot === 'undefined') {
33
- return false;
34
- }
35
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
36
- }
37
- function isLastTraversableNode(node) {
38
- return ['html', 'body', '#document'].includes(getNodeName(node));
39
- }
40
- function getComputedStyle(element) {
41
- return getWindow(element).getComputedStyle(element);
42
- }
43
- function getParentNode(node) {
44
- if (getNodeName(node) === 'html') {
45
- return node;
46
- }
47
- const result =
48
- // Step into the shadow DOM of the parent of a slotted node.
49
- node.assignedSlot ||
50
- // DOM Element detected.
51
- node.parentNode ||
52
- // ShadowRoot detected.
53
- isShadowRoot(node) && node.host ||
54
- // Fallback.
55
- getDocumentElement(node);
56
- return isShadowRoot(result) ? result.host : result;
57
- }
58
-
59
- exports.getComputedStyle = getComputedStyle;
60
- exports.getDocumentElement = getDocumentElement;
61
- exports.getNodeName = getNodeName;
62
- exports.getParentNode = getParentNode;
63
- exports.getWindow = getWindow;
64
- exports.isElement = isElement;
65
- exports.isHTMLElement = isHTMLElement;
66
- exports.isLastTraversableNode = isLastTraversableNode;
67
- exports.isNode = isNode;
68
- exports.isShadowRoot = isShadowRoot;
@@ -1,4 +0,0 @@
1
- 'use client';
2
- const floor = Math.floor;
3
-
4
- export { floor };
@@ -1,57 +0,0 @@
1
- 'use client';
2
- function getNodeName(node) {
3
- if (isNode(node)) {
4
- return (node.nodeName || '').toLowerCase();
5
- }
6
- // Mocked nodes in testing environments may not be instances of Node. By
7
- // returning `#document` an infinite loop won't occur.
8
- // https://github.com/floating-ui/floating-ui/issues/2317
9
- return '#document';
10
- }
11
- function getWindow(node) {
12
- var _node$ownerDocument;
13
- return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
14
- }
15
- function getDocumentElement(node) {
16
- var _ref;
17
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
18
- }
19
- function isNode(value) {
20
- return value instanceof Node || value instanceof getWindow(value).Node;
21
- }
22
- function isElement(value) {
23
- return value instanceof Element || value instanceof getWindow(value).Element;
24
- }
25
- function isHTMLElement(value) {
26
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
27
- }
28
- function isShadowRoot(value) {
29
- // Browsers without `ShadowRoot` support.
30
- if (typeof ShadowRoot === 'undefined') {
31
- return false;
32
- }
33
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
34
- }
35
- function isLastTraversableNode(node) {
36
- return ['html', 'body', '#document'].includes(getNodeName(node));
37
- }
38
- function getComputedStyle(element) {
39
- return getWindow(element).getComputedStyle(element);
40
- }
41
- function getParentNode(node) {
42
- if (getNodeName(node) === 'html') {
43
- return node;
44
- }
45
- const result =
46
- // Step into the shadow DOM of the parent of a slotted node.
47
- node.assignedSlot ||
48
- // DOM Element detected.
49
- node.parentNode ||
50
- // ShadowRoot detected.
51
- isShadowRoot(node) && node.host ||
52
- // Fallback.
53
- getDocumentElement(node);
54
- return isShadowRoot(result) ? result.host : result;
55
- }
56
-
57
- export { getComputedStyle, getDocumentElement, getNodeName, getParentNode, getWindow, isElement, isHTMLElement, isLastTraversableNode, isNode, isShadowRoot };