{"version":3,"file":"use-collapse-item.js","sources":["../../../../../../packages/components/collapse/src/use-collapse-item.ts"],"sourcesContent":["import { computed, inject, ref, unref } from 'vue'\nimport { useIdInjection, useNamespace } from '@element-plus/hooks'\nimport { collapseContextKey } from './constants'\n\nimport type { CollapseItemProps } from './collapse-item'\n\nexport const useCollapseItem = (props: CollapseItemProps) => {\n const collapse = inject(collapseContextKey)\n const { namespace } = useNamespace('collapse')\n\n const focusing = ref(false)\n const isClick = ref(false)\n const idInjection = useIdInjection()\n const id = computed(() => idInjection.current++)\n const name = computed(() => {\n return (\n props.name ?? `${namespace.value}-id-${idInjection.prefix}-${unref(id)}`\n )\n })\n\n const isActive = computed(() =>\n collapse?.activeNames.value.includes(unref(name))\n )\n\n const handleFocus = () => {\n setTimeout(() => {\n if (!isClick.value) {\n focusing.value = true\n } else {\n isClick.value = false\n }\n }, 50)\n }\n\n const handleHeaderClick = () => {\n if (props.disabled) return\n collapse?.handleItemClick(unref(name))\n focusing.value = false\n isClick.value = true\n }\n\n const handleEnterClick = () => {\n collapse?.handleItemClick(unref(name))\n }\n\n return {\n focusing,\n id,\n isActive,\n handleFocus,\n handleHeaderClick,\n handleEnterClick,\n }\n}\n\nexport const useCollapseItemDOM = (\n props: CollapseItemProps,\n { focusing, isActive, id }: Partial>\n) => {\n const ns = useNamespace('collapse')\n\n const rootKls = computed(() => [\n ns.b('item'),\n ns.is('active', unref(isActive)),\n ns.is('disabled', props.disabled),\n ])\n const headKls = computed(() => [\n ns.be('item', 'header'),\n ns.is('active', unref(isActive)),\n { focusing: unref(focusing) && !props.disabled },\n ])\n const arrowKls = computed(() => [\n ns.be('item', 'arrow'),\n ns.is('active', unref(isActive)),\n ])\n const itemWrapperKls = computed(() => ns.be('item', 'wrap'))\n const itemContentKls = computed(() => ns.be('item', 'content'))\n const scopedContentId = computed(() => ns.b(`content-${unref(id)}`))\n const scopedHeadId = computed(() => ns.b(`head-${unref(id)}`))\n\n return {\n arrowKls,\n headKls,\n rootKls,\n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