@tabler/core 1.3.2 → 1.4.0

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.
Files changed (141) hide show
  1. package/dist/css/tabler-flags.css +1 -1
  2. package/dist/css/tabler-flags.min.css +1 -1
  3. package/dist/css/tabler-flags.rtl.css +1 -1
  4. package/dist/css/tabler-flags.rtl.min.css +1 -1
  5. package/dist/css/tabler-marketing.css +1 -1
  6. package/dist/css/tabler-marketing.min.css +1 -1
  7. package/dist/css/tabler-marketing.rtl.css +1 -1
  8. package/dist/css/tabler-marketing.rtl.min.css +1 -1
  9. package/dist/css/tabler-payments.css +1 -1
  10. package/dist/css/tabler-payments.min.css +1 -1
  11. package/dist/css/tabler-payments.rtl.css +1 -1
  12. package/dist/css/tabler-payments.rtl.min.css +1 -1
  13. package/dist/css/tabler-props.css +74 -74
  14. package/dist/css/tabler-props.css.map +1 -1
  15. package/dist/css/tabler-props.min.css +2 -2
  16. package/dist/css/tabler-props.min.css.map +1 -1
  17. package/dist/css/tabler-props.rtl.css +74 -74
  18. package/dist/css/tabler-props.rtl.css.map +1 -1
  19. package/dist/css/tabler-props.rtl.min.css +2 -2
  20. package/dist/css/tabler-props.rtl.min.css.map +1 -1
  21. package/dist/css/tabler-socials.css +1 -1
  22. package/dist/css/tabler-socials.min.css +1 -1
  23. package/dist/css/tabler-socials.rtl.css +1 -1
  24. package/dist/css/tabler-socials.rtl.min.css +1 -1
  25. package/dist/css/tabler-themes.css +1 -1
  26. package/dist/css/tabler-themes.min.css +1 -1
  27. package/dist/css/tabler-themes.rtl.css +1 -1
  28. package/dist/css/tabler-themes.rtl.min.css +1 -1
  29. package/dist/css/tabler-vendors.css +1 -1
  30. package/dist/css/tabler-vendors.min.css +1 -1
  31. package/dist/css/tabler-vendors.rtl.css +1 -1
  32. package/dist/css/tabler-vendors.rtl.min.css +1 -1
  33. package/dist/css/tabler.css +649 -428
  34. package/dist/css/tabler.css.map +1 -1
  35. package/dist/css/tabler.min.css +2 -2
  36. package/dist/css/tabler.min.css.map +1 -1
  37. package/dist/css/tabler.rtl.css +647 -428
  38. package/dist/css/tabler.rtl.css.map +1 -1
  39. package/dist/css/tabler.rtl.min.css +2 -2
  40. package/dist/css/tabler.rtl.min.css.map +1 -1
  41. package/dist/js/tabler-theme.esm.js +1 -1
  42. package/dist/js/tabler-theme.esm.js.map +1 -1
  43. package/dist/js/tabler-theme.esm.min.js +1 -1
  44. package/dist/js/tabler-theme.js +1 -1
  45. package/dist/js/tabler-theme.js.map +1 -1
  46. package/dist/js/tabler-theme.min.js +2 -2
  47. package/dist/js/tabler-theme.min.js.map +1 -1
  48. package/dist/js/tabler.esm.js +4 -4
  49. package/dist/js/tabler.esm.js.map +1 -1
  50. package/dist/js/tabler.esm.min.js +4 -4
  51. package/dist/js/tabler.esm.min.js.map +1 -1
  52. package/dist/js/tabler.js +4 -4
  53. package/dist/js/tabler.js.map +1 -1
  54. package/dist/js/tabler.min.js +4 -4
  55. package/dist/js/tabler.min.js.map +1 -1
  56. package/dist/libs/@melloware/coloris/dist/esm/coloris.js +9 -3
  57. package/dist/libs/@melloware/coloris/dist/esm/coloris.min.js +1 -1
  58. package/dist/libs/@melloware/coloris/dist/umd/coloris.js +9 -3
  59. package/dist/libs/@melloware/coloris/dist/umd/coloris.min.js +1 -1
  60. package/dist/libs/@melloware/coloris/package.json +1 -1
  61. package/dist/libs/countup.js/README.md +2 -2
  62. package/dist/libs/countup.js/dist/countUp.d.ts +3 -2
  63. package/dist/libs/countup.js/dist/countUp.js +11 -2
  64. package/dist/libs/countup.js/dist/countUp.min.js +1 -1
  65. package/dist/libs/countup.js/dist/countUp.umd.js +1 -1
  66. package/dist/libs/countup.js/package.json +1 -1
  67. package/dist/libs/countup.js/src/countUp.spec.ts +75 -25
  68. package/dist/libs/countup.js/src/countUp.ts +13 -3
  69. package/dist/libs/fslightbox/index.js +1 -1
  70. package/dist/libs/fslightbox/package.json +1 -1
  71. package/dist/libs/fullcalendar/index.global.js +49 -20
  72. package/dist/libs/fullcalendar/index.global.min.js +2 -2
  73. package/dist/libs/fullcalendar/package.json +7 -7
  74. package/dist/libs/jsvectormap/dist/jsvectormap.cjs +240 -224
  75. package/dist/libs/jsvectormap/dist/jsvectormap.css +83 -57
  76. package/dist/libs/jsvectormap/dist/jsvectormap.esm.js +240 -224
  77. package/dist/libs/jsvectormap/dist/jsvectormap.js +240 -224
  78. package/dist/libs/jsvectormap/dist/jsvectormap.min.css +1 -1
  79. package/dist/libs/jsvectormap/dist/jsvectormap.min.js +1 -1
  80. package/dist/libs/jsvectormap/package.json +1 -1
  81. package/dist/libs/jsvectormap/src/js/components/base.js +0 -5
  82. package/dist/libs/jsvectormap/src/js/components/concerns/interactable.js +2 -7
  83. package/dist/libs/jsvectormap/src/js/components/line.js +38 -10
  84. package/dist/libs/jsvectormap/src/js/components/marker.js +72 -33
  85. package/dist/libs/jsvectormap/src/js/components/region.js +0 -5
  86. package/dist/libs/jsvectormap/src/js/components/route.js +76 -0
  87. package/dist/libs/jsvectormap/src/js/components/tooltip.js +0 -5
  88. package/dist/libs/jsvectormap/src/js/core/createLines.js +25 -24
  89. package/dist/libs/jsvectormap/src/js/core/createMarkers.js +15 -20
  90. package/dist/libs/jsvectormap/src/js/core/createRoutes.js +16 -0
  91. package/dist/libs/jsvectormap/src/js/core/repositionLines.js +22 -18
  92. package/dist/libs/jsvectormap/src/js/core/setupContainerEvents.js +2 -2
  93. package/dist/libs/jsvectormap/src/js/core/setupContainerTouchEvents.js +2 -2
  94. package/dist/libs/jsvectormap/src/js/core/setupElementEvents.js +7 -3
  95. package/dist/libs/jsvectormap/src/js/core/setupZoomButtons.js +23 -6
  96. package/dist/libs/jsvectormap/src/js/defaults/options.js +1 -0
  97. package/dist/libs/jsvectormap/src/js/eventHandler.js +0 -5
  98. package/dist/libs/jsvectormap/src/js/index.js +0 -5
  99. package/dist/libs/jsvectormap/src/js/legend.js +1 -9
  100. package/dist/libs/jsvectormap/src/js/map.js +36 -13
  101. package/dist/libs/jsvectormap/src/js/scales/ordinalScale.js +0 -5
  102. package/dist/libs/jsvectormap/src/js/series.js +0 -5
  103. package/dist/libs/jsvectormap/src/js/svg/baseElement.js +0 -5
  104. package/dist/libs/jsvectormap/src/js/svg/canvasElement.js +2 -7
  105. package/dist/libs/jsvectormap/src/js/svg/imageElement.js +0 -5
  106. package/dist/libs/jsvectormap/src/js/svg/shapeElement.js +0 -5
  107. package/dist/libs/jsvectormap/src/js/svg/textElement.js +0 -5
  108. package/dist/libs/jsvectormap/src/scss/_variables.scss +37 -0
  109. package/dist/libs/jsvectormap/src/scss/jsvectormap.scss +104 -112
  110. package/dist/libs/signature_pad/dist/signature_pad.js +133 -87
  111. package/dist/libs/signature_pad/dist/signature_pad.js.map +1 -1
  112. package/dist/libs/signature_pad/dist/signature_pad.min.js +2 -2
  113. package/dist/libs/signature_pad/dist/signature_pad.min.js.map +1 -1
  114. package/dist/libs/signature_pad/dist/signature_pad.umd.js +133 -87
  115. package/dist/libs/signature_pad/dist/signature_pad.umd.js.map +1 -1
  116. package/dist/libs/signature_pad/dist/signature_pad.umd.min.js +2 -2
  117. package/dist/libs/signature_pad/dist/signature_pad.umd.min.js.map +1 -1
  118. package/dist/libs/signature_pad/dist/types/signature_pad.d.ts +4 -1
  119. package/dist/libs/signature_pad/docs/js/signature_pad.umd.min.js +2 -2
  120. package/dist/libs/signature_pad/docs/js/signature_pad.umd.min.js.map +1 -1
  121. package/dist/libs/signature_pad/package.json +19 -19
  122. package/dist/libs/signature_pad/src/signature_pad.ts +84 -28
  123. package/package.json +9 -9
  124. package/scss/_bootstrap-components.scss +0 -1
  125. package/scss/_core.scss +1 -0
  126. package/scss/_variables.scss +78 -48
  127. package/scss/layout/_animations.scss +52 -17
  128. package/scss/layout/_navbar.scss +8 -4
  129. package/scss/ui/_breadcrumbs.scss +31 -0
  130. package/scss/ui/_buttons.scss +92 -20
  131. package/scss/ui/_cards.scss +4 -2
  132. package/scss/ui/_dropdowns.scss +1 -1
  133. package/scss/ui/_grid.scss +2 -2
  134. package/scss/ui/_lists.scss +8 -8
  135. package/scss/ui/_nav.scss +1 -1
  136. package/scss/ui/_pagination.scss +4 -4
  137. package/scss/ui/_stars.scss +0 -4
  138. package/scss/ui/_switch-icon.scss +6 -2
  139. package/scss/ui/_tables.scss +1 -1
  140. package/scss/utils/_hover.scss +47 -0
  141. package/scss/vendor/_nouislider.scss +2 -2
