react-luna-form 0.0.38 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/cjs/index.js +1 -1
- package/dist/client/esm/index.js +1 -1
- package/dist/config/cjs/index.js +1 -1
- package/dist/config/esm/index.js +1 -1
- package/dist/server/cjs/index.js +1 -1
- package/dist/server/esm/index.js +1 -1
- package/dist/types/luna-react/src/client/component/input-date.d.ts +16 -0
- package/dist/types/luna-react/src/client/hook/use-format.d.ts +5 -0
- package/package.json +3 -3
- package/dist/types/luna-core/src/fetcher.d.ts +0 -2
- package/dist/types/luna-core/src/handle/proxy-event.d.ts +0 -6
- package/dist/types/luna-core/src/handle/source-event.d.ts +0 -2
- package/dist/types/luna-core/src/handle/state-event.d.ts +0 -2
- package/dist/types/luna-core/src/handle/value-event.d.ts +0 -2
- package/dist/types/luna-core/src/helper/input.d.ts +0 -54
- package/dist/types/luna-core/src/index.d.ts +0 -24
- package/dist/types/luna-core/src/type.d.ts +0 -214
- package/dist/types/luna-core/src/util/attributes.d.ts +0 -6
- package/dist/types/luna-core/src/util/build.d.ts +0 -6
- package/dist/types/luna-core/src/util/column.d.ts +0 -2
- package/dist/types/luna-core/src/util/constant.d.ts +0 -51
- package/dist/types/luna-core/src/util/date.d.ts +0 -20
- package/dist/types/luna-core/src/util/extract.d.ts +0 -16
- package/dist/types/luna-core/src/util/is-input.d.ts +0 -24
- package/dist/types/luna-core/src/util/is-type.d.ts +0 -7
- package/dist/types/luna-core/src/util/list.d.ts +0 -4
- package/dist/types/luna-core/src/util/logger.d.ts +0 -5
- package/dist/types/luna-core/src/util/operator.d.ts +0 -1
- package/dist/types/luna-core/src/util/prepare.d.ts +0 -4
- package/dist/types/luna-core/src/util/schema.d.ts +0 -14
- package/dist/types/luna-core/src/util/source.d.ts +0 -2
- package/dist/types/luna-core/src/util/string.d.ts +0 -8
- package/dist/types/luna-core/src/util/stringify.d.ts +0 -1
- package/dist/types/luna-core/src/util/style.d.ts +0 -6
- package/dist/types/luna-core/src/util/translate.d.ts +0 -1
- package/dist/types/luna-core/src/util/url.d.ts +0 -10
package/dist/server/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as kn}from"react/jsx-runtime";function ge(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return kn("div",{"data-slot":"field-control",className:"w-full",children:t})}import{Activity as fr,useCallback as mr,useState as pr}from"react";import{jsx as ye}from"react/jsx-runtime";function xe(e){return ye("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:ye("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 P="input",be="input/email",Te="input/number";var he="input/time";var Re="textarea",Se="radio",Ae="checkbox",K="list";var Fe="select",Ce="select/day",Ne="select/month",Ie="select/timezone",Ee="select/year";var ve="chips",ke="chips/day",Le="chips/month",F="column",Pe="description",W="fields",we="label",q="value",w="options",J="email",Oe="number",De="password",Me="tel",C="text",_e="aria-errormessage",Ve="aria-invalid",ze="data-invalid",He="data-readonly",Ge="aria",$e="data",Be="max",Ue="maxLength",Ye="min",Xe="minLength",h="$ref";var Ze="type",Ke={Africa:"Africa",America:"Americas",Asia:"Asia / Pacific",Atlantic:"Atlantic",Australia:"Asia / Pacific",Europe:"Europe",Indian:"Asia / Pacific",Pacific:"Asia / Pacific"};function s(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function m(e){return f(e)||typeof e=="number"||Ln(e)}function f(e){return typeof e=="string"}function Ln(e){return typeof e=="boolean"}function We(e,t=q){if(e!=null){if(Array.isArray(e)&&e.every(m)||m(e))return e;if(s(e)){let n=Pn(e,t);if(m(n))return n}}}function Pn(e,t){let n=p(e,t);if(m(n))return n}function p(e,t){if(!t||!s(e))return null;let n=t.split(".").filter(o=>o!=="");if(n.length===0)return null;let r=e;for(let o of n)if(s(r)&&o in r)r=r[o];else return null;return r}function qe(e,t={description:Pe,label:we,value:q}){return e.map(n=>{if(s(n)){let r=p(n,t.label),o=p(n,t.value);if(m(r)&&m(o)){let i=p(n,t.description);return{label:`${r}`,value:`${o}`,...m(i)&&{description:`${i}`}}}}return n})}function Je(e=C){let t=e.lastIndexOf("/"),n=t===-1?e:e.slice(t+1);return n&&n!==P?n.trim().toLowerCase():C}var wn=/\[([^\]]{1,500})\]\(([^)]{1,2000})\)/g;function Q(e,t={}){if(f(e))return On(e,t);if(Array.isArray(e))return e.map(n=>Q(n,t));if(s(e)){let n={};for(let r in e)n[r]=Q(e[r],t);return n}return e}function O(e,t={}){return j(e)?Q(e,t):e}function j(e){return f(e)?/{([^}]{1,200})}/.test(e):Array.isArray(e)?e.some(t=>j(t)):s(e)?Object.values(e).some(t=>j(t)):!1}function On(e,t={}){return e.replace(/{([^}]{1,200})}/g,(n,r)=>{let o=r.includes(".")?p(t,r):t[r];return m(o)?String(o):n})}function Qe(e,t){if(!f(e)||!e||e.trim().length===0)return null;let n,r=0,o=!1,i=[];for(;(n=wn.exec(e))!==null;){let[l,c,d]=n,u=n.index;o=!0,u>r&&i.push(e.substring(r,u));let A=t?t(u,d,c):l;i.push(A),r=u+l.length}return o?(r<e.length&&i.push(e.substring(r)),i):e}var je=e=>a(Ce)(e),et=e=>a(Ne)(e),tt=e=>a(Ee)(e),nt=e=>a(Ie)(e),rt=e=>a(ke)(e),ot=e=>a(Le)(e),g=a(Ae),ee=a(ve),it=a(P),b=a(Se),y=a(Fe),lt=a(Re),te=a(he),at=a(C,J,De,Me),xo=a(be,J),st=a(Te,Oe);function ct(e){return b(e)||g(e)}function dt(e){return e.type===K}function R(e){return e.type===F}function D(e){return e.type!==F&&e.type!==K}function ne(e){return y(e)||b(e)}function M(e){return e!=null&&e!==""}function a(...e){return t=>{let n=f(t.type)?t.type:void 0;return n?e.some(r=>n===r||n?.startsWith(`${r}/`)):!1}}function ut(e,t={}){if(y(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&s(n))return[n]}}function ft(e){return b(e)||g(e)?!0:e.advanced?.horizontal??!1}function mt(e){return g(e)?e.advanced?.reverse!==!1:!1}function pt(e,t){let n=e.readonly??!1;return t||n}function gt(e){if(b(e)||y(e)&&!e.disabled){let t=e.source;if(Array.isArray(t)||s(t)&&!(h in t))return t}}import{isValid as Dn,parse as Mn,format as _n}from"date-fns";var Vn=/^\d+$/,zn=new Date(2e3,0,1),Hn=()=>"supportedValuesOf"in Intl?Intl.supportedValuesOf("timeZone"):[];function re(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function oe(){return Array.from({length:7},(e,t)=>({value:t.toString(),label:new Date(2e3,0,2+t).toLocaleString("default",{weekday:"long"})}))}function bt(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 ie(){return new Date().getFullYear()}function Gn(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function $n(e){let t=e.indexOf("/"),n=t===-1?e:e.slice(0,t);return Ke[n]??"Other"}function Bn(e,t){return(e.find(r=>r.type==="timeZoneName")?.value??t).replace(/\s+(?:Standard|Daylight(?: Saving)?|Summer|Winter)\s+Time$/,"")}function yt(e,t){let n=new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(t),r=new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"long"}).formatToParts(t),i=(n.find(c=>c.type==="timeZoneName")?.value??"GMT+00:00").replace("GMT","UTC"),l=Bn(r,e);return{offset:i,longName:l}}function xt(e){return e.slice(e.lastIndexOf("/")+1).replace(/_/g," ")}var _=null;function Tt(){if(_)return _;let e=new Date,t=Gn(),n=new Map,r=xt(t),{offset:o,longName:i}=yt(t,e),l={value:t,label:`${r} - ${i} (${o})`};for(let d of Hn()){if(d===t)continue;let u=xt(d),{offset:A,longName:vn}=yt(d,e),me={value:d,label:`${u} - ${vn} (${A})`},Z=$n(d);if(Z==="Other")continue;let pe=n.get(Z);pe?pe.push(me):n.set(Z,[me])}for(let d of n.values())d.sort((u,A)=>u.label.localeCompare(A.label));let c=Array.from(n.entries()).sort(([d],[u])=>d.localeCompare(u)).map(([d,u])=>({label:d,items:u}));return _=[{label:"Suggested",items:[l]},...c],_}function le(e,t){if(typeof e=="number")return e;let n=t??ie(),r=e.trim().toLowerCase();if(r.startsWith("current")){let o=r.match(/^current([+-])(\d+)$/);if(o){let[,i,l]=o,c=parseInt(l,10);if(!isNaN(c))return i==="+"?n+c:n-c}return n}return Vn.test(r)?parseInt(r,10):n}function ht(e,t){if(!e)return"";try{let n=Mn(e,t,zn);return Dn(n)?_n(n,"HH:mm:ss"):""}catch{return""}}function ae(e){return e.advanced?.format??"HH:mm"}var V=ie();function Un(e){if(ee(e))return Yn(e)}function Yn(e){if(rt(e))return oe();if(ot(e))return re()}function Xn(e){if(y(e))return Zn(e)}function Zn(e){if(je(e))return oe();if(et(e))return re();if(tt(e)){let t=e.advanced?.length?.min??V,n=e.advanced?.length?.max??V+5;return bt(le(t,V),le(n,V))}if(nt(e))return Tt()}function Rt(e,t=!1){let n={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return it(e)?{...n,...Kn(e)}:y(e)?{...n,...St(e,Xn)}:lt(e)?{...n,...qn(e)}:ee(e)?{...n,...Wn(e)}:n}function Kn(e){let t=Je(e.type),n={...e,type:t};return{...Qn(e),...At(e),...Jn(n),...at(n)?Ft(n):{},type:t}}function St(e,t){let n=t(e);return n?{options:n}:{}}function Wn(e){let t=St(e,Un),n=e.advanced?.multiple??!0;return{...t,multiple:n}}function qn(e){return{...At(e),...Ft(e)}}function At(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function Jn(e){return st(e)?jn(e):{}}function Qn(e){if(te(e)){let t=ae(e);return{step:t==="HH:mm:ss"||t==="hh:mm:ss a"?"1":"60"}}return{}}function Ft(e){return Ct(e,{min:Xe,max:Ue})}function jn(e){return Ct(e,{min:Ye,max:Be})}function Ct(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 Nt(e,t){let n=gt(e);return n||ut(e,t)}function er(e,t){let n=s(t)&&e.name in t?t[e.name]:t,r=We(n,e.advanced?.entity);return te(e)&&M(r)?tr(e,r):r}function tr(e,t){let n=ae(e);return f(t)?ht(t,n):t}function nr(e,t,n){return ne(e)&&Array.isArray(n)?{...t,[w]:n}:t}function rr(e,t,n){if(e.required&&!M(n)&&y(e)&&e.advanced?.preselected!==!1&&w in t){let r=t[w];if(Array.isArray(r)&&r.length===1)return r[0]}return n}function or(e,t){return ne(e)&&Array.isArray(t)?qe(t,e.advanced?.options):t}function It(e,t,n,r){let o=er(e,r),i=Array.isArray(n)?or(e,n):n,l=nr(e,t,i),c=rr(e,l,o);return{commonPropsWithOptions:l,defaultValue:c}}function Et(e,t){return g(e)?{defaultChecked:M(t)}:{defaultValue:t}}var ir=/^#\/definition\//;function H(e=[],t){let n=z(e,t);return Array.isArray(n)?n.filter(ar).sort((r,o)=>vt(r)-vt(o)):[]}function z(e,t,n=new Map,r=new WeakSet){if(!lr(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=>z(i,t,n,r));if(h in e&&f(e[h])){let i=e[h].replace(ir,""),l=p(t,i);return l!==null?z(l,t,n,r):e}let o={};for(let[i,l]of Object.entries(e))o[i]=z(l,t,n,r);return r.delete(e),n.set(e,o),o}function kt(e){return Object.entries(e??{})}function vt(e){return e.order??Number.MAX_VALUE}function lr(e){return e!==void 0&&s(e)&&Object.keys(e).length>0}function ar(e){return Ze in e?!0:Array.isArray(e[W])?e[W].length>0:!0}function Lt(e,t){let n={};for(let[r,o]of kt(t))n[`${e}-${r}`]=o;return n}function sr(e){return Lt(Ge,e)}function cr(e){return Lt($e,e)}function Pt(e,t){let n=sr(e.advanced?.aria);return t&&t.length>0&&(n[Ve]="true",n[_e]=`${e.name}-error`),n}function wt(e){return cr(e.advanced?.data)}var Ot={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},Dt={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function Mt(e,t=2){return Ot[e&&e in Ot?e:t]}function _t(e){if(e&&e in Dt)return Dt[e]}function dr(e,t){let n=e.advanced?.length?.min??1;if(t){let r=p(t,e.name);if(Array.isArray(r))return Math.max(r.length,n)}return Math.max(n,0)}function Vt(e){return!Array.isArray(e.fields)||e.fields.length===0?!1:e.fields.length>1||e.fields[0].type===F}function zt(e,t){let n=dr(e,t);return Array.from({length:n},(r,o)=>o)}function Ht(e){return e.label??e.name}function S(e,t){return e?t?t[e]??e:e:""}function G(e,t){return{...e,...t}}import{jsx as ur}from"react/jsx-runtime";function x(e){return Qe(e,(t,n,r)=>ur("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:r},`${n}-${t}`))}import{jsx as N,jsxs as se}from"react/jsx-runtime";function Gt(e){let{fields:t=[]}=e.section,[n,r]=pr(!1),o=mr(()=>r(i=>!i),[]);return se("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:[N("legend",{children:se("button",{className:"flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",onClick:o,type:"button",children:[N(xe,{expanded:n}),N("span",{children:x(e.section.title)})]})}),N(fr,{mode:n?"visible":"hidden",children:se("div",{className:"mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-slate-300 pl-4 dark:border-slate-600","data-slot":"field-set-content",children:[e.section.description&&N("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:x(e.section.description)}),e.group]})})]})}import{Fragment as gr,jsx as $t,jsxs as yr}from"react/jsx-runtime";function Bt(e){return yr(gr,{children:[e.title&&$t("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:x(e.title)}),e.description&&$t("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:x(e.description)})]})}import{jsx as xr,jsxs as br}from"react/jsx-runtime";function $(e){return br("fieldset",{"data-slot":"field-set","data-empty":e.empty,className:"flex flex-col data-[empty=false]:gap-6",id:e.id,children:[xr(Bt,{description:e.description,title:e.title}),e.children]})}import{jsx as Tr}from"react/jsx-runtime";function T(e){return Tr("div",{"data-slot":"field-group","data-compact":e.compact,className:"flex w-full flex-col gap-8 data-[compact=true]:gap-3",children:e.children})}import{jsx as ce}from"react/jsx-runtime";function Ut(e){let{fields:t=[]}=e.section,{compact:n}=G(e.style,{compact:e.section.compact}),r=ce(T,{compact:n,children:e.children});return!e.section.title&&!e.section.description?r:e.section.advanced?ce(Gt,{section:e.section,group:r}):ce($,{description:e.section.description,empty:t.length===0,id:e.section.id?.toString(),title:e.section.title,children:r})}import{useAtomValue as Nr}from"jotai";import{atom as I}from"jotai";import{atomFamily as hr}from"jotai-family";import{deepEqual as Yt}from"fast-equals";function Rr(e,t){let{[t]:n,...r}=e;return r}function Sr(e){return hr(t=>I(n=>n(e)[t]??void 0,(n,r,o)=>{let i=n(e);if(o!=null){let l=i[t];Yt(l,o)||r(e,{...i,[t]:o})}else t in i&&r(e,Rr(i,t))}))}function Ar(e){return I(null,(t,n)=>{let r=t(e);r&&Object.keys(r).length>0&&n(e,{})})}function Fr(e){return I(null,(t,n,r)=>{let i={...t(e)},l=!1;for(let c of r)c in i&&(delete i[c],l=!0);l&&n(e,i)})}function Cr(e){return I(null,(t,n,r)=>{let o=t(e);Yt(o,r)||n(e,r)})}function Xt(e={}){let t=I(e);return{atom:t,clearAll:Ar(t),clear:Fr(t),bulkReport:Cr(t),report:Sr(t)}}var Zt=Xt(),Kt=Zt.atom,Ti=Zt.report;function Ir(e,t){return e.fields.every(n=>Wt(n,t))}function Wt(e,t){return t[e.name]?.hidden??e.hidden??!1}function Er(e,t){return R(e)?Ir(e,t):Wt(e,t)}function qt(e){let t=Nr(Kt);return e.container&&(t[e.container.name]?.hidden??e.container.hidden??!1)||e.fields.length===0||e.fields.every(r=>Er(r,t))?null:e.children}import{jsx as Jt}from"react/jsx-runtime";function Qt(){return Jt("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:Jt("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}import{jsx as E,jsxs as jt}from"react/jsx-runtime";function en(e){let t=H(e.sections,e.definition);return E("div",{className:"h-full w-full",children:E("form",{noValidate:e.noValidate,action:e.action,children:jt(T,{children:[t.map((n,r)=>jt(qt,{fields:n.fields??[],children:[E(Ut,{section:n,style:e.config.style,children:e.children({disabled:e.readOnly,fields:n.fields})}),n.separator&&E(Qt,{})]},r)),e.control&&E(ge,{isPending:e.isPending,children:e.control})]})})})}import{jsx as vr}from"react/jsx-runtime";function B(e){return vr("p",{className:"-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}import{jsx as kr}from"react/jsx-runtime";function U(e){let t={context:e.context,env:e.config?.env},n=S(O(e.text,t),e.translations),r=x(n);return r?kr(B,{children:r}):null}import{twMerge as Lr}from"tailwind-merge";import{jsx as Pr,jsxs as wr}from"react/jsx-runtime";function tn(e){let t=e.style?.showOptionalLabel??!0,n=b(e.field)||g(e.field);return wr("label",{"data-slot":"field-label","data-normal":n,className:Lr("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&&Pr("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:S("(Optional)",e.translations)})]})}import{jsx as nn,jsxs as Or}from"react/jsx-runtime";function rn(e){let t={context:e.context,env:e.config?.env},n=O(e.field.label,t);return Or("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[nn(tn,{field:e.field,style:e.config?.style,translations:e.translations,children:S(n,e.translations)}),e.horizontal===!0&&nn(U,{config:e.config,context:e.context,text:e.field.description,translations:e.translations})]})}import{Fragment as Dr,jsx as on,jsxs as Mr}from"react/jsx-runtime";function ln(e){return Mr(Dr,{children:[e.field.name&&e.field.label&&on(rn,{config:e.config,context:e.context,field:e.field,horizontal:e.horizontal,translations:e.translations}),e.children,e.horizontal===!1&&on(U,{config:e.config,context:e.context,text:e.field.description,translations:e.translations})]})}function an(e,t){return e?t(e):null}import{jsx as sn}from"react/jsx-runtime";function cn(e){let t=Nt(e.field,e.value),{commonPropsWithOptions:n,defaultValue:r}=It(e.field,e.commonProps,t,e.value),o=Et(e.field,r);return an(e.config.inputs[e.field.type],i=>sn(ln,{config:e.config,context:e.context,field:e.field,horizontal:e.horizontal,translations:e.translations,children:sn(i,{...e.ariaAttributes,...n,...e.dataAttributes,...o})}))}import{jsx as dn}from"react/jsx-runtime";function un(e){return!e.errors||e.errors.length===0?null:dn("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)=>dn("li",{children:t},e.name?`${e.name}-error-${n}`:n))})}import{twMerge as _r}from"tailwind-merge";import{jsx as Vr}from"react/jsx-runtime";function Y(e){let t=e.errors&&e.errors.length>0;return Vr("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[ze]:"true"},...e.disabled&&{[He]:"true"},"data-orientation":e.orientation,className:_r("group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500","data-[clickable=true]:items-start",e.isCheckbox&&(e.isReversed?"flex-row-reverse!":"flex-row!"),"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",e.className),children:e.children})}import{twMerge as zr}from"tailwind-merge";import{jsx as Hr}from"react/jsx-runtime";function fn(e){return Hr(Y,{...e,orientation:"vertical",className:zr("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}import{twMerge as Gr}from"tailwind-merge";import{jsx as $r}from"react/jsx-runtime";function mn(e){return $r(Y,{...e,orientation:"horizontal",className:Gr("gap-2 md:flex-row md:gap-4","[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start","[&_[role=checkbox]]:mt-[1.5px]",e.isClickable&&"md:flex-col",!e.isClickable&&["md:justify-between","[&>*:not([data-slot=field-content])]:w-full","[&>*:not([data-slot=field-content])]:md:w-1/2","[&>*:not([data-slot=field-content])]:xl:w-2/5"]),children:e.children})}import{jsx as pn}from"react/jsx-runtime";function gn(e){let t=ct(e.field),n=g(e.field),r=mt(e.field);return e.horizontal?pn(mn,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children}):pn(fn,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children})}function yn(e){if(!e.field.type)return null;let t=Rt(e.field,e.disabled),n=wt(e.field),r=Pt(e.field,e.errors),o={...e.field,disabled:t.disabled};return e.children({ariaAttributes:r,commonProps:t,dataAttributes:n,field:o,horizontal:e.horizontal})}import{twMerge as Br}from"tailwind-merge";import{jsx as de,jsxs as Ur}from"react/jsx-runtime";function xn(e){let t=e.field.advanced?.cols,n=e.field.name?e.errors?.[e.field.name]:void 0,{horizontal:r}=G(e.style,{horizontal:ft(e.field)}),o=pt(e.field,e.disabled);return Ur("div",{className:Br("flex flex-col gap-3",_t(t)),children:[de(gn,{disabled:o,errors:n,field:e.field,horizontal:r,children:de(yn,{disabled:o,errors:n,field:e.field,horizontal:r,children:e.children})}),de(un,{errors:n,name:e.field.name})]})}import{twMerge as Yr}from"tailwind-merge";import{jsx as v,jsxs as X}from"react/jsx-runtime";function bn(e){function t(){e.canRemove&&e.onRemove&&e.onRemove(e.index)}let n=e.canRemove&&e.onRemove!=null&&v("button",{"aria-label":`Remove ${e.label} item ${e.index+1}`,className:Yr("rounded p-1 text-xl text-slate-400","transition-colors duration-150","hover:text-red-500","focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:outline-none","dark:text-slate-500 dark:hover:text-red-400"),onClick:t,type:"button",children:v("span",{"aria-hidden":"true",children:"\xD7"})});return e.isMultiField?X("div",{className:"rounded-lg border border-slate-100 p-4 dark:border-slate-900",children:[X("div",{className:"mb-3 flex items-center justify-between",children:[X("span",{className:"text-sm font-medium text-slate-400 dark:text-slate-500",children:[e.label," ",e.index+1]}),n]}),v(T,{children:e.children})]}):X("div",{className:"flex items-start gap-2",children:[v(T,{children:e.children}),n&&v("div",{className:"shrink-0",children:n})]})}import{jsx as Xr}from"react/jsx-runtime";function Tn(e){let t=Ht(e.field),n=Vt(e.field);return zt(e.field,e.value).map(r=>Xr(bn,{index:r,isMultiField:n,label:t,children:e.children(r)},r))}import{jsx as Zr}from"react/jsx-runtime";function hn(e){let t=Array.isArray(e.field.fields)&&e.field.fields.length===0;return Zr($,{description:e.field.description,empty:t,id:e.field.name,title:e.field.label,children:e.children})}import{jsx as Rn}from"react/jsx-runtime";function Sn({children:e,field:t,value:n}){return Rn(hn,{field:t,children:Rn(Tn,{field:t,value:n,children:e})})}import{twMerge as Kr}from"tailwind-merge";import{jsx as An,jsxs as Wr}from"react/jsx-runtime";function Fn(e){let t=Mt(e.column?.advanced?.cols);return Wr("div",{className:"flex w-full flex-col gap-4",children:[An("div",{className:Kr("grid grid-cols-1 gap-3 sm:gap-4",t),children:e.children}),e.column?.description&&An(B,{children:e.column.description})]})}import{Fragment as Jr}from"react";import{jsx as qr}from"react/jsx-runtime";function Cn(e){let t=Array.isArray(e.field.fields)?e.field.fields.map(n=>D(n)?{...n,name:`${e.field.name}.${e.index}.${n.name}`}:R(n)?{...n,fields:n.fields.map(r=>({...r,name:`${e.field.name}.${e.index}.${r.name}`}))}:n):[];return qr(k,{children:e.children,components:e.components,disabled:e.disabled,fields:t,style:e.style,value:e.value})}import{jsx as L,jsxs as Qr}from"react/jsx-runtime";function k(e){let{field:t,list:n}=e.components;return H(e.fields).map((r,o)=>Qr(Jr,{children:[R(r)&&L(Fn,{column:r,children:L(k,{...e,fields:r.fields})}),D(r)&&L(t,{disabled:e.disabled,field:r,style:e.style,children:e.children}),dt(r)&&L(n,{field:r,value:e.value,children:i=>L(Cn,{children:e.children,components:e.components,disabled:e.disabled,field:r,index:i,style:e.style,value:e.value})})]},o))}import{jsx as jr}from"react/jsx-runtime";function Nn(e){return n=>jr(k,{...n,components:e})}var In=Nn({field:xn,list:Sn});import{jsx as ue}from"react/jsx-runtime";function fe(e){let t=e.translations?.[e.lang??""];return ue(en,{config:e.config,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,children:({disabled:n,fields:r})=>ue(In,{disabled:n,fields:r,style:e.config.style,children:o=>ue(cn,{...o,config:e.config,context:e.context,translations:t,value:e.value})})})}import{Suspense as eo}from"react";import{jsx as En}from"react/jsx-runtime";function to(e){return En(eo,{fallback:En(fe,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}export{to as Fallback,fe as Form};
|
|
1
|
+
import{jsx as Vn}from"react/jsx-runtime";function ge(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return Vn("div",{"data-slot":"field-control",className:"w-full",children:t})}import{Activity as xr,useCallback as br,useState as Tr}from"react";import{jsx as ye}from"react/jsx-runtime";function xe(e){return ye("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:ye("path",{fillRule:"evenodd",d:"M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"})})}var D="input",be="input/date",Te="input/email",he="input/number";var Re="input/time";var Fe="textarea",Se="radio",Ae="checkbox",K="list";var Ne="select",Ce="select/day",Ie="select/month",Ee="select/timezone",ve="select/year";var ke="chips",Le="chips/day",Pe="chips/month",A="column",De="description",W="fields",we="label",q="value",w="options",J="email",Oe="number",Me="password",_e="tel",N="text",Ve="aria-errormessage",ze="aria-invalid",He="data-invalid",Ge="data-readonly",$e="aria",Be="data",Ue="max",Ye="maxLength",Xe="min",Ze="minLength",h="$ref";var Ke="type",We={Africa:"Africa",America:"Americas",Asia:"Asia / Pacific",Atlantic:"Atlantic",Australia:"Asia / Pacific",Europe:"Europe",Indian:"Asia / Pacific",Pacific:"Asia / Pacific"};function s(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function m(e){return f(e)||typeof e=="number"||zn(e)}function f(e){return typeof e=="string"}function zn(e){return typeof e=="boolean"}function qe(e,t=q){if(e!=null){if(Array.isArray(e)&&e.every(m)||m(e))return e;if(s(e)){let n=Hn(e,t);if(m(n))return n}}}function Hn(e,t){let n=p(e,t);if(m(n))return n}function p(e,t){if(!t||!s(e))return null;let n=t.split(".").filter(o=>o!=="");if(n.length===0)return null;let r=e;for(let o of n)if(s(r)&&o in r)r=r[o];else return null;return r}function Je(e,t={description:De,label:we,value:q}){return e.map(n=>{if(s(n)){let r=p(n,t.label),o=p(n,t.value);if(m(r)&&m(o)){let i=p(n,t.description);return{label:`${r}`,value:`${o}`,...m(i)&&{description:`${i}`}}}}return n})}function Qe(e=N){let t=e.lastIndexOf("/"),n=t===-1?e:e.slice(t+1);return n&&n!==D?n.trim().toLowerCase():N}var Gn=/\[([^\]]{1,500})\]\(([^)]{1,2000})\)/g;function Q(e,t={}){if(f(e))return $n(e,t);if(Array.isArray(e))return e.map(n=>Q(n,t));if(s(e)){let n={};for(let r in e)n[r]=Q(e[r],t);return n}return e}function O(e,t={}){return j(e)?Q(e,t):e}function j(e){return f(e)?/{([^}]{1,200})}/.test(e):Array.isArray(e)?e.some(t=>j(t)):s(e)?Object.values(e).some(t=>j(t)):!1}function $n(e,t={}){return e.replace(/{([^}]{1,200})}/g,(n,r)=>{let o=r.includes(".")?p(t,r):t[r];return m(o)?String(o):n})}function je(e,t){if(!f(e)||!e||e.trim().length===0)return null;let n,r=0,o=!1,i=[];for(;(n=Gn.exec(e))!==null;){let[l,c,d]=n,u=n.index;o=!0,u>r&&i.push(e.substring(r,u));let S=t?t(u,d,c):l;i.push(S),r=u+l.length}return o?(r<e.length&&i.push(e.substring(r)),i):e}var et=e=>a(Ce)(e),tt=e=>a(Ie)(e),nt=e=>a(ve)(e),rt=e=>a(Ee)(e),ot=e=>a(Le)(e),it=e=>a(Pe)(e),lt=a(be),ee=a(Re),g=a(Ae),te=a(ke),b=a(Se),at=a(D),y=a(Ne),st=a(Fe),ct=a(N,J,Me,_e),Fo=a(Te,J),dt=a(he,Oe);function ut(e){return b(e)||g(e)}function ft(e){return e.type===K}function R(e){return e.type===A}function M(e){return e.type!==A&&e.type!==K}function ne(e){return y(e)||b(e)}function C(e){return e!=null&&e!==""}function a(...e){return t=>{let n=f(t.type)?t.type:void 0;return n?e.some(r=>n===r||n?.startsWith(`${r}/`)):!1}}function mt(e,t={}){if(y(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&s(n))return[n]}}function pt(e){return b(e)||g(e)?!0:e.advanced?.horizontal??!1}function gt(e){return g(e)?e.advanced?.reverse!==!1:!1}function yt(e,t){let n=e.readonly??!1;return t||n}function xt(e){if(b(e)||y(e)&&!e.disabled){let t=e.source;if(Array.isArray(t)||s(t)&&!(h in t))return t}}import{isValid as ht,parse as Rt,format as Ft}from"date-fns";var Bn=/^\d+$/,St=new Date(2e3,0,1),Un=()=>"supportedValuesOf"in Intl?Intl.supportedValuesOf("timeZone"):[];function re(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function oe(){return Array.from({length:7},(e,t)=>({value:t.toString(),label:new Date(2e3,0,2+t).toLocaleString("default",{weekday:"long"})}))}function At(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 ie(){return new Date().getFullYear()}function Yn(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function Xn(e){let t=e.indexOf("/"),n=t===-1?e:e.slice(0,t);return We[n]??"Other"}function Zn(e,t){return(e.find(r=>r.type==="timeZoneName")?.value??t).replace(/\s+(?:Standard|Daylight(?: Saving)?|Summer|Winter)\s+Time$/,"")}function bt(e,t){let n=new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(t),r=new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"long"}).formatToParts(t),i=(n.find(c=>c.type==="timeZoneName")?.value??"GMT+00:00").replace("GMT","UTC"),l=Zn(r,e);return{offset:i,longName:l}}function Tt(e){return e.slice(e.lastIndexOf("/")+1).replace(/_/g," ")}var _=null;function Nt(){if(_)return _;let e=new Date,t=Yn(),n=new Map,r=Tt(t),{offset:o,longName:i}=bt(t,e),l={value:t,label:`${r} - ${i} (${o})`};for(let d of Un()){if(d===t)continue;let u=Tt(d),{offset:S,longName:_n}=bt(d,e),me={value:d,label:`${u} - ${_n} (${S})`},Z=Xn(d);if(Z==="Other")continue;let pe=n.get(Z);pe?pe.push(me):n.set(Z,[me])}for(let d of n.values())d.sort((u,S)=>u.label.localeCompare(S.label));let c=Array.from(n.entries()).sort(([d],[u])=>d.localeCompare(u)).map(([d,u])=>({label:d,items:u}));return _=[{label:"Suggested",items:[l]},...c],_}function le(e,t){if(typeof e=="number")return e;let n=t??ie(),r=e.trim().toLowerCase();if(r.startsWith("current")){let o=r.match(/^current([+-])(\d+)$/);if(o){let[,i,l]=o,c=parseInt(l,10);if(!isNaN(c))return i==="+"?n+c:n-c}return n}return Bn.test(r)?parseInt(r,10):n}function Ct(e,t){if(!e)return"";try{let n=Rt(e,t,St);return ht(n)?Ft(n,"yyyy-MM-dd"):""}catch{return""}}function It(e,t){if(!e)return"";try{let n=Rt(e,t,St);return ht(n)?Ft(n,"HH:mm:ss"):""}catch{return""}}function ae(e){return e.advanced?.format??"HH:mm"}function Et(e){return e.advanced?.format??"yyyy-MM-dd"}var V=ie();function Kn(e){if(te(e))return Wn(e)}function Wn(e){if(ot(e))return oe();if(it(e))return re()}function qn(e){if(y(e))return Jn(e)}function Jn(e){if(et(e))return oe();if(tt(e))return re();if(nt(e)){let t=e.advanced?.length?.min??V,n=e.advanced?.length?.max??V+5;return At(le(t,V),le(n,V))}if(rt(e))return Nt()}function vt(e,t=!1){let n={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return at(e)?{...n,...Qn(e)}:y(e)?{...n,...kt(e,qn)}:st(e)?{...n,...er(e)}:te(e)?{...n,...jn(e)}:n}function Qn(e){let t=Qe(e.type),n={...e,type:t};return{...nr(e),...Lt(e),...tr(n),...ct(n)?Pt(n):{},type:t}}function kt(e,t){let n=t(e);return n?{options:n}:{}}function jn(e){let t=kt(e,Kn),n=e.advanced?.multiple??!0;return{...t,multiple:n}}function er(e){return{...Lt(e),...Pt(e)}}function Lt(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function tr(e){return dt(e)?rr(e):{}}function nr(e){if(ee(e)){let t=ae(e);return{step:t==="HH:mm:ss"||t==="hh:mm:ss a"?"1":"60"}}return{}}function Pt(e){return Dt(e,{min:Ze,max:Ye})}function rr(e){return Dt(e,{min:Xe,max:Ue})}function Dt(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 wt(e,t){let n=xt(e);return n||mt(e,t)}function or(e,t){let n=s(t)&&e.name in t?t[e.name]:t,r=qe(n,e.advanced?.entity);return ee(e)&&C(r)?ir(e,r):lt(e)&&C(r)?cr(e,r):r}function ir(e,t){let n=ae(e);return f(t)?It(t,n):t}function lr(e,t,n){return ne(e)&&Array.isArray(n)?{...t,[w]:n}:t}function ar(e,t,n){if(e.required&&!C(n)&&y(e)&&e.advanced?.preselected!==!1&&w in t){let r=t[w];if(Array.isArray(r)&&r.length===1)return r[0]}return n}function sr(e,t){return ne(e)&&Array.isArray(t)?Je(t,e.advanced?.options):t}function Ot(e,t,n,r){let o=or(e,r),i=Array.isArray(n)?sr(e,n):n,l=lr(e,t,i),c=ar(e,l,o);return{commonPropsWithOptions:l,defaultValue:c}}function Mt(e,t){return g(e)?{defaultChecked:C(t)}:{defaultValue:t}}function cr(e,t){let n=Et(e);return f(t)?Ct(t,n):t}var dr=/^#\/definition\//;function H(e=[],t){let n=z(e,t);return Array.isArray(n)?n.filter(fr).sort((r,o)=>_t(r)-_t(o)):[]}function z(e,t,n=new Map,r=new WeakSet){if(!ur(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=>z(i,t,n,r));if(h in e&&f(e[h])){let i=e[h].replace(dr,""),l=p(t,i);return l!==null?z(l,t,n,r):e}let o={};for(let[i,l]of Object.entries(e))o[i]=z(l,t,n,r);return r.delete(e),n.set(e,o),o}function Vt(e){return Object.entries(e??{})}function _t(e){return e.order??Number.MAX_VALUE}function ur(e){return e!==void 0&&s(e)&&Object.keys(e).length>0}function fr(e){return Ke in e?!0:Array.isArray(e[W])?e[W].length>0:!0}function zt(e,t){let n={};for(let[r,o]of Vt(t))n[`${e}-${r}`]=o;return n}function mr(e){return zt($e,e)}function pr(e){return zt(Be,e)}function Ht(e,t){let n=mr(e.advanced?.aria);return t&&t.length>0&&(n[ze]="true",n[Ve]=`${e.name}-error`),n}function Gt(e){return pr(e.advanced?.data)}var $t={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},Bt={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function Ut(e,t=2){return $t[e&&e in $t?e:t]}function Yt(e){if(e&&e in Bt)return Bt[e]}function gr(e,t){let n=e.advanced?.length?.min??1;if(t){let r=p(t,e.name);if(Array.isArray(r))return Math.max(r.length,n)}return Math.max(n,0)}function Xt(e){return!Array.isArray(e.fields)||e.fields.length===0?!1:e.fields.length>1||e.fields[0].type===A}function Zt(e,t){let n=gr(e,t);return Array.from({length:n},(r,o)=>o)}function Kt(e){return e.label??e.name}function F(e,t){return e?t?t[e]??e:e:""}function G(e,t){return{...e,...t}}import{jsx as yr}from"react/jsx-runtime";function x(e){return je(e,(t,n,r)=>yr("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:r},`${n}-${t}`))}import{jsx as I,jsxs as se}from"react/jsx-runtime";function Wt(e){let{fields:t=[]}=e.section,[n,r]=Tr(!1),o=br(()=>r(i=>!i),[]);return se("fieldset",{"data-slot":"field-set","data-advanced":"true","data-expanded":n,"data-empty":t.length===0,className:"flex flex-col",id:e.section.id?.toString(),children:[I("legend",{children:se("button",{className:"flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",onClick:o,type:"button",children:[I(xe,{expanded:n}),I("span",{children:x(e.section.title)})]})}),I(xr,{mode:n?"visible":"hidden",children:se("div",{className:"mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-slate-300 pl-4 dark:border-slate-600","data-slot":"field-set-content",children:[e.section.description&&I("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:x(e.section.description)}),e.group]})})]})}import{Fragment as hr,jsx as qt,jsxs as Rr}from"react/jsx-runtime";function Jt(e){return Rr(hr,{children:[e.title&&qt("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:x(e.title)}),e.description&&qt("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:x(e.description)})]})}import{jsx as Fr,jsxs as Sr}from"react/jsx-runtime";function $(e){return Sr("fieldset",{"data-slot":"field-set","data-empty":e.empty,className:"flex flex-col data-[empty=false]:gap-6",id:e.id,children:[Fr(Jt,{description:e.description,title:e.title}),e.children]})}import{jsx as Ar}from"react/jsx-runtime";function T(e){return Ar("div",{"data-slot":"field-group","data-compact":e.compact,className:"flex w-full flex-col gap-8 data-[compact=true]:gap-3",children:e.children})}import{jsx as ce}from"react/jsx-runtime";function Qt(e){let{fields:t=[]}=e.section,{compact:n}=G(e.style,{compact:e.section.compact}),r=ce(T,{compact:n,children:e.children});return!e.section.title&&!e.section.description?r:e.section.advanced?ce(Wt,{section:e.section,group:r}):ce($,{description:e.section.description,empty:t.length===0,id:e.section.id?.toString(),title:e.section.title,children:r})}import{useAtomValue as Lr}from"jotai";import{atom as E}from"jotai";import{atomFamily as Nr}from"jotai-family";import{deepEqual as jt}from"fast-equals";function Cr(e,t){let{[t]:n,...r}=e;return r}function Ir(e){return Nr(t=>E(n=>n(e)[t]??void 0,(n,r,o)=>{let i=n(e);if(o!=null){let l=i[t];jt(l,o)||r(e,{...i,[t]:o})}else t in i&&r(e,Cr(i,t))}))}function Er(e){return E(null,(t,n)=>{let r=t(e);r&&Object.keys(r).length>0&&n(e,{})})}function vr(e){return E(null,(t,n,r)=>{let i={...t(e)},l=!1;for(let c of r)c in i&&(delete i[c],l=!0);l&&n(e,i)})}function kr(e){return E(null,(t,n,r)=>{let o=t(e);jt(o,r)||n(e,r)})}function en(e={}){let t=E(e);return{atom:t,clearAll:Er(t),clear:vr(t),bulkReport:kr(t),report:Ir(t)}}var tn=en(),nn=tn.atom,Ai=tn.report;function Pr(e,t){return e.fields.every(n=>rn(n,t))}function rn(e,t){return t[e.name]?.hidden??e.hidden??!1}function Dr(e,t){return R(e)?Pr(e,t):rn(e,t)}function on(e){let t=Lr(nn);return e.container&&(t[e.container.name]?.hidden??e.container.hidden??!1)||e.fields.length===0||e.fields.every(r=>Dr(r,t))?null:e.children}import{jsx as ln}from"react/jsx-runtime";function an(){return ln("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:ln("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}import{jsx as v,jsxs as sn}from"react/jsx-runtime";function cn(e){let t=H(e.sections,e.definition);return v("div",{className:"h-full w-full",children:v("form",{noValidate:e.noValidate,action:e.action,children:sn(T,{children:[t.map((n,r)=>sn(on,{fields:n.fields??[],children:[v(Qt,{section:n,style:e.config.style,children:e.children({disabled:e.readOnly,fields:n.fields})}),n.separator&&v(an,{})]},r)),e.control&&v(ge,{isPending:e.isPending,children:e.control})]})})})}import{jsx as wr}from"react/jsx-runtime";function B(e){return wr("p",{className:"-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}import{jsx as Or}from"react/jsx-runtime";function U(e){let t={context:e.context,env:e.config?.env},n=F(O(e.text,t),e.translations),r=x(n);return r?Or(B,{children:r}):null}import{twMerge as Mr}from"tailwind-merge";import{jsx as _r,jsxs as Vr}from"react/jsx-runtime";function dn(e){let t=e.style?.showOptionalLabel??!0,n=b(e.field)||g(e.field);return Vr("label",{"data-slot":"field-label","data-normal":n,className:Mr("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&&_r("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:F("(Optional)",e.translations)})]})}import{jsx as un,jsxs as zr}from"react/jsx-runtime";function fn(e){let t={context:e.context,env:e.config?.env},n=O(e.field.label,t);return zr("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[un(dn,{field:e.field,style:e.config?.style,translations:e.translations,children:F(n,e.translations)}),e.horizontal===!0&&un(U,{config:e.config,context:e.context,text:e.field.description,translations:e.translations})]})}import{Fragment as Hr,jsx as mn,jsxs as Gr}from"react/jsx-runtime";function pn(e){return Gr(Hr,{children:[e.field.name&&e.field.label&&mn(fn,{config:e.config,context:e.context,field:e.field,horizontal:e.horizontal,translations:e.translations}),e.children,e.horizontal===!1&&mn(U,{config:e.config,context:e.context,text:e.field.description,translations:e.translations})]})}function gn(e,t){return e?t(e):null}import{jsx as yn}from"react/jsx-runtime";function xn(e){let t=wt(e.field,e.value),{commonPropsWithOptions:n,defaultValue:r}=Ot(e.field,e.commonProps,t,e.value),o=Mt(e.field,r);return gn(e.config.inputs[e.field.type],i=>yn(pn,{config:e.config,context:e.context,field:e.field,horizontal:e.horizontal,translations:e.translations,children:yn(i,{...e.ariaAttributes,...n,...e.dataAttributes,...o})}))}import{jsx as bn}from"react/jsx-runtime";function Tn(e){return!e.errors||e.errors.length===0?null:bn("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)=>bn("li",{children:t},e.name?`${e.name}-error-${n}`:n))})}import{twMerge as $r}from"tailwind-merge";import{jsx as Br}from"react/jsx-runtime";function Y(e){let t=e.errors&&e.errors.length>0;return Br("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[He]:"true"},...e.disabled&&{[Ge]:"true"},"data-orientation":e.orientation,className:$r("group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500","data-[clickable=true]:items-start",e.isCheckbox&&(e.isReversed?"flex-row-reverse!":"flex-row!"),"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",e.className),children:e.children})}import{twMerge as Ur}from"tailwind-merge";import{jsx as Yr}from"react/jsx-runtime";function hn(e){return Yr(Y,{...e,orientation:"vertical",className:Ur("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}import{twMerge as Xr}from"tailwind-merge";import{jsx as Zr}from"react/jsx-runtime";function Rn(e){return Zr(Y,{...e,orientation:"horizontal",className:Xr("gap-2 md:flex-row md:gap-4","[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start","[&_[role=checkbox]]:mt-[1.5px]",e.isClickable&&"md:flex-col",!e.isClickable&&["md:justify-between","[&>*:not([data-slot=field-content])]:w-full","[&>*:not([data-slot=field-content])]:md:w-1/2","[&>*:not([data-slot=field-content])]:xl:w-2/5"]),children:e.children})}import{jsx as Fn}from"react/jsx-runtime";function Sn(e){let t=ut(e.field),n=g(e.field),r=gt(e.field);return e.horizontal?Fn(Rn,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children}):Fn(hn,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children})}function An(e){if(!e.field.type)return null;let t=vt(e.field,e.disabled),n=Gt(e.field),r=Ht(e.field,e.errors),o={...e.field,disabled:t.disabled};return e.children({ariaAttributes:r,commonProps:t,dataAttributes:n,field:o,horizontal:e.horizontal})}import{twMerge as Kr}from"tailwind-merge";import{jsx as de,jsxs as Wr}from"react/jsx-runtime";function Nn(e){let t=e.field.advanced?.cols,n=e.field.name?e.errors?.[e.field.name]:void 0,{horizontal:r}=G(e.style,{horizontal:pt(e.field)}),o=yt(e.field,e.disabled);return Wr("div",{className:Kr("flex flex-col gap-3",Yt(t)),children:[de(Sn,{disabled:o,errors:n,field:e.field,horizontal:r,children:de(An,{disabled:o,errors:n,field:e.field,horizontal:r,children:e.children})}),de(Tn,{errors:n,name:e.field.name})]})}import{twMerge as qr}from"tailwind-merge";import{jsx as k,jsxs as X}from"react/jsx-runtime";function Cn(e){function t(){e.canRemove&&e.onRemove&&e.onRemove(e.index)}let n=e.canRemove&&e.onRemove!=null&&k("button",{"aria-label":`Remove ${e.label} item ${e.index+1}`,className:qr("rounded p-1 text-xl text-slate-400","transition-colors duration-150","hover:text-red-500","focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:outline-none","dark:text-slate-500 dark:hover:text-red-400"),onClick:t,type:"button",children:k("span",{"aria-hidden":"true",children:"\xD7"})});return e.isMultiField?X("div",{className:"rounded-lg border border-slate-100 p-4 dark:border-slate-900",children:[X("div",{className:"mb-3 flex items-center justify-between",children:[X("span",{className:"text-sm font-medium text-slate-400 dark:text-slate-500",children:[e.label," ",e.index+1]}),n]}),k(T,{children:e.children})]}):X("div",{className:"flex items-start gap-2",children:[k(T,{children:e.children}),n&&k("div",{className:"shrink-0",children:n})]})}import{jsx as Jr}from"react/jsx-runtime";function In(e){let t=Kt(e.field),n=Xt(e.field);return Zt(e.field,e.value).map(r=>Jr(Cn,{index:r,isMultiField:n,label:t,children:e.children(r)},r))}import{jsx as Qr}from"react/jsx-runtime";function En(e){let t=Array.isArray(e.field.fields)&&e.field.fields.length===0;return Qr($,{description:e.field.description,empty:t,id:e.field.name,title:e.field.label,children:e.children})}import{jsx as vn}from"react/jsx-runtime";function kn({children:e,field:t,value:n}){return vn(En,{field:t,children:vn(In,{field:t,value:n,children:e})})}import{twMerge as jr}from"tailwind-merge";import{jsx as Ln,jsxs as eo}from"react/jsx-runtime";function Pn(e){let t=Ut(e.column?.advanced?.cols);return eo("div",{className:"flex w-full flex-col gap-4",children:[Ln("div",{className:jr("grid grid-cols-1 gap-3 sm:gap-4",t),children:e.children}),e.column?.description&&Ln(B,{children:e.column.description})]})}import{Fragment as no}from"react";import{jsx as to}from"react/jsx-runtime";function Dn(e){let t=Array.isArray(e.field.fields)?e.field.fields.map(n=>M(n)?{...n,name:`${e.field.name}.${e.index}.${n.name}`}:R(n)?{...n,fields:n.fields.map(r=>({...r,name:`${e.field.name}.${e.index}.${r.name}`}))}:n):[];return to(L,{children:e.children,components:e.components,disabled:e.disabled,fields:t,style:e.style,value:e.value})}import{jsx as P,jsxs as ro}from"react/jsx-runtime";function L(e){let{field:t,list:n}=e.components;return H(e.fields).map((r,o)=>ro(no,{children:[R(r)&&P(Pn,{column:r,children:P(L,{...e,fields:r.fields})}),M(r)&&P(t,{disabled:e.disabled,field:r,style:e.style,children:e.children}),ft(r)&&P(n,{field:r,value:e.value,children:i=>P(Dn,{children:e.children,components:e.components,disabled:e.disabled,field:r,index:i,style:e.style,value:e.value})})]},o))}import{jsx as oo}from"react/jsx-runtime";function wn(e){return n=>oo(L,{...n,components:e})}var On=wn({field:Nn,list:kn});import{jsx as ue}from"react/jsx-runtime";function fe(e){let t=e.translations?.[e.lang??""];return ue(cn,{config:e.config,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,children:({disabled:n,fields:r})=>ue(On,{disabled:n,fields:r,style:e.config.style,children:o=>ue(xn,{...o,config:e.config,context:e.context,translations:t,value:e.value})})})}import{Suspense as io}from"react";import{jsx as Mn}from"react/jsx-runtime";function lo(e){return Mn(io,{fallback:Mn(fe,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}export{lo as Fallback,fe as Form};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AriaAttributes, type CommonProps, type DataAttributes, type Field, type Nullable, type Schema } from '@luna-form/core';
|
|
2
|
+
import type { Config, InputChange } from '../../type';
|
|
3
|
+
export declare function InputDate(props: Readonly<{
|
|
4
|
+
ariaAttributes?: AriaAttributes;
|
|
5
|
+
commonProps: CommonProps;
|
|
6
|
+
config: Config;
|
|
7
|
+
context?: Record<string, unknown>;
|
|
8
|
+
dataAttributes?: DataAttributes;
|
|
9
|
+
field: Field;
|
|
10
|
+
horizontal?: boolean;
|
|
11
|
+
onMount: (name: string, schema: Schema, field: Field) => void;
|
|
12
|
+
onUnmount: (name: string) => void;
|
|
13
|
+
onValueChange?: (input: InputChange) => void;
|
|
14
|
+
translations?: Record<string, string>;
|
|
15
|
+
value?: Nullable<Record<string, unknown>>;
|
|
16
|
+
}>): import("react").ReactNode;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-luna-form",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"description": "A React library for building forms based on JSON",
|
|
5
5
|
"main": "./dist/client/cjs/index.js",
|
|
6
6
|
"module": "./dist/client/esm/index.js",
|
|
7
|
-
"types": "./dist/types/client/index.d.ts",
|
|
7
|
+
"types": "./dist/types/luna-react/src/client/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"eslint-plugin-react": "7.37.5",
|
|
35
35
|
"eslint-plugin-react-hooks": "7.0.1",
|
|
36
36
|
"eslint-plugin-react-refresh": "0.5.2",
|
|
37
|
-
"@luna-form/core": "0.0.
|
|
37
|
+
"@luna-form/core": "0.0.39"
|
|
38
38
|
},
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"repository": {
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ChangeEvent, SourceEvent, StateEvent, ValueEvent } from '../type';
|
|
2
|
-
export declare function handleProxyEvent(events: ChangeEvent | undefined, callback: (props: {
|
|
3
|
-
sources: SourceEvent[];
|
|
4
|
-
states: StateEvent[];
|
|
5
|
-
values: ValueEvent[];
|
|
6
|
-
}) => void): void;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { CommonProps, DataSource, Field, Nullable, Value } from '../type';
|
|
2
|
-
export declare function buildOptionChips(field: Field): {
|
|
3
|
-
value: string;
|
|
4
|
-
label: string;
|
|
5
|
-
}[] | undefined;
|
|
6
|
-
export declare function buildOptionSelect(field: Field): {
|
|
7
|
-
value: string;
|
|
8
|
-
label: string;
|
|
9
|
-
}[] | import("..").TimezoneGroup[] | undefined;
|
|
10
|
-
export declare function buildCommon(field: Field, disabled?: boolean): CommonProps;
|
|
11
|
-
export declare function resolveSource(field: Field, value?: Nullable<Record<string, unknown>>): DataSource | unknown[] | undefined;
|
|
12
|
-
export declare function getInputValue<K>(field: Field, value?: Nullable<K>): Value | undefined;
|
|
13
|
-
export declare function mergeOptionsProps(field: Field, commonProps: CommonProps, options?: Nullable<DataSource | unknown[]>): CommonProps | {
|
|
14
|
-
options: unknown[];
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
id?: string;
|
|
17
|
-
name?: string;
|
|
18
|
-
placeholder?: string;
|
|
19
|
-
required?: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare function getPreselectedValue(field: Field, commonProps: CommonProps, value?: Value): any;
|
|
22
|
-
export declare function getOptions<T>(field: Field, data?: Nullable<T[]>): (T | {
|
|
23
|
-
description?: string | undefined;
|
|
24
|
-
label: string;
|
|
25
|
-
value: string;
|
|
26
|
-
})[] | null | undefined;
|
|
27
|
-
export declare function prepareInputProps<T, K>(field: Field, commonProps: CommonProps, data?: Nullable<DataSource | T[]>, value?: Nullable<K>): {
|
|
28
|
-
commonPropsWithOptions: CommonProps | {
|
|
29
|
-
options: unknown[];
|
|
30
|
-
disabled?: boolean;
|
|
31
|
-
id?: string;
|
|
32
|
-
name?: string;
|
|
33
|
-
placeholder?: string;
|
|
34
|
-
required?: boolean;
|
|
35
|
-
};
|
|
36
|
-
defaultValue: any;
|
|
37
|
-
};
|
|
38
|
-
export declare function prepareInputValue<T>(field: Field, value?: Nullable<T>): {
|
|
39
|
-
checked: boolean | Nullable<T> | undefined;
|
|
40
|
-
value?: undefined;
|
|
41
|
-
} | {
|
|
42
|
-
value: never[] | (T & any[]);
|
|
43
|
-
checked?: undefined;
|
|
44
|
-
} | {
|
|
45
|
-
value: string | NonNullable<T>;
|
|
46
|
-
checked?: undefined;
|
|
47
|
-
};
|
|
48
|
-
export declare function prepareDefaultValue<T>(field: Field, value?: Nullable<T>): {
|
|
49
|
-
defaultChecked: boolean;
|
|
50
|
-
defaultValue?: undefined;
|
|
51
|
-
} | {
|
|
52
|
-
defaultValue: Nullable<T> | undefined;
|
|
53
|
-
defaultChecked?: undefined;
|
|
54
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export * from './fetcher';
|
|
2
|
-
export * from './handle/proxy-event';
|
|
3
|
-
export * from './handle/source-event';
|
|
4
|
-
export * from './handle/state-event';
|
|
5
|
-
export * from './handle/value-event';
|
|
6
|
-
export * from './helper/input';
|
|
7
|
-
export * from './type';
|
|
8
|
-
export * from './util/attributes';
|
|
9
|
-
export * from './util/build';
|
|
10
|
-
export * from './util/column';
|
|
11
|
-
export * from './util/constant';
|
|
12
|
-
export * from './util/date';
|
|
13
|
-
export * from './util/extract';
|
|
14
|
-
export * from './util/is-input';
|
|
15
|
-
export * from './util/is-type';
|
|
16
|
-
export * from './util/list';
|
|
17
|
-
export * from './util/logger';
|
|
18
|
-
export * from './util/prepare';
|
|
19
|
-
export * from './util/schema';
|
|
20
|
-
export * from './util/source';
|
|
21
|
-
export * from './util/string';
|
|
22
|
-
export * from './util/style';
|
|
23
|
-
export * from './util/translate';
|
|
24
|
-
export * from './util/url';
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import type { core, z, ZodObject } from 'zod';
|
|
2
|
-
export type Schema = z.ZodTypeAny;
|
|
3
|
-
export type Schemas = Record<string, Schema>;
|
|
4
|
-
export type ZodSchema = ZodObject<{
|
|
5
|
-
[x: string]: Schema;
|
|
6
|
-
}, core.$strip>;
|
|
7
|
-
export type Nullable<T> = T | null;
|
|
8
|
-
export type DataAttributes = {
|
|
9
|
-
[key: `data-${string}`]: string | number | boolean;
|
|
10
|
-
};
|
|
11
|
-
export type AriaAttributes = {
|
|
12
|
-
[key: `aria-${string}`]: string | number | boolean;
|
|
13
|
-
};
|
|
14
|
-
export type TimeFormat = 'HH:mm' | 'HH:mm:ss' | 'hh:mm a' | 'hh:mm:ss a';
|
|
15
|
-
export type DataSource = {
|
|
16
|
-
url: string;
|
|
17
|
-
body?: BodyInit | Record<string, unknown>;
|
|
18
|
-
cache?: RequestCache;
|
|
19
|
-
headers?: HeadersInit;
|
|
20
|
-
method?: string;
|
|
21
|
-
namespace?: string;
|
|
22
|
-
};
|
|
23
|
-
export type Source = {
|
|
24
|
-
[key: string]: DataSource | Array<unknown>;
|
|
25
|
-
};
|
|
26
|
-
export type Definition = Record<string, unknown>;
|
|
27
|
-
export type Orderable = {
|
|
28
|
-
order?: number;
|
|
29
|
-
};
|
|
30
|
-
export type Hideable = {
|
|
31
|
-
hidden?: boolean;
|
|
32
|
-
};
|
|
33
|
-
export type Sections = Section[];
|
|
34
|
-
export type Multiple = readonly (string | number | boolean)[];
|
|
35
|
-
export type Value = string | number | Multiple;
|
|
36
|
-
export type Option = {
|
|
37
|
-
description?: string;
|
|
38
|
-
label: string;
|
|
39
|
-
value: string;
|
|
40
|
-
};
|
|
41
|
-
export type OptionGroup = {
|
|
42
|
-
label: string;
|
|
43
|
-
items: Option[];
|
|
44
|
-
};
|
|
45
|
-
export type List = {
|
|
46
|
-
advanced?: {
|
|
47
|
-
action?: string;
|
|
48
|
-
length?: Length<number>;
|
|
49
|
-
};
|
|
50
|
-
description?: string;
|
|
51
|
-
fields: Array<Field | Column>;
|
|
52
|
-
label?: string;
|
|
53
|
-
name: string;
|
|
54
|
-
type: 'list' | (string & {});
|
|
55
|
-
} & Base;
|
|
56
|
-
export type Fields = Array<Field | Column | List>;
|
|
57
|
-
export type Base = Orderable & Hideable;
|
|
58
|
-
export type CommonProps = {
|
|
59
|
-
disabled?: boolean;
|
|
60
|
-
id?: string;
|
|
61
|
-
name?: string;
|
|
62
|
-
placeholder?: string;
|
|
63
|
-
required?: boolean;
|
|
64
|
-
};
|
|
65
|
-
export type Section = {
|
|
66
|
-
advanced?: boolean;
|
|
67
|
-
compact?: boolean;
|
|
68
|
-
description?: string;
|
|
69
|
-
fields?: Fields;
|
|
70
|
-
id?: string | number;
|
|
71
|
-
separator?: boolean;
|
|
72
|
-
title?: string;
|
|
73
|
-
} & Base;
|
|
74
|
-
export type Column = {
|
|
75
|
-
advanced?: {
|
|
76
|
-
cols?: number;
|
|
77
|
-
};
|
|
78
|
-
description?: string;
|
|
79
|
-
fields: Array<Field>;
|
|
80
|
-
type: 'column' | (string & {});
|
|
81
|
-
} & Base;
|
|
82
|
-
export type Operator = 'eq' | 'neq' | 'in' | 'nin' | 'gt' | 'gte' | 'lt' | 'lte';
|
|
83
|
-
export type Condition = {
|
|
84
|
-
field?: string;
|
|
85
|
-
operator?: Operator;
|
|
86
|
-
value: string | number | string[];
|
|
87
|
-
};
|
|
88
|
-
export type CustomValidation = {
|
|
89
|
-
field: string;
|
|
90
|
-
message?: string;
|
|
91
|
-
operator?: Operator;
|
|
92
|
-
};
|
|
93
|
-
export type FieldState = {
|
|
94
|
-
disabled?: boolean;
|
|
95
|
-
hidden?: boolean;
|
|
96
|
-
};
|
|
97
|
-
export type ActionEvent<T> = {
|
|
98
|
-
action: T;
|
|
99
|
-
};
|
|
100
|
-
export type SourceEvent = ActionEvent<'source'> & {
|
|
101
|
-
source: DataSource;
|
|
102
|
-
target: string;
|
|
103
|
-
};
|
|
104
|
-
export type ValueEvent = ActionEvent<'value'> & {
|
|
105
|
-
value: Record<string, Value | Array<Record<string, unknown>>>;
|
|
106
|
-
};
|
|
107
|
-
export type StateEvent = ActionEvent<'state'> & {
|
|
108
|
-
state: FieldState;
|
|
109
|
-
target: string | string[];
|
|
110
|
-
when?: string | string[] | Condition;
|
|
111
|
-
};
|
|
112
|
-
export type ChangeEvent = Array<SourceEvent | ValueEvent | StateEvent>;
|
|
113
|
-
export type Validation = {
|
|
114
|
-
custom?: CustomValidation | Array<CustomValidation>;
|
|
115
|
-
email?: string;
|
|
116
|
-
length?: Length<string>;
|
|
117
|
-
required?: string;
|
|
118
|
-
};
|
|
119
|
-
export type Field = CommonProps & {
|
|
120
|
-
advanced?: {
|
|
121
|
-
aria?: AriaAttributes;
|
|
122
|
-
autocomplete?: string;
|
|
123
|
-
cols?: number;
|
|
124
|
-
data?: DataAttributes;
|
|
125
|
-
entity?: string;
|
|
126
|
-
horizontal?: boolean;
|
|
127
|
-
reverse?: boolean;
|
|
128
|
-
};
|
|
129
|
-
event?: {
|
|
130
|
-
change?: ChangeEvent;
|
|
131
|
-
};
|
|
132
|
-
description?: string;
|
|
133
|
-
fields?: never;
|
|
134
|
-
label?: string;
|
|
135
|
-
name: string;
|
|
136
|
-
readonly?: boolean;
|
|
137
|
-
type: string;
|
|
138
|
-
validation?: Validation;
|
|
139
|
-
} & Base;
|
|
140
|
-
export type Length<T> = {
|
|
141
|
-
max?: T;
|
|
142
|
-
min?: T;
|
|
143
|
-
};
|
|
144
|
-
export type Input = Field & {
|
|
145
|
-
advanced?: {
|
|
146
|
-
length?: Length<number>;
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
export type Select = Field & {
|
|
150
|
-
advanced?: {
|
|
151
|
-
autocomplete?: never;
|
|
152
|
-
length?: Length<number | string>;
|
|
153
|
-
options?: Option;
|
|
154
|
-
preselected?: boolean;
|
|
155
|
-
};
|
|
156
|
-
source?: DataSource | Array<unknown>;
|
|
157
|
-
};
|
|
158
|
-
export type Chips = Field & {
|
|
159
|
-
advanced?: {
|
|
160
|
-
multiple?: boolean;
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
export type Time = Field & {
|
|
164
|
-
advanced?: {
|
|
165
|
-
format?: TimeFormat;
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
export type Environment = {
|
|
169
|
-
[key: string]: Value;
|
|
170
|
-
};
|
|
171
|
-
export type Protocol = 'http' | 'https';
|
|
172
|
-
export type RemotePattern = {
|
|
173
|
-
hostname?: string;
|
|
174
|
-
port?: number;
|
|
175
|
-
protocol?: Protocol;
|
|
176
|
-
};
|
|
177
|
-
export type FormStateError = {
|
|
178
|
-
title: string;
|
|
179
|
-
description?: string;
|
|
180
|
-
details?: Nullable<Record<string, string[]> | string[]>;
|
|
181
|
-
};
|
|
182
|
-
export type BaseConfig<T> = {
|
|
183
|
-
env?: Environment;
|
|
184
|
-
fetcher: {
|
|
185
|
-
provider: <T>(dataSource: DataSource) => Promise<T>;
|
|
186
|
-
remotePatterns?: Array<RemotePattern>;
|
|
187
|
-
};
|
|
188
|
-
inputs: {
|
|
189
|
-
[key: string]: T;
|
|
190
|
-
};
|
|
191
|
-
style?: Style;
|
|
192
|
-
validation: {
|
|
193
|
-
blur?: boolean;
|
|
194
|
-
change?: boolean;
|
|
195
|
-
showError?: boolean;
|
|
196
|
-
submit?: boolean;
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
export type Style = {
|
|
200
|
-
compact?: boolean;
|
|
201
|
-
horizontal?: boolean;
|
|
202
|
-
showOptionalLabel?: boolean;
|
|
203
|
-
};
|
|
204
|
-
export type Filterable = Base & {
|
|
205
|
-
fields?: Filterable[];
|
|
206
|
-
};
|
|
207
|
-
export type TimezoneItem = {
|
|
208
|
-
label: string;
|
|
209
|
-
value: string;
|
|
210
|
-
};
|
|
211
|
-
export type TimezoneGroup = {
|
|
212
|
-
items: TimezoneItem[];
|
|
213
|
-
label: string;
|
|
214
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Field } from '../type';
|
|
2
|
-
export declare function getPrefixedAttributes(prefix: string, record?: Record<string, string | number | boolean>): Record<string, string | number | boolean>;
|
|
3
|
-
export declare function getAriaAttributes(record?: Record<string, string | number | boolean>): Record<string, string | number | boolean>;
|
|
4
|
-
export declare function getDataAttributes(record?: Record<string, string | number | boolean>): Record<string, string | number | boolean>;
|
|
5
|
-
export declare function buildAriaAttributes(field: Field, errors?: string[]): Record<string, string | number | boolean>;
|
|
6
|
-
export declare function buildDataAttributes(field: Field): Record<string, string | number | boolean>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Field, Nullable } from '../type';
|
|
2
|
-
export declare function buildOptions(field: Field, values?: Nullable<Record<string, unknown>>): Record<string, unknown>[] | undefined;
|
|
3
|
-
export declare function buildOrientation(field: Field): boolean;
|
|
4
|
-
export declare function buildReverse(field: Field): boolean;
|
|
5
|
-
export declare function buildDisabled(field: Field, disabled?: boolean): boolean;
|
|
6
|
-
export declare function buildSource(field: Field): import("..").DataSource | unknown[] | undefined;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export declare const INPUT = "input";
|
|
2
|
-
export declare const INPUT_EMAIL = "input/email";
|
|
3
|
-
export declare const INPUT_NUMBER = "input/number";
|
|
4
|
-
export declare const INPUT_PASSWORD = "input/password";
|
|
5
|
-
export declare const INPUT_TEL = "input/tel";
|
|
6
|
-
export declare const INPUT_TEXT = "input/text";
|
|
7
|
-
export declare const INPUT_TIME = "input/time";
|
|
8
|
-
export declare const INPUTS: string[];
|
|
9
|
-
export declare const TEXTAREA = "textarea";
|
|
10
|
-
export declare const RADIO = "radio";
|
|
11
|
-
export declare const CHECKBOX = "checkbox";
|
|
12
|
-
export declare const LIST = "list";
|
|
13
|
-
export declare const DATA_TABLE = "data-table";
|
|
14
|
-
export declare const SELECT = "select";
|
|
15
|
-
export declare const SELECT_DAY = "select/day";
|
|
16
|
-
export declare const SELECT_MONTH = "select/month";
|
|
17
|
-
export declare const SELECT_TIMEZONE = "select/timezone";
|
|
18
|
-
export declare const SELECT_YEAR = "select/year";
|
|
19
|
-
export declare const SELECTS: string[];
|
|
20
|
-
export declare const CHIPS = "chips";
|
|
21
|
-
export declare const CHIPS_DAYS = "chips/day";
|
|
22
|
-
export declare const CHIPS_MONTHS = "chips/month";
|
|
23
|
-
export declare const COLUMN = "column";
|
|
24
|
-
export declare const DESCRIPTION = "description";
|
|
25
|
-
export declare const FIELDS = "fields";
|
|
26
|
-
export declare const LABEL = "label";
|
|
27
|
-
export declare const VALUE = "value";
|
|
28
|
-
export declare const OPTIONS = "options";
|
|
29
|
-
export declare const TYPE_EMAIL = "email";
|
|
30
|
-
export declare const TYPE_NUMBER = "number";
|
|
31
|
-
export declare const TYPE_PASSWORD = "password";
|
|
32
|
-
export declare const TYPE_TEL = "tel";
|
|
33
|
-
export declare const TYPE_TEXT = "text";
|
|
34
|
-
export declare const ARIA_ERROR_MESSAGE = "aria-errormessage";
|
|
35
|
-
export declare const ARIA_INVALID = "aria-invalid";
|
|
36
|
-
export declare const DATA_INVALID = "data-invalid";
|
|
37
|
-
export declare const DATA_READONLY = "data-readonly";
|
|
38
|
-
export declare const PREFIX_ARIA = "aria";
|
|
39
|
-
export declare const PREFIX_DATA = "data";
|
|
40
|
-
export declare const MAX = "max";
|
|
41
|
-
export declare const MAX_LENGTH = "maxLength";
|
|
42
|
-
export declare const MIN = "min";
|
|
43
|
-
export declare const MIN_LENGTH = "minLength";
|
|
44
|
-
export declare const $REF = "$ref";
|
|
45
|
-
export declare const SET = "set";
|
|
46
|
-
export declare const SOURCE = "source";
|
|
47
|
-
export declare const STATE = "state";
|
|
48
|
-
export declare const COMMON_URL = "http://luna.internal";
|
|
49
|
-
export declare const HIDDEN = "hidden";
|
|
50
|
-
export declare const TYPE = "type";
|
|
51
|
-
export declare const TIMEZONE_REGIONS: Record<string, string>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Time, TimeFormat, TimezoneGroup } from '../type';
|
|
2
|
-
export declare function getMonth(): {
|
|
3
|
-
value: string;
|
|
4
|
-
label: string;
|
|
5
|
-
}[];
|
|
6
|
-
export declare function getWeekDays(): {
|
|
7
|
-
value: string;
|
|
8
|
-
label: string;
|
|
9
|
-
}[];
|
|
10
|
-
export declare function getYear(min: number, max: number): Array<{
|
|
11
|
-
value: string;
|
|
12
|
-
label: string;
|
|
13
|
-
}>;
|
|
14
|
-
export declare function getCurrentYear(): number;
|
|
15
|
-
export declare function getUserTimezone(): string;
|
|
16
|
-
export declare function getTimezones(): TimezoneGroup[];
|
|
17
|
-
export declare function getConvert(value: string | number, current?: number): number;
|
|
18
|
-
export declare function toNativeTime(value: string, fromFormat: TimeFormat): string;
|
|
19
|
-
export declare function fromNativeTime(native: string, toFormat?: TimeFormat): string;
|
|
20
|
-
export declare function getTimeFormat(field: Time): TimeFormat;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Nullable, Option, Value } from '../type';
|
|
2
|
-
export declare function getEntity<T>(selected: string, collection?: Nullable<T[]>, entity?: string): NonNullable<T> | {
|
|
3
|
-
value: string;
|
|
4
|
-
};
|
|
5
|
-
export declare function getCurrentValue<T>(value: T, entity?: string): Value | undefined;
|
|
6
|
-
export declare function getValue<T>(value: Record<string, T>, namespace?: string): T | undefined;
|
|
7
|
-
export declare function getArray<T>(value: Record<string, T> | T[], namespace?: string): Nullable<T[]>;
|
|
8
|
-
export declare function extract<T>(value: Record<string, T>, namespace?: string): T | null;
|
|
9
|
-
export declare function toOptions<T>(data: T[], options?: Option): (T | {
|
|
10
|
-
description?: string | undefined;
|
|
11
|
-
label: string;
|
|
12
|
-
value: string;
|
|
13
|
-
})[];
|
|
14
|
-
export declare function getType(value?: string): string;
|
|
15
|
-
export declare function getFormData(formData: FormData): Record<string, unknown>;
|
|
16
|
-
export declare function unflatten(data: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Chips, Column, Field, Input, List, Nullable, Select, Time } from '../type';
|
|
2
|
-
export declare const isSelectDay: (field: Field) => boolean;
|
|
3
|
-
export declare const isSelectMonth: (field: Field) => boolean;
|
|
4
|
-
export declare const isSelectYear: (field: Field) => boolean;
|
|
5
|
-
export declare const isSelectTimezone: (field: Field) => boolean;
|
|
6
|
-
export declare const isChipsDays: (field: Field) => boolean;
|
|
7
|
-
export declare const isChipsMonths: (field: Field) => boolean;
|
|
8
|
-
export declare const isCheckbox: (field: Field) => field is Input;
|
|
9
|
-
export declare const isChips: (field: Field) => field is Chips;
|
|
10
|
-
export declare const isInput: (field: Field) => field is Input;
|
|
11
|
-
export declare const isRadio: (field: Field) => field is Select;
|
|
12
|
-
export declare const isSelect: (field: Field) => field is Select;
|
|
13
|
-
export declare const isTextArea: (field: Field) => field is Input;
|
|
14
|
-
export declare const isTime: (field: Field) => field is Time;
|
|
15
|
-
export declare const isText: (field: Field) => field is Input;
|
|
16
|
-
export declare const isEmail: (field: Field) => field is Input;
|
|
17
|
-
export declare const isNumber: (field: Field) => field is Input;
|
|
18
|
-
export declare function isClickable(field: Field): boolean;
|
|
19
|
-
export declare function isList(slot: Field | Column | List): slot is List;
|
|
20
|
-
export declare function isColumn(slot: Field | Column | List): slot is Column;
|
|
21
|
-
export declare function isField(slot: Field | Column | List): slot is Field;
|
|
22
|
-
export declare function isOptions(field: Field): field is Select;
|
|
23
|
-
export declare function isTextable(field: Field): boolean;
|
|
24
|
-
export declare function isValidValue<T>(value?: Nullable<T>): boolean;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { DataSource, Value } from '../type';
|
|
2
|
-
export declare function isObject<T>(value: unknown): value is Record<string, T>;
|
|
3
|
-
export declare function isEmpty(value: unknown): boolean;
|
|
4
|
-
export declare function isValue(value: unknown): value is Value;
|
|
5
|
-
export declare function isString(value: unknown): value is string;
|
|
6
|
-
export declare function isDataSource(value: unknown): value is DataSource;
|
|
7
|
-
export declare function isBoolean(value: unknown): value is boolean;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { List, Nullable } from '../type';
|
|
2
|
-
export declare function isMultiFieldList(list: List): boolean;
|
|
3
|
-
export declare function getInitialList(list: List, value?: Nullable<Record<string, unknown>>): number[];
|
|
4
|
-
export declare function getLabel(list: List): string;
|