@varlet/ui 3.8.1 → 3.8.2
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/es/action-sheet/style/index.mjs +1 -1
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/menu-select/MenuSelect.mjs +24 -1
- package/es/utils/elements.mjs +14 -9
- package/es/varlet.esm.js +2502 -2484
- package/highlight/web-types.en-US.json +1 -1
- package/highlight/web-types.zh-CN.json +1 -1
- package/lib/varlet.cjs.js +39 -11
- package/package.json +7 -7
- package/umd/varlet.js +5 -5
package/es/index.bundle.mjs
CHANGED
|
@@ -280,7 +280,7 @@ import './tooltip/style/index.mjs'
|
|
|
280
280
|
import './uploader/style/index.mjs'
|
|
281
281
|
import './watermark/style/index.mjs'
|
|
282
282
|
|
|
283
|
-
const version = '3.8.
|
|
283
|
+
const version = '3.8.2'
|
|
284
284
|
|
|
285
285
|
function install(app) {
|
|
286
286
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/index.mjs
CHANGED
|
@@ -186,7 +186,7 @@ export * from './tooltip/index.mjs'
|
|
|
186
186
|
export * from './uploader/index.mjs'
|
|
187
187
|
export * from './watermark/index.mjs'
|
|
188
188
|
|
|
189
|
-
const version = '3.8.
|
|
189
|
+
const version = '3.8.2'
|
|
190
190
|
|
|
191
191
|
function install(app) {
|
|
192
192
|
ActionSheet.install && app.use(ActionSheet)
|
|
@@ -285,8 +285,31 @@ const __sfc__ = defineComponent({
|
|
|
285
285
|
return;
|
|
286
286
|
}
|
|
287
287
|
if (key === "ArrowDown" || key === "ArrowUp") {
|
|
288
|
-
focusChildElementByKey(
|
|
288
|
+
focusChildElementByKey(
|
|
289
|
+
menu.value.$el,
|
|
290
|
+
menuOptionsRef.value,
|
|
291
|
+
key,
|
|
292
|
+
(activeElement, nextActiveElement, isActiveInReferenceElements) => {
|
|
293
|
+
if (isActiveInReferenceElements) {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
return getActiveElementParent(activeElement) === getActiveElementParent(nextActiveElement);
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function getActiveElementParent(activeElement) {
|
|
302
|
+
var _a, _b, _c;
|
|
303
|
+
if (activeElement.classList.contains("var-menu-option--children-trigger")) {
|
|
304
|
+
return (_a = activeElement.parentNode) == null ? void 0 : _a.parentNode;
|
|
305
|
+
}
|
|
306
|
+
if (activeElement.classList.contains("var-checkbox__action")) {
|
|
307
|
+
const optionElement = (_c = (_b = activeElement.parentNode) == null ? void 0 : _b.parentNode) == null ? void 0 : _c.parentNode;
|
|
308
|
+
if (optionElement) {
|
|
309
|
+
return getActiveElementParent(optionElement);
|
|
310
|
+
}
|
|
289
311
|
}
|
|
312
|
+
return activeElement.parentNode;
|
|
290
313
|
}
|
|
291
314
|
function allowChildrenClose(option) {
|
|
292
315
|
var _a;
|
package/es/utils/elements.mjs
CHANGED
|
@@ -171,37 +171,42 @@ function isDisplayNoneElement(element) {
|
|
|
171
171
|
return false;
|
|
172
172
|
}
|
|
173
173
|
const focusableSelector = ["button", "input", "select", "textarea", "[tabindex]", "[href]"].map((s) => `${s}:not([disabled])`).join(", ");
|
|
174
|
-
function focusChildElementByKey(
|
|
175
|
-
var _a;
|
|
174
|
+
function focusChildElementByKey(referenceElement, parentElement, key, beforeFocus) {
|
|
176
175
|
const focusableElements = Array.from(parentElement.querySelectorAll(focusableSelector)).filter(
|
|
177
176
|
(element) => !isDisplayNoneElement(element)
|
|
178
177
|
);
|
|
179
178
|
if (!focusableElements.length) {
|
|
180
179
|
return;
|
|
181
180
|
}
|
|
182
|
-
const
|
|
181
|
+
const isActiveInReferenceElements = [referenceElement, ...Array.from(referenceElement.querySelectorAll(focusableSelector))].findIndex(
|
|
183
182
|
(el) => el === document.activeElement
|
|
184
183
|
) !== -1;
|
|
185
184
|
const activeElementIndex = Array.from(focusableElements).findIndex((el) => el === document.activeElement);
|
|
186
185
|
if (key === "ArrowDown") {
|
|
187
|
-
if (
|
|
188
|
-
focusableElements[0]
|
|
186
|
+
if (isActiveInReferenceElements && activeElementIndex === -1 || activeElementIndex === focusableElements.length - 1) {
|
|
187
|
+
focus(focusableElements[0]);
|
|
189
188
|
return;
|
|
190
189
|
}
|
|
191
190
|
if (activeElementIndex !== -1 && activeElementIndex < focusableElements.length - 1) {
|
|
192
|
-
focusableElements[activeElementIndex + 1]
|
|
191
|
+
focus(focusableElements[activeElementIndex + 1]);
|
|
193
192
|
return;
|
|
194
193
|
}
|
|
195
194
|
}
|
|
196
195
|
if (key === "ArrowUp") {
|
|
197
|
-
if (
|
|
198
|
-
(
|
|
196
|
+
if (isActiveInReferenceElements && activeElementIndex === -1 || activeElementIndex === 0) {
|
|
197
|
+
focus(focusableElements[focusableElements.length - 1]);
|
|
199
198
|
return;
|
|
200
199
|
}
|
|
201
200
|
if (activeElementIndex > 0) {
|
|
202
|
-
focusableElements[activeElementIndex - 1]
|
|
201
|
+
focus(focusableElements[activeElementIndex - 1]);
|
|
203
202
|
}
|
|
204
203
|
}
|
|
204
|
+
function focus(nextActiveElement) {
|
|
205
|
+
if (beforeFocus && !beforeFocus(document.activeElement, nextActiveElement, isActiveInReferenceElements)) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
nextActiveElement.focus();
|
|
209
|
+
}
|
|
205
210
|
}
|
|
206
211
|
export {
|
|
207
212
|
focusChildElementByKey,
|