@ulu/frontend 0.6.29 → 0.6.30

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.
@@ -24,6 +24,7 @@ export class ComponentInitializer {
24
24
  * Initializes the component based on the provided configuration.
25
25
  * @param {Object} config The initialization configuration.
26
26
  * @param {Function} config.setup The setup function to call for each element.
27
+ * @param {Function} config.update The update function to call for already initialized elements on coreEvents.
27
28
  * @param {String} config.key [null] The optional key to use with attribute selector.
28
29
  * @param {Boolean} config.withData [null] Whether to retrieve element data.
29
30
  * @param {Array} config.coreEvents [null] An array of core event names (e.g., 'pageModified') that should trigger a re-initialization.
@@ -31,6 +32,7 @@ export class ComponentInitializer {
31
32
  */
32
33
  init(config: {
33
34
  setup: Function;
35
+ update: Function;
34
36
  key: string;
35
37
  withData: boolean;
36
38
  coreEvents: any[];
@@ -50,6 +52,20 @@ export class ComponentInitializer {
50
52
  withData: boolean;
51
53
  context: HTMLElement;
52
54
  }): void;
55
+ /**
56
+ * Processes the already initialized elements based on the provided configuration.
57
+ * @param {object} config The initialization configuration.
58
+ * @param {function} config.update The update function to call for each element.
59
+ * @param {string} config.key The optional key to use with attribute selector.
60
+ * @param {boolean} config.withData [false] Whether to retrieve element data.
61
+ * @param {HTMLElement} config.context [document] The context to query within.
62
+ */
63
+ updateElements(config: {
64
+ update: Function;
65
+ key: string;
66
+ withData: boolean;
67
+ context: HTMLElement;
68
+ }): void;
53
69
  /**
54
70
  * Get an attribute name
55
71
  * @param {String} key Optional key, if no key will return baseAttribute if key will return key added to base
@@ -63,9 +79,21 @@ export class ComponentInitializer {
63
79
  attributeSelector(key: string): string;
64
80
  /**
65
81
  * Create an attribute selector for initial
82
+ * @param {String} key Optional key
66
83
  * @return {String}
67
84
  */
68
- attributeSelectorInitial(key: any): string;
85
+ attributeSelectorInitial(key: string): string;
86
+ /**
87
+ * Create an attribute selector for initialized elements
88
+ * @param {String} key Optional key
89
+ * @return {String}
90
+ */
91
+ attributeSelectorInitialized(key: string): string;
92
+ /**
93
+ * Internal helper to query and map elements.
94
+ * @private
95
+ */
96
+ private queryElements;
69
97
  /**
70
98
  * Queries all main elements of a component that have not been initialized and extracts their data attributes.
71
99
  * @param {HTMLElement} context The context to query within.
@@ -78,6 +106,17 @@ export class ComponentInitializer {
78
106
  data: object;
79
107
  initialize: Function;
80
108
  }>;
109
+ /**
110
+ * Queries all main elements of a component that have already been initialized and extracts their data attributes.
111
+ * @param {HTMLElement} context The context to query within.
112
+ * @param {Boolean} withData Include dataset from element (as optional JSON)
113
+ * @param {Node} context Element to query elements from
114
+ * @returns {Array<{element: HTMLElement, data: object}>} An array of objects containing the elements and their data
115
+ */
116
+ queryAllInitialized(key: any, withData: boolean, context?: HTMLElement): Array<{
117
+ element: HTMLElement;
118
+ data: object;
119
+ }>;
81
120
  /**
82
121
  * Sets the init attribute on an element, marking it as initialized.
83
122
  * @param {HTMLElement} element The element to initialize.
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../lib/js/core/component.js"],"names":[],"mappings":"AAUA;;GAEG;AACH;IACE;;;MAGE;IACF,iCAGE;IACF,+BAEE;IAEF;;;;;OAKG;IACH,qBAHG;QAAwB,IAAI;QACJ,aAAa;KACvC,EASA;IAFC,eAAwE;IACxE,iBAAgD;IAElD;;;;;;;;OAQG;IACH,aANG;QAAyB,KAAK;QACP,GAAG;QACF,QAAQ;QACV,UAAU;QACJ,OAAO,EAA3B,WAAW;KACrB,QAcA;IACD;;;;;;;OAOG;IACH,sBALG;QAAyB,KAAK;QACP,GAAG,EAAlB,MAAM;QACU,QAAQ,EAAxB,OAAO;QACa,OAAO,EAA3B,WAAW;KACrB,QAKA;IACD;;;;OAIG;IACH,kCAGC;IACD;;;OAGG;IACH,uCAEC;IACD;;;OAGG;IACH,2CAEC;IACD;;;;;;OAMG;IACH,uDALW,WAAW,GAGT,KAAK,CAAC;QAAC,OAAO,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,WAAU;KAAC,CAAC,CAS7E;IACD;;;OAGG;IACH,2BAFW,WAAW,QAIrB;IACD;;;OAGG;IACH,iCAFY,GAAC,CAKZ;IACD;;OAEG;IACH,0BAEC;IACD;;OAEG;IACH,2BAEC;IACD;;OAEG;IACH,+BAEC;CACF"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../lib/js/core/component.js"],"names":[],"mappings":"AAUA;;GAEG;AACH;IACE;;;MAGE;IACF,iCAGE;IACF,+BAEE;IAEF;;;;;OAKG;IACH,qBAHG;QAAwB,IAAI;QACJ,aAAa;KACvC,EASA;IAFC,eAAwE;IACxE,iBAAgD;IAElD;;;;;;;;;OASG;IACH,aAPG;QAAyB,KAAK;QACL,MAAM;QACR,GAAG;QACF,QAAQ;QACV,UAAU;QACJ,OAAO,EAA3B,WAAW;KACrB,QAmBA;IACD;;;;;;;OAOG;IACH,sBALG;QAAyB,KAAK;QACP,GAAG,EAAlB,MAAM;QACU,QAAQ,EAAxB,OAAO;QACa,OAAO,EAA3B,WAAW;KACrB,QAKA;IACD;;;;;;;OAOG;IACH,uBALG;QAAyB,MAAM;QACR,GAAG,EAAlB,MAAM;QACU,QAAQ,EAAxB,OAAO;QACa,OAAO,EAA3B,WAAW;KACrB,QAKA;IACD;;;;OAIG;IACH,kCAGC;IACD;;;OAGG;IACH,uCAEC;IACD;;;;OAIG;IACH,8CAEC;IACD;;;;OAIG;IACH,kDAEC;IACD;;;OAGG;IACH,sBAYC;IACD;;;;;;OAMG;IACH,uDALW,WAAW,GAGT,KAAK,CAAC;QAAC,OAAO,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,WAAU;KAAC,CAAC,CAU7E;IACD;;;;;;OAMG;IACH,2DALW,WAAW,GAGT,KAAK,CAAC;QAAC,OAAO,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAUvD;IACD;;;OAGG;IACH,2BAFW,WAAW,QAIrB;IACD;;;OAGG;IACH,iCAFY,GAAC,CAKZ;IACD;;OAEG;IACH,0BAEC;IACD;;OAEG;IACH,2BAEC;IACD;;OAEG;IACH,+BAEC;CACF"}
@@ -1,11 +1,11 @@
1
- var h = Object.defineProperty;
2
- var c = (r, t, e) => t in r ? h(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var n = (r, t, e) => c(r, typeof t != "symbol" ? t + "" : t, e);
1
+ var d = Object.defineProperty;
2
+ var m = (n, t, e) => t in n ? d(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var o = (n, t, e) => m(n, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { hasRequiredProps as p } from "@ulu/utils/object.js";
5
5
  import { getDatasetOptionalJson as b } from "@ulu/utils/browser/dom.js";
6
- import { dataAttributeToDatasetKey as d } from "../utils/dom.js";
7
- import { getCoreEventName as g } from "./events.js";
8
- const i = class i {
6
+ import { dataAttributeToDatasetKey as E } from "../utils/dom.js";
7
+ import { getCoreEventName as A } from "./events.js";
8
+ const s = class s {
9
9
  /**
10
10
  * Create a new instance of ComponentInitializer
11
11
  * @param {Object} options Options for configuring the component initializer.
@@ -13,17 +13,18 @@ const i = class i {
13
13
  * @param {String} options.baseAttribute Prefix and base attribute name (used for base attribute and further element attribute names).
14
14
  */
15
15
  constructor(t) {
16
- if (!i.hasRequiredOptions(t))
16
+ if (!s.hasRequiredOptions(t))
17
17
  throw new Error(
18
- `Missing a required options: ${i.requiredOptions.join(", ")}`
18
+ `Missing a required options: ${s.requiredOptions.join(", ")}`
19
19
  );
20
- this.options = Object.assign({}, i.defaults, t), this.logTitle = `ULU: ${this.options.type}:
20
+ this.options = Object.assign({}, s.defaults, t), this.logTitle = `ULU: ${this.options.type}:
21
21
  `;
22
22
  }
23
23
  /**
24
24
  * Initializes the component based on the provided configuration.
25
25
  * @param {Object} config The initialization configuration.
26
26
  * @param {Function} config.setup The setup function to call for each element.
27
+ * @param {Function} config.update The update function to call for already initialized elements on coreEvents.
27
28
  * @param {String} config.key [null] The optional key to use with attribute selector.
28
29
  * @param {Boolean} config.withData [null] Whether to retrieve element data.
29
30
  * @param {Array} config.coreEvents [null] An array of core event names (e.g., 'pageModified') that should trigger a re-initialization.
@@ -31,9 +32,11 @@ const i = class i {
31
32
  */
32
33
  init(t) {
33
34
  var e;
34
- this.setupElements(t), (e = t.coreEvents) != null && e.length && t.coreEvents.forEach((s) => {
35
- const o = g(s);
36
- o && document.addEventListener(o, () => this.setupElements(t));
35
+ this.setupElements(t), (e = t.coreEvents) != null && e.length && t.coreEvents.forEach((i) => {
36
+ const r = A(i);
37
+ r && document.addEventListener(r, () => {
38
+ this.setupElements(t), t.update && this.updateElements(t);
39
+ });
37
40
  });
38
41
  }
39
42
  /**
@@ -45,8 +48,20 @@ const i = class i {
45
48
  * @param {HTMLElement} config.context [document] The context to query within.
46
49
  */
47
50
  setupElements(t) {
48
- const { setup: e, key: s, withData: o, context: a } = t;
49
- this.queryAllInitial(s, o, a).forEach((u) => e(u, this));
51
+ const { setup: e, key: i, withData: r, context: l } = t;
52
+ this.queryAllInitial(i, r, l).forEach((a) => e(a, this));
53
+ }
54
+ /**
55
+ * Processes the already initialized elements based on the provided configuration.
56
+ * @param {object} config The initialization configuration.
57
+ * @param {function} config.update The update function to call for each element.
58
+ * @param {string} config.key The optional key to use with attribute selector.
59
+ * @param {boolean} config.withData [false] Whether to retrieve element data.
60
+ * @param {HTMLElement} config.context [document] The context to query within.
61
+ */
62
+ updateElements(t) {
63
+ const { update: e, key: i, withData: r, context: l } = t;
64
+ this.queryAllInitialized(i, r, l).forEach((a) => e(a, this));
50
65
  }
51
66
  /**
52
67
  * Get an attribute name
@@ -66,11 +81,33 @@ const i = class i {
66
81
  }
67
82
  /**
68
83
  * Create an attribute selector for initial
84
+ * @param {String} key Optional key
69
85
  * @return {String}
70
86
  */
71
87
  attributeSelectorInitial(t) {
72
88
  return `${this.attributeSelector(t)}:not([${this.getAttribute("init")}])`;
73
89
  }
90
+ /**
91
+ * Create an attribute selector for initialized elements
92
+ * @param {String} key Optional key
93
+ * @return {String}
94
+ */
95
+ attributeSelectorInitialized(t) {
96
+ return `${this.attributeSelector(t)}[${this.getAttribute("init")}]`;
97
+ }
98
+ /**
99
+ * Internal helper to query and map elements.
100
+ * @private
101
+ */
102
+ queryElements(t, e, i, r = document, l = !1) {
103
+ return [...r.querySelectorAll(t)].map((a) => {
104
+ const h = {
105
+ element: a,
106
+ data: i ? this.getData(a, e) : null
107
+ };
108
+ return l && (h.initialize = () => this.initializeElement(a)), h;
109
+ });
110
+ }
74
111
  /**
75
112
  * Queries all main elements of a component that have not been initialized and extracts their data attributes.
76
113
  * @param {HTMLElement} context The context to query within.
@@ -78,12 +115,30 @@ const i = class i {
78
115
  * @param {Node} context Element to query elements from
79
116
  * @returns {Array<{element: HTMLElement, data: object, initialize: Function}>} An array of objects containing the elements, their data, and convenience function initialize() which when called will set the init attribute on the element
80
117
  */
81
- queryAllInitial(t, e, s = document) {
82
- return [...s.querySelectorAll(this.attributeSelectorInitial(t))].map((a) => ({
83
- element: a,
84
- data: e ? this.getData(a, t) : null,
85
- initialize: () => this.initializeElement(a)
86
- }));
118
+ queryAllInitial(t, e, i = document) {
119
+ return this.queryElements(
120
+ this.attributeSelectorInitial(t),
121
+ t,
122
+ e,
123
+ i,
124
+ !0
125
+ );
126
+ }
127
+ /**
128
+ * Queries all main elements of a component that have already been initialized and extracts their data attributes.
129
+ * @param {HTMLElement} context The context to query within.
130
+ * @param {Boolean} withData Include dataset from element (as optional JSON)
131
+ * @param {Node} context Element to query elements from
132
+ * @returns {Array<{element: HTMLElement, data: object}>} An array of objects containing the elements and their data
133
+ */
134
+ queryAllInitialized(t, e, i = document) {
135
+ return this.queryElements(
136
+ this.attributeSelectorInitialized(t),
137
+ t,
138
+ e,
139
+ i,
140
+ !1
141
+ );
87
142
  }
88
143
  /**
89
144
  * Sets the init attribute on an element, marking it as initialized.
@@ -97,8 +152,8 @@ const i = class i {
97
152
  * @return {*} The value of the dataset, if JSON will return object else will return string value or undefined
98
153
  */
99
154
  getData(t, e) {
100
- const s = d(this.getAttribute(e));
101
- return b(t, s);
155
+ const i = E(this.getAttribute(e));
156
+ return b(t, i);
102
157
  }
103
158
  /**
104
159
  * Will output namespaced console logs for the given initializer
@@ -119,16 +174,16 @@ const i = class i {
119
174
  console.error(this.logTitle, ...t);
120
175
  }
121
176
  };
122
- n(i, "defaults", {
177
+ o(s, "defaults", {
123
178
  type: null,
124
179
  baseAttribute: null
125
- }), n(i, "requiredOptions", [
180
+ }), o(s, "requiredOptions", [
126
181
  "type",
127
182
  "baseAttribute"
128
- ]), n(i, "hasRequiredOptions", p(
129
- i.requiredOptions
183
+ ]), o(s, "hasRequiredOptions", p(
184
+ s.requiredOptions
130
185
  ));
131
- let l = i;
186
+ let c = s;
132
187
  export {
133
- l as ComponentInitializer
188
+ c as ComponentInitializer
134
189
  };
@@ -1 +1 @@
1
- {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../lib/js/ui/grid.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH,8BAFW,MAAM,QAUhB;AApBD;;GAEG;AACH,+CAGG;qCATkC,sBAAsB"}
1
+ {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../lib/js/ui/grid.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH,8BAFW,MAAM,QAahB;AAvBD;;GAEG;AACH,+CAGG;qCATkC,sBAAsB"}
@@ -1,18 +1,21 @@
1
- import { ComponentInitializer as o } from "../core/component.js";
2
- import { setPositionClasses as n } from "../utils/dom.js";
3
- const r = new o({
1
+ import { ComponentInitializer as n } from "../core/component.js";
2
+ import { setPositionClasses as e } from "../utils/dom.js";
3
+ const r = new n({
4
4
  type: "grid",
5
5
  baseAttribute: "data-grid"
6
6
  });
7
- function p(i) {
7
+ function d(t) {
8
8
  r.init({
9
9
  coreEvents: ["pageModified", "pageResized"],
10
- setup({ element: t, initialize: e }) {
11
- n(t, i), e();
10
+ setup({ element: i, initialize: o }) {
11
+ e(i, t), o();
12
+ },
13
+ update({ element: i }) {
14
+ e(i, t);
12
15
  }
13
16
  });
14
17
  }
15
18
  export {
16
- p as init,
19
+ d as init,
17
20
  r as initializer
18
21
  };
@@ -17,8 +17,10 @@ export class OverflowScroller {
17
17
  nextEnabled: boolean;
18
18
  previousEnabled: boolean;
19
19
  scrollHandler: (e: any) => void;
20
+ updateHandler: () => void;
20
21
  checkOverflow(): void;
21
22
  hasOverflow: boolean | undefined;
23
+ update(): void;
22
24
  createControls(context: any): {
23
25
  controls: HTMLUListElement;
24
26
  previousItem: HTMLLIElement;
@@ -35,5 +37,6 @@ export class OverflowScroller {
35
37
  next(): void;
36
38
  previous(): void;
37
39
  getClass(child: any): string;
40
+ destroy(): void;
38
41
  }
39
42
  //# sourceMappingURL=overflow-scroller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"overflow-scroller.d.ts","sourceRoot":"","sources":["../../../lib/js/ui/overflow-scroller.js"],"names":[],"mappings":"AAmBA;IACE,wBAAsB;IACtB;;;;;;;;;;MAUC;IACD,wCAgBC;IAfC,aAAmE;IAKnE,cAGC;IACD,qBAAuB;IACvB,yBAA2B;IAC3B,gCAA4C;IAK9C,sBAGC;IADC,iCAAwD;IAE1D;;;;;;MA2BC;IACD,oDAQC;IACD,uCAMC;IACD,2BAGC;IACD,2BAiBC;IACD,8CAeC;IACD,6BAaC;IACD,aAMC;IACD,iBAMC;IACD,6BAGC;CACF"}
1
+ {"version":3,"file":"overflow-scroller.d.ts","sourceRoot":"","sources":["../../../lib/js/ui/overflow-scroller.js"],"names":[],"mappings":"AAoBA;IACE,wBAAsB;IACtB;;;;;;;;;;MAUC;IACD,wCAqBC;IApBC,aAAmE;IAKnE,cAGC;IACD,qBAAuB;IACvB,yBAA2B;IAC3B,gCAA4C;IAG5C,0BAAwC;IAO1C,sBAGC;IADC,iCAAwD;IAE1D,eAGC;IACD;;;;;;MA2BC;IACD,oDAQC;IACD,uCAMC;IACD,2BAOC;IACD,2BAiBC;IACD,8CAeC;IACD,6BAaC;IACD,aAMC;IACD,iBAMC;IACD,6BAGC;IACD,gBAOC;CACF"}
@@ -1,64 +1,72 @@
1
1
  var x = Object.defineProperty;
2
2
  var f = Object.getOwnPropertySymbols;
3
- var E = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable;
4
- var u = (i, s, t) => s in i ? x(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[s] = t, p = (i, s) => {
5
- for (var t in s || (s = {}))
6
- E.call(s, t) && u(i, t, s[t]);
3
+ var L = Object.prototype.hasOwnProperty, g = Object.prototype.propertyIsEnumerable;
4
+ var p = (i, e, t) => e in i ? x(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, m = (i, e) => {
5
+ for (var t in e || (e = {}))
6
+ L.call(e, t) && p(i, t, e[t]);
7
7
  if (f)
8
- for (var t of f(s))
9
- L.call(s, t) && u(i, t, s[t]);
8
+ for (var t of f(e))
9
+ g.call(e, t) && p(i, t, e[t]);
10
10
  return i;
11
11
  };
12
- var m = (i, s, t) => u(i, typeof s != "symbol" ? s + "" : s, t);
13
- import { wrapSettingString as v } from "../core/settings.js";
14
- import { hasRequiredProps as g } from "@ulu/utils/object.js";
15
- import { logError as C } from "../utils/class-logger.js";
16
- const S = [
12
+ var v = (i, e, t) => p(i, typeof e != "symbol" ? e + "" : e, t);
13
+ import { wrapSettingString as C } from "../core/settings.js";
14
+ import { hasRequiredProps as S } from "@ulu/utils/object.js";
15
+ import { logError as b } from "../utils/class-logger.js";
16
+ import { getCoreEventName as u } from "../core/events.js";
17
+ const k = [
17
18
  "track",
18
19
  "controls"
19
20
  ], c = class c {
20
- constructor(s, t) {
21
- this.options = Object.assign({}, c.defaults, t), g(S) || C(this, "Missing a required Element"), this.elements = p(p({}, s), this.createControls(s.controls)), this.nextEnabled = !0, this.previousEnabled = !0, this.scrollHandler = (e) => this.onScroll(e), this.elements.track.addEventListener("scroll", this.scrollHandler, { passive: !0 }), this.checkOverflow(), this.onScroll();
21
+ constructor(e, t) {
22
+ this.options = Object.assign({}, c.defaults, t), S(k) || b(this, "Missing a required Element"), this.elements = m(m({}, e), this.createControls(e.controls)), this.nextEnabled = !0, this.previousEnabled = !0, this.scrollHandler = (s) => this.onScroll(s), this.elements.track.addEventListener("scroll", this.scrollHandler, { passive: !0 }), this.updateHandler = () => this.update(), document.addEventListener(u("pageResized"), this.updateHandler), document.addEventListener(u("pageModified"), this.updateHandler), this.checkOverflow(), this.onScroll();
22
23
  }
23
24
  checkOverflow() {
24
- const { track: s } = this.elements;
25
- this.hasOverflow = s.scrollWidth > s.clientWidth;
25
+ const { track: e } = this.elements;
26
+ this.hasOverflow = e.scrollWidth > e.clientWidth;
26
27
  }
27
- createControls(s) {
28
- const t = document.createElement("ul"), e = document.createElement("li"), o = document.createElement("li"), n = this.createControlButton("previous"), l = this.createControlButton("next"), r = this.getClass("controls-item");
29
- return o.classList.add(r), o.classList.add(r + "--next"), e.classList.add(r), e.classList.add(r + "--previous"), t.classList.add(this.getClass("controls")), e.appendChild(n), o.appendChild(l), t.appendChild(e), t.appendChild(o), n.addEventListener("click", this.previous.bind(this)), l.addEventListener("click", this.next.bind(this)), s.appendChild(t), {
28
+ update() {
29
+ this.checkOverflow(), this.onScroll();
30
+ }
31
+ createControls(e) {
32
+ const t = document.createElement("ul"), s = document.createElement("li"), o = document.createElement("li"), n = this.createControlButton("previous"), l = this.createControlButton("next"), r = this.getClass("controls-item");
33
+ return o.classList.add(r), o.classList.add(r + "--next"), s.classList.add(r), s.classList.add(r + "--previous"), t.classList.add(this.getClass("controls")), s.appendChild(n), o.appendChild(l), t.appendChild(s), t.appendChild(o), n.addEventListener("click", this.previous.bind(this)), l.addEventListener("click", this.next.bind(this)), e.appendChild(t), {
30
34
  controls: t,
31
- previousItem: e,
35
+ previousItem: s,
32
36
  nextItem: o,
33
37
  previous: n,
34
38
  next: l
35
39
  };
36
40
  }
37
- createControlButton(s) {
41
+ createControlButton(e) {
38
42
  const t = document.createElement("button");
39
- return t.classList.add(this.getClass("control-button")), t.classList.add(this.getClass(`control-button--${s}`)), t.classList.add(...this.options.buttonClasses), t.setAttribute("type", "button"), t.innerHTML = this.getControlContent(s), t;
43
+ return t.classList.add(this.getClass("control-button")), t.classList.add(this.getClass(`control-button--${e}`)), t.classList.add(...this.options.buttonClasses), t.setAttribute("type", "button"), t.innerHTML = this.getControlContent(e), t;
40
44
  }
41
- getControlContent(s) {
42
- const t = this.options[s === "next" ? "iconClassNext" : "iconClassPrevious"];
45
+ getControlContent(e) {
46
+ const t = this.options[e === "next" ? "iconClassNext" : "iconClassPrevious"];
43
47
  return `
44
- <span class="hidden-visually">${s}</span>
48
+ <span class="hidden-visually">${e}</span>
45
49
  <span class="${t}" aria-hidden="true"></span>
46
50
  `;
47
51
  }
48
- onScroll(s) {
49
- this.hasOverflow && this.onScrollHorizontal();
52
+ onScroll(e) {
53
+ if (!this.hasOverflow) {
54
+ this.setControlState("previous", !1), this.setControlState("next", !1);
55
+ return;
56
+ }
57
+ this.onScrollHorizontal();
50
58
  }
51
59
  onScrollHorizontal() {
52
- const { nextEnabled: s, previousEnabled: t } = this, { track: e } = this.elements, { offsetStart: o, offsetEnd: n } = this.options, { scrollWidth: l, clientWidth: r, scrollLeft: d } = e, a = d <= o, h = l - d - n <= r;
53
- a && t ? this.setControlState("previous", !1) : !a && !t && this.setControlState("previous", !0), h && s ? this.setControlState("next", !1) : !h && !s && this.setControlState("next", !0);
60
+ const { nextEnabled: e, previousEnabled: t } = this, { track: s } = this.elements, { offsetStart: o, offsetEnd: n } = this.options, { scrollWidth: l, clientWidth: r, scrollLeft: d } = s, a = d <= o, h = l - d - n <= r;
61
+ a && t ? this.setControlState("previous", !1) : !a && !t && this.setControlState("previous", !0), h && e ? this.setControlState("next", !1) : !h && !e && this.setControlState("next", !0);
54
62
  }
55
- setControlState(s, t) {
56
- const e = s === "next", { next: o, nextItem: n, previous: l, previousItem: r } = this.elements, d = e ? n : r, a = e ? o : l, h = t ? "remove" : "add";
57
- d.classList[h](this.getClass("controls-item--disabled")), a.classList[t ? "remove" : "add"](this.getClass("control--disabled")), t ? a.removeAttribute("disabled") : a.setAttribute("disabled", ""), this[e ? "nextEnabled" : "previousEnabled"] = t;
63
+ setControlState(e, t) {
64
+ const s = e === "next", { next: o, nextItem: n, previous: l, previousItem: r } = this.elements, d = s ? n : r, a = s ? o : l, h = t ? "remove" : "add";
65
+ d.classList[h](this.getClass("controls-item--disabled")), a.classList[t ? "remove" : "add"](this.getClass("control--disabled")), t ? a.removeAttribute("disabled") : a.setAttribute("disabled", ""), this[s ? "nextEnabled" : "previousEnabled"] = t;
58
66
  }
59
- resolveAmount(s) {
60
- const t = s === "next", { amount: e } = this.options, { scrollLeft: o, offsetWidth: n } = this.elements.track;
61
- return e === "auto" ? t ? o + n : o - n : typeof e == "function" ? e(this, s) : typeof e == "number" ? t ? o + e : o - e : (C("Unable to resolve amount for scroll"), 500);
67
+ resolveAmount(e) {
68
+ const t = e === "next", { amount: s } = this.options, { scrollLeft: o, offsetWidth: n } = this.elements.track;
69
+ return s === "auto" ? t ? o + n : o - n : typeof s == "function" ? s(this, e) : typeof s == "number" ? t ? o + s : o - s : (b("Unable to resolve amount for scroll"), 500);
62
70
  }
63
71
  next() {
64
72
  this.elements.track.scrollTo({
@@ -74,12 +82,15 @@ const S = [
74
82
  behavior: "smooth"
75
83
  });
76
84
  }
77
- getClass(s) {
85
+ getClass(e) {
78
86
  const { namespace: t } = this.options;
79
- return `${t}__${s}`;
87
+ return `${t}__${e}`;
88
+ }
89
+ destroy() {
90
+ this.elements.track.removeEventListener("scroll", this.scrollHandler), document.removeEventListener(u("pageResized"), this.updateHandler), document.removeEventListener(u("pageModified"), this.updateHandler), this.elements.controls && this.elements.controls.parentNode && this.elements.controls.parentNode.removeChild(this.elements.controls);
80
91
  }
81
92
  };
82
- m(c, "instances", []), m(c, "defaults", {
93
+ v(c, "instances", []), v(c, "defaults", {
83
94
  namespace: "OverflowScroller",
84
95
  events: {},
85
96
  horizontal: !0,
@@ -87,10 +98,10 @@ m(c, "instances", []), m(c, "defaults", {
87
98
  offsetEnd: 100,
88
99
  amount: "auto",
89
100
  buttonClasses: ["button", "button--icon"],
90
- iconClassPrevious: v("iconClassPrevious"),
91
- iconClassNext: v("iconClassNext")
101
+ iconClassPrevious: C("iconClassPrevious"),
102
+ iconClassNext: C("iconClassNext")
92
103
  });
93
- let b = c;
104
+ let E = c;
94
105
  export {
95
- b as OverflowScroller
106
+ E as OverflowScroller
96
107
  };
@@ -4,6 +4,13 @@
4
4
  * @returns {string} - The dataset property name (e.g., "uluDialog").
5
5
  */
6
6
  export function dataAttributeToDatasetKey(attribute: any): string;
7
+ /**
8
+ * Groups a parent's children into rows based on their visual coordinates (top and left positions).
9
+ * Filters out hidden elements and sorts them visually to support CSS grid order properties.
10
+ * @param {HTMLElement} parent The grid/parent container
11
+ * @returns {HTMLElement[][]} A 2D array of rows, where each row is an array of elements in visual order.
12
+ */
13
+ export function getVisualRows(parent: HTMLElement): HTMLElement[][];
7
14
  /**
8
15
  * Sets up the positional classes that would come from the equal
9
16
  * height module. Needs to be rerun by user when layout changes
@@ -1 +1 @@
1
- {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../lib/js/utils/dom.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,2DAFa,MAAM,CAIlB;AAED;;;;;;;;;GASG;AACH,2CAHa,IAAI,YACJ,MAAM,QAmClB;AAED;;;;;;;;GAQG;AACH,8CANa,MAAM,EAAE,CAiBpB"}
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../lib/js/utils/dom.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,2DAFa,MAAM,CAIlB;AAED;;;;;GAKG;AACH,sCAHW,WAAW,GACT,WAAW,EAAE,EAAE,CAqC3B;AAED;;;;;;;;;GASG;AACH,2CAHa,IAAI,YACJ,MAAM,QA0BlB;AAED;;;;;;;;GAQG;AACH,8CANa,MAAM,EAAE,CAiBpB"}
@@ -1,29 +1,36 @@
1
- import { kebabToCamel as f } from "@ulu/utils/string.js";
1
+ import { kebabToCamel as l } from "@ulu/utils/string.js";
2
+ function u(t) {
3
+ return l(t.replace(/^data-/, ""));
4
+ }
2
5
  function c(t) {
3
- return f(t.replace(/^data-/, ""));
6
+ const s = [...t.children].map((e) => ({ child: e, rect: e.getBoundingClientRect() })).filter((e) => e.rect.width !== 0 || e.rect.height !== 0);
7
+ if (s.length === 0)
8
+ return [];
9
+ s.sort((e, i) => Math.abs(e.rect.top - i.rect.top) > 1 ? e.rect.top - i.rect.top : e.rect.left - i.rect.left);
10
+ const o = [];
11
+ let r = null;
12
+ return s.forEach(({ child: e, rect: i }) => {
13
+ (r === null || Math.abs(i.top - r) > 1) && (o.push([]), r = i.top), o[o.length - 1].push(e);
14
+ }), o;
4
15
  }
5
- function p(t, o = {
16
+ function f(t, n = {
6
17
  columnFirst: "position-column-first",
7
18
  columnLast: "position-column-last",
8
19
  rowFirst: "position-row-first",
9
20
  rowLast: "position-row-last"
10
21
  }) {
11
- const l = [...t.children], n = [];
12
- let e;
13
- l.forEach((r) => {
14
- const s = r.getBoundingClientRect().y;
15
- e !== s && n.push([]), n[n.length - 1].push(r), e = s, r.classList.remove(...Object.values(o));
16
- }), n.forEach((r, s) => {
17
- s === 0 && r.forEach((i) => i.classList.add(o.rowFirst)), s == n.length - 1 && r.forEach((i) => i.classList.add(o.rowLast)), r.forEach((i, a) => {
18
- a === 0 && i.classList.add(o.columnFirst), a == r.length - 1 && i.classList.add(o.columnLast);
19
- });
20
- });
22
+ [...t.children].forEach((r) => r.classList.remove(...Object.values(n)));
23
+ const o = c(t);
24
+ o.length !== 0 && (o[0].forEach((r) => r.classList.add(n.rowFirst)), o[o.length - 1].forEach((r) => r.classList.add(n.rowLast)), o.forEach((r) => {
25
+ r[0].classList.add(n.columnFirst), r[r.length - 1].classList.add(n.columnLast);
26
+ }));
21
27
  }
22
- function m(t) {
23
- return typeof t == "string" ? t.split(" ").filter((o) => o !== "") : Array.isArray(t) ? t : t ? (console.warn("resolveClassArray: Invalid class input type.", t), []) : [];
28
+ function h(t) {
29
+ return typeof t == "string" ? t.split(" ").filter((n) => n !== "") : Array.isArray(t) ? t : t ? (console.warn("resolveClassArray: Invalid class input type.", t), []) : [];
24
30
  }
25
31
  export {
26
- c as dataAttributeToDatasetKey,
27
- m as resolveClasses,
28
- p as setPositionClasses
32
+ u as dataAttributeToDatasetKey,
33
+ c as getVisualRows,
34
+ h as resolveClasses,
35
+ f as setPositionClasses
29
36
  };