@zydon/common 2.0.1 → 2.0.3

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.
@@ -0,0 +1,16 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { DatePickerProps as DatePickerProps$1 } from '@mui/x-date-pickers-pro';
4
+ import { Dayjs } from 'dayjs';
5
+
6
+ type DatePickerProps = Omit<DatePickerProps$1<Dayjs>, 'value' | 'onChange'> & {
7
+ tabIndex?: number;
8
+ helperText?: ReactNode;
9
+ required?: boolean;
10
+ value?: Date | null | undefined;
11
+ onChange(value: Date | null | undefined): void;
12
+ };
13
+
14
+ declare const DatePicker: ({ value, onChange, tabIndex, helperText, required, ...other }: DatePickerProps) => react_jsx_runtime.JSX.Element;
15
+
16
+ export { DatePicker as default };
@@ -0,0 +1,7 @@
1
+ import { DatePicker } from '@mui/x-date-pickers-pro';
2
+ import s from 'dayjs';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ var P=({value:t,onChange:l,tabIndex:e,helperText:i,required:p,...o})=>jsx(DatePicker,{...o,format:"DD/MM/YYYY",value:t?s(t):null,onChange:r=>l(r?r.toDate():null),slotProps:{textField:{...o.slotProps?.textField,required:p,helperText:i,autoComplete:"off",spellCheck:"false",fullWidth:!0,inputProps:{tabIndex:e}},openPickerButton:{tabIndex:e}}}),c=P;
6
+
7
+ export { c as default };
@@ -0,0 +1,20 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { DateRangePickerProps as DateRangePickerProps$1 } from '@mui/x-date-pickers-pro';
4
+ import { Dayjs } from 'dayjs';
5
+
6
+ type DateRange = {
7
+ startDate?: Date | null | undefined;
8
+ endDate?: Date | null | undefined;
9
+ };
10
+ type DateRangePickerProps = Omit<DateRangePickerProps$1<Dayjs>, 'value' | 'onChange'> & {
11
+ value?: DateRange;
12
+ onChange(value?: DateRange): void;
13
+ tabIndex?: number;
14
+ helperText?: ReactNode;
15
+ required?: boolean;
16
+ };
17
+
18
+ declare const DateRangePicker: ({ label, value, onChange, tabIndex, helperText, required, ...other }: DateRangePickerProps) => react_jsx_runtime.JSX.Element;
19
+
20
+ export { DateRangePicker as default };
@@ -0,0 +1,7 @@
1
+ import { DateRangePicker } from '@mui/x-date-pickers-pro';
2
+ import o from 'dayjs';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ var p=({label:a,value:e,onChange:l,tabIndex:n,helperText:D,required:s,...r})=>jsx(DateRangePicker,{format:"DD/MM/YYYY",value:[e?.startDate?o(e.startDate):null,e?.endDate?o(e.endDate):null],onChange:t=>l({startDate:t[0]?t[0].toDate():null,endDate:t[1]?t[1].toDate():null}),...r,slotProps:{textField:({position:t})=>({...r.slotProps?.textField,required:s,helperText:D,autoComplete:"off",spellCheck:"false",fullWidth:!0,label:t==="start"?`${a} (Dt. In\xEDcio)`:`${a} (Dt. Fim)`,inputProps:{tabIndex:n}})},sx:{width:1}}),m=p;
6
+
7
+ export { m as default };
@@ -0,0 +1,16 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { DateTimePickerProps as DateTimePickerProps$1 } from '@mui/x-date-pickers-pro';
4
+ import { Dayjs } from 'dayjs';
5
+
6
+ type DateTimePickerProps = Omit<DateTimePickerProps$1<Dayjs>, 'value' | 'onChange'> & {
7
+ tabIndex?: number;
8
+ helperText?: ReactNode;
9
+ required?: boolean;
10
+ value?: Date | null | undefined;
11
+ onChange(value: Date | null | undefined): void;
12
+ };
13
+
14
+ declare const DateTimePicker: ({ value, onChange, tabIndex, helperText, required, ...other }: DateTimePickerProps) => react_jsx_runtime.JSX.Element;
15
+
16
+ export { DateTimePicker as default };
@@ -0,0 +1,7 @@
1
+ import { DateTimePicker } from '@mui/x-date-pickers-pro';
2
+ import a from 'dayjs';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ var s=({value:e,onChange:i,tabIndex:t,helperText:l,required:m,...o})=>jsx(DateTimePicker,{...o,format:"DD/MM/YYYY HH:mm",value:e?a(e):null,onChange:r=>i(r?r.toDate():null),slotProps:{textField:{...o.slotProps?.textField,required:m,helperText:l,autoComplete:"off",spellCheck:"false",fullWidth:!0,inputProps:{tabIndex:t}},openPickerButton:{tabIndex:t}}}),D=s;
6
+
7
+ export { D as default };
@@ -1,8 +1,8 @@
1
- export { a as default } from '../../chunk-OWZUABY4.mjs';
1
+ export { a as default } from '../../chunk-CKOWGDWH.mjs';
2
2
  import '../../chunk-2ZLS7IUJ.mjs';
