@idds/js 1.0.80 → 1.0.82
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 +110 -30
- package/dist/index.js +6 -0
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -25,6 +25,7 @@ var InaUI = (() => {
|
|
|
25
25
|
initCheckbox: () => initCheckbox,
|
|
26
26
|
initChip: () => initChip,
|
|
27
27
|
initDatepicker: () => initDatepicker,
|
|
28
|
+
initDrawer: () => initDrawer,
|
|
28
29
|
initDropdown: () => initDropdown,
|
|
29
30
|
initFileUpload: () => initFileUpload,
|
|
30
31
|
initFileUploadBase: () => initFileUploadBase,
|
|
@@ -960,8 +961,86 @@ var InaUI = (() => {
|
|
|
960
961
|
});
|
|
961
962
|
}
|
|
962
963
|
|
|
963
|
-
// src/js/components/
|
|
964
|
+
// src/js/components/stateless/drawer.js
|
|
964
965
|
var PREFIX2 = "ina";
|
|
966
|
+
function initDrawer(rootSelector = `.${PREFIX2}-drawer`) {
|
|
967
|
+
const drawers = document.querySelectorAll(rootSelector);
|
|
968
|
+
const closeDrawer = (drawer) => {
|
|
969
|
+
if (!drawer) return;
|
|
970
|
+
drawer.classList.add(`${PREFIX2}-drawer--closing`);
|
|
971
|
+
drawer.classList.remove(`${PREFIX2}-drawer--open`);
|
|
972
|
+
const onAnimationEnd = () => {
|
|
973
|
+
drawer.classList.remove(`${PREFIX2}-drawer--closing`);
|
|
974
|
+
drawer.style.display = "none";
|
|
975
|
+
document.body.style.overflow = "";
|
|
976
|
+
drawer.removeEventListener("animationend", onAnimationEnd);
|
|
977
|
+
};
|
|
978
|
+
setTimeout(() => {
|
|
979
|
+
if (drawer.style.display !== "none") onAnimationEnd();
|
|
980
|
+
}, 300);
|
|
981
|
+
drawer.addEventListener("animationend", onAnimationEnd, { once: true });
|
|
982
|
+
};
|
|
983
|
+
const openDrawer = (drawer) => {
|
|
984
|
+
if (!drawer) return;
|
|
985
|
+
drawer.style.display = "flex";
|
|
986
|
+
document.body.style.overflow = "hidden";
|
|
987
|
+
drawer.offsetHeight;
|
|
988
|
+
drawer.classList.add(`${PREFIX2}-drawer--open`);
|
|
989
|
+
drawer.dispatchEvent(new CustomEvent("drawer:open"));
|
|
990
|
+
};
|
|
991
|
+
drawers.forEach((drawer) => {
|
|
992
|
+
if (drawer.__inaDrawerInitialized) return;
|
|
993
|
+
const isPersistent = drawer.getAttribute("data-persistent") === "true";
|
|
994
|
+
const closeBtns = drawer.querySelectorAll(
|
|
995
|
+
`.${PREFIX2}-drawer__close-button`
|
|
996
|
+
);
|
|
997
|
+
closeBtns.forEach((btn) => {
|
|
998
|
+
btn.addEventListener("click", () => closeDrawer(drawer));
|
|
999
|
+
});
|
|
1000
|
+
const backdrop = drawer.querySelector(`.${PREFIX2}-drawer__backdrop`);
|
|
1001
|
+
if (backdrop) {
|
|
1002
|
+
backdrop.addEventListener("click", (e) => {
|
|
1003
|
+
if (!isPersistent) {
|
|
1004
|
+
closeDrawer(drawer);
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
document.addEventListener("keydown", (e) => {
|
|
1009
|
+
if (e.key === "Escape" && drawer.style.display === "flex" && !isPersistent) {
|
|
1010
|
+
closeDrawer(drawer);
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
drawer.__inaDrawerInitialized = true;
|
|
1014
|
+
});
|
|
1015
|
+
document.body.addEventListener("click", (e) => {
|
|
1016
|
+
const trigger = e.target.closest('[data-trigger="drawer"]');
|
|
1017
|
+
if (trigger) {
|
|
1018
|
+
const targetId = trigger.getAttribute("data-target");
|
|
1019
|
+
if (targetId) {
|
|
1020
|
+
const targetDrawer = document.querySelector(targetId);
|
|
1021
|
+
if (targetDrawer) {
|
|
1022
|
+
openDrawer(targetDrawer);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
const closeTrigger = e.target.closest('[data-dismiss="drawer"]');
|
|
1027
|
+
if (closeTrigger) {
|
|
1028
|
+
const targetId = closeTrigger.getAttribute("data-target");
|
|
1029
|
+
let targetDrawer;
|
|
1030
|
+
if (targetId) {
|
|
1031
|
+
targetDrawer = document.querySelector(targetId);
|
|
1032
|
+
} else {
|
|
1033
|
+
targetDrawer = closeTrigger.closest(`.${PREFIX2}-drawer`);
|
|
1034
|
+
}
|
|
1035
|
+
if (targetDrawer) {
|
|
1036
|
+
closeDrawer(targetDrawer);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// src/js/components/stateful/select-dropdown.js
|
|
1043
|
+
var PREFIX3 = "ina";
|
|
965
1044
|
function getDropdownState(root) {
|
|
966
1045
|
return {
|
|
967
1046
|
isOpen: root.getAttribute("data-state") === "open",
|
|
@@ -973,9 +1052,9 @@ var InaUI = (() => {
|
|
|
973
1052
|
function setDropdownState(root, newState) {
|
|
974
1053
|
if (newState.isOpen !== void 0) {
|
|
975
1054
|
root.setAttribute("data-state", newState.isOpen ? "open" : "closed");
|
|
976
|
-
const trigger = root.querySelector(`.${
|
|
1055
|
+
const trigger = root.querySelector(`.${PREFIX3}-select-dropdown__trigger`);
|
|
977
1056
|
if (trigger) trigger.setAttribute("aria-expanded", newState.isOpen);
|
|
978
|
-
const panel = root.querySelector(`.${
|
|
1057
|
+
const panel = root.querySelector(`.${PREFIX3}-select-dropdown__panel`);
|
|
979
1058
|
if (panel) {
|
|
980
1059
|
if (newState.isOpen) {
|
|
981
1060
|
panel.style.removeProperty("display");
|
|
@@ -990,20 +1069,20 @@ var InaUI = (() => {
|
|
|
990
1069
|
}
|
|
991
1070
|
}
|
|
992
1071
|
function closeAllSelectDropdowns(exceptRoot = null) {
|
|
993
|
-
document.querySelectorAll(`.${
|
|
1072
|
+
document.querySelectorAll(`.${PREFIX3}-select-dropdown[data-state="open"]`).forEach((root) => {
|
|
994
1073
|
if (root !== exceptRoot) {
|
|
995
1074
|
setDropdownState(root, { isOpen: false });
|
|
996
1075
|
}
|
|
997
1076
|
});
|
|
998
1077
|
}
|
|
999
1078
|
function updateTriggerUI(root, values, isMultiple) {
|
|
1000
|
-
const trigger = root.querySelector(`.${
|
|
1079
|
+
const trigger = root.querySelector(`.${PREFIX3}-select-dropdown__trigger`);
|
|
1001
1080
|
const input = trigger.querySelector("input");
|
|
1002
1081
|
const textSpan = trigger.querySelector(
|
|
1003
|
-
`.${
|
|
1082
|
+
`.${PREFIX3}-select-dropdown__trigger-text`
|
|
1004
1083
|
);
|
|
1005
1084
|
const placeholder = input ? input.getAttribute("placeholder") : textSpan ? textSpan.getAttribute("data-placeholder") : "Select...";
|
|
1006
|
-
const options = root.querySelectorAll(`.${
|
|
1085
|
+
const options = root.querySelectorAll(`.${PREFIX3}-select-dropdown__option`);
|
|
1007
1086
|
const getLabel = (val) => {
|
|
1008
1087
|
const opt = Array.from(options).find(
|
|
1009
1088
|
(o) => o.getAttribute("data-value") === val
|
|
@@ -1027,7 +1106,7 @@ var InaUI = (() => {
|
|
|
1027
1106
|
} else if (textSpan) {
|
|
1028
1107
|
textSpan.textContent = values.length > 0 ? label : placeholder;
|
|
1029
1108
|
textSpan.classList.toggle(
|
|
1030
|
-
`${
|
|
1109
|
+
`${PREFIX3}-select-dropdown__trigger-text--placeholder`,
|
|
1031
1110
|
values.length === 0
|
|
1032
1111
|
);
|
|
1033
1112
|
}
|
|
@@ -1036,20 +1115,20 @@ var InaUI = (() => {
|
|
|
1036
1115
|
const isSelected = values.includes(val);
|
|
1037
1116
|
if (isMultiple) {
|
|
1038
1117
|
opt.classList.toggle(
|
|
1039
|
-
`${
|
|
1118
|
+
`${PREFIX3}-select-dropdown__option--selected-multiple`,
|
|
1040
1119
|
isSelected
|
|
1041
1120
|
);
|
|
1042
1121
|
const cb = opt.querySelector(
|
|
1043
|
-
`.${
|
|
1122
|
+
`.${PREFIX3}-select-dropdown__option-checkbox`
|
|
1044
1123
|
);
|
|
1045
1124
|
if (cb)
|
|
1046
1125
|
cb.classList.toggle(
|
|
1047
|
-
`${
|
|
1126
|
+
`${PREFIX3}-select-dropdown__option-checkbox--checked`,
|
|
1048
1127
|
isSelected
|
|
1049
1128
|
);
|
|
1050
1129
|
} else {
|
|
1051
1130
|
opt.classList.toggle(
|
|
1052
|
-
`${
|
|
1131
|
+
`${PREFIX3}-select-dropdown__option--selected-single`,
|
|
1053
1132
|
isSelected
|
|
1054
1133
|
);
|
|
1055
1134
|
}
|
|
@@ -1059,9 +1138,9 @@ var InaUI = (() => {
|
|
|
1059
1138
|
if (window.__inaSelectDropdownInitialized) return;
|
|
1060
1139
|
document.addEventListener("click", (e) => {
|
|
1061
1140
|
const target = e.target;
|
|
1062
|
-
const trigger = target.closest(`.${
|
|
1063
|
-
const option = target.closest(`.${
|
|
1064
|
-
const root = target.closest(`.${
|
|
1141
|
+
const trigger = target.closest(`.${PREFIX3}-select-dropdown__trigger`);
|
|
1142
|
+
const option = target.closest(`.${PREFIX3}-select-dropdown__option`);
|
|
1143
|
+
const root = target.closest(`.${PREFIX3}-select-dropdown`);
|
|
1065
1144
|
if (trigger) {
|
|
1066
1145
|
if (root) {
|
|
1067
1146
|
const state = getDropdownState(root);
|
|
@@ -1107,12 +1186,12 @@ var InaUI = (() => {
|
|
|
1107
1186
|
}
|
|
1108
1187
|
});
|
|
1109
1188
|
document.addEventListener("input", (e) => {
|
|
1110
|
-
if (e.target.matches(`.${
|
|
1111
|
-
const root = e.target.closest(`.${
|
|
1189
|
+
if (e.target.matches(`.${PREFIX3}-select-dropdown__trigger-input`)) {
|
|
1190
|
+
const root = e.target.closest(`.${PREFIX3}-select-dropdown`);
|
|
1112
1191
|
if (root) {
|
|
1113
1192
|
const term = e.target.value.toLowerCase();
|
|
1114
1193
|
const options = root.querySelectorAll(
|
|
1115
|
-
`.${
|
|
1194
|
+
`.${PREFIX3}-select-dropdown__option`
|
|
1116
1195
|
);
|
|
1117
1196
|
if (root.getAttribute("data-state") !== "open") {
|
|
1118
1197
|
setDropdownState(root, { isOpen: true });
|
|
@@ -2402,27 +2481,27 @@ var InaUI = (() => {
|
|
|
2402
2481
|
}
|
|
2403
2482
|
|
|
2404
2483
|
// src/js/components/stateful/chip.js
|
|
2405
|
-
var
|
|
2406
|
-
function initChip(rootSelector = `.${
|
|
2484
|
+
var PREFIX4 = "ina";
|
|
2485
|
+
function initChip(rootSelector = `.${PREFIX4}-chip`) {
|
|
2407
2486
|
const chips = document.querySelectorAll(rootSelector);
|
|
2408
2487
|
chips.forEach((container) => {
|
|
2409
2488
|
if (container.__inaChipInitialized) return;
|
|
2410
2489
|
const showCustomization = container.getAttribute("data-show-customization") === "true";
|
|
2411
2490
|
const customizationLabel = container.getAttribute("data-customization-label") || "Kustomisasi";
|
|
2412
2491
|
let selectedValue = container.getAttribute("data-selected") || "";
|
|
2413
|
-
const list = container.querySelector(`.${
|
|
2414
|
-
const items = list ? list.querySelectorAll(`.${
|
|
2492
|
+
const list = container.querySelector(`.${PREFIX4}-chip__list`);
|
|
2493
|
+
const items = list ? list.querySelectorAll(`.${PREFIX4}-chip__item`) : [];
|
|
2415
2494
|
let customFieldContainer = container.querySelector(
|
|
2416
|
-
`.${
|
|
2495
|
+
`.${PREFIX4}-chip__custom-field`
|
|
2417
2496
|
);
|
|
2418
2497
|
const updateUI = () => {
|
|
2419
2498
|
items.forEach((item) => {
|
|
2420
2499
|
const itemValue = item.getAttribute("data-value");
|
|
2421
2500
|
const isSelected = itemValue === selectedValue;
|
|
2422
2501
|
if (isSelected) {
|
|
2423
|
-
item.classList.add(`${
|
|
2502
|
+
item.classList.add(`${PREFIX4}-chip__item--selected`);
|
|
2424
2503
|
} else {
|
|
2425
|
-
item.classList.remove(`${
|
|
2504
|
+
item.classList.remove(`${PREFIX4}-chip__item--selected`);
|
|
2426
2505
|
}
|
|
2427
2506
|
});
|
|
2428
2507
|
if (showCustomization) {
|
|
@@ -2440,17 +2519,17 @@ var InaUI = (() => {
|
|
|
2440
2519
|
if (showInput) {
|
|
2441
2520
|
if (!customFieldContainer) {
|
|
2442
2521
|
customFieldContainer = document.createElement("div");
|
|
2443
|
-
customFieldContainer.className = `${
|
|
2522
|
+
customFieldContainer.className = `${PREFIX4}-chip__custom-field`;
|
|
2444
2523
|
container.appendChild(customFieldContainer);
|
|
2445
2524
|
}
|
|
2446
2525
|
let input = customFieldContainer.querySelector(
|
|
2447
|
-
`.${
|
|
2526
|
+
`.${PREFIX4}-chip__input`
|
|
2448
2527
|
);
|
|
2449
2528
|
if (!input) {
|
|
2450
2529
|
customFieldContainer.innerHTML = `
|
|
2451
|
-
<div class="${
|
|
2452
|
-
<div class="${
|
|
2453
|
-
<input type="text" class="${
|
|
2530
|
+
<div class="${PREFIX4}-text-field ${PREFIX4}-text-field--size-medium ${PREFIX4}-text-field--variant-outline ${PREFIX4}-chip__input">
|
|
2531
|
+
<div class="${PREFIX4}-text-field__wrapper">
|
|
2532
|
+
<input type="text" class="${PREFIX4}-text-field__input" placeholder="Masukkan data yang Anda inginkan" value="${!isStandard ? selectedValue : ""}" />
|
|
2454
2533
|
</div>
|
|
2455
2534
|
</div>
|
|
2456
2535
|
`;
|
|
@@ -3127,6 +3206,7 @@ var InaUI = (() => {
|
|
|
3127
3206
|
if (typeof window !== void 0) {
|
|
3128
3207
|
document.addEventListener("DOMContentLoaded", () => {
|
|
3129
3208
|
initAccordion();
|
|
3209
|
+
initDrawer();
|
|
3130
3210
|
initButtonGroup();
|
|
3131
3211
|
initCheckbox();
|
|
3132
3212
|
initDatepicker();
|
package/dist/index.js
CHANGED
|
@@ -962,18 +962,24 @@ function initDrawer(rootSelector = `.${PREFIX2}-drawer`) {
|
|
|
962
962
|
const closeDrawer = (drawer) => {
|
|
963
963
|
if (!drawer) return;
|
|
964
964
|
drawer.classList.add(`${PREFIX2}-drawer--closing`);
|
|
965
|
+
drawer.classList.remove(`${PREFIX2}-drawer--open`);
|
|
965
966
|
const onAnimationEnd = () => {
|
|
966
967
|
drawer.classList.remove(`${PREFIX2}-drawer--closing`);
|
|
967
968
|
drawer.style.display = "none";
|
|
968
969
|
document.body.style.overflow = "";
|
|
969
970
|
drawer.removeEventListener("animationend", onAnimationEnd);
|
|
970
971
|
};
|
|
972
|
+
setTimeout(() => {
|
|
973
|
+
if (drawer.style.display !== "none") onAnimationEnd();
|
|
974
|
+
}, 300);
|
|
971
975
|
drawer.addEventListener("animationend", onAnimationEnd, { once: true });
|
|
972
976
|
};
|
|
973
977
|
const openDrawer = (drawer) => {
|
|
974
978
|
if (!drawer) return;
|
|
975
979
|
drawer.style.display = "flex";
|
|
976
980
|
document.body.style.overflow = "hidden";
|
|
981
|
+
drawer.offsetHeight;
|
|
982
|
+
drawer.classList.add(`${PREFIX2}-drawer--open`);
|
|
977
983
|
drawer.dispatchEvent(new CustomEvent("drawer:open"));
|
|
978
984
|
};
|
|
979
985
|
drawers.forEach((drawer) => {
|