@omer-x/tailwind-ui-kit 1.0.0-alpha.1 → 1.0.0-alpha.11
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/dist/components/button/BaseButton.d.ts +12 -0
- package/dist/components/button/BaseButton.js +52 -0
- package/dist/components/button/PulseButton.d.ts +8 -0
- package/dist/components/button/PulseButton.js +41 -0
- package/dist/components/button/index.d.ts +4 -0
- package/dist/components/button/index.js +4 -0
- package/dist/components/elements/JustAnchor.d.ts +6 -0
- package/dist/components/elements/JustAnchor.js +15 -0
- package/dist/components/elements/JustButton.d.ts +6 -0
- package/dist/components/elements/JustButton.js +15 -0
- package/dist/components/elements/JustDiv.d.ts +6 -0
- package/dist/components/elements/JustDiv.js +15 -0
- package/dist/components/elements/JustInput.d.ts +6 -0
- package/dist/components/elements/JustInput.js +15 -0
- package/dist/components/form/BaseForm.d.ts +13 -0
- package/dist/components/form/BaseForm.js +53 -0
- package/dist/components/form/BaseFormField.d.ts +20 -0
- package/dist/components/form/BaseFormField.js +25 -0
- package/dist/components/form/BaseInput.d.ts +10 -0
- package/dist/components/form/BaseInput.js +32 -0
- package/dist/components/form/FieldRoot.d.ts +11 -0
- package/dist/components/form/FieldRoot.js +23 -0
- package/dist/components/form/FormContext.d.ts +11 -0
- package/dist/components/form/FormContext.js +10 -0
- package/dist/components/form/ServerSideError.d.ts +12 -0
- package/dist/components/form/ServerSideError.js +19 -0
- package/dist/components/form/index.d.ts +10 -0
- package/dist/components/form/index.js +8 -0
- package/dist/components/layout/Container.d.ts +10 -0
- package/dist/components/layout/Container.js +11 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/index.js +4 -0
- package/dist/components/page/Pagination.d.ts +17 -0
- package/dist/components/page/Pagination.js +51 -0
- package/dist/components/page/index.d.ts +5 -0
- package/dist/components/page/index.js +4 -0
- package/dist/components/table/Tdx.d.ts +10 -0
- package/dist/components/table/Tdx.js +10 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +4 -0
- package/dist/hooks/useRipples.d.ts +5 -0
- package/dist/hooks/useRipples.js +36 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +4 -0
- package/package.json +39 -11
- package/dist/components/Button.d.ts +0 -18
- package/dist/components/Button.js +0 -37
- package/dist/components/LinkButton.d.ts +0 -15
- package/dist/components/LinkButton.js +0 -43
- package/dist/components/PulseButton.d.ts +0 -11
- package/dist/components/PulseButton.js +0 -55
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import PulseButton from './PulseButton.js';
|
|
4
|
+
import '@base-ui/react/button';
|
|
5
|
+
|
|
6
|
+
type BaseButtonProps = ComponentProps<typeof PulseButton> & {
|
|
7
|
+
size?: "lg" | "md" | "sm" | "xs";
|
|
8
|
+
pending?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const BaseButton: ({ size, pending, disabled, focusableWhenDisabled, className, children, ...otherProps }: BaseButtonProps) => react.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
|
+
...otherProps,
|
|
19
|
+
className: cn({
|
|
20
|
+
// Size
|
|
21
|
+
"h-12 px-5 text-base leading-7 gap-3": size === "lg",
|
|
22
|
+
"h-10 px-4 text-sm leading-6 gap-3": size === "md",
|
|
23
|
+
"h-9 px-3 text-sm leading-5 gap-2": size === "sm",
|
|
24
|
+
"h-8 px-2.5 text-xs leading-4 gap-2": size === "xs"
|
|
25
|
+
}, [
|
|
26
|
+
// Base
|
|
27
|
+
"relative",
|
|
28
|
+
"flex items-center justify-center",
|
|
29
|
+
"rounded-md",
|
|
30
|
+
"font-medium",
|
|
31
|
+
"select-none",
|
|
32
|
+
"outline-0",
|
|
33
|
+
"transition-colors",
|
|
34
|
+
// Focus
|
|
35
|
+
"focus-visible:outline-2",
|
|
36
|
+
"focus-visible:outline-offset-2",
|
|
37
|
+
// Cursor
|
|
38
|
+
"cursor-pointer",
|
|
39
|
+
"data-disabled:cursor-default"
|
|
40
|
+
], className),
|
|
41
|
+
disabled,
|
|
42
|
+
focusableWhenDisabled: pending || focusableWhenDisabled,
|
|
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,8 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import { Button } from '@base-ui/react/button';
|
|
4
|
+
|
|
5
|
+
type PulseButtonProps = ComponentProps<typeof Button> & {};
|
|
6
|
+
declare const PulseButton: ({ type, disabled, onClick, children, ...otherProps }: PulseButtonProps) => react.JSX.Element;
|
|
7
|
+
|
|
8
|
+
export { PulseButton as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from "@base-ui/react/button";
|
|
4
|
+
import {} from "react";
|
|
5
|
+
import { useFormStatus } from "react-dom";
|
|
6
|
+
import { useRipples } from "../../hooks/useRipples.js";
|
|
7
|
+
const PulseButton = ({
|
|
8
|
+
type,
|
|
9
|
+
disabled,
|
|
10
|
+
onClick,
|
|
11
|
+
children,
|
|
12
|
+
...otherProps
|
|
13
|
+
}) => {
|
|
14
|
+
const { pending } = useFormStatus();
|
|
15
|
+
const [triggerRippleEffect, ripples] = useRipples();
|
|
16
|
+
const submitting = type === "submit" && pending;
|
|
17
|
+
const handleClick = (e) => {
|
|
18
|
+
onClick?.(e);
|
|
19
|
+
if (!e.defaultPrevented) {
|
|
20
|
+
triggerRippleEffect(e);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return /* @__PURE__ */ jsxs(
|
|
24
|
+
Button,
|
|
25
|
+
{
|
|
26
|
+
...otherProps,
|
|
27
|
+
type,
|
|
28
|
+
disabled: submitting || disabled,
|
|
29
|
+
onClick: handleClick,
|
|
30
|
+
"data-submitting": submitting ? "" : void 0,
|
|
31
|
+
children: [
|
|
32
|
+
ripples,
|
|
33
|
+
children
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
var PulseButton_default = PulseButton;
|
|
39
|
+
export {
|
|
40
|
+
PulseButton_default as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
|
|
4
|
+
declare const JustAnchor: ({ render, ...props }: useRender.ComponentProps<"a">) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
|
|
6
|
+
export { JustAnchor as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
const JustAnchor = ({
|
|
3
|
+
render,
|
|
4
|
+
...props
|
|
5
|
+
}) => {
|
|
6
|
+
return useRender({
|
|
7
|
+
defaultTagName: "a",
|
|
8
|
+
render,
|
|
9
|
+
props
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var JustAnchor_default = JustAnchor;
|
|
13
|
+
export {
|
|
14
|
+
JustAnchor_default as default
|
|
15
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
|
|
4
|
+
declare const JustButton: ({ render, ...props }: useRender.ComponentProps<"button">) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
|
|
6
|
+
export { JustButton as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
const JustButton = ({
|
|
3
|
+
render,
|
|
4
|
+
...props
|
|
5
|
+
}) => {
|
|
6
|
+
return useRender({
|
|
7
|
+
defaultTagName: "button",
|
|
8
|
+
render,
|
|
9
|
+
props
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var JustButton_default = JustButton;
|
|
13
|
+
export {
|
|
14
|
+
JustButton_default as default
|
|
15
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
|
|
4
|
+
declare const JustDiv: ({ render, ...props }: useRender.ComponentProps<"div">) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
|
|
6
|
+
export { JustDiv as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
const JustDiv = ({
|
|
3
|
+
render,
|
|
4
|
+
...props
|
|
5
|
+
}) => {
|
|
6
|
+
return useRender({
|
|
7
|
+
defaultTagName: "div",
|
|
8
|
+
render,
|
|
9
|
+
props
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var JustDiv_default = JustDiv;
|
|
13
|
+
export {
|
|
14
|
+
JustDiv_default as default
|
|
15
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
|
|
4
|
+
declare const JustInput: ({ render, ...props }: useRender.ComponentProps<"input">) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
|
|
6
|
+
export { JustInput as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
const JustInput = ({
|
|
3
|
+
render,
|
|
4
|
+
...props
|
|
5
|
+
}) => {
|
|
6
|
+
return useRender({
|
|
7
|
+
defaultTagName: "input",
|
|
8
|
+
render,
|
|
9
|
+
props
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var JustInput_default = JustInput;
|
|
13
|
+
export {
|
|
14
|
+
JustInput_default as default
|
|
15
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import JustDiv from '../elements/JustDiv.js';
|
|
4
|
+
import '@base-ui/react/use-render';
|
|
5
|
+
|
|
6
|
+
type BaseFormProps = Omit<ComponentProps<"form">, "action"> & {
|
|
7
|
+
action: (initialState: unknown, formData: FormData) => Promise<Record<string, string>>;
|
|
8
|
+
messages?: Partial<Record<string, string>>;
|
|
9
|
+
renderMessages?: ComponentProps<typeof JustDiv>["render"];
|
|
10
|
+
};
|
|
11
|
+
declare const BaseForm: ({ action, messages: messageTranslations, renderMessages, className, children, }: BaseFormProps) => react.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { BaseForm as default };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Form } from "@base-ui/react/form";
|
|
4
|
+
import { useActionState, useRef } from "react";
|
|
5
|
+
import JustDiv from "../elements/JustDiv.js";
|
|
6
|
+
import { FormContext } from "./FormContext.js";
|
|
7
|
+
const BaseForm = ({
|
|
8
|
+
action,
|
|
9
|
+
messages: messageTranslations = {},
|
|
10
|
+
renderMessages,
|
|
11
|
+
className,
|
|
12
|
+
children
|
|
13
|
+
}) => {
|
|
14
|
+
const [state, formAction, _loading] = useActionState(action, {});
|
|
15
|
+
const fieldsRef = useRef(/* @__PURE__ */ new Set());
|
|
16
|
+
const getFieldMessage = (fieldName) => {
|
|
17
|
+
if (fieldName in state) {
|
|
18
|
+
return state[fieldName];
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
const registerField = (fieldName) => {
|
|
23
|
+
fieldsRef.current.add(fieldName);
|
|
24
|
+
};
|
|
25
|
+
const unregisterField = (fieldName) => {
|
|
26
|
+
fieldsRef.current.delete(fieldName);
|
|
27
|
+
};
|
|
28
|
+
const { formMessages, fieldMessages } = Object.keys(state).reduce((bundle, key) => {
|
|
29
|
+
if (fieldsRef.current.has(key)) {
|
|
30
|
+
return { ...bundle, fieldMessages: { ...bundle.fieldMessages, [key]: state[key] } };
|
|
31
|
+
}
|
|
32
|
+
return { ...bundle, formMessages: { ...bundle.formMessages, [key]: state[key] } };
|
|
33
|
+
}, {
|
|
34
|
+
formMessages: {},
|
|
35
|
+
fieldMessages: {}
|
|
36
|
+
});
|
|
37
|
+
return /* @__PURE__ */ jsxs(Form, { action: formAction, className, errors: fieldMessages, children: [
|
|
38
|
+
Object.entries(formMessages).map(([messageKey, message]) => /* @__PURE__ */ jsx(
|
|
39
|
+
JustDiv,
|
|
40
|
+
{
|
|
41
|
+
"data-message-type": messageKey.startsWith("[") ? messageKey.replace(/^\[|\]$/g, "") : "default",
|
|
42
|
+
render: renderMessages,
|
|
43
|
+
children: messageTranslations[message] || message
|
|
44
|
+
},
|
|
45
|
+
messageKey
|
|
46
|
+
)),
|
|
47
|
+
/* @__PURE__ */ jsx(FormContext, { value: { getFieldMessage, messageTranslations, registerField, unregisterField }, children })
|
|
48
|
+
] });
|
|
49
|
+
};
|
|
50
|
+
var BaseForm_default = BaseForm;
|
|
51
|
+
export {
|
|
52
|
+
BaseForm_default as default
|
|
53
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import { Field } from '@base-ui/react/field';
|
|
4
|
+
import JustInput from '../elements/JustInput.js';
|
|
5
|
+
import { ZodType } from 'zod';
|
|
6
|
+
import '@base-ui/react/use-render';
|
|
7
|
+
|
|
8
|
+
type BaseFormFieldProps = {
|
|
9
|
+
schema: ZodType;
|
|
10
|
+
name: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
messages?: Partial<Record<string, string>>;
|
|
13
|
+
control?: ComponentProps<typeof JustInput>["render"];
|
|
14
|
+
renderLabel?: ComponentProps<typeof Field.Label>["render"];
|
|
15
|
+
renderErrors?: ComponentProps<typeof Field.Error>["render"];
|
|
16
|
+
clientSideErrors?: Partial<Record<keyof ValidityState, string | ((payload: string | number | null) => string)>>;
|
|
17
|
+
};
|
|
18
|
+
declare const BaseFormField: ({ schema, name, label, messages, control, renderLabel, renderErrors, clientSideErrors, }: BaseFormFieldProps) => react.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { BaseFormField as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Field } from "@base-ui/react/field";
|
|
3
|
+
import { getErrorMessagePayload, getFieldConstraints } from "@omer-x/zod-to-form-constraints";
|
|
4
|
+
import JustInput from "../elements/JustInput.js";
|
|
5
|
+
import FieldRoot from "./FieldRoot.js";
|
|
6
|
+
import ServerSideError from "./ServerSideError.js";
|
|
7
|
+
const BaseFormField = ({
|
|
8
|
+
schema,
|
|
9
|
+
name,
|
|
10
|
+
label,
|
|
11
|
+
messages,
|
|
12
|
+
control,
|
|
13
|
+
renderLabel,
|
|
14
|
+
renderErrors,
|
|
15
|
+
clientSideErrors = {}
|
|
16
|
+
}) => /* @__PURE__ */ jsxs(FieldRoot, { name, className: "flex w-full flex-col items-start gap-1", children: [
|
|
17
|
+
typeof label !== "undefined" && /* @__PURE__ */ jsx(Field.Label, { render: renderLabel, children: label }),
|
|
18
|
+
/* @__PURE__ */ jsx(JustInput, { render: control, ...getFieldConstraints(schema) }),
|
|
19
|
+
Object.entries(clientSideErrors).map(([stateName, message]) => /* @__PURE__ */ jsx(Field.Error, { match: stateName, render: renderErrors, children: typeof message === "string" ? message : message(getErrorMessagePayload(schema, stateName)) }, stateName)),
|
|
20
|
+
/* @__PURE__ */ jsx(ServerSideError, { name, messages, render: renderErrors })
|
|
21
|
+
] });
|
|
22
|
+
var BaseFormField_default = BaseFormField;
|
|
23
|
+
export {
|
|
24
|
+
BaseFormField_default as default
|
|
25
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import { Input } from '@base-ui/react/input';
|
|
4
|
+
|
|
5
|
+
type BaseInputProps = Omit<ComponentProps<typeof Input>, "size"> & {
|
|
6
|
+
size?: "lg" | "md" | "sm" | "xs";
|
|
7
|
+
};
|
|
8
|
+
declare const BaseInput: ({ size, className, ...otherProps }: BaseInputProps) => react.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { BaseInput as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Input } from "@base-ui/react/input";
|
|
3
|
+
import {} from "react";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
const BaseInput = ({
|
|
6
|
+
size = "md",
|
|
7
|
+
className,
|
|
8
|
+
...otherProps
|
|
9
|
+
}) => /* @__PURE__ */ jsx(
|
|
10
|
+
Input,
|
|
11
|
+
{
|
|
12
|
+
className: cn({
|
|
13
|
+
// Size
|
|
14
|
+
"h-12 px-5 text-base": size === "lg",
|
|
15
|
+
"h-9 px-3 text-sm": size === "md",
|
|
16
|
+
"h-8 px-2.5 text-sm": size === "sm",
|
|
17
|
+
"h-7 px-2 text-xs": size === "xs"
|
|
18
|
+
}, [
|
|
19
|
+
// Base
|
|
20
|
+
"rounded-md",
|
|
21
|
+
"outline-2",
|
|
22
|
+
"outline-offset-2",
|
|
23
|
+
"outline-transparent",
|
|
24
|
+
"transition-colors"
|
|
25
|
+
], className),
|
|
26
|
+
...otherProps
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
var BaseInput_default = BaseInput;
|
|
30
|
+
export {
|
|
31
|
+
BaseInput_default as default
|
|
32
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type FieldRootProps = {
|
|
5
|
+
name: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
declare const FieldRoot: ({ name, className, children, }: FieldRootProps) => react.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { FieldRoot as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Field } from "@base-ui/react/field";
|
|
4
|
+
import { use, useEffect } from "react";
|
|
5
|
+
import { FormContext } from "./FormContext.js";
|
|
6
|
+
const FieldRoot = ({
|
|
7
|
+
name,
|
|
8
|
+
className,
|
|
9
|
+
children
|
|
10
|
+
}) => {
|
|
11
|
+
const { registerField, unregisterField } = use(FormContext);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
registerField(name);
|
|
14
|
+
return () => {
|
|
15
|
+
unregisterField(name);
|
|
16
|
+
};
|
|
17
|
+
}, [name]);
|
|
18
|
+
return /* @__PURE__ */ jsx(Field.Root, { name, className, children });
|
|
19
|
+
};
|
|
20
|
+
var FieldRoot_default = FieldRoot;
|
|
21
|
+
export {
|
|
22
|
+
FieldRoot_default as default
|
|
23
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
interface FormContextInterface {
|
|
4
|
+
getFieldMessage: (fieldName: string) => string | null;
|
|
5
|
+
messageTranslations: Partial<Record<string, string>>;
|
|
6
|
+
registerField: (fieldName: string) => void;
|
|
7
|
+
unregisterField: (fieldName: string) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const FormContext: react.Context<FormContextInterface>;
|
|
10
|
+
|
|
11
|
+
export { FormContext };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import { Field } from '@base-ui/react/field';
|
|
4
|
+
|
|
5
|
+
type ServerSideErrorProps = {
|
|
6
|
+
name: string;
|
|
7
|
+
messages?: Partial<Record<string, string>>;
|
|
8
|
+
render?: ComponentProps<typeof Field.Error>["render"];
|
|
9
|
+
};
|
|
10
|
+
declare const ServerSideError: ({ name, messages: fieldMessages, render, }: ServerSideErrorProps) => react.JSX.Element | null;
|
|
11
|
+
|
|
12
|
+
export { ServerSideError as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Field } from "@base-ui/react/field";
|
|
4
|
+
import { use } from "react";
|
|
5
|
+
import { FormContext } from "./FormContext.js";
|
|
6
|
+
const ServerSideError = ({
|
|
7
|
+
name,
|
|
8
|
+
messages: fieldMessages = {},
|
|
9
|
+
render
|
|
10
|
+
}) => {
|
|
11
|
+
const { getFieldMessage, messageTranslations: formMessages } = use(FormContext);
|
|
12
|
+
const message = getFieldMessage(name);
|
|
13
|
+
if (!message) return null;
|
|
14
|
+
return /* @__PURE__ */ jsx(Field.Error, { match: true, render, children: fieldMessages[message] || formMessages[message] || message });
|
|
15
|
+
};
|
|
16
|
+
var ServerSideError_default = ServerSideError;
|
|
17
|
+
export {
|
|
18
|
+
ServerSideError_default as default
|
|
19
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as BaseInput } from './BaseInput.js';
|
|
2
|
+
export { default as BaseForm } from './BaseForm.js';
|
|
3
|
+
export { default as BaseFormField } from './BaseFormField.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@base-ui/react/input';
|
|
6
|
+
import '../elements/JustDiv.js';
|
|
7
|
+
import '@base-ui/react/use-render';
|
|
8
|
+
import '@base-ui/react/field';
|
|
9
|
+
import '../elements/JustInput.js';
|
|
10
|
+
import 'zod';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
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.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,17 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import JustAnchor from '../elements/JustAnchor.js';
|
|
4
|
+
import JustButton from '../elements/JustButton.js';
|
|
5
|
+
import '@base-ui/react/use-render';
|
|
6
|
+
|
|
7
|
+
type PaginationProps = {
|
|
8
|
+
totalItems: number;
|
|
9
|
+
itemsPerPage: number;
|
|
10
|
+
currentPage: number;
|
|
11
|
+
queryParams: Record<string, unknown>;
|
|
12
|
+
renderButton?: ComponentProps<typeof JustButton>["render"];
|
|
13
|
+
renderLink?: ComponentProps<typeof JustAnchor>["render"];
|
|
14
|
+
};
|
|
15
|
+
declare const Pagination: ({ totalItems, itemsPerPage, currentPage, queryParams, renderButton, renderLink, }: PaginationProps) => react.JSX.Element;
|
|
16
|
+
|
|
17
|
+
export { Pagination as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {} from "react";
|
|
3
|
+
import JustAnchor from "../elements/JustAnchor.js";
|
|
4
|
+
import JustButton from "../elements/JustButton.js";
|
|
5
|
+
const Pagination = ({
|
|
6
|
+
totalItems,
|
|
7
|
+
itemsPerPage,
|
|
8
|
+
currentPage,
|
|
9
|
+
queryParams,
|
|
10
|
+
renderButton,
|
|
11
|
+
renderLink
|
|
12
|
+
}) => {
|
|
13
|
+
const totalPages = Math.ceil(totalItems / itemsPerPage);
|
|
14
|
+
const buildHref = (page) => {
|
|
15
|
+
const searchParams = new URLSearchParams();
|
|
16
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
17
|
+
searchParams.append(key, `${value}`);
|
|
18
|
+
}
|
|
19
|
+
if (page === 1) {
|
|
20
|
+
searchParams.delete("page");
|
|
21
|
+
} else {
|
|
22
|
+
searchParams.set("page", page.toString());
|
|
23
|
+
}
|
|
24
|
+
return `?${searchParams}`;
|
|
25
|
+
};
|
|
26
|
+
const Item = (props) => {
|
|
27
|
+
if (props.active || props.disabled || typeof props.page === "undefined") {
|
|
28
|
+
return /* @__PURE__ */ jsx(JustButton, { render: renderButton, disabled: true, children: /* @__PURE__ */ jsx(Fragment, { children: props.children || props.page }) });
|
|
29
|
+
}
|
|
30
|
+
return /* @__PURE__ */ jsx(JustAnchor, { render: renderLink, href: buildHref(props.page), children: /* @__PURE__ */ jsx(Fragment, { children: props.children || props.page }) });
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
33
|
+
/* @__PURE__ */ jsx(Item, { page: currentPage - 1, disabled: currentPage <= 1, children: "\xAB" }),
|
|
34
|
+
currentPage > 3 && /* @__PURE__ */ jsx(Item, { page: 1 }),
|
|
35
|
+
currentPage === 5 && /* @__PURE__ */ jsx(Item, { page: 2 }),
|
|
36
|
+
currentPage > 5 && /* @__PURE__ */ jsx(Item, { disabled: true, children: "\u2026" }),
|
|
37
|
+
currentPage > 2 && /* @__PURE__ */ jsx(Item, { page: currentPage - 2 }),
|
|
38
|
+
currentPage > 1 && /* @__PURE__ */ jsx(Item, { page: currentPage - 1 }),
|
|
39
|
+
/* @__PURE__ */ jsx(Item, { active: true, children: currentPage }),
|
|
40
|
+
currentPage <= totalPages - 1 && /* @__PURE__ */ jsx(Item, { page: currentPage + 1 }),
|
|
41
|
+
currentPage <= totalPages - 2 && /* @__PURE__ */ jsx(Item, { page: currentPage + 2 }),
|
|
42
|
+
currentPage <= totalPages - 5 && /* @__PURE__ */ jsx(Item, { disabled: true, children: "\u2026" }),
|
|
43
|
+
currentPage === totalPages - 4 && /* @__PURE__ */ jsx(Item, { page: totalPages - 1 }),
|
|
44
|
+
currentPage <= totalPages - 3 && /* @__PURE__ */ jsx(Item, { page: totalPages }),
|
|
45
|
+
/* @__PURE__ */ jsx(Item, { page: currentPage + 1, disabled: currentPage >= totalPages, children: "\xBB" })
|
|
46
|
+
] });
|
|
47
|
+
};
|
|
48
|
+
var Pagination_default = Pagination;
|
|
49
|
+
export {
|
|
50
|
+
Pagination_default as default
|
|
51
|
+
};
|
|
@@ -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,36 @@
|
|
|
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 hasValidPointer = typeof e.clientX === "number" && typeof e.clientY === "number" && (e.clientX !== 0 || e.clientY !== 0);
|
|
11
|
+
const x = hasValidPointer ? e.clientX - rect.left - size / 2 : rect.width / 2 - size / 2;
|
|
12
|
+
const y = hasValidPointer ? e.clientY - rect.top - size / 2 : rect.height / 2 - size / 2;
|
|
13
|
+
const newRipple = { x, y, size, id: Date.now() };
|
|
14
|
+
setRipples((prev) => [...prev, newRipple]);
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
setRipples((prev) => prev.filter((r) => r.id !== newRipple.id));
|
|
17
|
+
}, 600);
|
|
18
|
+
};
|
|
19
|
+
const ripplesNode = /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pointer-events-none overflow-hidden rounded-[inherit]", children: ripples.map((ripple) => /* @__PURE__ */ jsx(
|
|
20
|
+
"span",
|
|
21
|
+
{
|
|
22
|
+
className: cn(styles.animation, "absolute rounded-full bg-current opacity-10"),
|
|
23
|
+
style: {
|
|
24
|
+
left: ripple.x,
|
|
25
|
+
top: ripple.y,
|
|
26
|
+
width: ripple.size,
|
|
27
|
+
height: ripple.size
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
ripple.id
|
|
31
|
+
)) });
|
|
32
|
+
return [handleClick, ripplesNode];
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
useRipples
|
|
36
|
+
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omer-x/tailwind-ui-kit",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.11",
|
|
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,36 @@
|
|
|
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
|
+
"./form": {
|
|
49
|
+
"types": "./dist/components/form/index.d.ts",
|
|
50
|
+
"import": "./dist/components/form/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./table": {
|
|
53
|
+
"types": "./dist/components/table/index.d.ts",
|
|
54
|
+
"import": "./dist/components/table/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./page": {
|
|
57
|
+
"types": "./dist/components/page/index.d.ts",
|
|
58
|
+
"import": "./dist/components/page/index.js"
|
|
59
|
+
},
|
|
35
60
|
"./utils": {
|
|
36
61
|
"types": "./dist/utils/index.d.ts",
|
|
37
62
|
"import": "./dist/utils/index.js"
|
|
@@ -45,8 +70,13 @@
|
|
|
45
70
|
"dev": "vite --port 3000",
|
|
46
71
|
"build": "tsup"
|
|
47
72
|
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@omer-x/zod-to-form-constraints": "^1.1.2"
|
|
75
|
+
},
|
|
48
76
|
"peerDependencies": {
|
|
49
77
|
"@base-ui/react": "^1",
|
|
78
|
+
"@fortawesome/free-brands-svg-icons": "^7",
|
|
79
|
+
"@fortawesome/free-solid-svg-icons": "^7",
|
|
50
80
|
"@fortawesome/react-fontawesome": "^3",
|
|
51
81
|
"clsx": "^2",
|
|
52
82
|
"react": "^19",
|
|
@@ -55,23 +85,21 @@
|
|
|
55
85
|
"tailwindcss": "^4"
|
|
56
86
|
},
|
|
57
87
|
"devDependencies": {
|
|
58
|
-
"@fortawesome/free-brands-svg-icons": "^7.2.0",
|
|
59
|
-
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|
|
60
88
|
"@omer-x/eslint-config": "^2.3.2",
|
|
61
|
-
"@tailwindcss/vite": "^4.3.
|
|
62
|
-
"@types/node": "^
|
|
63
|
-
"@types/react": "^19.2.
|
|
89
|
+
"@tailwindcss/vite": "^4.3.2",
|
|
90
|
+
"@types/node": "^26.1.0",
|
|
91
|
+
"@types/react": "^19.2.17",
|
|
64
92
|
"@types/react-dom": "^19.2.3",
|
|
65
|
-
"@vitejs/plugin-react": "^6.0.
|
|
66
|
-
"@vitest/coverage-v8": "^4.1.
|
|
93
|
+
"@vitejs/plugin-react": "^6.0.3",
|
|
94
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
67
95
|
"esbuild-fix-imports-plugin": "^1.0.23",
|
|
68
96
|
"eslint": "^9.37.0",
|
|
69
97
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
70
98
|
"eslint-plugin-react": "^7.37.5",
|
|
71
|
-
"semantic-release": "^25.0.
|
|
99
|
+
"semantic-release": "^25.0.5",
|
|
72
100
|
"tsup": "^8.5.1",
|
|
73
101
|
"typescript": "^5",
|
|
74
|
-
"vite": "^8.
|
|
75
|
-
"vitest": "^4.1.
|
|
102
|
+
"vite": "^8.1.3",
|
|
103
|
+
"vitest": "^4.1.9"
|
|
76
104
|
}
|
|
77
105
|
}
|
|
@@ -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
|
-
};
|