@trunkjs/browser-utils 1.0.52 → 1.0.53
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.
- package/CHANGELOG.md +6 -0
- package/index.js +30 -20
- package/lib/FormDataAccessor.d.ts +2 -0
- package/package.json +2 -2
- package/skills/form-data-accessor-usage/SKILL.md +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 1.0.53 (2026-09-01)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for browser-utils to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
1
5
|
## 1.0.52 (2026-08-29)
|
|
2
6
|
|
|
3
7
|
### 🩹 Fixes
|
|
@@ -10,6 +14,8 @@
|
|
|
10
14
|
|
|
11
15
|
## Unreleased
|
|
12
16
|
|
|
17
|
+
- Treat named value elements as opaque controls so nested object values are not collected twice.
|
|
18
|
+
|
|
13
19
|
## 1.0.51 (2026-08-29)
|
|
14
20
|
|
|
15
21
|
### ✨ Features
|
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var O = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var P = (n) => {
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
5
|
var j = (n, t, e) => t in n ? O(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
6
|
-
var f = (n, t, e) => j(n, typeof t != "symbol" ? t + "" : t, e), T = (n, t, e) => t.has(n) ||
|
|
7
|
-
var l = (n, t, e) => (T(n, t, "read from private field"), e ? e.call(n) : t.get(n)), m = (n, t, e) => t.has(n) ?
|
|
6
|
+
var f = (n, t, e) => j(n, typeof t != "symbol" ? t + "" : t, e), T = (n, t, e) => t.has(n) || P("Cannot " + e);
|
|
7
|
+
var l = (n, t, e) => (T(n, t, "read from private field"), e ? e.call(n) : t.get(n)), m = (n, t, e) => t.has(n) ? P("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), y = (n, t, e, i) => (T(n, t, "write to private field"), i ? i.call(n, e) : t.set(n, e), e), w = (n, t, e) => (T(n, t, "access private method"), e);
|
|
8
8
|
const E = [
|
|
9
9
|
{ name: "xs", minWidth: 0 },
|
|
10
10
|
{ name: "sm", minWidth: 576 },
|
|
@@ -12,14 +12,14 @@ const E = [
|
|
|
12
12
|
{ name: "lg", minWidth: 992 },
|
|
13
13
|
{ name: "xl", minWidth: 1200 },
|
|
14
14
|
{ name: "xxl", minWidth: 1400 }
|
|
15
|
-
],
|
|
15
|
+
], S = E.reduce(
|
|
16
16
|
(n, t) => (n[t.name] = t.minWidth, n),
|
|
17
17
|
{}
|
|
18
18
|
);
|
|
19
19
|
function p(n) {
|
|
20
|
-
if (!(n in
|
|
20
|
+
if (!(n in S))
|
|
21
21
|
throw new Error(`Unknown breakpoint: ${n}`);
|
|
22
|
-
return
|
|
22
|
+
return S[n];
|
|
23
23
|
}
|
|
24
24
|
function F() {
|
|
25
25
|
return window.visualViewport ? window.visualViewport.width : window.innerWidth;
|
|
@@ -156,7 +156,7 @@ class rt {
|
|
|
156
156
|
const t = [];
|
|
157
157
|
for (const e of Array.from(this.root.querySelectorAll("[name]"))) {
|
|
158
158
|
const i = this.getName(e);
|
|
159
|
-
!i || !this.isValueElement(e) || t.push({
|
|
159
|
+
!i || !this.isValueElement(e) || this.hasValueElementParent(e) || t.push({
|
|
160
160
|
name: i,
|
|
161
161
|
element: e,
|
|
162
162
|
get value() {
|
|
@@ -212,6 +212,16 @@ class rt {
|
|
|
212
212
|
isValueElement(t) {
|
|
213
213
|
return !("value" in t) || t instanceof HTMLButtonElement ? !1 : !(t instanceof HTMLInputElement && H.has(t.type.toLowerCase()));
|
|
214
214
|
}
|
|
215
|
+
/** A named value element owns its value, so its descendants are not collected twice. */
|
|
216
|
+
hasValueElementParent(t) {
|
|
217
|
+
let e = t.parentElement;
|
|
218
|
+
for (; e && e !== this.root; ) {
|
|
219
|
+
if (this.getName(e) && this.isValueElement(e))
|
|
220
|
+
return !0;
|
|
221
|
+
e = e.parentElement;
|
|
222
|
+
}
|
|
223
|
+
return !1;
|
|
224
|
+
}
|
|
215
225
|
isDisabled(t) {
|
|
216
226
|
return !!t.disabled || t.hasAttribute("disabled") || t.matches(":disabled");
|
|
217
227
|
}
|
|
@@ -339,7 +349,7 @@ function X(n) {
|
|
|
339
349
|
return;
|
|
340
350
|
}
|
|
341
351
|
}
|
|
342
|
-
function
|
|
352
|
+
function _(n) {
|
|
343
353
|
const t = JSON.stringify(n);
|
|
344
354
|
return t === void 0 ? "null" : t;
|
|
345
355
|
}
|
|
@@ -360,7 +370,7 @@ class I {
|
|
|
360
370
|
const t = this.backend ? X(this.backend.getItem(this.storageKey)) : void 0, e = Q(t, this.initialValue);
|
|
361
371
|
if (this.backend && this.backend.getItem(this.storageKey) == null)
|
|
362
372
|
try {
|
|
363
|
-
this.backend.setItem(this.storageKey,
|
|
373
|
+
this.backend.setItem(this.storageKey, _(e));
|
|
364
374
|
} catch {
|
|
365
375
|
}
|
|
366
376
|
return this.cache = e, e;
|
|
@@ -368,7 +378,7 @@ class I {
|
|
|
368
378
|
write(t) {
|
|
369
379
|
if (this.cache = t, !!this.backend)
|
|
370
380
|
try {
|
|
371
|
-
this.backend.setItem(this.storageKey,
|
|
381
|
+
this.backend.setItem(this.storageKey, _(t));
|
|
372
382
|
} catch {
|
|
373
383
|
}
|
|
374
384
|
}
|
|
@@ -497,7 +507,7 @@ function mt(n) {
|
|
|
497
507
|
}
|
|
498
508
|
return e = new WeakMap(), i = new WeakMap(), t;
|
|
499
509
|
}
|
|
500
|
-
const k = Symbol("listenerDefs"),
|
|
510
|
+
const k = Symbol("listenerDefs"), N = Symbol("withEventBindings");
|
|
501
511
|
function gt(n, t) {
|
|
502
512
|
const e = Array.isArray(n) ? n : [n];
|
|
503
513
|
return function(i, r) {
|
|
@@ -510,7 +520,7 @@ function gt(n, t) {
|
|
|
510
520
|
opts: t
|
|
511
521
|
});
|
|
512
522
|
}), function(...s) {
|
|
513
|
-
if (!this[
|
|
523
|
+
if (!this[N])
|
|
514
524
|
throw new Error("[EventBindings] @Listen - decorator requires EventBindingMixin.");
|
|
515
525
|
return i.apply(this, s);
|
|
516
526
|
};
|
|
@@ -521,31 +531,31 @@ function Z(n, t) {
|
|
|
521
531
|
return !t || t === "host" ? n : t === "document" ? n.ownerDocument ?? document : t === "window" ? ((e = n.ownerDocument) == null ? void 0 : e.defaultView) ?? window : t === "shadowRoot" ? n.shadowRoot ?? n : typeof t == "function" ? t(n) : t;
|
|
522
532
|
}
|
|
523
533
|
function wt(n) {
|
|
524
|
-
var e, i,
|
|
534
|
+
var e, i, $;
|
|
525
535
|
class t extends n {
|
|
526
536
|
constructor(...o) {
|
|
527
537
|
super(...o);
|
|
528
538
|
m(this, i);
|
|
529
539
|
m(this, e);
|
|
530
|
-
this[
|
|
540
|
+
this[N] = !0;
|
|
531
541
|
}
|
|
532
542
|
connectedCallback() {
|
|
533
543
|
var o;
|
|
534
|
-
(o = super.connectedCallback) == null || o.call(this), w(this, i,
|
|
544
|
+
(o = super.connectedCallback) == null || o.call(this), w(this, i, $).call(this);
|
|
535
545
|
}
|
|
536
546
|
disconnectedCallback() {
|
|
537
547
|
var o, u;
|
|
538
548
|
(o = l(this, e)) == null || o.abort(), (u = super.disconnectedCallback) == null || u.call(this);
|
|
539
549
|
}
|
|
540
550
|
}
|
|
541
|
-
return e = new WeakMap(), i = new WeakSet(),
|
|
551
|
+
return e = new WeakMap(), i = new WeakSet(), $ = function() {
|
|
542
552
|
var u, c, d;
|
|
543
553
|
(u = l(this, e)) == null || u.abort(), y(this, e, new AbortController());
|
|
544
554
|
const o = this[k] || [];
|
|
545
555
|
for (const h of o) {
|
|
546
|
-
const g = Z(this, (c = h.opts) == null ? void 0 : c.target), b = ((d = h.opts) == null ? void 0 : d.options) ?? {},
|
|
547
|
-
for (const
|
|
548
|
-
g.addEventListener(
|
|
556
|
+
const g = Z(this, (c = h.opts) == null ? void 0 : c.target), b = ((d = h.opts) == null ? void 0 : d.options) ?? {}, V = this[h.method].bind(this);
|
|
557
|
+
for (const R of h.events)
|
|
558
|
+
g.addEventListener(R, V, { ...b, signal: l(this, e).signal });
|
|
549
559
|
}
|
|
550
560
|
}, t;
|
|
551
561
|
}
|
|
@@ -676,7 +686,7 @@ export {
|
|
|
676
686
|
yt as LoggingMixin,
|
|
677
687
|
pt as SlotVisibilityMixin,
|
|
678
688
|
ot as Stopwatch,
|
|
679
|
-
|
|
689
|
+
S as breakpointMap,
|
|
680
690
|
E as breakpoints,
|
|
681
691
|
nt as create_element,
|
|
682
692
|
it as debounce,
|
|
@@ -20,6 +20,8 @@ export declare class FormDataAccessor {
|
|
|
20
20
|
private get groupedEntries();
|
|
21
21
|
private getName;
|
|
22
22
|
private isValueElement;
|
|
23
|
+
/** A named value element owns its value, so its descendants are not collected twice. */
|
|
24
|
+
private hasValueElementParent;
|
|
23
25
|
private isDisabled;
|
|
24
26
|
private readGroup;
|
|
25
27
|
private writeGroup;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trunkjs/browser-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.53",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "packages/browser-utils",
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/trunkjs/trunkjs-monorepo"
|
|
8
|
+
"url": "git+https://github.com/trunkjs/trunkjs-monorepo.git"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {},
|
|
11
11
|
"type": "module",
|
|
@@ -21,6 +21,9 @@ The root may be an `HTMLElement`, `Document`, or `DocumentFragment`. Controls ar
|
|
|
21
21
|
access. A control needs a non-empty `name` and a readable/writable `value` property. Native inputs, textareas, selects,
|
|
22
22
|
and compatible custom elements such as `nte-input` follow this contract.
|
|
23
23
|
|
|
24
|
+
A named value element owns its complete value. Named descendants below it are not returned as additional entries. This
|
|
25
|
+
allows object-valued controls such as a named nested `tj-form` to form a data tree without duplicate flat fields.
|
|
26
|
+
|
|
24
27
|
## Data behavior
|
|
25
28
|
|
|
26
29
|
- `name[]` becomes an array under the name without `[]` in `data`.
|