@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
@@ -1,133 +1,85 @@
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
- import useResize from '../services/resize.js';
8
-
9
- function testBreakpoints(instance) {
10
- var breakpoint = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : useResize().props().breakpoint;
11
- var {
12
- activeBreakpoints,
13
- inactiveBreakpoints
14
- } = instance.$options;
15
- var isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(' ').includes(breakpoint);
16
- var isInInactiveBreakpoint = inactiveBreakpoints && inactiveBreakpoints.split(' ').includes(breakpoint);
17
-
1
+ import useResize from "../services/resize.js";
2
+ function testBreakpoints(instance, breakpoint = useResize().props().breakpoint) {
3
+ const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
4
+ const isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(" ").includes(breakpoint);
5
+ const isInInactiveBreakpoint = inactiveBreakpoints && inactiveBreakpoints.split(" ").includes(breakpoint);
18
6
  if (activeBreakpoints && isInActiveBreakpoint || inactiveBreakpoints && !isInInactiveBreakpoint) {
19
- return '$mount';
7
+ return "$mount";
20
8
  }
21
-
22
- return '$destroy';
9
+ return "$destroy";
23
10
  }
24
-
25
11
  function hasBreakpointConfiguration(instance) {
26
- var {
27
- activeBreakpoints,
28
- inactiveBreakpoints
29
- } = instance.$options;
12
+ const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
30
13
  return Boolean(activeBreakpoints || inactiveBreakpoints);
31
14
  }
32
-
33
15
  function testConflictingBreakpointConfiguration(instance) {
34
- var {
35
- activeBreakpoints,
36
- inactiveBreakpoints,
37
- name
38
- } = instance.$options;
39
-
16
+ const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;
40
17
  if (activeBreakpoints && inactiveBreakpoints) {
41
- throw new Error("[".concat(name, "] Incorrect configuration: the `activeBreakpoints` and `inactiveBreakpoints` are not compatible."));
18
+ throw new Error(`[${name}] Incorrect configuration: the \`activeBreakpoints\` and \`inactiveBreakpoints\` are not compatible.`);
42
19
  }
43
20
  }
44
-
45
21
  function addToResize(key, instance) {
46
22
  testConflictingBreakpointConfiguration(instance);
47
- var {
48
- add,
49
- has
50
- } = useResize();
51
-
23
+ const { add, has } = useResize();
52
24
  if (!has(key)) {
53
- add(key, function onResize(_ref) {
54
- var {
55
- breakpoint
56
- } = _ref;
57
- var action = testBreakpoints(instance, breakpoint);
58
-
59
- if (action === '$destroy' && instance.$isMounted) {
25
+ add(key, function onResize({ breakpoint }) {
26
+ const action = testBreakpoints(instance, breakpoint);
27
+ if (action === "$destroy" && instance.$isMounted) {
60
28
  instance[action]();
61
- } else if (action === '$mount' && !instance.$isMounted) {
29
+ } else if (action === "$mount" && !instance.$isMounted) {
62
30
  setTimeout(() => instance[action](), 0);
63
31
  }
64
32
  });
65
33
  }
66
34
  }
67
-
68
- export default function withBreakpointObserver(BaseClass) {
69
- var _class, _temp, _BaseClass$config$nam, _BaseClass$config, _BaseClass$config2;
70
-
71
- return _temp = _class = class extends BaseClass {
35
+ function withBreakpointObserver(BaseClass) {
36
+ return class extends BaseClass {
37
+ static config = {
38
+ ...BaseClass.config || {},
39
+ name: `${BaseClass?.config?.name ?? ""}WithBreakpointObserver`,
40
+ options: {
41
+ ...BaseClass?.config?.options || {},
42
+ activeBreakpoints: String,
43
+ inactiveBreakpoints: String
44
+ }
45
+ };
72
46
  constructor(element) {
73
47
  super(element);
74
- var {
75
- remove,
76
- props
77
- } = useResize();
78
- var {
79
- name
80
- } = this.$options;
81
-
48
+ const { remove, props } = useResize();
49
+ const { name } = this.$options;
82
50
  if (!props().breakpoint) {
83
- throw new Error("[".concat(name, "] The `BreakpointObserver` class requires breakpoints to be defined."));
51
+ throw new Error(`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);
84
52
  }
85
-
86
- var key = "BreakpointObserver-".concat(this.$id);
87
- var mutationObserver = new MutationObserver(_ref2 => {
88
- var [mutation] = _ref2;
89
-
90
- if (mutation.type === 'attributes' && (mutation.attributeName === 'data-options' || mutation.attributeName.startsWith('data-option-'))) {
53
+ const key = `BreakpointObserver-${this.$id}`;
54
+ const mutationObserver = new MutationObserver(([mutation]) => {
55
+ if (mutation.type === "attributes" && (mutation.attributeName === "data-options" || mutation.attributeName.startsWith("data-option-"))) {
91
56
  if (!hasBreakpointConfiguration(this)) {
92
57
  this.$mount();
93
58
  remove(key);
94
59
  return;
95
60
  }
96
-
97
61
  addToResize(key, this);
98
62
  }
99
63
  });
100
- mutationObserver.observe(this.$el, {
101
- attributes: true
102
- });
103
-
64
+ mutationObserver.observe(this.$el, { attributes: true });
104
65
  if (!hasBreakpointConfiguration(this)) {
105
66
  return this;
106
67
  }
107
-
108
68
  addToResize(key, this);
109
69
  return this;
110
70
  }
111
-
112
71
  $mount() {
113
72
  if (!hasBreakpointConfiguration(this)) {
114
73
  return super.$mount();
115
74
  }
116
-
117
- var action = testBreakpoints(this);
118
-
119
- if (action === '$mount') {
75
+ const action = testBreakpoints(this);
76
+ if (action === "$mount") {
120
77
  return super.$mount();
121
78
  }
122
-
123
79
  return this;
124
80
  }
125
-
126
- }, _defineProperty(_class, "config", _objectSpread(_objectSpread({}, BaseClass.config || {}), {}, {
127
- 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 : '', "WithBreakpointObserver"),
128
- options: _objectSpread(_objectSpread({}, (BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config2 = BaseClass.config) === null || _BaseClass$config2 === void 0 ? void 0 : _BaseClass$config2.options) || {}), {}, {
129
- activeBreakpoints: String,
130
- inactiveBreakpoints: String
131
- })
132
- })), _temp;
133
- }
81
+ };
82
+ }
83
+ export {
84
+ withBreakpointObserver as default
85
+ };
@@ -0,0 +1,55 @@
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/withDrag.js
30
+ var withDrag_exports = {};
31
+ __export(withDrag_exports, {
32
+ default: () => withDrag
33
+ });
34
+ var import_drag = __toESM(require("../services/drag.cjs"), 1);
35
+ function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
36
+ return class extends BaseClass {
37
+ static config = {
38
+ name: `${BaseClass.config.name}WithDrag`,
39
+ emits: ["dragged"]
40
+ };
41
+ constructor(el) {
42
+ super(el);
43
+ this.$on("mounted", () => {
44
+ this.$services.register("dragged", import_drag.default.bind(void 0, target.call(this, this), options));
45
+ this.$services.enable("dragged");
46
+ });
47
+ this.$on("destroyed", () => {
48
+ this.$services.disable("dragged");
49
+ this.$services.unregister("dragged");
50
+ });
51
+ }
52
+ };
53
+ }
54
+ module.exports = __toCommonJS(withDrag_exports);
55
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,31 +1,23 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["target"];
4
- import useDrag from '../services/drag.js';
5
- export default function withDrag(BaseClass) {
6
- var _class, _temp;
7
-
8
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
9
- {
10
- target = instance => instance.$el
11
- } = _ref,
12
- options = _objectWithoutProperties(_ref, _excluded);
13
-
14
- return _temp = _class = class extends BaseClass {
1
+ import useDrag from "../services/drag.js";
2
+ function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
3
+ return class extends BaseClass {
4
+ static config = {
5
+ name: `${BaseClass.config.name}WithDrag`,
6
+ emits: ["dragged"]
7
+ };
15
8
  constructor(el) {
16
9
  super(el);
17
- this.$on('mounted', () => {
18
- this.$services.register('dragged', useDrag.bind(undefined, target.call(this, this), options));
19
- this.$services.enable('dragged');
10
+ this.$on("mounted", () => {
11
+ this.$services.register("dragged", useDrag.bind(void 0, target.call(this, this), options));
12
+ this.$services.enable("dragged");
20
13
  });
21
- this.$on('destroyed', () => {
22
- this.$services.disable('dragged');
23
- this.$services.unregister('dragged');
14
+ this.$on("destroyed", () => {
15
+ this.$services.disable("dragged");
16
+ this.$services.unregister("dragged");
24
17
  });
25
18
  }
26
-
27
- }, _defineProperty(_class, "config", {
28
- name: "".concat(BaseClass.config.name, "WithDrag"),
29
- emits: ['dragged']
30
- }), _temp;
31
- }
19
+ };
20
+ }
21
+ export {
22
+ withDrag as default
23
+ };
@@ -0,0 +1,45 @@
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/withExtraConfig.js
30
+ var withExtraConfig_exports = {};
31
+ __export(withExtraConfig_exports, {
32
+ default: () => withExtraConfig
33
+ });
34
+ var import_deepmerge = __toESM(require("deepmerge"), 1);
35
+ function withExtraConfig(BaseClass, config, options = {}) {
36
+ const newConfig = (0, import_deepmerge.default)(BaseClass.config, config, options);
37
+ if (newConfig.name === BaseClass.config.name) {
38
+ newConfig.name = `${BaseClass.config.name}WithExtraConfig`;
39
+ }
40
+ return class extends BaseClass {
41
+ static config = newConfig;
42
+ };
43
+ }
44
+ module.exports = __toCommonJS(withExtraConfig_exports);
45
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,14 +1,13 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import merge from 'deepmerge';
3
- export default function withExtraConfig(BaseClass, config) {
4
- var _class, _temp;
5
-
6
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7
- var newConfig = merge(BaseClass.config, config, options);
8
-
1
+ import merge from "deepmerge";
2
+ function withExtraConfig(BaseClass, config, options = {}) {
3
+ const newConfig = merge(BaseClass.config, config, options);
9
4
  if (newConfig.name === BaseClass.config.name) {
10
- newConfig.name = "".concat(BaseClass.config.name, "WithExtraConfig");
5
+ newConfig.name = `${BaseClass.config.name}WithExtraConfig`;
11
6
  }
12
-
13
- return _temp = _class = class extends BaseClass {}, _defineProperty(_class, "config", newConfig), _temp;
14
- }
7
+ return class extends BaseClass {
8
+ static config = newConfig;
9
+ };
10
+ }
11
+ export {
12
+ withExtraConfig as default
13
+ };
@@ -0,0 +1,62 @@
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/withIntersectionObserver.js
25
+ var withIntersectionObserver_exports = {};
26
+ __export(withIntersectionObserver_exports, {
27
+ default: () => withIntersectionObserver
28
+ });
29
+ function createArrayOfNumber(length) {
30
+ return [...new Array(length + 1)].map((val, index) => index / length);
31
+ }
32
+ function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
33
+ return class extends BaseClass {
34
+ static config = {
35
+ ...BaseClass.config || {},
36
+ name: `${BaseClass?.config?.name ?? ""}WithIntersectionObserver`,
37
+ options: {
38
+ ...BaseClass?.config?.options || {},
39
+ intersectionObserver: Object
40
+ },
41
+ emits: ["intersected"]
42
+ };
43
+ constructor(element) {
44
+ super(element);
45
+ if (!this.intersected || typeof this.intersected !== "function") {
46
+ throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");
47
+ }
48
+ this.$observer = new IntersectionObserver((entries) => {
49
+ this.__callMethod("intersected", entries);
50
+ }, { ...defaultOptions, ...this.$options.intersectionObserver || {} });
51
+ this.$on("mounted", () => {
52
+ this.$observer.observe(this.$el);
53
+ });
54
+ this.$on("destroyed", () => {
55
+ this.$observer.unobserve(this.$el);
56
+ });
57
+ return this;
58
+ }
59
+ };
60
+ }
61
+ module.exports = __toCommonJS(withIntersectionObserver_exports);
62
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,44 +1,35 @@
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
1
  function createArrayOfNumber(length) {
8
2
  return [...new Array(length + 1)].map((val, index) => index / length);
9
3
  }
10
-
11
- export default function withIntersectionObserver(BaseClass) {
12
- var _class, _temp, _BaseClass$config$nam, _BaseClass$config, _BaseClass$config2;
13
-
14
- var defaultOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
15
- threshold: createArrayOfNumber(100)
16
- };
17
- return _temp = _class = class extends BaseClass {
4
+ function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
5
+ return class extends BaseClass {
6
+ static config = {
7
+ ...BaseClass.config || {},
8
+ name: `${BaseClass?.config?.name ?? ""}WithIntersectionObserver`,
9
+ options: {
10
+ ...BaseClass?.config?.options || {},
11
+ intersectionObserver: Object
12
+ },
13
+ emits: ["intersected"]
14
+ };
18
15
  constructor(element) {
19
16
  super(element);
20
-
21
- if (!this.intersected || typeof this.intersected !== 'function') {
22
- throw new Error('[withIntersectionObserver] The `intersected` method must be defined.');
17
+ if (!this.intersected || typeof this.intersected !== "function") {
18
+ throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");
23
19
  }
24
-
25
- this.$observer = new IntersectionObserver(entries => {
26
- this.__callMethod('intersected', entries);
27
- }, _objectSpread(_objectSpread({}, defaultOptions), this.$options.intersectionObserver || {}));
28
- this.$on('mounted', () => {
20
+ this.$observer = new IntersectionObserver((entries) => {
21
+ this.__callMethod("intersected", entries);
22
+ }, { ...defaultOptions, ...this.$options.intersectionObserver || {} });
23
+ this.$on("mounted", () => {
29
24
  this.$observer.observe(this.$el);
30
25
  });
31
- this.$on('destroyed', () => {
26
+ this.$on("destroyed", () => {
32
27
  this.$observer.unobserve(this.$el);
33
28
  });
34
29
  return this;
35
30
  }
36
-
37
- }, _defineProperty(_class, "config", _objectSpread(_objectSpread({}, BaseClass.config || {}), {}, {
38
- 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 : '', "WithIntersectionObserver"),
39
- options: _objectSpread(_objectSpread({}, (BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config2 = BaseClass.config) === null || _BaseClass$config2 === void 0 ? void 0 : _BaseClass$config2.options) || {}), {}, {
40
- intersectionObserver: Object
41
- }),
42
- emits: ['intersected']
43
- })), _temp;
44
- }
31
+ };
32
+ }
33
+ export {
34
+ withIntersectionObserver as default
35
+ };
@@ -0,0 +1,69 @@
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/withMountWhenInView.js
25
+ var withMountWhenInView_exports = {};
26
+ __export(withMountWhenInView_exports, {
27
+ default: () => withMountWhenInView
28
+ });
29
+ function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
30
+ return class extends BaseClass {
31
+ static config = {
32
+ ...BaseClass.config || {},
33
+ name: `${BaseClass?.config?.name ?? ""}WithMountWhenInView`,
34
+ options: {
35
+ ...BaseClass?.config?.options || {},
36
+ intersectionObserver: Object
37
+ }
38
+ };
39
+ #isVisible = false;
40
+ #observer;
41
+ constructor(element) {
42
+ super(element);
43
+ this.#observer = new IntersectionObserver((entries) => {
44
+ const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
45
+ if (this.#isVisible !== isVisible) {
46
+ this.#isVisible = isVisible;
47
+ if (isVisible) {
48
+ this.$mount();
49
+ } else {
50
+ setTimeout(() => this.$destroy());
51
+ }
52
+ }
53
+ }, { ...defaultOptions, ...this.$options.intersectionObserver });
54
+ this.#observer.observe(this.$el);
55
+ this.$on("terminated", () => {
56
+ this.#observer.disconnect();
57
+ });
58
+ return this;
59
+ }
60
+ $mount() {
61
+ if (this.#isVisible) {
62
+ super.$mount();
63
+ }
64
+ return this;
65
+ }
66
+ };
67
+ }
68
+ module.exports = __toCommonJS(withMountWhenInView_exports);
69
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,69 +1,42 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _classPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet";
3
- import _classPrivateFieldSet from "@babel/runtime/helpers/classPrivateFieldSet";
4
-
5
- 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; }
6
-
7
- 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; }
8
-
9
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
10
-
11
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
12
-
13
- export default function withMountWhenInView(BaseClass) {
14
- var _class, _isVisible, _observer, _temp, _BaseClass$config$nam, _BaseClass$config, _BaseClass$config2;
15
-
16
- var defaultOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
17
- threshold: [0, 1]
18
- };
19
- return _temp = (_isVisible = new WeakMap(), _observer = new WeakMap(), _class = class extends BaseClass {
1
+ function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
2
+ return class extends BaseClass {
3
+ static config = {
4
+ ...BaseClass.config || {},
5
+ name: `${BaseClass?.config?.name ?? ""}WithMountWhenInView`,
6
+ options: {
7
+ ...BaseClass?.config?.options || {},
8
+ intersectionObserver: Object
9
+ }
10
+ };
11
+ #isVisible = false;
12
+ #observer;
20
13
  constructor(element) {
21
14
  super(element);
22
-
23
- _classPrivateFieldInitSpec(this, _isVisible, {
24
- writable: true,
25
- value: false
26
- });
27
-
28
- _classPrivateFieldInitSpec(this, _observer, {
29
- writable: true,
30
- value: void 0
31
- });
32
-
33
- _classPrivateFieldSet(this, _observer, new IntersectionObserver(entries => {
34
- var isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
35
-
36
- if (_classPrivateFieldGet(this, _isVisible) !== isVisible) {
37
- _classPrivateFieldSet(this, _isVisible, isVisible);
38
-
15
+ this.#observer = new IntersectionObserver((entries) => {
16
+ const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
17
+ if (this.#isVisible !== isVisible) {
18
+ this.#isVisible = isVisible;
39
19
  if (isVisible) {
40
20
  this.$mount();
41
21
  } else {
42
22
  setTimeout(() => this.$destroy());
43
23
  }
44
24
  }
45
- }, _objectSpread(_objectSpread({}, defaultOptions), this.$options.intersectionObserver)));
46
-
47
- _classPrivateFieldGet(this, _observer).observe(this.$el);
48
-
49
- this.$on('terminated', () => {
50
- _classPrivateFieldGet(this, _observer).disconnect();
25
+ }, { ...defaultOptions, ...this.$options.intersectionObserver });
26
+ this.#observer.observe(this.$el);
27
+ this.$on("terminated", () => {
28
+ this.#observer.disconnect();
51
29
  });
52
30
  return this;
53
31
  }
54
-
55
32
  $mount() {
56
- if (_classPrivateFieldGet(this, _isVisible)) {
33
+ if (this.#isVisible) {
57
34
  super.$mount();
58
35
  }
59
-
60
36
  return this;
61
37
  }
62
-
63
- }), _defineProperty(_class, "config", _objectSpread(_objectSpread({}, BaseClass.config || {}), {}, {
64
- 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 : '', "WithMountWhenInView"),
65
- options: _objectSpread(_objectSpread({}, (BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config2 = BaseClass.config) === null || _BaseClass$config2 === void 0 ? void 0 : _BaseClass$config2.options) || {}), {}, {
66
- intersectionObserver: Object
67
- })
68
- })), _temp;
69
- }
38
+ };
39
+ }
40
+ export {
41
+ withMountWhenInView as default
42
+ };