@mbao01/common 0.0.3 → 0.0.5

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 (31) hide show
  1. package/dist/types/components/Card/Card.d.ts +9 -7
  2. package/dist/types/components/Description/Description.d.ts +7 -0
  3. package/dist/types/components/Description/index.d.ts +1 -0
  4. package/dist/types/components/Description/types.d.ts +3 -0
  5. package/dist/types/components/Skeleton/Skeleton.d.ts +2 -0
  6. package/dist/types/components/Skeleton/constants.d.ts +5 -0
  7. package/dist/types/components/Skeleton/index.d.ts +1 -0
  8. package/dist/types/components/Skeleton/types.d.ts +7 -0
  9. package/dist/types/components/Tooltip/Tooltip.d.ts +1 -1
  10. package/dist/types/components/Tooltip/index.d.ts +1 -1
  11. package/dist/types/components/Tooltip/types.d.ts +2 -2
  12. package/dist/types/index.d.ts +7 -2
  13. package/package.json +3 -3
  14. package/src/components/Card/Card.tsx +7 -8
  15. package/src/components/Description/Description.tsx +29 -0
  16. package/src/components/Description/index.ts +1 -0
  17. package/src/components/Description/types.ts +5 -0
  18. package/src/components/Skeleton/Skeleton.tsx +26 -0
  19. package/src/components/Skeleton/constants.ts +38 -0
  20. package/src/components/Skeleton/index.ts +1 -0
  21. package/src/components/Skeleton/types.ts +8 -0
  22. package/src/components/Tooltip/Tooltip.tsx +13 -2
  23. package/src/components/Tooltip/index.ts +1 -1
  24. package/src/components/Tooltip/types.ts +2 -2
  25. package/src/index.ts +10 -2
  26. package/dist/types/components/Detail/Detail.d.ts +0 -2
  27. package/dist/types/components/Detail/index.d.ts +0 -1
  28. package/dist/types/components/Detail/types.d.ts +0 -5
  29. package/src/components/Detail/Detail.tsx +0 -10
  30. package/src/components/Detail/index.ts +0 -1
  31. package/src/components/Detail/types.ts +0 -6
@@ -1,8 +1,10 @@
1
1
  import { CardContentProps, CardDescriptionProps, CardFooterProps, CardHeaderProps, CardImageProps, CardProps } from "./types";
