@omer-x/tailwind-ui-kit 1.0.0-alpha.24 → 1.0.0-alpha.26

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/README.md CHANGED
@@ -27,28 +27,24 @@ npm install @omer-x/tailwind-ui-kit
27
27
  Peer dependencies:
28
28
 
29
29
  ```sh
30
- npm install react@19 react-dom@19 tailwindcss@4 @base-ui/react@1
30
+ npm install react@19 react-dom@19 tailwindcss@4 @base-ui/react@1 zod@4
31
31
  ```
32
32
 
33
- `BaseForm` needs [`@omer-x/next-form-actions`](https://github.com/omermecitoglu/next-form-actions) v2 for its action and result types, and `BaseFormField` needs [`zod`](https://zod.dev) for its `schema` prop.
33
+ `BaseForm` needs [`@omer-x/next-form-actions`](https://github.com/omermecitoglu/next-form-actions) v2 for its action and result types, and `BaseFormField` needs [`zod`](https://zod.dev) v4 for its `schema` prop.
34
34
 
35
35
  ## Setup
36
36
 
37
- ### 1. Let Tailwind scan the package
38
-
39
37
  Tailwind v4 does not scan `node_modules`, so the classes used inside the components won't be generated unless you add an `@source` line to your global CSS. The path is relative to the CSS file:
40
38
 
41
39
  ```css
42
40
  /* src/app/globals.css */
43
41
  @import "tailwindcss";
44
- @source "../../node_modules/@omer-x/tailwind-ui-kit";
42
+ @source "../../node_modules/@omer-x/tailwind-ui-kit/dist";
45
43
  ```
46
44
 
47
- Some components use the `dark:` variant (e.g. the backdrop of `BaseDialog.Popup`). They follow whatever `dark` variant your app defines.
48
-
49
- ### 2. Your bundler must support CSS modules
45
+ That's the only setup. The kit ships no CSS files: everything, including the ripple animation, is Tailwind utilities.
50
46
 
51
- The ripple effect imports a CSS module from `node_modules`. Next.js and Vite handle this out of the box.
47
+ Some components use the `dark:` variant (e.g. the backdrop of `BaseDialog.Popup`). They follow whatever `dark` variant your app defines.
52
48
 
53
49
  ## Theming: wrap once, use everywhere
54
50
 
@@ -297,6 +293,25 @@ Error texts come from `BaseForm`'s `formatMessage`. Render functions get `FieldS
297
293
  />
298
294
  ```
299
295
 
296
+ **One schema for the server and the client.** Define one Zod object schema per form. Use it to validate in the server action, and pass its fields to `BaseFormField`. The browser checks then always match the server rules:
297
+
298
+ ```ts
299
+ // src/schemas/user.ts
300
+ import { z } from "zod";
301
+
302
+ export const UserSchema = z.object({
303
+ username: z.string().min(3).max(20),
304
+ email: z.email(),
305
+ });
306
+ ```
307
+
308
+ ```tsx
309
+ <BaseFormField name="username" label="Username" schema={UserSchema.shape.username} control={<Input />} />
310
+ <BaseFormField name="email" label="Email" schema={UserSchema.shape.email} control={<Input type="email" />} />
311
+ ```
312
+
313
+ The browser can check only the rules that map to HTML attributes (`required`, `minLength`, `maxLength`, `min`, `max`, …). Refinements, transforms, cross-field rules and async checks such as "username taken" only run on the server, and come back as `fieldErrors`. Users can also bypass browser checks, so **the server action must always validate the full schema**. The client constraints only give earlier feedback.
314
+
300
315
  ### `@omer-x/tailwind-ui-kit/dialog`
301
316
 
302
317
  #### `BaseDialog`
@@ -393,7 +408,7 @@ A `DialogHandle<Payload>` has `open(triggerId?)`, `openWithPayload(payload)`, `c
393
408
 
394
409
  #### `Container`
395
410
 
396
- Tailwind's `container`, centered with horizontal padding (`container mx-auto px-3`). Accepts `className` and `children`.
411
+ Tailwind's `container`, centered with horizontal padding (`container mx-auto px-3`). Accepts all `<div>` props.
397
412
 
398
413
  ### `@omer-x/tailwind-ui-kit/page`
399
414
 
@@ -449,16 +464,63 @@ const items = usePagination({ totalItems, itemsPerPage, currentPage, siblings: 1
449
464
 
450
465
  ### `@omer-x/tailwind-ui-kit/table`
451
466
 
452
- #### `Tdx`
467
+ #### `TableCell`
468
+
469
+ A `<td>` that accepts all `<td>` props (`colSpan`, `rowSpan`, `title`, event handlers, …).
453
470
 
454
- A `<td>` whose content is cut to a single line with an ellipsis instead of widening the column. Accepts `className` and `children`.
471
+ | Prop | Type | Description |
472
+ |------|------|-------------|
473
+ | `overflow` | `"wrap" \| "truncate"` | `"wrap"` (default) is a normal `<td>`. `"truncate"` keeps the content on one line and cuts it with an ellipsis instead of widening the column. Exposed as `data-overflow`. |
455
474
 
456
475
  ```tsx
457
476
  <tr>
458
- <Tdx className="max-w-48">{longDescription}</Tdx>
477
+ <TableCell overflow="truncate" className="max-w-48">{product.description}</TableCell>
478
+ <TableCell overflow={expanded ? "wrap" : "truncate"}>{product.notes}</TableCell>
459
479
  </tr>
460
480
  ```
461
481
 
482
+ #### `Tdx` (deprecated)
483
+
484
+ Use `<TableCell overflow="truncate">` instead. `Tdx` is kept as an alias for it and accepts the same `<td>` props.
485
+
486
+ ### `@omer-x/tailwind-ui-kit/elements`
487
+
488
+ Bare HTML elements whose only addition is a `render` prop (`RenderProp<Tag>`): `JustAnchor` (`<a>`), `JustButton` (`<button>`), `JustDiv` (`<div>`), `JustInput` (`<input>`) and `JustSpan` (`<span>`). They take all props of their element and add no styles.
489
+
490
+ ```tsx
491
+ import { JustDiv } from "@omer-x/tailwind-ui-kit/elements";
492
+
493
+ <JustDiv className="p-4" render={<section />}>…</JustDiv>
494
+ ```
495
+
496
+ ### `@omer-x/tailwind-ui-kit/hooks`
497
+
498
+ #### `useRipples`
499
+
500
+ The ripple effect of `BaseButton`, for your own clickable elements. Returns `[handleClick, ripples]`: call `handleClick` from `onClick` and render `ripples` inside the element.
501
+
502
+ - The element needs `relative` (the ripples are positioned absolutely and clipped to its rounded corners).
503
+ - Ripples use `bg-current`, so they follow the text color. They start from the center on keyboard clicks and are hidden when the user prefers reduced motion.
504
+ - It imports a CSS module (see [Setup](#2-your-bundler-must-support-css-modules)).
505
+
506
+ ```tsx
507
+ import { useRipples } from "@omer-x/tailwind-ui-kit/hooks";
508
+
509
+ const Chip = ({ children, onClick, ...props }: ComponentProps<"button">) => {
510
+ const [handleRipple, ripples] = useRipples();
511
+ return (
512
+ <button
513
+ {...props}
514
+ className="relative rounded-full px-3 py-1"
515
+ onClick={event => { handleRipple(event); onClick?.(event); }}
516
+ >
517
+ {children}
518
+ {ripples}
519
+ </button>
520
+ );
521
+ };
522
+ ```
523
+
462
524
  ### `@omer-x/tailwind-ui-kit/utils`
463
525
 
464
526
  Helpers for building your own components on the kit, so you never import Base UI.
@@ -0,0 +1,6 @@
1
+ import JustAnchor from "./JustAnchor.js";
2
+ import JustButton from "./JustButton.js";
3
+ import JustDiv from "./JustDiv.js";
4
+ import JustInput from "./JustInput.js";
5
+ import JustSpan from "./JustSpan.js";
6
+ export { JustAnchor, JustButton, JustDiv, JustInput, JustSpan };
@@ -0,0 +1,6 @@
1
+ import JustAnchor from "./JustAnchor.js";
2
+ import JustButton from "./JustButton.js";
3
+ import JustDiv from "./JustDiv.js";
4
+ import JustInput from "./JustInput.js";
5
+ import JustSpan from "./JustSpan.js";
6
+ export { JustAnchor, JustButton, JustDiv, JustInput, JustSpan };
@@ -1,7 +1,4 @@
1
- import { ComponentProps, ReactNode } from "react";
2
- type ContainerProps = ComponentProps<"div"> & {
3
- className?: string;
4
- children: ReactNode;
5
- };
6
- declare const Container: ({ className, children }: ContainerProps) => import("react").JSX.Element;
1
+ import { ComponentProps } from "react";
2
+ type ContainerProps = ComponentProps<"div">;
3
+ declare const Container: ({ className, ...props }: ContainerProps) => import("react").JSX.Element;
7
4
  export { Container as default };
@@ -3,8 +3,8 @@ import { cn } from "cn";
3
3
  import "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  // src/components/layout/Container.tsx
6
- const Container = ({ className, children }) => /* @__PURE__ */ jsx("div", {
6
+ const Container = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
7
7
  className: cn("container mx-auto px-3", className),
8
- children
8
+ ...props
9
9
  });
10
10
  export { Container as default };
@@ -0,0 +1,13 @@
1
+ import { ComponentProps } from "react";
2
+ export type TableCellOverflow = "wrap" | "truncate";
3
+ type TableCellProps = ComponentProps<"td"> & {
4
+ /**
5
+ * How content wider than the column is handled.
6
+ * - `"wrap"` (default): a normal `<td>`, content wraps.
7
+ * - `"truncate"`: one line, cut with an ellipsis instead of widening the column.
8
+ */
9
+ overflow?: TableCellOverflow;
10
+ };
11
+ /** A `<td>` that takes all `<td>` props. Exposes `data-overflow`. */
12
+ declare const TableCell: ({ overflow, children, ...props }: TableCellProps) => import("react").JSX.Element;
13
+ export { TableCell as default };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/table/TableCell.tsx
5
+ /** A `<td>` that takes all `<td>` props. Exposes `data-overflow`. */
6
+ const TableCell = ({ overflow = "wrap", children, ...props }) => /* @__PURE__ */ jsx("td", {
7
+ "data-overflow": overflow,
8
+ ...props,
9
+ children: overflow === "truncate" ? /* @__PURE__ */ jsx("div", {
10
+ className: "table w-full table-fixed",
11
+ children: /* @__PURE__ */ jsx("span", {
12
+ className: "table-cell truncate",
13
+ children
14
+ })
15
+ }) : children
16
+ });
17
+ export { TableCell as default };
@@ -1,7 +1,6 @@
1
- import { ReactNode } from "react";
2
- type TdxProps = {
3
- className?: string;
4
- children?: ReactNode;
5
- };
6
- declare const Tdx: ({ className, children }: TdxProps) => import("react").JSX.Element;
1
+ import { ComponentProps } from "react";
2
+ /**
3
+ * @deprecated Use `<TableCell overflow="truncate">` instead.
4
+ */
5
+ declare const Tdx: (props: ComponentProps<"td">) => import("react").JSX.Element;
7
6
  export { Tdx as default };
@@ -1,15 +1,12 @@
1
1
  "use client";
2
- import "react";
2
+ import TableCell from "./TableCell.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  // src/components/table/Tdx.tsx
5
- const Tdx = ({ className, children }) => /* @__PURE__ */ jsx("td", {
6
- className,
7
- children: /* @__PURE__ */ jsx("div", {
8
- className: "table w-full table-fixed",
9
- children: /* @__PURE__ */ jsx("span", {
10
- className: "table-cell truncate",
11
- children
12
- })
13
- })
5
+ /**
6
+ * @deprecated Use `<TableCell overflow="truncate">` instead.
7
+ */
8
+ const Tdx = (props) => /* @__PURE__ */ jsx(TableCell, {
9
+ overflow: "truncate",
10
+ ...props
14
11
  });
15
12
  export { Tdx as default };
@@ -1,2 +1,3 @@
1
+ import TableCell, { TableCellOverflow } from "./TableCell.js";
1
2
  import Tdx from "./Tdx.js";
2
- export { Tdx };
3
+ export { TableCell, type TableCellOverflow, Tdx };
@@ -1 +1,3 @@
1
- export { default as Tdx } from "./Tdx.js";
1
+ import TableCell from "./TableCell.js";
2
+ import Tdx from "./Tdx.js";
3
+ export { TableCell, Tdx };
@@ -0,0 +1,2 @@
1
+ import { useRipples } from "./useRipples.js";
2
+ export { useRipples };
@@ -0,0 +1 @@
1
+ export { useRipples } from "./useRipples.js";
@@ -1,6 +1,4 @@
1
- import { cn } from "cn";
2
1
  import { useEffect, useRef, useState } from "react";
3
- import styles from "../styles/ripple.module.css";
4
2
  import { jsx } from "react/jsx-runtime";
5
3
  // src/hooks/useRipples.tsx
6
4
  const RIPPLE_DURATION = 600;
@@ -36,7 +34,7 @@ function useRipples() {
36
34
  return [handleClick, /* @__PURE__ */ jsx("div", {
37
35
  className: "absolute inset-0 pointer-events-none overflow-hidden rounded-[inherit] motion-reduce:hidden",
38
36
  children: ripples.map((ripple) => /* @__PURE__ */ jsx("span", {
39
- className: cn(styles.animation, "absolute rounded-full bg-current opacity-10"),
37
+ className: "absolute rounded-full bg-current scale-400 opacity-0 transition-[scale,opacity] duration-600 ease-linear starting:scale-0 starting:opacity-10",
40
38
  style: {
41
39
  left: ripple.x,
42
40
  top: ripple.y,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omer-x/tailwind-ui-kit",
3
- "version": "1.0.0-alpha.24",
3
+ "version": "1.0.0-alpha.26",
4
4
  "description": "Tailwind CSS-based React component library for building user interfaces",
5
5
  "keywords": [
6
6
  "tailwind",
@@ -57,6 +57,14 @@
57
57
  "types": "./dist/components/page/index.d.ts",
58
58
  "import": "./dist/components/page/index.js"
59
59
  },
60
+ "./elements": {
61
+ "types": "./dist/components/elements/index.d.ts",
62
+ "import": "./dist/components/elements/index.js"
63
+ },
64
+ "./hooks": {
65
+ "types": "./dist/hooks/index.d.ts",
66
+ "import": "./dist/hooks/index.js"
67
+ },
60
68
  "./utils": {
61
69
  "types": "./dist/utils/index.d.ts",
62
70
  "import": "./dist/utils/index.js"
@@ -81,7 +89,8 @@
81
89
  "@omer-x/next-form-actions": "^2.0.0-alpha.1",
82
90
  "react": "^19",
83
91
  "react-dom": "^19",
84
- "tailwindcss": "^4"
92
+ "tailwindcss": "^4",
93
+ "zod": "^4"
85
94
  },
86
95
  "devDependencies": {
87
96
  "@omer-x/eslint-config": "^2.3.3",
@@ -104,6 +113,7 @@
104
113
  "tsdown": "^0.23.7",
105
114
  "typescript": "^6.0.3",
106
115
  "vite": "^8.4.0",
107
- "vitest": "^5.1.2"
116
+ "vitest": "^5.1.2",
117
+ "zod": "^4.6.7"
108
118
  }
109
119
  }
@@ -1,11 +0,0 @@
1
- @keyframes ripple {
2
- to {
3
- transform: scale(4);
4
- opacity: 0;
5
- }
6
- }
7
-
8
- .animation {
9
- animation: ripple 600ms linear;
10
- transform: scale(0);
11
- }