3
3
  import '../../chunk-OUPUY4L2.mjs';
4
- import '../../chunk-SXVKHA6L.mjs';
5
4
  import '../../chunk-WHA7HOMZ.mjs';
5
+ import '../../chunk-SXVKHA6L.mjs';
6
6
  import '../../chunk-MUAMRRNL.mjs';
7
7
  import '../../chunk-QHCGLZFD.mjs';
8
8
  import '../../chunk-KLIYANST.mjs';
@@ -1,8 +1,8 @@
1
1
  import { b, a as a$4 } from '../../chunk-MAKO5GLN.mjs';
2
2
  import { a as a$1 } from '../../chunk-2ZLS7IUJ.mjs';
3
3
  import { a } from '../../chunk-OUPUY4L2.mjs';
4
- import { a as a$3 } from '../../chunk-SXVKHA6L.mjs';
5
4
  import { a as a$2 } from '../../chunk-WHA7HOMZ.mjs';
5
+ import { a as a$3 } from '../../chunk-SXVKHA6L.mjs';
6
6
  import '../../chunk-MUAMRRNL.mjs';
7
7
  import { a as a$5 } from '../../chunk-QHCGLZFD.mjs';
8
8
  import '../../chunk-KLIYANST.mjs';
@@ -0,0 +1,16 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { TimePickerProps as TimePickerProps$1 } from '@mui/x-date-pickers-pro';
4
+ import { Dayjs } from 'dayjs';
5
+
6
+ type TimePickerProps = Omit<TimePickerProps$1<Dayjs>, 'value' | 'onChange'> & {
7
+ tabIndex?: number;
8
+ helperText?: ReactNode;
9
+ required?: boolean;
10
+ value?: Date | null | undefined;
11
+ onChange(value: Date | null | undefined): void;
12
+ };
13
+
14
+ declare const TimePicker: ({ value, onChange, tabIndex, helperText, required, ...other }: TimePickerProps) => react_jsx_runtime.JSX.Element;
15
+
16
+ export { TimePicker as default };
@@ -0,0 +1,7 @@
1
+ import { TimePicker } from '@mui/x-date-pickers-pro';
2
+ import s from 'dayjs';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ var P=({value:e,onChange:i,tabIndex:o,helperText:l,required:m,...r})=>jsx(TimePicker,{...r,format:"HH:mm",value:e?s(e):null,onChange:t=>i(t?t.toDate():null),slotProps:{textField:{...r.slotProps?.textField,required:m,helperText:l,autoComplete:"off",spellCheck:"false",fullWidth:!0,inputProps:{tabIndex:o}},openPickerButton:{tabIndex:o}}}),k=P;
6
+
7
+ export { k as default };
@@ -1,5 +1,5 @@
1
- import { a as a$2 } from '../../../chunk-ZREC5BF3.mjs';
2
1
  import { a as a$1 } from '../../../chunk-HQYCK4C3.mjs';
2
+ import { a as a$2 } from '../../../chunk-ZREC5BF3.mjs';
3
3
  import { a as a$3 } from '../../../chunk-POP3P3YE.mjs';
4
4
  import '../../../chunk-6UGYYTYE.mjs';
5
5
  import '../../../chunk-D6NU2WRK.mjs';
@@ -1,8 +1,8 @@
1
1
  import { useFormContext, Controller } from 'react-hook-form';
2
2
  import { DatePicker } from '@mui/x-date-pickers-pro';
