@studiometa/js-toolkit 2.0.0-beta.10 → 2.0.0-beta.14

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 (159) hide show
  1. package/Base/index.cjs +295 -0
  2. package/Base/index.js +88 -174
  3. package/Base/managers/ChildrenManager.cjs +125 -0
  4. package/Base/managers/ChildrenManager.js +29 -55
  5. package/Base/managers/EventsManager.cjs +185 -0
  6. package/Base/managers/EventsManager.js +84 -130
  7. package/Base/managers/OptionsManager.cjs +176 -0
  8. package/Base/managers/OptionsManager.js +46 -88
  9. package/Base/managers/RefsManager.cjs +99 -0
  10. package/Base/managers/RefsManager.js +22 -38
  11. package/Base/managers/ServicesManager.cjs +133 -0
  12. package/Base/managers/ServicesManager.js +31 -65
  13. package/Base/utils.cjs +46 -0
  14. package/Base/utils.js +12 -11
  15. package/decorators/index.cjs +50 -0
  16. package/decorators/index.js +18 -8
  17. package/decorators/withBreakpointManager.cjs +92 -0
  18. package/decorators/withBreakpointManager.js +18 -39
  19. package/decorators/withBreakpointObserver.cjs +117 -0
  20. package/decorators/withBreakpointObserver.js +40 -88
  21. package/decorators/withDrag.cjs +55 -0
  22. package/decorators/withDrag.js +18 -26
  23. package/decorators/withExtraConfig.cjs +45 -0
  24. package/decorators/withExtraConfig.js +11 -12
  25. package/decorators/withIntersectionObserver.cjs +62 -0
  26. package/decorators/withIntersectionObserver.js +23 -32
  27. package/decorators/withMountWhenInView.cjs +69 -0
  28. package/decorators/withMountWhenInView.js +26 -53
  29. package/decorators/withScrolledInView.cjs +113 -0
  30. package/decorators/withScrolledInView.js +50 -63
  31. package/decorators/withVue2.cjs +61 -0
  32. package/decorators/withVue2.js +21 -32
  33. package/helpers/createApp.cjs +57 -0
  34. package/helpers/createApp.js +12 -12
  35. package/helpers/importOnInteraction.cjs +57 -0
  36. package/helpers/importOnInteraction.js +17 -18
  37. package/helpers/importWhenIdle.cjs +53 -0
  38. package/helpers/importWhenIdle.js +13 -17
  39. package/helpers/importWhenVisible.cjs +55 -0
  40. package/helpers/importWhenVisible.js +16 -18
  41. package/helpers/index.cjs +42 -0
  42. package/helpers/index.js +10 -4
  43. package/helpers/utils.cjs +40 -0
  44. package/helpers/utils.js +7 -6
  45. package/index.cjs +39 -0
  46. package/index.js +7 -4
  47. package/package.json +14 -3
  48. package/services/Service.cjs +76 -0
  49. package/services/Service.js +13 -32
  50. package/services/drag.cjs +195 -0
  51. package/services/drag.js +60 -90
  52. package/services/index.cjs +48 -0
  53. package/services/index.js +16 -7
  54. package/services/key.cjs +102 -0
  55. package/services/key.js +34 -52
  56. package/services/load.cjs +71 -0
  57. package/services/load.js +13 -24
  58. package/services/pointer.cjs +160 -0
  59. package/services/pointer.js +60 -87
  60. package/services/raf.cjs +82 -0
  61. package/services/raf.js +16 -33
  62. package/services/resize.cjs +107 -0
  63. package/services/resize.js +31 -49
  64. package/services/scroll.cjs +130 -0
  65. package/services/scroll.js +44 -62
  66. package/utils/collide/boundingRectToCircle.cjs +39 -0
  67. package/utils/collide/boundingRectToCircle.d.ts +1 -1
  68. package/utils/collide/boundingRectToCircle.js +7 -10
  69. package/utils/collide/collideCircleCircle.cjs +39 -0
  70. package/utils/collide/collideCircleCircle.js +8 -7
  71. package/utils/collide/collideCircleRect.cjs +51 -0
  72. package/utils/collide/collideCircleRect.js +10 -12
  73. package/utils/collide/collidePointCircle.cjs +36 -0
  74. package/utils/collide/collidePointCircle.js +8 -5
  75. package/utils/collide/collidePointRect.cjs +33 -0
  76. package/utils/collide/collidePointRect.js +5 -2
  77. package/utils/collide/collideRectRect.cjs +33 -0
  78. package/utils/collide/collideRectRect.js +5 -2
  79. package/utils/collide/index.cjs +46 -0
  80. package/utils/collide/index.js +14 -6
  81. package/utils/css/classes.cjs +49 -0
  82. package/utils/css/classes.js +13 -12
  83. package/utils/css/index.cjs +42 -0
  84. package/utils/css/index.js +10 -6
  85. package/utils/css/matrix.cjs +34 -0
  86. package/utils/css/matrix.js +6 -5
  87. package/utils/css/styles.cjs +52 -0
  88. package/utils/css/styles.js +13 -12
  89. package/utils/css/transition.cjs +122 -0
  90. package/utils/css/transition.js +62 -117
  91. package/utils/debounce.cjs +39 -0
  92. package/utils/debounce.js +7 -9
  93. package/utils/focusTrap.cjs +89 -0
  94. package/utils/focusTrap.js +30 -21
  95. package/utils/history.cjs +96 -0
  96. package/utils/history.js +28 -57
  97. package/utils/index.cjs +58 -0
  98. package/utils/index.d.ts +1 -0
  99. package/utils/index.js +30 -11
  100. package/utils/keyCodes.cjs +40 -0
  101. package/utils/keyCodes.js +5 -2
  102. package/utils/math/clamp.cjs +33 -0
  103. package/utils/math/clamp.js +5 -2
  104. package/utils/math/clamp01.cjs +39 -0
  105. package/utils/math/clamp01.js +6 -3
  106. package/utils/math/damp.cjs +33 -0
  107. package/utils/math/damp.js +5 -4
  108. package/utils/math/ease.cjs +93 -0
  109. package/utils/math/ease.js +50 -25
  110. package/utils/math/index.cjs +49 -0
  111. package/utils/math/index.js +17 -8
  112. package/utils/math/inertiaFinalValue.cjs +42 -0
  113. package/utils/math/inertiaFinalValue.js +8 -10
  114. package/utils/math/lerp.cjs +33 -0
  115. package/utils/math/lerp.js +5 -2
  116. package/utils/math/map.cjs +33 -0
  117. package/utils/math/map.js +5 -2
  118. package/utils/math/round.cjs +33 -0
  119. package/utils/math/round.js +5 -3
  120. package/utils/memoize.cjs +48 -0
  121. package/utils/memoize.js +10 -19
  122. package/utils/nextFrame.cjs +45 -0
  123. package/utils/nextFrame.js +14 -9
  124. package/utils/object/autoBind.cjs +56 -0
  125. package/utils/object/autoBind.js +12 -22
  126. package/utils/object/getAllProperties.cjs +42 -0
  127. package/utils/object/getAllProperties.js +10 -13
  128. package/utils/object/index.cjs +40 -0
  129. package/utils/object/index.js +8 -3
  130. package/utils/object/isObject.cjs +33 -0
  131. package/utils/object/isObject.js +6 -3
  132. package/utils/scrollTo.cjs +87 -0
  133. package/utils/scrollTo.js +20 -40
  134. package/utils/string/index.cjs +54 -0
  135. package/utils/string/index.js +22 -10
  136. package/utils/string/withLeadingCharacters.cjs +39 -0
  137. package/utils/string/withLeadingCharacters.js +7 -4
  138. package/utils/string/withLeadingSlash.cjs +39 -0
  139. package/utils/string/withLeadingSlash.js +7 -4
  140. package/utils/string/withTrailingCharacters.cjs +39 -0
  141. package/utils/string/withTrailingCharacters.js +7 -4
  142. package/utils/string/withTrailingSlash.cjs +39 -0
  143. package/utils/string/withTrailingSlash.js +7 -4
  144. package/utils/string/withoutLeadingCharacters.cjs +33 -0
  145. package/utils/string/withoutLeadingCharacters.js +6 -3
  146. package/utils/string/withoutLeadingCharactersRecursive.cjs +44 -0
  147. package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
  148. package/utils/string/withoutLeadingSlash.cjs +39 -0
  149. package/utils/string/withoutLeadingSlash.js +7 -4
  150. package/utils/string/withoutTrailingCharacters.cjs +33 -0
  151. package/utils/string/withoutTrailingCharacters.js +6 -3
  152. package/utils/string/withoutTrailingCharactersRecursive.cjs +44 -0
  153. package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
  154. package/utils/string/withoutTrailingSlash.cjs +39 -0
  155. package/utils/string/withoutTrailingSlash.js +7 -4
  156. package/utils/throttle.cjs +41 -0
  157. package/utils/throttle.js +9 -9
  158. package/index.modern.js +0 -1
  159. package/index.umd.js +0 -1
