@studiometa/js-toolkit 2.2.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/Base/index.cjs +60 -68
  2. package/Base/index.d.ts +0 -8
  3. package/Base/index.js +67 -81
  4. package/Base/managers/AbstractManager.cjs +5 -10
  5. package/Base/managers/AbstractManager.js +5 -11
  6. package/Base/managers/ChildrenManager.cjs +2 -11
  7. package/Base/managers/ChildrenManager.js +2 -12
  8. package/Base/managers/EventsManager.cjs +61 -67
  9. package/Base/managers/EventsManager.js +61 -68
  10. package/Base/managers/OptionsManager.cjs +26 -27
  11. package/Base/managers/OptionsManager.js +26 -28
  12. package/Base/managers/RefsManager.cjs +9 -7
  13. package/Base/managers/RefsManager.js +9 -7
  14. package/Base/managers/ResponsiveOptionsManager.cjs +4 -1
  15. package/Base/managers/ResponsiveOptionsManager.js +4 -1
  16. package/Base/managers/ServicesManager.cjs +6 -11
  17. package/Base/managers/ServicesManager.js +7 -13
  18. package/Base/utils.cjs +23 -1
  19. package/Base/utils.d.ts +25 -0
  20. package/Base/utils.js +23 -1
  21. package/decorators/withBreakpointManager.cjs +15 -5
  22. package/decorators/withBreakpointManager.js +15 -5
  23. package/decorators/withBreakpointObserver.cjs +19 -18
  24. package/decorators/withBreakpointObserver.js +19 -19
  25. package/decorators/withDrag.cjs +6 -11
  26. package/decorators/withDrag.js +6 -12
  27. package/decorators/withExtraConfig.cjs +3 -8
  28. package/decorators/withExtraConfig.js +3 -9
  29. package/decorators/withFreezedOptions.cjs +1 -9
  30. package/decorators/withFreezedOptions.js +1 -10
  31. package/decorators/withIntersectionObserver.cjs +11 -16
  32. package/decorators/withIntersectionObserver.js +11 -17
  33. package/decorators/withMountWhenInView.cjs +12 -17
  34. package/decorators/withMountWhenInView.js +12 -18
  35. package/decorators/withScrolledInView.cjs +30 -35
  36. package/decorators/withScrolledInView.js +30 -36
  37. package/decorators/withVue2.cjs +20 -18
  38. package/decorators/withVue2.js +20 -19
  39. package/helpers/getInstanceFromElement.cjs +1 -2
  40. package/helpers/getInstanceFromElement.js +1 -2
  41. package/helpers/importOnInteraction.cjs +3 -2
  42. package/helpers/importOnInteraction.js +3 -2
  43. package/helpers/importWhenIdle.cjs +2 -3
  44. package/helpers/importWhenIdle.js +2 -3
  45. package/helpers/importWhenVisible.cjs +3 -2
  46. package/helpers/importWhenVisible.js +3 -2
  47. package/helpers/utils.cjs +3 -2
  48. package/helpers/utils.js +3 -2
  49. package/package.json +4 -1
  50. package/services/key.cjs +1 -1
  51. package/services/key.js +1 -1
  52. package/services/pointer.cjs +2 -3
  53. package/services/pointer.js +2 -3
  54. package/services/raf.cjs +2 -5
  55. package/services/raf.js +1 -1
  56. package/utils/css/animate.cjs +33 -98
  57. package/utils/css/animate.d.ts +4 -16
  58. package/utils/css/animate.js +31 -96
  59. package/utils/css/classes.cjs +2 -1
  60. package/utils/css/classes.js +2 -1
  61. package/utils/css/matrix.cjs +1 -2
  62. package/utils/css/matrix.js +1 -2
  63. package/utils/css/styles.cjs +2 -5
  64. package/utils/css/styles.js +1 -1
  65. package/utils/css/transform.cjs +14 -18
  66. package/utils/css/transform.js +2 -3
  67. package/utils/css/transition.cjs +7 -10
  68. package/utils/css/transition.js +7 -11
  69. package/utils/focusTrap.cjs +2 -1
  70. package/utils/focusTrap.js +2 -1
  71. package/utils/{isFunction.cjs → has.cjs} +7 -7
  72. package/utils/has.d.ts +6 -0
  73. package/utils/has.js +6 -0
  74. package/utils/history.cjs +5 -7
  75. package/utils/history.js +4 -3
  76. package/utils/index.cjs +5 -5
  77. package/utils/index.d.ts +3 -2
  78. package/utils/index.js +5 -5
  79. package/utils/{isDefined.cjs → is.cjs} +20 -8
  80. package/utils/is.d.ts +8 -0
  81. package/utils/is.js +18 -0
  82. package/utils/math/inertiaFinalValue.cjs +5 -3
  83. package/utils/math/inertiaFinalValue.js +2 -3
  84. package/utils/nextFrame.cjs +5 -3
  85. package/utils/nextFrame.js +5 -3
  86. package/utils/nextMicrotask.cjs +2 -1
  87. package/utils/nextMicrotask.js +2 -1
  88. package/utils/nextTick.cjs +2 -1
  89. package/utils/nextTick.js +2 -1
  90. package/utils/object/autoBind.cjs +3 -2
  91. package/utils/object/autoBind.js +3 -2
  92. package/utils/object/getAllProperties.cjs +2 -1
  93. package/utils/object/getAllProperties.js +2 -1
  94. package/utils/object/index.cjs +1 -3
  95. package/utils/object/index.d.ts +0 -1
  96. package/utils/object/index.js +1 -3
  97. package/utils/tween.cjs +113 -0
  98. package/utils/tween.d.ts +25 -0
  99. package/utils/tween.js +88 -0
  100. package/utils/isDefined.d.ts +0 -7
  101. package/utils/isDefined.js +0 -6
  102. package/utils/isFunction.d.ts +0 -7
  103. package/utils/isFunction.js +0 -6
  104. package/utils/object/isObject.cjs +0 -28
  105. package/utils/object/isObject.d.ts +0 -7
  106. package/utils/object/isObject.js +0 -6