3
- import D from 'dayjs';
3
+ import k from 'dayjs';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
6
- var h=({name:i,rules:n,tabIndex:t,helperText:s,required:p,...e})=>{let{control:m}=useFormContext();return jsx(Controller,{name:i,control:m,rules:n,render:({field:{ref:u,onChange:c,...o},fieldState:{error:l}})=>jsx(DatePicker,{inputRef:u,format:"DD/MM/YYYY",localeText:{previousMonth:"M\xEAs anterior",nextMonth:"Pr\xF3ximo m\xEAs",fieldDayPlaceholder:()=>"dd",fieldMonthPlaceholder:()=>"mm",fieldYearPlaceholder:()=>"aaaa",...e.localeText},...o,...e,value:o.value?D(o.value):null,onChange:r=>c(r?r.toDate():null),slotProps:{textField:{...e.slotProps?.textField,required:p,error:!!l,helperText:l?.message||s,autoComplete:"off",spellCheck:"false",fullWidth:!0,inputProps:{tabIndex:t}},openPickerButton:{tabIndex:t}}})})},C=h;
6
+ var d=({name:p,rules:s,tabIndex:t,helperText:i,required:n,...o})=>{let{control:u}=useFormContext();return jsx(Controller,{name:p,control:u,rules:s,render:({field:{ref:m,onChange:f,...e},fieldState:{error:r}})=>jsx(DatePicker,{inputRef:m,format:"DD/MM/YYYY",...e,...o,value:e.value?k(e.value):null,onChange:l=>f(l?l.toDate():null),slotProps:{textField:{...o.slotProps?.textField,required:n,error:!!r,helperText:r?.message||i,autoComplete:"off",spellCheck:"false",fullWidth:!0,inputProps:{tabIndex:t}},openPickerButton:{tabIndex:t}}})})},x=d;
7
7
 
8
- export { C as default };
8
+ export { x as default };
@@ -1,8 +1,8 @@
1
1
  import { useFormContext, Controller } from 'react-hook-form';
2
2
  import { DateRangePicker } from '@mui/x-date-pickers-pro';
3
- import n from 'dayjs';
3
+ import l from 'dayjs';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
6
- var x=({name:r,label:a,rules:i,tabIndex:d,helperText:D,required:m,...o})=>{let{control:f,setError:c}=useFormContext();return jsx(Controller,{name:r,control:f,rules:i,render:({field:{value:t,onChange:p},fieldState:{error:l}})=>jsx(DateRangePicker,{format:"DD/MM/YYYY",localeText:{previousMonth:"M\xEAs anterior",nextMonth:"Pr\xF3ximo m\xEAs",fieldDayPlaceholder:()=>"dd",fieldMonthPlaceholder:()=>"mm",fieldYearPlaceholder:()=>"aaaa",...o.localeText},value:[t?.startDate?n(t.startDate):null,t?.endDate?n(t.endDate):null],onChange:e=>p({startDate:e[0]?e[0].toDate():null,endDate:e[1]?e[1].toDate():null}),onError:e=>{c(r,{message:e[0]||e[1]||void 0});},...o,slotProps:{textField:({position:e})=>({...o.slotProps?.textField,required:m,error:!!l,helperText:l?.message||D,autoComplete:"off",spellCheck:"false",fullWidth:!0,label:e==="start"?`${a} (Dt. In\xEDcio)`:`${a} (Dt. Fim)`,inputProps:{tabIndex:d}})},sx:{width:1}})})},C=x;
6
+ var k=({name:r,label:o,rules:i,tabIndex:D,helperText:d,required:p,...a})=>{let{control:f,setError:m}=useFormContext();return jsx(Controller,{name:r,control:f,rules:i,render:({field:{value:t,onChange:u},fieldState:{error:n}})=>jsx(DateRangePicker,{format:"DD/MM/YYYY",value:[t?.startDate?l(t.startDate):null,t?.endDate?l(t.endDate):null],onChange:e=>u({startDate:e[0]?e[0].toDate():null,endDate:e[1]?e[1].toDate():null}),onError:e=>{m(r,{message:e[0]||e[1]||void 0});},...a,slotProps:{textField:({position:e})=>({...a.slotProps?.textField,required:p,error:!!n,helperText:n?.message||d,autoComplete:"off",spellCheck:"false",fullWidth:!0,label:e==="start"?`${o} (Dt. In\xEDcio)`:`${o} (Dt. Fim)`,inputProps:{tabIndex:D}})},sx:{width:1}})})},h=k;
7
7
 
8
- export { C as default };
8
+ export { h as default };
@@ -1,8 +1,8 @@
1
1
  import { useFormContext, Controller } from 'react-hook-form';
