@idds/js 1.0.96 → 1.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.iife.js +171 -71
- package/dist/index.js +164 -64
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -101,18 +101,18 @@ var InaUI = (() => {
|
|
|
101
101
|
const tabItem = tab.querySelectorAll(`.${PREFIX}-tab-item`);
|
|
102
102
|
tabItem.forEach((tabButton) => {
|
|
103
103
|
function updateState() {
|
|
104
|
-
const
|
|
104
|
+
const index2 = Array.from(tabItem).indexOf(tabButton);
|
|
105
105
|
tabItem.forEach((tabButton2, i) => {
|
|
106
106
|
tabButton2.classList.remove("active");
|
|
107
107
|
tabButton2.setAttribute("aria-selected", "false");
|
|
108
|
-
if (i ===
|
|
108
|
+
if (i === index2) {
|
|
109
109
|
tabButton2.classList.add("active");
|
|
110
110
|
tabButton2.setAttribute("aria-selected", "true");
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
tab.dispatchEvent(
|
|
114
114
|
new CustomEvent("tab:change", {
|
|
115
|
-
detail: { activeIndex:
|
|
115
|
+
detail: { activeIndex: index2 },
|
|
116
116
|
bubbles: true,
|
|
117
117
|
composed: true
|
|
118
118
|
})
|
|
@@ -207,28 +207,28 @@ var InaUI = (() => {
|
|
|
207
207
|
this.element.__inaAccordionGroup = this;
|
|
208
208
|
}
|
|
209
209
|
registerItem(item) {
|
|
210
|
-
const
|
|
211
|
-
this.items.set(item.id,
|
|
210
|
+
const index2 = this.items.size;
|
|
211
|
+
this.items.set(item.id, index2);
|
|
212
212
|
this.itemsArray.push(item);
|
|
213
213
|
if (item.defaultOpen) {
|
|
214
214
|
if (this.isMultiple) {
|
|
215
|
-
if (!this.openIndexes.includes(
|
|
216
|
-
this.openIndexes.push(
|
|
215
|
+
if (!this.openIndexes.includes(index2)) {
|
|
216
|
+
this.openIndexes.push(index2);
|
|
217
217
|
}
|
|
218
218
|
} else {
|
|
219
219
|
if (this.openIndexes.length === 0) {
|
|
220
|
-
this.openIndexes.push(
|
|
220
|
+
this.openIndexes.push(index2);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
return
|
|
224
|
+
return index2;
|
|
225
225
|
}
|
|
226
226
|
unregisterItem(item) {
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
227
|
+
const index2 = this.items.get(item.id);
|
|
228
|
+
if (index2 !== void 0) {
|
|
229
229
|
this.items.delete(item.id);
|
|
230
230
|
this.itemsArray = this.itemsArray.filter((i) => i !== item);
|
|
231
|
-
this.openIndexes = this.openIndexes.filter((idx) => idx !==
|
|
231
|
+
this.openIndexes = this.openIndexes.filter((idx) => idx !== index2).map((idx) => idx > index2 ? idx - 1 : idx);
|
|
232
232
|
const newMap = /* @__PURE__ */ new Map();
|
|
233
233
|
this.itemsArray.forEach((itm, newIdx) => {
|
|
234
234
|
newMap.set(itm.id, newIdx);
|
|
@@ -236,22 +236,22 @@ var InaUI = (() => {
|
|
|
236
236
|
this.items = newMap;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
handleItemToggle(
|
|
239
|
+
handleItemToggle(index2, isOpen) {
|
|
240
240
|
const prevIndexes = [...this.openIndexes];
|
|
241
241
|
let nextIndexes = [];
|
|
242
242
|
if (this.isMultiple) {
|
|
243
243
|
if (isOpen) {
|
|
244
|
-
if (!prevIndexes.includes(
|
|
245
|
-
nextIndexes = [...prevIndexes,
|
|
244
|
+
if (!prevIndexes.includes(index2)) {
|
|
245
|
+
nextIndexes = [...prevIndexes, index2];
|
|
246
246
|
} else {
|
|
247
247
|
nextIndexes = prevIndexes;
|
|
248
248
|
}
|
|
249
249
|
} else {
|
|
250
|
-
nextIndexes = prevIndexes.filter((idx) => idx !==
|
|
250
|
+
nextIndexes = prevIndexes.filter((idx) => idx !== index2);
|
|
251
251
|
}
|
|
252
252
|
} else {
|
|
253
253
|
if (isOpen) {
|
|
254
|
-
nextIndexes = [
|
|
254
|
+
nextIndexes = [index2];
|
|
255
255
|
} else {
|
|
256
256
|
nextIndexes = [];
|
|
257
257
|
}
|
|
@@ -259,16 +259,16 @@ var InaUI = (() => {
|
|
|
259
259
|
this.openIndexes = nextIndexes;
|
|
260
260
|
this.notifyItems();
|
|
261
261
|
}
|
|
262
|
-
isItemOpen(
|
|
263
|
-
return this.openIndexes.includes(
|
|
262
|
+
isItemOpen(index2) {
|
|
263
|
+
return this.openIndexes.includes(index2);
|
|
264
264
|
}
|
|
265
265
|
getItemIndex(itemId) {
|
|
266
266
|
return this.items.get(itemId);
|
|
267
267
|
}
|
|
268
268
|
// Notify all children to update their visual state based on new openIndexes
|
|
269
269
|
notifyItems() {
|
|
270
|
-
this.itemsArray.forEach((item,
|
|
271
|
-
const isOpen = this.openIndexes.includes(
|
|
270
|
+
this.itemsArray.forEach((item, index2) => {
|
|
271
|
+
const isOpen = this.openIndexes.includes(index2);
|
|
272
272
|
item.setOpenState(isOpen);
|
|
273
273
|
});
|
|
274
274
|
}
|
|
@@ -360,7 +360,7 @@ var InaUI = (() => {
|
|
|
360
360
|
|
|
361
361
|
// src/js/components/stateful/date-picker.js
|
|
362
362
|
var DatePicker = class {
|
|
363
|
-
constructor(selectorOrElement,
|
|
363
|
+
constructor(selectorOrElement, options2 = {}) {
|
|
364
364
|
this.container = typeof selectorOrElement === "string" ? document.querySelector(selectorOrElement) : selectorOrElement;
|
|
365
365
|
if (!this.container) {
|
|
366
366
|
console.warn("[IDDS DatePicker] Container not found:", selectorOrElement);
|
|
@@ -386,7 +386,7 @@ var InaUI = (() => {
|
|
|
386
386
|
onChange: null,
|
|
387
387
|
triggerWidth: "",
|
|
388
388
|
panelMaxHeight: "",
|
|
389
|
-
...
|
|
389
|
+
...options2
|
|
390
390
|
};
|
|
391
391
|
this.state = {
|
|
392
392
|
viewDate: /* @__PURE__ */ new Date(),
|
|
@@ -726,6 +726,14 @@ var InaUI = (() => {
|
|
|
726
726
|
this.state.viewDate.setMonth(this.state.viewDate.getMonth() - 1);
|
|
727
727
|
this.renderPanel();
|
|
728
728
|
};
|
|
729
|
+
prevBtn.onkeydown = (e) => {
|
|
730
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
731
|
+
e.preventDefault();
|
|
732
|
+
e.stopPropagation();
|
|
733
|
+
this.state.viewDate.setMonth(this.state.viewDate.getMonth() - 1);
|
|
734
|
+
this.renderPanel();
|
|
735
|
+
}
|
|
736
|
+
};
|
|
729
737
|
header.appendChild(prevBtn);
|
|
730
738
|
} else {
|
|
731
739
|
const spacer = document.createElement("div");
|
|
@@ -772,6 +780,14 @@ var InaUI = (() => {
|
|
|
772
780
|
this.state.viewDate.setMonth(this.state.viewDate.getMonth() + 1);
|
|
773
781
|
this.renderPanel();
|
|
774
782
|
};
|
|
783
|
+
nextBtn.onkeydown = (e) => {
|
|
784
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
785
|
+
e.preventDefault();
|
|
786
|
+
e.stopPropagation();
|
|
787
|
+
this.state.viewDate.setMonth(this.state.viewDate.getMonth() + 1);
|
|
788
|
+
this.renderPanel();
|
|
789
|
+
}
|
|
790
|
+
};
|
|
775
791
|
header.appendChild(nextBtn);
|
|
776
792
|
} else if (!isNextMonth) {
|
|
777
793
|
const spacer = document.createElement("div");
|
|
@@ -803,6 +819,8 @@ var InaUI = (() => {
|
|
|
803
819
|
btn.type = "button";
|
|
804
820
|
btn.className = `${PREFIX}-date-picker__day`;
|
|
805
821
|
btn.textContent = i;
|
|
822
|
+
btn.setAttribute("role", "gridcell");
|
|
823
|
+
btn.tabIndex = -1;
|
|
806
824
|
const disabled = this.isDateDisabled(date);
|
|
807
825
|
if (disabled) {
|
|
808
826
|
btn.classList.add(`${PREFIX}-date-picker__day--disabled`);
|
|
@@ -826,6 +844,7 @@ var InaUI = (() => {
|
|
|
826
844
|
isSelected = true;
|
|
827
845
|
if (start && end && date > start && date < end) isInRange = true;
|
|
828
846
|
}
|
|
847
|
+
btn.setAttribute("aria-selected", isSelected.toString());
|
|
829
848
|
if (isSelected) btn.classList.add(`${PREFIX}-date-picker__day--selected`);
|
|
830
849
|
if (isInRange) btn.classList.add(`${PREFIX}-date-picker__day--in-range`);
|
|
831
850
|
if (date.toDateString() === today.toDateString())
|
|
@@ -837,6 +856,24 @@ var InaUI = (() => {
|
|
|
837
856
|
e.stopPropagation();
|
|
838
857
|
this.handleDateSelect(date);
|
|
839
858
|
};
|
|
859
|
+
btn.onkeydown = (e) => {
|
|
860
|
+
if (disabled || this.options.readonly) return;
|
|
861
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
862
|
+
e.preventDefault();
|
|
863
|
+
this.handleDateSelect(date);
|
|
864
|
+
} else if (["ArrowRight", "ArrowLeft", "ArrowDown", "ArrowUp"].includes(e.key)) {
|
|
865
|
+
e.preventDefault();
|
|
866
|
+
const buttons = Array.from(grid.querySelectorAll("button"));
|
|
867
|
+
const currentIndex = buttons.indexOf(btn);
|
|
868
|
+
let nextIndex = currentIndex;
|
|
869
|
+
if (e.key === "ArrowRight") nextIndex += 1;
|
|
870
|
+
else if (e.key === "ArrowLeft") nextIndex -= 1;
|
|
871
|
+
else if (e.key === "ArrowDown") nextIndex += 7;
|
|
872
|
+
else if (e.key === "ArrowUp") nextIndex -= 7;
|
|
873
|
+
const targetBtn = buttons[nextIndex];
|
|
874
|
+
if (targetBtn) targetBtn.focus();
|
|
875
|
+
}
|
|
876
|
+
};
|
|
840
877
|
}
|
|
841
878
|
grid.appendChild(btn);
|
|
842
879
|
}
|
|
@@ -849,6 +886,19 @@ var InaUI = (() => {
|
|
|
849
886
|
btn.textContent = i;
|
|
850
887
|
grid.appendChild(btn);
|
|
851
888
|
}
|
|
889
|
+
setTimeout(() => {
|
|
890
|
+
const allButtons = Array.from(
|
|
891
|
+
grid.querySelectorAll("button:not(.ina-date-picker__day--other-month)")
|
|
892
|
+
);
|
|
893
|
+
const selectedBtn = allButtons.find(
|
|
894
|
+
(b) => b.classList.contains(`${PREFIX}-date-picker__day--selected`)
|
|
895
|
+
);
|
|
896
|
+
const todayBtn = allButtons.find(
|
|
897
|
+
(b) => b.classList.contains(`${PREFIX}-date-picker__day--today`) && !b.disabled
|
|
898
|
+
);
|
|
899
|
+
const focusableBtn = selectedBtn || todayBtn || allButtons.find((b) => !b.disabled);
|
|
900
|
+
if (focusableBtn) focusableBtn.tabIndex = 0;
|
|
901
|
+
}, 0);
|
|
852
902
|
container.append(header, grid);
|
|
853
903
|
return container;
|
|
854
904
|
}
|
|
@@ -950,11 +1000,11 @@ var InaUI = (() => {
|
|
|
950
1000
|
return this.state.rangeDate;
|
|
951
1001
|
}
|
|
952
1002
|
};
|
|
953
|
-
function initDatepicker(selectorOrElement,
|
|
1003
|
+
function initDatepicker(selectorOrElement, options2 = {}) {
|
|
954
1004
|
const elements = typeof selectorOrElement === "string" ? document.querySelectorAll(selectorOrElement) : selectorOrElement ? typeof selectorOrElement.length !== "undefined" ? selectorOrElement : [selectorOrElement] : document.querySelectorAll(`.${PREFIX}-date-picker`);
|
|
955
1005
|
const instances = [];
|
|
956
1006
|
elements.forEach((container) => {
|
|
957
|
-
const instance = new DatePicker(container,
|
|
1007
|
+
const instance = new DatePicker(container, options2);
|
|
958
1008
|
container.__datepickerAPI = instance;
|
|
959
1009
|
instances.push(instance);
|
|
960
1010
|
});
|
|
@@ -964,7 +1014,7 @@ var InaUI = (() => {
|
|
|
964
1014
|
|
|
965
1015
|
// src/js/components/stateful/time-picker.js
|
|
966
1016
|
var TimePicker = class {
|
|
967
|
-
constructor(selectorOrElement,
|
|
1017
|
+
constructor(selectorOrElement, options2 = {}) {
|
|
968
1018
|
this.container = typeof selectorOrElement === "string" ? document.querySelector(selectorOrElement) : selectorOrElement;
|
|
969
1019
|
if (!this.container) {
|
|
970
1020
|
console.warn("[IDDS TimePicker] Container not found:", selectorOrElement);
|
|
@@ -997,7 +1047,7 @@ var InaUI = (() => {
|
|
|
997
1047
|
secondStep: 1,
|
|
998
1048
|
onChange: null,
|
|
999
1049
|
size: this.container.dataset.size || "md",
|
|
1000
|
-
...
|
|
1050
|
+
...options2
|
|
1001
1051
|
};
|
|
1002
1052
|
this.state = {
|
|
1003
1053
|
isOpen: false,
|
|
@@ -1214,24 +1264,24 @@ var InaUI = (() => {
|
|
|
1214
1264
|
}
|
|
1215
1265
|
}
|
|
1216
1266
|
generateOptions(type) {
|
|
1217
|
-
const
|
|
1267
|
+
const options2 = [];
|
|
1218
1268
|
const { use12Hours, hourStep, minuteStep, secondStep } = this.options;
|
|
1219
1269
|
let limit = type === "hour" ? use12Hours ? 12 : 24 : 60;
|
|
1220
1270
|
let step = type === "hour" ? hourStep : type === "minute" ? minuteStep : secondStep;
|
|
1221
1271
|
if (limit === 12) {
|
|
1222
1272
|
for (let i = type === "hour" ? 1 : 0; i <= (type === "hour" ? 12 : 59); i += step) {
|
|
1223
|
-
|
|
1273
|
+
options2.push(i);
|
|
1224
1274
|
}
|
|
1225
1275
|
} else if (limit === 24) {
|
|
1226
1276
|
for (let i = 0; i <= 23; i += step) {
|
|
1227
|
-
|
|
1277
|
+
options2.push(i);
|
|
1228
1278
|
}
|
|
1229
1279
|
} else {
|
|
1230
1280
|
for (let i = 0; i <= 59; i += step) {
|
|
1231
|
-
|
|
1281
|
+
options2.push(i);
|
|
1232
1282
|
}
|
|
1233
1283
|
}
|
|
1234
|
-
return
|
|
1284
|
+
return options2;
|
|
1235
1285
|
}
|
|
1236
1286
|
renderColumn(type, optionsArr) {
|
|
1237
1287
|
const column = document.createElement("div");
|
|
@@ -1285,10 +1335,23 @@ var InaUI = (() => {
|
|
|
1285
1335
|
option.classList.add(`${PREFIX}-time-picker__option--selected`);
|
|
1286
1336
|
if (isDisabled)
|
|
1287
1337
|
option.classList.add(`${PREFIX}-time-picker__option--disabled`);
|
|
1338
|
+
option.setAttribute("role", "option");
|
|
1339
|
+
option.setAttribute("aria-selected", isSelected.toString());
|
|
1340
|
+
const isFirstFocusable = index === 0 && !options.some((opt) => {
|
|
1341
|
+
if (type === "hour") {
|
|
1342
|
+
return use12Hours ? (currentTime.hours === 0 ? 12 : currentTime.hours) === opt : currentTime.hours === opt;
|
|
1343
|
+
} else if (type === "minute") {
|
|
1344
|
+
return currentTime.minutes === opt;
|
|
1345
|
+
} else if (type === "second") {
|
|
1346
|
+
return currentTime.seconds === opt;
|
|
1347
|
+
}
|
|
1348
|
+
return false;
|
|
1349
|
+
});
|
|
1350
|
+
option.tabIndex = isSelected || isFirstFocusable ? 0 : -1;
|
|
1288
1351
|
option.textContent = optValue.toString().padStart(2, "0");
|
|
1289
1352
|
if (!isDisabled) {
|
|
1290
|
-
|
|
1291
|
-
e
|
|
1353
|
+
const handleSelection = (e) => {
|
|
1354
|
+
e?.stopPropagation();
|
|
1292
1355
|
const val = parseInt(optValue, 10);
|
|
1293
1356
|
if (type === "hour") {
|
|
1294
1357
|
this.state.currentTime.hours = use12Hours && val === 12 ? 0 : val;
|
|
@@ -1299,6 +1362,21 @@ var InaUI = (() => {
|
|
|
1299
1362
|
}
|
|
1300
1363
|
this.updateInput();
|
|
1301
1364
|
this.buildPanel();
|
|
1365
|
+
};
|
|
1366
|
+
option.addEventListener("click", handleSelection);
|
|
1367
|
+
option.addEventListener("keydown", (e) => {
|
|
1368
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1369
|
+
e.preventDefault();
|
|
1370
|
+
handleSelection();
|
|
1371
|
+
} else if (e.key === "ArrowDown") {
|
|
1372
|
+
e.preventDefault();
|
|
1373
|
+
const nextElement = e.currentTarget.nextElementSibling;
|
|
1374
|
+
if (nextElement) nextElement.focus();
|
|
1375
|
+
} else if (e.key === "ArrowUp") {
|
|
1376
|
+
e.preventDefault();
|
|
1377
|
+
const prevElement = e.currentTarget.previousElementSibling;
|
|
1378
|
+
if (prevElement) prevElement.focus();
|
|
1379
|
+
}
|
|
1302
1380
|
});
|
|
1303
1381
|
}
|
|
1304
1382
|
colContent.appendChild(option);
|
|
@@ -1326,12 +1404,34 @@ var InaUI = (() => {
|
|
|
1326
1404
|
);
|
|
1327
1405
|
if (isDisabled)
|
|
1328
1406
|
option.classList.add(`${PREFIX}-time-picker__option--disabled`);
|
|
1407
|
+
option.setAttribute("role", "option");
|
|
1408
|
+
option.setAttribute(
|
|
1409
|
+
"aria-selected",
|
|
1410
|
+
(this.state.currentTime.period === p).toString()
|
|
1411
|
+
);
|
|
1412
|
+
const isFirstFocusable = p === "AM" && this.state.currentTime.period !== "AM" && this.state.currentTime.period !== "PM";
|
|
1413
|
+
option.tabIndex = this.state.currentTime.period === p || isFirstFocusable ? 0 : -1;
|
|
1329
1414
|
if (!isDisabled) {
|
|
1330
|
-
|
|
1331
|
-
e
|
|
1415
|
+
const handleSelection = (e) => {
|
|
1416
|
+
e?.stopPropagation();
|
|
1332
1417
|
this.state.currentTime.period = p;
|
|
1333
1418
|
this.updateInput();
|
|
1334
1419
|
this.buildPanel();
|
|
1420
|
+
};
|
|
1421
|
+
option.addEventListener("click", handleSelection);
|
|
1422
|
+
option.addEventListener("keydown", (e) => {
|
|
1423
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1424
|
+
e.preventDefault();
|
|
1425
|
+
handleSelection();
|
|
1426
|
+
} else if (e.key === "ArrowDown") {
|
|
1427
|
+
e.preventDefault();
|
|
1428
|
+
const nextElement = e.currentTarget.nextElementSibling;
|
|
1429
|
+
if (nextElement) nextElement.focus();
|
|
1430
|
+
} else if (e.key === "ArrowUp") {
|
|
1431
|
+
e.preventDefault();
|
|
1432
|
+
const prevElement = e.currentTarget.previousElementSibling;
|
|
1433
|
+
if (prevElement) prevElement.focus();
|
|
1434
|
+
}
|
|
1335
1435
|
});
|
|
1336
1436
|
}
|
|
1337
1437
|
colContent.appendChild(option);
|
|
@@ -1412,11 +1512,11 @@ var InaUI = (() => {
|
|
|
1412
1512
|
return this.state.internalValue;
|
|
1413
1513
|
}
|
|
1414
1514
|
};
|
|
1415
|
-
function initTimepicker(selectorOrElement,
|
|
1515
|
+
function initTimepicker(selectorOrElement, options2 = {}) {
|
|
1416
1516
|
const elements = typeof selectorOrElement === "string" ? document.querySelectorAll(selectorOrElement) : selectorOrElement ? typeof selectorOrElement.length !== "undefined" ? selectorOrElement : [selectorOrElement] : document.querySelectorAll(`.${PREFIX}-time-picker`);
|
|
1417
1517
|
const instances = [];
|
|
1418
1518
|
elements.forEach((container) => {
|
|
1419
|
-
const instance = new TimePicker(container,
|
|
1519
|
+
const instance = new TimePicker(container, options2);
|
|
1420
1520
|
container.__timepickerAPI = instance;
|
|
1421
1521
|
instances.push(instance);
|
|
1422
1522
|
});
|
|
@@ -1658,9 +1758,9 @@ var InaUI = (() => {
|
|
|
1658
1758
|
`.${PREFIX3}-select-dropdown__trigger-text`
|
|
1659
1759
|
);
|
|
1660
1760
|
const placeholder = input ? input.getAttribute("placeholder") : textSpan ? textSpan.getAttribute("data-placeholder") : "Select...";
|
|
1661
|
-
const
|
|
1761
|
+
const options2 = root.querySelectorAll(`.${PREFIX3}-select-dropdown__option`);
|
|
1662
1762
|
const getLabel = (val) => {
|
|
1663
|
-
const opt = Array.from(
|
|
1763
|
+
const opt = Array.from(options2).find(
|
|
1664
1764
|
(o) => o.getAttribute("data-value") === val
|
|
1665
1765
|
);
|
|
1666
1766
|
return opt ? opt.textContent.trim() : val;
|
|
@@ -1686,7 +1786,7 @@ var InaUI = (() => {
|
|
|
1686
1786
|
values.length === 0
|
|
1687
1787
|
);
|
|
1688
1788
|
}
|
|
1689
|
-
|
|
1789
|
+
options2.forEach((opt) => {
|
|
1690
1790
|
const val = opt.getAttribute("data-value");
|
|
1691
1791
|
const isSelected = values.includes(val);
|
|
1692
1792
|
if (isMultiple) {
|
|
@@ -1766,13 +1866,13 @@ var InaUI = (() => {
|
|
|
1766
1866
|
const root = e.target.closest(`.${PREFIX3}-select-dropdown`);
|
|
1767
1867
|
if (root) {
|
|
1768
1868
|
const term = e.target.value.toLowerCase();
|
|
1769
|
-
const
|
|
1869
|
+
const options2 = root.querySelectorAll(
|
|
1770
1870
|
`.${PREFIX3}-select-dropdown__option`
|
|
1771
1871
|
);
|
|
1772
1872
|
if (root.getAttribute("data-state") !== "open") {
|
|
1773
1873
|
setDropdownState(root, { isOpen: true });
|
|
1774
1874
|
}
|
|
1775
|
-
|
|
1875
|
+
options2.forEach((opt) => {
|
|
1776
1876
|
const text = opt.textContent.trim().toLowerCase();
|
|
1777
1877
|
opt.style.display = text.includes(term) ? "" : "none";
|
|
1778
1878
|
});
|
|
@@ -1846,20 +1946,20 @@ var InaUI = (() => {
|
|
|
1846
1946
|
`;
|
|
1847
1947
|
const updateUI = () => {
|
|
1848
1948
|
stepper.dataset.currentStep = currentStep;
|
|
1849
|
-
items.forEach((item,
|
|
1949
|
+
items.forEach((item, index2) => {
|
|
1850
1950
|
const iconWrapper = item.querySelector(
|
|
1851
1951
|
`.${PREFIX}-stepper__icon-wrapper`
|
|
1852
1952
|
);
|
|
1853
|
-
const itemNumber =
|
|
1953
|
+
const itemNumber = index2 + 1;
|
|
1854
1954
|
item.classList.remove(
|
|
1855
1955
|
`${PREFIX}-stepper__item--completed`,
|
|
1856
1956
|
`${PREFIX}-stepper__item--active`
|
|
1857
1957
|
);
|
|
1858
1958
|
if (iconWrapper) iconWrapper.innerHTML = "";
|
|
1859
|
-
if (
|
|
1959
|
+
if (index2 < currentStep) {
|
|
1860
1960
|
item.classList.add(`${PREFIX}-stepper__item--completed`);
|
|
1861
1961
|
if (iconWrapper) iconWrapper.innerHTML = checkIcon;
|
|
1862
|
-
} else if (
|
|
1962
|
+
} else if (index2 === currentStep) {
|
|
1863
1963
|
item.classList.add(`${PREFIX}-stepper__item--active`);
|
|
1864
1964
|
if (iconWrapper)
|
|
1865
1965
|
iconWrapper.innerHTML = `<span class="${PREFIX}-stepper__step-number">${itemNumber}</span>`;
|
|
@@ -1868,8 +1968,8 @@ var InaUI = (() => {
|
|
|
1868
1968
|
iconWrapper.innerHTML = `<span class="${PREFIX}-stepper__step-number">${itemNumber}</span>`;
|
|
1869
1969
|
}
|
|
1870
1970
|
});
|
|
1871
|
-
separators.forEach((separator,
|
|
1872
|
-
if (
|
|
1971
|
+
separators.forEach((separator, index2) => {
|
|
1972
|
+
if (index2 < currentStep) {
|
|
1873
1973
|
separator.classList.add(`${PREFIX}-stepper__separator--completed`);
|
|
1874
1974
|
} else {
|
|
1875
1975
|
separator.classList.remove(`${PREFIX}-stepper__separator--completed`);
|
|
@@ -1915,11 +2015,11 @@ var InaUI = (() => {
|
|
|
1915
2015
|
}
|
|
1916
2016
|
});
|
|
1917
2017
|
});
|
|
1918
|
-
items.forEach((item,
|
|
2018
|
+
items.forEach((item, index2) => {
|
|
1919
2019
|
if (item.classList.contains(`${PREFIX}-stepper__item--clickable`) || item.hasAttribute("data-clickable")) {
|
|
1920
2020
|
item.addEventListener("click", () => {
|
|
1921
2021
|
if (!item.classList.contains(`${PREFIX}-stepper__item--disabled`)) {
|
|
1922
|
-
currentStep =
|
|
2022
|
+
currentStep = index2;
|
|
1923
2023
|
updateUI();
|
|
1924
2024
|
}
|
|
1925
2025
|
});
|
|
@@ -1993,7 +2093,7 @@ var InaUI = (() => {
|
|
|
1993
2093
|
} else {
|
|
1994
2094
|
filesContainer.style.display = "none";
|
|
1995
2095
|
}
|
|
1996
|
-
uploadedFiles.forEach((f,
|
|
2096
|
+
uploadedFiles.forEach((f, index2) => {
|
|
1997
2097
|
const fileEl = document.createElement("div");
|
|
1998
2098
|
fileEl.className = `${PREFIX}-file-upload__file`;
|
|
1999
2099
|
let statusClass = "";
|
|
@@ -3267,7 +3367,7 @@ var InaUI = (() => {
|
|
|
3267
3367
|
|
|
3268
3368
|
// src/js/components/stateful/table.js
|
|
3269
3369
|
var Table = class {
|
|
3270
|
-
constructor(selectorOrElement,
|
|
3370
|
+
constructor(selectorOrElement, options2 = {}) {
|
|
3271
3371
|
this.container = typeof selectorOrElement === "string" ? document.querySelector(selectorOrElement) : selectorOrElement;
|
|
3272
3372
|
if (!this.container) {
|
|
3273
3373
|
console.warn("[IDDS Table] Container not found:", selectorOrElement);
|
|
@@ -3299,7 +3399,7 @@ var InaUI = (() => {
|
|
|
3299
3399
|
searchContainer: null,
|
|
3300
3400
|
searchButton: null,
|
|
3301
3401
|
onSearch: null,
|
|
3302
|
-
...
|
|
3402
|
+
...options2
|
|
3303
3403
|
};
|
|
3304
3404
|
this.state = {
|
|
3305
3405
|
currentPage: this.options.initialPage,
|
|
@@ -3504,7 +3604,7 @@ var InaUI = (() => {
|
|
|
3504
3604
|
this.updateSelectAllState();
|
|
3505
3605
|
return;
|
|
3506
3606
|
}
|
|
3507
|
-
rowData.forEach((row,
|
|
3607
|
+
rowData.forEach((row, index2) => {
|
|
3508
3608
|
const tr = document.createElement("tr");
|
|
3509
3609
|
tr.className = `${PREFIX}-table__row`;
|
|
3510
3610
|
if (this.options.rowClickable) {
|
|
@@ -3515,11 +3615,11 @@ var InaUI = (() => {
|
|
|
3515
3615
|
return;
|
|
3516
3616
|
}
|
|
3517
3617
|
if (typeof this.options.onRowClick === "function") {
|
|
3518
|
-
this.options.onRowClick(row,
|
|
3618
|
+
this.options.onRowClick(row, index2);
|
|
3519
3619
|
}
|
|
3520
3620
|
});
|
|
3521
3621
|
}
|
|
3522
|
-
const rowKeyStr = String(row[this.options.rowKey] ||
|
|
3622
|
+
const rowKeyStr = String(row[this.options.rowKey] || index2);
|
|
3523
3623
|
if (this.options.selectable) {
|
|
3524
3624
|
const td = document.createElement("td");
|
|
3525
3625
|
td.className = `${PREFIX}-table__cell`;
|
|
@@ -3545,7 +3645,7 @@ var InaUI = (() => {
|
|
|
3545
3645
|
const td = document.createElement("td");
|
|
3546
3646
|
td.className = `${PREFIX}-table__cell`;
|
|
3547
3647
|
if (typeof col.render === "function") {
|
|
3548
|
-
const content = col.render(row,
|
|
3648
|
+
const content = col.render(row, index2);
|
|
3549
3649
|
if (typeof content === "string") {
|
|
3550
3650
|
td.innerHTML = content;
|
|
3551
3651
|
} else if (content instanceof HTMLElement) {
|
|
@@ -3779,8 +3879,8 @@ var InaUI = (() => {
|
|
|
3779
3879
|
this.triggerSelectionChange();
|
|
3780
3880
|
}
|
|
3781
3881
|
toggleAllSelection(checked) {
|
|
3782
|
-
this.state.currentData.forEach((row,
|
|
3783
|
-
const keyStr = String(row[this.options.rowKey] ||
|
|
3882
|
+
this.state.currentData.forEach((row, index2) => {
|
|
3883
|
+
const keyStr = String(row[this.options.rowKey] || index2);
|
|
3784
3884
|
if (checked) {
|
|
3785
3885
|
this.state.selectedKeys.add(keyStr);
|
|
3786
3886
|
this.state.selectedRows.set(keyStr, row);
|
|
@@ -3861,11 +3961,11 @@ var InaUI = (() => {
|
|
|
3861
3961
|
};
|
|
3862
3962
|
}
|
|
3863
3963
|
};
|
|
3864
|
-
function initTable(selectorOrElement,
|
|
3964
|
+
function initTable(selectorOrElement, options2 = {}) {
|
|
3865
3965
|
const elements = typeof selectorOrElement === "string" ? document.querySelectorAll(selectorOrElement) : selectorOrElement ? typeof selectorOrElement.length !== "undefined" ? selectorOrElement : [selectorOrElement] : document.querySelectorAll(`.${PREFIX}-table`);
|
|
3866
3966
|
const instances = [];
|
|
3867
3967
|
elements.forEach((container) => {
|
|
3868
|
-
const instance = new Table(container,
|
|
3968
|
+
const instance = new Table(container, options2);
|
|
3869
3969
|
container.__tableAPI = instance;
|
|
3870
3970
|
instances.push(instance);
|
|
3871
3971
|
});
|
|
@@ -3916,7 +4016,7 @@ var InaUI = (() => {
|
|
|
3916
4016
|
return { toastItem, toast };
|
|
3917
4017
|
}
|
|
3918
4018
|
function showToast(optionsOrMessage, variant = "default", duration = 5e3) {
|
|
3919
|
-
const
|
|
4019
|
+
const options2 = typeof optionsOrMessage === "string" ? {
|
|
3920
4020
|
message: optionsOrMessage,
|
|
3921
4021
|
state: variant,
|
|
3922
4022
|
duration
|
|
@@ -3929,7 +4029,7 @@ var InaUI = (() => {
|
|
|
3929
4029
|
duration: autoCloseDuration = 5e3,
|
|
3930
4030
|
position = "top-right",
|
|
3931
4031
|
actionHtml = ""
|
|
3932
|
-
} =
|
|
4032
|
+
} = options2;
|
|
3933
4033
|
const container = getOrCreateContainer(position);
|
|
3934
4034
|
const { toastItem, toast } = createToastElement({
|
|
3935
4035
|
title,
|
|
@@ -4041,8 +4141,8 @@ var InaUI = (() => {
|
|
|
4041
4141
|
const menuItems = menu.querySelectorAll("li[role='option']");
|
|
4042
4142
|
const menuId = menu.id;
|
|
4043
4143
|
let activeIndex = -1;
|
|
4044
|
-
menuItems.forEach((item,
|
|
4045
|
-
item.id = `${menuId}-item-${
|
|
4144
|
+
menuItems.forEach((item, index2) => {
|
|
4145
|
+
item.id = `${menuId}-item-${index2}`;
|
|
4046
4146
|
});
|
|
4047
4147
|
const toggleMenu = (show) => {
|
|
4048
4148
|
const isCurrentlyShown = dropdown.classList.contains("show");
|
|
@@ -4097,15 +4197,15 @@ var InaUI = (() => {
|
|
|
4097
4197
|
}
|
|
4098
4198
|
toggleMenu(false);
|
|
4099
4199
|
};
|
|
4100
|
-
const setHighlight = (
|
|
4200
|
+
const setHighlight = (index2) => {
|
|
4101
4201
|
removeHighlight();
|
|
4102
4202
|
const visibleItems = menu.querySelectorAll(
|
|
4103
4203
|
"li[role='option']:not(.hidden)"
|
|
4104
4204
|
);
|
|
4105
4205
|
if (visibleItems.length === 0) return;
|
|
4106
|
-
if (
|
|
4107
|
-
else if (
|
|
4108
|
-
const itemToHighlight = visibleItems[
|
|
4206
|
+
if (index2 < 0) index2 = 0;
|
|
4207
|
+
else if (index2 >= visibleItems.length) index2 = visibleItems.length - 1;
|
|
4208
|
+
const itemToHighlight = visibleItems[index2];
|
|
4109
4209
|
if (itemToHighlight) {
|
|
4110
4210
|
itemToHighlight.classList.add("highlighted");
|
|
4111
4211
|
input.setAttribute("aria-activedescendant", itemToHighlight.id);
|
|
@@ -4113,7 +4213,7 @@ var InaUI = (() => {
|
|
|
4113
4213
|
behavior: "smooth",
|
|
4114
4214
|
block: "nearest"
|
|
4115
4215
|
});
|
|
4116
|
-
activeIndex =
|
|
4216
|
+
activeIndex = index2;
|
|
4117
4217
|
}
|
|
4118
4218
|
};
|
|
4119
4219
|
const removeHighlight = () => {
|
package/dist/index.js
CHANGED
|
@@ -91,18 +91,18 @@ function initTab(rootSelector = `.${PREFIX}-tab`) {
|
|
|
91
91
|
const tabItem = tab.querySelectorAll(`.${PREFIX}-tab-item`);
|
|
92
92
|
tabItem.forEach((tabButton) => {
|
|
93
93
|
function updateState() {
|
|
94
|
-
const
|
|
94
|
+
const index2 = Array.from(tabItem).indexOf(tabButton);
|
|
95
95
|
tabItem.forEach((tabButton2, i) => {
|
|
96
96
|
tabButton2.classList.remove("active");
|
|
97
97
|
tabButton2.setAttribute("aria-selected", "false");
|
|
98
|
-
if (i ===
|
|
98
|
+
if (i === index2) {
|
|
99
99
|
tabButton2.classList.add("active");
|
|
100
100
|
tabButton2.setAttribute("aria-selected", "true");
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
tab.dispatchEvent(
|
|
104
104
|
new CustomEvent("tab:change", {
|
|
105
|
-
detail: { activeIndex:
|
|
105
|
+
detail: { activeIndex: index2 },
|
|
106
106
|
bubbles: true,
|
|
107
107
|
composed: true
|
|
108
108
|
})
|
|
@@ -197,28 +197,28 @@ var AccordionGroup = class {
|
|
|
197
197
|
this.element.__inaAccordionGroup = this;
|
|
198
198
|
}
|
|
199
199
|
registerItem(item) {
|
|
200
|
-
const
|
|
201
|
-
this.items.set(item.id,
|
|
200
|
+
const index2 = this.items.size;
|
|
201
|
+
this.items.set(item.id, index2);
|
|
202
202
|
this.itemsArray.push(item);
|
|
203
203
|
if (item.defaultOpen) {
|
|
204
204
|
if (this.isMultiple) {
|
|
205
|
-
if (!this.openIndexes.includes(
|
|
206
|
-
this.openIndexes.push(
|
|
205
|
+
if (!this.openIndexes.includes(index2)) {
|
|
206
|
+
this.openIndexes.push(index2);
|
|
207
207
|
}
|
|
208
208
|
} else {
|
|
209
209
|
if (this.openIndexes.length === 0) {
|
|
210
|
-
this.openIndexes.push(
|
|
210
|
+
this.openIndexes.push(index2);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
return
|
|
214
|
+
return index2;
|
|
215
215
|
}
|
|
216
216
|
unregisterItem(item) {
|
|
217
|
-
const
|
|
218
|
-
if (
|
|
217
|
+
const index2 = this.items.get(item.id);
|
|
218
|
+
if (index2 !== void 0) {
|
|
219
219
|
this.items.delete(item.id);
|
|
220
220
|
this.itemsArray = this.itemsArray.filter((i) => i !== item);
|
|
221
|
-
this.openIndexes = this.openIndexes.filter((idx) => idx !==
|
|
221
|
+
this.openIndexes = this.openIndexes.filter((idx) => idx !== index2).map((idx) => idx > index2 ? idx - 1 : idx);
|
|
222
222
|
const newMap = /* @__PURE__ */ new Map();
|
|
223
223
|
this.itemsArray.forEach((itm, newIdx) => {
|
|
224
224
|
newMap.set(itm.id, newIdx);
|
|
@@ -226,22 +226,22 @@ var AccordionGroup = class {
|
|
|
226
226
|
this.items = newMap;
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
handleItemToggle(
|
|
229
|
+
handleItemToggle(index2, isOpen) {
|
|
230
230
|
const prevIndexes = [...this.openIndexes];
|
|
231
231
|
let nextIndexes = [];
|
|
232
232
|
if (this.isMultiple) {
|
|
233
233
|
if (isOpen) {
|
|
234
|
-
if (!prevIndexes.includes(
|
|
235
|
-
nextIndexes = [...prevIndexes,
|
|
234
|
+
if (!prevIndexes.includes(index2)) {
|
|
235
|
+
nextIndexes = [...prevIndexes, index2];
|
|
236
236
|
} else {
|
|
237
237
|
nextIndexes = prevIndexes;
|
|
238
238
|
}
|
|
239
239
|
} else {
|
|
240
|
-
nextIndexes = prevIndexes.filter((idx) => idx !==
|
|
240
|
+
nextIndexes = prevIndexes.filter((idx) => idx !== index2);
|
|
241
241
|
}
|
|
242
242
|
} else {
|
|
243
243
|
if (isOpen) {
|
|
244
|
-
nextIndexes = [
|
|
244
|
+
nextIndexes = [index2];
|
|
245
245
|
} else {
|
|
246
246
|
nextIndexes = [];
|
|
247
247
|
}
|
|
@@ -249,16 +249,16 @@ var AccordionGroup = class {
|
|
|
249
249
|
this.openIndexes = nextIndexes;
|
|
250
250
|
this.notifyItems();
|
|
251
251
|
}
|
|
252
|
-
isItemOpen(
|
|
253
|
-
return this.openIndexes.includes(
|
|
252
|
+
isItemOpen(index2) {
|
|
253
|
+
return this.openIndexes.includes(index2);
|
|
254
254
|
}
|
|
255
255
|
getItemIndex(itemId) {
|
|
256
256
|
return this.items.get(itemId);
|
|
257
257
|
}
|
|
258
258
|
// Notify all children to update their visual state based on new openIndexes
|
|
259
259
|
notifyItems() {
|
|
260
|
-
this.itemsArray.forEach((item,
|
|
261
|
-
const isOpen = this.openIndexes.includes(
|
|
260
|
+
this.itemsArray.forEach((item, index2) => {
|
|
261
|
+
const isOpen = this.openIndexes.includes(index2);
|
|
262
262
|
item.setOpenState(isOpen);
|
|
263
263
|
});
|
|
264
264
|
}
|
|
@@ -350,7 +350,7 @@ function initAccordion(rootSelector = `.${PREFIX}-accordion-group`) {
|
|
|
350
350
|
|
|
351
351
|
// src/js/components/stateful/date-picker.js
|
|
352
352
|
var DatePicker = class {
|
|
353
|
-
constructor(selectorOrElement,
|
|
353
|
+
constructor(selectorOrElement, options2 = {}) {
|
|
354
354
|
this.container = typeof selectorOrElement === "string" ? document.querySelector(selectorOrElement) : selectorOrElement;
|
|
355
355
|
if (!this.container) {
|
|
356
356
|
console.warn("[IDDS DatePicker] Container not found:", selectorOrElement);
|
|
@@ -376,7 +376,7 @@ var DatePicker = class {
|
|
|
376
376
|
onChange: null,
|
|
377
377
|
triggerWidth: "",
|
|
378
378
|
panelMaxHeight: "",
|
|
379
|
-
...
|
|
379
|
+
...options2
|
|
380
380
|
};
|
|
381
381
|
this.state = {
|
|
382
382
|
viewDate: /* @__PURE__ */ new Date(),
|
|
@@ -716,6 +716,14 @@ var DatePicker = class {
|
|
|
716
716
|
this.state.viewDate.setMonth(this.state.viewDate.getMonth() - 1);
|
|
717
717
|
this.renderPanel();
|
|
718
718
|
};
|
|
719
|
+
prevBtn.onkeydown = (e) => {
|
|
720
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
721
|
+
e.preventDefault();
|
|
722
|
+
e.stopPropagation();
|
|
723
|
+
this.state.viewDate.setMonth(this.state.viewDate.getMonth() - 1);
|
|
724
|
+
this.renderPanel();
|
|
725
|
+
}
|
|
726
|
+
};
|
|
719
727
|
header.appendChild(prevBtn);
|
|
720
728
|
} else {
|
|
721
729
|
const spacer = document.createElement("div");
|
|
@@ -762,6 +770,14 @@ var DatePicker = class {
|
|
|
762
770
|
this.state.viewDate.setMonth(this.state.viewDate.getMonth() + 1);
|
|
763
771
|
this.renderPanel();
|
|
764
772
|
};
|
|
773
|
+
nextBtn.onkeydown = (e) => {
|
|
774
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
775
|
+
e.preventDefault();
|
|
776
|
+
e.stopPropagation();
|
|
777
|
+
this.state.viewDate.setMonth(this.state.viewDate.getMonth() + 1);
|
|
778
|
+
this.renderPanel();
|
|
779
|
+
}
|
|
780
|
+
};
|
|
765
781
|
header.appendChild(nextBtn);
|
|
766
782
|
} else if (!isNextMonth) {
|
|
767
783
|
const spacer = document.createElement("div");
|
|
@@ -793,6 +809,8 @@ var DatePicker = class {
|
|
|
793
809
|
btn.type = "button";
|
|
794
810
|
btn.className = `${PREFIX}-date-picker__day`;
|
|
795
811
|
btn.textContent = i;
|
|
812
|
+
btn.setAttribute("role", "gridcell");
|
|
813
|
+
btn.tabIndex = -1;
|
|
796
814
|
const disabled = this.isDateDisabled(date);
|
|
797
815
|
if (disabled) {
|
|
798
816
|
btn.classList.add(`${PREFIX}-date-picker__day--disabled`);
|
|
@@ -816,6 +834,7 @@ var DatePicker = class {
|
|
|
816
834
|
isSelected = true;
|
|
817
835
|
if (start && end && date > start && date < end) isInRange = true;
|
|
818
836
|
}
|
|
837
|
+
btn.setAttribute("aria-selected", isSelected.toString());
|
|
819
838
|
if (isSelected) btn.classList.add(`${PREFIX}-date-picker__day--selected`);
|
|
820
839
|
if (isInRange) btn.classList.add(`${PREFIX}-date-picker__day--in-range`);
|
|
821
840
|
if (date.toDateString() === today.toDateString())
|
|
@@ -827,6 +846,24 @@ var DatePicker = class {
|
|
|
827
846
|
e.stopPropagation();
|
|
828
847
|
this.handleDateSelect(date);
|
|
829
848
|
};
|
|
849
|
+
btn.onkeydown = (e) => {
|
|
850
|
+
if (disabled || this.options.readonly) return;
|
|
851
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
852
|
+
e.preventDefault();
|
|
853
|
+
this.handleDateSelect(date);
|
|
854
|
+
} else if (["ArrowRight", "ArrowLeft", "ArrowDown", "ArrowUp"].includes(e.key)) {
|
|
855
|
+
e.preventDefault();
|
|
856
|
+
const buttons = Array.from(grid.querySelectorAll("button"));
|
|
857
|
+
const currentIndex = buttons.indexOf(btn);
|
|
858
|
+
let nextIndex = currentIndex;
|
|
859
|
+
if (e.key === "ArrowRight") nextIndex += 1;
|
|
860
|
+
else if (e.key === "ArrowLeft") nextIndex -= 1;
|
|
861
|
+
else if (e.key === "ArrowDown") nextIndex += 7;
|
|
862
|
+
else if (e.key === "ArrowUp") nextIndex -= 7;
|
|
863
|
+
const targetBtn = buttons[nextIndex];
|
|
864
|
+
if (targetBtn) targetBtn.focus();
|
|
865
|
+
}
|
|
866
|
+
};
|
|
830
867
|
}
|
|
831
868
|
grid.appendChild(btn);
|
|
832
869
|
}
|
|
@@ -839,6 +876,19 @@ var DatePicker = class {
|
|
|
839
876
|
btn.textContent = i;
|
|
840
877
|
grid.appendChild(btn);
|
|
841
878
|
}
|
|
879
|
+
setTimeout(() => {
|
|
880
|
+
const allButtons = Array.from(
|
|
881
|
+
grid.querySelectorAll("button:not(.ina-date-picker__day--other-month)")
|
|
882
|
+
);
|
|
883
|
+
const selectedBtn = allButtons.find(
|
|
884
|
+
(b) => b.classList.contains(`${PREFIX}-date-picker__day--selected`)
|
|
885
|
+
);
|
|
886
|
+
const todayBtn = allButtons.find(
|
|
887
|
+
(b) => b.classList.contains(`${PREFIX}-date-picker__day--today`) && !b.disabled
|
|
888
|
+
);
|
|
889
|
+
const focusableBtn = selectedBtn || todayBtn || allButtons.find((b) => !b.disabled);
|
|
890
|
+
if (focusableBtn) focusableBtn.tabIndex = 0;
|
|
891
|
+
}, 0);
|
|
842
892
|
container.append(header, grid);
|
|
843
893
|
return container;
|
|
844
894
|
}
|
|
@@ -940,11 +990,11 @@ var DatePicker = class {
|
|
|
940
990
|
return this.state.rangeDate;
|
|
941
991
|
}
|
|
942
992
|
};
|
|
943
|
-
function initDatepicker(selectorOrElement,
|
|
993
|
+
function initDatepicker(selectorOrElement, options2 = {}) {
|
|
944
994
|
const elements = typeof selectorOrElement === "string" ? document.querySelectorAll(selectorOrElement) : selectorOrElement ? typeof selectorOrElement.length !== "undefined" ? selectorOrElement : [selectorOrElement] : document.querySelectorAll(`.${PREFIX}-date-picker`);
|
|
945
995
|
const instances = [];
|
|
946
996
|
elements.forEach((container) => {
|
|
947
|
-
const instance = new DatePicker(container,
|
|
997
|
+
const instance = new DatePicker(container, options2);
|
|
948
998
|
container.__datepickerAPI = instance;
|
|
949
999
|
instances.push(instance);
|
|
950
1000
|
});
|
|
@@ -954,7 +1004,7 @@ function initDatepicker(selectorOrElement, options = {}) {
|
|
|
954
1004
|
|
|
955
1005
|
// src/js/components/stateful/time-picker.js
|
|
956
1006
|
var TimePicker = class {
|
|
957
|
-
constructor(selectorOrElement,
|
|
1007
|
+
constructor(selectorOrElement, options2 = {}) {
|
|
958
1008
|
this.container = typeof selectorOrElement === "string" ? document.querySelector(selectorOrElement) : selectorOrElement;
|
|
959
1009
|
if (!this.container) {
|
|
960
1010
|
console.warn("[IDDS TimePicker] Container not found:", selectorOrElement);
|
|
@@ -987,7 +1037,7 @@ var TimePicker = class {
|
|
|
987
1037
|
secondStep: 1,
|
|
988
1038
|
onChange: null,
|
|
989
1039
|
size: this.container.dataset.size || "md",
|
|
990
|
-
...
|
|
1040
|
+
...options2
|
|
991
1041
|
};
|
|
992
1042
|
this.state = {
|
|
993
1043
|
isOpen: false,
|
|
@@ -1204,24 +1254,24 @@ var TimePicker = class {
|
|
|
1204
1254
|
}
|
|
1205
1255
|
}
|
|
1206
1256
|
generateOptions(type) {
|
|
1207
|
-
const
|
|
1257
|
+
const options2 = [];
|
|
1208
1258
|
const { use12Hours, hourStep, minuteStep, secondStep } = this.options;
|
|
1209
1259
|
let limit = type === "hour" ? use12Hours ? 12 : 24 : 60;
|
|
1210
1260
|
let step = type === "hour" ? hourStep : type === "minute" ? minuteStep : secondStep;
|
|
1211
1261
|
if (limit === 12) {
|
|
1212
1262
|
for (let i = type === "hour" ? 1 : 0; i <= (type === "hour" ? 12 : 59); i += step) {
|
|
1213
|
-
|
|
1263
|
+
options2.push(i);
|
|
1214
1264
|
}
|
|
1215
1265
|
} else if (limit === 24) {
|
|
1216
1266
|
for (let i = 0; i <= 23; i += step) {
|
|
1217
|
-
|
|
1267
|
+
options2.push(i);
|
|
1218
1268
|
}
|
|
1219
1269
|
} else {
|
|
1220
1270
|
for (let i = 0; i <= 59; i += step) {
|
|
1221
|
-
|
|
1271
|
+
options2.push(i);
|
|
1222
1272
|
}
|
|
1223
1273
|
}
|
|
1224
|
-
return
|
|
1274
|
+
return options2;
|
|
1225
1275
|
}
|
|
1226
1276
|
renderColumn(type, optionsArr) {
|
|
1227
1277
|
const column = document.createElement("div");
|
|
@@ -1275,10 +1325,23 @@ var TimePicker = class {
|
|
|
1275
1325
|
option.classList.add(`${PREFIX}-time-picker__option--selected`);
|
|
1276
1326
|
if (isDisabled)
|
|
1277
1327
|
option.classList.add(`${PREFIX}-time-picker__option--disabled`);
|
|
1328
|
+
option.setAttribute("role", "option");
|
|
1329
|
+
option.setAttribute("aria-selected", isSelected.toString());
|
|
1330
|
+
const isFirstFocusable = index === 0 && !options.some((opt) => {
|
|
1331
|
+
if (type === "hour") {
|
|
1332
|
+
return use12Hours ? (currentTime.hours === 0 ? 12 : currentTime.hours) === opt : currentTime.hours === opt;
|
|
1333
|
+
} else if (type === "minute") {
|
|
1334
|
+
return currentTime.minutes === opt;
|
|
1335
|
+
} else if (type === "second") {
|
|
1336
|
+
return currentTime.seconds === opt;
|
|
1337
|
+
}
|
|
1338
|
+
return false;
|
|
1339
|
+
});
|
|
1340
|
+
option.tabIndex = isSelected || isFirstFocusable ? 0 : -1;
|
|
1278
1341
|
option.textContent = optValue.toString().padStart(2, "0");
|
|
1279
1342
|
if (!isDisabled) {
|
|
1280
|
-
|
|
1281
|
-
e
|
|
1343
|
+
const handleSelection = (e) => {
|
|
1344
|
+
e?.stopPropagation();
|
|
1282
1345
|
const val = parseInt(optValue, 10);
|
|
1283
1346
|
if (type === "hour") {
|
|
1284
1347
|
this.state.currentTime.hours = use12Hours && val === 12 ? 0 : val;
|
|
@@ -1289,6 +1352,21 @@ var TimePicker = class {
|
|
|
1289
1352
|
}
|
|
1290
1353
|
this.updateInput();
|
|
1291
1354
|
this.buildPanel();
|
|
1355
|
+
};
|
|
1356
|
+
option.addEventListener("click", handleSelection);
|
|
1357
|
+
option.addEventListener("keydown", (e) => {
|
|
1358
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1359
|
+
e.preventDefault();
|
|
1360
|
+
handleSelection();
|
|
1361
|
+
} else if (e.key === "ArrowDown") {
|
|
1362
|
+
e.preventDefault();
|
|
1363
|
+
const nextElement = e.currentTarget.nextElementSibling;
|
|
1364
|
+
if (nextElement) nextElement.focus();
|
|
1365
|
+
} else if (e.key === "ArrowUp") {
|
|
1366
|
+
e.preventDefault();
|
|
1367
|
+
const prevElement = e.currentTarget.previousElementSibling;
|
|
1368
|
+
if (prevElement) prevElement.focus();
|
|
1369
|
+
}
|
|
1292
1370
|
});
|
|
1293
1371
|
}
|
|
1294
1372
|
colContent.appendChild(option);
|
|
@@ -1316,12 +1394,34 @@ var TimePicker = class {
|
|
|
1316
1394
|
);
|
|
1317
1395
|
if (isDisabled)
|
|
1318
1396
|
option.classList.add(`${PREFIX}-time-picker__option--disabled`);
|
|
1397
|
+
option.setAttribute("role", "option");
|
|
1398
|
+
option.setAttribute(
|
|
1399
|
+
"aria-selected",
|
|
1400
|
+
(this.state.currentTime.period === p).toString()
|
|
1401
|
+
);
|
|
1402
|
+
const isFirstFocusable = p === "AM" && this.state.currentTime.period !== "AM" && this.state.currentTime.period !== "PM";
|
|
1403
|
+
option.tabIndex = this.state.currentTime.period === p || isFirstFocusable ? 0 : -1;
|
|
1319
1404
|
if (!isDisabled) {
|
|
1320
|
-
|
|
1321
|
-
e
|
|
1405
|
+
const handleSelection = (e) => {
|
|
1406
|
+
e?.stopPropagation();
|
|
1322
1407
|
this.state.currentTime.period = p;
|
|
1323
1408
|
this.updateInput();
|
|
1324
1409
|
this.buildPanel();
|
|
1410
|
+
};
|
|
1411
|
+
option.addEventListener("click", handleSelection);
|
|
1412
|
+
option.addEventListener("keydown", (e) => {
|
|
1413
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1414
|
+
e.preventDefault();
|
|
1415
|
+
handleSelection();
|
|
1416
|
+
} else if (e.key === "ArrowDown") {
|
|
1417
|
+
e.preventDefault();
|
|
1418
|
+
const nextElement = e.currentTarget.nextElementSibling;
|
|
1419
|
+
if (nextElement) nextElement.focus();
|
|
1420
|
+
} else if (e.key === "ArrowUp") {
|
|
1421
|
+
e.preventDefault();
|
|
1422
|
+
const prevElement = e.currentTarget.previousElementSibling;
|
|
1423
|
+
if (prevElement) prevElement.focus();
|
|
1424
|
+
}
|
|
1325
1425
|
});
|
|
1326
1426
|
}
|
|
1327
1427
|
colContent.appendChild(option);
|
|
@@ -1402,11 +1502,11 @@ var TimePicker = class {
|
|
|
1402
1502
|
return this.state.internalValue;
|
|
1403
1503
|
}
|
|
1404
1504
|
};
|
|
1405
|
-
function initTimepicker(selectorOrElement,
|
|
1505
|
+
function initTimepicker(selectorOrElement, options2 = {}) {
|
|
1406
1506
|
const elements = typeof selectorOrElement === "string" ? document.querySelectorAll(selectorOrElement) : selectorOrElement ? typeof selectorOrElement.length !== "undefined" ? selectorOrElement : [selectorOrElement] : document.querySelectorAll(`.${PREFIX}-time-picker`);
|
|
1407
1507
|
const instances = [];
|
|
1408
1508
|
elements.forEach((container) => {
|
|
1409
|
-
const instance = new TimePicker(container,
|
|
1509
|
+
const instance = new TimePicker(container, options2);
|
|
1410
1510
|
container.__timepickerAPI = instance;
|
|
1411
1511
|
instances.push(instance);
|
|
1412
1512
|
});
|
|
@@ -1740,9 +1840,9 @@ function updateTriggerUI(root, values, isMultiple) {
|
|
|
1740
1840
|
`.${PREFIX4}-select-dropdown__trigger-text`
|
|
1741
1841
|
);
|
|
1742
1842
|
const placeholder = input ? input.getAttribute("placeholder") : textSpan ? textSpan.getAttribute("data-placeholder") : "Select...";
|
|
1743
|
-
const
|
|
1843
|
+
const options2 = root.querySelectorAll(`.${PREFIX4}-select-dropdown__option`);
|
|
1744
1844
|
const getLabel = (val) => {
|
|
1745
|
-
const opt = Array.from(
|
|
1845
|
+
const opt = Array.from(options2).find(
|
|
1746
1846
|
(o) => o.getAttribute("data-value") === val
|
|
1747
1847
|
);
|
|
1748
1848
|
return opt ? opt.textContent.trim() : val;
|
|
@@ -1768,7 +1868,7 @@ function updateTriggerUI(root, values, isMultiple) {
|
|
|
1768
1868
|
values.length === 0
|
|
1769
1869
|
);
|
|
1770
1870
|
}
|
|
1771
|
-
|
|
1871
|
+
options2.forEach((opt) => {
|
|
1772
1872
|
const val = opt.getAttribute("data-value");
|
|
1773
1873
|
const isSelected = values.includes(val);
|
|
1774
1874
|
if (isMultiple) {
|
|
@@ -1848,13 +1948,13 @@ function initSelectDropdown() {
|
|
|
1848
1948
|
const root = e.target.closest(`.${PREFIX4}-select-dropdown`);
|
|
1849
1949
|
if (root) {
|
|
1850
1950
|
const term = e.target.value.toLowerCase();
|
|
1851
|
-
const
|
|
1951
|
+
const options2 = root.querySelectorAll(
|
|
1852
1952
|
`.${PREFIX4}-select-dropdown__option`
|
|
1853
1953
|
);
|
|
1854
1954
|
if (root.getAttribute("data-state") !== "open") {
|
|
1855
1955
|
setDropdownState(root, { isOpen: true });
|
|
1856
1956
|
}
|
|
1857
|
-
|
|
1957
|
+
options2.forEach((opt) => {
|
|
1858
1958
|
const text = opt.textContent.trim().toLowerCase();
|
|
1859
1959
|
opt.style.display = text.includes(term) ? "" : "none";
|
|
1860
1960
|
});
|
|
@@ -1928,20 +2028,20 @@ function initStepper() {
|
|
|
1928
2028
|
`;
|
|
1929
2029
|
const updateUI = () => {
|
|
1930
2030
|
stepper.dataset.currentStep = currentStep;
|
|
1931
|
-
items.forEach((item,
|
|
2031
|
+
items.forEach((item, index2) => {
|
|
1932
2032
|
const iconWrapper = item.querySelector(
|
|
1933
2033
|
`.${PREFIX}-stepper__icon-wrapper`
|
|
1934
2034
|
);
|
|
1935
|
-
const itemNumber =
|
|
2035
|
+
const itemNumber = index2 + 1;
|
|
1936
2036
|
item.classList.remove(
|
|
1937
2037
|
`${PREFIX}-stepper__item--completed`,
|
|
1938
2038
|
`${PREFIX}-stepper__item--active`
|
|
1939
2039
|
);
|
|
1940
2040
|
if (iconWrapper) iconWrapper.innerHTML = "";
|
|
1941
|
-
if (
|
|
2041
|
+
if (index2 < currentStep) {
|
|
1942
2042
|
item.classList.add(`${PREFIX}-stepper__item--completed`);
|
|
1943
2043
|
if (iconWrapper) iconWrapper.innerHTML = checkIcon;
|
|
1944
|
-
} else if (
|
|
2044
|
+
} else if (index2 === currentStep) {
|
|
1945
2045
|
item.classList.add(`${PREFIX}-stepper__item--active`);
|
|
1946
2046
|
if (iconWrapper)
|
|
1947
2047
|
iconWrapper.innerHTML = `<span class="${PREFIX}-stepper__step-number">${itemNumber}</span>`;
|
|
@@ -1950,8 +2050,8 @@ function initStepper() {
|
|
|
1950
2050
|
iconWrapper.innerHTML = `<span class="${PREFIX}-stepper__step-number">${itemNumber}</span>`;
|
|
1951
2051
|
}
|
|
1952
2052
|
});
|
|
1953
|
-
separators.forEach((separator,
|
|
1954
|
-
if (
|
|
2053
|
+
separators.forEach((separator, index2) => {
|
|
2054
|
+
if (index2 < currentStep) {
|
|
1955
2055
|
separator.classList.add(`${PREFIX}-stepper__separator--completed`);
|
|
1956
2056
|
} else {
|
|
1957
2057
|
separator.classList.remove(`${PREFIX}-stepper__separator--completed`);
|
|
@@ -1997,11 +2097,11 @@ function initStepper() {
|
|
|
1997
2097
|
}
|
|
1998
2098
|
});
|
|
1999
2099
|
});
|
|
2000
|
-
items.forEach((item,
|
|
2100
|
+
items.forEach((item, index2) => {
|
|
2001
2101
|
if (item.classList.contains(`${PREFIX}-stepper__item--clickable`) || item.hasAttribute("data-clickable")) {
|
|
2002
2102
|
item.addEventListener("click", () => {
|
|
2003
2103
|
if (!item.classList.contains(`${PREFIX}-stepper__item--disabled`)) {
|
|
2004
|
-
currentStep =
|
|
2104
|
+
currentStep = index2;
|
|
2005
2105
|
updateUI();
|
|
2006
2106
|
}
|
|
2007
2107
|
});
|
|
@@ -2075,7 +2175,7 @@ function initFileUpload(rootSelector = `.${PREFIX}-file-upload`) {
|
|
|
2075
2175
|
} else {
|
|
2076
2176
|
filesContainer.style.display = "none";
|
|
2077
2177
|
}
|
|
2078
|
-
uploadedFiles.forEach((f,
|
|
2178
|
+
uploadedFiles.forEach((f, index2) => {
|
|
2079
2179
|
const fileEl = document.createElement("div");
|
|
2080
2180
|
fileEl.className = `${PREFIX}-file-upload__file`;
|
|
2081
2181
|
let statusClass = "";
|
|
@@ -3349,7 +3449,7 @@ function initTabHorizontal() {
|
|
|
3349
3449
|
|
|
3350
3450
|
// src/js/components/stateful/table.js
|
|
3351
3451
|
var Table = class {
|
|
3352
|
-
constructor(selectorOrElement,
|
|
3452
|
+
constructor(selectorOrElement, options2 = {}) {
|
|
3353
3453
|
this.container = typeof selectorOrElement === "string" ? document.querySelector(selectorOrElement) : selectorOrElement;
|
|
3354
3454
|
if (!this.container) {
|
|
3355
3455
|
console.warn("[IDDS Table] Container not found:", selectorOrElement);
|
|
@@ -3381,7 +3481,7 @@ var Table = class {
|
|
|
3381
3481
|
searchContainer: null,
|
|
3382
3482
|
searchButton: null,
|
|
3383
3483
|
onSearch: null,
|
|
3384
|
-
...
|
|
3484
|
+
...options2
|
|
3385
3485
|
};
|
|
3386
3486
|
this.state = {
|
|
3387
3487
|
currentPage: this.options.initialPage,
|
|
@@ -3586,7 +3686,7 @@ var Table = class {
|
|
|
3586
3686
|
this.updateSelectAllState();
|
|
3587
3687
|
return;
|
|
3588
3688
|
}
|
|
3589
|
-
rowData.forEach((row,
|
|
3689
|
+
rowData.forEach((row, index2) => {
|
|
3590
3690
|
const tr = document.createElement("tr");
|
|
3591
3691
|
tr.className = `${PREFIX}-table__row`;
|
|
3592
3692
|
if (this.options.rowClickable) {
|
|
@@ -3597,11 +3697,11 @@ var Table = class {
|
|
|
3597
3697
|
return;
|
|
3598
3698
|
}
|
|
3599
3699
|
if (typeof this.options.onRowClick === "function") {
|
|
3600
|
-
this.options.onRowClick(row,
|
|
3700
|
+
this.options.onRowClick(row, index2);
|
|
3601
3701
|
}
|
|
3602
3702
|
});
|
|
3603
3703
|
}
|
|
3604
|
-
const rowKeyStr = String(row[this.options.rowKey] ||
|
|
3704
|
+
const rowKeyStr = String(row[this.options.rowKey] || index2);
|
|
3605
3705
|
if (this.options.selectable) {
|
|
3606
3706
|
const td = document.createElement("td");
|
|
3607
3707
|
td.className = `${PREFIX}-table__cell`;
|
|
@@ -3627,7 +3727,7 @@ var Table = class {
|
|
|
3627
3727
|
const td = document.createElement("td");
|
|
3628
3728
|
td.className = `${PREFIX}-table__cell`;
|
|
3629
3729
|
if (typeof col.render === "function") {
|
|
3630
|
-
const content = col.render(row,
|
|
3730
|
+
const content = col.render(row, index2);
|
|
3631
3731
|
if (typeof content === "string") {
|
|
3632
3732
|
td.innerHTML = content;
|
|
3633
3733
|
} else if (content instanceof HTMLElement) {
|
|
@@ -3861,8 +3961,8 @@ var Table = class {
|
|
|
3861
3961
|
this.triggerSelectionChange();
|
|
3862
3962
|
}
|
|
3863
3963
|
toggleAllSelection(checked) {
|
|
3864
|
-
this.state.currentData.forEach((row,
|
|
3865
|
-
const keyStr = String(row[this.options.rowKey] ||
|
|
3964
|
+
this.state.currentData.forEach((row, index2) => {
|
|
3965
|
+
const keyStr = String(row[this.options.rowKey] || index2);
|
|
3866
3966
|
if (checked) {
|
|
3867
3967
|
this.state.selectedKeys.add(keyStr);
|
|
3868
3968
|
this.state.selectedRows.set(keyStr, row);
|
|
@@ -3943,11 +4043,11 @@ var Table = class {
|
|
|
3943
4043
|
};
|
|
3944
4044
|
}
|
|
3945
4045
|
};
|
|
3946
|
-
function initTable(selectorOrElement,
|
|
4046
|
+
function initTable(selectorOrElement, options2 = {}) {
|
|
3947
4047
|
const elements = typeof selectorOrElement === "string" ? document.querySelectorAll(selectorOrElement) : selectorOrElement ? typeof selectorOrElement.length !== "undefined" ? selectorOrElement : [selectorOrElement] : document.querySelectorAll(`.${PREFIX}-table`);
|
|
3948
4048
|
const instances = [];
|
|
3949
4049
|
elements.forEach((container) => {
|
|
3950
|
-
const instance = new Table(container,
|
|
4050
|
+
const instance = new Table(container, options2);
|
|
3951
4051
|
container.__tableAPI = instance;
|
|
3952
4052
|
instances.push(instance);
|
|
3953
4053
|
});
|
|
@@ -3998,7 +4098,7 @@ function createToastElement({ title, message, state, style, actionHtml }) {
|
|
|
3998
4098
|
return { toastItem, toast };
|
|
3999
4099
|
}
|
|
4000
4100
|
function showToast(optionsOrMessage, variant = "default", duration = 5e3) {
|
|
4001
|
-
const
|
|
4101
|
+
const options2 = typeof optionsOrMessage === "string" ? {
|
|
4002
4102
|
message: optionsOrMessage,
|
|
4003
4103
|
state: variant,
|
|
4004
4104
|
duration
|
|
@@ -4011,7 +4111,7 @@ function showToast(optionsOrMessage, variant = "default", duration = 5e3) {
|
|
|
4011
4111
|
duration: autoCloseDuration = 5e3,
|
|
4012
4112
|
position = "top-right",
|
|
4013
4113
|
actionHtml = ""
|
|
4014
|
-
} =
|
|
4114
|
+
} = options2;
|
|
4015
4115
|
const container = getOrCreateContainer(position);
|
|
4016
4116
|
const { toastItem, toast } = createToastElement({
|
|
4017
4117
|
title,
|