dou-ui 0.1.0-alpha.21 → 0.1.0-alpha.23

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 (110) hide show
  1. package/dist/components/chat-input/chat-input.vue_vue_type_script_setup_true_lang.js +19 -14
  2. package/dist/components/chat-input/chat-input.vue_vue_type_script_setup_true_lang.js.map +1 -1
  3. package/dist/components/chat-input/chat-input2.js.map +1 -1
  4. package/dist/components/chat-list/chat-list.js.map +1 -1
  5. package/dist/components/chat-list/chat-list.vue_vue_type_script_setup_true_lang.js +51 -19
  6. package/dist/components/chat-list/chat-list.vue_vue_type_script_setup_true_lang.js.map +1 -1
  7. package/dist/components/chat-list/chat-list2.js.map +1 -1
  8. package/dist/components/chat-message/chat-message.js.map +1 -1
  9. package/dist/components/chat-message/chat-message.vue_vue_type_script_setup_true_lang.js +52 -12
  10. package/dist/components/chat-message/chat-message.vue_vue_type_script_setup_true_lang.js.map +1 -1
  11. package/dist/components/chat-message/chat-message2.js.map +1 -1
  12. package/dist/components/chat-plan/chat-plan.js.map +1 -1
  13. package/dist/components/chat-plan/chat-plan.vue_vue_type_script_setup_true_lang.js +22 -9
  14. package/dist/components/chat-plan/chat-plan.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/components/chat-plan/chat-plan2.js.map +1 -1
  16. package/dist/components/code-block/code-block.js.map +1 -1
  17. package/dist/components/code-block/code-block.vue_vue_type_script_setup_true_lang.js +144 -7
  18. package/dist/components/code-block/code-block.vue_vue_type_script_setup_true_lang.js.map +1 -1
  19. package/dist/components/dock/dock-group.js.map +1 -1
  20. package/dist/components/dock/dock-group.vue_vue_type_script_setup_true_lang.js +4 -2
  21. package/dist/components/dock/dock-group.vue_vue_type_script_setup_true_lang.js.map +1 -1
  22. package/dist/components/dock/dock.js.map +1 -1
  23. package/dist/components/dock/dock.vue_vue_type_script_setup_true_lang.js +30 -4
  24. package/dist/components/dock/dock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/components/dock/style.js +1 -0
  26. package/dist/components/form/form.vue_vue_type_script_setup_true_lang.js +1 -0
  27. package/dist/components/form/form.vue_vue_type_script_setup_true_lang.js.map +1 -1
  28. package/dist/components/form/form2.js.map +1 -1
  29. package/dist/components/image/image-preview.js.map +1 -1
  30. package/dist/components/image/image-preview.vue_vue_type_script_setup_true_lang.js +63 -95
  31. package/dist/components/image/image-preview.vue_vue_type_script_setup_true_lang.js.map +1 -1
  32. package/dist/components/image/use-preview-viewport.js +619 -0
  33. package/dist/components/image/use-preview-viewport.js.map +1 -0
  34. package/dist/components/image/viewport.js +142 -0
  35. package/dist/components/image/viewport.js.map +1 -0
  36. package/dist/components/link/link.js.map +1 -1
  37. package/dist/components/link/link.vue_vue_type_script_setup_true_lang.js +59 -14
  38. package/dist/components/link/link.vue_vue_type_script_setup_true_lang.js.map +1 -1
  39. package/dist/components/popover/popover.js.map +1 -1
  40. package/dist/components/popover/popover.vue_vue_type_script_setup_true_lang.js +13 -3
  41. package/dist/components/popover/popover.vue_vue_type_script_setup_true_lang.js.map +1 -1
  42. package/dist/components/splitter/splitter.js.map +1 -1
  43. package/dist/components/splitter/splitter.vue_vue_type_script_setup_true_lang.js +111 -41
  44. package/dist/components/splitter/splitter.vue_vue_type_script_setup_true_lang.js.map +1 -1
  45. package/dist/components/tabs/style.js +1 -0
  46. package/dist/components/tabs/tab-button.js +6 -0
  47. package/dist/components/tabs/tab-button.js.map +1 -0
  48. package/dist/components/tabs/tab-button.vue_vue_type_script_setup_true_lang.js +108 -0
  49. package/dist/components/tabs/tab-button.vue_vue_type_script_setup_true_lang.js.map +1 -0
  50. package/dist/components/tabs/tab-drag.js +10 -2
  51. package/dist/components/tabs/tab-drag.js.map +1 -1
  52. package/dist/components/tabs/tab-panel.js.map +1 -1
  53. package/dist/components/tabs/tab-panel.vue_vue_type_script_setup_true_lang.js +4 -0
  54. package/dist/components/tabs/tab-panel.vue_vue_type_script_setup_true_lang.js.map +1 -1
  55. package/dist/components/tabs/tabs.js.map +1 -1
  56. package/dist/components/tabs/tabs.vue_vue_type_script_setup_true_lang.js +430 -181
  57. package/dist/components/tabs/tabs.vue_vue_type_script_setup_true_lang.js.map +1 -1
  58. package/dist/components/tabs/tabs2.js.map +1 -1
  59. package/dist/components/virtual-list/virtual-list.vue_vue_type_script_setup_true_lang.js +77 -34
  60. package/dist/components/virtual-list/virtual-list.vue_vue_type_script_setup_true_lang.js.map +1 -1
  61. package/dist/components/virtual-list/virtual-list2.js.map +1 -1
  62. package/dist/composables/use-floating.js +60 -8
  63. package/dist/composables/use-floating.js.map +1 -1
  64. package/dist/composables/use-measured-sizes.js +7 -3
  65. package/dist/composables/use-measured-sizes.js.map +1 -1
  66. package/dist/composables/use-popup.js +3 -0
  67. package/dist/composables/use-popup.js.map +1 -1
  68. package/dist/composables/use-touch-scroll.js +141 -29
  69. package/dist/composables/use-touch-scroll.js.map +1 -1
  70. package/dist/locale/en.js +3 -2
  71. package/dist/locale/en.js.map +1 -1
  72. package/dist/locale/zh-cn.js +3 -2
  73. package/dist/locale/zh-cn.js.map +1 -1
  74. package/dist/locale/zh-tw.js +3 -2
  75. package/dist/locale/zh-tw.js.map +1 -1
  76. package/dist/style.css +1 -1
  77. package/dist/types/components/chat-list/chat-list.d.ts +13 -0
  78. package/dist/types/components/chat-list/index.d.ts +2 -0
  79. package/dist/types/components/chat-message/chat-message.d.ts +19 -0
  80. package/dist/types/components/chat-message/chat-message.vue.d.ts +1 -0
  81. package/dist/types/components/chat-message/index.d.ts +3 -0
  82. package/dist/types/components/chat-plan/chat-plan.d.ts +3 -1
  83. package/dist/types/components/chat-plan/chat-plan.vue.d.ts +1 -0
  84. package/dist/types/components/chat-plan/index.d.ts +3 -0
  85. package/dist/types/components/code-block/code-block.d.ts +23 -0
  86. package/dist/types/components/code-block/code-block.vue.d.ts +8 -2
  87. package/dist/types/components/code-block/index.d.ts +19 -3
  88. package/dist/types/components/dock/dock.d.ts +6 -0
  89. package/dist/types/components/image/image.d.ts +1 -1
  90. package/dist/types/components/image/use-preview-viewport.d.ts +48 -0
  91. package/dist/types/components/image/viewport.d.ts +58 -0
  92. package/dist/types/components/link/index.d.ts +3 -0
  93. package/dist/types/components/link/link.d.ts +12 -3
  94. package/dist/types/components/link/link.vue.d.ts +1 -0
  95. package/dist/types/components/popover/index.d.ts +3 -0
  96. package/dist/types/components/popover/popover.d.ts +7 -0
  97. package/dist/types/components/popover/popover.vue.d.ts +1 -0
  98. package/dist/types/components/splitter/index.d.ts +6 -9
  99. package/dist/types/components/splitter/splitter.d.ts +31 -4
  100. package/dist/types/components/splitter/splitter.vue.d.ts +3 -4
  101. package/dist/types/components/tabs/index.d.ts +3 -0
  102. package/dist/types/components/tabs/tab-button.vue.d.ts +28 -0
  103. package/dist/types/components/tabs/tab-drag.d.ts +8 -0
  104. package/dist/types/components/tabs/tab-panel.vue.d.ts +1 -0
  105. package/dist/types/components/tabs/tabs.d.ts +6 -0
  106. package/dist/types/composables/use-floating.d.ts +1 -1
  107. package/dist/types/composables/use-measured-sizes.d.ts +2 -0
  108. package/dist/types/composables/use-touch-scroll.d.ts +8 -0
  109. package/dist/types/locale/types.d.ts +6 -3
  110. package/package.json +3 -3
