react-luna-form 0.0.26 → 0.0.27

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.
Files changed (42) hide show
  1. package/dist/client/cjs/index.js +2741 -1
  2. package/dist/client/esm/index.js +2708 -1
  3. package/dist/config/cjs/index.js +229 -1
  4. package/dist/config/esm/index.js +206 -1
  5. package/dist/server/cjs/index.js +1446 -1
  6. package/dist/server/esm/index.js +1423 -1
  7. package/dist/types/luna-core/src/handle/state-event.d.ts +1 -1
  8. package/dist/types/luna-core/src/index.d.ts +1 -0
  9. package/dist/types/luna-core/src/type.d.ts +16 -2
  10. package/dist/types/luna-core/src/util/constant.d.ts +4 -0
  11. package/dist/types/luna-core/src/util/extract.d.ts +2 -1
  12. package/dist/types/luna-core/src/util/is-input.d.ts +4 -3
  13. package/dist/types/luna-core/src/util/is-type.d.ts +1 -0
  14. package/dist/types/luna-core/src/util/list.d.ts +4 -0
  15. package/dist/types/luna-core/src/util/prepare.d.ts +2 -2
  16. package/dist/types/luna-core/src/util/string.d.ts +1 -0
  17. package/dist/types/luna-react/src/client/component/field/field-list.d.ts +2 -0
  18. package/dist/types/luna-react/src/client/component/{wrapper/with-error.d.ts → field/field-with-error.d.ts} +1 -1
  19. package/dist/types/luna-react/src/client/component/{wrapper/with-field-state.d.ts → field/field-with-state.d.ts} +1 -1
  20. package/dist/types/luna-react/src/client/component/guard/list-guard.d.ts +2 -0
  21. package/dist/types/luna-react/src/client/component/guard/visibility-guard.d.ts +6 -0
  22. package/dist/types/luna-react/src/client/component/slot/slot.d.ts +7 -0
  23. package/dist/types/luna-react/src/client/hook/use-field-list.d.ts +2 -0
  24. package/dist/types/luna-react/src/component/column.d.ts +2 -3
  25. package/dist/types/luna-react/src/component/field/field-base.d.ts +4 -2
  26. package/dist/types/luna-react/src/component/field/field-horizontal.d.ts +2 -8
  27. package/dist/types/luna-react/src/component/field/field-list-item.d.ts +8 -0
  28. package/dist/types/luna-react/src/component/field/field-list.d.ts +7 -0
  29. package/dist/types/luna-react/src/component/field/field-set-advanced.d.ts +5 -0
  30. package/dist/types/luna-react/src/component/field/field-set-base.d.ts +7 -0
  31. package/dist/types/luna-react/src/component/field/field-vertical.d.ts +2 -8
  32. package/dist/types/luna-react/src/component/list.d.ts +5 -0
  33. package/dist/types/luna-react/src/component/slot/list-slot.d.ts +2 -0
  34. package/dist/types/luna-react/src/component/slot/slot-base.d.ts +8 -6
  35. package/dist/types/luna-react/src/component/slot/slot-create.d.ts +4 -3
  36. package/dist/types/luna-react/src/component/slot/slot-list.d.ts +12 -0
  37. package/dist/types/luna-react/src/component/slot/slot.d.ts +1 -0
  38. package/package.json +5 -5
  39. package/dist/types/luna-react/src/component/input/input-attributes.d.ts +0 -3
  40. package/dist/types/luna-react/src/component/input/input-common.d.ts +0 -2
  41. package/dist/types/luna-react/src/component/input/input-option-select.d.ts +0 -5
  42. /package/dist/types/luna-react/src/client/component/{wrapper/index.d.ts → field/field.d.ts} +0 -0
