@leaflink/stash 42.2.0 → 42.4.0

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/PlaidLink.js CHANGED
@@ -1,6 +1,6 @@
1
- import { defineComponent as w, computed as y, ref as u, openBlock as E, createElementBlock as S, renderSlot as h } from "vue";
1
+ import { defineComponent as y, computed as E, ref as p, openBlock as S, createElementBlock as h, renderSlot as x } from "vue";
2
2
  import l from "@leaflink/snitch";
3
- const T = /* @__PURE__ */ w({
3
+ const _ = /* @__PURE__ */ y({
4
4
  __name: "PlaidLink",
5
5
  props: {
6
6
  initScriptUrl: { default: "https://cdn.plaid.com/link/v2/stable/link-initialize.js" },
@@ -11,16 +11,16 @@ const T = /* @__PURE__ */ w({
11
11
  createToken: { type: Function, default: void 0 }
12
12
  },
13
13
  emits: ["error", "success", "exit", "load", "event"],
14
- setup(p, { emit: n }) {
15
- const t = p, s = y(() => t.storageKey ? t.storageKey : `${window.location.host.split(".").splice(-3).join(".")}-plaid`), i = u(""), a = u(!1), v = (e, r) => {
14
+ setup(v, { expose: f, emit: n }) {
15
+ const t = v, s = E(() => t.storageKey ? t.storageKey : `${window.location.host.split(".").splice(-3).join(".")}-plaid`), i = p(""), a = p(!1), k = (e, r) => {
16
16
  a.value = !1, e && (l.error(new Error("Plaid: Error trying to link an account"), {
17
17
  tags: { plaid: !0 },
18
18
  extra: { PlaidError: e }
19
19
  }), n("error", e, r)), sessionStorage.removeItem(s.value), n("exit", r);
20
- }, f = (e, r) => {
20
+ }, g = (e, r) => {
21
21
  a.value = !1, sessionStorage.removeItem(s.value), n("success", e, r);
22
- }, k = (...e) => n("load", ...e), g = (...e) => n("event", ...e);
23
- async function m() {
22
+ }, m = (...e) => n("load", ...e), w = (...e) => n("event", ...e);
23
+ async function c() {
24
24
  if (a.value !== !0) {
25
25
  if (a.value = !0, typeof t.createToken == "function")
26
26
  try {
@@ -43,33 +43,35 @@ const T = /* @__PURE__ */ w({
43
43
  sessionStorage.setItem(
44
44
  s.value,
45
45
  JSON.stringify({ token: i.value, returnTo: t.returnTo, env: t.env })
46
- ), window.Plaid || await c(), window.Plaid.create({
46
+ ), window.Plaid || await d(), window.Plaid.create({
47
47
  token: i.value,
48
48
  env: t.env,
49
- onExit: v,
50
- onSuccess: f,
51
- onEvent: g,
52
- onLoad: k
49
+ onExit: k,
50
+ onSuccess: g,
51
+ onEvent: w,
52
+ onLoad: m
53
53
  }).open();
54
54
  }
55
55
  }
56
- function c() {
56
+ function d() {
57
57
  return new Promise(function(e, r) {
58
- const d = document.querySelector('script[src="' + t.initScriptUrl + '"]');
59
- d && d.remove();
58
+ const u = document.querySelector('script[src="' + t.initScriptUrl + '"]');
59
+ u && u.remove();
60
60
  const o = document.createElement("script");
61
61
  o.type = "text/javascript", o.async = !0, o.src = t.initScriptUrl, o.addEventListener("load", () => e()), o.addEventListener("error", r), o.addEventListener("abort", r), document.head.appendChild(o);
62
62
  });
63
63
  }
64
- return c(), (e, r) => (E(), S("span", {
64
+ return d(), f({
65
+ handleClick: c
66
+ }), (e, r) => (S(), h("span", {
65
67
  "data-test": "stash-plaid-link",
66
- onClick: m
68
+ onClick: c
67
69
  }, [
68
- h(e.$slots, "default", { open: a.value })
70
+ x(e.$slots, "default", { open: a.value })
69
71
  ]));
70
72
  }
71
73
  });
72
74
  export {
73
- T as default
75
+ _ as default
74
76
  };
75
77
  //# sourceMappingURL=PlaidLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlaidLink.js","sources":["../src/components/PlaidLink/PlaidLink.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import logger from '@leaflink/snitch';\n import { Plaid } from 'plaid-link';\n import { computed, ref } from 'vue';\n\n export interface LinkTokenResponse {\n link_token: string;\n /**\n * expiration date in ISO-8601 format\n */\n expiration: string;\n request_id: string;\n }\n\n export interface PlaidLinkProps {\n /**\n * Plaid initialization script url to be used\n */\n initScriptUrl?: string;\n\n /**\n * Key to be used in session storage for OAuth flow\n */\n storageKey?: string;\n\n /**\n * Url to be used to redirect the user from the OAuth flow\n */\n returnTo?: string;\n\n /**\n * Plaid link token\n */\n token?: string;\n\n /**\n * Plaid environment to connect\n */\n env?: Plaid.Environment;\n\n /**\n * Function that returns a link token object to be used with Plaid.\n * `link_token` takes precedence over `token` if informed.\n */\n createToken?: () => Promise<LinkTokenResponse>;\n }\n\n const props = withDefaults(defineProps<PlaidLinkProps>(), {\n initScriptUrl: 'https://cdn.plaid.com/link/v2/stable/link-initialize.js',\n storageKey: undefined,\n returnTo: window.location.href,\n env: 'sandbox',\n token: undefined,\n createToken: undefined,\n });\n\n const internalStorageKey = computed(() => {\n if (props.storageKey) {\n return props.storageKey;\n }\n\n // returns up to the last 3 parts of the host. e.g. for `subdomain.my.domain.com` it will return `my.domain.com`\n const host = window.location.host.split('.').splice(-3).join('.');\n\n return `${host}-plaid`;\n });\n\n const internalToken = ref('');\n\n const emit =\n defineEmits<{\n /**\n * Emitted whenever the exit event contains errors\n */\n (e: 'error', error: Plaid.Error | null | Error, metadata?: Plaid.OnExitMetaData): void;\n /**\n * Emitted whenever the user successfully links an item\n */\n (e: 'success', public_token: string, metadata: Plaid.OnSuccessMetaData): void;\n /**\n * Emitted whenever the user exits the Link flow\n */\n (e: 'exit', metadata: Plaid.OnExitMetaData): void;\n /**\n * Emitted when the Link is ready to be opened\n */\n (e: 'load'): void;\n /**\n * Emitted at specific points during the Link flow\n */\n (e: 'event', eventName: Plaid.EventName, metadata: Plaid.OnEventMetaData): void;\n }>();\n\n const isPlaidModalOpen = ref(false);\n\n const onExit: Plaid.OnExit = (error: Plaid.Error | null, metadata: Plaid.OnExitMetaData) => {\n isPlaidModalOpen.value = false;\n\n if (error) {\n logger.error(new Error('Plaid: Error trying to link an account'), {\n tags: { plaid: true },\n extra: { PlaidError: error },\n });\n emit('error', error, metadata);\n }\n\n sessionStorage.removeItem(internalStorageKey.value);\n\n emit('exit', metadata);\n };\n\n const onSuccess: Plaid.OnSuccess = (public_token: string, metadata: Plaid.OnSuccessMetaData) => {\n isPlaidModalOpen.value = false;\n\n sessionStorage.removeItem(internalStorageKey.value);\n\n emit('success', public_token, metadata);\n };\n\n const onLoad: Plaid.OnLoad = (...args) => emit('load', ...args);\n\n const onEvent: Plaid.OnEvent = (...args) => emit('event', ...args);\n\n async function handleClick() {\n if (isPlaidModalOpen.value === true) {\n return;\n }\n\n isPlaidModalOpen.value = true;\n\n if (typeof props.createToken === 'function') {\n try {\n const { link_token } = await props.createToken();\n\n internalToken.value = link_token;\n } catch (err) {\n const error = new Error('Plaid: Error trying to invoke createToken');\n\n logger.error(error, {\n tags: { plaid: true },\n extra: { error: err },\n });\n\n emit('error', error);\n }\n } else if (props.token) {\n internalToken.value = props.token;\n }\n\n if (!internalToken.value) {\n const error = new Error('Plaid: link token not found');\n\n logger.error(error, { tags: { plaid: true } });\n emit('error', error);\n\n isPlaidModalOpen.value = false;\n\n return;\n }\n\n sessionStorage.setItem(\n internalStorageKey.value,\n JSON.stringify({ token: internalToken.value, returnTo: props.returnTo, env: props.env }),\n );\n\n // Retries Plaid's script initialization if not loaded yet\n if (!window.Plaid) {\n await loadPlaidScript();\n }\n\n window.Plaid.create({\n token: internalToken.value,\n env: props.env,\n onExit,\n onSuccess,\n onEvent,\n onLoad,\n }).open();\n }\n\n function loadPlaidScript() {\n return new Promise<void>(function (resolve, reject) {\n const existingScript = document.querySelector('script[src=\"' + props.initScriptUrl + '\"]');\n\n if (existingScript) {\n existingScript.remove();\n }\n\n const el = document.createElement('script');\n\n el.type = 'text/javascript';\n el.async = true;\n el.src = props.initScriptUrl;\n el.addEventListener('load', () => resolve());\n el.addEventListener('error', reject);\n el.addEventListener('abort', reject);\n document.head.appendChild(el);\n });\n }\n\n loadPlaidScript();\n</script>\n\n<template>\n <span data-test=\"stash-plaid-link\" @click=\"handleClick\">\n <!-- @slot Default slot to trigger Plaid's modal -->\n <slot :open=\"isPlaidModalOpen\"></slot>\n </span>\n</template>\n"],"names":["internalStorageKey","computed","props","internalToken","ref","isPlaidModalOpen","onExit","error","metadata","logger","emit","onSuccess","public_token","onLoad","args","onEvent","handleClick","link_token","err","loadPlaidScript","resolve","reject","existingScript","el"],"mappings":";;;;;;;;;;;;;;iBAwDQA,IAAqBC,EAAS,MAC9BC,EAAM,aACDA,EAAM,aAMR,GAFM,OAAO,SAAS,KAAK,MAAM,GAAG,EAAE,OAAO,EAAE,EAAE,KAAK,GAAG,CAElD,QACf,GAEKC,IAAgBC,EAAI,EAAE,GA0BtBC,IAAmBD,EAAI,EAAK,GAE5BE,IAAuB,CAACC,GAA2BC,MAAmC;AAC1F,MAAAH,EAAiB,QAAQ,IAErBE,MACFE,EAAO,MAAM,IAAI,MAAM,wCAAwC,GAAG;AAAA,QAChE,MAAM,EAAE,OAAO,GAAK;AAAA,QACpB,OAAO,EAAE,YAAYF,EAAM;AAAA,MAAA,CAC5B,GACIG,EAAA,SAASH,GAAOC,CAAQ,IAGhB,eAAA,WAAWR,EAAmB,KAAK,GAElDU,EAAK,QAAQF,CAAQ;AAAA,IAAA,GAGjBG,IAA6B,CAACC,GAAsBJ,MAAsC;AAC9F,MAAAH,EAAiB,QAAQ,IAEV,eAAA,WAAWL,EAAmB,KAAK,GAE7CU,EAAA,WAAWE,GAAcJ,CAAQ;AAAA,IAAA,GAGlCK,IAAuB,IAAIC,MAASJ,EAAK,QAAQ,GAAGI,CAAI,GAExDC,IAAyB,IAAID,MAASJ,EAAK,SAAS,GAAGI,CAAI;AAEjE,mBAAeE,IAAc;AACvB,UAAAX,EAAiB,UAAU,IAM3B;AAAA,YAFJA,EAAiB,QAAQ,IAErB,OAAOH,EAAM,eAAgB;AAC3B,cAAA;AACF,kBAAM,EAAE,YAAAe,EAAe,IAAA,MAAMf,EAAM,YAAY;AAE/C,YAAAC,EAAc,QAAQc;AAAA,mBACfC,GAAK;AACN,kBAAAX,IAAQ,IAAI,MAAM,2CAA2C;AAEnE,YAAAE,EAAO,MAAMF,GAAO;AAAA,cAClB,MAAM,EA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Link.js","sources":["../src/components/PlaidLink/PlaidLink.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import logger from '@leaflink/snitch';\n import { Plaid } from 'plaid-link';\n import { computed, ref } from 'vue';\n\n export interface LinkTokenResponse {\n link_token: string;\n /**\n * expiration date in ISO-8601 format\n */\n expiration: string;\n request_id: string;\n }\n\n export interface PlaidLinkProps {\n /**\n * Plaid initialization script url to be used\n */\n initScriptUrl?: string;\n\n /**\n * Key to be used in session storage for OAuth flow\n */\n storageKey?: string;\n\n /**\n * Url to be used to redirect the user from the OAuth flow\n */\n returnTo?: string;\n\n /**\n * Plaid link token\n */\n token?: string;\n\n /**\n * Plaid environment to connect\n */\n env?: Plaid.Environment;\n\n /**\n * Function that returns a link token object to be used with Plaid.\n * `link_token` takes precedence over `token` if informed.\n */\n createToken?: () => Promise<LinkTokenResponse>;\n }\n\n const props = withDefaults(defineProps<PlaidLinkProps>(), {\n initScriptUrl: 'https://cdn.plaid.com/link/v2/stable/link-initialize.js',\n storageKey: undefined,\n returnTo: window.location.href,\n env: 'sandbox',\n token: undefined,\n createToken: undefined,\n });\n\n const internalStorageKey = computed(() => {\n if (props.storageKey) {\n return props.storageKey;\n }\n\n // returns up to the last 3 parts of the host. e.g. for `subdomain.my.domain.com` it will return `my.domain.com`\n const host = window.location.host.split('.').splice(-3).join('.');\n\n return `${host}-plaid`;\n });\n\n const internalToken = ref('');\n\n const emit =\n defineEmits<{\n /**\n * Emitted whenever the exit event contains errors\n */\n (e: 'error', error: Plaid.Error | null | Error, metadata?: Plaid.OnExitMetaData): void;\n /**\n * Emitted whenever the user successfully links an item\n */\n (e: 'success', public_token: string, metadata: Plaid.OnSuccessMetaData): void;\n /**\n * Emitted whenever the user exits the Link flow\n */\n (e: 'exit', metadata: Plaid.OnExitMetaData): void;\n /**\n * Emitted when the Link is ready to be opened\n */\n (e: 'load'): void;\n /**\n * Emitted at specific points during the Link flow\n */\n (e: 'event', eventName: Plaid.EventName, metadata: Plaid.OnEventMetaData): void;\n }>();\n\n const isPlaidModalOpen = ref(false);\n\n const onExit: Plaid.OnExit = (error: Plaid.Error | null, metadata: Plaid.OnExitMetaData) => {\n isPlaidModalOpen.value = false;\n\n if (error) {\n logger.error(new Error('Plaid: Error trying to link an account'), {\n tags: { plaid: true },\n extra: { PlaidError: error },\n });\n emit('error', error, metadata);\n }\n\n sessionStorage.removeItem(internalStorageKey.value);\n\n emit('exit', metadata);\n };\n\n const onSuccess: Plaid.OnSuccess = (public_token: string, metadata: Plaid.OnSuccessMetaData) => {\n isPlaidModalOpen.value = false;\n\n sessionStorage.removeItem(internalStorageKey.value);\n\n emit('success', public_token, metadata);\n };\n\n const onLoad: Plaid.OnLoad = (...args) => emit('load', ...args);\n\n const onEvent: Plaid.OnEvent = (...args) => emit('event', ...args);\n\n async function handleClick() {\n if (isPlaidModalOpen.value === true) {\n return;\n }\n\n isPlaidModalOpen.value = true;\n\n if (typeof props.createToken === 'function') {\n try {\n const { link_token } = await props.createToken();\n\n internalToken.value = link_token;\n } catch (err) {\n const error = new Error('Plaid: Error trying to invoke createToken');\n\n logger.error(error, {\n tags: { plaid: true },\n extra: { error: err },\n });\n\n emit('error', error);\n }\n } else if (props.token) {\n internalToken.value = props.token;\n }\n\n if (!internalToken.value) {\n const error = new Error('Plaid: link token not found');\n\n logger.error(error, { tags: { plaid: true } });\n emit('error', error);\n\n isPlaidModalOpen.value = false;\n\n return;\n }\n\n sessionStorage.setItem(\n internalStorageKey.value,\n JSON.stringify({ token: internalToken.value, returnTo: props.returnTo, env: props.env }),\n );\n\n // Retries Plaid's script initialization if not loaded yet\n if (!window.Plaid) {\n await loadPlaidScript();\n }\n\n window.Plaid.create({\n token: internalToken.value,\n env: props.env,\n onExit,\n onSuccess,\n onEvent,\n onLoad,\n }).open();\n }\n\n function loadPlaidScript() {\n return new Promise<void>(function (resolve, reject) {\n const existingScript = document.querySelector('script[src=\"' + props.initScriptUrl + '\"]');\n\n if (existingScript) {\n existingScript.remove();\n }\n\n const el = document.createElement('script');\n\n el.type = 'text/javascript';\n el.async = true;\n el.src = props.initScriptUrl;\n el.addEventListener('load', () => resolve());\n el.addEventListener('error', reject);\n el.addEventListener('abort', reject);\n document.head.appendChild(el);\n });\n }\n\n loadPlaidScript();\n\n defineExpose({\n handleClick,\n });\n</script>\n\n<template>\n <span data-test=\"stash-plaid-link\" @click=\"handleClick\">\n <!-- @slot Default slot to trigger Plaid's modal -->\n <slot :open=\"isPlaidModalOpen\"></slot>\n </span>\n</template>\n"],"names":["internalStorageKey","computed","props","internalToken","ref","isPlaidModalOpen","onExit","error","metadata","logger","emit","onSuccess","public_token","onLoad","args","onEvent","handleClick","link_token","err","loadPlaidScript","resolve","reject","existingScript","el","__expose"],"mappings":";;;;;;;;;;;;;;iBAwDQA,IAAqBC,EAAS,MAC9BC,EAAM,aACDA,EAAM,aAMR,GAFM,OAAO,SAAS,KAAK,MAAM,GAAG,EAAE,OAAO,EAAE,EAAE,KAAK,GAAG,CAElD,QACf,GAEKC,IAAgBC,EAAI,EAAE,GA0BtBC,IAAmBD,EAAI,EAAK,GAE5BE,IAAuB,CAACC,GAA2BC,MAAmC;AAC1F,MAAAH,EAAiB,QAAQ,IAErBE,MACFE,EAAO,MAAM,IAAI,MAAM,wCAAwC,GAAG;AAAA,QAChE,MAAM,EAAE,OAAO,GAAK;AAAA,QACpB,OAAO,EAAE,YAAYF,EAAM;AAAA,MAAA,CAC5B,GACIG,EAAA,SAASH,GAAOC,CAAQ,IAGhB,eAAA,WAAWR,EAAmB,KAAK,GAElDU,EAAK,QAAQF,CAAQ;AAAA,IAAA,GAGjBG,IAA6B,CAACC,GAAsBJ,MAAsC;AAC9F,MAAAH,EAAiB,QAAQ,IAEV,eAAA,WAAWL,EAAmB,KAAK,GAE7CU,EAAA,WAAWE,GAAcJ,CAAQ;AAAA,IAAA,GAGlCK,IAAuB,IAAIC,MAASJ,EAAK,QAAQ,GAAGI,CAAI,GAExDC,IAAyB,IAAID,MAASJ,EAAK,SAAS,GAAGI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C,IAAK,SAAS,cAAc,QAAQ;AAE1C,QAAAA,EAAG,OAAO,mBACVA,EAAG,QAAQ,IACXA,EAAG,MAAMrB,EAAM,eACfqB,EAAG,iBAAiB,QAAQ,MAAMH,EAAS,CAAA,GACxCG,EAAA,iBAAiB,SAASF,CAAM,GAChCE,EAAA,iBAAiB,SAASF,CAAM,GAC1B,SAAA,KAAK,YAAYE,CAAE;AAAA,MAAA,CAC7B;AAAA,IACH;AAEgB,WAAAJ,KAEHK,EAAA;AAAA,MACX,aAAAR;AAAA,IAAA,CACD;;;;;;;;"}
@@ -41,7 +41,9 @@ declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_WithDefaul
41
41
  env: string;
42
42
  token: undefined;
43
43
  createToken: undefined;
44
- }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
44
+ }>, {
45
+ handleClick: typeof handleClick;
46
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
45
47
  error: (error: Error | Plaid.Error | null, metadata?: Plaid.OnExitMetaData | undefined) => void;
46
48
  success: (public_token: string, metadata: Plaid.OnSuccessMetaData) => void;
47
49
  exit: (metadata: Plaid.OnExitMetaData) => void;
@@ -74,6 +76,8 @@ declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_WithDefaul
74
76
  }>;
75
77
  export default _default;
76
78
 
79
+ declare function handleClick(): Promise<void>;
80
+
77
81
  export declare interface LinkTokenResponse {
78
82
  link_token: string;
79
83
  /**
@@ -24,7 +24,7 @@ declare interface CloseArgs {
24
24
  name?: string;
25
25
  }
26
26
 
27
- export declare interface Modal {
27
+ export declare interface Modal<TAttributes = Record<string, unknown>> {
28
28
  /**
29
29
  * Import the modal that you want to use in your component,
30
30
  * then pass that to the composable
@@ -39,7 +39,7 @@ export declare interface Modal {
39
39
  *
40
40
  * Listeners need to be formatted as `onEventName`
41
41
  */
42
- attributes?: Record<string, unknown>;
42
+ attributes?: ToRecord<TAttributes>;
43
43
  /**
44
44
  * Dyanmic slots that you want rendered in the format of
45
45
  * { default: 'my slot content' }
@@ -62,6 +62,10 @@ export declare interface Modal {
62
62
  };
63
63
  }
64
64
 
65
+ declare type ToRecord<T> = {
66
+ [P in keyof T]: T[P];
67
+ };
68
+
65
69
  declare function useModals(): {
66
70
  active: readonly {
67
71
  readonly component: FunctionalComponent<any, any, any> | {
@@ -404,7 +408,7 @@ declare function useModals(): {
404
408
  readonly disableDefaultListeners?: boolean | undefined;
405
409
  } | undefined;
406
410
  }[];
407
- open: (modal: Modal) => void;
411
+ open: <T>(modal: Modal<T>) => void;
408
412
  close: ({ index, name }?: CloseArgs) => void;
409
413
  closeAll: () => void;
410
414
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useModals.js","sources":["../src/composables/useModals/useModals.ts"],"sourcesContent":["import merge from 'lodash-es/merge';\nimport { Component, markRaw, reactive, readonly, ref } from 'vue';\n\n// #region modal-interface\nexport interface Modal {\n /**\n * Import the modal that you want to use in your component,\n * then pass that to the composable\n */\n component: Component;\n\n /**\n * Optional identifier used to close a modal. The default value is `component.name` (if defined).\n */\n name?: string;\n\n /**\n * Props and listeners to passed through.\n *\n * Listeners need to be formatted as `onEventName`\n */\n attributes?: Record<string, unknown>;\n\n /**\n * Dyanmic slots that you want rendered in the format of\n * { default: 'my slot content' }\n *\n * The Modals component which renders this list passes the value for slots through\n * a html sanitizer to avoid XSS attacks\n */\n slots?: Record<string, string>;\n\n /**\n * Custom options to use for the given modal.\n *\n * If options are not passed in, then useModals will set the following values as defaults\n *\n * {\n * disableDefaultListeners: false\n * }\n */\n options?: {\n disableDefaultListeners?: boolean;\n };\n}\n// #endregion modal-interface\n\ninterface CloseArgs {\n index?: number;\n name?: string;\n}\n\nconst active = ref<Modal[]>([]);\n\nexport default function useModals() {\n function open(modal: Modal) {\n if (!modal.name && modal.component.name) {\n modal.name = modal.component.name;\n }\n\n //Prevent vue from making the entire component passed in reactive to avoid unnecessary performance overhead\n modal.component = markRaw(modal.component);\n\n const optionsDefaults: Modal['options'] = {\n disableDefaultListeners: false,\n };\n\n modal.options = merge({}, optionsDefaults, modal.options);\n\n active.value.push(modal);\n }\n\n function close({ index, name }: CloseArgs = {}) {\n if (index === undefined && !name) {\n active.value.pop();\n return;\n }\n\n if (index !== undefined) {\n active.value.splice(index, 1);\n return;\n }\n\n if (name) {\n const index = active.value.findIndex((modal) => modal.name === name);\n\n if (index === -1) return;\n\n active.value.splice(index, 1);\n return;\n }\n }\n\n function closeAll() {\n active.value = [];\n }\n\n return reactive({\n /**\n * The list of modals that are currently open.\n */\n active: readonly(active),\n\n /**\n * Opens the given modal.\n */\n open,\n\n /**\n * Closes a modal.\n * If no arguments are passed, then the top-most modal is closed.\n * If an index is passed, then the modal at that index is closed.\n * If a name is passed, then the modal with that name is closed.\n */\n close,\n\n /**\n * Closes all active/open modals.\n */\n closeAll,\n });\n}\n"],"names":["active","ref","useModals","open","modal","markRaw","optionsDefaults","merge","close","index","name","closeAll","reactive","readonly"],"mappings":";;;;;;;;;;;;AAoDA,MAAMA,IAASC,EAAa,CAAA,CAAE;AAE9B,SAAwBC,IAAY;AAClC,WAASC,EAAKC,GAAc;AAC1B,IAAI,CAACA,EAAM,QAAQA,EAAM,UAAU,SAC3BA,EAAA,OAAOA,EAAM,UAAU,OAIzBA,EAAA,YAAYC,EAAQD,EAAM,SAAS;AAEzC,UAAME,IAAoC;AAAA,MACxC,yBAAyB;AAAA,IAAA;AAG3B,IAAAF,EAAM,UAAUG,EAAM,CAAA,GAAID,GAAiBF,EAAM,OAAO,GAEjDJ,EAAA,MAAM,KAAKI,CAAK;AAAA,EACzB;AAEA,WAASI,EAAM,EAAE,OAAAC,GAAO,MAAAC,EAAK,IAAe,CAAA,GAAI;AAC1C,QAAAD,MAAU,UAAa,CAACC,GAAM;AAChC,MAAAV,EAAO,MAAM;AACb;AAAA,IACF;AAEA,QAAIS,MAAU,QAAW;AAChB,MAAAT,EAAA,MAAM,OAAOS,GAAO,CAAC;AAC5B;AAAA,IACF;AAEA,QAAIC,GAAM;AACFD,YAAAA,IAAQT,EAAO,MAAM,UAAU,CAACI,MAAUA,EAAM,SAASM,CAAI;AAEnE,UAAID,MAAU;AAAI;AAEX,MAAAT,EAAA,MAAM,OAAOS,GAAO,CAAC;AAC5B;AAAA,IACF;AAAA,EACF;AAEA,WAASE,IAAW;AAClB,IAAAX,EAAO,QAAQ;EACjB;AAEA,SAAOY,EAAS;AAAA;AAAA;AAAA;AAAA,IAId,QAAQC,EAASb,CAAM;AAAA;AAAA;AAAA;AAAA,IAKvB,MAAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQA,OAAAK;AAAA;AAAA;AAAA;AAAA,IAKA,UAAAG;AAAA,EAAA,CACD;AACH;"}
1
+ {"version":3,"file":"useModals.js","sources":["../src/composables/useModals/useModals.ts"],"sourcesContent":["import merge from 'lodash-es/merge';\nimport { Component, markRaw, reactive, readonly, ref } from 'vue';\n\n// Utility type that maps each property of T to unknown, making it compatible with Record<string, unknown>\n// this ensures that the attributes property of the Modal interface can be used with custom types defined downstream\n// while still being compatible with the Record<string, unknown> type\ntype ToRecord<T> = {\n [P in keyof T]: T[P];\n};\n\n// #region modal-interface\nexport interface Modal<TAttributes = Record<string, unknown>> {\n /**\n * Import the modal that you want to use in your component,\n * then pass that to the composable\n */\n component: Component;\n\n /**\n * Optional identifier used to close a modal. The default value is `component.name` (if defined).\n */\n name?: string;\n\n /**\n * Props and listeners to passed through.\n *\n * Listeners need to be formatted as `onEventName`\n */\n attributes?: ToRecord<TAttributes>;\n\n /**\n * Dyanmic slots that you want rendered in the format of\n * { default: 'my slot content' }\n *\n * The Modals component which renders this list passes the value for slots through\n * a html sanitizer to avoid XSS attacks\n */\n slots?: Record<string, string>;\n\n /**\n * Custom options to use for the given modal.\n *\n * If options are not passed in, then useModals will set the following values as defaults\n *\n * {\n * disableDefaultListeners: false\n * }\n */\n options?: {\n disableDefaultListeners?: boolean;\n };\n}\n// #endregion modal-interface\n\ninterface CloseArgs {\n index?: number;\n name?: string;\n}\n\nconst active = ref<Modal[]>([]);\n\nexport default function useModals() {\n // T is the custom interface of the attributes that are passed to the modal\n function open<T>(modal: Modal<T>) {\n if (!modal.name && modal.component.name) {\n modal.name = modal.component.name;\n }\n\n //Prevent vue from making the entire component passed in reactive to avoid unnecessary performance overhead\n modal.component = markRaw(modal.component);\n\n const optionsDefaults: Modal['options'] = {\n disableDefaultListeners: false,\n };\n\n modal.options = merge({}, optionsDefaults, modal.options);\n\n active.value.push(modal);\n }\n\n function close({ index, name }: CloseArgs = {}) {\n if (index === undefined && !name) {\n active.value.pop();\n return;\n }\n\n if (index !== undefined) {\n active.value.splice(index, 1);\n return;\n }\n\n if (name) {\n const index = active.value.findIndex((modal) => modal.name === name);\n\n if (index === -1) return;\n\n active.value.splice(index, 1);\n return;\n }\n }\n\n function closeAll() {\n active.value = [];\n }\n\n return reactive({\n /**\n * The list of modals that are currently open.\n */\n active: readonly(active),\n\n /**\n * Opens the given modal.\n */\n open,\n\n /**\n * Closes a modal.\n * If no arguments are passed, then the top-most modal is closed.\n * If an index is passed, then the modal at that index is closed.\n * If a name is passed, then the modal with that name is closed.\n */\n close,\n\n /**\n * Closes all active/open modals.\n */\n closeAll,\n });\n}\n"],"names":["active","ref","useModals","open","modal","markRaw","optionsDefaults","merge","close","index","name","closeAll","reactive","readonly"],"mappings":";;;;;;;;;;;;AA2DA,MAAMA,IAASC,EAAa,CAAA,CAAE;AAE9B,SAAwBC,IAAY;AAElC,WAASC,EAAQC,GAAiB;AAChC,IAAI,CAACA,EAAM,QAAQA,EAAM,UAAU,SAC3BA,EAAA,OAAOA,EAAM,UAAU,OAIzBA,EAAA,YAAYC,EAAQD,EAAM,SAAS;AAEzC,UAAME,IAAoC;AAAA,MACxC,yBAAyB;AAAA,IAAA;AAG3B,IAAAF,EAAM,UAAUG,EAAM,CAAA,GAAID,GAAiBF,EAAM,OAAO,GAEjDJ,EAAA,MAAM,KAAKI,CAAK;AAAA,EACzB;AAEA,WAASI,EAAM,EAAE,OAAAC,GAAO,MAAAC,EAAK,IAAe,CAAA,GAAI;AAC1C,QAAAD,MAAU,UAAa,CAACC,GAAM;AAChC,MAAAV,EAAO,MAAM;AACb;AAAA,IACF;AAEA,QAAIS,MAAU,QAAW;AAChB,MAAAT,EAAA,MAAM,OAAOS,GAAO,CAAC;AAC5B;AAAA,IACF;AAEA,QAAIC,GAAM;AACFD,YAAAA,IAAQT,EAAO,MAAM,UAAU,CAACI,MAAUA,EAAM,SAASM,CAAI;AAEnE,UAAID,MAAU;AAAI;AAEX,MAAAT,EAAA,MAAM,OAAOS,GAAO,CAAC;AAC5B;AAAA,IACF;AAAA,EACF;AAEA,WAASE,IAAW;AAClB,IAAAX,EAAO,QAAQ;EACjB;AAEA,SAAOY,EAAS;AAAA;AAAA;AAAA;AAAA,IAId,QAAQC,EAASb,CAAM;AAAA;AAAA;AAAA;AAAA,IAKvB,MAAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQA,OAAAK;AAAA;AAAA;AAAA;AAAA,IAKA,UAAAG;AAAA,EAAA,CACD;AACH;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflink/stash",
3
- "version": "42.2.0",
3
+ "version": "42.4.0",
4
4
  "description": "LeafLink's design system.",
5
5
  "homepage": "https://stash.leaflink.com",
6
6
  "main": "./dist/index.ts",