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
package/README.md CHANGED
@@ -1,153 +1,171 @@
1
- # DOM Primitive Bindings
2
-
3
- > Browser-native, single-listener container event delegation driven by declarative JSON instructions.
4
-
5
- [![npm version](https://img.shields.io/npm/v/dom-primitive-bindings.svg?style=flat-square)](https://www.npmjs.com/package/dom-primitive-bindings)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
7
- [![GitHub Pages](https://img.shields.io/badge/Docs-GitHub%20Pages-success.svg?style=flat-square)](https://keshavsoft.github.io/dom-primitive-bindings/)
8
-
9
- ---
10
-
11
- ## 🌐 Live Documentation & Interactive Story
12
-
13
- Explore the complete interactive story and live samples on **[GitHub Pages](https://keshavsoft.github.io/dom-primitive-bindings/)**:
14
-
15
- 1. **[Chapter 1: The Problem (Why?)](https://keshavsoft.github.io/dom-primitive-bindings/why/)** ([local](./docs/why/index.html))
16
- Why attaching listeners to individual elements causes memory leaks, double-trigger cascades, and re-render dead zones.
17
- 2. **[Chapter 2: How We Achieved It](https://keshavsoft.github.io/dom-primitive-bindings/how/)** ([local](./docs/how/index.html))
18
- The delegation epiphany: leveraging browser event bubbling across a decoupled 4-stage pipeline (`guards` $\to$ `prepare` $\to$ `listeners` $\to$ `dispatch`).
19
- 3. **[Chapter 3: Declarative JSON](https://keshavsoft.github.io/dom-primitive-bindings/declarative/)** ([local](./docs/declarative/index.html))
20
- Separating intent from execution: why JSON instructions make UI code human-readable, statically guardable, and self-documenting.
21
- 4. **[Usage & Available Builds](https://keshavsoft.github.io/dom-primitive-bindings/usage/)** ([local](./docs/usage/index.html))
22
- Available builds hosted on GitHub Pages CDN with one-click copyable script tags and ES Module imports.
23
-
24
- ---
25
-
26
- ## 🎯 The Philosophy: The Wiring Layer
27
-
28
- A common mistake in UI architecture is conflating **event wiring** with **DOM manipulation** or **data extraction**:
29
-
30
- - **`dom-primitive-bindings` (This Repository):**
31
- Pure **Wiring Layer**. Attaches one container listener per event type, matches bubbling targets via `closest(selector)`, and delivers `{ event, targetElement }`. It does **not** manipulate DOM elements and does **not** extract schemas.
32
- - **`dom-primitive-engine` (Sibling Repository):**
33
- Pure **Extraction Layer**. Receives the matched target element and executes declarative instruction pipelines (e.g. `closest("tr")`, `querySelectorAll("td")`) to produce clean JSON.
34
-
35
- ```text
36
- [ User Action in Browser ]
37
- │
38
- ▼
39
- ┌───────────────────────────────┐
40
- │ dom-primitive-bindings │ ◄── Wiring Layer: Catches bubbling event & matches target
41
- │ (guards → prepare → dispatch)│
42
- └──────────────┬────────────────┘
43
- │ delivers { event, targetElement }
44
- ▼
45
- ┌───────────────────────────────┐
46
- │ Consumer / App Logic │ ◄── Extraction (dom-primitive-engine) or Action Handler
47
- └───────────────────────────────┘
48
- ```
49
-
50
- ---
51
-
52
- ## ⚡ Quick Start & Distribution
53
-
54
- ### 1. Direct Script Tag (Zero Install via GitHub Pages CDN)
55
-
56
- ```html
57
- <script type="module" src="https://keshavsoft.github.io/dom-primitive-bindings/dist/v4/min.js"></script>
58
- ```
59
-
60
- Or always use the latest build:
61
-
62
- ```html
63
- <script type="module" src="https://keshavsoft.github.io/dom-primitive-bindings/dist/min.js"></script>
64
- ```
65
-
66
- ### 2. ES Module Import in JavaScript
67
-
68
- ```javascript
69
- import { bindEvents } from "https://keshavsoft.github.io/dom-primitive-bindings/dist/v4/min.js";
70
- ```
71
-
72
- ### 3. NPM Package
73
-
74
- ```bash
75
- npm install dom-primitive-bindings
76
- ```
77
-
78
- ---
79
-
80
- ## 📦 Usage Example
81
-
82
- ### 1. Declare `bindings.json`
83
-
84
- ```json
85
- [
86
- {
87
- "event": "click",
88
- "selector": "#rakaBtn",
89
- "narration": "Load and populate Raka columns JSON into editor"
90
- },
91
- {
92
- "event": "click",
93
- "selector": "#templateBtn",
94
- "narration": "Load and populate template JSON into editor"
95
- },
96
- {
97
- "event": "click",
98
- "selector": "#buildBtn",
99
- "narration": "Transform columns with template and display output in editor"
100
- }
101
- ]
102
- ```
103
-
104
- ### 2. Delegate with `bindEvents`
105
-
106
- ```javascript
107
- import { bindEvents } from "https://keshavsoft.github.io/dom-primitive-bindings/dist/v4/min.js";
108
- import bindings from "./bindings.json" with { type: "json" };
109
-
110
- bindEvents("app-container", bindings);
111
- ```
112
-
113
- ---
114
-
115
- ## 🏗️ Staged Pipeline Architecture
116
-
117
- The engine enforces a decoupled pipeline where every directory contains an `index.js` public gateway:
118
-
119
- ```text
120
- src/v4/
121
- ├── guards/ # Validates container & bindings array before execution
122
- ├── prepare/ # Groups bindings by event type into Map
123
- ├── listeners/ # Attaches single container listener per event type
124
- ├── dispatch/ # Handles event bubbling, target matching (closest) & execution
125
- ├── register/ # Exposes module onto window.ks.domPrimitiveBindings
126
- └── index.js # Orchestrator
127
- ```
128
-
129
- ---
130
-
131
- ## 🧪 Testing & Build
132
-
133
- ```bash
134
- # Run unit tests
135
- npm test
136
-
137
- # Build production bundle using build-cli
138
- npx @keshavsoft/build-cli build
139
- ```
140
-
141
- ---
142
-
143
- ## 🔗 Useful Links
144
-
145
- - **Live Documentation**: [https://keshavsoft.github.io/dom-primitive-bindings/](https://keshavsoft.github.io/dom-primitive-bindings/)
146
- - **Copyable Script Links**: [https://keshavsoft.github.io/dom-primitive-bindings/usage/](https://keshavsoft.github.io/dom-primitive-bindings/usage/)
147
- - **NPM Package**: [https://www.npmjs.com/package/dom-primitive-bindings](https://www.npmjs.com/package/dom-primitive-bindings)
148
-
149
- ---
150
-
151
- ## 📄 License
152
-
153
- MIT © KeshavSoft
1
+ # DOM Primitive Bindings
2
+
3
+ > Browser-native, single-listener container event delegation driven by declarative JSON instructions.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/dom-primitive-bindings.svg?style=flat-square)](https://www.npmjs.com/package/dom-primitive-bindings)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
7
+ [![GitHub Pages](https://img.shields.io/badge/Docs-GitHub%20Pages-success.svg?style=flat-square)](https://keshavsoft.github.io/dom-primitive-bindings/)
8
+
9
+ ---
10
+
11
+ ## 🌐 Live Documentation & Interactive Story
12
+
13
+ Explore the complete interactive story and live samples on **[GitHub Pages](https://keshavsoft.github.io/dom-primitive-bindings/)**:
14
+
15
+ 1. **[Chapter 1: The Problem (Why?)](https://keshavsoft.github.io/dom-primitive-bindings/why/)** ([local](./docs/why/index.html))
16
+ Why attaching listeners to individual elements causes memory leaks, double-trigger cascades, and re-render dead zones.
17
+ 2. **[Chapter 2: How We Achieved It](https://keshavsoft.github.io/dom-primitive-bindings/how/)** ([local](./docs/how/index.html))
18
+ The delegation epiphany: leveraging browser event bubbling across a decoupled 4-stage pipeline (`guards` $\to$ `prepare` $\to$ `listeners` $\to$ `dispatch`).
19
+ 3. **[Chapter 3: Declarative JSON](https://keshavsoft.github.io/dom-primitive-bindings/declarative/)** ([local](./docs/declarative/index.html))
20
+ Separating intent from execution: why JSON instructions make UI code human-readable, statically guardable, and self-documenting.
21
+ 4. **[Chapter 4: The Declarative Transformation](https://keshavsoft.github.io/dom-primitive-bindings/stories/04-declarative-json-bindings.html)** ([local](./docs/stories/04-declarative-json-bindings.html))
22
+ Moving from imperative JavaScript arrays to serializable `bindings.json` specifications.
23
+ 5. **[Chapter 5: The Pure 3-File Architecture (v7)](https://keshavsoft.github.io/dom-primitive-bindings/stories/05-the-three-file-architecture.html)** ([local](./docs/stories/05-the-three-file-architecture.html))
24
+ The ultimate standard: cleanly decoupling `bindings.json` (Blueprint), `actions.js` (Behavior), and `index.js` (Wiring) at every folder level.
25
+ 6. **[Usage & Available Builds](https://keshavsoft.github.io/dom-primitive-bindings/usage/)** ([local](./docs/usage/index.html))
26
+ Available builds hosted on GitHub Pages CDN with one-click copyable script tags and ES Module imports.
27
+ 7. **[Interactive v7 Showcase](https://keshavsoft.github.io/dom-primitive-bindings/samples/v7/)** ([local](./samples/v7/index.html))
28
+ Live in-browser demonstrations: Card Grid delegation, Table with live search filtering, and Form controls.
29
+
30
+ ---
31
+
32
+ ## 🎯 The Philosophy: The Wiring Layer
33
+
34
+ A common mistake in UI architecture is conflating **event wiring** with **DOM manipulation** or **data extraction**:
35
+
36
+ - **`dom-primitive-bindings` (This Repository):**
37
+ Pure **Wiring Layer**. Attaches one container listener per event type, matches bubbling targets via `closest(selector)`, and delivers `{ event, targetElement }`. It does **not** manipulate DOM elements and does **not** extract schemas.
38
+ - **`dom-primitive-engine` (Sibling Repository):**
39
+ Pure **Extraction Layer**. Receives the matched target element and executes declarative instruction pipelines (e.g. `closest("tr")`, `querySelectorAll("td")`) to produce clean JSON.
40
+
41
+ ```text
42
+ [ User Action in Browser ]
43
+ │
44
+ ▼
45
+ ┌───────────────────────────────┐
46
+ │ dom-primitive-bindings │ ◄── Wiring Layer: Catches bubbling event & matches target
47
+ │ (guards → prepare → dispatch)│
48
+ └──────────────┬────────────────┘
49
+ │ delivers { event, targetElement }
50
+ ▼
51
+ ┌───────────────────────────────┐
52
+ │ Consumer / App Logic │ ◄── Extraction (dom-primitive-engine) or Action Handler
53
+ └───────────────────────────────┘
54
+ ```
55
+
56
+ ---
57
+
58
+ ## ⚡ Quick Start & Distribution
59
+
60
+ ### 1. Direct Script Tag (Zero Install via GitHub Pages CDN)
61
+
62
+ ```html
63
+ <script type="module" src="https://keshavsoft.github.io/dom-primitive-bindings/dist/v7/min.js"></script>
64
+ ```
65
+
66
+ Or always use the latest build:
67
+
68
+ ```html
69
+ <script type="module" src="https://keshavsoft.github.io/dom-primitive-bindings/dist/min.js"></script>
70
+ ```
71
+
72
+ ### 2. ES Module Import in JavaScript
73
+
74
+ ```javascript
75
+ import { bindEvents } from "https://keshavsoft.github.io/dom-primitive-bindings/dist/v7/min.js";
76
+ ```
77
+
78
+ ### 3. NPM Package
79
+
80
+ ```bash
81
+ npm install dom-primitive-bindings
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 📦 The 3-File Standard Usage Example (v7)
87
+
88
+ ### 1. Declare `bindings.json` (The Blueprint)
89
+
90
+ ```json
91
+ [
92
+ {
93
+ "event": "click",
94
+ "selector": "#rakaBtn",
95
+ "action": "loadRaka"
96
+ },
97
+ {
98
+ "event": "click",
99
+ "selector": "#buildBtn",
100
+ "action": "buildOutput"
101
+ }
102
+ ]
103
+ ```
104
+
105
+ ### 2. Declare `actions.js` (The Behaviors)
106
+
107
+ ```javascript
108
+ export const actions = {
109
+ loadRaka: (event, matchElement) => {
110
+ console.log("Loading Raka columns into editor...");
111
+ },
112
+ buildOutput: (event, matchElement) => {
113
+ console.log("Transforming and rendering output...");
114
+ }
115
+ };
116
+
117
+ export default actions;
118
+ ```
119
+
120
+ ### 3. Delegate with `index.js` (The Orchestrator)
121
+
122
+ ```javascript
123
+ import bindings from "./bindings.json" with { type: "json" };
124
+ import actions from "./actions.js";
125
+ import { bindEvents } from "dom-primitive-bindings";
126
+
127
+ // Single container listener intercepts bubbling events and dispatches to actions
128
+ bindEvents("app-container", bindings, actions);
129
+ ```
130
+
131
+ ---
132
+
133
+ ## 🏗️ Staged Pipeline Architecture
134
+
135
+ The engine enforces a decoupled pipeline where every directory contains an `index.js` public gateway:
136
+
137
+ ```text
138
+ src/v7/
139
+ ├── guards/ # Validates container, bindings array, and actions object
140
+ ├── prepare/ # Groups bindings by event type into Map & wires action mappings
141
+ ├── listeners/ # Attaches single container listener per event type
142
+ ├── dispatch/ # Handles event bubbling, target matching (closest) & execution
143
+ ├── register/ # Exposes module onto globalThis.ks.domPrimitiveBindings
144
+ └── index.js # Orchestrator
145
+ ```
146
+
147
+ ---
148
+
149
+ ## 🧪 Testing & Build
150
+
151
+ ```bash
152
+ # Run unit tests
153
+ npm test
154
+
155
+ # Build production bundle using build-cli
156
+ npx @keshavsoft/build-cli build
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 🔗 Useful Links
162
+
163
+ - **Live Documentation**: [https://keshavsoft.github.io/dom-primitive-bindings/](https://keshavsoft.github.io/dom-primitive-bindings/)
164
+ - **Copyable Script Links**: [https://keshavsoft.github.io/dom-primitive-bindings/usage/](https://keshavsoft.github.io/dom-primitive-bindings/usage/)
165
+ - **NPM Package**: [https://www.npmjs.com/package/dom-primitive-bindings](https://www.npmjs.com/package/dom-primitive-bindings)
166
+
167
+ ---
168
+
169
+ ## 📄 License
170
+
171
+ MIT © KeshavSoft
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dom-primitive-bindings",
3
- "version": "1.7.3",
3
+ "version": "1.8.1",
4
4
  "description": "Declarative, instruction-driven DOM delegated event bindings",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -22,6 +22,8 @@
22
22
  "README.md",
23
23
  "LICENSE"
24
24
  ],
25
- "scripts": {},
25
+ "scripts": {
26
+ "build": "npx @keshavsoft/build-cli"
27
+ },
26
28
  "devDependencies": {}
27
29
  }
@@ -1,21 +1,21 @@
1
- const isPlainObject = (value) => {
2
- if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
3
- const prototype = Object.getPrototypeOf(value);
4
- return prototype === Object.prototype || prototype === null;
5
- };
6
-
7
- const checkActions = (actions = {}) => {
8
- if (!isPlainObject(actions)) {
9
- throw new TypeError("actions must be a plain, flat object.");
10
- }
11
-
12
- for (const [name, action] of Object.entries(actions)) {
13
- if (typeof action !== "function") {
14
- throw new TypeError(`actions.${name} must be a function.`);
15
- }
16
- }
17
-
18
- return actions;
19
- };
20
-
21
- export default checkActions;
1
+ const isPlainObject = (value) => {
2
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
3
+ const prototype = Object.getPrototypeOf(value);
4
+ return prototype === Object.prototype || prototype === null;
5
+ };
6
+
7
+ const checkActions = (actions = {}) => {
8
+ if (!isPlainObject(actions)) {
9
+ throw new TypeError("actions must be a plain, flat object.");
10
+ }
11
+
12
+ for (const [name, action] of Object.entries(actions)) {
13
+ if (typeof action !== "function") {
14
+ throw new TypeError(`actions.${name} must be a function.`);
15
+ }
16
+ }
17
+
18
+ return actions;
19
+ };
20
+
21
+ export default checkActions;
@@ -1,5 +1,5 @@
1
- import validateArray from "./validateArray.js";
2
-
3
- const checkBindings = (bindings) => validateArray(bindings);
4
-
5
- export default checkBindings;
1
+ import validateArray from "./validateArray.js";
2
+
3
+ const checkBindings = (bindings) => validateArray(bindings);
4
+
5
+ export default checkBindings;
@@ -1,23 +1,23 @@
1
- import validateBinding from "./validateBinding.js";
2
-
3
- const validateArray = (bindings) => {
4
- if (!Array.isArray(bindings)) {
5
- throw new TypeError("bindings must be an array.");
6
- }
7
-
8
- if (bindings.length === 0) {
9
- throw new TypeError("bindings must contain at least one binding.");
10
- }
11
-
12
- bindings.forEach((binding, index) => {
13
- if (!validateBinding(binding)) {
14
- throw new TypeError(
15
- `bindings[${index}] must be an object with exactly three non-empty string properties: event, selector, and action.`
16
- );
17
- }
18
- });
19
-
20
- return bindings;
21
- };
22
-
23
- export default validateArray;
1
+ import validateBinding from "./validateBinding.js";
2
+
3
+ const validateArray = (bindings) => {
4
+ if (!Array.isArray(bindings)) {
5
+ throw new TypeError("bindings must be an array.");
6
+ }
7
+
8
+ if (bindings.length === 0) {
9
+ throw new TypeError("bindings must contain at least one binding.");
10
+ }
11
+
12
+ bindings.forEach((binding, index) => {
13
+ if (!validateBinding(binding)) {
14
+ throw new TypeError(
15
+ `bindings[${index}] must be an object with exactly three non-empty string properties: event, selector, and action.`
16
+ );
17
+ }
18
+ });
19
+
20
+ return bindings;
21
+ };
22
+
23
+ export default validateArray;
@@ -1,22 +1,22 @@
1
- const bindingKeys = ["event", "selector", "action"];
2
-
3
- const isPlainObject = (value) => {
4
- if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
5
- const prototype = Object.getPrototypeOf(value);
6
- return prototype === Object.prototype || prototype === null;
7
- };
8
-
9
- const validateBinding = (binding) => {
10
- if (!isPlainObject(binding)) return false;
11
-
12
- const keys = Object.keys(binding);
13
- if (keys.length !== bindingKeys.length) return false;
14
- if (!bindingKeys.every((key) => Object.hasOwn(binding, key))) return false;
15
-
16
- return bindingKeys.every((key) => (
17
- typeof binding[key] === "string" && binding[key].trim().length > 0
18
- ));
19
- };
20
-
21
- export { bindingKeys, isPlainObject };
22
- export default validateBinding;
1
+ const bindingKeys = ["event", "selector", "action"];
2
+
3
+ const isPlainObject = (value) => {
4
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
5
+ const prototype = Object.getPrototypeOf(value);
6
+ return prototype === Object.prototype || prototype === null;
7
+ };
8
+
9
+ const validateBinding = (binding) => {
10
+ if (!isPlainObject(binding)) return false;
11
+
12
+ const keys = Object.keys(binding);
13
+ if (keys.length !== bindingKeys.length) return false;
14
+ if (!bindingKeys.every((key) => Object.hasOwn(binding, key))) return false;
15
+
16
+ return bindingKeys.every((key) => (
17
+ typeof binding[key] === "string" && binding[key].trim().length > 0
18
+ ));
19
+ };
20
+
21
+ export { bindingKeys, isPlainObject };
22
+ export default validateBinding;
@@ -1,19 +1,19 @@
1
- import checkContainer from "./container/index.js";
2
- import checkBindings from "./bindings/index.js";
3
- import checkActions from "./actions/index.js";
4
-
5
- const runGuards = (containerOrId, bindings, actions = {}) => {
6
- const container = checkContainer(containerOrId);
7
- if (!container) return null;
8
-
9
- const validBindings = checkBindings(bindings);
10
- const validActions = checkActions(actions);
11
-
12
- return {
13
- container,
14
- bindings: validBindings,
15
- actions: validActions
16
- };
17
- };
18
-
19
- export default runGuards;
1
+ import checkContainer from "./container/index.js";
2
+ import checkBindings from "./bindings/index.js";
3
+ import checkActions from "./actions/index.js";
4
+
5
+ const runGuards = (containerOrId, bindings, actions = {}) => {
6
+ const container = checkContainer(containerOrId);
7
+ if (!container) return null;
8
+
9
+ const validBindings = checkBindings(bindings);
10
+ const validActions = checkActions(actions);
11
+
12
+ return {
13
+ container,
14
+ bindings: validBindings,
15
+ actions: validActions
16
+ };
17
+ };
18
+
19
+ export default runGuards;
package/src/v6/index.js CHANGED
@@ -1,21 +1,21 @@
1
- import registerGlobal from "./register/index.js";
2
- import runGuards from "./guards/index.js";
3
- import prepareBindings from "./prepare/index.js";
4
- import attachListeners from "./listeners/index.js";
5
-
6
- const bindEvents = (containerOrId, bindings = [], actions = {}) => {
7
- const guarded = runGuards(containerOrId, bindings, actions);
8
- if (!guarded) return null;
9
-
10
- const { container, bindings: validBindings } = guarded;
11
- const eventGroups = prepareBindings(validBindings, guarded.actions);
12
-
13
- attachListeners(container, eventGroups);
14
-
15
- return container;
16
- };
17
-
18
- export { bindEvents };
19
- export default bindEvents;
20
-
21
- registerGlobal(bindEvents);
1
+ import registerGlobal from "./register/index.js";
2
+ import runGuards from "./guards/index.js";
3
+ import prepareBindings from "./prepare/index.js";
4
+ import attachListeners from "./listeners/index.js";
5
+
6
+ const bindEvents = (containerOrId, bindings = [], actions = {}) => {
7
+ const guarded = runGuards(containerOrId, bindings, actions);
8
+ if (!guarded) return null;
9
+
10
+ const { container, bindings: validBindings } = guarded;
11
+ const eventGroups = prepareBindings(validBindings, guarded.actions);
12
+
13
+ attachListeners(container, eventGroups);
14
+
15
+ return container;
16
+ };
17
+
18
+ export { bindEvents };
19
+ export default bindEvents;
20
+
21
+ registerGlobal(bindEvents);
@@ -1,23 +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;
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;
@@ -1,6 +1,6 @@
1
- export const meta = {
2
- name: "dom-primitive-bindings",
3
- version: "5.0.0"
4
- };
5
-
6
- export default meta;
1
+ export const meta = {
2
+ name: "dom-primitive-bindings",
3
+ version: "5.0.0"
4
+ };
5
+
6
+ export default meta;