@@ -1 +1,1423 @@
1
- import{jsx as vt}from"react/jsx-runtime";function z(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return vt("div",{"data-slot":"field-control",className:"w-full",children:t})}import{Activity as rn,useState as ln}from"react";import{jsx as Z}from"react/jsx-runtime";function q(e){return Z("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:Z("path",{fillRule:"evenodd",d:"M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"})})}import{jsx as Lt}from"react/jsx-runtime";function T(e){return Lt("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})}var I="input",J="input/email",Q="input/number";var j="textarea",ee="radio",te="checkbox",ne="select",oe="select/month",re="select/year";var M="column";var ie="label",V="value",k="options",G="email",le="number",ae="password",se="tel",C="text",ce="aria-errormessage",de="aria-invalid",ue="data-invalid",fe="data-readonly",me="aria",pe="data",ge="min",xe="max",be="minLength",ye="maxLength",A="$ref";var f="vertical",h="horizontal";function l(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function m(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function x(e){return typeof e=="string"}var Dt=/[^/]+$/;function Re(e,t=V){if(e!=null){if(m(e))return e;if(l(e)){let n=_t(e,t);if(m(n))return n}}}function _t(e,t){let n=b(e,t);if(m(n))return n}function b(e,t){if(!t||!l(e))return null;let n=t.split(".").filter(r=>r!=="");if(n.length===0)return null;let o=e;for(let r of n)if(l(o)&&r in o)o=o[r];else return null;return o}function Te(e,t={label:ie,value:V}){return e.map(n=>{if(l(n)){let o=b(n,t.label),r=b(n,t.value);if(m(o)&&m(r))return{label:`${o}`,value:`${r}`}}return n})}function Ae(e=C){if(e){let t=e.match(Dt);if(t){let[n]=t;if(n!==I)return n.trim().toLowerCase()}}return C}var Mt=/\[([^\]]+)\]\(([^)]+)\)/g;function N(e,t={}){if(x(e))return Vt(e,t);if(Array.isArray(e))return e.map(n=>N(n,t));if(l(e)){let n={};for(let o in e)n[o]=N(e[o],t);return n}return e}function S(e){return x(e)?/{([^}]+)}/.test(e):Array.isArray(e)?e.some(t=>S(t)):l(e)?Object.values(e).some(t=>S(t)):!1}function Vt(e,t={}){return e.replace(/{([^}]+)}/g,(n,o)=>{let r=o.includes(".")?b(t,o):t[o];return m(r)?String(r):n})}function he(e,t){if(!e||e.trim().length===0)return null;let n,o=0,r=!1,i=[];for(;(n=Mt.exec(e))!==null;){let[a,g,Pt]=n,E=n.index;r=!0,E>o&&i.push(e.substring(o,E));let wt=t?t(E,Pt,g):a;i.push(wt),o=E+a.length}return r?(o<e.length&&i.push(e.substring(o)),i):e}var Ce=e=>c(oe)(e),Ne=e=>c(re)(e),s=c(te),Se=c(I),y=c(ee),d=c(ne),Fe=c(j),Ee=c(C,G,ae,se),Kn=c(J,G),Ie=c(Q,le);function ke(e){return y(e)||s(e)}function Oe(e){return e.type===M}function Pe(e){return e.type!==M}function we(e){return d(e)||y(e)}function X(e){return e!=null&&e!==""}function c(...e){return t=>{let n=x(t.type)?t.type:void 0;return n?e.some(o=>n===o||n?.startsWith(`${o}/`)):!1}}function ve(e,t={}){if(d(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&l(n))return[n]}}function Le(e){return y(e)||s(e)?h:e.advanced?.orientation??f}function De(e){return s(e)?e.advanced?.reverse!==!1:!1}function _e(e,t){let n=e.readonly??!1;return t||n}function Me(e){if(y(e)||d(e)&&!e.disabled){let t=e.source;if(Array.isArray(t)||l(t)&&!(A in t))return t}}var Gt=/^\d+$/;function Ve(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function Ge(e,t){return t>=e?Array.from({length:t-e+1},(n,o)=>{let r=e+o;return{value:r.toString(),label:r.toString()}}):[]}function Y(){return new Date().getFullYear()}function B(e,t){if(typeof e=="number")return e;let n=t??Y(),o=e.trim().toLowerCase();if(o.startsWith("current")){let r=o.match(/^current([+-])(\d+)$/);if(r){let[,i,a]=r,g=parseInt(a,10);if(!isNaN(g))return i==="+"?n+g:n-g}return n}return Gt.test(o)?parseInt(o,10):n}var O=Y();function Xt(e){if(d(e))return Yt(e)}function Yt(e){if(Ce(e))return Ve();if(Ne(e)){let t=e.advanced?.length?.min??O,n=e.advanced?.length?.max??O+5;return Ge(B(t,O),B(n,O))}}function Xe(e,t=!1){let n={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return Se(e)?{...n,...Bt(e)}:d(e)?{...n,...Ut(e)}:Fe(e)?{...n,...$t(e)}:n}function Bt(e){let t=Ae(e.type),n={...e,type:t};return{...Ye(e),...Ht(n),...Ee(n)?Be(n):{},type:t}}function Ut(e){let t=Xt(e);return t?{options:t}:{}}function $t(e){return{...Ye(e),...Be(e)}}function Ye(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function Ht(e){return Ie(e)?Kt(e):{}}function Be(e){return Ue(e,{min:be,max:ye})}function Kt(e){return Ue(e,{min:ge,max:xe})}function Ue(e,t){let n={},o=e.advanced?.length;return o&&(o.min!==void 0&&(n[t.min]=o.min),o.max!==void 0&&(n[t.max]=o.max)),n}function $e(e,t){let n=Me(e);return n||ve(e,t)}function Wt(e,t){let n=l(t)&&e.name in t?t[e.name]:t;return Re(n,e.advanced?.entity)}function zt(e,t,n){return we(e)&&Array.isArray(n)?{...t,[k]:n}:t}function Zt(e,t,n){if(e.required&&!X(n)&&d(e)&&e.advanced?.preselected!==!1&&k in t){let o=t[k];if(Array.isArray(o)&&o.length===1)return o[0]}return n}function qt(e,t){return d(e)&&Array.isArray(t)?Te(t,e.advanced?.options):t}function He(e,t,n,o){let r=Wt(e,o),i=Array.isArray(n)?qt(e,n):n,a=zt(e,t,i),g=Zt(e,a,r);return{commonPropsWithOptions:a,defaultValue:g}}function Ke(e,t){return s(e)?{defaultChecked:X(t)}:{defaultValue:t}}var Jt=/^#\/definition\//;function w(e=[],t){let n=P(e,t);return Array.isArray(n)?n.sort((o,r)=>We(o)-We(r)):[]}function P(e,t,n=new Map,o=new WeakSet){if(!Qt(t)||!e||typeof e!="object")return e;if(n.has(e))return n.get(e);if(o.has(e))return e;if(o.add(e),Array.isArray(e))return e.map(i=>P(i,t,n,o));if(A in e&&x(e[A])){let i=e[A].replace(Jt,""),a=b(t,i);return a!==null?P(a,t,n,o):e}let r={};for(let[i,a]of Object.entries(e))r[i]=P(a,t,n,o);return o.delete(e),n.set(e,r),r}function ze(e){return Object.entries(e??{})}function We(e){return e.order??Number.MAX_VALUE}function Qt(e){return e!==void 0&&l(e)&&Object.keys(e).length>0}function Ze(e,t){let n={};for(let[o,r]of ze(t))n[`${e}-${o}`]=r;return n}function jt(e){return Ze(me,e)}function en(e){return Ze(pe,e)}function qe(e,t){let n=jt(e.advanced?.aria);return t&&t.length>0&&(n[de]="true",n[ce]=`${e.name}-error`),n}function Je(e){return en(e.advanced?.data)}var Qe={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},je={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function et(e,t=2){return Qe[e&&e in Qe?e:t]}function tt(e){if(e&&e in je)return je[e]}function R(e,t){return e?t?t[e]??e:e:""}function v(e,t){return{...e,...t}}import{jsx as tn}from"react/jsx-runtime";function p(e){return he(e,(t,n,o)=>tn("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:o},`${n}-${t}`))}import{Fragment as nn,jsx as nt,jsxs as on}from"react/jsx-runtime";function ot(e){return on(nn,{children:[e.title&&nt("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:p(e.title)}),e.description&&nt("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:p(e.description)})]})}import{jsx as u,jsxs as L}from"react/jsx-runtime";function rt(e){let t=e.section.fields||[],[n,o]=ln(!1),{compact:r}=v(e.style,{compact:e.section.compact});return!e.section.title&&!e.section.description?u(T,{compact:r,children:e.children}):e.section.advanced?L("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:[u("legend",{children:L("button",{type:"button",onClick:()=>o(i=>!i),className:"flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",children:[u(q,{expanded:n}),u("span",{children:p(e.section.title)})]})}),u(rn,{mode:n?"visible":"hidden",children:L("div",{className:"mt-3 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&&u("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:p(e.section.description)}),u(T,{compact:r,children:e.children})]})})]}):L("fieldset",{"data-slot":"field-set","data-empty":t.length===0,className:"flex flex-col data-[empty=false]:gap-6",id:e.section.id?.toString(),children:[u(ot,{description:e.section.description,title:e.section.title}),u(T,{compact:r,children:e.children})]})}import{Fragment as an}from"react";import{jsx as it}from"react/jsx-runtime";function lt(){return it("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:it("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}import{jsx as F,jsxs as at}from"react/jsx-runtime";function st(e){let t=w(e.sections,e.definition);return F("div",{className:"h-full w-full",children:F("form",{noValidate:e.noValidate,action:e.action,children:at(T,{children:[t.map((n,o)=>at(an,{children:[F(rt,{section:n,style:e.config.style,children:e.children({disabled:e.readOnly,fields:n.fields})}),n.separator&&F(lt,{})]},o)),e.control&&F(z,{isPending:e.isPending,children:e.control})]})})})}import{jsx as sn}from"react/jsx-runtime";function ct(e){return sn("p",{className:"-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}import{jsx as cn}from"react/jsx-runtime";function D(e){let t=p(e.text);return t?cn(ct,{children:t}):null}import{twMerge as dn}from"tailwind-merge";import{jsx as un,jsxs as fn}from"react/jsx-runtime";function dt(e){let t=e.style?.showOptionalLabel??!0,n=y(e.field)||s(e.field);return fn("label",{"data-slot":"field-label","data-normal":n,className:dn("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&&un("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:R("(Optional)",e.translations)})]})}import{jsx as ut,jsxs as mn}from"react/jsx-runtime";function ft(e){let t=S(e.field.label)?N(e.field.label,{context:e.context,env:e.config?.env}):e.field.label,n=S(e.field.description)?N(e.field.description,{context:e.context,env:e.config?.env}):e.field.description;return mn("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[ut(dt,{field:e.field,style:e.config?.style,translations:e.translations,children:R(t,e.translations)}),e.orientation===h&&ut(D,{text:R(n,e.translations)})]})}import{Fragment as pn,jsx as mt,jsxs as gn}from"react/jsx-runtime";function pt(e){return gn(pn,{children:[e.field.name&&e.field.label&&mt(ft,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations}),e.children,e.orientation===f&&e.field.description&&mt(D,{text:R(e.field.description,e.translations)})]})}function gt(e,t){return e?t(e):null}import{jsx as xt}from"react/jsx-runtime";function bt(e){let t=$e(e.field,e.value),{commonPropsWithOptions:n,defaultValue:o}=He(e.field,e.commonProps,t,e.value),r=Ke(e.field,o);return gt(e.config.inputs[e.field.type],i=>xt(pt,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations,children:xt(i,{...e.ariaAttributes,...n,...e.dataAttributes,...r})}))}import{jsx as yt}from"react/jsx-runtime";function Rt(e){return!e.errors||e.errors.length===0?null:yt("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)=>yt("li",{children:t},e.name?`${e.name}-error-${n}`:n))})}import{twMerge as xn}from"tailwind-merge";import{jsx as bn}from"react/jsx-runtime";function _(e){let t=e.errors&&e.errors.length>0;return bn("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[ue]:"true"},...e.disabled&&{[fe]:"true"},"data-orientation":e.orientation,className:xn("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 yn}from"tailwind-merge";import{jsx as Rn}from"react/jsx-runtime";function Tt(e){return Rn(_,{...e,orientation:f,className:yn("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}import{twMerge as Tn}from"tailwind-merge";import{jsx as An}from"react/jsx-runtime";function At(e){return An(_,{...e,orientation:h,className:Tn("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 ht}from"react/jsx-runtime";function Ct(e){let t=ke(e.field),n=s(e.field),o=De(e.field);return e.orientation===f?ht(Tt,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:o,isClickable:t,children:e.children}):ht(At,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:o,isClickable:t,children:e.children})}function Nt(e){if(!e.field.type)return null;let t=Xe(e.field,e.disabled),n=Je(e.field),o=qe(e.field,e.errors),r={...e.field,disabled:t.disabled};return e.children({ariaAttributes:o,commonProps:t,dataAttributes:n,field:r,orientation:e.orientation})}import{twMerge as hn}from"tailwind-merge";import{jsx as U,jsxs as Cn}from"react/jsx-runtime";function St(e){let t=e.field.advanced?.cols,n=e.field.name?e.errors?.[e.field.name]:void 0,{orientation:o}=v(e.style,{orientation:Le(e.field)}),r=_e(e.field,e.disabled);return Cn("div",{className:hn("flex flex-col gap-3",tt(t)),children:[U(Ct,{disabled:r,errors:n,field:e.field,orientation:o,children:U(Nt,{disabled:r,errors:n,field:e.field,orientation:o,children:e.children})}),U(Rt,{errors:n,name:e.field.name})]})}import{twMerge as Nn}from"tailwind-merge";import{jsx as Ft}from"react/jsx-runtime";function Et(e){let t=et(e.column?.advanced?.cols);return Ft("div",{className:"flex w-full flex-col gap-4",children:Ft("div",{className:Nn("grid grid-cols-1 gap-3 sm:gap-4",t),children:e.children})})}import{Fragment as Sn}from"react";import{jsx as $,jsxs as Fn}from"react/jsx-runtime";function H(e){let{column:t,field:n}=e.components;return w(e.fields).map((o,r)=>Fn(Sn,{children:[Oe(o)&&$(t,{column:o,children:$(H,{...e,fields:o.fields})}),Pe(o)&&$(n,{disabled:e.disabled,field:o,style:e.style,children:e.children})]},r))}import{jsx as En}from"react/jsx-runtime";function It(e){return n=>En(H,{...n,components:{column:Et,field:e}})}var kt=It(St);import{jsx as K}from"react/jsx-runtime";function W(e){let t=e.translations?.[e.lang??""];return K(st,{config:e.config,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,children:({disabled:n,fields:o})=>K(kt,{disabled:n,fields:o,style:e.config.style,children:r=>K(bt,{...r,config:e.config,context:e.context,translations:t,value:e.value})})})}import{Suspense as In}from"react";import{jsx as Ot}from"react/jsx-runtime";function kn(e){return Ot(In,{fallback:Ot(W,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}export{kn as Fallback,W 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/field/field-set-advanced.tsx
9
+ import { Activity, useCallback, useState } from "react";
10
+
11
+ // src/component/chevron-icon.tsx
12
+ import { jsx as jsx2 } from "react/jsx-runtime";
13
+ function ChevronIcon(props) {
14
+ return /* @__PURE__ */ jsx2(
15
+ "svg",
16
+ {
17
+ xmlns: "http://www.w3.org/2000/svg",
18
+ viewBox: "0 0 20 20",
19
+ fill: "currentColor",
20
+ className: `size-4 transition-transform duration-200 ${props.expanded ? "rotate-90" : ""}`,
21
+ children: /* @__PURE__ */ jsx2(
22
+ "path",
23
+ {
24
+ fillRule: "evenodd",
25
+ 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",
26
+ clipRule: "evenodd"
27
+ }
28
+ )
29
+ }
30
+ );
31
+ }
32
+
33
+ // ../luna-core/src/util/constant.ts
34
+ var INPUT = "input";
35
+ var INPUT_EMAIL = "input/email";
36
+ var INPUT_NUMBER = "input/number";
37
+ var TEXTAREA = "textarea";
38
+ var RADIO = "radio";
39
+ var CHECKBOX = "checkbox";
40
+ var LIST = "list";
41
+ var SELECT = "select";
42
+ var SELECT_MONTH = "select/month";
43
+ var SELECT_YEAR = "select/year";
44
+ var COLUMN = "column";
45
+ var FIELDS = "fields";
46
+ var LABEL = "label";
47
+ var VALUE = "value";
48
+ var OPTIONS = "options";
49
+ var TYPE_EMAIL = "email";
50
+ var TYPE_NUMBER = "number";
51
+ var TYPE_PASSWORD = "password";
52
+ var TYPE_TEL = "tel";
53
+ var TYPE_TEXT = "text";
54
+ var ARIA_ERROR_MESSAGE = "aria-errormessage";
55
+ var ARIA_INVALID = "aria-invalid";
56
+ var DATA_INVALID = "data-invalid";
57
+ var DATA_READONLY = "data-readonly";
58
+ var PREFIX_ARIA = "aria";
59
+ var PREFIX_DATA = "data";
60
+ var MIN = "min";
61
+ var MAX = "max";
62
+ var MIN_LENGTH = "minLength";
63
+ var MAX_LENGTH = "maxLength";
64
+ var $REF = "$ref";
65
+ var VERTICAL = "vertical";
66
+ var HORIZONTAL = "horizontal";
67
+ var TYPE = "type";
68
+
69
+ // ../luna-core/src/util/is-type.ts
70
+ function isObject(value) {
71
+ return value !== null && Object.prototype.toString.call(value) === "[object Object]";
72
+ }
73
+ function isValue(value) {
74
+ return isString(value) || typeof value === "number" || isBoolean(value);
75
+ }
76
+ function isString(value) {
77
+ return typeof value === "string";
78
+ }
79
+ function isBoolean(value) {
80
+ return typeof value === "boolean";
81
+ }
82
+
83
+ // ../luna-core/src/util/extract.ts
84
+ var REGEX_TYPE = /[^/]+$/;
85
+ function getCurrentValue(value, entity = VALUE) {
86
+ if (value !== null && value !== void 0) {
87
+ if (isValue(value)) {
88
+ return value;
89
+ }
90
+ if (isObject(value)) {
91
+ const result = getValue(value, entity);
92
+ if (isValue(result)) {
93
+ return result;
94
+ }
95
+ }
96
+ }
97
+ }
98
+ function getValue(value, namespace) {
99
+ const result = extract(value, namespace);
100
+ if (isValue(result)) {
101
+ return result;
102
+ }
103
+ }
104
+ function extract(value, namespace) {
105
+ if (!namespace || !isObject(value)) {
106
+ return null;
107
+ }
108
+ const keys = namespace.split(".").filter((key) => key !== "");
109
+ if (keys.length === 0) {
110
+ return null;
111
+ }
112
+ let result = value;
113
+ for (const key of keys) {
114
+ if (isObject(result) && key in result) {
115
+ const obj = result;
116
+ result = obj[key];
117
+ } else {
118
+ return null;
119
+ }
120
+ }
121
+ return result;
122
+ }
123
+ function toOptions(data, options = { label: LABEL, value: VALUE }) {
124
+ return data.map((item) => {
125
+ if (isObject(item)) {
126
+ const label = extract(item, options.label);
127
+ const value = extract(item, options.value);
128
+ if (isValue(label) && isValue(value)) {
129
+ return {
130
+ label: `${label}`,
131
+ value: `${value}`
132
+ };
133
+ }
134
+ }
135
+ return item;
136
+ });
137
+ }
138
+ function getType(value = TYPE_TEXT) {
139
+ if (value) {
140
+ const result = value.match(REGEX_TYPE);
141
+ if (result) {
142
+ const [type] = result;
143
+ if (type !== INPUT) {
144
+ return type.trim().toLowerCase();
145
+ }
146
+ }
147
+ }
148
+ return TYPE_TEXT;
149
+ }
150
+
151
+ // ../luna-core/src/util/string.ts
152
+ var REGEX_MARKDOWN_LINK = /\[([^\]]+)\]\(([^)]+)\)/g;
153
+ function interpolate(template, values = {}) {
154
+ if (isString(template)) {
155
+ return replacePlaceholders(template, values);
156
+ }
157
+ if (Array.isArray(template)) {
158
+ return template.map((item) => {
159
+ return interpolate(item, values);
160
+ });
161
+ }
162
+ if (isObject(template)) {
163
+ const results = {};
164
+ for (const key in template) {
165
+ results[key] = interpolate(template[key], values);
166
+ }
167
+ return results;
168
+ }
169
+ return template;
170
+ }
171
+ function interpolateIfNeeded(template, values = {}) {
172
+ return isInterpolated(template) ? interpolate(template, values) : template;
173
+ }
174
+ function isInterpolated(template) {
175
+ if (isString(template)) {
176
+ return /{([^}]+)}/.test(template);
177
+ }
178
+ if (Array.isArray(template)) {
179
+ return template.some((item) => isInterpolated(item));
180
+ }
181
+ if (isObject(template)) {
182
+ return Object.values(template).some((value) => isInterpolated(value));
183
+ }
184
+ return false;
185
+ }
186
+ function replacePlaceholders(template, values = {}) {
187
+ return template.replace(/{([^}]+)}/g, (match, key) => {
188
+ const value = key.includes(".") ? extract(values, key) : values[key];
189
+ if (isValue(value)) {
190
+ return String(value);
191
+ }
192
+ return match;
193
+ });
194
+ }
195
+ function formatMarkdown(text, callback) {
196
+ if (!text || text.trim().length === 0) {
197
+ return null;
198
+ }
199
+ let match;
200
+ let lastIndex = 0;
201
+ let hasMatch = false;
202
+ const parts = [];
203
+ while ((match = REGEX_MARKDOWN_LINK.exec(text)) !== null) {
204
+ const [fullMatch, linkText, url] = match;
205
+ const index = match.index;
206
+ hasMatch = true;
207
+ if (index > lastIndex) {
208
+ parts.push(text.substring(lastIndex, index));
209
+ }
210
+ const value = callback ? callback(index, url, linkText) : fullMatch;
211
+ parts.push(value);
212
+ lastIndex = index + fullMatch.length;
213
+ }
214
+ if (!hasMatch) {
215
+ return text;
216
+ }
217
+ if (lastIndex < text.length) {
218
+ parts.push(text.substring(lastIndex));
219
+ }
220
+ return parts;
221
+ }
222
+
223
+ // ../luna-core/src/util/is-input.ts
224
+ var isSelectMonth = (field) => createTypeChecker(SELECT_MONTH)(field);
225
+ var isSelectYear = (field) => createTypeChecker(SELECT_YEAR)(field);
226
+ var isCheckbox = createTypeChecker(CHECKBOX);
227
+ var isInput = createTypeChecker(INPUT);
228
+ var isRadio = createTypeChecker(RADIO);
229
+ var isSelect = createTypeChecker(SELECT);
230
+ var isTextArea = createTypeChecker(TEXTAREA);
231
+ var isText = createTypeChecker(
232
+ TYPE_TEXT,
233
+ TYPE_EMAIL,
234
+ TYPE_PASSWORD,
235
+ TYPE_TEL
236
+ );
237
+ var isEmail = createTypeChecker(INPUT_EMAIL, TYPE_EMAIL);
238
+ var isNumber = createTypeChecker(INPUT_NUMBER, TYPE_NUMBER);
239
+ function isClickable(field) {
240
+ return isRadio(field) || isCheckbox(field);
241
+ }
242
+ function isList(slot) {
243
+ return slot.type === LIST;
244
+ }
245
+ function isColumn(slot) {
246
+ return slot.type === COLUMN;
247
+ }
248
+ function isField(slot) {
249
+ return slot.type !== COLUMN && slot.type !== LIST;
250
+ }
251
+ function isOptions(field) {
252
+ return isSelect(field) || isRadio(field);
253
+ }
254
+ function isValidValue(value) {
255
+ return value !== void 0 && value !== null && value !== "";
256
+ }
257
+ function createTypeChecker(...types) {
258
+ return (field) => {
259
+ const inputType = isString(field.type) ? field.type : void 0;
260
+ if (!inputType) {
261
+ return false;
262
+ }
263
+ return types.some((type) => {
264
+ return inputType === type || inputType?.startsWith(`${type}/`);
265
+ });
266
+ };
267
+ }
268
+
269
+ // ../luna-core/src/util/build.ts
270
+ function buildOptions(field, values = {}) {
271
+ if (isSelect(field) && field.disabled) {
272
+ const current = field.name ? values?.[field.name] : void 0;
273
+ if (current && isObject(current)) {
274
+ return [current];
275
+ }
276
+ }
277
+ }
278
+ function buildOrientation(field) {
279
+ if (isRadio(field) || isCheckbox(field)) {
280
+ return HORIZONTAL;
281
+ }
282
+ return field.advanced?.orientation ?? VERTICAL;
283
+ }
284
+ function buildReverse(field) {
285
+ if (!isCheckbox(field)) {
286
+ return false;
287
+ }
288
+ return field.advanced?.reverse !== false;
289
+ }
290
+ function buildDisabled(field, disabled) {
291
+ const readonly = field.readonly ?? false;
292
+ return disabled ? disabled : readonly;
293
+ }
294
+ function buildSource(field) {
295
+ if (isRadio(field) || isSelect(field) && !field.disabled) {
296
+ const source = field.source;
297
+ if (Array.isArray(source) || isObject(source) && !($REF in source)) {
298
+ return source;
299
+ }
300
+ }
301
+ }
302
+
303
+ // ../luna-core/src/util/date.ts
304
+ var REGEX_DIGITS = /^\d+$/;
305
+ function getMonth() {
306
+ return Array.from({ length: 12 }, (_, i) => ({
307
+ value: (i + 1).toString(),
308
+ label: new Date(0, i).toLocaleString("default", {
309
+ month: "long"
310
+ })
311
+ }));
312
+ }
313
+ function getYear(min, max) {
314
+ if (max >= min) {
315
+ return Array.from({ length: max - min + 1 }, (_, i) => {
316
+ const year = min + i;
317
+ return {
318
+ value: year.toString(),
319
+ label: year.toString()
320
+ };
321
+ });
322
+ }
323
+ return [];
324
+ }
325
+ function getCurrentYear() {
326
+ return (/* @__PURE__ */ new Date()).getFullYear();
327
+ }
328
+ function getConvert(value, current) {
329
+ if (typeof value === "number") {
330
+ return value;
331
+ }
332
+ const now2 = current ?? getCurrentYear();
333
+ const trimmed = value.trim().toLowerCase();
334
+ if (trimmed.startsWith("current")) {
335
+ const match = trimmed.match(/^current([+-])(\d+)$/);
336
+ if (match) {
337
+ const [, operator, offsetStr] = match;
338
+ const offset = parseInt(offsetStr, 10);
339
+ if (!isNaN(offset)) {
340
+ return operator === "+" ? now2 + offset : now2 - offset;
341
+ }
342
+ }
343
+ return now2;
344
+ }
345
+ if (REGEX_DIGITS.test(trimmed)) {
346
+ return parseInt(trimmed, 10);
347
+ }
348
+ return now2;
349
+ }
350
+
351
+ // ../luna-core/src/helper/input.ts
352
+ var now = getCurrentYear();
353
+ function buildOptionSelect(field) {
354
+ if (isSelect(field)) {
355
+ return defineOption(field);
356
+ }
357
+ }
358
+ function defineOption(select) {
359
+ if (isSelectMonth(select)) {
360
+ return getMonth();
361
+ }
362
+ if (isSelectYear(select)) {
363
+ const min = select.advanced?.length?.min ?? now;
364
+ const max = select.advanced?.length?.max ?? now + 5;
365
+ return getYear(getConvert(min, now), getConvert(max, now));
366
+ }
367
+ }
368
+ function buildCommon(field, disabled = false) {
369
+ const commonProps = {
370
+ disabled,
371
+ id: field.name,
372
+ name: field.name,
373
+ placeholder: field.placeholder,
374
+ required: field.required
375
+ };
376
+ if (isInput(field)) {
377
+ return {
378
+ ...commonProps,
379
+ ...defineInput(field)
380
+ };
381
+ }
382
+ if (isSelect(field)) {
383
+ return {
384
+ ...commonProps,
385
+ ...defineSelect(field)
386
+ };
387
+ }
388
+ if (isTextArea(field)) {
389
+ return {
390
+ ...commonProps,
391
+ ...defineTextArea(field)
392
+ };
393
+ }
394
+ return commonProps;
395
+ }
396
+ function defineInput(input) {
397
+ const type = getType(input.type);
398
+ const copy = { ...input, type };
399
+ return {
400
+ ...defineAutoComplete(input),
401
+ ...defineNumberLimits(copy),
402
+ ...isText(copy) ? defineLength(copy) : {},
403
+ type
404
+ };
405
+ }
406
+ function defineSelect(field) {
407
+ const options = buildOptionSelect(field);
408
+ if (options) {
409
+ return { options };
410
+ }
411
+ return {};
412
+ }
413
+ function defineTextArea(field) {
414
+ return {
415
+ ...defineAutoComplete(field),
416
+ ...defineLength(field)
417
+ };
418
+ }
419
+ function defineAutoComplete(input) {
420
+ const autoComplete = input.advanced?.autocomplete;
421
+ if (autoComplete) {
422
+ return { autoComplete };
423
+ }
424
+ return {};
425
+ }
426
+ function defineNumberLimits(input) {
427
+ if (isNumber(input)) {
428
+ return defineMinMax(input);
429
+ }
430
+ return {};
431
+ }
432
+ function defineLength(input) {
433
+ return defineConstraints(input, { min: MIN_LENGTH, max: MAX_LENGTH });
434
+ }
435
+ function defineMinMax(input) {
436
+ return defineConstraints(input, { min: MIN, max: MAX });
437
+ }
438
+ function defineConstraints(input, keys) {
439
+ const result = {};
440
+ const length = input.advanced?.length;
441
+ if (length) {
442
+ if (length.min !== void 0) {
443
+ result[keys.min] = length.min;
444
+ }
445
+ if (length.max !== void 0) {
446
+ result[keys.max] = length.max;
447
+ }
448
+ }
449
+ return result;
450
+ }
451
+ function resolveSource(field, value) {
452
+ const current = buildSource(field);
453
+ if (current) {
454
+ return current;
455
+ }
456
+ return buildOptions(field, value);
457
+ }
458
+ function getInputValue(field, value) {
459
+ const newValue = isObject(value) && field.name in value ? value[field.name] : value;
460
+ return getCurrentValue(newValue, field.advanced?.entity);
461
+ }
462
+ function mergeOptionsProps(field, commonProps, options) {
463
+ return isOptions(field) && Array.isArray(options) ? { ...commonProps, [OPTIONS]: options } : commonProps;
464
+ }
465
+ function getPreselectedValue(field, commonProps, value) {
466
+ if (field.required && !isValidValue(value)) {
467
+ if (isSelect(field)) {
468
+ if (field.advanced?.preselected !== false && OPTIONS in commonProps) {
469
+ const options = commonProps[OPTIONS];
470
+ if (Array.isArray(options) && options.length === 1) {
471
+ return options[0];
472
+ }
473
+ }
474
+ }
475
+ }
476
+ return value;
477
+ }
478
+ function getOptions(field, data) {
479
+ if (isSelect(field) && Array.isArray(data)) {
480
+ return toOptions(data, field.advanced?.options);
481
+ }
482
+ return data;
483
+ }
484
+ function prepareInputProps(field, commonProps, data, value) {
485
+ const currentValue = getInputValue(field, value);
486
+ const options = Array.isArray(data) ? getOptions(field, data) : data;
487
+ const commonPropsWithOptions = mergeOptionsProps(field, commonProps, options);
488
+ const defaultValue = getPreselectedValue(
489
+ field,
490
+ commonPropsWithOptions,
491
+ currentValue
492
+ );
493
+ return {
494
+ commonPropsWithOptions,
495
+ defaultValue
496
+ };
497
+ }
498
+ function prepareDefaultValue(field, value) {
499
+ if (isCheckbox(field)) {
500
+ return {
501
+ defaultChecked: isValidValue(value)
502
+ };
503
+ }
504
+ return { defaultValue: value };
505
+ }
506
+
507
+ // ../luna-core/src/util/prepare.ts
508
+ var REGEX_REF = /^#\/definition\//;
509
+ function prepare(base = [], definition) {
510
+ const resolved = resolveRefs(base, definition);
511
+ return Array.isArray(resolved) ? resolved.filter(filter).sort((a, b) => getOrder(a) - getOrder(b)) : [];
512
+ }
513
+ function resolveRefs(base, definition, cache = /* @__PURE__ */ new Map(), visited = /* @__PURE__ */ new WeakSet()) {
514
+ if (!isDefinition(definition) || !base || typeof base !== "object") {
515
+ return base;
516
+ }
517
+ if (cache.has(base)) {
518
+ return cache.get(base);
519
+ }
520
+ if (visited.has(base)) {
521
+ return base;
522
+ }
523
+ visited.add(base);
524
+ if (Array.isArray(base)) {
525
+ return base.map((item) => resolveRefs(item, definition, cache, visited));
526
+ }
527
+ if ($REF in base && isString(base[$REF])) {
528
+ const path = base[$REF].replace(REGEX_REF, "");
529
+ const resolved = extract(definition, path);
530
+ if (resolved !== null) {
531
+ return resolveRefs(resolved, definition, cache, visited);
532
+ }
533
+ return base;
534
+ }
535
+ const result = {};
536
+ for (const [key, value] of Object.entries(base)) {
537
+ result[key] = resolveRefs(value, definition, cache, visited);
538
+ }
539
+ visited.delete(base);
540
+ cache.set(base, result);
541
+ return result;
542
+ }
543
+ function entries(values) {
544
+ return Object.entries(values ?? {});
545
+ }
546
+ function getOrder(item) {
547
+ return item.order ?? Number.MAX_VALUE;
548
+ }
549
+ function isDefinition(definition) {
550
+ return definition !== void 0 && isObject(definition) && Object.keys(definition).length > 0;
551
+ }
552
+ function filter(base) {
553
+ if (TYPE in base) {
554
+ return true;
555
+ }
556
+ if (Array.isArray(base[FIELDS])) {
557
+ return base[FIELDS].length > 0;
558
+ }
559
+ return true;
560
+ }
561
+
562
+ // ../luna-core/src/util/attributes.ts
563
+ function getPrefixedAttributes(prefix, record) {
564
+ const attrs = {};
565
+ for (const [key, value] of entries(record)) {
566
+ attrs[`${prefix}-${key}`] = value;
567
+ }
568
+ return attrs;
569
+ }
570
+ function getAriaAttributes(record) {
571
+ return getPrefixedAttributes(PREFIX_ARIA, record);
572
+ }
573
+ function getDataAttributes(record) {
574
+ return getPrefixedAttributes(PREFIX_DATA, record);
575
+ }
576
+ function buildAriaAttributes(field, errors) {
577
+ const ariaAttributes = getAriaAttributes(field.advanced?.aria);
578
+ if (errors && errors.length > 0) {
579
+ ariaAttributes[ARIA_INVALID] = "true";
580
+ ariaAttributes[ARIA_ERROR_MESSAGE] = `${field.name}-error`;
581
+ }
582
+ return ariaAttributes;
583
+ }
584
+ function buildDataAttributes(field) {
585
+ return getDataAttributes(field.advanced?.data);
586
+ }
587
+
588
+ // ../luna-core/src/util/column.ts
589
+ var cols = {
590
+ 1: "md:grid-cols-1",
591
+ 2: "md:grid-cols-2",
592
+ 3: "md:grid-cols-3"
593
+ };
594
+ var span = {
595
+ 1: "md:col-span-1",
596
+ 2: "md:col-span-2",
597
+ 3: "md:col-span-3"
598
+ };
599
+ function getColumn(value, defaultCols = 2) {
600
+ return cols[value && value in cols ? value : defaultCols];
601
+ }
602
+ function getSpan(value) {
603
+ if (value && value in span) {
604
+ return span[value];
605
+ }
606
+ }
607
+
608
+ // ../luna-core/src/util/list.ts
609
+ function getInitialCount(list, value) {
610
+ const min = list.advanced?.length?.min ?? 1;
611
+ if (value) {
612
+ const data = extract(value, list.name);
613
+ if (Array.isArray(data)) {
614
+ return Math.max(data.length, min);
615
+ }
616
+ }
617
+ return Math.max(min, 0);
618
+ }
619
+ function isMultiFieldList(list) {
620
+ if (!Array.isArray(list.fields) || list.fields.length === 0) {
621
+ return false;
622
+ }
623
+ return list.fields.length > 1 || list.fields[0].type === COLUMN;
624
+ }
625
+ function getInitialList(list, value) {
626
+ const count = getInitialCount(list, value);
627
+ return Array.from({ length: count }, (_, index) => index);
628
+ }
629
+ function getLabel(list) {
630
+ return list.label ?? list.name;
631
+ }
632
+
633
+ // ../luna-core/src/util/translate.ts
634
+ function translate(key, dictionary) {
635
+ if (!key) {
636
+ return "";
637
+ }
638
+ if (!dictionary) {
639
+ return key;
640
+ }
641
+ return dictionary[key] ?? key;
642
+ }
643
+
644
+ // ../luna-core/src/util/style.ts
645
+ function mergeStyle(globalStyle, localStyle) {
646
+ return { ...globalStyle, ...localStyle };
647
+ }
648
+
649
+ // src/lib/string.tsx
650
+ import { jsx as jsx3 } from "react/jsx-runtime";
651
+ function formatMarkdown2(text) {
652
+ return formatMarkdown(
653
+ text,
654
+ (index, url, text2) => {
655
+ return /* @__PURE__ */ jsx3(
656
+ "a",
657
+ {
658
+ className: "underline",
659
+ href: url,
660
+ rel: "noopener noreferrer",
661
+ target: "_blank",
662
+ children: text2
663
+ },
664
+ `${url}-${index}`
665
+ );
666
+ }
667
+ );
668
+ }
669
+
670
+ // src/component/field/field-set-advanced.tsx
671
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
672
+ function FieldSetAdvanced(props) {
673
+ const { fields = [] } = props.section;
674
+ const [isOpen, setIsOpen] = useState(false);
675
+ const handleOpen = useCallback(() => setIsOpen((previous) => !previous), []);
676
+ return /* @__PURE__ */ jsxs(
677
+ "fieldset",
678
+ {
679
+ "data-slot": "field-set",
680
+ "data-advanced": "true",
681
+ "data-expanded": isOpen,
682
+ "data-empty": fields.length === 0,
683
+ className: "flex flex-col",
684
+ id: props.section.id?.toString(),
685
+ children: [
686
+ /* @__PURE__ */ jsx4("legend", { children: /* @__PURE__ */ jsxs(
687
+ "button",
688
+ {
689
+ className: "flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",
690
+ onClick: handleOpen,
691
+ type: "button",
692
+ children: [
693
+ /* @__PURE__ */ jsx4(ChevronIcon, { expanded: isOpen }),
694
+ /* @__PURE__ */ jsx4("span", { children: formatMarkdown2(props.section.title) })
695
+ ]
696
+ }
697
+ ) }),
698
+ /* @__PURE__ */ jsx4(Activity, { mode: isOpen ? "visible" : "hidden", children: /* @__PURE__ */ jsxs(
699
+ "div",
700
+ {
701
+ className: "mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-slate-300 pl-4 dark:border-slate-600",
702
+ "data-slot": "field-set-content",
703
+ children: [
704
+ props.section.description && /* @__PURE__ */ jsx4("p", { className: "text-sm leading-normal font-normal text-slate-600 dark:text-slate-400", children: formatMarkdown2(props.section.description) }),
705
+ props.group
706
+ ]
707
+ }
708
+ ) })
709
+ ]
710
+ }
711
+ );
712
+ }
713
+
714
+ // src/component/legend.tsx
715
+ import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
716
+ function Legend(props) {
717
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
718
+ props.title && /* @__PURE__ */ jsx5("legend", { className: "mb-3 font-medium text-slate-800 dark:text-slate-200", children: formatMarkdown2(props.title) }),
719
+ props.description && /* @__PURE__ */ jsx5("p", { className: "-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400", children: formatMarkdown2(props.description) })
720
+ ] });
721
+ }
722
+
723
+ // src/component/field/field-set-base.tsx
724
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
725
+ function FieldSetBase(props) {
726
+ return /* @__PURE__ */ jsxs3(
727
+ "fieldset",
728
+ {
729
+ "data-slot": "field-set",
730
+ "data-empty": props.empty,
731
+ className: "flex flex-col data-[empty=false]:gap-6",
732
+ id: props.id,
733
+ children: [
734
+ /* @__PURE__ */ jsx6(Legend, { description: props.description, title: props.title }),
735
+ props.children
736
+ ]
737
+ }
738
+ );
739
+ }
740
+
741
+ // src/component/group.tsx
742
+ import { jsx as jsx7 } from "react/jsx-runtime";
743
+ function Group(props) {
744
+ return /* @__PURE__ */ jsx7(
745
+ "div",
746
+ {
747
+ "data-slot": "field-group",
748
+ "data-compact": props.compact,
749
+ className: "flex w-full flex-col gap-8 data-[compact=true]:gap-3",
750
+ children: props.children
751
+ }
752
+ );
753
+ }
754
+
755
+ // src/component/field/field-set.tsx
756
+ import { jsx as jsx8 } from "react/jsx-runtime";
757
+ function FieldSet(props) {
758
+ const { fields = [] } = props.section;
759
+ const { compact } = mergeStyle(props.style, {
760
+ compact: props.section.compact
761
+ });
762
+ const group = /* @__PURE__ */ jsx8(Group, { compact, children: props.children });
763
+ if (!props.section.title && !props.section.description) {
764
+ return group;
765
+ }
766
+ if (props.section.advanced) {
767
+ return /* @__PURE__ */ jsx8(FieldSetAdvanced, { section: props.section, group });
768
+ }
769
+ return /* @__PURE__ */ jsx8(
770
+ FieldSetBase,
771
+ {
772
+ description: props.section.description,
773
+ empty: fields.length === 0,
774
+ id: props.section.id?.toString(),
775
+ title: props.section.title,
776
+ children: group
777
+ }
778
+ );
779
+ }
780
+
781
+ // src/client/component/guard/visibility-guard.tsx
782
+ import { useAtomValue } from "jotai";
783
+
784
+ // src/client/lib/store-helper.ts
785
+ import { atom } from "jotai";
786
+ import { atomFamily } from "jotai-family";
787
+ import { deepEqual } from "fast-equals";
788
+ function createRecordAtomFamily(baseAtom) {
789
+ return atomFamily(
790
+ (name) => atom(
791
+ (get) => {
792
+ return get(baseAtom)[name] ?? void 0;
793
+ },
794
+ (get, set, newValue) => {
795
+ const current = get(baseAtom);
796
+ if (newValue !== void 0 && newValue !== null) {
797
+ const currentValue = current[name];
798
+ if (!currentValue || !deepEqual(currentValue, newValue)) {
799
+ set(baseAtom, { ...current, [name]: newValue });
800
+ }
801
+ } else if (current[name]) {
802
+ const { [name]: _unused, ...rest } = current;
803
+ set(baseAtom, rest);
804
+ }
805
+ }
806
+ )
807
+ );
808
+ }
809
+ function createClearAllAtom(baseAtom) {
810
+ return atom(null, (get, set) => {
811
+ const current = get(baseAtom);
812
+ if (current && Object.keys(current).length > 0) {
813
+ set(baseAtom, {});
814
+ }
815
+ });
816
+ }
817
+ function createClearAtom(baseAtom) {
818
+ return atom(null, (get, set, names) => {
819
+ const current = get(baseAtom);
820
+ const next = { ...current };
821
+ let hasChanges = false;
822
+ for (const name of names) {
823
+ if (next[name]) {
824
+ delete next[name];
825
+ hasChanges = true;
826
+ }
827
+ }
828
+ if (hasChanges) {
829
+ set(baseAtom, next);
830
+ }
831
+ });
832
+ }
833
+ function createBulkReportAtom(baseAtom) {
834
+ return atom(null, (get, set, newValue) => {
835
+ const current = get(baseAtom);
836
+ if (!deepEqual(current, newValue)) {
837
+ set(baseAtom, newValue);
838
+ }
839
+ });
840
+ }
841
+ function createAtomStore(initialValue = {}) {
842
+ const baseAtom = atom(initialValue);
843
+ return {
844
+ atom: baseAtom,
845
+ clearAll: createClearAllAtom(baseAtom),
846
+ clear: createClearAtom(baseAtom),
847
+ bulkReport: createBulkReportAtom(baseAtom),
848
+ report: createRecordAtomFamily(baseAtom)
849
+ };
850
+ }
851
+
852
+ // src/client/lib/state-store.ts
853
+ var store = createAtomStore();
854
+ var fieldStateAtom = store.atom;
855
+ var reportFieldStateAtom = store.report;
856
+
857
+ // src/client/component/guard/visibility-guard.tsx
858
+ function isColumnHidden(column, states) {
859
+ return column.fields.every((field) => isFieldHidden(field, states));
860
+ }
861
+ function isFieldHidden(field, states) {
862
+ return states[field.name]?.hidden ?? field.hidden ?? false;
863
+ }
864
+ function isEntryHidden(entry, states) {
865
+ return isColumn(entry) ? isColumnHidden(entry, states) : isFieldHidden(entry, states);
866
+ }
867
+ function VisibilityGuard(props) {
868
+ const states = useAtomValue(fieldStateAtom);
869
+ if (props.container) {
870
+ const hidden = states[props.container.name]?.hidden ?? props.container.hidden ?? false;
871
+ if (hidden) {
872
+ return null;
873
+ }
874
+ }
875
+ if (props.fields.length === 0) {
876
+ return null;
877
+ }
878
+ const allHidden = props.fields.every((entry) => isEntryHidden(entry, states));
879
+ if (allHidden) {
880
+ return null;
881
+ }
882
+ return props.children;
883
+ }
884
+
885
+ // src/component/separator.tsx
886
+ import { jsx as jsx9 } from "react/jsx-runtime";
887
+ function Separator() {
888
+ return /* @__PURE__ */ jsx9("div", { "data-slot": "field-separator", className: "relative -my-2 h-5 text-sm", children: /* @__PURE__ */ jsx9("div", { className: "absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800" }) });
889
+ }
890
+
891
+ // src/component/form.tsx
892
+ import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
893
+ function Form(props) {
894
+ const sections = prepare(props.sections, props.definition);
895
+ return /* @__PURE__ */ jsx10("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx10("form", { noValidate: props.noValidate, action: props.action, children: /* @__PURE__ */ jsxs4(Group, { children: [
896
+ sections.map((section, index) => /* @__PURE__ */ jsxs4(VisibilityGuard, { fields: section.fields ?? [], children: [
897
+ /* @__PURE__ */ jsx10(FieldSet, { section, style: props.config.style, children: props.children({
898
+ disabled: props.readOnly,
899
+ fields: section.fields
900
+ }) }),
901
+ section.separator && /* @__PURE__ */ jsx10(Separator, {})
902
+ ] }, index)),
903
+ props.control && /* @__PURE__ */ jsx10(Control, { isPending: props.isPending, children: props.control })
904
+ ] }) }) });
905
+ }
906
+
907
+ // src/component/description.tsx
908
+ import { jsx as jsx11 } from "react/jsx-runtime";
909
+ function Description(props) {
910
+ return /* @__PURE__ */ jsx11("p", { className: "-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400", children: props.children });
911
+ }
912
+
913
+ // src/component/formatted-description.tsx
914
+ import { jsx as jsx12 } from "react/jsx-runtime";
915
+ function FormattedDescription(props) {
916
+ const content = formatMarkdown2(props.text);
917
+ if (content) {
918
+ return /* @__PURE__ */ jsx12(Description, { children: content });
919
+ }
920
+ return null;
921
+ }
922
+
923
+ // src/component/label.tsx
924
+ import { twMerge } from "tailwind-merge";
925
+ import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
926
+ function Label(props) {
927
+ const showOptionalLabel = props.style?.showOptionalLabel ?? true;
928
+ const normal = isRadio(props.field) || isCheckbox(props.field);
929
+ return /* @__PURE__ */ jsxs5(
930
+ "label",
931
+ {
932
+ "data-slot": "field-label",
933
+ "data-normal": normal,
934
+ className: twMerge(
935
+ "flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",
936
+ "data-[normal=true]:font-normal",
937
+ "group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"
938
+ ),
939
+ htmlFor: props.field.name,
940
+ children: [
941
+ props.children,
942
+ showOptionalLabel && !props.field.required && /* @__PURE__ */ jsx13("span", { className: "text-sm text-slate-600 dark:text-slate-400", children: translate("(Optional)", props.translations) })
943
+ ]
944
+ }
945
+ );
946
+ }
947
+
948
+ // src/component/input-label.tsx
949
+ import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
950
+ function InputLabel(props) {
951
+ const interpolateOpts = {
952
+ context: props.context,
953
+ env: props.config?.env
954
+ };
955
+ const label = interpolateIfNeeded(props.field.label, interpolateOpts);
956
+ const description = interpolateIfNeeded(
957
+ props.field.description,
958
+ interpolateOpts
959
+ );
960
+ return /* @__PURE__ */ jsxs6(
961
+ "div",
962
+ {
963
+ "data-slot": "field-content",
964
+ className: "flex w-full flex-1 flex-col gap-1.5 leading-snug",
965
+ children: [
966
+ /* @__PURE__ */ jsx14(
967
+ Label,
968
+ {
969
+ field: props.field,
970
+ style: props.config?.style,
971
+ translations: props.translations,
972
+ children: translate(label, props.translations)
973
+ }
974
+ ),
975
+ props.orientation === HORIZONTAL && /* @__PURE__ */ jsx14(
976
+ FormattedDescription,
977
+ {
978
+ text: translate(description, props.translations)
979
+ }
980
+ )
981
+ ]
982
+ }
983
+ );
984
+ }
985
+
986
+ // src/component/input-group.tsx
987
+ import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
988
+ function InputGroup(props) {
989
+ return /* @__PURE__ */ jsxs7(Fragment2, { children: [
990
+ props.field.name && props.field.label && /* @__PURE__ */ jsx15(
991
+ InputLabel,
992
+ {
993
+ config: props.config,
994
+ context: props.context,
995
+ field: props.field,
996
+ orientation: props.orientation,
997
+ translations: props.translations
998
+ }
999
+ ),
1000
+ props.children,
1001
+ props.orientation === VERTICAL && props.field.description && /* @__PURE__ */ jsx15(
1002
+ FormattedDescription,
1003
+ {
1004
+ text: translate(props.field.description, props.translations)
1005
+ }
1006
+ )
1007
+ ] });
1008
+ }
1009
+
1010
+ // src/lib/render-If-exists.ts
1011
+ function renderIfExists(value, render) {
1012
+ if (!value) {
1013
+ return null;
1014
+ }
1015
+ return render(value);
1016
+ }
1017
+
1018
+ // src/server/component/input.tsx
1019
+ import { jsx as jsx16 } from "react/jsx-runtime";
1020
+ function Input(props) {
1021
+ const source = resolveSource(props.field, props.value);
1022
+ const { commonPropsWithOptions, defaultValue } = prepareInputProps(
1023
+ props.field,
1024
+ props.commonProps,
1025
+ source,
1026
+ props.value
1027
+ );
1028
+ const defaultProps = prepareDefaultValue(props.field, defaultValue);
1029
+ return renderIfExists(props.config.inputs[props.field.type], (Component) => /* @__PURE__ */ jsx16(
1030
+ InputGroup,
1031
+ {
1032
+ config: props.config,
1033
+ context: props.context,
1034
+ field: props.field,
1035
+ orientation: props.orientation,
1036
+ translations: props.translations,
1037
+ children: /* @__PURE__ */ jsx16(
1038
+ Component,
1039
+ {
1040
+ ...props.ariaAttributes,
1041
+ ...commonPropsWithOptions,
1042
+ ...props.dataAttributes,
1043
+ ...defaultProps
1044
+ }
1045
+ )
1046
+ }
1047
+ ));
1048
+ }
1049
+
1050
+ // src/component/field/field-error.tsx
1051
+ import { jsx as jsx17 } from "react/jsx-runtime";
1052
+ function FieldError(props) {
1053
+ if (!props.errors || props.errors.length === 0) {
1054
+ return null;
1055
+ }
1056
+ return /* @__PURE__ */ jsx17(
1057
+ "ul",
1058
+ {
1059
+ className: "text-sm text-red-600 dark:text-red-500",
1060
+ id: props.name ? `${props.name}-error` : void 0,
1061
+ children: props.errors?.map((error, index) => /* @__PURE__ */ jsx17("li", { children: error }, props.name ? `${props.name}-error-${index}` : index))
1062
+ }
1063
+ );
1064
+ }
1065
+
1066
+ // src/component/field/field-base.tsx
1067
+ import { twMerge as twMerge2 } from "tailwind-merge";
1068
+ import { jsx as jsx18 } from "react/jsx-runtime";
1069
+ function FieldBase(props) {
1070
+ const errors = props.errors && props.errors.length > 0;
1071
+ return /* @__PURE__ */ jsx18(
1072
+ "div",
1073
+ {
1074
+ "data-slot": "field",
1075
+ "data-clickable": props.isClickable ? "true" : "false",
1076
+ ...errors && { [DATA_INVALID]: "true" },
1077
+ ...props.disabled && { [DATA_READONLY]: "true" },
1078
+ "data-orientation": props.orientation,
1079
+ className: twMerge2(
1080
+ "group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500",
1081
+ "data-[clickable=true]:items-start",
1082
+ props.isCheckbox && (props.isReversed ? "flex-row-reverse!" : "flex-row!"),
1083
+ "data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",
1084
+ props.className
1085
+ ),
1086
+ children: props.children
1087
+ }
1088
+ );
1089
+ }
1090
+
1091
+ // src/component/field/field-vertical.tsx
1092
+ import { twMerge as twMerge3 } from "tailwind-merge";
1093
+ import { jsx as jsx19 } from "react/jsx-runtime";
1094
+ function FieldVertical(props) {
1095
+ return /* @__PURE__ */ jsx19(
1096
+ FieldBase,
1097
+ {
1098
+ ...props,
1099
+ orientation: VERTICAL,
1100
+ className: twMerge3(
1101
+ "gap-3 has-[>[data-slot=field-content]]:items-start",
1102
+ !props.isClickable && "[&>*]:w-full"
1103
+ ),
1104
+ children: props.children
1105
+ }
1106
+ );
1107
+ }
1108
+
1109
+ // src/component/field/field-horizontal.tsx
1110
+ import { twMerge as twMerge4 } from "tailwind-merge";
1111
+ import { jsx as jsx20 } from "react/jsx-runtime";
1112
+ function FieldHorizontal(props) {
1113
+ return /* @__PURE__ */ jsx20(
1114
+ FieldBase,
1115
+ {
1116
+ ...props,
1117
+ orientation: HORIZONTAL,
1118
+ className: twMerge4(
1119
+ "gap-2 md:flex-row md:gap-4",
1120
+ "[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start",
1121
+ "[&_[role=checkbox]]:mt-[1.5px]",
1122
+ props.isClickable && "md:flex-col",
1123
+ !props.isClickable && [
1124
+ "md:justify-between",
1125
+ "[&>*:not([data-slot=field-content])]:w-full",
1126
+ "[&>*:not([data-slot=field-content])]:md:w-1/2",
1127
+ "[&>*:not([data-slot=field-content])]:xl:w-2/5"
1128
+ ]
1129
+ ),
1130
+ children: props.children
1131
+ }
1132
+ );
1133
+ }
1134
+
1135
+ // src/component/field/field-group.tsx
1136
+ import { jsx as jsx21 } from "react/jsx-runtime";
1137
+ function FieldGroup(props) {
1138
+ const clickable = isClickable(props.field);
1139
+ const checkbox = isCheckbox(props.field);
1140
+ const reversed = buildReverse(props.field);
1141
+ if (props.orientation === VERTICAL) {
1142
+ return /* @__PURE__ */ jsx21(
1143
+ FieldVertical,
1144
+ {
1145
+ disabled: props.disabled,
1146
+ errors: props.errors,
1147
+ isCheckbox: checkbox,
1148
+ isReversed: reversed,
1149
+ isClickable: clickable,
1150
+ children: props.children
1151
+ }
1152
+ );
1153
+ }
1154
+ return /* @__PURE__ */ jsx21(
1155
+ FieldHorizontal,
1156
+ {
1157
+ disabled: props.disabled,
1158
+ errors: props.errors,
1159
+ isCheckbox: checkbox,
1160
+ isReversed: reversed,
1161
+ isClickable: clickable,
1162
+ children: props.children
1163
+ }
1164
+ );
1165
+ }
1166
+
1167
+ // src/component/input/input-base.tsx
1168
+ function InputBase(props) {
1169
+ if (!props.field.type) {
1170
+ return null;
1171
+ }
1172
+ const commonProps = buildCommon(props.field, props.disabled);
1173
+ const dataAttributes = buildDataAttributes(props.field);
1174
+ const ariaAttributes = buildAriaAttributes(props.field, props.errors);
1175
+ const field = {
1176
+ ...props.field,
1177
+ disabled: commonProps.disabled
1178
+ };
1179
+ return props.children({
1180
+ ariaAttributes,
1181
+ commonProps,
1182
+ dataAttributes,
1183
+ field,
1184
+ orientation: props.orientation
1185
+ });
1186
+ }
1187
+
1188
+ // src/component/field/field.tsx
1189
+ import { twMerge as twMerge5 } from "tailwind-merge";
1190
+ import { jsx as jsx22, jsxs as jsxs8 } from "react/jsx-runtime";
1191
+ function Field(props) {
1192
+ const cols2 = props.field.advanced?.cols;
1193
+ const errors = props.field.name ? props.errors?.[props.field.name] : void 0;
1194
+ const { orientation } = mergeStyle(props.style, {
1195
+ orientation: buildOrientation(props.field)
1196
+ });
1197
+ const disabled = buildDisabled(props.field, props.disabled);
1198
+ return /* @__PURE__ */ jsxs8("div", { className: twMerge5("flex flex-col gap-3", getSpan(cols2)), children: [
1199
+ /* @__PURE__ */ jsx22(
1200
+ FieldGroup,
1201
+ {
1202
+ disabled,
1203
+ errors,
1204
+ field: props.field,
1205
+ orientation,
1206
+ children: /* @__PURE__ */ jsx22(
1207
+ InputBase,
1208
+ {
1209
+ disabled,
1210
+ errors,
1211
+ field: props.field,
1212
+ orientation,
1213
+ children: props.children
1214
+ }
1215
+ )
1216
+ }
1217
+ ),
1218
+ /* @__PURE__ */ jsx22(FieldError, { errors, name: props.field.name })
1219
+ ] });
1220
+ }
1221
+
1222
+ // src/component/field/field-list-item.tsx
1223
+ import { twMerge as twMerge6 } from "tailwind-merge";
1224
+ import { jsx as jsx23, jsxs as jsxs9 } from "react/jsx-runtime";
1225
+ function FieldListItem(props) {
1226
+ function handleRemove() {
1227
+ if (props.canRemove && props.onRemove) {
1228
+ props.onRemove(props.index);
1229
+ }
1230
+ }
1231
+ const removeButton = props.canRemove && props.onRemove != null && /* @__PURE__ */ jsx23(
1232
+ "button",
1233
+ {
1234
+ "aria-label": `Remove ${props.label} item ${props.index + 1}`,
1235
+ className: twMerge6(
1236
+ "rounded p-1 text-xl text-slate-400",
1237
+ "transition-colors duration-150",
1238
+ "hover:text-red-500",
1239
+ "focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:outline-none",
1240
+ "dark:text-slate-500 dark:hover:text-red-400"
1241
+ ),
1242
+ onClick: handleRemove,
1243
+ type: "button",
1244
+ children: /* @__PURE__ */ jsx23("span", { "aria-hidden": "true", children: "\xD7" })
1245
+ }
1246
+ );
1247
+ if (props.isMultiField) {
1248
+ return /* @__PURE__ */ jsxs9("div", { className: "rounded-lg border border-slate-100 p-4 dark:border-slate-900", children: [
1249
+ /* @__PURE__ */ jsxs9("div", { className: "mb-3 flex items-center justify-between", children: [
1250
+ /* @__PURE__ */ jsxs9("span", { className: "text-sm font-medium text-slate-400 dark:text-slate-500", children: [
1251
+ props.label,
1252
+ " ",
1253
+ props.index + 1
1254
+ ] }),
1255
+ removeButton
1256
+ ] }),
1257
+ /* @__PURE__ */ jsx23(Group, { children: props.children })
1258
+ ] });
1259
+ }
1260
+ return /* @__PURE__ */ jsxs9("div", { className: "flex items-start gap-2", children: [
1261
+ /* @__PURE__ */ jsx23(Group, { children: props.children }),
1262
+ removeButton && /* @__PURE__ */ jsx23("div", { className: "shrink-0", children: removeButton })
1263
+ ] });
1264
+ }
1265
+
1266
+ // src/component/field/field-list.tsx
1267
+ import { jsx as jsx24 } from "react/jsx-runtime";
1268
+ function FieldList(props) {
1269
+ const label = getLabel(props.field);
1270
+ const isMultiField = isMultiFieldList(props.field);
1271
+ return getInitialList(props.field, props.value).map((index) => /* @__PURE__ */ jsx24(
1272
+ FieldListItem,
1273
+ {
1274
+ index,
1275
+ isMultiField,
1276
+ label,
1277
+ children: props.children(index)
1278
+ },
1279
+ index
1280
+ ));
1281
+ }
1282
+
1283
+ // src/component/list.tsx
1284
+ import { jsx as jsx25 } from "react/jsx-runtime";
1285
+ function List(props) {
1286
+ const empty = Array.isArray(props.field.fields) && props.field.fields.length === 0;
1287
+ return /* @__PURE__ */ jsx25(
1288
+ FieldSetBase,
1289
+ {
1290
+ description: props.field.description,
1291
+ empty,
1292
+ id: props.field.name,
1293
+ title: props.field.label,
1294
+ children: props.children
1295
+ }
1296
+ );
1297
+ }
1298
+
1299
+ // src/component/slot/list-slot.tsx
1300
+ import { jsx as jsx26 } from "react/jsx-runtime";
1301
+ function ListSlot({ children, field, value }) {
1302
+ return /* @__PURE__ */ jsx26(List, { field, children: /* @__PURE__ */ jsx26(FieldList, { field, value, children }) });
1303
+ }
1304
+
1305
+ // src/component/column.tsx
1306
+ import { twMerge as twMerge7 } from "tailwind-merge";
1307
+ import { jsx as jsx27 } from "react/jsx-runtime";
1308
+ function Column(props) {
1309
+ const cols2 = getColumn(props.column?.advanced?.cols);
1310
+ return /* @__PURE__ */ jsx27("div", { className: "flex w-full flex-col gap-4", children: /* @__PURE__ */ jsx27("div", { className: twMerge7("grid grid-cols-1 gap-3 sm:gap-4", cols2), children: props.children }) });
1311
+ }
1312
+
1313
+ // src/component/slot/slot-base.tsx
1314
+ import { Fragment as Fragment3 } from "react";
1315
+
1316
+ // src/component/slot/slot-list.tsx
1317
+ import { jsx as jsx28 } from "react/jsx-runtime";
1318
+ function SlotList(props) {
1319
+ const fields = Array.isArray(props.field.fields) ? props.field.fields.map((field) => {
1320
+ if (isField(field)) {
1321
+ return {
1322
+ ...field,
1323
+ name: `${props.field.name}.${props.index}.${field.name}`
1324
+ };
1325
+ }
1326
+ if (isColumn(field)) {
1327
+ return {
1328
+ ...field,
1329
+ fields: field.fields.map((columnField) => ({
1330
+ ...columnField,
1331
+ name: `${props.field.name}.${props.index}.${columnField.name}`
1332
+ }))
1333
+ };
1334
+ }
1335
+ return field;
1336
+ }) : [];
1337
+ return /* @__PURE__ */ jsx28(
1338
+ SlotBase,
1339
+ {
1340
+ children: props.children,
1341
+ components: props.components,
1342
+ disabled: props.disabled,
1343
+ fields,
1344
+ style: props.style,
1345
+ value: props.value
1346
+ }
1347
+ );
1348
+ }
1349
+
1350
+ // src/component/slot/slot-base.tsx
1351
+ import { jsx as jsx29, jsxs as jsxs10 } from "react/jsx-runtime";
1352
+ function SlotBase(props) {
1353
+ const { field: Field2, list: List2 } = props.components;
1354
+ return prepare(props.fields).map((field, index) => /* @__PURE__ */ jsxs10(Fragment3, { children: [
1355
+ isColumn(field) && /* @__PURE__ */ jsx29(Column, { column: field, children: /* @__PURE__ */ jsx29(SlotBase, { ...props, fields: field.fields }) }),
1356
+ isField(field) && /* @__PURE__ */ jsx29(Field2, { disabled: props.disabled, field, style: props.style, children: props.children }),
1357
+ isList(field) && /* @__PURE__ */ jsx29(List2, { field, value: props.value, children: (index2) => /* @__PURE__ */ jsx29(
1358
+ SlotList,
1359
+ {
1360
+ children: props.children,
1361
+ components: props.components,
1362
+ disabled: props.disabled,
1363
+ field,
1364
+ index: index2,
1365
+ style: props.style,
1366
+ value: props.value
1367
+ }
1368
+ ) })
1369
+ ] }, index));
1370
+ }
1371
+
1372
+ // src/component/slot/slot-create.tsx
1373
+ import { jsx as jsx30 } from "react/jsx-runtime";
1374
+ function createSlot(components) {
1375
+ const CreateSlot = (props) => /* @__PURE__ */ jsx30(SlotBase, { ...props, components });
1376
+ return CreateSlot;
1377
+ }
1378
+
1379
+ // src/component/slot/slot.tsx
1380
+ var Slot = createSlot({ field: Field, list: ListSlot });
1381
+
1382
+ // src/server/component/form.tsx
1383
+ import { jsx as jsx31 } from "react/jsx-runtime";
1384
+ function Form2(props) {
1385
+ const translations = props.translations?.[props.lang ?? ""];
1386
+ return /* @__PURE__ */ jsx31(
1387
+ Form,
1388
+ {
1389
+ config: props.config,
1390
+ control: props.children,
1391
+ definition: props.definition,
1392
+ readOnly: props.readOnly,
1393
+ sections: props.sections,
1394
+ children: ({ disabled, fields }) => /* @__PURE__ */ jsx31(Slot, { disabled, fields, style: props.config.style, children: (internal) => /* @__PURE__ */ jsx31(
1395
+ Input,
1396
+ {
1397
+ ...internal,
1398
+ config: props.config,
1399
+ context: props.context,
1400
+ translations,
1401
+ value: props.value
1402
+ }
1403
+ ) })
1404
+ }
1405
+ );
1406
+ }
1407
+
1408
+ // src/server/component/fallback.tsx
1409
+ import { Suspense } from "react";
1410
+ import { jsx as jsx32 } from "react/jsx-runtime";
1411
+ function Fallback(props) {
1412
+ return /* @__PURE__ */ jsx32(
1413
+ Suspense,
1414
+ {
1415
+ fallback: /* @__PURE__ */ jsx32(Form2, { config: props.config, sections: props.sections, readOnly: true }),
1416
+ children: props.children
1417
+ }
1418
+ );
1419
+ }
1420
+ export {
1421
+ Fallback,
1422
+ Form2 as Form
1423
+ };