@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.
- package/APX.mjs +2 -0
- package/README.md +207 -203
- package/dist/2ab50e700c8fbddb45e0.svg +10 -0
- package/dist/2e967d8dd752e0bed703.svg +10 -0
- package/dist/5ddaeefe5dfbc8e09652.svg +7 -0
- package/dist/6dc2907ba3bbb232601d.svg +10 -0
- package/dist/6e1e61dfca176a885b8d.svg +3 -0
- package/dist/6f3a0a27a260bb2c221b.svg +9 -0
- package/dist/8b07a8bf719a38262b7d.svg +10 -0
- package/dist/APX.dev.mjs +843 -245
- package/dist/APX.mjs +1 -1
- package/dist/APX.prod.mjs +1 -1
- package/dist/APX.standalone.js +744 -92
- package/dist/APX.standalone.js.map +1 -1
- package/dist/bdfa755a1cdb872368c7.svg +3 -0
- package/dist/c9da177f7663f9fcd023.svg +10 -0
- package/dist/ce9ef5fceb78e17e68c9.svg +8 -0
- package/dist/ed5af5163957b04bc6cc.svg +7 -0
- package/modules/listen/README.md +242 -235
- package/modules/listen/listen.mjs +1 -3
- package/modules/scrollableTable/README.md +52 -0
- package/modules/scrollableTable/css/scrollableTable.css +60 -0
- package/modules/scrollableTable/scrollableTable.mjs +198 -0
- package/modules/toast/README.md +186 -153
- package/modules/tools/form-packer/README.md +12 -14
- package/modules/tools/form-packer/augment-apx.mjs +4 -2
- package/modules/tools/form-packer/packToJson.mjs +58 -16
- package/modules/tristate/CHANGELOG.md +34 -0
- package/modules/tristate/README.md +157 -94
- package/modules/tristate/assets/tristate-checked.svg +3 -0
- package/modules/tristate/assets/tristate-cross.svg +10 -0
- package/modules/tristate/assets/tristate-crossed.svg +3 -0
- package/modules/tristate/assets/tristate-indeterminate-dash.svg +9 -0
- package/modules/tristate/assets/tristate-tick.svg +10 -0
- package/modules/tristate/assets/tristate-unchecked.svg +7 -0
- package/modules/tristate/css/tristate.css +91 -24
- package/modules/tristate/tristate.mjs +292 -171
- 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/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
APX.toast(
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
APX.toast
|
|
92
|
-
|
|
93
|
-
//
|
|
94
|
-
APX.toast.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
**
|
|
121
|
-
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
// Using
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
// Using
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
// Using
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
// Using a
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
- `
|
|
170
|
-
- `
|
|
171
|
-
-
|
|
172
|
-
-
|
|
173
|
-
-
|
|
174
|
-
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
- **`APX.
|
|
184
|
-
- **`APX.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
##
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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,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
|
+
<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>
|