@@ -16,13 +16,6 @@ if (!Element.prototype.closest) {
1616 } ;
1717}
1818
19- if ( document . fonts && document . body ) {
20- document . body . classList . add ( 'rz-icons-loading' ) ;
21- document . fonts . load ( '16px Material Symbols' ) . then ( ( ) => {
22- document . body . classList . remove ( 'rz-icons-loading' ) ;
23- } )
24- }
25-
2619var resolveCallbacks = [ ] ;
2720var rejectCallbacks = [ ] ;
2821var radzenRecognition ;
@@ -987,9 +980,9 @@ window.Radzen = {
987980 return ;
988981 }
989982
990- var ch = String . fromCharCode ( e . charCode ) ;
983+ var ch = e . key ;
991984
992- if ( ( isInteger ? / ^ [ - \d ] $ / : / ^ [ - \d , . ] $ / ) . test ( ch ) ) {
985+ if ( / \p { Nd } / u . test ( ch ) || ch === '-' || ( ! isInteger && ch === decimalSeparator ) ) {
993986 return ;
994987 }
995988
@@ -1136,6 +1129,9 @@ window.Radzen = {
11361129 }
11371130
11381131 popup . style . display = 'block' ;
1132+ popup . onanimationend = null ;
1133+ popup . classList . add ( "rz-open" ) ;
1134+ popup . classList . remove ( "rz-close" ) ;
11391135
11401136 var rect = popup . getBoundingClientRect ( ) ;
11411137 rect . width = x ? rect . width + 20 : rect . width ;
@@ -1228,8 +1224,11 @@ window.Radzen = {
12281224 }
12291225
12301226 var closestLink = e . target . closest && ( e . target . closest ( '.rz-link' ) || e . target . closest ( '.rz-navigation-item-link' ) ) ;
1231- if ( closestLink && closestLink . closest && closestLink . closest ( 'a' ) ) {
1232- if ( Radzen . closeAllPopups ) {
1227+ if ( e . type == 'resize' && ! / A n d r o i d / i. test ( navigator . userAgent ) ) {
1228+ if ( closestLink && closestLink . closest && closestLink . closest ( 'a' ) && e . button == 0 ) {
1229+ closestLink . closest ( 'a' ) . click ( ) ;
1230+ Radzen . closeAllPopups ( ) ;
1231+ } else {
12331232 Radzen . closeAllPopups ( ) ;
12341233 }
12351234 }
@@ -1280,7 +1279,7 @@ window.Radzen = {
12801279 if ( firstFocusable ) {
12811280 firstFocusable . focus ( ) ;
12821281 }
1283- } , 500 ) ;
1282+ } , 200 ) ;
12841283 }
12851284 } ,
12861285 closeAllPopups : function ( e , id ) {
@@ -1327,7 +1326,12 @@ window.Radzen = {
13271326 Radzen [ id + 'FZL' ] = null ;
13281327 }
13291328
1330- popup . style . display = 'none' ;
1329+ popup . onanimationend = function ( ) {
1330+ popup . style . display = 'none' ;
1331+ popup . onanimationend = null ;
1332+ }
1333+ popup . classList . add ( "rz-close" ) ;
1334+ popup . classList . remove ( "rz-open" ) ;
13311335 }
13321336 document . removeEventListener ( 'mousedown' , Radzen [ id ] ) ;
13331337 window . removeEventListener ( 'resize' , Radzen [ id ] ) ;
@@ -1658,7 +1662,7 @@ window.Radzen = {
16581662 reader . addEventListener (
16591663 'load' ,
16601664 function ( ) {
1661- if ( maxWidth > 0 && maxHeight > 0 ) {
1665+ if ( fileInput . files [ 0 ] && fileInput . files [ 0 ] . type . includes ( 'image' ) && maxWidth > 0 && maxHeight > 0 ) {
16621666 var img = document . createElement ( "img" ) ;
16631667 img . onload = function ( event ) {
16641668 // Dynamically create a canvas element
@@ -1702,14 +1706,26 @@ window.Radzen = {
17021706 var children = item . querySelector ( '.rz-navigation-menu' ) ;
17031707
17041708 if ( children ) {
1705- children . style . display = active ? '' : 'none' ;
1709+ if ( active ) {
1710+ children . onanimationend = null ;
1711+ children . style . display = '' ;
1712+ children . classList . add ( 'rz-open' ) ;
1713+ children . classList . remove ( 'rz-close' ) ;
1714+ } else {
1715+ children . onanimationend = function ( ) {
1716+ children . style . display = 'none' ;
1717+ children . onanimationend = null ;
1718+ }
1719+ children . classList . remove ( 'rz-open' ) ;
1720+ children . classList . add ( 'rz-close' ) ;
1721+ }
17061722 }
17071723
17081724 var icon = item . querySelector ( '.rz-navigation-item-icon-children' ) ;
17091725
17101726 if ( icon ) {
1711- var deg = active ? '180deg' : 0 ;
1712- icon . style . transform = 'rotate(' + deg + ')' ;
1727+ icon . classList . toggle ( 'rz-state-expanded' , active ) ;
1728+ icon . classList . toggle ( 'rz-state-collapsed' , ! active ) ;
17131729 }
17141730 }
17151731
@@ -1734,6 +1750,7 @@ window.Radzen = {
17341750 document . addEventListener ( 'click' , target . clickHandler ) ;
17351751 } ,
17361752 destroyChart : function ( ref ) {
1753+ if ( ! ref ) return ;
17371754 ref . removeEventListener ( 'mouseleave' , ref . mouseLeaveHandler ) ;
17381755 delete ref . mouseLeaveHandler ;
17391756 ref . removeEventListener ( 'mouseenter' , ref . mouseEnterHandler ) ;
@@ -2127,7 +2144,7 @@ window.Radzen = {
21272144 visual . style . height = cell . offsetHeight + 'px' ;
21282145 visual . style . width = cell . offsetWidth + 'px' ;
21292146 visual . style . zIndex = 2000 ;
2130- visual . innerHTML = cell . innerHTML ;
2147+ visual . innerHTML = cell . firstChild . outerHTML ;
21312148 visual . id = id + 'visual' ;
21322149 document . body . appendChild ( visual ) ;
21332150
@@ -2218,11 +2235,16 @@ window.Radzen = {
22182235 if ( Radzen [ el ] ) {
22192236 var widthFloat = ( Radzen [ el ] . width - ( Radzen . isRTL ( cell ) ? - 1 : 1 ) * ( Radzen [ el ] . clientX - e . clientX ) ) ;
22202237 var minWidth = parseFloat ( cell . style . minWidth || 0 )
2238+ var maxWidth = parseFloat ( cell . style . maxWidth || 0 )
22212239
22222240 if ( widthFloat < minWidth ) {
22232241 widthFloat = minWidth ;
22242242 }
22252243
2244+ if ( cell . style . maxWidth && widthFloat > maxWidth ) {
2245+ widthFloat = maxWidth ;
2246+ }
2247+
22262248 var width = widthFloat + 'px' ;
22272249
22282250 if ( cell ) {
@@ -2495,5 +2517,64 @@ window.Radzen = {
24952517 tooltipContent . classList . remove ( 'rz-top-chart-tooltip' ) ;
24962518 tooltipContent . classList . remove ( 'rz-bottom-chart-tooltip' ) ;
24972519 tooltipContent . classList . add ( tooltipContentClassName ) ;
2520+ } ,
2521+ navigateTo : function ( selector , scroll ) {
2522+ if ( selector . startsWith ( '#' ) ) {
2523+ history . replaceState ( null , '' , location . pathname + location . search + selector ) ;
2524+ }
2525+
2526+ if ( scroll ) {
2527+ const target = document . querySelector ( selector ) ;
2528+ if ( target ) {
2529+ target . scrollIntoView ( { behavior : 'smooth' , block : 'center' , inline : 'start' } ) ;
2530+ }
2531+ }
2532+ } ,
2533+ registerScrollListener : function ( element , ref , selectors , selector ) {
2534+ let currentSelector ;
2535+ const container = selector ? document . querySelector ( selector ) : document . documentElement ;
2536+ const elements = selectors . map ( document . querySelector , document ) ;
2537+
2538+ this . unregisterScrollListener ( element ) ;
2539+ element . scrollHandler = ( ) => {
2540+ const center = ( container . tagName === 'HTML' ? 0 : container . getBoundingClientRect ( ) . top ) + container . clientHeight / 2 ;
2541+
2542+ let min = Number . MAX_SAFE_INTEGER ;
2543+ let match ;
2544+
2545+ for ( let i = 0 ; i < elements . length ; i ++ ) {
2546+ const element = elements [ i ] ;
2547+ if ( ! element ) continue ;
2548+
2549+ const rect = element . getBoundingClientRect ( ) ;
2550+ const diff = Math . abs ( rect . top - center ) ;
2551+
2552+ if ( ! match && rect . top < center ) {
2553+ match = selectors [ i ] ;
2554+ min = diff ;
2555+ continue ;
2556+ }
2557+
2558+ if ( match && rect . top >= center ) continue ;
2559+
2560+ if ( diff < min ) {
2561+ match = selectors [ i ] ;
2562+ min = diff ;
2563+ }
2564+ }
2565+
2566+ if ( match !== currentSelector ) {
2567+ currentSelector = match ;
2568+ this . navigateTo ( currentSelector , false ) ;
2569+ ref . invokeMethodAsync ( 'ScrollIntoView' , currentSelector ) ;
2570+ }
2571+ } ;
2572+
2573+ document . addEventListener ( 'scroll' , element . scrollHandler , true ) ;
2574+ window . addEventListener ( 'resize' , element . scrollHandler , true ) ;
2575+ } ,
2576+ unregisterScrollListener : function ( element ) {
2577+ document . removeEventListener ( 'scroll' , element . scrollHandler , true ) ;
2578+ window . removeEventListener ( 'resize' , element . scrollHandler , true ) ;
24982579 }
24992580} ;
0 commit comments