dou-ui 0.1.0-alpha.8 → 0.1.0-alpha.9

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.
Files changed (26) hide show
  1. package/dist/components/dock/context.js.map +1 -1
  2. package/dist/components/dock/dock-group.js.map +1 -1
  3. package/dist/components/dock/dock-group.vue_vue_type_script_setup_true_lang.js +25 -24
  4. package/dist/components/dock/dock-group.vue_vue_type_script_setup_true_lang.js.map +1 -1
  5. package/dist/components/dock/dock-node.js.map +1 -1
  6. package/dist/components/dock/dock-node.vue_vue_type_script_setup_true_lang.js +2 -2
  7. package/dist/components/dock/dock-node.vue_vue_type_script_setup_true_lang.js.map +1 -1
  8. package/dist/components/dock/dock.js.map +1 -1
  9. package/dist/components/dock/dock.vue_vue_type_script_setup_true_lang.js +145 -18
  10. package/dist/components/dock/dock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  11. package/dist/components/dock/drop-side.js +37 -0
  12. package/dist/components/dock/drop-side.js.map +1 -0
  13. package/dist/components/tabs/tab-drag.js +16 -7
  14. package/dist/components/tabs/tab-drag.js.map +1 -1
  15. package/dist/components/tabs/tabs.vue_vue_type_script_setup_true_lang.js +7 -2
  16. package/dist/components/tabs/tabs.vue_vue_type_script_setup_true_lang.js.map +1 -1
  17. package/dist/components/tabs/tabs2.js.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/types/components/dock/context.d.ts +4 -1
  20. package/dist/types/components/dock/dock-group.vue.d.ts +6 -0
  21. package/dist/types/components/dock/dock.d.ts +52 -5
  22. package/dist/types/components/dock/dock.vue.d.ts +12 -4
  23. package/dist/types/components/dock/drop-side.d.ts +24 -0
  24. package/dist/types/components/dock/index.d.ts +20 -9
  25. package/dist/types/components/tabs/tab-drag.d.ts +8 -0
  26. package/package.json +3 -3
@@ -0,0 +1,37 @@
1
+ // src/components/dock/drop-side.ts
2
+ /**
3
+ * Whether `length` px can hold two parts of at least `min` each beside
4
+ * the 1px divider of a split. A number is a percent of the split.
5
+ */
6
+ function roomForSplit(length, min) {
7
+ const room = length - 1;
8
+ return room >= (typeof min === "number" ? room * min / 100 : Number.parseFloat(min) || 0) * 2;
9
+ }
10
+ /**
11
+ * Where a tab dropped at `x`, `y` on a group goes: the nearest edge within
12
+ * reach (a quarter of the side, at least 24px) splits it off there, the
13
+ * rest takes it in. The edges of a direction too small to split in two
14
+ * are part of the middle.
15
+ */
16
+ function dockDropSide(box, x, y, min) {
17
+ const edgeX = Math.max(24, box.width / 4);
18
+ const edgeY = Math.max(24, box.height / 4);
19
+ const across = roomForSplit(box.width, min.width);
20
+ const down = roomForSplit(box.height, min.height);
21
+ const reach = [
22
+ ["left", across && (x - box.left) / edgeX],
23
+ ["right", across && (box.left + box.width - x) / edgeX],
24
+ ["top", down && (y - box.top) / edgeY],
25
+ ["bottom", down && (box.top + box.height - y) / edgeY]
26
+ ];
27
+ let best = "center";
28
+ let nearest = 1;
29
+ for (const [side, d] of reach) if (d !== false && d < nearest) {
30
+ nearest = d;
31
+ best = side;
32
+ }
33
+ return best;
34
+ }
35
+ export { dockDropSide, roomForSplit };
36
+
37
+ //# sourceMappingURL=drop-side.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drop-side.js","names":[],"sources":["../../../src/components/dock/drop-side.ts"],"sourcesContent":["import type { SplitterLimit } from '../splitter/splitter'\nimport type { DockSide } from './layout'\n\ninterface Box {\n left: number\n top: number\n width: number\n height: number\n}\n\n/**\n * Whether `length` px can hold two parts of at least `min` each beside\n * the 1px divider of a split. A number is a percent of the split.\n */\nexport function roomForSplit(length: number, min: SplitterLimit) {\n // the parts share what the divider leaves, as in DouSplitter\n const room = length - 1\n const each = typeof min === 'number' ? (room * min) / 100 : Number.parseFloat(min) || 0\n return room >= each * 2\n}\n\n/**\n * Where a tab dropped at `x`, `y` on a group goes: the nearest edge within\n * reach (a quarter of the side, at least 24px) splits it off there, the\n * rest takes it in. The edges of a direction too small to split in two\n * are part of the middle.\n */\nexport function dockDropSide(\n box: Box,\n x: number,\n y: number,\n min: { width: SplitterLimit; height: SplitterLimit },\n): DockSide | 'center' {\n const edgeX = Math.max(24, box.width / 4)\n const edgeY = Math.max(24, box.height / 4)\n const across = roomForSplit(box.width, min.width)\n const down = roomForSplit(box.height, min.height)\n // each edge's distance relative to its reach\n const reach: [DockSide, number | false][] = [\n ['left', across && (x - box.left) / edgeX],\n ['right', across && (box.left + box.width - x) / edgeX],\n ['top', down && (y - box.top) / edgeY],\n ['bottom', down && (box.top + box.height - y) / edgeY],\n ]\n let best: DockSide | 'center' = 'center'\n let nearest = 1\n for (const [side, d] of reach)\n if (d !== false && d < nearest) {\n nearest = d\n best = side\n }\n return best\n}\n"],"mappings":";;;;;AAcA,SAAgB,aAAa,QAAgB,KAAoB;CAE/D,MAAM,OAAO,SAAS;CAEtB,OAAO,SADM,OAAO,QAAQ,WAAY,OAAO,MAAO,MAAM,OAAO,WAAW,GAAG,KAAK,KAChE;AACxB;;;;;;;AAQA,SAAgB,aACd,KACA,GACA,GACA,KACqB;CACrB,MAAM,QAAQ,KAAK,IAAI,IAAI,IAAI,QAAQ,CAAC;CACxC,MAAM,QAAQ,KAAK,IAAI,IAAI,IAAI,SAAS,CAAC;CACzC,MAAM,SAAS,aAAa,IAAI,OAAO,IAAI,KAAK;CAChD,MAAM,OAAO,aAAa,IAAI,QAAQ,IAAI,MAAM;CAEhD,MAAM,QAAsC;EAC1C,CAAC,QAAQ,WAAW,IAAI,IAAI,QAAQ,KAAK;EACzC,CAAC,SAAS,WAAW,IAAI,OAAO,IAAI,QAAQ,KAAK,KAAK;EACtD,CAAC,OAAO,SAAS,IAAI,IAAI,OAAO,KAAK;EACrC,CAAC,UAAU,SAAS,IAAI,MAAM,IAAI,SAAS,KAAK,KAAK;CACvD;CACA,IAAI,OAA4B;CAChC,IAAI,UAAU;CACd,KAAK,MAAM,CAAC,MAAM,MAAM,OACtB,IAAI,MAAM,SAAS,IAAI,SAAS;EAC9B,UAAU;EACV,OAAO;CACT;CACF,OAAO;AACT"}
@@ -63,23 +63,32 @@ function pressTab(event, options) {
63
63
  x: Math.min(e.clientX - rect.left, 16),
64
64
  y: -16
65
65
  };
66
- const clone = options.el.cloneNode(true);
67
- clone.removeAttribute("id");
68
- clone.classList.remove("is-dragging");
66
+ let clone;
67
+ if (options.ghost) {
68
+ clone = document.createElement("div");
69
+ clone.className = "dou-tabs__tab";
70
+ clone.textContent = options.ghost.label;
71
+ } else {
72
+ clone = options.el.cloneNode(true);
73
+ clone.removeAttribute("id");
74
+ clone.classList.remove("is-dragging");
75
+ Object.assign(clone.style, {
76
+ width: `${rect.width}px`,
77
+ height: `${rect.height}px`
78
+ });
79
+ }
69
80
  clone.classList.add("dou-tabs-ghost");
70
81
  clone.setAttribute("aria-hidden", "true");
71
82
  Object.assign(clone.style, {
72
83
  position: "fixed",
73
84
  left: "0",
74
85
  top: "0",
75
- width: `${rect.width}px`,
76
- height: `${rect.height}px`,
77
86
  margin: "0",
78
87
  boxSizing: "border-box",
79
88
  pointerEvents: "none",
80
89
  zIndex: "9999"
81
90
  });
