ivt 0.3.3 → 0.3.4
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/accordion/index.mjs +19 -1
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/alert/index.mjs +43 -1
- package/dist/alert/index.mjs.map +1 -1
- package/dist/alert-dialog/index.mjs +260 -1
- package/dist/alert-dialog/index.mjs.map +1 -1
- package/dist/avatar/index.mjs +164 -1
- package/dist/avatar/index.mjs.map +1 -1
- package/dist/badge/index.mjs +6 -1
- package/dist/badge/index.mjs.map +1 -1
- package/dist/base/index.mjs +760 -1
- package/dist/base/index.mjs.map +1 -1
- package/dist/button/index.mjs +6 -1
- package/dist/button/index.mjs.map +1 -1
- package/dist/calendar/index.mjs +11 -1
- package/dist/calendar/index.mjs.map +1 -1
- package/dist/card/index.mjs +55 -1
- package/dist/card/index.mjs.map +1 -1
- package/dist/chart/index.mjs +17042 -1
- package/dist/chart/index.mjs.map +1 -1
- package/dist/checkbox/index.mjs +223 -1
- package/dist/checkbox/index.mjs.map +1 -1
- package/dist/chunks/_commonjsHelpers-DqEvkrE1.mjs +6 -0
- package/dist/chunks/_commonjsHelpers-DqEvkrE1.mjs.map +1 -0
- package/dist/chunks/accordion-BMP2PSSC.mjs +455 -0
- package/dist/chunks/{accordion-CdshDFZC.mjs.map → accordion-BMP2PSSC.mjs.map} +1 -1
- package/dist/chunks/badge-DxuZhgBF.mjs +57 -0
- package/dist/chunks/{badge-BYqshEmA.mjs.map → badge-DxuZhgBF.mjs.map} +1 -1
- package/dist/chunks/bundle-mjs-tFg__FnT.mjs +4491 -0
- package/dist/chunks/{bundle-mjs-9BXytT_r.mjs.map → bundle-mjs-tFg__FnT.mjs.map} +1 -1
- package/dist/chunks/button-CX0htulo.mjs +47 -0
- package/dist/chunks/{button-DrFZXJ7z.mjs.map → button-CX0htulo.mjs.map} +1 -1
- package/dist/chunks/calendar-B4IV5RyM.mjs +7106 -0
- package/dist/chunks/calendar-B4IV5RyM.mjs.map +1 -0
- package/dist/chunks/check-B7209s3e.mjs +15 -0
- package/dist/chunks/{check-CimnOyD7.mjs.map → check-B7209s3e.mjs.map} +1 -1
- package/dist/chunks/chevron-down-D84DRJBv.mjs +15 -0
- package/dist/chunks/{chevron-down-D3fvbjxE.mjs.map → chevron-down-D84DRJBv.mjs.map} +1 -1
- package/dist/chunks/chevron-left-DtL1t1DJ.mjs +15 -0
- package/dist/chunks/{chevron-left-CrN7DlXg.mjs.map → chevron-left-DtL1t1DJ.mjs.map} +1 -1
- package/dist/chunks/chevron-right-Cdxg1JSQ.mjs +15 -0
- package/dist/chunks/{chevron-right-BMSCuDGK.mjs.map → chevron-right-Cdxg1JSQ.mjs.map} +1 -1
- package/dist/chunks/chevrons-up-down-DtBUG1i8.mjs +22 -0
- package/dist/chunks/{chevrons-up-down-DBgvRkZm.mjs.map → chevrons-up-down-DtBUG1i8.mjs.map} +1 -1
- package/dist/chunks/circle-BLWMZ9yp.mjs +17 -0
- package/dist/chunks/{circle-CGqt18Bd.mjs.map → circle-BLWMZ9yp.mjs.map} +1 -1
- package/dist/chunks/command-C8cVzg-x.mjs +611 -0
- package/dist/chunks/command-C8cVzg-x.mjs.map +1 -0
- package/dist/chunks/createLucideIcon-Ba0IWqsz.mjs +60 -0
- package/dist/chunks/{createLucideIcon-L-tld2uc.mjs.map → createLucideIcon-Ba0IWqsz.mjs.map} +1 -1
- package/dist/chunks/dialog-D9vbxUuQ.mjs +80 -0
- package/dist/chunks/{dialog-36eqHzT3.mjs.map → dialog-D9vbxUuQ.mjs.map} +1 -1
- package/dist/chunks/hover-card-idvDPXrI.mjs +274 -0
- package/dist/chunks/{hover-card-Cnd58du6.mjs.map → hover-card-idvDPXrI.mjs.map} +1 -1
- package/dist/chunks/index-6JUj2Tld.mjs +18 -0
- package/dist/chunks/{index-CRxQlsb9.mjs.map → index-6JUj2Tld.mjs.map} +1 -1
- package/dist/chunks/index-B0IElWB4.mjs +51 -0
- package/dist/chunks/{index-vmPXTidH.mjs.map → index-B0IElWB4.mjs.map} +1 -1
- package/dist/chunks/index-B4VRyyD1.mjs +40 -0
- package/dist/chunks/index-B4VRyyD1.mjs.map +1 -0
- package/dist/chunks/index-BE-_q4IW.mjs +266 -0
- package/dist/chunks/index-BE-_q4IW.mjs.map +1 -0
- package/dist/chunks/index-BNxaLFA6.mjs +216 -0
- package/dist/chunks/{index-LvOFIVGz.mjs.map → index-BNxaLFA6.mjs.map} +1 -1
- package/dist/chunks/index-BZUrHhU8.mjs +7 -0
- package/dist/chunks/{index-CLtWFQL5.mjs.map → index-BZUrHhU8.mjs.map} +1 -1
- package/dist/chunks/index-B_FsTtnF.mjs +110 -0
- package/dist/chunks/{index-CCcl327A.mjs.map → index-B_FsTtnF.mjs.map} +1 -1
- package/dist/chunks/index-CAg47KJ6.mjs +13 -0
- package/dist/chunks/{index-CXszXOf_.mjs.map → index-CAg47KJ6.mjs.map} +1 -1
- package/dist/chunks/index-CXuEm8w1.mjs +12 -0
- package/dist/chunks/{index-CU_y1XAz.mjs.map → index-CXuEm8w1.mjs.map} +1 -1
- package/dist/chunks/index-C_jFwfR_.mjs +77 -0
- package/dist/chunks/{index-CybgQKpz.mjs.map → index-C_jFwfR_.mjs.map} +1 -1
- package/dist/chunks/index-CglX-DNW.mjs +21 -0
- package/dist/chunks/index-CglX-DNW.mjs.map +1 -0
- package/dist/chunks/index-CyMuypYR.mjs +324 -0
- package/dist/chunks/{index-DUNcuWJE.mjs.map → index-CyMuypYR.mjs.map} +1 -1
- package/dist/chunks/index-D0S6rRRE.mjs +50 -0
- package/dist/chunks/{index-w9bxia3O.mjs.map → index-D0S6rRRE.mjs.map} +1 -1
- package/dist/chunks/index-D23BhVQG.mjs +859 -0
- package/dist/chunks/{index-DZHMFdr0.mjs.map → index-D23BhVQG.mjs.map} +1 -1
- package/dist/chunks/index-D2wfJaZh.mjs +145 -0
- package/dist/chunks/index-D2wfJaZh.mjs.map +1 -0
- package/dist/chunks/index-DNvm9MP3.mjs +34 -0
- package/dist/chunks/{index-D2sZp5OP.mjs.map → index-DNvm9MP3.mjs.map} +1 -1
- package/dist/chunks/index-Dm4_czlz.mjs +12 -0
- package/dist/chunks/index-Dm4_czlz.mjs.map +1 -0
- package/dist/chunks/index-PaJVyocC.mjs +151 -0
- package/dist/chunks/index-PaJVyocC.mjs.map +1 -0
- package/dist/chunks/index-kr6_v_F8.mjs +2370 -0
- package/dist/chunks/index-kr6_v_F8.mjs.map +1 -0
- package/dist/chunks/index-sz_BcBbA.mjs +1210 -0
- package/dist/chunks/index-sz_BcBbA.mjs.map +1 -0
- package/dist/chunks/input-DK1slFF1.mjs +14 -0
- package/dist/chunks/{input-85UFztMJ.mjs.map → input-DK1slFF1.mjs.map} +1 -1
- package/dist/chunks/label-D7ONQdHc.mjs +32 -0
- package/dist/chunks/{label-CICFzZIt.mjs.map → label-D7ONQdHc.mjs.map} +1 -1
- package/dist/chunks/pagination-BM_IQ6Qk.mjs +106 -0
- package/dist/chunks/{pagination-CReDQes6.mjs.map → pagination-BM_IQ6Qk.mjs.map} +1 -1
- package/dist/chunks/popover-D3F326FR.mjs +308 -0
- package/dist/chunks/{popover-Cn2ZTvKd.mjs.map → popover-D3F326FR.mjs.map} +1 -1
- package/dist/chunks/progress-BCl5yD5Q.mjs +99 -0
- package/dist/chunks/{progress-CSxQH6-f.mjs.map → progress-BCl5yD5Q.mjs.map} +1 -1
- package/dist/chunks/scroll-area-DB3eUx8V.mjs +791 -0
- package/dist/chunks/scroll-area-DB3eUx8V.mjs.map +1 -0
- package/dist/chunks/select-Cw81y8pT.mjs +104 -0
- package/dist/chunks/{select-BR6_N_Yo.mjs.map → select-Cw81y8pT.mjs.map} +1 -1
- package/dist/chunks/separator-2k1C7RSn.mjs +48 -0
- package/dist/chunks/{separator-BB6-E9Z1.mjs.map → separator-2k1C7RSn.mjs.map} +1 -1
- package/dist/chunks/skeleton-qx8-vr62.mjs +13 -0
- package/dist/chunks/{skeleton-XPWWiaac.mjs.map → skeleton-qx8-vr62.mjs.map} +1 -1
- package/dist/chunks/sortable-D8ayoe_b.mjs +4221 -0
- package/dist/chunks/sortable-D8ayoe_b.mjs.map +1 -0
- package/dist/chunks/table-BDNUhtz-.mjs +62 -0
- package/dist/chunks/{table-LQIHzPHi.mjs.map → table-BDNUhtz-.mjs.map} +1 -1
- package/dist/chunks/toggle-CE2ycSdL.mjs +65 -0
- package/dist/chunks/{toggle-Co72WXGd.mjs.map → toggle-CE2ycSdL.mjs.map} +1 -1
- package/dist/chunks/tooltip-DLD0ycR4.mjs +596 -0
- package/dist/chunks/{tooltip-qX2HjdJP.mjs.map → tooltip-DLD0ycR4.mjs.map} +1 -1
- package/dist/chunks/tslib.es6-BgHLrbno.mjs +61 -0
- package/dist/chunks/{tslib.es6-cMGqxriw.mjs.map → tslib.es6-BgHLrbno.mjs.map} +1 -1
- package/dist/chunks/utils-BUelq9Ro.mjs +42 -0
- package/dist/chunks/utils-BUelq9Ro.mjs.map +1 -0
- package/dist/chunks/x-Bjz0Vo6R.mjs +22 -0
- package/dist/chunks/{x-BNLl0E-E.mjs.map → x-Bjz0Vo6R.mjs.map} +1 -1
- package/dist/combobox/index.mjs +65 -1
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/command/index.mjs +23 -1
- package/dist/command/index.mjs.map +1 -1
- package/dist/data-table/index.mjs +673 -1
- package/dist/data-table/index.mjs.map +1 -1
- package/dist/dialog/index.mjs +22 -1
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/dropdown-menu/index.mjs +438 -1
- package/dist/dropdown-menu/index.mjs.map +1 -1
- package/dist/dropzone/index.mjs +7839 -1
- package/dist/dropzone/index.mjs.map +1 -1
- package/dist/form/index.mjs +649 -1
- package/dist/form/index.mjs.map +1 -1
- package/dist/hover-card/index.mjs +18 -1
- package/dist/hover-card/index.mjs.map +1 -1
- package/dist/icon/index.mjs +317 -1
- package/dist/icon/index.mjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/input/index.mjs +4 -1
- package/dist/input/index.mjs.map +1 -1
- package/dist/ivt.css +1 -1
- package/dist/label/index.mjs +8 -1
- package/dist/label/index.mjs.map +1 -1
- package/dist/menubar/index.mjs +583 -1
- package/dist/menubar/index.mjs.map +1 -1
- package/dist/multi-select/index.mjs +297 -1
- package/dist/multi-select/index.mjs.map +1 -1
- package/dist/pagination/index.mjs +10 -1
- package/dist/pagination/index.mjs.map +1 -1
- package/dist/popover/index.mjs +21 -1
- package/dist/popover/index.mjs.map +1 -1
- package/dist/progress/index.mjs +9 -1
- package/dist/progress/index.mjs.map +1 -1
- package/dist/radio-group/index.mjs +267 -1
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/scroll-area/index.mjs +15 -1
- package/dist/scroll-area/index.mjs.map +1 -1
- package/dist/select/index.mjs +8 -1
- package/dist/select/index.mjs.map +1 -1
- package/dist/separator/index.mjs +8 -1
- package/dist/separator/index.mjs.map +1 -1
- package/dist/sheet/index.mjs +96 -1
- package/dist/sheet/index.mjs.map +1 -1
- package/dist/skeleton/index.mjs +4 -1
- package/dist/skeleton/index.mjs.map +1 -1
- package/dist/sonner/index.mjs +1140 -1
- package/dist/sonner/index.mjs.map +1 -1
- package/dist/sortable/index.mjs +8 -1
- package/dist/sortable/index.mjs.map +1 -1
- package/dist/table/index.mjs +4 -1
- package/dist/table/index.mjs.map +1 -1
- package/dist/tabs/index.mjs +193 -1
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/textarea/index.mjs +13 -1
- package/dist/textarea/index.mjs.map +1 -1
- package/dist/toast/index.mjs +705 -1
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toggle/index.mjs +12 -1
- package/dist/toggle/index.mjs.map +1 -1
- package/dist/toggle-group/index.mjs +219 -1
- package/dist/toggle-group/index.mjs.map +1 -1
- package/dist/tooltip/index.mjs +20 -1
- package/dist/tooltip/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/_commonjsHelpers-6qLFzZa5.mjs +0 -2
- package/dist/chunks/_commonjsHelpers-6qLFzZa5.mjs.map +0 -1
- package/dist/chunks/accordion-CdshDFZC.mjs +0 -2
- package/dist/chunks/badge-BYqshEmA.mjs +0 -2
- package/dist/chunks/bundle-mjs-9BXytT_r.mjs +0 -2
- package/dist/chunks/button-DrFZXJ7z.mjs +0 -2
- package/dist/chunks/calendar-BY6t8wdJ.mjs +0 -2
- package/dist/chunks/calendar-BY6t8wdJ.mjs.map +0 -1
- package/dist/chunks/check-CimnOyD7.mjs +0 -2
- package/dist/chunks/chevron-down-D3fvbjxE.mjs +0 -2
- package/dist/chunks/chevron-left-CrN7DlXg.mjs +0 -2
- package/dist/chunks/chevron-right-BMSCuDGK.mjs +0 -2
- package/dist/chunks/chevrons-up-down-DBgvRkZm.mjs +0 -2
- package/dist/chunks/circle-CGqt18Bd.mjs +0 -2
- package/dist/chunks/command-C6ON-ciq.mjs +0 -2
- package/dist/chunks/command-C6ON-ciq.mjs.map +0 -1
- package/dist/chunks/createLucideIcon-L-tld2uc.mjs +0 -2
- package/dist/chunks/dialog-36eqHzT3.mjs +0 -2
- package/dist/chunks/hover-card-Cnd58du6.mjs +0 -2
- package/dist/chunks/index-B4QsDzeM.mjs +0 -2
- package/dist/chunks/index-B4QsDzeM.mjs.map +0 -1
- package/dist/chunks/index-BdpYc58_.mjs +0 -2
- package/dist/chunks/index-BdpYc58_.mjs.map +0 -1
- package/dist/chunks/index-CCcl327A.mjs +0 -2
- package/dist/chunks/index-CLtWFQL5.mjs +0 -2
- package/dist/chunks/index-COvW87ew.mjs +0 -2
- package/dist/chunks/index-COvW87ew.mjs.map +0 -1
- package/dist/chunks/index-CRxQlsb9.mjs +0 -2
- package/dist/chunks/index-CU_y1XAz.mjs +0 -2
- package/dist/chunks/index-CXszXOf_.mjs +0 -2
- package/dist/chunks/index-CdJCOoFA.mjs +0 -2
- package/dist/chunks/index-CdJCOoFA.mjs.map +0 -1
- package/dist/chunks/index-Cpq7N5Ej.mjs +0 -2
- package/dist/chunks/index-Cpq7N5Ej.mjs.map +0 -1
- package/dist/chunks/index-CybgQKpz.mjs +0 -2
- package/dist/chunks/index-D2sZp5OP.mjs +0 -2
- package/dist/chunks/index-DOyt-JEx.mjs +0 -2
- package/dist/chunks/index-DOyt-JEx.mjs.map +0 -1
- package/dist/chunks/index-DUNcuWJE.mjs +0 -2
- package/dist/chunks/index-DZHMFdr0.mjs +0 -2
- package/dist/chunks/index-LvOFIVGz.mjs +0 -2
- package/dist/chunks/index-lvPXnk5F.mjs +0 -2
- package/dist/chunks/index-lvPXnk5F.mjs.map +0 -1
- package/dist/chunks/index-vmPXTidH.mjs +0 -2
- package/dist/chunks/index-w9bxia3O.mjs +0 -2
- package/dist/chunks/index-xew3kygQ.mjs +0 -2
- package/dist/chunks/index-xew3kygQ.mjs.map +0 -1
- package/dist/chunks/input-85UFztMJ.mjs +0 -2
- package/dist/chunks/label-CICFzZIt.mjs +0 -2
- package/dist/chunks/pagination-CReDQes6.mjs +0 -2
- package/dist/chunks/popover-Cn2ZTvKd.mjs +0 -2
- package/dist/chunks/progress-CSxQH6-f.mjs +0 -2
- package/dist/chunks/scroll-area-CvCz7cL_.mjs +0 -2
- package/dist/chunks/scroll-area-CvCz7cL_.mjs.map +0 -1
- package/dist/chunks/select-BR6_N_Yo.mjs +0 -2
- package/dist/chunks/separator-BB6-E9Z1.mjs +0 -2
- package/dist/chunks/skeleton-XPWWiaac.mjs +0 -2
- package/dist/chunks/sortable-CqPFGn8Q.mjs +0 -2
- package/dist/chunks/sortable-CqPFGn8Q.mjs.map +0 -1
- package/dist/chunks/table-LQIHzPHi.mjs +0 -2
- package/dist/chunks/toggle-Co72WXGd.mjs +0 -2
- package/dist/chunks/tooltip-qX2HjdJP.mjs +0 -2
- package/dist/chunks/tslib.es6-cMGqxriw.mjs +0 -2
- package/dist/chunks/utils-BctauAA9.mjs +0 -2
- package/dist/chunks/utils-BctauAA9.mjs.map +0 -1
- package/dist/chunks/x-BNLl0E-E.mjs +0 -2
package/dist/form/index.mjs
CHANGED
@@ -1,2 +1,650 @@
|
|
1
|
-
import{Slot
|
1
|
+
import { Slot } from '@radix-ui/react-slot';
|
2
|
+
import * as React from 'react';
|
3
|
+
import React__default from 'react';
|
4
|
+
import { c as cn } from '../chunks/utils-BUelq9Ro.mjs';
|
5
|
+
import { L as Label } from '../chunks/label-D7ONQdHc.mjs';
|
6
|
+
import '../chunks/bundle-mjs-tFg__FnT.mjs';
|
7
|
+
import '../chunks/index-D0S6rRRE.mjs';
|
8
|
+
import 'react-dom';
|
9
|
+
import 'react/jsx-runtime';
|
10
|
+
|
11
|
+
var isCheckBoxInput = (element)=>element.type === 'checkbox';
|
12
|
+
var isDateObject = (value1)=>value1 instanceof Date;
|
13
|
+
var isNullOrUndefined = (value1)=>value1 == null;
|
14
|
+
const isObjectType = (value1)=>typeof value1 === 'object';
|
15
|
+
var isObject = (value1)=>!isNullOrUndefined(value1) && !Array.isArray(value1) && isObjectType(value1) && !isDateObject(value1);
|
16
|
+
var getEventValue = (event)=>isObject(event) && event.target ? isCheckBoxInput(event.target) ? event.target.checked : event.target.value : event;
|
17
|
+
var getNodeParentName = (name)=>name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
|
18
|
+
var isNameInFieldArray = (names, name)=>names.has(getNodeParentName(name));
|
19
|
+
var isPlainObject = (tempObject)=>{
|
20
|
+
const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
|
21
|
+
return isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf');
|
22
|
+
};
|
23
|
+
var isWeb = typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined' && typeof document !== 'undefined';
|
24
|
+
function cloneObject(data) {
|
25
|
+
let copy;
|
26
|
+
const isArray = Array.isArray(data);
|
27
|
+
const isFileListInstance = typeof FileList !== 'undefined' ? data instanceof FileList : false;
|
28
|
+
if (data instanceof Date) {
|
29
|
+
copy = new Date(data);
|
30
|
+
} else if (!(isWeb && (data instanceof Blob || isFileListInstance)) && (isArray || isObject(data))) {
|
31
|
+
copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
|
32
|
+
if (!isArray && !isPlainObject(data)) {
|
33
|
+
copy = data;
|
34
|
+
} else {
|
35
|
+
for(const key in data){
|
36
|
+
if (data.hasOwnProperty(key)) {
|
37
|
+
copy[key] = cloneObject(data[key]);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
} else {
|
42
|
+
return data;
|
43
|
+
}
|
44
|
+
return copy;
|
45
|
+
}
|
46
|
+
var isKey = (value1)=>/^\w*$/.test(value1);
|
47
|
+
var isUndefined = (val)=>val === undefined;
|
48
|
+
var compact = (value1)=>Array.isArray(value1) ? value1.filter(Boolean) : [];
|
49
|
+
var stringToPath = (input)=>compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
|
50
|
+
var get = (object, path, defaultValue)=>{
|
51
|
+
if (!path || !isObject(object)) {
|
52
|
+
return defaultValue;
|
53
|
+
}
|
54
|
+
const result = (isKey(path) ? [
|
55
|
+
path
|
56
|
+
] : stringToPath(path)).reduce((result, key)=>isNullOrUndefined(result) ? result : result[key], object);
|
57
|
+
return isUndefined(result) || result === object ? isUndefined(object[path]) ? defaultValue : object[path] : result;
|
58
|
+
};
|
59
|
+
var isBoolean = (value1)=>typeof value1 === 'boolean';
|
60
|
+
var set = (object, path, value1)=>{
|
61
|
+
let index = -1;
|
62
|
+
const tempPath = isKey(path) ? [
|
63
|
+
path
|
64
|
+
] : stringToPath(path);
|
65
|
+
const length = tempPath.length;
|
66
|
+
const lastIndex = length - 1;
|
67
|
+
while(++index < length){
|
68
|
+
const key = tempPath[index];
|
69
|
+
let newValue = value1;
|
70
|
+
if (index !== lastIndex) {
|
71
|
+
const objValue = object[key];
|
72
|
+
newValue = isObject(objValue) || Array.isArray(objValue) ? objValue : !isNaN(+tempPath[index + 1]) ? [] : {};
|
73
|
+
}
|
74
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
object[key] = newValue;
|
78
|
+
object = object[key];
|
79
|
+
}
|
80
|
+
};
|
81
|
+
const EVENTS = {
|
82
|
+
BLUR: 'blur',
|
83
|
+
CHANGE: 'change'
|
84
|
+
};
|
85
|
+
const VALIDATION_MODE = {
|
86
|
+
all: 'all'
|
87
|
+
};
|
88
|
+
const HookFormContext = React__default.createContext(null);
|
89
|
+
HookFormContext.displayName = 'HookFormContext';
|
90
|
+
/**
|
91
|
+
* This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
|
92
|
+
*
|
93
|
+
* @remarks
|
94
|
+
* [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
95
|
+
*
|
96
|
+
* @returns return all useForm methods
|
97
|
+
*
|
98
|
+
* @example
|
99
|
+
* ```tsx
|
100
|
+
* function App() {
|
101
|
+
* const methods = useForm();
|
102
|
+
* const onSubmit = data => console.log(data);
|
103
|
+
*
|
104
|
+
* return (
|
105
|
+
* <FormProvider {...methods} >
|
106
|
+
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
107
|
+
* <NestedInput />
|
108
|
+
* <input type="submit" />
|
109
|
+
* </form>
|
110
|
+
* </FormProvider>
|
111
|
+
* );
|
112
|
+
* }
|
113
|
+
*
|
114
|
+
* function NestedInput() {
|
115
|
+
* const { register } = useFormContext(); // retrieve all hook methods
|
116
|
+
* return <input {...register("test")} />;
|
117
|
+
* }
|
118
|
+
* ```
|
119
|
+
*/ const useFormContext = ()=>React__default.useContext(HookFormContext);
|
120
|
+
/**
|
121
|
+
* A provider component that propagates the `useForm` methods to all children components via [React Context](https://reactjs.org/docs/context.html) API. To be used with {@link useFormContext}.
|
122
|
+
*
|
123
|
+
* @remarks
|
124
|
+
* [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
125
|
+
*
|
126
|
+
* @param props - all useForm methods
|
127
|
+
*
|
128
|
+
* @example
|
129
|
+
* ```tsx
|
130
|
+
* function App() {
|
131
|
+
* const methods = useForm();
|
132
|
+
* const onSubmit = data => console.log(data);
|
133
|
+
*
|
134
|
+
* return (
|
135
|
+
* <FormProvider {...methods} >
|
136
|
+
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
137
|
+
* <NestedInput />
|
138
|
+
* <input type="submit" />
|
139
|
+
* </form>
|
140
|
+
* </FormProvider>
|
141
|
+
* );
|
142
|
+
* }
|
143
|
+
*
|
144
|
+
* function NestedInput() {
|
145
|
+
* const { register } = useFormContext(); // retrieve all hook methods
|
146
|
+
* return <input {...register("test")} />;
|
147
|
+
* }
|
148
|
+
* ```
|
149
|
+
*/ const FormProvider = (props)=>{
|
150
|
+
const { children, ...data } = props;
|
151
|
+
return React__default.createElement(HookFormContext.Provider, {
|
152
|
+
value: data
|
153
|
+
}, children);
|
154
|
+
};
|
155
|
+
var getProxyFormState = (formState, control, localProxyFormState, isRoot = true)=>{
|
156
|
+
const result = {
|
157
|
+
defaultValues: control._defaultValues
|
158
|
+
};
|
159
|
+
for(const key in formState){
|
160
|
+
Object.defineProperty(result, key, {
|
161
|
+
get: ()=>{
|
162
|
+
const _key = key;
|
163
|
+
if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
|
164
|
+
control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
|
165
|
+
}
|
166
|
+
localProxyFormState && (localProxyFormState[_key] = true);
|
167
|
+
return formState[_key];
|
168
|
+
}
|
169
|
+
});
|
170
|
+
}
|
171
|
+
return result;
|
172
|
+
};
|
173
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React__default.useLayoutEffect : React__default.useEffect;
|
174
|
+
/**
|
175
|
+
* This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
|
176
|
+
*
|
177
|
+
* @remarks
|
178
|
+
* [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
|
179
|
+
*
|
180
|
+
* @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
|
181
|
+
*
|
182
|
+
* @example
|
183
|
+
* ```tsx
|
184
|
+
* function App() {
|
185
|
+
* const { register, handleSubmit, control } = useForm({
|
186
|
+
* defaultValues: {
|
187
|
+
* firstName: "firstName"
|
188
|
+
* }});
|
189
|
+
* const { dirtyFields } = useFormState({
|
190
|
+
* control
|
191
|
+
* });
|
192
|
+
* const onSubmit = (data) => console.log(data);
|
193
|
+
*
|
194
|
+
* return (
|
195
|
+
* <form onSubmit={handleSubmit(onSubmit)}>
|
196
|
+
* <input {...register("firstName")} placeholder="First Name" />
|
197
|
+
* {dirtyFields.firstName && <p>Field is dirty.</p>}
|
198
|
+
* <input type="submit" />
|
199
|
+
* </form>
|
200
|
+
* );
|
201
|
+
* }
|
202
|
+
* ```
|
203
|
+
*/ function useFormState(props) {
|
204
|
+
const methods = useFormContext();
|
205
|
+
const { control = methods.control, disabled, name, exact } = props || {};
|
206
|
+
const [formState, updateFormState] = React__default.useState(control._formState);
|
207
|
+
const _localProxyFormState = React__default.useRef({
|
208
|
+
isDirty: false,
|
209
|
+
isLoading: false,
|
210
|
+
dirtyFields: false,
|
211
|
+
touchedFields: false,
|
212
|
+
validatingFields: false,
|
213
|
+
isValidating: false,
|
214
|
+
isValid: false,
|
215
|
+
errors: false
|
216
|
+
});
|
217
|
+
useIsomorphicLayoutEffect(()=>control._subscribe({
|
218
|
+
name,
|
219
|
+
formState: _localProxyFormState.current,
|
220
|
+
exact,
|
221
|
+
callback: (formState)=>{
|
222
|
+
!disabled && updateFormState({
|
223
|
+
...control._formState,
|
224
|
+
...formState
|
225
|
+
});
|
226
|
+
}
|
227
|
+
}), [
|
228
|
+
name,
|
229
|
+
disabled,
|
230
|
+
exact
|
231
|
+
]);
|
232
|
+
React__default.useEffect(()=>{
|
233
|
+
_localProxyFormState.current.isValid && control._setValid(true);
|
234
|
+
}, [
|
235
|
+
control
|
236
|
+
]);
|
237
|
+
return React__default.useMemo(()=>getProxyFormState(formState, control, _localProxyFormState.current, false), [
|
238
|
+
formState,
|
239
|
+
control
|
240
|
+
]);
|
241
|
+
}
|
242
|
+
var isString = (value1)=>typeof value1 === 'string';
|
243
|
+
var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue)=>{
|
244
|
+
if (isString(names)) {
|
245
|
+
return get(formValues, names, defaultValue);
|
246
|
+
}
|
247
|
+
if (Array.isArray(names)) {
|
248
|
+
return names.map((fieldName)=>(get(formValues, fieldName)));
|
249
|
+
}
|
250
|
+
return formValues;
|
251
|
+
};
|
252
|
+
var isPrimitive = (value1)=>isNullOrUndefined(value1) || !isObjectType(value1);
|
253
|
+
function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
|
254
|
+
if (isPrimitive(object1) || isPrimitive(object2)) {
|
255
|
+
return object1 === object2;
|
256
|
+
}
|
257
|
+
if (isDateObject(object1) && isDateObject(object2)) {
|
258
|
+
return object1.getTime() === object2.getTime();
|
259
|
+
}
|
260
|
+
const keys1 = Object.keys(object1);
|
261
|
+
const keys2 = Object.keys(object2);
|
262
|
+
if (keys1.length !== keys2.length) {
|
263
|
+
return false;
|
264
|
+
}
|
265
|
+
if (_internal_visited.has(object1) || _internal_visited.has(object2)) {
|
266
|
+
return true;
|
267
|
+
}
|
268
|
+
_internal_visited.add(object1);
|
269
|
+
_internal_visited.add(object2);
|
270
|
+
for (const key of keys1){
|
271
|
+
const val1 = object1[key];
|
272
|
+
if (!keys2.includes(key)) {
|
273
|
+
return false;
|
274
|
+
}
|
275
|
+
if (key !== 'ref') {
|
276
|
+
const val2 = object2[key];
|
277
|
+
if (isDateObject(val1) && isDateObject(val2) || isObject(val1) && isObject(val2) || Array.isArray(val1) && Array.isArray(val2) ? !deepEqual(val1, val2, _internal_visited) : val1 !== val2) {
|
278
|
+
return false;
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}
|
282
|
+
return true;
|
283
|
+
}
|
284
|
+
/**
|
285
|
+
* Custom hook to subscribe to field change and isolate re-rendering at the component level.
|
286
|
+
*
|
287
|
+
* @remarks
|
288
|
+
*
|
289
|
+
* [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
290
|
+
*
|
291
|
+
* @example
|
292
|
+
* ```tsx
|
293
|
+
* const { control } = useForm();
|
294
|
+
* const values = useWatch({
|
295
|
+
* name: "fieldName"
|
296
|
+
* control,
|
297
|
+
* })
|
298
|
+
* ```
|
299
|
+
*/ function useWatch(props) {
|
300
|
+
const methods = useFormContext();
|
301
|
+
const { control = methods.control, name, defaultValue, disabled, exact, compute } = props || {};
|
302
|
+
const _defaultValue = React__default.useRef(defaultValue);
|
303
|
+
const _compute = React__default.useRef(compute);
|
304
|
+
const _computeFormValues = React__default.useRef(undefined);
|
305
|
+
_compute.current = compute;
|
306
|
+
const defaultValueMemo = React__default.useMemo(()=>control._getWatch(name, _defaultValue.current), [
|
307
|
+
control,
|
308
|
+
name
|
309
|
+
]);
|
310
|
+
const [value1, updateValue] = React__default.useState(_compute.current ? _compute.current(defaultValueMemo) : defaultValueMemo);
|
311
|
+
useIsomorphicLayoutEffect(()=>control._subscribe({
|
312
|
+
name,
|
313
|
+
formState: {
|
314
|
+
values: true
|
315
|
+
},
|
316
|
+
exact,
|
317
|
+
callback: (formState)=>{
|
318
|
+
if (!disabled) {
|
319
|
+
const formValues = generateWatchOutput(name, control._names, formState.values || control._formValues, false, _defaultValue.current);
|
320
|
+
if (_compute.current) {
|
321
|
+
const computedFormValues = _compute.current(formValues);
|
322
|
+
if (!deepEqual(computedFormValues, _computeFormValues.current)) {
|
323
|
+
updateValue(computedFormValues);
|
324
|
+
_computeFormValues.current = computedFormValues;
|
325
|
+
}
|
326
|
+
} else {
|
327
|
+
updateValue(formValues);
|
328
|
+
}
|
329
|
+
}
|
330
|
+
}
|
331
|
+
}), [
|
332
|
+
control,
|
333
|
+
disabled,
|
334
|
+
name,
|
335
|
+
exact
|
336
|
+
]);
|
337
|
+
React__default.useEffect(()=>control._removeUnmounted());
|
338
|
+
return value1;
|
339
|
+
}
|
340
|
+
/**
|
341
|
+
* Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.
|
342
|
+
*
|
343
|
+
* @remarks
|
344
|
+
* [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)
|
345
|
+
*
|
346
|
+
* @param props - the path name to the form field value, and validation rules.
|
347
|
+
*
|
348
|
+
* @returns field properties, field and form state. {@link UseControllerReturn}
|
349
|
+
*
|
350
|
+
* @example
|
351
|
+
* ```tsx
|
352
|
+
* function Input(props) {
|
353
|
+
* const { field, fieldState, formState } = useController(props);
|
354
|
+
* return (
|
355
|
+
* <div>
|
356
|
+
* <input {...field} placeholder={props.name} />
|
357
|
+
* <p>{fieldState.isTouched && "Touched"}</p>
|
358
|
+
* <p>{formState.isSubmitted ? "submitted" : ""}</p>
|
359
|
+
* </div>
|
360
|
+
* );
|
361
|
+
* }
|
362
|
+
* ```
|
363
|
+
*/ function useController(props) {
|
364
|
+
const methods = useFormContext();
|
365
|
+
const { name, disabled, control = methods.control, shouldUnregister, defaultValue } = props;
|
366
|
+
const isArrayField = isNameInFieldArray(control._names.array, name);
|
367
|
+
const defaultValueMemo = React__default.useMemo(()=>get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [
|
368
|
+
control,
|
369
|
+
name,
|
370
|
+
defaultValue
|
371
|
+
]);
|
372
|
+
const value1 = useWatch({
|
373
|
+
control,
|
374
|
+
name,
|
375
|
+
defaultValue: defaultValueMemo,
|
376
|
+
exact: true
|
377
|
+
});
|
378
|
+
const formState = useFormState({
|
379
|
+
control,
|
380
|
+
name,
|
381
|
+
exact: true
|
382
|
+
});
|
383
|
+
const _props = React__default.useRef(props);
|
384
|
+
const _registerProps = React__default.useRef(control.register(name, {
|
385
|
+
...props.rules,
|
386
|
+
value: value1,
|
387
|
+
...isBoolean(props.disabled) ? {
|
388
|
+
disabled: props.disabled
|
389
|
+
} : {}
|
390
|
+
}));
|
391
|
+
_props.current = props;
|
392
|
+
const fieldState = React__default.useMemo(()=>Object.defineProperties({}, {
|
393
|
+
invalid: {
|
394
|
+
enumerable: true,
|
395
|
+
get: ()=>!!get(formState.errors, name)
|
396
|
+
},
|
397
|
+
isDirty: {
|
398
|
+
enumerable: true,
|
399
|
+
get: ()=>!!get(formState.dirtyFields, name)
|
400
|
+
},
|
401
|
+
isTouched: {
|
402
|
+
enumerable: true,
|
403
|
+
get: ()=>!!get(formState.touchedFields, name)
|
404
|
+
},
|
405
|
+
isValidating: {
|
406
|
+
enumerable: true,
|
407
|
+
get: ()=>!!get(formState.validatingFields, name)
|
408
|
+
},
|
409
|
+
error: {
|
410
|
+
enumerable: true,
|
411
|
+
get: ()=>get(formState.errors, name)
|
412
|
+
}
|
413
|
+
}), [
|
414
|
+
formState,
|
415
|
+
name
|
416
|
+
]);
|
417
|
+
const onChange = React__default.useCallback((event)=>_registerProps.current.onChange({
|
418
|
+
target: {
|
419
|
+
value: getEventValue(event),
|
420
|
+
name: name
|
421
|
+
},
|
422
|
+
type: EVENTS.CHANGE
|
423
|
+
}), [
|
424
|
+
name
|
425
|
+
]);
|
426
|
+
const onBlur = React__default.useCallback(()=>_registerProps.current.onBlur({
|
427
|
+
target: {
|
428
|
+
value: get(control._formValues, name),
|
429
|
+
name: name
|
430
|
+
},
|
431
|
+
type: EVENTS.BLUR
|
432
|
+
}), [
|
433
|
+
name,
|
434
|
+
control._formValues
|
435
|
+
]);
|
436
|
+
const ref = React__default.useCallback((elm)=>{
|
437
|
+
const field = get(control._fields, name);
|
438
|
+
if (field && elm) {
|
439
|
+
field._f.ref = {
|
440
|
+
focus: ()=>elm.focus && elm.focus(),
|
441
|
+
select: ()=>elm.select && elm.select(),
|
442
|
+
setCustomValidity: (message)=>elm.setCustomValidity(message),
|
443
|
+
reportValidity: ()=>elm.reportValidity()
|
444
|
+
};
|
445
|
+
}
|
446
|
+
}, [
|
447
|
+
control._fields,
|
448
|
+
name
|
449
|
+
]);
|
450
|
+
const field = React__default.useMemo(()=>({
|
451
|
+
name,
|
452
|
+
value: value1,
|
453
|
+
...isBoolean(disabled) || formState.disabled ? {
|
454
|
+
disabled: formState.disabled || disabled
|
455
|
+
} : {},
|
456
|
+
onChange,
|
457
|
+
onBlur,
|
458
|
+
ref
|
459
|
+
}), [
|
460
|
+
name,
|
461
|
+
disabled,
|
462
|
+
formState.disabled,
|
463
|
+
onChange,
|
464
|
+
onBlur,
|
465
|
+
ref,
|
466
|
+
value1
|
467
|
+
]);
|
468
|
+
React__default.useEffect(()=>{
|
469
|
+
const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
|
470
|
+
control.register(name, {
|
471
|
+
..._props.current.rules,
|
472
|
+
...isBoolean(_props.current.disabled) ? {
|
473
|
+
disabled: _props.current.disabled
|
474
|
+
} : {}
|
475
|
+
});
|
476
|
+
const updateMounted = (name, value1)=>{
|
477
|
+
const field = get(control._fields, name);
|
478
|
+
if (field && field._f) {
|
479
|
+
field._f.mount = value1;
|
480
|
+
}
|
481
|
+
};
|
482
|
+
updateMounted(name, true);
|
483
|
+
if (_shouldUnregisterField) {
|
484
|
+
const value1 = cloneObject(get(control._options.defaultValues, name));
|
485
|
+
set(control._defaultValues, name, value1);
|
486
|
+
if (isUndefined(get(control._formValues, name))) {
|
487
|
+
set(control._formValues, name, value1);
|
488
|
+
}
|
489
|
+
}
|
490
|
+
!isArrayField && control.register(name);
|
491
|
+
return ()=>{
|
492
|
+
(isArrayField ? _shouldUnregisterField && !control._state.action : _shouldUnregisterField) ? control.unregister(name) : updateMounted(name, false);
|
493
|
+
};
|
494
|
+
}, [
|
495
|
+
name,
|
496
|
+
control,
|
497
|
+
isArrayField,
|
498
|
+
shouldUnregister
|
499
|
+
]);
|
500
|
+
React__default.useEffect(()=>{
|
501
|
+
control._setDisabledField({
|
502
|
+
disabled,
|
503
|
+
name
|
504
|
+
});
|
505
|
+
}, [
|
506
|
+
disabled,
|
507
|
+
name,
|
508
|
+
control
|
509
|
+
]);
|
510
|
+
return React__default.useMemo(()=>({
|
511
|
+
field,
|
512
|
+
formState,
|
513
|
+
fieldState
|
514
|
+
}), [
|
515
|
+
field,
|
516
|
+
formState,
|
517
|
+
fieldState
|
518
|
+
]);
|
519
|
+
}
|
520
|
+
/**
|
521
|
+
* Component based on `useController` hook to work with controlled component.
|
522
|
+
*
|
523
|
+
* @remarks
|
524
|
+
* [API](https://react-hook-form.com/docs/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)
|
525
|
+
*
|
526
|
+
* @param props - the path name to the form field value, and validation rules.
|
527
|
+
*
|
528
|
+
* @returns provide field handler functions, field and form state.
|
529
|
+
*
|
530
|
+
* @example
|
531
|
+
* ```tsx
|
532
|
+
* function App() {
|
533
|
+
* const { control } = useForm<FormValues>({
|
534
|
+
* defaultValues: {
|
535
|
+
* test: ""
|
536
|
+
* }
|
537
|
+
* });
|
538
|
+
*
|
539
|
+
* return (
|
540
|
+
* <form>
|
541
|
+
* <Controller
|
542
|
+
* control={control}
|
543
|
+
* name="test"
|
544
|
+
* render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (
|
545
|
+
* <>
|
546
|
+
* <input
|
547
|
+
* onChange={onChange} // send value to hook form
|
548
|
+
* onBlur={onBlur} // notify when input is touched
|
549
|
+
* value={value} // return updated value
|
550
|
+
* ref={ref} // set ref for focus management
|
551
|
+
* />
|
552
|
+
* <p>{formState.isSubmitted ? "submitted" : ""}</p>
|
553
|
+
* <p>{fieldState.isTouched ? "touched" : ""}</p>
|
554
|
+
* </>
|
555
|
+
* )}
|
556
|
+
* />
|
557
|
+
* </form>
|
558
|
+
* );
|
559
|
+
* }
|
560
|
+
* ```
|
561
|
+
*/ const Controller = (props)=>props.render(useController(props));
|
562
|
+
|
563
|
+
const Form = FormProvider;
|
564
|
+
const FormFieldContext = /*#__PURE__*/ React.createContext({});
|
565
|
+
const FormField = ({ ...props })=>{
|
566
|
+
return /*#__PURE__*/ React.createElement(FormFieldContext.Provider, {
|
567
|
+
value: {
|
568
|
+
name: props.name
|
569
|
+
}
|
570
|
+
}, /*#__PURE__*/ React.createElement(Controller, props));
|
571
|
+
};
|
572
|
+
const useFormField = ()=>{
|
573
|
+
const fieldContext = React.useContext(FormFieldContext);
|
574
|
+
const itemContext = React.useContext(FormItemContext);
|
575
|
+
const { getFieldState } = useFormContext();
|
576
|
+
const formState = useFormState({
|
577
|
+
name: fieldContext.name
|
578
|
+
});
|
579
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
580
|
+
if (!fieldContext) {
|
581
|
+
throw new Error("useFormField should be used within <FormField>");
|
582
|
+
}
|
583
|
+
const { id } = itemContext;
|
584
|
+
return {
|
585
|
+
id,
|
586
|
+
name: fieldContext.name,
|
587
|
+
formItemId: `${id}-form-item`,
|
588
|
+
formDescriptionId: `${id}-form-item-description`,
|
589
|
+
formMessageId: `${id}-form-item-message`,
|
590
|
+
...fieldState
|
591
|
+
};
|
592
|
+
};
|
593
|
+
const FormItemContext = /*#__PURE__*/ React.createContext({});
|
594
|
+
function FormItem({ className, ...props }) {
|
595
|
+
const id = React.useId();
|
596
|
+
return /*#__PURE__*/ React.createElement(FormItemContext.Provider, {
|
597
|
+
value: {
|
598
|
+
id
|
599
|
+
}
|
600
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
601
|
+
"data-slot": "form-item",
|
602
|
+
className: cn("grid gap-2", className),
|
603
|
+
...props
|
604
|
+
}));
|
605
|
+
}
|
606
|
+
function FormLabel({ className, ...props }) {
|
607
|
+
const { error, formItemId } = useFormField();
|
608
|
+
return /*#__PURE__*/ React.createElement(Label, {
|
609
|
+
"data-slot": "form-label",
|
610
|
+
"data-error": !!error,
|
611
|
+
className: cn("data-[error=true]:text-destructive", className),
|
612
|
+
htmlFor: formItemId,
|
613
|
+
...props
|
614
|
+
});
|
615
|
+
}
|
616
|
+
function FormControl({ ...props }) {
|
617
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
618
|
+
return /*#__PURE__*/ React.createElement(Slot, {
|
619
|
+
"data-slot": "form-control",
|
620
|
+
id: formItemId,
|
621
|
+
"aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
|
622
|
+
"aria-invalid": !!error,
|
623
|
+
...props
|
624
|
+
});
|
625
|
+
}
|
626
|
+
function FormDescription({ className, ...props }) {
|
627
|
+
const { formDescriptionId } = useFormField();
|
628
|
+
return /*#__PURE__*/ React.createElement("p", {
|
629
|
+
"data-slot": "form-description",
|
630
|
+
id: formDescriptionId,
|
631
|
+
className: cn("text-muted-foreground text-sm", className),
|
632
|
+
...props
|
633
|
+
});
|
634
|
+
}
|
635
|
+
function FormMessage({ className, ...props }) {
|
636
|
+
const { error, formMessageId } = useFormField();
|
637
|
+
const body = error ? String(error?.message ?? "") : props.children;
|
638
|
+
if (!body) {
|
639
|
+
return null;
|
640
|
+
}
|
641
|
+
return /*#__PURE__*/ React.createElement("p", {
|
642
|
+
"data-slot": "form-message",
|
643
|
+
id: formMessageId,
|
644
|
+
className: cn("text-destructive text-sm", className),
|
645
|
+
...props
|
646
|
+
}, body);
|
647
|
+
}
|
648
|
+
|
649
|
+
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
|
2
650
|
//# sourceMappingURL=index.mjs.map
|