maz-ui 4.3.4-beta.1 → 4.3.4-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ .m-card-spotlight[data-v-97a73cfa]{border-radius:var(--maz-radius);padding:max(var(--maz-border-width),1px);contain:layout style paint;display:inline-flex;position:relative;overflow:hidden}.m-card-spotlight .inner[data-v-97a73cfa]{border-radius:calc(var(--maz-radius) - max(var(--maz-border-width),1px));width:100%;height:auto;position:relative;overflow:hidden}.m-card-spotlight .inner[data-v-97a73cfa]:before{content:"";z-index:1;--maz-tw-bg-opacity:1;background-color:hsl(var(--maz-background)/var(--maz-tw-bg-opacity,1));width:100%;height:100%;opacity:var(--inner-opacity);position:absolute;top:0;left:0}.m-card-spotlight .content[data-v-97a73cfa]{z-index:2;width:100%;height:100%;position:relative}.m-card-spotlight .blob[data-v-97a73cfa]{z-index:0;--maz-tw-blur:blur(40px);filter:var(--maz-tw-blur)var(--maz-tw-brightness)var(--maz-tw-contrast)var(--maz-tw-grayscale)var(--maz-tw-hue-rotate)var(--maz-tw-invert)var(--maz-tw-saturate)var(--maz-tw-sepia)var(--maz-tw-drop-shadow);will-change:transform;border-radius:9999px;width:208px;height:208px;transition:transform .12s cubic-bezier(.4,0,.2,1),opacity .15s ease-out;position:absolute;top:0;left:0}
@@ -1,6 +1,7 @@
1
- import { defineComponent, ref, computed, onMounted, onUnmounted, createElementBlock, openBlock, normalizeStyle, normalizeClass, createElementVNode, withDirectives, renderSlot, vShow } from "vue";
1
+ import { defineComponent, ref, computed, onMounted, onBeforeUnmount, createElementBlock, openBlock, normalizeStyle, normalizeClass, createElementVNode, withDirectives, renderSlot, vShow } from "vue";
2
+ import { isServer } from "@maz-ui/utils";
2
3
  import { _ as _export_sfc } from "../chunks/_plugin-vue_export-helper.B--vMWp3.js";
