jqx-es 1.2.6 → 1.2.8
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/{src → Resource/Common}/DOM.js +2 -5
- package/{src → Resource/Common}/DOMCleanup.js +1 -2
- package/{src → Resource/Common}/Popup.js +1 -1
- package/{src → Resource/Common}/Utilities.js +177 -260
- package/{src → Resource/Common}/tinyDOM.js +1 -2
- package/index.js +2 -79
- package/package.json +1 -1
- package/src/JQxConstructorFactory.js +78 -0
- package/src/{JQxFactory.js → JQxCreatorFactory.js} +6 -9
- package/src/{JQxMethods.js → JQxInstanceMethods.js} +11 -13
- package/src/JQxUtilities.js +111 -0
- /package/{src → Resource/Common}/EmbedResources.js +0 -0
- /package/{src → Resource/Common}/HTMLTags.js +0 -0
- /package/{src → Resource/Common}/HandlerFactory.js +0 -0
- /package/{src → Resource/Common}/LifeCSS.js +0 -0
- /package/{src → Resource/Common}/TypeofAnything.js +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { proxify, addJQxStaticMethods } from "./JQxCreatorFactory.js";
|
|
2
|
+
import {
|
|
3
|
+
isHtmlString, truncateHtmlStr, isArrayOfHtmlStrings, isArrayOfHtmlElements,
|
|
4
|
+
ElemArray2HtmlString, input2Collection, setCollectionFromCssSelector,
|
|
5
|
+
IS, systemLog, insertPositions, inject2DOMTree, createElementFromHtmlString
|
|
6
|
+
} from "./JQxUtilities.js";
|
|
7
|
+
|
|
8
|
+
export default addJQxStaticMethods(JQxMainFactory());
|
|
9
|
+
|
|
10
|
+
function JQxMainFactory() {
|
|
11
|
+
const logLineLength = 70;
|
|
12
|
+
|
|
13
|
+
return function(input, root, position = insertPositions.BeforeEnd) {
|
|
14
|
+
if (input?.isJQx) { return input; }
|
|
15
|
+
const isVirtual = IS(root, HTMLBRElement);
|
|
16
|
+
root = (!isVirtual && root && root.isJQx ? root[0] : root) || document.body;
|
|
17
|
+
position = position && Object.values(insertPositions).find(pos => position === pos) ? position : undefined;
|
|
18
|
+
const isRawHtml = isHtmlString(input);
|
|
19
|
+
const isRawHtmlArray = !isRawHtml && isArrayOfHtmlStrings(input);
|
|
20
|
+
const shouldCreateElements = isRawHtmlArray || isRawHtml;
|
|
21
|
+
|
|
22
|
+
let instance = {
|
|
23
|
+
collection: input2Collection(input) ?? [],
|
|
24
|
+
isVirtual,
|
|
25
|
+
isJQx: true,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const isRawElemCollection = isArrayOfHtmlElements(instance.collection);
|
|
29
|
+
|
|
30
|
+
const logStr = `JQx: input => ${
|
|
31
|
+
isRawHtmlArray
|
|
32
|
+
? `"${truncateHtmlStr(input.join(`, `), logLineLength)}"`
|
|
33
|
+
: !shouldCreateElements && isRawElemCollection ? `element collection [${
|
|
34
|
+
truncateHtmlStr( instance.collection.map(el => `${
|
|
35
|
+
IS(el, Comment, Text) ? `Comment|Text @` : ``} ${
|
|
36
|
+
el?.outerHTML || el?.textContent}`).join(`, `), logLineLength)}]`
|
|
37
|
+
: `"${truncateHtmlStr(input, logLineLength)}"`}`;
|
|
38
|
+
|
|
39
|
+
if (instance.collection.length && isRawElemCollection) {
|
|
40
|
+
systemLog.log(logStr);
|
|
41
|
+
|
|
42
|
+
if (!isVirtual) {
|
|
43
|
+
instance.collection.forEach(el => {
|
|
44
|
+
if (!root.contains(el)) {
|
|
45
|
+
inject2DOMTree([el], root, position);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return proxify(instance);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (shouldCreateElements) {
|
|
54
|
+
[input].flat().forEach(htmlStringOrComment =>
|
|
55
|
+
instance.collection.push(createElementFromHtmlString(htmlStringOrComment)));
|
|
56
|
+
|
|
57
|
+
if (instance.collection.length > 0) {
|
|
58
|
+
const errors = instance.collection.filter( el => el?.dataset?.jqxcreationerror );
|
|
59
|
+
instance.collection = instance.collection.filter(el => !el?.dataset?.jqxcreationerror);
|
|
60
|
+
|
|
61
|
+
systemLog.log(`${logStr}`);
|
|
62
|
+
systemLog.log(`JQx: created ${instance.isVirtual ? `VIRTUAL ` : ``}[${
|
|
63
|
+
truncateHtmlStr(ElemArray2HtmlString(instance.collection).trim() ||
|
|
64
|
+
"sanitized: no elements remaining", logLineLength)}]`);
|
|
65
|
+
|
|
66
|
+
if (!instance.isVirtual) {
|
|
67
|
+
inject2DOMTree(instance.collection, root, position);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return proxify(instance);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const forLog = setCollectionFromCssSelector(input, root, instance);
|
|
75
|
+
systemLog.log(`JQx: input => ${forLog}`);
|
|
76
|
+
return proxify(instance);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { cleanupHtml } from "./DOM.js";
|
|
2
|
-
import allMethodsFactory from "./JQxMethods.js";
|
|
3
|
-
import PopupFactory from "./Popup.js";
|
|
4
|
-
import { listeners, default as HandleFactory } from "./HandlerFactory.js";
|
|
5
|
-
import tagLib from "./HTMLTags.js";
|
|
6
1
|
import {
|
|
7
|
-
randomString, toDashedNotation, IS, tagFNFactory as $T, styleFactory, toCamelcase, systemLog,
|
|
8
|
-
isNonEmptyString, resolveEventTypeParameter, selectedFactoryHelpers, insertPositions
|
|
9
|
-
|
|
2
|
+
randomString, toDashedNotation, IS, tagFNFactory as $T, styleFactory, toCamelcase, systemLog,
|
|
3
|
+
escHtml, isNonEmptyString, resolveEventTypeParameter, selectedFactoryHelpers, insertPositions,
|
|
4
|
+
cleanupHtml, PopupFactory, tagLib, listeners, HandleFactory,
|
|
5
|
+
} from "./JQxUtilities.js";
|
|
6
|
+
import allMethodsFactory from "./JQxInstanceMethods.js";
|
|
10
7
|
|
|
11
8
|
let instanceGetters, instanceMethods;
|
|
12
9
|
const {
|
|
@@ -19,7 +16,7 @@ export { proxify, addJQxStaticMethods };
|
|
|
19
16
|
function selectedUtilitiesFactory() {
|
|
20
17
|
return {
|
|
21
18
|
...selectedFactoryHelpers(),
|
|
22
|
-
addFn(name, extensionMethod) {
|
|
19
|
+
addFn: function(name, extensionMethod) {
|
|
23
20
|
systemLog.log(`JQx: added extension function [${name}]`);
|
|
24
21
|
return instanceMethods[name] = (self, ...params) => extensionMethod(self, ...params);
|
|
25
22
|
} };
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import {createElementFromHtmlString, inject2DOMTree} from "./DOM.js";
|
|
2
1
|
import {
|
|
3
2
|
IS, isNode, truncateHtmlStr, addHandlerId, ExamineElementFeatureFactory,
|
|
4
3
|
isNonEmptyString, toDashedNotation, escHtml, systemLog, insertPositions,
|
|
5
|
-
datasetKeyProxy, loop, cloneAndDestroy, setData, before, after,
|
|
6
|
-
emptyElement, checkProp, css, assignAttrValues,
|
|
7
|
-
|
|
4
|
+
datasetKeyProxy, loop, cloneAndDestroy, setData, before, after,
|
|
5
|
+
findParentScrollDistance, emptyElement, checkProp, css, assignAttrValues,
|
|
6
|
+
applyStyle, createElementFromHtmlString, inject2DOMTree,
|
|
7
|
+
} from "./JQxUtilities.js";
|
|
8
8
|
|
|
9
9
|
const instanceIs = ExamineElementFeatureFactory();
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
export default function(jqx) {
|
|
12
|
+
return {
|
|
13
|
+
factoryExtensions: factoryExtensionsFactory(jqx),
|
|
14
|
+
instanceExtensions: instanceExtensionsFactory(jqx),
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
12
18
|
function factoryExtensionsFactory(jqx) {
|
|
13
19
|
return {
|
|
14
20
|
data: instance => ({
|
|
@@ -509,11 +515,3 @@ function instanceExtensionsFactory(jqx) {
|
|
|
509
515
|
},
|
|
510
516
|
};
|
|
511
517
|
}
|
|
512
|
-
|
|
513
|
-
/* endregion exportfunctions */
|
|
514
|
-
export default function(jqx) {
|
|
515
|
-
return {
|
|
516
|
-
factoryExtensions: factoryExtensionsFactory(jqx),
|
|
517
|
-
instanceExtensions: instanceExtensionsFactory(jqx),
|
|
518
|
-
}
|
|
519
|
-
};
|
|
@@ -0,0 +1,111 @@
|
|
|
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"
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
addHandlerId, after, applyStyle, assignAttrValues, before, checkProp, cloneAndDestroy, css, datasetKeyProxy,
|
|
13
|
+
ElemArray2HtmlString, emptyElement, escHtml, ExamineElementFeatureFactory, findParentScrollDistance,
|
|
14
|
+
input2Collection, insertPositions, IS, isArrayOfHtmlElements, isArrayOfHtmlStrings, isCommentOrTextNode,
|
|
15
|
+
isHtmlString, isNode, isNonEmptyString, logTime, loop, maybe, randomNr, randomString, resolveEventTypeParameter,
|
|
16
|
+
selectedFactoryHelpers, setCollectionFromCssSelector, setData, styleFactory, systemLog, tagFNFactory,
|
|
17
|
+
toCamelcase, toDashedNotation, truncate2SingleStr, truncateHtmlStr, createElementFromHtmlString, inject2DOMTree,
|
|
18
|
+
cleanupHtml, PopupFactory, tagLib, HandleFactory, listeners
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function loop(instance, callback) {
|
|
22
|
+
const cleanCollection = instance.collection.filter(el => !isCommentOrTextNode(el));
|
|
23
|
+
for (let i = 0; i < cleanCollection.length; i += 1) {
|
|
24
|
+
callback(cleanCollection[i], i);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return instance;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function setCollectionFromCssSelector(input, root, self) {
|
|
31
|
+
const selectorRoot = root !== document.body && (IS(input, String) && input.toLowerCase() !== "body") ? root : document;
|
|
32
|
+
let errorStr = undefined;
|
|
33
|
+
|
|
34
|
+
try { self.collection = [...selectorRoot.querySelectorAll(input)]; }
|
|
35
|
+
catch (err) { errorStr = `Invalid CSS querySelector. [${!IS(input, String) ? `Nothing valid given!` : input}]`; }
|
|
36
|
+
const collectionLen = self.collection.length;
|
|
37
|
+
return collectionLen < 1
|
|
38
|
+
? `CSS querySelector "${input}", output: nothing`
|
|
39
|
+
: errorStr ?? `CSS querySelector "${input}", output ${collectionLen} element${collectionLen > 1 ? `s` : ``}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function addHandlerId(instance) {
|
|
43
|
+
const handleId = instance.data.get(`hid`) || `HID${randomString()}`;
|
|
44
|
+
instance.data.add({hid: handleId});
|
|
45
|
+
return `[data-hid="${handleId}"]`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function selectedFactoryHelpers() {
|
|
49
|
+
return {
|
|
50
|
+
isCommentOrTextNode, isNode, isComment, isText, isHtmlString, isArrayOfHtmlElements,
|
|
51
|
+
isArrayOfHtmlStrings, ElemArray2HtmlString, input2Collection, setCollectionFromCssSelector,
|
|
52
|
+
addHandlerId, cssRuleEdit: styleFactory({createWithId: `JQxStylesheet`}) };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function ExamineElementFeatureFactory() {
|
|
56
|
+
const notApplicable = `n/a`;
|
|
57
|
+
const noElements = Object.freeze({
|
|
58
|
+
notInDOM: true, writable: notApplicable, modal: notApplicable, empty: true,
|
|
59
|
+
open: notApplicable, visible: notApplicable, });
|
|
60
|
+
|
|
61
|
+
return self => {
|
|
62
|
+
const firstElem = self.node;
|
|
63
|
+
|
|
64
|
+
return IS(firstElem, Node)
|
|
65
|
+
? Object.freeze({
|
|
66
|
+
get writable() {
|
|
67
|
+
return isWritable(firstElem);
|
|
68
|
+
},
|
|
69
|
+
get modal() {
|
|
70
|
+
return isModal(firstElem);
|
|
71
|
+
},
|
|
72
|
+
get inDOM() {
|
|
73
|
+
return firstElem.isConnected;
|
|
74
|
+
},
|
|
75
|
+
get open() {
|
|
76
|
+
return firstElem.open ?? false;
|
|
77
|
+
},
|
|
78
|
+
get visible() {
|
|
79
|
+
return isVisible(firstElem);
|
|
80
|
+
},
|
|
81
|
+
get disabled() {
|
|
82
|
+
return firstElem.hasAttribute("readonly") || firstElem.hasAttribute("disabled");
|
|
83
|
+
},
|
|
84
|
+
get empty() {
|
|
85
|
+
return self.collection.length < 1;
|
|
86
|
+
},
|
|
87
|
+
get virtual() {
|
|
88
|
+
return self.isVirtual;
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
: noElements;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function css(el, keyOrKvPairs, value, jqx) {
|
|
96
|
+
if (value && IS(keyOrKvPairs, String)) {
|
|
97
|
+
keyOrKvPairs = {[keyOrKvPairs]: value === "-" ? "" : value};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let nwClass = undefined;
|
|
101
|
+
|
|
102
|
+
if (keyOrKvPairs.className) {
|
|
103
|
+
nwClass = keyOrKvPairs.className;
|
|
104
|
+
delete keyOrKvPairs.className;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const classExists = ([...el.classList].find(c => c.startsWith(`JQxClass-`) || nwClass && c === nwClass));
|
|
108
|
+
nwClass = classExists || nwClass || `JQxClass-${randomString().slice(1)}`;
|
|
109
|
+
jqx.editCssRule(`.${nwClass}`, keyOrKvPairs);
|
|
110
|
+
el.classList.add(nwClass);
|
|
111
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|