@arraypress/waveform-bar 1.0.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/LICENSE +21 -0
- package/README.md +732 -0
- package/dist/waveform-bar.css +943 -0
- package/dist/waveform-bar.esm.js +1389 -0
- package/dist/waveform-bar.js +1387 -0
- package/dist/waveform-bar.min.css +1 -0
- package/dist/waveform-bar.min.js +51 -0
- package/package.json +60 -0
- package/src/css/waveform-bar.css +943 -0
- package/src/js/actions.js +35 -0
- package/src/js/core.js +1271 -0
- package/src/js/dom.js +84 -0
- package/src/js/icons.js +24 -0
- package/src/js/index.js +20 -0
- package/src/js/queue.js +113 -0
- package/src/js/storage.js +92 -0
- package/src/js/utils.js +74 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module actions
|
|
3
|
+
* @description Action button handlers (favorite, cart) for WaveformBar
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fire an action to an endpoint or callback
|
|
8
|
+
* @param {Object} actionConfig - { endpoint, method, headers }
|
|
9
|
+
* @param {Object} payload - Data to send
|
|
10
|
+
*/
|
|
11
|
+
export function fireAction(actionConfig, payload) {
|
|
12
|
+
if (!actionConfig || !actionConfig.endpoint) return;
|
|
13
|
+
|
|
14
|
+
// Callback function
|
|
15
|
+
if (typeof actionConfig.endpoint === 'function') {
|
|
16
|
+
try {
|
|
17
|
+
actionConfig.endpoint(payload);
|
|
18
|
+
} catch (err) {
|
|
19
|
+
console.warn('WaveformBar action callback error:', err);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// REST endpoint
|
|
25
|
+
if (typeof actionConfig.endpoint === 'string') {
|
|
26
|
+
fetch(actionConfig.endpoint, {
|
|
27
|
+
method: actionConfig.method || 'POST',
|
|
28
|
+
headers: {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
...(actionConfig.headers || {})
|
|
31
|
+
},
|
|
32
|
+
body: JSON.stringify(payload)
|
|
33
|
+
}).catch(err => console.warn('WaveformBar action request failed:', err));
|
|
34
|
+
}
|
|
35
|
+
}
|