jqx-es 1.2.7 → 1.2.9
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/Bundle/jqx.browser.min.js +14 -14
- package/Bundle/jqx.min.js +14 -14
- package/Resource/Common/DOM.js +2 -5
- package/Resource/Common/DOMCleanup.js +1 -2
- package/Resource/Common/Popup.js +21 -4
- package/Resource/Common/Utilities.js +196 -2
- package/Resource/Common/WebComponentFactory.min.js +11 -0
- package/Resource/Common/cright.css +40 -0
- package/Resource/Common/css.min.js +31 -0
- package/Resource/Common/highlight.min.js +418 -0
- package/Resource/Common/javascript.min.js +81 -0
- package/Resource/Common/rainbow.min.css +1 -0
- package/Resource/Common/xml.min.js +29 -0
- package/package.json +1 -1
- package/src/JQxConstructorFactory.js +2 -2
- package/src/JQxCreatorFactory.js +4 -7
- package/src/JQxInstanceMethods.js +8 -11
- package/src/JQxUtilities.js +11 -191
package/src/JQxCreatorFactory.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { cleanupHtml } from "../Resource/Common/DOM.js";
|
|
2
|
-
import allMethodsFactory from "./JQxInstanceMethods.js";
|
|
3
|
-
import PopupFactory from "../Resource/Common/Popup.js";
|
|
4
|
-
import { listeners, default as HandleFactory } from "../Resource/Common/HandlerFactory.js";
|
|
5
|
-
import tagLib from "../Resource/Common/HTMLTags.js";
|
|
6
1
|
import {
|
|
7
|
-
randomString, toDashedNotation, IS, tagFNFactory as $T, styleFactory, toCamelcase, systemLog,
|
|
8
|
-
isNonEmptyString, resolveEventTypeParameter, selectedFactoryHelpers, insertPositions
|
|
2
|
+
randomString, toDashedNotation, IS, tagFNFactory as $T, styleFactory, toCamelcase, systemLog,
|
|
3
|
+
escHtml, isNonEmptyString, resolveEventTypeParameter, selectedFactoryHelpers, insertPositions,
|
|
4
|
+
cleanupHtml, PopupFactory, tagLib, listeners, HandleFactory,
|
|
9
5
|
} from "./JQxUtilities.js";
|
|
6
|
+
import allMethodsFactory from "./JQxInstanceMethods.js";
|
|
10
7
|
|
|
11
8
|
let instanceGetters, instanceMethods;
|
|
12
9
|
const {
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import {createElementFromHtmlString, inject2DOMTree} from "../Resource/Common/DOM.js";
|
|
2
1
|
import {
|
|
3
2
|
IS, isNode, truncateHtmlStr, addHandlerId, ExamineElementFeatureFactory,
|
|
4
3
|
isNonEmptyString, toDashedNotation, escHtml, systemLog, insertPositions,
|
|
5
4
|
datasetKeyProxy, loop, cloneAndDestroy, setData, before, after,
|
|
6
5
|
findParentScrollDistance, emptyElement, checkProp, css, assignAttrValues,
|
|
7
|
-
applyStyle,
|
|
6
|
+
applyStyle, createElementFromHtmlString, inject2DOMTree,
|
|
8
7
|
} from "./JQxUtilities.js";
|
|
9
8
|
|
|
10
9
|
const instanceIs = ExamineElementFeatureFactory();
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
export default function(jqx) {
|
|
12
|
+
return {
|
|
13
|
+
factoryExtensions: factoryExtensionsFactory(jqx),
|
|
14
|
+
instanceExtensions: instanceExtensionsFactory(jqx),
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
13
18
|
function factoryExtensionsFactory(jqx) {
|
|
14
19
|
return {
|
|
15
20
|
data: instance => ({
|
|
@@ -510,11 +515,3 @@ function instanceExtensionsFactory(jqx) {
|
|
|
510
515
|
},
|
|
511
516
|
};
|
|
512
517
|
}
|
|
513
|
-
|
|
514
|
-
/* endregion exportfunctions */
|
|
515
|
-
export default function(jqx) {
|
|
516
|
-
return {
|
|
517
|
-
factoryExtensions: factoryExtensionsFactory(jqx),
|
|
518
|
-
instanceExtensions: instanceExtensionsFactory(jqx),
|
|
519
|
-
}
|
|
520
|
-
};
|
package/src/JQxUtilities.js
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const datasetKeyProxy = Object.freeze({
|
|
11
|
-
get(obj, key) { return obj[toCamelcase(key)] || obj[key]; },
|
|
12
|
-
enumerable: false,
|
|
13
|
-
configurable: false
|
|
14
|
-
});
|
|
15
|
-
const insertPositions = Object.freeze(new Proxy({
|
|
16
|
-
start: "afterbegin", afterbegin: "afterbegin",
|
|
17
|
-
end: "beforeend", beforeend: "beforeend",
|
|
18
|
-
before: "beforebegin", beforebegin: "beforebegin",
|
|
19
|
-
after: "afterend", afterend: "afterend" }, {
|
|
20
|
-
get(obj, key) { return obj[String(key).toLowerCase()] ?? obj[key]; }
|
|
21
|
-
}));
|
|
1
|
+
import {
|
|
2
|
+
after, applyStyle, assignAttrValues, before, checkProp, cloneAndDestroy, datasetKeyProxy,
|
|
3
|
+
ElemArray2HtmlString, emptyElement, escHtml, findParentScrollDistance, input2Collection, insertPositions,
|
|
4
|
+
IS, isArrayOfHtmlElements, isArrayOfHtmlStrings, isComment, isCommentOrTextNode, isHtmlString, isModal,
|
|
5
|
+
isNode, isNonEmptyString, isText, isVisible, isWritable, logTime, maybe, randomNr, randomString,
|
|
6
|
+
resolveEventTypeParameter, setData, styleFactory, systemLog, tagFNFactory, toCamelcase, toDashedNotation,
|
|
7
|
+
truncate2SingleStr, truncateHtmlStr, createElementFromHtmlString, inject2DOMTree, cleanupHtml,
|
|
8
|
+
PopupFactory, tagLib, listeners, HandleFactory,
|
|
9
|
+
} from "../Resource/Common/Utilities.js"
|
|
22
10
|
|
|
23
11
|
export {
|
|
24
12
|
addHandlerId, after, applyStyle, assignAttrValues, before, checkProp, cloneAndDestroy, css, datasetKeyProxy,
|
|
@@ -26,21 +14,10 @@ export {
|
|
|
26
14
|
input2Collection, insertPositions, IS, isArrayOfHtmlElements, isArrayOfHtmlStrings, isCommentOrTextNode,
|
|
27
15
|
isHtmlString, isNode, isNonEmptyString, logTime, loop, maybe, randomNr, randomString, resolveEventTypeParameter,
|
|
28
16
|
selectedFactoryHelpers, setCollectionFromCssSelector, setData, styleFactory, systemLog, tagFNFactory,
|
|
29
|
-
toCamelcase, toDashedNotation, truncate2SingleStr, truncateHtmlStr,
|
|
17
|
+
toCamelcase, toDashedNotation, truncate2SingleStr, truncateHtmlStr, createElementFromHtmlString, inject2DOMTree,
|
|
18
|
+
cleanupHtml, PopupFactory, tagLib, HandleFactory, listeners
|
|
30
19
|
};
|
|
31
20
|
|
|
32
|
-
function randomNr(max, min = 0) {
|
|
33
|
-
[max, min] = [Math.floor(max), Math.ceil(min)];
|
|
34
|
-
return Math.floor( ([...crypto.getRandomValues(new Uint32Array(1))].shift() / 2 ** 32 ) * (max - min + 1) + min );
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function resolveEventTypeParameter (maybeTypes) {
|
|
38
|
-
maybeTypes = IS(maybeTypes, String) && /,/.test(maybeTypes) ? maybeTypes.split(`,`) : maybeTypes;
|
|
39
|
-
return IS(maybeTypes, Array)
|
|
40
|
-
? maybeTypes.filter(t => isNonEmptyString(t)).map(t => t.trim().toLowerCase())
|
|
41
|
-
: IS(maybeTypes, String) && maybeTypes?.trim().toLowerCase() || ``;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
21
|
function loop(instance, callback) {
|
|
45
22
|
const cleanCollection = instance.collection.filter(el => !isCommentOrTextNode(el));
|
|
46
23
|
for (let i = 0; i < cleanCollection.length; i += 1) {
|
|
@@ -50,76 +27,6 @@ function loop(instance, callback) {
|
|
|
50
27
|
return instance;
|
|
51
28
|
}
|
|
52
29
|
|
|
53
|
-
function shuffle(array) {
|
|
54
|
-
let i = array.length;
|
|
55
|
-
while (i--) {
|
|
56
|
-
const ri = randomNr(i);
|
|
57
|
-
[array[i], array[ri]] = [array[ri], array[i]];
|
|
58
|
-
}
|
|
59
|
-
return array;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function toDashedNotation(str2Convert) {
|
|
63
|
-
return str2Convert.replace(/[A-Z]/g, a => `-${a.toLowerCase()}`).replace(/^-|-$/, ``);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function ucFirst([first, ...theRest]) {
|
|
67
|
-
return `${first.toUpperCase()}${theRest.join(``)}`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function toCamelcase(str2Convert) {
|
|
71
|
-
return IS(str2Convert, String)
|
|
72
|
-
? str2Convert.toLowerCase()
|
|
73
|
-
.split(`-`)
|
|
74
|
-
.map( (str, i) => i && `${ucFirst(str)}` || str)
|
|
75
|
-
.join(``)
|
|
76
|
-
: str2Convert;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function randomString() {
|
|
80
|
-
return `_${shuffle(characters4RandomString).slice(0, 8).join(``)}`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function isCommentOrTextNode(node) {
|
|
84
|
-
return IS(node, Comment, Text);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function isComment(input) {
|
|
88
|
-
IS(input, Comment);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function isText(input) {
|
|
92
|
-
return IS(input, Text);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function isHtmlString(input) {
|
|
96
|
-
return IS(input, String) && /^<|>$/.test(`${input}`.trim());
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function isArrayOfHtmlElements(input) {
|
|
100
|
-
return IS(input, Array) && !input?.find(el => !isNode(el));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function isArrayOfHtmlStrings(input) {
|
|
104
|
-
return IS(input, Array) && !input?.find(s => !isHtmlString(s));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function ElemArray2HtmlString(elems) {
|
|
108
|
-
return elems?.filter(el => el).reduce((acc, el) =>
|
|
109
|
-
acc.concat(isComment(el) ? `<!--${el.data}-->`
|
|
110
|
-
: isCommentOrTextNode(el) ? el.textContent
|
|
111
|
-
: el.outerHTML), ``);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function input2Collection(input) {
|
|
115
|
-
return !input ? []
|
|
116
|
-
: IS(input, Proxy) ? [input.EL]
|
|
117
|
-
: IS(input, NodeList) ? [...input]
|
|
118
|
-
: isNode(input) ? [input]
|
|
119
|
-
: isArrayOfHtmlElements(input) ? input
|
|
120
|
-
: input.isJQx ? input.collection : undefined;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
30
|
function setCollectionFromCssSelector(input, root, self) {
|
|
124
31
|
const selectorRoot = root !== document.body && (IS(input, String) && input.toLowerCase() !== "body") ? root : document;
|
|
125
32
|
let errorStr = undefined;
|
|
@@ -145,26 +52,6 @@ function selectedFactoryHelpers() {
|
|
|
145
52
|
addHandlerId, cssRuleEdit: styleFactory({createWithId: `JQxStylesheet`}) };
|
|
146
53
|
}
|
|
147
54
|
|
|
148
|
-
function isVisible(el) {
|
|
149
|
-
if (!el) { return undefined; }
|
|
150
|
-
const elStyle = el.style;
|
|
151
|
-
const computedStyle = getComputedStyle(el);
|
|
152
|
-
const invisible = [elStyle.visibility, computedStyle.visibility].includes("hidden");
|
|
153
|
-
const noDisplay = [elStyle.display, computedStyle.display].includes("none");
|
|
154
|
-
const offscreen = el.offsetTop < 0 || (el.offsetLeft + el.offsetWidth) < 0
|
|
155
|
-
|| el.offsetLeft > document.body.offsetWidth;
|
|
156
|
-
const noOpacity = +computedStyle.opacity === 0 || +(elStyle.opacity || 1) === 0;
|
|
157
|
-
return !(offscreen || noOpacity || noDisplay || invisible);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function isWritable(elem) {
|
|
161
|
-
return [...elem.parentNode.querySelectorAll(`:is(:read-write)`)]?.find(el => el === elem) ?? false;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function isModal(elem) {
|
|
165
|
-
return [...elem.parentNode.querySelectorAll(`:is(:modal)`)]?.find(el => el === elem) ?? false;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
55
|
function ExamineElementFeatureFactory() {
|
|
169
56
|
const notApplicable = `n/a`;
|
|
170
57
|
const noElements = Object.freeze({
|
|
@@ -205,44 +92,6 @@ function ExamineElementFeatureFactory() {
|
|
|
205
92
|
};
|
|
206
93
|
}
|
|
207
94
|
|
|
208
|
-
function cloneAndDestroy(elem) {
|
|
209
|
-
const cloned = elem.cloneNode(true)
|
|
210
|
-
cloned.removeAttribute && cloned.removeAttribute(`id`);
|
|
211
|
-
elem.isConnected ? elem.remove() : elem = null;
|
|
212
|
-
return cloned;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function setData(el, keyValuePairs) {
|
|
216
|
-
if (el && IS(keyValuePairs, Object)) {
|
|
217
|
-
for (const [key, value] of Object.entries(keyValuePairs)) {
|
|
218
|
-
el.setAttribute(`data-${toDashedNotation(key)}`, value);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function before (instance, elem2AddBefore) {
|
|
224
|
-
return instance.andThen(elem2AddBefore, true);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function after(instance, elem2AddAfter) {
|
|
228
|
-
return instance.andThen(elem2AddAfter);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function findParentScrollDistance(node, distance = 0, top = true) {
|
|
232
|
-
node = node?.parentElement;
|
|
233
|
-
const what = top ? `scrollTop` : `scrollLeft`;
|
|
234
|
-
distance += node ? node[what] : 0;
|
|
235
|
-
return !node ? distance : findParentScrollDistance(node, distance, top);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function emptyElement(el) {
|
|
239
|
-
return el && (el.textContent = "");
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function checkProp(prop) {
|
|
243
|
-
return prop.startsWith(`data`) || ATTRS.html.find(attr => prop.toLowerCase() === attr);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
95
|
function css(el, keyOrKvPairs, value, jqx) {
|
|
247
96
|
if (value && IS(keyOrKvPairs, String)) {
|
|
248
97
|
keyOrKvPairs = {[keyOrKvPairs]: value === "-" ? "" : value};
|
|
@@ -260,32 +109,3 @@ function css(el, keyOrKvPairs, value, jqx) {
|
|
|
260
109
|
jqx.editCssRule(`.${nwClass}`, keyOrKvPairs);
|
|
261
110
|
el.classList.add(nwClass);
|
|
262
111
|
}
|
|
263
|
-
|
|
264
|
-
function assignAttrValues(/*NODOC*/el, keyValuePairs) {
|
|
265
|
-
if (el) {
|
|
266
|
-
for (let [key, value] of Object.entries(keyValuePairs)) {
|
|
267
|
-
key = toDashedNotation(key);
|
|
268
|
-
if (key.startsWith(`data`)) {
|
|
269
|
-
return setData(el, value);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (IS(value, String) && checkProp(key)) {
|
|
273
|
-
el.setAttribute(key, value.split(/[, ]/)?.join(` `));
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function applyStyle(el, rules) {
|
|
280
|
-
if (IS(rules, Object)) {
|
|
281
|
-
for (let [key, value] of Object.entries(rules)) {
|
|
282
|
-
let priority;
|
|
283
|
-
if (/!important/i.test(value)) {
|
|
284
|
-
value = value.slice(0, value.indexOf(`!`)).trim();
|
|
285
|
-
priority = 'important';
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
el.style.setProperty(toDashedNotation(key), value, priority)
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|