@omer-x/tailwind-ui-kit 1.0.0-alpha.5 → 1.0.0-alpha.7

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.
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { ComponentProps, ReactNode } from 'react';
3
3
  import { Button } from '@base-ui/react/button';
4
4
 
@@ -7,6 +7,6 @@ type BaseButtonProps = ComponentProps<typeof Button> & {
7
7
  pending?: boolean;
8
8
  children: ReactNode;
9
9
  };
10
- declare const BaseButton: ({ size, pending, disabled, focusableWhenDisabled, className, children, ...otherProps }: BaseButtonProps) => react_jsx_runtime.JSX.Element;
10
+ declare const BaseButton: ({ size, pending, disabled, focusableWhenDisabled, className, children, ...otherProps }: BaseButtonProps) => react.JSX.Element;
11
11
 
12
12
  export { BaseButton as default };
@@ -1,10 +1,10 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Button } from '@base-ui/react/button';
1
+ import * as react from 'react';
3
2
  import { ComponentProps, ReactNode } from 'react';
3
+ import { Button } from '@base-ui/react/button';
4
4
 
5
5
  type PulseButtonProps = ComponentProps<typeof Button> & {
6
6
  children: ReactNode;
7
7
  };
8
- declare const PulseButton: ({ children, onClick, ...otherProps }: PulseButtonProps) => react_jsx_runtime.JSX.Element;
8
+ declare const PulseButton: ({ children, onClick, ...otherProps }: PulseButtonProps) => react.JSX.Element;
9
9
 
10
10
  export { PulseButton as default };
@@ -1,4 +1,3 @@
1
1
  export { default as BaseButton } from './BaseButton.js';
2
- import 'react/jsx-runtime';
3
2
  import 'react';
4
3
  import '@base-ui/react/button';