@@ -3,7 +3,7 @@ const Coloris = (() => {
3
3
  * Copyright (c) 2021-2024 Momo Bassit.
4
4
  * Licensed under the MIT License (MIT)
5
5
  * https://github.com/mdbassit/Coloris
6
- * Version: 0.24.0
6
+ * Version: 0.25.0
7
7
  * NPM: https://github.com/melloware/coloris-npm
8
8
  */
9
9
 
@@ -368,7 +368,7 @@ const Coloris = (() => {
368
368
  }
369
369
 
370
370
  // Trigger an "open" event
371
- currentEl.dispatchEvent(new Event('open', { bubbles: true }));
371
+ currentEl.dispatchEvent(new Event('open', { bubbles: false }));
372
372
  }
373
373
 
374
374
  /**
@@ -536,7 +536,7 @@ const Coloris = (() => {
536
536
  }
537
537
 
538
538
  // Trigger a "close" event
539
- prevEl.dispatchEvent(new Event('close', { bubbles: true }));
539
+ prevEl.dispatchEvent(new Event('close', { bubbles: false }));
540
540
 
541
541
  if (settings.focusInput) {
542
542
  prevEl.focus({ preventScroll: true });
@@ -1109,6 +1109,12 @@ const Coloris = (() => {
1109
1109
 
1110
1110
  if (key === 'Escape') {
1111
1111
  closePicker(true);
1112
+ return;
1113
+
1114
+ // Close the color picker and keep the selected color on press on Enter
1115
+ } else if (key === 'Enter' && target.tagName !== 'BUTTON') {
1116
+ closePicker();
1117
+ return;
1112
1118
 
1113
1119
  // Display focus rings when using the keyboard
1114
1120
  } else if (navKeys.includes(key)) {
@@ -1 +1 @@
1
- const Coloris=(()=>{{var L=window,x=document,C=Math,A=void 0;const V=x.createElement("canvas").getContext("2d"),Z={r:0,g:0,b:0,h:0,s:0,v:0,a:1};let u,p,d,c,i,h,f,b,v,l,y,m,g,w,a,o,k={};const ee={el:"[data-coloris]",parent:"body",theme:"default",themeMode:"light",rtl:!1,wrap:!0,margin:2,format:"hex",formatToggle:!1,swatches:[],swatchesOnly:!1,alpha:!0,forceAlpha:!1,focusInput:!0,selectInput:!1,inline:!1,defaultColor:"#000000",clearButton:!1,clearLabel:"Clear",closeButton:!1,closeLabel:"Close",onChange:()=>A,a11y:{open:"Open color picker",close:"Close color picker",clear:"Clear the selected color",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},te={};let n="",s={},E=!1;function S(t){if("object"==typeof t)for(const n in t)switch(n){case"el":B(t.el),!1!==t.wrap&&H(t.el);break;case"parent":(u=t.parent instanceof HTMLElement?t.parent:x.querySelector(t.parent))&&(u.appendChild(p),ee.parent=t.parent,u===x.body)&&(u=A);break;case"themeMode":ee.themeMode=t.themeMode,"auto"===t.themeMode&&L.matchMedia&&L.matchMedia("(prefers-color-scheme: dark)").matches&&(ee.themeMode="dark");case"theme":t.theme&&(ee.theme=t.theme),p.className=`clr-picker clr-${ee.theme} clr-`+ee.themeMode,ee.inline&&M();break;case"rtl":ee.rtl=!!t.rtl,Array.from(x.getElementsByClassName("clr-field")).forEach(e=>e.classList.toggle("clr-rtl",ee.rtl));break;case"margin":t.margin*=1,ee.margin=(isNaN(t.margin)?ee:t).margin;break;case"wrap":t.el&&t.wrap&&H(t.el);break;case"formatToggle":ee.formatToggle=!!t.formatToggle,G("clr-format").style.display=ee.formatToggle?"block":"none",ee.formatToggle&&(ee.format="auto");break;case"swatches":if(Array.isArray(t.swatches)){var a=G("clr-swatches");const s=x.createElement("div");a.textContent="",t.swatches.forEach((e,t)=>{var a=x.createElement("button");a.setAttribute("type","button"),a.setAttribute("id","clr-swatch-"+t),a.setAttribute("aria-labelledby","clr-swatch-label clr-swatch-"+t),a.style.color=e,a.textContent=e,s.appendChild(a)}),t.swatches.length&&a.appendChild(s),ee.swatches=t.swatches.slice()}break;case"swatchesOnly":ee.swatchesOnly=!!t.swatchesOnly,p.setAttribute("data-minimal",ee.swatchesOnly);break;case"alpha":ee.alpha=!!t.alpha,p.setAttribute("data-alpha",ee.alpha);break;case"inline":ee.inline=!!t.inline,p.setAttribute("data-inline",ee.inline),ee.inline&&(a=t.defaultColor||ee.defaultColor,w=D(a),M(),O(a));break;case"clearButton":"object"==typeof t.clearButton&&(t.clearButton.label&&(ee.clearLabel=t.clearButton.label,f.innerHTML=ee.clearLabel),t.clearButton=t.clearButton.show),ee.clearButton=!!t.clearButton,f.style.display=ee.clearButton?"block":"none";break;case"clearLabel":ee.clearLabel=t.clearLabel,f.innerHTML=ee.clearLabel;break;case"closeButton":ee.closeButton=!!t.closeButton,ee.closeButton?p.insertBefore(b,i):i.appendChild(b);break;case"closeLabel":ee.closeLabel=t.closeLabel,b.innerHTML=ee.closeLabel;break;case"a11y":var l,r,o=t.a11y;let e=!1;if("object"==typeof o)for(const c in o)o[c]&&ee.a11y[c]&&(ee.a11y[c]=o[c],e=!0);e&&(l=G("clr-open-label"),r=G("clr-swatch-label"),l.innerHTML=ee.a11y.open,r.innerHTML=ee.a11y.swatch,b.setAttribute("aria-label",ee.a11y.close),f.setAttribute("aria-label",ee.a11y.clear),v.setAttribute("aria-label",ee.a11y.hueSlider),y.setAttribute("aria-label",ee.a11y.alphaSlider),h.setAttribute("aria-label",ee.a11y.input),d.setAttribute("aria-label",ee.a11y.instruction));break;default:ee[n]=t[n]}}function e(e,t){"string"==typeof e&&"object"==typeof t&&(te[e]=t,E=!0)}function $(e){delete te[e],0===Object.keys(te).length&&(E=!1,e===n)&&T()}function r(e){if(E){var t,a=["el","wrap","rtl","inline","defaultColor","a11y"];for(t in te){const r=te[t];if(e.matches(t)){for(var l in n=t,s={},a.forEach(e=>delete r[e]),r)s[l]=Array.isArray(ee[l])?ee[l].slice():ee[l];S(r);break}}}}function T(){0<Object.keys(s).length&&(S(s),n="",s={})}function B(e){e instanceof HTMLElement&&(e=[e]),Array.isArray(e)?e.forEach(e=>{K(e,"click",t),K(e,"input",_)}):(K(x,"click",e,t),K(x,"input",e,_))}function t(e){ee.inline||(r(e.target),g=e.target,a=g.value,w=D(a),p.classList.add("clr-open"),M(),O(a),(ee.focusInput||ee.selectInput)&&(h.focus({preventScroll:!0}),h.setSelectionRange(g.selectionStart,g.selectionEnd)),ee.selectInput&&h.select(),(o||ee.swatchesOnly)&&z().shift().focus(),g.dispatchEvent(new Event("open",{bubbles:!0})))}function M(){if(p&&(g||ee.inline)){var r=u,o=L.scrollY,n=p.offsetWidth,s=p.offsetHeight,c={left:!1,top:!1};let e,a,t,l={x:0,y:0};if(r&&(e=L.getComputedStyle(r),a=parseFloat(e.marginTop),t=parseFloat(e.borderTopWidth),(l=r.getBoundingClientRect()).y+=t+o),!ee.inline){var i=g.getBoundingClientRect();let e=i.x,t=o+i.y+i.height+ee.margin;r?(e-=l.x,t-=l.y,e+n>r.clientWidth&&(e+=i.width-n,c.left=!0),t+s>r.clientHeight-a&&s+ee.margin<=i.top-(l.y-o)&&(t-=i.height+s+2*ee.margin,c.top=!0),t+=r.scrollTop):(e+n>x.documentElement.clientWidth&&(e+=i.width-n,c.left=!0),t+s-o>x.documentElement.clientHeight&&s+ee.margin<=i.top&&(t=o+i.y-s-ee.margin,c.top=!0)),p.classList.toggle("clr-left",c.left),p.classList.toggle("clr-top",c.top),p.style.left=e+"px",p.style.top=t+"px",l.x+=p.offsetLeft,l.y+=p.offsetTop}k={width:d.offsetWidth,height:d.offsetHeight,x:d.offsetLeft+l.x,y:d.offsetTop+l.y}}}function H(e){e instanceof HTMLElement?I(e):(Array.isArray(e)?e:x.querySelectorAll(e)).forEach(I)}function I(t){var a=t.parentNode;if(!a.classList.contains("clr-field")){var l=x.createElement("div");let e="clr-field";(ee.rtl||t.classList.contains("clr-rtl"))&&(e+=" clr-rtl"),l.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',a.insertBefore(l,t),l.className=e,l.style.color=t.value,l.appendChild(t)}}function _(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)}function N(e){if(g&&!ee.inline){const t=g;e&&(g=A,a!==t.value)&&(t.value=a,t.dispatchEvent(new Event("input",{bubbles:!0}))),setTimeout(()=>{a!==t.value&&t.dispatchEvent(new Event("change",{bubbles:!0}))}),p.classList.remove("clr-open"),E&&T(),t.dispatchEvent(new Event("close",{bubbles:!0})),ee.focusInput&&t.focus({preventScroll:!0}),g=A}}function O(e){var e=function(e){let t,a;V.fillStyle="#000",V.fillStyle=e,a=(t=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(V.fillStyle))?{r:+t[3],g:+t[4],b:+t[5],a:+t[6]}:(t=V.fillStyle.replace("#","").match(/.{2}/g).map(e=>parseInt(e,16)),{r:t[0],g:t[1],b:t[2],a:1});return a}(e),t=function(e){var t=e.r/255,a=e.g/255,l=e.b/255,r=C.max(t,a,l),o=C.min(t,a,l),o=r-o,n=r;let s=0,c=0;o&&(r===t&&(s=(a-l)/o),r===a&&(s=2+(l-t)/o),r===l&&(s=4+(t-a)/o),r)&&(c=o/r);return{h:(s=C.floor(60*s))<0?s+360:s,s:C.round(100*c),v:C.round(100*n),a:e.a}}(e);R(t.s,t.v),F(e,t),v.value=t.h,p.style.color=`hsl(${t.h}, 100%, 50%)`,l.style.left=t.h/360*100+"%",c.style.left=k.width*t.s/100+"px",c.style.top=k.height-k.height*t.v/100+"px",y.value=100*t.a,m.style.left=100*t.a+"%"}function D(e){e=e.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function P(e){e=e!==A?e:h.value,g&&(g.value=e,g.dispatchEvent(new Event("input",{bubbles:!0}))),ee.onChange&&ee.onChange.call(L,e,g),x.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:e,currentEl:g}}))}function j(e,t){var a,l,r,o,n,e={h:+v.value,s:e/k.width*100,v:100-t/k.height*100,a:y.value/100},s=(s=(t=e).s/100,a=t.v/100,s*=a,l=t.h/60,r=s*(1-C.abs(l%2-1)),s+=a-=s,r+=a,l=C.floor(l)%6,o=[s,r,a,a,r,s][l],n=[r,s,s,r,a,a][l],a=[a,a,r,s,s,r][l],{r:C.round(255*o),g:C.round(255*n),b:C.round(255*a),a:t.a});R(e.s,e.v),F(s,e),P()}function R(e,t){let a=ee.a11y.marker;e=+e.toFixed(1),t=+t.toFixed(1),a=(a=a.replace("{s}",e)).replace("{v}",t),c.setAttribute("aria-label",a)}function W(e){var t={pageX:((t=e).changedTouches?t.changedTouches[0]:t).pageX,pageY:(t.changedTouches?t.changedTouches[0]:t).pageY},a=t.pageX-k.x;let l=t.pageY-k.y;u&&(l+=u.scrollTop),q(a,l),e.preventDefault(),e.stopPropagation()}function q(e,t){e=e<0?0:e>k.width?k.width:e,t=t<0?0:t>k.height?k.height:t,c.style.left=e+"px",c.style.top=t+"px",j(e,t),c.focus()}function F(e,t){void 0===e&&(e={}),void 0===t&&(t={});let a=ee.format;for(const n in e)Z[n]=e[n];for(const s in t)Z[s]=t[s];var l,r=function(e){let t=e.r.toString(16),a=e.g.toString(16),l=e.b.toString(16),r="";e.r<16&&(t="0"+t);e.g<16&&(a="0"+a);e.b<16&&(l="0"+l);ee.alpha&&(e.a<1||ee.forceAlpha)&&(e=255*e.a|0,r=e.toString(16),e<16)&&(r="0"+r);return"#"+t+a+l+r}(Z),o=r.substring(0,7);switch(c.style.color=o,m.parentNode.style.color=o,m.style.color=r,i.style.color=r,d.style.display="none",d.offsetHeight,d.style.display="",m.nextElementSibling.style.display="none",m.nextElementSibling.offsetHeight,m.nextElementSibling.style.display="","mixed"===a?a=1===Z.a?"hex":"rgb":"auto"===a&&(a=w),a){case"hex":h.value=r;break;case"rgb":h.value=(l=Z,!ee.alpha||1===l.a&&!ee.forceAlpha?`rgb(${l.r}, ${l.g}, ${l.b})`:`rgba(${l.r}, ${l.g}, ${l.b}, ${l.a})`);break;case"hsl":h.value=(l=function(e){var t=e.v/100,a=t*(1-e.s/100/2);let l;0<a&&a<1&&(l=C.round((t-a)/C.min(a,1-a)*100));return{h:e.h,s:l||0,l:C.round(100*a),a:e.a}}(Z),!ee.alpha||1===l.a&&!ee.forceAlpha?`hsl(${l.h}, ${l.s}%, ${l.l}%)`:`hsla(${l.h}, ${l.s}%, ${l.l}%, ${l.a})`)}x.querySelector(`.clr-format [value="${a}"]`).checked=!0}function Y(){var e=+v.value,t=+c.style.left.replace("px",""),a=+c.style.top.replace("px","");p.style.color=`hsl(${e}, 100%, 50%)`,l.style.left=e/360*100+"%",j(t,a)}function U(){var e=y.value/100;m.style.left=100*e+"%",F({a:e}),P()}function X(){x.getElementById("clr-picker")||(u=A,(p=x.createElement("div")).setAttribute("id","clr-picker"),p.className="clr-picker",p.innerHTML=`<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="${ee.a11y.input}">`+`<div id="clr-color-area" class="clr-gradient" role="application" aria-label="${ee.a11y.instruction}">`+'<div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue">'+`<input id="clr-hue-slider" name="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="${ee.a11y.hueSlider}">`+'<div id="clr-hue-marker"></div></div><div class="clr-alpha">'+`<input id="clr-alpha-slider" name="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="${ee.a11y.alphaSlider}">`+'<div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented">'+`<legend>${ee.a11y.format}</legend>`+'<input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div>'+`<button type="button" id="clr-clear" class="clr-clear" aria-label="${ee.a11y.clear}">${ee.clearLabel}</button>`+'<div id="clr-color-preview" class="clr-preview">'+`<button type="button" id="clr-close" class="clr-close" aria-label="${ee.a11y.close}">${ee.closeLabel}</button>`+"</div>"+`<span id="clr-open-label" hidden>${ee.a11y.open}</span>`+`<span id="clr-swatch-label" hidden>${ee.a11y.swatch}</span>`,x.body.appendChild(p),d=G("clr-color-area"),c=G("clr-color-marker"),f=G("clr-clear"),b=G("clr-close"),i=G("clr-color-preview"),h=G("clr-color-value"),v=G("clr-hue-slider"),l=G("clr-hue-marker"),y=G("clr-alpha-slider"),m=G("clr-alpha-marker"),B(ee.el),H(ee.el),K(p,"mousedown",e=>{p.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),K(d,"mousedown",e=>{K(x,"mousemove",W)}),K(d,"contextmenu",e=>{e.preventDefault()}),K(d,"touchstart",e=>{x.addEventListener("touchmove",W,{passive:!1})}),K(c,"mousedown",e=>{K(x,"mousemove",W)}),K(c,"touchstart",e=>{x.addEventListener("touchmove",W,{passive:!1})}),K(h,"change",e=>{var t=h.value;(g||ee.inline)&&P(""===t?t:O(t))}),K(f,"click",e=>{P(""),N()}),K(b,"click",e=>{P(),N()}),K(G("clr-format"),"click",".clr-format input",e=>{w=e.target.value,F(),P()}),K(p,"click",".clr-swatches button",e=>{O(e.target.textContent),P(),ee.swatchesOnly&&N()}),K(x,"mouseup",e=>{x.removeEventListener("mousemove",W)}),K(x,"touchend",e=>{x.removeEventListener("touchmove",W)}),K(x,"mousedown",e=>{o=!1,p.classList.remove("clr-keyboard-nav"),N()}),K(x,"keydown",e=>{var t,a=e.key,l=e.target,r=e.shiftKey;"Escape"===a?N(!0):["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(a)&&(o=!0,p.classList.add("clr-keyboard-nav")),"Tab"===a&&l.matches(".clr-picker *")&&(t=(a=z()).shift(),a=a.pop(),r&&l===t?(a.focus(),e.preventDefault()):r||l!==a||(t.focus(),e.preventDefault()))}),K(x,"click",".clr-field button",e=>{E&&T(),e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),K(c,"keydown",e=>{var t,a={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(a).includes(e.key)&&([a,t]=[...a[e.key]],q(+c.style.left.replace("px","")+a,+c.style.top.replace("px","")+t),e.preventDefault())}),K(d,"click",W),K(v,"input",Y),K(y,"input",U))}function z(){return Array.from(p.querySelectorAll("input, button")).filter(e=>!!e.offsetWidth)}function G(e){return x.getElementById(e)}function K(e,t,a,l){const r=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof a?e.addEventListener(t,e=>{r.call(e.target,a)&&l.call(e.target,e)}):(l=a,e.addEventListener(t,l))}function J(e,t){t=t!==A?t:[],"loading"!==x.readyState?e(...t):x.addEventListener("DOMContentLoaded",()=>{e(...t)})}function ae(e,t){g=t,a=g.value,r(t),w=D(e),M(),O(e),P(),a!==e&&g.dispatchEvent(new Event("change",{bubbles:!0}))}NodeList!==A&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);var Q=(()=>{const l={init:X,set:S,wrap:H,close:N,setInstance:e,setColor:ae,removeInstance:$,updatePosition:M,ready:J};function t(e){J(()=>{e&&("string"==typeof e?B:S)(e)})}for(const r in l)t[r]=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];J(l[r],t)};return J(()=>{L.addEventListener("resize",e=>{t.updatePosition()}),L.addEventListener("scroll",e=>{t.updatePosition()})}),t})();return Q.coloris=Q}})(),_coloris=Coloris.coloris,_init=Coloris.init,_set=Coloris.set,_wrap=Coloris.wrap,_close=Coloris.close,_setInstance=Coloris.setInstance,_removeInstance=Coloris.removeInstance,_updatePosition=Coloris.updatePosition;export default Coloris;export{_coloris as coloris,_close as close,_init as init,_set as set,_wrap as wrap,_setInstance as setInstance,_removeInstance as removeInstance,_updatePosition as updatePosition};
1
+ const Coloris=(()=>{{var L=window,x=document,C=Math,A=void 0;const V=x.createElement("canvas").getContext("2d"),Z={r:0,g:0,b:0,h:0,s:0,v:0,a:1};let u,p,d,c,i,h,f,b,v,l,y,m,g,w,a,o,k={};const ee={el:"[data-coloris]",parent:"body",theme:"default",themeMode:"light",rtl:!1,wrap:!0,margin:2,format:"hex",formatToggle:!1,swatches:[],swatchesOnly:!1,alpha:!0,forceAlpha:!1,focusInput:!0,selectInput:!1,inline:!1,defaultColor:"#000000",clearButton:!1,clearLabel:"Clear",closeButton:!1,closeLabel:"Close",onChange:()=>A,a11y:{open:"Open color picker",close:"Close color picker",clear:"Clear the selected color",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},te={};let n="",s={},E=!1;function S(t){if("object"==typeof t)for(const n in t)switch(n){case"el":B(t.el),!1!==t.wrap&&H(t.el);break;case"parent":(u=t.parent instanceof HTMLElement?t.parent:x.querySelector(t.parent))&&(u.appendChild(p),ee.parent=t.parent,u===x.body)&&(u=A);break;case"themeMode":ee.themeMode=t.themeMode,"auto"===t.themeMode&&L.matchMedia&&L.matchMedia("(prefers-color-scheme: dark)").matches&&(ee.themeMode="dark");case"theme":t.theme&&(ee.theme=t.theme),p.className=`clr-picker clr-${ee.theme} clr-`+ee.themeMode,ee.inline&&M();break;case"rtl":ee.rtl=!!t.rtl,Array.from(x.getElementsByClassName("clr-field")).forEach(e=>e.classList.toggle("clr-rtl",ee.rtl));break;case"margin":t.margin*=1,ee.margin=(isNaN(t.margin)?ee:t).margin;break;case"wrap":t.el&&t.wrap&&H(t.el);break;case"formatToggle":ee.formatToggle=!!t.formatToggle,G("clr-format").style.display=ee.formatToggle?"block":"none",ee.formatToggle&&(ee.format="auto");break;case"swatches":if(Array.isArray(t.swatches)){var a=G("clr-swatches");const s=x.createElement("div");a.textContent="",t.swatches.forEach((e,t)=>{var a=x.createElement("button");a.setAttribute("type","button"),a.setAttribute("id","clr-swatch-"+t),a.setAttribute("aria-labelledby","clr-swatch-label clr-swatch-"+t),a.style.color=e,a.textContent=e,s.appendChild(a)}),t.swatches.length&&a.appendChild(s),ee.swatches=t.swatches.slice()}break;case"swatchesOnly":ee.swatchesOnly=!!t.swatchesOnly,p.setAttribute("data-minimal",ee.swatchesOnly);break;case"alpha":ee.alpha=!!t.alpha,p.setAttribute("data-alpha",ee.alpha);break;case"inline":ee.inline=!!t.inline,p.setAttribute("data-inline",ee.inline),ee.inline&&(a=t.defaultColor||ee.defaultColor,w=D(a),M(),O(a));break;case"clearButton":"object"==typeof t.clearButton&&(t.clearButton.label&&(ee.clearLabel=t.clearButton.label,f.innerHTML=ee.clearLabel),t.clearButton=t.clearButton.show),ee.clearButton=!!t.clearButton,f.style.display=ee.clearButton?"block":"none";break;case"clearLabel":ee.clearLabel=t.clearLabel,f.innerHTML=ee.clearLabel;break;case"closeButton":ee.closeButton=!!t.closeButton,ee.closeButton?p.insertBefore(b,i):i.appendChild(b);break;case"closeLabel":ee.closeLabel=t.closeLabel,b.innerHTML=ee.closeLabel;break;case"a11y":var l,r,o=t.a11y;let e=!1;if("object"==typeof o)for(const c in o)o[c]&&ee.a11y[c]&&(ee.a11y[c]=o[c],e=!0);e&&(l=G("clr-open-label"),r=G("clr-swatch-label"),l.innerHTML=ee.a11y.open,r.innerHTML=ee.a11y.swatch,b.setAttribute("aria-label",ee.a11y.close),f.setAttribute("aria-label",ee.a11y.clear),v.setAttribute("aria-label",ee.a11y.hueSlider),y.setAttribute("aria-label",ee.a11y.alphaSlider),h.setAttribute("aria-label",ee.a11y.input),d.setAttribute("aria-label",ee.a11y.instruction));break;default:ee[n]=t[n]}}function e(e,t){"string"==typeof e&&"object"==typeof t&&(te[e]=t,E=!0)}function T(e){delete te[e],0===Object.keys(te).length&&(E=!1,e===n)&&$()}function r(e){if(E){var t,a=["el","wrap","rtl","inline","defaultColor","a11y"];for(t in te){const r=te[t];if(e.matches(t)){for(var l in n=t,s={},a.forEach(e=>delete r[e]),r)s[l]=Array.isArray(ee[l])?ee[l].slice():ee[l];S(r);break}}}}function $(){0<Object.keys(s).length&&(S(s),n="",s={})}function B(e){e instanceof HTMLElement&&(e=[e]),Array.isArray(e)?e.forEach(e=>{K(e,"click",t),K(e,"input",_)}):(K(x,"click",e,t),K(x,"input",e,_))}function t(e){ee.inline||(r(e.target),g=e.target,a=g.value,w=D(a),p.classList.add("clr-open"),M(),O(a),(ee.focusInput||ee.selectInput)&&(h.focus({preventScroll:!0}),h.setSelectionRange(g.selectionStart,g.selectionEnd)),ee.selectInput&&h.select(),(o||ee.swatchesOnly)&&z().shift().focus(),g.dispatchEvent(new Event("open",{bubbles:!1})))}function M(){if(p&&(g||ee.inline)){var r=u,o=L.scrollY,n=p.offsetWidth,s=p.offsetHeight,c={left:!1,top:!1};let e,a,t,l={x:0,y:0};if(r&&(e=L.getComputedStyle(r),a=parseFloat(e.marginTop),t=parseFloat(e.borderTopWidth),(l=r.getBoundingClientRect()).y+=t+o),!ee.inline){var i=g.getBoundingClientRect();let e=i.x,t=o+i.y+i.height+ee.margin;r?(e-=l.x,t-=l.y,e+n>r.clientWidth&&(e+=i.width-n,c.left=!0),t+s>r.clientHeight-a&&s+ee.margin<=i.top-(l.y-o)&&(t-=i.height+s+2*ee.margin,c.top=!0),t+=r.scrollTop):(e+n>x.documentElement.clientWidth&&(e+=i.width-n,c.left=!0),t+s-o>x.documentElement.clientHeight&&s+ee.margin<=i.top&&(t=o+i.y-s-ee.margin,c.top=!0)),p.classList.toggle("clr-left",c.left),p.classList.toggle("clr-top",c.top),p.style.left=e+"px",p.style.top=t+"px",l.x+=p.offsetLeft,l.y+=p.offsetTop}k={width:d.offsetWidth,height:d.offsetHeight,x:d.offsetLeft+l.x,y:d.offsetTop+l.y}}}function H(e){e instanceof HTMLElement?I(e):(Array.isArray(e)?e:x.querySelectorAll(e)).forEach(I)}function I(t){var a=t.parentNode;if(!a.classList.contains("clr-field")){var l=x.createElement("div");let e="clr-field";(ee.rtl||t.classList.contains("clr-rtl"))&&(e+=" clr-rtl"),l.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',a.insertBefore(l,t),l.className=e,l.style.color=t.value,l.appendChild(t)}}function _(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)}function N(e){if(g&&!ee.inline){const t=g;e&&(g=A,a!==t.value)&&(t.value=a,t.dispatchEvent(new Event("input",{bubbles:!0}))),setTimeout(()=>{a!==t.value&&t.dispatchEvent(new Event("change",{bubbles:!0}))}),p.classList.remove("clr-open"),E&&$(),t.dispatchEvent(new Event("close",{bubbles:!1})),ee.focusInput&&t.focus({preventScroll:!0}),g=A}}function O(e){var e=function(e){let t,a;V.fillStyle="#000",V.fillStyle=e,a=(t=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(V.fillStyle))?{r:+t[3],g:+t[4],b:+t[5],a:+t[6]}:(t=V.fillStyle.replace("#","").match(/.{2}/g).map(e=>parseInt(e,16)),{r:t[0],g:t[1],b:t[2],a:1});return a}(e),t=function(e){var t=e.r/255,a=e.g/255,l=e.b/255,r=C.max(t,a,l),o=C.min(t,a,l),o=r-o,n=r;let s=0,c=0;o&&(r===t&&(s=(a-l)/o),r===a&&(s=2+(l-t)/o),r===l&&(s=4+(t-a)/o),r)&&(c=o/r);return{h:(s=C.floor(60*s))<0?s+360:s,s:C.round(100*c),v:C.round(100*n),a:e.a}}(e);R(t.s,t.v),F(e,t),v.value=t.h,p.style.color=`hsl(${t.h}, 100%, 50%)`,l.style.left=t.h/360*100+"%",c.style.left=k.width*t.s/100+"px",c.style.top=k.height-k.height*t.v/100+"px",y.value=100*t.a,m.style.left=100*t.a+"%"}function D(e){e=e.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function P(e){e=e!==A?e:h.value,g&&(g.value=e,g.dispatchEvent(new Event("input",{bubbles:!0}))),ee.onChange&&ee.onChange.call(L,e,g),x.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:e,currentEl:g}}))}function j(e,t){var a,l,r,o,n,e={h:+v.value,s:e/k.width*100,v:100-t/k.height*100,a:y.value/100},s=(s=(t=e).s/100,a=t.v/100,s*=a,l=t.h/60,r=s*(1-C.abs(l%2-1)),s+=a-=s,r+=a,l=C.floor(l)%6,o=[s,r,a,a,r,s][l],n=[r,s,s,r,a,a][l],a=[a,a,r,s,s,r][l],{r:C.round(255*o),g:C.round(255*n),b:C.round(255*a),a:t.a});R(e.s,e.v),F(s,e),P()}function R(e,t){let a=ee.a11y.marker;e=+e.toFixed(1),t=+t.toFixed(1),a=(a=a.replace("{s}",e)).replace("{v}",t),c.setAttribute("aria-label",a)}function W(e){var t={pageX:((t=e).changedTouches?t.changedTouches[0]:t).pageX,pageY:(t.changedTouches?t.changedTouches[0]:t).pageY},a=t.pageX-k.x;let l=t.pageY-k.y;u&&(l+=u.scrollTop),q(a,l),e.preventDefault(),e.stopPropagation()}function q(e,t){e=e<0?0:e>k.width?k.width:e,t=t<0?0:t>k.height?k.height:t,c.style.left=e+"px",c.style.top=t+"px",j(e,t),c.focus()}function F(e,t){void 0===e&&(e={}),void 0===t&&(t={});let a=ee.format;for(const n in e)Z[n]=e[n];for(const s in t)Z[s]=t[s];var l,r=function(e){let t=e.r.toString(16),a=e.g.toString(16),l=e.b.toString(16),r="";e.r<16&&(t="0"+t);e.g<16&&(a="0"+a);e.b<16&&(l="0"+l);ee.alpha&&(e.a<1||ee.forceAlpha)&&(e=255*e.a|0,r=e.toString(16),e<16)&&(r="0"+r);return"#"+t+a+l+r}(Z),o=r.substring(0,7);switch(c.style.color=o,m.parentNode.style.color=o,m.style.color=r,i.style.color=r,d.style.display="none",d.offsetHeight,d.style.display="",m.nextElementSibling.style.display="none",m.nextElementSibling.offsetHeight,m.nextElementSibling.style.display="","mixed"===a?a=1===Z.a?"hex":"rgb":"auto"===a&&(a=w),a){case"hex":h.value=r;break;case"rgb":h.value=(l=Z,!ee.alpha||1===l.a&&!ee.forceAlpha?`rgb(${l.r}, ${l.g}, ${l.b})`:`rgba(${l.r}, ${l.g}, ${l.b}, ${l.a})`);break;case"hsl":h.value=(l=function(e){var t=e.v/100,a=t*(1-e.s/100/2);let l;0<a&&a<1&&(l=C.round((t-a)/C.min(a,1-a)*100));return{h:e.h,s:l||0,l:C.round(100*a),a:e.a}}(Z),!ee.alpha||1===l.a&&!ee.forceAlpha?`hsl(${l.h}, ${l.s}%, ${l.l}%)`:`hsla(${l.h}, ${l.s}%, ${l.l}%, ${l.a})`)}x.querySelector(`.clr-format [value="${a}"]`).checked=!0}function U(){var e=+v.value,t=+c.style.left.replace("px",""),a=+c.style.top.replace("px","");p.style.color=`hsl(${e}, 100%, 50%)`,l.style.left=e/360*100+"%",j(t,a)}function Y(){var e=y.value/100;m.style.left=100*e+"%",F({a:e}),P()}function X(){x.getElementById("clr-picker")||(u=A,(p=x.createElement("div")).setAttribute("id","clr-picker"),p.className="clr-picker",p.innerHTML=`<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="${ee.a11y.input}">`+`<div id="clr-color-area" class="clr-gradient" role="application" aria-label="${ee.a11y.instruction}">`+'<div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue">'+`<input id="clr-hue-slider" name="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="${ee.a11y.hueSlider}">`+'<div id="clr-hue-marker"></div></div><div class="clr-alpha">'+`<input id="clr-alpha-slider" name="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="${ee.a11y.alphaSlider}">`+'<div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented">'+`<legend>${ee.a11y.format}</legend>`+'<input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div>'+`<button type="button" id="clr-clear" class="clr-clear" aria-label="${ee.a11y.clear}">${ee.clearLabel}</button>`+'<div id="clr-color-preview" class="clr-preview">'+`<button type="button" id="clr-close" class="clr-close" aria-label="${ee.a11y.close}">${ee.closeLabel}</button>`+"</div>"+`<span id="clr-open-label" hidden>${ee.a11y.open}</span>`+`<span id="clr-swatch-label" hidden>${ee.a11y.swatch}</span>`,x.body.appendChild(p),d=G("clr-color-area"),c=G("clr-color-marker"),f=G("clr-clear"),b=G("clr-close"),i=G("clr-color-preview"),h=G("clr-color-value"),v=G("clr-hue-slider"),l=G("clr-hue-marker"),y=G("clr-alpha-slider"),m=G("clr-alpha-marker"),B(ee.el),H(ee.el),K(p,"mousedown",e=>{p.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),K(d,"mousedown",e=>{K(x,"mousemove",W)}),K(d,"contextmenu",e=>{e.preventDefault()}),K(d,"touchstart",e=>{x.addEventListener("touchmove",W,{passive:!1})}),K(c,"mousedown",e=>{K(x,"mousemove",W)}),K(c,"touchstart",e=>{x.addEventListener("touchmove",W,{passive:!1})}),K(h,"change",e=>{var t=h.value;(g||ee.inline)&&P(""===t?t:O(t))}),K(f,"click",e=>{P(""),N()}),K(b,"click",e=>{P(),N()}),K(G("clr-format"),"click",".clr-format input",e=>{w=e.target.value,F(),P()}),K(p,"click",".clr-swatches button",e=>{O(e.target.textContent),P(),ee.swatchesOnly&&N()}),K(x,"mouseup",e=>{x.removeEventListener("mousemove",W)}),K(x,"touchend",e=>{x.removeEventListener("touchmove",W)}),K(x,"mousedown",e=>{o=!1,p.classList.remove("clr-keyboard-nav"),N()}),K(x,"keydown",e=>{var t,a=e.key,l=e.target,r=e.shiftKey;"Escape"===a?N(!0):"Enter"===a&&"BUTTON"!==l.tagName?N():(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(a)&&(o=!0,p.classList.add("clr-keyboard-nav")),"Tab"===a&&l.matches(".clr-picker *")&&(t=(a=z()).shift(),a=a.pop(),r&&l===t?(a.focus(),e.preventDefault()):r||l!==a||(t.focus(),e.preventDefault())))}),K(x,"click",".clr-field button",e=>{E&&$(),e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),K(c,"keydown",e=>{var t,a={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(a).includes(e.key)&&([a,t]=[...a[e.key]],q(+c.style.left.replace("px","")+a,+c.style.top.replace("px","")+t),e.preventDefault())}),K(d,"click",W),K(v,"input",U),K(y,"input",Y))}function z(){return Array.from(p.querySelectorAll("input, button")).filter(e=>!!e.offsetWidth)}function G(e){return x.getElementById(e)}function K(e,t,a,l){const r=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof a?e.addEventListener(t,e=>{r.call(e.target,a)&&l.call(e.target,e)}):(l=a,e.addEventListener(t,l))}function J(e,t){t=t!==A?t:[],"loading"!==x.readyState?e(...t):x.addEventListener("DOMContentLoaded",()=>{e(...t)})}function ae(e,t){g=t,a=g.value,r(t),w=D(e),M(),O(e),P(),a!==e&&g.dispatchEvent(new Event("change",{bubbles:!0}))}NodeList!==A&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);var Q=(()=>{const l={init:X,set:S,wrap:H,close:N,setInstance:e,setColor:ae,removeInstance:T,updatePosition:M,ready:J};function t(e){J(()=>{e&&("string"==typeof e?B:S)(e)})}for(const r in l)t[r]=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];J(l[r],t)};return J(()=>{L.addEventListener("resize",e=>{t.updatePosition()}),L.addEventListener("scroll",e=>{t.updatePosition()})}),t})();return Q.coloris=Q}})(),_coloris=Coloris.coloris,_init=Coloris.init,_set=Coloris.set,_wrap=Coloris.wrap,_close=Coloris.close,_setInstance=Coloris.setInstance,_removeInstance=Coloris.removeInstance,_updatePosition=Coloris.updatePosition;export default Coloris;export{_coloris as coloris,_close as close,_init as init,_set as set,_wrap as wrap,_setInstance as setInstance,_removeInstance as removeInstance,_updatePosition as updatePosition};
@@ -44,7 +44,7 @@
44
44
  * Copyright (c) 2021-2024 Momo Bassit.
45
45
  * Licensed under the MIT License (MIT)
46
46
  * https://github.com/mdbassit/Coloris
47
- * Version: 0.24.0
47
+ * Version: 0.25.0
48
48
  * NPM: https://github.com/melloware/coloris-npm
49
49
  */
50
50
 
@@ -409,7 +409,7 @@
409
409
  }
410
410
 
411
411
  // Trigger an "open" event
412
- currentEl.dispatchEvent(new Event('open', { bubbles: true }));
412
+ currentEl.dispatchEvent(new Event('open', { bubbles: false }));
413
413
  }
