@paroicms/list-field-plugin 0.26.1 → 0.27.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.
|
@@ -1 +1,110 @@
|
|
|
1
|
-
|
|
1
|
+
function ht(r){return typeof r=="object"&&r!==null&&"j"in r}const _t={en:{en:"English",fr:"French",es:"Spanish",de:"German",it:"Italian",pt:"Portuguese"},fr:{en:"Anglais",fr:"Français",es:"Espagnol",de:"Allemand",it:"Italien",pt:"Portugais"},es:{en:"Inglés",fr:"Francés",es:"Español",de:"Alemán",it:"Italiano",pt:"Portugués"},de:{en:"Englisch",fr:"Französisch",es:"Spanisch",de:"Deutsch",it:"Italienisch",pt:"Portugiesisch"},it:{en:"Inglese",fr:"Francese",es:"Spagnolo",de:"Tedesco",it:"Italiano",pt:"Portoghese"},pt:{en:"Inglês",fr:"Francês",es:"Espanhol",de:"Alemão",it:"Italiano",pt:"Português"}},K=Object.keys(_t);function vt(r,{pluginLanguages:t,siteLanguages:e=[]}){if(t.includes(r)||K.includes(r)&&t.includes(r))return r;const s=e.find(i=>K.includes(i)&&t.includes(i));return s||(t.includes("en")?"en":t[0]??"en")}
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2019 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*/const H=globalThis,D=H.ShadowRoot&&(H.ShadyCSS===void 0||H.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,z=Symbol(),J=new WeakMap;let dt=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==z)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(D&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=J.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&J.set(e,t))}return t}toString(){return this.cssText}};const yt=r=>new dt(typeof r=="string"?r:r+"",void 0,z),ct=(r,...t)=>{const e=r.length===1?r[0]:t.reduce((s,i,n)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+r[n+1],r[0]);return new dt(e,r,z)},At=(r,t)=>{if(D)r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const s=document.createElement("style"),i=H.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,r.appendChild(s)}},Z=D?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return yt(e)})(r):r;
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright 2017 Google LLC
|
|
10
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
+
*/const{is:bt,defineProperty:Et,getOwnPropertyDescriptor:xt,getOwnPropertyNames:St,getOwnPropertySymbols:wt,getPrototypeOf:Ct}=Object,k=globalThis,G=k.trustedTypes,Pt=G?G.emptyScript:"",Ut=k.reactiveElementPolyfillSupport,L=(r,t)=>r,j={toAttribute(r,t){switch(t){case Boolean:r=r?Pt:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},ut=(r,t)=>!bt(r,t),Q={attribute:!0,type:String,converter:j,reflect:!1,useDefault:!1,hasChanged:ut};Symbol.metadata??=Symbol("metadata"),k.litPropertyMetadata??=new WeakMap;let x=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Q){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&Et(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=xt(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get:i,set(o){const a=i?.call(this);n?.call(this,o),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Q}static _$Ei(){if(this.hasOwnProperty(L("elementProperties")))return;const t=Ct(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(L("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(L("properties"))){const e=this.properties,s=[...St(e),...wt(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(Z(i))}else t!==void 0&&e.push(Z(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return At(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const n=(s.converter?.toAttribute!==void 0?s.converter:j).toAttribute(e,s.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const n=s.getPropertyOptions(i),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:j;this._$Em=i;const a=o.fromAttribute(e,n.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){const i=this.constructor,n=this[t];if(s??=i.getPropertyOptions(t),!((s.hasChanged??ut)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(i._$Eu(t,s))))return;this.C(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),n!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,n]of this._$Ep)this[i]=n;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,n]of s){const{wrapped:o}=n,a=this[i];o!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,n,a)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(e)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(t){}firstUpdated(t){}};x.elementStyles=[],x.shadowRootOptions={mode:"open"},x[L("elementProperties")]=new Map,x[L("finalized")]=new Map,Ut?.({ReactiveElement:x}),(k.reactiveElementVersions??=[]).push("2.1.1");
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Copyright 2017 Google LLC
|
|
15
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
+
*/const q=globalThis,O=q.trustedTypes,X=O?O.createPolicy("lit-html",{createHTML:r=>r}):void 0,pt="$lit$",g=`lit$${Math.random().toFixed(9).slice(2)}$`,ft="?"+g,Lt=`<${ft}>`,b=document,I=()=>b.createComment(""),M=r=>r===null||typeof r!="object"&&typeof r!="function",V=Array.isArray,It=r=>V(r)||typeof r?.[Symbol.iterator]=="function",B=`[ \t\n\f\r]`,P=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,tt=/-->/g,et=/>/g,_=RegExp(`>|${B}(?:([^\\s"'>=/]+)(${B}*=${B}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),st=/'/g,it=/"/g,$t=/^(?:script|style|textarea|title)$/i,Mt=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),y=Mt(1),E=Symbol.for("lit-noChange"),$=Symbol.for("lit-nothing"),rt=new WeakMap,A=b.createTreeWalker(b,129);function mt(r,t){if(!V(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return X!==void 0?X.createHTML(t):t}const Tt=(r,t)=>{const e=r.length-1,s=[];let i,n=t===2?"<svg>":t===3?"<math>":"",o=P;for(let a=0;a<e;a++){const l=r[a];let d,p,h=-1,u=0;for(;u<l.length&&(o.lastIndex=u,p=o.exec(l),p!==null);)u=o.lastIndex,o===P?p[1]==="!--"?o=tt:p[1]!==void 0?o=et:p[2]!==void 0?($t.test(p[2])&&(i=RegExp("</"+p[2],"g")),o=_):p[3]!==void 0&&(o=_):o===_?p[0]===">"?(o=i??P,h=-1):p[1]===void 0?h=-2:(h=o.lastIndex-p[2].length,d=p[1],o=p[3]===void 0?_:p[3]==='"'?it:st):o===it||o===st?o=_:o===tt||o===et?o=P:(o=_,i=void 0);const c=o===_&&r[a+1].startsWith("/>")?" ":"";n+=o===P?l+Lt:h>=0?(s.push(d),l.slice(0,h)+pt+l.slice(h)+g+c):l+g+(h===-2?a:c)}return[mt(r,n+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class T{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const a=t.length-1,l=this.parts,[d,p]=Tt(t,e);if(this.el=T.createElement(d,s),A.currentNode=this.el.content,e===2||e===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(i=A.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const h of i.getAttributeNames())if(h.endsWith(pt)){const u=p[o++],c=i.getAttribute(h).split(g),f=/([.?@])?(.*)/.exec(u);l.push({type:1,index:n,name:f[2],strings:c,ctor:f[1]==="."?Ot:f[1]==="?"?kt:f[1]==="@"?Rt:R}),i.removeAttribute(h)}else h.startsWith(g)&&(l.push({type:6,index:n}),i.removeAttribute(h));if($t.test(i.tagName)){const h=i.textContent.split(g),u=h.length-1;if(u>0){i.textContent=O?O.emptyScript:"";for(let c=0;c<u;c++)i.append(h[c],I()),A.nextNode(),l.push({type:2,index:++n});i.append(h[u],I())}}}else if(i.nodeType===8)if(i.data===ft)l.push({type:2,index:n});else{let h=-1;for(;(h=i.data.indexOf(g,h+1))!==-1;)l.push({type:7,index:n}),h+=g.length-1}n++}}static createElement(t,e){const s=b.createElement("template");return s.innerHTML=t,s}}function w(r,t,e=r,s){if(t===E)return t;let i=s!==void 0?e._$Co?.[s]:e._$Cl;const n=M(t)?void 0:t._$litDirective$;return i?.constructor!==n&&(i?._$AO?.(!1),n===void 0?i=void 0:(i=new n(r),i._$AT(r,e,s)),s!==void 0?(e._$Co??=[])[s]=i:e._$Cl=i),i!==void 0&&(t=w(r,i._$AS(r,t.values),i,s)),t}let Ht=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??b).importNode(e,!0);A.currentNode=i;let n=A.nextNode(),o=0,a=0,l=s[0];for(;l!==void 0;){if(o===l.index){let d;l.type===2?d=new C(n,n.nextSibling,this,t):l.type===1?d=new l.ctor(n,l.name,l.strings,this,t):l.type===6&&(d=new Nt(n,this,t)),this._$AV.push(d),l=s[++a]}o!==l?.index&&(n=A.nextNode(),o++)}return A.currentNode=b,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}};class C{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=$,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=w(this,t,e),M(t)?t===$||t==null||t===""?(this._$AH!==$&&this._$AR(),this._$AH=$):t!==this._$AH&&t!==E&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):It(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==$&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(b.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=T.createElement(mt(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const n=new Ht(i,this),o=n.u(this.options);n.p(e),this.T(o),this._$AH=n}}_$AC(t){let e=rt.get(t.strings);return e===void 0&&rt.set(t.strings,e=new T(t)),e}k(t){V(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new C(this.O(I()),this.O(I()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}}class R{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=$,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=$}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(n===void 0)t=w(this,t,e,0),o=!M(t)||t!==this._$AH&&t!==E,o&&(this._$AH=t);else{const a=t;let l,d;for(t=n[0],l=0;l<n.length-1;l++)d=w(this,a[s+l],e,l),d===E&&(d=this._$AH[l]),o||=!M(d)||d!==this._$AH[l],d===$?t=$:t!==$&&(t+=(d??"")+n[l+1]),this._$AH[l]=d}o&&!i&&this.j(t)}j(t){t===$?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ot extends R{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===$?void 0:t}}class kt extends R{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==$)}}class Rt extends R{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=w(this,t,e,0)??$)===E)return;const s=this._$AH,i=t===$&&s!==$||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==$&&(s===$||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class Nt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){w(this,t)}}const Bt={I:C},Ft=q.litHtmlPolyfillSupport;Ft?.(T,C),(q.litHtmlVersions??=[]).push("3.3.1");const jt=(r,t,e)=>{const s=e?.renderBefore??t;let i=s._$litPart$;if(i===void 0){const n=e?.renderBefore??null;s._$litPart$=i=new C(t.insertBefore(I(),n),n,void 0,e??{})}return i._$AI(r),i};
|
|
17
|
+
/**
|
|
18
|
+
* @license
|
|
19
|
+
* Copyright 2017 Google LLC
|
|
20
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
21
|
+
*/const W=globalThis;let S=class extends x{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=jt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return E}};S._$litElement$=!0,S.finalized=!0,W.litElementHydrateSupport?.({LitElement:S});const Dt=W.litElementPolyfillSupport;Dt?.({LitElement:S});(W.litElementVersions??=[]).push("4.2.1");
|
|
22
|
+
/**
|
|
23
|
+
* @license
|
|
24
|
+
* Copyright 2017 Google LLC
|
|
25
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
26
|
+
*/const zt={CHILD:2},qt=r=>(...t)=>({_$litDirective$:r,values:t});class Vt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
27
|
+
/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2020 Google LLC
|
|
30
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
31
|
+
*/const{I:Wt}=Bt,nt=()=>document.createComment(""),U=(r,t,e)=>{const s=r._$AA.parentNode,i=t===void 0?r._$AB:t._$AA;if(e===void 0){const n=s.insertBefore(nt(),i),o=s.insertBefore(nt(),i);e=new Wt(n,o,r,r.options)}else{const n=e._$AB.nextSibling,o=e._$AM,a=o!==r;if(a){let l;e._$AQ?.(r),e._$AM=r,e._$AP!==void 0&&(l=r._$AU)!==o._$AU&&e._$AP(l)}if(n!==i||a){let l=e._$AA;for(;l!==n;){const d=l.nextSibling;s.insertBefore(l,i),l=d}}}return e},v=(r,t,e=r)=>(r._$AI(t,e),r),Yt={},Kt=(r,t=Yt)=>r._$AH=t,Jt=r=>r._$AH,F=r=>{r._$AR(),r._$AA.remove()};
|
|
32
|
+
/**
|
|
33
|
+
* @license
|
|
34
|
+
* Copyright 2017 Google LLC
|
|
35
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
36
|
+
*/const ot=(r,t,e)=>{const s=new Map;for(let i=t;i<=e;i++)s.set(r[i],i);return s},Zt=qt(class extends Vt{constructor(r){if(super(r),r.type!==zt.CHILD)throw Error("repeat() can only be used in text expressions")}dt(r,t,e){let s;e===void 0?e=t:t!==void 0&&(s=t);const i=[],n=[];let o=0;for(const a of r)i[o]=s?s(a,o):o,n[o]=e(a,o),o++;return{values:n,keys:i}}render(r,t,e){return this.dt(r,t,e).values}update(r,[t,e,s]){const i=Jt(r),{values:n,keys:o}=this.dt(t,e,s);if(!Array.isArray(i))return this.ut=o,n;const a=this.ut??=[],l=[];let d,p,h=0,u=i.length-1,c=0,f=n.length-1;for(;h<=u&&c<=f;)if(i[h]===null)h++;else if(i[u]===null)u--;else if(a[h]===o[c])l[c]=v(i[h],n[c]),h++,c++;else if(a[u]===o[f])l[f]=v(i[u],n[f]),u--,f--;else if(a[h]===o[f])l[f]=v(i[h],n[f]),U(r,l[f+1],i[h]),h++,f--;else if(a[u]===o[c])l[c]=v(i[u],n[c]),U(r,i[h],i[u]),u--,c++;else if(d===void 0&&(d=ot(o,c,f),p=ot(a,h,u)),d.has(a[h]))if(d.has(a[u])){const m=p.get(o[c]),N=m!==void 0?i[m]:null;if(N===null){const Y=U(r,i[h]);v(Y,n[c]),l[c]=Y}else l[c]=v(N,n[c]),U(r,i[h],N),i[m]=null;c++}else F(i[u]),u--;else F(i[h]),h++;for(;c<=f;){const m=U(r,l[f+1]);v(m,n[c]),l[c++]=m}for(;h<=u;){const m=i[h++];m!==null&&F(m)}return this.ut=o,Kt(r,l),E}}),Gt={placeholder:"Bearbeiten…",emptyList:"Keine Elemente gefunden"},Qt={ListField:Gt},Xt={placeholder:"Edit…",emptyList:"No items found"},te={ListField:Xt},ee={placeholder:"Editar…",emptyList:"Lista vacía"},se={ListField:ee},ie={placeholder:"Éditer…",emptyList:"Liste vide"},re={ListField:ie},ne={placeholder:"Modifica…",emptyList:"Nessun elemento trovato"},oe={ListField:ne},le={placeholder:"Editar…",emptyList:"Nenhum item encontrado"},ae={ListField:le},lt={en:te,fr:re,es:se,de:Qt,it:oe,pt:ae};class he{_ctx;constructor(t){this._ctx={language:"",dict:{}},this.setLanguage(t)}setLanguage(t,e){const s=Object.keys(lt),i=vt(t,{pluginLanguages:s,siteLanguages:e}),n=i,o={};gt(lt[n],"",o),this._ctx={language:i,dict:o}}t(t){return this._ctx.dict[t]??t}}function gt(r,t,e){for(const s in r){const i=r[s],n=t?`${t}.${s}`:s;i&&typeof i=="object"&&!Array.isArray(i)?gt(i,n,e):typeof i=="string"&&(e[n]=i)}}class de extends S{static properties={value:{type:String},placeholder:{type:String},disabled:{type:Boolean,reflect:!0}};static styles=ct`
|
|
37
|
+
:host { display: contents; }
|
|
38
|
+
input { flex: 1; border: none; outline: none; font: inherit; background: transparent; }
|
|
39
|
+
`;value="";placeholder="";disabled=!1;focus(){this.renderRoot.querySelector("input")?.focus()}render(){return y`<input
|
|
40
|
+
class="input"
|
|
41
|
+
.value=${this.value}
|
|
42
|
+
?disabled=${this.disabled}
|
|
43
|
+
@input=${this.#t}
|
|
44
|
+
placeholder=${this.placeholder}
|
|
45
|
+
aria-disabled=${this.disabled?"true":"false"}
|
|
46
|
+
tabindex=${this.disabled?-1:0}
|
|
47
|
+
/>`}#t(t){if(!t.currentTarget||this.disabled)return;const e=t.currentTarget.value;this.value=e,this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:e},bubbles:!0,composed:!0}))}}customElements.define("pcms-list-field-item-text",de);class ce extends S{static properties={language:{type:String}};static styles=ct`
|
|
48
|
+
:host {
|
|
49
|
+
display: block;
|
|
50
|
+
font: inherit;
|
|
51
|
+
--pcms-lf-gap: 0.5rem;
|
|
52
|
+
--pcms-lf-border-color: #d0d7de;
|
|
53
|
+
--pcms-lf-border-radius: 4px;
|
|
54
|
+
--pcms-lf-handle-color: #666;
|
|
55
|
+
--pcms-lf-handle-color-hover: #111;
|
|
56
|
+
--pcms-lf-item-bg: #fff;
|
|
57
|
+
--pcms-lf-item-bg-drag: #f5f7fa;
|
|
58
|
+
}
|
|
59
|
+
.root { display: flex; flex-direction: column; gap: var(--pcms-lf-gap); }
|
|
60
|
+
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--pcms-lf-gap); }
|
|
61
|
+
.item { display: flex; align-items: stretch; gap: 0.25rem; background: var(--pcms-lf-item-bg); border: 1px solid var(--pcms-lf-border-color); border-radius: var(--pcms-lf-border-radius); padding: 0.25rem 0.5rem; position: relative; min-height: 2.25rem; box-sizing: border-box; }
|
|
62
|
+
.item.dragging { background: var(--pcms-lf-item-bg-drag); box-shadow: 0 2px 6px rgba(0,0,0,0.15); z-index: 10; }
|
|
63
|
+
.item.source-collapsed { height: 0 !important; padding: 0 !important; border: 0 !important; margin: 0 !important; min-height: 0 !important; overflow: hidden; }
|
|
64
|
+
.drag-ghost { position: fixed; pointer-events: none; box-sizing: border-box; background: var(--pcms-lf-item-bg-drag); border: 1px solid var(--pcms-lf-border-color); border-radius: var(--pcms-lf-border-radius); padding: 0.25rem 0.5rem; display: flex; gap: 0.25rem; align-items: stretch; box-shadow: 0 4px 10px rgba(0,0,0,0.2); opacity: 0.95; }
|
|
65
|
+
.handle { cursor: grab; display: flex; align-items: center; padding: 0 0.25rem; user-select: none; color: var(--pcms-lf-handle-color); }
|
|
66
|
+
.handle:active { cursor: grabbing; }
|
|
67
|
+
.handle:hover { color: var(--pcms-lf-handle-color-hover); }
|
|
68
|
+
.input { flex: 1; border: none; outline: none; font: inherit; background: transparent; }
|
|
69
|
+
.deleteBtn, .addBtn { border: 1px solid var(--pcms-lf-border-color); background: #fafbfc; border-radius: var(--pcms-lf-border-radius); cursor: pointer; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; }
|
|
70
|
+
.deleteBtn:hover { background: #ffeaea; }
|
|
71
|
+
.addBtn { align-self: flex-start; }
|
|
72
|
+
.empty { font-size: 0.85rem; color: #777; padding: 0.25rem 0.5rem; }
|
|
73
|
+
.placeholder { height: 2.25rem; border: 1px dashed var(--pcms-lf-border-color); border-radius: var(--pcms-lf-border-radius); }
|
|
74
|
+
`;#t=[];#a=0;get items(){return this.#t.map(t=>t.value)}set items(t){const e=Array.isArray(t)?t:[],s=[];for(let i=0;i<e.length;++i){const n=this.#t[i];s.push({id:n?.id??String(this.#a++),value:String(e[i])})}this.#t=s,this.requestUpdate("items")}language="en";#e;#s;#r=0;#n=new he("en");#h=0;#d=0;#i=null;#o;willUpdate(t){t.has("language")&&this.#n.setLanguage(this.language)}render(){return y`<div class="root">
|
|
75
|
+
<ul class="list">
|
|
76
|
+
${this.items.length?this.#f():y`<div class="empty">${this.#n.t("ListField.emptyList")}</div>`}
|
|
77
|
+
</ul>
|
|
78
|
+
<button type="button" class="addBtn" @click=${()=>this.#p()} aria-label="add">+</button>
|
|
79
|
+
</div>`}destroy(){}async#p(){this.#t=[...this.#t,{id:String(this.#a++),value:""}],this.requestUpdate("items"),this.#l(),await this.updateComplete;const t=this.renderRoot.querySelectorAll("pcms-list-field-item-text");t[t.length-1]?.focus?.()}#l(){this.dispatchEvent(new CustomEvent("items-changed",{detail:{items:[...this.items]},bubbles:!0,composed:!0}))}#f(){const t=this.#e,e=this.#s,s=this.#t,i=Zt(s,a=>a.id,(a,l)=>{const d=l===t,p=d&&e!==void 0&&e!==t,h=d&&!p?`transform: translateY(${this.#r}px);`:"";return y`
|
|
80
|
+
${t!==void 0&&e!==void 0&&e===l&&e!==t?y`<li class="placeholder" data-placeholder="true"></li>`:null}
|
|
81
|
+
<li
|
|
82
|
+
class="item ${d?"dragging":""} ${p?"source-collapsed":""}"
|
|
83
|
+
style=${h}
|
|
84
|
+
aria-grabbed=${d?"true":"false"}
|
|
85
|
+
data-entry-id=${a.id}
|
|
86
|
+
>
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
class="handle"
|
|
90
|
+
@pointerdown=${c=>this.#g(c,l)}
|
|
91
|
+
title="move"
|
|
92
|
+
aria-label="move"
|
|
93
|
+
tabindex="-1"
|
|
94
|
+
>⇳</button>
|
|
95
|
+
<pcms-list-field-item-text
|
|
96
|
+
.value=${a.value}
|
|
97
|
+
.placeholder=${this.#n.t("ListField.placeholder")}
|
|
98
|
+
@value-changed=${c=>this.#$(a.id,c.detail.value)}
|
|
99
|
+
></pcms-list-field-item-text>
|
|
100
|
+
<button
|
|
101
|
+
type="button"
|
|
102
|
+
class="deleteBtn"
|
|
103
|
+
@click=${()=>this.#m(l)}
|
|
104
|
+
aria-label="delete"
|
|
105
|
+
>🗑</button>
|
|
106
|
+
</li>`}),n=t!==void 0&&e!==void 0&&e===s.length&&e!==t?y`<li class="placeholder" data-placeholder="true"></li>`:null,o=t!==void 0&&this.#i&&e!==void 0&&e!==t?(()=>{const a=this.#i;if(!a)return null;const l=a.top+this.#r;return y`<div class="drag-ghost" style=${`top:${l}px;left:${a.left}px;width:${a.width}px;`}>
|
|
107
|
+
<button type="button" class="handle" title="move" aria-label="move" tabindex="-1">⇳</button>
|
|
108
|
+
<pcms-list-field-item-text .value=${this.#t[t].value} .placeholder=${this.#n.t("ListField.placeholder")} disabled aria-hidden="true"></pcms-list-field-item-text>
|
|
109
|
+
<button type="button" class="deleteBtn" aria-hidden="true" tabindex="-1">🗑</button>
|
|
110
|
+
</div>`})():null;return[i,n,o]}#$(t,e){const s=this.#t.findIndex(o=>o.id===t);if(s===-1)return;const i=e.trim();if(this.#t[s].value===i)return;const n=[...this.#t];n[s]={...n[s],value:i},this.#t=n,this.requestUpdate("items"),this.#l()}async#m(t){const e=[...this.#t];e.splice(t,1),this.#t=e,this.requestUpdate("items"),this.#l(),await this.updateComplete;const s=this.renderRoot.querySelectorAll("pcms-list-field-item-text");if(!s.length)return;const i=Math.min(t,s.length-1);s[i]?.focus?.()}#g(t,e){const s=t.currentTarget;this.#o=s,this.#e=e,this.#s=void 0,this.#d=t.clientY;const i=s.closest("li.item")||void 0;if(i){const n=i.getBoundingClientRect();this.#i={top:n.top,left:n.left,width:n.width,height:n.height}}else this.#i=null;s.setPointerCapture(t.pointerId),s.addEventListener("pointermove",this.#c),s.addEventListener("pointerup",this.#u,{once:!0}),s.addEventListener("pointercancel",this.#v,{once:!0})}#c=t=>{if(this.#e===void 0)return;const e=t.clientY-this.#d;this.#r=e,cancelAnimationFrame(this.#h),this.#h=requestAnimationFrame(()=>{this.#_(t.clientY),this.requestUpdate()})};#_(t){if(this.#e===void 0)return;const e=this.renderRoot.querySelector("ul.list");if(!e)return;const s=Array.from(e.querySelectorAll("li.item")),i=this.#e;if(!s[i])return;const n=[];for(let d=0;d<s.length;++d)d!==i&&n.push({el:s[d],fullIndex:d});let o=n.length;for(let d=0;d<n.length;++d){const{el:p}=n[d],h=p.getBoundingClientRect(),u=h.top+h.height/2;if(t<u){o=d;break}}let a;o===n.length?a=s.length:a=n[o].fullIndex;let l=a;i<a&&(l=a-1),l===i?this.#s=void 0:this.#s=a}#u=()=>{if(this.#e===void 0)return;const t=this.#e,e=this.#s;if(e!==void 0){let s=e;if(t<e&&(s=e-1),s<0&&(s=0),t!==s){const i=[...this.#t],[n]=i.splice(t,1);i.splice(s,0,n),this.#t=i,this.requestUpdate("items"),this.#l()}}this.#e=void 0,this.#s=void 0,this.#r=0,this.#i=null,this.#o&&(this.#o.removeEventListener("pointermove",this.#c),this.#o=void 0),this.requestUpdate()};#v=()=>{this.#u()}}customElements.define("pcms-list-field",ce);const _e={create:pe,init:ue};function ue({pluginBaseUrl:r}){const t=`${r}/admin-ui-plugin.css`,e=document.createElement("link");e.rel="stylesheet",e.href=t,document.head.appendChild(e)}function pe(r){const{fieldType:t,initialValue:e}=r;if(t.dataType!=="json")throw new Error(`field type '${t.name}' is incompatible with list-field plugin, needs data type 'json'`);if(e!==void 0&&!ht(e))throw new Error(`field type '${t.name}' is incompatible, should be a json, got '${typeof e}'`);const s=document.createElement("pcms-list-field");return s.items=at(e),s.language=r.language,s.addEventListener("items-changed",i=>{const n=i.detail;r.setModifiedValue({j:n.items})}),{element:s,setLanguage:i=>{s.language=i},setValue:i=>{s.items=at(i)},getValue:()=>({j:[...s.items]}),dispose:()=>s.destroy()}}function at(r){return ht(r)&&Array.isArray(r.j)?r.j.map(t=>String(t)):[]}export{_e as default};
|