From 43fa326d9f35e9e8d477dbff83611bd124f8cfb4 Mon Sep 17 00:00:00 2001 From: btopro Date: Tue, 8 Aug 2023 16:10:46 -0400 Subject: [PATCH] https://github.com/elmsln/issues/issues/1644 --- .../lib/core/haxcms-site-store.js | 2 +- .../ui-components/routes/site-views-route.js | 158 ++++++++++++++++-- .../lib/simple-fields-tag-list.js | 4 +- .../simple-icon/lib/simple-iconset-demo.js | 4 +- 4 files changed, 151 insertions(+), 17 deletions(-) diff --git a/build/es6/node_modules/@lrnwebcomponents/haxcms-elements/lib/core/haxcms-site-store.js b/build/es6/node_modules/@lrnwebcomponents/haxcms-elements/lib/core/haxcms-site-store.js index 320811a562d..96d31f3e690 100644 --- a/build/es6/node_modules/@lrnwebcomponents/haxcms-elements/lib/core/haxcms-site-store.js +++ b/build/es6/node_modules/@lrnwebcomponents/haxcms-elements/lib/core/haxcms-site-store.js @@ -1 +1 @@ -import{observable as e,makeObservable as t,computed as i,autorun as a,toJS as s,configure as n}from"../../../../mobx/dist/mobx.esm.js";import{varExists as o,varGet as r,localStorageGet as d}from"../../../utils/utils.js";import{JsonOutlineSchema as c}from"../../../json-outline-schema/json-outline-schema.js";import{DeviceDetails as m}from"../../../replace-tag/lib/PerformanceDetect.js";import{iconFromPageType as l}from"../../../course-design/lib/learning-component.js";import{SimpleIconsetStore as h}from"../../../simple-icon/lib/simple-iconset.js";n({enforceActions:!1});export const store=new class Store{constructor(){this.badDevice=!1,this.internalRoutes={search:{},views:{}},this.evaluatebadDevice(),this.location=null,this.currentRouterLocation={},this.jwt=null,this.version="0.0.0",this.soundStatus=d("app-hax-soundStatus",!0),this.darkMode=!!d("app-hax-darkMode")&&d("app-hax-darkMode"),this.setupSlots={"haxcms-site-editor-ui-prefix-avatar":[],"haxcms-site-editor-ui-prefix-buttons":[],"haxcms-site-editor-ui-suffix-buttons":[],"haxcms-site-editor-ui-main-menu":[],"haxcms-site-editor-ui-topbar-character-button":[]},fetch(new URL("../../package.json",import.meta.url)).then((e=>e.json())).then((e=>this.version=e.version)),this.appReady=!1,this.editMode=!1,this.manifest=null,this.activeItemContent="",this.themeElement=null,this.themeStyleElement=document.createElement("style"),this.themeStyleElement.id="haxcms-theme-global-style-element",this.t={close:"Close",search:"Search",views:"Views",pageNotFound:"Page not found"},this.activeId=null,this.userData={},this.cmsSiteEditor={instance:null},this.cmsSiteEditorBackend={instance:null},this._registration={},t(this,{location:e.ref,currentRouterLocation:e.ref,internalRoutes:e,editMode:e,jwt:e,userData:e,manifest:e,activeItemContent:e,themeElement:e,version:e,routerManifest:i,siteTitle:i,isLoggedIn:i,themeData:i,homeLink:i,activeId:e,activeItem:i,activeItemFields:i,activeManifestIndex:i,activeManifestIndexCounter:i,activeTitle:i,activeTags:i,parentTitle:i,ancestorTitle:i,ancestorItem:i,darkMode:e,soundStatus:e,appReady:e,badDevice:e})}getUniqueSlugName(e,t=null,i=!1){let a=e;if(null!=t&&null!=t.parent&&""!=t.parent&&i){let i=t,s=[e];for(;i=this.findItem(i.parent);){let e=i.slug.split("/");s.unshift(e.pop())}a=e=s.join("/")}let s=0,n=!1;for(;!n;)for(var o in n=!0,this.manifest.items){let i=this.manifest.items[o];if(a==i.slug){if(null!=t&&i.id==t.id)return a;s++,a=e+"-"+s,n=!1}}return a.toLowerCase().split(" ").join("-").replace(/[^0-9\-\/a-z]/gi,"")}async evaluatebadDevice(){this.badDevice=await m.badDevice(),this.badDevice&&(this.soundStatus=!1)}playSound(e){if(this.soundStatus&&this.appReady)try{switch(e){case"click":case"click2":case"coin":case"coin2":case"hit":case"success":case"error":"error"==e&&(e="hit"),this.audio=new Audio(new URL(`../../../app-hax/lib/assets/sounds/${e}.mp3`,import.meta.url).href),this.audio.volume=.5,this.audio.play();break;default:this.audio=new Audio(new URL("../../../app-hax/lib/assets/sounds/hit.mp3",import.meta.url).href),this.audio.volume=.5,this.audio.play(),console.warn(`${e} is not a valid sound file yet`)}}catch(e){console.warn(e)}}toast(e,t=2e3,i={},a="capsule",s=this.t.close,n=null,o=null){this.appReady&&window.dispatchEvent(new CustomEvent("haxcms-toast-show",{bubbles:!0,composed:!0,cancelable:!0,detail:{text:e,duration:t,classStyle:a,closeText:s,eventCallback:n,slot:o,...i}}))}async loadManifest(e,t=null){if(null==t&&window&&(t=window),o(e,"metadata.siteName")){let t=r(e,"publishing.git",{});e.metadata.site={name:e.metadata.siteName,git:t,created:e.metadata.created,updated:e.metadata.updated},e.metadata.theme.variables={image:e.metadata.image,icon:e.metadata.icon,hexCode:e.metadata.hexCode,cssVariable:e.metadata.cssVariable},e.metadata.node={dynamicElementLoader:e.metadata.dynamicElementLoader,fields:e.metadata.fields},delete e.metadata.publishing,delete e.metadata.created,delete e.metadata.updated,delete e.metadata.siteName,delete e.metadata.image,delete e.metadata.icon,delete e.metadata.hexCode,delete e.metadata.cssVariable,delete e.metadata.dynamicElementLoader,delete e.metadata.fields}await e.items.forEach(((e,t,i)=>{e.slug||(i[t].slug=e.location.replace("pages/","").replace("/index.html","")),e.metadata.hasOwnProperty("published")||(i[t].metadata.published=!0),i[t].order=Number(i[t].order),e.metadata.hasOwnProperty("locked")||(i[t].metadata.locked=!1),e.metadata.hasOwnProperty("status")||(i[t].metadata.status="")}));var i=new c,a=i.itemsToNodes(e.items),s=i.nodesToItems(a),n=[];for(var d in s)n.push(e.items.find((e=>e.id===s[d].id)));document.documentElement&&e.metadata.site.lang&&(document.documentElement.lang=e.metadata.site.lang,window.dispatchEvent(new CustomEvent("languagechange",{detail:e.metadata.site.lang}))),e.items=n,this.manifest=e,t.dispatchEvent(new CustomEvent("json-outline-schema-changed",{bubbles:!0,composed:!0,cancelable:!1,detail:e})),window.dispatchEvent(new CustomEvent("haxcms-item-rebuild",{bubbles:!0,composed:!0,cancelable:!1,detail:!0}))}cmsSiteEditorAvailability(){return this.cmsSiteEditor.instance||(this.cmsSiteEditor.instance=document.createElement("haxcms-site-editor")),this.cmsSiteEditor.instance}get processedItems(){}_computeItems(e,t,i,a,s){if(s){let n,o=[],r=[];switch(s.items.forEach((e=>{e.parent||o.push(e)})),a){case"parent":n=s.items.find((e=>i===e.id)),n&&(i=n.parent);break;case"ancestor":for(n=s.items.find((e=>i===e.id));n&&null!=n.parent;)n=s.items.find((e=>e.id==n.parent));n&&(i=n.id)}return o.forEach(((a,s)=>{this._spiderChildren(a,r,e,t,i,!1)})),r}}_setChildren(e,t){const i=t.filter((t=>e.id===t.parent));e.children=i,e.children.length>0&&e.children.forEach((e=>{this._setChildren(e,t)}))}get routerManifest(){const e=this.manifest;if(document.body.dispatchEvent(new CustomEvent("json-outline-schema-changed",{bubbles:!0,composed:!0,cancelable:!1,detail:e})),e&&void 0!==e.items){let t=e.items.map((t=>{let i=null,a=null,s=e.items.find((e=>t.parent===e.id));s&&(i=s.location,a=s.slug);let n=t.metadata,o=t.location,r=t.slug;return n&&n.pageType&&(t.metadata.icon=l(n.pageType)),Object.assign({},t,{parentLocation:i,parentSlug:a,location:o,slug:r,metadata:n})}));if(t.forEach(((e,i)=>{this._setChildren(e,t)})),!0===r(e,"metadata.site.settings.publishPagesOn",!0)){const filterHiddenParentsRecursive=e=>{if(!1===e.metadata.published)return!1;const i=t.find((t=>t.id===e.parent));return!i||filterHiddenParentsRecursive(i)};this.isLoggedIn||(t=t.filter((e=>filterHiddenParentsRecursive(e))))}return Object.assign({},e,{items:t})}}get siteTitle(){return this.manifest&&this.manifest.title?this.manifest.title:""}get homeLink(){if(this.manifest){const e=this.manifest.items.find((e=>void 0!==e.id));if(e)return e.slug}return"/"}get activeItem(){let e=this.findItem(this.activeId);if(this.activeId&&HAXcmsStore.storePieces&&HAXcmsStore.storePieces.siteRouter&&null==e&&"404"===this.activeId){e={id:"404",_internalRoute:!0,title:this.t.pageNotFound,location:"hax-fake-404.html"};const t=store.getInternalRoute();t&&store.internalRoutes[t]&&("function"==typeof store.internalRoutes[t].callback&&store.internalRoutes[t].callback(),e={id:"x/"+t,_internalRoute:!0,component:`site-${t}-route`,title:this.t[t]||t,location:"hax-internal-route.html"})}return e||null}get activeItemFields(){if(this.activeItem&&this.activeItem.metadata){let e={title:this.activeItem.title,description:this.activeItem.description,location:this.activeItem.location,slug:this.activeItem.slug,created:this.activeItem.metadata.created,updated:this.activeItem.metadata.created};if(this.activeItem.metadata.fields)return Object.assign({},e,this.activeItem.metadata.fields)}}get themeData(){if(this.manifest){var e={};return e=o(this.manifest,"metadata.theme")?this.manifest.metadata.theme:{"haxcms-basic-theme":{element:"haxcms-basic-theme",path:"@lrnwebcomponents/haxcms-elements/lib/core/themes/haxcms-basic-theme.js",name:"Basic theme",variables:{image:"assets/banner.jpg",icon:"icons:record-voice-over",hexCode:"#da004e",cssVariable:"pink"}}},this.activeItem&&o(this.activeItem,"metadata.theme")?this.activeItem.metadata.theme:e}}get activeManifestIndex(){if(this.manifest&&this.manifest.items&&this.activeId)for(var e in this.manifest.items)if(this.manifest.items[e].id===this.activeId)return parseInt(e);return-1}get activeRouterManifestIndex(){if(this.routerManifest&&this.routerManifest.items&&this.activeId)for(var e in this.routerManifest.items)if(this.routerManifest.items[e].id===this.activeId)return parseInt(e);return-1}get activeManifestIndexCounter(){return null!==this.activeManifestIndex?1+this.activeManifestIndex:0}get activeTitle(){return this.activeItem?this.activeItem.title:""}get activeTags(){return this.activeItem&&this.activeItem.metadata&&this.activeItem.metadata.tags?this.activeItem.metadata.tags:null}get parentTitle(){if(this.manifest&&this.activeItem){let e=this.manifest.items.find((e=>this.activeItem.parent===e.id));if(e)return e.title}return""}get isLoggedIn(){return!(!this.jwt||"null"==this.jwt)}get ancestorTitle(){if(this.manifest&&this.activeItem){let e=this.manifest.items.find((e=>this.activeItem.parent===e.id));for(;e&&null!=e.parent;)e=this.manifest.items.find((t=>t.id==e.parent));if(e)return e.title}return""}get ancestorItem(){if(this.manifest&&this.activeItem){let e=this.manifest.items.find((e=>this.activeItem.parent===e.id));for(;e&&null!=e.parent;)e=this.manifest.items.find((t=>t.id==e.parent));if(e)return e}return null}findItem(e){return this.manifest&&e?this.manifest.items.find((t=>t.id===e)):null}async findItemAsObject(e,t="id",i="item",a=!0){if(this.manifest&&e){var n=await this.manifest.items.find((i=>i[t]===e));if(a&&(n=s(n)),"item"==i)return n;if("parent"==i&&n.parent)return s(await this.manifest.items.find((e=>n.parent===e.id)))}return null}fallbackItemSlug(){if(this.manifest&&this.activeItem){if(this.activeManifestIndex>0&&this.manifest.items[this.activeManifestIndex-1])return this.manifest.items[this.activeManifestIndex-1].slug;if(this.activeManifestIndexe.id===o[d].id)));return this.manifest.items.replace(r),window.dispatchEvent(new CustomEvent("json-outline-schema-changed",{bubbles:!0,composed:!0,cancelable:!1,detail:this.manifest})),window.dispatchEvent(new CustomEvent("haxcms-item-rebuild",{bubbles:!0,composed:!0,cancelable:!1,detail:!0})),this.findItem(i.id)}removeItem(e){const t=this.findItem(e);if(t)if("new"===t.metadata.status){const e=this.manifest.items.indexOf(t);e>-1&&this.manifest.items.splice(e,1)}else t.metadata.status="delete"}spiderChildren(e,t,i,a,s,n,o){e.id===s||n?(n||(n=!0,!o&&e.indent>=i&&(i+=e.indent,a+=e.indent)),e.indent>=i&&e.indent<=a&&t.push(e),e.children.length>0&&e.children.forEach((e=>{this.spiderChildren(e,t,i,a,s,n,o)}))):e.children.length>0&&e.children.forEach((e=>{this.spiderChildren(e,t,a,s,n,o)}))}getInternalRoute(){return!!(this.currentRouterLocation&&this.currentRouterLocation.params&&this.currentRouterLocation.params[0])&&this.currentRouterLocation.params[0].replace("x/","")}computeItems(e,t,i,a,s,n){if(s){let o,r=[],d=[];switch(s.items.forEach((e=>{e.parent||r.push(e)})),a){case"parent":o=s.items.find((e=>i===e.id)),o&&(i=o.parent);break;case"ancestor":for(o=s.items.find((e=>i===e.id));o&&null!=o.parent;)o=s.items.find((e=>e.id==o.parent));o&&(i=o.id)}return s.items.forEach(((a,s)=>{store.spiderChildren(a,d,e,t,i,!1,n)})),d}}};window.HAXCMS=window.HAXCMS||{},window.HAXCMS.setTheme=function(e){window.HAXCMS.instance.store.manifest.metadata.theme.element=e},window.HAXCMS.requestAvailability=()=>(window.HAXCMS.instance||(window.HAXCMS.instance=document.createElement("haxcms-site-store"),document.body.appendChild(window.HAXCMS.instance)),window.HAXCMS.instance);export const HAXcmsStore=window.HAXCMS.requestAvailability();class HAXCMSSiteStore extends HTMLElement{constructor(){super(),this.storePieces={},this.store=store,this.source="",a((()=>{if(store.location&&store.location.route&&store.location.route.component){const e=store.location.route.name;store.manifest.items.filter((t=>t.id===e))&&(store.activeId=e)}})),a((()=>{const e=s(store.findItem(store.activeId));e&&(document.body.dispatchEvent(new CustomEvent("json-outline-schema-active-item-changed",{bubbles:!0,composed:!0,cancelable:!1,detail:e})),document.title=store.activeTitle)})),a((()=>{if(store.appReady){const e=document.querySelector('link[rel="icon"]');e&&(this.faviconSiteDefault=e.href,this.faviconInstance=e)}})),a((()=>{const e=s(store.editMode);window.HaxStore&&window.HaxStore.requestAvailability()&&window.HaxStore.requestAvailability().write&&(window.dispatchEvent(new CustomEvent("haxcms-edit-mode-changed",{bubbles:!0,composed:!0,cancelable:!1,detail:e})),window.HaxStore.requestAvailability().editMode=e,window.HaxStore.requestAvailability().toastShowEventName="haxcms-toast-show")}))}connectedCallback(){document.body.appendChild(this.store.themeStyleElement)}disconnectedCallback(){this.store.themeStyleElement.remove(),this.store.themeStyleElement=document.createElement("style")}resetFavicon(){this.setFavicon()}setFavicon(e=null,t=!0){e?t&&(e=h.getIcon(e)):e=this.faviconSiteDefault,this.faviconInstance&&this.faviconInstance.setAttribute("href",e)}resetCursor(){this.setCursor()}setCursor(e=null,t=!0){e?(t&&(e=h.getIcon(e)),document.body.style.cursor=`url("${e}") 16 16, pointer`):document.body.style.removeProperty("cursor")}getApplicationContext(){let e="";if("undefined"!=typeof DatArchive)e="beaker";else switch(window.HAXCMSContext){case"published":case"nodejs":case"php":case"11ty":case"demo":case"desktop":case"local":case"userfs":e=window.HAXCMSContext;break;default:e="php"}return e}static get tag(){return"haxcms-site-store"}static get observedAttributes(){return["source"]}set source(e){this[name]=e,e&&this.setAttribute("source",e)}get source(){return this.getAttribute("source")}attributeChangedCallback(e,t,i){"source"==e&&""!=i&&fetch(this[e]).then((e=>e.json())).then((e=>{this.store.loadManifest(e)})).catch((e=>{console.warn(e)}))}}customElements.define(HAXCMSSiteStore.tag,HAXCMSSiteStore);export{HAXCMSSiteStore}; \ No newline at end of file +import{observable as e,makeObservable as t,computed as i,autorun as a,toJS as s,configure as n}from"../../../../mobx/dist/mobx.esm.js";import{varExists as o,varGet as r,localStorageGet as d}from"../../../utils/utils.js";import{JsonOutlineSchema as c}from"../../../json-outline-schema/json-outline-schema.js";import{DeviceDetails as m}from"../../../replace-tag/lib/PerformanceDetect.js";import{iconFromPageType as l}from"../../../course-design/lib/learning-component.js";import{SimpleIconsetStore as h}from"../../../simple-icon/lib/simple-iconset.js";n({enforceActions:!1});export const store=new class Store{constructor(){this.badDevice=!1,this.internalRoutes={search:{},views:{}},this.evaluatebadDevice(),this.location=null,this.currentRouterLocation={},this.jwt=null,this.version="0.0.0",this.soundStatus=d("app-hax-soundStatus",!0),this.darkMode=!!d("app-hax-darkMode")&&d("app-hax-darkMode"),this.setupSlots={"haxcms-site-editor-ui-prefix-avatar":[],"haxcms-site-editor-ui-prefix-buttons":[],"haxcms-site-editor-ui-suffix-buttons":[],"haxcms-site-editor-ui-main-menu":[],"haxcms-site-editor-ui-topbar-character-button":[]},fetch(new URL("../../package.json",import.meta.url)).then((e=>e.json())).then((e=>this.version=e.version)),this.appReady=!1,this.editMode=!1,this.manifest=null,this.activeItemContent="",this.themeElement=null,this.themeStyleElement=document.createElement("style"),this.themeStyleElement.id="haxcms-theme-global-style-element",this.t={close:"Close",search:"Search",views:"Content Views",pageNotFound:"Page not found"},this.activeId=null,this.userData={},this.cmsSiteEditor={instance:null},this.cmsSiteEditorBackend={instance:null},this._registration={},t(this,{location:e.ref,currentRouterLocation:e.ref,internalRoutes:e,editMode:e,jwt:e,userData:e,manifest:e,activeItemContent:e,themeElement:e,version:e,routerManifest:i,siteTitle:i,isLoggedIn:i,themeData:i,homeLink:i,activeId:e,activeItem:i,activeItemFields:i,activeManifestIndex:i,activeManifestIndexCounter:i,activeTitle:i,activeTags:i,parentTitle:i,ancestorTitle:i,ancestorItem:i,darkMode:e,soundStatus:e,appReady:e,badDevice:e})}getUniqueSlugName(e,t=null,i=!1){let a=e;if(null!=t&&null!=t.parent&&""!=t.parent&&i){let i=t,s=[e];for(;i=this.findItem(i.parent);){let e=i.slug.split("/");s.unshift(e.pop())}a=e=s.join("/")}let s=0,n=!1;for(;!n;)for(var o in n=!0,this.manifest.items){let i=this.manifest.items[o];if(a==i.slug){if(null!=t&&i.id==t.id)return a;s++,a=e+"-"+s,n=!1}}return a.toLowerCase().split(" ").join("-").replace(/[^0-9\-\/a-z]/gi,"")}async evaluatebadDevice(){this.badDevice=await m.badDevice(),this.badDevice&&(this.soundStatus=!1)}playSound(e){if(this.soundStatus&&this.appReady)try{switch(e){case"click":case"click2":case"coin":case"coin2":case"hit":case"success":case"error":"error"==e&&(e="hit"),this.audio=new Audio(new URL(`../../../app-hax/lib/assets/sounds/${e}.mp3`,import.meta.url).href),this.audio.volume=.5,this.audio.play();break;default:this.audio=new Audio(new URL("../../../app-hax/lib/assets/sounds/hit.mp3",import.meta.url).href),this.audio.volume=.5,this.audio.play(),console.warn(`${e} is not a valid sound file yet`)}}catch(e){console.warn(e)}}toast(e,t=2e3,i={},a="capsule",s=this.t.close,n=null,o=null){this.appReady&&window.dispatchEvent(new CustomEvent("haxcms-toast-show",{bubbles:!0,composed:!0,cancelable:!0,detail:{text:e,duration:t,classStyle:a,closeText:s,eventCallback:n,slot:o,...i}}))}async loadManifest(e,t=null){if(null==t&&window&&(t=window),o(e,"metadata.siteName")){let t=r(e,"publishing.git",{});e.metadata.site={name:e.metadata.siteName,git:t,created:e.metadata.created,updated:e.metadata.updated},e.metadata.theme.variables={image:e.metadata.image,icon:e.metadata.icon,hexCode:e.metadata.hexCode,cssVariable:e.metadata.cssVariable},e.metadata.node={dynamicElementLoader:e.metadata.dynamicElementLoader,fields:e.metadata.fields},delete e.metadata.publishing,delete e.metadata.created,delete e.metadata.updated,delete e.metadata.siteName,delete e.metadata.image,delete e.metadata.icon,delete e.metadata.hexCode,delete e.metadata.cssVariable,delete e.metadata.dynamicElementLoader,delete e.metadata.fields}await e.items.forEach(((e,t,i)=>{e.slug||(i[t].slug=e.location.replace("pages/","").replace("/index.html","")),e.metadata.hasOwnProperty("published")||(i[t].metadata.published=!0),i[t].order=Number(i[t].order),e.metadata.hasOwnProperty("locked")||(i[t].metadata.locked=!1),e.metadata.hasOwnProperty("status")||(i[t].metadata.status="")}));var i=new c,a=i.itemsToNodes(e.items),s=i.nodesToItems(a),n=[];for(var d in s)n.push(e.items.find((e=>e.id===s[d].id)));document.documentElement&&e.metadata.site.lang&&(document.documentElement.lang=e.metadata.site.lang,window.dispatchEvent(new CustomEvent("languagechange",{detail:e.metadata.site.lang}))),e.items=n,this.manifest=e,t.dispatchEvent(new CustomEvent("json-outline-schema-changed",{bubbles:!0,composed:!0,cancelable:!1,detail:e})),window.dispatchEvent(new CustomEvent("haxcms-item-rebuild",{bubbles:!0,composed:!0,cancelable:!1,detail:!0}))}cmsSiteEditorAvailability(){return this.cmsSiteEditor.instance||(this.cmsSiteEditor.instance=document.createElement("haxcms-site-editor")),this.cmsSiteEditor.instance}get processedItems(){}_computeItems(e,t,i,a,s){if(s){let n,o=[],r=[];switch(s.items.forEach((e=>{e.parent||o.push(e)})),a){case"parent":n=s.items.find((e=>i===e.id)),n&&(i=n.parent);break;case"ancestor":for(n=s.items.find((e=>i===e.id));n&&null!=n.parent;)n=s.items.find((e=>e.id==n.parent));n&&(i=n.id)}return o.forEach(((a,s)=>{this._spiderChildren(a,r,e,t,i,!1)})),r}}_setChildren(e,t){const i=t.filter((t=>e.id===t.parent));e.children=i,e.children.length>0&&e.children.forEach((e=>{this._setChildren(e,t)}))}get routerManifest(){const e=this.manifest;if(document.body.dispatchEvent(new CustomEvent("json-outline-schema-changed",{bubbles:!0,composed:!0,cancelable:!1,detail:e})),e&&void 0!==e.items){let t=e.items.map((t=>{let i=null,a=null,s=e.items.find((e=>t.parent===e.id));s&&(i=s.location,a=s.slug);let n=t.metadata,o=t.location,r=t.slug;return n&&n.pageType&&(t.metadata.icon=l(n.pageType)),Object.assign({},t,{parentLocation:i,parentSlug:a,location:o,slug:r,metadata:n})}));if(t.forEach(((e,i)=>{this._setChildren(e,t)})),!0===r(e,"metadata.site.settings.publishPagesOn",!0)){const filterHiddenParentsRecursive=e=>{if(!1===e.metadata.published)return!1;const i=t.find((t=>t.id===e.parent));return!i||filterHiddenParentsRecursive(i)};this.isLoggedIn||(t=t.filter((e=>filterHiddenParentsRecursive(e))))}return Object.assign({},e,{items:t})}}get siteTitle(){return this.manifest&&this.manifest.title?this.manifest.title:""}get homeLink(){if(this.manifest){const e=this.manifest.items.find((e=>void 0!==e.id));if(e)return e.slug}return"/"}get activeItem(){let e=this.findItem(this.activeId);if(this.activeId&&HAXcmsStore.storePieces&&HAXcmsStore.storePieces.siteRouter&&null==e&&"404"===this.activeId){e={id:"404",_internalRoute:!0,title:this.t.pageNotFound,location:"hax-fake-404.html"};const t=store.getInternalRoute();t&&store.internalRoutes[t]&&("function"==typeof store.internalRoutes[t].callback&&store.internalRoutes[t].callback(),e={id:"x/"+t,_internalRoute:!0,component:`site-${t}-route`,title:this.t[t]||t,location:"hax-internal-route.html"})}return e||null}get activeItemFields(){if(this.activeItem&&this.activeItem.metadata){let e={title:this.activeItem.title,description:this.activeItem.description,location:this.activeItem.location,slug:this.activeItem.slug,created:this.activeItem.metadata.created,updated:this.activeItem.metadata.created};if(this.activeItem.metadata.fields)return Object.assign({},e,this.activeItem.metadata.fields)}}get themeData(){if(this.manifest){var e={};return e=o(this.manifest,"metadata.theme")?this.manifest.metadata.theme:{"haxcms-basic-theme":{element:"haxcms-basic-theme",path:"@lrnwebcomponents/haxcms-elements/lib/core/themes/haxcms-basic-theme.js",name:"Basic theme",variables:{image:"assets/banner.jpg",icon:"icons:record-voice-over",hexCode:"#da004e",cssVariable:"pink"}}},this.activeItem&&o(this.activeItem,"metadata.theme")?this.activeItem.metadata.theme:e}}get activeManifestIndex(){if(this.manifest&&this.manifest.items&&this.activeId)for(var e in this.manifest.items)if(this.manifest.items[e].id===this.activeId)return parseInt(e);return-1}get activeRouterManifestIndex(){if(this.routerManifest&&this.routerManifest.items&&this.activeId)for(var e in this.routerManifest.items)if(this.routerManifest.items[e].id===this.activeId)return parseInt(e);return-1}get activeManifestIndexCounter(){return null!==this.activeManifestIndex?1+this.activeManifestIndex:0}get activeTitle(){return this.activeItem?this.activeItem.title:""}get activeTags(){return this.activeItem&&this.activeItem.metadata&&this.activeItem.metadata.tags?this.activeItem.metadata.tags:null}get parentTitle(){if(this.manifest&&this.activeItem){let e=this.manifest.items.find((e=>this.activeItem.parent===e.id));if(e)return e.title}return""}get isLoggedIn(){return!(!this.jwt||"null"==this.jwt)}get ancestorTitle(){if(this.manifest&&this.activeItem){let e=this.manifest.items.find((e=>this.activeItem.parent===e.id));for(;e&&null!=e.parent;)e=this.manifest.items.find((t=>t.id==e.parent));if(e)return e.title}return""}get ancestorItem(){if(this.manifest&&this.activeItem){let e=this.manifest.items.find((e=>this.activeItem.parent===e.id));for(;e&&null!=e.parent;)e=this.manifest.items.find((t=>t.id==e.parent));if(e)return e}return null}findItem(e){return this.manifest&&e?this.manifest.items.find((t=>t.id===e)):null}async findItemAsObject(e,t="id",i="item",a=!0){if(this.manifest&&e){var n=await this.manifest.items.find((i=>i[t]===e));if(a&&(n=s(n)),"item"==i)return n;if("parent"==i&&n.parent)return s(await this.manifest.items.find((e=>n.parent===e.id)))}return null}fallbackItemSlug(){if(this.manifest&&this.activeItem){if(this.activeManifestIndex>0&&this.manifest.items[this.activeManifestIndex-1])return this.manifest.items[this.activeManifestIndex-1].slug;if(this.activeManifestIndexe.id===o[d].id)));return this.manifest.items.replace(r),window.dispatchEvent(new CustomEvent("json-outline-schema-changed",{bubbles:!0,composed:!0,cancelable:!1,detail:this.manifest})),window.dispatchEvent(new CustomEvent("haxcms-item-rebuild",{bubbles:!0,composed:!0,cancelable:!1,detail:!0})),this.findItem(i.id)}removeItem(e){const t=this.findItem(e);if(t)if("new"===t.metadata.status){const e=this.manifest.items.indexOf(t);e>-1&&this.manifest.items.splice(e,1)}else t.metadata.status="delete"}spiderChildren(e,t,i,a,s,n,o){e.id===s||n?(n||(n=!0,!o&&e.indent>=i&&(i+=e.indent,a+=e.indent)),e.indent>=i&&e.indent<=a&&t.push(e),e.children.length>0&&e.children.forEach((e=>{this.spiderChildren(e,t,i,a,s,n,o)}))):e.children.length>0&&e.children.forEach((e=>{this.spiderChildren(e,t,a,s,n,o)}))}getInternalRoute(){return!!(this.currentRouterLocation&&this.currentRouterLocation.params&&this.currentRouterLocation.params[0])&&this.currentRouterLocation.params[0].replace("x/","")}computeItems(e,t,i,a,s,n){if(s){let o,r=[],d=[];switch(s.items.forEach((e=>{e.parent||r.push(e)})),a){case"parent":o=s.items.find((e=>i===e.id)),o&&(i=o.parent);break;case"ancestor":for(o=s.items.find((e=>i===e.id));o&&null!=o.parent;)o=s.items.find((e=>e.id==o.parent));o&&(i=o.id)}return s.items.forEach(((a,s)=>{store.spiderChildren(a,d,e,t,i,!1,n)})),d}}};window.HAXCMS=window.HAXCMS||{},window.HAXCMS.setTheme=function(e){window.HAXCMS.instance.store.manifest.metadata.theme.element=e},window.HAXCMS.requestAvailability=()=>(window.HAXCMS.instance||(window.HAXCMS.instance=document.createElement("haxcms-site-store"),document.body.appendChild(window.HAXCMS.instance)),window.HAXCMS.instance);export const HAXcmsStore=window.HAXCMS.requestAvailability();class HAXCMSSiteStore extends HTMLElement{constructor(){super(),this.storePieces={},this.store=store,this.source="",a((()=>{if(store.location&&store.location.route&&store.location.route.component){const e=store.location.route.name;store.manifest.items.filter((t=>t.id===e))&&(store.activeId=e)}})),a((()=>{const e=s(store.findItem(store.activeId));e&&(document.body.dispatchEvent(new CustomEvent("json-outline-schema-active-item-changed",{bubbles:!0,composed:!0,cancelable:!1,detail:e})),document.title=store.activeTitle)})),a((()=>{if(store.appReady){const e=document.querySelector('link[rel="icon"]');e&&(this.faviconSiteDefault=e.href,this.faviconInstance=e)}})),a((()=>{const e=s(store.editMode);window.HaxStore&&window.HaxStore.requestAvailability()&&window.HaxStore.requestAvailability().write&&(window.dispatchEvent(new CustomEvent("haxcms-edit-mode-changed",{bubbles:!0,composed:!0,cancelable:!1,detail:e})),window.HaxStore.requestAvailability().editMode=e,window.HaxStore.requestAvailability().toastShowEventName="haxcms-toast-show")}))}connectedCallback(){document.body.appendChild(this.store.themeStyleElement)}disconnectedCallback(){this.store.themeStyleElement.remove(),this.store.themeStyleElement=document.createElement("style")}resetFavicon(){this.setFavicon()}setFavicon(e=null,t=!0){e?t&&(e=h.getIcon(e)):e=this.faviconSiteDefault,this.faviconInstance&&this.faviconInstance.setAttribute("href",e)}resetCursor(){this.setCursor()}setCursor(e=null,t=!0){e?(t&&(e=h.getIcon(e)),document.body.style.cursor=`url("${e}") 16 16, pointer`):document.body.style.removeProperty("cursor")}getApplicationContext(){let e="";if("undefined"!=typeof DatArchive)e="beaker";else switch(window.HAXCMSContext){case"published":case"nodejs":case"php":case"11ty":case"demo":case"desktop":case"local":case"userfs":e=window.HAXCMSContext;break;default:e="php"}return e}static get tag(){return"haxcms-site-store"}static get observedAttributes(){return["source"]}set source(e){this[name]=e,e&&this.setAttribute("source",e)}get source(){return this.getAttribute("source")}attributeChangedCallback(e,t,i){"source"==e&&""!=i&&fetch(this[e]).then((e=>e.json())).then((e=>{this.store.loadManifest(e)})).catch((e=>{console.warn(e)}))}}customElements.define(HAXCMSSiteStore.tag,HAXCMSSiteStore);export{HAXCMSSiteStore}; \ No newline at end of file diff --git a/build/es6/node_modules/@lrnwebcomponents/haxcms-elements/lib/ui-components/routes/site-views-route.js b/build/es6/node_modules/@lrnwebcomponents/haxcms-elements/lib/ui-components/routes/site-views-route.js index 44c8a273918..6e31ec6a41e 100644 --- a/build/es6/node_modules/@lrnwebcomponents/haxcms-elements/lib/ui-components/routes/site-views-route.js +++ b/build/es6/node_modules/@lrnwebcomponents/haxcms-elements/lib/ui-components/routes/site-views-route.js @@ -2,25 +2,159 @@ * Copyright 2022 The Pennsylvania State University * @license Apache-2.0, see License.md for full text. */ -import{LitElement as t,html as e,css as s}from"../../../../../lit/index.js";import{store as i}from"../../core/haxcms-site-store.js";import{MicroFrontendRegistry as a}from"../../../../micro-frontend-registry/micro-frontend-registry.js";import{enableServices as o}from"../../../../micro-frontend-registry/lib/microServices.js";import"../../../../simple-fields/lib/simple-tags.js";import{autorun as r,toJS as n}from"../../../../../mobx/dist/mobx.esm.js";export class SiteViewsRoute extends t{static get tag(){return"site-views-route"}static get styles(){return[s` +import{LitElement as t,html as e,css as a,nothing as i}from"../../../../../lit/index.js";import{unsafeHTML as s}from"../../../../../lit/directives/unsafe-html.js";import{store as l}from"../../core/haxcms-site-store.js";import{MicroFrontendRegistry as r}from"../../../../micro-frontend-registry/micro-frontend-registry.js";import{enableServices as o}from"../../../../micro-frontend-registry/lib/microServices.js";import"../../../../simple-fields/lib/simple-tags.js";import"../../../../simple-fields/lib/simple-fields-field.js";import"../../../../simple-fields/lib/simple-fields-tag-list.js";import"../../../../simple-icon/lib/simple-icon-button-lite.js";import"../../../../editable-table/lib/editable-table-display.js";import{iconFromPageType as d}from"../../../../course-design/lib/learning-component.js";import{autorun as n,toJS as c}from"../../../../../mobx/dist/mobx.esm.js";export class SiteViewsRoute extends t{static get tag(){return"site-views-route"}static get styles(){return[a` :host { display: block; + font-size: 16px; } + editable-table-display::part(tag-link), a { text-decoration: none; + font-size: 16px; } - `]}constructor(){super(),this.loading=!1,this.results=[],this._debounce=null,o(["haxcms"]),r((()=>{i.currentRouterLocation;clearTimeout(this._debounce),this._debounce=setTimeout((async()=>{if(!this.loading&&"views"===i.getInternalRoute()){const t=Object.fromEntries(new URLSearchParams(location.search)),e=n(i.manifest);let s=document.querySelector("base").href;s||(s="/");const o={type:"site",site:{file:s+"site.json",id:e.id,title:e.title,author:e.author,description:e.description,license:e.license,metadata:e.metadata,items:e.items},link:s,...t};this.loading=!0;const r=await a.call("@haxcms/views",o);r.data&&(this.results=r.data),this.loading=!1}}),0)}))}render(){return e` - ${this.loading?e`

