@shohojdhara/atomix 0.6.2 → 0.6.4
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/README.md +510 -106
- package/dist/atomix.css +26 -22
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +5 -5
- package/dist/atomix.min.css.map +1 -1
- package/dist/atomix.umd.js +1 -1
- package/dist/atomix.umd.js.map +1 -1
- package/dist/atomix.umd.min.js +1 -1
- package/dist/charts.d.ts +2 -2
- package/dist/charts.js +251 -131
- package/dist/charts.js.map +1 -1
- package/dist/core.d.ts +5 -39
- package/dist/core.js +254 -137
- package/dist/core.js.map +1 -1
- package/dist/forms.d.ts +2 -1
- package/dist/forms.js +342 -177
- package/dist/forms.js.map +1 -1
- package/dist/heavy.js +254 -135
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +141 -159
- package/dist/index.esm.js +348 -195
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +348 -195
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/theme.d.ts +14 -6
- package/dist/theme.js +2 -9
- package/dist/theme.js.map +1 -1
- package/package.json +26 -26
- package/src/components/AtomixGlass/AtomixGlass.tsx +1 -1
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +8 -1
- package/src/components/AtomixGlass/glass-utils.ts +29 -0
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +32 -1
- package/src/components/Button/Button.stories.tsx +1 -1
- package/src/components/Button/Button.tsx +6 -5
- package/src/components/Card/Card.tsx +2 -2
- package/src/components/Dropdown/Dropdown.tsx +1 -0
- package/src/components/EdgePanel/EdgePanel.tsx +1 -3
- package/src/components/Form/Select.test.tsx +75 -0
- package/src/components/Form/Select.tsx +348 -252
- package/src/components/Form/SelectOption.tsx +16 -10
- package/src/components/index.ts +1 -1
- package/src/layouts/CssGrid/index.ts +1 -0
- package/src/lib/composables/useAtomixGlass.ts +238 -138
- package/src/lib/composables/useAtomixGlassStyles.ts +201 -149
- package/src/lib/constants/components.ts +50 -35
- package/src/lib/theme/config/configLoader.ts +1 -1
- package/src/lib/theme/test/testTheme.ts +2 -2
- package/src/lib/theme/utils/themeUtils.ts +98 -110
- package/src/lib/types/components.ts +21 -63
- package/src/styles/01-settings/_settings.atomix-glass.scss +5 -5
- package/src/styles/01-settings/_settings.spacing.scss +6 -1
- package/src/styles/03-generic/_generic.reset.scss +1 -1
- package/src/styles/06-components/_components.atomix-glass.scss +20 -29
- package/src/styles/06-components/_components.data-table.scss +5 -4
- package/src/styles/06-components/_components.dynamic-background.scss +9 -8
- package/src/styles/06-components/_components.footer.scss +8 -7
- package/src/styles/06-components/_components.hero.scss +2 -2
- package/src/styles/06-components/_components.messages.scss +16 -16
- package/src/styles/06-components/_components.select.scss +15 -2
- package/src/styles/06-components/_components.upload.scss +3 -3
- package/CHANGELOG.md +0 -165
package/dist/index.esm.js
CHANGED
|
@@ -1727,12 +1727,23 @@ const _includesInstanceProperty = getDefaultExportFromCjs((function(it) {
|
|
|
1727
1727
|
},
|
|
1728
1728
|
DEFAULTS: {
|
|
1729
1729
|
DISPLACEMENT_SCALE: 70,
|
|
1730
|
-
BLUR_AMOUNT
|
|
1731
|
-
|
|
1732
|
-
|
|
1730
|
+
get BLUR_AMOUNT() {
|
|
1731
|
+
return .15 * this.DISPLACEMENT_SCALE;
|
|
1732
|
+
// Dynamically computed based on displacement
|
|
1733
|
+
},
|
|
1734
|
+
get SATURATION() {
|
|
1735
|
+
return 100 + .5 * this.DISPLACEMENT_SCALE;
|
|
1736
|
+
// Saturate relative to intensity
|
|
1737
|
+
},
|
|
1738
|
+
get ABERRATION_INTENSITY() {
|
|
1739
|
+
return .03 * this.DISPLACEMENT_SCALE;
|
|
1740
|
+
// Scale aberration with displacement
|
|
1741
|
+
},
|
|
1733
1742
|
ELASTICITY: .15,
|
|
1734
|
-
CORNER_RADIUS
|
|
1735
|
-
|
|
1743
|
+
get CORNER_RADIUS() {
|
|
1744
|
+
return 16;
|
|
1745
|
+
// Use 16 to match SCSS design system (was 20)
|
|
1746
|
+
},
|
|
1736
1747
|
PADDING: "0",
|
|
1737
1748
|
MODE: "standard",
|
|
1738
1749
|
OVER_LIGHT: !1,
|
|
@@ -1758,6 +1769,11 @@ const _includesInstanceProperty = getDefaultExportFromCjs((function(it) {
|
|
|
1758
1769
|
ELASTICITY_TRANSLATION_FACTOR: .1,
|
|
1759
1770
|
ELASTICITY_DISTANCE_THRESHOLD: 200,
|
|
1760
1771
|
ELASTICITY_COMPRESSION_FACTOR: .3,
|
|
1772
|
+
ELASTICITY_STIFFNESS: .1,
|
|
1773
|
+
ELASTICITY_DAMPING: .76,
|
|
1774
|
+
ELASTICITY_VELOCITY_FACTOR: .65,
|
|
1775
|
+
ELASTICITY_STRETCH_RATIO: .45,
|
|
1776
|
+
ELASTICITY_MAGNIFICATION_BASE: 1.02,
|
|
1761
1777
|
// Note: This default must match the SCSS variable --atomix-radius-md
|
|
1762
1778
|
// @see src/styles/01-settings/_settings.global.scss
|
|
1763
1779
|
DEFAULT_CORNER_RADIUS: 16,
|
|
@@ -1774,84 +1790,126 @@ const _includesInstanceProperty = getDefaultExportFromCjs((function(it) {
|
|
|
1774
1790
|
// Base angle for border gradients (degrees)
|
|
1775
1791
|
ANGLE_MULTIPLIER: 1.2,
|
|
1776
1792
|
// Multiplier for mouse influence on angle
|
|
1793
|
+
VELOCITY_ANGLE_MULTIPLIER: 2.5,
|
|
1794
|
+
// How much velocity affects gradient rotation
|
|
1795
|
+
CHROMATIC_OFFSET: 1.5,
|
|
1796
|
+
// Degree offset for chromatic rim layers
|
|
1777
1797
|
BORDER_STOP_1: {
|
|
1778
1798
|
MIN: 10,
|
|
1779
1799
|
// Minimum percentage for border stop 1
|
|
1780
1800
|
BASE: 33,
|
|
1781
1801
|
// Base percentage for border stop 1
|
|
1782
|
-
MULTIPLIER
|
|
1802
|
+
get MULTIPLIER() {
|
|
1803
|
+
return .009 * this.BASE;
|
|
1804
|
+
}
|
|
1783
1805
|
},
|
|
1784
1806
|
BORDER_STOP_2: {
|
|
1785
1807
|
MAX: 90,
|
|
1786
1808
|
// Maximum percentage for border stop 2
|
|
1787
1809
|
BASE: 66,
|
|
1788
1810
|
// Base percentage for border stop 2
|
|
1789
|
-
MULTIPLIER
|
|
1811
|
+
get MULTIPLIER() {
|
|
1812
|
+
return .006 * this.BASE;
|
|
1813
|
+
}
|
|
1790
1814
|
},
|
|
1791
1815
|
BORDER_OPACITY: {
|
|
1792
1816
|
BASE_1: .12,
|
|
1793
1817
|
// Base opacity for border gradient 1
|
|
1794
|
-
BASE_2
|
|
1818
|
+
get BASE_2() {
|
|
1819
|
+
return 3.33 * this.BASE_1;
|
|
1820
|
+
},
|
|
1795
1821
|
// Base opacity for border gradient 2
|
|
1796
|
-
BASE_3
|
|
1822
|
+
get BASE_3() {
|
|
1823
|
+
return 2.66 * this.BASE_1;
|
|
1824
|
+
},
|
|
1797
1825
|
// Base opacity for border gradient 3
|
|
1798
|
-
BASE_4
|
|
1826
|
+
get BASE_4() {
|
|
1827
|
+
return 5 * this.BASE_1;
|
|
1828
|
+
},
|
|
1799
1829
|
// Base opacity for border gradient 4
|
|
1800
|
-
MULTIPLIER_LOW
|
|
1830
|
+
get MULTIPLIER_LOW() {
|
|
1831
|
+
return .066 * this.BASE_1;
|
|
1832
|
+
},
|
|
1801
1833
|
// Low multiplier for mouse influence on opacity
|
|
1802
|
-
MULTIPLIER_HIGH
|
|
1834
|
+
get MULTIPLIER_HIGH() {
|
|
1835
|
+
return .1 * this.BASE_1;
|
|
1836
|
+
}
|
|
1803
1837
|
},
|
|
1804
1838
|
CENTER_POSITION: 50,
|
|
1805
1839
|
// Center position percentage (50%)
|
|
1806
1840
|
HOVER_POSITION: {
|
|
1807
1841
|
DIVISOR_1: 2,
|
|
1808
1842
|
// Divisor for hover 1 position calculation
|
|
1809
|
-
DIVISOR_2
|
|
1843
|
+
get DIVISOR_2() {
|
|
1844
|
+
return .75 * this.DIVISOR_1;
|
|
1845
|
+
},
|
|
1810
1846
|
// Divisor for hover 2 position calculation
|
|
1811
|
-
MULTIPLIER_3
|
|
1847
|
+
get MULTIPLIER_3() {
|
|
1848
|
+
return .5 * this.DIVISOR_1;
|
|
1849
|
+
}
|
|
1812
1850
|
},
|
|
1813
|
-
BASE_LAYER_MULTIPLIER
|
|
1851
|
+
get BASE_LAYER_MULTIPLIER() {
|
|
1852
|
+
return .5;
|
|
1853
|
+
}
|
|
1814
1854
|
},
|
|
1815
1855
|
// Gradient opacity values for hover effects
|
|
1816
1856
|
GRADIENT_OPACITY: {
|
|
1817
1857
|
HOVER_1: {
|
|
1818
1858
|
BLACK_START: .3,
|
|
1819
1859
|
// Start opacity for black hover 1
|
|
1820
|
-
BLACK_MID
|
|
1860
|
+
get BLACK_MID() {
|
|
1861
|
+
return this.BLACK_START / 3;
|
|
1862
|
+
},
|
|
1821
1863
|
// Mid opacity for black hover 1
|
|
1822
1864
|
BLACK_STOP: 30,
|
|
1823
1865
|
// Stop percentage for black hover 1
|
|
1824
|
-
BLACK_END
|
|
1866
|
+
get BLACK_END() {
|
|
1867
|
+
return 2 * this.BLACK_STOP;
|
|
1868
|
+
},
|
|
1825
1869
|
// End percentage for black hover 1
|
|
1826
1870
|
WHITE_START: .5,
|
|
1827
1871
|
// Start opacity for white hover 1
|
|
1828
|
-
WHITE_STOP
|
|
1872
|
+
get WHITE_STOP() {
|
|
1873
|
+
return this.BLACK_END - 10;
|
|
1874
|
+
}
|
|
1829
1875
|
},
|
|
1830
1876
|
HOVER_2: {
|
|
1831
1877
|
BLACK_START: .4,
|
|
1832
1878
|
// Start opacity for black hover 2
|
|
1833
|
-
BLACK_MID
|
|
1879
|
+
get BLACK_MID() {
|
|
1880
|
+
return .375 * this.BLACK_START;
|
|
1881
|
+
},
|
|
1834
1882
|
// Mid opacity for black hover 2
|
|
1835
1883
|
BLACK_STOP: 40,
|
|
1836
1884
|
// Stop percentage for black hover 2
|
|
1837
|
-
BLACK_END
|
|
1885
|
+
get BLACK_END() {
|
|
1886
|
+
return 2 * this.BLACK_STOP;
|
|
1887
|
+
},
|
|
1838
1888
|
// End percentage for black hover 2
|
|
1839
1889
|
WHITE_START: 1,
|
|
1840
1890
|
// Start opacity for white hover 2
|
|
1841
|
-
WHITE_STOP
|
|
1891
|
+
get WHITE_STOP() {
|
|
1892
|
+
return this.BLACK_END;
|
|
1893
|
+
}
|
|
1842
1894
|
},
|
|
1843
1895
|
HOVER_3: {
|
|
1844
1896
|
BLACK_START: .5,
|
|
1845
1897
|
// Start opacity for black hover 3
|
|
1846
|
-
BLACK_MID
|
|
1898
|
+
get BLACK_MID() {
|
|
1899
|
+
return .4 * this.BLACK_START;
|
|
1900
|
+
},
|
|
1847
1901
|
// Mid opacity for black hover 3
|
|
1848
1902
|
BLACK_STOP: 50,
|
|
1849
1903
|
// Stop percentage for black hover 3
|
|
1850
|
-
BLACK_END
|
|
1904
|
+
get BLACK_END() {
|
|
1905
|
+
return 2 * this.BLACK_STOP;
|
|
1906
|
+
},
|
|
1851
1907
|
// End percentage for black hover 3
|
|
1852
1908
|
WHITE_START: 1,
|
|
1853
1909
|
// Start opacity for white hover 3
|
|
1854
|
-
WHITE_STOP
|
|
1910
|
+
get WHITE_STOP() {
|
|
1911
|
+
return this.BLACK_END;
|
|
1912
|
+
}
|
|
1855
1913
|
}
|
|
1856
1914
|
},
|
|
1857
1915
|
// Base and overlay gradient constants
|
|
@@ -1860,34 +1918,54 @@ const _includesInstanceProperty = getDefaultExportFromCjs((function(it) {
|
|
|
1860
1918
|
// Gradient angle in degrees
|
|
1861
1919
|
BLACK_START_BASE: .15,
|
|
1862
1920
|
// Base start opacity for black
|
|
1863
|
-
BLACK_START_MULTIPLIER
|
|
1921
|
+
get BLACK_START_MULTIPLIER() {
|
|
1922
|
+
return .02 * this.BLACK_START_BASE;
|
|
1923
|
+
},
|
|
1864
1924
|
// Multiplier for mouse X influence on start
|
|
1865
1925
|
BLACK_MID_BASE: .1,
|
|
1866
1926
|
// Base mid opacity for black
|
|
1867
|
-
BLACK_MID_MULTIPLIER
|
|
1927
|
+
get BLACK_MID_MULTIPLIER() {
|
|
1928
|
+
return .02 * this.BLACK_MID_BASE;
|
|
1929
|
+
},
|
|
1868
1930
|
// Multiplier for mouse Y influence on mid
|
|
1869
1931
|
BLACK_MID_STOP: 50,
|
|
1870
1932
|
// Mid stop percentage
|
|
1871
|
-
BLACK_END_BASE
|
|
1933
|
+
get BLACK_END_BASE() {
|
|
1934
|
+
return 1.2 * this.BLACK_START_BASE;
|
|
1935
|
+
},
|
|
1872
1936
|
// Base end opacity for black
|
|
1873
|
-
BLACK_END_MULTIPLIER
|
|
1937
|
+
get BLACK_END_MULTIPLIER() {
|
|
1938
|
+
return .022 * this.BLACK_END_BASE;
|
|
1939
|
+
},
|
|
1874
1940
|
// Multiplier for mouse X influence on end
|
|
1875
|
-
WHITE_OPACITY
|
|
1941
|
+
get WHITE_OPACITY() {
|
|
1942
|
+
return .666 * this.BLACK_START_BASE;
|
|
1943
|
+
}
|
|
1876
1944
|
},
|
|
1877
1945
|
OVERLAY_GRADIENT: {
|
|
1878
1946
|
BLACK_START_BASE: .12,
|
|
1879
1947
|
// Base start opacity for black overlay
|
|
1880
|
-
BLACK_START_MULTIPLIER
|
|
1948
|
+
get BLACK_START_MULTIPLIER() {
|
|
1949
|
+
return .025 * this.BLACK_START_BASE;
|
|
1950
|
+
},
|
|
1881
1951
|
// Multiplier for mouse X influence on start
|
|
1882
|
-
BLACK_MID
|
|
1952
|
+
get BLACK_MID() {
|
|
1953
|
+
return .5 * this.BLACK_START_BASE;
|
|
1954
|
+
},
|
|
1883
1955
|
// Mid opacity for black overlay
|
|
1884
1956
|
BLACK_MID_STOP: 40,
|
|
1885
1957
|
// Mid stop percentage
|
|
1886
|
-
BLACK_END_BASE
|
|
1958
|
+
get BLACK_END_BASE() {
|
|
1959
|
+
return 1.25 * this.BLACK_START_BASE;
|
|
1960
|
+
},
|
|
1887
1961
|
// Base end opacity for black overlay
|
|
1888
|
-
BLACK_END_MULTIPLIER
|
|
1962
|
+
get BLACK_END_MULTIPLIER() {
|
|
1963
|
+
return .02 * this.BLACK_END_BASE;
|
|
1964
|
+
},
|
|
1889
1965
|
// Multiplier for mouse Y influence on end
|
|
1890
|
-
WHITE_OPACITY
|
|
1966
|
+
get WHITE_OPACITY() {
|
|
1967
|
+
return .416 * this.BLACK_START_BASE;
|
|
1968
|
+
}
|
|
1891
1969
|
},
|
|
1892
1970
|
// Overlay highlight constants
|
|
1893
1971
|
OVERLAY_HIGHLIGHT: {
|
|
@@ -1897,9 +1975,13 @@ const _includesInstanceProperty = getDefaultExportFromCjs((function(it) {
|
|
|
1897
1975
|
// Y position percentage
|
|
1898
1976
|
WHITE_OPACITY: .4,
|
|
1899
1977
|
// White opacity in gradient
|
|
1900
|
-
STOP
|
|
1978
|
+
get STOP() {
|
|
1979
|
+
return 150 * this.WHITE_OPACITY;
|
|
1980
|
+
},
|
|
1901
1981
|
// Stop percentage
|
|
1902
|
-
OPACITY_MULTIPLIER
|
|
1982
|
+
get OPACITY_MULTIPLIER() {
|
|
1983
|
+
return 1.75 * this.WHITE_OPACITY;
|
|
1984
|
+
}
|
|
1903
1985
|
},
|
|
1904
1986
|
// Displacement and aberration multipliers
|
|
1905
1987
|
MULTIPLIERS: {
|
|
@@ -2009,11 +2091,7 @@ function useAccordion(initialProps) {
|
|
|
2009
2091
|
};
|
|
2010
2092
|
}
|
|
2011
2093
|
|
|
2012
|
-
const {CONSTANTS: CONSTANTS$2} = ATOMIX_GLASS,
|
|
2013
|
-
if (!pos1 || !pos2 || "number" != typeof pos1.x || "number" != typeof pos1.y || "number" != typeof pos2.x || "number" != typeof pos2.y) return 0;
|
|
2014
|
-
const deltaX = pos1.x - pos2.x, deltaY = pos1.y - pos2.y;
|
|
2015
|
-
return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
2016
|
-
}, calculateElementCenter = rect => rect ? {
|
|
2094
|
+
const {CONSTANTS: CONSTANTS$2} = ATOMIX_GLASS, calculateElementCenter = rect => rect ? {
|
|
2017
2095
|
x: rect.left + rect.width / 2,
|
|
2018
2096
|
y: rect.top + rect.height / 2
|
|
2019
2097
|
} : {
|
|
@@ -2085,7 +2163,16 @@ const {CONSTANTS: CONSTANTS$2} = ATOMIX_GLASS, calculateDistance = (pos1, pos2)
|
|
|
2085
2163
|
// Silently handle errors
|
|
2086
2164
|
}
|
|
2087
2165
|
return CONSTANTS$2.DEFAULT_CORNER_RADIUS;
|
|
2088
|
-
},
|
|
2166
|
+
}, smoothstep = t => {
|
|
2167
|
+
const clamped = Math.max(0, Math.min(1, t));
|
|
2168
|
+
return clamped * clamped * (3 - 2 * clamped);
|
|
2169
|
+
}, lerp$1 = (a, b, t) => a + (b - a) * t, softClamp = (value, max) => max <= 0 ? 0 : max * (1 - Math.exp(-value / max)), calculateSpring = (current, target, velocity, stiffness = .1, damping = .8) => {
|
|
2170
|
+
const newVelocity = (velocity + (target - current) * stiffness) * damping;
|
|
2171
|
+
return {
|
|
2172
|
+
value: current + newVelocity,
|
|
2173
|
+
velocity: newVelocity
|
|
2174
|
+
};
|
|
2175
|
+
}, getDisplacementMap = (mode, displacementMap, polarDisplacementMap, prominentDisplacementMap, shaderMapUrl) => {
|
|
2089
2176
|
switch (mode) {
|
|
2090
2177
|
case "standard":
|
|
2091
2178
|
return displacementMap;
|
|
@@ -2476,6 +2563,9 @@ shaderTime: shaderTime, withTimeAnimation: withTimeAnimation = !1, animationSpee
|
|
|
2476
2563
|
}), jsx("div", {
|
|
2477
2564
|
ref: contentRef,
|
|
2478
2565
|
className: ATOMIX_GLASS.CONTENT_CLASS,
|
|
2566
|
+
style: {
|
|
2567
|
+
transform: "var(--atomix-glass-child-parallax, none)"
|
|
2568
|
+
},
|
|
2479
2569
|
children: children
|
|
2480
2570
|
}) ]
|
|
2481
2571
|
})
|
|
@@ -2600,51 +2690,26 @@ class {
|
|
|
2600
2690
|
}
|
|
2601
2691
|
}, updateAtomixGlassStyles = (wrapperElement, containerElement, params) => {
|
|
2602
2692
|
if (!wrapperElement && !containerElement) return;
|
|
2603
|
-
|
|
2693
|
+
if (!validateGlassSize(params.glassSize)) return;
|
|
2694
|
+
const {mouseOffset: mouseOffset, globalMousePosition: globalMousePosition, glassSize: glassSize, isHovered: isHovered, isActive: isActive, isOverLight: isOverLight, baseOverLightConfig: baseOverLightConfig, effectiveBorderRadius: effectiveBorderRadius, effectiveWithoutEffects: effectiveWithoutEffects, effectiveReducedMotion: effectiveReducedMotion, elasticity: elasticity, elasticTranslation: elasticTranslation, elasticVelocity: elasticVelocity, mouseVelocity: mouseVelocity, directionalScale: directionalScale, scaleBase: scaleBase, onClick: onClick, withLiquidBlur: withLiquidBlur, blurAmount: blurAmount = ATOMIX_GLASS.DEFAULTS.BLUR_AMOUNT, saturation: saturation = ATOMIX_GLASS.DEFAULTS.SATURATION, padding: padding = ATOMIX_GLASS.DEFAULTS.PADDING, isFixedOrSticky: isFixedOrSticky = !1} = params, mouseInfluence = calculateMouseInfluence(mouseOffset), hoverIntensity = isHovered ? 1.4 : 1, activeIntensity = isActive ? 1.6 : 1, overLightConfig = {
|
|
2604
2695
|
opacity: baseOverLightConfig.opacity * hoverIntensity * activeIntensity,
|
|
2605
2696
|
contrast: Math.min(1.6, baseOverLightConfig.contrast + .1 * mouseInfluence),
|
|
2606
2697
|
brightness: Math.min(1.1, baseOverLightConfig.brightness + .05 * mouseInfluence),
|
|
2607
2698
|
shadowIntensity: Math.min(1.2, Math.max(.5, baseOverLightConfig.shadowIntensity + .2 * mouseInfluence)),
|
|
2608
2699
|
borderOpacity: Math.min(1, Math.max(.3, baseOverLightConfig.borderOpacity + .1 * mouseInfluence)),
|
|
2609
2700
|
saturationBoost: baseOverLightConfig.saturationBoost
|
|
2610
|
-
}
|
|
2611
|
-
|
|
2612
|
-
|
|
2701
|
+
}, scaleX = directionalScale.x * scaleBase, scaleY = directionalScale.y * scaleBase, transformStyle = effectiveWithoutEffects ? `scale(${scaleBase})` : `translate(${elasticTranslation.x}px, ${elasticTranslation.y}px) scaleX(${scaleX}) scaleY(${scaleY})`, stretchMagnitude = ((pos1, pos2) => {
|
|
2702
|
+
if (!pos1 || !pos2 || "number" != typeof pos1.x || "number" != typeof pos1.y || "number" != typeof pos2.x || "number" != typeof pos2.y) return 0;
|
|
2703
|
+
const deltaX = pos1.x - pos2.x, deltaY = pos1.y - pos2.y;
|
|
2704
|
+
return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
2705
|
+
})({
|
|
2613
2706
|
x: 0,
|
|
2614
2707
|
y: 0
|
|
2615
|
-
};
|
|
2616
|
-
// Calculate
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
if (globalMousePosition.x && globalMousePosition.y && validateGlassSize(glassSize)) {
|
|
2621
|
-
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({
|
|
2622
|
-
x: edgeDistanceX,
|
|
2623
|
-
y: edgeDistanceY
|
|
2624
|
-
}, {
|
|
2625
|
-
x: 0,
|
|
2626
|
-
y: 0
|
|
2627
|
-
}), rawT = edgeDistance > ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE ? 0 : 1 - edgeDistance / ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE, fadeInFactor = (t => {
|
|
2628
|
-
const clamped = Math.max(0, Math.min(1, t));
|
|
2629
|
-
return clamped * clamped * (3 - 2 * clamped);
|
|
2630
|
-
})(rawT);
|
|
2631
|
-
// Directional scale
|
|
2632
|
-
if (elasticTranslation = {
|
|
2633
|
-
x: deltaX * elasticity * .1 * fadeInFactor,
|
|
2634
|
-
y: deltaY * elasticity * .1 * fadeInFactor
|
|
2635
|
-
}, !isOverLight && edgeDistance <= ATOMIX_GLASS.CONSTANTS.ACTIVATION_ZONE) {
|
|
2636
|
-
const centerDistance = calculateDistance(globalMousePosition, center);
|
|
2637
|
-
if (centerDistance > 0) {
|
|
2638
|
-
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);
|
|
2639
|
-
computedDirectionalScale = `scaleX(${Math.max(.85, softScaleX)}) scaleY(${Math.max(.85, softScaleY)})`;
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2642
|
-
}
|
|
2643
|
-
}
|
|
2644
|
-
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}`;
|
|
2645
|
-
// Update Wrapper Styles (glassVars)
|
|
2646
|
-
if (wrapperElement) {
|
|
2647
|
-
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 = {
|
|
2708
|
+
}, elasticTranslation), tensionFactor = smoothstep(stretchMagnitude / 80), lightingContrast = Math.min(1.8, overLightConfig.contrast + .2 * tensionFactor), lightingBrightness = Math.min(1.2, overLightConfig.brightness + .1 * tensionFactor);
|
|
2709
|
+
// Calculate mouse influence
|
|
2710
|
+
// Update Wrapper Styles (glassVars)
|
|
2711
|
+
if (wrapperElement) {
|
|
2712
|
+
const mx = mouseOffset.x, my = mouseOffset.y, absMx = Math.abs(mx), absMy = Math.abs(my), GRADIENT = ATOMIX_GLASS.CONSTANTS.GRADIENT, velocityRotation = (mouseVelocity.x + elasticVelocity.x) * (GRADIENT.VELOCITY_ANGLE_MULTIPLIER || 2.5), borderGradientAngle = GRADIENT.BASE_ANGLE + mx * GRADIENT.ANGLE_MULTIPLIER + velocityRotation, chromaticOffset = GRADIENT.CHROMATIC_OFFSET || 1.5, angleR = borderGradientAngle - chromaticOffset, angleB = borderGradientAngle + chromaticOffset, 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), tensionGlow = 1 + .5 * tensionFactor, borderOpacities = [ (GRADIENT.BORDER_OPACITY.BASE_1 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_LOW) * tensionGlow, (GRADIENT.BORDER_OPACITY.BASE_2 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_HIGH) * tensionGlow, (GRADIENT.BORDER_OPACITY.BASE_3 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_LOW) * tensionGlow, (GRADIENT.BORDER_OPACITY.BASE_4 + absMx * GRADIENT.BORDER_OPACITY.MULTIPLIER_HIGH) * tensionGlow ], configBorderOpacity = overLightConfig.borderOpacity, whiteColor = ATOMIX_GLASS.CONSTANTS.PALETTE.WHITE, blackColor = ATOMIX_GLASS.CONSTANTS.PALETTE.BLACK, hoverPositions = {
|
|
2648
2713
|
hover1: {
|
|
2649
2714
|
x: GRADIENT.CENTER_POSITION + mx / GRADIENT.HOVER_POSITION.DIVISOR_1,
|
|
2650
2715
|
y: GRADIENT.CENTER_POSITION + my / GRADIENT.HOVER_POSITION.DIVISOR_1
|
|
@@ -2667,10 +2732,16 @@ class {
|
|
|
2667
2732
|
base: isOverLight ? overLightConfig.opacity : 0,
|
|
2668
2733
|
over: isOverLight ? 1.1 * overLightConfig.opacity : 0
|
|
2669
2734
|
}, style = wrapperElement.style;
|
|
2670
|
-
style.setProperty("--atomix-glass-transform", transformStyle || "none")
|
|
2671
|
-
//
|
|
2672
|
-
|
|
2673
|
-
style.setProperty("--atomix-glass-
|
|
2735
|
+
style.setProperty("--atomix-glass-transform", transformStyle || "none");
|
|
2736
|
+
// Parallax for content (liquid refraction feel)
|
|
2737
|
+
const parallaxFactor = .38 + .12 * tensionFactor;
|
|
2738
|
+
style.setProperty("--atomix-glass-child-parallax", `translate(${elasticTranslation.x * -parallaxFactor}px, ${elasticTranslation.y * -parallaxFactor}px)`),
|
|
2739
|
+
style.setProperty("--atomix-glass-contrast", lightingContrast.toString()), style.setProperty("--atomix-glass-brightness", lightingBrightness.toString()),
|
|
2740
|
+
// ── Chromatic Rim Lighting ──────────────────────────────────────
|
|
2741
|
+
// Layer 1: Core White/Blue highlight
|
|
2742
|
+
style.setProperty("--atomix-glass-border-gradient-1", `linear-gradient(${angleB}deg, rgba(${whiteColor}, 0) 0%, rgba(${whiteColor}, ${(borderOpacities[0] ?? 1) * configBorderOpacity}) ${borderStop1}%, rgba(${whiteColor}, ${(borderOpacities[1] ?? 1) * configBorderOpacity}) ${borderStop2}%, rgba(${whiteColor}, 0) 100%)`),
|
|
2743
|
+
// Layer 2: Subtle Red/Warm highlight (offset angle)
|
|
2744
|
+
style.setProperty("--atomix-glass-border-gradient-2", `linear-gradient(${angleR}deg, rgba(${whiteColor}, 0) 0%, rgba(${whiteColor}, ${(borderOpacities[2] ?? 1) * configBorderOpacity}) ${borderStop1}%, rgba(${whiteColor}, ${(borderOpacities[3] ?? 1) * configBorderOpacity}) ${borderStop2}%, rgba(${whiteColor}, 0) 100%)`),
|
|
2674
2745
|
// Hover gradients
|
|
2675
2746
|
style.setProperty("--atomix-glass-hover-1-gradient", isOverLight ? `radial-gradient(circle at ${hoverPositions.hover1.x}% ${hoverPositions.hover1.y}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_1.BLACK_START}) 0%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_1.BLACK_MID}) ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_1.BLACK_STOP}%, rgba(${blackColor}, 0) ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_1.BLACK_END}%)` : `radial-gradient(circle at ${hoverPositions.hover1.x}% ${hoverPositions.hover1.y}%, rgba(${whiteColor}, ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_1.WHITE_START}) 0%, rgba(${whiteColor}, 0) ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_1.WHITE_STOP}%)`),
|
|
2676
2747
|
style.setProperty("--atomix-glass-hover-2-gradient", isOverLight ? `radial-gradient(circle at ${hoverPositions.hover2.x}% ${hoverPositions.hover2.y}%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_2.BLACK_START}) 0%, rgba(${blackColor}, ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_2.BLACK_MID}) ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_2.BLACK_STOP}%, rgba(${blackColor}, 0) ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_2.BLACK_END}%)` : `radial-gradient(circle at ${hoverPositions.hover2.x}% ${hoverPositions.hover2.y}%, rgba(${whiteColor}, ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_2.WHITE_START}) 0%, rgba(${whiteColor}, 0) ${ATOMIX_GLASS.CONSTANTS.GRADIENT_OPACITY.HOVER_2.WHITE_STOP}%)`),
|
|
@@ -2698,7 +2769,7 @@ class {
|
|
|
2698
2769
|
flowBlur: blurAmount * FLOW_BLUR_MULTIPLIER
|
|
2699
2770
|
};
|
|
2700
2771
|
if (withLiquidBlur && rect) {
|
|
2701
|
-
const mouseInfluence = calculateMouseInfluence(mouseOffset), maxBlur = blurAmount * MAX_BLUR_RELATIVE, baseBlur =
|
|
2772
|
+
const mouseInfluence = calculateMouseInfluence(mouseOffset), maxBlur = blurAmount * MAX_BLUR_RELATIVE, baseBlur = softClamp(blurAmount + mouseInfluence * blurAmount * MOUSE_INFLUENCE_BLUR_FACTOR, maxBlur), edgeBlur = softClamp(baseBlur * (.8 + mouseInfluence * EDGE_INTENSITY_MOUSE_FACTOR * .4), maxBlur), centerBlur = softClamp(baseBlur * (.3 + mouseInfluence * CENTER_INTENSITY_MOUSE_FACTOR * .3), maxBlur), flowBlur = softClamp(baseBlur * FLOW_BLUR_MULTIPLIER, maxBlur);
|
|
2702
2773
|
liquidBlur = {
|
|
2703
2774
|
baseBlur: clampBlur(baseBlur),
|
|
2704
2775
|
edgeBlur: clampBlur(edgeBlur),
|
|
@@ -2707,9 +2778,10 @@ class {
|
|
|
2707
2778
|
};
|
|
2708
2779
|
}
|
|
2709
2780
|
// Backdrop filter
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2781
|
+
const dynamicSaturation = saturation + 40 * tensionFactor + 15 * (liquidBlur.baseBlur || 0);
|
|
2782
|
+
let backdropFilterString = "";
|
|
2783
|
+
const area = rect ? rect.width * rect.height : 0;
|
|
2784
|
+
backdropFilterString = !withLiquidBlur || effectiveReducedMotion || effectiveWithoutEffects || area > 18e4 ? `blur(${clampBlur(Math.max(liquidBlur.baseBlur, .8 * liquidBlur.edgeBlur, 1.1 * liquidBlur.centerBlur, .9 * liquidBlur.flowBlur))}px) saturate(${Math.min(dynamicSaturation, 250)}%) contrast(${lightingContrast}) brightness(${lightingBrightness})` : `blur(${clampBlur(.4 * liquidBlur.baseBlur + .25 * liquidBlur.edgeBlur + .15 * liquidBlur.centerBlur + .2 * liquidBlur.flowBlur)}px) saturate(${Math.min(dynamicSaturation, 250)}%) contrast(${lightingContrast}) brightness(${lightingBrightness})`;
|
|
2713
2785
|
// Container variables
|
|
2714
2786
|
const style = containerElement.style;
|
|
2715
2787
|
style.setProperty("--atomix-glass-container-padding", padding), style.setProperty("--atomix-glass-container-radius", `${effectiveBorderRadius}px`),
|
|
@@ -2888,7 +2960,24 @@ withTimeAnimation = ATOMIX_GLASS.DEFAULTS.WITH_TIME_ANIMATION, animationSpeed: a
|
|
|
2888
2960
|
}), targetGlobalMousePositionRef = useRef({
|
|
2889
2961
|
x: 0,
|
|
2890
2962
|
y: 0
|
|
2891
|
-
}), lerpRafRef = useRef(null), lerpActiveRef = useRef(!1), [dynamicBorderRadius, setDynamicCornerRadius] = useState(CONSTANTS.DEFAULT_CORNER_RADIUS),
|
|
2963
|
+
}), lerpRafRef = useRef(null), lerpActiveRef = useRef(!1), [dynamicBorderRadius, setDynamicCornerRadius] = useState(CONSTANTS.DEFAULT_CORNER_RADIUS), elasticTranslationRef = useRef({
|
|
2964
|
+
x: 0,
|
|
2965
|
+
y: 0
|
|
2966
|
+
}), elasticVelocityRef = useRef({
|
|
2967
|
+
x: 0,
|
|
2968
|
+
y: 0
|
|
2969
|
+
}), directionalScaleRef = useRef({
|
|
2970
|
+
x: 1,
|
|
2971
|
+
y: 1
|
|
2972
|
+
}), scaleVelocityRef = useRef({
|
|
2973
|
+
x: 0,
|
|
2974
|
+
y: 0
|
|
2975
|
+
});
|
|
2976
|
+
useRef(0);
|
|
2977
|
+
const mouseVelocityRef = useRef({
|
|
2978
|
+
x: 0,
|
|
2979
|
+
y: 0
|
|
2980
|
+
}), [userPrefersReducedMotion, setUserPrefersReducedMotion] = useState(!1), [userPrefersHighContrast, setUserPrefersHighContrast] = useState(!1), [detectedOverLight, setDetectedOverLight] = useState(!1), animationFrameIdRef = useRef(null), animationStartTimeRef = useRef(0), elapsedTimeRef = useRef(0), shaderTimeRef = useRef(0), fbmConfig = useMemo((() => {
|
|
2892
2981
|
// If quality preset is provided, use it as base
|
|
2893
2982
|
const preset = (quality = distortionQuality, ATOMIX_GLASS.CONSTANTS.DISTORTION_QUALITY_PRESETS[quality]);
|
|
2894
2983
|
// Override with custom values if provided
|
|
@@ -3173,57 +3262,85 @@ withTimeAnimation = ATOMIX_GLASS.DEFAULTS.WITH_TIME_ANIMATION, animationSpeed: a
|
|
|
3173
3262
|
return "undefined" == typeof process || process.env, finalConfig;
|
|
3174
3263
|
}
|
|
3175
3264
|
return "undefined" == typeof process || process.env, baseConfig;
|
|
3176
|
-
}), [ overLight, getEffectiveOverLight, isHovered, isActive, validateConfigValue, debugOverLight ]), transformStyle = useMemo((() => effectiveWithoutEffects || isActive && Boolean(onClick) ? "scale(0.
|
|
3265
|
+
}), [ overLight, getEffectiveOverLight, isHovered, isActive, validateConfigValue, debugOverLight ]), transformStyle = useMemo((() => effectiveWithoutEffects || isActive && Boolean(onClick) ? "scale(0.99)" : "scale(1)"), [ effectiveWithoutEffects, isActive, onClick ]), updateRectRef = useRef(null), stopLerpLoop = useCallback((() => {
|
|
3177
3266
|
lerpActiveRef.current = !1, null !== lerpRafRef.current && (cancelAnimationFrame(lerpRafRef.current),
|
|
3178
3267
|
lerpRafRef.current = null);
|
|
3179
3268
|
}), []), startLerpLoop = useCallback((() => {
|
|
3180
3269
|
if (lerpActiveRef.current) return;
|
|
3181
|
-
lerpActiveRef.current = !0;
|
|
3182
|
-
|
|
3270
|
+
lerpActiveRef.current = !0, CONSTANTS.LERP_FACTOR;
|
|
3271
|
+
// 0.08 – lower = more viscous
|
|
3272
|
+
const tick = () => {
|
|
3183
3273
|
if (!lerpActiveRef.current) return;
|
|
3184
3274
|
if (!glassRef.current) return void (lerpActiveRef.current = !1);
|
|
3185
|
-
const cur = internalMouseOffsetRef.current, tgt = targetMouseOffsetRef.current,
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
},
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
// Final update and stop
|
|
3193
|
-
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
3194
|
-
mouseOffset: internalMouseOffsetRef.current,
|
|
3195
|
-
globalMousePosition: internalGlobalMousePositionRef.current,
|
|
3196
|
-
glassSize: glassSize,
|
|
3197
|
-
isHovered: isHovered,
|
|
3198
|
-
isActive: isActive,
|
|
3199
|
-
isOverLight: overLightConfig.isOverLight,
|
|
3200
|
-
baseOverLightConfig: overLightConfig,
|
|
3201
|
-
effectiveBorderRadius: effectiveBorderRadius,
|
|
3202
|
-
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
3203
|
-
effectiveReducedMotion: effectiveReducedMotion,
|
|
3204
|
-
elasticity: elasticity,
|
|
3205
|
-
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
3206
|
-
onClick: onClick,
|
|
3207
|
-
withLiquidBlur: withLiquidBlur,
|
|
3208
|
-
blurAmount: blurAmount,
|
|
3209
|
-
saturation: saturation,
|
|
3210
|
-
padding: padding,
|
|
3211
|
-
isFixedOrSticky: isFixedOrSticky
|
|
3212
|
-
}), void stopLerpLoop();
|
|
3213
|
-
// Smooth step
|
|
3214
|
-
internalMouseOffsetRef.current = {
|
|
3215
|
-
x: lerp$1(cur.x, tgt.x, LERP_T),
|
|
3216
|
-
y: lerp$1(cur.y, tgt.y, LERP_T)
|
|
3275
|
+
const cur = internalMouseOffsetRef.current, tgt = targetMouseOffsetRef.current, springX = calculateSpring(cur.x, tgt.x, mouseVelocityRef.current.x, CONSTANTS.LERP_FACTOR, CONSTANTS.ELASTICITY_DAMPING), springY = calculateSpring(cur.y, tgt.y, mouseVelocityRef.current.y, CONSTANTS.LERP_FACTOR, CONSTANTS.ELASTICITY_DAMPING);
|
|
3276
|
+
internalMouseOffsetRef.current = {
|
|
3277
|
+
x: springX.value,
|
|
3278
|
+
y: springY.value
|
|
3279
|
+
}, mouseVelocityRef.current = {
|
|
3280
|
+
x: springX.velocity,
|
|
3281
|
+
y: springY.velocity
|
|
3217
3282
|
};
|
|
3218
3283
|
const curG = internalGlobalMousePositionRef.current, tgtG = targetGlobalMousePositionRef.current;
|
|
3219
3284
|
internalGlobalMousePositionRef.current = {
|
|
3220
|
-
x: lerp$1(curG.x, tgtG.x,
|
|
3221
|
-
y: lerp$1(curG.y, tgtG.y,
|
|
3285
|
+
x: lerp$1(curG.x, tgtG.x, CONSTANTS.LERP_FACTOR),
|
|
3286
|
+
y: lerp$1(curG.y, tgtG.y, CONSTANTS.LERP_FACTOR)
|
|
3287
|
+
};
|
|
3288
|
+
// ── Calculate Elastic Physics ─────────────────────────────────────
|
|
3289
|
+
let targetElasticTranslation = {
|
|
3290
|
+
x: 0,
|
|
3291
|
+
y: 0
|
|
3292
|
+
}, targetScale = {
|
|
3293
|
+
x: 1,
|
|
3294
|
+
y: 1
|
|
3295
|
+
};
|
|
3296
|
+
if (!effectiveWithoutEffects && glassRef.current) {
|
|
3297
|
+
const rect = cachedRectRef.current || glassRef.current.getBoundingClientRect(), center = calculateElementCenter(rect), globalPos = internalGlobalMousePositionRef.current;
|
|
3298
|
+
if (globalPos.x && globalPos.y) {
|
|
3299
|
+
const deltaX = globalPos.x - center.x, deltaY = globalPos.y - center.y, edgeDistanceX = Math.max(0, Math.abs(deltaX) - rect.width / 2), edgeDistanceY = Math.max(0, Math.abs(deltaY) - rect.height / 2), edgeDistance = Math.sqrt(edgeDistanceX * edgeDistanceX + edgeDistanceY * edgeDistanceY), activationZone = CONSTANTS.ACTIVATION_ZONE, rawT = edgeDistance > activationZone ? 0 : 1 - edgeDistance / activationZone, fadeInFactor = smoothstep(rawT);
|
|
3300
|
+
// Scale stretch logic (liquid surface tension)
|
|
3301
|
+
if (targetElasticTranslation = {
|
|
3302
|
+
x: deltaX * elasticity * CONSTANTS.ELASTICITY_TRANSLATION_FACTOR * fadeInFactor,
|
|
3303
|
+
y: deltaY * elasticity * CONSTANTS.ELASTICITY_TRANSLATION_FACTOR * fadeInFactor
|
|
3304
|
+
}, edgeDistance <= activationZone) {
|
|
3305
|
+
const centerDistance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
3306
|
+
if (centerDistance > 0) {
|
|
3307
|
+
const nx = deltaX / centerDistance, ny = deltaY / centerDistance, stretchIntensity = Math.min(centerDistance / 350, 1) * elasticity * rawT, mag = 1 + .06 * stretchIntensity;
|
|
3308
|
+
targetScale = {
|
|
3309
|
+
x: mag + Math.abs(nx) * stretchIntensity * CONSTANTS.ELASTICITY_STRETCH_RATIO,
|
|
3310
|
+
y: mag + Math.abs(ny) * stretchIntensity * CONSTANTS.ELASTICITY_STRETCH_RATIO
|
|
3311
|
+
},
|
|
3312
|
+
// Maintain liquid volume by compressing the perpendicular axis
|
|
3313
|
+
targetScale.x -= Math.abs(ny) * stretchIntensity * .15, targetScale.y -= Math.abs(nx) * stretchIntensity * .15;
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
// Integrate Elastic Translation Spring
|
|
3319
|
+
const springTX = calculateSpring(elasticTranslationRef.current.x, targetElasticTranslation.x, elasticVelocityRef.current.x, CONSTANTS.ELASTICITY_STIFFNESS, CONSTANTS.ELASTICITY_DAMPING), springTY = calculateSpring(elasticTranslationRef.current.y, targetElasticTranslation.y, elasticVelocityRef.current.y, CONSTANTS.ELASTICITY_STIFFNESS, CONSTANTS.ELASTICITY_DAMPING);
|
|
3320
|
+
elasticTranslationRef.current = {
|
|
3321
|
+
x: springTX.value,
|
|
3322
|
+
y: springTY.value
|
|
3323
|
+
}, elasticVelocityRef.current = {
|
|
3324
|
+
x: springTX.velocity,
|
|
3325
|
+
y: springTY.velocity
|
|
3326
|
+
};
|
|
3327
|
+
// Integrate Scale Spring
|
|
3328
|
+
const springSX = calculateSpring(directionalScaleRef.current.x, targetScale.x, scaleVelocityRef.current.x, CONSTANTS.ELASTICITY_STIFFNESS, CONSTANTS.ELASTICITY_DAMPING), springSY = calculateSpring(directionalScaleRef.current.y, targetScale.y, scaleVelocityRef.current.y, CONSTANTS.ELASTICITY_STIFFNESS, CONSTANTS.ELASTICITY_DAMPING);
|
|
3329
|
+
directionalScaleRef.current = {
|
|
3330
|
+
x: springSX.value,
|
|
3331
|
+
y: springSY.value
|
|
3332
|
+
}, scaleVelocityRef.current = {
|
|
3333
|
+
x: springSX.velocity,
|
|
3334
|
+
y: springSY.velocity
|
|
3222
3335
|
},
|
|
3223
3336
|
// Imperative style update
|
|
3224
3337
|
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
3225
3338
|
mouseOffset: internalMouseOffsetRef.current,
|
|
3226
3339
|
globalMousePosition: internalGlobalMousePositionRef.current,
|
|
3340
|
+
elasticTranslation: elasticTranslationRef.current,
|
|
3341
|
+
elasticVelocity: elasticVelocityRef.current,
|
|
3342
|
+
mouseVelocity: mouseVelocityRef.current,
|
|
3343
|
+
directionalScale: directionalScaleRef.current,
|
|
3227
3344
|
glassSize: glassSize,
|
|
3228
3345
|
isHovered: isHovered,
|
|
3229
3346
|
isActive: isActive,
|
|
@@ -3233,17 +3350,16 @@ withTimeAnimation = ATOMIX_GLASS.DEFAULTS.WITH_TIME_ANIMATION, animationSpeed: a
|
|
|
3233
3350
|
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
3234
3351
|
effectiveReducedMotion: effectiveReducedMotion,
|
|
3235
3352
|
elasticity: elasticity,
|
|
3236
|
-
|
|
3353
|
+
scaleBase: isActive && Boolean(onClick) ? .99 : 1,
|
|
3237
3354
|
onClick: onClick,
|
|
3238
3355
|
withLiquidBlur: withLiquidBlur,
|
|
3239
3356
|
blurAmount: blurAmount,
|
|
3240
3357
|
saturation: saturation,
|
|
3241
3358
|
padding: padding,
|
|
3242
3359
|
isFixedOrSticky: isFixedOrSticky
|
|
3243
|
-
}), lerpRafRef.current = requestAnimationFrame(tick);
|
|
3360
|
+
}), Math.abs(mouseVelocityRef.current.x) < .001 && Math.abs(mouseVelocityRef.current.y) < .001 && Math.abs(elasticVelocityRef.current.x) < .001 && Math.abs(elasticVelocityRef.current.y) < .001 && Math.abs(scaleVelocityRef.current.x) < .001 && Math.abs(scaleVelocityRef.current.y) < .001 && Math.abs(internalMouseOffsetRef.current.x - targetMouseOffsetRef.current.x) < .001 && Math.abs(internalMouseOffsetRef.current.y - targetMouseOffsetRef.current.y) < .001 ? stopLerpLoop() : lerpRafRef.current = requestAnimationFrame(tick);
|
|
3244
3361
|
};
|
|
3245
|
-
|
|
3246
|
-
lerpRafRef.current = requestAnimationFrame(tick);
|
|
3362
|
+
lerpRafRef.current = requestAnimationFrame(tick);
|
|
3247
3363
|
}), [ glassRef, wrapperRef, glassSize, isHovered, isActive, overLightConfig, effectiveBorderRadius, effectiveWithoutEffects, effectiveReducedMotion, elasticity, onClick, withLiquidBlur, blurAmount, saturation, padding, isFixedOrSticky, stopLerpLoop ]), handleGlobalMousePosition = useCallback((globalPos => {
|
|
3248
3364
|
if (externalGlobalMousePosition && externalMouseOffset) return;
|
|
3249
3365
|
if (effectiveWithoutEffects) return;
|
|
@@ -3290,6 +3406,11 @@ withTimeAnimation = ATOMIX_GLASS.DEFAULTS.WITH_TIME_ANIMATION, animationSpeed: a
|
|
|
3290
3406
|
updateAtomixGlassStyles(wrapperRef?.current || null, glassRef.current, {
|
|
3291
3407
|
mouseOffset: externalMouseOffset || internalMouseOffsetRef.current,
|
|
3292
3408
|
globalMousePosition: externalGlobalMousePosition || internalGlobalMousePositionRef.current,
|
|
3409
|
+
elasticTranslation: elasticTranslationRef.current,
|
|
3410
|
+
elasticVelocity: elasticVelocityRef.current,
|
|
3411
|
+
mouseVelocity: mouseVelocityRef.current,
|
|
3412
|
+
directionalScale: directionalScaleRef.current,
|
|
3413
|
+
scaleBase: isActive && Boolean(onClick) ? .96 : 1,
|
|
3293
3414
|
glassSize: glassSize,
|
|
3294
3415
|
isHovered: isHovered,
|
|
3295
3416
|
isActive: isActive,
|
|
@@ -3299,7 +3420,6 @@ withTimeAnimation = ATOMIX_GLASS.DEFAULTS.WITH_TIME_ANIMATION, animationSpeed: a
|
|
|
3299
3420
|
effectiveWithoutEffects: effectiveWithoutEffects,
|
|
3300
3421
|
effectiveReducedMotion: effectiveReducedMotion,
|
|
3301
3422
|
elasticity: elasticity,
|
|
3302
|
-
directionalScale: isActive && Boolean(onClick) ? "scale(0.96)" : "scale(1)",
|
|
3303
3423
|
onClick: onClick,
|
|
3304
3424
|
withLiquidBlur: withLiquidBlur,
|
|
3305
3425
|
blurAmount: blurAmount,
|
|
@@ -4265,7 +4385,7 @@ function getDevicePreset(presetName) {
|
|
|
4265
4385
|
"aria-label": ariaLabel,
|
|
4266
4386
|
"aria-describedby": ariaDescribedBy,
|
|
4267
4387
|
"aria-disabled": !(!onClick || !effectiveWithoutEffects) || !onClick && void 0,
|
|
4268
|
-
"aria-pressed": void 0,
|
|
4388
|
+
"aria-pressed": onClick ? isActive : void 0,
|
|
4269
4389
|
onKeyDown: onClick ? handleKeyDown : void 0,
|
|
4270
4390
|
children: [ jsx(AtomixGlassContainer, {
|
|
4271
4391
|
ref: glassRef,
|
|
@@ -5480,10 +5600,10 @@ const Button = React.memo( forwardRef((({label: label, children: children, onCl
|
|
|
5480
5600
|
children: renderSlot(slots?.spinner, {
|
|
5481
5601
|
className: ThemeNaming.bemClass(THEME_NAMING.BUTTON_PREFIX, THEME_NAMING.SPINNER_ELEMENT),
|
|
5482
5602
|
size: spinnerSize,
|
|
5483
|
-
variant: "link" === variant || "string" == typeof variant && variant.startsWith("outline-") ? "primary" : "danger" === variant ? "
|
|
5603
|
+
variant: "link" === variant || "ghost" === variant || "string" == typeof variant && variant.startsWith("outline-") ? "primary" : "danger" === variant ? "danger" : variant
|
|
5484
5604
|
}, jsx(Spinner, {
|
|
5485
5605
|
size: spinnerSize,
|
|
5486
|
-
variant: "link" === variant || "string" == typeof variant && variant.startsWith("outline-") ? "primary" : "danger" === variant ? "
|
|
5606
|
+
variant: "link" === variant || "ghost" === variant || "string" == typeof variant && variant.startsWith("outline-") ? "primary" : "danger" === variant ? "danger" : variant
|
|
5487
5607
|
}))
|
|
5488
5608
|
}), iconElement && !loading && jsx("span", {
|
|
5489
5609
|
className: ThemeNaming.bemClass(THEME_NAMING.BUTTON_PREFIX, THEME_NAMING.ICON_ELEMENT),
|
|
@@ -5572,8 +5692,7 @@ const Button = React.memo( forwardRef((({label: label, children: children, onCl
|
|
|
5572
5692
|
const defaultGlassProps = {
|
|
5573
5693
|
displacementScale: 20,
|
|
5574
5694
|
blurAmount: 0,
|
|
5575
|
-
saturation: 200
|
|
5576
|
-
elasticity: 0
|
|
5695
|
+
saturation: 200
|
|
5577
5696
|
}, glassProps = !0 === glass ? defaultGlassProps : {
|
|
5578
5697
|
...defaultGlassProps,
|
|
5579
5698
|
...glass
|
|
@@ -5998,7 +6117,6 @@ className: className = "", style: style, ...rest}, ref) => {
|
|
|
5998
6117
|
children: cardContent
|
|
5999
6118
|
}), glass ? jsx(AtomixGlass, {
|
|
6000
6119
|
...!0 === glass ? {} : glass,
|
|
6001
|
-
elasticity: 0,
|
|
6002
6120
|
children: anchorElement
|
|
6003
6121
|
}) : anchorElement;
|
|
6004
6122
|
}
|
|
@@ -6010,7 +6128,6 @@ className: className = "", style: style, ...rest}, ref) => {
|
|
|
6010
6128
|
});
|
|
6011
6129
|
return glass ? jsx(AtomixGlass, {
|
|
6012
6130
|
...!0 === glass ? {} : glass,
|
|
6013
|
-
elasticity: 0,
|
|
6014
6131
|
children: divElement
|
|
6015
6132
|
}) : divElement;
|
|
6016
6133
|
})));
|
|
@@ -12238,9 +12355,7 @@ const EdgePanel = memo((({title: title, children: children, position: position
|
|
|
12238
12355
|
// The original code returned null if !isOpenState && isOpen === false.
|
|
12239
12356
|
// Let's keep that logic.
|
|
12240
12357
|
if (!isOpenState && !1 === isOpen) return null;
|
|
12241
|
-
const defaultGlassProps = {
|
|
12242
|
-
elasticity: 0
|
|
12243
|
-
}, glassProps = !0 === glass ? defaultGlassProps : {
|
|
12358
|
+
const defaultGlassProps = {}, glassProps = !0 === glass ? defaultGlassProps : {
|
|
12244
12359
|
...defaultGlassProps,
|
|
12245
12360
|
...glass
|
|
12246
12361
|
}, panelContent = React.Children.toArray(children).some((child => {
|
|
@@ -13618,26 +13733,25 @@ const composablesImport = Object.freeze( Object.defineProperty({
|
|
|
13618
13733
|
useTodo: useTodo
|
|
13619
13734
|
}, Symbol.toStringTag, {
|
|
13620
13735
|
value: "Module"
|
|
13621
|
-
})), SelectContext = createContext(null), SelectOption = memo((({value: value, children: children, disabled: disabled = !1, className: className = "", style: style}) => {
|
|
13622
|
-
const context = useContext(SelectContext),
|
|
13623
|
-
|
|
13624
|
-
// For simplicity, we use children as label for registration if it's a string.
|
|
13625
|
-
if (useEffect((() => {
|
|
13736
|
+
})), SelectContext = createContext(null), SelectOption = memo((({value: value, label: label, children: children, disabled: disabled = !1, className: className = "", style: style}) => {
|
|
13737
|
+
const context = useContext(SelectContext), displayLabel = label || ("string" == typeof children ? children : value);
|
|
13738
|
+
if (useEffect((() => {
|
|
13626
13739
|
if (context) return context.registerOption({
|
|
13627
13740
|
value: value,
|
|
13628
|
-
label:
|
|
13741
|
+
label: displayLabel,
|
|
13629
13742
|
disabled: disabled
|
|
13630
13743
|
}), () => {
|
|
13631
13744
|
context.unregisterOption(value);
|
|
13632
13745
|
};
|
|
13633
|
-
}), [ context, value,
|
|
13746
|
+
}), [ context, value, displayLabel, disabled ]), !context) return console.warn("SelectOption must be used within a Select component"),
|
|
13634
13747
|
null;
|
|
13635
|
-
const {selectedValue: selectedValue, onSelect: onSelect} = context, isSelected = Array.isArray(selectedValue) ? _includesInstanceProperty(selectedValue).call(selectedValue, value) : selectedValue === value;
|
|
13748
|
+
const {selectedValue: selectedValue, onSelect: onSelect, focusedValue: focusedValue, id: id} = context, isSelected = Array.isArray(selectedValue) ? _includesInstanceProperty(selectedValue).call(selectedValue, value) : selectedValue === value, isFocused = focusedValue === value;
|
|
13636
13749
|
return jsx("li", {
|
|
13637
|
-
|
|
13750
|
+
id: id ? `${id}-opt-${value}` : void 0,
|
|
13751
|
+
className: `${SELECT.CLASSES.SELECT_ITEM} ${isFocused ? "is-focused" : ""} ${isSelected ? "is-selected" : ""} ${className}`.trim(),
|
|
13638
13752
|
"data-value": value,
|
|
13639
13753
|
onClick: e => {
|
|
13640
|
-
e.preventDefault(), e.stopPropagation(), disabled || onSelect(value,
|
|
13754
|
+
e.preventDefault(), e.stopPropagation(), disabled || onSelect(value, displayLabel);
|
|
13641
13755
|
},
|
|
13642
13756
|
style: style,
|
|
13643
13757
|
role: "option",
|
|
@@ -13657,7 +13771,7 @@ const composablesImport = Object.freeze( Object.defineProperty({
|
|
|
13657
13771
|
tabIndex: -1
|
|
13658
13772
|
}), jsx("div", {
|
|
13659
13773
|
className: "c-select__item-label",
|
|
13660
|
-
children: children
|
|
13774
|
+
children: children || displayLabel
|
|
13661
13775
|
}) ]
|
|
13662
13776
|
})
|
|
13663
13777
|
});
|
|
@@ -13680,18 +13794,18 @@ const SelectComponentBase = ({options: options, value: value, onChange: onChange
|
|
|
13680
13794
|
disabled: disabled,
|
|
13681
13795
|
invalid: invalid,
|
|
13682
13796
|
valid: valid
|
|
13683
|
-
}), [isOpen, setIsOpen] = useState(!1), [
|
|
13797
|
+
}), [isOpen, setIsOpen] = useState(!1), [focusedIndex, setFocusedIndex] = useState(-1), dropdownRef = useRef(null), panelRef = useRef(null), bodyRef = useRef(null), nativeSelectRef = useRef(null), [registeredOptions, setRegisteredOptions] = useState([]), registerOption = useCallback((option => {
|
|
13684
13798
|
setRegisteredOptions((prev => prev.some((o => o.value === option.value)) ? prev : [ ...prev, option ]));
|
|
13685
13799
|
}), []), unregisterOption = useCallback((value => {
|
|
13686
13800
|
setRegisteredOptions((prev => prev.filter((o => o.value !== value))));
|
|
13687
|
-
}), []), hasOptionsProp = options && options.length > 0, activeOptions = hasOptionsProp ? options : registeredOptions
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
if (value) {
|
|
13801
|
+
}), []), hasOptionsProp = options && options.length > 0, activeOptions = hasOptionsProp ? options : registeredOptions, selectedLabel = useMemo((() => {
|
|
13802
|
+
if (multiple && Array.isArray(value)) return 0 === value.length ? placeholder : activeOptions.filter((opt => _includesInstanceProperty(value).call(value, opt.value))).map((opt => opt.label)).join(", ");
|
|
13803
|
+
if (value && "string" == typeof value) {
|
|
13691
13804
|
const selectedOption = activeOptions.find((opt => opt.value === value));
|
|
13692
|
-
selectedOption
|
|
13693
|
-
}
|
|
13694
|
-
|
|
13805
|
+
return selectedOption ? selectedOption.label : placeholder;
|
|
13806
|
+
}
|
|
13807
|
+
return placeholder;
|
|
13808
|
+
}), [ value, activeOptions, placeholder, multiple ]);
|
|
13695
13809
|
// Handle click outside to close dropdown
|
|
13696
13810
|
useEffect((() => {
|
|
13697
13811
|
const handleClickOutside = event => {
|
|
@@ -13704,31 +13818,54 @@ const SelectComponentBase = ({options: options, value: value, onChange: onChange
|
|
|
13704
13818
|
}), []);
|
|
13705
13819
|
// Toggle dropdown
|
|
13706
13820
|
const handleToggle = () => {
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13821
|
+
if (!disabled) {
|
|
13822
|
+
const nextOpen = !isOpen;
|
|
13823
|
+
if (nextOpen && bodyRef.current && panelRef.current)
|
|
13824
|
+
// Set focused index to current selection or first item
|
|
13825
|
+
if (bodyRef.current.style.height = `${panelRef.current.clientHeight}px`, value && !multiple && "string" == typeof value) {
|
|
13826
|
+
const index = activeOptions.findIndex((opt => opt.value === value));
|
|
13827
|
+
setFocusedIndex(index >= 0 ? index : 0);
|
|
13828
|
+
} else if (multiple && Array.isArray(value) && value.length > 0) {
|
|
13829
|
+
const index = activeOptions.findIndex((opt => _includesInstanceProperty(value).call(value, opt.value)));
|
|
13830
|
+
setFocusedIndex(index >= 0 ? index : 0);
|
|
13831
|
+
} else setFocusedIndex(0); else bodyRef.current && (bodyRef.current.style.height = "0px",
|
|
13832
|
+
setFocusedIndex(-1));
|
|
13833
|
+
setIsOpen(nextOpen);
|
|
13720
13834
|
}
|
|
13721
|
-
}
|
|
13835
|
+
}, handleItemClick = useCallback((option => {
|
|
13836
|
+
let newValue;
|
|
13837
|
+
if (multiple) {
|
|
13838
|
+
const currentValues = Array.isArray(value) ? value : value ? [ value ] : [];
|
|
13839
|
+
newValue = _includesInstanceProperty(currentValues).call(currentValues, option.value) ? currentValues.filter((v => v !== option.value)) : [ ...currentValues, option.value ];
|
|
13840
|
+
} else newValue = option.value, setIsOpen(!1), bodyRef.current && (bodyRef.current.style.height = "0px");
|
|
13841
|
+
onChange && (
|
|
13842
|
+
// Sync native select before firing onChange
|
|
13843
|
+
nativeSelectRef.current && (multiple && Array.isArray(newValue) ? Array.from(nativeSelectRef.current.options).forEach((opt => {
|
|
13844
|
+
opt.selected = _includesInstanceProperty(newValue).call(newValue, opt.value);
|
|
13845
|
+
})) : "string" == typeof newValue && (nativeSelectRef.current.value = newValue)),
|
|
13846
|
+
onChange({
|
|
13847
|
+
target: {
|
|
13848
|
+
name: name,
|
|
13849
|
+
value: newValue
|
|
13850
|
+
}
|
|
13851
|
+
}));
|
|
13852
|
+
}), [ onChange, name, multiple, value ]), onSelect = useCallback(((val, label) => {
|
|
13722
13853
|
handleItemClick({
|
|
13723
13854
|
value: val,
|
|
13724
13855
|
label: label
|
|
13725
13856
|
});
|
|
13726
|
-
}), [ handleItemClick ]),
|
|
13857
|
+
}), [ handleItemClick ]), focusedValue = useMemo((() => {
|
|
13858
|
+
if (focusedIndex >= 0 && focusedIndex < activeOptions.length) return activeOptions[focusedIndex]?.value;
|
|
13859
|
+
}), [ focusedIndex, activeOptions ]), focusedOptionId = useMemo((() => {
|
|
13860
|
+
if (isOpen && focusedValue) return `${id || "select"}-opt-${focusedValue}`;
|
|
13861
|
+
}), [ isOpen, focusedValue, id ]), contextValue = React.useMemo((() => ({
|
|
13727
13862
|
registerOption: registerOption,
|
|
13728
13863
|
unregisterOption: unregisterOption,
|
|
13729
13864
|
selectedValue: value,
|
|
13730
|
-
onSelect: onSelect
|
|
13731
|
-
|
|
13865
|
+
onSelect: onSelect,
|
|
13866
|
+
focusedValue: focusedValue,
|
|
13867
|
+
id: id || "select"
|
|
13868
|
+
})), [ registerOption, unregisterOption, value, onSelect, focusedValue, id ]), selectContent = jsx(SelectContext.Provider, {
|
|
13732
13869
|
value: contextValue,
|
|
13733
13870
|
children: jsxs("div", {
|
|
13734
13871
|
className: `${selectClass} ${isOpen ? SELECT.CLASSES.IS_OPEN : ""}`,
|
|
@@ -13776,7 +13913,12 @@ const SelectComponentBase = ({options: options, value: value, onChange: onChange
|
|
|
13776
13913
|
if (!disabled) switch (event.key) {
|
|
13777
13914
|
case "Enter":
|
|
13778
13915
|
case " ":
|
|
13779
|
-
event.preventDefault(),
|
|
13916
|
+
if (event.preventDefault(), isOpen) {
|
|
13917
|
+
if (focusedIndex >= 0 && focusedIndex < activeOptions.length) {
|
|
13918
|
+
const option = activeOptions[focusedIndex];
|
|
13919
|
+
option && !option.disabled && handleItemClick(option);
|
|
13920
|
+
}
|
|
13921
|
+
} else handleToggle();
|
|
13780
13922
|
break;
|
|
13781
13923
|
|
|
13782
13924
|
case "Escape":
|
|
@@ -13784,8 +13926,23 @@ const SelectComponentBase = ({options: options, value: value, onChange: onChange
|
|
|
13784
13926
|
break;
|
|
13785
13927
|
|
|
13786
13928
|
case "ArrowDown":
|
|
13929
|
+
event.preventDefault(), isOpen ? setFocusedIndex((prev => prev < activeOptions.length - 1 ? prev + 1 : prev)) : handleToggle();
|
|
13930
|
+
break;
|
|
13931
|
+
|
|
13787
13932
|
case "ArrowUp":
|
|
13788
|
-
|
|
13933
|
+
event.preventDefault(), isOpen ? setFocusedIndex((prev => prev > 0 ? prev - 1 : 0)) : handleToggle();
|
|
13934
|
+
break;
|
|
13935
|
+
|
|
13936
|
+
case "Home":
|
|
13937
|
+
isOpen && (event.preventDefault(), setFocusedIndex(0));
|
|
13938
|
+
break;
|
|
13939
|
+
|
|
13940
|
+
case "End":
|
|
13941
|
+
isOpen && (event.preventDefault(), setFocusedIndex(activeOptions.length - 1));
|
|
13942
|
+
break;
|
|
13943
|
+
|
|
13944
|
+
case "Tab":
|
|
13945
|
+
isOpen && (setIsOpen(!1), bodyRef.current && (bodyRef.current.style.height = "0px"));
|
|
13789
13946
|
}
|
|
13790
13947
|
},
|
|
13791
13948
|
"aria-disabled": disabled,
|
|
@@ -13794,7 +13951,11 @@ const SelectComponentBase = ({options: options, value: value, onChange: onChange
|
|
|
13794
13951
|
"aria-haspopup": "listbox",
|
|
13795
13952
|
"aria-expanded": isOpen,
|
|
13796
13953
|
"aria-controls": id ? `${id}-listbox` : void 0,
|
|
13797
|
-
|
|
13954
|
+
"aria-activedescendant": focusedOptionId,
|
|
13955
|
+
children: jsx("div", {
|
|
13956
|
+
className: "c-select__selected-text",
|
|
13957
|
+
children: selectedLabel
|
|
13958
|
+
})
|
|
13798
13959
|
}), jsx("i", {
|
|
13799
13960
|
className: `${SELECT.CLASSES.ICON_CARET} ${SELECT.CLASSES.TOGGLE_ICON}`
|
|
13800
13961
|
}), jsx("div", {
|
|
@@ -13812,11 +13973,13 @@ const SelectComponentBase = ({options: options, value: value, onChange: onChange
|
|
|
13812
13973
|
id: id ? `${id}-listbox` : void 0,
|
|
13813
13974
|
"aria-labelledby": id,
|
|
13814
13975
|
children: hasOptionsProp ? options.map(((option, index) => jsx("li", {
|
|
13815
|
-
|
|
13976
|
+
id: `${id || "select"}-opt-${option.value}`,
|
|
13977
|
+
className: `${SELECT.CLASSES.SELECT_ITEM} ${focusedIndex === index ? "is-focused" : ""} ${multiple && Array.isArray(value) && _includesInstanceProperty(value).call(value, option.value) || value === option.value ? "is-selected" : ""}`,
|
|
13816
13978
|
"data-value": option.value,
|
|
13817
13979
|
onClick: () => !option.disabled && handleItemClick(option),
|
|
13980
|
+
onMouseEnter: () => setFocusedIndex(index),
|
|
13818
13981
|
role: "option",
|
|
13819
|
-
"aria-selected": value === option.value,
|
|
13982
|
+
"aria-selected": multiple && Array.isArray(value) && _includesInstanceProperty(value).call(value, option.value) || value === option.value,
|
|
13820
13983
|
"aria-disabled": option.disabled,
|
|
13821
13984
|
children: jsxs("label", {
|
|
13822
13985
|
htmlFor: `SelectItem${index}`,
|
|
@@ -13825,7 +13988,7 @@ const SelectComponentBase = ({options: options, value: value, onChange: onChange
|
|
|
13825
13988
|
type: "checkbox",
|
|
13826
13989
|
id: `SelectItem${index}`,
|
|
13827
13990
|
className: "c-checkbox__input c-select__item-input",
|
|
13828
|
-
checked: value === option.value,
|
|
13991
|
+
checked: multiple && Array.isArray(value) && _includesInstanceProperty(value).call(value, option.value) || value === option.value,
|
|
13829
13992
|
readOnly: !0,
|
|
13830
13993
|
disabled: option.disabled
|
|
13831
13994
|
}), jsx("div", {
|
|
@@ -13844,10 +14007,7 @@ const SelectComponentBase = ({options: options, value: value, onChange: onChange
|
|
|
13844
14007
|
// Default glass settings for select components
|
|
13845
14008
|
const defaultGlassProps = {
|
|
13846
14009
|
displacementScale: 60,
|
|
13847
|
-
blurAmount:
|
|
13848
|
-
saturation: 180,
|
|
13849
|
-
aberrationIntensity: .2,
|
|
13850
|
-
borderRadius: 12,
|
|
14010
|
+
blurAmount: 10,
|
|
13851
14011
|
mode: "shader"
|
|
13852
14012
|
}, glassProps = !0 === glass ? defaultGlassProps : {
|
|
13853
14013
|
...defaultGlassProps,
|
|
@@ -22053,7 +22213,7 @@ class ThemeLogger {
|
|
|
22053
22213
|
document.body && document.body.setAttribute(dataAttribute, themeName),
|
|
22054
22214
|
// Also set on documentElement for broader compatibility
|
|
22055
22215
|
document.documentElement.setAttribute(dataAttribute, themeName));
|
|
22056
|
-
}, isValidThemeName = themeName => !(!themeName || "string" != typeof themeName) && /^[a-z0-9]+(-[a-z0-9]+)*$/.test(themeName), createLocalStorageAdapter = () => ({
|
|
22216
|
+
}, getSystemTheme = () => isServer() ? "light" : window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", isValidThemeName = themeName => !(!themeName || "string" != typeof themeName) && /^[a-z0-9]+(-[a-z0-9]+)*$/.test(themeName), createLocalStorageAdapter = () => ({
|
|
22057
22217
|
getItem: key => {
|
|
22058
22218
|
if (isServer()) return null;
|
|
22059
22219
|
try {
|
|
@@ -22090,6 +22250,7 @@ class ThemeLogger {
|
|
|
22090
22250
|
applyThemeAttributes: applyThemeAttributes,
|
|
22091
22251
|
buildThemePath: buildThemePath,
|
|
22092
22252
|
createLocalStorageAdapter: createLocalStorageAdapter,
|
|
22253
|
+
getSystemTheme: getSystemTheme,
|
|
22093
22254
|
isBrowser: isBrowser,
|
|
22094
22255
|
isServer: isServer,
|
|
22095
22256
|
isValidThemeName: isValidThemeName,
|
|
@@ -22200,14 +22361,6 @@ function switchTheme(mode, options = {}) {
|
|
|
22200
22361
|
return "undefined" == typeof window ? "light" : localStorage.getItem(storageKey) || "light";
|
|
22201
22362
|
}
|
|
22202
22363
|
|
|
22203
|
-
/**
|
|
22204
|
-
* Get system theme preference
|
|
22205
|
-
*
|
|
22206
|
-
* @returns 'dark' if system prefers dark mode, 'light' otherwise
|
|
22207
|
-
*/ function getSystemTheme() {
|
|
22208
|
-
return "undefined" == typeof window ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
22209
|
-
}
|
|
22210
|
-
|
|
22211
22364
|
/**
|
|
22212
22365
|
* Initialize theme based on saved preference or system preference
|
|
22213
22366
|
*
|