82
- const tabs = options.el.closest(".dou-tabs");
91
+ const tabs = options.ghost ? options.ghost.tabs : options.el.closest(".dou-tabs");
83
92
  if (tabs) {
84
93
  const style = getComputedStyle(tabs);
85
94
  for (const name of [
@@ -89,7 +98,7 @@ function pressTab(event, options) {
89
98
  ]) clone.style.setProperty(name, style.getPropertyValue(name));
90
99
  clone.style.fontSize = style.fontSize;
91
100
  }
92
- const theme = options.el.closest("[data-dou-theme]")?.dataset.douTheme;
101
+ const theme = (tabs ?? options.el).closest("[data-dou-theme]")?.dataset.douTheme;
93
102
  if (theme) clone.dataset.douTheme = theme;
94
103
  document.body.append(clone);
95
104
  ghost = clone;
@@ -1 +1 @@
1
- {"version":3,"file":"tab-drag.js","names":[],"sources":["../../../src/components/tabs/tab-drag.ts"],"sourcesContent":["import { shallowRef } from 'vue'\nimport { holdPointer } from '../../utils/pointer'\nimport type { TabsValue } from './tabs'\n\n/** A tab being dragged. One at a time on the whole page. */\nexport interface TabDrag {\n value: TabsValue\n /** The tab's text, for the ghost and for what screen readers hear. */\n label: string\n /** The `group` of the tabs it comes from. */\n group: string | undefined\n /** The `name` of the tabs it comes from. */\n name: string | undefined\n /** Its index in the tabs it comes from. */\n index: number\n /** The tabs it comes from, to tell a move within them from one between tabs. */\n source: object\n}\n\n/** A place a tab can be dropped on: a row of tabs, or a group of a dock. */\nexport interface TabDropZone {\n el: () => Element | null | undefined\n accepts: (drag: TabDrag) => boolean\n /** The pointer is over the zone; show where the tab would go. */\n over: (drag: TabDrag, x: number, y: number) => void\n /** The pointer left the zone, or the drag ended. */\n leave: () => void\n drop: (drag: TabDrag) => void\n}\n\nconst zones = new Map<Element, TabDropZone>()\n\n/** The drag in progress, if any. */\nexport const activeTabDrag = shallowRef<TabDrag | null>(null)\n\nexport function registerTabDropZone(zone: TabDropZone) {\n let el: Element | null | undefined\n return {\n /** Call after the zone's element changes. */\n update() {\n const next = zone.el()\n if (next === el) return\n if (el) zones.delete(el)\n el = next\n if (el) zones.set(el, zone)\n },\n remove() {\n if (el) zones.delete(el)\n el = undefined\n },\n }\n}\n\n/** The innermost zone under the point that takes this tab. */\nfunction zoneAt(drag: TabDrag, x: number, y: number) {\n let el = document.elementFromPoint(x, y)\n while (el) {\n const zone = zones.get(el)\n if (zone?.accepts(drag)) return zone\n el = el.parentElement\n }\n return undefined\n}\n\nexport interface StartTabDragOptions {\n /** The tab element: it is copied for the ghost and dimmed while it moves. */\n el: HTMLElement\n /** An element that stays in the page for the whole drag, to capture the pointer. */\n root: HTMLElement | null\n drag: () => TabDrag\n onStart?: () => void\n /** The drag is over, dropped or not. */\n onEnd?: (dropped: boolean) => void\n}\n\n/**\n * Watch a press on a tab and turn it into a drag once the pointer moves\n * far enough. On touch the press has to be held first, so a swipe still\n * scrolls the row of tabs.\n */\nexport function pressTab(event: PointerEvent, options: StartTabDragOptions) {\n if (event.button !== 0 || activeTabDrag.value) return\n const start = { x: event.clientX, y: event.clientY }\n const press = event.pointerType === 'touch'\n let ready = !press\n let drag: TabDrag | null = null\n let ghost: HTMLElement | undefined\n let offset = { x: 0, y: 0 }\n let pointer = { x: 0, y: 0 }\n let current: TabDropZone | undefined\n let frame = 0\n const timer = press ? setTimeout(() => (ready = true), 250) : undefined\n const hold = holdPointer(event, options.root)\n\n function makeGhost(e: PointerEvent) {\n const rect = options.el.getBoundingClientRect()\n // below the pointer, off the row it moves along, so the mark where it drops stays in sight\n offset = { x: Math.min(e.clientX - rect.left, 16), y: -16 }\n const clone = options.el.cloneNode(true) as HTMLElement\n clone.removeAttribute('id')\n clone.classList.remove('is-dragging')\n clone.classList.add('dou-tabs-ghost')\n clone.setAttribute('aria-hidden', 'true')\n Object.assign(clone.style, {\n position: 'fixed',\n left: '0',\n top: '0',\n width: `${rect.width}px`,\n height: `${rect.height}px`,\n margin: '0',\n boxSizing: 'border-box',\n pointerEvents: 'none',\n zIndex: '9999',\n })\n // the copy sits on `body`: keep the size and theme of the tabs it came from\n const tabs = options.el.closest<HTMLElement>('.dou-tabs')\n if (tabs) {\n const style = getComputedStyle(tabs)\n for (const name of ['--dou-tabs-height', '--dou-tabs-padding-x', '--dou-tabs-icon-size'])\n clone.style.setProperty(name, style.getPropertyValue(name))\n clone.style.fontSize = style.fontSize\n }\n const theme = options.el.closest<HTMLElement>('[data-dou-theme]')?.dataset.douTheme\n if (theme) clone.dataset.douTheme = theme\n document.body.append(clone)\n ghost = clone\n moveGhost()\n }\n function moveGhost() {\n if (ghost) ghost.style.translate = `${pointer.x - offset.x}px ${pointer.y - offset.y}px`\n }\n\n // checked every frame, so a row that scrolls under a still pointer stays right\n function tick() {\n if (!drag) return\n const zone = zoneAt(drag, pointer.x, pointer.y)\n if (zone !== current) current?.leave()\n current = zone\n zone?.over(drag, pointer.x, pointer.y)\n frame = requestAnimationFrame(tick)\n }\n\n function begin(e: PointerEvent) {\n drag = options.drag()\n activeTabDrag.value = drag\n hold.grab()\n document.documentElement.classList.add('dou-tabs-dragging')\n makeGhost(e)\n options.onStart?.()\n frame = requestAnimationFrame(tick)\n }\n\n function end(commit: boolean) {\n stop()\n cancelAnimationFrame(frame)\n ghost?.remove()\n document.documentElement.classList.remove('dou-tabs-dragging')\n const finished = drag\n drag = null\n activeTabDrag.value = null\n if (!finished) return\n // where the pointer is now, also when no frame ran since the last move\n const zone = commit ? zoneAt(finished, pointer.x, pointer.y) : undefined\n if (zone !== current) current?.leave()\n current = undefined\n if (zone) {\n // brought up to date with the pointer, then dropped on; it clears what it showed\n zone.over(finished, pointer.x, pointer.y)\n zone.drop(finished)\n }\n options.onEnd?.(!!zone)\n }\n\n const onMove = (e: PointerEvent) => {\n pointer = { x: e.clientX, y: e.clientY }\n if (!drag) {\n if (Math.hypot(e.clientX - start.x, e.clientY - start.y) <= 4) return\n if (!ready) return stop()\n begin(e)\n }\n e.preventDefault()\n moveGhost()\n }\n const onUp = () => (drag ? end(true) : stop())\n const onCancel = () => (drag ? end(false) : stop())\n const onKey = (e: KeyboardEvent) => {\n if (e.key !== 'Escape' || !drag) return\n e.preventDefault()\n e.stopPropagation()\n end(false)\n }\n function stop() {\n clearTimeout(timer)\n hold.release()\n window.removeEventListener('pointermove', onMove)\n window.removeEventListener('pointerup', onUp)\n window.removeEventListener('pointercancel', onCancel)\n window.removeEventListener('keydown', onKey, true)\n }\n window.addEventListener('pointermove', onMove)\n window.addEventListener('pointerup', onUp)\n window.addEventListener('pointercancel', onCancel)\n window.addEventListener('keydown', onKey, true)\n}\n"],"mappings":";;;AA8BA,IAAM,wBAAQ,IAAI,IAA0B;;AAG5C,IAAa,gBAAgB,WAA2B,IAAI;AAE5D,SAAgB,oBAAoB,MAAmB;CACrD,IAAI;CACJ,OAAO;;EAEL,SAAS;GACP,MAAM,OAAO,KAAK,GAAG;GACrB,IAAI,SAAS,IAAI;GACjB,IAAI,IAAI,MAAM,OAAO,EAAE;GACvB,KAAK;GACL,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI;EAC5B;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Q,CAAC,IAAI,KAAA;EAC/D,IAAI,SAAS,SAAS,SAAS,MAAM;EACrC,UAAU,KAAA;EACV,IAAI,MAAM;GAER,KAAK,KAAK,UAAU,QAAQ,GAAG,QAAQ,CAAC;GACxC,KAAK,KAAK,QAAQ;EACpB;EACA,QAAQ,QAAQ,CAAC,CAAC,IAAI;CACxB;CAEA,MAAM,UAAU,MAAoB;EAClC,UAAU;GAAE,GAAG,EAAE;GAAS,GAAG,EAAE;EAAQ;EACvC,IAAI,CAAC,MAAM;GACT,IAAI,KAAK,MAAM,EAAE,UAAU,MAAM,GAAG,EAAE,UAAU,MAAM,CAAC,KAAK,GAAG;GAC/D,IAAI,CAAC,OAAO,OAAO,KAAK;GACxB,MAAM,CAAC;EACT;EACA,EAAE,eAAe;EACjB,UAAU;CACZ;CACA,MAAM,aAAc,OAAO,IAAI,IAAI,IAAI,KAAK;CAC5C,MAAM,iBAAkB,OAAO,IAAI,KAAK,IAAI,KAAK;CACjD,MAAM,SAAS,MAAqB;EAClC,IAAI,EAAE,QAAQ,YAAY,CAAC,MAAM;EACjC,EAAE,eAAe;EACjB,EAAE,gBAAgB;EAClB,IAAI,KAAK;CACX;CACA,SAAS,OAAO;EACd,aAAa,KAAK;EAClB,KAAK,QAAQ;EACb,OAAO,oBAAoB,eAAe,MAAM;EAChD,OAAO,oBAAoB,aAAa,IAAI;EAC5C,OAAO,oBAAoB,iBAAiB,QAAQ;EACpD,OAAO,oBAAoB,WAAW,OAAO,IAAI;CACnD;CACA,OAAO,iBAAiB,eAAe,MAAM;CAC7C,OAAO,iBAAiB,aAAa,IAAI;CACzC,OAAO,iBAAiB,iBAAiB,QAAQ;CACjD,OAAO,iBAAiB,WAAW,OAAO,IAAI;AAChD"}
1
+ {"version":3,"file":"tab-drag.js","names":[],"sources":["../../../src/components/tabs/tab-drag.ts"],"sourcesContent":["import { shallowRef } from 'vue'\nimport { holdPointer } from '../../utils/pointer'\nimport type { TabsValue } from './tabs'\n\n/** A tab being dragged. One at a time on the whole page. */\nexport interface TabDrag {\n value: TabsValue\n /** The tab's text, for the ghost and for what screen readers hear. */\n label: string\n /** The `group` of the tabs it comes from. */\n group: string | undefined\n /** The `name` of the tabs it comes from. */\n name: string | undefined\n /** Its index in the tabs it comes from. */\n index: number\n /** The tabs it comes from, to tell a move within them from one between tabs. */\n source: object\n}\n\n/** A place a tab can be dropped on: a row of tabs, or a group of a dock. */\nexport interface TabDropZone {\n el: () => Element | null | undefined\n accepts: (drag: TabDrag) => boolean\n /** The pointer is over the zone; show where the tab would go. */\n over: (drag: TabDrag, x: number, y: number) => void\n /** The pointer left the zone, or the drag ended. */\n leave: () => void\n drop: (drag: TabDrag) => void\n}\n\nconst zones = new Map<Element, TabDropZone>()\n\n/** The drag in progress, if any. */\nexport const activeTabDrag = shallowRef<TabDrag | null>(null)\n\nexport function registerTabDropZone(zone: TabDropZone) {\n let el: Element | null | undefined\n return {\n /** Call after the zone's element changes. */\n update() {\n const next = zone.el()\n if (next === el) return\n if (el) zones.delete(el)\n el = next\n if (el) zones.set(el, zone)\n },\n remove() {\n if (el) zones.delete(el)\n el = undefined\n },\n }\n}\n\n/** The innermost zone under the point that takes this tab. */\nfunction zoneAt(drag: TabDrag, x: number, y: number) {\n let el = document.elementFromPoint(x, y)\n while (el) {\n const zone = zones.get(el)\n if (zone?.accepts(drag)) return zone\n el = el.parentElement\n }\n return undefined\n}\n\nexport interface StartTabDragOptions {\n /** The tab element: it is copied for the ghost and dimmed while it moves. */\n el: HTMLElement\n /**\n * For a drag that starts on something other than a tab: the ghost is a\n * tab with this text, sized like the tabs of `tabs`, in place of a copy of `el`.\n */\n ghost?: { label: string; tabs: HTMLElement | null | undefined }\n /** An element that stays in the page for the whole drag, to capture the pointer. */\n root: HTMLElement | null\n drag: () => TabDrag\n onStart?: () => void\n /** The drag is over, dropped or not. */\n onEnd?: (dropped: boolean) => void\n}\n\n/**\n * Watch a press on a tab and turn it into a drag once the pointer moves\n * far enough. On touch the press has to be held first, so a swipe still\n * scrolls the row of tabs.\n */\nexport function pressTab(event: PointerEvent, options: StartTabDragOptions) {\n if (event.button !== 0 || activeTabDrag.value) return\n const start = { x: event.clientX, y: event.clientY }\n const press = event.pointerType === 'touch'\n let ready = !press\n let drag: TabDrag | null = null\n let ghost: HTMLElement | undefined\n let offset = { x: 0, y: 0 }\n let pointer = { x: 0, y: 0 }\n let current: TabDropZone | undefined\n let frame = 0\n const timer = press ? setTimeout(() => (ready = true), 250) : undefined\n const hold = holdPointer(event, options.root)\n\n function makeGhost(e: PointerEvent) {\n const rect = options.el.getBoundingClientRect()\n // below the pointer, off the row it moves along, so the mark where it drops stays in sight\n offset = { x: Math.min(e.clientX - rect.left, 16), y: -16 }\n let clone: HTMLElement\n if (options.ghost) {\n clone = document.createElement('div')\n clone.className = 'dou-tabs__tab'\n clone.textContent = options.ghost.label\n } else {\n clone = options.el.cloneNode(true) as HTMLElement\n clone.removeAttribute('id')\n clone.classList.remove('is-dragging')\n Object.assign(clone.style, { width: `${rect.width}px`, height: `${rect.height}px` })\n }\n clone.classList.add('dou-tabs-ghost')\n clone.setAttribute('aria-hidden', 'true')\n Object.assign(clone.style, {\n position: 'fixed',\n left: '0',\n top: '0',\n margin: '0',\n boxSizing: 'border-box',\n pointerEvents: 'none',\n zIndex: '9999',\n })\n // the copy sits on `body`: keep the size and theme of the tabs it came from\n const tabs = options.ghost ? options.ghost.tabs : options.el.closest<HTMLElement>('.dou-tabs')\n if (tabs) {\n const style = getComputedStyle(tabs)\n for (const name of ['--dou-tabs-height', '--dou-tabs-padding-x', '--dou-tabs-icon-size'])\n clone.style.setProperty(name, style.getPropertyValue(name))\n clone.style.fontSize = style.fontSize\n }\n const theme = (tabs ?? options.el).closest<HTMLElement>('[data-dou-theme]')?.dataset.douTheme\n if (theme) clone.dataset.douTheme = theme\n document.body.append(clone)\n ghost = clone\n moveGhost()\n }\n function moveGhost() {\n if (ghost) ghost.style.translate = `${pointer.x - offset.x}px ${pointer.y - offset.y}px`\n }\n\n // checked every frame, so a row that scrolls under a still pointer stays right\n function tick() {\n if (!drag) return\n const zone = zoneAt(drag, pointer.x, pointer.y)\n if (zone !== current) current?.leave()\n current = zone\n zone?.over(drag, pointer.x, pointer.y)\n frame = requestAnimationFrame(tick)\n }\n\n function begin(e: PointerEvent) {\n drag = options.drag()\n activeTabDrag.value = drag\n hold.grab()\n document.documentElement.classList.add('dou-tabs-dragging')\n makeGhost(e)\n options.onStart?.()\n frame = requestAnimationFrame(tick)\n }\n\n function end(commit: boolean) {\n stop()\n cancelAnimationFrame(frame)\n ghost?.remove()\n document.documentElement.classList.remove('dou-tabs-dragging')\n const finished = drag\n drag = null\n activeTabDrag.value = null\n if (!finished) return\n // where the pointer is now, also when no frame ran since the last move\n const zone = commit ? zoneAt(finished, pointer.x, pointer.y) : undefined\n if (zone !== current) current?.leave()\n current = undefined\n if (zone) {\n // brought up to date with the pointer, then dropped on; it clears what it showed\n zone.over(finished, pointer.x, pointer.y)\n zone.drop(finished)\n }\n options.onEnd?.(!!zone)\n }\n\n const onMove = (e: PointerEvent) => {\n pointer = { x: e.clientX, y: e.clientY }\n if (!drag) {\n if (Math.hypot(e.clientX - start.x, e.clientY - start.y) <= 4) return\n if (!ready) return stop()\n begin(e)\n }\n e.preventDefault()\n moveGhost()\n }\n const onUp = () => (drag ? end(true) : stop())\n const onCancel = () => (drag ? end(false) : stop())\n const onKey = (e: KeyboardEvent) => {\n if (e.key !== 'Escape' || !drag) return\n e.preventDefault()\n e.stopPropagation()\n end(false)\n }\n function stop() {\n clearTimeout(timer)\n hold.release()\n window.removeEventListener('pointermove', onMove)\n window.removeEventListener('pointerup', onUp)\n window.removeEventListener('pointercancel', onCancel)\n window.removeEventListener('keydown', onKey, true)\n }\n window.addEventListener('pointermove', onMove)\n window.addEventListener('pointerup', onUp)\n window.addEventListener('pointercancel', onCancel)\n window.addEventListener('keydown', onKey, true)\n}\n"],"mappings":";;;AA8BA,IAAM,wBAAQ,IAAI,IAA0B;;AAG5C,IAAa,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Q;EACb,OAAO,oBAAoB,eAAe,MAAM;EAChD,OAAO,oBAAoB,aAAa,IAAI;EAC5C,OAAO,oBAAoB,iBAAiB,QAAQ;EACpD,OAAO,oBAAoB,WAAW,OAAO,IAAI;CACnD;CACA,OAAO,iBAAiB,eAAe,MAAM;CAC7C,OAAO,iBAAiB,aAAa,IAAI;CACzC,OAAO,iBAAiB,iBAAiB,QAAQ;CACjD,OAAO,iBAAiB,WAAW,OAAO,IAAI;AAChD"}
@@ -233,8 +233,13 @@ var tabs_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
233
233
  });
234
234
  return index < 0 ? entries.length : index;
235
235
  }
236
+ /**
237
+ * Whether the tab comes from these tabs: dragged from them, or from
238
+ * elsewhere (a list outside a dock) when these tabs hold it already.
239
+ */
240
+ const fromHere = (drag) => drag.source === self || drag.name !== void 0 && drag.name === props.name && drag.group === props.group;
236
241
  /** Whether dropping there leaves the tab where it is. */
