@mbao01/common 0.0.23 → 0.0.24

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.
@@ -6,6 +6,6 @@ declare const Button: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes
6
6
  size?: "xs" | "sm" | "md" | "lg" | undefined;
7
7
  isLoading?: boolean | undefined;
8
8
  } & {
9
- as?: "a" | "span" | "p" | undefined;
9
+ asChild?: boolean | undefined;
10
10
  } & React.RefAttributes<HTMLButtonElement>>;
11
11
  export { Button };
@@ -2,5 +2,5 @@ import { type VariantProps } from "../../libs";
2
2
  import { type ButtonHTMLAttributes } from "react";
3
3
  import { getButtonClasses } from "./constants";
4
4
  export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof getButtonClasses> & {
5
- as?: keyof Pick<JSX.IntrinsicElements, "a" | "span" | "p">;
5
+ asChild?: boolean;
6
6
  };
@@ -12,7 +12,7 @@ declare const Carousel: {
12
12
  size?: "xs" | "sm" | "md" | "lg" | undefined;
13
13
  isLoading?: boolean | undefined;
14
14
  } & {
15
- as?: "a" | "span" | "p" | undefined;
15
+ asChild?: boolean | undefined;
16
16
  } & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
17
17
  Previous: import("react").ForwardRefExoticComponent<Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
18
18
  variant?: "accent" | "default" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | undefined;
@@ -21,7 +21,7 @@ declare const Carousel: {
21
21
  size?: "xs" | "sm" | "md" | "lg" | undefined;
22
22
  isLoading?: boolean | undefined;
23
23
  } & {
24
- as?: "a" | "span" | "p" | undefined;
24
+ asChild?: boolean | undefined;
25
25
  } & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
26
26
  };
27
27
  export { Carousel };
@@ -8,7 +8,7 @@ declare const Command: {
8
8
  ref?: React.Ref<HTMLInputElement> | undefined;
9
9
  } & {
10
10
  asChild?: boolean | undefined;
11
- }, "key" | "asChild" | keyof React.InputHTMLAttributes<HTMLInputElement>>, "onChange" | "type" | "value"> & {
11
+ }, "asChild" | "key" | keyof React.InputHTMLAttributes<HTMLInputElement>>, "onChange" | "type" | "value"> & {
12
12
  value?: string | undefined;
13
13
  onValueChange?: ((search: string) => void) | undefined;
14
14
  } & React.RefAttributes<HTMLInputElement>, "ref"> & {} & React.RefAttributes<HTMLInputElement>>;
@@ -18,7 +18,7 @@ declare const Command: {
18
18
  ref?: React.Ref<HTMLDivElement> | undefined;
19
19
  } & {
20
20
  asChild?: boolean | undefined;
21
- }, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild"> & {
21
+ }, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
22
22
  label?: string | undefined;
23
23
  } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
24
24
  Empty: React.ForwardRefExoticComponent<Omit<{
@@ -27,14 +27,14 @@ declare const Command: {
27
27
  ref?: React.Ref<HTMLDivElement> | undefined;
28
28
  } & {
29
29
  asChild?: boolean | undefined;
30
- }, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
30
+ }, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
31
31
  Group: React.ForwardRefExoticComponent<Omit<{
32
32
  children?: React.ReactNode;
33
33
  } & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
34
34
  ref?: React.Ref<HTMLDivElement> | undefined;
35
35
  } & {
36
36
  asChild?: boolean | undefined;
37
- }, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild">, "heading" | "value"> & {
37
+ }, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>>, "heading" | "value"> & {
38
38
  heading?: React.ReactNode;
39
39
  value?: string | undefined;
40
40
  forceMount?: boolean | undefined;
@@ -45,7 +45,7 @@ declare const Command: {
45
45
  ref?: React.Ref<HTMLDivElement> | undefined;
46
46
  } & {
47
47
  asChild?: boolean | undefined;
48
- }, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild">, "onSelect" | "disabled" | "value"> & {
48
+ }, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>>, "onSelect" | "disabled" | "value"> & {
49
49
  disabled?: boolean | undefined;
50
50
  onSelect?: ((value: string) => void) | undefined;
51
51
  value?: string | undefined;
@@ -60,7 +60,7 @@ declare const Command: {
60
60
  ref?: React.Ref<HTMLDivElement> | undefined;
61
61
  } & {
62
62
  asChild?: boolean | undefined;
63
- }, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild"> & {
63
+ }, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
64
64
  alwaysRender?: boolean | undefined;
65
65
  } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
66
66
  };
@@ -1 +1 @@
1
- export { Slot } from "@radix-ui/react-slot";
1
+ export { Slot, Slottable } from "@radix-ui/react-slot";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.23",
4
+ "version": "0.0.24",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -142,5 +142,5 @@
142
142
  "react-dom": "^18.2.0",
143
143
  "typescript": "^5.2.2"
144
144
  },
145
- "gitHead": "ba76159ca3d5d96cbdcbc04b7dbd545f071027b6"
145
+ "gitHead": "b95f089ac1b19964127f550809c9943b2766749f"
146
146
  }
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Slot } from "@radix-ui/react-slot";
2
+ import { Slot, Slottable } from "@radix-ui/react-slot";
3
3
  import { type ButtonProps } from "./types";
4
4
  import { getButtonClasses } from "./constants";
5
5
  import { Loading } from "../Loading";
@@ -8,7 +8,7 @@ import { cn } from "../../utilities";
8
8
  const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
9
9
  (
10
10
  {
11
- as,
11
+ asChild,
12
12
  className,
13
13
  outline,
14
14
  children,
@@ -20,8 +20,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
20
20
  },
21
21
  ref
22
22
  ) => {
23
- const Comp = as ? Slot : "button";
24
- const SlotChild = as ? as : React.Fragment;
23
+ const Comp = asChild ? Slot : "button";
25
24
 
26
25
  return (
27
26
  <Comp
@@ -32,18 +31,15 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
32
31
  )}
33
32
  {...props}
34
33
  >
35
- {/* slot merges it's prop into it's immediate child */}
36
- <SlotChild>
37
- {children}
38
- {isLoading ? (
39
- <span
40
- className="absolute left-0 top-0 flex h-full w-full items-center justify-center bg-[inherit]"
41
- data-testid="loading"
42
- >
43
- <Loading />
44
- </span>
45
- ) : null}
46
- </SlotChild>
34
+ <Slottable>{children}</Slottable>
35
+ {isLoading ? (
36
+ <span
37
+ className="absolute left-0 top-0 flex h-full w-full items-center justify-center bg-[inherit]"
38
+ data-testid="loading"
39
+ >
40
+ <Loading />
41
+ </span>
42
+ ) : null}
47
43
  </Comp>
48
44
  );
49
45
  }
@@ -4,5 +4,5 @@ import { getButtonClasses } from "./constants";
4
4
 
5
5
  export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &
6
6
  VariantProps<typeof getButtonClasses> & {
7
- as?: keyof Pick<JSX.IntrinsicElements, "a" | "span" | "p">;
7
+ asChild?: boolean;
8
8
  };
@@ -1 +1 @@
1
- export { Slot } from "@radix-ui/react-slot";
1
+ export { Slot, Slottable } from "@radix-ui/react-slot";