nuxt-ui-elements 0.1.19 → 0.1.21

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-ui-elements",
3
3
  "configKey": "uiElements",
4
- "version": "0.1.19",
4
+ "version": "0.1.21",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -69,8 +69,76 @@ const dialogConfirm = (options) => ({
69
69
  }
70
70
  });
71
71
 
72
+ const dialogAlert = (options) => ({
73
+ slots: {
74
+ content: "divide-y-0 bg-default ring-0",
75
+ header: "relative flex items-center gap-1.5 p-4 sm:px-6 min-h-16",
76
+ icon: "shrink-0 size-12",
77
+ title: "text-lg font-semibold",
78
+ description: "text-sm opacity-90",
79
+ body: "p-2 sm:p-5 sm:pt-0",
80
+ footer: "justify-center gap-3"
81
+ },
82
+ variants: {
83
+ size: {
84
+ sm: {
85
+ content: "sm:max-w-md"
86
+ },
87
+ md: {
88
+ content: "sm:max-w-3xl"
89
+ }
90
+ },
91
+ color: {
92
+ ...Object.fromEntries((options.theme.colors || []).map((color) => [color, ""])),
93
+ neutral: ""
94
+ },
95
+ variant: {
96
+ solid: "",
97
+ outline: ""
98
+ }
99
+ },
100
+ compoundVariants: [
101
+ // Solid variants - dynamically generated for all theme colors
102
+ ...(options.theme.colors || []).map((color) => ({
103
+ color,
104
+ variant: "solid",
105
+ class: {
106
+ content: `bg-${color} text-inverted`
107
+ }
108
+ })),
109
+ {
110
+ color: "neutral",
111
+ variant: "solid",
112
+ class: {
113
+ content: "text-inverted bg-inverted"
114
+ }
115
+ },
116
+ // Outline variants - dynamically generated for all theme colors
117
+ ...(options.theme.colors || []).map((color) => ({
118
+ color,
119
+ variant: "outline",
120
+ class: {
121
+ content: `bg-gradient-to-b from-${color}/5 to-${color}/5 bg-default text-${color} !ring !ring-inset !ring-${color}`
122
+ }
123
+ })),
124
+ {
125
+ color: "neutral",
126
+ variant: "outline",
127
+ class: {
128
+ content: "text-highlighted bg-elevated !ring !ring-inset !ring-accented"
129
+ }
130
+ }
131
+ ],
132
+ defaultVariants: {
133
+ color: "primary",
134
+ variant: "solid",
135
+ size: "sm"
136
+ }
137
+ });
138
+
72
139
  const theme = {
73
140
  __proto__: null,
141
+ dialogAlert: dialogAlert,
74
142
  dialogConfirm: dialogConfirm
75
143
  };
76
144
 
