@zydon/common 2.7.54 → 2.7.56

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.
@@ -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, 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 k from 'dayjs';
3
+ import Y from 'dayjs';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
6
- var C=({name:t,rules:s,tabIndex:i,helperText:u,required:p,...e})=>{let{control:c}=useFormContext();return jsx(Controller,{name:t,control:c,rules:s,render:({field:{ref:f,onChange:m,...o},fieldState:{error:r}})=>jsx(DatePicker,{inputRef:f,format:"DD/MM/YYYY",...o,"data-intercom-target":t,...e,value:o.value?k(o.value):null,onChange:l=>{let a=l?l.toDate():null;m(a),e.onChange&&e.onChange(a);},slotProps:{textField:{...e.slotProps?.textField,name:t,required:p,error:!!r,helperText:r?.message||u,autoComplete:"off",spellCheck:"false",fullWidth:!0},openPickerButton:{tabIndex:i}}})})},h=C;
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 { h as default };
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","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,QAuBV,cAAAC,MAAA,oBAnBR,IAAMC,EAAa,CAAC,CAClB,KAAAC,EACA,MAAAC,EACA,SAAAC,EACA,WAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAAuB,CACrB,GAAM,CAAE,QAAAC,CAAQ,EAAIX,EAAe,EAEnC,OACEG,EAACJ,EAAA,CACC,KAAMM,EACN,QAASM,EACT,MAAOL,EACP,OAAQ,CAAC,CACP,MAAO,CAAE,IAAAM,EAAK,SAAAC,EAAU,GAAGC,CAAM,EACjC,WAAY,CAAE,MAAAC,CAAM,CACtB,IACEZ,EAACF,EAAA,CACC,SAAUW,EACV,OAAO,aACN,GAAGE,EACJ,uBAAsBT,EACrB,GAAGK,EACJ,MAAOI,EAAM,MAAQZ,EAAMY,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,KAAAL,EACA,SAAAI,EACA,MAAO,CAAC,CAACM,EACT,WAAYA,GAAO,SAAWP,EAC9B,aAAc,MACd,WAAY,QACZ,UAAW,EACb,EACA,iBAAkB,CAChB,SAAAD,CACF,CACF,EACF,EAEJ,CAEJ,EAEOW,EAAQd","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 rules,\n tabIndex,\n helperText,\n required,\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 name,\n required,\n error: !!error,\n helperText: error?.message || helperText,\n autoComplete: 'off',\n spellCheck: 'false',\n fullWidth: true,\n },\n openPickerButton: {\n tabIndex,\n },\n }}\n />\n )}\n />\n );\n};\n\nexport default DatePicker;\n"]}
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"]}
@@ -5,11 +5,15 @@ import { BaseField } from './baseField.js';
5
5
  import 'react-hook-form';
6
6
 
7
7
  type DatePickerProps = BaseField<Omit<DatePickerProps$1<Dayjs>, 'value' | 'onChange'>> & {
8
+ id?: string;
8
9
  tabIndex?: number;
9
10
  helperText?: ReactNode;
10
11
  required?: boolean;
11
12
  value?: Date | null | undefined;
12
13
  onChange?(value: Date | null | undefined): void;
14
+ size?: 'medium' | 'small';
15
+ fullWidth?: boolean;
16
+ placeholder?: string;
13
17
  };
14
18
 
15
19
  export { DatePickerProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.7.54",
3
+ "version": "2.7.56",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",