@1337exp/taoui 5.48.0 → 5.49.1
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/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/README.ru.md +1 -1
- package/dist/index.d.ts +67 -8
- package/dist/index.js +72 -35
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/skills/taoui/SKILL.md +1 -1
- package/skills/taoui/references/components.md +1392 -1390
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.49.1
|
|
4
|
+
|
|
5
|
+
Nothing to migrate. To make a key selectable again (a page of documentation that wants it copied): `.my-doc .tao-kbd { user-select: text; }`.
|
|
6
|
+
|
|
7
|
+
- **`TaoKbd` is not selectable.** A key is a hint, not content: a double click on a menu row or a button no longer selects the key with it, and a copied row carries no key. `user-select: none` sits on the zero-specificity `:where(.tao-kbd)` rule, so both `cap` and `plain` have it and the place that holds a key can override it.
|
|
8
|
+
|
|
9
|
+
## 5.49.0
|
|
10
|
+
|
|
11
|
+
Nothing to migrate: an `anchor` that is an element works as before.
|
|
12
|
+
|
|
13
|
+
- **`TaoMenu` opens at a point of the screen.** `anchor` is now an element or a virtual anchor `{ x, y, width?, height? }` in viewport coordinates (types `TaoAnchor`, `TaoVirtualAnchor`, helpers `isVirtualAnchor`, `anchorRect` in `floating.ts`): a menu at a drop point of a canvas or at the pointer needs no empty positioned element any more. With a point the default `placement` is `bottom-start` (the top-left corner 4px under the point, so the click that opened the menu does not hit the first item; with an element it stays `bottom-end`); the panel is `fixed`, flips and shifts at the viewport edges like an anchored one, stays at its screen point on scroll (`closeOnScroll` closes it, as with an element), moves when the point changes, and the point can be swapped for an element and back. With a point the menu gives the focus back, on close, to what had it before opening (not after a press elsewhere or a scroll). Escape, outside press, arrows, type-ahead and submenus are the same as before.
|
|
14
|
+
- **`TaoPopover` takes the same `anchor`** (a point or an element instead of the trigger); Escape gives the focus back to what had it before opening.
|
|
15
|
+
- **`useFloating`** accepts a ref, a getter or a value as the anchor and re-measures when the anchor changes.
|
|
16
|
+
- **`TaoContextMenu`** is built on it: the hidden `.tao-context-menu__anchor` span and its own focus bookkeeping are gone (a private detail, the behaviour is the same).
|
|
17
|
+
- **Recipe, a context menu of your own:** `@contextmenu.prevent="e => { point = { x: e.clientX, y: e.clientY }; open = true }"` and `<TaoMenu :items :open :anchor="point" @close="open = false" />` (the demo of `TaoMenubar / TaoContextMenu` shows it). Not tested in real browsers or on touch.
|
|
18
|
+
|
|
3
19
|
## 5.48.0
|
|
4
20
|
|
|
5
21
|
A link with a class keeps its own colour on hover (it used to turn rose). Three looks change: the text of a field in the light theme is softer, the rose of a link on hover is a shade deeper, the accent text of a palette is a shade darker where it stands on a tint. To give your own link the rose on hover as before: `.my-link:hover { color: var(--tao-color-link-hover); }`.
|
package/README.md
CHANGED
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
- **TaoLink** — `<NuxtLink>` in Nuxt, `<RouterLink>` with vue-router, otherwise a plain `<a>` — no extra setup
|
|
140
140
|
- **TaoStretchedLink** — a `TaoLink` that makes a whole card or row one link while the buttons inside it still work: `tao-stretched` on the container, `tao-stretched-raise` on a control that must stay clickable by itself. The keyboard sees one link and its focus ring goes round the container (`--tao-stretched-radius`). Never put `filter` / `transform` on the link: the layer would shrink under the pointer and the cursor would flicker The text under the stretched layer cannot be selected with the mouse (lift what must be selectable with `tao-stretched-raise`), and the link is named only by what is written in it: for a card, point `aria-describedby` of the link at the description.
|
|
141
141
|
- **TaoBreadcrumb** — crumbs: the last item is the current page
|
|
142
|
-
- **TaoDropdownMenu** / **TaoMenu** — a menu from a plain data tree `items`: submenus, checkboxes, radios, separators, group labels, shortcuts to show, disabled items. Arrows, Home / End, type-ahead, `→` / `←` for submenus, Esc closes the top level first. `TaoMenu` is the panel itself, for your own shells (a menu bar, a context menu); flips at the viewport edge; `size` makes the button a compact square, `dots="horizontal"` lays the three dots down (⋯), `:tabbable="false"` takes it out of the Tab order
|
|
142
|
+
- **TaoDropdownMenu** / **TaoMenu** — a menu from a plain data tree `items`: submenus, checkboxes, radios, separators, group labels, shortcuts to show, disabled items. Arrows, Home / End, type-ahead, `→` / `←` for submenus, Esc closes the top level first. `TaoMenu` is the panel itself, for your own shells (a menu bar, a context menu); its `anchor` is an element or a point `{ x, y }` of the screen (a menu at the pointer or at a drop point, no anchor element; `TaoPopover` takes the same `anchor`); flips at the viewport edge; `size` makes the button a compact square, `dots="horizontal"` lays the three dots down (⋯), `:tabbable="false"` takes it out of the Tab order
|
|
143
143
|
- **TaoMenubar** / **TaoContextMenu** — the menu bar of an editor and the menu on the right click, on `TaoMenu`. The bar is one tab stop (`role="menubar"`): `←` / `→` walk it, `↓` / Enter open, with a menu open `←` / `→` and the pointer move to the neighbour menu; an entry without `items` is a plain action. The context menu opens at the pointer (or at the element for the Menu key / Shift+F10) and wraps its content without a box of its own
|
|
144
144
|
- **TaoToolbar** / **TaoToolbarGroup** / **TaoToolbarSeparator** — a bar of tools (`role="toolbar"`): one tab stop, `←` / `→` (or `↑` / `↓` when `orientation="vertical"`) walk the items, Home / End; inside a `TaoSegmented` the arrows pick the option and go on from its edge. Groups are split by a thin line across the bar; `inset` puts a sunken pill behind a group. Toggles are `TaoButton` with `v-model:pressed`. `overflow` keeps the bar in one row: the groups that do not fit go, the last one first, under a «⋮» button that opens them in a panel (the same buttons, not copies); a `TaoToolbarGroup` with `pinned` stays
|
|
145
145
|
- **TaoScrollTop** — floating “back to top”: `solid` / `ghost` / `text` looks, `side`, a mouse-hover `label`. Appears on reverse scroll after `boundary`
|
package/README.ru.md
CHANGED
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
- **TaoLink** — `<NuxtLink>` в Nuxt, `<RouterLink>` при vue-router, иначе обычный `<a>` — без дополнительной настройки
|
|
140
140
|
- **TaoStretchedLink** — `TaoLink`, который делает целую карточку или строку одной ссылкой, а кнопки внутри продолжают работать: `tao-stretched` на контейнере, `tao-stretched-raise` на элементе, который должен нажиматься сам. Клавиатура видит одну ссылку, кольцо фокуса идёт по контейнеру (`--tao-stretched-radius`). Не давайте ссылке `filter` / `transform`: слой сожмётся под курсором, и курсор начнёт мигать Текст под растянутым слоем нельзя выделить мышью (то, что должно выделяться, поднимите через `tao-stretched-raise`), а имя ссылке даёт только то, что в ней написано: для карточки направьте `aria-describedby` ссылки на описание.
|
|
141
141
|
- **TaoBreadcrumb** — крошки: последний пункт — текущая страница
|
|
142
|
-
- **TaoDropdownMenu** / **TaoMenu** — меню из простого дерева данных `items`: подменю, чекбоксы, радио, разделители, подписи групп, сочетания для показа, недоступные пункты. Стрелки, Home / End, быстрый поиск по букве, `→` / `←` для подменю, Esc закрывает верхний уровень первым. `TaoMenu` — сама панель для своих оболочек (полоса меню, контекстное меню); у края экрана переворачивается; `size` делает кнопку компактным квадратом, `dots="horizontal"` кладёт три точки горизонтально (⋯), `:tabbable="false"` убирает её из порядка Tab
|
|
142
|
+
- **TaoDropdownMenu** / **TaoMenu** — меню из простого дерева данных `items`: подменю, чекбоксы, радио, разделители, подписи групп, сочетания для показа, недоступные пункты. Стрелки, Home / End, быстрый поиск по букве, `→` / `←` для подменю, Esc закрывает верхний уровень первым. `TaoMenu` — сама панель для своих оболочек (полоса меню, контекстное меню); её `anchor` — элемент или точка экрана `{ x, y }` (меню у указателя или в точке сброса, без элемента-якоря; `TaoPopover` принимает тот же `anchor`); у края экрана переворачивается; `size` делает кнопку компактным квадратом, `dots="horizontal"` кладёт три точки горизонтально (⋯), `:tabbable="false"` убирает её из порядка Tab
|
|
143
143
|
- **TaoMenubar** / **TaoContextMenu** — полоса меню редактора и меню по правой кнопке, на `TaoMenu`. Полоса — одна остановка Tab (`role="menubar"`): `←` / `→` ходят по ней, `↓` / Enter открывают, при открытом меню `←` / `→` и указатель переходят к соседнему; пункт без `items` — обычное действие. Контекстное меню открывается у указателя (или у элемента для клавиши Menu / Shift+F10) и оборачивает содержимое без своей коробки
|
|
144
144
|
- **TaoToolbar** / **TaoToolbarGroup** / **TaoToolbarSeparator** — панель инструментов (`role="toolbar"`): одна остановка Tab, `←` / `→` (или `↑` / `↓` при `orientation="vertical"`) ходят по элементам, Home / End; внутри `TaoSegmented` стрелки выбирают вариант и идут дальше с его края. Группы делит тонкая черта поперёк панели; `inset` кладёт под группу утопленную подложку. Переключатели — `TaoButton` с `v-model:pressed`. `overflow` держит панель в одной строке: группы, которые не влезли, уходят (последняя первой) под кнопку «⋮», она открывает их в панели (те же кнопки, а не копии); `TaoToolbarGroup` с `pinned` остаётся
|
|
145
145
|
- **TaoScrollTop** — плавающая кнопка «наверх»: виды `solid` / `ghost` / `text`, `side`, подпись `label` при наведении мыши. Появляется при обратном скролле после `boundary`
|
package/dist/index.d.ts
CHANGED
|
@@ -229,8 +229,16 @@ modelValue?: boolean;
|
|
|
229
229
|
/** Side and alignment against the trigger; flips when there is no room. / Сторона и выравнивание; при нехватке места переворачивается. */
|
|
230
230
|
placement?: TaoPlacement;
|
|
231
231
|
disabled?: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* A virtual anchor: a point `{ x, y }` in viewport coordinates (optionally `width` / `height`) or an element to hang from
|
|
234
|
+
* instead of the trigger. A point stays at its screen point; the focus goes back to what had it before opening.
|
|
235
|
+
* Виртуальный якорь: точка `{ x, y }` в координатах окна (при желании `width` / `height`) или элемент вместо триггера.
|
|
236
|
+
* Точка стоит на своём месте экрана; фокус возвращается туда, где был до открытия.
|
|
237
|
+
*/
|
|
238
|
+
anchor?: TaoAnchor | null;
|
|
232
239
|
}>, {
|
|
233
240
|
modelValue: undefined;
|
|
241
|
+
anchor: null;
|
|
234
242
|
placement: string;
|
|
235
243
|
disabled: boolean;
|
|
236
244
|
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
@@ -241,14 +249,23 @@ modelValue?: boolean;
|
|
|
241
249
|
/** Side and alignment against the trigger; flips when there is no room. / Сторона и выравнивание; при нехватке места переворачивается. */
|
|
242
250
|
placement?: TaoPlacement;
|
|
243
251
|
disabled?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* A virtual anchor: a point `{ x, y }` in viewport coordinates (optionally `width` / `height`) or an element to hang from
|
|
254
|
+
* instead of the trigger. A point stays at its screen point; the focus goes back to what had it before opening.
|
|
255
|
+
* Виртуальный якорь: точка `{ x, y }` в координатах окна (при желании `width` / `height`) или элемент вместо триггера.
|
|
256
|
+
* Точка стоит на своём месте экрана; фокус возвращается туда, где был до открытия.
|
|
257
|
+
*/
|
|
258
|
+
anchor?: TaoAnchor | null;
|
|
244
259
|
}>, {
|
|
245
260
|
modelValue: undefined;
|
|
261
|
+
anchor: null;
|
|
246
262
|
placement: string;
|
|
247
263
|
disabled: boolean;
|
|
248
264
|
}>>> & Readonly<{
|
|
249
265
|
onChange?: ((value: boolean) => any) | undefined;
|
|
250
266
|
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
251
267
|
}>, {
|
|
268
|
+
anchor: TaoAnchor | null;
|
|
252
269
|
disabled: boolean;
|
|
253
270
|
modelValue: boolean;
|
|
254
271
|
placement: TaoPlacement;
|
|
@@ -1113,8 +1130,21 @@ tabbable: boolean;
|
|
|
1113
1130
|
declare const __VLS_component_38: DefineComponent<ExtractPropTypes<__VLS_WithDefaults_36<__VLS_TypePropsToRuntimeProps_40<{
|
|
1114
1131
|
items: TaoMenuItem[];
|
|
1115
1132
|
open: boolean;
|
|
1116
|
-
/**
|
|
1117
|
-
|
|
1133
|
+
/**
|
|
1134
|
+
* What the panel hangs from: a button, the item a submenu opens from, or a point `{ x, y }` on the screen (viewport
|
|
1135
|
+
* coordinates, optionally `width` / `height`) for a menu at the pointer. A point follows nothing: the panel stays at that
|
|
1136
|
+
* screen point (it is `fixed`), flips and shifts at the edges, and the focus goes back to where it was before the menu
|
|
1137
|
+
* opened. Change the point and the menu moves; swap an element for a point and back.
|
|
1138
|
+
* К чему крепится панель: кнопка, пункт, из которого открыто подменю, или точка `{ x, y }` экрана (координаты окна, при
|
|
1139
|
+
* желании `width` / `height`) для меню у указателя. Точка ни за чем не следует: панель стоит в этой точке экрана
|
|
1140
|
+
* (`fixed`), у краёв переворачивается и сдвигается, а фокус при закрытии возвращается туда, где был до открытия.
|
|
1141
|
+
* Сменили точку — меню переехало; элемент можно менять на точку и обратно.
|
|
1142
|
+
*/
|
|
1143
|
+
anchor: TaoAnchor | null;
|
|
1144
|
+
/**
|
|
1145
|
+
* Default `bottom-end` for an element, `bottom-start` for a point (the top-left corner at the point, 4px under it).
|
|
1146
|
+
* По умолчанию `bottom-end` для элемента, `bottom-start` для точки (левый верхний угол у точки, на 4px ниже).
|
|
1147
|
+
*/
|
|
1118
1148
|
placement?: TaoPlacement;
|
|
1119
1149
|
/** Accessible name of the menu. / Имя меню для скринридера. */
|
|
1120
1150
|
label?: string;
|
|
@@ -1124,7 +1154,7 @@ label?: string;
|
|
|
1124
1154
|
*/
|
|
1125
1155
|
closeOnScroll?: boolean;
|
|
1126
1156
|
}>, {
|
|
1127
|
-
placement:
|
|
1157
|
+
placement: undefined;
|
|
1128
1158
|
label: undefined;
|
|
1129
1159
|
closeOnScroll: boolean;
|
|
1130
1160
|
}>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
@@ -1135,8 +1165,21 @@ edge: (direction: "prev" | "next") => void;
|
|
|
1135
1165
|
}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_36<__VLS_TypePropsToRuntimeProps_40<{
|
|
1136
1166
|
items: TaoMenuItem[];
|
|
1137
1167
|
open: boolean;
|
|
1138
|
-
/**
|
|
1139
|
-
|
|
1168
|
+
/**
|
|
1169
|
+
* What the panel hangs from: a button, the item a submenu opens from, or a point `{ x, y }` on the screen (viewport
|
|
1170
|
+
* coordinates, optionally `width` / `height`) for a menu at the pointer. A point follows nothing: the panel stays at that
|
|
1171
|
+
* screen point (it is `fixed`), flips and shifts at the edges, and the focus goes back to where it was before the menu
|
|
1172
|
+
* opened. Change the point and the menu moves; swap an element for a point and back.
|
|
1173
|
+
* К чему крепится панель: кнопка, пункт, из которого открыто подменю, или точка `{ x, y }` экрана (координаты окна, при
|
|
1174
|
+
* желании `width` / `height`) для меню у указателя. Точка ни за чем не следует: панель стоит в этой точке экрана
|
|
1175
|
+
* (`fixed`), у краёв переворачивается и сдвигается, а фокус при закрытии возвращается туда, где был до открытия.
|
|
1176
|
+
* Сменили точку — меню переехало; элемент можно менять на точку и обратно.
|
|
1177
|
+
*/
|
|
1178
|
+
anchor: TaoAnchor | null;
|
|
1179
|
+
/**
|
|
1180
|
+
* Default `bottom-end` for an element, `bottom-start` for a point (the top-left corner at the point, 4px under it).
|
|
1181
|
+
* По умолчанию `bottom-end` для элемента, `bottom-start` для точки (левый верхний угол у точки, на 4px ниже).
|
|
1182
|
+
*/
|
|
1140
1183
|
placement?: TaoPlacement;
|
|
1141
1184
|
/** Accessible name of the menu. / Имя меню для скринридера. */
|
|
1142
1185
|
label?: string;
|
|
@@ -1146,7 +1189,7 @@ label?: string;
|
|
|
1146
1189
|
*/
|
|
1147
1190
|
closeOnScroll?: boolean;
|
|
1148
1191
|
}>, {
|
|
1149
|
-
placement:
|
|
1192
|
+
placement: undefined;
|
|
1150
1193
|
label: undefined;
|
|
1151
1194
|
closeOnScroll: boolean;
|
|
1152
1195
|
}>>> & Readonly<{
|
|
@@ -7153,6 +7196,9 @@ export declare const TAO_CHART_COLORS = 6;
|
|
|
7153
7196
|
|
|
7154
7197
|
export declare const TaoAlert: __VLS_WithTemplateSlots_66<typeof __VLS_component_66, ReturnType<typeof __VLS_template_66>>;
|
|
7155
7198
|
|
|
7199
|
+
/** What a panel hangs from: an element or a virtual anchor. / К чему крепится панель: элемент или виртуальный якорь. */
|
|
7200
|
+
export declare type TaoAnchor = HTMLElement | TaoVirtualAnchor;
|
|
7201
|
+
|
|
7156
7202
|
export declare const TaoAnimatedBorder: __VLS_WithTemplateSlots_31<typeof __VLS_component_31, ReturnType<typeof __VLS_template_31>>;
|
|
7157
7203
|
|
|
7158
7204
|
export declare const TaoAvatar: DefineComponent<ExtractPropTypes<__VLS_WithDefaults_76<__VLS_TypePropsToRuntimeProps_82<{
|
|
@@ -8911,11 +8957,11 @@ error: boolean;
|
|
|
8911
8957
|
resize: boolean;
|
|
8912
8958
|
variant: TaoTextareaVariant;
|
|
8913
8959
|
modelValue: string;
|
|
8960
|
+
spellcheck: boolean;
|
|
8961
|
+
autofocus: boolean;
|
|
8914
8962
|
align: "start" | "center" | "end";
|
|
8915
8963
|
autocomplete: string;
|
|
8916
|
-
spellcheck: boolean;
|
|
8917
8964
|
rows: number;
|
|
8918
|
-
autofocus: boolean;
|
|
8919
8965
|
maxHeight: number | string;
|
|
8920
8966
|
maxlength: number;
|
|
8921
8967
|
minlength: number;
|
|
@@ -9154,6 +9200,19 @@ export declare interface TaoUIOptions {
|
|
|
9154
9200
|
locale?: TaoLocale | TaoLocaleOverrides;
|
|
9155
9201
|
}
|
|
9156
9202
|
|
|
9203
|
+
/**
|
|
9204
|
+
* A virtual anchor: a point (or a box) in viewport coordinates instead of an element, for a menu at the pointer.
|
|
9205
|
+
* `width` and `height` default to 0. It follows nothing: the panel is `fixed` and stays where the point is on the screen.
|
|
9206
|
+
* Виртуальный якорь: точка (или рамка) в координатах окна вместо элемента, для меню у указателя.
|
|
9207
|
+
* `width` и `height` по умолчанию 0. Ни за чем не следует: панель `fixed` и стоит в точке экрана.
|
|
9208
|
+
*/
|
|
9209
|
+
export declare interface TaoVirtualAnchor {
|
|
9210
|
+
x: number;
|
|
9211
|
+
y: number;
|
|
9212
|
+
width?: number;
|
|
9213
|
+
height?: number;
|
|
9214
|
+
}
|
|
9215
|
+
|
|
9157
9216
|
export declare const toast: TaoToastApi;
|
|
9158
9217
|
|
|
9159
9218
|
export declare function todayTaoDate(): string;
|
package/dist/index.js
CHANGED
|
@@ -3109,6 +3109,15 @@ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
|
|
|
3109
3109
|
}
|
|
3110
3110
|
});
|
|
3111
3111
|
const TaoScrubber = /* @__PURE__ */ _export_sfc(_sfc_main$1c, [["__scopeId", "data-v-517dc331"]]);
|
|
3112
|
+
function isVirtualAnchor(anchor) {
|
|
3113
|
+
return anchor != null && typeof anchor === "object" && typeof anchor.x === "number" && typeof anchor.y === "number" && typeof anchor.getBoundingClientRect !== "function";
|
|
3114
|
+
}
|
|
3115
|
+
function anchorRect(anchor) {
|
|
3116
|
+
if (isVirtualAnchor(anchor)) {
|
|
3117
|
+
return { left: anchor.x, top: anchor.y, width: anchor.width ?? 0, height: anchor.height ?? 0 };
|
|
3118
|
+
}
|
|
3119
|
+
return anchor.getBoundingClientRect();
|
|
3120
|
+
}
|
|
3112
3121
|
const opposite = { top: "bottom", bottom: "top", left: "right", right: "left" };
|
|
3113
3122
|
function computePosition(input) {
|
|
3114
3123
|
const { anchor, size, viewport, placement = "bottom-start", gap = 4, pad = 8, flip = true } = input;
|
|
@@ -3173,12 +3182,12 @@ function useFloating(anchor, panel, open, options = {}) {
|
|
|
3173
3182
|
const placed = ref(false);
|
|
3174
3183
|
let strategy = "absolute";
|
|
3175
3184
|
function update() {
|
|
3176
|
-
const anchorEl = anchor
|
|
3177
|
-
const panelEl = panel
|
|
3185
|
+
const anchorEl = toValue(anchor);
|
|
3186
|
+
const panelEl = toValue(panel);
|
|
3178
3187
|
if (!anchorEl || !panelEl || typeof window === "undefined") {
|
|
3179
3188
|
return;
|
|
3180
3189
|
}
|
|
3181
|
-
const rect = anchorEl
|
|
3190
|
+
const rect = anchorRect(anchorEl);
|
|
3182
3191
|
const result = computePosition({
|
|
3183
3192
|
anchor: rect,
|
|
3184
3193
|
size: { width: options.matchWidth ? rect.width : panelEl.offsetWidth, height: panelEl.offsetHeight },
|
|
@@ -3222,11 +3231,27 @@ function useFloating(anchor, panel, open, options = {}) {
|
|
|
3222
3231
|
window.addEventListener("resize", onViewportChange);
|
|
3223
3232
|
window.addEventListener("scroll", onViewportChange, true);
|
|
3224
3233
|
await nextTick();
|
|
3225
|
-
|
|
3234
|
+
pickStrategy();
|
|
3226
3235
|
update();
|
|
3227
3236
|
},
|
|
3228
3237
|
{ immediate: true }
|
|
3229
3238
|
);
|
|
3239
|
+
function pickStrategy() {
|
|
3240
|
+
const el = toValue(anchor);
|
|
3241
|
+
strategy = options.fixed || isVirtualAnchor(el) || el && pinnedToScreen(el) ? "fixed" : "absolute";
|
|
3242
|
+
}
|
|
3243
|
+
watch(
|
|
3244
|
+
() => {
|
|
3245
|
+
const el = toValue(anchor);
|
|
3246
|
+
return isVirtualAnchor(el) ? `${el.x},${el.y},${el.width ?? 0},${el.height ?? 0}` : el;
|
|
3247
|
+
},
|
|
3248
|
+
() => {
|
|
3249
|
+
if (toValue(open)) {
|
|
3250
|
+
pickStrategy();
|
|
3251
|
+
update();
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
);
|
|
3230
3255
|
watch(() => toValue(options.placement), () => onViewportChange());
|
|
3231
3256
|
onBeforeUnmount(() => {
|
|
3232
3257
|
if (typeof window !== "undefined") {
|
|
@@ -3383,7 +3408,8 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
|
|
|
3383
3408
|
props: {
|
|
3384
3409
|
modelValue: { type: Boolean, default: void 0 },
|
|
3385
3410
|
placement: { default: "bottom-start" },
|
|
3386
|
-
disabled: { type: Boolean, default: false }
|
|
3411
|
+
disabled: { type: Boolean, default: false },
|
|
3412
|
+
anchor: { default: null }
|
|
3387
3413
|
},
|
|
3388
3414
|
emits: ["update:modelValue", "change"],
|
|
3389
3415
|
setup(__props, { emit: __emit }) {
|
|
@@ -3413,14 +3439,19 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
|
|
|
3413
3439
|
setOpen(false);
|
|
3414
3440
|
}
|
|
3415
3441
|
function focusTrigger() {
|
|
3442
|
+
if (isVirtualAnchor(props.anchor)) {
|
|
3443
|
+
returnTo?.focus?.({ preventScroll: true });
|
|
3444
|
+
return;
|
|
3445
|
+
}
|
|
3416
3446
|
const root = triggerRef.value;
|
|
3417
3447
|
const focusable = root?.querySelector(
|
|
3418
3448
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
3419
3449
|
);
|
|
3420
3450
|
(focusable ?? root)?.focus?.();
|
|
3421
3451
|
}
|
|
3422
|
-
|
|
3423
|
-
|
|
3452
|
+
let returnTo = null;
|
|
3453
|
+
const { style: panelStyle } = useFloating(() => props.anchor ?? triggerRef.value, panelRef, open, { placement: () => props.placement });
|
|
3454
|
+
useDismiss(open, () => [triggerRef.value, props.anchor instanceof Element ? props.anchor : null, panelRef.value], close);
|
|
3424
3455
|
useLayer(open, {
|
|
3425
3456
|
onEscape: () => {
|
|
3426
3457
|
close();
|
|
@@ -3429,8 +3460,10 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
|
|
|
3429
3460
|
});
|
|
3430
3461
|
watch(open, (isOpen) => {
|
|
3431
3462
|
if (isOpen) {
|
|
3432
|
-
|
|
3433
|
-
|
|
3463
|
+
const host = props.anchor instanceof Element ? props.anchor : triggerRef.value;
|
|
3464
|
+
returnTo = isVirtualAnchor(props.anchor) && document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
3465
|
+
panelSize.value = resolveSize(host);
|
|
3466
|
+
panelDensity.value = resolveDensity(host);
|
|
3434
3467
|
void nextTick(() => panelRef.value?.focus({ preventScroll: true }));
|
|
3435
3468
|
}
|
|
3436
3469
|
});
|
|
@@ -3464,7 +3497,7 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
|
|
|
3464
3497
|
};
|
|
3465
3498
|
}
|
|
3466
3499
|
});
|
|
3467
|
-
const TaoPopover = /* @__PURE__ */ _export_sfc(_sfc_main$1a, [["__scopeId", "data-v-
|
|
3500
|
+
const TaoPopover = /* @__PURE__ */ _export_sfc(_sfc_main$1a, [["__scopeId", "data-v-98bcaeef"]]);
|
|
3468
3501
|
const spoilerGroupKey = Symbol("taoSpoilerGroup");
|
|
3469
3502
|
function frameStyle(bordered) {
|
|
3470
3503
|
if (bordered === void 0 || bordered === null) {
|
|
@@ -5786,7 +5819,7 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
5786
5819
|
items: {},
|
|
5787
5820
|
open: { type: Boolean },
|
|
5788
5821
|
anchor: {},
|
|
5789
|
-
placement: { default:
|
|
5822
|
+
placement: { default: void 0 },
|
|
5790
5823
|
label: { default: void 0 },
|
|
5791
5824
|
closeOnScroll: { type: Boolean, default: false }
|
|
5792
5825
|
},
|
|
@@ -5794,6 +5827,8 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
5794
5827
|
setup(__props, { emit: __emit }) {
|
|
5795
5828
|
const props = __props;
|
|
5796
5829
|
const emit = __emit;
|
|
5830
|
+
let returnTo = null;
|
|
5831
|
+
let lastReason;
|
|
5797
5832
|
const parent = inject(menuTreeKey, null);
|
|
5798
5833
|
const isSub = parent !== null;
|
|
5799
5834
|
const ownRootId = useId();
|
|
@@ -5804,11 +5839,13 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
5804
5839
|
emit("select", item.id);
|
|
5805
5840
|
}
|
|
5806
5841
|
},
|
|
5807
|
-
closeAll: (reason) =>
|
|
5842
|
+
closeAll: (reason) => {
|
|
5843
|
+
lastReason = reason;
|
|
5844
|
+
emit("close", reason);
|
|
5845
|
+
}
|
|
5808
5846
|
};
|
|
5809
5847
|
provide(menuTreeKey, tree);
|
|
5810
5848
|
const panelRef = ref(null);
|
|
5811
|
-
const anchorRef = computed(() => props.anchor);
|
|
5812
5849
|
const itemRefs = ref([]);
|
|
5813
5850
|
const activeIndex = ref(-1);
|
|
5814
5851
|
const openSub = ref(-1);
|
|
@@ -5818,13 +5855,13 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
5818
5855
|
const enabled = computed(() => props.items.map(isMenuSelectable));
|
|
5819
5856
|
const itemId = (index) => `${menuId}-item-${index}`;
|
|
5820
5857
|
const activeId = computed(() => activeIndex.value >= 0 ? itemId(activeIndex.value) : void 0);
|
|
5821
|
-
const { style: panelStyle } = useFloating(
|
|
5822
|
-
placement: () => props.placement,
|
|
5858
|
+
const { style: panelStyle } = useFloating(() => props.anchor, panelRef, () => props.open, {
|
|
5859
|
+
placement: () => props.placement ?? (isVirtualAnchor(props.anchor) ? "bottom-start" : "bottom-end"),
|
|
5823
5860
|
gap: isSub ? 0 : 4
|
|
5824
5861
|
});
|
|
5825
5862
|
useDismiss(
|
|
5826
5863
|
() => props.open && !isSub,
|
|
5827
|
-
() => [props.anchor, ...document.querySelectorAll(`[data-tao-menu-root="${tree.rootId}"]`)],
|
|
5864
|
+
() => [props.anchor instanceof Element ? props.anchor : null, ...document.querySelectorAll(`[data-tao-menu-root="${tree.rootId}"]`)],
|
|
5828
5865
|
() => tree.closeAll("outside")
|
|
5829
5866
|
);
|
|
5830
5867
|
useLayer(() => props.open, {
|
|
@@ -5914,15 +5951,30 @@ const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
|
5914
5951
|
async (isOpen) => {
|
|
5915
5952
|
if (!isOpen) {
|
|
5916
5953
|
closeSub();
|
|
5954
|
+
restoreFocus();
|
|
5917
5955
|
return;
|
|
5918
5956
|
}
|
|
5957
|
+
lastReason = void 0;
|
|
5958
|
+
returnTo = !isSub && isVirtualAnchor(props.anchor) && document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
5919
5959
|
activeIndex.value = enabled.value.indexOf(true);
|
|
5920
|
-
density.value = resolveDensity(props.anchor);
|
|
5960
|
+
density.value = resolveDensity(props.anchor instanceof Element ? props.anchor : null);
|
|
5921
5961
|
await nextTick();
|
|
5922
5962
|
panelRef.value?.focus({ preventScroll: true });
|
|
5923
5963
|
},
|
|
5924
5964
|
{ immediate: true }
|
|
5925
5965
|
);
|
|
5966
|
+
function restoreFocus() {
|
|
5967
|
+
const target = returnTo;
|
|
5968
|
+
returnTo = null;
|
|
5969
|
+
if (!target || !target.isConnected) {
|
|
5970
|
+
return;
|
|
5971
|
+
}
|
|
5972
|
+
const active = document.activeElement;
|
|
5973
|
+
const lost = !active || active === document.body || Boolean(panelRef.value?.contains(active));
|
|
5974
|
+
if (lastReason ? menuReturnsFocus(lastReason) : lost) {
|
|
5975
|
+
target.focus({ preventScroll: true });
|
|
5976
|
+
}
|
|
5977
|
+
}
|
|
5926
5978
|
watch(
|
|
5927
5979
|
() => props.open && props.closeOnScroll && !isSub,
|
|
5928
5980
|
(listen, _was, onCleanup) => {
|
|
@@ -6129,15 +6181,12 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
6129
6181
|
const l10n = useLocaleText(props, "contextMenu");
|
|
6130
6182
|
const emit = __emit;
|
|
6131
6183
|
const isOpen = ref(false);
|
|
6132
|
-
const anchor = ref(null);
|
|
6133
6184
|
const point = ref({ x: 0, y: 0 });
|
|
6134
|
-
let returnTo = null;
|
|
6135
6185
|
async function onContextMenu(event) {
|
|
6136
6186
|
if (props.disabled || !props.items.length) {
|
|
6137
6187
|
return;
|
|
6138
6188
|
}
|
|
6139
6189
|
event.preventDefault();
|
|
6140
|
-
returnTo = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
6141
6190
|
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
6142
6191
|
const fromKeyboard = event.clientX === 0 && event.clientY === 0 && target;
|
|
6143
6192
|
const rect = fromKeyboard ? target.getBoundingClientRect() : null;
|
|
@@ -6147,12 +6196,8 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
6147
6196
|
isOpen.value = true;
|
|
6148
6197
|
emit("open", { ...point.value });
|
|
6149
6198
|
}
|
|
6150
|
-
function onClose(
|
|
6199
|
+
function onClose() {
|
|
6151
6200
|
isOpen.value = false;
|
|
6152
|
-
if (menuReturnsFocus(reason)) {
|
|
6153
|
-
returnTo?.focus?.();
|
|
6154
|
-
}
|
|
6155
|
-
returnTo = null;
|
|
6156
6201
|
}
|
|
6157
6202
|
return (_ctx, _cache) => {
|
|
6158
6203
|
return openBlock(), createElementBlock("div", {
|
|
@@ -6160,18 +6205,10 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
6160
6205
|
onContextmenu: onContextMenu
|
|
6161
6206
|
}, [
|
|
6162
6207
|
renderSlot(_ctx.$slots, "default", {}, void 0, true),
|
|
6163
|
-
createElementVNode("span", {
|
|
6164
|
-
ref_key: "anchor",
|
|
6165
|
-
ref: anchor,
|
|
6166
|
-
class: "tao-context-menu__anchor",
|
|
6167
|
-
"aria-hidden": "true",
|
|
6168
|
-
style: normalizeStyle({ left: `${point.value.x}px`, top: `${point.value.y}px` })
|
|
6169
|
-
}, null, 4),
|
|
6170
6208
|
createVNode(_sfc_main$P, {
|
|
6171
6209
|
items: __props.items,
|
|
6172
6210
|
open: isOpen.value,
|
|
6173
|
-
anchor:
|
|
6174
|
-
placement: "bottom-start",
|
|
6211
|
+
anchor: point.value,
|
|
6175
6212
|
label: __props.menuLabel ?? unref(l10n).menuLabel,
|
|
6176
6213
|
"close-on-scroll": __props.closeOnScroll,
|
|
6177
6214
|
onSelect: _cache[0] || (_cache[0] = ($event) => emit("select", $event)),
|
|
@@ -6189,7 +6226,7 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
6189
6226
|
};
|
|
6190
6227
|
}
|
|
6191
6228
|
});
|
|
6192
|
-
const TaoContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main$N, [["__scopeId", "data-v-
|
|
6229
|
+
const TaoContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main$N, [["__scopeId", "data-v-2d883ec7"]]);
|
|
6193
6230
|
const _hoisted_1$K = ["aria-label"];
|
|
6194
6231
|
const _hoisted_2$F = ["tabindex", "aria-haspopup", "aria-expanded", "aria-disabled", "onClick", "onKeydown", "onMouseenter", "onFocus"];
|
|
6195
6232
|
const _sfc_main$M = /* @__PURE__ */ defineComponent({
|