@uploadcare/file-uploader 1.1.1 → 1.3.0-alpha.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.
- package/README.md +7 -7
- package/abstract/ActivityBlock.d.ts +1 -1
- package/abstract/ActivityBlock.d.ts.map +1 -1
- package/abstract/ActivityBlock.js +2 -0
- package/abstract/Block.d.ts +6 -11
- package/abstract/Block.d.ts.map +1 -1
- package/abstract/Block.js +37 -18
- package/abstract/CTX.d.ts +6 -6
- package/abstract/CTX.d.ts.map +1 -1
- package/abstract/LocaleManager.d.ts +3 -3
- package/abstract/SecureUploadsManager.d.ts +2 -2
- package/abstract/SecureUploadsManager.d.ts.map +1 -1
- package/abstract/SolutionBlock.d.ts +2 -2
- package/abstract/SolutionBlock.d.ts.map +1 -1
- package/abstract/TypedCollection.d.ts +1 -1
- package/abstract/TypedCollection.d.ts.map +1 -1
- package/abstract/TypedCollection.js +4 -4
- package/abstract/TypedData.d.ts +2 -2
- package/abstract/TypedData.d.ts.map +1 -1
- package/abstract/TypedData.js +4 -4
- package/abstract/UploaderBlock.d.ts +5 -5
- package/abstract/UploaderBlock.d.ts.map +1 -1
- package/abstract/UploaderBlock.js +5 -5
- package/abstract/UploaderPublicApi.d.ts +22 -21
- package/abstract/UploaderPublicApi.d.ts.map +1 -1
- package/abstract/UploaderPublicApi.js +3 -3
- package/abstract/ValidationManager.d.ts +3 -3
- package/abstract/ValidationManager.d.ts.map +1 -1
- package/abstract/a11y.d.ts +2 -2
- package/abstract/a11y.d.ts.map +1 -1
- package/abstract/bindCompatibilityFallbackProcessor.d.ts +3 -0
- package/abstract/bindCompatibilityFallbackProcessor.d.ts.map +1 -0
- package/abstract/bindCompatibilityFallbackProcessor.js +16 -0
- package/abstract/buildOutputCollectionState.d.ts +1 -1
- package/abstract/buildOutputCollectionState.d.ts.map +1 -1
- package/abstract/defineComponents.d.ts +5 -0
- package/abstract/defineComponents.d.ts.map +1 -0
- package/abstract/{registerBlocks.js → defineComponents.js} +6 -1
- package/abstract/l10nProcessor.d.ts.map +1 -1
- package/abstract/l10nProcessor.js +3 -3
- package/abstract/loadFileUploaderFrom.d.ts +8 -0
- package/abstract/loadFileUploaderFrom.d.ts.map +1 -0
- package/abstract/{connectBlocksFrom.js → loadFileUploaderFrom.js} +4 -4
- package/abstract/localeRegistry.d.ts.map +1 -1
- package/abstract/sharedConfigKey.d.ts.map +1 -1
- package/abstract/uploadEntrySchema.d.ts +2 -2
- package/abstract/uploadEntrySchema.d.ts.map +1 -1
- package/abstract/uploadEntrySchema.js +1 -1
- package/blocks/CameraSource/CameraSource.d.ts.map +1 -1
- package/blocks/CameraSource/CameraSource.js +12 -11
- package/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/CropFrame.d.ts +11 -11
- package/blocks/CloudImageEditor/src/CropFrame.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/CropFrame.js +2 -1
- package/blocks/CloudImageEditor/src/EditorButtonControl.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorButtonControl.js +3 -2
- package/blocks/CloudImageEditor/src/EditorCropButtonControl.js +1 -1
- package/blocks/CloudImageEditor/src/EditorFilterControl.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorFilterControl.js +4 -3
- package/blocks/CloudImageEditor/src/EditorImageCropper.d.ts +3 -3
- package/blocks/CloudImageEditor/src/EditorImageCropper.js +2 -2
- package/blocks/CloudImageEditor/src/EditorImageFader.d.ts +1 -1
- package/blocks/CloudImageEditor/src/EditorImageFader.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorOperationControl.js +1 -1
- package/blocks/CloudImageEditor/src/EditorScroller.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorScroller.js +2 -1
- package/blocks/CloudImageEditor/src/EditorSlider.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorSlider.js +3 -2
- package/blocks/CloudImageEditor/src/EditorToolbar.d.ts +1 -1
- package/blocks/CloudImageEditor/src/EditorToolbar.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorToolbar.js +15 -14
- package/blocks/CloudImageEditor/src/crop-utils.d.ts +14 -14
- package/blocks/CloudImageEditor/src/crop-utils.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/elements/button/BtnUi.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/elements/button/BtnUi.js +5 -5
- package/blocks/CloudImageEditor/src/elements/line-loader/LineLoaderUi.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/elements/line-loader/LineLoaderUi.js +2 -1
- package/blocks/CloudImageEditor/src/elements/presence-toggle/PresenceToggle.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/elements/presence-toggle/PresenceToggle.js +3 -2
- package/blocks/CloudImageEditor/src/elements/slider/SliderUi.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/elements/slider/SliderUi.js +3 -2
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts +1 -1
- package/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts +3 -3
- package/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/state.d.ts +4 -4
- package/blocks/CloudImageEditor/src/svg-sprite.d.ts +1 -1
- package/blocks/CloudImageEditor/src/svg-sprite.js +1 -1
- package/blocks/CloudImageEditor/src/template.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/template.js +5 -4
- package/blocks/CloudImageEditor/src/types.d.ts +2 -2
- package/blocks/CloudImageEditor/src/types.d.ts.map +1 -1
- package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts +3 -3
- package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts.map +1 -1
- package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.js +2 -1
- package/blocks/CloudImageEditorActivity/test.js +1 -1
- package/blocks/Config/Config.d.ts +3 -11
- package/blocks/Config/Config.d.ts.map +1 -1
- package/blocks/Config/initialConfig.d.ts +1 -1
- package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
- package/blocks/Copyright/Copyright.d.ts.map +1 -1
- package/blocks/Copyright/Copyright.js +2 -1
- package/blocks/DropArea/DropArea.d.ts +2 -2
- package/blocks/DropArea/DropArea.d.ts.map +1 -1
- package/blocks/DropArea/DropArea.js +5 -5
- package/blocks/DropArea/addDropzone.d.ts.map +1 -1
- package/blocks/DropArea/getDropItems.d.ts +2 -2
- package/blocks/DropArea/getDropItems.d.ts.map +1 -1
- package/blocks/ExternalSource/ExternalSource.d.ts +5 -5
- package/blocks/ExternalSource/ExternalSource.d.ts.map +1 -1
- package/blocks/ExternalSource/ExternalSource.js +9 -9
- package/blocks/ExternalSource/buildStyles.js +2 -2
- package/blocks/ExternalSource/query-string.d.ts.map +1 -1
- package/blocks/FileItem/FileItem.d.ts +3 -3
- package/blocks/FileItem/FileItem.d.ts.map +1 -1
- package/blocks/FileItem/FileItem.js +12 -11
- package/blocks/Icon/Icon.d.ts.map +1 -1
- package/blocks/Icon/Icon.js +3 -2
- package/blocks/Img/ImgBase.js +9 -9
- package/blocks/Img/ImgConfig.d.ts +2 -2
- package/blocks/Img/ImgConfig.d.ts.map +1 -1
- package/blocks/Img/ImgConfig.js +3 -3
- package/blocks/Img/utils/parseObjectToString.js +1 -1
- package/blocks/Modal/Modal.d.ts.map +1 -1
- package/blocks/Modal/Modal.js +2 -1
- package/blocks/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/blocks/ProgressBar/ProgressBar.js +2 -1
- package/blocks/ProgressBarCommon/ProgressBarCommon.d.ts.map +1 -1
- package/blocks/ProgressBarCommon/ProgressBarCommon.js +2 -1
- package/blocks/Select/Select.d.ts.map +1 -1
- package/blocks/Select/Select.js +14 -9
- package/blocks/SimpleBtn/SimpleBtn.d.ts +2 -2
- package/blocks/SimpleBtn/SimpleBtn.d.ts.map +1 -1
- package/blocks/SimpleBtn/SimpleBtn.js +4 -3
- package/blocks/SourceBtn/SourceBtn.d.ts +2 -2
- package/blocks/SourceBtn/SourceBtn.d.ts.map +1 -1
- package/blocks/SourceBtn/SourceBtn.js +4 -4
- package/blocks/SourceList/SourceList.d.ts.map +1 -1
- package/blocks/SourceList/SourceList.js +5 -4
- package/blocks/StartFrom/StartFrom.d.ts.map +1 -1
- package/blocks/StartFrom/StartFrom.js +2 -1
- package/blocks/UploadCtxProvider/EventEmitter.d.ts +19 -19
- package/blocks/UploadCtxProvider/EventEmitter.d.ts.map +1 -1
- package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts +4 -4
- package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts.map +1 -1
- package/blocks/UploadList/UploadList.d.ts +2 -2
- package/blocks/UploadList/UploadList.d.ts.map +1 -1
- package/blocks/UploadList/UploadList.js +10 -11
- package/blocks/UrlSource/UrlSource.d.ts.map +1 -1
- package/blocks/UrlSource/UrlSource.js +7 -6
- package/blocks/themes/uc-basic/index.css +0 -1
- package/blocks/themes/uc-basic/svg-sprite.d.ts +1 -1
- package/blocks/themes/uc-basic/svg-sprite.js +1 -1
- package/blocks/utils/debounce.d.ts +3 -1
- package/blocks/utils/debounce.d.ts.map +1 -1
- package/blocks/utils/throttle.d.ts +3 -1
- package/blocks/utils/throttle.d.ts.map +1 -1
- package/blocks/utils/userAgent.d.ts +1 -1
- package/blocks/utils/userAgent.d.ts.map +1 -1
- package/env.d.ts +1 -1
- package/env.js +1 -1
- package/index.d.ts +3 -3
- package/index.js +3 -3
- package/index.ssr.d.ts +118 -4
- package/index.ssr.d.ts.map +1 -1
- package/index.ssr.js +193 -81
- package/package.json +10 -8
- package/solutions/cloud-image-editor/index.d.ts +1 -1
- package/solutions/cloud-image-editor/index.js +1 -1
- package/solutions/file-uploader/inline/FileUploaderInline.d.ts +2 -2
- package/solutions/file-uploader/inline/FileUploaderInline.d.ts.map +1 -1
- package/solutions/file-uploader/inline/FileUploaderInline.js +3 -2
- package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts.map +1 -1
- package/solutions/file-uploader/minimal/FileUploaderMinimal.js +2 -1
- package/solutions/file-uploader/minimal/index.d.ts +1 -1
- package/solutions/file-uploader/minimal/index.js +1 -1
- package/solutions/file-uploader/regular/FileUploaderRegular.d.ts +2 -2
- package/solutions/file-uploader/regular/FileUploaderRegular.d.ts.map +1 -1
- package/solutions/file-uploader/regular/FileUploaderRegular.js +4 -3
- package/types/global.d.ts +1 -1
- package/types/jsx.d.ts +1 -1
- package/utils/getPluralForm.d.ts.map +1 -1
- package/utils/isSecureTokenExpired.d.ts +1 -1
- package/utils/memoize.d.ts.map +1 -1
- package/utils/mixinClass.d.ts +3 -1
- package/utils/mixinClass.d.ts.map +1 -1
- package/utils/prettyBytes.d.ts.map +1 -1
- package/utils/template-utils.d.ts.map +1 -1
- package/utils/toKebabCase.d.ts.map +1 -1
- package/utils/uniqueArray.d.ts.map +1 -1
- package/utils/validators/collection/validateCollectionUploadError.d.ts +1 -1
- package/utils/validators/collection/validateMultiple.d.ts +1 -1
- package/utils/validators/file/validateFileType.d.ts +1 -1
- package/utils/validators/file/validateIsImage.d.ts +1 -1
- package/utils/validators/file/validateMaxSizeLimit.d.ts +1 -1
- package/utils/validators/file/validateUploadError.d.ts +1 -1
- package/utils/waitForAttribute.d.ts +12 -6
- package/utils/waitForAttribute.d.ts.map +1 -1
- package/utils/waitForAttribute.js +38 -8
- package/utils/waitForAttribute.test.js +10 -47
- package/utils/withResolvers.d.ts +7 -0
- package/utils/withResolvers.d.ts.map +1 -0
- package/utils/withResolvers.js +17 -0
- package/utils/withResolvers.test.d.ts +2 -0
- package/utils/withResolvers.test.d.ts.map +1 -0
- package/utils/withResolvers.test.js +27 -0
- package/web/file-uploader.iife.min.js +29 -0
- package/web/file-uploader.min.js +29 -0
- package/web/uc-basic.min.css +1 -1
- package/web/uc-cloud-image-editor.min.js +4 -4
- package/web/uc-file-uploader-inline.min.css +1 -1
- package/web/uc-file-uploader-inline.min.js +4 -4
- package/web/uc-file-uploader-minimal.min.js +3 -3
- package/web/uc-file-uploader-regular.min.css +1 -1
- package/web/uc-file-uploader-regular.min.js +4 -4
- package/web/uc-img.min.js +3 -3
- package/abstract/connectBlocksFrom.d.ts +0 -8
- package/abstract/connectBlocksFrom.d.ts.map +0 -1
- package/abstract/registerBlocks.d.ts +0 -5
- package/abstract/registerBlocks.d.ts.map +0 -1
- package/blocks/CloudImageEditor/src/lib/FocusVisible.d.ts +0 -15
- package/blocks/CloudImageEditor/src/lib/FocusVisible.d.ts.map +0 -1
- package/blocks/CloudImageEditor/src/lib/FocusVisible.js +0 -33
- package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.d.ts +0 -10
- package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.d.ts.map +0 -1
- package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.js +0 -256
- package/blocks/Range/Range.d.ts +0 -16
- package/blocks/Range/Range.d.ts.map +0 -1
- package/blocks/Range/Range.js +0 -44
- package/blocks/Range/range.css +0 -65
- package/web/blocks.iife.min.js +0 -29
- package/web/blocks.min.js +0 -29
package/web/uc-img.min.js
CHANGED
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
|
-
var
|
|
27
|
-
`,"\\n"),
|
|
28
|
-
`));return}window.customElements.define(t,s?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(t){this.observedAttributes=Object.keys(t),this.__attrDesc=t}attributeChangedCallback(t,s,e){var r;if(s===e)return;let i=(r=this.constructor.__attrDesc)==null?void 0:r[t];i?this.__dataCtxInitialized?this.$[i]=e:this.init$[i]=e:this[t]=e}getCssData(t,s=!1){if(this.__cssDataCache||(this.__cssDataCache=Object.create(null)),!Object.keys(this.__cssDataCache).includes(t)){this.__computedStyle||(this.__computedStyle=window.getComputedStyle(this));let e=this.__computedStyle.getPropertyValue(t).trim();try{this.__cssDataCache[t]=It(e)}catch{!s&&console.warn(`CSS Data error: ${t}`),this.__cssDataCache[t]=null}}return this.__cssDataCache[t]}__extractCssName(t){return t.split("--").map((s,e)=>e===0?"":s).join("--")}__initStyleAttrObserver(){p||(p=new Set),p.add(this.updateCssData),g||(g=new MutationObserver(t=>{t[0].type==="attributes"&&p.forEach(s=>{s()})}),g.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}))}bindCssData(t,s=""){this.__boundCssProps||(this.__boundCssProps=new Set),this.__boundCssProps.add(t);let e=this.getCssData(this.__extractCssName(t),!0);e===null&&(e=s),this.add(t,e),this.__initStyleAttrObserver()}dropCssDataCache(){this.__cssDataCache=null,this.__computedStyle=null}defineAccessor(t,s,e){let r="__"+t;this[r]=this[t],Object.defineProperty(this,t,{set:i=>{this[r]=i,e?window.setTimeout(()=>{s==null||s(i)}):s==null||s(i)},get:()=>this[r]}),this[t]=this[r]}static set shadowStyles(t){let s=new Blob([t],{type:"text/css"});this.__shadowStylesUrl=URL.createObjectURL(s)}static set rootStyles(t){if(!this.__rootStylesLink){let s=new Blob([t],{type:"text/css"}),e=URL.createObjectURL(s),r=document.createElement("link");r.href=e,r.rel="stylesheet",this.__rootStylesLink=r}}},U=f;L(U,"template");var N=class{static _print(t){console.warn(t)}static setDefaultTitle(t){this.defaultTitle=t}static setRoutingMap(t){Object.assign(this.appMap,t);for(let s in this.appMap)!this.defaultRoute&&this.appMap[s].default===!0?this.defaultRoute=s:!this.errorRoute&&this.appMap[s].error===!0&&(this.errorRoute=s)}static set routingEventName(t){this.__routingEventName=t}static get routingEventName(){return this.__routingEventName||"sym-on-route"}static readAddressBar(){let t={route:null,options:{}};return window.location.search.split(this.separator).forEach(e=>{if(e.includes("?"))t.route=e.replace("?","");else if(e.includes("=")){let r=e.split("=");t.options[r[0]]=decodeURI(r[1])}else t.options[e]=!0}),t}static notify(){let t=this.readAddressBar(),s=this.appMap[t.route];if(s&&s.title&&(document.title=s.title),t.route===null&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!s&&this.errorRoute){this.applyRoute(this.errorRoute);return}else if(!s&&this.defaultRoute){this.applyRoute(this.defaultRoute);return}else if(!s){this._print(`Route "${t.route}" not found...`);return}let e=new CustomEvent(N.routingEventName,{detail:{route:t.route,options:Object.assign(s||{},t.options)}});window.dispatchEvent(e)}static reflect(t,s={}){let e=this.appMap[t];if(!e){this._print("Wrong route: "+t);return}let r="?"+t;for(let n in s)s[n]===!0?r+=this.separator+n:r+=this.separator+n+`=${s[n]}`;let i=e.title||this.defaultTitle||"";window.history.pushState(null,i,r),document.title=i}static applyRoute(t,s={}){this.reflect(t,s),this.notify()}static setSeparator(t){this._separator=t}static get separator(){return this._separator||"&"}static createRouterData(t,s){this.setRoutingMap(s);let e=c.registerCtx({route:null,options:null,title:null},t);return window.addEventListener(this.routingEventName,r=>{var i;e.multiPub({route:r.detail.route,options:r.detail.options,title:((i=r.detail.options)==null?void 0:i.title)||this.defaultTitle||""})}),N.notify(),this.initPopstateListener(),e}static initPopstateListener(){this.__onPopstate||(this.__onPopstate=()=>{this.notify()},window.addEventListener("popstate",this.__onPopstate))}static removePopstateListener(){window.removeEventListener("popstate",this.__onPopstate),this.__onPopstate=null}};N.appMap=Object.create(null);var tt="idb-store-ready",Dt="symbiote-db",Nt="symbiote-idb-update_",Lt=class{_notifyWhenReady(t=null){window.dispatchEvent(new CustomEvent(tt,{detail:{dbName:this.name,storeName:this.storeName,event:t}}))}get _updEventName(){return Nt+this.name}_getUpdateEvent(t){return new CustomEvent(this._updEventName,{detail:{key:this.name,newValue:t}})}_notifySubscribers(t){window.localStorage.removeItem(this.name),window.localStorage.setItem(this.name,t),window.dispatchEvent(this._getUpdateEvent(t))}constructor(t,s){this.name=t,this.storeName=s,this.version=1,this.request=window.indexedDB.open(this.name,this.version),this.request.onupgradeneeded=e=>{this.db=e.target.result,this.objStore=this.db.createObjectStore(s,{keyPath:"_key"}),this.objStore.transaction.oncomplete=r=>{this._notifyWhenReady(r)}},this.request.onsuccess=e=>{this.db=e.target.result,this._notifyWhenReady(e)},this.request.onerror=e=>{console.error(e)},this._subscriptionsMap={},this._updateHandler=e=>{e.key===this.name&&this._subscriptionsMap[e.newValue]&&this._subscriptionsMap[e.newValue].forEach(async i=>{i(await this.read(e.newValue))})},this._localUpdateHandler=e=>{this._updateHandler(e.detail)},window.addEventListener("storage",this._updateHandler),window.addEventListener(this._updEventName,this._localUpdateHandler)}read(t){let e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).get(t);return new Promise((r,i)=>{e.onsuccess=n=>{var o;(o=n.target.result)!=null&&o._value?r(n.target.result._value):(r(null),console.warn(`IDB: cannot read "${t}"`))},e.onerror=n=>{i(n)}})}write(t,s,e=!1){let r={_key:t,_value:s},n=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).put(r);return new Promise((o,l)=>{n.onsuccess=u=>{e||this._notifySubscribers(t),o(u.target.result)},n.onerror=u=>{l(u)}})}delete(t,s=!1){let r=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(t);return new Promise((i,n)=>{r.onsuccess=o=>{s||this._notifySubscribers(t),i(o)},r.onerror=o=>{n(o)}})}getAll(){let s=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).getAll();return new Promise((e,r)=>{s.onsuccess=i=>{let n=i.target.result;e(n.map(o=>o._value))},s.onerror=i=>{r(i)}})}subscribe(t,s){this._subscriptionsMap[t]||(this._subscriptionsMap[t]=new Set);let e=this._subscriptionsMap[t];return e.add(s),{remove:()=>{e.delete(s),e.size||delete this._subscriptionsMap[t]}}}stop(){window.removeEventListener("storage",this._updateHandler),this._subscriptionsMap=null,et.clear(this.name)}},et=class{static get readyEventName(){return tt}static open(t=Dt,s="store"){let e=t+"/"+s;return this._reg[e]||(this._reg[e]=new Lt(t,s)),this._reg[e]}static clear(t){window.indexedDB.deleteDatabase(t);for(let s in this._reg)s.split("/")[0]===t&&delete this._reg[s]}};L(et,"_reg",Object.create(null));var Ut="https://ucarecdn.com",y=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:Ut},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var T="--uc-img-",M="unresolved";var k=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),X=3e3,B=5e3,F=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var st="blocks",rt="1.1.1";var nt=Object.create(null),it;for(let t in y)nt[T+t]=((it=y[t])==null?void 0:it.default)||"";var P=class extends U{constructor(){super(...arguments);w(this,"cssInit$",nt)}$$(e){return this.$[T+e]}set$$(e){for(let r in e)this.$[T+r]=e[r]}sub$$(e,r){this.sub(T+e,i=>{i===null||i===""||r(i)})}analyticsParams(){return`-/@clib/${st}/${rt}/uc-img/`}initAttributes(e){[...this.attributes].forEach(r=>{y[r.name]||e.setAttribute(r.name,r.value)})}initIntersection(e,r){let i={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(n=>{n.forEach(o=>{o.isIntersecting&&(r(),this._isnObserver.unobserve(e))})},i),this._isnObserver.observe(e),this._observed||(this._observed=new Set),this._observed.add(e)}destroyCallback(){super.destroyCallback(),this._isnObserver&&(this._observed.forEach(e=>{this._isnObserver.unobserve(e)}),this._isnObserver=null),c.deleteCtx(this)}static get observedAttributes(){return Object.keys(y)}attributeChangedCallback(e,r,i){window.setTimeout(()=>{this.$[T+e]=i})}};var O=class extends P{constructor(){super(...arguments);w(this,"_img",new Image);w(this,"_imgPreview",new Image)}_fmtAbs(e){return!e.includes("//")&&!k&&(e=new URL(e,document.baseURI).href),e}_validateSize(e){if((e==null?void 0:e.trim())!==""){let r=e.match(/\d+/)[0],i=e.match(/[a-zA-Z]+/)[0],n=parseInt(r,10);if(Number(n)>B&&this.hasFormatJPG)return B+i;if(Number(n)>X&&!this.hasFormatJPG)return X+i}return e}_getCdnModifiers(e,r){let i={format:this.$$("format"),quality:this.$$("quality"),resize:this._validateSize(e),blur:r,"cdn-operations":this.$$("cdn-operations"),analytics:this.analyticsParams()};return W(...G(i))}_getUrlBase(e="",r=""){if(this.$$("src").startsWith("data:")||this.$$("src").startsWith("blob:"))return this.$$("src");if(k&&this.$$("src")&&!this.$$("src").includes("//"))return this._proxyUrl(this.$$("src"));let i=this._getCdnModifiers(e,r);if(this.$$("src").startsWith(this.$$("cdn-cname")))return m(this.$$("src"),i);if(this.$$("cdn-cname")&&this.$$("uuid"))return this._proxyUrl(m(D(this.$$("cdn-cname"),this.$$("uuid")),i));if(this.$$("uuid"))return this._proxyUrl(m(D(this.$$("cdn-cname"),this.$$("uuid")),i));if(this.$$("proxy-cname"))return this._proxyUrl(m(this.$$("proxy-cname"),i,this._fmtAbs(this.$$("src"))));if(this.$$("pubkey"))return this._proxyUrl(m(`https://${this.$$("pubkey")}.ucr.io/`,i,this._fmtAbs(this.$$("src"))))}_proxyUrl(e){return this.$$("secure-delivery-proxy")?j(this.$$("secure-delivery-proxy"),{previewUrl:e},{transform:i=>window.encodeURIComponent(i)}):e}_getElSize(e,r=1,i=!0){let n=e.getBoundingClientRect(),o=r*Math.round(n.width),l=i?"":r*Math.round(n.height);return o||l?`${o||""}x${l||""}`:null}_setupEventProxy(e){let r=n=>{n.stopPropagation();let o=new Event(n.type,n);this.dispatchEvent(o)},i=["load","error"];for(let n of i)e.addEventListener(n,r)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:F.PREVIEW,img:this._imgPreview}:{type:F.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){if(this.$$("breakpoints")){let e=q(this.$$("breakpoints"));return V(e.map(r=>parseInt(r,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(e){let r=new Set;r.add(`url("${this._getUrlBase(this._getElSize(e))}") 1x`),this.$$("hi-res-support")&&r.add(`url("${this._getUrlBase(this._getElSize(e,2))}") ${2}x`),this.$$("ultra-res-support")&&r.add(`url("${this._getUrlBase(this._getElSize(e,3))}") ${3}x`);let i=`image-set(${[...r].join(", ")})`;e.style.setProperty("background-image",i),e.style.setProperty("background-image","-webkit-"+i)}getSrcset(){let e=new Set;return this.breakpoints?this.breakpoints.forEach(r=>{e.add(this._getUrlBase(r+"x")+` ${this._validateSize(r+"w")}`),this.$$("hi-res-support")&&e.add(this._getUrlBase(r*2+"x")+` ${this._validateSize(r*2+"w")}`),this.$$("ultra-res-support")&&e.add(this._getUrlBase(r*3+"x")+` ${this._validateSize(r*3+"w")}`)}):(e.add(this._getUrlBase(this._getElSize(this.currentImg.img))+" 1x"),this.$$("hi-res-support")&&e.add(this._getUrlBase(this._getElSize(this.currentImg.img,2))+" 2x"),this.$$("ultra-res-support")&&e.add(this._getUrlBase(this._getElSize(this.currentImg.img,3))+" 3x")),[...e].join()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){[...document.querySelectorAll(this.bgSelector)].forEach(e=>{this.$$("intersection")?this.initIntersection(e,()=>{this.renderBg(e)}):this.renderBg(e)})}_appendURL({elNode:e,src:r,srcset:i}){r&&(e.src=r),i&&(e.srcset=i)}_setupConfigForImage({elNode:e}){this._setupEventProxy(e),this.initAttributes(e)}loaderImage({src:e,srcset:r,elNode:i}){return new Promise((n,o)=>{this._setupConfigForImage({elNode:i}),i.setAttribute(M,""),i.addEventListener("load",()=>{i.removeAttribute(M),n(i)}),i.addEventListener("error",()=>{o(!1)}),this._appendURL({elNode:i,src:e,srcset:r})})}async renderImage(){var e,r;if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{var i;this.hasPreviewImage&&(this._imgPreview.src=this.srcUrlPreview);try{await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await((i=this._imgPreview)==null?void 0:i.remove()),this.appendChild(this._img)}});return}try{this.hasPreviewImage&&(await this.loaderImage({src:this.srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await((e=this._imgPreview)==null?void 0:e.remove()),this.appendChild(this._img)}catch{this.hasPreviewImage&&await((r=this._imgPreview)==null?void 0:r.remove()),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var I=class extends O{initCallback(){super.initCallback(),this.sub$$("src",()=>{this.init()}),this.sub$$("uuid",()=>{this.init()}),this.sub$$("lazy",s=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=s?"lazy":"eager")})}};I.reg("uc-img");export{I as Img};
|
|
26
|
+
var Ft=Object.defineProperty;var Ht=(r,i,t)=>i in r?Ft(r,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[i]=t;var E=(r,i,t)=>(Ht(r,typeof i!="symbol"?i+"":i,t),t),ut=(r,i,t)=>{if(!i.has(r))throw TypeError("Cannot "+t)};var h=(r,i,t)=>(ut(r,i,"read from private field"),t?t.call(r):i.get(r)),u=(r,i,t)=>{if(i.has(r))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(r):i.set(r,t)},p=(r,i,t,e)=>(ut(r,i,"write to private field"),e?e.call(r,t):i.set(r,t),t);var f=(r,i,t)=>(ut(r,i,"access private method"),t);var zt=r=>r,Vt="{{",Gt="}}";function At(r,i,t={}){var a;let{openToken:e=Vt,closeToken:s=Gt,transform:o=zt}=t;for(let l in i){let c=(a=i[l])==null?void 0:a.toString();r=r.replaceAll(e+l+s,typeof c=="string"?o(c):c)}return r}var qt=r=>{if(typeof r!="string"||!r)return"";let i=r.trim();return i.startsWith("-/")?i=i.slice(2):i.startsWith("/")&&(i=i.slice(1)),i.endsWith("/")&&(i=i.slice(0,i.length-1)),i},Yt=(...r)=>r.filter(i=>typeof i=="string"&&i).map(i=>qt(i)).join("/-/"),Ct=(...r)=>{let i=Yt(...r);return i?`-/${i}/`:""};function Pt(r){let i=new URL(r),t=i.pathname+i.search+i.hash,e=t.lastIndexOf("http"),s=t.lastIndexOf("/"),o="";return e>=0?o=t.slice(e):s>=0&&(o=t.slice(s+1)),o}function Jt(r){let i=new URL(r),t=Pt(r),e=xt(t)?wt(t).pathname:t;return i.pathname=i.pathname.replace(e,""),i.search="",i.hash="",i.toString()}function xt(r){return r.startsWith("http")}function wt(r){let i=new URL(r);return{pathname:i.origin+i.pathname||"",search:i.search||"",hash:i.hash||""}}var M=(r,i,t)=>{let e=new URL(Jt(r));if(t=t||Pt(r),e.pathname.startsWith("//")&&(e.pathname=e.pathname.replace("//","/")),xt(t)){let s=wt(t);e.pathname=e.pathname+(i||"")+(s.pathname||""),e.search=s.search,e.hash=s.hash}else e.pathname=e.pathname+(i||"")+(t||"");return e.toString()},ct=(r,i)=>{let t=new URL(r);return t.pathname=i+"/",t.toString()};var $t=(r,i=",")=>r.trim().split(i).map(t=>t.trim()).filter(t=>t.length>0);var Ot=r=>[...new Set(r)];var Rt=r=>Object.entries(r).filter(([,i])=>i!==void 0&&i!=="").map(([i,t])=>i==="cdn-operations"||i==="analytics"?t:`${i}/${t}`);var n=Object.freeze({BIND_ATTR:"bind",ATTR_BIND_PX:"@",SHARED_CTX_PX:"*",PARENT_CTX_PX:"^",NAMED_CTX_SPLTR:"/",COMPUTED_PX:"+",CSS_DATA_PX:"--",CTX_NAME_ATTR:"ctx",CTX_OWNER_ATTR:"ctx-owner",CSS_CTX_PROP:"--ctx",EL_REF_ATTR:"ref",AUTO_TAG_PX:"sym",LIST_ATTR:"itemize",LIST_ITEM_TAG_ATTR:"item-tag",SET_LATER_KEY:"__toSetLater__",USE_TPL_ATTR:"use-template",DEFAULT_SLOT_KEY:"__default__",TEXT_NODE_SKIP_ATTR:"skip-text-nodes",TEXT_NODE_OPEN_TOKEN:"{{",TEXT_NODE_CLOSE_TOKEN:"}}"});function Qt(r){let i=t=>{var e;for(let s in t)((e=t[s])==null?void 0:e.constructor)===Object&&(t[s]=i(t[s]));return{...t}};return i(r)}var k,j,w,$,U,tt,It,T=class T{constructor(i){u(this,k,void 0);u(this,j,void 0);u(this,w,void 0);i.constructor===Object?this.store=Qt(i):(p(this,w,!0),this.store=i),this.callbackMap=Object.create(null)}read(i){var t,e;if(!h(this,w)&&!this.store.hasOwnProperty(i))return f(t=T,$,U).call(t,"read",i),null;if(typeof i=="string"&&i.startsWith(n.COMPUTED_PX)){let s=this.store[i];if((s==null?void 0:s.constructor)!==Function){f(e=T,$,U).call(e,"compute",i);return}this.__computedMap||(this.__computedMap={});let o=s();return Object.keys(this.__computedMap).includes(i)||(this.__computedMap[i]=o,this.notify(i)),o}else return this.store[i]}has(i){return h(this,w)?this.store[i]!==void 0:this.store.hasOwnProperty(i)}add(i,t,e=!1){!e&&Object.keys(this.store).includes(i)||(this.store[i]=t,this.notify(i))}pub(i,t){var e,s;if(!h(this,w)&&!this.store.hasOwnProperty(i)){f(e=T,$,U).call(e,"publish",i);return}if(i!=null&&i.startsWith(n.COMPUTED_PX)&&t.constructor!==Function){f(s=T,$,U).call(s,"publish computed",i);return}!(this.store[i]===null||t===null)&&typeof this.store[i]!=typeof t&&console.warn(`Symbiote PubSub: type warning for "${i}" [${typeof this.store[i]} -> ${typeof t}]`),this.store[i]=t,this.notify(i)}get proxy(){if(!h(this,j)){let i=Object.create(null);p(this,j,new Proxy(i,{set:(t,e,s)=>(this.pub(e,s),!0),get:(t,e)=>{this.read(e)}}))}return h(this,j)}multiPub(i){for(let t in i)this.pub(t,i[t])}notify(i){var e;let t=i==null?void 0:i.startsWith(n.COMPUTED_PX);if(this.callbackMap[i]){let s=this.read(i);this.callbackMap[i].forEach(o=>{o(s)}),t&&(this.__computedMap[i]=s)}!t&&f(e=T,tt,It).call(e,this,i)}sub(i,t,e=!0){var s;return!h(this,w)&&!this.store.hasOwnProperty(i)?(f(s=T,$,U).call(s,"subscribe",i),null):(this.callbackMap[i]||(this.callbackMap[i]=new Set),this.callbackMap[i].add(t),e&&t(this.read(i)),{remove:()=>{this.callbackMap[i].delete(t),this.callbackMap[i].size||delete this.callbackMap[i]},callback:t})}set uid(i){!h(this,k)&&p(this,k,i)}get uid(){return h(this,k)}static registerCtx(i,t=Symbol()){let e=T.globalStore.get(t);return e?console.warn('PubSub: context UID "'+t+'" is already in use'):(e=new T(i),e.uid=t,T.globalStore.set(t,e)),e}static deleteCtx(i){T.globalStore.delete(i)}static getCtx(i,t=!0){return T.globalStore.get(i)||(t&&console.warn('PubSub: wrong context UID - "'+i+'"'),null)}};k=new WeakMap,j=new WeakMap,w=new WeakMap,$=new WeakSet,U=function(i,t){console.warn(`Symbiote PubSub: cannot ${i}. Prop name: `+t)},tt=new WeakSet,It=function(i,t){this.globalStore.forEach(e=>{e.__computedMap&&Object.keys(e.__computedMap).forEach(s=>{if(e===i&&t===s)return;let o=`__${s}_timeout`;e[o]&&window.clearTimeout(e[o]),e[o]=window.setTimeout(()=>{let a=e.read(s);a!==e.__computedMap[s]&&(e.__computedMap[s]=a,e.notify(s))})})})},u(T,$),u(T,tt);var v=T;v.globalStore=new Map;var C=v;var vt="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm",Zt=vt.length-1,F=class{static generate(i="XXXXXXXXX-XXX"){let t="";for(let e=0;e<i.length;e++)t+=i[e]==="-"?i[e]:vt.charAt(Math.random()*Zt);return t}};function H(r,i,t){let e=!0,s,o=i.split(".");return o.forEach((a,l)=>{l<o.length-1?r=r[a]:s=a}),r?r[s]=t:e=!1,e}function ft(r){let i;return r.constructor===CSSStyleSheet?i=r:r.constructor===String&&(i=new CSSStyleSheet,i.replaceSync(r)),i}function Dt(r,i){[...r.querySelectorAll(`[${n.LIST_ATTR}]`)].filter(t=>!t.matches(`[${n.LIST_ATTR}] [${n.LIST_ATTR}]`)).forEach(t=>{var a;let e=t.getAttribute(n.LIST_ITEM_TAG_ATTR),s;for(e&&(s=window.customElements.get(e)),s||(s=class extends i.Symbiote{constructor(){super(),e||(this.style.display="contents")}},s.template=((a=t.querySelector("template"))==null?void 0:a.innerHTML)||t.innerHTML,s.reg(e));t.firstChild;)t.firstChild.remove();let o=t.getAttribute(n.LIST_ATTR);i.sub(o,l=>{if(!l){for(;t.firstChild;)t.firstChild.remove();return}let c=[...t.children],I,d=b=>{b.forEach((A,Z)=>{if(c[Z])if(c[Z].set$)c[Z].set$(A);else for(let x in A)c[Z][x]=A[x];else{I||(I=new DocumentFragment);let x=new s;Object.assign((x==null?void 0:x.init$)||x,A),I.appendChild(x)}}),I&&t.appendChild(I);let _=c.slice(b.length,c.length);for(let A of _)A.remove()};if(l.constructor===Array)d(l);else if(l.constructor===Object){let b=[];for(let _ in l){let A=l[_];Object.defineProperty(A,"_KEY_",{value:_,enumerable:!0}),b.push(A)}d(b)}else console.warn("Symbiote list data type error:"),console.log(l)}),t.removeAttribute(n.LIST_ATTR),t.removeAttribute(n.LIST_ITEM_TAG_ATTR)})}function te(r,i){[...r.querySelectorAll(`[${n.EL_REF_ATTR}]`)].forEach(t=>{let e=t.getAttribute(n.EL_REF_ATTR);i.ref[e]=t,t.removeAttribute(n.EL_REF_ATTR)})}function ee(r,i){[...r.querySelectorAll(`[${n.BIND_ATTR}]`)].forEach(t=>{t.getAttribute(n.BIND_ATTR).split(";").forEach(o=>{if(!o)return;let a=o.split(":").map(d=>d.trim()),l=a[0],c;l.indexOf(n.ATTR_BIND_PX)===0&&(c=!0,l=l.replace(n.ATTR_BIND_PX,""));let I=a[1].split(",").map(d=>d.trim());for(let d of I){let b;d.startsWith("!!")?(b="double",d=d.replace("!!","")):d.startsWith("!")&&(b="single",d=d.replace("!","")),!i.has(d)&&i.allowTemplateInits&&(d.startsWith(n.ATTR_BIND_PX)?i.add(d,i.getAttribute(d.replace(n.ATTR_BIND_PX,""))):i.add(d,null)),i.sub(d,_=>{b==="double"?_=!!_:b==="single"&&(_=!_),c?(_==null?void 0:_.constructor)===Boolean?_?t.setAttribute(l,""):t.removeAttribute(l):t.setAttribute(l,_):H(t,l,_)||(t[n.SET_LATER_KEY]||(t[n.SET_LATER_KEY]=Object.create(null)),t[n.SET_LATER_KEY][l]=_)},!(i.ssrMode&&(l==="textContent"||c)))}}),t.removeAttribute(n.BIND_ATTR)})}function ie(r){let i,t=[],e=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:s=>{var o;return!((o=s.parentElement)!=null&&o.hasAttribute(n.TEXT_NODE_SKIP_ATTR))&&s.textContent.includes(n.TEXT_NODE_OPEN_TOKEN)&&s.textContent.includes(n.TEXT_NODE_CLOSE_TOKEN)&&1}});for(;i=e.nextNode();)t.push(i);return t}var se=function(r,i){ie(r).forEach(e=>{let s=[],o;for(;e.textContent.includes(n.TEXT_NODE_CLOSE_TOKEN);)e.textContent.startsWith(n.TEXT_NODE_OPEN_TOKEN)?(o=e.textContent.indexOf(n.TEXT_NODE_CLOSE_TOKEN)+n.TEXT_NODE_CLOSE_TOKEN.length,e.splitText(o),s.push(e)):(o=e.textContent.indexOf(n.TEXT_NODE_OPEN_TOKEN),e.splitText(o)),e=e.nextSibling;s.forEach(a=>{let l=a.textContent.replace(n.TEXT_NODE_OPEN_TOKEN,"").replace(n.TEXT_NODE_CLOSE_TOKEN,"");a.textContent="",!i.has(l)&&i.allowTemplateInits&&(l.startsWith(n.ATTR_BIND_PX)?(i.add(l,i.getAttribute(l.replace(n.ATTR_BIND_PX,""))),i.initAttributeObserver()):i.add(l,null)),i.sub(l,c=>{a.textContent=c})})})},Nt=[Dt,te,ee,se];var et="'",B='"',re=/\\([0-9a-fA-F]{1,6} ?)/g;function oe(r){return(r[0]===B||r[0]===et)&&(r[r.length-1]===B||r[r.length-1]===et)}function ne(r){return(r[0]===B||r[0]===et)&&(r=r.slice(1)),(r[r.length-1]===B||r[r.length-1]===et)&&(r=r.slice(0,-1)),r}function ae(r){let i="",t="";for(var e=0;e<r.length;e++){let s=r[e+1];r[e]==="\\"&&s==='"'?(i+='\\"',e++):r[e]==='"'&&t!=="\\"?i+='\\"':i+=r[e],t=r[e]}return i}function Xt(r){let i=r;oe(r)&&(i=ne(i),i=i.replace(re,(t,e)=>String.fromCodePoint(parseInt(e.trim(),16))),i=i.replaceAll(`\\
|
|
27
|
+
`,"\\n"),i=ae(i),i=B+i+B);try{return JSON.parse(i)}catch{throw new Error(`Failed to parse CSS property value: ${i}. Original input: ${r}`)}}var ve=[n.LIST_ATTR,n.LIST_ITEM_TAG_ATTR,n.EL_REF_ATTR,n.USE_TPL_ATTR,n.CTX_NAME_ATTR,n.CTX_OWNER_ATTR];function S(r,...i){let t="",e=new CSSStyleSheet;return r.forEach((s,o)=>{t+=s+i[o]}),S.processors.forEach(s=>{t=s(t)}),S.clearProcessors(),e.replaceSync(t),e}S.processors=[];S.clearProcessors=function(){S.processors=[]};S.useProcessor=function(...r){return S.processors=[...S.processors,...r],S};var Lt=0,z,N,V,O,W,G,R,y,X,L,m,q,pt,P,D,it,Mt,st,Ut,Y,mt,rt,kt,J,_t,g=class g extends HTMLElement{constructor(){super();u(this,q);u(this,it);u(this,st);u(this,Y);u(this,rt);u(this,J);u(this,z,void 0);u(this,N,void 0);u(this,V,void 0);u(this,O,void 0);u(this,W,void 0);u(this,G,void 0);u(this,R,void 0);u(this,y,void 0);u(this,X,void 0);u(this,L,void 0);u(this,m,this.constructor);E(this,"updateCssData",()=>{var t;this.dropCssDataCache(),(t=h(this,L))==null||t.forEach(e=>{let s=this.getCssData(f(this,J,_t).call(this,e),!0);s!==null&&this.$[e]!==s&&(this.$[e]=s)})});this.init$=Object.create(null),this.cssInit$=Object.create(null),this.tplProcessors=new Set,this.ref=Object.create(null),this.allSubs=new Set,this.pauseRender=!1,this.renderShadow=!1,this.readyToDestroy=!0,this.processInnerHtml=!1,this.ssrMode=!1,this.allowCustomTemplate=!1,this.ctxOwner=!1,this.isVirtual=!1,this.allowTemplateInits=!0}get Symbiote(){return g}initCallback(){}renderCallback(){}render(t,e=this.renderShadow){let s;if((e||h(this,m).shadowStyleSheets)&&!this.shadowRoot&&this.attachShadow({mode:"open"}),this.allowCustomTemplate){let a=this.getAttribute(n.USE_TPL_ATTR);if(a){let l=this.getRootNode(),c=(l==null?void 0:l.querySelector(a))||document.querySelector(a);c?t=c.content.cloneNode(!0):console.warn(`Symbiote template "${a}" is not found...`)}}if(this.processInnerHtml||this.ssrMode)for(let a of this.tplProcessors)a(this,this);if(t||h(this,m).template){if(h(this,m).template&&!h(this,m).__tpl&&(h(this,m).__tpl=document.createElement("template"),h(this,m).__tpl.innerHTML=h(this,m).template),(t==null?void 0:t.constructor)===DocumentFragment)s=t;else if((t==null?void 0:t.constructor)===String){let a=document.createElement("template");a.innerHTML=t,s=a.content.cloneNode(!0)}else h(this,m).__tpl&&(s=h(this,m).__tpl.content.cloneNode(!0));for(let a of this.tplProcessors)a(s,this)}let o=()=>{var a;s&&this.isVirtual?this.replaceWith(s):s&&(e&&this.shadowRoot.appendChild(s)||this.appendChild(s)),f(this,q,pt).call(this),(a=this.renderCallback)==null||a.call(this)};h(this,m).shadowStyleSheets&&(e=!0,this.shadowRoot.adoptedStyleSheets=[...h(this,m).shadowStyleSheets]),o()}addTemplateProcessor(t){this.tplProcessors.add(t)}get autoCtxName(){return h(this,N)||(p(this,N,F.generate()),this.style.setProperty(n.CSS_CTX_PROP,`'${h(this,N)}'`)),h(this,N)}get cssCtxName(){return this.getCssData(n.CSS_CTX_PROP,!0)}get ctxName(){var e;let t=((e=this.getAttribute(n.CTX_NAME_ATTR))==null?void 0:e.trim())||this.cssCtxName||h(this,V)||this.autoCtxName;return p(this,V,t),t}get localCtx(){return h(this,O)||p(this,O,C.registerCtx({})),h(this,O)}get sharedCtx(){return C.getCtx(this.ctxName,!1)||C.registerCtx({},this.ctxName)}sub(t,e,s=!0){var l;let o=c=>{h(this,Y,mt)||e(c)},a=f(l=g,P,D).call(l,t,this);a.ctx.has(a.name)?this.allSubs.add(a.ctx.sub(a.name,o,s)):window.setTimeout(()=>{this.allSubs.add(a.ctx.sub(a.name,o,s))})}notify(t){var s;let e=f(s=g,P,D).call(s,t,this);e.ctx.notify(e.name)}has(t){var s;let e=f(s=g,P,D).call(s,t,this);return e.ctx.has(e.name)}add(t,e,s=!1){var a;let o=f(a=g,P,D).call(a,t,this);o.ctx.add(o.name,e,s)}add$(t,e=!1){for(let s in t)this.add(s,t[s],e)}get $(){if(!h(this,W)){let t=Object.create(null);p(this,W,new Proxy(t,{set:(e,s,o)=>{var l;let a=f(l=g,P,D).call(l,s,this);return a.ctx.pub(a.name,o),!0},get:(e,s)=>{var a;let o=f(a=g,P,D).call(a,s,this);return o.ctx.read(o.name)}}))}return h(this,W)}set$(t,e=!1){for(let s in t){let o=t[s];e||![String,Number,Boolean].includes(o==null?void 0:o.constructor)?this.$[s]=o:this.$[s]!==o&&(this.$[s]=o)}}initAttributeObserver(){this.attributeMutationObserver||(this.attributeMutationObserver=new MutationObserver(t=>{for(let e of t)if(e.type==="attributes"){let s=n.ATTR_BIND_PX+e.attributeName;this.has(s)&&(this.$[s]=this.getAttribute(e.attributeName))}}),this.attributeMutationObserver.observe(this,{attributes:!0}))}connectedCallback(){f(this,rt,kt).call(this)}destroyCallback(){}disconnectedCallback(){this.connectedOnce&&(this.dropCssDataCache(),this.readyToDestroy&&(h(this,R)&&window.clearTimeout(h(this,R)),p(this,R,window.setTimeout(()=>{this.destroyCallback(),this.attributeMutationObserver&&this.attributeMutationObserver.disconnect();for(let t of this.allSubs)t.remove(),this.allSubs.delete(t);h(this,O)&&C.deleteCtx(h(this,O).uid);for(let t of this.tplProcessors)this.tplProcessors.delete(t)},100))))}static reg(t,e=!1){t||(Lt++,t=`${n.AUTO_TAG_PX}-${Lt}`),this.__tag=t;let s=window.customElements.get(t);if(s){!e&&s!==this&&console.warn([`Element with tag name "${t}" already registered.`,`You're trying to override it with another class "${this.name}".`,"This is most likely a mistake.","New element will not be registered."].join(`
|
|
28
|
+
`));return}window.customElements.define(t,e?class extends this{}:this)}static get is(){return this.__tag||this.reg(),this.__tag}static bindAttributes(t){this.observedAttributes=[...new Set((this.observedAttributes||[]).concat(Object.keys(t)))],this.__attrDesc=t}attributeChangedCallback(t,e,s){var a;if(e===s)return;let o=(a=h(this,m).__attrDesc)==null?void 0:a[t];o?h(this,G)?this.$[o]=s:this.init$[o]=s:this[t]=s}getCssData(t,e=!1){if(h(this,y)||p(this,y,Object.create(null)),!Object.keys(h(this,y)).includes(t)){h(this,X)||p(this,X,window.getComputedStyle(this));let s=h(this,X).getPropertyValue(t).trim();try{h(this,y)[t]=Xt(s)}catch{!e&&console.warn(`CSS Data error: ${t}`),h(this,y)[t]=null}}return h(this,y)[t]}bindCssData(t,e=""){h(this,L)||p(this,L,new Set),h(this,L).add(t);let s=this.getCssData(f(this,J,_t).call(this,t),!0);s===null&&(s=e),t.startsWith(n.CSS_DATA_PX)?this.localCtx.add(t,s):this.add(t,s)}dropCssDataCache(){p(this,y,null),p(this,X,null)}defineAccessor(t,e,s){let o="#"+t;this[o]=this[t],Object.defineProperty(this,t,{set:a=>{this[o]=a,s?window.setTimeout(()=>{e==null||e(a)}):e==null||e(a)},get:()=>this[o]}),this[t]=this[o]}static addRootStyles(t){this.rootStyleSheets||(this.rootStyleSheets=[]),this.rootStyleSheets.push(ft(t))}static addShadowStyles(t){this.shadowStyleSheets||(this.shadowStyleSheets=[]),this.shadowStyleSheets.push(ft(t))}static set rootStyles(t){this.rootStyleSheets=[],this.addRootStyles(t)}static set shadowStyles(t){this.shadowStyleSheets=[],this.addShadowStyles(t)}};z=new WeakMap,N=new WeakMap,V=new WeakMap,O=new WeakMap,W=new WeakMap,G=new WeakMap,R=new WeakMap,y=new WeakMap,X=new WeakMap,L=new WeakMap,m=new WeakMap,q=new WeakSet,pt=function(){var t;h(this,z)||(p(this,z,!0),(t=this.initCallback)==null||t.call(this))},P=new WeakSet,D=function(t,e){var a;let s,o;if(t.startsWith(n.SHARED_CTX_PX))s=e.sharedCtx,o=t.replace(n.SHARED_CTX_PX,"");else if(t.startsWith(n.PARENT_CTX_PX)){o=t.replace(n.PARENT_CTX_PX,"");let l=e;for(;l&&!((a=l==null?void 0:l.has)!=null&&a.call(l,o));)l=l.parentElement||l.parentNode||l.host;s=(l==null?void 0:l.localCtx)||e.localCtx}else if(t.includes(n.NAMED_CTX_SPLTR)){let l=t.split(n.NAMED_CTX_SPLTR);s=C.getCtx(l[0]),o=l[1]}else t.startsWith(n.CSS_DATA_PX)?(s=e.localCtx,o=t,s.has(o)||e.bindCssData(o)):(s=e.localCtx,o=t);return{ctx:s,name:o}},it=new WeakSet,Mt=function(){return this.ctxOwner||this.hasAttribute(n.CTX_OWNER_ATTR)&&this.getAttribute(n.CTX_OWNER_ATTR)!=="false"},st=new WeakSet,Ut=function(){let t=h(this,m).__attrDesc;if(t)for(let e of Object.values(t))Object.keys(this.init$).includes(e)||(this.init$[e]="");for(let e in this.init$)if(e.startsWith(n.SHARED_CTX_PX))this.sharedCtx.add(e.replace(n.SHARED_CTX_PX,""),this.init$[e],h(this,it,Mt));else if(e.startsWith(n.ATTR_BIND_PX))this.localCtx.add(e,this.getAttribute(e.replace(n.ATTR_BIND_PX,""))||this.init$[e]),this.initAttributeObserver();else if(e.includes(n.NAMED_CTX_SPLTR)){let s=e.split(n.NAMED_CTX_SPLTR),o=s[0].trim(),a=s[1].trim();if(o&&a){let l=C.getCtx(o,!1);l||(l=C.registerCtx({},o)),l.add(a,this.init$[e])}}else this.localCtx.add(e,this.init$[e]);for(let e in this.cssInit$)this.bindCssData(e,this.cssInit$[e]);p(this,G,!0)},Y=new WeakSet,mt=function(){return!this.isVirtual&&!this.isConnected},rt=new WeakSet,kt=function(){var t;if(!h(this,Y,mt)){if(h(this,R)&&window.clearTimeout(h(this,R)),!this.connectedOnce){let e=(t=this.getAttribute(n.CTX_NAME_ATTR))==null?void 0:t.trim();if(e&&this.style.setProperty(n.CSS_CTX_PROP,`'${e}'`),f(this,st,Ut).call(this),this[n.SET_LATER_KEY]){for(let s in this[n.SET_LATER_KEY])H(this,s,this[n.SET_LATER_KEY][s]);delete this[n.SET_LATER_KEY]}this.initChildren=[...this.childNodes];for(let s of Nt)this.addTemplateProcessor(s);if(this.pauseRender)f(this,q,pt).call(this);else{if(h(this,m).rootStyleSheets){let s=this.getRootNode();if(!s)return;let o=new Set([...s.adoptedStyleSheets,...h(this,m).rootStyleSheets]);s.adoptedStyleSheets=[...o]}this.render()}}this.connectedOnce=!0}},J=new WeakSet,_t=function(t){return t.split("--").map((e,s)=>s===0?"":e).join("--")},u(g,P),E(g,"__tpl"),E(g,"template");var dt=g,Tt=dt;var he="https://ucarecdn.com",Q=Object.freeze({"dev-mode":{},pubkey:{},uuid:{},src:{},lazy:{default:1},intersection:{},breakpoints:{},"cdn-cname":{default:he},"proxy-cname":{},"secure-delivery-proxy":{},"hi-res-support":{default:1},"ultra-res-support":{},format:{},"cdn-operations":{},progressive:{},quality:{},"is-background-for":{},"is-preview-blur":{default:1}});var K="--uc-img-",gt="unresolved";var St=!window.location.host.trim()||window.location.host.includes(":")||window.location.hostname.includes("localhost"),bt=3e3,Et=5e3,yt=Object.freeze({PREVIEW:"PREVIEW",MAIN:"MAIN"});var jt="blocks",Bt="1.2.0";var Kt=Object.create(null),Wt;for(let r in Q)Kt[K+r]=((Wt=Q[r])==null?void 0:Wt.default)||"";var ot=class extends Tt{constructor(){super(...arguments);E(this,"cssInit$",Kt)}$$(t){return this.$[K+t]}set$$(t){for(let e in t)this.$[K+e]=t[e]}sub$$(t,e){this.sub(K+t,s=>{s===null||s===""||e(s)})}analyticsParams(){return`-/@clib/${jt}/${Bt}/uc-img/`}initAttributes(t){[...this.attributes].forEach(e=>{Q[e.name]||t.setAttribute(e.name,e.value)})}initIntersection(t,e){let s={root:null,rootMargin:"0px"};this._isnObserver=new IntersectionObserver(o=>{o.forEach(a=>{a.isIntersecting&&(e(),this._isnObserver.unobserve(t))})},s),this._isnObserver.observe(t),this._observed||(this._observed=new Set),this._observed.add(t)}destroyCallback(){super.destroyCallback(),this._isnObserver&&(this._observed.forEach(t=>{this._isnObserver.unobserve(t)}),this._isnObserver=null),v.deleteCtx(this)}static get observedAttributes(){return Object.keys(Q)}attributeChangedCallback(t,e,s){window.setTimeout(()=>{this.$[K+t]=s})}};var lt=class extends ot{constructor(){super(...arguments);E(this,"_img",new Image);E(this,"_imgPreview",new Image)}_fmtAbs(t){return!t.includes("//")&&!St&&(t=new URL(t,document.baseURI).href),t}_validateSize(t){if((t==null?void 0:t.trim())!==""){let e=t.match(/\d+/)[0],s=t.match(/[a-zA-Z]+/)[0],o=parseInt(e,10);if(Number(o)>Et&&this.hasFormatJPG)return Et+s;if(Number(o)>bt&&!this.hasFormatJPG)return bt+s}return t}_getCdnModifiers(t,e){let s={format:this.$$("format"),quality:this.$$("quality"),resize:this._validateSize(t),blur:e,"cdn-operations":this.$$("cdn-operations"),analytics:this.analyticsParams()};return Ct(...Rt(s))}_getUrlBase(t="",e=""){if(this.$$("src").startsWith("data:")||this.$$("src").startsWith("blob:"))return this.$$("src");if(St&&this.$$("src")&&!this.$$("src").includes("//"))return this._proxyUrl(this.$$("src"));let s=this._getCdnModifiers(t,e);if(this.$$("src").startsWith(this.$$("cdn-cname")))return M(this.$$("src"),s);if(this.$$("cdn-cname")&&this.$$("uuid"))return this._proxyUrl(M(ct(this.$$("cdn-cname"),this.$$("uuid")),s));if(this.$$("uuid"))return this._proxyUrl(M(ct(this.$$("cdn-cname"),this.$$("uuid")),s));if(this.$$("proxy-cname"))return this._proxyUrl(M(this.$$("proxy-cname"),s,this._fmtAbs(this.$$("src"))));if(this.$$("pubkey"))return this._proxyUrl(M(`https://${this.$$("pubkey")}.ucr.io/`,s,this._fmtAbs(this.$$("src"))))}_proxyUrl(t){return this.$$("secure-delivery-proxy")?At(this.$$("secure-delivery-proxy"),{previewUrl:t},{transform:s=>window.encodeURIComponent(s)}):t}_getElSize(t,e=1,s=!0){let o=t.getBoundingClientRect(),a=e*Math.round(o.width),l=s?"":e*Math.round(o.height);return a||l?`${a||""}x${l||""}`:null}_setupEventProxy(t){let e=o=>{o.stopPropagation();let a=new Event(o.type,o);this.dispatchEvent(a)},s=["load","error"];for(let o of s)t.addEventListener(o,e)}get img(){return this.hasPreviewImage||(this._setupConfigForImage({elNode:this._img}),this.appendChild(this._img)),this._img}get currentImg(){return this.hasPreviewImage?{type:yt.PREVIEW,img:this._imgPreview}:{type:yt.MAIN,img:this.img}}get hasPreviewImage(){return this.$$("is-preview-blur")}get bgSelector(){return this.$$("is-background-for")}get breakpoints(){if(this.$$("breakpoints")){let t=$t(this.$$("breakpoints"));return Ot(t.map(e=>parseInt(e,10)))}else return null}get hasFormatJPG(){return this.$$("format").toLowerCase()==="jpeg"}renderBg(t){let e=new Set;e.add(`url("${this._getUrlBase(this._getElSize(t))}") 1x`),this.$$("hi-res-support")&&e.add(`url("${this._getUrlBase(this._getElSize(t,2))}") ${2}x`),this.$$("ultra-res-support")&&e.add(`url("${this._getUrlBase(this._getElSize(t,3))}") ${3}x`);let s=`image-set(${[...e].join(", ")})`;t.style.setProperty("background-image",s),t.style.setProperty("background-image","-webkit-"+s)}getSrcset(){let t=new Set;return this.breakpoints?this.breakpoints.forEach(e=>{t.add(this._getUrlBase(e+"x")+` ${this._validateSize(e+"w")}`),this.$$("hi-res-support")&&t.add(this._getUrlBase(e*2+"x")+` ${this._validateSize(e*2+"w")}`),this.$$("ultra-res-support")&&t.add(this._getUrlBase(e*3+"x")+` ${this._validateSize(e*3+"w")}`)}):(t.add(this._getUrlBase(this._getElSize(this.currentImg.img))+" 1x"),this.$$("hi-res-support")&&t.add(this._getUrlBase(this._getElSize(this.currentImg.img,2))+" 2x"),this.$$("ultra-res-support")&&t.add(this._getUrlBase(this._getElSize(this.currentImg.img,3))+" 3x")),[...t].join()}getSrc(){return this._getUrlBase()}get srcUrlPreview(){return this._getUrlBase("100x","100")}renderBackground(){[...document.querySelectorAll(this.bgSelector)].forEach(t=>{this.$$("intersection")?this.initIntersection(t,()=>{this.renderBg(t)}):this.renderBg(t)})}_appendURL({elNode:t,src:e,srcset:s}){e&&(t.src=e),s&&(t.srcset=s)}_setupConfigForImage({elNode:t}){this._setupEventProxy(t),this.initAttributes(t)}loaderImage({src:t,srcset:e,elNode:s}){return new Promise((o,a)=>{this._setupConfigForImage({elNode:s}),s.setAttribute(gt,""),s.addEventListener("load",()=>{s.removeAttribute(gt),o(s)}),s.addEventListener("error",()=>{a(!1)}),this._appendURL({elNode:s,src:t,srcset:e})})}async renderImage(){var t,e;if(this.$$("intersection")){this.hasPreviewImage&&(this._setupConfigForImage({elNode:this._imgPreview}),this.appendChild(this._imgPreview)),this.initIntersection(this.currentImg.img,async()=>{var s;this.hasPreviewImage&&(this._imgPreview.src=this.srcUrlPreview);try{await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await this._imgPreview.remove(),this.appendChild(this._img)}catch{this.hasPreviewImage&&await((s=this._imgPreview)==null?void 0:s.remove()),this.appendChild(this._img)}});return}try{this.hasPreviewImage&&(await this.loaderImage({src:this.srcUrlPreview,elNode:this._imgPreview}),this.appendChild(this._imgPreview)),await this.loaderImage({src:this.getSrc(),srcset:this.getSrcset(),elNode:this._img}),this.hasPreviewImage&&await((t=this._imgPreview)==null?void 0:t.remove()),this.appendChild(this._img)}catch{this.hasPreviewImage&&await((e=this._imgPreview)==null?void 0:e.remove()),this.appendChild(this._img)}}init(){this.bgSelector?this.renderBackground():this.renderImage()}};var ht=class extends lt{initCallback(){super.initCallback(),this.sub$$("src",()=>{this.init()}),this.sub$$("uuid",()=>{this.init()}),this.sub$$("lazy",i=>{!this.$$("is-background-for")&&!this.$$("is-preview-blur")&&(this.img.loading=i?"lazy":"eager")})}};ht.reg("uc-img");export{ht as Img};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {String} url Blocks pack url
|
|
3
|
-
* @param {Boolean} [register] Register connected package, if it not registered yet
|
|
4
|
-
* @returns {Promise<import('../index.js')>}
|
|
5
|
-
*/
|
|
6
|
-
export function connectBlocksFrom(url: string, register?: boolean | undefined): Promise<typeof import("../index.js")>;
|
|
7
|
-
export const UC_WINDOW_KEY: "UC";
|
|
8
|
-
//# sourceMappingURL=connectBlocksFrom.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connectBlocksFrom.d.ts","sourceRoot":"","sources":["connectBlocksFrom.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,gFAFa,qCAA8B,CA0B1C;AA/BD,iCAAkC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registerBlocks.d.ts","sourceRoot":"","sources":["registerBlocks.js"],"names":[],"mappings":"AAAA,gDAAgD;AAChD;QADmB,MAAM,GAAE,GAAG;SAoB7B"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export class FocusVisible {
|
|
2
|
-
/**
|
|
3
|
-
* @param {boolean} focusVisible
|
|
4
|
-
* @param {HTMLElement} element
|
|
5
|
-
*/
|
|
6
|
-
static handleFocusVisible(focusVisible: boolean, element: HTMLElement): void;
|
|
7
|
-
/** @param {ShadowRoot | Document} scope */
|
|
8
|
-
static register(scope: ShadowRoot | Document): void;
|
|
9
|
-
/** @param {Document | ShadowRoot} scope */
|
|
10
|
-
static unregister(scope: Document | ShadowRoot): void;
|
|
11
|
-
}
|
|
12
|
-
export namespace FocusVisible {
|
|
13
|
-
let _destructors: WeakMap<WeakKey, any>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=FocusVisible.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FocusVisible.d.ts","sourceRoot":"","sources":["FocusVisible.js"],"names":[],"mappings":"AAEA;IACE;;;OAGG;IACH,wCAHW,OAAO,WACP,WAAW,QASrB;IAED,2CAA2C;IAC3C,uBADY,UAAU,GAAG,QAAQ,QAGhC;IAED,2CAA2C;IAC3C,yBADY,QAAQ,GAAG,UAAU,QAQhC;CACF"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { applyFocusVisiblePolyfill } from './applyFocusVisiblePolyfill.js';
|
|
2
|
-
|
|
3
|
-
export class FocusVisible {
|
|
4
|
-
/**
|
|
5
|
-
* @param {boolean} focusVisible
|
|
6
|
-
* @param {HTMLElement} element
|
|
7
|
-
*/
|
|
8
|
-
static handleFocusVisible(focusVisible, element) {
|
|
9
|
-
if (focusVisible) {
|
|
10
|
-
let customOutline = element.style.getPropertyValue('--focus-visible-outline');
|
|
11
|
-
element.style.outline = customOutline || '2px solid var(--color-focus-ring)';
|
|
12
|
-
} else {
|
|
13
|
-
element.style.outline = 'none';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** @param {ShadowRoot | Document} scope */
|
|
18
|
-
static register(scope) {
|
|
19
|
-
FocusVisible._destructors.set(scope, applyFocusVisiblePolyfill(scope, FocusVisible.handleFocusVisible));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** @param {Document | ShadowRoot} scope */
|
|
23
|
-
static unregister(scope) {
|
|
24
|
-
if (!FocusVisible._destructors.has(scope)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
let removeFocusVisiblePolyfill = FocusVisible._destructors.get(scope);
|
|
28
|
-
removeFocusVisiblePolyfill();
|
|
29
|
-
FocusVisible._destructors.delete(scope);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
FocusVisible._destructors = new WeakMap();
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Applies the :focus-visible polyfill at the given scope. A scope, in this case, is either the top-level Document or a
|
|
3
|
-
* Shadow Root.
|
|
4
|
-
*
|
|
5
|
-
* @param {Document | ShadowRoot} scope
|
|
6
|
-
* @param {(focusVisible: boolean, el: EventTarget) => void} [callback]
|
|
7
|
-
* @see https://github.com/WICG/focus-visible
|
|
8
|
-
*/
|
|
9
|
-
export function applyFocusVisiblePolyfill(scope: Document | ShadowRoot, callback?: ((focusVisible: boolean, el: EventTarget) => void) | undefined): () => void;
|
|
10
|
-
//# sourceMappingURL=applyFocusVisiblePolyfill.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"applyFocusVisiblePolyfill.d.ts","sourceRoot":"","sources":["applyFocusVisiblePolyfill.js"],"names":[],"mappings":"AAgDA;;;;;;;GAOG;AACH,iDAJW,QAAQ,GAAG,UAAU,6BACN,OAAO,MAAM,WAAW,KAAK,IAAI,2BA0M1D"}
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper function for legacy browsers and iframes which sometimes focus on elements like document, body, and
|
|
3
|
-
* non-interactive SVG.
|
|
4
|
-
*
|
|
5
|
-
* @param {EventTarget} el
|
|
6
|
-
*/
|
|
7
|
-
function isValidFocusTarget(el) {
|
|
8
|
-
if (
|
|
9
|
-
el &&
|
|
10
|
-
el !== document &&
|
|
11
|
-
/** @type {Element} */ (el).nodeName !== 'HTML' &&
|
|
12
|
-
/** @type {Element} */ (el).nodeName !== 'BODY' &&
|
|
13
|
-
'classList' in el &&
|
|
14
|
-
'contains' in /** @type {Element} */ (el).classList
|
|
15
|
-
) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Computes whether the given element should automatically trigger the `focus-visible` class being added, i.e., whether
|
|
23
|
-
* it should always match `:focus-visible` when focused.
|
|
24
|
-
*
|
|
25
|
-
* @param {EventTarget} el
|
|
26
|
-
* @returns {boolean}
|
|
27
|
-
*/
|
|
28
|
-
function focusTriggersKeyboardModality(el) {
|
|
29
|
-
let { tagName } = /** @type {Element} */ (el);
|
|
30
|
-
|
|
31
|
-
if (tagName === 'INPUT' && !(/** @type {HTMLInputElement} */ (el).readOnly)) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (tagName === 'TEXTAREA' && !(/** @type {HTMLTextAreaElement} */ (el).readOnly)) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (/** @type {HTMLElement} */ (el).isContentEditable) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
let hadKeyboardEvent = true;
|
|
47
|
-
let hadFocusVisibleRecently = false;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Applies the :focus-visible polyfill at the given scope. A scope, in this case, is either the top-level Document or a
|
|
51
|
-
* Shadow Root.
|
|
52
|
-
*
|
|
53
|
-
* @param {Document | ShadowRoot} scope
|
|
54
|
-
* @param {(focusVisible: boolean, el: EventTarget) => void} [callback]
|
|
55
|
-
* @see https://github.com/WICG/focus-visible
|
|
56
|
-
*/
|
|
57
|
-
export function applyFocusVisiblePolyfill(scope, callback) {
|
|
58
|
-
let hadFocusVisibleRecentlyTimeout = null;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Add the `focus-visible` class to the given element if the author did not add it.
|
|
62
|
-
*
|
|
63
|
-
* @param {EventTarget} el
|
|
64
|
-
*/
|
|
65
|
-
function addFocusVisibleClass(el) {
|
|
66
|
-
/** @type {Element} */ (el).setAttribute('focus-visible', '');
|
|
67
|
-
callback(true, el);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Remove the `focus-visible` class from the given element if the author did not originally add it.
|
|
72
|
-
*
|
|
73
|
-
* @param {EventTarget} el
|
|
74
|
-
*/
|
|
75
|
-
function removeFocusVisibleClass(el) {
|
|
76
|
-
if (!(/** @type {Element} */ (el).hasAttribute('focus-visible'))) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
/** @type {Element} */ (el).removeAttribute('focus-visible');
|
|
80
|
-
callback(false, el);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* If the most recent user interaction was via the keyboard, and the keypress did not include a meta, alt/option, or
|
|
85
|
-
* control key, then the keyboard's modality. Otherwise, the modality is not the keyboard.Apply `focus-visible` to any
|
|
86
|
-
* current active element and keep track of our keyboard modality state with `hadKeyboardEvent`.
|
|
87
|
-
*
|
|
88
|
-
* @param {KeyboardEvent} e
|
|
89
|
-
*/
|
|
90
|
-
function onKeyDown(e) {
|
|
91
|
-
if (e.metaKey || e.altKey || e.ctrlKey) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (isValidFocusTarget(scope.activeElement)) {
|
|
96
|
-
addFocusVisibleClass(scope.activeElement);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
hadKeyboardEvent = true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* If at any point a user clicks with a pointing device, ensure that we change the modality away from the keyboard.
|
|
104
|
-
* This avoids the situation where a user presses a key on an already focused element, and then clicks on a different
|
|
105
|
-
* element focusing it with a pointing device while we still think we're in keyboard modality.
|
|
106
|
-
*
|
|
107
|
-
* @param {Event} e
|
|
108
|
-
*/
|
|
109
|
-
function onPointerDown(e) {
|
|
110
|
-
hadKeyboardEvent = false;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* On `focus`, add the `focus-visible` class to the target if: - the target received focus as a result of keyboard
|
|
115
|
-
* navigation or - the event target is an element that will likely require interaction via the keyboard (e.g., a text
|
|
116
|
-
* box).
|
|
117
|
-
*
|
|
118
|
-
* @param {Event} e
|
|
119
|
-
*/
|
|
120
|
-
function onFocus(e) {
|
|
121
|
-
// Prevent IE from focusing the document or HTML element.
|
|
122
|
-
if (!isValidFocusTarget(e.target)) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (hadKeyboardEvent || focusTriggersKeyboardModality(e.target)) {
|
|
127
|
-
addFocusVisibleClass(e.target);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* On `blur`, remove the `focus-visible` class from the target.
|
|
133
|
-
*
|
|
134
|
-
* @param {Event} e
|
|
135
|
-
*/
|
|
136
|
-
function onBlur(e) {
|
|
137
|
-
if (!isValidFocusTarget(e.target)) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (/** @type {Element} */ (e.target).hasAttribute('focus-visible')) {
|
|
142
|
-
// To detect a tab/window switch, we look for a blur event followed
|
|
143
|
-
// rapidly by a visibility change.
|
|
144
|
-
// If we don't see a visibility change within 100ms, it's probably a
|
|
145
|
-
// regular focus change.
|
|
146
|
-
hadFocusVisibleRecently = true;
|
|
147
|
-
window.clearTimeout(hadFocusVisibleRecentlyTimeout);
|
|
148
|
-
hadFocusVisibleRecentlyTimeout = window.setTimeout(() => {
|
|
149
|
-
hadFocusVisibleRecently = false;
|
|
150
|
-
}, 100);
|
|
151
|
-
removeFocusVisibleClass(e.target);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Add a group of listeners to detect usage of any pointing devices. These listeners will be added when the polyfill
|
|
157
|
-
* first loads and anytime the window is blurred so that they are active when the window regains focus.
|
|
158
|
-
*/
|
|
159
|
-
function addInitialPointerMoveListeners() {
|
|
160
|
-
/* eslint-disable no-use-before-define */
|
|
161
|
-
document.addEventListener('mousemove', onInitialPointerMove);
|
|
162
|
-
document.addEventListener('mousedown', onInitialPointerMove);
|
|
163
|
-
document.addEventListener('mouseup', onInitialPointerMove);
|
|
164
|
-
document.addEventListener('pointermove', onInitialPointerMove);
|
|
165
|
-
document.addEventListener('pointerdown', onInitialPointerMove);
|
|
166
|
-
document.addEventListener('pointerup', onInitialPointerMove);
|
|
167
|
-
document.addEventListener('touchmove', onInitialPointerMove);
|
|
168
|
-
document.addEventListener('touchstart', onInitialPointerMove);
|
|
169
|
-
document.addEventListener('touchend', onInitialPointerMove);
|
|
170
|
-
/* eslint-enable no-use-before-define */
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function removeInitialPointerMoveListeners() {
|
|
174
|
-
/* eslint-disable no-use-before-define */
|
|
175
|
-
document.removeEventListener('mousemove', onInitialPointerMove);
|
|
176
|
-
document.removeEventListener('mousedown', onInitialPointerMove);
|
|
177
|
-
document.removeEventListener('mouseup', onInitialPointerMove);
|
|
178
|
-
document.removeEventListener('pointermove', onInitialPointerMove);
|
|
179
|
-
document.removeEventListener('pointerdown', onInitialPointerMove);
|
|
180
|
-
document.removeEventListener('pointerup', onInitialPointerMove);
|
|
181
|
-
document.removeEventListener('touchmove', onInitialPointerMove);
|
|
182
|
-
document.removeEventListener('touchstart', onInitialPointerMove);
|
|
183
|
-
document.removeEventListener('touchend', onInitialPointerMove);
|
|
184
|
-
/* eslint-enable no-use-before-define */
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* If the user changes tabs, keep track of whether or not the previously focused element had .focus-visible.
|
|
189
|
-
*
|
|
190
|
-
* @param {Event} e
|
|
191
|
-
*/
|
|
192
|
-
function onVisibilityChange(e) {
|
|
193
|
-
if (document.visibilityState === 'hidden') {
|
|
194
|
-
// If the tab becomes active again, the browser will handle calling focus
|
|
195
|
-
// on the element (Safari actually calls it twice).
|
|
196
|
-
// If this tab change caused a blur on an element with focus-visible,
|
|
197
|
-
// re-apply the class when the user switches back to the tab.
|
|
198
|
-
if (hadFocusVisibleRecently) {
|
|
199
|
-
hadKeyboardEvent = true;
|
|
200
|
-
}
|
|
201
|
-
addInitialPointerMoveListeners();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* When the polyfill first loads, assume the user is in keyboard modality. If any event is received from a pointing
|
|
207
|
-
* device (e.g., mouse, pointer, touch), turn off keyboard modality. This accounts for situations where focus enters
|
|
208
|
-
* the page from the URL bar.
|
|
209
|
-
*
|
|
210
|
-
* @param {Event} e
|
|
211
|
-
*/
|
|
212
|
-
function onInitialPointerMove(e) {
|
|
213
|
-
// Work around a Safari quirk that fires a mousemove on <html> whenever the
|
|
214
|
-
// window blurs, even if you're tabbing out of the page. ¯\_(ツ)_/¯
|
|
215
|
-
if (
|
|
216
|
-
/** @type {Element} */ (e.target).nodeName &&
|
|
217
|
-
/** @type {Element} */ (e.target).nodeName.toLowerCase() === 'html'
|
|
218
|
-
) {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
hadKeyboardEvent = false;
|
|
223
|
-
removeInitialPointerMoveListeners();
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// We are interested in changes at the global scope only for some kinds of states.
|
|
227
|
-
// For example, global pointer input, global key presses, and global
|
|
228
|
-
// visibility change should affect the state at every scope:
|
|
229
|
-
document.addEventListener('keydown', onKeyDown, true);
|
|
230
|
-
document.addEventListener('mousedown', onPointerDown, true);
|
|
231
|
-
document.addEventListener('pointerdown', onPointerDown, true);
|
|
232
|
-
document.addEventListener('touchstart', onPointerDown, true);
|
|
233
|
-
document.addEventListener('visibilitychange', onVisibilityChange, true);
|
|
234
|
-
|
|
235
|
-
addInitialPointerMoveListeners();
|
|
236
|
-
|
|
237
|
-
// We specifically care about state changes in the local scope for focus and blur.
|
|
238
|
-
// This is because focus/blur events that originate from within a
|
|
239
|
-
// shadow root are not re-dispatched from the host element if it was already
|
|
240
|
-
// the active element in its own scope:
|
|
241
|
-
scope.addEventListener('focus', onFocus, true);
|
|
242
|
-
scope.addEventListener('blur', onBlur, true);
|
|
243
|
-
|
|
244
|
-
return () => {
|
|
245
|
-
removeInitialPointerMoveListeners();
|
|
246
|
-
|
|
247
|
-
document.removeEventListener('keydown', onKeyDown, true);
|
|
248
|
-
document.removeEventListener('mousedown', onPointerDown, true);
|
|
249
|
-
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
250
|
-
document.removeEventListener('touchstart', onPointerDown, true);
|
|
251
|
-
document.removeEventListener('visibilitychange', onVisibilityChange, true);
|
|
252
|
-
|
|
253
|
-
scope.removeEventListener('focus', onFocus, true);
|
|
254
|
-
scope.removeEventListener('blur', onBlur, true);
|
|
255
|
-
};
|
|
256
|
-
}
|
package/blocks/Range/Range.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export class Range extends BaseComponent<any> {
|
|
2
|
-
constructor();
|
|
3
|
-
init$: {
|
|
4
|
-
cssLeft: string;
|
|
5
|
-
barActive: boolean;
|
|
6
|
-
value: number;
|
|
7
|
-
onChange: (e: any) => void;
|
|
8
|
-
};
|
|
9
|
-
/** @type {HTMLInputElement} */
|
|
10
|
-
_range: HTMLInputElement | undefined;
|
|
11
|
-
}
|
|
12
|
-
export namespace Range {
|
|
13
|
-
let template: string;
|
|
14
|
-
}
|
|
15
|
-
import { BaseComponent } from '@symbiotejs/symbiote';
|
|
16
|
-
//# sourceMappingURL=Range.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Range.d.ts","sourceRoot":"","sources":["Range.js"],"names":[],"mappings":"AAEA;IAqC0C,cAAgB;IApCxD;;;;;MAUE;IAIA,+BAA+B;IAC/B,qCAA4B;CAe/B;;;;8BAjC6B,sBAAsB"}
|
package/blocks/Range/Range.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from '@symbiotejs/symbiote';
|
|
2
|
-
|
|
3
|
-
export class Range extends BaseComponent {
|
|
4
|
-
init$ = {
|
|
5
|
-
cssLeft: '50%',
|
|
6
|
-
barActive: false,
|
|
7
|
-
value: 50,
|
|
8
|
-
onChange: (e) => {
|
|
9
|
-
e.preventDefault();
|
|
10
|
-
e.stopPropagation();
|
|
11
|
-
this.$.value = parseFloat(this._range.value);
|
|
12
|
-
this.dispatchEvent(new Event('change'));
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
initCallback() {
|
|
17
|
-
super.initCallback();
|
|
18
|
-
/** @type {HTMLInputElement} */
|
|
19
|
-
this._range = this.ref.range;
|
|
20
|
-
[...this.attributes].forEach((attr) => {
|
|
21
|
-
let exclude = ['style', 'ref'];
|
|
22
|
-
if (!exclude.includes(attr.name)) {
|
|
23
|
-
this.ref.range.setAttribute(attr.name, attr.value);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
this.sub('value', (val) => {
|
|
27
|
-
let pcnt = (val / 100) * 100;
|
|
28
|
-
this.$.cssLeft = `${pcnt}%`;
|
|
29
|
-
});
|
|
30
|
-
this.defineAccessor('value', (val) => {
|
|
31
|
-
this.$.value = val;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
Range.template = /* HTML */ `
|
|
37
|
-
<div class="uc-track-wrapper">
|
|
38
|
-
<div class="uc-track"></div>
|
|
39
|
-
<div class="uc-bar" set -style.width="cssLeft" -@active="barActive"></div>
|
|
40
|
-
<div class="uc-slider" set -style.left="cssLeft"></div>
|
|
41
|
-
</div>
|
|
42
|
-
|
|
43
|
-
<input type="range" ref="range" set -@value="value" -oninput="onChange" />
|
|
44
|
-
`;
|