@studiometa/js-toolkit 2.4.4-alpha.5 → 2.4.4-alpha.8

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 (41) hide show
  1. package/Base/index.d.ts +4 -3
  2. package/Base/types.d.ts +5 -1
  3. package/decorators/index.cjs +9 -32
  4. package/decorators/index.d.ts +9 -10
  5. package/decorators/index.js +9 -22
  6. package/decorators/withBreakpointManager.cjs +6 -12
  7. package/decorators/withBreakpointManager.d.ts +3 -2
  8. package/decorators/withBreakpointManager.js +4 -4
  9. package/decorators/withBreakpointObserver.cjs +5 -11
  10. package/decorators/withBreakpointObserver.d.ts +7 -112
  11. package/decorators/withBreakpointObserver.js +2 -2
  12. package/decorators/withDrag.cjs +5 -11
  13. package/decorators/withDrag.d.ts +8 -93
  14. package/decorators/withDrag.js +4 -4
  15. package/decorators/withExtraConfig.cjs +1 -1
  16. package/decorators/withExtraConfig.d.ts +3 -96
  17. package/decorators/withExtraConfig.js +1 -1
  18. package/decorators/withFreezedOptions.cjs +1 -1
  19. package/decorators/withFreezedOptions.d.ts +6 -105
  20. package/decorators/withFreezedOptions.js +1 -1
  21. package/decorators/withIntersectionObserver.cjs +1 -1
  22. package/decorators/withIntersectionObserver.d.ts +7 -107
  23. package/decorators/withIntersectionObserver.js +1 -1
  24. package/decorators/withMountWhenInView.cjs +1 -1
  25. package/decorators/withMountWhenInView.d.ts +16 -116
  26. package/decorators/withMountWhenInView.js +1 -1
  27. package/decorators/withResponsiveOptions.cjs +1 -1
  28. package/decorators/withResponsiveOptions.d.ts +3 -98
  29. package/decorators/withResponsiveOptions.js +1 -1
  30. package/decorators/withScrolledInView.cjs +20 -18
  31. package/decorators/withScrolledInView.d.ts +28 -306
  32. package/decorators/withScrolledInView.js +20 -12
  33. package/decorators/withVue2.cjs +1 -1
  34. package/decorators/withVue2.d.ts +8 -106
  35. package/decorators/withVue2.js +1 -1
  36. package/helpers/createApp.d.ts +2 -2
  37. package/index.d.ts +2 -2
  38. package/package.json +1 -1
  39. package/decorators/withType.cjs +0 -28
  40. package/decorators/withType.d.ts +0 -5
  41. package/decorators/withType.js +0 -6
@@ -1,101 +1,6 @@
1
- import type { Base, BaseTypeParameter, BaseConstructor, Managers } from '../Base/index.js';
2
- import ResponsiveOptionsManager from '../Base/managers/ResponsiveOptionsManager.js';
1
+ import type { BaseInterface, BaseDecorator } from '../Base/types.js';
2
+ import type { Base } from '../Base/index.js';
3
3
  /**
4
4
  * Extends the configuration of an existing class.
5
5
  */
