react-luna-form 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/cjs/index.js +2261 -1
- package/dist/client/esm/index.js +2228 -1
- package/dist/config/cjs/index.js +229 -1
- package/dist/config/esm/index.js +206 -1
- package/dist/server/cjs/index.js +1085 -1
- package/dist/server/esm/index.js +1062 -1
- package/package.json +3 -3
package/dist/server/cjs/index.js
CHANGED
|
@@ -1 +1,1085 @@
|
|
|
1
|
-
"use strict";var $=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var Qt=Object.prototype.hasOwnProperty;var jt=(e,t)=>{for(var n in t)$(e,n,{get:t[n],enumerable:!0})},en=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jt(t))!Qt.call(e,o)&&o!==n&&$(e,o,{get:()=>t[o],enumerable:!(r=Zt(t,o))||r.enumerable});return e};var tn=e=>en($({},"__esModule",{value:!0}),e);var hn={};jt(hn,{Fallback:()=>Wt,Form:()=>B});module.exports=tn(hn);var ie=require("react/jsx-runtime");function oe(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return(0,ie.jsx)("div",{"data-slot":"field-control",className:"w-full",children:t})}var le=require("react/jsx-runtime");function S(e){return(0,le.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 L="input",ae="input/email",se="input/number";var ce="textarea",de="radio",ue="checkbox",fe="select",me="select/month",pe="select/year";var H="column";var ge="label",K="value",D="options",W="email",xe="number",ye="password",be="tel",E="text",Re="aria-errormessage",Te="aria-invalid",Ae="data-invalid",Ce="data-readonly",he="aria",Ne="data",Fe="min",Se="max",Ee="minLength",Ie="maxLength",A="$ref";var f="vertical",C="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 g(e){return typeof e=="string"}var nn=/[^/]+$/;function Oe(e,t=K){if(e!=null){if(m(e))return e;if(l(e)){let n=rn(e,t);if(m(n))return n}}}function rn(e,t){let n=x(e,t);if(m(n))return n}function x(e,t){if(!t||!l(e))return null;let n=t.split(".").filter(o=>o!=="");if(n.length===0)return null;let r=e;for(let o of n)if(l(r)&&o in r)r=r[o];else return null;return r}function ke(e,t={label:ge,value:K}){return e.map(n=>{if(l(n)){let r=x(n,t.label),o=x(n,t.value);if(m(r)&&m(o))return{label:`${r}`,value:`${o}`}}return n})}function Pe(e=E){if(e){let t=e.match(nn);if(t){let[n]=t;if(n!==L)return n.trim().toLowerCase()}}return E}var on=/\[([^\]]+)\]\(([^)]+)\)/g;function I(e,t={}){if(g(e))return ln(e,t);if(Array.isArray(e))return e.map(n=>I(n,t));if(l(e)){let n={};for(let r in e)n[r]=I(e[r],t);return n}return e}function O(e){return g(e)?/{([^}]+)}/.test(e):Array.isArray(e)?e.some(t=>O(t)):l(e)?Object.values(e).some(t=>O(t)):!1}function ln(e,t={}){return e.replace(/{([^}]+)}/g,(n,r)=>{let o=r.includes(".")?x(t,r):t[r];return m(o)?String(o):n})}function we(e,t){if(!e||e.trim().length===0)return null;let n,r=0,o=!1,i=[];for(;(n=on.exec(e))!==null;){let[a,p,qt]=n,w=n.index;o=!0,w>r&&i.push(e.substring(r,w));let zt=t?t(w,qt,p):a;i.push(zt),r=w+a.length}return o?(r<e.length&&i.push(e.substring(r)),i):e}var Le=e=>c(me)(e),De=e=>c(pe)(e),s=c(ue),_e=c(L),y=c(de),d=c(fe),ve=c(ce),Me=c(E,W,ye,be),Mn=c(ae,W),Ve=c(se,xe);function Ge(e){return y(e)||s(e)}function Xe(e){return e.type===H}function Ye(e){return e.type!==H}function Ue(e){return d(e)||y(e)}function q(e){return e!=null&&e!==""}function c(...e){return t=>{let n=g(t.type)?t.type:void 0;return n?e.some(r=>n===r||n?.startsWith(`${r}/`)):!1}}function Be(e,t={}){if(d(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&l(n))return[n]}}function $e(e){return y(e)||s(e)?C:e.advanced?.orientation??f}function He(e){return s(e)?e.advanced?.reverse!==!1:!1}function Ke(e,t){let n=e.readonly??!1;return t||n}function We(e){if(y(e)||d(e)&&!e.disabled){let t=e.source;if(Array.isArray(t)||l(t)&&!(A in t))return t}}var an=/^\d+$/;function qe(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function ze(e,t){return t>=e?Array.from({length:t-e+1},(n,r)=>{let o=e+r;return{value:o.toString(),label:o.toString()}}):[]}function z(){return new Date().getFullYear()}function Z(e,t){if(typeof e=="number")return e;let n=t??z(),r=e.trim().toLowerCase();if(r.startsWith("current")){let o=r.match(/^current([+-])(\d+)$/);if(o){let[,i,a]=o,p=parseInt(a,10);if(!isNaN(p))return i==="+"?n+p:n-p}return n}return an.test(r)?parseInt(r,10):n}var _=z();function sn(e){if(d(e))return cn(e)}function cn(e){if(Le(e))return qe();if(De(e)){let t=e.advanced?.length?.min??_,n=e.advanced?.length?.max??_+5;return ze(Z(t,_),Z(n,_))}}function Ze(e,t=!1){let n={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return _e(e)?{...n,...dn(e)}:d(e)?{...n,...un(e)}:ve(e)?{...n,...fn(e)}:n}function dn(e){let t=Pe(e.type),n={...e,type:t};return{...Je(e),...mn(n),...Me(n)?Qe(n):{},type:t}}function un(e){let t=sn(e);return t?{options:t}:{}}function fn(e){return{...Je(e),...Qe(e)}}function Je(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function mn(e){return Ve(e)?pn(e):{}}function Qe(e){return je(e,{min:Ee,max:Ie})}function pn(e){return je(e,{min:Fe,max:Se})}function je(e,t){let n={},r=e.advanced?.length;return r&&(r.min!==void 0&&(n[t.min]=r.min),r.max!==void 0&&(n[t.max]=r.max)),n}function et(e,t){let n=We(e);return n||Be(e,t)}function gn(e,t){let n=l(t)&&e.name in t?t[e.name]:t;return Oe(n,e.advanced?.entity)}function xn(e,t,n){return Ue(e)&&Array.isArray(n)?{...t,[D]:n}:t}function yn(e,t,n){if(e.required&&!q(n)&&d(e)&&e.advanced?.preselected!==!1&&D in t){let r=t[D];if(Array.isArray(r)&&r.length===1)return r[0]}return n}function bn(e,t){return d(e)&&Array.isArray(t)?ke(t,e.advanced?.options):t}function tt(e,t,n,r){let o=gn(e,r),i=Array.isArray(n)?bn(e,n):n,a=xn(e,t,i),p=yn(e,a,o);return{commonPropsWithOptions:a,defaultValue:p}}function nt(e,t){return s(e)?{defaultChecked:q(t)}:{defaultValue:t}}var Rn=/^#\/definition\//;function M(e=[],t){let n=v(e,t);return Array.isArray(n)?n.sort((r,o)=>rt(r)-rt(o)):[]}function v(e,t,n=new Map,r=new WeakSet){if(!Tn(t)||!e||typeof e!="object")return e;if(n.has(e))return n.get(e);if(r.has(e))return e;if(r.add(e),Array.isArray(e))return e.map(i=>v(i,t,n,r));if(A in e&&g(e[A])){let i=e[A].replace(Rn,""),a=x(t,i);return a!==null?v(a,t,n,r):e}let o={};for(let[i,a]of Object.entries(e))o[i]=v(a,t,n,r);return r.delete(e),n.set(e,o),o}function ot(e){return Object.entries(e??{})}function rt(e){return e.order??Number.MAX_VALUE}function Tn(e){return e!==void 0&&l(e)&&Object.keys(e).length>0}function it(e,t){let n={};for(let[r,o]of ot(t))n[`${e}-${r}`]=o;return n}function An(e){return it(he,e)}function Cn(e){return it(Ne,e)}function lt(e,t){let n=An(e.advanced?.aria);return t&&t.length>0&&(n[Te]="true",n[Re]=`${e.name}-error`),n}function at(e){return Cn(e.advanced?.data)}var st={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},ct={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function dt(e,t=2){return st[e&&e in st?e:t]}function ut(e){if(e&&e in ct)return ct[e]}function b(e,t){return e?t?t[e]??e:e:""}function V(e,t){return{...e,...t}}var ft=require("react/jsx-runtime");function k(e){return we(e,(t,n,r)=>(0,ft.jsx)("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:r},`${n}-${t}`))}var R=require("react/jsx-runtime");function mt(e){return(0,R.jsxs)(R.Fragment,{children:[e.title&&(0,R.jsx)("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:k(e.title)}),e.description&&(0,R.jsx)("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:k(e.description)})]})}var h=require("react/jsx-runtime");function pt(e){let t=e.section.fields||[],{compact:n}=V(e.style,{compact:e.section.compact});return!e.section.title&&!e.section.description?(0,h.jsx)(S,{compact:n,children:e.children}):(0,h.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,h.jsx)(mt,{description:e.section.description,title:e.section.title}),(0,h.jsx)(S,{compact:n,children:e.children})]})}var xt=require("react");var J=require("react/jsx-runtime");function gt(){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 u=require("react/jsx-runtime");function yt(e){let t=M(e.sections,e.definition);return(0,u.jsx)("div",{className:"h-full w-full",children:(0,u.jsx)("form",{noValidate:e.noValidate,action:e.action,children:(0,u.jsxs)(S,{children:[t.map((n,r)=>(0,u.jsxs)(xt.Fragment,{children:[(0,u.jsx)(pt,{section:n,style:e.config.style,children:e.children({disabled:e.readOnly,fields:n.fields})}),n.separator&&(0,u.jsx)(gt,{})]},r)),e.control&&(0,u.jsx)(oe,{isPending:e.isPending,children:e.control})]})})})}var Rt=require("react/jsx-runtime");function bt(e){return(0,Rt.jsx)("p",{className:"-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}var Tt=require("react/jsx-runtime");function G(e){let t=k(e.text);return t?(0,Tt.jsx)(bt,{children:t}):null}var At=require("tailwind-merge"),X=require("react/jsx-runtime");function Ct(e){let t=e.style?.showOptionalLabel??!0,n=y(e.field)||s(e.field);return(0,X.jsxs)("label",{"data-slot":"field-label","data-normal":n,className:(0,At.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,X.jsx)("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:b("(Optional)",e.translations)})]})}var P=require("react/jsx-runtime");function ht(e){let t=O(e.field.label)?I(e.field.label,{context:e.context,env:e.config?.env}):e.field.label,n=O(e.field.description)?I(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)(Ct,{field:e.field,style:e.config?.style,translations:e.translations,children:b(t,e.translations)}),e.orientation===C&&(0,P.jsx)(G,{text:b(n,e.translations)})]})}var T=require("react/jsx-runtime");function Nt(e){return(0,T.jsxs)(T.Fragment,{children:[e.field.name&&e.field.label&&(0,T.jsx)(ht,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations}),e.children,e.orientation===f&&e.field.description&&(0,T.jsx)(G,{text:b(e.field.description,e.translations)})]})}function Ft(e,t){return e?t(e):null}var Q=require("react/jsx-runtime");function St(e){let t=et(e.field,e.value),{commonPropsWithOptions:n,defaultValue:r}=tt(e.field,e.commonProps,t,e.value),o=nt(e.field,r);return Ft(e.config.inputs[e.field.type],i=>(0,Q.jsx)(Nt,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations,children:(0,Q.jsx)(i,{...e.ariaAttributes,...n,...e.dataAttributes,...o})}))}var j=require("react/jsx-runtime");function Et(e){return!e.errors||e.errors.length===0?null:(0,j.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,j.jsx)("li",{children:t},e.name?`${e.name}-error-${n}`:n))})}var It=require("tailwind-merge"),Ot=require("react/jsx-runtime");function Y(e){let t=e.errors&&e.errors.length>0;return(0,Ot.jsx)("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[Ae]:"true"},...e.disabled&&{[Ce]:"true"},"data-orientation":e.orientation,className:(0,It.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 kt=require("tailwind-merge"),wt=require("react/jsx-runtime");function Pt(e){return(0,wt.jsx)(Y,{...e,orientation:f,className:(0,kt.twMerge)("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}var Lt=require("tailwind-merge"),_t=require("react/jsx-runtime");function Dt(e){return(0,_t.jsx)(Y,{...e,orientation:C,className:(0,Lt.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 ee=require("react/jsx-runtime");function vt(e){let t=Ge(e.field),n=s(e.field),r=He(e.field);return e.orientation===f?(0,ee.jsx)(Pt,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children}):(0,ee.jsx)(Dt,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children})}function Mt(e){if(!e.field.type)return null;let t=Ze(e.field,e.disabled),n=at(e.field),r=lt(e.field,e.errors),o={...e.field,disabled:t.disabled};return e.children({ariaAttributes:r,commonProps:t,dataAttributes:n,field:o,orientation:e.orientation})}var Vt=require("tailwind-merge"),N=require("react/jsx-runtime");function Gt(e){let t=e.field.advanced?.cols,n=e.field.name?e.errors?.[e.field.name]:void 0,{orientation:r}=V(e.style,{orientation:$e(e.field)}),o=Ke(e.field,e.disabled);return(0,N.jsxs)("div",{className:(0,Vt.twMerge)("flex flex-col gap-3",ut(t)),children:[(0,N.jsx)(vt,{disabled:o,errors:n,field:e.field,orientation:r,children:(0,N.jsx)(Mt,{disabled:o,errors:n,field:e.field,orientation:r,children:e.children})}),(0,N.jsx)(Et,{errors:n,name:e.field.name})]})}var Xt=require("tailwind-merge"),te=require("react/jsx-runtime");function Yt(e){let t=dt(e.column?.advanced?.cols);return(0,te.jsx)("div",{className:"flex w-full flex-col gap-4",children:(0,te.jsx)("div",{className:(0,Xt.twMerge)("grid grid-cols-1 gap-3 sm:gap-4",t),children:e.children})})}var Ut=require("react"),F=require("react/jsx-runtime");function ne(e){let{column:t,field:n}=e.components;return M(e.fields).map((r,o)=>(0,F.jsxs)(Ut.Fragment,{children:[Xe(r)&&(0,F.jsx)(t,{column:r,children:(0,F.jsx)(ne,{...e,fields:r.fields})}),Ye(r)&&(0,F.jsx)(n,{disabled:e.disabled,field:r,style:e.style,children:e.children})]},o))}var $t=require("react/jsx-runtime");function Bt(e){return n=>(0,$t.jsx)(ne,{...n,components:{column:Yt,field:e}})}var Ht=Bt(Gt);var U=require("react/jsx-runtime");function B(e){let t=e.translations?.[e.lang??""];return(0,U.jsx)(yt,{config:e.config,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,children:({disabled:n,fields:r})=>(0,U.jsx)(Ht,{disabled:n,fields:r,style:e.config.style,children:o=>(0,U.jsx)(St,{...o,config:e.config,context:e.context,translations:t,value:e.value})})})}var Kt=require("react");var re=require("react/jsx-runtime");function Wt(e){return(0,re.jsx)(Kt.Suspense,{fallback:(0,re.jsx)(B,{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/group.tsx
|
|
36
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
37
|
+
function Group(props) {
|
|
38
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
"data-slot": "field-group",
|
|
42
|
+
"data-compact": props.compact,
|
|
43
|
+
className: "flex w-full flex-col gap-8 data-[compact=true]:gap-3",
|
|
44
|
+
children: props.children
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ../luna-core/src/util/constant.ts
|
|
50
|
+
var INPUT = "input";
|
|
51
|
+
var INPUT_EMAIL = "input/email";
|
|
52
|
+
var INPUT_NUMBER = "input/number";
|
|
53
|
+
var TEXTAREA = "textarea";
|
|
54
|
+
var RADIO = "radio";
|
|
55
|
+
var CHECKBOX = "checkbox";
|
|
56
|
+
var SELECT = "select";
|
|
57
|
+
var SELECT_MONTH = "select/month";
|
|
58
|
+
var SELECT_YEAR = "select/year";
|
|
59
|
+
var COLUMN = "column";
|
|
60
|
+
var LABEL = "label";
|
|
61
|
+
var VALUE = "value";
|
|
62
|
+
var OPTIONS = "options";
|
|
63
|
+
var TYPE_EMAIL = "email";
|
|
64
|
+
var TYPE_NUMBER = "number";
|
|
65
|
+
var TYPE_PASSWORD = "password";
|
|
66
|
+
var TYPE_TEL = "tel";
|
|
67
|
+
var TYPE_TEXT = "text";
|
|
68
|
+
var ARIA_ERROR_MESSAGE = "aria-errormessage";
|
|
69
|
+
var ARIA_INVALID = "aria-invalid";
|
|
70
|
+
var DATA_INVALID = "data-invalid";
|
|
71
|
+
var DATA_READONLY = "data-readonly";
|
|
72
|
+
var PREFIX_ARIA = "aria";
|
|
73
|
+
var PREFIX_DATA = "data";
|
|
74
|
+
var MIN = "min";
|
|
75
|
+
var MAX = "max";
|
|
76
|
+
var MIN_LENGTH = "minLength";
|
|
77
|
+
var MAX_LENGTH = "maxLength";
|
|
78
|
+
var $REF = "$ref";
|
|
79
|
+
var VERTICAL = "vertical";
|
|
80
|
+
var HORIZONTAL = "horizontal";
|
|
81
|
+
|
|
82
|
+
// ../luna-core/src/util/is-type.ts
|
|
83
|
+
function isObject(value) {
|
|
84
|
+
return value !== null && Object.prototype.toString.call(value) === "[object Object]";
|
|
85
|
+
}
|
|
86
|
+
function isValue(value) {
|
|
87
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
88
|
+
}
|
|
89
|
+
function isString(value) {
|
|
90
|
+
return typeof value === "string";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ../luna-core/src/util/extract.ts
|
|
94
|
+
var REGEX_TYPE = /[^/]+$/;
|
|
95
|
+
function getCurrentValue(value, entity = VALUE) {
|
|
96
|
+
if (value !== null && value !== void 0) {
|
|
97
|
+
if (isValue(value)) {
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
if (isObject(value)) {
|
|
101
|
+
const result = getValue(value, entity);
|
|
102
|
+
if (isValue(result)) {
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function getValue(value, namespace) {
|
|
109
|
+
const result = extract(value, namespace);
|
|
110
|
+
if (isValue(result)) {
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function extract(value, namespace) {
|
|
115
|
+
if (!namespace || !isObject(value)) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const keys = namespace.split(".").filter((key) => key !== "");
|
|
119
|
+
if (keys.length === 0) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
let result = value;
|
|
123
|
+
for (const key of keys) {
|
|
124
|
+
if (isObject(result) && key in result) {
|
|
125
|
+
const obj = result;
|
|
126
|
+
result = obj[key];
|
|
127
|
+
} else {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
function toOptions(data, options = { label: LABEL, value: VALUE }) {
|
|
134
|
+
return data.map((item) => {
|
|
135
|
+
if (isObject(item)) {
|
|
136
|
+
const label = extract(item, options.label);
|
|
137
|
+
const value = extract(item, options.value);
|
|
138
|
+
if (isValue(label) && isValue(value)) {
|
|
139
|
+
return {
|
|
140
|
+
label: `${label}`,
|
|
141
|
+
value: `${value}`
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return item;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function getType(value = TYPE_TEXT) {
|
|
149
|
+
if (value) {
|
|
150
|
+
const result = value.match(REGEX_TYPE);
|
|
151
|
+
if (result) {
|
|
152
|
+
const [type] = result;
|
|
153
|
+
if (type !== INPUT) {
|
|
154
|
+
return type.trim().toLowerCase();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return TYPE_TEXT;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ../luna-core/src/util/string.ts
|
|
162
|
+
var REGEX_MARKDOWN_LINK = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
163
|
+
function interpolate(template, values = {}) {
|
|
164
|
+
if (isString(template)) {
|
|
165
|
+
return replacePlaceholders(template, values);
|
|
166
|
+
}
|
|
167
|
+
if (Array.isArray(template)) {
|
|
168
|
+
return template.map((item) => {
|
|
169
|
+
return interpolate(item, values);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
if (isObject(template)) {
|
|
173
|
+
const results = {};
|
|
174
|
+
for (const key in template) {
|
|
175
|
+
results[key] = interpolate(template[key], values);
|
|
176
|
+
}
|
|
177
|
+
return results;
|
|
178
|
+
}
|
|
179
|
+
return template;
|
|
180
|
+
}
|
|
181
|
+
function isInterpolated(template) {
|
|
182
|
+
if (isString(template)) {
|
|
183
|
+
return /{([^}]+)}/.test(template);
|
|
184
|
+
}
|
|
185
|
+
if (Array.isArray(template)) {
|
|
186
|
+
return template.some((item) => isInterpolated(item));
|
|
187
|
+
}
|
|
188
|
+
if (isObject(template)) {
|
|
189
|
+
return Object.values(template).some((value) => isInterpolated(value));
|
|
190
|
+
}
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
function replacePlaceholders(template, values = {}) {
|
|
194
|
+
return template.replace(/{([^}]+)}/g, (match, key) => {
|
|
195
|
+
const value = key.includes(".") ? extract(values, key) : values[key];
|
|
196
|
+
if (isValue(value)) {
|
|
197
|
+
return String(value);
|
|
198
|
+
}
|
|
199
|
+
return match;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function formatMarkdown(text, callback) {
|
|
203
|
+
if (!text || text.trim().length === 0) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
let match;
|
|
207
|
+
let lastIndex = 0;
|
|
208
|
+
let hasMatch = false;
|
|
209
|
+
const parts = [];
|
|
210
|
+
while ((match = REGEX_MARKDOWN_LINK.exec(text)) !== null) {
|
|
211
|
+
const [fullMatch, linkText, url] = match;
|
|
212
|
+
const index = match.index;
|
|
213
|
+
hasMatch = true;
|
|
214
|
+
if (index > lastIndex) {
|
|
215
|
+
parts.push(text.substring(lastIndex, index));
|
|
216
|
+
}
|
|
217
|
+
const value = callback ? callback(index, url, linkText) : fullMatch;
|
|
218
|
+
parts.push(value);
|
|
219
|
+
lastIndex = index + fullMatch.length;
|
|
220
|
+
}
|
|
221
|
+
if (!hasMatch) {
|
|
222
|
+
return text;
|
|
223
|
+
}
|
|
224
|
+
if (lastIndex < text.length) {
|
|
225
|
+
parts.push(text.substring(lastIndex));
|
|
226
|
+
}
|
|
227
|
+
return parts;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ../luna-core/src/util/is-input.ts
|
|
231
|
+
var isSelectMonth = (field) => createTypeChecker(SELECT_MONTH)(field);
|
|
232
|
+
var isSelectYear = (field) => createTypeChecker(SELECT_YEAR)(field);
|
|
233
|
+
var isCheckbox = createTypeChecker(CHECKBOX);
|
|
234
|
+
var isInput = createTypeChecker(INPUT);
|
|
235
|
+
var isRadio = createTypeChecker(RADIO);
|
|
236
|
+
var isSelect = createTypeChecker(SELECT);
|
|
237
|
+
var isTextArea = createTypeChecker(TEXTAREA);
|
|
238
|
+
var isText = createTypeChecker(
|
|
239
|
+
TYPE_TEXT,
|
|
240
|
+
TYPE_EMAIL,
|
|
241
|
+
TYPE_PASSWORD,
|
|
242
|
+
TYPE_TEL
|
|
243
|
+
);
|
|
244
|
+
var isEmail = createTypeChecker(INPUT_EMAIL, TYPE_EMAIL);
|
|
245
|
+
var isNumber = createTypeChecker(INPUT_NUMBER, TYPE_NUMBER);
|
|
246
|
+
function isClickable(field) {
|
|
247
|
+
return isRadio(field) || isCheckbox(field);
|
|
248
|
+
}
|
|
249
|
+
function isColumn(slot) {
|
|
250
|
+
return slot.type === COLUMN;
|
|
251
|
+
}
|
|
252
|
+
function isField(slot) {
|
|
253
|
+
return slot.type !== COLUMN;
|
|
254
|
+
}
|
|
255
|
+
function isOptions(field) {
|
|
256
|
+
return isSelect(field) || isRadio(field);
|
|
257
|
+
}
|
|
258
|
+
function isValidValue(value) {
|
|
259
|
+
return value !== void 0 && value !== null && value !== "";
|
|
260
|
+
}
|
|
261
|
+
function createTypeChecker(...types) {
|
|
262
|
+
return (field) => {
|
|
263
|
+
const inputType = isString(field.type) ? field.type : void 0;
|
|
264
|
+
if (!inputType) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return types.some((type) => {
|
|
268
|
+
return inputType === type || inputType?.startsWith(`${type}/`);
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// ../luna-core/src/util/build.ts
|
|
274
|
+
function buildOptions(field, values = {}) {
|
|
275
|
+
if (isSelect(field) && field.disabled) {
|
|
276
|
+
const current = field.name ? values?.[field.name] : void 0;
|
|
277
|
+
if (current && isObject(current)) {
|
|
278
|
+
return [current];
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function buildOrientation(field) {
|
|
283
|
+
if (isRadio(field) || isCheckbox(field)) {
|
|
284
|
+
return HORIZONTAL;
|
|
285
|
+
}
|
|
286
|
+
return field.advanced?.orientation ?? VERTICAL;
|
|
287
|
+
}
|
|
288
|
+
function buildReverse(field) {
|
|
289
|
+
if (!isCheckbox(field)) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
return field.advanced?.reverse !== false;
|
|
293
|
+
}
|
|
294
|
+
function buildDisabled(field, disabled) {
|
|
295
|
+
const readonly = field.readonly ?? false;
|
|
296
|
+
return disabled ? disabled : readonly;
|
|
297
|
+
}
|
|
298
|
+
function buildSource(field) {
|
|
299
|
+
if (isRadio(field) || isSelect(field) && !field.disabled) {
|
|
300
|
+
const source = field.source;
|
|
301
|
+
if (Array.isArray(source) || isObject(source) && !($REF in source)) {
|
|
302
|
+
return source;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// ../luna-core/src/util/date.ts
|
|
308
|
+
var REGEX_DIGITS = /^\d+$/;
|
|
309
|
+
function getMonth() {
|
|
310
|
+
return Array.from({ length: 12 }, (_, i) => ({
|
|
311
|
+
value: (i + 1).toString(),
|
|
312
|
+
label: new Date(0, i).toLocaleString("default", {
|
|
313
|
+
month: "long"
|
|
314
|
+
})
|
|
315
|
+
}));
|
|
316
|
+
}
|
|
317
|
+
function getYear(min, max) {
|
|
318
|
+
if (max >= min) {
|
|
319
|
+
return Array.from({ length: max - min + 1 }, (_, i) => {
|
|
320
|
+
const year = min + i;
|
|
321
|
+
return {
|
|
322
|
+
value: year.toString(),
|
|
323
|
+
label: year.toString()
|
|
324
|
+
};
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
return [];
|
|
328
|
+
}
|
|
329
|
+
function getCurrentYear() {
|
|
330
|
+
return (/* @__PURE__ */ new Date()).getFullYear();
|
|
331
|
+
}
|
|
332
|
+
function getConvert(value, current) {
|
|
333
|
+
if (typeof value === "number") {
|
|
334
|
+
return value;
|
|
335
|
+
}
|
|
336
|
+
const now2 = current ?? getCurrentYear();
|
|
337
|
+
const trimmed = value.trim().toLowerCase();
|
|
338
|
+
if (trimmed.startsWith("current")) {
|
|
339
|
+
const match = trimmed.match(/^current([+-])(\d+)$/);
|
|
340
|
+
if (match) {
|
|
341
|
+
const [, operator, offsetStr] = match;
|
|
342
|
+
const offset = parseInt(offsetStr, 10);
|
|
343
|
+
if (!isNaN(offset)) {
|
|
344
|
+
return operator === "+" ? now2 + offset : now2 - offset;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return now2;
|
|
348
|
+
}
|
|
349
|
+
if (REGEX_DIGITS.test(trimmed)) {
|
|
350
|
+
return parseInt(trimmed, 10);
|
|
351
|
+
}
|
|
352
|
+
return now2;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// ../luna-core/src/helper/input.ts
|
|
356
|
+
var now = getCurrentYear();
|
|
357
|
+
function buildOptionSelect(field) {
|
|
358
|
+
if (isSelect(field)) {
|
|
359
|
+
return defineOption(field);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function defineOption(select) {
|
|
363
|
+
if (isSelectMonth(select)) {
|
|
364
|
+
return getMonth();
|
|
365
|
+
}
|
|
366
|
+
if (isSelectYear(select)) {
|
|
367
|
+
const min = select.advanced?.length?.min ?? now;
|
|
368
|
+
const max = select.advanced?.length?.max ?? now + 5;
|
|
369
|
+
return getYear(getConvert(min, now), getConvert(max, now));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
function buildCommon(field, disabled = false) {
|
|
373
|
+
const commonProps = {
|
|
374
|
+
disabled,
|
|
375
|
+
id: field.name,
|
|
376
|
+
name: field.name,
|
|
377
|
+
placeholder: field.placeholder,
|
|
378
|
+
required: field.required
|
|
379
|
+
};
|
|
380
|
+
if (isInput(field)) {
|
|
381
|
+
return {
|
|
382
|
+
...commonProps,
|
|
383
|
+
...defineInput(field)
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
if (isSelect(field)) {
|
|
387
|
+
return {
|
|
388
|
+
...commonProps,
|
|
389
|
+
...defineSelect(field)
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
if (isTextArea(field)) {
|
|
393
|
+
return {
|
|
394
|
+
...commonProps,
|
|
395
|
+
...defineTextArea(field)
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
return commonProps;
|
|
399
|
+
}
|
|
400
|
+
function defineInput(input) {
|
|
401
|
+
const type = getType(input.type);
|
|
402
|
+
const copy = { ...input, type };
|
|
403
|
+
return {
|
|
404
|
+
...defineAutoComplete(input),
|
|
405
|
+
...defineNumberLimits(copy),
|
|
406
|
+
...isText(copy) ? defineLength(copy) : {},
|
|
407
|
+
type
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function defineSelect(field) {
|
|
411
|
+
const options = buildOptionSelect(field);
|
|
412
|
+
if (options) {
|
|
413
|
+
return { options };
|
|
414
|
+
}
|
|
415
|
+
return {};
|
|
416
|
+
}
|
|
417
|
+
function defineTextArea(field) {
|
|
418
|
+
return {
|
|
419
|
+
...defineAutoComplete(field),
|
|
420
|
+
...defineLength(field)
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
function defineAutoComplete(input) {
|
|
424
|
+
const autoComplete = input.advanced?.autocomplete;
|
|
425
|
+
if (autoComplete) {
|
|
426
|
+
return { autoComplete };
|
|
427
|
+
}
|
|
428
|
+
return {};
|
|
429
|
+
}
|
|
430
|
+
function defineNumberLimits(input) {
|
|
431
|
+
if (isNumber(input)) {
|
|
432
|
+
return defineMinMax(input);
|
|
433
|
+
}
|
|
434
|
+
return {};
|
|
435
|
+
}
|
|
436
|
+
function defineLength(input) {
|
|
437
|
+
return defineConstraints(input, { min: MIN_LENGTH, max: MAX_LENGTH });
|
|
438
|
+
}
|
|
439
|
+
function defineMinMax(input) {
|
|
440
|
+
return defineConstraints(input, { min: MIN, max: MAX });
|
|
441
|
+
}
|
|
442
|
+
function defineConstraints(input, keys) {
|
|
443
|
+
const result = {};
|
|
444
|
+
const length = input.advanced?.length;
|
|
445
|
+
if (length) {
|
|
446
|
+
if (length.min !== void 0) {
|
|
447
|
+
result[keys.min] = length.min;
|
|
448
|
+
}
|
|
449
|
+
if (length.max !== void 0) {
|
|
450
|
+
result[keys.max] = length.max;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return result;
|
|
454
|
+
}
|
|
455
|
+
function resolveSource(field, value) {
|
|
456
|
+
const current = buildSource(field);
|
|
457
|
+
if (current) {
|
|
458
|
+
return current;
|
|
459
|
+
}
|
|
460
|
+
return buildOptions(field, value);
|
|
461
|
+
}
|
|
462
|
+
function getInputValue(field, value) {
|
|
463
|
+
const newValue = isObject(value) && field.name in value ? value[field.name] : value;
|
|
464
|
+
return getCurrentValue(newValue, field.advanced?.entity);
|
|
465
|
+
}
|
|
466
|
+
function mergeOptionsProps(field, commonProps, options) {
|
|
467
|
+
return isOptions(field) && Array.isArray(options) ? { ...commonProps, [OPTIONS]: options } : commonProps;
|
|
468
|
+
}
|
|
469
|
+
function getPreselectedValue(field, commonProps, value) {
|
|
470
|
+
if (field.required && !isValidValue(value)) {
|
|
471
|
+
if (isSelect(field)) {
|
|
472
|
+
if (field.advanced?.preselected !== false && OPTIONS in commonProps) {
|
|
473
|
+
const options = commonProps[OPTIONS];
|
|
474
|
+
if (Array.isArray(options) && options.length === 1) {
|
|
475
|
+
return options[0];
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return value;
|
|
481
|
+
}
|
|
482
|
+
function getOptions(field, data) {
|
|
483
|
+
if (isSelect(field) && Array.isArray(data)) {
|
|
484
|
+
return toOptions(data, field.advanced?.options);
|
|
485
|
+
}
|
|
486
|
+
return data;
|
|
487
|
+
}
|
|
488
|
+
function prepareInputProps(field, commonProps, data, value) {
|
|
489
|
+
const currentValue = getInputValue(field, value);
|
|
490
|
+
const options = Array.isArray(data) ? getOptions(field, data) : data;
|
|
491
|
+
const commonPropsWithOptions = mergeOptionsProps(field, commonProps, options);
|
|
492
|
+
const defaultValue = getPreselectedValue(
|
|
493
|
+
field,
|
|
494
|
+
commonPropsWithOptions,
|
|
495
|
+
currentValue
|
|
496
|
+
);
|
|
497
|
+
return {
|
|
498
|
+
commonPropsWithOptions,
|
|
499
|
+
defaultValue
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function prepareDefaultValue(field, value) {
|
|
503
|
+
if (isCheckbox(field)) {
|
|
504
|
+
return {
|
|
505
|
+
defaultChecked: isValidValue(value)
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
return { defaultValue: value };
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// ../luna-core/src/util/prepare.ts
|
|
512
|
+
var REGEX_REF = /^#\/definition\//;
|
|
513
|
+
function prepare(base = [], definition) {
|
|
514
|
+
const resolved = resolveRefs(base, definition);
|
|
515
|
+
return Array.isArray(resolved) ? resolved.sort((a, b) => getOrder(a) - getOrder(b)) : [];
|
|
516
|
+
}
|
|
517
|
+
function resolveRefs(base, definition, cache = /* @__PURE__ */ new Map(), visited = /* @__PURE__ */ new WeakSet()) {
|
|
518
|
+
if (!isDefinition(definition) || !base || typeof base !== "object") {
|
|
519
|
+
return base;
|
|
520
|
+
}
|
|
521
|
+
if (cache.has(base)) {
|
|
522
|
+
return cache.get(base);
|
|
523
|
+
}
|
|
524
|
+
if (visited.has(base)) {
|
|
525
|
+
return base;
|
|
526
|
+
}
|
|
527
|
+
visited.add(base);
|
|
528
|
+
if (Array.isArray(base)) {
|
|
529
|
+
return base.map((item) => resolveRefs(item, definition, cache, visited));
|
|
530
|
+
}
|
|
531
|
+
if ($REF in base && isString(base[$REF])) {
|
|
532
|
+
const path = base[$REF].replace(REGEX_REF, "");
|
|
533
|
+
const resolved = extract(definition, path);
|
|
534
|
+
if (resolved !== null) {
|
|
535
|
+
return resolveRefs(resolved, definition, cache, visited);
|
|
536
|
+
}
|
|
537
|
+
return base;
|
|
538
|
+
}
|
|
539
|
+
const result = {};
|
|
540
|
+
for (const [key, value] of Object.entries(base)) {
|
|
541
|
+
result[key] = resolveRefs(value, definition, cache, visited);
|
|
542
|
+
}
|
|
543
|
+
visited.delete(base);
|
|
544
|
+
cache.set(base, result);
|
|
545
|
+
return result;
|
|
546
|
+
}
|
|
547
|
+
function entries(values) {
|
|
548
|
+
return Object.entries(values ?? {});
|
|
549
|
+
}
|
|
550
|
+
function getOrder(item) {
|
|
551
|
+
return item.order ?? Number.MAX_VALUE;
|
|
552
|
+
}
|
|
553
|
+
function isDefinition(definition) {
|
|
554
|
+
return definition !== void 0 && isObject(definition) && Object.keys(definition).length > 0;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// ../luna-core/src/util/attributes.ts
|
|
558
|
+
function getPrefixedAttributes(prefix, record) {
|
|
559
|
+
const attrs = {};
|
|
560
|
+
for (const [key, value] of entries(record)) {
|
|
561
|
+
attrs[`${prefix}-${key}`] = value;
|
|
562
|
+
}
|
|
563
|
+
return attrs;
|
|
564
|
+
}
|
|
565
|
+
function getAriaAttributes(record) {
|
|
566
|
+
return getPrefixedAttributes(PREFIX_ARIA, record);
|
|
567
|
+
}
|
|
568
|
+
function getDataAttributes(record) {
|
|
569
|
+
return getPrefixedAttributes(PREFIX_DATA, record);
|
|
570
|
+
}
|
|
571
|
+
function buildAriaAttributes(field, errors) {
|
|
572
|
+
const ariaAttributes = getAriaAttributes(field.advanced?.aria);
|
|
573
|
+
if (errors && errors.length > 0) {
|
|
574
|
+
ariaAttributes[ARIA_INVALID] = "true";
|
|
575
|
+
ariaAttributes[ARIA_ERROR_MESSAGE] = `${field.name}-error`;
|
|
576
|
+
}
|
|
577
|
+
return ariaAttributes;
|
|
578
|
+
}
|
|
579
|
+
function buildDataAttributes(field) {
|
|
580
|
+
return getDataAttributes(field.advanced?.data);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// ../luna-core/src/util/column.ts
|
|
584
|
+
var cols = {
|
|
585
|
+
1: "md:grid-cols-1",
|
|
586
|
+
2: "md:grid-cols-2",
|
|
587
|
+
3: "md:grid-cols-3"
|
|
588
|
+
};
|
|
589
|
+
var span = {
|
|
590
|
+
1: "md:col-span-1",
|
|
591
|
+
2: "md:col-span-2",
|
|
592
|
+
3: "md:col-span-3"
|
|
593
|
+
};
|
|
594
|
+
function getColumn(value, defaultCols = 2) {
|
|
595
|
+
return cols[value && value in cols ? value : defaultCols];
|
|
596
|
+
}
|
|
597
|
+
function getSpan(value) {
|
|
598
|
+
if (value && value in span) {
|
|
599
|
+
return span[value];
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// ../luna-core/src/util/translate.ts
|
|
604
|
+
function translate(key, dictionary) {
|
|
605
|
+
if (!key) {
|
|
606
|
+
return "";
|
|
607
|
+
}
|
|
608
|
+
if (!dictionary) {
|
|
609
|
+
return key;
|
|
610
|
+
}
|
|
611
|
+
return dictionary[key] ?? key;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// ../luna-core/src/util/style.ts
|
|
615
|
+
function mergeStyle(globalStyle, localStyle) {
|
|
616
|
+
return { ...globalStyle, ...localStyle };
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// src/lib/string.tsx
|
|
620
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
621
|
+
function formatMarkdown2(text) {
|
|
622
|
+
return formatMarkdown(
|
|
623
|
+
text,
|
|
624
|
+
(index, url, text2) => {
|
|
625
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
626
|
+
"a",
|
|
627
|
+
{
|
|
628
|
+
className: "underline",
|
|
629
|
+
href: url,
|
|
630
|
+
rel: "noopener noreferrer",
|
|
631
|
+
target: "_blank",
|
|
632
|
+
children: text2
|
|
633
|
+
},
|
|
634
|
+
`${url}-${index}`
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// src/component/legend.tsx
|
|
641
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
642
|
+
function Legend(props) {
|
|
643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
644
|
+
props.title && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { className: "mb-3 font-medium text-slate-800 dark:text-slate-200", children: formatMarkdown2(props.title) }),
|
|
645
|
+
props.description && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400", children: formatMarkdown2(props.description) })
|
|
646
|
+
] });
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// src/component/field/field-set.tsx
|
|
650
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
651
|
+
function FieldSet(props) {
|
|
652
|
+
const fields = props.section.fields || [];
|
|
653
|
+
const { compact } = mergeStyle(props.style, {
|
|
654
|
+
compact: props.section.compact
|
|
655
|
+
});
|
|
656
|
+
if (!props.section.title && !props.section.description) {
|
|
657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Group, { compact, children: props.children });
|
|
658
|
+
}
|
|
659
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
660
|
+
"fieldset",
|
|
661
|
+
{
|
|
662
|
+
"data-slot": "field-set",
|
|
663
|
+
"data-empty": fields.length === 0,
|
|
664
|
+
className: "flex flex-col data-[empty=false]:gap-6",
|
|
665
|
+
id: props.section.id?.toString(),
|
|
666
|
+
children: [
|
|
667
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
668
|
+
Legend,
|
|
669
|
+
{
|
|
670
|
+
description: props.section.description,
|
|
671
|
+
title: props.section.title
|
|
672
|
+
}
|
|
673
|
+
),
|
|
674
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Group, { compact, children: props.children })
|
|
675
|
+
]
|
|
676
|
+
}
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// src/component/form.tsx
|
|
681
|
+
var import_react = require("react");
|
|
682
|
+
|
|
683
|
+
// src/component/separator.tsx
|
|
684
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
685
|
+
function Separator() {
|
|
686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { "data-slot": "field-separator", className: "relative -my-2 h-5 text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800" }) });
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// src/component/form.tsx
|
|
690
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
691
|
+
function Form(props) {
|
|
692
|
+
const sections = prepare(props.sections, props.definition);
|
|
693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "h-full w-full", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("form", { noValidate: props.noValidate, action: props.action, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Group, { children: [
|
|
694
|
+
sections.map((section, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react.Fragment, { children: [
|
|
695
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FieldSet, { section, style: props.config.style, children: props.children({
|
|
696
|
+
disabled: props.readOnly,
|
|
697
|
+
fields: section.fields
|
|
698
|
+
}) }),
|
|
699
|
+
section.separator && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Separator, {})
|
|
700
|
+
] }, index)),
|
|
701
|
+
props.control && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Control, { isPending: props.isPending, children: props.control })
|
|
702
|
+
] }) }) });
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// src/component/description.tsx
|
|
706
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
707
|
+
function Description(props) {
|
|
708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400", children: props.children });
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// src/component/formatted-description.tsx
|
|
712
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
713
|
+
function FormattedDescription(props) {
|
|
714
|
+
const content = formatMarkdown2(props.text);
|
|
715
|
+
if (content) {
|
|
716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Description, { children: content });
|
|
717
|
+
}
|
|
718
|
+
return null;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// src/component/label.tsx
|
|
722
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
723
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
724
|
+
function Label(props) {
|
|
725
|
+
const showOptionalLabel = props.style?.showOptionalLabel ?? true;
|
|
726
|
+
const normal = isRadio(props.field) || isCheckbox(props.field);
|
|
727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
728
|
+
"label",
|
|
729
|
+
{
|
|
730
|
+
"data-slot": "field-label",
|
|
731
|
+
"data-normal": normal,
|
|
732
|
+
className: (0, import_tailwind_merge.twMerge)(
|
|
733
|
+
"flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",
|
|
734
|
+
"data-[normal=true]:font-normal",
|
|
735
|
+
"group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"
|
|
736
|
+
),
|
|
737
|
+
htmlFor: props.field.name,
|
|
738
|
+
children: [
|
|
739
|
+
props.children,
|
|
740
|
+
showOptionalLabel && !props.field.required && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-sm text-slate-600 dark:text-slate-400", children: translate("(Optional)", props.translations) })
|
|
741
|
+
]
|
|
742
|
+
}
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// src/component/input-label.tsx
|
|
747
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
748
|
+
function InputLabel(props) {
|
|
749
|
+
const label = isInterpolated(props.field.label) ? interpolate(props.field.label, {
|
|
750
|
+
context: props.context,
|
|
751
|
+
env: props.config?.env
|
|
752
|
+
}) : props.field.label;
|
|
753
|
+
const description = isInterpolated(props.field.description) ? interpolate(props.field.description, {
|
|
754
|
+
context: props.context,
|
|
755
|
+
env: props.config?.env
|
|
756
|
+
}) : props.field.description;
|
|
757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
758
|
+
"div",
|
|
759
|
+
{
|
|
760
|
+
"data-slot": "field-content",
|
|
761
|
+
className: "flex w-full flex-1 flex-col gap-1.5 leading-snug",
|
|
762
|
+
children: [
|
|
763
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
764
|
+
Label,
|
|
765
|
+
{
|
|
766
|
+
field: props.field,
|
|
767
|
+
style: props.config?.style,
|
|
768
|
+
translations: props.translations,
|
|
769
|
+
children: translate(label, props.translations)
|
|
770
|
+
}
|
|
771
|
+
),
|
|
772
|
+
props.orientation === HORIZONTAL && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
773
|
+
FormattedDescription,
|
|
774
|
+
{
|
|
775
|
+
text: translate(description, props.translations)
|
|
776
|
+
}
|
|
777
|
+
)
|
|
778
|
+
]
|
|
779
|
+
}
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// src/component/input-group.tsx
|
|
784
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
785
|
+
function InputGroup(props) {
|
|
786
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
787
|
+
props.field.name && props.field.label && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
788
|
+
InputLabel,
|
|
789
|
+
{
|
|
790
|
+
config: props.config,
|
|
791
|
+
context: props.context,
|
|
792
|
+
field: props.field,
|
|
793
|
+
orientation: props.orientation,
|
|
794
|
+
translations: props.translations
|
|
795
|
+
}
|
|
796
|
+
),
|
|
797
|
+
props.children,
|
|
798
|
+
props.orientation === VERTICAL && props.field.description && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
799
|
+
FormattedDescription,
|
|
800
|
+
{
|
|
801
|
+
text: translate(props.field.description, props.translations)
|
|
802
|
+
}
|
|
803
|
+
)
|
|
804
|
+
] });
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// src/lib/render-If-exists.ts
|
|
808
|
+
function renderIfExists(value, render) {
|
|
809
|
+
if (!value) {
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
return render(value);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// src/server/component/input.tsx
|
|
816
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
817
|
+
function Input(props) {
|
|
818
|
+
const source = resolveSource(props.field, props.value);
|
|
819
|
+
const { commonPropsWithOptions, defaultValue } = prepareInputProps(
|
|
820
|
+
props.field,
|
|
821
|
+
props.commonProps,
|
|
822
|
+
source,
|
|
823
|
+
props.value
|
|
824
|
+
);
|
|
825
|
+
const defaultProps = prepareDefaultValue(props.field, defaultValue);
|
|
826
|
+
return renderIfExists(props.config.inputs[props.field.type], (Component) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
827
|
+
InputGroup,
|
|
828
|
+
{
|
|
829
|
+
config: props.config,
|
|
830
|
+
context: props.context,
|
|
831
|
+
field: props.field,
|
|
832
|
+
orientation: props.orientation,
|
|
833
|
+
translations: props.translations,
|
|
834
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
835
|
+
Component,
|
|
836
|
+
{
|
|
837
|
+
...props.ariaAttributes,
|
|
838
|
+
...commonPropsWithOptions,
|
|
839
|
+
...props.dataAttributes,
|
|
840
|
+
...defaultProps
|
|
841
|
+
}
|
|
842
|
+
)
|
|
843
|
+
}
|
|
844
|
+
));
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// src/component/field/field-error.tsx
|
|
848
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
849
|
+
function FieldError(props) {
|
|
850
|
+
if (!props.errors || props.errors.length === 0) {
|
|
851
|
+
return null;
|
|
852
|
+
}
|
|
853
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
854
|
+
"ul",
|
|
855
|
+
{
|
|
856
|
+
className: "text-sm text-red-600 dark:text-red-500",
|
|
857
|
+
id: props.name ? `${props.name}-error` : void 0,
|
|
858
|
+
children: props.errors?.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("li", { children: error }, props.name ? `${props.name}-error-${index}` : index))
|
|
859
|
+
}
|
|
860
|
+
);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// src/component/field/field-base.tsx
|
|
864
|
+
var import_tailwind_merge2 = require("tailwind-merge");
|
|
865
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
866
|
+
function FieldBase(props) {
|
|
867
|
+
const errors = props.errors && props.errors.length > 0;
|
|
868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
869
|
+
"div",
|
|
870
|
+
{
|
|
871
|
+
"data-slot": "field",
|
|
872
|
+
"data-clickable": props.isClickable ? "true" : "false",
|
|
873
|
+
...errors && { [DATA_INVALID]: "true" },
|
|
874
|
+
...props.disabled && { [DATA_READONLY]: "true" },
|
|
875
|
+
"data-orientation": props.orientation,
|
|
876
|
+
className: (0, import_tailwind_merge2.twMerge)(
|
|
877
|
+
"group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500",
|
|
878
|
+
"data-[clickable=true]:items-start",
|
|
879
|
+
props.isCheckbox && (props.isReversed ? "flex-row-reverse!" : "flex-row!"),
|
|
880
|
+
"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",
|
|
881
|
+
props.className
|
|
882
|
+
),
|
|
883
|
+
children: props.children
|
|
884
|
+
}
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// src/component/field/field-vertical.tsx
|
|
889
|
+
var import_tailwind_merge3 = require("tailwind-merge");
|
|
890
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
891
|
+
function FieldVertical(props) {
|
|
892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
893
|
+
FieldBase,
|
|
894
|
+
{
|
|
895
|
+
...props,
|
|
896
|
+
orientation: VERTICAL,
|
|
897
|
+
className: (0, import_tailwind_merge3.twMerge)(
|
|
898
|
+
"gap-3 has-[>[data-slot=field-content]]:items-start",
|
|
899
|
+
!props.isClickable && "[&>*]:w-full"
|
|
900
|
+
),
|
|
901
|
+
children: props.children
|
|
902
|
+
}
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// src/component/field/field-horizontal.tsx
|
|
907
|
+
var import_tailwind_merge4 = require("tailwind-merge");
|
|
908
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
909
|
+
function FieldHorizontal(props) {
|
|
910
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
911
|
+
FieldBase,
|
|
912
|
+
{
|
|
913
|
+
...props,
|
|
914
|
+
orientation: HORIZONTAL,
|
|
915
|
+
className: (0, import_tailwind_merge4.twMerge)(
|
|
916
|
+
"gap-2 md:flex-row md:gap-4",
|
|
917
|
+
"[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start",
|
|
918
|
+
"[&_[role=checkbox]]:mt-[1.5px]",
|
|
919
|
+
props.isClickable && "md:flex-col",
|
|
920
|
+
!props.isClickable && [
|
|
921
|
+
"md:justify-between",
|
|
922
|
+
"[&>*:not([data-slot=field-content])]:w-full",
|
|
923
|
+
"[&>*:not([data-slot=field-content])]:md:w-1/2",
|
|
924
|
+
"[&>*:not([data-slot=field-content])]:xl:w-2/5"
|
|
925
|
+
]
|
|
926
|
+
),
|
|
927
|
+
children: props.children
|
|
928
|
+
}
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// src/component/field/field-group.tsx
|
|
933
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
934
|
+
function FieldGroup(props) {
|
|
935
|
+
const clickable = isClickable(props.field);
|
|
936
|
+
const checkbox = isCheckbox(props.field);
|
|
937
|
+
const reversed = buildReverse(props.field);
|
|
938
|
+
if (props.orientation === VERTICAL) {
|
|
939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
940
|
+
FieldVertical,
|
|
941
|
+
{
|
|
942
|
+
disabled: props.disabled,
|
|
943
|
+
errors: props.errors,
|
|
944
|
+
isCheckbox: checkbox,
|
|
945
|
+
isReversed: reversed,
|
|
946
|
+
isClickable: clickable,
|
|
947
|
+
children: props.children
|
|
948
|
+
}
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
952
|
+
FieldHorizontal,
|
|
953
|
+
{
|
|
954
|
+
disabled: props.disabled,
|
|
955
|
+
errors: props.errors,
|
|
956
|
+
isCheckbox: checkbox,
|
|
957
|
+
isReversed: reversed,
|
|
958
|
+
isClickable: clickable,
|
|
959
|
+
children: props.children
|
|
960
|
+
}
|
|
961
|
+
);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// src/component/input/input-base.tsx
|
|
965
|
+
function InputBase(props) {
|
|
966
|
+
if (!props.field.type) {
|
|
967
|
+
return null;
|
|
968
|
+
}
|
|
969
|
+
const commonProps = buildCommon(props.field, props.disabled);
|
|
970
|
+
const dataAttributes = buildDataAttributes(props.field);
|
|
971
|
+
const ariaAttributes = buildAriaAttributes(props.field, props.errors);
|
|
972
|
+
const field = {
|
|
973
|
+
...props.field,
|
|
974
|
+
disabled: commonProps.disabled
|
|
975
|
+
};
|
|
976
|
+
return props.children({
|
|
977
|
+
ariaAttributes,
|
|
978
|
+
commonProps,
|
|
979
|
+
dataAttributes,
|
|
980
|
+
field,
|
|
981
|
+
orientation: props.orientation
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// src/component/field/field.tsx
|
|
986
|
+
var import_tailwind_merge5 = require("tailwind-merge");
|
|
987
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
988
|
+
function Field(props) {
|
|
989
|
+
const cols2 = props.field.advanced?.cols;
|
|
990
|
+
const errors = props.field.name ? props.errors?.[props.field.name] : void 0;
|
|
991
|
+
const { orientation } = mergeStyle(props.style, {
|
|
992
|
+
orientation: buildOrientation(props.field)
|
|
993
|
+
});
|
|
994
|
+
const disabled = buildDisabled(props.field, props.disabled);
|
|
995
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: (0, import_tailwind_merge5.twMerge)("flex flex-col gap-3", getSpan(cols2)), children: [
|
|
996
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
997
|
+
FieldGroup,
|
|
998
|
+
{
|
|
999
|
+
disabled,
|
|
1000
|
+
errors,
|
|
1001
|
+
field: props.field,
|
|
1002
|
+
orientation,
|
|
1003
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1004
|
+
InputBase,
|
|
1005
|
+
{
|
|
1006
|
+
disabled,
|
|
1007
|
+
errors,
|
|
1008
|
+
field: props.field,
|
|
1009
|
+
orientation,
|
|
1010
|
+
children: props.children
|
|
1011
|
+
}
|
|
1012
|
+
)
|
|
1013
|
+
}
|
|
1014
|
+
),
|
|
1015
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FieldError, { errors, name: props.field.name })
|
|
1016
|
+
] });
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// src/component/column.tsx
|
|
1020
|
+
var import_tailwind_merge6 = require("tailwind-merge");
|
|
1021
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1022
|
+
function Column(props) {
|
|
1023
|
+
const cols2 = getColumn(props.column?.advanced?.cols);
|
|
1024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex w-full flex-col gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: (0, import_tailwind_merge6.twMerge)("grid grid-cols-1 gap-3 sm:gap-4", cols2), children: props.children }) });
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// src/component/slot/slot-base.tsx
|
|
1028
|
+
var import_react2 = require("react");
|
|
1029
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1030
|
+
function SlotBase(props) {
|
|
1031
|
+
const { column: Column2, field: Field2 } = props.components;
|
|
1032
|
+
return prepare(props.fields).map((field, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_react2.Fragment, { children: [
|
|
1033
|
+
isColumn(field) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Column2, { column: field, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotBase, { ...props, fields: field.fields }) }),
|
|
1034
|
+
isField(field) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Field2, { disabled: props.disabled, field, style: props.style, children: props.children })
|
|
1035
|
+
] }, index));
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// src/component/slot/slot-create.tsx
|
|
1039
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1040
|
+
function createSlot(Field2) {
|
|
1041
|
+
const CreateSlot = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotBase, { ...props, components: { column: Column, field: Field2 } });
|
|
1042
|
+
return CreateSlot;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// src/component/slot/slot.tsx
|
|
1046
|
+
var Slot = createSlot(Field);
|
|
1047
|
+
|
|
1048
|
+
// src/server/component/form.tsx
|
|
1049
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1050
|
+
function Form2(props) {
|
|
1051
|
+
const translations = props.translations?.[props.lang ?? ""];
|
|
1052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1053
|
+
Form,
|
|
1054
|
+
{
|
|
1055
|
+
config: props.config,
|
|
1056
|
+
control: props.children,
|
|
1057
|
+
definition: props.definition,
|
|
1058
|
+
readOnly: props.readOnly,
|
|
1059
|
+
sections: props.sections,
|
|
1060
|
+
children: ({ disabled, fields }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Slot, { disabled, fields, style: props.config.style, children: (internal) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1061
|
+
Input,
|
|
1062
|
+
{
|
|
1063
|
+
...internal,
|
|
1064
|
+
config: props.config,
|
|
1065
|
+
context: props.context,
|
|
1066
|
+
translations,
|
|
1067
|
+
value: props.value
|
|
1068
|
+
}
|
|
1069
|
+
) })
|
|
1070
|
+
}
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
// src/server/component/fallback.tsx
|
|
1075
|
+
var import_react3 = require("react");
|
|
1076
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1077
|
+
function Fallback(props) {
|
|
1078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1079
|
+
import_react3.Suspense,
|
|
1080
|
+
{
|
|
1081
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Form2, { config: props.config, sections: props.sections, readOnly: true }),
|
|
1082
|
+
children: props.children
|
|
1083
|
+
}
|
|
1084
|
+
);
|
|
1085
|
+
}
|