@doyosi/laraisy 1.0.1 → 1.0.3
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 +1 -1
- package/package.json +1 -1
- package/src/CodeInput.js +48 -48
- package/src/DSAlert.js +352 -352
- package/src/DSAvatar.js +207 -207
- package/src/DSDelete.js +274 -274
- package/src/DSForm.js +568 -568
- package/src/DSGridOrTable.js +453 -453
- package/src/DSLocaleSwitcher.js +239 -239
- package/src/DSLogout.js +293 -293
- package/src/DSNotifications.js +365 -365
- package/src/DSRestore.js +181 -181
- package/src/DSSelect.js +1071 -1071
- package/src/DSSelectBox.js +563 -563
- package/src/DSSimpleSlider.js +517 -517
- package/src/DSSvgFetch.js +69 -69
- package/src/DSTable/DSTableExport.js +68 -68
- package/src/DSTable/DSTableFilter.js +224 -224
- package/src/DSTable/DSTablePagination.js +136 -136
- package/src/DSTable/DSTableSearch.js +40 -40
- package/src/DSTable/DSTableSelection.js +192 -192
- package/src/DSTable/DSTableSort.js +58 -58
- package/src/DSTable.js +353 -353
- package/src/DSTabs.js +488 -488
- package/src/DSUpload.js +887 -887
- package/dist/CodeInput.d.ts +0 -10
- package/dist/DSAlert.d.ts +0 -112
- package/dist/DSAvatar.d.ts +0 -45
- package/dist/DSDelete.d.ts +0 -61
- package/dist/DSForm.d.ts +0 -151
- package/dist/DSGridOrTable/DSGOTRenderer.d.ts +0 -60
- package/dist/DSGridOrTable/DSGOTViewToggle.d.ts +0 -26
- package/dist/DSGridOrTable.d.ts +0 -296
- package/dist/DSLocaleSwitcher.d.ts +0 -71
- package/dist/DSLogout.d.ts +0 -76
- package/dist/DSNotifications.d.ts +0 -54
- package/dist/DSRestore.d.ts +0 -56
- package/dist/DSSelect.d.ts +0 -221
- package/dist/DSSelectBox.d.ts +0 -123
- package/dist/DSSimpleSlider.d.ts +0 -136
- package/dist/DSSvgFetch.d.ts +0 -17
- package/dist/DSTable/DSTableExport.d.ts +0 -11
- package/dist/DSTable/DSTableFilter.d.ts +0 -40
- package/dist/DSTable/DSTablePagination.d.ts +0 -12
- package/dist/DSTable/DSTableSearch.d.ts +0 -8
- package/dist/DSTable/DSTableSelection.d.ts +0 -46
- package/dist/DSTable/DSTableSort.d.ts +0 -8
- package/dist/DSTable.d.ts +0 -116
- package/dist/DSTabs.d.ts +0 -156
- package/dist/DSUpload.d.ts +0 -220
- package/dist/index.d.ts +0 -17
package/src/DSSvgFetch.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DSSvgFetch
|
|
3
|
-
* Fetches SVG files and injects them inline.
|
|
4
|
-
* Replaces <svg> classes with those defined in data-class.
|
|
5
|
-
*/
|
|
6
|
-
export
|
|
7
|
-
constructor(options = {}) {
|
|
8
|
-
this.config = {
|
|
9
|
-
selector: '.icon-fetch-web',
|
|
10
|
-
attribute: 'data-svg',
|
|
11
|
-
classAttribute: 'data-class', // New config for the class data
|
|
12
|
-
...options
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
this.svgCache = new Map();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
init() {
|
|
19
|
-
const elements = document.querySelectorAll(this.config.selector);
|
|
20
|
-
|
|
21
|
-
elements.forEach(element => {
|
|
22
|
-
if (element.dataset.svgProcessed) return;
|
|
23
|
-
this.processElement(element);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async processElement(element) {
|
|
28
|
-
const url = element.getAttribute(this.config.attribute);
|
|
29
|
-
const customClasses = element.getAttribute(this.config.classAttribute);
|
|
30
|
-
|
|
31
|
-
if (!url) return;
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
element.dataset.svgProcessed = 'true';
|
|
35
|
-
|
|
36
|
-
// 1. Fetch content (or get from cache)
|
|
37
|
-
const svgContent = await this.fetchSvg(url);
|
|
38
|
-
|
|
39
|
-
// 2. Inject HTML
|
|
40
|
-
element.innerHTML = svgContent;
|
|
41
|
-
|
|
42
|
-
// 3. Apply custom classes if data-class exists
|
|
43
|
-
if (customClasses) {
|
|
44
|
-
const svg = element.querySelector('svg');
|
|
45
|
-
if (svg) {
|
|
46
|
-
// setAttribute overwrites the entire 'class' attribute,
|
|
47
|
-
// effectively removing old classes and adding the new ones.
|
|
48
|
-
svg.setAttribute('class', customClasses);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error(`DSSvgFetch: Failed to load ${url}`, error);
|
|
54
|
-
delete element.dataset.svgProcessed;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async fetchSvg(url) {
|
|
59
|
-
if (this.svgCache.has(url)) {
|
|
60
|
-
return this.svgCache.get(url);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const response = await fetch(url);
|
|
64
|
-
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
65
|
-
|
|
66
|
-
const text = await response.text();
|
|
67
|
-
this.svgCache.set(url, text);
|
|
68
|
-
return text;
|
|
69
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* DSSvgFetch
|
|
3
|
+
* Fetches SVG files and injects them inline.
|
|
4
|
+
* Replaces <svg> classes with those defined in data-class.
|
|
5
|
+
*/
|
|
6
|
+
export class DSSvgFetch {
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.config = {
|
|
9
|
+
selector: '.icon-fetch-web',
|
|
10
|
+
attribute: 'data-svg',
|
|
11
|
+
classAttribute: 'data-class', // New config for the class data
|
|
12
|
+
...options
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
this.svgCache = new Map();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
init() {
|
|
19
|
+
const elements = document.querySelectorAll(this.config.selector);
|
|
20
|
+
|
|
21
|
+
elements.forEach(element => {
|
|
22
|
+
if (element.dataset.svgProcessed) return;
|
|
23
|
+
this.processElement(element);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async processElement(element) {
|
|
28
|
+
const url = element.getAttribute(this.config.attribute);
|
|
29
|
+
const customClasses = element.getAttribute(this.config.classAttribute);
|
|
30
|
+
|
|
31
|
+
if (!url) return;
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
element.dataset.svgProcessed = 'true';
|
|
35
|
+
|
|
36
|
+
// 1. Fetch content (or get from cache)
|
|
37
|
+
const svgContent = await this.fetchSvg(url);
|
|
38
|
+
|
|
39
|
+
// 2. Inject HTML
|
|
40
|
+
element.innerHTML = svgContent;
|
|
41
|
+
|
|
42
|
+
// 3. Apply custom classes if data-class exists
|
|
43
|
+
if (customClasses) {
|
|
44
|
+
const svg = element.querySelector('svg');
|
|
45
|
+
if (svg) {
|
|
46
|
+
// setAttribute overwrites the entire 'class' attribute,
|
|
47
|
+
// effectively removing old classes and adding the new ones.
|
|
48
|
+
svg.setAttribute('class', customClasses);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(`DSSvgFetch: Failed to load ${url}`, error);
|
|
54
|
+
delete element.dataset.svgProcessed;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async fetchSvg(url) {
|
|
59
|
+
if (this.svgCache.has(url)) {
|
|
60
|
+
return this.svgCache.get(url);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const response = await fetch(url);
|
|
64
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
65
|
+
|
|
66
|
+
const text = await response.text();
|
|
67
|
+
this.svgCache.set(url, text);
|
|
68
|
+
return text;
|
|
69
|
+
}
|
|
70
70
|
}
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
export class DSTableExport {
|
|
2
|
-
constructor(tableInstance) {
|
|
3
|
-
this.table = tableInstance;
|
|
4
|
-
this.table.registerModule('export', this);
|
|
5
|
-
|
|
6
|
-
// Look for export buttons
|
|
7
|
-
this.buttons = document.querySelectorAll('[data-ds-table-export]');
|
|
8
|
-
|
|
9
|
-
this._init();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
_init() {
|
|
13
|
-
this.buttons.forEach(btn => {
|
|
14
|
-
btn.addEventListener('click', (e) => {
|
|
15
|
-
e.preventDefault();
|
|
16
|
-
const type = btn.dataset.dsTableExport || 'csv';
|
|
17
|
-
this.exportData(type);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
exportData(type) {
|
|
23
|
-
// Simple client-side export of current page data
|
|
24
|
-
// For full export, we might need server support or fetch all.
|
|
25
|
-
// Assuming client-side of current data for now.
|
|
26
|
-
|
|
27
|
-
const data = this.table.data;
|
|
28
|
-
if (!data || data.length === 0) return;
|
|
29
|
-
|
|
30
|
-
if (type === 'csv') {
|
|
31
|
-
this._exportCSV(data);
|
|
32
|
-
} else if (type === 'json') {
|
|
33
|
-
this._exportJSON(data);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
_exportCSV(data) {
|
|
38
|
-
if (!data.length) return;
|
|
39
|
-
|
|
40
|
-
// Flatten object for CSV? Or just take top level keys
|
|
41
|
-
const headers = Object.keys(data[0]);
|
|
42
|
-
const csvContent = [
|
|
43
|
-
headers.join(','),
|
|
44
|
-
...data.map(row => headers.map(fieldName => {
|
|
45
|
-
let cell = row[fieldName] === null || row[fieldName] === undefined ? '' : row[fieldName];
|
|
46
|
-
if (typeof cell === 'object') cell = JSON.stringify(cell); // Simple handling
|
|
47
|
-
return JSON.stringify(cell); // Quote strings
|
|
48
|
-
}).join(','))
|
|
49
|
-
].join('\r\n');
|
|
50
|
-
|
|
51
|
-
this._downloadFile(csvContent, 'export.csv', 'text/csv');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
_exportJSON(data) {
|
|
55
|
-
const jsonContent = JSON.stringify(data, null, 2);
|
|
56
|
-
this._downloadFile(jsonContent, 'export.json', 'application/json');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
_downloadFile(content, fileName, mimeType) {
|
|
60
|
-
const a = document.createElement('a');
|
|
61
|
-
const blob = new Blob([content], { type: mimeType });
|
|
62
|
-
const url = URL.createObjectURL(blob);
|
|
63
|
-
a.setAttribute('href', url);
|
|
64
|
-
a.setAttribute('download', fileName);
|
|
65
|
-
a.click();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
export default DSTableExport;
|
|
1
|
+
export class DSTableExport {
|
|
2
|
+
constructor(tableInstance) {
|
|
3
|
+
this.table = tableInstance;
|
|
4
|
+
this.table.registerModule('export', this);
|
|
5
|
+
|
|
6
|
+
// Look for export buttons
|
|
7
|
+
this.buttons = document.querySelectorAll('[data-ds-table-export]');
|
|
8
|
+
|
|
9
|
+
this._init();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
_init() {
|
|
13
|
+
this.buttons.forEach(btn => {
|
|
14
|
+
btn.addEventListener('click', (e) => {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
const type = btn.dataset.dsTableExport || 'csv';
|
|
17
|
+
this.exportData(type);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exportData(type) {
|
|
23
|
+
// Simple client-side export of current page data
|
|
24
|
+
// For full export, we might need server support or fetch all.
|
|
25
|
+
// Assuming client-side of current data for now.
|
|
26
|
+
|
|
27
|
+
const data = this.table.data;
|
|
28
|
+
if (!data || data.length === 0) return;
|
|
29
|
+
|
|
30
|
+
if (type === 'csv') {
|
|
31
|
+
this._exportCSV(data);
|
|
32
|
+
} else if (type === 'json') {
|
|
33
|
+
this._exportJSON(data);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_exportCSV(data) {
|
|
38
|
+
if (!data.length) return;
|
|
39
|
+
|
|
40
|
+
// Flatten object for CSV? Or just take top level keys
|
|
41
|
+
const headers = Object.keys(data[0]);
|
|
42
|
+
const csvContent = [
|
|
43
|
+
headers.join(','),
|
|
44
|
+
...data.map(row => headers.map(fieldName => {
|
|
45
|
+
let cell = row[fieldName] === null || row[fieldName] === undefined ? '' : row[fieldName];
|
|
46
|
+
if (typeof cell === 'object') cell = JSON.stringify(cell); // Simple handling
|
|
47
|
+
return JSON.stringify(cell); // Quote strings
|
|
48
|
+
}).join(','))
|
|
49
|
+
].join('\r\n');
|
|
50
|
+
|
|
51
|
+
this._downloadFile(csvContent, 'export.csv', 'text/csv');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_exportJSON(data) {
|
|
55
|
+
const jsonContent = JSON.stringify(data, null, 2);
|
|
56
|
+
this._downloadFile(jsonContent, 'export.json', 'application/json');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_downloadFile(content, fileName, mimeType) {
|
|
60
|
+
const a = document.createElement('a');
|
|
61
|
+
const blob = new Blob([content], { type: mimeType });
|
|
62
|
+
const url = URL.createObjectURL(blob);
|
|
63
|
+
a.setAttribute('href', url);
|
|
64
|
+
a.setAttribute('download', fileName);
|
|
65
|
+
a.click();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export default DSTableExport;
|