velocis 1.0.1 → 1.1.1
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/AGENTS.md +29 -0
- package/README.md +33 -0
- package/dist/card.d.cts +3 -0
- package/dist/card.d.ts +3 -0
- package/dist/dialog1.cjs +24 -0
- package/dist/dialog1.d.cts +1 -0
- package/dist/dialog1.d.ts +1 -0
- package/dist/dialog1.js +2 -0
- package/dist/dropdown1.cjs +24 -0
- package/dist/dropdown1.d.cts +1 -0
- package/dist/dropdown1.d.ts +1 -0
- package/dist/dropdown1.js +2 -0
- package/dist/table2.cjs +24 -0
- package/dist/table2.d.cts +1 -0
- package/dist/table2.d.ts +1 -0
- package/dist/table2.js +2 -0
- package/docs/README.md +89 -0
- package/docs/card.md +77 -0
- package/docs/core.md +75 -0
- package/docs/dialog1.md +180 -0
- package/docs/dropdown1.md +154 -0
- package/docs/feedback.md +90 -0
- package/docs/forms.md +78 -0
- package/docs/hero.md +84 -0
- package/docs/list.md +73 -0
- package/docs/navigation.md +102 -0
- package/docs/table.md +111 -0
- package/docs/table2.md +265 -0
- package/docs/theme.md +66 -0
- package/package.json +26 -5
package/AGENTS.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# AI / Agent reference
|
|
2
|
+
|
|
3
|
+
When integrating Velocis in a consumer project, read these files (included in the published npm package under `node_modules/velocis/docs/`):
|
|
4
|
+
|
|
5
|
+
1. **[docs/README.md](./docs/README.md)** — setup, import rules, component picker
|
|
6
|
+
2. **Module docs** — `docs/theme.md`, `docs/card.md`, `docs/hero.md`, `docs/table.md`, `docs/table2.md`, `docs/dialog1.md`, `docs/dropdown1.md`, `docs/list.md`, `docs/feedback.md`, `docs/forms.md`, `docs/navigation.md`, `docs/core.md`
|
|
7
|
+
|
|
8
|
+
## Rules
|
|
9
|
+
|
|
10
|
+
- Always import `velocis/styles.css` in the root layout.
|
|
11
|
+
- Wrap the app with `VelocisProvider` and `DirectionProvider` from `velocis/theme`.
|
|
12
|
+
- Use subpath imports: `velocis/table`, `velocis/card`, etc.
|
|
13
|
+
- Use `'use client'` for interactive components in Next.js App Router.
|
|
14
|
+
- Pick the variant documented in each module's "When to use" section.
|
|
15
|
+
|
|
16
|
+
## Quick picker
|
|
17
|
+
|
|
18
|
+
| Task | Import |
|
|
19
|
+
|------|--------|
|
|
20
|
+
| Data grid | `Table` from `velocis/table` |
|
|
21
|
+
| Custom UI table | `Table2` from `velocis/table2` |
|
|
22
|
+
| Dialog / popup / anchored | `Dialog1` from `velocis/dialog1` |
|
|
23
|
+
| Action menu | `Dropdown1` from `velocis/dropdown1` |
|
|
24
|
+
| Card UI | `Card` from `velocis/card` |
|
|
25
|
+
| Landing hero | `HeroCentered` from `velocis/hero/centered` |
|
|
26
|
+
| Item list | `ListView` from `velocis/list` |
|
|
27
|
+
| Loading state | `LoadingState` from `velocis/feedback` |
|
|
28
|
+
| Form | `FormRoot`, `FormField` from `velocis/forms` |
|
|
29
|
+
| Tabs / nav | `Tabs`, `Navbar` from `velocis/navigation` |
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# velocis
|
|
2
|
+
|
|
3
|
+
Meta package — publishes all Velocis UI modules under subpath imports.
|
|
4
|
+
|
|
5
|
+
## Consumer imports
|
|
6
|
+
|
|
7
|
+
| Subpath | Module |
|
|
8
|
+
|---------|--------|
|
|
9
|
+
| `velocis` | Everything (core + all components) |
|
|
10
|
+
| `velocis/theme` | Providers & tokens |
|
|
11
|
+
| `velocis/card` | Card |
|
|
12
|
+
| `velocis/hero` | Hero variants |
|
|
13
|
+
| `velocis/hero/centered` | Single hero (tree-shaken) |
|
|
14
|
+
| `velocis/table` | Tables |
|
|
15
|
+
| `velocis/list` | Lists |
|
|
16
|
+
| `velocis/feedback` | States & overlays |
|
|
17
|
+
| `velocis/forms` | Forms |
|
|
18
|
+
| `velocis/navigation` | Navigation |
|
|
19
|
+
| `velocis/styles.css` | Pre-built CSS |
|
|
20
|
+
| `velocis/tailwind-preset` | Tailwind preset |
|
|
21
|
+
|
|
22
|
+
Full documentation: [docs/README.md](../../docs/README.md) · [AGENTS.md](../../AGENTS.md) (AI agent reference)
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import 'velocis/styles.css';
|
|
28
|
+
import { VelocisProvider, DirectionProvider } from 'velocis/theme';
|
|
29
|
+
import { Card } from 'velocis/card';
|
|
30
|
+
import { Table } from 'velocis/table';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Prefer subpath imports over `import { … } from 'velocis'` for smaller bundles.
|
package/dist/card.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from '@velocis/card';
|
|
2
|
+
import '@velocis/dialog1';
|
|
3
|
+
import '@velocis/dropdown1';
|
|
2
4
|
import '@velocis/feedback';
|
|
3
5
|
import '@velocis/forms';
|
|
4
6
|
import '@velocis/hero';
|
|
@@ -7,4 +9,5 @@ import '@velocis/theme';
|
|
|
7
9
|
import '@velocis/table';
|
|
8
10
|
import '@velocis/list';
|
|
9
11
|
import '@velocis/navigation';
|
|
12
|
+
import '@velocis/table2';
|
|
10
13
|
import '@velocis/theme/tailwind-preset';
|
package/dist/card.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from '@velocis/card';
|
|
2
|
+
import '@velocis/dialog1';
|
|
3
|
+
import '@velocis/dropdown1';
|
|
2
4
|
import '@velocis/feedback';
|
|
3
5
|
import '@velocis/forms';
|
|
4
6
|
import '@velocis/hero';
|
|
@@ -7,4 +9,5 @@ import '@velocis/theme';
|
|
|
7
9
|
import '@velocis/table';
|
|
8
10
|
import '@velocis/list';
|
|
9
11
|
import '@velocis/navigation';
|
|
12
|
+
import '@velocis/table2';
|
|
10
13
|
import '@velocis/theme/tailwind-preset';
|
package/dist/dialog1.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/dialog1.ts
|
|
18
|
+
var dialog1_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(dialog1_exports);
|
|
20
|
+
__reExport(dialog1_exports, require("@velocis/dialog1"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@velocis/dialog1")
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@velocis/dialog1';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@velocis/dialog1';
|
package/dist/dialog1.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/dropdown1.ts
|
|
18
|
+
var dropdown1_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(dropdown1_exports);
|
|
20
|
+
__reExport(dropdown1_exports, require("@velocis/dropdown1"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@velocis/dropdown1")
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@velocis/dropdown1';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@velocis/dropdown1';
|
package/dist/table2.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/table2.ts
|
|
18
|
+
var table2_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(table2_exports);
|
|
20
|
+
__reExport(table2_exports, require("@velocis/table2"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("@velocis/table2")
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@velocis/table2';
|
package/dist/table2.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@velocis/table2';
|
package/dist/table2.js
ADDED
package/docs/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Velocis Documentation
|
|
2
|
+
|
|
3
|
+
Reference for developers and AI agents integrating the `velocis` React UI library.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install velocis
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Required setup
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
// app/layout.tsx
|
|
15
|
+
import 'velocis/styles.css';
|
|
16
|
+
import { VelocisProvider, DirectionProvider } from 'velocis/theme';
|
|
17
|
+
|
|
18
|
+
export default function RootLayout({ children }) {
|
|
19
|
+
return (
|
|
20
|
+
<html lang="en">
|
|
21
|
+
<body>
|
|
22
|
+
<VelocisProvider theme="system">
|
|
23
|
+
<DirectionProvider direction="ltr">{children}</DirectionProvider>
|
|
24
|
+
</VelocisProvider>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Import rules
|
|
32
|
+
|
|
33
|
+
| Context | Import from | Example |
|
|
34
|
+
|---------|-------------|---------|
|
|
35
|
+
| External app (npm) | `velocis/...` subpaths | `import { Table } from 'velocis/table'` |
|
|
36
|
+
| Monorepo internal | `@velocis/...` packages | `import { Table } from '@velocis/table'` |
|
|
37
|
+
| Everything at once | `velocis` | `import { Table, Card } from 'velocis'` |
|
|
38
|
+
|
|
39
|
+
Prefer subpath imports (`velocis/table`, `velocis/card`, …) for smaller bundles.
|
|
40
|
+
|
|
41
|
+
## Module index
|
|
42
|
+
|
|
43
|
+
| Module | Import path | Doc |
|
|
44
|
+
|--------|-------------|-----|
|
|
45
|
+
| Theme & providers | `velocis/theme` | [theme.md](./theme.md) |
|
|
46
|
+
| Card | `velocis/card` | [card.md](./card.md) |
|
|
47
|
+
| Hero sections | `velocis/hero`, `velocis/hero/centered` | [hero.md](./hero.md) |
|
|
48
|
+
| Tables | `velocis/table` | [table.md](./table.md) |
|
|
49
|
+
| Custom tables | `velocis/table2` | [table2.md](./table2.md) |
|
|
50
|
+
| Dialogs & popovers | `velocis/dialog1` | [dialog1.md](./dialog1.md) |
|
|
51
|
+
| Action menus | `velocis/dropdown1` | [dropdown1.md](./dropdown1.md) |
|
|
52
|
+
| Lists | `velocis/list` | [list.md](./list.md) |
|
|
53
|
+
| Feedback & overlays | `velocis/feedback` | [feedback.md](./feedback.md) |
|
|
54
|
+
| Forms | `velocis/forms` | [forms.md](./forms.md) |
|
|
55
|
+
| Navigation | `velocis/navigation` | [navigation.md](./navigation.md) |
|
|
56
|
+
| Primitives & hooks | `velocis` (core re-export) | [core.md](./core.md) |
|
|
57
|
+
|
|
58
|
+
## Quick component picker
|
|
59
|
+
|
|
60
|
+
| Need | Use |
|
|
61
|
+
|------|-----|
|
|
62
|
+
| Landing page header | `HeroCentered`, `HeroSplitImage`, … → [hero.md](./hero.md) |
|
|
63
|
+
| Content container | `Card` → [card.md](./card.md) |
|
|
64
|
+
| Data grid | `Table`, `Table.Paginated`, `Table.Tree` → [table.md](./table.md) |
|
|
65
|
+
| Custom UI table | `Table2`, `useTable2Selection` → [table2.md](./table2.md) |
|
|
66
|
+
| Item list | `ListView`, `ListView.Avatar`, `ListView.Kanban` → [list.md](./list.md) |
|
|
67
|
+
| Loading / empty / error | `LoadingState`, `EmptyState`, `ErrorFallback` → [feedback.md](./feedback.md) |
|
|
68
|
+
| Modal / toast / alert | `Modal`, `useToast`, `Alert` → [feedback.md](./feedback.md) |
|
|
69
|
+
| Anchored dialog / popover | `Dialog1`, `useDialog1Anchor` → [dialog1.md](./dialog1.md) |
|
|
70
|
+
| Action menu / nested menu | `Dropdown1` → [dropdown1.md](./dropdown1.md) |
|
|
71
|
+
| Form with fields | `FormRoot`, `FormField`, `FormSelect` → [forms.md](./forms.md) |
|
|
72
|
+
| Tabs / navbar / sidebar | `Tabs`, `Navbar`, `Sidebar` → [navigation.md](./navigation.md) |
|
|
73
|
+
| RTL / dark mode | `VelocisProvider`, `DirectionProvider` → [theme.md](./theme.md) |
|
|
74
|
+
|
|
75
|
+
## Styles
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import 'velocis/styles.css'; // pre-built CSS (recommended)
|
|
79
|
+
// or Tailwind v4:
|
|
80
|
+
import 'velocis/tailwind-v4.css';
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## CSS / Tailwind preset
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
// tailwind.config.js
|
|
87
|
+
import velocisPreset from 'velocis/tailwind-preset';
|
|
88
|
+
export default { presets: [velocisPreset] };
|
|
89
|
+
```
|
package/docs/card.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Card (`velocis/card`)
|
|
2
|
+
|
|
3
|
+
Flexible card container with variants and compound subcomponents.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Card, CardSkeleton, cardVariants, CARD_DEFAULT_PROPS } from 'velocis/card';
|
|
9
|
+
import type { CardProps, CardVariantProps } from 'velocis/card';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Basic usage
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
<Card variant="glass" size="lg" interactive="hoverLift">
|
|
16
|
+
<Card.Header title="Title" description="Subtitle" />
|
|
17
|
+
<Card.Body>Content here</Card.Body>
|
|
18
|
+
<Card.Footer>Actions</Card.Footer>
|
|
19
|
+
</Card>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Variants
|
|
23
|
+
|
|
24
|
+
| `variant` | Description |
|
|
25
|
+
|-----------|-------------|
|
|
26
|
+
| `elevated` | Default, shadow + border |
|
|
27
|
+
| `outline` | Border only, no shadow |
|
|
28
|
+
| `glass` | Frosted glass / backdrop blur |
|
|
29
|
+
| `gradient` | Subtle gradient background |
|
|
30
|
+
| `minimal` | Transparent, no border |
|
|
31
|
+
| `neumorphic` | Soft embossed look |
|
|
32
|
+
| `borderedAccent` | Left accent border |
|
|
33
|
+
|
|
34
|
+
## Sizes
|
|
35
|
+
|
|
36
|
+
`sm` | `md` (default) | `lg` | `xl`
|
|
37
|
+
|
|
38
|
+
## Interactive modes
|
|
39
|
+
|
|
40
|
+
| `interactive` | Behavior |
|
|
41
|
+
|---------------|----------|
|
|
42
|
+
| `false` | Static (default) |
|
|
43
|
+
| `hoverLift` | Lifts on hover |
|
|
44
|
+
| `pressable` | Scale-down on press |
|
|
45
|
+
|
|
46
|
+
## Compound subcomponents
|
|
47
|
+
|
|
48
|
+
| Component | Purpose |
|
|
49
|
+
|-----------|---------|
|
|
50
|
+
| `Card.Header` | Title + description |
|
|
51
|
+
| `Card.Media` | Image or media slot |
|
|
52
|
+
| `Card.Body` | Main content |
|
|
53
|
+
| `Card.Footer` | Footer actions |
|
|
54
|
+
| `Card.Badge` | Corner badge |
|
|
55
|
+
| `Card.Actions` | Action button row |
|
|
56
|
+
| `Card.Collapse` | Expandable section |
|
|
57
|
+
| `Card.Grid` | Card grid layout |
|
|
58
|
+
| `Card.Selectable` | Selectable card state |
|
|
59
|
+
| `Card.Skeleton` | Loading placeholder |
|
|
60
|
+
|
|
61
|
+
## Props (root)
|
|
62
|
+
|
|
63
|
+
| Prop | Type | Description |
|
|
64
|
+
|------|------|-------------|
|
|
65
|
+
| `variant` | see variants | Visual style |
|
|
66
|
+
| `size` | `sm \| md \| lg \| xl` | Padding scale |
|
|
67
|
+
| `interactive` | `false \| hoverLift \| pressable` | Hover/press behavior |
|
|
68
|
+
| `isLoading` | `boolean` | Shows `CardSkeleton` |
|
|
69
|
+
| `asChild` | `boolean` | Merge props onto child |
|
|
70
|
+
| `renderHeader` | `() => ReactNode` | Custom header slot |
|
|
71
|
+
| `renderFooter` | `() => ReactNode` | Custom footer slot |
|
|
72
|
+
|
|
73
|
+
## When to use
|
|
74
|
+
|
|
75
|
+
- Display grouped content, dashboards, product tiles.
|
|
76
|
+
- Use `variant="glass"` for overlays on images.
|
|
77
|
+
- Use `isLoading` while fetching card data.
|
package/docs/core.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Core (via `velocis`)
|
|
2
|
+
|
|
3
|
+
Primitives, hooks, and utilities. Re-exported from the main `velocis` package (source: `@velocis/core`).
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
// External apps
|
|
9
|
+
import { Box, Flex, cn, useDirection, useAsyncData } from 'velocis';
|
|
10
|
+
|
|
11
|
+
// Monorepo
|
|
12
|
+
import { Box, Flex, cn } from '@velocis/core';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Layout primitives
|
|
16
|
+
|
|
17
|
+
| Component | Purpose |
|
|
18
|
+
|-----------|---------|
|
|
19
|
+
| `Box` | Generic container |
|
|
20
|
+
| `Flex` | Flexbox layout |
|
|
21
|
+
| `Grid` | CSS grid layout |
|
|
22
|
+
| `Stack` | Vertical/horizontal stack |
|
|
23
|
+
| `Container` | Max-width page container |
|
|
24
|
+
| `Spacer` | Flexible space |
|
|
25
|
+
| `Divider` | Horizontal/vertical rule |
|
|
26
|
+
| `AspectRatio` | Fixed aspect ratio box |
|
|
27
|
+
| `Text` | Typography wrapper |
|
|
28
|
+
| `VisuallyHidden` | Screen-reader-only content |
|
|
29
|
+
| `Icon` | Icon wrapper |
|
|
30
|
+
| `Portal` | Render outside DOM hierarchy |
|
|
31
|
+
| `Overlay` | Full-screen overlay |
|
|
32
|
+
| `Avatar` | User avatar |
|
|
33
|
+
| `SkipLink` | Accessibility skip link |
|
|
34
|
+
| `Slot` | Merge props onto child element |
|
|
35
|
+
|
|
36
|
+
## Hooks
|
|
37
|
+
|
|
38
|
+
| Hook | Purpose |
|
|
39
|
+
|------|---------|
|
|
40
|
+
| `useDirection` | Current `ltr` / `rtl` from context |
|
|
41
|
+
| `useMergedClassNames` | Merge class name strings |
|
|
42
|
+
| `useAsyncData` | Fetch paginated async data (`DataSource`) |
|
|
43
|
+
| `useVirtualizer` | Virtual scroll calculations |
|
|
44
|
+
| `useIdSafe` | SSR-safe unique ids |
|
|
45
|
+
| `useReducedMotion` | Respect `prefers-reduced-motion` |
|
|
46
|
+
| `useFocusTrap` | Trap focus in modal |
|
|
47
|
+
| `useUndoRedo` | Undo/redo state stack |
|
|
48
|
+
|
|
49
|
+
## Utilities
|
|
50
|
+
|
|
51
|
+
| Export | Purpose |
|
|
52
|
+
|--------|---------|
|
|
53
|
+
| `cn` | Merge Tailwind classes |
|
|
54
|
+
| `rtl` helpers | RTL-aware positioning |
|
|
55
|
+
| `responsive` helpers | Breakpoint utilities |
|
|
56
|
+
| `VelocisError` | Library error type |
|
|
57
|
+
|
|
58
|
+
## Async data (for tables)
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { useAsyncData } from 'velocis';
|
|
62
|
+
|
|
63
|
+
const { data, status, error, refetch, total } = useAsyncData({
|
|
64
|
+
dataSource: mySource,
|
|
65
|
+
params: { page: 1, pageSize: 10 },
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Used internally by `PaginatedTable`. Status values: `'loading' | 'empty' | 'error' | 'success'`.
|
|
70
|
+
|
|
71
|
+
## When to use
|
|
72
|
+
|
|
73
|
+
- Build custom layouts not covered by Card, List, or Navigation.
|
|
74
|
+
- Use `cn` everywhere you compose Tailwind classes with Velocis components.
|
|
75
|
+
- Use `useAsyncData` when building custom data views with the same pattern as `Table.Paginated`.
|
package/docs/dialog1.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Dialog1 (`velocis/dialog1`)
|
|
2
|
+
|
|
3
|
+
Highly flexible dialogs: centered modal, popover anchored to a trigger, and side anchored panel — with full RTL/LTR support and CSS customization at every layer.
|
|
4
|
+
|
|
5
|
+
Use **Dialog1** for anchored popups and custom dialog layouts. Use [`velocis/feedback`](./feedback.md) `Modal` for simple centered confirmations.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
'use client';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
Dialog1,
|
|
14
|
+
useDialog1,
|
|
15
|
+
useDialog1Anchor,
|
|
16
|
+
useAlertDialog,
|
|
17
|
+
dialog1Styles,
|
|
18
|
+
} from 'velocis/dialog1';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## When to use
|
|
22
|
+
|
|
23
|
+
| Scenario | Use |
|
|
24
|
+
|----------|-----|
|
|
25
|
+
| Centered popup / form | `variant="modal"` |
|
|
26
|
+
| Menu / dropdown beside button | `variant="popover"` + `useDialog1Anchor` |
|
|
27
|
+
| Side panel beside trigger | `variant="anchored"` |
|
|
28
|
+
| Quick alert | `useAlertDialog` or `Dialog1.Alert` |
|
|
29
|
+
| Simple confirmation | `Modal` from [`velocis/feedback`](./feedback.md) |
|
|
30
|
+
|
|
31
|
+
## Variants
|
|
32
|
+
|
|
33
|
+
| Variant | Behavior |
|
|
34
|
+
|---------|----------|
|
|
35
|
+
| `modal` | Centered overlay, body scroll lock, focus trap |
|
|
36
|
+
| `popover` | Fixed panel below/near anchor, viewport clamping |
|
|
37
|
+
| `anchored` | Full-height side panel beside anchor |
|
|
38
|
+
|
|
39
|
+
## Quick setup — modal
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
const { show, dialogProps } = useDialog1();
|
|
43
|
+
|
|
44
|
+
<button onClick={show}>Open</button>
|
|
45
|
+
<Dialog1 {...dialogProps}>
|
|
46
|
+
<Dialog1.Content>
|
|
47
|
+
<Dialog1.Header>
|
|
48
|
+
<Dialog1.Title>Title</Dialog1.Title>
|
|
49
|
+
</Dialog1.Header>
|
|
50
|
+
<p>Content here</p>
|
|
51
|
+
<Dialog1.Close onClose={() => dialogProps.onOpenChange(false)} />
|
|
52
|
+
</Dialog1.Content>
|
|
53
|
+
</Dialog1>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick setup — popover (anchored to button)
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const { open, setOpen, anchorRef, dialogProps } = useDialog1Anchor({
|
|
60
|
+
variant: 'popover',
|
|
61
|
+
placement: 'bottom-start',
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
<button ref={anchorRef} onClick={() => setOpen(true)}>Menu</button>
|
|
65
|
+
<Dialog1 {...dialogProps} anchorRef={anchorRef}>
|
|
66
|
+
<Dialog1.Content className="p-4">
|
|
67
|
+
<p>Popover content</p>
|
|
68
|
+
</Dialog1.Content>
|
|
69
|
+
</Dialog1>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Quick setup — anchored side panel
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
const { anchorRef, dialogProps, setOpen } = useDialog1Anchor({
|
|
76
|
+
variant: 'anchored',
|
|
77
|
+
anchoredWidthPx: 320,
|
|
78
|
+
anchoredTop: '20%',
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
<button ref={anchorRef} onClick={() => setOpen(true)}>Filters</button>
|
|
82
|
+
<Dialog1 {...dialogProps} anchorRef={anchorRef}>
|
|
83
|
+
<Dialog1.Content>...</Dialog1.Content>
|
|
84
|
+
</Dialog1>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Alert dialog
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
const { show, AlertDialog } = useAlertDialog({
|
|
91
|
+
title: 'تنبيه',
|
|
92
|
+
description: 'هل أنت متأكد؟',
|
|
93
|
+
confirmLabel: 'حسناً',
|
|
94
|
+
dir: 'rtl',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
<button onClick={show}>Show alert</button>
|
|
98
|
+
{AlertDialog}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## RTL / LTR
|
|
102
|
+
|
|
103
|
+
- Default direction from `DirectionProvider` (`useDirection`)
|
|
104
|
+
- Override per dialog: `dir="rtl"` or `dir="ltr"`
|
|
105
|
+
- `placement` is **logical**: `bottom-start` = below + inline-start (right in RTL, left in LTR)
|
|
106
|
+
- `Dialog1Close` positions on logical start side
|
|
107
|
+
- Mixed content: set `dir` on subcomponents independently
|
|
108
|
+
|
|
109
|
+
## CSS customization
|
|
110
|
+
|
|
111
|
+
### Level 1 — root props
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
<Dialog1
|
|
115
|
+
rootClassName="..."
|
|
116
|
+
backdropClassName="bg-black/50"
|
|
117
|
+
panelClassName="rounded-3xl shadow-xl"
|
|
118
|
+
panelStyle={{ zoom: 0.95 }}
|
|
119
|
+
/>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Level 2 — subcomponents
|
|
123
|
+
|
|
124
|
+
Every subcomponent accepts `className` + native HTML attributes:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
<Dialog1.Header className="bg-velocis-background px-6" />
|
|
128
|
+
<Dialog1.Title className="text-3xl" />
|
|
129
|
+
<Dialog1.Footer className="justify-between" />
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Level 3 — presets
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import { dialog1Styles, cardPanelStyles } from 'velocis/dialog1';
|
|
136
|
+
import { cn } from 'velocis';
|
|
137
|
+
|
|
138
|
+
<Dialog1 panelClassName={cn(dialog1Styles.panel, cardPanelStyles.panel)} />
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Compound API
|
|
142
|
+
|
|
143
|
+
| Property | Component |
|
|
144
|
+
|----------|-----------|
|
|
145
|
+
| `Dialog1` | Root |
|
|
146
|
+
| `Dialog1.Content` | Scrollable body wrapper |
|
|
147
|
+
| `Dialog1.Header` | Header slot |
|
|
148
|
+
| `Dialog1.Title` | Title heading |
|
|
149
|
+
| `Dialog1.Description` | Description text |
|
|
150
|
+
| `Dialog1.Footer` | Footer actions |
|
|
151
|
+
| `Dialog1.Close` | Close button (logical position) |
|
|
152
|
+
| `Dialog1.Alert` | Pre-built alert modal |
|
|
153
|
+
|
|
154
|
+
## Props reference (`Dialog1`)
|
|
155
|
+
|
|
156
|
+
| Prop | Type | Default | Description |
|
|
157
|
+
|------|------|---------|-------------|
|
|
158
|
+
| `open` | `boolean` | — | Controlled open state |
|
|
159
|
+
| `onOpenChange` | `(open) => void` | — | State callback |
|
|
160
|
+
| `variant` | `modal \| popover \| anchored` | `modal` | Display mode |
|
|
161
|
+
| `anchorRef` | `RefObject<HTMLElement>` | — | Trigger element |
|
|
162
|
+
| `getAnchorElement` | `() => HTMLElement \| null` | — | Dynamic anchor resolver |
|
|
163
|
+
| `placement` | `bottom-start \| bottom-end \| top-start \| top-end` | `bottom-start` | Popover placement |
|
|
164
|
+
| `offset` | `number` | `8` | Gap from anchor (px) |
|
|
165
|
+
| `maxWidth` | `string` | `max-w-4xl` | Tailwind max-width class |
|
|
166
|
+
| `elevated` | `boolean` | `false` | Higher z-index layer |
|
|
167
|
+
| `dir` | `rtl \| ltr` | from provider | Text direction |
|
|
168
|
+
| `popoverMaxWidthPx` | `number` | `288` | Popover width cap |
|
|
169
|
+
| `anchoredTop` | `string` | `30%` | Anchored panel top offset |
|
|
170
|
+
| `anchoredWidthPx` | `number` | `300` | Anchored panel width |
|
|
171
|
+
|
|
172
|
+
## vs `velocis/feedback`
|
|
173
|
+
|
|
174
|
+
| | `Modal` / `Popover` | `Dialog1` |
|
|
175
|
+
|--|---------------------|-----------|
|
|
176
|
+
| Modes | Centered / basic popover | modal + popover + anchored |
|
|
177
|
+
| Anchor | Internal trigger only | `anchorRef` + `getAnchorElement` |
|
|
178
|
+
| Positioning | Static | Placement + clamp + scroll sync |
|
|
179
|
+
| CSS | Single `className` | Slots on every layer |
|
|
180
|
+
| Setup | Manual props | `useDialog1`, `useDialog1Anchor` |
|