@studiometa/js-toolkit 2.0.1 → 2.2.0-alpha.1

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 (66) hide show
  1. package/Base/index.cjs +55 -18
  2. package/Base/index.d.ts +23 -1
  3. package/Base/index.js +55 -18
  4. package/Base/managers/AbstractManager.cjs +56 -0
  5. package/Base/managers/AbstractManager.d.ts +44 -0
  6. package/Base/managers/AbstractManager.js +35 -0
  7. package/Base/managers/ChildrenManager.cjs +79 -100
  8. package/Base/managers/ChildrenManager.d.ts +7 -82
  9. package/Base/managers/ChildrenManager.js +76 -100
  10. package/Base/managers/EventsManager.cjs +75 -99
  11. package/Base/managers/EventsManager.d.ts +31 -100
  12. package/Base/managers/EventsManager.js +75 -99
  13. package/Base/managers/OptionsManager.cjs +65 -78
  14. package/Base/managers/OptionsManager.d.ts +37 -79
  15. package/Base/managers/OptionsManager.js +66 -79
  16. package/Base/managers/RefsManager.cjs +44 -68
  17. package/Base/managers/RefsManager.d.ts +10 -64
  18. package/Base/managers/RefsManager.js +41 -69
  19. package/Base/managers/ResponsiveOptionsManager.cjs +62 -0
  20. package/Base/managers/ResponsiveOptionsManager.d.ts +26 -0
  21. package/Base/managers/ResponsiveOptionsManager.js +37 -0
  22. package/Base/managers/ServicesManager.cjs +5 -11
  23. package/Base/managers/ServicesManager.d.ts +2 -11
  24. package/Base/managers/ServicesManager.js +5 -11
  25. package/decorators/index.cjs +2 -0
  26. package/decorators/index.d.ts +1 -0
  27. package/decorators/index.js +6 -4
  28. package/decorators/withResponsiveOptions.cjs +39 -0
  29. package/decorators/withResponsiveOptions.d.ts +8 -0
  30. package/decorators/withResponsiveOptions.js +14 -0
  31. package/decorators/withScrolledInView.cjs +66 -23
  32. package/decorators/withScrolledInView.d.ts +4 -2
  33. package/decorators/withScrolledInView.js +67 -24
  34. package/package.json +2 -1
  35. package/services/Service.cjs +2 -2
  36. package/services/Service.d.ts +9 -1
  37. package/services/Service.js +2 -2
  38. package/services/raf.cjs +16 -0
  39. package/services/raf.js +16 -0
  40. package/utils/css/animate.cjs +207 -0
  41. package/utils/css/animate.d.ts +57 -0
  42. package/utils/css/animate.js +182 -0
  43. package/utils/css/getOffsetSizes.cjs +47 -0
  44. package/utils/css/getOffsetSizes.d.ts +15 -0
  45. package/utils/css/getOffsetSizes.js +25 -0
  46. package/utils/css/index.cjs +6 -0
  47. package/utils/css/index.d.ts +3 -0
  48. package/utils/css/index.js +9 -4
  49. package/utils/css/transform.cjs +91 -0
  50. package/utils/css/transform.d.ts +43 -0
  51. package/utils/css/transform.js +66 -0
  52. package/utils/index.cjs +5 -0
  53. package/utils/index.d.ts +3 -0
  54. package/utils/index.js +5 -0
  55. package/utils/isDefined.cjs +28 -0
  56. package/utils/isDefined.d.ts +7 -0
  57. package/utils/isDefined.js +6 -0
  58. package/utils/isFunction.cjs +28 -0
  59. package/utils/isFunction.d.ts +7 -0
  60. package/utils/isFunction.js +6 -0
  61. package/utils/math/index.cjs +2 -0
  62. package/utils/math/index.d.ts +1 -0
  63. package/utils/math/index.js +2 -0
  64. package/utils/scheduler.cjs +73 -0
  65. package/utils/scheduler.d.ts +19 -0
  66. package/utils/scheduler.js +51 -0
@@ -2,62 +2,44 @@
2
2
  * @typedef {import('../index.js').default} Base
