@eva/plugin-a11y 1.2.7-fix.4 → 1.2.7-fix.5

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.
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_a11y=function(t,e,n){"use strict";var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},r(t,e)};function o(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)};function a(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,n,a):o(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a}function s(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))}function c(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function u(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function p(t){return function(e,n){var r=h(e,n);r.key=n,r.type=t}}function l(t){return function(e,n){h(e,n).step=t}}var d,v,f,y,g=function(t,e){var n=e.width,r=e.height,o=e.position,i=e.left,a=void 0===i?0:i,s=e.top,c=void 0===s?0:s,u=e.zIndex,h=e.pointerEvents,p=e.background;t.style.width=n+"px",t.style.height=r+"px",t.style.position=o,t.style.left=""+a,t.style.top=""+c,t.style.zIndex=""+u,t.style.pointerEvents=h,t.style.background=p,t.style.border="none",t.style.overflow="hidden"},m=function(t){function e(e){var n=t.call(this)||this;_extends(n,e);var r=e.hint,o=void 0===r?"":r,i=e.event,a=e.delay,s=void 0===a?0:a,c=e.attr,u=void 0===c?{}:c,h=e.role,p=void 0===h?"":h,l=e.props,d=void 0===l?{}:l,v=e.state,f=void 0===v?{}:v;return n.hint=o,n.event=i,n.delay=s,n.attr=u,n.role=p,n.props=d,n.state=f,n.a11yId="_"+function(t){for(var e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=[],r=e.length,o=0;o<t;o++)n[o]=e[0|Math.random()*r];return n.join("")}(6),n}return o(e,t),e.componentName="A11y",a([p("boolean")],e.prototype,"interactive",void 0),a([p("string")],e.prototype,"hint",void 0),a([p("number"),l(1)],e.prototype,"delay",void 0),a([p("string")],e.prototype,"role",void 0),a([p("string")],e.prototype,"a11yId",void 0),e}(e.Component),b=m,E="absolute";t.A11yActivate=void 0,(d=t.A11yActivate||(t.A11yActivate={}))[d.ENABLE=0]="ENABLE",d[d.DISABLE=1]="DISABLE",d[d.CHECK=2]="CHECK",function(t){t.NONE="none",t.AUTO="auto"}(v||(v={})),function(t){t.DEBUG="rgba(255,0,0,0.5)",t.NONE="transparent"}(f||(f={})),function(t){t.BUTTON="button",t.DIV="div"}(y||(y={}));var w=["hint","event","delay","attr","role","props","state","a11yId","name"],A=function(t,e,n){var r=this;["touchstart","touchend","tap"].forEach((function(o){t.emit(o,{stopPropagation:function(){return n.stopPropagation()},data:{position:r.eventPosition},gameObject:e})}))},O=function(r){function h(t){var e=r.call(this,t)||this;return e.cache=new Map,e.eventCache=new Map,e.zIndex=3,e}return o(h,r),Object.defineProperty(h.prototype,"ratioX",{get:function(){return this._ratioX||this.setRatio()?this._ratioX:0},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"ratioY",{get:function(){return this._ratioY||this.setRatio()?this._ratioY:0},enumerable:!1,configurable:!0}),h.prototype.init=function(e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var n,r,o,i,a,s,u,h,p;return c(this,(function(c){switch(c.label){case 0:switch(n=e.activate,r=void 0===n?t.A11yActivate.CHECK:n,o=e.delay,i=void 0===o?100:o,a=e.checkA11yOpen,s=void 0===a?function(){return Promise.resolve(!1)}:a,u=e.zIndex,this.delay=i,this.zIndex=u||this.zIndex,r){case t.A11yActivate.CHECK:return[3,1];case t.A11yActivate.DISABLE:return[3,5];case t.A11yActivate.ENABLE:return[3,6]}return[3,7];case 1:return c.trys.push([1,3,,4]),h=this,[4,s()];case 2:return h.activate=c.sent(),[3,4];case 3:return c.sent(),this.activate=!1,[3,4];case 4:return[3,7];case 5:return this.activate=!1,[3,7];case 6:return this.activate=!0,[3,7];case 7:return this.debug=e.debug||!1,this.debug&&(this.activate=!0),this.activate?(p=document.createElement("div"),this.div=p,this.game.canvas.parentNode&&this.game.canvas.parentNode.insertBefore(this.div,this.game.canvas),[2]):[2]}}))}))},h.prototype.setRatio=function(){var t=this.getCanvasBoundingClientRect(),e=t.width,n=t.height,r=this.getRenderRect(),o=r.renderWidth,i=r.renderHeight;return this._ratioX=e/o,this._ratioY=n/i,!(!e&&!n)&&(this.initDiv(),!0)},h.prototype.getRenderRect=function(){var t=this.game.getSystem(n.RendererSystem).params,e=void 0===t?{width:300,height:300}:t,r=e.height;return{renderWidth:e.width,renderHeight:r}},h.prototype.getCanvasBoundingClientRect=function(){var t=this.game.canvas.getBoundingClientRect();return{width:t.width,height:t.height,left:t.left,top:t.top}},h.prototype.initDiv=function(){var t=this,e=window.pageXOffset,n=window.pageYOffset,r=this.getCanvasBoundingClientRect(),o={width:r.width,height:r.height,left:r.left+e+"px",top:r.top+n+"px",position:E,zIndex:this.zIndex,pointerEvents:v.NONE,background:f.NONE};g(this.div,o),this.div.addEventListener("click",(function(e){var n=e.currentTarget.getBoundingClientRect(),r=n.left,o=n.top,i=(e.pageX-r)/t.ratioX,a=(e.pageY-o)/t.ratioY;t.eventPosition={x:i,y:a}}),!0)},h.prototype.update=function(){return s(this,void 0,void 0,(function(){var t,n,r,o,i,a;return c(this,(function(s){if(t=this.componentObserver.clear(),!this.activate)return[2];try{for(n=u(t),r=n.next();!r.done;r=n.next())switch((o=r.value).type){case e.OBSERVER_TYPE.ADD:"Event"===o.componentName&&this.addEvent(o.gameObject),"A11y"===o.componentName&&this.add(o);break;case e.OBSERVER_TYPE.CHANGE:"Transform"===o.componentName&&this.transformChange(o),"A11y"===o.componentName&&this.change(o);break;case e.OBSERVER_TYPE.REMOVE:"Event"===o.componentName&&this.removeEvent(o),"A11y"===o.componentName&&this.remove(o)}}catch(t){i={error:t}}finally{try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(i)throw i.error}}return[2]}))}))},h.prototype.change=function(t){var e=t.component;if("hint"===t.prop.prop[0]){var n=this.cache.get(e.a11yId);null==n||n.setAttribute("aria-label",e.hint),n&&this.setPosition(n,t.gameObject.transform)}},h.prototype.remove=function(t){var e=t.component;if(e){var n=e.a11yId,r=this.div.querySelector("#"+n);r&&this.div.removeChild(r),this.cache.delete(n)}},h.prototype.add=function(t){var e=this;if(this.activate){var n=t.component,r=t.gameObject,o=n.delay,i=n.a11yId,a=n.event;if(r){var s=r.transform;if(s){var c=document.createElement("div");this.cache.set(i,c),a||(a=r.getComponent("Event")),setTimeout((function(){e.setPosition(c,s),e.setA11yAttr(c,n),a&&e.addEvent(r),r.scene&&e.div.appendChild(c)}),o||this.delay)}}}},h.prototype.transformChange=function(t){var e=t.component,n=t.gameObject.getComponent(b);if(n){var r=n.a11yId;if(e.inScene){if(this.cache.has(r)){var o=this.cache.get(r);o&&this.div.appendChild(o)}}else{var i=this.div.querySelector("#"+r);i&&this.div.removeChild(i)}}},h.prototype.setEvent=function(t,e,n,r){if(e){var o=A.bind(this,e,n);this.eventCache.set(r,o),t.addEventListener("click",o)}},h.prototype.addEvent=function(t){var e=t.getComponent(b);if(e){var n=t.getComponent("Event");if(n){var r=this.cache.get(e.a11yId);r&&this.setEvent(r,n,t,e.a11yId)}}},h.prototype.removeEvent=function(t){var e=t.gameObject.getComponent(b);if(e&&t.component){var n=e.a11yId,r=this.eventCache.get(n),o=this.cache.get(n);o&&o.removeEventListener("click",r)}},h.prototype.setA11yAttr=function(t,e){var n,r,o,i,a,s,c=e.hint,h=e.props,p=void 0===h?{}:h,l=e.state,d=void 0===l?{}:l,v=e.role,f=e.a11yId,y=v||"text";t.setAttribute("role",y),t.setAttribute("aria-label",c),t.id=f;var g=Object.keys(p);try{for(var m=u(g),b=m.next();!b.done;b=m.next()){var E=b.value;t.setAttribute(E,p[E])}}catch(t){n={error:t}}finally{try{b&&!b.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}var A=Object.keys(d);try{for(var O=u(A),x=O.next();!x.done;x=O.next()){E=x.value;t.setAttribute(E,d[E])}}catch(t){o={error:t}}finally{try{x&&!x.done&&(i=O.return)&&i.call(O)}finally{if(o)throw o.error}}try{for(var C=u(Object.keys(e)),I=C.next();!I.done;I=C.next()){"string"==typeof e[E=I.value]&&-1===w.indexOf(E)&&1!==E.indexOf("_")&&t.setAttribute(E,e[E])}}catch(t){a={error:t}}finally{try{I&&!I.done&&(s=C.return)&&s.call(C)}finally{if(a)throw a.error}}},h.prototype.setPosition=function(t,e){var n=e.size,r=n.width,o=n.height,a={width:0===r?1:r*this.ratioX,height:0===o?1:o*this.ratioY,position:E,zIndex:this.zIndex,pointerEvents:v.AUTO,background:this.debug?f.DEBUG:f.NONE},s=i({},e);g(t,a),function(t,e,n,r){var o=e.worldTransform,i="matrix("+o.a+", "+o.b+", "+o.c+", "+o.d+", "+o.tx*n+", "+o.ty*r+")";t.style.transform=""+i,t.style.webkitTransform=""+i,t.style.transformOrigin="left top",t.style.webkitTransformOrigin="left top"}(t,s,this.ratioX,this.ratioY)},h.prototype.onDestroy=function(){this.div.parentElement.removeChild(this.div),this.cache=null,this.eventCache=null,this.div=null},h.systemName="A11ySystem",h=a([e.decorators.componentObserver({A11y:["hint"],Transform:["inScene"],Event:[]})],h)}(e.System);return t.A11y=b,t.A11ySystem=O,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer);window.EVA.plugin.a11y=window.EVA.plugin.a11y||_EVA_IIFE_a11y;
1
+ function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_a11y=function(t,e,n){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function o(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function a(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,n,a):o(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a}function s(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))}function c(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function u(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function p(t){return function(e,n){var r=h(e,n);r.key=n,r.type=t}}function l(t){return function(e,n){h(e,n).step=t}}var d,v,f,y,g=function(t,e){var n=e.width,r=e.height,o=e.position,i=e.left,a=void 0===i?0:i,s=e.top,c=void 0===s?0:s,u=e.zIndex,h=e.pointerEvents,p=e.background;t.style.width=n+"px",t.style.height=r+"px",t.style.position=o,t.style.left=""+a,t.style.top=""+c,t.style.zIndex=""+u,t.style.pointerEvents=h,t.style.background=p,t.style.border="none",t.style.overflow="hidden"},m=function(t){function e(e){var n=t.call(this)||this;_extends(n,e);var r=e.hint,o=void 0===r?"":r,i=e.event,a=e.delay,s=void 0===a?0:a,c=e.attr,u=void 0===c?{}:c,h=e.role,p=void 0===h?"":h,l=e.props,d=void 0===l?{}:l,v=e.state,f=void 0===v?{}:v;return n.hint=o,n.event=i,n.delay=s,n.attr=u,n.role=p,n.props=d,n.state=f,n.a11yId="_"+function(t){for(var e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=[],r=e.length,o=0;o<t;o++)n[o]=e[0|Math.random()*r];return n.join("")}(6),n}return o(e,t),e.componentName="A11y",a([p("boolean")],e.prototype,"interactive",void 0),a([p("string")],e.prototype,"hint",void 0),a([p("number"),l(1)],e.prototype,"delay",void 0),a([p("string")],e.prototype,"role",void 0),a([p("string")],e.prototype,"a11yId",void 0),e}(e.Component),b="absolute";t.A11yActivate=void 0,(d=t.A11yActivate||(t.A11yActivate={}))[d.ENABLE=0]="ENABLE",d[d.DISABLE=1]="DISABLE",d[d.CHECK=2]="CHECK",function(t){t.NONE="none",t.AUTO="auto"}(v||(v={})),function(t){t.DEBUG="rgba(255,0,0,0.5)",t.NONE="transparent"}(f||(f={})),function(t){t.BUTTON="button",t.DIV="div"}(y||(y={}));var E=["hint","event","delay","attr","role","props","state","a11yId","name"],w=function(t,e,n){var r=this;["touchstart","touchend","tap"].forEach((function(o){t.emit(o,{stopPropagation:function(){return n.stopPropagation()},data:{position:r.eventPosition},gameObject:e})}))},A=function(r){function h(t){var e=r.call(this,t)||this;return e.cache=new Map,e.eventCache=new Map,e.zIndex=3,e}return o(h,r),Object.defineProperty(h.prototype,"ratioX",{get:function(){return this._ratioX||this.setRatio()?this._ratioX:0},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"ratioY",{get:function(){return this._ratioY||this.setRatio()?this._ratioY:0},enumerable:!1,configurable:!0}),h.prototype.init=function(e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var n,r,o,i,a,s,u,h,p;return c(this,(function(c){switch(c.label){case 0:switch(n=e.activate,r=void 0===n?t.A11yActivate.CHECK:n,o=e.delay,i=void 0===o?100:o,a=e.checkA11yOpen,s=void 0===a?function(){return Promise.resolve(!1)}:a,u=e.zIndex,this.delay=i,this.zIndex=u||this.zIndex,r){case t.A11yActivate.CHECK:return[3,1];case t.A11yActivate.DISABLE:return[3,5];case t.A11yActivate.ENABLE:return[3,6]}return[3,7];case 1:return c.trys.push([1,3,,4]),h=this,[4,s()];case 2:return h.activate=c.sent(),[3,4];case 3:return c.sent(),this.activate=!1,[3,4];case 4:return[3,7];case 5:return this.activate=!1,[3,7];case 6:return this.activate=!0,[3,7];case 7:return this.debug=e.debug||!1,this.debug&&(this.activate=!0),this.activate?(p=document.createElement("div"),this.div=p,this.game.canvas.parentNode&&this.game.canvas.parentNode.insertBefore(this.div,this.game.canvas),[2]):[2]}}))}))},h.prototype.setRatio=function(){var t=this.getCanvasBoundingClientRect(),e=t.width,n=t.height,r=this.getRenderRect(),o=r.renderWidth,i=r.renderHeight;return this._ratioX=e/o,this._ratioY=n/i,!(!e&&!n)&&(this.initDiv(),!0)},h.prototype.getRenderRect=function(){var t=this.game.getSystem(n.RendererSystem).params,e=void 0===t?{width:300,height:300}:t,r=e.height;return{renderWidth:e.width,renderHeight:r}},h.prototype.getCanvasBoundingClientRect=function(){var t=this.game.canvas.getBoundingClientRect();return{width:t.width,height:t.height,left:t.left,top:t.top}},h.prototype.initDiv=function(){var t=this,e=window.pageXOffset,n=window.pageYOffset,r=this.getCanvasBoundingClientRect(),o={width:r.width,height:r.height,left:r.left+e+"px",top:r.top+n+"px",position:b,zIndex:this.zIndex,pointerEvents:v.NONE,background:f.NONE};g(this.div,o),this.div.addEventListener("click",(function(e){var n=e.currentTarget.getBoundingClientRect(),r=n.left,o=n.top,i=(e.pageX-r)/t.ratioX,a=(e.pageY-o)/t.ratioY;t.eventPosition={x:i,y:a}}),!0)},h.prototype.update=function(){return s(this,void 0,void 0,(function(){var t,n,r,o,i,a;return c(this,(function(s){if(t=this.componentObserver.clear(),!this.activate)return[2];try{for(n=u(t),r=n.next();!r.done;r=n.next())switch((o=r.value).type){case e.OBSERVER_TYPE.ADD:"Event"===o.componentName&&this.addEvent(o.gameObject),"A11y"===o.componentName&&this.add(o);break;case e.OBSERVER_TYPE.CHANGE:"Transform"===o.componentName&&this.transformChange(o),"A11y"===o.componentName&&this.change(o);break;case e.OBSERVER_TYPE.REMOVE:"Event"===o.componentName&&this.removeEvent(o),"A11y"===o.componentName&&this.remove(o)}}catch(t){i={error:t}}finally{try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(i)throw i.error}}return[2]}))}))},h.prototype.change=function(t){var e=t.component;if("hint"===t.prop.prop[0]){var n=this.cache.get(e.a11yId);null==n||n.setAttribute("aria-label",e.hint),n&&this.setPosition(n,t.gameObject.transform)}},h.prototype.remove=function(t){var e=t.component;if(e){var n=e.a11yId,r=this.div.querySelector("#"+n);r&&this.div.removeChild(r),this.cache.delete(n)}},h.prototype.add=function(t){var e=this;if(this.activate){var n=t.component,r=t.gameObject,o=n.delay,i=n.a11yId,a=n.event;if(r){var s=r.transform;if(s){var c=document.createElement("div");this.cache.set(i,c),a||(a=r.getComponent("Event")),setTimeout((function(){e.setPosition(c,s),e.setA11yAttr(c,n),a&&e.addEvent(r),r.scene&&e.div.appendChild(c)}),o||this.delay)}}}},h.prototype.transformChange=function(t){var e=t.component,n=t.gameObject.getComponent(m);if(n){var r=n.a11yId;if(e.inScene){if(this.cache.has(r)){var o=this.cache.get(r);o&&this.div.appendChild(o)}}else{var i=this.div.querySelector("#"+r);i&&this.div.removeChild(i)}}},h.prototype.setEvent=function(t,e,n,r){if(e){var o=w.bind(this,e,n);this.eventCache.set(r,o),t.addEventListener("click",o)}},h.prototype.addEvent=function(t){var e=t.getComponent(m);if(e){var n=t.getComponent("Event");if(n){var r=this.cache.get(e.a11yId);r&&this.setEvent(r,n,t,e.a11yId)}}},h.prototype.removeEvent=function(t){var e=t.gameObject.getComponent(m);if(e&&t.component){var n=e.a11yId,r=this.eventCache.get(n),o=this.cache.get(n);o&&o.removeEventListener("click",r)}},h.prototype.setA11yAttr=function(t,e){var n,r,o,i,a,s,c=e.hint,h=e.props,p=void 0===h?{}:h,l=e.state,d=void 0===l?{}:l,v=e.role,f=e.a11yId,y=v||"text";t.setAttribute("role",y),t.setAttribute("aria-label",c),t.id=f;var g=Object.keys(p);try{for(var m=u(g),b=m.next();!b.done;b=m.next()){var w=b.value;t.setAttribute(w,p[w])}}catch(t){n={error:t}}finally{try{b&&!b.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}var A=Object.keys(d);try{for(var O=u(A),x=O.next();!x.done;x=O.next()){w=x.value;t.setAttribute(w,d[w])}}catch(t){o={error:t}}finally{try{x&&!x.done&&(i=O.return)&&i.call(O)}finally{if(o)throw o.error}}try{for(var C=u(Object.keys(e)),I=C.next();!I.done;I=C.next()){"string"==typeof e[w=I.value]&&-1===E.indexOf(w)&&1!==w.indexOf("_")&&t.setAttribute(w,e[w])}}catch(t){a={error:t}}finally{try{I&&!I.done&&(s=C.return)&&s.call(C)}finally{if(a)throw a.error}}},h.prototype.setPosition=function(t,e){var n=e.size,r=n.width,o=n.height,a={width:0===r?1:r*this.ratioX,height:0===o?1:o*this.ratioY,position:b,zIndex:this.zIndex,pointerEvents:v.AUTO,background:this.debug?f.DEBUG:f.NONE},s=i({},e);g(t,a),function(t,e,n,r){var o=e.worldTransform,i="matrix("+o.a+", "+o.b+", "+o.c+", "+o.d+", "+o.tx*n+", "+o.ty*r+")";t.style.transform=""+i,t.style.webkitTransform=""+i,t.style.transformOrigin="left top",t.style.webkitTransformOrigin="left top"}(t,s,this.ratioX,this.ratioY)},h.prototype.onDestroy=function(){this.div.parentElement.removeChild(this.div),this.cache=null,this.eventCache=null,this.div=null},h.systemName="A11ySystem",h=a([e.decorators.componentObserver({A11y:["hint"],Transform:["inScene"],Event:[]})],h)}(e.System);return t.A11y=m,t.A11ySystem=A,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer);window.EVA.plugin.a11y=window.EVA.plugin.a11y||_EVA_IIFE_a11y;
@@ -1,29 +1,34 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
2
3
  import { documentAlias, windowAlias } from '@eva/miniprogram-adapter';
