@gmcode/forms 0.0.7 → 0.0.9
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/en-Bw2ceTNi.mjs +24 -0
- package/dist/{en-CnkPOj-4.mjs.map → en-Bw2ceTNi.mjs.map} +1 -1
- package/dist/index.d.mts +38 -196
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +904 -1
- package/dist/index.mjs.map +1 -1
- package/dist/locales.d.mts.map +1 -1
- package/dist/locales.mjs +30 -1
- package/dist/locales.mjs.map +1 -1
- package/package.json +10 -14
- package/dist/en-CnkPOj-4.mjs +0 -2
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,905 @@
|
|
|
1
|
-
import{t as e}from"./en-CnkPOj-4.mjs";import{createInstance as t}from"i18next";import{Button as n,Calendar as r,Checkbox as i,Field as a,FieldDescription as o,FieldError as s,FieldLabel as c,FieldSet as l,Input as u,InputGroup as d,InputGroupAddon as f,InputGroupButton as p,InputGroupInput as m,Label as h,RadioGroup as g,RadioGroupItem as _,Select as v,SelectContent as y,SelectItem as b,SelectTrigger as x,SelectValue as S,Spinner as C,Switch as w,TextareaAutosize as T,cn as E,flash as ee}from"@gmcode/react-ui";import{Controller as D,useForm as O}from"react-hook-form";import{c as k}from"react/compiler-runtime";import{I18nextProvider as te,useTranslation as A}from"react-i18next";import{Fragment as ne,jsx as j,jsxs as M}from"react/jsx-runtime";import{useTsvResolver as re,useTsvResolver as N}from"@gmcode/tsv-hookform";import{useEffect as P,useState as F}from"react";import{useForm as I}from"@inertiajs/react";import{Minus as L,Plus as R,X as z}from"lucide-react";import{InputCheckboxRule as B,InputColorRule as V,InputEmailRule as H,InputNumberRule as U,InputRule as W,InputSelectRule as G,InputTextRule as K,Message as q,Schema as J}from"@gmcode/tsv-input";const Y=t({fallbackLng:`en`,interpolation:{escapeValue:!1},resources:{en:e}});Y.init();function X(e){return`${e.getFullYear()}-${(e.getMonth()+1+``).padStart(2,`0`)}-${(e.getDate()+``).padStart(2,`0`)}`}function ie(e){if(!e)return;let t=new Date(e);if(!isNaN(t.getFullYear()))return t}function Z(e){let t=k(9);if(t[0]!==`e1e2461c713ca647286d0fc423569ef83087dbc1e837bfd11a46d13a4019c79a`){for(let e=0;e<9;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`e1e2461c713ca647286d0fc423569ef83087dbc1e837bfd11a46d13a4019c79a`}let{error:n}=e,{t:r}=A();if(!n?.message)return null;if(r){let e;t[1]!==n.message||t[2]!==n.params||t[3]!==r?(e=r(n.message,n.params),t[1]=n.message,t[2]=n.params,t[3]=r,t[4]=e):e=t[4];let i;return t[5]===e?i=t[6]:(i=j(s,{errors:{message:e}}),t[5]=e,t[6]=i),i}let i;return t[7]===n?i=t[8]:(i=j(s,{errors:n}),t[7]=n,t[8]=i),i}function ae({control:e,dateToString:t=X,disabled:n,inputId:i,inputName:o,label:s,locale:l,stringToDate:u=ie,...d}){return j(D,{name:o,control:e,render:({field:e,fieldState:f})=>M(a,{"data-invalid":f.invalid,...d,children:[s&&j(c,{htmlFor:i??o,children:s}),j(r,{"aria-invalid":f.invalid,className:`w-full rounded-md border`,disabled:n,fixedWeeks:!0,id:i??(s?o:void 0),locale:l,mode:`single`,onSelect:n=>e.onChange(n?t(n):``),selected:u(e.value)}),j(Z,{error:f.error})]})})}function oe({control:e,disabled:t,inputId:n,inputName:r,label:o,onCheckedChange:s,orientation:l=`horizontal`,readOnly:u,uncheckedValue:d=``,value:f=`true`,...p}){return j(D,{control:e,disabled:t,name:r,render:({field:e,fieldState:t})=>M(a,{"data-invalid":t.invalid,orientation:l,...p,children:[j(i,{"aria-invalid":t.invalid,"aria-readonly":u,checked:e.value===f,className:`aria-readonly:opacity-50`,disabled:e.disabled,id:n??(o?r:void 0),name:e.name,onBlur:e.onBlur,onCheckedChange:t=>{u||(e.onChange(t===!0?f:d),s&&s(t,e))},ref:e.ref,value:f}),o&&j(c,{htmlFor:n??r,children:o}),j(Z,{error:t.error})]})})}function Q(e){let t=k(26);if(t[0]!==`7501af4e40fae6de51379fcd69a5dbf630a70539ba636a47e077920376e26910`){for(let e=0;e<26;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`7501af4e40fae6de51379fcd69a5dbf630a70539ba636a47e077920376e26910`}let n,r,i,o,s,l,d,f,p,m;t[1]===e?(n=t[2],r=t[3],i=t[4],o=t[5],s=t[6],l=t[7],d=t[8],f=t[9],p=t[10],m=t[11]):({autoComplete:n,control:r,disabled:i,inputId:o,inputName:s,label:l,placeholder:d,readOnly:p,type:m,...f}=e,t[1]=e,t[2]=n,t[3]=r,t[4]=i,t[5]=o,t[6]=s,t[7]=l,t[8]=d,t[9]=f,t[10]=p,t[11]=m);let h;t[12]!==n||t[13]!==o||t[14]!==s||t[15]!==l||t[16]!==d||t[17]!==f||t[18]!==p||t[19]!==m?(h=e=>{let{field:t,fieldState:r}=e;return M(a,{"data-invalid":r.invalid,...f,children:[l&&j(c,{htmlFor:o??s,children:l}),j(u,{"aria-invalid":r.invalid,autoComplete:n,id:o??(l?s:void 0),placeholder:d,readOnly:p,type:m,...t}),j(Z,{error:r.error})]})},t[12]=n,t[13]=o,t[14]=s,t[15]=l,t[16]=d,t[17]=f,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==r||t[22]!==i||t[23]!==s||t[24]!==h?(g=j(D,{control:r,disabled:i,name:s,render:h}),t[21]=r,t[22]=i,t[23]=s,t[24]=h,t[25]=g):g=t[25],g}function se({autoComplete:e=`on`,type:t=`email`,...n}){return j(Q,{autoComplete:e,type:t,...n})}function ce(e){let t=k(24);if(t[0]!==`f049c21be78fb6540f3470521dce48b055b196c1dc09159c5c6b5f5d2dcbc0b9`){for(let e=0;e<24;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`f049c21be78fb6540f3470521dce48b055b196c1dc09159c5c6b5f5d2dcbc0b9`}let n,r,i,a,s,u,d,f,p;t[1]===e?(n=t[2],r=t[3],i=t[4],a=t[5],s=t[6],u=t[7],d=t[8],f=t[9],p=t[10]):({control:n,defaultValue:r,description:i,disabled:a,groupId:s,inputName:u,label:d,options:f,...p}=e,t[1]=e,t[2]=n,t[3]=r,t[4]=i,t[5]=a,t[6]=s,t[7]=u,t[8]=d,t[9]=f,t[10]=p);let m;t[11]!==r||t[12]!==i||t[13]!==s||t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==p?(m=e=>{let{field:t,fieldState:n}=e;return M(l,{"data-invalid":n.invalid,...p,children:[d&&j(c,{htmlFor:s??u,children:d}),i&&j(o,{children:i}),j(Z,{error:n.error}),j(g,{defaultValue:r,disabled:t.disabled,id:s??(d?u:void 0),name:t.name,onBlur:t.onBlur,onValueChange:t.onChange,ref:t.ref,children:f.map(le)})]})},t[11]=r,t[12]=i,t[13]=s,t[14]=u,t[15]=d,t[16]=f,t[17]=p,t[18]=m):m=t[18];let h;return t[19]!==n||t[20]!==a||t[21]!==u||t[22]!==m?(h=j(D,{control:n,disabled:a,name:u,render:m}),t[19]=n,t[20]=a,t[21]=u,t[22]=m,t[23]=h):h=t[23],h}function le(e){return j(h,{className:`rounded-md border ring-ring/50 transition-all hover:bg-accent/50 has-focus-visible:ring-[3px]`,"data-slot":`field-label`,children:M(`div`,{className:`flex w-full items-center gap-3 rounded-md p-3 transition-all has-aria-checked:border-l-8 has-aria-checked:border-ring`,children:[j(_,{className:`sr-only`,id:e.id,value:e.value}),e.Icon&&j(e.Icon,{}),e.label]})},e.key??e.id??e.value)}function ue({children:e,className:t,defaults:n={},rootError:r=`flash`,onBefore:i,onBeforeUpdate:a,onCancel:o,onCancelToken:s,onError:c,onFinish:l,onFlash:u,onPrefetched:d,onPrefetching:f,onProgress:p,onStart:m,onSuccess:h,preserveScroll:g=!0,resetOnSuccess:_=!0,route:v,schema:y,setDefaultsOnSuccess:b=!1}){let[x,S]=F(),C=Object.fromEntries(Object.keys(y.ruleset).map(e=>[e,n[e]??``])),w=O({defaultValues:C,resolver:N(y)}),T=I(C);function D(e){e.root&&(r===`flash`?ee({level:`error`,title:e.root}):r===`monitor`&&S({message:e.root})),c&&c(e)}function k(e){b&&(T.setDefaults(),w.reset(w.getValues())),_&&(T.reset(),w.reset()),h&&h(e)}function A(e){T.transform(()=>e),T[v.method](v.url,{onBefore:i,onBeforeUpdate:a,onCancel:o,onCancelToken:s,onError:D,onFinish:l,onFlash:u,onPrefetched:d,onPrefetching:f,onProgress:p,onStart:m,onSuccess:k,preserveScroll:g})}return P(()=>{for(let[e,t]of Object.entries(T.errors))t&&w.setError(e,{message:t,type:`inertia`})},[T.errors,w]),j(te,{i18n:Y,children:M(`form`,{action:v.url,className:E(`grid gap-6`,t),method:v.method,onSubmit:w.handleSubmit(A),children:[j(ne,{children:e({errors:T.errors,form:w,loading:T.processing})}),r===`monitor`&&j(Z,{error:x})]})})}function de({autoComplete:e=`off`,className:t,type:n=`hidden`,...r}){return j(Q,{autoComplete:e,className:E(`hidden`,t),type:n,...r})}function fe({children:e,className:t,control:n,disabled:r,inputId:o,inputName:s,label:c,onCheckedChange:l,orientation:u=`horizontal`,readOnly:d,text:f,uncheckedValue:p=``,value:m=`true`,...g}){return j(D,{control:n,disabled:r,name:s,render:({field:n,fieldState:r})=>j(a,{className:E(`block`,t),"data-invalid":r.invalid,orientation:u,...g,children:M(h,{className:`flex items-start gap-3 rounded-lg border p-3 hover:bg-accent/50 has-aria-checked:border-info-foreground has-aria-checked:bg-info`,"data-slot":`field-label`,children:[j(i,{"aria-invalid":r.invalid,"aria-readonly":d,checked:n.value===m,className:`aria-readonly:opacity-50 data-[state=checked]:border-info-foreground data-[state=checked]:bg-info-foreground data-[state=checked]:text-white dark:data-[state=checked]:border-info-foreground dark:data-[state=checked]:bg-info-foreground`,disabled:n.disabled,id:o,name:n.name,onBlur:n.onBlur,onCheckedChange:e=>{d||(n.onChange(e===!0?m:p),l&&l(e,n))},ref:n.ref,value:m}),M(`div`,{className:`grid gap-1.5 font-normal`,children:[j(`p`,{className:`text-sm leading-none font-medium`,children:c}),f?j(`p`,{className:`text-sm text-muted-foreground`,children:f}):e,j(Z,{error:r.error})]})]})})})}function pe(e){let t=k(29);if(t[0]!==`aef79d6bb8014bb7e50376596fc0ae9e5294086f70390531e20fce8a0095eeca`){for(let e=0;e<29;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`aef79d6bb8014bb7e50376596fc0ae9e5294086f70390531e20fce8a0095eeca`}let r,i,s,l,u,d,f,p,m,h,g;t[1]===e?(r=t[2],i=t[3],s=t[4],l=t[5],u=t[6],d=t[7],f=t[8],p=t[9],m=t[10],h=t[11],g=t[12]):({autoComplete:r,control:i,description:s,disabled:l,inputId:u,inputName:d,label:f,options:p,placeholder:m,setValue:g,...h}=e,t[1]=e,t[2]=r,t[3]=i,t[4]=s,t[5]=l,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m,t[11]=h,t[12]=g);let{t:_}=A(),b;t[13]!==r||t[14]!==s||t[15]!==u||t[16]!==d||t[17]!==f||t[18]!==p||t[19]!==m||t[20]!==h||t[21]!==g||t[22]!==_?(b=e=>{let{field:t,fieldState:i}=e;return M(a,{"data-invalid":i.invalid,...h,children:[f&&j(c,{htmlFor:u??d,children:f}),M(`div`,{className:`flex items-end gap-4`,children:[M(v,{autoComplete:r,disabled:t.disabled,name:t.name,onValueChange:t.onChange,value:t.value,children:[j(x,{"aria-invalid":i.invalid,className:`flex-1 overflow-hidden`,id:u??(f?d:void 0),children:j(S,{placeholder:m})}),j(y,{children:p.map(me)})]}),j(n,{"aria-label":_($),className:`flex-none`,onClick:()=>g(d,``),type:`button`,variant:`outline`,children:j(z,{})})]}),s&&j(o,{children:s}),j(Z,{error:i.error})]})},t[13]=r,t[14]=s,t[15]=u,t[16]=d,t[17]=f,t[18]=p,t[19]=m,t[20]=h,t[21]=g,t[22]=_,t[23]=b):b=t[23];let C;return t[24]!==i||t[25]!==l||t[26]!==d||t[27]!==b?(C=j(D,{control:i,disabled:l,name:d,render:b}),t[24]=i,t[25]=l,t[26]=d,t[27]=b,t[28]=C):C=t[28],C}function $(e){return e.reset}function me(e){return j(b,{id:e.id,value:e.value,children:e.label},e.key??e.id??e.value)}function he(e,t,n,r,i){let a=Number(e);return isNaN(a)?``:(t?a+=n===void 0?1:n:a-=n===void 0?1:n,r!==void 0&&(a=Math.max(a,r)),i!==void 0&&(a=Math.min(a,i)),a.toString())}function ge({autoComplete:e,control:t,disabled:n,inputId:r,inputMode:i=`numeric`,inputName:o,label:s,placeholder:l,type:u,ui:h,...g}){let{t:_}=A();function v(e,t){h?.setValue&&h.setValue(o,he(e,t,h.step,h.min,h.max),{shouldValidate:!0})}return j(D,{control:t,disabled:n,name:o,render:({field:t,fieldState:y})=>M(a,{"data-invalid":y.invalid,...g,children:[s&&j(c,{htmlFor:r??o,children:s}),M(d,{children:[j(m,{"aria-invalid":y.invalid,autoComplete:e,id:r??(s?o:void 0),inputMode:i,placeholder:l,type:u,...t}),h&&M(f,{align:`inline-end`,children:[j(p,{"aria-label":_(e=>e.decrease),disabled:n,onClick:()=>v(t.value,!1),size:`icon-xs`,children:j(L,{})}),j(p,{"aria-label":_(e=>e.increase),disabled:n,onClick:()=>v(t.value,!0),size:`icon-xs`,children:j(R,{})})]})]}),j(Z,{error:y.error})]})})}function _e({autoComplete:e=`off`,type:t=`password`,...n}){return j(Q,{autoComplete:e,type:t,...n})}function ve(e){let t=k(26);if(t[0]!==`17d768ca562ec97c16bcafe5b5f4a7680b17a9911e26839427dd0f20be4d3e30`){for(let e=0;e<26;e+=1)t[e]=Symbol.for(`react.memo_cache_sentinel`);t[0]=`17d768ca562ec97c16bcafe5b5f4a7680b17a9911e26839427dd0f20be4d3e30`}let n,r,i,s,l,u,d,f,p,m;t[1]===e?(n=t[2],r=t[3],i=t[4],s=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11]):({autoComplete:n,control:r,description:i,disabled:s,inputId:l,inputName:u,label:d,options:f,placeholder:p,...m}=e,t[1]=e,t[2]=n,t[3]=r,t[4]=i,t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m);let h;t[12]!==n||t[13]!==i||t[14]!==l||t[15]!==u||t[16]!==d||t[17]!==f||t[18]!==p||t[19]!==m?(h=e=>{let{field:t,fieldState:r}=e;return M(a,{"data-invalid":r.invalid,...m,children:[d&&j(c,{htmlFor:l??u,children:d}),M(v,{autoComplete:n,disabled:t.disabled,name:t.name,onValueChange:t.onChange,value:t.value,children:[j(x,{"aria-invalid":r.invalid,id:l??(d?u:void 0),children:j(S,{placeholder:p})}),j(y,{children:f.map(ye)})]}),i&&j(o,{children:i}),j(Z,{error:r.error})]})},t[12]=n,t[13]=i,t[14]=l,t[15]=u,t[16]=d,t[17]=f,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==r||t[22]!==s||t[23]!==u||t[24]!==h?(g=j(D,{control:r,disabled:s,name:u,render:h}),t[21]=r,t[22]=s,t[23]=u,t[24]=h,t[25]=g):g=t[25],g}function ye(e){return j(b,{id:e.id,value:e.value,children:e.label},e.key??e.id??e.value)}function be({label:e,loading:t=!1,type:r=`submit`,...i}){let{t:a}=A();return j(n,{disabled:t,type:r,...i,children:M(`div`,{className:`relative`,children:[j(`span`,{className:E({invisible:t}),children:e??a(e=>e.submit)}),j(C,{className:E(`trans absolute top-1/2 left-1/2 hidden -translate-x-1/2 -translate-y-1/2`,{block:t})})]})})}function xe({control:e,disabled:t,inputId:n,inputName:r,label:i,onCheckedChange:o,orientation:s=`horizontal`,readOnly:l,uncheckedValue:u=``,value:d=`true`,...f}){return j(D,{control:e,disabled:t,name:r,render:({field:e,fieldState:t})=>M(a,{"data-invalid":t.invalid,orientation:s,...f,children:[j(w,{"aria-invalid":t.invalid,"aria-readonly":l,checked:e.value===d,className:`aria-readonly:opacity-50`,disabled:e.disabled,id:n??(i?r:void 0),name:e.name,onBlur:e.onBlur,onCheckedChange:t=>{l||(e.onChange(t===!0?d:u),o&&o(t,e))},ref:e.ref,value:d}),i&&j(c,{htmlFor:n??r,children:i}),j(Z,{error:t.error})]})})}function Se({autoComplete:e=`on`,type:t=`text`,...n}){return j(Q,{autoComplete:e,type:t,...n})}function Ce({cacheMeasurements:e,control:t,inputId:n,inputName:r,label:i,maxRows:o,minRows:s,onHeightChange:l,placeholder:u,resize:d=`none`,...f}){return j(D,{name:r,control:t,render:({field:t,fieldState:p})=>M(a,{"data-invalid":p.invalid,...f,children:[i&&j(c,{htmlFor:n??r,children:i}),j(T,{"aria-invalid":p.invalid,autoComplete:`off`,cacheMeasurements:e,className:E({resize:d===`both`,"resize-none":d===`none`,"resize-x":d===`x`,"resize-y":d===`y`}),id:n??(i?r:void 0),maxRows:o,minRows:s,onHeightChange:l,placeholder:u,...t}),j(Z,{error:p.error})]})})}export{ae as CalendarField,oe as CheckboxField,se as EmailField,Z as ErrorMonitor,ce as FancyRadioField,ue as Form,de as HiddenField,fe as InfoCheckboxField,B as InputCheckboxRule,V as InputColorRule,H as InputEmailRule,Q as InputField,U as InputNumberRule,W as InputRule,G as InputSelectRule,K as InputTextRule,q as Message,pe as NullableSelectField,ge as NumericField,_e as PasswordField,J as Schema,ve as SelectField,be as Submit,xe as SwitchField,Se as TextField,Ce as TextareaField,Y as i18n,re as useTsvResolver};
|
|
1
|
+
import { t as en_default } from "./en-Bw2ceTNi.mjs";
|
|
2
|
+
import { createInstance } from "i18next";
|
|
3
|
+
import { Button, Calendar, Checkbox, Field, FieldDescription, FieldError, FieldLabel, FieldSet, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, Label, RadioGroup, RadioGroupItem, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Spinner, Switch, TextareaAutosize, cn, flash } from "@gmcode/react-ui";
|
|
4
|
+
import { Controller, useForm } from "react-hook-form";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { I18nextProvider, useTranslation } from "react-i18next";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useTsvResolver, useTsvResolver as useTsvResolver$1 } from "@gmcode/tsv-hookform";
|
|
9
|
+
import { useForm as useForm$1 } from "@inertiajs/react";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
import { Minus, Plus, X } from "lucide-react";
|
|
12
|
+
import { InputCheckboxRule, InputColorRule, InputEmailRule, InputNumberRule, InputRule, InputSelectRule, InputTextRule, Message, Schema } from "@gmcode/tsv-input";
|
|
13
|
+
|
|
14
|
+
//#region src/i18n.ts
|
|
15
|
+
const i18n = createInstance({
|
|
16
|
+
fallbackLng: "en",
|
|
17
|
+
interpolation: { escapeValue: false },
|
|
18
|
+
resources: { en: en_default }
|
|
19
|
+
});
|
|
20
|
+
i18n.init();
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/components/error-monitor.tsx
|
|
24
|
+
function ErrorMonitor(t0) {
|
|
25
|
+
const $ = c(9);
|
|
26
|
+
if ($[0] !== "c1152b8b10c8eb9b2d5487945cb5eb86f0f91985c5c6904e6837c158e73942d1") {
|
|
27
|
+
for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
28
|
+
$[0] = "c1152b8b10c8eb9b2d5487945cb5eb86f0f91985c5c6904e6837c158e73942d1";
|
|
29
|
+
}
|
|
30
|
+
const { error } = t0;
|
|
31
|
+
const { t } = useTranslation();
|
|
32
|
+
if (!error?.message) return null;
|
|
33
|
+
if (t.name === "notReadyT") {
|
|
34
|
+
let t1;
|
|
35
|
+
if ($[1] !== error) {
|
|
36
|
+
t1 = /* @__PURE__ */ jsx(FieldError, { errors: error });
|
|
37
|
+
$[1] = error;
|
|
38
|
+
$[2] = t1;
|
|
39
|
+
} else t1 = $[2];
|
|
40
|
+
return t1;
|
|
41
|
+
}
|
|
42
|
+
let t1;
|
|
43
|
+
if ($[3] !== error.message || $[4] !== error.params || $[5] !== t) {
|
|
44
|
+
t1 = t(error.message, error.params);
|
|
45
|
+
$[3] = error.message;
|
|
46
|
+
$[4] = error.params;
|
|
47
|
+
$[5] = t;
|
|
48
|
+
$[6] = t1;
|
|
49
|
+
} else t1 = $[6];
|
|
50
|
+
let t2;
|
|
51
|
+
if ($[7] !== t1) {
|
|
52
|
+
t2 = /* @__PURE__ */ jsx(FieldError, { errors: { message: t1 } });
|
|
53
|
+
$[7] = t1;
|
|
54
|
+
$[8] = t2;
|
|
55
|
+
} else t2 = $[8];
|
|
56
|
+
return t2;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/lib/utils.ts
|
|
61
|
+
/**
|
|
62
|
+
* Convert a javascript `Date` object to a string with the format `aaaa-mm-dd`.
|
|
63
|
+
*/
|
|
64
|
+
function dateToString(date) {
|
|
65
|
+
return `${date.getFullYear()}-${(date.getMonth() + 1 + "").padStart(2, "0")}-${(date.getDate() + "").padStart(2, "0")}`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Convert a string to a javascript `Date` object or undefined if the string is
|
|
69
|
+
* not a valid date.
|
|
70
|
+
*/
|
|
71
|
+
function stringToDate(string) {
|
|
72
|
+
if (!string) return;
|
|
73
|
+
const date = new Date(string);
|
|
74
|
+
if (isNaN(date.getFullYear())) return;
|
|
75
|
+
return date;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/components/calendar-field.tsx
|
|
80
|
+
function CalendarField({ control, dateToString: dateToString$1 = dateToString, disabled, inputId, inputName, label, locale, stringToDate: stringToDate$1 = stringToDate, ...props }) {
|
|
81
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
82
|
+
control,
|
|
83
|
+
name: inputName,
|
|
84
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxs(Field, {
|
|
85
|
+
"data-invalid": fieldState.invalid,
|
|
86
|
+
...props,
|
|
87
|
+
children: [
|
|
88
|
+
label && /* @__PURE__ */ jsx(FieldLabel, {
|
|
89
|
+
htmlFor: inputId ?? inputName,
|
|
90
|
+
children: label
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ jsx(Calendar, {
|
|
93
|
+
"aria-invalid": fieldState.invalid,
|
|
94
|
+
className: "w-full rounded-md border",
|
|
95
|
+
disabled,
|
|
96
|
+
fixedWeeks: true,
|
|
97
|
+
id: inputId ?? (label ? inputName : void 0),
|
|
98
|
+
locale,
|
|
99
|
+
mode: "single",
|
|
100
|
+
onSelect: (date) => field.onChange(date ? dateToString$1(date) : ""),
|
|
101
|
+
selected: stringToDate$1(field.value)
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ jsx(ErrorMonitor, { error: fieldState.error })
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/components/checkbox-field.tsx
|
|
111
|
+
function CheckboxField({ control, disabled, inputId, inputName, label, onCheckedChange, orientation = "horizontal", readOnly, uncheckedValue = "", value = "true", ...props }) {
|
|
112
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
113
|
+
control,
|
|
114
|
+
disabled,
|
|
115
|
+
name: inputName,
|
|
116
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxs(Field, {
|
|
117
|
+
"data-invalid": fieldState.invalid,
|
|
118
|
+
orientation,
|
|
119
|
+
...props,
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsx(Checkbox, {
|
|
122
|
+
"aria-invalid": fieldState.invalid,
|
|
123
|
+
"aria-readonly": readOnly,
|
|
124
|
+
checked: field.value === value,
|
|
125
|
+
className: "aria-readonly:opacity-50",
|
|
126
|
+
disabled: field.disabled,
|
|
127
|
+
id: inputId ?? (label ? inputName : void 0),
|
|
128
|
+
name: field.name,
|
|
129
|
+
onBlur: field.onBlur,
|
|
130
|
+
onCheckedChange: (checked) => {
|
|
131
|
+
if (!readOnly) {
|
|
132
|
+
field.onChange(checked === true ? value : uncheckedValue);
|
|
133
|
+
if (onCheckedChange) onCheckedChange(checked, field);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
ref: field.ref,
|
|
137
|
+
value
|
|
138
|
+
}),
|
|
139
|
+
label && /* @__PURE__ */ jsx(FieldLabel, {
|
|
140
|
+
htmlFor: inputId ?? inputName,
|
|
141
|
+
children: label
|
|
142
|
+
}),
|
|
143
|
+
/* @__PURE__ */ jsx(ErrorMonitor, { error: fieldState.error })
|
|
144
|
+
]
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/components/input-field.tsx
|
|
151
|
+
function InputField(t0) {
|
|
152
|
+
const $ = c(26);
|
|
153
|
+
if ($[0] !== "eb6b897d20af47d2fa5513291ad28dc03dd5944c0cdad844bd9abb66dc900d34") {
|
|
154
|
+
for (let $i = 0; $i < 26; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
155
|
+
$[0] = "eb6b897d20af47d2fa5513291ad28dc03dd5944c0cdad844bd9abb66dc900d34";
|
|
156
|
+
}
|
|
157
|
+
let autoComplete;
|
|
158
|
+
let control;
|
|
159
|
+
let disabled;
|
|
160
|
+
let inputId;
|
|
161
|
+
let inputName;
|
|
162
|
+
let label;
|
|
163
|
+
let placeholder;
|
|
164
|
+
let props;
|
|
165
|
+
let readOnly;
|
|
166
|
+
let type;
|
|
167
|
+
if ($[1] !== t0) {
|
|
168
|
+
({autoComplete, control, disabled, inputId, inputName, label, placeholder, readOnly, type, ...props} = t0);
|
|
169
|
+
$[1] = t0;
|
|
170
|
+
$[2] = autoComplete;
|
|
171
|
+
$[3] = control;
|
|
172
|
+
$[4] = disabled;
|
|
173
|
+
$[5] = inputId;
|
|
174
|
+
$[6] = inputName;
|
|
175
|
+
$[7] = label;
|
|
176
|
+
$[8] = placeholder;
|
|
177
|
+
$[9] = props;
|
|
178
|
+
$[10] = readOnly;
|
|
179
|
+
$[11] = type;
|
|
180
|
+
} else {
|
|
181
|
+
autoComplete = $[2];
|
|
182
|
+
control = $[3];
|
|
183
|
+
disabled = $[4];
|
|
184
|
+
inputId = $[5];
|
|
185
|
+
inputName = $[6];
|
|
186
|
+
label = $[7];
|
|
187
|
+
placeholder = $[8];
|
|
188
|
+
props = $[9];
|
|
189
|
+
readOnly = $[10];
|
|
190
|
+
type = $[11];
|
|
191
|
+
}
|
|
192
|
+
let t1;
|
|
193
|
+
if ($[12] !== autoComplete || $[13] !== inputId || $[14] !== inputName || $[15] !== label || $[16] !== placeholder || $[17] !== props || $[18] !== readOnly || $[19] !== type) {
|
|
194
|
+
t1 = (t2) => {
|
|
195
|
+
const { field, fieldState } = t2;
|
|
196
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
197
|
+
"data-invalid": fieldState.invalid,
|
|
198
|
+
...props,
|
|
199
|
+
children: [
|
|
200
|
+
label && /* @__PURE__ */ jsx(FieldLabel, {
|
|
201
|
+
htmlFor: inputId ?? inputName,
|
|
202
|
+
children: label
|
|
203
|
+
}),
|
|
204
|
+
/* @__PURE__ */ jsx(Input, {
|
|
205
|
+
"aria-invalid": fieldState.invalid,
|
|
206
|
+
autoComplete,
|
|
207
|
+
id: inputId ?? (label ? inputName : void 0),
|
|
208
|
+
placeholder,
|
|
209
|
+
readOnly,
|
|
210
|
+
type,
|
|
211
|
+
...field
|
|
212
|
+
}),
|
|
213
|
+
/* @__PURE__ */ jsx(ErrorMonitor, { error: fieldState.error })
|
|
214
|
+
]
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
$[12] = autoComplete;
|
|
218
|
+
$[13] = inputId;
|
|
219
|
+
$[14] = inputName;
|
|
220
|
+
$[15] = label;
|
|
221
|
+
$[16] = placeholder;
|
|
222
|
+
$[17] = props;
|
|
223
|
+
$[18] = readOnly;
|
|
224
|
+
$[19] = type;
|
|
225
|
+
$[20] = t1;
|
|
226
|
+
} else t1 = $[20];
|
|
227
|
+
let t2;
|
|
228
|
+
if ($[21] !== control || $[22] !== disabled || $[23] !== inputName || $[24] !== t1) {
|
|
229
|
+
t2 = /* @__PURE__ */ jsx(Controller, {
|
|
230
|
+
control,
|
|
231
|
+
disabled,
|
|
232
|
+
name: inputName,
|
|
233
|
+
render: t1
|
|
234
|
+
});
|
|
235
|
+
$[21] = control;
|
|
236
|
+
$[22] = disabled;
|
|
237
|
+
$[23] = inputName;
|
|
238
|
+
$[24] = t1;
|
|
239
|
+
$[25] = t2;
|
|
240
|
+
} else t2 = $[25];
|
|
241
|
+
return t2;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/components/email-field.tsx
|
|
246
|
+
function EmailField({ autoComplete = "on", type = "email", ...props }) {
|
|
247
|
+
return /* @__PURE__ */ jsx(InputField, {
|
|
248
|
+
autoComplete,
|
|
249
|
+
type,
|
|
250
|
+
...props
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/components/fancy-radio-field.tsx
|
|
256
|
+
function FancyRadioField(t0) {
|
|
257
|
+
const $ = c(24);
|
|
258
|
+
if ($[0] !== "7a4979d82af7419e1bc9831eb290204811c7a1a15ab9a1058ace533faf000995") {
|
|
259
|
+
for (let $i = 0; $i < 24; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
260
|
+
$[0] = "7a4979d82af7419e1bc9831eb290204811c7a1a15ab9a1058ace533faf000995";
|
|
261
|
+
}
|
|
262
|
+
let control;
|
|
263
|
+
let defaultValue;
|
|
264
|
+
let description;
|
|
265
|
+
let disabled;
|
|
266
|
+
let groupId;
|
|
267
|
+
let inputName;
|
|
268
|
+
let label;
|
|
269
|
+
let options;
|
|
270
|
+
let props;
|
|
271
|
+
if ($[1] !== t0) {
|
|
272
|
+
({control, defaultValue, description, disabled, groupId, inputName, label, options, ...props} = t0);
|
|
273
|
+
$[1] = t0;
|
|
274
|
+
$[2] = control;
|
|
275
|
+
$[3] = defaultValue;
|
|
276
|
+
$[4] = description;
|
|
277
|
+
$[5] = disabled;
|
|
278
|
+
$[6] = groupId;
|
|
279
|
+
$[7] = inputName;
|
|
280
|
+
$[8] = label;
|
|
281
|
+
$[9] = options;
|
|
282
|
+
$[10] = props;
|
|
283
|
+
} else {
|
|
284
|
+
control = $[2];
|
|
285
|
+
defaultValue = $[3];
|
|
286
|
+
description = $[4];
|
|
287
|
+
disabled = $[5];
|
|
288
|
+
groupId = $[6];
|
|
289
|
+
inputName = $[7];
|
|
290
|
+
label = $[8];
|
|
291
|
+
options = $[9];
|
|
292
|
+
props = $[10];
|
|
293
|
+
}
|
|
294
|
+
let t1;
|
|
295
|
+
if ($[11] !== defaultValue || $[12] !== description || $[13] !== groupId || $[14] !== inputName || $[15] !== label || $[16] !== options || $[17] !== props) {
|
|
296
|
+
t1 = (t2) => {
|
|
297
|
+
const { field, fieldState } = t2;
|
|
298
|
+
return /* @__PURE__ */ jsxs(FieldSet, {
|
|
299
|
+
"data-invalid": fieldState.invalid,
|
|
300
|
+
...props,
|
|
301
|
+
children: [
|
|
302
|
+
label && /* @__PURE__ */ jsx(FieldLabel, {
|
|
303
|
+
htmlFor: groupId ?? inputName,
|
|
304
|
+
children: label
|
|
305
|
+
}),
|
|
306
|
+
description && /* @__PURE__ */ jsx(FieldDescription, { children: description }),
|
|
307
|
+
/* @__PURE__ */ jsx(ErrorMonitor, { error: fieldState.error }),
|
|
308
|
+
/* @__PURE__ */ jsx(RadioGroup, {
|
|
309
|
+
defaultValue,
|
|
310
|
+
disabled: field.disabled,
|
|
311
|
+
id: groupId ?? (label ? inputName : void 0),
|
|
312
|
+
name: field.name,
|
|
313
|
+
onBlur: field.onBlur,
|
|
314
|
+
onValueChange: field.onChange,
|
|
315
|
+
ref: field.ref,
|
|
316
|
+
children: options.map(_temp$2)
|
|
317
|
+
})
|
|
318
|
+
]
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
$[11] = defaultValue;
|
|
322
|
+
$[12] = description;
|
|
323
|
+
$[13] = groupId;
|
|
324
|
+
$[14] = inputName;
|
|
325
|
+
$[15] = label;
|
|
326
|
+
$[16] = options;
|
|
327
|
+
$[17] = props;
|
|
328
|
+
$[18] = t1;
|
|
329
|
+
} else t1 = $[18];
|
|
330
|
+
let t2;
|
|
331
|
+
if ($[19] !== control || $[20] !== disabled || $[21] !== inputName || $[22] !== t1) {
|
|
332
|
+
t2 = /* @__PURE__ */ jsx(Controller, {
|
|
333
|
+
control,
|
|
334
|
+
disabled,
|
|
335
|
+
name: inputName,
|
|
336
|
+
render: t1
|
|
337
|
+
});
|
|
338
|
+
$[19] = control;
|
|
339
|
+
$[20] = disabled;
|
|
340
|
+
$[21] = inputName;
|
|
341
|
+
$[22] = t1;
|
|
342
|
+
$[23] = t2;
|
|
343
|
+
} else t2 = $[23];
|
|
344
|
+
return t2;
|
|
345
|
+
}
|
|
346
|
+
function _temp$2(option) {
|
|
347
|
+
return /* @__PURE__ */ jsx(Label, {
|
|
348
|
+
className: "rounded-md border ring-ring/50 transition-all hover:bg-accent/50 has-focus-visible:ring-[3px]",
|
|
349
|
+
"data-slot": "field-label",
|
|
350
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
351
|
+
className: "flex w-full items-center gap-3 rounded-md p-3 transition-all has-aria-checked:border-l-8 has-aria-checked:border-ring",
|
|
352
|
+
children: [
|
|
353
|
+
/* @__PURE__ */ jsx(RadioGroupItem, {
|
|
354
|
+
className: "sr-only",
|
|
355
|
+
id: option.id,
|
|
356
|
+
value: option.value
|
|
357
|
+
}),
|
|
358
|
+
option.Icon && /* @__PURE__ */ jsx(option.Icon, {}),
|
|
359
|
+
option.label
|
|
360
|
+
]
|
|
361
|
+
})
|
|
362
|
+
}, option.key ?? option.id ?? option.value);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/components/form.tsx
|
|
367
|
+
function Form({ children, className, defaults = {}, onBefore, onBeforeUpdate, onCancel, onCancelToken, onError, onFinish, onFlash, onPrefetched, onPrefetching, onProgress, onStart, onSuccess, preserveScroll = true, resetOnSuccess = true, rootError: displayRootError = "flash", route, schema, setDefaultsOnSuccess = false }) {
|
|
368
|
+
const [rootError, setRootError] = useState();
|
|
369
|
+
const defaultValues = Object.fromEntries(Object.keys(schema.ruleset).map((field) => [field, defaults[field] ?? ""]));
|
|
370
|
+
const reactForm = useForm({
|
|
371
|
+
defaultValues,
|
|
372
|
+
resolver: useTsvResolver$1(schema)
|
|
373
|
+
});
|
|
374
|
+
const inertiaForm = useForm$1(defaultValues);
|
|
375
|
+
function onErrorWithToast(errors) {
|
|
376
|
+
if (errors.root) {
|
|
377
|
+
if (displayRootError === "flash") flash({
|
|
378
|
+
level: "error",
|
|
379
|
+
title: errors.root
|
|
380
|
+
});
|
|
381
|
+
else if (displayRootError === "monitor") setRootError({ message: errors.root });
|
|
382
|
+
}
|
|
383
|
+
if (onError) onError(errors);
|
|
384
|
+
}
|
|
385
|
+
function onSuccessWithReset(page) {
|
|
386
|
+
if (setDefaultsOnSuccess) {
|
|
387
|
+
inertiaForm.setDefaults();
|
|
388
|
+
reactForm.reset(reactForm.getValues());
|
|
389
|
+
}
|
|
390
|
+
if (resetOnSuccess) {
|
|
391
|
+
inertiaForm.reset();
|
|
392
|
+
reactForm.reset();
|
|
393
|
+
}
|
|
394
|
+
if (onSuccess) onSuccess(page);
|
|
395
|
+
}
|
|
396
|
+
function onSubmit(values) {
|
|
397
|
+
inertiaForm.transform(() => values);
|
|
398
|
+
inertiaForm[route.method](route.url, {
|
|
399
|
+
onBefore,
|
|
400
|
+
onBeforeUpdate,
|
|
401
|
+
onCancel,
|
|
402
|
+
onCancelToken,
|
|
403
|
+
onError: onErrorWithToast,
|
|
404
|
+
onFinish,
|
|
405
|
+
onFlash,
|
|
406
|
+
onPrefetched,
|
|
407
|
+
onPrefetching,
|
|
408
|
+
onProgress,
|
|
409
|
+
onStart,
|
|
410
|
+
onSuccess: onSuccessWithReset,
|
|
411
|
+
preserveScroll
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
useEffect(() => {
|
|
415
|
+
for (const [key, error] of Object.entries(inertiaForm.errors)) if (error) reactForm.setError(key, {
|
|
416
|
+
message: error,
|
|
417
|
+
type: "inertia"
|
|
418
|
+
});
|
|
419
|
+
}, [inertiaForm.errors, reactForm]);
|
|
420
|
+
return /* @__PURE__ */ jsx(I18nextProvider, {
|
|
421
|
+
i18n,
|
|
422
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
423
|
+
action: route.url,
|
|
424
|
+
className: cn("grid gap-6", className),
|
|
425
|
+
method: route.method,
|
|
426
|
+
onSubmit: reactForm.handleSubmit(onSubmit),
|
|
427
|
+
children: [/* @__PURE__ */ jsx(Fragment, { children: children({
|
|
428
|
+
errors: inertiaForm.errors,
|
|
429
|
+
form: reactForm,
|
|
430
|
+
loading: inertiaForm.processing
|
|
431
|
+
}) }), displayRootError === "monitor" && /* @__PURE__ */ jsx(ErrorMonitor, { error: rootError })]
|
|
432
|
+
})
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region src/components/hidden-field.tsx
|
|
438
|
+
function HiddenField({ autoComplete = "off", className, type = "hidden", ...props }) {
|
|
439
|
+
return /* @__PURE__ */ jsx(InputField, {
|
|
440
|
+
autoComplete,
|
|
441
|
+
className: cn("hidden", className),
|
|
442
|
+
type,
|
|
443
|
+
...props
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/components/info-checkbox-field.tsx
|
|
449
|
+
function InfoCheckboxField({ children, className, control, disabled, inputId, inputName, label, onCheckedChange, orientation = "horizontal", readOnly, text, uncheckedValue = "", value = "true", ...props }) {
|
|
450
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
451
|
+
control,
|
|
452
|
+
disabled,
|
|
453
|
+
name: inputName,
|
|
454
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsx(Field, {
|
|
455
|
+
className: cn("block", className),
|
|
456
|
+
"data-invalid": fieldState.invalid,
|
|
457
|
+
orientation,
|
|
458
|
+
...props,
|
|
459
|
+
children: /* @__PURE__ */ jsxs(Label, {
|
|
460
|
+
className: "flex items-start gap-3 rounded-lg border p-3 hover:bg-accent/50 has-aria-checked:border-info-foreground has-aria-checked:bg-info",
|
|
461
|
+
"data-slot": "field-label",
|
|
462
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
463
|
+
"aria-invalid": fieldState.invalid,
|
|
464
|
+
"aria-readonly": readOnly,
|
|
465
|
+
checked: field.value === value,
|
|
466
|
+
className: "aria-readonly:opacity-50 data-[state=checked]:border-info-foreground data-[state=checked]:bg-info-foreground data-[state=checked]:text-white dark:data-[state=checked]:border-info-foreground dark:data-[state=checked]:bg-info-foreground",
|
|
467
|
+
disabled: field.disabled,
|
|
468
|
+
id: inputId,
|
|
469
|
+
name: field.name,
|
|
470
|
+
onBlur: field.onBlur,
|
|
471
|
+
onCheckedChange: (checked) => {
|
|
472
|
+
if (!readOnly) {
|
|
473
|
+
field.onChange(checked === true ? value : uncheckedValue);
|
|
474
|
+
if (onCheckedChange) onCheckedChange(checked, field);
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
ref: field.ref,
|
|
478
|
+
value
|
|
479
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
480
|
+
className: "grid gap-1.5 font-normal",
|
|
481
|
+
children: [
|
|
482
|
+
/* @__PURE__ */ jsx("p", {
|
|
483
|
+
className: "text-sm leading-none font-medium",
|
|
484
|
+
children: label
|
|
485
|
+
}),
|
|
486
|
+
text ? /* @__PURE__ */ jsx("p", {
|
|
487
|
+
className: "text-sm text-muted-foreground",
|
|
488
|
+
children: text
|
|
489
|
+
}) : children,
|
|
490
|
+
/* @__PURE__ */ jsx(ErrorMonitor, { error: fieldState.error })
|
|
491
|
+
]
|
|
492
|
+
})]
|
|
493
|
+
})
|
|
494
|
+
})
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region src/components/nullable-select-field.tsx
|
|
500
|
+
function NullableSelectField(t0) {
|
|
501
|
+
const $ = c(29);
|
|
502
|
+
if ($[0] !== "fa464e82ea599f229aec23b6d5f7a56a07f7b4011320bb3b2b9ddd2f6ed96f93") {
|
|
503
|
+
for (let $i = 0; $i < 29; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
504
|
+
$[0] = "fa464e82ea599f229aec23b6d5f7a56a07f7b4011320bb3b2b9ddd2f6ed96f93";
|
|
505
|
+
}
|
|
506
|
+
let autoComplete;
|
|
507
|
+
let control;
|
|
508
|
+
let description;
|
|
509
|
+
let disabled;
|
|
510
|
+
let inputId;
|
|
511
|
+
let inputName;
|
|
512
|
+
let label;
|
|
513
|
+
let options;
|
|
514
|
+
let placeholder;
|
|
515
|
+
let props;
|
|
516
|
+
let setValue;
|
|
517
|
+
if ($[1] !== t0) {
|
|
518
|
+
({autoComplete, control, description, disabled, inputId, inputName, label, options, placeholder, setValue, ...props} = t0);
|
|
519
|
+
$[1] = t0;
|
|
520
|
+
$[2] = autoComplete;
|
|
521
|
+
$[3] = control;
|
|
522
|
+
$[4] = description;
|
|
523
|
+
$[5] = disabled;
|
|
524
|
+
$[6] = inputId;
|
|
525
|
+
$[7] = inputName;
|
|
526
|
+
$[8] = label;
|
|
527
|
+
$[9] = options;
|
|
528
|
+
$[10] = placeholder;
|
|
529
|
+
$[11] = props;
|
|
530
|
+
$[12] = setValue;
|
|
531
|
+
} else {
|
|
532
|
+
autoComplete = $[2];
|
|
533
|
+
control = $[3];
|
|
534
|
+
description = $[4];
|
|
535
|
+
disabled = $[5];
|
|
536
|
+
inputId = $[6];
|
|
537
|
+
inputName = $[7];
|
|
538
|
+
label = $[8];
|
|
539
|
+
options = $[9];
|
|
540
|
+
placeholder = $[10];
|
|
541
|
+
props = $[11];
|
|
542
|
+
setValue = $[12];
|
|
543
|
+
}
|
|
544
|
+
const { t } = useTranslation();
|
|
545
|
+
let t1;
|
|
546
|
+
if ($[13] !== autoComplete || $[14] !== description || $[15] !== inputId || $[16] !== inputName || $[17] !== label || $[18] !== options || $[19] !== placeholder || $[20] !== props || $[21] !== setValue || $[22] !== t) {
|
|
547
|
+
t1 = (t2) => {
|
|
548
|
+
const { field, fieldState } = t2;
|
|
549
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
550
|
+
"data-invalid": fieldState.invalid,
|
|
551
|
+
...props,
|
|
552
|
+
children: [
|
|
553
|
+
label && /* @__PURE__ */ jsx(FieldLabel, {
|
|
554
|
+
htmlFor: inputId ?? inputName,
|
|
555
|
+
children: label
|
|
556
|
+
}),
|
|
557
|
+
/* @__PURE__ */ jsxs("div", {
|
|
558
|
+
className: "flex items-end gap-4",
|
|
559
|
+
children: [/* @__PURE__ */ jsxs(Select, {
|
|
560
|
+
autoComplete,
|
|
561
|
+
disabled: field.disabled,
|
|
562
|
+
name: field.name,
|
|
563
|
+
onValueChange: field.onChange,
|
|
564
|
+
value: field.value,
|
|
565
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
566
|
+
"aria-invalid": fieldState.invalid,
|
|
567
|
+
className: "flex-1 overflow-hidden",
|
|
568
|
+
id: inputId ?? (label ? inputName : void 0),
|
|
569
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder })
|
|
570
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: options.map(_temp$1) })]
|
|
571
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
572
|
+
"aria-label": t(_temp2),
|
|
573
|
+
className: "flex-none",
|
|
574
|
+
onClick: () => setValue(inputName, ""),
|
|
575
|
+
type: "button",
|
|
576
|
+
variant: "outline",
|
|
577
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
578
|
+
})]
|
|
579
|
+
}),
|
|
580
|
+
description && /* @__PURE__ */ jsx(FieldDescription, { children: description }),
|
|
581
|
+
/* @__PURE__ */ jsx(ErrorMonitor, { error: fieldState.error })
|
|
582
|
+
]
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
$[13] = autoComplete;
|
|
586
|
+
$[14] = description;
|
|
587
|
+
$[15] = inputId;
|
|
588
|
+
$[16] = inputName;
|
|
589
|
+
$[17] = label;
|
|
590
|
+
$[18] = options;
|
|
591
|
+
$[19] = placeholder;
|
|
592
|
+
$[20] = props;
|
|
593
|
+
$[21] = setValue;
|
|
594
|
+
$[22] = t;
|
|
595
|
+
$[23] = t1;
|
|
596
|
+
} else t1 = $[23];
|
|
597
|
+
let t2;
|
|
598
|
+
if ($[24] !== control || $[25] !== disabled || $[26] !== inputName || $[27] !== t1) {
|
|
599
|
+
t2 = /* @__PURE__ */ jsx(Controller, {
|
|
600
|
+
control,
|
|
601
|
+
disabled,
|
|
602
|
+
name: inputName,
|
|
603
|
+
render: t1
|
|
604
|
+
});
|
|
605
|
+
$[24] = control;
|
|
606
|
+
$[25] = disabled;
|
|
607
|
+
$[26] = inputName;
|
|
608
|
+
$[27] = t1;
|
|
609
|
+
$[28] = t2;
|
|
610
|
+
} else t2 = $[28];
|
|
611
|
+
return t2;
|
|
612
|
+
}
|
|
613
|
+
function _temp2($) {
|
|
614
|
+
return $.reset;
|
|
615
|
+
}
|
|
616
|
+
function _temp$1(option) {
|
|
617
|
+
return /* @__PURE__ */ jsx(SelectItem, {
|
|
618
|
+
id: option.id,
|
|
619
|
+
value: option.value,
|
|
620
|
+
children: option.label
|
|
621
|
+
}, option.key ?? option.id ?? option.value);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
//#endregion
|
|
625
|
+
//#region src/components/numeric-field.tsx
|
|
626
|
+
function stepInput(original, add, step, min, max) {
|
|
627
|
+
let parsed = Number(original);
|
|
628
|
+
if (isNaN(parsed)) return "";
|
|
629
|
+
if (add) parsed += step === void 0 ? 1 : step;
|
|
630
|
+
else parsed -= step === void 0 ? 1 : step;
|
|
631
|
+
if (min !== void 0) parsed = Math.max(parsed, min);
|
|
632
|
+
if (max !== void 0) parsed = Math.min(parsed, max);
|
|
633
|
+
return parsed.toString();
|
|
634
|
+
}
|
|
635
|
+
function NumericField({ autoComplete, control, disabled, inputId, inputMode = "numeric", inputName, label, placeholder, type, ui, ...props }) {
|
|
636
|
+
const { t } = useTranslation();
|
|
637
|
+
function stepValue(value, add) {
|
|
638
|
+
if (ui?.setValue) ui.setValue(inputName, stepInput(value, add, ui.step, ui.min, ui.max), { shouldValidate: true });
|
|
639
|
+
}
|
|
640
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
641
|
+
control,
|
|
642
|
+
disabled,
|
|
643
|
+
name: inputName,
|
|
644
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxs(Field, {
|
|
645
|
+
"data-invalid": fieldState.invalid,
|
|
646
|
+
...props,
|
|
647
|
+
children: [
|
|
648
|
+
label && /* @__PURE__ */ jsx(FieldLabel, {
|
|
649
|
+
htmlFor: inputId ?? inputName,
|
|
650
|
+
children: label
|
|
651
|
+
}),
|
|
652
|
+
/* @__PURE__ */ jsxs(InputGroup, { children: [/* @__PURE__ */ jsx(InputGroupInput, {
|
|
653
|
+
"aria-invalid": fieldState.invalid,
|
|
654
|
+
autoComplete,
|
|
655
|
+
id: inputId ?? (label ? inputName : void 0),
|
|
656
|
+
inputMode,
|
|
657
|
+
placeholder,
|
|
658
|
+
type,
|
|
659
|
+
...field
|
|
660
|
+
}), ui && /* @__PURE__ */ jsxs(InputGroupAddon, {
|
|
661
|
+
align: "inline-end",
|
|
662
|
+
children: [/* @__PURE__ */ jsx(InputGroupButton, {
|
|
663
|
+
"aria-label": t(($) => $.decrease),
|
|
664
|
+
disabled,
|
|
665
|
+
onClick: () => stepValue(field.value, false),
|
|
666
|
+
size: "icon-xs",
|
|
667
|
+
children: /* @__PURE__ */ jsx(Minus, {})
|
|
668
|
+
}), /* @__PURE__ */ jsx(InputGroupButton, {
|
|
669
|
+
"aria-label": t(($_0) => $_0.increase),
|
|
670
|
+
disabled,
|
|
671
|
+
onClick: () => stepValue(field.value, true),
|
|
672
|
+
size: "icon-xs",
|
|
673
|
+
children: /* @__PURE__ */ jsx(Plus, {})
|
|
674
|
+
})]
|
|
675
|
+
})] }),
|
|
676
|
+
/* @__PURE__ */ jsx(ErrorMonitor, { error: fieldState.error })
|
|
677
|
+
]
|
|
678
|
+
})
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/components/password-field.tsx
|
|
684
|
+
function PasswordField({ autoComplete = "off", type = "password", ...props }) {
|
|
685
|
+
return /* @__PURE__ */ jsx(InputField, {
|
|
686
|
+
autoComplete,
|
|
687
|
+
type,
|
|
688
|
+
...props
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
//#endregion
|
|
693
|
+
//#region src/components/select-field.tsx
|
|
694
|
+
function SelectField(t0) {
|
|
695
|
+
const $ = c(26);
|
|
696
|
+
if ($[0] !== "5ff5d5548794cbeba39c824ca84a0abfecd4ad7cd87afe79eb9406ec981a0164") {
|
|
697
|
+
for (let $i = 0; $i < 26; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
698
|
+
$[0] = "5ff5d5548794cbeba39c824ca84a0abfecd4ad7cd87afe79eb9406ec981a0164";
|
|
699
|
+
}
|
|
700
|
+
let autoComplete;
|
|
701
|
+
let control;
|
|
702
|
+
let description;
|
|
703
|
+
let disabled;
|
|
704
|
+
let inputId;
|
|
705
|
+
let inputName;
|
|
706
|
+
let label;
|
|
707
|
+
let options;
|
|
708
|
+
let placeholder;
|
|
709
|
+
let props;
|
|
710
|
+
if ($[1] !== t0) {
|
|
711
|
+
({autoComplete, control, description, disabled, inputId, inputName, label, options, placeholder, ...props} = t0);
|
|
712
|
+
$[1] = t0;
|
|
713
|
+
$[2] = autoComplete;
|
|
714
|
+
$[3] = control;
|
|
715
|
+
$[4] = description;
|
|
716
|
+
$[5] = disabled;
|
|
717
|
+
$[6] = inputId;
|
|
718
|
+
$[7] = inputName;
|
|
719
|
+
$[8] = label;
|
|
720
|
+
$[9] = options;
|
|
721
|
+
$[10] = placeholder;
|
|
722
|
+
$[11] = props;
|
|
723
|
+
} else {
|
|
724
|
+
autoComplete = $[2];
|
|
725
|
+
control = $[3];
|
|
726
|
+
description = $[4];
|
|
727
|
+
disabled = $[5];
|
|
728
|
+
inputId = $[6];
|
|
729
|
+
inputName = $[7];
|
|
730
|
+
label = $[8];
|
|
731
|
+
options = $[9];
|
|
732
|
+
placeholder = $[10];
|
|
733
|
+
props = $[11];
|
|
734
|
+
}
|
|
735
|
+
let t1;
|
|
736
|
+
if ($[12] !== autoComplete || $[13] !== description || $[14] !== inputId || $[15] !== inputName || $[16] !== label || $[17] !== options || $[18] !== placeholder || $[19] !== props) {
|
|
737
|
+
t1 = (t2) => {
|
|
738
|
+
const { field, fieldState } = t2;
|
|
739
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
740
|
+
"data-invalid": fieldState.invalid,
|
|
741
|
+
...props,
|
|
742
|
+
children: [
|
|
743
|
+
label && /* @__PURE__ */ jsx(FieldLabel, {
|
|
744
|
+
htmlFor: inputId ?? inputName,
|
|
745
|
+
children: label
|
|
746
|
+
}),
|
|
747
|
+
/* @__PURE__ */ jsxs(Select, {
|
|
748
|
+
autoComplete,
|
|
749
|
+
disabled: field.disabled,
|
|
750
|
+
name: field.name,
|
|
751
|
+
onValueChange: field.onChange,
|
|
752
|
+
value: field.value,
|
|
753
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
754
|
+
"aria-invalid": fieldState.invalid,
|
|
755
|
+
id: inputId ?? (label ? inputName : void 0),
|
|
756
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder })
|
|
757
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: options.map(_temp) })]
|
|
758
|
+
}),
|
|
759
|
+
description && /* @__PURE__ */ jsx(FieldDescription, { children: description }),
|
|
760
|
+
/* @__PURE__ */ jsx(ErrorMonitor, { error: fieldState.error })
|
|
761
|
+
]
|
|
762
|
+
});
|
|
763
|
+
};
|
|
764
|
+
$[12] = autoComplete;
|
|
765
|
+
$[13] = description;
|
|
766
|
+
$[14] = inputId;
|
|
767
|
+
$[15] = inputName;
|
|
768
|
+
$[16] = label;
|
|
769
|
+
$[17] = options;
|
|
770
|
+
$[18] = placeholder;
|
|
771
|
+
$[19] = props;
|
|
772
|
+
$[20] = t1;
|
|
773
|
+
} else t1 = $[20];
|
|
774
|
+
let t2;
|
|
775
|
+
if ($[21] !== control || $[22] !== disabled || $[23] !== inputName || $[24] !== t1) {
|
|
776
|
+
t2 = /* @__PURE__ */ jsx(Controller, {
|
|
777
|
+
control,
|
|
778
|
+
disabled,
|
|
779
|
+
name: inputName,
|
|
780
|
+
render: t1
|
|
781
|
+
});
|
|
782
|
+
$[21] = control;
|
|
783
|
+
$[22] = disabled;
|
|
784
|
+
$[23] = inputName;
|
|
785
|
+
$[24] = t1;
|
|
786
|
+
$[25] = t2;
|
|
787
|
+
} else t2 = $[25];
|
|
788
|
+
return t2;
|
|
789
|
+
}
|
|
790
|
+
function _temp(option) {
|
|
791
|
+
return /* @__PURE__ */ jsx(SelectItem, {
|
|
792
|
+
id: option.id,
|
|
793
|
+
value: option.value,
|
|
794
|
+
children: option.label
|
|
795
|
+
}, option.key ?? option.id ?? option.value);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
//#endregion
|
|
799
|
+
//#region src/components/submit.tsx
|
|
800
|
+
function Submit({ label, loading = false, type = "submit", ...props }) {
|
|
801
|
+
const { t } = useTranslation();
|
|
802
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
803
|
+
disabled: loading,
|
|
804
|
+
type,
|
|
805
|
+
...props,
|
|
806
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
807
|
+
className: "relative",
|
|
808
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
809
|
+
className: cn({ invisible: loading }),
|
|
810
|
+
children: label ?? t(($) => $.submit)
|
|
811
|
+
}), /* @__PURE__ */ jsx(Spinner, { className: cn("trans absolute top-1/2 left-1/2 hidden -translate-x-1/2 -translate-y-1/2", { block: loading }) })]
|
|
812
|
+
})
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
//#endregion
|
|
817
|
+
//#region src/components/switch-field.tsx
|
|
818
|
+
function SwitchField({ control, disabled, inputId, inputName, label, onCheckedChange, orientation = "horizontal", readOnly, uncheckedValue = "", value = "true", ...props }) {
|
|
819
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
820
|
+
control,
|
|
821
|
+
disabled,
|
|
822
|
+
name: inputName,
|
|
823
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxs(Field, {
|
|
824
|
+
"data-invalid": fieldState.invalid,
|
|
825
|
+
orientation,
|
|
826
|
+
...props,
|
|
827
|
+
children: [
|
|
828
|
+
/* @__PURE__ */ jsx(Switch, {
|
|
829
|
+
"aria-invalid": fieldState.invalid,
|
|
830
|
+
"aria-readonly": readOnly,
|
|
831
|
+
checked: field.value === value,
|
|
832
|
+
className: "aria-readonly:opacity-50",
|
|
833
|
+
disabled: field.disabled,
|
|
834
|
+
id: inputId ?? (label ? inputName : void 0),
|
|
835
|
+
name: field.name,
|
|
836
|
+
onBlur: field.onBlur,
|
|
837
|
+
onCheckedChange: (checked) => {
|
|
838
|
+
if (!readOnly) {
|
|
839
|
+
field.onChange(checked === true ? value : uncheckedValue);
|
|
840
|
+
if (onCheckedChange) onCheckedChange(checked, field);
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
ref: field.ref,
|
|
844
|
+
value
|
|
845
|
+
}),
|
|
846
|
+
label && /* @__PURE__ */ jsx(FieldLabel, {
|
|
847
|
+
htmlFor: inputId ?? inputName,
|
|
848
|
+
children: label
|
|
849
|
+
}),
|
|
850
|
+
/* @__PURE__ */ jsx(ErrorMonitor, { error: fieldState.error })
|
|
851
|
+
]
|
|
852
|
+
})
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
//#endregion
|
|
857
|
+
//#region src/components/text-field.tsx
|
|
858
|
+
function TextField({ autoComplete = "on", type = "text", ...props }) {
|
|
859
|
+
return /* @__PURE__ */ jsx(InputField, {
|
|
860
|
+
autoComplete,
|
|
861
|
+
type,
|
|
862
|
+
...props
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
//#endregion
|
|
867
|
+
//#region src/components/textarea-field.tsx
|
|
868
|
+
function TextareaField({ cacheMeasurements, control, inputId, inputName, label, maxRows, minRows, onHeightChange, placeholder, resize = "none", ...props }) {
|
|
869
|
+
return /* @__PURE__ */ jsx(Controller, {
|
|
870
|
+
control,
|
|
871
|
+
name: inputName,
|
|
872
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxs(Field, {
|
|
873
|
+
"data-invalid": fieldState.invalid,
|
|
874
|
+
...props,
|
|
875
|
+
children: [
|
|
876
|
+
label && /* @__PURE__ */ jsx(FieldLabel, {
|
|
877
|
+
htmlFor: inputId ?? inputName,
|
|
878
|
+
children: label
|
|
879
|
+
}),
|
|
880
|
+
/* @__PURE__ */ jsx(TextareaAutosize, {
|
|
881
|
+
"aria-invalid": fieldState.invalid,
|
|
882
|
+
autoComplete: "off",
|
|
883
|
+
cacheMeasurements,
|
|
884
|
+
className: cn({
|
|
885
|
+
resize: resize === "both",
|
|
886
|
+
"resize-none": resize === "none",
|
|
887
|
+
"resize-x": resize === "x",
|
|
888
|
+
"resize-y": resize === "y"
|
|
889
|
+
}),
|
|
890
|
+
id: inputId ?? (label ? inputName : void 0),
|
|
891
|
+
maxRows,
|
|
892
|
+
minRows,
|
|
893
|
+
onHeightChange,
|
|
894
|
+
placeholder,
|
|
895
|
+
...field
|
|
896
|
+
}),
|
|
897
|
+
/* @__PURE__ */ jsx(ErrorMonitor, { error: fieldState.error })
|
|
898
|
+
]
|
|
899
|
+
})
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
//#endregion
|
|
904
|
+
export { CalendarField, CheckboxField, EmailField, ErrorMonitor, FancyRadioField, Form, HiddenField, InfoCheckboxField, InputCheckboxRule, InputColorRule, InputEmailRule, InputField, InputNumberRule, InputRule, InputSelectRule, InputTextRule, Message, NullableSelectField, NumericField, PasswordField, Schema, SelectField, Submit, SwitchField, TextField, TextareaField, i18n, useTsvResolver };
|
|
2
905
|
//# sourceMappingURL=index.mjs.map
|