@doyosi/laraisy 1.0.2 → 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
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
export class DSTablePagination {
|
|
2
|
-
constructor(tableInstance) {
|
|
3
|
-
this.table = tableInstance;
|
|
4
|
-
this.table.registerModule('pagination', this);
|
|
5
|
-
this.wrapper = this.table.wrapper;
|
|
6
|
-
this.container = null;
|
|
7
|
-
this._init();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
_init() {
|
|
11
|
-
// Locate or create pagination container
|
|
12
|
-
// Usually inside the wrapper, after the table
|
|
13
|
-
// We can look for a specific container or append one.
|
|
14
|
-
// For this implementation, we will append a container if one doesn't exist with a specific class custom to this plugin,
|
|
15
|
-
// OR reuse the provided HTML structure from the instructions.
|
|
16
|
-
|
|
17
|
-
// Instructions sample: <div class="flex justify-between items-center mt-4 pt-4 border-t border-base-200">...</div>
|
|
18
|
-
|
|
19
|
-
this.container = this.wrapper.querySelector('.ds-table-pagination');
|
|
20
|
-
if (!this.container) {
|
|
21
|
-
this.container = document.createElement('div');
|
|
22
|
-
this.container.className = 'ds-table-pagination';
|
|
23
|
-
this.wrapper.appendChild(this.container);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Bind events for static elements if any (usually dynamic)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
onDataLoaded(response) {
|
|
30
|
-
this.render(response.meta);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
render(meta) {
|
|
34
|
-
if (!meta || !meta.total) { // || meta.total === 0
|
|
35
|
-
this.container.innerHTML = '';
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const { current_page, last_page, total, per_page, from, to } = meta;
|
|
40
|
-
var text = this.table.config.pagination_translations.stats;
|
|
41
|
-
const stats_replace = (from, to, total, text) => text.replace('{from}', from).replace('{to}', to).replace('{total}', total);
|
|
42
|
-
this.container.innerHTML = `
|
|
43
|
-
<div class="flex flex-col sm:flex-row justify-between items-center mt-4 pt-4 border-t border-base-200 gap-4">
|
|
44
|
-
<div class="flex items-center gap-4">
|
|
45
|
-
<div class="text-sm text-base-content/70">
|
|
46
|
-
${stats_replace(meta.from, meta.to, total, text)}
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
<div class="flex items-center gap-2">
|
|
50
|
-
<div class="join">
|
|
51
|
-
${this._buildButtons(current_page, last_page)}
|
|
52
|
-
</div>
|
|
53
|
-
<div class="flex items-center gap-2 ml-2">
|
|
54
|
-
<span class="text-xs text-base-content/70">${this.table.config.pagination_translations.goto}</span>
|
|
55
|
-
<input type="number" min="1" max="${last_page}" class="input input-sm input-bordered w-16 text-center page-goto" value="${current_page}">
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
`;
|
|
60
|
-
|
|
61
|
-
this._bindEvents();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
_buildButtons(current, last) {
|
|
65
|
-
let buttons = '';
|
|
66
|
-
|
|
67
|
-
// Prev
|
|
68
|
-
buttons += `<button class="join-item btn btn-sm ${current === 1 ? 'btn-disabled' : ''}" data-page="${current - 1}">«</button>`;
|
|
69
|
-
|
|
70
|
-
// Simple logic: Show all if small, or sliding window
|
|
71
|
-
// For brevity: 1, 2, 3 ... last
|
|
72
|
-
|
|
73
|
-
const delta = 2;
|
|
74
|
-
const range = [];
|
|
75
|
-
for (let i = Math.max(2, current - delta); i <= Math.min(last - 1, current + delta); i++) {
|
|
76
|
-
range.push(i);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (current - delta > 2) range.unshift('...');
|
|
80
|
-
if (current + delta < last - 1) range.push('...');
|
|
81
|
-
|
|
82
|
-
range.unshift(1);
|
|
83
|
-
if (last > 1) range.push(last);
|
|
84
|
-
|
|
85
|
-
range.forEach(i => {
|
|
86
|
-
if (i === '...') {
|
|
87
|
-
buttons += `<button class="join-item btn btn-sm btn-disabled">...</button>`;
|
|
88
|
-
} else {
|
|
89
|
-
const isActive = i === current;
|
|
90
|
-
buttons += `<button class="join-item btn btn-sm ${isActive ? 'btn-active btn-disabled' : ''}" data-page="${i}">${i}</button>`;
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// Next
|
|
95
|
-
buttons += `<button class="join-item btn btn-sm ${current === last ? 'btn-disabled' : ''}" data-page="${current + 1}">»</button>`;
|
|
96
|
-
|
|
97
|
-
return buttons;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
_bindEvents() {
|
|
101
|
-
// Buttons
|
|
102
|
-
this.container.querySelectorAll('button[data-page]').forEach(btn => {
|
|
103
|
-
btn.addEventListener('click', (e) => {
|
|
104
|
-
e.preventDefault();
|
|
105
|
-
if (btn.classList.contains('btn-disabled')) return;
|
|
106
|
-
const page = parseInt(btn.dataset.page);
|
|
107
|
-
if (page) {
|
|
108
|
-
this.table.setParam('page', page);
|
|
109
|
-
this.table.loadData();
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// Go to input
|
|
115
|
-
const gotoInput = this.container.querySelector('.page-goto');
|
|
116
|
-
if (gotoInput) {
|
|
117
|
-
gotoInput.addEventListener('change', (e) => {
|
|
118
|
-
let page = parseInt(e.target.value);
|
|
119
|
-
const max = parseInt(e.target.max);
|
|
120
|
-
if (page < 1) page = 1;
|
|
121
|
-
if (page > max) page = max;
|
|
122
|
-
|
|
123
|
-
if (page !== this.table.getParam('page')) {
|
|
124
|
-
this.table.setParam('page', page);
|
|
125
|
-
this.table.loadData();
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
gotoInput.addEventListener('keypress', (e) => {
|
|
129
|
-
if (e.key === 'Enter') {
|
|
130
|
-
gotoInput.blur(); // Trigger change
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
export default DSTablePagination;
|
|
1
|
+
export class DSTablePagination {
|
|
2
|
+
constructor(tableInstance) {
|
|
3
|
+
this.table = tableInstance;
|
|
4
|
+
this.table.registerModule('pagination', this);
|
|
5
|
+
this.wrapper = this.table.wrapper;
|
|
6
|
+
this.container = null;
|
|
7
|
+
this._init();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
_init() {
|
|
11
|
+
// Locate or create pagination container
|
|
12
|
+
// Usually inside the wrapper, after the table
|
|
13
|
+
// We can look for a specific container or append one.
|
|
14
|
+
// For this implementation, we will append a container if one doesn't exist with a specific class custom to this plugin,
|
|
15
|
+
// OR reuse the provided HTML structure from the instructions.
|
|
16
|
+
|
|
17
|
+
// Instructions sample: <div class="flex justify-between items-center mt-4 pt-4 border-t border-base-200">...</div>
|
|
18
|
+
|
|
19
|
+
this.container = this.wrapper.querySelector('.ds-table-pagination');
|
|
20
|
+
if (!this.container) {
|
|
21
|
+
this.container = document.createElement('div');
|
|
22
|
+
this.container.className = 'ds-table-pagination';
|
|
23
|
+
this.wrapper.appendChild(this.container);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Bind events for static elements if any (usually dynamic)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
onDataLoaded(response) {
|
|
30
|
+
this.render(response.meta);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render(meta) {
|
|
34
|
+
if (!meta || !meta.total) { // || meta.total === 0
|
|
35
|
+
this.container.innerHTML = '';
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { current_page, last_page, total, per_page, from, to } = meta;
|
|
40
|
+
var text = this.table.config.pagination_translations.stats;
|
|
41
|
+
const stats_replace = (from, to, total, text) => text.replace('{from}', from).replace('{to}', to).replace('{total}', total);
|
|
42
|
+
this.container.innerHTML = `
|
|
43
|
+
<div class="flex flex-col sm:flex-row justify-between items-center mt-4 pt-4 border-t border-base-200 gap-4">
|
|
44
|
+
<div class="flex items-center gap-4">
|
|
45
|
+
<div class="text-sm text-base-content/70">
|
|
46
|
+
${stats_replace(meta.from, meta.to, total, text)}
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="flex items-center gap-2">
|
|
50
|
+
<div class="join">
|
|
51
|
+
${this._buildButtons(current_page, last_page)}
|
|
52
|
+
</div>
|
|
53
|
+
<div class="flex items-center gap-2 ml-2">
|
|
54
|
+
<span class="text-xs text-base-content/70">${this.table.config.pagination_translations.goto}</span>
|
|
55
|
+
<input type="number" min="1" max="${last_page}" class="input input-sm input-bordered w-16 text-center page-goto" value="${current_page}">
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
this._bindEvents();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_buildButtons(current, last) {
|
|
65
|
+
let buttons = '';
|
|
66
|
+
|
|
67
|
+
// Prev
|
|
68
|
+
buttons += `<button class="join-item btn btn-sm ${current === 1 ? 'btn-disabled' : ''}" data-page="${current - 1}">«</button>`;
|
|
69
|
+
|
|
70
|
+
// Simple logic: Show all if small, or sliding window
|
|
71
|
+
// For brevity: 1, 2, 3 ... last
|
|
72
|
+
|
|
73
|
+
const delta = 2;
|
|
74
|
+
const range = [];
|
|
75
|
+
for (let i = Math.max(2, current - delta); i <= Math.min(last - 1, current + delta); i++) {
|
|
76
|
+
range.push(i);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (current - delta > 2) range.unshift('...');
|
|
80
|
+
if (current + delta < last - 1) range.push('...');
|
|
81
|
+
|
|
82
|
+
range.unshift(1);
|
|
83
|
+
if (last > 1) range.push(last);
|
|
84
|
+
|
|
85
|
+
range.forEach(i => {
|
|
86
|
+
if (i === '...') {
|
|
87
|
+
buttons += `<button class="join-item btn btn-sm btn-disabled">...</button>`;
|
|
88
|
+
} else {
|
|
89
|
+
const isActive = i === current;
|
|
90
|
+
buttons += `<button class="join-item btn btn-sm ${isActive ? 'btn-active btn-disabled' : ''}" data-page="${i}">${i}</button>`;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Next
|
|
95
|
+
buttons += `<button class="join-item btn btn-sm ${current === last ? 'btn-disabled' : ''}" data-page="${current + 1}">»</button>`;
|
|
96
|
+
|
|
97
|
+
return buttons;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
_bindEvents() {
|
|
101
|
+
// Buttons
|
|
102
|
+
this.container.querySelectorAll('button[data-page]').forEach(btn => {
|
|
103
|
+
btn.addEventListener('click', (e) => {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
if (btn.classList.contains('btn-disabled')) return;
|
|
106
|
+
const page = parseInt(btn.dataset.page);
|
|
107
|
+
if (page) {
|
|
108
|
+
this.table.setParam('page', page);
|
|
109
|
+
this.table.loadData();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Go to input
|
|
115
|
+
const gotoInput = this.container.querySelector('.page-goto');
|
|
116
|
+
if (gotoInput) {
|
|
117
|
+
gotoInput.addEventListener('change', (e) => {
|
|
118
|
+
let page = parseInt(e.target.value);
|
|
119
|
+
const max = parseInt(e.target.max);
|
|
120
|
+
if (page < 1) page = 1;
|
|
121
|
+
if (page > max) page = max;
|
|
122
|
+
|
|
123
|
+
if (page !== this.table.getParam('page')) {
|
|
124
|
+
this.table.setParam('page', page);
|
|
125
|
+
this.table.loadData();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
gotoInput.addEventListener('keypress', (e) => {
|
|
129
|
+
if (e.key === 'Enter') {
|
|
130
|
+
gotoInput.blur(); // Trigger change
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export default DSTablePagination;
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
export class DSTableSearch {
|
|
2
|
-
constructor(tableInstance) {
|
|
3
|
-
this.table = tableInstance;
|
|
4
|
-
this.table.registerModule('search', this);
|
|
5
|
-
this.wrapper = this.table.wrapper;
|
|
6
|
-
|
|
7
|
-
// Look for search input from options or convention
|
|
8
|
-
// Instructions: input_selector: '#search'
|
|
9
|
-
|
|
10
|
-
this.input = document.querySelector(this.table.config.search_selector || '#search') ||
|
|
11
|
-
this.wrapper.querySelector('.ds-table-search input'); // Fallback convention
|
|
12
|
-
|
|
13
|
-
if (this.input) {
|
|
14
|
-
this._init();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
_init() {
|
|
19
|
-
let timeout;
|
|
20
|
-
this.input.addEventListener('input', (e) => {
|
|
21
|
-
clearTimeout(timeout);
|
|
22
|
-
timeout = setTimeout(() => {
|
|
23
|
-
const val = e.target.value;
|
|
24
|
-
this.table.setParam('search', val);
|
|
25
|
-
this.table.setParam('page', 1); // Reset to page 1 on search
|
|
26
|
-
this.table.loadData();
|
|
27
|
-
}, 500); // 500ms debounce
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Handle "X" clear search
|
|
31
|
-
this.input.addEventListener('search', (e) => {
|
|
32
|
-
if (e.target.value === '') {
|
|
33
|
-
this.table.setParam('search', '');
|
|
34
|
-
this.table.setParam('page', 1);
|
|
35
|
-
this.table.loadData();
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export default DSTableSearch;
|
|
1
|
+
export class DSTableSearch {
|
|
2
|
+
constructor(tableInstance) {
|
|
3
|
+
this.table = tableInstance;
|
|
4
|
+
this.table.registerModule('search', this);
|
|
5
|
+
this.wrapper = this.table.wrapper;
|
|
6
|
+
|
|
7
|
+
// Look for search input from options or convention
|
|
8
|
+
// Instructions: input_selector: '#search'
|
|
9
|
+
|
|
10
|
+
this.input = document.querySelector(this.table.config.search_selector || '#search') ||
|
|
11
|
+
this.wrapper.querySelector('.ds-table-search input'); // Fallback convention
|
|
12
|
+
|
|
13
|
+
if (this.input) {
|
|
14
|
+
this._init();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_init() {
|
|
19
|
+
let timeout;
|
|
20
|
+
this.input.addEventListener('input', (e) => {
|
|
21
|
+
clearTimeout(timeout);
|
|
22
|
+
timeout = setTimeout(() => {
|
|
23
|
+
const val = e.target.value;
|
|
24
|
+
this.table.setParam('search', val);
|
|
25
|
+
this.table.setParam('page', 1); // Reset to page 1 on search
|
|
26
|
+
this.table.loadData();
|
|
27
|
+
}, 500); // 500ms debounce
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Handle "X" clear search
|
|
31
|
+
this.input.addEventListener('search', (e) => {
|
|
32
|
+
if (e.target.value === '') {
|
|
33
|
+
this.table.setParam('search', '');
|
|
34
|
+
this.table.setParam('page', 1);
|
|
35
|
+
this.table.loadData();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export default DSTableSearch;
|