@astryx-vue/core 0.26.1 → 0.28.0
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/AlertDialog/index.js +1 -1
- package/dist/{AlertDialog-CGGkPG4T.js → AlertDialog-B195FgtL.js} +2 -2
- package/dist/AppShell/index.js +1 -1
- package/dist/{AppShell-DGJgCvS6.js → AppShell-Da255Ktm.js} +3 -3
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/Banner/index.d.ts +1 -1
- package/dist/BottomSheet/index.d.ts +1 -1
- package/dist/Breadcrumbs/index.d.ts +2 -2
- package/dist/Breadcrumbs/index.js +2 -2
- package/dist/{Breadcrumbs-BZsjHn_5.js → Breadcrumbs-CmtcXM4e.js} +1 -1
- package/dist/Button/index.d.ts +1 -1
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/Calendar/index.d.ts +1 -1
- package/dist/Carousel/index.d.ts +1 -1
- package/dist/Center/index.d.ts +1 -1
- package/dist/Chat/index.d.ts +1 -1
- package/dist/Chat/index.js +1 -1
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxList/index.d.ts +1 -1
- package/dist/CheckboxList/index.js +1 -1
- package/dist/{CheckboxList-CWHlG8Jq.js → CheckboxList-DGM-cgX5.js} +2 -2
- package/dist/ClickableCard/index.d.ts +1 -1
- package/dist/ClickableCard/index.js +1 -1
- package/dist/Collapsible/index.js +1 -1
- package/dist/{Collapsible-BSRdsb6w.js → Collapsible-B2vrr_YP.js} +2 -2
- package/dist/ComplexSelector/index.js +1 -1
- package/dist/{ComplexSelector-DI3J30Ho.js → ComplexSelector-Dq9esodQ.js} +1 -1
- package/dist/ContextMenu/index.d.ts +2 -2
- package/dist/ContextMenu/index.js +2 -2
- package/dist/{ContextMenu-CVf4OqJP.js → ContextMenu-DB4XcNKf.js} +1 -1
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-DK-FI37x.js → DateInput-DNqm49AX.js} +1 -1
- package/dist/DateRangeInput/index.d.ts +1 -1
- package/dist/DateRangeInput/index.js +1 -1
- package/dist/{DateRangeInput-ClriBc4F.js → DateRangeInput-Bch513M0.js} +1 -1
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.js +1 -1
- package/dist/{DateTimeInput-BdXkBBYi.js → DateTimeInput-BCFgCeNy.js} +1 -1
- package/dist/Dialog/index.d.ts +1 -1
- package/dist/Divider/index.d.ts +1 -1
- package/dist/Drawer/index.d.ts +1 -1
- package/dist/DropdownMenu/index.d.ts +2 -2
- package/dist/DropdownMenu/index.js +3 -3
- package/dist/{DropdownMenu-CdwEvDld.js → DropdownMenu-D9swCben.js} +3 -3
- package/dist/{DropdownMenu-q5euMYv-.js → DropdownMenu-DlfMGzZ2.js} +3 -33
- package/dist/{DropdownMenuRadioItem.vue-DINRx71W.d.ts → DropdownMenuRadioItem.vue-C8rePTyz.d.ts} +1 -1
- package/dist/HoverCard/index.d.ts +1 -1
- package/dist/InfoTip/index.d.ts +1 -1
- package/dist/InternationalizationProvider/index.d.ts +1 -1
- package/dist/InternationalizationProvider/index.js +1 -1
- package/dist/{InternationalizationProvider-8qllKdVk.js → InternationalizationProvider-CEmlN48L.js} +1 -1
- package/dist/{Item-DUI1Qnnd.js → Item-C8UAQwFQ.js} +193 -111
- package/dist/Link/index.d.ts +1 -1
- package/dist/List/index.d.ts +2 -2
- package/dist/List/index.js +2 -2
- package/dist/{ListItem-C8SqSrU6.js → ListItem-BlrEngDO.js} +11 -3
- package/dist/MetadataList/index.d.ts +1 -1
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-DAq29azZ.js → MoreMenu-GPcHAauX.js} +3 -1
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/NavItem/index.d.ts +1 -1
- package/dist/NavItem/index.js +1 -1
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/Outline/index.js +1 -1
- package/dist/{Outline-DvQbXc_H.js → Outline-DI9MZnuQ.js} +106 -50
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/Pagination/index.d.ts +1 -1
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-CRrou1P-.js → Pagination-BNPBvFW1.js} +2 -2
- package/dist/Popover/index.d.ts +1 -1
- package/dist/Popover/index.js +1 -1
- package/dist/{Popover-sERt08TR.js → Popover-MJQZog5m.js} +2 -2
- package/dist/PowerSearch/index.d.ts +1 -1
- package/dist/PowerSearch/index.js +1 -1
- package/dist/{PowerSearch-CiVIW13b.js → PowerSearch-Bv-yUo6C.js} +10 -8
- package/dist/Radio/index.d.ts +1 -1
- package/dist/RadioList/index.d.ts +1 -1
- package/dist/ScrollableArea/index.d.ts +1 -1
- package/dist/SelectableCard/index.d.ts +1 -1
- package/dist/Selector/index.d.ts +1 -1
- package/dist/Selector/index.js +1 -1
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +2 -2
- package/dist/{SideNav-CHSwzwTt.js → SideNav-B_0Fv-ZU.js} +4 -4
- package/dist/Stack/index.d.ts +1 -1
- package/dist/Stepper/index.d.ts +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/TabList/index.d.ts +1 -1
- package/dist/Table/index.d.ts +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/{Table-DEqfIA3q.js → Table-B0Aj43zB.js} +9 -9
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/TimeInput/index.d.ts +1 -1
- package/dist/Timestamp/index.d.ts +1 -1
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/Token/index.d.ts +1 -1
- package/dist/Tokenizer/index.d.ts +2 -2
- package/dist/Tokenizer/index.js +1 -1
- package/dist/Tokenizer-iJb-WZ55.js +2067 -0
- package/dist/Toolbar/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/TopNav/index.d.ts +1 -1
- package/dist/TopNav/index.js +1 -1
- package/dist/{TopNav-Ce79A3zT.js → TopNav-ctvKlpxf.js} +1 -1
- package/dist/TreeList/index.d.ts +1 -1
- package/dist/TreeList/index.js +1 -1
- package/dist/{TreeList-BEPHdVYu.js → TreeList-Dh0uAj2B.js} +48 -7
- package/dist/Typeahead/index.d.ts +1 -1
- package/dist/Typeahead/index.js +2 -2
- package/dist/{Typeahead-CBrUdbHv.js → Typeahead-D2O3n477.js} +1 -1
- package/dist/{animator-BooLoGyI.js → animator-BGq5a6vT.js} +4 -300
- package/dist/{batch-CM-vJhQg.js → batch-BhaAWUIt.js} +3 -2
- package/dist/{bezier-Cts7gENO.js → bezier-Df-yGuNZ.js} +1 -90
- package/dist/composables/index.js +2 -1
- package/dist/{composables-BtqijTIO.js → composables-BTRbNgmR.js} +4 -41
- package/dist/{context-DH8E-qjm.js → context-jtpQfR6F.js} +1 -1
- package/dist/{edge-BYXwSggM.js → edge-CJIswPTX.js} +1 -1
- package/dist/{edgeRide-B5mlN2Q4.js → edgeRide-Drk4V-MC.js} +2 -2
- package/dist/{index-ZbNwGVkS.d.ts → index-BKnyTWPM.d.ts} +1 -1
- package/dist/{index-DeZ11MNP.d.ts → index-BLsYMZgA.d.ts} +4 -4
- package/dist/{index-D7ShT2c-.d.ts → index-BgT6mH3U.d.ts} +1 -1
- package/dist/{index-BD-Pxni9.d.ts → index-BhxqUt3y.d.ts} +1 -1
- package/dist/{index-LqFjvL4C.d.ts → index-Bu4R0WZA.d.ts} +21 -5
- package/dist/{index-B5aHF0Ml.d.ts → index-C0nKJSA2.d.ts} +1 -1
- package/dist/{index-DlKz3dB1.d.ts → index-C6IcBhAn.d.ts} +2 -2
- package/dist/{index-Cm36VS1A.d.ts → index-C9uW39Mj.d.ts} +1 -1
- package/dist/{index-CnOH43-f.d.ts → index-CBH9Gyte.d.ts} +1 -1
- package/dist/{index-CRtGmCHi.d.ts → index-CEtFUoIm.d.ts} +1 -1
- package/dist/{index-C4S65SAW.d.ts → index-CKnr0JlT.d.ts} +1 -1
- package/dist/{index-BdhQpERn.d.ts → index-CMZnO7VU.d.ts} +4 -4
- package/dist/{index-DY1kpap1.d.ts → index-CkzTX9pb.d.ts} +42 -42
- package/dist/{index-DSMv6W8s.d.ts → index-Ct6SEtjd.d.ts} +4 -4
- package/dist/{index-C8wfe0Mr.d.ts → index-D05JGsT3.d.ts} +1 -1
- package/dist/{index-FeZXsFO-.d.ts → index-DDrL_-hJ.d.ts} +1 -1
- package/dist/{index-DDVCVpnG.d.ts → index-DE-QPNz0.d.ts} +1 -1
- package/dist/{index-BxWCX2pJ.d.ts → index-DFLPv9io.d.ts} +3 -3
- package/dist/{index-CB6VQETg.d.ts → index-DIw5D3zj.d.ts} +2 -2
- package/dist/{index-eCp-ElSp.d.ts → index-DYabo8TI.d.ts} +1 -1
- package/dist/{index-Otl047R1.d.ts → index-DofC9Rll.d.ts} +1 -1
- package/dist/{index-C2zWUiJ1.d.ts → index-DogWVRJi.d.ts} +1 -1
- package/dist/{index-aHC2C89h.d.ts → index-Ea2V_FSK.d.ts} +4 -4
- package/dist/{index-DPklTi3o.d.ts → index-Q1oG9yIT.d.ts} +1 -1
- package/dist/{index-NOXYEdOI.d.ts → index-utZGF4GR.d.ts} +1 -1
- package/dist/index.d.ts +30 -30
- package/dist/index.js +39 -37
- package/dist/{landing-B9Uvex6x.js → landing-CBaXCGEg.js} +2 -2
- package/dist/{loadCatalog-BRd5XCbW.js → loadCatalog-Blm5sm1o.js} +36 -8
- package/dist/{loadCatalog-CLm4V7mm.d.ts → loadCatalog-DDLjLKYA.d.ts} +21 -0
- package/dist/locale/index.d.ts +2 -2
- package/dist/locale/index.js +3 -3
- package/dist/{locale-BkAezFog.js → locale-Y7dHbjs4.js} +1 -1
- package/dist/resolveMotion-CurhYTVC.js +307 -0
- package/dist/{themeTiming-CWEvdh31.js → themeTiming-BFDOPRjK.js} +1 -1
- package/dist/timing-CSHWQbTJ.js +90 -0
- package/dist/tokenizer-C1y-55Ft.js +72 -0
- package/dist/{types-Gw2OjSK9.d.ts → types-ClOMFbqC.d.ts} +2 -2
- package/dist/useAnimatedLayout-DC2l3WrE.js +40 -0
- package/dist/{useMenuDrillIn-CP0P49ej.js → useMenuDrillIn-BQx6lQMz.js} +1 -1
- package/dist/useMenuEntranceHold-buV5S9yk.js +33 -0
- package/dist/{useTypeaheadMenuConfig-DeDGVR8S.js → useTypeaheadMenuConfig-Do0jOyEm.js} +35 -35
- package/package.json +1 -1
- package/styles/list.css +102 -5
- package/styles/metadata-list.css +6 -1
- package/styles/more-menu.css +42 -35
- package/styles/outline.css +2 -1
- package/styles/sheet-confirmation.css +8 -0
- package/styles/tokenizer-sheet.css +203 -0
- package/styles.css +2 -0
- package/dist/Tokenizer-2zj57yDt.js +0 -888
- package/dist/tokenizer-ChiAuPN-.js +0 -34
- package/dist/{Chat-RE_6Ez79.js → Chat-Bg1IuDMt.js} +1 -1
- package/dist/{ClickableCard-CwGxO0GU.js → ClickableCard-ChmOwgYq.js} +1 -1
- package/dist/{NavItem-c1ScHEJY.js → NavItem-kj9FbbFS.js} +1 -1
- package/dist/{Selector-Bj4q6aT5.js → Selector-BrNA4sLV.js} +1 -1
- package/dist/{index-J6YRJ7Ul.d.ts → index-CHx33xGa.d.ts} +1 -1
|
@@ -1,888 +0,0 @@
|
|
|
1
|
-
import { i as useSize } from "./SizeContext-BbaF-SEx.js";
|
|
2
|
-
import { s as isImeKeyEvent } from "./layerDepth-D3Rh8T5C.js";
|
|
3
|
-
import { a as trackInteractionModality, t as getInteractionModality } from "./interactionModality-4Km2ibsq.js";
|
|
4
|
-
import { t as _sfc_main$1 } from "./ButtonTooltip-CNKOQHYR.js";
|
|
5
|
-
import { t as useButtonTooltip } from "./useButtonTooltip-DjCaZMp_.js";
|
|
6
|
-
import { n as isDevBuild, t as devPropError } from "./devBuild-G249YcdZ.js";
|
|
7
|
-
import { t as useAnnounce } from "./announce-GU01Oix2.js";
|
|
8
|
-
import { t as useInputStatusIcon } from "./useInputStatusIcon-CGj9gMj8.js";
|
|
9
|
-
import { o as useComponentMessages } from "./context-B8IEFCDR.js";
|
|
10
|
-
import { t as useOverflow } from "./useOverflow-GU0pxGaU.js";
|
|
11
|
-
import { t as useResolvedLabelHidden } from "./useResolvedLabelHidden-B2rlWiaI.js";
|
|
12
|
-
import { t as useScrollbars } from "./useScrollbars-Ch0xqJWO.js";
|
|
13
|
-
import { t as useBusyAnnouncement } from "./busyAnnouncement-CExubuYm.js";
|
|
14
|
-
import { t as _sfc_main$2 } from "./Field-DrUMz0oj.js";
|
|
15
|
-
import { t as useFieldPartStyling } from "./fieldParts-CuE5V12i.js";
|
|
16
|
-
import { t as tokenizerMessages } from "./tokenizer-ChiAuPN-.js";
|
|
17
|
-
import { t as _sfc_main$3 } from "./Token-C7Dt5ygK.js";
|
|
18
|
-
import { n as scrollOptionIntoView, r as useAnchoredListbox } from "./stillPointerGate-D3loXLh7.js";
|
|
19
|
-
import { a as useLatchedOptionGrid, n as useTypeaheadAnnouncement, o as useTypeaheadMenu, r as _sfc_main$4, t as useTypeaheadMenuConfig } from "./useTypeaheadMenuConfig-DeDGVR8S.js";
|
|
20
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createVNode, defineComponent, guardReactiveProps, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useAttrs, useId, useTemplateRef, watch, withCtx } from "vue";
|
|
21
|
-
import "../styles/layer.css";
|
|
22
|
-
import "../styles/visually-hidden-utility.css";
|
|
23
|
-
import "../styles/typeahead.css";
|
|
24
|
-
import "../styles/tokenizer.css";
|
|
25
|
-
//#region src/composables/internal/useTokenRemoveTap.ts
|
|
26
|
-
/**
|
|
27
|
-
* 手指点 Token 自带的删除按钮时,别把触屏键盘弹起来。
|
|
28
|
-
*
|
|
29
|
-
* 触屏浏览器在一次点按里聚焦输入框就会弹出键盘。标签输入框删掉一个标签后
|
|
30
|
-
* 默认把焦点交回输入框,于是手指每删一个标签都要再收一次键盘。这里记下
|
|
31
|
-
* 字段里最近一次按下:手指按在删除按钮上、而输入框当时没有焦点(键盘是收着的)
|
|
32
|
-
* 时,删除后焦点留在原处,被按的删除按钮也不接焦点。鼠标、笔、按键删除,
|
|
33
|
-
* 以及键盘已经弹起时的点按,都照旧把焦点交回输入框。
|
|
34
|
-
*/
|
|
35
|
-
/** Token 自带的删除按钮。自定义插槽画的删除控件不算。 */
|
|
36
|
-
const TOKEN_REMOVE_SELECTOR = ".astryx-token-remove";
|
|
37
|
-
function removeControlOf(target) {
|
|
38
|
-
return target instanceof Element ? target.closest(TOKEN_REMOVE_SELECTOR) : null;
|
|
39
|
-
}
|
|
40
|
-
function useTokenRemoveTap(options) {
|
|
41
|
-
trackInteractionModality();
|
|
42
|
-
let press = null;
|
|
43
|
-
let endTimer;
|
|
44
|
-
/** 键盘是收着的:最近一次是手指按下,当时输入框没有焦点,之后也没按过键。 */
|
|
45
|
-
function wasKeyboardDown() {
|
|
46
|
-
return press != null && press.isFinger && !press.inputHadFocus && getInteractionModality() === "pointer";
|
|
47
|
-
}
|
|
48
|
-
function onPointerDown(event) {
|
|
49
|
-
clearTimeout(endTimer);
|
|
50
|
-
const input = options.input.value;
|
|
51
|
-
press = {
|
|
52
|
-
inputHadFocus: input != null && input.ownerDocument.activeElement === input,
|
|
53
|
-
isFinger: event.pointerType === "touch",
|
|
54
|
-
pressedRemove: removeControlOf(event.target)
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
/** 手指点按后浏览器补发的 mousedown 会让按钮抢到焦点,键盘收着时取消它。 */
|
|
58
|
-
function onMouseDown(event) {
|
|
59
|
-
if (removeControlOf(event.target) != null && wasKeyboardDown()) event.preventDefault();
|
|
60
|
-
}
|
|
61
|
-
/** 这次按下的记录随点按结束:click 所在的任务跑完,或者浏览器把按下接管成滚动。 */
|
|
62
|
-
function onClick() {
|
|
63
|
-
clearTimeout(endTimer);
|
|
64
|
-
endTimer = setTimeout(() => {
|
|
65
|
-
press = null;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function onPointerCancel() {
|
|
69
|
-
press = null;
|
|
70
|
-
}
|
|
71
|
-
const listeners = [
|
|
72
|
-
["pointerdown", onPointerDown],
|
|
73
|
-
["mousedown", onMouseDown],
|
|
74
|
-
["click", onClick],
|
|
75
|
-
["pointercancel", onPointerCancel]
|
|
76
|
-
];
|
|
77
|
-
let boundTo = null;
|
|
78
|
-
function bindTo(element) {
|
|
79
|
-
if (element === boundTo) return;
|
|
80
|
-
for (const [type, listener] of listeners) {
|
|
81
|
-
boundTo?.removeEventListener(type, listener, true);
|
|
82
|
-
element?.addEventListener(type, listener, true);
|
|
83
|
-
}
|
|
84
|
-
boundTo = element;
|
|
85
|
-
}
|
|
86
|
-
onMounted(() => bindTo(options.root.value));
|
|
87
|
-
watch(options.root, (element) => bindTo(element), { flush: "post" });
|
|
88
|
-
onBeforeUnmount(() => {
|
|
89
|
-
clearTimeout(endTimer);
|
|
90
|
-
bindTo(null);
|
|
91
|
-
});
|
|
92
|
-
function shouldFocusInputAfterRemove() {
|
|
93
|
-
const pressed = wasKeyboardDown() ? press?.pressedRemove ?? null : null;
|
|
94
|
-
if (pressed == null) return true;
|
|
95
|
-
const active = pressed.ownerDocument.activeElement;
|
|
96
|
-
const token = pressed.closest(options.tokenSelector) ?? pressed;
|
|
97
|
-
return active != null && token.contains(active);
|
|
98
|
-
}
|
|
99
|
-
return { shouldFocusInputAfterRemove };
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/Tokenizer/inputAttrs.ts
|
|
103
|
-
/**
|
|
104
|
-
* 这些属性由组件自己算,不能让外面透传的值盖掉。
|
|
105
|
-
* 其余的原生属性和事件监听(@keydown / @focus / @blur …)原样落到输入框上。
|
|
106
|
-
*/
|
|
107
|
-
const controlledAttrs = /* @__PURE__ */ new Set([
|
|
108
|
-
"id",
|
|
109
|
-
"type",
|
|
110
|
-
"role",
|
|
111
|
-
"value",
|
|
112
|
-
"class",
|
|
113
|
-
"style",
|
|
114
|
-
"disabled",
|
|
115
|
-
"readonly",
|
|
116
|
-
"autofocus",
|
|
117
|
-
"placeholder",
|
|
118
|
-
"tabindex",
|
|
119
|
-
"autocomplete",
|
|
120
|
-
"aria-labelledby",
|
|
121
|
-
"aria-describedby",
|
|
122
|
-
"aria-invalid",
|
|
123
|
-
"aria-expanded",
|
|
124
|
-
"aria-controls",
|
|
125
|
-
"aria-activedescendant",
|
|
126
|
-
"aria-autocomplete",
|
|
127
|
-
"aria-disabled",
|
|
128
|
-
"aria-required"
|
|
129
|
-
]);
|
|
130
|
-
/** 去掉组件自己控制的属性,剩下的落到输入框上。 */
|
|
131
|
-
function pickInputAttrs(attrs) {
|
|
132
|
-
return Object.fromEntries(Object.entries(attrs).filter(([key]) => !controlledAttrs.has(key)));
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/Tokenizer/useTokenizerDisabled.ts
|
|
136
|
-
/**
|
|
137
|
-
* 禁用的 Tokenizer 仍是 Tab 停点:输入框用 aria-disabled 加只读,不用原生 disabled,
|
|
138
|
-
* 有禁用说明时悬停和键盘聚焦都能读到它。
|
|
139
|
-
* 例外是 `overflow="unfocused-layer"` 且没有说明:输入框在失焦时才展开的浮层里,
|
|
140
|
-
* 禁用的字段打不开那层,此时仍用原生 disabled。
|
|
141
|
-
*/
|
|
142
|
-
function useTokenizerDisabled(props) {
|
|
143
|
-
/** 新名 disabledMessage 优先,旧名 disabledReason 继续可用。 */
|
|
144
|
-
const disabledMessage = computed(() => {
|
|
145
|
-
const message = props.disabledMessage?.trim() ? props.disabledMessage : props.disabledReason;
|
|
146
|
-
return message?.trim() ? message : void 0;
|
|
147
|
-
});
|
|
148
|
-
const showsDisabledMessage = computed(() => Boolean(props.disabled) && Boolean(disabledMessage.value));
|
|
149
|
-
return {
|
|
150
|
-
disabledMessage,
|
|
151
|
-
showsDisabledMessage,
|
|
152
|
-
focusableDisabled: computed(() => Boolean(props.disabled) && (showsDisabledMessage.value || props.overflow !== "unfocused-layer")),
|
|
153
|
-
disabledTooltip: useButtonTooltip(showsDisabledMessage)
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/Tokenizer/useTokenizerFieldAria.ts
|
|
158
|
-
/** 输入框的名字、说明和状态图标。 */
|
|
159
|
-
function useTokenizerFieldAria(options) {
|
|
160
|
-
const { props, attrs, inputId, fieldLabelId, disabledId, hasDisabledDescription } = options;
|
|
161
|
-
const fieldStatus = computed(() => {
|
|
162
|
-
if (!props.statusMessage || props.status === "default") return void 0;
|
|
163
|
-
return {
|
|
164
|
-
type: props.status,
|
|
165
|
-
message: props.statusMessage
|
|
166
|
-
};
|
|
167
|
-
});
|
|
168
|
-
/** 调用方的 aria-labelledby 接在字段自己的标签后面,不取代它。 */
|
|
169
|
-
const labelledBy = computed(() => {
|
|
170
|
-
const external = attrs["aria-labelledby"];
|
|
171
|
-
return typeof external === "string" && external !== "" ? `${fieldLabelId} ${external}` : void 0;
|
|
172
|
-
});
|
|
173
|
-
const { statusIcon, statusIconProps } = useInputStatusIcon({
|
|
174
|
-
status: () => fieldStatus.value,
|
|
175
|
-
statusVariant: () => props.statusVariant ?? "attached"
|
|
176
|
-
});
|
|
177
|
-
return {
|
|
178
|
-
fieldStatus,
|
|
179
|
-
labelledBy,
|
|
180
|
-
statusIcon,
|
|
181
|
-
statusIconProps,
|
|
182
|
-
describedBy: computed(() => {
|
|
183
|
-
return [
|
|
184
|
-
typeof attrs["aria-describedby"] === "string" ? attrs["aria-describedby"] : void 0,
|
|
185
|
-
props.description ? `${inputId}-description` : void 0,
|
|
186
|
-
props.statusMessage ? `${inputId}-status` : void 0,
|
|
187
|
-
hasDisabledDescription.value ? disabledId : void 0
|
|
188
|
-
].filter(Boolean).join(" ") || void 0;
|
|
189
|
-
})
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region src/Tokenizer/useTokenizerKeys.ts
|
|
194
|
-
/** 输入框和标签上的按键:退格删最后一个、方向键在标签和输入框之间移动焦点。 */
|
|
195
|
-
function useTokenizerKeys(options) {
|
|
196
|
-
const { values, menu, optionGrid, inputRef, remove, focusToken } = options;
|
|
197
|
-
function onInputKeyDown(event) {
|
|
198
|
-
if (event.defaultPrevented || isImeKeyEvent(event)) return;
|
|
199
|
-
if (optionGrid.actionGrid.onKeyDown(event)) return;
|
|
200
|
-
const input = inputRef.value;
|
|
201
|
-
if (event.key === "Backspace" && menu.query.value === "" && values.value.length > 0) {
|
|
202
|
-
event.preventDefault();
|
|
203
|
-
const last = values.value[values.value.length - 1];
|
|
204
|
-
if (last) remove(last);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
if (event.key === "ArrowLeft" && input && input.selectionStart === 0 && input.selectionEnd === 0 && values.value.length > 0) {
|
|
208
|
-
event.preventDefault();
|
|
209
|
-
focusToken(values.value.length - 1);
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
menu.onKeyDown(event);
|
|
213
|
-
}
|
|
214
|
-
function onTokenKeyDown(event, item, index) {
|
|
215
|
-
if (event.key === "ArrowLeft" && index > 0) {
|
|
216
|
-
event.preventDefault();
|
|
217
|
-
focusToken(index - 1);
|
|
218
|
-
} else if (event.key === "ArrowRight") {
|
|
219
|
-
event.preventDefault();
|
|
220
|
-
if (index < values.value.length - 1) focusToken(index + 1);
|
|
221
|
-
else inputRef.value?.focus();
|
|
222
|
-
} else if (event.key === "Escape") inputRef.value?.focus();
|
|
223
|
-
else if (!options.disabled() && (event.key === "Backspace" || event.key === "Delete")) {
|
|
224
|
-
event.preventDefault();
|
|
225
|
-
remove(item);
|
|
226
|
-
if (index > 0) focusToken(index - 1);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return {
|
|
230
|
-
onInputKeyDown,
|
|
231
|
-
onTokenKeyDown
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/Tokenizer/Tokenizer.vue
|
|
236
|
-
const _hoisted_1 = {
|
|
237
|
-
key: 0,
|
|
238
|
-
class: "astryx-tokenizer-icon",
|
|
239
|
-
"aria-hidden": "true"
|
|
240
|
-
};
|
|
241
|
-
const _hoisted_2 = ["onKeydown"];
|
|
242
|
-
const _hoisted_3 = {
|
|
243
|
-
key: 0,
|
|
244
|
-
class: "astryx-tokenizer-more"
|
|
245
|
-
};
|
|
246
|
-
const _hoisted_4 = {
|
|
247
|
-
class: "astryx-tokenizer-more",
|
|
248
|
-
"data-overflow-indicator": ""
|
|
249
|
-
};
|
|
250
|
-
const _hoisted_5 = [
|
|
251
|
-
"data-autofocus",
|
|
252
|
-
"placeholder",
|
|
253
|
-
"value",
|
|
254
|
-
"disabled",
|
|
255
|
-
"readonly",
|
|
256
|
-
"aria-disabled",
|
|
257
|
-
"aria-expanded",
|
|
258
|
-
"aria-haspopup",
|
|
259
|
-
"aria-activedescendant",
|
|
260
|
-
"aria-labelledby",
|
|
261
|
-
"aria-describedby",
|
|
262
|
-
"aria-required",
|
|
263
|
-
"aria-invalid"
|
|
264
|
-
];
|
|
265
|
-
const _hoisted_6 = ["aria-label"];
|
|
266
|
-
const _hoisted_7 = [
|
|
267
|
-
"name",
|
|
268
|
-
"value",
|
|
269
|
-
"disabled"
|
|
270
|
-
];
|
|
271
|
-
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
272
|
-
name: "AstryxTokenizer",
|
|
273
|
-
inheritAttrs: false,
|
|
274
|
-
__name: "Tokenizer",
|
|
275
|
-
props: {
|
|
276
|
-
modelValue: { default: () => [] },
|
|
277
|
-
menu: {},
|
|
278
|
-
searchSource: {},
|
|
279
|
-
label: {},
|
|
280
|
-
isLabelHidden: { type: Boolean },
|
|
281
|
-
labelHidden: {
|
|
282
|
-
type: Boolean,
|
|
283
|
-
default: false
|
|
284
|
-
},
|
|
285
|
-
description: {},
|
|
286
|
-
labelTooltip: {},
|
|
287
|
-
placeholder: {},
|
|
288
|
-
disabled: {
|
|
289
|
-
type: Boolean,
|
|
290
|
-
default: false
|
|
291
|
-
},
|
|
292
|
-
disabledReason: {},
|
|
293
|
-
disabledMessage: {},
|
|
294
|
-
status: { default: "default" },
|
|
295
|
-
statusMessage: {},
|
|
296
|
-
statusVariant: { default: "attached" },
|
|
297
|
-
size: {},
|
|
298
|
-
clearable: {
|
|
299
|
-
type: Boolean,
|
|
300
|
-
default: false
|
|
301
|
-
},
|
|
302
|
-
hasClear: {
|
|
303
|
-
type: Boolean,
|
|
304
|
-
default: false
|
|
305
|
-
},
|
|
306
|
-
debounceMs: { default: 150 },
|
|
307
|
-
maxMenuItems: { default: 10 },
|
|
308
|
-
menuWidth: {},
|
|
309
|
-
minQueryLength: { default: 1 },
|
|
310
|
-
showOnFocus: {
|
|
311
|
-
type: Boolean,
|
|
312
|
-
default: false
|
|
313
|
-
},
|
|
314
|
-
hasEntriesOnFocus: { type: Boolean },
|
|
315
|
-
hasAutoFocus: {
|
|
316
|
-
type: Boolean,
|
|
317
|
-
default: false
|
|
318
|
-
},
|
|
319
|
-
emptyText: {},
|
|
320
|
-
emptySearchText: {},
|
|
321
|
-
maxEntries: {},
|
|
322
|
-
creatable: {
|
|
323
|
-
type: Boolean,
|
|
324
|
-
default: false
|
|
325
|
-
},
|
|
326
|
-
hasCreate: {
|
|
327
|
-
type: Boolean,
|
|
328
|
-
default: false
|
|
329
|
-
},
|
|
330
|
-
overflow: { default: "none" },
|
|
331
|
-
required: {
|
|
332
|
-
type: Boolean,
|
|
333
|
-
default: false
|
|
334
|
-
},
|
|
335
|
-
optional: {
|
|
336
|
-
type: Boolean,
|
|
337
|
-
default: false
|
|
338
|
-
},
|
|
339
|
-
name: {},
|
|
340
|
-
width: {},
|
|
341
|
-
containerClass: { type: [
|
|
342
|
-
Boolean,
|
|
343
|
-
null,
|
|
344
|
-
String,
|
|
345
|
-
Object,
|
|
346
|
-
Array
|
|
347
|
-
] },
|
|
348
|
-
containerStyle: { type: [
|
|
349
|
-
Boolean,
|
|
350
|
-
null,
|
|
351
|
-
String,
|
|
352
|
-
Object,
|
|
353
|
-
Array
|
|
354
|
-
] },
|
|
355
|
-
controlClass: { type: [
|
|
356
|
-
Boolean,
|
|
357
|
-
null,
|
|
358
|
-
String,
|
|
359
|
-
Object,
|
|
360
|
-
Array
|
|
361
|
-
] },
|
|
362
|
-
controlStyle: { type: [
|
|
363
|
-
Boolean,
|
|
364
|
-
null,
|
|
365
|
-
String,
|
|
366
|
-
Object,
|
|
367
|
-
Array
|
|
368
|
-
] }
|
|
369
|
-
},
|
|
370
|
-
emits: [
|
|
371
|
-
"update:modelValue",
|
|
372
|
-
"change",
|
|
373
|
-
"search",
|
|
374
|
-
"changeQuery",
|
|
375
|
-
"openChange",
|
|
376
|
-
"focus",
|
|
377
|
-
"blur"
|
|
378
|
-
],
|
|
379
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
380
|
-
const props = __props;
|
|
381
|
-
const emit = __emit;
|
|
382
|
-
if (isDevBuild() && props.modelValue != null && !Array.isArray(props.modelValue)) throw devPropError("Tokenizer", "modelValue", "must be an array of the selected items, for example v-model=\"selected\" with const selected = ref([]).");
|
|
383
|
-
const size = useSize(() => props.size, "md");
|
|
384
|
-
const attrs = useAttrs();
|
|
385
|
-
const parts = useFieldPartStyling({
|
|
386
|
-
component: "Tokenizer",
|
|
387
|
-
props,
|
|
388
|
-
attrs,
|
|
389
|
-
reservedAttrs: [
|
|
390
|
-
"id",
|
|
391
|
-
"role",
|
|
392
|
-
"aria-label",
|
|
393
|
-
"aria-labelledby",
|
|
394
|
-
"aria-describedby",
|
|
395
|
-
"aria-expanded",
|
|
396
|
-
"aria-controls",
|
|
397
|
-
"aria-haspopup",
|
|
398
|
-
"aria-activedescendant",
|
|
399
|
-
"aria-autocomplete",
|
|
400
|
-
"aria-disabled",
|
|
401
|
-
"aria-required"
|
|
402
|
-
]
|
|
403
|
-
});
|
|
404
|
-
const messages = useComponentMessages({ tokenizer: tokenizerMessages });
|
|
405
|
-
/** 正名 isLabelHidden,旧名 labelHidden 任一为真就藏起标签。 */
|
|
406
|
-
const hideLabel = useResolvedLabelHidden(() => props.isLabelHidden, () => props.labelHidden);
|
|
407
|
-
const inputId = `astryx-tokenizer-${useId()}`;
|
|
408
|
-
const listboxId = `${inputId}-listbox`;
|
|
409
|
-
const fieldLabelId = `${inputId}-label`;
|
|
410
|
-
const disabledId = `${inputId}-disabled`;
|
|
411
|
-
const disabledTooltipId = `${inputId}-disabled-tooltip`;
|
|
412
|
-
const values = computed(() => props.modelValue ?? []);
|
|
413
|
-
const focused = ref(false);
|
|
414
|
-
const placeholderHeight = ref(0);
|
|
415
|
-
const announce = useAnnounce();
|
|
416
|
-
const anchorRef = useTemplateRef("anchorRef");
|
|
417
|
-
const popupRef = useTemplateRef("popupRef");
|
|
418
|
-
const listboxRef = computed(() => popupRef.value?.el ?? null);
|
|
419
|
-
useScrollbars(listboxRef);
|
|
420
|
-
const inputRef = useTemplateRef("inputRef");
|
|
421
|
-
const tokenEls = /* @__PURE__ */ new Map();
|
|
422
|
-
const placeholder = computed(() => props.placeholder ?? messages.value.tokenizer.placeholder);
|
|
423
|
-
const emptyText = computed(() => props.emptySearchText ?? props.emptyText ?? messages.value.tokenizer.empty);
|
|
424
|
-
const { disabledMessage, showsDisabledMessage, focusableDisabled, disabledTooltip } = useTokenizerDisabled(props);
|
|
425
|
-
/** 两个名字任一为真就画清除按钮。 */
|
|
426
|
-
const showsClear = computed(() => props.hasClear || props.clearable);
|
|
427
|
-
/** 两个名字任一为真就在聚焦时先展开。 */
|
|
428
|
-
const showsEntriesOnFocus = computed(() => props.hasEntriesOnFocus || props.showOnFocus);
|
|
429
|
-
/** 两个名字任一为真就能从输入的文字新建标签。 */
|
|
430
|
-
const isCreatable = computed(() => props.hasCreate || props.creatable);
|
|
431
|
-
/** 禁用的字段不向表单交值:不渲染隐藏输入,而不是渲染一个原生禁用的。 */
|
|
432
|
-
const hiddenCarrierItems = computed(() => props.disabled ? [] : values.value);
|
|
433
|
-
const atMax = computed(() => props.maxEntries != null && values.value.length >= props.maxEntries);
|
|
434
|
-
const collapsed = computed(() => props.overflow !== "none" && !focused.value);
|
|
435
|
-
const floating = computed(() => props.overflow === "unfocused-layer" && focused.value);
|
|
436
|
-
const { fieldStatus, labelledBy, statusIcon, statusIconProps, describedBy } = useTokenizerFieldAria({
|
|
437
|
-
props,
|
|
438
|
-
attrs,
|
|
439
|
-
inputId,
|
|
440
|
-
fieldLabelId,
|
|
441
|
-
disabledId,
|
|
442
|
-
hasDisabledDescription: computed(() => focusableDisabled.value && Boolean(disabledMessage.value))
|
|
443
|
-
});
|
|
444
|
-
function inputAttrs() {
|
|
445
|
-
return pickInputAttrs(attrs);
|
|
446
|
-
}
|
|
447
|
-
const menu = useTypeaheadMenu({
|
|
448
|
-
source: () => props.searchSource,
|
|
449
|
-
debounceMs: () => props.debounceMs,
|
|
450
|
-
showOnFocus: () => showsEntriesOnFocus.value && !atMax.value,
|
|
451
|
-
minQueryLength: () => props.minQueryLength,
|
|
452
|
-
maxItems: () => props.maxMenuItems,
|
|
453
|
-
disabled: () => props.disabled || atMax.value || props.menu?.role === "dialog",
|
|
454
|
-
excludeIds: () => values.value.map((item) => item.id),
|
|
455
|
-
blockedLabels: () => values.value.map((item) => item.label),
|
|
456
|
-
creatable: () => isCreatable.value && !atMax.value,
|
|
457
|
-
createLabel: (query) => messages.value.tokenizer.create(query),
|
|
458
|
-
onSelect: (entry) => add(entry.item, entry.create ? "create" : "add"),
|
|
459
|
-
onQueryChange: (query) => {
|
|
460
|
-
emit("search", query);
|
|
461
|
-
emit("changeQuery", query);
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
/** 搜索忙碌时由输入框念一次「加载中」;列表里的转圈只是装饰。 */
|
|
465
|
-
const settleBusy = useBusyAnnouncement(() => menu.status.value === "loading", () => messages.value.tokenizer.loading, inputRef);
|
|
466
|
-
useTypeaheadAnnouncement({
|
|
467
|
-
menu,
|
|
468
|
-
settleBusy,
|
|
469
|
-
emptyText: () => emptyText.value,
|
|
470
|
-
emptySearchText: () => emptyText.value,
|
|
471
|
-
resultCount: (count) => messages.value.tokenizer.resultCount(count)
|
|
472
|
-
});
|
|
473
|
-
const menuConfig = useTypeaheadMenuConfig({
|
|
474
|
-
config: () => props.menu,
|
|
475
|
-
popupEl: () => listboxRef.value,
|
|
476
|
-
inputEl: () => inputRef.value,
|
|
477
|
-
listbox: {
|
|
478
|
-
isOpen: menu.combobox.isOpen,
|
|
479
|
-
open: () => menu.open(),
|
|
480
|
-
close: () => menu.close()
|
|
481
|
-
},
|
|
482
|
-
isDisabled: () => props.disabled,
|
|
483
|
-
canOpenList: () => showsEntriesOnFocus.value || menu.query.value !== ""
|
|
484
|
-
});
|
|
485
|
-
const anchored = useAnchoredListbox({
|
|
486
|
-
anchor: anchorRef,
|
|
487
|
-
layer: listboxRef,
|
|
488
|
-
isOpen: menuConfig.popupOpen,
|
|
489
|
-
menuWidth: () => props.menuWidth,
|
|
490
|
-
onDismiss: () => menuConfig.isDialog.value ? menuConfig.dismiss() : menu.close()
|
|
491
|
-
});
|
|
492
|
-
onMounted(() => {
|
|
493
|
-
if (props.hasAutoFocus) inputRef.value?.focus();
|
|
494
|
-
});
|
|
495
|
-
const removeTap = useTokenRemoveTap({
|
|
496
|
-
root: anchorRef,
|
|
497
|
-
input: inputRef,
|
|
498
|
-
tokenSelector: ".astryx-tokenizer-token"
|
|
499
|
-
});
|
|
500
|
-
const tokenCount = computed(() => values.value.length);
|
|
501
|
-
const overflow = useOverflow(tokenCount, { gap: 4 });
|
|
502
|
-
const visibleCount = computed(() => collapsed.value ? overflow.visibleCount.value : tokenCount.value);
|
|
503
|
-
const hiddenCount = computed(() => Math.max(0, tokenCount.value - visibleCount.value));
|
|
504
|
-
const measureMoreLabel = computed(() => messages.value.tokenizer.more(Math.max(hiddenCount.value, 1)));
|
|
505
|
-
const visibleItems = computed(() => values.value.slice(0, visibleCount.value));
|
|
506
|
-
watch(collapsed, () => void nextTick(() => overflow.remeasure()));
|
|
507
|
-
watch(menuConfig.popupOpen, (isOpen) => emit("openChange", isOpen));
|
|
508
|
-
watch(() => menu.combobox.activeIndex.value, (index) => {
|
|
509
|
-
if (!menu.combobox.isOpen.value || index < 0) return;
|
|
510
|
-
nextTick(() => scrollOptionIntoView(listboxRef.value, menu.entries.value[index]?.id));
|
|
511
|
-
});
|
|
512
|
-
function commit(next, change) {
|
|
513
|
-
emit("update:modelValue", next);
|
|
514
|
-
emit("change", next, change);
|
|
515
|
-
}
|
|
516
|
-
function add(item, type) {
|
|
517
|
-
if (props.disabled || atMax.value || values.value.some((entry) => entry.id === item.id)) return;
|
|
518
|
-
const fromFocusList = showsEntriesOnFocus.value && type === "add" && menu.query.value === "";
|
|
519
|
-
const pickedIndex = Math.max(0, menu.entries.value.findIndex((entry) => entry.item.id === item.id));
|
|
520
|
-
menuConfig.beginPick();
|
|
521
|
-
commit([...values.value, item], {
|
|
522
|
-
type,
|
|
523
|
-
item
|
|
524
|
-
});
|
|
525
|
-
announce(messages.value.tokenizer.added(item.label));
|
|
526
|
-
menu.resetQuery();
|
|
527
|
-
if (!fromFocusList && !menuConfig.endPick()) menu.close();
|
|
528
|
-
nextTick(() => {
|
|
529
|
-
inputRef.value?.focus();
|
|
530
|
-
if (!fromFocusList) return;
|
|
531
|
-
const remaining = menu.entries.value;
|
|
532
|
-
if (remaining.length === 0 || atMax.value || props.disabled) menu.close();
|
|
533
|
-
else menu.combobox.activeIndex.value = Math.min(pickedIndex, remaining.length - 1);
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
function remove(item) {
|
|
537
|
-
if (props.disabled) return;
|
|
538
|
-
commit(values.value.filter((entry) => entry.id !== item.id), {
|
|
539
|
-
type: "remove",
|
|
540
|
-
item
|
|
541
|
-
});
|
|
542
|
-
announce(messages.value.tokenizer.removed(item.label));
|
|
543
|
-
if (removeTap.shouldFocusInputAfterRemove()) nextTick(() => inputRef.value?.focus());
|
|
544
|
-
}
|
|
545
|
-
function clearAll(event) {
|
|
546
|
-
event?.stopPropagation();
|
|
547
|
-
if (props.disabled || values.value.length === 0) return;
|
|
548
|
-
commit([], { type: "clear" });
|
|
549
|
-
announce(messages.value.tokenizer.allRemoved);
|
|
550
|
-
menu.close();
|
|
551
|
-
inputRef.value?.focus();
|
|
552
|
-
}
|
|
553
|
-
function setTokenEl(index, element) {
|
|
554
|
-
if (element instanceof HTMLElement) tokenEls.set(index, element);
|
|
555
|
-
else tokenEls.delete(index);
|
|
556
|
-
}
|
|
557
|
-
function focusToken(index) {
|
|
558
|
-
nextTick(() => tokenEls.get(index)?.focus());
|
|
559
|
-
}
|
|
560
|
-
function onInput(event) {
|
|
561
|
-
if (props.disabled || atMax.value) return;
|
|
562
|
-
menu.setQuery(event.target.value);
|
|
563
|
-
}
|
|
564
|
-
/** 焦点从外面进来(而不是在字段内部换元素)才算。 */
|
|
565
|
-
function onFocusIn(event) {
|
|
566
|
-
const comingFromOutside = !isInsideTokenizer(event.relatedTarget);
|
|
567
|
-
disabledTooltip.onTooltipPointerEnter();
|
|
568
|
-
if (!focused.value && props.overflow === "unfocused-layer") placeholderHeight.value = anchorRef.value?.offsetHeight ?? 0;
|
|
569
|
-
focused.value = true;
|
|
570
|
-
if (event.target === inputRef.value && showsEntriesOnFocus.value && !props.disabled && !atMax.value) menu.open();
|
|
571
|
-
if (comingFromOutside) emit("focus", event);
|
|
572
|
-
}
|
|
573
|
-
function onFocusOut(event) {
|
|
574
|
-
disabledTooltip.onBlur();
|
|
575
|
-
if (isInsideTokenizer(event.relatedTarget)) return;
|
|
576
|
-
focused.value = false;
|
|
577
|
-
menu.close();
|
|
578
|
-
emit("blur", event);
|
|
579
|
-
}
|
|
580
|
-
function isInsideTokenizer(node) {
|
|
581
|
-
if (!(node instanceof Node)) return false;
|
|
582
|
-
return Boolean(anchorRef.value?.contains(node) || listboxRef.value?.contains(node));
|
|
583
|
-
}
|
|
584
|
-
const optionGrid = useLatchedOptionGrid({
|
|
585
|
-
entries: () => menu.entries.value,
|
|
586
|
-
isOpen: () => menu.combobox.isOpen.value,
|
|
587
|
-
activeIndex: menu.combobox.activeIndex,
|
|
588
|
-
getListbox: () => listboxRef.value,
|
|
589
|
-
listboxId: () => listboxId
|
|
590
|
-
});
|
|
591
|
-
const { onInputKeyDown: onListKeyDown, onTokenKeyDown } = useTokenizerKeys({
|
|
592
|
-
values,
|
|
593
|
-
disabled: () => props.disabled,
|
|
594
|
-
menu,
|
|
595
|
-
optionGrid,
|
|
596
|
-
inputRef,
|
|
597
|
-
remove,
|
|
598
|
-
focusToken
|
|
599
|
-
});
|
|
600
|
-
function onInputKeyDown(event) {
|
|
601
|
-
if (!menuConfig.closeOnEscape(event)) onListKeyDown(event);
|
|
602
|
-
}
|
|
603
|
-
function onFieldClick(event) {
|
|
604
|
-
if (props.disabled) return;
|
|
605
|
-
const target = event.target;
|
|
606
|
-
if (target instanceof Element && target.closest("button, a")) return;
|
|
607
|
-
inputRef.value?.focus();
|
|
608
|
-
}
|
|
609
|
-
function highlight(index) {
|
|
610
|
-
const entry = menu.entries.value[index];
|
|
611
|
-
if (entry && !entry.disabled) menu.combobox.activeIndex.value = index;
|
|
612
|
-
}
|
|
613
|
-
function onMenuSelect(id) {
|
|
614
|
-
const entry = menu.entries.value.find((item) => item.id === id);
|
|
615
|
-
if (!entry || entry.disabled) return;
|
|
616
|
-
add(entry.create ? entry.item : entry.item, entry.create ? "create" : "add");
|
|
617
|
-
}
|
|
618
|
-
__expose({
|
|
619
|
-
focus: () => inputRef.value?.focus(),
|
|
620
|
-
blur: () => inputRef.value?.blur(),
|
|
621
|
-
open: menuConfig.open,
|
|
622
|
-
close: menuConfig.close
|
|
623
|
-
});
|
|
624
|
-
return (_ctx, _cache) => {
|
|
625
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
626
|
-
createVNode(_sfc_main$2, {
|
|
627
|
-
class: normalizeClass(["astryx-tokenizer", [
|
|
628
|
-
unref(parts).containerClass.value,
|
|
629
|
-
`size-${unref(size)}`,
|
|
630
|
-
{ "is-floating": floating.value }
|
|
631
|
-
]]),
|
|
632
|
-
style: normalizeStyle(unref(parts).containerStyle.value),
|
|
633
|
-
label: props.label,
|
|
634
|
-
"input-id": inputId,
|
|
635
|
-
description: props.description,
|
|
636
|
-
"label-tooltip": props.labelTooltip,
|
|
637
|
-
"is-label-hidden": unref(hideLabel),
|
|
638
|
-
"is-disabled": props.disabled,
|
|
639
|
-
"is-required": props.required,
|
|
640
|
-
"is-optional": props.optional,
|
|
641
|
-
status: unref(fieldStatus),
|
|
642
|
-
"status-variant": props.statusVariant,
|
|
643
|
-
width: props.width
|
|
644
|
-
}, {
|
|
645
|
-
default: withCtx(() => [
|
|
646
|
-
floating.value ? (openBlock(), createElementBlock("div", {
|
|
647
|
-
key: 0,
|
|
648
|
-
class: "astryx-tokenizer-placeholder",
|
|
649
|
-
style: normalizeStyle({ height: `${placeholderHeight.value}px` })
|
|
650
|
-
}, null, 4)) : createCommentVNode("v-if", true),
|
|
651
|
-
createCommentVNode(" eslint-disable-next-line vue-a11y/click-events-have-key-events, vue-a11y/no-static-element-interactions -- 点空白处只是把焦点交给输入框;方向键和删除由输入框与标签处理。 "),
|
|
652
|
-
createElementVNode("div", {
|
|
653
|
-
ref_key: "anchorRef",
|
|
654
|
-
ref: anchorRef,
|
|
655
|
-
class: normalizeClass(["astryx-tokenizer-control", [
|
|
656
|
-
unref(parts).controlClass(),
|
|
657
|
-
`status-${props.status}`,
|
|
658
|
-
{
|
|
659
|
-
"is-open": unref(menu).combobox.isOpen.value,
|
|
660
|
-
"is-disabled": props.disabled,
|
|
661
|
-
"is-floating": floating.value,
|
|
662
|
-
"has-tokens": values.value.length > 0
|
|
663
|
-
}
|
|
664
|
-
]]),
|
|
665
|
-
style: normalizeStyle(unref(parts).controlStyle()),
|
|
666
|
-
onClick: onFieldClick,
|
|
667
|
-
onFocusin: onFocusIn,
|
|
668
|
-
onFocusout: onFocusOut,
|
|
669
|
-
onPointerenter: _cache[0] || (_cache[0] = (...args) => unref(disabledTooltip).onPointerEnter && unref(disabledTooltip).onPointerEnter(...args)),
|
|
670
|
-
onPointerleave: _cache[1] || (_cache[1] = (...args) => unref(disabledTooltip).onPointerLeave && unref(disabledTooltip).onPointerLeave(...args))
|
|
671
|
-
}, [
|
|
672
|
-
_ctx.$slots.icon ? (openBlock(), createElementBlock("span", _hoisted_1, [renderSlot(_ctx.$slots, "icon")])) : createCommentVNode("v-if", true),
|
|
673
|
-
createElementVNode("span", {
|
|
674
|
-
ref: unref(overflow).containerRef,
|
|
675
|
-
class: normalizeClass(["astryx-tokenizer-tokens", { "is-collapsed": collapsed.value }])
|
|
676
|
-
}, [
|
|
677
|
-
createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 方向键在标签容器上移动焦点,删除由内部按钮处理。 "),
|
|
678
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(visibleItems.value, (item, index) => {
|
|
679
|
-
return openBlock(), createElementBlock("span", {
|
|
680
|
-
key: item.id,
|
|
681
|
-
ref_for: true,
|
|
682
|
-
ref: (element) => setTokenEl(index, element),
|
|
683
|
-
class: "astryx-tokenizer-token",
|
|
684
|
-
tabindex: "-1",
|
|
685
|
-
onKeydown: ($event) => unref(onTokenKeyDown)($event, item, index)
|
|
686
|
-
}, [renderSlot(_ctx.$slots, "token", {
|
|
687
|
-
item,
|
|
688
|
-
remove: () => remove(item)
|
|
689
|
-
}, () => [createVNode(_sfc_main$3, {
|
|
690
|
-
label: item.label,
|
|
691
|
-
size: unref(size),
|
|
692
|
-
disabled: props.disabled,
|
|
693
|
-
removable: "",
|
|
694
|
-
onRemove: ($event) => remove(item)
|
|
695
|
-
}, null, 8, [
|
|
696
|
-
"label",
|
|
697
|
-
"size",
|
|
698
|
-
"disabled",
|
|
699
|
-
"onRemove"
|
|
700
|
-
])])], 40, _hoisted_2);
|
|
701
|
-
}), 128)),
|
|
702
|
-
collapsed.value && hiddenCount.value > 0 ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(unref(messages).tokenizer.more(hiddenCount.value)), 1)) : createCommentVNode("v-if", true)
|
|
703
|
-
], 2),
|
|
704
|
-
createElementVNode("span", {
|
|
705
|
-
ref: unref(overflow).measureRef,
|
|
706
|
-
class: "astryx-tokenizer-measure",
|
|
707
|
-
"aria-hidden": "true"
|
|
708
|
-
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(values.value, (item) => {
|
|
709
|
-
return openBlock(), createElementBlock("span", {
|
|
710
|
-
key: item.id,
|
|
711
|
-
class: "astryx-tokenizer-token"
|
|
712
|
-
}, [createVNode(_sfc_main$3, {
|
|
713
|
-
label: item.label,
|
|
714
|
-
size: unref(size),
|
|
715
|
-
removable: ""
|
|
716
|
-
}, null, 8, ["label", "size"])]);
|
|
717
|
-
}), 128)), createElementVNode("span", _hoisted_4, toDisplayString(measureMoreLabel.value), 1)], 512),
|
|
718
|
-
createElementVNode("input", mergeProps(inputAttrs(), {
|
|
719
|
-
id: inputId,
|
|
720
|
-
ref_key: "inputRef",
|
|
721
|
-
ref: inputRef,
|
|
722
|
-
class: ["astryx-tokenizer-input", { "is-empty": unref(menu).query.value === "" }],
|
|
723
|
-
type: "text",
|
|
724
|
-
role: "combobox",
|
|
725
|
-
autocomplete: "off",
|
|
726
|
-
autocapitalize: "off",
|
|
727
|
-
autocorrect: "off",
|
|
728
|
-
enterkeyhint: "search",
|
|
729
|
-
"data-autofocus": props.hasAutoFocus || void 0,
|
|
730
|
-
placeholder: values.value.length === 0 ? placeholder.value : void 0,
|
|
731
|
-
value: unref(menu).query.value,
|
|
732
|
-
disabled: props.disabled && !unref(focusableDisabled),
|
|
733
|
-
readonly: unref(focusableDisabled) || atMax.value || void 0,
|
|
734
|
-
"aria-disabled": unref(focusableDisabled) ? "true" : void 0,
|
|
735
|
-
"aria-expanded": unref(menuConfig).popupOpen.value,
|
|
736
|
-
"aria-haspopup": unref(menuConfig).isDialog.value ? "dialog" : unref(optionGrid).popupKind.value,
|
|
737
|
-
"aria-controls": listboxId,
|
|
738
|
-
"aria-autocomplete": "list",
|
|
739
|
-
"aria-activedescendant": unref(menuConfig).isDialog.value ? void 0 : unref(optionGrid).gridMode.value ? unref(optionGrid).actionGrid.activeDescendant.value : unref(menu).activeId.value ? `${listboxId}-option-${unref(menu).combobox.activeIndex.value}` : void 0,
|
|
740
|
-
"aria-labelledby": unref(labelledBy),
|
|
741
|
-
"aria-describedby": unref(describedBy),
|
|
742
|
-
"aria-required": props.required || void 0,
|
|
743
|
-
"aria-invalid": props.status === "error" ? true : void 0,
|
|
744
|
-
onInput,
|
|
745
|
-
onKeydown: onInputKeyDown
|
|
746
|
-
}), null, 16, _hoisted_5),
|
|
747
|
-
renderSlot(_ctx.$slots, "end"),
|
|
748
|
-
showsClear.value && values.value.length > 0 && !props.disabled ? (openBlock(), createElementBlock("button", {
|
|
749
|
-
key: 1,
|
|
750
|
-
type: "button",
|
|
751
|
-
class: "astryx-tokenizer-clear",
|
|
752
|
-
"aria-label": unref(messages).tokenizer.clear,
|
|
753
|
-
onClick: clearAll
|
|
754
|
-
}, [..._cache[2] || (_cache[2] = [createElementVNode("svg", {
|
|
755
|
-
width: "16",
|
|
756
|
-
height: "16",
|
|
757
|
-
viewBox: "0 0 16 16",
|
|
758
|
-
fill: "none",
|
|
759
|
-
"aria-hidden": "true"
|
|
760
|
-
}, [createElementVNode("path", {
|
|
761
|
-
d: "M12 4L4 12M4 4L12 12",
|
|
762
|
-
stroke: "currentColor",
|
|
763
|
-
"stroke-width": "1.5",
|
|
764
|
-
"stroke-linecap": "round"
|
|
765
|
-
})], -1)])], 8, _hoisted_6)) : createCommentVNode("v-if", true),
|
|
766
|
-
unref(statusIcon) ? (openBlock(), createBlock(resolveDynamicComponent(unref(statusIcon)), normalizeProps(mergeProps({ key: 2 }, unref(statusIconProps))), null, 16)) : createCommentVNode("v-if", true),
|
|
767
|
-
unref(focusableDisabled) && unref(disabledMessage) ? (openBlock(), createElementBlock("span", {
|
|
768
|
-
key: 3,
|
|
769
|
-
id: disabledId,
|
|
770
|
-
class: "astryx-visually-hidden"
|
|
771
|
-
}, toDisplayString(unref(disabledMessage)), 1)) : createCommentVNode("v-if", true),
|
|
772
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(hiddenCarrierItems.value, (item) => {
|
|
773
|
-
return openBlock(), createElementBlock("input", {
|
|
774
|
-
key: `${props.name}-${item.id}`,
|
|
775
|
-
type: "hidden",
|
|
776
|
-
name: props.name,
|
|
777
|
-
value: item.id,
|
|
778
|
-
disabled: !props.name
|
|
779
|
-
}, null, 8, _hoisted_7);
|
|
780
|
-
}), 128))
|
|
781
|
-
], 38)
|
|
782
|
-
]),
|
|
783
|
-
_: 3
|
|
784
|
-
}, 8, [
|
|
785
|
-
"class",
|
|
786
|
-
"style",
|
|
787
|
-
"label",
|
|
788
|
-
"description",
|
|
789
|
-
"label-tooltip",
|
|
790
|
-
"is-label-hidden",
|
|
791
|
-
"is-disabled",
|
|
792
|
-
"is-required",
|
|
793
|
-
"is-optional",
|
|
794
|
-
"status",
|
|
795
|
-
"status-variant",
|
|
796
|
-
"width"
|
|
797
|
-
]),
|
|
798
|
-
unref(showsDisabledMessage) ? (openBlock(), createBlock(_sfc_main$1, {
|
|
799
|
-
key: 0,
|
|
800
|
-
id: disabledTooltipId,
|
|
801
|
-
anchor: anchorRef.value,
|
|
802
|
-
open: unref(disabledTooltip).isOpen.value,
|
|
803
|
-
text: unref(disabledMessage) ?? "",
|
|
804
|
-
onPointerEnter: unref(disabledTooltip).onTooltipPointerEnter,
|
|
805
|
-
onPointerLeave: unref(disabledTooltip).onTooltipPointerLeave
|
|
806
|
-
}, null, 8, [
|
|
807
|
-
"anchor",
|
|
808
|
-
"open",
|
|
809
|
-
"text",
|
|
810
|
-
"onPointerEnter",
|
|
811
|
-
"onPointerLeave"
|
|
812
|
-
])) : createCommentVNode("v-if", true),
|
|
813
|
-
createVNode(_sfc_main$4, {
|
|
814
|
-
id: listboxId,
|
|
815
|
-
ref_key: "popupRef",
|
|
816
|
-
ref: popupRef,
|
|
817
|
-
"is-open": unref(menuConfig).popupOpen.value,
|
|
818
|
-
config: props.menu,
|
|
819
|
-
label: unref(messages).tokenizer.results,
|
|
820
|
-
grid: unref(optionGrid).gridMode.value,
|
|
821
|
-
placement: unref(anchored).position.value.placement,
|
|
822
|
-
"popup-style": unref(anchored).style.value,
|
|
823
|
-
entries: unref(menu).entries.value.map((entry) => ({
|
|
824
|
-
id: entry.id,
|
|
825
|
-
label: entry.label,
|
|
826
|
-
description: entry.description,
|
|
827
|
-
disabled: entry.disabled,
|
|
828
|
-
group: entry.group,
|
|
829
|
-
action: entry.action,
|
|
830
|
-
selected: values.value.some((item) => item.id === entry.item.id)
|
|
831
|
-
})),
|
|
832
|
-
"active-index": unref(menu).combobox.activeIndex.value,
|
|
833
|
-
"action-index": unref(optionGrid).actionGrid.column.value === "action" ? unref(menu).combobox.activeIndex.value : -1,
|
|
834
|
-
status: unref(menu).menuStatus.value,
|
|
835
|
-
"empty-text": emptyText.value,
|
|
836
|
-
"loading-text": unref(messages).tokenizer.loading,
|
|
837
|
-
"error-text": unref(messages).tokenizer.error,
|
|
838
|
-
query: unref(menu).query.value,
|
|
839
|
-
"is-settled": unref(menu).isSettled.value,
|
|
840
|
-
onSelect: onMenuSelect,
|
|
841
|
-
onHighlight: highlight,
|
|
842
|
-
onClose: unref(menuConfig).close,
|
|
843
|
-
onKeydown: unref(menuConfig).closeOnEscape
|
|
844
|
-
}, createSlots({ _: 2 }, [
|
|
845
|
-
_ctx.$slots.item ? {
|
|
846
|
-
name: "item",
|
|
847
|
-
fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "item", {
|
|
848
|
-
item: unref(menu).entries.value.find((entry) => entry.id === slotProps.entry.id).item,
|
|
849
|
-
isActive: slotProps.isActive,
|
|
850
|
-
isSelected: slotProps.isSelected
|
|
851
|
-
})]),
|
|
852
|
-
key: "0"
|
|
853
|
-
} : void 0,
|
|
854
|
-
_ctx.$slots.empty ? {
|
|
855
|
-
name: "empty",
|
|
856
|
-
fn: withCtx(() => [renderSlot(_ctx.$slots, "empty")]),
|
|
857
|
-
key: "1"
|
|
858
|
-
} : void 0,
|
|
859
|
-
_ctx.$slots.menu ? {
|
|
860
|
-
name: "menu",
|
|
861
|
-
fn: withCtx((menuProps) => [renderSlot(_ctx.$slots, "menu", normalizeProps(guardReactiveProps(menuProps)))]),
|
|
862
|
-
key: "2"
|
|
863
|
-
} : void 0
|
|
864
|
-
]), 1032, [
|
|
865
|
-
"is-open",
|
|
866
|
-
"config",
|
|
867
|
-
"label",
|
|
868
|
-
"grid",
|
|
869
|
-
"placement",
|
|
870
|
-
"popup-style",
|
|
871
|
-
"entries",
|
|
872
|
-
"active-index",
|
|
873
|
-
"action-index",
|
|
874
|
-
"status",
|
|
875
|
-
"empty-text",
|
|
876
|
-
"loading-text",
|
|
877
|
-
"error-text",
|
|
878
|
-
"query",
|
|
879
|
-
"is-settled",
|
|
880
|
-
"onClose",
|
|
881
|
-
"onKeydown"
|
|
882
|
-
])
|
|
883
|
-
], 64);
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
});
|
|
887
|
-
//#endregion
|
|
888
|
-
export { useTokenRemoveTap as n, _sfc_main as t };
|