@nrk/core-progress
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -77,15 +77,14 @@ 'use strict'; | ||
var canUpdate = noChanges || dispatchEvent(progress, 'progress.change', { value: newValue, max: max, percentage: percentage, indeterminate: indeterminate }); | ||
var setValue = canUpdate ? newValue : oldValue; | ||
progress.setAttribute(UUID, canUpdate ? newValue : oldValue); | ||
progress.setAttribute(UUID, setValue); | ||
progress.setAttribute('role', 'img'); | ||
if (canUpdate) { | ||
if (indeterminate) { | ||
progress.removeAttribute('value'); | ||
progress.setAttribute('aria-label', newValue); | ||
} else { | ||
progress.setAttribute('value', newValue); | ||
progress.setAttribute('max', max); | ||
progress.setAttribute('aria-label', (percentage + "%")); | ||
} | ||
if (indeterminate) { | ||
progress.removeAttribute('value'); | ||
progress.setAttribute('aria-label', setValue); | ||
} else { | ||
progress.setAttribute('value', setValue); | ||
progress.setAttribute('max', max); | ||
progress.setAttribute('aria-label', (percentage + "%")); | ||
} | ||
@@ -92,0 +91,0 @@ |
@@ -18,15 +18,14 @@ import { name, version } from './package.json' | ||
const canUpdate = noChanges || dispatchEvent(progress, 'progress.change', { value: newValue, max, percentage, indeterminate }) | ||
const setValue = canUpdate ? newValue : oldValue | ||
progress.setAttribute(UUID, canUpdate ? newValue : oldValue) | ||
progress.setAttribute(UUID, setValue) | ||
progress.setAttribute('role', 'img') | ||
if (canUpdate) { | ||
if (indeterminate) { | ||
progress.removeAttribute('value') | ||
progress.setAttribute('aria-label', newValue) | ||
} else { | ||
progress.setAttribute('value', newValue) | ||
progress.setAttribute('max', max) | ||
progress.setAttribute('aria-label', `${percentage}%`) | ||
} | ||
if (indeterminate) { | ||
progress.removeAttribute('value') | ||
progress.setAttribute('aria-label', setValue) | ||
} else { | ||
progress.setAttribute('value', setValue) | ||
progress.setAttribute('max', max) | ||
progress.setAttribute('aria-label', `${percentage}%`) | ||
} | ||
@@ -33,0 +32,0 @@ |
/*! @nrk/core-progress v1.0.0 - Copyright (c) 2017-2018 NRK */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):e.CoreProgress=t(e.React,e.PropTypes)}(this,function(a,e){"use strict";a=a&&a.hasOwnProperty("default")?a.default:a,e=e&&e.hasOwnProperty("default")?e.default:e;var t="undefined"!=typeof window;t&&/(android)/i.test(navigator.userAgent),t&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}}();var p="prevent_recursive_dispatch_maximum_callstack";var c="data-@nrk/core-progress-1.0.0".replace(/\W+/g,"-");function n(e,t){var s="object"==typeof t?t:{value:t};return function(e,t){if(void 0===t&&(t=document),e){if(e.nodeType)return[e];if("string"==typeof e)return[].slice.call(t.querySelectorAll(e));if(e.length)return[].slice.call(e)}return[]}(e).map(function(e){var t=void 0!==window.HTMLProgressElement,n=e.getAttribute(c)||e.getAttribute("value")||"0",r=String(s.value||n),o=String(s.max||e.getAttribute("max")||1),i=Number(r)!==parseFloat(r),a=Math.round(r/o*100)||0,u=r===n&&o===e.getAttribute("max")&&i!==e.hasAttribute("value")||function(e,t,n){void 0===n&&(n={});var r,o=""+p+t;if(e[o])return!0;e[o]=!0,"function"==typeof window.CustomEvent?r=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(r=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n);var i=e.dispatchEvent(r);return e[o]=null,i}(e,"progress.change",{value:r,max:o,percentage:a,indeterminate:i});return e.setAttribute(c,u?r:n),e.setAttribute("role","img"),u&&(i?(e.removeAttribute("value"),e.setAttribute("aria-label",r)):(e.setAttribute("value",r),e.setAttribute("max",o),e.setAttribute("aria-label",a+"%"))),t||document.getElementById(c)||document.head.insertAdjacentHTML("beforeend",'<style id="'+c+'">['+c+"]:after {content: attr(aria-label)}</style>"),e})}var r=function(t){function i(e){t.call(this,e),this.onChange=this.onChange.bind(this)}t&&(i.__proto__=t),(i.prototype=Object.create(t&&t.prototype)).constructor=i;var e={defaultProps:{configurable:!0}};return e.defaultProps.get=function(){return{value:0,max:1,onChange:null}},i.prototype.componentDidMount=function(){n(this.el,this.props),this.el.addEventListener("progress.change",this.onChange)},i.prototype.componentDidUpdate=function(){n(this.el,this.props)},i.prototype.componentWillUnmount=function(){this.el.removeEventListener("progress.change",this.onChange)},i.prototype.onChange=function(e){this.props.onChange&&this.props.onChange(e)},i.prototype.render=function(){var n,r,e,t=this,o=(n=this.props,r=i.defaultProps,void 0===(e={ref:function(e){return t.el=e}})&&(e={}),Object.keys(n).reduce(function(e,t){return r.hasOwnProperty(t)||(e[t]=n[t]),e},e));return a.createElement("progress",o)},Object.defineProperties(i,e),i}(a.Component);return r.propTypes={onChange:e.func,value:e.oneOfType([e.number,e.string]),max:e.number},r}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):e.CoreProgress=t(e.React,e.PropTypes)}(this,function(a,e){"use strict";a=a&&a.hasOwnProperty("default")?a.default:a,e=e&&e.hasOwnProperty("default")?e.default:e;var t="undefined"!=typeof window;t&&/(android)/i.test(navigator.userAgent),t&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}}();var p="prevent_recursive_dispatch_maximum_callstack";var c="data-@nrk/core-progress-1.0.0".replace(/\W+/g,"-");function n(e,t){var s="object"==typeof t?t:{value:t};return function(e,t){if(void 0===t&&(t=document),e){if(e.nodeType)return[e];if("string"==typeof e)return[].slice.call(t.querySelectorAll(e));if(e.length)return[].slice.call(e)}return[]}(e).map(function(e){var t=void 0!==window.HTMLProgressElement,n=e.getAttribute(c)||e.getAttribute("value")||"0",r=String(s.value||n),o=String(s.max||e.getAttribute("max")||1),i=Number(r)!==parseFloat(r),a=Math.round(r/o*100)||0,u=r===n&&o===e.getAttribute("max")&&i!==e.hasAttribute("value")||function(e,t,n){void 0===n&&(n={});var r,o=""+p+t;if(e[o])return!0;e[o]=!0,"function"==typeof window.CustomEvent?r=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(r=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n);var i=e.dispatchEvent(r);return e[o]=null,i}(e,"progress.change",{value:r,max:o,percentage:a,indeterminate:i})?r:n;return e.setAttribute(c,u),e.setAttribute("role","img"),i?(e.removeAttribute("value"),e.setAttribute("aria-label",u)):(e.setAttribute("value",u),e.setAttribute("max",o),e.setAttribute("aria-label",a+"%")),t||document.getElementById(c)||document.head.insertAdjacentHTML("beforeend",'<style id="'+c+'">['+c+"]:after {content: attr(aria-label)}</style>"),e})}var r=function(t){function i(e){t.call(this,e),this.onChange=this.onChange.bind(this)}t&&(i.__proto__=t),(i.prototype=Object.create(t&&t.prototype)).constructor=i;var e={defaultProps:{configurable:!0}};return e.defaultProps.get=function(){return{value:0,max:1,onChange:null}},i.prototype.componentDidMount=function(){n(this.el,this.props),this.el.addEventListener("progress.change",this.onChange)},i.prototype.componentDidUpdate=function(){n(this.el,this.props)},i.prototype.componentWillUnmount=function(){this.el.removeEventListener("progress.change",this.onChange)},i.prototype.onChange=function(e){this.props.onChange&&this.props.onChange(e)},i.prototype.render=function(){var n,r,e,t=this,o=(n=this.props,r=i.defaultProps,void 0===(e={ref:function(e){return t.el=e}})&&(e={}),Object.keys(n).reduce(function(e,t){return r.hasOwnProperty(t)||(e[t]=n[t]),e},e));return a.createElement("progress",o)},Object.defineProperties(i,e),i}(a.Component);return r.propTypes={onChange:e.func,value:e.oneOfType([e.number,e.string]),max:e.number},r}); | ||
//# sourceMappingURL=core-progress.jsx.js.map |
/*! @nrk/core-progress v1.0.0 - Copyright (c) 2017-2018 NRK */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.coreProgress=t()}(this,function(){"use strict";var e="undefined"!=typeof window,s=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}}(),"prevent_recursive_dispatch_maximum_callstack");var d="data-@nrk/core-progress-1.0.0".replace(/\W+/g,"-");return function(e,t){var l="object"==typeof t?t:{value:t};return function(e,t){if(void 0===t&&(t=document),e){if(e.nodeType)return[e];if("string"==typeof e)return[].slice.call(t.querySelectorAll(e));if(e.length)return[].slice.call(e)}return[]}(e).map(function(e){var t=void 0!==window.HTMLProgressElement,r=e.getAttribute(d)||e.getAttribute("value")||"0",n=String(l.value||r),i=String(l.max||e.getAttribute("max")||1),a=Number(n)!==parseFloat(n),o=Math.round(n/i*100)||0,u=n===r&&i===e.getAttribute("max")&&a!==e.hasAttribute("value")||function(e,t,r){void 0===r&&(r={});var n,i=""+s+t;if(e[i])return!0;e[i]=!0,"function"==typeof window.CustomEvent?n=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r}):(n=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,r);var a=e.dispatchEvent(n);return e[i]=null,a}(e,"progress.change",{value:n,max:i,percentage:o,indeterminate:a});return e.setAttribute(d,u?n:r),e.setAttribute("role","img"),u&&(a?(e.removeAttribute("value"),e.setAttribute("aria-label",n)):(e.setAttribute("value",n),e.setAttribute("max",i),e.setAttribute("aria-label",o+"%"))),t||document.getElementById(d)||document.head.insertAdjacentHTML("beforeend",'<style id="'+d+'">['+d+"]:after {content: attr(aria-label)}</style>"),e})}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.coreProgress=t()}(this,function(){"use strict";var e="undefined"!=typeof window,s=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}}(),"prevent_recursive_dispatch_maximum_callstack");var d="data-@nrk/core-progress-1.0.0".replace(/\W+/g,"-");return function(e,t){var l="object"==typeof t?t:{value:t};return function(e,t){if(void 0===t&&(t=document),e){if(e.nodeType)return[e];if("string"==typeof e)return[].slice.call(t.querySelectorAll(e));if(e.length)return[].slice.call(e)}return[]}(e).map(function(e){var t=void 0!==window.HTMLProgressElement,r=e.getAttribute(d)||e.getAttribute("value")||"0",n=String(l.value||r),i=String(l.max||e.getAttribute("max")||1),a=Number(n)!==parseFloat(n),o=Math.round(n/i*100)||0,u=n===r&&i===e.getAttribute("max")&&a!==e.hasAttribute("value")||function(e,t,r){void 0===r&&(r={});var n,i=""+s+t;if(e[i])return!0;e[i]=!0,"function"==typeof window.CustomEvent?n=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r}):(n=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,r);var a=e.dispatchEvent(n);return e[i]=null,a}(e,"progress.change",{value:n,max:i,percentage:o,indeterminate:a})?n:r;return e.setAttribute(d,u),e.setAttribute("role","img"),a?(e.removeAttribute("value"),e.setAttribute("aria-label",u)):(e.setAttribute("value",u),e.setAttribute("max",i),e.setAttribute("aria-label",o+"%")),t||document.getElementById(d)||document.head.insertAdjacentHTML("beforeend",'<style id="'+d+'">['+d+"]:after {content: attr(aria-label)}</style>"),e})}}); | ||
//# sourceMappingURL=core-progress.min.js.map |
19
jsx.js
@@ -97,15 +97,14 @@ 'use strict'; | ||
var canUpdate = noChanges || dispatchEvent(progress, 'progress.change', { value: newValue, max: max, percentage: percentage, indeterminate: indeterminate }); | ||
var setValue = canUpdate ? newValue : oldValue; | ||
progress.setAttribute(UUID, canUpdate ? newValue : oldValue); | ||
progress.setAttribute(UUID, setValue); | ||
progress.setAttribute('role', 'img'); | ||
if (canUpdate) { | ||
if (indeterminate) { | ||
progress.removeAttribute('value'); | ||
progress.setAttribute('aria-label', newValue); | ||
} else { | ||
progress.setAttribute('value', newValue); | ||
progress.setAttribute('max', max); | ||
progress.setAttribute('aria-label', (percentage + "%")); | ||
} | ||
if (indeterminate) { | ||
progress.removeAttribute('value'); | ||
progress.setAttribute('aria-label', setValue); | ||
} else { | ||
progress.setAttribute('value', setValue); | ||
progress.setAttribute('max', max); | ||
progress.setAttribute('aria-label', (percentage + "%")); | ||
} | ||
@@ -112,0 +111,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"author": "NRK <opensource@nrk.no> (https://www.nrk.no/)", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "core-progress.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
44015
350