3
3
  * @typedef {import('./ChildrenManager.js').default} ChildrenManager
4
4
  */
5
+ /**
6
+ * Normalize the given name to PascalCase, such as:
7
+ *
8
+ * ```
9
+ * sentence case => SentenceCase
10
+ * lowercase => Lowercase
11
+ * UPPERCASE => Uppercase
12
+ * kebab-case => KebabCase
13
+ * snake_case => SnakeCase
14
+ * camelCase => CamelCase
15
+ * PascalCase => PascalCase
16
+ * .class-selector => ClassSelector
17
+ * .bem__selector => BemSelector
18
+ * __id-selector => IdSelector
19
+ * .complex[class^ ="__"] => ComplexClass
20
+ * ```
21
+ *
22
+ * @param {string} name
23
+ * @returns {string}
24
+ */
25
+ export function normalizeName(name: string): string;
26
+ /**
27
+ * Normalize the event names from PascalCase to kebab-case.
28
+ *
29
+ * @param {string} name
30
+ * @returns {string}
31
+ */
32
+ export function normalizeEventName(name: string): string;
5
33
  /**
6
34
  * Event management class.
7
35
  * @todo Prevent binding of `onChildOrRefEvent` to the root element
8
36
  * @todo Use event delegation?
9
37
  */
