@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.
- package/dist/es/core/component.d.ts +40 -1
- package/dist/es/core/component.d.ts.map +1 -1
- package/dist/es/core/component.js +83 -28
- package/dist/es/ui/grid.d.ts.map +1 -1
- package/dist/es/ui/grid.js +10 -7
- package/dist/es/ui/overflow-scroller.d.ts +3 -0
- package/dist/es/ui/overflow-scroller.d.ts.map +1 -1
- package/dist/es/ui/overflow-scroller.js +52 -41
- package/dist/es/utils/dom.d.ts +7 -0
- package/dist/es/utils/dom.d.ts.map +1 -1
- package/dist/es/utils/dom.js +25 -18
- package/dist/mcp-data.json +528 -305
- package/dist/umd/ulu-frontend.umd.js +10 -10
- package/lib/js/core/component.js +70 -8
- package/lib/js/ui/grid.js +3 -0
- package/lib/js/ui/overflow-scroller.js +24 -2
- package/lib/js/utils/dom.js +62 -28
- package/lib/scss/components/_card-grid.demo.html +35 -21
- package/package.json +1 -1
|
@@ -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:
|
|
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
|
|
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
|
|
2
|
-
var
|
|
3
|
-
var
|
|
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
|
|
7
|
-
import { getCoreEventName as
|
|
8
|
-
const
|
|
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 (!
|
|
16
|
+
if (!s.hasRequiredOptions(t))
|
|
17
17
|
throw new Error(
|
|
18
|
-
`Missing a required options: ${
|
|
18
|
+
`Missing a required options: ${s.requiredOptions.join(", ")}`
|
|
19
19
|
);
|
|
20
|
-
this.options = Object.assign({},
|
|
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((
|
|
35
|
-
const
|
|
36
|
-
|
|
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:
|
|
49
|
-
this.queryAllInitial(
|
|
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,
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
|
101
|
-
return b(t,
|
|
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
|
-
|
|
177
|
+
o(s, "defaults", {
|
|
123
178
|
type: null,
|
|
124
179
|
baseAttribute: null
|
|
125
|
-
}),
|
|
180
|
+
}), o(s, "requiredOptions", [
|
|
126
181
|
"type",
|
|
127
182
|
"baseAttribute"
|
|
128
|
-
]),
|
|
129
|
-
|
|
183
|
+
]), o(s, "hasRequiredOptions", p(
|
|
184
|
+
s.requiredOptions
|
|
130
185
|
));
|
|
131
|
-
let
|
|
186
|
+
let c = s;
|
|
132
187
|
export {
|
|
133
|
-
|
|
188
|
+
c as ComponentInitializer
|
|
134
189
|
};
|
package/dist/es/ui/grid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../lib/js/ui/grid.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH,8BAFW,MAAM,
|
|
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"}
|
package/dist/es/ui/grid.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { ComponentInitializer as
|
|
2
|
-
import { setPositionClasses as
|
|
3
|
-
const r = new
|
|
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
|
|
7
|
+
function d(t) {
|
|
8
8
|
r.init({
|
|
9
9
|
coreEvents: ["pageModified", "pageResized"],
|
|
10
|
-
setup({ element:
|
|
11
|
-
|
|
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
|
-
|
|
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":"
|
|
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
|
|
4
|
-
var
|
|
5
|
-
for (var t in
|
|
6
|
-
|
|
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(
|
|
9
|
-
|
|
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
|
|
13
|
-
import { wrapSettingString as
|
|
14
|
-
import { hasRequiredProps as
|
|
15
|
-
import { logError as
|
|
16
|
-
|
|
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(
|
|
21
|
-
this.options = Object.assign({}, c.defaults, t),
|
|
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:
|
|
25
|
-
this.hasOverflow =
|
|
25
|
+
const { track: e } = this.elements;
|
|
26
|
+
this.hasOverflow = e.scrollWidth > e.clientWidth;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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:
|
|
35
|
+
previousItem: s,
|
|
32
36
|
nextItem: o,
|
|
33
37
|
previous: n,
|
|
34
38
|
next: l
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
|
-
createControlButton(
|
|
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--${
|
|
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(
|
|
42
|
-
const t = this.options[
|
|
45
|
+
getControlContent(e) {
|
|
46
|
+
const t = this.options[e === "next" ? "iconClassNext" : "iconClassPrevious"];
|
|
43
47
|
return `
|
|
44
|
-
<span class="hidden-visually">${
|
|
48
|
+
<span class="hidden-visually">${e}</span>
|
|
45
49
|
<span class="${t}" aria-hidden="true"></span>
|
|
46
50
|
`;
|
|
47
51
|
}
|
|
48
|
-
onScroll(
|
|
49
|
-
this.hasOverflow
|
|
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:
|
|
53
|
-
a && t ? this.setControlState("previous", !1) : !a && !t && this.setControlState("previous", !0), h &&
|
|
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(
|
|
56
|
-
const
|
|
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[
|
|
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(
|
|
60
|
-
const t =
|
|
61
|
-
return
|
|
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(
|
|
85
|
+
getClass(e) {
|
|
78
86
|
const { namespace: t } = this.options;
|
|
79
|
-
return `${t}__${
|
|
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
|
-
|
|
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:
|
|
91
|
-
iconClassNext:
|
|
101
|
+
iconClassPrevious: C("iconClassPrevious"),
|
|
102
|
+
iconClassNext: C("iconClassNext")
|
|
92
103
|
});
|
|
93
|
-
let
|
|
104
|
+
let E = c;
|
|
94
105
|
export {
|
|
95
|
-
|
|
106
|
+
E as OverflowScroller
|
|
96
107
|
};
|
package/dist/es/utils/dom.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/es/utils/dom.js
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
|
-
import { kebabToCamel as
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
23
|
-
return typeof t == "string" ? t.split(" ").filter((
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
u as dataAttributeToDatasetKey,
|
|
33
|
+
c as getVisualRows,
|
|
34
|
+
h as resolveClasses,
|
|
35
|
+
f as setPositionClasses
|
|
29
36
|
};
|