@stimulus-library/utilities 1.2.1 → 1.3.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.
@@ -4,7 +4,6 @@ import { dispatchEvent } from "./events";
4
4
  export class BaseController extends Controller {
5
5
  constructor(context) {
6
6
  super(context);
7
- // @ts-ignore
8
7
  if (!this.application.debug) {
9
8
  return this;
10
9
  }
@@ -48,7 +47,7 @@ export class BaseController extends Controller {
48
47
  }
49
48
  metaValue(name) {
50
49
  const element = document.head.querySelector(`meta[name="${name}"]`);
51
- return element?.getAttribute("content") || null;
50
+ return (element === null || element === void 0 ? void 0 : element.getAttribute("content")) || null;
52
51
  }
53
52
  eventName(eventName) {
54
53
  return `${this.identifier}:${eventName}`;
@@ -1 +1 @@
1
- export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number, immediate?: boolean): T;
1
+ export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number, immediate?: boolean, timoutName?: string): T;
package/dist/debounce.js CHANGED
@@ -1,4 +1,5 @@
1
- export function debounce(func, wait, immediate = false) {
1
+ export function debounce(func, wait, immediate = false, timoutName) {
2
+ timoutName = timoutName || "activeTimeout";
2
3
  let timeout;
3
4
  return function (...args) {
4
5
  const later = () => {
@@ -12,6 +13,7 @@ export function debounce(func, wait, immediate = false) {
12
13
  clearTimeout(timeout);
13
14
  }
14
15
  timeout = setTimeout(later, wait);
16
+ this[timoutName] = timeout;
15
17
  if (callNow) {
16
18
  func.apply(this, args);
17
19
  }
@@ -8,9 +8,6 @@ const c2 = c1 * 1.525;
8
8
  const c3 = c1 + 1;
9
9
  const c4 = (2 * PI) / 3;
10
10
  const c5 = (2 * PI) / 4.5;
11
- // interface EasingDictionary {
12
- // [easing: string]: EasingFunction;
13
- // }
14
11
  const bounceOut = function (x) {
15
12
  const n1 = 7.5625;
16
13
  const d1 = 2.75;
@@ -5,33 +5,26 @@ export class EphemeralController extends BaseController {
5
5
  this.cleanup(this.el);
6
6
  }
7
7
  cleanup(element) {
8
- // @ts-ignore
9
- element.dataset.controller = element.dataset.controller?.replaceAll(new RegExp(`(\\s|^)${this.identifier}(\\s|$)`, "g"), "") || "";
8
+ var _a, _b, _c;
9
+ element.dataset.controller = ((_a = element.dataset.controller) === null || _a === void 0 ? void 0 : _a.replaceAll(new RegExp(`(\\s|^)${this.identifier}(\\s|$)`, "g"), "")) || "";
10
10
  if (element.dataset.controller == "") {
11
- // If there are no controllers left, remove the attribute
12
11
  delete element.dataset.controller;
13
12
  }
14
13
  const substringIdentifierValueRegex = new RegExp(`(\\s|^)${this.identifier}\\..+?(\\s|$)`, "g");
15
- // @ts-ignore
16
- element.dataset.target = element.dataset.target?.replaceAll(substringIdentifierValueRegex, "") || "";
14
+ element.dataset.target = ((_b = element.dataset.target) === null || _b === void 0 ? void 0 : _b.replaceAll(substringIdentifierValueRegex, "")) || "";
17
15
  delete element.dataset[camelCase(`${this.identifier}-target`)];
18
16
  if (element.dataset.target == "") {
19
- // If there are no targets left, remove the attribute
20
17
  delete element.dataset.target;
21
18
  }
22
- // @ts-ignore
23
- element.dataset.action = element.dataset.target?.replaceAll(substringIdentifierValueRegex, "") || "";
19
+ element.dataset.action = ((_c = element.dataset.target) === null || _c === void 0 ? void 0 : _c.replaceAll(substringIdentifierValueRegex, "")) || "";
24
20
  delete element.dataset[camelCase(`${this.identifier}-action`)];
25
21
  if (element.dataset.action == "") {
26
- // If there are no actions left, remove the attribute
27
22
  delete element.dataset.action;
28
23
  }
29
- // @ts-ignore
30
24
  const values = this.constructor.values;
31
25
  if (values) {
32
26
  Object.keys(values).forEach(val => delete element.dataset[camelCase(`${this.identifier}-${val}-value`)]);
33
27
  }
34
- // @ts-ignore
35
28
  const classes = this.constructor.classes;
36
29
  if (classes) {
37
30
  Object.keys(classes).forEach(val => delete element.dataset[camelCase(`${this.identifier}-${val}-class`)]);
package/dist/get_set.js CHANGED
@@ -1,51 +1,3 @@
1
- // The following code is extracted and modified from lodash v4.17.21
2
- // Original copyright and license information is below.
3
- //
4
- // The MIT License
5
- //
6
- // Copyright JS Foundation and other contributors <https://js.foundation/>
7
- //
8
- // Based on Underscore.js, copyright Jeremy Ashkenas,
9
- // DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
10
- //
11
- // This software consists of voluntary contributions made by many
12
- // individuals. For exact contribution history, see the revision history
13
- // available at https://github.com/lodash/lodash
14
- //
15
- // The following license applies to all parts of this software except as
16
- // documented below:
17
- //
18
- // ====
19
- //
20
- // Permission is hereby granted, free of charge, to any person obtaining
21
- // a copy of this software and associated documentation files (the
22
- // "Software"), to deal in the Software without restriction, including
23
- // without limitation the rights to use, copy, modify, merge, publish,
24
- // distribute, sublicense, and/or sell copies of the Software, and to
25
- // permit persons to whom the Software is furnished to do so, subject to
26
- // the following conditions:
27
- //
28
- // The above copyright notice and this permission notice shall be
29
- // included in all copies or substantial portions of the Software.
30
- //
31
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38
- //
39
- // ====
40
- //
41
- // Copyright and related rights for sample code are waived via CC0. Sample
42
- // code is defined as all source code displayed within the prose of the
43
- // documentation.
44
- //
45
- // CC0: http://creativecommons.org/publicdomain/zero/1.0/
46
- //
47
- // ====
48
- /** Used to match property names within property paths. */
49
1
  const reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
50
2
  const reIsPlainProp = /^\w*$/;
51
3
  const rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
@@ -55,12 +7,9 @@ const symbolTag = "[object Symbol]";
55
7
  const hasOwnProperty = Object.prototype.hasOwnProperty;
56
8
  const isArray = Array.isArray;
57
9
  const symbolProto = Symbol ? Symbol.prototype : undefined;
58
- // const symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
59
10
  const symbolToString = symbolProto ? symbolProto.toString : undefined;
60
11
  const INFINITY = 1 / 0;
61
12
  const MAX_SAFE_INTEGER = 9007199254740991;
62
- // const MAX_INTEGER = 1.7976931348623157e+308;
63
- // const NAN = 0 / 0;
64
13
  function arrayMap(array, iteratee) {
65
14
  let index = -1;
66
15
  const length = array == null ? 0 : array.length;
@@ -71,12 +20,10 @@ function arrayMap(array, iteratee) {
71
20
  return result;
72
21
  }
73
22
  function baseToString(value) {
74
- // Exit early for strings to avoid a performance hit in some environments.
75
23
  if (typeof value == "string") {
76
24
  return value;
77
25
  }
78
26
  if (isArray(value)) {
79
- // Recursively convert values (susceptible to call stack limits).
80
27
  return arrayMap(value, baseToString) + "";
81
28
  }
82
29
  if (isSymbol(value)) {
@@ -90,17 +37,15 @@ function toString(value) {
90
37
  }
91
38
  export function stringToPath(str) {
92
39
  const result = [];
93
- if (str.charCodeAt(0) === 46 /* . */) {
40
+ if (str.charCodeAt(0) === 46) {
94
41
  result.push("");
95
42
  }
96
- // @ts-ignore
97
43
  str.replace(rePropName, function (match, number, quote, subString) {
98
44
  result.push(quote ? subString.replace(reEscapeChar, "$1") : (number || match));
99
45
  });
100
46
  return result;
101
47
  }
102
48
  function defineProperty(object, key, value) {
103
- // @ts-ignore
104
49
  object[key] = value;
105
50
  return object;
106
51
  }
@@ -137,7 +82,6 @@ function isSymbol(value) {
137
82
  (isObjectLike(value) && baseGetTag(value) == symbolTag);
138
83
  }
139
84
  function baseGetTag(value) {
140
- // @ts-ignore
141
85
  return objectToString.call(value);
142
86
  }
143
87
  function objectToString(value) {
@@ -149,7 +93,6 @@ function baseGet(object, path) {
149
93
  let index = 0;
150
94
  const length = castedPath.length;
151
95
  while (object != null && index < length) {
152
- // @ts-ignore
153
96
  object = object[toKey(castedPath[index++])];
154
97
  }
155
98
  return (index && index == length) ? object : undefined;
@@ -161,14 +104,12 @@ function isObject(value) {
161
104
  function isIndex(value, length = null) {
162
105
  const type = typeof value;
163
106
  length = length == null ? MAX_SAFE_INTEGER : length;
164
- // @ts-ignore
165
107
  return !!length && (type == "number" || (type != "symbol" && reIsUint.test(value))) && (value > -1 && value % 1 == 0 && value < length);
166
108
  }
167
109
  function eq(value, other) {
168
110
  return value === other || (value !== value && other !== other);
169
111
  }
170
112
  function assignValue(object, key, value) {
171
- // @ts-ignore
172
113
  const objValue = object[key];
173
114
  if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
174
115
  (value === undefined && !(key in object))) {
@@ -185,7 +126,6 @@ function baseAssignValue(object, key, value) {
185
126
  });
186
127
  }
187
128
  else {
188
- // @ts-ignore
189
129
  object[key] = value;
190
130
  }
191
131
  }
@@ -202,14 +142,12 @@ function baseSet(object, path, value) {
202
142
  const key = toKey(castedPath[index]);
203
143
  let newValue = value;
204
144
  if (index != lastIndex) {
205
- // @ts-ignore
206
145
  const objValue = nested[key];
207
146
  newValue = isObject(objValue)
208
147
  ? objValue
209
148
  : (isIndex(castedPath[index + 1]) ? [] : {});
210
149
  }
211
150
  assignValue(nested, key, newValue);
212
- // @ts-ignore
213
151
  nested = nested[key];
214
152
  }
215
153
  return object;
package/dist/reactive.js CHANGED
@@ -6,16 +6,13 @@ export function reactive(object) {
6
6
  if (Object.getOwnPropertyDescriptor(object, property) == undefined) {
7
7
  continue;
8
8
  }
9
- // @ts-ignore
10
9
  object[property] = reactive(object[property]);
11
10
  }
12
11
  return new Proxy(object, {
13
12
  get(target, property) {
14
- // @ts-ignore
15
13
  return target[property];
16
14
  },
17
15
  set(target, property, value) {
18
- // @ts-ignore
19
16
  target[property] = reactive(value);
20
17
  return true;
21
18
  },
package/dist/stimulus.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export function controllerMethod(controller, methodName) {
2
- // @ts-ignore
3
2
  const method = controller[methodName];
4
3
  if (typeof method == "function") {
5
4
  return method;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "ruby on rails",
10
10
  "ruby-on-rails"
11
11
  ],
12
- "version": "1.2.1",
12
+ "version": "1.3.1",
13
13
  "license": "MIT",
14
14
  "author": {
15
15
  "name": "Sub-Xaero",
@@ -41,22 +41,23 @@
41
41
  "mitt": "^3.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@types/chai": "^4.3.5",
44
+ "@types/chai": "^5.0.1",
45
45
  "@types/mocha": "^10.0.1",
46
+ "@types/node": "^22.13.17",
46
47
  "@types/sinon": "^17.0.1",
47
- "@types/sinon-chai": "^3.2.9",
48
+ "@types/sinon-chai": "^4.0.0",
48
49
  "agadoo": "^3.0.0",
49
50
  "chai": "^5.1.1",
50
51
  "fast-glob": "^3.2.12",
51
52
  "lerna": "^8.0.0",
52
- "mocha": "^10.2.0",
53
+ "mocha": "^11.1.0",
53
54
  "rimraf": "^6.0.1",
54
- "sinon": "^18.0.0",
55
+ "sinon": "^20.0.0",
55
56
  "sinon-chai": "^4.0.0",
56
57
  "standard-version": "^9.5.0",
57
- "ts-node": "^10.9.1",
58
- "typescript": "^5.1.3",
59
- "vite": "^5.0.2"
58
+ "ts-node": "^10.9.2",
59
+ "typescript": "^5.8.2",
60
+ "vite": "^6.2.4"
60
61
  },
61
- "gitHead": "2760f91fcea2b872f0f42140125a7e73f86e341c"
62
+ "gitHead": "0e40d14436b1c5541e9ad6d73553041f9c60cceb"
62
63
  }