3
- import '../assets/MazCardSpotlight.B7lFD7Pi.css';const _hoisted_1 = { class: "inner" }, _sfc_main = /* @__PURE__ */ defineComponent({
4
+ import '../assets/MazCardSpotlight.B-P62Hj-.css';const _hoisted_1 = { class: "inner" }, _sfc_main = /* @__PURE__ */ defineComponent({
4
5
  __name: "MazCardSpotlight",
5
6
  props: {
6
7
  color: { default: "primary" },
@@ -13,28 +14,46 @@ import '../assets/MazCardSpotlight.B7lFD7Pi.css';const _hoisted_1 = { class: "in
13
14
  innerOpacity: { default: 0.95 }
14
15
  },
15
16
  setup(__props) {
16
- const blobElement = ref(), fakeblobElement = ref(), blobVisible = ref(!1);
17
- function animateBlob({ clientX, clientY }) {
18
- blobVisible.value = !0;
19
- const rec = fakeblobElement.value?.getBoundingClientRect();
20
- rec && blobElement.value?.animate?.(
21
- [
22
- {
23
- transform: `translate(${clientX - rec.left - rec.width / 2}px,${clientY - rec.top - rec.height / 2}px)`
24
- }
25
- ],
26
- {
27
- duration: 300,
28
- fill: "forwards"
29
- }
30
- );
31
- }
17
+ const containerElement = ref(), blobElement = ref(), blobVisible = ref(!1);
18
+ let rafId = null, isIntersecting = !1, cachedRect = null;
32
19
  const alphaColor = computed(() => `hsl(var(--maz-${__props.color}) / 60%)`), alphaColor20 = computed(() => `hsl(var(--maz-${__props.color}) / 20%)`);
20
+ function updateCachedRect() {
21
+ containerElement.value && (cachedRect = containerElement.value.getBoundingClientRect());
22
+ }
23
+ function updateBlobPosition(x, y) {
24
+ if (!blobElement.value || !cachedRect)
25
+ return;
26
+ const blobWidth = 208, blobHeight = 208, translateX = x - cachedRect.left - blobWidth / 2, translateY = y - cachedRect.top - blobHeight / 2;
27
+ blobElement.value.style.transform = `translate(${translateX}px, ${translateY}px)`;
28
+ }
29
+ function handleMouseMove(event) {
30
+ !isIntersecting || rafId !== null || (blobVisible.value = !0, rafId = requestAnimationFrame(() => {
31
+ updateBlobPosition(event.clientX, event.clientY), rafId = null;
32
+ }));
33
+ }
34
+ function stopBlobAnimation() {
35
+ blobVisible.value = !1, rafId !== null && (cancelAnimationFrame(rafId), rafId = null);
36
+ }
33
37
  return onMounted(() => {
34
- globalThis.addEventListener("mousemove", animateBlob);
35
- }), onUnmounted(() => {
36
- globalThis.removeEventListener("mousemove", animateBlob);
38
+ if (isServer() || !containerElement.value)
39
+ return;
40
+ updateCachedRect();
41
+ const observer = new IntersectionObserver(
42
+ (entries) => {
43
+ isIntersecting = entries[0].isIntersecting, isIntersecting || stopBlobAnimation();
44
+ },
45
+ { threshold: 0 }
46
+ );
47
+ observer.observe(containerElement.value);
48
+ const handleScrollResize = () => {
49
+ updateCachedRect();
50
+ };
51
+ globalThis.addEventListener("mousemove", handleMouseMove, { passive: !0 }), globalThis.addEventListener("scroll", handleScrollResize, { passive: !0 }), globalThis.addEventListener("resize", handleScrollResize, { passive: !0 }), onBeforeUnmount(() => {
52
+ rafId !== null && cancelAnimationFrame(rafId), observer.disconnect(), globalThis.removeEventListener("mousemove", handleMouseMove), globalThis.removeEventListener("scroll", handleScrollResize), globalThis.removeEventListener("resize", handleScrollResize);
53
+ });
37
54
  }), (_ctx, _cache) => (openBlock(), createElementBlock("div", {
55
+ ref_key: "containerElement",
56
+ ref: containerElement,
38
57
  class: normalizeClass(["m-card-spotlight m-reset-css", { "maz-shadow-elevation maz-drop-shadow-md": __props.elevation }]),
39
58
  style: normalizeStyle({ backgroundColor: alphaColor20.value, "--inner-opacity": __props.innerOpacity })
40
59
  }, [
@@ -53,17 +72,10 @@ import '../assets/MazCardSpotlight.B7lFD7Pi.css';const _hoisted_1 = { class: "in
53
72
  style: normalizeStyle({ backgroundColor: alphaColor.value })
54
73
  }, null, 4), [
55
74
  [vShow, blobVisible.value]
56
- ]),
57
- withDirectives(createElementVNode("div", {
58
- ref_key: "fakeblobElement",
59
- ref: fakeblobElement,
60
- class: "fakeblob"
61
- }, null, 512), [
62
- [vShow, blobVisible.value]
63
75
  ])
64
76
  ], 6));
65
77
  }
66
- }), MazCardSpotlight = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bc3305c0"]]);
78
+ }), MazCardSpotlight = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-97a73cfa"]]);
67
79
  export {
68
80
  MazCardSpotlight as default
69
81
  };
@@ -38,15 +38,15 @@ declare function __VLS_template(): {
38
38
  default?(_: {}): any;
39
39
  };
40
40
  refs: {
41
+ containerElement: HTMLDivElement;
41
42
  blobElement: HTMLDivElement;
42
- fakeblobElement: HTMLDivElement;
43
43
  };
