@omer-x/tailwind-ui-kit 1.0.0-alpha.1 → 1.0.0-alpha.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.
@@ -0,0 +1,12 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ComponentProps, ReactNode } from 'react';
3
+ import { Button } from '@base-ui/react/button';
4
+
5
+ type BaseButtonProps = ComponentProps<typeof Button> & {
6
+ size?: "lg" | "md" | "sm" | "xs";
7
+ pending?: boolean;
8
+ children: ReactNode;
9
+ };
10
+ declare const BaseButton: ({ size, pending, disabled, focusableWhenDisabled, className, children, ...otherProps }: BaseButtonProps) => react_jsx_runtime.JSX.Element;
11
+
12
+ export { BaseButton as default };
@@ -0,0 +1,52 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { faSpinner } from "@fortawesome/free-solid-svg-icons/faSpinner";
3
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4
+ import {} from "react";
5
+ import { cn } from "../../utils/cn.js";
6
+ import PulseButton from "./PulseButton.js";
7
+ const BaseButton = ({
8
+ size = "md",
9
+ pending = false,
10
+ disabled,
11
+ focusableWhenDisabled,
12
+ className,
13
+ children,
14
+ ...otherProps
15
+ }) => /* @__PURE__ */ jsxs(
16
+ PulseButton,
17
+ {
18
+ className: (state) => cn({
19
+ // Size
20
+ "h-12 px-5 text-base leading-7 gap-3": size === "lg",
21
+ "h-10 px-4 text-sm leading-6 gap-3": size === "md",
22
+ "h-9 px-3 text-sm leading-5 gap-2": size === "sm",
23
+ "h-8 px-2.5 text-xs leading-4 gap-2": size === "xs"
24
+ }, [
25
+ // Base
26
+ "relative",
27
+ "flex items-center justify-center",
28
+ "rounded-md",
29
+ "font-medium",
30
+ "select-none",
31
+ "outline-0",
32
+ "transition-colors",
33
+ // Focus
34
+ "focus-visible:outline-2",
35
+ "focus-visible:outline-offset-2",
36
+ // Cursor
37
+ "cursor-pointer",
38
+ "data-disabled:cursor-default"
39
+ ], typeof className === "function" ? className(state) : className),
40
+ disabled,
41
+ focusableWhenDisabled: pending || focusableWhenDisabled,
42
+ ...otherProps,
43
+ children: [
44
+ pending && /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faSpinner, size: "lg", className: "fa-spin-pulse" }),
45
+ children
46
+ ]
47
+ }
48
+ );
49
+ var BaseButton_default = BaseButton;
50
+ export {
51
+ BaseButton_default as default
52
+ };
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Button } from '@base-ui/react/button';
3
+ import { ComponentProps, ReactNode } from 'react';
4
+
5
+ type PulseButtonProps = ComponentProps<typeof Button> & {
6
+ children: ReactNode;
7
+ };
8
+ declare const PulseButton: ({ children, onClick, ...otherProps }: PulseButtonProps) => react_jsx_runtime.JSX.Element;
9
+
10
+ export { PulseButton as default };
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { jsxs } from "react/jsx-runtime";
3
+ import { Button } from "@base-ui/react/button";
4
+ import {} from "react";
5
+ import { useRipples } from "../../hooks/useRipples.js";
6
+ const PulseButton = ({
7
+ children,
8
+ onClick,
9
+ ...otherProps
10
+ }) => {
11
+ const [triggerRippleEffect, ripples] = useRipples();
12
+ const handleClick = (e) => {
13
+ triggerRippleEffect(e);
14
+ onClick?.(e);
15
+ };
16
+ return /* @__PURE__ */ jsxs(Button, { ...otherProps, onClick: handleClick, children: [
17
+ ripples,
18
+ children
19
+ ] });
20
+ };
21
+ var PulseButton_default = PulseButton;
22
+ export {
23
+ PulseButton_default as default
24
+ };
@@ -0,0 +1,4 @@
1
+ export { default as BaseButton } from './BaseButton.js';
2
+ import 'react/jsx-runtime';
3
+ import 'react';
4
+ import '@base-ui/react/button';
@@ -0,0 +1,4 @@
1
+ import { default as default2 } from "./BaseButton.js";
2
+ export {
3
+ default2 as BaseButton
4
+ };
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ComponentProps, ReactNode } from 'react';
3
+
4
+ type ContainerProps = ComponentProps<"div"> & {
5
+ className?: string;
6
+ children: ReactNode;
7
+ };
8
+ declare const Container: ({ className, children, }: ContainerProps) => react_jsx_runtime.JSX.Element;
9
+
10
+ export { Container as default };
@@ -0,0 +1,11 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import {} from "react";
3
+ import { cn } from "../../utils/cn.js";
4
+ const Container = ({
5
+ className,
6
+ children
7
+ }) => /* @__PURE__ */ jsx("div", { className: cn("container mx-auto px-3", className), children });
8
+ var Container_default = Container;
9
+ export {
10
+ Container_default as default
11
+ };
@@ -0,0 +1,3 @@
1
+ export { default as Container } from './Container.js';
2
+ import 'react/jsx-runtime';
3
+ import 'react';
@@ -0,0 +1,4 @@
1
+ import { default as default2 } from "./Container.js";
2
+ export {
3
+ default2 as Container
4
+ };
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ type TdxProps = {
5
+ className?: string;
6
+ children?: ReactNode;
7
+ };
8
+ declare const Tdx: ({ className, children, }: TdxProps) => react_jsx_runtime.JSX.Element;
9
+
10
+ export { Tdx as default };
@@ -0,0 +1,10 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import {} from "react";
3
+ const Tdx = ({
4
+ className,
5
+ children
6
+ }) => /* @__PURE__ */ jsx("td", { className, children: /* @__PURE__ */ jsx("div", { className: "table w-full table-fixed", children: /* @__PURE__ */ jsx("span", { className: "table-cell truncate", children }) }) });
7
+ var Tdx_default = Tdx;
8
+ export {
9
+ Tdx_default as default
10
+ };
@@ -0,0 +1,3 @@
1
+ export { default as Tdx } from './Tdx.js';
2
+ import 'react/jsx-runtime';
3
+ import 'react';
@@ -0,0 +1,4 @@
1
+ import { default as default2 } from "./Tdx.js";
2
+ export {
3
+ default2 as Tdx
4
+ };
@@ -0,0 +1,5 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare function useRipples(): readonly [(e: React.MouseEvent<Element>) => void, react_jsx_runtime.JSX.Element];
4
+
5
+ export { useRipples };
@@ -0,0 +1,35 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import styles from "../styles/ripple.module.css";
4
+ import { cn } from "../utils/cn.js";
5
+ function useRipples() {
6
+ const [ripples, setRipples] = useState([]);
7
+ const handleClick = (e) => {
8
+ const rect = e.currentTarget.getBoundingClientRect();
9
+ const size = Math.max(rect.width, rect.height);
10
+ const x = e.clientX - rect.left - size / 2;
11
+ const y = e.clientY - rect.top - size / 2;
12
+ const newRipple = { x, y, size, id: Date.now() };
13
+ setRipples((prev) => [...prev, newRipple]);
14
+ setTimeout(() => {
15
+ setRipples((prev) => prev.filter((r) => r.id !== newRipple.id));
16
+ }, 600);
17
+ };
18
+ const ripplesNode = /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pointer-events-none overflow-hidden rounded-md", children: ripples.map((ripple) => /* @__PURE__ */ jsx(
19
+ "span",
20
+ {
21
+ className: cn(styles.animation, "absolute rounded-full bg-current opacity-10"),
22
+ style: {
23
+ left: ripple.x,
24
+ top: ripple.y,
25
+ width: ripple.size,
26
+ height: ripple.size
27
+ }
28
+ },
29
+ ripple.id
30
+ )) });
31
+ return [handleClick, ripplesNode];
32
+ }
33
+ export {
34
+ useRipples
35
+ };
@@ -0,0 +1,2 @@
1
+ export { cn } from './cn.js';
2
+ import 'clsx';
@@ -0,0 +1,4 @@
1
+ import { cn } from "./cn.js";
2
+ export {
3
+ cn
4
+ };
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@omer-x/tailwind-ui-kit",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "Tailwind CSS-based React component library for building user interfaces",
5
5
  "keywords": [
6
+ "tailwind",
7
+ "ui-kit",
8
+ "font-awesome",
6
9
  "typescript"
7
10
  ],
