@juit/vue-modal 1.0.4 → 1.0.6

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/plugin.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { App, DefineComponent, EmitsOptions, Prop } from 'vue';
2
- declare type RequiredPropKeys<T> = {
1
+ import type { App, DefineComponent, EmitsOptions, Prop } from '@vue/runtime-core';
2
+ type RequiredPropKeys<T> = {
3
3
  [K in keyof T]: T[K] extends {
4
4
  required: true;
5
5
  } ? K : never;
6
6
  }[keyof T];
7
- declare type OptionalKeys<T> = Exclude<keyof T, RequiredPropKeys<T>>;
8
- declare type InferPropType<T> = [T] extends [null] ? any : [T] extends [
7
+ type OptionalKeys<T> = Exclude<keyof T, RequiredPropKeys<T>>;
8
+ type InferPropType<T> = [T] extends [null] ? any : [T] extends [
9
9
  {
10
10
  type: null | true;
11
11
  }
@@ -22,7 +22,7 @@ declare type InferPropType<T> = [T] extends [null] ? any : [T] extends [
22
22
  type: DateConstructor;
23
23
  }
24
24
  ] ? Date : [T] extends [Prop<infer V, infer D>] ? unknown extends V ? D : V : T;
25
- declare type InjectablePropTypes<O> = O extends object ? {
25
+ type InjectablePropTypes<O> = O extends object ? {
26
26
  [K in RequiredPropKeys<O>]: InferPropType<O[K]>;
27
27
  } & {
28
28
  [K in OptionalKeys<O>]?: InferPropType<O[K]>;
@@ -32,16 +32,16 @@ declare type InjectablePropTypes<O> = O extends object ? {
32
32
  declare type DismissModalType<E> = E extends {
33
33
  dismissModal: (...args: any[]) => any;
34
34
  } ? Parameters<E['dismissModal']>[0] : unknown;
35
- export declare type ModalStack = InstanceType<typeof ModalStackComponent>;
35
+ export type ModalStack = InstanceType<typeof ModalStackComponent>;
36
36
  export declare const ModalStackComponent: DefineComponent<{}, {}, {
37
37
  stack: string[];
38
38
  }, {
39
39
  hasModals(): boolean;
40
- }, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("modals" | "modalCreated" | "modalDismissed")[], "modals" | "modalCreated" | "modalDismissed", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{} & {} & {}> & {
40
+ }, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, ("modals" | "modalCreated" | "modalDismissed")[], "modals" | "modalCreated" | "modalDismissed", import("@vue/runtime-core").PublicProps, Readonly<{}> & Readonly<{
41
41
  onModals?: ((...args: any[]) => any) | undefined;
42
42
  onModalCreated?: ((...args: any[]) => any) | undefined;
43
43
  onModalDismissed?: ((...args: any[]) => any) | undefined;
44
- }, {}>;
44
+ }>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
45
45
  export declare function createModal<P, E extends EmitsOptions>(component: DefineComponent<P, any, any, any, any, any, any, E, any>, props?: InjectablePropTypes<P>): Promise<DismissModalType<E>>;
46
46
  declare module '@vue/runtime-core' {
47
47
  interface ComponentCustomProperties {
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.modals = exports.createModal = exports.ModalStackComponent = void 0;
4
- const vue_1 = require("vue");
3
+ exports.modals = exports.ModalStackComponent = void 0;
4
+ exports.createModal = createModal;
5
+ const runtime_core_1 = require("@vue/runtime-core");
5
6
  // A record of modal entries keyed by their IDs. This is necessary so that only
6
7
  // the `stack` array in `ModalStackComponent` is _reactive_ while all the
7
8
  // details associated with their life cycle is not!
@@ -9,7 +10,7 @@ const entries = {};
9
10
  // Current (available) `ModalStack`
10
11
  let modalStack = undefined;
11
12
  // Our modal stack component, rendering one after another all open modals
12
- exports.ModalStackComponent = (0, vue_1.defineComponent)({
13
+ exports.ModalStackComponent = (0, runtime_core_1.defineComponent)({
13
14
  emits: ['modals', 'modalCreated', 'modalDismissed'],
14
15
  data() {
15
16
  return { stack: [] };
@@ -22,7 +23,7 @@ exports.ModalStackComponent = (0, vue_1.defineComponent)({
22
23
  // Mounted here simply warns the about using <modal-stack/> multiple times
23
24
  mounted() {
24
25
  if (modalStack)
25
- (0, vue_1.warn)('Vue modal stack component mounted multiple times');
26
+ (0, runtime_core_1.warn)('Vue modal stack component mounted multiple times');
26
27
  else
27
28
  modalStack = this;
28
29
  },
@@ -51,12 +52,12 @@ exports.ModalStackComponent = (0, vue_1.defineComponent)({
51
52
  this.$emit('modals', this.hasModals);
52
53
  };
53
54
  // Render our component in the VNODE tree tracking `dismissModal` events
54
- const componentVNode = (0, vue_1.h)(entry.component, Object.assign(Object.assign({}, entry.props), { onDismissModal }));
55
+ const componentVNode = (0, runtime_core_1.h)(entry.component, Object.assign(Object.assign({}, entry.props), { onDismissModal }));
55
56
  // Emit our events
56
57
  this.$emit('modalDismissed', this.hasModals);
57
58
  this.$emit('modals', this.hasModals);
58
59
  // Nicely wrap our modal component in a DIV: one modal, one DIV
59
- return entry.vnode = (0, vue_1.h)('div', { [`data-modal-${id}`]: '' }, componentVNode);
60
+ return entry.vnode = (0, runtime_core_1.h)('div', { [`data-modal-${id}`]: '' }, componentVNode);
60
61
  });
61
62
  },
62
63
  });
@@ -67,7 +68,7 @@ exports.ModalStackComponent = (0, vue_1.defineComponent)({
67
68
  function createModal(component, props) {
68
69
  return new Promise((resolve, reject) => {
69
70
  if (!modalStack) {
70
- (0, vue_1.warn)('No ModalStack component mounted in current render tree');
71
+ (0, runtime_core_1.warn)('No ModalStack component mounted in current render tree');
71
72
  reject(new Error('No ModalStack avaible'));
72
73
  }
73
74
  // Get a random ID we can use to identify our DIVs
@@ -78,7 +79,6 @@ function createModal(component, props) {
78
79
  modalStack === null || modalStack === void 0 ? void 0 : modalStack.stack.push(id);
79
80
  });
80
81
  }
81
- exports.createModal = createModal;
82
82
  /**
83
83
  * The `vue-modals` plugin, instrumenting the `$createModal()` function on
84
84
  * components instances and providing the `<modal-stack/>` component.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"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,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;QAE/C,mEAAmE;QACnE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;QAC3C,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC;AAoBD;;;GAGG;AACU,QAAA,MAAM,GAAG;IACpB,OAAO,CAAC,GAAQ;QACd,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,YAAY,GAAG,WAAW,CAAA;QACtD,GAAG,CAAC,SAAS,CAAC,YAAY,EAAE,2BAAmB,CAAC,CAAA;IAClD,CAAC;CACF,CAAA"}
@@ -0,0 +1,88 @@
1
+ import { defineComponent, h, warn, } from '@vue/runtime-core';
2
+ // A record of modal entries keyed by their IDs. This is necessary so that only
3
+ // the `stack` array in `ModalStackComponent` is _reactive_ while all the
4
+ // details associated with their life cycle is not!
5
+ const entries = {};
6
+ // Current (available) `ModalStack`
7
+ let modalStack = undefined;
8
+ // Our modal stack component, rendering one after another all open modals
9
+ export const ModalStackComponent = defineComponent({
10
+ emits: ['modals', 'modalCreated', 'modalDismissed'],
11
+ data() {
12
+ return { stack: [] };
13
+ },
14
+ computed: {
15
+ hasModals() {
16
+ return this.stack.length > 0;
17
+ },
18
+ },
19
+ // Mounted here simply warns the about using <modal-stack/> multiple times
20
+ mounted() {
21
+ if (modalStack)
22
+ warn('Vue modal stack component mounted multiple times');
23
+ else
24
+ modalStack = this;
25
+ },
26
+ // BeforeUnmount removes the ability to create modals
27
+ beforeUnmount() {
28
+ if (modalStack === this)
29
+ modalStack = undefined;
30
+ },
31
+ // Render our stack of modals, one after another
32
+ render() {
33
+ return this.stack.map((id) => {
34
+ const entry = entries[id];
35
+ // If we created a vnode before, simply return it
36
+ if (entry.vnode)
37
+ return entry.vnode;
38
+ // Dismiss the modal, removing it from the stack, removing it from our
39
+ // keyed hash of modals, and finally resolving the promise with the result
40
+ const onDismissModal = (result) => {
41
+ const index = this.stack.indexOf(id);
42
+ if (index >= 0)
43
+ this.stack.splice(index, 1);
44
+ delete entries[id];
45
+ entry.resolve(result);
46
+ // Emit our events
47
+ this.$emit('modalCreated', this.hasModals);
48
+ this.$emit('modals', this.hasModals);
49
+ };
50
+ // Render our component in the VNODE tree tracking `dismissModal` events
51
+ const componentVNode = h(entry.component, Object.assign(Object.assign({}, entry.props), { onDismissModal }));
52
+ // Emit our events
53
+ this.$emit('modalDismissed', this.hasModals);
54
+ this.$emit('modals', this.hasModals);
55
+ // Nicely wrap our modal component in a DIV: one modal, one DIV
56
+ return entry.vnode = h('div', { [`data-modal-${id}`]: '' }, componentVNode);
57
+ });
58
+ },
59
+ });
60
+ /* ========================================================================== *
61
+ * CREATE MODAL *
62
+ * ========================================================================== */
63
+ // Push a new modal in our modals stack
64
+ export function createModal(component, props) {
65
+ return new Promise((resolve, reject) => {
66
+ if (!modalStack) {
67
+ warn('No ModalStack component mounted in current render tree');
68
+ reject(new Error('No ModalStack avaible'));
69
+ }
70
+ // Get a random ID we can use to identify our DIVs
71
+ const id = Math.floor((Math.random() * Number.MAX_SAFE_INTEGER))
72
+ .toString(16).substr(0, 8).padStart(8, '0');
73
+ // Push our ID, component, props and deferring methods in the stack
74
+ entries[id] = { component, props, resolve };
75
+ modalStack === null || modalStack === void 0 ? void 0 : modalStack.stack.push(id);
76
+ });
77
+ }
78
+ /**
79
+ * The `vue-modals` plugin, instrumenting the `$createModal()` function on
80
+ * components instances and providing the `<modal-stack/>` component.
81
+ */
82
+ export const modals = {
83
+ install(app) {
84
+ app.config.globalProperties.$createModal = createModal;
85
+ app.component('ModalStack', ModalStackComponent);
86
+ },
87
+ };
88
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src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AAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;QAE/C,mEAAmE;QACnE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;QAC3C,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC;AAoBD;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO,CAAC,GAAQ;QACd,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,YAAY,GAAG,WAAW,CAAA;QACtD,GAAG,CAAC,SAAS,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAAA;IAClD,CAAC;CACF,CAAA"}
@@ -0,0 +1,35 @@
1
+ import configurations from '@plugjs/eslint-plugin-vue'
2
+
3
+ export default [
4
+ ...configurations,
5
+
6
+ // ===== DEFINE THE LOCATION OF OUR TSCONFIG.JSON FILES ======================
7
+ {
8
+ name: 'local/options',
9
+
10
+ languageOptions: {
11
+ parserOptions: {
12
+ createDefaultProgram: true,
13
+ project: [
14
+ './tsconfig.json',
15
+ './tsconfig.app.json',
16
+ './tsconfig.node.json',
17
+ './worker/tsconfig.json',
18
+ ],
19
+ },
20
+ },
21
+ },
22
+
23
+ // ===== IGNORED FILES =======================================================
24
+ // REMEMBER! Ignores *must* be in its own configuration, they can not coexist
25
+ // with "rules", "languageOptions", "files", ... or anything else, otherwise
26
+ // ESLint will blaantly ignore the ignore files!
27
+ {
28
+ name: 'local/ignores',
29
+
30
+ ignores: [
31
+ 'dist/',
32
+ 'public/',
33
+ ],
34
+ },
35
+ ]
package/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "@juit/vue-modal",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "TypeScript Modals for Vue.js 3",
5
- "main": "dist/plugin.js",
5
+ "main": "dist-cjs/plugin.js",
6
+ "module": "dist-esm/plugin.js",
6
7
  "types": "dist/plugin.d.ts",
7
8
  "repository": {
8
9
  "type": "git",
9
10
  "url": "git+ssh://git@github.com/juitnow/juit-vue-modal.git"
10
11
  },
11
12
  "scripts": {
12
- "build": "rm -rf dist && npm run lint && npm run compile",
13
- "compile": "tsc",
13
+ "build": "npm run lint && npm run build-cjs && npm run build-esm && npm run build-dts",
14
+ "build-cjs": "rm -rf dist-cjs && tsc --module commonjs --outDir dist-cjs",
15
+ "build-esm": "rm -rf dist-esm && tsc --module es2020 --outDir dist-esm",
16
+ "build-dts": "rm -rf dist && tsc --declaration true --emitDeclarationOnly",
14
17
  "lint": "eslint src",
15
18
  "lintfix": "eslint --fix src"
16
19
  },
@@ -21,15 +24,12 @@
21
24
  },
22
25
  "homepage": "https://github.com/juitnow/juit-vue-modal#readme",
23
26
  "peerDependencies": {
24
- "vue": ">=3"
27
+ "@vue/runtime-core": ">=3"
25
28
  },
26
29
  "devDependencies": {
27
- "@typescript-eslint/eslint-plugin": "^4.31.1",
28
- "@typescript-eslint/parser": "^4.31.1",
29
- "eslint": "^7.32.0",
30
- "eslint-config-google": "^0.14.0",
31
- "eslint-plugin-deprecation": "^1.2.1",
32
- "typescript": "^4.4.3",
33
- "vue": "^3.2.11"
30
+ "@plugjs/eslint-plugin-vue": "^0.1.6",
31
+ "@vue/runtime-core": ">=3",
32
+ "eslint": "^9.38.0",
33
+ "typescript": "^5.9.3"
34
34
  }
35
35
  }
package/src/plugin.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  import {
2
+ defineComponent,
3
+ h,
4
+ warn,
5
+ } from '@vue/runtime-core'
6
+
7
+ import type {
2
8
  App,
3
9
  DefineComponent,
4
10
  EmitsOptions,
5
11
  Prop,
6
12
  VNode,
7
- defineComponent,
8
- h,
9
- warn,
10
- } from 'vue'
13
+ } from '@vue/runtime-core'
11
14
 
12
15
  /* ========================================================================== *
13
16
  * TYPES *
@@ -18,11 +21,11 @@ import {
18
21
  // in the prop definition, and ignore defaults.
19
22
  type RequiredPropKeys<T> = {
20
23
  [K in keyof T]: T[K] extends { required: true } ? K : never
21
- } [keyof T];
24
+ } [keyof T]
22
25
 
23
26
  // Extract the _optional_ property keys for a given component: this simply
24
27
  // negates `RequiredPropKeys` above.
25
- type OptionalKeys<T> = Exclude<keyof T, RequiredPropKeys<T>>;
28
+ type OptionalKeys<T> = Exclude<keyof T, RequiredPropKeys<T>>
26
29
 
27
30
  // Infer the type for a property: this is cloned straight from Vue's source,
28
31
  // as it's not an exported type, dammit!!! :-)
@@ -34,7 +37,7 @@ type InferPropType<T> = [T] extends [null] ? any : [T] extends [{
34
37
  type: BooleanConstructor;
35
38
  }] ? boolean : [T] extends [DateConstructor | {
36
39
  type: DateConstructor;
37
- }] ? Date : [T] extends [Prop<infer V, infer D>] ? unknown extends V ? D : V : T;
40
+ }] ? Date : [T] extends [Prop<infer V, infer D>] ? unknown extends V ? D : V : T
38
41
 
39
42
  // All _injectable_ properties (and types) for a component: this differs from
40
43
  // Vue's `ExtractPropTypes` (and it's simpler) as we simply want a Record of
@@ -45,13 +48,13 @@ type InjectablePropTypes<O> = O extends object ? {
45
48
  [K in OptionalKeys<O>]?: InferPropType<O[K]>;
46
49
  } : {
47
50
  [K in string]: any;
48
- };
51
+ }
49
52
 
50
53
  // The type of the _first_ parameter of the `dismissModal` emitter in a
51
54
  // component or `unknown`, to properly return the typed value to our callers
52
55
  declare type DismissModalType<E> =
53
- E extends { dismissModal : (...args: any[]) => any } ?
54
- Parameters<E['dismissModal']>[0] : unknown;
56
+ E extends { dismissModal: (...args: any[]) => any } ?
57
+ Parameters<E['dismissModal']>[0] : unknown
55
58
 
56
59
  /* ========================================================================== *
57
60
  * COMPONENTS *
@@ -92,7 +95,7 @@ export const ModalStackComponent = defineComponent({
92
95
  // Mounted here simply warns the about using <modal-stack/> multiple times
93
96
  mounted() {
94
97
  if (modalStack) warn('Vue modal stack component mounted multiple times')
95
- else modalStack = this
98
+ else modalStack = this as any
96
99
  },
97
100
 
98
101
  // BeforeUnmount removes the ability to create modals
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;AAAA,6BASY;AA2DZ,+EAA+E;AAC/E,yEAAyE;AACzE,mDAAmD;AACnD,MAAM,OAAO,GAA+B,EAAE,CAAA;AAK9C,mCAAmC;AACnC,IAAI,UAAU,GAA2B,SAAS,CAAA;AAElD,yEAAyE;AAC5D,QAAA,mBAAmB,GAAG,IAAA,qBAAe,EAAC;IACjD,KAAK,EAAE,CAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,CAAE;IACrD,IAAI;QACF,OAAO,EAAE,KAAK,EAAE,EAAc,EAAE,CAAA;IAClC,CAAC;IACD,QAAQ,EAAE;QACR,SAAS;YACP,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;QAC9B,CAAC;KACF;IAED,0EAA0E;IAC1E,OAAO;QACL,IAAI,UAAU;YAAE,IAAA,UAAI,EAAC,kDAAkD,CAAC,CAAA;;YACnE,UAAU,GAAG,IAAI,CAAA;IACxB,CAAC;IAED,qDAAqD;IACrD,aAAa;QACX,IAAI,UAAU,KAAK,IAAI;YAAE,UAAU,GAAG,SAAS,CAAA;IACjD,CAAC;IAED,gDAAgD;IAChD,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;YAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,EAAE,CAAC,CAAA;YAEzB,iDAAiD;YACjD,IAAI,KAAK,CAAC,KAAK;gBAAE,OAAO,KAAK,CAAC,KAAK,CAAA;YAEnC,sEAAsE;YACtE,0EAA0E;YAC1E,MAAM,cAAc,GAAG,CAAC,MAAW,EAAQ,EAAE;gBAC3C,MAAM,KAAK,GAAG,IAAI,CAA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