@studiometa/js-toolkit 2.0.0-beta.8 → 2.0.0-rc.2

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 (189) hide show
  1. package/Base/index.cjs +285 -0
  2. package/Base/index.d.ts +11 -2
  3. package/Base/index.js +114 -197
  4. package/Base/managers/ChildrenManager.cjs +146 -0
  5. package/Base/managers/ChildrenManager.d.ts +9 -1
  6. package/Base/managers/ChildrenManager.js +60 -59
  7. package/Base/managers/EventsManager.cjs +183 -0
  8. package/Base/managers/EventsManager.js +72 -112
  9. package/Base/managers/OptionsManager.cjs +174 -0
  10. package/Base/managers/OptionsManager.d.ts +9 -5
  11. package/Base/managers/OptionsManager.js +60 -90
  12. package/Base/managers/RefsManager.cjs +99 -0
  13. package/Base/managers/RefsManager.js +30 -35
  14. package/Base/managers/ServicesManager.cjs +131 -0
  15. package/Base/managers/ServicesManager.js +39 -67
  16. package/Base/utils.cjs +41 -0
  17. package/Base/utils.js +12 -11
  18. package/README.md +13 -70
  19. package/decorators/index.cjs +45 -0
  20. package/decorators/index.d.ts +9 -9
  21. package/decorators/index.js +20 -9
  22. package/decorators/withBreakpointManager.cjs +85 -0
  23. package/decorators/withBreakpointManager.js +18 -39
  24. package/decorators/withBreakpointObserver.cjs +115 -0
  25. package/decorators/withBreakpointObserver.js +44 -86
  26. package/decorators/withDrag.cjs +53 -0
  27. package/decorators/withDrag.js +24 -26
  28. package/decorators/withExtraConfig.cjs +43 -0
  29. package/decorators/withExtraConfig.js +17 -12
  30. package/decorators/withFreezedOptions.cjs +37 -0
  31. package/decorators/withFreezedOptions.d.ts +14 -0
  32. package/decorators/withFreezedOptions.js +15 -0
  33. package/decorators/withIntersectionObserver.cjs +62 -0
  34. package/decorators/withIntersectionObserver.js +29 -32
  35. package/decorators/withMountWhenInView.cjs +69 -0
  36. package/decorators/withMountWhenInView.js +31 -52
  37. package/decorators/withScrolledInView.cjs +114 -0
  38. package/decorators/withScrolledInView.d.ts +2 -1
  39. package/decorators/withScrolledInView.js +35 -39
  40. package/decorators/withVue2.cjs +61 -0
  41. package/decorators/withVue2.js +27 -32
  42. package/helpers/createApp.cjs +52 -0
  43. package/helpers/createApp.d.ts +2 -2
  44. package/helpers/createApp.js +12 -12
  45. package/helpers/importOnInteraction.cjs +52 -0
  46. package/helpers/importOnInteraction.js +17 -18
  47. package/helpers/importWhenIdle.cjs +49 -0
  48. package/helpers/importWhenIdle.js +14 -17
  49. package/helpers/importWhenVisible.cjs +50 -0
  50. package/helpers/importWhenVisible.js +16 -18
  51. package/helpers/index.cjs +35 -0
  52. package/helpers/index.d.ts +4 -5
  53. package/helpers/index.js +10 -5
  54. package/helpers/utils.cjs +35 -0
  55. package/helpers/utils.js +7 -6
  56. package/index.cjs +33 -0
  57. package/index.d.ts +4 -21
  58. package/index.js +7 -5
  59. package/package.json +14 -4
  60. package/services/Service.cjs +76 -0
  61. package/services/Service.js +19 -32
  62. package/services/drag.cjs +213 -0
  63. package/services/drag.d.ts +1 -0
  64. package/services/drag.js +64 -68
  65. package/services/index.cjs +41 -0
  66. package/services/index.d.ts +7 -8
  67. package/services/index.js +16 -8
  68. package/services/key.cjs +104 -0
  69. package/services/key.js +28 -36
  70. package/services/load.cjs +72 -0
  71. package/services/load.js +17 -19
  72. package/services/pointer.cjs +162 -0
  73. package/services/pointer.js +43 -60
  74. package/services/raf.cjs +83 -0
  75. package/services/raf.js +20 -28
  76. package/services/resize.cjs +108 -0
  77. package/services/resize.js +33 -42
  78. package/services/scroll.cjs +131 -0
  79. package/services/scroll.js +26 -35
  80. package/utils/collide/boundingRectToCircle.cjs +34 -0
  81. package/utils/collide/boundingRectToCircle.d.ts +1 -1
  82. package/utils/collide/boundingRectToCircle.js +7 -10
  83. package/utils/collide/collideCircleCircle.cjs +34 -0
  84. package/utils/collide/collideCircleCircle.js +8 -7
  85. package/utils/collide/collideCircleRect.cjs +46 -0
  86. package/utils/collide/collideCircleRect.js +10 -12
  87. package/utils/collide/collidePointCircle.cjs +31 -0
  88. package/utils/collide/collidePointCircle.js +8 -5
  89. package/utils/collide/collidePointRect.cjs +28 -0
  90. package/utils/collide/collidePointRect.js +5 -2
  91. package/utils/collide/collideRectRect.cjs +28 -0
  92. package/utils/collide/collideRectRect.js +5 -2
  93. package/utils/collide/index.cjs +39 -0
  94. package/utils/collide/index.d.ts +6 -7
  95. package/utils/collide/index.js +14 -7
  96. package/utils/css/classes.cjs +47 -0
  97. package/utils/css/classes.d.ts +10 -9
  98. package/utils/css/classes.js +18 -14
  99. package/utils/css/index.cjs +38 -0
  100. package/utils/css/index.d.ts +4 -5
  101. package/utils/css/index.js +13 -5
  102. package/utils/css/matrix.cjs +30 -0
  103. package/utils/css/matrix.js +7 -5
  104. package/utils/css/styles.cjs +44 -0
  105. package/utils/css/styles.d.ts +6 -18
  106. package/utils/css/styles.js +12 -12
  107. package/utils/css/transition.cjs +120 -0
  108. package/utils/css/transition.d.ts +15 -9
  109. package/utils/css/transition.js +70 -119
  110. package/utils/debounce.cjs +34 -0
  111. package/utils/debounce.js +7 -9
  112. package/utils/focusTrap.cjs +82 -0
  113. package/utils/focusTrap.js +30 -21
  114. package/utils/history.cjs +89 -0
  115. package/utils/history.js +28 -57
  116. package/utils/index.cjs +54 -0
  117. package/utils/index.d.ts +14 -35
  118. package/utils/index.js +32 -17
  119. package/utils/keyCodes.cjs +35 -0
  120. package/utils/keyCodes.js +5 -2
  121. package/utils/math/clamp.cjs +28 -0
  122. package/utils/math/clamp.js +5 -2
  123. package/utils/math/clamp01.cjs +32 -0
  124. package/utils/math/clamp01.js +6 -3
  125. package/utils/math/damp.cjs +28 -0
  126. package/utils/math/damp.js +5 -4
  127. package/utils/math/ease.cjs +88 -0
  128. package/utils/math/ease.d.ts +78 -0
  129. package/utils/math/ease.js +66 -0
  130. package/utils/math/index.cjs +43 -0
  131. package/utils/math/index.d.ts +8 -8
  132. package/utils/math/index.js +17 -8
  133. package/utils/math/inertiaFinalValue.cjs +37 -0
  134. package/utils/math/inertiaFinalValue.js +8 -10
  135. package/utils/math/lerp.cjs +28 -0
  136. package/utils/math/lerp.js +5 -2
  137. package/utils/math/map.cjs +28 -0
  138. package/utils/math/map.js +5 -2
  139. package/utils/math/round.cjs +28 -0
  140. package/utils/math/round.js +5 -3
  141. package/utils/memoize.cjs +43 -0
  142. package/utils/memoize.js +10 -19
  143. package/utils/nextFrame.cjs +38 -0
  144. package/utils/nextFrame.d.ts +4 -3
  145. package/utils/nextFrame.js +13 -10
  146. package/utils/nextMicrotask.cjs +28 -0
  147. package/utils/nextMicrotask.d.ts +8 -0
  148. package/utils/nextMicrotask.js +6 -0
  149. package/utils/nextTick.cjs +30 -0
  150. package/utils/nextTick.d.ts +8 -0
  151. package/utils/nextTick.js +8 -0
  152. package/utils/object/autoBind.cjs +49 -0
  153. package/utils/object/autoBind.js +12 -22
  154. package/utils/object/getAllProperties.cjs +37 -0
  155. package/utils/object/getAllProperties.js +10 -13
  156. package/utils/object/index.cjs +33 -0
  157. package/utils/object/index.d.ts +3 -4
  158. package/utils/object/index.js +8 -4
  159. package/utils/object/isObject.cjs +28 -0
  160. package/utils/object/isObject.js +6 -3
  161. package/utils/scrollTo.cjs +80 -0
  162. package/utils/scrollTo.js +20 -40
  163. package/utils/string/index.cjs +47 -0
  164. package/utils/string/index.d.ts +10 -11
  165. package/utils/string/index.js +22 -11
  166. package/utils/string/withLeadingCharacters.cjs +32 -0
  167. package/utils/string/withLeadingCharacters.js +7 -4
  168. package/utils/string/withLeadingSlash.cjs +32 -0
  169. package/utils/string/withLeadingSlash.js +7 -4
  170. package/utils/string/withTrailingCharacters.cjs +32 -0
  171. package/utils/string/withTrailingCharacters.js +7 -4
  172. package/utils/string/withTrailingSlash.cjs +32 -0
  173. package/utils/string/withTrailingSlash.js +7 -4
  174. package/utils/string/withoutLeadingCharacters.cjs +28 -0
  175. package/utils/string/withoutLeadingCharacters.js +6 -3
  176. package/utils/string/withoutLeadingCharactersRecursive.cjs +37 -0
  177. package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
  178. package/utils/string/withoutLeadingSlash.cjs +32 -0
  179. package/utils/string/withoutLeadingSlash.js +7 -4
  180. package/utils/string/withoutTrailingCharacters.cjs +28 -0
  181. package/utils/string/withoutTrailingCharacters.js +6 -3
  182. package/utils/string/withoutTrailingCharactersRecursive.cjs +37 -0
  183. package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
  184. package/utils/string/withoutTrailingSlash.cjs +32 -0
  185. package/utils/string/withoutTrailingSlash.js +7 -4
  186. package/utils/throttle.cjs +36 -0
  187. package/utils/throttle.js +9 -9
  188. package/index.modern.js +0 -1
  189. package/index.umd.js +0 -1