237
- const stays = (drag, index) => drag.source === self && (index === drag.index || index === drag.index + 1);
242
+ const stays = (drag, index) => fromHere(drag) && (index === drag.index || index === drag.index + 1);
238
243
  function markerOffset(index) {
239
244
  const entries = panels.value;
240
245
  const style = getComputedStyle(listRef.value);
@@ -292,7 +297,7 @@ var tabs_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
292
297
  const index = marker.value?.index;
293
298
  marker.value = null;
294
299
  if (index === void 0) return;
295
- const within = drag.source === self;
300
+ const within = fromHere(drag);
296
301
  emit("move", {
297
302
  value: drag.value,
298
303
  from: {
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_useSlots","_openBlock","_createElementBlock","_normalizeClass","_unref","_normalizeStyle","_createElementVNode","_createVNode","_createCommentVNode","_Fragment","_renderList","_createBlock","_withCtx","_resolveDynamicComponent","_withModifiers","_renderSlot"],"sources":["../../../src/components/tabs/tabs.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n h,\n nextTick,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n provide,\n ref,\n shallowRef,\n toRef,\n triggerRef,\n useId,\n useTemplateRef,\n watch,\n} from 'vue'\nimport { ChevronLeftIcon, ChevronRightIcon, CloseIcon, PlusIcon } from '@dou-ui/icons'\nimport { useReducedMotion } from '../../composables/use-motion'\nimport { announce } from '../../utils/announce'\nimport { useNamespace } from '../../utils/namespace'\nimport { scrollPositionOf } from '../../utils/scroll'\nimport { devWarn } from '../../utils/status-check'\nimport { useLocale } from '../config-provider/use-config'\nimport { useFormSize } from '../form/use-form-item'\nimport { DouTooltip } from '../tooltip'\nimport { pressTab, registerTabDropZone } from './tab-drag'\nimport { tabsKey } from './tabs'\nimport type { FunctionalComponent, VNode } from 'vue'\nimport type { TabDrag } from './tab-drag'\nimport type { TabPanelEntry, TabsMoveEvent, TabsProps, TabsSlots, TabsValue } from './tabs'\n\ndefineOptions({ name: 'DouTabs' })\n\nconst props = withDefaults(defineProps<TabsProps>(), {\n activation: 'auto',\n placement: 'top',\n closable: false,\n addable: false,\n iconOnly: false,\n draggable: false,\n})\nconst model = defineModel<TabsValue>()\nconst emit = defineEmits<{\n change: [value: TabsValue]\n remove: [value: TabsValue]\n add: []\n move: [event: TabsMoveEvent]\n}>()\nconst slots = defineSlots<TabsSlots>()\n\nconst ns = useNamespace('tabs')\nconst { t } = useLocale()\nconst id = useId()\nconst vertical = computed(() => props.placement !== 'top')\nconst size = useFormSize(() => props.size)\n\nconst panels = shallowRef<TabPanelEntry[]>([])\n\n// Panels register in the order they are set up, which is their order on\n// the page; a panel added later is sorted in once it is mounted.\nfunction register(entry: TabPanelEntry) {\n panels.value = [...panels.value, entry]\n}\nfunction unregister(uid: number) {\n panels.value = panels.value.filter((entry) => entry.uid !== uid)\n}\n/** Put the panels in their order on the page; whether that changed anything. */\nfunction sync() {\n // oxlint-disable-next-line unicorn/no-array-sort -- sorts a copy\n const sorted = [...panels.value].sort((a, b) => {\n if (!a.el.value || !b.el.value) return 0\n return a.el.value.compareDocumentPosition(b.el.value) & Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1\n })\n if (!sorted.some((entry, index) => entry !== panels.value[index])) return false\n panels.value = sorted\n return true\n}\nfunction reorder() {\n if (!sync()) triggerRef(panels)\n}\n// The panels may have been put in a new order, e.g. after a `move`.\nonUpdated(sync)\n\nconst firstEnabled = computed(() => panels.value.find((entry) => !entry.props.disabled))\nconst selected = computed(() => model.value ?? firstEnabled.value?.props.value)\n\nconst key = (value: TabsValue) => String(value).replace(/\\s+/g, '-')\nconst tabId = (value: TabsValue) => `${id}-tab-${key(value)}`\nconst panelId = (value: TabsValue) => `${id}-panel-${key(value)}`\n\nprovide(tabsKey, {\n selected: toRef(() => selected.value),\n tabId,\n panelId,\n register,\n unregister,\n reorder,\n})\n\nasync function select(entry: TabPanelEntry) {\n if (entry.props.disabled) return\n await selectValue(entry.props.value)\n}\nasync function selectValue(next: TabsValue) {\n if (next === selected.value) return\n if (props.beforeLeave && !(await props.beforeLeave(next, selected.value))) return\n model.value = next\n emit('change', next)\n}\n\nconst isClosable = (entry: TabPanelEntry) =>\n !entry.props.disabled && (entry.props.closable ?? props.closable)\n\nfunction remove(entry: TabPanelEntry) {\n if (isClosable(entry)) emit('remove', entry.props.value)\n}\n\nconst listRef = useTemplateRef<HTMLElement>('list')\nconst headerRef = useTemplateRef<HTMLElement>('header')\nconst tabElements = new Map<number, HTMLElement>()\n\nfunction setTabElement(uid: number, el: unknown) {\n if (el instanceof HTMLElement) tabElements.set(uid, el)\n else tabElements.delete(uid)\n}\nfunction tabElement(entry: TabPanelEntry) {\n return tabElements.get(entry.uid)\n}\n\n/** The label slot of a panel, rendered inside its tab. */\nconst TabLabel: FunctionalComponent<{ entry: TabPanelEntry; selected: boolean }> = ({\n entry,\n selected: isSelected,\n}) => (entry.slots.label?.({ selected: isSelected }) as VNode[] | undefined) ?? labelText(entry)\n\nconst labelText = (entry: TabPanelEntry) => entry.props.label ?? String(entry.props.value)\n\n/** With `iconOnly`, whether the tab shows its icon alone; without an icon it keeps its text. */\nfunction iconAlone(entry: TabPanelEntry) {\n if (!props.iconOnly) return false\n if (entry.props.icon) {\n // the label slot cannot name an icon: the tab would be read out as its value\n if (process.env.NODE_ENV !== 'production' && entry.props.label === undefined)\n devWarn(\n `[dou-ui] DouTabs: \\`iconOnly\\` names each tab by its \\`label\\`; the DouTabPanel \"${entry.props.value}\" has none and is named by its value.`,\n )\n return true\n }\n if (process.env.NODE_ENV !== 'production')\n devWarn(\n `[dou-ui] DouTabs: \\`iconOnly\\` needs an \\`icon\\` on each DouTabPanel; \"${labelText(entry)}\" keeps its text.`,\n )\n return false\n}\n\n// With `iconOnly`, the label shows in a tooltip: beside a column, above a row.\nconst tipPlacement = computed(() =>\n props.placement === 'start' ? 'right' : props.placement === 'end' ? 'left' : 'top',\n)\nconst TabTip: FunctionalComponent<{ entry: TabPanelEntry }> = ({ entry }, { slots: tip }) =>\n iconAlone(entry)\n ? h(DouTooltip, { content: labelText(entry), placement: tipPlacement.value }, tip)\n : tip.default?.()\n\nfunction onKeydown(event: KeyboardEvent, entry: TabPanelEntry) {\n if (event.altKey && isDraggable(entry) && moveByKey(event, entry)) return\n const enabled = panels.value.filter((panel) => !panel.props.disabled)\n const index = enabled.indexOf(entry)\n let target: TabPanelEntry | undefined\n const [prev, next] = vertical.value ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight']\n switch (event.key) {\n case next:\n target = enabled[(index + 1) % enabled.length]\n break\n case prev:\n target = enabled[(index - 1 + enabled.length) % enabled.length]\n break\n case 'Delete':\n case 'Backspace':\n if (!isClosable(entry)) return\n event.preventDefault()\n remove(entry)\n return\n case 'Home':\n target = enabled[0]\n break\n case 'End':\n target = enabled[enabled.length - 1]\n break\n case 'Enter':\n case ' ':\n event.preventDefault()\n void select(entry)\n return\n default:\n return\n }\n if (!target) return\n event.preventDefault()\n tabElement(target)?.focus()\n if (props.activation === 'auto') void select(target)\n}\n\n/* dragging */\n\nconst isDraggable = (entry: TabPanelEntry) =>\n !entry.props.disabled && (entry.props.draggable ?? props.draggable)\n\n/** This instance, to tell a move within the tabs from one that comes from other tabs. */\nconst self = {}\nconst draggingUid = ref<number | null>(null)\nlet clickBlocked = false\n\nfunction onClick(entry: TabPanelEntry) {\n // the press that ended a drag is not a click on the tab\n if (clickBlocked) return\n void select(entry)\n}\n\nfunction onPointerdown(event: PointerEvent, entry: TabPanelEntry) {\n if (!isDraggable(entry) || (event.target as Element).closest(`.${ns.e('close')}`)) return\n const el = tabElement(entry)\n if (!el) return\n pressTab(event, {\n el,\n root: listRef.value,\n drag: () => ({\n value: entry.props.value,\n label: labelText(entry),\n group: props.group,\n name: props.name,\n index: panels.value.indexOf(entry),\n source: self,\n }),\n onStart: () => (draggingUid.value = entry.uid),\n onEnd: () => {\n draggingUid.value = null\n clickBlocked = true\n setTimeout(() => (clickBlocked = false))\n },\n })\n}\n\n/** Where a tab dropped now would go: before the tab at `index`, or after the last. */\nconst marker = ref<{ index: number; at: number } | null>(null)\n\nfunction insertionAt(x: number, y: number) {\n const entries = panels.value\n const index = entries.findIndex((entry) => {\n const rect = tabElement(entry)?.getBoundingClientRect()\n if (!rect) return false\n return vertical.value ? y < rect.top + rect.height / 2 : x < rect.left + rect.width / 2\n })\n return index < 0 ? entries.length : index\n}\n\n/** Whether dropping there leaves the tab where it is. */\nconst stays = (drag: TabDrag, index: number) =>\n drag.source === self && (index === drag.index || index === drag.index + 1)\n\nfunction markerOffset(index: number) {\n const entries = panels.value\n const style = getComputedStyle(listRef.value!)\n const gap = Number.parseFloat(vertical.value ? style.rowGap : style.columnGap) || 0\n const before = entries[index] && tabElement(entries[index])\n if (before) return (vertical.value ? before.offsetTop : before.offsetLeft) - gap / 2\n const last = entries.at(-1)\n const after = last && tabElement(last)\n if (!after) return 0\n return vertical.value\n ? after.offsetTop + after.offsetHeight + gap / 2\n : after.offsetLeft + after.offsetWidth + gap / 2\n}\n\n/** Scroll a row that does not fit while the pointer is near one of its ends. */\nfunction scrollNearEdge(x: number, y: number) {\n const list = listRef.value\n if (!list) return\n const rect = list.getBoundingClientRect()\n const EDGE = 32\n const speed = (d: number) => Math.ceil(((EDGE - Math.max(0, d)) / EDGE) * 10)\n const [pos, startEdge, endEdge] = vertical.value\n ? [y, rect.top, rect.bottom]\n : [x, rect.left, rect.right]\n let delta = 0\n if (pos - startEdge < EDGE) delta = -speed(pos - startEdge)\n else if (endEdge - pos < EDGE) delta = speed(endEdge - pos)\n if (!delta) return\n if (vertical.value) list.scrollTop += delta\n else list.scrollLeft += delta\n}\n\nconst dropZone = registerTabDropZone({\n el: () => headerRef.value,\n // its own tabs always come back; tabs from others only when these take drops\n accepts: (drag) =>\n drag.source === self || (props.draggable && !!props.group && drag.group === props.group),\n over(drag, x, y) {\n scrollNearEdge(x, y)\n const index = insertionAt(x, y)\n if (stays(drag, index)) {\n marker.value = null\n return\n }\n // kept inside the row, which cuts off what sticks out\n const list = listRef.value!\n const end = (vertical.value ? list.scrollHeight : list.scrollWidth) - 2\n const at = Math.min(Math.max(markerOffset(index), 1), end)\n if (marker.value?.index !== index || marker.value.at !== at) marker.value = { index, at }\n },\n leave: () => (marker.value = null),\n drop(drag) {\n const index = marker.value?.index\n marker.value = null\n if (index === undefined) return\n const within = drag.source === self\n emit('move', {\n value: drag.value,\n from: { name: drag.name, index: drag.index },\n to: { name: props.name, index: within && index > drag.index ? index - 1 : index },\n })\n // dragging a tab is using it\n void selectValue(drag.value)\n },\n})\nonMounted(() => {\n dropZone.update()\n if (process.env.NODE_ENV !== 'production' && props.group && props.name === undefined)\n devWarn(\n `[dou-ui] DouTabs: tabs in the group \"${props.group}\" need a \\`name\\`; \\`move\\` cannot tell which tabs a tab came from without it.`,\n )\n})\nonUpdated(() => dropZone.update())\nonBeforeUnmount(() => dropZone.remove())\n\nconst markerStyle = computed(() => {\n const at = marker.value?.at\n if (at === undefined) return { display: 'none' }\n return { transform: vertical.value ? `translateY(${at}px)` : `translateX(${at}px)` }\n})\n\n/** A tab moved with the keyboard keeps the focus once it is in its new place. */\nlet focusAfterMove: TabsValue | undefined\n\nfunction moveByKey(event: KeyboardEvent, entry: TabPanelEntry) {\n const [prev, next] = vertical.value ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight']\n const entries = panels.value\n const index = entries.indexOf(entry)\n const last = entries.length - 1\n const target =\n event.key === prev\n ? index - 1\n : event.key === next\n ? index + 1\n : event.key === 'Home'\n ? 0\n : event.key === 'End'\n ? last\n : null\n if (target === null) return false\n event.preventDefault()\n if (target < 0 || target > last || target === index) return true\n focusAfterMove = entry.props.value\n emit('move', {\n value: entry.props.value,\n from: { name: props.name, index },\n to: { name: props.name, index: target },\n })\n announce(\n t('tabs.moved', { label: labelText(entry), position: target + 1, total: entries.length }),\n )\n return true\n}\n\nwatch(\n panels,\n () => {\n if (focusAfterMove === undefined) return\n const entry = panels.value.find((panel) => panel.props.value === focusAfterMove)\n focusAfterMove = undefined\n const el = entry && tabElement(entry)\n if (el && document.activeElement !== el) el.focus()\n },\n { flush: 'post' },\n)\n\nconst moveKeys = computed(() =>\n vertical.value\n ? 'Alt+ArrowUp Alt+ArrowDown Alt+Home Alt+End'\n : 'Alt+ArrowLeft Alt+ArrowRight Alt+Home Alt+End',\n)\nfunction keyShortcuts(entry: TabPanelEntry) {\n const keys = [isClosable(entry) && 'Delete', isDraggable(entry) && moveKeys.value].filter(Boolean)\n return keys.length ? keys.join(' ') : undefined\n}\n\n// The underline slides between the tabs. It is measured from the\n// selected tab, like the selection of a segmented control.\nconst indicator = ref<{ left: number; top: number; width: number; height: number } | null>(null)\nconst settled = ref(false)\n\nfunction measure() {\n const list = listRef.value\n const entry = panels.value.find((panel) => panel.props.value === selected.value)\n const tab = entry && tabElement(entry)\n if (!list || !tab) {\n indicator.value = null\n return\n }\n indicator.value = {\n left: tab.offsetLeft,\n top: tab.offsetTop,\n width: tab.offsetWidth,\n height: tab.offsetHeight,\n }\n}\n\n// When the tabs do not fit, the list scrolls sideways: the edges fade and\n// arrows appear on the side that has more, and the selected tab is kept in view.\nconst overflow = ref({ start: false, end: false })\nconst reduced = useReducedMotion()\n\n// Arrows in a narrow row would leave no room for a single tab: there the\n// row scrolls by swiping, the wheel or the keyboard alone.\nconst ARROWS_MIN_WIDTH = 160\nconst arrows = ref(true)\n\nfunction updateOverflow() {\n // a header not laid out yet has no width to go by\n const width = headerRef.value?.clientWidth || Infinity\n arrows.value = width >= ARROWS_MIN_WIDTH\n const list = listRef.value\n if (!list) {\n overflow.value = { start: false, end: false }\n return\n }\n if (vertical.value) {\n // a column only overflows with a fixed `height`; there it fades but has no arrows\n const max = list.scrollHeight - list.clientHeight\n // kept in range while the column bounces\n const top = scrollPositionOf(list).top\n overflow.value = { start: top > 1, end: top < max - 1 }\n return\n }\n const max = list.scrollWidth - list.clientWidth\n // from the start, also right to left, and kept in range while the row bounces\n const left = Math.abs(scrollPositionOf(list).left)\n // a sub-pixel remainder is not something to scroll to\n overflow.value = { start: left > 1, end: left < max - 1 }\n}\n\nfunction reveal(smooth: boolean) {\n const list = listRef.value\n const entry = panels.value.find((panel) => panel.props.value === selected.value)\n const tab = entry && tabElement(entry)\n if (!list || !tab) return\n // leave room for the faded edge, so the tab is not under it\n const margin = 32\n if (vertical.value) {\n const top = tab.offsetTop - margin\n const bottom = tab.offsetTop + tab.offsetHeight + margin - list.clientHeight\n const target = top < list.scrollTop ? top : bottom > list.scrollTop ? bottom : null\n if (target === null) return\n list.scrollTo({\n top: Math.max(0, target),\n behavior: smooth && !reduced.value ? 'smooth' : 'auto',\n })\n return\n }\n const left = tab.offsetLeft - margin\n const right = tab.offsetLeft + tab.offsetWidth + margin - list.clientWidth\n const target = left < list.scrollLeft ? left : right > list.scrollLeft ? right : null\n if (target === null) return\n list.scrollTo({\n left: Math.max(0, target),\n behavior: smooth && !reduced.value ? 'smooth' : 'auto',\n })\n}\n\nfunction scrollByPage(direction: 1 | -1) {\n const list = listRef.value\n if (!list) return\n list.scrollBy({\n left: direction * list.clientWidth * 0.8,\n behavior: reduced.value ? 'auto' : 'smooth',\n })\n}\n\nlet observer: ResizeObserver | undefined\nonMounted(() => {\n measure()\n updateOverflow()\n reveal(false)\n requestAnimationFrame(() => (settled.value = true))\n if (typeof ResizeObserver !== 'undefined' && listRef.value) {\n observer = new ResizeObserver(() => {\n measure()\n updateOverflow()\n })\n observer.observe(listRef.value)\n }\n})\nonBeforeUnmount(() => observer?.disconnect())\nwatch(\n [selected, panels, size, () => props.placement, () => props.iconOnly, () => props.height],\n () =>\n nextTick(() => {\n measure()\n updateOverflow()\n reveal(settled.value)\n }),\n)\n\nconst rootStyle = computed(() =>\n props.height === undefined\n ? undefined\n : {\n height: typeof props.height === 'number' ? `${props.height}px` : props.height,\n },\n)\n\nconst indicatorStyle = computed(() => {\n const box = indicator.value\n if (!box) return { display: 'none' }\n return vertical.value\n ? { transform: `translateY(${box.top}px)`, height: `${box.height}px` }\n : { transform: `translateX(${box.left}px)`, width: `${box.width}px` }\n})\n</script>\n\n<template>\n <div\n :class=\"[\n ns.b(),\n ns.m(size),\n ns.is('settled', settled),\n ns.is('vertical', vertical),\n vertical && ns.is(`placement-${placement}`, true),\n ns.is('fixed', height !== undefined),\n ns.is('icon-only', iconOnly),\n ns.is('drop-target', !!marker),\n ]\"\n :style=\"rootStyle\"\n >\n <div ref=\"header\" :class=\"ns.e('header')\">\n <button\n v-if=\"!vertical && arrows && (overflow.start || overflow.end)\"\n type=\"button\"\n tabindex=\"-1\"\n :class=\"[ns.e('scroll'), ns.is('start', true)]\"\n :disabled=\"!overflow.start\"\n :aria-label=\"t('tabs.scrollPrev')\"\n @click=\"scrollByPage(-1)\"\n >\n <ChevronLeftIcon />\n </button>\n <div\n ref=\"list\"\n :class=\"[\n ns.e('list'),\n ns.is('fade-start', overflow.start),\n ns.is('fade-end', overflow.end),\n ]\"\n role=\"tablist\"\n :aria-orientation=\"vertical ? 'vertical' : 'horizontal'\"\n @scroll.passive=\"updateOverflow\"\n >\n <template v-for=\"entry in panels\" :key=\"entry.uid\">\n <TabTip :entry=\"entry\">\n <button\n :id=\"tabId(entry.props.value)\"\n :ref=\"(el) => setTabElement(entry.uid, el)\"\n type=\"button\"\n role=\"tab\"\n :class=\"[\n ns.e('tab'),\n ns.is('selected', entry.props.value === selected),\n ns.is('disabled', !!entry.props.disabled),\n ns.is('closable', isClosable(entry)),\n ns.is('icon-alone', iconAlone(entry)),\n ns.is('draggable', isDraggable(entry)),\n ns.is('dragging', draggingUid === entry.uid),\n ]\"\n :aria-selected=\"entry.props.value === selected\"\n :aria-controls=\"panelId(entry.props.value)\"\n :aria-label=\"iconAlone(entry) ? labelText(entry) : undefined\"\n :aria-disabled=\"entry.props.disabled || undefined\"\n :tabindex=\"entry.props.value === selected ? 0 : -1\"\n :aria-keyshortcuts=\"keyShortcuts(entry)\"\n @click=\"onClick(entry)\"\n @pointerdown=\"onPointerdown($event, entry)\"\n @keydown=\"onKeydown($event, entry)\"\n >\n <component\n :is=\"entry.props.icon\"\n v-if=\"entry.props.icon\"\n :class=\"ns.e('icon')\"\n aria-hidden=\"true\"\n />\n <span v-if=\"!iconAlone(entry)\" :class=\"ns.e('label')\">\n <TabLabel :entry=\"entry\" :selected=\"entry.props.value === selected\" />\n </span>\n <!-- not a button of its own: a tab cannot hold one; `Delete` closes it from the keyboard.\n An icon alone already has the label's tooltip, so the close button goes without. -->\n <DouTooltip\n v-if=\"isClosable(entry)\"\n :content=\"t('tabs.close')\"\n shortcut=\"delete\"\n :disabled=\"iconAlone(entry)\"\n >\n <span :class=\"ns.e('close')\" aria-hidden=\"true\" @click.stop=\"remove(entry)\">\n <CloseIcon />\n </span>\n </DouTooltip>\n </button>\n </TabTip>\n </template>\n <span :class=\"ns.e('indicator')\" :style=\"indicatorStyle\" aria-hidden=\"true\" />\n <span v-if=\"draggable\" :class=\"ns.e('marker')\" :style=\"markerStyle\" aria-hidden=\"true\" />\n </div>\n <button\n v-if=\"!vertical && arrows && (overflow.start || overflow.end)\"\n type=\"button\"\n tabindex=\"-1\"\n :class=\"[ns.e('scroll'), ns.is('end', true)]\"\n :disabled=\"!overflow.end\"\n :aria-label=\"t('tabs.scrollNext')\"\n @click=\"scrollByPage(1)\"\n >\n <ChevronRightIcon />\n </button>\n <button\n v-if=\"addable\"\n type=\"button\"\n :class=\"ns.e('add')\"\n :aria-label=\"t('tabs.add')\"\n @click=\"emit('add')\"\n >\n <PlusIcon />\n </button>\n <div v-if=\"slots.extra\" :class=\"ns.e('extra')\">\n <slot name=\"extra\" />\n </div>\n </div>\n <slot />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2aA,IAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAzYzB,MAAM,QAAQ;EAQd,MAAM,QAAQA,SAAsB,SAAA,YAAC;EACrC,MAAM,OAAO;EAMb,MAAM,QAAQC,SAAA;EAEd,MAAM,KAAK,aAAa,MAAM;EAC9B,MAAM,EAAE,MAAM,UAAU;EACxB,MAAM,KAAK,MAAM;EACjB,MAAM,WAAW,eAAe,MAAM,cAAc,KAAK;EACzD,MAAM,OAAO,kBAAkB,MAAM,IAAI;EAEzC,MAAM,SAAS,WAA4B,CAAC,CAAC;EAI7C,SAAS,SAAS,OAAsB;GACtC,OAAO,QAAQ,CAAC,GAAG,OAAO,OAAO,KAAK;EACxC;EACA,SAAS,WAAW,KAAa;GAC/B,OAAO,QAAQ,OAAO,MAAM,QAAQ,UAAU,MAAM,QAAQ,GAAG;EACjE;;EAEA,SAAS,OAAO;GAEd,MAAM,SAAS,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM;IAC9C,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GAAG,OAAO,OAAO;IACvC,OAAO,EAAE,GAAG,MAAM,wBAAwB,EAAE,GAAG,KAAK,IAAI,KAAK,8BACzD,KACA;GACN,CAAC;GACD,IAAI,CAAC,OAAO,MAA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B,OAAKC,eAAEC,MAAA,EAAA,CAAE,CAAC,EAAC,OAAA,CAAA;I,IAClCW,WAAqB,KAAA,QAAA,OAAA,C;G,OAGzBA,WAAQ,KAAA,QAAA,SAAA,C"}
1
+ {"version":3,"file":"tabs.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_useSlots","_openBlock","_createElementBlock","_normalizeClass","_unref","_normalizeStyle","_createElementVNode","_createVNode","_createCommentVNode","_Fragment","_renderList","_createBlock","_withCtx","_resolveDynamicComponent","_withModifiers","_renderSlot"],"sources":["../../../src/components/tabs/tabs.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n h,\n nextTick,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n provide,\n ref,\n shallowRef,\n toRef,\n triggerRef,\n useId,\n useTemplateRef,\n watch,\n} from 'vue'\nimport { ChevronLeftIcon, ChevronRightIcon, CloseIcon, PlusIcon } from '@dou-ui/icons'\nimport { useReducedMotion } from '../../composables/use-motion'\nimport { announce } from '../../utils/announce'\nimport { useNamespace } from '../../utils/namespace'\nimport { scrollPositionOf } from '../../utils/scroll'\nimport { devWarn } from '../../utils/status-check'\nimport { useLocale } from '../config-provider/use-config'\nimport { useFormSize } from '../form/use-form-item'\nimport { DouTooltip } from '../tooltip'\nimport { pressTab, registerTabDropZone } from './tab-drag'\nimport { tabsKey } from './tabs'\nimport type { FunctionalComponent, VNode } from 'vue'\nimport type { TabDrag } from './tab-drag'\nimport type { TabPanelEntry, TabsMoveEvent, TabsProps, TabsSlots, TabsValue } from './tabs'\n\ndefineOptions({ name: 'DouTabs' })\n\nconst props = withDefaults(defineProps<TabsProps>(), {\n activation: 'auto',\n placement: 'top',\n closable: false,\n addable: false,\n iconOnly: false,\n draggable: false,\n})\nconst model = defineModel<TabsValue>()\nconst emit = defineEmits<{\n change: [value: TabsValue]\n remove: [value: TabsValue]\n add: []\n move: [event: TabsMoveEvent]\n}>()\nconst slots = defineSlots<TabsSlots>()\n\nconst ns = useNamespace('tabs')\nconst { t } = useLocale()\nconst id = useId()\nconst vertical = computed(() => props.placement !== 'top')\nconst size = useFormSize(() => props.size)\n\nconst panels = shallowRef<TabPanelEntry[]>([])\n\n// Panels register in the order they are set up, which is their order on\n// the page; a panel added later is sorted in once it is mounted.\nfunction register(entry: TabPanelEntry) {\n panels.value = [...panels.value, entry]\n}\nfunction unregister(uid: number) {\n panels.value = panels.value.filter((entry) => entry.uid !== uid)\n}\n/** Put the panels in their order on the page; whether that changed anything. */\nfunction sync() {\n // oxlint-disable-next-line unicorn/no-array-sort -- sorts a copy\n const sorted = [...panels.value].sort((a, b) => {\n if (!a.el.value || !b.el.value) return 0\n return a.el.value.compareDocumentPosition(b.el.value) & Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1\n })\n if (!sorted.some((entry, index) => entry !== panels.value[index])) return false\n panels.value = sorted\n return true\n}\nfunction reorder() {\n if (!sync()) triggerRef(panels)\n}\n// The panels may have been put in a new order, e.g. after a `move`.\nonUpdated(sync)\n\nconst firstEnabled = computed(() => panels.value.find((entry) => !entry.props.disabled))\nconst selected = computed(() => model.value ?? firstEnabled.value?.props.value)\n\nconst key = (value: TabsValue) => String(value).replace(/\\s+/g, '-')\nconst tabId = (value: TabsValue) => `${id}-tab-${key(value)}`\nconst panelId = (value: TabsValue) => `${id}-panel-${key(value)}`\n\nprovide(tabsKey, {\n selected: toRef(() => selected.value),\n tabId,\n panelId,\n register,\n unregister,\n reorder,\n})\n\nasync function select(entry: TabPanelEntry) {\n if (entry.props.disabled) return\n await selectValue(entry.props.value)\n}\nasync function selectValue(next: TabsValue) {\n if (next === selected.value) return\n if (props.beforeLeave && !(await props.beforeLeave(next, selected.value))) return\n model.value = next\n emit('change', next)\n}\n\nconst isClosable = (entry: TabPanelEntry) =>\n !entry.props.disabled && (entry.props.closable ?? props.closable)\n\nfunction remove(entry: TabPanelEntry) {\n if (isClosable(entry)) emit('remove', entry.props.value)\n}\n\nconst listRef = useTemplateRef<HTMLElement>('list')\nconst headerRef = useTemplateRef<HTMLElement>('header')\nconst tabElements = new Map<number, HTMLElement>()\n\nfunction setTabElement(uid: number, el: unknown) {\n if (el instanceof HTMLElement) tabElements.set(uid, el)\n else tabElements.delete(uid)\n}\nfunction tabElement(entry: TabPanelEntry) {\n return tabElements.get(entry.uid)\n}\n\n/** The label slot of a panel, rendered inside its tab. */\nconst TabLabel: FunctionalComponent<{ entry: TabPanelEntry; selected: boolean }> = ({\n entry,\n selected: isSelected,\n}) => (entry.slots.label?.({ selected: isSelected }) as VNode[] | undefined) ?? labelText(entry)\n\nconst labelText = (entry: TabPanelEntry) => entry.props.label ?? String(entry.props.value)\n\n/** With `iconOnly`, whether the tab shows its icon alone; without an icon it keeps its text. */\nfunction iconAlone(entry: TabPanelEntry) {\n if (!props.iconOnly) return false\n if (entry.props.icon) {\n // the label slot cannot name an icon: the tab would be read out as its value\n if (process.env.NODE_ENV !== 'production' && entry.props.label === undefined)\n devWarn(\n `[dou-ui] DouTabs: \\`iconOnly\\` names each tab by its \\`label\\`; the DouTabPanel \"${entry.props.value}\" has none and is named by its value.`,\n )\n return true\n }\n if (process.env.NODE_ENV !== 'production')\n devWarn(\n `[dou-ui] DouTabs: \\`iconOnly\\` needs an \\`icon\\` on each DouTabPanel; \"${labelText(entry)}\" keeps its text.`,\n )\n return false\n}\n\n// With `iconOnly`, the label shows in a tooltip: beside a column, above a row.\nconst tipPlacement = computed(() =>\n props.placement === 'start' ? 'right' : props.placement === 'end' ? 'left' : 'top',\n)\nconst TabTip: FunctionalComponent<{ entry: TabPanelEntry }> = ({ entry }, { slots: tip }) =>\n iconAlone(entry)\n ? h(DouTooltip, { content: labelText(entry), placement: tipPlacement.value }, tip)\n : tip.default?.()\n\nfunction onKeydown(event: KeyboardEvent, entry: TabPanelEntry) {\n if (event.altKey && isDraggable(entry) && moveByKey(event, entry)) return\n const enabled = panels.value.filter((panel) => !panel.props.disabled)\n const index = enabled.indexOf(entry)\n let target: TabPanelEntry | undefined\n const [prev, next] = vertical.value ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight']\n switch (event.key) {\n case next:\n target = enabled[(index + 1) % enabled.length]\n break\n case prev:\n target = enabled[(index - 1 + enabled.length) % enabled.length]\n break\n case 'Delete':\n case 'Backspace':\n if (!isClosable(entry)) return\n event.preventDefault()\n remove(entry)\n return\n case 'Home':\n target = enabled[0]\n break\n case 'End':\n target = enabled[enabled.length - 1]\n break\n case 'Enter':\n case ' ':\n event.preventDefault()\n void select(entry)\n return\n default:\n return\n }\n if (!target) return\n event.preventDefault()\n tabElement(target)?.focus()\n if (props.activation === 'auto') void select(target)\n}\n\n/* dragging */\n\nconst isDraggable = (entry: TabPanelEntry) =>\n !entry.props.disabled && (entry.props.draggable ?? props.draggable)\n\n/** This instance, to tell a move within the tabs from one that comes from other tabs. */\nconst self = {}\nconst draggingUid = ref<number | null>(null)\nlet clickBlocked = false\n\nfunction onClick(entry: TabPanelEntry) {\n // the press that ended a drag is not a click on the tab\n if (clickBlocked) return\n void select(entry)\n}\n\nfunction onPointerdown(event: PointerEvent, entry: TabPanelEntry) {\n if (!isDraggable(entry) || (event.target as Element).closest(`.${ns.e('close')}`)) return\n const el = tabElement(entry)\n if (!el) return\n pressTab(event, {\n el,\n root: listRef.value,\n drag: () => ({\n value: entry.props.value,\n label: labelText(entry),\n group: props.group,\n name: props.name,\n index: panels.value.indexOf(entry),\n source: self,\n }),\n onStart: () => (draggingUid.value = entry.uid),\n onEnd: () => {\n draggingUid.value = null\n clickBlocked = true\n setTimeout(() => (clickBlocked = false))\n },\n })\n}\n\n/** Where a tab dropped now would go: before the tab at `index`, or after the last. */\nconst marker = ref<{ index: number; at: number } | null>(null)\n\nfunction insertionAt(x: number, y: number) {\n const entries = panels.value\n const index = entries.findIndex((entry) => {\n const rect = tabElement(entry)?.getBoundingClientRect()\n if (!rect) return false\n return vertical.value ? y < rect.top + rect.height / 2 : x < rect.left + rect.width / 2\n })\n return index < 0 ? entries.length : index\n}\n\n/**\n * Whether the tab comes from these tabs: dragged from them, or from\n * elsewhere (a list outside a dock) when these tabs hold it already.\n */\nconst fromHere = (drag: TabDrag) =>\n drag.source === self ||\n (drag.name !== undefined && drag.name === props.name && drag.group === props.group)\n\n/** Whether dropping there leaves the tab where it is. */\nconst stays = (drag: TabDrag, index: number) =>\n fromHere(drag) && (index === drag.index || index === drag.index + 1)\n\nfunction markerOffset(index: number) {\n const entries = panels.value\n const style = getComputedStyle(listRef.value!)\n const gap = Number.parseFloat(vertical.value ? style.rowGap : style.columnGap) || 0\n const before = entries[index] && tabElement(entries[index])\n if (before) return (vertical.value ? before.offsetTop : before.offsetLeft) - gap / 2\n const last = entries.at(-1)\n const after = last && tabElement(last)\n if (!after) return 0\n return vertical.value\n ? after.offsetTop + after.offsetHeight + gap / 2\n : after.offsetLeft + after.offsetWidth + gap / 2\n}\n\n/** Scroll a row that does not fit while the pointer is near one of its ends. */\nfunction scrollNearEdge(x: number, y: number) {\n const list = listRef.value\n if (!list) return\n const rect = list.getBoundingClientRect()\n const EDGE = 32\n const speed = (d: number) => Math.ceil(((EDGE - Math.max(0, d)) / EDGE) * 10)\n const [pos, startEdge, endEdge] = vertical.value\n ? [y, rect.top, rect.bottom]\n : [x, rect.left, rect.right]\n let delta = 0\n if (pos - startEdge < EDGE) delta = -speed(pos - startEdge)\n else if (endEdge - pos < EDGE) delta = speed(endEdge - pos)\n if (!delta) return\n if (vertical.value) list.scrollTop += delta\n else list.scrollLeft += delta\n}\n\nconst dropZone = registerTabDropZone({\n el: () => headerRef.value,\n // its own tabs always come back; tabs from others only when these take drops\n accepts: (drag) =>\n drag.source === self || (props.draggable && !!props.group && drag.group === props.group),\n over(drag, x, y) {\n scrollNearEdge(x, y)\n const index = insertionAt(x, y)\n if (stays(drag, index)) {\n marker.value = null\n return\n }\n // kept inside the row, which cuts off what sticks out\n const list = listRef.value!\n const end = (vertical.value ? list.scrollHeight : list.scrollWidth) - 2\n const at = Math.min(Math.max(markerOffset(index), 1), end)\n if (marker.value?.index !== index || marker.value.at !== at) marker.value = { index, at }\n },\n leave: () => (marker.value = null),\n drop(drag) {\n const index = marker.value?.index\n marker.value = null\n if (index === undefined) return\n const within = fromHere(drag)\n emit('move', {\n value: drag.value,\n from: { name: drag.name, index: drag.index },\n to: { name: props.name, index: within && index > drag.index ? index - 1 : index },\n })\n // dragging a tab is using it\n void selectValue(drag.value)\n },\n})\nonMounted(() => {\n dropZone.update()\n if (process.env.NODE_ENV !== 'production' && props.group && props.name === undefined)\n devWarn(\n `[dou-ui] DouTabs: tabs in the group \"${props.group}\" need a \\`name\\`; \\`move\\` cannot tell which tabs a tab came from without it.`,\n )\n})\nonUpdated(() => dropZone.update())\nonBeforeUnmount(() => dropZone.remove())\n\nconst markerStyle = computed(() => {\n const at = marker.value?.at\n if (at === undefined) return { display: 'none' }\n return { transform: vertical.value ? `translateY(${at}px)` : `translateX(${at}px)` }\n})\n\n/** A tab moved with the keyboard keeps the focus once it is in its new place. */\nlet focusAfterMove: TabsValue | undefined\n\nfunction moveByKey(event: KeyboardEvent, entry: TabPanelEntry) {\n const [prev, next] = vertical.value ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight']\n const entries = panels.value\n const index = entries.indexOf(entry)\n const last = entries.length - 1\n const target =\n event.key === prev\n ? index - 1\n : event.key === next\n ? index + 1\n : event.key === 'Home'\n ? 0\n : event.key === 'End'\n ? last\n : null\n if (target === null) return false\n event.preventDefault()\n if (target < 0 || target > last || target === index) return true\n focusAfterMove = entry.props.value\n emit('move', {\n value: entry.props.value,\n from: { name: props.name, index },\n to: { name: props.name, index: target },\n })\n announce(\n t('tabs.moved', { label: labelText(entry), position: target + 1, total: entries.length }),\n )\n return true\n}\n\nwatch(\n panels,\n () => {\n if (focusAfterMove === undefined) return\n const entry = panels.value.find((panel) => panel.props.value === focusAfterMove)\n focusAfterMove = undefined\n const el = entry && tabElement(entry)\n if (el && document.activeElement !== el) el.focus()\n },\n { flush: 'post' },\n)\n\nconst moveKeys = computed(() =>\n vertical.value\n ? 'Alt+ArrowUp Alt+ArrowDown Alt+Home Alt+End'\n : 'Alt+ArrowLeft Alt+ArrowRight Alt+Home Alt+End',\n)\nfunction keyShortcuts(entry: TabPanelEntry) {\n const keys = [isClosable(entry) && 'Delete', isDraggable(entry) && moveKeys.value].filter(Boolean)\n return keys.length ? keys.join(' ') : undefined\n}\n\n// The underline slides between the tabs. It is measured from the\n// selected tab, like the selection of a segmented control.\nconst indicator = ref<{ left: number; top: number; width: number; height: number } | null>(null)\nconst settled = ref(false)\n\nfunction measure() {\n const list = listRef.value\n const entry = panels.value.find((panel) => panel.props.value === selected.value)\n const tab = entry && tabElement(entry)\n if (!list || !tab) {\n indicator.value = null\n return\n }\n indicator.value = {\n left: tab.offsetLeft,\n top: tab.offsetTop,\n width: tab.offsetWidth,\n height: tab.offsetHeight,\n }\n}\n\n// When the tabs do not fit, the list scrolls sideways: the edges fade and\n// arrows appear on the side that has more, and the selected tab is kept in view.\nconst overflow = ref({ start: false, end: false })\nconst reduced = useReducedMotion()\n\n// Arrows in a narrow row would leave no room for a single tab: there the\n// row scrolls by swiping, the wheel or the keyboard alone.\nconst ARROWS_MIN_WIDTH = 160\nconst arrows = ref(true)\n\nfunction updateOverflow() {\n // a header not laid out yet has no width to go by\n const width = headerRef.value?.clientWidth || Infinity\n arrows.value = width >= ARROWS_MIN_WIDTH\n const list = listRef.value\n if (!list) {\n overflow.value = { start: false, end: false }\n return\n }\n if (vertical.value) {\n // a column only overflows with a fixed `height`; there it fades but has no arrows\n const max = list.scrollHeight - list.clientHeight\n // kept in range while the column bounces\n const top = scrollPositionOf(list).top\n overflow.value = { start: top > 1, end: top < max - 1 }\n return\n }\n const max = list.scrollWidth - list.clientWidth\n // from the start, also right to left, and kept in range while the row bounces\n const left = Math.abs(scrollPositionOf(list).left)\n // a sub-pixel remainder is not something to scroll to\n overflow.value = { start: left > 1, end: left < max - 1 }\n}\n\nfunction reveal(smooth: boolean) {\n const list = listRef.value\n const entry = panels.value.find((panel) => panel.props.value === selected.value)\n const tab = entry && tabElement(entry)\n if (!list || !tab) return\n // leave room for the faded edge, so the tab is not under it\n const margin = 32\n if (vertical.value) {\n const top = tab.offsetTop - margin\n const bottom = tab.offsetTop + tab.offsetHeight + margin - list.clientHeight\n const target = top < list.scrollTop ? top : bottom > list.scrollTop ? bottom : null\n if (target === null) return\n list.scrollTo({\n top: Math.max(0, target),\n behavior: smooth && !reduced.value ? 'smooth' : 'auto',\n })\n return\n }\n const left = tab.offsetLeft - margin\n const right = tab.offsetLeft + tab.offsetWidth + margin - list.clientWidth\n const target = left < list.scrollLeft ? left : right > list.scrollLeft ? right : null\n if (target === null) return\n list.scrollTo({\n left: Math.max(0, target),\n behavior: smooth && !reduced.value ? 'smooth' : 'auto',\n })\n}\n\nfunction scrollByPage(direction: 1 | -1) {\n const list = listRef.value\n if (!list) return\n list.scrollBy({\n left: direction * list.clientWidth * 0.8,\n behavior: reduced.value ? 'auto' : 'smooth',\n })\n}\n\nlet observer: ResizeObserver | undefined\nonMounted(() => {\n measure()\n updateOverflow()\n reveal(false)\n requestAnimationFrame(() => (settled.value = true))\n if (typeof ResizeObserver !== 'undefined' && listRef.value) {\n observer = new ResizeObserver(() => {\n measure()\n updateOverflow()\n })\n observer.observe(listRef.value)\n }\n})\nonBeforeUnmount(() => observer?.disconnect())\nwatch(\n [selected, panels, size, () => props.placement, () => props.iconOnly, () => props.height],\n () =>\n nextTick(() => {\n measure()\n updateOverflow()\n reveal(settled.value)\n }),\n)\n\nconst rootStyle = computed(() =>\n props.height === undefined\n ? undefined\n : {\n height: typeof props.height === 'number' ? `${props.height}px` : props.height,\n },\n)\n\nconst indicatorStyle = computed(() => {\n const box = indicator.value\n if (!box) return { display: 'none' }\n return vertical.value\n ? { transform: `translateY(${box.top}px)`, height: `${box.height}px` }\n : { transform: `translateX(${box.left}px)`, width: `${box.width}px` }\n})\n</script>\n\n<template>\n <div\n :class=\"[\n ns.b(),\n ns.m(size),\n ns.is('settled', settled),\n ns.is('vertical', vertical),\n vertical && ns.is(`placement-${placement}`, true),\n ns.is('fixed', height !== undefined),\n ns.is('icon-only', iconOnly),\n ns.is('drop-target', !!marker),\n ]\"\n :style=\"rootStyle\"\n >\n <div ref=\"header\" :class=\"ns.e('header')\">\n <button\n v-if=\"!vertical && arrows && (overflow.start || overflow.end)\"\n type=\"button\"\n tabindex=\"-1\"\n :class=\"[ns.e('scroll'), ns.is('start', true)]\"\n :disabled=\"!overflow.start\"\n :aria-label=\"t('tabs.scrollPrev')\"\n @click=\"scrollByPage(-1)\"\n >\n <ChevronLeftIcon />\n </button>\n <div\n ref=\"list\"\n :class=\"[\n ns.e('list'),\n ns.is('fade-start', overflow.start),\n ns.is('fade-end', overflow.end),\n ]\"\n role=\"tablist\"\n :aria-orientation=\"vertical ? 'vertical' : 'horizontal'\"\n @scroll.passive=\"updateOverflow\"\n >\n <template v-for=\"entry in panels\" :key=\"entry.uid\">\n <TabTip :entry=\"entry\">\n <button\n :id=\"tabId(entry.props.value)\"\n :ref=\"(el) => setTabElement(entry.uid, el)\"\n type=\"button\"\n role=\"tab\"\n :class=\"[\n ns.e('tab'),\n ns.is('selected', entry.props.value === selected),\n ns.is('disabled', !!entry.props.disabled),\n ns.is('closable', isClosable(entry)),\n ns.is('icon-alone', iconAlone(entry)),\n ns.is('draggable', isDraggable(entry)),\n ns.is('dragging', draggingUid === entry.uid),\n ]\"\n :aria-selected=\"entry.props.value === selected\"\n :aria-controls=\"panelId(entry.props.value)\"\n :aria-label=\"iconAlone(entry) ? labelText(entry) : undefined\"\n :aria-disabled=\"entry.props.disabled || undefined\"\n :tabindex=\"entry.props.value === selected ? 0 : -1\"\n :aria-keyshortcuts=\"keyShortcuts(entry)\"\n @click=\"onClick(entry)\"\n @pointerdown=\"onPointerdown($event, entry)\"\n @keydown=\"onKeydown($event, entry)\"\n >\n <component\n :is=\"entry.props.icon\"\n v-if=\"entry.props.icon\"\n :class=\"ns.e('icon')\"\n aria-hidden=\"true\"\n />\n <span v-if=\"!iconAlone(entry)\" :class=\"ns.e('label')\">\n <TabLabel :entry=\"entry\" :selected=\"entry.props.value === selected\" />\n </span>\n <!-- not a button of its own: a tab cannot hold one; `Delete` closes it from the keyboard.\n An icon alone already has the label's tooltip, so the close button goes without. -->\n <DouTooltip\n v-if=\"isClosable(entry)\"\n :content=\"t('tabs.close')\"\n shortcut=\"delete\"\n :disabled=\"iconAlone(entry)\"\n >\n <span :class=\"ns.e('close')\" aria-hidden=\"true\" @click.stop=\"remove(entry)\">\n <CloseIcon />\n </span>\n </DouTooltip>\n </button>\n </TabTip>\n </template>\n <span :class=\"ns.e('indicator')\" :style=\"indicatorStyle\" aria-hidden=\"true\" />\n <span v-if=\"draggable\" :class=\"ns.e('marker')\" :style=\"markerStyle\" aria-hidden=\"true\" />\n </div>\n <button\n v-if=\"!vertical && arrows && (overflow.start || overflow.end)\"\n type=\"button\"\n tabindex=\"-1\"\n :class=\"[ns.e('scroll'), ns.is('end', true)]\"\n :disabled=\"!overflow.end\"\n :aria-label=\"t('tabs.scrollNext')\"\n @click=\"scrollByPage(1)\"\n >\n <ChevronRightIcon />\n </button>\n <button\n v-if=\"addable\"\n type=\"button\"\n :class=\"ns.e('add')\"\n :aria-label=\"t('tabs.add')\"\n @click=\"emit('add')\"\n >\n <PlusIcon />\n </button>\n <div v-if=\"slots.extra\" :class=\"ns.e('extra')\">\n <slot name=\"extra\" />\n </div>\n </div>\n <slot />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmbA,IAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAjZzB,MAAM,QAAQ;EAQd,MAAM,QAAQA,SAAsB,SAAA,YAAC;EACrC,MAAM,OAAO;EAMb,MAAM,QAAQC,SAAA;EAEd,MAAM,KAAK,aAAa,MAAM;EAC9B,MAAM,EAAE,MAAM,UAAU;EACxB,MAAM,KAAK,MAAM;EACjB,MAAM,WAAW,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AAA,MAAS,QAD3DJ,UAAA,GAAAC,mBAUS,UAAA;;KARP,MAAK;KACL,UAAS;KACR,OAAKC,eAAA,CAAGC,MAAA,EAAA,CAAE,CAAC,EAAC,QAAA,GAAYA,MAAA,EAAA,CAAE,CAAC,GAAE,OAAA,IAAA,CAAA,CAAA;KAC7B,UAAQ,CAAG,SAAA,MAAS;KACpB,cAAYA,MAAA,CAAA,CAAC,CAAA,iBAAA;KACb,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,aAAY,CAAA;I,IAEpBG,YAAoBH,MAAA,gBAAA,CAAA,C;IAGd,QAAA,WADRH,UAAA,GAAAC,mBAQS,UAAA;;KANP,MAAK;KACJ,OAAKC,eAAEC,MAAA,EAAA,CAAE,CAAC,EAAC,KAAA,CAAA;KACX,cAAYA,MAAA,CAAA,CAAC,CAAA,UAAA;KACb,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,KAAA;I,IAEZG,YAAYH,MAAA,QAAA,CAAA,C;IAEH,MAAM,SAAjBH,UAAA,GAAAC,mBAEM,OAAA;;KAFmB,OAAKC,eAAEC,MAAA,EAAA,CAAE,CAAC,EAAC,OAAA,CAAA;I,IAClCW,WAAqB,KAAA,QAAA,OAAA,C;G,OAGzBA,WAAQ,KAAA,QAAA,SAAA,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"tabs2.js","names":["_sfc_main"],"sources":["../../../src/components/tabs/tabs.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n h,\n nextTick,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n provide,\n ref,\n shallowRef,\n toRef,\n triggerRef,\n useId,\n useTemplateRef,\n watch,\n} from 'vue'\nimport { ChevronLeftIcon, ChevronRightIcon, CloseIcon, PlusIcon } from '@dou-ui/icons'\nimport { useReducedMotion } from '../../composables/use-motion'\nimport { announce } from '../../utils/announce'\nimport { useNamespace } from '../../utils/namespace'\nimport { scrollPositionOf } from '../../utils/scroll'\nimport { devWarn } from '../../utils/status-check'\nimport { useLocale } from '../config-provider/use-config'\nimport { useFormSize } from '../form/use-form-item'\nimport { DouTooltip } from '../tooltip'\nimport { pressTab, registerTabDropZone } from './tab-drag'\nimport { tabsKey } from './tabs'\nimport type { FunctionalComponent, VNode } from 'vue'\nimport type { TabDrag } from './tab-drag'\nimport type { TabPanelEntry, TabsMoveEvent, TabsProps, TabsSlots, TabsValue } from './tabs'\n\ndefineOptions({ name: 'DouTabs' })\n\nconst props = withDefaults(defineProps<TabsProps>(), {\n activation: 'auto',\n placement: 'top',\n closable: false,\n addable: false,\n iconOnly: false,\n draggable: false,\n})\nconst model = defineModel<TabsValue>()\nconst emit = defineEmits<{\n change: [value: TabsValue]\n remove: [value: TabsValue]\n add: []\n move: [event: TabsMoveEvent]\n}>()\nconst slots = defineSlots<TabsSlots>()\n\nconst ns = useNamespace('tabs')\nconst { t } = useLocale()\nconst id = useId()\nconst vertical = computed(() => props.placement !== 'top')\nconst size = useFormSize(() => props.size)\n\nconst panels = shallowRef<TabPanelEntry[]>([])\n\n// Panels register in the order they are set up, which is their order on\n// the page; a panel added later is sorted in once it is mounted.\nfunction register(entry: TabPanelEntry) {\n panels.value = [...panels.value, entry]\n}\nfunction unregister(uid: number) {\n panels.value = panels.value.filter((entry) => entry.uid !== uid)\n}\n/** Put the panels in their order on the page; whether that changed anything. */\nfunction sync() {\n // oxlint-disable-next-line unicorn/no-array-sort -- sorts a copy\n const sorted = [...panels.value].sort((a, b) => {\n if (!a.el.value || !b.el.value) return 0\n return a.el.value.compareDocumentPosition(b.el.value) & Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1\n })\n if (!sorted.some((entry, index) => entry !== panels.value[index])) return false\n panels.value = sorted\n return true\n}\nfunction reorder() {\n if (!sync()) triggerRef(panels)\n}\n// The panels may have been put in a new order, e.g. after a `move`.\nonUpdated(sync)\n\nconst firstEnabled = computed(() => panels.value.find((entry) => !entry.props.disabled))\nconst selected = computed(() => model.value ?? firstEnabled.value?.props.value)\n\nconst key = (value: TabsValue) => String(value).replace(/\\s+/g, '-')\nconst tabId = (value: TabsValue) => `${id}-tab-${key(value)}`\nconst panelId = (value: TabsValue) => `${id}-panel-${key(value)}`\n\nprovide(tabsKey, {\n selected: toRef(() => selected.value),\n tabId,\n panelId,\n register,\n unregister,\n reorder,\n})\n\nasync function select(entry: TabPanelEntry) {\n if (entry.props.disabled) return\n await selectValue(entry.props.value)\n}\nasync function selectValue(next: TabsValue) {\n if (next === selected.value) return\n if (props.beforeLeave && !(await props.beforeLeave(next, selected.value))) return\n model.value = next\n emit('change', next)\n}\n\nconst isClosable = (entry: TabPanelEntry) =>\n !entry.props.disabled && (entry.props.closable ?? props.closable)\n\nfunction remove(entry: TabPanelEntry) {\n if (isClosable(entry)) emit('remove', entry.props.value)\n}\n\nconst listRef = useTemplateRef<HTMLElement>('list')\nconst headerRef = useTemplateRef<HTMLElement>('header')\nconst tabElements = new Map<number, HTMLElement>()\n\nfunction setTabElement(uid: number, el: unknown) {\n if (el instanceof HTMLElement) tabElements.set(uid, el)\n else tabElements.delete(uid)\n}\nfunction tabElement(entry: TabPanelEntry) {\n return tabElements.get(entry.uid)\n}\n\n/** The label slot of a panel, rendered inside its tab. */\nconst TabLabel: FunctionalComponent<{ entry: TabPanelEntry; selected: boolean }> = ({\n entry,\n selected: isSelected,\n}) => (entry.slots.label?.({ selected: isSelected }) as VNode[] | undefined) ?? labelText(entry)\n\nconst labelText = (entry: TabPanelEntry) => entry.props.label ?? String(entry.props.value)\n\n/** With `iconOnly`, whether the tab shows its icon alone; without an icon it keeps its text. */\nfunction iconAlone(entry: TabPanelEntry) {\n if (!props.iconOnly) return false\n if (entry.props.icon) {\n // the label slot cannot name an icon: the tab would be read out as its value\n if (process.env.NODE_ENV !== 'production' && entry.props.label === undefined)\n devWarn(\n `[dou-ui] DouTabs: \\`iconOnly\\` names each tab by its \\`label\\`; the DouTabPanel \"${entry.props.value}\" has none and is named by its value.`,\n )\n return true\n }\n if (process.env.NODE_ENV !== 'production')\n devWarn(\n `[dou-ui] DouTabs: \\`iconOnly\\` needs an \\`icon\\` on each DouTabPanel; \"${labelText(entry)}\" keeps its text.`,\n )\n return false\n}\n\n// With `iconOnly`, the label shows in a tooltip: beside a column, above a row.\nconst tipPlacement = computed(() =>\n props.placement === 'start' ? 'right' : props.placement === 'end' ? 'left' : 'top',\n)\nconst TabTip: FunctionalComponent<{ entry: TabPanelEntry }> = ({ entry }, { slots: tip }) =>\n iconAlone(entry)\n ? h(DouTooltip, { content: labelText(entry), placement: tipPlacement.value }, tip)\n : tip.default?.()\n\nfunction onKeydown(event: KeyboardEvent, entry: TabPanelEntry) {\n if (event.altKey && isDraggable(entry) && moveByKey(event, entry)) return\n const enabled = panels.value.filter((panel) => !panel.props.disabled)\n const index = enabled.indexOf(entry)\n let target: TabPanelEntry | undefined\n const [prev, next] = vertical.value ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight']\n switch (event.key) {\n case next:\n target = enabled[(index + 1) % enabled.length]\n break\n case prev:\n target = enabled[(index - 1 + enabled.length) % enabled.length]\n break\n case 'Delete':\n case 'Backspace':\n if (!isClosable(entry)) return\n event.preventDefault()\n remove(entry)\n return\n case 'Home':\n target = enabled[0]\n break\n case 'End':\n target = enabled[enabled.length - 1]\n break\n case 'Enter':\n case ' ':\n event.preventDefault()\n void select(entry)\n return\n default:\n return\n }\n if (!target) return\n event.preventDefault()\n tabElement(target)?.focus()\n if (props.activation === 'auto') void select(target)\n}\n\n/* dragging */\n\nconst isDraggable = (entry: TabPanelEntry) =>\n !entry.props.disabled && (entry.props.draggable ?? props.draggable)\n\n/** This instance, to tell a move within the tabs from one that comes from other tabs. */\nconst self = {}\nconst draggingUid = ref<number | null>(null)\nlet clickBlocked = false\n\nfunction onClick(entry: TabPanelEntry) {\n // the press that ended a drag is not a click on the tab\n if (clickBlocked) return\n void select(entry)\n}\n\nfunction onPointerdown(event: PointerEvent, entry: TabPanelEntry) {\n if (!isDraggable(entry) || (event.target as Element).closest(`.${ns.e('close')}`)) return\n const el = tabElement(entry)\n if (!el) return\n pressTab(event, {\n el,\n root: listRef.value,\n drag: () => ({\n value: entry.props.value,\n label: labelText(entry),\n group: props.group,\n name: props.name,\n index: panels.value.indexOf(entry),\n source: self,\n }),\n onStart: () => (draggingUid.value = entry.uid),\n onEnd: () => {\n draggingUid.value = null\n clickBlocked = true\n setTimeout(() => (clickBlocked = false))\n },\n })\n}\n\n/** Where a tab dropped now would go: before the tab at `index`, or after the last. */\nconst marker = ref<{ index: number; at: number } | null>(null)\n\nfunction insertionAt(x: number, y: number) {\n const entries = panels.value\n const index = entries.findIndex((entry) => {\n const rect = tabElement(entry)?.getBoundingClientRect()\n if (!rect) return false\n return vertical.value ? y < rect.top + rect.height / 2 : x < rect.left + rect.width / 2\n })\n return index < 0 ? entries.length : index\n}\n\n/** Whether dropping there leaves the tab where it is. */\nconst stays = (drag: TabDrag, index: number) =>\n drag.source === self && (index === drag.index || index === drag.index + 1)\n\nfunction markerOffset(index: number) {\n const entries = panels.value\n const style = getComputedStyle(listRef.value!)\n const gap = Number.parseFloat(vertical.value ? style.rowGap : style.columnGap) || 0\n const before = entries[index] && tabElement(entries[index])\n if (before) return (vertical.value ? before.offsetTop : before.offsetLeft) - gap / 2\n const last = entries.at(-1)\n const after = last && tabElement(last)\n if (!after) return 0\n return vertical.value\n ? after.offsetTop + after.offsetHeight + gap / 2\n : after.offsetLeft + after.offsetWidth + gap / 2\n}\n\n/** Scroll a row that does not fit while the pointer is near one of its ends. */\nfunction scrollNearEdge(x: number, y: number) {\n const list = listRef.value\n if (!list) return\n const rect = list.getBoundingClientRect()\n const EDGE = 32\n const speed = (d: number) => Math.ceil(((EDGE - Math.max(0, d)) / EDGE) * 10)\n const [pos, startEdge, endEdge] = vertical.value\n ? [y, rect.top, rect.bottom]\n : [x, rect.left, rect.right]\n let delta = 0\n if (pos - startEdge < EDGE) delta = -speed(pos - startEdge)\n else if (endEdge - pos < EDGE) delta = speed(endEdge - pos)\n if (!delta) return\n if (vertical.value) list.scrollTop += delta\n else list.scrollLeft += delta\n}\n\nconst dropZone = registerTabDropZone({\n el: () => headerRef.value,\n // its own tabs always come back; tabs from others only when these take drops\n accepts: (drag) =>\n drag.source === self || (props.draggable && !!props.group && drag.group === props.group),\n over(drag, x, y) {\n scrollNearEdge(x, y)\n const index = insertionAt(x, y)\n if (stays(drag, index)) {\n marker.value = null\n return\n }\n // kept inside the row, which cuts off what sticks out\n const list = listRef.value!\n const end = (vertical.value ? list.scrollHeight : list.scrollWidth) - 2\n const at = Math.min(Math.max(markerOffset(index), 1), end)\n if (marker.value?.index !== index || marker.value.at !== at) marker.value = { index, at }\n },\n leave: () => (marker.value = null),\n drop(drag) {\n const index = marker.value?.index\n marker.value = null\n if (index === undefined) return\n const within = drag.source === self\n emit('move', {\n value: drag.value,\n from: { name: drag.name, index: drag.index },\n to: { name: props.name, index: within && index > drag.index ? index - 1 : index },\n })\n // dragging a tab is using it\n void selectValue(drag.value)\n },\n})\nonMounted(() => {\n dropZone.update()\n if (process.env.NODE_ENV !== 'production' && props.group && props.name === undefined)\n devWarn(\n `[dou-ui] DouTabs: tabs in the group \"${props.group}\" need a \\`name\\`; \\`move\\` cannot tell which tabs a tab came from without it.`,\n )\n})\nonUpdated(() => dropZone.update())\nonBeforeUnmount(() => dropZone.remove())\n\nconst markerStyle = computed(() => {\n const at = marker.value?.at\n if (at === undefined) return { display: 'none' }\n return { transform: vertical.value ? `translateY(${at}px)` : `translateX(${at}px)` }\n})\n\n/** A tab moved with the keyboard keeps the focus once it is in its new place. */\nlet focusAfterMove: TabsValue | undefined\n\nfunction moveByKey(event: KeyboardEvent, entry: TabPanelEntry) {\n const [prev, next] = vertical.value ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight']\n const entries = panels.value\n const index = entries.indexOf(entry)\n const last = entries.length - 1\n const target =\n event.key === prev\n ? index - 1\n : event.key === next\n ? index + 1\n : event.key === 'Home'\n ? 0\n : event.key === 'End'\n ? last\n : null\n if (target === null) return false\n event.preventDefault()\n if (target < 0 || target > last || target === index) return true\n focusAfterMove = entry.props.value\n emit('move', {\n value: entry.props.value,\n from: { name: props.name, index },\n to: { name: props.name, index: target },\n })\n announce(\n t('tabs.moved', { label: labelText(entry), position: target + 1, total: entries.length }),\n )\n return true\n}\n\nwatch(\n panels,\n () => {\n if (focusAfterMove === undefined) return\n const entry = panels.value.find((panel) => panel.props.value === focusAfterMove)\n focusAfterMove = undefined\n const el = entry && tabElement(entry)\n if (el && document.activeElement !== el) el.focus()\n },\n { flush: 'post' },\n)\n\nconst moveKeys = computed(() =>\n vertical.value\n ? 'Alt+ArrowUp Alt+ArrowDown Alt+Home Alt+End'\n : 'Alt+ArrowLeft Alt+ArrowRight Alt+Home Alt+End',\n)\nfunction keyShortcuts(entry: TabPanelEntry) {\n const keys = [isClosable(entry) && 'Delete', isDraggable(entry) && moveKeys.value].filter(Boolean)\n return keys.length ? keys.join(' ') : undefined\n}\n\n// The underline slides between the tabs. It is measured from the\n// selected tab, like the selection of a segmented control.\nconst indicator = ref<{ left: number; top: number; width: number; height: number } | null>(null)\nconst settled = ref(false)\n\nfunction measure() {\n const list = listRef.value\n const entry = panels.value.find((panel) => panel.props.value === selected.value)\n const tab = entry && tabElement(entry)\n if (!list || !tab) {\n indicator.value = null\n return\n }\n indicator.value = {\n left: tab.offsetLeft,\n top: tab.offsetTop,\n width: tab.offsetWidth,\n height: tab.offsetHeight,\n }\n}\n\n// When the tabs do not fit, the list scrolls sideways: the edges fade and\n// arrows appear on the side that has more, and the selected tab is kept in view.\nconst overflow = ref({ start: false, end: false })\nconst reduced = useReducedMotion()\n\n// Arrows in a narrow row would leave no room for a single tab: there the\n// row scrolls by swiping, the wheel or the keyboard alone.\nconst ARROWS_MIN_WIDTH = 160\nconst arrows = ref(true)\n\nfunction updateOverflow() {\n // a header not laid out yet has no width to go by\n const width = headerRef.value?.clientWidth || Infinity\n arrows.value = width >= ARROWS_MIN_WIDTH\n const list = listRef.value\n if (!list) {\n overflow.value = { start: false, end: false }\n return\n }\n if (vertical.value) {\n // a column only overflows with a fixed `height`; there it fades but has no arrows\n const max = list.scrollHeight - list.clientHeight\n // kept in range while the column bounces\n const top = scrollPositionOf(list).top\n overflow.value = { start: top > 1, end: top < max - 1 }\n return\n }\n const max = list.scrollWidth - list.clientWidth\n // from the start, also right to left, and kept in range while the row bounces\n const left = Math.abs(scrollPositionOf(list).left)\n // a sub-pixel remainder is not something to scroll to\n overflow.value = { start: left > 1, end: left < max - 1 }\n}\n\nfunction reveal(smooth: boolean) {\n const list = listRef.value\n const entry = panels.value.find((panel) => panel.props.value === selected.value)\n const tab = entry && tabElement(entry)\n if (!list || !tab) return\n // leave room for the faded edge, so the tab is not under it\n const margin = 32\n if (vertical.value) {\n const top = tab.offsetTop - margin\n const bottom = tab.offsetTop + tab.offsetHeight + margin - list.clientHeight\n const target = top < list.scrollTop ? top : bottom > list.scrollTop ? bottom : null\n if (target === null) return\n list.scrollTo({\n top: Math.max(0, target),\n behavior: smooth && !reduced.value ? 'smooth' : 'auto',\n })\n return\n }\n const left = tab.offsetLeft - margin\n const right = tab.offsetLeft + tab.offsetWidth + margin - list.clientWidth\n const target = left < list.scrollLeft ? left : right > list.scrollLeft ? right : null\n if (target === null) return\n list.scrollTo({\n left: Math.max(0, target),\n behavior: smooth && !reduced.value ? 'smooth' : 'auto',\n })\n}\n\nfunction scrollByPage(direction: 1 | -1) {\n const list = listRef.value\n if (!list) return\n list.scrollBy({\n left: direction * list.clientWidth * 0.8,\n behavior: reduced.value ? 'auto' : 'smooth',\n })\n}\n\nlet observer: ResizeObserver | undefined\nonMounted(() => {\n measure()\n updateOverflow()\n reveal(false)\n requestAnimationFrame(() => (settled.value = true))\n if (typeof ResizeObserver !== 'undefined' && listRef.value) {\n observer = new ResizeObserver(() => {\n measure()\n updateOverflow()\n })\n observer.observe(listRef.value)\n }\n})\nonBeforeUnmount(() => observer?.disconnect())\nwatch(\n [selected, panels, size, () => props.placement, () => props.iconOnly, () => props.height],\n () =>\n nextTick(() => {\n measure()\n updateOverflow()\n reveal(settled.value)\n }),\n)\n\nconst rootStyle = computed(() =>\n props.height === undefined\n ? undefined\n : {\n height: typeof props.height === 'number' ? `${props.height}px` : props.height,\n },\n)\n\nconst indicatorStyle = computed(() => {\n const box = indicator.value\n if (!box) return { display: 'none' }\n return vertical.value\n ? { transform: `translateY(${box.top}px)`, height: `${box.height}px` }\n : { transform: `translateX(${box.left}px)`, width: `${box.width}px` }\n})\n</script>\n\n<template>\n <div\n :class=\"[\n ns.b(),\n ns.m(size),\n ns.is('settled', settled),\n ns.is('vertical', vertical),\n vertical && ns.is(`placement-${placement}`, true),\n ns.is('fixed', height !== undefined),\n ns.is('icon-only', iconOnly),\n ns.is('drop-target', !!marker),\n ]\"\n :style=\"rootStyle\"\n >\n <div ref=\"header\" :class=\"ns.e('header')\">\n <button\n v-if=\"!vertical && arrows && (overflow.start || overflow.end)\"\n type=\"button\"\n tabindex=\"-1\"\n :class=\"[ns.e('scroll'), ns.is('start', true)]\"\n :disabled=\"!overflow.start\"\n :aria-label=\"t('tabs.scrollPrev')\"\n @click=\"scrollByPage(-1)\"\n >\n <ChevronLeftIcon />\n </button>\n <div\n ref=\"list\"\n :class=\"[\n ns.e('list'),\n ns.is('fade-start', overflow.start),\n ns.is('fade-end', overflow.end),\n ]\"\n role=\"tablist\"\n :aria-orientation=\"vertical ? 'vertical' : 'horizontal'\"\n @scroll.passive=\"updateOverflow\"\n >\n <template v-for=\"entry in panels\" :key=\"entry.uid\">\n <TabTip :entry=\"entry\">\n <button\n :id=\"tabId(entry.props.value)\"\n :ref=\"(el) => setTabElement(entry.uid, el)\"\n type=\"button\"\n role=\"tab\"\n :class=\"[\n ns.e('tab'),\n ns.is('selected', entry.props.value === selected),\n ns.is('disabled', !!entry.props.disabled),\n ns.is('closable', isClosable(entry)),\n ns.is('icon-alone', iconAlone(entry)),\n ns.is('draggable', isDraggable(entry)),\n ns.is('dragging', draggingUid === entry.uid),\n ]\"\n :aria-selected=\"entry.props.value === selected\"\n :aria-controls=\"panelId(entry.props.value)\"\n :aria-label=\"iconAlone(entry) ? labelText(entry) : undefined\"\n :aria-disabled=\"entry.props.disabled || undefined\"\n :tabindex=\"entry.props.value === selected ? 0 : -1\"\n :aria-keyshortcuts=\"keyShortcuts(entry)\"\n @click=\"onClick(entry)\"\n @pointerdown=\"onPointerdown($event, entry)\"\n @keydown=\"onKeydown($event, entry)\"\n >\n <component\n :is=\"entry.props.icon\"\n v-if=\"entry.props.icon\"\n :class=\"ns.e('icon')\"\n aria-hidden=\"true\"\n />\n <span v-if=\"!iconAlone(entry)\" :class=\"ns.e('label')\">\n <TabLabel :entry=\"entry\" :selected=\"entry.props.value === selected\" />\n </span>\n <!-- not a button of its own: a tab cannot hold one; `Delete` closes it from the keyboard.\n An icon alone already has the label's tooltip, so the close button goes without. -->\n <DouTooltip\n v-if=\"isClosable(entry)\"\n :content=\"t('tabs.close')\"\n shortcut=\"delete\"\n :disabled=\"iconAlone(entry)\"\n >\n <span :class=\"ns.e('close')\" aria-hidden=\"true\" @click.stop=\"remove(entry)\">\n <CloseIcon />\n </span>\n </DouTooltip>\n </button>\n </TabTip>\n </template>\n <span :class=\"ns.e('indicator')\" :style=\"indicatorStyle\" aria-hidden=\"true\" />\n <span v-if=\"draggable\" :class=\"ns.e('marker')\" :style=\"markerStyle\" aria-hidden=\"true\" />\n </div>\n <button\n v-if=\"!vertical && arrows && (overflow.start || overflow.end)\"\n type=\"button\"\n tabindex=\"-1\"\n :class=\"[ns.e('scroll'), ns.is('end', true)]\"\n :disabled=\"!overflow.end\"\n :aria-label=\"t('tabs.scrollNext')\"\n @click=\"scrollByPage(1)\"\n >\n <ChevronRightIcon />\n </button>\n <button\n v-if=\"addable\"\n type=\"button\"\n :class=\"ns.e('add')\"\n :aria-label=\"t('tabs.add')\"\n @click=\"emit('add')\"\n >\n <PlusIcon />\n </button>\n <div v-if=\"slots.extra\" :class=\"ns.e('extra')\">\n <slot name=\"extra\" />\n </div>\n </div>\n <slot />\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"tabs2.js","names":["_sfc_main"],"sources":["../../../src/components/tabs/tabs.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n h,\n nextTick,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n provide,\n ref,\n shallowRef,\n toRef,\n triggerRef,\n useId,\n useTemplateRef,\n watch,\n} from 'vue'\nimport { ChevronLeftIcon, ChevronRightIcon, CloseIcon, PlusIcon } from '@dou-ui/icons'\nimport { useReducedMotion } from '../../composables/use-motion'\nimport { announce } from '../../utils/announce'\nimport { useNamespace } from '../../utils/namespace'\nimport { scrollPositionOf } from '../../utils/scroll'\nimport { devWarn } from '../../utils/status-check'\nimport { useLocale } from '../config-provider/use-config'\nimport { useFormSize } from '../form/use-form-item'\nimport { DouTooltip } from '../tooltip'\nimport { pressTab, registerTabDropZone } from './tab-drag'\nimport { tabsKey } from './tabs'\nimport type { FunctionalComponent, VNode } from 'vue'\nimport type { TabDrag } from './tab-drag'\nimport type { TabPanelEntry, TabsMoveEvent, TabsProps, TabsSlots, TabsValue } from './tabs'\n\ndefineOptions({ name: 'DouTabs' })\n\nconst props = withDefaults(defineProps<TabsProps>(), {\n activation: 'auto',\n placement: 'top',\n closable: false,\n addable: false,\n iconOnly: false,\n draggable: false,\n})\nconst model = defineModel<TabsValue>()\nconst emit = defineEmits<{\n change: [value: TabsValue]\n remove: [value: TabsValue]\n add: []\n move: [event: TabsMoveEvent]\n}>()\nconst slots = defineSlots<TabsSlots>()\n\nconst ns = useNamespace('tabs')\nconst { t } = useLocale()\nconst id = useId()\nconst vertical = computed(() => props.placement !== 'top')\nconst size = useFormSize(() => props.size)\n\nconst panels = shallowRef<TabPanelEntry[]>([])\n\n// Panels register in the order they are set up, which is their order on\n// the page; a panel added later is sorted in once it is mounted.\nfunction register(entry: TabPanelEntry) {\n panels.value = [...panels.value, entry]\n}\nfunction unregister(uid: number) {\n panels.value = panels.value.filter((entry) => entry.uid !== uid)\n}\n/** Put the panels in their order on the page; whether that changed anything. */\nfunction sync() {\n // oxlint-disable-next-line unicorn/no-array-sort -- sorts a copy\n const sorted = [...panels.value].sort((a, b) => {\n if (!a.el.value || !b.el.value) return 0\n return a.el.value.compareDocumentPosition(b.el.value) & Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1\n })\n if (!sorted.some((entry, index) => entry !== panels.value[index])) return false\n panels.value = sorted\n return true\n}\nfunction reorder() {\n if (!sync()) triggerRef(panels)\n}\n// The panels may have been put in a new order, e.g. after a `move`.\nonUpdated(sync)\n\nconst firstEnabled = computed(() => panels.value.find((entry) => !entry.props.disabled))\nconst selected = computed(() => model.value ?? firstEnabled.value?.props.value)\n\nconst key = (value: TabsValue) => String(value).replace(/\\s+/g, '-')\nconst tabId = (value: TabsValue) => `${id}-tab-${key(value)}`\nconst panelId = (value: TabsValue) => `${id}-panel-${key(value)}`\n\nprovide(tabsKey, {\n selected: toRef(() => selected.value),\n tabId,\n panelId,\n register,\n unregister,\n reorder,\n})\n\nasync function select(entry: TabPanelEntry) {\n if (entry.props.disabled) return\n await selectValue(entry.props.value)\n}\nasync function selectValue(next: TabsValue) {\n if (next === selected.value) return\n if (props.beforeLeave && !(await props.beforeLeave(next, selected.value))) return\n model.value = next\n emit('change', next)\n}\n\nconst isClosable = (entry: TabPanelEntry) =>\n !entry.props.disabled && (entry.props.closable ?? props.closable)\n\nfunction remove(entry: TabPanelEntry) {\n if (isClosable(entry)) emit('remove', entry.props.value)\n}\n\nconst listRef = useTemplateRef<HTMLElement>('list')\nconst headerRef = useTemplateRef<HTMLElement>('header')\nconst tabElements = new Map<number, HTMLElement>()\n\nfunction setTabElement(uid: number, el: unknown) {\n if (el instanceof HTMLElement) tabElements.set(uid, el)\n else tabElements.delete(uid)\n}\nfunction tabElement(entry: TabPanelEntry) {\n return tabElements.get(entry.uid)\n}\n\n/** The label slot of a panel, rendered inside its tab. */\nconst TabLabel: FunctionalComponent<{ entry: TabPanelEntry; selected: boolean }> = ({\n entry,\n selected: isSelected,\n}) => (entry.slots.label?.({ selected: isSelected }) as VNode[] | undefined) ?? labelText(entry)\n\nconst labelText = (entry: TabPanelEntry) => entry.props.label ?? String(entry.props.value)\n\n/** With `iconOnly`, whether the tab shows its icon alone; without an icon it keeps its text. */\nfunction iconAlone(entry: TabPanelEntry) {\n if (!props.iconOnly) return false\n if (entry.props.icon) {\n // the label slot cannot name an icon: the tab would be read out as its value\n if (process.env.NODE_ENV !== 'production' && entry.props.label === undefined)\n devWarn(\n `[dou-ui] DouTabs: \\`iconOnly\\` names each tab by its \\`label\\`; the DouTabPanel \"${entry.props.value}\" has none and is named by its value.`,\n )\n return true\n }\n if (process.env.NODE_ENV !== 'production')\n devWarn(\n `[dou-ui] DouTabs: \\`iconOnly\\` needs an \\`icon\\` on each DouTabPanel; \"${labelText(entry)}\" keeps its text.`,\n )\n return false\n}\n\n// With `iconOnly`, the label shows in a tooltip: beside a column, above a row.\nconst tipPlacement = computed(() =>\n props.placement === 'start' ? 'right' : props.placement === 'end' ? 'left' : 'top',\n)\nconst TabTip: FunctionalComponent<{ entry: TabPanelEntry }> = ({ entry }, { slots: tip }) =>\n iconAlone(entry)\n ? h(DouTooltip, { content: labelText(entry), placement: tipPlacement.value }, tip)\n : tip.default?.()\n\nfunction onKeydown(event: KeyboardEvent, entry: TabPanelEntry) {\n if (event.altKey && isDraggable(entry) && moveByKey(event, entry)) return\n const enabled = panels.value.filter((panel) => !panel.props.disabled)\n const index = enabled.indexOf(entry)\n let target: TabPanelEntry | undefined\n const [prev, next] = vertical.value ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight']\n switch (event.key) {\n case next:\n target = enabled[(index + 1) % enabled.length]\n break\n case prev:\n target = enabled[(index - 1 + enabled.length) % enabled.length]\n break\n case 'Delete':\n case 'Backspace':\n if (!isClosable(entry)) return\n event.preventDefault()\n remove(entry)\n return\n case 'Home':\n target = enabled[0]\n break\n case 'End':\n target = enabled[enabled.length - 1]\n break\n case 'Enter':\n case ' ':\n event.preventDefault()\n void select(entry)\n return\n default:\n return\n }\n if (!target) return\n event.preventDefault()\n tabElement(target)?.focus()\n if (props.activation === 'auto') void select(target)\n}\n\n/* dragging */\n\nconst isDraggable = (entry: TabPanelEntry) =>\n !entry.props.disabled && (entry.props.draggable ?? props.draggable)\n\n/** This instance, to tell a move within the tabs from one that comes from other tabs. */\nconst self = {}\nconst draggingUid = ref<number | null>(null)\nlet clickBlocked = false\n\nfunction onClick(entry: TabPanelEntry) {\n // the press that ended a drag is not a click on the tab\n if (clickBlocked) return\n void select(entry)\n}\n\nfunction onPointerdown(event: PointerEvent, entry: TabPanelEntry) {\n if (!isDraggable(entry) || (event.target as Element).closest(`.${ns.e('close')}`)) return\n const el = tabElement(entry)\n if (!el) return\n pressTab(event, {\n el,\n root: listRef.value,\n drag: () => ({\n value: entry.props.value,\n label: labelText(entry),\n group: props.group,\n name: props.name,\n index: panels.value.indexOf(entry),\n source: self,\n }),\n onStart: () => (draggingUid.value = entry.uid),\n onEnd: () => {\n draggingUid.value = null\n clickBlocked = true\n setTimeout(() => (clickBlocked = false))\n },\n })\n}\n\n/** Where a tab dropped now would go: before the tab at `index`, or after the last. */\nconst marker = ref<{ index: number; at: number } | null>(null)\n\nfunction insertionAt(x: number, y: number) {\n const entries = panels.value\n const index = entries.findIndex((entry) => {\n const rect = tabElement(entry)?.getBoundingClientRect()\n if (!rect) return false\n return vertical.value ? y < rect.top + rect.height / 2 : x < rect.left + rect.width / 2\n })\n return index < 0 ? entries.length : index\n}\n\n/**\n * Whether the tab comes from these tabs: dragged from them, or from\n * elsewhere (a list outside a dock) when these tabs hold it already.\n */\nconst fromHere = (drag: TabDrag) =>\n drag.source === self ||\n (drag.name !== undefined && drag.name === props.name && drag.group === props.group)\n\n/** Whether dropping there leaves the tab where it is. */\nconst stays = (drag: TabDrag, index: number) =>\n fromHere(drag) && (index === drag.index || index === drag.index + 1)\n\nfunction markerOffset(index: number) {\n const entries = panels.value\n const style = getComputedStyle(listRef.value!)\n const gap = Number.parseFloat(vertical.value ? style.rowGap : style.columnGap) || 0\n const before = entries[index] && tabElement(entries[index])\n if (before) return (vertical.value ? before.offsetTop : before.offsetLeft) - gap / 2\n const last = entries.at(-1)\n const after = last && tabElement(last)\n if (!after) return 0\n return vertical.value\n ? after.offsetTop + after.offsetHeight + gap / 2\n : after.offsetLeft + after.offsetWidth + gap / 2\n}\n\n/** Scroll a row that does not fit while the pointer is near one of its ends. */\nfunction scrollNearEdge(x: number, y: number) {\n const list = listRef.value\n if (!list) return\n const rect = list.getBoundingClientRect()\n const EDGE = 32\n const speed = (d: number) => Math.ceil(((EDGE - Math.max(0, d)) / EDGE) * 10)\n const [pos, startEdge, endEdge] = vertical.value\n ? [y, rect.top, rect.bottom]\n : [x, rect.left, rect.right]\n let delta = 0\n if (pos - startEdge < EDGE) delta = -speed(pos - startEdge)\n else if (endEdge - pos < EDGE) delta = speed(endEdge - pos)\n if (!delta) return\n if (vertical.value) list.scrollTop += delta\n else list.scrollLeft += delta\n}\n\nconst dropZone = registerTabDropZone({\n el: () => headerRef.value,\n // its own tabs always come back; tabs from others only when these take drops\n accepts: (drag) =>\n drag.source === self || (props.draggable && !!props.group && drag.group === props.group),\n over(drag, x, y) {\n scrollNearEdge(x, y)\n const index = insertionAt(x, y)\n if (stays(drag, index)) {\n marker.value = null\n return\n }\n // kept inside the row, which cuts off what sticks out\n const list = listRef.value!\n const end = (vertical.value ? list.scrollHeight : list.scrollWidth) - 2\n const at = Math.min(Math.max(markerOffset(index), 1), end)\n if (marker.value?.index !== index || marker.value.at !== at) marker.value = { index, at }\n },\n leave: () => (marker.value = null),\n drop(drag) {\n const index = marker.value?.index\n marker.value = null\n if (index === undefined) return\n const within = fromHere(drag)\n emit('move', {\n value: drag.value,\n from: { name: drag.name, index: drag.index },\n to: { name: props.name, index: within && index > drag.index ? index - 1 : index },\n })\n // dragging a tab is using it\n void selectValue(drag.value)\n },\n})\nonMounted(() => {\n dropZone.update()\n if (process.env.NODE_ENV !== 'production' && props.group && props.name === undefined)\n devWarn(\n `[dou-ui] DouTabs: tabs in the group \"${props.group}\" need a \\`name\\`; \\`move\\` cannot tell which tabs a tab came from without it.`,\n )\n})\nonUpdated(() => dropZone.update())\nonBeforeUnmount(() => dropZone.remove())\n\nconst markerStyle = computed(() => {\n const at = marker.value?.at\n if (at === undefined) return { display: 'none' }\n return { transform: vertical.value ? `translateY(${at}px)` : `translateX(${at}px)` }\n})\n\n/** A tab moved with the keyboard keeps the focus once it is in its new place. */\nlet focusAfterMove: TabsValue | undefined\n\nfunction moveByKey(event: KeyboardEvent, entry: TabPanelEntry) {\n const [prev, next] = vertical.value ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight']\n const entries = panels.value\n const index = entries.indexOf(entry)\n const last = entries.length - 1\n const target =\n event.key === prev\n ? index - 1\n : event.key === next\n ? index + 1\n : event.key === 'Home'\n ? 0\n : event.key === 'End'\n ? last\n : null\n if (target === null) return false\n event.preventDefault()\n if (target < 0 || target > last || target === index) return true\n focusAfterMove = entry.props.value\n emit('move', {\n value: entry.props.value,\n from: { name: props.name, index },\n to: { name: props.name, index: target },\n })\n announce(\n t('tabs.moved', { label: labelText(entry), position: target + 1, total: entries.length }),\n )\n return true\n}\n\nwatch(\n panels,\n () => {\n if (focusAfterMove === undefined) return\n const entry = panels.value.find((panel) => panel.props.value === focusAfterMove)\n focusAfterMove = undefined\n const el = entry && tabElement(entry)\n if (el && document.activeElement !== el) el.focus()\n },\n { flush: 'post' },\n)\n\nconst moveKeys = computed(() =>\n vertical.value\n ? 'Alt+ArrowUp Alt+ArrowDown Alt+Home Alt+End'\n : 'Alt+ArrowLeft Alt+ArrowRight Alt+Home Alt+End',\n)\nfunction keyShortcuts(entry: TabPanelEntry) {\n const keys = [isClosable(entry) && 'Delete', isDraggable(entry) && moveKeys.value].filter(Boolean)\n return keys.length ? keys.join(' ') : undefined\n}\n\n// The underline slides between the tabs. It is measured from the\n// selected tab, like the selection of a segmented control.\nconst indicator = ref<{ left: number; top: number; width: number; height: number } | null>(null)\nconst settled = ref(false)\n\nfunction measure() {\n const list = listRef.value\n const entry = panels.value.find((panel) => panel.props.value === selected.value)\n const tab = entry && tabElement(entry)\n if (!list || !tab) {\n indicator.value = null\n return\n }\n indicator.value = {\n left: tab.offsetLeft,\n top: tab.offsetTop,\n width: tab.offsetWidth,\n height: tab.offsetHeight,\n }\n}\n\n// When the tabs do not fit, the list scrolls sideways: the edges fade and\n// arrows appear on the side that has more, and the selected tab is kept in view.\nconst overflow = ref({ start: false, end: false })\nconst reduced = useReducedMotion()\n\n// Arrows in a narrow row would leave no room for a single tab: there the\n// row scrolls by swiping, the wheel or the keyboard alone.\nconst ARROWS_MIN_WIDTH = 160\nconst arrows = ref(true)\n\nfunction updateOverflow() {\n // a header not laid out yet has no width to go by\n const width = headerRef.value?.clientWidth || Infinity\n arrows.value = width >= ARROWS_MIN_WIDTH\n const list = listRef.value\n if (!list) {\n overflow.value = { start: false, end: false }\n return\n }\n if (vertical.value) {\n // a column only overflows with a fixed `height`; there it fades but has no arrows\n const max = list.scrollHeight - list.clientHeight\n // kept in range while the column bounces\n const top = scrollPositionOf(list).top\n overflow.value = { start: top > 1, end: top < max - 1 }\n return\n }\n const max = list.scrollWidth - list.clientWidth\n // from the start, also right to left, and kept in range while the row bounces\n const left = Math.abs(scrollPositionOf(list).left)\n // a sub-pixel remainder is not something to scroll to\n overflow.value = { start: left > 1, end: left < max - 1 }\n}\n\nfunction reveal(smooth: boolean) {\n const list = listRef.value\n const entry = panels.value.find((panel) => panel.props.value === selected.value)\n const tab = entry && tabElement(entry)\n if (!list || !tab) return\n // leave room for the faded edge, so the tab is not under it\n const margin = 32\n if (vertical.value) {\n const top = tab.offsetTop - margin\n const bottom = tab.offsetTop + tab.offsetHeight + margin - list.clientHeight\n const target = top < list.scrollTop ? top : bottom > list.scrollTop ? bottom : null\n if (target === null) return\n list.scrollTo({\n top: Math.max(0, target),\n behavior: smooth && !reduced.value ? 'smooth' : 'auto',\n })\n return\n }\n const left = tab.offsetLeft - margin\n const right = tab.offsetLeft + tab.offsetWidth + margin - list.clientWidth\n const target = left < list.scrollLeft ? left : right > list.scrollLeft ? right : null\n if (target === null) return\n list.scrollTo({\n left: Math.max(0, target),\n behavior: smooth && !reduced.value ? 'smooth' : 'auto',\n })\n}\n\nfunction scrollByPage(direction: 1 | -1) {\n const list = listRef.value\n if (!list) return\n list.scrollBy({\n left: direction * list.clientWidth * 0.8,\n behavior: reduced.value ? 'auto' : 'smooth',\n })\n}\n\nlet observer: ResizeObserver | undefined\nonMounted(() => {\n measure()\n updateOverflow()\n reveal(false)\n requestAnimationFrame(() => (settled.value = true))\n if (typeof ResizeObserver !== 'undefined' && listRef.value) {\n observer = new ResizeObserver(() => {\n measure()\n updateOverflow()\n })\n observer.observe(listRef.value)\n }\n})\nonBeforeUnmount(() => observer?.disconnect())\nwatch(\n [selected, panels, size, () => props.placement, () => props.iconOnly, () => props.height],\n () =>\n nextTick(() => {\n measure()\n updateOverflow()\n reveal(settled.value)\n }),\n)\n\nconst rootStyle = computed(() =>\n props.height === undefined\n ? undefined\n : {\n height: typeof props.height === 'number' ? `${props.height}px` : props.height,\n },\n)\n\nconst indicatorStyle = computed(() => {\n const box = indicator.value\n if (!box) return { display: 'none' }\n return vertical.value\n ? { transform: `translateY(${box.top}px)`, height: `${box.height}px` }\n : { transform: `translateX(${box.left}px)`, width: `${box.width}px` }\n})\n</script>\n\n<template>\n <div\n :class=\"[\n ns.b(),\n ns.m(size),\n ns.is('settled', settled),\n ns.is('vertical', vertical),\n vertical && ns.is(`placement-${placement}`, true),\n ns.is('fixed', height !== undefined),\n ns.is('icon-only', iconOnly),\n ns.is('drop-target', !!marker),\n ]\"\n :style=\"rootStyle\"\n >\n <div ref=\"header\" :class=\"ns.e('header')\">\n <button\n v-if=\"!vertical && arrows && (overflow.start || overflow.end)\"\n type=\"button\"\n tabindex=\"-1\"\n :class=\"[ns.e('scroll'), ns.is('start', true)]\"\n :disabled=\"!overflow.start\"\n :aria-label=\"t('tabs.scrollPrev')\"\n @click=\"scrollByPage(-1)\"\n >\n <ChevronLeftIcon />\n </button>\n <div\n ref=\"list\"\n :class=\"[\n ns.e('list'),\n ns.is('fade-start', overflow.start),\n ns.is('fade-end', overflow.end),\n ]\"\n role=\"tablist\"\n :aria-orientation=\"vertical ? 'vertical' : 'horizontal'\"\n @scroll.passive=\"updateOverflow\"\n >\n <template v-for=\"entry in panels\" :key=\"entry.uid\">\n <TabTip :entry=\"entry\">\n <button\n :id=\"tabId(entry.props.value)\"\n :ref=\"(el) => setTabElement(entry.uid, el)\"\n type=\"button\"\n role=\"tab\"\n :class=\"[\n ns.e('tab'),\n ns.is('selected', entry.props.value === selected),\n ns.is('disabled', !!entry.props.disabled),\n ns.is('closable', isClosable(entry)),\n ns.is('icon-alone', iconAlone(entry)),\n ns.is('draggable', isDraggable(entry)),\n ns.is('dragging', draggingUid === entry.uid),\n ]\"\n :aria-selected=\"entry.props.value === selected\"\n :aria-controls=\"panelId(entry.props.value)\"\n :aria-label=\"iconAlone(entry) ? labelText(entry) : undefined\"\n :aria-disabled=\"entry.props.disabled || undefined\"\n :tabindex=\"entry.props.value === selected ? 0 : -1\"\n :aria-keyshortcuts=\"keyShortcuts(entry)\"\n @click=\"onClick(entry)\"\n @pointerdown=\"onPointerdown($event, entry)\"\n @keydown=\"onKeydown($event, entry)\"\n >\n <component\n :is=\"entry.props.icon\"\n v-if=\"entry.props.icon\"\n :class=\"ns.e('icon')\"\n aria-hidden=\"true\"\n />\n <span v-if=\"!iconAlone(entry)\" :class=\"ns.e('label')\">\n <TabLabel :entry=\"entry\" :selected=\"entry.props.value === selected\" />\n </span>\n <!-- not a button of its own: a tab cannot hold one; `Delete` closes it from the keyboard.\n An icon alone already has the label's tooltip, so the close button goes without. -->\n <DouTooltip\n v-if=\"isClosable(entry)\"\n :content=\"t('tabs.close')\"\n shortcut=\"delete\"\n :disabled=\"iconAlone(entry)\"\n >\n <span :class=\"ns.e('close')\" aria-hidden=\"true\" @click.stop=\"remove(entry)\">\n <CloseIcon />\n </span>\n </DouTooltip>\n </button>\n </TabTip>\n </template>\n <span :class=\"ns.e('indicator')\" :style=\"indicatorStyle\" aria-hidden=\"true\" />\n <span v-if=\"draggable\" :class=\"ns.e('marker')\" :style=\"markerStyle\" aria-hidden=\"true\" />\n </div>\n <button\n v-if=\"!vertical && arrows && (overflow.start || overflow.end)\"\n type=\"button\"\n tabindex=\"-1\"\n :class=\"[ns.e('scroll'), ns.is('end', true)]\"\n :disabled=\"!overflow.end\"\n :aria-label=\"t('tabs.scrollNext')\"\n @click=\"scrollByPage(1)\"\n >\n <ChevronRightIcon />\n </button>\n <button\n v-if=\"addable\"\n type=\"button\"\n :class=\"ns.e('add')\"\n :aria-label=\"t('tabs.add')\"\n @click=\"emit('add')\"\n >\n <PlusIcon />\n </button>\n <div v-if=\"slots.extra\" :class=\"ns.e('extra')\">\n <slot name=\"extra\" />\n </div>\n </div>\n <slot />\n </div>\n</template>\n"],"mappings":""}
package/dist/index.js CHANGED
@@ -106,8 +106,8 @@ import { formatDateValue } from "./components/date-picker/format.js";
106
106
  import { DouCalendar, DouDatePicker } from "./components/date-picker/index.js";
107
107
  import { DouDescriptions, DouDescriptionsItem } from "./components/descriptions/index.js";
108
108
  import { DouDivider } from "./components/divider/index.js";
109
- import { DouTabPanel, DouTabs } from "./components/tabs/index.js";
110
109
  import { useElementSize, useIntersection, useResizeObserver } from "./composables/use-element-size.js";
110
+ import { DouTabPanel, DouTabs } from "./components/tabs/index.js";
111
111
  import { DouSplitter } from "./components/splitter/index.js";
112
112
  import { dockGroups, findDockGroup, moveDockTab, nextDockGroupId, removeDockTab, selectDockTab, splitDockTab } from "./components/dock/layout.js";
113
113
  import { DouDock } from "./components/dock/index.js";
@@ -10,7 +10,8 @@ export interface DockContext {
10
10
  size: () => TabsSize | undefined;
11
11
  closable: () => boolean;
12
12
  addable: () => boolean;
13
- min: () => SplitterLimit;
13
+ /** The smallest each side of a split in this direction may get. */
14
+ min: (direction: DockSplit['direction']) => SplitterLimit;
14
15
  draggable: () => boolean;
15
16
  panel: (value: TabsValue) => DockPanel | undefined;
16
17
  slots: DockSlots;
@@ -22,6 +23,8 @@ export interface DockContext {
22
23
  drop: (drag: TabDrag, group: DockGroup, side: DockSide | 'center') => void;
23
24
  remove: (value: TabsValue, group: DockGroup) => void;
24
25
  add: (group: DockGroup) => void;
26
+ /** A pointer pressed or the focus moved into a group, or a tab was dropped on it. */
27
+ use: (group: string) => void;
25
28
  /** The place in the layout a group is shown in. */
26
29
  setCell: (id: string, el: unknown) => void;
27
30
  }
@@ -1,6 +1,12 @@
1
1
  import type { DockGroup } from './layout';
2
2
  type __VLS_Props = {
3
3
  group: DockGroup;
4
+ /** Which slots the dock has; read in its render, so a slot that comes later shows up. */
5
+ slotted: {
6
+ label: boolean;
7
+ extra: boolean;
8
+ empty: boolean;
9
+ };
4
10
  };
5
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
12
  declare const _default: typeof __VLS_export;