@stories-js/core
Version:
Stories web components to build stories
5 lines • 9.7 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(e,t,o,r){function n(e){return e instanceof o?e:new o((function(t){t(e)}))}return new(o||(o=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(t){i(t)}}function s(e){try{l(r["throw"](e))}catch(t){i(t)}}function l(e){e.done?o(e.value):n(e.value).then(a,s)}l((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,n,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return l([e,t])}}function l(a){if(r)throw new TypeError("Generator is already executing.");while(o)try{if(r=1,n&&(i=a[0]&2?n["return"]:a[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;if(n=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:o.label++;return{value:a[1],done:false};case 5:o.label++;n=a[1];a=[0];continue;case 7:a=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){o=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(a[0]===6&&o.label<i[1]){o.label=i[1];i=a;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(a);break}if(i[2])o.ops.pop();o.trys.pop();continue}a=t.call(e,o)}catch(s){a=[6,s];n=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};
/*!
* (C) StoriesJS https://storiesjs.org - GPL-2.0 License
*/System.register(["./p-fbcb0011.system.js","./p-5d1bdeae.system.js","./p-743c979d.system.js"],(function(e){"use strict";var t,o,r,n,i,a,s,l,c;return{setters:[function(e){t=e.r;o=e.i;r=e.f;n=e.h;i=e.c;a=e.g},function(e){s=e.d;l=e.a},function(e){c=e.c}],execute:function(){var h=":host{--placeholder-color:initial;--placeholder-font-style:initial;--placeholder-font-weight:initial;--placeholder-opacity:.5;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:-ms-flexbox;display:flex;position:relative;-ms-flex-align:center;align-items:center;width:100%;color:var(--color);font-family:var(--stories-font-family, inherit);-webkit-box-sizing:border-box;box-sizing:border-box}:host(.stories-color){color:var(--stories-color-contrast)}:host(.stories-color) .searchbar-input{background:var(--stories-color-base)}:host(.stories-color) .searchbar-clear-button,:host(.stories-color) .searchbar-cancel-button,:host(.stories-color) .searchbar-search-icon{color:inherit}.searchbar-search-icon{color:var(--icon-color);pointer-events:none}.searchbar-input-container{display:block;position:relative;-ms-flex-negative:1;flex-shrink:1;width:100%}.searchbar-input{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;text-decoration:inherit;text-indent:inherit;text-overflow:inherit;text-transform:inherit;text-align:inherit;white-space:inherit;color:inherit;border-radius:var(--border-radius);display:block;width:100%;border:0;outline:none;background:var(--background);font-family:inherit;-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow);-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-input::-webkit-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input::-moz-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input:-ms-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input::-ms-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input::placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input::-webkit-search-cancel-button,.searchbar-input::-ms-clear{display:none}.searchbar-cancel-button{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:none;height:100%;border:0;outline:none;color:var(--cancel-button-color);cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-cancel-button>div{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:100%;height:100%}.searchbar-clear-button{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;display:none;min-height:0;outline:none;color:var(--clear-button-color);-webkit-appearance:none;-moz-appearance:none;appearance:none}:host(.searchbar-has-value.searchbar-should-show-clear) .searchbar-clear-button{display:block}:host(.searchbar-disabled){cursor:default;opacity:0.4;pointer-events:none}";var u=e("stories_searchbar",function(){function e(e){var r=this;t(this,e);this.storiesInput=o(this,"storiesInput",7);this.storiesChange=o(this,"storiesChange",7);this.storiesCancel=o(this,"storiesCancel",7);this.storiesClear=o(this,"storiesClear",7);this.storiesBlur=o(this,"storiesBlur",7);this.storiesFocus=o(this,"storiesFocus",7);this.storiesStyle=o(this,"storiesStyle",7);this.shouldAlignLeft=true;this.focused=false;this.cancelButtonIcon="arrow-back-sharp";this.debounce=250;this.disabled=false;this.placeholder="Search";this.showCancelButton="never";this.showClearButton="always";this.type="search";this.value="";this.onClearInput=function(e,t){r.storiesClear.emit();if(e){e.preventDefault();e.stopPropagation()}setTimeout((function(){var e=r.getValue();if(e!==""){r.value="";r.storiesInput.emit();if(t&&!r.focused){r.setFocus()}}}),16*4)};this.onInput=function(e){var t=e.target;if(t){r.value=t.value}r.storiesInput.emit(e)};this.onBlur=function(){r.focused=false;r.storiesBlur.emit();r.positionElements()};this.onFocus=function(){r.focused=true;r.storiesFocus.emit();r.positionElements()}}e.prototype.debounceChanged=function(){this.storiesChange=s(this.storiesChange,this.debounce)};e.prototype.valueChanged=function(){var e=this.nativeInput;var t=this.getValue();if(e&&e.value!==t){e.value=t}this.storiesChange.emit({value:t})};e.prototype.showCancelButtonChanged=function(){var e=this;requestAnimationFrame((function(){e.positionElements();r(e)}))};e.prototype.connectedCallback=function(){this.emitStyle()};e.prototype.componentDidLoad=function(){this.positionElements();this.debounceChanged()};e.prototype.emitStyle=function(){this.storiesStyle.emit({searchbar:true})};e.prototype.setFocus=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){if(this.nativeInput){this.nativeInput.focus()}return[2]}))}))};e.prototype.getInputElement=function(){return Promise.resolve(this.nativeInput)};e.prototype.positionElements=function(){var e=this.getValue();var t=this.shouldAlignLeft;var o=e.trim()!==""||!!this.focused;this.shouldAlignLeft=o;if(t!==o){this.positionPlaceholder()}};e.prototype.positionPlaceholder=function(){var e=this.nativeInput;if(!e){return}var t=document.dir==="rtl";var o=(this.el.shadowRoot||this.el).querySelector(".searchbar-search-icon");if(this.shouldAlignLeft){e.removeAttribute("style");o.removeAttribute("style")}else{var r=document;var n=r.createElement("span");n.innerText=this.placeholder||"";r.body.appendChild(n);l((function(){var r=n.offsetWidth;n.remove();var i="calc(50% - "+r/2+"px)";var a="calc(50% - "+(r/2+30)+"px)";if(t){e.style.paddingRight=i;o.style.marginRight=a}else{e.style.paddingLeft=i;o.style.marginLeft=a}}))}};e.prototype.getValue=function(){return this.value||""};e.prototype.hasValue=function(){return this.getValue()!==""};e.prototype.shouldShowClearButton=function(){if(this.showClearButton==="never"||this.showClearButton==="focus"&&!this.focused){return false}return true};e.prototype.render=function(){var e=this;var t=this.clearIcon||"close-sharp";var o=this.searchIcon||"search-sharp";return n(i,{"aria-disabled":this.disabled?"true":null,class:c(this.color,{"searchbar-disabled":this.disabled,"searchbar-has-value":this.hasValue(),"searchbar-left-aligned":this.shouldAlignLeft,"searchbar-has-focus":this.focused,"searchbar-should-show-clear":this.shouldShowClearButton()}),role:"search"},n("div",{class:"searchbar-input-container"},n("input",{ref:function(t){return e.nativeInput=t},"aria-label":"search text",class:"searchbar-input",disabled:this.disabled,inputMode:this.inputmode,onBlur:this.onBlur,onFocus:this.onFocus,onInput:this.onInput,placeholder:this.placeholder,type:this.type,value:this.getValue()}),n("stories-icon",{"aria-hidden":"true",class:"searchbar-search-icon",name:o}),n("button",{"aria-label":"reset",class:"searchbar-clear-button",onMouseDown:function(t){return e.onClearInput(t,true)},onTouchStart:function(t){return e.onClearInput(t,true)},type:"button","no-blur":true},n("stories-icon",{"aria-hidden":"true",class:"searchbar-clear-icon",name:t}))))};Object.defineProperty(e.prototype,"el",{get:function(){return a(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{debounce:["debounceChanged"],value:["valueChanged"],showCancelButton:["showCancelButtonChanged"]}},enumerable:false,configurable:true});return e}());u.style=h}}}));
//# sourceMappingURL=p-75d27650.system.entry.js.map