@studiometa/js-toolkit 2.4.4-alpha.3 → 2.4.4-alpha.6

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 (71) hide show
  1. package/Base/index.cjs +1 -1
  2. package/Base/index.d.ts +16 -18
  3. package/Base/index.js +1 -1
  4. package/Base/managers/AbstractManager.d.ts +2 -2
  5. package/Base/managers/ChildrenManager.cjs +2 -4
  6. package/Base/managers/ChildrenManager.d.ts +2 -10
  7. package/Base/managers/ChildrenManager.js +1 -3
  8. package/Base/managers/EventsManager.cjs +3 -3
  9. package/Base/managers/EventsManager.d.ts +9 -15
  10. package/Base/managers/EventsManager.js +2 -2
  11. package/Base/managers/OptionsManager.d.ts +2 -2
  12. package/Base/managers/ServicesManager.d.ts +1 -1
  13. package/Base/types.d.ts +5 -1
  14. package/Base/utils.cjs +1 -1
  15. package/Base/utils.d.ts +5 -21
  16. package/decorators/index.cjs +11 -32
  17. package/decorators/index.d.ts +10 -10
  18. package/decorators/index.js +10 -22
  19. package/decorators/withBreakpointManager.cjs +9 -14
  20. package/decorators/withBreakpointManager.d.ts +3 -56
  21. package/decorators/withBreakpointManager.js +7 -6
  22. package/decorators/withBreakpointObserver.cjs +11 -15
  23. package/decorators/withBreakpointObserver.d.ts +12 -62
  24. package/decorators/withBreakpointObserver.js +8 -6
  25. package/decorators/withDrag.cjs +10 -15
  26. package/decorators/withDrag.d.ts +8 -51
  27. package/decorators/withDrag.js +9 -8
  28. package/decorators/withExtraConfig.cjs +5 -4
  29. package/decorators/withExtraConfig.d.ts +3 -53
  30. package/decorators/withExtraConfig.js +5 -4
  31. package/decorators/withFreezedOptions.cjs +4 -3
  32. package/decorators/withFreezedOptions.d.ts +6 -53
  33. package/decorators/withFreezedOptions.js +4 -3
  34. package/decorators/withIntersectionObserver.cjs +7 -5
  35. package/decorators/withIntersectionObserver.d.ts +4 -63
  36. package/decorators/withIntersectionObserver.js +7 -5
  37. package/decorators/withMountWhenInView.cjs +11 -6
  38. package/decorators/withMountWhenInView.d.ts +16 -61
  39. package/decorators/withMountWhenInView.js +11 -6
  40. package/decorators/withResponsiveOptions.cjs +4 -3
  41. package/decorators/withResponsiveOptions.d.ts +3 -50
  42. package/decorators/withResponsiveOptions.js +4 -3
  43. package/decorators/withScrolledInView.cjs +25 -18
  44. package/decorators/withScrolledInView.d.ts +30 -141
  45. package/decorators/withScrolledInView.js +25 -12
  46. package/decorators/withVue2.cjs +8 -5
  47. package/decorators/withVue2.d.ts +8 -62
  48. package/decorators/withVue2.js +8 -5
  49. package/helpers/createApp.cjs +1 -1
  50. package/helpers/createApp.d.ts +2 -10
  51. package/helpers/getDirectChildren.cjs +5 -5
  52. package/helpers/getDirectChildren.d.ts +3 -6
  53. package/helpers/getDirectChildren.js +4 -4
  54. package/helpers/getInstanceFromElement.cjs +3 -4
  55. package/helpers/getInstanceFromElement.d.ts +2 -11
  56. package/helpers/getInstanceFromElement.js +2 -3
  57. package/helpers/importOnInteraction.cjs +1 -1
  58. package/helpers/importOnInteraction.d.ts +4 -9
  59. package/helpers/importWhenIdle.cjs +3 -5
  60. package/helpers/importWhenIdle.d.ts +7 -10
  61. package/helpers/importWhenIdle.js +2 -4
  62. package/helpers/importWhenVisible.cjs +1 -1
  63. package/helpers/importWhenVisible.d.ts +2 -7
  64. package/helpers/index.cjs +1 -1
  65. package/helpers/index.d.ts +6 -6
  66. package/helpers/utils.cjs +1 -1
  67. package/helpers/utils.d.ts +1 -1
  68. package/index.cjs +2 -8
  69. package/index.d.ts +2 -2
  70. package/index.js +2 -2
  71. package/package.json +1 -1
