@idds/js 1.0.69 → 1.0.71
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/dist/index.iife.js +188 -18
- package/dist/index.js +187 -18
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -36,6 +36,7 @@ var InaUI = (() => {
|
|
|
36
36
|
initRangeDatepicker: () => initRangeDatepicker,
|
|
37
37
|
initSelectDropdown: () => initSelectDropdown,
|
|
38
38
|
initSingleFileUpload: () => initSingleFileUpload,
|
|
39
|
+
initStepper: () => initStepper,
|
|
39
40
|
initTab: () => initTab,
|
|
40
41
|
initTimepicker: () => initTimepicker,
|
|
41
42
|
initToggle: () => initToggle,
|
|
@@ -1024,6 +1025,129 @@ var InaUI = (() => {
|
|
|
1024
1025
|
});
|
|
1025
1026
|
}
|
|
1026
1027
|
|
|
1028
|
+
// src/js/components/stateful/stepper.js
|
|
1029
|
+
function initStepper() {
|
|
1030
|
+
const steppers = document.querySelectorAll(`.${PREFIX}-stepper`);
|
|
1031
|
+
steppers.forEach((stepper) => {
|
|
1032
|
+
if (stepper.dataset.initialized === "true") return;
|
|
1033
|
+
stepper.dataset.initialized = "true";
|
|
1034
|
+
const stepperId = stepper.id;
|
|
1035
|
+
const items = stepper.querySelectorAll(`.${PREFIX}-stepper__item`);
|
|
1036
|
+
const separators = stepper.querySelectorAll(
|
|
1037
|
+
`.${PREFIX}-stepper__separator`
|
|
1038
|
+
);
|
|
1039
|
+
const totalSteps = items.length;
|
|
1040
|
+
let currentStep = parseInt(stepper.dataset.currentStep || "0", 10);
|
|
1041
|
+
const nextBtns = document.querySelectorAll(
|
|
1042
|
+
`[data-stepper-next="${stepperId}"]`
|
|
1043
|
+
);
|
|
1044
|
+
const prevBtns = document.querySelectorAll(
|
|
1045
|
+
`[data-stepper-prev="${stepperId}"]`
|
|
1046
|
+
);
|
|
1047
|
+
const displayTargetId = stepper.dataset.displayTarget;
|
|
1048
|
+
const displayTarget = displayTargetId ? document.getElementById(displayTargetId) : null;
|
|
1049
|
+
const checkIcon = `
|
|
1050
|
+
<svg
|
|
1051
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
1052
|
+
class="${PREFIX}-stepper__check-icon"
|
|
1053
|
+
width="16"
|
|
1054
|
+
height="16"
|
|
1055
|
+
viewBox="0 0 24 24"
|
|
1056
|
+
stroke-width="2.5"
|
|
1057
|
+
stroke="currentColor"
|
|
1058
|
+
fill="none"
|
|
1059
|
+
stroke-linecap="round"
|
|
1060
|
+
stroke-linejoin="round"
|
|
1061
|
+
>
|
|
1062
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
1063
|
+
<path d="M5 12l5 5l10 -10" />
|
|
1064
|
+
</svg>
|
|
1065
|
+
`;
|
|
1066
|
+
const updateUI = () => {
|
|
1067
|
+
stepper.dataset.currentStep = currentStep;
|
|
1068
|
+
items.forEach((item, index) => {
|
|
1069
|
+
const iconWrapper = item.querySelector(
|
|
1070
|
+
`.${PREFIX}-stepper__icon-wrapper`
|
|
1071
|
+
);
|
|
1072
|
+
const itemNumber = index + 1;
|
|
1073
|
+
item.classList.remove(
|
|
1074
|
+
`${PREFIX}-stepper__item--completed`,
|
|
1075
|
+
`${PREFIX}-stepper__item--active`
|
|
1076
|
+
);
|
|
1077
|
+
if (iconWrapper) iconWrapper.innerHTML = "";
|
|
1078
|
+
if (index < currentStep) {
|
|
1079
|
+
item.classList.add(`${PREFIX}-stepper__item--completed`);
|
|
1080
|
+
if (iconWrapper) iconWrapper.innerHTML = checkIcon;
|
|
1081
|
+
} else if (index === currentStep) {
|
|
1082
|
+
item.classList.add(`${PREFIX}-stepper__item--active`);
|
|
1083
|
+
if (iconWrapper)
|
|
1084
|
+
iconWrapper.innerHTML = `<span class="${PREFIX}-stepper__step-number">${itemNumber}</span>`;
|
|
1085
|
+
} else {
|
|
1086
|
+
if (iconWrapper)
|
|
1087
|
+
iconWrapper.innerHTML = `<span class="${PREFIX}-stepper__step-number">${itemNumber}</span>`;
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1090
|
+
separators.forEach((separator, index) => {
|
|
1091
|
+
if (index < currentStep) {
|
|
1092
|
+
separator.classList.add(`${PREFIX}-stepper__separator--completed`);
|
|
1093
|
+
} else {
|
|
1094
|
+
separator.classList.remove(`${PREFIX}-stepper__separator--completed`);
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
prevBtns.forEach((btn) => {
|
|
1098
|
+
if (currentStep === 0) {
|
|
1099
|
+
btn.setAttribute("disabled", "true");
|
|
1100
|
+
} else {
|
|
1101
|
+
btn.removeAttribute("disabled");
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
nextBtns.forEach((btn) => {
|
|
1105
|
+
if (currentStep === totalSteps - 1) {
|
|
1106
|
+
btn.setAttribute("disabled", "true");
|
|
1107
|
+
} else {
|
|
1108
|
+
btn.removeAttribute("disabled");
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
if (displayTarget) {
|
|
1112
|
+
displayTarget.textContent = `Current Step: ${currentStep + 1}`;
|
|
1113
|
+
}
|
|
1114
|
+
stepper.dispatchEvent(
|
|
1115
|
+
new CustomEvent("stepper:change", {
|
|
1116
|
+
bubbles: true,
|
|
1117
|
+
detail: { currentStep, totalSteps }
|
|
1118
|
+
})
|
|
1119
|
+
);
|
|
1120
|
+
};
|
|
1121
|
+
nextBtns.forEach((btn) => {
|
|
1122
|
+
btn.addEventListener("click", () => {
|
|
1123
|
+
if (currentStep < totalSteps - 1) {
|
|
1124
|
+
currentStep++;
|
|
1125
|
+
updateUI();
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
});
|
|
1129
|
+
prevBtns.forEach((btn) => {
|
|
1130
|
+
btn.addEventListener("click", () => {
|
|
1131
|
+
if (currentStep > 0) {
|
|
1132
|
+
currentStep--;
|
|
1133
|
+
updateUI();
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
});
|
|
1137
|
+
items.forEach((item, index) => {
|
|
1138
|
+
if (item.classList.contains(`${PREFIX}-stepper__item--clickable`) || item.hasAttribute("data-clickable")) {
|
|
1139
|
+
item.addEventListener("click", () => {
|
|
1140
|
+
if (!item.classList.contains(`${PREFIX}-stepper__item--disabled`)) {
|
|
1141
|
+
currentStep = index;
|
|
1142
|
+
updateUI();
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
updateUI();
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1027
1151
|
// src/js/components/stateful/file-upload.js
|
|
1028
1152
|
var ICONS = {
|
|
1029
1153
|
upload: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"></path><polyline points="16 6 12 2 8 6"></polyline><line x1="12" y1="2" x2="12" y2="16"></line></svg>`,
|
|
@@ -2280,53 +2404,65 @@ var InaUI = (() => {
|
|
|
2280
2404
|
let currentPage = parseInt(container.dataset.current || "1", 10);
|
|
2281
2405
|
let totalPages = parseInt(container.dataset.total || "10", 10);
|
|
2282
2406
|
let pageSize = parseInt(container.dataset.pageSize || "10", 10);
|
|
2407
|
+
let isDisabled = container.dataset.disabled === "true";
|
|
2283
2408
|
let pageButtons = [];
|
|
2284
2409
|
const updateUI = () => {
|
|
2285
2410
|
pageInfo.textContent = `Halaman ${currentPage} dari ${totalPages}`;
|
|
2286
2411
|
const isFirst = currentPage === 1;
|
|
2287
2412
|
if (firstBtn) {
|
|
2288
|
-
|
|
2413
|
+
const disabled = isDisabled || isFirst;
|
|
2414
|
+
firstBtn.disabled = disabled;
|
|
2289
2415
|
firstBtn.classList.toggle(
|
|
2290
2416
|
`${PREFIX}-pagination__nav-button--disabled`,
|
|
2291
|
-
|
|
2417
|
+
disabled
|
|
2292
2418
|
);
|
|
2293
2419
|
firstBtn.classList.toggle(
|
|
2294
2420
|
`${PREFIX}-pagination__nav-button--enabled`,
|
|
2295
|
-
!
|
|
2421
|
+
!disabled
|
|
2296
2422
|
);
|
|
2297
2423
|
}
|
|
2298
2424
|
if (prevBtn) {
|
|
2299
|
-
|
|
2425
|
+
const disabled = isDisabled || isFirst;
|
|
2426
|
+
prevBtn.disabled = disabled;
|
|
2300
2427
|
prevBtn.classList.toggle(
|
|
2301
2428
|
`${PREFIX}-pagination__nav-button--disabled`,
|
|
2302
|
-
|
|
2429
|
+
disabled
|
|
2303
2430
|
);
|
|
2304
2431
|
prevBtn.classList.toggle(
|
|
2305
2432
|
`${PREFIX}-pagination__nav-button--enabled`,
|
|
2306
|
-
!
|
|
2433
|
+
!disabled
|
|
2307
2434
|
);
|
|
2308
2435
|
}
|
|
2309
2436
|
const isLast = currentPage === totalPages;
|
|
2310
2437
|
if (nextBtn) {
|
|
2311
|
-
|
|
2438
|
+
const disabled = isDisabled || isLast;
|
|
2439
|
+
nextBtn.disabled = disabled;
|
|
2312
2440
|
nextBtn.classList.toggle(
|
|
2313
2441
|
`${PREFIX}-pagination__nav-button--disabled`,
|
|
2314
|
-
|
|
2442
|
+
disabled
|
|
2315
2443
|
);
|
|
2316
2444
|
nextBtn.classList.toggle(
|
|
2317
2445
|
`${PREFIX}-pagination__nav-button--enabled`,
|
|
2318
|
-
!
|
|
2446
|
+
!disabled
|
|
2319
2447
|
);
|
|
2320
2448
|
}
|
|
2321
2449
|
if (lastBtn) {
|
|
2322
|
-
|
|
2450
|
+
const disabled = isDisabled || isLast;
|
|
2451
|
+
lastBtn.disabled = disabled;
|
|
2323
2452
|
lastBtn.classList.toggle(
|
|
2324
2453
|
`${PREFIX}-pagination__nav-button--disabled`,
|
|
2325
|
-
|
|
2454
|
+
disabled
|
|
2326
2455
|
);
|
|
2327
2456
|
lastBtn.classList.toggle(
|
|
2328
2457
|
`${PREFIX}-pagination__nav-button--enabled`,
|
|
2329
|
-
!
|
|
2458
|
+
!disabled
|
|
2459
|
+
);
|
|
2460
|
+
}
|
|
2461
|
+
if (pageSizeSelect) {
|
|
2462
|
+
pageSizeSelect.disabled = isDisabled;
|
|
2463
|
+
pageSizeSelect.classList.toggle(
|
|
2464
|
+
`${PREFIX}-pagination__page-size-select--disabled`,
|
|
2465
|
+
isDisabled
|
|
2330
2466
|
);
|
|
2331
2467
|
}
|
|
2332
2468
|
renderPageNumbers();
|
|
@@ -2353,10 +2489,11 @@ var InaUI = (() => {
|
|
|
2353
2489
|
const button = document.createElement("button");
|
|
2354
2490
|
button.type = "button";
|
|
2355
2491
|
button.textContent = i;
|
|
2356
|
-
button.
|
|
2492
|
+
button.disabled = isDisabled;
|
|
2493
|
+
button.className = `${PREFIX}-pagination__page-button ${PREFIX}-pagination__page-button--${isActive ? "active" : isDisabled ? "disabled" : "enabled"}`;
|
|
2357
2494
|
button.addEventListener("click", (e) => {
|
|
2358
2495
|
e.stopPropagation();
|
|
2359
|
-
if (i !== currentPage) {
|
|
2496
|
+
if (!isDisabled && i !== currentPage) {
|
|
2360
2497
|
goToPage(i);
|
|
2361
2498
|
}
|
|
2362
2499
|
});
|
|
@@ -2365,6 +2502,7 @@ var InaUI = (() => {
|
|
|
2365
2502
|
}
|
|
2366
2503
|
};
|
|
2367
2504
|
const goToPage = (page) => {
|
|
2505
|
+
if (isDisabled) return;
|
|
2368
2506
|
if (page < 1) page = 1;
|
|
2369
2507
|
if (page > totalPages) page = totalPages;
|
|
2370
2508
|
if (page === currentPage) return;
|
|
@@ -2385,24 +2523,55 @@ var InaUI = (() => {
|
|
|
2385
2523
|
})
|
|
2386
2524
|
);
|
|
2387
2525
|
};
|
|
2526
|
+
const observer = new MutationObserver((mutations) => {
|
|
2527
|
+
mutations.forEach((mutation) => {
|
|
2528
|
+
if (mutation.type === "attributes") {
|
|
2529
|
+
if (mutation.attributeName === "data-current") {
|
|
2530
|
+
const newVal = parseInt(container.dataset.current || "1", 10);
|
|
2531
|
+
if (newVal !== currentPage) {
|
|
2532
|
+
currentPage = newVal;
|
|
2533
|
+
updateUI();
|
|
2534
|
+
}
|
|
2535
|
+
} else if (mutation.attributeName === "data-total") {
|
|
2536
|
+
totalPages = parseInt(container.dataset.total || "10", 10);
|
|
2537
|
+
updateUI();
|
|
2538
|
+
} else if (mutation.attributeName === "data-page-size") {
|
|
2539
|
+
pageSize = parseInt(container.dataset.pageSize || "10", 10);
|
|
2540
|
+
} else if (mutation.attributeName === "data-disabled") {
|
|
2541
|
+
isDisabled = container.dataset.disabled === "true";
|
|
2542
|
+
updateUI();
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
});
|
|
2546
|
+
});
|
|
2547
|
+
observer.observe(container, {
|
|
2548
|
+
attributes: true,
|
|
2549
|
+
attributeFilter: [
|
|
2550
|
+
"data-current",
|
|
2551
|
+
"data-total",
|
|
2552
|
+
"data-page-size",
|
|
2553
|
+
"data-disabled"
|
|
2554
|
+
]
|
|
2555
|
+
});
|
|
2388
2556
|
if (firstBtn)
|
|
2389
2557
|
firstBtn.addEventListener("click", () => {
|
|
2390
|
-
if (currentPage > 1) goToPage(1);
|
|
2558
|
+
if (!isDisabled && currentPage > 1) goToPage(1);
|
|
2391
2559
|
});
|
|
2392
2560
|
if (prevBtn)
|
|
2393
2561
|
prevBtn.addEventListener("click", () => {
|
|
2394
|
-
if (currentPage > 1) goToPage(currentPage - 1);
|
|
2562
|
+
if (!isDisabled && currentPage > 1) goToPage(currentPage - 1);
|
|
2395
2563
|
});
|
|
2396
2564
|
if (nextBtn)
|
|
2397
2565
|
nextBtn.addEventListener("click", () => {
|
|
2398
|
-
if (currentPage < totalPages) goToPage(currentPage + 1);
|
|
2566
|
+
if (!isDisabled && currentPage < totalPages) goToPage(currentPage + 1);
|
|
2399
2567
|
});
|
|
2400
2568
|
if (lastBtn)
|
|
2401
2569
|
lastBtn.addEventListener("click", () => {
|
|
2402
|
-
if (currentPage < totalPages) goToPage(totalPages);
|
|
2570
|
+
if (!isDisabled && currentPage < totalPages) goToPage(totalPages);
|
|
2403
2571
|
});
|
|
2404
2572
|
if (pageSizeSelect) {
|
|
2405
2573
|
pageSizeSelect.addEventListener("change", (e) => {
|
|
2574
|
+
if (isDisabled) return;
|
|
2406
2575
|
pageSize = parseInt(e.target.value, 10);
|
|
2407
2576
|
currentPage = 1;
|
|
2408
2577
|
container.dataset.pageSize = pageSize;
|
|
@@ -2690,6 +2859,7 @@ var InaUI = (() => {
|
|
|
2690
2859
|
initModal();
|
|
2691
2860
|
initRangeDatepicker();
|
|
2692
2861
|
initRadioButton();
|
|
2862
|
+
initStepper();
|
|
2693
2863
|
initTab();
|
|
2694
2864
|
initTimepicker();
|
|
2695
2865
|
initToggle();
|
package/dist/index.js
CHANGED
|
@@ -1187,6 +1187,129 @@ function initRadioButton() {
|
|
|
1187
1187
|
});
|
|
1188
1188
|
}
|
|
1189
1189
|
|
|
1190
|
+
// src/js/components/stateful/stepper.js
|
|
1191
|
+
function initStepper() {
|
|
1192
|
+
const steppers = document.querySelectorAll(`.${PREFIX}-stepper`);
|
|
1193
|
+
steppers.forEach((stepper) => {
|
|
1194
|
+
if (stepper.dataset.initialized === "true") return;
|
|
1195
|
+
stepper.dataset.initialized = "true";
|
|
1196
|
+
const stepperId = stepper.id;
|
|
1197
|
+
const items = stepper.querySelectorAll(`.${PREFIX}-stepper__item`);
|
|
1198
|
+
const separators = stepper.querySelectorAll(
|
|
1199
|
+
`.${PREFIX}-stepper__separator`
|
|
1200
|
+
);
|
|
1201
|
+
const totalSteps = items.length;
|
|
1202
|
+
let currentStep = parseInt(stepper.dataset.currentStep || "0", 10);
|
|
1203
|
+
const nextBtns = document.querySelectorAll(
|
|
1204
|
+
`[data-stepper-next="${stepperId}"]`
|
|
1205
|
+
);
|
|
1206
|
+
const prevBtns = document.querySelectorAll(
|
|
1207
|
+
`[data-stepper-prev="${stepperId}"]`
|
|
1208
|
+
);
|
|
1209
|
+
const displayTargetId = stepper.dataset.displayTarget;
|
|
1210
|
+
const displayTarget = displayTargetId ? document.getElementById(displayTargetId) : null;
|
|
1211
|
+
const checkIcon = `
|
|
1212
|
+
<svg
|
|
1213
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
1214
|
+
class="${PREFIX}-stepper__check-icon"
|
|
1215
|
+
width="16"
|
|
1216
|
+
height="16"
|
|
1217
|
+
viewBox="0 0 24 24"
|
|
1218
|
+
stroke-width="2.5"
|
|
1219
|
+
stroke="currentColor"
|
|
1220
|
+
fill="none"
|
|
1221
|
+
stroke-linecap="round"
|
|
1222
|
+
stroke-linejoin="round"
|
|
1223
|
+
>
|
|
1224
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
1225
|
+
<path d="M5 12l5 5l10 -10" />
|
|
1226
|
+
</svg>
|
|
1227
|
+
`;
|
|
1228
|
+
const updateUI = () => {
|
|
1229
|
+
stepper.dataset.currentStep = currentStep;
|
|
1230
|
+
items.forEach((item, index) => {
|
|
1231
|
+
const iconWrapper = item.querySelector(
|
|
1232
|
+
`.${PREFIX}-stepper__icon-wrapper`
|
|
1233
|
+
);
|
|
1234
|
+
const itemNumber = index + 1;
|
|
1235
|
+
item.classList.remove(
|
|
1236
|
+
`${PREFIX}-stepper__item--completed`,
|
|
1237
|
+
`${PREFIX}-stepper__item--active`
|
|
1238
|
+
);
|
|
1239
|
+
if (iconWrapper) iconWrapper.innerHTML = "";
|
|
1240
|
+
if (index < currentStep) {
|
|
1241
|
+
item.classList.add(`${PREFIX}-stepper__item--completed`);
|
|
1242
|
+
if (iconWrapper) iconWrapper.innerHTML = checkIcon;
|
|
1243
|
+
} else if (index === currentStep) {
|
|
1244
|
+
item.classList.add(`${PREFIX}-stepper__item--active`);
|
|
1245
|
+
if (iconWrapper)
|
|
1246
|
+
iconWrapper.innerHTML = `<span class="${PREFIX}-stepper__step-number">${itemNumber}</span>`;
|
|
1247
|
+
} else {
|
|
1248
|
+
if (iconWrapper)
|
|
1249
|
+
iconWrapper.innerHTML = `<span class="${PREFIX}-stepper__step-number">${itemNumber}</span>`;
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
separators.forEach((separator, index) => {
|
|
1253
|
+
if (index < currentStep) {
|
|
1254
|
+
separator.classList.add(`${PREFIX}-stepper__separator--completed`);
|
|
1255
|
+
} else {
|
|
1256
|
+
separator.classList.remove(`${PREFIX}-stepper__separator--completed`);
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
prevBtns.forEach((btn) => {
|
|
1260
|
+
if (currentStep === 0) {
|
|
1261
|
+
btn.setAttribute("disabled", "true");
|
|
1262
|
+
} else {
|
|
1263
|
+
btn.removeAttribute("disabled");
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
nextBtns.forEach((btn) => {
|
|
1267
|
+
if (currentStep === totalSteps - 1) {
|
|
1268
|
+
btn.setAttribute("disabled", "true");
|
|
1269
|
+
} else {
|
|
1270
|
+
btn.removeAttribute("disabled");
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
if (displayTarget) {
|
|
1274
|
+
displayTarget.textContent = `Current Step: ${currentStep + 1}`;
|
|
1275
|
+
}
|
|
1276
|
+
stepper.dispatchEvent(
|
|
1277
|
+
new CustomEvent("stepper:change", {
|
|
1278
|
+
bubbles: true,
|
|
1279
|
+
detail: { currentStep, totalSteps }
|
|
1280
|
+
})
|
|
1281
|
+
);
|
|
1282
|
+
};
|
|
1283
|
+
nextBtns.forEach((btn) => {
|
|
1284
|
+
btn.addEventListener("click", () => {
|
|
1285
|
+
if (currentStep < totalSteps - 1) {
|
|
1286
|
+
currentStep++;
|
|
1287
|
+
updateUI();
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1290
|
+
});
|
|
1291
|
+
prevBtns.forEach((btn) => {
|
|
1292
|
+
btn.addEventListener("click", () => {
|
|
1293
|
+
if (currentStep > 0) {
|
|
1294
|
+
currentStep--;
|
|
1295
|
+
updateUI();
|
|
1296
|
+
}
|
|
1297
|
+
});
|
|
1298
|
+
});
|
|
1299
|
+
items.forEach((item, index) => {
|
|
1300
|
+
if (item.classList.contains(`${PREFIX}-stepper__item--clickable`) || item.hasAttribute("data-clickable")) {
|
|
1301
|
+
item.addEventListener("click", () => {
|
|
1302
|
+
if (!item.classList.contains(`${PREFIX}-stepper__item--disabled`)) {
|
|
1303
|
+
currentStep = index;
|
|
1304
|
+
updateUI();
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
updateUI();
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1190
1313
|
// src/js/components/stateful/file-upload.js
|
|
1191
1314
|
var ICONS = {
|
|
1192
1315
|
upload: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"></path><polyline points="16 6 12 2 8 6"></polyline><line x1="12" y1="2" x2="12" y2="16"></line></svg>`,
|
|
@@ -2443,53 +2566,65 @@ function initPagination() {
|
|
|
2443
2566
|
let currentPage = parseInt(container.dataset.current || "1", 10);
|
|
2444
2567
|
let totalPages = parseInt(container.dataset.total || "10", 10);
|
|
2445
2568
|
let pageSize = parseInt(container.dataset.pageSize || "10", 10);
|
|
2569
|
+
let isDisabled = container.dataset.disabled === "true";
|
|
2446
2570
|
let pageButtons = [];
|
|
2447
2571
|
const updateUI = () => {
|
|
2448
2572
|
pageInfo.textContent = `Halaman ${currentPage} dari ${totalPages}`;
|
|
2449
2573
|
const isFirst = currentPage === 1;
|
|
2450
2574
|
if (firstBtn) {
|
|
2451
|
-
|
|
2575
|
+
const disabled = isDisabled || isFirst;
|
|
2576
|
+
firstBtn.disabled = disabled;
|
|
2452
2577
|
firstBtn.classList.toggle(
|
|
2453
2578
|
`${PREFIX}-pagination__nav-button--disabled`,
|
|
2454
|
-
|
|
2579
|
+
disabled
|
|
2455
2580
|
);
|
|
2456
2581
|
firstBtn.classList.toggle(
|
|
2457
2582
|
`${PREFIX}-pagination__nav-button--enabled`,
|
|
2458
|
-
!
|
|
2583
|
+
!disabled
|
|
2459
2584
|
);
|
|
2460
2585
|
}
|
|
2461
2586
|
if (prevBtn) {
|
|
2462
|
-
|
|
2587
|
+
const disabled = isDisabled || isFirst;
|
|
2588
|
+
prevBtn.disabled = disabled;
|
|
2463
2589
|
prevBtn.classList.toggle(
|
|
2464
2590
|
`${PREFIX}-pagination__nav-button--disabled`,
|
|
2465
|
-
|
|
2591
|
+
disabled
|
|
2466
2592
|
);
|
|
2467
2593
|
prevBtn.classList.toggle(
|
|
2468
2594
|
`${PREFIX}-pagination__nav-button--enabled`,
|
|
2469
|
-
!
|
|
2595
|
+
!disabled
|
|
2470
2596
|
);
|
|
2471
2597
|
}
|
|
2472
2598
|
const isLast = currentPage === totalPages;
|
|
2473
2599
|
if (nextBtn) {
|
|
2474
|
-
|
|
2600
|
+
const disabled = isDisabled || isLast;
|
|
2601
|
+
nextBtn.disabled = disabled;
|
|
2475
2602
|
nextBtn.classList.toggle(
|
|
2476
2603
|
`${PREFIX}-pagination__nav-button--disabled`,
|
|
2477
|
-
|
|
2604
|
+
disabled
|
|
2478
2605
|
);
|
|
2479
2606
|
nextBtn.classList.toggle(
|
|
2480
2607
|
`${PREFIX}-pagination__nav-button--enabled`,
|
|
2481
|
-
!
|
|
2608
|
+
!disabled
|
|
2482
2609
|
);
|
|
2483
2610
|
}
|
|
2484
2611
|
if (lastBtn) {
|
|
2485
|
-
|
|
2612
|
+
const disabled = isDisabled || isLast;
|
|
2613
|
+
lastBtn.disabled = disabled;
|
|
2486
2614
|
lastBtn.classList.toggle(
|
|
2487
2615
|
`${PREFIX}-pagination__nav-button--disabled`,
|
|
2488
|
-
|
|
2616
|
+
disabled
|
|
2489
2617
|
);
|
|
2490
2618
|
lastBtn.classList.toggle(
|
|
2491
2619
|
`${PREFIX}-pagination__nav-button--enabled`,
|
|
2492
|
-
!
|
|
2620
|
+
!disabled
|
|
2621
|
+
);
|
|
2622
|
+
}
|
|
2623
|
+
if (pageSizeSelect) {
|
|
2624
|
+
pageSizeSelect.disabled = isDisabled;
|
|
2625
|
+
pageSizeSelect.classList.toggle(
|
|
2626
|
+
`${PREFIX}-pagination__page-size-select--disabled`,
|
|
2627
|
+
isDisabled
|
|
2493
2628
|
);
|
|
2494
2629
|
}
|
|
2495
2630
|
renderPageNumbers();
|
|
@@ -2516,10 +2651,11 @@ function initPagination() {
|
|
|
2516
2651
|
const button = document.createElement("button");
|
|
2517
2652
|
button.type = "button";
|
|
2518
2653
|
button.textContent = i;
|
|
2519
|
-
button.
|
|
2654
|
+
button.disabled = isDisabled;
|
|
2655
|
+
button.className = `${PREFIX}-pagination__page-button ${PREFIX}-pagination__page-button--${isActive ? "active" : isDisabled ? "disabled" : "enabled"}`;
|
|
2520
2656
|
button.addEventListener("click", (e) => {
|
|
2521
2657
|
e.stopPropagation();
|
|
2522
|
-
if (i !== currentPage) {
|
|
2658
|
+
if (!isDisabled && i !== currentPage) {
|
|
2523
2659
|
goToPage(i);
|
|
2524
2660
|
}
|
|
2525
2661
|
});
|
|
@@ -2528,6 +2664,7 @@ function initPagination() {
|
|
|
2528
2664
|
}
|
|
2529
2665
|
};
|
|
2530
2666
|
const goToPage = (page) => {
|
|
2667
|
+
if (isDisabled) return;
|
|
2531
2668
|
if (page < 1) page = 1;
|
|
2532
2669
|
if (page > totalPages) page = totalPages;
|
|
2533
2670
|
if (page === currentPage) return;
|
|
@@ -2548,24 +2685,55 @@ function initPagination() {
|
|
|
2548
2685
|
})
|
|
2549
2686
|
);
|
|
2550
2687
|
};
|
|
2688
|
+
const observer = new MutationObserver((mutations) => {
|
|
2689
|
+
mutations.forEach((mutation) => {
|
|
2690
|
+
if (mutation.type === "attributes") {
|
|
2691
|
+
if (mutation.attributeName === "data-current") {
|
|
2692
|
+
const newVal = parseInt(container.dataset.current || "1", 10);
|
|
2693
|
+
if (newVal !== currentPage) {
|
|
2694
|
+
currentPage = newVal;
|
|
2695
|
+
updateUI();
|
|
2696
|
+
}
|
|
2697
|
+
} else if (mutation.attributeName === "data-total") {
|
|
2698
|
+
totalPages = parseInt(container.dataset.total || "10", 10);
|
|
2699
|
+
updateUI();
|
|
2700
|
+
} else if (mutation.attributeName === "data-page-size") {
|
|
2701
|
+
pageSize = parseInt(container.dataset.pageSize || "10", 10);
|
|
2702
|
+
} else if (mutation.attributeName === "data-disabled") {
|
|
2703
|
+
isDisabled = container.dataset.disabled === "true";
|
|
2704
|
+
updateUI();
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
});
|
|
2708
|
+
});
|
|
2709
|
+
observer.observe(container, {
|
|
2710
|
+
attributes: true,
|
|
2711
|
+
attributeFilter: [
|
|
2712
|
+
"data-current",
|
|
2713
|
+
"data-total",
|
|
2714
|
+
"data-page-size",
|
|
2715
|
+
"data-disabled"
|
|
2716
|
+
]
|
|
2717
|
+
});
|
|
2551
2718
|
if (firstBtn)
|
|
2552
2719
|
firstBtn.addEventListener("click", () => {
|
|
2553
|
-
if (currentPage > 1) goToPage(1);
|
|
2720
|
+
if (!isDisabled && currentPage > 1) goToPage(1);
|
|
2554
2721
|
});
|
|
2555
2722
|
if (prevBtn)
|
|
2556
2723
|
prevBtn.addEventListener("click", () => {
|
|
2557
|
-
if (currentPage > 1) goToPage(currentPage - 1);
|
|
2724
|
+
if (!isDisabled && currentPage > 1) goToPage(currentPage - 1);
|
|
2558
2725
|
});
|
|
2559
2726
|
if (nextBtn)
|
|
2560
2727
|
nextBtn.addEventListener("click", () => {
|
|
2561
|
-
if (currentPage < totalPages) goToPage(currentPage + 1);
|
|
2728
|
+
if (!isDisabled && currentPage < totalPages) goToPage(currentPage + 1);
|
|
2562
2729
|
});
|
|
2563
2730
|
if (lastBtn)
|
|
2564
2731
|
lastBtn.addEventListener("click", () => {
|
|
2565
|
-
if (currentPage < totalPages) goToPage(totalPages);
|
|
2732
|
+
if (!isDisabled && currentPage < totalPages) goToPage(totalPages);
|
|
2566
2733
|
});
|
|
2567
2734
|
if (pageSizeSelect) {
|
|
2568
2735
|
pageSizeSelect.addEventListener("change", (e) => {
|
|
2736
|
+
if (isDisabled) return;
|
|
2569
2737
|
pageSize = parseInt(e.target.value, 10);
|
|
2570
2738
|
currentPage = 1;
|
|
2571
2739
|
container.dataset.pageSize = pageSize;
|
|
@@ -2660,6 +2828,7 @@ function initAll() {
|
|
|
2660
2828
|
initActionDropdown();
|
|
2661
2829
|
initSelectDropdown();
|
|
2662
2830
|
initRadioButton();
|
|
2831
|
+
initStepper();
|
|
2663
2832
|
initFileUpload();
|
|
2664
2833
|
initSingleFileUpload();
|
|
2665
2834
|
initFileUploadBase();
|