6
- export default function withResponsiveOptions<S extends BaseConstructor<Base>, T extends BaseTypeParameter = BaseTypeParameter>(BaseClass: S): {
7
- new (...args: any[]): {
8
- /**
9
- * Get managers.
10
- */
11
- readonly __managers: Managers & {
12
- OptionsManager: typeof ResponsiveOptionsManager;
13
- };
14
- $parent: Base<BaseTypeParameter>;
15
- $id: string;
16
- $el: HTMLElement & {
17
- __base__?: WeakMap<BaseConstructor<Base<BaseTypeParameter>>, Base<BaseTypeParameter> | "terminated">;
18
- };
19
- $isMounted: boolean;
20
- __eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
21
- readonly $root: Base<BaseTypeParameter>;
22
- readonly __config: import("../Base/index.js").BaseConfig;
23
- __services: import("../Base/managers/ServicesManager.js").default;
24
- readonly $services: import("../Base/managers/ServicesManager.js").default;
25
- __refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
26
- readonly $refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
27
- __options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
28
- readonly $options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
29
- __children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
30
- readonly $children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
31
- __events: import("../Base/managers/EventsManager.js").default;
32
- readonly $log: (...args: unknown[]) => void;
33
- readonly __debug: (...args: unknown[]) => void;
34
- __callMethod(method: string, ...args: unknown[]): unknown;
35
- __hasEvent(event: string): boolean;
36
- $mount(): any;
37
- $update(): any;
38
- $destroy(): any;
39
- $terminate(): void;
40
- __addEmits(event: string): void;
41
- __removeEmits(event: string): void;
42
- readonly __ctor: BaseConstructor<Base<BaseTypeParameter>>;
43
- $on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
44
- $off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
45
- $emit(event: string, ...args: unknown[]): void;
46
- addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
47
- dispatchEvent(event: Event): boolean;
48
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
49
- };
50
- prototype: Base<BaseTypeParameter>;
51
- } & Pick<typeof Base, "prototype" | "$isBase" | "config" | "$factory"> & Pick<{
52
- new (...args: any[]): {
53
- /**
54
- * Get managers.
55
- */
56
- readonly __managers: Managers & {
57
- OptionsManager: typeof ResponsiveOptionsManager;
58
- };
59
- $parent: Base<BaseTypeParameter>;
60
- $id: string;
61
- $el: HTMLElement & {
62
- __base__?: WeakMap<BaseConstructor<Base<BaseTypeParameter>>, Base<BaseTypeParameter> | "terminated">;
63
- };
64
- $isMounted: boolean;
65
- __eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
66
- readonly $root: Base<BaseTypeParameter>;
67
- readonly __config: import("../Base/index.js").BaseConfig;
68
- __services: import("../Base/managers/ServicesManager.js").default;
69
- readonly $services: import("../Base/managers/ServicesManager.js").default;
70
- __refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
71
- readonly $refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
72
- __options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
73
- readonly $options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
74
- __children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
75
- readonly $children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
76
- __events: import("../Base/managers/EventsManager.js").default;
77
- readonly $log: (...args: unknown[]) => void;
78
- readonly __debug: (...args: unknown[]) => void;
79
- __callMethod(method: string, ...args: unknown[]): unknown;
80
- __hasEvent(event: string): boolean;
81
- $mount(): any;
82
- $update(): any;
83
- $destroy(): any;
84
- $terminate(): void;
85
- __addEmits(event: string): void;
86
- __removeEmits(event: string): void;
87
- readonly __ctor: BaseConstructor<Base<BaseTypeParameter>>;
88
- $on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
89
- $off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
90
- $emit(event: string, ...args: unknown[]): void;
91
- addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
92
- dispatchEvent(event: Event): boolean;
93
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
94
- };
95
- readonly $isBase: true;
96
- config: import("../Base/index.js").BaseConfig;
97
- $factory: typeof Base.$factory;
98
- } & S, "prototype" | "$isBase" | "config" | "$factory" | keyof S> & S & {
99
- new (...args: any[]): Base<T>;
100
- prototype: Base<BaseTypeParameter>;
101
- };
6
+ export declare function withResponsiveOptions<S extends Base>(BaseClass: typeof Base): BaseDecorator<BaseInterface, S>;
@@ -11,5 +11,5 @@ function withResponsiveOptions(BaseClass) {
11
11
  return WithResponsiveOptions;
12
12
  }
13
13
  export {
14
- withResponsiveOptions as default
14
+ withResponsiveOptions
15
15
  };