3
4
  import { __extends, __decorate, __awaiter, __generator, __values, __assign } from 'tslib';
4
5
  import { Component, OBSERVER_TYPE, decorators, System } from '@eva/eva.js/dist/miniprogram';
5
6
  import { RendererSystem } from '@eva/plugin-renderer/dist/miniprogram';
6
7
  import { type, step } from '@eva/inspector-decorator';
8
+
7
9
  function uuid(len) {
8
10
  var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
9
11
  var uuid = [];
10
12
  var radix = chars.length;
13
+
11
14
  for (var i = 0; i < len; i++) {
12
15
  uuid[i] = chars[0 | Math.random() * radix];
13
16
  }
17
+
14
18
  return uuid.join('');
15
19
  }
20
+
16
21
  var setStyle = function setStyle(element, style) {
17
22
  var width = style.width,
18
- height = style.height,
19
- position = style.position,
20
- _a = style.left,
21
- left = _a === void 0 ? 0 : _a,
22
- _b = style.top,
23
- top = _b === void 0 ? 0 : _b,
24
- zIndex = style.zIndex,
25
- pointerEvents = style.pointerEvents,
26
- background = style.background;
23
+ height = style.height,
24
+ position = style.position,
25
+ _a = style.left,
26
+ left = _a === void 0 ? 0 : _a,
27
+ _b = style.top,
28
+ top = _b === void 0 ? 0 : _b,
29
+ zIndex = style.zIndex,
30
+ pointerEvents = style.pointerEvents,
31
+ background = style.background;
27
32
  element.style.width = width + "px";
28
33
  element.style.height = height + "px";
29
34
  element.style.position = position;
@@ -35,38 +40,43 @@ var setStyle = function setStyle(element, style) {
35
40
  element.style.border = 'none';
36
41
  element.style.overflow = 'hidden';
37
42
  };
43
+
38
44
  var setTransform = function setTransform(element, transform, ratioX, ratioY) {
39
45
  var worldTransform = transform.worldTransform;
40
46
  var a = worldTransform.a,
41
- b = worldTransform.b,
42
- c = worldTransform.c,
43
- d = worldTransform.d,
44
- tx = worldTransform.tx,
45
- ty = worldTransform.ty;
47
+ b = worldTransform.b,
48
+ c = worldTransform.c,
49
+ d = worldTransform.d,
50
+ tx = worldTransform.tx,
51
+ ty = worldTransform.ty;
46
52
  var matrix = "matrix(" + a + ", " + b + ", " + c + ", " + d + ", " + tx * ratioX + ", " + ty * ratioY + ")";
47
53
  element.style.transform = "" + matrix;
48
54
  element.style.webkitTransform = "" + matrix;
49
55
  element.style.transformOrigin = 'left top';
50
56
  element.style.webkitTransformOrigin = 'left top';
51
57
  };
58
+
52
59
  var A11y = function (_super) {
53
60
  __extends(A11y, _super);
61
+
54
62
  function A11y(param) {
55
63
  var _this = _super.call(this) || this;
64
+
56
65
  _extends(_this, param);
66
+
57
67
  var _a = param.hint,
58
- hint = _a === void 0 ? '' : _a,
59
- event = param.event,
60
- _b = param.delay,
61
- delay = _b === void 0 ? 0 : _b,
62
- _c = param.attr,
63
- attr = _c === void 0 ? {} : _c,
64
- _d = param.role,
65
- role = _d === void 0 ? '' : _d,
66
- _e = param.props,
67
- props = _e === void 0 ? {} : _e,
68
- _f = param.state,
69
- state = _f === void 0 ? {} : _f;
68
+ hint = _a === void 0 ? '' : _a,
69
+ event = param.event,
70
+ _b = param.delay,
71
+ delay = _b === void 0 ? 0 : _b,
72
+ _c = param.attr,
73
+ attr = _c === void 0 ? {} : _c,
74
+ _d = param.role,
75
+ role = _d === void 0 ? '' : _d,
76
+ _e = param.props,
77
+ props = _e === void 0 ? {} : _e,
78
+ _f = param.state,
79
+ state = _f === void 0 ? {} : _f;
70
80
  _this.hint = hint;
71
81
  _this.event = event;
72
82
  _this.delay = delay;
@@ -77,41 +87,59 @@ var A11y = function (_super) {
77
87
  _this.a11yId = "_" + uuid(6);
78
88
  return _this;
79
89
  }
90
+
80
91
  A11y.componentName = 'A11y';
92
+
81
93
  __decorate([type('boolean')], A11y.prototype, "interactive", void 0);
94
+
82
95
  __decorate([type('string')], A11y.prototype, "hint", void 0);
96
+
83
97
  __decorate([type('number'), step(1)], A11y.prototype, "delay", void 0);
98
+
84
99
  __decorate([type('string')], A11y.prototype, "role", void 0);
100
+
85
101
  __decorate([type('string')], A11y.prototype, "a11yId", void 0);
102
+
86
103
  return A11y;
87
104
  }(Component);
105
+
88
106
  var A11y$1 = A11y;
89
107
  var POSITION = 'absolute';
90
108
  var ZINDEX = 3;
91
109
  var A11yActivate;
110
+
92
111
  (function (A11yActivate) {
93
112
  A11yActivate[A11yActivate["ENABLE"] = 0] = "ENABLE";
94
113
  A11yActivate[A11yActivate["DISABLE"] = 1] = "DISABLE";
95
114
  A11yActivate[A11yActivate["CHECK"] = 2] = "CHECK";
96
115
  })(A11yActivate || (A11yActivate = {}));
116
+
97
117
  var PointerEvents;
118
+
98
119
  (function (PointerEvents) {
99
120
  PointerEvents["NONE"] = "none";
100
121
  PointerEvents["AUTO"] = "auto";
101
122
  })(PointerEvents || (PointerEvents = {}));
123
+
102
124
  var MaskBackground;
125
+
103
126
  (function (MaskBackground) {
104
127
  MaskBackground["DEBUG"] = "rgba(255,0,0,0.5)";
105
128
  MaskBackground["NONE"] = "transparent";
106
129
  })(MaskBackground || (MaskBackground = {}));
130
+
107
131
  var ElementType;
132
+
108
133
  (function (ElementType) {
109
134
  ElementType["BUTTON"] = "button";
110
135
  ElementType["DIV"] = "div";
111
136
  })(ElementType || (ElementType = {}));
137
+
112
138
  var notAttr = ['hint', 'event', 'delay', 'attr', 'role', 'props', 'state', 'a11yId', 'name'];
139
+
113
140
  var getEventFunc = function getEventFunc(event, gameObject, e) {
114
141
  var _this = this;
142
+
115
143
  ['touchstart', 'touchend', 'tap'].forEach(function (name) {
116
144
  event.emit(name, {
117
145
  stopPropagation: function stopPropagation() {
@@ -124,21 +152,26 @@ var getEventFunc = function getEventFunc(event, gameObject, e) {
124
152
  });
125
153
  });
126
154
  };
155
+
127
156
  var A11ySystem = function (_super) {
128
157
  __extends(A11ySystem, _super);
158
+
129
159
  function A11ySystem(opt) {
130
160
  var _this = _super.call(this, opt) || this;
161
+
131
162
  _this.cache = new Map();
132
163
  _this.eventCache = new Map();
133
164
  _this.zIndex = ZINDEX;
134
165
  return _this;
135
166
  }
167
+
136
168
  Object.defineProperty(A11ySystem.prototype, "ratioX", {
137
169
  get: function get() {
138
170
  if (this._ratioX) {
139
171
  return this._ratioX;
140
172
  } else {
141
173
  var success = this.setRatio();
174
+
142
175
  if (success) {
143
176
  return this._ratioX;
144
177
  } else {
@@ -155,6 +188,7 @@ var A11ySystem = function (_super) {
155
188
  return this._ratioY;
156
189
  } else {
157
190
  var success = this.setRatio();
191
+
158
192
  if (success) {
159
193
  return this._ratioY;
160
194
  } else {
@@ -165,12 +199,15 @@ var A11ySystem = function (_super) {
165
199
  enumerable: false,
166
200
  configurable: true
167
201
  });
202
+
168
203
  A11ySystem.prototype.init = function (opt) {
169
204
  if (opt === void 0) {
170
205
  opt = {};
171
206
  }
207
+
172
208
  return __awaiter(this, void 0, void 0, function () {
173
209
  var _a, activate, _b, delay, _c, checkA11yOpen, zIndex, _d, _e, div;
210
+
174
211
  return __generator(this, function (_f) {
175
212
  switch (_f.label) {
176
213
  case 0:
@@ -180,59 +217,80 @@ var A11ySystem = function (_super) {
180
217
  this.delay = delay;
181
218
  this.zIndex = zIndex || this.zIndex;
182
219
  _d = activate;
220
+
183
221
  switch (_d) {
184
222
  case A11yActivate.CHECK:
185
223
  return [3, 1];
224
+
186
225
  case A11yActivate.DISABLE:
187
226
  return [3, 5];
227
+
188
228
  case A11yActivate.ENABLE:
189
229
  return [3, 6];
190
230
  }
231
+
191
232
  return [3, 7];
233
+
192
234
  case 1:
193
235
  _f.trys.push([1, 3,, 4]);
236
+
194
237
  _e = this;
195
238
  return [4, checkA11yOpen()];
239
+
196
240
  case 2:
197
241
  _e.activate = _f.sent();
198
242
  return [3, 4];
243
+
199
244
  case 3:
200
245
  _f.sent();
246
+
201
247
  this.activate = false;
202
248
  return [3, 4];
249
+
203
250
  case 4:
204
251
  return [3, 7];
252
+
205
253
  case 5:
206
254
  this.activate = false;
207
255
  return [3, 7];
256
+
208
257
  case 6:
209
258
  this.activate = true;
210
259
  return [3, 7];
260
+
211
261
  case 7:
212
262
  this.debug = opt.debug || false;
263
+
213
264
  if (this.debug) {
214
265
  this.activate = true;
215
266
  }
267
+
216
268
  if (!this.activate) return [2];
217
269
  div = documentAlias.createElement('div');
218
270
  this.div = div;
271
+
219
272
  if (this.game.canvas.parentNode) {
220
273
  this.game.canvas.parentNode.insertBefore(this.div, this.game.canvas);
221
274
  }
275
+
222
276
  return [2];
223
277
  }
224
278
  });
225
279
  });
226
280
  };
281
+
227
282
  A11ySystem.prototype.setRatio = function () {
228
283
  var _a = this.getCanvasBoundingClientRect(),
229
- width = _a.width,
230
- height = _a.height;
284
+ width = _a.width,
285
+ height = _a.height;
286
+
231
287
  var _b = this.getRenderRect(),
232
- renderWidth = _b.renderWidth,
233
- renderHeight = _b.renderHeight;
288
+ renderWidth = _b.renderWidth,
289
+ renderHeight = _b.renderHeight;
290
+
234
291
  this._ratioX = width / renderWidth;
235
292
  this._ratioY = height / renderHeight;
293
+
236
294
  if (width || height) {
237
295
  this.initDiv();
238
296
  return true;
@@ -240,25 +298,28 @@ var A11ySystem = function (_super) {
240
298
  return false;
241
299
  }
242
300
  };
301
+
243
302
  A11ySystem.prototype.getRenderRect = function () {
244
303
  var _a = this.game.getSystem(RendererSystem).params,
245
- params = _a === void 0 ? {
246
- width: 300,
247
- height: 300
248
- } : _a;
304
+ params = _a === void 0 ? {
305
+ width: 300,
306
+ height: 300
307
+ } : _a;
249
308
  var renderHeight = params.height,
250
- renderWidth = params.width;
309
+ renderWidth = params.width;
251
310
  return {
252
311
  renderWidth: renderWidth,
253
312
  renderHeight: renderHeight
254
313
  };
255
314
  };
315
+
256
316
  A11ySystem.prototype.getCanvasBoundingClientRect = function () {
257
317
  var _a = this.game.canvas.getBoundingClientRect(),
258
- width = _a.width,
259
- height = _a.height,
260
- left = _a.left,
261
- top = _a.top;
318
+ width = _a.width,
319
+ height = _a.height,
320
+ left = _a.left,
321
+ top = _a.top;
322
+
262
323
  return {
263
324
  width: width,
264
325
  height: height,
@@ -266,15 +327,19 @@ var A11ySystem = function (_super) {
266
327
  top: top
267
328
  };
268
329
  };
330
+
269
331
  A11ySystem.prototype.initDiv = function () {
270
332
  var _this = this;
333
+
271
334
  var pageXOffset = windowAlias.pageXOffset,
272
- pageYOffset = windowAlias.pageYOffset;
335
+ pageYOffset = windowAlias.pageYOffset;
336
+
273
337
  var _a = this.getCanvasBoundingClientRect(),
274
- width = _a.width,
275
- height = _a.height,
276
- left = _a.left,
277
- top = _a.top;
338
+ width = _a.width,
339
+ height = _a.height,
340
+ left = _a.left,
341
+ top = _a.top;
342
+
278
343
  var style = {
279
344
  width: width,
280
345
  height: height,
@@ -288,9 +353,11 @@ var A11ySystem = function (_super) {
288
353
  setStyle(this.div, style);
289
354
  this.div.addEventListener('click', function (e) {
290
355
  var currentTarget = e.currentTarget;
356
+
291
357
  var _a = currentTarget.getBoundingClientRect(),
292
- left = _a.left,
293
- top = _a.top;
358
+ left = _a.left,
359
+ top = _a.top;
360
+
294
361
  var x = (e.pageX - left) / _this.ratioX;
295
362
  var y = (e.pageY - top) / _this.ratioY;
296
363
  _this.eventPosition = {
@@ -299,27 +366,35 @@ var A11ySystem = function (_super) {
299
366
  };
300
367
  }, true);
301
368
  };
369
+
302
370
  A11ySystem.prototype.update = function () {
303
371
  return __awaiter(this, void 0, void 0, function () {
304
372
  var changes, changes_1, changes_1_1, changed;
373
+
305
374
  var e_1, _a;
375
+
306
376
  return __generator(this, function (_b) {
307
377
  changes = this.componentObserver.clear();
378
+
308
379
  if (!this.activate) {
309
380
  return [2];
310
381
  }
382
+
311
383
  try {
312
384
  for (changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
313
385
  changed = changes_1_1.value;
386
+
314
387
  switch (changed.type) {
315
388
  case OBSERVER_TYPE.ADD:
316
389
  changed.componentName === 'Event' && this.addEvent(changed.gameObject);
317
390
  changed.componentName === 'A11y' && this.add(changed);
318
391
  break;
392
+
319
393
  case OBSERVER_TYPE.CHANGE:
320
394
  changed.componentName === 'Transform' && this.transformChange(changed);
321
395
  changed.componentName === 'A11y' && this.change(changed);
322
396
  break;
397
+
323
398
  case OBSERVER_TYPE.REMOVE:
324
399
  changed.componentName === 'Event' && this.removeEvent(changed);
325
400
  changed.componentName === 'A11y' && this.remove(changed);
@@ -336,18 +411,22 @@ var A11ySystem = function (_super) {
336
411
  if (e_1) throw e_1.error;
337
412
  }
338
413
  }
414
+
339
415
  return [2];
340
416
  });
341
417
  });
342
418
  };
419
+
343
420
  A11ySystem.prototype.change = function (changed) {
344
421
  var component = changed.component;
422
+
345
423
  if (changed.prop.prop[0] === 'hint') {
346
424
  var dom = this.cache.get(component.a11yId);
347
425
  dom === null || dom === void 0 ? void 0 : dom.setAttribute('aria-label', component.hint);
348
426
  dom && this.setPosition(dom, changed.gameObject.transform);
349
427
  }
350
428
  };
429
+
351
430
  A11ySystem.prototype.remove = function (changed) {
352
431
  var component = changed.component;
353
432
  if (!component) return;
@@ -356,39 +435,48 @@ var A11ySystem = function (_super) {
356
435
  element && this.div.removeChild(element);
357
436
  this.cache.delete(a11yId);
358
437
  };
438
+
359
439
  A11ySystem.prototype.add = function (changed) {
360
440
  var _this = this;
441
+
361
442
  if (!this.activate) return;
362
443
  var component = changed.component;
363
444
  var gameObject = changed.gameObject;
364
445
  var delay = component.delay,
365
- id = component.a11yId;
446
+ id = component.a11yId;
366
447
  var event = component.event;
367
448
  if (!gameObject) return;
368
449
  var transform = gameObject.transform;
369
450
  if (!transform) return;
370
451
  var element = documentAlias.createElement('div');
371
452
  this.cache.set(id, element);
453
+
372
454
  if (!event) {
373
455
  event = gameObject.getComponent('Event');
374
456
  }
457
+
375
458
  setTimeout(function () {
376
459
  _this.setPosition(element, transform);
460
+
377
461
  _this.setA11yAttr(element, component);
462
+
378
463
  if (event) {
379
464
  _this.addEvent(gameObject);
380
465
  }
466
+
381
467
  if (gameObject.scene) {
382
468
  _this.div.appendChild(element);
383
469
  }
384
470
  }, delay || this.delay);
385
471
  };
472
+
386
473
  A11ySystem.prototype.transformChange = function (changed) {
387
474
  var component = changed.component;
388
475
  var gameObject = changed.gameObject;
389
476
  var a11yComponent = gameObject.getComponent(A11y$1);
390
477
  if (!a11yComponent) return;
391
478
  var a11yId = a11yComponent.a11yId;
479
+
392
480
  if (!component.inScene) {
393
481
  var dom = this.div.querySelector("#" + a11yId);
394
482
  dom && this.div.removeChild(dom);
@@ -399,14 +487,17 @@ var A11ySystem = function (_super) {
399
487
  }
400
488
  }
401
489
  };
490
+
402
491
  A11ySystem.prototype.setEvent = function (element, event, gameObject, id) {
403
492
  if (!event) {
404
493
  return;
405
494
  }
495
+
406
496
  var func = getEventFunc.bind(this, event, gameObject);
407
497
  this.eventCache.set(id, func);
408
498
  element.addEventListener('click', func);
409
499
  };
500
+
410
501
  A11ySystem.prototype.addEvent = function (gameObject) {
411
502
  var a11y = gameObject.getComponent(A11y$1);
412
503
  if (!a11y) return;
@@ -415,6 +506,7 @@ var A11ySystem = function (_super) {
415
506
  var element = this.cache.get(a11y.a11yId);
416
507
  element && this.setEvent(element, event, gameObject, a11y.a11yId);
417
508
  };
509
+
418
510
  A11ySystem.prototype.removeEvent = function (changed) {
419
511
  var gameObject = changed.gameObject;
420
512
  var a11y = gameObject.getComponent(A11y$1);
@@ -426,20 +518,23 @@ var A11ySystem = function (_super) {
426
518
  var element = this.cache.get(a11yId);
427
519
  element && element.removeEventListener('click', func);
428
520
  };
521
+
429
522
  A11ySystem.prototype.setA11yAttr = function (element, component) {
430
523
  var e_2, _a, e_3, _b, e_4, _c;
524
+
431
525
  var hint = component.hint,
432
- _d = component.props,
433
- props = _d === void 0 ? {} : _d,
434
- _e = component.state,
435
- state = _e === void 0 ? {} : _e,
436
- role = component.role,
437
- id = component.a11yId;
526
+ _d = component.props,
527
+ props = _d === void 0 ? {} : _d,
528
+ _e = component.state,
529
+ state = _e === void 0 ? {} : _e,
530
+ role = component.role,
531
+ id = component.a11yId;
438
532
  var realRole = role || 'text';
439
533
  element.setAttribute('role', realRole);
440
534
  element.setAttribute('aria-label', hint);
441
535
  element.id = id;
442
536
  var ariaProps = Object.keys(props);
537
+
443
538
  try {
444
539
  for (var ariaProps_1 = __values(ariaProps), ariaProps_1_1 = ariaProps_1.next(); !ariaProps_1_1.done; ariaProps_1_1 = ariaProps_1.next()) {
445
540
  var key = ariaProps_1_1.value;
@@ -456,7 +551,9 @@ var A11ySystem = function (_super) {
456
551
  if (e_2) throw e_2.error;
457
552
  }
458
553
  }
554
+
459
555
  var ariaState = Object.keys(state);
556
+
460
557
  try {
461
558
  for (var ariaState_1 = __values(ariaState), ariaState_1_1 = ariaState_1.next(); !ariaState_1_1.done; ariaState_1_1 = ariaState_1.next()) {
462
559
  var key = ariaState_1_1.value;
@@ -473,9 +570,11 @@ var A11ySystem = function (_super) {
473
570
  if (e_3) throw e_3.error;
474
571
  }
475
572
  }
573
+
476
574
  try {
477
575
  for (var _f = __values(Object.keys(component)), _g = _f.next(); !_g.done; _g = _f.next()) {
478
576
  var key = _g.value;
577
+
479
578
  if (typeof component[key] === 'string' && notAttr.indexOf(key) === -1 && key.indexOf('_') !== 1) {
480
579
  element.setAttribute(key, component[key]);
481
580
  }
@@ -492,10 +591,11 @@ var A11ySystem = function (_super) {
492
591
  }
493
592
  }
494
593
  };
594
+
495
595
  A11ySystem.prototype.setPosition = function (element, transform) {
496
596
  var _a = transform.size,
497
- width = _a.width,
498
- height = _a.height;
597
+ width = _a.width,
598
+ height = _a.height;
499
599
  var style = {
500
600
  width: width === 0 ? 1 : width * this.ratioX,
501
601
  height: height === 0 ? 1 : height * this.ratioY,
@@ -504,16 +604,20 @@ var A11ySystem = function (_super) {
504
604
  pointerEvents: PointerEvents.AUTO,
505
605
  background: this.debug ? MaskBackground.DEBUG : MaskBackground.NONE
506
606
  };
607
+
507
608
  var transformProps = __assign({}, transform);
609
+
508
610
  setStyle(element, style);
509
611
  setTransform(element, transformProps, this.ratioX, this.ratioY);
510
612
  };
613
+
511
614
  A11ySystem.prototype.onDestroy = function () {
512
615
  this.div.parentElement.removeChild(this.div);
513
616
  this.cache = null;
514
617
  this.eventCache = null;
515
618
  this.div = null;
516
619
  };
620
+
517
621
  A11ySystem.systemName = 'A11ySystem';
518
622
  A11ySystem = __decorate([decorators.componentObserver({
519
623
  A11y: ['hint'],
@@ -522,5 +626,6 @@ var A11ySystem = function (_super) {
522
626
  })], A11ySystem);
523
627
  return A11ySystem;
524
628
  }(System);
629
+
525
630
  var A11ySystem$1 = A11ySystem;
526
631
  export { A11y$1 as A11y, A11yActivate, A11ySystem$1 as A11ySystem };