@@ -0,0 +1,18 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ComponentProps } from 'react';
3
+ import { Field } from '@base-ui/react/field';
4
+ import { getFieldConstraints } from '@omer-x/zod-to-form-constraints';
5
+ import { ZodType } from 'zod';
6
+
7
+ type BaseFormFieldProps = {
8
+ schema: ZodType;
9
+ name: string;
10
+ label?: string;
11
+ renderInput: (props: ReturnType<typeof getFieldConstraints>) => ReactNode;
12
+ renderLabel?: ComponentProps<typeof Field.Label>["render"];
13
+ renderErrors?: ComponentProps<typeof Field.Error>["render"];
14
+ clientSideErrors?: Partial<Record<keyof ValidityState, string | ((payload: string | number | null) => string)>>;
15
+ };
16
+ declare const BaseFormField: ({ schema, name, label, renderInput, renderLabel, renderErrors, clientSideErrors, }: BaseFormFieldProps) => react.JSX.Element;
17
+
18
+ export { BaseFormField as default };
@@ -0,0 +1,23 @@
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 FieldRoot from "./FieldRoot.js";
5
+ import ServerSideError from "./ServerSideError.js";
6
+ const BaseFormField = ({
7
+ schema,
8
+ name,
9
+ label,
10
+ renderInput,
11
+ renderLabel,
12
+ renderErrors,
13
+ clientSideErrors = {}
14
+ }) => /* @__PURE__ */ jsxs(FieldRoot, { name, className: "flex w-full flex-col items-start gap-1", children: [
15
+ typeof label !== "undefined" && /* @__PURE__ */ jsx(Field.Label, { render: renderLabel, children: label }),
16
+ renderInput(getFieldConstraints(schema)),
17
+ Object.entries(clientSideErrors).map(([stateName, message]) => /* @__PURE__ */ jsx(Field.Error, { match: stateName, render: renderErrors, children: typeof message === "string" ? message : message(getErrorMessagePayload(schema, stateName)) }, stateName)),
18
+ /* @__PURE__ */ jsx(ServerSideError, { name, render: renderErrors })
19
+ ] });
20
+ var BaseFormField_default = BaseFormField;
21
+ export {
22
+ BaseFormField_default as default
23
+ };
@@ -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,9 @@
1
+ import * as react from 'react';
2
+ import { ComponentProps } from 'react';
3
+
4
+ type FormProps = Omit<ComponentProps<"form">, "action"> & {
5
+ action: (initialState: unknown, formData: FormData) => Promise<Record<string, string>>;
6
+ };
7
+ declare const Form: ({ action, className, children, }: FormProps) => react.JSX.Element;
8
+
9
+ export { Form as default };
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Form as BaseForm } from "@base-ui/react/form";
4
+ import { useActionState, useRef } from "react";
5
+ import { FormContext } from "./FormContext.js";
6
+ const Form = ({
7
+ action,
8
+ className,
9
+ children
10
+ }) => {
11
+ const [state, formAction, _loading] = useActionState(action, {});
12
+ const fieldsRef = useRef(/* @__PURE__ */ new Set());
13
+ const getError = (fieldName) => {
14
+ if (fieldName in state) {
15
+ return state[fieldName];
16
+ }
17
+ return null;
18
+ };
19
+ const registerField = (fieldName) => {
20
+ fieldsRef.current.add(fieldName);
21
+ };
22
+ const unregisterField = (fieldName) => {
23
+ fieldsRef.current.delete(fieldName);
24
+ };
25
+ const globalErrors = Object.fromEntries(Object.entries(state).filter(([key]) => {
26
+ if (!fieldsRef.current.has(key)) return true;
27
+ return key.startsWith("[") && key.endsWith("]");
28
+ }));
29
+ return /* @__PURE__ */ jsxs(BaseForm, { action: formAction, className, errors: state, children: [
30
+ JSON.stringify(Array.from(fieldsRef.current)),
31
+ Object.entries(globalErrors).map(([key, value]) => /* @__PURE__ */ jsx("div", { className: "bg-red-500/50", children: value }, key)),
32
+ /* @__PURE__ */ jsx(FormContext, { value: { getError, registerField, unregisterField }, children })
33
+ ] });
34
+ };
35
+ var Form_default = Form;
36
+ export {
37
+ Form_default as default
38
+ };
@@ -0,0 +1,10 @@
1
+ import * as react from 'react';
2
+
3
+ interface FormContextInterface {
4
+ getError: (fieldName: string) => string | null;
5
+ registerField: (fieldName: string) => void;
6
+ unregisterField: (fieldName: string) => void;
7
+ }
8
+ declare const FormContext: react.Context<FormContextInterface>;
9
+
10
+ export { FormContext };
@@ -0,0 +1,9 @@
1
+ import { createContext } from "react";
2
+ const FormContext = createContext({
3
+ getError: () => null,
4
+ registerField: () => null,
5
+ unregisterField: () => null
6
+ });
7
+ export {
8
+ FormContext
9
+ };
@@ -0,0 +1,11 @@
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
+ render?: ComponentProps<typeof Field.Error>["render"];
8
+ };
9
+ declare const ServerSideError: ({ name, render, }: ServerSideErrorProps) => react.JSX.Element;
10
+
11
+ export { ServerSideError as default };
@@ -0,0 +1,17 @@
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
+ render
9
+ }) => {
10
+ const { getError } = use(FormContext);
11
+ const error = getError(name);
12
+ return /* @__PURE__ */ jsx(Field.Error, { match: error !== null, render, children: error });
13
+ };
14
+ var ServerSideError_default = ServerSideError;
15
+ export {
16
+ ServerSideError_default as default
17
+ };
@@ -0,0 +1,8 @@
1
+ export { default as BaseInput } from './BaseInput.js';
2
+ export { default as Form } from './Form.js';
3
+ export { default as BaseFormField } from './BaseFormField.js';
4
+ import 'react';
5
+ import '@base-ui/react/input';
6
+ import '@base-ui/react/field';
7
+ import '@omer-x/zod-to-form-constraints';
8
+ import 'zod';
@@ -0,0 +1,8 @@
1
+ import { default as default2 } from "./BaseInput.js";
2
+ import { default as default3 } from "./Form.js";
3
+ import { default as default4 } from "./BaseFormField.js";
4
+ export {
5
+ default4 as BaseFormField,
6
+ default2 as BaseInput,
7
+ default3 as Form
8
+ };
@@ -1,10 +1,10 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { ComponentProps, ReactNode } from 'react';
3
3
 
4
4
  type ContainerProps = ComponentProps<"div"> & {
5
5
  className?: string;
6
6
  children: ReactNode;
7
7
  };
8
- declare const Container: ({ className, children, }: ContainerProps) => react_jsx_runtime.JSX.Element;
8
+ declare const Container: ({ className, children, }: ContainerProps) => react.JSX.Element;
9
9
 