8
11
  "repository": {
@@ -24,14 +27,28 @@
24
27
  },
25
28
  "license": "MIT",
26
29
  "type": "module",
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
27
32
  "files": [
28
33
  "dist/"
29
34
  ],
30
35
  "exports": {
36
+ "./layout": {
37
+ "types": "./dist/components/layout/index.d.ts",
38
+ "import": "./dist/components/layout/index.js"
39
+ },
40
+ "./button": {
41
+ "types": "./dist/components/button/index.d.ts",
42
+ "import": "./dist/components/button/index.js"
43
+ },
31
44
  "./dialog": {
32
45
  "types": "./dist/components/dialog/index.d.ts",
33
46
  "import": "./dist/components/dialog/index.js"
34
47
  },
48
+ "./table": {
49
+ "types": "./dist/components/table/index.d.ts",
50
+ "import": "./dist/components/table/index.js"
51
+ },
35
52
  "./utils": {
36
53
  "types": "./dist/utils/index.d.ts",
37
54
  "import": "./dist/utils/index.js"
@@ -1,18 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { IconProp } from '@fortawesome/fontawesome-svg-core';
3
- import { ComponentProps } from 'react';
4
-
5
- type ButtonProps = Omit<ComponentProps<"button">, "children" | "onClick"> & {
6
- color?: "primary" | "secondary" | "success" | "warning" | "danger";
7
- stretched?: boolean;
8
- onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
9
- } & ({
10
- icon: IconProp;
11
- text?: string;
12
- } | {
13
- icon?: IconProp;
14
- text: string;
15
- });
16
- declare const Button: ({ color, icon, text, stretched, onClick, className, ...otherProps }: ButtonProps) => react_jsx_runtime.JSX.Element;
17
-
18
- export { Button as default };
@@ -1,37 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
3
- import { cn } from "../utils/cn.js";
4
- import PulseButton from "./PulseButton.js";
5
- const Button = ({
6
- color = "primary",
7
- icon,
8
- text,
9
- stretched = false,
10
- onClick,
11
- className,
12
- ...otherProps
13
- }) => /* @__PURE__ */ jsxs(
14
- PulseButton,
15
- {
16
- className: cn("relative overflow-hidden inline-flex justify-center items-center transition rounded-lg min-h-9 px-3 py-2 text-sm font-medium text-white focus-visible:outline-2 focus-visible:outline-offset-2 cursor-pointer", {
17
- "bg-blue-500 hover:bg-blue-600 focus-visible:outline-blue-500": color === "primary",
18
- "text-slate-900 bg-slate-400 hover:bg-slate-500 focus-visible:outline-slate-400": color === "secondary",
19
- "bg-green-600 hover:bg-green-700 focus-visible:outline-green-600": color === "success",
20
- "text-slate-900 bg-yellow-500 hover:bg-yellow-600 focus-visible:outline-yellow-500": color === "warning",
21
- "bg-red-600 hover:bg-red-700 focus-visible:outline-red-600": color === "danger",
22
- "gap-2": !stretched,
23
- "gap-3": stretched
24
- }, className),
25
- onClick,
26
- ...otherProps,
27
- children: [
28
- icon && /* @__PURE__ */ jsx(FontAwesomeIcon, { icon, size: "lg" }),
29
- !icon && !text ? /* @__PURE__ */ jsx(Fragment, { children: "\xA0" }) : /* @__PURE__ */ jsx(Fragment, { children: text }),
30
- stretched && icon && /* @__PURE__ */ jsx("div", { className: "w-[var(--fa-width,1.25em)]" })
31
- ]
32
- }
33
- );
34
- var Button_default = Button;
35
- export {
36
- Button_default as default
37
- };
@@ -1,15 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ComponentProps, ReactNode } from 'react';
3
- import { IconProp } from '@fortawesome/fontawesome-svg-core';
4
-
5
- type ButtonProps<LinkProps> = Omit<ComponentProps<"a">, "children" | "href" | "onClick"> & {
6
- color?: "primary" | "secondary" | "success" | "warning" | "danger";
7
- icon?: IconProp;
8
- text?: string;
9
- stretched?: boolean;
10
- as: (props: LinkProps) => ReactNode;
11
- href: string;
12
- };
13
- declare const Button: <LinkProps extends ComponentProps<"a">>({ color, icon, text, stretched, as: Link, href, className, ...otherProps }: ButtonProps<LinkProps>) => react_jsx_runtime.JSX.Element;
14
-
15
- export { Button as default };
@@ -1,43 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
3
- import {} from "react";
4
- import { cn } from "../utils/cn.js";
5
- import PulseButton from "./PulseButton.js";
6
- const Button = ({
7
- color,
8
- icon,
9
- text,
10
- stretched = false,
11
- as: Link,
12
- href,
13
- className,
14
- ...otherProps
15
- }) => (
16
- // @ts-expect-error: shut up typescript!
17
- /* @__PURE__ */ jsxs(
18
- PulseButton,
19
- {
20
- as: Link,
21
- href,
22
- className: cn("relative overflow-hidden inline-flex justify-center items-center transition rounded-lg px-3 py-2 text-sm font-medium text-white focus-visible:outline-2 focus-visible:outline-offset-2 cursor-pointer", {
23
- "bg-blue-500 hover:bg-blue-600 focus-visible:outline-blue-500": color === "primary",
24
- "bg-slate-400 hover:bg-slate-500 focus-visible:outline-slate-400": color === "secondary",
25
- "bg-green-600 hover:bg-green-700 focus-visible:outline-green-600": color === "success",
26
- "bg-yellow-500 hover:bg-yellow-600 focus-visible:outline-yellow-500": color === "warning",
27
- "bg-red-500 hover:bg-red-600 focus-visible:outline-red-500": color === "danger",
28
- "gap-2": !stretched,
29
- "gap-3": stretched
30
- }, className),
31
- ...otherProps,
32
- children: [
33
- icon && /* @__PURE__ */ jsx(FontAwesomeIcon, { icon, size: "lg" }),
34
- !icon && !text ? /* @__PURE__ */ jsx(Fragment, { children: "\xA0" }) : /* @__PURE__ */ jsx(Fragment, { children: text }),
35
- stretched && icon && /* @__PURE__ */ jsx("div", { className: "w-[var(--fa-width,1.25em)]" })
36
- ]
37
- }
38
- )
39
- );
40
- var LinkButton_default = Button;
41
- export {
42
- LinkButton_default as default
43
- };
@@ -1,11 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ElementType, ReactNode, ComponentPropsWithoutRef } from 'react';
3
-
4
- type PulseButtonProps<As extends ElementType> = {
5
- as?: As;
6
- onClick?: (e: React.MouseEvent<Element>) => void;
7
- children: ReactNode;
8
- } & Omit<ComponentPropsWithoutRef<As>, "as" | "onClick" | "children">;
9
- declare const PulseButton: <As extends ElementType = "button">({ as, onClick, children, className, ...otherProps }: PulseButtonProps<As>) => react_jsx_runtime.JSX.Element;
10
-
11
- export { PulseButton as default };
@@ -1,55 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useState } from "react";
4
- import styles from "../styles/ripple.module.css";
5
- import { cn } from "../utils/cn.js";
6
- const PulseButton = ({
7
- as,
8
- onClick,
9
- children,
10
- className,
11
- ...otherProps
12
- }) => {
13
- const Component = as ?? "button";
14
- const [ripples, setRipples] = useState([]);
15
- const handleClick = (e) => {
16
- onClick?.(e);
17
- const rect = e.currentTarget.getBoundingClientRect();
18
- const size = Math.max(rect.width, rect.height);
19
- const x = e.clientX - rect.left - size / 2;
20
- const y = e.clientY - rect.top - size / 2;
21
- const newRipple = { x, y, size, id: Date.now() };
22
- setRipples((prev) => [...prev, newRipple]);
23
- setTimeout(() => {
24
- setRipples((prev) => prev.filter((r) => r.id !== newRipple.id));
25
- }, 600);
26
- };
27
- return /* @__PURE__ */ jsxs(
28
- Component,
29
- {
30
- onClick: handleClick,
31
- className: cn("relative overflow-hidden", className),
32
- ...otherProps,
33
- children: [
34
- children,
35
- ripples.map((ripple) => /* @__PURE__ */ jsx(
36
- "span",
37
- {
38
- className: cn(styles.animation, "absolute rounded-full bg-white opacity-40"),
39
- style: {
40
- left: ripple.x,
41
- top: ripple.y,
42
- width: ripple.size,
43
- height: ripple.size
44
- }
45
- },
46
- ripple.id
47
- ))
48
- ]
49
- }
50
- );
51
- };
52
- var PulseButton_default = PulseButton;
53
- export {
54
- PulseButton_default as default
55
- };