@@ -0,0 +1,113 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+
29
+ // packages/js-toolkit/decorators/withScrolledInView.js
30
+ var withScrolledInView_exports = {};
31
+ __export(withScrolledInView_exports, {
32
+ default: () => withScrolledInView
33
+ });
34
+ var import_withMountWhenInView = __toESM(require("./withMountWhenInView.cjs"), 1);
35
+ var import_utils = require("../utils/index.cjs");
36
+ function withScrolledInView(BaseClass, options) {
37
+ return class extends (0, import_withMountWhenInView.default)(BaseClass, options) {
38
+ static config = {
39
+ name: `${BaseClass.config.name}WithMountWhenInView`,
40
+ emits: ["scrolledInView"]
41
+ };
42
+ __props = {
43
+ start: {
44
+ x: 0,
45
+ y: 0
46
+ },
47
+ end: {
48
+ x: 0,
49
+ y: 0
50
+ },
51
+ current: {
52
+ x: 0,
53
+ y: 0
54
+ },
55
+ progress: {
56
+ x: 0,
57
+ y: 0
58
+ },
59
+ dampedProgress: {
60
+ x: 0,
61
+ y: 0
62
+ }
63
+ };
64
+ dampFactor = 0.1;
65
+ dampPrecision = 1e-3;
66
+ mounted() {
67
+ this.__setProps();
68
+ }
69
+ resized() {
70
+ this.__setProps();
71
+ }
72
+ scrolled(props) {
73
+ if (!this.$services.has("ticked") && props.changed.y || props.changed.x) {
74
+ this.$services.enable("ticked");
75
+ }
76
+ }
77
+ ticked() {
78
+ this.__props.current.x = (0, import_utils.clamp)(window.pageXOffset, this.__props.start.x, this.__props.end.x);
79
+ this.__props.progress.x = (0, import_utils.clamp01)((this.__props.current.x - this.__props.start.x) / (this.__props.end.x - this.__props.start.x));
80
+ this.__props.dampedProgress.x = (0, import_utils.damp)(this.__props.progress.x, this.__props.dampedProgress.x, this.dampFactor, this.dampPrecision);
81
+ this.__props.current.y = (0, import_utils.clamp)(window.pageYOffset, this.__props.start.y, this.__props.end.y);
82
+ this.__props.progress.y = (0, import_utils.clamp01)((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
83
+ this.__props.dampedProgress.y = (0, import_utils.damp)(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
84
+ if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
85
+ this.$services.disable("ticked");
86
+ }
87
+ this.__callMethod("scrolledInView", this.__props);
88
+ }
89
+ __setProps() {
90
+ const sizes = this.$el.getBoundingClientRect();
91
+ const yEnd = sizes.top + window.pageYOffset + sizes.height;
92
+ const yStart = yEnd - window.innerHeight - sizes.height;
93
+ const yCurrent = (0, import_utils.clamp)(window.pageYOffset, yStart, yEnd);
94
+ const yProgress = (0, import_utils.clamp01)((yCurrent - yStart) / (yEnd - yStart));
95
+ const xEnd = sizes.left + window.pageXOffset + sizes.width;
96
+ const xStart = xEnd - window.innerWidth - sizes.width;
97
+ const xCurrent = (0, import_utils.clamp)(window.pageXOffset, xStart, xEnd);
98
+ const xProgress = (0, import_utils.clamp01)((xCurrent - xStart) / (xEnd - xStart));
99
+ this.__props.start.x = xStart;
100
+ this.__props.start.y = yStart;
101
+ this.__props.end.x = xEnd;
102
+ this.__props.end.y = yEnd;
103
+ this.__props.current.x = xCurrent;
104
+ this.__props.current.y = yCurrent;
105
+ this.__props.progress.x = xProgress;
106
+ this.__props.progress.y = yProgress;
107
+ this.__props.dampedProgress.x = (0, import_utils.damp)(xProgress, this.__props.dampedProgress.x);
108
+ this.__props.dampedProgress.y = (0, import_utils.damp)(yProgress, this.__props.dampedProgress.y);
109
+ }
110
+ };
111
+ }
112
+ module.exports = __toCommonJS(withScrolledInView_exports);
113
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,55 +1,46 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import withMountWhenInView from './withMountWhenInView.js';
3
- import { damp, clamp, clamp01 } from '../utils/index.js';
4
- export default function withScrolledInView(BaseClass, options) {
5
- var _class, _temp;
6
-
7
- return _temp = _class = class extends withMountWhenInView(BaseClass, options) {
8
- constructor() {
9
- super(...arguments);
10
-
11
- _defineProperty(this, "__props", {
12
- start: {
13
- x: 0,
14
- y: 0
15
- },
16
- end: {
17
- x: 0,
18
- y: 0
19
- },
20
- current: {
21
- x: 0,
22
- y: 0
23
- },
24
- progress: {
25
- x: 0,
26
- y: 0
27
- },
28
- dampedProgress: {
29
- x: 0,
30
- y: 0
31
- }
32
- });
33
-
34
- _defineProperty(this, "dampFactor", 0.1);
35
-
36
- _defineProperty(this, "dampPrecision", 0.001);
37
- }
38
-
1
+ import withMountWhenInView from "./withMountWhenInView.js";
2
+ import { damp, clamp, clamp01 } from "../utils/index.js";
3
+ function withScrolledInView(BaseClass, options) {
4
+ return class extends withMountWhenInView(BaseClass, options) {
5
+ static config = {
6
+ name: `${BaseClass.config.name}WithMountWhenInView`,
7
+ emits: ["scrolledInView"]
8
+ };
9
+ __props = {
10
+ start: {
11
+ x: 0,
12
+ y: 0
13
+ },
14
+ end: {
15
+ x: 0,
16
+ y: 0
17
+ },
18
+ current: {
19
+ x: 0,
20
+ y: 0
21
+ },
22
+ progress: {
23
+ x: 0,
24
+ y: 0
25
+ },
26
+ dampedProgress: {
27
+ x: 0,
28
+ y: 0
29
+ }
30
+ };
31
+ dampFactor = 0.1;
32
+ dampPrecision = 1e-3;
39
33
  mounted() {
40
34
  this.__setProps();
41
35
  }
42
-
43
36
  resized() {
44
37
  this.__setProps();
45
38
  }
46
-
47
39
  scrolled(props) {
48
- if (!this.$services.has('ticked') && props.changed.y || props.changed.x) {
49
- this.$services.enable('ticked');
40
+ if (!this.$services.has("ticked") && props.changed.y || props.changed.x) {
41
+ this.$services.enable("ticked");
50
42
  }
51
43
  }
52
-
53
44
  ticked() {
54
45
  this.__props.current.x = clamp(window.pageXOffset, this.__props.start.x, this.__props.end.x);
55
46
  this.__props.progress.x = clamp01((this.__props.current.x - this.__props.start.x) / (this.__props.end.x - this.__props.start.x));
@@ -57,24 +48,21 @@ export default function withScrolledInView(BaseClass, options) {
57
48
  this.__props.current.y = clamp(window.pageYOffset, this.__props.start.y, this.__props.end.y);
58
49
  this.__props.progress.y = clamp01((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
59
50
  this.__props.dampedProgress.y = damp(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
60
-
61
51
  if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
62
- this.$services.disable('ticked');
52
+ this.$services.disable("ticked");
63
53
  }
64
-
65
- this.__callMethod('scrolledInView', this.__props);
54
+ this.__callMethod("scrolledInView", this.__props);
66
55
  }
67
-
68
56
  __setProps() {
69
- var sizes = this.$el.getBoundingClientRect();
70
- var yEnd = sizes.top + window.pageYOffset + sizes.height;
71
- var yStart = yEnd - window.innerHeight - sizes.height;
72
- var yCurrent = clamp(window.pageYOffset, yStart, yEnd);
73
- var yProgress = clamp01((yCurrent - yStart) / (yEnd - yStart));
74
- var xEnd = sizes.left + window.pageXOffset + sizes.width;
75
- var xStart = xEnd - window.innerWidth - sizes.width;
76
- var xCurrent = clamp(window.pageXOffset, xStart, xEnd);
77
- var xProgress = clamp01((xCurrent - xStart) / (xEnd - xStart));
57
+ const sizes = this.$el.getBoundingClientRect();
58
+ const yEnd = sizes.top + window.pageYOffset + sizes.height;
59
+ const yStart = yEnd - window.innerHeight - sizes.height;
60
+ const yCurrent = clamp(window.pageYOffset, yStart, yEnd);
61
+ const yProgress = clamp01((yCurrent - yStart) / (yEnd - yStart));
62
+ const xEnd = sizes.left + window.pageXOffset + sizes.width;
63
+ const xStart = xEnd - window.innerWidth - sizes.width;
64
+ const xCurrent = clamp(window.pageXOffset, xStart, xEnd);
65
+ const xProgress = clamp01((xCurrent - xStart) / (xEnd - xStart));
78
66
  this.__props.start.x = xStart;
79
67
  this.__props.start.y = yStart;
80
68
  this.__props.end.x = xEnd;
@@ -86,9 +74,8 @@ export default function withScrolledInView(BaseClass, options) {
86
74
  this.__props.dampedProgress.x = damp(xProgress, this.__props.dampedProgress.x);
87
75
  this.__props.dampedProgress.y = damp(yProgress, this.__props.dampedProgress.y);
88
76
  }
89
-
90
- }, _defineProperty(_class, "config", {
91
- name: "".concat(BaseClass.config.name, "WithMountWhenInView"),
92
- emits: ['scrolledInView']
93
- }), _temp;
94
- }
77
+ };
78
+ }
79
+ export {
80
+ withScrolledInView as default
81
+ };
@@ -0,0 +1,61 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __reExport = (target, module2, copyDefault, desc) => {
11
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
12
+ for (let key of __getOwnPropNames(module2))
13
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
14
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
15
+ }
16
+ return target;
17
+ };
18
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
19
+ return (module2, temp) => {
20
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
21
+ };
22
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
23
+
24
+ // packages/js-toolkit/decorators/withVue2.js
25
+ var withVue2_exports = {};
26
+ __export(withVue2_exports, {
27
+ default: () => withVue2_default
28
+ });
29
+ var withVue2_default = (BaseClass, Vue) => {
30
+ return class WithVue2 extends BaseClass {
31
+ static config = {
32
+ ...BaseClass.config || {},
33
+ name: `${BaseClass?.config?.name ?? ""}WithVue`,
34
+ refs: [...BaseClass?.config?.refs ?? [], "vue"]
35
+ };
36
+ $vue;
37
+ static vueConfig;
38
+ constructor(element) {
39
+ super(element);
40
+ const { vueConfig } = this.constructor;
41
+ if (!vueConfig) {
42
+ throw new Error("[withVue] You must define a `vueConfig` object.");
43
+ }
44
+ if (typeof vueConfig.render !== "function") {
45
+ throw new Error("[withVue] You must define a `render` function in vueConfig.");
46
+ }
47
+ this.$vue = new Vue(vueConfig);
48
+ this.$on("mounted", () => {
49
+ if (!(this.$refs.vue instanceof HTMLElement)) {
50
+ throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
51
+ }
52
+ this.$vue.$mount(this.$refs.vue);
53
+ });
54
+ this.$on("destroyed", () => {
55
+ this.$vue.$destroy();
56
+ });
57
+ }
58
+ };
59
+ };
60
+ module.exports = __toCommonJS(withVue2_exports);
61
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,45 +1,34 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
- export default ((BaseClass, Vue) => {
8
- var _class, _temp, _BaseClass$config$nam, _BaseClass$config, _BaseClass$config$ref, _BaseClass$config2;
9
-
10
- return _temp = _class = class WithVue2 extends BaseClass {
1
+ var withVue2_default = (BaseClass, Vue) => {
2
+ return class WithVue2 extends BaseClass {
3
+ static config = {
4
+ ...BaseClass.config || {},
5
+ name: `${BaseClass?.config?.name ?? ""}WithVue`,
6
+ refs: [...BaseClass?.config?.refs ?? [], "vue"]
7
+ };
8
+ $vue;
9
+ static vueConfig;
11
10
  constructor(element) {
12
11
  super(element);
13
-
14
- _defineProperty(this, "$vue", void 0);
15
-
16
- var {
17
- vueConfig
18
- } = this.constructor;
19
-
12
+ const { vueConfig } = this.constructor;
20
13
  if (!vueConfig) {
21
- throw new Error('[withVue] You must define a `vueConfig` object.');
14
+ throw new Error("[withVue] You must define a `vueConfig` object.");
22
15
  }
23
-
24
- if (typeof vueConfig.render !== 'function') {
25
- throw new Error('[withVue] You must define a `render` function in vueConfig.');
16
+ if (typeof vueConfig.render !== "function") {
17
+ throw new Error("[withVue] You must define a `render` function in vueConfig.");
26
18
  }
27
-
28
19
  this.$vue = new Vue(vueConfig);
29
- this.$on('mounted', () => {
20
+ this.$on("mounted", () => {
30
21
  if (!(this.$refs.vue instanceof HTMLElement)) {
31
- throw new Error('[withVue] The `vue` refs must be a single HTMLElement.');
22
+ throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
32
23
  }
33
-
34
24
  this.$vue.$mount(this.$refs.vue);
35
25
  });
36
- this.$on('destroyed', () => {
26
+ this.$on("destroyed", () => {
37
27
  this.$vue.$destroy();
38
28
  });
39
29
  }
40
-
41
- }, _defineProperty(_class, "config", _objectSpread(_objectSpread({}, BaseClass.config || {}), {}, {
42
- name: "".concat((_BaseClass$config$nam = BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config = BaseClass.config) === null || _BaseClass$config === void 0 ? void 0 : _BaseClass$config.name) !== null && _BaseClass$config$nam !== void 0 ? _BaseClass$config$nam : '', "WithVue"),
43
- refs: [...((_BaseClass$config$ref = BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config2 = BaseClass.config) === null || _BaseClass$config2 === void 0 ? void 0 : _BaseClass$config2.refs) !== null && _BaseClass$config$ref !== void 0 ? _BaseClass$config$ref : []), 'vue']
44
- })), _defineProperty(_class, "vueConfig", void 0), _temp;
45
- });
30
+ };
31
+ };
32
+ export {
33
+ withVue2_default as default
34
+ };
@@ -0,0 +1,57 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __reExport = (target, module2, copyDefault, desc) => {
11
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
12
+ for (let key of __getOwnPropNames(module2))
13
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
14
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
15
+ }
16
+ return target;
17
+ };
18
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
19
+ return (module2, temp) => {
20
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
21
+ };
22
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
23
+
24
+ // packages/js-toolkit/helpers/createApp.js
25
+ var createApp_exports = {};
26
+ __export(createApp_exports, {
27
+ default: () => createApp
28
+ });
29
+ function createApp(App, rootElement) {
30
+ let isLoaded = document.readyState === "complete";
31
+ let app;
32
+ if (!isLoaded) {
33
+ document.addEventListener("readystatechange", () => {
34
+ if (document.readyState === "complete") {
35
+ app = new App(rootElement).$mount();
36
+ isLoaded = true;
37
+ }
38
+ });
39
+ } else {
40
+ app = new App(rootElement).$mount();
41
+ }
42
+ const promise = new Promise((resolve) => {
43
+ document.addEventListener("readystatechange", () => {
44
+ if (document.readyState === "complete") {
45
+ setTimeout(() => resolve(app), 0);
46
+ }
47
+ });
48
+ });
49
+ return function useApp() {
50
+ if (isLoaded) {
51
+ return Promise.resolve(app);
52
+ }
53
+ return promise;
54
+ };
55
+ }
56
+ module.exports = __toCommonJS(createApp_exports);
57
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,10 +1,9 @@
1
- export default function createApp(App, rootElement) {
2
- var isLoaded = document.readyState === 'complete';
3
- var app;
4
-
1
+ function createApp(App, rootElement) {
2
+ let isLoaded = document.readyState === "complete";
3
+ let app;
5
4
  if (!isLoaded) {
6
- document.addEventListener('readystatechange', () => {
7
- if (document.readyState === 'complete') {
5
+ document.addEventListener("readystatechange", () => {
6
+ if (document.readyState === "complete") {
8
7
  app = new App(rootElement).$mount();
9
8
  isLoaded = true;
10
9
  }
@@ -12,10 +11,9 @@ export default function createApp(App, rootElement) {
12
11
  } else {
13
12
  app = new App(rootElement).$mount();
14
13
  }
15
-
16
- var promise = new Promise(resolve => {
17
- document.addEventListener('readystatechange', () => {
18
- if (document.readyState === 'complete') {
14
+ const promise = new Promise((resolve) => {
15
+ document.addEventListener("readystatechange", () => {
16
+ if (document.readyState === "complete") {
19
17
  setTimeout(() => resolve(app), 0);
20
18
  }
21
19
  });
@@ -24,7 +22,9 @@ export default function createApp(App, rootElement) {
24
22
  if (isLoaded) {
25
23
  return Promise.resolve(app);
26
24
  }
27
-
28
25
  return promise;
29
26
  };
30
- }
27
+ }
28
+ export {
29
+ createApp as default
30
+ };
@@ -0,0 +1,57 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __reExport = (target, module2, copyDefault, desc) => {
11
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
12
+ for (let key of __getOwnPropNames(module2))
13
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
14
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
15
+ }
16
+ return target;
17
+ };
18
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
19
+ return (module2, temp) => {
20
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
21
+ };
22
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
23
+
24
+ // packages/js-toolkit/helpers/importOnInteraction.js
25
+ var importOnInteraction_exports = {};
26
+ __export(importOnInteraction_exports, {
27
+ default: () => importOnInteraction
28
+ });
29
+ var import_utils = require("./utils.cjs");
30
+ function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {
31
+ const normalizedEvents = typeof events === "string" ? [events] : events;
32
+ let ResolvedClass;
33
+ const resolver = (resolve) => {
34
+ fn().then((module2) => {
35
+ ResolvedClass = "default" in module2 ? module2.default : module2;
36
+ resolve(ResolvedClass);
37
+ });
38
+ };
39
+ return new Promise((resolve) => {
40
+ const elements = (0, import_utils.getTargetElements)(nameOrSelectorOrElement, parent?.$el);
41
+ const eventListenerOptions = {
42
+ capture: true,
43
+ passive: true,
44
+ once: true
45
+ };
46
+ const handler = () => {
47
+ resolver(resolve);
48
+ };
49
+ elements.forEach((element) => {
50
+ normalizedEvents.forEach((event) => {
51
+ element.addEventListener(event, handler, eventListenerOptions);
52
+ });
53
+ });
54
+ });
55
+ }
56
+ module.exports = __toCommonJS(importOnInteraction_exports);
57
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,31 +1,30 @@
1
- import { getTargetElements } from './utils.js';
2
- export default function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {
3
- var normalizedEvents = typeof events === 'string' ? [events] : events;
4
- var ResolvedClass;
5
-
6
- var resolver = resolve => {
7
- fn().then(module => {
8
- ResolvedClass = 'default' in module ? module.default : module;
1
+ import { getTargetElements } from "./utils.js";
2
+ function importOnInteraction(fn, nameOrSelectorOrElement, events, parent) {
3
+ const normalizedEvents = typeof events === "string" ? [events] : events;
4
+ let ResolvedClass;
5
+ const resolver = (resolve) => {
6
+ fn().then((module) => {
7
+ ResolvedClass = "default" in module ? module.default : module;
9
8
  resolve(ResolvedClass);
10
9
  });
11
10
  };
12
-
13
- return new Promise(resolve => {
14
- var elements = getTargetElements(nameOrSelectorOrElement, parent === null || parent === void 0 ? void 0 : parent.$el);
15
- var eventListenerOptions = {
11
+ return new Promise((resolve) => {
12
+ const elements = getTargetElements(nameOrSelectorOrElement, parent?.$el);
13
+ const eventListenerOptions = {
16
14
  capture: true,
17
15
  passive: true,
18
16
  once: true
19
17
  };
20
-
21
- var handler = () => {
18
+ const handler = () => {
22
19
  resolver(resolve);
23
20
  };
24
-
25
- elements.forEach(element => {
26
- normalizedEvents.forEach(event => {
21
+ elements.forEach((element) => {
22
+ normalizedEvents.forEach((event) => {
27
23
  element.addEventListener(event, handler, eventListenerOptions);
28
24
  });
29
25
  });
30
26
  });
31
- }
27
+ }
28
+ export {
29
+ importOnInteraction as default
30
+ };
@@ -0,0 +1,53 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __reExport = (target, module2, copyDefault, desc) => {
11
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
12
+ for (let key of __getOwnPropNames(module2))
13
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
14
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
15
+ }
16
+ return target;
17
+ };
18
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
19
+ return (module2, temp) => {
20
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
21
+ };
22
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
23
+
24
+ // packages/js-toolkit/helpers/importWhenIdle.js
25
+ var importWhenIdle_exports = {};
26
+ __export(importWhenIdle_exports, {
27
+ default: () => importWhenIdle
28
+ });
29
+ function importWhenIdle(fn, options) {
30
+ let ResolvedClass;
31
+ const resolver = (resolve) => {
32
+ fn().then((module2) => {
33
+ ResolvedClass = "default" in module2 ? module2.default : module2;
34
+ resolve(ResolvedClass);
35
+ });
36
+ };
37
+ return new Promise((resolve) => {
38
+ const timeout = options?.timeout ?? 1;
39
+ if (!("requestIdleCallback" in window)) {
40
+ setTimeout(() => {
41
+ resolver(resolve);
42
+ }, timeout);
43
+ } else {
44
+ window.requestIdleCallback(() => {
45
+ setTimeout(() => {
46
+ resolver(resolve);
47
+ }, 0);
48
+ }, { timeout: options?.timeout });
49
+ }
50
+ });
51
+ }
52
+ module.exports = __toCommonJS(importWhenIdle_exports);
53
+ if (module.exports.default) module.exports = module.exports.default;