@idds/js 1.0.62 → 1.0.64
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.js +54 -50
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -833,13 +833,14 @@ function initModal(rootSelector = `.${PREFIX}-modal`) {
|
|
|
833
833
|
}
|
|
834
834
|
|
|
835
835
|
// src/js/components/stateless/drawer.js
|
|
836
|
-
|
|
836
|
+
var PREFIX2 = "ina";
|
|
837
|
+
function initDrawer(rootSelector = `.${PREFIX2}-drawer`) {
|
|
837
838
|
const drawers = document.querySelectorAll(rootSelector);
|
|
838
839
|
const closeDrawer = (drawer) => {
|
|
839
840
|
if (!drawer) return;
|
|
840
|
-
drawer.classList.add(`${
|
|
841
|
+
drawer.classList.add(`${PREFIX2}-drawer--closing`);
|
|
841
842
|
const onAnimationEnd = () => {
|
|
842
|
-
drawer.classList.remove(`${
|
|
843
|
+
drawer.classList.remove(`${PREFIX2}-drawer--closing`);
|
|
843
844
|
drawer.style.display = "none";
|
|
844
845
|
document.body.style.overflow = "";
|
|
845
846
|
drawer.removeEventListener("animationend", onAnimationEnd);
|
|
@@ -856,12 +857,12 @@ function initDrawer(rootSelector = `.${PREFIX}-drawer`) {
|
|
|
856
857
|
if (drawer.__inaDrawerInitialized) return;
|
|
857
858
|
const isPersistent = drawer.getAttribute("data-persistent") === "true";
|
|
858
859
|
const closeBtns = drawer.querySelectorAll(
|
|
859
|
-
`.${
|
|
860
|
+
`.${PREFIX2}-drawer__close-button`
|
|
860
861
|
);
|
|
861
862
|
closeBtns.forEach((btn) => {
|
|
862
863
|
btn.addEventListener("click", () => closeDrawer(drawer));
|
|
863
864
|
});
|
|
864
|
-
const backdrop = drawer.querySelector(`.${
|
|
865
|
+
const backdrop = drawer.querySelector(`.${PREFIX2}-drawer__backdrop`);
|
|
865
866
|
if (backdrop) {
|
|
866
867
|
backdrop.addEventListener("click", (e) => {
|
|
867
868
|
if (!isPersistent) {
|
|
@@ -894,7 +895,7 @@ function initDrawer(rootSelector = `.${PREFIX}-drawer`) {
|
|
|
894
895
|
if (targetId) {
|
|
895
896
|
targetDrawer = document.querySelector(targetId);
|
|
896
897
|
} else {
|
|
897
|
-
targetDrawer = closeTrigger.closest(`.${
|
|
898
|
+
targetDrawer = closeTrigger.closest(`.${PREFIX2}-drawer`);
|
|
898
899
|
}
|
|
899
900
|
if (targetDrawer) {
|
|
900
901
|
closeDrawer(targetDrawer);
|
|
@@ -904,6 +905,7 @@ function initDrawer(rootSelector = `.${PREFIX}-drawer`) {
|
|
|
904
905
|
}
|
|
905
906
|
|
|
906
907
|
// src/js/components/stateful/basic-dropdown.js
|
|
908
|
+
var PREFIX3 = "ina";
|
|
907
909
|
var handleDropdownLogic = (rootSelector, triggerSelector, panelSelector, activeClass) => {
|
|
908
910
|
const dropdowns = document.querySelectorAll(rootSelector);
|
|
909
911
|
dropdowns.forEach((dropdown) => {
|
|
@@ -921,26 +923,26 @@ var handleDropdownLogic = (rootSelector, triggerSelector, panelSelector, activeC
|
|
|
921
923
|
if (activeClass) panel.classList.add(activeClass);
|
|
922
924
|
if (rootSelector.includes("basic")) {
|
|
923
925
|
const btn = trigger.querySelector(
|
|
924
|
-
`.${
|
|
926
|
+
`.${PREFIX3}-basic-dropdown__trigger-button`
|
|
925
927
|
);
|
|
926
928
|
if (btn)
|
|
927
|
-
btn.classList.add(`${
|
|
929
|
+
btn.classList.add(`${PREFIX3}-basic-dropdown__trigger-button--open`);
|
|
928
930
|
} else {
|
|
929
|
-
trigger.classList.add(`${
|
|
931
|
+
trigger.classList.add(`${PREFIX3}-action-dropdown__trigger--open`);
|
|
930
932
|
}
|
|
931
933
|
} else {
|
|
932
934
|
if (activeClass) panel.classList.remove(activeClass);
|
|
933
935
|
panel.style.display = "none";
|
|
934
936
|
if (rootSelector.includes("basic")) {
|
|
935
937
|
const btn = trigger.querySelector(
|
|
936
|
-
`.${
|
|
938
|
+
`.${PREFIX3}-basic-dropdown__trigger-button`
|
|
937
939
|
);
|
|
938
940
|
if (btn)
|
|
939
941
|
btn.classList.remove(
|
|
940
|
-
`${
|
|
942
|
+
`${PREFIX3}-basic-dropdown__trigger-button--open`
|
|
941
943
|
);
|
|
942
944
|
} else {
|
|
943
|
-
trigger.classList.remove(`${
|
|
945
|
+
trigger.classList.remove(`${PREFIX3}-action-dropdown__trigger--open`);
|
|
944
946
|
}
|
|
945
947
|
}
|
|
946
948
|
};
|
|
@@ -961,7 +963,7 @@ var handleDropdownLogic = (rootSelector, triggerSelector, panelSelector, activeC
|
|
|
961
963
|
});
|
|
962
964
|
if (rootSelector.includes("action")) {
|
|
963
965
|
panel.addEventListener("click", (e) => {
|
|
964
|
-
const item = e.target.closest(`.${
|
|
966
|
+
const item = e.target.closest(`.${PREFIX3}-action-dropdown__item`);
|
|
965
967
|
if (item && !item.disabled) {
|
|
966
968
|
toggle(false);
|
|
967
969
|
}
|
|
@@ -972,47 +974,48 @@ var handleDropdownLogic = (rootSelector, triggerSelector, panelSelector, activeC
|
|
|
972
974
|
};
|
|
973
975
|
function initBasicDropdown() {
|
|
974
976
|
handleDropdownLogic(
|
|
975
|
-
`.${
|
|
976
|
-
`.${
|
|
977
|
-
`.${
|
|
977
|
+
`.${PREFIX3}-basic-dropdown`,
|
|
978
|
+
`.${PREFIX3}-basic-dropdown__trigger`,
|
|
979
|
+
`.${PREFIX3}-basic-dropdown__panel`
|
|
978
980
|
);
|
|
979
981
|
}
|
|
980
982
|
function initActionDropdown() {
|
|
981
983
|
handleDropdownLogic(
|
|
982
|
-
`.${
|
|
983
|
-
`.${
|
|
984
|
-
`.${
|
|
985
|
-
`${
|
|
984
|
+
`.${PREFIX3}-action-dropdown`,
|
|
985
|
+
`.${PREFIX3}-action-dropdown__trigger`,
|
|
986
|
+
`.${PREFIX3}-action-dropdown__menu`,
|
|
987
|
+
`${PREFIX3}-action-dropdown__menu--visible`
|
|
986
988
|
);
|
|
987
989
|
}
|
|
988
990
|
|
|
989
991
|
// src/js/components/stateful/select-dropdown.js
|
|
990
|
-
|
|
992
|
+
var PREFIX4 = "ina";
|
|
993
|
+
function initSelectDropdown(rootSelector = `.${PREFIX4}-select-dropdown`) {
|
|
991
994
|
document.querySelectorAll(rootSelector).forEach((dropdown) => {
|
|
992
995
|
if (dropdown.__inaSelectDropdownInitialized) return;
|
|
993
996
|
const isMultiple = dropdown.getAttribute("data-multiple") === "true";
|
|
994
997
|
const isSearchable = dropdown.getAttribute("data-searchable") !== "false";
|
|
995
998
|
const trigger = dropdown.querySelector(
|
|
996
|
-
`.${
|
|
999
|
+
`.${PREFIX4}-select-dropdown__trigger`
|
|
997
1000
|
);
|
|
998
1001
|
const input = dropdown.querySelector(
|
|
999
|
-
`.${
|
|
1002
|
+
`.${PREFIX4}-select-dropdown__trigger-input`
|
|
1000
1003
|
);
|
|
1001
|
-
const panel = dropdown.querySelector(`.${
|
|
1004
|
+
const panel = dropdown.querySelector(`.${PREFIX4}-select-dropdown__panel`);
|
|
1002
1005
|
const optionsContainer = dropdown.querySelector(
|
|
1003
|
-
`.${
|
|
1006
|
+
`.${PREFIX4}-select-dropdown__options`
|
|
1004
1007
|
);
|
|
1005
1008
|
if (!trigger || !panel) return;
|
|
1006
1009
|
let isOpen = false;
|
|
1007
1010
|
let selectedValues = [];
|
|
1008
1011
|
const options = panel.querySelectorAll(
|
|
1009
|
-
`.${
|
|
1012
|
+
`.${PREFIX4}-select-dropdown__option`
|
|
1010
1013
|
);
|
|
1011
1014
|
options.forEach((opt) => {
|
|
1012
1015
|
if (opt.classList.contains(
|
|
1013
|
-
`${
|
|
1016
|
+
`${PREFIX4}-select-dropdown__option--selected-single`
|
|
1014
1017
|
) || opt.classList.contains(
|
|
1015
|
-
`${
|
|
1018
|
+
`${PREFIX4}-select-dropdown__option--selected-multiple`
|
|
1016
1019
|
)) {
|
|
1017
1020
|
const val = getOptionValue(opt);
|
|
1018
1021
|
if (val) selectedValues.push(val);
|
|
@@ -1039,7 +1042,7 @@ function initSelectDropdown(rootSelector = `.${PREFIX}-select-dropdown`) {
|
|
|
1039
1042
|
}
|
|
1040
1043
|
function updateTriggerUI() {
|
|
1041
1044
|
const triggerText = trigger.querySelector(
|
|
1042
|
-
`.${
|
|
1045
|
+
`.${PREFIX4}-select-dropdown__trigger-text`
|
|
1043
1046
|
);
|
|
1044
1047
|
if (isMultiple) {
|
|
1045
1048
|
let label = "";
|
|
@@ -1064,7 +1067,7 @@ function initSelectDropdown(rootSelector = `.${PREFIX}-select-dropdown`) {
|
|
|
1064
1067
|
} else if (triggerText) {
|
|
1065
1068
|
triggerText.textContent = label;
|
|
1066
1069
|
triggerText.classList.toggle(
|
|
1067
|
-
`${
|
|
1070
|
+
`${PREFIX4}-select-dropdown__trigger-text--placeholder`,
|
|
1068
1071
|
selectedValues.length === 0
|
|
1069
1072
|
);
|
|
1070
1073
|
}
|
|
@@ -1084,7 +1087,7 @@ function initSelectDropdown(rootSelector = `.${PREFIX}-select-dropdown`) {
|
|
|
1084
1087
|
} else if (triggerText) {
|
|
1085
1088
|
triggerText.textContent = label;
|
|
1086
1089
|
triggerText.classList.toggle(
|
|
1087
|
-
`${
|
|
1090
|
+
`${PREFIX4}-select-dropdown__trigger-text--placeholder`,
|
|
1088
1091
|
!val
|
|
1089
1092
|
);
|
|
1090
1093
|
}
|
|
@@ -1098,37 +1101,37 @@ function initSelectDropdown(rootSelector = `.${PREFIX}-select-dropdown`) {
|
|
|
1098
1101
|
if (idx > -1) {
|
|
1099
1102
|
selectedValues.splice(idx, 1);
|
|
1100
1103
|
option.classList.remove(
|
|
1101
|
-
`${
|
|
1104
|
+
`${PREFIX4}-select-dropdown__option--selected-multiple`
|
|
1102
1105
|
);
|
|
1103
1106
|
const checkbox = option.querySelector(
|
|
1104
|
-
`.${
|
|
1107
|
+
`.${PREFIX4}-select-dropdown__option-checkbox`
|
|
1105
1108
|
);
|
|
1106
1109
|
if (checkbox)
|
|
1107
1110
|
checkbox.classList.remove(
|
|
1108
|
-
`${
|
|
1111
|
+
`${PREFIX4}-select-dropdown__option-checkbox--checked`
|
|
1109
1112
|
);
|
|
1110
1113
|
} else {
|
|
1111
1114
|
selectedValues.push(val);
|
|
1112
1115
|
option.classList.add(
|
|
1113
|
-
`${
|
|
1116
|
+
`${PREFIX4}-select-dropdown__option--selected-multiple`
|
|
1114
1117
|
);
|
|
1115
1118
|
const checkbox = option.querySelector(
|
|
1116
|
-
`.${
|
|
1119
|
+
`.${PREFIX4}-select-dropdown__option-checkbox`
|
|
1117
1120
|
);
|
|
1118
1121
|
if (checkbox)
|
|
1119
1122
|
checkbox.classList.add(
|
|
1120
|
-
`${
|
|
1123
|
+
`${PREFIX4}-select-dropdown__option-checkbox--checked`
|
|
1121
1124
|
);
|
|
1122
1125
|
}
|
|
1123
1126
|
} else {
|
|
1124
1127
|
selectedValues = [val];
|
|
1125
1128
|
options.forEach((o) => {
|
|
1126
1129
|
o.classList.remove(
|
|
1127
|
-
`${
|
|
1130
|
+
`${PREFIX4}-select-dropdown__option--selected-single`
|
|
1128
1131
|
);
|
|
1129
1132
|
});
|
|
1130
1133
|
option.classList.add(
|
|
1131
|
-
`${
|
|
1134
|
+
`${PREFIX4}-select-dropdown__option--selected-single`
|
|
1132
1135
|
);
|
|
1133
1136
|
toggle(false);
|
|
1134
1137
|
}
|
|
@@ -2470,26 +2473,27 @@ if (typeof window !== void 0) {
|
|
|
2470
2473
|
}
|
|
2471
2474
|
|
|
2472
2475
|
// src/js/components/stateful/chip.js
|
|
2473
|
-
|
|
2476
|
+
var PREFIX5 = "ina";
|
|
2477
|
+
function initChip(rootSelector = `.${PREFIX5}-chip`) {
|
|
2474
2478
|
const chips = document.querySelectorAll(rootSelector);
|
|
2475
2479
|
chips.forEach((container) => {
|
|
2476
2480
|
if (container.__inaChipInitialized) return;
|
|
2477
2481
|
const showCustomization = container.getAttribute("data-show-customization") === "true";
|
|
2478
2482
|
const customizationLabel = container.getAttribute("data-customization-label") || "Kustomisasi";
|
|
2479
2483
|
let selectedValue = container.getAttribute("data-selected") || "";
|
|
2480
|
-
const list = container.querySelector(`.${
|
|
2481
|
-
const items = list ? list.querySelectorAll(`.${
|
|
2484
|
+
const list = container.querySelector(`.${PREFIX5}-chip__list`);
|
|
2485
|
+
const items = list ? list.querySelectorAll(`.${PREFIX5}-chip__item`) : [];
|
|
2482
2486
|
let customFieldContainer = container.querySelector(
|
|
2483
|
-
`.${
|
|
2487
|
+
`.${PREFIX5}-chip__custom-field`
|
|
2484
2488
|
);
|
|
2485
2489
|
const updateUI = () => {
|
|
2486
2490
|
items.forEach((item) => {
|
|
2487
2491
|
const itemValue = item.getAttribute("data-value");
|
|
2488
2492
|
const isSelected = itemValue === selectedValue;
|
|
2489
2493
|
if (isSelected) {
|
|
2490
|
-
item.classList.add(`${
|
|
2494
|
+
item.classList.add(`${PREFIX5}-chip__item--selected`);
|
|
2491
2495
|
} else {
|
|
2492
|
-
item.classList.remove(`${
|
|
2496
|
+
item.classList.remove(`${PREFIX5}-chip__item--selected`);
|
|
2493
2497
|
}
|
|
2494
2498
|
});
|
|
2495
2499
|
if (showCustomization) {
|
|
@@ -2507,17 +2511,17 @@ function initChip(rootSelector = `.${PREFIX}-chip`) {
|
|
|
2507
2511
|
if (showInput) {
|
|
2508
2512
|
if (!customFieldContainer) {
|
|
2509
2513
|
customFieldContainer = document.createElement("div");
|
|
2510
|
-
customFieldContainer.className = `${
|
|
2514
|
+
customFieldContainer.className = `${PREFIX5}-chip__custom-field`;
|
|
2511
2515
|
container.appendChild(customFieldContainer);
|
|
2512
2516
|
}
|
|
2513
2517
|
let input = customFieldContainer.querySelector(
|
|
2514
|
-
`.${
|
|
2518
|
+
`.${PREFIX5}-chip__input`
|
|
2515
2519
|
);
|
|
2516
2520
|
if (!input) {
|
|
2517
2521
|
customFieldContainer.innerHTML = `
|
|
2518
|
-
<div class="${
|
|
2519
|
-
<div class="${
|
|
2520
|
-
<input type="text" class="${
|
|
2522
|
+
<div class="${PREFIX5}-text-field ${PREFIX5}-text-field--size-medium ${PREFIX5}-text-field--variant-outline ${PREFIX5}-chip__input">
|
|
2523
|
+
<div class="${PREFIX5}-text-field__wrapper">
|
|
2524
|
+
<input type="text" class="${PREFIX5}-text-field__input" placeholder="Masukkan data yang Anda inginkan" value="${!isStandard ? selectedValue : ""}" />
|
|
2521
2525
|
</div>
|
|
2522
2526
|
</div>
|
|
2523
2527
|
`;
|