@@ -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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
6
  var __export = (target, all) => {
@@ -17,10 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
19
  var __publicField = (obj, key, value) => {
26
20
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -33,7 +27,7 @@ __export(withScrolledInView_exports, {
33
27
  withScrolledInView: () => withScrolledInView
34
28
  });
35
29
  module.exports = __toCommonJS(withScrolledInView_exports);
36
- var import_withMountWhenInView = __toESM(require("./withMountWhenInView.cjs"), 1);
30
+ var import_withMountWhenInView = require("./withMountWhenInView.cjs");
37
31
  var import_utils = require("../utils/index.cjs");
38
32
  var scheduler = (0, import_utils.useScheduler)(["update", "render"]);
39
33
  function updateProps(props, dampFactor, dampPrecision, axis = "x") {
@@ -56,8 +50,7 @@ function updateProps(props, dampFactor, dampPrecision, axis = "x") {
56
50
  );
57
51
  }
58
52
  function withScrolledInView(BaseClass, options = {}) {
59
- const WithMountWhenInView = (0, import_withMountWhenInView.default)(BaseClass, options);
60
- class WithScrolledInView extends WithMountWhenInView {
53
+ class WithScrolledInView extends (0, import_withMountWhenInView.withMountWhenInView)(BaseClass, options) {
61
54
  constructor(element) {
62
55
  super(element);
63
56
  __publicField(this, "__props", {
@@ -86,6 +79,8 @@ function withScrolledInView(BaseClass, options = {}) {
86
79
  y: 0
87
80
  }
88
81
  });
82
+ __publicField(this, "dampFactor", null);
83
+ __publicField(this, "dampPrecision", null);
89
84
  const render = () => {
90
85
  scheduler.update(() => {
91
86
  const renderFn = this.__callMethod("scrolledInView", this.__props);
@@ -109,8 +104,11 @@ function withScrolledInView(BaseClass, options = {}) {
109
104
  }
110
105
  },
111
106
  ticked: () => {
112
- updateProps(this.__props, this.dampFactor, this.dampPrecision, "x");
113
- updateProps(this.__props, this.dampFactor, this.dampPrecision, "y");
107
+ var _a, _b;
108
+ const dampFactor = (_a = this.dampFactor) != null ? _a : this.$options.dampFactor;
109
+ const dampPrecision = (_b = this.dampFactor) != null ? _b : this.$options.dampFactor;
110
+ updateProps(this.__props, dampFactor, dampPrecision, "x");
111
+ updateProps(this.__props, dampFactor, dampPrecision, "y");
114
112
  if (this.__props.dampedCurrent.x === this.__props.current.x && this.__props.dampedCurrent.y === this.__props.current.y) {
115
113
  this.$services.disable("ticked");
116
114
  }
@@ -136,12 +134,6 @@ function withScrolledInView(BaseClass, options = {}) {
136
134
  render();
137
135
  });
138
136
  }
139
- get dampFactor() {
140
- return 0.1;
141
- }
142
- get dampPrecision() {
143
- return 1e-3;
144
- }
145
137
  mounted() {
146
138
  if ((0, import_utils.isFunction)(super.mounted)) {
147
139
  super.mounted();
@@ -207,7 +199,17 @@ function withScrolledInView(BaseClass, options = {}) {
207
199
  }
208
200
  __publicField(WithScrolledInView, "config", {
209
201
  name: `${BaseClass.config.name}WithMountWhenInView`,
210
- emits: ["scrolledInView"]
202
+ emits: ["scrolledInView"],
203
+ options: {
204
+ dampFactor: {
205
+ type: Number,
206
+ default: 0.1
207
+ },
208
+ dampPrecision: {
209
+ type: Number,
210
+ default: 1e-3
211
+ }
212
+ }
211
213
  });
212
214
  return WithScrolledInView;
213
215
  }
@@ -1,5 +1,12 @@
1
- import type { Base, BaseTypeParameter, BaseConstructor, BaseConfig } from '../Base/index.js';
1
+ import type { BaseInterface, BaseDecorator } from '../Base/types.js';
2
+ import type { Base, BaseProps } from '../Base/index.js';
2
3
  import type { RafServiceProps, ScrollServiceProps, ResizeServiceProps } from '../services/index.js';
4
+ export interface WithScrolledInViewProps extends BaseProps {
5
+ $options: {
6
+ dampFactor: number;
7
+ dampPrecision: number;
8
+ };
9
+ }
3
10
  export declare type ScrollInViewProps = {
4
11
  start: {
5
12
  x: number;
@@ -26,313 +33,28 @@ export declare type ScrollInViewProps = {
26
33
  y: number;
27
34
  };
28
35
  };
29
- declare type withScrolledInViewOptions = IntersectionObserverInit & {
36
+ export declare type WithScrolledInViewOptions = IntersectionObserverInit & {
30
37
  useOffsetSizes?: boolean;
31
38
  };
39
+ export interface WithScrolledInViewInterface extends BaseInterface {
40
+ /**
41
+ * @private
42
+ * @type {ScrollInViewProps}
43
+ */
44
+ __props: ScrollInViewProps;
45
+ dampFactor?: number;
46
+ dampPrecision?: number;
47
+ mounted(): void;
48
+ resized(props: ResizeServiceProps): void;
49
+ scrolled(props: ScrollServiceProps): void;
50
+ ticked(props: RafServiceProps): void;
51
+ destroyed(): void;
52
+ /**
53
+ * @private
54
+ */
55
+ __setProps(): void;
56
+ }
32
57
  /**
33
58
  * Add scrolled in view capabilities to a component.
34
59
  */
35
- export declare function withScrolledInView<S extends BaseConstructor<Base>, T extends BaseTypeParameter = BaseTypeParameter>(BaseClass: S, options?: withScrolledInViewOptions): {
36
- new (...args: any[]): {
37
- __props: ScrollInViewProps;
38
- /**
39
- * Factor used for the `dampedProgress` props.
40
- */
41
- readonly dampFactor: number;
42
- /**
43
- * Precision for the `dampedProgress` props.
44
- */
45
- readonly dampPrecision: number;
46
- /**
47
- * Mounted hook.
48
- */
49
- mounted(): void;
50
- /**
51
- * Resized hook.
52
- */
53
- resized(props: ResizeServiceProps): void;
54
- /**
55
- * Scrolled hook.
56
- */
57
- scrolled(props: ScrollServiceProps): void;
58
- /**
59
- * Ticked hook.
60
- */
61
- ticked(props: RafServiceProps): void;
62
- /**
63
- * Destroyed hook.
64
- */
65
- destroyed(): void;
66
- /**
67
- * Set the decorator props.
68
- */
69
- __setProps(): void;
70
- __isVisible: boolean;
71
- __observer: IntersectionObserver;
72
- $mount: (() => any) & (() => any);
73
- $parent: Base<BaseTypeParameter>;
74
- $id: string;
75
- $el: HTMLElement & {
76
- __base__?: WeakMap<BaseConstructor<Base<BaseTypeParameter>>, Base<BaseTypeParameter> | "terminated">;
77
- } & (T & {
78
- $options: {
79
- intersectionObserver: IntersectionObserverInit;
80
- };
81
- })["$el"];
82
- $isMounted: boolean;
83
- __eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
84
- readonly $root: Base<BaseTypeParameter>;
85
- readonly __config: BaseConfig;
86
- __services: import("../Base/managers/ServicesManager.js").default;
87
- readonly $services: import("../Base/managers/ServicesManager.js").default;
88
- __refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs & (T & {
89
- $options: {
90
- intersectionObserver: IntersectionObserverInit;
91
- };
92
- })["$refs"];
93
- readonly $refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs & (T & {
94
- $options: {
95
- intersectionObserver: IntersectionObserverInit;
96
- };
97
- })["$refs"];
98
- __options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions & (T & {
99
- $options: {
100
- intersectionObserver: IntersectionObserverInit;
101
- };
102
- })["$options"];
103
- readonly $options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions & (T & {
104
- $options: {
105
- intersectionObserver: IntersectionObserverInit;
106
- };
107
- })["$options"];
108
- __children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren & (T & {
109
- $options: {
110
- intersectionObserver: IntersectionObserverInit;
111
- };
112
- })["$children"];
113
- readonly $children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren & (T & {
114
- $options: {
115
- intersectionObserver: IntersectionObserverInit;
116
- };
117
- })["$children"];
118
- __events: import("../Base/managers/EventsManager.js").default;
119
- readonly $log: (...args: unknown[]) => void;
120
- readonly __debug: (...args: unknown[]) => void;
121
- readonly __managers: import("../Base/index.js").Managers;
122
- __callMethod(method: string, ...args: unknown[]): unknown;
123
- __hasEvent(event: string): boolean;
124
- $update(): any;
125
- $destroy(): any;
126
- $terminate(): void;
127
- __addEmits(event: string): void;
128
- __removeEmits(event: string): void;
129
- readonly __ctor: BaseConstructor<Base<BaseTypeParameter>>;
130
- $on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
131
- $off: ((event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void) & ((event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void);
132
- $emit: ((event: string, ...args: unknown[]) => void) & ((event: string, ...args: unknown[]) => void);
133
- addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
134
- dispatchEvent(event: Event): boolean;
135
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
136
- };
137
- prototype: Base<BaseTypeParameter>;
138
- } & Pick<typeof Base, "prototype" | "$isBase" | "config" | "$factory"> & Pick<{
139
- new (element: HTMLElement): {
140
- __props: ScrollInViewProps;
141
- /**
142
- * Factor used for the `dampedProgress` props.
143
- */
144
- readonly dampFactor: number;
145
- /**
146
- * Precision for the `dampedProgress` props.
147
- */
148
- readonly dampPrecision: number;
149
- /**
150
- * Mounted hook.
151
- */
152
- mounted(): void;
153
- /**
154
- * Resized hook.
155
- */
156
- resized(props: ResizeServiceProps): void;
157
- /**
158
- * Scrolled hook.
159
- */
160
- scrolled(props: ScrollServiceProps): void;
161
- /**
162
- * Ticked hook.
163
- */
164
- ticked(props: RafServiceProps): void;
165
- /**
166
- * Destroyed hook.
167
- */
168
- destroyed(): void;
169
- /**
170
- * Set the decorator props.
171
- */
172
- __setProps(): void;
173
- __isVisible: boolean;
174
- __observer: IntersectionObserver;
175
- $mount: (() => any) & (() => any);
176
- $parent: Base<BaseTypeParameter>;
177
- $id: string;
178
- $el: HTMLElement & {
179
- __base__?: WeakMap<BaseConstructor<Base<BaseTypeParameter>>, Base<BaseTypeParameter> | "terminated">;
180
- } & (T & {
181
- $options: {
182
- intersectionObserver: IntersectionObserverInit;
183
- };
184
- })["$el"];
185
- $isMounted: boolean;
186
- __eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
187
- readonly $root: Base<BaseTypeParameter>;
188
- readonly __config: BaseConfig;
189
- __services: import("../Base/managers/ServicesManager.js").default;
190
- readonly $services: import("../Base/managers/ServicesManager.js").default;
191
- __refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs & (T & {
192
- $options: {
193
- intersectionObserver: IntersectionObserverInit;
194
- };
195
- })["$refs"];
196
- readonly $refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs & (T & {
197
- $options: {
198
- intersectionObserver: IntersectionObserverInit;
199
- };
200
- })["$refs"];
201
- __options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions & (T & {
202
- $options: {
203
- intersectionObserver: IntersectionObserverInit;
204
- };
205
- })["$options"];
206
- readonly $options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions & (T & {
207
- $options: {
208
- intersectionObserver: IntersectionObserverInit;
209
- };
210
- })["$options"];
211
- __children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren & (T & {
212
- $options: {
213
- intersectionObserver: IntersectionObserverInit;
214
- };
215
- })["$children"];
216
- readonly $children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren & (T & {
217
- $options: {
218
- intersectionObserver: IntersectionObserverInit;
219
- };
220
- })["$children"];
221
- __events: import("../Base/managers/EventsManager.js").default;
222
- readonly $log: (...args: unknown[]) => void;
223
- readonly __debug: (...args: unknown[]) => void;
224
- readonly __managers: import("../Base/index.js").Managers;
225
- __callMethod(method: string, ...args: unknown[]): unknown;
226
- __hasEvent(event: string): boolean;
227
- $update(): any;
228
- $destroy(): any;
229
- $terminate(): void;
230
- __addEmits(event: string): void;
231
- __removeEmits(event: string): void;
232
- readonly __ctor: BaseConstructor<Base<BaseTypeParameter>>;
233
- $on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
234
- $off: ((event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void) & ((event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void);
235
- $emit: ((event: string, ...args: unknown[]) => void) & ((event: string, ...args: unknown[]) => void);
236
- addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
237
- dispatchEvent(event: Event): boolean;
238
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
239
- };
240
- /**
241
- * Config.
242
- */
243
- config: BaseConfig;
244
- readonly $isBase: true & ({
245
- new (element: HTMLElement): {
246
- __isVisible: boolean;
247
- __observer: IntersectionObserver;
248
- $mount(): any;
249
- $parent: Base<BaseTypeParameter>;
250
- $id: string;
251
- $el: HTMLElement & {
252
- __base__?: WeakMap<BaseConstructor<Base<BaseTypeParameter>>, Base<BaseTypeParameter> | "terminated">;
253
- };
254
- $isMounted: boolean;
255
- __eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
256
- readonly $root: Base<BaseTypeParameter>;
257
- readonly __config: BaseConfig;
258
- __services: import("../Base/managers/ServicesManager.js").default;
259
- readonly $services: import("../Base/managers/ServicesManager.js").default;
260
- __refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
261
- readonly $refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
262
- __options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
263
- readonly $options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
264
- __children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
265
- readonly $children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
266
- __events: import("../Base/managers/EventsManager.js").default;
267
- readonly $log: (...args: unknown[]) => void;
268
- readonly __debug: (...args: unknown[]) => void;
269
- readonly __managers: import("../Base/index.js").Managers;
270
- __callMethod(method: string, ...args: unknown[]): unknown;
271
- __hasEvent(event: string): boolean;
272
- $update(): any;
273
- $destroy(): any;
274
- $terminate(): void;
275
- __addEmits(event: string): void;
276
- __removeEmits(event: string): void;
277
- readonly __ctor: BaseConstructor<Base<BaseTypeParameter>>;
278
- $on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
279
- $off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
280
- $emit(event: string, ...args: unknown[]): void;
281
- addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
282
- dispatchEvent(event: Event): boolean;
283
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
284
- };
285
- config: BaseConfig;
286
- readonly $isBase: true;
287
- $factory: typeof Base.$factory;
288
- } & S)["$isBase"];
289
- $factory: typeof Base.$factory & ({
290
- new (element: HTMLElement): {
291
- __isVisible: boolean;
292
- __observer: IntersectionObserver;
293
- $mount(): any;
294
- $parent: Base<BaseTypeParameter>;
295
- $id: string;
296
- $el: HTMLElement & {
297
- __base__?: WeakMap<BaseConstructor<Base<BaseTypeParameter>>, Base<BaseTypeParameter> | "terminated">;
298
- };
299
- $isMounted: boolean;
300
- __eventHandlers: Map<string, Set<EventListenerOrEventListenerObject>>;
301
- readonly $root: Base<BaseTypeParameter>;
302
- readonly __config: BaseConfig;
303
- __services: import("../Base/managers/ServicesManager.js").default;
304
- readonly $services: import("../Base/managers/ServicesManager.js").default;
305
- __refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
306
- readonly $refs: import("../Base/managers/RefsManager.js").default & import("../Base/index.js").BaseRefs;
307
- __options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
308
- readonly $options: import("../Base/managers/OptionsManager.js").default & import("../Base/index.js").BaseOptions;
309
- __children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
310
- readonly $children: import("../Base/managers/ChildrenManager.js").default & import("../Base/index.js").BaseChildren;
311
- __events: import("../Base/managers/EventsManager.js").default;
312
- readonly $log: (...args: unknown[]) => void;
313
- readonly __debug: (...args: unknown[]) => void;
314
- readonly __managers: import("../Base/index.js").Managers;
315
- __callMethod(method: string, ...args: unknown[]): unknown;
316
- __hasEvent(event: string): boolean;
317
- $update(): any;
318
- $destroy(): any;
319
- $terminate(): void;
320
- __addEmits(event: string): void;
321
- __removeEmits(event: string): void;
322
- readonly __ctor: BaseConstructor<Base<BaseTypeParameter>>;
323
- $on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
324
- $off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
325
- $emit(event: string, ...args: unknown[]): void;
326
- addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
327
- dispatchEvent(event: Event): boolean;
328
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
329
- };
330
- config: BaseConfig;
331
- readonly $isBase: true;
332
- $factory: typeof Base.$factory;
333
- } & S)["$factory"];
334
- } & S, "prototype" | "$isBase" | "config" | "$factory" | keyof S> & S & {
335
- new (...args: any[]): Base<T>;
336
- prototype: Base<BaseTypeParameter>;
337
- };
338
- export {};
60
+ export declare function withScrolledInView<S extends Base = Base>(BaseClass: typeof Base, options?: WithScrolledInViewOptions): BaseDecorator<WithScrolledInViewInterface, S>;
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import withMountWhenInView from "./withMountWhenInView.js";
7
+ import { withMountWhenInView } from "./withMountWhenInView.js";
8
8
  import { damp, clamp, clamp01, getOffsetSizes, isFunction, useScheduler } from "../utils/index.js";
9
9
  const scheduler = useScheduler(["update", "render"]);
10
10
  function updateProps(props, dampFactor, dampPrecision, axis = "x") {
@@ -27,8 +27,7 @@ function updateProps(props, dampFactor, dampPrecision, axis = "x") {
27
27
  );
28
28
  }
29
29
  function withScrolledInView(BaseClass, options = {}) {
30
- const WithMountWhenInView = withMountWhenInView(BaseClass, options);
31
- class WithScrolledInView extends WithMountWhenInView {
30
+ class WithScrolledInView extends withMountWhenInView(BaseClass, options) {
32
31
  constructor(element) {
33
32
  super(element);
34
33
  __publicField(this, "__props", {
@@ -57,6 +56,8 @@ function withScrolledInView(BaseClass, options = {}) {
57
56
  y: 0
58
57
  }
59
58
  });
59
+ __publicField(this, "dampFactor", null);
60
+ __publicField(this, "dampPrecision", null);
60
61
  const render = () => {
61
62
  scheduler.update(() => {
62
63
  const renderFn = this.__callMethod("scrolledInView", this.__props);
@@ -80,8 +81,11 @@ function withScrolledInView(BaseClass, options = {}) {
80
81
  }
81
82
  },
82
83
  ticked: () => {
83
- updateProps(this.__props, this.dampFactor, this.dampPrecision, "x");
84
- updateProps(this.__props, this.dampFactor, this.dampPrecision, "y");
84
+ var _a, _b;
85
+ const dampFactor = (_a = this.dampFactor) != null ? _a : this.$options.dampFactor;
86
+ const dampPrecision = (_b = this.dampFactor) != null ? _b : this.$options.dampFactor;
87
+ updateProps(this.__props, dampFactor, dampPrecision, "x");
88
+ updateProps(this.__props, dampFactor, dampPrecision, "y");
85
89
  if (this.__props.dampedCurrent.x === this.__props.current.x && this.__props.dampedCurrent.y === this.__props.current.y) {
86
90
  this.$services.disable("ticked");
87
91
  }
@@ -107,12 +111,6 @@ function withScrolledInView(BaseClass, options = {}) {
107
111
  render();
108
112
  });
109
113
  }
110
- get dampFactor() {
111
- return 0.1;
112
- }
113
- get dampPrecision() {
114
- return 1e-3;
115
- }
116
114
  mounted() {
117
115
  if (isFunction(super.mounted)) {
118
116
  super.mounted();
@@ -178,7 +176,17 @@ function withScrolledInView(BaseClass, options = {}) {
178
176
  }
179
177
  __publicField(WithScrolledInView, "config", {
180
178
  name: `${BaseClass.config.name}WithMountWhenInView`,
181
- emits: ["scrolledInView"]
179
+ emits: ["scrolledInView"],
180
+ options: {
181
+ dampFactor: {
182
+ type: Number,
183
+ default: 0.1
184
+ },
185
+ dampPrecision: {
186
+ type: Number,
187
+ default: 1e-3
188
+ }
189
+ }
182
190
  });
183
191
  return WithScrolledInView;
184
192
  }
@@ -24,7 +24,7 @@ var __publicField = (obj, key, value) => {
24
24
  // packages/js-toolkit/decorators/withVue2.ts
25
25
  var withVue2_exports = {};
26
26
  __export(withVue2_exports, {
27
- default: () => withVue2
27
+ withVue2: () => withVue2
28
28
  });
29
29
  module.exports = __toCommonJS(withVue2_exports);
30
30
  var import_utils = require("../utils/index.cjs");