@resee-movies/nuxt-ux 0.3.1 → 0.4.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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@resee-movies/nuxt-ux",
3
3
  "configKey": "ux",
4
- "version": "0.3.1",
4
+ "version": "0.4.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.0"
package/dist/module.mjs CHANGED
@@ -133,6 +133,13 @@ function importModules(nuxt) {
133
133
  ...primeOptions?.includeComponents ?? []
134
134
  ])
135
135
  );
136
+ nuxt.options.vite.optimizeDeps ??= {};
137
+ nuxt.options.vite.optimizeDeps.include ??= [];
138
+ nuxt.options.vite.optimizeDeps.include.push(
139
+ "primevue/usetoast",
140
+ "primevue/toasteventbus",
141
+ "primevue/toastservice"
142
+ );
136
143
  const Primevue = {
137
144
  defaults: {
138
145
  autoImport: false,
@@ -214,7 +221,10 @@ const module = defineNuxtModule({
214
221
  const sources = options.tailwind?.sources?.slice() ?? [];
215
222
  const plugins = options.tailwind?.plugins?.slice() ?? [];
216
223
  const imports = options.tailwind?.plugins?.slice() ?? [];
217
- sources.push(components);
224
+ const constants = await resolver.resolvePath("./runtime/constants", {
225
+ extensions: ["ts", "js"]
226
+ });
227
+ sources.push(components, constants);
218
228
  plugins.push(await resolvePath("@egoist/tailwindcss-icons"));
219
229
  imports.push(stylesheet);
220
230
  addComponentsDir({ path: components, prefix: options.componentPrefix });
@@ -11,12 +11,12 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<Dialog
11
11
  "onUpdate:visible"?: ((visible: boolean) => any) | undefined;
12
12
  }>, {
13
13
  size: "xxs" | "xs" | "sm" | "md" | "lg";
14
+ closable: boolean;
14
15
  showHeaderText: boolean;
15
16
  showHeaderStyle: boolean;
16
17
  showModalStyle: boolean;
17
18
  modal: boolean;
18
19
  contentClass: any;
19
- closable: boolean;
20
20
  dismissableMask: boolean;
21
21
  showHeader: boolean;
22
22
  position: import("@primevue/core").HintedString<"top" | "center" | "bottom" | "left" | "right" | "topleft" | "topright" | "bottomleft" | "bottomright">;
@@ -145,5 +145,5 @@ const altText = computed(() => {
145
145
  </script>
146
146
 
147
147
  <style scoped>
148
- @reference "tailwindcss";.image{background-color:#fff;overflow:clip;position:relative;width:-moz-max-content;width:max-content;@variant dark{background-color:#000}}.image.bordered{border:2px solid var(--color-global-background-accent)}.image.beveled{border-bottom-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.image.raised{box-shadow:var(--shadow-heavy)}.image.glass:after{background-image:linear-gradient(110deg,transparent 25%,hsla(0,0%,100%,.15) 80%,transparent);content:var(--zero-width-space);inset:0;position:absolute}.image .icon{color:var(--color-global-background-accent);left:50%;position:absolute;top:50%;transform:translateX(-50%) translateY(-50%)}
148
+ @reference "tailwindcss";.image{background-color:#fff;overflow:clip;position:relative;width:-moz-fit-content;width:fit-content;@variant dark{background-color:#000}}.image.bordered{border:2px solid var(--color-global-background-accent)}.image.beveled{border-bottom-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.image.raised{box-shadow:var(--shadow-heavy)}.image.glass:after{background-image:linear-gradient(110deg,transparent 25%,hsla(0,0%,100%,.15) 80%,transparent);content:var(--zero-width-space);inset:0;position:absolute}.image .icon{color:var(--color-global-background-accent);left:50%;position:absolute;top:50%;transform:translateX(-50%) translateY(-50%)}
149
149
  </style>
@@ -1,8 +1,12 @@
1
1
  <template>
2
2
  <PrimeMessage :severity="props.severity" class="message" :pt="passthroughProps">
3
- <slot>
4
- {{ props.text }}
5
- </slot>
3
+ <template #icon>
4
+ <Icon :name="props.icon" :size="props.iconSize" />
5
+ </template>
6
+
7
+ <template #default>
8
+ <slot>{{ props.text }}</slot>
9
+ </template>
6
10
  </PrimeMessage>
7
11
  </template>
8
12
 
@@ -12,12 +16,15 @@ import { computed } from "vue";
12
16
 
13
17
  <script setup>
14
18
  import PrimeMessage from "primevue/message";
19
+ import Icon from "./Icon.vue";
15
20
  const props = defineProps({
16
21
  severity: { type: String, required: false },
17
22
  text: { type: String, required: false },
18
23
  class: { type: String, required: false },
19
24
  style: { type: String, required: false },
20
- accented: { type: Boolean, required: false }
25
+ accented: { type: Boolean, required: false },
26
+ icon: { type: String, required: false },
27
+ iconSize: { type: String, required: false }
21
28
  });
22
29
  const passthroughProps = computed(() => {
23
30
  return {
@@ -1,10 +1,13 @@
1
1
  import type { StatusLevel } from '../types/index.js';
2
+ import type { IconProps } from './Icon.vue.js';
2
3
  export interface MessageProps {
3
4
  severity?: StatusLevel;
4
5
  text?: string;
5
6
  class?: string;
6
7
  style?: string;
7
8
  accented?: boolean;
9
+ icon?: IconProps['name'];
10
+ iconSize?: IconProps['size'];
8
11
  }
9
12
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<MessageProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MessageProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
10
13
  default?: (props: {}) => any;
@@ -7,6 +7,7 @@
7
7
  </template>
8
8
 
9
9
  <script setup>
10
+ import { isString } from "@resee-movies/utilities/strings/is-string";
10
11
  import PrimeToast, {} from "primevue/toast";
11
12
  import { StatusLevelIcons } from "../constants";
12
13
  const passthroughProps = {
@@ -19,9 +20,16 @@ const passthroughProps = {
19
20
  props.message?.summary?.trim() ? "has-summary" : void 0
20
21
  ]
21
22
  }),
22
- messageIcon: ({ props }) => ({
23
- class: ["icon", StatusLevelIcons[props.message?.severity ?? "default"]]
24
- }),
23
+ messageIcon: ({ props }) => {
24
+ let iconClassName = StatusLevelIcons[props.message?.severity ?? "default"];
25
+ if (props.message && "icon" in props.message && isString(props.message.icon)) {
26
+ iconClassName = props.message.icon;
27
+ }
28
+ console.log(iconClassName);
29
+ return {
30
+ class: ["icon", iconClassName]
31
+ };
32
+ },
25
33
  root: { class: "notification-container" },
26
34
  messageContent: { class: "content" },
27
35
  messageText: { class: "text" },
@@ -1,17 +1,24 @@
1
- export type NotificationOptions = {
1
+ import type { ToastServiceMethods } from 'primevue/toastservice';
2
+ import type { StatusLevel } from '../types/index.js';
3
+ export interface NotificationOptions {
2
4
  headline?: string;
3
5
  closable?: boolean;
4
- };
5
- export type UseNotificationReturn = {
6
- notify: (message: string, options?: NotificationOptions) => void;
7
- notifyInfo: (message: string, options?: NotificationOptions) => void;
8
- notifyHelp: (message: string, options?: NotificationOptions) => void;
9
- notifySuccess: (message: string, options?: NotificationOptions) => void;
10
- notifyWarning: (message: string, options?: NotificationOptions) => void;
11
- notifyError: (message: string, options?: NotificationOptions) => void;
12
- };
6
+ icon?: string;
7
+ lifetime?: number;
8
+ }
9
+ export declare class NotificationService {
10
+ readonly notify: (message: string, options?: NotificationOptions & {
11
+ severity?: StatusLevel;
12
+ }) => void;
13
+ readonly notifyInfo: (message: string, options?: NotificationOptions) => void;
14
+ readonly notifyHelp: (message: string, options?: NotificationOptions) => void;
15
+ readonly notifySuccess: (message: string, options?: NotificationOptions) => void;
16
+ readonly notifyWarning: (message: string, options?: NotificationOptions) => void;
17
+ readonly notifyError: (message: string, options?: NotificationOptions) => void;
18
+ constructor(toast: ToastServiceMethods);
19
+ }
13
20
  /**
14
21
  * Returns a collection of methods for providing user feedback via popup
15
22
  * notifications (a.k.a. toast notifications / snackbar notifications).
16
23
  */
17
- export declare function useNotification(): UseNotificationReturn;
24
+ export declare function useNotification(): NotificationService;
@@ -1,31 +1,31 @@
1
+ import { isNumber } from "@resee-movies/utilities/numbers/is-number";
1
2
  import { useToast } from "primevue/usetoast";
2
- const DefaultLifetime = 5e3;
3
- function createToastMessageOptions(message, status, config) {
4
- return {
5
- detail: message,
6
- severity: status,
7
- summary: config?.headline,
8
- closable: config?.closable === true,
9
- life: config?.closable === true ? void 0 : DefaultLifetime
10
- };
11
- }
12
- function createToastMessageClosure(toast, status) {
13
- const fn = (message, options) => {
14
- toast.add(createToastMessageOptions(message, status, options));
15
- };
16
- Object.defineProperty(fn, "name", {
17
- value: `notify${status ?? ""}`
18
- });
19
- return fn;
3
+ export class NotificationService {
4
+ notify;
5
+ notifyInfo;
6
+ notifyHelp;
7
+ notifySuccess;
8
+ notifyWarning;
9
+ notifyError;
10
+ constructor(toast) {
11
+ this.notify = (message, options) => {
12
+ toast.add({
13
+ detail: message,
14
+ severity: options?.severity,
15
+ summary: options?.headline,
16
+ closable: options?.closable === true,
17
+ life: isNumber(options?.lifetime) ? options?.lifetime : 5e3,
18
+ /* @ts-expect-error - adding custom props to extend functionality */
19
+ icon: options?.icon
20
+ });
21
+ };
22
+ this.notifyInfo = (message, options) => this.notify(message, { severity: "info", ...options });
23
+ this.notifyHelp = (message, options) => this.notify(message, { severity: "help", ...options });
24
+ this.notifySuccess = (message, options) => this.notify(message, { severity: "success", ...options });
25
+ this.notifyWarning = (message, options) => this.notify(message, { severity: "warn", ...options });
26
+ this.notifyError = (message, options) => this.notify(message, { severity: "error", ...options });
27
+ }
20
28
  }
21
29
  export function useNotification() {
22
- const toast = useToast();
23
- return {
24
- notify: createToastMessageClosure(toast, void 0),
25
- notifyInfo: createToastMessageClosure(toast, "info"),
26
- notifyHelp: createToastMessageClosure(toast, "help"),
27
- notifySuccess: createToastMessageClosure(toast, "success"),
28
- notifyWarning: createToastMessageClosure(toast, "warn"),
29
- notifyError: createToastMessageClosure(toast, "error")
30
- };
30
+ return new NotificationService(useToast());
31
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resee-movies/nuxt-ux",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "description": "The next-gen user experience library for ReSee Movies - currently in development. ",
5
5
  "repository": {
6
6
  "url": "https://github.com/ReSee-Movies/nuxt-ux.git"