dom-primitive-bindings 1.7.3 → 1.8.1
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 +171 -153
- package/package.json +4 -2
- package/src/v6/guards/actions/index.js +21 -21
- package/src/v6/guards/bindings/index.js +5 -5
- package/src/v6/guards/bindings/validateArray.js +23 -23
- package/src/v6/guards/bindings/validateBinding.js +22 -22
- package/src/v6/guards/index.js +19 -19
- package/src/v6/index.js +21 -21
- package/src/v6/prepare/index.js +23 -23
- package/src/v6/register/meta.js +6 -6
- package/src/v7/guards/actions/index.js +21 -21
- package/src/v7/guards/bindings/index.js +5 -5
- package/src/v7/guards/bindings/validateArray.js +23 -23
- package/src/v7/guards/bindings/validateBinding.js +22 -22
- package/src/v7/guards/index.js +19 -19
- package/src/v7/index.js +43 -43
- package/src/v7/prepare/index.js +23 -23
- package/src/v7/register/index.js +18 -18
- package/src/v7/register/meta.js +6 -6
- package/src/v7/sample/index.js +22 -22
- package/src/v8/dispatch/executeBinding.js +21 -0
- package/src/v8/dispatch/getClientData.js +8 -0
- package/src/v8/dispatch/getStartInput.js +10 -0
- package/src/v8/dispatch/index.js +15 -0
- package/src/v8/guards/actions/index.js +21 -0
- package/src/v8/guards/bindings/index.js +5 -0
- package/src/v8/guards/bindings/validateArray.js +23 -0
- package/src/v8/guards/bindings/validateBinding.js +22 -0
- package/src/v8/guards/container/index.js +13 -0
- package/src/v8/guards/container/resolveElement.js +14 -0
- package/src/v8/guards/index.js +19 -0
- package/src/v8/index.js +37 -0
- package/src/v8/listeners/attachListener.js +10 -0
- package/src/v8/listeners/index.js +12 -0
- package/src/v8/prepare/groupBindings.js +14 -0
- package/src/v8/prepare/index.js +23 -0
- package/src/v8/register/index.js +15 -0
- package/src/v8/register/meta.js +6 -0
- package/src/v8/sample/index.js +22 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const groupBindings = (bindings) => {
|
|
2
|
+
const groups = new Map();
|
|
3
|
+
|
|
4
|
+
for (const binding of bindings) {
|
|
5
|
+
const list = groups.get(binding.event) ?? [];
|
|
6
|
+
list.push(binding);
|
|
7
|
+
groups.set(binding.event, list);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return groups;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default groupBindings;
|
|
14
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import groupBindings from "./groupBindings.js";
|
|
2
|
+
|
|
3
|
+
const prepareBindings = (bindings, actions = {}) => {
|
|
4
|
+
const hasActions = actions && typeof actions === "object" && Object.keys(actions).length > 0;
|
|
5
|
+
|
|
6
|
+
const configuredBindings = hasActions
|
|
7
|
+
? bindings.map((binding) => {
|
|
8
|
+
if (binding.action && typeof actions[binding.action] === "function" && typeof binding.onExtract !== "function") {
|
|
9
|
+
return {
|
|
10
|
+
...binding,
|
|
11
|
+
onExtract: (result, event, matchElement) => {
|
|
12
|
+
actions[binding.action](event, matchElement, result);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return binding;
|
|
17
|
+
})
|
|
18
|
+
: bindings;
|
|
19
|
+
|
|
20
|
+
return groupBindings(configuredBindings);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default prepareBindings;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import meta from "./meta.js";
|
|
2
|
+
|
|
3
|
+
const registerGlobal = (bindEvents) => {
|
|
4
|
+
if (!bindEvents || typeof globalThis === "undefined") return;
|
|
5
|
+
|
|
6
|
+
globalThis.ks ??= {};
|
|
7
|
+
globalThis.ks.domPrimitive ??= {};
|
|
8
|
+
|
|
9
|
+
globalThis.ks.domPrimitive.bindings = {
|
|
10
|
+
meta,
|
|
11
|
+
bindEvents
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default registerGlobal;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const sampleContainer = () => "app";
|
|
2
|
+
|
|
3
|
+
const sampleBindings = () => [
|
|
4
|
+
{
|
|
5
|
+
event: "click",
|
|
6
|
+
selector: "#loadBtn",
|
|
7
|
+
action: "loadData"
|
|
8
|
+
}
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const sampleActions = () => ({
|
|
12
|
+
loadData: () => {}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const sample = () => ({
|
|
16
|
+
containerOrId: sampleContainer(),
|
|
17
|
+
bindings: sampleBindings(),
|
|
18
|
+
actions: sampleActions()
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export { sample, sampleContainer, sampleBindings, sampleActions };
|
|
22
|
+
export default sample;
|