@paroicms/list-field-plugin 0.19.0 → 0.20.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 I,template as p,addEventListener as w,effect as $,setAttribute as V,use as v,insert as m,createComponent as g}from"https://esm.sh/solid-js@1.9.7/web";import{createMemo as A,onMount as x,Index as E,createRoot as O,createSignal as L}from"https://esm.sh/solid-js@1.9.7";function _(e){return typeof e=="object"&&e!==null&&"j"in e}const b=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function j(e,s,t){for(const[n,i]of Object.entries(s)){const l=`${t}.${n}`;e[l]=i,b(i)&&j(e,i,l)}}function C(e){const s={...e};for(const[t,n]of Object.entries(e))b(n)&&j(s,n,t);return s}const D=e=>e;function T(e,s=D){return(t,...n)=>{t[0]==="."&&(t=t.slice(1));const i=e()?.[t];switch(typeof i){case"function":return i(...n);case"string":return s(i,n[0]);default:return i}}}const B={placeholder:"Edit...",emptyList:"No items found"},M={ListField:B},R={placeholder:"Éditer...",emptyList:"Liste vide"},S={ListField:R},y={en:M,fr:S};function k(e){const s=A((()=>{const n=e(),i=n in y?n:"en";return C(y[i])}));return{t:T(s)}}var J=p('<div class=LFInputField><input class=LFInputField-input type=text><button type=button class="pi pi-trash LFInputField-delete LFIconBtn">');function N({language:e,value:s,handleDelete:t,onChange:n}){const{t:i}=k(e);let l;return x((()=>{l?.focus()})),(()=>{var u=J(),c=u.firstChild,d=c.nextSibling;c.$$input=a=>n(a.currentTarget.value);var r=l;return typeof r=="function"?v(r,c):l=c,w(d,"click",t,!0),$((()=>V(c,"placeholder",i("ListField.placeholder")))),$((()=>c.value=s())),u})()}I(["input","click"]);var P=p("<ul class=LFList>"),U=p("<div class=LFList-empty>"),q=p("<li class=LFListItem>");function z(e){const{t:s}=k(e.language);let t;return(()=>{var n=P(),i=t;return typeof i=="function"?v(i,n):t=n,m(n,g(E,{get each(){return e.values()},get fallback(){return(()=>{var l=U();return m(l,(()=>s("ListField.emptyList"))),l})()},children:(l,u)=>(()=>{var c=q();return m(c,g(N,{onChange:d=>{e.updateValue(u,d)},value:l,get language(){return e.language},handleDelete:()=>e.handleDelete(u)})),c})()})),n})()}var G=p('<div class=LFApp><button type=button class="pi pi-plus LFIconBtn LFApp-addItemBtn">');function H(e){const{language:s,list:t,setList:n,itemIndexes:i}=e,l=()=>{n([...t(),""],[...i(),i().length])},u=r=>{const a=[...t()];a.splice(r,1);const o=[...i()];o.splice(r,1),n(a,o)},c=(r,a)=>{const o=[...t()];o[r]=a,n(o,i())},d=(r,a)=>{const o=[...i()];o.splice(a,0,o.splice(r,1)[0]),n(t(),o)};return(()=>{var r=G(),a=r.firstChild;return m(r,g(z,{changeOrder:d,updateValue:c,handleDelete:u,language:s,values:t}),a),a.$$click=l,r})()}I(["click"]);const Y={create:Q,init:K};function K({pluginBaseUrl:e}){const s=`${e}/admin-ui-plugin.css`,t=document.createElement("link");t.rel="stylesheet",t.href=s,document.head.appendChild(t)}function Q(e){const{fieldType:s,initialValue:t}=e;if(s.dataType!=="json")throw new Error(`field type '${s.name}' is incompatible with list-field plugin, needs data type 'json'`);if(t!==void 0&&!_(t))throw new Error(`field type '${s.name}' is incompatible, should be a json, got '${typeof t}'`);const n=h(t);return O((i=>{const[l,u]=L(n),[c,d]=L(F(n)),[r,a]=L(e.language);return{element:g(H,{language:r,list:l,setList:(o,f)=>{u(o),d(f),e.setModifiedValue({j:o})},itemIndexes:c}),setLanguage:a,setValue:o=>{const f=h(o);u(f),d(F(f))},getValue:()=>({j:l}),dispose:i}}))}function F(e){return e.map(((s,t)=>t))}function h(e){return _(e)&&Array.isArray(e.j)?e.j:[]}export{Y as default};
1
+ import{delegateEvents as I,template as p,addEventListener as w,effect as $,setAttribute as V,use as v,insert as m,createComponent as g}from"https://esm.sh/solid-js@1.9.7/web";import{createMemo as A,onMount as x,Index as E,createRoot as O,createSignal as L}from"https://esm.sh/solid-js@1.9.7";function _(e){return typeof e=="object"&&e!==null&&"j"in e}const b=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function j(e,s,t){for(const[n,i]of Object.entries(s)){const l=`${t}.${n}`;e[l]=i,b(i)&&j(e,i,l)}}function C(e){const s={...e};for(const[t,n]of Object.entries(e))b(n)&&j(s,n,t);return s}const D=e=>e;function T(e,s=D){return(t,...n)=>{t[0]==="."&&(t=t.slice(1));const i=e()?.[t];switch(typeof i){case"function":return i(...n);case"string":return s(i,n[0]);default:return i}}}const B={placeholder:"Edit",emptyList:"No items found"},M={ListField:B},R={placeholder:"Éditer",emptyList:"Liste vide"},S={ListField:R},y={en:M,fr:S};function k(e){const s=A((()=>{const n=e(),i=n in y?n:"en";return C(y[i])}));return{t:T(s)}}var J=p('<div class=LFInputField><input class=LFInputField-input type=text><button type=button class="pi pi-trash LFInputField-delete LFIconBtn">');function N({language:e,value:s,handleDelete:t,onChange:n}){const{t:i}=k(e);let l;return x((()=>{l?.focus()})),(()=>{var u=J(),c=u.firstChild,d=c.nextSibling;c.$$input=a=>n(a.currentTarget.value);var r=l;return typeof r=="function"?v(r,c):l=c,w(d,"click",t,!0),$((()=>V(c,"placeholder",i("ListField.placeholder")))),$((()=>c.value=s())),u})()}I(["input","click"]);var P=p("<ul class=LFList>"),U=p("<div class=LFList-empty>"),q=p("<li class=LFListItem>");function z(e){const{t:s}=k(e.language);let t;return(()=>{var n=P(),i=t;return typeof i=="function"?v(i,n):t=n,m(n,g(E,{get each(){return e.values()},get fallback(){return(()=>{var l=U();return m(l,(()=>s("ListField.emptyList"))),l})()},children:(l,u)=>(()=>{var c=q();return m(c,g(N,{onChange:d=>{e.updateValue(u,d)},value:l,get language(){return e.language},handleDelete:()=>e.handleDelete(u)})),c})()})),n})()}var G=p('<div class=LFApp><button type=button class="pi pi-plus LFIconBtn LFApp-addItemBtn">');function H(e){const{language:s,list:t,setList:n,itemIndexes:i}=e,l=()=>{n([...t(),""],[...i(),i().length])},u=r=>{const a=[...t()];a.splice(r,1);const o=[...i()];o.splice(r,1),n(a,o)},c=(r,a)=>{const o=[...t()];o[r]=a,n(o,i())},d=(r,a)=>{const o=[...i()];o.splice(a,0,o.splice(r,1)[0]),n(t(),o)};return(()=>{var r=G(),a=r.firstChild;return m(r,g(z,{changeOrder:d,updateValue:c,handleDelete:u,language:s,values:t}),a),a.$$click=l,r})()}I(["click"]);const Y={create:Q,init:K};function K({pluginBaseUrl:e}){const s=`${e}/admin-ui-plugin.css`,t=document.createElement("link");t.rel="stylesheet",t.href=s,document.head.appendChild(t)}function Q(e){const{fieldType:s,initialValue:t}=e;if(s.dataType!=="json")throw new Error(`field type '${s.name}' is incompatible with list-field plugin, needs data type 'json'`);if(t!==void 0&&!_(t))throw new Error(`field type '${s.name}' is incompatible, should be a json, got '${typeof t}'`);const n=h(t);return O((i=>{const[l,u]=L(n),[c,d]=L(F(n)),[r,a]=L(e.language);return{element:g(H,{language:r,list:l,setList:(o,f)=>{u(o),d(f),e.setModifiedValue({j:o})},itemIndexes:c}),setLanguage:a,setValue:o=>{const f=h(o);u(f),d(F(f))},getValue:()=>({j:l}),dispose:i}}))}function F(e){return e.map(((s,t)=>t))}function h(e){return _(e)&&Array.isArray(e.j)?e.j:[]}export{Y as default};
@@ -1,10 +1,10 @@
1
- import { strVal } from "@paroi/data-formatters-lib";
2
- import { resolveModuleDirectory } from "@paroicms/public-server-lib";
3
1
  import { readFileSync } from "node:fs";