10
- export default class EventsManager {
11
- /**
12
- * Normalize the given name to PascalCase, such as:
13
- *
14
- * ```
15
- * sentence case => SentenceCase
16
- * lowercase => Lowercase
17
- * UPPERCASE => Uppercase
18
- * kebab-case => KebabCase
19
- * snake_case => SnakeCase
20
- * camelCase => CamelCase
21
- * PascalCase => PascalCase
22
- * .class-selector => ClassSelector
23
- * .bem__selector => BemSelector
24
- * __id-selector => IdSelector
25
- * .complex[class^ ="__"] => ComplexClass
26
- * ```
27
- *
28
- * @param {string} name
29
- * @returns {string}
30
- */
31
- static normalizeName(name: string): string;
32
- /**
33
- * Normalize the event names from PascalCase to kebab-case.
34
- *
35
- * @param {string} name
36
- * @returns {string}
37
- */
38
- static normalizeEventName(name: string): string;
39
- /**
40
- * Class constructor.
41
- *
42
- * @param {HTMLElement} rootElement
43
- * @param {Base} base
44
- */
45
- constructor(rootElement: HTMLElement, base: Base);
46
- /**
47
- * @type {HTMLElement}
48
- * @private
49
- */
50
- private __rootElement;
51
- /**
52
- * @type {Base}
53
- * @private
54
- */
55
- private __base;
38
+ export default class EventsManager extends AbstractManager {
56
39
  /**
57
40
  * @type {WeakMap}
58
- * @private
59
41
  */
60
- private __methodsCache;
42
+ __methodsCache: WeakMap<any, any>;
61
43
  /**
62
44
  * Event listener object for the root element.
63
45
  *
@@ -76,19 +58,6 @@ export default class EventsManager {
76
58
  * @type {EventListenerObject}
77
59
  */
78
60
  __childrenHandler: EventListenerObject;
79
- /**
80
- * Manage a ref event methods.
81
- *
82
- * @param {string} name
83
- * The name of the ref.
84
- * @param {HTMLElement[]} elements
85
- * The elements of the ref.
86
- * @param {'add'|'remove'} [mode]
87
- * The action to perform: add or remove the event listeners.
88
- * @returns {void}
89
- * @private
90
- */
91
- private __manageRef;
92
61
  /**
93
62
  * Bind event methods to the given ref elements.
94
63
  *
@@ -109,19 +78,6 @@ export default class EventsManager {
109
78
  * @returns {void}
110
79
  */
111
80
  unbindRef(name: string, elements: HTMLElement[]): void;
112
- /**
113
- * Manage event methods to the given child instance.
114
- *
115
- * @param {string} name
116
- * The name of the ref.
117
- * @param {Base} instance
118
- * A base instance.
119
- * @param {'add'|'remove'} [mode]
120
- * The action to perform: add or remove the event listeners.
121
- * @returns {void}
122
- * @private
123
- */
124
- private __manageChild;
125
81
  /**
126
82
  * Bind event methods to the given child instance.
127
83
  *
@@ -142,15 +98,6 @@ export default class EventsManager {
142
98
  * @returns {void}
143
99
  */
144
100
  unbindChild(name: string, instance: Base): void;
145
- /**
146
- * Manage event methods on the root element.
147
- *
148
- * @param {'add'|'remove'} [mode]
149
- * The action to perform: add or remove the event listeners, defaults to 'add'.
150
- * @returns {void}
151
- * @private
152
- */
153
- private __manageRootElement;
154
101
  /**
155
102
  * Bind event methods on the root element.
156
103
  *
@@ -163,23 +110,7 @@ export default class EventsManager {
163
110
  * @returns {void}
164
111
  */
165
112
  unbindRootElement(): void;
166
- /**
167
- * Get the event name from the given method and its tied ref or children name.
168
- *
169
- * @param {string} method
170
- * @param {string} name
171
- * @returns {string}
172
- * @private
173
- */
174
- private __getEventNameByMethod;
175
- /**
176
- * Get the base instance methods matching the `onSomething` pattern.
177
- *
178
- * @param {string} [name]
179
- * @returns {string[]}
180
- * @private
181
- */
182
- private __getEventMethodsByName;
183
113
  }
184
114
  export type Base = import('../index.js').default;
185
115
  export type ChildrenManager = import('./ChildrenManager.js').default;
116
+ import AbstractManager from "./AbstractManager.js";
@@ -5,15 +5,64 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import getAllProperties from "../../utils/object/getAllProperties.js";
8
- import RefsManager from "./RefsManager.js";
9
- class EventsManager {
10
- constructor(rootElement, base) {
11
- __publicField(this, "__rootElement");
12
- __publicField(this, "__base");
8
+ import AbstractManager from "./AbstractManager.js";
9
+ import { normalizeRefName } from "./RefsManager.js";
10
+ function normalizeName(name) {
11
+ return name.replace(/[A-Z]([A-Z].*)/g, (c) => c.toLowerCase()).replace(/[^a-zA-Z\d\s:]/g, " ").replace(/(^\w|\s+\w)/g, (c) => c.trim().toUpperCase()).trim();
12
+ }
13
+ function normalizeEventName(name) {
14
+ return name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/^-/, "");
15
+ }
16
+ function __getEventNameByMethod(that, method, name = "") {
17
+ const normalizedName = normalizeName(name);
18
+ const regex = new RegExp(`^on${normalizedName}([A-Z].*)$`);
19
+ const [, event] = method.match(regex);
20
+ return normalizeEventName(event);
21
+ }
22
+ function __getEventMethodsByName(that, name = "") {
23
+ const normalizedName = normalizeName(name);
24
+ const regex = new RegExp(`^on${normalizedName}[A-Z].*$`);
25
+ const key = regex.toString();
26
+ let methods = that.__methodsCache.get(key);
27
+ if (!methods) {
28
+ methods = Array.from(getAllProperties(that.__base, [], (method) => regex.test(method)).reduce((set, [method]) => set.add(method), /* @__PURE__ */ new Set()));
29
+ that.__methodsCache.set(key, methods);
30
+ }
31
+ return methods;
32
+ }
33
+ function __manageRef(that, name, elements, mode = "add") {
34
+ const action = `${mode}EventListener`;
35
+ const methods = __getEventMethodsByName(that, name);
36
+ methods.forEach((method) => {
37
+ const event = __getEventNameByMethod(that, method, name);
38
+ elements.forEach((element) => element[action](event, that.__refsHandler));
39
+ });
40
+ }
41
+ function __manageChild(that, name, instance, mode = "add") {
42
+ const action = mode === "add" ? "$on" : "$off";
43
+ const methods = __getEventMethodsByName(that, name);
44
+ methods.forEach((method) => {
45
+ const event = __getEventNameByMethod(that, method, name);
46
+ instance[action](event, that.__childrenHandler);
47
+ });
48
+ }
49
+ function __manageRootElement(that, mode = "add") {
50
+ const modeMethod = `${mode}EventListener`;
51
+ const methods = __getEventMethodsByName(that);
52
+ const { emits = [] } = that.__base.__config;
53
+ methods.forEach((method) => {
54
+ const event = __getEventNameByMethod(that, method);
55
+ const target = emits.includes(event) ? that.__base : that.__element;
56
+ target[modeMethod](event, that.__rootElementHandler);
57
+ });
58
+ }
59
+ class EventsManager extends AbstractManager {
60
+ constructor(base) {
61
+ super(base);
13
62
  __publicField(this, "__methodsCache", /* @__PURE__ */ new Map());
14
63
  __publicField(this, "__rootElementHandler", {
15
64
  handleEvent: (event) => {
16
- const normalizedEventName = EventsManager.normalizeName(event.type);
65
+ const normalizedEventName = normalizeName(event.type);
17
66
  const method = `on${normalizedEventName}`;
18
67
  this.__base[method](event);
19
68
  }
@@ -21,9 +70,9 @@ class EventsManager {
21
70
  __publicField(this, "__refsHandler", {
22
71
  handleEvent: (event) => {
23
72
  const ref = event.currentTarget;
24
- const refName = RefsManager.normalizeRefName(ref.dataset.ref);
25
- const normalizedRefName = EventsManager.normalizeName(refName);
26
- const normalizedEventName = EventsManager.normalizeName(event.type);
73
+ const refName = normalizeRefName(ref.dataset.ref);
74
+ const normalizedRefName = normalizeName(refName);
75
+ const normalizedEventName = normalizeName(event.type);
27
76
  const method = `on${normalizedRefName}${normalizedEventName}`;
28
77
  let index = 0;
29
78
  if (Array.isArray(this.__base.$refs[refName])) {
@@ -46,114 +95,41 @@ class EventsManager {
46
95
  }
47
96
  return false;
48
97
  });
49
- const normalizedRefName = EventsManager.normalizeName(childName);
50
- const normalizedEventName = EventsManager.normalizeName(event.type);
98
+ const normalizedRefName = normalizeName(childName);
99
+ const normalizedEventName = normalizeName(event.type);
51
100
  const method = `on${normalizedRefName}${normalizedEventName}`;
52
101
  const args = Array.isArray(event.detail) ? event.detail : [];
53
102
  this.__base[method](...args, index, event);
54
103
  }
55
104
  });
56
- Object.defineProperties(this, {
57
- __rootElement: {
58
- enumerable: false,
59
- writable: false,
60
- value: rootElement
61
- },
62
- __base: {
63
- enumerable: false,
64
- writable: false,
65
- value: base
66
- },
67
- __methodsCache: {
68
- enumerable: false,
69
- writable: false,
70
- value: this.__methodsCache
71
- },
72
- __rootElementHandler: {
73
- enumerable: false,
74
- writable: false,
75
- value: this.__rootElementHandler
76
- },
77
- __refsHandler: {
78
- enumerable: false,
79
- writable: false,
80
- value: this.__refsHandler
81
- },
82
- __childrenHandler: {
83
- enumerable: false,
84
- writable: false,
85
- value: this.__childrenHandler
86
- }
87
- });
88
- }
89
- __manageRef(name, elements, mode = "add") {
90
- const action = `${mode}EventListener`;
91
- const methods = this.__getEventMethodsByName(name);
92
- methods.forEach((method) => {
93
- const event = this.__getEventNameByMethod(method, name);
94
- elements.forEach((element) => element[action](event, this.__refsHandler));
95
- });
105
+ this.__hideProperties([
106
+ "__methodsCache",
107
+ "__rootElementHandler",
108
+ "__refsHandler",
109
+ "__childrenHandler"
110
+ ]);
96
111
  }
97
112
  bindRef(name, elements) {
98
- this.__manageRef(name, elements);
113
+ __manageRef(this, name, elements);
99
114
  }
100
115
  unbindRef(name, elements) {
101
- this.__manageRef(name, elements, "remove");
102
- }
103
- __manageChild(name, instance, mode = "add") {
104
- const action = mode === "add" ? "$on" : "$off";
105
- const methods = this.__getEventMethodsByName(name);
106
- methods.forEach((method) => {
107
- const event = this.__getEventNameByMethod(method, name);
108
- instance[action](event, this.__childrenHandler);
109
- });
116
+ __manageRef(this, name, elements, "remove");
110
117
  }
111
118
  bindChild(name, instance) {
112
- this.__manageChild(name, instance);
119
+ __manageChild(this, name, instance);
113
120
  }
114
121
  unbindChild(name, instance) {
115
- this.__manageChild(name, instance, "remove");
116
- }
117
- __manageRootElement(mode = "add") {
118
- const modeMethod = `${mode}EventListener`;
119
- const methods = this.__getEventMethodsByName();
120
- const { emits = [] } = this.__base.__config;
121
- methods.forEach((method) => {
122
- const event = this.__getEventNameByMethod(method);
123
- const target = emits.includes(event) ? this.__base : this.__rootElement;
124
- target[modeMethod](event, this.__rootElementHandler);
125
- });
122
+ __manageChild(this, name, instance, "remove");
126
123
  }
127
124
  bindRootElement() {
128
- this.__manageRootElement();
125
+ __manageRootElement(this);
129
126
  }
130
127
  unbindRootElement() {
131
- this.__manageRootElement("remove");
132
- }
133
- __getEventNameByMethod(method, name = "") {
134
- const normalizedName = EventsManager.normalizeName(name);
135
- const regex = new RegExp(`^on${normalizedName}([A-Z].*)$`);
136
- const [, event] = method.match(regex);
137
- return EventsManager.normalizeEventName(event);
138
- }
139
- __getEventMethodsByName(name = "") {
140
- const normalizedName = EventsManager.normalizeName(name);
141
- const regex = new RegExp(`^on${normalizedName}[A-Z].*$`);
142
- const key = regex.toString();
143
- let methods = this.__methodsCache.get(key);
144
- if (!methods) {
145
- methods = Array.from(getAllProperties(this.__base, [], (method) => regex.test(method)).reduce((set, [method]) => set.add(method), /* @__PURE__ */ new Set()));
146
- this.__methodsCache.set(key, methods);
147
- }
148
- return methods;
149
- }
150
- static normalizeName(name) {
151
- return name.replace(/[A-Z]([A-Z].*)/g, (c) => c.toLowerCase()).replace(/[^a-zA-Z\d\s:]/g, " ").replace(/(^\w|\s+\w)/g, (c) => c.trim().toUpperCase()).trim();
152
- }
153
- static normalizeEventName(name) {
154
- return name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/^-/, "");
128
+ __manageRootElement(this, "remove");
155
129
  }
156
130
  }
157
131
  export {
158
- EventsManager as default
132
+ EventsManager as default,
133
+ normalizeEventName,
134
+ normalizeName
159
135
  };
@@ -27,84 +27,84 @@ var __publicField = (obj, key, value) => {
27
27
  // packages/js-toolkit/Base/managers/OptionsManager.js
28
28
  var OptionsManager_exports = {};
29
29
  __export(OptionsManager_exports, {
30
+ __getPropertyName: () => __getPropertyName,
30
31
  default: () => OptionsManager
31
32
  });
32
33
  module.exports = __toCommonJS(OptionsManager_exports);
33
34
  var import_deepmerge = __toESM(require("deepmerge"), 1);
35
+ var import_AbstractManager = __toESM(require("./AbstractManager.cjs"), 1);
34
36
  var import_isObject = __toESM(require("../../utils/object/isObject.cjs"), 1);
35
- var _OptionsManager = class {
36
- constructor(element, schema, baseConfig) {
37
- __publicField(this, "__element");
37
+ var types = /* @__PURE__ */ new Set([String, Number, Boolean, Array, Object]);
38
+ var __defaultValues = {
39
+ String: "",
40
+ Number: 0,
41
+ Boolean: false,
42
+ Array: () => [],
43
+ Object: () => ({})
44
+ };
45
+ function __hasProperty(that, prop) {
46
+ return typeof that.__element.dataset[prop] !== "undefined";
47
+ }
48
+ var __propertyNameCache = /* @__PURE__ */ new Map();
49
+ function __getPropertyName(name, prefix = "") {
50
+ const key = name + prefix;
51
+ if (__propertyNameCache.has(key)) {
52
+ return __propertyNameCache.get(key);
53
+ }
54
+ const propertyName = `option${prefix}${name.replace(/^\w/, (c) => c.toUpperCase())}`;
55
+ __propertyNameCache.set(key, propertyName);
56
+ return propertyName;
57
+ }
58
+ function __register(that, name, config) {
59
+ var _a;
60
+ if (!types.has(config.type)) {
61
+ throw new Error(`The "${name}" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.`);
62
+ }
63
+ config.default = (_a = config.default) != null ? _a : __defaultValues[config.type.name];
64
+ if ((config.type === Array || config.type === Object) && typeof config.default !== "function") {
65
+ throw new Error(`The default value for options of type "${config.type.name}" must be returned by a function.`);
66
+ }
67
+ Object.defineProperty(that, name, {
68
+ get: () => {
69
+ return that.get(name, config);
70
+ },
71
+ set: (value) => {
72
+ that.set(name, value, config);
73
+ },
74
+ enumerable: true
75
+ });
76
+ }
77
+ var OptionsManager = class extends import_AbstractManager.default {
78
+ constructor(base) {
79
+ super(base);
38
80
  __publicField(this, "__values", {});
39
- __publicField(this, "__defaultValues", {
40
- String: "",
41
- Number: 0,
42
- Boolean: false,
43
- Array: () => [],
44
- Object: () => ({})
45
- });
46
81
  __publicField(this, "name", "Base");
47
82
  __publicField(this, "debug", false);
48
83
  __publicField(this, "log", false);
49
84
  var _a, _b;
50
- Object.defineProperties(this, {
51
- __element: {
52
- enumerable: false,
53
- writable: false,
54
- value: element
55
- },
56
- __values: {
57
- enumerable: false,
58
- writable: false,
59
- value: this.__values
60
- },
61
- __defaultValues: {
62
- enumerable: false,
63
- writable: false,
64
- value: this.__defaultValues
65
- }
66
- });
67
- this.name = baseConfig.name;
85
+ this.__hideProperties(["__values", "__defaultValues"]);
86
+ const schema = this.__config.options || {};
87
+ this.name = this.__config.name;
68
88
  schema.debug = {
69
89
  type: Boolean,
70
- default: (_a = baseConfig.debug) != null ? _a : false
90
+ default: (_a = this.__config.debug) != null ? _a : false
71
91
  };
72
92
  schema.log = {
73
93
  type: Boolean,
74
- default: (_b = baseConfig.log) != null ? _b : false
94
+ default: (_b = this.__config.log) != null ? _b : false
75
95
  };
76
96
  Object.entries(schema).forEach(([name, config]) => {
77
- this.__register(name, config);
97
+ __register(this, name, types.has(config) ? { type: config } : config);
78
98
  });
79
99
  }
80
- __register(name, config) {
81
- const isObjectConfig = typeof config === "object";
82
- const hasDefaultValue = !_OptionsManager.types.includes(config);
83
- const type = isObjectConfig ? config.type : config;
84
- if (!_OptionsManager.types.includes(type)) {
85
- throw new Error(`The "${name}" option has an invalid type. The allowed types are: String, Number, Boolean, Array and Object.`);
86
- }
87
- const defaultValue = hasDefaultValue ? config.default : this.__defaultValues[type.name];
88
- if ((type === Array || type === Object) && typeof defaultValue !== "function") {
89
- throw new Error(`The default value for options of type "${type.name}" must be returned by a function.`);
90
- }
91
- Object.defineProperty(this, name, {
92
- get: () => {
93
- return this.get(name, type, defaultValue, isObjectConfig ? config.merge : void 0);
94
- },
95
- set: (value) => {
96
- this.set(name, type, value, defaultValue);
97
- },
98
- enumerable: true
99
- });
100
- }
101
- get(name, type, defaultValue, merge) {
102
- const propertyName = _OptionsManager.__getPropertyName(name);
103
- const hasProperty = this.__hasProperty(propertyName);
100
+ get(name, config) {
101
+ const { type, default: defaultValue } = config;
102
+ const propertyName = __getPropertyName(name);
103
+ const hasProperty = __hasProperty(this, propertyName);
104
104
  if (type === Boolean) {
105
105
  if (defaultValue) {
106
- const negatedPropertyName = _OptionsManager.__getPropertyName(name, "No");
107
- const hasNegatedProperty = this.__hasProperty(negatedPropertyName);
106
+ const negatedPropertyName = __getPropertyName(name, "No");
107
+ const hasNegatedProperty = __hasProperty(this, negatedPropertyName);
108
108
  return !hasNegatedProperty;
109
109
  }
110
110
  return hasProperty || defaultValue;
@@ -114,10 +114,11 @@ var _OptionsManager = class {
114
114
  return hasProperty ? Number(value) : defaultValue;
115
115
  }
116
116
  if (type === Array || type === Object) {
117
+ config = type === Array ? config : config;
117
118
  if (!this.__values[name]) {
118
- let val = hasProperty ? JSON.parse(value) : defaultValue();
119
- if (typeof merge !== "undefined") {
120
- val = typeof merge === "boolean" ? (0, import_deepmerge.default)(defaultValue(), val) : (0, import_deepmerge.default)(defaultValue(), val, merge);
119
+ let val = hasProperty ? JSON.parse(value) : config.default();
120
+ if (typeof config.merge !== "undefined") {
121
+ val = typeof config.merge === "boolean" ? (0, import_deepmerge.default)(config.default(), val) : (0, import_deepmerge.default)(config.default(), val, config.merge);
121
122
  }
122
123
  this.__values[name] = val;
123
124
  }
@@ -125,8 +126,9 @@ var _OptionsManager = class {
125
126
  }
126
127
  return hasProperty ? value : defaultValue;
127
128
  }
128
- set(name, type, value, defaultValue) {
129
- const propertyName = _OptionsManager.__getPropertyName(name);
129
+ set(name, value, config) {
130
+ const { type, default: defaultValue } = config;
131
+ const propertyName = __getPropertyName(name);
130
132
  if (value.constructor.name !== type.name) {
131
133
  const val = Array.isArray(value) || (0, import_isObject.default)(value) ? JSON.stringify(value) : value;
132
134
  throw new TypeError(`The "${val}" value for the "${name}" option must be of type "${type.name}"`);
@@ -134,7 +136,7 @@ var _OptionsManager = class {
134
136
  switch (type) {
135
137
  case Boolean:
136
138
  if (defaultValue) {
137
- const negatedPropertyName = _OptionsManager.__getPropertyName(name, "No");
139
+ const negatedPropertyName = __getPropertyName(name, "No");
138
140
  if (value) {
139
141
  delete this.__element.dataset[negatedPropertyName];
140
142
  } else {
@@ -154,20 +156,5 @@ var _OptionsManager = class {
154
156
  this.__element.dataset[propertyName] = value;
155
157
  }
156
158
  }
157
- __hasProperty(prop) {
158
- return typeof this.__element.dataset[prop] !== "undefined";
159
- }
160
- static __getPropertyName(name, prefix = "") {
161
- const key = name + prefix;
162
- if (_OptionsManager.__propertyNameCache.has(key)) {
163
- return _OptionsManager.__propertyNameCache.get(key);
164
- }
165
- const propertyName = `option${prefix}${name.replace(/^\w/, (c) => c.toUpperCase())}`;
166
- _OptionsManager.__propertyNameCache.set(key, propertyName);
167
- return propertyName;
168
- }
169
159
  };
170
- var OptionsManager = _OptionsManager;
171
- __publicField(OptionsManager, "types", [String, Number, Boolean, Array, Object]);
172
- __publicField(OptionsManager, "__propertyNameCache", /* @__PURE__ */ new Map());
173
160
  if (module.exports.default) module.exports = module.exports.default;