UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 1.73 kB
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../../../../packages/components/watermark/src/utils.ts"],"sourcesContent":["import type { CSSProperties } from 'vue'\n\n/** converting camel-cased strings to be lowercase and link it with Separator */\nexport function toLowercaseSeparator(key: string) {\n return key.replace(/([A-Z])/g, '-$1').toLowerCase()\n}\n\nexport function getStyleStr(style: CSSProperties): string {\n return Object.keys(style)\n .map(\n (key) =>\n `${toLowercaseSeparator(key)}: ${style[key as keyof CSSProperties]};`\n )\n .join(' ')\n}\n\n/** Returns the ratio of the device's physical pixel resolution to the css pixel resolution */\nexport function getPixelRatio() {\n return window.devicePixelRatio || 1\n}\n\n/** Whether to re-render the watermark */\nexport const reRendering = (\n mutation: MutationRecord,\n watermarkElement?: HTMLElement\n) => {\n let flag = false\n // Whether to delete the watermark node\n if (mutation.removedNodes.length && watermarkElement) {\n flag = Array.from(mutation.removedNodes).includes(watermarkElement)\n }\n // Whether the watermark dom property value has been modified\n if (mutation.type === 'attributes' && mutation.target === watermarkElement) {\n flag = true\n }\n return flag\n}\n"],"mappings":";;AAGA,SAAgB,qBAAqB,KAAa;AAChD,QAAO,IAAI,QAAQ,YAAY,MAAM,CAAC,aAAa;;AAGrD,SAAgB,YAAY,OAA8B;AACxD,QAAO,OAAO,KAAK,MAAM,CACtB,KACE,QACC,GAAG,qBAAqB,IAAI,CAAC,IAAI,MAAM,KAA4B,GACtE,CACA,KAAK,IAAI;;;AAId,SAAgB,gBAAgB;AAC9B,QAAO,OAAO,oBAAoB;;;AAIpC,MAAa,eACX,UACA,qBACG;CACH,IAAI,OAAO;AAEX,KAAI,SAAS,aAAa,UAAU,iBAClC,QAAO,MAAM,KAAK,SAAS,aAAa,CAAC,SAAS,iBAAiB;AAGrE,KAAI,SAAS,SAAS,gBAAgB,SAAS,WAAW,iBACxD,QAAO;AAET,QAAO"}