element-plus
Version:
A Component Library for Vue 3
1 lines • 2.06 kB
Source Map (JSON)
{"version":3,"file":"utils.mjs","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"],"names":[],"mappings":"AAGO,SAAS,qBAAqB,GAAA,EAAa;AAChD,EAAA,OAAO,GAAA,CAAI,OAAA,CAAQ,UAAA,EAAY,KAAK,EAAE,WAAA,EAAY;AACpD;AAEO,SAAS,YAAY,KAAA,EAA8B;AACxD,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,CACrB,GAAA;AAAA,IACC,CAAC,QACC,CAAA,EAAG,oBAAA,CAAqB,GAAG,CAAC,CAAA,EAAA,EAAK,KAAA,CAAM,GAA0B,CAAC,CAAA,CAAA;AAAA,GACtE,CACC,KAAK,GAAG,CAAA;AACb;AAGO,SAAS,aAAA,GAAgB;AAC9B,EAAA,OAAO,OAAO,gBAAA,IAAoB,CAAA;AACpC;AAGO,MAAM,WAAA,GAAc,CACzB,QAAA,EACA,gBAAA,KACG;AACH,EAAA,IAAI,IAAA,GAAO,KAAA;AAEX,EAAA,IAAI,QAAA,CAAS,YAAA,CAAa,MAAA,IAAU,gBAAA,EAAkB;AACpD,IAAA,IAAA,GAAO,MAAM,IAAA,CAAK,QAAA,CAAS,YAAY,CAAA,CAAE,SAAS,gBAAgB,CAAA;AAAA,EACpE;AAEA,EAAA,IAAI,QAAA,CAAS,IAAA,KAAS,YAAA,IAAgB,QAAA,CAAS,WAAW,gBAAA,EAAkB;AAC1E,IAAA,IAAA,GAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA;AACT;;;;"}