Loading...

`:e`

Results

-${this.results.map((t=>e` -
- ${t.title} - ${t.metadata.tags&&""!=t.metadata.tags?t.metadata.tags.split(",").map((s=>e` + [data-active] { + background-color: var(--simple-colors-default-theme-accent-1); + } + simple-icon-button-lite { + border-radius: 0; + font-size: 16px; + } + /* list display */ + .list { + margin: 0; + padding: 0; + list-style: none; + } + .list-item { + margin: 0; + padding: 16px; + border-bottom: 1px solid var(--simple-colors-default-theme-grey-3); + } + .list-item:hover { + background-color: var(--simple-colors-default-theme-grey-2); + } + .list-link a { + font-size: 32px; + } + .list-breadcrumb { + font-size: 10px; + } + + + /* editable table display */ + editable-table-display, + editable-table-display::part(table), + table,tr,th,td { + font-size: 16px; + } + `]}constructor(){super(),this.loading=!1,this.params={display:"list"},this.results=[],this._debounce=null,o(["haxcms"]),n((()=>{l.currentRouterLocation;clearTimeout(this._debounce),this._debounce=setTimeout((async()=>{await this.rebuildSearchResults()}),0)}))}async rebuildSearchResults(){if(!this.loading&&"views"===l.getInternalRoute()){const t=new URLSearchParams(location.search),e=Object.fromEntries(t);this.params={...this.params,...e},e.display||(t.set("display",this.params.display||"list"),window.history.replaceState({},"",decodeURIComponent(`./x/views?${t}`)));const a=c(l.manifest);let i=document.querySelector("base").href;i||(i="/");const s={type:"site",site:{file:i+"site.json",id:a.id,title:a.title,author:a.author,description:a.description,license:a.license,metadata:a.metadata,items:a.items},link:i,...e};this.loading=!0;const o=await r.call("@haxcms/views",s);o.data&&(this.results=o.data),this.loading=!1}}toggleDisplay(t){const e=new URLSearchParams(window.location.search);e.set("display",t.target.dataset.display),window.history.pushState({},"",decodeURIComponent(`./x/views?${e}`)),this.params=Object.fromEntries(e)}toggleMediaDisplay(t){const e=new URLSearchParams(window.location.search);e.set("mediatype",t.target.dataset.mediatype),window.history.pushState({},"",decodeURIComponent(`./x/views?${e}`)),this.params=Object.fromEntries(e)}evaluateTagValue(t){setTimeout((()=>{if(0===this.shadowRoot.querySelector("simple-fields-tag-list").tagList.length){const t=new URLSearchParams(window.location.search);t.delete("tag"),window.history.pushState({},"",decodeURIComponent(`./x/views?${t}`)),this.params=Object.fromEntries(t)}}),0)}render(){return e` + List display + Table display + Card display + Media display + Refresh data + + + ${this.loading?e`

Loading...

`:e`

Results

+${"list"===this.params.display?this.listTemplate():i} +${"table"===this.params.display?this.tableTemplate():i} +${"card"===this.params.display?this.cardTemplate():i} +${"media"===this.params.display?this.mediaTemplate():i} + `}`}iconFromKey(t){switch(t){case"audio":return"av:volume-up";case"selfChecks":return"hax:check";case"objectives":return"hax:learning-outcome";case"authorNotes":return"hax:note";case"images":return"image:photo";case"h5p":return"hax:h5p";case"headings":return"editor:format-size";case"dataTables":return"editor:table-chart";case"specialTags":return"hax:tag";case"links":return"editor:link";case"placeholders":return"editor:insert-comment";case"siteremotecontent":return"hax:remote";case"video":return"av:videocam";default:return"hax:module"}}mediaTemplate(){let t=["audio","selfChecks","objectives","authorNotes","images","h5p","headings","dataTables","specialTags","links","placeholders","siteremotecontent","video"];return e` +
+ ${t.map((t=>e` + ${t} + `))} +
+
+ ${this.results.map((a=>e` + ${t.map((t=>e`${"string"==typeof a.media[t]&&this.params.mediatype===t?s(a.media[t]):i}`))} + `))} +
+ `}listTemplate(){return e` +
`}tableTemplate(){return e` + + + + + + + + + + + + ${this.results.map((t=>e` + + + + + + + + + `))} +
IconTypeTitleTagsUpdatedCreatedStatus
${t.metadata.pageType?e``:i}${t.metadata.pageType?t.metadata.pageType:i}${t.title} + ${t.metadata.tags&&""!=t.metadata.tags?t.metadata.tags.split(",").map((a=>e` `)):""} + >`)):i} + + + + + + ${!1!==t.metadata.published?"published":"unpublished"} +
+
`}updated(t){super.updated&&super.updated(t),t.forEach(((t,e)=>{"params"===e&&t&&this.params&&(t.tag!==this.params.tag||"media"===this.params.display)&&this.rebuildSearchResults()}))}cardTemplate(){return e`${this.results.map((t=>e` + +
${t.title}
+
${t.metadata.tags&&""!=t.metadata.tags?t.metadata.tags.split(",").map((a=>e` + `)):i}
+ - `))}`} - - `}activateView(t){const e=new URLSearchParams(window.location.search);e.set("tag",t.target.value),window.history.pushState({},"",decodeURIComponent(`./x/views?${e}`))}static get properties(){return{results:{type:Array},loading:{type:Boolean,reflect:!0}}}}customElements.define(SiteViewsRoute.tag,SiteViewsRoute); \ No newline at end of file +
`))}`}calculateBreadcrumb(t){let e=[];const a=c(l.manifest);let i=t;for(;i&&null!=i.parent;)i=a.items.find((t=>t.id==i.parent)),i&&e.unshift({title:i.title});return e}activateView(t){const e=new URLSearchParams(window.location.search);e.set("tag",t.target.value),window.history.pushState({},"",decodeURIComponent(`./x/views?${e}`))}static get properties(){return{results:{type:Array},loading:{type:Boolean,reflect:!0},params:{type:Object}}}}customElements.define(SiteViewsRoute.tag,SiteViewsRoute); \ No newline at end of file diff --git a/build/es6/node_modules/@lrnwebcomponents/simple-fields/lib/simple-fields-tag-list.js b/build/es6/node_modules/@lrnwebcomponents/simple-fields/lib/simple-fields-tag-list.js index a96a4eb632b..897535699ae 100755 --- a/build/es6/node_modules/@lrnwebcomponents/simple-fields/lib/simple-fields-tag-list.js +++ b/build/es6/node_modules/@lrnwebcomponents/simple-fields/lib/simple-fields-tag-list.js @@ -36,7 +36,7 @@ import{LitElement as e,html as t,css as s}from"../../../lit/index.js";import{Sim [part="option-inner"] { height: var(--simple-fields-tag-list-height); } - `]}static get properties(){return{...super.properties,requiredMessage:{type:String},tagList:{type:Array,attribute:"tag-list"},value:{reflect:!0},label:{type:String}}}constructor(){super(),this.windowControllers=new AbortController,this.label="Tags",this.value="",this.tagList=[],this.id=this._generateUUID(),this.addEventListener("dragleave",this._handleDragLeave),this.addEventListener("dragover",this._handleDragEnter),this.addEventListener("drop",this._handleDragDrop)}updated(e){e.forEach(((e,t)=>{"id"!==t||this.id||(this.id=this._generateUUID()),"value"===t&&this._fireValueChanged(),"tagList"===t&&this._fireTagListChanged()}))}_handleGlobalTagDrop(e){this.classList.remove("drop-possible")}_handleGlobalTagDrag(e){this.classList.add("drop-possible")}get prefixTemplate(){return t` + `]}static get properties(){return{...super.properties,requiredMessage:{type:String},tagList:{type:Array,attribute:"tag-list"},value:{reflect:!0},label:{type:String},singleValueOnly:{type:Boolean,attribute:"single-value-only"}}}constructor(){super(),this.windowControllers=new AbortController,this.label="Tags",this.singleValueOnly=!1,this.value="",this.tagList=[],this.id=this._generateUUID(),this.addEventListener("dragleave",this._handleDragLeave),this.addEventListener("dragover",this._handleDragEnter),this.addEventListener("drop",this._handleDragDrop)}firstUpdated(e){super.firstUpdated&&super.firstUpdated(e),setTimeout((()=>{this._updateTaglist()}),0)}updated(e){super.updated&&super.updated(e),e.forEach(((e,t)=>{"id"!==t||this.id||(this.id=this._generateUUID()),"value"===t&&this._fireValueChanged(),"tagList"===t&&this._fireTagListChanged()}))}_handleGlobalTagDrop(e){this.classList.remove("drop-possible")}_handleGlobalTagDrag(e){this.classList.add("drop-possible")}get prefixTemplate(){return t` ${super.prefixTemplate} ${this.tagList.map((e=>t` @@ -75,4 +75,4 @@ import{LitElement as e,html as t,css as s}from"../../../lit/index.js";import{Sim part="option-input" /> - `}removeTag(e){this.tagList=[...this.tagList.filter((t=>t.term!==e.detail.value))]}_handleDragLeave(e){this.classList.remove("drag-focus"),this.classList.add("drop-possible")}_handleDragEnter(e){e.preventDefault(),this.classList.add("drag-focus"),this.classList.remove("drop-possible")}_handleDragDrop(e){if(e.preventDefault(),this.classList.remove("drop-possible"),this.classList.remove("drag-focus"),JSON.parse(e.dataTransfer.getData("text"))){let t=JSON.parse(e.dataTransfer.getData("text"));this.tagList=[...this.tagList.filter((e=>e.term!==t.term))];let s=this.tagList;s.push(t),this.tagList=[...s]}}_handleKeydown(e){"Enter"===e.key&&""!=this.shadowRoot.querySelector("input").value&&this._updateTaglist()}_handleKeyup(e){","===e.key&&""!=this.shadowRoot.querySelector("input").value&&this._updateTaglist()}_updateTaglist(){let e=this.shadowRoot.querySelector("input").value;e=e.replace(/,$/,"").trim(),this.tagList=[...this.tagList.filter((e=>e.term!==this.shadowRoot.querySelector("input").value))];let t=this.tagList;t.push({term:e,color:"grey"}),this.tagList=[...t],this.shadowRoot.querySelector("input").value=""}get slottedFieldObserver(){}validate(){return!this.value&&this.required&&(this.error=!0,this.errorMessage=this.requiredMessage||"required"),!this.error}_fireValueChanged(){this.dispatchEvent(new CustomEvent("value-changed",{bubbles:!1,cancelable:!1,composed:!1,detail:this}))}_fireTagListChanged(e){this.dispatchEvent(new CustomEvent("simple-fields-tag-list-changed",{bubbles:!0,cancelable:!0,composed:!0,detail:this}))}_onFocusout(e){super._onFocusout(e),""!=this.shadowRoot.querySelector("input").value&&this._updateTaglist()}_observeAndListen(e=!0){e?(this.addEventListener("click",this.focus),this.addEventListener("focusout",this._onFocusout),this.addEventListener("focusin",this._onFocusin)):(this.removeEventListener("click",this.focus),this.removeEventListener("focusout",this._onFocusout),this.removeEventListener("focusin",this._onFocusin))}connectedCallback(){super.connectedCallback(),window.addEventListener("simple-tag-dragstart",this._handleGlobalTagDrag.bind(this),{signal:this.windowControllers.signal}),window.addEventListener("simple-tag-drop",this._handleGlobalTagDrop.bind(this),{signal:this.windowControllers.signal})}disconnectedCallback(){this.windowControllers.abort(),super.disconnectedCallback()}}customElements.define(SimpleFieldsTagList.tag,SimpleFieldsTagList);export{SimpleFieldsTagList}; \ No newline at end of file + `}removeTag(e){this.tagList=[...this.tagList.filter((t=>t.term!==e.detail.value))]}_handleDragLeave(e){this.classList.remove("drag-focus"),this.classList.add("drop-possible")}_handleDragEnter(e){e.preventDefault(),this.classList.add("drag-focus"),this.classList.remove("drop-possible")}_handleDragDrop(e){if(e.preventDefault(),this.classList.remove("drop-possible"),this.classList.remove("drag-focus"),JSON.parse(e.dataTransfer.getData("text"))){let t=JSON.parse(e.dataTransfer.getData("text"));this.tagList=[...this.tagList.filter((e=>e.term!==t.term))];let s=this.tagList;s.push(t),this.tagList=[...s]}}_handleKeydown(e){"Enter"===e.key&&""!=this.shadowRoot.querySelector("input").value&&this._updateTaglist()}_handleKeyup(e){","===e.key&&""!=this.shadowRoot.querySelector("input").value&&this._updateTaglist()}_updateTaglist(){let e=this.shadowRoot.querySelector("input").value;e=e.replace(/,$/,"").trim(),this.tagList=[...this.tagList.filter((e=>e.term!==this.shadowRoot.querySelector("input").value&&""!=e.term&&null!==e.term))];let t=this.tagList;""!==e&&(this.singleValueOnly&&(t=[]),t.push({term:e,color:"grey"}),this.tagList=[...t]),this.shadowRoot.querySelector("input").value=""}get slottedFieldObserver(){}validate(){return!this.value&&this.required&&(this.error=!0,this.errorMessage=this.requiredMessage||"required"),!this.error}_fireValueChanged(){setTimeout((()=>{this._updateTaglist()}),0),this.dispatchEvent(new CustomEvent("value-changed",{bubbles:!1,cancelable:!1,composed:!1,detail:this}))}_fireTagListChanged(e){this.dispatchEvent(new CustomEvent("simple-fields-tag-list-changed",{bubbles:!0,cancelable:!0,composed:!0,detail:this}))}_onFocusout(e){super._onFocusout(e),""!=this.shadowRoot.querySelector("input").value&&this._updateTaglist()}_observeAndListen(e=!0){e?(this.addEventListener("click",this.focus),this.addEventListener("focusout",this._onFocusout),this.addEventListener("focusin",this._onFocusin)):(this.removeEventListener("click",this.focus),this.removeEventListener("focusout",this._onFocusout),this.removeEventListener("focusin",this._onFocusin))}connectedCallback(){super.connectedCallback(),window.addEventListener("simple-tag-dragstart",this._handleGlobalTagDrag.bind(this),{signal:this.windowControllers.signal}),window.addEventListener("simple-tag-drop",this._handleGlobalTagDrop.bind(this),{signal:this.windowControllers.signal})}disconnectedCallback(){this.windowControllers.abort(),super.disconnectedCallback()}}customElements.define(SimpleFieldsTagList.tag,SimpleFieldsTagList);export{SimpleFieldsTagList}; \ No newline at end of file diff --git a/build/es6/node_modules/@lrnwebcomponents/simple-icon/lib/simple-iconset-demo.js b/build/es6/node_modules/@lrnwebcomponents/simple-icon/lib/simple-iconset-demo.js index a96e6b9a01b..7902d2ccfa8 100644 --- a/build/es6/node_modules/@lrnwebcomponents/simple-icon/lib/simple-iconset-demo.js +++ b/build/es6/node_modules/@lrnwebcomponents/simple-icon/lib/simple-iconset-demo.js @@ -2,7 +2,7 @@ * Copyright 2018 The Pennsylvania State University * @license Apache-2.0, see License.md for full text. */ -import{html as t,svg as e,css as i,LitElement as o}from"../../../lit/index.js";import"./simple-icon-lite.js";import"./simple-icons.js";import{SimpleIconsetStore as s}from"./simple-iconset.js";import{SimpleIconIconsetsManifest as n}from"./simple-iconset-manifest.js";class SimpleIconsetDemo extends o{static get tag(){return"simple-iconset-demo"}static get styles(){return[i` +import{html as t,svg as e,css as i,LitElement as o}from"../../../lit/index.js";import"./simple-icon-lite.js";import"./simple-icons.js";import{SimpleIconsetStore as s}from"./simple-iconset.js";import{SimpleIconIconsetsManifest as n}from"./simple-iconset-manifest.js";import{HaxIconsetManifest as c}from"../../hax-iconset/lib/hax-iconset-manifest.js";class SimpleIconsetDemo extends o{static get tag(){return"simple-iconset-demo"}static get styles(){return[i` :host { display: block; box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), @@ -83,4 +83,4 @@ import{html as t,svg as e,css as i,LitElement as o}from"../../../lit/index.js";i `))} -
`))}static get properties(){return{exclude:{attribute:"exclude",type:String},iconsets:{type:Array},include:{attribute:"include",type:String},imports:{type:Array}}}constructor(){super(),window.SimpleIconset.requestAvailability(),this.imports=[],this._getIconsets()}updated(t){t.forEach(((t,e)=>{"imports"==e&&this._getIconsets()}))}_getIconsets(){let t=(this.imports.length<1?[n]:this.imports).flat(),e=(this.exclude||"").split(" "),i=(this.include||"").split(" ");this.iconsets=t.filter((t=>!!t&&!e.includes(t)&&(!this.include||i.includes(t))))}}customElements.define(SimpleIconsetDemo.tag,SimpleIconsetDemo);export{SimpleIconsetDemo}; \ No newline at end of file + `))}static get properties(){return{exclude:{attribute:"exclude",type:String},iconsets:{type:Array},include:{attribute:"include",type:String},imports:{type:Array}}}constructor(){super(),window.SimpleIconset.requestAvailability(),this.imports=[],this._getIconsets()}updated(t){t.forEach(((t,e)=>{"imports"==e&&this._getIconsets()}))}_getIconsets(){let t=(this.imports.length<1?[n,c]:this.imports).flat(),e=(this.exclude||"").split(" "),i=(this.include||"").split(" ");this.iconsets=t.filter((t=>!!t&&!e.includes(t)&&(!this.include||i.includes(t))))}}customElements.define(SimpleIconsetDemo.tag,SimpleIconsetDemo);export{SimpleIconsetDemo}; \ No newline at end of file