@studiometa/js-toolkit 2.7.0 → 2.9.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.
Files changed (143) hide show
  1. package/Base/Base.cjs +325 -0
  2. package/Base/Base.cjs.map +7 -0
  3. package/Base/Base.d.ts +197 -0
  4. package/Base/Base.js +304 -0
  5. package/Base/Base.js.map +7 -0
  6. package/Base/features.cjs +1 -3
  7. package/Base/features.cjs.map +2 -2
  8. package/Base/features.d.ts +1 -1
  9. package/Base/features.js +1 -3
  10. package/Base/features.js.map +2 -2
  11. package/Base/index.cjs +2 -292
  12. package/Base/index.cjs.map +3 -3
  13. package/Base/index.d.ts +1 -193
  14. package/Base/index.js +1 -290
  15. package/Base/index.js.map +2 -2
  16. package/Base/managers/AbstractManager.d.ts +2 -2
  17. package/Base/managers/ChildrenManager.cjs +11 -7
  18. package/Base/managers/ChildrenManager.cjs.map +2 -2
  19. package/Base/managers/ChildrenManager.d.ts +1 -1
  20. package/Base/managers/ChildrenManager.js +12 -8
  21. package/Base/managers/ChildrenManager.js.map +2 -2
  22. package/Base/managers/OptionsManager.d.ts +9 -9
  23. package/Base/managers/RefsManager.cjs +13 -8
  24. package/Base/managers/RefsManager.cjs.map +2 -2
  25. package/Base/managers/RefsManager.js +14 -9
  26. package/Base/managers/RefsManager.js.map +2 -2
  27. package/Base/managers/ResponsiveOptionsManager.d.ts +1 -1
  28. package/Base/managers/ServicesManager.d.ts +2 -2
  29. package/Base/managers/index.cjs +0 -2
  30. package/Base/managers/index.cjs.map +2 -2
  31. package/Base/managers/index.d.ts +0 -1
  32. package/Base/managers/index.js +0 -2
  33. package/Base/managers/index.js.map +2 -2
  34. package/Base/types.d.ts +1 -1
  35. package/Base/utils.cjs +28 -1
  36. package/Base/utils.cjs.map +2 -2
  37. package/Base/utils.d.ts +4 -0
  38. package/Base/utils.js +29 -2
  39. package/Base/utils.js.map +2 -2
  40. package/decorators/index.cjs +1 -1
  41. package/decorators/index.cjs.map +2 -2
  42. package/decorators/index.d.ts +1 -1
  43. package/decorators/index.js +1 -1
  44. package/decorators/index.js.map +1 -1
  45. package/decorators/withDrag.d.ts +1 -1
  46. package/decorators/withScrolledInView/index.cjs +22 -0
  47. package/decorators/withScrolledInView/index.cjs.map +7 -0
  48. package/decorators/withScrolledInView/index.d.ts +2 -0
  49. package/decorators/withScrolledInView/index.js +3 -0
  50. package/decorators/withScrolledInView/index.js.map +7 -0
  51. package/decorators/withScrolledInView/types.cjs +19 -0
  52. package/decorators/withScrolledInView/types.cjs.map +7 -0
  53. package/decorators/withScrolledInView/types.d.ts +2 -0
  54. package/decorators/withScrolledInView/types.js +1 -0
  55. package/decorators/withScrolledInView/types.js.map +7 -0
  56. package/decorators/withScrolledInView/utils.cjs +99 -0
  57. package/decorators/withScrolledInView/utils.cjs.map +7 -0
  58. package/decorators/withScrolledInView/utils.d.ts +17 -0
  59. package/decorators/withScrolledInView/utils.js +77 -0
  60. package/decorators/withScrolledInView/utils.js.map +7 -0
  61. package/decorators/{withScrolledInView.cjs → withScrolledInView/withScrolledInView.cjs} +47 -46
  62. package/decorators/withScrolledInView/withScrolledInView.cjs.map +7 -0
  63. package/decorators/{withScrolledInView.d.ts → withScrolledInView/withScrolledInView.d.ts} +7 -11
  64. package/decorators/{withScrolledInView.js → withScrolledInView/withScrolledInView.js} +53 -45
  65. package/decorators/withScrolledInView/withScrolledInView.js.map +7 -0
  66. package/helpers/createApp.d.ts +1 -1
  67. package/helpers/getClosestParent.cjs +3 -11
  68. package/helpers/getClosestParent.cjs.map +2 -2
  69. package/helpers/getClosestParent.js +3 -11
  70. package/helpers/getClosestParent.js.map +2 -2
  71. package/helpers/importWhenIdle.d.ts +1 -1
  72. package/package.json +2 -2
  73. package/services/drag.d.ts +2 -2
  74. package/services/index.d.ts +7 -7
  75. package/services/key.d.ts +1 -1
  76. package/services/load.d.ts +1 -1
  77. package/services/pointer.d.ts +1 -1
  78. package/services/raf.d.ts +1 -1
  79. package/services/resize.d.ts +1 -1
  80. package/services/scroll.d.ts +1 -1
  81. package/utils/Queue.cjs +4 -1
  82. package/utils/Queue.cjs.map +2 -2
  83. package/utils/Queue.d.ts +1 -1
  84. package/utils/Queue.js +4 -1
  85. package/utils/Queue.js.map +2 -2
  86. package/utils/SmartQueue.cjs +57 -0
  87. package/utils/SmartQueue.cjs.map +7 -0
  88. package/utils/SmartQueue.d.ts +25 -0
  89. package/utils/SmartQueue.js +29 -0
  90. package/utils/SmartQueue.js.map +7 -0
  91. package/utils/css/animate.cjs +18 -1
  92. package/utils/css/animate.cjs.map +3 -3
  93. package/utils/css/animate.d.ts +6 -3
  94. package/utils/css/animate.js +18 -1
  95. package/utils/css/animate.js.map +3 -3
  96. package/utils/css/getOffsetSizes.cjs +1 -1
  97. package/utils/css/getOffsetSizes.cjs.map +1 -1
  98. package/utils/css/getOffsetSizes.js +1 -1
  99. package/utils/css/getOffsetSizes.js.map +1 -1
  100. package/utils/css/matrix.d.ts +1 -1
  101. package/utils/css/transform.d.ts +1 -1
  102. package/utils/css/transition.d.ts +2 -2
  103. package/utils/dom/ancestors.cjs +37 -0
  104. package/utils/dom/ancestors.cjs.map +7 -0
  105. package/utils/dom/ancestors.d.ts +8 -0
  106. package/utils/dom/ancestors.js +15 -0
  107. package/utils/dom/ancestors.js.map +7 -0
  108. package/utils/dom/index.cjs +21 -0
  109. package/utils/dom/index.cjs.map +7 -0
  110. package/utils/dom/index.d.ts +1 -0
  111. package/utils/dom/index.js +2 -0
  112. package/utils/dom/index.js.map +7 -0
  113. package/utils/index.cjs +4 -0
  114. package/utils/index.cjs.map +2 -2
  115. package/utils/index.d.ts +3 -0
  116. package/utils/index.js +4 -0
  117. package/utils/index.js.map +2 -2
  118. package/utils/is.cjs +1 -1
  119. package/utils/is.cjs.map +2 -2
  120. package/utils/is.js +1 -1
  121. package/utils/is.js.map +2 -2
  122. package/utils/math/createEases.d.ts +1 -1
  123. package/utils/nextTick.cjs +2 -5
  124. package/utils/nextTick.cjs.map +2 -2
  125. package/utils/nextTick.js +2 -5
  126. package/utils/nextTick.js.map +2 -2
  127. package/utils/tween.cjs +3 -2
  128. package/utils/tween.cjs.map +2 -2
  129. package/utils/tween.d.ts +2 -1
  130. package/utils/tween.js +3 -2
  131. package/utils/tween.js.map +2 -2
  132. package/utils/wait.cjs +31 -0
  133. package/utils/wait.cjs.map +7 -0
  134. package/utils/wait.d.ts +1 -0
  135. package/utils/wait.js +9 -0
  136. package/utils/wait.js.map +7 -0
  137. package/Base/managers/AsyncChildrenManager.cjs +0 -61
  138. package/Base/managers/AsyncChildrenManager.cjs.map +0 -7
  139. package/Base/managers/AsyncChildrenManager.d.ts +0 -18
  140. package/Base/managers/AsyncChildrenManager.js +0 -39
  141. package/Base/managers/AsyncChildrenManager.js.map +0 -7
  142. package/decorators/withScrolledInView.cjs.map +0 -7
  143. package/decorators/withScrolledInView.js.map +0 -7
