@zydon/common 2.7.55 → 2.7.57
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/form/DatePicker/index.d.ts +1 -1
- package/dist/components/form/DatePicker/index.js +3 -3
- package/dist/components/form/DatePicker/index.js.map +1 -1
- package/dist/components/form/MultiCheckbox/index.d.ts +1 -1
- package/dist/components/form/MultiCheckbox/index.js +8 -8
- package/dist/components/form/MultiCheckbox/index.js.map +1 -1
- package/dist/types/datePickerProps.d.ts +3 -0
- package/dist/types/multiCheckboxProps.d.ts +3 -1
- package/package.json +1 -1
|
@@ -6,6 +6,6 @@ import 'dayjs';
|
|
|
6
6
|
import '../../../types/baseField.js';
|
|
7
7
|
import 'react-hook-form';
|
|
8
8
|
|
|
9
|
-
declare const DatePicker: ({ name, id, rules, tabIndex, helperText, required, ...other }: DatePickerProps) => react_jsx_runtime.JSX.Element;
|
|
9
|
+
declare const DatePicker: ({ name, id, rules, tabIndex, helperText, required, size, fullWidth, placeholder, ...other }: DatePickerProps) => react_jsx_runtime.JSX.Element;
|
|
10
10
|
|
|
11
11
|
export { DatePicker as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useFormContext, Controller } from 'react-hook-form';
|
|
2
2
|
import { DatePicker } from '@mui/x-date-pickers-pro';
|
|
3
|
-
import
|
|
3
|
+
import Y from 'dayjs';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var F=({name:t,id:s,rules:i,tabIndex:p,helperText:u,required:c,size:m,fullWidth:f=!0,placeholder:P,...e})=>{let{control:D}=useFormContext();return jsx(Controller,{name:t,control:D,rules:i,render:({field:{ref:k,onChange:C,...o},fieldState:{error:r}})=>jsx(DatePicker,{inputRef:k,format:"DD/MM/YYYY",...o,"data-intercom-target":t,...e,value:o.value?Y(o.value):null,onChange:l=>{let a=l?l.toDate():null;C(a),e.onChange&&e.onChange(a);},slotProps:{textField:{...e.slotProps?.textField,id:s,name:t,required:c,error:!!r,helperText:r?.message||u,autoComplete:"off",spellCheck:"false",size:m,fullWidth:f,placeholder:P},openPickerButton:{tabIndex:p}}})})},w=F;
|
|
7
7
|
|
|
8
|
-
export {
|
|
8
|
+
export { w as default };
|
|
9
9
|
//# sourceMappingURL=out.js.map
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/form/DatePicker/index.tsx"],"names":["Controller","useFormContext","MuiDatePicker","dayjs","jsx","DatePicker","name","id","rules","tabIndex","helperText","required","other","control","ref","onChange","field","error","v","newValue","DatePicker_default"],"mappings":"AAAA,OAAS,cAAAA,EAAY,kBAAAC,MAAsB,kBAC3C,OAAS,cAAcC,MAAqB,0BAC5C,OAAOC,MAAW,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/form/DatePicker/index.tsx"],"names":["Controller","useFormContext","MuiDatePicker","dayjs","jsx","DatePicker","name","id","rules","tabIndex","helperText","required","size","fullWidth","placeholder","other","control","ref","onChange","field","error","v","newValue","DatePicker_default"],"mappings":"AAAA,OAAS,cAAAA,EAAY,kBAAAC,MAAsB,kBAC3C,OAAS,cAAcC,MAAqB,0BAC5C,OAAOC,MAAW,QA2BV,cAAAC,MAAA,oBAvBR,IAAMC,EAAa,CAAC,CAClB,KAAAC,EACA,GAAAC,EACA,MAAAC,EACA,SAAAC,EACA,WAAAC,EACA,SAAAC,EACA,KAAAC,EACA,UAAAC,EAAY,GACZ,YAAAC,EACA,GAAGC,CACL,IAAuB,CACrB,GAAM,CAAE,QAAAC,CAAQ,EAAIf,EAAe,EAEnC,OACEG,EAACJ,EAAA,CACC,KAAMM,EACN,QAASU,EACT,MAAOR,EACP,OAAQ,CAAC,CACP,MAAO,CAAE,IAAAS,EAAK,SAAAC,EAAU,GAAGC,CAAM,EACjC,WAAY,CAAE,MAAAC,CAAM,CACtB,IACEhB,EAACF,EAAA,CACC,SAAUe,EACV,OAAO,aACN,GAAGE,EACJ,uBAAsBb,EACrB,GAAGS,EACJ,MAAOI,EAAM,MAAQhB,EAAMgB,EAAM,KAAK,EAAI,KAC1C,SAAUE,GAAK,CACb,IAAMC,EAAWD,EAAIA,EAAE,OAAO,EAAI,KAClCH,EAASI,CAAQ,EACjBP,EAAM,UAAYA,EAAM,SAASO,CAAQ,CAC3C,EACA,UAAW,CACT,UAAW,CACT,GAAGP,EAAM,WAAW,UACpB,GAAAR,EACA,KAAAD,EACA,SAAAK,EACA,MAAO,CAAC,CAACS,EACT,WAAYA,GAAO,SAAWV,EAC9B,aAAc,MACd,WAAY,QACZ,KAAAE,EACA,UAAAC,EACA,YAAAC,CACF,EACA,iBAAkB,CAChB,SAAAL,CACF,CACF,EACF,EAEJ,CAEJ,EAEOc,EAAQlB","sourcesContent":["import { Controller, useFormContext } from 'react-hook-form';\nimport { DatePicker as MuiDatePicker } from '@mui/x-date-pickers-pro';\nimport dayjs from 'dayjs';\n\nimport { DatePickerProps } from 'types/datePickerProps';\n\nconst DatePicker = ({\n name,\n id,\n rules,\n tabIndex,\n helperText,\n required,\n size,\n fullWidth = true,\n placeholder,\n ...other\n}: DatePickerProps) => {\n const { control } = useFormContext();\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({\n field: { ref, onChange, ...field },\n fieldState: { error },\n }) => (\n <MuiDatePicker\n inputRef={ref}\n format=\"DD/MM/YYYY\"\n {...field}\n data-intercom-target={name}\n {...other}\n value={field.value ? dayjs(field.value) : null}\n onChange={v => {\n const newValue = v ? v.toDate() : null;\n onChange(newValue);\n other.onChange && other.onChange(newValue);\n }}\n slotProps={{\n textField: {\n ...other.slotProps?.textField,\n id,\n name,\n required,\n error: !!error,\n helperText: error?.message || helperText,\n autoComplete: 'off',\n spellCheck: 'false',\n size,\n fullWidth,\n placeholder,\n },\n openPickerButton: {\n tabIndex,\n },\n }}\n />\n )}\n />\n );\n};\n\nexport default DatePicker;\n"]}
|
|
@@ -4,6 +4,6 @@ import '@mui/material/FormControlLabel';
|
|
|
4
4
|
import '../../../types/baseField.js';
|
|
5
5
|
import 'react-hook-form';
|
|
6
6
|
|
|
7
|
-
declare const MultiCheckbox: ({ row, name, rules, label, options, spacing, helperText, required, ...other }: MultiCheckboxProps) => react_jsx_runtime.JSX.Element;
|
|
7
|
+
declare const MultiCheckbox: ({ row, name, rules, label, options, spacing, helperText, required, onSelectOption, ...other }: MultiCheckboxProps) => react_jsx_runtime.JSX.Element;
|
|
8
8
|
|
|
9
9
|
export { MultiCheckbox as default };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useFormContext, Controller } from 'react-hook-form';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
2
|
+
import y from '@mui/material/Checkbox';
|
|
3
|
+
import h from '@mui/material/FormControl';
|
|
4
|
+
import k from '@mui/material/FormControlLabel';
|
|
5
|
+
import M from '@mui/material/FormGroup';
|
|
6
|
+
import L from '@mui/material/FormHelperText';
|
|
7
|
+
import G from '@mui/material/FormLabel';
|
|
8
8
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var H=({row:m,name:n,rules:d,label:i,options:s,spacing:a,helperText:f,required:b,onSelectOption:p,...c})=>{let{control:C}=useFormContext(),F=(o,l)=>o.includes(l)?o.filter(r=>r!==l):[...o,l];return jsx(Controller,{name:n,control:C,rules:d,render:({field:{value:o=[],...l},fieldState:{error:r}})=>jsxs(h,{component:"fieldset",children:[i&&jsx(G,{component:"legend",sx:{typography:"body2"},required:b,children:i}),jsx(M,{sx:{...m&&{flexDirection:"row"},"& .MuiFormControlLabel-root":{"&:not(:last-of-type)":{mb:a||0},...m&&{mr:0,"&:not(:last-of-type)":{mr:a||2}}}},children:s.map(e=>jsx(k,{control:jsx(y,{checked:o.includes(e.value),onChange:()=>{let u=F(o,e.value);p&&p(u,o),l.onChange(u);}}),label:e.label,"data-intercom-target":n,...c},e.value))}),(!!r||f)&&jsx(L,{error:!!r,sx:e=>({color:c.disabled?e.palette.grey[500]:void 0}),children:r?r?.message:f})]})})},z=H;
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export { z as default };
|
|
13
13
|
//# sourceMappingURL=out.js.map
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/form/MultiCheckbox/index.tsx"],"names":["Controller","useFormContext","MuiCheckbox","FormControl","FormControlLabel","FormGroup","FormHelperText","FormLabel","jsx","jsxs","MultiCheckbox","row","name","rules","label","options","spacing","helperText","required","other","control","getSelected","selectedItems","item","value","field","error","option","theme","MultiCheckbox_default"],"mappings":"AAAA,OAAS,cAAAA,EAAY,kBAAAC,MAAsB,kBAC3C,OAAOC,MAAiB,yBACxB,OAAOC,MAAiB,4BACxB,OAAOC,MAAsB,iCAC7B,OAAOC,MAAe,0BACtB,OAAOC,MAAoB,+BAC3B,OAAOC,MAAe,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/form/MultiCheckbox/index.tsx"],"names":["Controller","useFormContext","MuiCheckbox","FormControl","FormControlLabel","FormGroup","FormHelperText","FormLabel","jsx","jsxs","MultiCheckbox","row","name","rules","label","options","spacing","helperText","required","onSelectOption","other","control","getSelected","selectedItems","item","value","field","error","option","newValue","theme","MultiCheckbox_default"],"mappings":"AAAA,OAAS,cAAAA,EAAY,kBAAAC,MAAsB,kBAC3C,OAAOC,MAAiB,yBACxB,OAAOC,MAAiB,4BACxB,OAAOC,MAAsB,iCAC7B,OAAOC,MAAe,0BACtB,OAAOC,MAAoB,+BAC3B,OAAOC,MAAe,0BA6Bd,OAEI,OAAAC,EAFJ,QAAAC,MAAA,oBAzBR,IAAMC,EAAgB,CAAC,CACrB,IAAAC,EACA,KAAAC,EACA,MAAAC,EACA,MAAAC,EACA,QAAAC,EACA,QAAAC,EACA,WAAAC,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GAAO,QAAUV,EAC5B,GAEJ,EAEJ,CAEJ,EAEOc,EAAQrB","sourcesContent":["import { Controller, useFormContext } from 'react-hook-form';\nimport MuiCheckbox from '@mui/material/Checkbox';\nimport FormControl from '@mui/material/FormControl';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport FormGroup from '@mui/material/FormGroup';\nimport FormHelperText from '@mui/material/FormHelperText';\nimport FormLabel from '@mui/material/FormLabel';\n\nimport { MultiCheckboxProps } from 'types/multiCheckboxProps';\n\nconst MultiCheckbox = ({\n row,\n name,\n rules,\n label,\n options,\n spacing,\n helperText,\n required,\n onSelectOption,\n ...other\n}: MultiCheckboxProps) => {\n const { control } = useFormContext();\n\n const getSelected = (selectedItems: string[], item: string) =>\n selectedItems.includes(item)\n ? selectedItems.filter(value => value !== item)\n : [...selectedItems, item];\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ field: { value = [], ...field }, fieldState: { error } }) => (\n <FormControl component=\"fieldset\">\n {label && (\n <FormLabel\n component=\"legend\"\n sx={{ typography: 'body2' }}\n required={required}\n >\n {label}\n </FormLabel>\n )}\n\n <FormGroup\n sx={{\n ...(row && {\n flexDirection: 'row',\n }),\n '& .MuiFormControlLabel-root': {\n '&:not(:last-of-type)': {\n mb: spacing || 0,\n },\n ...(row && {\n mr: 0,\n '&:not(:last-of-type)': {\n mr: spacing || 2,\n },\n }),\n },\n }}\n >\n {options.map(option => (\n <FormControlLabel\n key={option.value}\n control={\n <MuiCheckbox\n checked={value.includes(option.value)}\n onChange={() => {\n const newValue = getSelected(value, option.value);\n\n if (onSelectOption) onSelectOption(newValue, value);\n field.onChange(newValue);\n }}\n />\n }\n label={option.label}\n data-intercom-target={name}\n {...other}\n />\n ))}\n </FormGroup>\n\n {(!!error || helperText) && (\n <FormHelperText\n error={!!error}\n sx={theme => ({\n color: other.disabled ? theme.palette.grey[500] : undefined,\n })}\n >\n {error ? error?.message : helperText}\n </FormHelperText>\n )}\n </FormControl>\n )}\n />\n );\n};\n\nexport default MultiCheckbox;\n"]}
|
|
@@ -11,6 +11,9 @@ type DatePickerProps = BaseField<Omit<DatePickerProps$1<Dayjs>, 'value' | 'onCha
|
|
|
11
11
|
required?: boolean;
|
|
12
12
|
value?: Date | null | undefined;
|
|
13
13
|
onChange?(value: Date | null | undefined): void;
|
|
14
|
+
size?: 'medium' | 'small';
|
|
15
|
+
fullWidth?: boolean;
|
|
16
|
+
placeholder?: string;
|
|
14
17
|
};
|
|
15
18
|
|
|
16
19
|
export { DatePickerProps };
|
|
@@ -13,6 +13,8 @@ interface MultiCheckbox extends Omit<FormControlLabelProps, 'control' | 'label'>
|
|
|
13
13
|
spacing?: number;
|
|
14
14
|
helperText?: React.ReactNode;
|
|
15
15
|
}
|
|
16
|
-
type MultiCheckboxProps = BaseField<MultiCheckbox
|
|
16
|
+
type MultiCheckboxProps = BaseField<MultiCheckbox> & {
|
|
17
|
+
onSelectOption?(newValue: string[], oldValue?: string[]): void;
|
|
18
|
+
};
|
|
17
19
|
|
|
18
20
|
export { MultiCheckbox, MultiCheckboxProps };
|