nuxt-toastflow 1.0.1 โ 1.0.2-beta.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 +100 -86
- package/dist/module.d.mts +4 -7
- package/dist/module.d.ts +4 -7
- package/dist/module.js +9 -21
- package/dist/module.mjs +11 -22
- package/dist/runtime/index.d.mts +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +24 -0
- package/dist/runtime/index.mjs +2 -0
- package/dist/styles.css +900 -0
- package/package.json +17 -6
- package/dist/module.json +0 -12
- package/dist/runtime/composables/toast.d.ts +0 -4
- package/dist/runtime/composables/toast.js +0 -14
- package/dist/runtime/plugin.d.ts +0 -2
- package/dist/runtime/plugin.js +0 -11
- package/dist/types.d.mts +0 -9
package/README.md
CHANGED
|
@@ -1,86 +1,100 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="../../assets/banner.png" alt="Toastflow" width="100%" />
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<h1 align="center">๐ nuxt-toastflow</h1>
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
<strong>Nuxt module for Toastflow</strong> โ auto-imports, SSR support, and zero-config setup.
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
<p align="center">
|
|
12
|
-
<a href="https://www.npmjs.com/package/nuxt-toastflow"><img src="https://img.shields.io/npm/v/nuxt-toastflow?color=00dc82&style=flat-square" alt="npm version" /></a>
|
|
13
|
-
<a href="https://www.npmjs.com/package/nuxt-toastflow"><img src="https://img.shields.io/npm/dm/nuxt-toastflow?style=flat-square" alt="npm downloads" /></a>
|
|
14
|
-
<a href="../../LICENSE"><img src="https://img.shields.io/github/license/adrianjanocko/toastflow?style=flat-square" alt="License" /></a>
|
|
15
|
-
</p>
|
|
16
|
-
|
|
17
|
-
<p align="center">
|
|
18
|
-
<a href="https://
|
|
19
|
-
</p>
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## ๐ Quick Start
|
|
24
|
-
|
|
25
|
-
**1. Install**
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
pnpm add nuxt-toastflow
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
**2. Add the module**
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
// nuxt.config.ts
|
|
35
|
-
export default defineNuxtConfig({
|
|
36
|
-
modules: ["nuxt-toastflow"],
|
|
37
|
-
toastflow: {
|
|
38
|
-
config: {
|
|
39
|
-
position: "top-right",
|
|
40
|
-
duration: 5000,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
**3. Toast away ๐**
|
|
47
|
-
|
|
48
|
-
```vue
|
|
49
|
-
<!-- app.vue -->
|
|
50
|
-
<script setup lang="ts">
|
|
51
|
-
toast.success({
|
|
52
|
-
title: "Saved",
|
|
53
|
-
description: "Your changes are live.",
|
|
54
|
-
});
|
|
55
|
-
</script>
|
|
56
|
-
|
|
57
|
-
<template>
|
|
58
|
-
<ToastContainer />
|
|
59
|
-
<NuxtPage />
|
|
60
|
-
</template>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
> ๐ก Both `toast` and `useToast()` are auto-imported โ no manual imports needed!
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="../../assets/banner.png" alt="Toastflow" width="100%" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">๐ nuxt-toastflow</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Nuxt module for Toastflow</strong> โ auto-imports, SSR support, and zero-config setup.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/nuxt-toastflow"><img src="https://img.shields.io/npm/v/nuxt-toastflow?color=00dc82&style=flat-square" alt="npm version" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/nuxt-toastflow"><img src="https://img.shields.io/npm/dm/nuxt-toastflow?style=flat-square" alt="npm downloads" /></a>
|
|
14
|
+
<a href="../../LICENSE"><img src="https://img.shields.io/github/license/adrianjanocko/toastflow?style=flat-square" alt="License" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://www.toastflow.top/docs">๐ Docs</a> ยท <a href="https://www.toastflow.top/">๐ฎ Playground</a> ยท <a href="https://www.toastflow.top/docs/more/comparisons">โ๏ธ Comparisons</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ๐ Quick Start
|
|
24
|
+
|
|
25
|
+
**1. Install**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm add nuxt-toastflow
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**2. Add the module**
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// nuxt.config.ts
|
|
35
|
+
export default defineNuxtConfig({
|
|
36
|
+
modules: ["nuxt-toastflow"],
|
|
37
|
+
toastflow: {
|
|
38
|
+
config: {
|
|
39
|
+
position: "top-right",
|
|
40
|
+
duration: 5000,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**3. Toast away ๐**
|
|
47
|
+
|
|
48
|
+
```vue
|
|
49
|
+
<!-- app.vue -->
|
|
50
|
+
<script setup lang="ts">
|
|
51
|
+
toast.success({
|
|
52
|
+
title: "Saved",
|
|
53
|
+
description: "Your changes are live.",
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<ToastContainer />
|
|
59
|
+
<NuxtPage />
|
|
60
|
+
</template>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> ๐ก Both `toast` and `useToast()` are auto-imported โ no manual imports needed!
|
|
64
|
+
|
|
65
|
+
If you need the lower-level Vue runtime pieces directly, import them from `nuxt-toastflow/runtime`:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import {
|
|
69
|
+
Toast,
|
|
70
|
+
ToastProgress,
|
|
71
|
+
ToastContainer,
|
|
72
|
+
toast,
|
|
73
|
+
} from "nuxt-toastflow/runtime";
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## โ๏ธ Module Options
|
|
77
|
+
|
|
78
|
+
| Option | Type | Default | Description |
|
|
79
|
+
| :----------------- | :--------------------- | :----------------: | :----------------------------------------- |
|
|
80
|
+
| ๐ ๏ธ `config` | `Partial<ToastConfig>` | `{}` | Toast configuration passed to the plugin |
|
|
81
|
+
| ๐จ `css` | `boolean` | `true` | Include default styles |
|
|
82
|
+
| ๐งฑ `componentName` | `string \| false` | `"ToastContainer"` | Auto-registered client-only component name |
|
|
83
|
+
|
|
84
|
+
<details>
|
|
85
|
+
<summary>๐ก <strong>How does it work under the hood?</strong></summary>
|
|
86
|
+
|
|
87
|
+
<br />
|
|
88
|
+
|
|
89
|
+
- `ToastContainer` is auto-registered as a **client-only** component
|
|
90
|
+
- `toast` and `useToast()` are **auto-imported** โ use either one
|
|
91
|
+
- `vue-toastflow` is added to the transpile list so internal components resolve correctly
|
|
92
|
+
- Styles are injected automatically unless `css: false`
|
|
93
|
+
- The module forwards `css` to `createToastflow(..., { css })`, so it uses the same CSS toggle as `vue-toastflow`
|
|
94
|
+
- When you disable CSS and still want the shipped stylesheet manually, import `nuxt-toastflow/styles.css`
|
|
95
|
+
|
|
96
|
+
</details>
|
|
97
|
+
|
|
98
|
+
## ๐ License
|
|
99
|
+
|
|
100
|
+
[MIT](../../LICENSE) โ made with โค๏ธ by [@adrianjanocko](https://github.com/adrianjanocko)
|
package/dist/module.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface NuxtToastflowOptions {
|
|
1
|
+
import type { ToastConfig } from "./runtime";
|
|
2
|
+
export interface NuxtToastflowOptions {
|
|
5
3
|
/**
|
|
6
4
|
* Global Toastflow config passed to createToastflow.
|
|
7
5
|
*/
|
|
@@ -15,6 +13,5 @@ interface NuxtToastflowOptions {
|
|
|
15
13
|
*/
|
|
16
14
|
componentName: string | false;
|
|
17
15
|
}
|
|
18
|
-
declare const _default:
|
|
19
|
-
|
|
20
|
-
export { type NuxtToastflowOptions, _default as default };
|
|
16
|
+
declare const _default: import("@nuxt/schema").NuxtModule<NuxtToastflowOptions, NuxtToastflowOptions, false>;
|
|
17
|
+
export default _default;
|
package/dist/module.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface NuxtToastflowOptions {
|
|
1
|
+
import type { ToastConfig } from "./runtime";
|
|
2
|
+
export interface NuxtToastflowOptions {
|
|
5
3
|
/**
|
|
6
4
|
* Global Toastflow config passed to createToastflow.
|
|
7
5
|
*/
|
|
@@ -15,6 +13,5 @@ interface NuxtToastflowOptions {
|
|
|
15
13
|
*/
|
|
16
14
|
componentName: string | false;
|
|
17
15
|
}
|
|
18
|
-
declare const _default:
|
|
19
|
-
|
|
20
|
-
export { type NuxtToastflowOptions, _default as default };
|
|
16
|
+
declare const _default: import("@nuxt/schema").NuxtModule<NuxtToastflowOptions, NuxtToastflowOptions, false>;
|
|
17
|
+
export default _default;
|
package/dist/module.js
CHANGED
|
@@ -58,7 +58,10 @@ var module_default = (0, import_kit.defineNuxtModule)({
|
|
|
58
58
|
css: true,
|
|
59
59
|
componentName: "ToastContainer"
|
|
60
60
|
},
|
|
61
|
-
setup(options
|
|
61
|
+
setup(options) {
|
|
62
|
+
const nuxt = (0, import_kit.useNuxt)();
|
|
63
|
+
const runtimeEntry = "nuxt-toastflow/runtime";
|
|
64
|
+
nuxt.options.build.transpile.push("vue-toastflow");
|
|
62
65
|
if (containsFunction(options.config)) {
|
|
63
66
|
console.warn(
|
|
64
67
|
"[nuxt-toastflow] Functions in `toastflow.config` are not serializable in nuxt.config and will be omitted."
|
|
@@ -77,10 +80,10 @@ var module_default = (0, import_kit.defineNuxtModule)({
|
|
|
77
80
|
mode: "client",
|
|
78
81
|
getContents: function() {
|
|
79
82
|
return [
|
|
80
|
-
|
|
83
|
+
`import { createToastflow, toast } from "${runtimeEntry}";`,
|
|
81
84
|
"",
|
|
82
85
|
"export default defineNuxtPlugin((nuxtApp) => {",
|
|
83
|
-
` nuxtApp.vueApp.use(createToastflow(${serializedConfig}));`,
|
|
86
|
+
` nuxtApp.vueApp.use(createToastflow(${serializedConfig}, { css: ${options.css ? "true" : "false"} }));`,
|
|
84
87
|
"",
|
|
85
88
|
" return {",
|
|
86
89
|
" provide: {",
|
|
@@ -98,7 +101,7 @@ var module_default = (0, import_kit.defineNuxtModule)({
|
|
|
98
101
|
return [
|
|
99
102
|
'import { useNuxtApp } from "#app";',
|
|
100
103
|
"",
|
|
101
|
-
|
|
104
|
+
`type ToastApi = typeof import("${runtimeEntry}")["toast"];`,
|
|
102
105
|
"",
|
|
103
106
|
"export function useToast(): ToastApi {",
|
|
104
107
|
" return useNuxtApp().$toast;",
|
|
@@ -130,7 +133,7 @@ var module_default = (0, import_kit.defineNuxtModule)({
|
|
|
130
133
|
filename: "types/nuxt-toastflow.d.ts",
|
|
131
134
|
getContents: function() {
|
|
132
135
|
return [
|
|
133
|
-
|
|
136
|
+
`type ToastApi = typeof import("${runtimeEntry}")["toast"];`,
|
|
134
137
|
"",
|
|
135
138
|
'declare module "#app" {',
|
|
136
139
|
" interface NuxtApp {",
|
|
@@ -153,24 +156,9 @@ var module_default = (0, import_kit.defineNuxtModule)({
|
|
|
153
156
|
(0, import_kit.addComponent)({
|
|
154
157
|
name: options.componentName,
|
|
155
158
|
export: "ToastContainer",
|
|
156
|
-
filePath:
|
|
159
|
+
filePath: runtimeEntry,
|
|
157
160
|
mode: "client"
|
|
158
161
|
});
|
|
159
162
|
}
|
|
160
|
-
if (options.css) {
|
|
161
|
-
const cssEntry = "vue-toastflow/styles.css";
|
|
162
|
-
const hasCssEntry = nuxt.options.css.some(function(entry) {
|
|
163
|
-
if (typeof entry === "string") {
|
|
164
|
-
return entry === cssEntry;
|
|
165
|
-
}
|
|
166
|
-
if (Array.isArray(entry) && typeof entry[0] === "string") {
|
|
167
|
-
return entry[0] === cssEntry;
|
|
168
|
-
}
|
|
169
|
-
return false;
|
|
170
|
-
});
|
|
171
|
-
if (!hasCssEntry) {
|
|
172
|
-
nuxt.options.css.push(cssEntry);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
163
|
}
|
|
176
164
|
});
|
package/dist/module.mjs
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
addPluginTemplate,
|
|
6
6
|
addTemplate,
|
|
7
7
|
addTypeTemplate,
|
|
8
|
-
defineNuxtModule
|
|
8
|
+
defineNuxtModule,
|
|
9
|
+
useNuxt
|
|
9
10
|
} from "@nuxt/kit";
|
|
10
11
|
function containsFunction(value, visited = /* @__PURE__ */ new Set()) {
|
|
11
12
|
if (typeof value === "function") {
|
|
@@ -41,7 +42,10 @@ var module_default = defineNuxtModule({
|
|
|
41
42
|
css: true,
|
|
42
43
|
componentName: "ToastContainer"
|
|
43
44
|
},
|
|
44
|
-
setup(options
|
|
45
|
+
setup(options) {
|
|
46
|
+
const nuxt = useNuxt();
|
|
47
|
+
const runtimeEntry = "nuxt-toastflow/runtime";
|
|
48
|
+
nuxt.options.build.transpile.push("vue-toastflow");
|
|
45
49
|
if (containsFunction(options.config)) {
|
|
46
50
|
console.warn(
|
|
47
51
|
"[nuxt-toastflow] Functions in `toastflow.config` are not serializable in nuxt.config and will be omitted."
|
|
@@ -60,10 +64,10 @@ var module_default = defineNuxtModule({
|
|
|
60
64
|
mode: "client",
|
|
61
65
|
getContents: function() {
|
|
62
66
|
return [
|
|
63
|
-
|
|
67
|
+
`import { createToastflow, toast } from "${runtimeEntry}";`,
|
|
64
68
|
"",
|
|
65
69
|
"export default defineNuxtPlugin((nuxtApp) => {",
|
|
66
|
-
` nuxtApp.vueApp.use(createToastflow(${serializedConfig}));`,
|
|
70
|
+
` nuxtApp.vueApp.use(createToastflow(${serializedConfig}, { css: ${options.css ? "true" : "false"} }));`,
|
|
67
71
|
"",
|
|
68
72
|
" return {",
|
|
69
73
|
" provide: {",
|
|
@@ -81,7 +85,7 @@ var module_default = defineNuxtModule({
|
|
|
81
85
|
return [
|
|
82
86
|
'import { useNuxtApp } from "#app";',
|
|
83
87
|
"",
|
|
84
|
-
|
|
88
|
+
`type ToastApi = typeof import("${runtimeEntry}")["toast"];`,
|
|
85
89
|
"",
|
|
86
90
|
"export function useToast(): ToastApi {",
|
|
87
91
|
" return useNuxtApp().$toast;",
|
|
@@ -113,7 +117,7 @@ var module_default = defineNuxtModule({
|
|
|
113
117
|
filename: "types/nuxt-toastflow.d.ts",
|
|
114
118
|
getContents: function() {
|
|
115
119
|
return [
|
|
116
|
-
|
|
120
|
+
`type ToastApi = typeof import("${runtimeEntry}")["toast"];`,
|
|
117
121
|
"",
|
|
118
122
|
'declare module "#app" {',
|
|
119
123
|
" interface NuxtApp {",
|
|
@@ -136,25 +140,10 @@ var module_default = defineNuxtModule({
|
|
|
136
140
|
addComponent({
|
|
137
141
|
name: options.componentName,
|
|
138
142
|
export: "ToastContainer",
|
|
139
|
-
filePath:
|
|
143
|
+
filePath: runtimeEntry,
|
|
140
144
|
mode: "client"
|
|
141
145
|
});
|
|
142
146
|
}
|
|
143
|
-
if (options.css) {
|
|
144
|
-
const cssEntry = "vue-toastflow/styles.css";
|
|
145
|
-
const hasCssEntry = nuxt.options.css.some(function(entry) {
|
|
146
|
-
if (typeof entry === "string") {
|
|
147
|
-
return entry === cssEntry;
|
|
148
|
-
}
|
|
149
|
-
if (Array.isArray(entry) && typeof entry[0] === "string") {
|
|
150
|
-
return entry[0] === cssEntry;
|
|
151
|
-
}
|
|
152
|
-
return false;
|
|
153
|
-
});
|
|
154
|
-
if (!hasCssEntry) {
|
|
155
|
-
nuxt.options.css.push(cssEntry);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
147
|
}
|
|
159
148
|
});
|
|
160
149
|
export {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "vue-toastflow";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "vue-toastflow";
|
|
@@ -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/runtime/index.ts
|
|
18
|
+
var runtime_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
20
|
+
__reExport(runtime_exports, require("vue-toastflow"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("vue-toastflow")
|
|
24
|
+
});
|