@idds/js 1.2.1 → 1.2.3
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 +116 -31
- package/dist/index.js +116 -31
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -297,6 +297,7 @@ var InaUI = (() => {
|
|
|
297
297
|
this.index = this.group.registerItem(this);
|
|
298
298
|
}
|
|
299
299
|
this.toggle.addEventListener("click", (e) => this.handleClick(e));
|
|
300
|
+
this.toggle.addEventListener("keydown", (e) => this.handleKeyDown(e));
|
|
300
301
|
if (this.group) {
|
|
301
302
|
const isOpen = this.group.isItemOpen(this.index);
|
|
302
303
|
this.setOpenState(isOpen);
|
|
@@ -325,6 +326,22 @@ var InaUI = (() => {
|
|
|
325
326
|
this.setOpenState(nextState);
|
|
326
327
|
}
|
|
327
328
|
}
|
|
329
|
+
handleKeyDown(e) {
|
|
330
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
331
|
+
e.preventDefault();
|
|
332
|
+
const currentAccordion = this.element;
|
|
333
|
+
const container = currentAccordion.closest(".ina-accordion-group") || currentAccordion.parentElement;
|
|
334
|
+
if (!container) return;
|
|
335
|
+
const toggles = Array.from(
|
|
336
|
+
container.querySelectorAll(".ina-accordion__toggle:not([disabled])")
|
|
337
|
+
);
|
|
338
|
+
const currentIndex = toggles.indexOf(this.toggle);
|
|
339
|
+
if (currentIndex > -1) {
|
|
340
|
+
const nextIndex = e.key === "ArrowDown" ? (currentIndex + 1) % toggles.length : (currentIndex - 1 + toggles.length) % toggles.length;
|
|
341
|
+
toggles[nextIndex]?.focus();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
328
345
|
setOpenState(isOpen) {
|
|
329
346
|
if (isOpen) {
|
|
330
347
|
this.element.classList.add(`${PREFIX}-accordion--open`);
|
|
@@ -3006,15 +3023,14 @@ var InaUI = (() => {
|
|
|
3006
3023
|
);
|
|
3007
3024
|
});
|
|
3008
3025
|
if (showCustomization) {
|
|
3009
|
-
const
|
|
3026
|
+
const isToggleBtn2 = (i) => i.hasAttribute("data-customization-toggle") || i.textContent.trim() === customizationLabel;
|
|
3027
|
+
const standardValues = Array.from(items).filter((item) => !isToggleBtn2(item)).map((item) => item.getAttribute("data-value"));
|
|
3010
3028
|
const customValues = normSelected.filter(
|
|
3011
3029
|
(val) => !standardValues.includes(val) && val !== ""
|
|
3012
3030
|
);
|
|
3013
3031
|
const isStandard = customValues.length === 0;
|
|
3014
3032
|
const primaryCustomValue = customValues[customValues.length - 1] || "";
|
|
3015
|
-
const toggleBtn = Array.from(items).find(
|
|
3016
|
-
(i) => i.textContent.trim() === customizationLabel
|
|
3017
|
-
);
|
|
3033
|
+
const toggleBtn = Array.from(items).find(isToggleBtn2);
|
|
3018
3034
|
const showInput = toggleBtn && normSelected.includes(toggleBtn.getAttribute("data-value")) || !isStandard && normSelected.length > 0;
|
|
3019
3035
|
if (showInput) {
|
|
3020
3036
|
if (!customFieldContainer) {
|
|
@@ -3035,16 +3051,11 @@ var InaUI = (() => {
|
|
|
3035
3051
|
`;
|
|
3036
3052
|
input = customFieldContainer.querySelector("input");
|
|
3037
3053
|
input.addEventListener("blur", (e) => {
|
|
3038
|
-
|
|
3039
|
-
if (val.trim()) {
|
|
3040
|
-
handleSelect(val.trim());
|
|
3041
|
-
}
|
|
3054
|
+
commitCustomValue(e.target);
|
|
3042
3055
|
});
|
|
3043
3056
|
input.addEventListener("keydown", (e) => {
|
|
3044
3057
|
if (e.key === "Enter") {
|
|
3045
|
-
|
|
3046
|
-
handleSelect(e.target.value.trim());
|
|
3047
|
-
}
|
|
3058
|
+
commitCustomValue(e.target);
|
|
3048
3059
|
e.target.blur();
|
|
3049
3060
|
}
|
|
3050
3061
|
});
|
|
@@ -3103,14 +3114,55 @@ var InaUI = (() => {
|
|
|
3103
3114
|
currentFocusedIndex = index2;
|
|
3104
3115
|
}
|
|
3105
3116
|
};
|
|
3117
|
+
const commitCustomValue = (inputEl) => {
|
|
3118
|
+
const finalValue = inputEl.value.trim();
|
|
3119
|
+
let normSelected = getNormalizedSelected();
|
|
3120
|
+
const toggleBtn = Array.from(items).find(isToggleBtn);
|
|
3121
|
+
const toggleVal = toggleBtn ? toggleBtn.getAttribute("data-value") : null;
|
|
3122
|
+
const standardValues = Array.from(items).filter((i) => !isToggleBtn(i)).map((i) => i.getAttribute("data-value"));
|
|
3123
|
+
const customValues = normSelected.filter(
|
|
3124
|
+
(val) => !standardValues.includes(val) && val !== "" && val !== toggleVal
|
|
3125
|
+
);
|
|
3126
|
+
const primaryCustomValue = customValues[customValues.length - 1];
|
|
3127
|
+
if (primaryCustomValue) {
|
|
3128
|
+
normSelected = normSelected.filter((v) => v !== primaryCustomValue);
|
|
3129
|
+
}
|
|
3130
|
+
if (finalValue !== "") {
|
|
3131
|
+
if (!normSelected.includes(finalValue)) {
|
|
3132
|
+
normSelected.push(finalValue);
|
|
3133
|
+
}
|
|
3134
|
+
} else {
|
|
3135
|
+
if (toggleVal) {
|
|
3136
|
+
normSelected = normSelected.filter((v) => v !== toggleVal);
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
if (isMultiple) {
|
|
3140
|
+
selectedValue = normSelected.join(",");
|
|
3141
|
+
} else {
|
|
3142
|
+
selectedValue = finalValue;
|
|
3143
|
+
}
|
|
3144
|
+
updateUI();
|
|
3145
|
+
const changeEvent = new CustomEvent(`${PREFIX4}-chip:change`, {
|
|
3146
|
+
detail: { value: isMultiple ? getNormalizedSelected() : selectedValue },
|
|
3147
|
+
bubbles: true
|
|
3148
|
+
});
|
|
3149
|
+
container.dispatchEvent(changeEvent);
|
|
3150
|
+
};
|
|
3106
3151
|
items.forEach((item, index2) => {
|
|
3107
3152
|
item.addEventListener("click", (e) => {
|
|
3108
3153
|
if (item.hasAttribute("disabled")) return;
|
|
3109
3154
|
currentFocusedIndex = index2;
|
|
3110
3155
|
const val = item.getAttribute("data-value");
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3156
|
+
if (showCustomization && isToggleBtn(item)) {
|
|
3157
|
+
const normSelected = getNormalizedSelected();
|
|
3158
|
+
const standardValues = Array.from(items).filter((i) => !isToggleBtn(i)).map((i) => i.getAttribute("data-value"));
|
|
3159
|
+
const customValues = normSelected.filter(
|
|
3160
|
+
(v) => !standardValues.includes(v) && v !== "" && v !== val
|
|
3161
|
+
);
|
|
3162
|
+
const isInputVisible = normSelected.includes(val) || customValues.length > 0;
|
|
3163
|
+
if (!isInputVisible) {
|
|
3164
|
+
handleSelect(val);
|
|
3165
|
+
}
|
|
3114
3166
|
} else {
|
|
3115
3167
|
handleSelect(val);
|
|
3116
3168
|
}
|
|
@@ -3134,22 +3186,7 @@ var InaUI = (() => {
|
|
|
3134
3186
|
}
|
|
3135
3187
|
if (e.key === " " || e.key === "Enter") {
|
|
3136
3188
|
e.preventDefault();
|
|
3137
|
-
|
|
3138
|
-
const label = item.textContent.trim();
|
|
3139
|
-
if (showCustomization && label === customizationLabel) {
|
|
3140
|
-
handleSelect(val);
|
|
3141
|
-
setTimeout(() => {
|
|
3142
|
-
const customFieldContainer2 = container.querySelector(
|
|
3143
|
-
`.${PREFIX4}-chip__custom-field`
|
|
3144
|
-
);
|
|
3145
|
-
if (customFieldContainer2) {
|
|
3146
|
-
const inputEl = customFieldContainer2.querySelector("input");
|
|
3147
|
-
if (inputEl) inputEl.focus();
|
|
3148
|
-
}
|
|
3149
|
-
}, 50);
|
|
3150
|
-
} else {
|
|
3151
|
-
handleSelect(val);
|
|
3152
|
-
}
|
|
3189
|
+
item.click();
|
|
3153
3190
|
}
|
|
3154
3191
|
});
|
|
3155
3192
|
});
|
|
@@ -3343,6 +3380,28 @@ var InaUI = (() => {
|
|
|
3343
3380
|
lastBtn.addEventListener("click", () => {
|
|
3344
3381
|
if (!isDisabled && currentPage < totalPages) goToPage(totalPages);
|
|
3345
3382
|
});
|
|
3383
|
+
if (navButtonsContainer && !navButtonsContainer.__inaKeyboardSet) {
|
|
3384
|
+
navButtonsContainer.addEventListener("keydown", (e) => {
|
|
3385
|
+
if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
|
|
3386
|
+
const focusable = Array.from(
|
|
3387
|
+
navButtonsContainer.querySelectorAll("button:not([disabled])")
|
|
3388
|
+
);
|
|
3389
|
+
if (!focusable.length) return;
|
|
3390
|
+
const currentIndex = focusable.indexOf(document.activeElement);
|
|
3391
|
+
if (currentIndex >= 0) {
|
|
3392
|
+
e.preventDefault();
|
|
3393
|
+
const nextIndex = e.key === "ArrowRight" ? (currentIndex + 1) % focusable.length : (currentIndex - 1 + focusable.length) % focusable.length;
|
|
3394
|
+
focusable[nextIndex]?.focus();
|
|
3395
|
+
}
|
|
3396
|
+
} else if (e.key === "Enter" || e.key === " ") {
|
|
3397
|
+
if (document.activeElement && document.activeElement.tagName === "BUTTON") {
|
|
3398
|
+
e.preventDefault();
|
|
3399
|
+
document.activeElement.click();
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
});
|
|
3403
|
+
navButtonsContainer.__inaKeyboardSet = true;
|
|
3404
|
+
}
|
|
3346
3405
|
if (pageSizeSelect) {
|
|
3347
3406
|
pageSizeSelect.addEventListener("change", (e) => {
|
|
3348
3407
|
if (isDisabled) return;
|
|
@@ -4547,13 +4606,39 @@ var InaUI = (() => {
|
|
|
4547
4606
|
})
|
|
4548
4607
|
);
|
|
4549
4608
|
};
|
|
4550
|
-
buttons.forEach((button) => {
|
|
4609
|
+
buttons.forEach((button, index2) => {
|
|
4551
4610
|
button.addEventListener("click", (e) => {
|
|
4552
4611
|
if (button.type !== "submit") {
|
|
4553
4612
|
e.preventDefault();
|
|
4554
4613
|
}
|
|
4555
4614
|
updateState(button);
|
|
4556
4615
|
});
|
|
4616
|
+
button.addEventListener("keydown", (e) => {
|
|
4617
|
+
const isDisabled = button.hasAttribute("disabled") || button.classList.contains(`${PREFIX}-button-group__button--disabled`);
|
|
4618
|
+
if (isDisabled) return;
|
|
4619
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
4620
|
+
e.preventDefault();
|
|
4621
|
+
updateState(button);
|
|
4622
|
+
} else if (e.key === "ArrowRight" || e.key === "ArrowDown") {
|
|
4623
|
+
e.preventDefault();
|
|
4624
|
+
let nextIndex = (index2 + 1) % buttons.length;
|
|
4625
|
+
while ((buttons[nextIndex].hasAttribute("disabled") || buttons[nextIndex].classList.contains(
|
|
4626
|
+
`${PREFIX}-button-group__button--disabled`
|
|
4627
|
+
)) && nextIndex !== index2) {
|
|
4628
|
+
nextIndex = (nextIndex + 1) % buttons.length;
|
|
4629
|
+
}
|
|
4630
|
+
buttons[nextIndex]?.focus();
|
|
4631
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
|
|
4632
|
+
e.preventDefault();
|
|
4633
|
+
let prevIndex = (index2 - 1 + buttons.length) % buttons.length;
|
|
4634
|
+
while ((buttons[prevIndex].hasAttribute("disabled") || buttons[prevIndex].classList.contains(
|
|
4635
|
+
`${PREFIX}-button-group__button--disabled`
|
|
4636
|
+
)) && prevIndex !== index2) {
|
|
4637
|
+
prevIndex = (prevIndex - 1 + buttons.length) % buttons.length;
|
|
4638
|
+
}
|
|
4639
|
+
buttons[prevIndex]?.focus();
|
|
4640
|
+
}
|
|
4641
|
+
});
|
|
4557
4642
|
});
|
|
4558
4643
|
buttonGroup.__inaButtonGroupInitialized = true;
|
|
4559
4644
|
});
|
package/dist/index.js
CHANGED
|
@@ -29,13 +29,39 @@ function initButtonGroup(rootSelector = `.${PREFIX}-button-group`) {
|
|
|
29
29
|
})
|
|
30
30
|
);
|
|
31
31
|
};
|
|
32
|
-
buttons.forEach((button) => {
|
|
32
|
+
buttons.forEach((button, index2) => {
|
|
33
33
|
button.addEventListener("click", (e) => {
|
|
34
34
|
if (button.type !== "submit") {
|
|
35
35
|
e.preventDefault();
|
|
36
36
|
}
|
|
37
37
|
updateState(button);
|
|
38
38
|
});
|
|
39
|
+
button.addEventListener("keydown", (e) => {
|
|
40
|
+
const isDisabled = button.hasAttribute("disabled") || button.classList.contains(`${PREFIX}-button-group__button--disabled`);
|
|
41
|
+
if (isDisabled) return;
|
|
42
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
updateState(button);
|
|
45
|
+
} else if (e.key === "ArrowRight" || e.key === "ArrowDown") {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
let nextIndex = (index2 + 1) % buttons.length;
|
|
48
|
+
while ((buttons[nextIndex].hasAttribute("disabled") || buttons[nextIndex].classList.contains(
|
|
49
|
+
`${PREFIX}-button-group__button--disabled`
|
|
50
|
+
)) && nextIndex !== index2) {
|
|
51
|
+
nextIndex = (nextIndex + 1) % buttons.length;
|
|
52
|
+
}
|
|
53
|
+
buttons[nextIndex]?.focus();
|
|
54
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
let prevIndex = (index2 - 1 + buttons.length) % buttons.length;
|
|
57
|
+
while ((buttons[prevIndex].hasAttribute("disabled") || buttons[prevIndex].classList.contains(
|
|
58
|
+
`${PREFIX}-button-group__button--disabled`
|
|
59
|
+
)) && prevIndex !== index2) {
|
|
60
|
+
prevIndex = (prevIndex - 1 + buttons.length) % buttons.length;
|
|
61
|
+
}
|
|
62
|
+
buttons[prevIndex]?.focus();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
39
65
|
});
|
|
40
66
|
buttonGroup.__inaButtonGroupInitialized = true;
|
|
41
67
|
});
|
|
@@ -285,6 +311,7 @@ var Accordion = class {
|
|
|
285
311
|
this.index = this.group.registerItem(this);
|
|
286
312
|
}
|
|
287
313
|
this.toggle.addEventListener("click", (e) => this.handleClick(e));
|
|
314
|
+
this.toggle.addEventListener("keydown", (e) => this.handleKeyDown(e));
|
|
288
315
|
if (this.group) {
|
|
289
316
|
const isOpen = this.group.isItemOpen(this.index);
|
|
290
317
|
this.setOpenState(isOpen);
|
|
@@ -313,6 +340,22 @@ var Accordion = class {
|
|
|
313
340
|
this.setOpenState(nextState);
|
|
314
341
|
}
|
|
315
342
|
}
|
|
343
|
+
handleKeyDown(e) {
|
|
344
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
345
|
+
e.preventDefault();
|
|
346
|
+
const currentAccordion = this.element;
|
|
347
|
+
const container = currentAccordion.closest(".ina-accordion-group") || currentAccordion.parentElement;
|
|
348
|
+
if (!container) return;
|
|
349
|
+
const toggles = Array.from(
|
|
350
|
+
container.querySelectorAll(".ina-accordion__toggle:not([disabled])")
|
|
351
|
+
);
|
|
352
|
+
const currentIndex = toggles.indexOf(this.toggle);
|
|
353
|
+
if (currentIndex > -1) {
|
|
354
|
+
const nextIndex = e.key === "ArrowDown" ? (currentIndex + 1) % toggles.length : (currentIndex - 1 + toggles.length) % toggles.length;
|
|
355
|
+
toggles[nextIndex]?.focus();
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
316
359
|
setOpenState(isOpen) {
|
|
317
360
|
if (isOpen) {
|
|
318
361
|
this.element.classList.add(`${PREFIX}-accordion--open`);
|
|
@@ -3086,15 +3129,14 @@ function initChip(rootSelector = `.${PREFIX5}-chip`) {
|
|
|
3086
3129
|
);
|
|
3087
3130
|
});
|
|
3088
3131
|
if (showCustomization) {
|
|
3089
|
-
const
|
|
3132
|
+
const isToggleBtn2 = (i) => i.hasAttribute("data-customization-toggle") || i.textContent.trim() === customizationLabel;
|
|
3133
|
+
const standardValues = Array.from(items).filter((item) => !isToggleBtn2(item)).map((item) => item.getAttribute("data-value"));
|
|
3090
3134
|
const customValues = normSelected.filter(
|
|
3091
3135
|
(val) => !standardValues.includes(val) && val !== ""
|
|
3092
3136
|
);
|
|
3093
3137
|
const isStandard = customValues.length === 0;
|
|
3094
3138
|
const primaryCustomValue = customValues[customValues.length - 1] || "";
|
|
3095
|
-
const toggleBtn = Array.from(items).find(
|
|
3096
|
-
(i) => i.textContent.trim() === customizationLabel
|
|
3097
|
-
);
|
|
3139
|
+
const toggleBtn = Array.from(items).find(isToggleBtn2);
|
|
3098
3140
|
const showInput = toggleBtn && normSelected.includes(toggleBtn.getAttribute("data-value")) || !isStandard && normSelected.length > 0;
|
|
3099
3141
|
if (showInput) {
|
|
3100
3142
|
if (!customFieldContainer) {
|
|
@@ -3115,16 +3157,11 @@ function initChip(rootSelector = `.${PREFIX5}-chip`) {
|
|
|
3115
3157
|
`;
|
|
3116
3158
|
input = customFieldContainer.querySelector("input");
|
|
3117
3159
|
input.addEventListener("blur", (e) => {
|
|
3118
|
-
|
|
3119
|
-
if (val.trim()) {
|
|
3120
|
-
handleSelect(val.trim());
|
|
3121
|
-
}
|
|
3160
|
+
commitCustomValue(e.target);
|
|
3122
3161
|
});
|
|
3123
3162
|
input.addEventListener("keydown", (e) => {
|
|
3124
3163
|
if (e.key === "Enter") {
|
|
3125
|
-
|
|
3126
|
-
handleSelect(e.target.value.trim());
|
|
3127
|
-
}
|
|
3164
|
+
commitCustomValue(e.target);
|
|
3128
3165
|
e.target.blur();
|
|
3129
3166
|
}
|
|
3130
3167
|
});
|
|
@@ -3183,14 +3220,55 @@ function initChip(rootSelector = `.${PREFIX5}-chip`) {
|
|
|
3183
3220
|
currentFocusedIndex = index2;
|
|
3184
3221
|
}
|
|
3185
3222
|
};
|
|
3223
|
+
const commitCustomValue = (inputEl) => {
|
|
3224
|
+
const finalValue = inputEl.value.trim();
|
|
3225
|
+
let normSelected = getNormalizedSelected();
|
|
3226
|
+
const toggleBtn = Array.from(items).find(isToggleBtn);
|
|
3227
|
+
const toggleVal = toggleBtn ? toggleBtn.getAttribute("data-value") : null;
|
|
3228
|
+
const standardValues = Array.from(items).filter((i) => !isToggleBtn(i)).map((i) => i.getAttribute("data-value"));
|
|
3229
|
+
const customValues = normSelected.filter(
|
|
3230
|
+
(val) => !standardValues.includes(val) && val !== "" && val !== toggleVal
|
|
3231
|
+
);
|
|
3232
|
+
const primaryCustomValue = customValues[customValues.length - 1];
|
|
3233
|
+
if (primaryCustomValue) {
|
|
3234
|
+
normSelected = normSelected.filter((v) => v !== primaryCustomValue);
|
|
3235
|
+
}
|
|
3236
|
+
if (finalValue !== "") {
|
|
3237
|
+
if (!normSelected.includes(finalValue)) {
|
|
3238
|
+
normSelected.push(finalValue);
|
|
3239
|
+
}
|
|
3240
|
+
} else {
|
|
3241
|
+
if (toggleVal) {
|
|
3242
|
+
normSelected = normSelected.filter((v) => v !== toggleVal);
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
if (isMultiple) {
|
|
3246
|
+
selectedValue = normSelected.join(",");
|
|
3247
|
+
} else {
|
|
3248
|
+
selectedValue = finalValue;
|
|
3249
|
+
}
|
|
3250
|
+
updateUI();
|
|
3251
|
+
const changeEvent = new CustomEvent(`${PREFIX5}-chip:change`, {
|
|
3252
|
+
detail: { value: isMultiple ? getNormalizedSelected() : selectedValue },
|
|
3253
|
+
bubbles: true
|
|
3254
|
+
});
|
|
3255
|
+
container.dispatchEvent(changeEvent);
|
|
3256
|
+
};
|
|
3186
3257
|
items.forEach((item, index2) => {
|
|
3187
3258
|
item.addEventListener("click", (e) => {
|
|
3188
3259
|
if (item.hasAttribute("disabled")) return;
|
|
3189
3260
|
currentFocusedIndex = index2;
|
|
3190
3261
|
const val = item.getAttribute("data-value");
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3262
|
+
if (showCustomization && isToggleBtn(item)) {
|
|
3263
|
+
const normSelected = getNormalizedSelected();
|
|
3264
|
+
const standardValues = Array.from(items).filter((i) => !isToggleBtn(i)).map((i) => i.getAttribute("data-value"));
|
|
3265
|
+
const customValues = normSelected.filter(
|
|
3266
|
+
(v) => !standardValues.includes(v) && v !== "" && v !== val
|
|
3267
|
+
);
|
|
3268
|
+
const isInputVisible = normSelected.includes(val) || customValues.length > 0;
|
|
3269
|
+
if (!isInputVisible) {
|
|
3270
|
+
handleSelect(val);
|
|
3271
|
+
}
|
|
3194
3272
|
} else {
|
|
3195
3273
|
handleSelect(val);
|
|
3196
3274
|
}
|
|
@@ -3214,22 +3292,7 @@ function initChip(rootSelector = `.${PREFIX5}-chip`) {
|
|
|
3214
3292
|
}
|
|
3215
3293
|
if (e.key === " " || e.key === "Enter") {
|
|
3216
3294
|
e.preventDefault();
|
|
3217
|
-
|
|
3218
|
-
const label = item.textContent.trim();
|
|
3219
|
-
if (showCustomization && label === customizationLabel) {
|
|
3220
|
-
handleSelect(val);
|
|
3221
|
-
setTimeout(() => {
|
|
3222
|
-
const customFieldContainer2 = container.querySelector(
|
|
3223
|
-
`.${PREFIX5}-chip__custom-field`
|
|
3224
|
-
);
|
|
3225
|
-
if (customFieldContainer2) {
|
|
3226
|
-
const inputEl = customFieldContainer2.querySelector("input");
|
|
3227
|
-
if (inputEl) inputEl.focus();
|
|
3228
|
-
}
|
|
3229
|
-
}, 50);
|
|
3230
|
-
} else {
|
|
3231
|
-
handleSelect(val);
|
|
3232
|
-
}
|
|
3295
|
+
item.click();
|
|
3233
3296
|
}
|
|
3234
3297
|
});
|
|
3235
3298
|
});
|
|
@@ -3423,6 +3486,28 @@ function initPagination() {
|
|
|
3423
3486
|
lastBtn.addEventListener("click", () => {
|
|
3424
3487
|
if (!isDisabled && currentPage < totalPages) goToPage(totalPages);
|
|
3425
3488
|
});
|
|
3489
|
+
if (navButtonsContainer && !navButtonsContainer.__inaKeyboardSet) {
|
|
3490
|
+
navButtonsContainer.addEventListener("keydown", (e) => {
|
|
3491
|
+
if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
|
|
3492
|
+
const focusable = Array.from(
|
|
3493
|
+
navButtonsContainer.querySelectorAll("button:not([disabled])")
|
|
3494
|
+
);
|
|
3495
|
+
if (!focusable.length) return;
|
|
3496
|
+
const currentIndex = focusable.indexOf(document.activeElement);
|
|
3497
|
+
if (currentIndex >= 0) {
|
|
3498
|
+
e.preventDefault();
|
|
3499
|
+
const nextIndex = e.key === "ArrowRight" ? (currentIndex + 1) % focusable.length : (currentIndex - 1 + focusable.length) % focusable.length;
|
|
3500
|
+
focusable[nextIndex]?.focus();
|
|
3501
|
+
}
|
|
3502
|
+
} else if (e.key === "Enter" || e.key === " ") {
|
|
3503
|
+
if (document.activeElement && document.activeElement.tagName === "BUTTON") {
|
|
3504
|
+
e.preventDefault();
|
|
3505
|
+
document.activeElement.click();
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
});
|
|
3509
|
+
navButtonsContainer.__inaKeyboardSet = true;
|
|
3510
|
+
}
|
|
3426
3511
|
if (pageSizeSelect) {
|
|
3427
3512
|
pageSizeSelect.addEventListener("change", (e) => {
|
|
3428
3513
|
if (isDisabled) return;
|