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.
Files changed (39) hide show
  1. package/README.md +171 -153
  2. package/package.json +4 -2
  3. package/src/v6/guards/actions/index.js +21 -21
  4. package/src/v6/guards/bindings/index.js +5 -5
  5. package/src/v6/guards/bindings/validateArray.js +23 -23
  6. package/src/v6/guards/bindings/validateBinding.js +22 -22
  7. package/src/v6/guards/index.js +19 -19
  8. package/src/v6/index.js +21 -21
  9. package/src/v6/prepare/index.js +23 -23
  10. package/src/v6/register/meta.js +6 -6
  11. package/src/v7/guards/actions/index.js +21 -21
  12. package/src/v7/guards/bindings/index.js +5 -5
  13. package/src/v7/guards/bindings/validateArray.js +23 -23
  14. package/src/v7/guards/bindings/validateBinding.js +22 -22
  15. package/src/v7/guards/index.js +19 -19
  16. package/src/v7/index.js +43 -43
  17. package/src/v7/prepare/index.js +23 -23
  18. package/src/v7/register/index.js +18 -18
  19. package/src/v7/register/meta.js +6 -6
  20. package/src/v7/sample/index.js +22 -22
  21. package/src/v8/dispatch/executeBinding.js +21 -0
  22. package/src/v8/dispatch/getClientData.js +8 -0
  23. package/src/v8/dispatch/getStartInput.js +10 -0
  24. package/src/v8/dispatch/index.js +15 -0
  25. package/src/v8/guards/actions/index.js +21 -0
  26. package/src/v8/guards/bindings/index.js +5 -0
  27. package/src/v8/guards/bindings/validateArray.js +23 -0
  28. package/src/v8/guards/bindings/validateBinding.js +22 -0
  29. package/src/v8/guards/container/index.js +13 -0
  30. package/src/v8/guards/container/resolveElement.js +14 -0
  31. package/src/v8/guards/index.js +19 -0
  32. package/src/v8/index.js +37 -0
  33. package/src/v8/listeners/attachListener.js +10 -0
  34. package/src/v8/listeners/index.js +12 -0
  35. package/src/v8/prepare/groupBindings.js +14 -0
  36. package/src/v8/prepare/index.js +23 -0
  37. package/src/v8/register/index.js +15 -0
  38. package/src/v8/register/meta.js +6 -0
  39. 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,6 @@
1
+ export const meta = {
2
+ name: "dom-primitive-bindings",
3
+ version: "1.8.1"
4
+ };
5
+
6
+ export default meta;
@@ -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;