@paroicms/list-field-plugin 0.27.0 → 0.28.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.
|
@@ -8,12 +8,12 @@ function ht(r){return typeof r=="object"&&r!==null&&"j"in r}const _t={en:{en:"En
|
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
10
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}},
|
|
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}},pt=(r,t)=>!bt(r,t),Q={attribute:!0,type:String,converter:j,reflect:!1,useDefault:!1,hasChanged:pt};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??pt)(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
12
|
/**
|
|
13
13
|
* @license
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
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,
|
|
16
|
+
*/const q=globalThis,O=q.trustedTypes,X=O?O.createPolicy("lit-html",{createHTML:r=>r}):void 0,ut="$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,u,h=-1,p=0;for(;p<l.length&&(o.lastIndex=p,u=o.exec(l),u!==null);)p=o.lastIndex,o===P?u[1]==="!--"?o=tt:u[1]!==void 0?o=et:u[2]!==void 0?($t.test(u[2])&&(i=RegExp("</"+u[2],"g")),o=_):u[3]!==void 0&&(o=_):o===_?u[0]===">"?(o=i??P,h=-1):u[1]===void 0?h=-2:(h=o.lastIndex-u[2].length,d=u[1],o=u[3]===void 0?_:u[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)+ut+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,u]=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(ut)){const p=u[o++],c=i.getAttribute(h).split(g),f=/([.?@])?(.*)/.exec(p);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),p=h.length-1;if(p>0){i.textContent=O?O.emptyScript:"";for(let c=0;c<p;c++)i.append(h[c],I()),A.nextNode(),l.push({type:2,index:++n});i.append(h[p],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
17
|
/**
|
|
18
18
|
* @license
|
|
19
19
|
* Copyright 2017 Google LLC
|
|
@@ -33,7 +33,7 @@ function ht(r){return typeof r=="object"&&r!==null&&"j"in r}const _t={en:{en:"En
|
|
|
33
33
|
* @license
|
|
34
34
|
* Copyright 2017 Google LLC
|
|
35
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,
|
|
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,u,h=0,p=i.length-1,c=0,f=n.length-1;for(;h<=p&&c<=f;)if(i[h]===null)h++;else if(i[p]===null)p--;else if(a[h]===o[c])l[c]=v(i[h],n[c]),h++,c++;else if(a[p]===o[f])l[f]=v(i[p],n[f]),p--,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[p]===o[c])l[c]=v(i[p],n[c]),U(r,i[h],i[p]),p--,c++;else if(d===void 0&&(d=ot(o,c,f),u=ot(a,h,p)),d.has(a[h]))if(d.has(a[p])){const m=u.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[p]),p--;else F(i[h]),h++;for(;c<=f;){const m=U(r,l[f+1]);v(m,n[c]),l[c++]=m}for(;h<=p;){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
37
|
:host { display: contents; }
|
|
38
38
|
input { flex: 1; border: none; outline: none; font: inherit; background: transparent; }
|
|
39
39
|
`;value="";placeholder="";disabled=!1;focus(){this.renderRoot.querySelector("input")?.focus()}render(){return y`<input
|
|
@@ -71,15 +71,15 @@ function ht(r){return typeof r=="object"&&r!==null&&"j"in r}const _t={en:{en:"En
|
|
|
71
71
|
.addBtn { align-self: flex-start; }
|
|
72
72
|
.empty { font-size: 0.85rem; color: #777; padding: 0.25rem 0.5rem; }
|
|
73
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(
|
|
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(){this.#n.setLanguage(this.language)}render(){return y`<div class="root">
|
|
75
75
|
<ul class="list">
|
|
76
76
|
${this.items.length?this.#f():y`<div class="empty">${this.#n.t("ListField.emptyList")}</div>`}
|
|
77
77
|
</ul>
|
|
78
|
-
<button type="button" class="addBtn" @click=${()=>this.#
|
|
79
|
-
</div>`}destroy(){}async#
|
|
78
|
+
<button type="button" class="addBtn" @click=${()=>this.#u()} aria-label="add">+</button>
|
|
79
|
+
</div>`}destroy(){}async#u(){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,u=d&&e!==void 0&&e!==t,h=d&&!u?`transform: translateY(${this.#r}px);`:"";return y`
|
|
80
80
|
${t!==void 0&&e!==void 0&&e===l&&e!==t?y`<li class="placeholder" data-placeholder="true"></li>`:null}
|
|
81
81
|
<li
|
|
82
|
-
class="item ${d?"dragging":""} ${
|
|
82
|
+
class="item ${d?"dragging":""} ${u?"source-collapsed":""}"
|
|
83
83
|
style=${h}
|
|
84
84
|
aria-grabbed=${d?"true":"false"}
|
|
85
85
|
data-entry-id=${a.id}
|
|
@@ -107,4 +107,4 @@ function ht(r){return typeof r=="object"&&r!==null&&"j"in r}const _t={en:{en:"En
|
|
|
107
107
|
<button type="button" class="handle" title="move" aria-label="move" tabindex="-1">⇳</button>
|
|
108
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
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.#
|
|
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.#p,{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:u}=n[d],h=u.getBoundingClientRect(),p=h.top+h.height/2;if(t<p){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}#p=()=>{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.#p()}}customElements.define("pcms-list-field",ce);const _e={create:ue,init:pe};function pe({pluginBaseUrl:r}){const t=`${r}/admin-ui-plugin.css`,e=document.createElement("link");e.rel="stylesheet",e.href=t,document.head.appendChild(e)}function ue(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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/list-field-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "List field plugin for ParoiCMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paroicms",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"clear": "rimraf backend/dist/* admin-ui-plugin/dist/*"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@paroicms/script-lib": "0.3.
|
|
28
|
+
"@paroicms/script-lib": "0.3.2",
|
|
29
29
|
"arktype": "~2.1.20"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@paroicms/public-server-lib": "0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@paroicms/public-anywhere-lib": "0.
|
|
37
|
-
"@paroicms/public-server-lib": "0.
|
|
36
|
+
"@paroicms/public-anywhere-lib": "0.37.0",
|
|
37
|
+
"@paroicms/public-server-lib": "0.47.0",
|
|
38
38
|
"@types/node": "~24.0.1",
|
|
39
39
|
"rimraf": "~6.0.1",
|
|
40
40
|
"typescript": "~5.9.2"
|