@idds/js 1.0.63 → 1.0.65
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 +70 -57
- 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) => {
|
|
@@ -916,35 +918,44 @@ var handleDropdownLogic = (rootSelector, triggerSelector, panelSelector, activeC
|
|
|
916
918
|
const shouldExpand = force !== void 0 ? force : !isExpanded;
|
|
917
919
|
trigger.setAttribute("aria-expanded", shouldExpand);
|
|
918
920
|
if (shouldExpand) {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
921
|
+
if (activeClass) {
|
|
922
|
+
panel.classList.add(activeClass);
|
|
923
|
+
}
|
|
924
|
+
panel.style.removeProperty("display");
|
|
922
925
|
if (rootSelector.includes("basic")) {
|
|
923
926
|
const btn = trigger.querySelector(
|
|
924
|
-
`.${
|
|
927
|
+
`.${PREFIX3}-basic-dropdown__trigger-button`
|
|
925
928
|
);
|
|
926
929
|
if (btn)
|
|
927
|
-
btn.classList.add(`${
|
|
930
|
+
btn.classList.add(`${PREFIX3}-basic-dropdown__trigger-button--open`);
|
|
928
931
|
} else {
|
|
929
|
-
trigger.classList.add(`${
|
|
932
|
+
trigger.classList.add(`${PREFIX3}-action-dropdown__trigger--open`);
|
|
930
933
|
}
|
|
931
934
|
} else {
|
|
932
|
-
if (activeClass)
|
|
933
|
-
|
|
935
|
+
if (activeClass) {
|
|
936
|
+
panel.classList.remove(activeClass);
|
|
937
|
+
} else {
|
|
938
|
+
panel.style.display = "none";
|
|
939
|
+
}
|
|
934
940
|
if (rootSelector.includes("basic")) {
|
|
935
941
|
const btn = trigger.querySelector(
|
|
936
|
-
`.${
|
|
942
|
+
`.${PREFIX3}-basic-dropdown__trigger-button`
|
|
937
943
|
);
|
|
938
944
|
if (btn)
|
|
939
945
|
btn.classList.remove(
|
|
940
|
-
`${
|
|
946
|
+
`${PREFIX3}-basic-dropdown__trigger-button--open`
|
|
941
947
|
);
|
|
942
948
|
} else {
|
|
943
|
-
trigger.classList.remove(`${
|
|
949
|
+
trigger.classList.remove(`${PREFIX3}-action-dropdown__trigger--open`);
|
|
944
950
|
}
|
|
945
951
|
}
|
|
946
952
|
};
|
|
947
|
-
|
|
953
|
+
if (!activeClass) {
|
|
954
|
+
panel.style.display = "none";
|
|
955
|
+
} else {
|
|
956
|
+
panel.classList.remove(activeClass);
|
|
957
|
+
panel.style.removeProperty("display");
|
|
958
|
+
}
|
|
948
959
|
trigger.addEventListener("click", (e) => {
|
|
949
960
|
e.stopPropagation();
|
|
950
961
|
toggle();
|
|
@@ -961,7 +972,7 @@ var handleDropdownLogic = (rootSelector, triggerSelector, panelSelector, activeC
|
|
|
961
972
|
});
|
|
962
973
|
if (rootSelector.includes("action")) {
|
|
963
974
|
panel.addEventListener("click", (e) => {
|
|
964
|
-
const item = e.target.closest(`.${
|
|
975
|
+
const item = e.target.closest(`.${PREFIX3}-action-dropdown__item`);
|
|
965
976
|
if (item && !item.disabled) {
|
|
966
977
|
toggle(false);
|
|
967
978
|
}
|
|
@@ -972,47 +983,48 @@ var handleDropdownLogic = (rootSelector, triggerSelector, panelSelector, activeC
|
|
|
972
983
|
};
|
|
973
984
|
function initBasicDropdown() {
|
|
974
985
|
handleDropdownLogic(
|
|
975
|
-
`.${
|
|
976
|
-
`.${
|
|
977
|
-
`.${
|
|
986
|
+
`.${PREFIX3}-basic-dropdown`,
|
|
987
|
+
`.${PREFIX3}-basic-dropdown__trigger`,
|
|
988
|
+
`.${PREFIX3}-basic-dropdown__panel`
|
|
978
989
|
);
|
|
979
990
|
}
|
|
980
991
|
function initActionDropdown() {
|
|
981
992
|
handleDropdownLogic(
|
|
982
|
-
`.${
|
|
983
|
-
`.${
|
|
984
|
-
`.${
|
|
985
|
-
`${
|
|
993
|
+
`.${PREFIX3}-action-dropdown`,
|
|
994
|
+
`.${PREFIX3}-action-dropdown__trigger`,
|
|
995
|
+
`.${PREFIX3}-action-dropdown__menu`,
|
|
996
|
+
`${PREFIX3}-action-dropdown__menu--visible`
|
|
986
997
|
);
|
|
987
998
|
}
|
|
988
999
|
|
|
989
1000
|
// src/js/components/stateful/select-dropdown.js
|
|
990
|
-
|
|
1001
|
+
var PREFIX4 = "ina";
|
|
1002
|
+
function initSelectDropdown(rootSelector = `.${PREFIX4}-select-dropdown`) {
|
|
991
1003
|
document.querySelectorAll(rootSelector).forEach((dropdown) => {
|
|
992
1004
|
if (dropdown.__inaSelectDropdownInitialized) return;
|
|
993
1005
|
const isMultiple = dropdown.getAttribute("data-multiple") === "true";
|
|
994
1006
|
const isSearchable = dropdown.getAttribute("data-searchable") !== "false";
|
|
995
1007
|
const trigger = dropdown.querySelector(
|
|
996
|
-
`.${
|
|
1008
|
+
`.${PREFIX4}-select-dropdown__trigger`
|
|
997
1009
|
);
|
|
998
1010
|
const input = dropdown.querySelector(
|
|
999
|
-
`.${
|
|
1011
|
+
`.${PREFIX4}-select-dropdown__trigger-input`
|
|
1000
1012
|
);
|
|
1001
|
-
const panel = dropdown.querySelector(`.${
|
|
1013
|
+
const panel = dropdown.querySelector(`.${PREFIX4}-select-dropdown__panel`);
|
|
1002
1014
|
const optionsContainer = dropdown.querySelector(
|
|
1003
|
-
`.${
|
|
1015
|
+
`.${PREFIX4}-select-dropdown__options`
|
|
1004
1016
|
);
|
|
1005
1017
|
if (!trigger || !panel) return;
|
|
1006
1018
|
let isOpen = false;
|
|
1007
1019
|
let selectedValues = [];
|
|
1008
1020
|
const options = panel.querySelectorAll(
|
|
1009
|
-
`.${
|
|
1021
|
+
`.${PREFIX4}-select-dropdown__option`
|
|
1010
1022
|
);
|
|
1011
1023
|
options.forEach((opt) => {
|
|
1012
1024
|
if (opt.classList.contains(
|
|
1013
|
-
`${
|
|
1025
|
+
`${PREFIX4}-select-dropdown__option--selected-single`
|
|
1014
1026
|
) || opt.classList.contains(
|
|
1015
|
-
`${
|
|
1027
|
+
`${PREFIX4}-select-dropdown__option--selected-multiple`
|
|
1016
1028
|
)) {
|
|
1017
1029
|
const val = getOptionValue(opt);
|
|
1018
1030
|
if (val) selectedValues.push(val);
|
|
@@ -1024,7 +1036,7 @@ function initSelectDropdown(rootSelector = `.${PREFIX}-select-dropdown`) {
|
|
|
1024
1036
|
isOpen = shouldOpen;
|
|
1025
1037
|
trigger.setAttribute("aria-expanded", isOpen);
|
|
1026
1038
|
if (isOpen) {
|
|
1027
|
-
panel.style.display
|
|
1039
|
+
panel.style.removeProperty("display");
|
|
1028
1040
|
if (input) input.focus();
|
|
1029
1041
|
} else {
|
|
1030
1042
|
panel.style.display = "none";
|
|
@@ -1039,7 +1051,7 @@ function initSelectDropdown(rootSelector = `.${PREFIX}-select-dropdown`) {
|
|
|
1039
1051
|
}
|
|
1040
1052
|
function updateTriggerUI() {
|
|
1041
1053
|
const triggerText = trigger.querySelector(
|
|
1042
|
-
`.${
|
|
1054
|
+
`.${PREFIX4}-select-dropdown__trigger-text`
|
|
1043
1055
|
);
|
|
1044
1056
|
if (isMultiple) {
|
|
1045
1057
|
let label = "";
|
|
@@ -1064,7 +1076,7 @@ function initSelectDropdown(rootSelector = `.${PREFIX}-select-dropdown`) {
|
|
|
1064
1076
|
} else if (triggerText) {
|
|
1065
1077
|
triggerText.textContent = label;
|
|
1066
1078
|
triggerText.classList.toggle(
|
|
1067
|
-
`${
|
|
1079
|
+
`${PREFIX4}-select-dropdown__trigger-text--placeholder`,
|
|
1068
1080
|
selectedValues.length === 0
|
|
1069
1081
|
);
|
|
1070
1082
|
}
|
|
@@ -1084,7 +1096,7 @@ function initSelectDropdown(rootSelector = `.${PREFIX}-select-dropdown`) {
|
|
|
1084
1096
|
} else if (triggerText) {
|
|
1085
1097
|
triggerText.textContent = label;
|
|
1086
1098
|
triggerText.classList.toggle(
|
|
1087
|
-
`${
|
|
1099
|
+
`${PREFIX4}-select-dropdown__trigger-text--placeholder`,
|
|
1088
1100
|
!val
|
|
1089
1101
|
);
|
|
1090
1102
|
}
|
|
@@ -1098,37 +1110,37 @@ function initSelectDropdown(rootSelector = `.${PREFIX}-select-dropdown`) {
|
|
|
1098
1110
|
if (idx > -1) {
|
|
1099
1111
|
selectedValues.splice(idx, 1);
|
|
1100
1112
|
option.classList.remove(
|
|
1101
|
-
`${
|
|
1113
|
+
`${PREFIX4}-select-dropdown__option--selected-multiple`
|
|
1102
1114
|
);
|
|
1103
1115
|
const checkbox = option.querySelector(
|
|
1104
|
-
`.${
|
|
1116
|
+
`.${PREFIX4}-select-dropdown__option-checkbox`
|
|
1105
1117
|
);
|
|
1106
1118
|
if (checkbox)
|
|
1107
1119
|
checkbox.classList.remove(
|
|
1108
|
-
`${
|
|
1120
|
+
`${PREFIX4}-select-dropdown__option-checkbox--checked`
|
|
1109
1121
|
);
|
|
1110
1122
|
} else {
|
|
1111
1123
|
selectedValues.push(val);
|
|
1112
1124
|
option.classList.add(
|
|
1113
|
-
`${
|
|
1125
|
+
`${PREFIX4}-select-dropdown__option--selected-multiple`
|
|
1114
1126
|
);
|
|
1115
1127
|
const checkbox = option.querySelector(
|
|
1116
|
-
`.${
|
|
1128
|
+
`.${PREFIX4}-select-dropdown__option-checkbox`
|
|
1117
1129
|
);
|
|
1118
1130
|
if (checkbox)
|
|
1119
1131
|
checkbox.classList.add(
|
|
1120
|
-
`${
|
|
1132
|
+
`${PREFIX4}-select-dropdown__option-checkbox--checked`
|
|
1121
1133
|
);
|
|
1122
1134
|
}
|
|
1123
1135
|
} else {
|
|
1124
1136
|
selectedValues = [val];
|
|
1125
1137
|
options.forEach((o) => {
|
|
1126
1138
|
o.classList.remove(
|
|
1127
|
-
`${
|
|
1139
|
+
`${PREFIX4}-select-dropdown__option--selected-single`
|
|
1128
1140
|
);
|
|
1129
1141
|
});
|
|
1130
1142
|
option.classList.add(
|
|
1131
|
-
`${
|
|
1143
|
+
`${PREFIX4}-select-dropdown__option--selected-single`
|
|
1132
1144
|
);
|
|
1133
1145
|
toggle(false);
|
|
1134
1146
|
}
|
|
@@ -2470,26 +2482,27 @@ if (typeof window !== void 0) {
|
|
|
2470
2482
|
}
|
|
2471
2483
|
|
|
2472
2484
|
// src/js/components/stateful/chip.js
|
|
2473
|
-
|
|
2485
|
+
var PREFIX5 = "ina";
|
|
2486
|
+
function initChip(rootSelector = `.${PREFIX5}-chip`) {
|
|
2474
2487
|
const chips = document.querySelectorAll(rootSelector);
|
|
2475
2488
|
chips.forEach((container) => {
|
|
2476
2489
|
if (container.__inaChipInitialized) return;
|
|
2477
2490
|
const showCustomization = container.getAttribute("data-show-customization") === "true";
|
|
2478
2491
|
const customizationLabel = container.getAttribute("data-customization-label") || "Kustomisasi";
|
|
2479
2492
|
let selectedValue = container.getAttribute("data-selected") || "";
|
|
2480
|
-
const list = container.querySelector(`.${
|
|
2481
|
-
const items = list ? list.querySelectorAll(`.${
|
|
2493
|
+
const list = container.querySelector(`.${PREFIX5}-chip__list`);
|
|
2494
|
+
const items = list ? list.querySelectorAll(`.${PREFIX5}-chip__item`) : [];
|
|
2482
2495
|
let customFieldContainer = container.querySelector(
|
|
2483
|
-
`.${
|
|
2496
|
+
`.${PREFIX5}-chip__custom-field`
|
|
2484
2497
|
);
|
|
2485
2498
|
const updateUI = () => {
|
|
2486
2499
|
items.forEach((item) => {
|
|
2487
2500
|
const itemValue = item.getAttribute("data-value");
|
|
2488
2501
|
const isSelected = itemValue === selectedValue;
|
|
2489
2502
|
if (isSelected) {
|
|
2490
|
-
item.classList.add(`${
|
|
2503
|
+
item.classList.add(`${PREFIX5}-chip__item--selected`);
|
|
2491
2504
|
} else {
|
|
2492
|
-
item.classList.remove(`${
|
|
2505
|
+
item.classList.remove(`${PREFIX5}-chip__item--selected`);
|
|
2493
2506
|
}
|
|
2494
2507
|
});
|
|
2495
2508
|
if (showCustomization) {
|
|
@@ -2507,17 +2520,17 @@ function initChip(rootSelector = `.${PREFIX}-chip`) {
|
|
|
2507
2520
|
if (showInput) {
|
|
2508
2521
|
if (!customFieldContainer) {
|
|
2509
2522
|
customFieldContainer = document.createElement("div");
|
|
2510
|
-
customFieldContainer.className = `${
|
|
2523
|
+
customFieldContainer.className = `${PREFIX5}-chip__custom-field`;
|
|
2511
2524
|
container.appendChild(customFieldContainer);
|
|
2512
2525
|
}
|
|
2513
2526
|
let input = customFieldContainer.querySelector(
|
|
2514
|
-
`.${
|
|
2527
|
+
`.${PREFIX5}-chip__input`
|
|
2515
2528
|
);
|
|
2516
2529
|
if (!input) {
|
|
2517
2530
|
customFieldContainer.innerHTML = `
|
|
2518
|
-
<div class="${
|
|
2519
|
-
<div class="${
|
|
2520
|
-
<input type="text" class="${
|
|
2531
|
+
<div class="${PREFIX5}-text-field ${PREFIX5}-text-field--size-medium ${PREFIX5}-text-field--variant-outline ${PREFIX5}-chip__input">
|
|
2532
|
+
<div class="${PREFIX5}-text-field__wrapper">
|
|
2533
|
+
<input type="text" class="${PREFIX5}-text-field__input" placeholder="Masukkan data yang Anda inginkan" value="${!isStandard ? selectedValue : ""}" />
|
|
2521
2534
|
</div>
|
|
2522
2535
|
</div>
|
|
2523
2536
|
`;
|