@@ -27,12 +27,13 @@ __export(RefsManager_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(RefsManager_exports);
29
29
  var import_AbstractManager = __toESM(require("./AbstractManager.cjs"), 1);
30
+ var import_utils = require("../../utils/index.cjs");
30
31
  function normalizeRefName(name) {
31
32
  return name.endsWith("[]") ? name.replace(/\[\]$/, "") : name;
32
33
  }
33
34
  function __filterRefsBelongingToInstance(that, ref) {
34
35
  let ancestor = ref.parentElement;
35
- while (ancestor && ancestor.dataset.component === void 0) {
36
+ while (ancestor && !(0, import_utils.isDefined)(ancestor.dataset.component)) {
36
37
  ancestor = ancestor.parentElement;
37
38
  }
38
39
  return ancestor === null || ancestor === that.__element;
@@ -41,11 +42,13 @@ function __register(that, refName) {
41
42
  const isMultiple = refName.endsWith("[]");
42
43
  const propName = normalizeRefName(refName);
43
44
  const refs = Array.from(that.__element.querySelectorAll(`[data-ref="${refName}"]`)).filter((ref) => __filterRefsBelongingToInstance(that, ref));
44
- if (!isMultiple && refs.length > 1) {
45
+ if (import_utils.isDev && !isMultiple && refs.length > 1) {
45
46
  console.warn(`[${that.__base.$options.name}]`, `The "${refName}" ref has been found multiple times.`, "Did you forgot to add the `[]` suffix to its name?");
46
47
  }
47
- if (!isMultiple && refs.length <= 1 && refs[0] === void 0) {
48
- console.warn(`[${that.__base.$options.name}]`, `The "${refName}" ref is missing.`, `Is there an \`[data-ref="${refName}"]\` element in the component's scope?`);
48
+ if (!isMultiple && refs.length <= 1 && !(0, import_utils.isDefined)(refs[0])) {
49
+ if (import_utils.isDev) {
50
+ console.warn(`[${that.__base.$options.name}]`, `The "${refName}" ref is missing.`, `Is there an \`[data-ref="${refName}"]\` element in the component's scope?`);
51
+ }
49
52
  return;
50
53
  }
51
54
  that.__eventsManager.bindRef(refName, refs);
@@ -57,13 +60,12 @@ function __register(that, refName) {
57
60
  }
58
61
  function __unregister(that, refName) {
59
62
  const propName = normalizeRefName(refName);
60
- const refs = Array.isArray(that[propName]) ? that[propName] : [that[propName]];
63
+ const refs = (0, import_utils.isArray)(that[propName]) ? that[propName] : [that[propName]];
61
64
  that.__eventsManager.unbindRef(refName, refs);
62
65
  }
63
66
  var RefsManager = class extends import_AbstractManager.default {
64
67
  get __refs() {
65
- var _a;
66
- return (_a = this.__config.refs) != null ? _a : [];
68
+ return this.__config.refs ?? [];
67
69
  }
68
70
  registerAll() {
69
71
  this.__refs.forEach((refName) => __register(this, refName));
@@ -1,10 +1,11 @@
1
1
  import AbstractManager from "./AbstractManager.js";
2
+ import { isDev, isArray, isDefined } from "../../utils/index.js";
2
3
  function normalizeRefName(name) {
3
4
  return name.endsWith("[]") ? name.replace(/\[\]$/, "") : name;
4
5
  }
5
6
  function __filterRefsBelongingToInstance(that, ref) {
6
7
  let ancestor = ref.parentElement;
7
- while (ancestor && ancestor.dataset.component === void 0) {
8
+ while (ancestor && !isDefined(ancestor.dataset.component)) {
8
9
  ancestor = ancestor.parentElement;
9
10
  }
10
11
  return ancestor === null || ancestor === that.__element;
@@ -13,11 +14,13 @@ function __register(that, refName) {
13
14
  const isMultiple = refName.endsWith("[]");
14
15
  const propName = normalizeRefName(refName);
15
16
  const refs = Array.from(that.__element.querySelectorAll(`[data-ref="${refName}"]`)).filter((ref) => __filterRefsBelongingToInstance(that, ref));
16
- if (!isMultiple && refs.length > 1) {
17
+ if (isDev && !isMultiple && refs.length > 1) {
17
18
  console.warn(`[${that.__base.$options.name}]`, `The "${refName}" ref has been found multiple times.`, "Did you forgot to add the `[]` suffix to its name?");
18
19
  }
19
- if (!isMultiple && refs.length <= 1 && refs[0] === void 0) {
20
- console.warn(`[${that.__base.$options.name}]`, `The "${refName}" ref is missing.`, `Is there an \`[data-ref="${refName}"]\` element in the component's scope?`);
20
+ if (!isMultiple && refs.length <= 1 && !isDefined(refs[0])) {
21
+ if (isDev) {
22
+ console.warn(`[${that.__base.$options.name}]`, `The "${refName}" ref is missing.`, `Is there an \`[data-ref="${refName}"]\` element in the component's scope?`);
23
+ }
21
24
  return;
22
25
  }
23
26
  that.__eventsManager.bindRef(refName, refs);
@@ -29,13 +32,12 @@ function __register(that, refName) {
29
32
  }
30
33
  function __unregister(that, refName) {
31
34
  const propName = normalizeRefName(refName);
32
- const refs = Array.isArray(that[propName]) ? that[propName] : [that[propName]];
35
+ const refs = isArray(that[propName]) ? that[propName] : [that[propName]];
33
36
  that.__eventsManager.unbindRef(refName, refs);
34
37
  }
35
38
  class RefsManager extends AbstractManager {
36
39
  get __refs() {
37
- var _a;
38
- return (_a = this.__config.refs) != null ? _a : [];
40
+ return this.__config.refs ?? [];
39
41
  }
40
42
  registerAll() {
41
43
  this.__refs.forEach((refName) => __register(this, refName));
@@ -27,6 +27,7 @@ __export(ResponsiveOptionsManager_exports, {
27
27
  module.exports = __toCommonJS(ResponsiveOptionsManager_exports);
28
28
  var import_OptionsManager = __toESM(require("./OptionsManager.cjs"), 1);
29
29
  var import_services = require("../../services/index.cjs");
30
+ var import_utils = require("../../utils/index.cjs");
30
31
  function __getResponsiveName(that, name) {
31
32
  const { breakpoint } = (0, import_services.useResize)().props();
32
33
  if (!breakpoint) {
@@ -56,7 +57,9 @@ var ResponsiveOptionsManager = class extends import_OptionsManager.default {
56
57
  super.set(name, value, config);
57
58
  return;
58
59
  }
59
- console.warn(`[${this.__config.name}]`, "Responsive options are read-only.");
60
+ if (import_utils.isDev) {
61
+ console.warn(`[${this.__config.name}]`, "Responsive options are read-only.");
62
+ }
60
63
  }
61
64
  };
62
65
  if (module.exports.default) module.exports = module.exports.default;
@@ -1,5 +1,6 @@
1
1
  import OptionsManager, { __getPropertyName } from "./OptionsManager.js";
2
2
  import { useResize } from "../../services/index.js";
3
+ import { isDev } from "../../utils/index.js";
3
4
  function __getResponsiveName(that, name) {
4
5
  const { breakpoint } = useResize().props();
5
6
  if (!breakpoint) {
@@ -29,7 +30,9 @@ class ResponsiveOptionsManager extends OptionsManager {
29
30
  super.set(name, value, config);
30
31
  return;
31
32
  }
32
- console.warn(`[${this.__config.name}]`, "Responsive options are read-only.");
33
+ if (isDev) {
34
+ console.warn(`[${this.__config.name}]`, "Responsive options are read-only.");
35
+ }
33
36
  }
34
37
  }
35
38
  export {
@@ -4,7 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
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
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -19,10 +18,6 @@ var __copyProps = (to, from, except, desc) => {
19
18
  };
20
19
  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
20
  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
21
 
27
22
  // packages/js-toolkit/Base/managers/ServicesManager.js
28
23
  var ServicesManager_exports = {};
@@ -48,10 +43,7 @@ var SERVICES_MAP = {
48
43
  };
49
44
  var SERVICE_NAMES = Object.keys(SERVICES_MAP);
50
45
  var ServicesManager = class extends import_AbstractManager.default {
51
- constructor() {
52
- super(...arguments);
53
- __publicField(this, "__customServices", {});
54
- }
46
+ __customServices = {};
55
47
  get __services() {
56
48
  return {
57
49
  ...this.__customServices,
@@ -99,7 +91,7 @@ var ServicesManager = class extends import_AbstractManager.default {
99
91
  remove(this.__base.$id);
100
92
  }
101
93
  toggle(service, force) {
102
- if (typeof force !== "undefined") {
94
+ if ((0, import_utils.isDefined)(force)) {
103
95
  if (force && !this.has(service)) {
104
96
  this.enable(service);
105
97
  }
@@ -118,7 +110,10 @@ var ServicesManager = class extends import_AbstractManager.default {
118
110
  }
119
111
  unregister(name) {
120
112
  if (SERVICE_NAMES.includes(name)) {
121
- throw new Error(`[ServicesManager] The \`${name}\` core service can not be unregistered.`);
113
+ if (import_utils.isDev) {
114
+ throw new Error(`[ServicesManager] The \`${name}\` core service can not be unregistered.`);
115
+ }
116
+ return;
122
117
  }
123
118
  this.__base.__removeEmits(name);
124
119
  delete this.__customServices[name];
@@ -1,9 +1,3 @@
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
1
  import usePointer from "../../services/pointer.js";
8
2
  import useRaf from "../../services/raf.js";
9
3
  import useResize from "../../services/resize.js";
@@ -11,7 +5,7 @@ import useScroll from "../../services/scroll.js";
11
5
  import useKey from "../../services/key.js";
12
6
  import useLoad from "../../services/load.js";
13
7
  import AbstractManager from "./AbstractManager.js";
14
- import { noop, isFunction } from "../../utils/index.js";
8
+ import { noop, isFunction, isDefined, isDev } from "../../utils/index.js";
15
9
  const SERVICES_MAP = {
16
10
  scrolled: useScroll,
17
11
  resized: useResize,
@@ -22,10 +16,7 @@ const SERVICES_MAP = {
22
16
  };
23
17
  const SERVICE_NAMES = Object.keys(SERVICES_MAP);
24
18
  class ServicesManager extends AbstractManager {
25
- constructor() {
26
- super(...arguments);
27
- __publicField(this, "__customServices", {});
28
- }
19
+ __customServices = {};
29
20
  get __services() {
30
21
  return {
31
22
  ...this.__customServices,
@@ -73,7 +64,7 @@ class ServicesManager extends AbstractManager {
73
64
  remove(this.__base.$id);
74
65
  }
75
66
  toggle(service, force) {
76
- if (typeof force !== "undefined") {
67
+ if (isDefined(force)) {
77
68
  if (force && !this.has(service)) {
78
69
  this.enable(service);
79
70
  }
@@ -92,7 +83,10 @@ class ServicesManager extends AbstractManager {
92
83
  }
93
84
  unregister(name) {
94
85
  if (SERVICE_NAMES.includes(name)) {
95
- throw new Error(`[ServicesManager] The \`${name}\` core service can not be unregistered.`);
86
+ if (isDev) {
87
+ throw new Error(`[ServicesManager] The \`${name}\` core service can not be unregistered.`);
88
+ }
89
+ return;
96
90
  }
97
91
  this.__base.__removeEmits(name);
98
92
  delete this.__customServices[name];
package/Base/utils.cjs CHANGED
@@ -19,9 +19,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // packages/js-toolkit/Base/utils.js
20
20
  var utils_exports = {};
21
21
  __export(utils_exports, {
22
- getComponentElements: () => getComponentElements
22
+ eventIsDefinedInConfig: () => eventIsDefinedInConfig,
23
+ eventIsNative: () => eventIsNative,
24
+ getComponentElements: () => getComponentElements,
25
+ getEventTarget: () => getEventTarget
23
26
  });
24
27
  module.exports = __toCommonJS(utils_exports);
28
+ var import_utils = require("../utils/index.cjs");
25
29
  function getComponentElements(nameOrSelector, element = document) {
26
30
  const selector = `[data-component="${nameOrSelector}"]`;
27
31
  let elements = [];
@@ -34,4 +38,22 @@ function getComponentElements(nameOrSelector, element = document) {
34
38
  }
35
39
  return elements;
36
40
  }
41
+ function eventIsDefinedInConfig(event, config) {
42
+ return (0, import_utils.isArray)(config.emits) && config.emits.includes(event);
43
+ }
44
+ function eventIsNative(event, element) {
45
+ return (0, import_utils.isDefined)(element[`on${event}`]);
46
+ }
47
+ function getEventTarget(instance, event, config) {
48
+ if (eventIsDefinedInConfig(event, config)) {
49
+ return instance;
50
+ }
51
+ if (eventIsNative(event, instance.$el)) {
52
+ return instance.$el;
53
+ }
54
+ if (import_utils.isDev) {
55
+ console.warn(`[${config.name}]`, `The "${event}" event is missing from the configuration and is not a native`, `event for the root element of type \`${instance.$el.constructor.name}\`.`);
56
+ }
57
+ return instance;
58
+ }
37
59
  if (module.exports.default) module.exports = module.exports.default;
package/Base/utils.d.ts CHANGED
@@ -12,4 +12,29 @@
12
12
  * A list of elements on which the component should be mounted.
13
13
  */
14
14
  export function getComponentElements(nameOrSelector: string, element?: HTMLElement | Document): Array<HTMLElement>;
15
+ /**
16
+ * Test if an event is defined in the given config.
17
+ *
18
+ * @param {string} event
19
+ * @param {import('./index.js').BaseConfig} config
20
+ * @returns {boolean}
21
+ */
22
+ export function eventIsDefinedInConfig(event: string, config: import('./index.js').BaseConfig): boolean;
23
+ /**
24
+ * Test if an event can be used on the given element.
25
+ *
26
+ * @param {string} event
27
+ * @param {HTMLElement} element
28
+ * @returns {boolean}
29
+ */
30
+ export function eventIsNative(event: string, element: HTMLElement): boolean;
31
+ /**
32
+ * Get the target of a given event.
33
+ *
34
+ * @param {Base} instance
35
+ * @param {string} event
36
+ * @param {import('./index.js').BaseConfig} config
37
+ * @returns {Base|Base['$el']}
38
+ */
39
+ export function getEventTarget(instance: Base, event: string, config: import('./index.js').BaseConfig): Base | Base['$el'];
15
40
  export type Base = import('./index.js').default;
package/Base/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { isArray, isDefined, isDev } from "../utils/index.js";
1
2
  function getComponentElements(nameOrSelector, element = document) {
2
3
  const selector = `[data-component="${nameOrSelector}"]`;
3
4
  let elements = [];
@@ -10,6 +11,27 @@ function getComponentElements(nameOrSelector, element = document) {
10
11
  }
11
12
  return elements;
12
13
  }
14
+ function eventIsDefinedInConfig(event, config) {
15
+ return isArray(config.emits) && config.emits.includes(event);
16
+ }
17
+ function eventIsNative(event, element) {
18
+ return isDefined(element[`on${event}`]);
19
+ }
20
+ function getEventTarget(instance, event, config) {
21
+ if (eventIsDefinedInConfig(event, config)) {
22
+ return instance;
23
+ }
24
+ if (eventIsNative(event, instance.$el)) {
25
+ return instance.$el;
26
+ }
27
+ if (isDev) {
28
+ console.warn(`[${config.name}]`, `The "${event}" event is missing from the configuration and is not a native`, `event for the root element of type \`${instance.$el.constructor.name}\`.`);
29
+ }
30
+ return instance;
31
+ }
13
32
  export {
14
- getComponentElements
33
+ eventIsDefinedInConfig,
34
+ eventIsNative,
35
+ getComponentElements,
36
+ getEventTarget
15
37
  };
@@ -26,6 +26,7 @@ __export(withBreakpointManager_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(withBreakpointManager_exports);
28
28
  var import_resize = __toESM(require("../services/resize.cjs"), 1);
29
+ var import_utils = require("../utils/index.cjs");
29
30
  function testBreakpoints(breakpoints) {
30
31
  const { breakpoint } = (0, import_resize.default)().props();
31
32
  breakpoints.forEach(([breakpointKeys, instance]) => {
@@ -45,15 +46,24 @@ function mountComponents(instance, breakpoints) {
45
46
  }
46
47
  var instances = /* @__PURE__ */ new WeakMap();
47
48
  function withBreakpointManager(BaseClass, breakpoints) {
48
- if (!Array.isArray(breakpoints)) {
49
- throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");
49
+ if (!(0, import_utils.isArray)(breakpoints)) {
50
+ if (import_utils.isDev) {
51
+ throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");
52
+ }
53
+ return BaseClass;
50
54
  }
51
55
  if (breakpoints.length < 2) {
52
- throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");
56
+ if (import_utils.isDev) {
57
+ throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");
58
+ }
59
+ return BaseClass;
53
60
  }
54
61
  const { add, props } = (0, import_resize.default)();
55
62
  if (!props().breakpoint) {
56
- throw new Error(`The \`BreakpointManager\` class requires breakpoints to be defined.`);
63
+ if (import_utils.isDev) {
64
+ throw new Error(`The \`BreakpointManager\` class requires breakpoints to be defined.`);
65
+ }
66
+ return BaseClass;
57
67
  }
58
68
  return class extends BaseClass {
59
69
  constructor(element) {
@@ -72,7 +82,7 @@ function withBreakpointManager(BaseClass, breakpoints) {
72
82
  return this;
73
83
  }
74
84
  $destroy() {
75
- if (Array.isArray(instances.get(this))) {
85
+ if ((0, import_utils.isArray)(instances.get(this))) {
76
86
  instances.get(this).forEach(([, instance]) => {
77
87
  instance.$destroy();
78
88
  });
@@ -1,4 +1,5 @@
1
1
  import useResize from "../services/resize.js";
2
+ import { isDev, isArray } from "../utils/index.js";
2
3
  function testBreakpoints(breakpoints) {
3
4
  const { breakpoint } = useResize().props();
4
5
  breakpoints.forEach(([breakpointKeys, instance]) => {
@@ -18,15 +19,24 @@ function mountComponents(instance, breakpoints) {
18
19
  }
19
20
  const instances = /* @__PURE__ */ new WeakMap();
20
21
  function withBreakpointManager(BaseClass, breakpoints) {
21
- if (!Array.isArray(breakpoints)) {
22
- throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");
22
+ if (!isArray(breakpoints)) {
23
+ if (isDev) {
24
+ throw new Error("[withBreakpointManager] The `breakpoints` parameter must be an array.");
25
+ }
26
+ return BaseClass;
23
27
  }
24
28
  if (breakpoints.length < 2) {
25
- throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");
29
+ if (isDev) {
30
+ throw new Error("[withBreakpointManager] You must define at least 2 breakpoints.");
31
+ }
32
+ return BaseClass;
26
33
  }
27
34
  const { add, props } = useResize();
28
35
  if (!props().breakpoint) {
29
- throw new Error(`The \`BreakpointManager\` class requires breakpoints to be defined.`);
36
+ if (isDev) {
37
+ throw new Error(`The \`BreakpointManager\` class requires breakpoints to be defined.`);
38
+ }
39
+ return BaseClass;
30
40
  }
31
41
  return class extends BaseClass {
32
42
  constructor(element) {
@@ -45,7 +55,7 @@ function withBreakpointManager(BaseClass, breakpoints) {
45
55
  return this;
46
56
  }
47
57
  $destroy() {
48
- if (Array.isArray(instances.get(this))) {
58
+ if (isArray(instances.get(this))) {
49
59
  instances.get(this).forEach(([, instance]) => {
50
60
  instance.$destroy();
51
61
  });
@@ -4,7 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
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
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -19,10 +18,6 @@ var __copyProps = (to, from, except, desc) => {
19
18
  };
20
19
  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
20
  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
21
 
27
22
  // packages/js-toolkit/decorators/withBreakpointObserver.js
28
23
  var withBreakpointObserver_exports = {};
@@ -31,6 +26,7 @@ __export(withBreakpointObserver_exports, {
31
26
  });
32
27
  module.exports = __toCommonJS(withBreakpointObserver_exports);
33
28
  var import_resize = __toESM(require("../services/resize.cjs"), 1);
29
+ var import_utils = require("../utils/index.cjs");
34
30
  function testBreakpoints(instance, breakpoint = (0, import_resize.default)().props().breakpoint) {
35
31
  const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
36
32
  const isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(" ").includes(breakpoint);
@@ -51,7 +47,9 @@ function testConflictingBreakpointConfiguration(instance) {
51
47
  }
52
48
  }
53
49
  function addToResize(key, instance) {
54
- testConflictingBreakpointConfiguration(instance);
50
+ if (import_utils.isDev) {
51
+ testConflictingBreakpointConfiguration(instance);
52
+ }
55
53
  const { add, has } = (0, import_resize.default)();
56
54
  if (!has(key)) {
57
55
  add(key, function onResize({ breakpoint }) {
@@ -65,14 +63,25 @@ function addToResize(key, instance) {
65
63
  }
66
64
  }
67
65
  function withBreakpointObserver(BaseClass) {
68
- var _a, _b;
69
- return _b = class extends BaseClass {
66
+ return class extends BaseClass {
67
+ static config = {
68
+ ...BaseClass.config,
69
+ name: `${BaseClass.config.name}WithBreakpointObserver`,
70
+ options: {
71
+ ...BaseClass.config?.options || {},
72
+ activeBreakpoints: String,
73
+ inactiveBreakpoints: String
74
+ }
75
+ };
70
76
  constructor(element) {
71
77
  super(element);
72
78
  const { remove, props } = (0, import_resize.default)();
73
79
  const { name } = this.$options;
74
80
  if (!props().breakpoint) {
75
- throw new Error(`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);
81
+ if (import_utils.isDev) {
82
+ throw new Error(`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);
83
+ }
84
+ return;
76
85
  }
77
86
  const key = `BreakpointObserver-${this.$id}`;
78
87
  const mutationObserver = new MutationObserver(([mutation]) => {
@@ -101,14 +110,6 @@ function withBreakpointObserver(BaseClass) {
101
110
  }
102
111
  return this;
103
112
  }
104
- }, __publicField(_b, "config", {
105
- ...BaseClass.config,
106
- name: `${BaseClass.config.name}WithBreakpointObserver`,
107
- options: {
108
- ...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
109
- activeBreakpoints: String,
110
- inactiveBreakpoints: String
111
- }
112
- }), _b;
113
+ };
113
114
  }
114
115
  if (module.exports.default) module.exports = module.exports.default;
@@ -1,10 +1,5 @@
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
1
  import useResize from "../services/resize.js";
2
+ import { isDev } from "../utils/index.js";
8
3
  function testBreakpoints(instance, breakpoint = useResize().props().breakpoint) {
9
4
  const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
10
5
  const isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(" ").includes(breakpoint);
@@ -25,7 +20,9 @@ function testConflictingBreakpointConfiguration(instance) {
25
20
  }
26
21
  }
27
22
  function addToResize(key, instance) {
28
- testConflictingBreakpointConfiguration(instance);
23
+ if (isDev) {
24
+ testConflictingBreakpointConfiguration(instance);
25
+ }
29
26
  const { add, has } = useResize();
30
27
  if (!has(key)) {
31
28
  add(key, function onResize({ breakpoint }) {
@@ -39,14 +36,25 @@ function addToResize(key, instance) {
39
36
  }
40
37
  }
41
38
  function withBreakpointObserver(BaseClass) {
42
- var _a, _b;
43
- return _b = class extends BaseClass {
39
+ return class extends BaseClass {
40
+ static config = {
41
+ ...BaseClass.config,
42
+ name: `${BaseClass.config.name}WithBreakpointObserver`,
43
+ options: {
44
+ ...BaseClass.config?.options || {},
45
+ activeBreakpoints: String,
46
+ inactiveBreakpoints: String
47
+ }
48
+ };
44
49
  constructor(element) {
45
50
  super(element);
46
51
  const { remove, props } = useResize();
47
52
  const { name } = this.$options;
48
53
  if (!props().breakpoint) {
49
- throw new Error(`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);
54
+ if (isDev) {
55
+ throw new Error(`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`);
56
+ }
57
+ return;
50
58
  }
51
59
  const key = `BreakpointObserver-${this.$id}`;
52
60
  const mutationObserver = new MutationObserver(([mutation]) => {
@@ -75,15 +83,7 @@ function withBreakpointObserver(BaseClass) {
75
83
  }
76
84
  return this;
77
85
  }
78
- }, __publicField(_b, "config", {
79
- ...BaseClass.config,
80
- name: `${BaseClass.config.name}WithBreakpointObserver`,
81
- options: {
82
- ...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
83
- activeBreakpoints: String,
84
- inactiveBreakpoints: String
85
- }
86
- }), _b;
86
+ };
87
87
  }
88
88
  export {
89
89
  withBreakpointObserver as default
@@ -4,7 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
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
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -19,10 +18,6 @@ var __copyProps = (to, from, except, desc) => {
19
18
  };
20
19
  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
20
  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
21
 
27
22
  // packages/js-toolkit/decorators/withDrag.js
28
23
  var withDrag_exports = {};
@@ -32,8 +27,11 @@ __export(withDrag_exports, {
32
27
  module.exports = __toCommonJS(withDrag_exports);
33
28
  var import_drag = __toESM(require("../services/drag.cjs"), 1);
34
29
  function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
35
- var _a;
36
- return _a = class extends BaseClass {
30
+ return class extends BaseClass {
31
+ static config = {
32
+ name: `${BaseClass.config.name}WithDrag`,
33
+ emits: ["dragged"]
34
+ };
37
35
  constructor(el) {
38
36
  super(el);
39
37
  this.$on("mounted", () => {
@@ -45,9 +43,6 @@ function withDrag(BaseClass, { target = (instance) => instance.$el, ...options }
45
43
  this.$services.unregister("dragged");
46
44
  });
47
45
  }
48
- }, __publicField(_a, "config", {
49
- name: `${BaseClass.config.name}WithDrag`,
50
- emits: ["dragged"]
51
- }), _a;
46
+ };
52
47
  }
53
48
  if (module.exports.default) module.exports = module.exports.default;
@@ -1,13 +1,10 @@
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
1
  import useDrag from "../services/drag.js";
8
2
  function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
9
- var _a;
10
- return _a = class extends BaseClass {
3
+ return class extends BaseClass {
4
+ static config = {
5
+ name: `${BaseClass.config.name}WithDrag`,
6
+ emits: ["dragged"]
7
+ };
11
8
  constructor(el) {
12
9
  super(el);
13
10
  this.$on("mounted", () => {
@@ -19,10 +16,7 @@ function withDrag(BaseClass, { target = (instance) => instance.$el, ...options }
19
16
  this.$services.unregister("dragged");
20
17
  });
21
18
  }
22
- }, __publicField(_a, "config", {
23
- name: `${BaseClass.config.name}WithDrag`,
24
- emits: ["dragged"]
25
- }), _a;
19
+ };
26
20
  }
27
21
  export {
28
22
  withDrag as default