44
44
  rootEl: HTMLDivElement;
45
45
  };
46
46
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
47
47
  declare const __VLS_component: import('vue').DefineComponent<MazCardSpotlightProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<MazCardSpotlightProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
48
+ containerElement: HTMLDivElement;
48
49
  blobElement: HTMLDivElement;
49
- fakeblobElement: HTMLDivElement;
50
50
  }, HTMLDivElement>;
51
51
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
52
52
  export default _default;
@@ -38,15 +38,15 @@ declare function __VLS_template(): {
38
38
  default?(_: {}): any;
39
39
  };
40
40
  refs: {
41
+ containerElement: HTMLDivElement;
41
42
  blobElement: HTMLDivElement;
42
- fakeblobElement: HTMLDivElement;
43
43
  };
44
44
  rootEl: HTMLDivElement;
45
45
  };
46
46
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
47
47
  declare const __VLS_component: import('vue').DefineComponent<MazCardSpotlightProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<MazCardSpotlightProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
48
+ containerElement: HTMLDivElement;
48
49
  blobElement: HTMLDivElement;
49
- fakeblobElement: HTMLDivElement;
50
50
  }, HTMLDivElement>;
51
51
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
52
52
  export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "maz-ui",
3
3
  "type": "module",
4
- "version": "4.3.4-beta.1",
4
+ "version": "4.3.4-beta.2",
5
5
  "description": "A standalone components library for Vue.Js 3 & Nuxt.Js 3",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
@@ -178,11 +178,11 @@
178
178
  "libphonenumber-js": "^1.12.33",
179
179
  "valibot": "^1.2.0",
180
180
  "vue-chartjs": "^5.3.3",
181
- "@maz-ui/icons": "4.3.0",
182
181
  "@maz-ui/cli": "4.3.4-beta.0",
183
- "@maz-ui/utils": "4.3.0",
182
+ "@maz-ui/icons": "4.3.0",
184
183
  "@maz-ui/themes": "4.3.0",
185
- "@maz-ui/translations": "4.3.0"
184
+ "@maz-ui/translations": "4.3.0",
185
+ "@maz-ui/utils": "4.3.0"
186
186
  },
187
187
  "devDependencies": {
188
188
  "@vitejs/plugin-vue": "^6.0.3",
@@ -1 +0,0 @@
1
- .m-card-spotlight[data-v-bc3305c0]{border-radius:var(--maz-radius);padding:max(var(--maz-border-width),1px);display:inline-flex;position:relative;overflow:hidden}.m-card-spotlight .inner[data-v-bc3305c0]{border-radius:calc(var(--maz-radius) - max(var(--maz-border-width),1px));width:100%;height:auto;position:relative;overflow:hidden}.m-card-spotlight .inner[data-v-bc3305c0]:before{content:"";z-index:1;--maz-tw-bg-opacity:1;background-color:hsl(var(--maz-background)/var(--maz-tw-bg-opacity,1));width:100%;height:100%;opacity:var(--inner-opacity);position:absolute;top:0;left:0}.m-card-spotlight .content[data-v-bc3305c0]{z-index:2;width:100%;height:100%;position:relative}.m-card-spotlight .blob[data-v-bc3305c0]{z-index:0;--maz-tw-blur:blur(40px);width:16rem;height:16rem;filter:var(--maz-tw-blur)var(--maz-tw-brightness)var(--maz-tw-contrast)var(--maz-tw-grayscale)var(--maz-tw-hue-rotate)var(--maz-tw-invert)var(--maz-tw-saturate)var(--maz-tw-sepia)var(--maz-tw-drop-shadow);border-radius:9999px;position:absolute;top:0;left:0}.m-card-spotlight .fakeblob[data-v-bc3305c0]{z-index:-1;border-radius:9999px;width:13rem;height:13rem;position:absolute;top:0;left:0}