package/Base/index.cjs CHANGED
@@ -30,7 +30,7 @@ var __publicField = (obj, key, value) => {
30
30
  // packages/js-toolkit/Base/index.ts
31
31
  var Base_exports = {};
32
32
  __export(Base_exports, {
33
- default: () => Base
33
+ Base: () => Base
34
34
  });
35
35
  module.exports = __toCommonJS(Base_exports);
36
36
  var import_utils = require("./utils.cjs");
package/Base/index.d.ts CHANGED
@@ -3,9 +3,15 @@ import RefsManager from './managers/RefsManager.js';
3
3
  import ServicesManager from './managers/ServicesManager.js';
4
4
  import EventsManager from './managers/EventsManager.js';
5
5
  import OptionsManager from './managers/OptionsManager.js';
6
- export declare type BaseConstructor = typeof Base;
7
- export declare type BaseAsyncConstructor = (Base: any) => Promise<BaseConstructor | {
8
- default: BaseConstructor;
6
+ export declare type BaseEl = HTMLElement & {
7
+ __base__?: WeakMap<BaseConstructor, Base | 'terminated'>;
8
+ };
9
+ export declare type BaseConstructor<T extends Base = Base> = {
10
+ new (...args: any[]): T;
11
+ prototype: Base;
12
+ } & Pick<typeof Base, keyof typeof Base>;
13
+ export declare type BaseAsyncConstructor<T extends Base = Base> = (Base: any) => Promise<BaseConstructor<T> | {
14
+ default: BaseConstructor<T>;
9
15
  }>;
10
16
  export declare type BaseOptions = {
11
17
  [name: string]: unknown;
@@ -32,9 +38,7 @@ export declare type BaseTypeParameter = {
32
38
  $el?: HTMLElement;
33
39
  $options?: BaseOptions;
34
40
  $refs?: BaseRefs;
35
- $children?: {
36
- [name: string]: Base | Promise<Base>;
37
- };
41
+ $children?: BaseChildren;
38
42
  };
39
43
  export declare type Managers = {
40
44
  ChildrenManager: typeof ChildrenManager;
@@ -46,7 +50,7 @@ export declare type Managers = {
46
50
  /**
47
51
  * Base class.
48
52
  */
49
- export default class Base<T extends BaseTypeParameter = BaseTypeParameter> extends EventTarget {
53
+ export declare class Base<T extends BaseTypeParameter = BaseTypeParameter> extends EventTarget {
50
54
  /**
51
55
  * This is a Base instance.
52
56
  */
@@ -62,9 +66,7 @@ export default class Base<T extends BaseTypeParameter = BaseTypeParameter> exten
62
66
  /**
63
67
  * The root element.
64
68
  */
65
- $el: T['$el'] & HTMLElement & {
66
- __base__?: WeakMap<BaseConstructor, Base | 'terminated'>;
67
- };
69
+ $el: T['$el'] & BaseEl;
68
70
  /**
69
71
  * The state of the component.
70
72
  */
@@ -88,21 +90,17 @@ export default class Base<T extends BaseTypeParameter = BaseTypeParameter> exten
88
90
  get $refs(): RefsManager & T['$refs'] & BaseRefs;
89
91
  __options: OptionsManager & T['$options'] & BaseOptions;
90
92
  get $options(): OptionsManager & T['$options'] & BaseOptions;
91
- __children: ChildrenManager & {
92
- [key in keyof T['$children']]: Array<T['$children'][key]>;
93
- } & BaseChildren;
94
- get $children(): ChildrenManager & {
95
- [key in keyof T['$children']]: Array<T['$children'][key]>;
96
- } & BaseChildren;
93
+ __children: ChildrenManager & T['$children'] & BaseChildren;
94
+ get $children(): ChildrenManager & T['$children'] & BaseChildren;
97
95
  __events: EventsManager;
98
96
  /**
99
97
  * Small helper to log stuff.
100
98
  */
101
- get $log(): (...args: any) => void;
99
+ get $log(): (...args: unknown[]) => void;
102
100
  /**
103
101
  * Small helper to debug information.
104
102
  */
105
- get __debug(): (...args: any) => void;
103
+ get __debug(): (...args: unknown[]) => void;
106
104
  /**
107
105
  * Get manager constructors.
108
106
  */
package/Base/index.js CHANGED
@@ -289,5 +289,5 @@ __publicField(Base, "config", {
289
289
  ]
290
290
  });
291
291
  export {
292
- Base as default
292
+ Base
293
293
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @typedef {import('../index.js').default} Base
2
+ * @typedef {import('../index.js').Base} Base
3
3
  * @typedef {import('../index.js').BaseConfig} BaseConfig
4
4
  * @typedef {import('./EventsManager.js').default} EventsManager
5
5
  */
@@ -39,6 +39,6 @@ export default class AbstractManager {
39
39
  */
40
40
  __hideProperties(properties: string[]): void;
41
41
  }
42
- export type Base = import('../index.js').default;
42
+ export type Base = import('../index.js').Base;
43
43
  export type BaseConfig = import('../index.js').BaseConfig;
44
44
  export type EventsManager = import('./EventsManager.js').default;
@@ -27,7 +27,7 @@ var __publicField = (obj, key, value) => {
27
27
  return value;
28
28
  };
29
29
 
30
- // packages/js-toolkit/Base/managers/ChildrenManager.js
30
+ // packages/js-toolkit/Base/managers/ChildrenManager.ts
31
31
  var ChildrenManager_exports = {};
32
32
  __export(ChildrenManager_exports, {
33
33
  default: () => ChildrenManager
@@ -36,9 +36,7 @@ module.exports = __toCommonJS(ChildrenManager_exports);
36
36
  var import_AbstractManager = __toESM(require("./AbstractManager.cjs"), 1);
37
37
  var import_utils = require("../utils.cjs");
38
38
  function __getChild(that, el, ComponentClass, name) {
39
- const asyncComponentPromise = that.__asyncComponentPromises.get(
40
- ComponentClass
41
- );
39
+ const asyncComponentPromise = that.__asyncComponentPromises.get(ComponentClass);
42
40
  if ("$isBase" in ComponentClass || asyncComponentPromise && asyncComponentPromise.status === "resolved") {
43
41
  let ctor = ComponentClass;
44
42
  if (asyncComponentPromise) {
@@ -1,3 +1,5 @@
1
+ import type { BaseConstructor, BaseAsyncConstructor } from '../index.js';
2
+ import AbstractManager from './AbstractManager.js';
1
3
  /**
2
4
  * Children manager.
3
5
  */
@@ -5,17 +7,12 @@ export default class ChildrenManager extends AbstractManager {
5
7
  /**
6
8
  * Store async component promises to avoid calling them multiple times and
7
9
  * waiting for them when they are already resolved.
8
- *
9
- * @type {WeakMap<BaseAsyncConstructor, { promise: ReturnType<BaseAsyncConstructor>, status: 'pending'|'resolved', ctor?: BaseConstructor }>}
10
10
  */
11
11
  __asyncComponentPromises: WeakMap<BaseAsyncConstructor, {
12
12
  promise: ReturnType<BaseAsyncConstructor>;
13
13
  status: 'pending' | 'resolved';
14
14
  ctor?: BaseConstructor;
15
15
  }>;
16
- /**
17
- * @returns {string[]}
18
- */
19
16
  get registeredNames(): string[];
20
17
  /**
21
18
  * Register instances of all children components.
@@ -34,8 +31,3 @@ export default class ChildrenManager extends AbstractManager {
34
31
  */
35
32
  destroyAll(): void;
36
33
  }
37
- export type Base = import('../index.js').default;
38
- export type BaseConstructor = import('../index.js').BaseConstructor;
39
- export type BaseAsyncConstructor = import('../index.js').BaseAsyncConstructor;
40
- export type BaseConfigComponents = import('../index.js').BaseConfigComponents;
41
- import AbstractManager from "./AbstractManager.js";
@@ -7,9 +7,7 @@ var __publicField = (obj, key, value) => {
7
7
  import AbstractManager from "./AbstractManager.js";
8
8
  import { getComponentElements } from "../utils.js";
9
9
  function __getChild(that, el, ComponentClass, name) {
10
- const asyncComponentPromise = that.__asyncComponentPromises.get(
11
- ComponentClass
12
- );
10
+ const asyncComponentPromise = that.__asyncComponentPromises.get(ComponentClass);
13
11
  if ("$isBase" in ComponentClass || asyncComponentPromise && asyncComponentPromise.status === "resolved") {
14
12
  let ctor = ComponentClass;
15
13
  if (asyncComponentPromise) {
@@ -27,7 +27,7 @@ var __publicField = (obj, key, value) => {
27
27
  return value;
28
28
  };
29
29
 
30
- // packages/js-toolkit/Base/managers/EventsManager.js
30
+ // packages/js-toolkit/Base/managers/EventsManager.ts
31
31
  var EventsManager_exports = {};
32
32
  __export(EventsManager_exports, {
33
33
  default: () => EventsManager,
@@ -143,14 +143,14 @@ var EventsManager = class extends import_AbstractManager.default {
143
143
  const childrenManager = this.__base.$children;
144
144
  const { name, child: resolvedChild } = childrenManager.registeredNames.map((childName) => ({
145
145
  name: childName,
146
- child: childrenManager[childName].find(
146
+ child: [...childrenManager[childName]].find(
147
147
  (instance) => instance === event.currentTarget || instance.$el === event.currentTarget
148
148
  )
149
149
  })).find(({ child }) => child);
150
150
  const normalizedChildName = normalizeName(name);
151
151
  const normalizedEventName = normalizeName(event.type);
152
152
  const method = `on${normalizedChildName}${normalizedEventName}`;
153
- const index = childrenManager[name].indexOf(resolvedChild);
153
+ const index = [...childrenManager[name]].indexOf(resolvedChild);
154
154
  const args = (0, import_utils.isArray)(event.detail) ? event.detail : [];
155
155
  this.__base[method](...args, index, event);
156
156
  }
@@ -1,3 +1,5 @@
1
+ import type { Base } from '../index.js';
2
+ import AbstractManager from './AbstractManager.js';
1
3
  /**
2
4
  * Normalize the given name to PascalCase, such as:
3
5
  *
@@ -18,42 +20,37 @@
18
20
  * @param {string} name
19
21
  * @returns {string}
20
22
  */
21
- export function normalizeName(name: string): string;
23
+ export declare function normalizeName(name: string): string;
22
24
  /**
23
25
  * Normalize the event names from PascalCase to kebab-case.
24
26
  *
25
27
  * @param {string} name
26
28
  * @returns {string}
27
29
  */
28
- export function normalizeEventName(name: string): string;
30
+ export declare function normalizeEventName(name: string): string;
29
31
  /**
30
32
  * Event management class.
31
33
  * @todo Prevent binding of `onChildOrRefEvent` to the root element
32
34
  * @todo Use event delegation?
33
35
  */
34
36
  export default class EventsManager extends AbstractManager {
35
- /**
36
- * @type {WeakMap}
37
- */
38
- __methodsCache: WeakMap<any, any>;
37
+ __methodsCache: Map<string, string[]>;
39
38
  /**
40
39
  * Event listener object for the root element.
41
- *
42
- * @type {EventListenerObject}
43
40
  */
44
41
  __rootElementHandler: EventListenerObject;
45
42
  /**
46
43
  * Event listener object for the refs.
47
- *
48
- * @type {EventListenerObject}
49
44
  */
50
45
  __refsHandler: EventListenerObject;
51
46
  /**
52
47
  * Event listener object for the children.
53
- *
54
- * @type {EventListenerObject}
55
48
  */
56
49
  __childrenHandler: EventListenerObject;
50
+ /**
51
+ * Class constructor.
52
+ */
53
+ constructor(base: Base);
57
54
  /**
58
55
  * Bind event methods to the given ref elements.
59
56
  *
@@ -107,6 +104,3 @@ export default class EventsManager extends AbstractManager {
107
104
  */
108
105
  unbindRootElement(): void;
109
106
  }
110
- export type Base = import('../index.js').default;
111
- export type ChildrenManager = import('./ChildrenManager.js').default;
112
- import AbstractManager from "./AbstractManager.js";
@@ -112,14 +112,14 @@ class EventsManager extends AbstractManager {
112
112
  const childrenManager = this.__base.$children;
113
113
  const { name, child: resolvedChild } = childrenManager.registeredNames.map((childName) => ({
114
114
  name: childName,
115
- child: childrenManager[childName].find(
115
+ child: [...childrenManager[childName]].find(
116
116
  (instance) => instance === event.currentTarget || instance.$el === event.currentTarget
117
117
  )
118
118
  })).find(({ child }) => child);
119
119
  const normalizedChildName = normalizeName(name);
120
120
  const normalizedEventName = normalizeName(event.type);
121
121
  const method = `on${normalizedChildName}${normalizedEventName}`;
122
- const index = childrenManager[name].indexOf(resolvedChild);
122
+ const index = [...childrenManager[name]].indexOf(resolvedChild);
123
123
  const args = isArray(event.detail) ? event.detail : [];
124
124
  this.__base[method](...args, index, event);
125
125
  }
@@ -52,7 +52,7 @@ export default class OptionsManager extends AbstractManager {
52
52
  set(name: string, value: any, config: OptionObject): void;
53
53
  }
54
54
  export type DeepmergeOptions = import('deepmerge').Options;
55
- export type Base = import('../index.js').default;
55
+ export type Base = import('../index.js').Base;
56
56
  export type BaseConfig = import('../index.js').BaseConfig;
57
57
  export type OptionType = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor;
58
58
  export type ArrayOption = {
@@ -79,7 +79,7 @@ export type BooleanOption = {
79
79
  };
80
80
  export type OptionObject = ArrayOption | ObjectOption | StringOption | NumberOption | BooleanOption;
81
81
  export type OptionsSchema = {
82
- [name: string]: OptionType | OptionObject;
82
+ [name: string]: OptionObject | OptionType;
83
83
  };
84
84
  export type OptionsInterface = {
85
85
  [optionName: string]: any;
@@ -79,7 +79,7 @@ export default class ServicesManager extends AbstractManager {
79
79
  */
80
80
  unregister(name: string): void;
81
81
  }
82
- export type Base = import('../index').default;
82
+ export type Base = import('../index').Base;
83
83
  export type BaseConstructor = import('../index').BaseConstructor;
84
84
  export type ServiceInterface = import('../../services').ServiceInterface<any>;
85
85
  export type Services = typeof SERVICES_MAP & Record<string, () => import("../../services").ServiceInterface<any>>;
package/Base/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { KeyServiceProps, LoadServiceProps, PointerServiceProps, RafServiceProps, ResizeServiceProps, ScrollServiceProps } from '../services/index.js';
1
+ import type { Base, BaseTypeParameter } from './index.js';
2
+ import type { KeyServiceProps, LoadServiceProps, PointerServiceProps, RafServiceProps, ResizeServiceProps, ScrollServiceProps } from '../services/index.js';
2
3
  export interface BaseInterface {
3
4
  /**
4
5
  * Mounted hook.
@@ -41,3 +42,6 @@ export interface BaseInterface {
41
42
  */
42
43
  scrolled?(props: ScrollServiceProps): void;
43
44
  }
45
+ export declare type BaseDecorator<S extends BaseInterface, T extends Base> = {
46
+ new <W extends BaseTypeParameter = BaseTypeParameter>(...args: unknown[]): S & T & Base<W>;
47
+ } & Partial<Pick<T, keyof T>>;
package/Base/utils.cjs CHANGED
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // packages/js-toolkit/Base/utils.js
19
+ // packages/js-toolkit/Base/utils.ts
20
20
  var utils_exports = {};
21
21
  __export(utils_exports, {
22
22
  eventIsDefinedInConfig: () => eventIsDefinedInConfig,
package/Base/utils.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- /**
2
- * @typedef {import('./index.js').default} Base
3
- */
1
+ import type { Base, BaseConfig } from './index.js';
4
2
  /**
5
3
  * Get a list of elements based on the name of a component.
6
4
  *
@@ -11,30 +9,16 @@
11
9
  * @returns {Array<HTMLElement>}
12
10
  * A list of elements on which the component should be mounted.
13
11
  */
14
- export function getComponentElements(nameOrSelector: string, element?: HTMLElement | Document): Array<HTMLElement>;
12
+ export declare function getComponentElements(nameOrSelector: string, element?: HTMLElement | Document): HTMLElement[];
15
13
  /**
16
14
  * 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
15
  */
22
- export function eventIsDefinedInConfig(event: string, config: import('./index.js').BaseConfig): boolean;
16
+ export declare function eventIsDefinedInConfig(event: string, config: BaseConfig): boolean;
23
17
  /**
24
18
  * Test if an event can be used on the given element.
25
- *
26
- * @param {string} event
27
- * @param {HTMLElement} element
28
- * @returns {boolean}
29
19
  */
30
- export function eventIsNative(event: string, element: HTMLElement): boolean;
20
+ export declare function eventIsNative(event: string, element: HTMLElement): boolean;
31
21
  /**
32
22
  * 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
23
  */
39
- export function getEventTarget(instance: Base, event: string, config: import('./index.js').BaseConfig): Base | Base['$el'];
40
- export type Base = import('./index.js').default;
24
+ export declare function getEventTarget(instance: Base, event: string, config: BaseConfig): Base | Base['$el'];
@@ -1,13 +1,7 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
5
  var __copyProps = (to, from, except, desc) => {
12
6
  if (from && typeof from === "object" || typeof from === "function") {
13
7
  for (let key of __getOwnPropNames(from))
@@ -16,35 +10,20 @@ var __copyProps = (to, from, except, desc) => {
16
10
  }
17
11
  return to;
18
12
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
15
 
25
16
  // packages/js-toolkit/decorators/index.ts
26
17
  var decorators_exports = {};
27
- __export(decorators_exports, {
28
- withBreakpointManager: () => import_withBreakpointManager.default,
29
- withBreakpointObserver: () => import_withBreakpointObserver.default,
30
- withDrag: () => import_withDrag.default,
31
- withExtraConfig: () => import_withExtraConfig.default,
32
- withFreezedOptions: () => import_withFreezedOptions.default,
33
- withIntersectionObserver: () => import_withIntersectionObserver.default,
34
- withMountWhenInView: () => import_withMountWhenInView.default,
35
- withResponsiveOptions: () => import_withResponsiveOptions.default,
36
- withScrolledInView: () => import_withScrolledInView.default,
37
- withVue2: () => import_withVue2.default
38
- });
39
18
  module.exports = __toCommonJS(decorators_exports);
40
- var import_withBreakpointManager = __toESM(require("./withBreakpointManager.cjs"), 1);
41
- var import_withBreakpointObserver = __toESM(require("./withBreakpointObserver.cjs"), 1);
42
- var import_withDrag = __toESM(require("./withDrag.cjs"), 1);
43
- var import_withExtraConfig = __toESM(require("./withExtraConfig.cjs"), 1);
44
- var import_withFreezedOptions = __toESM(require("./withFreezedOptions.cjs"), 1);
45
- var import_withIntersectionObserver = __toESM(require("./withIntersectionObserver.cjs"), 1);
46
- var import_withMountWhenInView = __toESM(require("./withMountWhenInView.cjs"), 1);
47
- var import_withResponsiveOptions = __toESM(require("./withResponsiveOptions.cjs"), 1);
48
- var import_withScrolledInView = __toESM(require("./withScrolledInView.cjs"), 1);
49
- var import_withVue2 = __toESM(require("./withVue2.cjs"), 1);
19
+ __reExport(decorators_exports, require("./withBreakpointManager.cjs"), module.exports);
20
+ __reExport(decorators_exports, require("./withBreakpointObserver.cjs"), module.exports);
21
+ __reExport(decorators_exports, require("./withDrag.cjs"), module.exports);
22
+ __reExport(decorators_exports, require("./withExtraConfig.cjs"), module.exports);
23
+ __reExport(decorators_exports, require("./withFreezedOptions.cjs"), module.exports);
24
+ __reExport(decorators_exports, require("./withIntersectionObserver.cjs"), module.exports);
25
+ __reExport(decorators_exports, require("./withMountWhenInView.cjs"), module.exports);
26
+ __reExport(decorators_exports, require("./withResponsiveOptions.cjs"), module.exports);
27
+ __reExport(decorators_exports, require("./withScrolledInView.cjs"), module.exports);
28
+ __reExport(decorators_exports, require("./withVue2.cjs"), module.exports);
50
29
  if (module.exports.default) module.exports = module.exports.default;
@@ -1,10 +1,10 @@
1
- export { default as withBreakpointManager } from './withBreakpointManager.js';
2
- export { default as withBreakpointObserver } from './withBreakpointObserver.js';
3
- export { default as withDrag } from './withDrag.js';
4
- export { default as withExtraConfig } from './withExtraConfig.js';
5
- export { default as withFreezedOptions } from './withFreezedOptions.js';
6
- export { default as withIntersectionObserver } from './withIntersectionObserver.js';
7
- export { default as withMountWhenInView } from './withMountWhenInView.js';
8
- export { default as withResponsiveOptions } from './withResponsiveOptions.js';
9
- export { default as withScrolledInView } from './withScrolledInView.js';
10
- export { default as withVue2 } from './withVue2.js';
1
+ export * from './withBreakpointManager.js';
2
+ export * from './withBreakpointObserver.js';
3
+ export * from './withDrag.js';
4
+ export * from './withExtraConfig.js';
5
+ export * from './withFreezedOptions.js';
6
+ export * from './withIntersectionObserver.js';
7
+ export * from './withMountWhenInView.js';
8
+ export * from './withResponsiveOptions.js';
9
+ export * from './withScrolledInView.js';
10
+ export * from './withVue2.js';
@@ -1,22 +1,10 @@
1
- import { default as default2 } from "./withBreakpointManager.js";
2
- import { default as default3 } from "./withBreakpointObserver.js";
3
- import { default as default4 } from "./withDrag.js";
4
- import { default as default5 } from "./withExtraConfig.js";
5
- import { default as default6 } from "./withFreezedOptions.js";
6
- import { default as default7 } from "./withIntersectionObserver.js";
7
- import { default as default8 } from "./withMountWhenInView.js";
8
- import { default as default9 } from "./withResponsiveOptions.js";
9
- import { default as default10 } from "./withScrolledInView.js";
10
- import { default as default11 } from "./withVue2.js";
11
- export {
12
- default2 as withBreakpointManager,
13
- default3 as withBreakpointObserver,
14
- default4 as withDrag,
15
- default5 as withExtraConfig,
16
- default6 as withFreezedOptions,
17
- default7 as withIntersectionObserver,
18
- default8 as withMountWhenInView,
19
- default9 as withResponsiveOptions,
20
- default10 as withScrolledInView,
21
- default11 as withVue2
22
- };
1
+ export * from "./withBreakpointManager.js";
2
+ export * from "./withBreakpointObserver.js";
3
+ export * from "./withDrag.js";
4
+ export * from "./withExtraConfig.js";
5
+ export * from "./withFreezedOptions.js";
6
+ export * from "./withIntersectionObserver.js";
7
+ export * from "./withMountWhenInView.js";
8
+ export * from "./withResponsiveOptions.js";
9
+ export * from "./withScrolledInView.js";
10
+ export * from "./withVue2.js";
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,22 +14,18 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
23
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
18
 
25
19
  // packages/js-toolkit/decorators/withBreakpointManager.ts
26
20
  var withBreakpointManager_exports = {};
27
21
  __export(withBreakpointManager_exports, {
28
- default: () => withBreakpointManager
22
+ withBreakpointManager: () => withBreakpointManager
29
23
  });
30
24
  module.exports = __toCommonJS(withBreakpointManager_exports);
31
- var import_resize = __toESM(require("../services/resize.cjs"), 1);
25
+ var import_services = require("../services/index.cjs");
32
26
  var import_utils = require("../utils/index.cjs");
33
27
  function testBreakpoints(breakpoints) {
34
- const { breakpoint } = (0, import_resize.default)().props();
28
+ const { breakpoint } = (0, import_services.useResize)().props();
35
29
  breakpoints.forEach(([breakpointKeys, instance]) => {
36
30
  if (breakpointKeys.includes(breakpoint) && !instance.$isMounted) {
37
31
  setTimeout(() => instance.$mount(), 0);
@@ -44,7 +38,7 @@ function mountComponents(instance, breakpoints) {
44
38
  return breakpoints.map(([bk, ComponentClass]) => {
45
39
  const child = new ComponentClass(instance.$el);
46
40
  Object.defineProperty(child, "$parent", { get: () => instance.$parent });
47
- return [bk, child];
41
+ return [bk.split(" "), child];
48
42
  });
49
43
  }
50
44
  var instances = /* @__PURE__ */ new WeakMap();
@@ -61,14 +55,14 @@ function withBreakpointManager(BaseClass, breakpoints) {
61
55
  }
62
56
  return BaseClass;
63
57
  }
64
- const { add, props } = (0, import_resize.default)();
58
+ const { add, props } = (0, import_services.useResize)();
65
59
  if (!props().breakpoint) {
66
60
  if (import_utils.isDev) {
67
- throw new Error(`The \`BreakpointManager\` class requires breakpoints to be defined.`);
61
+ throw new Error("The `BreakpointManager` class requires breakpoints to be defined.");
68
62
  }
69
63
  return BaseClass;
70
64
  }
71
- return class WithBreakpointManager extends BaseClass {
65
+ class WithBreakpointManager extends BaseClass {
72
66
  constructor(element) {
73
67
  super(element);
74
68
  if (!instances.has(this)) {
@@ -91,6 +85,7 @@ function withBreakpointManager(BaseClass, breakpoints) {
91
85
  }
92
86
  return super.$destroy();
93
87
  }
94
- };
88
+ }
89
+ return WithBreakpointManager;
95
90
  }
96
91
  if (module.exports.default) module.exports = module.exports.default;
@@ -1,59 +1,6 @@
1
- import type Base from '../Base/index.js';
2
- import type { BaseConstructor, BaseTypeParameter } from '../Base/index.js';
1
+ import type { BaseDecorator, BaseInterface } from '../Base/types.js';
2
+ import type { Base, BaseConstructor } from '../Base/index.js';
3
3
  /**
4
4
  * BreakpointManager class.
5
5
  */
6
- export default function withBreakpointManager<T extends BaseTypeParameter = BaseTypeParameter>(BaseClass: BaseConstructor, breakpoints: Array<[string, BaseConstructor]>): typeof Base | {
7
- new <U extends BaseTypeParameter = BaseTypeParameter>(element: any): {
8
- /**
9
- * Override the default $mount method to prevent component's from being
10
- * mounted when they should not.
11
- *
12
- * @returns {this}
13
- */
14
- $mount(): any;
15
- /**
16
- * Destroy all instances when the main one is destroyed.
17
- *
18
- * @returns {this}
19
- */
20
- $destroy(): any;
21
- $parent: Base<BaseTypeParameter>;
22
- $id: string;
23
- $el: (T & U)["$el"] & HTMLElement & {
24
- __base__?: WeakMap<typeof Base, Base<BaseTypeParameter> | "terminated">;
25
- };
26
- $isMounted: boolean;
27
- __eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
28
- readonly $root: Base<BaseTypeParameter>;
29
- readonly __config: import("../Base/index.js").BaseConfig;
30
- __services: import("../Base/managers/ServicesManager.js").default;
31
- readonly $services: import("../Base/managers/ServicesManager.js").default;
32
- __refs: import("../Base/managers/RefsManager.js").default & (T & U)["$refs"] & import("../Base/index.js").BaseRefs;
33
- readonly $refs: import("../Base/managers/RefsManager.js").default & (T & U)["$refs"] & import("../Base/index.js").BaseRefs;
34
- __options: import("../Base/managers/OptionsManager.js").default & (T & U)["$options"] & import("../Base/index.js").BaseOptions;
35
- readonly $options: import("../Base/managers/OptionsManager.js").default & (T & U)["$options"] & import("../Base/index.js").BaseOptions;
36
- __children: import("../Base/managers/ChildrenManager.js").default & ((T & U)["$children"] extends infer T_1 ? { [key in keyof T_1]: (T & U)["$children"][key][]; } : never) & import("../Base/index.js").BaseChildren;
37
- readonly $children: import("../Base/managers/ChildrenManager.js").default & ((T & U)["$children"] extends infer T_2 ? { [key_1 in keyof T_2]: (T & U)["$children"][key_1][]; } : never) & import("../Base/index.js").BaseChildren;
38
- __events: import("../Base/managers/EventsManager.js").default;
39
- readonly $log: (...args: any) => void;
40
- readonly __debug: (...args: any) => void;
41
- readonly __managers: import("../Base/index.js").Managers;
42
- __callMethod(method: string, ...args: unknown[]): unknown;
43
- __hasEvent(event: string): boolean;
44
- $update(): any;
45
- $terminate(): void;
46
- __addEmits(event: string): void;
47
- __removeEmits(event: string): void;
48
- readonly __ctor: typeof Base;
49
- $on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
50
- $off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
51
- $emit(event: string, ...args: unknown[]): void;
52
- addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
53
- dispatchEvent(event: Event): boolean;
54
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
55
- };
56
- readonly $isBase: true;
57
- config: import("../Base/index.js").BaseConfig;
58
- $factory(nameOrSelector: string): Base<BaseTypeParameter>[];
59
- };
6
+ export declare function withBreakpointManager<S extends Base>(BaseClass: typeof Base, breakpoints: Array<[string, BaseConstructor<Base>]>): BaseDecorator<BaseInterface, S>;