element-plus
Version:
A Component Library for Vue 3
1 lines • 2.6 kB
Source Map (JSON)
{"version":3,"file":"use-content-dom.mjs","names":[],"sources":["../../../../../../../packages/components/popper/src/composables/use-content-dom.ts"],"sourcesContent":["import { computed, ref, unref } from 'vue'\nimport { useNamespace, useZIndex } from '@element-plus/hooks'\nimport { isNumber } from '@element-plus/utils'\n\nimport type { CSSProperties, StyleValue } from 'vue'\nimport type { UsePopperReturn } from '@element-plus/hooks'\nimport type { UsePopperContentReturn } from './use-content'\nimport type { PopperContentProps } from '../content'\n\nexport const usePopperContentDOM = (\n props: PopperContentProps,\n {\n attributes,\n styles,\n role,\n }: Pick<UsePopperReturn, 'attributes' | 'styles'> &\n Pick<UsePopperContentReturn, 'role'>\n) => {\n const { nextZIndex } = useZIndex()\n const ns = useNamespace('popper')\n\n const contentAttrs = computed(() => unref(attributes).popper)\n const contentZIndex = ref<number>(\n isNumber(props.zIndex) ? props.zIndex : nextZIndex()\n )\n const contentClass = computed(() => [\n ns.b(),\n ns.is('pure', props.pure),\n ns.is(props.effect!),\n props.popperClass,\n ])\n const contentStyle = computed<StyleValue[]>(() => {\n return [\n { zIndex: unref(contentZIndex) } as CSSProperties,\n unref(styles).popper as CSSProperties,\n props.popperStyle || {},\n ]\n })\n const ariaModal = computed<string | undefined>(() =>\n role.value === 'dialog' ? 'false' : undefined\n )\n const arrowStyle = computed(\n () => (unref(styles).arrow || {}) as CSSProperties\n )\n\n const updateZIndex = () => {\n contentZIndex.value = isNumber(props.zIndex) ? props.zIndex : nextZIndex()\n }\n\n return {\n ariaModal,\n arrowStyle,\n contentAttrs,\n contentClass,\n contentStyle,\n contentZIndex,\n\n updateZIndex,\n }\n}\n\nexport type UsePopperContentDOMReturn = ReturnType<typeof usePopperContentDOM>\n"],"mappings":";;;;;;AASA,MAAa,uBACX,OACA,EACE,YACA,QACA,WAGC;CACH,MAAM,EAAE,eAAe,WAAW;CAClC,MAAM,KAAK,aAAa,SAAS;CAEjC,MAAM,eAAe,eAAe,MAAM,WAAW,CAAC,OAAO;CAC7D,MAAM,gBAAgB,IACpB,SAAS,MAAM,OAAO,GAAG,MAAM,SAAS,YAAY,CACrD;CACD,MAAM,eAAe,eAAe;EAClC,GAAG,GAAG;EACN,GAAG,GAAG,QAAQ,MAAM,KAAK;EACzB,GAAG,GAAG,MAAM,OAAQ;EACpB,MAAM;EACP,CAAC;CACF,MAAM,eAAe,eAA6B;AAChD,SAAO;GACL,EAAE,QAAQ,MAAM,cAAc,EAAE;GAChC,MAAM,OAAO,CAAC;GACd,MAAM,eAAe,EAAE;GACxB;GACD;CACF,MAAM,YAAY,eAChB,KAAK,UAAU,WAAW,UAAU,OACrC;CACD,MAAM,aAAa,eACV,MAAM,OAAO,CAAC,SAAS,EAAE,CACjC;CAED,MAAM,qBAAqB;AACzB,gBAAc,QAAQ,SAAS,MAAM,OAAO,GAAG,MAAM,SAAS,YAAY;;AAG5E,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EAEA;EACD"}