4
2
  import { dirname, join } from "node:path";
3
+ import { resolveModuleDirectory } from "@paroicms/public-server-lib";
4
+ import { type } from "arktype";
5
5
  const projectDir = resolveModuleDirectory(import.meta.url, { parent: true });
6
6
  const packageDir = dirname(projectDir);
7
- const version = strVal(JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8")).version);
7
+ const version = type({ version: "string", "+": "ignore" }).assert(JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8"))).version;
8
8
  const plugin = {
9
9
  version,
10
10
  siteInit(service) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paroicms/list-field-plugin",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "List field plugin for ParoiCMS",
5
5
  "keywords": [
6
6
  "paroicms",
@@ -25,16 +25,16 @@
25
25
  "clear": "rimraf backend/dist/* admin-ui-plugin/dist/*"
26
26
  },
27
27
  "dependencies": {
28
- "@paroi/data-formatters-lib": "~0.4.0"
28
+ "arktype": "~2.1.20"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@paroicms/public-anywhere-lib": "0",
32
32
  "@paroicms/public-server-lib": "0"
33
33
  },
34
34
  "devDependencies": {
35
- "@paroicms/public-anywhere-lib": "0.24.0",
36
- "@paroicms/public-admin-ui-lib": "0.25.0",
37
- "@paroicms/public-server-lib": "0.36.0",
35
+ "@paroicms/public-admin-ui-lib": "0.26.0",
36
+ "@paroicms/public-anywhere-lib": "0.25.0",
37
+ "@paroicms/public-server-lib": "0.37.0",
38
38
  "@solid-primitives/i18n": "~2.2.1",
39
39
  "@types/node": "~24.0.1",
40
40
  "primeicons": "^7.0.0",
@@ -42,10 +42,10 @@
42
42
  "sass": "~1.89.2",
43
43
  "solid-devtools": "~0.34.0",
44
44
  "solid-js": "1.9.7",
45
+ "terser": "~5.42.0",
45
46
  "typescript": "~5.8.3",
46
47
  "vite": "~6.3.5",
47
- "vite-plugin-solid": "~2.11.6",
48
- "terser": "~5.42.0"
48
+ "vite-plugin-solid": "~2.11.6"
49
49
  },
50
50
  "type": "module",
51
51
  "main": "backend/dist/plugin.js",