cotomy 0.3.6 → 0.3.7

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 CHANGED
@@ -77,7 +77,7 @@ The View layer provides thin wrappers around DOM elements and window events.
77
77
  - `appendTo(target): this` / `prependTo(target): this`
78
78
  - `clone(type?): CotomyElement` - Returns a deep-cloned element, optionally typed, and reassigns new `data-cotomy-scopeid` values to the clone and all descendants so scoped CSS and event registries stay isolated
79
79
  - `clear(): this` — Removes all descendants and text
80
- - `remove(): void`
80
+ - `remove(): void` — Explicitly non-chainable after removal
81
81
  - Geometry & visibility
82
82
  - `visible: boolean`
83
83
  - `width: number` (get/set px)
@@ -141,15 +141,15 @@ The first command ensures `[scope]` expands to `[data-cotomy-scopeid="..."]` in
141
141
  - Singleton
142
142
  - `CotomyWindow.instance`
143
143
  - `initialized: boolean` — Call `initialize()` once after DOM is ready
144
- - `initialize(): void`
144
+ - `initialize(): this`
145
145
  - DOM helpers
146
146
  - `body: CotomyElement`
147
- - `append(element: CotomyElement)`
147
+ - `append(element: CotomyElement): this`
148
148
  - `moveNext(focused: CotomyElement, shift = false)` — Move focus to next/previous focusable
149
149
  - Window events
150
- - `on(eventOrEvents, handler)` / `off(eventOrEvents, handler?)` / `trigger(event[, Event])` — `eventOrEvents` accepts a single event name or an array. CotomyWindow’s `trigger` also bubbles by default and accepts an `Event` to override the behavior.
151
- - `load(handler)` / `ready(handler)`
152
- - `resize([handler])` / `scroll([handler])` / `changeLayout([handler])` / `pageshow([handler])`
150
+ - `on(eventOrEvents, handler): this` / `off(eventOrEvents, handler?): this` / `trigger(event[, Event]): this` — `eventOrEvents` accepts a single event name or an array. CotomyWindow’s `trigger` also bubbles by default and accepts an `Event` to override the behavior.
151
+ - `load(handler): this` / `ready(handler): this`
152
+ - `resize([handler]): this` / `scroll([handler]): this` / `changeLayout([handler]): this` / `pageshow([handler]): this`
153
153
  - Window state
154
154
  - `scrollTop`, `scrollLeft`, `width`, `height`, `documentWidth`, `documentHeight`
155
155
  - `reload(): void` (sets internal `reloading` flag), `reloading: boolean`
@@ -1115,6 +1115,7 @@ class CotomyElement {
1115
1115
  }
1116
1116
  setFocus() {
1117
1117
  this.element.focus();
1118
+ return this;
1118
1119
  }
1119
1120
  get visible() {
1120
1121
  if (!this.attached) {
@@ -1877,6 +1878,7 @@ class CotomyWindow {
1877
1878
  });
1878
1879
  this._mutationObserver.observe(this.body.element, { childList: true, subtree: true });
1879
1880
  }
1881
+ return this;
1880
1882
  }
1881
1883
  get reloading() {
1882
1884
  return this._reloading;
@@ -1890,6 +1892,7 @@ class CotomyWindow {
1890
1892
  }
1891
1893
  append(e) {
1892
1894
  this._body.append(e);
1895
+ return this;
1893
1896
  }
1894
1897
  moveNext(focused, shift = false) {
1895
1898
  const selector = "input, a, select, button, textarea";
@@ -1910,6 +1913,7 @@ class CotomyWindow {
1910
1913
  }
1911
1914
  trigger(event, e) {
1912
1915
  window.dispatchEvent(e ?? new Event(event, { bubbles: true }));
1916
+ return this;
1913
1917
  }
1914
1918
  on(event, handle) {
1915
1919
  const events = Array.isArray(event) ? event : [event];
@@ -1919,6 +1923,7 @@ class CotomyWindow {
1919
1923
  this._eventHandlers[eventName].push(handle);
1920
1924
  window.addEventListener(eventName, handle);
1921
1925
  });
1926
+ return this;
1922
1927
  }
1923
1928
  off(event, handle) {
1924
1929
  const events = Array.isArray(event) ? event : [event];
@@ -1940,43 +1945,44 @@ class CotomyWindow {
1940
1945
  delete this._eventHandlers[eventName];
1941
1946
  }
1942
1947
  });
1948
+ return this;
1943
1949
  }
1944
1950
  load(handle) {
1945
- this.on("load", handle);
1951
+ return this.on("load", handle);
1946
1952
  }
1947
1953
  ready(handle) {
1948
- this.on("cotomy:ready", handle);
1954
+ return this.on("cotomy:ready", handle);
1949
1955
  }
1950
1956
  resize(handle) {
1951
1957
  if (handle) {
1952
- this.on("resize", handle);
1958
+ return this.on("resize", handle);
1953
1959
  }
1954
1960
  else {
1955
- this.trigger("resize");
1961
+ return this.trigger("resize");
1956
1962
  }
1957
1963
  }
1958
1964
  scroll(handle) {
1959
1965
  if (handle) {
1960
- this.on("scroll", handle);
1966
+ return this.on("scroll", handle);
1961
1967
  }
1962
1968
  else {
1963
- this.trigger("scroll");
1969
+ return this.trigger("scroll");
1964
1970
  }
1965
1971
  }
1966
1972
  changeLayout(handle) {
1967
1973
  if (handle) {
1968
- this.on("cotomy:changelayout", handle);
1974
+ return this.on("cotomy:changelayout", handle);
1969
1975
  }
1970
1976
  else {
1971
- this.trigger("cotomy:changelayout");
1977
+ return this.trigger("cotomy:changelayout");
1972
1978
  }
1973
1979
  }
1974
1980
  pageshow(handle) {
1975
1981
  if (handle) {
1976
- this.on("pageshow", handle);
1982
+ return this.on("pageshow", handle);
1977
1983
  }
1978
1984
  else {
1979
- this.trigger("pageshow");
1985
+ return this.trigger("pageshow");
1980
1986
  }
1981
1987
  }
1982
1988
  get scrollTop() {