@koi-design/uxd-ui 13.1.9 → 13.2.2
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/es/components/Mention/Mention.mjs +5 -2
- package/es/components/Mention/Mention.mjs.map +1 -1
- package/es/components/Mention/Mentions.type.d.ts +1 -0
- package/es/components/Mention/Mentions.type.mjs.map +1 -1
- package/es/components/Mention/MentionsSelect.mjs +5 -1
- package/es/components/Mention/MentionsSelect.mjs.map +1 -1
- package/es/components/Popover/Popover.mjs +2 -1
- package/es/components/Popover/Popover.mjs.map +1 -1
- package/es/components/Popover/Popover.type.d.ts +4 -0
- package/es/components/Popover/Popover.type.mjs +4 -0
- package/es/components/Popover/Popover.type.mjs.map +1 -1
- package/es/components/Popover/Popover.vue.d.ts +9 -0
- package/es/components/Popover/index.d.ts +19 -0
- package/es/components/Tree/Tree.mjs +17 -1
- package/es/components/Tree/Tree.mjs.map +1 -1
- package/es/components/Tree/Tree.type.d.ts +1 -0
- package/es/components/Tree/Tree.type.mjs.map +1 -1
- package/es/components/Tree/TreeNode.mjs +15 -1
- package/es/components/Tree/TreeNode.mjs.map +1 -1
- package/lib/components/Mention/Mention.js +5 -2
- package/lib/components/Mention/Mention.js.map +1 -1
- package/lib/components/Mention/Mentions.type.d.ts +1 -0
- package/lib/components/Mention/Mentions.type.js.map +1 -1
- package/lib/components/Mention/MentionsSelect.js +5 -1
- package/lib/components/Mention/MentionsSelect.js.map +1 -1
- package/lib/components/Popover/Popover.js +2 -1
- package/lib/components/Popover/Popover.js.map +1 -1
- package/lib/components/Popover/Popover.type.d.ts +4 -0
- package/lib/components/Popover/Popover.type.js +4 -0
- package/lib/components/Popover/Popover.type.js.map +1 -1
- package/lib/components/Popover/Popover.vue.d.ts +9 -0
- package/lib/components/Popover/index.d.ts +19 -0
- package/lib/components/Tree/Tree.js +17 -1
- package/lib/components/Tree/Tree.js.map +1 -1
- package/lib/components/Tree/Tree.type.d.ts +1 -0
- package/lib/components/Tree/Tree.type.js.map +1 -1
- package/lib/components/Tree/TreeNode.js +15 -1
- package/lib/components/Tree/TreeNode.js.map +1 -1
- package/package.json +1 -1
- package/styles/components/mentions/index.css +1 -1
- package/styles/components/mentions/index.less +1 -1
- package/styles/components/table/index.css +1 -1
- package/styles/components/table/index.less +53 -40
- package/styles/components/tooltip/index.css +1 -1
- package/styles/components/tooltip/var.less +2 -2
- package/styles/components/tree/index.css +1 -1
- package/styles/components/tree/index.less +10 -1
- package/styles/index.css +1 -1
- package/styles/tokens/colors/index.css +4 -4
- package/types/components/Mention/Mentions.type.d.ts +1 -0
- package/types/components/Popover/Popover.type.d.ts +4 -0
- package/types/components/Popover/Popover.vue.d.ts +9 -0
- package/types/components/Popover/index.d.ts +19 -0
- package/types/components/Tree/Tree.type.d.ts +1 -0
- package/uxd-ui.css +1 -1
- package/uxd-ui.esm.min.mjs +5 -5
- package/uxd-ui.esm.mjs +49 -7
- package/uxd-ui.umd.js +49 -7
- package/uxd-ui.umd.min.js +5 -5
|
@@ -19,6 +19,7 @@ const _sfc_main = defineComponent({
|
|
|
19
19
|
styleMap: { default: () => ({}) },
|
|
20
20
|
config: { default: () => ({}) },
|
|
21
21
|
resizable: { type: Boolean, default: false },
|
|
22
|
+
optEmptyTip: { default: "" },
|
|
22
23
|
prefix: { default: "uui" },
|
|
23
24
|
triggerSign: { default: () => ["@"] },
|
|
24
25
|
mentionClass: { default: "mention" },
|
|
@@ -446,9 +447,10 @@ const _sfc_main = defineComponent({
|
|
|
446
447
|
const startY = e.clientY;
|
|
447
448
|
const startHeight = (_b = (_a = editorWrap.value) == null ? void 0 : _a.offsetHeight) != null ? _b : 100;
|
|
448
449
|
const handleMouseMove = (moveEvent) => {
|
|
450
|
+
var _a2;
|
|
449
451
|
const deltaY = moveEvent.clientY - startY;
|
|
450
452
|
const newHeight = startHeight + deltaY;
|
|
451
|
-
const minHeight =
|
|
453
|
+
const minHeight = (_a2 = props.minHeight) != null ? _a2 : 40;
|
|
452
454
|
resizedHeight.value = Math.max(minHeight, newHeight);
|
|
453
455
|
};
|
|
454
456
|
const handleMouseUp = () => {
|
|
@@ -492,6 +494,7 @@ const _sfc_main = defineComponent({
|
|
|
492
494
|
}, [
|
|
493
495
|
state.measuring ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
494
496
|
createVNode(MentionsSelect, {
|
|
497
|
+
"empty-tip": _ctx.optEmptyTip,
|
|
495
498
|
prefix: prefixCls.value,
|
|
496
499
|
options: options.value,
|
|
497
500
|
onClose: handleClose
|
|
@@ -500,7 +503,7 @@ const _sfc_main = defineComponent({
|
|
|
500
503
|
renderSlot(_ctx.$slots, "label", { data })
|
|
501
504
|
]),
|
|
502
505
|
_: 3
|
|
503
|
-
}, 8, ["prefix", "options"])
|
|
506
|
+
}, 8, ["empty-tip", "prefix", "options"])
|
|
504
507
|
])) : createCommentVNode("v-if", true)
|
|
505
508
|
], 2),
|
|
506
509
|
_ctx.resizable ? (openBlock(), createElementBlock("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mention.mjs","sources":["../../../../src/components/Mention/Mention.vue"],"sourcesContent":["<template>\n <div\n ref=\"editorWrap\"\n :class=\"[\n prefixCls,\n {\n disabled\n }\n ]\"\n :style=\"computedStyle\"\n >\n <div\n ref=\"divEditor\"\n :class=\"[`${prefixCls}-editor`]\"\n :contenteditable=\"!disabled\"\n :data-placeholder=\"placeholder\"\n @input=\"handleInput\"\n @keydown=\"handleKeyDown\"\n @keyup=\"handkeKeyUp\"\n @focus=\"onInputFocus\"\n @blur=\"onInputBlur\"\n @compositionstart=\"handleCompositionstart\"\n @compositionend=\"handleCompositionend\"\n @paste=\"onPaste\"\n />\n <div ref=\"popper\" :class=\"`${prefixCls}-popper-wrap`\">\n <div v-if=\"state.measuring\">\n <MentionsSelect :prefix=\"prefixCls\" :options=\"options\" @close=\"handleClose\">\n <template #label=\"{ data }\">\n <slot :data=\"data\" name=\"label\" />\n </template>\n </MentionsSelect>\n </div>\n </div>\n <div\n v-if=\"resizable\"\n class=\"resize-handle\"\n :style=\"{\n backgroundImage: `url('data:image/svg+xml;charset=utf-8,${encodeURIComponent(resizeSvg)}')`\n }\"\n @mousedown=\"startResize\"\n />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport type { Instance as PopperInstance } from '@popperjs/core';\nimport { createPopper } from '@popperjs/core';\nimport { ref, shallowRef, reactive, onMounted, provide, toRef, nextTick, watch, computed, onBeforeUnmount } from 'vue';\nimport { getCursorPosition, generateGetBoundingClientRect, getOffsetText, deleteContentAfterAtSign, insertMention } from './utils';\nimport KeyCode from './keyCode';\nimport { MentionsContextKey } from './mentionsTypes';\nimport MentionsSelect from './MentionsSelect.vue';\nimport type { MentionProps, MentionState, OptionProps } from './Mentions.type';\n\nconst props = withDefaults(defineProps<MentionProps>(), {\n placeholder: '',\n disabled: false,\n prefix: 'uui',\n triggerSign: () => ['@'],\n mentionClass: 'mention',\n styleMap: () => ({}),\n config: () => ({}),\n transformFn: (item: OptionProps) => item.label,\n resizable: false\n});\n\nconst emit = defineEmits<{\n (e: 'change', value: string): void;\n (e: 'focus', event: FocusEvent): void;\n (e: 'blur', event: FocusEvent): void;\n (e: 'pressenter'): void;\n (e: 'select', option: OptionProps): void;\n (e: 'openDialog', item: any): void;\n (e: 'update:modelValue', value: string): void;\n}>();\n\nconst resizedHeight = ref<number>(100);\n\nconst prefix = computed(() => Object.keys(props.config));\n\nconst resizeSvg = ref<string>(\n '<?xml version=\"1.0\" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"><svg t=\"1733799380257\" class=\"icon\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"6697\" width=\"16\" height=\"16\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><path d=\"M925.631795 576.639028L580.680138 921.590686c-21.563778 21.563778-21.563778 53.880784 0 75.456025s53.880784 21.552314 75.444561 0l344.963122-344.928729c21.552314-21.552314 21.552314-53.880784 0-75.444562-10.776157-21.563778-53.892248-21.563778-75.456026-0.034392z m86.232183-560.474793c-21.552314-21.552314-53.880784-21.552314-75.456026 0L20.205345 932.366842c-21.552314 21.563778-21.552314 53.880784 0 75.456026s53.880784 21.563778 75.456025 0l916.202608-916.202607c10.776157-21.552314 10.776157-53.892248 0-75.456026z\" fill=\"#CCCCCC\" p-id=\"6698\"></path></svg>'\n);\n\ndefineOptions({\n name: 'UMentions'\n});\n\nconst prefixCls = computed(() => {\n return `${props.prefix}-mention`;\n});\n\nconst divEditor = ref<HTMLDivElement | null>(null);\nconst computedStyle = computed(() => {\n return {\n height: resizedHeight.value ? `${resizedHeight.value}px` : typeof props.height === 'number' ? `${props.height}px` : props.height,\n maxHeight: props.maxHeight,\n minHeight: props.minHeight\n };\n});\n\nconst popper = ref<HTMLElement | null>(null);\nconst isInput = ref(false);\nconst popperIns = shallowRef<PopperInstance | null>(null);\nconst lastRange = shallowRef<Range | null>(null);\nconst composing = shallowRef(false);\nconst options = ref<OptionProps[]>([]);\n\ninterface VirtualElement {\n getBoundingClientRect: () => DOMRect;\n}\n\nconst virtualElement: VirtualElement = {\n getBoundingClientRect: generateGetBoundingClientRect(0, 0)\n};\n\nconst state = reactive<MentionState>({\n value: '',\n measuring: false,\n measureLocation: 0,\n measureText: null,\n measurePrefix: '',\n activeIndex: 0,\n isFocus: false\n});\n\nconst startMeasure = (measureText: string, measurePrefix: string, measureLocation: number) => {\n Object.assign(state, {\n measuring: true,\n measureText,\n measurePrefix,\n measureLocation,\n activeIndex: 0\n });\n};\n\nconst stopMeasure = (callback?: () => void) => {\n Object.assign(state, {\n measuring: false,\n measureLocation: 0,\n measureText: null\n });\n callback?.();\n};\n\nconst triggerChange = (val: string) => {\n emit('change', val);\n};\n\nconst setFocus = () => {\n if (divEditor.value) {\n divEditor.value.focus();\n }\n};\n\nonMounted(() => {\n const popperOptions = toRef(props, 'popperOptions');\n if (popperOptions.value && popper.value) {\n popperIns.value = createPopper(virtualElement as any, popper.value as HTMLElement, popperOptions.value);\n } else {\n popperIns.value = createPopper(virtualElement as any, popper.value as HTMLElement, {\n placement: 'auto',\n strategy: 'fixed'\n });\n }\n});\n\nconst handleCusClick = (item: any) => {\n emit('openDialog', item);\n};\n\nconst handleCompositionstart = () => {\n composing.value = true;\n};\nconst handleInput = () => {\n if (composing.value || props.disabled) {\n return;\n }\n // 检查光标位置和输入情况\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n const container = range.startContainer;\n\n // 检查是否在 mention span 内\n let mentionSpan: Node | null = container;\n while (mentionSpan && !(mentionSpan as HTMLElement).classList?.contains(props.mentionClass)) {\n mentionSpan = mentionSpan.parentNode;\n }\n\n // 如果在 mention span 内\n if (mentionSpan && (mentionSpan as HTMLElement).classList) {\n // 获取原始的 mention 文本\n const originalText = (mentionSpan as HTMLElement).getAttribute('data-name');\n const currentText = mentionSpan.textContent;\n\n if (currentText !== originalText && originalText !== null) {\n // 找出新输入的文本\n const newText = currentText?.replace(originalText, '') || '';\n\n // 恢复 mention 的原始文本\n mentionSpan.textContent = originalText;\n\n // 建新的文本节点,放在 mention span 的父元素中\n const textNode = document.createTextNode(newText);\n const { parentNode } = mentionSpan;\n // 如果 mention 后面已经有文本节点,就合并内容\n const nextNode = mentionSpan.nextSibling;\n if (nextNode && nextNode.nodeType === Node.TEXT_NODE) {\n nextNode.textContent = newText + (nextNode.textContent || '');\n // 设置光标位置到新文本的开始处\n const newRange = document.createRange();\n newRange.setStart(nextNode, newText.length);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n } else {\n // 否则插入新的文本节点\n parentNode.insertBefore(textNode, mentionSpan.nextSibling);\n // 设置光标位置到新文本节点\n const newRange = document.createRange();\n newRange.setStart(textNode, newText.length);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n }\n }\n }\n }\n\n const content = divEditor.value?.innerHTML || '';\n triggerChange(content);\n emit('update:modelValue', content);\n};\n\nconst handleCompositionend = () => {\n composing.value = false;\n\n handleInput();\n};\n\nconst selectOption = (option: OptionProps) => {\n const selecttion = window.getSelection();\n if (document.activeElement !== (divEditor.value as unknown as Node)) {\n setFocus();\n\n if (selecttion) {\n selecttion.removeAllRanges();\n selecttion.addRange(lastRange.value);\n }\n }\n\n if (selecttion) {\n const range = selecttion.getRangeAt(0);\n\n deleteContentAfterAtSign(range, state.measurePrefix);\n\n const r = selecttion.getRangeAt(0);\n const { value } = option;\n const text = props.transformFn(option);\n\n // Add zero-width spaces before and after the mention text\n const mentionText = `${text}`;\n\n insertMention(r, mentionText, value, props.mentionClass, props.styleMap[state.measurePrefix]);\n\n handleInput();\n triggerChange(divEditor.value.innerHTML);\n\n composing.value = false;\n stopMeasure();\n }\n};\n\nconst onPaste = (event: ClipboardEvent) => {\n event.preventDefault();\n\n const { clipboardData } = event;\n const selection = window.getSelection();\n\n if (selection && clipboardData) {\n // 清理粘贴内容中的零宽空格(包括 HTML 实体形式)\n const pastedData = clipboardData.getData('text/plain');\n\n const range = selection.getRangeAt(0);\n\n // Remove the selected content before inserting the pasted data\n range.deleteContents();\n\n const currentNode = range.startContainer;\n const { startOffset } = range;\n if (currentNode.nodeType === Node.TEXT_NODE) {\n const currentText = currentNode.textContent;\n const beforeText = currentText.slice(0, startOffset);\n const afterText = currentText.slice(startOffset);\n currentNode.textContent = beforeText + pastedData + afterText;\n const newRange = document.createRange();\n newRange.setStart(currentNode, startOffset + pastedData.length);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n } else {\n const textNode = document.createTextNode(pastedData);\n range.insertNode(textNode);\n\n // 设置光标位置到新文本的末尾\n const newRange = document.createRange();\n newRange.setStart(textNode, pastedData.length);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n }\n\n handleInput();\n }\n};\n\nconst handkeKeyUp = (event: KeyboardEvent) => {\n const { which } = event;\n\n if ([KeyCode.ESC, KeyCode.UP, KeyCode.DOWN, KeyCode.ENTER].indexOf(which) !== -1) {\n return;\n }\n\n const selection = window.getSelection();\n if (!selection || !selection.rangeCount) return;\n\n const range = selection.getRangeAt(0);\n const { startContainer, startOffset } = range;\n\n // 检查光标前面的字符是否是提及符号\n let beforeText = '';\n if (startContainer.nodeType === Node.TEXT_NODE) {\n beforeText = startContainer.textContent.slice(0, startOffset);\n }\n\n // 如果光标前没有文,检查前一个节点\n if (!beforeText && startOffset === 0) {\n const prevNode = startContainer.previousSibling;\n if (prevNode && prevNode.nodeType === Node.TEXT_NODE) {\n beforeText = prevNode.textContent;\n }\n }\n\n // 检查光标前最后一个字符是否是提及符号\n const lastChar = beforeText.slice(-1);\n const isPrefixChar = prefix.value.includes(lastChar);\n\n if (isPrefixChar) {\n // 获取当前输入框的完整文本\n const innerText = getOffsetText();\n options.value = props.config[lastChar] || [];\n\n // 检查是否在mention span内\n let inMentionSpan = false;\n let currentNode = startContainer;\n while (currentNode && currentNode !== (divEditor.value as unknown as Node)) {\n if ((currentNode as HTMLElement).classList?.contains(props.mentionClass)) {\n inMentionSpan = true;\n break;\n }\n currentNode = currentNode.parentNode;\n }\n\n if (!inMentionSpan) {\n const { x, y } = getCursorPosition();\n virtualElement.getBoundingClientRect = generateGetBoundingClientRect(x, y);\n popperIns.value?.update();\n lastRange.value = range;\n\n // 获取@后面的搜索文本\n const afterText = innerText.slice(beforeText.length);\n const searchText = afterText.split(/[\\s\\n]/)[0] || '';\n\n startMeasure(searchText, lastChar, beforeText.length - 1);\n }\n } else if (state.measuring) {\n // 如果光标前不是提及符号且列表正在显示,则关闭列表\n stopMeasure();\n }\n};\n\nconst handleKeyDown = (event: KeyboardEvent) => {\n const { which } = event;\n\n // 处理回车键\n if (which === KeyCode.ENTER) {\n event.preventDefault();\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n range.collapse(false);\n const div = document.createElement('div');\n div.innerHTML = '<br>';\n\n // 获取当前节点和其父节点\n const currentNode = range.startContainer;\n const { parentNode } = currentNode;\n\n if ((parentNode as HTMLElement).classList?.contains(props.mentionClass)) {\n // 如果在mention内,将mention后的内容一起移到新行\n const afterContent = parentNode.nextSibling;\n if (afterContent) {\n div.appendChild(afterContent.cloneNode(true));\n afterContent.remove();\n }\n parentNode.parentNode.insertBefore(div, parentNode.nextSibling);\n } else if ((currentNode.previousSibling as HTMLElement)?.classList?.contains(props.mentionClass)) {\n // 如果在mention后,将当前位置后的内容起移到新行\n const afterContent = currentNode.textContent.substring(range.startOffset);\n if (afterContent) {\n div.textContent = afterContent;\n currentNode.textContent = currentNode.textContent.substring(0, range.startOffset);\n }\n currentNode.parentNode.insertBefore(div, currentNode.nextSibling);\n } else {\n // 普通文本节点的处理\n const { startOffset } = range;\n const currentContent = currentNode.textContent || '';\n\n if (startOffset > 0) {\n const beforeText = currentContent.substring(0, startOffset);\n const afterText = currentContent.substring(startOffset);\n\n if (afterText) {\n div.textContent = afterText;\n }\n\n if (currentNode.nodeType === Node.TEXT_NODE) {\n currentNode.textContent = beforeText;\n }\n }\n\n // 找到当前行的父级块级元素\n let blockParent: Node | null = currentNode;\n while (blockParent && blockParent.parentNode !== (divEditor.value as unknown)) {\n blockParent = blockParent.parentNode;\n }\n\n // 插入新行\n if (blockParent) {\n blockParent.parentNode.insertBefore(div, blockParent.nextSibling);\n } else {\n divEditor.value.appendChild(div);\n }\n }\n\n // 将光标移动到新div的开始位置\n const newRange = document.createRange();\n newRange.setStart(div, 0);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n\n handleInput();\n }\n return;\n }\n\n if (!state.measuring) {\n // 处理删除键\n if (which === KeyCode.BACKSPACE) {\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n\n // 检查是否选中了内容\n if (!range.collapsed) {\n event.preventDefault();\n range.deleteContents();\n handleInput();\n } else {\n // 检查当前节点是否在 mention span 内部\n let mentionSpan = range.startContainer;\n while (mentionSpan && !(mentionSpan as HTMLElement).classList?.contains(props.mentionClass)) {\n mentionSpan = mentionSpan.parentNode;\n }\n\n // 如果在 mention span 内部\n if (mentionSpan) {\n event.preventDefault();\n const text = mentionSpan.textContent;\n // 创建新的文本节点,内容是去掉最后一个字符的文本\n const newText = text.slice(0, -1);\n const textNode = document.createTextNode(newText);\n mentionSpan.parentNode.insertBefore(textNode, mentionSpan);\n (mentionSpan as HTMLElement).remove();\n\n // 设置光标位置到新文本的末尾\n const newRange = document.createRange();\n newRange.setStart(textNode, newText.length);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n\n handleInput();\n return;\n }\n\n // 处理光标在mention前的删除操作\n const offset = range.startOffset;\n if (offset === 0) {\n const prevNode = range.startContainer.previousSibling;\n if (prevNode && (prevNode as HTMLElement).classList?.contains(props.mentionClass)) {\n event.preventDefault();\n prevNode.remove();\n handleInput();\n }\n }\n }\n }\n }\n return;\n }\n if (which === KeyCode.ESC) {\n stopMeasure();\n }\n};\n\nconst onFocus = (event: FocusEvent) => {\n const { isFocus } = state;\n if (!isFocus && event) {\n emit('focus', event);\n }\n state.isFocus = true;\n};\nconst onBlur = () => {\n const focusTimer = setTimeout(() => {\n state.isFocus = false;\n stopMeasure();\n }, 100);\n clearTimeout(focusTimer);\n};\n\nconst onInputFocus = (event: FocusEvent) => {\n isInput.value = true;\n composing.value = false;\n onFocus(event);\n};\nconst onInputBlur = () => {\n isInput.value = false;\n composing.value = false;\n\n onBlur();\n};\n\nconst setActiveIndex = (activeIndex: number) => {\n state.activeIndex = activeIndex;\n};\n\nprovide(MentionsContextKey, {\n activeIndex: toRef(state, 'activeIndex'),\n setActiveIndex,\n selectOption,\n onFocus,\n onBlur,\n handleCusClick,\n loading: toRef(props, 'loading')\n});\n\nconst initEditor = ({ html }: { html: string }) => {\n nextTick(() => {\n divEditor.value.innerHTML = html;\n });\n};\nonMounted(() => {\n divEditor.value.innerHTML = String(props.modelValue);\n});\nconst handleClose = () => {\n state.measuring = false;\n};\nwatch(\n () => props.modelValue,\n (val) => {\n if (isInput.value) {\n return;\n }\n if (divEditor.value) {\n divEditor.value.innerHTML = String(val);\n }\n }\n);\nonBeforeUnmount(() => {\n if (popperIns.value) {\n popperIns.value.destroy();\n popperIns.value = null;\n }\n});\ndefineExpose({\n selectOption,\n setFocus,\n divEditor,\n initEditor,\n onPaste,\n computedStyle\n});\n\nconst editorWrap = ref<HTMLDivElement | null>(null);\n\nconst startResize = (e: MouseEvent) => {\n e.preventDefault();\n\n const startY = e.clientY;\n const startHeight = editorWrap.value?.offsetHeight ?? 100;\n\n const handleMouseMove = (moveEvent: MouseEvent) => {\n const deltaY = moveEvent.clientY - startY;\n const newHeight = startHeight + deltaY;\n\n // 设置最小高度限制\n const minHeight = 100;\n resizedHeight.value = Math.max(minHeight, newHeight);\n };\n\n const handleMouseUp = () => {\n document.removeEventListener('mousemove', handleMouseMove);\n document.removeEventListener('mouseup', handleMouseUp);\n };\n\n document.addEventListener('mousemove', handleMouseMove);\n document.addEventListener('mouseup', handleMouseUp);\n};\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAuDM,QAAQ;UAYR,OAAO;UAUP,gBAAgB,IAAY,GAAG;UAE/B,SAAS,SAAS,MAAM,OAAO,KAAK,MAAM,MAAM,CAAC;UAEjD,YAAY;AAAA,MAChB;AAAA;UAOI,YAAY,SAAS,MAAM;aACxB,GAAG,MAAM;AAAA,KACjB;UAEK,YAAY,IAA2B,IAAI;UAC3C,gBAAgB,SAAS,MAAM;aAC5B;AAAA,QACL,QAAQ,cAAc,QAAQ,GAAG,cAAc,YAAY,OAAO,MAAM,WAAW,WAAW,GAAG,MAAM,aAAa,MAAM;AAAA,QAC1H,WAAW,MAAM;AAAA,QACjB,WAAW,MAAM;AAAA;AACnB,KACD;UAEK,SAAS,IAAwB,IAAI;UACrC,UAAU,IAAI,KA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;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Mention.mjs","sources":["../../../../src/components/Mention/Mention.vue"],"sourcesContent":["<template>\n <div\n ref=\"editorWrap\"\n :class=\"[\n prefixCls,\n {\n disabled\n }\n ]\"\n :style=\"computedStyle\"\n >\n <div\n ref=\"divEditor\"\n :class=\"[`${prefixCls}-editor`]\"\n :contenteditable=\"!disabled\"\n :data-placeholder=\"placeholder\"\n @input=\"handleInput\"\n @keydown=\"handleKeyDown\"\n @keyup=\"handkeKeyUp\"\n @focus=\"onInputFocus\"\n @blur=\"onInputBlur\"\n @compositionstart=\"handleCompositionstart\"\n @compositionend=\"handleCompositionend\"\n @paste=\"onPaste\"\n />\n <div ref=\"popper\" :class=\"`${prefixCls}-popper-wrap`\">\n <div v-if=\"state.measuring\">\n <MentionsSelect :empty-tip=\"optEmptyTip\" :prefix=\"prefixCls\" :options=\"options\" @close=\"handleClose\">\n <template #label=\"{ data }\">\n <slot :data=\"data\" name=\"label\" />\n </template>\n </MentionsSelect>\n </div>\n </div>\n <div\n v-if=\"resizable\"\n class=\"resize-handle\"\n :style=\"{\n backgroundImage: `url('data:image/svg+xml;charset=utf-8,${encodeURIComponent(resizeSvg)}')`\n }\"\n @mousedown=\"startResize\"\n />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport type { Instance as PopperInstance } from '@popperjs/core';\nimport { createPopper } from '@popperjs/core';\nimport { ref, shallowRef, reactive, onMounted, provide, toRef, nextTick, watch, computed, onBeforeUnmount } from 'vue';\nimport { getCursorPosition, generateGetBoundingClientRect, getOffsetText, deleteContentAfterAtSign, insertMention } from './utils';\nimport KeyCode from './keyCode';\nimport { MentionsContextKey } from './mentionsTypes';\nimport MentionsSelect from './MentionsSelect.vue';\nimport type { MentionProps, MentionState, OptionProps } from './Mentions.type';\n\nconst props = withDefaults(defineProps<MentionProps>(), {\n placeholder: '',\n disabled: false,\n prefix: 'uui',\n optEmptyTip: '',\n triggerSign: () => ['@'],\n mentionClass: 'mention',\n styleMap: () => ({}),\n config: () => ({}),\n transformFn: (item: OptionProps) => item.label,\n resizable: false\n});\n\nconst emit = defineEmits<{\n (e: 'change', value: string): void;\n (e: 'focus', event: FocusEvent): void;\n (e: 'blur', event: FocusEvent): void;\n (e: 'pressenter'): void;\n (e: 'select', option: OptionProps): void;\n (e: 'openDialog', item: any): void;\n (e: 'update:modelValue', value: string): void;\n}>();\n\nconst resizedHeight = ref<number>(100);\n\nconst prefix = computed(() => Object.keys(props.config));\n\nconst resizeSvg = ref<string>(\n '<?xml version=\"1.0\" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"><svg t=\"1733799380257\" class=\"icon\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"6697\" width=\"16\" height=\"16\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><path d=\"M925.631795 576.639028L580.680138 921.590686c-21.563778 21.563778-21.563778 53.880784 0 75.456025s53.880784 21.552314 75.444561 0l344.963122-344.928729c21.552314-21.552314 21.552314-53.880784 0-75.444562-10.776157-21.563778-53.892248-21.563778-75.456026-0.034392z m86.232183-560.474793c-21.552314-21.552314-53.880784-21.552314-75.456026 0L20.205345 932.366842c-21.552314 21.563778-21.552314 53.880784 0 75.456026s53.880784 21.563778 75.456025 0l916.202608-916.202607c10.776157-21.552314 10.776157-53.892248 0-75.456026z\" fill=\"#CCCCCC\" p-id=\"6698\"></path></svg>'\n);\n\ndefineOptions({\n name: 'UMentions'\n});\n\nconst prefixCls = computed(() => {\n return `${props.prefix}-mention`;\n});\n\nconst divEditor = ref<HTMLDivElement | null>(null);\nconst computedStyle = computed(() => {\n return {\n height: resizedHeight.value ? `${resizedHeight.value}px` : typeof props.height === 'number' ? `${props.height}px` : props.height,\n maxHeight: props.maxHeight,\n minHeight: props.minHeight\n };\n});\n\nconst popper = ref<HTMLElement | null>(null);\nconst isInput = ref(false);\nconst popperIns = shallowRef<PopperInstance | null>(null);\nconst lastRange = shallowRef<Range | null>(null);\nconst composing = shallowRef(false);\nconst options = ref<OptionProps[]>([]);\n\ninterface VirtualElement {\n getBoundingClientRect: () => DOMRect;\n}\n\nconst virtualElement: VirtualElement = {\n getBoundingClientRect: generateGetBoundingClientRect(0, 0)\n};\n\nconst state = reactive<MentionState>({\n value: '',\n measuring: false,\n measureLocation: 0,\n measureText: null,\n measurePrefix: '',\n activeIndex: 0,\n isFocus: false\n});\n\nconst startMeasure = (measureText: string, measurePrefix: string, measureLocation: number) => {\n Object.assign(state, {\n measuring: true,\n measureText,\n measurePrefix,\n measureLocation,\n activeIndex: 0\n });\n};\n\nconst stopMeasure = (callback?: () => void) => {\n Object.assign(state, {\n measuring: false,\n measureLocation: 0,\n measureText: null\n });\n callback?.();\n};\n\nconst triggerChange = (val: string) => {\n emit('change', val);\n};\n\nconst setFocus = () => {\n if (divEditor.value) {\n divEditor.value.focus();\n }\n};\n\nonMounted(() => {\n const popperOptions = toRef(props, 'popperOptions');\n if (popperOptions.value && popper.value) {\n popperIns.value = createPopper(virtualElement as any, popper.value as HTMLElement, popperOptions.value);\n } else {\n popperIns.value = createPopper(virtualElement as any, popper.value as HTMLElement, {\n placement: 'auto',\n strategy: 'fixed'\n });\n }\n});\n\nconst handleCusClick = (item: any) => {\n emit('openDialog', item);\n};\n\nconst handleCompositionstart = () => {\n composing.value = true;\n};\nconst handleInput = () => {\n if (composing.value || props.disabled) {\n return;\n }\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n const container = range.startContainer;\n\n let mentionSpan: Node | null = container;\n while (mentionSpan && !(mentionSpan as HTMLElement).classList?.contains(props.mentionClass)) {\n mentionSpan = mentionSpan.parentNode;\n }\n\n if (mentionSpan && (mentionSpan as HTMLElement).classList) {\n const originalText = (mentionSpan as HTMLElement).getAttribute('data-name');\n const currentText = mentionSpan.textContent;\n\n if (currentText !== originalText && originalText !== null) {\n const newText = currentText?.replace(originalText, '') || '';\n\n mentionSpan.textContent = originalText;\n\n const textNode = document.createTextNode(newText);\n const { parentNode } = mentionSpan;\n const nextNode = mentionSpan.nextSibling;\n if (nextNode && nextNode.nodeType === Node.TEXT_NODE) {\n nextNode.textContent = newText + (nextNode.textContent || '');\n const newRange = document.createRange();\n newRange.setStart(nextNode, newText.length);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n } else {\n parentNode.insertBefore(textNode, mentionSpan.nextSibling);\n const newRange = document.createRange();\n newRange.setStart(textNode, newText.length);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n }\n }\n }\n }\n\n const content = divEditor.value?.innerHTML || '';\n triggerChange(content);\n emit('update:modelValue', content);\n};\n\nconst handleCompositionend = () => {\n composing.value = false;\n\n handleInput();\n};\n\nconst selectOption = (option: OptionProps) => {\n const selecttion = window.getSelection();\n if (document.activeElement !== (divEditor.value as unknown as Node)) {\n setFocus();\n\n if (selecttion) {\n selecttion.removeAllRanges();\n selecttion.addRange(lastRange.value);\n }\n }\n\n if (selecttion) {\n const range = selecttion.getRangeAt(0);\n\n deleteContentAfterAtSign(range, state.measurePrefix);\n\n const r = selecttion.getRangeAt(0);\n const { value } = option;\n const text = props.transformFn(option);\n\n // Add zero-width spaces before and after the mention text\n const mentionText = `${text}`;\n\n insertMention(r, mentionText, value, props.mentionClass, props.styleMap[state.measurePrefix]);\n\n handleInput();\n triggerChange(divEditor.value.innerHTML);\n\n composing.value = false;\n stopMeasure();\n }\n};\n\nconst onPaste = (event: ClipboardEvent) => {\n event.preventDefault();\n\n const { clipboardData } = event;\n const selection = window.getSelection();\n\n if (selection && clipboardData) {\n const pastedData = clipboardData.getData('text/plain');\n\n const range = selection.getRangeAt(0);\n\n // Remove the selected content before inserting the pasted data\n range.deleteContents();\n\n const currentNode = range.startContainer;\n const { startOffset } = range;\n if (currentNode.nodeType === Node.TEXT_NODE) {\n const currentText = currentNode.textContent;\n const beforeText = currentText.slice(0, startOffset);\n const afterText = currentText.slice(startOffset);\n currentNode.textContent = beforeText + pastedData + afterText;\n const newRange = document.createRange();\n newRange.setStart(currentNode, startOffset + pastedData.length);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n } else {\n const textNode = document.createTextNode(pastedData);\n range.insertNode(textNode);\n\n const newRange = document.createRange();\n newRange.setStart(textNode, pastedData.length);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n }\n\n handleInput();\n }\n};\n\nconst handkeKeyUp = (event: KeyboardEvent) => {\n const { which } = event;\n\n if ([KeyCode.ESC, KeyCode.UP, KeyCode.DOWN, KeyCode.ENTER].indexOf(which) !== -1) {\n return;\n }\n\n const selection = window.getSelection();\n if (!selection || !selection.rangeCount) return;\n\n const range = selection.getRangeAt(0);\n const { startContainer, startOffset } = range;\n\n let beforeText = '';\n if (startContainer.nodeType === Node.TEXT_NODE) {\n beforeText = startContainer.textContent.slice(0, startOffset);\n }\n\n if (!beforeText && startOffset === 0) {\n const prevNode = startContainer.previousSibling;\n if (prevNode && prevNode.nodeType === Node.TEXT_NODE) {\n beforeText = prevNode.textContent;\n }\n }\n\n const lastChar = beforeText.slice(-1);\n const isPrefixChar = prefix.value.includes(lastChar);\n\n if (isPrefixChar) {\n const innerText = getOffsetText();\n options.value = props.config[lastChar] || [];\n\n let inMentionSpan = false;\n let currentNode = startContainer;\n while (currentNode && currentNode !== (divEditor.value as unknown as Node)) {\n if ((currentNode as HTMLElement).classList?.contains(props.mentionClass)) {\n inMentionSpan = true;\n break;\n }\n currentNode = currentNode.parentNode;\n }\n\n if (!inMentionSpan) {\n const { x, y } = getCursorPosition();\n virtualElement.getBoundingClientRect = generateGetBoundingClientRect(x, y);\n popperIns.value?.update();\n lastRange.value = range;\n\n const afterText = innerText.slice(beforeText.length);\n const searchText = afterText.split(/[\\s\\n]/)[0] || '';\n\n startMeasure(searchText, lastChar, beforeText.length - 1);\n }\n } else if (state.measuring) {\n stopMeasure();\n }\n};\n\nconst handleKeyDown = (event: KeyboardEvent) => {\n const { which } = event;\n\n if (which === KeyCode.ENTER) {\n event.preventDefault();\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n range.collapse(false);\n const div = document.createElement('div');\n div.innerHTML = '<br>';\n\n const currentNode = range.startContainer;\n const { parentNode } = currentNode;\n\n if ((parentNode as HTMLElement).classList?.contains(props.mentionClass)) {\n const afterContent = parentNode.nextSibling;\n if (afterContent) {\n div.appendChild(afterContent.cloneNode(true));\n afterContent.remove();\n }\n parentNode.parentNode.insertBefore(div, parentNode.nextSibling);\n } else if ((currentNode.previousSibling as HTMLElement)?.classList?.contains(props.mentionClass)) {\n const afterContent = currentNode.textContent.substring(range.startOffset);\n if (afterContent) {\n div.textContent = afterContent;\n currentNode.textContent = currentNode.textContent.substring(0, range.startOffset);\n }\n currentNode.parentNode.insertBefore(div, currentNode.nextSibling);\n } else {\n const { startOffset } = range;\n const currentContent = currentNode.textContent || '';\n\n if (startOffset > 0) {\n const beforeText = currentContent.substring(0, startOffset);\n const afterText = currentContent.substring(startOffset);\n\n if (afterText) {\n div.textContent = afterText;\n }\n\n if (currentNode.nodeType === Node.TEXT_NODE) {\n currentNode.textContent = beforeText;\n }\n }\n\n let blockParent: Node | null = currentNode;\n while (blockParent && blockParent.parentNode !== (divEditor.value as unknown)) {\n blockParent = blockParent.parentNode;\n }\n\n if (blockParent) {\n blockParent.parentNode.insertBefore(div, blockParent.nextSibling);\n } else {\n divEditor.value.appendChild(div);\n }\n }\n\n const newRange = document.createRange();\n newRange.setStart(div, 0);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n\n handleInput();\n }\n return;\n }\n\n if (!state.measuring) {\n if (which === KeyCode.BACKSPACE) {\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n\n if (!range.collapsed) {\n event.preventDefault();\n range.deleteContents();\n handleInput();\n } else {\n let mentionSpan = range.startContainer;\n while (mentionSpan && !(mentionSpan as HTMLElement).classList?.contains(props.mentionClass)) {\n mentionSpan = mentionSpan.parentNode;\n }\n\n if (mentionSpan) {\n event.preventDefault();\n const text = mentionSpan.textContent;\n const newText = text.slice(0, -1);\n const textNode = document.createTextNode(newText);\n mentionSpan.parentNode.insertBefore(textNode, mentionSpan);\n (mentionSpan as HTMLElement).remove();\n\n const newRange = document.createRange();\n newRange.setStart(textNode, newText.length);\n newRange.collapse(true);\n selection.removeAllRanges();\n selection.addRange(newRange);\n\n handleInput();\n return;\n }\n\n const offset = range.startOffset;\n if (offset === 0) {\n const prevNode = range.startContainer.previousSibling;\n if (prevNode && (prevNode as HTMLElement).classList?.contains(props.mentionClass)) {\n event.preventDefault();\n prevNode.remove();\n handleInput();\n }\n }\n }\n }\n }\n return;\n }\n if (which === KeyCode.ESC) {\n stopMeasure();\n }\n};\n\nconst onFocus = (event: FocusEvent) => {\n const { isFocus } = state;\n if (!isFocus && event) {\n emit('focus', event);\n }\n state.isFocus = true;\n};\nconst onBlur = () => {\n const focusTimer = setTimeout(() => {\n state.isFocus = false;\n stopMeasure();\n }, 100);\n clearTimeout(focusTimer);\n};\n\nconst onInputFocus = (event: FocusEvent) => {\n isInput.value = true;\n composing.value = false;\n onFocus(event);\n};\nconst onInputBlur = () => {\n isInput.value = false;\n composing.value = false;\n\n onBlur();\n};\n\nconst setActiveIndex = (activeIndex: number) => {\n state.activeIndex = activeIndex;\n};\n\nprovide(MentionsContextKey, {\n activeIndex: toRef(state, 'activeIndex'),\n setActiveIndex,\n selectOption,\n onFocus,\n onBlur,\n handleCusClick,\n loading: toRef(props, 'loading')\n});\n\nconst initEditor = ({ html }: { html: string }) => {\n nextTick(() => {\n divEditor.value.innerHTML = html;\n });\n};\nonMounted(() => {\n divEditor.value.innerHTML = String(props.modelValue);\n});\nconst handleClose = () => {\n state.measuring = false;\n};\nwatch(\n () => props.modelValue,\n (val) => {\n if (isInput.value) {\n return;\n }\n if (divEditor.value) {\n divEditor.value.innerHTML = String(val);\n }\n }\n);\nonBeforeUnmount(() => {\n if (popperIns.value) {\n popperIns.value.destroy();\n popperIns.value = null;\n }\n});\ndefineExpose({\n selectOption,\n setFocus,\n divEditor,\n initEditor,\n onPaste,\n computedStyle\n});\n\nconst editorWrap = ref<HTMLDivElement | null>(null);\n\nconst startResize = (e: MouseEvent) => {\n e.preventDefault();\n\n const startY = e.clientY;\n const startHeight = editorWrap.value?.offsetHeight ?? 100;\n\n const handleMouseMove = (moveEvent: MouseEvent) => {\n const deltaY = moveEvent.clientY - startY;\n const newHeight = startHeight + deltaY;\n\n const minHeight = (props.minHeight as number) ?? 40;\n resizedHeight.value = Math.max(minHeight, newHeight);\n };\n\n const handleMouseUp = () => {\n document.removeEventListener('mousemove', handleMouseMove);\n document.removeEventListener('mouseup', handleMouseUp);\n };\n\n document.addEventListener('mousemove', handleMouseMove);\n document.addEventListener('mouseup', handleMouseUp);\n};\n</script>\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAuDM,QAAQ;UAaR,OAAO;UAUP,gBAAgB,IAAY,GAAG;UAE/B,SAAS,SAAS,MAAM,OAAO,KAAK,MAAM,MAAM,CAAC;UAEjD,YAAY;AAAA,MAChB;AAAA;UAOI,YAAY,SAAS,MAAM;aACxB,GAAG,MAAM;AAAA,KACjB;UAEK,YAAY,IAA2B,IAAI;UAC3C,gBAAgB,SAAS,MAAM;aAC5B;AAAA,QACL,QAAQ,cAAc,QAAQ,GAAG,cAAc,YAAY,OAAO,MAAM,WAAW,WAAW,GAAG,MAAM,aAAa,MAAM;AAAA,QAC1H,WAAW,MAAM;AAAA,QACjB,WAAW,MAAM;AAAA;AACnB,KACD;UAEK,SAAS,IAAwB,IAAI;UACrC,UAAU,IAAI,KAAK;UACnB,YAAY,WAAkC,IAAI;UAClD,YAAY,WAAyB,IAAI;UACzC,YAAY,WAAW,KAAK;UAC5B,UAAU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js","sources":["../../../../src/components/Mention/Mentions.type.ts"],"sourcesContent":["import type { InjectionKey, PropType, VNode, Ref } from 'vue';\n\nexport type VNodeChildAtom = VNode | string | number | boolean | null | undefined | void;\nexport type VueNode = VNodeChildAtom | VNodeChildAtom[];\n\nexport function anyType<T = any>(defaultVal?: T, required?: boolean) {\n const type = { validator: () => true, default: defaultVal as T } as unknown;\n return required\n ? (type as {\n type: PropType<T>;\n default: T;\n required: true;\n })\n : (type as {\n default: T;\n type: PropType<T>;\n });\n}\n\nexport function arrayType<T extends any[]>(defaultVal?: T) {\n return { type: Array as unknown as PropType<T>, default: defaultVal as T };\n}\n\nexport function objectType<T = any>(defaultVal?: T) {\n return { type: Object as PropType<T>, default: defaultVal as T };\n}\n\nexport const baseOptionsProps = {\n value: String,\n disabled: Boolean,\n payload: objectType<Record<string, any>>()\n};\n\nexport interface OptionProps {\n label: string;\n value: string;\n [key: string]: any;\n}\n\nexport type EventHandler = (...args: any[]) => void;\n\nexport interface MentionsContext {\n activeIndex: Ref<number>;\n setActiveIndex?: (index: number) => void;\n selectOption?: (option: OptionProps) => void;\n onFocus?: EventListener;\n onBlur?: EventListener;\n loading?: Ref<boolean>;\n handleCusClick?: <T>(item?: T) => void;\n}\n\nexport interface MentionConfig {\n html: string;\n}\n\nexport interface MentionState {\n value: string;\n measuring: boolean;\n measureLocation: number;\n measureText: string | null;\n measurePrefix: string;\n activeIndex: number;\n isFocus: boolean;\n}\n\nexport interface MentionProps {\n placeholder?: string;\n disabled?: boolean;\n styleMap?: Record<string, string>;\n config: Record<string, any>;\n resizable?: boolean;\n prefix?: string;\n triggerSign?: string[];\n mentionClass?: string;\n popperOptions?: any;\n transformFn?: (item: OptionProps) => string;\n modelValue: string | number;\n height?: number | string;\n maxHeight?: number | string;\n minHeight?: number | string;\n loading?: boolean;\n}\n\nexport const MentionsopenDialogValue: InjectionKey<any> = Symbol('MentionsopenDialogValue');\n"],"names":[],"mappings":"SAKgB,QAAiB,YAAgB,UAAoB;AACnE,QAAM,OAAO,EAAE,WAAW,MAAM,MAAM,SAAS;AAC/C,SAAO,WACF,OAKA;AAIP;SAEgB,UAA2B,YAAgB;AACzD,SAAO,EAAE,MAAM,OAAiC,SAAS;AAC3D;SAEgB,WAAoB,YAAgB;AAClD,SAAO,EAAE,MAAM,QAAuB,SAAS;AACjD;MAEa,mBAAmB;AAAA,EAC9B,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AACX;
|
|
1
|
+
{"version":3,"file":"Mentions.type.mjs","sources":["../../../../src/components/Mention/Mentions.type.ts"],"sourcesContent":["import type { InjectionKey, PropType, VNode, Ref } from 'vue';\n\nexport type VNodeChildAtom = VNode | string | number | boolean | null | undefined | void;\nexport type VueNode = VNodeChildAtom | VNodeChildAtom[];\n\nexport function anyType<T = any>(defaultVal?: T, required?: boolean) {\n const type = { validator: () => true, default: defaultVal as T } as unknown;\n return required\n ? (type as {\n type: PropType<T>;\n default: T;\n required: true;\n })\n : (type as {\n default: T;\n type: PropType<T>;\n });\n}\n\nexport function arrayType<T extends any[]>(defaultVal?: T) {\n return { type: Array as unknown as PropType<T>, default: defaultVal as T };\n}\n\nexport function objectType<T = any>(defaultVal?: T) {\n return { type: Object as PropType<T>, default: defaultVal as T };\n}\n\nexport const baseOptionsProps = {\n value: String,\n disabled: Boolean,\n payload: objectType<Record<string, any>>()\n};\n\nexport interface OptionProps {\n label: string;\n value: string;\n [key: string]: any;\n}\n\nexport type EventHandler = (...args: any[]) => void;\n\nexport interface MentionsContext {\n activeIndex: Ref<number>;\n setActiveIndex?: (index: number) => void;\n selectOption?: (option: OptionProps) => void;\n onFocus?: EventListener;\n onBlur?: EventListener;\n loading?: Ref<boolean>;\n handleCusClick?: <T>(item?: T) => void;\n}\n\nexport interface MentionConfig {\n html: string;\n}\n\nexport interface MentionState {\n value: string;\n measuring: boolean;\n measureLocation: number;\n measureText: string | null;\n measurePrefix: string;\n activeIndex: number;\n isFocus: boolean;\n}\n\nexport interface MentionProps {\n placeholder?: string;\n disabled?: boolean;\n styleMap?: Record<string, string>;\n config: Record<string, any>;\n resizable?: boolean;\n optEmptyTip?: string;\n prefix?: string;\n triggerSign?: string[];\n mentionClass?: string;\n popperOptions?: any;\n transformFn?: (item: OptionProps) => string;\n modelValue: string | number;\n height?: number | string;\n maxHeight?: number | string;\n minHeight?: number | string;\n loading?: boolean;\n}\n\nexport const MentionsopenDialogValue: InjectionKey<any> = Symbol('MentionsopenDialogValue');\n"],"names":[],"mappings":"SAKgB,QAAiB,YAAgB,UAAoB;AACnE,QAAM,OAAO,EAAE,WAAW,MAAM,MAAM,SAAS;AAC/C,SAAO,WACF,OAKA;AAIP;SAEgB,UAA2B,YAAgB;AACzD,SAAO,EAAE,MAAM,OAAiC,SAAS;AAC3D;SAEgB,WAAoB,YAAgB;AAClD,SAAO,EAAE,MAAM,QAAuB,SAAS;AACjD;MAEa,mBAAmB;AAAA,EAC9B,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AACX;MAqDa,0BAA6C,OAAO,yBAAyB;;;;"}
|
|
@@ -12,6 +12,10 @@ const _hoisted_2 = {
|
|
|
12
12
|
const _sfc_main = {
|
|
13
13
|
__name: "MentionsSelect",
|
|
14
14
|
props: {
|
|
15
|
+
emptyTip: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: ""
|
|
18
|
+
},
|
|
15
19
|
options: {
|
|
16
20
|
type: Array,
|
|
17
21
|
default: () => []
|
|
@@ -101,7 +105,7 @@ const _sfc_main = {
|
|
|
101
105
|
_: 3
|
|
102
106
|
})
|
|
103
107
|
], 2),
|
|
104
|
-
showNoData.value ? (openBlock(), createElementBlock("div", _hoisted_2,
|
|
108
|
+
showNoData.value ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(__props.emptyTip), 1)) : createCommentVNode("v-if", true)
|
|
105
109
|
], 2);
|
|
106
110
|
};
|
|
107
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentionsSelect.mjs","sources":["../../../../src/components/Mention/MentionsSelect.vue"],"sourcesContent":["<template>\n <div ref=\"mentionSelect\" :class=\"`${prefix}-select-wrap`\">\n <u-input v-model=\"search\" clearable>\n <template #suffix>\n <u-icon :size=\"14\">\n <ULineSearch />\n </u-icon>\n </template>\n </u-input>\n <div :class=\"`${prefix}-select-content`\">\n <u-scrollbar max-height=\"200px\">\n <div v-for=\"(item, index) in filterOptions\" :key=\"index\">\n <div :class=\"`${prefix}-item`\" @click=\"handleClick(item, index)\">\n <div :class=\"`${prefix}-text`\">\n <slot :data=\"item\" name=\"label\">\n <span>{{ item?.label }}</span>\n </slot>\n </div>\n </div>\n </div>\n </u-scrollbar>\n </div>\n
|
|
1
|
+
{"version":3,"file":"MentionsSelect.mjs","sources":["../../../../src/components/Mention/MentionsSelect.vue"],"sourcesContent":["<template>\n <div ref=\"mentionSelect\" :class=\"`${prefix}-select-wrap`\">\n <u-input v-model=\"search\" clearable>\n <template #suffix>\n <u-icon :size=\"14\">\n <ULineSearch />\n </u-icon>\n </template>\n </u-input>\n <div :class=\"`${prefix}-select-content`\">\n <u-scrollbar max-height=\"200px\">\n <div v-for=\"(item, index) in filterOptions\" :key=\"index\">\n <div :class=\"`${prefix}-item`\" @click=\"handleClick(item, index)\">\n <div :class=\"`${prefix}-text`\">\n <slot :data=\"item\" name=\"label\">\n <span>{{ item?.label }}</span>\n </slot>\n </div>\n </div>\n </div>\n </u-scrollbar>\n </div>\n <div v-if=\"showNoData\" class=\"no-more-wrap\">{{ emptyTip }}</div>\n </div>\n</template>\n\n<script setup>\nimport { shallowRef, inject, computed, nextTick, ref } from 'vue';\nimport { isEmpty } from 'lodash-es';\nimport { MentionsContextKey } from './mentionsTypes';\nimport { setupClickOutside } from './utils';\n\nconst props = defineProps({\n emptyTip: {\n type: String,\n default: ''\n },\n options: {\n type: Array,\n default: () => []\n },\n prefix: {\n type: String,\n default: ''\n }\n});\n\nconst emits = defineEmits(['close']);\nconst { setActiveIndex, selectOption } = inject(MentionsContextKey, {\n activeIndex: shallowRef()\n});\n\nconst showNoData = computed(() => {\n return isEmpty(props.options);\n});\nconst search = ref('');\nconst mentionSelect = ref(null);\n\nconst filterOptions = computed(() => {\n return props.options.filter((item) => {\n return item.label.includes(search.value);\n });\n});\nsetupClickOutside(mentionSelect, () => {\n emits('close');\n});\nconst handleClick = (item, index) => {\n if (setActiveIndex) {\n setActiveIndex(index);\n }\n\n nextTick(() => {\n if (selectOption) {\n selectOption(item);\n }\n });\n};\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,UAAM,QAAQ;AAed,UAAM,QAAQ;AACd,UAAM,EAAE,gBAAgB,iBAAiB,OAAO,oBAAoB;AAAA,MAClE,aAAa;AAAW,KACzB;AAED,UAAM,aAAa,SAAS,MAAM;AAChC,aAAO,QAAQ,MAAM,OAAO;AAAA,KAC7B;AACD,UAAM,SAAS,IAAI,EAAE;AACrB,UAAM,gBAAgB,IAAI,IAAI;AAE9B,UAAM,gBAAgB,SAAS,MAAM;AACnC,aAAO,MAAM,QAAQ,OAAO,CAAC,SAAS;AACpC,eAAO,KAAK,MAAM,SAAS,OAAO,KAAK;AAAA,OACxC;AAAA,KACF;AACD,sBAAkB,eAAe,MAAM;AACrC,YAAM,OAAO;AAAA,KACd;AACD,UAAM,cAAc,CAAC,MAAM,UAAU;AACnC,UAAI,gBAAgB;AAClB,uBAAe,KAAK;AAAA;AAGtB,eAAS,MAAM;AACb,YAAI,cAAc;AAChB,uBAAa,IAAI;AAAA;AACnB,OACD;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -103,6 +103,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
103
103
|
visible: _ctx.visible,
|
|
104
104
|
placement: _ctx.placement,
|
|
105
105
|
trigger: [_ctx.trigger],
|
|
106
|
+
"mouse-enter-delay": _ctx.showDelay / 1e3,
|
|
106
107
|
"transition-name": "zoom-big-fast",
|
|
107
108
|
offset: _ctx.offset,
|
|
108
109
|
"destroy-popup-on-hide": _ctx.destroyOnHide,
|
|
@@ -144,7 +145,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
144
145
|
renderSlot(_ctx.$slots, "default")
|
|
145
146
|
]),
|
|
146
147
|
_: 3
|
|
147
|
-
}, 8, ["class", "style", "prefix-cls", "popup-class", "popup-style", "visible", "placement", "trigger", "offset", "destroy-popup-on-hide", "onPopupVisibleChange"]));
|
|
148
|
+
}, 8, ["class", "style", "prefix-cls", "popup-class", "popup-style", "visible", "placement", "trigger", "mouse-enter-delay", "offset", "destroy-popup-on-hide", "onPopupVisibleChange"]));
|
|
148
149
|
}
|
|
149
150
|
var Popover = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "D:\\uxd\\uxd-ui\\src\\components\\Popover\\Popover.vue"]]);
|
|
150
151
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.mjs","sources":["../../../../src/components/Popover/Popover.vue"],"sourcesContent":["<template>\n <template v-if=\"disabled\">\n <slot />\n </template>\n <template v-else>\n <Popup\n ref=\"popupRef\"\n :class=\"$attrs.class\"\n :style=\"$attrs.style\"\n :prefix-cls=\"prefixCls\"\n :popup-class=\"dropdownClass\"\n :popup-style=\"popupStyle\"\n :visible=\"visible\"\n :placement=\"placement\"\n :trigger=\"[trigger]\"\n transition-name=\"zoom-big-fast\"\n :offset=\"offset\"\n :destroy-popup-on-hide=\"destroyOnHide\"\n @popup-visible-change=\"onVisibleChange\"\n >\n <slot />\n <template #popup>\n <div v-if=\"showArrow\" :class=\"`${prefixCls}-arrow`\" :style=\"arrowStyle\" />\n <div v-if=\"type === 'popover'\" ref=\"innerRef\" :class=\"`${prefixCls}-inner`\" role=\"popover\">\n <div v-if=\"showTitle\" :class=\"`${prefixCls}-inner-title`\">\n <slot name=\"title\">\n {{ title }}\n </slot>\n </div>\n <div\n :class=\"{\n [`${prefixCls}-inner-content`]: true,\n [`${dropdownClass}-content`]: dropdownClass\n }\"\n >\n <slot name=\"content\">\n {{ content }}\n </slot>\n </div>\n </div>\n <slot v-else name=\"popConfirm\" />\n </template>\n </Popup>\n </template>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, computed, ref, inject } from 'vue';\nimport type { CSSProperties } from 'vue';\nimport Popup from '@uxd-ui/components/Popup';\nimport useGlobalConfig from '../base/hooks/useGlobalConfig';\nimport { popoverProps, popoverEmits } from './Popover.type';\nimport { findDOMNode } from '../../utils';\n\nexport default defineComponent({\n name: 'UPopover',\n components: {\n Popup\n },\n props: popoverProps,\n emits: popoverEmits,\n setup(props, { slots, emit }) {\n const { prefixCls } = useGlobalConfig('popover');\n const popupRef = ref(null);\n const innerRef = ref(null);\n const popConfirmInnerRef = inject('PopConfirmInnerRef', ref(null));\n
|
|
1
|
+
{"version":3,"file":"Popover.mjs","sources":["../../../../src/components/Popover/Popover.vue"],"sourcesContent":["<template>\n <template v-if=\"disabled\">\n <slot />\n </template>\n <template v-else>\n <Popup\n ref=\"popupRef\"\n :class=\"$attrs.class\"\n :style=\"$attrs.style\"\n :prefix-cls=\"prefixCls\"\n :popup-class=\"dropdownClass\"\n :popup-style=\"popupStyle\"\n :visible=\"visible\"\n :placement=\"placement\"\n :trigger=\"[trigger]\"\n :mouse-enter-delay=\"showDelay / 1000\"\n transition-name=\"zoom-big-fast\"\n :offset=\"offset\"\n :destroy-popup-on-hide=\"destroyOnHide\"\n @popup-visible-change=\"onVisibleChange\"\n >\n <slot />\n <template #popup>\n <div v-if=\"showArrow\" :class=\"`${prefixCls}-arrow`\" :style=\"arrowStyle\" />\n <div v-if=\"type === 'popover'\" ref=\"innerRef\" :class=\"`${prefixCls}-inner`\" role=\"popover\">\n <div v-if=\"showTitle\" :class=\"`${prefixCls}-inner-title`\">\n <slot name=\"title\">\n {{ title }}\n </slot>\n </div>\n <div\n :class=\"{\n [`${prefixCls}-inner-content`]: true,\n [`${dropdownClass}-content`]: dropdownClass\n }\"\n >\n <slot name=\"content\">\n {{ content }}\n </slot>\n </div>\n </div>\n <slot v-else name=\"popConfirm\" />\n </template>\n </Popup>\n </template>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, computed, ref, inject } from 'vue';\nimport type { CSSProperties } from 'vue';\nimport Popup from '@uxd-ui/components/Popup';\nimport useGlobalConfig from '../base/hooks/useGlobalConfig';\nimport { popoverProps, popoverEmits } from './Popover.type';\nimport { findDOMNode } from '../../utils';\n\nexport default defineComponent({\n name: 'UPopover',\n components: {\n Popup\n },\n props: popoverProps,\n emits: popoverEmits,\n setup(props, { slots, emit }) {\n const { prefixCls } = useGlobalConfig('popover');\n const popupRef = ref(null);\n const innerRef = ref(null);\n const popConfirmInnerRef = inject('PopConfirmInnerRef', ref(null));\n const onVisibleChange = (val: boolean) => {\n emit('update:visible', val);\n emit('visible-change', val);\n };\n const showTitle = computed(() => {\n return props.title || slots.title !== undefined;\n });\n const popupStyle = computed(() => {\n const width = typeof props.width === 'number' ? `${props.width}px` : props.width;\n return props.type === 'popover' ? ({ ...props.dropdownStyle } as CSSProperties) : ({ ...{ width }, ...props.dropdownStyle } as CSSProperties);\n });\n\n const arrowStyle = computed(() => {\n if (popupRef.value?.reference && (innerRef.value || popConfirmInnerRef.value)) {\n const { width, height } = findDOMNode(popupRef.value.reference).getBoundingClientRect();\n const inner = innerRef.value || popConfirmInnerRef.value;\n const { width: contentWidth, height: contentHeight } = inner.getBoundingClientRect();\n if (props.placement === 'left-start' || props.placement === 'right-start') {\n let top = height / 2;\n if (top > contentHeight) {\n top = 8;\n }\n return {\n top: `${top}px`,\n transform: 'translateY(-50%)'\n };\n }\n if (props.placement === 'left-end' || props.placement === 'right-end') {\n let bottom = height / 2;\n if (bottom > contentHeight) {\n bottom = 8;\n }\n return {\n bottom: `${bottom}px`,\n transform: 'translateY(50%)'\n };\n }\n if (props.placement === 'top-start' || props.placement === 'bottom-start') {\n let left = width / 2;\n if (left > contentWidth) {\n left = 16;\n }\n return {\n left: `${left}px`,\n transform: 'translateX(-50%)'\n };\n }\n if (props.placement === 'top-end' || props.placement === 'bottom-end') {\n let right = width / 2;\n if (right > contentWidth) {\n right = 16;\n }\n return {\n right: `${right}px`,\n transform: 'translateX(50%)'\n };\n }\n }\n return {};\n });\n\n return {\n popupRef,\n innerRef,\n prefixCls,\n showTitle,\n popupStyle,\n arrowStyle,\n onVisibleChange\n };\n }\n});\n</script>\n"],"names":["_renderSlot","_createBlock","_normalizeClass","_normalizeStyle","_withCtx","_createElementBlock","_createElementVNode"],"mappings":";;;;;;;;;AAuDA,MAAK,YAAa,gBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA;AACF,EACA,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM,OAAO,EAAE,OAAO,QAAQ;UACtB,EAAE,cAAc,gBAAgB,SAAS;UACzC,WAAW,IAAI,IAAI;UACnB,WAAW,IAAI,IAAI;UACnB,qBAAqB,OAAO,sBAAsB,IAAI,IAAI,CAAC;UAC3D,kBAAkB,CAAC,QAAiB;WACnC,kBAAkB,GAAG;WACrB,kBAAkB,GAAG;AAAA;UAEtB,YAAY,SAAS,MAAM;aACxB,MAAM,SAAS,MAAM,UAAU;AAAA,KACvC;UACK,aAAa,SAAS,MAAM;YAC1B,QAAQ,OAAO,MAAM,UAAU,WAAW,GAAG,MAAM,YAAY,MAAM;aACpE,MAAM,SAAS,YAAa,EAAE,GAAG,MAAM,kBAAqC,EAAE,GAAG,EAAE,SAAS,GAAG,MAAM;AAAc,KAC3H;UAEK,aAAa,SAAS,MAAM;AA/BtC;YAgCU,cAAS,UAAT,mBAAgB,eAAc,SAAS,SAAS,mBAAmB,QAAQ;cACvE,EAAE,OAAO,WAAW,YAAY,SAAS,MAAM,SAAS,EAAE;cAC1D,QAAQ,SAAS,SAAS,mBAAmB;cAC7C,EAAE,OAAO,cAAc,QAAQ,kBAAkB,MAAM;YAC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AK,sBAAS;AAAA,QAAU,MAAK;AAAA;QACpE,+BAAXG,mBAIM;;UAJiB,OAAKH,kBAAK,4BAAS;AAAA;UACxCF,WAEO,0BAFP,MAEO;AAAA,4CADF,UAAK;;;QAGZM,mBASM;UARH,OAAKJ;gBAAsB,iCAAS;AAAA,gBAA2C,+BAA0B;;;UAK1GF,WAEO,4BAFP,MAEO;AAAA,4CADF,YAAO;;;eAIhBA,WAAiC;;qBApBnC,MAAQ;AAAA,MAARA,WAAQ;;;;;;;;;"}
|
|
@@ -58,6 +58,10 @@ export declare const popoverProps: {
|
|
|
58
58
|
type: BooleanConstructor;
|
|
59
59
|
default: boolean;
|
|
60
60
|
};
|
|
61
|
+
showDelay: {
|
|
62
|
+
type: NumberConstructor;
|
|
63
|
+
default: number;
|
|
64
|
+
};
|
|
61
65
|
};
|
|
62
66
|
export declare type PopoverProps = ExtractPropTypes<typeof popoverProps>;
|
|
63
67
|
export declare const popoverEmits: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.type.mjs","sources":["../../../../src/components/Popover/Popover.type.ts"],"sourcesContent":["import type { CSSProperties, ExtractPropTypes, PropType } from 'vue';\nimport type { Placements } from '../../utils/placements';\nimport placements from '../../utils/placements';\nimport { isArrayOf, oneOf } from '../../utils/propsValidators';\nimport type Popover from './Popover.vue';\n\nexport const popoverTrigger = ['hover', 'focus', 'click', 'contextmenu'] as const;\nexport type PopoverTrigger = (typeof popoverTrigger)[number];\n\nexport const popoverType = ['popover', 'popConfirm'] as const;\nexport type PopoverType = (typeof popoverType)[number];\n\nexport const popoverProps = {\n placement: {\n type: String as PropType<Placements>,\n default: 'top',\n validator: oneOf(placements)\n },\n visible: {\n type: Boolean,\n default: undefined as undefined\n },\n disabled: {\n type: Boolean,\n default: false\n },\n title: {\n type: String\n },\n content: {\n type: String\n },\n dropdownClass: {\n type: String,\n default: ''\n },\n dropdownStyle: {\n type: Object as PropType<CSSProperties>,\n default: () => ({})\n },\n trigger: {\n type: String as PropType<PopoverTrigger>,\n default: 'hover',\n validator: oneOf(popoverTrigger)\n },\n offset: {\n type: Array as PropType<number[]>,\n validator: isArrayOf(Number)\n },\n type: {\n type: String as PropType<PopoverType>,\n default: 'popover',\n validator: oneOf(popoverType)\n },\n destroyOnHide: {\n type: Boolean,\n default: true\n },\n width: {\n type: [Number, String],\n default: 300\n },\n showArrow: {\n type: Boolean,\n default: true\n }\n};\n\nexport type PopoverProps = ExtractPropTypes<typeof popoverProps>;\n\nexport const popoverEmits = {\n 'visible-change': (v: boolean) => typeof v === 'boolean',\n 'update:visible': (v: boolean) => typeof v === 'boolean'\n};\n\nexport type PopoverEmits = typeof popoverEmits;\n\nexport type PopoverInstanceType = InstanceType<typeof Popover>;\n"],"names":[],"mappings":";;;MAMa,iBAAiB,CAAC,SAAS,SAAS,SAAS,aAAa;MAG1D,cAAc,CAAC,WAAW,YAAY;MAGtC,eAAe;AAAA,EAC1B,WAAW;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW,MAAM,UAAU;AAAA;AAC7B,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,OAAO;AAAA,IACL,MAAM;AAAA;AACR,EACA,SAAS;AAAA,IACP,MAAM;AAAA;AACR,EACA,eAAe;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,eAAe;AAAA,IACb,MAAM;AAAA,IACN,SAAS,OAAO;AAAC;AACnB,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW,MAAM,cAAc;AAAA;AACjC,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,WAAW,UAAU,MAAM;AAAA;AAC7B,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW,MAAM,WAAW;AAAA;AAC9B,EACA,eAAe;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,OAAO;AAAA,IACL,MAAM,CAAC,QAAQ,MAAM;AAAA,IACrB,SAAS;AAAA;AACX,EACA,WAAW;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA;AAEb;MAIa,eAAe;AAAA,EAC1B,kBAAkB,CAAC,MAAe,OAAO,MAAM;AAAA,EAC/C,kBAAkB,CAAC,MAAe,OAAO,MAAM;AACjD;;;;"}
|
|
1
|
+
{"version":3,"file":"Popover.type.mjs","sources":["../../../../src/components/Popover/Popover.type.ts"],"sourcesContent":["import type { CSSProperties, ExtractPropTypes, PropType } from 'vue';\nimport type { Placements } from '../../utils/placements';\nimport placements from '../../utils/placements';\nimport { isArrayOf, oneOf } from '../../utils/propsValidators';\nimport type Popover from './Popover.vue';\n\nexport const popoverTrigger = ['hover', 'focus', 'click', 'contextmenu'] as const;\nexport type PopoverTrigger = (typeof popoverTrigger)[number];\n\nexport const popoverType = ['popover', 'popConfirm'] as const;\nexport type PopoverType = (typeof popoverType)[number];\n\nexport const popoverProps = {\n placement: {\n type: String as PropType<Placements>,\n default: 'top',\n validator: oneOf(placements)\n },\n visible: {\n type: Boolean,\n default: undefined as undefined\n },\n disabled: {\n type: Boolean,\n default: false\n },\n title: {\n type: String\n },\n content: {\n type: String\n },\n dropdownClass: {\n type: String,\n default: ''\n },\n dropdownStyle: {\n type: Object as PropType<CSSProperties>,\n default: () => ({})\n },\n trigger: {\n type: String as PropType<PopoverTrigger>,\n default: 'hover',\n validator: oneOf(popoverTrigger)\n },\n offset: {\n type: Array as PropType<number[]>,\n validator: isArrayOf(Number)\n },\n type: {\n type: String as PropType<PopoverType>,\n default: 'popover',\n validator: oneOf(popoverType)\n },\n destroyOnHide: {\n type: Boolean,\n default: true\n },\n width: {\n type: [Number, String],\n default: 300\n },\n showArrow: {\n type: Boolean,\n default: true\n },\n showDelay: {\n type: Number,\n default: 0\n }\n};\n\nexport type PopoverProps = ExtractPropTypes<typeof popoverProps>;\n\nexport const popoverEmits = {\n 'visible-change': (v: boolean) => typeof v === 'boolean',\n 'update:visible': (v: boolean) => typeof v === 'boolean'\n};\n\nexport type PopoverEmits = typeof popoverEmits;\n\nexport type PopoverInstanceType = InstanceType<typeof Popover>;\n"],"names":[],"mappings":";;;MAMa,iBAAiB,CAAC,SAAS,SAAS,SAAS,aAAa;MAG1D,cAAc,CAAC,WAAW,YAAY;MAGtC,eAAe;AAAA,EAC1B,WAAW;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW,MAAM,UAAU;AAAA;AAC7B,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,OAAO;AAAA,IACL,MAAM;AAAA;AACR,EACA,SAAS;AAAA,IACP,MAAM;AAAA;AACR,EACA,eAAe;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,eAAe;AAAA,IACb,MAAM;AAAA,IACN,SAAS,OAAO;AAAC;AACnB,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW,MAAM,cAAc;AAAA;AACjC,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,WAAW,UAAU,MAAM;AAAA;AAC7B,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW,MAAM,WAAW;AAAA;AAC9B,EACA,eAAe;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,OAAO;AAAA,IACL,MAAM,CAAC,QAAQ,MAAM;AAAA,IACrB,SAAS;AAAA;AACX,EACA,WAAW;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,WAAW;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA;AAEb;MAIa,eAAe;AAAA,EAC1B,kBAAkB,CAAC,MAAe,OAAO,MAAM;AAAA,EAC/C,kBAAkB,CAAC,MAAe,OAAO,MAAM;AACjD;;;;"}
|
|
@@ -53,6 +53,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
53
53
|
type: BooleanConstructor;
|
|
54
54
|
default: boolean;
|
|
55
55
|
};
|
|
56
|
+
showDelay: {
|
|
57
|
+
type: NumberConstructor;
|
|
58
|
+
default: number;
|
|
59
|
+
};
|
|
56
60
|
}, {
|
|
57
61
|
popupRef: import("vue").Ref<any, any>;
|
|
58
62
|
innerRef: import("vue").Ref<any, any>;
|
|
@@ -148,6 +152,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
148
152
|
type: BooleanConstructor;
|
|
149
153
|
default: boolean;
|
|
150
154
|
};
|
|
155
|
+
showDelay: {
|
|
156
|
+
type: NumberConstructor;
|
|
157
|
+
default: number;
|
|
158
|
+
};
|
|
151
159
|
}>> & {
|
|
152
160
|
"onUpdate:visible"?: (v: boolean) => any;
|
|
153
161
|
"onVisible-change"?: (v: boolean) => any;
|
|
@@ -162,5 +170,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
162
170
|
dropdownStyle: CSSProperties;
|
|
163
171
|
destroyOnHide: boolean;
|
|
164
172
|
showArrow: boolean;
|
|
173
|
+
showDelay: number;
|
|
165
174
|
}, {}>;
|
|
166
175
|
export default _default;
|
|
@@ -53,6 +53,10 @@ export declare const UPopover: {
|
|
|
53
53
|
type: BooleanConstructor;
|
|
54
54
|
default: boolean;
|
|
55
55
|
};
|
|
56
|
+
showDelay: {
|
|
57
|
+
type: NumberConstructor;
|
|
58
|
+
default: number;
|
|
59
|
+
};
|
|
56
60
|
}>> & {
|
|
57
61
|
"onUpdate:visible"?: (v: boolean) => any;
|
|
58
62
|
"onVisible-change"?: (v: boolean) => any;
|
|
@@ -151,6 +155,10 @@ export declare const UPopover: {
|
|
|
151
155
|
type: BooleanConstructor;
|
|
152
156
|
default: boolean;
|
|
153
157
|
};
|
|
158
|
+
showDelay: {
|
|
159
|
+
type: NumberConstructor;
|
|
160
|
+
default: number;
|
|
161
|
+
};
|
|
154
162
|
}>> & {
|
|
155
163
|
"onUpdate:visible"?: (v: boolean) => any;
|
|
156
164
|
"onVisible-change"?: (v: boolean) => any;
|
|
@@ -165,6 +173,7 @@ export declare const UPopover: {
|
|
|
165
173
|
dropdownStyle: import("vue").CSSProperties;
|
|
166
174
|
destroyOnHide: boolean;
|
|
167
175
|
showArrow: boolean;
|
|
176
|
+
showDelay: number;
|
|
168
177
|
}, true, {}, {}, {
|
|
169
178
|
P: {};
|
|
170
179
|
B: {};
|
|
@@ -226,6 +235,10 @@ export declare const UPopover: {
|
|
|
226
235
|
type: BooleanConstructor;
|
|
227
236
|
default: boolean;
|
|
228
237
|
};
|
|
238
|
+
showDelay: {
|
|
239
|
+
type: NumberConstructor;
|
|
240
|
+
default: number;
|
|
241
|
+
};
|
|
229
242
|
}>> & {
|
|
230
243
|
"onUpdate:visible"?: (v: boolean) => any;
|
|
231
244
|
"onVisible-change"?: (v: boolean) => any;
|
|
@@ -278,6 +291,7 @@ export declare const UPopover: {
|
|
|
278
291
|
dropdownStyle: import("vue").CSSProperties;
|
|
279
292
|
destroyOnHide: boolean;
|
|
280
293
|
showArrow: boolean;
|
|
294
|
+
showDelay: number;
|
|
281
295
|
}>;
|
|
282
296
|
__isFragment?: never;
|
|
283
297
|
__isTeleport?: never;
|
|
@@ -336,6 +350,10 @@ export declare const UPopover: {
|
|
|
336
350
|
type: BooleanConstructor;
|
|
337
351
|
default: boolean;
|
|
338
352
|
};
|
|
353
|
+
showDelay: {
|
|
354
|
+
type: NumberConstructor;
|
|
355
|
+
default: number;
|
|
356
|
+
};
|
|
339
357
|
}>> & {
|
|
340
358
|
"onUpdate:visible"?: (v: boolean) => any;
|
|
341
359
|
"onVisible-change"?: (v: boolean) => any;
|
|
@@ -391,6 +409,7 @@ export declare const UPopover: {
|
|
|
391
409
|
dropdownStyle: import("vue").CSSProperties;
|
|
392
410
|
destroyOnHide: boolean;
|
|
393
411
|
showArrow: boolean;
|
|
412
|
+
showDelay: number;
|
|
394
413
|
}, {}, string, {}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & import("vue").Plugin<any[]> & Record<string, any>;
|
|
395
414
|
export default UPopover;
|
|
396
415
|
export * from './Popover.type';
|
|
@@ -204,6 +204,21 @@ const _sfc_main = defineComponent({
|
|
|
204
204
|
emit("update:expandedKeys", expandedKeys.value);
|
|
205
205
|
emit("expand", expandedKeys.value, e);
|
|
206
206
|
};
|
|
207
|
+
const getParentDisabled = (key) => {
|
|
208
|
+
const node = treeDataMap.value.get(key);
|
|
209
|
+
if (node == null ? void 0 : node.disabled)
|
|
210
|
+
return true;
|
|
211
|
+
if (node == null ? void 0 : node.parent) {
|
|
212
|
+
return getParentDisabled(node.parent.key);
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
};
|
|
216
|
+
const isDisabledNode = (key) => {
|
|
217
|
+
const node = treeDataMap.value.get(key);
|
|
218
|
+
if (node == null ? void 0 : node.disabled)
|
|
219
|
+
return true;
|
|
220
|
+
return getParentDisabled(key);
|
|
221
|
+
};
|
|
207
222
|
provide(
|
|
208
223
|
TREE_CONTEXT_INJECTION_KEY,
|
|
209
224
|
reactive({
|
|
@@ -224,7 +239,8 @@ const _sfc_main = defineComponent({
|
|
|
224
239
|
fireTreeSelect,
|
|
225
240
|
fireTreeCheck,
|
|
226
241
|
fireTreeExpand,
|
|
227
|
-
getDataKey
|
|
242
|
+
getDataKey,
|
|
243
|
+
isDisabledNode
|
|
228
244
|
})
|
|
229
245
|
);
|
|
230
246
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.mjs","sources":["../../../../src/components/Tree/Tree.vue"],"sourcesContent":["<template>\n <ul\n :class=\"[\n prefixCls,\n {\n [`${prefixCls}-show-line`]: showLine\n }\n ]\"\n >\n <SubTree :data=\"localTreeData\" />\n </ul>\n</template>\n\n<script lang=\"ts\">\nimport { provide, ref, watch, defineComponent, reactive } from 'vue';\nimport { treeMap } from '../../utils/tools';\nimport useGlobalConfig from '../base/hooks/useGlobalConfig';\nimport useTransfer from './hooks/useTransfer';\nimport { findNodeByLoop, getDragNode } from './utils/tools';\nimport { generateCheck } from './utils/generateCheck';\nimport SubTree from './SubTree.vue';\nimport { type TreeItem, treeProps, treeEmits, TREE_CONTEXT_INJECTION_KEY, type InnerTreeItem } from './Tree.type';\n\nexport default defineComponent({\n name: 'UTree',\n components: {\n SubTree\n },\n props: treeProps,\n emits: treeEmits,\n setup(props, { emit, slots }) {\n const { prefixCls } = useGlobalConfig('tree');\n const selectedKeys = ref<(string | number)[]>([]);\n const checkedKeys = ref<(string | number)[]>([]);\n const halfCheckedKeys = ref<(string | number)[]>([]);\n const loadingKeys = ref<(string | number)[]>([]);\n const dragKey = ref<string | number>('');\n\n const getDataKey = (data: InnerTreeItem): string | number => {\n if (typeof props.dataKey === 'function') {\n return props.dataKey(data);\n }\n return data[props.dataKey];\n };\n\n const { expandedKeys, localTreeData, treeDataMap, initData } = useTransfer(props, slots, getDataKey);\n\n const computedChecked = (keys: (string | number)[], checked: boolean) => {\n const checkedParams = {\n oriCheckedKeys: checkedKeys.value,\n oriHalfCheckedKeys: halfCheckedKeys.value\n };\n const checkResult = generateCheck(keys, checked, treeDataMap.value, checkedParams, getDataKey);\n return checkResult;\n };\n\n // #region init halfCheckedKeys _checkedKeys\n const initChecked = () => {\n if (props.checkStrictly) return;\n const checkResult = computedChecked(checkedKeys.value, true);\n checkedKeys.value = checkResult.checkedKeys;\n halfCheckedKeys.value = checkResult.halfCheckedKeys;\n // emit('update:checkedKeys', checkResult.checkedKeys);\n emit('check', checkResult.checkedKeys, checkResult.halfCheckedKeys);\n };\n // #endregion\n\n // #region watch\n watch(\n () => props.treeData,\n (nv) => {\n initData(nv);\n },\n { immediate: true }\n );\n watch(\n () => props.selectedKeys,\n (nv) => {\n selectedKeys.value = [...nv];\n },\n { immediate: true }\n );\n watch(\n () => props.checkedKeys,\n (nv) => {\n if (checkedKeys.value !== nv && checkedKeys.value.length !== nv.length && props.checkable) {\n checkedKeys.value = [...nv];\n initChecked();\n }\n },\n { immediate: true }\n );\n // #endregion\n\n // methods\n const updateDragKeys = (key: string | number) => {\n dragKey.value = key;\n };\n\n const updateOriginData = (data: TreeItem[]) => {\n if (props.treeSelect) {\n emit('update-data', data);\n }\n emit('update:treeData', data);\n };\n // #region fireTreeDrop\n const fireTreeDrop = (dropEvent: { dragKey: string | number; dropKey: string | number; dropPosition: number; dropToGap: boolean }) => {\n // const dropPos = dropKey.split('-');\n const dropNode = treeDataMap.value.get(dropEvent.dropKey);\n // const _dropPosition = dropPosition - Number(dropPos[dropPos.length - 1]);\n const data = treeMap<TreeItem, TreeItem>(props.treeData, (x) => ({\n ...x\n }));\n const dragNode = getDragNode(data, dropEvent.dragKey, getDataKey);\n if (!dropEvent.dropToGap) {\n // Drop on the content\n findNodeByLoop(\n data,\n dropEvent.dropKey,\n (item: TreeItem) => {\n item.children = item.children || [];\n\n item.children.push(dragNode);\n },\n getDataKey\n );\n } else if ((dropNode?.children || []).length > 0 && dropEvent.dropPosition === 1) {\n findNodeByLoop(\n data,\n dropEvent.dropKey,\n (item) => {\n item.children = item.children || [];\n\n item.children.unshift(dragNode);\n },\n getDataKey\n );\n } else {\n let tempArr: TreeItem[] = [];\n let tempIndex = 0;\n findNodeByLoop(\n data,\n dropEvent.dropKey,\n (item, index, arr) => {\n tempArr = arr;\n tempIndex = index;\n },\n getDataKey\n );\n if (dropEvent.dropPosition === -1) {\n tempArr.splice(tempIndex, 0, dragNode);\n } else {\n tempArr.splice(tempIndex + 1, 0, dragNode);\n }\n }\n updateOriginData(data);\n };\n // #endregion\n\n // #region treeSelect\n\n const fireTreeSelect = (e: Event) => {\n const selectItems = [] as TreeItem[];\n selectedKeys.value.forEach((key) => {\n if (treeDataMap.value.get(key)) {\n selectItems.push(treeDataMap.value.get(key)!.dataRef);\n }\n });\n emit('update:selectedKeys', selectedKeys.value);\n emit('select', selectItems, e);\n };\n\n // #endregion\n\n // #region treeCheck\n\n const fireTreeCheck = (e: Event, key: string | number) => {\n if (props.disabled) return;\n const keyIndex = checkedKeys.value.indexOf(key);\n if (props.checkStrictly) {\n if (keyIndex === -1) {\n checkedKeys.value.push(key);\n } else {\n checkedKeys.value.splice(keyIndex, 1);\n }\n } else {\n const checked = !(keyIndex >= 0);\n const checkResult = computedChecked([key], checked);\n checkedKeys.value = checkResult.checkedKeys;\n halfCheckedKeys.value = checkResult.halfCheckedKeys;\n // emit('check', checkResult.checkedKeys, checkResult.halfCheckedKeys, e);\n }\n emit('update:checkedKeys', checkedKeys.value);\n emit('check', checkedKeys.value, props.checkStrictly ? [] : halfCheckedKeys.value, e);\n };\n\n // #endregion\n\n // #region tree Data operate\n const treeNodeOperate = (type: 'add' | 'delete', key: string | number, children?: TreeItem[]) => {\n const data = treeMap(props.treeData, (x) => ({ ...x }));\n if (type === 'add') {\n findNodeByLoop(\n data,\n key,\n (item) => {\n item.children = [...(item.children || []), ...(children || [])];\n },\n getDataKey\n );\n } else {\n const currentNode = treeDataMap.value.get(key)!;\n\n if (currentNode.parent === null) {\n const index = data.findIndex((x) => getDataKey(x as InnerTreeItem) === key);\n data.splice(index, 1);\n } else {\n findNodeByLoop(\n data,\n getDataKey(currentNode.parent),\n (item) => {\n const index = item.children!.findIndex((x) => getDataKey(x as InnerTreeItem) === key);\n item.children!.splice(index, 1);\n },\n getDataKey\n );\n }\n }\n\n updateOriginData(data);\n };\n\n // #endregion\n\n // #region async load data\n\n const asyncLoadData = (node: InnerTreeItem) => {\n const nodeKey = getDataKey(node);\n loadingKeys.value.push(nodeKey);\n return new Promise<void>((resolve) => {\n if (props.loadData) {\n const promise = props.loadData(node);\n promise.then((children?: TreeItem[]) => {\n if (children && Array.isArray(children)) {\n treeNodeOperate('add', nodeKey, children);\n }\n loadingKeys.value = loadingKeys.value.filter((x) => x !== nodeKey);\n resolve();\n });\n }\n resolve();\n });\n };\n\n // #endregion\n\n const fireTreeExpand = (e: Event) => {\n emit('update:expandedKeys', expandedKeys.value);\n emit('expand', expandedKeys.value, e);\n };\n\n // #region provide\n provide(\n TREE_CONTEXT_INJECTION_KEY,\n reactive({\n props,\n emit,\n prefixCls,\n treeDataMap,\n selectedKeys,\n expandedKeys,\n checkedKeys,\n halfCheckedKeys,\n dragKey,\n loadingKeys,\n asyncLoadData,\n treeNodeOperate,\n updateDragKeys,\n fireTreeDrop,\n fireTreeSelect,\n fireTreeCheck,\n fireTreeExpand,\n getDataKey\n })\n );\n // #endregion\n\n return {\n prefixCls,\n localTreeData,\n computedChecked // treeSelect use\n };\n }\n});\n</script>\n"],"names":["_createElementBlock","_normalizeClass","_createVNode"],"mappings":";;;;;;;;;;AAuBA,MAAK,YAAa,gBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA;AACF,EACA,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM,OAAO,EAAE,MAAM,SAAS;UACtB,EAAE,cAAc,gBAAgB,MAAM;UACtC,eAAe,IAAyB,EAAE;UAC1C,cAAc,IAAyB,EAAE;UACzC,kBAAkB,IAAyB,EAAE;UAC7C,cAAc,IAAyB,EAAE;UACzC,UAAU,IAAqB,EAAE;UAEjC,aAAa,CAAC,SAAyC;UACvD,OAAO,MAAM,YAAY,YAAY;eAChC,MAAM,QAAQ,IAAI;AAAA;aAEpB,KAAK,MAAM;AAAA;UAGd,EAAE,cAAc,eAAe,aAAa,aAAa,YAAY,OAAO,OAAO,UAAU;UAE7F,kBAAkB,CAAC,MAA2B,YAAqB;YACjE,gBAAgB;AAAA,QACpB,gBAAgB,YAAY;AAAA,QAC5B,oBAAoB,gBAAgB;AAAA;YAEhC,cAAc,cAAc,MAAM,SAAS,YAAY,OAAO,eAAe,UAAU;aACtF;AAAA;UAIH,cAAc,MAAM;UACpB,MAAM;;YACJ,cAAc,gBAAgB,YAAY,OAAO,IAAI;kBAC/C,QAAQ,YAAY;sBAChB,QAAQ,YAAY;WAE/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YAC7B,CAAC,SAAS;oBACF,QAAQ,KAAK,SAAU,UAAU,CAAC,MAAM,WAAW,CAAkB,MAAM,GAAG;mBAC/E,SAAU,OAAO,OAAO,CAAC;AAAA;AAChC,YACA;AAAA;AACF;AACF;uBAGe,IAAI;AAAA;UAOjB,gBAAgB,CAAC,SAAwB;YACvC,UAAU,WAAW,IAAI;kBACnB,MAAM,KAAK,OAAO;aACvB,IAAI,QAAc,CAAC,YAAY;YAChC,MAAM,UAAU;gBACZ,UAAU,MAAM,SAAS,IAAI;kBAC3B,KAAK,CAAC,aAA0B;gBAClC,YAAY,MAAM,QAAQ,QAAQ,GAAG;8BACvB,OAAO,SAAS,QAAQ;AAAA;wBAE9B,QAAQ,YAAY,MAAM,OAAO,CAAC,MAAM,MAAM,OAAO;;AACzD,WACT;AAAA;;AAEK,OACT;AAAA;UAKG,iBAAiB,CAAC,MAAa;WAC9B,uBAAuB,aAAa,KAAK;WACzC,UAAU,aAAa,OAAO,CAAC;AAAA;;MAKpC;AAAA,MACA,SAAS;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,OACD;AAAA;WAII;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA;AACF;AAEJ,CAAC;;;sBApSCA,mBASK;IARF,OAAKC;MAAU;;YAA+B,6BAAwB;;;;IAOvEC,YAAiC,sBAAvB,MAAM;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Tree.mjs","sources":["../../../../src/components/Tree/Tree.vue"],"sourcesContent":["<template>\n <ul\n :class=\"[\n prefixCls,\n {\n [`${prefixCls}-show-line`]: showLine\n }\n ]\"\n >\n <SubTree :data=\"localTreeData\" />\n </ul>\n</template>\n\n<script lang=\"ts\">\nimport { provide, ref, watch, defineComponent, reactive } from 'vue';\nimport { treeMap } from '../../utils/tools';\nimport useGlobalConfig from '../base/hooks/useGlobalConfig';\nimport useTransfer from './hooks/useTransfer';\nimport { findNodeByLoop, getDragNode } from './utils/tools';\nimport { generateCheck } from './utils/generateCheck';\nimport SubTree from './SubTree.vue';\nimport { type TreeItem, treeProps, treeEmits, TREE_CONTEXT_INJECTION_KEY, type InnerTreeItem } from './Tree.type';\n\nexport default defineComponent({\n name: 'UTree',\n components: {\n SubTree\n },\n props: treeProps,\n emits: treeEmits,\n setup(props, { emit, slots }) {\n const { prefixCls } = useGlobalConfig('tree');\n const selectedKeys = ref<(string | number)[]>([]);\n const checkedKeys = ref<(string | number)[]>([]);\n const halfCheckedKeys = ref<(string | number)[]>([]);\n const loadingKeys = ref<(string | number)[]>([]);\n const dragKey = ref<string | number>('');\n\n const getDataKey = (data: InnerTreeItem): string | number => {\n if (typeof props.dataKey === 'function') {\n return props.dataKey(data);\n }\n return data[props.dataKey];\n };\n\n const { expandedKeys, localTreeData, treeDataMap, initData } = useTransfer(props, slots, getDataKey);\n\n const computedChecked = (keys: (string | number)[], checked: boolean) => {\n const checkedParams = {\n oriCheckedKeys: checkedKeys.value,\n oriHalfCheckedKeys: halfCheckedKeys.value\n };\n const checkResult = generateCheck(keys, checked, treeDataMap.value, checkedParams, getDataKey);\n return checkResult;\n };\n\n // #region init halfCheckedKeys _checkedKeys\n const initChecked = () => {\n if (props.checkStrictly) return;\n const checkResult = computedChecked(checkedKeys.value, true);\n checkedKeys.value = checkResult.checkedKeys;\n halfCheckedKeys.value = checkResult.halfCheckedKeys;\n // emit('update:checkedKeys', checkResult.checkedKeys);\n emit('check', checkResult.checkedKeys, checkResult.halfCheckedKeys);\n };\n // #endregion\n\n // #region watch\n watch(\n () => props.treeData,\n (nv) => {\n initData(nv);\n },\n { immediate: true }\n );\n watch(\n () => props.selectedKeys,\n (nv) => {\n selectedKeys.value = [...nv];\n },\n { immediate: true }\n );\n watch(\n () => props.checkedKeys,\n (nv) => {\n if (checkedKeys.value !== nv && checkedKeys.value.length !== nv.length && props.checkable) {\n checkedKeys.value = [...nv];\n initChecked();\n }\n },\n { immediate: true }\n );\n // #endregion\n\n // methods\n const updateDragKeys = (key: string | number) => {\n dragKey.value = key;\n };\n\n const updateOriginData = (data: TreeItem[]) => {\n if (props.treeSelect) {\n emit('update-data', data);\n }\n emit('update:treeData', data);\n };\n // #region fireTreeDrop\n const fireTreeDrop = (dropEvent: { dragKey: string | number; dropKey: string | number; dropPosition: number; dropToGap: boolean }) => {\n // const dropPos = dropKey.split('-');\n const dropNode = treeDataMap.value.get(dropEvent.dropKey);\n // const _dropPosition = dropPosition - Number(dropPos[dropPos.length - 1]);\n const data = treeMap<TreeItem, TreeItem>(props.treeData, (x) => ({\n ...x\n }));\n const dragNode = getDragNode(data, dropEvent.dragKey, getDataKey);\n if (!dropEvent.dropToGap) {\n // Drop on the content\n findNodeByLoop(\n data,\n dropEvent.dropKey,\n (item: TreeItem) => {\n item.children = item.children || [];\n\n item.children.push(dragNode);\n },\n getDataKey\n );\n } else if ((dropNode?.children || []).length > 0 && dropEvent.dropPosition === 1) {\n findNodeByLoop(\n data,\n dropEvent.dropKey,\n (item) => {\n item.children = item.children || [];\n\n item.children.unshift(dragNode);\n },\n getDataKey\n );\n } else {\n let tempArr: TreeItem[] = [];\n let tempIndex = 0;\n findNodeByLoop(\n data,\n dropEvent.dropKey,\n (item, index, arr) => {\n tempArr = arr;\n tempIndex = index;\n },\n getDataKey\n );\n if (dropEvent.dropPosition === -1) {\n tempArr.splice(tempIndex, 0, dragNode);\n } else {\n tempArr.splice(tempIndex + 1, 0, dragNode);\n }\n }\n updateOriginData(data);\n };\n // #endregion\n\n // #region treeSelect\n\n const fireTreeSelect = (e: Event) => {\n const selectItems = [] as TreeItem[];\n selectedKeys.value.forEach((key) => {\n if (treeDataMap.value.get(key)) {\n selectItems.push(treeDataMap.value.get(key)!.dataRef);\n }\n });\n emit('update:selectedKeys', selectedKeys.value);\n emit('select', selectItems, e);\n };\n\n // #endregion\n\n // #region treeCheck\n\n const fireTreeCheck = (e: Event, key: string | number) => {\n if (props.disabled) return;\n const keyIndex = checkedKeys.value.indexOf(key);\n if (props.checkStrictly) {\n if (keyIndex === -1) {\n checkedKeys.value.push(key);\n } else {\n checkedKeys.value.splice(keyIndex, 1);\n }\n } else {\n const checked = !(keyIndex >= 0);\n const checkResult = computedChecked([key], checked);\n checkedKeys.value = checkResult.checkedKeys;\n halfCheckedKeys.value = checkResult.halfCheckedKeys;\n // emit('check', checkResult.checkedKeys, checkResult.halfCheckedKeys, e);\n }\n emit('update:checkedKeys', checkedKeys.value);\n emit('check', checkedKeys.value, props.checkStrictly ? [] : halfCheckedKeys.value, e);\n };\n\n // #endregion\n\n // #region tree Data operate\n const treeNodeOperate = (type: 'add' | 'delete', key: string | number, children?: TreeItem[]) => {\n const data = treeMap(props.treeData, (x) => ({ ...x }));\n if (type === 'add') {\n findNodeByLoop(\n data,\n key,\n (item) => {\n item.children = [...(item.children || []), ...(children || [])];\n },\n getDataKey\n );\n } else {\n const currentNode = treeDataMap.value.get(key)!;\n\n if (currentNode.parent === null) {\n const index = data.findIndex((x) => getDataKey(x as InnerTreeItem) === key);\n data.splice(index, 1);\n } else {\n findNodeByLoop(\n data,\n getDataKey(currentNode.parent),\n (item) => {\n const index = item.children!.findIndex((x) => getDataKey(x as InnerTreeItem) === key);\n item.children!.splice(index, 1);\n },\n getDataKey\n );\n }\n }\n\n updateOriginData(data);\n };\n\n // #endregion\n\n // #region async load data\n\n const asyncLoadData = (node: InnerTreeItem) => {\n const nodeKey = getDataKey(node);\n loadingKeys.value.push(nodeKey);\n return new Promise<void>((resolve) => {\n if (props.loadData) {\n const promise = props.loadData(node);\n promise.then((children?: TreeItem[]) => {\n if (children && Array.isArray(children)) {\n treeNodeOperate('add', nodeKey, children);\n }\n loadingKeys.value = loadingKeys.value.filter((x) => x !== nodeKey);\n resolve();\n });\n }\n resolve();\n });\n };\n\n // #endregion\n\n const fireTreeExpand = (e: Event) => {\n emit('update:expandedKeys', expandedKeys.value);\n emit('expand', expandedKeys.value, e);\n };\n\n const getParentDisabled = (key: string | number): boolean => {\n const node = treeDataMap.value.get(key);\n if (node?.disabled) return true;\n if (node?.parent) {\n return getParentDisabled(node.parent.key);\n }\n return false;\n };\n\n // 当前节点是否禁用,找到根节点\n const isDisabledNode = (key: string | number) => {\n const node = treeDataMap.value.get(key);\n if (node?.disabled) return true;\n return getParentDisabled(key);\n };\n\n // #region provide\n provide(\n TREE_CONTEXT_INJECTION_KEY,\n reactive({\n props,\n emit,\n prefixCls,\n treeDataMap,\n selectedKeys,\n expandedKeys,\n checkedKeys,\n halfCheckedKeys,\n dragKey,\n loadingKeys,\n asyncLoadData,\n treeNodeOperate,\n updateDragKeys,\n fireTreeDrop,\n fireTreeSelect,\n fireTreeCheck,\n fireTreeExpand,\n getDataKey,\n isDisabledNode\n })\n );\n // #endregion\n\n return {\n prefixCls,\n localTreeData,\n computedChecked // treeSelect use\n };\n }\n});\n</script>\n"],"names":["_createElementBlock","_normalizeClass","_createVNode"],"mappings":";;;;;;;;;;AAuBA,MAAK,YAAa,gBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA;AACF,EACA,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM,OAAO,EAAE,MAAM,SAAS;UACtB,EAAE,cAAc,gBAAgB,MAAM;UACtC,eAAe,IAAyB,EAAE;UAC1C,cAAc,IAAyB,EAAE;UACzC,kBAAkB,IAAyB,EAAE;UAC7C,cAAc,IAAyB,EAAE;UACzC,UAAU,IAAqB,EAAE;UAEjC,aAAa,CAAC,SAAyC;UACvD,OAAO,MAAM,YAAY,YAAY;eAChC,MAAM,QAAQ,IAAI;AAAA;aAEpB,KAAK,MAAM;AAAA;UAGd,EAAE,cAAc,eAAe,aAAa,aAAa,YAAY,OAAO,OAAO,UAAU;UAE7F,kBAAkB,CAAC,MAA2B,YAAqB;YACjE,gBAAgB;AAAA,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;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,OACD;AAAA;WAII;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA;AACF;AAEJ,CAAC;;;sBArTCA,mBASK;IARF,OAAKC;MAAU;;YAA+B,6BAAwB;;;;IAOvEC,YAAiC,sBAAvB,MAAM;;;;;;;"}
|
|
@@ -151,5 +151,6 @@ export interface TreeContext {
|
|
|
151
151
|
fireTreeCheck: (e: Event, key: string | number) => void;
|
|
152
152
|
fireTreeExpand: (e: Event) => void;
|
|
153
153
|
getDataKey: (data: InnerTreeItem) => string | number;
|
|
154
|
+
isDisabledNode: (key: string | number) => boolean;
|
|
154
155
|
}
|
|
155
156
|
export declare const TREE_CONTEXT_INJECTION_KEY: InjectionKey<TreeContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.type.mjs","sources":["../../../../src/components/Tree/Tree.type.ts"],"sourcesContent":["import type { PropType, ExtractPropTypes, InjectionKey, VNode } from 'vue';\nimport { USolidCaretRight } from '@koi-design/uxd-icon';\nimport type { EmitFn, IconPropType } from '../../utils/globalType';\n\nexport interface TreeItem {\n title: string;\n key?: string | number;\n disabled?: boolean;\n children?: TreeItem[];\n isLeaf?: boolean;\n checkable?: boolean;\n [key: string]: any;\n}\n\nexport interface TreeNodeSlotArgs {\n node: InnerTreeItem;\n origin: TreeItem;\n operate: (type: 'add' | 'delete', key: string, children: TreeItem[]) => void;\n}\nexport interface InnerTreeItem extends TreeItem {\n key: string | number;\n slot: (param: TreeNodeSlotArgs) => VNode[];\n operateSlot: (param: TreeNodeSlotArgs) => VNode[];\n componentKey: string;\n dataRef: TreeItem;\n // & { parent: boolean | null };\n parent: InnerTreeItem | null;\n level: string;\n children?: InnerTreeItem[];\n}\n\nexport type TreeMap = Map<string | number, InnerTreeItem>;\n\nexport type TreeLoadData = (node: InnerTreeItem) => Promise<TreeItem[] | undefined>;\n\nexport type GetDataKey = (item: InnerTreeItem) => string | number;\n\nexport const treeProps = {\n treeData: {\n type: Array as PropType<TreeItem[]>,\n default: (): TreeItem[] => []\n },\n dataKey: {\n type: [Function, String] as PropType<string | GetDataKey>,\n default: 'key'\n },\n multiple: {\n type: Boolean,\n default: false\n },\n checkable: {\n type: Boolean,\n default: false\n },\n selectable: {\n type: Boolean,\n default: true\n },\n checkStrictly: {\n type: Boolean,\n default: false\n },\n disabled: {\n type: Boolean,\n default: false\n },\n switcherIcon: {\n type: [String, Object] as PropType<IconPropType>,\n default: USolidCaretRight\n },\n showLine: {\n type: Boolean,\n default: false\n },\n showIcon: {\n type: Boolean,\n default: false\n },\n selectedKeys: {\n type: Array as PropType<(string | number)[]>,\n default: (): string[] => []\n },\n expandedKeys: {\n type: Array as PropType<(string | number)[]>,\n default: (): string[] => []\n },\n checkedKeys: {\n type: Array as PropType<(string | number)[]>,\n default: (): string[] => []\n },\n defaultExpandAll: {\n type: Boolean,\n default: false\n },\n draggable: {\n type: Boolean,\n default: false\n },\n blockNode: {\n type: Boolean,\n default: false\n },\n loadData: {\n type: Function as PropType<TreeLoadData>\n },\n loadedKeys: {\n type: Array as PropType<(string | number)[]>\n },\n treeSelect: {\n type: Boolean,\n default: false\n }\n};\nexport type TreeProps = ExtractPropTypes<typeof treeProps>;\n\nexport const treeEmits = {\n 'update:treeData': (data: TreeItem[]) => Array.isArray(data),\n 'update:selectedKeys': (keys: (string | number)[]) => Array.isArray(keys),\n 'update:expandedKeys': (keys: (string | number)[]) => Array.isArray(keys),\n 'update:checkedKeys': (keys: (string | number)[]) => Array.isArray(keys),\n\n select: (item: TreeItem[], e: Event) => Array.isArray(item) && e instanceof Event,\n check: (checkedkeys: (string | number)[], halfCheckedKeys: (string | number)[], e?: Event) =>\n Array.isArray(checkedkeys) && Array.isArray(halfCheckedKeys) && (e === undefined || e instanceof Event),\n expand: (keys: (string | number)[], e: Event) => Array.isArray(keys) && e instanceof Event,\n 'update-data': (data: TreeItem[]) => Array.isArray(data),\n 'drag-start': (node: TreeItem, e: Event) => typeof node === 'object' && e instanceof Event\n};\n\nexport type TreeEmits = typeof treeEmits;\n\nexport const treeNodeProps = {\n data: {\n type: Object as PropType<InnerTreeItem>,\n default: () => ({} as InnerTreeItem)\n },\n appear: {\n type: Boolean,\n default: false\n }\n};\n\nexport type TreeNodeProps = ExtractPropTypes<typeof treeNodeProps>;\n\nexport interface TreeContext {\n props: TreeProps;\n prefixCls: string;\n treeDataMap: TreeMap;\n selectedKeys: (string | number)[];\n expandedKeys: (string | number)[];\n checkedKeys: (string | number)[];\n halfCheckedKeys: (string | number)[];\n dragKey: string | number;\n loadingKeys: (string | number)[];\n emit: EmitFn<TreeEmits>;\n updateDragKeys: (key: string | number) => void;\n fireTreeDrop: (params: { dragKey: string | number; dropKey: string | number; dropPosition: number; dropToGap: boolean }) => void;\n treeNodeOperate: (type: 'add' | 'delete', key: string, children?: TreeItem[]) => void;\n asyncLoadData: (node: InnerTreeItem) => Promise<void>;\n fireTreeSelect: (e: Event) => void;\n fireTreeCheck: (e: Event, key: string | number) => void;\n fireTreeExpand: (e: Event) => void;\n getDataKey: (data: InnerTreeItem) => string | number;\n}\n\nexport const TREE_CONTEXT_INJECTION_KEY: InjectionKey<TreeContext> = Symbol('treeContext');\n"],"names":[],"mappings":";;MAqCa,YAAY;AAAA,EACvB,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS,MAAkB;AAAC;AAC9B,EACA,SAAS;AAAA,IACP,MAAM,CAAC,UAAU,MAAM;AAAA,IACvB,SAAS;AAAA;AACX,EACA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,WAAW;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,YAAY;AAAA,IACV,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,eAAe;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA;A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AA,EACrF,eAAe,CAAC,SAAqB,MAAM,QAAQ,IAAI;AAAA,EACvD,cAAc,CAAC,MAAgB,MAAa,OAAO,SAAS,YAAY,aAAa;AACvF;MAIa,gBAAgB;AAAA,EAC3B,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,SAAS,OAAO;AAAC;AACnB,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA;AAEb;
|
|
1
|
+
{"version":3,"file":"Tree.type.mjs","sources":["../../../../src/components/Tree/Tree.type.ts"],"sourcesContent":["import type { PropType, ExtractPropTypes, InjectionKey, VNode } from 'vue';\nimport { USolidCaretRight } from '@koi-design/uxd-icon';\nimport type { EmitFn, IconPropType } from '../../utils/globalType';\n\nexport interface TreeItem {\n title: string;\n key?: string | number;\n disabled?: boolean;\n children?: TreeItem[];\n isLeaf?: boolean;\n checkable?: boolean;\n [key: string]: any;\n}\n\nexport interface TreeNodeSlotArgs {\n node: InnerTreeItem;\n origin: TreeItem;\n operate: (type: 'add' | 'delete', key: string, children: TreeItem[]) => void;\n}\nexport interface InnerTreeItem extends TreeItem {\n key: string | number;\n slot: (param: TreeNodeSlotArgs) => VNode[];\n operateSlot: (param: TreeNodeSlotArgs) => VNode[];\n componentKey: string;\n dataRef: TreeItem;\n // & { parent: boolean | null };\n parent: InnerTreeItem | null;\n level: string;\n children?: InnerTreeItem[];\n}\n\nexport type TreeMap = Map<string | number, InnerTreeItem>;\n\nexport type TreeLoadData = (node: InnerTreeItem) => Promise<TreeItem[] | undefined>;\n\nexport type GetDataKey = (item: InnerTreeItem) => string | number;\n\nexport const treeProps = {\n treeData: {\n type: Array as PropType<TreeItem[]>,\n default: (): TreeItem[] => []\n },\n dataKey: {\n type: [Function, String] as PropType<string | GetDataKey>,\n default: 'key'\n },\n multiple: {\n type: Boolean,\n default: false\n },\n checkable: {\n type: Boolean,\n default: false\n },\n selectable: {\n type: Boolean,\n default: true\n },\n checkStrictly: {\n type: Boolean,\n default: false\n },\n disabled: {\n type: Boolean,\n default: false\n },\n switcherIcon: {\n type: [String, Object] as PropType<IconPropType>,\n default: USolidCaretRight\n },\n showLine: {\n type: Boolean,\n default: false\n },\n showIcon: {\n type: Boolean,\n default: false\n },\n selectedKeys: {\n type: Array as PropType<(string | number)[]>,\n default: (): string[] => []\n },\n expandedKeys: {\n type: Array as PropType<(string | number)[]>,\n default: (): string[] => []\n },\n checkedKeys: {\n type: Array as PropType<(string | number)[]>,\n default: (): string[] => []\n },\n defaultExpandAll: {\n type: Boolean,\n default: false\n },\n draggable: {\n type: Boolean,\n default: false\n },\n blockNode: {\n type: Boolean,\n default: false\n },\n loadData: {\n type: Function as PropType<TreeLoadData>\n },\n loadedKeys: {\n type: Array as PropType<(string | number)[]>\n },\n treeSelect: {\n type: Boolean,\n default: false\n }\n};\nexport type TreeProps = ExtractPropTypes<typeof treeProps>;\n\nexport const treeEmits = {\n 'update:treeData': (data: TreeItem[]) => Array.isArray(data),\n 'update:selectedKeys': (keys: (string | number)[]) => Array.isArray(keys),\n 'update:expandedKeys': (keys: (string | number)[]) => Array.isArray(keys),\n 'update:checkedKeys': (keys: (string | number)[]) => Array.isArray(keys),\n\n select: (item: TreeItem[], e: Event) => Array.isArray(item) && e instanceof Event,\n check: (checkedkeys: (string | number)[], halfCheckedKeys: (string | number)[], e?: Event) =>\n Array.isArray(checkedkeys) && Array.isArray(halfCheckedKeys) && (e === undefined || e instanceof Event),\n expand: (keys: (string | number)[], e: Event) => Array.isArray(keys) && e instanceof Event,\n 'update-data': (data: TreeItem[]) => Array.isArray(data),\n 'drag-start': (node: TreeItem, e: Event) => typeof node === 'object' && e instanceof Event\n};\n\nexport type TreeEmits = typeof treeEmits;\n\nexport const treeNodeProps = {\n data: {\n type: Object as PropType<InnerTreeItem>,\n default: () => ({} as InnerTreeItem)\n },\n appear: {\n type: Boolean,\n default: false\n }\n};\n\nexport type TreeNodeProps = ExtractPropTypes<typeof treeNodeProps>;\n\nexport interface TreeContext {\n props: TreeProps;\n prefixCls: string;\n treeDataMap: TreeMap;\n selectedKeys: (string | number)[];\n expandedKeys: (string | number)[];\n checkedKeys: (string | number)[];\n halfCheckedKeys: (string | number)[];\n dragKey: string | number;\n loadingKeys: (string | number)[];\n emit: EmitFn<TreeEmits>;\n updateDragKeys: (key: string | number) => void;\n fireTreeDrop: (params: { dragKey: string | number; dropKey: string | number; dropPosition: number; dropToGap: boolean }) => void;\n treeNodeOperate: (type: 'add' | 'delete', key: string, children?: TreeItem[]) => void;\n asyncLoadData: (node: InnerTreeItem) => Promise<void>;\n fireTreeSelect: (e: Event) => void;\n fireTreeCheck: (e: Event, key: string | number) => void;\n fireTreeExpand: (e: Event) => void;\n getDataKey: (data: InnerTreeItem) => string | number;\n isDisabledNode: (key: string | number) => boolean;\n}\n\nexport const TREE_CONTEXT_INJECTION_KEY: InjectionKey<TreeContext> = Symbol('treeContext');\n"],"names":[],"mappings":";;MAqCa,YAAY;AAAA,EACvB,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS,MAAkB;AAAC;AAC9B,EACA,SAAS;AAAA,IACP,MAAM,CAAC,UAAU,MAAM;AAAA,IACvB,SAAS;AAAA;AACX,EACA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,WAAW;AAAA,IACT,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,YAAY;AAAA,IACV,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,eAAe;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,cAAc;AAAA,IACZ,MAAM,CAAC,QAAQ,MAAM;AAAA,IACrB,SAAS;AAAA;AACX,EACA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA;AACX,EACA,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,SAAS,MAAg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
|
@@ -42,7 +42,19 @@ const _sfc_main = defineComponent({
|
|
|
42
42
|
return tree.loadingKeys.includes(dataKey.value);
|
|
43
43
|
});
|
|
44
44
|
const isDisabled = computed(() => {
|
|
45
|
-
|
|
45
|
+
if (props.data.disabled !== void 0) {
|
|
46
|
+
return props.data.disabled;
|
|
47
|
+
}
|
|
48
|
+
if (!tree.props.checkStrictly) {
|
|
49
|
+
const parentDisabled = tree.isDisabledNode(dataKey.value);
|
|
50
|
+
if (parentDisabled) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return tree.props.disabled;
|
|
55
|
+
});
|
|
56
|
+
const checkStrictly = computed(() => {
|
|
57
|
+
return tree.props.checkable && tree.props.checkStrictly;
|
|
46
58
|
});
|
|
47
59
|
const pauseEvent = (e) => {
|
|
48
60
|
e.stopPropagation();
|
|
@@ -128,6 +140,7 @@ const _sfc_main = defineComponent({
|
|
|
128
140
|
dragOverGapBottom,
|
|
129
141
|
isLeaf,
|
|
130
142
|
treeNodeOperate,
|
|
143
|
+
checkStrictly,
|
|
131
144
|
...toRefs(tree.props)
|
|
132
145
|
};
|
|
133
146
|
}
|
|
@@ -147,6 +160,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
147
160
|
{
|
|
148
161
|
[`${_ctx.prefixCls}-node-open`]: _ctx.expanded,
|
|
149
162
|
[`${_ctx.prefixCls}-node-disabled`]: _ctx.isDisabled,
|
|
163
|
+
[`${_ctx.prefixCls}-node-checkStrictly`]: !_ctx.isDisabled && _ctx.checkStrictly,
|
|
150
164
|
[`${_ctx.prefixCls}-block-node`]: _ctx.blockNode,
|
|
151
165
|
[`${_ctx.prefixCls}-node-selected`]: !_ctx.disabled && !_ctx.data.disabled && _ctx.selected && _ctx.blockNode && !_ctx.checkable,
|
|
152
166
|
"drag-over": _ctx.dragOver,
|