react-luna-form 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +201 -0
  2. package/dist/client/cjs/index.js +1 -0
  3. package/dist/client/esm/index.js +1 -0
  4. package/dist/config/cjs/index.js +1 -0
  5. package/dist/config/esm/index.js +1 -0
  6. package/dist/server/cjs/index.js +1 -0
  7. package/dist/server/esm/index.js +1 -0
  8. package/dist/types/client/component/form.d.ts +10 -0
  9. package/dist/types/client/component/input.d.ts +13 -0
  10. package/dist/types/client/component/slot.d.ts +7 -0
  11. package/dist/types/client/component/wrapper/column.d.ts +5 -0
  12. package/dist/types/client/component/wrapper/field.d.ts +7 -0
  13. package/dist/types/client/component/wrapper/with-error.d.ts +3 -0
  14. package/dist/types/client/hook/useDataSource.d.ts +2 -0
  15. package/dist/types/client/hook/useFormAction.d.ts +2 -0
  16. package/dist/types/client/hook/useInput.d.ts +2 -0
  17. package/dist/types/client/hook/useSchema.d.ts +2 -0
  18. package/dist/types/client/index.d.ts +3 -0
  19. package/dist/types/client/lib/error-store.d.ts +7 -0
  20. package/dist/types/component/column.d.ts +7 -0
  21. package/dist/types/component/control.d.ts +3 -0
  22. package/dist/types/component/description.d.ts +3 -0
  23. package/dist/types/component/field-error.d.ts +5 -0
  24. package/dist/types/component/field-set.d.ts +5 -0
  25. package/dist/types/component/field.d.ts +9 -0
  26. package/dist/types/component/form.d.ts +9 -0
  27. package/dist/types/component/group.d.ts +3 -0
  28. package/dist/types/component/input/input-attributes.d.ts +3 -0
  29. package/dist/types/component/input/input-base.d.ts +8 -0
  30. package/dist/types/component/input/input-common.d.ts +2 -0
  31. package/dist/types/component/input/input-option-select.d.ts +5 -0
  32. package/dist/types/component/label.d.ts +5 -0
  33. package/dist/types/component/legend.d.ts +4 -0
  34. package/dist/types/component/separator.d.ts +1 -0
  35. package/dist/types/component/slot/slot-base.d.ts +13 -0
  36. package/dist/types/component/slot/slot.d.ts +6 -0
  37. package/dist/types/config/fetcher.d.ts +2 -0
  38. package/dist/types/config/index.d.ts +9 -0
  39. package/dist/types/server/component/fallback.d.ts +6 -0
  40. package/dist/types/server/component/form.d.ts +9 -0
  41. package/dist/types/server/component/input.d.ts +10 -0
  42. package/dist/types/server/index.d.ts +4 -0
  43. package/dist/types/type.d.ts +112 -0
  44. package/dist/types/util/attributes.d.ts +3 -0
  45. package/dist/types/util/build.d.ts +4 -0
  46. package/dist/types/util/column.d.ts +2 -0
  47. package/dist/types/util/constant.d.ts +25 -0
  48. package/dist/types/util/date.d.ts +10 -0
  49. package/dist/types/util/extract.d.ts +5 -0
  50. package/dist/types/util/helper/input.d.ts +11 -0
  51. package/dist/types/util/is-input.d.ts +14 -0
  52. package/dist/types/util/is-type.d.ts +3 -0
  53. package/dist/types/util/prepare.d.ts +3 -0
  54. package/dist/types/util/schema.d.ts +12 -0
  55. package/package.json +70 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2025] Jonattan Velásquez
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ "use strict";var Bt=Object.create;var E=Object.defineProperty;var Gt=Object.getOwnPropertyDescriptor;var Ht=Object.getOwnPropertyNames;var Wt=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var zt=(e,t)=>{for(var r in t)E(e,r,{get:t[r],enumerable:!0})},J=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ht(t))!$t.call(e,o)&&o!==r&&E(e,o,{get:()=>t[o],enumerable:!(n=Gt(t,o))||n.enumerable});return e};var Zt=(e,t,r)=>(r=e!=null?Bt(Wt(e)):{},J(t||!e||!e.__esModule?E(r,"default",{value:e,enumerable:!0}):r,e)),Kt=e=>J(E({},"__esModule",{value:!0}),e);var yr={};zt(yr,{Form:()=>Yt});module.exports=Kt(yr);var j=require("react/jsx-runtime");function Q(e){return(0,j.jsx)("div",{"data-slot":"field-control",className:"flex w-full flex-row gap-4",children:e.children})}var ee=require("react/jsx-runtime");function A(e){return(0,ee.jsx)("div",{"data-slot":"field-group",className:"flex w-full flex-col gap-8",children:e.children})}var p=require("react/jsx-runtime");function te(e){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:e.title}),(0,p.jsx)("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.description})]})}var y=require("react/jsx-runtime");function re(e){return!e.title&&!e.description?(0,y.jsx)(A,{children:e.children}):(0,y.jsxs)("fieldset",{"data-slot":"field-set",className:"flex flex-col gap-6",children:[(0,y.jsx)(te,{title:e.title,description:e.description}),(0,y.jsx)(A,{children:e.children})]})}var ie=require("react");var U=require("react/jsx-runtime");function ne(){return(0,U.jsx)("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:(0,U.jsx)("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}function F(e=[]){return Array.isArray(e)?e.filter(t=>t.hidden!==!0).sort((t,r)=>oe(t)-oe(r)):[]}function oe(e){return e.order??Number.MAX_VALUE}function I(e){return Object.entries(e??{})}var u=require("react/jsx-runtime");function le(e){let t=F(e.sections);return(0,u.jsx)("div",{className:"h-full w-full",children:(0,u.jsx)("form",{noValidate:e.noValidate,action:e.action,children:(0,u.jsxs)(A,{children:[t.map((r,n)=>(0,u.jsxs)(ie.Fragment,{children:[(0,u.jsx)(re,{description:r.description,title:r.title,children:e.children({disabled:e.readOnly,fields:r.fields})}),r.separator&&(0,u.jsx)(ne,{})]},n)),e.control&&(0,u.jsx)(Q,{children:e.control})]})})})}var ue=require("react/jsx-runtime");function ae(e){return(0,ue.jsx)("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}var Y=require("react/jsx-runtime");function N(e){return!e.errors||e.errors.length===0?null:(0,Y.jsx)("ul",{className:"text-sm text-red-600 dark:text-red-500",id:e.name?`${e.name}-error`:void 0,children:e.errors?.map((t,r)=>(0,Y.jsx)("li",{children:t},e.name?`${e.name}-error-${r}`:r))})}var P=require("jotai"),se=require("jotai-family"),s=(0,P.atom)({}),ce=(0,se.atomFamily)(e=>(0,P.atom)(t=>t(s)[e]??null,(t,r,n)=>{let o=t(s);if(n.length>0)o[e]?.every(l=>n.includes(l))||r(s,{...o,[e]:n});else if(o[e]){let{[e]:i,...l}=o;r(s,l)}})),me=(0,P.atom)(null,(e,t,r)=>{let n=e(s);Jt(n,r)&&t(s,r)});function Jt(e,t){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!0;for(let o of n){let i=e[o],l=t[o];if(!i||i.length!==l.length)return!0;if(i.length>0){let d=new Set(i);if(!l.every(f=>d.has(f)))return!0}}return!1}var ot=require("jotai");var De=Zt(require("swr"),1);function b(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function M(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var q="input",de="input/email",fe="input/number",pe="textarea",X="column",ge="fields",ye="radio",be="value",xe="select",he="select/month",Ae="select/year",B="email",Te="number",Ce="password";var v="text",Se="aria-errormessage",Re="aria-invalid",Ee="data-invalid",Fe="aria",Ie="data";var Ne="minLength",Pe="maxLength";function Me(e,t=be){if(e!=null){if(M(e))return e;if(b(e)){let r=Qt(e,t);if(M(r))return r}}}function Qt(e,t){let r=we(e,t);if(M(r))return r}function ve(e,t){if(Array.isArray(e))return e;let r=we(e,t);return Array.isArray(r)?r:null}function we(e,t){if(!t||!b(e))return null;let r=t.split(".").filter(o=>o!=="");if(r.length===0)return null;let n=e;for(let o of r)if(b(n)&&o in n)n=n[o];else return null;return n}function Le(e=null,t,r=!1){let{data:n}=(0,De.default)(jt(e,r),t.fetcher);if(e){if(Array.isArray(e))return[e];if(n)return[ve(n,e.namespace)]}return[null]}function jt(e=null,t=!1){return e&&!Array.isArray(e)&&!t?e:null}function w(e){return e.type===he}function D(e){return e.type===Ae}function _e(e){return c(e)||G(e)}var Oe=H(q),G=H(ye),c=H(xe);function ke(e){return e.type===X&&ge in e}function Ve(e){return e.type!==X}function Ue(e){return e.type===pe}function Ye(e){return e.type===v||e.type===B||e.type===Ce||e.type==="tel"}function L(e){return e.type===fe||e.type===Te}function qe(e){return e.type===de||e.type===B}function Xe(e=v){if(e){let t=e.match(/[^/]+$/);if(t){let[r]=t;if(r!==q)return r.trim().toLowerCase()}}return v}function H(e){return t=>t.type===e||t.type.startsWith(`${e}/`)}var a=require("zod"),tr=[[L,or],[qe,rr],[D,ir],[w,lr]];function He(e){return a.z.object(e)}function We(e){let t={},r=a.z.flattenError(e).fieldErrors;for(let[n,o]of Object.entries(r))o!==void 0&&(t[n]=o);return t}function $e(e){for(let[t,r]of tr)if(t(e))return r(e);return nr(e)}function rr(e){let t=a.z.email().trim();return e.required?t.min(1,e.validation?.required):t.or(a.z.literal("")).nullable()}function nr(e){let t=a.z.coerce.string().trim();return t=ze(t,e),e.required?(t=Ze(t,e),a.z.preprocess(r=>r===null?"":r,t)):t.nullable()}function or(e){let t=a.z.coerce.number().int();return t=ze(t,e),e.required?(t=Ze(t,e),a.z.preprocess(r=>r===null?void 0:r,t)):t.nullable()}function ir(e){if(e.required){let t=a.z.coerce.number({message:e.validation?.required}).int();return a.z.preprocess(ar,t)}return a.z.coerce.number().int().nullable()}function lr(e){let t=a.z.coerce.number().int().min(1,e.validation?.required).max(12,e.validation?.required);return e.required?t:t.nullable()}function ar(e){return e==null||e===""?void 0:e}function ze(e,t){return e=ur(e,t),e=sr(e,t),e}function Ze(e,t){let r=t.advanced?.length?.min;return r===void 0||r<1?e.min(1,t.validation?.required):e}var ur=(e,t)=>Ke(e,t,"min"),sr=(e,t)=>Ke(e,t,"max");function Ke(e,t,r){let n=t.advanced?.length?.[r];return n!==void 0?e[r](n,t.validation?.length?.[r]):e}var T=require("react");function Je(e,t,r){let n=$e(e),o=(0,T.useEffectEvent)(l=>{l&&t(l,n)}),i=(0,T.useEffectEvent)(l=>{l&&r(l)});return(0,T.useEffect)(()=>(o(e.name),()=>{i(e.name)}),[e.name]),[n]}function Qe(e,t={}){if(c(e)&&e.disabled){let r=e.name?t[e.name]:void 0;if(r&&b(r))return[r]}}function je(e,t){if(t){let r=t[e.name];if(G(e)||c(e)&&!e.disabled)return r}}function et(e){let t=new FormData;for(let[r,n]of Object.entries(e))n!==null&&t.append(r,String(n));return t}function tt(e,t,r){let n=Qe(e,t);return je(e,r)??n}function rt(e,t){return Me(e.name?t?.[e.name]:void 0)}function nt(e,t,r){return _e(e)&&Array.isArray(r)?{...t,options:r}:t}var m=require("react/jsx-runtime");function it(e){let t=rt(e.field,e.value),r=tt(e.field,e.value,e.source),[n,o]=(0,ot.useAtom)(ce(e.field.name)),[i]=Je(e.field,e.onMount,e.onUnmount),[l]=Le(r,e.config,e.field.disabled),d=nt(e.field,e.commonProps,l);function g(h){let R=h.target.value;Z(R)}function f(h){let R=h.target.value;Z(R)}function Z(h){let qt=i.safeParse(h).error?.issues.map(Xt=>Xt.message)??[];o(qt)}let K=e.config.inputs[e.field.type];return K?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(K,{...e.ariaAttributes,...d,...e.dataAttributes,defaultValue:t,onBlur:f,onChange:g}),e.field.description&&(0,m.jsx)(ae,{children:e.field.description}),!e.withinColumn&&(0,m.jsx)(N,{name:e.field.name,errors:n})]}):null}var lt={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},at={1:"col-span-1",2:"col-span-2",3:"col-span-3"};function ut(e,t=2){return lt[e&&e in lt?e:t]}function st(e){if(e&&e in at)return at[e]}var ct=require("tailwind-merge"),C=require("react/jsx-runtime");function mt(e){let t=ut(e.column?.advanced?.cols),r=e.column?.fields??[],n=I(e.errors).filter(([o])=>r.find(i=>i.name===o)).flatMap(([,o])=>o??[]);return(0,C.jsxs)("div",{className:"flex w-full flex-col gap-4",children:[(0,C.jsx)("div",{className:(0,ct.twMerge)("grid grid-cols-1 gap-8 sm:gap-4",t),children:e.children}),(0,C.jsx)(N,{errors:n})]})}var dt=require("jotai"),ft=require("react/jsx-runtime");function _(e){return r=>{let n=(0,dt.useAtomValue)(s);return(0,ft.jsx)(e,{...r,errors:n})}}var pt=_(mt);function gt(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function yt(e,t){return t>=e?Array.from({length:t-e+1},(r,n)=>{let o=e+n;return{value:o.toString(),label:o.toString()}}):[]}function W(){return new Date().getFullYear()}function $(e,t){if(typeof e=="number")return e;let r=t??W(),n=e.trim().toLowerCase();if(n.startsWith("current")){let i=n.split("+");if(i.length===2){let l=parseInt(i[1],10);if(!isNaN(l))return r+l}return r}let o=parseInt(n,10);return isNaN(o)?r:o}var O=W();function bt(e){if(c(e))return cr(e)}function cr(e){if(w(e))return gt();if(D(e)){let t=e.advanced?.length?.min??O,r=e.advanced?.length?.max??O+5;return yt($(t,O),$(r,O))}}function xt(e,t=!1){let r={disabled:t??e.readonly,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return Oe(e)?{...r,...mr(e)}:c(e)?{...r,...dr(e)}:Ue(e)?{...r,...fr(e)}:r}function mr(e){let t=Xe(e.type),r={...e,type:t};return{...ht(e),...pr(r),...Ye(r)?At(r):{},type:t}}function dr(e){let t=bt(e);return t?{options:t}:{}}function fr(e){return{...ht(e),...At(e)}}function ht(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function pr(e){return L(e)?gr(e):{}}function At(e){return Tt(e,{min:Ne,max:Pe})}function gr(e){return Tt(e,{min:"min",max:"max"})}function Tt(e,t){let r={},n=e.advanced?.length;return n&&(n.min!==void 0&&(r[t.min]=n.min),n.max!==void 0&&(r[t.max]=n.max)),r}function Ct(e,t){let r={};for(let[n,o]of I(t))r[`${e}-${n}`]=o;return r}function St(e){return Ct(Fe,e)}function Rt(e){return Ct(Ie,e)}function Et(e,t){let r=St(e.advanced?.aria);return t&&t.length>0&&(r[Re]="true",r[Se]=`${e.name}-error`),r}function Ft(e){return Rt(e.advanced?.data)}function It(e){if(!e.field.type)return null;let t=xt(e.field,e.disabled),r=Ft(e.field),n=Et(e.field,e.errors),o={...e.field,disabled:e.disabled};return e.children({ariaAttributes:n,commonProps:t,dataAttributes:r,field:o,withinColumn:e.withinColumn})}var k=require("react/jsx-runtime");function Nt(e){return(0,k.jsxs)("label",{"data-slot":"field-label",className:"flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",htmlFor:e.name,children:[e.children,!e.required&&(0,k.jsx)("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:"(Optional)"})]})}var Pt=require("tailwind-merge"),S=require("react/jsx-runtime");function Mt(e){let t=e.field.name?e.errors?.[e.field.name]:void 0;return(0,S.jsxs)("div",{...t&&{[Ee]:"true"},"data-slot":"field",className:(0,Pt.twMerge)("flex w-full flex-col gap-3 *:w-full data-[invalid=true]:text-red-500",st(e.field.advanced?.cols)),children:[e.field.name&&e.field.label&&(0,S.jsx)(Nt,{name:e.field.name,required:e.field.required,children:e.field.label}),(0,S.jsx)(It,{disabled:e.disabled,errors:t,field:e.field,withinColumn:e.withinColumn,children:e.children})]})}var vt=_(Mt);var wt=require("react");var x=require("react/jsx-runtime");function z(e){let t=F(e.fields),{column:r,field:n}=e.components;return t.map((o,i)=>(0,x.jsxs)(wt.Fragment,{children:[ke(o)&&(0,x.jsx)(r,{column:o,children:(0,x.jsx)(z,{...e,fields:o.fields,withinColumn:!0})}),Ve(o)&&(0,x.jsx)(n,{disabled:e.disabled,field:o,withinColumn:e.withinColumn,children:e.children})]},i))}var Lt=require("react/jsx-runtime"),Dt=e=>(0,Lt.jsx)(z,{...e,components:{column:pt,field:vt}});var _t=require("react"),Ot=require("jotai");function kt(e,t){let r=(0,Ot.useSetAtom)(me);async function n(o){let i=e(),l=He(i),d=Object.fromEntries(o),g=l.safeParse(d);if(!g.success){let f=We(g.error);(0,_t.startTransition)(()=>{r(f)});return}if(t){let f=et(g.data);await t(f)}}return[n]}var Vt=require("react");function Ut(){let e=(0,Vt.useRef)({});function t(o,i){e.current[o]=i}function r(o){e.current[o]&&delete e.current[o]}function n(){return e.current}return[n,t,r]}var V=require("react/jsx-runtime");function Yt(e){let[t,r,n]=Ut(),[o]=kt(t,e.action);return(0,V.jsx)(le,{action:o,control:e.children,noValidate:!0,readOnly:e.readOnly,sections:e.sections,children:({disabled:i,fields:l})=>(0,V.jsx)(Dt,{disabled:i,fields:l,children:d=>(0,V.jsx)(it,{...d,config:e.config,onMount:r,onUnmount:n,source:e.source,value:e.value})})})}
@@ -0,0 +1 @@
1
+ import{jsx as Rt}from"react/jsx-runtime";function B(e){return Rt("div",{"data-slot":"field-control",className:"flex w-full flex-row gap-4",children:e.children})}import{jsx as Et}from"react/jsx-runtime";function g(e){return Et("div",{"data-slot":"field-group",className:"flex w-full flex-col gap-8",children:e.children})}import{Fragment as Ft,jsx as G,jsxs as It}from"react/jsx-runtime";function H(e){return It(Ft,{children:[G("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:e.title}),G("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.description})]})}import{jsx as N,jsxs as Nt}from"react/jsx-runtime";function W(e){return!e.title&&!e.description?N(g,{children:e.children}):Nt("fieldset",{"data-slot":"field-set",className:"flex flex-col gap-6",children:[N(H,{title:e.title,description:e.description}),N(g,{children:e.children})]})}import{Fragment as Pt}from"react";import{jsx as $}from"react/jsx-runtime";function z(){return $("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:$("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}function x(e=[]){return Array.isArray(e)?e.filter(t=>t.hidden!==!0).sort((t,r)=>Z(t)-Z(r)):[]}function Z(e){return e.order??Number.MAX_VALUE}function h(e){return Object.entries(e??{})}import{jsx as y,jsxs as K}from"react/jsx-runtime";function J(e){let t=x(e.sections);return y("div",{className:"h-full w-full",children:y("form",{noValidate:e.noValidate,action:e.action,children:K(g,{children:[t.map((r,n)=>K(Pt,{children:[y(W,{description:r.description,title:r.title,children:e.children({disabled:e.readOnly,fields:r.fields})}),r.separator&&y(z,{})]},n)),e.control&&y(B,{children:e.control})]})})})}import{jsx as Mt}from"react/jsx-runtime";function Q(e){return Mt("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}import{jsx as j}from"react/jsx-runtime";function A(e){return!e.errors||e.errors.length===0?null:j("ul",{className:"text-sm text-red-600 dark:text-red-500",id:e.name?`${e.name}-error`:void 0,children:e.errors?.map((t,r)=>j("li",{children:t},e.name?`${e.name}-error-${r}`:r))})}import{atom as P}from"jotai";import{atomFamily as vt}from"jotai-family";var u=P({}),ee=vt(e=>P(t=>t(u)[e]??null,(t,r,n)=>{let o=t(u);if(n.length>0)o[e]?.every(l=>n.includes(l))||r(u,{...o,[e]:n});else if(o[e]){let{[e]:i,...l}=o;r(u,l)}})),te=P(null,(e,t,r)=>{let n=e(u);wt(n,r)&&t(u,r)});function wt(e,t){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!0;for(let o of n){let i=e[o],l=t[o];if(!i||i.length!==l.length)return!0;if(i.length>0){let c=new Set(i);if(!l.every(m=>c.has(m)))return!0}}return!1}import{useAtom as $t}from"jotai";import Lt from"swr";function f(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function T(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var M="input",re="input/email",ne="input/number",oe="textarea",v="column",ie="fields",le="radio",ae="value",ue="select",se="select/month",ce="select/year",w="email",me="number",de="password";var C="text",fe="aria-errormessage",pe="aria-invalid",ge="data-invalid",ye="aria",be="data";var xe="minLength",he="maxLength";function Ae(e,t=ae){if(e!=null){if(T(e))return e;if(f(e)){let r=Dt(e,t);if(T(r))return r}}}function Dt(e,t){let r=Ce(e,t);if(T(r))return r}function Te(e,t){if(Array.isArray(e))return e;let r=Ce(e,t);return Array.isArray(r)?r:null}function Ce(e,t){if(!t||!f(e))return null;let r=t.split(".").filter(o=>o!=="");if(r.length===0)return null;let n=e;for(let o of r)if(f(n)&&o in n)n=n[o];else return null;return n}function Se(e=null,t,r=!1){let{data:n}=Lt(_t(e,r),t.fetcher);if(e){if(Array.isArray(e))return[e];if(n)return[Te(n,e.namespace)]}return[null]}function _t(e=null,t=!1){return e&&!Array.isArray(e)&&!t?e:null}function S(e){return e.type===se}function R(e){return e.type===ce}function Re(e){return s(e)||D(e)}var Ee=L(M),D=L(le),s=L(ue);function Fe(e){return e.type===v&&ie in e}function Ie(e){return e.type!==v}function Ne(e){return e.type===oe}function Pe(e){return e.type===C||e.type===w||e.type===de||e.type==="tel"}function E(e){return e.type===ne||e.type===me}function Me(e){return e.type===re||e.type===w}function ve(e=C){if(e){let t=e.match(/[^/]+$/);if(t){let[r]=t;if(r!==M)return r.trim().toLowerCase()}}return C}function L(e){return t=>t.type===e||t.type.startsWith(`${e}/`)}import{z as a}from"zod";var kt=[[E,Yt],[Me,Vt],[R,qt],[S,Xt]];function Le(e){return a.object(e)}function _e(e){let t={},r=a.flattenError(e).fieldErrors;for(let[n,o]of Object.entries(r))o!==void 0&&(t[n]=o);return t}function Oe(e){for(let[t,r]of kt)if(t(e))return r(e);return Ut(e)}function Vt(e){let t=a.email().trim();return e.required?t.min(1,e.validation?.required):t.or(a.literal("")).nullable()}function Ut(e){let t=a.coerce.string().trim();return t=ke(t,e),e.required?(t=Ve(t,e),a.preprocess(r=>r===null?"":r,t)):t.nullable()}function Yt(e){let t=a.coerce.number().int();return t=ke(t,e),e.required?(t=Ve(t,e),a.preprocess(r=>r===null?void 0:r,t)):t.nullable()}function qt(e){if(e.required){let t=a.coerce.number({message:e.validation?.required}).int();return a.preprocess(Bt,t)}return a.coerce.number().int().nullable()}function Xt(e){let t=a.coerce.number().int().min(1,e.validation?.required).max(12,e.validation?.required);return e.required?t:t.nullable()}function Bt(e){return e==null||e===""?void 0:e}function ke(e,t){return e=Gt(e,t),e=Ht(e,t),e}function Ve(e,t){let r=t.advanced?.length?.min;return r===void 0||r<1?e.min(1,t.validation?.required):e}var Gt=(e,t)=>Ue(e,t,"min"),Ht=(e,t)=>Ue(e,t,"max");function Ue(e,t,r){let n=t.advanced?.length?.[r];return n!==void 0?e[r](n,t.validation?.length?.[r]):e}import{useEffect as Wt,useEffectEvent as Ye}from"react";function qe(e,t,r){let n=Oe(e),o=Ye(l=>{l&&t(l,n)}),i=Ye(l=>{l&&r(l)});return Wt(()=>(o(e.name),()=>{i(e.name)}),[e.name]),[n]}function Xe(e,t={}){if(s(e)&&e.disabled){let r=e.name?t[e.name]:void 0;if(r&&f(r))return[r]}}function Be(e,t){if(t){let r=t[e.name];if(D(e)||s(e)&&!e.disabled)return r}}function Ge(e){let t=new FormData;for(let[r,n]of Object.entries(e))n!==null&&t.append(r,String(n));return t}function He(e,t,r){let n=Xe(e,t);return Be(e,r)??n}function We(e,t){return Ae(e.name?t?.[e.name]:void 0)}function $e(e,t,r){return Re(e)&&Array.isArray(r)?{...t,options:r}:t}import{Fragment as zt,jsx as _,jsxs as Zt}from"react/jsx-runtime";function ze(e){let t=We(e.field,e.value),r=He(e.field,e.value,e.source),[n,o]=$t(ee(e.field.name)),[i]=qe(e.field,e.onMount,e.onUnmount),[l]=Se(r,e.config,e.field.disabled),c=$e(e.field,e.commonProps,l);function d(p){let b=p.target.value;q(b)}function m(p){let b=p.target.value;q(b)}function q(p){let Ct=i.safeParse(p).error?.issues.map(St=>St.message)??[];o(Ct)}let X=e.config.inputs[e.field.type];return X?Zt(zt,{children:[_(X,{...e.ariaAttributes,...c,...e.dataAttributes,defaultValue:t,onBlur:m,onChange:d}),e.field.description&&_(Q,{children:e.field.description}),!e.withinColumn&&_(A,{name:e.field.name,errors:n})]}):null}var Ze={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},Ke={1:"col-span-1",2:"col-span-2",3:"col-span-3"};function Je(e,t=2){return Ze[e&&e in Ze?e:t]}function Qe(e){if(e&&e in Ke)return Ke[e]}import{twMerge as Kt}from"tailwind-merge";import{jsx as je,jsxs as Jt}from"react/jsx-runtime";function et(e){let t=Je(e.column?.advanced?.cols),r=e.column?.fields??[],n=h(e.errors).filter(([o])=>r.find(i=>i.name===o)).flatMap(([,o])=>o??[]);return Jt("div",{className:"flex w-full flex-col gap-4",children:[je("div",{className:Kt("grid grid-cols-1 gap-8 sm:gap-4",t),children:e.children}),je(A,{errors:n})]})}import{useAtomValue as Qt}from"jotai";import{jsx as jt}from"react/jsx-runtime";function F(e){return r=>{let n=Qt(u);return jt(e,{...r,errors:n})}}var tt=F(et);function rt(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function nt(e,t){return t>=e?Array.from({length:t-e+1},(r,n)=>{let o=e+n;return{value:o.toString(),label:o.toString()}}):[]}function O(){return new Date().getFullYear()}function k(e,t){if(typeof e=="number")return e;let r=t??O(),n=e.trim().toLowerCase();if(n.startsWith("current")){let i=n.split("+");if(i.length===2){let l=parseInt(i[1],10);if(!isNaN(l))return r+l}return r}let o=parseInt(n,10);return isNaN(o)?r:o}var I=O();function ot(e){if(s(e))return er(e)}function er(e){if(S(e))return rt();if(R(e)){let t=e.advanced?.length?.min??I,r=e.advanced?.length?.max??I+5;return nt(k(t,I),k(r,I))}}function it(e,t=!1){let r={disabled:t??e.readonly,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return Ee(e)?{...r,...tr(e)}:s(e)?{...r,...rr(e)}:Ne(e)?{...r,...nr(e)}:r}function tr(e){let t=ve(e.type),r={...e,type:t};return{...lt(e),...or(r),...Pe(r)?at(r):{},type:t}}function rr(e){let t=ot(e);return t?{options:t}:{}}function nr(e){return{...lt(e),...at(e)}}function lt(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function or(e){return E(e)?ir(e):{}}function at(e){return ut(e,{min:xe,max:he})}function ir(e){return ut(e,{min:"min",max:"max"})}function ut(e,t){let r={},n=e.advanced?.length;return n&&(n.min!==void 0&&(r[t.min]=n.min),n.max!==void 0&&(r[t.max]=n.max)),r}function st(e,t){let r={};for(let[n,o]of h(t))r[`${e}-${n}`]=o;return r}function ct(e){return st(ye,e)}function mt(e){return st(be,e)}function dt(e,t){let r=ct(e.advanced?.aria);return t&&t.length>0&&(r[pe]="true",r[fe]=`${e.name}-error`),r}function ft(e){return mt(e.advanced?.data)}function pt(e){if(!e.field.type)return null;let t=it(e.field,e.disabled),r=ft(e.field),n=dt(e.field,e.errors),o={...e.field,disabled:e.disabled};return e.children({ariaAttributes:n,commonProps:t,dataAttributes:r,field:o,withinColumn:e.withinColumn})}import{jsx as lr,jsxs as ar}from"react/jsx-runtime";function gt(e){return ar("label",{"data-slot":"field-label",className:"flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",htmlFor:e.name,children:[e.children,!e.required&&lr("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:"(Optional)"})]})}import{twMerge as ur}from"tailwind-merge";import{jsx as yt,jsxs as sr}from"react/jsx-runtime";function bt(e){let t=e.field.name?e.errors?.[e.field.name]:void 0;return sr("div",{...t&&{[ge]:"true"},"data-slot":"field",className:ur("flex w-full flex-col gap-3 *:w-full data-[invalid=true]:text-red-500",Qe(e.field.advanced?.cols)),children:[e.field.name&&e.field.label&&yt(gt,{name:e.field.name,required:e.field.required,children:e.field.label}),yt(pt,{disabled:e.disabled,errors:t,field:e.field,withinColumn:e.withinColumn,children:e.children})]})}var xt=F(bt);import{Fragment as cr}from"react";import{jsx as V,jsxs as mr}from"react/jsx-runtime";function U(e){let t=x(e.fields),{column:r,field:n}=e.components;return t.map((o,i)=>mr(cr,{children:[Fe(o)&&V(r,{column:o,children:V(U,{...e,fields:o.fields,withinColumn:!0})}),Ie(o)&&V(n,{disabled:e.disabled,field:o,withinColumn:e.withinColumn,children:e.children})]},i))}import{jsx as dr}from"react/jsx-runtime";var ht=e=>dr(U,{...e,components:{column:tt,field:xt}});import{startTransition as fr}from"react";import{useSetAtom as pr}from"jotai";function At(e,t){let r=pr(te);async function n(o){let i=e(),l=Le(i),c=Object.fromEntries(o),d=l.safeParse(c);if(!d.success){let m=_e(d.error);fr(()=>{r(m)});return}if(t){let m=Ge(d.data);await t(m)}}return[n]}import{useRef as gr}from"react";function Tt(){let e=gr({});function t(o,i){e.current[o]=i}function r(o){e.current[o]&&delete e.current[o]}function n(){return e.current}return[n,t,r]}import{jsx as Y}from"react/jsx-runtime";function yr(e){let[t,r,n]=Tt(),[o]=At(t,e.action);return Y(J,{action:o,control:e.children,noValidate:!0,readOnly:e.readOnly,sections:e.sections,children:({disabled:i,fields:l})=>Y(ht,{disabled:i,fields:l,children:c=>Y(ze,{...c,config:e.config,onMount:r,onUnmount:n,source:e.source,value:e.value})})})}export{yr as Form};
@@ -0,0 +1 @@
1
+ "use strict";var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var l=(n,e)=>{for(var t in e)s(n,t,{get:e[t],enumerable:!0})},m=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of d(e))!y.call(n,r)&&r!==t&&s(n,r,{get:()=>e[r],enumerable:!(o=f(e,r))||o.enumerable});return n};var h=n=>m(s({},"__esModule",{value:!0}),n);var A={};l(A,{defineConfig:()=>I,defineInput:()=>w,defineSelect:()=>S,defineTextArea:()=>D});module.exports=h(A);async function a(n){let[e,t]=T(n),o=n.body,r=b(n);if(o&&!u(t)){let p=x(o);p&&(o=p,r=g(r))}let i=await fetch(e.toString(),{body:E(t,o),cache:n.cache,headers:r,method:t}),c=await i.json();if(i.ok)return c;throw c}function T(n){let e=n.url?.trim();if(!e||!C(e))throw new Error(`Invalid URL: ${n.url}`);let t=new URL(e),o=R(n);return n.body&&u(o)&&Object.entries(n.body).filter(([,r])=>r!==void 0&&r!=="undefined").forEach(([r,i])=>{t.searchParams.append(r,String(i))}),[t,o]}function g(n){return{...n,"Content-Type":"application/json"}}function C(n){return!n.includes("undefined")&&!n.includes("null")}function R(n){return n.method??"GET"}function b(n){return{Accept:"application/json",...n.headers??{}}}function u(n){return n.toUpperCase()==="GET"}function x(n){try{return JSON.stringify(n)}catch{return null}}function E(n,e){if(!u(n))return e}function I(n){let e={env:n.env,fetcher:a,inputs:{}};return n.inputs.forEach(({types:t,input:o})=>{(Array.isArray(t)?t:[t]).forEach(i=>{e.inputs[i]=o})}),e}function w(n){return{types:["input","input/email","input/number","input/password","input/tel","input/text"],input:n}}function D(n){return{types:["textarea"],input:n}}function S(n){return{types:["select","select/year","select/month"],input:n}}
@@ -0,0 +1 @@
1
+ async function p(n){let[e,t]=a(n),r=n.body,o=l(n);if(r&&!s(t)){let c=m(r);c&&(r=c,o=f(o))}let i=await fetch(e.toString(),{body:h(t,r),cache:n.cache,headers:o,method:t}),u=await i.json();if(i.ok)return u;throw u}function a(n){let e=n.url?.trim();if(!e||!d(e))throw new Error(`Invalid URL: ${n.url}`);let t=new URL(e),r=y(n);return n.body&&s(r)&&Object.entries(n.body).filter(([,o])=>o!==void 0&&o!=="undefined").forEach(([o,i])=>{t.searchParams.append(o,String(i))}),[t,r]}function f(n){return{...n,"Content-Type":"application/json"}}function d(n){return!n.includes("undefined")&&!n.includes("null")}function y(n){return n.method??"GET"}function l(n){return{Accept:"application/json",...n.headers??{}}}function s(n){return n.toUpperCase()==="GET"}function m(n){try{return JSON.stringify(n)}catch{return null}}function h(n,e){if(!s(n))return e}function C(n){let e={env:n.env,fetcher:p,inputs:{}};return n.inputs.forEach(({types:t,input:r})=>{(Array.isArray(t)?t:[t]).forEach(i=>{e.inputs[i]=r})}),e}function R(n){return{types:["input","input/email","input/number","input/password","input/tel","input/text"],input:n}}function b(n){return{types:["textarea"],input:n}}function x(n){return{types:["select","select/year","select/month"],input:n}}export{C as defineConfig,R as defineInput,x as defineSelect,b as defineTextArea};
@@ -0,0 +1 @@
1
+ "use strict";var S=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var ot=Object.prototype.hasOwnProperty;var it=(e,t)=>{for(var r in t)S(e,r,{get:t[r],enumerable:!0})},lt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of nt(t))!ot.call(e,o)&&o!==r&&S(e,o,{get:()=>t[o],enumerable:!(n=rt(t,o))||n.enumerable});return e};var at=e=>lt(S({},"__esModule",{value:!0}),e);var At={};it(At,{Fallback:()=>tt,Form:()=>F});module.exports=at(At);var k=require("react/jsx-runtime");function v(e){return(0,k.jsx)("div",{"data-slot":"field-control",className:"flex w-full flex-row gap-4",children:e.children})}var V=require("react/jsx-runtime");function f(e){return(0,V.jsx)("div",{"data-slot":"field-group",className:"flex w-full flex-col gap-8",children:e.children})}var u=require("react/jsx-runtime");function Y(e){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:e.title}),(0,u.jsx)("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.description})]})}var d=require("react/jsx-runtime");function U(e){return!e.title&&!e.description?(0,d.jsx)(f,{children:e.children}):(0,d.jsxs)("fieldset",{"data-slot":"field-set",className:"flex flex-col gap-6",children:[(0,d.jsx)(Y,{title:e.title,description:e.description}),(0,d.jsx)(f,{children:e.children})]})}var B=require("react");var h=require("react/jsx-runtime");function X(){return(0,h.jsx)("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:(0,h.jsx)("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}function y(e=[]){return Array.isArray(e)?e.filter(t=>t.hidden!==!0).sort((t,r)=>G(t)-G(r)):[]}function G(e){return e.order??Number.MAX_VALUE}function b(e){return Object.entries(e??{})}var i=require("react/jsx-runtime");function H(e){let t=y(e.sections);return(0,i.jsx)("div",{className:"h-full w-full",children:(0,i.jsx)("form",{noValidate:e.noValidate,action:e.action,children:(0,i.jsxs)(f,{children:[t.map((r,n)=>(0,i.jsxs)(B.Fragment,{children:[(0,i.jsx)(U,{description:r.description,title:r.title,children:e.children({disabled:e.readOnly,fields:r.fields})}),r.separator&&(0,i.jsx)(X,{})]},n)),e.control&&(0,i.jsx)(v,{children:e.control})]})})})}var q=require("react/jsx-runtime");function $(e){return(0,q.jsx)("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}function c(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function x(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var N="input";var W="input/number",z="textarea",E="column",J="fields",K="radio",Q="value",Z="select",j="select/month",ee="select/year",te="email",re="number",ne="password";var A="text",oe="aria-errormessage",ie="aria-invalid",le="data-invalid",ae="aria",ue="data";var se="minLength",de="maxLength";function ce(e){return e.type===j}function me(e){return e.type===ee}function fe(e){return l(e)||I(e)}var pe=P(N),I=P(K),l=P(Z);function ge(e){return e.type===E&&J in e}function ye(e){return e.type!==E}function be(e){return e.type===z}function xe(e){return e.type===A||e.type===te||e.type===ne||e.type==="tel"}function Ae(e){return e.type===W||e.type===re}function Re(e=A){if(e){let t=e.match(/[^/]+$/);if(t){let[r]=t;if(r!==N)return r.trim().toLowerCase()}}return A}function P(e){return t=>t.type===e||t.type.startsWith(`${e}/`)}function Ce(e,t={}){if(l(e)&&e.disabled){let r=e.name?t[e.name]:void 0;if(r&&c(r))return[r]}}function Te(e,t){if(t){let r=t[e.name];if(I(e)||l(e)&&!e.disabled)return r}}function Fe(e,t=Q){if(e!=null){if(x(e))return e;if(c(e)){let r=st(e,t);if(x(r))return r}}}function st(e,t){let r=dt(e,t);if(x(r))return r}function dt(e,t){if(!t||!c(e))return null;let r=t.split(".").filter(o=>o!=="");if(r.length===0)return null;let n=e;for(let o of r)if(c(n)&&o in n)n=n[o];else return null;return n}function Se(e,t,r){let n=Ce(e,t);return Te(e,r)??n}function he(e,t){return Fe(e.name?t?.[e.name]:void 0)}function Ne(e,t,r){return fe(e)&&Array.isArray(r)?{...t,options:r}:t}var s=require("react/jsx-runtime");function Ee(e){let t=he(e.field,e.value),r=Se(e.field,e.value,e.source),n=Ne(e.field,e.commonProps,r),o=e.config.inputs[e.field.type];return o?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o,{...e.ariaAttributes,...n,...e.dataAttributes,defaultValue:t}),e.field.description&&(0,s.jsx)($,{children:e.field.description})]}):null}var Ie=require("react");var m=require("react/jsx-runtime");function L(e){let t=y(e.fields),{column:r,field:n}=e.components;return t.map((o,a)=>(0,m.jsxs)(Ie.Fragment,{children:[ge(o)&&(0,m.jsx)(r,{column:o,children:(0,m.jsx)(L,{...e,fields:o.fields,withinColumn:!0})}),ye(o)&&(0,m.jsx)(n,{disabled:e.disabled,field:o,withinColumn:e.withinColumn,children:e.children})]},a))}var _=require("react/jsx-runtime");function Pe(e){return!e.errors||e.errors.length===0?null:(0,_.jsx)("ul",{className:"text-sm text-red-600 dark:text-red-500",id:e.name?`${e.name}-error`:void 0,children:e.errors?.map((t,r)=>(0,_.jsx)("li",{children:t},e.name?`${e.name}-error-${r}`:r))})}var Le={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},_e={1:"col-span-1",2:"col-span-2",3:"col-span-3"};function we(e,t=2){return Le[e&&e in Le?e:t]}function Me(e){if(e&&e in _e)return _e[e]}var De=require("tailwind-merge"),p=require("react/jsx-runtime");function Oe(e){let t=we(e.column?.advanced?.cols),r=e.column?.fields??[],n=b(e.errors).filter(([o])=>r.find(a=>a.name===o)).flatMap(([,o])=>o??[]);return(0,p.jsxs)("div",{className:"flex w-full flex-col gap-4",children:[(0,p.jsx)("div",{className:(0,De.twMerge)("grid grid-cols-1 gap-8 sm:gap-4",t),children:e.children}),(0,p.jsx)(Pe,{errors:n})]})}function ve(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function ke(e,t){return t>=e?Array.from({length:t-e+1},(r,n)=>{let o=e+n;return{value:o.toString(),label:o.toString()}}):[]}function w(){return new Date().getFullYear()}function M(e,t){if(typeof e=="number")return e;let r=t??w(),n=e.trim().toLowerCase();if(n.startsWith("current")){let a=n.split("+");if(a.length===2){let O=parseInt(a[1],10);if(!isNaN(O))return r+O}return r}let o=parseInt(n,10);return isNaN(o)?r:o}var R=w();function Ve(e){if(l(e))return ct(e)}function ct(e){if(ce(e))return ve();if(me(e)){let t=e.advanced?.length?.min??R,r=e.advanced?.length?.max??R+5;return ke(M(t,R),M(r,R))}}function Ye(e,t=!1){let r={disabled:t??e.readonly,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return pe(e)?{...r,...pt(e)}:l(e)?{...r,...gt(e)}:be(e)?{...r,...yt(e)}:r}function pt(e){let t=Re(e.type),r={...e,type:t};return{...Ue(e),...bt(r),...xe(r)?Xe(r):{},type:t}}function gt(e){let t=Ve(e);return t?{options:t}:{}}function yt(e){return{...Ue(e),...Xe(e)}}function Ue(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function bt(e){return Ae(e)?xt(e):{}}function Xe(e){return Ge(e,{min:se,max:de})}function xt(e){return Ge(e,{min:"min",max:"max"})}function Ge(e,t){let r={},n=e.advanced?.length;return n&&(n.min!==void 0&&(r[t.min]=n.min),n.max!==void 0&&(r[t.max]=n.max)),r}function Be(e,t){let r={};for(let[n,o]of b(t))r[`${e}-${n}`]=o;return r}function He(e){return Be(ae,e)}function $e(e){return Be(ue,e)}function qe(e,t){let r=He(e.advanced?.aria);return t&&t.length>0&&(r[ie]="true",r[oe]=`${e.name}-error`),r}function We(e){return $e(e.advanced?.data)}function ze(e){if(!e.field.type)return null;let t=Ye(e.field,e.disabled),r=We(e.field),n=qe(e.field,e.errors),o={...e.field,disabled:e.disabled};return e.children({ariaAttributes:n,commonProps:t,dataAttributes:r,field:o,withinColumn:e.withinColumn})}var C=require("react/jsx-runtime");function Je(e){return(0,C.jsxs)("label",{"data-slot":"field-label",className:"flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",htmlFor:e.name,children:[e.children,!e.required&&(0,C.jsx)("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:"(Optional)"})]})}var Ke=require("tailwind-merge"),g=require("react/jsx-runtime");function Qe(e){let t=e.field.name?e.errors?.[e.field.name]:void 0;return(0,g.jsxs)("div",{...t&&{[le]:"true"},"data-slot":"field",className:(0,Ke.twMerge)("flex w-full flex-col gap-3 *:w-full data-[invalid=true]:text-red-500",Me(e.field.advanced?.cols)),children:[e.field.name&&e.field.label&&(0,g.jsx)(Je,{name:e.field.name,required:e.field.required,children:e.field.label}),(0,g.jsx)(ze,{disabled:e.disabled,errors:t,field:e.field,withinColumn:e.withinColumn,children:e.children})]})}var je=require("react/jsx-runtime"),Ze=e=>(0,je.jsx)(L,{...e,components:{column:Oe,field:Qe}});var T=require("react/jsx-runtime");function F(e){return(0,T.jsx)(H,{control:e.children,readOnly:e.readOnly,sections:e.sections,children:({disabled:t,fields:r})=>(0,T.jsx)(Ze,{disabled:t,fields:r,children:n=>(0,T.jsx)(Ee,{...n,config:e.config,source:e.source,value:e.value})})})}var et=require("react");var D=require("react/jsx-runtime");function tt(e){return(0,D.jsx)(et.Suspense,{fallback:(0,D.jsx)(F,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}
@@ -0,0 +1 @@
1
+ import{jsx as $e}from"react/jsx-runtime";function E(e){return $e("div",{"data-slot":"field-control",className:"flex w-full flex-row gap-4",children:e.children})}import{jsx as qe}from"react/jsx-runtime";function u(e){return qe("div",{"data-slot":"field-group",className:"flex w-full flex-col gap-8",children:e.children})}import{Fragment as We,jsx as I,jsxs as ze}from"react/jsx-runtime";function P(e){return ze(We,{children:[I("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:e.title}),I("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.description})]})}import{jsx as g,jsxs as Je}from"react/jsx-runtime";function L(e){return!e.title&&!e.description?g(u,{children:e.children}):Je("fieldset",{"data-slot":"field-set",className:"flex flex-col gap-6",children:[g(P,{title:e.title,description:e.description}),g(u,{children:e.children})]})}import{Fragment as Ke}from"react";import{jsx as _}from"react/jsx-runtime";function w(){return _("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:_("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}function d(e=[]){return Array.isArray(e)?e.filter(t=>t.hidden!==!0).sort((t,r)=>M(t)-M(r)):[]}function M(e){return e.order??Number.MAX_VALUE}function c(e){return Object.entries(e??{})}import{jsx as s,jsxs as D}from"react/jsx-runtime";function O(e){let t=d(e.sections);return s("div",{className:"h-full w-full",children:s("form",{noValidate:e.noValidate,action:e.action,children:D(u,{children:[t.map((r,n)=>D(Ke,{children:[s(L,{description:r.description,title:r.title,children:e.children({disabled:e.readOnly,fields:r.fields})}),r.separator&&s(w,{})]},n)),e.control&&s(E,{children:e.control})]})})})}import{jsx as Qe}from"react/jsx-runtime";function v(e){return Qe("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}function a(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function m(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}var y="input";var k="input/number",V="textarea",b="column",Y="fields",U="radio",X="value",G="select",B="select/month",H="select/year",$="email",q="number",W="password";var f="text",z="aria-errormessage",J="aria-invalid",K="data-invalid",Q="aria",Z="data";var j="minLength",ee="maxLength";function te(e){return e.type===B}function re(e){return e.type===H}function ne(e){return i(e)||x(e)}var oe=A(y),x=A(U),i=A(G);function ie(e){return e.type===b&&Y in e}function le(e){return e.type!==b}function ae(e){return e.type===V}function ue(e){return e.type===f||e.type===$||e.type===W||e.type==="tel"}function se(e){return e.type===k||e.type===q}function de(e=f){if(e){let t=e.match(/[^/]+$/);if(t){let[r]=t;if(r!==y)return r.trim().toLowerCase()}}return f}function A(e){return t=>t.type===e||t.type.startsWith(`${e}/`)}function ce(e,t={}){if(i(e)&&e.disabled){let r=e.name?t[e.name]:void 0;if(r&&a(r))return[r]}}function me(e,t){if(t){let r=t[e.name];if(x(e)||i(e)&&!e.disabled)return r}}function fe(e,t=X){if(e!=null){if(m(e))return e;if(a(e)){let r=je(e,t);if(m(r))return r}}}function je(e,t){let r=et(e,t);if(m(r))return r}function et(e,t){if(!t||!a(e))return null;let r=t.split(".").filter(o=>o!=="");if(r.length===0)return null;let n=e;for(let o of r)if(a(n)&&o in n)n=n[o];else return null;return n}function pe(e,t,r){let n=ce(e,t);return me(e,r)??n}function ge(e,t){return fe(e.name?t?.[e.name]:void 0)}function ye(e,t,r){return ne(e)&&Array.isArray(r)?{...t,options:r}:t}import{Fragment as tt,jsx as be,jsxs as rt}from"react/jsx-runtime";function xe(e){let t=ge(e.field,e.value),r=pe(e.field,e.value,e.source),n=ye(e.field,e.commonProps,r),o=e.config.inputs[e.field.type];return o?rt(tt,{children:[be(o,{...e.ariaAttributes,...n,...e.dataAttributes,defaultValue:t}),e.field.description&&be(v,{children:e.field.description})]}):null}import{Fragment as nt}from"react";import{jsx as R,jsxs as ot}from"react/jsx-runtime";function C(e){let t=d(e.fields),{column:r,field:n}=e.components;return t.map((o,l)=>ot(nt,{children:[ie(o)&&R(r,{column:o,children:R(C,{...e,fields:o.fields,withinColumn:!0})}),le(o)&&R(n,{disabled:e.disabled,field:o,withinColumn:e.withinColumn,children:e.children})]},l))}import{jsx as Ae}from"react/jsx-runtime";function Re(e){return!e.errors||e.errors.length===0?null:Ae("ul",{className:"text-sm text-red-600 dark:text-red-500",id:e.name?`${e.name}-error`:void 0,children:e.errors?.map((t,r)=>Ae("li",{children:t},e.name?`${e.name}-error-${r}`:r))})}var Ce={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},Te={1:"col-span-1",2:"col-span-2",3:"col-span-3"};function Fe(e,t=2){return Ce[e&&e in Ce?e:t]}function Se(e){if(e&&e in Te)return Te[e]}import{twMerge as it}from"tailwind-merge";import{jsx as he,jsxs as lt}from"react/jsx-runtime";function Ne(e){let t=Fe(e.column?.advanced?.cols),r=e.column?.fields??[],n=c(e.errors).filter(([o])=>r.find(l=>l.name===o)).flatMap(([,o])=>o??[]);return lt("div",{className:"flex w-full flex-col gap-4",children:[he("div",{className:it("grid grid-cols-1 gap-8 sm:gap-4",t),children:e.children}),he(Re,{errors:n})]})}function Ee(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function Ie(e,t){return t>=e?Array.from({length:t-e+1},(r,n)=>{let o=e+n;return{value:o.toString(),label:o.toString()}}):[]}function T(){return new Date().getFullYear()}function F(e,t){if(typeof e=="number")return e;let r=t??T(),n=e.trim().toLowerCase();if(n.startsWith("current")){let l=n.split("+");if(l.length===2){let N=parseInt(l[1],10);if(!isNaN(N))return r+N}return r}let o=parseInt(n,10);return isNaN(o)?r:o}var p=T();function Pe(e){if(i(e))return at(e)}function at(e){if(te(e))return Ee();if(re(e)){let t=e.advanced?.length?.min??p,r=e.advanced?.length?.max??p+5;return Ie(F(t,p),F(r,p))}}function Le(e,t=!1){let r={disabled:t??e.readonly,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return oe(e)?{...r,...dt(e)}:i(e)?{...r,...ct(e)}:ae(e)?{...r,...mt(e)}:r}function dt(e){let t=de(e.type),r={...e,type:t};return{..._e(e),...ft(r),...ue(r)?we(r):{},type:t}}function ct(e){let t=Pe(e);return t?{options:t}:{}}function mt(e){return{..._e(e),...we(e)}}function _e(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function ft(e){return se(e)?pt(e):{}}function we(e){return Me(e,{min:j,max:ee})}function pt(e){return Me(e,{min:"min",max:"max"})}function Me(e,t){let r={},n=e.advanced?.length;return n&&(n.min!==void 0&&(r[t.min]=n.min),n.max!==void 0&&(r[t.max]=n.max)),r}function De(e,t){let r={};for(let[n,o]of c(t))r[`${e}-${n}`]=o;return r}function Oe(e){return De(Q,e)}function ve(e){return De(Z,e)}function ke(e,t){let r=Oe(e.advanced?.aria);return t&&t.length>0&&(r[J]="true",r[z]=`${e.name}-error`),r}function Ve(e){return ve(e.advanced?.data)}function Ye(e){if(!e.field.type)return null;let t=Le(e.field,e.disabled),r=Ve(e.field),n=ke(e.field,e.errors),o={...e.field,disabled:e.disabled};return e.children({ariaAttributes:n,commonProps:t,dataAttributes:r,field:o,withinColumn:e.withinColumn})}import{jsx as gt,jsxs as yt}from"react/jsx-runtime";function Ue(e){return yt("label",{"data-slot":"field-label",className:"flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",htmlFor:e.name,children:[e.children,!e.required&&gt("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:"(Optional)"})]})}import{twMerge as bt}from"tailwind-merge";import{jsx as Xe,jsxs as xt}from"react/jsx-runtime";function Ge(e){let t=e.field.name?e.errors?.[e.field.name]:void 0;return xt("div",{...t&&{[K]:"true"},"data-slot":"field",className:bt("flex w-full flex-col gap-3 *:w-full data-[invalid=true]:text-red-500",Se(e.field.advanced?.cols)),children:[e.field.name&&e.field.label&&Xe(Ue,{name:e.field.name,required:e.field.required,children:e.field.label}),Xe(Ye,{disabled:e.disabled,errors:t,field:e.field,withinColumn:e.withinColumn,children:e.children})]})}import{jsx as At}from"react/jsx-runtime";var Be=e=>At(C,{...e,components:{column:Ne,field:Ge}});import{jsx as S}from"react/jsx-runtime";function h(e){return S(O,{control:e.children,readOnly:e.readOnly,sections:e.sections,children:({disabled:t,fields:r})=>S(Be,{disabled:t,fields:r,children:n=>S(xe,{...n,config:e.config,source:e.source,value:e.value})})})}import{Suspense as Rt}from"react";import{jsx as He}from"react/jsx-runtime";function Ct(e){return He(Rt,{fallback:He(h,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}export{Ct as Fallback,h as Form};
@@ -0,0 +1,10 @@
1
+ import type { Sections, Config, Source } from '../../type';
2
+ export declare function Form(props: Readonly<{
3
+ action?: (formData: FormData) => Promise<void> | void;
4
+ children?: React.ReactNode;
5
+ config: Config;
6
+ readOnly?: boolean;
7
+ sections: Sections;
8
+ source?: Source;
9
+ value?: Record<string, unknown>;
10
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { AriaAttributes, CommonProps, Config, DataAttributes, Field, Schema, Source } from '../../type';
2
+ export declare function Input(props: Readonly<{
3
+ ariaAttributes?: AriaAttributes;
4
+ commonProps: CommonProps;
5
+ config: Config;
6
+ dataAttributes?: DataAttributes;
7
+ field: Field;
8
+ onMount: (name: string, schema: Schema) => void;
9
+ onUnmount: (name: string) => void;
10
+ source?: Source;
11
+ value?: Record<string, unknown>;
12
+ withinColumn?: boolean;
13
+ }>): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,7 @@
1
+ import type { Children, Fields } from '../../type';
2
+ export declare const Slot: (props: Readonly<{
3
+ children: Children;
4
+ disabled?: boolean;
5
+ fields?: Fields;
6
+ withinColumn?: boolean;
7
+ }>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export declare const Column: (props: Readonly<Omit<Readonly<{
2
+ children?: React.ReactNode;
3
+ column?: import("../../../type").Column<import("../../../type").Field>;
4
+ errors?: Record<string, string[]>;
5
+ }>, "errors">>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ export declare const Field: (props: Readonly<Omit<Readonly<{
2
+ children: import("../../../type").Children;
3
+ disabled?: boolean;
4
+ errors?: Record<string, string[]>;
5
+ field: import("../../../type").Field;
6
+ withinColumn?: boolean;
7
+ }>, "errors">>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare function withErrors<P extends {
2
+ errors?: Record<string, string[]>;
3
+ }>(Component: React.ComponentType<P>): (props: Readonly<Omit<P, "errors">>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { Config, DataSource, Nullable } from '../../type';
2
+ export declare function useDataSource<T>(dataSource: Nullable<DataSource | T[]> | undefined, config: Config, disabled?: boolean): [Nullable<T[]>];
@@ -0,0 +1,2 @@
1
+ import type { Schemas } from '../../type';
2
+ export declare function useFormAction(getSchema: () => Schemas, action?: (formData: FormData) => Promise<void> | void): readonly [(formData: FormData) => Promise<void>];
@@ -0,0 +1,2 @@
1
+ import type { Field, Schema } from '../../type';
2
+ export declare function useInput(field: Field, onMount: (name: string, schema: Schema) => void, onUnmount: (name: string) => void): readonly [import("zod").ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>];
@@ -0,0 +1,2 @@
1
+ import type { Schema, Schemas } from '../../type';
2
+ export declare function useSchema(): readonly [() => Schemas, (name: string, schema: Schema) => void, (name: string) => void];
@@ -0,0 +1,3 @@
1
+ import { Form } from './component/form';
2
+ export { Form };
3
+ export type { Sections, Source } from '../type';
@@ -0,0 +1,7 @@
1
+ export declare const inputErrorAtom: import("jotai").PrimitiveAtom<Record<string, string[]>> & {
2
+ init: Record<string, string[]>;
3
+ };
4
+ export declare const reportInputErrorAtom: import("jotai-family").AtomFamily<string, import("jotai").WritableAtom<string[], [errors: string[]], void>>;
5
+ export declare const reportErrorAtom: import("jotai").WritableAtom<null, [error: Record<string, string[]>], void> & {
6
+ init: null;
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { Column, Field } from '../type';
2
+ export type ColumnProps = Readonly<{
3
+ children?: React.ReactNode;
4
+ column?: Column<Field>;
5
+ errors?: Record<string, string[]>;
6
+ }>;
7
+ export declare function Column(props: ColumnProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare function Control(props: Readonly<{
2
+ children?: React.ReactNode;
3
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare function Description(props: Readonly<{
2
+ children: string;
3
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import type { Nullable } from '../type';
2
+ export declare function FieldError(props: Readonly<{
3
+ errors?: Nullable<string[]>;
4
+ name?: string;
5
+ }>): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,5 @@
1
+ export declare function FieldSet(props: Readonly<{
2
+ children?: React.ReactNode;
3
+ description?: string;
4
+ title?: string;
5
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import type { Children, Field } from '../type';
2
+ export type FieldProps = Readonly<{
3
+ children: Children;
4
+ disabled?: boolean;
5
+ errors?: Record<string, string[]>;
6
+ field: Field;
7
+ withinColumn?: boolean;
8
+ }>;
9
+ export declare function Field(props: FieldProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import type { Sections, Slot } from '../type';
2
+ export declare function Form(props: Readonly<{
3
+ action?: (formData: FormData) => void;
4
+ children: Slot;
5
+ control?: React.ReactNode;
6
+ noValidate?: boolean;
7
+ readOnly?: boolean;
8
+ sections: Sections;
9
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare function Group(props: Readonly<{
2
+ children?: React.ReactNode;
3
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import type { Field } from '../../type';
2
+ export declare function buildAriaAttributes(field: Field, errors?: string[]): Record<string, string | number | boolean>;
3
+ export declare function buildDataAttributes(field: Field): Record<string, string | number | boolean>;
@@ -0,0 +1,8 @@
1
+ import type { Children, Field } from '../../type';
2
+ export declare function InputBase(props: Readonly<{
3
+ children: Children;
4
+ disabled?: boolean;
5
+ errors?: string[];
6
+ field: Field;
7
+ withinColumn?: boolean;
8
+ }>): import("react").ReactNode;
@@ -0,0 +1,2 @@
1
+ import type { CommonProps, Field } from '../../type';
2
+ export declare function buildCommon(field: Field, disabled?: boolean): CommonProps;
@@ -0,0 +1,5 @@
1
+ import type { Field } from '../../type';
2
+ export declare function buildOptionSelect(field: Field): {
3
+ value: string;
4
+ label: string;
5
+ }[] | undefined;
@@ -0,0 +1,5 @@
1
+ export declare function Label(props: Readonly<{
2
+ children?: React.ReactNode;
3
+ name: string;
4
+ required?: boolean;
5
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export declare function Legend(props: Readonly<{
2
+ title?: string;
3
+ description?: string;
4
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function Separator(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { Children, Fields } from '../../type';
2
+ import type { ColumnProps } from '../column';
3
+ import type { FieldProps } from '../field';
4
+ export declare function SlotBase<T extends {
5
+ column: React.ComponentType<ColumnProps>;
6
+ field: React.ComponentType<FieldProps>;
7
+ }>(props: Readonly<{
8
+ children: Children;
9
+ disabled?: boolean;
10
+ fields?: Fields;
11
+ withinColumn?: boolean;
12
+ components: T;
13
+ }>): import("react/jsx-runtime").JSX.Element[];
@@ -0,0 +1,6 @@
1
+ import type { Children, Fields } from '../../type';
2
+ export declare const Slot: (props: Readonly<{
3
+ children: Children;
4
+ disabled?: boolean;
5
+ fields?: Fields;
6
+ }>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { DataSource } from '../type';
2
+ export declare function fetcher(dataSource: DataSource): Promise<any>;
@@ -0,0 +1,9 @@
1
+ import type { Config, DataSource, Environment, InputConfig } from '../type';
2
+ export declare function defineConfig<T extends React.ElementType>(options: Readonly<{
3
+ env?: Environment;
4
+ fetcher?: <T>(dataSource: DataSource) => Promise<T>;
5
+ inputs: Array<InputConfig<T>>;
6
+ }>): Config;
7
+ export declare function defineInput<T extends React.ElementType>(input: React.ComponentProps<T>): InputConfig<T>;
8
+ export declare function defineTextArea<T extends React.ElementType>(input: React.ComponentProps<T>): InputConfig<T>;
9
+ export declare function defineSelect<T extends React.ElementType>(input: React.ComponentProps<T>): InputConfig<T>;
@@ -0,0 +1,6 @@
1
+ import type { Config, Sections } from '../../type';
2
+ export declare function Fallback(props: Readonly<{
3
+ children: React.ReactNode;
4
+ config: Config;
5
+ sections: Sections;
6
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import type { Sections, Config, Source } from '../../type';
2
+ export declare function Form(props: Readonly<{
3
+ children?: React.ReactNode;
4
+ config: Config;
5
+ readOnly?: boolean;
6
+ sections: Sections;
7
+ source?: Source;
8
+ value?: Record<string, unknown>;
9
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import type { AriaAttributes, CommonProps, DataAttributes, Field, Config, Source } from '../../type';
2
+ export declare function Input(props: Readonly<{
3
+ ariaAttributes?: AriaAttributes;
4
+ commonProps: CommonProps;
5
+ config: Config;
6
+ dataAttributes?: DataAttributes;
7
+ field: Field;
8
+ source?: Source;
9
+ value?: Record<string, unknown>;
10
+ }>): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ import { Form } from './component/form';
2
+ import { Fallback } from './component/fallback';
3
+ export { Form, Fallback };
4
+ export type { Sections, Source } from '../type';
@@ -0,0 +1,112 @@
1
+ import type { z } from 'zod';
2
+ export type Nullable<T> = T | null;
3
+ export type Orderable = {
4
+ order?: number;
5
+ };
6
+ export type Hideable = {
7
+ hidden?: boolean;
8
+ };
9
+ export type Sections = Section[];
10
+ export type Value = string | number | readonly string[];
11
+ export type Fields = Array<Field | Column<Field>>;
12
+ export type Base = Orderable & Hideable;
13
+ export type Section = {
14
+ description?: string;
15
+ fields?: Fields;
16
+ separator?: boolean;
17
+ title?: string;
18
+ } & Base;
19
+ export type DataSource = {
20
+ url: string;
21
+ body?: BodyInit | Record<string, unknown>;
22
+ cache?: RequestCache;
23
+ headers?: HeadersInit;
24
+ method?: string;
25
+ namespace?: string;
26
+ };
27
+ export type Source = {
28
+ [key: string]: DataSource | Array<unknown>;
29
+ };
30
+ export type Column<T> = {
31
+ advanced?: {
32
+ cols?: number;
33
+ };
34
+ type: 'column';
35
+ fields?: T[];
36
+ } & Base;
37
+ export type DataAttributes = {
38
+ [key: `data-${string}`]: string | number | boolean;
39
+ };
40
+ export type AriaAttributes = {
41
+ [key: `aria-${string}`]: string | number | boolean;
42
+ };
43
+ export type CommonProps = {
44
+ disabled?: boolean;
45
+ id?: string;
46
+ name: string;
47
+ placeholder?: string;
48
+ required?: boolean;
49
+ };
50
+ export type Field = CommonProps & {
51
+ advanced?: {
52
+ aria?: AriaAttributes;
53
+ cols?: number;
54
+ data?: DataAttributes;
55
+ };
56
+ description?: string;
57
+ label?: string;
58
+ readonly?: boolean;
59
+ type: string;
60
+ validation?: {
61
+ required?: string;
62
+ length?: {
63
+ max?: string;
64
+ min?: string;
65
+ };
66
+ };
67
+ } & Base;
68
+ export type Input = Field & {
69
+ advanced?: {
70
+ autocomplete?: string;
71
+ length?: {
72
+ max?: number;
73
+ min?: number;
74
+ };
75
+ };
76
+ };
77
+ export type Select = Field & {
78
+ advanced?: {
79
+ length?: {
80
+ min?: number | string;
81
+ max?: number | string;
82
+ };
83
+ };
84
+ };
85
+ export type Slot = (props: {
86
+ disabled?: boolean;
87
+ fields?: Fields;
88
+ withinColumn?: boolean;
89
+ }) => React.ReactNode;
90
+ export type Children = (props: {
91
+ ariaAttributes?: AriaAttributes;
92
+ commonProps: CommonProps;
93
+ dataAttributes?: DataAttributes;
94
+ field: Field;
95
+ withinColumn?: boolean;
96
+ }) => React.ReactNode;
97
+ export type Schema = z.ZodTypeAny;
98
+ export type Schemas = Record<string, Schema>;
99
+ export type Environment = {
100
+ [key: string]: Value;
101
+ };
102
+ export type InputConfig<T extends React.ElementType> = {
103
+ types: string | string[];
104
+ input: React.ComponentProps<T>;
105
+ };
106
+ export type Config = {
107
+ env?: Environment;
108
+ inputs: {
109
+ [key: string]: React.ComponentProps<React.ElementType>;
110
+ };
111
+ fetcher: <T>(dataSource: DataSource) => Promise<T>;
112
+ };
@@ -0,0 +1,3 @@
1
+ export declare function getPrefixedAttributes(prefix: string, record?: Record<string, string | number | boolean>): Record<string, string | number | boolean>;
2
+ export declare function getAriaAttributes(record?: Record<string, string | number | boolean>): Record<string, string | number | boolean>;
3
+ export declare function getDataAttributes(record?: Record<string, string | number | boolean>): Record<string, string | number | boolean>;
@@ -0,0 +1,4 @@
1
+ import type { Field, Source } from '../type';
2
+ export declare function buildOptions(field: Field, values?: Record<string, unknown>): Record<string, unknown>[] | undefined;
3
+ export declare function buildSource(field: Field, source?: Source): import("../type").DataSource | unknown[] | undefined;
4
+ export declare function buildFormData(form: Record<string, unknown>): FormData;
@@ -0,0 +1,2 @@
1
+ export declare function getColumn(value?: number, defaultCols?: number): string;
2
+ export declare function getSpan(value?: number): string | undefined;
@@ -0,0 +1,25 @@
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_TEXTAREA = "textarea";
5
+ export declare const COLUMN = "column";
6
+ export declare const FIELDS = "fields";
7
+ export declare const RADIO = "radio";
8
+ export declare const VALUE = "value";
9
+ export declare const SELECT = "select";
10
+ export declare const SELECT_MONTH = "select/month";
11
+ export declare const SELECT_YEAR = "select/year";
12
+ export declare const TYPE_EMAIL = "email";
13
+ export declare const TYPE_NUMBER = "number";
14
+ export declare const TYPE_PASSWORD = "password";
15
+ export declare const TYPE_TEL = "tel";
16
+ export declare const TYPE_TEXT = "text";
17
+ export declare const ARIA_ERROR_MESSAGE = "aria-errormessage";
18
+ export declare const ARIA_INVALID = "aria-invalid";
19
+ export declare const DATA_INVALID = "data-invalid";
20
+ export declare const PREFIX_ARIA = "aria";
21
+ export declare const PREFIX_DATA = "data";
22
+ export declare const MIN = "min";
23
+ export declare const MAX = "max";
24
+ export declare const MIN_LENGTH = "minLength";
25
+ export declare const MAX_LENGTH = "maxLength";
@@ -0,0 +1,10 @@
1
+ export declare function getMonth(): {
2
+ value: string;
3
+ label: string;
4
+ }[];
5
+ export declare function getYear(min: number, max: number): Array<{
6
+ value: string;
7
+ label: string;
8
+ }>;
9
+ export declare function getCurrentYear(): number;
10
+ export declare function getConvert(value: string | number, current?: number): number;
@@ -0,0 +1,5 @@
1
+ import type { Nullable, Value } from '../type';
2
+ export declare function getCurrentValue<T>(value: T, entity?: string): Value | undefined;
3
+ export declare function getValue<T>(value: Record<string, T>, namespace?: string): T | undefined;
4
+ export declare function getArray<T>(value: Record<string, T> | T[], namespace?: string): Nullable<T[]>;
5
+ export declare function extract<T>(value: Record<string, T>, namespace?: string): T | null;
@@ -0,0 +1,11 @@
1
+ import type { CommonProps, DataSource, Field, Nullable, Source } from '../../type';
2
+ export declare function resolveSource(field: Field, value?: Record<string, unknown>, source?: Source): DataSource | unknown[] | undefined;
3
+ export declare function getValue(field: Field, value?: Record<string, unknown>): import("../../type").Value | undefined;
4
+ export declare function mergeCommonProps(field: Field, commonProps: CommonProps, options?: Nullable<DataSource | unknown[]>): CommonProps | {
5
+ options: unknown[];
6
+ disabled?: boolean;
7
+ id?: string;
8
+ name: string;
9
+ placeholder?: string;
10
+ required?: boolean;
11
+ };
@@ -0,0 +1,14 @@
1
+ import type { Column, Field, Input, Select } from '../type';
2
+ export declare function isSelectMonth(field: Field): boolean;
3
+ export declare function isSelectYear(field: Field): boolean;
4
+ export declare function isOptions(field: Field): field is Input;
5
+ export declare const isInput: (field: Field) => field is Input;
6
+ export declare const isRadio: (field: Field) => field is Select;
7
+ export declare const isSelect: (field: Field) => field is Select;
8
+ export declare function isColumn(slot: Field | Column<Field>): slot is Column<Field>;
9
+ export declare function isField(slot: Field | Column<Field>): slot is Field;
10
+ export declare function isTextArea(field: Field): field is Input;
11
+ export declare function isText(field: Field): field is Input;
12
+ export declare function isNumber(field: Field): field is Input;
13
+ export declare function isEmail(field: Field): field is Input;
14
+ export declare function getType(value?: string): string;
@@ -0,0 +1,3 @@
1
+ import type { Value } from '../type';
2
+ export declare function isObject<T>(value: unknown): value is Record<string, T>;
3
+ export declare function isValue(value: unknown): value is Value;
@@ -0,0 +1,3 @@
1
+ import type { Base, Nullable } from '../type';
2
+ export declare function prepare<T extends Base>(base?: readonly T[]): any[];
3
+ export declare function entries<T>(values?: Nullable<Record<string, T>>): [key: string, value: T][];
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ import type { Input, Schemas } from '../type';
3
+ export declare function buildSchema(schemas: Schemas): z.ZodObject<{
4
+ [x: string]: import("../type").Schema;
5
+ }, z.core.$strip>;
6
+ export declare function flatten(error: z.ZodError<Record<string, unknown>>): Record<string, string[]>;
7
+ export declare function getSchema(input: Input): z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
8
+ export declare function getEmail(input: Input): z.ZodEmail | z.ZodNullable<z.ZodUnion<[z.ZodEmail, z.ZodLiteral<"">]>>;
9
+ export declare function getText(input: Input): z.ZodPipe<z.ZodTransform<{} | undefined, unknown>, z.ZodCoercedString<unknown>> | z.ZodNullable<z.ZodCoercedString<unknown>>;
10
+ export declare function getNumber(input: Input): z.ZodPipe<z.ZodTransform<{} | undefined, unknown>, z.ZodCoercedNumber<unknown>> | z.ZodNullable<z.ZodCoercedNumber<unknown>>;
11
+ export declare function getYear(input: Input): z.ZodPipe<z.ZodTransform<{} | undefined, unknown>, z.ZodCoercedNumber<unknown>> | z.ZodNullable<z.ZodCoercedNumber<unknown>>;
12
+ export declare function getMonth(input: Input): z.ZodCoercedNumber<unknown> | z.ZodNullable<z.ZodCoercedNumber<unknown>>;
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "react-luna-form",
3
+ "version": "0.0.1",
4
+ "description": "A React library for building forms based on JSON Schema with validation powered by Zod.",
5
+ "main": "./dist/client/cjs/index.js",
6
+ "module": "./dist/client/esm/index.js",
7
+ "types": "./dist/types/client/index.d.ts",
8
+ "type": "module",
9
+ "sideEffects": false,
10
+ "keywords": [
11
+ "forms",
12
+ "json-schema",
13
+ "react",
14
+ "validation"
15
+ ],
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "peerDependencies": {
20
+ "jotai": "^2.0.0",
21
+ "jotai-family": "^1.0.0",
22
+ "react": "^18.2.0 || ^19.0.0",
23
+ "react-dom": "^18.2.0 || ^19.0.0",
24
+ "swr": "^2.3.0",
25
+ "tailwind-merge": "^3.4.0",
26
+ "zod": "^4.0.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/react": "19.2.7",
30
+ "@types/react-dom": "19.2.3",
31
+ "eslint-plugin-react": "7.37.5",
32
+ "eslint-plugin-react-hooks": "7.0.1",
33
+ "eslint-plugin-react-refresh": "0.4.25"
34
+ },
35
+ "license": "Apache-2.0",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/jonattanva/luna.git",
39
+ "directory": "packages/luna-react"
40
+ },
41
+ "exports": {
42
+ "./package.json": "./package.json",
43
+ ".": {
44
+ "types": "./dist/types/client/index.d.ts",
45
+ "import": "./dist/client/esm/index.js",
46
+ "require": "./dist/client/cjs/index.js",
47
+ "default": "./dist/client/cjs/index.js"
48
+ },
49
+ "./server": {
50
+ "types": "./dist/types/server/index.d.ts",
51
+ "import": "./dist/server/esm/index.js",
52
+ "require": "./dist/server/cjs/index.js",
53
+ "default": "./dist/server/cjs/index.js"
54
+ },
55
+ "./config": {
56
+ "types": "./dist/types/config/index.d.ts",
57
+ "import": "./dist/config/esm/index.js",
58
+ "require": "./dist/config/cjs/index.js",
59
+ "default": "./dist/config/cjs/index.js"
60
+ }
61
+ },
62
+ "scripts": {
63
+ "build": "node esbuild.mjs && pnpm run types",
64
+ "lint": "eslint . --cache",
65
+ "prettier:check": "prettier --check .",
66
+ "prettier:fix": "prettier --write .",
67
+ "types": "tsc --project tsconfig.json --declaration --emitDeclarationOnly --declarationDir dist/types",
68
+ "typescript": "tsc --noEmit"
69
+ }
70
+ }