@@ -1,12 +1,7 @@
1
- import useResize from '../services/resize.js';
2
-
1
+ import useResize from "../services/resize.js";
3
2
  function testBreakpoints(breakpoints) {
4
- var {
5
- breakpoint
6
- } = useResize().props();
7
- breakpoints.forEach(_ref => {
8
- var [breakpointKeys, instance] = _ref;
9
-
3
+ const { breakpoint } = useResize().props();
4
+ breakpoints.forEach(([breakpointKeys, instance]) => {
10
5
  if (breakpointKeys.includes(breakpoint) && !instance.$isMounted) {
11
6
  setTimeout(() => instance.$mount(), 0);
12
7
  } else if (!breakpointKeys.includes(breakpoint) && instance.$isMounted) {
@@ -14,68 +9,52 @@ function testBreakpoints(breakpoints) {
14
9
  }
15
10
  });
16
11
  }
17
-
18
12
  function mountComponents(instance, breakpoints) {
19
- return breakpoints.map(_ref2 => {
20
- var [bk, ComponentClass] = _ref2;
21
- var child = new ComponentClass(instance.$el);
22
- Object.defineProperty(child, '$parent', {
23
- get: () => instance.$parent
24
- });
13
+ return breakpoints.map(([bk, ComponentClass]) => {
14
+ const child = new ComponentClass(instance.$el);
15
+ Object.defineProperty(child, "$parent", { get: () => instance.$parent });
25
16
  return [bk, child];
26
17
  });
27
18
  }
28
-
29
- var instances = new WeakMap();
30
- export default function withBreakpointManager(BaseClass, breakpoints) {
19
+ const instances = /* @__PURE__ */ new WeakMap();
20
+ function withBreakpointManager(BaseClass, breakpoints) {
31
21
  if (!Array.isArray(breakpoints)) {
32
- throw new Error('[withBreakpointManager] The `breakpoints` parameter must be an array.');
22
+ throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");
33
23
  }
34
-
35
24
  if (breakpoints.length < 2) {
36
- throw new Error('[withBreakpointManager] You must define at least 2 breakpoints.');
25
+ throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");
37
26
  }
38
-
39
- var {
40
- add,
41
- props
42
- } = useResize();
43
-
27
+ const { add, props } = useResize();
44
28
  if (!props().breakpoint) {
45
- throw new Error("The `BreakpointManager` class requires breakpoints to be defined.");
29
+ throw new Error(`The \`BreakpointManager\` class requires breakpoints to be defined.`);
46
30
  }
47
-
48
31
  return class extends BaseClass {
49
32
  constructor(element) {
50
33
  super(element);
51
-
52
34
  if (!instances.has(this)) {
53
35
  instances.set(this, mountComponents(this, breakpoints));
54
36
  }
55
-
56
- add("BreakpointManager-".concat(this.$id), () => {
37
+ add(`BreakpointManager-${this.$id}`, () => {
57
38
  testBreakpoints(instances.get(this));
58
39
  });
59
40
  this.instances = instances.get(this);
60
41
  return this;
61
42
  }
62
-
63
43
  $mount() {
64
44
  super.$mount();
65
45
  testBreakpoints(instances.get(this));
66
46
  return this;
67
47
  }
68
-
69
48
  $destroy() {
70
49
  if (Array.isArray(instances.get(this))) {
71
- instances.get(this).forEach(_ref3 => {
72
- var [, instance] = _ref3;
50
+ instances.get(this).forEach(([, instance]) => {
73
51
  instance.$destroy();
74
52
  });
75
53
  }
76
-
77
54
  return super.$destroy();
78
55
  }
79
-
80
56
  };
81
- }
57
+ }
58
+ export {
59
+ withBreakpointManager as default
60
+ };
@@ -0,0 +1,115 @@
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var __publicField = (obj, key, value) => {
23
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
24
+ return value;
25
+ };
26
+
27
+ // packages/js-toolkit/decorators/withBreakpointObserver.js
28
+ var withBreakpointObserver_exports = {};
29
+ __export(withBreakpointObserver_exports, {
30
+ default: () => withBreakpointObserver
31
+ });
32
+ module.exports = __toCommonJS(withBreakpointObserver_exports);
33
+ var import_resize = __toESM(require("../services/resize.cjs"), 1);
34
+ function testBreakpoints(instance, breakpoint = (0, import_resize.default)().props().breakpoint) {
35
+ const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
36
+ const isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(" ").includes(breakpoint);
37
+ const isInInactiveBreakpoint = inactiveBreakpoints && inactiveBreakpoints.split(" ").includes(breakpoint);
38
+ if (activeBreakpoints && isInActiveBreakpoint || inactiveBreakpoints && !isInInactiveBreakpoint) {
39
+ return "$mount";
40
+ }
41
+ return "$destroy";
42
+ }
43
+ function hasBreakpointConfiguration(instance) {
44
+ const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
45
+ return Boolean(activeBreakpoints || inactiveBreakpoints);
46
+ }
47
+ function testConflictingBreakpointConfiguration(instance) {
48
+ const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;
49
+ if (activeBreakpoints && inactiveBreakpoints) {
50
+ throw new Error(`[${name}] Incorrect configuration: the \`activeBreakpoints\` and \`inactiveBreakpoints\` are not compatible.`);
51
+ }
52
+ }
53
+ function addToResize(key, instance) {
54
+ testConflictingBreakpointConfiguration(instance);
55
+ const { add, has } = (0, import_resize.default)();
56
+ if (!has(key)) {
57
+ add(key, function onResize({ breakpoint }) {
58
+ const action = testBreakpoints(instance, breakpoint);
59
+ if (action === "$destroy" && instance.$isMounted) {
60
+ instance[action]();
61
+ } else if (action === "$mount" && !instance.$isMounted) {
62
+ setTimeout(() => instance[action](), 0);
63
+ }
64
+ });
65
+ }
66
+ }
67
+ function withBreakpointObserver(BaseClass) {
68
+ var _a, _b;
69
+ return _b = class extends BaseClass {
70
+ constructor(element) {
71
+ super(element);
72
+ const { remove, props } = (0, import_resize.default)();
73
+ const { name } = this.$options;
74
+ if (!props().breakpoint) {
75
+ throw new Error(`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);
76
+ }
77
+ const key = `BreakpointObserver-${this.$id}`;
78
+ const mutationObserver = new MutationObserver(([mutation]) => {
79
+ if (mutation.type === "attributes" && (mutation.attributeName === "data-options" || mutation.attributeName.startsWith("data-option-"))) {
80
+ if (!hasBreakpointConfiguration(this)) {
81
+ this.$mount();
82
+ remove(key);
83
+ return;
84
+ }
85
+ addToResize(key, this);
86
+ }
87
+ });
88
+ mutationObserver.observe(this.$el, { attributes: true });
89
+ if (!hasBreakpointConfiguration(this)) {
90
+ return this;
91
+ }
92
+ addToResize(key, this);
93
+ return this;
94
+ }
95
+ $mount() {
96
+ if (!hasBreakpointConfiguration(this)) {
97
+ return super.$mount();
98
+ }
99
+ const action = testBreakpoints(this);
100
+ if (action === "$mount") {
101
+ return super.$mount();
102
+ }
103
+ return this;
104
+ }
105
+ }, __publicField(_b, "config", {
106
+ ...BaseClass.config,
107
+ name: `${BaseClass.config.name}WithBreakpointObserver`,
108
+ options: {
109
+ ...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
110
+ activeBreakpoints: String,
111
+ inactiveBreakpoints: String
112
+ }
113
+ }), _b;
114
+ }
115
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,133 +1,91 @@
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
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import useResize from "../services/resize.js";
8
+ function testBreakpoints(instance, breakpoint = useResize().props().breakpoint) {
9
+ const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
10
+ const isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(" ").includes(breakpoint);
11
+ const isInInactiveBreakpoint = inactiveBreakpoints && inactiveBreakpoints.split(" ").includes(breakpoint);
18
12
  if (activeBreakpoints && isInActiveBreakpoint || inactiveBreakpoints && !isInInactiveBreakpoint) {
19
- return '$mount';
13
+ return "$mount";
20
14
  }
21
-
22
- return '$destroy';
15
+ return "$destroy";
23
16
  }
24
-
25
17
  function hasBreakpointConfiguration(instance) {
26
- var {
27
- activeBreakpoints,
28
- inactiveBreakpoints
29
- } = instance.$options;
18
+ const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
30
19
  return Boolean(activeBreakpoints || inactiveBreakpoints);
31
20
  }
32
-
33
21
  function testConflictingBreakpointConfiguration(instance) {
34
- var {
35
- activeBreakpoints,
36
- inactiveBreakpoints,
37
- name
38
- } = instance.$options;
39
-
22
+ const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;
40
23
  if (activeBreakpoints && inactiveBreakpoints) {
41
- throw new Error("[".concat(name, "] Incorrect configuration: the `activeBreakpoints` and `inactiveBreakpoints` are not compatible."));
24
+ throw new Error(`[${name}] Incorrect configuration: the \`activeBreakpoints\` and \`inactiveBreakpoints\` are not compatible.`);
42
25
  }
43
26
  }
44
-
45
27
  function addToResize(key, instance) {
46
28
  testConflictingBreakpointConfiguration(instance);
47
- var {
48
- add,
49
- has
50
- } = useResize();
51
-
29
+ const { add, has } = useResize();
52
30
  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) {
31
+ add(key, function onResize({ breakpoint }) {
32
+ const action = testBreakpoints(instance, breakpoint);
33
+ if (action === "$destroy" && instance.$isMounted) {
60
34
  instance[action]();
61
- } else if (action === '$mount' && !instance.$isMounted) {
35
+ } else if (action === "$mount" && !instance.$isMounted) {
62
36
  setTimeout(() => instance[action](), 0);
63
37
  }
64
38
  });
65
39
  }
66
40
  }
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 {
41
+ function withBreakpointObserver(BaseClass) {
42
+ var _a, _b;
43
+ return _b = class extends BaseClass {
72
44
  constructor(element) {
73
45
  super(element);
74
- var {
75
- remove,
76
- props
77
- } = useResize();
78
- var {
79
- name
80
- } = this.$options;
81
-
46
+ const { remove, props } = useResize();
47
+ const { name } = this.$options;
82
48
  if (!props().breakpoint) {
83
- throw new Error("[".concat(name, "] The `BreakpointObserver` class requires breakpoints to be defined."));
49
+ throw new Error(`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);
84
50
  }
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-'))) {
51
+ const key = `BreakpointObserver-${this.$id}`;
52
+ const mutationObserver = new MutationObserver(([mutation]) => {
53
+ if (mutation.type === "attributes" && (mutation.attributeName === "data-options" || mutation.attributeName.startsWith("data-option-"))) {
91
54
  if (!hasBreakpointConfiguration(this)) {
92
55
  this.$mount();
93
56
  remove(key);
94
57
  return;
95
58
  }
96
-
97
59
  addToResize(key, this);
98
60
  }
99
61
  });
100
- mutationObserver.observe(this.$el, {
101
- attributes: true
102
- });
103
-
62
+ mutationObserver.observe(this.$el, { attributes: true });
104
63
  if (!hasBreakpointConfiguration(this)) {
105
64
  return this;
106
65
  }
107
-
108
66
  addToResize(key, this);
109
67
  return this;
110
68
  }
111
-
112
69
  $mount() {
113
70
  if (!hasBreakpointConfiguration(this)) {
114
71
  return super.$mount();
115
72
  }
116
-
117
- var action = testBreakpoints(this);
118
-
119
- if (action === '$mount') {
73
+ const action = testBreakpoints(this);
74
+ if (action === "$mount") {
120
75
  return super.$mount();
121
76
  }
122
-
123
77
  return this;
124
78
  }
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) || {}), {}, {
79
+ }, __publicField(_b, "config", {
80
+ ...BaseClass.config,
81
+ name: `${BaseClass.config.name}WithBreakpointObserver`,
82
+ options: {
83
+ ...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
129
84
  activeBreakpoints: String,
130
85
  inactiveBreakpoints: String
131
- })
132
- })), _temp;
133
- }
86
+ }
87
+ }), _b;
88
+ }
89
+ export {
90
+ withBreakpointObserver as default
91
+ };
@@ -0,0 +1,53 @@
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var __publicField = (obj, key, value) => {
23
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
24
+ return value;
25
+ };
26
+
27
+ // packages/js-toolkit/decorators/withDrag.js
28
+ var withDrag_exports = {};
29
+ __export(withDrag_exports, {
30
+ default: () => withDrag
31
+ });
32
+ module.exports = __toCommonJS(withDrag_exports);
33
+ var import_drag = __toESM(require("../services/drag.cjs"), 1);
34
+ function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
35
+ var _a;
36
+ return _a = class extends BaseClass {
37
+ constructor(el) {
38
+ super(el);
39
+ this.$on("mounted", () => {
40
+ this.$services.register("dragged", import_drag.default.bind(void 0, target.call(this, this), options));
41
+ this.$services.enable("dragged");
42
+ });
43
+ this.$on("destroyed", () => {
44
+ this.$services.disable("dragged");
45
+ this.$services.unregister("dragged");
46
+ });
47
+ }
48
+ }, __publicField(_a, "config", {
49
+ name: `${BaseClass.config.name}WithDrag`,
50
+ emits: ["dragged"]
51
+ }), _a;
52
+ }
53
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,31 +1,29 @@
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
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import useDrag from "../services/drag.js";
8
+ function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
9
+ var _a;
10
+ return _a = class extends BaseClass {
15
11
  constructor(el) {
16
12
  super(el);
17
- this.$on('mounted', () => {
18
- this.$services.register('dragged', useDrag.bind(undefined, target.call(this, this), options));
19
- this.$services.enable('dragged');
13
+ this.$on("mounted", () => {
14
+ this.$services.register("dragged", useDrag.bind(void 0, target.call(this, this), options));
15
+ this.$services.enable("dragged");
20
16
  });
21
- this.$on('destroyed', () => {
22
- this.$services.disable('dragged');
23
- this.$services.unregister('dragged');
17
+ this.$on("destroyed", () => {
18
+ this.$services.disable("dragged");
19
+ this.$services.unregister("dragged");
24
20
  });
25
21
  }
26
-
27
- }, _defineProperty(_class, "config", {
28
- name: "".concat(BaseClass.config.name, "WithDrag"),
29
- emits: ['dragged']
30
- }), _temp;
31
- }
22
+ }, __publicField(_a, "config", {
23
+ name: `${BaseClass.config.name}WithDrag`,
24
+ emits: ["dragged"]
25
+ }), _a;
26
+ }
27
+ export {
28
+ withDrag as default
29
+ };
@@ -0,0 +1,43 @@
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var __publicField = (obj, key, value) => {
23
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
24
+ return value;
25
+ };
26
+
27
+ // packages/js-toolkit/decorators/withExtraConfig.js
28
+ var withExtraConfig_exports = {};
29
+ __export(withExtraConfig_exports, {
30
+ default: () => withExtraConfig
31
+ });
32
+ module.exports = __toCommonJS(withExtraConfig_exports);
33
+ var import_deepmerge = __toESM(require("deepmerge"), 1);
34
+ function withExtraConfig(BaseClass, config, options = {}) {
35
+ var _a;
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 _a = class extends BaseClass {
41
+ }, __publicField(_a, "config", newConfig), _a;
42
+ }
43
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,14 +1,19 @@
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
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import merge from "deepmerge";
8
+ function withExtraConfig(BaseClass, config, options = {}) {
9
+ var _a;
10
+ const newConfig = merge(BaseClass.config, config, options);
9
11
  if (newConfig.name === BaseClass.config.name) {
10
- newConfig.name = "".concat(BaseClass.config.name, "WithExtraConfig");
12
+ newConfig.name = `${BaseClass.config.name}WithExtraConfig`;
11
13
  }
12
-
13
- return _temp = _class = class extends BaseClass {}, _defineProperty(_class, "config", newConfig), _temp;
14
- }
14
+ return _a = class extends BaseClass {
15
+ }, __publicField(_a, "config", newConfig), _a;
16
+ }
17
+ export {
18
+ withExtraConfig as default
19
+ };
@@ -0,0 +1,37 @@
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/withFreezedOptions.js
20
+ var withFreezedOptions_exports = {};
21
+ __export(withFreezedOptions_exports, {
22
+ default: () => withFreezedOptions
23
+ });
24
+ module.exports = __toCommonJS(withFreezedOptions_exports);
25
+ function withFreezedOptions(BaseClass) {
26
+ return class extends BaseClass {
27
+ get $options() {
28
+ Object.defineProperty(this, "$options", {
29
+ value: Object.freeze({ ...super.$options }),
30
+ enumerable: true,
31
+ configurable: true
32
+ });
33
+ return this.$options;
34
+ }
35
+ };
36
+ }
37
+ if (module.exports.default) module.exports = module.exports.default;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @typedef {import('../Base').BaseOptions} BaseOptions
3
+ * @typedef {import('../Base').BaseConstructor} BaseConstructor
4
+ */
5
+ /**
6
+ * Freeze the `$options` property to improve performance.
7
+ *
8
+ * @template {BaseConstructor} T
9
+ * @param {T} BaseClass The Base class to extend.
10
+ * @return {T}
11
+ */
12
+ export default function withFreezedOptions<T extends typeof import("../Base").default>(BaseClass: T): T;
13
+ export type BaseOptions = import('../Base').BaseOptions;
14
+ export type BaseConstructor = import('../Base').BaseConstructor;
@@ -0,0 +1,15 @@
1
+ function withFreezedOptions(BaseClass) {
2
+ return class extends BaseClass {
3
+ get $options() {
4
+ Object.defineProperty(this, "$options", {
5
+ value: Object.freeze({ ...super.$options }),
6
+ enumerable: true,
7
+ configurable: true
8
+ });
9
+ return this.$options;
10
+ }
11
+ };
12
+ }
13
+ export {
14
+ withFreezedOptions as default
15
+ };