@idds/js 1.0.68 → 1.0.70

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.
Files changed (3) hide show
  1. package/dist/index.iife.js +1329 -741
  2. package/dist/index.js +405 -195
  3. package/package.json +1 -1
@@ -23,6 +23,7 @@ var InaUI = (() => {
23
23
  initAccordion: () => initAccordion,
24
24
  initButtonGroup: () => initButtonGroup,
25
25
  initCheckbox: () => initCheckbox,
26
+ initChip: () => initChip,
26
27
  initDatepicker: () => initDatepicker,
27
28
  initDropdown: () => initDropdown,
28
29
  initFileUpload: () => initFileUpload,
@@ -30,8 +31,12 @@ var InaUI = (() => {
30
31
  initFileUploadItem: () => initFileUploadItem,
31
32
  initImgCompare: () => initImgCompare,
32
33
  initModal: () => initModal,
34
+ initPagination: () => initPagination,
35
+ initRadioButton: () => initRadioButton,
33
36
  initRangeDatepicker: () => initRangeDatepicker,
37
+ initSelectDropdown: () => initSelectDropdown,
34
38
  initSingleFileUpload: () => initSingleFileUpload,
39
+ initStepper: () => initStepper,
35
40
  initTab: () => initTab,
36
41
  initTimepicker: () => initTimepicker,
37
42
  initToggle: () => initToggle,
@@ -829,6 +834,320 @@ var InaUI = (() => {
829
834
  });
830
835
  }
831
836
 
837
+ // src/js/components/stateful/select-dropdown.js
838
+ var PREFIX2 = "ina";
839
+ function getDropdownState(root) {
840
+ return {
841
+ isOpen: root.getAttribute("data-state") === "open",
842
+ values: JSON.parse(root.getAttribute("data-values") || "[]"),
843
+ isMultiple: root.getAttribute("data-multiple") === "true",
844
+ isSearchable: root.getAttribute("data-searchable") !== "false"
845
+ };
846
+ }
847
+ function setDropdownState(root, newState) {
848
+ if (newState.isOpen !== void 0) {
849
+ root.setAttribute("data-state", newState.isOpen ? "open" : "closed");
850
+ const trigger = root.querySelector(`.${PREFIX2}-select-dropdown__trigger`);
851
+ if (trigger) trigger.setAttribute("aria-expanded", newState.isOpen);
852
+ const panel = root.querySelector(`.${PREFIX2}-select-dropdown__panel`);
853
+ if (panel) {
854
+ if (newState.isOpen) {
855
+ panel.style.removeProperty("display");
856
+ } else {
857
+ panel.style.display = "none";
858
+ }
859
+ }
860
+ }
861
+ if (newState.values !== void 0) {
862
+ root.setAttribute("data-values", JSON.stringify(newState.values));
863
+ updateTriggerUI(root, newState.values, newState.isMultiple);
864
+ }
865
+ }
866
+ function closeAllSelectDropdowns(exceptRoot = null) {
867
+ document.querySelectorAll(`.${PREFIX2}-select-dropdown[data-state="open"]`).forEach((root) => {
868
+ if (root !== exceptRoot) {
869
+ setDropdownState(root, { isOpen: false });
870
+ }
871
+ });
872
+ }
873
+ function updateTriggerUI(root, values, isMultiple) {
874
+ const trigger = root.querySelector(`.${PREFIX2}-select-dropdown__trigger`);
875
+ const input = trigger.querySelector("input");
876
+ const textSpan = trigger.querySelector(
877
+ `.${PREFIX2}-select-dropdown__trigger-text`
878
+ );
879
+ const placeholder = input ? input.getAttribute("placeholder") : textSpan ? textSpan.getAttribute("data-placeholder") : "Select...";
880
+ const options = root.querySelectorAll(`.${PREFIX2}-select-dropdown__option`);
881
+ const getLabel = (val) => {
882
+ const opt = Array.from(options).find(
883
+ (o) => o.getAttribute("data-value") === val
884
+ );
885
+ return opt ? opt.textContent.trim() : val;
886
+ };
887
+ let label = "";
888
+ if (values.length === 0) {
889
+ } else if (isMultiple) {
890
+ label = values.length > 3 ? `${values.length} data terpilih` : values.map(getLabel).join(", ");
891
+ } else {
892
+ label = getLabel(values[0]);
893
+ }
894
+ if (input) {
895
+ input.value = !isMultiple && values.length > 0 && root.getAttribute("data-state") !== "open" ? label : "";
896
+ if (values.length > 0) {
897
+ input.placeholder = label;
898
+ } else {
899
+ input.placeholder = "Select...";
900
+ }
901
+ } else if (textSpan) {
902
+ textSpan.textContent = values.length > 0 ? label : placeholder;
903
+ textSpan.classList.toggle(
904
+ `${PREFIX2}-select-dropdown__trigger-text--placeholder`,
905
+ values.length === 0
906
+ );
907
+ }
908
+ options.forEach((opt) => {
909
+ const val = opt.getAttribute("data-value");
910
+ const isSelected = values.includes(val);
911
+ if (isMultiple) {
912
+ opt.classList.toggle(
913
+ `${PREFIX2}-select-dropdown__option--selected-multiple`,
914
+ isSelected
915
+ );
916
+ const cb = opt.querySelector(
917
+ `.${PREFIX2}-select-dropdown__option-checkbox`
918
+ );
919
+ if (cb)
920
+ cb.classList.toggle(
921
+ `${PREFIX2}-select-dropdown__option-checkbox--checked`,
922
+ isSelected
923
+ );
924
+ } else {
925
+ opt.classList.toggle(
926
+ `${PREFIX2}-select-dropdown__option--selected-single`,
927
+ isSelected
928
+ );
929
+ }
930
+ });
931
+ }
932
+ function initSelectDropdown() {
933
+ if (window.__inaSelectDropdownInitialized) return;
934
+ document.addEventListener("click", (e) => {
935
+ const target = e.target;
936
+ const trigger = target.closest(`.${PREFIX2}-select-dropdown__trigger`);
937
+ const option = target.closest(`.${PREFIX2}-select-dropdown__option`);
938
+ const root = target.closest(`.${PREFIX2}-select-dropdown`);
939
+ if (trigger) {
940
+ if (root) {
941
+ const state = getDropdownState(root);
942
+ if (target.tagName === "INPUT" && state.isOpen) {
943
+ return;
944
+ }
945
+ closeAllSelectDropdowns(root);
946
+ setDropdownState(root, { isOpen: !state.isOpen });
947
+ if (!state.isOpen) {
948
+ const input = trigger.querySelector("input");
949
+ if (input) input.focus();
950
+ }
951
+ }
952
+ return;
953
+ }
954
+ if (option && root) {
955
+ const state = getDropdownState(root);
956
+ const val = option.getAttribute("data-value");
957
+ let newValues = [...state.values];
958
+ if (state.isMultiple) {
959
+ if (newValues.includes(val)) {
960
+ newValues = newValues.filter((v) => v !== val);
961
+ } else {
962
+ newValues.push(val);
963
+ }
964
+ setDropdownState(root, { values: newValues });
965
+ } else {
966
+ newValues = [val];
967
+ setDropdownState(root, { values: newValues, isOpen: false });
968
+ }
969
+ root.dispatchEvent(
970
+ new CustomEvent("change", {
971
+ detail: {
972
+ value: state.isMultiple ? newValues : newValues[0]
973
+ }
974
+ })
975
+ );
976
+ e.stopPropagation();
977
+ return;
978
+ }
979
+ if (!root) {
980
+ closeAllSelectDropdowns();
981
+ }
982
+ });
983
+ document.addEventListener("input", (e) => {
984
+ if (e.target.matches(`.${PREFIX2}-select-dropdown__trigger-input`)) {
985
+ const root = e.target.closest(`.${PREFIX2}-select-dropdown`);
986
+ if (root) {
987
+ const term = e.target.value.toLowerCase();
988
+ const options = root.querySelectorAll(
989
+ `.${PREFIX2}-select-dropdown__option`
990
+ );
991
+ if (root.getAttribute("data-state") !== "open") {
992
+ setDropdownState(root, { isOpen: true });
993
+ }
994
+ options.forEach((opt) => {
995
+ const text = opt.textContent.trim().toLowerCase();
996
+ opt.style.display = text.includes(term) ? "" : "none";
997
+ });
998
+ }
999
+ }
1000
+ });
1001
+ window.__inaSelectDropdownInitialized = true;
1002
+ }
1003
+
1004
+ // src/js/components/stateful/radio-button.js
1005
+ function initRadioButton() {
1006
+ const radioGroups = document.querySelectorAll(`.${PREFIX}-radio-input`);
1007
+ radioGroups.forEach((group) => {
1008
+ if (group.dataset.initialized === "true") return;
1009
+ group.dataset.initialized = "true";
1010
+ const inputs = group.querySelectorAll('input[type="radio"]');
1011
+ const displayTargetId = group.dataset.displayTarget;
1012
+ const displayTarget = displayTargetId ? document.getElementById(displayTargetId) : null;
1013
+ const updateDisplay = () => {
1014
+ if (!displayTarget) return;
1015
+ const selected = Array.from(inputs).find((input) => input.checked);
1016
+ const value = selected ? selected.value : "";
1017
+ displayTarget.textContent = `Selected: ${value || "None"}`;
1018
+ };
1019
+ if (inputs.length > 0) {
1020
+ inputs.forEach((input) => {
1021
+ input.addEventListener("change", updateDisplay);
1022
+ });
1023
+ updateDisplay();
1024
+ }
1025
+ });
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
+
832
1151
  // src/js/components/stateful/file-upload.js
833
1152
  var ICONS = {
834
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>`,
@@ -1352,797 +1671,871 @@ var InaUI = (() => {
1352
1671
  });
1353
1672
  }
1354
1673
 
1355
- // src/js/components/stateless/img-compare.js
1356
- function initImgCompare(rootSelector = `.${PREFIX}-img-compare`) {
1357
- document.querySelectorAll(rootSelector).forEach((imgCompare) => {
1358
- const sliderEl = document.createElement("input");
1359
- sliderEl.type = "range";
1360
- sliderEl.min = "0";
1361
- sliderEl.max = "100";
1362
- sliderEl.value = "50";
1363
- sliderEl.setAttribute("aria-label", "Percentage of the image to show");
1364
- sliderEl.setAttribute("aria-valuenow", "50");
1365
- sliderEl.setAttribute("aria-valuemin", "0");
1366
- sliderEl.setAttribute("aria-valuemax", "100");
1367
- sliderEl.classList.add("ina-ss-img__slider");
1368
- sliderEl.addEventListener("input", () => {
1369
- imgCompare.style.setProperty(
1370
- `--${PREFIX}-position`,
1371
- `${sliderEl.value}%`
1372
- );
1373
- });
1374
- const sliderLineEl = document.createElement("div");
1375
- sliderLineEl.classList.add("ina-ss-img__slider-line");
1376
- const sliderButtonEl = document.createElement("button");
1377
- sliderButtonEl.classList.add("ina-ss-img__slider-button");
1378
- imgCompare.appendChild(sliderEl);
1379
- imgCompare.appendChild(sliderLineEl);
1380
- imgCompare.appendChild(sliderButtonEl);
1381
- });
1382
- }
1383
-
1384
- // src/js/components/stateful/timepicker.js
1385
- function initTimepicker() {
1386
- document.querySelectorAll(`.${PREFIX}-time-picker`).forEach((picker) => {
1387
- if (picker.dataset.initialized === "true") return;
1388
- picker.dataset.initialized = "true";
1389
- const input = picker.querySelector(`.${PREFIX}-time-picker__input`);
1390
- const wrapper = picker.querySelector(`.${PREFIX}-time-picker__wrapper`);
1391
- if (!input || !wrapper) return;
1392
- const format = picker.dataset.format || "HH:mm";
1393
- const use12Hours = picker.dataset.use12Hours === "true" || picker.getAttribute("data-use-12-hours") === "true" || /a/i.test(format);
1394
- const showSecond = picker.dataset.showSecond === "true";
1395
- const disabled = picker.classList.contains(
1396
- `${PREFIX}-time-picker--disabled`
1674
+ // src/js/components/stateful/range-datepicker.js
1675
+ function initRangeDatepicker() {
1676
+ document.querySelectorAll(".ina-ss-range-datepicker").forEach((rangeDatepicker) => {
1677
+ let currentDate = /* @__PURE__ */ new Date();
1678
+ let currentDateLeft = /* @__PURE__ */ new Date();
1679
+ let currentDateRight = new Date(
1680
+ currentDateLeft.getFullYear(),
1681
+ currentDateLeft.getMonth() + 1,
1682
+ currentDateLeft.getDate()
1397
1683
  );
1398
- const allowClear = picker.dataset.allowClear !== "false";
1399
- let isOpen = false;
1400
- let internalValue = input.value || "";
1401
- let panel = picker.querySelector(`.${PREFIX}-time-picker__panel`);
1402
- if (!panel) {
1403
- panel = document.createElement("div");
1404
- panel.className = `${PREFIX}-time-picker__panel`;
1405
- panel.style.display = "none";
1406
- picker.appendChild(panel);
1407
- }
1408
- let content = panel.querySelector(`.${PREFIX}-time-picker__content`);
1409
- if (!content) {
1410
- content = document.createElement("div");
1411
- content.className = `${PREFIX}-time-picker__content`;
1412
- panel.appendChild(content);
1413
- } else {
1414
- content.innerHTML = "";
1415
- }
1416
- let actions = panel.querySelector(`.${PREFIX}-time-picker__actions`);
1417
- if (!actions) {
1418
- actions = document.createElement("div");
1419
- actions.className = `${PREFIX}-time-picker__actions`;
1420
- const confirmBtn = document.createElement("button");
1421
- confirmBtn.type = "button";
1422
- confirmBtn.className = `${PREFIX}-time-picker__confirm-button`;
1423
- confirmBtn.textContent = "Pilih";
1424
- confirmBtn.onclick = (e) => {
1425
- e.stopPropagation();
1426
- close();
1427
- };
1428
- actions.appendChild(confirmBtn);
1429
- panel.appendChild(actions);
1430
- }
1431
- const parseTime = (timeStr) => {
1432
- if (!timeStr) return { hours: 0, minutes: 0, seconds: 0, period: "AM" };
1433
- let hours = 0, minutes = 0, seconds = 0, period = "AM";
1434
- try {
1435
- if (use12Hours) {
1436
- const [time, p] = timeStr.split(" ");
1437
- const [h, m, s] = time.split(":");
1438
- hours = parseInt(h || "0", 10);
1439
- minutes = parseInt(m || "0", 10);
1440
- seconds = parseInt(s || "0", 10);
1441
- period = p || "AM";
1442
- } else {
1443
- const [h, m, s] = timeStr.split(":");
1444
- hours = parseInt(h || "0", 10);
1445
- minutes = parseInt(m || "0", 10);
1446
- seconds = parseInt(s || "0", 10);
1447
- }
1448
- } catch (e) {
1449
- console.warn("Invalid time format", timeStr);
1450
- }
1451
- return { hours, minutes, seconds, period };
1452
- };
1453
- const formatTime = (h, m, s, p) => {
1454
- const pad = (n) => n.toString().padStart(2, "0");
1455
- if (use12Hours) {
1456
- let displayHours = h;
1457
- if (displayHours === 0) displayHours = 12;
1458
- const main = `${pad(displayHours)}:${pad(m)}`;
1459
- const sec = showSecond ? `:${pad(s)}` : "";
1460
- return `${main}${sec} ${p}`;
1461
- } else {
1462
- const main = `${pad(h)}:${pad(m)}`;
1463
- const sec = showSecond ? `:${pad(s)}` : "";
1464
- return `${main}${sec}`;
1465
- }
1466
- };
1467
- let currentTime = parseTime(internalValue);
1468
- const renderColumn = (type, max) => {
1469
- const column = document.createElement("div");
1470
- column.className = `${PREFIX}-time-picker__column ${PREFIX}-time-picker__column--${type}`;
1471
- const colContent = document.createElement("div");
1472
- colContent.className = `${PREFIX}-time-picker__column-content`;
1473
- column.appendChild(colContent);
1474
- const start = type === "hour" && use12Hours ? 1 : 0;
1475
- const end = type === "hour" && use12Hours ? 12 : max - 1;
1476
- for (let i = start; i <= end; i++) {
1477
- const option = document.createElement("div");
1478
- option.className = `${PREFIX}-time-picker__option`;
1479
- option.textContent = i.toString().padStart(2, "0");
1480
- option.dataset.value = i;
1481
- let isSelected = false;
1482
- if (type === "hour") {
1483
- isSelected = currentTime.hours === i || use12Hours && currentTime.hours === 0 && i === 12;
1484
- } else if (type === "minute") isSelected = currentTime.minutes === i;
1485
- else if (type === "second") isSelected = currentTime.seconds === i;
1486
- if (isSelected)
1487
- option.classList.add(`${PREFIX}-time-picker__option--selected`);
1488
- option.addEventListener("click", (e) => {
1489
- e.stopPropagation();
1490
- const val = parseInt(option.dataset.value, 10);
1491
- if (type === "hour")
1492
- currentTime.hours = use12Hours && val === 12 ? 0 : val;
1493
- if (type === "hour") currentTime.hours = val;
1494
- if (type === "minute") currentTime.minutes = val;
1495
- if (type === "second") currentTime.seconds = val;
1496
- updateInput();
1497
- colContent.querySelectorAll(`.${PREFIX}-time-picker__option`).forEach(
1498
- (el) => el.classList.remove(`${PREFIX}-time-picker__option--selected`)
1499
- );
1500
- option.classList.add(`${PREFIX}-time-picker__option--selected`);
1501
- });
1502
- colContent.appendChild(option);
1684
+ let selectedDateTarget = null;
1685
+ let fromSelectedDate = null;
1686
+ let toSelectedDate = null;
1687
+ let selectedDate = null;
1688
+ const MONTHS = [
1689
+ "Januari",
1690
+ "Februari",
1691
+ "Maret",
1692
+ "April",
1693
+ "Mei",
1694
+ "Juni",
1695
+ "Juli",
1696
+ "Agustus",
1697
+ "September",
1698
+ "Oktober",
1699
+ "November",
1700
+ "Desember"
1701
+ ];
1702
+ const DAYS = ["Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"];
1703
+ const rangeDatepickerTrigger = rangeDatepicker.querySelector(
1704
+ `.ina-ss-range-datepicker__trigger`
1705
+ );
1706
+ const rangeDatepickerPopover = rangeDatepicker.querySelector(
1707
+ `.ina-ss-range-datepicker__popover`
1708
+ );
1709
+ const datePickerLeftDate = rangeDatepicker.querySelector(
1710
+ `.ina-ss-range-datepicker__left-date`
1711
+ );
1712
+ const datePickerRightDate = rangeDatepicker.querySelector(
1713
+ `.ina-ss-range-datepicker__right-date`
1714
+ );
1715
+ const datepickerMonthLeftTrigger = datePickerLeftDate.querySelector(
1716
+ `.ina-ss-range-datepicker__month-trigger`
1717
+ );
1718
+ const datepickerMonthRightTrigger = datePickerRightDate.querySelector(
1719
+ `.ina-ss-range-datepicker__month-trigger`
1720
+ );
1721
+ const datepickerLeftContent = datePickerLeftDate.querySelector(
1722
+ `.ina-ss-range-datepicker__content`
1723
+ );
1724
+ const datepickerRightContent = datePickerRightDate.querySelector(
1725
+ `.ina-ss-range-datepicker__content`
1726
+ );
1727
+ const prevMonthButtonLeft = datePickerLeftDate.querySelector(
1728
+ `.ina-ss-range-datepicker__nav-prev`
1729
+ );
1730
+ const nextMonthButtonLeft = datePickerLeftDate.querySelector(
1731
+ `.ina-ss-range-datepicker__nav-next`
1732
+ );
1733
+ const prevMonthButtonRight = datePickerRightDate.querySelector(
1734
+ `.ina-ss-range-datepicker__nav-prev`
1735
+ );
1736
+ const nextMonthButtonRight = datePickerRightDate.querySelector(
1737
+ `.ina-ss-range-datepicker__nav-next`
1738
+ );
1739
+ function renderCalendar(targetEl, year, month) {
1740
+ const rangeDatepickerMonthTrigger = targetEl.querySelector(
1741
+ `.ina-ss-range-datepicker__month-trigger`
1742
+ );
1743
+ const rangeDatepickerMonthPopover = targetEl.querySelector(
1744
+ `.ina-ss-range-datepicker__month-popover`
1745
+ );
1746
+ const rangeDatepickerMonthItem = targetEl.querySelectorAll(
1747
+ `.ina-ss-range-datepicker__month-item`
1748
+ );
1749
+ const rangeDatepickerYearTrigger = targetEl.querySelector(
1750
+ `.ina-ss-range-datepicker__year-trigger`
1751
+ );
1752
+ const targetContentEl = targetEl.querySelector(
1753
+ `.ina-ss-range-datepicker__content`
1754
+ );
1755
+ targetContentEl.innerHTML = "";
1756
+ rangeDatepickerMonthTrigger.textContent = MONTHS[month].substring(0, 3);
1757
+ rangeDatepickerYearTrigger.textContent = year;
1758
+ DAYS.forEach((day) => {
1759
+ const dayNameWrapper = document.createElement("div");
1760
+ dayNameWrapper.className = `ina-ss-range-datepicker__dayname-wrapper`;
1761
+ const dayNameEl = document.createElement("span");
1762
+ dayNameEl.className = `ina-ss-range-datepicker__dayname`;
1763
+ dayNameEl.textContent = day.substring(0, 3);
1764
+ dayNameWrapper.appendChild(dayNameEl);
1765
+ targetContentEl.appendChild(dayNameWrapper);
1766
+ });
1767
+ const firstDayOfMonth = new Date(year, month, 1).getDay();
1768
+ const daysInMonth = new Date(year, month + 1, 0).getDate();
1769
+ const daysInPrevMonth = new Date(year, month, 0).getDate();
1770
+ for (let i = 0; i < firstDayOfMonth; i++) {
1771
+ const dayEl = document.createElement("button");
1772
+ dayEl.className = `ina-ss-range-datepicker__calendar-day outside-month`;
1773
+ dayEl.textContent = daysInPrevMonth - firstDayOfMonth + 1 + i;
1774
+ dayEl.disabled = true;
1775
+ targetContentEl.appendChild(dayEl);
1503
1776
  }
1504
- return column;
1505
- };
1506
- const renderPeriodColumn = () => {
1507
- const column = document.createElement("div");
1508
- column.className = `${PREFIX}-time-picker__column ${PREFIX}-time-picker__column--period`;
1509
- const colContent = document.createElement("div");
1510
- colContent.className = `${PREFIX}-time-picker__column-content`;
1511
- column.appendChild(colContent);
1512
- ["AM", "PM"].forEach((p) => {
1513
- const option = document.createElement("div");
1514
- option.className = `${PREFIX}-time-picker__option`;
1515
- option.textContent = p;
1516
- if (currentTime.period === p)
1517
- option.classList.add(`${PREFIX}-time-picker__option--selected`);
1518
- option.addEventListener("click", (e) => {
1519
- e.stopPropagation();
1520
- currentTime.period = p;
1521
- updateInput();
1522
- colContent.querySelectorAll(`.${PREFIX}-time-picker__option`).forEach(
1523
- (el) => el.classList.remove(`${PREFIX}-time-picker__option--selected`)
1777
+ const today = /* @__PURE__ */ new Date();
1778
+ for (let i = 1; i <= daysInMonth; i++) {
1779
+ const dayEl = document.createElement("button");
1780
+ dayEl.className = `ina-ss-range-datepicker__calendar-day`;
1781
+ dayEl.textContent = i;
1782
+ dayEl.dataset.date = new Date(year, month, i).toISOString();
1783
+ if (fromSelectedDate && new Date(year, month, i).getTime() === fromSelectedDate?.getTime()) {
1784
+ dayEl.classList.add("selected-from");
1785
+ }
1786
+ if (toSelectedDate && new Date(year, month, i).getTime() === toSelectedDate?.getTime()) {
1787
+ dayEl.classList.add("selected-to");
1788
+ }
1789
+ if (toSelectedDate && new Date(year, month, i) === toSelectedDate) {
1790
+ dayEl.classList.add("selected-to");
1791
+ }
1792
+ if (fromSelectedDate && toSelectedDate && new Date(year, month, i) > fromSelectedDate && new Date(year, month, i) < toSelectedDate) {
1793
+ dayEl.classList.add("selected-range");
1794
+ }
1795
+ if (year === today.getFullYear() && month === today.getMonth() && i === today.getDate()) {
1796
+ const marker = document.createElement("span");
1797
+ marker.className = `ina-ss-range-datepicker__today-marker`;
1798
+ marker.textContent = "Hari ini";
1799
+ dayEl.appendChild(marker);
1800
+ dayEl.classList.add("today");
1801
+ }
1802
+ if (selectedDate && year === selectedDate.getFullYear() && month === selectedDate.getMonth() && i === selectedDate.getDate()) {
1803
+ dayEl.classList.add("selected");
1804
+ }
1805
+ targetContentEl.appendChild(dayEl);
1806
+ }
1807
+ const totalCells = 42;
1808
+ const cellsRendered = firstDayOfMonth + daysInMonth;
1809
+ const remainingCells = totalCells - cellsRendered;
1810
+ for (let i = 1; i <= remainingCells; i++) {
1811
+ const dayEl = document.createElement("button");
1812
+ dayEl.className = `ina-ss-range-datepicker__calendar-day outside-month`;
1813
+ dayEl.textContent = i;
1814
+ dayEl.disabled = true;
1815
+ targetContentEl.appendChild(dayEl);
1816
+ }
1817
+ }
1818
+ function handleChangeDate(target) {
1819
+ if (fromSelectedDate && toSelectedDate) {
1820
+ if (target.classList.contains(
1821
+ `ina-ss-range-datepicker__calendar-day`
1822
+ ) && !target.classList.contains("outside-month")) {
1823
+ const targetDate = new Date(target.dataset.date);
1824
+ if (target.classList.contains("selected-from") || target.classList.contains("selected-to")) {
1825
+ const fromSelectedDateLeftEl = datepickerLeftContent.querySelector(
1826
+ `.ina-ss-range-datepicker__calendar-day.selected-from`
1827
+ );
1828
+ const fromSelectedDateRightEl = datepickerRightContent.querySelector(
1829
+ `.ina-ss-range-datepicker__calendar-day.selected-from`
1830
+ );
1831
+ fromSelectedDateLeftEl?.classList.remove("selected-from");
1832
+ fromSelectedDateRightEl?.classList.remove("selected-from");
1833
+ const toSelectedDateLeftEl = datepickerLeftContent.querySelector(
1834
+ `.ina-ss-range-datepicker__calendar-day.selected-to`
1835
+ );
1836
+ const toSelectedDateRightEl = datepickerRightContent.querySelector(
1837
+ `.ina-ss-range-datepicker__calendar-day.selected-to`
1838
+ );
1839
+ toSelectedDateLeftEl?.classList.remove("selected-to");
1840
+ toSelectedDateRightEl?.classList.remove("selected-to");
1841
+ target.classList.add("selected-from");
1842
+ target.classList.add("selected-to");
1843
+ fromSelectedDate = targetDate;
1844
+ toSelectedDate = targetDate;
1845
+ }
1846
+ if (targetDate < fromSelectedDate) {
1847
+ const fromSelectedDateLeftEl = datepickerLeftContent.querySelector(
1848
+ `.ina-ss-range-datepicker__calendar-day.selected-from`
1849
+ );
1850
+ const fromSelectedDateRightEl = datepickerRightContent.querySelector(
1851
+ `.ina-ss-range-datepicker__calendar-day.selected-from`
1852
+ );
1853
+ fromSelectedDateLeftEl?.classList.remove("selected-from");
1854
+ fromSelectedDateRightEl?.classList.remove("selected-from");
1855
+ fromSelectedDate = targetDate;
1856
+ target.classList.add("selected-from");
1857
+ }
1858
+ if (targetDate > toSelectedDate || targetDate > fromSelectedDate) {
1859
+ const toSelectedDateLeftEl = datepickerLeftContent.querySelector(
1860
+ `.ina-ss-range-datepicker__calendar-day.selected-to`
1861
+ );
1862
+ const toSelectedDateRightEl = datepickerRightContent.querySelector(
1863
+ `.ina-ss-range-datepicker__calendar-day.selected-to`
1864
+ );
1865
+ toSelectedDateLeftEl?.classList.remove("selected-to");
1866
+ toSelectedDateRightEl?.classList.remove("selected-to");
1867
+ toSelectedDate = targetDate;
1868
+ target.classList.add("selected-to");
1869
+ }
1870
+ const leftDays = datepickerLeftContent.querySelectorAll(
1871
+ ".ina-ss-range-datepicker__calendar-day"
1524
1872
  );
1525
- option.classList.add(`${PREFIX}-time-picker__option--selected`);
1526
- });
1527
- colContent.appendChild(option);
1528
- });
1529
- return column;
1530
- };
1531
- const updateInput = () => {
1532
- const val = formatTime(
1533
- currentTime.hours,
1534
- currentTime.minutes,
1535
- currentTime.seconds,
1536
- currentTime.period
1873
+ const rightDays = datepickerRightContent.querySelectorAll(
1874
+ ".ina-ss-range-datepicker__calendar-day"
1875
+ );
1876
+ const leftDaysArray = Array.from(leftDays);
1877
+ const rightDaysArray = Array.from(rightDays);
1878
+ const leftFromIndex = leftDaysArray.findIndex(
1879
+ (btn) => btn.classList.contains("selected-from")
1880
+ );
1881
+ const rightFromIndex = rightDaysArray.findIndex(
1882
+ (btn) => btn.classList.contains("selected-from")
1883
+ );
1884
+ const leftToIndex = leftDaysArray.findIndex(
1885
+ (btn) => btn.classList.contains("selected-to")
1886
+ );
1887
+ const rightToIndex = rightDaysArray.findIndex(
1888
+ (btn) => btn.classList.contains("selected-to")
1889
+ );
1890
+ leftDaysArray.forEach(
1891
+ (btn) => btn.classList.remove("selected-range")
1892
+ );
1893
+ rightDaysArray.forEach(
1894
+ (btn) => btn.classList.remove("selected-range")
1895
+ );
1896
+ if (leftFromIndex !== -1 && leftToIndex !== -1 && rightFromIndex === -1 && rightToIndex === -1) {
1897
+ for (let i = leftFromIndex + 1; i <= leftToIndex - 1; i++) {
1898
+ leftDaysArray[i].classList.add("selected-range");
1899
+ }
1900
+ }
1901
+ if (leftFromIndex !== -1 && rightToIndex !== -1) {
1902
+ for (let i = leftFromIndex + 1; i < leftDaysArray.length; i++) {
1903
+ leftDaysArray[i].classList.add("selected-range");
1904
+ }
1905
+ for (let i = 0; i < rightToIndex; i++) {
1906
+ rightDaysArray[i].classList.add("selected-range");
1907
+ }
1908
+ }
1909
+ if (leftFromIndex === -1 && leftToIndex === -1 && rightFromIndex !== -1 && rightToIndex !== -1) {
1910
+ for (let i = rightFromIndex + 1; i <= rightToIndex - 1; i++) {
1911
+ rightDaysArray[i].classList.add("selected-range");
1912
+ }
1913
+ }
1914
+ }
1915
+ } else {
1916
+ if (target.classList.contains(
1917
+ `ina-ss-range-datepicker__calendar-day`
1918
+ ) && !target.classList.contains("outside-month")) {
1919
+ if (target.classList.contains("selected-from") && target.classList.contains("selected-to")) {
1920
+ target.classList.remove("selected-from");
1921
+ target.classList.remove("selected-to");
1922
+ selectedDateTarget = null;
1923
+ } else {
1924
+ target.classList.add("selected-from");
1925
+ target.classList.add("selected-to");
1926
+ selectedDateTarget = target;
1927
+ }
1928
+ fromSelectedDate = selectedDateTarget ? new Date(selectedDateTarget.dataset.date) : null;
1929
+ toSelectedDate = selectedDateTarget ? new Date(selectedDateTarget.dataset.date) : null;
1930
+ }
1931
+ }
1932
+ rangeDatepicker.dispatchEvent(
1933
+ new CustomEvent("date:changed", {
1934
+ detail: {
1935
+ selectedDate: {
1936
+ from: fromSelectedDate,
1937
+ to: toSelectedDate
1938
+ }
1939
+ }
1940
+ })
1537
1941
  );
1538
- input.value = val;
1539
- picker.dataset.value = val;
1540
- input.dispatchEvent(new Event("change", { bubbles: true }));
1541
- };
1542
- const buildPanel = () => {
1543
- content.innerHTML = "";
1544
- content.appendChild(renderColumn("hour", use12Hours ? 13 : 24));
1545
- content.appendChild(renderColumn("minute", 60));
1546
- if (showSecond) content.appendChild(renderColumn("second", 60));
1547
- if (use12Hours) content.appendChild(renderPeriodColumn());
1548
- };
1549
- const open = () => {
1550
- if (disabled) return;
1551
- isOpen = true;
1552
- picker.classList.add(`${PREFIX}-time-picker--open`);
1553
- panel.style.display = "block";
1554
- currentTime = parseTime(input.value);
1555
- buildPanel();
1556
- document.dispatchEvent(
1557
- new CustomEvent("closeTimePicker", { detail: { exclude: picker } })
1942
+ }
1943
+ datepickerLeftContent.addEventListener("click", (e) => {
1944
+ const target = e.target;
1945
+ if (!target) return;
1946
+ handleChangeDate(target);
1947
+ });
1948
+ datepickerRightContent.addEventListener("click", (e) => {
1949
+ const target = e.target;
1950
+ if (!target) return;
1951
+ handleChangeDate(target);
1952
+ });
1953
+ function togglePopover() {
1954
+ if (rangeDatepickerPopover.style.display === "none" || rangeDatepickerPopover.style.display === "") {
1955
+ rangeDatepickerPopover.style.display = "flex";
1956
+ renderCalendar(
1957
+ datePickerLeftDate,
1958
+ currentDateLeft.getFullYear(),
1959
+ currentDateLeft.getMonth()
1960
+ );
1961
+ renderCalendar(
1962
+ datePickerRightDate,
1963
+ currentDateRight.getFullYear(),
1964
+ currentDateRight.getMonth()
1965
+ );
1966
+ } else {
1967
+ rangeDatepickerPopover.style.display = "none";
1968
+ }
1969
+ }
1970
+ function getMonthDifference(d1, d2) {
1971
+ let months;
1972
+ months = (d2.getFullYear() - d1.getFullYear()) * 12;
1973
+ months -= d1.getMonth();
1974
+ months += d2.getMonth();
1975
+ return months;
1976
+ }
1977
+ rangeDatepickerTrigger.addEventListener("click", (e) => {
1978
+ e.stopPropagation();
1979
+ togglePopover();
1980
+ });
1981
+ prevMonthButtonLeft.addEventListener("click", () => {
1982
+ currentDateLeft.setMonth(currentDateLeft.getMonth() - 1);
1983
+ renderCalendar(
1984
+ datePickerLeftDate,
1985
+ currentDateLeft.getFullYear(),
1986
+ currentDateLeft.getMonth()
1987
+ );
1988
+ });
1989
+ nextMonthButtonLeft.addEventListener("click", () => {
1990
+ const monthDiff = getMonthDifference(currentDateLeft, currentDateRight);
1991
+ currentDateLeft.setMonth(currentDateLeft.getMonth() + 1);
1992
+ renderCalendar(
1993
+ datePickerLeftDate,
1994
+ currentDateLeft.getFullYear(),
1995
+ currentDateLeft.getMonth()
1996
+ );
1997
+ if (monthDiff === 1) {
1998
+ currentDateRight.setMonth(currentDateRight.getMonth() + 1);
1999
+ renderCalendar(
2000
+ datePickerRightDate,
2001
+ currentDateRight.getFullYear(),
2002
+ currentDateRight.getMonth()
2003
+ );
2004
+ }
2005
+ });
2006
+ prevMonthButtonRight.addEventListener("click", () => {
2007
+ const monthDiff = getMonthDifference(currentDateLeft, currentDateRight);
2008
+ currentDateRight.setMonth(currentDateRight.getMonth() - 1);
2009
+ renderCalendar(
2010
+ datePickerRightDate,
2011
+ currentDateRight.getFullYear(),
2012
+ currentDateRight.getMonth()
2013
+ );
2014
+ if (monthDiff === 1) {
2015
+ currentDateLeft.setMonth(currentDateRight.getMonth() - 1);
2016
+ renderCalendar(
2017
+ datePickerLeftDate,
2018
+ currentDateLeft.getFullYear(),
2019
+ currentDateLeft.getMonth()
2020
+ );
2021
+ }
2022
+ });
2023
+ nextMonthButtonRight.addEventListener("click", () => {
2024
+ currentDateRight.setMonth(currentDateRight.getMonth() + 1);
2025
+ renderCalendar(
2026
+ datePickerRightDate,
2027
+ currentDateRight.getFullYear(),
2028
+ currentDateRight.getMonth()
1558
2029
  );
1559
- };
1560
- const close = () => {
1561
- isOpen = false;
1562
- picker.classList.remove(`${PREFIX}-time-picker--open`);
1563
- panel.style.display = "none";
1564
- };
1565
- const toggle = (e) => {
1566
- e.stopPropagation();
1567
- if (isOpen) close();
1568
- else open();
1569
- };
1570
- wrapper.addEventListener("click", toggle);
1571
- input.addEventListener("click", (e) => {
1572
2030
  });
1573
2031
  document.addEventListener("click", (e) => {
1574
- if (!picker.contains(e.target)) close();
1575
- });
1576
- document.addEventListener("closeTimePicker", (e) => {
1577
- if (e.detail && e.detail.exclude !== picker) close();
2032
+ if (!rangeDatepickerPopover.contains(e.target) && e.target !== rangeDatepickerTrigger && !rangeDatepickerTrigger.contains(e.target)) {
2033
+ rangeDatepickerPopover.style.display = "none";
2034
+ }
1578
2035
  });
1579
- const clearBtn = picker.querySelector(
1580
- `.${PREFIX}-time-picker__clear-button`
1581
- );
1582
- if (clearBtn && allowClear) {
1583
- clearBtn.addEventListener("click", (e) => {
1584
- e.stopPropagation();
1585
- input.value = "";
1586
- currentTime = { hours: 0, minutes: 0, seconds: 0, period: "AM" };
1587
- picker.dataset.value = "";
1588
- input.dispatchEvent(new Event("change", { bubbles: true }));
1589
- });
1590
- }
1591
2036
  });
1592
2037
  }
1593
2038
 
1594
- // src/js/index.js
1595
- var PREFIX = "ina";
1596
-
1597
- // src/js/components/stateful/button-group.js
1598
- function initButtonGroup(rootSelector = `.${PREFIX}-button-group`) {
1599
- const buttonGroups = document.querySelectorAll(rootSelector);
1600
- buttonGroups.forEach((buttonGroup) => {
1601
- if (buttonGroup.__inaButtonGroupInitialized) return;
1602
- const buttons = buttonGroup.querySelectorAll(
1603
- `.${PREFIX}-button-group__button`
1604
- );
1605
- const updateState = (clickedButton) => {
1606
- const isDisabled = clickedButton.hasAttribute("disabled") || clickedButton.classList.contains(
1607
- `${PREFIX}-button-group__button--disabled`
1608
- );
1609
- if (isDisabled) return;
1610
- const value = clickedButton.getAttribute("data-value");
1611
- buttons.forEach((btn) => {
1612
- if (btn === clickedButton) {
1613
- btn.classList.add(`${PREFIX}-button-group__button--selected`);
1614
- btn.setAttribute("aria-pressed", "true");
1615
- } else {
1616
- btn.classList.remove(`${PREFIX}-button-group__button--selected`);
1617
- btn.setAttribute("aria-pressed", "false");
1618
- }
1619
- });
1620
- buttonGroup.dispatchEvent(
1621
- new CustomEvent("button-group:change", {
1622
- detail: { value },
1623
- bubbles: true,
1624
- composed: true
1625
- })
2039
+ // src/js/components/stateless/img-compare.js
2040
+ function initImgCompare(rootSelector = `.${PREFIX}-img-compare`) {
2041
+ document.querySelectorAll(rootSelector).forEach((imgCompare) => {
2042
+ const sliderEl = document.createElement("input");
2043
+ sliderEl.type = "range";
2044
+ sliderEl.min = "0";
2045
+ sliderEl.max = "100";
2046
+ sliderEl.value = "50";
2047
+ sliderEl.setAttribute("aria-label", "Percentage of the image to show");
2048
+ sliderEl.setAttribute("aria-valuenow", "50");
2049
+ sliderEl.setAttribute("aria-valuemin", "0");
2050
+ sliderEl.setAttribute("aria-valuemax", "100");
2051
+ sliderEl.classList.add("ina-ss-img__slider");
2052
+ sliderEl.addEventListener("input", () => {
2053
+ imgCompare.style.setProperty(
2054
+ `--${PREFIX}-position`,
2055
+ `${sliderEl.value}%`
1626
2056
  );
1627
- };
1628
- buttons.forEach((button) => {
1629
- button.addEventListener("click", (e) => {
1630
- if (button.type !== "submit") {
1631
- e.preventDefault();
1632
- }
1633
- updateState(button);
1634
- });
1635
2057
  });
1636
- buttonGroup.__inaButtonGroupInitialized = true;
2058
+ const sliderLineEl = document.createElement("div");
2059
+ sliderLineEl.classList.add("ina-ss-img__slider-line");
2060
+ const sliderButtonEl = document.createElement("button");
2061
+ sliderButtonEl.classList.add("ina-ss-img__slider-button");
2062
+ imgCompare.appendChild(sliderEl);
2063
+ imgCompare.appendChild(sliderLineEl);
2064
+ imgCompare.appendChild(sliderButtonEl);
1637
2065
  });
1638
2066
  }
1639
2067
 
1640
- // src/js/components/stateful/dropdown.js
1641
- function initDropdown(rootSelector = `.${PREFIX}-dropdown`) {
1642
- document.querySelectorAll(rootSelector).forEach((dropdown) => {
1643
- const trigger = dropdown.querySelector(`.${PREFIX}-dropdown__trigger`);
1644
- const input = dropdown.querySelector(`.${PREFIX}-dropdown__input`);
1645
- const menu = dropdown.querySelector(`.${PREFIX}-dropdown__menu`);
1646
- const menuItems = menu.querySelectorAll("li[role='option']");
1647
- const menuId = menu.id;
1648
- let activeIndex = -1;
1649
- menuItems.forEach((item, index) => {
1650
- item.id = `${menuId}-item-${index}`;
1651
- });
1652
- const toggleMenu = (show) => {
1653
- const isCurrentlyShown = dropdown.classList.contains("show");
1654
- const isShown = show !== void 0 ? show : !isCurrentlyShown;
1655
- if (isShown === isCurrentlyShown) {
1656
- return;
2068
+ // src/js/components/stateful/timepicker.js
2069
+ function initTimepicker() {
2070
+ document.querySelectorAll(`.${PREFIX}-time-picker`).forEach((picker) => {
2071
+ if (picker.dataset.initialized === "true") return;
2072
+ picker.dataset.initialized = "true";
2073
+ const input = picker.querySelector(`.${PREFIX}-time-picker__input`);
2074
+ const wrapper = picker.querySelector(`.${PREFIX}-time-picker__wrapper`);
2075
+ if (!input || !wrapper) return;
2076
+ const format = picker.dataset.format || "HH:mm";
2077
+ const use12Hours = picker.dataset.use12Hours === "true" || picker.getAttribute("data-use-12-hours") === "true" || /a/i.test(format);
2078
+ const showSecond = picker.dataset.showSecond === "true";
2079
+ const disabled = picker.classList.contains(
2080
+ `${PREFIX}-time-picker--disabled`
2081
+ );
2082
+ const allowClear = picker.dataset.allowClear !== "false";
2083
+ let isOpen = false;
2084
+ let internalValue = input.value || "";
2085
+ let panel = picker.querySelector(`.${PREFIX}-time-picker__panel`);
2086
+ if (!panel) {
2087
+ panel = document.createElement("div");
2088
+ panel.className = `${PREFIX}-time-picker__panel`;
2089
+ panel.style.display = "none";
2090
+ picker.appendChild(panel);
2091
+ }
2092
+ let content = panel.querySelector(`.${PREFIX}-time-picker__content`);
2093
+ if (!content) {
2094
+ content = document.createElement("div");
2095
+ content.className = `${PREFIX}-time-picker__content`;
2096
+ panel.appendChild(content);
2097
+ } else {
2098
+ content.innerHTML = "";
2099
+ }
2100
+ let actions = panel.querySelector(`.${PREFIX}-time-picker__actions`);
2101
+ if (!actions) {
2102
+ actions = document.createElement("div");
2103
+ actions.className = `${PREFIX}-time-picker__actions`;
2104
+ const confirmBtn = document.createElement("button");
2105
+ confirmBtn.type = "button";
2106
+ confirmBtn.className = `${PREFIX}-time-picker__confirm-button`;
2107
+ confirmBtn.textContent = "Pilih";
2108
+ confirmBtn.onclick = (e) => {
2109
+ e.stopPropagation();
2110
+ close();
2111
+ };
2112
+ actions.appendChild(confirmBtn);
2113
+ panel.appendChild(actions);
2114
+ }
2115
+ const parseTime = (timeStr) => {
2116
+ if (!timeStr) return { hours: 0, minutes: 0, seconds: 0, period: "AM" };
2117
+ let hours = 0, minutes = 0, seconds = 0, period = "AM";
2118
+ try {
2119
+ if (use12Hours) {
2120
+ const [time, p] = timeStr.split(" ");
2121
+ const [h, m, s] = time.split(":");
2122
+ hours = parseInt(h || "0", 10);
2123
+ minutes = parseInt(m || "0", 10);
2124
+ seconds = parseInt(s || "0", 10);
2125
+ period = p || "AM";
2126
+ } else {
2127
+ const [h, m, s] = timeStr.split(":");
2128
+ hours = parseInt(h || "0", 10);
2129
+ minutes = parseInt(m || "0", 10);
2130
+ seconds = parseInt(s || "0", 10);
2131
+ }
2132
+ } catch (e) {
2133
+ console.warn("Invalid time format", timeStr);
1657
2134
  }
1658
- dropdown.classList.toggle("show", isShown);
1659
- trigger.setAttribute("aria-expanded", isShown);
1660
- if (isShown) {
1661
- input.focus();
2135
+ return { hours, minutes, seconds, period };
2136
+ };
2137
+ const formatTime = (h, m, s, p) => {
2138
+ const pad = (n) => n.toString().padStart(2, "0");
2139
+ if (use12Hours) {
2140
+ let displayHours = h;
2141
+ if (displayHours === 0) displayHours = 12;
2142
+ const main = `${pad(displayHours)}:${pad(m)}`;
2143
+ const sec = showSecond ? `:${pad(s)}` : "";
2144
+ return `${main}${sec} ${p}`;
1662
2145
  } else {
1663
- input.blur();
1664
- removeHighlight();
1665
- activeIndex = -1;
1666
- input.removeAttribute("aria-activedescendant");
2146
+ const main = `${pad(h)}:${pad(m)}`;
2147
+ const sec = showSecond ? `:${pad(s)}` : "";
2148
+ return `${main}${sec}`;
1667
2149
  }
1668
2150
  };
1669
- const filterItems = () => {
1670
- const filterValue = input.value.toLowerCase();
1671
- let hasVisibleItems = false;
1672
- activeIndex = -1;
1673
- removeHighlight();
1674
- input.removeAttribute("aria-activedescendant");
1675
- const activeItem = menu.querySelector("li[role='option'].selected");
1676
- if (activeItem && input.value !== activeItem.textContent.trim()) {
1677
- activeItem.classList.remove("selected");
1678
- }
1679
- menuItems.forEach((item) => {
1680
- const itemText = item.textContent.toLowerCase();
1681
- const isMatch = itemText.includes(filterValue);
1682
- item.classList.toggle("hidden", !isMatch);
1683
- if (isMatch) hasVisibleItems = true;
1684
- });
1685
- if (!dropdown.classList.contains("show") && hasVisibleItems) {
1686
- toggleMenu(true);
2151
+ let currentTime = parseTime(internalValue);
2152
+ const renderColumn = (type, max) => {
2153
+ const column = document.createElement("div");
2154
+ column.className = `${PREFIX}-time-picker__column ${PREFIX}-time-picker__column--${type}`;
2155
+ const colContent = document.createElement("div");
2156
+ colContent.className = `${PREFIX}-time-picker__column-content`;
2157
+ column.appendChild(colContent);
2158
+ const start = type === "hour" && use12Hours ? 1 : 0;
2159
+ const end = type === "hour" && use12Hours ? 12 : max - 1;
2160
+ for (let i = start; i <= end; i++) {
2161
+ const option = document.createElement("div");
2162
+ option.className = `${PREFIX}-time-picker__option`;
2163
+ option.textContent = i.toString().padStart(2, "0");
2164
+ option.dataset.value = i;
2165
+ let isSelected = false;
2166
+ if (type === "hour") {
2167
+ isSelected = currentTime.hours === i || use12Hours && currentTime.hours === 0 && i === 12;
2168
+ } else if (type === "minute") isSelected = currentTime.minutes === i;
2169
+ else if (type === "second") isSelected = currentTime.seconds === i;
2170
+ if (isSelected)
2171
+ option.classList.add(`${PREFIX}-time-picker__option--selected`);
2172
+ option.addEventListener("click", (e) => {
2173
+ e.stopPropagation();
2174
+ const val = parseInt(option.dataset.value, 10);
2175
+ if (type === "hour")
2176
+ currentTime.hours = use12Hours && val === 12 ? 0 : val;
2177
+ if (type === "hour") currentTime.hours = val;
2178
+ if (type === "minute") currentTime.minutes = val;
2179
+ if (type === "second") currentTime.seconds = val;
2180
+ updateInput();
2181
+ colContent.querySelectorAll(`.${PREFIX}-time-picker__option`).forEach(
2182
+ (el) => el.classList.remove(`${PREFIX}-time-picker__option--selected`)
2183
+ );
2184
+ option.classList.add(`${PREFIX}-time-picker__option--selected`);
2185
+ });
2186
+ colContent.appendChild(option);
1687
2187
  }
2188
+ return column;
1688
2189
  };
1689
- const selectItem = (item) => {
1690
- const itemText = item.textContent.trim();
1691
- input.value = itemText;
1692
- menuItems.forEach((li) => {
1693
- li.classList.remove("selected");
2190
+ const renderPeriodColumn = () => {
2191
+ const column = document.createElement("div");
2192
+ column.className = `${PREFIX}-time-picker__column ${PREFIX}-time-picker__column--period`;
2193
+ const colContent = document.createElement("div");
2194
+ colContent.className = `${PREFIX}-time-picker__column-content`;
2195
+ column.appendChild(colContent);
2196
+ ["AM", "PM"].forEach((p) => {
2197
+ const option = document.createElement("div");
2198
+ option.className = `${PREFIX}-time-picker__option`;
2199
+ option.textContent = p;
2200
+ if (currentTime.period === p)
2201
+ option.classList.add(`${PREFIX}-time-picker__option--selected`);
2202
+ option.addEventListener("click", (e) => {
2203
+ e.stopPropagation();
2204
+ currentTime.period = p;
2205
+ updateInput();
2206
+ colContent.querySelectorAll(`.${PREFIX}-time-picker__option`).forEach(
2207
+ (el) => el.classList.remove(`${PREFIX}-time-picker__option--selected`)
2208
+ );
2209
+ option.classList.add(`${PREFIX}-time-picker__option--selected`);
2210
+ });
2211
+ colContent.appendChild(option);
1694
2212
  });
1695
- if (item) {
1696
- item.classList.add("selected");
1697
- dropdown.dispatchEvent(
1698
- new CustomEvent("dropdown:changed", {
1699
- detail: { value: itemText }
1700
- })
1701
- );
1702
- }
1703
- toggleMenu(false);
2213
+ return column;
1704
2214
  };
1705
- const setHighlight = (index) => {
1706
- removeHighlight();
1707
- const visibleItems = menu.querySelectorAll(
1708
- "li[role='option']:not(.hidden)"
2215
+ const updateInput = () => {
2216
+ const val = formatTime(
2217
+ currentTime.hours,
2218
+ currentTime.minutes,
2219
+ currentTime.seconds,
2220
+ currentTime.period
1709
2221
  );
1710
- if (visibleItems.length === 0) return;
1711
- if (index < 0) index = 0;
1712
- else if (index >= visibleItems.length) index = visibleItems.length - 1;
1713
- const itemToHighlight = visibleItems[index];
1714
- if (itemToHighlight) {
1715
- itemToHighlight.classList.add("highlighted");
1716
- input.setAttribute("aria-activedescendant", itemToHighlight.id);
1717
- itemToHighlight.scrollIntoView({
1718
- behavior: "smooth",
1719
- block: "nearest"
1720
- });
1721
- activeIndex = index;
1722
- }
2222
+ input.value = val;
2223
+ picker.dataset.value = val;
2224
+ input.dispatchEvent(new Event("change", { bubbles: true }));
1723
2225
  };
1724
- const removeHighlight = () => {
1725
- menuItems.forEach((item) => item.classList.remove("highlighted"));
2226
+ const buildPanel = () => {
2227
+ content.innerHTML = "";
2228
+ content.appendChild(renderColumn("hour", use12Hours ? 13 : 24));
2229
+ content.appendChild(renderColumn("minute", 60));
2230
+ if (showSecond) content.appendChild(renderColumn("second", 60));
2231
+ if (use12Hours) content.appendChild(renderPeriodColumn());
1726
2232
  };
1727
- trigger.addEventListener("click", () => {
1728
- toggleMenu();
1729
- });
1730
- input.addEventListener("input", filterItems);
1731
- menu.addEventListener("click", (e) => {
1732
- const option = e.target.closest("li[role='option']");
1733
- if (option) {
1734
- e.preventDefault();
1735
- selectItem(option);
1736
- }
2233
+ const open = () => {
2234
+ if (disabled) return;
2235
+ isOpen = true;
2236
+ picker.classList.add(`${PREFIX}-time-picker--open`);
2237
+ panel.style.display = "block";
2238
+ currentTime = parseTime(input.value);
2239
+ buildPanel();
2240
+ document.dispatchEvent(
2241
+ new CustomEvent("closeTimePicker", { detail: { exclude: picker } })
2242
+ );
2243
+ };
2244
+ const close = () => {
2245
+ isOpen = false;
2246
+ picker.classList.remove(`${PREFIX}-time-picker--open`);
2247
+ panel.style.display = "none";
2248
+ };
2249
+ const toggle = (e) => {
2250
+ e.stopPropagation();
2251
+ if (isOpen) close();
2252
+ else open();
2253
+ };
2254
+ wrapper.addEventListener("click", toggle);
2255
+ input.addEventListener("click", (e) => {
1737
2256
  });
1738
2257
  document.addEventListener("click", (e) => {
1739
- if (!dropdown.contains(e.target)) {
1740
- toggleMenu(false);
1741
- }
2258
+ if (!picker.contains(e.target)) close();
1742
2259
  });
1743
- input.addEventListener("keydown", (e) => {
1744
- const { key } = e;
1745
- const isMenuOpen = dropdown.classList.contains("show");
1746
- switch (key) {
1747
- case "ArrowDown":
1748
- e.preventDefault();
1749
- if (!isMenuOpen) {
1750
- toggleMenu(true);
1751
- }
1752
- setHighlight(activeIndex + 1);
1753
- break;
1754
- case "ArrowUp":
1755
- e.preventDefault();
1756
- if (isMenuOpen) {
1757
- setHighlight(activeIndex - 1);
1758
- }
1759
- break;
1760
- case "Enter":
1761
- e.preventDefault();
1762
- const firstVisible = menu.querySelector(
1763
- "li[role='option']:not(.hidden)"
1764
- );
1765
- const activeItem = menu.querySelector(".highlighted");
1766
- if (isMenuOpen && activeItem) {
1767
- selectItem(activeItem);
1768
- } else if (isMenuOpen && firstVisible) {
1769
- toggleMenu(false);
1770
- }
1771
- break;
1772
- case "Escape":
1773
- e.preventDefault();
1774
- toggleMenu(false);
1775
- break;
1776
- case "Tab":
1777
- toggleMenu(false);
1778
- break;
1779
- }
2260
+ document.addEventListener("closeTimePicker", (e) => {
2261
+ if (e.detail && e.detail.exclude !== picker) close();
1780
2262
  });
1781
- });
1782
- }
1783
-
1784
- // src/js/components/stateful/range-datepicker.js
1785
- function initRangeDatepicker() {
1786
- document.querySelectorAll(".ina-ss-range-datepicker").forEach((rangeDatepicker) => {
1787
- let currentDate = /* @__PURE__ */ new Date();
1788
- let currentDateLeft = /* @__PURE__ */ new Date();
1789
- let currentDateRight = new Date(
1790
- currentDateLeft.getFullYear(),
1791
- currentDateLeft.getMonth() + 1,
1792
- currentDateLeft.getDate()
1793
- );
1794
- let selectedDateTarget = null;
1795
- let fromSelectedDate = null;
1796
- let toSelectedDate = null;
1797
- let selectedDate = null;
1798
- const MONTHS = [
1799
- "Januari",
1800
- "Februari",
1801
- "Maret",
1802
- "April",
1803
- "Mei",
1804
- "Juni",
1805
- "Juli",
1806
- "Agustus",
1807
- "September",
1808
- "Oktober",
1809
- "November",
1810
- "Desember"
1811
- ];
1812
- const DAYS = ["Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"];
1813
- const rangeDatepickerTrigger = rangeDatepicker.querySelector(
1814
- `.ina-ss-range-datepicker__trigger`
1815
- );
1816
- const rangeDatepickerPopover = rangeDatepicker.querySelector(
1817
- `.ina-ss-range-datepicker__popover`
1818
- );
1819
- const datePickerLeftDate = rangeDatepicker.querySelector(
1820
- `.ina-ss-range-datepicker__left-date`
1821
- );
1822
- const datePickerRightDate = rangeDatepicker.querySelector(
1823
- `.ina-ss-range-datepicker__right-date`
1824
- );
1825
- const datepickerMonthLeftTrigger = datePickerLeftDate.querySelector(
1826
- `.ina-ss-range-datepicker__month-trigger`
1827
- );
1828
- const datepickerMonthRightTrigger = datePickerRightDate.querySelector(
1829
- `.ina-ss-range-datepicker__month-trigger`
1830
- );
1831
- const datepickerLeftContent = datePickerLeftDate.querySelector(
1832
- `.ina-ss-range-datepicker__content`
1833
- );
1834
- const datepickerRightContent = datePickerRightDate.querySelector(
1835
- `.ina-ss-range-datepicker__content`
1836
- );
1837
- const prevMonthButtonLeft = datePickerLeftDate.querySelector(
1838
- `.ina-ss-range-datepicker__nav-prev`
1839
- );
1840
- const nextMonthButtonLeft = datePickerLeftDate.querySelector(
1841
- `.ina-ss-range-datepicker__nav-next`
1842
- );
1843
- const prevMonthButtonRight = datePickerRightDate.querySelector(
1844
- `.ina-ss-range-datepicker__nav-prev`
1845
- );
1846
- const nextMonthButtonRight = datePickerRightDate.querySelector(
1847
- `.ina-ss-range-datepicker__nav-next`
2263
+ const clearBtn = picker.querySelector(
2264
+ `.${PREFIX}-time-picker__clear-button`
1848
2265
  );
1849
- function renderCalendar(targetEl, year, month) {
1850
- const rangeDatepickerMonthTrigger = targetEl.querySelector(
1851
- `.ina-ss-range-datepicker__month-trigger`
1852
- );
1853
- const rangeDatepickerMonthPopover = targetEl.querySelector(
1854
- `.ina-ss-range-datepicker__month-popover`
1855
- );
1856
- const rangeDatepickerMonthItem = targetEl.querySelectorAll(
1857
- `.ina-ss-range-datepicker__month-item`
1858
- );
1859
- const rangeDatepickerYearTrigger = targetEl.querySelector(
1860
- `.ina-ss-range-datepicker__year-trigger`
1861
- );
1862
- const targetContentEl = targetEl.querySelector(
1863
- `.ina-ss-range-datepicker__content`
1864
- );
1865
- targetContentEl.innerHTML = "";
1866
- rangeDatepickerMonthTrigger.textContent = MONTHS[month].substring(0, 3);
1867
- rangeDatepickerYearTrigger.textContent = year;
1868
- DAYS.forEach((day) => {
1869
- const dayNameWrapper = document.createElement("div");
1870
- dayNameWrapper.className = `ina-ss-range-datepicker__dayname-wrapper`;
1871
- const dayNameEl = document.createElement("span");
1872
- dayNameEl.className = `ina-ss-range-datepicker__dayname`;
1873
- dayNameEl.textContent = day.substring(0, 3);
1874
- dayNameWrapper.appendChild(dayNameEl);
1875
- targetContentEl.appendChild(dayNameWrapper);
2266
+ if (clearBtn && allowClear) {
2267
+ clearBtn.addEventListener("click", (e) => {
2268
+ e.stopPropagation();
2269
+ input.value = "";
2270
+ currentTime = { hours: 0, minutes: 0, seconds: 0, period: "AM" };
2271
+ picker.dataset.value = "";
2272
+ input.dispatchEvent(new Event("change", { bubbles: true }));
1876
2273
  });
1877
- const firstDayOfMonth = new Date(year, month, 1).getDay();
1878
- const daysInMonth = new Date(year, month + 1, 0).getDate();
1879
- const daysInPrevMonth = new Date(year, month, 0).getDate();
1880
- for (let i = 0; i < firstDayOfMonth; i++) {
1881
- const dayEl = document.createElement("button");
1882
- dayEl.className = `ina-ss-range-datepicker__calendar-day outside-month`;
1883
- dayEl.textContent = daysInPrevMonth - firstDayOfMonth + 1 + i;
1884
- dayEl.disabled = true;
1885
- targetContentEl.appendChild(dayEl);
1886
- }
1887
- const today = /* @__PURE__ */ new Date();
1888
- for (let i = 1; i <= daysInMonth; i++) {
1889
- const dayEl = document.createElement("button");
1890
- dayEl.className = `ina-ss-range-datepicker__calendar-day`;
1891
- dayEl.textContent = i;
1892
- dayEl.dataset.date = new Date(year, month, i).toISOString();
1893
- if (fromSelectedDate && new Date(year, month, i).getTime() === fromSelectedDate?.getTime()) {
1894
- dayEl.classList.add("selected-from");
1895
- }
1896
- if (toSelectedDate && new Date(year, month, i).getTime() === toSelectedDate?.getTime()) {
1897
- dayEl.classList.add("selected-to");
1898
- }
1899
- if (toSelectedDate && new Date(year, month, i) === toSelectedDate) {
1900
- dayEl.classList.add("selected-to");
1901
- }
1902
- if (fromSelectedDate && toSelectedDate && new Date(year, month, i) > fromSelectedDate && new Date(year, month, i) < toSelectedDate) {
1903
- dayEl.classList.add("selected-range");
1904
- }
1905
- if (year === today.getFullYear() && month === today.getMonth() && i === today.getDate()) {
1906
- const marker = document.createElement("span");
1907
- marker.className = `ina-ss-range-datepicker__today-marker`;
1908
- marker.textContent = "Hari ini";
1909
- dayEl.appendChild(marker);
1910
- dayEl.classList.add("today");
1911
- }
1912
- if (selectedDate && year === selectedDate.getFullYear() && month === selectedDate.getMonth() && i === selectedDate.getDate()) {
1913
- dayEl.classList.add("selected");
1914
- }
1915
- targetContentEl.appendChild(dayEl);
1916
- }
1917
- const totalCells = 42;
1918
- const cellsRendered = firstDayOfMonth + daysInMonth;
1919
- const remainingCells = totalCells - cellsRendered;
1920
- for (let i = 1; i <= remainingCells; i++) {
1921
- const dayEl = document.createElement("button");
1922
- dayEl.className = `ina-ss-range-datepicker__calendar-day outside-month`;
1923
- dayEl.textContent = i;
1924
- dayEl.disabled = true;
1925
- targetContentEl.appendChild(dayEl);
1926
- }
1927
2274
  }
1928
- function handleChangeDate(target) {
1929
- if (fromSelectedDate && toSelectedDate) {
1930
- if (target.classList.contains(
1931
- `ina-ss-range-datepicker__calendar-day`
1932
- ) && !target.classList.contains("outside-month")) {
1933
- const targetDate = new Date(target.dataset.date);
1934
- if (target.classList.contains("selected-from") || target.classList.contains("selected-to")) {
1935
- const fromSelectedDateLeftEl = datepickerLeftContent.querySelector(
1936
- `.ina-ss-range-datepicker__calendar-day.selected-from`
1937
- );
1938
- const fromSelectedDateRightEl = datepickerRightContent.querySelector(
1939
- `.ina-ss-range-datepicker__calendar-day.selected-from`
1940
- );
1941
- fromSelectedDateLeftEl?.classList.remove("selected-from");
1942
- fromSelectedDateRightEl?.classList.remove("selected-from");
1943
- const toSelectedDateLeftEl = datepickerLeftContent.querySelector(
1944
- `.ina-ss-range-datepicker__calendar-day.selected-to`
1945
- );
1946
- const toSelectedDateRightEl = datepickerRightContent.querySelector(
1947
- `.ina-ss-range-datepicker__calendar-day.selected-to`
1948
- );
1949
- toSelectedDateLeftEl?.classList.remove("selected-to");
1950
- toSelectedDateRightEl?.classList.remove("selected-to");
1951
- target.classList.add("selected-from");
1952
- target.classList.add("selected-to");
1953
- fromSelectedDate = targetDate;
1954
- toSelectedDate = targetDate;
1955
- }
1956
- if (targetDate < fromSelectedDate) {
1957
- const fromSelectedDateLeftEl = datepickerLeftContent.querySelector(
1958
- `.ina-ss-range-datepicker__calendar-day.selected-from`
1959
- );
1960
- const fromSelectedDateRightEl = datepickerRightContent.querySelector(
1961
- `.ina-ss-range-datepicker__calendar-day.selected-from`
1962
- );
1963
- fromSelectedDateLeftEl?.classList.remove("selected-from");
1964
- fromSelectedDateRightEl?.classList.remove("selected-from");
1965
- fromSelectedDate = targetDate;
1966
- target.classList.add("selected-from");
2275
+ });
2276
+ }
2277
+
2278
+ // src/js/components/stateful/chip.js
2279
+ var PREFIX3 = "ina";
2280
+ function initChip(rootSelector = `.${PREFIX3}-chip`) {
2281
+ const chips = document.querySelectorAll(rootSelector);
2282
+ chips.forEach((container) => {
2283
+ if (container.__inaChipInitialized) return;
2284
+ const showCustomization = container.getAttribute("data-show-customization") === "true";
2285
+ const customizationLabel = container.getAttribute("data-customization-label") || "Kustomisasi";
2286
+ let selectedValue = container.getAttribute("data-selected") || "";
2287
+ const list = container.querySelector(`.${PREFIX3}-chip__list`);
2288
+ const items = list ? list.querySelectorAll(`.${PREFIX3}-chip__item`) : [];
2289
+ let customFieldContainer = container.querySelector(
2290
+ `.${PREFIX3}-chip__custom-field`
2291
+ );
2292
+ const updateUI = () => {
2293
+ items.forEach((item) => {
2294
+ const itemValue = item.getAttribute("data-value");
2295
+ const isSelected = itemValue === selectedValue;
2296
+ if (isSelected) {
2297
+ item.classList.add(`${PREFIX3}-chip__item--selected`);
2298
+ } else {
2299
+ item.classList.remove(`${PREFIX3}-chip__item--selected`);
2300
+ }
2301
+ });
2302
+ if (showCustomization) {
2303
+ const isCustomToggleSelected = selectedValue === customizationLabel;
2304
+ let isStandard = false;
2305
+ items.forEach((item) => {
2306
+ if (item.getAttribute("data-value") === selectedValue && item.textContent.trim() !== customizationLabel) {
2307
+ isStandard = true;
1967
2308
  }
1968
- if (targetDate > toSelectedDate || targetDate > fromSelectedDate) {
1969
- const toSelectedDateLeftEl = datepickerLeftContent.querySelector(
1970
- `.ina-ss-range-datepicker__calendar-day.selected-to`
1971
- );
1972
- const toSelectedDateRightEl = datepickerRightContent.querySelector(
1973
- `.ina-ss-range-datepicker__calendar-day.selected-to`
1974
- );
1975
- toSelectedDateLeftEl?.classList.remove("selected-to");
1976
- toSelectedDateRightEl?.classList.remove("selected-to");
1977
- toSelectedDate = targetDate;
1978
- target.classList.add("selected-to");
2309
+ });
2310
+ const toggleBtn = Array.from(items).find(
2311
+ (i) => i.textContent.trim() === customizationLabel
2312
+ );
2313
+ const showInput = toggleBtn && selectedValue === toggleBtn.getAttribute("data-value") || !isStandard && selectedValue !== "";
2314
+ if (showInput) {
2315
+ if (!customFieldContainer) {
2316
+ customFieldContainer = document.createElement("div");
2317
+ customFieldContainer.className = `${PREFIX3}-chip__custom-field`;
2318
+ container.appendChild(customFieldContainer);
1979
2319
  }
1980
- const leftDays = datepickerLeftContent.querySelectorAll(
1981
- ".ina-ss-range-datepicker__calendar-day"
1982
- );
1983
- const rightDays = datepickerRightContent.querySelectorAll(
1984
- ".ina-ss-range-datepicker__calendar-day"
1985
- );
1986
- const leftDaysArray = Array.from(leftDays);
1987
- const rightDaysArray = Array.from(rightDays);
1988
- const leftFromIndex = leftDaysArray.findIndex(
1989
- (btn) => btn.classList.contains("selected-from")
1990
- );
1991
- const rightFromIndex = rightDaysArray.findIndex(
1992
- (btn) => btn.classList.contains("selected-from")
1993
- );
1994
- const leftToIndex = leftDaysArray.findIndex(
1995
- (btn) => btn.classList.contains("selected-to")
1996
- );
1997
- const rightToIndex = rightDaysArray.findIndex(
1998
- (btn) => btn.classList.contains("selected-to")
2320
+ let input = customFieldContainer.querySelector(
2321
+ `.${PREFIX3}-chip__input`
1999
2322
  );
2000
- leftDaysArray.forEach(
2001
- (btn) => btn.classList.remove("selected-range")
2002
- );
2003
- rightDaysArray.forEach(
2004
- (btn) => btn.classList.remove("selected-range")
2005
- );
2006
- if (leftFromIndex !== -1 && leftToIndex !== -1 && rightFromIndex === -1 && rightToIndex === -1) {
2007
- for (let i = leftFromIndex + 1; i <= leftToIndex - 1; i++) {
2008
- leftDaysArray[i].classList.add("selected-range");
2009
- }
2010
- }
2011
- if (leftFromIndex !== -1 && rightToIndex !== -1) {
2012
- for (let i = leftFromIndex + 1; i < leftDaysArray.length; i++) {
2013
- leftDaysArray[i].classList.add("selected-range");
2014
- }
2015
- for (let i = 0; i < rightToIndex; i++) {
2016
- rightDaysArray[i].classList.add("selected-range");
2017
- }
2018
- }
2019
- if (leftFromIndex === -1 && leftToIndex === -1 && rightFromIndex !== -1 && rightToIndex !== -1) {
2020
- for (let i = rightFromIndex + 1; i <= rightToIndex - 1; i++) {
2021
- rightDaysArray[i].classList.add("selected-range");
2323
+ if (!input) {
2324
+ customFieldContainer.innerHTML = `
2325
+ <div class="${PREFIX3}-text-field ${PREFIX3}-text-field--size-medium ${PREFIX3}-text-field--variant-outline ${PREFIX3}-chip__input">
2326
+ <div class="${PREFIX3}-text-field__wrapper">
2327
+ <input type="text" class="${PREFIX3}-text-field__input" placeholder="Masukkan data yang Anda inginkan" value="${!isStandard ? selectedValue : ""}" />
2328
+ </div>
2329
+ </div>
2330
+ `;
2331
+ input = customFieldContainer.querySelector("input");
2332
+ input.addEventListener("blur", (e) => {
2333
+ const val = e.target.value;
2334
+ if (val.trim()) {
2335
+ handleSelect(val);
2336
+ } else {
2337
+ handleSelect("");
2338
+ }
2339
+ });
2340
+ input.addEventListener("keydown", (e) => {
2341
+ if (e.key === "Enter") {
2342
+ handleSelect(e.target.value);
2343
+ e.target.blur();
2344
+ }
2345
+ });
2346
+ } else {
2347
+ const inputEl = customFieldContainer.querySelector("input");
2348
+ if (inputEl && document.activeElement !== inputEl) {
2349
+ inputEl.value = !isStandard ? selectedValue : "";
2022
2350
  }
2023
2351
  }
2024
- }
2025
- } else {
2026
- if (target.classList.contains(
2027
- `ina-ss-range-datepicker__calendar-day`
2028
- ) && !target.classList.contains("outside-month")) {
2029
- if (target.classList.contains("selected-from") && target.classList.contains("selected-to")) {
2030
- target.classList.remove("selected-from");
2031
- target.classList.remove("selected-to");
2032
- selectedDateTarget = null;
2033
- } else {
2034
- target.classList.add("selected-from");
2035
- target.classList.add("selected-to");
2036
- selectedDateTarget = target;
2352
+ customFieldContainer.style.display = "block";
2353
+ } else {
2354
+ if (customFieldContainer) {
2355
+ customFieldContainer.style.display = "none";
2037
2356
  }
2038
- fromSelectedDate = selectedDateTarget ? new Date(selectedDateTarget.dataset.date) : null;
2039
- toSelectedDate = selectedDateTarget ? new Date(selectedDateTarget.dataset.date) : null;
2040
2357
  }
2041
2358
  }
2042
- rangeDatepicker.dispatchEvent(
2043
- new CustomEvent("date:changed", {
2044
- detail: {
2045
- selectedDate: {
2046
- from: fromSelectedDate,
2047
- to: toSelectedDate
2048
- }
2049
- }
2359
+ };
2360
+ const handleSelect = (val) => {
2361
+ selectedValue = val;
2362
+ container.setAttribute("data-selected", val);
2363
+ updateUI();
2364
+ container.dispatchEvent(
2365
+ new CustomEvent("chip:select", {
2366
+ detail: { value: val },
2367
+ bubbles: true
2050
2368
  })
2051
2369
  );
2052
- }
2053
- datepickerLeftContent.addEventListener("click", (e) => {
2054
- const target = e.target;
2055
- if (!target) return;
2056
- handleChangeDate(target);
2057
- });
2058
- datepickerRightContent.addEventListener("click", (e) => {
2059
- const target = e.target;
2060
- if (!target) return;
2061
- handleChangeDate(target);
2062
- });
2063
- function togglePopover() {
2064
- if (rangeDatepickerPopover.style.display === "none" || rangeDatepickerPopover.style.display === "") {
2065
- rangeDatepickerPopover.style.display = "flex";
2066
- renderCalendar(
2067
- datePickerLeftDate,
2068
- currentDateLeft.getFullYear(),
2069
- currentDateLeft.getMonth()
2070
- );
2071
- renderCalendar(
2072
- datePickerRightDate,
2073
- currentDateRight.getFullYear(),
2074
- currentDateRight.getMonth()
2075
- );
2076
- } else {
2077
- rangeDatepickerPopover.style.display = "none";
2078
- }
2079
- }
2080
- function getMonthDifference(d1, d2) {
2081
- let months;
2082
- months = (d2.getFullYear() - d1.getFullYear()) * 12;
2083
- months -= d1.getMonth();
2084
- months += d2.getMonth();
2085
- return months;
2086
- }
2087
- rangeDatepickerTrigger.addEventListener("click", (e) => {
2088
- e.stopPropagation();
2089
- togglePopover();
2090
- });
2091
- prevMonthButtonLeft.addEventListener("click", () => {
2092
- currentDateLeft.setMonth(currentDateLeft.getMonth() - 1);
2093
- renderCalendar(
2094
- datePickerLeftDate,
2095
- currentDateLeft.getFullYear(),
2096
- currentDateLeft.getMonth()
2097
- );
2370
+ };
2371
+ items.forEach((item) => {
2372
+ item.addEventListener("click", (e) => {
2373
+ const val = item.getAttribute("data-value");
2374
+ const label = item.textContent.trim();
2375
+ if (showCustomization && label === customizationLabel) {
2376
+ handleSelect(val);
2377
+ } else {
2378
+ handleSelect(val);
2379
+ }
2380
+ });
2098
2381
  });
2099
- nextMonthButtonLeft.addEventListener("click", () => {
2100
- const monthDiff = getMonthDifference(currentDateLeft, currentDateRight);
2101
- currentDateLeft.setMonth(currentDateLeft.getMonth() + 1);
2102
- renderCalendar(
2103
- datePickerLeftDate,
2104
- currentDateLeft.getFullYear(),
2105
- currentDateLeft.getMonth()
2106
- );
2107
- if (monthDiff === 1) {
2108
- currentDateRight.setMonth(currentDateRight.getMonth() + 1);
2109
- renderCalendar(
2110
- datePickerRightDate,
2111
- currentDateRight.getFullYear(),
2112
- currentDateRight.getMonth()
2382
+ updateUI();
2383
+ container.__inaChipInitialized = true;
2384
+ });
2385
+ }
2386
+
2387
+ // src/js/components/stateful/pagination.js
2388
+ function initPagination() {
2389
+ document.querySelectorAll(`.${PREFIX}-pagination`).forEach((container) => {
2390
+ if (container.dataset.initialized === "true") return;
2391
+ container.dataset.initialized = "true";
2392
+ const navButtonsContainer = container.querySelector(
2393
+ `.${PREFIX}-pagination__nav-buttons`
2394
+ );
2395
+ const pageInfo = container.querySelector(
2396
+ `.${PREFIX}-pagination__page-info`
2397
+ );
2398
+ const firstBtn = container.querySelector('[data-action="first"]');
2399
+ const prevBtn = container.querySelector('[data-action="prev"]');
2400
+ const nextBtn = container.querySelector('[data-action="next"]');
2401
+ const lastBtn = container.querySelector('[data-action="last"]');
2402
+ const pageSizeSelect = container.querySelector('[data-role="page-size"]');
2403
+ if (!navButtonsContainer || !pageInfo) return;
2404
+ let currentPage = parseInt(container.dataset.current || "1", 10);
2405
+ let totalPages = parseInt(container.dataset.total || "10", 10);
2406
+ let pageSize = parseInt(container.dataset.pageSize || "10", 10);
2407
+ let pageButtons = [];
2408
+ const updateUI = () => {
2409
+ pageInfo.textContent = `Halaman ${currentPage} dari ${totalPages}`;
2410
+ const isFirst = currentPage === 1;
2411
+ if (firstBtn) {
2412
+ firstBtn.disabled = isFirst;
2413
+ firstBtn.classList.toggle(
2414
+ `${PREFIX}-pagination__nav-button--disabled`,
2415
+ isFirst
2416
+ );
2417
+ firstBtn.classList.toggle(
2418
+ `${PREFIX}-pagination__nav-button--enabled`,
2419
+ !isFirst
2113
2420
  );
2114
2421
  }
2115
- });
2116
- prevMonthButtonRight.addEventListener("click", () => {
2117
- const monthDiff = getMonthDifference(currentDateLeft, currentDateRight);
2118
- currentDateRight.setMonth(currentDateRight.getMonth() - 1);
2119
- renderCalendar(
2120
- datePickerRightDate,
2121
- currentDateRight.getFullYear(),
2122
- currentDateRight.getMonth()
2123
- );
2124
- if (monthDiff === 1) {
2125
- currentDateLeft.setMonth(currentDateRight.getMonth() - 1);
2126
- renderCalendar(
2127
- datePickerLeftDate,
2128
- currentDateLeft.getFullYear(),
2129
- currentDateLeft.getMonth()
2422
+ if (prevBtn) {
2423
+ prevBtn.disabled = isFirst;
2424
+ prevBtn.classList.toggle(
2425
+ `${PREFIX}-pagination__nav-button--disabled`,
2426
+ isFirst
2427
+ );
2428
+ prevBtn.classList.toggle(
2429
+ `${PREFIX}-pagination__nav-button--enabled`,
2430
+ !isFirst
2130
2431
  );
2131
2432
  }
2132
- });
2133
- nextMonthButtonRight.addEventListener("click", () => {
2134
- currentDateRight.setMonth(currentDateRight.getMonth() + 1);
2135
- renderCalendar(
2136
- datePickerRightDate,
2137
- currentDateRight.getFullYear(),
2138
- currentDateRight.getMonth()
2139
- );
2140
- });
2141
- document.addEventListener("click", (e) => {
2142
- if (!rangeDatepickerPopover.contains(e.target) && e.target !== rangeDatepickerTrigger && !rangeDatepickerTrigger.contains(e.target)) {
2143
- rangeDatepickerPopover.style.display = "none";
2433
+ const isLast = currentPage === totalPages;
2434
+ if (nextBtn) {
2435
+ nextBtn.disabled = isLast;
2436
+ nextBtn.classList.toggle(
2437
+ `${PREFIX}-pagination__nav-button--disabled`,
2438
+ isLast
2439
+ );
2440
+ nextBtn.classList.toggle(
2441
+ `${PREFIX}-pagination__nav-button--enabled`,
2442
+ !isLast
2443
+ );
2144
2444
  }
2145
- });
2445
+ if (lastBtn) {
2446
+ lastBtn.disabled = isLast;
2447
+ lastBtn.classList.toggle(
2448
+ `${PREFIX}-pagination__nav-button--disabled`,
2449
+ isLast
2450
+ );
2451
+ lastBtn.classList.toggle(
2452
+ `${PREFIX}-pagination__nav-button--enabled`,
2453
+ !isLast
2454
+ );
2455
+ }
2456
+ renderPageNumbers();
2457
+ };
2458
+ const renderPageNumbers = () => {
2459
+ let start, end;
2460
+ if (currentPage === 1) {
2461
+ start = 1;
2462
+ end = Math.min(3, totalPages);
2463
+ } else if (currentPage === totalPages) {
2464
+ start = Math.max(1, totalPages - 2);
2465
+ end = totalPages;
2466
+ } else {
2467
+ start = currentPage - 1;
2468
+ end = currentPage + 1;
2469
+ }
2470
+ if (start < 1) start = 1;
2471
+ if (end > totalPages) end = totalPages;
2472
+ pageButtons.forEach((btn) => btn.remove());
2473
+ pageButtons = [];
2474
+ const refNode = nextBtn || null;
2475
+ for (let i = start; i <= end; i++) {
2476
+ const isActive = i === currentPage;
2477
+ const button = document.createElement("button");
2478
+ button.type = "button";
2479
+ button.textContent = i;
2480
+ button.className = `${PREFIX}-pagination__page-button ${PREFIX}-pagination__page-button--${isActive ? "active" : "enabled"}`;
2481
+ button.addEventListener("click", (e) => {
2482
+ e.stopPropagation();
2483
+ if (i !== currentPage) {
2484
+ goToPage(i);
2485
+ }
2486
+ });
2487
+ navButtonsContainer.insertBefore(button, refNode);
2488
+ pageButtons.push(button);
2489
+ }
2490
+ };
2491
+ const goToPage = (page) => {
2492
+ if (page < 1) page = 1;
2493
+ if (page > totalPages) page = totalPages;
2494
+ if (page === currentPage) return;
2495
+ currentPage = page;
2496
+ container.dataset.current = currentPage;
2497
+ updateUI();
2498
+ dispatchChange();
2499
+ };
2500
+ const dispatchChange = () => {
2501
+ container.dispatchEvent(
2502
+ new CustomEvent("pagination:change", {
2503
+ bubbles: true,
2504
+ detail: {
2505
+ page: currentPage,
2506
+ pageSize,
2507
+ totalPages
2508
+ }
2509
+ })
2510
+ );
2511
+ };
2512
+ if (firstBtn)
2513
+ firstBtn.addEventListener("click", () => {
2514
+ if (currentPage > 1) goToPage(1);
2515
+ });
2516
+ if (prevBtn)
2517
+ prevBtn.addEventListener("click", () => {
2518
+ if (currentPage > 1) goToPage(currentPage - 1);
2519
+ });
2520
+ if (nextBtn)
2521
+ nextBtn.addEventListener("click", () => {
2522
+ if (currentPage < totalPages) goToPage(currentPage + 1);
2523
+ });
2524
+ if (lastBtn)
2525
+ lastBtn.addEventListener("click", () => {
2526
+ if (currentPage < totalPages) goToPage(totalPages);
2527
+ });
2528
+ if (pageSizeSelect) {
2529
+ pageSizeSelect.addEventListener("change", (e) => {
2530
+ pageSize = parseInt(e.target.value, 10);
2531
+ currentPage = 1;
2532
+ container.dataset.pageSize = pageSize;
2533
+ container.dataset.current = currentPage;
2534
+ updateUI();
2535
+ dispatchChange();
2536
+ });
2537
+ }
2538
+ updateUI();
2146
2539
  });
2147
2540
  }
2148
2541
 
@@ -2215,6 +2608,196 @@ var InaUI = (() => {
2215
2608
  }
2216
2609
  }
2217
2610
 
2611
+ // src/js/index.js
2612
+ var PREFIX = "ina";
2613
+
2614
+ // src/js/components/stateful/button-group.js
2615
+ function initButtonGroup(rootSelector = `.${PREFIX}-button-group`) {
2616
+ const buttonGroups = document.querySelectorAll(rootSelector);
2617
+ buttonGroups.forEach((buttonGroup) => {
2618
+ if (buttonGroup.__inaButtonGroupInitialized) return;
2619
+ const buttons = buttonGroup.querySelectorAll(
2620
+ `.${PREFIX}-button-group__button`
2621
+ );
2622
+ const updateState = (clickedButton) => {
2623
+ const isDisabled = clickedButton.hasAttribute("disabled") || clickedButton.classList.contains(
2624
+ `${PREFIX}-button-group__button--disabled`
2625
+ );
2626
+ if (isDisabled) return;
2627
+ const value = clickedButton.getAttribute("data-value");
2628
+ buttons.forEach((btn) => {
2629
+ if (btn === clickedButton) {
2630
+ btn.classList.add(`${PREFIX}-button-group__button--selected`);
2631
+ btn.setAttribute("aria-pressed", "true");
2632
+ } else {
2633
+ btn.classList.remove(`${PREFIX}-button-group__button--selected`);
2634
+ btn.setAttribute("aria-pressed", "false");
2635
+ }
2636
+ });
2637
+ buttonGroup.dispatchEvent(
2638
+ new CustomEvent("button-group:change", {
2639
+ detail: { value },
2640
+ bubbles: true,
2641
+ composed: true
2642
+ })
2643
+ );
2644
+ };
2645
+ buttons.forEach((button) => {
2646
+ button.addEventListener("click", (e) => {
2647
+ if (button.type !== "submit") {
2648
+ e.preventDefault();
2649
+ }
2650
+ updateState(button);
2651
+ });
2652
+ });
2653
+ buttonGroup.__inaButtonGroupInitialized = true;
2654
+ });
2655
+ }
2656
+
2657
+ // src/js/components/stateful/dropdown.js
2658
+ function initDropdown(rootSelector = `.${PREFIX}-dropdown`) {
2659
+ document.querySelectorAll(rootSelector).forEach((dropdown) => {
2660
+ const trigger = dropdown.querySelector(`.${PREFIX}-dropdown__trigger`);
2661
+ const input = dropdown.querySelector(`.${PREFIX}-dropdown__input`);
2662
+ const menu = dropdown.querySelector(`.${PREFIX}-dropdown__menu`);
2663
+ const menuItems = menu.querySelectorAll("li[role='option']");
2664
+ const menuId = menu.id;
2665
+ let activeIndex = -1;
2666
+ menuItems.forEach((item, index) => {
2667
+ item.id = `${menuId}-item-${index}`;
2668
+ });
2669
+ const toggleMenu = (show) => {
2670
+ const isCurrentlyShown = dropdown.classList.contains("show");
2671
+ const isShown = show !== void 0 ? show : !isCurrentlyShown;
2672
+ if (isShown === isCurrentlyShown) {
2673
+ return;
2674
+ }
2675
+ dropdown.classList.toggle("show", isShown);
2676
+ trigger.setAttribute("aria-expanded", isShown);
2677
+ if (isShown) {
2678
+ input.focus();
2679
+ } else {
2680
+ input.blur();
2681
+ removeHighlight();
2682
+ activeIndex = -1;
2683
+ input.removeAttribute("aria-activedescendant");
2684
+ }
2685
+ };
2686
+ const filterItems = () => {
2687
+ const filterValue = input.value.toLowerCase();
2688
+ let hasVisibleItems = false;
2689
+ activeIndex = -1;
2690
+ removeHighlight();
2691
+ input.removeAttribute("aria-activedescendant");
2692
+ const activeItem = menu.querySelector("li[role='option'].selected");
2693
+ if (activeItem && input.value !== activeItem.textContent.trim()) {
2694
+ activeItem.classList.remove("selected");
2695
+ }
2696
+ menuItems.forEach((item) => {
2697
+ const itemText = item.textContent.toLowerCase();
2698
+ const isMatch = itemText.includes(filterValue);
2699
+ item.classList.toggle("hidden", !isMatch);
2700
+ if (isMatch) hasVisibleItems = true;
2701
+ });
2702
+ if (!dropdown.classList.contains("show") && hasVisibleItems) {
2703
+ toggleMenu(true);
2704
+ }
2705
+ };
2706
+ const selectItem = (item) => {
2707
+ const itemText = item.textContent.trim();
2708
+ input.value = itemText;
2709
+ menuItems.forEach((li) => {
2710
+ li.classList.remove("selected");
2711
+ });
2712
+ if (item) {
2713
+ item.classList.add("selected");
2714
+ dropdown.dispatchEvent(
2715
+ new CustomEvent("dropdown:changed", {
2716
+ detail: { value: itemText }
2717
+ })
2718
+ );
2719
+ }
2720
+ toggleMenu(false);
2721
+ };
2722
+ const setHighlight = (index) => {
2723
+ removeHighlight();
2724
+ const visibleItems = menu.querySelectorAll(
2725
+ "li[role='option']:not(.hidden)"
2726
+ );
2727
+ if (visibleItems.length === 0) return;
2728
+ if (index < 0) index = 0;
2729
+ else if (index >= visibleItems.length) index = visibleItems.length - 1;
2730
+ const itemToHighlight = visibleItems[index];
2731
+ if (itemToHighlight) {
2732
+ itemToHighlight.classList.add("highlighted");
2733
+ input.setAttribute("aria-activedescendant", itemToHighlight.id);
2734
+ itemToHighlight.scrollIntoView({
2735
+ behavior: "smooth",
2736
+ block: "nearest"
2737
+ });
2738
+ activeIndex = index;
2739
+ }
2740
+ };
2741
+ const removeHighlight = () => {
2742
+ menuItems.forEach((item) => item.classList.remove("highlighted"));
2743
+ };
2744
+ trigger.addEventListener("click", () => {
2745
+ toggleMenu();
2746
+ });
2747
+ input.addEventListener("input", filterItems);
2748
+ menu.addEventListener("click", (e) => {
2749
+ const option = e.target.closest("li[role='option']");
2750
+ if (option) {
2751
+ e.preventDefault();
2752
+ selectItem(option);
2753
+ }
2754
+ });
2755
+ document.addEventListener("click", (e) => {
2756
+ if (!dropdown.contains(e.target)) {
2757
+ toggleMenu(false);
2758
+ }
2759
+ });
2760
+ input.addEventListener("keydown", (e) => {
2761
+ const { key } = e;
2762
+ const isMenuOpen = dropdown.classList.contains("show");
2763
+ switch (key) {
2764
+ case "ArrowDown":
2765
+ e.preventDefault();
2766
+ if (!isMenuOpen) {
2767
+ toggleMenu(true);
2768
+ }
2769
+ setHighlight(activeIndex + 1);
2770
+ break;
2771
+ case "ArrowUp":
2772
+ e.preventDefault();
2773
+ if (isMenuOpen) {
2774
+ setHighlight(activeIndex - 1);
2775
+ }
2776
+ break;
2777
+ case "Enter":
2778
+ e.preventDefault();
2779
+ const firstVisible = menu.querySelector(
2780
+ "li[role='option']:not(.hidden)"
2781
+ );
2782
+ const activeItem = menu.querySelector(".highlighted");
2783
+ if (isMenuOpen && activeItem) {
2784
+ selectItem(activeItem);
2785
+ } else if (isMenuOpen && firstVisible) {
2786
+ toggleMenu(false);
2787
+ }
2788
+ break;
2789
+ case "Escape":
2790
+ e.preventDefault();
2791
+ toggleMenu(false);
2792
+ break;
2793
+ case "Tab":
2794
+ toggleMenu(false);
2795
+ break;
2796
+ }
2797
+ });
2798
+ });
2799
+ }
2800
+
2218
2801
  // src/js/bundle.js
2219
2802
  if (typeof window !== void 0) {
2220
2803
  document.addEventListener("DOMContentLoaded", () => {
@@ -2230,9 +2813,14 @@ var InaUI = (() => {
2230
2813
  initImgCompare();
2231
2814
  initModal();
2232
2815
  initRangeDatepicker();
2816
+ initRadioButton();
2817
+ initStepper();
2233
2818
  initTab();
2234
2819
  initTimepicker();
2235
2820
  initToggle();
2821
+ initPagination();
2822
+ initSelectDropdown();
2823
+ initChip();
2236
2824
  });
2237
2825
  }
2238
2826
  return __toCommonJS(bundle_exports);