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