10
10
  export { Container as default };
@@ -1,3 +1,2 @@
1
1
  export { default as Container } from './Container.js';
2
- import 'react/jsx-runtime';
3
2
  import 'react';
@@ -1,10 +1,10 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  type TdxProps = {
5
5
  className?: string;
6
6
  children?: ReactNode;
7
7
  };
8
- declare const Tdx: ({ className, children, }: TdxProps) => react_jsx_runtime.JSX.Element;
8
+ declare const Tdx: ({ className, children, }: TdxProps) => react.JSX.Element;
9
9
 
10
10
  export { Tdx as default };
@@ -1,3 +1,2 @@
1
1
  export { default as Tdx } from './Tdx.js';
2
- import 'react/jsx-runtime';
3
2
  import 'react';
@@ -1,5 +1,5 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
 
3
- declare function useRipples(): readonly [(e: React.MouseEvent<Element>) => void, react_jsx_runtime.JSX.Element];
3
+ declare function useRipples(): readonly [(e: React.MouseEvent<Element>) => void, react.JSX.Element];
4
4
 
5
5
  export { useRipples };
@@ -15,7 +15,7 @@ function useRipples() {
15
15
  setRipples((prev) => prev.filter((r) => r.id !== newRipple.id));
16
16
  }, 600);
17
17
  };
18
- const ripplesNode = /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pointer-events-none overflow-hidden rounded-md", children: ripples.map((ripple) => /* @__PURE__ */ jsx(
18
+ const ripplesNode = /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pointer-events-none overflow-hidden rounded-[inherit]", children: ripples.map((ripple) => /* @__PURE__ */ jsx(
19
19
  "span",
20
20
  {
21
21
  className: cn(styles.animation, "absolute rounded-full bg-current opacity-10"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omer-x/tailwind-ui-kit",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.7",
4
4
  "description": "Tailwind CSS-based React component library for building user interfaces",
5
5
  "keywords": [
6
6
  "tailwind",
@@ -45,6 +45,10 @@
45
45
  "types": "./dist/components/dialog/index.d.ts",
46
46
  "import": "./dist/components/dialog/index.js"
47
47
  },
48
+ "./form": {
49
+ "types": "./dist/components/form/index.d.ts",
50
+ "import": "./dist/components/form/index.js"
51
+ },
48
52
  "./table": {
49
53
  "types": "./dist/components/table/index.d.ts",
50
54
  "import": "./dist/components/table/index.js"
@@ -62,6 +66,9 @@
62
66
  "dev": "vite --port 3000",
63
67
  "build": "tsup"
64
68
  },
69
+ "dependencies": {
70
+ "@omer-x/zod-to-form-constraints": "^1.1.2"
71
+ },
65
72
  "peerDependencies": {
66
73
  "@base-ui/react": "^1",
67
74
  "@fortawesome/free-brands-svg-icons": "^7",
@@ -75,20 +82,20 @@
75
82
  },
76
83
  "devDependencies": {
77
84
  "@omer-x/eslint-config": "^2.3.2",
78
- "@tailwindcss/vite": "^4.3.0",
79
- "@types/node": "^25.7.0",
80
- "@types/react": "^19.2.14",
85
+ "@tailwindcss/vite": "^4.3.2",
86
+ "@types/node": "^26.1.0",
87
+ "@types/react": "^19.2.17",
81
88
  "@types/react-dom": "^19.2.3",
82
- "@vitejs/plugin-react": "^6.0.1",
83
- "@vitest/coverage-v8": "^4.1.6",
89
+ "@vitejs/plugin-react": "^6.0.3",
90
+ "@vitest/coverage-v8": "^4.1.9",
84
91
  "esbuild-fix-imports-plugin": "^1.0.23",
85
92
  "eslint": "^9.37.0",
86
93
  "eslint-plugin-jsx-a11y": "^6.10.2",
87
94
  "eslint-plugin-react": "^7.37.5",
88
- "semantic-release": "^25.0.3",
95
+ "semantic-release": "^25.0.5",
89
96
  "tsup": "^8.5.1",
90
97
  "typescript": "^5",
91
- "vite": "^8.0.12",
92
- "vitest": "^4.1.6"
98
+ "vite": "^8.1.3",
99
+ "vitest": "^4.1.9"
93
100
  }
94
101
  }