dou-ui 0.1.0-alpha.21 → 0.1.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/chat-input/chat-input.vue_vue_type_script_setup_true_lang.js +19 -14
- package/dist/components/chat-input/chat-input.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/chat-input/chat-input2.js.map +1 -1
- package/dist/components/chat-list/chat-list.js.map +1 -1
- package/dist/components/chat-list/chat-list.vue_vue_type_script_setup_true_lang.js +51 -19
- package/dist/components/chat-list/chat-list.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/chat-list/chat-list2.js.map +1 -1
- package/dist/components/chat-message/chat-message.js.map +1 -1
- package/dist/components/chat-message/chat-message.vue_vue_type_script_setup_true_lang.js +52 -12
- package/dist/components/chat-message/chat-message.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/chat-message/chat-message2.js.map +1 -1
- package/dist/components/chat-plan/chat-plan.js.map +1 -1
- package/dist/components/chat-plan/chat-plan.vue_vue_type_script_setup_true_lang.js +22 -9
- package/dist/components/chat-plan/chat-plan.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/chat-plan/chat-plan2.js.map +1 -1
- 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 +144 -7
- package/dist/components/code-block/code-block.vue_vue_type_script_setup_true_lang.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 +4 -2
- 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 +30 -4
- package/dist/components/dock/dock.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/dock/style.js +1 -0
- package/dist/components/form/form.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/components/form/form.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/form/form2.js.map +1 -1
- package/dist/components/image/image-preview.js.map +1 -1
- package/dist/components/image/image-preview.vue_vue_type_script_setup_true_lang.js +63 -95
- package/dist/components/image/image-preview.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/image/use-preview-viewport.js +619 -0
- package/dist/components/image/use-preview-viewport.js.map +1 -0
- package/dist/components/image/viewport.js +142 -0
- package/dist/components/image/viewport.js.map +1 -0
- package/dist/components/link/link.js.map +1 -1
- package/dist/components/link/link.vue_vue_type_script_setup_true_lang.js +59 -14
- package/dist/components/link/link.vue_vue_type_script_setup_true_lang.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 +13 -3
- package/dist/components/popover/popover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/splitter/splitter.js.map +1 -1
- package/dist/components/splitter/splitter.vue_vue_type_script_setup_true_lang.js +111 -41
- package/dist/components/splitter/splitter.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tabs/style.js +1 -0
- package/dist/components/tabs/tab-button.js +6 -0
- package/dist/components/tabs/tab-button.js.map +1 -0
- package/dist/components/tabs/tab-button.vue_vue_type_script_setup_true_lang.js +108 -0
- package/dist/components/tabs/tab-button.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/tabs/tab-drag.js +10 -2
- package/dist/components/tabs/tab-drag.js.map +1 -1
- package/dist/components/tabs/tab-panel.js.map +1 -1
- package/dist/components/tabs/tab-panel.vue_vue_type_script_setup_true_lang.js +4 -0
- package/dist/components/tabs/tab-panel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/tabs/tabs.vue_vue_type_script_setup_true_lang.js +430 -181
- 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/virtual-list/virtual-list.vue_vue_type_script_setup_true_lang.js +77 -34
- package/dist/components/virtual-list/virtual-list.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/virtual-list/virtual-list2.js.map +1 -1
- package/dist/composables/use-floating.js +60 -8
- package/dist/composables/use-floating.js.map +1 -1
- package/dist/composables/use-measured-sizes.js +7 -3
- package/dist/composables/use-measured-sizes.js.map +1 -1
- package/dist/composables/use-popup.js +3 -0
- package/dist/composables/use-popup.js.map +1 -1
- package/dist/composables/use-touch-scroll.js +141 -29
- package/dist/composables/use-touch-scroll.js.map +1 -1
- package/dist/locale/en.js +3 -2
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/zh-cn.js +3 -2
- package/dist/locale/zh-cn.js.map +1 -1
- package/dist/locale/zh-tw.js +3 -2
- package/dist/locale/zh-tw.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/components/chat-list/chat-list.d.ts +13 -0
- package/dist/types/components/chat-list/index.d.ts +2 -0
- package/dist/types/components/chat-message/chat-message.d.ts +19 -0
- package/dist/types/components/chat-message/chat-message.vue.d.ts +1 -0
- package/dist/types/components/chat-message/index.d.ts +3 -0
- package/dist/types/components/chat-plan/chat-plan.d.ts +3 -1
- package/dist/types/components/chat-plan/chat-plan.vue.d.ts +1 -0
- package/dist/types/components/chat-plan/index.d.ts +3 -0
- package/dist/types/components/code-block/code-block.d.ts +23 -0
- package/dist/types/components/code-block/code-block.vue.d.ts +8 -2
- package/dist/types/components/code-block/index.d.ts +19 -3
- package/dist/types/components/dock/dock.d.ts +6 -0
- package/dist/types/components/image/image.d.ts +1 -1
- package/dist/types/components/image/use-preview-viewport.d.ts +48 -0
- package/dist/types/components/image/viewport.d.ts +58 -0
- package/dist/types/components/link/index.d.ts +3 -0
- package/dist/types/components/link/link.d.ts +12 -3
- package/dist/types/components/link/link.vue.d.ts +1 -0
- package/dist/types/components/popover/index.d.ts +3 -0
- package/dist/types/components/popover/popover.d.ts +7 -0
- package/dist/types/components/popover/popover.vue.d.ts +1 -0
- package/dist/types/components/splitter/index.d.ts +6 -9
- package/dist/types/components/splitter/splitter.d.ts +31 -4
- package/dist/types/components/splitter/splitter.vue.d.ts +3 -4
- package/dist/types/components/tabs/index.d.ts +3 -0
- package/dist/types/components/tabs/tab-button.vue.d.ts +28 -0
- package/dist/types/components/tabs/tab-drag.d.ts +8 -0
- package/dist/types/components/tabs/tab-panel.vue.d.ts +1 -0
- package/dist/types/components/tabs/tabs.d.ts +6 -0
- package/dist/types/composables/use-floating.d.ts +1 -1
- package/dist/types/composables/use-measured-sizes.d.ts +2 -0
- package/dist/types/composables/use-touch-scroll.d.ts +8 -0
- package/dist/types/locale/types.d.ts +6 -3
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"splitter.js","names":["_sfc_main"],"sources":["../../../src/components/splitter/splitter.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n shallowReactive,\n useId,\n useTemplateRef,\n watchEffect,\n} from 'vue'\nimport { useElementSize } from '../../composables/use-element-size'\nimport { useNamespace } from '../../utils/namespace'\nimport { devWarn } from '../../utils/status-check'\nimport { useLocale } from '../config-provider/use-config'\nimport { splitterContextKey } from './context'\nimport type { SplitterMinSize } from './context'\nimport type { SplitterLimit, SplitterProps, SplitterSlots } from './splitter'\n\ndefineOptions({ name: 'DouSplitter' })\n\nconst props = withDefaults(defineProps<SplitterProps>(), {\n direction: 'horizontal',\n min: 0,\n max: 100,\n minEnd: 0,\n collapsible: false,\n step: 1,\n disabled: false,\n})\nconst size = defineModel<number>({ default: 50 })\nconst collapsed = defineModel<boolean>('collapsed', { default: false })\nconst emit = defineEmits<{ change: [value: number] }>()\ndefineSlots<SplitterSlots>()\n\nconst ns = useNamespace('splitter')\nconst { t } = useLocale()\nconst startId = `dou-splitter-${useId()}-start`\nconst root = useTemplateRef<HTMLElement>('root')\n\nconst horizontal = computed(() => props.direction === 'horizontal')\n// Kept up to date, so px limits still hold when the container resizes\nconst box = useElementSize(root, { box: 'border-box' })\n// the divider is a 1px line; the panes share the rest, so limits are a share of that\nconst BAR = 1\nconst length = () => Math.max(0, (horizontal.value ? box.width.value : box.height.value) - BAR)\n\nif (process.env.NODE_ENV !== 'production')\n watchEffect(() => {\n for (const [name, limit] of [\n ['min', props.min],\n ['max', props.max],\n ['minEnd', props.minEnd],\n ] as const)\n if (typeof limit === 'string' && !/^\\s*\\d+(?:\\.\\d+)?px\\s*$/.test(limit))\n devWarn(\n `[dou-ui] DouSplitter: \\`${name}\\` is \"${limit}\"; use a number for percent or a length in px such as '240px'.`,\n )\n })\n\nconst px = (limit: SplitterLimit) => (typeof limit === 'string' ? Number.parseFloat(limit) || 0 : 0)\n// px as a percentage of the splitter, 0 until it is measured\nfunction share(value: number) {\n const total = length()\n return total ? (value / total) * 100 : 0\n}\nconst percent = (limit: SplitterLimit) => (typeof limit === 'number' ? limit : 0)\n\n/* splitters inside the panes: their px limits add up to a minimum for the pane */\n\nconst startPane = useTemplateRef<HTMLElement>('startPane')\nconst endPane = useTemplateRef<HTMLElement>('endPane')\nconst nested = shallowReactive(new Map<HTMLElement, () => SplitterMinSize>())\nprovide(splitterContextKey, {\n register(el, measureNeed) {\n nested.set(el, measureNeed)\n return () => nested.delete(el)\n },\n})\nfunction inside(pane: HTMLElement | null): SplitterMinSize {\n const need = { width: 0, height: 0 }\n for (const [el, measureNeed] of nested) {\n if (!pane?.contains(el)) continue\n const { width, height } = measureNeed()\n need.width = Math.max(need.width, width)\n need.height = Math.max(need.height, height)\n }\n return need\n}\nconst needs = computed(() => {\n const main = horizontal.value ? 'width' : 'height'\n const cross = horizontal.value ? 'height' : 'width'\n const start = inside(startPane.value)\n const end = inside(endPane.value)\n return {\n start: Math.max(px(props.min), start[main]),\n end: Math.max(px(props.minEnd), end[main]),\n cross: Math.max(collapsed.value ? 0 : start[cross], end[cross]),\n }\n})\nconst parent = inject(splitterContextKey, null)\nlet unregister: (() => void) | undefined\nonMounted(() => {\n unregister = root.value\n ? parent?.register(root.value, () => {\n const { start, end, cross } = needs.value\n const along = (collapsed.value ? 0 : start) + BAR + end\n return horizontal.value ? { width: along, height: cross } : { width: cross, height: along }\n })\n : undefined\n})\nonBeforeUnmount(() => unregister?.())\n\nconst bounds = () => {\n const min = Math.max(0, percent(props.min), share(needs.value.start))\n const end = Math.max(0, percent(props.minEnd), share(needs.value.end))\n // Too small for both minimums: they share the room in proportion\n if (min + end > 100) {\n const at = (min / (min + end)) * 100\n return { min: at, max: at }\n }\n const max = typeof props.max === 'number' ? props.max : share(px(props.max))\n return { min, max: Math.max(min, Math.min(100 - end, max)) }\n}\nconst round = (value: number) => Math.round(value * 100) / 100\nfunction clamp(value: number) {\n const { min, max } = bounds()\n const next = round(Math.min(max, Math.max(min, value)))\n // rounding must not push a pane below its minimum: round inwards at the limits\n if (next > max) return Math.floor(max * 100) / 100\n if (next < min) return Math.ceil(min * 100) / 100\n return next\n}\n\nfunction set(value: number) {\n const next = clamp(value)\n if (collapsed.value) collapsed.value = false\n if (next !== size.value) size.value = next\n}\n\nfunction toggle() {\n if (!props.collapsible || props.disabled) return\n collapsed.value = !collapsed.value\n emit('change', size.value)\n}\n\n/* dragging */\n\nconst dragging = ref(false)\nfunction onPointerdown(event: PointerEvent) {\n if (props.disabled || event.button !== 0) return\n event.preventDefault()\n ;(event.currentTarget as HTMLElement).setPointerCapture?.(event.pointerId)\n ;(event.currentTarget as HTMLElement).focus()\n dragging.value = true\n}\nfunction onPointermove(event: PointerEvent) {\n if (!dragging.value || !root.value) return\n const rect = root.value.getBoundingClientRect()\n const total = (horizontal.value ? rect.width : rect.height) - BAR\n if (total <= 0) return\n const at = (horizontal.value ? event.clientX - rect.left : event.clientY - rect.top) - BAR / 2\n set((at / total) * 100)\n}\nfunction onPointerup() {\n if (!dragging.value) return\n dragging.value = false\n emit('change', size.value)\n}\n\n/* keys */\n\nfunction onKeydown(event: KeyboardEvent) {\n if (props.disabled) return\n const step = props.step * (event.shiftKey ? 10 : 1)\n const back = horizontal.value ? 'ArrowLeft' : 'ArrowUp'\n const forth = horizontal.value ? 'ArrowRight' : 'ArrowDown'\n const current = shown.value\n let next: number | undefined\n if (event.key === back) next = current - step\n else if (event.key === forth) next = current + step\n else if (event.key === 'Home') next = bounds().min\n else if (event.key === 'End') next = bounds().max\n else if (event.key === 'Enter' && props.collapsible) {\n event.preventDefault()\n return toggle()\n } else return\n event.preventDefault()\n set(next)\n emit('change', size.value)\n}\n\n// What is on screen: the model value kept within the limits, which can\n// tighten as the container resizes. The model itself only changes when\n// someone moves the divider.\nconst shown = computed(() => {\n if (collapsed.value) return 0\n return clamp(size.value)\n})\nconst template = computed(\n () => `minmax(0, ${shown.value}fr) auto minmax(0, ${round(100 - shown.value)}fr)`,\n)\nconst style = computed(() =>\n horizontal.value ? { gridTemplateColumns: template.value } : { gridTemplateRows: template.value },\n)\nconst limits = computed(() => {\n // px limits count as 0 until the container is measured\n const { min, max } = bounds()\n return { min: Math.round(min), max: Math.round(max) }\n})\n</script>\n\n<template>\n <div\n ref=\"root\"\n :class=\"[\n ns.b(),\n ns.m(direction),\n ns.is('dragging', dragging),\n ns.is('collapsed', collapsed),\n ns.is('disabled', disabled),\n ]\"\n :style=\"style\"\n >\n <div ref=\"startPane\" :id=\"startId\" :class=\"[ns.e('pane'), ns.is('start', true)]\">\n <slot name=\"start\" />\n </div>\n <div\n role=\"separator\"\n :class=\"ns.e('bar')\"\n :tabindex=\"disabled ? undefined : 0\"\n :aria-orientation=\"horizontal ? 'vertical' : 'horizontal'\"\n :aria-valuenow=\"Math.round(shown)\"\n :aria-valuemin=\"limits.min\"\n :aria-valuemax=\"limits.max\"\n :aria-controls=\"startId\"\n :aria-label=\"ariaLabel ?? t('splitter.label')\"\n :aria-disabled=\"disabled || undefined\"\n @pointerdown=\"onPointerdown\"\n @pointermove=\"onPointermove\"\n @pointerup=\"onPointerup\"\n @pointercancel=\"onPointerup\"\n @keydown=\"onKeydown\"\n @dblclick=\"toggle\"\n >\n <span :class=\"ns.e('handle')\" aria-hidden=\"true\" />\n </div>\n <div ref=\"endPane\" :class=\"[ns.e('pane'), ns.is('end', true)]\">\n <slot name=\"end\" />\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"splitter.js","names":["_sfc_main"],"sources":["../../../src/components/splitter/splitter.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n shallowReactive,\n useId,\n useTemplateRef,\n watch,\n watchEffect,\n} from 'vue'\nimport { useElementSize } from '../../composables/use-element-size'\nimport { useNamespace } from '../../utils/namespace'\nimport { devWarn } from '../../utils/status-check'\nimport { useLocale } from '../config-provider/use-config'\nimport { splitterContextKey } from './context'\nimport type { SplitterMinSize } from './context'\nimport type { SplitterLimit, SplitterPane, SplitterProps, SplitterSlots } from './splitter'\n\ndefineOptions({ name: 'DouSplitter' })\n\nconst props = withDefaults(defineProps<SplitterProps>(), {\n direction: 'horizontal',\n unit: 'percent',\n min: 0,\n minEnd: 0,\n collapsible: false,\n singlePane: null,\n disabled: false,\n})\nconst collapsed = defineModel<boolean>('collapsed', { default: false })\nconst emit = defineEmits<{\n 'update:modelValue': [value: number]\n change: [value: number]\n}>()\ndefineSlots<SplitterSlots>()\n\nconst ns = useNamespace('splitter')\nconst { t } = useLocale()\nconst startId = `dou-splitter-${useId()}-start`\nconst root = useTemplateRef<HTMLElement>('root')\n\nconst horizontal = computed(() => props.direction === 'horizontal')\nconst isPx = computed(() => props.unit === 'px')\nconst activeSinglePane = computed<SplitterPane | null>(() =>\n props.singlePane === 'start' || props.singlePane === 'end' ? props.singlePane : null,\n)\nconst stepSize = computed(() => props.step ?? (isPx.value ? 10 : 1))\nconst localSize = ref<number | undefined>()\nconst currentSize = computed(() => props.modelValue ?? localSize.value ?? (isPx.value ? 240 : 50))\n\n// Kept up to date, so px limits and px mode still hold when the container resizes\nconst box = useElementSize(root, { box: 'border-box' })\n// the divider is a 1px line; the panes share the rest, so limits are a share of that\nconst BAR = 1\nconst length = () => Math.max(0, (horizontal.value ? box.width.value : box.height.value) - BAR)\n\nif (process.env.NODE_ENV !== 'production')\n watchEffect(() => {\n for (const [name, limit] of [\n ['min', props.min],\n ['max', props.max],\n ['minEnd', props.minEnd],\n ] as const)\n if (typeof limit === 'string' && !/^\\s*\\d+(?:\\.\\d+)?px\\s*$/.test(limit))\n devWarn(\n `[dou-ui] DouSplitter: \\`${name}\\` is \"${limit}\"; use a number for percent or a length in px such as '240px'.`,\n )\n })\n\nconst limitPx = (limit: SplitterLimit | undefined) => {\n if (typeof limit === 'string') return Number.parseFloat(limit) || 0\n if (typeof limit === 'number' && isPx.value) return limit\n return 0\n}\n// px as a percentage of the splitter, 0 until it is measured\nfunction share(value: number) {\n const total = length()\n return total ? (value / total) * 100 : 0\n}\nconst limitPercent = (limit: SplitterLimit | undefined) =>\n typeof limit === 'number' && !isPx.value ? limit : 0\n\n/* splitters inside the panes: their px limits add up to a minimum for the pane */\n\nconst startPane = useTemplateRef<HTMLElement>('startPane')\nconst endPane = useTemplateRef<HTMLElement>('endPane')\nconst nested = shallowReactive(new Map<HTMLElement, () => SplitterMinSize>())\nprovide(splitterContextKey, {\n register(el, measureNeed) {\n nested.set(el, measureNeed)\n return () => nested.delete(el)\n },\n})\nfunction inside(pane: HTMLElement | null): SplitterMinSize {\n const need = { width: 0, height: 0 }\n for (const [el, measureNeed] of nested) {\n if (!pane?.contains(el)) continue\n const { width, height } = measureNeed()\n need.width = Math.max(need.width, width)\n need.height = Math.max(need.height, height)\n }\n return need\n}\nconst needs = computed(() => {\n const main = horizontal.value ? 'width' : 'height'\n const cross = horizontal.value ? 'height' : 'width'\n const start = inside(startPane.value)\n const end = inside(endPane.value)\n const hideStart = activeSinglePane.value === 'end' || (!activeSinglePane.value && collapsed.value)\n const hideEnd = activeSinglePane.value === 'start'\n return {\n start: Math.max(limitPx(props.min), start[main]),\n end: Math.max(limitPx(props.minEnd), end[main]),\n cross: Math.max(hideStart ? 0 : start[cross], hideEnd ? 0 : end[cross]),\n }\n})\nconst parent = inject(splitterContextKey, null)\nlet unregister: (() => void) | undefined\nonMounted(() => {\n unregister = root.value\n ? parent?.register(root.value, () => {\n const { start, end, cross } = needs.value\n let along: number\n if (activeSinglePane.value === 'start') along = start\n else if (activeSinglePane.value === 'end') along = end\n else along = (collapsed.value ? 0 : start) + BAR + end\n return horizontal.value ? { width: along, height: cross } : { width: cross, height: along }\n })\n : undefined\n})\nonBeforeUnmount(() => unregister?.())\n\nconst bounds = () => {\n if (isPx.value) {\n const min = Math.max(0, needs.value.start)\n const end = Math.max(0, needs.value.end)\n const explicitMax = props.max === undefined ? Infinity : Math.max(0, limitPx(props.max))\n const total = length()\n if (total > 0) {\n // Too small for both minimums: they share the room in proportion\n if (min + end > total) {\n const at = (min / (min + end)) * total\n return { min: at, max: at }\n }\n return { min, max: Math.max(min, Math.min(total - end, explicitMax)) }\n }\n return { min, max: Math.max(min, explicitMax) }\n }\n const min = Math.max(0, limitPercent(props.min), share(needs.value.start))\n const end = Math.max(0, limitPercent(props.minEnd), share(needs.value.end))\n // Too small for both minimums: they share the room in proportion\n if (min + end > 100) {\n const at = (min / (min + end)) * 100\n return { min: at, max: at }\n }\n const max =\n props.max === undefined\n ? 100\n : typeof props.max === 'number'\n ? props.max\n : share(limitPx(props.max))\n return { min, max: Math.max(min, Math.min(100 - end, max)) }\n}\nconst round = (value: number) => Math.round(value * 100) / 100\nfunction clamp(value: number) {\n const { min, max } = bounds()\n const bounded = Math.min(max, Math.max(min, value))\n if (isPx.value) {\n if (Math.ceil(min) > Math.floor(max)) return round(bounded)\n const next = Math.round(bounded)\n if (next > max) return Math.floor(max)\n if (next < min) return Math.ceil(min)\n return next\n }\n const next = round(bounded)\n // rounding must not push a pane below its minimum: round inwards at the limits\n if (next > max) return Math.floor(max * 100) / 100\n if (next < min) return Math.ceil(min * 100) / 100\n return next\n}\n\nfunction set(value: number) {\n const next = clamp(value)\n if (collapsed.value) collapsed.value = false\n if (next !== currentSize.value) {\n localSize.value = next\n emit('update:modelValue', next)\n }\n return next\n}\n\nfunction toggle() {\n if (!props.collapsible || props.disabled || activeSinglePane.value) return\n collapsed.value = !collapsed.value\n emit('change', currentSize.value)\n}\n\n/* dragging */\n\nconst dragging = ref(false)\nlet dragValue = 0\nwatch(activeSinglePane, (pane) => {\n if (pane) dragging.value = false\n})\nfunction onPointerdown(event: PointerEvent) {\n if (props.disabled || activeSinglePane.value || event.button !== 0) return\n event.preventDefault()\n ;(event.currentTarget as HTMLElement).setPointerCapture?.(event.pointerId)\n ;(event.currentTarget as HTMLElement).focus()\n dragValue = currentSize.value\n dragging.value = true\n}\nfunction onPointermove(event: PointerEvent) {\n if (!dragging.value || !root.value) return\n const rect = root.value.getBoundingClientRect()\n const total = (horizontal.value ? rect.width : rect.height) - BAR\n if (total <= 0) return\n const at = (horizontal.value ? event.clientX - rect.left : event.clientY - rect.top) - BAR / 2\n dragValue = set(isPx.value ? at : (at / total) * 100)\n}\nfunction onPointerup() {\n if (!dragging.value) return\n dragging.value = false\n emit('change', dragValue)\n}\n\n/* keys */\n\nfunction onKeydown(event: KeyboardEvent) {\n if (props.disabled || activeSinglePane.value) return\n const step = stepSize.value * (event.shiftKey ? 10 : 1)\n const back = horizontal.value ? 'ArrowLeft' : 'ArrowUp'\n const forth = horizontal.value ? 'ArrowRight' : 'ArrowDown'\n const current = shown.value\n let next: number | undefined\n if (event.key === back) next = current - step\n else if (event.key === forth) next = current + step\n else if (event.key === 'Home') next = bounds().min\n else if (event.key === 'End') {\n const { max } = bounds()\n if (!Number.isFinite(max)) return\n next = max\n } else if (event.key === 'Enter' && props.collapsible) {\n event.preventDefault()\n return toggle()\n } else return\n event.preventDefault()\n const committed = set(next)\n emit('change', committed)\n}\n\n// What is on screen: the model value kept within the limits, which can\n// tighten as the container resizes. The model itself only changes when\n// someone moves the divider.\nconst shown = computed(() => {\n if (collapsed.value) return 0\n return clamp(currentSize.value)\n})\nconst template = computed(() => {\n if (activeSinglePane.value) return 'minmax(0, 1fr)'\n if (isPx.value) return `${shown.value}px auto minmax(0, 1fr)`\n return `minmax(0, ${shown.value}fr) auto minmax(0, ${round(100 - shown.value)}fr)`\n})\nconst style = computed(() =>\n horizontal.value ? { gridTemplateColumns: template.value } : { gridTemplateRows: template.value },\n)\nconst limits = computed(() => {\n // px limits count as 0 until the container is measured in percent mode\n const { min, max } = bounds()\n return {\n min: Math.round(min),\n max: Number.isFinite(max) ? Math.round(max) : undefined,\n }\n})\n</script>\n\n<template>\n <div\n ref=\"root\"\n :class=\"[\n ns.b(),\n ns.m(direction),\n ns.is('dragging', dragging),\n ns.is('collapsed', collapsed && !activeSinglePane),\n ns.is('disabled', disabled),\n ns.is('single-pane', !!activeSinglePane),\n ns.is('single-start', activeSinglePane === 'start'),\n ns.is('single-end', activeSinglePane === 'end'),\n ]\"\n :style=\"style\"\n >\n <div\n ref=\"startPane\"\n :id=\"startId\"\n :class=\"[ns.e('pane'), ns.is('start', true)]\"\n :hidden=\"activeSinglePane === 'end' || undefined\"\n >\n <slot name=\"start\" />\n </div>\n <div\n role=\"separator\"\n :class=\"ns.e('bar')\"\n :hidden=\"!!activeSinglePane || undefined\"\n :tabindex=\"disabled || activeSinglePane ? undefined : 0\"\n :aria-orientation=\"horizontal ? 'vertical' : 'horizontal'\"\n :aria-valuenow=\"Math.round(shown)\"\n :aria-valuemin=\"limits.min\"\n :aria-valuemax=\"limits.max\"\n :aria-controls=\"startId\"\n :aria-label=\"ariaLabel ?? t('splitter.label')\"\n :aria-disabled=\"disabled || undefined\"\n @pointerdown=\"onPointerdown\"\n @pointermove=\"onPointermove\"\n @pointerup=\"onPointerup\"\n @pointercancel=\"onPointerup\"\n @keydown=\"onKeydown\"\n @dblclick=\"toggle\"\n >\n <span :class=\"ns.e('handle')\" aria-hidden=\"true\" />\n </div>\n <div\n ref=\"endPane\"\n :class=\"[ns.e('pane'), ns.is('end', true)]\"\n :hidden=\"activeSinglePane === 'start' || undefined\"\n >\n <slot name=\"end\" />\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -3,9 +3,11 @@ import { useLocale } from "../config-provider/use-config.js";
|
|
|
3
3
|
import { devWarn } from "../../utils/status-check.js";
|
|
4
4
|
import { useElementSize } from "../../composables/use-element-size.js";
|
|
5
5
|
import { splitterContextKey } from "./context.js";
|
|
6
|
-
import { computed, createElementBlock, createElementVNode, defineComponent, inject, mergeModels, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, ref, renderSlot, shallowReactive, unref, useId, useModel, useTemplateRef, watchEffect } from "vue";
|
|
6
|
+
import { computed, createElementBlock, createElementVNode, defineComponent, inject, mergeModels, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, ref, renderSlot, shallowReactive, unref, useId, useModel, useTemplateRef, watch, watchEffect } from "vue";
|
|
7
7
|
// src/components/splitter/splitter.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
-
var _hoisted_1 = [
|
|
8
|
+
var _hoisted_1 = ["hidden"];
|
|
9
|
+
var _hoisted_2 = [
|
|
10
|
+
"hidden",
|
|
9
11
|
"tabindex",
|
|
10
12
|
"aria-orientation",
|
|
11
13
|
"aria-valuenow",
|
|
@@ -14,6 +16,7 @@ var _hoisted_1 = [
|
|
|
14
16
|
"aria-label",
|
|
15
17
|
"aria-disabled"
|
|
16
18
|
];
|
|
19
|
+
var _hoisted_3 = ["hidden"];
|
|
17
20
|
var BAR = 1;
|
|
18
21
|
var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
19
22
|
name: "DouSplitter",
|
|
@@ -21,33 +24,32 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
21
24
|
props: /*@__PURE__*/ mergeModels({
|
|
22
25
|
modelValue: {},
|
|
23
26
|
direction: { default: "horizontal" },
|
|
27
|
+
unit: { default: "percent" },
|
|
24
28
|
min: { default: 0 },
|
|
25
|
-
max: {
|
|
29
|
+
max: {},
|
|
26
30
|
minEnd: { default: 0 },
|
|
27
31
|
collapsible: {
|
|
28
32
|
type: Boolean,
|
|
29
33
|
default: false
|
|
30
34
|
},
|
|
31
35
|
collapsed: { type: Boolean },
|
|
32
|
-
|
|
36
|
+
singlePane: { default: null },
|
|
37
|
+
step: {},
|
|
33
38
|
disabled: {
|
|
34
39
|
type: Boolean,
|
|
35
40
|
default: false
|
|
36
41
|
},
|
|
37
42
|
ariaLabel: {}
|
|
38
43
|
}, {
|
|
39
|
-
"modelValue": { default: 50 },
|
|
40
|
-
"modelModifiers": {},
|
|
41
44
|
"collapsed": {
|
|
42
45
|
type: Boolean,
|
|
43
46
|
default: false
|
|
44
47
|
},
|
|
45
48
|
"collapsedModifiers": {}
|
|
46
49
|
}),
|
|
47
|
-
emits: /*@__PURE__*/ mergeModels(["
|
|
50
|
+
emits: /*@__PURE__*/ mergeModels(["update:modelValue", "change"], ["update:collapsed"]),
|
|
48
51
|
setup(__props, { emit: __emit }) {
|
|
49
52
|
const props = __props;
|
|
50
|
-
const size = useModel(__props, "modelValue");
|
|
51
53
|
const collapsed = useModel(__props, "collapsed");
|
|
52
54
|
const emit = __emit;
|
|
53
55
|
const ns = useNamespace("splitter");
|
|
@@ -55,6 +57,11 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
55
57
|
const startId = `dou-splitter-${useId()}-start`;
|
|
56
58
|
const root = useTemplateRef("root");
|
|
57
59
|
const horizontal = computed(() => props.direction === "horizontal");
|
|
60
|
+
const isPx = computed(() => props.unit === "px");
|
|
61
|
+
const activeSinglePane = computed(() => props.singlePane === "start" || props.singlePane === "end" ? props.singlePane : null);
|
|
62
|
+
const stepSize = computed(() => props.step ?? (isPx.value ? 10 : 1));
|
|
63
|
+
const localSize = ref();
|
|
64
|
+
const currentSize = computed(() => props.modelValue ?? localSize.value ?? (isPx.value ? 240 : 50));
|
|
58
65
|
const box = useElementSize(root, { box: "border-box" });
|
|
59
66
|
const length = () => Math.max(0, (horizontal.value ? box.width.value : box.height.value) - BAR);
|
|
60
67
|
if (process.env.NODE_ENV !== "production") watchEffect(() => {
|
|
@@ -64,12 +71,16 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
64
71
|
["minEnd", props.minEnd]
|
|
65
72
|
]) if (typeof limit === "string" && !/^\s*\d+(?:\.\d+)?px\s*$/.test(limit)) devWarn(`[dou-ui] DouSplitter: \`${name}\` is "${limit}"; use a number for percent or a length in px such as '240px'.`);
|
|
66
73
|
});
|
|
67
|
-
const
|
|
74
|
+
const limitPx = (limit) => {
|
|
75
|
+
if (typeof limit === "string") return Number.parseFloat(limit) || 0;
|
|
76
|
+
if (typeof limit === "number" && isPx.value) return limit;
|
|
77
|
+
return 0;
|
|
78
|
+
};
|
|
68
79
|
function share(value) {
|
|
69
80
|
const total = length();
|
|
70
81
|
return total ? value / total * 100 : 0;
|
|
71
82
|
}
|
|
72
|
-
const
|
|
83
|
+
const limitPercent = (limit) => typeof limit === "number" && !isPx.value ? limit : 0;
|
|
73
84
|
const startPane = useTemplateRef("startPane");
|
|
74
85
|
const endPane = useTemplateRef("endPane");
|
|
75
86
|
const nested = shallowReactive(/* @__PURE__ */ new Map());
|
|
@@ -95,10 +106,12 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
95
106
|
const cross = horizontal.value ? "height" : "width";
|
|
96
107
|
const start = inside(startPane.value);
|
|
97
108
|
const end = inside(endPane.value);
|
|
109
|
+
const hideStart = activeSinglePane.value === "end" || !activeSinglePane.value && collapsed.value;
|
|
110
|
+
const hideEnd = activeSinglePane.value === "start";
|
|
98
111
|
return {
|
|
99
|
-
start: Math.max(
|
|
100
|
-
end: Math.max(
|
|
101
|
-
cross: Math.max(
|
|
112
|
+
start: Math.max(limitPx(props.min), start[main]),
|
|
113
|
+
end: Math.max(limitPx(props.minEnd), end[main]),
|
|
114
|
+
cross: Math.max(hideStart ? 0 : start[cross], hideEnd ? 0 : end[cross])
|
|
102
115
|
};
|
|
103
116
|
});
|
|
104
117
|
const parent = inject(splitterContextKey, null);
|
|
@@ -106,7 +119,10 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
106
119
|
onMounted(() => {
|
|
107
120
|
unregister = root.value ? parent?.register(root.value, () => {
|
|
108
121
|
const { start, end, cross } = needs.value;
|
|
109
|
-
|
|
122
|
+
let along;
|
|
123
|
+
if (activeSinglePane.value === "start") along = start;
|
|
124
|
+
else if (activeSinglePane.value === "end") along = end;
|
|
125
|
+
else along = (collapsed.value ? 0 : start) + BAR + end;
|
|
110
126
|
return horizontal.value ? {
|
|
111
127
|
width: along,
|
|
112
128
|
height: cross
|
|
@@ -118,8 +134,31 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
118
134
|
});
|
|
119
135
|
onBeforeUnmount(() => unregister?.());
|
|
120
136
|
const bounds = () => {
|
|
121
|
-
|
|
122
|
-
|
|
137
|
+
if (isPx.value) {
|
|
138
|
+
const min = Math.max(0, needs.value.start);
|
|
139
|
+
const end = Math.max(0, needs.value.end);
|
|
140
|
+
const explicitMax = props.max === void 0 ? Infinity : Math.max(0, limitPx(props.max));
|
|
141
|
+
const total = length();
|
|
142
|
+
if (total > 0) {
|
|
143
|
+
if (min + end > total) {
|
|
144
|
+
const at = min / (min + end) * total;
|
|
145
|
+
return {
|
|
146
|
+
min: at,
|
|
147
|
+
max: at
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
min,
|
|
152
|
+
max: Math.max(min, Math.min(total - end, explicitMax))
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
min,
|
|
157
|
+
max: Math.max(min, explicitMax)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const min = Math.max(0, limitPercent(props.min), share(needs.value.start));
|
|
161
|
+
const end = Math.max(0, limitPercent(props.minEnd), share(needs.value.end));
|
|
123
162
|
if (min + end > 100) {
|
|
124
163
|
const at = min / (min + end) * 100;
|
|
125
164
|
return {
|
|
@@ -127,7 +166,7 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
127
166
|
max: at
|
|
128
167
|
};
|
|
129
168
|
}
|
|
130
|
-
const max = typeof props.max === "number" ? props.max : share(
|
|
169
|
+
const max = props.max === void 0 ? 100 : typeof props.max === "number" ? props.max : share(limitPx(props.max));
|
|
131
170
|
return {
|
|
132
171
|
min,
|
|
133
172
|
max: Math.max(min, Math.min(100 - end, max))
|
|
@@ -136,7 +175,15 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
136
175
|
const round = (value) => Math.round(value * 100) / 100;
|
|
137
176
|
function clamp(value) {
|
|
138
177
|
const { min, max } = bounds();
|
|
139
|
-
const
|
|
178
|
+
const bounded = Math.min(max, Math.max(min, value));
|
|
179
|
+
if (isPx.value) {
|
|
180
|
+
if (Math.ceil(min) > Math.floor(max)) return round(bounded);
|
|
181
|
+
const next = Math.round(bounded);
|
|
182
|
+
if (next > max) return Math.floor(max);
|
|
183
|
+
if (next < min) return Math.ceil(min);
|
|
184
|
+
return next;
|
|
185
|
+
}
|
|
186
|
+
const next = round(bounded);
|
|
140
187
|
if (next > max) return Math.floor(max * 100) / 100;
|
|
141
188
|
if (next < min) return Math.ceil(min * 100) / 100;
|
|
142
189
|
return next;
|
|
@@ -144,19 +191,28 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
144
191
|
function set(value) {
|
|
145
192
|
const next = clamp(value);
|
|
146
193
|
if (collapsed.value) collapsed.value = false;
|
|
147
|
-
if (next !==
|
|
194
|
+
if (next !== currentSize.value) {
|
|
195
|
+
localSize.value = next;
|
|
196
|
+
emit("update:modelValue", next);
|
|
197
|
+
}
|
|
198
|
+
return next;
|
|
148
199
|
}
|
|
149
200
|
function toggle() {
|
|
150
|
-
if (!props.collapsible || props.disabled) return;
|
|
201
|
+
if (!props.collapsible || props.disabled || activeSinglePane.value) return;
|
|
151
202
|
collapsed.value = !collapsed.value;
|
|
152
|
-
emit("change",
|
|
203
|
+
emit("change", currentSize.value);
|
|
153
204
|
}
|
|
154
205
|
const dragging = ref(false);
|
|
206
|
+
let dragValue = 0;
|
|
207
|
+
watch(activeSinglePane, (pane) => {
|
|
208
|
+
if (pane) dragging.value = false;
|
|
209
|
+
});
|
|
155
210
|
function onPointerdown(event) {
|
|
156
|
-
if (props.disabled || event.button !== 0) return;
|
|
211
|
+
if (props.disabled || activeSinglePane.value || event.button !== 0) return;
|
|
157
212
|
event.preventDefault();
|
|
158
213
|
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
159
214
|
event.currentTarget.focus();
|
|
215
|
+
dragValue = currentSize.value;
|
|
160
216
|
dragging.value = true;
|
|
161
217
|
}
|
|
162
218
|
function onPointermove(event) {
|
|
@@ -164,16 +220,17 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
164
220
|
const rect = root.value.getBoundingClientRect();
|
|
165
221
|
const total = (horizontal.value ? rect.width : rect.height) - BAR;
|
|
166
222
|
if (total <= 0) return;
|
|
167
|
-
|
|
223
|
+
const at = (horizontal.value ? event.clientX - rect.left : event.clientY - rect.top) - BAR / 2;
|
|
224
|
+
dragValue = set(isPx.value ? at : at / total * 100);
|
|
168
225
|
}
|
|
169
226
|
function onPointerup() {
|
|
170
227
|
if (!dragging.value) return;
|
|
171
228
|
dragging.value = false;
|
|
172
|
-
emit("change",
|
|
229
|
+
emit("change", dragValue);
|
|
173
230
|
}
|
|
174
231
|
function onKeydown(event) {
|
|
175
|
-
if (props.disabled) return;
|
|
176
|
-
const step =
|
|
232
|
+
if (props.disabled || activeSinglePane.value) return;
|
|
233
|
+
const step = stepSize.value * (event.shiftKey ? 10 : 1);
|
|
177
234
|
const back = horizontal.value ? "ArrowLeft" : "ArrowUp";
|
|
178
235
|
const forth = horizontal.value ? "ArrowRight" : "ArrowDown";
|
|
179
236
|
const current = shown.value;
|
|
@@ -181,26 +238,33 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
181
238
|
if (event.key === back) next = current - step;
|
|
182
239
|
else if (event.key === forth) next = current + step;
|
|
183
240
|
else if (event.key === "Home") next = bounds().min;
|
|
184
|
-
else if (event.key === "End")
|
|
185
|
-
|
|
241
|
+
else if (event.key === "End") {
|
|
242
|
+
const { max } = bounds();
|
|
243
|
+
if (!Number.isFinite(max)) return;
|
|
244
|
+
next = max;
|
|
245
|
+
} else if (event.key === "Enter" && props.collapsible) {
|
|
186
246
|
event.preventDefault();
|
|
187
247
|
return toggle();
|
|
188
248
|
} else return;
|
|
189
249
|
event.preventDefault();
|
|
190
|
-
set(next);
|
|
191
|
-
emit("change",
|
|
250
|
+
const committed = set(next);
|
|
251
|
+
emit("change", committed);
|
|
192
252
|
}
|
|
193
253
|
const shown = computed(() => {
|
|
194
254
|
if (collapsed.value) return 0;
|
|
195
|
-
return clamp(
|
|
255
|
+
return clamp(currentSize.value);
|
|
256
|
+
});
|
|
257
|
+
const template = computed(() => {
|
|
258
|
+
if (activeSinglePane.value) return "minmax(0, 1fr)";
|
|
259
|
+
if (isPx.value) return `${shown.value}px auto minmax(0, 1fr)`;
|
|
260
|
+
return `minmax(0, ${shown.value}fr) auto minmax(0, ${round(100 - shown.value)}fr)`;
|
|
196
261
|
});
|
|
197
|
-
const template = computed(() => `minmax(0, ${shown.value}fr) auto minmax(0, ${round(100 - shown.value)}fr)`);
|
|
198
262
|
const style = computed(() => horizontal.value ? { gridTemplateColumns: template.value } : { gridTemplateRows: template.value });
|
|
199
263
|
const limits = computed(() => {
|
|
200
264
|
const { min, max } = bounds();
|
|
201
265
|
return {
|
|
202
266
|
min: Math.round(min),
|
|
203
|
-
max: Math.round(max)
|
|
267
|
+
max: Number.isFinite(max) ? Math.round(max) : void 0
|
|
204
268
|
};
|
|
205
269
|
});
|
|
206
270
|
return (_ctx, _cache) => {
|
|
@@ -211,8 +275,11 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
211
275
|
unref(ns).b(),
|
|
212
276
|
unref(ns).m(__props.direction),
|
|
213
277
|
unref(ns).is("dragging", dragging.value),
|
|
214
|
-
unref(ns).is("collapsed", collapsed.value),
|
|
215
|
-
unref(ns).is("disabled", __props.disabled)
|
|
278
|
+
unref(ns).is("collapsed", collapsed.value && !activeSinglePane.value),
|
|
279
|
+
unref(ns).is("disabled", __props.disabled),
|
|
280
|
+
unref(ns).is("single-pane", !!activeSinglePane.value),
|
|
281
|
+
unref(ns).is("single-start", activeSinglePane.value === "start"),
|
|
282
|
+
unref(ns).is("single-end", activeSinglePane.value === "end")
|
|
216
283
|
]),
|
|
217
284
|
style: normalizeStyle(style.value)
|
|
218
285
|
}, [
|
|
@@ -220,12 +287,14 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
220
287
|
ref_key: "startPane",
|
|
221
288
|
ref: startPane,
|
|
222
289
|
id: startId,
|
|
223
|
-
class: normalizeClass([unref(ns).e("pane"), unref(ns).is("start", true)])
|
|
224
|
-
|
|
290
|
+
class: normalizeClass([unref(ns).e("pane"), unref(ns).is("start", true)]),
|
|
291
|
+
hidden: activeSinglePane.value === "end" || void 0
|
|
292
|
+
}, [renderSlot(_ctx.$slots, "start")], 10, _hoisted_1),
|
|
225
293
|
createElementVNode("div", {
|
|
226
294
|
role: "separator",
|
|
227
295
|
class: normalizeClass(unref(ns).e("bar")),
|
|
228
|
-
|
|
296
|
+
hidden: !!activeSinglePane.value || void 0,
|
|
297
|
+
tabindex: __props.disabled || activeSinglePane.value ? void 0 : 0,
|
|
229
298
|
"aria-orientation": horizontal.value ? "vertical" : "horizontal",
|
|
230
299
|
"aria-valuenow": Math.round(shown.value),
|
|
231
300
|
"aria-valuemin": limits.value.min,
|
|
@@ -242,12 +311,13 @@ var splitter_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
|
|
|
242
311
|
}, [createElementVNode("span", {
|
|
243
312
|
class: normalizeClass(unref(ns).e("handle")),
|
|
244
313
|
"aria-hidden": "true"
|
|
245
|
-
}, null, 2)], 42,
|
|
314
|
+
}, null, 2)], 42, _hoisted_2),
|
|
246
315
|
createElementVNode("div", {
|
|
247
316
|
ref_key: "endPane",
|
|
248
317
|
ref: endPane,
|
|
249
|
-
class: normalizeClass([unref(ns).e("pane"), unref(ns).is("end", true)])
|
|
250
|
-
|
|
318
|
+
class: normalizeClass([unref(ns).e("pane"), unref(ns).is("end", true)]),
|
|
319
|
+
hidden: activeSinglePane.value === "start" || void 0
|
|
320
|
+
}, [renderSlot(_ctx.$slots, "end")], 10, _hoisted_3)
|
|
251
321
|
], 6);
|
|
252
322
|
};
|
|
253
323
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"splitter.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_normalizeClass","_unref","_normalizeStyle","_createElementVNode","_renderSlot"],"sources":["../../../src/components/splitter/splitter.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n shallowReactive,\n useId,\n useTemplateRef,\n watchEffect,\n} from 'vue'\nimport { useElementSize } from '../../composables/use-element-size'\nimport { useNamespace } from '../../utils/namespace'\nimport { devWarn } from '../../utils/status-check'\nimport { useLocale } from '../config-provider/use-config'\nimport { splitterContextKey } from './context'\nimport type { SplitterMinSize } from './context'\nimport type { SplitterLimit, SplitterProps, SplitterSlots } from './splitter'\n\ndefineOptions({ name: 'DouSplitter' })\n\nconst props = withDefaults(defineProps<SplitterProps>(), {\n direction: 'horizontal',\n min: 0,\n max: 100,\n minEnd: 0,\n collapsible: false,\n step: 1,\n disabled: false,\n})\nconst size = defineModel<number>({ default: 50 })\nconst collapsed = defineModel<boolean>('collapsed', { default: false })\nconst emit = defineEmits<{ change: [value: number] }>()\ndefineSlots<SplitterSlots>()\n\nconst ns = useNamespace('splitter')\nconst { t } = useLocale()\nconst startId = `dou-splitter-${useId()}-start`\nconst root = useTemplateRef<HTMLElement>('root')\n\nconst horizontal = computed(() => props.direction === 'horizontal')\n// Kept up to date, so px limits still hold when the container resizes\nconst box = useElementSize(root, { box: 'border-box' })\n// the divider is a 1px line; the panes share the rest, so limits are a share of that\nconst BAR = 1\nconst length = () => Math.max(0, (horizontal.value ? box.width.value : box.height.value) - BAR)\n\nif (process.env.NODE_ENV !== 'production')\n watchEffect(() => {\n for (const [name, limit] of [\n ['min', props.min],\n ['max', props.max],\n ['minEnd', props.minEnd],\n ] as const)\n if (typeof limit === 'string' && !/^\\s*\\d+(?:\\.\\d+)?px\\s*$/.test(limit))\n devWarn(\n `[dou-ui] DouSplitter: \\`${name}\\` is \"${limit}\"; use a number for percent or a length in px such as '240px'.`,\n )\n })\n\nconst px = (limit: SplitterLimit) => (typeof limit === 'string' ? Number.parseFloat(limit) || 0 : 0)\n// px as a percentage of the splitter, 0 until it is measured\nfunction share(value: number) {\n const total = length()\n return total ? (value / total) * 100 : 0\n}\nconst percent = (limit: SplitterLimit) => (typeof limit === 'number' ? limit : 0)\n\n/* splitters inside the panes: their px limits add up to a minimum for the pane */\n\nconst startPane = useTemplateRef<HTMLElement>('startPane')\nconst endPane = useTemplateRef<HTMLElement>('endPane')\nconst nested = shallowReactive(new Map<HTMLElement, () => SplitterMinSize>())\nprovide(splitterContextKey, {\n register(el, measureNeed) {\n nested.set(el, measureNeed)\n return () => nested.delete(el)\n },\n})\nfunction inside(pane: HTMLElement | null): SplitterMinSize {\n const need = { width: 0, height: 0 }\n for (const [el, measureNeed] of nested) {\n if (!pane?.contains(el)) continue\n const { width, height } = measureNeed()\n need.width = Math.max(need.width, width)\n need.height = Math.max(need.height, height)\n }\n return need\n}\nconst needs = computed(() => {\n const main = horizontal.value ? 'width' : 'height'\n const cross = horizontal.value ? 'height' : 'width'\n const start = inside(startPane.value)\n const end = inside(endPane.value)\n return {\n start: Math.max(px(props.min), start[main]),\n end: Math.max(px(props.minEnd), end[main]),\n cross: Math.max(collapsed.value ? 0 : start[cross], end[cross]),\n }\n})\nconst parent = inject(splitterContextKey, null)\nlet unregister: (() => void) | undefined\nonMounted(() => {\n unregister = root.value\n ? parent?.register(root.value, () => {\n const { start, end, cross } = needs.value\n const along = (collapsed.value ? 0 : start) + BAR + end\n return horizontal.value ? { width: along, height: cross } : { width: cross, height: along }\n })\n : undefined\n})\nonBeforeUnmount(() => unregister?.())\n\nconst bounds = () => {\n const min = Math.max(0, percent(props.min), share(needs.value.start))\n const end = Math.max(0, percent(props.minEnd), share(needs.value.end))\n // Too small for both minimums: they share the room in proportion\n if (min + end > 100) {\n const at = (min / (min + end)) * 100\n return { min: at, max: at }\n }\n const max = typeof props.max === 'number' ? props.max : share(px(props.max))\n return { min, max: Math.max(min, Math.min(100 - end, max)) }\n}\nconst round = (value: number) => Math.round(value * 100) / 100\nfunction clamp(value: number) {\n const { min, max } = bounds()\n const next = round(Math.min(max, Math.max(min, value)))\n // rounding must not push a pane below its minimum: round inwards at the limits\n if (next > max) return Math.floor(max * 100) / 100\n if (next < min) return Math.ceil(min * 100) / 100\n return next\n}\n\nfunction set(value: number) {\n const next = clamp(value)\n if (collapsed.value) collapsed.value = false\n if (next !== size.value) size.value = next\n}\n\nfunction toggle() {\n if (!props.collapsible || props.disabled) return\n collapsed.value = !collapsed.value\n emit('change', size.value)\n}\n\n/* dragging */\n\nconst dragging = ref(false)\nfunction onPointerdown(event: PointerEvent) {\n if (props.disabled || event.button !== 0) return\n event.preventDefault()\n ;(event.currentTarget as HTMLElement).setPointerCapture?.(event.pointerId)\n ;(event.currentTarget as HTMLElement).focus()\n dragging.value = true\n}\nfunction onPointermove(event: PointerEvent) {\n if (!dragging.value || !root.value) return\n const rect = root.value.getBoundingClientRect()\n const total = (horizontal.value ? rect.width : rect.height) - BAR\n if (total <= 0) return\n const at = (horizontal.value ? event.clientX - rect.left : event.clientY - rect.top) - BAR / 2\n set((at / total) * 100)\n}\nfunction onPointerup() {\n if (!dragging.value) return\n dragging.value = false\n emit('change', size.value)\n}\n\n/* keys */\n\nfunction onKeydown(event: KeyboardEvent) {\n if (props.disabled) return\n const step = props.step * (event.shiftKey ? 10 : 1)\n const back = horizontal.value ? 'ArrowLeft' : 'ArrowUp'\n const forth = horizontal.value ? 'ArrowRight' : 'ArrowDown'\n const current = shown.value\n let next: number | undefined\n if (event.key === back) next = current - step\n else if (event.key === forth) next = current + step\n else if (event.key === 'Home') next = bounds().min\n else if (event.key === 'End') next = bounds().max\n else if (event.key === 'Enter' && props.collapsible) {\n event.preventDefault()\n return toggle()\n } else return\n event.preventDefault()\n set(next)\n emit('change', size.value)\n}\n\n// What is on screen: the model value kept within the limits, which can\n// tighten as the container resizes. The model itself only changes when\n// someone moves the divider.\nconst shown = computed(() => {\n if (collapsed.value) return 0\n return clamp(size.value)\n})\nconst template = computed(\n () => `minmax(0, ${shown.value}fr) auto minmax(0, ${round(100 - shown.value)}fr)`,\n)\nconst style = computed(() =>\n horizontal.value ? { gridTemplateColumns: template.value } : { gridTemplateRows: template.value },\n)\nconst limits = computed(() => {\n // px limits count as 0 until the container is measured\n const { min, max } = bounds()\n return { min: Math.round(min), max: Math.round(max) }\n})\n</script>\n\n<template>\n <div\n ref=\"root\"\n :class=\"[\n ns.b(),\n ns.m(direction),\n ns.is('dragging', dragging),\n ns.is('collapsed', collapsed),\n ns.is('disabled', disabled),\n ]\"\n :style=\"style\"\n >\n <div ref=\"startPane\" :id=\"startId\" :class=\"[ns.e('pane'), ns.is('start', true)]\">\n <slot name=\"start\" />\n </div>\n <div\n role=\"separator\"\n :class=\"ns.e('bar')\"\n :tabindex=\"disabled ? undefined : 0\"\n :aria-orientation=\"horizontal ? 'vertical' : 'horizontal'\"\n :aria-valuenow=\"Math.round(shown)\"\n :aria-valuemin=\"limits.min\"\n :aria-valuemax=\"limits.max\"\n :aria-controls=\"startId\"\n :aria-label=\"ariaLabel ?? t('splitter.label')\"\n :aria-disabled=\"disabled || undefined\"\n @pointerdown=\"onPointerdown\"\n @pointermove=\"onPointermove\"\n @pointerup=\"onPointerup\"\n @pointercancel=\"onPointerup\"\n @keydown=\"onKeydown\"\n @dblclick=\"toggle\"\n >\n <span :class=\"ns.e('handle')\" aria-hidden=\"true\" />\n </div>\n <div ref=\"endPane\" :class=\"[ns.e('pane'), ns.is('end', true)]\">\n <slot name=\"end\" />\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;AA8CA,IAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAvBZ,MAAM,QAAQ;EASd,MAAM,OAAOA,SAAmB,SAAA,YAAgB;EAChD,MAAM,YAAYA,SAAoB,SAAC,WAA+B;EACtE,MAAM,OAAO;EAGb,MAAM,KAAK,aAAa,UAAU;EAClC,MAAM,EAAE,MAAM,UAAU;EACxB,MAAM,UAAU,gBAAgB,MAAM,EAAE;EACxC,MAAM,OAAO,eAA4B,MAAM;EAE/C,MAAM,aAAa,eAAe,MAAM,cAAc,YAAY;EAElE,MAAM,MAAM,eAAe,MAAM,EAAE,KAAK,aAAa,CAAC;EAGtD,MAAM,eAAe,KAAK,IAAI,IAAI,WAAW,QAAQ,IAAI,MAAM,QAAQ,IAAI,OAAO,SAAS,GAAG;EAE9F,IAAA,QAAA,IAAA,aAA6B,cAC3B,kBAAkB;GAChB,KAAK,MAAM,CAAC,MAAM,UAAU;IAC1B,CAAC,OAAO,MAAM,GAAG;IACjB,CAAC,OAAO,MAAM,GAAG;IACjB,CAAC,UAAU,MAAM,MAAM;GACzB,GACE,IAAI,OAAO,UAAU,YAAY,CAAC,0BAA0B,KAAK,KAAK,GACpE,QACE,2BAA2B,KAAK,SAAS,MAAM,+DACjD;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,MAAA,EAAA,CAAE,CAAC,EAAC,KAAA,CAAA;KACX,UAAU,QAAA,WAAW,KAAA,IAAS;KAC9B,oBAAkB,WAAA,QAAU,aAAA;KAC5B,iBAAe,KAAK,MAAM,MAAA,KAAK;KAC/B,iBAAe,OAAA,MAAO;KACtB,iBAAe,OAAA,MAAO;KACtB,iBAAe;KACf,cAAY,QAAA,aAAaA,MAAA,CAAA,CAAC,CAAA,gBAAA;KAC1B,iBAAe,QAAA,YAAY,KAAA;KACd;KACA;KACF;KACX,iBAAe;KACN;KACT,YAAU;I,IAEXE,mBAAmD,QAAA;KAA5C,OAAKH,eAAEC,MAAA,EAAA,CAAE,CAAC,EAAC,QAAA,CAAA;KAAY,eAAY;;IAE5CE,mBAEM,OAAA;KAFG,SAAA;KAAJ,KAAI;KAAW,OAAKH,eAAA,CAAGC,MAAA,EAAA,CAAE,CAAC,EAAC,MAAA,GAAUA,MAAA,EAAA,CAAE,CAAC,GAAE,OAAA,IAAA,CAAA,CAAA;I,IAC7CG,WAAmB,KAAA,QAAA,KAAA,C"}
|
|
1
|
+
{"version":3,"file":"splitter.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_normalizeClass","_unref","_normalizeStyle","_createElementVNode","_renderSlot"],"sources":["../../../src/components/splitter/splitter.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n shallowReactive,\n useId,\n useTemplateRef,\n watch,\n watchEffect,\n} from 'vue'\nimport { useElementSize } from '../../composables/use-element-size'\nimport { useNamespace } from '../../utils/namespace'\nimport { devWarn } from '../../utils/status-check'\nimport { useLocale } from '../config-provider/use-config'\nimport { splitterContextKey } from './context'\nimport type { SplitterMinSize } from './context'\nimport type { SplitterLimit, SplitterPane, SplitterProps, SplitterSlots } from './splitter'\n\ndefineOptions({ name: 'DouSplitter' })\n\nconst props = withDefaults(defineProps<SplitterProps>(), {\n direction: 'horizontal',\n unit: 'percent',\n min: 0,\n minEnd: 0,\n collapsible: false,\n singlePane: null,\n disabled: false,\n})\nconst collapsed = defineModel<boolean>('collapsed', { default: false })\nconst emit = defineEmits<{\n 'update:modelValue': [value: number]\n change: [value: number]\n}>()\ndefineSlots<SplitterSlots>()\n\nconst ns = useNamespace('splitter')\nconst { t } = useLocale()\nconst startId = `dou-splitter-${useId()}-start`\nconst root = useTemplateRef<HTMLElement>('root')\n\nconst horizontal = computed(() => props.direction === 'horizontal')\nconst isPx = computed(() => props.unit === 'px')\nconst activeSinglePane = computed<SplitterPane | null>(() =>\n props.singlePane === 'start' || props.singlePane === 'end' ? props.singlePane : null,\n)\nconst stepSize = computed(() => props.step ?? (isPx.value ? 10 : 1))\nconst localSize = ref<number | undefined>()\nconst currentSize = computed(() => props.modelValue ?? localSize.value ?? (isPx.value ? 240 : 50))\n\n// Kept up to date, so px limits and px mode still hold when the container resizes\nconst box = useElementSize(root, { box: 'border-box' })\n// the divider is a 1px line; the panes share the rest, so limits are a share of that\nconst BAR = 1\nconst length = () => Math.max(0, (horizontal.value ? box.width.value : box.height.value) - BAR)\n\nif (process.env.NODE_ENV !== 'production')\n watchEffect(() => {\n for (const [name, limit] of [\n ['min', props.min],\n ['max', props.max],\n ['minEnd', props.minEnd],\n ] as const)\n if (typeof limit === 'string' && !/^\\s*\\d+(?:\\.\\d+)?px\\s*$/.test(limit))\n devWarn(\n `[dou-ui] DouSplitter: \\`${name}\\` is \"${limit}\"; use a number for percent or a length in px such as '240px'.`,\n )\n })\n\nconst limitPx = (limit: SplitterLimit | undefined) => {\n if (typeof limit === 'string') return Number.parseFloat(limit) || 0\n if (typeof limit === 'number' && isPx.value) return limit\n return 0\n}\n// px as a percentage of the splitter, 0 until it is measured\nfunction share(value: number) {\n const total = length()\n return total ? (value / total) * 100 : 0\n}\nconst limitPercent = (limit: SplitterLimit | undefined) =>\n typeof limit === 'number' && !isPx.value ? limit : 0\n\n/* splitters inside the panes: their px limits add up to a minimum for the pane */\n\nconst startPane = useTemplateRef<HTMLElement>('startPane')\nconst endPane = useTemplateRef<HTMLElement>('endPane')\nconst nested = shallowReactive(new Map<HTMLElement, () => SplitterMinSize>())\nprovide(splitterContextKey, {\n register(el, measureNeed) {\n nested.set(el, measureNeed)\n return () => nested.delete(el)\n },\n})\nfunction inside(pane: HTMLElement | null): SplitterMinSize {\n const need = { width: 0, height: 0 }\n for (const [el, measureNeed] of nested) {\n if (!pane?.contains(el)) continue\n const { width, height } = measureNeed()\n need.width = Math.max(need.width, width)\n need.height = Math.max(need.height, height)\n }\n return need\n}\nconst needs = computed(() => {\n const main = horizontal.value ? 'width' : 'height'\n const cross = horizontal.value ? 'height' : 'width'\n const start = inside(startPane.value)\n const end = inside(endPane.value)\n const hideStart = activeSinglePane.value === 'end' || (!activeSinglePane.value && collapsed.value)\n const hideEnd = activeSinglePane.value === 'start'\n return {\n start: Math.max(limitPx(props.min), start[main]),\n end: Math.max(limitPx(props.minEnd), end[main]),\n cross: Math.max(hideStart ? 0 : start[cross], hideEnd ? 0 : end[cross]),\n }\n})\nconst parent = inject(splitterContextKey, null)\nlet unregister: (() => void) | undefined\nonMounted(() => {\n unregister = root.value\n ? parent?.register(root.value, () => {\n const { start, end, cross } = needs.value\n let along: number\n if (activeSinglePane.value === 'start') along = start\n else if (activeSinglePane.value === 'end') along = end\n else along = (collapsed.value ? 0 : start) + BAR + end\n return horizontal.value ? { width: along, height: cross } : { width: cross, height: along }\n })\n : undefined\n})\nonBeforeUnmount(() => unregister?.())\n\nconst bounds = () => {\n if (isPx.value) {\n const min = Math.max(0, needs.value.start)\n const end = Math.max(0, needs.value.end)\n const explicitMax = props.max === undefined ? Infinity : Math.max(0, limitPx(props.max))\n const total = length()\n if (total > 0) {\n // Too small for both minimums: they share the room in proportion\n if (min + end > total) {\n const at = (min / (min + end)) * total\n return { min: at, max: at }\n }\n return { min, max: Math.max(min, Math.min(total - end, explicitMax)) }\n }\n return { min, max: Math.max(min, explicitMax) }\n }\n const min = Math.max(0, limitPercent(props.min), share(needs.value.start))\n const end = Math.max(0, limitPercent(props.minEnd), share(needs.value.end))\n // Too small for both minimums: they share the room in proportion\n if (min + end > 100) {\n const at = (min / (min + end)) * 100\n return { min: at, max: at }\n }\n const max =\n props.max === undefined\n ? 100\n : typeof props.max === 'number'\n ? props.max\n : share(limitPx(props.max))\n return { min, max: Math.max(min, Math.min(100 - end, max)) }\n}\nconst round = (value: number) => Math.round(value * 100) / 100\nfunction clamp(value: number) {\n const { min, max } = bounds()\n const bounded = Math.min(max, Math.max(min, value))\n if (isPx.value) {\n if (Math.ceil(min) > Math.floor(max)) return round(bounded)\n const next = Math.round(bounded)\n if (next > max) return Math.floor(max)\n if (next < min) return Math.ceil(min)\n return next\n }\n const next = round(bounded)\n // rounding must not push a pane below its minimum: round inwards at the limits\n if (next > max) return Math.floor(max * 100) / 100\n if (next < min) return Math.ceil(min * 100) / 100\n return next\n}\n\nfunction set(value: number) {\n const next = clamp(value)\n if (collapsed.value) collapsed.value = false\n if (next !== currentSize.value) {\n localSize.value = next\n emit('update:modelValue', next)\n }\n return next\n}\n\nfunction toggle() {\n if (!props.collapsible || props.disabled || activeSinglePane.value) return\n collapsed.value = !collapsed.value\n emit('change', currentSize.value)\n}\n\n/* dragging */\n\nconst dragging = ref(false)\nlet dragValue = 0\nwatch(activeSinglePane, (pane) => {\n if (pane) dragging.value = false\n})\nfunction onPointerdown(event: PointerEvent) {\n if (props.disabled || activeSinglePane.value || event.button !== 0) return\n event.preventDefault()\n ;(event.currentTarget as HTMLElement).setPointerCapture?.(event.pointerId)\n ;(event.currentTarget as HTMLElement).focus()\n dragValue = currentSize.value\n dragging.value = true\n}\nfunction onPointermove(event: PointerEvent) {\n if (!dragging.value || !root.value) return\n const rect = root.value.getBoundingClientRect()\n const total = (horizontal.value ? rect.width : rect.height) - BAR\n if (total <= 0) return\n const at = (horizontal.value ? event.clientX - rect.left : event.clientY - rect.top) - BAR / 2\n dragValue = set(isPx.value ? at : (at / total) * 100)\n}\nfunction onPointerup() {\n if (!dragging.value) return\n dragging.value = false\n emit('change', dragValue)\n}\n\n/* keys */\n\nfunction onKeydown(event: KeyboardEvent) {\n if (props.disabled || activeSinglePane.value) return\n const step = stepSize.value * (event.shiftKey ? 10 : 1)\n const back = horizontal.value ? 'ArrowLeft' : 'ArrowUp'\n const forth = horizontal.value ? 'ArrowRight' : 'ArrowDown'\n const current = shown.value\n let next: number | undefined\n if (event.key === back) next = current - step\n else if (event.key === forth) next = current + step\n else if (event.key === 'Home') next = bounds().min\n else if (event.key === 'End') {\n const { max } = bounds()\n if (!Number.isFinite(max)) return\n next = max\n } else if (event.key === 'Enter' && props.collapsible) {\n event.preventDefault()\n return toggle()\n } else return\n event.preventDefault()\n const committed = set(next)\n emit('change', committed)\n}\n\n// What is on screen: the model value kept within the limits, which can\n// tighten as the container resizes. The model itself only changes when\n// someone moves the divider.\nconst shown = computed(() => {\n if (collapsed.value) return 0\n return clamp(currentSize.value)\n})\nconst template = computed(() => {\n if (activeSinglePane.value) return 'minmax(0, 1fr)'\n if (isPx.value) return `${shown.value}px auto minmax(0, 1fr)`\n return `minmax(0, ${shown.value}fr) auto minmax(0, ${round(100 - shown.value)}fr)`\n})\nconst style = computed(() =>\n horizontal.value ? { gridTemplateColumns: template.value } : { gridTemplateRows: template.value },\n)\nconst limits = computed(() => {\n // px limits count as 0 until the container is measured in percent mode\n const { min, max } = bounds()\n return {\n min: Math.round(min),\n max: Number.isFinite(max) ? Math.round(max) : undefined,\n }\n})\n</script>\n\n<template>\n <div\n ref=\"root\"\n :class=\"[\n ns.b(),\n ns.m(direction),\n ns.is('dragging', dragging),\n ns.is('collapsed', collapsed && !activeSinglePane),\n ns.is('disabled', disabled),\n ns.is('single-pane', !!activeSinglePane),\n ns.is('single-start', activeSinglePane === 'start'),\n ns.is('single-end', activeSinglePane === 'end'),\n ]\"\n :style=\"style\"\n >\n <div\n ref=\"startPane\"\n :id=\"startId\"\n :class=\"[ns.e('pane'), ns.is('start', true)]\"\n :hidden=\"activeSinglePane === 'end' || undefined\"\n >\n <slot name=\"start\" />\n </div>\n <div\n role=\"separator\"\n :class=\"ns.e('bar')\"\n :hidden=\"!!activeSinglePane || undefined\"\n :tabindex=\"disabled || activeSinglePane ? undefined : 0\"\n :aria-orientation=\"horizontal ? 'vertical' : 'horizontal'\"\n :aria-valuenow=\"Math.round(shown)\"\n :aria-valuemin=\"limits.min\"\n :aria-valuemax=\"limits.max\"\n :aria-controls=\"startId\"\n :aria-label=\"ariaLabel ?? t('splitter.label')\"\n :aria-disabled=\"disabled || undefined\"\n @pointerdown=\"onPointerdown\"\n @pointermove=\"onPointermove\"\n @pointerup=\"onPointerup\"\n @pointercancel=\"onPointerup\"\n @keydown=\"onKeydown\"\n @dblclick=\"toggle\"\n >\n <span :class=\"ns.e('handle')\" aria-hidden=\"true\" />\n </div>\n <div\n ref=\"endPane\"\n :class=\"[ns.e('pane'), ns.is('end', true)]\"\n :hidden=\"activeSinglePane === 'start' || undefined\"\n >\n <slot name=\"end\" />\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyDA,IAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAjCZ,MAAM,QAAQ;EASd,MAAM,YAAYA,SAAoB,SAAC,WAA+B;EACtE,MAAM,OAAO;EAMb,MAAM,KAAK,aAAa,UAAU;EAClC,MAAM,EAAE,MAAM,UAAU;EACxB,MAAM,UAAU,gBAAgB,MAAM,EAAE;EACxC,MAAM,OAAO,eAA4B,MAAM;EAE/C,MAAM,aAAa,eAAe,MAAM,cAAc,YAAY;EAClE,MAAM,OAAO,eAAe,MAAM,SAAS,IAAI;EAC/C,MAAM,mBAAmB,eACvB,MAAM,eAAe,WAAW,MAAM,eAAe,QAAQ,MAAM,aAAa,IAClF;EACA,MAAM,WAAW,eAAe,MAAM,SAAS,KAAK,QAAQ,KAAK,EAAE;EACnE,MAAM,YAAY,IAAwB;EAC1C,MAAM,cAAc,eAAe,MAAM,cAA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B,WAAA,QAAU,aAAA;KAC5B,iBAAe,KAAK,MAAM,MAAA,KAAK;KAC/B,iBAAe,OAAA,MAAO;KACtB,iBAAe,OAAA,MAAO;KACtB,iBAAe;KACf,cAAY,QAAA,aAAaA,MAAA,CAAA,CAAC,CAAA,gBAAA;KAC1B,iBAAe,QAAA,YAAY,KAAA;KACd;KACA;KACF;KACX,iBAAe;KACN;KACT,YAAU;I,IAEXE,mBAAmD,QAAA;KAA5C,OAAKH,eAAEC,MAAA,EAAA,CAAE,CAAC,EAAC,QAAA,CAAA;KAAY,eAAY;;IAE5CE,mBAMM,OAAA;KALA,SAAA;KAAJ,KAAI;KACH,OAAKH,eAAA,CAAGC,MAAA,EAAA,CAAE,CAAC,EAAC,MAAA,GAAUA,MAAA,EAAA,CAAE,CAAC,GAAE,OAAA,IAAA,CAAA,CAAA;KAC3B,QAAQ,iBAAA,UAAgB,WAAgB,KAAA;I,IAEzCG,WAAmB,KAAA,QAAA,KAAA,C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import tab_button_vue_vue_type_script_setup_true_lang_default from "./tab-button.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
// src/components/tabs/tab-button.vue
|
|
3
|
+
var tab_button_default = tab_button_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
export { tab_button_default as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=tab-button.js.map
|
|
@@ -0,0 +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 :class=\"ns.e('close')\" aria-hidden=\"true\" @click.stop=\"emit('remove')\">\n <CloseIcon />\n </span>\n </DouTooltip>\n </button>\n </TabTip>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useNamespace } from "../../utils/namespace.js";
|
|
2
|
+
import { useLocale } from "../config-provider/use-config.js";
|
|
3
|
+
import { DouTooltip } from "../tooltip/index.js";
|
|
4
|
+
import { createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, h, normalizeClass, openBlock, resolveDynamicComponent, unref, withCtx, withModifiers } from "vue";
|
|
5
|
+
import { CloseIcon } from "@dou-ui/icons";
|
|
6
|
+
// src/components/tabs/tab-button.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
+
var _hoisted_1 = [
|
|
8
|
+
"id",
|
|
9
|
+
"aria-selected",
|
|
10
|
+
"aria-controls",
|
|
11
|
+
"aria-label",
|
|
12
|
+
"aria-disabled",
|
|
13
|
+
"tabindex",
|
|
14
|
+
"aria-keyshortcuts"
|
|
15
|
+
];
|
|
16
|
+
var tab_button_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
17
|
+
name: "DouTabButton",
|
|
18
|
+
__name: "tab-button",
|
|
19
|
+
props: {
|
|
20
|
+
entry: {},
|
|
21
|
+
tabId: {},
|
|
22
|
+
panelId: {},
|
|
23
|
+
labelText: {},
|
|
24
|
+
selected: { type: Boolean },
|
|
25
|
+
closable: { type: Boolean },
|
|
26
|
+
iconAlone: { type: Boolean },
|
|
27
|
+
draggable: { type: Boolean },
|
|
28
|
+
dragging: { type: Boolean },
|
|
29
|
+
tipPlacement: {},
|
|
30
|
+
keyShortcuts: {},
|
|
31
|
+
setEl: { type: Function }
|
|
32
|
+
},
|
|
33
|
+
emits: [
|
|
34
|
+
"click",
|
|
35
|
+
"pointerdown",
|
|
36
|
+
"keydown",
|
|
37
|
+
"remove"
|
|
38
|
+
],
|
|
39
|
+
setup(__props, { emit: __emit }) {
|
|
40
|
+
const props = __props;
|
|
41
|
+
const emit = __emit;
|
|
42
|
+
const ns = useNamespace("tabs");
|
|
43
|
+
const { t } = useLocale();
|
|
44
|
+
const onButtonRef = (el) => props.setEl(el);
|
|
45
|
+
/** The label slot of a panel, rendered inside its tab. */
|
|
46
|
+
const TabLabel = () => props.entry.slots.label?.({ selected: props.selected }) ?? props.labelText;
|
|
47
|
+
const TabTip = (_, { slots: tip }) => props.iconAlone ? h(DouTooltip, {
|
|
48
|
+
content: props.labelText,
|
|
49
|
+
placement: props.tipPlacement
|
|
50
|
+
}, tip) : tip.default?.();
|
|
51
|
+
return (_ctx, _cache) => {
|
|
52
|
+
return openBlock(), createBlock(TabTip, null, {
|
|
53
|
+
default: withCtx(() => [createElementVNode("button", {
|
|
54
|
+
id: __props.tabId,
|
|
55
|
+
ref: onButtonRef,
|
|
56
|
+
type: "button",
|
|
57
|
+
role: "tab",
|
|
58
|
+
class: normalizeClass([
|
|
59
|
+
unref(ns).e("tab"),
|
|
60
|
+
unref(ns).is("selected", __props.selected),
|
|
61
|
+
unref(ns).is("disabled", !!__props.entry.props.disabled),
|
|
62
|
+
unref(ns).is("closable", __props.closable),
|
|
63
|
+
unref(ns).is("icon-alone", __props.iconAlone),
|
|
64
|
+
unref(ns).is("pinned", !!__props.entry.props.pinned),
|
|
65
|
+
unref(ns).is("draggable", __props.draggable),
|
|
66
|
+
unref(ns).is("dragging", __props.dragging)
|
|
67
|
+
]),
|
|
68
|
+
"aria-selected": __props.selected,
|
|
69
|
+
"aria-controls": __props.panelId,
|
|
70
|
+
"aria-label": __props.iconAlone ? __props.labelText : void 0,
|
|
71
|
+
"aria-disabled": __props.entry.props.disabled || void 0,
|
|
72
|
+
tabindex: __props.selected ? 0 : -1,
|
|
73
|
+
"aria-keyshortcuts": __props.keyShortcuts,
|
|
74
|
+
onClick: _cache[1] || (_cache[1] = ($event) => emit("click")),
|
|
75
|
+
onPointerdown: _cache[2] || (_cache[2] = ($event) => emit("pointerdown", $event)),
|
|
76
|
+
onKeydown: _cache[3] || (_cache[3] = ($event) => emit("keydown", $event))
|
|
77
|
+
}, [
|
|
78
|
+
__props.entry.props.icon ? (openBlock(), createBlock(resolveDynamicComponent(__props.entry.props.icon), {
|
|
79
|
+
key: 0,
|
|
80
|
+
class: normalizeClass(unref(ns).e("icon")),
|
|
81
|
+
"aria-hidden": "true"
|
|
82
|
+
}, null, 8, ["class"])) : createCommentVNode("", true),
|
|
83
|
+
!__props.iconAlone ? (openBlock(), createElementBlock("span", {
|
|
84
|
+
key: 1,
|
|
85
|
+
class: normalizeClass(unref(ns).e("label"))
|
|
86
|
+
}, [createVNode(TabLabel)], 2)) : createCommentVNode("", true),
|
|
87
|
+
__props.closable ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
88
|
+
key: 2,
|
|
89
|
+
content: unref(t)("tabs.close"),
|
|
90
|
+
shortcut: "delete",
|
|
91
|
+
disabled: __props.iconAlone
|
|
92
|
+
}, {
|
|
93
|
+
default: withCtx(() => [createElementVNode("span", {
|
|
94
|
+
class: normalizeClass(unref(ns).e("close")),
|
|
95
|
+
"aria-hidden": "true",
|
|
96
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => emit("remove"), ["stop"]))
|
|
97
|
+
}, [createVNode(unref(CloseIcon))], 2)]),
|
|
98
|
+
_: 1
|
|
99
|
+
}, 8, ["content", "disabled"])) : createCommentVNode("", true)
|
|
100
|
+
], 42, _hoisted_1)]),
|
|
101
|
+
_: 1
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
export { tab_button_vue_vue_type_script_setup_true_lang_default as default };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=tab-button.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +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 :class=\"ns.e('close')\" aria-hidden=\"true\" @click.stop=\"emit('remove')\">\n <CloseIcon />\n </span>\n </DouTooltip>\n </button>\n </TabTip>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWA,MAAM,QAAQ;EAed,MAAM,OAAO;EAOb,MAAM,KAAK,aAAa,MAAM;EAC9B,MAAM,EAAE,MAAM,UAAU;EACxB,MAAM,eAAe,OAAgB,MAAM,MAAM,EAAE;;EAGnD,MAAM,iBACH,MAAM,MAAM,MAAM,QAAQ,EAAE,UAAU,MAAM,SAAS,CAAC,KACvD,MAAM;EAER,MAAM,UAA+B,GAAG,EAAE,OAAO,UAC/C,MAAM,YACF,EAAE,YAAY;GAAE,SAAS,MAAM;GAAW,WAAW,MAAM;EAAa,GAAG,GAAG,IAC9E,IAAI,UAAU;;GAIlB,OAAAA,UAAA,GAAAC,YAgDS,QAAA,MAAA;IA/CP,SAAAC,cA8CS,CA9CTC,mBA8CS,UAAA;KA7CN,IAAI,QAAA;KACJ,KAAK;KACN,MAAK;KACL,MAAK;KACJ,OAAKC,eAAA;MAAYC,MAAA,EAAA,CAAE,C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