UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

1 lines • 2.81 kB
{"version":3,"file":"Blur.js","names":[],"sources":["esm/platform/effects/Blur.js"],"sourcesContent":["import { DomView } from \"../web/DomView\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nfunction material(tint) {\n const dark = tint === \"dark\" || tint.endsWith(\"Dark\");\n const color = dark ? \"0,0,0\" : \"255,255,255\";\n const opacity = tint.includes(\"UltraThin\") ? 0.12 : tint.includes(\"Thin\") ? 0.2 : tint.includes(\"Thick\") ? 0.5 : tint.includes(\"Chrome\") ? 0.6 : tint === \"extraLight\" ? 0.15 : tint === \"prominent\" ? 0.45 : 0.3;\n return { color, opacity };\n}\nfunction Blur({\n intensity = 50,\n tint = \"default\",\n children,\n ...props\n}) {\n const strength = Math.max(0, Math.min(1, intensity / 100));\n const { color, opacity } = material(tint);\n const adaptive = ![\"light\", \"dark\", \"extraLight\"].includes(tint) && !tint.endsWith(\"Light\") && !tint.endsWith(\"Dark\");\n const veil = adaptive ? `light-dark(rgba(255,255,255,${strength * opacity}),rgba(0,0,0,${strength * opacity}))` : `rgba(${color},${strength * opacity})`;\n const background = {\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n borderRadius: \"inherit\",\n backdropFilter: `blur(${strength * 20}px)`,\n WebkitBackdropFilter: `blur(${strength * 20}px)`,\n colorScheme: \"light dark\",\n backgroundColor: veil\n };\n return /* @__PURE__ */ jsxs(DomView, { ...props, children: [\n /* @__PURE__ */ jsx(\"div\", { \"aria-hidden\": true, style: background }),\n /* @__PURE__ */ jsx(\n \"div\",\n {\n style: {\n position: \"relative\",\n display: \"flex\",\n flexDirection: \"column\",\n flex: 1\n },\n children\n }\n )\n ] });\n}\nexport {\n Blur\n};\n//# sourceMappingURL=Blur.js.map\n"],"mappings":";;;;AAEA,SAAS,SAAS,MAAM;CACtB,MAAM,OAAO,SAAS,UAAU,KAAK,SAAS,MAAM;CACpD,MAAM,QAAQ,OAAO,UAAU;CAC/B,MAAM,UAAU,KAAK,SAAS,WAAW,IAAI,MAAO,KAAK,SAAS,MAAM,IAAI,KAAM,KAAK,SAAS,OAAO,IAAI,KAAM,KAAK,SAAS,QAAQ,IAAI,KAAM,SAAS,eAAe,MAAO,SAAS,cAAc,MAAO;CAC9M,OAAO;EAAE;EAAO;CAAQ;AAC1B;AACA,SAAS,KAAK,EACZ,YAAY,IACZ,OAAO,WACP,UACA,GAAG,SACF;CACD,MAAM,WAAW,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,YAAY,GAAG,CAAC;CACzD,MAAM,EAAE,OAAO,YAAY,SAAS,IAAI;CACxC,MAAM,WAAW,CAAC;EAAC;EAAS;EAAQ;CAAY,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,KAAK,SAAS,OAAO,KAAK,CAAC,KAAK,SAAS,MAAM;CACpH,MAAM,OAAO,WAAW,+BAA+B,WAAW,QAAQ,eAAe,WAAW,QAAQ,MAAM,QAAQ,MAAM,GAAG,WAAW,QAAQ;CACtJ,MAAM,aAAa;EACjB,UAAU;EACV,OAAO;EACP,eAAe;EACf,cAAc;EACd,gBAAgB,QAAQ,WAAW,GAAG;EACtC,sBAAsB,QAAQ,WAAW,GAAG;EAC5C,aAAa;EACb,iBAAiB;CACnB;CACA,OAAuB,qBAAK,SAAS;EAAE,GAAG;EAAO,UAAU,CACzC,oBAAI,OAAO;GAAE,eAAe;GAAM,OAAO;EAAW,CAAC,GACrD,oBACd,OACA;GACE,OAAO;IACL,UAAU;IACV,SAAS;IACT,eAAe;IACf,MAAM;GACR;GACA;EACF,CACF,CACF;CAAE,CAAC;AACL"}