You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
3.1 KiB

{"ast":null,"code":"function toLowercaseSeparator(key) {\n return key.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n}\nfunction getStyleStr(style) {\n return Object.keys(style).map(key => `${toLowercaseSeparator(key)}: ${style[key]};`).join(\" \");\n}\nfunction getPixelRatio() {\n return window.devicePixelRatio || 1;\n}\nconst reRendering = (mutation, watermarkElement) => {\n let flag = false;\n if (mutation.removedNodes.length && watermarkElement) {\n flag = Array.from(mutation.removedNodes).includes(watermarkElement);\n }\n if (mutation.type === \"attributes\" && mutation.target === watermarkElement) {\n flag = true;\n }\n return flag;\n};\nexport { getPixelRatio, getStyleStr, reRendering, toLowercaseSeparator };","map":{"version":3,"names":["toLowercaseSeparator","key","replace","toLowerCase","getStyleStr","style","Object","keys","map","join","getPixelRatio","window","devicePixelRatio","reRendering","mutation","watermarkElement","flag","removedNodes","length","Array","from","includes","type","target"],"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 Separato */\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":"AAAO,SAASA,oBAAoBA,CAACC,GAAG,EAAE;EACxC,OAAOA,GAAG,CAACC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAACC,WAAW,EAAE;AACrD;AACO,SAASC,WAAWA,CAACC,KAAK,EAAE;EACjC,OAAOC,MAAM,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,GAAG,CAAEP,GAAG,IAAK,GAAGD,oBAAoB,CAACC,GAAG,CAAC,KAAKI,KAAK,CAACJ,GAAG,CAAC,GAAG,CAAC,CAACQ,IAAI,CAAC,GAAG,CAAC;AAClG;AACO,SAASC,aAAaA,CAAA,EAAG;EAC9B,OAAOC,MAAM,CAACC,gBAAgB,IAAI,CAAC;AACrC;AACY,MAACC,WAAW,GAAGA,CAACC,QAAQ,EAAEC,gBAAgB,KAAK;EACzD,IAAIC,IAAI,GAAG,KAAK;EAChB,IAAIF,QAAQ,CAACG,YAAY,CAACC,MAAM,IAAIH,gBAAgB,EAAE;IACpDC,IAAI,GAAGG,KAAK,CAACC,IAAI,CAACN,QAAQ,CAACG,YAAY,CAAC,CAACI,QAAQ,CAACN,gBAAgB,CAAC;EACvE;EACE,IAAID,QAAQ,CAACQ,IAAI,KAAK,YAAY,IAAIR,QAAQ,CAACS,MAAM,KAAKR,gBAAgB,EAAE;IAC1EC,IAAI,GAAG,IAAI;EACf;EACE,OAAOA,IAAI;AACb","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}