nuxt-ui-elements 0.1.40 → 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/README.md +6 -191
- package/dist/module.json +1 -1
- package/dist/module.mjs +233 -3
- package/dist/runtime/components/DialogAlert.vue +1 -1
- package/dist/runtime/components/DialogConfirm.vue +1 -1
- package/dist/runtime/components/Flow.d.vue.ts +77 -0
- package/dist/runtime/components/Flow.vue +99 -0
- package/dist/runtime/components/Flow.vue.d.ts +77 -0
- package/dist/runtime/components/FlowHandle.d.vue.ts +22 -0
- package/dist/runtime/components/FlowHandle.vue +33 -0
- package/dist/runtime/components/FlowHandle.vue.d.ts +22 -0
- package/dist/runtime/components/FlowNode.d.vue.ts +26 -0
- package/dist/runtime/components/FlowNode.vue +39 -0
- package/dist/runtime/components/FlowNode.vue.d.ts +26 -0
- package/dist/runtime/components/ToggleGroup.vue +1 -1
- package/dist/runtime/components/flow/FlowBackground.d.vue.ts +21 -0
- package/dist/runtime/components/flow/FlowBackground.vue +39 -0
- package/dist/runtime/components/flow/FlowBackground.vue.d.ts +21 -0
- package/dist/runtime/components/flow/FlowControls.d.vue.ts +29 -0
- package/dist/runtime/components/flow/FlowControls.vue +37 -0
- package/dist/runtime/components/flow/FlowControls.vue.d.ts +29 -0
- package/dist/runtime/components/flow/FlowMiniMap.d.vue.ts +37 -0
- package/dist/runtime/components/flow/FlowMiniMap.vue +51 -0
- package/dist/runtime/components/flow/FlowMiniMap.vue.d.ts +37 -0
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/types/index.d.ts +6 -0
- package/dist/runtime/types/index.js +6 -0
- package/dist/runtime/utils/std.d.ts +1 -0
- package/dist/runtime/utils/std.js +1 -0
- package/package.json +26 -8
package/README.md
CHANGED
|
@@ -7,11 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
**A growing collection of components and utilities that extend [@nuxt/ui](https://ui.nuxt.com) with enhanced functionality.**
|
|
9
9
|
|
|
10
|
-
This module extends Nuxt UI with additional components and utilities designed to integrate with Nuxt UI's design system.
|
|
11
|
-
|
|
12
10
|
> **Early Development Notice**: This project is in early development. APIs, component interfaces, and utilities are subject to change in future releases. Please use with caution in production environments.
|
|
13
11
|
|
|
14
|
-
- [
|
|
12
|
+
- [Release Notes](/CHANGELOG.md)
|
|
15
13
|
|
|
16
14
|
## Features
|
|
17
15
|
|
|
@@ -26,20 +24,15 @@ This module extends Nuxt UI with additional components and utilities designed to
|
|
|
26
24
|
|
|
27
25
|
This module requires [@nuxt/ui](https://ui.nuxt.com) v4.0.0 or higher.
|
|
28
26
|
|
|
29
|
-
##
|
|
27
|
+
## Quick Setup
|
|
28
|
+
|
|
29
|
+
Install the module:
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
# pnpm
|
|
33
32
|
pnpm add nuxt-ui-elements
|
|
34
|
-
|
|
35
|
-
# npm
|
|
36
|
-
npm install nuxt-ui-elements
|
|
37
|
-
|
|
38
|
-
# yarn
|
|
39
|
-
yarn add nuxt-ui-elements
|
|
40
33
|
```
|
|
41
34
|
|
|
42
|
-
Add
|
|
35
|
+
Add it to your `nuxt.config.ts`:
|
|
43
36
|
|
|
44
37
|
```typescript
|
|
45
38
|
export default defineNuxtConfig({
|
|
@@ -55,188 +48,10 @@ Import the module's CSS in your main CSS file (e.g., `assets/css/main.css`):
|
|
|
55
48
|
@import "nuxt-ui-elements";
|
|
56
49
|
```
|
|
57
50
|
|
|
58
|
-
That's it!
|
|
51
|
+
That's it! Components and composables are automatically available in your Nuxt app.
|
|
59
52
|
|
|
60
53
|
> **Note:** The CSS import is required for Tailwind v4 to properly scan and generate styles from the component themes.
|
|
61
54
|
|
|
62
|
-
## Usage
|
|
63
|
-
|
|
64
|
-
Components and composables are automatically imported. Standard utilities (`#std`) are available via explicit imports.
|
|
65
|
-
|
|
66
|
-
### Dialog Components
|
|
67
|
-
|
|
68
|
-
The module provides two dialog components via the `useDialog` composable: Alert and Confirm dialogs.
|
|
69
|
-
|
|
70
|
-
#### Alert Dialog
|
|
71
|
-
|
|
72
|
-
Display informational messages to users:
|
|
73
|
-
|
|
74
|
-
```vue
|
|
75
|
-
<script setup>
|
|
76
|
-
const { alert } = useDialog()
|
|
77
|
-
|
|
78
|
-
function showAlert() {
|
|
79
|
-
alert({
|
|
80
|
-
title: 'Success!',
|
|
81
|
-
description: 'Your changes have been saved.',
|
|
82
|
-
icon: 'i-lucide-check-circle',
|
|
83
|
-
label: 'Got it',
|
|
84
|
-
color: 'success'
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
</script>
|
|
88
|
-
|
|
89
|
-
<template>
|
|
90
|
-
<UButton @click="showAlert">Show Alert</UButton>
|
|
91
|
-
</template>
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
**Alert Dialog API:**
|
|
95
|
-
|
|
96
|
-
| Property | Type | Default | Description |
|
|
97
|
-
|----------|------|---------|-------------|
|
|
98
|
-
| `title` | `string` | `''` | Dialog title |
|
|
99
|
-
| `description` | `string` | `''` | Dialog description/message |
|
|
100
|
-
| `icon` | `string` | `undefined` | Icon name (e.g., 'i-lucide-info') |
|
|
101
|
-
| `label` | `string` | `'Ok'` | Dismiss button label |
|
|
102
|
-
| `color` | `'primary' \| 'secondary' \| 'success' \| 'info' \| 'warning' \| 'error' \| 'neutral'` | `'neutral'` | Color theme |
|
|
103
|
-
| `variant` | `'solid' \| 'outline'` | `'solid'` | Dialog variant |
|
|
104
|
-
| `onDismiss` | `() => void \| Promise<void>` | `() => {}` | Callback when dismissed |
|
|
105
|
-
| `ui` | `object` | `{}` | Custom UI classes override |
|
|
106
|
-
|
|
107
|
-
#### Confirm Dialog
|
|
108
|
-
|
|
109
|
-
Request user confirmation with async support:
|
|
110
|
-
|
|
111
|
-
```vue
|
|
112
|
-
<script setup>
|
|
113
|
-
const { confirm } = useDialog()
|
|
114
|
-
|
|
115
|
-
async function handleDelete() {
|
|
116
|
-
confirm({
|
|
117
|
-
title: 'Delete Item',
|
|
118
|
-
description: 'Are you sure? This action cannot be undone.',
|
|
119
|
-
confirmLabel: 'Delete',
|
|
120
|
-
dismissLabel: 'Cancel',
|
|
121
|
-
color: 'error',
|
|
122
|
-
onConfirm: async () => {
|
|
123
|
-
// Async operations are supported
|
|
124
|
-
await deleteItem()
|
|
125
|
-
// Dialog shows loading state and success feedback automatically
|
|
126
|
-
},
|
|
127
|
-
onDismiss: () => {
|
|
128
|
-
console.log('User cancelled')
|
|
129
|
-
}
|
|
130
|
-
})
|
|
131
|
-
}
|
|
132
|
-
</script>
|
|
133
|
-
|
|
134
|
-
<template>
|
|
135
|
-
<UButton @click="handleDelete">Delete</UButton>
|
|
136
|
-
</template>
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
**Confirm Dialog API:**
|
|
140
|
-
|
|
141
|
-
| Property | Type | Default | Description |
|
|
142
|
-
|----------|------|---------|-------------|
|
|
143
|
-
| `title` | `string` | `''` | Dialog title |
|
|
144
|
-
| `description` | `string` | `''` | Dialog description/message |
|
|
145
|
-
| `icon` | `boolean` | `true` | Show icon (auto-selected based on color) |
|
|
146
|
-
| `confirmLabel` | `string` | `'Yes'` | Confirm button label |
|
|
147
|
-
| `dismissLabel` | `string` | `'No'` | Dismiss button label |
|
|
148
|
-
| `color` | `'primary' \| 'secondary' \| 'success' \| 'info' \| 'warning' \| 'error' \| 'neutral'` | `'neutral'` | Color theme |
|
|
149
|
-
| `variant` | `'solid' \| 'outline'` | `'solid'` | Dialog variant |
|
|
150
|
-
| `close` | `boolean` | `false` | Show close button in header |
|
|
151
|
-
| `onConfirm` | `() => void \| Promise<void>` | `() => {}` | Callback when confirmed (supports async) |
|
|
152
|
-
| `onDismiss` | `() => void \| Promise<void>` | `() => {}` | Callback when dismissed |
|
|
153
|
-
| `ui` | `object` | `{}` | Custom UI classes override |
|
|
154
|
-
|
|
155
|
-
**Async Support**: When `onConfirm` returns a Promise, the dialog automatically shows loading state and displays success/error feedback before closing.
|
|
156
|
-
|
|
157
|
-
## Standard Utilities (`#std`)
|
|
158
|
-
|
|
159
|
-
The module provides tree-shakeable utility functions via the `#std` alias. These are **not** auto-imported and must be explicitly imported.
|
|
160
|
-
|
|
161
|
-
### Date Utilities
|
|
162
|
-
|
|
163
|
-
Comprehensive date manipulation built on `@internationalized/date`. Import the entire module or individual functions:
|
|
164
|
-
|
|
165
|
-
```typescript
|
|
166
|
-
import std from '#std'
|
|
167
|
-
|
|
168
|
-
const nextMonth = std.date.add(std.date.today(), 1, 'month')
|
|
169
|
-
const formatted = std.date.format(new Date(), 'YYYY-MM-DD')
|
|
170
|
-
|
|
171
|
-
// Or import individual functions
|
|
172
|
-
import { add, format, today, relative } from '#std/date'
|
|
173
|
-
|
|
174
|
-
// Add/subtract time
|
|
175
|
-
const nextMonth = add(today(), 1, 'month')
|
|
176
|
-
const lastWeek = subtract(new Date(), 7, 'day')
|
|
177
|
-
|
|
178
|
-
// Format dates (Day.js-compatible tokens)
|
|
179
|
-
format(new Date(), 'YYYY-MM-DD') // "2024-01-15"
|
|
180
|
-
format(new Date(), 'MMMM D, YYYY') // "January 15, 2024"
|
|
181
|
-
format(new Date(), 'MMM DD, YYYY h:mm A') // "Jan 15, 2024 3:30 PM"
|
|
182
|
-
|
|
183
|
-
// Relative time
|
|
184
|
-
relative(someDate) // "2 days ago" or "in 3 months"
|
|
185
|
-
|
|
186
|
-
// Date comparisons
|
|
187
|
-
isBefore(date1, date2)
|
|
188
|
-
isAfter(date1, date2)
|
|
189
|
-
isSame(date1, date2)
|
|
190
|
-
isBetween(date, startDate, endDate)
|
|
191
|
-
|
|
192
|
-
// Date manipulation
|
|
193
|
-
set(someDate, { day: 15, month: 3 })
|
|
194
|
-
startOf(someDate, 'month')
|
|
195
|
-
endOf(someDate, 'week')
|
|
196
|
-
|
|
197
|
-
// Calculate differences
|
|
198
|
-
diff(date1, date2, 'days') // number of days between dates
|
|
199
|
-
|
|
200
|
-
// Conversions
|
|
201
|
-
toDate(dateValue) // Convert to JavaScript Date
|
|
202
|
-
asCalendarDate(date) // Date without time
|
|
203
|
-
asCalendarDateTime(date) // Date with time, no timezone
|
|
204
|
-
asZonedDateTime(date, 'UTC') // Date with timezone
|
|
205
|
-
|
|
206
|
-
// Utilities
|
|
207
|
-
today() // Current date
|
|
208
|
-
now() // Current date and time
|
|
209
|
-
parse('2024-01-15') // Parse date string
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
**Available Functions:**
|
|
213
|
-
|
|
214
|
-
| Function | Description |
|
|
215
|
-
|----------|-------------|
|
|
216
|
-
| `add(date, amount, unit)` | Add time to a date |
|
|
217
|
-
| `subtract(date, amount, unit)` | Subtract time from a date |
|
|
218
|
-
| `set(date, values)` | Set specific date/time values |
|
|
219
|
-
| `format(date, formatString, locale?)` | Format date with Day.js tokens |
|
|
220
|
-
| `relative(date, locale?)` | Get relative time string |
|
|
221
|
-
| `toDate(input, timeZone?)` | Convert to JavaScript Date |
|
|
222
|
-
| `asCalendarDate(input)` | Convert to date without time |
|
|
223
|
-
| `asCalendarDateTime(input)` | Convert to date with time |
|
|
224
|
-
| `asZonedDateTime(input, timeZone?)` | Convert to date with timezone |
|
|
225
|
-
| `isBefore(date1, date2)` | Check if date1 is before date2 |
|
|
226
|
-
| `isAfter(date1, date2)` | Check if date1 is after date2 |
|
|
227
|
-
| `isSame(date1, date2)` | Check if dates are equal |
|
|
228
|
-
| `isBetween(date, start, end, inclusive?)` | Check if date is in range |
|
|
229
|
-
| `diff(date1, date2, unit?)` | Calculate difference between dates |
|
|
230
|
-
| `startOf(date, unit, locale?)` | Get start of time period |
|
|
231
|
-
| `endOf(date, unit, locale?)` | Get end of time period |
|
|
232
|
-
| `today(timeZone?)` | Get today's date |
|
|
233
|
-
| `now(timeZone?)` | Get current date and time |
|
|
234
|
-
| `parse(dateString)` | Parse YYYY-MM-DD string |
|
|
235
|
-
|
|
236
|
-
Plus re-exported utilities: `isSameDay`, `isSameMonth`, `isSameYear`, `isToday`, `isWeekend`, `getDayOfWeek`, `getWeeksInMonth`, `getLocalTimeZone`
|
|
237
|
-
|
|
238
|
-
**Tree-shakeable**: All utilities under `#std` are tree-shakeable. Only imported functions will be included in your bundle, whether you import the entire module or individual functions.
|
|
239
|
-
|
|
240
55
|
## Contribution
|
|
241
56
|
|
|
242
57
|
<details>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addTemplate, defineNuxtModule, createResolver, addImportsDir, addComponentsDir } from '@nuxt/kit';
|
|
1
|
+
import { addTemplate, defineNuxtModule, createResolver, addImportsDir, addComponentsDir, tryResolveModule } from '@nuxt/kit';
|
|
2
2
|
import { kebabCase } from 'scule';
|
|
3
3
|
|
|
4
4
|
const dialogConfirm = (options) => ({
|
|
@@ -166,10 +166,222 @@ const toggleGroup = (_options) => ({
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
+
const flow = (_options) => ({
|
|
170
|
+
slots: {
|
|
171
|
+
root: "w-full h-[500px] relative",
|
|
172
|
+
wrapper: ""
|
|
173
|
+
},
|
|
174
|
+
variants: {},
|
|
175
|
+
defaultVariants: {}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const flowNode = (options) => ({
|
|
179
|
+
slots: {
|
|
180
|
+
root: [
|
|
181
|
+
"rounded-lg border px-4 py-3 shadow-sm",
|
|
182
|
+
"transition-all duration-200",
|
|
183
|
+
"min-w-[150px]"
|
|
184
|
+
],
|
|
185
|
+
label: "text-sm font-medium",
|
|
186
|
+
content: "text-xs mt-1 opacity-80"
|
|
187
|
+
},
|
|
188
|
+
variants: {
|
|
189
|
+
color: {
|
|
190
|
+
...Object.fromEntries((options.theme.colors || []).map((color) => [color, ""])),
|
|
191
|
+
neutral: ""
|
|
192
|
+
},
|
|
193
|
+
variant: {
|
|
194
|
+
solid: "",
|
|
195
|
+
outline: "",
|
|
196
|
+
soft: "",
|
|
197
|
+
subtle: ""
|
|
198
|
+
},
|
|
199
|
+
selected: {
|
|
200
|
+
true: {
|
|
201
|
+
root: "ring-2 ring-offset-2 ring-offset-default"
|
|
202
|
+
},
|
|
203
|
+
false: ""
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
compoundVariants: [
|
|
207
|
+
// Solid variants
|
|
208
|
+
...(options.theme.colors || []).map((color) => ({
|
|
209
|
+
color,
|
|
210
|
+
variant: "solid",
|
|
211
|
+
class: {
|
|
212
|
+
root: `bg-${color} text-inverted border-${color}`
|
|
213
|
+
}
|
|
214
|
+
})),
|
|
215
|
+
{
|
|
216
|
+
color: "neutral",
|
|
217
|
+
variant: "solid",
|
|
218
|
+
class: {
|
|
219
|
+
root: "bg-inverted text-inverted border-inverted"
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
// Outline variants
|
|
223
|
+
...(options.theme.colors || []).map((color) => ({
|
|
224
|
+
color,
|
|
225
|
+
variant: "outline",
|
|
226
|
+
class: {
|
|
227
|
+
root: `bg-default border-${color} text-${color}`
|
|
228
|
+
}
|
|
229
|
+
})),
|
|
230
|
+
{
|
|
231
|
+
color: "neutral",
|
|
232
|
+
variant: "outline",
|
|
233
|
+
class: {
|
|
234
|
+
root: "bg-default border-accented text-highlighted"
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
// Soft variants
|
|
238
|
+
...(options.theme.colors || []).map((color) => ({
|
|
239
|
+
color,
|
|
240
|
+
variant: "soft",
|
|
241
|
+
class: {
|
|
242
|
+
root: `bg-${color}/10 border-${color}/20 text-${color}`
|
|
243
|
+
}
|
|
244
|
+
})),
|
|
245
|
+
{
|
|
246
|
+
color: "neutral",
|
|
247
|
+
variant: "soft",
|
|
248
|
+
class: {
|
|
249
|
+
root: "bg-elevated border-accented text-highlighted"
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
// Subtle variants
|
|
253
|
+
...(options.theme.colors || []).map((color) => ({
|
|
254
|
+
color,
|
|
255
|
+
variant: "subtle",
|
|
256
|
+
class: {
|
|
257
|
+
root: `bg-${color}/5 border-transparent text-${color}`
|
|
258
|
+
}
|
|
259
|
+
})),
|
|
260
|
+
{
|
|
261
|
+
color: "neutral",
|
|
262
|
+
variant: "subtle",
|
|
263
|
+
class: {
|
|
264
|
+
root: "bg-elevated/50 border-transparent text-highlighted"
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
// Selected + color ring
|
|
268
|
+
...(options.theme.colors || []).map((color) => ({
|
|
269
|
+
color,
|
|
270
|
+
selected: true,
|
|
271
|
+
class: {
|
|
272
|
+
root: `ring-${color}`
|
|
273
|
+
}
|
|
274
|
+
})),
|
|
275
|
+
{
|
|
276
|
+
color: "neutral",
|
|
277
|
+
selected: true,
|
|
278
|
+
class: {
|
|
279
|
+
root: "ring-accented"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
],
|
|
283
|
+
defaultVariants: {
|
|
284
|
+
color: "primary",
|
|
285
|
+
variant: "outline",
|
|
286
|
+
selected: false
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
const flowHandle = (options) => ({
|
|
291
|
+
slots: {
|
|
292
|
+
root: [
|
|
293
|
+
"!size-3 !rounded-full !border-2 !bg-default",
|
|
294
|
+
"transition-colors duration-150"
|
|
295
|
+
]
|
|
296
|
+
},
|
|
297
|
+
variants: {
|
|
298
|
+
color: {
|
|
299
|
+
...Object.fromEntries((options.theme.colors || []).map((color) => [color, ""])),
|
|
300
|
+
neutral: ""
|
|
301
|
+
},
|
|
302
|
+
connected: {
|
|
303
|
+
true: "",
|
|
304
|
+
false: ""
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
compoundVariants: [
|
|
308
|
+
// Default state: colored border, fill on hover
|
|
309
|
+
...(options.theme.colors || []).map((color) => ({
|
|
310
|
+
color,
|
|
311
|
+
class: {
|
|
312
|
+
root: `!border-${color} hover:!bg-${color}`
|
|
313
|
+
}
|
|
314
|
+
})),
|
|
315
|
+
{
|
|
316
|
+
color: "neutral",
|
|
317
|
+
class: {
|
|
318
|
+
root: "!border-accented hover:!bg-inverted"
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
// Connected state: filled with color
|
|
322
|
+
...(options.theme.colors || []).map((color) => ({
|
|
323
|
+
color,
|
|
324
|
+
connected: true,
|
|
325
|
+
class: {
|
|
326
|
+
root: `!bg-${color}`
|
|
327
|
+
}
|
|
328
|
+
})),
|
|
329
|
+
{
|
|
330
|
+
color: "neutral",
|
|
331
|
+
connected: true,
|
|
332
|
+
class: {
|
|
333
|
+
root: "!bg-inverted"
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
],
|
|
337
|
+
defaultVariants: {
|
|
338
|
+
color: "primary",
|
|
339
|
+
connected: false
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
const flowBackground = (_options) => ({
|
|
344
|
+
slots: {
|
|
345
|
+
root: ""
|
|
346
|
+
},
|
|
347
|
+
variants: {
|
|
348
|
+
pattern: {
|
|
349
|
+
dots: "",
|
|
350
|
+
lines: ""
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
defaultVariants: {
|
|
354
|
+
pattern: "dots"
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
const flowControls = (_options) => ({
|
|
359
|
+
slots: {
|
|
360
|
+
root: "bg-default border border-accented rounded-lg shadow-sm overflow-hidden",
|
|
361
|
+
button: "p-2 hover:bg-elevated transition-colors border-b border-accented last:border-b-0"
|
|
362
|
+
},
|
|
363
|
+
variants: {},
|
|
364
|
+
defaultVariants: {}
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
const flowMiniMap = (_options) => ({
|
|
368
|
+
slots: {
|
|
369
|
+
root: "border border-accented rounded-lg shadow-sm overflow-hidden"
|
|
370
|
+
},
|
|
371
|
+
variants: {},
|
|
372
|
+
defaultVariants: {}
|
|
373
|
+
});
|
|
374
|
+
|
|
169
375
|
const theme = {
|
|
170
376
|
__proto__: null,
|
|
171
377
|
dialogAlert: dialogAlert,
|
|
172
378
|
dialogConfirm: dialogConfirm,
|
|
379
|
+
flow: flow,
|
|
380
|
+
flowBackground: flowBackground,
|
|
381
|
+
flowControls: flowControls,
|
|
382
|
+
flowHandle: flowHandle,
|
|
383
|
+
flowMiniMap: flowMiniMap,
|
|
384
|
+
flowNode: flowNode,
|
|
173
385
|
toggleGroup: toggleGroup
|
|
174
386
|
};
|
|
175
387
|
|
|
@@ -269,7 +481,7 @@ const module$1 = defineNuxtModule({
|
|
|
269
481
|
moduleDependencies: {
|
|
270
482
|
"@nuxt/ui": {}
|
|
271
483
|
},
|
|
272
|
-
setup(options, nuxt) {
|
|
484
|
+
async setup(options, nuxt) {
|
|
273
485
|
const resolver = createResolver(import.meta.url);
|
|
274
486
|
const uiOptions = nuxt.options.ui;
|
|
275
487
|
const themeColors = uiOptions?.theme?.colors || ["primary", "secondary", "success", "info", "warning", "error"];
|
|
@@ -286,8 +498,26 @@ const module$1 = defineNuxtModule({
|
|
|
286
498
|
nuxt.options.alias["#ui-elements"] = resolver.resolve("./runtime");
|
|
287
499
|
addComponentsDir({
|
|
288
500
|
path: resolver.resolve("./runtime/components"),
|
|
289
|
-
prefix: options.prefix
|
|
501
|
+
prefix: options.prefix,
|
|
502
|
+
ignore: ["**/flow/**"]
|
|
290
503
|
});
|
|
504
|
+
const moduleDirs = nuxt.options.modulesDir;
|
|
505
|
+
if (await tryResolveModule("@vue-flow/core", moduleDirs)) {
|
|
506
|
+
nuxt.options.css.push("@vue-flow/core/dist/style.css");
|
|
507
|
+
nuxt.options.css.push("@vue-flow/core/dist/theme-default.css");
|
|
508
|
+
nuxt.options.build.transpile.push("@vue-flow/core");
|
|
509
|
+
}
|
|
510
|
+
if (await tryResolveModule("@vue-flow/background", moduleDirs)) {
|
|
511
|
+
nuxt.options.build.transpile.push("@vue-flow/background");
|
|
512
|
+
}
|
|
513
|
+
if (await tryResolveModule("@vue-flow/controls", moduleDirs)) {
|
|
514
|
+
nuxt.options.css.push("@vue-flow/controls/dist/style.css");
|
|
515
|
+
nuxt.options.build.transpile.push("@vue-flow/controls");
|
|
516
|
+
}
|
|
517
|
+
if (await tryResolveModule("@vue-flow/minimap", moduleDirs)) {
|
|
518
|
+
nuxt.options.css.push("@vue-flow/minimap/dist/style.css");
|
|
519
|
+
nuxt.options.build.transpile.push("@vue-flow/minimap");
|
|
520
|
+
}
|
|
291
521
|
}
|
|
292
522
|
});
|
|
293
523
|
|
|
@@ -24,7 +24,7 @@ const {
|
|
|
24
24
|
color: { type: null, required: false },
|
|
25
25
|
variant: { type: null, required: false },
|
|
26
26
|
onDismiss: { type: Function, required: false },
|
|
27
|
-
ui: { type:
|
|
27
|
+
ui: { type: null, required: false }
|
|
28
28
|
});
|
|
29
29
|
const emits = defineEmits(["update:open", "close"]);
|
|
30
30
|
const ui = computed(
|
|
@@ -31,7 +31,7 @@ const {
|
|
|
31
31
|
close: { type: Boolean, required: false },
|
|
32
32
|
onConfirm: { type: Function, required: false },
|
|
33
33
|
onDismiss: { type: Function, required: false },
|
|
34
|
-
ui: { type:
|
|
34
|
+
ui: { type: null, required: false }
|
|
35
35
|
});
|
|
36
36
|
const emits = defineEmits(["update:open", "close"]);
|
|
37
37
|
const isLoading = ref(false);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { AppConfig } from "@nuxt/schema";
|
|
2
|
+
import theme from "#build/ui-elements/flow";
|
|
3
|
+
import type { ComponentConfig } from "../types/index.js";
|
|
4
|
+
import type { Node, Edge, ConnectionMode } from "@vue-flow/core";
|
|
5
|
+
import type { FlowBackgroundProps } from "./flow/FlowBackground.vue.js";
|
|
6
|
+
import type { FlowControlsProps } from "./flow/FlowControls.vue.js";
|
|
7
|
+
import type { FlowMiniMapProps } from "./flow/FlowMiniMap.vue.js";
|
|
8
|
+
type Flow = ComponentConfig<typeof theme, AppConfig, "flow">;
|
|
9
|
+
export interface FlowProps {
|
|
10
|
+
/** Array of node objects */
|
|
11
|
+
nodes?: Node[];
|
|
12
|
+
/** Array of edge objects */
|
|
13
|
+
edges?: Edge[];
|
|
14
|
+
/** Map of custom node type components */
|
|
15
|
+
nodeTypes?: Record<string, any>;
|
|
16
|
+
/** Map of custom edge type components */
|
|
17
|
+
edgeTypes?: Record<string, any>;
|
|
18
|
+
/** Fit view on initialization */
|
|
19
|
+
fitViewOnInit?: boolean;
|
|
20
|
+
/** Minimum zoom level */
|
|
21
|
+
minZoom?: number;
|
|
22
|
+
/** Maximum zoom level */
|
|
23
|
+
maxZoom?: number;
|
|
24
|
+
/** Whether nodes are draggable */
|
|
25
|
+
nodesDraggable?: boolean;
|
|
26
|
+
/** Whether nodes are connectable */
|
|
27
|
+
nodesConnectable?: boolean;
|
|
28
|
+
/** Whether elements are selectable */
|
|
29
|
+
elementsSelectable?: boolean;
|
|
30
|
+
/** Connection mode */
|
|
31
|
+
connectionMode?: ConnectionMode;
|
|
32
|
+
/** Default edge options */
|
|
33
|
+
defaultEdgeOptions?: Record<string, any>;
|
|
34
|
+
/** Show background (true for defaults, or pass config object) */
|
|
35
|
+
background?: boolean | Omit<FlowBackgroundProps, "ui">;
|
|
36
|
+
/** Show controls (true for defaults, or pass config object) */
|
|
37
|
+
controls?: boolean | Omit<FlowControlsProps, "ui">;
|
|
38
|
+
/** Show minimap (true for defaults, or pass config object) */
|
|
39
|
+
minimap?: boolean | Omit<FlowMiniMapProps, "ui">;
|
|
40
|
+
/** Theme slot overrides */
|
|
41
|
+
ui?: Flow["slots"];
|
|
42
|
+
}
|
|
43
|
+
export interface FlowEmits {
|
|
44
|
+
"update:nodes": [nodes: Node[]];
|
|
45
|
+
"update:edges": [edges: Edge[]];
|
|
46
|
+
nodeClick: [event: any];
|
|
47
|
+
edgeClick: [event: any];
|
|
48
|
+
paneClick: [event: any];
|
|
49
|
+
connect: [params: any];
|
|
50
|
+
}
|
|
51
|
+
export type { FlowBackgroundProps, FlowControlsProps, FlowMiniMapProps };
|
|
52
|
+
export type { FlowNodeProps } from "./FlowNode.vue.js";
|
|
53
|
+
export type { FlowHandleProps } from "./FlowHandle.vue.js";
|
|
54
|
+
declare const _default: typeof __VLS_export;
|
|
55
|
+
export default _default;
|
|
56
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FlowProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
57
|
+
"update:nodes": (nodes: Node<any, any, string>[]) => any;
|
|
58
|
+
"update:edges": (edges: Edge[]) => any;
|
|
59
|
+
nodeClick: (event: any) => any;
|
|
60
|
+
edgeClick: (event: any) => any;
|
|
61
|
+
paneClick: (event: any) => any;
|
|
62
|
+
connect: (params: any) => any;
|
|
63
|
+
}, string, import("vue").PublicProps, Readonly<FlowProps> & Readonly<{
|
|
64
|
+
"onUpdate:nodes"?: ((nodes: Node<any, any, string>[]) => any) | undefined;
|
|
65
|
+
"onUpdate:edges"?: ((edges: Edge[]) => any) | undefined;
|
|
66
|
+
onNodeClick?: ((event: any) => any) | undefined;
|
|
67
|
+
onEdgeClick?: ((event: any) => any) | undefined;
|
|
68
|
+
onPaneClick?: ((event: any) => any) | undefined;
|
|
69
|
+
onConnect?: ((params: any) => any) | undefined;
|
|
70
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
71
|
+
[x: string]: ((props: any) => any) | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
74
|
+
new (): {
|
|
75
|
+
$slots: S;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui-elements/flow";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import { computed } from "vue";
|
|
7
|
+
import { VueFlow } from "@vue-flow/core";
|
|
8
|
+
import { tv } from "../utils/tv";
|
|
9
|
+
import FlowBackground from "./flow/FlowBackground.vue";
|
|
10
|
+
import FlowControls from "./flow/FlowControls.vue";
|
|
11
|
+
import FlowMiniMap from "./flow/FlowMiniMap.vue";
|
|
12
|
+
const {
|
|
13
|
+
nodes = [],
|
|
14
|
+
edges = [],
|
|
15
|
+
fitViewOnInit = true,
|
|
16
|
+
minZoom = 0.2,
|
|
17
|
+
maxZoom = 4,
|
|
18
|
+
nodesDraggable = true,
|
|
19
|
+
nodesConnectable = true,
|
|
20
|
+
elementsSelectable = true,
|
|
21
|
+
background = true,
|
|
22
|
+
controls = true,
|
|
23
|
+
minimap = false,
|
|
24
|
+
ui: uiProps = {}
|
|
25
|
+
} = defineProps({
|
|
26
|
+
nodes: { type: Array, required: false },
|
|
27
|
+
edges: { type: Array, required: false },
|
|
28
|
+
nodeTypes: { type: Object, required: false },
|
|
29
|
+
edgeTypes: { type: Object, required: false },
|
|
30
|
+
fitViewOnInit: { type: Boolean, required: false },
|
|
31
|
+
minZoom: { type: Number, required: false },
|
|
32
|
+
maxZoom: { type: Number, required: false },
|
|
33
|
+
nodesDraggable: { type: Boolean, required: false },
|
|
34
|
+
nodesConnectable: { type: Boolean, required: false },
|
|
35
|
+
elementsSelectable: { type: Boolean, required: false },
|
|
36
|
+
connectionMode: { type: String, required: false },
|
|
37
|
+
defaultEdgeOptions: { type: Object, required: false },
|
|
38
|
+
background: { type: [Boolean, Object], required: false },
|
|
39
|
+
controls: { type: [Boolean, Object], required: false },
|
|
40
|
+
minimap: { type: [Boolean, Object], required: false },
|
|
41
|
+
ui: { type: null, required: false }
|
|
42
|
+
});
|
|
43
|
+
const emit = defineEmits(["update:nodes", "update:edges", "nodeClick", "edgeClick", "paneClick", "connect"]);
|
|
44
|
+
const ui = computed(() => tv({ extend: tv(theme) })({}));
|
|
45
|
+
const backgroundProps = computed(() => {
|
|
46
|
+
if (background === false) return null;
|
|
47
|
+
if (background === true) return {};
|
|
48
|
+
return background;
|
|
49
|
+
});
|
|
50
|
+
const controlsProps = computed(() => {
|
|
51
|
+
if (controls === false) return null;
|
|
52
|
+
if (controls === true) return {};
|
|
53
|
+
return controls;
|
|
54
|
+
});
|
|
55
|
+
const minimapProps = computed(() => {
|
|
56
|
+
if (minimap === false) return null;
|
|
57
|
+
if (minimap === true) return {};
|
|
58
|
+
return minimap;
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<ClientOnly>
|
|
64
|
+
<div :class="ui.root({ class: uiProps?.root })">
|
|
65
|
+
<VueFlow
|
|
66
|
+
:nodes="nodes"
|
|
67
|
+
:edges="edges"
|
|
68
|
+
:node-types="nodeTypes"
|
|
69
|
+
:edge-types="edgeTypes"
|
|
70
|
+
:fit-view-on-init="fitViewOnInit"
|
|
71
|
+
:min-zoom="minZoom"
|
|
72
|
+
:max-zoom="maxZoom"
|
|
73
|
+
:nodes-draggable="nodesDraggable"
|
|
74
|
+
:nodes-connectable="nodesConnectable"
|
|
75
|
+
:elements-selectable="elementsSelectable"
|
|
76
|
+
:connection-mode="connectionMode"
|
|
77
|
+
:default-edge-options="defaultEdgeOptions"
|
|
78
|
+
:class="ui.wrapper({ class: uiProps?.wrapper })"
|
|
79
|
+
@update:nodes="emit('update:nodes', $event)"
|
|
80
|
+
@update:edges="emit('update:edges', $event)"
|
|
81
|
+
@node-click="emit('nodeClick', $event)"
|
|
82
|
+
@edge-click="emit('edgeClick', $event)"
|
|
83
|
+
@pane-click="emit('paneClick', $event)"
|
|
84
|
+
@connect="emit('connect', $event)">
|
|
85
|
+
<template v-for="(_, name) in $slots" #[name]="slotData">
|
|
86
|
+
<slot :name="name" v-bind="slotData ?? {}" />
|
|
87
|
+
</template>
|
|
88
|
+
|
|
89
|
+
<FlowBackground v-if="backgroundProps" v-bind="backgroundProps" />
|
|
90
|
+
<FlowControls v-if="controlsProps" v-bind="controlsProps" />
|
|
91
|
+
<FlowMiniMap v-if="minimapProps" v-bind="minimapProps" />
|
|
92
|
+
</VueFlow>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<template #fallback>
|
|
96
|
+
<div :class="ui.root({ class: uiProps?.root })" />
|
|
97
|
+
</template>
|
|
98
|
+
</ClientOnly>
|
|
99
|
+
</template>
|