@pumba-ui/ui 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +155 -2
- package/USAGE.md +180 -0
- package/dist/badge/badge.d.ts +7 -0
- package/dist/badge/badge.js +19 -0
- package/dist/badge/index.d.ts +1 -0
- package/dist/button/button.d.ts +9 -0
- package/dist/button/button.js +25 -0
- package/dist/button/index.d.ts +1 -0
- package/dist/card/card.d.ts +9 -0
- package/dist/card/card.js +27 -0
- package/dist/card/index.d.ts +8 -0
- package/dist/card/index.js +10 -0
- package/dist/dialog/dialog.d.ts +31 -0
- package/dist/dialog/dialog.js +72 -0
- package/dist/dialog/index.d.ts +10 -0
- package/dist/dialog/index.js +12 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/input.d.ts +7 -0
- package/dist/input/input.js +24 -0
- package/dist/reset.css +29 -0
- package/dist/styles.css +717 -0
- package/dist/tabs/index.d.ts +8 -0
- package/dist/tabs/index.js +10 -0
- package/dist/tabs/tabs.d.ts +25 -0
- package/dist/tabs/tabs.js +35 -0
- package/package.json +78 -3
- package/skills/pumba-design/SKILL.md +317 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vicente Loyola
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,156 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @pumba-ui/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Accessible React components for the Pumba design system.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @pumba-ui/ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`react` and `react-dom` (19 or later) are peer dependencies: your app provides them, so there
|
|
12
|
+
is only one copy of React.
|
|
13
|
+
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
Import the styles once, then use the components:
|
|
17
|
+
|
|
18
|
+
```css
|
|
19
|
+
@import "@pumba-ui/ui/styles.css";
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { Button, Card } from "@pumba-ui/ui";
|
|
24
|
+
|
|
25
|
+
export function Welcome() {
|
|
26
|
+
return (
|
|
27
|
+
<Card.Root>
|
|
28
|
+
<Card.Content>Ready to go.</Card.Content>
|
|
29
|
+
<Card.Footer>
|
|
30
|
+
<Button>Get started</Button>
|
|
31
|
+
</Card.Footer>
|
|
32
|
+
</Card.Root>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Every component, and every part of a compound component such as `Card.Root`, can be rendered
|
|
38
|
+
straight from a React Server Component (for example, a Next.js page). Each component file ships
|
|
39
|
+
its own `"use client"` directive, so you do not need a wrapper.
|
|
40
|
+
|
|
41
|
+
## Components
|
|
42
|
+
|
|
43
|
+
`Button`, `Card`, `Badge`, `Input`, `Tabs` and `Dialog`. They accept the native props of the
|
|
44
|
+
element they render, append your `className` to their own, and take a `render` prop to change
|
|
45
|
+
the element they render. The rules every component follows are in
|
|
46
|
+
[`docs/api-conventions.md`](https://github.com/vnloyola/pumba-ui/blob/main/docs/api-conventions.md).
|
|
47
|
+
|
|
48
|
+
[`USAGE.md`](./USAGE.md), shipped in the package, is the short guide for building an app with
|
|
49
|
+
Pumba: setup, theming, the props every component shares, compound components, the accessibility
|
|
50
|
+
the app provides and how dialogs stack. It is written so an agent can read it from
|
|
51
|
+
`node_modules/@pumba-ui/ui/USAGE.md`. The design rules that go with it ship as a skill in
|
|
52
|
+
`skills/pumba-design/SKILL.md`; `USAGE.md` shows how to register it in a project.
|
|
53
|
+
|
|
54
|
+
## Styles
|
|
55
|
+
|
|
56
|
+
Import the stylesheet once, in your app's entry CSS or JS:
|
|
57
|
+
|
|
58
|
+
```css
|
|
59
|
+
@import "@pumba-ui/ui/styles.css";
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
It contains the tokens (`--pumba-*`), a minimal base and every component's styles. The reset is
|
|
63
|
+
**not** included.
|
|
64
|
+
|
|
65
|
+
It also loads the Figtree and JetBrains Mono variable fonts, which `@pumba-ui/ui` installs as
|
|
66
|
+
dependencies (`@fontsource-variable/*`). Your bundler copies the font files; the browser only
|
|
67
|
+
downloads the subsets (`unicode-range`) the page uses.
|
|
68
|
+
|
|
69
|
+
### Layers
|
|
70
|
+
|
|
71
|
+
Pumba's CSS lives in layers under the `pumba.*` namespace, declared in this order:
|
|
72
|
+
|
|
73
|
+
```css
|
|
74
|
+
@layer pumba.reset, pumba.tokens, pumba.base, pumba.components;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`styles.css` starts with that statement. Your CSS outside any layer always wins over Pumba
|
|
78
|
+
without raising specificity.
|
|
79
|
+
|
|
80
|
+
### Without Tailwind
|
|
81
|
+
|
|
82
|
+
Nothing else is needed. To also use Pumba's reset, import it first:
|
|
83
|
+
|
|
84
|
+
```css
|
|
85
|
+
@import "@pumba-ui/ui/reset.css";
|
|
86
|
+
@import "@pumba-ui/ui/styles.css";
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### With Tailwind v4
|
|
90
|
+
|
|
91
|
+
Declare the layer order **once, before any import**, with `pumba` between `components` and
|
|
92
|
+
`utilities`. Do not import `reset.css`: Tailwind's preflight already does that job.
|
|
93
|
+
|
|
94
|
+
```css
|
|
95
|
+
@layer theme, base, components, pumba, utilities;
|
|
96
|
+
@import "tailwindcss";
|
|
97
|
+
@import "@pumba-ui/ui/styles.css";
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Tailwind utilities then win over Pumba, and Pumba wins over Tailwind's `base`. Without the
|
|
101
|
+
order statement the result depends on import order and one of the two stops working. See
|
|
102
|
+
section 13 of `docs/api-conventions.md` for the cases tested.
|
|
103
|
+
|
|
104
|
+
## Theme
|
|
105
|
+
|
|
106
|
+
Colors follow the OS (`prefers-color-scheme`). Set `data-theme="light"` or `data-theme="dark"`
|
|
107
|
+
on `<html>`, or on any element to theme only its subtree.
|
|
108
|
+
|
|
109
|
+
## For maintainers
|
|
110
|
+
|
|
111
|
+
### Development
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pnpm --filter @pumba-ui/ui build # dist/: index.js, .d.ts, styles.css, reset.css
|
|
115
|
+
pnpm --filter @pumba-ui/ui check:package # publint and arethetypeswrong
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### How the package is built
|
|
119
|
+
|
|
120
|
+
Three tools, one job each:
|
|
121
|
+
|
|
122
|
+
- **Vite** builds `src/` into readable ESM with one output file per source module
|
|
123
|
+
(`preserveModules`, `minify: false`; the consumer's bundler minifies). `react`, `react-dom`
|
|
124
|
+
and `@base-ui/react` stay external, so the consumer installs each once.
|
|
125
|
+
`emptyOutDir` is off because `dist/` also holds the types and CSS. Each component file
|
|
126
|
+
(`button.tsx`, `card.tsx`…) starts with `"use client"`, because the components call hooks
|
|
127
|
+
(`useRender`, `useRef`). The `index.ts` files do not: they build the compound objects
|
|
128
|
+
(`Card = { Root: CardRoot, … }`) outside the client module, so a Server Component that reads
|
|
129
|
+
`Card.Root` gets a client reference instead of `undefined`. A single bundle with one
|
|
130
|
+
`"use client"` banner cannot do that: the server only sees the `Card` object as an opaque
|
|
131
|
+
reference and cannot read its parts.
|
|
132
|
+
- **`tsc`** emits the declarations (`tsconfig.build.json`, which excludes tests, stories and
|
|
133
|
+
`icons.ts`).
|
|
134
|
+
Relative imports in `src` carry the `.js` extension so the emitted types resolve under Node's
|
|
135
|
+
ESM rules.
|
|
136
|
+
- **`scripts/build-css.mjs`** inlines the CSS `@import`s with `postcss-import`, resolving
|
|
137
|
+
`@pumba-ui/tokens/tokens.css` through the package's `exports` map the way a bundler would.
|
|
138
|
+
The `@fontsource-variable/*` imports are left as they are: their CSS points at the font files
|
|
139
|
+
with relative URLs, which only resolve from the package's own folder, so the consumer's
|
|
140
|
+
bundler resolves them.
|
|
141
|
+
The CSS is otherwise left as written, so the layer order statement stays at the top of
|
|
142
|
+
`styles.css` and the files stay readable and unminified.
|
|
143
|
+
|
|
144
|
+
### Conventions
|
|
145
|
+
|
|
146
|
+
- `src/icons.ts` is the only file that imports `lucide-react`. Components import icons from it,
|
|
147
|
+
so the icon library can change without touching them. While only stories and tests use icons,
|
|
148
|
+
`icons.ts` is left out of `dist/` and `lucide-react` is a `devDependency`; the first component
|
|
149
|
+
that renders an icon moves `lucide-react` back to `dependencies`, adds it to Vite's `external`
|
|
150
|
+
list and removes `icons.ts` from the `tsconfig.build.json` excludes.
|
|
151
|
+
- Each component's CSS is added to `src/styles/styles.css` with
|
|
152
|
+
`@import url("../<name>/<name>.css") layer(pumba.components);`.
|
|
153
|
+
- `reset.css` is optional and separate from `styles.css`. Tailwind users skip it.
|
|
154
|
+
- Every Pumba stylesheet starts with the layer order, which lives in `src/styles/layers.css`.
|
|
155
|
+
The names sit under `pumba.*` so they never merge with Tailwind's own `base` and `components`
|
|
156
|
+
layers.
|
package/USAGE.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Using @pumba-ui/ui
|
|
2
|
+
|
|
3
|
+
A guide for whoever builds an app with Pumba, person or agent. It covers what the types do not
|
|
4
|
+
say. For the props of each component, read the type declarations shipped in this package:
|
|
5
|
+
`dist/index.d.ts` and `dist/<component>/<component>.d.ts`. For the token names, read
|
|
6
|
+
`@pumba-ui/tokens/dist/index.d.ts` (`TokenName`). The full contract is
|
|
7
|
+
[`docs/api-conventions.md`](https://github.com/vnloyola/pumba-ui/blob/main/docs/api-conventions.md).
|
|
8
|
+
|
|
9
|
+
The design rules (which variant, token, spacing or elevation to pick) are in
|
|
10
|
+
`skills/pumba-design/SKILL.md`, next to this file, and match the installed version. To register
|
|
11
|
+
them as a skill, add `.claude/skills/pumba-design/SKILL.md` to the project with only a pointer, so
|
|
12
|
+
it never goes stale:
|
|
13
|
+
|
|
14
|
+
```markdown
|
|
15
|
+
---
|
|
16
|
+
name: pumba-design
|
|
17
|
+
description: Design rules for building UI with @pumba-ui/ui. Use when creating or reviewing pages, layouts or components that use Pumba.
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
Read `node_modules/@pumba-ui/ui/skills/pumba-design/SKILL.md` and follow it.
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
Import the styles once, in the app's entry CSS. They hold the tokens, a minimal base and every
|
|
26
|
+
component, and load the Figtree and JetBrains Mono fonts.
|
|
27
|
+
|
|
28
|
+
```css
|
|
29
|
+
@import "@pumba-ui/ui/reset.css"; /* optional; skip it with Tailwind */
|
|
30
|
+
@import "@pumba-ui/ui/styles.css";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
With Tailwind v4, declare the layer order first, before any import:
|
|
34
|
+
|
|
35
|
+
```css
|
|
36
|
+
@layer theme, base, components, pumba, utilities;
|
|
37
|
+
@import "tailwindcss";
|
|
38
|
+
@import "@pumba-ui/ui/styles.css";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Pumba's CSS lives in the layers `pumba.reset, pumba.tokens, pumba.base, pumba.components`. Your
|
|
42
|
+
CSS outside any layer always wins over it, without raising specificity.
|
|
43
|
+
|
|
44
|
+
Pumba does not style the page itself. Give the root its background, text color and font:
|
|
45
|
+
|
|
46
|
+
```css
|
|
47
|
+
body {
|
|
48
|
+
background: var(--pumba-color-background);
|
|
49
|
+
color: var(--pumba-color-text);
|
|
50
|
+
font-family: var(--pumba-text-body-font-family);
|
|
51
|
+
font-size: var(--pumba-text-body-font-size);
|
|
52
|
+
line-height: var(--pumba-text-body-line-height);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Components render from React Server Components without a wrapper: each component file already
|
|
57
|
+
ships `"use client"`.
|
|
58
|
+
|
|
59
|
+
## Tokens and theme
|
|
60
|
+
|
|
61
|
+
- Style your own layout with the semantic tokens (`--pumba-color-*`, `--pumba-space-*`,
|
|
62
|
+
`--pumba-radius-*`, `--pumba-shadow-*`, `--pumba-text-*`), never with literal colors, sizes or
|
|
63
|
+
`--pumba-primitive-*` tokens. Primitives are the raw palette and do not change meaning with the
|
|
64
|
+
theme.
|
|
65
|
+
- Colors follow the OS. `data-theme="dark"` or `data-theme="light"` on `<html>` forces a theme
|
|
66
|
+
for the page; on any other element it themes only that subtree, which then needs its own
|
|
67
|
+
`background` and `color`.
|
|
68
|
+
- To apply a stored theme without a flash, set `data-theme` from a blocking inline script in
|
|
69
|
+
`<head>`, not after React mounts.
|
|
70
|
+
- A surface inside a surface follows its corner with `--pumba-radius-control`: the surface radius
|
|
71
|
+
is the control radius plus `--pumba-space-inset`.
|
|
72
|
+
|
|
73
|
+
## Props every component shares
|
|
74
|
+
|
|
75
|
+
- Native props: a component accepts everything its element accepts (`Button` takes `type`,
|
|
76
|
+
`form`, `onClick`…). Unknown props reach the element.
|
|
77
|
+
- `className` is added to the component's own class, never replaces it. Do not restyle
|
|
78
|
+
`.pumba-*` classes to change a variant: pick the variant.
|
|
79
|
+
- `variant` and `size` are string unions written to `data-variant` and `data-size`, default value
|
|
80
|
+
included, so `[data-variant="secondary"]` is a valid selector. The default size is `md`.
|
|
81
|
+
- `render` changes the element a component renders and keeps its class, attributes and behavior:
|
|
82
|
+
`<Button render={<a href="/docs" />}>Docs</Button>` is an `<a>` styled as a button. The element
|
|
83
|
+
passed must forward `ref` and spread the props it receives. A Base UI part (`Tabs.Tab`,
|
|
84
|
+
`Dialog.Trigger`, `Dialog.Close`) that renders something other than a `<button>` also needs
|
|
85
|
+
`nativeButton={false}`.
|
|
86
|
+
- `ref` is a regular prop.
|
|
87
|
+
- A `Button` is as wide as its content only in a row. As a direct child of a grid or a
|
|
88
|
+
column flexbox it stretches, so give it `justify-self: start` (grid) or `align-self: start`
|
|
89
|
+
(flex), or put it in a row.
|
|
90
|
+
|
|
91
|
+
## Compound components
|
|
92
|
+
|
|
93
|
+
`Card`, `Tabs` and `Dialog` are objects of parts. Use the parts, in this shape:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<Card.Root render={<form onSubmit={save} />}>
|
|
97
|
+
<Card.Header>
|
|
98
|
+
<h2 className="card-title">Project details</h2>
|
|
99
|
+
</Card.Header>
|
|
100
|
+
<Card.Content>…</Card.Content>
|
|
101
|
+
<Card.Footer>
|
|
102
|
+
<Button variant="ghost" type="button" onClick={cancel}>Cancel</Button>
|
|
103
|
+
<Button type="submit">Save</Button>
|
|
104
|
+
</Card.Footer>
|
|
105
|
+
</Card.Root>
|
|
106
|
+
|
|
107
|
+
<Tabs.Root defaultValue="overview">
|
|
108
|
+
<Tabs.List aria-label="Project">
|
|
109
|
+
<Tabs.Tab value="overview">Overview</Tabs.Tab>
|
|
110
|
+
<Tabs.Tab value="settings">Settings</Tabs.Tab>
|
|
111
|
+
</Tabs.List>
|
|
112
|
+
<Tabs.Panel value="overview">…</Tabs.Panel>
|
|
113
|
+
<Tabs.Panel value="settings">…</Tabs.Panel>
|
|
114
|
+
</Tabs.Root>
|
|
115
|
+
|
|
116
|
+
<Dialog.Root>
|
|
117
|
+
<Dialog.Trigger>
|
|
118
|
+
<Button variant="destructive">Delete project</Button>
|
|
119
|
+
</Dialog.Trigger>
|
|
120
|
+
<Dialog.Content>
|
|
121
|
+
<Dialog.Title>Delete project</Dialog.Title>
|
|
122
|
+
<Dialog.Description>This cannot be undone.</Dialog.Description>
|
|
123
|
+
<div className="dialog-actions">
|
|
124
|
+
<Dialog.Close>
|
|
125
|
+
<Button variant="secondary">Cancel</Button>
|
|
126
|
+
</Dialog.Close>
|
|
127
|
+
<Dialog.Close>
|
|
128
|
+
<Button variant="destructive" onClick={deleteProject}>Delete project</Button>
|
|
129
|
+
</Dialog.Close>
|
|
130
|
+
</div>
|
|
131
|
+
</Dialog.Content>
|
|
132
|
+
</Dialog.Root>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- `Card.Root` stacks its parts with `--pumba-space-stack`, and `Card.Footer` lays out its
|
|
136
|
+
children in a row with `--pumba-space-gap`, so buttons go straight in the footer. `Card.Header`
|
|
137
|
+
has no type style: put your own heading in it. To make the card a form, render the root as one
|
|
138
|
+
(`render={<form />}`) instead of wrapping the parts, so the spacing between parts stays.
|
|
139
|
+
- `Tabs.Tab` and `Tabs.Panel` pair by the same string `value`. `Tabs.Root` takes `defaultValue`,
|
|
140
|
+
or `value` with `onValueChange(value)`.
|
|
141
|
+
- `Dialog.Root` takes `defaultOpen`, or `open` with `onOpenChange(open)`.
|
|
142
|
+
- `Dialog.Trigger` and `Dialog.Close` with a single element child give it their behavior, so a
|
|
143
|
+
`Button` inside them is one `<button>`. Do not nest them in a `Button` or the other way around
|
|
144
|
+
with `render`.
|
|
145
|
+
- `Dialog.Content` already renders the portal, the backdrop and the scrolling body, and stacks its
|
|
146
|
+
children in a column. Do not add your own overlay. Put the actions in your own row
|
|
147
|
+
(`display: flex; justify-content: flex-end; gap: var(--pumba-space-gap)`), or each button
|
|
148
|
+
stretches to the dialog's width. The confirming action is a `Button` with its `onClick` inside a
|
|
149
|
+
`Dialog.Close`, so it runs and closes the dialog.
|
|
150
|
+
- A `Card.Root` rendered as a link (`render={<a href="…" />}`) is a single link: put no button or
|
|
151
|
+
other link inside it.
|
|
152
|
+
|
|
153
|
+
## Accessibility you provide
|
|
154
|
+
|
|
155
|
+
- `Button` with `iconOnly` needs an `aria-label`. Icons next to a text label get
|
|
156
|
+
`aria-hidden="true"`. Pumba exports no icons: use any icon set.
|
|
157
|
+
- `Input` always has a visible label (`<label htmlFor>`); a placeholder is not a label. With
|
|
158
|
+
`invalid`, show the error as visible text linked with `aria-describedby`.
|
|
159
|
+
- State is never carried by color alone: a `Badge` with `variant="error"` or `"success"` has text
|
|
160
|
+
that names the state, ideally with an icon.
|
|
161
|
+
- A `Dialog.Content` has a `Dialog.Title`. Give `Tabs.List` an `aria-label` when nothing else
|
|
162
|
+
names it.
|
|
163
|
+
- Use `Button` for actions and a link (`<a>`, or `render={<a />}`) for navigation.
|
|
164
|
+
|
|
165
|
+
## Layers and stacking
|
|
166
|
+
|
|
167
|
+
`Dialog.Content` is rendered into `document.body`, outside your app's tree. Two consequences:
|
|
168
|
+
|
|
169
|
+
- Give the app's root its own stacking context, so the z-index of a sticky header or a sidebar
|
|
170
|
+
stays inside it and the dialog is drawn above:
|
|
171
|
+
|
|
172
|
+
```css
|
|
173
|
+
#root {
|
|
174
|
+
isolation: isolate;
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
A dialog drawn under something is fixed in the app's CSS, never inside the component.
|
|
179
|
+
- A dialog opened from a subtree with its own `data-theme` comes out with the page's theme. Pass
|
|
180
|
+
that subtree as `container`: `<Dialog.Content container={element}>`.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export type BadgeProps = ComponentProps<"span"> & {
|
|
3
|
+
variant?: "neutral" | "accent" | "success" | "error" | "warning";
|
|
4
|
+
size?: "sm" | "md";
|
|
5
|
+
render?: ReactElement | ((props: ComponentProps<"span">) => ReactElement);
|
|
6
|
+
};
|
|
7
|
+
export declare function Badge(props: BadgeProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
//#region src/badge/badge.tsx
|
|
5
|
+
function Badge(props) {
|
|
6
|
+
const { variant = "neutral", size = "md", render, ref, ...rest } = props;
|
|
7
|
+
return useRender({
|
|
8
|
+
defaultTagName: "span",
|
|
9
|
+
render,
|
|
10
|
+
ref,
|
|
11
|
+
props: mergeProps({
|
|
12
|
+
className: "pumba-badge",
|
|
13
|
+
"data-variant": variant,
|
|
14
|
+
"data-size": size
|
|
15
|
+
}, rest)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Badge };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Badge, type BadgeProps } from "./badge.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export type ButtonProps = ComponentProps<"button"> & {
|
|
3
|
+
variant?: "primary" | "secondary" | "ghost" | "destructive";
|
|
4
|
+
size?: "sm" | "md" | "lg";
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
iconOnly?: boolean;
|
|
7
|
+
render?: ReactElement | ((props: ComponentProps<"button">) => ReactElement);
|
|
8
|
+
};
|
|
9
|
+
export declare function Button(props: ButtonProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
//#region src/button/button.tsx
|
|
5
|
+
function Button(props) {
|
|
6
|
+
const { variant = "primary", size = "md", loading = false, iconOnly = false, disabled = false, render, ref, onClick, ...rest } = props;
|
|
7
|
+
return useRender({
|
|
8
|
+
defaultTagName: "button",
|
|
9
|
+
render,
|
|
10
|
+
ref,
|
|
11
|
+
props: mergeProps({
|
|
12
|
+
className: "pumba-button",
|
|
13
|
+
"data-variant": variant,
|
|
14
|
+
"data-size": size,
|
|
15
|
+
"data-disabled": disabled ? "" : void 0,
|
|
16
|
+
"data-loading": loading ? "" : void 0,
|
|
17
|
+
"data-icon-only": iconOnly ? "" : void 0,
|
|
18
|
+
"aria-busy": loading || void 0,
|
|
19
|
+
disabled,
|
|
20
|
+
onClick: loading ? void 0 : onClick
|
|
21
|
+
}, rest)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { Button };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Button, type ButtonProps } from "./button.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export type CardProps = ComponentProps<"div"> & {
|
|
3
|
+
render?: ReactElement | ((props: ComponentProps<"div">) => ReactElement);
|
|
4
|
+
};
|
|
5
|
+
declare function CardRoot(props: CardProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
6
|
+
declare function CardHeader(props: CardProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
+
declare function CardContent(props: CardProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
8
|
+
declare function CardFooter(props: CardProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
9
|
+
export { CardContent, CardFooter, CardHeader, CardRoot };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
//#region src/card/card.tsx
|
|
5
|
+
function usePart(className, props) {
|
|
6
|
+
const { render, ref, ...rest } = props;
|
|
7
|
+
return useRender({
|
|
8
|
+
defaultTagName: "div",
|
|
9
|
+
render,
|
|
10
|
+
ref,
|
|
11
|
+
props: mergeProps({ className }, rest)
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function CardRoot(props) {
|
|
15
|
+
return usePart("pumba-card", props);
|
|
16
|
+
}
|
|
17
|
+
function CardHeader(props) {
|
|
18
|
+
return usePart("pumba-card-header", props);
|
|
19
|
+
}
|
|
20
|
+
function CardContent(props) {
|
|
21
|
+
return usePart("pumba-card-content", props);
|
|
22
|
+
}
|
|
23
|
+
function CardFooter(props) {
|
|
24
|
+
return usePart("pumba-card-footer", props);
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { CardContent, CardFooter, CardHeader, CardRoot };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CardContent, CardFooter, CardHeader, CardRoot } from "./card.js";
|
|
2
|
+
export type { CardProps } from "./card.js";
|
|
3
|
+
export declare const Card: {
|
|
4
|
+
Root: typeof CardRoot;
|
|
5
|
+
Header: typeof CardHeader;
|
|
6
|
+
Content: typeof CardContent;
|
|
7
|
+
Footer: typeof CardFooter;
|
|
8
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
type Render<Tag extends "div" | "button" | "h2" | "p"> = ReactElement | ((props: ComponentProps<Tag>) => ReactElement);
|
|
3
|
+
export type DialogProps = {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
defaultOpen?: boolean;
|
|
6
|
+
onOpenChange?: (open: boolean) => void;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
type ButtonPartProps = ComponentProps<"button"> & {
|
|
10
|
+
nativeButton?: boolean;
|
|
11
|
+
render?: Render<"button">;
|
|
12
|
+
};
|
|
13
|
+
type DialogTriggerProps = ButtonPartProps;
|
|
14
|
+
type DialogContentProps = ComponentProps<"div"> & {
|
|
15
|
+
container?: HTMLElement | null;
|
|
16
|
+
render?: Render<"div">;
|
|
17
|
+
};
|
|
18
|
+
type DialogTitleProps = ComponentProps<"h2"> & {
|
|
19
|
+
render?: Render<"h2">;
|
|
20
|
+
};
|
|
21
|
+
type DialogDescriptionProps = ComponentProps<"p"> & {
|
|
22
|
+
render?: Render<"p">;
|
|
23
|
+
};
|
|
24
|
+
type DialogCloseProps = ButtonPartProps;
|
|
25
|
+
declare function DialogRoot({ onOpenChange, ...rest }: DialogProps): import("react").JSX.Element;
|
|
26
|
+
declare function DialogTrigger({ className, children, render, ...rest }: DialogTriggerProps): import("react").JSX.Element;
|
|
27
|
+
declare function DialogContent({ className, container, children, ref, ...rest }: DialogContentProps): import("react").JSX.Element;
|
|
28
|
+
declare function DialogTitle({ className, ...rest }: DialogTitleProps): import("react").JSX.Element;
|
|
29
|
+
declare function DialogDescription({ className, ...rest }: DialogDescriptionProps): import("react").JSX.Element;
|
|
30
|
+
declare function DialogClose({ className, children, render, ...rest }: DialogCloseProps): import("react").JSX.Element;
|
|
31
|
+
export { DialogClose, DialogContent, DialogDescription, DialogRoot, DialogTitle, DialogTrigger };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
3
|
+
import { isValidElement, useRef } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/dialog/dialog.tsx
|
|
6
|
+
var FOCUSABLE = "a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
7
|
+
var setRefs = (...refs) => (node) => {
|
|
8
|
+
for (const ref of refs) if (typeof ref === "function") ref(node);
|
|
9
|
+
else if (ref) ref.current = node;
|
|
10
|
+
};
|
|
11
|
+
var elementFromChild = (children, render) => render === void 0 && isValidElement(children) ? {
|
|
12
|
+
render: children,
|
|
13
|
+
children: children.props.children
|
|
14
|
+
} : {
|
|
15
|
+
render,
|
|
16
|
+
children
|
|
17
|
+
};
|
|
18
|
+
var join = (own, className) => className ? `${own} ${className}` : own;
|
|
19
|
+
function DialogRoot({ onOpenChange, ...rest }) {
|
|
20
|
+
return /* @__PURE__ */ jsx(Dialog.Root, {
|
|
21
|
+
onOpenChange: (open) => onOpenChange?.(open),
|
|
22
|
+
...rest
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function DialogTrigger({ className, children, render, ...rest }) {
|
|
26
|
+
return /* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
27
|
+
className: join("pumba-dialog-trigger", className),
|
|
28
|
+
...elementFromChild(children, render),
|
|
29
|
+
...rest
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function DialogContent({ className, container, children, ref, ...rest }) {
|
|
33
|
+
const popup = useRef(null);
|
|
34
|
+
return /* @__PURE__ */ jsxs(Dialog.Portal, {
|
|
35
|
+
container,
|
|
36
|
+
children: [/* @__PURE__ */ jsx(Dialog.Backdrop, { className: "pumba-dialog-backdrop" }), /* @__PURE__ */ jsx(Dialog.Popup, {
|
|
37
|
+
className: join("pumba-dialog", className),
|
|
38
|
+
ref: setRefs(ref, popup),
|
|
39
|
+
initialFocus: () => {
|
|
40
|
+
const target = popup.current?.querySelector(FOCUSABLE) ?? popup.current;
|
|
41
|
+
target?.focus({ preventScroll: true });
|
|
42
|
+
return document.activeElement === target ? false : null;
|
|
43
|
+
},
|
|
44
|
+
...rest,
|
|
45
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
46
|
+
className: "pumba-dialog-body",
|
|
47
|
+
children
|
|
48
|
+
})
|
|
49
|
+
})]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function DialogTitle({ className, ...rest }) {
|
|
53
|
+
return /* @__PURE__ */ jsx(Dialog.Title, {
|
|
54
|
+
className: join("pumba-dialog-title", className),
|
|
55
|
+
...rest
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function DialogDescription({ className, ...rest }) {
|
|
59
|
+
return /* @__PURE__ */ jsx(Dialog.Description, {
|
|
60
|
+
className: join("pumba-dialog-description", className),
|
|
61
|
+
...rest
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function DialogClose({ className, children, render, ...rest }) {
|
|
65
|
+
return /* @__PURE__ */ jsx(Dialog.Close, {
|
|
66
|
+
className: join("pumba-dialog-close", className),
|
|
67
|
+
...elementFromChild(children, render),
|
|
68
|
+
...rest
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { DialogClose, DialogContent, DialogDescription, DialogRoot, DialogTitle, DialogTrigger };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DialogClose, DialogContent, DialogDescription, DialogRoot, DialogTitle, DialogTrigger } from "./dialog.js";
|
|
2
|
+
export type { DialogProps } from "./dialog.js";
|
|
3
|
+
export declare const Dialog: {
|
|
4
|
+
Root: typeof DialogRoot;
|
|
5
|
+
Trigger: typeof DialogTrigger;
|
|
6
|
+
Content: typeof DialogContent;
|
|
7
|
+
Title: typeof DialogTitle;
|
|
8
|
+
Description: typeof DialogDescription;
|
|
9
|
+
Close: typeof DialogClose;
|
|
10
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DialogClose, DialogContent, DialogDescription, DialogRoot, DialogTitle, DialogTrigger } from "./dialog.js";
|
|
2
|
+
//#region src/dialog/index.ts
|
|
3
|
+
var Dialog = {
|
|
4
|
+
Root: DialogRoot,
|
|
5
|
+
Trigger: DialogTrigger,
|
|
6
|
+
Content: DialogContent,
|
|
7
|
+
Title: DialogTitle,
|
|
8
|
+
Description: DialogDescription,
|
|
9
|
+
Close: DialogClose
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Dialog };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Badge, type BadgeProps } from "./badge/index.js";
|
|
2
|
+
export { Button, type ButtonProps } from "./button/index.js";
|
|
3
|
+
export { Card, type CardProps } from "./card/index.js";
|
|
4
|
+
export { Dialog, type DialogProps } from "./dialog/index.js";
|
|
5
|
+
export { Input, type InputProps } from "./input/index.js";
|
|
6
|
+
export { Tabs, type TabsProps } from "./tabs/index.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Badge } from "./badge/badge.js";
|
|
2
|
+
import { Button } from "./button/button.js";
|
|
3
|
+
import { Card } from "./card/index.js";
|
|
4
|
+
import { Dialog } from "./dialog/index.js";
|
|
5
|
+
import { Input } from "./input/input.js";
|
|
6
|
+
import { Tabs } from "./tabs/index.js";
|
|
7
|
+
export { Badge, Button, Card, Dialog, Input, Tabs };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Input, type InputProps } from "./input.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentProps, ReactElement } from "react";
|
|
2
|
+
export type InputProps = Omit<ComponentProps<"input">, "size"> & {
|
|
3
|
+
size?: "sm" | "md" | "lg";
|
|
4
|
+
invalid?: boolean;
|
|
5
|
+
render?: ReactElement | ((props: ComponentProps<"input">) => ReactElement);
|
|
6
|
+
};
|
|
7
|
+
export declare function Input(props: InputProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|