react-luna-form 0.0.43 → 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/dist/types/luna-react/src/client/component/field/field-preview-item.d.ts +4 -0
- package/dist/types/luna-react/src/client/component/field/field-preview.d.ts +4 -0
- package/dist/types/luna-react/src/client/component/form-content.d.ts +3 -0
- package/dist/types/luna-react/src/client/component/form.d.ts +3 -0
- package/dist/types/luna-react/src/client/component/slot/slot.d.ts +3 -0
- package/dist/types/luna-react/src/client/context/keep-value-context.d.ts +1 -0
- package/dist/types/luna-react/src/client/hook/use-input-core.d.ts +3 -1
- package/dist/types/luna-react/src/client/hook/use-input.d.ts +3 -1
- package/dist/types/luna-react/src/client/hook/use-schema.d.ts +3 -1
- package/dist/types/luna-react/src/client/hook/use-store.d.ts +3 -1
- package/dist/types/luna-react/src/client/lib/persistence-context.d.ts +4 -0
- package/dist/types/luna-react/src/component/collapsible.d.ts +4 -0
- package/dist/types/luna-react/src/component/column.d.ts +4 -0
- package/dist/types/luna-react/src/component/field/field-list-item.d.ts +3 -0
- package/dist/types/luna-react/src/component/field/field-set-base.d.ts +1 -0
- package/dist/types/luna-react/src/component/field/field-set.d.ts +4 -0
- package/dist/types/luna-react/src/component/form.d.ts +3 -0
- package/dist/types/luna-react/src/component/formatted-description.d.ts +2 -1
- package/dist/types/luna-react/src/component/legend.d.ts +2 -1
- package/dist/types/luna-react/src/component/slot/slot-base.d.ts +4 -1
- package/dist/types/luna-react/src/component/slot/slot-create.d.ts +4 -1
- package/dist/types/luna-react/src/component/slot/slot-list.d.ts +4 -1
- package/dist/types/luna-react/src/component/slot/slot.d.ts +3 -0
- package/dist/types/luna-react/src/server/component/form.d.ts +3 -0
- package/package.json +2 -2
package/dist/server/esm/index.js
CHANGED
|
@@ -1 +1,1799 @@
|
|
|
1
|
-
import{jsx as _n}from"react/jsx-runtime";function pe(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return _n("div",{"data-slot":"field-control",className:"w-full",children:t})}import{Activity as yr,useCallback as xr,useState as br}from"react";import{jsx as ge}from"react/jsx-runtime";function ye(e){return ge("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:ge("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"})})}var D="input",xe="input/date",be="input/email",Te="input/number";var he="input/time";var Re="textarea",Fe="radio",Se="checkbox",Z="list";var Ae="select",Ne="select/day",Ce="select/month",Ie="select/timezone",Ee="select/year";var ve="chips",ke="chips/day",Le="chips/month",A="column",Pe="description",K="fields",De="label",W="value",w="options",q="email",we="number",Oe="password",Me="tel",N="text",_e="aria-errormessage",Ve="aria-invalid",He="data-invalid",ze="data-readonly",Ge="aria",$e="data",Be="max",Ue="maxLength",Ye="min",Xe="minLength",h="$ref";var Ze="type",Ke={Africa:"Africa",America:"Americas",Asia:"Asia / Pacific",Atlantic:"Atlantic",Australia:"Asia / Pacific",Europe:"Europe",Indian:"Asia / Pacific",Pacific:"Asia / Pacific"};function s(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function m(e){return f(e)||typeof e=="number"||Vn(e)}function f(e){return typeof e=="string"}function Vn(e){return typeof e=="boolean"}function We(e,t=W){if(e!=null){if(Array.isArray(e)&&e.every(m)||m(e))return e;if(s(e)){let n=Hn(e,t);if(m(n))return n}}}function Hn(e,t){let n=p(e,t);if(m(n))return n}function p(e,t){if(!t||!s(e))return null;let n=t.split(".").filter(o=>o!=="");if(n.length===0)return null;let r=e;for(let o of n)if(s(r)&&o in r)r=r[o];else return null;return r}function qe(e,t={description:Pe,label:De,value:W}){return e.map(n=>{if(s(n)){let r=p(n,t.label),o=p(n,t.value);if(m(r)&&m(o)){let i=p(n,t.description);return{label:`${r}`,value:`${o}`,...m(i)&&{description:`${i}`}}}}return n})}function Je(e=N){let t=e.lastIndexOf("/"),n=t===-1?e:e.slice(t+1);return n&&n!==D?n.trim().toLowerCase():N}var zn=/\[([^\]]{1,500})\]\(([^)]{1,2000})\)/g;function J(e,t={}){if(f(e))return Gn(e,t);if(Array.isArray(e))return e.map(n=>J(n,t));if(s(e)){let n={};for(let r in e)n[r]=J(e[r],t);return n}return e}function O(e,t={}){return Q(e)?J(e,t):e}function Q(e){return f(e)?/{([^}]{1,200})}/.test(e):Array.isArray(e)?e.some(t=>Q(t)):s(e)?Object.values(e).some(t=>Q(t)):!1}function Gn(e,t={}){return e.replace(/{([^}]{1,200})}/g,(n,r)=>{let o=r.includes(".")?p(t,r):t[r];return m(o)?String(o):n})}function Qe(e,t){if(!f(e)||!e||e.trim().length===0)return null;let n,r=0,o=!1,i=[];for(;(n=zn.exec(e))!==null;){let[l,c,d]=n,u=n.index;o=!0,u>r&&i.push(e.substring(r,u));let S=t?t(u,d,c):l;i.push(S),r=u+l.length}return o?(r<e.length&&i.push(e.substring(r)),i):e}var je=e=>a(Ne)(e),et=e=>a(Ce)(e),tt=e=>a(Ee)(e),nt=e=>a(Ie)(e),rt=e=>a(ke)(e),ot=e=>a(Le)(e),it=a(xe),j=a(he),g=a(Se),ee=a(ve),b=a(Fe),lt=a(D),y=a(Ae),at=a(Re),st=a(N,q,Oe,Me),Ro=a(be,q),ct=a(Te,we);function dt(e){return b(e)||g(e)}function ut(e){return e.type===Z}function R(e){return e.type===A}function M(e){return e.type!==A&&e.type!==Z}function te(e){return y(e)||b(e)}function C(e){return e!=null&&e!==""}function a(...e){return t=>{let n=f(t.type)?t.type:void 0;return n?e.some(r=>n===r||n?.startsWith(`${r}/`)):!1}}function ft(e,t={}){if(y(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&s(n))return[n]}}function mt(e){return b(e)||g(e)?!0:e.advanced?.horizontal??!1}function pt(e){return g(e)?e.advanced?.reverse!==!1:!1}function gt(e,t){let n=e.readonly??!1;return t||n}function yt(e){if(b(e)||y(e)&&!e.disabled){let t=e.source;if(Array.isArray(t)||s(t)&&!(h in t))return t}}import{isValid as Tt,parse as ht,format as Rt}from"date-fns";var $n=/^\d+$/,Ft=new Date(2e3,0,1),Bn=()=>"supportedValuesOf"in Intl?Intl.supportedValuesOf("timeZone"):[];function ne(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function re(){return Array.from({length:7},(e,t)=>({value:t.toString(),label:new Date(2e3,0,2+t).toLocaleString("default",{weekday:"long"})}))}function St(e,t){return t>=e?Array.from({length:t-e+1},(n,r)=>{let o=e+r;return{value:o.toString(),label:o.toString()}}):[]}function oe(){return new Date().getFullYear()}function Un(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function Yn(e){let t=e.indexOf("/"),n=t===-1?e:e.slice(0,t);return Ke[n]??"Other"}function Xn(e,t){return(e.find(r=>r.type==="timeZoneName")?.value??t).replace(/\s+(?:Standard|Daylight(?: Saving)?|Summer|Winter)\s+Time$/,"")}function xt(e,t){let n=new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(t),r=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=Xn(r,e);return{offset:i,longName:l}}function bt(e){return e.slice(e.lastIndexOf("/")+1).replace(/_/g," ")}function At(){let e=new Date,t=Un(),n=new Map,r=bt(t),{offset:o,longName:i}=xt(t,e),l={value:t,label:`${r} - ${i} (${o})`};for(let d of Bn()){if(d===t)continue;let u=bt(d),{offset:S,longName:Mn}=xt(d,e),fe={value:d,label:`${u} - ${Mn} (${S})`},X=Yn(d);if(X==="Other")continue;let me=n.get(X);me?me.push(fe):n.set(X,[fe])}for(let d of n.values())d.sort((u,S)=>u.label.localeCompare(S.label));let c=Array.from(n.entries()).sort(([d],[u])=>d.localeCompare(u)).map(([d,u])=>({label:d,items:u}));return[{label:"Suggested",items:[l]},...c]}function ie(e,t){if(typeof e=="number")return e;let n=t??oe(),r=e.trim().toLowerCase();if(r.startsWith("current")){let o=r.match(/^current([+-])(\d+)$/);if(o){let[,i,l]=o,c=parseInt(l,10);if(!isNaN(c))return i==="+"?n+c:n-c}return n}return $n.test(r)?parseInt(r,10):n}function Nt(e,t){if(!e)return"";try{let n=ht(e,t,Ft);return Tt(n)?Rt(n,"yyyy-MM-dd"):""}catch{return""}}function Ct(e,t){if(!e)return"";try{let n=ht(e,t,Ft);return Tt(n)?Rt(n,"HH:mm:ss"):""}catch{return""}}function le(e){return e.advanced?.format??"HH:mm"}function It(e){return e.advanced?.format??"MMMM d, yyyy"}var _=oe();function Zn(e){if(ee(e))return Kn(e)}function Kn(e){if(rt(e))return re();if(ot(e))return ne()}function Wn(e){if(y(e))return qn(e)}function qn(e){if(je(e))return re();if(et(e))return ne();if(tt(e)){let t=e.advanced?.length?.min??_,n=e.advanced?.length?.max??_+5;return St(ie(t,_),ie(n,_))}if(nt(e))return At()}function Et(e,t=!1){let n={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return lt(e)?{...n,...Jn(e)}:y(e)?{...n,...vt(e,Wn)}:at(e)?{...n,...jn(e)}:ee(e)?{...n,...Qn(e)}:n}function Jn(e){let t=Je(e.type),n={...e,type:t};return{...tr(e),...kt(e),...er(n),...st(n)?Lt(n):{},type:t}}function vt(e,t){let n=t(e);return n?{options:n}:{}}function Qn(e){let t=vt(e,Zn),n=e.advanced?.multiple??!0;return{...t,multiple:n}}function jn(e){return{...kt(e),...Lt(e)}}function kt(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function er(e){return ct(e)?nr(e):{}}function tr(e){if(j(e)){let t=le(e);return{step:t==="HH:mm:ss"||t==="hh:mm:ss a"?"1":"60"}}return{}}function Lt(e){return Pt(e,{min:Xe,max:Ue})}function nr(e){return Pt(e,{min:Ye,max:Be})}function Pt(e,t){let n={},r=e.advanced?.length;return r&&(r.min!==void 0&&(n[t.min]=r.min),r.max!==void 0&&(n[t.max]=r.max)),n}function Dt(e,t){let n=yt(e);return n||ft(e,t)}function rr(e,t){let n=s(t)&&e.name in t?t[e.name]:t,r=We(n,e.advanced?.entity);return j(e)&&C(r)?or(e,r):it(e)&&C(r)?sr(e,r):r}function or(e,t){let n=le(e);return f(t)?Ct(t,n):t}function ir(e,t,n){return te(e)&&Array.isArray(n)?{...t,[w]:n}:t}function lr(e,t,n){if(e.required&&!C(n)&&y(e)&&e.advanced?.preselected!==!1&&w in t){let r=t[w];if(Array.isArray(r)&&r.length===1)return r[0]}return n}function ar(e,t){return te(e)&&Array.isArray(t)?qe(t,e.advanced?.options):t}function wt(e,t,n,r){let o=rr(e,r),i=Array.isArray(n)?ar(e,n):n,l=ir(e,t,i),c=lr(e,l,o);return{commonPropsWithOptions:l,defaultValue:c}}function Ot(e,t){return g(e)?{defaultChecked:C(t)}:{defaultValue:t}}function sr(e,t){let n=It(e);return f(t)?Nt(t,n):t}var cr=/^#\/definition\//;function H(e=[],t){let n=V(e,t);return Array.isArray(n)?n.filter(ur).sort((r,o)=>Mt(r)-Mt(o)):[]}function V(e,t,n=new Map,r=new WeakSet){if(!dr(t)||!e||typeof e!="object")return e;if(n.has(e))return n.get(e);if(r.has(e))return e;if(r.add(e),Array.isArray(e))return e.map(i=>V(i,t,n,r));if(h in e&&f(e[h])){let i=e[h].replace(cr,""),l=p(t,i);return l!==null?V(l,t,n,r):e}let o={};for(let[i,l]of Object.entries(e))o[i]=V(l,t,n,r);return r.delete(e),n.set(e,o),o}function _t(e){return Object.entries(e??{})}function Mt(e){return e.order??Number.MAX_VALUE}function dr(e){return e!==void 0&&s(e)&&Object.keys(e).length>0}function ur(e){return Ze in e?!0:Array.isArray(e[K])?e[K].length>0:!0}function Vt(e,t){let n={};for(let[r,o]of _t(t))n[`${e}-${r}`]=o;return n}function fr(e){return Vt(Ge,e)}function mr(e){return Vt($e,e)}function Ht(e,t){let n=fr(e.advanced?.aria);return t&&t.length>0&&(n[Ve]="true",n[_e]=`${e.name}-error`),n}function zt(e){return mr(e.advanced?.data)}var Gt={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},$t={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function Bt(e,t=2){return Gt[e&&e in Gt?e:t]}function Ut(e){if(e&&e in $t)return $t[e]}function pr(e,t){let n=e.advanced?.length?.min??1;if(t){let r=p(t,e.name);if(Array.isArray(r))return Math.max(r.length,n)}return Math.max(n,0)}function Yt(e){return!Array.isArray(e.fields)||e.fields.length===0?!1:e.fields.length>1||e.fields[0].type===A}function Xt(e,t){let n=pr(e,t);return Array.from({length:n},(r,o)=>o)}function Zt(e){return e.label??e.name}function F(e,t){return e?t?t[e]??e:e:""}function z(e,t){return{...e,...t}}import{jsx as gr}from"react/jsx-runtime";function x(e){return Qe(e,(t,n,r)=>gr("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:r},`${n}-${t}`))}import{jsx as I,jsxs as ae}from"react/jsx-runtime";function Kt(e){let{fields:t=[]}=e.section,[n,r]=br(!1),o=xr(()=>r(i=>!i),[]);return ae("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:[I("legend",{children:ae("button",{className:"flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",onClick:o,type:"button",children:[I(ye,{expanded:n}),I("span",{children:x(e.section.title)})]})}),I(yr,{mode:n?"visible":"hidden",children:ae("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&&I("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:x(e.section.description)}),e.group]})})]})}import{Fragment as Tr,jsx as Wt,jsxs as hr}from"react/jsx-runtime";function qt(e){return hr(Tr,{children:[e.title&&Wt("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:x(e.title)}),e.description&&Wt("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:x(e.description)})]})}import{jsx as Rr,jsxs as Fr}from"react/jsx-runtime";function G(e){return Fr("fieldset",{"data-slot":"field-set","data-empty":e.empty,className:"flex flex-col data-[empty=false]:gap-6",id:e.id,children:[Rr(qt,{description:e.description,title:e.title}),e.children]})}import{jsx as Sr}from"react/jsx-runtime";function T(e){return Sr("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 se}from"react/jsx-runtime";function Jt(e){let{fields:t=[]}=e.section,{compact:n}=z(e.style,{compact:e.section.compact}),r=se(T,{compact:n,children:e.children});return!e.section.title&&!e.section.description?r:e.section.advanced?se(Kt,{section:e.section,group:r}):se(G,{description:e.section.description,empty:t.length===0,id:e.section.id?.toString(),title:e.section.title,children:r})}import{useAtomValue as kr}from"jotai";import{atom as E}from"jotai";import{atomFamily as Ar}from"jotai-family";import{deepEqual as Qt}from"fast-equals";function Nr(e,t){let{[t]:n,...r}=e;return r}function Cr(e){return Ar(t=>E(n=>n(e)[t]??void 0,(n,r,o)=>{let i=n(e);if(o!=null){let l=i[t];Qt(l,o)||r(e,{...i,[t]:o})}else t in i&&r(e,Nr(i,t))}))}function Ir(e){return E(null,(t,n)=>{let r=t(e);r&&Object.keys(r).length>0&&n(e,{})})}function Er(e){return E(null,(t,n,r)=>{let i={...t(e)},l=!1;for(let c of r)c in i&&(delete i[c],l=!0);l&&n(e,i)})}function vr(e){return E(null,(t,n,r)=>{let o=t(e);Qt(o,r)||n(e,r)})}function jt(e={}){let t=E(e);return{atom:t,clearAll:Ir(t),clear:Er(t),bulkReport:vr(t),report:Cr(t)}}var en=jt(),tn=en.atom,Ai=en.report;function Lr(e,t){return e.fields.every(n=>nn(n,t))}function nn(e,t){return t[e.name]?.hidden??e.hidden??!1}function Pr(e,t){return R(e)?Lr(e,t):nn(e,t)}function rn(e){let t=kr(tn);return e.container&&(t[e.container.name]?.hidden??e.container.hidden??!1)||e.fields.length===0||e.fields.every(r=>Pr(r,t))?null:e.children}import{jsx as on}from"react/jsx-runtime";function ln(){return on("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:on("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}import{jsx as v,jsxs as an}from"react/jsx-runtime";function sn(e){let t=H(e.sections,e.definition);return v("div",{className:"h-full w-full",children:v("form",{noValidate:e.noValidate,action:e.action,children:an(T,{children:[t.map((n,r)=>an(rn,{fields:n.fields??[],children:[v(Jt,{section:n,style:e.config.style,children:e.children({disabled:e.readOnly,fields:n.fields})}),n.separator&&v(ln,{})]},r)),e.control&&v(pe,{isPending:e.isPending,children:e.control})]})})})}import{jsx as Dr}from"react/jsx-runtime";function $(e){return Dr("p",{className:"-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}import{jsx as wr}from"react/jsx-runtime";function B(e){let t={context:e.context,env:e.config?.env},n=F(O(e.text,t),e.translations),r=x(n);return r?wr($,{children:r}):null}import{twMerge as Or}from"tailwind-merge";import{jsx as Mr,jsxs as _r}from"react/jsx-runtime";function cn(e){let t=e.style?.showOptionalLabel??!0,n=b(e.field)||g(e.field);return _r("label",{"data-slot":"field-label","data-normal":n,className:Or("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&&Mr("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:F("(Optional)",e.translations)})]})}import{jsx as dn,jsxs as Vr}from"react/jsx-runtime";function un(e){let t={context:e.context,env:e.config?.env},n=O(e.field.label,t);return Vr("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[dn(cn,{field:e.field,style:e.config?.style,translations:e.translations,children:F(n,e.translations)}),e.horizontal===!0&&dn(B,{config:e.config,context:e.context,text:e.field.description,translations:e.translations})]})}import{Fragment as Hr,jsx as fn,jsxs as zr}from"react/jsx-runtime";function mn(e){return zr(Hr,{children:[e.field.name&&e.field.label&&fn(un,{config:e.config,context:e.context,field:e.field,horizontal:e.horizontal,translations:e.translations}),e.children,e.horizontal===!1&&fn(B,{config:e.config,context:e.context,text:e.field.description,translations:e.translations})]})}function pn(e,t){return e?t(e):null}import{jsx as gn}from"react/jsx-runtime";function yn(e){let t=Dt(e.field,e.value),{commonPropsWithOptions:n,defaultValue:r}=wt(e.field,e.commonProps,t,e.value),o=Ot(e.field,r);return pn(e.config.inputs[e.field.type],i=>gn(mn,{config:e.config,context:e.context,field:e.field,horizontal:e.horizontal,translations:e.translations,children:gn(i,{...e.ariaAttributes,...n,...e.dataAttributes,...o})}))}import{jsx as xn}from"react/jsx-runtime";function bn(e){return!e.errors||e.errors.length===0?null:xn("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)=>xn("li",{children:t},e.name?`${e.name}-error-${n}`:n))})}import{twMerge as Gr}from"tailwind-merge";import{jsx as $r}from"react/jsx-runtime";function U(e){let t=e.errors&&e.errors.length>0;return $r("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[He]:"true"},...e.disabled&&{[ze]:"true"},"data-orientation":e.orientation,className:Gr("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 Br}from"tailwind-merge";import{jsx as Ur}from"react/jsx-runtime";function Tn(e){return Ur(U,{...e,orientation:"vertical",className:Br("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}import{twMerge as Yr}from"tailwind-merge";import{jsx as Xr}from"react/jsx-runtime";function hn(e){return Xr(U,{...e,orientation:"horizontal",className:Yr("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 Rn}from"react/jsx-runtime";function Fn(e){let t=dt(e.field),n=g(e.field),r=pt(e.field);return e.horizontal?Rn(hn,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children}):Rn(Tn,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children})}function Sn(e){if(!e.field.type)return null;let t=Et(e.field,e.disabled),n=zt(e.field),r=Ht(e.field,e.errors),o={...e.field,disabled:t.disabled};return e.children({ariaAttributes:r,commonProps:t,dataAttributes:n,field:o,horizontal:e.horizontal})}import{twMerge as Zr}from"tailwind-merge";import{jsx as ce,jsxs as Kr}from"react/jsx-runtime";function An(e){let t=e.field.advanced?.cols,n=e.field.name?e.errors?.[e.field.name]:void 0,{horizontal:r}=z(e.style,{horizontal:mt(e.field)}),o=gt(e.field,e.disabled);return Kr("div",{className:Zr("flex flex-col gap-3",Ut(t)),children:[ce(Fn,{disabled:o,errors:n,field:e.field,horizontal:r,children:ce(Sn,{disabled:o,errors:n,field:e.field,horizontal:r,children:e.children})}),ce(bn,{errors:n,name:e.field.name})]})}import{twMerge as Wr}from"tailwind-merge";import{jsx as k,jsxs as Y}from"react/jsx-runtime";function Nn(e){function t(){e.canRemove&&e.onRemove&&e.onRemove(e.index)}let n=e.canRemove&&e.onRemove!=null&&k("button",{"aria-label":`Remove ${e.label} item ${e.index+1}`,className:Wr("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:t,type:"button",children:k("span",{"aria-hidden":"true",children:"\xD7"})});return e.isMultiField?Y("div",{className:"rounded-lg border border-slate-100 p-4 dark:border-slate-900",children:[Y("div",{className:"mb-3 flex items-center justify-between",children:[Y("span",{className:"text-sm font-medium text-slate-400 dark:text-slate-500",children:[e.label," ",e.index+1]}),n]}),k(T,{children:e.children})]}):Y("div",{className:"flex items-start gap-2",children:[k(T,{children:e.children}),n&&k("div",{className:"shrink-0",children:n})]})}import{jsx as qr}from"react/jsx-runtime";function Cn(e){let t=Zt(e.field),n=Yt(e.field);return Xt(e.field,e.value).map(r=>qr(Nn,{index:r,isMultiField:n,label:t,children:e.children(r)},r))}import{jsx as Jr}from"react/jsx-runtime";function In(e){let t=Array.isArray(e.field.fields)&&e.field.fields.length===0;return Jr(G,{description:e.field.description,empty:t,id:e.field.name,title:e.field.label,children:e.children})}import{jsx as En}from"react/jsx-runtime";function vn({children:e,field:t,value:n}){return En(In,{field:t,children:En(Cn,{field:t,value:n,children:e})})}import{twMerge as Qr}from"tailwind-merge";import{jsx as kn,jsxs as jr}from"react/jsx-runtime";function Ln(e){let t=Bt(e.column?.advanced?.cols);return jr("div",{className:"flex w-full flex-col gap-4",children:[kn("div",{className:Qr("grid grid-cols-1 gap-3 sm:gap-4",t),children:e.children}),e.column?.description&&kn($,{children:e.column.description})]})}import{Fragment as to}from"react";import{jsx as eo}from"react/jsx-runtime";function Pn(e){let t=Array.isArray(e.field.fields)?e.field.fields.map(n=>M(n)?{...n,name:`${e.field.name}.${e.index}.${n.name}`}:R(n)?{...n,fields:n.fields.map(r=>({...r,name:`${e.field.name}.${e.index}.${r.name}`}))}:n):[];return eo(L,{children:e.children,components:e.components,disabled:e.disabled,fields:t,style:e.style,value:e.value})}import{jsx as P,jsxs as no}from"react/jsx-runtime";function L(e){let{field:t,list:n}=e.components;return H(e.fields).map((r,o)=>no(to,{children:[R(r)&&P(Ln,{column:r,children:P(L,{...e,fields:r.fields})}),M(r)&&P(t,{disabled:e.disabled,field:r,style:e.style,children:e.children}),ut(r)&&P(n,{field:r,value:e.value,children:i=>P(Pn,{children:e.children,components:e.components,disabled:e.disabled,field:r,index:i,style:e.style,value:e.value})})]},o))}import{jsx as ro}from"react/jsx-runtime";function Dn(e){return n=>ro(L,{...n,components:e})}var wn=Dn({field:An,list:vn});import{jsx as de}from"react/jsx-runtime";function ue(e){let t=e.translations?.[e.lang??""];return de(sn,{config:e.config,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,children:({disabled:n,fields:r})=>de(wn,{disabled:n,fields:r,style:e.config.style,children:o=>de(yn,{...o,config:e.config,context:e.context,translations:t,value:e.value})})})}import{Suspense as oo}from"react";import{jsx as On}from"react/jsx-runtime";function io(e){return On(oo,{fallback:On(ue,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}export{io as Fallback,ue 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
|
+
};
|