dou-ui 0.1.0-alpha.24 → 0.1.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/code-block/code-block.js.map +1 -1
- package/dist/components/code-block/code-block.vue_vue_type_script_setup_true_lang.js +61 -27
- package/dist/components/code-block/code-block.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/dock/context.js.map +1 -1
- package/dist/components/dock/dock-group.js.map +1 -1
- package/dist/components/dock/dock-group.vue_vue_type_script_setup_true_lang.js +15 -4
- package/dist/components/dock/dock-group.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/dock/dock.js.map +1 -1
- package/dist/components/dock/dock.vue_vue_type_script_setup_true_lang.js +72 -21
- package/dist/components/dock/dock.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/dock/index.js +2 -2
- package/dist/components/dock/index.js.map +1 -1
- package/dist/components/dock/layout.js +12 -1
- package/dist/components/dock/layout.js.map +1 -1
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/popover/popover.vue_vue_type_script_setup_true_lang.js +29 -5
- package/dist/components/popover/popover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tabs/tab-button.js.map +1 -1
- package/dist/components/tabs/tab-button.vue_vue_type_script_setup_true_lang.js +27 -5
- package/dist/components/tabs/tab-button.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tabs/tab-drag.js +12 -4
- package/dist/components/tabs/tab-drag.js.map +1 -1
- package/dist/components/tabs/tabs.vue_vue_type_script_setup_true_lang.js +70 -10
- package/dist/components/tabs/tabs.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tabs/tabs2.js.map +1 -1
- package/dist/components/tabs/truncated-title.js +28 -0
- package/dist/components/tabs/truncated-title.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/types/components/code-block/code-block.d.ts +9 -2
- package/dist/types/components/dock/context.d.ts +2 -0
- package/dist/types/components/dock/dock.d.ts +40 -0
- package/dist/types/components/dock/index.d.ts +1 -1
- package/dist/types/components/dock/layout.d.ts +6 -0
- package/dist/types/components/popover/popover.d.ts +1 -1
- package/dist/types/components/tabs/tab-button.vue.d.ts +1 -0
- package/dist/types/components/tabs/tab-drag.d.ts +10 -0
- package/dist/types/components/tabs/truncated-title.d.ts +7 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dock.vue_vue_type_script_setup_true_lang.js","names":["$slots","_useModel","_useSlots","_openBlock","_createElementBlock","_normalizeClass","_unref","_createVNode","DockNodeView","_Fragment","_renderList","_createBlock","_Teleport","DockGroupView"],"sources":["../../../src/components/dock/dock.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n nextTick,\n provide,\n shallowReactive,\n useId,\n useTemplateRef,\n watch,\n watchEffect,\n} from 'vue'\nimport { useResizeObserver } from '../../composables/use-element-size'\nimport { useNamespace } from '../../utils/namespace'\nimport { devWarn } from '../../utils/status-check'\nimport { dockKey } from './context'\nimport { roomForSplit } from './drop-side'\nimport DockGroupView from './dock-group.vue'\nimport DockNodeView from './dock-node.vue'\nimport {\n dockGroups,\n findDockGroup,\n moveDockTab,\n nextDockGroupId,\n replaceDockNode,\n selectDockTab,\n splitDockTab,\n} from './layout'\nimport { isIgnoredDragPress, pressTab } from '../tabs/tab-drag'\nimport type { SplitterLimit } from '../splitter/splitter'\nimport type { TabDrag } from '../tabs/tab-drag'\nimport type { TabsMoveEvent, TabsValue } from '../tabs/tabs'\nimport type { DockDropItem, DockEmits, DockExpose, DockPanel, DockProps, DockSlots } from './dock'\nimport type { DockGroup, DockNode, DockSide } from './layout'\n\ndefineOptions({ name: 'DouDock' })\n\nconst DEFAULT_MIN = '120px'\n\nconst props = withDefaults(defineProps<DockProps>(), {\n panels: () => [],\n closable: false,\n addable: false,\n draggable: true,\n min: DEFAULT_MIN,\n})\nconst emit = defineEmits<Omit<DockEmits, 'update:activeGroup'>>()\nconst activeGroup = defineModel<string>('activeGroup')\nconst slots = defineSlots<DockSlots>()\n\nconst ns = useNamespace('dock')\nconst group = `dou-dock-${useId()}`\n\n// Changes made in one go (a drop moves a tab and selects it) build on\n// each other before the new layout comes back through the prop.\nlet latest = props.modelValue\nwatch(\n () => props.modelValue,\n (value) => (latest = value),\n)\nfunction commit(next: DockNode) {\n if (next === latest) return\n latest = next\n emit('update:modelValue', next)\n // a parent that turned the change down keeps its layout: build on that from now on\n void nextTick(() => (latest = props.modelValue))\n}\n\nconst panels = computed(() => new Map(props.panels.map((entry) => [entry.value, entry])))\nfunction panel(value: TabsValue): DockPanel | undefined {\n const found = panels.value.get(value)\n if (!found && process.env.NODE_ENV !== 'production')\n devWarn(\n `[dou-ui] DouDock: the tab \"${value}\" has no entry in \\`panels\\`; it is named by its value.`,\n )\n return found\n}\n\n/** Where a tab is now. */\nfunction locate(value: TabsValue) {\n const found = findDockGroup(latest, value)\n return found && { group: found.id, index: found.tabs.indexOf(value) }\n}\n\nfunction move(event: TabsMoveEvent) {\n const from = locate(event.value) ?? null\n const to = event.to.name\n if (to === undefined) return\n const index = event.to.index\n commit(moveDockTab(latest, event.value, to, index))\n emit('move', { value: event.value, from, to: { group: to, index } })\n use(to)\n}\n\nfunction canDrop(drag: TabDrag, target: DockGroup, side: DockSide | 'center') {\n const from = findDockGroup(latest, drag.value)\n // not in the layout yet: it opens anywhere\n if (!from) return true\n // the middle of its own group, or an edge of a group it is alone in, leaves it where it is\n if (from.id === target.id) return side !== 'center' && target.tabs.length > 1\n return true\n}\n\nfunction pinnedInsertIndex(target: DockGroup) {\n let index = 0\n for (let i = 0; i < target.tabs.length; i++) {\n if (panels.value.get(target.tabs[i]!)?.pinned) index = i + 1\n }\n return index\n}\n\nfunction drop(drag: TabDrag, target: DockGroup, side: DockSide | 'center') {\n const from = locate(drag.value) ?? null\n if (!canDrop(drag, target, side)) return\n if (side === 'center') {\n const index = drag.pinned ? pinnedInsertIndex(target) : target.tabs.length\n commit(moveDockTab(latest, drag.value, target.id, index))\n emit('move', { value: drag.value, from, to: { group: target.id, index } })\n use(target.id)\n return\n }\n const id = props.createId?.(latest) ?? nextDockGroupId(latest)\n commit(splitDockTab(latest, drag.value, target.id, side, id))\n emit('split', { value: drag.value, from, target: target.id, side, group: id })\n use(id)\n}\n\n/* the group last used */\n\nfunction use(id: string | undefined) {\n // also unbound, it emits only a change\n if (id !== activeGroup.value) activeGroup.value = id\n}\n// a group dragged empty or closed, or one never in the layout, is not the one to open things in\nwatch(\n () =>\n activeGroup.value !== undefined && !findGroup(props.modelValue, activeGroup.value)\n ? activeGroup.value\n : undefined,\n (stale) => stale !== undefined && use(undefined),\n { immediate: true },\n)\n\n// Each group is rendered here, in one flat list, and teleported into its\n// place in the layout: splitting or merging the parts around a group moves\n// it, and its content (state, scroll position) stays as it is.\nconst groups = computed(() => dockGroups(props.modelValue))\nfunction findGroup(layout: DockNode, id: string) {\n return dockGroups(layout).some((item) => item.id === id)\n}\nconst cells = shallowReactive(new Map<string, HTMLElement>())\nfunction setCell(id: string, el: unknown) {\n if (el instanceof HTMLElement) {\n if (cells.get(id) !== el) cells.set(id, el)\n } else if (cells.has(id) && !cells.get(id)!.isConnected) {\n cells.delete(id)\n sizes.delete(id)\n }\n}\n\n// Moving a group in the page resets what scrolled inside it: note the\n// offsets before a change of shape moves groups, and put them back after.\nconst shape = (node: DockNode): string =>\n node.type === 'group' ? node.id : `${node.direction[0]}(${shape(node.start)},${shape(node.end)})`\nlet scrolled: [Element, number, number][] = []\nwatch(\n () => shape(props.modelValue),\n () => {\n scrolled = []\n for (const cell of cells.values())\n for (const el of cell.querySelectorAll('*'))\n if (el.scrollTop || el.scrollLeft) scrolled.push([el, el.scrollTop, el.scrollLeft])\n },\n { flush: 'pre' },\n)\nwatch(\n () => shape(props.modelValue),\n () => {\n const notes = scrolled\n scrolled = []\n const restore = () => {\n for (const [el, top, left] of notes) {\n el.scrollTop = top\n el.scrollLeft = left\n }\n }\n restore()\n // a group whose place appears in this update moves in on the next one\n void nextTick(restore)\n },\n { flush: 'post' },\n)\n\n/* dragging something from outside the dock in */\n\nconst root = useTemplateRef<HTMLElement>('root')\nconst RAPID_REPEAT_MS = 400\nconst RAPID_REPEAT_PX = 8\nlet lastDropPress: { time: number; x: number; y: number } | null = null\n\nfunction isRapidRepeat(event: PointerEvent) {\n const now = Date.now()\n const x = event.clientX\n const y = event.clientY\n const repeated =\n event.detail > 1 ||\n (lastDropPress !== null &&\n now - lastDropPress.time <= RAPID_REPEAT_MS &&\n Math.hypot(x - lastDropPress.x, y - lastDropPress.y) <= RAPID_REPEAT_PX)\n lastDropPress = { time: now, x, y }\n return repeated\n}\n\nfunction startDrop(event: PointerEvent, item: DockDropItem) {\n if (isIgnoredDragPress(event)) return\n // `currentTarget` is gone once the handler returns, after an `await`: then the element pressed\n const target = event.currentTarget ?? event.target\n if (!(target instanceof HTMLElement || target instanceof SVGElement)) {\n if (process.env.NODE_ENV !== 'production')\n devWarn(\n '[dou-ui] DouDock: `startDrop` needs the `pointerdown` event of an element, to know what was pressed.',\n )\n return\n }\n const entry = panels.value.get(item.value)\n if (!props.draggable || entry?.disabled || entry?.draggable === false) {\n if (process.env.NODE_ENV !== 'production' && props.draggable)\n devWarn(\n `[dou-ui] DouDock: \\`startDrop\\` for \"${item.value}\" does nothing, as its panel is ${entry?.disabled ? 'disabled' : 'not draggable'}.`,\n )\n return\n }\n if (isRapidRepeat(event)) return\n const label = item.label ?? entry?.label ?? String(item.value)\n // the browser's own drag of a link or an image would take the pointer away\n target.addEventListener('dragstart', noNativeDrag)\n const release = () => {\n target.removeEventListener('dragstart', noNativeDrag)\n window.removeEventListener('pointerup', release, true)\n window.removeEventListener('pointercancel', release, true)\n }\n window.addEventListener('pointerup', release, true)\n window.addEventListener('pointercancel', release, true)\n let dragged = false\n pressTab(event, {\n el: target as HTMLElement,\n root: target as HTMLElement,\n ghost: { label, tabs: root.value?.querySelector<HTMLElement>('.dou-tabs') },\n drag: () => {\n // open already: a drag of it from its group, so dropping it back in its place does nothing\n const from = locate(item.value)\n return {\n value: item.value,\n label,\n group,\n name: from?.group,\n index: from?.index ?? -1,\n source: target,\n pinned: !!entry?.pinned,\n }\n },\n onStart: () => {\n dragged = true\n lastDropPress = null\n },\n onEnd() {\n if (!dragged) return\n // the release that ends a drag is not a click on the element\n window.addEventListener('click', swallow, { capture: true, once: true })\n setTimeout(() => window.removeEventListener('click', swallow, { capture: true }), 0)\n },\n })\n}\nconst noNativeDrag = (e: Event) => e.preventDefault()\nconst swallow = (click: Event) => {\n click.stopPropagation()\n click.preventDefault()\n}\n\nfunction minFor(direction: 'horizontal' | 'vertical'): SplitterLimit {\n const min = props.min\n if (typeof min !== 'object') return min\n return (direction === 'horizontal' ? min.width : min.height) ?? DEFAULT_MIN\n}\n\nif (process.env.NODE_ENV !== 'production')\n watchEffect(() => {\n for (const direction of ['horizontal', 'vertical'] as const) {\n const min = minFor(direction)\n if (typeof min === 'number' && min > 50)\n devWarn(\n `[dou-ui] DouDock: \\`min\\` of ${min} is a percent, so no group can be split ${direction === 'horizontal' ? 'side by side' : 'top to bottom'}. Write '${min}px' for px.`,\n )\n }\n })\n\n// the size of each group's place, kept up to date so `canSplit` can be read in a render\nconst sizes = shallowReactive(new Map<string, { width: number; height: number }>())\nuseResizeObserver(\n () => [...cells.values()],\n (entries) => {\n for (const entry of entries)\n for (const [id, el] of cells)\n if (el === entry.target) {\n const box = entry.borderBoxSize?.[0]\n sizes.set(id, {\n width: box ? box.inlineSize : entry.contentRect.width,\n height: box ? box.blockSize : entry.contentRect.height,\n })\n }\n },\n { box: 'border-box' },\n)\n\n/**\n * Whether a group has room to split a tab off to `side`: two parts of\n * `min` beside the divider, as dragging to its edge checks. Reactive.\n */\nfunction canSplit(groupId: string, side: DockSide) {\n const el = cells.get(groupId)\n if (!el) return false\n const across = side === 'left' || side === 'right'\n const size = sizes.get(groupId) ?? el.getBoundingClientRect()\n return roomForSplit(across ? size.width : size.height, minFor(across ? 'horizontal' : 'vertical'))\n}\ndefineExpose<DockExpose>({ canSplit, startDrop })\n\nprovide(dockKey, {\n group,\n size: () => props.size,\n closable: () => props.closable,\n addable: () => props.addable,\n min: minFor,\n draggable: () => props.draggable,\n panel,\n slots,\n resize: (node, size) => commit(replaceDockNode(latest, node, { ...node, size })),\n select(target, value) {\n if (findDockGroup(latest, value)?.id === target.id) commit(selectDockTab(latest, value))\n },\n move,\n canDrop,\n drop,\n remove: (value, target) => emit('remove', value, target.id),\n add: (target) => emit('add', target.id),\n use,\n setCell,\n})\n</script>\n\n<template>\n <div ref=\"root\" :class=\"ns.b()\">\n <DockNodeView :node=\"modelValue\" />\n <!-- until its place exists (and on the server) a group renders right here -->\n <Teleport\n v-for=\"item in groups\"\n :key=\"item.id\"\n :to=\"cells.get(item.id) ?? 'body'\"\n :disabled=\"!cells.get(item.id)\"\n >\n <DockGroupView\n :group=\"item\"\n :slotted=\"{ label: !!$slots.label, extra: !!$slots.extra, empty: !!$slots.empty }\"\n />\n </Teleport>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;AAoCA,IAAM,cAAc;AA+JpB,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA9JxB,MAAM,QAAQ;EAOd,MAAM,OAAO;EACb,MAAM,cAAcC,SAAmB,SAAC,aAAa;EACrD,MAAM,QAAQC,SAAA;EAEd,MAAM,KAAK,aAAa,MAAM;EAC9B,MAAM,QAAQ,YAAY,MAAM;EAIhC,IAAI,SAAS,MAAM;EACnB,YACQ,MAAM,aACX,UAAW,SAAS,KACvB;EACA,SAAS,OAAO,MAAgB;GAC9B,IAAI,SAAS,QAAQ;GACrB,SAAS;GACT,KAAK,qBAAqB,IAAI;GAE9B,eAAqB,SAAS,MAAM,UAAW;EACjD;EAEA,MAAM,SAAS,eAAe,IAAI,IAAI,MAAM,OAAO,KAAK,UAAU,CAAC,MAAM,OAAO,K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AS,OAAO,gBAAgB,QAAQ,MAAM;IAAE,GAAG;IAAM;GAAK,CAAC,CAAC;GAC/E,OAAO,QAAQ,OAAO;IACpB,IAAI,cAAc,QAAQ,KAAK,CAAC,EAAE,OAAO,OAAO,IAAI,OAAO,cAAc,QAAQ,KAAK,CAAC;GACzF;GACA;GACA;GACA;GACA,SAAS,OAAO,WAAW,KAAK,UAAU,OAAO,OAAO,EAAE;GAC1D,MAAM,WAAW,KAAK,OAAO,OAAO,EAAE;GACtC;GACA;EACF,CAAC;;GAIC,OAAAC,UAAA,GAAAC,mBAcM,OAAA;IAdG,SAAA;IAAJ,KAAI;IAAQ,OAAKC,eAAEC,MAAA,EAAA,CAAE,CAAC,EAAC,CAAA;G,IAC1BC,YAAmCC,mBAAA,EAApB,MAAM,QAAA,WAAU,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,IAE/BL,UAAA,IAAA,GAAAC,mBAUWK,UAAA,MAAAC,WATM,OAAA,QAAR,SAAI;IADb,OAAAP,UAAA,GAAAQ,YAUWC,UAAA;KARR,KAAK,KAAK;KACV,IAAIN,MAAA,KAAA,CAAK,CAAC,IAAI,KAAK,EAAE,KAAA;KACrB,UAAQ,CAAGA,MAAA,KAAA,CAAK,CAAC,IAAI,KAAK,EAAE;I,IAE7BC,YAGEM,oBAAA;KAFC,OAAO;KACP,SAAO;MAAA,OAAA,CAAA,CAAab,KAAAA,OAAO;MAAK,OAAA,CAAA,CAAWA,KAAAA,OAAO;MAAK,OAAA,CAAA,CAAWA,KAAAA,OAAO;KAAK"}
|
|
1
|
+
{"version":3,"file":"dock.vue_vue_type_script_setup_true_lang.js","names":["$slots","_useModel","_useSlots","_openBlock","_createElementBlock","_normalizeClass","_unref","_createVNode","DockNodeView","_Fragment","_renderList","_createBlock","_Teleport","DockGroupView"],"sources":["../../../src/components/dock/dock.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n nextTick,\n provide,\n shallowReactive,\n useId,\n useTemplateRef,\n watch,\n watchEffect,\n} from 'vue'\nimport { useResizeObserver } from '../../composables/use-element-size'\nimport { useNamespace } from '../../utils/namespace'\nimport { devWarn } from '../../utils/status-check'\nimport { dockKey } from './context'\nimport { roomForSplit } from './drop-side'\nimport DockGroupView from './dock-group.vue'\nimport DockNodeView from './dock-node.vue'\nimport {\n dockGroups,\n findDockGroup,\n mergeDockTab,\n moveDockTab,\n nextDockGroupId,\n replaceDockNode,\n selectDockTab,\n splitDockTab,\n} from './layout'\nimport { isIgnoredDragPress, pressTab } from '../tabs/tab-drag'\nimport type { SplitterLimit } from '../splitter/splitter'\nimport type { TabDrag } from '../tabs/tab-drag'\nimport type { TabsMoveEvent, TabsValue } from '../tabs/tabs'\nimport type {\n DockDropItem,\n DockEmits,\n DockExpose,\n DockLocation,\n DockPanel,\n DockProps,\n DockSlots,\n} from './dock'\nimport type { DockGroup, DockNode, DockSide } from './layout'\n\ndefineOptions({ name: 'DouDock' })\n\nconst DEFAULT_MIN = '120px'\n\nconst props = withDefaults(defineProps<DockProps>(), {\n panels: () => [],\n closable: false,\n addable: false,\n draggable: true,\n min: DEFAULT_MIN,\n})\nconst emit = defineEmits<Omit<DockEmits, 'update:activeGroup'>>()\nconst activeGroup = defineModel<string>('activeGroup')\nconst slots = defineSlots<DockSlots>()\n\nconst ns = useNamespace('dock')\nconst group = `dou-dock-${useId()}`\n\n// Changes made in one go (a drop moves a tab and selects it) build on\n// each other before the new layout comes back through the prop.\nlet latest = props.modelValue\nwatch(\n () => props.modelValue,\n (value) => (latest = value),\n)\nfunction commit(next: DockNode) {\n if (next === latest) return\n latest = next\n emit('update:modelValue', next)\n // a parent that turned the change down keeps its layout: build on that from now on\n void nextTick(() => (latest = props.modelValue))\n}\n\nconst panels = computed(() => new Map(props.panels.map((entry) => [entry.value, entry])))\nfunction panel(value: TabsValue): DockPanel | undefined {\n const found = panels.value.get(value)\n if (!found && process.env.NODE_ENV !== 'production')\n devWarn(\n `[dou-ui] DouDock: the tab \"${value}\" has no entry in \\`panels\\`; it is named by its value.`,\n )\n return found\n}\n\n/** Where a tab is now. */\nfunction locate(value: TabsValue) {\n const found = findDockGroup(latest, value)\n return found && { group: found.id, index: found.tabs.indexOf(value) }\n}\n\n/**\n * Find an existing tab in `target` that shares `value`'s `mergeId` when `value`\n * comes from another group or from outside the dock. Prefers a pinned tab.\n */\nfunction findMergeTarget(target: DockGroup, value: TabsValue): TabsValue | undefined {\n const source = panels.value.get(value)\n if (source?.mergeId === undefined) return undefined\n const from = findDockGroup(latest, value)\n if (from?.id === target.id) return undefined\n let fallback: TabsValue | undefined\n for (const tab of target.tabs) {\n if (tab === value) continue\n const entry = panels.value.get(tab)\n if (entry?.mergeId !== source.mergeId || entry.disabled) continue\n if (entry.pinned) return tab\n if (fallback === undefined) fallback = tab\n }\n return fallback\n}\n\nfunction performMove(\n value: TabsValue,\n from: DockLocation | null,\n targetGroup: DockGroup,\n index: number,\n) {\n const autoMerge = findMergeTarget(targetGroup, value)\n let resolvedMerge = autoMerge\n if (props.beforeMove) {\n const decision = props.beforeMove({\n value,\n from,\n to: { group: targetGroup.id, index },\n targetGroup,\n mergeInto: autoMerge,\n })\n if (decision === false) return\n if (typeof decision === 'object' && decision !== null && 'mergeInto' in decision) {\n resolvedMerge = decision.mergeInto ?? undefined\n }\n }\n if (resolvedMerge !== undefined) {\n if (!targetGroup.tabs.includes(resolvedMerge)) {\n if (process.env.NODE_ENV !== 'production')\n devWarn(\n `[dou-ui] DouDock: \\`beforeMove\\` returned \\`mergeInto: \"${resolvedMerge}\"\\`, which is not in group \"${targetGroup.id}\". The move was cancelled.`,\n )\n return\n }\n const next = mergeDockTab(latest, value, resolvedMerge)\n const mergedIndex = findDockGroup(next, resolvedMerge)?.tabs.indexOf(resolvedMerge) ?? 0\n commit(next)\n emit('move', {\n value,\n from,\n to: { group: targetGroup.id, index: mergedIndex },\n mergedInto: resolvedMerge,\n })\n use(targetGroup.id)\n return\n }\n commit(moveDockTab(latest, value, targetGroup.id, index))\n emit('move', { value, from, to: { group: targetGroup.id, index } })\n use(targetGroup.id)\n}\n\nfunction move(event: TabsMoveEvent) {\n const from = locate(event.value) ?? null\n const to = event.to.name\n if (to === undefined) return\n const targetGroup = dockGroups(latest).find((item) => item.id === to)\n if (!targetGroup) return\n performMove(event.value, from, targetGroup, event.to.index)\n}\n\nfunction canDrop(drag: TabDrag, target: DockGroup, side: DockSide | 'center') {\n const from = findDockGroup(latest, drag.value)\n // not in the layout yet: it opens anywhere\n if (!from) return true\n // the middle of its own group, or an edge of a group it is alone in, leaves it where it is\n if (from.id === target.id) return side !== 'center' && target.tabs.length > 1\n return true\n}\n\nfunction pinnedInsertIndex(target: DockGroup) {\n let index = 0\n for (let i = 0; i < target.tabs.length; i++) {\n if (panels.value.get(target.tabs[i]!)?.pinned) index = i + 1\n }\n return index\n}\n\nfunction drop(drag: TabDrag, target: DockGroup, side: DockSide | 'center') {\n const from = locate(drag.value) ?? null\n if (!canDrop(drag, target, side)) return\n if (side === 'center') {\n const index = drag.pinned ? pinnedInsertIndex(target) : target.tabs.length\n performMove(drag.value, from, target, index)\n return\n }\n const id = props.createId?.(latest) ?? nextDockGroupId(latest)\n commit(splitDockTab(latest, drag.value, target.id, side, id))\n emit('split', { value: drag.value, from, target: target.id, side, group: id })\n use(id)\n}\n\n/* the group last used */\n\nfunction use(id: string | undefined) {\n // also unbound, it emits only a change\n if (id !== activeGroup.value) activeGroup.value = id\n}\n// a group dragged empty or closed, or one never in the layout, is not the one to open things in\nwatch(\n () =>\n activeGroup.value !== undefined && !findGroup(props.modelValue, activeGroup.value)\n ? activeGroup.value\n : undefined,\n (stale) => stale !== undefined && use(undefined),\n { immediate: true },\n)\n\n// Each group is rendered here, in one flat list, and teleported into its\n// place in the layout: splitting or merging the parts around a group moves\n// it, and its content (state, scroll position) stays as it is.\nconst groups = computed(() => dockGroups(props.modelValue))\nfunction findGroup(layout: DockNode, id: string) {\n return dockGroups(layout).some((item) => item.id === id)\n}\nconst cells = shallowReactive(new Map<string, HTMLElement>())\nfunction setCell(id: string, el: unknown) {\n if (el instanceof HTMLElement) {\n if (cells.get(id) !== el) cells.set(id, el)\n } else if (cells.has(id) && !cells.get(id)!.isConnected) {\n cells.delete(id)\n sizes.delete(id)\n }\n}\n\n// Moving a group in the page resets what scrolled inside it: note the\n// offsets before a change of shape moves groups, and put them back after.\nconst shape = (node: DockNode): string =>\n node.type === 'group' ? node.id : `${node.direction[0]}(${shape(node.start)},${shape(node.end)})`\nlet scrolled: [Element, number, number][] = []\nwatch(\n () => shape(props.modelValue),\n () => {\n scrolled = []\n for (const cell of cells.values())\n for (const el of cell.querySelectorAll('*'))\n if (el.scrollTop || el.scrollLeft) scrolled.push([el, el.scrollTop, el.scrollLeft])\n },\n { flush: 'pre' },\n)\nwatch(\n () => shape(props.modelValue),\n () => {\n const notes = scrolled\n scrolled = []\n const restore = () => {\n for (const [el, top, left] of notes) {\n el.scrollTop = top\n el.scrollLeft = left\n }\n }\n restore()\n // a group whose place appears in this update moves in on the next one\n void nextTick(restore)\n },\n { flush: 'post' },\n)\n\n/* dragging something from outside the dock in */\n\nconst root = useTemplateRef<HTMLElement>('root')\nconst RAPID_REPEAT_MS = 400\nconst RAPID_REPEAT_PX = 8\nlet lastDropPress: { time: number; x: number; y: number } | null = null\n\nfunction isRapidRepeat(event: PointerEvent) {\n const now = Date.now()\n const x = event.clientX\n const y = event.clientY\n const repeated =\n event.detail > 1 ||\n (lastDropPress !== null &&\n now - lastDropPress.time <= RAPID_REPEAT_MS &&\n Math.hypot(x - lastDropPress.x, y - lastDropPress.y) <= RAPID_REPEAT_PX)\n lastDropPress = { time: now, x, y }\n return repeated\n}\n\nfunction startDrop(event: PointerEvent, item: DockDropItem) {\n if (isIgnoredDragPress(event)) return\n // `currentTarget` is gone once the handler returns, after an `await`: then the element pressed\n const target = event.currentTarget ?? event.target\n if (!(target instanceof HTMLElement || target instanceof SVGElement)) {\n if (process.env.NODE_ENV !== 'production')\n devWarn(\n '[dou-ui] DouDock: `startDrop` needs the `pointerdown` event of an element, to know what was pressed.',\n )\n return\n }\n const entry = panels.value.get(item.value)\n if (!props.draggable || entry?.disabled || entry?.draggable === false) {\n if (process.env.NODE_ENV !== 'production' && props.draggable)\n devWarn(\n `[dou-ui] DouDock: \\`startDrop\\` for \"${item.value}\" does nothing, as its panel is ${entry?.disabled ? 'disabled' : 'not draggable'}.`,\n )\n return\n }\n if (isRapidRepeat(event)) return\n const label = item.label ?? entry?.label ?? String(item.value)\n // the browser's own drag of a link or an image would take the pointer away\n target.addEventListener('dragstart', noNativeDrag)\n const release = () => {\n target.removeEventListener('dragstart', noNativeDrag)\n window.removeEventListener('pointerup', release, true)\n window.removeEventListener('pointercancel', release, true)\n }\n window.addEventListener('pointerup', release, true)\n window.addEventListener('pointercancel', release, true)\n let dragged = false\n pressTab(event, {\n el: target as HTMLElement,\n root: target as HTMLElement,\n ghost: { label, tabs: root.value?.querySelector<HTMLElement>('.dou-tabs') },\n drag: () => {\n // open already: a drag of it from its group, so dropping it back in its place does nothing\n const from = locate(item.value)\n return {\n value: item.value,\n label,\n group,\n name: from?.group,\n index: from?.index ?? -1,\n source: target,\n pinned: !!entry?.pinned,\n }\n },\n onStart: () => {\n dragged = true\n lastDropPress = null\n },\n onEnd() {\n if (!dragged) return\n // the release that ends a drag is not a click on the element\n window.addEventListener('click', swallow, { capture: true, once: true })\n setTimeout(() => window.removeEventListener('click', swallow, { capture: true }), 0)\n },\n })\n}\nconst noNativeDrag = (e: Event) => e.preventDefault()\nconst swallow = (click: Event) => {\n click.stopPropagation()\n click.preventDefault()\n}\n\nfunction minFor(direction: 'horizontal' | 'vertical'): SplitterLimit {\n const min = props.min\n if (typeof min !== 'object') return min\n return (direction === 'horizontal' ? min.width : min.height) ?? DEFAULT_MIN\n}\n\nif (process.env.NODE_ENV !== 'production')\n watchEffect(() => {\n for (const direction of ['horizontal', 'vertical'] as const) {\n const min = minFor(direction)\n if (typeof min === 'number' && min > 50)\n devWarn(\n `[dou-ui] DouDock: \\`min\\` of ${min} is a percent, so no group can be split ${direction === 'horizontal' ? 'side by side' : 'top to bottom'}. Write '${min}px' for px.`,\n )\n }\n })\n\n// the size of each group's place, kept up to date so `canSplit` can be read in a render\nconst sizes = shallowReactive(new Map<string, { width: number; height: number }>())\nuseResizeObserver(\n () => [...cells.values()],\n (entries) => {\n for (const entry of entries)\n for (const [id, el] of cells)\n if (el === entry.target) {\n const box = entry.borderBoxSize?.[0]\n sizes.set(id, {\n width: box ? box.inlineSize : entry.contentRect.width,\n height: box ? box.blockSize : entry.contentRect.height,\n })\n }\n },\n { box: 'border-box' },\n)\n\n/**\n * Whether a group has room to split a tab off to `side`: two parts of\n * `min` beside the divider, as dragging to its edge checks. Reactive.\n */\nfunction canSplit(groupId: string, side: DockSide) {\n const el = cells.get(groupId)\n if (!el) return false\n const across = side === 'left' || side === 'right'\n const size = sizes.get(groupId) ?? el.getBoundingClientRect()\n return roomForSplit(across ? size.width : size.height, minFor(across ? 'horizontal' : 'vertical'))\n}\ndefineExpose<DockExpose>({ canSplit, startDrop })\n\nprovide(dockKey, {\n group,\n size: () => props.size,\n closable: () => props.closable,\n addable: () => props.addable,\n min: minFor,\n draggable: () => props.draggable,\n panel,\n slots,\n resize: (node, size) => commit(replaceDockNode(latest, node, { ...node, size })),\n select(target, value) {\n if (findDockGroup(latest, value)?.id === target.id) commit(selectDockTab(latest, value))\n },\n move,\n mergeTarget: (drag, target) => findMergeTarget(target, drag.value),\n canDrop,\n drop,\n remove: (value, target) => emit('remove', value, target.id),\n add: (target) => emit('add', target.id),\n use,\n setCell,\n})\n</script>\n\n<template>\n <div ref=\"root\" :class=\"ns.b()\">\n <DockNodeView :node=\"modelValue\" />\n <!-- until its place exists (and on the server) a group renders right here -->\n <Teleport\n v-for=\"item in groups\"\n :key=\"item.id\"\n :to=\"cells.get(item.id) ?? 'body'\"\n :disabled=\"!cells.get(item.id)\"\n >\n <DockGroupView\n :group=\"item\"\n :slotted=\"{ label: !!$slots.label, extra: !!$slots.extra, empty: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MAAAC,WATM,OAAA,QAAR,SAAI;IADb,OAAAP,UAAA,GAAAQ,YAUWC,UAAA;KARR,KAAK,KAAK;KACV,IAAIN,MAAA,KAAA,CAAK,CAAC,IAAI,KAAK,EAAE,KAAA;KACrB,UAAQ,CAAGA,MAAA,KAAA,CAAK,CAAC,IAAI,KAAK,EAAE;I,IAE7BC,YAGEM,oBAAA;KAFC,OAAO;KACP,SAAO;MAAA,OAAA,CAAA,CAAab,KAAAA,OAAO;MAAK,OAAA,CAAA,CAAWA,KAAAA,OAAO;MAAK,OAAA,CAAA,CAAWA,KAAAA,OAAO;KAAK"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { withInstall } from "../../utils/install.js";
|
|
2
|
-
import { dockGroups, findDockGroup, moveDockTab, nextDockGroupId, removeDockTab, selectDockTab, splitDockTab } from "./layout.js";
|
|
2
|
+
import { dockGroups, findDockGroup, mergeDockTab, moveDockTab, nextDockGroupId, removeDockTab, selectDockTab, splitDockTab } from "./layout.js";
|
|
3
3
|
import dock_default from "./dock.js";
|
|
4
4
|
// src/components/dock/index.ts
|
|
5
5
|
var DouDock = withInstall(dock_default);
|
|
6
|
-
export { DouDock, DouDock as default, dockGroups, findDockGroup, moveDockTab, nextDockGroupId, removeDockTab, selectDockTab, splitDockTab };
|
|
6
|
+
export { DouDock, DouDock as default, dockGroups, findDockGroup, mergeDockTab, moveDockTab, nextDockGroupId, removeDockTab, selectDockTab, splitDockTab };
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Dock"],"sources":["../../../src/components/dock/index.ts"],"sourcesContent":["import { withInstall } from '../../utils/install'\nimport Dock from './dock.vue'\n\nexport const DouDock = withInstall(Dock)\nexport default DouDock\n\nexport type * from './dock'\nexport {\n dockGroups,\n findDockGroup,\n moveDockTab,\n nextDockGroupId,\n removeDockTab,\n selectDockTab,\n splitDockTab,\n} from './layout'\nexport type DockInstance = InstanceType<typeof Dock>\n\ndeclare module 'vue' {\n export interface GlobalComponents {\n DouDock: typeof DouDock\n }\n}\n"],"mappings":";;;;AAGA,IAAa,UAAU,YAAYA,YAAI"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Dock"],"sources":["../../../src/components/dock/index.ts"],"sourcesContent":["import { withInstall } from '../../utils/install'\nimport Dock from './dock.vue'\n\nexport const DouDock = withInstall(Dock)\nexport default DouDock\n\nexport type * from './dock'\nexport {\n dockGroups,\n findDockGroup,\n mergeDockTab,\n moveDockTab,\n nextDockGroupId,\n removeDockTab,\n selectDockTab,\n splitDockTab,\n} from './layout'\nexport type DockInstance = InstanceType<typeof Dock>\n\ndeclare module 'vue' {\n export interface GlobalComponents {\n DouDock: typeof DouDock\n }\n}\n"],"mappings":";;;;AAGA,IAAa,UAAU,YAAYA,YAAI"}
|
|
@@ -105,6 +105,17 @@ function removeDockTab(layout, value) {
|
|
|
105
105
|
if (!group) return layout;
|
|
106
106
|
return orEmpty(takeOut(layout, value), group.id);
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Merge a tab into an existing `target` tab: take `value` out of its group
|
|
110
|
+
* (dropping that group once it is empty) and select `target` in its group.
|
|
111
|
+
* Returns a new layout; if `target` is not in the layout, returns it as is.
|
|
112
|
+
*/
|
|
113
|
+
function mergeDockTab(layout, value, target) {
|
|
114
|
+
const targetGroup = findDockGroup(layout, target);
|
|
115
|
+
if (!targetGroup) return layout;
|
|
116
|
+
if (value === target) return selectDockTab(layout, target);
|
|
117
|
+
return selectDockTab(orEmpty(takeOut(layout, value, targetGroup.id), targetGroup.id), target);
|
|
118
|
+
}
|
|
108
119
|
/** Select a tab in its group. Returns a new layout. */
|
|
109
120
|
function selectDockTab(layout, value) {
|
|
110
121
|
return mapNode(layout, (node) => node.type === "group" && node.tabs.includes(value) && node.active !== value ? {
|
|
@@ -116,6 +127,6 @@ function selectDockTab(layout, value) {
|
|
|
116
127
|
function replaceDockNode(layout, node, next) {
|
|
117
128
|
return mapNode(layout, (current) => current === node ? next : current);
|
|
118
129
|
}
|
|
119
|
-
export { dockGroups, findDockGroup, moveDockTab, nextDockGroupId, removeDockTab, replaceDockNode, selectDockTab, splitDockTab };
|
|
130
|
+
export { dockGroups, findDockGroup, mergeDockTab, moveDockTab, nextDockGroupId, removeDockTab, replaceDockNode, selectDockTab, splitDockTab };
|
|
120
131
|
|
|
121
132
|
//# sourceMappingURL=layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","names":[],"sources":["../../../src/components/dock/layout.ts"],"sourcesContent":["import type { TabsValue } from '../tabs/tabs'\n\n/** Two parts side by side or stacked, as a `DouSplitter` shows them. */\nexport interface DockSplit {\n type: 'split'\n /** `horizontal` puts `start` and `end` side by side; `vertical` stacks them. */\n direction: 'horizontal' | 'vertical'\n /** The size of `start` in percent. Defaults to 50. */\n size?: number\n start: DockNode\n end: DockNode\n}\n\n/** A group of tabs, shown as one `DouTabs`. */\nexport interface DockGroup {\n type: 'group'\n id: string\n /** The values of its tabs, in order. */\n tabs: TabsValue[]\n /** The selected tab. Defaults to the first. */\n active?: TabsValue\n}\n\nexport type DockNode = DockSplit | DockGroup\n\n/** The side of a group a tab is split off to. */\nexport type DockSide = 'top' | 'right' | 'bottom' | 'left'\n\nfunction groups(node: DockNode): DockGroup[] {\n return node.type === 'group' ? [node] : [...groups(node.start), ...groups(node.end)]\n}\n\n/** The group a tab is in. */\nexport function findDockGroup(layout: DockNode, value: TabsValue) {\n return groups(layout).find((group) => group.tabs.includes(value))\n}\n\n/** The groups of a layout, from the top left. */\nexport function dockGroups(layout: DockNode) {\n return groups(layout)\n}\n\n/** An id that no group of the layout has yet, `group-1`, `group-2`… */\nexport function nextDockGroupId(layout: DockNode) {\n const ids = new Set(groups(layout).map((group) => group.id))\n let n = 1\n while (ids.has(`group-${n}`)) n++\n return `group-${n}`\n}\n\n/** Replace the nodes `map` returns something new for, keeping the rest. */\nfunction mapNode(node: DockNode, map: (node: DockNode) => DockNode | null): DockNode | null {\n const own = map(node)\n if (own !== node) return own\n if (node.type === 'group') return node\n const start = mapNode(node.start, map)\n const end = mapNode(node.end, map)\n if (start === node.start && end === node.end) return node\n // a split with one side gone is the other side\n if (!start) return end\n if (!end) return start\n return { ...node, start, end }\n}\n\n/** Take a tab out of its group, dropping the group once it is empty. */\nfunction takeOut(layout: DockNode, value: TabsValue, keep?: string): DockNode | null {\n return mapNode(layout, (node) => {\n if (node.type !== 'group' || !node.tabs.includes(value)) return node\n const index = node.tabs.indexOf(value)\n const tabs = node.tabs.filter((tab) => tab !== value)\n if (!tabs.length && node.id !== keep) return null\n const active =\n node.active === value ? (tabs[Math.min(index, tabs.length - 1)] ?? undefined) : node.active\n return { ...node, tabs, active }\n })\n}\n\n/** A layout with nothing left in it keeps one empty group. */\nconst orEmpty = (layout: DockNode | null, id: string): DockNode =>\n layout ?? { type: 'group', id, tabs: [] }\n\n/**\n * Move a tab to a group, at `index` (counted without the tab itself) or\n * at the end, and select it there. The group it leaves is dropped once\n * it is empty. Returns a new layout; the one passed in is not changed.\n */\nexport function moveDockTab(\n layout: DockNode,\n value: TabsValue,\n groupId: string,\n index?: number,\n): DockNode {\n const target = groups(layout).find((group) => group.id === groupId)\n if (!target) return layout\n const taken = takeOut(layout, value, groupId)\n const next = mapNode(orEmpty(taken, groupId), (node) => {\n if (node.type !== 'group' || node.id !== groupId) return node\n const tabs = [...node.tabs]\n tabs.splice(Math.min(Math.max(index ?? tabs.length, 0), tabs.length), 0, value)\n return { ...node, tabs, active: value }\n })\n return next!\n}\n\n/**\n * Split a tab off to one side of a group, into a new group of its own\n * that takes half of the group's place. Returns a new layout.\n */\nexport function splitDockTab(\n layout: DockNode,\n value: TabsValue,\n groupId: string,\n side: DockSide,\n newId: string = nextDockGroupId(layout),\n): DockNode {\n const target = groups(layout).find((group) => group.id === groupId)\n // splitting a group's only tab off itself would leave it where it was\n if (!target || (target.tabs.length === 1 && target.tabs[0] === value)) return layout\n const taken = takeOut(layout, value, groupId)\n const added: DockGroup = { type: 'group', id: newId, tabs: [value], active: value }\n const next = mapNode(orEmpty(taken, groupId), (node) => {\n if (node.type !== 'group' || node.id !== groupId) return node\n const direction = side === 'left' || side === 'right' ? 'horizontal' : 'vertical'\n const first = side === 'left' || side === 'top'\n return {\n type: 'split',\n direction,\n size: 50,\n start: first ? added : node,\n end: first ? node : added,\n }\n })\n return next!\n}\n\n/** Remove a tab, dropping its group once it is empty. Returns a new layout. */\nexport function removeDockTab(layout: DockNode, value: TabsValue): DockNode {\n const group = findDockGroup(layout, value)\n if (!group) return layout\n return orEmpty(takeOut(layout, value), group.id)\n}\n\n/** Select a tab in its group. Returns a new layout. */\nexport function selectDockTab(layout: DockNode, value: TabsValue): DockNode {\n return mapNode(layout, (node) =>\n node.type === 'group' && node.tabs.includes(value) && node.active !== value\n ? { ...node, active: value }\n : node,\n )!\n}\n\n/** Replace one node of the layout, found by identity. */\nexport function replaceDockNode(layout: DockNode, node: DockNode, next: DockNode): DockNode {\n return mapNode(layout, (current) => (current === node ? next : current))!\n}\n"],"mappings":";AA4BA,SAAS,OAAO,MAA6B;CAC3C,OAAO,KAAK,SAAS,UAAU,CAAC,IAAI,IAAI,CAAC,GAAG,OAAO,KAAK,KAAK,GAAG,GAAG,OAAO,KAAK,GAAG,CAAC;AACrF;;AAGA,SAAgB,cAAc,QAAkB,OAAkB;CAChE,OAAO,OAAO,MAAM,CAAC,CAAC,MAAM,UAAU,MAAM,KAAK,SAAS,KAAK,CAAC;AAClE;;AAGA,SAAgB,WAAW,QAAkB;CAC3C,OAAO,OAAO,MAAM;AACtB;;AAGA,SAAgB,gBAAgB,QAAkB;CAChD,MAAM,MAAM,IAAI,IAAI,OAAO,MAAM,CAAC,CAAC,KAAK,UAAU,MAAM,EAAE,CAAC;CAC3D,IAAI,IAAI;CACR,OAAO,IAAI,IAAI,SAAS,GAAG,GAAG;CAC9B,OAAO,SAAS;AAClB;;AAGA,SAAS,QAAQ,MA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AY,OAAO,OAAO,OAAQ;AACzE"}
|
|
1
|
+
{"version":3,"file":"layout.js","names":[],"sources":["../../../src/components/dock/layout.ts"],"sourcesContent":["import type { TabsValue } from '../tabs/tabs'\n\n/** Two parts side by side or stacked, as a `DouSplitter` shows them. */\nexport interface DockSplit {\n type: 'split'\n /** `horizontal` puts `start` and `end` side by side; `vertical` stacks them. */\n direction: 'horizontal' | 'vertical'\n /** The size of `start` in percent. Defaults to 50. */\n size?: number\n start: DockNode\n end: DockNode\n}\n\n/** A group of tabs, shown as one `DouTabs`. */\nexport interface DockGroup {\n type: 'group'\n id: string\n /** The values of its tabs, in order. */\n tabs: TabsValue[]\n /** The selected tab. Defaults to the first. */\n active?: TabsValue\n}\n\nexport type DockNode = DockSplit | DockGroup\n\n/** The side of a group a tab is split off to. */\nexport type DockSide = 'top' | 'right' | 'bottom' | 'left'\n\nfunction groups(node: DockNode): DockGroup[] {\n return node.type === 'group' ? [node] : [...groups(node.start), ...groups(node.end)]\n}\n\n/** The group a tab is in. */\nexport function findDockGroup(layout: DockNode, value: TabsValue) {\n return groups(layout).find((group) => group.tabs.includes(value))\n}\n\n/** The groups of a layout, from the top left. */\nexport function dockGroups(layout: DockNode) {\n return groups(layout)\n}\n\n/** An id that no group of the layout has yet, `group-1`, `group-2`… */\nexport function nextDockGroupId(layout: DockNode) {\n const ids = new Set(groups(layout).map((group) => group.id))\n let n = 1\n while (ids.has(`group-${n}`)) n++\n return `group-${n}`\n}\n\n/** Replace the nodes `map` returns something new for, keeping the rest. */\nfunction mapNode(node: DockNode, map: (node: DockNode) => DockNode | null): DockNode | null {\n const own = map(node)\n if (own !== node) return own\n if (node.type === 'group') return node\n const start = mapNode(node.start, map)\n const end = mapNode(node.end, map)\n if (start === node.start && end === node.end) return node\n // a split with one side gone is the other side\n if (!start) return end\n if (!end) return start\n return { ...node, start, end }\n}\n\n/** Take a tab out of its group, dropping the group once it is empty. */\nfunction takeOut(layout: DockNode, value: TabsValue, keep?: string): DockNode | null {\n return mapNode(layout, (node) => {\n if (node.type !== 'group' || !node.tabs.includes(value)) return node\n const index = node.tabs.indexOf(value)\n const tabs = node.tabs.filter((tab) => tab !== value)\n if (!tabs.length && node.id !== keep) return null\n const active =\n node.active === value ? (tabs[Math.min(index, tabs.length - 1)] ?? undefined) : node.active\n return { ...node, tabs, active }\n })\n}\n\n/** A layout with nothing left in it keeps one empty group. */\nconst orEmpty = (layout: DockNode | null, id: string): DockNode =>\n layout ?? { type: 'group', id, tabs: [] }\n\n/**\n * Move a tab to a group, at `index` (counted without the tab itself) or\n * at the end, and select it there. The group it leaves is dropped once\n * it is empty. Returns a new layout; the one passed in is not changed.\n */\nexport function moveDockTab(\n layout: DockNode,\n value: TabsValue,\n groupId: string,\n index?: number,\n): DockNode {\n const target = groups(layout).find((group) => group.id === groupId)\n if (!target) return layout\n const taken = takeOut(layout, value, groupId)\n const next = mapNode(orEmpty(taken, groupId), (node) => {\n if (node.type !== 'group' || node.id !== groupId) return node\n const tabs = [...node.tabs]\n tabs.splice(Math.min(Math.max(index ?? tabs.length, 0), tabs.length), 0, value)\n return { ...node, tabs, active: value }\n })\n return next!\n}\n\n/**\n * Split a tab off to one side of a group, into a new group of its own\n * that takes half of the group's place. Returns a new layout.\n */\nexport function splitDockTab(\n layout: DockNode,\n value: TabsValue,\n groupId: string,\n side: DockSide,\n newId: string = nextDockGroupId(layout),\n): DockNode {\n const target = groups(layout).find((group) => group.id === groupId)\n // splitting a group's only tab off itself would leave it where it was\n if (!target || (target.tabs.length === 1 && target.tabs[0] === value)) return layout\n const taken = takeOut(layout, value, groupId)\n const added: DockGroup = { type: 'group', id: newId, tabs: [value], active: value }\n const next = mapNode(orEmpty(taken, groupId), (node) => {\n if (node.type !== 'group' || node.id !== groupId) return node\n const direction = side === 'left' || side === 'right' ? 'horizontal' : 'vertical'\n const first = side === 'left' || side === 'top'\n return {\n type: 'split',\n direction,\n size: 50,\n start: first ? added : node,\n end: first ? node : added,\n }\n })\n return next!\n}\n\n/** Remove a tab, dropping its group once it is empty. Returns a new layout. */\nexport function removeDockTab(layout: DockNode, value: TabsValue): DockNode {\n const group = findDockGroup(layout, value)\n if (!group) return layout\n return orEmpty(takeOut(layout, value), group.id)\n}\n\n/**\n * Merge a tab into an existing `target` tab: take `value` out of its group\n * (dropping that group once it is empty) and select `target` in its group.\n * Returns a new layout; if `target` is not in the layout, returns it as is.\n */\nexport function mergeDockTab(layout: DockNode, value: TabsValue, target: TabsValue): DockNode {\n const targetGroup = findDockGroup(layout, target)\n if (!targetGroup) return layout\n if (value === target) return selectDockTab(layout, target)\n const taken = takeOut(layout, value, targetGroup.id)\n return selectDockTab(orEmpty(taken, targetGroup.id), target)\n}\n\n/** Select a tab in its group. Returns a new layout. */\nexport function selectDockTab(layout: DockNode, value: TabsValue): DockNode {\n return mapNode(layout, (node) =>\n node.type === 'group' && node.tabs.includes(value) && node.active !== value\n ? { ...node, active: value }\n : node,\n )!\n}\n\n/** Replace one node of the layout, found by identity. */\nexport function replaceDockNode(layout: DockNode, node: DockNode, next: DockNode): DockNode {\n return mapNode(layout, (current) => (current === node ? next : current))!\n}\n"],"mappings":";AA4BA,SAAS,OAAO,MAA6B;CAC3C,OAAO,KAAK,SAAS,UAAU,CAAC,IAAI,IAAI,CAAC,GAAG,OAAO,KAAK,KAAK,GAAG,GAAG,OAAO,KAAK,GAAG,CAAC;AACrF;;AAGA,SAAgB,cAAc,QAAkB,OAAkB;CAChE,OAAO,OAAO,MAAM,CAAC,CAAC,MAAM,UAAU,MAAM,KAAK,SAAS,KAAK,CAAC;AAClE;;AAGA,SAAgB,WAAW,QAAkB;CAC3C,OAAO,OAAO,MAAM;AACtB;;AAGA,SAAgB,gBAAgB,QAAkB;CAChD,MAAM,MAAM,IAAI,IAAI,OAAO,MAAM,CAAC,CAAC,KAAK,UAAU,MAAM,EAAE,CAAC;CAC3D,IAAI,IAAI;CACR,OAAO,IAAI,IAAI,SAAS,GAAG,GAAG;CAC9B,OAAO,SAAS;AAClB;;AAG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AAG,MAAM;AAC7D;;AAGA,SAAgB,cAAc,QAAkB,OAA4B;CAC1E,OAAO,QAAQ,SAAS,SACtB,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,KAAK,KAAK,KAAK,WAAW,QAClE;EAAE,GAAG;EAAM,QAAQ;CAAM,IACzB,IACN;AACF;;AAGA,SAAgB,gBAAgB,QAAkB,MAAgB,MAA0B;CAC1F,OAAO,QAAQ,SAAS,YAAa,YAAY,OAAO,OAAO,OAAQ;AACzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":["_sfc_main"],"sources":["../../../src/components/popover/popover.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, mergeProps, useId, useSlots } from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { getTabbable } from '../../composables/use-focus-trap'\nimport { usePopup } from '../../composables/use-popup'\nimport { useNamespace } from '../../utils/namespace'\nimport { OnlyChild } from '../../utils/only-child'\nimport type { PopoverExpose, PopoverProps, PopoverSlots } from './popover'\nimport { useTeleport } from '../../utils/teleport'\n\ndefineOptions({ name: 'DouPopover', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<PopoverProps>(), {\n placement: 'bottom',\n trigger: 'click',\n disabled: false,\n showDelay: 100,\n hideDelay: 150,\n offset: 8,\n openOnTap: true,\n teleport: undefined,\n})\nconst teleportTarget = useTeleport(() => props.teleport)\nconst open = defineModel<boolean>('open', { default: false })\ndefineSlots<PopoverSlots>()\nconst slots = useSlots()\n\nconst ns = useNamespace('popover')\nconst id = `dou-popover-${useId()}`\nconst titleId = `${id}-title`\nconst hasTitle = computed(() => !!props.title || !!slots.title)\n\nconst popup = usePopup({\n open,\n trigger: () => props.trigger,\n disabled: () => props.disabled,\n placement: () => props.placement,\n offset: () => props.offset,\n showDelay: () => props.showDelay,\n hideDelay: () => props.hideDelay,\n tap: () => props.openOnTap,\n})\nconst { triggerRef, panelRef, rendered, theme, placement, panelStyle, panelListeners } = popup\n\n// The panel lives at the end of <body>, away from the trigger in tab\n// order. `Tab` from the trigger steps into the panel, and stepping out of\n// either end of the panel lands back on the trigger, from where the\n// browser carries on as usual. Leaving the trigger any other way (`Tab`\n// with nothing to focus in the panel, or `Shift+Tab`) closes the panel, so\n// it doesn't stay open away from the focus.\nfunction onTriggerKeydown(event: KeyboardEvent) {\n if (event.key !== 'Tab' || !open.value || !panelRef.value) return\n const first = event.shiftKey ? undefined : getTabbable(panelRef.value)[0]\n if (!first) return popup.hide()\n event.preventDefault()\n first.focus()\n}\n\nfunction onPanelKeydown(event: KeyboardEvent) {\n if (event.key !== 'Tab' || !panelRef.value) return\n const tabbable = getTabbable(panelRef.value)\n const trigger = popup.reference() as HTMLElement | null\n if (event.shiftKey && document.activeElement === tabbable[0]) {\n event.preventDefault()\n trigger?.focus()\n } else if (!event.shiftKey && document.activeElement === tabbable.at(-1)) {\n trigger?.focus()\n popup.hide()\n }\n}\n\n// Hover has no keyboard of its own: Enter or Space on the trigger (a click\n// with `detail` 0) opens and closes a hover card too, so a screen reader\n// can reach it. A link trigger keeps Enter for following the link.\nfunction onTriggerClick(event: MouseEvent) {\n if (props.trigger !== 'hover' || event.detail !== 0 || props.disabled) return\n if ((event.currentTarget as Element | null)?.matches('a[href]')) return\n if (open.value) return popup.hide()\n popup.tapped.value = true\n popup.show()\n}\n\nconst triggerProps = computed(() =>\n mergeProps(popup.triggerListeners.value, {\n onKeydown: onTriggerKeydown,\n onClick: onTriggerClick,\n 'aria-haspopup': 'dialog' as const,\n // a hover card a tap or the keyboard opened stays, like a dialog\n 'aria-expanded': props.trigger === 'hover' && !popup.tapped.value ? undefined : open.value,\n 'aria-controls': rendered.value ? id : undefined,\n }),\n)\n\nconst panelClasses = computed(() => [ns.b(), 'dou-floating', ns.is('titled', hasTitle.value)])\nconst cssSize = (value: string | number | undefined)
|
|
1
|
+
{"version":3,"file":"popover.js","names":["_sfc_main"],"sources":["../../../src/components/popover/popover.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, mergeProps, useId, useSlots } from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { getTabbable } from '../../composables/use-focus-trap'\nimport { usePopup } from '../../composables/use-popup'\nimport { useNamespace } from '../../utils/namespace'\nimport { OnlyChild } from '../../utils/only-child'\nimport type { PopoverExpose, PopoverProps, PopoverSlots } from './popover'\nimport { useTeleport } from '../../utils/teleport'\n\ndefineOptions({ name: 'DouPopover', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<PopoverProps>(), {\n placement: 'bottom',\n trigger: 'click',\n disabled: false,\n showDelay: 100,\n hideDelay: 150,\n offset: 8,\n openOnTap: true,\n teleport: undefined,\n})\nconst teleportTarget = useTeleport(() => props.teleport)\nconst open = defineModel<boolean>('open', { default: false })\ndefineSlots<PopoverSlots>()\nconst slots = useSlots()\n\nconst ns = useNamespace('popover')\nconst id = `dou-popover-${useId()}`\nconst titleId = `${id}-title`\nconst hasTitle = computed(() => !!props.title || !!slots.title)\n\nconst popup = usePopup({\n open,\n trigger: () => props.trigger,\n disabled: () => props.disabled,\n placement: () => props.placement,\n offset: () => props.offset,\n showDelay: () => props.showDelay,\n hideDelay: () => props.hideDelay,\n tap: () => props.openOnTap,\n})\nconst { triggerRef, panelRef, rendered, theme, placement, panelStyle, panelListeners } = popup\n\n// The panel lives at the end of <body>, away from the trigger in tab\n// order. `Tab` from the trigger steps into the panel, and stepping out of\n// either end of the panel lands back on the trigger, from where the\n// browser carries on as usual. Leaving the trigger any other way (`Tab`\n// with nothing to focus in the panel, or `Shift+Tab`) closes the panel, so\n// it doesn't stay open away from the focus.\nfunction onTriggerKeydown(event: KeyboardEvent) {\n if (event.key !== 'Tab' || !open.value || !panelRef.value) return\n const first = event.shiftKey ? undefined : getTabbable(panelRef.value)[0]\n if (!first) return popup.hide()\n event.preventDefault()\n first.focus()\n}\n\nfunction onPanelKeydown(event: KeyboardEvent) {\n if (event.key !== 'Tab' || !panelRef.value) return\n const tabbable = getTabbable(panelRef.value)\n const trigger = popup.reference() as HTMLElement | null\n if (event.shiftKey && document.activeElement === tabbable[0]) {\n event.preventDefault()\n trigger?.focus()\n } else if (!event.shiftKey && document.activeElement === tabbable.at(-1)) {\n trigger?.focus()\n popup.hide()\n }\n}\n\n// Hover has no keyboard of its own: Enter or Space on the trigger (a click\n// with `detail` 0) opens and closes a hover card too, so a screen reader\n// can reach it. A link trigger keeps Enter for following the link.\nfunction onTriggerClick(event: MouseEvent) {\n if (props.trigger !== 'hover' || event.detail !== 0 || props.disabled) return\n if ((event.currentTarget as Element | null)?.matches('a[href]')) return\n if (open.value) return popup.hide()\n popup.tapped.value = true\n popup.show()\n}\n\nconst triggerProps = computed(() =>\n mergeProps(popup.triggerListeners.value, {\n onKeydown: onTriggerKeydown,\n onClick: onTriggerClick,\n 'aria-haspopup': 'dialog' as const,\n // a hover card a tap or the keyboard opened stays, like a dialog\n 'aria-expanded': props.trigger === 'hover' && !popup.tapped.value ? undefined : open.value,\n 'aria-controls': rendered.value ? id : undefined,\n }),\n)\n\nconst panelClasses = computed(() => [ns.b(), 'dou-floating', ns.is('titled', hasTitle.value)])\n// CSS `min()` only accepts <length-percentage>, length math functions and\n// var()/env(). Writing unitless strings, intrinsic keywords or malformed values\n// into `--dou-popover-max-*` would make `max-width` / `max-height` invalid at\n// computed-value time (IACVT) and drop the viewport clamp.\nconst CSS_LENGTH_PERCENTAGE =\n /^\\+?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:e[+-]?\\d+)?(?:%|px|cm|mm|q|in|pc|pt|r?(?:em|ex|cap|ch|ic|lh)|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max))$/i\nconst CSS_MIN_FUNCTION = /^(?:calc|min|max|clamp|round|abs|mod|rem|var|env)\\(/i\nfunction isMinCompatibleSize(value: string): boolean {\n if (CSS_LENGTH_PERCENTAGE.test(value)) return true\n if (!CSS_MIN_FUNCTION.test(value) || !value.endsWith(')')) return false\n const openIndex = value.indexOf('(')\n if (!value.slice(openIndex + 1, -1).trim()) return false\n let depth = 0\n for (let i = openIndex; i < value.length; i++) {\n if (value[i] === '(') depth++\n else if (value[i] === ')') {\n depth--\n if (depth === 0) return i === value.length - 1\n if (depth < 0) return false\n }\n }\n return false\n}\nconst cssSize = (value: string | number | undefined) => {\n if (typeof value === 'number')\n return Number.isFinite(value) && value >= 0 ? `${value}px` : undefined\n const trimmed = value?.trim()\n return trimmed || undefined\n}\nconst panelSizeStyle = computed<CSSProperties>(() => {\n const width = cssSize(props.width)\n const maxHeight = cssSize(props.maxHeight)\n return {\n width,\n ...(width !== undefined &&\n isMinCompatibleSize(width) && {\n '--dou-popover-max-width': width,\n }),\n ...(maxHeight !== undefined &&\n isMinCompatibleSize(maxHeight) && {\n '--dou-popover-max-height': maxHeight,\n }),\n }\n})\n\ndefineExpose<PopoverExpose>({ open: () => popup.show(), close: () => popup.dismiss() })\n</script>\n\n<template>\n <OnlyChild ref=\"triggerRef\" v-bind=\"triggerProps\"><slot /></OnlyChild>\n <Teleport v-if=\"rendered\" :to=\"teleportTarget.to\" :disabled=\"teleportTarget.disabled\">\n <Transition appear name=\"dou-floating\">\n <div\n v-show=\"open\"\n :id=\"id\"\n ref=\"panelRef\"\n role=\"dialog\"\n :aria-labelledby=\"hasTitle ? titleId : undefined\"\n :class=\"panelClasses\"\n :style=\"[panelStyle, panelSizeStyle]\"\n :data-placement=\"placement\"\n :data-dou-theme=\"theme\"\n v-bind=\"{ ...$attrs, ...panelListeners }\"\n @keydown=\"onPanelKeydown\"\n >\n <div v-if=\"hasTitle\" :id=\"titleId\" :class=\"ns.e('title')\">\n <slot name=\"title\">{{ title }}</slot>\n </div>\n <div :class=\"ns.e('content')\">\n <slot name=\"content\" :close=\"popup.dismiss\">{{ content }}</slot>\n </div>\n </div>\n </Transition>\n </Teleport>\n</template>\n"],"mappings":""}
|
|
@@ -103,11 +103,35 @@ var popover_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCo
|
|
|
103
103
|
"dou-floating",
|
|
104
104
|
ns.is("titled", hasTitle.value)
|
|
105
105
|
]);
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
const CSS_LENGTH_PERCENTAGE = /^\+?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(?:%|px|cm|mm|q|in|pc|pt|r?(?:em|ex|cap|ch|ic|lh)|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max))$/i;
|
|
107
|
+
const CSS_MIN_FUNCTION = /^(?:calc|min|max|clamp|round|abs|mod|rem|var|env)\(/i;
|
|
108
|
+
function isMinCompatibleSize(value) {
|
|
109
|
+
if (CSS_LENGTH_PERCENTAGE.test(value)) return true;
|
|
110
|
+
if (!CSS_MIN_FUNCTION.test(value) || !value.endsWith(")")) return false;
|
|
111
|
+
const openIndex = value.indexOf("(");
|
|
112
|
+
if (!value.slice(openIndex + 1, -1).trim()) return false;
|
|
113
|
+
let depth = 0;
|
|
114
|
+
for (let i = openIndex; i < value.length; i++) if (value[i] === "(") depth++;
|
|
115
|
+
else if (value[i] === ")") {
|
|
116
|
+
depth--;
|
|
117
|
+
if (depth === 0) return i === value.length - 1;
|
|
118
|
+
if (depth < 0) return false;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const cssSize = (value) => {
|
|
123
|
+
if (typeof value === "number") return Number.isFinite(value) && value >= 0 ? `${value}px` : void 0;
|
|
124
|
+
return value?.trim() || void 0;
|
|
125
|
+
};
|
|
126
|
+
const panelSizeStyle = computed(() => {
|
|
127
|
+
const width = cssSize(props.width);
|
|
128
|
+
const maxHeight = cssSize(props.maxHeight);
|
|
129
|
+
return {
|
|
130
|
+
width,
|
|
131
|
+
...width !== void 0 && isMinCompatibleSize(width) && { "--dou-popover-max-width": width },
|
|
132
|
+
...maxHeight !== void 0 && isMinCompatibleSize(maxHeight) && { "--dou-popover-max-height": maxHeight }
|
|
133
|
+
};
|
|
134
|
+
});
|
|
111
135
|
__expose({
|
|
112
136
|
open: () => popup.show(),
|
|
113
137
|
close: () => popup.dismiss()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_useModel","_openBlock","_createElementBlock","_Fragment","_createVNode","_unref","_mergeProps","_withCtx","_renderSlot","_createBlock","_Teleport","_Transition","_withDirectives","_createElementVNode","_normalizeClass","_createTextVNode","_toDisplayString","_createCommentVNode","_vShow"],"sources":["../../../src/components/popover/popover.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, mergeProps, useId, useSlots } from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { getTabbable } from '../../composables/use-focus-trap'\nimport { usePopup } from '../../composables/use-popup'\nimport { useNamespace } from '../../utils/namespace'\nimport { OnlyChild } from '../../utils/only-child'\nimport type { PopoverExpose, PopoverProps, PopoverSlots } from './popover'\nimport { useTeleport } from '../../utils/teleport'\n\ndefineOptions({ name: 'DouPopover', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<PopoverProps>(), {\n placement: 'bottom',\n trigger: 'click',\n disabled: false,\n showDelay: 100,\n hideDelay: 150,\n offset: 8,\n openOnTap: true,\n teleport: undefined,\n})\nconst teleportTarget = useTeleport(() => props.teleport)\nconst open = defineModel<boolean>('open', { default: false })\ndefineSlots<PopoverSlots>()\nconst slots = useSlots()\n\nconst ns = useNamespace('popover')\nconst id = `dou-popover-${useId()}`\nconst titleId = `${id}-title`\nconst hasTitle = computed(() => !!props.title || !!slots.title)\n\nconst popup = usePopup({\n open,\n trigger: () => props.trigger,\n disabled: () => props.disabled,\n placement: () => props.placement,\n offset: () => props.offset,\n showDelay: () => props.showDelay,\n hideDelay: () => props.hideDelay,\n tap: () => props.openOnTap,\n})\nconst { triggerRef, panelRef, rendered, theme, placement, panelStyle, panelListeners } = popup\n\n// The panel lives at the end of <body>, away from the trigger in tab\n// order. `Tab` from the trigger steps into the panel, and stepping out of\n// either end of the panel lands back on the trigger, from where the\n// browser carries on as usual. Leaving the trigger any other way (`Tab`\n// with nothing to focus in the panel, or `Shift+Tab`) closes the panel, so\n// it doesn't stay open away from the focus.\nfunction onTriggerKeydown(event: KeyboardEvent) {\n if (event.key !== 'Tab' || !open.value || !panelRef.value) return\n const first = event.shiftKey ? undefined : getTabbable(panelRef.value)[0]\n if (!first) return popup.hide()\n event.preventDefault()\n first.focus()\n}\n\nfunction onPanelKeydown(event: KeyboardEvent) {\n if (event.key !== 'Tab' || !panelRef.value) return\n const tabbable = getTabbable(panelRef.value)\n const trigger = popup.reference() as HTMLElement | null\n if (event.shiftKey && document.activeElement === tabbable[0]) {\n event.preventDefault()\n trigger?.focus()\n } else if (!event.shiftKey && document.activeElement === tabbable.at(-1)) {\n trigger?.focus()\n popup.hide()\n }\n}\n\n// Hover has no keyboard of its own: Enter or Space on the trigger (a click\n// with `detail` 0) opens and closes a hover card too, so a screen reader\n// can reach it. A link trigger keeps Enter for following the link.\nfunction onTriggerClick(event: MouseEvent) {\n if (props.trigger !== 'hover' || event.detail !== 0 || props.disabled) return\n if ((event.currentTarget as Element | null)?.matches('a[href]')) return\n if (open.value) return popup.hide()\n popup.tapped.value = true\n popup.show()\n}\n\nconst triggerProps = computed(() =>\n mergeProps(popup.triggerListeners.value, {\n onKeydown: onTriggerKeydown,\n onClick: onTriggerClick,\n 'aria-haspopup': 'dialog' as const,\n // a hover card a tap or the keyboard opened stays, like a dialog\n 'aria-expanded': props.trigger === 'hover' && !popup.tapped.value ? undefined : open.value,\n 'aria-controls': rendered.value ? id : undefined,\n }),\n)\n\nconst panelClasses = computed(() => [ns.b(), 'dou-floating', ns.is('titled', hasTitle.value)])\nconst cssSize = (value: string | number | undefined) =>\n typeof value === 'number' ? `${value}px` : (value ?? undefined)\nconst panelSizeStyle = computed<CSSProperties>(() => ({\n width: cssSize(props.width),\n ...(props.maxHeight !== undefined && {\n '--dou-popover-max-height': cssSize(props.maxHeight),\n }),\n}))\n\ndefineExpose<PopoverExpose>({ open: () => popup.show(), close: () => popup.dismiss() })\n</script>\n\n<template>\n <OnlyChild ref=\"triggerRef\" v-bind=\"triggerProps\"><slot /></OnlyChild>\n <Teleport v-if=\"rendered\" :to=\"teleportTarget.to\" :disabled=\"teleportTarget.disabled\">\n <Transition appear name=\"dou-floating\">\n <div\n v-show=\"open\"\n :id=\"id\"\n ref=\"panelRef\"\n role=\"dialog\"\n :aria-labelledby=\"hasTitle ? titleId : undefined\"\n :class=\"panelClasses\"\n :style=\"[panelStyle, panelSizeStyle]\"\n :data-placement=\"placement\"\n :data-dou-theme=\"theme\"\n v-bind=\"{ ...$attrs, ...panelListeners }\"\n @keydown=\"onPanelKeydown\"\n >\n <div v-if=\"hasTitle\" :id=\"titleId\" :class=\"ns.e('title')\">\n <slot name=\"title\">{{ title }}</slot>\n </div>\n <div :class=\"ns.e('content')\">\n <slot name=\"content\" :close=\"popup.dismiss\">{{ content }}</slot>\n </div>\n </div>\n </Transition>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,MAAM,QAAQ;EAUd,MAAM,iBAAiB,kBAAkB,MAAM,QAAQ;EACvD,MAAM,OAAOC,SAAoB,SAAC,MAA0B;EAE5D,MAAM,QAAQ,SAAS;EAEvB,MAAM,KAAK,aAAa,SAAS;EACjC,MAAM,KAAK,eAAe,MAAM;EAChC,MAAM,UAAU,GAAG,GAAG;EACtB,MAAM,WAAW,eAAe,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC,MAAM,KAAK;EAE9D,MAAM,QAAQ,SAAS;GACrB;GACA,eAAe,MAAM;GACrB,gBAAgB,MAAM;GACtB,iBAAiB,MAAM;GACvB,cAAc,MAAM;GACpB,iBAAiB,MAAM;GACvB,iBAAiB,MAAM;GACvB,WAAW,MAAM;EACnB,CAAC;EACD,MAAM,EAAE,YAAY,UAAU,UAAU,OAAO,WAAW,YAAY,mBAAmB;EAQzF,SAAS,iBAAiB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WAAgE,KAAA,QAAA,WAAA,EAA1C,OAAOH,MAAA,KAAA,CAAK,CAAC,QAAnC,SAAgE,CAAjBU,gBAAAC,gBAAA,QAAA,OAAO,GAAA,CAAA,C,4BAhBhD,CAAAE,OAAA,KAAA,KAAI,C"}
|
|
1
|
+
{"version":3,"file":"popover.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_useModel","_openBlock","_createElementBlock","_Fragment","_createVNode","_unref","_mergeProps","_withCtx","_renderSlot","_createBlock","_Teleport","_Transition","_withDirectives","_createElementVNode","_normalizeClass","_createTextVNode","_toDisplayString","_createCommentVNode","_vShow"],"sources":["../../../src/components/popover/popover.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, mergeProps, useId, useSlots } from 'vue'\nimport type { CSSProperties } from 'vue'\nimport { getTabbable } from '../../composables/use-focus-trap'\nimport { usePopup } from '../../composables/use-popup'\nimport { useNamespace } from '../../utils/namespace'\nimport { OnlyChild } from '../../utils/only-child'\nimport type { PopoverExpose, PopoverProps, PopoverSlots } from './popover'\nimport { useTeleport } from '../../utils/teleport'\n\ndefineOptions({ name: 'DouPopover', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<PopoverProps>(), {\n placement: 'bottom',\n trigger: 'click',\n disabled: false,\n showDelay: 100,\n hideDelay: 150,\n offset: 8,\n openOnTap: true,\n teleport: undefined,\n})\nconst teleportTarget = useTeleport(() => props.teleport)\nconst open = defineModel<boolean>('open', { default: false })\ndefineSlots<PopoverSlots>()\nconst slots = useSlots()\n\nconst ns = useNamespace('popover')\nconst id = `dou-popover-${useId()}`\nconst titleId = `${id}-title`\nconst hasTitle = computed(() => !!props.title || !!slots.title)\n\nconst popup = usePopup({\n open,\n trigger: () => props.trigger,\n disabled: () => props.disabled,\n placement: () => props.placement,\n offset: () => props.offset,\n showDelay: () => props.showDelay,\n hideDelay: () => props.hideDelay,\n tap: () => props.openOnTap,\n})\nconst { triggerRef, panelRef, rendered, theme, placement, panelStyle, panelListeners } = popup\n\n// The panel lives at the end of <body>, away from the trigger in tab\n// order. `Tab` from the trigger steps into the panel, and stepping out of\n// either end of the panel lands back on the trigger, from where the\n// browser carries on as usual. Leaving the trigger any other way (`Tab`\n// with nothing to focus in the panel, or `Shift+Tab`) closes the panel, so\n// it doesn't stay open away from the focus.\nfunction onTriggerKeydown(event: KeyboardEvent) {\n if (event.key !== 'Tab' || !open.value || !panelRef.value) return\n const first = event.shiftKey ? undefined : getTabbable(panelRef.value)[0]\n if (!first) return popup.hide()\n event.preventDefault()\n first.focus()\n}\n\nfunction onPanelKeydown(event: KeyboardEvent) {\n if (event.key !== 'Tab' || !panelRef.value) return\n const tabbable = getTabbable(panelRef.value)\n const trigger = popup.reference() as HTMLElement | null\n if (event.shiftKey && document.activeElement === tabbable[0]) {\n event.preventDefault()\n trigger?.focus()\n } else if (!event.shiftKey && document.activeElement === tabbable.at(-1)) {\n trigger?.focus()\n popup.hide()\n }\n}\n\n// Hover has no keyboard of its own: Enter or Space on the trigger (a click\n// with `detail` 0) opens and closes a hover card too, so a screen reader\n// can reach it. A link trigger keeps Enter for following the link.\nfunction onTriggerClick(event: MouseEvent) {\n if (props.trigger !== 'hover' || event.detail !== 0 || props.disabled) return\n if ((event.currentTarget as Element | null)?.matches('a[href]')) return\n if (open.value) return popup.hide()\n popup.tapped.value = true\n popup.show()\n}\n\nconst triggerProps = computed(() =>\n mergeProps(popup.triggerListeners.value, {\n onKeydown: onTriggerKeydown,\n onClick: onTriggerClick,\n 'aria-haspopup': 'dialog' as const,\n // a hover card a tap or the keyboard opened stays, like a dialog\n 'aria-expanded': props.trigger === 'hover' && !popup.tapped.value ? undefined : open.value,\n 'aria-controls': rendered.value ? id : undefined,\n }),\n)\n\nconst panelClasses = computed(() => [ns.b(), 'dou-floating', ns.is('titled', hasTitle.value)])\n// CSS `min()` only accepts <length-percentage>, length math functions and\n// var()/env(). Writing unitless strings, intrinsic keywords or malformed values\n// into `--dou-popover-max-*` would make `max-width` / `max-height` invalid at\n// computed-value time (IACVT) and drop the viewport clamp.\nconst CSS_LENGTH_PERCENTAGE =\n /^\\+?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:e[+-]?\\d+)?(?:%|px|cm|mm|q|in|pc|pt|r?(?:em|ex|cap|ch|ic|lh)|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max))$/i\nconst CSS_MIN_FUNCTION = /^(?:calc|min|max|clamp|round|abs|mod|rem|var|env)\\(/i\nfunction isMinCompatibleSize(value: string): boolean {\n if (CSS_LENGTH_PERCENTAGE.test(value)) return true\n if (!CSS_MIN_FUNCTION.test(value) || !value.endsWith(')')) return false\n const openIndex = value.indexOf('(')\n if (!value.slice(openIndex + 1, -1).trim()) return false\n let depth = 0\n for (let i = openIndex; i < value.length; i++) {\n if (value[i] === '(') depth++\n else if (value[i] === ')') {\n depth--\n if (depth === 0) return i === value.length - 1\n if (depth < 0) return false\n }\n }\n return false\n}\nconst cssSize = (value: string | number | undefined) => {\n if (typeof value === 'number')\n return Number.isFinite(value) && value >= 0 ? `${value}px` : undefined\n const trimmed = value?.trim()\n return trimmed || undefined\n}\nconst panelSizeStyle = computed<CSSProperties>(() => {\n const width = cssSize(props.width)\n const maxHeight = cssSize(props.maxHeight)\n return {\n width,\n ...(width !== undefined &&\n isMinCompatibleSize(width) && {\n '--dou-popover-max-width': width,\n }),\n ...(maxHeight !== undefined &&\n isMinCompatibleSize(maxHeight) && {\n '--dou-popover-max-height': maxHeight,\n }),\n }\n})\n\ndefineExpose<PopoverExpose>({ open: () => popup.show(), close: () => popup.dismiss() })\n</script>\n\n<template>\n <OnlyChild ref=\"triggerRef\" v-bind=\"triggerProps\"><slot /></OnlyChild>\n <Teleport v-if=\"rendered\" :to=\"teleportTarget.to\" :disabled=\"teleportTarget.disabled\">\n <Transition appear name=\"dou-floating\">\n <div\n v-show=\"open\"\n :id=\"id\"\n ref=\"panelRef\"\n role=\"dialog\"\n :aria-labelledby=\"hasTitle ? titleId : undefined\"\n :class=\"panelClasses\"\n :style=\"[panelStyle, panelSizeStyle]\"\n :data-placement=\"placement\"\n :data-dou-theme=\"theme\"\n v-bind=\"{ ...$attrs, ...panelListeners }\"\n @keydown=\"onPanelKeydown\"\n >\n <div v-if=\"hasTitle\" :id=\"titleId\" :class=\"ns.e('title')\">\n <slot name=\"title\">{{ title }}</slot>\n </div>\n <div :class=\"ns.e('content')\">\n <slot name=\"content\" :close=\"popup.dismiss\">{{ content }}</slot>\n </div>\n </div>\n </Transition>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,MAAM,QAAQ;EAUd,MAAM,iBAAiB,kBAAkB,MAAM,QAAQ;EACvD,MAAM,OAAOC,SAAoB,SAAC,MAA0B;EAE5D,MAAM,QAAQ,SAAS;EAEvB,MAAM,KAAK,aAAa,SAAS;EACjC,MAAM,KAAK,eAAe,MAAM;EAChC,MAAM,UAAU,GAAG,GAAG;EACtB,MAAM,WAAW,eAAe,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC,MAAM,KAAK;EAE9D,MAAM,QAAQ,SAAS;GACrB;GACA,eAAe,MAAM;GACrB,gBAAgB,MAAM;GACtB,iBAAiB,MAAM;GACvB,cAAc,MAAM;GACpB,iBAAiB,MAAM;GACvB,iBAAiB,MAAM;GACvB,WAAW,MAAM;EACnB,CAAC;EACD,MAAM,EAAE,YAAY,UAAU,UAAU,OAAO,WAAW,YAAY,mBAAmB;EAQzF,SAAS,iBAAiB,OAAsB;GAC9C,IAAI,MAAM,QAAQ,SAAS,CAAC,KAAK,SAAS,CAAC,SAAS,OAAO;GAC3D,MAAM,QAAQ,MAAM,WAAW,KAAA,IAAY,YAAY,SAAS,KAAK,CAAC,CAAC;GACvE,IAAI,CAAC,OAAO,OAAO,MAAM,KAAK;GAC9B,MAAM,eAAe;GACrB,MAAM,MAAM;EACd;EAEA,SAAS,eAAe,OAAsB;GAC5C,IAAI,MAAM,QAAQ,SAAS,CA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KAClC,kBAAgBA,MAAA,SAAA;KAChB,kBAAgBA,MAAA,KAAA;IACJN,GAAAA;KAAAA,GAAAA,KAAAA;KAAM,GAAKM,MAAA,cAAA;IAAc,GAAA,EACrC,WAAS,eAAc,CAAA,GAAA,CAEb,SAAA,SAAXJ,UAAA,GAAAC,mBAEM,OAAA;;KAFgB,IAAI;KAAU,OAAKY,eAAET,MAAA,EAAA,CAAE,CAAC,EAAC,OAAA,CAAA;I,IAC7CG,WAAqC,KAAA,QAAA,SAAA,CAAA,SAAA,CAAfO,gBAAAC,gBAAA,QAAA,KAAK,GAAA,CAAA,C,yCAE7BH,mBAEM,OAAA,EAFA,OAAKC,eAAET,MAAA,EAAA,CAAE,CAAC,EAAC,SAAA,CAAA,E,IACfG,WAAgE,KAAA,QAAA,WAAA,EAA1C,OAAOH,MAAA,KAAA,CAAK,CAAC,QAAnC,SAAgE,CAAjBU,gBAAAC,gBAAA,QAAA,OAAO,GAAA,CAAA,C,4BAhBhD,CAAAE,OAAA,KAAA,KAAI,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-button.js","names":["_sfc_main"],"sources":["../../../src/components/tabs/tab-button.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { h } from 'vue'\nimport { CloseIcon } from '@dou-ui/icons'\nimport { useNamespace } from '../../utils/namespace'\nimport { useLocale } from '../config-provider/use-config'\nimport { DouTooltip } from '../tooltip'\nimport type { FunctionalComponent, VNode } from 'vue'\nimport type { TabPanelEntry } from './tabs'\n\ndefineOptions({ name: 'DouTabButton' })\n\nconst props = defineProps<{\n entry: TabPanelEntry\n tabId: string\n panelId: string\n labelText: string\n selected: boolean\n closable: boolean\n iconAlone: boolean\n draggable: boolean\n dragging: boolean\n tipPlacement: 'top' | 'right' | 'left'\n keyShortcuts?: string\n setEl: (el: unknown) => void\n}>()\n\nconst emit = defineEmits<{\n click: []\n pointerdown: [event: PointerEvent]\n keydown: [event: KeyboardEvent]\n remove: []\n}>()\n\nconst ns = useNamespace('tabs')\nconst { t } = useLocale()\nconst onButtonRef = (el: unknown) => props.setEl(el)\n\n/** The label slot of a panel, rendered inside its tab. */\nconst TabLabel: FunctionalComponent = () =>\n (props.entry.slots.label?.({ selected: props.selected }) as VNode[] | undefined) ??\n props.labelText\n\nconst TabTip: FunctionalComponent = (_, { slots: tip }) =>\n props.iconAlone\n ? h(DouTooltip, { content: props.labelText, placement: props.tipPlacement }, tip)\n : tip.default?.()\n</script>\n\n<template>\n <TabTip>\n <button\n :id=\"tabId\"\n :ref=\"onButtonRef\"\n type=\"button\"\n role=\"tab\"\n :class=\"[\n ns.e('tab'),\n ns.is('selected', selected),\n ns.is('disabled', !!entry.props.disabled),\n ns.is('closable', closable),\n ns.is('icon-alone', iconAlone),\n ns.is('pinned', !!entry.props.pinned),\n ns.is('draggable', draggable),\n ns.is('dragging', dragging),\n ]\"\n :aria-selected=\"selected\"\n :aria-controls=\"panelId\"\n :aria-label=\"iconAlone ? labelText : undefined\"\n :aria-disabled=\"entry.props.disabled || undefined\"\n :tabindex=\"selected ? 0 : -1\"\n :aria-keyshortcuts=\"keyShortcuts\"\n @click=\"emit('click')\"\n @pointerdown=\"emit('pointerdown', $event)\"\n @keydown=\"emit('keydown', $event)\"\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\" :class=\"ns.e('label')\">\n <TabLabel />\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=\"closable\"\n :content=\"t('tabs.close')\"\n shortcut=\"delete\"\n :disabled=\"iconAlone\"\n >\n <span
|
|
1
|
+
{"version":3,"file":"tab-button.js","names":["_sfc_main"],"sources":["../../../src/components/tabs/tab-button.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { h, ref, useTemplateRef, watch } from 'vue'\nimport { CloseIcon } from '@dou-ui/icons'\nimport { useNamespace } from '../../utils/namespace'\nimport { useLocale } from '../config-provider/use-config'\nimport { DouTooltip } from '../tooltip'\nimport { resolveTruncatedTitle } from './truncated-title'\nimport type { FunctionalComponent, VNode } from 'vue'\nimport type { TabPanelEntry } from './tabs'\n\ndefineOptions({ name: 'DouTabButton' })\n\nconst props = defineProps<{\n entry: TabPanelEntry\n tabId: string\n panelId: string\n labelText: string\n selected: boolean\n closable: boolean\n iconAlone: boolean\n draggable: boolean\n dragging: boolean\n mergeTarget?: boolean\n tipPlacement: 'top' | 'right' | 'left'\n keyShortcuts?: string\n setEl: (el: unknown) => void\n}>()\n\nconst emit = defineEmits<{\n click: []\n pointerdown: [event: PointerEvent]\n keydown: [event: KeyboardEvent]\n remove: []\n}>()\n\nconst ns = useNamespace('tabs')\nconst { t } = useLocale()\nconst onButtonRef = (el: unknown) => props.setEl(el)\n\n// A label cut short by an ellipsis shows the full text as a native title on\n// hover. Measured lazily on pointerenter so idle tabs pay nothing, and skipped\n// for icon-alone tabs which already have a DouTooltip.\nconst labelRef = useTemplateRef<HTMLElement>('label')\nconst tabTitle = ref<string>()\nfunction updateTitle() {\n if (props.iconAlone) {\n tabTitle.value = undefined\n return\n }\n tabTitle.value = resolveTruncatedTitle(labelRef.value, props.entry.props.label)\n}\nwatch([() => props.labelText, () => props.iconAlone], () => {\n tabTitle.value = undefined\n})\n\n/** The label slot of a panel, rendered inside its tab. */\nconst TabLabel: FunctionalComponent = () =>\n (props.entry.slots.label?.({ selected: props.selected }) as VNode[] | undefined) ??\n props.labelText\n\nconst TabTip: FunctionalComponent = (_, { slots: tip }) =>\n props.iconAlone\n ? h(DouTooltip, { content: props.labelText, placement: props.tipPlacement }, tip)\n : tip.default?.()\n</script>\n\n<template>\n <TabTip>\n <button\n :id=\"tabId\"\n :ref=\"onButtonRef\"\n type=\"button\"\n role=\"tab\"\n :class=\"[\n ns.e('tab'),\n ns.is('selected', selected),\n ns.is('disabled', !!entry.props.disabled),\n ns.is('closable', closable),\n ns.is('icon-alone', iconAlone),\n ns.is('pinned', !!entry.props.pinned),\n ns.is('draggable', draggable),\n ns.is('dragging', dragging),\n ns.is('merge-target', !!mergeTarget),\n ]\"\n :title=\"tabTitle\"\n :aria-selected=\"selected\"\n :aria-controls=\"panelId\"\n :aria-label=\"iconAlone ? labelText : undefined\"\n :aria-disabled=\"entry.props.disabled || undefined\"\n :tabindex=\"selected ? 0 : -1\"\n :aria-keyshortcuts=\"keyShortcuts\"\n @click=\"emit('click')\"\n @pointerenter=\"updateTitle\"\n @pointerdown=\"emit('pointerdown', $event)\"\n @keydown=\"emit('keydown', $event)\"\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\" ref=\"label\" :class=\"ns.e('label')\" @pointerenter=\"updateTitle\">\n <TabLabel />\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=\"closable\"\n :content=\"t('tabs.close')\"\n shortcut=\"delete\"\n :disabled=\"iconAlone\"\n >\n <span\n :class=\"ns.e('close')\"\n :title=\"tabTitle ? '' : undefined\"\n aria-hidden=\"true\"\n @click.stop=\"emit('remove')\"\n >\n <CloseIcon />\n </span>\n </DouTooltip>\n </button>\n </TabTip>\n</template>\n"],"mappings":""}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { useNamespace } from "../../utils/namespace.js";
|
|
2
2
|
import { useLocale } from "../config-provider/use-config.js";
|
|
3
3
|
import { DouTooltip } from "../tooltip/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveTruncatedTitle } from "./truncated-title.js";
|
|
5
|
+
import { createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, h, normalizeClass, openBlock, ref, resolveDynamicComponent, unref, useTemplateRef, watch, withCtx, withModifiers } from "vue";
|
|
5
6
|
import { CloseIcon } from "@dou-ui/icons";
|
|
6
7
|
// src/components/tabs/tab-button.vue?vue&type=script&setup=true&lang.ts
|
|
7
8
|
var _hoisted_1 = [
|
|
8
9
|
"id",
|
|
10
|
+
"title",
|
|
9
11
|
"aria-selected",
|
|
10
12
|
"aria-controls",
|
|
11
13
|
"aria-label",
|
|
@@ -13,6 +15,7 @@ var _hoisted_1 = [
|
|
|
13
15
|
"tabindex",
|
|
14
16
|
"aria-keyshortcuts"
|
|
15
17
|
];
|
|
18
|
+
var _hoisted_2 = ["title"];
|
|
16
19
|
var tab_button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
17
20
|
name: "DouTabButton",
|
|
18
21
|
__name: "tab-button",
|
|
@@ -26,6 +29,7 @@ var tab_button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
26
29
|
iconAlone: { type: Boolean },
|
|
27
30
|
draggable: { type: Boolean },
|
|
28
31
|
dragging: { type: Boolean },
|
|
32
|
+
mergeTarget: { type: Boolean },
|
|
29
33
|
tipPlacement: {},
|
|
30
34
|
keyShortcuts: {},
|
|
31
35
|
setEl: { type: Function }
|
|
@@ -42,6 +46,18 @@ var tab_button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
42
46
|
const ns = useNamespace("tabs");
|
|
43
47
|
const { t } = useLocale();
|
|
44
48
|
const onButtonRef = (el) => props.setEl(el);
|
|
49
|
+
const labelRef = useTemplateRef("label");
|
|
50
|
+
const tabTitle = ref();
|
|
51
|
+
function updateTitle() {
|
|
52
|
+
if (props.iconAlone) {
|
|
53
|
+
tabTitle.value = void 0;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
tabTitle.value = resolveTruncatedTitle(labelRef.value, props.entry.props.label);
|
|
57
|
+
}
|
|
58
|
+
watch([() => props.labelText, () => props.iconAlone], () => {
|
|
59
|
+
tabTitle.value = void 0;
|
|
60
|
+
});
|
|
45
61
|
/** The label slot of a panel, rendered inside its tab. */
|
|
46
62
|
const TabLabel = () => props.entry.slots.label?.({ selected: props.selected }) ?? props.labelText;
|
|
47
63
|
const TabTip = (_, { slots: tip }) => props.iconAlone ? h(DouTooltip, {
|
|
@@ -63,8 +79,10 @@ var tab_button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
63
79
|
unref(ns).is("icon-alone", __props.iconAlone),
|
|
64
80
|
unref(ns).is("pinned", !!__props.entry.props.pinned),
|
|
65
81
|
unref(ns).is("draggable", __props.draggable),
|
|
66
|
-
unref(ns).is("dragging", __props.dragging)
|
|
82
|
+
unref(ns).is("dragging", __props.dragging),
|
|
83
|
+
unref(ns).is("merge-target", !!__props.mergeTarget)
|
|
67
84
|
]),
|
|
85
|
+
title: tabTitle.value,
|
|
68
86
|
"aria-selected": __props.selected,
|
|
69
87
|
"aria-controls": __props.panelId,
|
|
70
88
|
"aria-label": __props.iconAlone ? __props.labelText : void 0,
|
|
@@ -72,6 +90,7 @@ var tab_button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
72
90
|
tabindex: __props.selected ? 0 : -1,
|
|
73
91
|
"aria-keyshortcuts": __props.keyShortcuts,
|
|
74
92
|
onClick: _cache[1] || (_cache[1] = ($event) => emit("click")),
|
|
93
|
+
onPointerenter: updateTitle,
|
|
75
94
|
onPointerdown: _cache[2] || (_cache[2] = ($event) => emit("pointerdown", $event)),
|
|
76
95
|
onKeydown: _cache[3] || (_cache[3] = ($event) => emit("keydown", $event))
|
|
77
96
|
}, [
|
|
@@ -82,8 +101,10 @@ var tab_button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
82
101
|
}, null, 8, ["class"])) : createCommentVNode("", true),
|
|
83
102
|
!__props.iconAlone ? (openBlock(), createElementBlock("span", {
|
|
84
103
|
key: 1,
|
|
85
|
-
|
|
86
|
-
|
|
104
|
+
ref: "label",
|
|
105
|
+
class: normalizeClass(unref(ns).e("label")),
|
|
106
|
+
onPointerenter: updateTitle
|
|
107
|
+
}, [createVNode(TabLabel)], 34)) : createCommentVNode("", true),
|
|
87
108
|
__props.closable ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
88
109
|
key: 2,
|
|
89
110
|
content: unref(t)("tabs.close"),
|
|
@@ -92,9 +113,10 @@ var tab_button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
92
113
|
}, {
|
|
93
114
|
default: withCtx(() => [createElementVNode("span", {
|
|
94
115
|
class: normalizeClass(unref(ns).e("close")),
|
|
116
|
+
title: tabTitle.value ? "" : void 0,
|
|
95
117
|
"aria-hidden": "true",
|
|
96
118
|
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => emit("remove"), ["stop"]))
|
|
97
|
-
}, [createVNode(unref(CloseIcon))],
|
|
119
|
+
}, [createVNode(unref(CloseIcon))], 10, _hoisted_2)]),
|
|
98
120
|
_: 1
|
|
99
121
|
}, 8, ["content", "disabled"])) : createCommentVNode("", true)
|
|
100
122
|
], 42, _hoisted_1)]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-button.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_withCtx","_createElementVNode","_normalizeClass","_unref","_resolveDynamicComponent","_createCommentVNode","_createElementBlock","_createVNode","_withModifiers"],"sources":["../../../src/components/tabs/tab-button.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { h } from 'vue'\nimport { CloseIcon } from '@dou-ui/icons'\nimport { useNamespace } from '../../utils/namespace'\nimport { useLocale } from '../config-provider/use-config'\nimport { DouTooltip } from '../tooltip'\nimport type { FunctionalComponent, VNode } from 'vue'\nimport type { TabPanelEntry } from './tabs'\n\ndefineOptions({ name: 'DouTabButton' })\n\nconst props = defineProps<{\n entry: TabPanelEntry\n tabId: string\n panelId: string\n labelText: string\n selected: boolean\n closable: boolean\n iconAlone: boolean\n draggable: boolean\n dragging: boolean\n tipPlacement: 'top' | 'right' | 'left'\n keyShortcuts?: string\n setEl: (el: unknown) => void\n}>()\n\nconst emit = defineEmits<{\n click: []\n pointerdown: [event: PointerEvent]\n keydown: [event: KeyboardEvent]\n remove: []\n}>()\n\nconst ns = useNamespace('tabs')\nconst { t } = useLocale()\nconst onButtonRef = (el: unknown) => props.setEl(el)\n\n/** The label slot of a panel, rendered inside its tab. */\nconst TabLabel: FunctionalComponent = () =>\n (props.entry.slots.label?.({ selected: props.selected }) as VNode[] | undefined) ??\n props.labelText\n\nconst TabTip: FunctionalComponent = (_, { slots: tip }) =>\n props.iconAlone\n ? h(DouTooltip, { content: props.labelText, placement: props.tipPlacement }, tip)\n : tip.default?.()\n</script>\n\n<template>\n <TabTip>\n <button\n :id=\"tabId\"\n :ref=\"onButtonRef\"\n type=\"button\"\n role=\"tab\"\n :class=\"[\n ns.e('tab'),\n ns.is('selected', selected),\n ns.is('disabled', !!entry.props.disabled),\n ns.is('closable', closable),\n ns.is('icon-alone', iconAlone),\n ns.is('pinned', !!entry.props.pinned),\n ns.is('draggable', draggable),\n ns.is('dragging', dragging),\n ]\"\n :aria-selected=\"selected\"\n :aria-controls=\"panelId\"\n :aria-label=\"iconAlone ? labelText : undefined\"\n :aria-disabled=\"entry.props.disabled || undefined\"\n :tabindex=\"selected ? 0 : -1\"\n :aria-keyshortcuts=\"keyShortcuts\"\n @click=\"emit('click')\"\n @pointerdown=\"emit('pointerdown', $event)\"\n @keydown=\"emit('keydown', $event)\"\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\" :class=\"ns.e('label')\">\n <TabLabel />\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=\"closable\"\n :content=\"t('tabs.close')\"\n shortcut=\"delete\"\n :disabled=\"iconAlone\"\n >\n <span
|
|
1
|
+
{"version":3,"file":"tab-button.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_withCtx","_createElementVNode","_normalizeClass","_unref","_resolveDynamicComponent","_createCommentVNode","_createElementBlock","_createVNode","_withModifiers"],"sources":["../../../src/components/tabs/tab-button.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { h, ref, useTemplateRef, watch } from 'vue'\nimport { CloseIcon } from '@dou-ui/icons'\nimport { useNamespace } from '../../utils/namespace'\nimport { useLocale } from '../config-provider/use-config'\nimport { DouTooltip } from '../tooltip'\nimport { resolveTruncatedTitle } from './truncated-title'\nimport type { FunctionalComponent, VNode } from 'vue'\nimport type { TabPanelEntry } from './tabs'\n\ndefineOptions({ name: 'DouTabButton' })\n\nconst props = defineProps<{\n entry: TabPanelEntry\n tabId: string\n panelId: string\n labelText: string\n selected: boolean\n closable: boolean\n iconAlone: boolean\n draggable: boolean\n dragging: boolean\n mergeTarget?: boolean\n tipPlacement: 'top' | 'right' | 'left'\n keyShortcuts?: string\n setEl: (el: unknown) => void\n}>()\n\nconst emit = defineEmits<{\n click: []\n pointerdown: [event: PointerEvent]\n keydown: [event: KeyboardEvent]\n remove: []\n}>()\n\nconst ns = useNamespace('tabs')\nconst { t } = useLocale()\nconst onButtonRef = (el: unknown) => props.setEl(el)\n\n// A label cut short by an ellipsis shows the full text as a native title on\n// hover. Measured lazily on pointerenter so idle tabs pay nothing, and skipped\n// for icon-alone tabs which already have a DouTooltip.\nconst labelRef = useTemplateRef<HTMLElement>('label')\nconst tabTitle = ref<string>()\nfunction updateTitle() {\n if (props.iconAlone) {\n tabTitle.value = undefined\n return\n }\n tabTitle.value = resolveTruncatedTitle(labelRef.value, props.entry.props.label)\n}\nwatch([() => props.labelText, () => props.iconAlone], () => {\n tabTitle.value = undefined\n})\n\n/** The label slot of a panel, rendered inside its tab. */\nconst TabLabel: FunctionalComponent = () =>\n (props.entry.slots.label?.({ selected: props.selected }) as VNode[] | undefined) ??\n props.labelText\n\nconst TabTip: FunctionalComponent = (_, { slots: tip }) =>\n props.iconAlone\n ? h(DouTooltip, { content: props.labelText, placement: props.tipPlacement }, tip)\n : tip.default?.()\n</script>\n\n<template>\n <TabTip>\n <button\n :id=\"tabId\"\n :ref=\"onButtonRef\"\n type=\"button\"\n role=\"tab\"\n :class=\"[\n ns.e('tab'),\n ns.is('selected', selected),\n ns.is('disabled', !!entry.props.disabled),\n ns.is('closable', closable),\n ns.is('icon-alone', iconAlone),\n ns.is('pinned', !!entry.props.pinned),\n ns.is('draggable', draggable),\n ns.is('dragging', dragging),\n ns.is('merge-target', !!mergeTarget),\n ]\"\n :title=\"tabTitle\"\n :aria-selected=\"selected\"\n :aria-controls=\"panelId\"\n :aria-label=\"iconAlone ? labelText : undefined\"\n :aria-disabled=\"entry.props.disabled || undefined\"\n :tabindex=\"selected ? 0 : -1\"\n :aria-keyshortcuts=\"keyShortcuts\"\n @click=\"emit('click')\"\n @pointerenter=\"updateTitle\"\n @pointerdown=\"emit('pointerdown', $event)\"\n @keydown=\"emit('keydown', $event)\"\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\" ref=\"label\" :class=\"ns.e('label')\" @pointerenter=\"updateTitle\">\n <TabLabel />\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=\"closable\"\n :content=\"t('tabs.close')\"\n shortcut=\"delete\"\n :disabled=\"iconAlone\"\n >\n <span\n :class=\"ns.e('close')\"\n :title=\"tabTitle ? '' : undefined\"\n aria-hidden=\"true\"\n @click.stop=\"emit('remove')\"\n >\n <CloseIcon />\n </span>\n </DouTooltip>\n </button>\n </TabTip>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,MAAM,QAAQ;EAgBd,MAAM,OAAO;EAOb,MAAM,KAAK,aAA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@@ import { shallowRef } from "vue";
|
|
|
4
4
|
var zones = /* @__PURE__ */ new Map();
|
|
5
5
|
/** The drag in progress, if any. */
|
|
6
6
|
var activeTabDrag = shallowRef(null);
|
|
7
|
+
var tabMergeTargetKey = Symbol("DouTabMergeTarget");
|
|
7
8
|
function registerTabDropZone(zone) {
|
|
8
9
|
let el;
|
|
9
10
|
return {
|
|
@@ -75,7 +76,10 @@ function pressTab(event, options) {
|
|
|
75
76
|
if (options.ghost) {
|
|
76
77
|
clone = document.createElement("div");
|
|
77
78
|
clone.className = "dou-tabs__tab";
|
|
78
|
-
|
|
79
|
+
const text = document.createElement("span");
|
|
80
|
+
text.className = "dou-tabs__label";
|
|
81
|
+
text.textContent = options.ghost.label;
|
|
82
|
+
clone.append(text);
|
|
79
83
|
} else {
|
|
80
84
|
clone = options.el.cloneNode(true);
|
|
81
85
|
clone.removeAttribute("id");
|
|
@@ -102,8 +106,12 @@ function pressTab(event, options) {
|
|
|
102
106
|
for (const name of [
|
|
103
107
|
"--dou-tabs-height",
|
|
104
108
|
"--dou-tabs-padding-x",
|
|
105
|
-
"--dou-tabs-icon-size"
|
|
106
|
-
|
|
109
|
+
"--dou-tabs-icon-size",
|
|
110
|
+
"--dou-tabs-tab-max-width"
|
|
111
|
+
]) {
|
|
112
|
+
const value = style.getPropertyValue(name);
|
|
113
|
+
if (value) clone.style.setProperty(name, value);
|
|
114
|
+
}
|
|
107
115
|
clone.style.fontSize = style.fontSize;
|
|
108
116
|
}
|
|
109
117
|
const theme = (tabs ?? options.el).closest("[data-dou-theme]")?.dataset.douTheme;
|
|
@@ -184,6 +192,6 @@ function pressTab(event, options) {
|
|
|
184
192
|
window.addEventListener("pointercancel", onCancel);
|
|
185
193
|
window.addEventListener("keydown", onKey, true);
|
|
186
194
|
}
|
|
187
|
-
export { activeTabDrag, isIgnoredDragPress, pressTab, registerTabDropZone };
|
|
195
|
+
export { activeTabDrag, isIgnoredDragPress, pressTab, registerTabDropZone, tabMergeTargetKey };
|
|
188
196
|
|
|
189
197
|
//# 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 /** 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,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,mBAAmB,OAAqB;CACtD,OAAO,MAAM,WAAW,KAAK,MAAM,WAAW,MAAM,WAAW,MAAM,YAAY,MAAM;AACzF;;;;;;AAOA,SAAgB,SAAS,OAAqB,SAA8B;CAC1E,IAAI,mBAAmB,KAAK,KAAK,cAAc,OAAO;CACtD,MAAM,QAAQ;EAAE,GAAG,MAAM;EAAS,GAAG,MAAM;CAA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xB;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 { InjectionKey, Ref } from 'vue'\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\n/**\n * Internal bridge for `DouDock` to report whether dropping `drag` onto a\n * group's tab bar or center body will merge into an existing tab instead of inserting.\n */\nexport interface TabMergeBridge {\n resolve: (drag: TabDrag) => TabsValue | undefined\n active: Ref<TabsValue | null>\n}\nexport const tabMergeTargetKey: InjectionKey<TabMergeBridge> = Symbol('DouTabMergeTarget')\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 const text = document.createElement('span')\n text.className = 'dou-tabs__label'\n text.textContent = options.ghost.label\n clone.append(text)\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 [\n '--dou-tabs-height',\n '--dou-tabs-padding-x',\n '--dou-tabs-icon-size',\n '--dou-tabs-tab-max-width',\n ]) {\n const value = style.getPropertyValue(name)\n if (value) clone.style.setProperty(name, value)\n }\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":";;;AAiCA,IAAM,wBAAQ,IAAI,IAA0B;;AAG5C,IAAa,gBAAgB,WAA2B,IAAI;AAU5D,IAAa,oBAAkD,OAAO,mBAAmB;AAEzF,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,mBAAmB,OAAqB;CACtD,OAAO,MAAM,WAAW,KAAK,MAAM,WAAW,MAAM,WAAW,MAAM,YAAY,MAAM;AACzF;;;;;;AAOA,SAAgB,SAAS,OAAqB,SAA8B;CAC1E,IAAI,mBAAmB,KAAK,KAAK,cAAc,OAAO;CACtD,MAAM,QAAQ;EAAE,GAAG,MAAM;EAAS,GAAG,MAAM;CAAQ;CACnD,MAAM,QAAQ,MAAM,gBAAgB;CACpC,IAAI,QAAQ,CAAC;CACb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