@@ -135,6 +203,24 @@ function addTemplates(options, _nuxt) {
135
203
  .animate-shake {
136
204
  animation: shake 0.5s ease-in-out;
137
205
  }
206
+
207
+ @keyframes alert-bounce {
208
+ 0% {
209
+ opacity: 0;
210
+ transform: scale(0.95);
211
+ }
212
+ 50% {
213
+ transform: scale(1.02);
214
+ }
215
+ 100% {
216
+ opacity: 1;
217
+ transform: scale(1);
218
+ }
219
+ }
220
+
221
+ .animate-alert-bounce {
222
+ animation: alert-bounce 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
223
+ }
138
224
  `;
139
225
  }
140
226
  });
@@ -0,0 +1,25 @@
1
+ import type { AppConfig } from "@nuxt/schema";
2
+ import theme from "#build/ui-elements/dialog-alert";
3
+ import type { ComponentConfig } from "../types/tv.js";
4
+ type DialogAlert = ComponentConfig<typeof theme, AppConfig, "dialogAlert">;
5
+ interface DialogAlertProps {
6
+ title?: string;
7
+ description?: string;
8
+ icon?: string;
9
+ label?: string;
10
+ color?: DialogAlert["variants"]["color"];
11
+ variant?: DialogAlert["variants"]["variant"];
12
+ onDismiss?: (() => void) | (() => Promise<void>);
13
+ ui?: DialogAlert["slots"];
14
+ }
15
+ declare const _default: typeof __VLS_export;
16
+ export default _default;
17
+ declare const __VLS_export: import("vue").DefineComponent<DialogAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
+ close: (value?: any) => any;
19
+ "update:open": (value: boolean) => any;
20
+ "after:leave": () => any;
21
+ }, string, import("vue").PublicProps, Readonly<DialogAlertProps> & Readonly<{
22
+ onClose?: ((value?: any) => any) | undefined;
23
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
24
+ "onAfter:leave"?: (() => any) | undefined;
25
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -0,0 +1,78 @@
1
+ <script>
2
+ import theme from "#build/ui-elements/dialog-alert";
3
+ import { computed } from "vue";
4
+ import { DialogTitle, DialogDescription } from "reka-ui";
5
+ import { tv } from "../utils/tv";
6
+ </script>
7
+
8
+ <script setup>
9
+ const {
10
+ title = "",
11
+ description = "",
12
+ icon = void 0,
13
+ label = "Ok",
14
+ color = "neutral",
15
+ variant = "solid",
16
+ onDismiss = () => {
17
+ },
18
+ ui: uiProps = {}
19
+ } = defineProps({
20
+ title: { type: String, required: false },
21
+ description: { type: String, required: false },
22
+ icon: { type: String, required: false },
23
+ label: { type: String, required: false },
24
+ color: { type: null, required: false },
25
+ variant: { type: null, required: false },
26
+ onDismiss: { type: Function, required: false },
27
+ ui: { type: null, required: false }
28
+ });
29
+ const emits = defineEmits(["update:open", "close", "after:leave"]);
30
+ const ui = computed(
31
+ () => tv({
32
+ extend: tv(theme)
33
+ })({
34
+ size: "sm",
35
+ color,
36
+ variant
37
+ })
38
+ );
39
+ const dismissHandler = () => {
40
+ onDismiss();
41
+ emits("close");
42
+ };
43
+ </script>
44
+
45
+ <template>
46
+ <UModal
47
+ :dismissible="false"
48
+ :close="false"
49
+ :title="title"
50
+ :description="description"
51
+ :ui="{
52
+ content: ui.content({ class: ['animate-alert-bounce', uiProps?.content] }),
53
+ header: ui.header({ class: uiProps?.header }),
54
+ body: ui.body({ class: uiProps?.body }),
55
+ footer: ui.footer({ class: uiProps?.footer })
56
+ }"
57
+ @close="emits('close', $event)"
58
+ @after:leave="emits('after:leave')">
59
+ <template #header>
60
+ <div class="relative w-full flex flex-col items-center text-center gap-3">
61
+ <UIcon v-if="icon" :name="icon" data-slot="icon" :class="ui.icon({ class: uiProps?.icon })" />
62
+ <div class="w-full">
63
+ <DialogTitle v-if="title" data-slot="title" :class="ui.title({ class: uiProps?.title })">
64
+ {{ title }}
65
+ </DialogTitle>
66
+
67
+ <DialogDescription v-if="description" :class="ui.description({ class: uiProps?.description })">
68
+ {{ description }}
69
+ </DialogDescription>
70
+ </div>
71
+ </div>
72
+ </template>
73
+
74
+ <template #footer>
75
+ <UButton :label="label" size="lg" color="neutral" variant="outline" @click="dismissHandler" />
76
+ </template>
77
+ </UModal>
78
+ </template>
@@ -0,0 +1,25 @@
1
+ import type { AppConfig } from "@nuxt/schema";
2
+ import theme from "#build/ui-elements/dialog-alert";
3
+ import type { ComponentConfig } from "../types/tv.js";
4
+ type DialogAlert = ComponentConfig<typeof theme, AppConfig, "dialogAlert">;
5
+ interface DialogAlertProps {
6
+ title?: string;
7
+ description?: string;
8
+ icon?: string;
9
+ label?: string;
10
+ color?: DialogAlert["variants"]["color"];
11
+ variant?: DialogAlert["variants"]["variant"];
12
+ onDismiss?: (() => void) | (() => Promise<void>);
13
+ ui?: DialogAlert["slots"];
14
+ }
15
+ declare const _default: typeof __VLS_export;
16
+ export default _default;
17
+ declare const __VLS_export: import("vue").DefineComponent<DialogAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
+ close: (value?: any) => any;
19
+ "update:open": (value: boolean) => any;
20
+ "after:leave": () => any;
21
+ }, string, import("vue").PublicProps, Readonly<DialogAlertProps> & Readonly<{
22
+ onClose?: ((value?: any) => any) | undefined;
23
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
24
+ "onAfter:leave"?: (() => any) | undefined;
25
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -14,8 +14,18 @@ export interface DialogConfirmOptions {
14
14
  onDismiss?: CallbackFn;
15
15
  ui?: any;
16
16
  }
17
+ export interface DialogAlertOptions {
18
+ title: string;
19
+ description?: string;
20
+ icon?: string;
21
+ label?: string;
22
+ color?: Color;
23
+ variant?: Variant;
24
+ onDismiss?: CallbackFn;
25
+ ui?: any;
26
+ }
17
27
  export declare const useDialog: () => {
18
28
  confirm: (options: DialogConfirmOptions) => void;
19
- confirmNavigate: (path: string, options?: Omit<DialogConfirmOptions, "title" | "description" | "onConfirm">) => void;
29
+ alert: (options: DialogAlertOptions) => void;
20
30
  };
21
31
  export {};
@@ -1,6 +1,6 @@
1
1
  import DialogConfirm from "../components/DialogConfirm.vue";
2
+ import DialogAlert from "../components/DialogAlert.vue";
2
3
  import { useOverlay } from "#imports";
3
- import { navigateTo } from "#app";
4
4
  export const useDialog = () => {
5
5
  const overlay = useOverlay();
6
6
  const confirm = (options) => {
@@ -10,15 +10,12 @@ export const useDialog = () => {
10
10
  });
11
11
  modal.open();
12
12
  };
13
- const confirmNavigate = (path, options) => {
14
- confirm({
15
- title: "Leave this page?",
16
- description: "Are you sure you want to navigate away? Unsaved changes will be lost.",
17
- ...options,
18
- onConfirm: () => {
19
- navigateTo(path);
20
- }
13
+ const alert = (options) => {
14
+ const modal = overlay.create(DialogAlert, {
15
+ destroyOnClose: true,
16
+ props: options
21
17
  });
18
+ modal.open();
22
19
  };
23
- return { confirm, confirmNavigate };
20
+ return { confirm, alert };
24
21
  };
@@ -1,14 +1,19 @@
1
1
  /**
2
- * Standard utility library re-exports
3
- * Import from '#std' for tree-shakeable utilities
2
+ * Standard utility library
4
3
  *
5
4
  * @example
6
- * import { plur, slugify, date } from '#std'
5
+ * import std from '#std'
7
6
  *
8
- * const text = plur('item', count)
9
- * const slug = slugify('Hello World')
10
- * const nextMonth = date.add(date.today(), 1, 'month')
7
+ * const text = std.plur('item', count)
8
+ * const slug = std.slugify('Hello World')
9
+ * const nextMonth = std.date.add(std.date.today(), 1, 'month')
11
10
  */
12
- export { default as plur } from "plur";
13
- export { default as slugify } from "@sindresorhus/slugify";
14
- export * as date from "./std/date.js";
11
+ import plur from "plur";
12
+ import slugify from "@sindresorhus/slugify";
13
+ import * as date from "./std/date.js";
14
+ declare const _default: {
15
+ readonly plur: typeof plur;
16
+ readonly slugify: typeof slugify;
17
+ readonly date: typeof date;
18
+ };
19
+ export default _default;
@@ -1,3 +1,8 @@
1
- export { default as plur } from "plur";
2
- export { default as slugify } from "@sindresorhus/slugify";
3
- export * as date from "./std/date.js";
1
+ import plur from "plur";
2
+ import slugify from "@sindresorhus/slugify";
3
+ import * as date from "./std/date.js";
4
+ export default {
5
+ plur,
6
+ slugify,
7
+ date
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-ui-elements",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "A collection of beautiful, animated UI components for Nuxt applications",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/genu/nuxt-ui-elements.git",