@@ -31,12 +31,20 @@ function zoneAt(drag, x, y) {
31
31
  }
32
32
  }
33
33
  /**
34
+ * Whether a pointerdown should not start a tab drag: non-primary buttons and
35
+ * modifier-key clicks keep their native behavior (context menu, open in new
36
+ * tab, range select, etc.).
37
+ */
38
+ function isIgnoredDragPress(event) {
39
+ return event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey;
40
+ }
41
+ /**
34
42
  * Watch a press on a tab and turn it into a drag once the pointer moves
35
43
  * far enough. On touch the press has to be held first, so a swipe still
36
44
  * scrolls the row of tabs.
37
45
  */
38
46
  function pressTab(event, options) {
39
- if (event.button !== 0 || activeTabDrag.value) return;
47
+ if (isIgnoredDragPress(event) || activeTabDrag.value) return;
40
48
  const start = {
41
49
  x: event.clientX,
42
50
  y: event.clientY
@@ -176,6 +184,6 @@ function pressTab(event, options) {
176
184
  window.addEventListener("pointercancel", onCancel);
177
185
  window.addEventListener("keydown", onKey, true);
178
186
  }
179
- export { activeTabDrag, pressTab, registerTabDropZone };
187
+ export { activeTabDrag, isIgnoredDragPress, pressTab, registerTabDropZone };
180
188
 
181
189
  //# sourceMappingURL=tab-drag.js.map
@@ -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 /**\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,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;EACA,SAAS;GACP,IAAI,IAAI,MAAM,OAAO,EAAE;GACvB,KAAK,KAAA;EACP;CACF;AACF;;AAGA,SAAS,OAAO,MAAe,GAAW,GAAW;CACnD,IAAI,KAAK,SAAS,iBAAiB,GAAG,CAAC;CACvC,OAAO,IAAI;EACT,MAAM,OAAO,MAAM,IAAI,EAAE;EACzB,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO;EAChC,KAAK,GAAG;CACV;AAEF;;;;;;AAuBA,SAAgB,SAAS,OAAqB,SAA8B;CAC1E,IAAI,MAAM,WAAW,KAAK,cAAc,OAAO;CAC/C,MAAM,QAAQ;EAAE,GAAG,MAAM;EAAS,GAAG,MAAM;CAAQ;CACnD,MAAM,QAAQ,MAAM,gBAAgB;CACpC,IAAI,QAAQ,CAAC;CACb,IAAI,OAAuB;CAC3B,IAAI;CACJ,IAAI,SAAS;EAAE,GAAG;EAAG,GAAG;CAAE;CAC1B,IAAI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,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 /** Whether the dragged tab is pinned. */\n pinned?: boolean\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 * Whether a pointerdown should not start a tab drag: non-primary buttons and\n * modifier-key clicks keep their native behavior (context menu, open in new\n * tab, range select, etc.).\n */\nexport function isIgnoredDragPress(event: PointerEvent) {\n return event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey\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 (isIgnoredDragPress(event) || 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":";;;AAgCA,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,IA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AChD,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 +1 @@
1
- {"version":3,"file":"tab-panel.js","names":["_sfc_main"],"sources":["../../../src/components/tabs/tab-panel.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n getCurrentInstance,\n inject,\n onBeforeUnmount,\n onMounted,\n ref,\n useTemplateRef,\n watch,\n} from 'vue'\nimport { useNamespace } from '../../utils/namespace'\nimport { tabsKey } from './tabs'\nimport type { TabPanelProps, TabPanelSlots } from './tabs'\n\ndefineOptions({ name: 'DouTabPanel' })\n\nconst props = withDefaults(defineProps<TabPanelProps>(), {\n disabled: false,\n closable: undefined,\n draggable: undefined,\n eager: false,\n})\nconst slots = defineSlots<TabPanelSlots>()\n\nconst ns = useNamespace('tabs')\nconst tabs = inject(tabsKey, undefined)\nconst uid = getCurrentInstance()!.uid\nconst el = useTemplateRef<HTMLElement>('el')\n\ntabs?.register({ uid, props, slots, el })\nonMounted(() => tabs?.reorder())\nonBeforeUnmount(() => tabs?.unregister(uid))\n\nconst selected = computed(() => tabs?.selected.value === props.value)\n\n// Render the content the first time the panel is shown, then keep it, so\n// switching back is instant and keeps its state.\nconst visited = ref(selected.value || props.eager)\nwatch(selected, (value) => {\n if (value) visited.value = true\n})\n</script>\n\n<template>\n <div\n :id=\"tabs?.panelId(value)\"\n ref=\"el\"\n :class=\"ns.e('panel')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabs?.tabId(value)\"\n :hidden=\"!selected\"\n tabindex=\"0\"\n >\n <slot v-if=\"visited\" />\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"tab-panel.js","names":["_sfc_main"],"sources":["../../../src/components/tabs/tab-panel.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n getCurrentInstance,\n inject,\n onBeforeUnmount,\n onMounted,\n ref,\n useTemplateRef,\n watch,\n} from 'vue'\nimport { useNamespace } from '../../utils/namespace'\nimport { tabsKey } from './tabs'\nimport type { TabPanelProps, TabPanelSlots } from './tabs'\n\ndefineOptions({ name: 'DouTabPanel' })\n\nconst props = withDefaults(defineProps<TabPanelProps>(), {\n disabled: false,\n closable: undefined,\n draggable: undefined,\n pinned: false,\n eager: false,\n})\nconst slots = defineSlots<TabPanelSlots>()\n\nconst ns = useNamespace('tabs')\nconst tabs = inject(tabsKey, undefined)\nconst uid = getCurrentInstance()!.uid\nconst el = useTemplateRef<HTMLElement>('el')\n\ntabs?.register({ uid, props, slots, el })\nonMounted(() => tabs?.reorder())\nonBeforeUnmount(() => tabs?.unregister(uid))\n\nconst selected = computed(() => tabs?.selected.value === props.value)\n\n// Render the content the first time the panel is shown, then keep it, so\n// switching back is instant and keeps its state.\nconst visited = ref(selected.value || props.eager)\nwatch(selected, (value) => {\n if (value) visited.value = true\n})\n</script>\n\n<template>\n <div\n :id=\"tabs?.panelId(value)\"\n ref=\"el\"\n :class=\"ns.e('panel')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabs?.tabId(value)\"\n :hidden=\"!selected\"\n tabindex=\"0\"\n >\n <slot v-if=\"visited\" />\n </div>\n</template>\n"],"mappings":""}
@@ -26,6 +26,10 @@ var tab_panel_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
26
26
  type: Boolean,
27
27
  default: void 0
28
28
  },
29
+ pinned: {
30
+ type: Boolean,
31
+ default: false
32
+ },
29
33
  eager: {
30
34
  type: Boolean,
31
35
  default: false
@@ -1 +1 @@
1
- {"version":3,"file":"tab-panel.vue_vue_type_script_setup_true_lang.js","names":["_useSlots","_openBlock","_createElementBlock","_unref","_normalizeClass","_renderSlot","_createCommentVNode"],"sources":["../../../src/components/tabs/tab-panel.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n getCurrentInstance,\n inject,\n onBeforeUnmount,\n onMounted,\n ref,\n useTemplateRef,\n watch,\n} from 'vue'\nimport { useNamespace } from '../../utils/namespace'\nimport { tabsKey } from './tabs'\nimport type { TabPanelProps, TabPanelSlots } from './tabs'\n\ndefineOptions({ name: 'DouTabPanel' })\n\nconst props = withDefaults(defineProps<TabPanelProps>(), {\n disabled: false,\n closable: undefined,\n draggable: undefined,\n eager: false,\n})\nconst slots = defineSlots<TabPanelSlots>()\n\nconst ns = useNamespace('tabs')\nconst tabs = inject(tabsKey, undefined)\nconst uid = getCurrentInstance()!.uid\nconst el = useTemplateRef<HTMLElement>('el')\n\ntabs?.register({ uid, props, slots, el })\nonMounted(() => tabs?.reorder())\nonBeforeUnmount(() => tabs?.unregister(uid))\n\nconst selected = computed(() => tabs?.selected.value === props.value)\n\n// Render the content the first time the panel is shown, then keep it, so\n// switching back is instant and keeps its state.\nconst visited = ref(selected.value || props.eager)\nwatch(selected, (value) => {\n if (value) visited.value = true\n})\n</script>\n\n<template>\n <div\n :id=\"tabs?.panelId(value)\"\n ref=\"el\"\n :class=\"ns.e('panel')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabs?.tabId(value)\"\n :hidden=\"!selected\"\n tabindex=\"0\"\n >\n <slot v-if=\"visited\" />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBA,MAAM,QAAQ;EAMd,MAAM,QAAQA,SAAA;EAEd,MAAM,KAAK,aAAa,MAAM;EAC9B,MAAM,OAAO,OAAO,SAAS,KAAA,CAAS;EACtC,MAAM,MAAM,mBAAmB,CAAC,CAAE;EAClC,MAAM,KAAK,eAA4B,IAAI;EAE3C,MAAM,SAAS;GAAE;GAAK;GAAO;GAAO;EAAG,CAAC;EACxC,gBAAgB,MAAM,QAAQ,CAAC;EAC/B,sBAAsB,MAAM,WAAW,GAAG,CAAC;EAE3C,MAAM,WAAW,eAAe,MAAM,SAAS,UAAU,MAAM,KAAK;EAIpE,MAAM,UAAU,IAAI,SAAS,SAAS,MAAM,KAAK;EACjD,MAAM,WAAW,UAAU;GACzB,IAAI,OAAO,QAAQ,QAAQ;EAC7B,CAAC;;GAIC,OAAAC,UAAA,GAAAC,mBAUM,OAAA;IATH,IAAIC,MAAA,IAAA,CAAI,EAAE,QAAQ,QAAA,KAAK;IACpB,SAAA;IAAJ,KAAI;IACH,OAAKC,eAAED,MAAA,EAAA,CAAE,CAAC,EAAC,OAAA,CAAA;IACZ,MAAK;IACJ,mBAAiBA,MAAA,IAAA,CAAI,EAAE,MAAM,QAAA,KAAK;IAClC,QAAM,CAAG,SAAA;IACV,UAAS;G,IAEG,QAAA,QAAZE,WAAuB,KAAA,QAAA,WAAA,CAAA,GAAA,KAAA,GAAA,KAAA,GAAA,CAAA,I"}
1
+ {"version":3,"file":"tab-panel.vue_vue_type_script_setup_true_lang.js","names":["_useSlots","_openBlock","_createElementBlock","_unref","_normalizeClass","_renderSlot","_createCommentVNode"],"sources":["../../../src/components/tabs/tab-panel.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n getCurrentInstance,\n inject,\n onBeforeUnmount,\n onMounted,\n ref,\n useTemplateRef,\n watch,\n} from 'vue'\nimport { useNamespace } from '../../utils/namespace'\nimport { tabsKey } from './tabs'\nimport type { TabPanelProps, TabPanelSlots } from './tabs'\n\ndefineOptions({ name: 'DouTabPanel' })\n\nconst props = withDefaults(defineProps<TabPanelProps>(), {\n disabled: false,\n closable: undefined,\n draggable: undefined,\n pinned: false,\n eager: false,\n})\nconst slots = defineSlots<TabPanelSlots>()\n\nconst ns = useNamespace('tabs')\nconst tabs = inject(tabsKey, undefined)\nconst uid = getCurrentInstance()!.uid\nconst el = useTemplateRef<HTMLElement>('el')\n\ntabs?.register({ uid, props, slots, el })\nonMounted(() => tabs?.reorder())\nonBeforeUnmount(() => tabs?.unregister(uid))\n\nconst selected = computed(() => tabs?.selected.value === props.value)\n\n// Render the content the first time the panel is shown, then keep it, so\n// switching back is instant and keeps its state.\nconst visited = ref(selected.value || props.eager)\nwatch(selected, (value) => {\n if (value) visited.value = true\n})\n</script>\n\n<template>\n <div\n :id=\"tabs?.panelId(value)\"\n ref=\"el\"\n :class=\"ns.e('panel')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabs?.tabId(value)\"\n :hidden=\"!selected\"\n tabindex=\"0\"\n >\n <slot v-if=\"visited\" />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBA,MAAM,QAAQ;EAOd,MAAM,QAAQA,SAAA;EAEd,MAAM,KAAK,aAAa,MAAM;EAC9B,MAAM,OAAO,OAAO,SAAS,KAAA,CAAS;EACtC,MAAM,MAAM,mBAAmB,CAAC,CAAE;EAClC,MAAM,KAAK,eAA4B,IAAI;EAE3C,MAAM,SAAS;GAAE;GAAK;GAAO;GAAO;EAAG,CAAC;EACxC,gBAAgB,MAAM,QAAQ,CAAC;EAC/B,sBAAsB,MAAM,WAAW,GAAG,CAAC;EAE3C,MAAM,WAAW,eAAe,MAAM,SAAS,UAAU,MAAM,KAAK;EAIpE,MAAM,UAAU,IAAI,SAAS,SAAS,MAAM,KAAK;EACjD,MAAM,WAAW,UAAU;GACzB,IAAI,OAAO,QAAQ,QAAQ;EAC7B,CAAC;;GAIC,OAAAC,UAAA,GAAAC,mBAUM,OAAA;IATH,IAAIC,MAAA,IAAA,CAAI,EAAE,QAAQ,QAAA,KAAK;IACpB,SAAA;IAAJ,KAAI;IACH,OAAKC,eAAED,MAAA,EAAA,CAAE,CAAC,EAAC,OAAA,CAAA;IACZ,MAAK;IACJ,mBAAiBA,MAAA,IAAA,CAAI,EAAE,MAAM,QAAA,KAAK;IAClC,QAAM,CAAG,SAAA;IACV,UAAS;G,IAEG,QAAA,QAAZE,WAAuB,KAAA,QAAA,WAAA,CAAA,GAAA,KAAA,GAAA,KAAA,GAAA,CAAA,I"}
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","names":[],"sources":["../../../src/components/tabs/tabs.ts"],"sourcesContent":["import type { Component, InjectionKey, Ref } from 'vue'\nimport type { Size } from '../../utils/types'\n\nexport type TabsValue = string | number\nexport type TabsSize = Size\nexport type TabsActivation = 'auto' | 'manual'\n/** Where the tab list sits: above the panels, or beside them on the start or end side. */\nexport type TabsPlacement = 'top' | 'start' | 'end'\n\nexport interface TabsProps {\n /** The value of the selected panel, bound with `v-model`. Defaults to the first enabled panel. */\n modelValue?: TabsValue\n size?: TabsSize\n /**\n * `auto` selects a tab as soon as arrow keys move focus to it; `manual`\n * waits for `Enter` or `Space`, for panels that are slow to render.\n */\n activation?: TabsActivation\n placement?: TabsPlacement\n /**\n * A fixed height, numbers in px; `'100%'` fills the parent. The panels\n * fill it and scroll on their own, and so does a column of tabs that\n * does not fit. Left unset, the tabs grow with their content.\n */\n height?: number | string\n /**\n * Show each tab as its panel's `icon` alone. The label becomes the tab's\n * accessible name and shows in a tooltip on hover and focus.\n */\n iconOnly?: boolean\n /** Give every tab a close button that emits `remove`. A panel's own `closable` wins. */\n closable?: boolean\n /** Put a button after the tabs that emits `add`. */\n addable?: boolean\n /**\n * Called before another tab is selected. Return `false`, or a promise of\n * `false`, to stay on the current one, e.g. while a form has unsaved changes.\n */\n beforeLeave?: (next: TabsValue, current: TabsValue | undefined) => boolean | Promise<boolean>\n /**\n * Let the tabs be dragged to a new place, and take tabs dropped here.\n * `Alt` with the arrow keys moves the focused tab. The tabs only emit\n * `move`; put the panels in the new order yourself.\n */\n draggable?: boolean\n /** Tabs with the same group take each other's tabs. */\n group?: string\n /** Names these tabs in `move` events, to tell the tabs of a group apart. */\n name?: string\n}\n\n/** Where a tab is: the `name` of its tabs and its index there. */\nexport interface TabsLocation {\n name: string | undefined\n index: number\n}\n\nexport interface TabsMoveEvent {\n value: TabsValue\n from: TabsLocation\n /** Where the tab ends up, its index counted once the move is done. */\n to: TabsLocation\n}\n\nexport interface TabsEmits {\n 'update:modelValue': [value: TabsValue]\n /** The user picked another tab. */\n change: [value: TabsValue]\n /** The close button of a tab was pressed, or `Delete` on a closable tab. Remove its panel. */\n remove: [value: TabsValue]\n /** The add button was pressed. */\n add: []\n /**\n * A tab was dragged, or moved with `Alt` and an arrow key. Sent by the\n * tabs it lands in, also when it comes from other tabs of the group.\n */\n move: [event: TabsMoveEvent]\n}\n\nexport interface TabsSlots {\n /** The panels, `DouTabPanel`s. */\n default?: () => unknown\n /** Placed at the end of the tab list, e.g. an action button. */\n extra?: () => unknown\n}\n\nexport interface TabPanelProps {\n value: TabsValue\n /** The text of the tab. With `iconOnly`, its accessible name and tooltip. */\n label?: string\n /** An icon component, shown before the label, and alone with the tabs' `iconOnly`. */\n icon?: Component\n disabled?: boolean\n /** Show a close button on this tab, overriding the tabs' `closable`. */\n closable?: boolean\n /** Whether this tab can be dragged, overriding the tabs' `draggable`. */\n draggable?: boolean\n /**\n * Render the content before the panel is first shown, instead of on\n * first show. For content that must exist while hidden, e.g. form\n * fields that are checked on submit.\n */\n eager?: boolean\n}\n\nexport interface TabPanelSlots {\n default?: () => unknown\n /** Replaces the text of the tab, e.g. to add a count. Not shown with the tabs' `iconOnly`. */\n label?: (props: { selected: boolean }) => unknown\n}\n\nexport interface TabPanelEntry {\n uid: number\n props: TabPanelProps\n slots: TabPanelSlots\n el: Ref<HTMLElement | null>\n}\n\nexport interface TabsContext {\n selected: Readonly<Ref<TabsValue | undefined>>\n tabId: (value: TabsValue) => string\n panelId: (value: TabsValue) => string\n register: (entry: TabPanelEntry) => void\n unregister: (uid: number) => void\n reorder: () => void\n}\n\nexport const tabsKey: InjectionKey<TabsContext> = Symbol('DouTabs')\n"],"mappings":";AA+HA,IAAa,UAAqC,OAAO,SAAS"}
1
+ {"version":3,"file":"tabs.js","names":[],"sources":["../../../src/components/tabs/tabs.ts"],"sourcesContent":["import type { Component, InjectionKey, Ref } from 'vue'\nimport type { Size } from '../../utils/types'\n\nexport type TabsValue = string | number\nexport type TabsSize = Size\nexport type TabsActivation = 'auto' | 'manual'\n/** Where the tab list sits: above the panels, or beside them on the start or end side. */\nexport type TabsPlacement = 'top' | 'start' | 'end'\n\nexport interface TabsProps {\n /** The value of the selected panel, bound with `v-model`. Defaults to the first enabled panel. */\n modelValue?: TabsValue\n size?: TabsSize\n /**\n * `auto` selects a tab as soon as arrow keys move focus to it; `manual`\n * waits for `Enter` or `Space`, for panels that are slow to render.\n */\n activation?: TabsActivation\n placement?: TabsPlacement\n /**\n * A fixed height, numbers in px; `'100%'` fills the parent. The panels\n * fill it and scroll on their own, and so does a column of tabs that\n * does not fit. Left unset, the tabs grow with their content.\n */\n height?: number | string\n /**\n * Show each tab as its panel's `icon` alone. The label becomes the tab's\n * accessible name and shows in a tooltip on hover and focus.\n */\n iconOnly?: boolean\n /** Give every tab a close button that emits `remove`. A panel's own `closable` wins. */\n closable?: boolean\n /** Put a button after the tabs that emits `add`. */\n addable?: boolean\n /**\n * Called before another tab is selected. Return `false`, or a promise of\n * `false`, to stay on the current one, e.g. while a form has unsaved changes.\n */\n beforeLeave?: (next: TabsValue, current: TabsValue | undefined) => boolean | Promise<boolean>\n /**\n * Let the tabs be dragged to a new place, and take tabs dropped here.\n * `Alt` with the arrow keys moves the focused tab. The tabs only emit\n * `move`; put the panels in the new order yourself.\n */\n draggable?: boolean\n /** Tabs with the same group take each other's tabs. */\n group?: string\n /** Names these tabs in `move` events, to tell the tabs of a group apart. */\n name?: string\n}\n\n/** Where a tab is: the `name` of its tabs and its index there. */\nexport interface TabsLocation {\n name: string | undefined\n index: number\n}\n\nexport interface TabsMoveEvent {\n value: TabsValue\n from: TabsLocation\n /** Where the tab ends up, its index counted once the move is done. */\n to: TabsLocation\n}\n\nexport interface TabsEmits {\n 'update:modelValue': [value: TabsValue]\n /** The user picked another tab. */\n change: [value: TabsValue]\n /** The close button of a tab was pressed, or `Delete` on a closable tab. Remove its panel. */\n remove: [value: TabsValue]\n /** The add button was pressed. */\n add: []\n /**\n * A tab was dragged, or moved with `Alt` and an arrow key. Sent by the\n * tabs it lands in, also when it comes from other tabs of the group.\n */\n move: [event: TabsMoveEvent]\n}\n\nexport interface TabsSlots {\n /** The panels, `DouTabPanel`s. */\n default?: () => unknown\n /** Placed at the end of the tab list, e.g. an action button. */\n extra?: () => unknown\n}\n\nexport interface TabPanelProps {\n value: TabsValue\n /** The text of the tab. With `iconOnly`, its accessible name and tooltip. */\n label?: string\n /** An icon component, shown before the label, and alone with the tabs' `iconOnly`. */\n icon?: Component\n disabled?: boolean\n /** Show a close button on this tab, overriding the tabs' `closable`. */\n closable?: boolean\n /** Whether this tab can be dragged, overriding the tabs' `draggable`. */\n draggable?: boolean\n /**\n * Pin this tab to the start of the tab bar so it stays visible while other\n * tabs scroll. A pinned tab with an `icon` shows the icon alone with a\n * tooltip, and is not closable unless `closable: true` is set on the panel.\n */\n pinned?: boolean\n /**\n * Render the content before the panel is first shown, instead of on\n * first show. For content that must exist while hidden, e.g. form\n * fields that are checked on submit.\n */\n eager?: boolean\n}\n\nexport interface TabPanelSlots {\n default?: () => unknown\n /** Replaces the text of the tab, e.g. to add a count. Not shown with the tabs' `iconOnly`. */\n label?: (props: { selected: boolean }) => unknown\n}\n\nexport interface TabPanelEntry {\n uid: number\n props: TabPanelProps\n slots: TabPanelSlots\n el: Ref<HTMLElement | null>\n}\n\nexport interface TabsContext {\n selected: Readonly<Ref<TabsValue | undefined>>\n tabId: (value: TabsValue) => string\n panelId: (value: TabsValue) => string\n register: (entry: TabPanelEntry) => void\n unregister: (uid: number) => void\n reorder: () => void\n}\n\nexport const tabsKey: InjectionKey<TabsContext> = Symbol('DouTabs')\n"],"mappings":";AAqIA,IAAa,UAAqC,OAAO,SAAS"}