cotomy 0.4.1 → 0.4.3
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/README.md +4 -3
- package/dist/browser/cotomy.js +39 -17
- package/dist/browser/cotomy.js.map +1 -1
- package/dist/browser/cotomy.min.js +1 -1
- package/dist/browser/cotomy.min.js.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/view.js +39 -17
- package/dist/esm/view.js.map +1 -1
- package/dist/types/view.d.ts +27 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@ The View layer provides thin wrappers around DOM elements and window events.
|
|
|
66
66
|
- `html: string` (get/set)
|
|
67
67
|
- `value: string` — Works for inputs; falls back to `data-cotomy-value` otherwise
|
|
68
68
|
- `readonly: boolean` (get/set) — Uses native property if available, otherwise attribute
|
|
69
|
+
- `disabled: boolean` (get/set) — Uses native property if available (respects `fieldset[disabled]`), otherwise attribute
|
|
69
70
|
- `enabled: boolean` (get/set) — Toggles `disabled` attribute
|
|
70
71
|
- `setFocus(): void`
|
|
71
72
|
- Tree traversal & manipulation
|
|
@@ -76,8 +77,8 @@ The View layer provides thin wrappers around DOM elements and window events.
|
|
|
76
77
|
- `lastChild(selector = "*", type?)`
|
|
77
78
|
- `closest(selector, type?)`
|
|
78
79
|
- `find(selector, type?)` / `first(selector = "*", type?)` / `last(selector = "*", type?)` / `contains(selector)`
|
|
79
|
-
- `append(child): this` / `prepend(child): this` / `appendAll(children): this`
|
|
80
|
-
- `insertBefore(sibling): this` / `insertAfter(sibling): this`
|
|
80
|
+
- `append(child): this` / `prepend(child): this` / `appendAll(children): this` — accepts `CotomyElement`, HTML string, or `{ html, css? }`
|
|
81
|
+
- `insertBefore(sibling): this` / `insertAfter(sibling): this` — accepts `CotomyElement`, HTML string, or `{ html, css? }`
|
|
81
82
|
- `appendTo(target): this` / `prependTo(target): this`
|
|
82
83
|
- `comesBefore(target): boolean` / `comesAfter(target): boolean` — Checks DOM order (returns `false` for the same element or disconnected nodes)
|
|
83
84
|
- `clone(type?): CotomyElement` - Returns a deep-cloned element, optionally typed, and reassigns a new `data-cotomy-instance` while preserving the `data-cotomy-scopeid` for scoped CSS sharing (strips `data-cotomy-moving`). Cloning an invalidated element (`data-cotomy-invalidated`) throws.
|
|
@@ -160,7 +161,7 @@ npm test -- --run tests/view.spec.ts -t "compares document order with comesBefor
|
|
|
160
161
|
- `initialize(): this`
|
|
161
162
|
- DOM helpers
|
|
162
163
|
- `body: CotomyElement`
|
|
163
|
-
- `append(element: CotomyElement): this`
|
|
164
|
+
- `append(element: CotomyElement | string | { html: string, css?: string }): this`
|
|
164
165
|
- `scrollTo(target, options?: CotomyScrollOptions | Partial<CotomyScrollOptions>): this` — Scrolls to reveal a target (`selector | CotomyElement | HTMLElement`)
|
|
165
166
|
- `moveNext(focused: CotomyElement, shift = false)` — Move focus to next/previous focusable
|
|
166
167
|
- Window events
|
package/dist/browser/cotomy.js
CHANGED
|
@@ -1182,17 +1182,32 @@ class CotomyElement {
|
|
|
1182
1182
|
}
|
|
1183
1183
|
return false;
|
|
1184
1184
|
}
|
|
1185
|
-
get
|
|
1186
|
-
|
|
1185
|
+
get disabled() {
|
|
1186
|
+
if ("disabled" in this.element) {
|
|
1187
|
+
if (this.match(":disabled"))
|
|
1188
|
+
return true;
|
|
1189
|
+
return this.element.disabled;
|
|
1190
|
+
}
|
|
1191
|
+
return this.element.hasAttribute("disabled");
|
|
1187
1192
|
}
|
|
1188
|
-
set
|
|
1193
|
+
set disabled(value) {
|
|
1194
|
+
if ("disabled" in this.element) {
|
|
1195
|
+
this.element.disabled = value;
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1189
1198
|
if (value) {
|
|
1190
|
-
this.
|
|
1199
|
+
this.attribute("disabled", "");
|
|
1191
1200
|
}
|
|
1192
1201
|
else {
|
|
1193
|
-
this.
|
|
1202
|
+
this.attribute("disabled", null);
|
|
1194
1203
|
}
|
|
1195
1204
|
}
|
|
1205
|
+
get enabled() {
|
|
1206
|
+
return !this.disabled;
|
|
1207
|
+
}
|
|
1208
|
+
set enabled(value) {
|
|
1209
|
+
this.disabled = !value;
|
|
1210
|
+
}
|
|
1196
1211
|
get invalidated() {
|
|
1197
1212
|
return this.element.hasAttribute("data-cotomy-invalidated");
|
|
1198
1213
|
}
|
|
@@ -1616,18 +1631,23 @@ class CotomyElement {
|
|
|
1616
1631
|
target.trigger("cotomy:transitend");
|
|
1617
1632
|
}
|
|
1618
1633
|
}
|
|
1634
|
+
static toElement(target) {
|
|
1635
|
+
return target instanceof CotomyElement ? target : new CotomyElement(target);
|
|
1636
|
+
}
|
|
1619
1637
|
prepend(prepend) {
|
|
1620
|
-
CotomyElement.
|
|
1621
|
-
|
|
1638
|
+
const e = CotomyElement.toElement(prepend);
|
|
1639
|
+
CotomyElement.runWithMoveEvents(e, () => {
|
|
1640
|
+
this.element.prepend(e.element);
|
|
1622
1641
|
});
|
|
1623
|
-
|
|
1642
|
+
e.ensureScopedCss();
|
|
1624
1643
|
return this;
|
|
1625
1644
|
}
|
|
1626
1645
|
append(target) {
|
|
1627
|
-
CotomyElement.
|
|
1628
|
-
|
|
1646
|
+
const e = CotomyElement.toElement(target);
|
|
1647
|
+
CotomyElement.runWithMoveEvents(e, () => {
|
|
1648
|
+
this.element.append(e.element);
|
|
1629
1649
|
});
|
|
1630
|
-
|
|
1650
|
+
e.ensureScopedCss();
|
|
1631
1651
|
return this;
|
|
1632
1652
|
}
|
|
1633
1653
|
appendAll(targets) {
|
|
@@ -1635,17 +1655,19 @@ class CotomyElement {
|
|
|
1635
1655
|
return this;
|
|
1636
1656
|
}
|
|
1637
1657
|
insertBefore(append) {
|
|
1638
|
-
CotomyElement.
|
|
1639
|
-
|
|
1658
|
+
const e = CotomyElement.toElement(append);
|
|
1659
|
+
CotomyElement.runWithMoveEvents(e, () => {
|
|
1660
|
+
this.element.before(e.element);
|
|
1640
1661
|
});
|
|
1641
|
-
|
|
1662
|
+
e.ensureScopedCss();
|
|
1642
1663
|
return this;
|
|
1643
1664
|
}
|
|
1644
1665
|
insertAfter(append) {
|
|
1645
|
-
CotomyElement.
|
|
1646
|
-
|
|
1666
|
+
const e = CotomyElement.toElement(append);
|
|
1667
|
+
CotomyElement.runWithMoveEvents(e, () => {
|
|
1668
|
+
this.element.after(e.element);
|
|
1647
1669
|
});
|
|
1648
|
-
|
|
1670
|
+
e.ensureScopedCss();
|
|
1649
1671
|
return this;
|
|
1650
1672
|
}
|
|
1651
1673
|
appendTo(target) {
|