@appius-fr/apx 2.6.1 → 2.7.0

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 (38) hide show
  1. package/APX.mjs +2 -0
  2. package/README.md +207 -203
  3. package/dist/2ab50e700c8fbddb45e0.svg +10 -0
  4. package/dist/2e967d8dd752e0bed703.svg +10 -0
  5. package/dist/5ddaeefe5dfbc8e09652.svg +7 -0
  6. package/dist/6dc2907ba3bbb232601d.svg +10 -0
  7. package/dist/6e1e61dfca176a885b8d.svg +3 -0
  8. package/dist/6f3a0a27a260bb2c221b.svg +9 -0
  9. package/dist/8b07a8bf719a38262b7d.svg +10 -0
  10. package/dist/APX.dev.mjs +843 -245
  11. package/dist/APX.mjs +1 -1
  12. package/dist/APX.prod.mjs +1 -1
  13. package/dist/APX.standalone.js +744 -92
  14. package/dist/APX.standalone.js.map +1 -1
  15. package/dist/bdfa755a1cdb872368c7.svg +3 -0
  16. package/dist/c9da177f7663f9fcd023.svg +10 -0
  17. package/dist/ce9ef5fceb78e17e68c9.svg +8 -0
  18. package/dist/ed5af5163957b04bc6cc.svg +7 -0
  19. package/modules/listen/README.md +242 -235
  20. package/modules/listen/listen.mjs +1 -3
  21. package/modules/scrollableTable/README.md +52 -0
  22. package/modules/scrollableTable/css/scrollableTable.css +60 -0
  23. package/modules/scrollableTable/scrollableTable.mjs +198 -0
  24. package/modules/toast/README.md +186 -153
  25. package/modules/tools/form-packer/README.md +12 -14
  26. package/modules/tools/form-packer/augment-apx.mjs +4 -2
  27. package/modules/tools/form-packer/packToJson.mjs +58 -16
  28. package/modules/tristate/CHANGELOG.md +34 -0
  29. package/modules/tristate/README.md +157 -94
  30. package/modules/tristate/assets/tristate-checked.svg +3 -0
  31. package/modules/tristate/assets/tristate-cross.svg +10 -0
  32. package/modules/tristate/assets/tristate-crossed.svg +3 -0
  33. package/modules/tristate/assets/tristate-indeterminate-dash.svg +9 -0
  34. package/modules/tristate/assets/tristate-tick.svg +10 -0
  35. package/modules/tristate/assets/tristate-unchecked.svg +7 -0
  36. package/modules/tristate/css/tristate.css +91 -24
  37. package/modules/tristate/tristate.mjs +292 -171
  38. package/package.json +5 -1
package/APX.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import augmentWithListen from './modules/listen/listen.mjs';
2
2
  import augmentWithTristate from './modules/tristate/tristate.mjs';
3
+ import augmentWithScrollableTable from './modules/scrollableTable/scrollableTable.mjs';
3
4
  import dialog from './modules/dialog/dialog.mjs';
4
5
  import toast from './modules/toast/toast.mjs';
5
6
  import { loadCss } from './modules/common.mjs';
@@ -104,6 +105,7 @@ const APX = function (input, context = document) {
104
105
  };
105
106
  augmentWithListen(apx);
106
107
  augmentWithTristate(apx);
108
+ augmentWithScrollableTable(apx);
107
109
  augmentWithPack(apx);
108
110
  return apx;
109
111
  };
