@vygruppen/spor-react 12.8.1 → 12.8.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vygruppen/spor-react",
3
3
  "type": "module",
4
- "version": "12.8.1",
4
+ "version": "12.8.3",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
package/src/index.tsx CHANGED
@@ -26,6 +26,7 @@ export * from "./table";
26
26
  export * from "./theme";
27
27
  export * from "./theme/brand";
28
28
  export * from "./toast";
29
+ export * from "./tooltip";
29
30
  export * from "./transition";
30
31
  export * from "./typography";
31
32
  export * from "./util";
@@ -4,7 +4,7 @@ import React from "react";
4
4
  export type CheckboxGroupProps = React.ComponentProps<
5
5
  typeof ChakraCheckboxGroup
6
6
  > & {
7
- direction: "row" | "column"; // Defaults to row
7
+ direction?: "row" | "column";
8
8
  };
9
9
  /**
10
10
  * Used to group several checkboxes together. You can pass the default value, as well as whether or not they're all disabled
@@ -30,7 +30,7 @@ export type FieldBaseProps = {
30
30
 
31
31
  export type FieldProps = Omit<
32
32
  ChakraField.RootProps,
33
- "label" | "onChange" | "onBlur" | "onFocus" | "onClick" | "children"
33
+ "label" | "onChange" | "onBlur"
34
34
  > &
35
35
  React.PropsWithChildren<FieldVariantProps> &
36
36
  FieldBaseProps;
@@ -31,7 +31,7 @@ export const fieldSlotRecipe = defineSlotRecipe({
31
31
  textStyle: "xs",
32
32
  width: "fit-content",
33
33
  position: "absolute",
34
- top: "100%", // position below parent
34
+ top: "100%",
35
35
  left: 3,
36
36
  zIndex: "dropdown",
37
37
  maxWidth: "50ch",
@@ -66,4 +66,5 @@ export const slotRecipes = {
66
66
  toast: toastSlotRecipe,
67
67
  checkboxCard: choiceChipSlotRecipe,
68
68
  collapsible: collapsibleSlotRecipe,
69
+ tooltip: popoverSlotRecipe,
69
70
  };
@@ -10,6 +10,8 @@ export const popoverSlotRecipe = defineSlotRecipe({
10
10
  position: "relative",
11
11
  display: "flex",
12
12
  flexDirection: "row-reverse",
13
+ color: "text.inverted",
14
+
13
15
  gap: "0.625rem",
14
16
  padding: "0.563rem 0.75rem",
15
17
 
@@ -0,0 +1,38 @@
1
+ "use client";
2
+
3
+ import { Portal, Tooltip as ChakraTooltip } from "@chakra-ui/react";
4
+ import { forwardRef } from "react";
5
+
6
+ export const Tooltip = ChakraTooltip.Root;
7
+
8
+ export const TooltipTrigger = forwardRef<
9
+ HTMLButtonElement,
10
+ ChakraTooltip.TriggerProps
11
+ >(({ children, ...props }, ref) => {
12
+ const isStringChild = typeof children === "string";
13
+
14
+ return (
15
+ <ChakraTooltip.Trigger {...props} ref={ref} asChild={!isStringChild}>
16
+ {children}
17
+ </ChakraTooltip.Trigger>
18
+ );
19
+ });
20
+ TooltipTrigger.displayName = "TooltipTrigger";
21
+
22
+ export type TooltipProps = ChakraTooltip.ContentProps;
23
+
24
+ export const TooltipContent = forwardRef<HTMLDivElement, TooltipProps>(
25
+ ({ children, ...props }, ref) => {
26
+ return (
27
+ <Portal>
28
+ <ChakraTooltip.Positioner>
29
+ <ChakraTooltip.Content ref={ref} {...props}>
30
+ <ChakraTooltip.Arrow />
31
+ <ChakraTooltip.Content {...props}>{children}</ChakraTooltip.Content>
32
+ </ChakraTooltip.Content>
33
+ </ChakraTooltip.Positioner>
34
+ </Portal>
35
+ );
36
+ },
37
+ );
38
+ TooltipContent.displayName = "TooltipContent";