@shohojdhara/atomix 0.4.5 → 0.4.7
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.
- package/dist/atomix.css +70 -33
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +2 -2
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.d.ts +93 -109
- package/dist/charts.js +273 -371
- package/dist/charts.js.map +1 -1
- package/dist/core.js +183 -184
- package/dist/core.js.map +1 -1
- package/dist/forms.js +183 -184
- package/dist/forms.js.map +1 -1
- package/dist/heavy.js +183 -184
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +7 -51
- package/dist/index.esm.js +281 -470
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +287 -476
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AtomixGlass/AtomixGlass.tsx +60 -38
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +6 -35
- package/src/components/AtomixGlass/glass-utils.ts +27 -14
- package/src/components/AtomixGlass/stories/Overview.stories.tsx +19 -21
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +1162 -515
- package/src/components/AtomixGlass/stories/shared-components.tsx +11 -3
- package/src/components/Chart/BubbleChart.tsx +6 -2
- package/src/components/Chart/Chart.stories.tsx +108 -96
- package/src/components/Chart/ChartToolbar.tsx +6 -4
- package/src/components/Chart/ChartTooltip.tsx +5 -4
- package/src/components/Chart/GaugeChart.tsx +20 -12
- package/src/components/Chart/HeatmapChart.tsx +53 -23
- package/src/components/Chart/TreemapChart.tsx +44 -15
- package/src/components/Chart/index.ts +0 -2
- package/src/components/Chart/types.ts +4 -4
- package/src/components/Navigation/Navbar/Navbar.tsx +13 -5
- package/src/components/index.ts +0 -1
- package/src/lib/composables/index.ts +1 -2
- package/src/lib/composables/useAtomixGlass.ts +246 -222
- package/src/lib/composables/useAtomixGlassStyles.ts +46 -23
- package/src/lib/constants/components.ts +3 -1
- package/src/styles/01-settings/_settings.chart.scss +13 -13
- package/src/styles/06-components/_components.atomix-glass.scss +45 -20
- package/src/styles/06-components/_components.chart.scss +23 -5
- package/src/components/Chart/AnimatedChart.tsx +0 -230
- package/src/lib/composables/atomix-glass/useGlassBackgroundDetection.ts +0 -329
- package/src/lib/composables/atomix-glass/useGlassCornerRadius.ts +0 -82
- package/src/lib/composables/atomix-glass/useGlassMouseTracking.ts +0 -153
- package/src/lib/composables/atomix-glass/useGlassOverLight.ts +0 -198
- package/src/lib/composables/atomix-glass/useGlassState.ts +0 -112
- package/src/lib/composables/atomix-glass/useGlassTransforms.ts +0 -160
- package/src/lib/composables/glass-styles.ts +0 -302
- package/src/lib/composables/useGlassContainer.ts +0 -177
package/dist/index.esm.js
CHANGED
|
@@ -1730,7 +1730,9 @@ const _includesInstanceProperty = getDefaultExportFromCjs((function(it) {
|
|
|
1730
1730
|
ENABLE_OVER_LIGHT_LAYERS: !0
|
|
1731
1731
|
},
|
|
1732
1732
|
CONSTANTS: {
|
|
1733
|
-
ACTIVATION_ZONE:
|
|
1733
|
+
ACTIVATION_ZONE: 350,
|
|
1734
|
+
LERP_FACTOR: .08,
|
|
1735
|
+
SMOOTHSTEP_POWER: 2.5,
|
|
1734
1736
|
MIN_BLUR: .1,
|
|
1735
1737
|
MOUSE_INFLUENCE_DIVISOR: 100,
|
|
1736
1738
|
EDGE_FADE_PIXELS: 2,
|
|
@@ -2025,7 +2027,7 @@ const {CONSTANTS: CONSTANTS$2} = ATOMIX_GLASS, calculateDistance = (pos1, pos2)
|
|
|
2025
2027
|
// Silently handle errors
|
|
2026
2028
|
}
|
|
2027
2029
|
return CONSTANTS$2.DEFAULT_CORNER_RADIUS;
|
|
2028
|
-
}, getDisplacementMap = (mode, displacementMap, polarDisplacementMap, prominentDisplacementMap, shaderMapUrl) => {
|
|
2030
|
+
}, lerp = (a, b, t) => a + (b - a) * t, softClamp = (value, max) => max <= 0 ? 0 : max * (1 - Math.exp(-value / max)), getDisplacementMap = (mode, displacementMap, polarDisplacementMap, prominentDisplacementMap, shaderMapUrl) => {
|
|
2029
2031
|
switch (mode) {
|
|
2030
2032
|
case "standard":
|
|
2031
2033
|
return displacementMap;
|
|
@@ -2383,20 +2385,12 @@ const sharedShaderCache = new Map, AtomixGlassContainer = forwardRef((({childre
|
|
|
2383
2385
|
onClick: onClick,
|
|
2384
2386
|
children: jsxs("div", {
|
|
2385
2387
|
className: ATOMIX_GLASS.INNER_CLASS,
|
|
2386
|
-
style: {
|
|
2387
|
-
padding: "var(--atomix-glass-container-padding)",
|
|
2388
|
-
boxShadow: "var(--atomix-glass-container-box-shadow)"
|
|
2389
|
-
},
|
|
2390
2388
|
onMouseEnter: onMouseEnter,
|
|
2391
2389
|
onMouseLeave: onMouseLeave,
|
|
2392
2390
|
onMouseDown: onMouseDown,
|
|
2393
2391
|
onMouseUp: onMouseUp,
|
|
2394
2392
|
children: [ jsxs("div", {
|
|
2395
2393
|
className: ATOMIX_GLASS.FILTER_CLASS,
|
|
2396
|
-
style: {
|
|
2397
|
-
position: "absolute",
|
|
2398
|
-
inset: 0
|
|
2399
|
-
},
|
|
2400
2394
|
children: [ jsx(GlassFilter, {
|
|
2401
2395
|
blurAmount: blurAmount,
|
|
2402
2396
|
mode: mode,
|
|
@@ -2411,26 +2405,14 @@ const sharedShaderCache = new Map, AtomixGlassContainer = forwardRef((({childre
|
|
|
2411
2405
|
},
|
|
2412
2406
|
className: ATOMIX_GLASS.FILTER_OVERLAY_CLASS,
|
|
2413
2407
|
style: {
|
|
2414
|
-
filter: `url(#${filterId})
|
|
2415
|
-
backdropFilter: "var(--atomix-glass-container-backdrop)",
|
|
2416
|
-
borderRadius: "var(--atomix-glass-container-radius)"
|
|
2408
|
+
filter: `url(#${filterId})`
|
|
2417
2409
|
}
|
|
2418
2410
|
}), jsx("div", {
|
|
2419
|
-
className: ATOMIX_GLASS.FILTER_SHADOW_CLASS
|
|
2420
|
-
style: {
|
|
2421
|
-
boxShadow: "var(--atomix-glass-container-shadow)",
|
|
2422
|
-
opacity: "var(--atomix-glass-container-shadow-opacity)",
|
|
2423
|
-
background: "var(--atomix-glass-container-bg)",
|
|
2424
|
-
borderRadius: "var(--atomix-glass-container-radius)"
|
|
2425
|
-
}
|
|
2411
|
+
className: ATOMIX_GLASS.FILTER_SHADOW_CLASS
|
|
2426
2412
|
}) ]
|
|
2427
2413
|
}), jsx("div", {
|
|
2428
2414
|
ref: contentRef,
|
|
2429
2415
|
className: ATOMIX_GLASS.CONTENT_CLASS,
|
|
2430
|
-
style: {
|
|
2431
|
-
position: "relative",
|
|
2432
|
-
textShadow: "var(--atomix-glass-container-text-shadow)"
|
|
2433
|
-
},
|
|
2434
2416
|
children: children
|
|
2435
2417
|
}) ]
|
|
2436
2418
|
})
|
|
@@ -2534,31 +2516,39 @@ class {
|
|
|
2534
2516
|
saturationBoost: baseOverLightConfig.saturationBoost
|
|
2535
2517
|
};
|
|
2536
2518
|
// Calculate mouse influence
|
|
2537
|
-
|
|
2538
|
-
let elasticTranslation = {
|
|
2519
|
+
let computedDirectionalScale = directionalScale, elasticTranslation = {
|
|
2539
2520
|
x: 0,
|
|
2540
2521
|
y: 0
|
|
2541
2522
|
};
|
|
2542
|
-
|
|
2523
|
+
// Calculate elastic translation and directional scale
|
|
2524
|
+
if (!effectiveWithoutEffects && wrapperElement) {
|
|
2543
2525
|
const rect = wrapperElement.getBoundingClientRect(), center = calculateElementCenter(rect);
|
|
2544
|
-
//
|
|
2545
|
-
let fadeInFactor = 0;
|
|
2526
|
+
// Mouse presence and edge distance logic
|
|
2546
2527
|
if (globalMousePosition.x && globalMousePosition.y && validateGlassSize(glassSize)) {
|
|
2547
|
-
const edgeDistanceX = Math.max(0, Math.abs(
|
|
2528
|
+
const deltaX = globalMousePosition.x - center.x, deltaY = globalMousePosition.y - center.y, edgeDistanceX = Math.max(0, Math.abs(deltaX) - glassSize.width / 2), edgeDistanceY = Math.max(0, Math.abs(deltaY) - glassSize.height / 2), edgeDistance = calculateDistance({
|
|
2548
2529
|
x: edgeDistanceX,
|
|
2549
2530
|
y: edgeDistanceY
|
|
2550
2531
|
}, {
|
|
2551
2532
|
x: 0,
|
|
2552
2533
|
y: 0
|
|
2553
|
-
})
|
|
2554
|
-
|
|
2534
|
+
}), rawT = edgeDistance > ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE ? 0 : 1 - edgeDistance / ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE, fadeInFactor = (t => {
|
|
2535
|
+
const clamped = Math.max(0, Math.min(1, t));
|
|
2536
|
+
return clamped * clamped * (3 - 2 * clamped);
|
|
2537
|
+
})(rawT);
|
|
2538
|
+
// Directional scale
|
|
2539
|
+
if (elasticTranslation = {
|
|
2540
|
+
x: deltaX * elasticity * .1 * fadeInFactor,
|
|
2541
|
+
y: deltaY * elasticity * .1 * fadeInFactor
|
|
2542
|
+
}, !isOverLight && edgeDistance <= ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE) {
|
|
2543
|
+
const centerDistance = calculateDistance(globalMousePosition, center);
|
|
2544
|
+
if (centerDistance > 0) {
|
|
2545
|
+
const normalizedX = deltaX / centerDistance, normalizedY = deltaY / centerDistance, stretchIntensity = Math.min(centerDistance / 300, 1) * elasticity * rawT, scaleX = 1 + Math.abs(normalizedX) * stretchIntensity * .3 - Math.abs(normalizedY) * stretchIntensity * .15, scaleY = 1 + Math.abs(normalizedY) * stretchIntensity * .3 - Math.abs(normalizedX) * stretchIntensity * .15, softScaleX = 1 - softClamp(Math.max(0, 1 - scaleX), .2), softScaleY = 1 - softClamp(Math.max(0, 1 - scaleY), .2);
|
|
2546
|
+
computedDirectionalScale = `scaleX(${Math.max(.85, softScaleX)}) scaleY(${Math.max(.85, softScaleY)})`;
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2555
2549
|
}
|
|
2556
|
-
elasticTranslation = {
|
|
2557
|
-
x: (globalMousePosition.x - center.x) * elasticity * .1 * fadeInFactor,
|
|
2558
|
-
y: (globalMousePosition.y - center.y) * elasticity * .1 * fadeInFactor
|
|
2559
|
-
};
|
|
2560
2550
|
}
|
|
2561
|
-
const transformStyle = effectiveWithoutEffects ? isActive && Boolean(onClick) ? "scale(0.98)" : "scale(1)" : `translate(${elasticTranslation.x}px, ${elasticTranslation.y}px) ${isActive && Boolean(onClick) ? "scale(0.96)" :
|
|
2551
|
+
const transformStyle = effectiveWithoutEffects ? isActive && Boolean(onClick) ? "scale(0.98)" : "scale(1)" : `translate(${elasticTranslation.x}px, ${elasticTranslation.y}px) ${isActive && Boolean(onClick) ? "scale(0.96)" : computedDirectionalScale}`;
|
|
2562
2552
|
// Update Wrapper Styles (glassVars)
|
|
2563
2553
|
if (wrapperElement) {
|
|
2564
2554
|
const mx = mouseOffset.x, my = mouseOffset.y, absMx = Math.abs(mx), absMy = Math.abs(my), GRADIENT = ATOMIX_GLASS.CONSTANTS.GRADIENT, borderGradientAngle = GRADIENT.BASE_ANGLE + mx * GRADIENT.ANGLE_MULTIPLIER, borderStop1 = Math.max(GRADIENT.BORDER_STOP_1.MIN, GRADIENT.BORDER_STOP_1.BASE + my * GRADIENT.BORDER_STOP_1.MULTIPLIER), borderStop2 = Math.min(GRADIENT.BORDER_STOP_2.MAX, GRADIENT.BORDER_STOP_2.BASE + my * GRADIENT.BORDER_STOP_2.MULTIPLIER), borderOpacities = [ GRADIENT.BORDER_OPACITY.BASE_1 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_LOW, GRADIENT.BORDER_OPACITY.BASE_2 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_HIGH, GRADIENT.BORDER_OPACITY.BASE_3 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_LOW, GRADIENT.BORDER_OPACITY.BASE_4 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_HIGH ], configBorderOpacity = overLightConfig.borderOpacity, whiteColor = ATOMIX_GLASS.CONSTANTS.PALETTE.WHITE, blackColor = ATOMIX_GLASS.CONSTANTS.PALETTE.BLACK, hoverPositions = {
|
|
@@ -2665,7 +2655,13 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2665
2655
|
}), internalMouseOffsetRef = useRef({
|
|
2666
2656
|
x: 0,
|
|
2667
2657
|
y: 0
|
|
2668
|
-
}),
|
|
2658
|
+
}), targetMouseOffsetRef = useRef({
|
|
2659
|
+
x: 0,
|
|
2660
|
+
y: 0
|
|
2661
|
+
}), targetGlobalMousePositionRef = useRef({
|
|
2662
|
+
x: 0,
|
|
2663
|
+
y: 0
|
|
2664
|
+
}), lerpRafRef = useRef(null), lerpActiveRef = useRef(!1), [dynamicBorderRadius, setDynamicCornerRadius] = useState(CONSTANTS.DEFAULT_CORNER_RADIUS), [userPrefersReducedMotion, setUserPrefersReducedMotion] = useState(!1), [userPrefersHighContrast, setUserPrefersHighContrast] = useState(!1), [detectedOverLight, setDetectedOverLight] = useState(!1), effectiveBorderRadius = useMemo((() => void 0 !== borderRadius ? Math.max(0, borderRadius) : Math.max(0, dynamicBorderRadius)), [ borderRadius, dynamicBorderRadius ]), {glassSize: glassSize} = function({glassRef: glassRef, effectiveBorderRadius: effectiveBorderRadius, cachedRectRef: cachedRectRef}) {
|
|
2669
2665
|
const [glassSize, setGlassSize] = useState({
|
|
2670
2666
|
width: 270,
|
|
2671
2667
|
height: 69
|
|
@@ -2762,7 +2758,23 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2762
2758
|
const timeoutId = setTimeout(extractRadius, 100);
|
|
2763
2759
|
return () => clearTimeout(timeoutId);
|
|
2764
2760
|
}), [ children, debugBorderRadius, contentRef ]),
|
|
2765
|
-
// Media query
|
|
2761
|
+
// Media query detection for reduced motion and high contrast
|
|
2762
|
+
useEffect((() => {
|
|
2763
|
+
if ("undefined" == typeof window || "function" != typeof window.matchMedia) return;
|
|
2764
|
+
const mediaQueryReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)"), mediaQueryHighContrast = window.matchMedia("(prefers-contrast: high)");
|
|
2765
|
+
setUserPrefersReducedMotion(mediaQueryReducedMotion.matches), setUserPrefersHighContrast(mediaQueryHighContrast.matches);
|
|
2766
|
+
const handleReducedMotionChange = e => {
|
|
2767
|
+
setUserPrefersReducedMotion(e.matches);
|
|
2768
|
+
}, handleHighContrastChange = e => {
|
|
2769
|
+
setUserPrefersHighContrast(e.matches);
|
|
2770
|
+
};
|
|
2771
|
+
return mediaQueryReducedMotion.addEventListener("change", handleReducedMotionChange),
|
|
2772
|
+
mediaQueryHighContrast.addEventListener("change", handleHighContrastChange), () => {
|
|
2773
|
+
mediaQueryReducedMotion.removeEventListener("change", handleReducedMotionChange),
|
|
2774
|
+
mediaQueryHighContrast.removeEventListener("change", handleHighContrastChange);
|
|
2775
|
+
};
|
|
2776
|
+
}), []),
|
|
2777
|
+
// Background detection for overLight auto-detect
|
|
2766
2778
|
useEffect((() => {
|
|
2767
2779
|
if (("auto" === overLight || "object" == typeof overLight && null !== overLight) && glassRef.current) {
|
|
2768
2780
|
const element = glassRef.current, cachedResult = ((parentElement, overLightConfig) => {
|
|
@@ -2862,102 +2874,36 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2862
2874
|
}), 150);
|
|
2863
2875
|
return () => clearTimeout(timeoutId);
|
|
2864
2876
|
}
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
setUserPrefersReducedMotion(mediaQueryReducedMotion.matches), setUserPrefersHighContrast(mediaQueryHighContrast.matches);
|
|
2868
|
-
const handleReducedMotionChange = e => {
|
|
2869
|
-
setUserPrefersReducedMotion(e.matches);
|
|
2870
|
-
}, handleHighContrastChange = e => {
|
|
2871
|
-
setUserPrefersHighContrast(e.matches);
|
|
2872
|
-
};
|
|
2873
|
-
return mediaQueryReducedMotion.addEventListener ? (mediaQueryReducedMotion.addEventListener("change", handleReducedMotionChange),
|
|
2874
|
-
mediaQueryHighContrast.addEventListener("change", handleHighContrastChange)) : mediaQueryReducedMotion.addListener && (mediaQueryReducedMotion.addListener(handleReducedMotionChange),
|
|
2875
|
-
mediaQueryHighContrast.addListener(handleHighContrastChange)), () => {
|
|
2876
|
-
// ignore
|
|
2877
|
-
};
|
|
2878
|
-
} catch (error) {
|
|
2879
|
-
return;
|
|
2880
|
-
}
|
|
2881
|
-
}), [ overLight, glassRef, debugOverLight ]);
|
|
2877
|
+
"boolean" == typeof overLight && setDetectedOverLight(!1);
|
|
2878
|
+
}), [ overLight, glassRef ]);
|
|
2882
2879
|
/**
|
|
2883
2880
|
* Get effective overLight value based on configuration
|
|
2884
2881
|
*/
|
|
2885
|
-
const getEffectiveOverLight = useCallback((() => "boolean" == typeof overLight ? overLight : ("auto" === overLight || "object" == typeof overLight && null !== overLight) && detectedOverLight), [ overLight, detectedOverLight ]), validateConfigValue = useCallback(((value, min, max, defaultValue) => "number" != typeof value || isNaN(value) || !isFinite(value) ? defaultValue : Math.min(max, Math.max(min, value))), []),
|
|
2886
|
-
const isOverLight = getEffectiveOverLight(), baseConfig = {
|
|
2882
|
+
const getEffectiveOverLight = useCallback((() => "boolean" == typeof overLight ? overLight : ("auto" === overLight || "object" == typeof overLight && null !== overLight) && detectedOverLight), [ overLight, detectedOverLight ]), validateConfigValue = useCallback(((value, min, max, defaultValue) => "number" != typeof value || isNaN(value) || !isFinite(value) ? defaultValue : Math.min(max, Math.max(min, value))), []), overLightConfig = useMemo((() => {
|
|
2883
|
+
const isOverLight = getEffectiveOverLight(), hoverIntensity = isHovered ? 1.4 : 1, activeIntensity = isActive ? 1.6 : 1, baseConfig = {
|
|
2887
2884
|
isOverLight: isOverLight,
|
|
2888
2885
|
threshold: .7,
|
|
2889
|
-
opacity: isOverLight ? Math.min(.6, Math.max(.2, .5)) : 0,
|
|
2890
|
-
contrast: 1,
|
|
2891
|
-
|
|
2892
|
-
brightness: 1,
|
|
2893
|
-
// Base brightness
|
|
2886
|
+
opacity: isOverLight ? Math.min(.6, Math.max(.2, .5 * hoverIntensity * activeIntensity)) : 0,
|
|
2887
|
+
contrast: 1.4,
|
|
2888
|
+
brightness: .9,
|
|
2894
2889
|
saturationBoost: 1.3,
|
|
2890
|
+
// Fixed value — dynamic saturation amplifies perceived displacement
|
|
2895
2891
|
shadowIntensity: .9,
|
|
2896
2892
|
borderOpacity: .7
|
|
2897
2893
|
};
|
|
2898
2894
|
if ("object" == typeof overLight && null !== overLight) {
|
|
2899
|
-
const objConfig = overLight, validatedThreshold = validateConfigValue(objConfig.threshold, .1, 1, baseConfig.threshold), validatedOpacity = validateConfigValue(objConfig.opacity, .1, 1, baseConfig.opacity), validatedContrast = validateConfigValue(objConfig.contrast, .5, 2.5, baseConfig.contrast), validatedBrightness = validateConfigValue(objConfig.brightness, .5, 2, baseConfig.brightness), validatedSaturationBoost = validateConfigValue(objConfig.saturationBoost, .5, 3, baseConfig.saturationBoost)
|
|
2900
|
-
return {
|
|
2895
|
+
const objConfig = overLight, validatedThreshold = validateConfigValue(objConfig.threshold, .1, 1, baseConfig.threshold), validatedOpacity = validateConfigValue(objConfig.opacity, .1, 1, baseConfig.opacity), validatedContrast = validateConfigValue(objConfig.contrast, .5, 2.5, baseConfig.contrast), validatedBrightness = validateConfigValue(objConfig.brightness, .5, 2, baseConfig.brightness), validatedSaturationBoost = validateConfigValue(objConfig.saturationBoost, .5, 3, baseConfig.saturationBoost), finalConfig = {
|
|
2901
2896
|
...baseConfig,
|
|
2902
2897
|
threshold: validatedThreshold,
|
|
2903
|
-
opacity: validatedOpacity,
|
|
2898
|
+
opacity: validatedOpacity * hoverIntensity * activeIntensity,
|
|
2904
2899
|
contrast: validatedContrast,
|
|
2905
2900
|
brightness: validatedBrightness,
|
|
2906
2901
|
saturationBoost: validatedSaturationBoost
|
|
2907
2902
|
};
|
|
2903
|
+
return "undefined" == typeof process || process.env, finalConfig;
|
|
2908
2904
|
}
|
|
2909
|
-
return baseConfig;
|
|
2910
|
-
}), [ overLight, getEffectiveOverLight, validateConfigValue ]),
|
|
2911
|
-
const mouseInfluence = calculateMouseInfluence(mouseOffset), hoverIntensity = isHovered ? 1.4 : 1, activeIntensity = isActive ? 1.6 : 1;
|
|
2912
|
-
return {
|
|
2913
|
-
isOverLight: baseOverLightConfig.isOverLight,
|
|
2914
|
-
threshold: baseOverLightConfig.threshold,
|
|
2915
|
-
opacity: baseOverLightConfig.opacity * hoverIntensity * activeIntensity,
|
|
2916
|
-
contrast: Math.min(1.6, baseOverLightConfig.contrast + .1 * mouseInfluence),
|
|
2917
|
-
brightness: Math.min(1.1, baseOverLightConfig.brightness + .05 * mouseInfluence),
|
|
2918
|
-
saturationBoost: baseOverLightConfig.saturationBoost,
|
|
2919
|
-
shadowIntensity: Math.min(1.2, Math.max(.5, baseOverLightConfig.shadowIntensity + .2 * mouseInfluence)),
|
|
2920
|
-
borderOpacity: Math.min(1, Math.max(.3, baseOverLightConfig.borderOpacity + .1 * mouseInfluence))
|
|
2921
|
-
};
|
|
2922
|
-
}), [ baseOverLightConfig, mouseOffset, isHovered, isActive ]), updateRectRef = useRef(null), calculateDirectionalScale = useCallback((() => {
|
|
2923
|
-
if (baseOverLightConfig.isOverLight) return "scale(1)";
|
|
2924
|
-
if (!(globalMousePosition.x && globalMousePosition.y && glassRef.current && validateGlassSize(glassSize))) return "scale(1)";
|
|
2925
|
-
const rect = glassRef.current.getBoundingClientRect(), center = calculateElementCenter(rect), deltaX = globalMousePosition.x - center.x, deltaY = globalMousePosition.y - center.y, edgeDistanceX = Math.max(0, Math.abs(deltaX) - glassSize.width / 2), edgeDistanceY = Math.max(0, Math.abs(deltaY) - glassSize.height / 2), edgeDistance = calculateDistance({
|
|
2926
|
-
x: edgeDistanceX,
|
|
2927
|
-
y: edgeDistanceY
|
|
2928
|
-
}, {
|
|
2929
|
-
x: 0,
|
|
2930
|
-
y: 0
|
|
2931
|
-
});
|
|
2932
|
-
if (edgeDistance > CONSTANTS.ACTIVATION_ZONE) return "scale(1)";
|
|
2933
|
-
const fadeInFactor = 1 - edgeDistance / CONSTANTS.ACTIVATION_ZONE, centerDistance = calculateDistance(globalMousePosition, center);
|
|
2934
|
-
if (0 === centerDistance) return "scale(1)";
|
|
2935
|
-
const normalizedX = deltaX / centerDistance, normalizedY = deltaY / centerDistance, stretchIntensity = Math.min(centerDistance / 300, 1) * elasticity * fadeInFactor, scaleX = 1 + Math.abs(normalizedX) * stretchIntensity * .3 - Math.abs(normalizedY) * stretchIntensity * .15, scaleY = 1 + Math.abs(normalizedY) * stretchIntensity * .3 - Math.abs(normalizedX) * stretchIntensity * .15;
|
|
2936
|
-
return `scaleX(${Math.max(.8, scaleX)}) scaleY(${Math.max(.8, scaleY)})`;
|
|
2937
|
-
}), [ globalMousePosition, elasticity, glassSize, glassRef, baseOverLightConfig ]), calculateFadeInFactor = useCallback((() => {
|
|
2938
|
-
if (!(globalMousePosition.x && globalMousePosition.y && glassRef.current && validateGlassSize(glassSize))) return 0;
|
|
2939
|
-
const rect = glassRef.current.getBoundingClientRect(), center = calculateElementCenter(rect), edgeDistanceX = Math.max(0, Math.abs(globalMousePosition.x - center.x) - glassSize.width / 2), edgeDistanceY = Math.max(0, Math.abs(globalMousePosition.y - center.y) - glassSize.height / 2), edgeDistance = calculateDistance({
|
|
2940
|
-
x: edgeDistanceX,
|
|
2941
|
-
y: edgeDistanceY
|
|
2942
|
-
}, {
|
|
2943
|
-
x: 0,
|
|
2944
|
-
y: 0
|
|
2945
|
-
});
|
|
2946
|
-
return edgeDistance > CONSTANTS.ACTIVATION_ZONE ? 0 : 1 - edgeDistance / CONSTANTS.ACTIVATION_ZONE;
|
|
2947
|
-
}), [ globalMousePosition, glassSize, glassRef ]), calculateElasticTranslation = useCallback((() => {
|
|
2948
|
-
if (!glassRef.current) return {
|
|
2949
|
-
x: 0,
|
|
2950
|
-
y: 0
|
|
2951
|
-
};
|
|
2952
|
-
const fadeInFactor = calculateFadeInFactor(), rect = glassRef.current.getBoundingClientRect(), center = calculateElementCenter(rect);
|
|
2953
|
-
return {
|
|
2954
|
-
x: (globalMousePosition.x - center.x) * elasticity * .1 * fadeInFactor,
|
|
2955
|
-
y: (globalMousePosition.y - center.y) * elasticity * .1 * fadeInFactor
|
|
2956
|
-
};
|
|
2957
|
-
}), [ globalMousePosition, elasticity, calculateFadeInFactor, glassRef ]), elasticTranslation = useMemo((() => effectiveWithoutEffects ? {
|
|
2958
|
-
x: 0,
|
|
2959
|
-
y: 0
|
|
2960
|
-
} : calculateElasticTranslation()), [ calculateElasticTranslation, effectiveWithoutEffects ]), directionalScale = useMemo((() => effectiveWithoutEffects ? "scale(1)" : calculateDirectionalScale()), [ calculateDirectionalScale, effectiveWithoutEffects ]), transformStyle = useMemo((() => effectiveWithoutEffects ? isActive && Boolean(onClick) ? "scale(0.98)" : "scale(1)" : `translate(${elasticTranslation.x}px, ${elasticTranslation.y}px) ${isActive && Boolean(onClick) ? "scale(0.96)" : directionalScale}`), [ elasticTranslation, isActive, onClick, directionalScale, effectiveWithoutEffects ]), handleGlobalMousePosition = useCallback((globalPos => {
|
|
2905
|
+
return "undefined" == typeof process || process.env, baseConfig;
|
|
2906
|
+
}), [ overLight, getEffectiveOverLight, isHovered, isActive, validateConfigValue, debugOverLight ]), transformStyle = useMemo((() => effectiveWithoutEffects || isActive && Boolean(onClick) ? "scale(0.98)" : "scale(1)"), [ effectiveWithoutEffects, isActive, onClick ]), updateRectRef = useRef(null), handleGlobalMousePosition = useCallback((globalPos => {
|
|
2961
2907
|
if (externalGlobalMousePosition && externalMouseOffset) return;
|
|
2962
2908
|
if (effectiveWithoutEffects) return;
|
|
2963
2909
|
const container = mouseContainer?.current || glassRef.current;
|
|
@@ -2966,35 +2912,61 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
2966
2912
|
let rect = cachedRectRef.current;
|
|
2967
2913
|
if (rect && 0 !== rect.width && 0 !== rect.height || (rect = container.getBoundingClientRect(),
|
|
2968
2914
|
cachedRectRef.current = rect), 0 === rect.width || 0 === rect.height) return;
|
|
2969
|
-
const center = calculateElementCenter(rect)
|
|
2915
|
+
const center = calculateElementCenter(rect);
|
|
2916
|
+
// Write raw target — the lerp loop will smoothly pursue it
|
|
2917
|
+
targetMouseOffsetRef.current = {
|
|
2970
2918
|
x: (globalPos.x - center.x) / rect.width * 100,
|
|
2971
2919
|
y: (globalPos.y - center.y) / rect.height * 100
|
|
2920
|
+
}, targetGlobalMousePositionRef.current = globalPos;
|
|
2921
|
+
}), [ mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]), startLerpLoop = useCallback((() => {
|
|
2922
|
+
if (lerpActiveRef.current) return;
|
|
2923
|
+
lerpActiveRef.current = !0;
|
|
2924
|
+
const LERP_T = CONSTANTS.LERP_FACTOR, tick = () => {
|
|
2925
|
+
if (!lerpActiveRef.current) return;
|
|
2926
|
+
const cur = internalMouseOffsetRef.current, tgt = targetMouseOffsetRef.current, dx = tgt.x - cur.x, dy = tgt.y - cur.y;
|
|
2927
|
+
// If we're close enough, snap and park
|
|
2928
|
+
if (Math.abs(dx) < .05 && Math.abs(dy) < .05) internalMouseOffsetRef.current = {
|
|
2929
|
+
...tgt
|
|
2930
|
+
}, internalGlobalMousePositionRef.current = {
|
|
2931
|
+
...targetGlobalMousePositionRef.current
|
|
2932
|
+
}; else {
|
|
2933
|
+
internalMouseOffsetRef.current = {
|
|
2934
|
+
x: lerp(cur.x, tgt.x, LERP_T),
|
|
2935
|
+
y: lerp(cur.y, tgt.y, LERP_T)
|
|
2936
|
+
};
|
|
2937
|
+
const curG = internalGlobalMousePositionRef.current, tgtG = targetGlobalMousePositionRef.current;
|
|
2938
|
+
internalGlobalMousePositionRef.current = {
|
|
2939
|
+
x: lerp(curG.x, tgtG.x, LERP_T),
|
|
2940
|
+
y: lerp(curG.y, tgtG.y, LERP_T)
|
|
2941
|
+
};
|
|
2942
|
+
}
|
|
2943
|
+
// Imperative style update with the smoothed values
|
|
2944
|
+
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
2945
|
+
mouseOffset: internalMouseOffsetRef.current,
|
|
2946
|
+
globalMousePosition: internalGlobalMousePositionRef.current,
|
|
2947
|
+
glassSize: glassSize,
|
|
2948
|
+
isHovered: isHovered,
|
|
2949
|
+
isActive: isActive,
|
|
2950
|
+
isOverLight: overLightConfig.isOverLight,
|
|
2951
|
+
baseOverLightConfig: overLightConfig,
|
|
2952
|
+
effectiveBorderRadius: effectiveBorderRadius,
|
|
2953
|
+
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
2954
|
+
effectiveReducedMotion: effectiveReducedMotion,
|
|
2955
|
+
elasticity: elasticity,
|
|
2956
|
+
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
2957
|
+
onClick: onClick,
|
|
2958
|
+
withLiquidBlur: withLiquidBlur,
|
|
2959
|
+
blurAmount: blurAmount,
|
|
2960
|
+
saturation: saturation,
|
|
2961
|
+
padding: padding
|
|
2962
|
+
}), lerpRafRef.current = requestAnimationFrame(tick);
|
|
2972
2963
|
};
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
globalMousePosition: globalPos,
|
|
2980
|
-
glassSize: glassSize,
|
|
2981
|
-
isHovered: isHovered,
|
|
2982
|
-
isActive: isActive,
|
|
2983
|
-
isOverLight: baseOverLightConfig.isOverLight,
|
|
2984
|
-
baseOverLightConfig: baseOverLightConfig,
|
|
2985
|
-
effectiveBorderRadius: effectiveBorderRadius,
|
|
2986
|
-
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
2987
|
-
effectiveReducedMotion: effectiveReducedMotion,
|
|
2988
|
-
elasticity: elasticity,
|
|
2989
|
-
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
2990
|
-
// Simplified directional scale for fast path
|
|
2991
|
-
onClick: onClick,
|
|
2992
|
-
withLiquidBlur: withLiquidBlur,
|
|
2993
|
-
blurAmount: blurAmount,
|
|
2994
|
-
saturation: saturation,
|
|
2995
|
-
padding: padding
|
|
2996
|
-
});
|
|
2997
|
-
}), [ mouseContainer, glassRef, wrapperRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects, glassSize, isHovered, isActive, baseOverLightConfig, effectiveBorderRadius, effectiveReducedMotion, elasticity, onClick, withLiquidBlur, blurAmount, saturation, padding ]);
|
|
2964
|
+
// 0.08 – lower = more viscous
|
|
2965
|
+
lerpRafRef.current = requestAnimationFrame(tick);
|
|
2966
|
+
}), [ glassRef, wrapperRef, glassSize, isHovered, isActive, overLightConfig, effectiveBorderRadius, effectiveWithoutEffects, effectiveReducedMotion, elasticity, onClick, withLiquidBlur, blurAmount, saturation, padding ]), stopLerpLoop = useCallback((() => {
|
|
2967
|
+
lerpActiveRef.current = !1, null !== lerpRafRef.current && (cancelAnimationFrame(lerpRafRef.current),
|
|
2968
|
+
lerpRafRef.current = null);
|
|
2969
|
+
}), []);
|
|
2998
2970
|
/**
|
|
2999
2971
|
* Validate and clamp a numeric config value
|
|
3000
2972
|
*/
|
|
@@ -3002,7 +2974,10 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
3002
2974
|
useEffect((() => {
|
|
3003
2975
|
if (externalGlobalMousePosition && externalMouseOffset) return;
|
|
3004
2976
|
if (effectiveWithoutEffects) return;
|
|
3005
|
-
const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition)
|
|
2977
|
+
const unsubscribe = globalMouseTracker.subscribe(handleGlobalMousePosition);
|
|
2978
|
+
// Start the lerp loop — it will smoothly chase the target
|
|
2979
|
+
startLerpLoop();
|
|
2980
|
+
const container = mouseContainer?.current || glassRef.current;
|
|
3006
2981
|
let resizeObserver = null;
|
|
3007
2982
|
return container && "undefined" != typeof ResizeObserver && (resizeObserver = new ResizeObserver((() => {
|
|
3008
2983
|
null !== updateRectRef.current && cancelAnimationFrame(updateRectRef.current), updateRectRef.current = requestAnimationFrame((() => {
|
|
@@ -3010,10 +2985,10 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
3010
2985
|
container && (cachedRectRef.current = container.getBoundingClientRect()), updateRectRef.current = null;
|
|
3011
2986
|
}));
|
|
3012
2987
|
})), resizeObserver.observe(container)), () => {
|
|
3013
|
-
unsubscribe(), null !== updateRectRef.current && (cancelAnimationFrame(updateRectRef.current),
|
|
2988
|
+
unsubscribe(), stopLerpLoop(), null !== updateRectRef.current && (cancelAnimationFrame(updateRectRef.current),
|
|
3014
2989
|
updateRectRef.current = null), resizeObserver && resizeObserver.disconnect();
|
|
3015
2990
|
};
|
|
3016
|
-
}), [ handleGlobalMousePosition, mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]),
|
|
2991
|
+
}), [ handleGlobalMousePosition, startLerpLoop, stopLerpLoop, mouseContainer, glassRef, externalGlobalMousePosition, externalMouseOffset, effectiveWithoutEffects ]),
|
|
3017
2992
|
// Also call updateStyles on other state changes (hover, active, etc)
|
|
3018
2993
|
useEffect((() => {
|
|
3019
2994
|
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
@@ -3022,22 +2997,22 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
3022
2997
|
glassSize: glassSize,
|
|
3023
2998
|
isHovered: isHovered,
|
|
3024
2999
|
isActive: isActive,
|
|
3025
|
-
isOverLight:
|
|
3026
|
-
baseOverLightConfig:
|
|
3000
|
+
isOverLight: overLightConfig.isOverLight,
|
|
3001
|
+
baseOverLightConfig: overLightConfig,
|
|
3027
3002
|
effectiveBorderRadius: effectiveBorderRadius,
|
|
3028
3003
|
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
3029
3004
|
effectiveReducedMotion: effectiveReducedMotion,
|
|
3030
3005
|
elasticity: elasticity,
|
|
3031
|
-
directionalScale:
|
|
3006
|
+
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
3032
3007
|
onClick: onClick,
|
|
3033
3008
|
withLiquidBlur: withLiquidBlur,
|
|
3034
3009
|
blurAmount: blurAmount,
|
|
3035
3010
|
saturation: saturation,
|
|
3036
3011
|
padding: padding
|
|
3037
3012
|
});
|
|
3038
|
-
}), [ isHovered, isActive, glassSize,
|
|
3013
|
+
}), [ isHovered, isActive, glassSize, overLightConfig, effectiveBorderRadius, effectiveWithoutEffects, effectiveReducedMotion, elasticity, wrapperRef, glassRef, externalMouseOffset, externalGlobalMousePosition, withLiquidBlur, blurAmount, saturation, padding, onClick ]);
|
|
3039
3014
|
// Event handlers
|
|
3040
|
-
const handleMouseEnter = useCallback((() => setIsHovered(!0)), []), handleMouseLeave = useCallback((() => setIsHovered(!1)), []), handleMouseDown = useCallback((() => setIsActive(!0)), []), handleMouseUp = useCallback((() => setIsActive(!1)), []),
|
|
3015
|
+
const handleMouseEnter = useCallback((() => setIsHovered(!0)), []), handleMouseLeave = useCallback((() => setIsHovered(!1)), []), handleMouseDown = useCallback((() => setIsActive(!0)), []), handleMouseUp = useCallback((() => setIsActive(!1)), []), handleKeyDown = useCallback((e => {
|
|
3041
3016
|
!onClick || "Enter" !== e.key && " " !== e.key || (e.preventDefault(), onClick());
|
|
3042
3017
|
}), [ onClick ]);
|
|
3043
3018
|
return {
|
|
@@ -3055,14 +3030,11 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
3055
3030
|
mouseOffset: mouseOffset,
|
|
3056
3031
|
// This is now static (refs or props) unless prop changes
|
|
3057
3032
|
overLightConfig: overLightConfig,
|
|
3058
|
-
elasticTranslation: elasticTranslation,
|
|
3059
|
-
directionalScale: directionalScale,
|
|
3060
3033
|
transformStyle: transformStyle,
|
|
3061
3034
|
handleMouseEnter: handleMouseEnter,
|
|
3062
3035
|
handleMouseLeave: handleMouseLeave,
|
|
3063
3036
|
handleMouseDown: handleMouseDown,
|
|
3064
3037
|
handleMouseUp: handleMouseUp,
|
|
3065
|
-
handleMouseMove: handleMouseMove,
|
|
3066
3038
|
handleKeyDown: handleKeyDown
|
|
3067
3039
|
};
|
|
3068
3040
|
}
|
|
@@ -3160,25 +3132,56 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
3160
3132
|
withLiquidBlur: withLiquidBlur,
|
|
3161
3133
|
padding: padding,
|
|
3162
3134
|
style: style
|
|
3163
|
-
}), isOverLight = useMemo((() => overLightConfig
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3135
|
+
}), isOverLight = useMemo((() => overLightConfig.isOverLight), [ overLightConfig.isOverLight ]), shouldRenderOverLightLayers = withOverLightLayers && isOverLight, {zIndex: customZIndex, ...restStyle} = style, isFixedOrSticky = "fixed" === restStyle.position || "sticky" === restStyle.position, rootLayoutStyle = useMemo((() => {
|
|
3136
|
+
if (!isFixedOrSticky) return {};
|
|
3137
|
+
const {position: p, top: t, left: l, right: r, bottom: b} = restStyle;
|
|
3138
|
+
return {
|
|
3139
|
+
...p && {
|
|
3140
|
+
position: p
|
|
3141
|
+
},
|
|
3142
|
+
...void 0 !== t && {
|
|
3143
|
+
top: t
|
|
3144
|
+
},
|
|
3145
|
+
...void 0 !== l && {
|
|
3146
|
+
left: l
|
|
3147
|
+
},
|
|
3148
|
+
...void 0 !== r && {
|
|
3149
|
+
right: r
|
|
3150
|
+
},
|
|
3151
|
+
...void 0 !== b && {
|
|
3152
|
+
bottom: b
|
|
3153
|
+
}
|
|
3154
|
+
};
|
|
3155
|
+
}), [ isFixedOrSticky, restStyle ]), baseStyle = useMemo((() => {
|
|
3156
|
+
if (isFixedOrSticky) {
|
|
3157
|
+
const {position: _p, top: _t, left: _l, right: _r, bottom: _b, ...visualStyle} = restStyle;
|
|
3158
|
+
return {
|
|
3159
|
+
...visualStyle,
|
|
3160
|
+
...!effectiveWithoutEffects && {
|
|
3161
|
+
transform: transformStyle
|
|
3162
|
+
}
|
|
3163
|
+
};
|
|
3167
3164
|
}
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3165
|
+
return {
|
|
3166
|
+
...restStyle,
|
|
3167
|
+
...!effectiveWithoutEffects && {
|
|
3168
|
+
transform: transformStyle
|
|
3169
|
+
}
|
|
3170
|
+
};
|
|
3171
|
+
}), [ isFixedOrSticky, restStyle, effectiveWithoutEffects, transformStyle ]), componentClassName = [ ATOMIX_GLASS.BASE_CLASS, effectiveReducedMotion && `${ATOMIX_GLASS.BASE_CLASS}--reduced-motion`, effectiveHighContrast && `${ATOMIX_GLASS.BASE_CLASS}--high-contrast`, effectiveWithoutEffects && `${ATOMIX_GLASS.BASE_CLASS}--disabled-effects`, className ].filter(Boolean).join(" "), positionStyles = useMemo((() => ({
|
|
3172
|
+
position: isFixedOrSticky ? "absolute" : restStyle.position || "absolute",
|
|
3173
|
+
top: isFixedOrSticky ? 0 : restStyle.top || 0,
|
|
3174
|
+
left: isFixedOrSticky ? 0 : restStyle.left || 0
|
|
3175
|
+
})), [ isFixedOrSticky, restStyle.position, restStyle.top, restStyle.left ]), adjustedSize = useMemo((() => {
|
|
3173
3176
|
const resolveSize = (propValue, styleValue, measuredSize) => {
|
|
3174
3177
|
const explicitSize = propValue ?? styleValue;
|
|
3175
3178
|
return void 0 !== explicitSize ? "number" == typeof explicitSize ? `${explicitSize}px` : explicitSize : "fixed" === positionStyles.position ? `${Math.max(measuredSize, 0)}px` : "100%";
|
|
3176
3179
|
};
|
|
3177
3180
|
return {
|
|
3178
|
-
width: resolveSize(width,
|
|
3179
|
-
height: resolveSize(height,
|
|
3181
|
+
width: resolveSize(width, restStyle.width, glassSize.width),
|
|
3182
|
+
height: resolveSize(height, restStyle.height, glassSize.height)
|
|
3180
3183
|
};
|
|
3181
|
-
}), [ width, height,
|
|
3184
|
+
}), [ width, height, restStyle.width, restStyle.height, positionStyles.position, glassSize.width, glassSize.height ]), gradientValues = useMemo((() => {
|
|
3182
3185
|
const mx = mouseOffset.x, my = mouseOffset.y, absMx = Math.abs(mx), absMy = Math.abs(my), GRADIENT = ATOMIX_GLASS.CONSTANTS.GRADIENT;
|
|
3183
3186
|
return {
|
|
3184
3187
|
borderGradientAngle: GRADIENT.BASE_ANGLE + mx * GRADIENT.ANGLE_MULTIPLIER,
|
|
@@ -3220,6 +3223,9 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
3220
3223
|
}), [ isHovered, isActive, isOverLight, overLightConfig.opacity ]), glassVars = useMemo((() => {
|
|
3221
3224
|
const whiteColor = ATOMIX_GLASS.CONSTANTS.PALETTE.WHITE, blackColor = ATOMIX_GLASS.CONSTANTS.PALETTE.BLACK, {borderGradientAngle: borderGradientAngle, borderStop1: borderStop1, borderStop2: borderStop2, borderOpacities: borderOpacities, hoverPositions: hoverPositions, basePosition: basePosition, mx: mx, my: my, absMx: absMx, absMy: absMy} = gradientValues, configBorderOpacity = overLightConfig?.borderOpacity ?? 1;
|
|
3222
3225
|
return {
|
|
3226
|
+
...void 0 !== customZIndex && {
|
|
3227
|
+
"--atomix-glass-base-z-index": customZIndex
|
|
3228
|
+
},
|
|
3223
3229
|
"--atomix-glass-radius": `${effectiveBorderRadius}px`,
|
|
3224
3230
|
"--atomix-glass-transform": transformStyle || "none",
|
|
3225
3231
|
"--atomix-glass-position": positionStyles.position,
|
|
@@ -3240,22 +3246,19 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
3240
3246
|
"--atomix-glass-base-opacity": opacityValues.base,
|
|
3241
3247
|
"--atomix-glass-base-gradient": isOverLight ? `linear-gradient(${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.ANGLE}deg, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_START_BASE + mx * ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_START_MULTIPLIER}) 0%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_MID_BASE + my * ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_MID_MULTIPLIER}) ${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_MID_STOP}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_END_BASE + absMx * ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.BLACK_END_MULTIPLIER}) 100%)` : `rgba(${whiteColor}, ${ATOMIX_GLASS.CONSTANTS.BASE_GRADIENT.WHITE_OPACITY})`,
|
|
3242
3248
|
"--atomix-glass-overlay-opacity": opacityValues.over,
|
|
3243
|
-
"--atomix-glass-overlay-gradient": isOverLight ? `radial-gradient(circle at ${basePosition.x}% ${basePosition.y}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_START_BASE + absMx * ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_START_MULTIPLIER}) 0%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_MID}) ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_MID_STOP}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_END_BASE + absMy * ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_END_MULTIPLIER}) 100%)` : `rgba(${whiteColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.WHITE_OPACITY})
|
|
3249
|
+
"--atomix-glass-overlay-gradient": isOverLight ? `radial-gradient(circle at ${basePosition.x}% ${basePosition.y}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_START_BASE + absMx * ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_START_MULTIPLIER}) 0%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_MID}) ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_MID_STOP}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_END_BASE + absMy * ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.BLACK_END_MULTIPLIER}) 100%)` : `rgba(${whiteColor}, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_GRADIENT.WHITE_OPACITY})`,
|
|
3250
|
+
"--atomix-glass-overlay-highlight-opacity": opacityValues.over * ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.OPACITY_MULTIPLIER,
|
|
3251
|
+
"--atomix-glass-overlay-highlight-bg": `radial-gradient(circle at ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.POSITION_X}% ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.POSITION_Y}%, rgba(255, 255, 255, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.WHITE_OPACITY}) 0%, transparent ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.STOP}%)`
|
|
3244
3252
|
};
|
|
3245
|
-
}), [ gradientValues, opacityValues, effectiveBorderRadius, transformStyle, positionStyles, adjustedSize, isOverLight, overLightConfig.borderOpacity ]), renderBackgroundLayer = layerType => jsx("div", {
|
|
3246
|
-
className: [ ATOMIX_GLASS.BACKGROUND_LAYER_CLASS, "dark" === layerType ? ATOMIX_GLASS.BACKGROUND_LAYER_DARK_CLASS : ATOMIX_GLASS.BACKGROUND_LAYER_BLACK_CLASS, isOverLight ? ATOMIX_GLASS.BACKGROUND_LAYER_OVER_LIGHT_CLASS : ATOMIX_GLASS.BACKGROUND_LAYER_HIDDEN_CLASS ].filter(Boolean).join(" ")
|
|
3247
|
-
style: {
|
|
3248
|
-
...positionStyles,
|
|
3249
|
-
height: adjustedSize.height,
|
|
3250
|
-
width: adjustedSize.width,
|
|
3251
|
-
borderRadius: `${effectiveBorderRadius}px`,
|
|
3252
|
-
transform: baseStyle.transform
|
|
3253
|
-
}
|
|
3253
|
+
}), [ gradientValues, opacityValues, effectiveBorderRadius, transformStyle, positionStyles, adjustedSize, isOverLight, overLightConfig.borderOpacity, customZIndex ]), renderBackgroundLayer = layerType => jsx("div", {
|
|
3254
|
+
className: [ ATOMIX_GLASS.BACKGROUND_LAYER_CLASS, "dark" === layerType ? ATOMIX_GLASS.BACKGROUND_LAYER_DARK_CLASS : ATOMIX_GLASS.BACKGROUND_LAYER_BLACK_CLASS, isOverLight ? ATOMIX_GLASS.BACKGROUND_LAYER_OVER_LIGHT_CLASS : ATOMIX_GLASS.BACKGROUND_LAYER_HIDDEN_CLASS ].filter(Boolean).join(" ")
|
|
3254
3255
|
});
|
|
3255
3256
|
return jsxs("div", {
|
|
3256
3257
|
...rest,
|
|
3257
3258
|
className: componentClassName,
|
|
3258
|
-
style:
|
|
3259
|
+
style: {
|
|
3260
|
+
...glassVars
|
|
3261
|
+
},
|
|
3259
3262
|
role: role || (onClick ? "button" : void 0),
|
|
3260
3263
|
tabIndex: onClick ? tabIndex ?? 0 : tabIndex,
|
|
3261
3264
|
"aria-label": ariaLabel,
|
|
@@ -3267,7 +3270,7 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
3267
3270
|
ref: glassRef,
|
|
3268
3271
|
contentRef: contentRef,
|
|
3269
3272
|
className: className,
|
|
3270
|
-
style:
|
|
3273
|
+
style: rootLayoutStyle,
|
|
3271
3274
|
borderRadius: effectiveBorderRadius,
|
|
3272
3275
|
displacementScale: effectiveWithoutEffects ? 0 : "shader" === mode ? displacementScale * ATOMIX_GLASS.CONSTANTS.MULTIPLIERS.SHADER_DISPLACEMENT : isOverLight ? displacementScale * ATOMIX_GLASS.CONSTANTS.MULTIPLIERS.OVER_LIGHT_DISPLACEMENT : displacementScale,
|
|
3273
3276
|
blurAmount: effectiveWithoutEffects ? 0 : blurAmount,
|
|
@@ -3318,11 +3321,7 @@ function useAtomixGlass({glassRef: glassRef, contentRef: contentRef, wrapperRef:
|
|
|
3318
3321
|
}), jsx("div", {
|
|
3319
3322
|
className: ATOMIX_GLASS.OVERLAY_LAYER_CLASS
|
|
3320
3323
|
}), jsx("div", {
|
|
3321
|
-
className: ATOMIX_GLASS.OVERLAY_HIGHLIGHT_CLASS
|
|
3322
|
-
style: {
|
|
3323
|
-
opacity: opacityValues.over * ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.OPACITY_MULTIPLIER,
|
|
3324
|
-
background: `radial-gradient(circle at ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.POSITION_X}% ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.POSITION_Y}%, rgba(255, 255, 255, ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.WHITE_OPACITY}) 0%, transparent ${ATOMIX_GLASS.CONSTANTS.OVERLAY_HIGHLIGHT.STOP}%)`
|
|
3325
|
-
}
|
|
3324
|
+
className: ATOMIX_GLASS.OVERLAY_HIGHLIGHT_CLASS
|
|
3326
3325
|
}) ]
|
|
3327
3326
|
}), withBorder && jsxs(Fragment, {
|
|
3328
3327
|
children: [ jsx("span", {
|
|
@@ -5392,7 +5391,7 @@ function getDatasetBounds(data) {
|
|
|
5392
5391
|
pan: !0,
|
|
5393
5392
|
reset: !0
|
|
5394
5393
|
}, exportFormats: exportFormats = [ "png", "svg", "csv" ], size: size = "md", position: position = "top", onRefresh: onRefresh, onExport: onExport, onFullscreen: onFullscreen, onSettings: onSettings, onZoomIn: onZoomIn, onZoomOut: onZoomOut, onZoomReset: onZoomReset, onPanToggle: onPanToggle, onReset: onReset, onGridToggle: onGridToggle, onLegendToggle: onLegendToggle, onTooltipsToggle: onTooltipsToggle, onAnimationsToggle: onAnimationsToggle, state: state = {}, className: className = "", ...props}, ref) => {
|
|
5395
|
-
const [showExportMenu, setShowExportMenu] = useState(!1), [showSettingsMenu, setShowSettingsMenu] = useState(!1), exportMenuRef = useRef(null), settingsMenuRef = useRef(null), exportButtonRef = useRef(null), settingsButtonRef = useRef(null), effectiveDefaults = groups && groups.length > 0 ? {
|
|
5394
|
+
const [showExportMenu, setShowExportMenu] = useState(!1), [showSettingsMenu, setShowSettingsMenu] = useState(!1), exportMenuRef = useRef(null), settingsMenuRef = useRef(null), exportButtonRef = useRef(null), settingsButtonRef = useRef(null), effectiveDefaults = useMemo((() => groups && groups.length > 0 ? {
|
|
5396
5395
|
refresh: defaults.refresh ?? !0,
|
|
5397
5396
|
export: defaults.export ?? !0,
|
|
5398
5397
|
fullscreen: defaults.fullscreen ?? !0,
|
|
@@ -5404,7 +5403,7 @@ function getDatasetBounds(data) {
|
|
|
5404
5403
|
legend: defaults.legend ?? !0,
|
|
5405
5404
|
tooltips: defaults.tooltips ?? !0,
|
|
5406
5405
|
animations: defaults.animations ?? !0
|
|
5407
|
-
} : defaults;
|
|
5406
|
+
} : defaults), [ groups, defaults ]);
|
|
5408
5407
|
// Close menus when clicking outside
|
|
5409
5408
|
useEffect((() => {
|
|
5410
5409
|
const handleClickOutside = event => {
|
|
@@ -6854,120 +6853,6 @@ const BaseChart = memo( forwardRef((({type: type, datasets: datasets = [], conf
|
|
|
6854
6853
|
|
|
6855
6854
|
BaseChart.displayName = "BaseChart";
|
|
6856
6855
|
|
|
6857
|
-
const AnimatedChart = memo( forwardRef((({datasets: datasets = [], config: config = {}, chartType: chartType = "line", particleEffects: particleEffects, onDataPointClick: onDataPointClick, ...props}, ref) => {
|
|
6858
|
-
const animationRef = useRef(0), timeRef = useRef(0), particlesRef = useRef([]);
|
|
6859
|
-
// Animation time tracking - moved outside callback
|
|
6860
|
-
useEffect((() => {
|
|
6861
|
-
const animateFrame = timestamp => {
|
|
6862
|
-
timeRef.current = timestamp, animationRef.current = requestAnimationFrame(animateFrame);
|
|
6863
|
-
};
|
|
6864
|
-
return animationRef.current = requestAnimationFrame(animateFrame), () => {
|
|
6865
|
-
animationRef.current && cancelAnimationFrame(animationRef.current);
|
|
6866
|
-
};
|
|
6867
|
-
}), []);
|
|
6868
|
-
const renderContent = useCallback((({scales: scales, colors: colors, datasets: chartDatasets, handlers: handlers, hoveredPoint: hoveredPoint, toolbarState: toolbarState, config: renderConfig}) => {
|
|
6869
|
-
if (!chartDatasets.length) return null;
|
|
6870
|
-
const chartWidth = scales.width - 80, chartHeight = scales.height - 80, elements = [];
|
|
6871
|
-
// Particle effects
|
|
6872
|
-
if (chartDatasets.forEach(((dataset, datasetIndex) => {
|
|
6873
|
-
const color = dataset.color || colors[datasetIndex % colors.length];
|
|
6874
|
-
switch (chartType) {
|
|
6875
|
-
case "bar":
|
|
6876
|
-
// Create animated bars
|
|
6877
|
-
dataset.data.forEach(((point, pointIndex) => {
|
|
6878
|
-
const barWidth = chartWidth / dataset.data.length * .8, x = 40 + pointIndex * (chartWidth / dataset.data.length) + (chartWidth / dataset.data.length - barWidth) / 2, height = point.value / 100 * chartHeight, y = 40 + chartHeight - height;
|
|
6879
|
-
elements.push(jsx("rect", {
|
|
6880
|
-
x: x,
|
|
6881
|
-
y: y,
|
|
6882
|
-
width: barWidth,
|
|
6883
|
-
height: height,
|
|
6884
|
-
fill: color,
|
|
6885
|
-
style: {
|
|
6886
|
-
transform: `scaleY(${.1 * Math.sin(.01 * timeRef.current + .2 * pointIndex) + .9})`,
|
|
6887
|
-
transformOrigin: "bottom"
|
|
6888
|
-
},
|
|
6889
|
-
onClick: () => handlers.onDataPointClick?.(point, datasetIndex, pointIndex)
|
|
6890
|
-
}, `bar-${datasetIndex}-${pointIndex}`));
|
|
6891
|
-
}));
|
|
6892
|
-
break;
|
|
6893
|
-
|
|
6894
|
-
default:
|
|
6895
|
-
{
|
|
6896
|
-
// Create animated line/area
|
|
6897
|
-
const points = dataset.data.map(((point, pointIndex) => ({
|
|
6898
|
-
x: 40 + pointIndex / (dataset.data.length - 1) * chartWidth,
|
|
6899
|
-
y: 40 + chartHeight - point.value / 100 * chartHeight
|
|
6900
|
-
})));
|
|
6901
|
-
if (points.length > 0) {
|
|
6902
|
-
const linePath = `M ${points.map((p => `${p.x},${p.y}`)).join(" L ")}`;
|
|
6903
|
-
// Area for area chart
|
|
6904
|
-
if ("area" === chartType) {
|
|
6905
|
-
const areaPath = `${linePath} L ${40 + chartWidth},${40 + chartHeight} L 40,${40 + chartHeight} Z`;
|
|
6906
|
-
elements.push(jsx("path", {
|
|
6907
|
-
d: areaPath,
|
|
6908
|
-
fill: color,
|
|
6909
|
-
fillOpacity: "0.3",
|
|
6910
|
-
style: {
|
|
6911
|
-
transform: `translateY(${2 * Math.sin(.01 * timeRef.current)}px)`
|
|
6912
|
-
}
|
|
6913
|
-
}, `area-${datasetIndex}`));
|
|
6914
|
-
}
|
|
6915
|
-
// Line
|
|
6916
|
-
elements.push(jsx("path", {
|
|
6917
|
-
d: linePath,
|
|
6918
|
-
stroke: color,
|
|
6919
|
-
fill: "none",
|
|
6920
|
-
className: "c-chart__data-line",
|
|
6921
|
-
style: {
|
|
6922
|
-
transform: `translateY(${2 * Math.sin(.01 * timeRef.current)}px)`
|
|
6923
|
-
}
|
|
6924
|
-
}, `line-${datasetIndex}`)),
|
|
6925
|
-
// Data points
|
|
6926
|
-
points.forEach(((point, pointIndex) => {
|
|
6927
|
-
elements.push(jsx("circle", {
|
|
6928
|
-
cx: point.x,
|
|
6929
|
-
cy: point.y,
|
|
6930
|
-
r: "4",
|
|
6931
|
-
fill: color,
|
|
6932
|
-
style: {
|
|
6933
|
-
transform: `scale(${1 + .2 * Math.sin(.01 * timeRef.current + pointIndex)})`
|
|
6934
|
-
},
|
|
6935
|
-
onClick: () => handlers.onDataPointClick?.(dataset.data[pointIndex], datasetIndex, pointIndex)
|
|
6936
|
-
}, `point-${datasetIndex}-${pointIndex}`));
|
|
6937
|
-
}));
|
|
6938
|
-
}
|
|
6939
|
-
break;
|
|
6940
|
-
}
|
|
6941
|
-
}
|
|
6942
|
-
})), particleEffects?.enabled) for (let i = 0; i < particleEffects.count; i++) {
|
|
6943
|
-
const particle = particlesRef.current[i];
|
|
6944
|
-
particle && elements.push(jsx("circle", {
|
|
6945
|
-
cx: particle.x,
|
|
6946
|
-
cy: particle.y,
|
|
6947
|
-
r: particle.size,
|
|
6948
|
-
fill: particle.color,
|
|
6949
|
-
style: {
|
|
6950
|
-
opacity: particle.life
|
|
6951
|
-
}
|
|
6952
|
-
}, `particle-${i}`));
|
|
6953
|
-
}
|
|
6954
|
-
return jsx("g", {
|
|
6955
|
-
children: elements
|
|
6956
|
-
});
|
|
6957
|
-
}), [ chartType, particleEffects ]);
|
|
6958
|
-
return jsx(BaseChart, {
|
|
6959
|
-
ref: ref,
|
|
6960
|
-
type: "line",
|
|
6961
|
-
datasets: datasets,
|
|
6962
|
-
config: config,
|
|
6963
|
-
renderContent: renderContent,
|
|
6964
|
-
onDataPointClick: onDataPointClick,
|
|
6965
|
-
...props
|
|
6966
|
-
});
|
|
6967
|
-
})));
|
|
6968
|
-
|
|
6969
|
-
AnimatedChart.displayName = "AnimatedChart";
|
|
6970
|
-
|
|
6971
6856
|
const ChartTooltip = memo((({dataPoint: dataPoint, datasetLabel: datasetLabel, datasetColor: datasetColor, position: position, visible: visible, customRenderer: customRenderer}) => {
|
|
6972
6857
|
const tooltipRef = useRef(null), [adjustedPosition, setAdjustedPosition] = useState(position);
|
|
6973
6858
|
// Dynamic positioning to keep tooltip in viewport
|
|
@@ -6989,15 +6874,16 @@ const ChartTooltip = memo((({dataPoint: dataPoint, datasetLabel: datasetLabel,
|
|
|
6989
6874
|
ref: tooltipRef,
|
|
6990
6875
|
className: "c-chart__tooltip",
|
|
6991
6876
|
style: {
|
|
6992
|
-
|
|
6993
|
-
top: `${adjustedPosition.y}px`,
|
|
6877
|
+
transform: `translate3d(${adjustedPosition.x}px, ${adjustedPosition.y}px, 0)`,
|
|
6994
6878
|
opacity: visible ? 1 : 0,
|
|
6995
6879
|
visibility: visible ? "visible" : "hidden",
|
|
6996
|
-
transition: "opacity 0.2s ease
|
|
6997
|
-
transform: "translateZ(0)",
|
|
6880
|
+
transition: "opacity 0.2s ease",
|
|
6998
6881
|
position: "fixed",
|
|
6882
|
+
left: 0,
|
|
6883
|
+
top: 0,
|
|
6999
6884
|
zIndex: 1e3,
|
|
7000
|
-
pointerEvents: "none"
|
|
6885
|
+
pointerEvents: "none",
|
|
6886
|
+
willChange: "transform"
|
|
7001
6887
|
},
|
|
7002
6888
|
children: customRenderer ? customRenderer(dataPoint) : jsxs(Fragment, {
|
|
7003
6889
|
children: [ jsx("div", {
|
|
@@ -7316,8 +7202,9 @@ const BubbleChart = memo( forwardRef((({bubbleData: bubbleData = [], config: co
|
|
|
7316
7202
|
if (!bubbleData.length) return null;
|
|
7317
7203
|
const showTooltips = toolbarState?.showTooltips ?? renderConfig?.showTooltips ?? !0, sizeValues = bubbleData.map((b => b.size)), minSize = Math.min(...sizeValues), sizeRange = Math.max(...sizeValues) - minSize || 1, bubbles = bubbleData.map(((bubble, index) => {
|
|
7318
7204
|
// Calculate scaled size
|
|
7319
|
-
const scaledSize = minBubbleSize + (bubble.size - minSize) / sizeRange * (maxBubbleSize - minBubbleSize), x = scales.padding.left + bubble.x / 100 *
|
|
7205
|
+
const scaledSize = minBubbleSize + (bubble.size - minSize) / sizeRange * (maxBubbleSize - minBubbleSize), effectiveWidth = scales.innerWidth - 2 * maxBubbleSize, effectiveHeight = scales.innerHeight - 2 * maxBubbleSize, x = scales.padding.left + maxBubbleSize + bubble.x / 100 * effectiveWidth, y = scales.padding.top + maxBubbleSize + effectiveHeight - bubble.y / 100 * effectiveHeight;
|
|
7320
7206
|
// Calculate position
|
|
7207
|
+
// Ensure bubbles don't get cut off by adding padding equal to maxBubbleSize
|
|
7321
7208
|
// Determine color
|
|
7322
7209
|
let bubbleColor = bubble.color;
|
|
7323
7210
|
if (!bubbleColor) if (sizeBasedColoring) {
|
|
@@ -7778,9 +7665,10 @@ const GaugeChart = memo( forwardRef((({value: value, min: min = 0, max: max = 1
|
|
|
7778
7665
|
// Create ticks
|
|
7779
7666
|
const ticks = [];
|
|
7780
7667
|
if (showTicks) {
|
|
7668
|
+
const innerRadius = radius * (1 - thickness);
|
|
7781
7669
|
// Major ticks
|
|
7782
|
-
|
|
7783
|
-
const tickValue = min + i / majorTicks * (max - min), tickAngle = startAngleRad + i / majorTicks * angleRange, tickRadius =
|
|
7670
|
+
for (let i = 0; i <= majorTicks; i++) {
|
|
7671
|
+
const tickValue = min + i / majorTicks * (max - min), tickAngle = startAngleRad + i / majorTicks * angleRange, tickRadius = innerRadius - 2, tickLength = .05 * radius, x1 = centerX + tickRadius * Math.cos(tickAngle), y1 = centerY + tickRadius * Math.sin(tickAngle), x2 = centerX + (tickRadius - tickLength) * Math.cos(tickAngle), y2 = centerY + (tickRadius - tickLength) * Math.sin(tickAngle);
|
|
7784
7672
|
// Labels for major ticks
|
|
7785
7673
|
if (ticks.push(jsx("line", {
|
|
7786
7674
|
x1: x1,
|
|
@@ -7790,12 +7678,12 @@ const GaugeChart = memo( forwardRef((({value: value, min: min = 0, max: max = 1
|
|
|
7790
7678
|
stroke: "var(--atomix-brand-border-subtle)",
|
|
7791
7679
|
strokeWidth: "2"
|
|
7792
7680
|
}, `major-tick-${i}`)), showMinMaxLabels) {
|
|
7793
|
-
const
|
|
7681
|
+
const labelRadius = tickRadius - tickLength - 15, labelX = centerX + labelRadius * Math.cos(tickAngle), labelY = centerY + labelRadius * Math.sin(tickAngle);
|
|
7794
7682
|
ticks.push(jsx("text", {
|
|
7795
7683
|
x: labelX,
|
|
7796
7684
|
y: labelY,
|
|
7797
7685
|
textAnchor: "middle",
|
|
7798
|
-
dominantBaseline: "
|
|
7686
|
+
dominantBaseline: "central",
|
|
7799
7687
|
fontSize: "12",
|
|
7800
7688
|
fill: "var(--atomix-brand-text-emphasis)",
|
|
7801
7689
|
children: tickValue
|
|
@@ -7803,8 +7691,9 @@ const GaugeChart = memo( forwardRef((({value: value, min: min = 0, max: max = 1
|
|
|
7803
7691
|
}
|
|
7804
7692
|
}
|
|
7805
7693
|
// Minor ticks
|
|
7806
|
-
for (let i = 0; i
|
|
7807
|
-
|
|
7694
|
+
for (let i = 0; i <= majorTicks * minorTicks; i++) {
|
|
7695
|
+
if (i % minorTicks == 0) continue;
|
|
7696
|
+
const tickAngle = startAngleRad + i / (majorTicks * minorTicks) * angleRange, tickRadius = innerRadius - 2, tickLength = .025 * radius, x1 = centerX + tickRadius * Math.cos(tickAngle), y1 = centerY + tickRadius * Math.sin(tickAngle), x2 = centerX + (tickRadius - tickLength) * Math.cos(tickAngle), y2 = centerY + (tickRadius - tickLength) * Math.sin(tickAngle);
|
|
7808
7697
|
ticks.push(jsx("line", {
|
|
7809
7698
|
x1: x1,
|
|
7810
7699
|
y1: y1,
|
|
@@ -7815,39 +7704,43 @@ const GaugeChart = memo( forwardRef((({value: value, min: min = 0, max: max = 1
|
|
|
7815
7704
|
}, `minor-tick-${i}`));
|
|
7816
7705
|
}
|
|
7817
7706
|
}
|
|
7818
|
-
|
|
7819
|
-
const needle = showNeedle ? jsxs("g", {
|
|
7707
|
+
const innerRadius = radius * (1 - thickness), needle = showNeedle ? jsxs("g", {
|
|
7820
7708
|
children: [ jsx("line", {
|
|
7821
7709
|
x1: centerX,
|
|
7822
7710
|
y1: centerY,
|
|
7823
|
-
x2: centerX +
|
|
7824
|
-
y2: centerY +
|
|
7711
|
+
x2: centerX + (innerRadius - 15) * Math.cos(valueAngle),
|
|
7712
|
+
y2: centerY + (innerRadius - 15) * Math.sin(valueAngle),
|
|
7825
7713
|
stroke: needleColor,
|
|
7826
|
-
strokeWidth: "
|
|
7714
|
+
strokeWidth: "4",
|
|
7827
7715
|
strokeLinecap: "round"
|
|
7828
7716
|
}), jsx("circle", {
|
|
7829
7717
|
cx: centerX,
|
|
7830
7718
|
cy: centerY,
|
|
7831
7719
|
r: "8",
|
|
7832
7720
|
fill: needleColor
|
|
7721
|
+
}), jsx("circle", {
|
|
7722
|
+
cx: centerX,
|
|
7723
|
+
cy: centerY,
|
|
7724
|
+
r: "3",
|
|
7725
|
+
fill: "var(--atomix-primary-bg, #fff)"
|
|
7833
7726
|
}) ]
|
|
7834
7727
|
}) : null, valueText = showValue ? jsx("text", {
|
|
7835
7728
|
x: centerX,
|
|
7836
|
-
y: centerY +
|
|
7729
|
+
y: centerY + 35,
|
|
7837
7730
|
textAnchor: "middle",
|
|
7838
|
-
fontSize: "
|
|
7731
|
+
fontSize: "32",
|
|
7839
7732
|
fontWeight: "bold",
|
|
7840
7733
|
fill: "var(--atomix-primary-text-emphasis)",
|
|
7841
7734
|
children: valueFormatter(clampedValue)
|
|
7842
7735
|
}) : null, labelText = label ? jsx("text", {
|
|
7843
7736
|
x: centerX,
|
|
7844
|
-
y: "top" === labelPosition ? centerY - .7 * radius : centerY + .7 * radius,
|
|
7737
|
+
y: "top" === labelPosition ? centerY - .7 * radius : centerY + .7 * radius + 10,
|
|
7845
7738
|
textAnchor: "middle",
|
|
7846
7739
|
fontSize: "16",
|
|
7847
7740
|
fill: "var(--atomix-brand-text-emphasis)",
|
|
7848
7741
|
children: label
|
|
7849
7742
|
}) : null;
|
|
7850
|
-
//
|
|
7743
|
+
// Create needle
|
|
7851
7744
|
return jsxs("g", {
|
|
7852
7745
|
children: [ jsx("path", {
|
|
7853
7746
|
d: createArcPath(centerX, centerY, radius, startAngleRad, endAngleRad, thickness),
|
|
@@ -7879,11 +7772,9 @@ const colorSchemes = {
|
|
|
7879
7772
|
greens: [ "var(--atomix-green-1)", "var(--atomix-green-2)", "var(--atomix-green-3)", "var(--atomix-green-4)", "var(--atomix-green-5)", "var(--atomix-green-6)", "var(--atomix-green-7)", "var(--atomix-green-8)", "var(--atomix-green-9)" ],
|
|
7880
7773
|
github: [ "var(--atomix-gray-2)", "var(--atomix-green-3)", "var(--atomix-green-4)", "var(--atomix-green-5)", "var(--atomix-green-6)" ]
|
|
7881
7774
|
}, HeatmapChart = memo( forwardRef((({data: data = [], config: config = {}, colorScale: colorScale = {
|
|
7882
|
-
scheme: "
|
|
7775
|
+
scheme: "blues",
|
|
7883
7776
|
steps: 9
|
|
7884
7777
|
}, cellConfig: cellConfig = {
|
|
7885
|
-
width: 40,
|
|
7886
|
-
height: 40,
|
|
7887
7778
|
spacing: 2,
|
|
7888
7779
|
borderRadius: 4,
|
|
7889
7780
|
showLabels: !1
|
|
@@ -7943,9 +7834,8 @@ const colorSchemes = {
|
|
|
7943
7834
|
renderContent: ({scales: scales, colors: colors, datasets: renderedDatasets, handlers: handlers, hoveredPoint: hoveredPoint, toolbarState: toolbarState, config: renderConfig}) => {
|
|
7944
7835
|
const {matrix: matrix, xLabels: xLabels, yLabels: yLabels} = processedData, showTooltips = toolbarState?.showTooltips ?? renderConfig?.showTooltips ?? !0;
|
|
7945
7836
|
if (!matrix.length) return null;
|
|
7946
|
-
const cellWidth = cellConfig.width ||
|
|
7947
|
-
|
|
7948
|
-
return xLabels.length, yLabels.length, jsxs(Fragment, {
|
|
7837
|
+
const spacing = cellConfig.spacing ?? 2, borderRadius = cellConfig.borderRadius ?? 4, {width: width, height: height} = scales, paddingRight = 20 + (showColorLegend ? 60 : 0), availableWidth = Math.max(0, width - 60 - paddingRight), availableHeight = Math.max(0, height - 20 - 40), cols = Math.max(1, xLabels.length), rows = Math.max(1, yLabels.length), maxCellWidth = Math.max(2, Math.floor((availableWidth - (cols - 1) * spacing) / cols)), maxCellHeight = Math.max(2, Math.floor((availableHeight - (rows - 1) * spacing) / rows)), cellWidth = cellConfig.width || maxCellWidth, cellHeight = cellConfig.height || maxCellHeight, totalWidth = cols * cellWidth + (cols - 1) * spacing, totalHeight = rows * cellHeight + (rows - 1) * spacing, startX = 60 + Math.max(0, (availableWidth - totalWidth) / 2), startY = 20 + Math.max(0, (availableHeight - totalHeight) / 2);
|
|
7838
|
+
return jsxs(Fragment, {
|
|
7949
7839
|
children: [ jsxs("g", {
|
|
7950
7840
|
children: [ jsx("defs", {
|
|
7951
7841
|
children: showColorLegend && (() => {
|
|
@@ -7964,7 +7854,7 @@ const colorSchemes = {
|
|
|
7964
7854
|
})()
|
|
7965
7855
|
}), matrix.map(((row, rowIndex) => row.map(((cell, colIndex) => {
|
|
7966
7856
|
if (!cell) return null;
|
|
7967
|
-
const x =
|
|
7857
|
+
const x = startX + colIndex * (cellWidth + spacing), y = startY + rowIndex * (cellHeight + spacing), color = getColorForValue(cell.value);
|
|
7968
7858
|
return jsxs("g", {
|
|
7969
7859
|
children: [ jsx("rect", {
|
|
7970
7860
|
x: x,
|
|
@@ -7974,12 +7864,7 @@ const colorSchemes = {
|
|
|
7974
7864
|
rx: borderRadius,
|
|
7975
7865
|
ry: borderRadius,
|
|
7976
7866
|
fill: color,
|
|
7977
|
-
className: "c-chart__heatmap-cell " + (
|
|
7978
|
-
style: {
|
|
7979
|
-
transition: "all 0.2s ease",
|
|
7980
|
-
transform: isHovered ? "scale(1.05)" : "scale(1)",
|
|
7981
|
-
transformOrigin: "center"
|
|
7982
|
-
},
|
|
7867
|
+
className: "c-chart__heatmap-cell " + (hoveredCell === cell ? "c-chart__heatmap-cell--hovered" : ""),
|
|
7983
7868
|
onClick: () => {
|
|
7984
7869
|
cell && handlers.onDataPointClick?.({
|
|
7985
7870
|
...cell,
|
|
@@ -7989,8 +7874,14 @@ const colorSchemes = {
|
|
|
7989
7874
|
},
|
|
7990
7875
|
onMouseEnter: e => {
|
|
7991
7876
|
setHoveredCell(cell);
|
|
7877
|
+
const pointIndex = data.findIndex((d => d.x === cell.x && d.y === cell.y)), rect = e.currentTarget.getBoundingClientRect();
|
|
7878
|
+
handlers.onPointHover(0,
|
|
7879
|
+
// datasetIndex is always 0 for Heatmap
|
|
7880
|
+
pointIndex >= 0 ? pointIndex : 0, x, y, rect.left + rect.width / 2, rect.top + rect.height / 2);
|
|
7992
7881
|
},
|
|
7993
|
-
onMouseLeave: () =>
|
|
7882
|
+
onMouseLeave: () => {
|
|
7883
|
+
setHoveredCell(null), handlers.onPointLeave();
|
|
7884
|
+
}
|
|
7994
7885
|
}), cellConfig.showLabels && cell.label && jsx("text", {
|
|
7995
7886
|
x: x + cellWidth / 2,
|
|
7996
7887
|
y: y + cellHeight / 2,
|
|
@@ -8001,7 +7892,7 @@ const colorSchemes = {
|
|
|
8001
7892
|
}) ]
|
|
8002
7893
|
}, `cell-${rowIndex}-${colIndex}`);
|
|
8003
7894
|
})))), xLabels.map(((label, index) => {
|
|
8004
|
-
const x =
|
|
7895
|
+
const x = startX + index * (cellWidth + spacing) + cellWidth / 2, y = startY + matrix.length * (cellHeight + spacing) + 20;
|
|
8005
7896
|
return jsx("text", {
|
|
8006
7897
|
x: x,
|
|
8007
7898
|
y: y,
|
|
@@ -8010,36 +7901,38 @@ const colorSchemes = {
|
|
|
8010
7901
|
children: String(label)
|
|
8011
7902
|
}, `x-label-${index}`);
|
|
8012
7903
|
})), yLabels.map(((label, index) => jsx("text", {
|
|
8013
|
-
x:
|
|
8014
|
-
y:
|
|
7904
|
+
x: startX - 20,
|
|
7905
|
+
y: startY + index * (cellHeight + spacing) + cellHeight / 2,
|
|
8015
7906
|
textAnchor: "end",
|
|
8016
7907
|
dominantBaseline: "middle",
|
|
8017
7908
|
className: "c-chart__heatmap-axis-label",
|
|
8018
7909
|
children: String(label)
|
|
8019
7910
|
}, `y-label-${index}`))), showColorLegend && jsxs("g", {
|
|
8020
|
-
transform:
|
|
7911
|
+
transform: `translate(${startX + totalWidth + 20}, ${startY})`,
|
|
8021
7912
|
children: [ jsx("rect", {
|
|
8022
7913
|
x: "0",
|
|
8023
7914
|
y: "0",
|
|
8024
|
-
width: "
|
|
8025
|
-
height:
|
|
7915
|
+
width: "12",
|
|
7916
|
+
height: totalHeight,
|
|
8026
7917
|
fill: "url(#heatmap-legend-gradient)",
|
|
8027
7918
|
stroke: "var(--atomix-border-color)",
|
|
8028
|
-
className: "c-chart__grid"
|
|
7919
|
+
className: "c-chart__grid",
|
|
7920
|
+
rx: borderRadius,
|
|
7921
|
+
ry: borderRadius
|
|
8029
7922
|
}), jsx("text", {
|
|
8030
|
-
x: "-
|
|
7923
|
+
x: "-5",
|
|
8031
7924
|
y: "-10",
|
|
8032
7925
|
className: "c-chart__heatmap-legend-title",
|
|
8033
7926
|
children: "Values"
|
|
8034
7927
|
}), jsx("text", {
|
|
8035
|
-
x: "
|
|
8036
|
-
y: "
|
|
7928
|
+
x: "20",
|
|
7929
|
+
y: "8",
|
|
8037
7930
|
textAnchor: "start",
|
|
8038
7931
|
className: "c-chart__heatmap-legend-label",
|
|
8039
7932
|
children: "High"
|
|
8040
7933
|
}), jsx("text", {
|
|
8041
|
-
x: "
|
|
8042
|
-
y:
|
|
7934
|
+
x: "20",
|
|
7935
|
+
y: totalHeight,
|
|
8043
7936
|
textAnchor: "start",
|
|
8044
7937
|
className: "c-chart__heatmap-legend-label",
|
|
8045
7938
|
children: "Low"
|
|
@@ -8811,8 +8704,7 @@ const DEFAULT_COLOR_CONFIG = {
|
|
|
8811
8704
|
}, DEFAULT_LABEL_CONFIG = {
|
|
8812
8705
|
showLabels: !0,
|
|
8813
8706
|
minSize: 1e3,
|
|
8814
|
-
fontSize: 12
|
|
8815
|
-
textColor: "white"
|
|
8707
|
+
fontSize: 12
|
|
8816
8708
|
}, DEFAULT_CONFIG = {}, TreemapChart = memo( forwardRef((({data: data = [], algorithm: algorithm = "squarified", colorConfig: colorConfig = DEFAULT_COLOR_CONFIG, labelConfig: labelConfig = DEFAULT_LABEL_CONFIG, onDataPointClick: onDataPointClick, config: config = DEFAULT_CONFIG, ...props}, ref) => {
|
|
8817
8709
|
const [hoveredNode, setHoveredNode] = useState(null), [selectedNode, setSelectedNode] = useState(null);
|
|
8818
8710
|
useState({
|
|
@@ -8876,13 +8768,13 @@ const DEFAULT_COLOR_CONFIG = {
|
|
|
8876
8768
|
}
|
|
8877
8769
|
// Sort nodes by value (descending)
|
|
8878
8770
|
const sortedNodes = [ ...nodes ].sort(((a, b) => b.value - a.value)), aspectRatio = rect => Math.max(rect.width / rect.height, rect.height / rect.width);
|
|
8879
|
-
let currentRow = [], remainingNodes = [ ...sortedNodes ], currentX = x, currentY = y, remainingWidth = width, remainingHeight = height;
|
|
8771
|
+
let currentRow = [], remainingNodes = [ ...sortedNodes ], currentX = x, currentY = y, remainingWidth = width, remainingHeight = height, remainingValue = totalValue;
|
|
8880
8772
|
for (;remainingNodes.length > 0; ) {
|
|
8881
8773
|
const node = remainingNodes.shift();
|
|
8882
8774
|
if (!node) break;
|
|
8883
8775
|
currentRow.push(node);
|
|
8884
8776
|
// Calculate dimensions for current row
|
|
8885
|
-
const rowValue = _reduceInstanceProperty(currentRow).call(currentRow, ((sum, n) => sum + n.value), 0), rowRatio = rowValue /
|
|
8777
|
+
const rowValue = _reduceInstanceProperty(currentRow).call(currentRow, ((sum, n) => sum + n.value), 0), rowRatio = remainingValue > 0 ? rowValue / remainingValue : 0;
|
|
8886
8778
|
let rowWidth, rowHeight;
|
|
8887
8779
|
remainingWidth >= remainingHeight ? (rowWidth = remainingWidth * rowRatio, rowHeight = remainingHeight) : (rowWidth = remainingWidth,
|
|
8888
8780
|
rowHeight = remainingHeight * rowRatio);
|
|
@@ -8891,7 +8783,7 @@ const DEFAULT_COLOR_CONFIG = {
|
|
|
8891
8783
|
if (remainingNodes.length > 0) {
|
|
8892
8784
|
const nextNode = remainingNodes[0];
|
|
8893
8785
|
if (!nextNode) break;
|
|
8894
|
-
const testRow = [ ...currentRow, nextNode ], testRowValue = _reduceInstanceProperty(testRow).call(testRow, ((sum, n) => sum + n.value), 0), testRowRatio = testRowValue /
|
|
8786
|
+
const testRow = [ ...currentRow, nextNode ], testRowValue = _reduceInstanceProperty(testRow).call(testRow, ((sum, n) => sum + n.value), 0), testRowRatio = remainingValue > 0 ? testRowValue / remainingValue : 0;
|
|
8895
8787
|
let testRowWidth, testRowHeight;
|
|
8896
8788
|
remainingWidth >= remainingHeight ? (testRowWidth = remainingWidth * testRowRatio,
|
|
8897
8789
|
testRowHeight = remainingHeight) : (testRowWidth = remainingWidth, testRowHeight = remainingHeight * testRowRatio);
|
|
@@ -8922,14 +8814,14 @@ const DEFAULT_COLOR_CONFIG = {
|
|
|
8922
8814
|
})),
|
|
8923
8815
|
// Update remaining space
|
|
8924
8816
|
remainingWidth >= remainingHeight ? (currentX += rowWidth, remainingWidth -= rowWidth) : (currentY += rowHeight,
|
|
8925
|
-
remainingHeight -= rowHeight), currentRow = [];
|
|
8817
|
+
remainingHeight -= rowHeight), remainingValue -= rowValue, currentRow = [];
|
|
8926
8818
|
}
|
|
8927
8819
|
}
|
|
8928
|
-
}), []), renderContent = useCallback((({scales: scales, colors: colors, datasets: renderedDatasets, handlers: handlers, hoveredPoint: hoveredPoint}) => {
|
|
8820
|
+
}), []), renderContent = useCallback((({scales: scales, colors: colors, datasets: renderedDatasets, handlers: handlers, hoveredPoint: hoveredPoint, toolbarState: toolbarState, config: renderConfig}) => {
|
|
8929
8821
|
if (!data.length) return null;
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8822
|
+
const showTooltips = toolbarState?.showTooltips ?? renderConfig?.showTooltips ?? !0, availableWidth = Math.max(0, scales.width), availableHeight = Math.max(0, scales.height), leafNodes = data.filter((item => !item.children || 0 === item.children.length));
|
|
8823
|
+
// Calculate available space
|
|
8824
|
+
if (!leafNodes.length) return null;
|
|
8933
8825
|
const totalValue = _reduceInstanceProperty(leafNodes).call(leafNodes, ((sum, node) => sum + node.value), 0), treemapNodes = leafNodes.map(((item, index) => ({
|
|
8934
8826
|
id: item.id,
|
|
8935
8827
|
label: item.label,
|
|
@@ -8949,24 +8841,26 @@ const DEFAULT_COLOR_CONFIG = {
|
|
|
8949
8841
|
})));
|
|
8950
8842
|
// Create treemap nodes with proper dimensions
|
|
8951
8843
|
// Apply squarified algorithm to layout nodes proportionally by value
|
|
8952
|
-
if ("squarified" === algorithm && totalValue > 0) squarify(treemapNodes,
|
|
8844
|
+
if ("squarified" === algorithm && totalValue > 0) squarify(treemapNodes, 0, 0, availableWidth, availableHeight); else {
|
|
8953
8845
|
// Fallback: simple grid layout (equal sizes)
|
|
8954
8846
|
const cols = Math.ceil(Math.sqrt(leafNodes.length)), rows = Math.ceil(leafNodes.length / cols), nodeWidth = availableWidth / cols, nodeHeight = availableHeight / rows;
|
|
8955
8847
|
treemapNodes.forEach(((node, index) => {
|
|
8956
8848
|
const col = index % cols, row = Math.floor(index / cols);
|
|
8957
|
-
node.x =
|
|
8849
|
+
node.x = 0 + col * nodeWidth, node.y = 0 + row * nodeHeight, node.width = nodeWidth,
|
|
8958
8850
|
node.height = nodeHeight;
|
|
8959
8851
|
}));
|
|
8960
8852
|
}
|
|
8961
|
-
return
|
|
8962
|
-
children: treemapNodes.map((node => {
|
|
8853
|
+
return jsxs(Fragment, {
|
|
8854
|
+
children: [ treemapNodes.map((node => {
|
|
8963
8855
|
const isHovered = hoveredNode === node, isSelected = selectedNode === node, area = node.width * node.height, showLabel = labelConfig.showLabels && area >= (labelConfig.minSize || 1e3);
|
|
8964
8856
|
return jsxs("g", {
|
|
8965
8857
|
children: [ jsx("rect", {
|
|
8966
|
-
x: node.x,
|
|
8967
|
-
y: node.y,
|
|
8968
|
-
width: node.width,
|
|
8969
|
-
height: node.height,
|
|
8858
|
+
x: node.x + 2,
|
|
8859
|
+
y: node.y + 2,
|
|
8860
|
+
width: Math.max(0, node.width - 4),
|
|
8861
|
+
height: Math.max(0, node.height - 4),
|
|
8862
|
+
rx: 6,
|
|
8863
|
+
ry: 6,
|
|
8970
8864
|
fill: node.color,
|
|
8971
8865
|
className: `c-chart__treemap-node ${isHovered ? "c-chart__treemap-node--hovered" : ""} ${isSelected ? "c-chart__treemap-node--selected" : ""}`,
|
|
8972
8866
|
onClick: () => {
|
|
@@ -8974,8 +8868,8 @@ const DEFAULT_COLOR_CONFIG = {
|
|
|
8974
8868
|
},
|
|
8975
8869
|
onMouseEnter: e => {
|
|
8976
8870
|
setHoveredNode(node);
|
|
8977
|
-
const rect = e.currentTarget.getBoundingClientRect();
|
|
8978
|
-
handlers.onPointHover(0, 0, node.x, node.y, rect.left + rect.width / 2, rect.top + rect.height / 2);
|
|
8871
|
+
const rect = e.currentTarget.getBoundingClientRect(), pointIndex = data.indexOf(node.originalData);
|
|
8872
|
+
handlers.onPointHover(0, pointIndex >= 0 ? pointIndex : 0, node.x, node.y, rect.left + rect.width / 2, rect.top + rect.height / 2);
|
|
8979
8873
|
},
|
|
8980
8874
|
onMouseLeave: () => {
|
|
8981
8875
|
setHoveredNode(null), handlers.onPointLeave();
|
|
@@ -8987,13 +8881,21 @@ const DEFAULT_COLOR_CONFIG = {
|
|
|
8987
8881
|
dominantBaseline: "middle",
|
|
8988
8882
|
className: "c-chart__treemap-label",
|
|
8989
8883
|
style: {
|
|
8990
|
-
fontSize: labelConfig.fontSize
|
|
8991
|
-
fill: labelConfig.textColor
|
|
8884
|
+
fontSize: labelConfig.fontSize
|
|
8992
8885
|
},
|
|
8993
8886
|
children: node.label
|
|
8994
8887
|
}) ]
|
|
8995
8888
|
}, node.id);
|
|
8996
|
-
}))
|
|
8889
|
+
})), showTooltips && hoveredPoint && renderedDatasets[hoveredPoint.datasetIndex]?.data?.[hoveredPoint.pointIndex] && jsx(ChartTooltip, {
|
|
8890
|
+
dataPoint: renderedDatasets[hoveredPoint.datasetIndex].data[hoveredPoint.pointIndex],
|
|
8891
|
+
datasetLabel: renderedDatasets[hoveredPoint.datasetIndex]?.label,
|
|
8892
|
+
datasetColor: renderedDatasets[hoveredPoint.datasetIndex]?.color || colors[hoveredPoint.datasetIndex % colors.length],
|
|
8893
|
+
position: {
|
|
8894
|
+
x: hoveredPoint.clientX,
|
|
8895
|
+
y: hoveredPoint.clientY
|
|
8896
|
+
},
|
|
8897
|
+
visible: !0
|
|
8898
|
+
}) ]
|
|
8997
8899
|
});
|
|
8998
8900
|
}), [ data, algorithm, generateColor, squarify, labelConfig, hoveredNode, selectedNode ]), datasets = useMemo((() => [ {
|
|
8999
8901
|
label: "Treemap Data",
|
|
@@ -12318,96 +12220,6 @@ function useTodo(initialProps) {
|
|
|
12318
12220
|
};
|
|
12319
12221
|
}
|
|
12320
12222
|
|
|
12321
|
-
/**
|
|
12322
|
-
* Custom hook for managing GlassContainer state and interactions
|
|
12323
|
-
*/ function useGlassContainer(props) {
|
|
12324
|
-
const {glassSize: glassSize = {
|
|
12325
|
-
width: 270,
|
|
12326
|
-
height: 69
|
|
12327
|
-
}, elasticity: elasticity = .15, mouseContainer: mouseContainer, globalMousePos: externalGlobalMousePos, mouseOffset: externalMouseOffset} = props, filterId = useId(), glassRef = useRef(null), [isHovered, setIsHovered] = useState(!1), [isActive, setIsActive] = useState(!1), [currentGlassSize, setCurrentGlassSize] = useState(glassSize), [internalGlobalMousePos, setInternalGlobalMousePos] = useState({
|
|
12328
|
-
x: 0,
|
|
12329
|
-
y: 0
|
|
12330
|
-
}), [internalMouseOffset, setInternalMouseOffset] = useState({
|
|
12331
|
-
x: 0,
|
|
12332
|
-
y: 0
|
|
12333
|
-
}), globalMousePos = externalGlobalMousePos || internalGlobalMousePos, mouseOffset = externalMouseOffset || internalMouseOffset, handleMouseMove = useCallback((e => {
|
|
12334
|
-
const container = mouseContainer?.current || glassRef.current;
|
|
12335
|
-
if (!container) return;
|
|
12336
|
-
const rect = container.getBoundingClientRect(), centerX = rect.left + rect.width / 2, centerY = rect.top + rect.height / 2;
|
|
12337
|
-
setInternalMouseOffset({
|
|
12338
|
-
x: (e.clientX - centerX) / rect.width * 100,
|
|
12339
|
-
y: (e.clientY - centerY) / rect.height * 100
|
|
12340
|
-
}), setInternalGlobalMousePos({
|
|
12341
|
-
x: e.clientX,
|
|
12342
|
-
y: e.clientY
|
|
12343
|
-
});
|
|
12344
|
-
}), [ mouseContainer ]);
|
|
12345
|
-
// Set up mouse tracking if no external mouse position is provided
|
|
12346
|
-
useEffect((() => {
|
|
12347
|
-
if (externalGlobalMousePos && externalMouseOffset) return;
|
|
12348
|
-
const container = mouseContainer?.current || glassRef.current;
|
|
12349
|
-
return container ? (container.addEventListener("mousemove", handleMouseMove), () => container.removeEventListener("mousemove", handleMouseMove)) : void 0;
|
|
12350
|
-
}), [ handleMouseMove, mouseContainer, externalGlobalMousePos, externalMouseOffset ]);
|
|
12351
|
-
// Calculate directional scaling based on mouse position
|
|
12352
|
-
const calculateDirectionalScale = useCallback((() => {
|
|
12353
|
-
if (!globalMousePos.x || !globalMousePos.y || !glassRef.current) return "scale(1)";
|
|
12354
|
-
const rect = glassRef.current.getBoundingClientRect(), pillCenterX = rect.left + rect.width / 2, pillCenterY = rect.top + rect.height / 2, pillWidth = currentGlassSize.width, pillHeight = currentGlassSize.height, deltaX = globalMousePos.x - pillCenterX, deltaY = globalMousePos.y - pillCenterY, edgeDistanceX = Math.max(0, Math.abs(deltaX) - pillWidth / 2), edgeDistanceY = Math.max(0, Math.abs(deltaY) - pillHeight / 2), edgeDistance = Math.sqrt(edgeDistanceX * edgeDistanceX + edgeDistanceY * edgeDistanceY);
|
|
12355
|
-
if (edgeDistance > 200) return "scale(1)";
|
|
12356
|
-
const fadeInFactor = 1 - edgeDistance / 200, centerDistance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
12357
|
-
if (0 === centerDistance) return "scale(1)";
|
|
12358
|
-
const normalizedX = deltaX / centerDistance, normalizedY = deltaY / centerDistance, stretchIntensity = Math.min(centerDistance / 300, 1) * elasticity * fadeInFactor, scaleX = 1 + Math.abs(normalizedX) * stretchIntensity * .3 - Math.abs(normalizedY) * stretchIntensity * .15, scaleY = 1 + Math.abs(normalizedY) * stretchIntensity * .3 - Math.abs(normalizedX) * stretchIntensity * .15;
|
|
12359
|
-
return `scaleX(${Math.max(.8, scaleX)}) scaleY(${Math.max(.8, scaleY)})`;
|
|
12360
|
-
}), [ globalMousePos, elasticity, currentGlassSize ]), calculateElasticTranslation = useCallback((() => {
|
|
12361
|
-
if (!glassRef.current) return {
|
|
12362
|
-
x: 0,
|
|
12363
|
-
y: 0
|
|
12364
|
-
};
|
|
12365
|
-
const rect = glassRef.current.getBoundingClientRect(), pillCenterX = rect.left + rect.width / 2, pillCenterY = rect.top + rect.height / 2, pillWidth = currentGlassSize.width, pillHeight = currentGlassSize.height, edgeDistanceX = Math.max(0, Math.abs(globalMousePos.x - pillCenterX) - pillWidth / 2), edgeDistanceY = Math.max(0, Math.abs(globalMousePos.y - pillCenterY) - pillHeight / 2), edgeDistance = Math.sqrt(edgeDistanceX * edgeDistanceX + edgeDistanceY * edgeDistanceY), fadeInFactor = edgeDistance > 200 ? 0 : 1 - edgeDistance / 200;
|
|
12366
|
-
return {
|
|
12367
|
-
x: (globalMousePos.x - pillCenterX) * elasticity * .1 * fadeInFactor,
|
|
12368
|
-
y: (globalMousePos.y - pillCenterY) * elasticity * .1 * fadeInFactor
|
|
12369
|
-
};
|
|
12370
|
-
}), [ globalMousePos, elasticity, currentGlassSize ]);
|
|
12371
|
-
// Calculate elastic translation
|
|
12372
|
-
// Update glass size
|
|
12373
|
-
useEffect((() => {
|
|
12374
|
-
const updateGlassSize = () => {
|
|
12375
|
-
if (glassRef.current) {
|
|
12376
|
-
const rect = glassRef.current.getBoundingClientRect();
|
|
12377
|
-
setCurrentGlassSize({
|
|
12378
|
-
width: rect.width,
|
|
12379
|
-
height: rect.height
|
|
12380
|
-
});
|
|
12381
|
-
}
|
|
12382
|
-
};
|
|
12383
|
-
return updateGlassSize(), window.addEventListener("resize", updateGlassSize), () => window.removeEventListener("resize", updateGlassSize);
|
|
12384
|
-
}), []);
|
|
12385
|
-
const handleMouseEnter = useCallback((() => {
|
|
12386
|
-
setIsHovered(!0);
|
|
12387
|
-
}), []), handleMouseLeave = useCallback((() => {
|
|
12388
|
-
setIsHovered(!1);
|
|
12389
|
-
}), []), handleMouseDown = useCallback((() => {
|
|
12390
|
-
setIsActive(!0);
|
|
12391
|
-
}), []), handleMouseUp = useCallback((() => {
|
|
12392
|
-
setIsActive(!1);
|
|
12393
|
-
}), []);
|
|
12394
|
-
return {
|
|
12395
|
-
filterId: filterId,
|
|
12396
|
-
glassRef: glassRef,
|
|
12397
|
-
isHovered: isHovered,
|
|
12398
|
-
isActive: isActive,
|
|
12399
|
-
currentGlassSize: currentGlassSize,
|
|
12400
|
-
globalMousePos: globalMousePos,
|
|
12401
|
-
mouseOffset: mouseOffset,
|
|
12402
|
-
calculateDirectionalScale: calculateDirectionalScale,
|
|
12403
|
-
calculateElasticTranslation: calculateElasticTranslation,
|
|
12404
|
-
handleMouseEnter: handleMouseEnter,
|
|
12405
|
-
handleMouseLeave: handleMouseLeave,
|
|
12406
|
-
handleMouseDown: handleMouseDown,
|
|
12407
|
-
handleMouseUp: handleMouseUp
|
|
12408
|
-
};
|
|
12409
|
-
}
|
|
12410
|
-
|
|
12411
12223
|
/**
|
|
12412
12224
|
* Radio state and functionality
|
|
12413
12225
|
* @param initialProps - Initial radio properties
|
|
@@ -12900,7 +12712,6 @@ const composablesImport = Object.freeze( Object.defineProperty({
|
|
|
12900
12712
|
useEdgePanel: useEdgePanel,
|
|
12901
12713
|
useForm: useForm,
|
|
12902
12714
|
useFormGroup: useFormGroup,
|
|
12903
|
-
useGlassContainer: useGlassContainer,
|
|
12904
12715
|
useHero: useHero,
|
|
12905
12716
|
useInput: useInput,
|
|
12906
12717
|
useLineChart: useLineChart,
|
|
@@ -14971,13 +14782,14 @@ const Navbar = forwardRef((({brand: brand, children: children, variant: variant
|
|
|
14971
14782
|
return jsx(AtomixGlass, {
|
|
14972
14783
|
...glassProps,
|
|
14973
14784
|
style: {
|
|
14974
|
-
..."fixed" === position && {
|
|
14975
|
-
position: "fixed"
|
|
14976
|
-
|
|
14977
|
-
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
|
|
14785
|
+
...("fixed" === position || "fixed-bottom" === position) && {
|
|
14786
|
+
position: "fixed",
|
|
14787
|
+
top: "fixed" === position ? 0 : void 0,
|
|
14788
|
+
bottom: "fixed-bottom" === position ? 0 : void 0,
|
|
14789
|
+
left: 0,
|
|
14790
|
+
right: 0,
|
|
14791
|
+
zIndex: 1030
|
|
14792
|
+
}
|
|
14981
14793
|
},
|
|
14982
14794
|
children: jsx("nav", {
|
|
14983
14795
|
ref: ref,
|
|
@@ -19345,7 +19157,6 @@ VideoPlayer.displayName = "VideoPlayer";
|
|
|
19345
19157
|
const components = Object.freeze( Object.defineProperty({
|
|
19346
19158
|
__proto__: null,
|
|
19347
19159
|
Accordion: Accordion,
|
|
19348
|
-
AnimatedChart: AnimatedChart,
|
|
19349
19160
|
AreaChart: AreaChart,
|
|
19350
19161
|
AtomixGlass: AtomixGlass,
|
|
19351
19162
|
AtomixLogo: AtomixLogo,
|
|
@@ -25432,5 +25243,5 @@ const atomix = {
|
|
|
25432
25243
|
types: types
|
|
25433
25244
|
};
|
|
25434
25245
|
|
|
25435
|
-
export { ACCORDION, ATOMIX_GLASS, AVATAR, AVATAR_GROUP, Accordion,
|
|
25246
|
+
export { ACCORDION, ATOMIX_GLASS, AVATAR, AVATAR_GROUP, Accordion, AreaChart, AtomixGlass, AtomixLogo, Avatar, AvatarGroup, BADGE, BADGE_CSS_VARS, BLOCK, BREADCRUMB, BUTTON, BUTTON_CSS_VARS, BUTTON_GROUP, Badge, BarChart, Block, Breadcrumb, BubbleChart, Button, ButtonGroup, CALLOUT, CARD, CARD_CSS_VARS, CHART, CHECKBOX_CSS_VARS, CLASS_PREFIX, CODE_SNIPPET, COMPONENT_CSS_VARS, COUNTDOWN, Callout, CandlestickChart, Card, Chart, ChartRenderer, Checkbox, ColorModeToggle, Container, Countdown, DATA_TABLE_CLASSES, DATA_TABLE_SELECTORS, DATEPICKER, DEFAULT_ATOMIX_FONTS, DOTS, DROPDOWN, DROPDOWN_CSS_VARS, DataTable, DatePicker, DesignTokensCustomizer, DonutChart, Dropdown, EDGE_PANEL, EdgePanel, ElevationCard, FOOTER, FORM, FORM_GROUP, Footer, FooterLink, FooterSection, FooterSocialLink, Form, FormGroup, FunnelChart, GaugeChart, Grid, GridCol, HERO, HeatmapChart, Hero, INPUT, INPUT_CSS_VARS, Icon, Input, LIST, LIST_GROUP, LineChart, List, ListGroup, MESSAGES, MODAL, MODAL_CSS_VARS, MasonryGrid, MasonryGridItem, MegaMenu, MegaMenuColumn, MegaMenuLink, Menu, MenuDivider, MenuItem, Messages, Modal, MultiAxisChart, NAV, NAVBAR, Nav, NavDropdown, NavItem, Navbar, PAGINATION_DEFAULTS, PHOTOVIEWER, POPOVER, PROGRESS, PROGRESS_CSS_VARS, Pagination, PhotoViewer, PieChart, Popover, ProductReview, Progress, RADIO, RADIO_CSS_VARS, RATING, RIVER, RTLManager, RadarChart, Radio, Rating, River, Row, SECTION_INTRO, SELECT, SIDE_MENU, SIZES, SLIDER, SPINNER, STEPS, ScatterChart, SectionIntro, Select, SideMenu, SideMenuItem, SideMenuList, Slider, Spinner, Steps, TAB, TABS_CSS_VARS, TESTIMONIAL, TEXTAREA, THEME_COLORS, THEME_NAMING, TODO, TOGGLE, TOOLTIP, TOOLTIP_CSS_VARS, Tabs, Testimonial, Textarea, ThemeApplicator, ThemeComparator, ThemeContext, ThemeErrorBoundary, ThemeInspector, ThemeLiveEditor, ThemePreview, ThemeProvider, ThemeValidator, Todo, Toggle, Tooltip, TreemapChart, UPLOAD, Upload, VIDEO_PLAYER, VideoPlayer, WaterfallChart, applyCSSVariables, applyCSSVarsToStyle, applyComponentTheme, applyPartStyles, applyTheme, camelToKebab, clearThemes, composables, constants, createCSSVarStyle, createDarkVariant, createDebugAttrs, createFontPreloadLink, createPartProps, createSlotComponent, createSlotProps, createTheme, createThemeRegistry, createTokens, cssVarsToStyle, deepMerge, atomix as default, defaultTokens, defineConfig, designTokensToCSSVars, exportTheme, extendTheme, extractComponentName, extractYouTubeId, generateCSSVariableName, generateCSSVariables$1 as generateCSSVariables, generateCSSVariablesForSelector, generateClassName, generateComponentCSSVars, generateFontPreloadTags, generateUUID, getAllThemes, getCSSVariable, getComponentCSSVars, getComponentThemeValue, getPartStyles, getTheme, getThemeApplicator, getThemeCount, getThemeIds, getThemeMetadata, hasCustomization, hasTheme, importTheme, injectCSS$1 as injectCSS, injectTheme, isCSSInjected, isDesignTokens, isSlot, isValidCSSVariableName, isYouTubeUrl, mapSCSSTokensToCSSVars, mergeCSSVars, mergeClassNames, mergeComponentProps, mergePartStyles, mergeSlots, mergeTheme, normalizeThemeTokens, preloadFonts, quickTheme, registerTheme, removeCSS, removeCSSVariables, removeTheme, renderSlot, sliderConstants, supportsDarkMode, theme, themePropertyToCSSVar, themeToCSS, types, unregisterTheme, useAccordion, useAtomixGlass, useBadge, useBarChart, useBlock, useBreadcrumb, useCard, useChartData, useChartInteraction, useChartScale, useComponentCustomization, useComponentDefaultProps, useComponentTheme, useDataTable, useEdgePanel, useForm, useFormGroup, useHero, useHistory, useInput, useLineChart, useMergedProps, useModal$1 as useModal, useNav, useNavDropdown, useNavItem, useNavbar, usePagination, usePieChart, useRadio, useRiver, useSelect, useSideMenu, useSideMenuItem, useSlider, useSlot, useSpinner, useTextarea, useTheme, useThemeTokens, useTodo, utils, validateTheme };
|
|
25436
25247
|
//# sourceMappingURL=index.esm.js.map
|