@mage-ui/components 0.0.70 → 0.0.72
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/components/controls/date-picker/DatePicker.d.ts +2 -0
- package/dist/components/controls/date-picker/DatePicker.d.ts.map +1 -1
- package/dist/components/controls/date-picker/DatePicker.js +1 -1
- package/dist/components/controls/date-picker/DatePicker.js.map +1 -1
- package/dist/components/forms/form/Form.d.ts +10 -0
- package/dist/components/forms/form/Form.d.ts.map +1 -1
- package/dist/components/forms/form/Form.js +1 -1
- package/dist/components/forms/form/Form.js.map +1 -1
- package/dist/components/forms/form/controls/FormControl.js +2 -0
- package/dist/components/forms/form/controls/FormControl.js.map +1 -0
- package/package.json +3 -3
|
@@ -11,6 +11,7 @@ type DatePickerProps = {
|
|
|
11
11
|
error?: string;
|
|
12
12
|
classNames?: DatePickerClassNames;
|
|
13
13
|
value?: DatePickerValue;
|
|
14
|
+
locale?: string;
|
|
14
15
|
onChange?: (date: Date | string | null) => void;
|
|
15
16
|
};
|
|
16
17
|
declare const DatePicker: ({
|
|
@@ -19,6 +20,7 @@ declare const DatePicker: ({
|
|
|
19
20
|
placeholder,
|
|
20
21
|
description,
|
|
21
22
|
icon,
|
|
23
|
+
locale,
|
|
22
24
|
...props
|
|
23
25
|
}: DatePickerProps) => ReactNode;
|
|
24
26
|
type DatePickerClassNames = InputClassNamesType & CalenderHeaderClassNamesType & CalendarMonthClassNamesType & CalendarMonthsListClassNamesType & CalendarYearsListClassNamesType & PopoverClassNamesType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","names":[],"sources":["../../../../src/components/controls/date-picker/DatePicker.tsx"],"sourcesContent":[],"mappings":";;;;KAkCY,eAAA;;EAAA,KAAA,CAAA,EAAA,MAAA;EAAe,WAAA,CAAA,EAAA,MAAA;aAKZ,CAAA,EAAA,MAAA;MAEA,CAAA,EAFN,KAAA,CAAM,SAEA;OACL,CAAA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AA,EAAA,MAAA;EAmBA,eAAA,CAAA,EAAA,MAAqB;;;;;KAvCrB,gCAAA;;;;;;KAoBA,+BAAA;;;;;;KAmBA,qBAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{calendarControl as e,calendarDay as t,calendarHeader as n,calendarHeaderControlIcon as r,calendarHeaderLevel as i,calendarMonth as a,calendarMonthRow as o,calendarMonthsList as s,calendarMonthsListCell as c,calendarMonthsListControl as l,calendarMonthsListRow as u,calendarWeekDay as d,calendarWeekDaysRow as f,calendarYearsList as p,calendarYearsListCell as m,calendarYearsListControl as h,calendarYearsListRow as g,datepickerDropdown as _,datepickerInput as v,input as y,inputDescription as b,inputError as x,inputLabel as S,inputPlaceholder as C,inputRoot as w,inputSection as T,inputWrapper as E}from"@mage-ui/styled-system/recipes";import{jsx as D}from"react/jsx-runtime";import{cx as O}from"@mage-ui/styled-system/css";import{DatePickerInput as k}from"@mantine/dates";const A=({classNames:e,label:t,placeholder:n,description:r,icon:i,...
|
|
1
|
+
import{calendarControl as e,calendarDay as t,calendarHeader as n,calendarHeaderControlIcon as r,calendarHeaderLevel as i,calendarMonth as a,calendarMonthRow as o,calendarMonthsList as s,calendarMonthsListCell as c,calendarMonthsListControl as l,calendarMonthsListRow as u,calendarWeekDay as d,calendarWeekDaysRow as f,calendarYearsList as p,calendarYearsListCell as m,calendarYearsListControl as h,calendarYearsListRow as g,datepickerDropdown as _,datepickerInput as v,input as y,inputDescription as b,inputError as x,inputLabel as S,inputPlaceholder as C,inputRoot as w,inputSection as T,inputWrapper as E}from"@mage-ui/styled-system/recipes";import{jsx as D}from"react/jsx-runtime";import{cx as O}from"@mage-ui/styled-system/css";import{DatePickerInput as k}from"@mantine/dates";const A=({classNames:e,label:t,placeholder:n,description:r,icon:i,locale:a,...o})=>D(k,{locale:a??`en`,label:t??`Pick date`,placeholder:n??`Pick date`,description:r??`Select a date`,classNames:L(e),popoverProps:{classNames:I(e)},rightSection:i,...o}),j=e=>({root:e?.root??w(),wrapper:e?.wrapper??E(),input:e?.input??O(y(),v()),label:e?.label??S(),error:e?.error??x(),description:e?.description??b(),placeholder:e?.placeholder??C(),section:e?.section??T({pointerEvents:`none`})}),M=t=>({calendarHeaderControl:t?.calendarHeaderControl??e(),calendarHeader:t?.calendarHeader??n(),calendarHeaderLevel:t?.calendarHeaderLevel??i(),calendarHeaderControlIcon:t?.calendarHeaderControlIcon??r()}),N=e=>({month:e?.calendarMonth??a(),weekdaysRow:e?.calendarWeekDaysRow??f(),weekday:e?.calendarWeekDay??d(),monthRow:e?.calendarMonthRow??o(),day:e?.calendarDay??t()}),P=e=>({monthsList:e?.calendarMonthsList??s(),monthsListRow:e?.calendarMonthsListRow??u(),monthsListCell:e?.calendarMonthsListCell??c(),monthsListControl:e?.calendarMonthsListControl??l()}),F=e=>({yearsList:e?.calendarYearsList??p(),yearsListRow:e?.calendarYearsListRow??g(),yearsListCell:e?.calendarYearsListCell??m(),yearsListControl:e?.calendarYearsListControl??h()}),I=e=>({dropdown:e?.datepickerDropdown??_()}),L=e=>({...j(e),...M(e),...N(e),...P(e),...F(e)});export{A as DatePicker};
|
|
2
2
|
//# sourceMappingURL=DatePicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","names":["icon"],"sources":["../../../../src/components/controls/date-picker/DatePicker.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n calendarControl,\n calendarDay,\n calendarHeader,\n calendarHeaderControlIcon,\n calendarHeaderLevel,\n calendarMonth,\n calendarMonthRow,\n calendarMonthsList,\n calendarMonthsListCell,\n calendarMonthsListControl,\n calendarMonthsListRow,\n calendarWeekDay,\n calendarWeekDaysRow,\n calendarYearsList,\n calendarYearsListCell,\n calendarYearsListControl,\n calendarYearsListRow,\n datepickerDropdown,\n datepickerInput,\n input,\n inputDescription,\n inputError,\n inputLabel,\n inputPlaceholder,\n inputRoot,\n inputSection,\n inputWrapper,\n} from '@mage-ui/styled-system/recipes';\nimport { DatePickerInput, type DatePickerValue } from '@mantine/dates';\n\nexport type DatePickerProps = {\n name?: string;\n label?: string;\n placeholder?: string;\n description?: string;\n icon?: React.ReactNode;\n error?: string;\n classNames?: DatePickerClassNames;\n value?: DatePickerValue;\n onChange?: (date: Date | string | null) => void;\n};\n\nexport const DatePicker = ({\n classNames,\n label,\n placeholder,\n description,\n icon,\n ...props\n}: DatePickerProps): ReactNode => {\n return (\n <DatePickerInput\n label={label ?? 'Pick date'}\n placeholder={placeholder ?? 'Pick date'}\n description={description ?? 'Select a date'}\n classNames={datePickerClassNames(classNames)}\n popoverProps={{\n classNames: popoverClassNames(classNames),\n }}\n rightSection={icon}\n {...props}\n />\n );\n};\n\ntype DatePickerClassNames = InputClassNamesType &\n CalenderHeaderClassNamesType &\n CalendarMonthClassNamesType &\n CalendarMonthsListClassNamesType &\n CalendarYearsListClassNamesType &\n PopoverClassNamesType;\n\ntype InputClassNamesType = {\n root?: string;\n wrapper?: string;\n input?: string;\n label?: string;\n error?: string;\n description?: string;\n placeholder?: string;\n section?: string;\n};\n\nconst inputClassNames = (classNames?: InputClassNamesType) => {\n return {\n root: classNames?.root ?? inputRoot(),\n wrapper: classNames?.wrapper ?? inputWrapper(),\n input: classNames?.input ?? cx(input(), datepickerInput()),\n label: classNames?.label ?? inputLabel(),\n error: classNames?.error ?? inputError(),\n description: classNames?.description ?? inputDescription(),\n placeholder: classNames?.placeholder ?? inputPlaceholder(),\n section: classNames?.section ?? inputSection({ pointerEvents: 'none' }),\n };\n};\n\ntype CalenderHeaderClassNamesType = {\n datepickerDropdown?: string;\n calendarHeaderControl?: string;\n calendarHeader?: string;\n calendarHeaderLevel?: string;\n calendarHeaderControlIcon?: string;\n};\n\nconst calendarHeaderClassNames = (\n classNames?: CalenderHeaderClassNamesType,\n) => {\n return {\n calendarHeaderControl:\n classNames?.calendarHeaderControl ?? calendarControl(),\n calendarHeader: classNames?.calendarHeader ?? calendarHeader(),\n calendarHeaderLevel:\n classNames?.calendarHeaderLevel ?? calendarHeaderLevel(),\n calendarHeaderControlIcon:\n classNames?.calendarHeaderControlIcon ?? calendarHeaderControlIcon(),\n };\n};\n\ntype CalendarMonthClassNamesType = {\n calendarMonth?: string;\n calendarWeekDaysRow?: string;\n calendarWeekDay?: string;\n calendarMonthRow?: string;\n calendarMonthCell?: string;\n calendarDay?: string;\n};\n\nconst calendarMonthClassNames = (classNames?: CalendarMonthClassNamesType) => {\n return {\n month: classNames?.calendarMonth ?? calendarMonth(),\n weekdaysRow: classNames?.calendarWeekDaysRow ?? calendarWeekDaysRow(),\n weekday: classNames?.calendarWeekDay ?? calendarWeekDay(),\n monthRow: classNames?.calendarMonthRow ?? calendarMonthRow(),\n day: classNames?.calendarDay ?? calendarDay(),\n };\n};\n\ntype CalendarMonthsListClassNamesType = {\n calendarMonthsList?: string;\n calendarMonthsListRow?: string;\n calendarMonthsListCell?: string;\n calendarMonthsListControl?: string;\n};\n\nconst calendarMonthsListClassNames = (\n classNames?: CalendarMonthsListClassNamesType,\n) => {\n return {\n monthsList: classNames?.calendarMonthsList ?? calendarMonthsList(),\n monthsListRow: classNames?.calendarMonthsListRow ?? calendarMonthsListRow(),\n monthsListCell:\n classNames?.calendarMonthsListCell ?? calendarMonthsListCell(),\n monthsListControl:\n classNames?.calendarMonthsListControl ?? calendarMonthsListControl(),\n };\n};\n\ntype CalendarYearsListClassNamesType = {\n calendarYearsList?: string;\n calendarYearsListRow?: string;\n calendarYearsListCell?: string;\n calendarYearsListControl?: string;\n};\n\nconst calendarYearsListClassNames = (\n classNames?: CalendarYearsListClassNamesType,\n) => {\n return {\n yearsList: classNames?.calendarYearsList ?? calendarYearsList(),\n yearsListRow: classNames?.calendarYearsListRow ?? calendarYearsListRow(),\n yearsListCell: classNames?.calendarYearsListCell ?? calendarYearsListCell(),\n yearsListControl:\n classNames?.calendarYearsListControl ?? calendarYearsListControl(),\n };\n};\n\ntype PopoverClassNamesType = {\n datepickerDropdown?: string;\n};\n\nconst popoverClassNames = (classNames?: PopoverClassNamesType) => {\n return {\n dropdown: classNames?.datepickerDropdown ?? datepickerDropdown(),\n };\n};\n\nconst datePickerClassNames = (classNames?: DatePickerClassNames) => {\n return {\n ...inputClassNames(classNames),\n ...calendarHeaderClassNames(classNames),\n ...calendarMonthClassNames(classNames),\n ...calendarMonthsListClassNames(classNames),\n ...calendarYearsListClassNames(classNames),\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatePicker.js","names":["icon"],"sources":["../../../../src/components/controls/date-picker/DatePicker.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cx } from '@mage-ui/styled-system/css';\nimport {\n calendarControl,\n calendarDay,\n calendarHeader,\n calendarHeaderControlIcon,\n calendarHeaderLevel,\n calendarMonth,\n calendarMonthRow,\n calendarMonthsList,\n calendarMonthsListCell,\n calendarMonthsListControl,\n calendarMonthsListRow,\n calendarWeekDay,\n calendarWeekDaysRow,\n calendarYearsList,\n calendarYearsListCell,\n calendarYearsListControl,\n calendarYearsListRow,\n datepickerDropdown,\n datepickerInput,\n input,\n inputDescription,\n inputError,\n inputLabel,\n inputPlaceholder,\n inputRoot,\n inputSection,\n inputWrapper,\n} from '@mage-ui/styled-system/recipes';\nimport { DatePickerInput, type DatePickerValue } from '@mantine/dates';\n\nexport type DatePickerProps = {\n name?: string;\n label?: string;\n placeholder?: string;\n description?: string;\n icon?: React.ReactNode;\n error?: string;\n classNames?: DatePickerClassNames;\n value?: DatePickerValue;\n locale?: string;\n onChange?: (date: Date | string | null) => void;\n};\n\nexport const DatePicker = ({\n classNames,\n label,\n placeholder,\n description,\n icon,\n locale,\n ...props\n}: DatePickerProps): ReactNode => {\n return (\n <DatePickerInput\n locale={locale ?? 'en'}\n label={label ?? 'Pick date'}\n placeholder={placeholder ?? 'Pick date'}\n description={description ?? 'Select a date'}\n classNames={datePickerClassNames(classNames)}\n popoverProps={{\n classNames: popoverClassNames(classNames),\n }}\n rightSection={icon}\n {...props}\n />\n );\n};\n\ntype DatePickerClassNames = InputClassNamesType &\n CalenderHeaderClassNamesType &\n CalendarMonthClassNamesType &\n CalendarMonthsListClassNamesType &\n CalendarYearsListClassNamesType &\n PopoverClassNamesType;\n\ntype InputClassNamesType = {\n root?: string;\n wrapper?: string;\n input?: string;\n label?: string;\n error?: string;\n description?: string;\n placeholder?: string;\n section?: string;\n};\n\nconst inputClassNames = (classNames?: InputClassNamesType) => {\n return {\n root: classNames?.root ?? inputRoot(),\n wrapper: classNames?.wrapper ?? inputWrapper(),\n input: classNames?.input ?? cx(input(), datepickerInput()),\n label: classNames?.label ?? inputLabel(),\n error: classNames?.error ?? inputError(),\n description: classNames?.description ?? inputDescription(),\n placeholder: classNames?.placeholder ?? inputPlaceholder(),\n section: classNames?.section ?? inputSection({ pointerEvents: 'none' }),\n };\n};\n\ntype CalenderHeaderClassNamesType = {\n datepickerDropdown?: string;\n calendarHeaderControl?: string;\n calendarHeader?: string;\n calendarHeaderLevel?: string;\n calendarHeaderControlIcon?: string;\n};\n\nconst calendarHeaderClassNames = (\n classNames?: CalenderHeaderClassNamesType,\n) => {\n return {\n calendarHeaderControl:\n classNames?.calendarHeaderControl ?? calendarControl(),\n calendarHeader: classNames?.calendarHeader ?? calendarHeader(),\n calendarHeaderLevel:\n classNames?.calendarHeaderLevel ?? calendarHeaderLevel(),\n calendarHeaderControlIcon:\n classNames?.calendarHeaderControlIcon ?? calendarHeaderControlIcon(),\n };\n};\n\ntype CalendarMonthClassNamesType = {\n calendarMonth?: string;\n calendarWeekDaysRow?: string;\n calendarWeekDay?: string;\n calendarMonthRow?: string;\n calendarMonthCell?: string;\n calendarDay?: string;\n};\n\nconst calendarMonthClassNames = (classNames?: CalendarMonthClassNamesType) => {\n return {\n month: classNames?.calendarMonth ?? calendarMonth(),\n weekdaysRow: classNames?.calendarWeekDaysRow ?? calendarWeekDaysRow(),\n weekday: classNames?.calendarWeekDay ?? calendarWeekDay(),\n monthRow: classNames?.calendarMonthRow ?? calendarMonthRow(),\n day: classNames?.calendarDay ?? calendarDay(),\n };\n};\n\ntype CalendarMonthsListClassNamesType = {\n calendarMonthsList?: string;\n calendarMonthsListRow?: string;\n calendarMonthsListCell?: string;\n calendarMonthsListControl?: string;\n};\n\nconst calendarMonthsListClassNames = (\n classNames?: CalendarMonthsListClassNamesType,\n) => {\n return {\n monthsList: classNames?.calendarMonthsList ?? calendarMonthsList(),\n monthsListRow: classNames?.calendarMonthsListRow ?? calendarMonthsListRow(),\n monthsListCell:\n classNames?.calendarMonthsListCell ?? calendarMonthsListCell(),\n monthsListControl:\n classNames?.calendarMonthsListControl ?? calendarMonthsListControl(),\n };\n};\n\ntype CalendarYearsListClassNamesType = {\n calendarYearsList?: string;\n calendarYearsListRow?: string;\n calendarYearsListCell?: string;\n calendarYearsListControl?: string;\n};\n\nconst calendarYearsListClassNames = (\n classNames?: CalendarYearsListClassNamesType,\n) => {\n return {\n yearsList: classNames?.calendarYearsList ?? calendarYearsList(),\n yearsListRow: classNames?.calendarYearsListRow ?? calendarYearsListRow(),\n yearsListCell: classNames?.calendarYearsListCell ?? calendarYearsListCell(),\n yearsListControl:\n classNames?.calendarYearsListControl ?? calendarYearsListControl(),\n };\n};\n\ntype PopoverClassNamesType = {\n datepickerDropdown?: string;\n};\n\nconst popoverClassNames = (classNames?: PopoverClassNamesType) => {\n return {\n dropdown: classNames?.datepickerDropdown ?? datepickerDropdown(),\n };\n};\n\nconst datePickerClassNames = (classNames?: DatePickerClassNames) => {\n return {\n ...inputClassNames(classNames),\n ...calendarHeaderClassNames(classNames),\n ...calendarMonthClassNames(classNames),\n ...calendarMonthsListClassNames(classNames),\n ...calendarYearsListClassNames(classNames),\n };\n};\n"],"mappings":"6wBA+CA,MAAa,GAAc,CACzB,aACA,QACA,cACA,cACA,KAAA,EACA,SACA,GAAG,KAGD,EAAC,EAAA,CACC,OAAQ,GAAU,KAClB,MAAO,GAAS,YAChB,YAAa,GAAe,YAC5B,YAAa,GAAe,gBAC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AwB,EAAW,CACtC,GAAG,EAA6B,EAAW,CAC3C,GAAG,EAA4B,EAAW,CAC3C"}
|
|
@@ -12,6 +12,7 @@ import { FormInputFileProps } from "./controls/FormInputFile.js";
|
|
|
12
12
|
import { FormInputPasswordProps } from "./controls/FormInputPassword.js";
|
|
13
13
|
import { FormIfFieldProps } from "./controls/FormIfField.js";
|
|
14
14
|
import * as react_jsx_runtime18 from "react/jsx-runtime";
|
|
15
|
+
import * as react0 from "react";
|
|
15
16
|
import { ReactNode } from "react";
|
|
16
17
|
import { ZodEffects, ZodObject, ZodRawShape, z } from "zod";
|
|
17
18
|
|
|
@@ -196,6 +197,15 @@ declare const Form: {
|
|
|
196
197
|
}: FormIfFieldProps): ReactNode;
|
|
197
198
|
displayName: string;
|
|
198
199
|
};
|
|
200
|
+
Control: {
|
|
201
|
+
({
|
|
202
|
+
children,
|
|
203
|
+
...props
|
|
204
|
+
}: {
|
|
205
|
+
children: ReactNode;
|
|
206
|
+
} & Record<string, unknown>): (string | number | bigint | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react0.ReactPortal | react0.ReactElement<unknown, string | react0.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react0.ReactElement<unknown, string | react0.JSXElementConstructor<any>>)[] | null | undefined;
|
|
207
|
+
displayName: string;
|
|
208
|
+
};
|
|
199
209
|
};
|
|
200
210
|
//#endregion
|
|
201
211
|
export { Form, FormProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","names":[],"sources":["../../../../src/components/forms/form/Form.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Form.d.ts","names":[],"sources":["../../../../src/components/forms/form/Form.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;KAyBY,SAAA;;UAEF,UAAU,eAAe,WAAW,UAAU;;YAE5C,KAAA,CAAM;;;cAIL;;;;;;;;KAOV,YAAS,mBAAA,CAAA,GAAA,CAAA;;;;OAAA;;;;;;;IAfA,CAAA;MAAA,IAAA;MAAS,OAAA;MAAA,GAAA;IAAA,CAAA,mBAAA,CAAA,iCAAA;IAAA,WAAA,EAAA,MAAA;IAED,KAAA,EAAA;MAAV,QAAA,EAAA,CAAA,OAAA,CAAA,EAAA,MAAA,EAAA,aAAA,aAAA,EAAA,OAAA,EAAA,OAAA,CAAA;IAA8C,CAAA;;eAArB,EAAA;IAEvB,CAAA;MAAA,IAAM;MAAA,OAAA;MAAA,QAAA;MAAA,GAAA;IAAA,CAAA,wBAAA,CAAA,iCAAA;IAAS,WAAA,EAAA,MAAA;IAId,KAmCZ,EAAA;MAAA,QAAA,EAAA,CAAA,OAAA,CAAA,EAAA,MAAA,EAAA,aAAA,YAAA,EAAA,MAAA,CAAA;;;;;;;;;;UA5BW,EAAA;IAAA,CAAA;MAAA,IAAA;MAAA,OAAA;MAAA,GAAA;IAAA,CAAA,mBAAA,CAAA,iCAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{FormCheckbox as e}from"./controls/FormCheckbox.js";import{FormCheckboxGroup as t}from"./controls/FormCheckboxGroup.js";import{FormCombobox as n}from"./controls/FormCombobox.js";import{
|
|
1
|
+
import{FormCheckbox as e}from"./controls/FormCheckbox.js";import{FormCheckboxGroup as t}from"./controls/FormCheckboxGroup.js";import{FormCombobox as n}from"./controls/FormCombobox.js";import{FormControl as r}from"./controls/FormControl.js";import{FormDatePicker as i}from"./controls/FormDatePicker.js";import{FormIfField as a}from"./controls/FormIfField.js";import{FormInputFile as o}from"./controls/FormInputFile.js";import{FormInputPassword as s}from"./controls/FormInputPassword.js";import{FormInputText as c}from"./controls/FormInputText.js";import{FormRadio as l}from"./controls/FormRadio.js";import{FormRadioGroup as u}from"./controls/FormRadioGroup.js";import{FormSelect as d}from"./controls/FormSelect.js";import{FormTextarea as f}from"./controls/FormTextarea.js";import{jsx as p}from"react/jsx-runtime";import{Children as m,cloneElement as h,isValidElement as g}from"react";import{FormProvider as _,useForm as v}from"react-hook-form";import{ZodEffects as y,z as b}from"zod";import{zodResolver as x}from"@hookform/resolvers/zod";const S=({defaultValues:e,rules:t=b.object({}).refine(()=>{}),onSubmit:n,children:r,className:i,...a})=>{let o=t instanceof y?t._def.schema:t,s=v({shouldFocusError:!0,...t&&Object.keys(o?.shape||{}).length>0?{resolver:x(o)}:{},defaultValues:e}),{register:c,handleSubmit:l,formState:{errors:u}}=s;return p(_,{...s,children:p(`form`,{onSubmit:l(n),className:i??void 0,...a,children:T(r,c,u,o)})})},C=[c,t,e,n,u,l,f,d,i,o,s,a,r],w=(e,t)=>{let n=e?.shape?.[t]||void 0;return n===void 0?!1:!(n.isOptional()||n.isNullable())},T=(e,t,n,r)=>m.map(e,e=>{if(!g(e))return e;let i=e.props;if(C.some(t=>e.type===t)&&i.name){let a={required:w(r,i.name),error:n[i.name]?.message,...i,...t(i.name,{setValueAs:e=>e===``||e===null?void 0:e})};return h(e,a)}return i.children?h(e,i,T(i.children,t,n,r)):e});S.InputText=c,S.Checkbox=e,S.CheckboxGroup=t,S.Combobox=n,S.RadioGroup=u,S.Radio=l,S.Textarea=f,S.Select=d,S.DatePicker=i,S.InputFile=o,S.InputPassword=s,S.IfField=a,S.Control=r;export{S as Form};
|
|
2
2
|
//# sourceMappingURL=Form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","names":["schema: ZodObject<ZodRawShape>"],"sources":["../../../../src/components/forms/form/Form.tsx"],"sourcesContent":["import { Children, cloneElement, isValidElement, type ReactNode } from 'react';\nimport {\n type FieldErrors,\n FormProvider,\n type UseFormRegister,\n useForm,\n} from 'react-hook-form';\nimport { ZodEffects, type ZodObject, type ZodRawShape, z } from 'zod';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\n\nimport { FormCheckbox } from './controls/FormCheckbox';\nimport { FormCheckboxGroup } from './controls/FormCheckboxGroup';\nimport { FormCombobox } from './controls/FormCombobox';\nimport { FormDatePicker } from './controls/FormDatePicker';\nimport { FormIfField } from './controls/FormIfField';\nimport { FormInputFile } from './controls/FormInputFile';\nimport { FormInputPassword } from './controls/FormInputPassword';\nimport { FormInputText } from './controls/FormInputText';\nimport { FormRadio } from './controls/FormRadio';\nimport { FormRadioGroup } from './controls/FormRadioGroup';\nimport { FormSelect } from './controls/FormSelect';\nimport { FormTextarea } from './controls/FormTextarea';\n\nexport type FormProps = {\n defaultValues?: object;\n rules?: ZodObject<ZodRawShape> | ZodEffects<ZodObject<ZodRawShape>>;\n onSubmit: (formData: object) => void;\n children: React.ReactNode;\n className?: string;\n};\n\nexport const Form = ({\n defaultValues,\n rules = z.object({}).refine(() => {}),\n onSubmit,\n children,\n className,\n ...props\n}: FormProps) => {\n const schema: ZodObject<ZodRawShape> =\n rules instanceof ZodEffects ? rules._def.schema : rules;\n\n const form = useForm({\n shouldFocusError: true,\n ...(rules && Object.keys(schema?.shape || {}).length > 0\n ? { resolver: zodResolver(schema) }\n : {}),\n defaultValues,\n });\n const {\n register,\n handleSubmit,\n formState: { errors },\n } = form;\n\n return (\n <FormProvider {...form}>\n <form\n onSubmit={handleSubmit(onSubmit)}\n className={className ?? undefined}\n {...props}\n >\n {renderChildrenRecursively(children, register, errors, schema)}\n </form>\n </FormProvider>\n );\n};\n\nconst controlList = [\n FormInputText,\n FormCheckboxGroup,\n FormCheckbox,\n FormCombobox,\n FormRadioGroup,\n FormRadio,\n FormTextarea,\n FormSelect,\n FormDatePicker,\n FormInputFile,\n FormInputPassword,\n FormIfField,\n];\n\nconst isRequired = (schema: ZodObject<ZodRawShape>, field: string) => {\n const shape = schema?.shape?.[field] || undefined;\n if (shape === undefined) {\n return false;\n }\n\n return !(shape.isOptional() || shape.isNullable());\n};\n\nconst renderChildrenRecursively = (\n children: React.ReactNode,\n register: UseFormRegister<Record<string, string>>,\n errors: FieldErrors,\n rules: ZodObject<ZodRawShape>,\n): ReactNode => {\n return Children.map(children, (child) => {\n if (!isValidElement(child)) {\n return child;\n }\n\n const props = child.props as {\n name?: string;\n type?: string;\n children?: ReactNode;\n };\n\n if (controlList.some((control) => child.type === control)) {\n if (props.name) {\n const newProps = {\n required: isRequired(rules, props.name),\n error: errors[props.name]?.message,\n ...props,\n ...register(props.name, {\n setValueAs: (value: unknown) => {\n return value === '' || value === null ? undefined : value;\n },\n }),\n };\n return cloneElement(child, newProps);\n }\n }\n\n if (props.children) {\n return cloneElement(\n child,\n props,\n renderChildrenRecursively(props.children, register, errors, rules),\n );\n }\n\n return child;\n });\n};\n\nForm.InputText = FormInputText;\nForm.Checkbox = FormCheckbox;\nForm.CheckboxGroup = FormCheckboxGroup;\nForm.Combobox = FormCombobox;\nForm.RadioGroup = FormRadioGroup;\nForm.Radio = FormRadio;\nForm.Textarea = FormTextarea;\nForm.Select = FormSelect;\nForm.DatePicker = FormDatePicker;\nForm.InputFile = FormInputFile;\nForm.InputPassword = FormInputPassword;\nForm.IfField = FormIfField;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Form.js","names":["schema: ZodObject<ZodRawShape>"],"sources":["../../../../src/components/forms/form/Form.tsx"],"sourcesContent":["import { Children, cloneElement, isValidElement, type ReactNode } from 'react';\nimport {\n type FieldErrors,\n FormProvider,\n type UseFormRegister,\n useForm,\n} from 'react-hook-form';\nimport { ZodEffects, type ZodObject, type ZodRawShape, z } from 'zod';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\n\nimport { FormCheckbox } from './controls/FormCheckbox';\nimport { FormCheckboxGroup } from './controls/FormCheckboxGroup';\nimport { FormCombobox } from './controls/FormCombobox';\nimport { FormControl } from './controls/FormControl';\nimport { FormDatePicker } from './controls/FormDatePicker';\nimport { FormIfField } from './controls/FormIfField';\nimport { FormInputFile } from './controls/FormInputFile';\nimport { FormInputPassword } from './controls/FormInputPassword';\nimport { FormInputText } from './controls/FormInputText';\nimport { FormRadio } from './controls/FormRadio';\nimport { FormRadioGroup } from './controls/FormRadioGroup';\nimport { FormSelect } from './controls/FormSelect';\nimport { FormTextarea } from './controls/FormTextarea';\n\nexport type FormProps = {\n defaultValues?: object;\n rules?: ZodObject<ZodRawShape> | ZodEffects<ZodObject<ZodRawShape>>;\n onSubmit: (formData: object) => void;\n children: React.ReactNode;\n className?: string;\n};\n\nexport const Form = ({\n defaultValues,\n rules = z.object({}).refine(() => {}),\n onSubmit,\n children,\n className,\n ...props\n}: FormProps) => {\n const schema: ZodObject<ZodRawShape> =\n rules instanceof ZodEffects ? rules._def.schema : rules;\n\n const form = useForm({\n shouldFocusError: true,\n ...(rules && Object.keys(schema?.shape || {}).length > 0\n ? { resolver: zodResolver(schema) }\n : {}),\n defaultValues,\n });\n const {\n register,\n handleSubmit,\n formState: { errors },\n } = form;\n\n return (\n <FormProvider {...form}>\n <form\n onSubmit={handleSubmit(onSubmit)}\n className={className ?? undefined}\n {...props}\n >\n {renderChildrenRecursively(children, register, errors, schema)}\n </form>\n </FormProvider>\n );\n};\n\nconst controlList = [\n FormInputText,\n FormCheckboxGroup,\n FormCheckbox,\n FormCombobox,\n FormRadioGroup,\n FormRadio,\n FormTextarea,\n FormSelect,\n FormDatePicker,\n FormInputFile,\n FormInputPassword,\n FormIfField,\n FormControl,\n];\n\nconst isRequired = (schema: ZodObject<ZodRawShape>, field: string) => {\n const shape = schema?.shape?.[field] || undefined;\n if (shape === undefined) {\n return false;\n }\n\n return !(shape.isOptional() || shape.isNullable());\n};\n\nconst renderChildrenRecursively = (\n children: React.ReactNode,\n register: UseFormRegister<Record<string, string>>,\n errors: FieldErrors,\n rules: ZodObject<ZodRawShape>,\n): ReactNode => {\n return Children.map(children, (child) => {\n if (!isValidElement(child)) {\n return child;\n }\n\n const props = child.props as {\n name?: string;\n type?: string;\n children?: ReactNode;\n };\n\n if (controlList.some((control) => child.type === control)) {\n if (props.name) {\n const newProps = {\n required: isRequired(rules, props.name),\n error: errors[props.name]?.message,\n ...props,\n ...register(props.name, {\n setValueAs: (value: unknown) => {\n return value === '' || value === null ? undefined : value;\n },\n }),\n };\n return cloneElement(child, newProps);\n }\n }\n\n if (props.children) {\n return cloneElement(\n child,\n props,\n renderChildrenRecursively(props.children, register, errors, rules),\n );\n }\n\n return child;\n });\n};\n\nForm.InputText = FormInputText;\nForm.Checkbox = FormCheckbox;\nForm.CheckboxGroup = FormCheckboxGroup;\nForm.Combobox = FormCombobox;\nForm.RadioGroup = FormRadioGroup;\nForm.Radio = FormRadio;\nForm.Textarea = FormTextarea;\nForm.Select = FormSelect;\nForm.DatePicker = FormDatePicker;\nForm.InputFile = FormInputFile;\nForm.InputPassword = FormInputPassword;\nForm.IfField = FormIfField;\nForm.Control = FormControl;\n"],"mappings":"6gCAiCA,MAAa,GAAQ,CACnB,gBACA,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,WAAa,GAAG,CACrC,WACA,WACA,YACA,GAAG,KACY,CACf,IAAMA,EACJ,aAAiB,EAAa,EAAM,KAAK,OAAS,EAE9C,EAAO,EAAQ,CACnB,iBAAkB,GAClB,GAAI,GAAS,OAAO,KAAK,GAAQ,OAAS,EAAE,CAAC,CAAC,OAAS,EACnD,CAAE,SAAU,EAAY,EAAO,CAAE,CACjC,EAAE,CACN,gBACD,CAAC,CACI,CACJ,WACA,eACA,UAAW,CAAE,WACX,EAEJ,OACE,EAAC,EAAA,CAAa,GAAI,WAChB,EAAC,OAAA,CACC,SAAU,EAAa,EAAS,CAChC,UAAW,GAAa,IAAA,GACxB,GAAI,WAEH,EAA0B,EAAU,EAAU,EAAQ,EAAO,EACzD,EACM,EAIb,EAAc,CAClB,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CAEK,GAAc,EAAgC,IAAkB,CACpE,IAAM,EAAQ,GAAQ,QAAQ,IAAU,IAAA,GAKxC,OAJI,IAAU,IAAA,GACL,GAGF,EAAE,EAAM,YAAY,EAAI,EAAM,YAAY,GAG7C,GACJ,EACA,EACA,EACA,IAEO,EAAS,IAAI,EAAW,GAAU,CACvC,GAAI,CAAC,EAAe,EAAM,CACxB,OAAO,EAGT,IAAM,EAAQ,EAAM,MAMpB,GAAI,EAAY,KAAM,GAAY,EAAM,OAAS,EAAQ,EACnD,EAAM,KAAM,CACd,IAAM,EAAW,CACf,SAAU,EAAW,EAAO,EAAM,KAAK,CACvC,MAAO,EAAO,EAAM,OAAO,QAC3B,GAAG,EACH,GAAG,EAAS,EAAM,KAAM,CACtB,WAAa,GACJ,IAAU,IAAM,IAAU,KAAO,IAAA,GAAY,EAEvD,CAAC,CACH,CACD,OAAO,EAAa,EAAO,EAAS,CAYxC,OARI,EAAM,SACD,EACL,EACA,EACA,EAA0B,EAAM,SAAU,EAAU,EAAQ,EAAM,CACnE,CAGI,GACP,CAGJ,EAAK,UAAY,EACjB,EAAK,SAAW,EAChB,EAAK,cAAgB,EACrB,EAAK,SAAW,EAChB,EAAK,WAAa,EAClB,EAAK,MAAQ,EACb,EAAK,SAAW,EAChB,EAAK,OAAS,EACd,EAAK,WAAa,EAClB,EAAK,UAAY,EACjB,EAAK,cAAgB,EACrB,EAAK,QAAU,EACf,EAAK,QAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormControl.js","names":[],"sources":["../../../../../src/components/forms/form/controls/FormControl.tsx"],"sourcesContent":["import { Children, cloneElement, isValidElement, type ReactNode } from 'react';\n\ntype FormControlProps = { children: ReactNode } & Record<string, unknown>;\n\nexport const FormControl = ({ children, ...props }: FormControlProps) => {\n return Children.map(children, (child) => {\n if (isValidElement(child)) {\n return cloneElement(child, {\n ...(child.props as Record<string, unknown>),\n ...(props as Record<string, unknown>),\n });\n }\n return child;\n });\n};\n\nFormControl.displayName = 'Form.Control';\n"],"mappings":"uEAIA,MAAa,GAAe,CAAE,WAAU,GAAG,KAClC,EAAS,IAAI,EAAW,GACzB,EAAe,EAAM,CAChB,EAAa,EAAO,CACzB,GAAI,EAAM,MACV,GAAI,EACL,CAAC,CAEG,EACP,CAGJ,EAAY,YAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mage-ui/components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.72",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"rimraf": "^6.0.1",
|
|
27
27
|
"tsdown": "^0.15.6",
|
|
28
28
|
"typescript": "^5.9.3",
|
|
29
|
-
"@mage-ui/preset": "0.0.
|
|
30
|
-
"@mage-ui/styled-system": "0.0.
|
|
29
|
+
"@mage-ui/preset": "0.0.72",
|
|
30
|
+
"@mage-ui/styled-system": "0.0.72"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@hookform/resolvers": "^5.2.2",
|