@paroicms/list-field-plugin 0.12.0 → 0.14.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 @@
|
|
|
1
|
-
import{delegateEvents as F,addEventListener as b,effect as L,setAttribute as k,
|
|
1
|
+
import{delegateEvents as F,template as p,addEventListener as b,effect as L,setAttribute as k,use as I,insert as f,createComponent as m}from"https://esm.sh/solid-js@1.9.4/web";import{createMemo as V,onMount as x,Index as A,createRoot as j,createSignal as g}from"https://esm.sh/solid-js@1.9.4";var h=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function v(e,s,t){for(const[n,l]of Object.entries(s)){const i=`${t}.${n}`;e[i]=l,h(l)&&v(e,l,i)}}function w(e){const s={...e};for(const[t,n]of Object.entries(e))h(n)&&v(s,n,t);return s}var O=e=>e;function T(e,s=O){return(t,...n)=>{t[0]==="."&&(t=t.slice(1));const l=e()?.[t];switch(typeof l){case"function":return l(...n);case"string":return s(l,n[0]);default:return l}}}const C={placeholder:"Edit...",emptyList:"No items found"},D={ListField:C},E={placeholder:"Éditer...",emptyList:"Liste vide"},B={ListField:E},$={en:D,fr:B};function _(e){const s=V((()=>{const n=e(),l=n in $?n:"en";return w($[l])}));return{t:T(s)}}var M=p('<div class=LFInputField><input class=LFInputField-input type=text><button type=button class="pi pi-trash LFInputField-delete LFIconBtn">');function R({language:e,value:s,handleDelete:t,onChange:n}){const{t:l}=_(e);let i;return x((()=>{i?.focus()})),(()=>{var u=M(),a=u.firstChild,o=a.nextSibling;a.$$input=c=>n(c.currentTarget.value);var r=i;return typeof r=="function"?I(r,a):i=a,b(o,"click",t,!0),L((()=>k(a,"placeholder",l("ListField.placeholder")))),L((()=>a.value=s())),u})()}F(["input","click"]);var S=p("<ul class=LFList>"),N=p("<div class=LFList-empty>"),P=p("<li class=LFListItem>");function U(e){const{t:s}=_(e.language);let t;return(()=>{var n=S(),l=t;return typeof l=="function"?I(l,n):t=n,f(n,m(A,{get each(){return e.values()},get fallback(){return(()=>{var i=N();return f(i,(()=>s("ListField.emptyList"))),i})()},children:(i,u)=>(()=>{var a=P();return f(a,m(R,{onChange:o=>{e.updateValue(u,o)},value:i,get language(){return e.language},handleDelete:()=>e.handleDelete(u)})),a})()})),n})()}var q=p('<div class=LFApp><button type=button class="pi pi-plus LFIconBtn LFApp-addItemBtn">');function z(e){const{language:s,list:t,setList:n,itemIndexes:l}=e,i=()=>{n([...t(),""],[...l(),l().length])},u=r=>{const c=[...t()];c.splice(r,1);const d=[...l()];d.splice(r,1),n(c,d)},a=(r,c)=>{const d=[...t()];d[r]=c,n(d,l())},o=(r,c)=>{const d=[...l()];d.splice(c,0,d.splice(r,1)[0]),n(t(),d)};return(()=>{var r=q(),c=r.firstChild;return f(r,m(U,{changeOrder:o,updateValue:a,handleDelete:u,language:s,values:t}),c),c.$$click=i,r})()}F(["click"]);const Q={create:H,init:G};function G({pluginBaseUrl:e}){const s=`${e}/bo-plugin.css`,t=document.createElement("link");t.rel="stylesheet",t.href=s,document.head.appendChild(t)}function H(e){if(e.fieldType.dataType!=="json")throw new Error(`data type '${e.fieldType.dataType}' is incompatible, should be 'json'`);return j((s=>{const[t,n]=g(e.initialValue??[]),[l,i]=g(y(e.initialValue??[])),[u,a]=g(e.language);return{element:m(z,{language:u,list:t,setList:(o,r)=>{n(o),i(r),e.setModifiedValue(o)},itemIndexes:l}),setLanguage:a,setValue:(o=[])=>{n(o),i(y(o))},getValue:t,dispose:s}}))}function y(e){return e.map(((s,t)=>t))}export{Q 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.14.0",
|
|
4
4
|
"description": "List field plugin for ParoiCMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paroicms",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"@paroicms/public-server-lib": "0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@paroicms/public-anywhere-lib": "0.
|
|
35
|
-
"@paroicms/public-bo-lib": "0.19.
|
|
36
|
-
"@paroicms/public-server-lib": "0.
|
|
34
|
+
"@paroicms/public-anywhere-lib": "0.18.0",
|
|
35
|
+
"@paroicms/public-bo-lib": "0.19.5",
|
|
36
|
+
"@paroicms/public-server-lib": "0.25.0",
|
|
37
37
|
"@solid-primitives/i18n": "~2.1.1",
|
|
38
38
|
"@types/node": "~22.10.7",
|
|
39
39
|
"primeicons": "^7.0.0",
|