@@ -1,22 +1,27 @@
1
1
  import { AbstractManager } from "./AbstractManager.js";
2
- import { isDev, isArray, isDefined } from "../../utils/index.js";
2
+ import { isDev, isArray, isDefined, getAncestorWhereUntil } from "../../utils/index.js";
3
3
  const NORMALIZE_REF_NAME_REGEX = /\[\]$/;
4
4
  function normalizeRefName(name) {
5
5
  return name.endsWith("[]") ? name.replace(NORMALIZE_REF_NAME_REGEX, "") : name;
6
6
  }
7
- function __filterRefsBelongingToInstance(that, ref) {
8
- let ancestor = ref.parentElement;
9
- while (ancestor && !isDefined(ancestor.dataset.component)) {
10
- ancestor = ancestor.parentElement;
11
- }
12
- return ancestor === null || ancestor === that.__element;
7
+ function refBelongToInstance(ref, rootElement, name) {
8
+ const isPrefixed = ref.dataset.ref.startsWith(name);
9
+ const firstComponentAncestor = getAncestorWhereUntil(
10
+ ref,
11
+ (el) => el && (isPrefixed ? el.dataset.component === name && el : isDefined(el.dataset.component)) && el !== rootElement,
12
+ (el) => el === rootElement
13
+ );
14
+ return firstComponentAncestor === rootElement;
13
15
  }
14
16
  function __register(that, refName) {
15
17
  const isMultiple = refName.endsWith("[]");
16
18
  const propName = normalizeRefName(refName);
19
+ const { name } = that.__base.$options;
17
20
  const refs = Array.from(
18
- that.__element.querySelectorAll(`[data-ref="${refName}"]`)
19
- ).filter((ref) => __filterRefsBelongingToInstance(that, ref));
21
+ that.__element.querySelectorAll(
22
+ `[data-ref="${refName}"],[data-ref="${name}.${refName}"]`
23
+ )
24
+ ).filter((ref) => refBelongToInstance(ref, that.__element, name));
20
25
  if (isDev && !isMultiple && refs.length > 1) {
21
26
  console.warn(
22
27
  `[${that.__base.$options.name}]`,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/Base/managers/RefsManager.ts"],
4
- "sourcesContent": ["import { AbstractManager } from './AbstractManager.js';\nimport { isDev, isArray, isDefined } from '../../utils/index.js';\n\nconst NORMALIZE_REF_NAME_REGEX = /\\[\\]$/;\n/**\n * Normalize the name of ref.\n */\nexport function normalizeRefName(name: string) {\n return name.endsWith('[]') ? name.replace(NORMALIZE_REF_NAME_REGEX, '') : name;\n}\n\n/**\n * Filter refs belonging to the related Base instance.\n */\nfunction __filterRefsBelongingToInstance(that: RefsManager, ref: HTMLElement) {\n let ancestor = ref.parentElement;\n\n while (ancestor && !isDefined(ancestor.dataset.component)) {\n ancestor = ancestor.parentElement;\n }\n\n return ancestor === null || ancestor === that.__element;\n}\n\n/**\n * Register one ref.\n *\n * @param {RefsManager} that\n * @param {string} refName The ref name.\n * @private\n */\nfunction __register(that: RefsManager, refName: string) {\n const isMultiple = refName.endsWith('[]');\n const propName = normalizeRefName(refName);\n\n const refs = Array.from(\n that.__element.querySelectorAll<HTMLElement>(`[data-ref=\"${refName}\"]`),\n ).filter((ref) => __filterRefsBelongingToInstance(that, ref));\n\n if (isDev && !isMultiple && refs.length > 1) {\n console.warn(\n // @ts-ignore\n `[${that.__base.$options.name}]`,\n `The \"${refName}\" ref has been found multiple times.`,\n 'Did you forgot to add the `[]` suffix to its name?',\n );\n }\n\n if (!isMultiple && refs.length <= 1 && !isDefined(refs[0])) {\n if (isDev) {\n console.warn(\n // @ts-ignore\n `[${that.__base.$options.name}]`,\n `The \"${refName}\" ref is missing.`,\n `Is there an \\`[data-ref=\"${refName}\"]\\` element in the component's scope?`,\n );\n }\n\n return;\n }\n\n that.__eventsManager.bindRef(refName, refs);\n\n Object.defineProperty(that, propName, {\n // @todo remove usage of non-multiple refs as array\n value: isMultiple || refs.length > 1 ? refs : refs[0],\n enumerable: true,\n configurable: true,\n });\n}\n\n/**\n * Unregister one ref.\n */\nfunction __unregister(that: RefsManager, refName: string) {\n const propName = normalizeRefName(refName);\n const refs = isArray(that[propName]) ? that[propName] : [that[propName]];\n that.__eventsManager.unbindRef(refName, refs);\n}\n\n/**\n * Refs Manager\n *\n * @todo Use `MutationObserver` to automatically update refs?\n */\nexport class RefsManager extends AbstractManager {\n /**\n * Get refs configuration.\n */\n get __refs() {\n return this.__config.refs ?? [];\n }\n\n /**\n * Register all refs.\n */\n registerAll() {\n this.__refs.forEach((refName) => __register(this, refName));\n }\n\n /**\n * Unregister all refs.\n */\n unregisterAll() {\n this.__refs.forEach((refName) => __unregister(this, refName));\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,OAAO,SAAS,iBAAiB;AAE1C,MAAM,2BAA2B;AAI1B,SAAS,iBAAiB,MAAc;AAC7C,SAAO,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,0BAA0B,EAAE,IAAI;AAC5E;AAKA,SAAS,gCAAgC,MAAmB,KAAkB;AAC5E,MAAI,WAAW,IAAI;AAEnB,SAAO,YAAY,CAAC,UAAU,SAAS,QAAQ,SAAS,GAAG;AACzD,eAAW,SAAS;AAAA,EACtB;AAEA,SAAO,aAAa,QAAQ,aAAa,KAAK;AAChD;AASA,SAAS,WAAW,MAAmB,SAAiB;AACtD,QAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,QAAM,WAAW,iBAAiB,OAAO;AAEzC,QAA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ntil } from '../../utils/index.js';\n\nconst NORMALIZE_REF_NAME_REGEX = /\\[\\]$/;\n\n/**\n * Normalize the name of ref.\n */\nexport function normalizeRefName(name: string) {\n return name.endsWith('[]') ? name.replace(NORMALIZE_REF_NAME_REGEX, '') : name;\n}\n\n/**\n * Filter refs belonging to the related Base instance.\n */\nfunction refBelongToInstance(ref: HTMLElement, rootElement: HTMLElement, name: string) {\n const isPrefixed = ref.dataset.ref.startsWith(name);\n const firstComponentAncestor = getAncestorWhereUntil(\n ref,\n (el) =>\n el &&\n (isPrefixed ? el.dataset.component === name && el : isDefined(el.dataset.component)) &&\n el !== rootElement,\n (el) => el === rootElement,\n );\n\n return firstComponentAncestor === rootElement;\n}\n\n/**\n * Register one ref.\n *\n * @param {RefsManager} that\n * @param {string} refName The ref name.\n * @private\n */\nfunction __register(that: RefsManager, refName: string) {\n const isMultiple = refName.endsWith('[]');\n const propName = normalizeRefName(refName);\n const { name } = that.__base.$options;\n\n const refs = Array.from(\n that.__element.querySelectorAll<HTMLElement>(\n `[data-ref=\"${refName}\"],[data-ref=\"${name}.${refName}\"]`,\n ),\n ).filter((ref) => refBelongToInstance(ref, that.__element, name));\n\n if (isDev && !isMultiple && refs.length > 1) {\n console.warn(\n // @ts-ignore\n `[${that.__base.$options.name}]`,\n `The \"${refName}\" ref has been found multiple times.`,\n 'Did you forgot to add the `[]` suffix to its name?',\n );\n }\n\n if (!isMultiple && refs.length <= 1 && !isDefined(refs[0])) {\n if (isDev) {\n console.warn(\n // @ts-ignore\n `[${that.__base.$options.name}]`,\n `The \"${refName}\" ref is missing.`,\n `Is there an \\`[data-ref=\"${refName}\"]\\` element in the component's scope?`,\n );\n }\n\n return;\n }\n\n that.__eventsManager.bindRef(refName, refs);\n\n Object.defineProperty(that, propName, {\n // @todo remove usage of non-multiple refs as array\n value: isMultiple || refs.length > 1 ? refs : refs[0],\n enumerable: true,\n configurable: true,\n });\n}\n\n/**\n * Unregister one ref.\n */\nfunction __unregister(that: RefsManager, refName: string) {\n const propName = normalizeRefName(refName);\n const refs = isArray(that[propName]) ? that[propName] : [that[propName]];\n that.__eventsManager.unbindRef(refName, refs);\n}\n\n/**\n * Refs Manager\n *\n * @todo Use `MutationObserver` to automatically update refs?\n */\nexport class RefsManager extends AbstractManager {\n /**\n * Get refs configuration.\n */\n get __refs() {\n return this.__config.refs ?? [];\n }\n\n /**\n * Register all refs.\n */\n registerAll() {\n this.__refs.forEach((refName) => __register(this, refName));\n }\n\n /**\n * Unregister all refs.\n */\n unregisterAll() {\n this.__refs.forEach((refName) => __unregister(this, refName));\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,OAAO,SAAS,WAAW,6BAA6B;AAEjE,MAAM,2BAA2B;AAK1B,SAAS,iBAAiB,MAAc;AAC7C,SAAO,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,0BAA0B,EAAE,IAAI;AAC5E;AAKA,SAAS,oBAAoB,KAAkB,aAA0B,MAAc;AACrF,QAAM,aAAa,IAAI,QAAQ,IAAI,WAAW,IAAI;AAClD,QAAM,yBAAyB;AAAA,IAC7B;AAAA,IACA,CAAC,OACC,OACC,aAAa,GAAG,QAAQ,cAAc,QAAQ,KAAK,UAAU,GAAG,QAAQ,SAAS,MAClF,OAAO;AAAA,IACT,CAAC,OAAO,OAAO;AAAA,EACjB;AAEA,SAAO,2BAA2B;AACpC;AASA,SAAS,WAAW,MAAmB,SAAiB;AACtD,QAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,QAAM,WAAW,iBAAiB,OAAO;AACzC,QAAM,EAAE,KAAK,IAAI,KAAK,OAAO;AAE7B,QAAM,OAAO,MAAM;AAAA,IACjB,KAAK,UAAU;AAAA,MACb,cAAc,wBAAwB,QAAQ;AAAA,IAChD;AAAA,EACF,EAAE,OAAO,CAAC,QAAQ,oBAAoB,KAAK,KAAK,WAAW,IAAI,CAAC;AAEhE,MAAI,SAAS,CAAC,cAAc,KAAK,SAAS,GAAG;AAC3C,YAAQ;AAAA,MAEN,IAAI,KAAK,OAAO,SAAS;AAAA,MACzB,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,cAAc,KAAK,UAAU,KAAK,CAAC,UAAU,KAAK,EAAE,GAAG;AAC1D,QAAI,OAAO;AACT,cAAQ;AAAA,QAEN,IAAI,KAAK,OAAO,SAAS;AAAA,QACzB,QAAQ;AAAA,QACR,4BAA4B;AAAA,MAC9B;AAAA,IACF;AAEA;AAAA,EACF;AAEA,OAAK,gBAAgB,QAAQ,SAAS,IAAI;AAE1C,SAAO,eAAe,MAAM,UAAU;AAAA,IAEpC,OAAO,cAAc,KAAK,SAAS,IAAI,OAAO,KAAK;AAAA,IACnD,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AACH;AAKA,SAAS,aAAa,MAAmB,SAAiB;AACxD,QAAM,WAAW,iBAAiB,OAAO;AACzC,QAAM,OAAO,QAAQ,KAAK,SAAS,IAAI,KAAK,YAAY,CAAC,KAAK,SAAS;AACvE,OAAK,gBAAgB,UAAU,SAAS,IAAI;AAC9C;AAOO,MAAM,oBAAoB,gBAAgB;AAAA,EAI/C,IAAI,SAAS;AACX,WAAO,KAAK,SAAS,QAAQ,CAAC;AAAA,EAChC;AAAA,EAKA,cAAc;AACZ,SAAK,OAAO,QAAQ,CAAC,YAAY,WAAW,MAAM,OAAO,CAAC;AAAA,EAC5D;AAAA,EAKA,gBAAgB;AACd,SAAK,OAAO,QAAQ,CAAC,YAAY,aAAa,MAAM,OAAO,CAAC;AAAA,EAC9D;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import { OptionsManager } from './OptionsManager.js';
2
2
  import type { OptionObject } from './OptionsManager.js';
3
- export declare type ResponsiveOptionObject = OptionObject & {
3
+ export type ResponsiveOptionObject = OptionObject & {
4
4
  responsive?: boolean;
5
5
  };
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import { usePointer, useRaf, useResize, useScroll, useKey, useLoad } from '../../services/index.js';
2
2
  import type { PointerServiceInterface, RafServiceInterface, ResizeServiceInterface, ScrollServiceInterface, KeyServiceInterface, LoadServiceInterface, ServiceInterface } from '../../services/index.js';
3
3
  import { AbstractManager } from './AbstractManager.js';
4
- declare type Services = {
4
+ type Services = {
5
5
  scrolled: ScrollServiceInterface;
6
6
  resized: ResizeServiceInterface;
7
7
  ticked: RafServiceInterface;
@@ -9,7 +9,7 @@ declare type Services = {
9
9
  keyed: KeyServiceInterface;
10
10
  loaded: LoadServiceInterface;
11
11
  } & Record<string, ServiceInterface<unknown>>;
12
- declare type ServiceNames = keyof Services;
12
+ type ServiceNames = keyof Services;
13
13
  /**
14
14
  * Services management for the Base class.
15
15
  *
@@ -20,7 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var managers_exports = {};
21
21
  __export(managers_exports, {
22
22
  AbstractManager: () => import_AbstractManager.AbstractManager,
23
- AsyncChildrenManager: () => import_AsyncChildrenManager.AsyncChildrenManager,
24
23
  ChildrenManager: () => import_ChildrenManager.ChildrenManager,
25
24
  EventsManager: () => import_EventsManager.EventsManager,
26
25
  OptionsManager: () => import_OptionsManager.OptionsManager,
@@ -30,7 +29,6 @@ __export(managers_exports, {
30
29
  });
31
30
  module.exports = __toCommonJS(managers_exports);
32
31
  var import_AbstractManager = require("./AbstractManager.cjs");
33
- var import_AsyncChildrenManager = require("./AsyncChildrenManager.cjs");
34
32
  var import_ChildrenManager = require("./ChildrenManager.cjs");
35
33
  var import_EventsManager = require("./EventsManager.cjs");
36
34
  var import_OptionsManager = require("./OptionsManager.cjs");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/Base/managers/index.ts"],
4
- "sourcesContent": ["export { AbstractManager } from './AbstractManager.js';\nexport { AsyncChildrenManager } from './AsyncChildrenManager.js';\nexport { ChildrenManager } from './ChildrenManager.js';\nexport { EventsManager } from './EventsManager.js';\nexport { OptionsManager } from './OptionsManager.js';\nexport { RefsManager } from './RefsManager.js';\nexport { ResponsiveOptionsManager } from './ResponsiveOptionsManager.js';\nexport { ServicesManager } from './ServicesManager.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAgC;AAChC,kCAAqC;AACrC,6BAAgC;AAChC,2BAA8B;AAC9B,4BAA+B;AAC/B,yBAA4B;AAC5B,sCAAyC;AACzC,6BAAgC;",
4
+ "sourcesContent": ["export { AbstractManager } from './AbstractManager.js';\nexport { ChildrenManager } from './ChildrenManager.js';\nexport { EventsManager } from './EventsManager.js';\nexport { OptionsManager } from './OptionsManager.js';\nexport { RefsManager } from './RefsManager.js';\nexport { ResponsiveOptionsManager } from './ResponsiveOptionsManager.js';\nexport { ServicesManager } from './ServicesManager.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAgC;AAChC,6BAAgC;AAChC,2BAA8B;AAC9B,4BAA+B;AAC/B,yBAA4B;AAC5B,sCAAyC;AACzC,6BAAgC;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,4 @@
1
1
  export { AbstractManager } from './AbstractManager.js';
2
- export { AsyncChildrenManager } from './AsyncChildrenManager.js';
3
2
  export { ChildrenManager } from './ChildrenManager.js';
4
3
  export { EventsManager } from './EventsManager.js';
5
4
  export { OptionsManager } from './OptionsManager.js';
@@ -1,5 +1,4 @@
1
1
  import { AbstractManager } from "./AbstractManager.js";
2
- import { AsyncChildrenManager } from "./AsyncChildrenManager.js";
3
2
  import { ChildrenManager } from "./ChildrenManager.js";
4
3
  import { EventsManager } from "./EventsManager.js";
5
4
  import { OptionsManager } from "./OptionsManager.js";
@@ -8,7 +7,6 @@ import { ResponsiveOptionsManager } from "./ResponsiveOptionsManager.js";
8
7
  import { ServicesManager } from "./ServicesManager.js";
9
8
  export {
10
9
  AbstractManager,
11
- AsyncChildrenManager,
12
10
  ChildrenManager,
13
11
  EventsManager,
14
12
  OptionsManager,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/Base/managers/index.ts"],
4
- "sourcesContent": ["export { AbstractManager } from './AbstractManager.js';\nexport { AsyncChildrenManager } from './AsyncChildrenManager.js';\nexport { ChildrenManager } from './ChildrenManager.js';\nexport { EventsManager } from './EventsManager.js';\nexport { OptionsManager } from './OptionsManager.js';\nexport { RefsManager } from './RefsManager.js';\nexport { ResponsiveOptionsManager } from './ResponsiveOptionsManager.js';\nexport { ServicesManager } from './ServicesManager.js';\n"],
5
- "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,uBAAuB;",
4
+ "sourcesContent": ["export { AbstractManager } from './AbstractManager.js';\nexport { ChildrenManager } from './ChildrenManager.js';\nexport { EventsManager } from './EventsManager.js';\nexport { OptionsManager } from './OptionsManager.js';\nexport { RefsManager } from './RefsManager.js';\nexport { ResponsiveOptionsManager } from './ResponsiveOptionsManager.js';\nexport { ServicesManager } from './ServicesManager.js';\n"],
5
+ "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,uBAAuB;",
6
6
  "names": []
7
7
  }
package/Base/types.d.ts CHANGED
@@ -42,6 +42,6 @@ export interface BaseInterface {
42
42
  */
43
43
  scrolled?(props: ScrollServiceProps): void;
44
44
  }
45
- export declare type BaseDecorator<S extends BaseInterface, T extends Base, U extends BaseProps = BaseProps> = {
45
+ export type BaseDecorator<S extends BaseInterface, T extends Base, U extends BaseProps = BaseProps> = {
46
46
  new <W extends BaseProps = BaseProps>(...args: unknown[]): S & T & Base<W & U>;
47
47
  } & Partial<Pick<T, keyof T>> & Pick<typeof Base, keyof typeof Base>;
package/Base/utils.cjs CHANGED
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // packages/js-toolkit/Base/utils.ts
20
20
  var utils_exports = {};
21
21
  __export(utils_exports, {
22
+ addToQueue: () => addToQueue,
22
23
  eventIsDefinedInConfig: () => eventIsDefinedInConfig,
23
24
  eventIsNative: () => eventIsNative,
24
25
  getComponentElements: () => getComponentElements,
@@ -26,8 +27,34 @@ __export(utils_exports, {
26
27
  });
27
28
  module.exports = __toCommonJS(utils_exports);
28
29
  var import_utils = require("../utils/index.cjs");
30
+ var import_features = require("./features.cjs");
31
+ var queue;
32
+ function addToQueue(fn) {
33
+ if (!import_features.features.get("asyncChildren")) {
34
+ fn();
35
+ return;
36
+ }
37
+ if (!queue) {
38
+ queue = new import_utils.SmartQueue();
39
+ }
40
+ queue.add(fn);
41
+ }
42
+ var selectors = /* @__PURE__ */ new Map();
43
+ var separator = " ";
44
+ function getSelector(nameOrSelector) {
45
+ if (!selectors.has(nameOrSelector)) {
46
+ const parts = [
47
+ `[data-component="${nameOrSelector}"]`,
48
+ `[data-component*="${separator}${nameOrSelector}${separator}"]`,
49
+ `[data-component$="${separator}${nameOrSelector}"]`,
50
+ `[data-component^="${nameOrSelector}${separator}"]`
51
+ ];
52
+ selectors.set(nameOrSelector, parts.join(","));
53
+ }
54
+ return selectors.get(nameOrSelector);
55
+ }
29
56
  function getComponentElements(nameOrSelector, element = document) {
30
- const selector = `[data-component="${nameOrSelector}"]`;
57
+ const selector = getSelector(nameOrSelector);
31
58
  let elements = [];
32
59
  try {
33
60
  elements = Array.from(element.querySelectorAll(selector));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/Base/utils.ts"],
4
- "sourcesContent": ["import { isArray, isDefined, isDev } from '../utils/index.js';\nimport type { Base, BaseConfig } from './index.js';\n\n/**\n * Get a list of elements based on the name of a component.\n *\n * @param {string} nameOrSelector\n * The name or selector to used for this component.\n * @param {HTMLElement|Document} element\n * The root element on which to query the selector, defaults to `document`.\n * @returns {Array<HTMLElement>}\n * A list of elements on which the component should be mounted.\n */\nexport function getComponentElements(\n nameOrSelector: string,\n element: HTMLElement | Document = document,\n): HTMLElement[] {\n const selector = `[data-component=\"${nameOrSelector}\"]`;\n let elements = [];\n\n try {\n elements = Array.from(element.querySelectorAll(selector));\n // eslint-disable-next-line no-empty\n } catch {}\n\n // If no child component found with the default selector, try a classic DOM selector\n if (elements.length === 0) {\n elements = Array.from(element.querySelectorAll(nameOrSelector));\n }\n\n return elements;\n}\n\n/**\n * Test if an event is defined in the given config.\n */\nexport function eventIsDefinedInConfig(event: string, config: BaseConfig): boolean {\n return isArray(config.emits) && config.emits.includes(event);\n}\n\n/**\n * Test if an event can be used on the given element.\n */\nexport function eventIsNative(event: string, element: HTMLElement): boolean {\n return isDefined(element[`on${event}`]);\n}\n\n/**\n * Get the target of a given event.\n * @todo Return false in v3 if event is not defined or not native to prevent adding a listener.\n */\nexport function getEventTarget(\n instance: Base,\n event: string,\n config: BaseConfig,\n): Base | Base['$el'] {\n if (eventIsDefinedInConfig(event, config)) {\n return instance;\n }\n\n if (eventIsNative(event, instance.$el)) {\n return instance.$el;\n }\n\n if (isDev) {\n console.warn(\n `[${config.name}]`,\n `The \"${event}\" event is missing from the configuration and is not a native`,\n `event for the root element of type \\`${instance.$el.constructor.name}\\`.`,\n );\n }\n\n // @todo v3 return false or null\n return instance;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAanC,SAAS,qBACd,gBACA,UAAkC,UACnB;AACf,QAAM,WAAW,oBAAoB;AACrC,MAAI,WAAW,CAAC;AAEhB,MAAI;AACF,eAAW,MAAM,KAAK,QAAQ,iBAAiB,QAAQ,CAAC;AAAA,EAE1D,QAAE;AAAA,EAAO;AAGT,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,MAAM,KAAK,QAAQ,iBAAiB,cAAc,CAAC;AAAA,EAChE;AAEA,SAAO;AACT;AAKO,SAAS,uBAAuB,OAAe,QAA6B;AACjF,aAAO,sBAAQ,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,KAAK;AAC7D;AAKO,SAAS,cAAc,OAAe,SAA+B;AAC1E,aAAO,wBAAU,QAAQ,KAAK,QAAQ;AACxC;AAMO,SAAS,eACd,UACA,OACA,QACoB;AACpB,MAAI,uBAAuB,OAAO,MAAM,GAAG;AACzC,WAAO;AAAA,EACT;AAEA,MAAI,cAAc,OAAO,SAAS,GAAG,GAAG;AACtC,WAAO,SAAS;AAAA,EAClB;AAEA,MAAI,oBAAO;AACT,YAAQ;AAAA,MACN,IAAI,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,wCAAwC,SAAS,IAAI,YAAY;AAAA,IACnE;AAAA,EACF;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["import { isArray, isDefined, isDev, SmartQueue } from '../utils/index.js';\nimport type { Base, BaseConfig } from './index.js';\nimport { features } from './features.js';\n\nlet queue: SmartQueue;\n\n/**\n * Add a task to the main queue.\n */\nexport function addToQueue(fn: () => unknown): void {\n if (!features.get('asyncChildren')) {\n fn();\n return;\n }\n\n if (!queue) {\n queue = new SmartQueue();\n }\n\n queue.add(fn);\n}\n\nconst selectors = new Map();\n\n// Separator used for multi-component declaration in `data-component` attributeS.\nconst separator = ' ';\n\n/**\n * Get the selector for a given component.\n */\nfunction getSelector(nameOrSelector: string): string {\n if (!selectors.has(nameOrSelector)) {\n const parts = [\n // Single selector\n `[data-component=\"${nameOrSelector}\"]`,\n // Selector in the middle of a list of selectors\n `[data-component*=\"${separator}${nameOrSelector}${separator}\"]`,\n // Selector at the end of a list of selectors\n `[data-component$=\"${separator}${nameOrSelector}\"]`,\n // Selector at the beginning of a list of selectors\n `[data-component^=\"${nameOrSelector}${separator}\"]`,\n ];\n selectors.set(nameOrSelector, parts.join(','));\n }\n\n return selectors.get(nameOrSelector);\n}\n\n/**\n * Get a list of elements based on the name of a component.\n *\n * @param {string} nameOrSelector\n * The name or selector to used for this component.\n * @param {HTMLElement|Document} element\n * The root element on which to query the selector, defaults to `document`.\n * @returns {Array<HTMLElement>}\n * A list of elements on which the component should be mounted.\n */\nexport function getComponentElements(\n nameOrSelector: string,\n element: HTMLElement | Document = document,\n): HTMLElement[] {\n const selector = getSelector(nameOrSelector);\n let elements = [];\n\n try {\n elements = Array.from(element.querySelectorAll(selector));\n // eslint-disable-next-line no-empty\n } catch {}\n\n // If no child component found with the default selector, try a classic DOM selector\n if (elements.length === 0) {\n elements = Array.from(element.querySelectorAll(nameOrSelector));\n }\n\n return elements;\n}\n\n/**\n * Test if an event is defined in the given config.\n */\nexport function eventIsDefinedInConfig(event: string, config: BaseConfig): boolean {\n return isArray(config.emits) && config.emits.includes(event);\n}\n\n/**\n * Test if an event can be used on the given element.\n */\nexport function eventIsNative(event: string, element: HTMLElement): boolean {\n return isDefined(element[`on${event}`]);\n}\n\n/**\n * Get the target of a given event.\n * @todo Return false in v3 if event is not defined or not native to prevent adding a listener.\n */\nexport function getEventTarget(\n instance: Base,\n event: string,\n config: BaseConfig,\n): Base | Base['$el'] {\n if (eventIsDefinedInConfig(event, config)) {\n return instance;\n }\n\n if (eventIsNative(event, instance.$el)) {\n return instance.$el;\n }\n\n if (isDev) {\n console.warn(\n `[${config.name}]`,\n `The \"${event}\" event is missing from the configuration and is not a native`,\n `event for the root element of type \\`${instance.$el.constructor.name}\\`.`,\n );\n }\n\n // @todo v3 return false or null\n return instance;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AAAA,EAClB;AAEA,MAAI,oBAAO;AACT,YAAQ;AAAA,MACN,IAAI,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,wCAAwC,SAAS,IAAI,YAAY;AAAA,IACnE;AAAA,EACF;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/Base/utils.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import type { Base, BaseConfig } from './index.js';
2
+ /**
3
+ * Add a task to the main queue.
4
+ */
5
+ export declare function addToQueue(fn: () => unknown): void;
2
6
  /**
3
7
  * Get a list of elements based on the name of a component.
4
8
  *
package/Base/utils.js CHANGED
@@ -1,6 +1,32 @@
1
- import { isArray, isDefined, isDev } from "../utils/index.js";
1
+ import { isArray, isDefined, isDev, SmartQueue } from "../utils/index.js";
2
+ import { features } from "./features.js";
3
+ let queue;
4
+ function addToQueue(fn) {
5
+ if (!features.get("asyncChildren")) {
6
+ fn();
7
+ return;
8
+ }
9
+ if (!queue) {
10
+ queue = new SmartQueue();
11
+ }
12
+ queue.add(fn);
13
+ }
14
+ const selectors = /* @__PURE__ */ new Map();
15
+ const separator = " ";
16
+ function getSelector(nameOrSelector) {
17
+ if (!selectors.has(nameOrSelector)) {
18
+ const parts = [
19
+ `[data-component="${nameOrSelector}"]`,
20
+ `[data-component*="${separator}${nameOrSelector}${separator}"]`,
21
+ `[data-component$="${separator}${nameOrSelector}"]`,
22
+ `[data-component^="${nameOrSelector}${separator}"]`
23
+ ];
24
+ selectors.set(nameOrSelector, parts.join(","));
25
+ }
26
+ return selectors.get(nameOrSelector);
27
+ }
2
28
  function getComponentElements(nameOrSelector, element = document) {
3
- const selector = `[data-component="${nameOrSelector}"]`;
29
+ const selector = getSelector(nameOrSelector);
4
30
  let elements = [];
5
31
  try {
6
32
  elements = Array.from(element.querySelectorAll(selector));
@@ -34,6 +60,7 @@ function getEventTarget(instance, event, config) {
34
60
  return instance;
35
61
  }
36
62
  export {
63
+ addToQueue,
37
64
  eventIsDefinedInConfig,
38
65
  eventIsNative,
39
66
  getComponentElements,
package/Base/utils.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/Base/utils.ts"],
4
- "sourcesContent": ["import { isArray, isDefined, isDev } from '../utils/index.js';\nimport type { Base, BaseConfig } from './index.js';\n\n/**\n * Get a list of elements based on the name of a component.\n *\n * @param {string} nameOrSelector\n * The name or selector to used for this component.\n * @param {HTMLElement|Document} element\n * The root element on which to query the selector, defaults to `document`.\n * @returns {Array<HTMLElement>}\n * A list of elements on which the component should be mounted.\n */\nexport function getComponentElements(\n nameOrSelector: string,\n element: HTMLElement | Document = document,\n): HTMLElement[] {\n const selector = `[data-component=\"${nameOrSelector}\"]`;\n let elements = [];\n\n try {\n elements = Array.from(element.querySelectorAll(selector));\n // eslint-disable-next-line no-empty\n } catch {}\n\n // If no child component found with the default selector, try a classic DOM selector\n if (elements.length === 0) {\n elements = Array.from(element.querySelectorAll(nameOrSelector));\n }\n\n return elements;\n}\n\n/**\n * Test if an event is defined in the given config.\n */\nexport function eventIsDefinedInConfig(event: string, config: BaseConfig): boolean {\n return isArray(config.emits) && config.emits.includes(event);\n}\n\n/**\n * Test if an event can be used on the given element.\n */\nexport function eventIsNative(event: string, element: HTMLElement): boolean {\n return isDefined(element[`on${event}`]);\n}\n\n/**\n * Get the target of a given event.\n * @todo Return false in v3 if event is not defined or not native to prevent adding a listener.\n */\nexport function getEventTarget(\n instance: Base,\n event: string,\n config: BaseConfig,\n): Base | Base['$el'] {\n if (eventIsDefinedInConfig(event, config)) {\n return instance;\n }\n\n if (eventIsNative(event, instance.$el)) {\n return instance.$el;\n }\n\n if (isDev) {\n console.warn(\n `[${config.name}]`,\n `The \"${event}\" event is missing from the configuration and is not a native`,\n `event for the root element of type \\`${instance.$el.constructor.name}\\`.`,\n );\n }\n\n // @todo v3 return false or null\n return instance;\n}\n"],
5
- "mappings": "AAAA,SAAS,SAAS,WAAW,aAAa;AAanC,SAAS,qBACd,gBACA,UAAkC,UACnB;AACf,QAAM,WAAW,oBAAoB;AACrC,MAAI,WAAW,CAAC;AAEhB,MAAI;AACF,eAAW,MAAM,KAAK,QAAQ,iBAAiB,QAAQ,CAAC;AAAA,EAE1D,QAAE;AAAA,EAAO;AAGT,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,MAAM,KAAK,QAAQ,iBAAiB,cAAc,CAAC;AAAA,EAChE;AAEA,SAAO;AACT;AAKO,SAAS,uBAAuB,OAAe,QAA6B;AACjF,SAAO,QAAQ,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,KAAK;AAC7D;AAKO,SAAS,cAAc,OAAe,SAA+B;AAC1E,SAAO,UAAU,QAAQ,KAAK,QAAQ;AACxC;AAMO,SAAS,eACd,UACA,OACA,QACoB;AACpB,MAAI,uBAAuB,OAAO,MAAM,GAAG;AACzC,WAAO;AAAA,EACT;AAEA,MAAI,cAAc,OAAO,SAAS,GAAG,GAAG;AACtC,WAAO,SAAS;AAAA,EAClB;AAEA,MAAI,OAAO;AACT,YAAQ;AAAA,MACN,IAAI,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,wCAAwC,SAAS,IAAI,YAAY;AAAA,IACnE;AAAA,EACF;AAGA,SAAO;AACT;",
4
+ "sourcesContent": ["import { isArray, isDefined, isDev, SmartQueue } from '../utils/index.js';\nimport type { Base, BaseConfig } from './index.js';\nimport { features } from './features.js';\n\nlet queue: SmartQueue;\n\n/**\n * Add a task to the main queue.\n */\nexport function addToQueue(fn: () => unknown): void {\n if (!features.get('asyncChildren')) {\n fn();\n return;\n }\n\n if (!queue) {\n queue = new SmartQueue();\n }\n\n queue.add(fn);\n}\n\nconst selectors = new Map();\n\n// Separator used for multi-component declaration in `data-component` attributeS.\nconst separator = ' ';\n\n/**\n * Get the selector for a given component.\n */\nfunction getSelector(nameOrSelector: string): string {\n if (!selectors.has(nameOrSelector)) {\n const parts = [\n // Single selector\n `[data-component=\"${nameOrSelector}\"]`,\n // Selector in the middle of a list of selectors\n `[data-component*=\"${separator}${nameOrSelector}${separator}\"]`,\n // Selector at the end of a list of selectors\n `[data-component$=\"${separator}${nameOrSelector}\"]`,\n // Selector at the beginning of a list of selectors\n `[data-component^=\"${nameOrSelector}${separator}\"]`,\n ];\n selectors.set(nameOrSelector, parts.join(','));\n }\n\n return selectors.get(nameOrSelector);\n}\n\n/**\n * Get a list of elements based on the name of a component.\n *\n * @param {string} nameOrSelector\n * The name or selector to used for this component.\n * @param {HTMLElement|Document} element\n * The root element on which to query the selector, defaults to `document`.\n * @returns {Array<HTMLElement>}\n * A list of elements on which the component should be mounted.\n */\nexport function getComponentElements(\n nameOrSelector: string,\n element: HTMLElement | Document = document,\n): HTMLElement[] {\n const selector = getSelector(nameOrSelector);\n let elements = [];\n\n try {\n elements = Array.from(element.querySelectorAll(selector));\n // eslint-disable-next-line no-empty\n } catch {}\n\n // If no child component found with the default selector, try a classic DOM selector\n if (elements.length === 0) {\n elements = Array.from(element.querySelectorAll(nameOrSelector));\n }\n\n return elements;\n}\n\n/**\n * Test if an event is defined in the given config.\n */\nexport function eventIsDefinedInConfig(event: string, config: BaseConfig): boolean {\n return isArray(config.emits) && config.emits.includes(event);\n}\n\n/**\n * Test if an event can be used on the given element.\n */\nexport function eventIsNative(event: string, element: HTMLElement): boolean {\n return isDefined(element[`on${event}`]);\n}\n\n/**\n * Get the target of a given event.\n * @todo Return false in v3 if event is not defined or not native to prevent adding a listener.\n */\nexport function getEventTarget(\n instance: Base,\n event: string,\n config: BaseConfig,\n): Base | Base['$el'] {\n if (eventIsDefinedInConfig(event, config)) {\n return instance;\n }\n\n if (eventIsNative(event, instance.$el)) {\n return instance.$el;\n }\n\n if (isDev) {\n console.warn(\n `[${config.name}]`,\n `The \"${event}\" event is missing from the configuration and is not a native`,\n `event for the root element of type \\`${instance.$el.constructor.name}\\`.`,\n );\n }\n\n // @todo v3 return false or null\n return instance;\n}\n"],
5
+ "mappings": "AAAA,SAAS,SAAS,WAAW,OAAO,kBAAk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EA,MAAI,OAAO;AACT,YAAQ;AAAA,MACN,IAAI,OAAO;AAAA,MACX,QAAQ;AAAA,MACR,wCAAwC,SAAS,IAAI,YAAY;AAAA,IACnE;AAAA,EACF;AAGA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -24,7 +24,7 @@ __reExport(decorators_exports, require("./withFreezedOptions.cjs"), module.expor
24
24
  __reExport(decorators_exports, require("./withIntersectionObserver.cjs"), module.exports);
25
25
  __reExport(decorators_exports, require("./withMountWhenInView.cjs"), module.exports);
26
26
  __reExport(decorators_exports, require("./withResponsiveOptions.cjs"), module.exports);
27
- __reExport(decorators_exports, require("./withScrolledInView.cjs"), module.exports);
27
+ __reExport(decorators_exports, require("./withScrolledInView/index.cjs"), module.exports);
28
28
  __reExport(decorators_exports, require("./withVue2.cjs"), module.exports);
29
29
  if (module.exports.default) module.exports = module.exports.default;
30
30
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/decorators/index.ts"],
4
- "sourcesContent": ["export * from './withBreakpointManager.js';\nexport * from './withBreakpointObserver.js';\nexport * from './withDrag.js';\nexport * from './withExtraConfig.js';\nexport * from './withFreezedOptions.js';\nexport * from './withIntersectionObserver.js';\nexport * from './withMountWhenInView.js';\nexport * from './withResponsiveOptions.js';\nexport * from './withScrolledInView.js';\nexport * from './withVue2.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,wCAAd;AACA,+BAAc,yCADd;AAEA,+BAAc,2BAFd;AAGA,+BAAc,kCAHd;AAIA,+BAAc,qCAJd;AAKA,+BAAc,2CALd;AAMA,+BAAc,sCANd;AAOA,+BAAc,wCAPd;AAQA,+BAAc,qCARd;AASA,+BAAc,2BATd;",
4
+ "sourcesContent": ["export * from './withBreakpointManager.js';\nexport * from './withBreakpointObserver.js';\nexport * from './withDrag.js';\nexport * from './withExtraConfig.js';\nexport * from './withFreezedOptions.js';\nexport * from './withIntersectionObserver.js';\nexport * from './withMountWhenInView.js';\nexport * from './withResponsiveOptions.js';\nexport * from './withScrolledInView/index.js';\nexport * from './withVue2.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,wCAAd;AACA,+BAAc,yCADd;AAEA,+BAAc,2BAFd;AAGA,+BAAc,kCAHd;AAIA,+BAAc,qCAJd;AAKA,+BAAc,2CALd;AAMA,+BAAc,sCANd;AAOA,+BAAc,wCAPd;AAQA,+BAAc,2CARd;AASA,+BAAc,2BATd;",
6
6
  "names": []
7
7
  }
@@ -6,5 +6,5 @@ export * from './withFreezedOptions.js';
6
6
  export * from './withIntersectionObserver.js';
7
7
  export * from './withMountWhenInView.js';
8
8
  export * from './withResponsiveOptions.js';
9
- export * from './withScrolledInView.js';
9
+ export * from './withScrolledInView/index.js';
10
10
  export * from './withVue2.js';
@@ -6,6 +6,6 @@ export * from "./withFreezedOptions.js";
6
6
  export * from "./withIntersectionObserver.js";
7
7
  export * from "./withMountWhenInView.js";
8
8
  export * from "./withResponsiveOptions.js";
9
- export * from "./withScrolledInView.js";
9
+ export * from "./withScrolledInView/index.js";
10
10
  export * from "./withVue2.js";
11
11
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/decorators/index.ts"],
4
- "sourcesContent": ["export * from './withBreakpointManager.js';\nexport * from './withBreakpointObserver.js';\nexport * from './withDrag.js';\nexport * from './withExtraConfig.js';\nexport * from './withFreezedOptions.js';\nexport * from './withIntersectionObserver.js';\nexport * from './withMountWhenInView.js';\nexport * from './withResponsiveOptions.js';\nexport * from './withScrolledInView.js';\nexport * from './withVue2.js';\n"],
4
+ "sourcesContent": ["export * from './withBreakpointManager.js';\nexport * from './withBreakpointObserver.js';\nexport * from './withDrag.js';\nexport * from './withExtraConfig.js';\nexport * from './withFreezedOptions.js';\nexport * from './withIntersectionObserver.js';\nexport * from './withMountWhenInView.js';\nexport * from './withResponsiveOptions.js';\nexport * from './withScrolledInView/index.js';\nexport * from './withVue2.js';\n"],
5
5
  "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import type { BaseDecorator, BaseInterface } from '../Base/types.js';
2
2
  import type { Base } from '../Base/index.js';
3
3
  import type { DragServiceOptions, DragServiceProps } from '../services/drag.js';
4
- export declare type DragDecoratorOptions = DragServiceOptions & {
4
+ export type DragDecoratorOptions = DragServiceOptions & {
5
5
  target?: (this: Base, instance: Base) => HTMLElement;
6
6
  };
7
7
  export interface WithDragInterface extends BaseInterface {
@@ -0,0 +1,22 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // packages/js-toolkit/decorators/withScrolledInView/index.ts
17
+ var withScrolledInView_exports = {};
18
+ module.exports = __toCommonJS(withScrolledInView_exports);
19
+ __reExport(withScrolledInView_exports, require("./withScrolledInView.cjs"), module.exports);
20
+ __reExport(withScrolledInView_exports, require("./types.cjs"), module.exports);
21
+ if (module.exports.default) module.exports = module.exports.default;
22
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../packages/js-toolkit/decorators/withScrolledInView/index.ts"],
4
+ "sourcesContent": ["export * from './withScrolledInView.js';\nexport * from './types.js';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,uCAAc,qCAAd;AACA,uCAAc,wBADd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from './withScrolledInView.js';
2
+ export * from './types.js';
@@ -0,0 +1,3 @@
1
+ export * from "./withScrolledInView.js";
2
+ export * from "./types.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../packages/js-toolkit/decorators/withScrolledInView/index.ts"],
4
+ "sourcesContent": ["export * from './withScrolledInView.js';\nexport * from './types.js';\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,19 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // packages/js-toolkit/decorators/withScrolledInView/types.ts
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
18
+ if (module.exports.default) module.exports = module.exports.default;
19
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../packages/js-toolkit/decorators/withScrolledInView/types.ts"],
4
+ "sourcesContent": ["export type OffsetValue = 'start' | 'center' | 'end' | string | number;\n\nexport type NormalizedOffset = [[OffsetValue, OffsetValue], [OffsetValue, OffsetValue]];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export type OffsetValue = 'start' | 'center' | 'end' | string | number;
2
+ export type NormalizedOffset = [[OffsetValue, OffsetValue], [OffsetValue, OffsetValue]];
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,99 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // packages/js-toolkit/decorators/withScrolledInView/utils.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ getEdgeWithOffset: () => getEdgeWithOffset,
23
+ getEdges: () => getEdges,
24
+ normalizeOffset: () => normalizeOffset,
25
+ parseNamedOffset: () => parseNamedOffset
26
+ });
27
+ module.exports = __toCommonJS(utils_exports);
28
+ var import_utils = require("../../utils/index.cjs");
29
+ var units = {
30
+ px: "px",
31
+ vh: "vh",
32
+ vw: "vw",
33
+ vmin: "vmin",
34
+ vmax: "vmax",
35
+ percent: "%"
36
+ };
37
+ var namedOffsets = {
38
+ start: 0,
39
+ center: 0.5,
40
+ end: 1
41
+ };
42
+ function normalizeOffset(offsets) {
43
+ return offsets.split("/").map((offset) => offset.trim().split(" ").slice(0, 2));
44
+ }
45
+ function parseNamedOffset(offset) {
46
+ if ((0, import_utils.isNumber)(offset)) {
47
+ return offset;
48
+ }
49
+ if ((0, import_utils.isNumber)(namedOffsets[offset])) {
50
+ return namedOffsets[offset];
51
+ }
52
+ if ((0, import_utils.isNumber)(Number(offset))) {
53
+ return Number(offset);
54
+ }
55
+ if ((0, import_utils.isString)(offset) && offset.endsWith(units.percent)) {
56
+ return Number.parseFloat(offset) / 100;
57
+ }
58
+ return offset;
59
+ }
60
+ function getEdgeWithOffset(start, size, offset) {
61
+ if ((0, import_utils.isNumber)(offset)) {
62
+ return start + size * offset;
63
+ }
64
+ const parsedNamedOffset = parseNamedOffset(offset);
65
+ if ((0, import_utils.isNumber)(parsedNamedOffset)) {
66
+ return start + size * parsedNamedOffset;
67
+ }
68
+ if ((0, import_utils.isString)(parsedNamedOffset)) {
69
+ const parsedOffset = Number.parseFloat(parsedNamedOffset);
70
+ if (parsedNamedOffset.endsWith(units.px)) {
71
+ return start + parsedOffset;
72
+ }
73
+ if (parsedNamedOffset.endsWith(units.vh)) {
74
+ return start + parsedOffset * window.innerHeight / 100;
75
+ }
76
+ if (parsedNamedOffset.endsWith(units.vw)) {
77
+ return start + parsedOffset * window.innerWidth / 100;
78
+ }
79
+ if (parsedNamedOffset.endsWith(units.vmin)) {
80
+ return start + parsedOffset * Math.min(window.innerWidth, window.innerHeight) / 100;
81
+ }
82
+ if (parsedNamedOffset.endsWith(units.vmax)) {
83
+ return start + parsedOffset * Math.max(window.innerWidth, window.innerHeight) / 100;
84
+ }
85
+ }
86
+ return start;
87
+ }
88
+ function getEdges(axis, targetSizes, containerSizes, offset) {
89
+ const sizeKey = axis === "x" ? "width" : "height";
90
+ const targetStart = getEdgeWithOffset(targetSizes[axis], targetSizes[sizeKey], offset[0][0]);
91
+ const containerStart = getEdgeWithOffset(0, containerSizes[sizeKey], offset[0][1]);
92
+ const targetEnd = getEdgeWithOffset(targetSizes[axis], targetSizes[sizeKey], offset[1][0]);
93
+ const containerEnd = getEdgeWithOffset(0, containerSizes[sizeKey], offset[1][1]);
94
+ const start = targetStart - containerStart;
95
+ const end = targetEnd - containerEnd;
96
+ return [start, end];
97
+ }
98
+ if (module.exports.default) module.exports = module.exports.default;
99
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../packages/js-toolkit/decorators/withScrolledInView/utils.ts"],
4
+ "sourcesContent": ["import { isNumber, isString } from '../../utils/index.js';\nimport type { NormalizedOffset } from './types.js';\n\nconst units = {\n px: 'px',\n vh: 'vh',\n vw: 'vw',\n vmin: 'vmin',\n vmax: 'vmax',\n percent: '%',\n};\n\nconst namedOffsets = {\n start: 0,\n center: 0.5,\n end: 1,\n};\n\n/**\n * Normalize offset input.\n */\nexport function normalizeOffset(offsets: string): NormalizedOffset {\n return offsets\n .split('/')\n .map((offset) => offset.trim().split(' ').slice(0, 2)) as NormalizedOffset;\n}\n\n/**\n * Parse the given offset.\n */\nexport function parseNamedOffset(offset: string | number): string | number {\n if (isNumber(offset)) {\n return offset;\n }\n\n if (isNumber(namedOffsets[offset])) {\n return namedOffsets[offset];\n }\n\n if (isNumber(Number(offset))) {\n return Number(offset);\n }\n\n if (isString(offset) && offset.endsWith(units.percent)) {\n return Number.parseFloat(offset) / 100;\n }\n\n return offset;\n}\n\n/**\n * Get an edge value given a start, size and offset value.\n */\nexport function getEdgeWithOffset(start: number, size: number, offset: string | number): number {\n if (isNumber(offset)) {\n return start + size * offset;\n }\n\n const parsedNamedOffset = parseNamedOffset(offset);\n if (isNumber(parsedNamedOffset)) {\n return start + size * parsedNamedOffset;\n }\n\n if (isString(parsedNamedOffset)) {\n const parsedOffset = Number.parseFloat(parsedNamedOffset);\n\n if (parsedNamedOffset.endsWith(units.px)) {\n return start + parsedOffset;\n }\n\n if (parsedNamedOffset.endsWith(units.vh)) {\n return start + (parsedOffset * window.innerHeight) / 100;\n }\n\n if (parsedNamedOffset.endsWith(units.vw)) {\n return start + (parsedOffset * window.innerWidth) / 100;\n }\n\n if (parsedNamedOffset.endsWith(units.vmin)) {\n return start + (parsedOffset * Math.min(window.innerWidth, window.innerHeight)) / 100;\n }\n\n if (parsedNamedOffset.endsWith(units.vmax)) {\n return start + (parsedOffset * Math.max(window.innerWidth, window.innerHeight)) / 100;\n }\n }\n\n return start;\n}\n\n/**\n * Get starting and ending edges for a given axis, a target sizings, a container sizings and their offset.\n */\nexport function getEdges(axis: 'x' | 'y', targetSizes, containerSizes, offset): [number, number] {\n const sizeKey = axis === 'x' ? 'width' : 'height';\n const targetStart = getEdgeWithOffset(targetSizes[axis], targetSizes[sizeKey], offset[0][0]);\n const containerStart = getEdgeWithOffset(0, containerSizes[sizeKey], offset[0][1]);\n const targetEnd = getEdgeWithOffset(targetSizes[axis], targetSizes[sizeKey], offset[1][0]);\n const containerEnd = getEdgeWithOffset(0, containerSizes[sizeKey], offset[1][1]);\n const start = targetStart - containerStart;\n const end = targetEnd - containerEnd;\n\n return [start, end];\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmC;AAGnC,IAAM,QAAQ;AAAA,EACZ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AACX;AAEA,IAAM,eAAe;AAAA,EACnB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AACP;AAKO,SAAS,gBAAgB,SAAmC;AACj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O,YAAY,OAAO,WAAW,IAAK;AAAA,IACpF;AAAA,EACF;AAEA,SAAO;AACT;AAKO,SAAS,SAAS,MAAiB,aAAa,gBAAgB,QAA0B;AAC/F,QAAM,UAAU,SAAS,MAAM,UAAU;AACzC,QAAM,cAAc,kBAAkB,YAAY,OAAO,YAAY,UAAU,OAAO,GAAG,EAAE;AAC3F,QAAM,iBAAiB,kBAAkB,GAAG,eAAe,UAAU,OAAO,GAAG,EAAE;AACjF,QAAM,YAAY,kBAAkB,YAAY,OAAO,YAAY,UAAU,OAAO,GAAG,EAAE;AACzF,QAAM,eAAe,kBAAkB,GAAG,eAAe,UAAU,OAAO,GAAG,EAAE;AAC/E,QAAM,QAAQ,cAAc;AAC5B,QAAM,MAAM,YAAY;AAExB,SAAO,CAAC,OAAO,GAAG;AACpB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,17 @@
1
+ import type { NormalizedOffset } from './types.js';
2
+ /**
3
+ * Normalize offset input.
4
+ */
5
+ export declare function normalizeOffset(offsets: string): NormalizedOffset;
6
+ /**
7
+ * Parse the given offset.
8
+ */
9
+ export declare function parseNamedOffset(offset: string | number): string | number;
10
+ /**
11
+ * Get an edge value given a start, size and offset value.
12
+ */
13
+ export declare function getEdgeWithOffset(start: number, size: number, offset: string | number): number;
14
+ /**
15
+ * Get starting and ending edges for a given axis, a target sizings, a container sizings and their offset.
16
+ */
17
+ export declare function getEdges(axis: 'x' | 'y', targetSizes: any, containerSizes: any, offset: any): [number, number];