nuance-ui 0.1.56 → 0.1.58

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.
Files changed (28) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +2 -6
  3. package/dist/runtime/components/index.d.ts +0 -1
  4. package/dist/runtime/components/index.js +0 -1
  5. package/dist/runtime/composals/index.d.ts +0 -1
  6. package/dist/runtime/composals/index.js +0 -1
  7. package/dist/runtime/{components/modals → modals}/_confirm-modal/confirm-modal.d.vue.ts +3 -4
  8. package/dist/runtime/{components/modals → modals}/_confirm-modal/confirm-modal.vue +7 -22
  9. package/dist/runtime/{components/modals → modals}/_confirm-modal/confirm-modal.vue.d.ts +3 -4
  10. package/dist/runtime/{components/modals → modals}/_confirm-modal/index.d.ts +1 -1
  11. package/dist/runtime/{components/modals → modals}/_confirm-modal/index.js +1 -1
  12. package/dist/runtime/modals/index.d.ts +4 -0
  13. package/dist/runtime/modals/index.js +4 -0
  14. package/dist/runtime/{plugins/modals → modals}/modal-manager.d.ts +7 -3
  15. package/dist/runtime/{plugins/modals → modals}/modal-manager.js +22 -17
  16. package/dist/runtime/modals/modals-provider.vue +16 -0
  17. package/dist/runtime/{composals → modals}/use-modal.d.ts +3 -3
  18. package/dist/runtime/{composals → modals}/use-modal.js +5 -6
  19. package/package.json +1 -1
  20. package/dist/runtime/components/modals/index.d.ts +0 -1
  21. package/dist/runtime/components/modals/index.js +0 -1
  22. package/dist/runtime/components/modals/modals-provider.vue +0 -19
  23. package/dist/runtime/plugins/modals/index.d.ts +0 -1
  24. package/dist/runtime/plugins/modals/index.js +0 -1
  25. package/dist/runtime/plugins/modals/plugin.client.d.ts +0 -8
  26. package/dist/runtime/plugins/modals/plugin.client.js +0 -10
  27. /package/dist/runtime/{components/modals → modals}/modals-provider.d.vue.ts +0 -0
  28. /package/dist/runtime/{components/modals → modals}/modals-provider.vue.d.ts +0 -0
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^4.0.0"
6
6
  },
7
- "version": "0.1.56",
7
+ "version": "0.1.58",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addPlugin } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir } from '@nuxt/kit';
2
2
  import { defu } from 'defu';
3
3
 
