@omer-x/tailwind-ui-kit 1.0.0-alpha.10 → 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 +4 -4
- package/dist/components/button/BaseButton.js +1 -1
- package/dist/components/button/index.d.ts +1 -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 +1 -1
- package/dist/components/elements/JustDiv.js +2 -2
- package/dist/components/elements/JustInput.d.ts +6 -0
- package/dist/components/elements/JustInput.js +15 -0
- package/dist/components/form/BaseFormField.d.ts +5 -4
- package/dist/components/form/BaseFormField.js +3 -2
- package/dist/components/form/index.d.ts +1 -1
- 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/hooks/useRipples.js +3 -2
- package/package.json +5 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ComponentProps
|
|
3
|
-
import
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import PulseButton from './PulseButton.js';
|
|
4
|
+
import '@base-ui/react/button';
|
|
4
5
|
|
|
5
|
-
type BaseButtonProps = ComponentProps<typeof
|
|
6
|
+
type BaseButtonProps = ComponentProps<typeof PulseButton> & {
|
|
6
7
|
size?: "lg" | "md" | "sm" | "xs";
|
|
7
8
|
pending?: boolean;
|
|
8
|
-
children: ReactNode;
|
|
9
9
|
};
|
|
10
10
|
declare const BaseButton: ({ size, pending, disabled, focusableWhenDisabled, className, children, ...otherProps }: BaseButtonProps) => react.JSX.Element;
|
|
11
11
|
|
|
@@ -15,6 +15,7 @@ const BaseButton = ({
|
|
|
15
15
|
}) => /* @__PURE__ */ jsxs(
|
|
16
16
|
PulseButton,
|
|
17
17
|
{
|
|
18
|
+
...otherProps,
|
|
18
19
|
className: cn({
|
|
19
20
|
// Size
|
|
20
21
|
"h-12 px-5 text-base leading-7 gap-3": size === "lg",
|
|
@@ -39,7 +40,6 @@ const BaseButton = ({
|
|
|
39
40
|
], className),
|
|
40
41
|
disabled,
|
|
41
42
|
focusableWhenDisabled: pending || focusableWhenDisabled,
|
|
42
|
-
...otherProps,
|
|
43
43
|
children: [
|
|
44
44
|
pending && /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faSpinner, size: "lg", className: "fa-spin-pulse" }),
|
|
45
45
|
children
|
|
@@ -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
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { useRender } from '@base-ui/react/use-render';
|
|
3
3
|
|
|
4
|
-
declare const JustDiv: ({ render, ...
|
|
4
|
+
declare const JustDiv: ({ render, ...props }: useRender.ComponentProps<"div">) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
5
|
|
|
6
6
|
export { JustDiv as default };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useRender } from "@base-ui/react/use-render";
|
|
2
2
|
const JustDiv = ({
|
|
3
3
|
render,
|
|
4
|
-
...
|
|
4
|
+
...props
|
|
5
5
|
}) => {
|
|
6
6
|
return useRender({
|
|
7
7
|
defaultTagName: "div",
|
|
8
8
|
render,
|
|
9
|
-
props
|
|
9
|
+
props
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
var JustDiv_default = JustDiv;
|
|
@@ -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
|
+
};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
3
|
import { Field } from '@base-ui/react/field';
|
|
4
|
-
import
|
|
4
|
+
import JustInput from '../elements/JustInput.js';
|
|
5
5
|
import { ZodType } from 'zod';
|
|
6
|
+
import '@base-ui/react/use-render';
|
|
6
7
|
|
|
7
8
|
type BaseFormFieldProps = {
|
|
8
9
|
schema: ZodType;
|
|
9
10
|
name: string;
|
|
10
11
|
label?: string;
|
|
11
12
|
messages?: Partial<Record<string, string>>;
|
|
12
|
-
|
|
13
|
+
control?: ComponentProps<typeof JustInput>["render"];
|
|
13
14
|
renderLabel?: ComponentProps<typeof Field.Label>["render"];
|
|
14
15
|
renderErrors?: ComponentProps<typeof Field.Error>["render"];
|
|
15
16
|
clientSideErrors?: Partial<Record<keyof ValidityState, string | ((payload: string | number | null) => string)>>;
|
|
16
17
|
};
|
|
17
|
-
declare const BaseFormField: ({ schema, name, label, messages,
|
|
18
|
+
declare const BaseFormField: ({ schema, name, label, messages, control, renderLabel, renderErrors, clientSideErrors, }: BaseFormFieldProps) => react.JSX.Element;
|
|
18
19
|
|
|
19
20
|
export { BaseFormField as default };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Field } from "@base-ui/react/field";
|
|
3
3
|
import { getErrorMessagePayload, getFieldConstraints } from "@omer-x/zod-to-form-constraints";
|
|
4
|
+
import JustInput from "../elements/JustInput.js";
|
|
4
5
|
import FieldRoot from "./FieldRoot.js";
|
|
5
6
|
import ServerSideError from "./ServerSideError.js";
|
|
6
7
|
const BaseFormField = ({
|
|
@@ -8,13 +9,13 @@ const BaseFormField = ({
|
|
|
8
9
|
name,
|
|
9
10
|
label,
|
|
10
11
|
messages,
|
|
11
|
-
|
|
12
|
+
control,
|
|
12
13
|
renderLabel,
|
|
13
14
|
renderErrors,
|
|
14
15
|
clientSideErrors = {}
|
|
15
16
|
}) => /* @__PURE__ */ jsxs(FieldRoot, { name, className: "flex w-full flex-col items-start gap-1", children: [
|
|
16
17
|
typeof label !== "undefined" && /* @__PURE__ */ jsx(Field.Label, { render: renderLabel, children: label }),
|
|
17
|
-
|
|
18
|
+
/* @__PURE__ */ jsx(JustInput, { render: control, ...getFieldConstraints(schema) }),
|
|
18
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)),
|
|
19
20
|
/* @__PURE__ */ jsx(ServerSideError, { name, messages, render: renderErrors })
|
|
20
21
|
] });
|
|
@@ -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
|
+
};
|
package/dist/hooks/useRipples.js
CHANGED
|
@@ -7,8 +7,9 @@ function useRipples() {
|
|
|
7
7
|
const handleClick = (e) => {
|
|
8
8
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
9
9
|
const size = Math.max(rect.width, rect.height);
|
|
10
|
-
const
|
|
11
|
-
const
|
|
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;
|
|
12
13
|
const newRipple = { x, y, size, id: Date.now() };
|
|
13
14
|
setRipples((prev) => [...prev, newRipple]);
|
|
14
15
|
setTimeout(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
6
|
"tailwind",
|
|
@@ -53,6 +53,10 @@
|
|
|
53
53
|
"types": "./dist/components/table/index.d.ts",
|
|
54
54
|
"import": "./dist/components/table/index.js"
|
|
55
55
|
},
|
|
56
|
+
"./page": {
|
|
57
|
+
"types": "./dist/components/page/index.d.ts",
|
|
58
|
+
"import": "./dist/components/page/index.js"
|
|
59
|
+
},
|
|
56
60
|
"./utils": {
|
|
57
61
|
"types": "./dist/utils/index.d.ts",
|
|
58
62
|
"import": "./dist/utils/index.js"
|