@vygruppen/spor-react 2.3.3 → 2.4.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.
@@ -1,5 +1,5 @@
1
1
  import { Box } from "@chakra-ui/react";
2
- import React, { useRef } from "react";
2
+ import React, { forwardRef, useRef } from "react";
3
3
  import {
4
4
  AriaPopoverProps,
5
5
  DismissButton,
@@ -33,38 +33,45 @@ type PopoverProps = {
33
33
  *
34
34
  * Used to render accessible popover content, like a dropdown menu or a card select. Should not be used directly, but as a part of Spor components.
35
35
  */
36
- export const Popover = ({
37
- children,
38
- state,
39
- triggerRef,
40
- offset = 0,
41
- crossOffset = 0,
42
- placement = "bottom",
43
- }: PopoverProps) => {
44
- const popoverRef = useRef<HTMLDivElement>(null);
45
- const { popoverProps, underlayProps } = usePopover(
36
+ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
37
+ (
46
38
  {
39
+ children,
40
+ state,
47
41
  triggerRef,
48
- popoverRef,
49
- offset,
50
- crossOffset,
51
- placement,
42
+ offset = 0,
43
+ crossOffset = 0,
44
+ placement = "bottom",
52
45
  },
53
- state
54
- );
46
+ ref
47
+ ) => {
48
+ const internalRef = useRef<HTMLDivElement>(null);
49
+ const popoverRef = ref ?? (internalRef as any);
55
50
 
56
- return (
57
- <Overlay>
58
- <Box {...underlayProps} position="fixed" inset="0" />
59
- <Box
60
- {...popoverProps}
61
- ref={popoverRef}
62
- minWidth={triggerRef.current?.clientWidth ?? "auto"}
63
- >
64
- <DismissButton onDismiss={state.close} />
65
- {children}
66
- <DismissButton onDismiss={state.close} />
67
- </Box>
68
- </Overlay>
69
- );
70
- };
51
+ const { popoverProps, underlayProps } = usePopover(
52
+ {
53
+ triggerRef,
54
+ popoverRef,
55
+ offset,
56
+ crossOffset,
57
+ placement,
58
+ },
59
+ state
60
+ );
61
+
62
+ return (
63
+ <Overlay>
64
+ <Box {...underlayProps} position="fixed" inset="0" />
65
+ <Box
66
+ {...popoverProps}
67
+ ref={popoverRef}
68
+ minWidth={triggerRef.current?.clientWidth ?? "auto"}
69
+ >
70
+ <DismissButton onDismiss={state.close} />
71
+ {children}
72
+ <DismissButton onDismiss={state.close} />
73
+ </Box>
74
+ </Overlay>
75
+ );
76
+ }
77
+ );
@@ -1,11 +1,12 @@
1
1
  export { FormHelperText, InputGroup } from "@chakra-ui/react";
2
2
  export type { InputGroupProps } from "@chakra-ui/react";
3
3
  export * from "./AttachedInputs";
4
+ export * from "./Autosuggest";
4
5
  export * from "./CardSelect";
5
6
  export * from "./Checkbox";
6
7
  export * from "./CheckboxGroup";
7
8
  export * from "./ChoiceChip";
8
- export * from "./NumericStepper";
9
+ export * from "./Combobox";
9
10
  export * from "./FormControl";
10
11
  export * from "./FormErrorMessage";
11
12
  export * from "./FormLabel";
@@ -14,6 +15,7 @@ export * from "./Input";
14
15
  export * from "./InputElement";
15
16
  export * from "./ListBox";
16
17
  export * from "./NativeSelect";
18
+ export * from "./NumericStepper";
17
19
  export * from "./PasswordInput";
18
20
  export * from "./PhoneNumberInput";
19
21
  export * from "./Radio";
@@ -1,6 +1,6 @@
1
- import { Box, BoxProps, Center } from "@chakra-ui/react";
2
1
  import { spinnerDarkData } from "@vygruppen/spor-loader";
3
2
  import React from "react";
3
+ import { Box, BoxProps, Center } from "..";
4
4
  import { ClientOnly } from "./ClientOnly";
5
5
  import Lottie from "./Lottie";
6
6
 
@@ -34,7 +34,7 @@ export const DarkSpinner = ({
34
34
  </ClientOnly>
35
35
  </Box>
36
36
  {children && (
37
- <Box mt={3} fontWeight="bold">
37
+ <Box marginTop={3} fontWeight="bold">
38
38
  {children}
39
39
  </Box>
40
40
  )}
@@ -31,19 +31,19 @@ const config = helpers.defineMultiStyleConfig({
31
31
  },
32
32
  _focus: {
33
33
  outline: "none",
34
- background: mode("mint", "darkTeal")(props),
34
+ backgroundColor: mode("mint", "darkTeal")(props),
35
35
  },
36
36
  _selected: {
37
- background: mode("pine", "pine")(props),
37
+ backgroundColor: mode("pine", "pine")(props),
38
38
  color: mode("white", "white")(props),
39
39
  },
40
40
  },
41
41
  label: {},
42
42
  description: {
43
43
  fontSize: ["mobile.xs", "desktop.xs"],
44
- color: "dimGrey",
44
+ color: mode("dimGrey", "silver")(props),
45
45
  "[aria-selected='true'] &": {
46
- color: "lightGrey",
46
+ color: mode("lightGrey", "platinum")(props),
47
47
  },
48
48
  },
49
49
  }),