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