package/README.md CHANGED
@@ -1,203 +1,207 @@
1
- # APX DOM Wrapper
2
-
3
- APX is a versatile DOM wrapper designed to simplify interactions with HTML elements. It provides a unified interface for working with various input types, including XPath, CSS selectors, individual HTMLElements, NodeLists, HTMLCollections, arrays of elements, jQuery objects, and even functions that return APX objects.
4
-
5
- ## Core Library
6
-
7
- The main APX library is defined in [`APX.mjs`](./APX.mjs), which provides the core DOM wrapping functionality and integrates all modules.
8
-
9
- **Quick Start:**
10
- ```javascript
11
- import APX from './APX.mjs';
12
-
13
- // Use APX to select and manipulate elements
14
- APX('.my-class').each((el) => console.log(el));
15
- ```
16
-
17
- ## Features
18
-
19
- - **XPath Support**: Easily select elements using XPath queries.
20
- - **CSS Selector Support**: Utilize CSS selectors for element selection.
21
- - **Enhanced Interactions**: Augmented with modules like `listen` for event handling and `tristate` for managing tristate logic.
22
- - **Utility Functions**: Includes tools like `loadCss`, `dialog`, and `toast` for extended functionality.
23
- - **jQuery Compatibility**: Seamlessly works with jQuery objects.
24
- - **Function Input**: Accepts functions returning an APX object as input.
25
-
26
- ## Modules
27
-
28
- APX is enhanced with several modules, each adding specialized functionality. Each module has its own detailed documentation:
29
-
30
- ### `listen`
31
-
32
- The `listen` module simplifies event handling for wrapped elements. It provides an intuitive way to attach and manage event listeners with support for event delegation, multiple callbacks, debouncing, and manual event triggering.
33
-
34
- **Documentation:** [`modules/listen/README.md`](./modules/listen/README.md)
35
-
36
- **Quick Example:**
37
- ```javascript
38
- APX('.button').listen('click').do((event) => {
39
- console.log('Button clicked!');
40
- });
41
- ```
42
-
43
- ### `tristate`
44
-
45
- The `tristate` module allows you to manage tristate logic (e.g., on/off/indeterminate) for HTML elements efficiently.
46
-
47
- **Documentation:** [`modules/tristate/tristate.mjs`](./modules/tristate/tristate.mjs)
48
-
49
- ### `dialog`
50
-
51
- The `dialog` module provides utilities to create and manage modal dialogs with lifecycle management, button interactions, and flexible content loading.
52
-
53
- **Documentation:** [`modules/dialog/README.md`](./modules/dialog/README.md)
54
-
55
- Since 2.4.0, dialog content can be fetched via GET (default) or POST with optional payload and headers.
56
-
57
- ```javascript
58
- // Example: POST fetch for dialog content (APX 2.4.0+)
59
- const myDialog = APX.dialog({
60
- title: 'Submit and Load',
61
- contentURI: '/api/dialog/content',
62
- contentMethod: 'POST',
63
- contentData: { foo: 'bar' }, // also supports FormData, URLSearchParams, string, Blob
64
- contentHeaders: { 'X-Request-ID': '123' },
65
- buttons: [
66
- { key: 'ok', label: 'OK', closeOnClick: true },
67
- { key: 'cancel', label: 'Cancel', closeOnClick: true }
68
- ],
69
- size: 'medium'
70
- });
71
-
72
- myDialog.open();
73
- ```
74
-
75
- ### `toast` (since 2.5.0)
76
-
77
- Minimal, framework‑agnostic toast notifications with auto‑loaded CSS and a small API. Exposed as `APX.toast`. Supports advanced positioning (sticky, relative, anchored), flow control, and container management.
78
-
79
- **Documentation:** [`modules/toast/README.md`](./modules/toast/README.md)
80
-
81
- **Quick Start:**
82
- ```javascript
83
- // One‑liners on the default manager
84
- APX.toast.success('Saved!');
85
- APX.toast.warning('Heads up', { durationMs: 4000 });
86
-
87
- // Callable shorthand (equivalent to show)
88
- APX.toast({ message: 'Processing…', type: 'info', durationMs: 0 });
89
-
90
- // Configure defaults
91
- APX.toast.configure({ position: 'top-right', maxToasts: 4, dedupe: true });
92
-
93
- // Named managers (profiles)
94
- APX.toast.create('admin', { position: 'bottom-left' });
95
- APX.toast.use('admin').info('Admin ready');
96
- ```
97
-
98
- **Demo pages** (work from file:// via standalone build):
99
- - `demo/index.html` (landing)
100
- - `demo/modules/toast/index.html` (basic and advanced examples with code viewer)
101
-
102
- ### `tools` (since 2.6.0)
103
-
104
- The `tools` module provides utility functions for common web development tasks. Currently includes form handling utilities with more tools planned for future releases.
105
-
106
- **Documentation:** [`modules/tools/README.md`](./modules/tools/README.md)
107
-
108
- **Quick Start:**
109
- ```javascript
110
- // Convert form to JSON
111
- const data = APX('form#myForm').pack();
112
- // or
113
- const data = APX.tools.packFormToJSON(document.querySelector('#myForm'));
114
- ```
115
-
116
- **Sub-modules:**
117
- - **`form-packer`**: Convert HTML forms to JSON with support for nested objects, arrays, and complex structures.
118
- - Documentation: [`modules/tools/form-packer/README.md`](./modules/tools/form-packer/README.md)
119
-
120
- **Demo page:**
121
- - `demo/modules/tools/index.html` (interactive form examples and validation)
122
-
123
- ### Utilities
124
-
125
- - **`loadCss`**: Dynamically load CSS files into your document.
126
-
127
- Documentation: [`modules/common.mjs`](./modules/common.mjs)
128
-
129
- ## Usage
130
-
131
- Here are some examples of how you can use APX:
132
-
133
- ```javascript
134
- // Using XPath
135
- const apx1 = APX('//div[@class="example"]');
136
-
137
- // Using CSS selector
138
- const apx2 = APX('.example');
139
-
140
- // Using a single element
141
- const element = document.querySelector('.example');
142
- const apx3 = APX(element);
143
-
144
- // Using NodeList or HTMLCollection
145
- const nodeList = document.querySelectorAll('.example');
146
- const apx4 = APX(nodeList);
147
-
148
- // Using an array of elements
149
- const elements = [document.querySelector('.example1'), document.querySelector('.example2')];
150
- const apx5 = APX(elements);
151
-
152
- // Using a jQuery object
153
- const $example = $('.example');
154
- const apx6 = APX($example);
155
-
156
- // Using a function returning an APX object
157
- const apx7 = APX(() => APX('.example'));
158
- ```
159
-
160
- ## API
161
-
162
- ### Core Functionality
163
-
164
- - **`APX(input, context = document)`**: The main function that creates an APX object. Accepts a wide variety of input types:
165
- - `string`: XPath or CSS selectors.
166
- - `HTMLElement`: Single DOM element.
167
- - `NodeList`/`HTMLCollection`: A collection of DOM elements.
168
- - `Array<HTMLElement>`: An array of DOM elements.
169
- - `jQuery`: A jQuery object.
170
- - `Function`: A function that returns an APX object.
171
- - **Methods on APX objects**:
172
- - `.each(callback)`: Iterates over elements.
173
- - `.get(index)`: Retrieves an element by index.
174
- - `.all()`: Returns all wrapped elements.
175
- - `.first()`: Returns the first wrapped element.
176
-
177
- ### Utilities
178
-
179
- - **`APX.loadCss()`**: Dynamically load CSS files.
180
- - **`APX.dialog()`**: Manage and display dialogs. See [`modules/dialog/README.md`](./modules/dialog/README.md)
181
- - **`APX.toast`**: Toast notification system. See [`modules/toast/README.md`](./modules/toast/README.md)
182
- - **`APX.tools`**: Utility functions. See [`modules/tools/README.md`](./modules/tools/README.md)
183
- - **`APX.isAPXObject(obj)`**: Check if an object is an APX object.
184
- - **`APX.is_numeric(n)`**: Check if a value is numeric.
185
-
186
- ## Installation
187
-
188
- To include APX in your project:
189
-
190
- 1. Clone the repository or download the package.
191
- 2. Import APX and its modules into your project:
192
- ```javascript
193
- import APX from './path-to-apx/apx.mjs';
194
- ```
195
-
196
- ## Contributing
197
-
198
- We welcome contributions! Please refer to the contribution guidelines in the repository.
199
-
200
- ## License
201
-
202
- Author : Thibault SAELEN
203
- Copyright Appius SARL.
1
+ # APX DOM Wrapper
2
+
3
+ APX is a versatile DOM wrapper designed to simplify interactions with HTML elements. It provides a unified interface for working with various input types, including XPath, CSS selectors, individual HTMLElements, NodeLists, HTMLCollections, arrays of elements, jQuery objects, and even functions that return APX objects.
4
+
5
+ ## Core Library
6
+
7
+ The main APX library is defined in [`APX.mjs`](./APX.mjs), which provides the core DOM wrapping functionality and integrates all modules.
8
+
9
+ **Quick Start:**
10
+ ```javascript
11
+ import APX from './APX.mjs';
12
+
13
+ // Use APX to select and manipulate elements
14
+ APX('.my-class').each((el) => console.log(el));
15
+ ```
16
+
17
+ ## Features
18
+
19
+ - **XPath Support**: Easily select elements using XPath queries.
20
+ - **CSS Selector Support**: Utilize CSS selectors for element selection.
21
+ - **Enhanced Interactions**: Augmented with modules like `listen` for event handling and `tristate` for managing tristate logic.
22
+ - **Utility Functions**: Includes tools like `loadCss`, `dialog`, and `toast` for extended functionality.
23
+ - **jQuery Compatibility**: Seamlessly works with jQuery objects.
24
+ - **Function Input**: Accepts functions returning an APX object as input.
25
+
26
+ ## Modules
27
+
28
+ APX is enhanced with several modules, each adding specialized functionality. Each module has its own detailed documentation:
29
+
30
+ ### `listen`
31
+
32
+ The `listen` module simplifies event handling for wrapped elements. It provides an intuitive way to attach and manage event listeners with support for event delegation, multiple callbacks, debouncing, and manual event triggering.
33
+
34
+ **Documentation:** [`modules/listen/README.md`](./modules/listen/README.md)
35
+
36
+ **Quick Example:**
37
+ ```javascript
38
+ APX('.button').listen('click').do((event) => {
39
+ console.log('Button clicked!');
40
+ });
41
+ ```
42
+
43
+ ### `tristate`
44
+
45
+ The `tristate` module allows you to manage tristate logic (e.g., on/off/indeterminate) for HTML elements efficiently.
46
+
47
+ **Documentation:** [`modules/tristate/README.md`](./modules/tristate/README.md)
48
+
49
+ **Demo page:**
50
+ - `demo/modules/tristate/index.html` (state preview and interactive cycle)
51
+
52
+ ### `dialog`
53
+
54
+ The `dialog` module provides utilities to create and manage modal dialogs with lifecycle management, button interactions, and flexible content loading.
55
+
56
+ **Documentation:** [`modules/dialog/README.md`](./modules/dialog/README.md)
57
+
58
+ Since 2.4.0, dialog content can be fetched via GET (default) or POST with optional payload and headers.
59
+
60
+ ```javascript
61
+ // Example: POST fetch for dialog content (APX 2.4.0+)
62
+ const myDialog = APX.dialog({
63
+ title: 'Submit and Load',
64
+ contentURI: '/api/dialog/content',
65
+ contentMethod: 'POST',
66
+ contentData: { foo: 'bar' }, // also supports FormData, URLSearchParams, string, Blob
67
+ contentHeaders: { 'X-Request-ID': '123' },
68
+ buttons: [
69
+ { key: 'ok', label: 'OK', closeOnClick: true },
70
+ { key: 'cancel', label: 'Cancel', closeOnClick: true }
71
+ ],
72
+ size: 'medium'
73
+ });
74
+
75
+ myDialog.open();
76
+ ```
77
+
78
+ ### `toast` (since 2.5.0)
79
+
80
+ Minimal, framework‑agnostic toast notifications with auto‑loaded CSS and a small API. Exposed as `APX.toast`. Supports advanced positioning (sticky, relative, anchored), flow control, and container management.
81
+
82
+ **Documentation:** [`modules/toast/README.md`](./modules/toast/README.md)
83
+
84
+ **Quick Start:**
85
+ ```javascript
86
+ // One‑liners on the default manager
87
+ APX.toast.success('Saved!');
88
+ APX.toast.warning('Heads up', { durationMs: 4000 });
89
+
90
+ // Callable shorthand (equivalent to show)
91
+ APX.toast({ message: 'Processing…', type: 'info', durationMs: 0 });
92
+
93
+ // Configure defaults
94
+ APX.toast.configure({ position: 'top-right', maxToasts: 4, dedupe: true });
95
+
96
+ // Named managers (profiles)
97
+ APX.toast.create('admin', { position: 'bottom-left' });
98
+ APX.toast.use('admin').info('Admin ready');
99
+ ```
100
+
101
+ **Demo pages** (work from file:// via standalone build):
102
+ - `demo/index.html` (landing)
103
+ - `demo/modules/toast/index.html` (basic and advanced examples with code viewer)
104
+ - `demo/modules/tristate/index.html` (state preview and interactive cycle)
105
+
106
+ ### `tools` (since 2.6.0)
107
+
108
+ The `tools` module provides utility functions for common web development tasks. Currently includes form handling utilities with more tools planned for future releases.
109
+
110
+ **Documentation:** [`modules/tools/README.md`](./modules/tools/README.md)
111
+
112
+ **Quick Start:**
113
+ ```javascript
114
+ // Convert form to JSON
115
+ const data = APX('form#myForm').pack();
116
+ // or
117
+ const data = APX.tools.packFormToJSON(document.querySelector('#myForm'));
118
+ ```
119
+
120
+ **Sub-modules:**
121
+ - **`form-packer`**: Convert HTML forms to JSON with support for nested objects, arrays, and complex structures.
122
+ - Documentation: [`modules/tools/form-packer/README.md`](./modules/tools/form-packer/README.md)
123
+
124
+ **Demo page:**
125
+ - `demo/modules/tools/index.html` (interactive form examples and validation)
126
+
127
+ ### Utilities
128
+
129
+ - **`loadCss`**: Dynamically load CSS files into your document.
130
+
131
+ Documentation: [`modules/common.mjs`](./modules/common.mjs)
132
+
133
+ ## Usage
134
+
135
+ Here are some examples of how you can use APX:
136
+
137
+ ```javascript
138
+ // Using XPath
139
+ const apx1 = APX('//div[@class="example"]');
140
+
141
+ // Using CSS selector
142
+ const apx2 = APX('.example');
143
+
144
+ // Using a single element
145
+ const element = document.querySelector('.example');
146
+ const apx3 = APX(element);
147
+
148
+ // Using NodeList or HTMLCollection
149
+ const nodeList = document.querySelectorAll('.example');
150
+ const apx4 = APX(nodeList);
151
+
152
+ // Using an array of elements
153
+ const elements = [document.querySelector('.example1'), document.querySelector('.example2')];
154
+ const apx5 = APX(elements);
155
+
156
+ // Using a jQuery object
157
+ const $example = $('.example');
158
+ const apx6 = APX($example);
159
+
160
+ // Using a function returning an APX object
161
+ const apx7 = APX(() => APX('.example'));
162
+ ```
163
+
164
+ ## API
165
+
166
+ ### Core Functionality
167
+
168
+ - **`APX(input, context = document)`**: The main function that creates an APX object. Accepts a wide variety of input types:
169
+ - `string`: XPath or CSS selectors.
170
+ - `HTMLElement`: Single DOM element.
171
+ - `NodeList`/`HTMLCollection`: A collection of DOM elements.
172
+ - `Array<HTMLElement>`: An array of DOM elements.
173
+ - `jQuery`: A jQuery object.
174
+ - `Function`: A function that returns an APX object.
175
+ - **Methods on APX objects**:
176
+ - `.each(callback)`: Iterates over elements.
177
+ - `.get(index)`: Retrieves an element by index.
178
+ - `.all()`: Returns all wrapped elements.
179
+ - `.first()`: Returns the first wrapped element.
180
+
181
+ ### Utilities
182
+
183
+ - **`APX.loadCss()`**: Dynamically load CSS files.
184
+ - **`APX.dialog()`**: Manage and display dialogs. See [`modules/dialog/README.md`](./modules/dialog/README.md)
185
+ - **`APX.toast`**: Toast notification system. See [`modules/toast/README.md`](./modules/toast/README.md)
186
+ - **`APX.tools`**: Utility functions. See [`modules/tools/README.md`](./modules/tools/README.md)
187
+ - **`APX.isAPXObject(obj)`**: Check if an object is an APX object.
188
+ - **`APX.is_numeric(n)`**: Check if a value is numeric.
189
+
190
+ ## Installation
191
+
192
+ To include APX in your project:
193
+
194
+ 1. Clone the repository or download the package.
195
+ 2. Import APX and its modules into your project:
196
+ ```javascript
197
+ import APX from './path-to-apx/apx.mjs';
198
+ ```
199
+
200
+ ## Contributing
201
+
202
+ We welcome contributions! Please refer to the contribution guidelines in the repository.
203
+
204
+ ## License
205
+
206
+ Author : Thibault SAELEN
207
+ Copyright Appius SARL.
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
+ <path
3
+ d="M8 8L24 24M24 8L8 24"
4
+ fill="none"
5
+ stroke="#000"
6
+ stroke-width="3"
7
+ stroke-linecap="round"
8
+ stroke-linejoin="round"
9
+ />
10
+ </svg>
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
+ <path
3
+ d="M8 8L24 24M24 8L8 24"
4
+ fill="none"
5
+ stroke="#fff"
6
+ stroke-width="3"
7
+ stroke-linecap="round"
8
+ stroke-linejoin="round"
9
+ />
10
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
+ <mask id="frame-cutout">
3
+ <rect width="32" height="32" fill="#fff" />
4
+ <rect x="3" y="3" width="26" height="26" rx="4" ry="4" fill="#000" />
5
+ </mask>
6
+ <rect width="32" height="32" fill="#cccccc" mask="url(#frame-cutout)" />
7
+ </svg>
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
+ <path
3
+ d="M6 17L12 23L26 9"
4
+ fill="none"
5
+ stroke="#fff"
6
+ stroke-width="3"
7
+ stroke-linecap="round"
8
+ stroke-linejoin="round"
9
+ />
10
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
+ <rect width="32" height="32" fill="#f00" />
3
+ </svg>
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
+ <path
3
+ d="M8 16h16"
4
+ fill="none"
5
+ stroke="#fff"
6
+ stroke-width="3"
7
+ stroke-linecap="round"
8
+ />
9
+ </svg>
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
+ <mask id="check-cutout">
3
+ <rect width="32" height="32" fill="#fff" />
4
+ <path
5
+ fill="#000"
6
+ d="M5.313 17.587l7.039 6.839 13.831-13.439-2.636-2.561-10.929 10.62-4.442-4.317-2.862 2.858z"
7
+ />
8
+ </mask>
9
+ <rect width="32" height="32" fill="#0654ba" mask="url(#check-cutout)" />
10
+ </svg>