4
4
  const defaultConfig = {
@@ -37,7 +37,7 @@ const module$1 = defineNuxtModule({
37
37
  nuxt.options.alias["@nui/utils"] = resolve("./runtime/utils");
38
38
  nuxt.options.alias["@nui/helpers"] = resolve("./runtime/helpers");
39
39
  nuxt.options.alias["@nui/types"] = resolve("./runtime/types");
40
- nuxt.options.alias["@nui/modals"] = resolve("./runtime/plugins/modals");
40
+ nuxt.options.alias["@nui/modals"] = resolve("./runtime/modals");
41
41
  nuxt.options.appConfig.nui = defu(nuxt.options.appConfig.nui || {}, defaultConfig);
42
42
  nuxt.options.postcss = nuxt.options.postcss || {};
43
43
  nuxt.options.postcss.plugins = nuxt.options.postcss.plugins || {};
@@ -70,10 +70,6 @@ const module$1 = defineNuxtModule({
70
70
  addImportsDir(resolve("./runtime/composals"));
71
71
  addImportsDir(resolve("./runtime/helpers"));
72
72
  }
73
- addPlugin({
74
- src: resolve("./runtime/plugins/modals/plugin.client"),
75
- mode: "client"
76
- });
77
73
  nuxt.options.css.push(resolve("./runtime/styles/global.css"));
78
74
  }
79
75
  });
@@ -20,7 +20,6 @@ export * from './input/index.js';
20
20
  export * from './link/index.js';
21
21
  export * from './loader/index.js';
22
22
  export * from './modal/index.js';
23
- export * from './modals/index.js';
24
23
  export * from './nav-link/index.js';
25
24
  export * from './paper.vue.js';
26
25
  export * from './popover/index.js';
@@ -18,7 +18,6 @@ export * from "./input/index.js";
18
18
  export * from "./link/index.js";
19
19
  export * from "./loader/index.js";
20
20
  export * from "./modal/index.js";
21
- export * from "./modals/index.js";
22
21
  export * from "./nav-link/index.js";
23
22
  export * from "./paper.vue";
24
23
  export * from "./popover/index.js";
@@ -1,5 +1,4 @@
1
1
  export * from './use-active-link.js';
2
2
  export * from './use-date-config.js';
3
- export * from './use-modal.js';
4
3
  export * from './use-style-resolver.js';
5
4
  export * from './use-theme.js';
@@ -1,5 +1,4 @@
1
1
  export * from "./use-active-link.js";
2
2
  export * from "./use-date-config.js";
3
- export * from "./use-modal.js";
4
3
  export * from "./use-style-resolver.js";
5
4
  export * from "./use-theme.js";
@@ -1,8 +1,7 @@
1
- import type { MaybePromise } from '@nui/types';
2
- import type { ButtonProps } from '../../button/button.vue.js';
3
- import type { ModalRootProps } from '../../modal/modal-root.vue.js';
1
+ import type { ButtonProps, ModalRootProps } from '../../components/index.js';
2
+ import type { MaybePromise } from '../../types/index.js';
4
3
  type ConfirmLabels = Record<'confirm' | 'cancel', string>;
5
- export interface ConfirmModalProps extends ModalRootProps {
4
+ export interface ConfirmModalProps extends /* @vue-ignore */ ModalRootProps {
6
5
  /** Modal title */
7
6
  title: string;
8
7
  /** Description text displayed below the title */
@@ -1,11 +1,11 @@
1
1
  <script setup>
2
- import { useModal } from "@nui/composals";
3
2
  import { ref } from "vue";
4
- import Button from "../../button/button.vue";
5
- import ModalCloseButton from "../../modal/modal-close-button.vue";
6
- import ModalHeader from "../../modal/modal-header.vue";
7
- import ModalRoot from "../../modal/modal-root.vue";
8
- import Title from "../../title.vue";
3
+ import Button from "../../components/button/button.vue";
4
+ import ModalCloseButton from "../../components/modal/modal-close-button.vue";
5
+ import ModalHeader from "../../components/modal/modal-header.vue";
6
+ import ModalRoot from "../../components/modal/modal-root.vue";
7
+ import Title from "../../components/title.vue";
8
+ import { useModal } from "../use-modal";
9
9
  const {
10
10
  title,
11
11
  description: body,
@@ -25,22 +25,7 @@ const {
25
25
  onCancel: { type: Function, required: false },
26
26
  onConfirm: { type: Function, required: false },
27
27
  cancelProps: { type: Object, required: false },
28
- confirmProps: { type: Object, required: false },
29
- centered: { type: Boolean, required: false },
30
- fullScreen: { type: Boolean, required: false },
31
- closeOnClickOutside: { type: Boolean, required: false },
32
- withinPortal: { type: Boolean, required: false },
33
- withoutOverlay: { type: Boolean, required: false },
34
- yOffset: { type: void 0, required: false },
35
- xOffset: { type: void 0, required: false },
36
- radius: { type: [String, Number], required: false },
37
- size: { type: String, required: false },
38
- shadow: { type: String, required: false },
39
- padding: { type: [String, Number], required: false },
40
- transition: { type: String, required: false },
41
- portalTarget: { type: [String, Object, null], required: false },
42
- is: { type: null, required: false },
43
- mod: { type: [Object, Array, null], required: false }
28
+ confirmProps: { type: Object, required: false }
44
29
  });
45
30
  const { opened, resolve: hide } = useModal("confirm");
46
31
  const loading = ref(false);
@@ -1,8 +1,7 @@
1
- import type { MaybePromise } from '@nui/types';
2
- import type { ButtonProps } from '../../button/button.vue.js';
3
- import type { ModalRootProps } from '../../modal/modal-root.vue.js';
1
+ import type { ButtonProps, ModalRootProps } from '../../components/index.js';
2
+ import type { MaybePromise } from '../../types/index.js';
4
3
  type ConfirmLabels = Record<'confirm' | 'cancel', string>;
5
- export interface ConfirmModalProps extends ModalRootProps {
4
+ export interface ConfirmModalProps extends /* @vue-ignore */ ModalRootProps {
6
5
  /** Modal title */
7
6
  title: string;
8
7
  /** Description text displayed below the title */
@@ -4,5 +4,5 @@ import type { ConfirmModalProps } from './confirm-modal.vue.js';
4
4
  *
5
5
  * Resolves with `true` if the user confirmed, rejects if cancelled.
6
6
  */
7
- export declare const openConfirmModal: (props?: ConfirmModalProps | undefined) => Promise<boolean>;
7
+ export declare const openConfirmModal: (props?: any) => Promise<boolean>;
8
8
  export type { ConfirmModalProps };
@@ -1,4 +1,4 @@
1
- import { $modals } from "../../../plugins/modals/index.js";
1
+ import { $modals } from "../modal-manager.js";
2
2
  import ConfirmModal from "./confirm-modal.vue";
3
3
  export const openConfirmModal = $modals.create(
4
4
  "confirm",
@@ -0,0 +1,4 @@
1
+ export * from './_confirm-modal/index.js';
2
+ export { $modals } from './modal-manager.js';
3
+ export { default as NModalsProvider } from './modals-provider.vue.js';
4
+ export * from './use-modal.js';
@@ -0,0 +1,4 @@
1
+ export * from "./_confirm-modal/index.js";
2
+ export { $modals } from "./modal-manager.js";
3
+ export { default as NModalsProvider } from "./modals-provider.vue";
4
+ export * from "./use-modal.js";
@@ -29,10 +29,12 @@ export interface ModalState<Props extends object = object, Resolve = unknown, Re
29
29
  * const result = await open({ foo: 'bar' }) // result: string
30
30
  * ```
31
31
  */
32
- export declare class ModalManager {
32
+ declare class ModalManager {
33
33
  #private;
34
- /** Reactive map of all active modals. Used by `ModalProvider` for rendering */
35
- get modals(): import("vue").Reactive<Map<string, ModalState<object, unknown, unknown>>>;
34
+ /** Reactive map of active modals */
35
+ readonly modals: import("vue").Reactive<Map<string, ModalState<object, unknown, unknown>>>;
36
+ private constructor();
37
+ static get instance(): ModalManager;
36
38
  /**
37
39
  * Registers a modal component and returns a typed function to open it.
38
40
  */
@@ -76,3 +78,5 @@ export declare class ModalManager {
76
78
  */
77
79
  state<Props extends object = object, Resolve = unknown, Reject = unknown>(id: string): ModalState<Props, Resolve, Reject>;
78
80
  }
81
+ export declare const $modals: import("vue").Raw<ModalManager>;
82
+ export {};
@@ -1,35 +1,39 @@
1
1
  import { markRaw, reactive } from "vue";
2
- export class ModalManager {
2
+ class ModalManager {
3
+ static #instance = null;
3
4
  /** Reactive map of active modals */
4
- #modals = reactive(/* @__PURE__ */ new Map());
5
+ modals = reactive(/* @__PURE__ */ new Map());
5
6
  /** Eagerly registered components (id → Component) */
6
7
  #registered = /* @__PURE__ */ new Map();
7
8
  /** Lazily registered loaders (id → loader) */
8
9
  #lazy = /* @__PURE__ */ new Map();
9
- /** Reactive map of all active modals. Used by `ModalProvider` for rendering */
10
- get modals() {
11
- return this.#modals;
10
+ constructor() {
12
11
  }
13
12
  // ── Facade ──
13
+ static get instance() {
14
+ if (!this.#instance)
15
+ this.#instance = new ModalManager();
16
+ return this.#instance;
17
+ }
14
18
  /**
15
19
  * Registers a modal component and returns a typed function to open it.
16
20
  */
17
21
  create(id, component) {
18
- this.#registered.set(id, component);
19
- return (props) => this.#show(id, props ?? {});
22
+ ModalManager.instance.#registered.set(id, component);
23
+ return (props) => ModalManager.instance.#show(id, props ?? {});
20
24
  }
21
25
  /**
22
26
  * Registers a lazy modal — the component is loaded on first open.
23
27
  */
24
28
  createLazy(id, loader) {
25
- this.#lazy.set(id, loader);
26
- return (props) => this.#show(id, props ?? {});
29
+ ModalManager.instance.#lazy.set(id, loader);
30
+ return (props) => ModalManager.instance.#show(id, props ?? {});
27
31
  }
28
32
  /**
29
33
  * Opens a previously registered modal by its identifier.
30
34
  */
31
35
  async show(id, props = {}) {
32
- return this.#show(id, props);
36
+ return ModalManager.instance.#show(id, props);
33
37
  }
34
38
  /**
35
39
  * Closes the modal and resolves its promise with the given result.
@@ -38,7 +42,7 @@ export class ModalManager {
38
42
  * @param result — value the promise resolves with
39
43
  */
40
44
  resolve(id, result) {
41
- this.#resolve(id, result);
45
+ ModalManager.instance.#resolve(id, result);
42
46
  }
43
47
  /**
44
48
  * Closes the modal and rejects its promise with the given reason.
@@ -47,7 +51,7 @@ export class ModalManager {
47
51
  * @param reason — rejection reason
48
52
  */
49
53
  reject(id, reason) {
50
- this.#reject(id, reason);
54
+ ModalManager.instance.#reject(id, reason);
51
55
  }
52
56
  /**
53
57
  * Returns the reactive state of a specific modal as `ComputedRef<ModalState>`.
@@ -55,7 +59,7 @@ export class ModalManager {
55
59
  * Used inside a modal component (via {@link useModal}).
56
60
  */
57
61
  state(id) {
58
- return this.#modals.get(id);
62
+ return ModalManager.instance.modals.get(id);
59
63
  }
60
64
  // ── Private implementation ──
61
65
  async #show(id, props = {}) {
@@ -71,7 +75,7 @@ export class ModalManager {
71
75
  const component = this.#registered.get(id);
72
76
  if (!component)
73
77
  return Promise.reject(new Error(`Modal "${id}" is not registered`));
74
- const existing = this.#modals.get(id);
78
+ const existing = this.modals.get(id);
75
79
  return new Promise((resolve, reject) => {
76
80
  if (existing) {
77
81
  existing.props = props;
@@ -79,7 +83,7 @@ export class ModalManager {
79
83
  existing.resolve = resolve;
80
84
  existing.reject = reject;
81
85
  } else {
82
- this.#modals.set(id, {
86
+ this.modals.set(id, {
83
87
  id,
84
88
  component: markRaw(component),
85
89
  props,
@@ -91,17 +95,18 @@ export class ModalManager {
91
95
  });
92
96
  }
93
97
  #resolve(id, result) {
94
- const modal = this.#modals.get(id);
98
+ const modal = this.modals.get(id);
95
99
  if (!modal)
96
100
  return;
97
101
  modal.opened = false;
98
102
  modal.resolve?.(result);
99
103
  }
100
104
  #reject(id, reason) {
101
- const modal = this.#modals.get(id);
105
+ const modal = this.modals.get(id);
102
106
  if (!modal)
103
107
  return;
104
108
  modal.opened = false;
105
109
  modal.reject?.(reason);
106
110
  }
107
111
  }
112
+ export const $modals = markRaw(ModalManager.instance);
@@ -0,0 +1,16 @@
1
+ <script setup>
2
+ import { $modals } from "./modal-manager";
3
+ </script>
4
+
5
+ <template>
6
+ <ClientOnly>
7
+ <div id='nui-modals-root'>
8
+ <component
9
+ :is='entry.component'
10
+ v-for='[id, entry] in $modals.modals'
11
+ :key='id'
12
+ v-bind='entry.props'
13
+ />
14
+ </div>
15
+ </ClientOnly>
16
+ </template>
@@ -21,8 +21,8 @@ id: string): {
21
21
  *
22
22
  * Setting to `true` reopens the modal, setting to `false` calls `reject`
23
23
  */
24
- opened: import("vue").WritableComputedRef<any, boolean>;
24
+ opened: import("vue").WritableComputedRef<boolean, boolean>;
25
25
  /** closes the modal and resolves the promise */
26
- resolve: (reason: Resolve) => any;
27
- reject: () => any;
26
+ resolve: (reason: Resolve) => void;
27
+ reject: () => void;
28
28
  };
@@ -1,11 +1,10 @@
1
- import { useNuxtApp } from "#app";
2
1
  import { computed } from "vue";
2
+ import { $modals } from "./modal-manager.js";
3
3
  export function useModal(id) {
4
- const manager = useNuxtApp().$modals;
5
- const state = computed(() => manager.state(id));
4
+ const state = computed(() => $modals.state(id));
6
5
  const opened = computed({
7
6
  get: () => state.value?.opened,
8
- set: (opened2) => opened2 ? manager.show(id, state.value.props) : manager.reject(id, "cancel")
7
+ set: (opened2) => opened2 ? $modals.show(id, state.value.props) : $modals.reject(id, "cancel")
9
8
  });
10
9
  if (!state)
11
10
  throw new Error(`Modal ${id} is not exist`);
@@ -17,7 +16,7 @@ export function useModal(id) {
17
16
  */
18
17
  opened,
19
18
  /** closes the modal and resolves the promise */
20
- resolve: (reason) => manager.resolve(id, reason),
21
- reject: () => manager.reject(id)
19
+ resolve: (reason) => $modals.resolve(id, reason),
20
+ reject: () => $modals.reject(id)
22
21
  };
23
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuance-ui",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
4
4
  "description": "A UI Library for Modern Web Apps, powered by Vue.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- export * from './_confirm-modal/index.js';
@@ -1 +0,0 @@
1
- export * from "./_confirm-modal/index.js";
@@ -1,19 +0,0 @@
1
- <script setup>
2
- import { useNuxtApp } from "#app";
3
- import { ClientOnly } from "#components";
4
- import { computed } from "vue";
5
- const modals = computed(() => useNuxtApp().$modals?.modals ?? []);
6
- </script>
7
-
8
- <template>
9
- <ClientOnly>
10
- <div id='nui-modals-root'>
11
- <component
12
- :is='entry.component'
13
- v-for='[id, entry] in modals'
14
- :key='id'
15
- v-bind='entry.props'
16
- />
17
- </div>
18
- </ClientOnly>
19
- </template>
@@ -1 +0,0 @@
1
- export { $modals } from './plugin.client.js';
@@ -1 +0,0 @@
1
- export { $modals } from "./plugin.client.js";
@@ -1,8 +0,0 @@
1
- import { ModalManager } from './modal-manager.js';
2
- export declare const $modals: import("vue").Raw<ModalManager>;
3
- declare const _default: import("#app").Plugin<{
4
- modals: import("vue").Raw<ModalManager>;
5
- }> & import("#app").ObjectPlugin<{
6
- modals: import("vue").Raw<ModalManager>;
7
- }>;
8
- export default _default;
@@ -1,10 +0,0 @@
1
- import { defineNuxtPlugin, markRaw } from "#imports";
2
- import { ModalManager } from "./modal-manager.js";
3
- export const $modals = markRaw(new ModalManager());
4
- export default defineNuxtPlugin(() => {
5
- return {
6
- provide: {
7
- modals: $modals
8
- }
9
- };
10
- });