UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 2.11 kB
{"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,GAAI,CAAA,OAAA,CAAQ,UAAY,EAAA,KAAK,EAAE,WAAY,EAAA,CAAA;AACpD,CAAA;AAEO,SAAS,YAAY,KAA8B,EAAA;AACxD,EAAO,OAAA,MAAA,CAAO,IAAK,CAAA,KAAK,CACrB,CAAA,GAAA;AAAA,IACC,CAAC,GACC,KAAA,CAAA,EAAG,oBAAqB,CAAA,GAAG,MAAM,KAAM,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,GAC3C,CACC,KAAK,GAAG,CAAA,CAAA;AACb,CAAA;AAGO,SAAS,aAAgB,GAAA;AAC9B,EAAA,OAAO,OAAO,gBAAoB,IAAA,CAAA,CAAA;AACpC,CAAA;AAGa,MAAA,WAAA,GAAc,CACzB,QAAA,EACA,gBACG,KAAA;AACH,EAAA,IAAI,IAAO,GAAA,KAAA,CAAA;AAEX,EAAI,IAAA,QAAA,CAAS,YAAa,CAAA,MAAA,IAAU,gBAAkB,EAAA;AACpD,IAAA,IAAA,GAAO,MAAM,IAAK,CAAA,QAAA,CAAS,YAAY,CAAA,CAAE,SAAS,gBAAgB,CAAA,CAAA;AAAA,GACpE;AAEA,EAAA,IAAI,QAAS,CAAA,IAAA,KAAS,YAAgB,IAAA,QAAA,CAAS,WAAW,gBAAkB,EAAA;AAC1E,IAAO,IAAA,GAAA,IAAA,CAAA;AAAA,GACT;AACA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}