@leaflink/stash 47.1.0 → 47.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"locale.js","sources":["../src/locales/en-US.ts","../src/locale.ts"],"sourcesContent":["export default {\n ll: {\n actions: 'Actions',\n all: 'All',\n allFilters: 'All Filters',\n apply: 'Apply',\n areYouSure: 'Are you sure?',\n cancel: 'Cancel',\n carousel: {\n imageLabel: 'Image {index} of {total}',\n paginationLabel: 'Go to image {index}',\n },\n clear: 'Clear',\n closeModal: 'Close modal',\n confirm: 'Confirm',\n copy: {\n copied: 'Copied!',\n copyToClipboard: 'Copy to clipboard',\n },\n datePicker: {\n dateFormat: 'Date format',\n today: 'Today',\n },\n pageStats: '{from} - {to} of {total}',\n emptyState: {\n noResults: 'No results',\n },\n fileUpload: {\n dragDropFileHere: 'Drag and drop your file here',\n errors: {\n incorrectFileType: 'Please drop a file with type: {fileTypes}',\n },\n or: 'or',\n remove: 'Remove',\n uploadFile: 'Upload File',\n },\n filter: 'Filter',\n filterBy: 'Filter by',\n filters: 'Filters',\n httpError: {\n 401: {\n title: 'Unauthorized',\n description: 'Sorry, you are not authorized to access the LeafLink portal!',\n },\n 403: {\n title: 'Access denied.',\n description: `Sorry, you can not access the page you are looking for. Talk to your account admin regarding your account's permission settings.`,\n },\n 404: {\n title: `Sorry, we can't find this page.`,\n description: `We couldn't find the page you're looking for.`,\n },\n 405: {\n title: 'Not allowed.',\n description: `We couldn't reach the page you're looking for this way.`,\n },\n '50X': {\n title: 'Please wait while we hash this out.',\n description: `You've encountered an error.`,\n },\n 504: {\n title: 'Your request got lost in the weeds.',\n description: `You've encountered an error.`,\n },\n },\n listView: {\n calculating: 'Calculating results...',\n clearSelection: 'Clear Selection',\n deselectAllCount: 'Deselect all ({count})',\n numItemsSelected: '{totalSelectedCount} of {totalCount} items selected',\n numberOfTotalSelected: '{num} of {total} selected',\n selectAll: 'Select all',\n selectAllCount: 'Select all ({count})',\n sortBy: 'Sort by',\n totalResults: 'Showing {num} of {total} results',\n },\n numberOfActiveFilters: 'Number of active filters',\n okay: 'Okay',\n optional: 'optional',\n pageNavigation: {\n more: 'More',\n },\n more: 'More',\n next: 'Next',\n previous: 'Previous',\n reset: 'Reset',\n resetAll: 'Reset all',\n search: 'Search',\n select: {\n self: 'Select',\n empty: 'No options',\n placeholder: 'Select option',\n selected: 'selected',\n },\n selectAll: 'Select all',\n sort: 'Sort',\n table: {\n collapseRow: 'Collapse row',\n expandRow: 'Expand row',\n },\n validation: {\n email: 'Email must be valid',\n maxLength: 'Must be at most {max} characters',\n maxValue: 'Must be at most {max}',\n minLength: 'Must be at least {min} characters',\n minValue: 'Must be at least {min}',\n positiveNumber: 'Must be greater than 0',\n price: 'Must have 2 decimal places',\n required: 'Required',\n wholeNumber: 'Must be a Whole Number',\n },\n viewFilterGroup: 'View filter group',\n },\n};\n","import get from 'lodash-es/get';\n\nimport messages from './locales/en-US';\n\nexport let locale = 'en-US';\nlet i18nHandler;\n\n/**\n * Replaces params in a translation message with respective values\n * @param {string} path Translation path (foo.bar.baz)\n * @param {object} params Any params used in the translation message\n * @returns {string}\n */\nexport function format(path, params) {\n const pathParams = path.match(/({)([\\w]+)(})/g) || [];\n let message = path;\n\n pathParams.forEach((param) => {\n const prop = param.replace(/[{}]/g, '');\n\n message = message.replace(param, params[prop] || '');\n });\n\n return message;\n}\n\n/**\n * Returns a translation based on translation path\n * @param {string} path Translation path (foo.bar.baz)\n * @param {object} params Any params used in the translation message\n */\nfunction translate(path, params) {\n // Lookup translation\n const value = get(messages, path);\n\n // Return translation, otherwise the path\n return value ? format(value, params) : path;\n}\n\n/**\n * Calls the provided translation method `config.i18n.t` if provided, or the built-in\n * @param {...(string|object)} args\n * @param {string} path Translation path (foo.bar.baz)\n * @param {object} params Any params used in the translation message\n * @returns {string} Translation message\n */\nexport function t(...args) {\n const value = i18nHandler && i18nHandler(...args);\n\n // If value exists, but translation doesn't (returns translation key format (xx.xx)),\n // then fallback to default\n if (value && !/^\\w{2,}\\.\\w{2,}/.test(value)) {\n return value;\n }\n\n // @ts-ignore - todo: Fix \"A spread argument must either have a tuple type or be passed to a rest parameter.ts(2556)\"\n // Default English message\n return translate(...args);\n}\n\n/**\n * Sets the locale\n * @param {string} l locale\n */\nexport function use(l) {\n locale = l || locale;\n}\n\n/**\n * Sets the translate function `t()`\n * @param {function} fn Translate function `t()`\n */\nexport function i18n(fn) {\n i18nHandler = fn;\n}\n\nexport default { i18n, locale, t, use };\n"],"names":["messages","locale","i18nHandler","format","path","params","pathParams","message","param","prop","translate","value","get","t","args","use","l","i18n","fn","locale$1"],"mappings":";AAAA,MAAeA,IAAA;AAAA,EACb,IAAI;AAAA,IACF,SAAS;AAAA,IACT,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,UAAU;AAAA,MACR,YAAY;AAAA,MACZ,iBAAiB;AAAA,IACnB;AAAA,IACA,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,iBAAiB;AAAA,IACnB;AAAA,IACA,YAAY;AAAA,MACV,YAAY;AAAA,MACZ,OAAO;AAAA,IACT;AAAA,IACA,WAAW;AAAA,IACX,YAAY;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACV,kBAAkB;AAAA,MAClB,QAAQ;AAAA,QACN,mBAAmB;AAAA,MACrB;AAAA,MACA,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,YAAY;AAAA,IACd;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,SAAS;AAAA,IACT,WAAW;AAAA,MACT,KAAK;AAAA,QACH,OAAO;AAAA,QACP,aAAa;AAAA,MACf;AAAA,MACA,KAAK;AAAA,QACH,OAAO;AAAA,QACP,aAAa;AAAA,MACf;AAAA,MACA,K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;AAC5B,UAAMC,IAAOD,EAAM,QAAQ,SAAS,EAAE;AAEtC,IAAAD,IAAUA,EAAQ,QAAQC,GAAOH,EAAOI,CAAI,KAAK,EAAE;AAAA,EAAA,CACpD,GAEMF;AACT;AAOA,SAASG,EAAUN,GAAMC,GAAQ;AAEzB,QAAAM,IAAQC,EAAIZ,GAAUI,CAAI;AAGhC,SAAOO,IAAQR,EAAOQ,GAAON,CAAM,IAAID;AACzC;AASO,SAASS,KAAKC,GAAM;AACzB,QAAMH,IAAQT,KAAeA,EAAY,GAAGY,CAAI;AAIhD,SAAIH,KAAS,CAAC,kBAAkB,KAAKA,CAAK,IACjCA,IAKFD,EAAU,GAAGI,CAAI;AAC1B;AAMO,SAASC,EAAIC,GAAG;AACrB,EAAAf,IAASe,KAAKf;AAChB;AAMO,SAASgB,EAAKC,GAAI;AACT,EAAAhB,IAAAgB;AAChB;AAEA,MAAeC,IAAA,EAAE,MAAAF,GAAM,QAAAhB,GAAQ,GAAAY,GAAG,KAAAE,EAAI;"}
1
+ {"version":3,"file":"locale.js","sources":["../src/locales/en-US.ts","../src/locale.ts"],"sourcesContent":["export default {\n ll: {\n actions: 'Actions',\n all: 'All',\n allFilters: 'All Filters',\n apply: 'Apply',\n areYouSure: 'Are you sure?',\n cancel: 'Cancel',\n carousel: {\n imageLabel: 'Image {index} of {total}',\n paginationLabel: 'Go to image {index}',\n },\n clear: 'Clear',\n closeModal: 'Close modal',\n confirm: 'Confirm',\n copy: {\n copied: 'Copied!',\n copyToClipboard: 'Copy to clipboard',\n },\n datePicker: {\n dateFormat: 'Date format',\n today: 'Today',\n },\n pageStats: '{from} - {to} of {total}',\n emptyState: {\n noResults: 'No results',\n },\n fileUpload: {\n dragDropFileHere: 'Drag and drop your file here',\n errors: {\n incorrectFileType: 'Please drop a file with type: {fileTypes}',\n },\n or: 'or',\n remove: 'Remove',\n uploadFile: 'Upload File',\n },\n filter: 'Filter',\n filterBy: 'Filter by',\n filters: 'Filters',\n httpError: {\n 401: {\n title: 'Unauthorized',\n description: 'Sorry, you are not authorized to access the LeafLink portal!',\n },\n 403: {\n title: 'Access denied.',\n description: `Sorry, you can not access the page you are looking for. Talk to your account admin regarding your account's permission settings.`,\n },\n 404: {\n title: `Sorry, we can't find this page.`,\n description: `We couldn't find the page you're looking for.`,\n },\n 405: {\n title: 'Not allowed.',\n description: `We couldn't reach the page you're looking for this way.`,\n },\n '50X': {\n title: 'Please wait while we hash this out.',\n description: `You've encountered an error.`,\n },\n 504: {\n title: 'Your request got lost in the weeds.',\n description: `You've encountered an error.`,\n },\n },\n listView: {\n calculating: 'Calculating results...',\n clearSelection: 'Clear Selection',\n deselectAllCount: 'Deselect all ({count})',\n numItemsSelected: '{totalSelectedCount} of {totalCount} items selected',\n numberOfTotalSelected: '{num} of {total} selected',\n selectAll: 'Select all',\n selectAllCount: 'Select all ({count})',\n sortBy: 'Sort by',\n totalResults: 'Showing {num} of {total} results',\n },\n numberOfActiveFilters: 'Number of active filters',\n okay: 'Okay',\n optional: 'optional',\n pageNavigation: {\n more: 'More',\n },\n more: 'More',\n next: 'Next',\n previous: 'Previous',\n reset: 'Reset',\n resetAll: 'Reset all',\n search: 'Search',\n select: {\n self: 'Select',\n empty: 'No options',\n placeholder: 'Select option',\n selected: 'selected',\n },\n selectAll: 'Select all',\n sort: 'Sort',\n stepper: {\n currentStep: 'Step {num} of {total}',\n },\n table: {\n collapseRow: 'Collapse row',\n expandRow: 'Expand row',\n },\n validation: {\n email: 'Email must be valid',\n maxLength: 'Must be at most {max} characters',\n maxValue: 'Must be at most {max}',\n minLength: 'Must be at least {min} characters',\n minValue: 'Must be at least {min}',\n positiveNumber: 'Must be greater than 0',\n price: 'Must have 2 decimal places',\n required: 'Required',\n wholeNumber: 'Must be a Whole Number',\n },\n viewFilterGroup: 'View filter group',\n },\n};\n","import get from 'lodash-es/get';\n\nimport messages from './locales/en-US';\n\nexport let locale = 'en-US';\nlet i18nHandler;\n\n/**\n * Replaces params in a translation message with respective values\n * @param {string} path Translation path (foo.bar.baz)\n * @param {object} params Any params used in the translation message\n * @returns {string}\n */\nexport function format(path, params) {\n const pathParams = path.match(/({)([\\w]+)(})/g) || [];\n let message = path;\n\n pathParams.forEach((param) => {\n const prop = param.replace(/[{}]/g, '');\n\n message = message.replace(param, params[prop] || '');\n });\n\n return message;\n}\n\n/**\n * Returns a translation based on translation path\n * @param {string} path Translation path (foo.bar.baz)\n * @param {object} params Any params used in the translation message\n */\nfunction translate(path, params) {\n // Lookup translation\n const value = get(messages, path);\n\n // Return translation, otherwise the path\n return value ? format(value, params) : path;\n}\n\n/**\n * Calls the provided translation method `config.i18n.t` if provided, or the built-in\n * @param {...(string|object)} args\n * @param {string} path Translation path (foo.bar.baz)\n * @param {object} params Any params used in the translation message\n * @returns {string} Translation message\n */\nexport function t(...args) {\n const value = i18nHandler && i18nHandler(...args);\n\n // If value exists, but translation doesn't (returns translation key format (xx.xx)),\n // then fallback to default\n if (value && !/^\\w{2,}\\.\\w{2,}/.test(value)) {\n return value;\n }\n\n // @ts-ignore - todo: Fix \"A spread argument must either have a tuple type or be passed to a rest parameter.ts(2556)\"\n // Default English message\n return translate(...args);\n}\n\n/**\n * Sets the locale\n * @param {string} l locale\n */\nexport function use(l) {\n locale = l || locale;\n}\n\n/**\n * Sets the translate function `t()`\n * @param {function} fn Translate function `t()`\n */\nexport function i18n(fn) {\n i18nHandler = fn;\n}\n\nexport default { i18n, locale, t, use };\n"],"names":["messages","locale","i18nHandler","format","path","params","pathParams","message","param","prop","translate","value","get","t","args","use","l","i18n","fn","locale$1"],"mappings":";AAAA,MAAeA,IAAA;AAAA,EACb,IAAI;AAAA,IACF,SAAS;AAAA,IACT,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,UAAU;AAAA,MACR,YAAY;AAAA,MACZ,iBAAiB;AAAA,IACnB;AAAA,IACA,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,SAAS;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+1,4 @@
1
+ import { ComputedRef } from 'vue';
1
2
  import { Ref } from 'vue';
2
3
 
3
4
  export declare interface StepDefinition {
@@ -22,6 +23,10 @@ export declare interface StepperOptions {
22
23
  * The stepper representation as an array of steps and substeps
23
24
  */
24
25
  steps?: Array<StepDefinition>;
26
+ /**
27
+ * A ref to the stepper element
28
+ */
29
+ ref?: Ref<HTMLUListElement | null>;
25
30
  }
26
31
 
27
32
  declare function useStepper(options?: StepperOptions): {
@@ -31,6 +36,8 @@ declare function useStepper(options?: StepperOptions): {
31
36
  readonly completed: boolean;
32
37
  }[];
33
38
  }[]>>;
39
+ stepCount: ComputedRef<number>;
40
+ activeStepElement: ComputedRef<HTMLLIElement>;
34
41
  activeStepIndex: Ref<number>;
35
42
  activeSubstepIndex: Ref<number>;
36
43
  registerStep: (nested?: boolean) => void;
@@ -1,65 +1,70 @@
1
- import { ref as r, readonly as m } from "vue";
2
- function d(s = {
1
+ import { ref as f, computed as p, readonly as w } from "vue";
2
+ function E(v = {
3
3
  linear: !1,
4
4
  activeStep: -1,
5
5
  activeSubstep: -1,
6
6
  steps: []
7
7
  }) {
8
- const u = r(s.steps ? s.steps : []), e = r(
9
- s.activeStep !== null && s.activeStep !== void 0 ? s.activeStep : -1
10
- ), l = r(
11
- s.activeSubstep !== null && s.activeSubstep !== void 0 ? s.activeSubstep : -1
12
- );
13
- function v(a) {
14
- return !!u.value[a].substeps.length;
8
+ const a = f(v.steps ? v.steps : []), o = p(() => a.value.length), e = f(
9
+ v.activeStep !== null && v.activeStep !== void 0 ? v.activeStep : -1
10
+ ), l = f(
11
+ v.activeSubstep !== null && v.activeSubstep !== void 0 ? v.activeSubstep : -1
12
+ ), S = p(() => {
13
+ var u, t;
14
+ return Array.from(((t = (u = v.ref) == null ? void 0 : u.value) == null ? void 0 : t.children) || []);
15
+ }), m = p(() => S.value[e.value]);
16
+ function s(u) {
17
+ return !!a.value[u].substeps.length;
15
18
  }
16
- function n() {
17
- const a = e.value === -1, t = e.value === u.value.length - 1;
18
- if (a)
19
- e.value++, v(e.value) && l.value++;
19
+ function b() {
20
+ const u = e.value === -1, t = e.value === a.value.length - 1;
21
+ if (u)
22
+ e.value++, s(e.value) && l.value++;
20
23
  else if (t)
21
- if (v(e.value)) {
22
- const i = l.value === -1, c = l.value === u.value[e.value].substeps.length - 1;
23
- i ? l.value++ : c ? (u.value[e.value].substeps[l.value].completed = !0, l.value = -1, u.value[e.value].completed = !0, e.value = -1) : (u.value[e.value].substeps[l.value].completed = !0, l.value++);
24
+ if (s(e.value)) {
25
+ const i = l.value === -1, c = l.value === a.value[e.value].substeps.length - 1;
26
+ i ? l.value++ : c ? (a.value[e.value].substeps[l.value].completed = !0, l.value = -1, a.value[e.value].completed = !0, e.value = -1) : (a.value[e.value].substeps[l.value].completed = !0, l.value++);
24
27
  } else
25
- u.value[e.value].completed = !0, e.value = -1;
26
- else if (v(e.value)) {
27
- const i = l.value === -1, c = l.value === u.value[e.value].substeps.length - 1;
28
- i ? l.value++ : c ? (u.value[e.value].substeps[l.value].completed = !0, l.value = -1, u.value[e.value].completed = !0, e.value++, v(e.value) && l.value++) : (u.value[e.value].substeps[l.value].completed = !0, l.value++);
28
+ a.value[e.value].completed = !0, e.value = -1;
29
+ else if (s(e.value)) {
30
+ const i = l.value === -1, c = l.value === a.value[e.value].substeps.length - 1;
31
+ i ? l.value++ : c ? (a.value[e.value].substeps[l.value].completed = !0, l.value = -1, a.value[e.value].completed = !0, e.value++, s(e.value) && l.value++) : (a.value[e.value].substeps[l.value].completed = !0, l.value++);
29
32
  } else
30
- u.value[e.value].completed = !0, e.value++, v(e.value) && l.value++;
33
+ a.value[e.value].completed = !0, e.value++, s(e.value) && l.value++;
31
34
  }
32
- function o() {
33
- e.value !== -1 && (v(e.value) ? l.value === 0 ? (e.value--, l.value--, e.value >= 0 && v(e.value) && (l.value = u.value[e.value].substeps.length - 1)) : l.value-- : (e.value--, e.value >= 0 && v(e.value) && (l.value = u.value[e.value].substeps.length - 1)));
35
+ function h() {
36
+ e.value !== -1 && (s(e.value) ? l.value === 0 ? (e.value--, l.value--, e.value >= 0 && s(e.value) && (l.value = a.value[e.value].substeps.length - 1)) : l.value-- : (e.value--, e.value >= 0 && s(e.value) && (l.value = a.value[e.value].substeps.length - 1)));
34
37
  }
35
- function S(a, t = -1) {
36
- s.linear ? (f(a - 1) || a === 0) && (v(a) && (t <= 0 ? l.value = 0 : f(a, t - 1) && (l.value = t)), e.value = a) : (e.value = a, v(a) && (t < 0 ? l.value = 0 : l.value = t));
38
+ function g(u, t = -1) {
39
+ v.linear ? (r(u - 1) || u === 0) && (s(u) && (t <= 0 ? l.value = 0 : r(u, t - 1) && (l.value = t)), e.value = u) : (e.value = u, s(u) && (t < 0 ? l.value = 0 : l.value = t));
37
40
  }
38
- function f(a, t = -1) {
39
- var i, c, p;
40
- return t >= 0 ? (c = (i = u.value[a]) == null ? void 0 : i.substeps[t]) == null ? void 0 : c.completed : (p = u.value[a]) == null ? void 0 : p.completed;
41
+ function r(u, t = -1) {
42
+ var i, c, n;
43
+ return t >= 0 ? (c = (i = a.value[u]) == null ? void 0 : i.substeps[t]) == null ? void 0 : c.completed : (n = a.value[u]) == null ? void 0 : n.completed;
41
44
  }
42
- function b(a, t = -1) {
43
- return t >= 0 ? e.value === a && l.value === t : e.value === a;
45
+ function d(u, t = -1) {
46
+ return t >= 0 ? e.value === u && l.value === t : e.value === u;
44
47
  }
45
- function h(a = !1) {
46
- if (a && !u.value.length)
48
+ function A(u = !1) {
49
+ if (u && !a.value.length)
47
50
  throw new Error("Cannot register a substep without a parent step.");
48
- a ? u.value[u.value.length - 1].substeps.push({ completed: !1 }) : u.value.push({ completed: !1, substeps: [] });
51
+ u ? a.value[a.value.length - 1].substeps.push({ completed: !1 }) : a.value.push({ completed: !1, substeps: [] });
49
52
  }
50
53
  return {
51
- steps: m(u),
54
+ steps: w(a),
55
+ stepCount: o,
56
+ activeStepElement: m,
52
57
  activeStepIndex: e,
53
58
  activeSubstepIndex: l,
54
- registerStep: h,
55
- next: n,
56
- back: o,
57
- goTo: S,
58
- isStepActive: b,
59
- isStepCompleted: f
59
+ registerStep: A,
60
+ next: b,
61
+ back: h,
62
+ goTo: g,
63
+ isStepActive: d,
64
+ isStepCompleted: r
60
65
  };
61
66
  }
62
67
  export {
63
- d as default
68
+ E as default
64
69
  };
65
70
  //# sourceMappingURL=useStepper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStepper.js","sources":["../src/composables/useStepper/useStepper.ts"],"sourcesContent":["import { readonly, ref } from 'vue';\n\nexport interface StepDefinition {\n completed: boolean;\n substeps: Array<Omit<StepDefinition, 'substeps'>>;\n}\n\nexport interface StepperOptions {\n /**\n * If true, the stepper will prevent skipping steps\n */\n linear?: boolean;\n /**\n * The index of the active step\n */\n activeStep?: number;\n /**\n * The index of the active substep\n */\n activeSubstep?: number;\n /**\n * The stepper representation as an array of steps and substeps\n */\n steps?: Array<StepDefinition>;\n}\n\nexport default function useStepper(\n options: StepperOptions = {\n linear: false,\n activeStep: -1,\n activeSubstep: -1,\n steps: [],\n },\n) {\n /**\n * The steps and substeps of the stepper, so we can keep track of their state.\n * Can be populated with the `steps` option, or via the `registerStep` function.\n */\n const steps = ref<Array<StepDefinition>>(options.steps ? options.steps : []);\n\n const activeStepIndex = ref(\n options.activeStep !== null && options.activeStep !== undefined ? options.activeStep : -1,\n );\n const activeSubstepIndex = ref(\n options.activeSubstep !== null && options.activeSubstep !== undefined ? options.activeSubstep : -1,\n );\n\n /**\n * Returns true if the step at the given index has substeps\n * @param stepIndex The index of the step to check\n */\n function stepHasSubsteps(stepIndex: number): boolean {\n return !!steps.value[stepIndex].substeps.length;\n }\n\n /**\n * Goes to the next step or substep, while flagging the current one as completed.\n * If the current step has substeps, it will go to the next substep if there are any, or to the next substep.\n * And if the next step has substeps, automatically goes to the first substep\n */\n function next(): void {\n const hasNoActiveStep = activeStepIndex.value === -1;\n const isLastStep = activeStepIndex.value === steps.value.length - 1;\n\n // If there is no active step, we want to activate the first step\n if (hasNoActiveStep) {\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep\n if (stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value++;\n }\n } else if (isLastStep) {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to reset the step and substep to -1\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n // If there are no substeps, we want to complete the current step and reset the step to -1\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n }\n } else {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to go to the next step\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value++;\n }\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value++;\n }\n }\n }\n }\n\n function back(): void {\n // We don't want to go back if there is no active step\n if (activeStepIndex.value === -1) {\n return;\n }\n\n if (stepHasSubsteps(activeStepIndex.value)) {\n // If the active substep is the first one, we want to go back to the previous step\n if (activeSubstepIndex.value === 0) {\n activeStepIndex.value--;\n activeSubstepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n } else {\n activeSubstepIndex.value--;\n }\n } else {\n activeStepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n }\n }\n\n /**\n * Navigates to a specific step and substep.\n */\n function goTo(stepIndex: number, substepIndex = -1): void {\n // A linear stepper prevents navigation to incomplete steps\n if (options.linear) {\n if (isStepCompleted(stepIndex - 1) || stepIndex === 0) {\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex <= 0) {\n activeSubstepIndex.value = 0;\n } else if (isStepCompleted(stepIndex, substepIndex - 1)) {\n activeSubstepIndex.value = substepIndex;\n }\n }\n activeStepIndex.value = stepIndex;\n }\n } else {\n activeStepIndex.value = stepIndex;\n\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex < 0) {\n activeSubstepIndex.value = 0;\n } else {\n activeSubstepIndex.value = substepIndex;\n }\n }\n }\n }\n\n /**\n * Returns true if the step is completed.\n * if the substep index is provided, check if the substep is completed.\n */\n function isStepCompleted(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return steps.value[stepIndex]?.substeps[substepIndex]?.completed;\n } else {\n return steps.value[stepIndex]?.completed;\n }\n }\n\n /**\n * Returns true if the step is active.\n * if the substep index is provided, check both if the step and the substep are active.\n */\n function isStepActive(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return activeStepIndex.value === stepIndex && activeSubstepIndex.value === substepIndex;\n } else {\n return activeStepIndex.value === stepIndex;\n }\n }\n\n /**\n * Registers a new step or substep into the steps array\n */\n function registerStep(nested = false): void {\n if (nested && !steps.value.length) {\n throw new Error('Cannot register a substep without a parent step.');\n }\n\n if (nested) {\n steps.value[steps.value.length - 1].substeps.push({ completed: false });\n } else {\n steps.value.push({ completed: false, substeps: [] });\n }\n }\n\n return {\n steps: readonly(steps),\n activeStepIndex,\n activeSubstepIndex,\n registerStep,\n next,\n back,\n goTo,\n isStepActive,\n isStepCompleted,\n };\n}\n"],"names":["useStepper","options","steps","ref","activeStepIndex","activeSubstepIndex","stepHasSubsteps","stepIndex","next","hasNoActiveStep","isLastStep","hasNoActiveSubstep","isLastSubstep","back","goTo","substepIndex","isStepCompleted","_b","_a","_c","isStepActive","registerStep","nested","readonly"],"mappings":";AA0BA,SAAwBA,EACtBC,IAA0B;AAAA,EACxB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,OAAO,CAAC;AACV,GACA;AAKA,QAAMC,IAAQC,EAA2BF,EAAQ,QAAQA,EAAQ,QAAQ,CAAA,CAAE,GAErEG,IAAkBD;AAAA,IACtBF,EAAQ,eAAe,QAAQA,EAAQ,eAAe,SAAYA,EAAQ,aAAa;AAAA,EAAA,GAEnFI,IAAqBF;AAAA,IACzBF,EAAQ,kBAAkB,QAAQA,EAAQ,kBAAkB,SAAYA,EAAQ,gBAAgB;AAAA,EAAA;AAOlG,WAASK,EAAgBC,GAA4B;AACnD,WAAO,CAAC,CAACL,EAAM,MAAMK,CAAS,EAAE,SAAS;AAAA,EAC3C;AAOA,WAASC,IAAa;AACd,UAAAC,IAAkBL,EAAgB,UAAU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D;AAGpE,IAAIoB,IACIpB,EAAA,MAAMA,EAAM,MAAM,SAAS,CAAC,EAAE,SAAS,KAAK,EAAE,WAAW,GAAO,CAAA,IAEhEA,EAAA,MAAM,KAAK,EAAE,WAAW,IAAO,UAAU,IAAI;AAAA,EAEvD;AAEO,SAAA;AAAA,IACL,OAAOqB,EAASrB,CAAK;AAAA,IACrB,iBAAAE;AAAA,IACA,oBAAAC;AAAA,IACA,cAAAgB;AAAA,IACA,MAAAb;AAAA,IACA,MAAAK;AAAA,IACA,MAAAC;AAAA,IACA,cAAAM;AAAA,IACA,iBAAAJ;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"useStepper.js","sources":["../src/composables/useStepper/useStepper.ts"],"sourcesContent":["import { computed, readonly, Ref, ref } from 'vue';\n\nexport interface StepDefinition {\n completed: boolean;\n substeps: Array<Omit<StepDefinition, 'substeps'>>;\n}\n\nexport interface StepperOptions {\n /**\n * If true, the stepper will prevent skipping steps\n */\n linear?: boolean;\n /**\n * The index of the active step\n */\n activeStep?: number;\n /**\n * The index of the active substep\n */\n activeSubstep?: number;\n /**\n * The stepper representation as an array of steps and substeps\n */\n steps?: Array<StepDefinition>;\n /**\n * A ref to the stepper element\n */\n ref?: Ref<HTMLUListElement | null>;\n}\n\nexport default function useStepper(\n options: StepperOptions = {\n linear: false,\n activeStep: -1,\n activeSubstep: -1,\n steps: [],\n },\n) {\n /**\n * The steps and substeps of the stepper, so we can keep track of their state.\n * Can be populated with the `steps` option, or via the `registerStep` function.\n */\n const steps = ref<Array<StepDefinition>>(options.steps ? options.steps : []);\n\n const stepCount = computed(() => steps.value.length);\n\n const activeStepIndex = ref(\n options.activeStep !== null && options.activeStep !== undefined ? options.activeStep : -1,\n );\n const activeSubstepIndex = ref(\n options.activeSubstep !== null && options.activeSubstep !== undefined ? options.activeSubstep : -1,\n );\n\n const stepElements = computed(() => {\n return Array.from((options.ref?.value?.children || []) as HTMLCollectionOf<HTMLLIElement>);\n });\n\n const activeStepElement = computed(() => stepElements.value[activeStepIndex.value]);\n\n /**\n * Returns true if the step at the given index has substeps\n * @param stepIndex The index of the step to check\n */\n function stepHasSubsteps(stepIndex: number): boolean {\n return !!steps.value[stepIndex].substeps.length;\n }\n\n /**\n * Goes to the next step or substep, while flagging the current one as completed.\n * If the current step has substeps, it will go to the next substep if there are any, or to the next substep.\n * And if the next step has substeps, automatically goes to the first substep\n */\n function next(): void {\n const hasNoActiveStep = activeStepIndex.value === -1;\n const isLastStep = activeStepIndex.value === steps.value.length - 1;\n\n // If there is no active step, we want to activate the first step\n if (hasNoActiveStep) {\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep\n if (stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value++;\n }\n } else if (isLastStep) {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to reset the step and substep to -1\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n // If there are no substeps, we want to complete the current step and reset the step to -1\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n }\n } else {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to go to the next step\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value++;\n }\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value++;\n }\n }\n }\n }\n\n function back(): void {\n // We don't want to go back if there is no active step\n if (activeStepIndex.value === -1) {\n return;\n }\n\n if (stepHasSubsteps(activeStepIndex.value)) {\n // If the active substep is the first one, we want to go back to the previous step\n if (activeSubstepIndex.value === 0) {\n activeStepIndex.value--;\n activeSubstepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n } else {\n activeSubstepIndex.value--;\n }\n } else {\n activeStepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n }\n }\n\n /**\n * Navigates to a specific step and substep.\n */\n function goTo(stepIndex: number, substepIndex = -1): void {\n // A linear stepper prevents navigation to incomplete steps\n if (options.linear) {\n if (isStepCompleted(stepIndex - 1) || stepIndex === 0) {\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex <= 0) {\n activeSubstepIndex.value = 0;\n } else if (isStepCompleted(stepIndex, substepIndex - 1)) {\n activeSubstepIndex.value = substepIndex;\n }\n }\n activeStepIndex.value = stepIndex;\n }\n } else {\n activeStepIndex.value = stepIndex;\n\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex < 0) {\n activeSubstepIndex.value = 0;\n } else {\n activeSubstepIndex.value = substepIndex;\n }\n }\n }\n }\n\n /**\n * Returns true if the step is completed.\n * if the substep index is provided, check if the substep is completed.\n */\n function isStepCompleted(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return steps.value[stepIndex]?.substeps[substepIndex]?.completed;\n } else {\n return steps.value[stepIndex]?.completed;\n }\n }\n\n /**\n * Returns true if the step is active.\n * if the substep index is provided, check both if the step and the substep are active.\n */\n function isStepActive(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return activeStepIndex.value === stepIndex && activeSubstepIndex.value === substepIndex;\n } else {\n return activeStepIndex.value === stepIndex;\n }\n }\n\n /**\n * Registers a new step or substep into the steps array\n */\n function registerStep(nested = false): void {\n if (nested && !steps.value.length) {\n throw new Error('Cannot register a substep without a parent step.');\n }\n\n if (nested) {\n steps.value[steps.value.length - 1].substeps.push({ completed: false });\n } else {\n steps.value.push({ completed: false, substeps: [] });\n }\n }\n\n return {\n steps: readonly(steps),\n stepCount,\n activeStepElement,\n activeStepIndex,\n activeSubstepIndex,\n registerStep,\n next,\n back,\n goTo,\n isStepActive,\n isStepCompleted,\n };\n}\n"],"names":["useStepper","options","steps","ref","stepCount","computed","activeStepIndex","activeSubstepIndex","stepElements","_b","_a","activeStepElement","stepHasSubsteps","stepIndex","next","hasNoActiveStep","isLastStep","hasNoActiveSubstep","isLastSubstep","back","goTo","substepIndex","isStepCompleted","_c","isStepActive","registerStep","nested","readonly"],"mappings":";AA8BA,SAAwBA,EACtBC,IAA0B;AAAA,EACxB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,OAAO,CAAC;AACV,GACA;AAKA,QAAMC,IAAQC,EAA2BF,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B,QAAQ,IAClBe,EAAgBT,GAAWQ,IAAe,CAAC,MACpDd,EAAmB,QAAQc,KAG/Bf,EAAgB,QAAQO,MAG1BP,EAAgB,QAAQO,GAEpBD,EAAgBC,CAAS,MACvBQ,IAAe,IACjBd,EAAmB,QAAQ,IAE3BA,EAAmB,QAAQc;AAAA,EAInC;AAMS,WAAAC,EAAgBT,GAAmBQ,IAAe,IAAa;;AACtE,WAAIA,KAAgB,KACXZ,KAAAC,IAAAR,EAAM,MAAMW,CAAS,MAArB,gBAAAH,EAAwB,SAASW,OAAjC,gBAAAZ,EAAgD,aAEhDc,IAAArB,EAAM,MAAMW,CAAS,MAArB,gBAAAU,EAAwB;AAAA,EAEnC;AAMS,WAAAC,EAAaX,GAAmBQ,IAAe,IAAa;AACnE,WAAIA,KAAgB,IACXf,EAAgB,UAAUO,KAAaN,EAAmB,UAAUc,IAEpEf,EAAgB,UAAUO;AAAA,EAErC;AAKS,WAAAY,EAAaC,IAAS,IAAa;AAC1C,QAAIA,KAAU,CAACxB,EAAM,MAAM;AACnB,YAAA,IAAI,MAAM,kDAAkD;AAGpE,IAAIwB,IACIxB,EAAA,MAAMA,EAAM,MAAM,SAAS,CAAC,EAAE,SAAS,KAAK,EAAE,WAAW,GAAO,CAAA,IAEhEA,EAAA,MAAM,KAAK,EAAE,WAAW,IAAO,UAAU,IAAI;AAAA,EAEvD;AAEO,SAAA;AAAA,IACL,OAAOyB,EAASzB,CAAK;AAAA,IACrB,WAAAE;AAAA,IACA,mBAAAO;AAAA,IACA,iBAAAL;AAAA,IACA,oBAAAC;AAAA,IACA,cAAAkB;AAAA,IACA,MAAAX;AAAA,IACA,MAAAK;AAAA,IACA,MAAAC;AAAA,IACA,cAAAI;AAAA,IACA,iBAAAF;AAAA,EAAA;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflink/stash",
3
- "version": "47.1.0",
3
+ "version": "47.2.1",
4
4
  "description": "LeafLink's design system.",
5
5
  "homepage": "https://stash.leaflink.com",
6
6
  "main": "./dist/index.ts",