2
- declare const Card: ({ compact, bordered, horizontal, overlay, className, ...props }: CardProps) => import("react/jsx-runtime").JSX.Element;
3
- declare const CardHeader: ({ className, ...props }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
4
- declare const CardDescription: ({ className, ...props }: CardDescriptionProps) => import("react/jsx-runtime").JSX.Element;
5
- declare const CardContent: ({ className, ...props }: CardContentProps) => import("react/jsx-runtime").JSX.Element;
6
- declare const CardImage: ({ className, src, alt, ...props }: CardImageProps) => import("react/jsx-runtime").JSX.Element;
7
- declare const CardFooter: ({ className, ...props }: CardFooterProps) => import("react/jsx-runtime").JSX.Element;
8
- export { Card, CardHeader, CardFooter, CardDescription, CardContent, CardImage, };
2
+ declare const Card: {
3
+ ({ compact, bordered, horizontal, overlay, className, ...props }: CardProps): import("react/jsx-runtime").JSX.Element;
4
+ Header: ({ className, ...props }: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
5
+ Content: ({ className, ...props }: CardContentProps) => import("react/jsx-runtime").JSX.Element;
6
+ Description: ({ className, ...props }: CardDescriptionProps) => import("react/jsx-runtime").JSX.Element;
7
+ Image: ({ className, src, alt, ...props }: CardImageProps) => import("react/jsx-runtime").JSX.Element;
8
+ Footer: ({ className, ...props }: CardFooterProps) => import("react/jsx-runtime").JSX.Element;
9
+ };
10
+ export { Card };
@@ -0,0 +1,7 @@
1
+ import type { DescriptionProps, DescriptionTermProps, DescriptionDetailProps } from "./types";
2
+ declare const Description: {
3
+ (props: DescriptionProps): import("react/jsx-runtime").JSX.Element;
4
+ Term: (props: DescriptionTermProps) => import("react/jsx-runtime").JSX.Element;
5
+ Detail: (props: DescriptionDetailProps) => import("react/jsx-runtime").JSX.Element;
6
+ };
7
+ export { Description };
@@ -0,0 +1 @@
1
+ export { Description } from "./Description";
@@ -0,0 +1,3 @@
1
+ export type DescriptionProps = React.HTMLAttributes<HTMLDListElement>;
2
+ export type DescriptionTermProps = React.HTMLAttributes<HTMLElement>;
3
+ export type DescriptionDetailProps = React.HTMLAttributes<HTMLElement>;
@@ -0,0 +1,2 @@
1
+ import { type SkeletonProps } from "./types";
2
+ export declare const Skeleton: ({ className, round, width, height, ...props }: SkeletonProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { Size } from "./types";
2
+ export declare const getSkeletonSize: ({ width, height, }: {
3
+ width?: Size | undefined;
4
+ height?: Size | undefined;
5
+ }) => string;
@@ -0,0 +1 @@
1
+ export { Skeleton } from "./Skeleton";
@@ -0,0 +1,7 @@
1
+ export type Size = 2 | 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | "full";
2
+ export type SkeletonProps = React.HTMLAttributes<HTMLDivElement> & {
3
+ width?: Size;
4
+ height?: Size;
5
+ round?: boolean;
6
+ className?: string;
7
+ };
@@ -1,2 +1,2 @@
1
1
  import { type TooltipProps } from './types';
2
- export declare const Tooltip: ({ tip, children, variant, position, className }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Tooltip: ({ content, children, variant, position, className, ...props }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- export { Tooltip } from './Tooltip';
1
+ export { Tooltip } from "./Tooltip";
@@ -1,8 +1,8 @@
1
1
  import { type ReactNode } from 'react';
2
2
  export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
3
3
  export type TooltipVariant = 'default' | 'neutral' | 'primary' | 'secondary' | 'accent' | 'ghost' | 'link' | 'info' | 'success' | 'warning' | 'error';
4
- export type TooltipProps = {
5
- tip: string;
4
+ export type TooltipProps = React.HTMLAttributes<HTMLDivElement> & {
5
+ content: string;
6
6
  children: ReactNode;
7
7
  variant?: TooltipVariant;
8
8
  position?: TooltipPosition;
@@ -1,6 +1,11 @@
1
- export * from "./components/Badge";
1
+ /** actions */
2
2
  export * from "./components/Button";
3
+ /** data display */
4
+ export * from "./components/Badge";
3
5
  export * from "./components/Card";
4
- export * from "./components/Detail";
6
+ export * from "./components/Description";
5
7
  export * from "./components/Text";
8
+ /** data input */
9
+ /** feedback */
10
+ export * from "./components/Skeleton";
6
11
  export * from "./components/Tooltip";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "vitest.config.ts"
39
39
  ],
40
40
  "bugs": "https://github.com/mbao01/mbao01/issues",
41
- "homepage": "https://shared.ayomidebakare.site",
41
+ "homepage": "https://ui.ayomidebakare.site/common/",
42
42
  "repository": {
43
43
  "type": "git",
44
44
  "url": "git+https://github.com/mbao01/mbao01.git"
@@ -107,5 +107,5 @@
107
107
  "react-dom": "^18.2.0",
108
108
  "typescript": "^5.2.2"
109
109
  },
110
- "gitHead": "fb1542aac0eb979dd16d8d4448e4380726e4e330"
110
+ "gitHead": "d40fb1867ee09180de85ab18ffe74c4436e43413"
111
111
  }
@@ -54,11 +54,10 @@ const CardFooter = ({ className, ...props }: CardFooterProps) => (
54
54
  <div className={c("card-actions", className)} {...props} />
55
55
  );
56
56
 
57
- export {
58
- Card,
59
- CardHeader,
60
- CardFooter,
61
- CardDescription,
62
- CardContent,
63
- CardImage,
64
- };
57
+ Card.Header = CardHeader;
58
+ Card.Content = CardContent;
59
+ Card.Description = CardDescription;
60
+ Card.Image = CardImage;
61
+ Card.Footer = CardFooter;
62
+
63
+ export { Card };
@@ -0,0 +1,29 @@
1
+ import c from "clsx";
2
+ import type {
3
+ DescriptionProps,
4
+ DescriptionTermProps,
5
+ DescriptionDetailProps,
6
+ } from "./types";
7
+
8
+ const Description = (props: DescriptionProps) => {
9
+ return <dl role="list" {...props} />;
10
+ };
11
+
12
+ const DescriptionTerm = (props: DescriptionTermProps) => {
13
+ return (
14
+ <dt
15
+ {...props}
16
+ role="listitem"
17
+ className={c("mb-1 py-2 text-sm font-medium", props.className)}
18
+ />
19
+ );
20
+ };
21
+
22
+ const DescriptionDetail = (props: DescriptionDetailProps) => {
23
+ return <dd {...props} className={c("text-base", props.className)} />;
24
+ };
25
+
26
+ Description.Term = DescriptionTerm;
27
+ Description.Detail = DescriptionDetail;
28
+
29
+ export { Description };
@@ -0,0 +1 @@
1
+ export { Description } from "./Description";
@@ -0,0 +1,5 @@
1
+ export type DescriptionProps = React.HTMLAttributes<HTMLDListElement>;
2
+
3
+ export type DescriptionTermProps = React.HTMLAttributes<HTMLElement>;
4
+
5
+ export type DescriptionDetailProps = React.HTMLAttributes<HTMLElement>;
@@ -0,0 +1,26 @@
1
+ import c from "clsx";
2
+ import { type SkeletonProps } from "./types";
3
+ import { getSkeletonSize } from "./constants";
4
+
5
+ export const Skeleton = ({
6
+ className,
7
+ round,
8
+ width,
9
+ height,
10
+ ...props
11
+ }: SkeletonProps) => {
12
+ return (
13
+ <div
14
+ {...props}
15
+ className={c(
16
+ "skeleton",
17
+ getSkeletonSize({ width, height }),
18
+ {
19
+ "rounded-md": !round,
20
+ "rounded-full": round,
21
+ },
22
+ className
23
+ )}
24
+ />
25
+ );
26
+ };
@@ -0,0 +1,38 @@
1
+ import c from "clsx";
2
+ import { Size } from "./types";
3
+
4
+ const WIDTH_SIZES = {
5
+ 2: c("w-2"),
6
+ 4: c("w-4"),
7
+ 8: c("w-8"),
8
+ 12: c("w-12"),
9
+ 16: c("w-16"),
10
+ 24: c("w-24"),
11
+ 32: c("w-32"),
12
+ 48: c("w-48"),
13
+ 64: c("w-64"),
14
+ full: c("w-full"),
15
+ } satisfies Record<Size, string>;
16
+
17
+ const HEIGHT_SIZES = {
18
+ 2: c("h-2"),
19
+ 4: c("h-4"),
20
+ 8: c("h-8"),
21
+ 12: c("h-12"),
22
+ 16: c("h-16"),
23
+ 24: c("h-24"),
24
+ 32: c("h-32"),
25
+ 48: c("h-48"),
26
+ 64: c("h-64"),
27
+ full: c("h-full"),
28
+ } satisfies Record<Size, string>;
29
+
30
+ export const getSkeletonSize = ({
31
+ width,
32
+ height,
33
+ }: {
34
+ width?: Size;
35
+ height?: Size;
36
+ }) => {
37
+ return c(WIDTH_SIZES[width!] ?? "w-full", HEIGHT_SIZES[height!] ?? "h-4");
38
+ };
@@ -0,0 +1 @@
1
+ export { Skeleton } from "./Skeleton";
@@ -0,0 +1,8 @@
1
+ export type Size = 2 | 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | "full";
2
+
3
+ export type SkeletonProps = React.HTMLAttributes<HTMLDivElement> & {
4
+ width?: Size;
5
+ height?: Size;
6
+ round?: boolean;
7
+ className?: string;
8
+ };
@@ -2,9 +2,20 @@ import c from 'clsx';
2
2
  import { getTooltipClasses } from './constants';
3
3
  import { type TooltipProps } from './types';
4
4
 
5
- export const Tooltip = ({ tip, children, variant, position, className }: TooltipProps) => {
5
+ export const Tooltip = ({
6
+ content,
7
+ children,
8
+ variant,
9
+ position,
10
+ className,
11
+ ...props
12
+ }: TooltipProps) => {
6
13
  return (
7
- <div className={c(getTooltipClasses({ variant, position }), className)} data-tip={tip}>
14
+ <div
15
+ {...props}
16
+ className={c(getTooltipClasses({ variant, position }), className)}
17
+ data-tip={content}
18
+ >
8
19
  {children}
9
20
  </div>
10
21
  );
@@ -1 +1 @@
1
- export { Tooltip } from './Tooltip';
1
+ export { Tooltip } from "./Tooltip";
@@ -15,8 +15,8 @@ export type TooltipVariant =
15
15
  | 'warning'
16
16
  | 'error';
17
17
 
18
- export type TooltipProps = {
19
- tip: string;
18
+ export type TooltipProps = React.HTMLAttributes<HTMLDivElement> & {
19
+ content: string;
20
20
  children: ReactNode;
21
21
  variant?: TooltipVariant;
22
22
  position?: TooltipPosition;
package/src/index.ts CHANGED
@@ -1,6 +1,14 @@
1
- export * from "./components/Badge";
1
+ /** actions */
2
2
  export * from "./components/Button";
3
+
4
+ /** data display */
5
+ export * from "./components/Badge";
3
6
  export * from "./components/Card";
4
- export * from "./components/Detail";
7
+ export * from "./components/Description";
5
8
  export * from "./components/Text";
9
+
10
+ /** data input */
11
+
12
+ /** feedback */
13
+ export * from "./components/Skeleton";
6
14
  export * from "./components/Tooltip";
@@ -1,2 +0,0 @@
1
- import { type DetailProps } from './types';
2
- export declare const Detail: ({ term, children }: DetailProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export { Detail } from './Detail';
@@ -1,5 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- export type DetailProps = {
3
- term: string;
4
- children: ReactNode;
5
- };
@@ -1,10 +0,0 @@
1
- import { type DetailProps } from './types';
2
-
3
- export const Detail = ({ term, children }: DetailProps) => {
4
- return (
5
- <dl>
6
- <dt className="mb-1 py-2 text-sm font-medium">{term}</dt>
7
- <dd className="text-base">{children}</dd>
8
- </dl>
9
- );
10
- };
@@ -1 +0,0 @@
1
- export { Detail } from './Detail';
@@ -1,6 +0,0 @@
1
- import { type ReactNode } from 'react';
2
-
3
- export type DetailProps = {
4
- term: string;
5
- children: ReactNode;
6
- };