2
2
  import { DateTimePicker } from '@mui/x-date-pickers-pro';
3
- import h from 'dayjs';
3
+ import k from 'dayjs';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
6
- var D=({name:i,rules:m,tabIndex:l,helperText:n,required:s,...e})=>{let{control:u}=useFormContext();return jsx(Controller,{name:i,control:u,rules:m,render:({field:{ref:c,onChange:d,...o},fieldState:{error:t}})=>jsx(DateTimePicker,{format:"DD/MM/YYYY HH:mm",inputRef:c,localeText:{previousMonth:"M\xEAs anterior",nextMonth:"Pr\xF3ximo m\xEAs",fieldDayPlaceholder:()=>"dd",fieldMonthPlaceholder:()=>"mm",fieldYearPlaceholder:()=>"aaaa",fieldHoursPlaceholder:()=>"hh",fieldMinutesPlaceholder:()=>"mm",...e.localeText},...o,...e,value:o.value?h(o.value):null,onChange:r=>d(r?r.toDate():null),slotProps:{textField:{...e.slotProps?.textField,required:s,error:!!t,helperText:t?.message||n,autoComplete:"off",spellCheck:"false",fullWidth:!0,inputProps:{tabIndex:l}},openPickerButton:{tabIndex:l}}})})},x=D;
6
+ var T=({name:m,rules:a,tabIndex:t,helperText:p,required:s,...o})=>{let{control:n}=useFormContext();return jsx(Controller,{name:m,control:n,rules:a,render:({field:{ref:u,onChange:f,...e},fieldState:{error:r}})=>jsx(DateTimePicker,{format:"DD/MM/YYYY HH:mm",inputRef:u,...e,...o,value:e.value?k(e.value):null,onChange:l=>f(l?l.toDate():null),slotProps:{textField:{...o.slotProps?.textField,required:s,error:!!r,helperText:r?.message||p,autoComplete:"off",spellCheck:"false",fullWidth:!0,inputProps:{tabIndex:t}},openPickerButton:{tabIndex:t}}})})},h=T;
7
7
 
8
- export { x as default };
8
+ export { h as default };
@@ -1,8 +1,8 @@
1
- import { a } from '../../../chunk-OWZUABY4.mjs';
1
+ import { a } from '../../../chunk-CKOWGDWH.mjs';
2
2
  import '../../../chunk-2ZLS7IUJ.mjs';
3
3
  import '../../../chunk-OUPUY4L2.mjs';
4
- import '../../../chunk-SXVKHA6L.mjs';
5
4
  import '../../../chunk-WHA7HOMZ.mjs';
5
+ import '../../../chunk-SXVKHA6L.mjs';
6
6
  import '../../../chunk-MUAMRRNL.mjs';
7
7
  import '../../../chunk-QHCGLZFD.mjs';
8
8
  import '../../../chunk-KLIYANST.mjs';
@@ -3,6 +3,6 @@ import { TimePicker } from '@mui/x-date-pickers-pro';
3
3
  import T from 'dayjs';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
6
- var k=({name:m,rules:s,tabIndex:l,helperText:a,required:p,...e})=>{let{control:u}=useFormContext();return jsx(Controller,{name:m,control:u,rules:s,render:({field:{ref:n,onChange:c,...o},fieldState:{error:r}})=>jsx(TimePicker,{ampm:!1,format:"HH:mm",inputRef:n,localeText:{fieldHoursPlaceholder:()=>"hh",fieldMinutesPlaceholder:()=>"mm",...e.localeText},...o,...e,value:o.value?T(o.value):null,onChange:t=>c(t?t.toDate():null),slotProps:{textField:{...e.slotProps?.textField,error:!!r,required:p,helperText:r?.message||a,autoComplete:"off",spellCheck:"false",fullWidth:!0,inputProps:{tabIndex:l}},openPickerButton:{tabIndex:l}}})})},F=k;
6
+ var d=({name:i,rules:p,tabIndex:o,helperText:s,required:n,...r})=>{let{control:u}=useFormContext();return jsx(Controller,{name:i,control:u,rules:p,render:({field:{ref:a,onChange:f,...e},fieldState:{error:t}})=>jsx(TimePicker,{ampm:!1,format:"HH:mm",inputRef:a,...e,...r,value:e.value?T(e.value):null,onChange:l=>f(l?l.toDate():null),slotProps:{textField:{...r.slotProps?.textField,error:!!t,required:n,helperText:t?.message||s,autoComplete:"off",spellCheck:"false",fullWidth:!0,inputProps:{tabIndex:o}},openPickerButton:{tabIndex:o}}})})},F=d;
7
7
 
