react-luna-form 0.0.44 → 0.0.45
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.
- package/dist/client/cjs/index.js +1 -1
- package/dist/client/esm/index.js +3366 -1
- package/dist/config/esm/index.js +227 -1
- package/dist/server/cjs/index.js +1 -1
- package/dist/server/esm/index.js +1799 -1
- package/package.json +2 -2
package/dist/server/esm/index.js
CHANGED
|
@@ -1 +1,1799 @@
|
|
|
1
|
-
import{jsx as Un}from"react/jsx-runtime";function ye(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return Un("div",{"data-slot":"field-control",className:"w-full",children:t})}import{jsx as be}from"react/jsx-runtime";function T(e){return be("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:`size-4 transition-transform duration-200 ${e.expanded?"rotate-90":""}`,children:be("path",{fillRule:"evenodd",d:"M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"})})}import{Activity as Xn}from"react";import{createContext as Yn}from"react";var Te=Yn(!1);import{jsx as he}from"react/jsx-runtime";function v({children:e,visible:t}){return he(Xn,{mode:t?"visible":"hidden",children:he(Te,{value:!0,children:e})})}var V="input",Re="input/date",Ce="input/email",Fe="input/number";var Ne="input/time";var Se="textarea",Ae="radio",ve="checkbox",q="list";var Ie="select",ke="select/day",Ee="select/month",Le="select/timezone",we="select/year";var Pe="chips",De="chips/day",Oe="chips/month",I="column",Me="description",J="fields",_e="label",Q="value",H="options",j="email",Ve="number",He="password",ze="tel",k="text",$e="aria-errormessage",Ge="aria-invalid",Be="data-invalid",Ue="data-readonly",Ye="aria",Xe="data",Ke="max",Ze="maxLength",We="min",qe="minLength",F="$ref";var Je="type",Qe={Africa:"Africa",America:"Americas",Asia:"Asia / Pacific",Atlantic:"Atlantic",Australia:"Asia / Pacific",Europe:"Europe",Indian:"Asia / Pacific",Pacific:"Asia / Pacific"};function a(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function g(e){return d(e)||typeof e=="number"||Kn(e)}function d(e){return typeof e=="string"}function Kn(e){return typeof e=="boolean"}function je(e,t=Q){if(e!=null){if(Array.isArray(e)&&e.every(g)||g(e))return e;if(a(e)){let n=Zn(e,t);if(g(n))return n}}}function Zn(e,t){let n=p(e,t);if(g(n))return n}function p(e,t){if(!t||!a(e))return null;let n=t.split(".").filter(r=>r!=="");if(n.length===0)return null;let o=e;for(let r of n)if(a(o)&&r in o)o=o[r];else return null;return o}function et(e,t={description:Me,label:_e,value:Q}){return e.map(n=>{if(a(n)){let o=p(n,t.label),r=p(n,t.value);if(g(o)&&g(r)){let i=p(n,t.description);return{label:`${o}`,value:`${r}`,...g(i)&&{description:`${i}`}}}}return n})}function tt(e=k){let t=e.lastIndexOf("/"),n=t===-1?e:e.slice(t+1);return n&&n!==V?n.trim().toLowerCase():k}var Wn=/\[([^\]]{1,500})\]\(([^)]{1,2000})\)/g;function ee(e,t={}){if(d(e))return qn(e,t);if(Array.isArray(e))return e.map(n=>ee(n,t));if(a(e)){let n={};for(let o in e)n[o]=ee(e[o],t);return n}return e}function E(e,t={}){return te(e)?ee(e,t):e}function te(e){return d(e)?/{([^}]{1,200})}/.test(e):Array.isArray(e)?e.some(t=>te(t)):a(e)?Object.values(e).some(t=>te(t)):!1}function qn(e,t={}){return e.replace(/{([^}]{1,200})}/g,(n,o)=>{let r=o.includes(".")?p(t,o):t[o];return g(r)?String(r):n})}function nt(e,t){if(!d(e)||!e||e.trim().length===0)return null;let n,o=0,r=!1,i=[];for(;(n=Wn.exec(e))!==null;){let[l,c,u]=n,m=n.index;r=!0,m>o&&i.push(e.substring(o,m));let A=t?t(m,u,c):l;i.push(A),o=m+l.length}return r?(o<e.length&&i.push(e.substring(o)),i):e}var ot=e=>s(ke)(e),rt=e=>s(Ee)(e),it=e=>s(we)(e),lt=e=>s(Le)(e),at=e=>s(De)(e),st=e=>s(Oe)(e),ct=s(Re),ne=s(Ne),x=s(ve),oe=s(Pe),h=s(Ae),dt=s(V),b=s(Ie),ut=s(Se),ft=s(k,j,He,ze),Pr=s(Ce,j),mt=s(Fe,Ve);function gt(e){return h(e)||x(e)}function pt(e){return e.type===q}function N(e){return e.type===I}function z(e){return e.type!==I&&e.type!==q}function re(e){return b(e)||h(e)}function L(e){return e!=null&&e!==""}function s(...e){return t=>{let n=d(t.type)?t.type:void 0;return n?e.some(o=>n===o||n?.startsWith(`${o}/`)):!1}}function xt(e,t={}){if(b(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&a(n))return[n]}}function yt(e){return h(e)||x(e)?!0:e.advanced?.horizontal??!1}function bt(e){return x(e)?e.advanced?.reverse!==!1:!1}function Tt(e,t){let n=e.readonly??!1;return t||n}function ht(e){if(h(e)||b(e)&&!e.disabled){let t=e.source;if(Array.isArray(t)||a(t)&&!(F in t))return t}}import{isValid as Ft,parse as Nt,format as St}from"date-fns";var Jn=/^\d+$/,At=new Date(2e3,0,1),Qn=()=>"supportedValuesOf"in Intl?Intl.supportedValuesOf("timeZone"):[];function ie(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function le(){return Array.from({length:7},(e,t)=>({value:t.toString(),label:new Date(2e3,0,2+t).toLocaleString("default",{weekday:"long"})}))}function vt(e,t){return t>=e?Array.from({length:t-e+1},(n,o)=>{let r=e+o;return{value:r.toString(),label:r.toString()}}):[]}function ae(){return new Date().getFullYear()}function jn(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function eo(e){let t=e.indexOf("/"),n=t===-1?e:e.slice(0,t);return Qe[n]??"Other"}function to(e,t){return(e.find(o=>o.type==="timeZoneName")?.value??t).replace(/\s+(?:Standard|Daylight(?: Saving)?|Summer|Winter)\s+Time$/,"")}function Rt(e,t){let n=new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(t),o=new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"long"}).formatToParts(t),i=(n.find(c=>c.type==="timeZoneName")?.value??"GMT+00:00").replace("GMT","UTC"),l=to(o,e);return{offset:i,longName:l}}function Ct(e){return e.slice(e.lastIndexOf("/")+1).replace(/_/g," ")}function It(){let e=new Date,t=jn(),n=new Map,o=Ct(t),{offset:r,longName:i}=Rt(t,e),l={value:t,label:`${o} - ${i} (${r})`};for(let u of Qn()){if(u===t)continue;let m=Ct(u),{offset:A,longName:Bn}=Rt(u,e),pe={value:u,label:`${m} - ${Bn} (${A})`},W=eo(u);if(W==="Other")continue;let xe=n.get(W);xe?xe.push(pe):n.set(W,[pe])}for(let u of n.values())u.sort((m,A)=>m.label.localeCompare(A.label));let c=Array.from(n.entries()).sort(([u],[m])=>u.localeCompare(m)).map(([u,m])=>({label:u,items:m}));return[{label:"Suggested",items:[l]},...c]}function se(e,t){if(typeof e=="number")return e;let n=t??ae(),o=e.trim().toLowerCase();if(o.startsWith("current")){let r=o.match(/^current([+-])(\d+)$/);if(r){let[,i,l]=r,c=parseInt(l,10);if(!isNaN(c))return i==="+"?n+c:n-c}return n}return Jn.test(o)?parseInt(o,10):n}function kt(e,t){if(!e)return"";try{let n=Nt(e,t,At);return Ft(n)?St(n,"yyyy-MM-dd"):""}catch{return""}}function Et(e,t){if(!e)return"";try{let n=Nt(e,t,At);return Ft(n)?St(n,"HH:mm:ss"):""}catch{return""}}function ce(e){return e.advanced?.format??"HH:mm"}function Lt(e){return e.advanced?.format??"MMMM d, yyyy"}var $=ae();function no(e){if(oe(e))return oo(e)}function oo(e){if(at(e))return le();if(st(e))return ie()}function ro(e){if(b(e))return io(e)}function io(e){if(ot(e))return le();if(rt(e))return ie();if(it(e)){let t=e.advanced?.length?.min??$,n=e.advanced?.length?.max??$+5;return vt(se(t,$),se(n,$))}if(lt(e))return It()}function wt(e,t=!1){let n={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return dt(e)?{...n,...lo(e)}:b(e)?{...n,...Pt(e,ro)}:ut(e)?{...n,...so(e)}:oe(e)?{...n,...ao(e)}:n}function lo(e){let t=tt(e.type),n={...e,type:t};return{...uo(e),...Dt(e),...co(n),...ft(n)?Ot(n):{},type:t}}function Pt(e,t){let n=t(e);return n?{options:n}:{}}function ao(e){let t=Pt(e,no),n=e.advanced?.multiple??!0;return{...t,multiple:n}}function so(e){return{...Dt(e),...Ot(e)}}function Dt(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function co(e){return mt(e)?fo(e):{}}function uo(e){if(ne(e)){let t=ce(e);return{step:t==="HH:mm:ss"||t==="hh:mm:ss a"?"1":"60"}}return{}}function Ot(e){return Mt(e,{min:qe,max:Ze})}function fo(e){return Mt(e,{min:We,max:Ke})}function Mt(e,t){let n={},o=e.advanced?.length;return o&&(o.min!==void 0&&(n[t.min]=o.min),o.max!==void 0&&(n[t.max]=o.max)),n}function _t(e,t){let n=ht(e);return n||xt(e,t)}function mo(e,t){let n=a(t)&&e.name in t?t[e.name]:t,o=je(n,e.advanced?.entity);return ne(e)&&L(o)?go(e,o):ct(e)&&L(o)?bo(e,o):o}function go(e,t){let n=ce(e);return d(t)?Et(t,n):t}function po(e,t,n){return re(e)&&Array.isArray(n)?{...t,[H]:n}:t}function xo(e,t,n){if(e.required&&!L(n)&&b(e)&&e.advanced?.preselected!==!1&&H in t){let o=t[H];if(Array.isArray(o)&&o.length===1)return o[0]}return n}function yo(e,t){return re(e)&&Array.isArray(t)?et(t,e.advanced?.options):t}function Vt(e,t,n,o){let r=mo(e,o),i=Array.isArray(n)?yo(e,n):n,l=po(e,t,i),c=xo(e,l,r);return{commonPropsWithOptions:l,defaultValue:c}}function Ht(e,t){return x(e)?{defaultChecked:L(t)}:{defaultValue:t}}function bo(e,t){let n=Lt(e);return d(t)?kt(t,n):t}var To=/^#\/definition\//;function B(e=[],t){let n=G(e,t);return Array.isArray(n)?n.filter(Ro).sort((o,r)=>zt(o)-zt(r)):[]}function G(e,t,n=new Map,o=new WeakSet){if(!ho(t)||!e||typeof e!="object")return e;if(n.has(e))return n.get(e);if(o.has(e))return e;if(o.add(e),Array.isArray(e))return e.map(i=>G(i,t,n,o));if(F in e&&d(e[F])){let i=e[F].replace(To,""),l=p(t,i);return l!==null?G(l,t,n,o):e}let r={};for(let[i,l]of Object.entries(e))r[i]=G(l,t,n,o);return o.delete(e),n.set(e,r),r}function $t(e){return Object.entries(e??{})}function zt(e){return e.order??Number.MAX_VALUE}function ho(e){return e!==void 0&&a(e)&&Object.keys(e).length>0}function Ro(e){return Je in e?!0:Array.isArray(e[J])?e[J].length>0:!0}function Gt(e,t){let n={};for(let[o,r]of $t(t))n[`${e}-${o}`]=r;return n}function Co(e){return Gt(Ye,e)}function Fo(e){return Gt(Xe,e)}function Bt(e,t){let n=Co(e.advanced?.aria);return t&&t.length>0&&(n[Ge]="true",n[$e]=`${e.name}-error`),n}function Ut(e){return Fo(e.advanced?.data)}var Yt={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},Xt={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function Kt(e,t=2){return Yt[e&&e in Yt?e:t]}function Zt(e){if(e&&e in Xt)return Xt[e]}function No(e,t){let n=e.advanced?.length?.min??1;if(t){let o=p(t,e.name);if(Array.isArray(o))return Math.max(o.length,n)}return Math.max(n,0)}function Wt(e){return!Array.isArray(e.fields)||e.fields.length===0?!1:e.fields.length>1||e.fields[0].type===I}function qt(e,t){let n=No(e,t);return Array.from({length:n},(o,r)=>r)}function Jt(e){return e.label??e.name}function R(e,t){return e?t?t[e]??e:e:""}function U(e,t){return{...e,...t}}import{jsx as So}from"react/jsx-runtime";function y(e){return nt(e,(t,n,o)=>So("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:o},`${n}-${t}`))}import{useCallback as Ao,useState as vo}from"react";import{jsx as w,jsxs as de}from"react/jsx-runtime";function Qt(e){let{fields:t=[]}=e.section,[n,o]=vo(!1),r=Ao(()=>o(i=>!i),[]);return de("fieldset",{"data-slot":"field-set","data-advanced":"true","data-expanded":n,"data-empty":t.length===0,className:"flex flex-col",id:e.section.id?.toString(),children:[w("legend",{children:de("button",{className:"flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",onClick:r,type:"button",children:[w(T,{expanded:n}),w("span",{children:y(e.section.title)})]})}),w(v,{visible:n,children:de("div",{className:"mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-slate-300 pl-4 dark:border-slate-600","data-slot":"field-set-content",children:[e.section.description&&w("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:y(e.section.description)}),e.group]})})]})}import{jsx as Y,jsxs as jt}from"react/jsx-runtime";function en(e){let t=jt("div",{className:"flex flex-col",children:[e.title&&Y("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:y(e.title)}),e.description&&Y("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:y(e.description)})]});return e.step?jt("div",{className:"flex flex-row items-start gap-4",children:[Y("div",{className:"bg-primary text-primary-foreground flex h-6 w-6 shrink-0 items-center justify-center rounded-full",children:Y("span",{className:"text-sm font-bold",children:e.step})}),t]}):t}import{jsx as Io,jsxs as ko}from"react/jsx-runtime";function X(e){return ko("fieldset",{className:"flex flex-col data-[empty=false]:gap-6","data-empty":e.empty,"data-slot":"field-set",id:e.id,children:[Io(en,{description:e.description,step:e.step,title:e.title}),e.children]})}import{jsx as Eo}from"react/jsx-runtime";function C(e){return Eo("div",{"data-slot":"field-group","data-compact":e.compact,className:"flex w-full flex-col gap-8 data-[compact=true]:gap-3",children:e.children})}import{jsx as ue}from"react/jsx-runtime";function tn(e){let{fields:t=[]}=e.section,n=e.advanced?.step?e.step:void 0,{compact:o}=U(e.style,{compact:e.section.advanced?.compact}),r=ue(C,{compact:o,children:e.children});return!e.section.title&&!e.section.description?r:e.section.advanced?.collapsible?ue(Qt,{section:e.section,group:r}):ue(X,{description:e.section.description,empty:t.length===0,id:e.section.id?.toString(),step:n,title:e.section.title,children:r})}import{jsx as nn}from"react/jsx-runtime";function on(){return nn("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:nn("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}import{useAtomValue as _o}from"jotai";import{atom as P}from"jotai";import{atomFamily as Lo}from"jotai-family";import{deepEqual as rn}from"fast-equals";function wo(e,t){let{[t]:n,...o}=e;return o}function Po(e){return Lo(t=>P(n=>n(e)[t]??void 0,(n,o,r)=>{let i=n(e);if(r!=null){let l=i[t];rn(l,r)||o(e,{...i,[t]:r})}else t in i&&o(e,wo(i,t))}))}function Do(e){return P(null,(t,n)=>{let o=t(e);o&&Object.keys(o).length>0&&n(e,{})})}function Oo(e){return P(null,(t,n,o)=>{let i={...t(e)},l=!1;for(let c of o)c in i&&(delete i[c],l=!0);l&&n(e,i)})}function Mo(e){return P(null,(t,n,o)=>{let r=t(e);rn(r,o)||n(e,o)})}function ln(e={}){let t=P(e);return{atom:t,clearAll:Do(t),clear:Oo(t),bulkReport:Mo(t),report:Po(t)}}var an=ln(),sn=an.atom,Hi=an.report;function Vo(e,t){return e.fields.every(n=>cn(n,t))}function cn(e,t){return t[e.name]?.hidden??e.hidden??!1}function Ho(e,t){return N(e)?Vo(e,t):cn(e,t)}function dn(e){let t=_o(sn);return e.container&&(t[e.container.name]?.hidden??e.container.hidden??!1)||e.fields.length===0||e.fields.every(o=>Ho(o,t))?null:e.children}import{jsx as D,jsxs as un}from"react/jsx-runtime";function fn(e){let t=B(e.sections,e.definition);return D("div",{className:"h-full w-full",children:D("form",{noValidate:e.noValidate,action:e.action,children:un(C,{children:[t.map((n,o)=>un(dn,{fields:n.fields??[],children:[D(tn,{advanced:e.advanced,section:n,step:o+1,style:e.config.style,children:e.children({disabled:e.readOnly,fields:n.fields})}),n.advanced?.separator&&D(on,{})]},`key-${n.id}-${o}`)),e.control&&D(ye,{isPending:e.isPending,children:e.control})]})})})}import{jsx as zo}from"react/jsx-runtime";function mn(e){return zo("p",{className:"-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}import{useState as $o}from"react";import{jsx as gn,jsxs as pn}from"react/jsx-runtime";function S(e){let t={context:e.context,env:e.config?.env},[n,o]=$o(()=>a(e.text)&&"collapsed"in e.text?!e.text.collapsed:!0),r=()=>o(c=>!c),i=a(e.text)&&d(e.text.title)?y(R(E(e.text.title,t),e.translations)):void 0,l=y(R(E(d(e.text)?e.text:e.text?.message,t),e.translations));return l?pn("div",{className:"flex flex-col gap-2",children:[i&&pn("button",{className:"flex items-center gap-1 text-left text-xs font-medium text-slate-700 hover:text-slate-900 dark:text-slate-300 dark:hover:text-slate-100",onClick:r,type:"button",children:[i,gn(T,{expanded:n})]}),n&&gn(mn,{children:l})]}):null}import{twMerge as Go}from"tailwind-merge";import{jsx as Bo,jsxs as Uo}from"react/jsx-runtime";function xn(e){let t=e.style?.showOptionalLabel??!0,n=h(e.field)||x(e.field);return Uo("label",{"data-slot":"field-label","data-normal":n,className:Go("flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none","data-[normal=true]:font-normal","group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"),htmlFor:e.field.name,children:[e.children,t&&!e.field.required&&Bo("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:R("(Optional)",e.translations)})]})}import{jsx as yn,jsxs as Yo}from"react/jsx-runtime";function bn(e){let t={context:e.context,env:e.config?.env},n=E(e.field.label,t);return Yo("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[yn(xn,{field:e.field,style:e.config?.style,translations:e.translations,children:R(n,e.translations)}),e.horizontal===!0&&yn(S,{config:e.config,context:e.context,text:e.field.description,translations:e.translations})]})}import{Fragment as Xo,jsx as Tn,jsxs as Ko}from"react/jsx-runtime";function hn(e){return Ko(Xo,{children:[e.field.name&&e.field.label&&Tn(bn,{config:e.config,context:e.context,field:e.field,horizontal:e.horizontal,translations:e.translations}),e.children,e.horizontal===!1&&Tn(S,{config:e.config,context:e.context,text:e.field.description,translations:e.translations})]})}function Rn(e,t){return e?t(e):null}import{jsx as Cn}from"react/jsx-runtime";function Fn(e){let t=_t(e.field,e.value),{commonPropsWithOptions:n,defaultValue:o}=Vt(e.field,e.commonProps,t,e.value),r=Ht(e.field,o);return Rn(e.config.inputs[e.field.type],i=>Cn(hn,{config:e.config,context:e.context,field:e.field,horizontal:e.horizontal,translations:e.translations,children:Cn(i,{...e.ariaAttributes,...n,...e.dataAttributes,...r})}))}import{jsx as Nn}from"react/jsx-runtime";function Sn(e){return!e.errors||e.errors.length===0?null:Nn("ul",{className:"text-sm text-red-600 dark:text-red-500",id:e.name?`${e.name}-error`:void 0,children:e.errors?.map((t,n)=>Nn("li",{children:t},e.name?`${e.name}-error-${n}`:n))})}import{twMerge as Zo}from"tailwind-merge";import{jsx as Wo}from"react/jsx-runtime";function K(e){let t=e.errors&&e.errors.length>0;return Wo("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[Be]:"true"},...e.disabled&&{[Ue]:"true"},"data-orientation":e.orientation,className:Zo("group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500","data-[clickable=true]:items-start",e.isCheckbox&&(e.isReversed?"flex-row-reverse!":"flex-row!"),"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",e.className),children:e.children})}import{twMerge as qo}from"tailwind-merge";import{jsx as Jo}from"react/jsx-runtime";function An(e){return Jo(K,{...e,orientation:"vertical",className:qo("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}import{twMerge as Qo}from"tailwind-merge";import{jsx as jo}from"react/jsx-runtime";function vn(e){return jo(K,{...e,orientation:"horizontal",className:Qo("gap-2 md:flex-row md:gap-4","[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start","[&_[role=checkbox]]:mt-[1.5px]",e.isClickable&&"md:flex-col",!e.isClickable&&["md:justify-between","[&>*:not([data-slot=field-content])]:w-full","[&>*:not([data-slot=field-content])]:md:w-1/2","[&>*:not([data-slot=field-content])]:xl:w-2/5"]),children:e.children})}import{jsx as In}from"react/jsx-runtime";function kn(e){let t=gt(e.field),n=x(e.field),o=bt(e.field);return e.horizontal?In(vn,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:o,isClickable:t,children:e.children}):In(An,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:o,isClickable:t,children:e.children})}function En(e){if(!e.field.type)return null;let t=wt(e.field,e.disabled),n=Ut(e.field),o=Bt(e.field,e.errors),r={...e.field,disabled:t.disabled};return e.children({ariaAttributes:o,commonProps:t,dataAttributes:n,field:r,horizontal:e.horizontal})}import{twMerge as er}from"tailwind-merge";import{jsx as fe,jsxs as tr}from"react/jsx-runtime";function Ln(e){let t=e.field.advanced?.cols,n=e.field.name?e.errors?.[e.field.name]:void 0,{horizontal:o}=U(e.style,{horizontal:yt(e.field)}),r=Tt(e.field,e.disabled);return tr("div",{className:er("flex flex-col gap-3",Zt(t)),children:[fe(kn,{disabled:r,errors:n,field:e.field,horizontal:o,children:fe(En,{disabled:r,errors:n,field:e.field,horizontal:o,children:e.children})}),fe(Sn,{errors:n,name:e.field.name})]})}import{twMerge as Z}from"tailwind-merge";import{useState as nr}from"react";import{jsx as f,jsxs as O}from"react/jsx-runtime";function wn(e){let[t,n]=nr(e.collapsible?!e.collapsed:!0);function o(){e.canRemove&&e.onRemove&&e.onRemove(e.index)}function r(){n(l=>!l)}let i=e.canRemove&&e.onRemove!=null&&f("button",{"aria-label":`Remove ${e.label} item ${e.index+1}`,className:Z("rounded p-1 text-xl text-slate-400","transition-colors duration-150","hover:text-red-500","focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:outline-none","dark:text-slate-500 dark:hover:text-red-400"),onClick:o,type:"button",children:f("span",{"aria-hidden":"true",children:"\xD7"})});return e.isMultiField?O("div",{"data-slot":"list-item-card",className:"rounded-lg border border-slate-100 p-4 dark:border-slate-900",children:[O("div",{className:"mb-3 flex items-center justify-between",children:[O("div",{className:"flex items-center gap-2",children:[e.collapsible&&f("button",{"aria-label":t?"Collapse":"Expand",className:Z("rounded p-1 text-slate-400 hover:bg-slate-50","transition-colors duration-150","dark:text-slate-500 dark:hover:bg-slate-800"),onClick:r,type:"button",children:f(T,{expanded:t})}),O("span",{className:"text-sm font-medium text-slate-300 dark:text-slate-400",children:[e.label," ",e.index+1,!t&&e.preview&&f("div",{className:"flex items-center gap-2 overflow-hidden text-ellipsis whitespace-nowrap text-slate-400 dark:text-slate-500",children:e.preview})]})]}),i]}),f(v,{visible:t,children:f(C,{children:e.children})})]}):O("div",{className:"flex items-start gap-2",children:[e.collapsible&&f("button",{"aria-label":t?"Collapse":"Expand",className:Z("rounded p-1 text-slate-400 hover:bg-slate-50","transition-colors duration-150","dark:text-slate-500 dark:hover:bg-slate-800",t&&"mt-7"),onClick:r,type:"button",children:f(T,{expanded:t})}),f("div",{className:"flex grow flex-col",children:f(v,{visible:t,children:f(C,{children:e.children})})}),i&&f("div",{className:Z("shrink-0",t&&"mt-7"),children:i})]})}import{jsx as or}from"react/jsx-runtime";function Pn(e){let t=Jt(e.field),n=Wt(e.field);return qt(e.field,e.value).map(o=>or(wn,{collapsed:e.field.advanced?.collapsed,collapsible:e.field.advanced?.collapsible,index:o,isMultiField:n,label:t,children:e.children(o)},o))}import{jsx as rr}from"react/jsx-runtime";function Dn(e){let t=Array.isArray(e.field.fields)&&e.field.fields.length===0;return rr(X,{description:e.field.description,empty:t,id:e.field.name,title:e.field.label,children:e.children})}import{jsx as On}from"react/jsx-runtime";function Mn({children:e,field:t,value:n}){return On(Dn,{field:t,children:On(Pn,{field:t,value:n,children:e})})}import{twMerge as ir}from"tailwind-merge";import{jsx as _n,jsxs as lr}from"react/jsx-runtime";function Vn(e){let t=Kt(e.column?.advanced?.cols);return lr("div",{className:"flex w-full flex-col gap-4",children:[_n("div",{className:ir("grid grid-cols-1 gap-3 sm:gap-4",t),children:e.children}),e.column?.description&&_n(S,{config:e.config,context:e.context,text:e.column.description,translations:e.translations})]})}import{Fragment as sr}from"react";import{jsx as ar}from"react/jsx-runtime";function Hn(e){let t=Array.isArray(e.field.fields)?e.field.fields.map(n=>z(n)?{...n,name:`${e.field.name}.${e.index}.${n.name}`}:N(n)?{...n,fields:n.fields.map(o=>({...o,name:`${e.field.name}.${e.index}.${o.name}`}))}:n):[];return ar(M,{children:e.children,components:e.components,config:e.config,context:e.context,disabled:e.disabled,fields:t,style:e.style,translations:e.translations,value:e.value})}import{jsx as _,jsxs as cr}from"react/jsx-runtime";function M(e){let{field:t,list:n}=e.components;return B(e.fields).map((o,r)=>cr(sr,{children:[N(o)&&_(Vn,{column:o,config:e.config,context:e.context,translations:e.translations,children:_(M,{...e,fields:o.fields})}),z(o)&&_(t,{disabled:e.disabled,field:o,style:e.style,children:e.children}),pt(o)&&_(n,{field:o,value:e.value,children:i=>_(Hn,{children:e.children,components:e.components,config:e.config,context:e.context,disabled:e.disabled,field:o,index:i,style:e.style,translations:e.translations,value:e.value})})]},r))}import{jsx as dr}from"react/jsx-runtime";function zn(e){return n=>dr(M,{...n,components:e})}var $n=zn({field:Ln,list:Mn});import{jsx as me}from"react/jsx-runtime";function ge(e){let t=e.translations?.[e.lang??""];return me(fn,{advanced:e.advanced,config:e.config,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,children:({disabled:n,fields:o})=>me($n,{config:e.config,context:e.context,disabled:n,fields:o,style:e.config.style,translations:t,value:e.value,children:r=>me(Fn,{...r,config:e.config,context:e.context,translations:t,value:e.value})})})}import{Suspense as ur}from"react";import{jsx as Gn}from"react/jsx-runtime";function fr(e){return Gn(ur,{fallback:Gn(ge,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}export{fr as Fallback,ge as Form};
|
|
1
|
+
// src/component/control.tsx
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
function Control(props) {
|
|
4
|
+
const content = typeof props.children === "function" ? props.children({ isPending: props.isPending }) : props.children;
|
|
5
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "field-control", className: "w-full", children: content });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// src/component/chevron-icon.tsx
|
|
9
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
10
|
+
function ChevronIcon(props) {
|
|
11
|
+
return /* @__PURE__ */ jsx2(
|
|
12
|
+
"svg",
|
|
13
|
+
{
|
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
+
viewBox: "0 0 20 20",
|
|
16
|
+
fill: "currentColor",
|
|
17
|
+
className: `size-4 transition-transform duration-200 ${props.expanded ? "rotate-90" : ""}`,
|
|
18
|
+
children: /* @__PURE__ */ jsx2(
|
|
19
|
+
"path",
|
|
20
|
+
{
|
|
21
|
+
fillRule: "evenodd",
|
|
22
|
+
d: "M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",
|
|
23
|
+
clipRule: "evenodd"
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/component/collapsible.tsx
|
|
31
|
+
import { Activity } from "react";
|
|
32
|
+
|
|
33
|
+
// src/client/context/keep-value-context.tsx
|
|
34
|
+
import { createContext } from "react";
|
|
35
|
+
var KeepValueContext = createContext(false);
|
|
36
|
+
|
|
37
|
+
// src/component/collapsible.tsx
|
|
38
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
39
|
+
function Collapsible({
|
|
40
|
+
children,
|
|
41
|
+
visible
|
|
42
|
+
}) {
|
|
43
|
+
return /* @__PURE__ */ jsx3(Activity, { mode: visible ? "visible" : "hidden", children: /* @__PURE__ */ jsx3(KeepValueContext, { value: true, children }) });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ../luna-core/src/util/constant.ts
|
|
47
|
+
var INPUT = "input";
|
|
48
|
+
var INPUT_DATE = "input/date";
|
|
49
|
+
var INPUT_EMAIL = "input/email";
|
|
50
|
+
var INPUT_NUMBER = "input/number";
|
|
51
|
+
var INPUT_TIME = "input/time";
|
|
52
|
+
var TEXTAREA = "textarea";
|
|
53
|
+
var RADIO = "radio";
|
|
54
|
+
var CHECKBOX = "checkbox";
|
|
55
|
+
var LIST = "list";
|
|
56
|
+
var SELECT = "select";
|
|
57
|
+
var SELECT_DAY = "select/day";
|
|
58
|
+
var SELECT_MONTH = "select/month";
|
|
59
|
+
var SELECT_TIMEZONE = "select/timezone";
|
|
60
|
+
var SELECT_YEAR = "select/year";
|
|
61
|
+
var CHIPS = "chips";
|
|
62
|
+
var CHIPS_DAYS = "chips/day";
|
|
63
|
+
var CHIPS_MONTHS = "chips/month";
|
|
64
|
+
var COLUMN = "column";
|
|
65
|
+
var DESCRIPTION = "description";
|
|
66
|
+
var FIELDS = "fields";
|
|
67
|
+
var LABEL = "label";
|
|
68
|
+
var VALUE = "value";
|
|
69
|
+
var OPTIONS = "options";
|
|
70
|
+
var TYPE_EMAIL = "email";
|
|
71
|
+
var TYPE_NUMBER = "number";
|
|
72
|
+
var TYPE_PASSWORD = "password";
|
|
73
|
+
var TYPE_TEL = "tel";
|
|
74
|
+
var TYPE_TEXT = "text";
|
|
75
|
+
var ARIA_ERROR_MESSAGE = "aria-errormessage";
|
|
76
|
+
var ARIA_INVALID = "aria-invalid";
|
|
77
|
+
var DATA_INVALID = "data-invalid";
|
|
78
|
+
var DATA_READONLY = "data-readonly";
|
|
79
|
+
var PREFIX_ARIA = "aria";
|
|
80
|
+
var PREFIX_DATA = "data";
|
|
81
|
+
var MAX = "max";
|
|
82
|
+
var MAX_LENGTH = "maxLength";
|
|
83
|
+
var MIN = "min";
|
|
84
|
+
var MIN_LENGTH = "minLength";
|
|
85
|
+
var $REF = "$ref";
|
|
86
|
+
var TYPE = "type";
|
|
87
|
+
var TIMEZONE_REGIONS = {
|
|
88
|
+
Africa: "Africa",
|
|
89
|
+
America: "Americas",
|
|
90
|
+
Asia: "Asia / Pacific",
|
|
91
|
+
Atlantic: "Atlantic",
|
|
92
|
+
Australia: "Asia / Pacific",
|
|
93
|
+
Europe: "Europe",
|
|
94
|
+
Indian: "Asia / Pacific",
|
|
95
|
+
Pacific: "Asia / Pacific"
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// ../luna-core/src/util/is-type.ts
|
|
99
|
+
function isObject(value) {
|
|
100
|
+
return value !== null && Object.prototype.toString.call(value) === "[object Object]";
|
|
101
|
+
}
|
|
102
|
+
function isValue(value) {
|
|
103
|
+
return isString(value) || typeof value === "number" || isBoolean(value);
|
|
104
|
+
}
|
|
105
|
+
function isString(value) {
|
|
106
|
+
return typeof value === "string";
|
|
107
|
+
}
|
|
108
|
+
function isBoolean(value) {
|
|
109
|
+
return typeof value === "boolean";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ../luna-core/src/util/extract.ts
|
|
113
|
+
function getCurrentValue(value, entity = VALUE) {
|
|
114
|
+
if (value != null) {
|
|
115
|
+
if (Array.isArray(value) && value.every(isValue)) {
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
if (isValue(value)) {
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
if (isObject(value)) {
|
|
122
|
+
const result = getValue(value, entity);
|
|
123
|
+
if (isValue(result)) {
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function getValue(value, namespace) {
|
|
130
|
+
const result = extract(value, namespace);
|
|
131
|
+
if (isValue(result)) {
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function extract(value, namespace) {
|
|
136
|
+
if (!namespace || !isObject(value)) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const keys = namespace.split(".").filter((key) => key !== "");
|
|
140
|
+
if (keys.length === 0) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
let result = value;
|
|
144
|
+
for (const key of keys) {
|
|
145
|
+
if (isObject(result) && key in result) {
|
|
146
|
+
const obj = result;
|
|
147
|
+
result = obj[key];
|
|
148
|
+
} else {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
function toOptions(data, options = {
|
|
155
|
+
description: DESCRIPTION,
|
|
156
|
+
label: LABEL,
|
|
157
|
+
value: VALUE
|
|
158
|
+
}) {
|
|
159
|
+
return data.map((item) => {
|
|
160
|
+
if (isObject(item)) {
|
|
161
|
+
const label = extract(item, options.label);
|
|
162
|
+
const value = extract(item, options.value);
|
|
163
|
+
if (isValue(label) && isValue(value)) {
|
|
164
|
+
const description = extract(item, options.description);
|
|
165
|
+
return {
|
|
166
|
+
label: `${label}`,
|
|
167
|
+
value: `${value}`,
|
|
168
|
+
...isValue(description) && { description: `${description}` }
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return item;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function getType(value = TYPE_TEXT) {
|
|
176
|
+
const lastSlash = value.lastIndexOf("/");
|
|
177
|
+
const type = lastSlash === -1 ? value : value.slice(lastSlash + 1);
|
|
178
|
+
if (type && type !== INPUT) {
|
|
179
|
+
return type.trim().toLowerCase();
|
|
180
|
+
}
|
|
181
|
+
return TYPE_TEXT;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ../luna-core/src/util/string.ts
|
|
185
|
+
var REGEX_MARKDOWN_LINK = /\[([^\]]{1,500})\]\(([^)]{1,2000})\)/g;
|
|
186
|
+
function interpolate(template, values = {}) {
|
|
187
|
+
if (isString(template)) {
|
|
188
|
+
return replacePlaceholders(template, values);
|
|
189
|
+
}
|
|
190
|
+
if (Array.isArray(template)) {
|
|
191
|
+
return template.map((item) => {
|
|
192
|
+
return interpolate(item, values);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (isObject(template)) {
|
|
196
|
+
const results = {};
|
|
197
|
+
for (const key in template) {
|
|
198
|
+
results[key] = interpolate(template[key], values);
|
|
199
|
+
}
|
|
200
|
+
return results;
|
|
201
|
+
}
|
|
202
|
+
return template;
|
|
203
|
+
}
|
|
204
|
+
function interpolateIfNeeded(template, values = {}) {
|
|
205
|
+
return isInterpolated(template) ? interpolate(template, values) : template;
|
|
206
|
+
}
|
|
207
|
+
function isInterpolated(template) {
|
|
208
|
+
if (isString(template)) {
|
|
209
|
+
return /{([^}]{1,200})}/.test(template);
|
|
210
|
+
}
|
|
211
|
+
if (Array.isArray(template)) {
|
|
212
|
+
return template.some((item) => isInterpolated(item));
|
|
213
|
+
}
|
|
214
|
+
if (isObject(template)) {
|
|
215
|
+
return Object.values(template).some((value) => isInterpolated(value));
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
function replacePlaceholders(template, values = {}) {
|
|
220
|
+
return template.replace(/{([^}]{1,200})}/g, (match, key) => {
|
|
221
|
+
const value = key.includes(".") ? extract(values, key) : values[key];
|
|
222
|
+
if (isValue(value)) {
|
|
223
|
+
return String(value);
|
|
224
|
+
}
|
|
225
|
+
return match;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
function formatMarkdown(text, callback) {
|
|
229
|
+
if (!isString(text)) {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
if (!text || text.trim().length === 0) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
let match;
|
|
236
|
+
let lastIndex = 0;
|
|
237
|
+
let hasMatch = false;
|
|
238
|
+
const parts = [];
|
|
239
|
+
while ((match = REGEX_MARKDOWN_LINK.exec(text)) !== null) {
|
|
240
|
+
const [fullMatch, linkText, url] = match;
|
|
241
|
+
const index = match.index;
|
|
242
|
+
hasMatch = true;
|
|
243
|
+
if (index > lastIndex) {
|
|
244
|
+
parts.push(text.substring(lastIndex, index));
|
|
245
|
+
}
|
|
246
|
+
const value = callback ? callback(index, url, linkText) : fullMatch;
|
|
247
|
+
parts.push(value);
|
|
248
|
+
lastIndex = index + fullMatch.length;
|
|
249
|
+
}
|
|
250
|
+
if (!hasMatch) {
|
|
251
|
+
return text;
|
|
252
|
+
}
|
|
253
|
+
if (lastIndex < text.length) {
|
|
254
|
+
parts.push(text.substring(lastIndex));
|
|
255
|
+
}
|
|
256
|
+
return parts;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// ../luna-core/src/util/is-input.ts
|
|
260
|
+
var isSelectDay = (field) => createTypeChecker(SELECT_DAY)(field);
|
|
261
|
+
var isSelectMonth = (field) => createTypeChecker(SELECT_MONTH)(field);
|
|
262
|
+
var isSelectYear = (field) => createTypeChecker(SELECT_YEAR)(field);
|
|
263
|
+
var isSelectTimezone = (field) => createTypeChecker(SELECT_TIMEZONE)(field);
|
|
264
|
+
var isChipsDays = (field) => createTypeChecker(CHIPS_DAYS)(field);
|
|
265
|
+
var isChipsMonths = (field) => createTypeChecker(CHIPS_MONTHS)(field);
|
|
266
|
+
var isDate = createTypeChecker(INPUT_DATE);
|
|
267
|
+
var isTime = createTypeChecker(INPUT_TIME);
|
|
268
|
+
var isCheckbox = createTypeChecker(CHECKBOX);
|
|
269
|
+
var isChips = createTypeChecker(CHIPS);
|
|
270
|
+
var isRadio = createTypeChecker(RADIO);
|
|
271
|
+
var isInput = createTypeChecker(INPUT);
|
|
272
|
+
var isSelect = createTypeChecker(SELECT);
|
|
273
|
+
var isTextArea = createTypeChecker(TEXTAREA);
|
|
274
|
+
var isText = createTypeChecker(
|
|
275
|
+
TYPE_TEXT,
|
|
276
|
+
TYPE_EMAIL,
|
|
277
|
+
TYPE_PASSWORD,
|
|
278
|
+
TYPE_TEL
|
|
279
|
+
);
|
|
280
|
+
var isEmail = createTypeChecker(INPUT_EMAIL, TYPE_EMAIL);
|
|
281
|
+
var isNumber = createTypeChecker(INPUT_NUMBER, TYPE_NUMBER);
|
|
282
|
+
function isClickable(field) {
|
|
283
|
+
return isRadio(field) || isCheckbox(field);
|
|
284
|
+
}
|
|
285
|
+
function isList(slot) {
|
|
286
|
+
return slot.type === LIST;
|
|
287
|
+
}
|
|
288
|
+
function isColumn(slot) {
|
|
289
|
+
return slot.type === COLUMN;
|
|
290
|
+
}
|
|
291
|
+
function isField(slot) {
|
|
292
|
+
return slot.type !== COLUMN && slot.type !== LIST;
|
|
293
|
+
}
|
|
294
|
+
function isOptions(field) {
|
|
295
|
+
return isSelect(field) || isRadio(field) || isChips(field);
|
|
296
|
+
}
|
|
297
|
+
function isValidValue(value) {
|
|
298
|
+
return value !== void 0 && value !== null && value !== "";
|
|
299
|
+
}
|
|
300
|
+
function createTypeChecker(...types) {
|
|
301
|
+
return (field) => {
|
|
302
|
+
const inputType = isString(field.type) ? field.type : void 0;
|
|
303
|
+
if (!inputType) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
return types.some((type) => {
|
|
307
|
+
return inputType === type || inputType?.startsWith(`${type}/`);
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// ../luna-core/src/util/build.ts
|
|
313
|
+
function buildOptions(field, values = {}) {
|
|
314
|
+
if (isSelect(field) && field.disabled) {
|
|
315
|
+
const current = field.name ? values?.[field.name] : void 0;
|
|
316
|
+
if (current && isObject(current)) {
|
|
317
|
+
return [current];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function buildOrientation(field) {
|
|
322
|
+
if (isRadio(field) || isCheckbox(field)) {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
return field.advanced?.horizontal ?? false;
|
|
326
|
+
}
|
|
327
|
+
function buildReverse(field) {
|
|
328
|
+
if (!isCheckbox(field)) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
return field.advanced?.reverse !== false;
|
|
332
|
+
}
|
|
333
|
+
function buildDisabled(field, disabled) {
|
|
334
|
+
const readonly = field.readonly ?? false;
|
|
335
|
+
return disabled ? disabled : readonly;
|
|
336
|
+
}
|
|
337
|
+
function buildSource(field) {
|
|
338
|
+
if (isRadio(field) || isChips(field) || isSelect(field) && !field.disabled) {
|
|
339
|
+
const source = field.source;
|
|
340
|
+
if (Array.isArray(source) || isObject(source) && !($REF in source)) {
|
|
341
|
+
return source;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// ../luna-core/src/util/date.ts
|
|
347
|
+
import { isValid, parse, format as fnsFormat } from "date-fns";
|
|
348
|
+
var REGEX_DIGITS = /^\d+$/;
|
|
349
|
+
var REF = new Date(2e3, 0, 1);
|
|
350
|
+
var getSupportedTimezones = () => "supportedValuesOf" in Intl ? Intl.supportedValuesOf("timeZone") : [];
|
|
351
|
+
function getMonth() {
|
|
352
|
+
return Array.from({ length: 12 }, (_, i) => ({
|
|
353
|
+
value: (i + 1).toString(),
|
|
354
|
+
label: new Date(0, i).toLocaleString("default", {
|
|
355
|
+
month: "long"
|
|
356
|
+
})
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
function getWeekDays() {
|
|
360
|
+
return Array.from({ length: 7 }, (_, i) => ({
|
|
361
|
+
value: i.toString(),
|
|
362
|
+
label: new Date(2e3, 0, 2 + i).toLocaleString("default", {
|
|
363
|
+
weekday: "long"
|
|
364
|
+
})
|
|
365
|
+
}));
|
|
366
|
+
}
|
|
367
|
+
function getYear(min, max) {
|
|
368
|
+
if (max >= min) {
|
|
369
|
+
return Array.from({ length: max - min + 1 }, (_, i) => {
|
|
370
|
+
const year = min + i;
|
|
371
|
+
return {
|
|
372
|
+
value: year.toString(),
|
|
373
|
+
label: year.toString()
|
|
374
|
+
};
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
return [];
|
|
378
|
+
}
|
|
379
|
+
function getCurrentYear() {
|
|
380
|
+
return (/* @__PURE__ */ new Date()).getFullYear();
|
|
381
|
+
}
|
|
382
|
+
function getUserTimezone() {
|
|
383
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
384
|
+
}
|
|
385
|
+
function getTimezoneRegion(tz) {
|
|
386
|
+
const slash = tz.indexOf("/");
|
|
387
|
+
const prefix = slash === -1 ? tz : tz.slice(0, slash);
|
|
388
|
+
return TIMEZONE_REGIONS[prefix] ?? "Other";
|
|
389
|
+
}
|
|
390
|
+
function getTimeZoneName(longNameParts, defaultTimeZone) {
|
|
391
|
+
const fullName = longNameParts.find((part) => {
|
|
392
|
+
return part.type === "timeZoneName";
|
|
393
|
+
})?.value ?? defaultTimeZone;
|
|
394
|
+
return fullName.replace(
|
|
395
|
+
/\s+(?:Standard|Daylight(?: Saving)?|Summer|Winter)\s+Time$/,
|
|
396
|
+
""
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
function getTimezoneInfo(tz, date) {
|
|
400
|
+
const offsetParts = new Intl.DateTimeFormat("en", {
|
|
401
|
+
timeZone: tz,
|
|
402
|
+
timeZoneName: "longOffset"
|
|
403
|
+
}).formatToParts(date);
|
|
404
|
+
const longNameParts = new Intl.DateTimeFormat("en", {
|
|
405
|
+
timeZone: tz,
|
|
406
|
+
timeZoneName: "long"
|
|
407
|
+
}).formatToParts(date);
|
|
408
|
+
const raw = offsetParts.find((part) => {
|
|
409
|
+
return part.type === "timeZoneName";
|
|
410
|
+
})?.value ?? "GMT+00:00";
|
|
411
|
+
const offset = raw.replace("GMT", "UTC");
|
|
412
|
+
const longName = getTimeZoneName(longNameParts, tz);
|
|
413
|
+
return { offset, longName };
|
|
414
|
+
}
|
|
415
|
+
function getTimezoneCity(tz) {
|
|
416
|
+
return tz.slice(tz.lastIndexOf("/") + 1).replace(/_/g, " ");
|
|
417
|
+
}
|
|
418
|
+
function getTimezones() {
|
|
419
|
+
const date = /* @__PURE__ */ new Date();
|
|
420
|
+
const detectedTimezone = getUserTimezone();
|
|
421
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
422
|
+
const detectedCity = getTimezoneCity(detectedTimezone);
|
|
423
|
+
const { offset: detectedOffset, longName: detectedLongName } = getTimezoneInfo(detectedTimezone, date);
|
|
424
|
+
const detectedItem = {
|
|
425
|
+
value: detectedTimezone,
|
|
426
|
+
label: `${detectedCity} - ${detectedLongName} (${detectedOffset})`
|
|
427
|
+
};
|
|
428
|
+
for (const tz of getSupportedTimezones()) {
|
|
429
|
+
if (tz === detectedTimezone) {
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
const city = getTimezoneCity(tz);
|
|
433
|
+
const { offset, longName } = getTimezoneInfo(tz, date);
|
|
434
|
+
const item = {
|
|
435
|
+
value: tz,
|
|
436
|
+
label: `${city} - ${longName} (${offset})`
|
|
437
|
+
};
|
|
438
|
+
const region = getTimezoneRegion(tz);
|
|
439
|
+
if (region === "Other") {
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
const existing = groupMap.get(region);
|
|
443
|
+
if (existing) {
|
|
444
|
+
existing.push(item);
|
|
445
|
+
} else {
|
|
446
|
+
groupMap.set(region, [item]);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
for (const items of groupMap.values()) {
|
|
450
|
+
items.sort((a, b) => a.label.localeCompare(b.label));
|
|
451
|
+
}
|
|
452
|
+
const sortedGroups = Array.from(groupMap.entries()).sort(([a], [b]) => a.localeCompare(b)).map(([label, items]) => ({ label, items }));
|
|
453
|
+
return [{ label: "Suggested", items: [detectedItem] }, ...sortedGroups];
|
|
454
|
+
}
|
|
455
|
+
function getConvert(value, current) {
|
|
456
|
+
if (typeof value === "number") {
|
|
457
|
+
return value;
|
|
458
|
+
}
|
|
459
|
+
const now2 = current ?? getCurrentYear();
|
|
460
|
+
const trimmed = value.trim().toLowerCase();
|
|
461
|
+
if (trimmed.startsWith("current")) {
|
|
462
|
+
const match = trimmed.match(/^current([+-])(\d+)$/);
|
|
463
|
+
if (match) {
|
|
464
|
+
const [, operator, offsetStr] = match;
|
|
465
|
+
const offset = parseInt(offsetStr, 10);
|
|
466
|
+
if (!isNaN(offset)) {
|
|
467
|
+
return operator === "+" ? now2 + offset : now2 - offset;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return now2;
|
|
471
|
+
}
|
|
472
|
+
if (REGEX_DIGITS.test(trimmed)) {
|
|
473
|
+
return parseInt(trimmed, 10);
|
|
474
|
+
}
|
|
475
|
+
return now2;
|
|
476
|
+
}
|
|
477
|
+
function toNativeDate(value, fromFormat) {
|
|
478
|
+
if (!value) {
|
|
479
|
+
return "";
|
|
480
|
+
}
|
|
481
|
+
try {
|
|
482
|
+
const date = parse(value, fromFormat, REF);
|
|
483
|
+
return isValid(date) ? fnsFormat(date, "yyyy-MM-dd") : "";
|
|
484
|
+
} catch {
|
|
485
|
+
return "";
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function toNativeTime(value, fromFormat) {
|
|
489
|
+
if (!value) {
|
|
490
|
+
return "";
|
|
491
|
+
}
|
|
492
|
+
try {
|
|
493
|
+
const date = parse(value, fromFormat, REF);
|
|
494
|
+
return isValid(date) ? fnsFormat(date, "HH:mm:ss") : "";
|
|
495
|
+
} catch {
|
|
496
|
+
return "";
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
function getTimeFormat(field) {
|
|
500
|
+
return field.advanced?.format ?? "HH:mm";
|
|
501
|
+
}
|
|
502
|
+
function getDateFormat(field) {
|
|
503
|
+
return field.advanced?.format ?? "MMMM d, yyyy";
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// ../luna-core/src/helper/input.ts
|
|
507
|
+
var now = getCurrentYear();
|
|
508
|
+
function buildOptionChips(field) {
|
|
509
|
+
if (isChips(field)) {
|
|
510
|
+
return defineOptionChips(field);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function defineOptionChips(field) {
|
|
514
|
+
if (isChipsDays(field)) {
|
|
515
|
+
return getWeekDays();
|
|
516
|
+
}
|
|
517
|
+
if (isChipsMonths(field)) {
|
|
518
|
+
return getMonth();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function buildOptionSelect(field) {
|
|
522
|
+
if (isSelect(field)) {
|
|
523
|
+
return defineOptionSelect(field);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function defineOptionSelect(select) {
|
|
527
|
+
if (isSelectDay(select)) {
|
|
528
|
+
return getWeekDays();
|
|
529
|
+
}
|
|
530
|
+
if (isSelectMonth(select)) {
|
|
531
|
+
return getMonth();
|
|
532
|
+
}
|
|
533
|
+
if (isSelectYear(select)) {
|
|
534
|
+
const min = select.advanced?.length?.min ?? now;
|
|
535
|
+
const max = select.advanced?.length?.max ?? now + 5;
|
|
536
|
+
return getYear(getConvert(min, now), getConvert(max, now));
|
|
537
|
+
}
|
|
538
|
+
if (isSelectTimezone(select)) {
|
|
539
|
+
return getTimezones();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
function buildCommon(field, disabled = false) {
|
|
543
|
+
const commonProps = {
|
|
544
|
+
disabled,
|
|
545
|
+
id: field.name,
|
|
546
|
+
name: field.name,
|
|
547
|
+
placeholder: field.placeholder,
|
|
548
|
+
required: field.required
|
|
549
|
+
};
|
|
550
|
+
if (isInput(field)) {
|
|
551
|
+
return {
|
|
552
|
+
...commonProps,
|
|
553
|
+
...defineInput(field)
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
if (isSelect(field)) {
|
|
557
|
+
return {
|
|
558
|
+
...commonProps,
|
|
559
|
+
...defineWithOptions(field, buildOptionSelect)
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
if (isTextArea(field)) {
|
|
563
|
+
return {
|
|
564
|
+
...commonProps,
|
|
565
|
+
...defineTextArea(field)
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
if (isChips(field)) {
|
|
569
|
+
return {
|
|
570
|
+
...commonProps,
|
|
571
|
+
...defineChips(field)
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
return commonProps;
|
|
575
|
+
}
|
|
576
|
+
function defineInput(input) {
|
|
577
|
+
const type = getType(input.type);
|
|
578
|
+
const copy = { ...input, type };
|
|
579
|
+
return {
|
|
580
|
+
...defineTime(input),
|
|
581
|
+
...defineAutoComplete(input),
|
|
582
|
+
...defineNumberLimits(copy),
|
|
583
|
+
...isText(copy) ? defineLength(copy) : {},
|
|
584
|
+
type
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
function defineWithOptions(field, builder) {
|
|
588
|
+
const options = builder(field);
|
|
589
|
+
if (options) {
|
|
590
|
+
return { options };
|
|
591
|
+
}
|
|
592
|
+
return {};
|
|
593
|
+
}
|
|
594
|
+
function defineChips(field) {
|
|
595
|
+
const withOptions = defineWithOptions(field, buildOptionChips);
|
|
596
|
+
const multiple = field.advanced?.multiple ?? true;
|
|
597
|
+
return { ...withOptions, multiple };
|
|
598
|
+
}
|
|
599
|
+
function defineTextArea(field) {
|
|
600
|
+
return {
|
|
601
|
+
...defineAutoComplete(field),
|
|
602
|
+
...defineLength(field)
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
function defineAutoComplete(input) {
|
|
606
|
+
const autoComplete = input.advanced?.autocomplete;
|
|
607
|
+
if (autoComplete) {
|
|
608
|
+
return { autoComplete };
|
|
609
|
+
}
|
|
610
|
+
return {};
|
|
611
|
+
}
|
|
612
|
+
function defineNumberLimits(input) {
|
|
613
|
+
if (isNumber(input)) {
|
|
614
|
+
return defineMinMax(input);
|
|
615
|
+
}
|
|
616
|
+
return {};
|
|
617
|
+
}
|
|
618
|
+
function defineTime(field) {
|
|
619
|
+
if (isTime(field)) {
|
|
620
|
+
const format = getTimeFormat(field);
|
|
621
|
+
const withSeconds = format === "HH:mm:ss" || format === "hh:mm:ss a";
|
|
622
|
+
return {
|
|
623
|
+
step: withSeconds ? "1" : "60"
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
return {};
|
|
627
|
+
}
|
|
628
|
+
function defineLength(input) {
|
|
629
|
+
return defineConstraints(input, { min: MIN_LENGTH, max: MAX_LENGTH });
|
|
630
|
+
}
|
|
631
|
+
function defineMinMax(input) {
|
|
632
|
+
return defineConstraints(input, { min: MIN, max: MAX });
|
|
633
|
+
}
|
|
634
|
+
function defineConstraints(input, keys) {
|
|
635
|
+
const result = {};
|
|
636
|
+
const length = input.advanced?.length;
|
|
637
|
+
if (length) {
|
|
638
|
+
if (length.min !== void 0) {
|
|
639
|
+
result[keys.min] = length.min;
|
|
640
|
+
}
|
|
641
|
+
if (length.max !== void 0) {
|
|
642
|
+
result[keys.max] = length.max;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
return result;
|
|
646
|
+
}
|
|
647
|
+
function resolveSource(field, value) {
|
|
648
|
+
const current = buildSource(field);
|
|
649
|
+
if (current) {
|
|
650
|
+
return current;
|
|
651
|
+
}
|
|
652
|
+
return buildOptions(field, value);
|
|
653
|
+
}
|
|
654
|
+
function getInputValue(field, value) {
|
|
655
|
+
const newValue = isObject(value) && field.name in value ? value[field.name] : value;
|
|
656
|
+
const currentValue = getCurrentValue(newValue, field.advanced?.entity);
|
|
657
|
+
if (isTime(field) && isValidValue(currentValue)) {
|
|
658
|
+
return getTimeValue(field, currentValue);
|
|
659
|
+
}
|
|
660
|
+
if (isDate(field) && isValidValue(currentValue)) {
|
|
661
|
+
return getDateValue(field, currentValue);
|
|
662
|
+
}
|
|
663
|
+
return currentValue;
|
|
664
|
+
}
|
|
665
|
+
function getTimeValue(field, currentValue) {
|
|
666
|
+
const format = getTimeFormat(field);
|
|
667
|
+
return isString(currentValue) ? toNativeTime(currentValue, format) : currentValue;
|
|
668
|
+
}
|
|
669
|
+
function mergeOptionsProps(field, commonProps, options) {
|
|
670
|
+
return isOptions(field) && Array.isArray(options) ? { ...commonProps, [OPTIONS]: options } : commonProps;
|
|
671
|
+
}
|
|
672
|
+
function getPreselectedValue(field, commonProps, value) {
|
|
673
|
+
if (field.required && !isValidValue(value)) {
|
|
674
|
+
if (isSelect(field)) {
|
|
675
|
+
if (field.advanced?.preselected !== false && OPTIONS in commonProps) {
|
|
676
|
+
const options = commonProps[OPTIONS];
|
|
677
|
+
if (Array.isArray(options) && options.length === 1) {
|
|
678
|
+
return options[0];
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return value;
|
|
684
|
+
}
|
|
685
|
+
function getOptions(field, data) {
|
|
686
|
+
if (isOptions(field) && Array.isArray(data)) {
|
|
687
|
+
return toOptions(data, field.advanced?.options);
|
|
688
|
+
}
|
|
689
|
+
return data;
|
|
690
|
+
}
|
|
691
|
+
function prepareInputProps(field, commonProps, data, value) {
|
|
692
|
+
const currentValue = getInputValue(field, value);
|
|
693
|
+
const options = Array.isArray(data) ? getOptions(field, data) : data;
|
|
694
|
+
const commonPropsWithOptions = mergeOptionsProps(field, commonProps, options);
|
|
695
|
+
const defaultValue = getPreselectedValue(
|
|
696
|
+
field,
|
|
697
|
+
commonPropsWithOptions,
|
|
698
|
+
currentValue
|
|
699
|
+
);
|
|
700
|
+
return {
|
|
701
|
+
commonPropsWithOptions,
|
|
702
|
+
defaultValue
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
function prepareDefaultValue(field, value) {
|
|
706
|
+
if (isCheckbox(field)) {
|
|
707
|
+
return {
|
|
708
|
+
defaultChecked: isValidValue(value)
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
return { defaultValue: value };
|
|
712
|
+
}
|
|
713
|
+
function getDateValue(field, currentValue) {
|
|
714
|
+
const format = getDateFormat(field);
|
|
715
|
+
return isString(currentValue) ? toNativeDate(currentValue, format) : currentValue;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// ../luna-core/src/util/prepare.ts
|
|
719
|
+
var REGEX_REF = /^#\/definition\//;
|
|
720
|
+
function prepare(base = [], definition) {
|
|
721
|
+
const resolved = resolveRefs(base, definition);
|
|
722
|
+
return Array.isArray(resolved) ? resolved.filter(filter).sort((a, b) => getOrder(a) - getOrder(b)) : [];
|
|
723
|
+
}
|
|
724
|
+
function resolveRefs(base, definition, cache = /* @__PURE__ */ new Map(), visited = /* @__PURE__ */ new WeakSet()) {
|
|
725
|
+
if (!isDefinition(definition) || !base || typeof base !== "object") {
|
|
726
|
+
return base;
|
|
727
|
+
}
|
|
728
|
+
if (cache.has(base)) {
|
|
729
|
+
return cache.get(base);
|
|
730
|
+
}
|
|
731
|
+
if (visited.has(base)) {
|
|
732
|
+
return base;
|
|
733
|
+
}
|
|
734
|
+
visited.add(base);
|
|
735
|
+
if (Array.isArray(base)) {
|
|
736
|
+
return base.map((item) => resolveRefs(item, definition, cache, visited));
|
|
737
|
+
}
|
|
738
|
+
if ($REF in base && isString(base[$REF])) {
|
|
739
|
+
const path = base[$REF].replace(REGEX_REF, "");
|
|
740
|
+
const resolved = extract(definition, path);
|
|
741
|
+
if (resolved !== null) {
|
|
742
|
+
return resolveRefs(resolved, definition, cache, visited);
|
|
743
|
+
}
|
|
744
|
+
return base;
|
|
745
|
+
}
|
|
746
|
+
const result = {};
|
|
747
|
+
for (const [key, value] of Object.entries(base)) {
|
|
748
|
+
result[key] = resolveRefs(value, definition, cache, visited);
|
|
749
|
+
}
|
|
750
|
+
visited.delete(base);
|
|
751
|
+
cache.set(base, result);
|
|
752
|
+
return result;
|
|
753
|
+
}
|
|
754
|
+
function entries(values) {
|
|
755
|
+
return Object.entries(values ?? {});
|
|
756
|
+
}
|
|
757
|
+
function getOrder(item) {
|
|
758
|
+
return item.order ?? Number.MAX_VALUE;
|
|
759
|
+
}
|
|
760
|
+
function isDefinition(definition) {
|
|
761
|
+
return definition !== void 0 && isObject(definition) && Object.keys(definition).length > 0;
|
|
762
|
+
}
|
|
763
|
+
function filter(base) {
|
|
764
|
+
if (TYPE in base) {
|
|
765
|
+
return true;
|
|
766
|
+
}
|
|
767
|
+
if (Array.isArray(base[FIELDS])) {
|
|
768
|
+
return base[FIELDS].length > 0;
|
|
769
|
+
}
|
|
770
|
+
return true;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// ../luna-core/src/util/attributes.ts
|
|
774
|
+
function getPrefixedAttributes(prefix, record) {
|
|
775
|
+
const attrs = {};
|
|
776
|
+
for (const [key, value] of entries(record)) {
|
|
777
|
+
attrs[`${prefix}-${key}`] = value;
|
|
778
|
+
}
|
|
779
|
+
return attrs;
|
|
780
|
+
}
|
|
781
|
+
function getAriaAttributes(record) {
|
|
782
|
+
return getPrefixedAttributes(PREFIX_ARIA, record);
|
|
783
|
+
}
|
|
784
|
+
function getDataAttributes(record) {
|
|
785
|
+
return getPrefixedAttributes(PREFIX_DATA, record);
|
|
786
|
+
}
|
|
787
|
+
function buildAriaAttributes(field, errors) {
|
|
788
|
+
const ariaAttributes = getAriaAttributes(field.advanced?.aria);
|
|
789
|
+
if (errors && errors.length > 0) {
|
|
790
|
+
ariaAttributes[ARIA_INVALID] = "true";
|
|
791
|
+
ariaAttributes[ARIA_ERROR_MESSAGE] = `${field.name}-error`;
|
|
792
|
+
}
|
|
793
|
+
return ariaAttributes;
|
|
794
|
+
}
|
|
795
|
+
function buildDataAttributes(field) {
|
|
796
|
+
return getDataAttributes(field.advanced?.data);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// ../luna-core/src/util/column.ts
|
|
800
|
+
var cols = {
|
|
801
|
+
1: "md:grid-cols-1",
|
|
802
|
+
2: "md:grid-cols-2",
|
|
803
|
+
3: "md:grid-cols-3"
|
|
804
|
+
};
|
|
805
|
+
var span = {
|
|
806
|
+
1: "md:col-span-1",
|
|
807
|
+
2: "md:col-span-2",
|
|
808
|
+
3: "md:col-span-3"
|
|
809
|
+
};
|
|
810
|
+
function getColumn(value, defaultCols = 2) {
|
|
811
|
+
return cols[value && value in cols ? value : defaultCols];
|
|
812
|
+
}
|
|
813
|
+
function getSpan(value) {
|
|
814
|
+
if (value && value in span) {
|
|
815
|
+
return span[value];
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
// ../luna-core/src/util/list.ts
|
|
820
|
+
function getInitialCount(list, value) {
|
|
821
|
+
const min = list.advanced?.length?.min ?? 1;
|
|
822
|
+
if (value) {
|
|
823
|
+
const data = extract(value, list.name);
|
|
824
|
+
if (Array.isArray(data)) {
|
|
825
|
+
return Math.max(data.length, min);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
return Math.max(min, 0);
|
|
829
|
+
}
|
|
830
|
+
function isMultiFieldList(list) {
|
|
831
|
+
if (!Array.isArray(list.fields) || list.fields.length === 0) {
|
|
832
|
+
return false;
|
|
833
|
+
}
|
|
834
|
+
return list.fields.length > 1 || list.fields[0].type === COLUMN;
|
|
835
|
+
}
|
|
836
|
+
function getInitialList(list, value) {
|
|
837
|
+
const count = getInitialCount(list, value);
|
|
838
|
+
return Array.from({ length: count }, (_, index) => index);
|
|
839
|
+
}
|
|
840
|
+
function getLabel(list) {
|
|
841
|
+
return list.label ?? list.name;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// ../luna-core/src/util/translate.ts
|
|
845
|
+
function translate(key, dictionary) {
|
|
846
|
+
if (!key) {
|
|
847
|
+
return "";
|
|
848
|
+
}
|
|
849
|
+
if (!dictionary) {
|
|
850
|
+
return key;
|
|
851
|
+
}
|
|
852
|
+
return dictionary[key] ?? key;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// ../luna-core/src/util/style.ts
|
|
856
|
+
function mergeStyle(globalStyle, localStyle) {
|
|
857
|
+
return { ...globalStyle, ...localStyle };
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
// src/lib/string.tsx
|
|
861
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
862
|
+
function formatMarkdown2(text) {
|
|
863
|
+
return formatMarkdown(
|
|
864
|
+
text,
|
|
865
|
+
(index, url, text2) => {
|
|
866
|
+
return /* @__PURE__ */ jsx4(
|
|
867
|
+
"a",
|
|
868
|
+
{
|
|
869
|
+
className: "underline",
|
|
870
|
+
href: url,
|
|
871
|
+
rel: "noopener noreferrer",
|
|
872
|
+
target: "_blank",
|
|
873
|
+
children: text2
|
|
874
|
+
},
|
|
875
|
+
`${url}-${index}`
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
// src/component/field/field-set-advanced.tsx
|
|
882
|
+
import { useCallback, useState } from "react";
|
|
883
|
+
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
884
|
+
function FieldSetAdvanced(props) {
|
|
885
|
+
const { fields = [] } = props.section;
|
|
886
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
887
|
+
const handleOpen = useCallback(() => setIsOpen((previous) => !previous), []);
|
|
888
|
+
return /* @__PURE__ */ jsxs(
|
|
889
|
+
"fieldset",
|
|
890
|
+
{
|
|
891
|
+
"data-slot": "field-set",
|
|
892
|
+
"data-advanced": "true",
|
|
893
|
+
"data-expanded": isOpen,
|
|
894
|
+
"data-empty": fields.length === 0,
|
|
895
|
+
className: "flex flex-col",
|
|
896
|
+
id: props.section.id?.toString(),
|
|
897
|
+
children: [
|
|
898
|
+
/* @__PURE__ */ jsx5("legend", { children: /* @__PURE__ */ jsxs(
|
|
899
|
+
"button",
|
|
900
|
+
{
|
|
901
|
+
className: "flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",
|
|
902
|
+
onClick: handleOpen,
|
|
903
|
+
type: "button",
|
|
904
|
+
children: [
|
|
905
|
+
/* @__PURE__ */ jsx5(ChevronIcon, { expanded: isOpen }),
|
|
906
|
+
/* @__PURE__ */ jsx5("span", { children: formatMarkdown2(props.section.title) })
|
|
907
|
+
]
|
|
908
|
+
}
|
|
909
|
+
) }),
|
|
910
|
+
/* @__PURE__ */ jsx5(Collapsible, { visible: isOpen, children: /* @__PURE__ */ jsxs(
|
|
911
|
+
"div",
|
|
912
|
+
{
|
|
913
|
+
className: "mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-slate-300 pl-4 dark:border-slate-600",
|
|
914
|
+
"data-slot": "field-set-content",
|
|
915
|
+
children: [
|
|
916
|
+
props.section.description && /* @__PURE__ */ jsx5("p", { className: "text-sm leading-normal font-normal text-slate-600 dark:text-slate-400", children: formatMarkdown2(props.section.description) }),
|
|
917
|
+
props.group
|
|
918
|
+
]
|
|
919
|
+
}
|
|
920
|
+
) })
|
|
921
|
+
]
|
|
922
|
+
}
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// src/component/legend.tsx
|
|
927
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
928
|
+
function Legend(props) {
|
|
929
|
+
const content = /* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
|
|
930
|
+
props.title && /* @__PURE__ */ jsx6("legend", { className: "mb-3 font-medium text-slate-800 dark:text-slate-200", children: formatMarkdown2(props.title) }),
|
|
931
|
+
props.description && /* @__PURE__ */ jsx6("p", { className: "-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400", children: formatMarkdown2(props.description) })
|
|
932
|
+
] });
|
|
933
|
+
if (props.step) {
|
|
934
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex flex-row items-start gap-4", children: [
|
|
935
|
+
/* @__PURE__ */ jsx6("div", { className: "bg-primary text-primary-foreground flex h-6 w-6 shrink-0 items-center justify-center rounded-full", children: /* @__PURE__ */ jsx6("span", { className: "text-sm font-bold", children: props.step }) }),
|
|
936
|
+
content
|
|
937
|
+
] });
|
|
938
|
+
}
|
|
939
|
+
return content;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// src/component/field/field-set-base.tsx
|
|
943
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
944
|
+
function FieldSetBase(props) {
|
|
945
|
+
return /* @__PURE__ */ jsxs3(
|
|
946
|
+
"fieldset",
|
|
947
|
+
{
|
|
948
|
+
className: "flex flex-col data-[empty=false]:gap-6",
|
|
949
|
+
"data-empty": props.empty,
|
|
950
|
+
"data-slot": "field-set",
|
|
951
|
+
id: props.id,
|
|
952
|
+
children: [
|
|
953
|
+
/* @__PURE__ */ jsx7(
|
|
954
|
+
Legend,
|
|
955
|
+
{
|
|
956
|
+
description: props.description,
|
|
957
|
+
step: props.step,
|
|
958
|
+
title: props.title
|
|
959
|
+
}
|
|
960
|
+
),
|
|
961
|
+
props.children
|
|
962
|
+
]
|
|
963
|
+
}
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// src/component/group.tsx
|
|
968
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
969
|
+
function Group(props) {
|
|
970
|
+
return /* @__PURE__ */ jsx8(
|
|
971
|
+
"div",
|
|
972
|
+
{
|
|
973
|
+
"data-slot": "field-group",
|
|
974
|
+
"data-compact": props.compact,
|
|
975
|
+
className: "flex w-full flex-col gap-8 data-[compact=true]:gap-3",
|
|
976
|
+
children: props.children
|
|
977
|
+
}
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
// src/component/field/field-set.tsx
|
|
982
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
983
|
+
function FieldSet(props) {
|
|
984
|
+
const { fields = [] } = props.section;
|
|
985
|
+
const step = props.advanced?.step ? props.step : void 0;
|
|
986
|
+
const { compact } = mergeStyle(props.style, {
|
|
987
|
+
compact: props.section.advanced?.compact
|
|
988
|
+
});
|
|
989
|
+
const group = /* @__PURE__ */ jsx9(Group, { compact, children: props.children });
|
|
990
|
+
if (!props.section.title && !props.section.description) {
|
|
991
|
+
return group;
|
|
992
|
+
}
|
|
993
|
+
if (props.section.advanced?.collapsible) {
|
|
994
|
+
return /* @__PURE__ */ jsx9(FieldSetAdvanced, { section: props.section, group });
|
|
995
|
+
}
|
|
996
|
+
return /* @__PURE__ */ jsx9(
|
|
997
|
+
FieldSetBase,
|
|
998
|
+
{
|
|
999
|
+
description: props.section.description,
|
|
1000
|
+
empty: fields.length === 0,
|
|
1001
|
+
id: props.section.id?.toString(),
|
|
1002
|
+
step,
|
|
1003
|
+
title: props.section.title,
|
|
1004
|
+
children: group
|
|
1005
|
+
}
|
|
1006
|
+
);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// src/component/separator.tsx
|
|
1010
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1011
|
+
function Separator() {
|
|
1012
|
+
return /* @__PURE__ */ jsx10("div", { "data-slot": "field-separator", className: "relative -my-2 h-5 text-sm", children: /* @__PURE__ */ jsx10("div", { className: "absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800" }) });
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// src/client/component/guard/visibility-guard.tsx
|
|
1016
|
+
import { useAtomValue } from "jotai";
|
|
1017
|
+
|
|
1018
|
+
// src/client/lib/store-helper.ts
|
|
1019
|
+
import { atom } from "jotai";
|
|
1020
|
+
import { atomFamily } from "jotai-family";
|
|
1021
|
+
import { deepEqual } from "fast-equals";
|
|
1022
|
+
function omitKey(obj, key) {
|
|
1023
|
+
const { [key]: _removed, ...rest } = obj;
|
|
1024
|
+
return rest;
|
|
1025
|
+
}
|
|
1026
|
+
function createRecordAtomFamily(baseAtom) {
|
|
1027
|
+
return atomFamily(
|
|
1028
|
+
(name) => atom(
|
|
1029
|
+
(get) => {
|
|
1030
|
+
return get(baseAtom)[name] ?? void 0;
|
|
1031
|
+
},
|
|
1032
|
+
(get, set, newValue) => {
|
|
1033
|
+
const current = get(baseAtom);
|
|
1034
|
+
if (newValue !== void 0 && newValue !== null) {
|
|
1035
|
+
const currentValue = current[name];
|
|
1036
|
+
if (!deepEqual(currentValue, newValue)) {
|
|
1037
|
+
set(baseAtom, { ...current, [name]: newValue });
|
|
1038
|
+
}
|
|
1039
|
+
} else if (name in current) {
|
|
1040
|
+
set(baseAtom, omitKey(current, name));
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
)
|
|
1044
|
+
);
|
|
1045
|
+
}
|
|
1046
|
+
function createClearAllAtom(baseAtom) {
|
|
1047
|
+
return atom(null, (get, set) => {
|
|
1048
|
+
const current = get(baseAtom);
|
|
1049
|
+
if (current && Object.keys(current).length > 0) {
|
|
1050
|
+
set(baseAtom, {});
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
function createClearAtom(baseAtom) {
|
|
1055
|
+
return atom(null, (get, set, names) => {
|
|
1056
|
+
const current = get(baseAtom);
|
|
1057
|
+
const next = { ...current };
|
|
1058
|
+
let hasChanges = false;
|
|
1059
|
+
for (const name of names) {
|
|
1060
|
+
if (name in next) {
|
|
1061
|
+
delete next[name];
|
|
1062
|
+
hasChanges = true;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
if (hasChanges) {
|
|
1066
|
+
set(baseAtom, next);
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
function createBulkReportAtom(baseAtom) {
|
|
1071
|
+
return atom(null, (get, set, newValue) => {
|
|
1072
|
+
const current = get(baseAtom);
|
|
1073
|
+
if (!deepEqual(current, newValue)) {
|
|
1074
|
+
set(baseAtom, newValue);
|
|
1075
|
+
}
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
function createAtomStore(initialValue = {}) {
|
|
1079
|
+
const baseAtom = atom(initialValue);
|
|
1080
|
+
return {
|
|
1081
|
+
atom: baseAtom,
|
|
1082
|
+
clearAll: createClearAllAtom(baseAtom),
|
|
1083
|
+
clear: createClearAtom(baseAtom),
|
|
1084
|
+
bulkReport: createBulkReportAtom(baseAtom),
|
|
1085
|
+
report: createRecordAtomFamily(baseAtom)
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
// src/client/lib/state-store.ts
|
|
1090
|
+
var store = createAtomStore();
|
|
1091
|
+
var fieldStateAtom = store.atom;
|
|
1092
|
+
var reportFieldStateAtom = store.report;
|
|
1093
|
+
|
|
1094
|
+
// src/client/component/guard/visibility-guard.tsx
|
|
1095
|
+
function isColumnHidden(column, states) {
|
|
1096
|
+
return column.fields.every((field) => isFieldHidden(field, states));
|
|
1097
|
+
}
|
|
1098
|
+
function isFieldHidden(field, states) {
|
|
1099
|
+
return states[field.name]?.hidden ?? field.hidden ?? false;
|
|
1100
|
+
}
|
|
1101
|
+
function isEntryHidden(entry, states) {
|
|
1102
|
+
return isColumn(entry) ? isColumnHidden(entry, states) : isFieldHidden(entry, states);
|
|
1103
|
+
}
|
|
1104
|
+
function VisibilityGuard(props) {
|
|
1105
|
+
const states = useAtomValue(fieldStateAtom);
|
|
1106
|
+
if (props.container) {
|
|
1107
|
+
const hidden = states[props.container.name]?.hidden ?? props.container.hidden ?? false;
|
|
1108
|
+
if (hidden) {
|
|
1109
|
+
return null;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
if (props.fields.length === 0) {
|
|
1113
|
+
return null;
|
|
1114
|
+
}
|
|
1115
|
+
const allHidden = props.fields.every((entry) => isEntryHidden(entry, states));
|
|
1116
|
+
if (allHidden) {
|
|
1117
|
+
return null;
|
|
1118
|
+
}
|
|
1119
|
+
return props.children;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
// src/component/form.tsx
|
|
1123
|
+
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1124
|
+
function Form(props) {
|
|
1125
|
+
const sections = prepare(props.sections, props.definition);
|
|
1126
|
+
return /* @__PURE__ */ jsx11("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx11("form", { noValidate: props.noValidate, action: props.action, children: /* @__PURE__ */ jsxs4(Group, { children: [
|
|
1127
|
+
sections.map((section, index) => /* @__PURE__ */ jsxs4(
|
|
1128
|
+
VisibilityGuard,
|
|
1129
|
+
{
|
|
1130
|
+
fields: section.fields ?? [],
|
|
1131
|
+
children: [
|
|
1132
|
+
/* @__PURE__ */ jsx11(
|
|
1133
|
+
FieldSet,
|
|
1134
|
+
{
|
|
1135
|
+
advanced: props.advanced,
|
|
1136
|
+
section,
|
|
1137
|
+
step: index + 1,
|
|
1138
|
+
style: props.config.style,
|
|
1139
|
+
children: props.children({
|
|
1140
|
+
disabled: props.readOnly,
|
|
1141
|
+
fields: section.fields
|
|
1142
|
+
})
|
|
1143
|
+
}
|
|
1144
|
+
),
|
|
1145
|
+
section.advanced?.separator && /* @__PURE__ */ jsx11(Separator, {})
|
|
1146
|
+
]
|
|
1147
|
+
},
|
|
1148
|
+
`key-${section.id}-${index}`
|
|
1149
|
+
)),
|
|
1150
|
+
props.control && /* @__PURE__ */ jsx11(Control, { isPending: props.isPending, children: props.control })
|
|
1151
|
+
] }) }) });
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
// src/component/description.tsx
|
|
1155
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1156
|
+
function Description(props) {
|
|
1157
|
+
return /* @__PURE__ */ jsx12("p", { className: "-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400", children: props.children });
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
// src/component/formatted-description.tsx
|
|
1161
|
+
import { useState as useState2 } from "react";
|
|
1162
|
+
import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1163
|
+
function FormattedDescription(props) {
|
|
1164
|
+
const interpolateOpts = {
|
|
1165
|
+
context: props.context,
|
|
1166
|
+
env: props.config?.env
|
|
1167
|
+
};
|
|
1168
|
+
const [isExpanded, setIsExpanded] = useState2(() => {
|
|
1169
|
+
if (isObject(props.text) && "collapsed" in props.text) {
|
|
1170
|
+
return !props.text.collapsed;
|
|
1171
|
+
}
|
|
1172
|
+
return true;
|
|
1173
|
+
});
|
|
1174
|
+
const handleExpandToggle = () => setIsExpanded((previous) => !previous);
|
|
1175
|
+
const title = isObject(props.text) && isString(props.text.title) ? formatMarkdown2(
|
|
1176
|
+
translate(
|
|
1177
|
+
interpolateIfNeeded(props.text.title, interpolateOpts),
|
|
1178
|
+
props.translations
|
|
1179
|
+
)
|
|
1180
|
+
) : void 0;
|
|
1181
|
+
const message = formatMarkdown2(
|
|
1182
|
+
translate(
|
|
1183
|
+
interpolateIfNeeded(
|
|
1184
|
+
isString(props.text) ? props.text : props.text?.message,
|
|
1185
|
+
interpolateOpts
|
|
1186
|
+
),
|
|
1187
|
+
props.translations
|
|
1188
|
+
)
|
|
1189
|
+
);
|
|
1190
|
+
if (message) {
|
|
1191
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-2", children: [
|
|
1192
|
+
title && /* @__PURE__ */ jsxs5(
|
|
1193
|
+
"button",
|
|
1194
|
+
{
|
|
1195
|
+
className: "flex items-center gap-1 text-left text-xs font-medium text-slate-700 hover:text-slate-900 dark:text-slate-300 dark:hover:text-slate-100",
|
|
1196
|
+
onClick: handleExpandToggle,
|
|
1197
|
+
type: "button",
|
|
1198
|
+
children: [
|
|
1199
|
+
title,
|
|
1200
|
+
/* @__PURE__ */ jsx13(ChevronIcon, { expanded: isExpanded })
|
|
1201
|
+
]
|
|
1202
|
+
}
|
|
1203
|
+
),
|
|
1204
|
+
isExpanded && /* @__PURE__ */ jsx13(Description, { children: message })
|
|
1205
|
+
] });
|
|
1206
|
+
}
|
|
1207
|
+
return null;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// src/component/label.tsx
|
|
1211
|
+
import { twMerge } from "tailwind-merge";
|
|
1212
|
+
import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1213
|
+
function Label(props) {
|
|
1214
|
+
const showOptionalLabel = props.style?.showOptionalLabel ?? true;
|
|
1215
|
+
const normal = isRadio(props.field) || isCheckbox(props.field);
|
|
1216
|
+
return /* @__PURE__ */ jsxs6(
|
|
1217
|
+
"label",
|
|
1218
|
+
{
|
|
1219
|
+
"data-slot": "field-label",
|
|
1220
|
+
"data-normal": normal,
|
|
1221
|
+
className: twMerge(
|
|
1222
|
+
"flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",
|
|
1223
|
+
"data-[normal=true]:font-normal",
|
|
1224
|
+
"group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"
|
|
1225
|
+
),
|
|
1226
|
+
htmlFor: props.field.name,
|
|
1227
|
+
children: [
|
|
1228
|
+
props.children,
|
|
1229
|
+
showOptionalLabel && !props.field.required && /* @__PURE__ */ jsx14("span", { className: "text-sm text-slate-600 dark:text-slate-400", children: translate("(Optional)", props.translations) })
|
|
1230
|
+
]
|
|
1231
|
+
}
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
// src/component/input-label.tsx
|
|
1236
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1237
|
+
function InputLabel(props) {
|
|
1238
|
+
const interpolateOpts = {
|
|
1239
|
+
context: props.context,
|
|
1240
|
+
env: props.config?.env
|
|
1241
|
+
};
|
|
1242
|
+
const label = interpolateIfNeeded(props.field.label, interpolateOpts);
|
|
1243
|
+
return /* @__PURE__ */ jsxs7(
|
|
1244
|
+
"div",
|
|
1245
|
+
{
|
|
1246
|
+
"data-slot": "field-content",
|
|
1247
|
+
className: "flex w-full flex-1 flex-col gap-1.5 leading-snug",
|
|
1248
|
+
children: [
|
|
1249
|
+
/* @__PURE__ */ jsx15(
|
|
1250
|
+
Label,
|
|
1251
|
+
{
|
|
1252
|
+
field: props.field,
|
|
1253
|
+
style: props.config?.style,
|
|
1254
|
+
translations: props.translations,
|
|
1255
|
+
children: translate(label, props.translations)
|
|
1256
|
+
}
|
|
1257
|
+
),
|
|
1258
|
+
props.horizontal === true && /* @__PURE__ */ jsx15(
|
|
1259
|
+
FormattedDescription,
|
|
1260
|
+
{
|
|
1261
|
+
config: props.config,
|
|
1262
|
+
context: props.context,
|
|
1263
|
+
text: props.field.description,
|
|
1264
|
+
translations: props.translations
|
|
1265
|
+
}
|
|
1266
|
+
)
|
|
1267
|
+
]
|
|
1268
|
+
}
|
|
1269
|
+
);
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
// src/component/input-group.tsx
|
|
1273
|
+
import { Fragment, jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1274
|
+
function InputGroup(props) {
|
|
1275
|
+
return /* @__PURE__ */ jsxs8(Fragment, { children: [
|
|
1276
|
+
props.field.name && props.field.label && /* @__PURE__ */ jsx16(
|
|
1277
|
+
InputLabel,
|
|
1278
|
+
{
|
|
1279
|
+
config: props.config,
|
|
1280
|
+
context: props.context,
|
|
1281
|
+
field: props.field,
|
|
1282
|
+
horizontal: props.horizontal,
|
|
1283
|
+
translations: props.translations
|
|
1284
|
+
}
|
|
1285
|
+
),
|
|
1286
|
+
props.children,
|
|
1287
|
+
props.horizontal === false && /* @__PURE__ */ jsx16(
|
|
1288
|
+
FormattedDescription,
|
|
1289
|
+
{
|
|
1290
|
+
config: props.config,
|
|
1291
|
+
context: props.context,
|
|
1292
|
+
text: props.field.description,
|
|
1293
|
+
translations: props.translations
|
|
1294
|
+
}
|
|
1295
|
+
)
|
|
1296
|
+
] });
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
// src/lib/render-If-exists.ts
|
|
1300
|
+
function renderIfExists(value, render) {
|
|
1301
|
+
if (!value) {
|
|
1302
|
+
return null;
|
|
1303
|
+
}
|
|
1304
|
+
return render(value);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
// src/server/component/input.tsx
|
|
1308
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1309
|
+
function Input(props) {
|
|
1310
|
+
const source = resolveSource(props.field, props.value);
|
|
1311
|
+
const { commonPropsWithOptions, defaultValue } = prepareInputProps(
|
|
1312
|
+
props.field,
|
|
1313
|
+
props.commonProps,
|
|
1314
|
+
source,
|
|
1315
|
+
props.value
|
|
1316
|
+
);
|
|
1317
|
+
const defaultProps = prepareDefaultValue(props.field, defaultValue);
|
|
1318
|
+
return renderIfExists(props.config.inputs[props.field.type], (Component) => /* @__PURE__ */ jsx17(
|
|
1319
|
+
InputGroup,
|
|
1320
|
+
{
|
|
1321
|
+
config: props.config,
|
|
1322
|
+
context: props.context,
|
|
1323
|
+
field: props.field,
|
|
1324
|
+
horizontal: props.horizontal,
|
|
1325
|
+
translations: props.translations,
|
|
1326
|
+
children: /* @__PURE__ */ jsx17(
|
|
1327
|
+
Component,
|
|
1328
|
+
{
|
|
1329
|
+
...props.ariaAttributes,
|
|
1330
|
+
...commonPropsWithOptions,
|
|
1331
|
+
...props.dataAttributes,
|
|
1332
|
+
...defaultProps
|
|
1333
|
+
}
|
|
1334
|
+
)
|
|
1335
|
+
}
|
|
1336
|
+
));
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
// src/component/field/field-error.tsx
|
|
1340
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1341
|
+
function FieldError(props) {
|
|
1342
|
+
if (!props.errors || props.errors.length === 0) {
|
|
1343
|
+
return null;
|
|
1344
|
+
}
|
|
1345
|
+
return /* @__PURE__ */ jsx18(
|
|
1346
|
+
"ul",
|
|
1347
|
+
{
|
|
1348
|
+
className: "text-sm text-red-600 dark:text-red-500",
|
|
1349
|
+
id: props.name ? `${props.name}-error` : void 0,
|
|
1350
|
+
children: props.errors?.map((error, index) => /* @__PURE__ */ jsx18("li", { children: error }, props.name ? `${props.name}-error-${index}` : index))
|
|
1351
|
+
}
|
|
1352
|
+
);
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
// src/component/field/field-base.tsx
|
|
1356
|
+
import { twMerge as twMerge2 } from "tailwind-merge";
|
|
1357
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1358
|
+
function FieldBase(props) {
|
|
1359
|
+
const errors = props.errors && props.errors.length > 0;
|
|
1360
|
+
return /* @__PURE__ */ jsx19(
|
|
1361
|
+
"div",
|
|
1362
|
+
{
|
|
1363
|
+
"data-slot": "field",
|
|
1364
|
+
"data-clickable": props.isClickable ? "true" : "false",
|
|
1365
|
+
...errors && { [DATA_INVALID]: "true" },
|
|
1366
|
+
...props.disabled && { [DATA_READONLY]: "true" },
|
|
1367
|
+
"data-orientation": props.orientation,
|
|
1368
|
+
className: twMerge2(
|
|
1369
|
+
"group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500",
|
|
1370
|
+
"data-[clickable=true]:items-start",
|
|
1371
|
+
props.isCheckbox && (props.isReversed ? "flex-row-reverse!" : "flex-row!"),
|
|
1372
|
+
"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",
|
|
1373
|
+
props.className
|
|
1374
|
+
),
|
|
1375
|
+
children: props.children
|
|
1376
|
+
}
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
// src/component/field/field-vertical.tsx
|
|
1381
|
+
import { twMerge as twMerge3 } from "tailwind-merge";
|
|
1382
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1383
|
+
function FieldVertical(props) {
|
|
1384
|
+
return /* @__PURE__ */ jsx20(
|
|
1385
|
+
FieldBase,
|
|
1386
|
+
{
|
|
1387
|
+
...props,
|
|
1388
|
+
orientation: "vertical",
|
|
1389
|
+
className: twMerge3(
|
|
1390
|
+
"gap-3 has-[>[data-slot=field-content]]:items-start",
|
|
1391
|
+
!props.isClickable && "[&>*]:w-full"
|
|
1392
|
+
),
|
|
1393
|
+
children: props.children
|
|
1394
|
+
}
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
// src/component/field/field-horizontal.tsx
|
|
1399
|
+
import { twMerge as twMerge4 } from "tailwind-merge";
|
|
1400
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1401
|
+
function FieldHorizontal(props) {
|
|
1402
|
+
return /* @__PURE__ */ jsx21(
|
|
1403
|
+
FieldBase,
|
|
1404
|
+
{
|
|
1405
|
+
...props,
|
|
1406
|
+
orientation: "horizontal",
|
|
1407
|
+
className: twMerge4(
|
|
1408
|
+
"gap-2 md:flex-row md:gap-4",
|
|
1409
|
+
"[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start",
|
|
1410
|
+
"[&_[role=checkbox]]:mt-[1.5px]",
|
|
1411
|
+
props.isClickable && "md:flex-col",
|
|
1412
|
+
!props.isClickable && [
|
|
1413
|
+
"md:justify-between",
|
|
1414
|
+
"[&>*:not([data-slot=field-content])]:w-full",
|
|
1415
|
+
"[&>*:not([data-slot=field-content])]:md:w-1/2",
|
|
1416
|
+
"[&>*:not([data-slot=field-content])]:xl:w-2/5"
|
|
1417
|
+
]
|
|
1418
|
+
),
|
|
1419
|
+
children: props.children
|
|
1420
|
+
}
|
|
1421
|
+
);
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
// src/component/field/field-group.tsx
|
|
1425
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1426
|
+
function FieldGroup(props) {
|
|
1427
|
+
const clickable = isClickable(props.field);
|
|
1428
|
+
const checkbox = isCheckbox(props.field);
|
|
1429
|
+
const reversed = buildReverse(props.field);
|
|
1430
|
+
if (!props.horizontal) {
|
|
1431
|
+
return /* @__PURE__ */ jsx22(
|
|
1432
|
+
FieldVertical,
|
|
1433
|
+
{
|
|
1434
|
+
disabled: props.disabled,
|
|
1435
|
+
errors: props.errors,
|
|
1436
|
+
isCheckbox: checkbox,
|
|
1437
|
+
isReversed: reversed,
|
|
1438
|
+
isClickable: clickable,
|
|
1439
|
+
children: props.children
|
|
1440
|
+
}
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1443
|
+
return /* @__PURE__ */ jsx22(
|
|
1444
|
+
FieldHorizontal,
|
|
1445
|
+
{
|
|
1446
|
+
disabled: props.disabled,
|
|
1447
|
+
errors: props.errors,
|
|
1448
|
+
isCheckbox: checkbox,
|
|
1449
|
+
isReversed: reversed,
|
|
1450
|
+
isClickable: clickable,
|
|
1451
|
+
children: props.children
|
|
1452
|
+
}
|
|
1453
|
+
);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// src/component/input/input-base.tsx
|
|
1457
|
+
function InputBase(props) {
|
|
1458
|
+
if (!props.field.type) {
|
|
1459
|
+
return null;
|
|
1460
|
+
}
|
|
1461
|
+
const commonProps = buildCommon(props.field, props.disabled);
|
|
1462
|
+
const dataAttributes = buildDataAttributes(props.field);
|
|
1463
|
+
const ariaAttributes = buildAriaAttributes(props.field, props.errors);
|
|
1464
|
+
const field = {
|
|
1465
|
+
...props.field,
|
|
1466
|
+
disabled: commonProps.disabled
|
|
1467
|
+
};
|
|
1468
|
+
return props.children({
|
|
1469
|
+
ariaAttributes,
|
|
1470
|
+
commonProps,
|
|
1471
|
+
dataAttributes,
|
|
1472
|
+
field,
|
|
1473
|
+
horizontal: props.horizontal
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
// src/component/field/field.tsx
|
|
1478
|
+
import { twMerge as twMerge5 } from "tailwind-merge";
|
|
1479
|
+
import { jsx as jsx23, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1480
|
+
function Field(props) {
|
|
1481
|
+
const cols2 = props.field.advanced?.cols;
|
|
1482
|
+
const errors = props.field.name ? props.errors?.[props.field.name] : void 0;
|
|
1483
|
+
const { horizontal } = mergeStyle(props.style, {
|
|
1484
|
+
horizontal: buildOrientation(props.field)
|
|
1485
|
+
});
|
|
1486
|
+
const disabled = buildDisabled(props.field, props.disabled);
|
|
1487
|
+
return /* @__PURE__ */ jsxs9("div", { className: twMerge5("flex flex-col gap-3", getSpan(cols2)), children: [
|
|
1488
|
+
/* @__PURE__ */ jsx23(
|
|
1489
|
+
FieldGroup,
|
|
1490
|
+
{
|
|
1491
|
+
disabled,
|
|
1492
|
+
errors,
|
|
1493
|
+
field: props.field,
|
|
1494
|
+
horizontal,
|
|
1495
|
+
children: /* @__PURE__ */ jsx23(
|
|
1496
|
+
InputBase,
|
|
1497
|
+
{
|
|
1498
|
+
disabled,
|
|
1499
|
+
errors,
|
|
1500
|
+
field: props.field,
|
|
1501
|
+
horizontal,
|
|
1502
|
+
children: props.children
|
|
1503
|
+
}
|
|
1504
|
+
)
|
|
1505
|
+
}
|
|
1506
|
+
),
|
|
1507
|
+
/* @__PURE__ */ jsx23(FieldError, { errors, name: props.field.name })
|
|
1508
|
+
] });
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
// src/component/field/field-list-item.tsx
|
|
1512
|
+
import { twMerge as twMerge6 } from "tailwind-merge";
|
|
1513
|
+
import { useState as useState3 } from "react";
|
|
1514
|
+
import { jsx as jsx24, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1515
|
+
function FieldListItem(props) {
|
|
1516
|
+
const [isOpen, setIsOpen] = useState3(
|
|
1517
|
+
props.collapsible ? !props.collapsed : true
|
|
1518
|
+
);
|
|
1519
|
+
function handleRemove() {
|
|
1520
|
+
if (props.canRemove && props.onRemove) {
|
|
1521
|
+
props.onRemove(props.index);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
function handleToggle() {
|
|
1525
|
+
setIsOpen((previous) => !previous);
|
|
1526
|
+
}
|
|
1527
|
+
const removeButton = props.canRemove && props.onRemove != null && /* @__PURE__ */ jsx24(
|
|
1528
|
+
"button",
|
|
1529
|
+
{
|
|
1530
|
+
"aria-label": `Remove ${props.label} item ${props.index + 1}`,
|
|
1531
|
+
className: twMerge6(
|
|
1532
|
+
"rounded p-1 text-xl text-slate-400",
|
|
1533
|
+
"transition-colors duration-150",
|
|
1534
|
+
"hover:text-red-500",
|
|
1535
|
+
"focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:outline-none",
|
|
1536
|
+
"dark:text-slate-500 dark:hover:text-red-400"
|
|
1537
|
+
),
|
|
1538
|
+
onClick: handleRemove,
|
|
1539
|
+
type: "button",
|
|
1540
|
+
children: /* @__PURE__ */ jsx24("span", { "aria-hidden": "true", children: "\xD7" })
|
|
1541
|
+
}
|
|
1542
|
+
);
|
|
1543
|
+
if (props.isMultiField) {
|
|
1544
|
+
return /* @__PURE__ */ jsxs10(
|
|
1545
|
+
"div",
|
|
1546
|
+
{
|
|
1547
|
+
"data-slot": "list-item-card",
|
|
1548
|
+
className: "rounded-lg border border-slate-100 p-4 dark:border-slate-900",
|
|
1549
|
+
children: [
|
|
1550
|
+
/* @__PURE__ */ jsxs10("div", { className: "mb-3 flex items-center justify-between", children: [
|
|
1551
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
|
|
1552
|
+
props.collapsible && /* @__PURE__ */ jsx24(
|
|
1553
|
+
"button",
|
|
1554
|
+
{
|
|
1555
|
+
"aria-label": isOpen ? "Collapse" : "Expand",
|
|
1556
|
+
className: twMerge6(
|
|
1557
|
+
"rounded p-1 text-slate-400 hover:bg-slate-50",
|
|
1558
|
+
"transition-colors duration-150",
|
|
1559
|
+
"dark:text-slate-500 dark:hover:bg-slate-800"
|
|
1560
|
+
),
|
|
1561
|
+
onClick: handleToggle,
|
|
1562
|
+
type: "button",
|
|
1563
|
+
children: /* @__PURE__ */ jsx24(ChevronIcon, { expanded: isOpen })
|
|
1564
|
+
}
|
|
1565
|
+
),
|
|
1566
|
+
/* @__PURE__ */ jsxs10("span", { className: "text-sm font-medium text-slate-300 dark:text-slate-400", children: [
|
|
1567
|
+
props.label,
|
|
1568
|
+
" ",
|
|
1569
|
+
props.index + 1,
|
|
1570
|
+
!isOpen && props.preview && /* @__PURE__ */ jsx24("div", { className: "flex items-center gap-2 overflow-hidden text-ellipsis whitespace-nowrap text-slate-400 dark:text-slate-500", children: props.preview })
|
|
1571
|
+
] })
|
|
1572
|
+
] }),
|
|
1573
|
+
removeButton
|
|
1574
|
+
] }),
|
|
1575
|
+
/* @__PURE__ */ jsx24(Collapsible, { visible: isOpen, children: /* @__PURE__ */ jsx24(Group, { children: props.children }) })
|
|
1576
|
+
]
|
|
1577
|
+
}
|
|
1578
|
+
);
|
|
1579
|
+
}
|
|
1580
|
+
return /* @__PURE__ */ jsxs10("div", { className: "flex items-start gap-2", children: [
|
|
1581
|
+
props.collapsible && /* @__PURE__ */ jsx24(
|
|
1582
|
+
"button",
|
|
1583
|
+
{
|
|
1584
|
+
"aria-label": isOpen ? "Collapse" : "Expand",
|
|
1585
|
+
className: twMerge6(
|
|
1586
|
+
"rounded p-1 text-slate-400 hover:bg-slate-50",
|
|
1587
|
+
"transition-colors duration-150",
|
|
1588
|
+
"dark:text-slate-500 dark:hover:bg-slate-800",
|
|
1589
|
+
isOpen && "mt-7"
|
|
1590
|
+
),
|
|
1591
|
+
onClick: handleToggle,
|
|
1592
|
+
type: "button",
|
|
1593
|
+
children: /* @__PURE__ */ jsx24(ChevronIcon, { expanded: isOpen })
|
|
1594
|
+
}
|
|
1595
|
+
),
|
|
1596
|
+
/* @__PURE__ */ jsx24("div", { className: "flex grow flex-col", children: /* @__PURE__ */ jsx24(Collapsible, { visible: isOpen, children: /* @__PURE__ */ jsx24(Group, { children: props.children }) }) }),
|
|
1597
|
+
removeButton && /* @__PURE__ */ jsx24("div", { className: twMerge6("shrink-0", isOpen && "mt-7"), children: removeButton })
|
|
1598
|
+
] });
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
// src/component/field/field-list.tsx
|
|
1602
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
1603
|
+
function FieldList(props) {
|
|
1604
|
+
const label = getLabel(props.field);
|
|
1605
|
+
const isMultiField = isMultiFieldList(props.field);
|
|
1606
|
+
return getInitialList(props.field, props.value).map((index) => /* @__PURE__ */ jsx25(
|
|
1607
|
+
FieldListItem,
|
|
1608
|
+
{
|
|
1609
|
+
collapsed: props.field.advanced?.collapsed,
|
|
1610
|
+
collapsible: props.field.advanced?.collapsible,
|
|
1611
|
+
index,
|
|
1612
|
+
isMultiField,
|
|
1613
|
+
label,
|
|
1614
|
+
children: props.children(index)
|
|
1615
|
+
},
|
|
1616
|
+
index
|
|
1617
|
+
));
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
// src/component/list.tsx
|
|
1621
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
1622
|
+
function List(props) {
|
|
1623
|
+
const empty = Array.isArray(props.field.fields) && props.field.fields.length === 0;
|
|
1624
|
+
return /* @__PURE__ */ jsx26(
|
|
1625
|
+
FieldSetBase,
|
|
1626
|
+
{
|
|
1627
|
+
description: props.field.description,
|
|
1628
|
+
empty,
|
|
1629
|
+
id: props.field.name,
|
|
1630
|
+
title: props.field.label,
|
|
1631
|
+
children: props.children
|
|
1632
|
+
}
|
|
1633
|
+
);
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
// src/component/slot/list-slot.tsx
|
|
1637
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
1638
|
+
function ListSlot({ children, field, value }) {
|
|
1639
|
+
return /* @__PURE__ */ jsx27(List, { field, children: /* @__PURE__ */ jsx27(FieldList, { field, value, children }) });
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
// src/component/column.tsx
|
|
1643
|
+
import { twMerge as twMerge7 } from "tailwind-merge";
|
|
1644
|
+
import { jsx as jsx28, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1645
|
+
function Column(props) {
|
|
1646
|
+
const cols2 = getColumn(props.column?.advanced?.cols);
|
|
1647
|
+
return /* @__PURE__ */ jsxs11("div", { className: "flex w-full flex-col gap-4", children: [
|
|
1648
|
+
/* @__PURE__ */ jsx28("div", { className: twMerge7("grid grid-cols-1 gap-3 sm:gap-4", cols2), children: props.children }),
|
|
1649
|
+
props.column?.description && /* @__PURE__ */ jsx28(
|
|
1650
|
+
FormattedDescription,
|
|
1651
|
+
{
|
|
1652
|
+
config: props.config,
|
|
1653
|
+
context: props.context,
|
|
1654
|
+
text: props.column.description,
|
|
1655
|
+
translations: props.translations
|
|
1656
|
+
}
|
|
1657
|
+
)
|
|
1658
|
+
] });
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
// src/component/slot/slot-base.tsx
|
|
1662
|
+
import { Fragment as Fragment2 } from "react";
|
|
1663
|
+
|
|
1664
|
+
// src/component/slot/slot-list.tsx
|
|
1665
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
1666
|
+
function SlotList(props) {
|
|
1667
|
+
const fields = Array.isArray(props.field.fields) ? props.field.fields.map((field) => {
|
|
1668
|
+
if (isField(field)) {
|
|
1669
|
+
return {
|
|
1670
|
+
...field,
|
|
1671
|
+
name: `${props.field.name}.${props.index}.${field.name}`
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
if (isColumn(field)) {
|
|
1675
|
+
return {
|
|
1676
|
+
...field,
|
|
1677
|
+
fields: field.fields.map((columnField) => ({
|
|
1678
|
+
...columnField,
|
|
1679
|
+
name: `${props.field.name}.${props.index}.${columnField.name}`
|
|
1680
|
+
}))
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
return field;
|
|
1684
|
+
}) : [];
|
|
1685
|
+
return /* @__PURE__ */ jsx29(
|
|
1686
|
+
SlotBase,
|
|
1687
|
+
{
|
|
1688
|
+
children: props.children,
|
|
1689
|
+
components: props.components,
|
|
1690
|
+
config: props.config,
|
|
1691
|
+
context: props.context,
|
|
1692
|
+
disabled: props.disabled,
|
|
1693
|
+
fields,
|
|
1694
|
+
style: props.style,
|
|
1695
|
+
translations: props.translations,
|
|
1696
|
+
value: props.value
|
|
1697
|
+
}
|
|
1698
|
+
);
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
// src/component/slot/slot-base.tsx
|
|
1702
|
+
import { jsx as jsx30, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1703
|
+
function SlotBase(props) {
|
|
1704
|
+
const { field: Field2, list: List2 } = props.components;
|
|
1705
|
+
return prepare(props.fields).map((field, index) => /* @__PURE__ */ jsxs12(Fragment2, { children: [
|
|
1706
|
+
isColumn(field) && /* @__PURE__ */ jsx30(
|
|
1707
|
+
Column,
|
|
1708
|
+
{
|
|
1709
|
+
column: field,
|
|
1710
|
+
config: props.config,
|
|
1711
|
+
context: props.context,
|
|
1712
|
+
translations: props.translations,
|
|
1713
|
+
children: /* @__PURE__ */ jsx30(SlotBase, { ...props, fields: field.fields })
|
|
1714
|
+
}
|
|
1715
|
+
),
|
|
1716
|
+
isField(field) && /* @__PURE__ */ jsx30(Field2, { disabled: props.disabled, field, style: props.style, children: props.children }),
|
|
1717
|
+
isList(field) && /* @__PURE__ */ jsx30(List2, { field, value: props.value, children: (index2) => /* @__PURE__ */ jsx30(
|
|
1718
|
+
SlotList,
|
|
1719
|
+
{
|
|
1720
|
+
children: props.children,
|
|
1721
|
+
components: props.components,
|
|
1722
|
+
config: props.config,
|
|
1723
|
+
context: props.context,
|
|
1724
|
+
disabled: props.disabled,
|
|
1725
|
+
field,
|
|
1726
|
+
index: index2,
|
|
1727
|
+
style: props.style,
|
|
1728
|
+
translations: props.translations,
|
|
1729
|
+
value: props.value
|
|
1730
|
+
}
|
|
1731
|
+
) })
|
|
1732
|
+
] }, index));
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
// src/component/slot/slot-create.tsx
|
|
1736
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
1737
|
+
function createSlot(components) {
|
|
1738
|
+
const CreateSlot = (props) => /* @__PURE__ */ jsx31(SlotBase, { ...props, components });
|
|
1739
|
+
return CreateSlot;
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
// src/component/slot/slot.tsx
|
|
1743
|
+
var Slot = createSlot({ field: Field, list: ListSlot });
|
|
1744
|
+
|
|
1745
|
+
// src/server/component/form.tsx
|
|
1746
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
1747
|
+
function Form2(props) {
|
|
1748
|
+
const translations = props.translations?.[props.lang ?? ""];
|
|
1749
|
+
return /* @__PURE__ */ jsx32(
|
|
1750
|
+
Form,
|
|
1751
|
+
{
|
|
1752
|
+
advanced: props.advanced,
|
|
1753
|
+
config: props.config,
|
|
1754
|
+
control: props.children,
|
|
1755
|
+
definition: props.definition,
|
|
1756
|
+
readOnly: props.readOnly,
|
|
1757
|
+
sections: props.sections,
|
|
1758
|
+
children: ({ disabled, fields }) => /* @__PURE__ */ jsx32(
|
|
1759
|
+
Slot,
|
|
1760
|
+
{
|
|
1761
|
+
config: props.config,
|
|
1762
|
+
context: props.context,
|
|
1763
|
+
disabled,
|
|
1764
|
+
fields,
|
|
1765
|
+
style: props.config.style,
|
|
1766
|
+
translations,
|
|
1767
|
+
value: props.value,
|
|
1768
|
+
children: (internal) => /* @__PURE__ */ jsx32(
|
|
1769
|
+
Input,
|
|
1770
|
+
{
|
|
1771
|
+
...internal,
|
|
1772
|
+
config: props.config,
|
|
1773
|
+
context: props.context,
|
|
1774
|
+
translations,
|
|
1775
|
+
value: props.value
|
|
1776
|
+
}
|
|
1777
|
+
)
|
|
1778
|
+
}
|
|
1779
|
+
)
|
|
1780
|
+
}
|
|
1781
|
+
);
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
// src/server/component/fallback.tsx
|
|
1785
|
+
import { Suspense } from "react";
|
|
1786
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
1787
|
+
function Fallback(props) {
|
|
1788
|
+
return /* @__PURE__ */ jsx33(
|
|
1789
|
+
Suspense,
|
|
1790
|
+
{
|
|
1791
|
+
fallback: /* @__PURE__ */ jsx33(Form2, { config: props.config, sections: props.sections, readOnly: true }),
|
|
1792
|
+
children: props.children
|
|
1793
|
+
}
|
|
1794
|
+
);
|
|
1795
|
+
}
|
|
1796
|
+
export {
|
|
1797
|
+
Fallback,
|
|
1798
|
+
Form2 as Form
|
|
1799
|
+
};
|