@maas/vue-equipment 0.7.6 → 0.7.8

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "configKey": "vueEquipment",
4
- "version": "0.7.5"
4
+ "version": "0.7.7"
5
5
  }
@@ -60,13 +60,22 @@ import {
60
60
  type MaybeRef,
61
61
  } from 'vue'
62
62
  import { onKeyStroke } from '@vueuse/core'
63
- import { defu } from 'defu'
64
63
  import { defaultOptions } from './../utils/defaultOptions'
65
64
  import { useModalApi } from './../composables/useModalApi'
66
65
  import { useModalCallback } from '../composables/private/useModalCallback'
67
66
 
68
67
  import type { Options } from './../types/index'
69
68
 
69
+ import { createDefu } from 'defu'
70
+
71
+ // Prevent keys array from being merged with default
72
+ const customDefu = createDefu((obj, key, value) => {
73
+ if (key === 'keys') {
74
+ obj[key] = value
75
+ return true
76
+ }
77
+ })
78
+
70
79
  interface MagicModalProps {
71
80
  id: MaybeRef<string>
72
81
  component?: Component
@@ -80,7 +89,7 @@ const props = withDefaults(defineProps<MagicModalProps>(), {
80
89
 
81
90
  const modal = ref<HTMLElement | undefined>(undefined)
82
91
  const modalApi = useModalApi(props.id, { focusTarget: modal })
83
- const mappedOptions = defu(props.options, defaultOptions)
92
+ const mappedOptions = customDefu(props.options, defaultOptions)
84
93
 
85
94
  const {
86
95
  isActive,
@@ -127,10 +136,14 @@ function onClose() {
127
136
  innerActive.value = false
128
137
  }
129
138
 
130
- onKeyStroke('Escape', (e) => {
131
- e.preventDefault()
132
- close()
133
- })
139
+ if (mappedOptions.keys) {
140
+ for (const key of mappedOptions.keys) {
141
+ onKeyStroke(key, (e) => {
142
+ e.preventDefault()
143
+ close()
144
+ })
145
+ }
146
+ }
134
147
 
135
148
  watch(isActive, async (value) => {
136
149
  if (value) {
@@ -1,4 +1,4 @@
1
- import { crypto } from "@maas/vue-equipment/utils";
1
+ import { uuid } from "@maas/vue-equipment/utils";
2
2
  import { ref, computed, toValue } from "vue";
3
3
  import { defu } from "defu";
4
4
  import { useScrollLock } from "@vueuse/core";
@@ -10,7 +10,7 @@ const defaultOptions = {
10
10
  };
11
11
  export function useModalApi(id, options) {
12
12
  const positionFixedElements = ref([]);
13
- const mappedId = computed(() => toValue(id) || crypto.randomUUID());
13
+ const mappedId = computed(() => toValue(id) || uuid());
14
14
  const mappedOptions = defu(options, defaultOptions);
15
15
  const focusTrap = mappedOptions.focusTarget ? useFocusTrap(mappedOptions.focusTarget) : void 0;
16
16
  const scrollLock = mappedOptions.scrollLock && typeof window !== "undefined" ? useScrollLock(document.body) : ref(false);
@@ -11,6 +11,7 @@ type Options = {
11
11
  content?: string;
12
12
  backdrop?: string;
13
13
  };
14
+ keys?: string[] | false;
14
15
  };
15
16
  type ModalEvents = {
16
17
  beforeEnter: string;
@@ -10,6 +10,7 @@ const defaultOptions = {
10
10
  transitions: {
11
11
  content: "magic-modal--content",
12
12
  backdrop: "magic-modal--backdrop"
13
- }
13
+ },
14
+ keys: ["Escape"]
14
15
  };
15
16
  export { defaultOptions };
@@ -43,7 +43,7 @@
43
43
  </template>
44
44
 
45
45
  <script setup lang="ts">
46
- import { crypto } from '@maas/vue-equipment/utils'
46
+ import { uuid } from '@maas/vue-equipment/utils'
47
47
  import { defu } from 'defu'
48
48
  import { toValue, ref, watch, type MaybeRef } from 'vue'
49
49
  import { onClickOutside, type MaybeElement } from '@vueuse/core'
@@ -67,7 +67,7 @@ const { toasts, count, oldest } = useToastApi(props.id)
67
67
 
68
68
  const mappedOptions = defu(props.options, defaultOptions)
69
69
  const isExpanded = ref(mappedOptions.layout?.expand === true)
70
- const teleportKey = ref(crypto.randomUUID())
70
+ const teleportKey = ref(uuid())
71
71
  const listRef = ref<MaybeElement>()
72
72
 
73
73
  const {
@@ -107,7 +107,7 @@ function outsideClickCallback() {
107
107
  onClickOutside(listRef, outsideClickCallback)
108
108
  watch(
109
109
  () => props.id,
110
- () => (teleportKey.value = crypto.randomUUID()),
110
+ () => (teleportKey.value = uuid()),
111
111
  )
112
112
  </script>
113
113
 
@@ -1,4 +1,4 @@
1
- import { crypto } from "@maas/vue-equipment/utils";
1
+ import { uuid } from "@maas/vue-equipment/utils";
2
2
  export function useToastInternalApi() {
3
3
  function removeToastAfterTimeout(id, duration, ctx) {
4
4
  if (duration > 0) {
@@ -8,7 +8,7 @@ export function useToastInternalApi() {
8
8
  }
9
9
  }
10
10
  function addToast(args, ctx) {
11
- const id = crypto.randomUUID();
11
+ const id = uuid();
12
12
  let { component, props, duration = 0 } = args;
13
13
  const toast = {
14
14
  component,
@@ -1,4 +1,4 @@
1
- import { crypto } from "@maas/vue-equipment/utils";
1
+ import { uuid } from "@maas/vue-equipment/utils";
2
2
  import {
3
3
  computed,
4
4
  onUnmounted,
@@ -9,7 +9,7 @@ import {
9
9
  import { useToastStore } from "./private/useToastStore.mjs";
10
10
  export function useToastApi(id) {
11
11
  const { findInstance, addInstance, removeInstance } = useToastStore();
12
- const mappedId = computed(() => toValue(id) || crypto.randomUUID());
12
+ const mappedId = computed(() => toValue(id) || uuid());
13
13
  const instance = computed(() => findInstance(toValue(mappedId)));
14
14
  function initialize() {
15
15
  const id2 = toValue(mappedId);
@@ -4,6 +4,8 @@ declare function isIOS(): boolean;
4
4
 
5
5
  declare function mapValue(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
6
6
 
7
- declare const crypto: any;
7
+ declare function uuid(): `${string}-${string}-${string}-${string}-${string}`;
8
8
 
9
- export { clampValue, crypto, isIOS, mapValue };
9
+ declare function uniq<T extends any[]>(a: T): any[];
10
+
11
+ export { clampValue, isIOS, mapValue, uniq, uuid };
@@ -4,6 +4,8 @@ declare function isIOS(): boolean;
4
4
 
5
5
  declare function mapValue(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
6
6
 
7
- declare const crypto: any;
7
+ declare function uuid(): `${string}-${string}-${string}-${string}-${string}`;
8
8
 
9
- export { clampValue, crypto, isIOS, mapValue };
9
+ declare function uniq<T extends any[]>(a: T): any[];
10
+
11
+ export { clampValue, isIOS, mapValue, uniq, uuid };
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,15 +17,24 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // index.ts
21
31
  var utils_exports = {};
22
32
  __export(utils_exports, {
23
33
  clampValue: () => clampValue,
24
- crypto: () => crypto,
25
34
  isIOS: () => isIOS,
26
- mapValue: () => mapValue
35
+ mapValue: () => mapValue,
36
+ uniq: () => uniq,
37
+ uuid: () => uuid
27
38
  });
28
39
  module.exports = __toCommonJS(utils_exports);
29
40
 
@@ -44,13 +55,23 @@ function mapValue(value, inMin, inMax, outMin, outMax) {
44
55
  return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
45
56
  }
46
57
 
47
- // src/functions/crypto.ts
48
- var crypto = typeof window === "undefined" ? require("crypto") : window.crypto;
58
+ // src/functions/uuid.ts
59
+ var import_crypto = __toESM(require("crypto"));
60
+ var isBrowser = typeof window !== "undefined";
61
+ function uuid() {
62
+ return isBrowser ? window.crypto.randomUUID() : import_crypto.default.randomUUID();
63
+ }
64
+
65
+ // src/functions/uniq.ts
66
+ function uniq(a) {
67
+ return Array.from(new Set(a));
68
+ }
49
69
  // Annotate the CommonJS export names for ESM import in node:
50
70
  0 && (module.exports = {
51
71
  clampValue,
52
- crypto,
53
72
  isIOS,
54
- mapValue
73
+ mapValue,
74
+ uniq,
75
+ uuid
55
76
  });
56
77
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../packages/utils/index.ts","../../packages/utils/src/functions/clampValue.ts","../../packages/utils/src/functions/isIOS.ts","../../packages/utils/src/functions/mapValue.ts","../../packages/utils/src/functions/crypto.ts"],"sourcesContent":["export * from './src/functions/clampValue'\nexport * from './src/functions/isIOS'\nexport * from './src/functions/mapValue'\nexport * from './src/functions/crypto'\n","export function clampValue(value: number, min: number, max: number) {\n return value <= min ? min : value >= max ? max : value\n}\n","export function isIOS() {\n if (typeof window === 'undefined') return false\n return /iPad|iPhone|iPod/.test(navigator?.userAgent)\n}\n","export function mapValue(\n value: number,\n inMin: number,\n inMax: number,\n outMin: number,\n outMax: number,\n) {\n return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin\n}\n","export const crypto =\n typeof window === 'undefined' ? require('crypto') : window.crypto\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,WAAW,OAAe,KAAa,KAAa;AAClE,SAAO,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM;AACnD;;;ACFO,SAAS,QAAQ;AACtB,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,SAAO,mBAAmB,KAAK,WAAW,SAAS;AACrD;;;ACHO,SAAS,SACd,OACA,OACA,OACA,QACA,QACA;AACA,UAAS,QAAQ,UAAU,SAAS,WAAY,QAAQ,SAAS;AACnE;;;ACRO,IAAM,SACX,OAAO,WAAW,cAAc,QAAQ,QAAQ,IAAI,OAAO;","names":[]}
1
+ {"version":3,"sources":["../../packages/utils/index.ts","../../packages/utils/src/functions/clampValue.ts","../../packages/utils/src/functions/isIOS.ts","../../packages/utils/src/functions/mapValue.ts","../../packages/utils/src/functions/uuid.ts","../../packages/utils/src/functions/uniq.ts"],"sourcesContent":["export * from './src/functions/clampValue'\nexport * from './src/functions/isIOS'\nexport * from './src/functions/mapValue'\nexport * from './src/functions/uuid'\nexport * from './src/functions/uniq'\n","export function clampValue(value: number, min: number, max: number) {\n return value <= min ? min : value >= max ? max : value\n}\n","export function isIOS() {\n if (typeof window === 'undefined') return false\n return /iPad|iPhone|iPod/.test(navigator?.userAgent)\n}\n","export function mapValue(\n value: number,\n inMin: number,\n inMax: number,\n outMin: number,\n outMax: number,\n) {\n return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin\n}\n","import crypto from 'crypto'\nconst isBrowser = typeof window !== 'undefined'\n\nexport function uuid() {\n return isBrowser ? window.crypto.randomUUID() : crypto.randomUUID()\n}\n","export function uniq<T extends any[]>(a: T) {\n return Array.from(new Set(a))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,WAAW,OAAe,KAAa,KAAa;AAClE,SAAO,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM;AACnD;;;ACFO,SAAS,QAAQ;AACtB,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,SAAO,mBAAmB,KAAK,WAAW,SAAS;AACrD;;;ACHO,SAAS,SACd,OACA,OACA,OACA,QACA,QACA;AACA,UAAS,QAAQ,UAAU,SAAS,WAAY,QAAQ,SAAS;AACnE;;;ACRA,oBAAmB;AACnB,IAAM,YAAY,OAAO,WAAW;AAE7B,SAAS,OAAO;AACrB,SAAO,YAAY,OAAO,OAAO,WAAW,IAAI,cAAAA,QAAO,WAAW;AACpE;;;ACLO,SAAS,KAAsB,GAAM;AAC1C,SAAO,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC;AAC9B;","names":["crypto"]}
@@ -1,11 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
1
  // src/functions/clampValue.ts
10
2
  function clampValue(value, min, max) {
11
3
  return value <= min ? min : value >= max ? max : value;
@@ -23,12 +15,22 @@ function mapValue(value, inMin, inMax, outMin, outMax) {
23
15
  return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
24
16
  }
25
17
 
26
- // src/functions/crypto.ts
27
- var crypto = typeof window === "undefined" ? __require("crypto") : window.crypto;
18
+ // src/functions/uuid.ts
19
+ import crypto from "crypto";
20
+ var isBrowser = typeof window !== "undefined";
21
+ function uuid() {
22
+ return isBrowser ? window.crypto.randomUUID() : crypto.randomUUID();
23
+ }
24
+
25
+ // src/functions/uniq.ts
26
+ function uniq(a) {
27
+ return Array.from(new Set(a));
28
+ }
28
29
  export {
29
30
  clampValue,
30
- crypto,
31
31
  isIOS,
32
- mapValue
32
+ mapValue,
33
+ uniq,
34
+ uuid
33
35
  };
34
36
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../packages/utils/src/functions/clampValue.ts","../../packages/utils/src/functions/isIOS.ts","../../packages/utils/src/functions/mapValue.ts","../../packages/utils/src/functions/crypto.ts"],"sourcesContent":["export function clampValue(value: number, min: number, max: number) {\n return value <= min ? min : value >= max ? max : value\n}\n","export function isIOS() {\n if (typeof window === 'undefined') return false\n return /iPad|iPhone|iPod/.test(navigator?.userAgent)\n}\n","export function mapValue(\n value: number,\n inMin: number,\n inMax: number,\n outMin: number,\n outMax: number,\n) {\n return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin\n}\n","export const crypto =\n typeof window === 'undefined' ? require('crypto') : window.crypto\n"],"mappings":";;;;;;;;;AAAO,SAAS,WAAW,OAAe,KAAa,KAAa;AAClE,SAAO,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM;AACnD;;;ACFO,SAAS,QAAQ;AACtB,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,SAAO,mBAAmB,KAAK,WAAW,SAAS;AACrD;;;ACHO,SAAS,SACd,OACA,OACA,OACA,QACA,QACA;AACA,UAAS,QAAQ,UAAU,SAAS,WAAY,QAAQ,SAAS;AACnE;;;ACRO,IAAM,SACX,OAAO,WAAW,cAAc,UAAQ,QAAQ,IAAI,OAAO;","names":[]}
1
+ {"version":3,"sources":["../../packages/utils/src/functions/clampValue.ts","../../packages/utils/src/functions/isIOS.ts","../../packages/utils/src/functions/mapValue.ts","../../packages/utils/src/functions/uuid.ts","../../packages/utils/src/functions/uniq.ts"],"sourcesContent":["export function clampValue(value: number, min: number, max: number) {\n return value <= min ? min : value >= max ? max : value\n}\n","export function isIOS() {\n if (typeof window === 'undefined') return false\n return /iPad|iPhone|iPod/.test(navigator?.userAgent)\n}\n","export function mapValue(\n value: number,\n inMin: number,\n inMax: number,\n outMin: number,\n outMax: number,\n) {\n return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin\n}\n","import crypto from 'crypto'\nconst isBrowser = typeof window !== 'undefined'\n\nexport function uuid() {\n return isBrowser ? window.crypto.randomUUID() : crypto.randomUUID()\n}\n","export function uniq<T extends any[]>(a: T) {\n return Array.from(new Set(a))\n}\n"],"mappings":";AAAO,SAAS,WAAW,OAAe,KAAa,KAAa;AAClE,SAAO,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM;AACnD;;;ACFO,SAAS,QAAQ;AACtB,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,SAAO,mBAAmB,KAAK,WAAW,SAAS;AACrD;;;ACHO,SAAS,SACd,OACA,OACA,OACA,QACA,QACA;AACA,UAAS,QAAQ,UAAU,SAAS,WAAY,QAAQ,SAAS;AACnE;;;ACRA,OAAO,YAAY;AACnB,IAAM,YAAY,OAAO,WAAW;AAE7B,SAAS,OAAO;AACrB,SAAO,YAAY,OAAO,OAAO,WAAW,IAAI,OAAO,WAAW;AACpE;;;ACLO,SAAS,KAAsB,GAAM;AAC1C,SAAO,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC;AAC9B;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "description": "A magic collection of Vue composables, plugins, components and directives",
4
- "version": "0.7.6",
4
+ "version": "0.7.8",
5
5
  "author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
6
6
  "devDependencies": {
7
7
  "@antfu/ni": "^0.21.5",
@@ -67,8 +67,7 @@
67
67
  "luxon": "^3.4.2",
68
68
  "mitt": "^3.0.1",
69
69
  "motion": "^10.16.2",
70
- "nuxt": "^3.5.1",
71
- "uuid": "^9.0.0"
70
+ "nuxt": "^3.5.1"
72
71
  },
73
72
  "peerDependenciesMeta": {
74
73
  "@maas/magic-timer": {
@@ -94,9 +93,6 @@
94
93
  },
95
94
  "nuxt": {
96
95
  "optional": false
97
- },
98
- "uuid": {
99
- "optional": false
100
96
  }
101
97
  },
102
98
  "scripts": {