414
414
 
415
415
  /**
@@ -577,7 +577,7 @@
577
577
  }
578
578
 
579
579
  // Trigger a "close" event
580
- prevEl.dispatchEvent(new Event('close', { bubbles: true }));
580
+ prevEl.dispatchEvent(new Event('close', { bubbles: false }));
581
581
 
582
582
  if (settings.focusInput) {
583
583
  prevEl.focus({ preventScroll: true });
@@ -1150,6 +1150,12 @@
1150
1150
 
1151
1151
  if (key === 'Escape') {
1152
1152
  closePicker(true);
1153
+ return;
1154
+
1155
+ // Close the color picker and keep the selected color on press on Enter
1156
+ } else if (key === 'Enter' && target.tagName !== 'BUTTON') {
1157
+ closePicker();
1158
+ return;
1153
1159
 
1154
1160
  // Display focus rings when using the keyboard
1155
1161
  } else if (navKeys.includes(key)) {
@@ -1 +1 @@
1
- !function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof module&&module.exports?module.exports=t():(e.Coloris=t(),"object"==typeof window&&e.Coloris.init())}("undefined"!=typeof self?self:void 0,function(){{var L=window,x=document,A=Math,C=void 0;const Z=x.createElement("canvas").getContext("2d"),_={r:0,g:0,b:0,h:0,s:0,v:0,a:1};let u,d,p,i,s,h,f,b,y,a,v,m,g,w,l,o,k={};const ee={el:"[data-coloris]",parent:"body",theme:"default",themeMode:"light",rtl:!1,wrap:!0,margin:2,format:"hex",formatToggle:!1,swatches:[],swatchesOnly:!1,alpha:!0,forceAlpha:!1,focusInput:!0,selectInput:!1,inline:!1,defaultColor:"#000000",clearButton:!1,clearLabel:"Clear",closeButton:!1,closeLabel:"Close",onChange:()=>C,a11y:{open:"Open color picker",close:"Close color picker",clear:"Clear the selected color",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},te={};let n="",c={},E=!1;function S(t){if("object"==typeof t)for(const n in t)switch(n){case"el":B(t.el),!1!==t.wrap&&H(t.el);break;case"parent":(u=t.parent instanceof HTMLElement?t.parent:x.querySelector(t.parent))&&(u.appendChild(d),ee.parent=t.parent,u===x.body)&&(u=C);break;case"themeMode":ee.themeMode=t.themeMode,"auto"===t.themeMode&&L.matchMedia&&L.matchMedia("(prefers-color-scheme: dark)").matches&&(ee.themeMode="dark");case"theme":t.theme&&(ee.theme=t.theme),d.className=`clr-picker clr-${ee.theme} clr-`+ee.themeMode,ee.inline&&M();break;case"rtl":ee.rtl=!!t.rtl,Array.from(x.getElementsByClassName("clr-field")).forEach(e=>e.classList.toggle("clr-rtl",ee.rtl));break;case"margin":t.margin*=1,ee.margin=(isNaN(t.margin)?ee:t).margin;break;case"wrap":t.el&&t.wrap&&H(t.el);break;case"formatToggle":ee.formatToggle=!!t.formatToggle,K("clr-format").style.display=ee.formatToggle?"block":"none",ee.formatToggle&&(ee.format="auto");break;case"swatches":if(Array.isArray(t.swatches)){var l=K("clr-swatches");const c=x.createElement("div");l.textContent="",t.swatches.forEach((e,t)=>{var l=x.createElement("button");l.setAttribute("type","button"),l.setAttribute("id","clr-swatch-"+t),l.setAttribute("aria-labelledby","clr-swatch-label clr-swatch-"+t),l.style.color=e,l.textContent=e,c.appendChild(l)}),t.swatches.length&&l.appendChild(c),ee.swatches=t.swatches.slice()}break;case"swatchesOnly":ee.swatchesOnly=!!t.swatchesOnly,d.setAttribute("data-minimal",ee.swatchesOnly);break;case"alpha":ee.alpha=!!t.alpha,d.setAttribute("data-alpha",ee.alpha);break;case"inline":ee.inline=!!t.inline,d.setAttribute("data-inline",ee.inline),ee.inline&&(l=t.defaultColor||ee.defaultColor,w=j(l),M(),I(l));break;case"clearButton":"object"==typeof t.clearButton&&(t.clearButton.label&&(ee.clearLabel=t.clearButton.label,f.innerHTML=ee.clearLabel),t.clearButton=t.clearButton.show),ee.clearButton=!!t.clearButton,f.style.display=ee.clearButton?"block":"none";break;case"clearLabel":ee.clearLabel=t.clearLabel,f.innerHTML=ee.clearLabel;break;case"closeButton":ee.closeButton=!!t.closeButton,ee.closeButton?d.insertBefore(b,s):s.appendChild(b);break;case"closeLabel":ee.closeLabel=t.closeLabel,b.innerHTML=ee.closeLabel;break;case"a11y":var a,r,o=t.a11y;let e=!1;if("object"==typeof o)for(const i in o)o[i]&&ee.a11y[i]&&(ee.a11y[i]=o[i],e=!0);e&&(a=K("clr-open-label"),r=K("clr-swatch-label"),a.innerHTML=ee.a11y.open,r.innerHTML=ee.a11y.swatch,b.setAttribute("aria-label",ee.a11y.close),f.setAttribute("aria-label",ee.a11y.clear),y.setAttribute("aria-label",ee.a11y.hueSlider),v.setAttribute("aria-label",ee.a11y.alphaSlider),h.setAttribute("aria-label",ee.a11y.input),p.setAttribute("aria-label",ee.a11y.instruction));break;default:ee[n]=t[n]}}function e(e,t){"string"==typeof e&&"object"==typeof t&&(te[e]=t,E=!0)}function $(e){delete te[e],0===Object.keys(te).length&&(E=!1,e===n)&&T()}function r(e){if(E){var t,l=["el","wrap","rtl","inline","defaultColor","a11y"];for(t in te){const r=te[t];if(e.matches(t)){for(var a in n=t,c={},l.forEach(e=>delete r[e]),r)c[a]=Array.isArray(ee[a])?ee[a].slice():ee[a];S(r);break}}}}function T(){0<Object.keys(c).length&&(S(c),n="",c={})}function B(e){e instanceof HTMLElement&&(e=[e]),Array.isArray(e)?e.forEach(e=>{J(e,"click",t),J(e,"input",O)}):(J(x,"click",e,t),J(x,"input",e,O))}function t(e){ee.inline||(r(e.target),g=e.target,l=g.value,w=j(l),d.classList.add("clr-open"),M(),I(l),(ee.focusInput||ee.selectInput)&&(h.focus({preventScroll:!0}),h.setSelectionRange(g.selectionStart,g.selectionEnd)),ee.selectInput&&h.select(),(o||ee.swatchesOnly)&&G().shift().focus(),g.dispatchEvent(new Event("open",{bubbles:!0})))}function M(){if(d&&(g||ee.inline)){var r=u,o=L.scrollY,n=d.offsetWidth,c=d.offsetHeight,i={left:!1,top:!1};let e,l,t,a={x:0,y:0};if(r&&(e=L.getComputedStyle(r),l=parseFloat(e.marginTop),t=parseFloat(e.borderTopWidth),(a=r.getBoundingClientRect()).y+=t+o),!ee.inline){var s=g.getBoundingClientRect();let e=s.x,t=o+s.y+s.height+ee.margin;r?(e-=a.x,t-=a.y,e+n>r.clientWidth&&(e+=s.width-n,i.left=!0),t+c>r.clientHeight-l&&c+ee.margin<=s.top-(a.y-o)&&(t-=s.height+c+2*ee.margin,i.top=!0),t+=r.scrollTop):(e+n>x.documentElement.clientWidth&&(e+=s.width-n,i.left=!0),t+c-o>x.documentElement.clientHeight&&c+ee.margin<=s.top&&(t=o+s.y-c-ee.margin,i.top=!0)),d.classList.toggle("clr-left",i.left),d.classList.toggle("clr-top",i.top),d.style.left=e+"px",d.style.top=t+"px",a.x+=d.offsetLeft,a.y+=d.offsetTop}k={width:p.offsetWidth,height:p.offsetHeight,x:p.offsetLeft+a.x,y:p.offsetTop+a.y}}}function H(e){e instanceof HTMLElement?N(e):(Array.isArray(e)?e:x.querySelectorAll(e)).forEach(N)}function N(t){var l=t.parentNode;if(!l.classList.contains("clr-field")){var a=x.createElement("div");let e="clr-field";(ee.rtl||t.classList.contains("clr-rtl"))&&(e+=" clr-rtl"),a.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',l.insertBefore(a,t),a.className=e,a.style.color=t.value,a.appendChild(t)}}function O(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)}function D(e){if(g&&!ee.inline){const t=g;e&&(g=C,l!==t.value)&&(t.value=l,t.dispatchEvent(new Event("input",{bubbles:!0}))),setTimeout(()=>{l!==t.value&&t.dispatchEvent(new Event("change",{bubbles:!0}))}),d.classList.remove("clr-open"),E&&T(),t.dispatchEvent(new Event("close",{bubbles:!0})),ee.focusInput&&t.focus({preventScroll:!0}),g=C}}function I(e){var e=function(e){let t,l;Z.fillStyle="#000",Z.fillStyle=e,l=(t=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(Z.fillStyle))?{r:+t[3],g:+t[4],b:+t[5],a:+t[6]}:(t=Z.fillStyle.replace("#","").match(/.{2}/g).map(e=>parseInt(e,16)),{r:t[0],g:t[1],b:t[2],a:1});return l}(e),t=function(e){var t=e.r/255,l=e.g/255,a=e.b/255,r=A.max(t,l,a),o=A.min(t,l,a),o=r-o,n=r;let c=0,i=0;o&&(r===t&&(c=(l-a)/o),r===l&&(c=2+(a-t)/o),r===a&&(c=4+(t-l)/o),r)&&(i=o/r);return{h:(c=A.floor(60*c))<0?c+360:c,s:A.round(100*i),v:A.round(100*n),a:e.a}}(e);P(t.s,t.v),Y(e,t),y.value=t.h,d.style.color=`hsl(${t.h}, 100%, 50%)`,a.style.left=t.h/360*100+"%",i.style.left=k.width*t.s/100+"px",i.style.top=k.height-k.height*t.v/100+"px",v.value=100*t.a,m.style.left=100*t.a+"%"}function j(e){e=e.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function R(e){e=e!==C?e:h.value,g&&(g.value=e,g.dispatchEvent(new Event("input",{bubbles:!0}))),ee.onChange&&ee.onChange.call(L,e,g),x.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:e,currentEl:g}}))}function W(e,t){var l,a,r,o,n,e={h:+y.value,s:e/k.width*100,v:100-t/k.height*100,a:v.value/100},c=(c=(t=e).s/100,l=t.v/100,c*=l,a=t.h/60,r=c*(1-A.abs(a%2-1)),c+=l-=c,r+=l,a=A.floor(a)%6,o=[c,r,l,l,r,c][a],n=[r,c,c,r,l,l][a],l=[l,l,r,c,c,r][a],{r:A.round(255*o),g:A.round(255*n),b:A.round(255*l),a:t.a});P(e.s,e.v),Y(c,e),R()}function P(e,t){let l=ee.a11y.marker;e=+e.toFixed(1),t=+t.toFixed(1),l=(l=l.replace("{s}",e)).replace("{v}",t),i.setAttribute("aria-label",l)}function q(e){var t={pageX:((t=e).changedTouches?t.changedTouches[0]:t).pageX,pageY:(t.changedTouches?t.changedTouches[0]:t).pageY},l=t.pageX-k.x;let a=t.pageY-k.y;u&&(a+=u.scrollTop),F(l,a),e.preventDefault(),e.stopPropagation()}function F(e,t){e=e<0?0:e>k.width?k.width:e,t=t<0?0:t>k.height?k.height:t,i.style.left=e+"px",i.style.top=t+"px",W(e,t),i.focus()}function Y(e,t){void 0===e&&(e={}),void 0===t&&(t={});let l=ee.format;for(const n in e)_[n]=e[n];for(const c in t)_[c]=t[c];var a,r=function(e){let t=e.r.toString(16),l=e.g.toString(16),a=e.b.toString(16),r="";e.r<16&&(t="0"+t);e.g<16&&(l="0"+l);e.b<16&&(a="0"+a);ee.alpha&&(e.a<1||ee.forceAlpha)&&(e=255*e.a|0,r=e.toString(16),e<16)&&(r="0"+r);return"#"+t+l+a+r}(_),o=r.substring(0,7);switch(i.style.color=o,m.parentNode.style.color=o,m.style.color=r,s.style.color=r,p.style.display="none",p.offsetHeight,p.style.display="",m.nextElementSibling.style.display="none",m.nextElementSibling.offsetHeight,m.nextElementSibling.style.display="","mixed"===l?l=1===_.a?"hex":"rgb":"auto"===l&&(l=w),l){case"hex":h.value=r;break;case"rgb":h.value=(a=_,!ee.alpha||1===a.a&&!ee.forceAlpha?`rgb(${a.r}, ${a.g}, ${a.b})`:`rgba(${a.r}, ${a.g}, ${a.b}, ${a.a})`);break;case"hsl":h.value=(a=function(e){var t=e.v/100,l=t*(1-e.s/100/2);let a;0<l&&l<1&&(a=A.round((t-l)/A.min(l,1-l)*100));return{h:e.h,s:a||0,l:A.round(100*l),a:e.a}}(_),!ee.alpha||1===a.a&&!ee.forceAlpha?`hsl(${a.h}, ${a.s}%, ${a.l}%)`:`hsla(${a.h}, ${a.s}%, ${a.l}%, ${a.a})`)}x.querySelector(`.clr-format [value="${l}"]`).checked=!0}function U(){var e=+y.value,t=+i.style.left.replace("px",""),l=+i.style.top.replace("px","");d.style.color=`hsl(${e}, 100%, 50%)`,a.style.left=e/360*100+"%",W(t,l)}function X(){var e=v.value/100;m.style.left=100*e+"%",Y({a:e}),R()}function z(){x.getElementById("clr-picker")||(u=C,(d=x.createElement("div")).setAttribute("id","clr-picker"),d.className="clr-picker",d.innerHTML=`<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="${ee.a11y.input}">`+`<div id="clr-color-area" class="clr-gradient" role="application" aria-label="${ee.a11y.instruction}">`+'<div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue">'+`<input id="clr-hue-slider" name="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="${ee.a11y.hueSlider}">`+'<div id="clr-hue-marker"></div></div><div class="clr-alpha">'+`<input id="clr-alpha-slider" name="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="${ee.a11y.alphaSlider}">`+'<div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented">'+`<legend>${ee.a11y.format}</legend>`+'<input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div>'+`<button type="button" id="clr-clear" class="clr-clear" aria-label="${ee.a11y.clear}">${ee.clearLabel}</button>`+'<div id="clr-color-preview" class="clr-preview">'+`<button type="button" id="clr-close" class="clr-close" aria-label="${ee.a11y.close}">${ee.closeLabel}</button>`+"</div>"+`<span id="clr-open-label" hidden>${ee.a11y.open}</span>`+`<span id="clr-swatch-label" hidden>${ee.a11y.swatch}</span>`,x.body.appendChild(d),p=K("clr-color-area"),i=K("clr-color-marker"),f=K("clr-clear"),b=K("clr-close"),s=K("clr-color-preview"),h=K("clr-color-value"),y=K("clr-hue-slider"),a=K("clr-hue-marker"),v=K("clr-alpha-slider"),m=K("clr-alpha-marker"),B(ee.el),H(ee.el),J(d,"mousedown",e=>{d.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),J(p,"mousedown",e=>{J(x,"mousemove",q)}),J(p,"contextmenu",e=>{e.preventDefault()}),J(p,"touchstart",e=>{x.addEventListener("touchmove",q,{passive:!1})}),J(i,"mousedown",e=>{J(x,"mousemove",q)}),J(i,"touchstart",e=>{x.addEventListener("touchmove",q,{passive:!1})}),J(h,"change",e=>{var t=h.value;(g||ee.inline)&&R(""===t?t:I(t))}),J(f,"click",e=>{R(""),D()}),J(b,"click",e=>{R(),D()}),J(K("clr-format"),"click",".clr-format input",e=>{w=e.target.value,Y(),R()}),J(d,"click",".clr-swatches button",e=>{I(e.target.textContent),R(),ee.swatchesOnly&&D()}),J(x,"mouseup",e=>{x.removeEventListener("mousemove",q)}),J(x,"touchend",e=>{x.removeEventListener("touchmove",q)}),J(x,"mousedown",e=>{o=!1,d.classList.remove("clr-keyboard-nav"),D()}),J(x,"keydown",e=>{var t,l=e.key,a=e.target,r=e.shiftKey;"Escape"===l?D(!0):["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(l)&&(o=!0,d.classList.add("clr-keyboard-nav")),"Tab"===l&&a.matches(".clr-picker *")&&(t=(l=G()).shift(),l=l.pop(),r&&a===t?(l.focus(),e.preventDefault()):r||a!==l||(t.focus(),e.preventDefault()))}),J(x,"click",".clr-field button",e=>{E&&T(),e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),J(i,"keydown",e=>{var t,l={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(l).includes(e.key)&&([l,t]=[...l[e.key]],F(+i.style.left.replace("px","")+l,+i.style.top.replace("px","")+t),e.preventDefault())}),J(p,"click",q),J(y,"input",U),J(v,"input",X))}function G(){return Array.from(d.querySelectorAll("input, button")).filter(e=>!!e.offsetWidth)}function K(e){return x.getElementById(e)}function J(e,t,l,a){const r=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof l?e.addEventListener(t,e=>{r.call(e.target,l)&&a.call(e.target,e)}):(a=l,e.addEventListener(t,a))}function Q(e,t){t=t!==C?t:[],"loading"!==x.readyState?e(...t):x.addEventListener("DOMContentLoaded",()=>{e(...t)})}function le(e,t){g=t,l=g.value,r(t),w=j(e),M(),I(e),R(),l!==e&&g.dispatchEvent(new Event("change",{bubbles:!0}))}NodeList!==C&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);var V=(()=>{const a={init:z,set:S,wrap:H,close:D,setInstance:e,setColor:le,removeInstance:$,updatePosition:M,ready:Q};function t(e){Q(()=>{e&&("string"==typeof e?B:S)(e)})}for(const r in a)t[r]=function(){for(var e=arguments.length,t=new Array(e),l=0;l<e;l++)t[l]=arguments[l];Q(a[r],t)};return Q(()=>{L.addEventListener("resize",e=>{t.updatePosition()}),L.addEventListener("scroll",e=>{t.updatePosition()})}),t})();return V.coloris=V}});
1
+ !function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof module&&module.exports?module.exports=t():(e.Coloris=t(),"object"==typeof window&&e.Coloris.init())}("undefined"!=typeof self?self:void 0,function(){{var L=window,x=document,A=Math,C=void 0;const Z=x.createElement("canvas").getContext("2d"),_={r:0,g:0,b:0,h:0,s:0,v:0,a:1};let u,d,p,i,s,h,f,b,y,a,v,m,g,w,l,n,k={};const ee={el:"[data-coloris]",parent:"body",theme:"default",themeMode:"light",rtl:!1,wrap:!0,margin:2,format:"hex",formatToggle:!1,swatches:[],swatchesOnly:!1,alpha:!0,forceAlpha:!1,focusInput:!0,selectInput:!1,inline:!1,defaultColor:"#000000",clearButton:!1,clearLabel:"Clear",closeButton:!1,closeLabel:"Close",onChange:()=>C,a11y:{open:"Open color picker",close:"Close color picker",clear:"Clear the selected color",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},te={};let o="",c={},E=!1;function S(t){if("object"==typeof t)for(const o in t)switch(o){case"el":B(t.el),!1!==t.wrap&&H(t.el);break;case"parent":(u=t.parent instanceof HTMLElement?t.parent:x.querySelector(t.parent))&&(u.appendChild(d),ee.parent=t.parent,u===x.body)&&(u=C);break;case"themeMode":ee.themeMode=t.themeMode,"auto"===t.themeMode&&L.matchMedia&&L.matchMedia("(prefers-color-scheme: dark)").matches&&(ee.themeMode="dark");case"theme":t.theme&&(ee.theme=t.theme),d.className=`clr-picker clr-${ee.theme} clr-`+ee.themeMode,ee.inline&&M();break;case"rtl":ee.rtl=!!t.rtl,Array.from(x.getElementsByClassName("clr-field")).forEach(e=>e.classList.toggle("clr-rtl",ee.rtl));break;case"margin":t.margin*=1,ee.margin=(isNaN(t.margin)?ee:t).margin;break;case"wrap":t.el&&t.wrap&&H(t.el);break;case"formatToggle":ee.formatToggle=!!t.formatToggle,K("clr-format").style.display=ee.formatToggle?"block":"none",ee.formatToggle&&(ee.format="auto");break;case"swatches":if(Array.isArray(t.swatches)){var l=K("clr-swatches");const c=x.createElement("div");l.textContent="",t.swatches.forEach((e,t)=>{var l=x.createElement("button");l.setAttribute("type","button"),l.setAttribute("id","clr-swatch-"+t),l.setAttribute("aria-labelledby","clr-swatch-label clr-swatch-"+t),l.style.color=e,l.textContent=e,c.appendChild(l)}),t.swatches.length&&l.appendChild(c),ee.swatches=t.swatches.slice()}break;case"swatchesOnly":ee.swatchesOnly=!!t.swatchesOnly,d.setAttribute("data-minimal",ee.swatchesOnly);break;case"alpha":ee.alpha=!!t.alpha,d.setAttribute("data-alpha",ee.alpha);break;case"inline":ee.inline=!!t.inline,d.setAttribute("data-inline",ee.inline),ee.inline&&(l=t.defaultColor||ee.defaultColor,w=j(l),M(),I(l));break;case"clearButton":"object"==typeof t.clearButton&&(t.clearButton.label&&(ee.clearLabel=t.clearButton.label,f.innerHTML=ee.clearLabel),t.clearButton=t.clearButton.show),ee.clearButton=!!t.clearButton,f.style.display=ee.clearButton?"block":"none";break;case"clearLabel":ee.clearLabel=t.clearLabel,f.innerHTML=ee.clearLabel;break;case"closeButton":ee.closeButton=!!t.closeButton,ee.closeButton?d.insertBefore(b,s):s.appendChild(b);break;case"closeLabel":ee.closeLabel=t.closeLabel,b.innerHTML=ee.closeLabel;break;case"a11y":var a,r,n=t.a11y;let e=!1;if("object"==typeof n)for(const i in n)n[i]&&ee.a11y[i]&&(ee.a11y[i]=n[i],e=!0);e&&(a=K("clr-open-label"),r=K("clr-swatch-label"),a.innerHTML=ee.a11y.open,r.innerHTML=ee.a11y.swatch,b.setAttribute("aria-label",ee.a11y.close),f.setAttribute("aria-label",ee.a11y.clear),y.setAttribute("aria-label",ee.a11y.hueSlider),v.setAttribute("aria-label",ee.a11y.alphaSlider),h.setAttribute("aria-label",ee.a11y.input),p.setAttribute("aria-label",ee.a11y.instruction));break;default:ee[o]=t[o]}}function e(e,t){"string"==typeof e&&"object"==typeof t&&(te[e]=t,E=!0)}function T(e){delete te[e],0===Object.keys(te).length&&(E=!1,e===o)&&$()}function r(e){if(E){var t,l=["el","wrap","rtl","inline","defaultColor","a11y"];for(t in te){const r=te[t];if(e.matches(t)){for(var a in o=t,c={},l.forEach(e=>delete r[e]),r)c[a]=Array.isArray(ee[a])?ee[a].slice():ee[a];S(r);break}}}}function $(){0<Object.keys(c).length&&(S(c),o="",c={})}function B(e){e instanceof HTMLElement&&(e=[e]),Array.isArray(e)?e.forEach(e=>{J(e,"click",t),J(e,"input",O)}):(J(x,"click",e,t),J(x,"input",e,O))}function t(e){ee.inline||(r(e.target),g=e.target,l=g.value,w=j(l),d.classList.add("clr-open"),M(),I(l),(ee.focusInput||ee.selectInput)&&(h.focus({preventScroll:!0}),h.setSelectionRange(g.selectionStart,g.selectionEnd)),ee.selectInput&&h.select(),(n||ee.swatchesOnly)&&G().shift().focus(),g.dispatchEvent(new Event("open",{bubbles:!1})))}function M(){if(d&&(g||ee.inline)){var r=u,n=L.scrollY,o=d.offsetWidth,c=d.offsetHeight,i={left:!1,top:!1};let e,l,t,a={x:0,y:0};if(r&&(e=L.getComputedStyle(r),l=parseFloat(e.marginTop),t=parseFloat(e.borderTopWidth),(a=r.getBoundingClientRect()).y+=t+n),!ee.inline){var s=g.getBoundingClientRect();let e=s.x,t=n+s.y+s.height+ee.margin;r?(e-=a.x,t-=a.y,e+o>r.clientWidth&&(e+=s.width-o,i.left=!0),t+c>r.clientHeight-l&&c+ee.margin<=s.top-(a.y-n)&&(t-=s.height+c+2*ee.margin,i.top=!0),t+=r.scrollTop):(e+o>x.documentElement.clientWidth&&(e+=s.width-o,i.left=!0),t+c-n>x.documentElement.clientHeight&&c+ee.margin<=s.top&&(t=n+s.y-c-ee.margin,i.top=!0)),d.classList.toggle("clr-left",i.left),d.classList.toggle("clr-top",i.top),d.style.left=e+"px",d.style.top=t+"px",a.x+=d.offsetLeft,a.y+=d.offsetTop}k={width:p.offsetWidth,height:p.offsetHeight,x:p.offsetLeft+a.x,y:p.offsetTop+a.y}}}function H(e){e instanceof HTMLElement?N(e):(Array.isArray(e)?e:x.querySelectorAll(e)).forEach(N)}function N(t){var l=t.parentNode;if(!l.classList.contains("clr-field")){var a=x.createElement("div");let e="clr-field";(ee.rtl||t.classList.contains("clr-rtl"))&&(e+=" clr-rtl"),a.innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',l.insertBefore(a,t),a.className=e,a.style.color=t.value,a.appendChild(t)}}function O(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)}function D(e){if(g&&!ee.inline){const t=g;e&&(g=C,l!==t.value)&&(t.value=l,t.dispatchEvent(new Event("input",{bubbles:!0}))),setTimeout(()=>{l!==t.value&&t.dispatchEvent(new Event("change",{bubbles:!0}))}),d.classList.remove("clr-open"),E&&$(),t.dispatchEvent(new Event("close",{bubbles:!1})),ee.focusInput&&t.focus({preventScroll:!0}),g=C}}function I(e){var e=function(e){let t,l;Z.fillStyle="#000",Z.fillStyle=e,l=(t=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(Z.fillStyle))?{r:+t[3],g:+t[4],b:+t[5],a:+t[6]}:(t=Z.fillStyle.replace("#","").match(/.{2}/g).map(e=>parseInt(e,16)),{r:t[0],g:t[1],b:t[2],a:1});return l}(e),t=function(e){var t=e.r/255,l=e.g/255,a=e.b/255,r=A.max(t,l,a),n=A.min(t,l,a),n=r-n,o=r;let c=0,i=0;n&&(r===t&&(c=(l-a)/n),r===l&&(c=2+(a-t)/n),r===a&&(c=4+(t-l)/n),r)&&(i=n/r);return{h:(c=A.floor(60*c))<0?c+360:c,s:A.round(100*i),v:A.round(100*o),a:e.a}}(e);P(t.s,t.v),U(e,t),y.value=t.h,d.style.color=`hsl(${t.h}, 100%, 50%)`,a.style.left=t.h/360*100+"%",i.style.left=k.width*t.s/100+"px",i.style.top=k.height-k.height*t.v/100+"px",v.value=100*t.a,m.style.left=100*t.a+"%"}function j(e){e=e.substring(0,3).toLowerCase();return"rgb"===e||"hsl"===e?e:"hex"}function R(e){e=e!==C?e:h.value,g&&(g.value=e,g.dispatchEvent(new Event("input",{bubbles:!0}))),ee.onChange&&ee.onChange.call(L,e,g),x.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:e,currentEl:g}}))}function W(e,t){var l,a,r,n,o,e={h:+y.value,s:e/k.width*100,v:100-t/k.height*100,a:v.value/100},c=(c=(t=e).s/100,l=t.v/100,c*=l,a=t.h/60,r=c*(1-A.abs(a%2-1)),c+=l-=c,r+=l,a=A.floor(a)%6,n=[c,r,l,l,r,c][a],o=[r,c,c,r,l,l][a],l=[l,l,r,c,c,r][a],{r:A.round(255*n),g:A.round(255*o),b:A.round(255*l),a:t.a});P(e.s,e.v),U(c,e),R()}function P(e,t){let l=ee.a11y.marker;e=+e.toFixed(1),t=+t.toFixed(1),l=(l=l.replace("{s}",e)).replace("{v}",t),i.setAttribute("aria-label",l)}function q(e){var t={pageX:((t=e).changedTouches?t.changedTouches[0]:t).pageX,pageY:(t.changedTouches?t.changedTouches[0]:t).pageY},l=t.pageX-k.x;let a=t.pageY-k.y;u&&(a+=u.scrollTop),F(l,a),e.preventDefault(),e.stopPropagation()}function F(e,t){e=e<0?0:e>k.width?k.width:e,t=t<0?0:t>k.height?k.height:t,i.style.left=e+"px",i.style.top=t+"px",W(e,t),i.focus()}function U(e,t){void 0===e&&(e={}),void 0===t&&(t={});let l=ee.format;for(const o in e)_[o]=e[o];for(const c in t)_[c]=t[c];var a,r=function(e){let t=e.r.toString(16),l=e.g.toString(16),a=e.b.toString(16),r="";e.r<16&&(t="0"+t);e.g<16&&(l="0"+l);e.b<16&&(a="0"+a);ee.alpha&&(e.a<1||ee.forceAlpha)&&(e=255*e.a|0,r=e.toString(16),e<16)&&(r="0"+r);return"#"+t+l+a+r}(_),n=r.substring(0,7);switch(i.style.color=n,m.parentNode.style.color=n,m.style.color=r,s.style.color=r,p.style.display="none",p.offsetHeight,p.style.display="",m.nextElementSibling.style.display="none",m.nextElementSibling.offsetHeight,m.nextElementSibling.style.display="","mixed"===l?l=1===_.a?"hex":"rgb":"auto"===l&&(l=w),l){case"hex":h.value=r;break;case"rgb":h.value=(a=_,!ee.alpha||1===a.a&&!ee.forceAlpha?`rgb(${a.r}, ${a.g}, ${a.b})`:`rgba(${a.r}, ${a.g}, ${a.b}, ${a.a})`);break;case"hsl":h.value=(a=function(e){var t=e.v/100,l=t*(1-e.s/100/2);let a;0<l&&l<1&&(a=A.round((t-l)/A.min(l,1-l)*100));return{h:e.h,s:a||0,l:A.round(100*l),a:e.a}}(_),!ee.alpha||1===a.a&&!ee.forceAlpha?`hsl(${a.h}, ${a.s}%, ${a.l}%)`:`hsla(${a.h}, ${a.s}%, ${a.l}%, ${a.a})`)}x.querySelector(`.clr-format [value="${l}"]`).checked=!0}function Y(){var e=+y.value,t=+i.style.left.replace("px",""),l=+i.style.top.replace("px","");d.style.color=`hsl(${e}, 100%, 50%)`,a.style.left=e/360*100+"%",W(t,l)}function X(){var e=v.value/100;m.style.left=100*e+"%",U({a:e}),R()}function z(){x.getElementById("clr-picker")||(u=C,(d=x.createElement("div")).setAttribute("id","clr-picker"),d.className="clr-picker",d.innerHTML=`<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="${ee.a11y.input}">`+`<div id="clr-color-area" class="clr-gradient" role="application" aria-label="${ee.a11y.instruction}">`+'<div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue">'+`<input id="clr-hue-slider" name="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="${ee.a11y.hueSlider}">`+'<div id="clr-hue-marker"></div></div><div class="clr-alpha">'+`<input id="clr-alpha-slider" name="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="${ee.a11y.alphaSlider}">`+'<div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented">'+`<legend>${ee.a11y.format}</legend>`+'<input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div>'+`<button type="button" id="clr-clear" class="clr-clear" aria-label="${ee.a11y.clear}">${ee.clearLabel}</button>`+'<div id="clr-color-preview" class="clr-preview">'+`<button type="button" id="clr-close" class="clr-close" aria-label="${ee.a11y.close}">${ee.closeLabel}</button>`+"</div>"+`<span id="clr-open-label" hidden>${ee.a11y.open}</span>`+`<span id="clr-swatch-label" hidden>${ee.a11y.swatch}</span>`,x.body.appendChild(d),p=K("clr-color-area"),i=K("clr-color-marker"),f=K("clr-clear"),b=K("clr-close"),s=K("clr-color-preview"),h=K("clr-color-value"),y=K("clr-hue-slider"),a=K("clr-hue-marker"),v=K("clr-alpha-slider"),m=K("clr-alpha-marker"),B(ee.el),H(ee.el),J(d,"mousedown",e=>{d.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),J(p,"mousedown",e=>{J(x,"mousemove",q)}),J(p,"contextmenu",e=>{e.preventDefault()}),J(p,"touchstart",e=>{x.addEventListener("touchmove",q,{passive:!1})}),J(i,"mousedown",e=>{J(x,"mousemove",q)}),J(i,"touchstart",e=>{x.addEventListener("touchmove",q,{passive:!1})}),J(h,"change",e=>{var t=h.value;(g||ee.inline)&&R(""===t?t:I(t))}),J(f,"click",e=>{R(""),D()}),J(b,"click",e=>{R(),D()}),J(K("clr-format"),"click",".clr-format input",e=>{w=e.target.value,U(),R()}),J(d,"click",".clr-swatches button",e=>{I(e.target.textContent),R(),ee.swatchesOnly&&D()}),J(x,"mouseup",e=>{x.removeEventListener("mousemove",q)}),J(x,"touchend",e=>{x.removeEventListener("touchmove",q)}),J(x,"mousedown",e=>{n=!1,d.classList.remove("clr-keyboard-nav"),D()}),J(x,"keydown",e=>{var t,l=e.key,a=e.target,r=e.shiftKey;"Escape"===l?D(!0):"Enter"===l&&"BUTTON"!==a.tagName?D():(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(l)&&(n=!0,d.classList.add("clr-keyboard-nav")),"Tab"===l&&a.matches(".clr-picker *")&&(t=(l=G()).shift(),l=l.pop(),r&&a===t?(l.focus(),e.preventDefault()):r||a!==l||(t.focus(),e.preventDefault())))}),J(x,"click",".clr-field button",e=>{E&&$(),e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),J(i,"keydown",e=>{var t,l={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};Object.keys(l).includes(e.key)&&([l,t]=[...l[e.key]],F(+i.style.left.replace("px","")+l,+i.style.top.replace("px","")+t),e.preventDefault())}),J(p,"click",q),J(y,"input",Y),J(v,"input",X))}function G(){return Array.from(d.querySelectorAll("input, button")).filter(e=>!!e.offsetWidth)}function K(e){return x.getElementById(e)}function J(e,t,l,a){const r=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof l?e.addEventListener(t,e=>{r.call(e.target,l)&&a.call(e.target,e)}):(a=l,e.addEventListener(t,a))}function Q(e,t){t=t!==C?t:[],"loading"!==x.readyState?e(...t):x.addEventListener("DOMContentLoaded",()=>{e(...t)})}function le(e,t){g=t,l=g.value,r(t),w=j(e),M(),I(e),R(),l!==e&&g.dispatchEvent(new Event("change",{bubbles:!0}))}NodeList!==C&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);var V=(()=>{const a={init:z,set:S,wrap:H,close:D,setInstance:e,setColor:le,removeInstance:T,updatePosition:M,ready:Q};function t(e){Q(()=>{e&&("string"==typeof e?B:S)(e)})}for(const r in a)t[r]=function(){for(var e=arguments.length,t=new Array(e),l=0;l<e;l++)t[l]=arguments[l];Q(a[r],t)};return Q(()=>{L.addEventListener("resize",e=>{t.updatePosition()}),L.addEventListener("scroll",e=>{t.updatePosition()})}),t})();return V.coloris=V}});
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melloware/coloris",
3
- "version": "0.24.2",
3
+ "version": "0.25.0",
4
4
  "description": "A lightweight and elegant color picker.",
5
5
  "author": "Momo Bassit",
6
6
  "contributors": [
@@ -42,8 +42,8 @@ Or tinker with CountUp in [Stackblitz](https://stackblitz.com/edit/countup-types
42
42
  On npm as `countup.js`. You can import as a module, or include the UMD script and access CountUp as a global. See [detailed instructions](#including-countup) on including CountUp.
43
43
 
44
44
  **Params**:
45
- - `target: string | HTMLElement | HTMLInputElement` - id of html element, input, svg text element, or DOM element reference where counting occurs
46
- - `endVal: number` - the value you want to arrive at
45
+ - `target: string | HTMLElement | HTMLInputElement` - id of html element, input, svg text element, or DOM element reference where counting occurs.
46
+ - `endVal: number | null` - the value you want to arrive at. Leave null to use the number in the target element.
47
47
  - `options?: CountUpOptions` - optional configuration object for fine-grain control
48
48
 
49
49
  **Options** (defaults in parentheses): <a name="options"></a>
@@ -25,7 +25,7 @@ export declare interface CountUpPlugin {
25
25
  render(elem: HTMLElement, formatted: string): void;
26
26
  }
27
27
  export declare class CountUp {
28
- private endVal;
28
+ private endVal?;
29
29
  options?: CountUpOptions;
30
30
  version: string;
31
31
  private defaults;
@@ -44,7 +44,7 @@ export declare class CountUp {
44
44
  paused: boolean;
45
45
  frameVal: number;
46
46
  once: boolean;
47
- constructor(target: string | HTMLElement | HTMLInputElement, endVal: number, options?: CountUpOptions);
47
+ constructor(target: string | HTMLElement | HTMLInputElement, endVal?: number | null, options?: CountUpOptions);
48
48
  handleScroll(self: CountUp): void;
49
49
  /**
50
50
  * Smart easing works by breaking the animation into 2 parts, the second part being the
@@ -64,4 +64,5 @@ export declare class CountUp {
64
64
  private resetDuration;
65
65
  formatNumber: (num: number) => string;
66
66
  easeOutExpo: (t: number, b: number, c: number, d: number) => number;
67
+ parse(number: string): number;
67
68
  }
@@ -15,7 +15,7 @@ var CountUp = /** @class */ (function () {
15
15
  var _this = this;
16
16
  this.endVal = endVal;
17
17
  this.options = options;
18
- this.version = '2.8.1';
18
+ this.version = '2.9.0';
19
19
  this.defaults = {
20
20
  startVal: 0,
21
21
  decimalPlaces: 0,
@@ -120,6 +120,8 @@ var CountUp = /** @class */ (function () {
120
120
  this.options.formattingFn : this.formatNumber;
121
121
  this.easingFn = (this.options.easingFn) ?
122
122
  this.options.easingFn : this.easeOutExpo;
123
+ this.el = (typeof target === 'string') ? document.getElementById(target) : target;
124
+ endVal = endVal == null ? this.parse(this.el.innerHTML) : endVal;
123
125
  this.startVal = this.validateValue(this.options.startVal);
124
126
  this.frameVal = this.startVal;
125
127
  this.endVal = this.validateValue(endVal);
@@ -130,7 +132,6 @@ var CountUp = /** @class */ (function () {
130
132
  if (this.options.separator === '') {
131
133
  this.options.useGrouping = false;
132
134
  }
133
- this.el = (typeof target === 'string') ? document.getElementById(target) : target;
134
135
  if (this.el) {
135
136
  this.printValue(this.startVal);
136
137
  }
@@ -298,6 +299,14 @@ var CountUp = /** @class */ (function () {
298
299
  this.duration = Number(this.options.duration) * 1000;
299
300
  this.remaining = this.duration;
300
301
  };
302
+ CountUp.prototype.parse = function (number) {
303
+ // eslint-disable-next-line no-irregular-whitespace
304
+ var escapeRegExp = function (s) { return s.replace(/([.,'  ])/g, '\\$1'); };
305
+ var sep = escapeRegExp(this.options.separator);
306
+ var dec = escapeRegExp(this.options.decimal);
307
+ var num = number.replace(new RegExp(sep, 'g'), '').replace(new RegExp(dec, 'g'), '.');
308
+ return parseFloat(num);
309
+ };
301
310
  return CountUp;
302
311
  }());
303
312
  export { CountUp };
@@ -1 +1 @@
1
- var t=function(){return t=Object.assign||function(t){for(var i,n=1,s=arguments.length;n<s;n++)for(var a in i=arguments[n])Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a]);return t},t.apply(this,arguments)},i=function(){function i(i,n,s){var a=this;this.endVal=n,this.options=s,this.version="2.8.1",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,useIndianSeparators:!1,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:"",enableScrollSpy:!1,scrollSpyDelay:200,scrollSpyOnce:!1},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.once=!1,this.count=function(t){a.startTime||(a.startTime=t);var i=t-a.startTime;a.remaining=a.duration-i,a.useEasing?a.countDown?a.frameVal=a.startVal-a.easingFn(i,0,a.startVal-a.endVal,a.duration):a.frameVal=a.easingFn(i,a.startVal,a.endVal-a.startVal,a.duration):a.frameVal=a.startVal+(a.endVal-a.startVal)*(i/a.duration);var n=a.countDown?a.frameVal<a.endVal:a.frameVal>a.endVal;a.frameVal=n?a.endVal:a.frameVal,a.frameVal=Number(a.frameVal.toFixed(a.options.decimalPlaces)),a.printValue(a.frameVal),i<a.duration?a.rAF=requestAnimationFrame(a.count):null!==a.finalEndVal?a.update(a.finalEndVal):a.options.onCompleteCallback&&a.options.onCompleteCallback()},this.formatNumber=function(t){var i,n,s,e,o=t<0?"-":"";i=Math.abs(t).toFixed(a.options.decimalPlaces);var r=(i+="").split(".");if(n=r[0],s=r.length>1?a.options.decimal+r[1]:"",a.options.useGrouping){e="";for(var l=3,h=0,u=0,p=n.length;u<p;++u)a.options.useIndianSeparators&&4===u&&(l=2,h=1),0!==u&&h%l==0&&(e=a.options.separator+e),h++,e=n[p-u-1]+e;n=e}return a.options.numerals&&a.options.numerals.length&&(n=n.replace(/[0-9]/g,(function(t){return a.options.numerals[+t]})),s=s.replace(/[0-9]/g,(function(t){return a.options.numerals[+t]}))),o+a.options.prefix+n+s+a.options.suffix},this.easeOutExpo=function(t,i,n,s){return n*(1-Math.pow(2,-10*t/s))*1024/1023+i},this.options=t(t({},this.defaults),s),this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.endVal=this.validateValue(n),this.options.decimalPlaces=Math.max(this.options.decimalPlaces),this.resetDuration(),this.options.separator=String(this.options.separator),this.useEasing=this.options.useEasing,""===this.options.separator&&(this.options.useGrouping=!1),this.el="string"==typeof i?document.getElementById(i):i,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined","undefined"!=typeof window&&this.options.enableScrollSpy&&(this.error?console.error(this.error,i):(window.onScrollFns=window.onScrollFns||[],window.onScrollFns.push((function(){return a.handleScroll(a)})),window.onscroll=function(){window.onScrollFns.forEach((function(t){return t()}))},this.handleScroll(this)))}return i.prototype.handleScroll=function(t){if(t&&window&&!t.once){var i=window.innerHeight+window.scrollY,n=t.el.getBoundingClientRect(),s=n.top+window.pageYOffset,a=n.top+n.height+window.pageYOffset;a<i&&a>window.scrollY&&t.paused?(t.paused=!1,setTimeout((function(){return t.start()}),t.options.scrollSpyDelay),t.options.scrollSpyOnce&&(t.once=!0)):(window.scrollY>a||s>i)&&!t.paused&&t.reset()}},i.prototype.determineDirectionAndSmartEasing=function(){var t=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>t;var i=t-this.startVal;if(Math.abs(i)>this.options.smartEasingThreshold&&this.options.useEasing){this.finalEndVal=t;var n=this.countDown?1:-1;this.endVal=t+n*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=t,this.finalEndVal=null;null!==this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},i.prototype.start=function(t){this.error||(this.options.onStartCallback&&this.options.onStartCallback(),t&&(this.options.onCompleteCallback=t),this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},i.prototype.pauseResume=function(){this.paused?(this.startTime=null,this.duration=this.remaining,this.startVal=this.frameVal,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count)):cancelAnimationFrame(this.rAF),this.paused=!this.paused},i.prototype.reset=function(){cancelAnimationFrame(this.rAF),this.paused=!0,this.resetDuration(),this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.printValue(this.startVal)},i.prototype.update=function(t){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(t),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,null==this.finalEndVal&&this.resetDuration(),this.finalEndVal=null,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},i.prototype.printValue=function(t){var i;if(this.el){var n=this.formattingFn(t);if(null===(i=this.options.plugin)||void 0===i?void 0:i.render)this.options.plugin.render(this.el,n);else if("INPUT"===this.el.tagName)this.el.value=n;else"text"===this.el.tagName||"tspan"===this.el.tagName?this.el.textContent=n:this.el.innerHTML=n}},i.prototype.ensureNumber=function(t){return"number"==typeof t&&!isNaN(t)},i.prototype.validateValue=function(t){var i=Number(t);return this.ensureNumber(i)?i:(this.error="[CountUp] invalid start or end value: ".concat(t),null)},i.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},i}();export{i as CountUp};
1
+ var t=function(){return t=Object.assign||function(t){for(var i,n=1,s=arguments.length;n<s;n++)for(var a in i=arguments[n])Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a]);return t},t.apply(this,arguments)},i=function(){function i(i,n,s){var a=this;this.endVal=n,this.options=s,this.version="2.9.0",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,useIndianSeparators:!1,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:"",enableScrollSpy:!1,scrollSpyDelay:200,scrollSpyOnce:!1},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.once=!1,this.count=function(t){a.startTime||(a.startTime=t);var i=t-a.startTime;a.remaining=a.duration-i,a.useEasing?a.countDown?a.frameVal=a.startVal-a.easingFn(i,0,a.startVal-a.endVal,a.duration):a.frameVal=a.easingFn(i,a.startVal,a.endVal-a.startVal,a.duration):a.frameVal=a.startVal+(a.endVal-a.startVal)*(i/a.duration);var n=a.countDown?a.frameVal<a.endVal:a.frameVal>a.endVal;a.frameVal=n?a.endVal:a.frameVal,a.frameVal=Number(a.frameVal.toFixed(a.options.decimalPlaces)),a.printValue(a.frameVal),i<a.duration?a.rAF=requestAnimationFrame(a.count):null!==a.finalEndVal?a.update(a.finalEndVal):a.options.onCompleteCallback&&a.options.onCompleteCallback()},this.formatNumber=function(t){var i,n,s,e,o=t<0?"-":"";i=Math.abs(t).toFixed(a.options.decimalPlaces);var r=(i+="").split(".");if(n=r[0],s=r.length>1?a.options.decimal+r[1]:"",a.options.useGrouping){e="";for(var l=3,h=0,u=0,p=n.length;u<p;++u)a.options.useIndianSeparators&&4===u&&(l=2,h=1),0!==u&&h%l==0&&(e=a.options.separator+e),h++,e=n[p-u-1]+e;n=e}return a.options.numerals&&a.options.numerals.length&&(n=n.replace(/[0-9]/g,(function(t){return a.options.numerals[+t]})),s=s.replace(/[0-9]/g,(function(t){return a.options.numerals[+t]}))),o+a.options.prefix+n+s+a.options.suffix},this.easeOutExpo=function(t,i,n,s){return n*(1-Math.pow(2,-10*t/s))*1024/1023+i},this.options=t(t({},this.defaults),s),this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.el="string"==typeof i?document.getElementById(i):i,n=null==n?this.parse(this.el.innerHTML):n,this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.endVal=this.validateValue(n),this.options.decimalPlaces=Math.max(this.options.decimalPlaces),this.resetDuration(),this.options.separator=String(this.options.separator),this.useEasing=this.options.useEasing,""===this.options.separator&&(this.options.useGrouping=!1),this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined","undefined"!=typeof window&&this.options.enableScrollSpy&&(this.error?console.error(this.error,i):(window.onScrollFns=window.onScrollFns||[],window.onScrollFns.push((function(){return a.handleScroll(a)})),window.onscroll=function(){window.onScrollFns.forEach((function(t){return t()}))},this.handleScroll(this)))}return i.prototype.handleScroll=function(t){if(t&&window&&!t.once){var i=window.innerHeight+window.scrollY,n=t.el.getBoundingClientRect(),s=n.top+window.pageYOffset,a=n.top+n.height+window.pageYOffset;a<i&&a>window.scrollY&&t.paused?(t.paused=!1,setTimeout((function(){return t.start()}),t.options.scrollSpyDelay),t.options.scrollSpyOnce&&(t.once=!0)):(window.scrollY>a||s>i)&&!t.paused&&t.reset()}},i.prototype.determineDirectionAndSmartEasing=function(){var t=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>t;var i=t-this.startVal;if(Math.abs(i)>this.options.smartEasingThreshold&&this.options.useEasing){this.finalEndVal=t;var n=this.countDown?1:-1;this.endVal=t+n*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=t,this.finalEndVal=null;null!==this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},i.prototype.start=function(t){this.error||(this.options.onStartCallback&&this.options.onStartCallback(),t&&(this.options.onCompleteCallback=t),this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},i.prototype.pauseResume=function(){this.paused?(this.startTime=null,this.duration=this.remaining,this.startVal=this.frameVal,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count)):cancelAnimationFrame(this.rAF),this.paused=!this.paused},i.prototype.reset=function(){cancelAnimationFrame(this.rAF),this.paused=!0,this.resetDuration(),this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.printValue(this.startVal)},i.prototype.update=function(t){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(t),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,null==this.finalEndVal&&this.resetDuration(),this.finalEndVal=null,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},i.prototype.printValue=function(t){var i;if(this.el){var n=this.formattingFn(t);if(null===(i=this.options.plugin)||void 0===i?void 0:i.render)this.options.plugin.render(this.el,n);else if("INPUT"===this.el.tagName)this.el.value=n;else"text"===this.el.tagName||"tspan"===this.el.tagName?this.el.textContent=n:this.el.innerHTML=n}},i.prototype.ensureNumber=function(t){return"number"==typeof t&&!isNaN(t)},i.prototype.validateValue=function(t){var i=Number(t);return this.ensureNumber(i)?i:(this.error="[CountUp] invalid start or end value: ".concat(t),null)},i.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},i.prototype.parse=function(t){var i=function(t){return t.replace(/([.,'  ])/g,"\\$1")},n=i(this.options.separator),s=i(this.options.decimal),a=t.replace(new RegExp(n,"g"),"").replace(new RegExp(s,"g"),".");return parseFloat(a)},i}();export{i as CountUp};
@@ -1 +1 @@
1
- !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).countUp={})}(this,(function(t){"use strict";var i=function(){return i=Object.assign||function(t){for(var i,n=1,s=arguments.length;n<s;n++)for(var a in i=arguments[n])Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a]);return t},i.apply(this,arguments)},n=function(){function t(t,n,s){var a=this;this.endVal=n,this.options=s,this.version="2.8.1",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,useIndianSeparators:!1,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:"",enableScrollSpy:!1,scrollSpyDelay:200,scrollSpyOnce:!1},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.once=!1,this.count=function(t){a.startTime||(a.startTime=t);var i=t-a.startTime;a.remaining=a.duration-i,a.useEasing?a.countDown?a.frameVal=a.startVal-a.easingFn(i,0,a.startVal-a.endVal,a.duration):a.frameVal=a.easingFn(i,a.startVal,a.endVal-a.startVal,a.duration):a.frameVal=a.startVal+(a.endVal-a.startVal)*(i/a.duration);var n=a.countDown?a.frameVal<a.endVal:a.frameVal>a.endVal;a.frameVal=n?a.endVal:a.frameVal,a.frameVal=Number(a.frameVal.toFixed(a.options.decimalPlaces)),a.printValue(a.frameVal),i<a.duration?a.rAF=requestAnimationFrame(a.count):null!==a.finalEndVal?a.update(a.finalEndVal):a.options.onCompleteCallback&&a.options.onCompleteCallback()},this.formatNumber=function(t){var i,n,s,e,o=t<0?"-":"";i=Math.abs(t).toFixed(a.options.decimalPlaces);var r=(i+="").split(".");if(n=r[0],s=r.length>1?a.options.decimal+r[1]:"",a.options.useGrouping){e="";for(var l=3,h=0,u=0,p=n.length;u<p;++u)a.options.useIndianSeparators&&4===u&&(l=2,h=1),0!==u&&h%l==0&&(e=a.options.separator+e),h++,e=n[p-u-1]+e;n=e}return a.options.numerals&&a.options.numerals.length&&(n=n.replace(/[0-9]/g,(function(t){return a.options.numerals[+t]})),s=s.replace(/[0-9]/g,(function(t){return a.options.numerals[+t]}))),o+a.options.prefix+n+s+a.options.suffix},this.easeOutExpo=function(t,i,n,s){return n*(1-Math.pow(2,-10*t/s))*1024/1023+i},this.options=i(i({},this.defaults),s),this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.endVal=this.validateValue(n),this.options.decimalPlaces=Math.max(this.options.decimalPlaces),this.resetDuration(),this.options.separator=String(this.options.separator),this.useEasing=this.options.useEasing,""===this.options.separator&&(this.options.useGrouping=!1),this.el="string"==typeof t?document.getElementById(t):t,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined","undefined"!=typeof window&&this.options.enableScrollSpy&&(this.error?console.error(this.error,t):(window.onScrollFns=window.onScrollFns||[],window.onScrollFns.push((function(){return a.handleScroll(a)})),window.onscroll=function(){window.onScrollFns.forEach((function(t){return t()}))},this.handleScroll(this)))}return t.prototype.handleScroll=function(t){if(t&&window&&!t.once){var i=window.innerHeight+window.scrollY,n=t.el.getBoundingClientRect(),s=n.top+window.pageYOffset,a=n.top+n.height+window.pageYOffset;a<i&&a>window.scrollY&&t.paused?(t.paused=!1,setTimeout((function(){return t.start()}),t.options.scrollSpyDelay),t.options.scrollSpyOnce&&(t.once=!0)):(window.scrollY>a||s>i)&&!t.paused&&t.reset()}},t.prototype.determineDirectionAndSmartEasing=function(){var t=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>t;var i=t-this.startVal;if(Math.abs(i)>this.options.smartEasingThreshold&&this.options.useEasing){this.finalEndVal=t;var n=this.countDown?1:-1;this.endVal=t+n*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=t,this.finalEndVal=null;null!==this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},t.prototype.start=function(t){this.error||(this.options.onStartCallback&&this.options.onStartCallback(),t&&(this.options.onCompleteCallback=t),this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},t.prototype.pauseResume=function(){this.paused?(this.startTime=null,this.duration=this.remaining,this.startVal=this.frameVal,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count)):cancelAnimationFrame(this.rAF),this.paused=!this.paused},t.prototype.reset=function(){cancelAnimationFrame(this.rAF),this.paused=!0,this.resetDuration(),this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.printValue(this.startVal)},t.prototype.update=function(t){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(t),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,null==this.finalEndVal&&this.resetDuration(),this.finalEndVal=null,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},t.prototype.printValue=function(t){var i;if(this.el){var n=this.formattingFn(t);if(null===(i=this.options.plugin)||void 0===i?void 0:i.render)this.options.plugin.render(this.el,n);else if("INPUT"===this.el.tagName)this.el.value=n;else"text"===this.el.tagName||"tspan"===this.el.tagName?this.el.textContent=n:this.el.innerHTML=n}},t.prototype.ensureNumber=function(t){return"number"==typeof t&&!isNaN(t)},t.prototype.validateValue=function(t){var i=Number(t);return this.ensureNumber(i)?i:(this.error="[CountUp] invalid start or end value: ".concat(t),null)},t.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},t}();t.CountUp=n}));
1
+ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).countUp={})}(this,(function(t){"use strict";var i=function(){return i=Object.assign||function(t){for(var i,n=1,s=arguments.length;n<s;n++)for(var e in i=arguments[n])Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e]);return t},i.apply(this,arguments)},n=function(){function t(t,n,s){var e=this;this.endVal=n,this.options=s,this.version="2.9.0",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,useIndianSeparators:!1,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:"",enableScrollSpy:!1,scrollSpyDelay:200,scrollSpyOnce:!1},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.once=!1,this.count=function(t){e.startTime||(e.startTime=t);var i=t-e.startTime;e.remaining=e.duration-i,e.useEasing?e.countDown?e.frameVal=e.startVal-e.easingFn(i,0,e.startVal-e.endVal,e.duration):e.frameVal=e.easingFn(i,e.startVal,e.endVal-e.startVal,e.duration):e.frameVal=e.startVal+(e.endVal-e.startVal)*(i/e.duration);var n=e.countDown?e.frameVal<e.endVal:e.frameVal>e.endVal;e.frameVal=n?e.endVal:e.frameVal,e.frameVal=Number(e.frameVal.toFixed(e.options.decimalPlaces)),e.printValue(e.frameVal),i<e.duration?e.rAF=requestAnimationFrame(e.count):null!==e.finalEndVal?e.update(e.finalEndVal):e.options.onCompleteCallback&&e.options.onCompleteCallback()},this.formatNumber=function(t){var i,n,s,a,o=t<0?"-":"";i=Math.abs(t).toFixed(e.options.decimalPlaces);var r=(i+="").split(".");if(n=r[0],s=r.length>1?e.options.decimal+r[1]:"",e.options.useGrouping){a="";for(var l=3,u=0,h=0,p=n.length;h<p;++h)e.options.useIndianSeparators&&4===h&&(l=2,u=1),0!==h&&u%l==0&&(a=e.options.separator+a),u++,a=n[p-h-1]+a;n=a}return e.options.numerals&&e.options.numerals.length&&(n=n.replace(/[0-9]/g,(function(t){return e.options.numerals[+t]})),s=s.replace(/[0-9]/g,(function(t){return e.options.numerals[+t]}))),o+e.options.prefix+n+s+e.options.suffix},this.easeOutExpo=function(t,i,n,s){return n*(1-Math.pow(2,-10*t/s))*1024/1023+i},this.options=i(i({},this.defaults),s),this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.el="string"==typeof t?document.getElementById(t):t,n=null==n?this.parse(this.el.innerHTML):n,this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.endVal=this.validateValue(n),this.options.decimalPlaces=Math.max(this.options.decimalPlaces),this.resetDuration(),this.options.separator=String(this.options.separator),this.useEasing=this.options.useEasing,""===this.options.separator&&(this.options.useGrouping=!1),this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined","undefined"!=typeof window&&this.options.enableScrollSpy&&(this.error?console.error(this.error,t):(window.onScrollFns=window.onScrollFns||[],window.onScrollFns.push((function(){return e.handleScroll(e)})),window.onscroll=function(){window.onScrollFns.forEach((function(t){return t()}))},this.handleScroll(this)))}return t.prototype.handleScroll=function(t){if(t&&window&&!t.once){var i=window.innerHeight+window.scrollY,n=t.el.getBoundingClientRect(),s=n.top+window.pageYOffset,e=n.top+n.height+window.pageYOffset;e<i&&e>window.scrollY&&t.paused?(t.paused=!1,setTimeout((function(){return t.start()}),t.options.scrollSpyDelay),t.options.scrollSpyOnce&&(t.once=!0)):(window.scrollY>e||s>i)&&!t.paused&&t.reset()}},t.prototype.determineDirectionAndSmartEasing=function(){var t=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>t;var i=t-this.startVal;if(Math.abs(i)>this.options.smartEasingThreshold&&this.options.useEasing){this.finalEndVal=t;var n=this.countDown?1:-1;this.endVal=t+n*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=t,this.finalEndVal=null;null!==this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},t.prototype.start=function(t){this.error||(this.options.onStartCallback&&this.options.onStartCallback(),t&&(this.options.onCompleteCallback=t),this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},t.prototype.pauseResume=function(){this.paused?(this.startTime=null,this.duration=this.remaining,this.startVal=this.frameVal,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count)):cancelAnimationFrame(this.rAF),this.paused=!this.paused},t.prototype.reset=function(){cancelAnimationFrame(this.rAF),this.paused=!0,this.resetDuration(),this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.printValue(this.startVal)},t.prototype.update=function(t){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(t),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,null==this.finalEndVal&&this.resetDuration(),this.finalEndVal=null,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},t.prototype.printValue=function(t){var i;if(this.el){var n=this.formattingFn(t);if(null===(i=this.options.plugin)||void 0===i?void 0:i.render)this.options.plugin.render(this.el,n);else if("INPUT"===this.el.tagName)this.el.value=n;else"text"===this.el.tagName||"tspan"===this.el.tagName?this.el.textContent=n:this.el.innerHTML=n}},t.prototype.ensureNumber=function(t){return"number"==typeof t&&!isNaN(t)},t.prototype.validateValue=function(t){var i=Number(t);return this.ensureNumber(i)?i:(this.error="[CountUp] invalid start or end value: ".concat(t),null)},t.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},t.prototype.parse=function(t){var i=function(t){return t.replace(/([.,'  ])/g,"\\$1")},n=i(this.options.separator),s=i(this.options.decimal),e=t.replace(new RegExp(n,"g"),"").replace(new RegExp(s,"g"),".");return parseFloat(e)},t}();t.CountUp=n}));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "countup.js",
3
3
  "description": "Animates a numerical value by counting to it",
4
- "version": "2.8.2",
4
+ "version": "2.9.0",
5
5
  "license": "MIT",
6
6
  "author": "Jamie Perkins",
7
7
  "main": "./dist/countUp.umd.js",
@@ -57,48 +57,98 @@ describe('CountUp', () => {
57
57
  it('should return a value for version', () => {
58
58
  expect(countUp.version).toBeTruthy();
59
59
  });
60
+
61
+ it('should support getting endVal from the target element', () => {
62
+ document.body.innerHTML =
63
+ '<div>' +
64
+ ' <h1 id="target">1,500</h1>' +
65
+ '</div>';
66
+
67
+ countUp = new CountUp('target');
68
+ expect(countUp.endVal).toBe(1500);
69
+ });
70
+
71
+ it('should set an error when endVal is omitted and not in target element', () => {
72
+ document.body.innerHTML =
73
+ '<div>' +
74
+ ' <h1 id="target"></h1>' +
75
+ '</div>';
76
+ countUp = new CountUp('target');
77
+ expect(countUp.error.length).toBeGreaterThan(0);
78
+ });
79
+
80
+ it('should not call parse when an endVal is passed to the constructor', () => {
81
+ const parseSpy = jest.spyOn(CountUp.prototype, 'parse');
82
+
83
+ countUp = new CountUp('target', 0, { startVal: 100 });
84
+ expect(parseSpy).not.toHaveBeenCalled();
85
+ parseSpy.mockRestore();
86
+ });
60
87
  });
61
88
 
62
89
  describe('class methods', () => {
63
- it('should count when start method is called', () => {
64
- countUp.start();
90
+ describe('# start', () => {
91
+ it('should count when start method is called', () => {
92
+ countUp.start();
65
93
 
66
- expect(getTargetHtml()).toEqual('100');
67
- });
94
+ expect(getTargetHtml()).toEqual('100');
95
+ });
68
96
 
69
- it('should use a callback provided to start', () => {
70
- const cb = jest.fn();
71
- countUp.start(cb);
97
+ it('should use a callback provided to start', () => {
98
+ const cb = jest.fn();
99
+ countUp.start(cb);
72
100
 
73
- expect(getTargetHtml()).toEqual('100');
74
- expect(cb).toHaveBeenCalled();
101
+ expect(getTargetHtml()).toEqual('100');
102
+ expect(cb).toHaveBeenCalled();
103
+ });
75
104
  });
76
105
 
77
- it('should pause when pauseResume is called', () => {
78
- countUp.start();
79
- // resetRAF();
80
- countUp.pauseResume();
106
+ describe('# pauseResume', () => {
107
+ it('should pause when pauseResume is called', () => {
108
+ countUp.start();
109
+ countUp.pauseResume();
81
110
 
82
- expect(countUp.paused).toBeTruthy();
111
+ expect(countUp.paused).toBeTruthy();
112
+ });
83
113
  });
84
114
 
85
- it('should reset when reset is called', () => {
86
- countUp.start();
87
- countUp.reset();
115
+ describe('# reset', () => {
116
+ it('should reset when reset is called', () => {
117
+ countUp.start();
118
+ countUp.reset();
88
119
 
89
- expect(getTargetHtml()).toEqual('0');
90
- expect(countUp.paused).toBeTruthy();
120
+ expect(getTargetHtml()).toEqual('0');
121
+ expect(countUp.paused).toBeTruthy();
122
+ });
91
123
  });
92
124
 
93
- it('should update when update is called', () => {
94
- countUp.start();
95
- expect(getTargetHtml()).toEqual('100');
125
+ describe('# update', () => {
126
+ it('should update when update is called', () => {
127
+ countUp.start();
128
+ expect(getTargetHtml()).toEqual('100');
96
129
 
97
- resetRAF();
98
- countUp.update(200);
99
- expect(getTargetHtml()).toEqual('200');
130
+ resetRAF();
131
+ countUp.update(200);
132
+ expect(getTargetHtml()).toEqual('200');
133
+ });
100
134
  });
101
135
 
136
+ describe('# parse', () => {
137
+ it('should properly parse numbers', () => {
138
+ countUp = new CountUp('target', 0);
139
+ const result0 = countUp.parse('14,921.00123');
140
+
141
+ countUp = new CountUp('target', 0, { separator: '.', decimal: ',' });
142
+ const result1 = countUp.parse('1.500,0');
143
+
144
+ countUp = new CountUp('target', 0, { separator: ' ' });
145
+ const result2 = countUp.parse('2 800');
146
+
147
+ expect(result0).toEqual(14921.00123);
148
+ expect(result1).toEqual(1500);
149
+ expect(result2).toEqual(2800);
150
+ });
151
+ });
102
152
  });
103
153
 
104
154
  describe('various use-cases', () => {
@@ -30,7 +30,7 @@ export declare interface CountUpPlugin {
30
30
  // playground: stackblitz.com/edit/countup-typescript
31
31
  export class CountUp {
32
32
 
33
- version = '2.8.1';
33
+ version = '2.9.0';
34
34
  private defaults: CountUpOptions = {
35
35
  startVal: 0,
36
36
  decimalPlaces: 0,
@@ -66,7 +66,7 @@ export class CountUp {
66
66
 
67
67
  constructor(
68
68
  target: string | HTMLElement | HTMLInputElement,
69
- private endVal: number,
69
+ private endVal?: number | null,
70
70
  public options?: CountUpOptions
71
71
  ) {
72
72
  this.options = {
@@ -78,6 +78,9 @@ export class CountUp {
78
78
  this.easingFn = (this.options.easingFn) ?
79
79
  this.options.easingFn : this.easeOutExpo;
80
80
 
81
+ this.el = (typeof target === 'string') ? document.getElementById(target) : target;
82
+ endVal = endVal == null ? this.parse(this.el.innerHTML) : endVal;
83
+
81
84
  this.startVal = this.validateValue(this.options.startVal);
82
85
  this.frameVal = this.startVal;
83
86
  this.endVal = this.validateValue(endVal);
@@ -88,7 +91,6 @@ export class CountUp {
88
91
  if (this.options.separator === '') {
89
92
  this.options.useGrouping = false;
90
93
  }
91
- this.el = (typeof target === 'string') ? document.getElementById(target) : target;
92
94
  if (this.el) {
93
95
  this.printValue(this.startVal);
94
96
  } else {
@@ -335,4 +337,12 @@ export class CountUp {
335
337
  easeOutExpo = (t: number, b: number, c: number, d: number): number =>
336
338
  c * (-Math.pow(2, -10 * t / d) + 1) * 1024 / 1023 + b;
337
339
 
340
+ parse(number: string): number {
341
+ // eslint-disable-next-line no-irregular-whitespace
342
+ const escapeRegExp = (s: string) => s.replace(/([.,'  ])/g, '\\$1');
343
+ const sep = escapeRegExp(this.options.separator);
344
+ const dec = escapeRegExp(this.options.decimal);
345
+ const num = number.replace(new RegExp(sep, 'g'), '').replace(new RegExp(dec, 'g'), '.');
346
+ return parseFloat(num)
347
+ }
338
348
  }