package.dist.prod.UI5ElementMetadata.js Maven / Gradle / Ivy
"use strict";import{camelToKebabCase as s,kebabToCamelCase as l}from"./util/StringHelper.js";import{getSlottedNodes as d}from"./util/SlotsHelper.js";import{getEffectiveScopingSuffixForTag as p}from"./CustomElementsScopeUtils.js";class u{constructor(t){this.metadata=t}getInitialState(){if(Object.prototype.hasOwnProperty.call(this,"_initialState"))return this._initialState;const t={};if(this.slotsAreManaged()){const o=this.getSlots();for(const[e,i]of Object.entries(o)){const n=i.propertyName||e;t[n]=[],t[l(n)]=t[n]}}return this._initialState=t,t}static validateSlotValue(t,r){return g(t,r)}getPureTag(){return this.metadata.tag||""}getFeatures(){return this.metadata.features||[]}getTag(){const t=this.metadata.tag;if(!t)return"";const r=p(t);return r?`${t}-${r}`:t}hasAttribute(t){const r=this.getProperties()[t];return r.type!==Object&&r.type!==Array&&!r.noAttribute}getPropertiesList(){return Object.keys(this.getProperties())}getAttributesList(){return this.getPropertiesList().filter(this.hasAttribute.bind(this)).map(s)}canSlotText(){return this.getSlots().default?.type===Node}hasSlots(){return!!Object.entries(this.getSlots()).length}hasIndividualSlots(){return this.slotsAreManaged()&&Object.values(this.getSlots()).some(t=>t.individualSlots)}slotsAreManaged(){return!!this.metadata.managedSlots}supportsF6FastNavigation(){return!!this.metadata.fastNavigation}getProperties(){return this.metadata.properties||(this.metadata.properties={}),this.metadata.properties}getEvents(){return this.metadata.events||(this.metadata.events={}),this.metadata.events}getSlots(){return this.metadata.slots||(this.metadata.slots={}),this.metadata.slots}isLanguageAware(){return!!this.metadata.languageAware}isThemeAware(){return!!this.metadata.themeAware}getShadowRootOptions(){return this.metadata.shadowRootOptions||{}}isFormAssociated(){return!!this.metadata.formAssociated}shouldInvalidateOnChildChange(t,r,o){const e=this.getSlots()[t].invalidateOnChildChange;if(e===void 0)return!1;if(typeof e=="boolean")return e;if(typeof e=="object"){if(r==="property"){if(e.properties===void 0)return!1;if(typeof e.properties=="boolean")return e.properties;if(Array.isArray(e.properties))return e.properties.includes(o);throw new Error("Wrong format for invalidateOnChildChange.properties: boolean or array is expected")}if(r==="slot"){if(e.slots===void 0)return!1;if(typeof e.slots=="boolean")return e.slots;if(Array.isArray(e.slots))return e.slots.includes(o);throw new Error("Wrong format for invalidateOnChildChange.slots: boolean or array is expected")}}throw new Error("Wrong format for invalidateOnChildChange: boolean or object is expected")}}const g=(a,t)=>(a&&d(a).forEach(r=>{if(!(r instanceof t.type))throw new Error(`The element is not of type ${t.type.toString()}`)}),a);export default u;
//# sourceMappingURL=UI5ElementMetadata.js.map