8
8
  export { F as default };
@@ -1,9 +1,9 @@
1
1
  import { b } from '../../../chunk-EPIVCFTK.mjs';
2
2
  import '../../../chunk-CLXZIOVZ.mjs';
3
3
  import '../../../chunk-PABYPOVH.mjs';
4
+ import '../../../chunk-FXUKC2TO.mjs';
4
5
  import '../../../chunk-NNSTFVSV.mjs';
5
6
  import '../../../chunk-EVHG7UNX.mjs';
6
- import '../../../chunk-FXUKC2TO.mjs';
7
7
  import '../../../chunk-S6AXG7VS.mjs';
8
8
  import { a } from '../../../chunk-R2LSQJYW.mjs';
9
9
  import '../../../chunk-OKHG4T22.mjs';
@@ -1,9 +1,9 @@
1
1
  import { d as d$1 } from '../../../chunk-LWMTG62I.mjs';
2
2
  import { d, e } from '../../../chunk-CLXZIOVZ.mjs';
3
3
  import { a as a$4 } from '../../../chunk-PABYPOVH.mjs';
4
+ import '../../../chunk-FXUKC2TO.mjs';
4
5
  import '../../../chunk-NNSTFVSV.mjs';
5
6
  import '../../../chunk-EVHG7UNX.mjs';
6
- import '../../../chunk-FXUKC2TO.mjs';
7
7
  import { a as a$2 } from '../../../chunk-WMRVP7HJ.mjs';
8
8
  import '../../../chunk-S6AXG7VS.mjs';
9
9
  import { a } from '../../../chunk-R2LSQJYW.mjs';
@@ -2,9 +2,9 @@ export { a as UploadAvatar, b as UploadAvatarWithCrop, b as UploadWithCrop } fro
2
2
  export { c as DeleteButton, a as MultiFilePreview, b as SingleFilePreview, d as Upload } from '../../chunk-LWMTG62I.mjs';
3
3
  export { c as RejectionFiles } from '../../chunk-CLXZIOVZ.mjs';
4
4
  import '../../chunk-PABYPOVH.mjs';
5
+ import '../../chunk-FXUKC2TO.mjs';
5
6
  import '../../chunk-NNSTFVSV.mjs';
6
7
  import '../../chunk-EVHG7UNX.mjs';
7
- import '../../chunk-FXUKC2TO.mjs';
8
8
  import { i } from '../../chunk-S6AXG7VS.mjs';
9
9
  import '../../chunk-OKHG4T22.mjs';
10
10
  import '../../chunk-BQ3PJ47P.mjs';
@@ -1,4 +1,4 @@
1
- declare const isValidDate: (date: string | Date) => boolean;
1
+ declare const isValidDate: (date?: string | Date | null) => boolean;
2
2
  declare function stringToDate(dateString?: string, format?: string): Date | null;
3
3
 
4
4
  export { isValidDate, stringToDate };
@@ -1,6 +1,6 @@
1
1
  import r from 'dayjs';
2
- import n from 'dayjs/plugin/customParseFormat';
2
+ import e from 'dayjs/plugin/customParseFormat';
3
3
 
4
- r.extend(n);var a=t=>r(t).isValid();function l(t,e="DD/MM/YYYY HH:mm:ss"){if(!t)return null;let o=r(t,e);return o.isValid()?o.toDate():null}
4
+ r.extend(e);var a=t=>t?r(t).isValid():!1;function l(t,o="DD/MM/YYYY HH:mm:ss"){if(!t)return null;let n=r(t,o);return n.isValid()?n.toDate():null}
5
5
 
6
6
  export { a as isValidDate, l as stringToDate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  import { a as a$3 } from './chunk-2ZLS7IUJ.mjs';
2
2
  import { a as a$1 } from './chunk-OUPUY4L2.mjs';
3
- import { a as a$2 } from './chunk-SXVKHA6L.mjs';
4
3
  import { a as a$4 } from './chunk-WHA7HOMZ.mjs';
4
+ import { a as a$2 } from './chunk-SXVKHA6L.mjs';
5
5
  import { a as a$5 } from './chunk-QHCGLZFD.mjs';
6
6
  import { useState } from 'react';
7
7
  import L from '@mui/material/Button';