@paygreen/pgui 2.7.0 → 2.8.0
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/cjs/index.js +187 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/InputDayPicker/index.d.ts +5 -2
- package/dist/cjs/types/components/InputRangePicker/index.d.ts +17 -0
- package/dist/cjs/types/components/NewDayPicker/index.d.ts +4 -2
- package/dist/cjs/types/components/index.d.ts +1 -0
- package/dist/esm/index.js +188 -19
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/InputDayPicker/index.d.ts +5 -2
- package/dist/esm/types/components/InputRangePicker/index.d.ts +17 -0
- package/dist/esm/types/components/NewDayPicker/index.d.ts +4 -2
- package/dist/esm/types/components/index.d.ts +1 -0
- package/dist/index.d.ts +23 -3
- package/package.json +1 -1
|
@@ -6,8 +6,11 @@ export type InputDayPickerProps = {
|
|
|
6
6
|
onChange: Dispatch<SetStateAction<string | undefined | null>>;
|
|
7
7
|
value?: string | Date;
|
|
8
8
|
locale?: string;
|
|
9
|
-
variant?:
|
|
9
|
+
variant?: 'unstyled' | 'filled' | 'outlined';
|
|
10
10
|
format?: string;
|
|
11
11
|
withTime?: boolean;
|
|
12
|
+
minDate?: Date | null | undefined;
|
|
13
|
+
maxDate?: Date | null | undefined;
|
|
14
|
+
calendarFunc: (date: any) => 'after-max-date' | 'before-min-date' | undefined;
|
|
12
15
|
} & InputProps;
|
|
13
|
-
export declare const InputDayPicker: ({ name, placeholder, value, onChange, locale, variant, format, withTime, ...inputProps }: InputDayPickerProps) => JSX.Element;
|
|
16
|
+
export declare const InputDayPicker: ({ name, placeholder, value, onChange, locale, variant, format, withTime, minDate, maxDate, calendarFunc, ...inputProps }: InputDayPickerProps) => JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
export interface ValueProps {
|
|
3
|
+
from: Date | null | undefined;
|
|
4
|
+
to: Date | null | undefined;
|
|
5
|
+
}
|
|
6
|
+
export type InputRangePickerProps = {
|
|
7
|
+
fromLabel: string;
|
|
8
|
+
toLabel: string;
|
|
9
|
+
onChange: Dispatch<SetStateAction<ValueProps | undefined>>;
|
|
10
|
+
minDate?: Date | null;
|
|
11
|
+
maxDate?: Date | null;
|
|
12
|
+
format?: string;
|
|
13
|
+
value?: ValueProps;
|
|
14
|
+
withTime?: boolean;
|
|
15
|
+
variant?: 'unstyled' | 'filled' | 'outlined';
|
|
16
|
+
};
|
|
17
|
+
export declare const InputRangePicker: ({ fromLabel, toLabel, value, onChange, minDate, maxDate, withTime, format, variant, ...props }: InputRangePickerProps) => JSX.Element;
|
|
@@ -4,9 +4,11 @@ import 'dayjs/locale/fr';
|
|
|
4
4
|
export type NewDayPickerProps = {
|
|
5
5
|
defaultValue?: string | Date;
|
|
6
6
|
onChange: (e: string | undefined) => void;
|
|
7
|
-
format: string;
|
|
8
7
|
locale?: string;
|
|
9
8
|
customFormat?: string;
|
|
10
9
|
withTime?: boolean;
|
|
10
|
+
minDate?: Date | null;
|
|
11
|
+
maxDate?: Date | null;
|
|
12
|
+
calendarFunc: (date: any) => 'after-max-date' | 'before-min-date' | undefined;
|
|
11
13
|
};
|
|
12
|
-
export declare const NewDayPicker: ({ defaultValue, onChange, locale, customFormat, withTime, ...props }: NewDayPickerProps) => JSX.Element;
|
|
14
|
+
export declare const NewDayPicker: ({ defaultValue, onChange, locale, customFormat, withTime, minDate, maxDate, calendarFunc, ...props }: NewDayPickerProps) => JSX.Element;
|
|
@@ -6,6 +6,7 @@ export * from './DayPicker';
|
|
|
6
6
|
export * from './FormGroup';
|
|
7
7
|
export * from './InputDayPicker';
|
|
8
8
|
export * from './InputPhone';
|
|
9
|
+
export * from './InputRangePicker';
|
|
9
10
|
export * from './ModalResponsive';
|
|
10
11
|
export * from './Pagination';
|
|
11
12
|
export * from './SearchInput';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { useState, useRef, useEffect, useContext, createContext as createContext$1, forwardRef as forwardRef$2, Component, useCallback, useMemo, useLayoutEffect, createElement, Fragment, Children } from 'react';
|
|
3
|
-
import { forwardRef as forwardRef$1, IconButton, Flex as Flex$1, createStylesContext, chakra as chakra$1, useMultiStyleConfig, useMenuItem, MenuIcon, MenuCommand, useMenuState, Icon as Icon$1, Text, useBreakpointValue, AccordionItem, AccordionButton, AccordionIcon, AccordionPanel, Box, Accordion, FormControl, FormLabel, FormHelperText, FormErrorMessage, SlideFade, useTheme as useTheme$1, VStack, Stack, Button as Button$1, HStack, InputGroup, InputLeftElement, Input as Input$4, useDisclosure, Popover, PopoverTrigger, InputRightElement, PopoverContent, PopoverArrow, useOutsideClick, List, ListItem, Drawer, DrawerOverlay, DrawerContent, DrawerCloseButton, Modal, ModalOverlay, ModalContent, ModalCloseButton, useControllableState, useMergeRefs, useColorModeValue, useStyleConfig as useStyleConfig$1, useToken, useBreakpoint, extendTheme } from '@chakra-ui/react';
|
|
3
|
+
import { forwardRef as forwardRef$1, IconButton, Flex as Flex$1, createStylesContext, chakra as chakra$1, useMultiStyleConfig, useMenuItem, MenuIcon, MenuCommand, useMenuState, Icon as Icon$1, Text, useBreakpointValue, AccordionItem, AccordionButton, AccordionIcon, AccordionPanel, Box, Accordion, FormControl, FormLabel, FormHelperText, FormErrorMessage, SlideFade, useTheme as useTheme$1, VStack, Stack, Button as Button$1, HStack, InputGroup, InputLeftElement, Input as Input$4, useDisclosure, Popover, PopoverTrigger, InputRightElement, PopoverContent, PopoverArrow, useOutsideClick, List, ListItem, Wrap, WrapItem, Drawer, DrawerOverlay, DrawerContent, DrawerCloseButton, Modal, ModalOverlay, ModalContent, ModalCloseButton, useControllableState, useMergeRefs, useColorModeValue, useStyleConfig as useStyleConfig$1, useToken, useBreakpoint, extendTheme } from '@chakra-ui/react';
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -42826,7 +42826,7 @@ var containsAnyLetters = function (str) {
|
|
|
42826
42826
|
return /[a-zA-Z]/.test(str);
|
|
42827
42827
|
};
|
|
42828
42828
|
var NewDayPicker = function (_a) {
|
|
42829
|
-
var defaultValue = _a.defaultValue, onChange = _a.onChange, _b = _a.locale, locale = _b === void 0 ? 'fr' : _b, customFormat = _a.customFormat, _c = _a.withTime, withTime = _c === void 0 ? false : _c, props = __rest$2(_a, ["defaultValue", "onChange", "locale", "customFormat", "withTime"]);
|
|
42829
|
+
var defaultValue = _a.defaultValue, onChange = _a.onChange, _b = _a.locale, locale = _b === void 0 ? 'fr' : _b, customFormat = _a.customFormat, _c = _a.withTime, withTime = _c === void 0 ? false : _c, minDate = _a.minDate, maxDate = _a.maxDate, calendarFunc = _a.calendarFunc, props = __rest$2(_a, ["defaultValue", "onChange", "locale", "customFormat", "withTime", "minDate", "maxDate", "calendarFunc"]);
|
|
42830
42830
|
var initialFormat = function () {
|
|
42831
42831
|
if (locale === 'fr' && withTime)
|
|
42832
42832
|
return "DD/MM/YYYY HH:mm";
|
|
@@ -42840,16 +42840,31 @@ var NewDayPicker = function (_a) {
|
|
|
42840
42840
|
var _d = useState(defaultValue), value = _d[0], setValue = _d[1];
|
|
42841
42841
|
var _e = useState('00:00'), timeValue = _e[0], setTimeValue = _e[1];
|
|
42842
42842
|
var _f = useState(false), isInvalid = _f[0], setIsInvalid = _f[1];
|
|
42843
|
-
var _g = useState(dayjs()
|
|
42844
|
-
|
|
42845
|
-
|
|
42846
|
-
|
|
42847
|
-
|
|
42848
|
-
|
|
42843
|
+
var _g = useState(dayjs(defaultValue).format(withTime ? 'DD/MM/YYYY HH:mm' : 'DD/MM/YYYY') ||
|
|
42844
|
+
dayjs()
|
|
42845
|
+
.set('hours', 0)
|
|
42846
|
+
.set('minutes', 0)
|
|
42847
|
+
.set('seconds', 0)
|
|
42848
|
+
.locale(locale)
|
|
42849
|
+
.format(format)), inputValue = _g[0], setInputValue = _g[1];
|
|
42849
42850
|
var theme = useTheme$1();
|
|
42850
42851
|
useEffect(function () {
|
|
42851
42852
|
if (value) {
|
|
42852
|
-
|
|
42853
|
+
if (minDate || maxDate) {
|
|
42854
|
+
if (minDate && dayjs(value).diff(dayjs(minDate)) < 0) {
|
|
42855
|
+
setInputValue(dayjs(minDate).format(format));
|
|
42856
|
+
setValue(minDate);
|
|
42857
|
+
onChange(dayjs(minDate).toISOString());
|
|
42858
|
+
}
|
|
42859
|
+
if (maxDate && dayjs(value).diff(dayjs(maxDate)) > 0) {
|
|
42860
|
+
setInputValue(dayjs(maxDate).format(format));
|
|
42861
|
+
setValue(maxDate);
|
|
42862
|
+
onChange(dayjs(maxDate).toISOString());
|
|
42863
|
+
}
|
|
42864
|
+
}
|
|
42865
|
+
else {
|
|
42866
|
+
setInputValue(dayjs(value).format(format));
|
|
42867
|
+
}
|
|
42853
42868
|
if (withTime) {
|
|
42854
42869
|
setTimeValue(dayjs(value).format('HH:mm'));
|
|
42855
42870
|
}
|
|
@@ -42857,7 +42872,7 @@ var NewDayPicker = function (_a) {
|
|
|
42857
42872
|
else {
|
|
42858
42873
|
setInputValue('');
|
|
42859
42874
|
}
|
|
42860
|
-
}, [value]);
|
|
42875
|
+
}, [defaultValue, value]);
|
|
42861
42876
|
var timer = [
|
|
42862
42877
|
'00:00',
|
|
42863
42878
|
'00:30',
|
|
@@ -42921,7 +42936,7 @@ var NewDayPicker = function (_a) {
|
|
|
42921
42936
|
};
|
|
42922
42937
|
return (React__default.createElement(VStack, __assign$2({ spacing: "2", maxW: "full", p: 2, w: "fit-content", maxWidth: "30rem", borderRadius: "md" }, props),
|
|
42923
42938
|
React__default.createElement(Stack, { direction: { base: 'column', sm: 'row' }, spacing: 2, w: "full" },
|
|
42924
|
-
React__default.createElement(Calendar, { locale: locale, onChange: function (e) {
|
|
42939
|
+
React__default.createElement(Calendar, { locale: locale, minDate: minDate, maxDate: maxDate, tileClassName: calendarFunc, onChange: function (e) {
|
|
42925
42940
|
setValue(e);
|
|
42926
42941
|
onChange(dayjs(e).toISOString());
|
|
42927
42942
|
setTimeValue('00:00');
|
|
@@ -42935,14 +42950,36 @@ var NewDayPicker = function (_a) {
|
|
|
42935
42950
|
.set('hours', parseInt(t.slice(0, 2), 10))
|
|
42936
42951
|
.set('minutes', parseInt(t.slice(-2), 10));
|
|
42937
42952
|
setValue(settedValue.toDate());
|
|
42938
|
-
|
|
42953
|
+
if (minDate && settedValue.diff(dayjs(minDate)) < 0) {
|
|
42954
|
+
onChange(dayjs(minDate).toISOString());
|
|
42955
|
+
}
|
|
42956
|
+
else if (maxDate &&
|
|
42957
|
+
settedValue.diff(dayjs(maxDate)) > 0) {
|
|
42958
|
+
onChange(dayjs(maxDate).toISOString());
|
|
42959
|
+
}
|
|
42960
|
+
else {
|
|
42961
|
+
onChange(settedValue.toISOString());
|
|
42962
|
+
}
|
|
42939
42963
|
setTimeValue(t);
|
|
42940
42964
|
setInputValue(dayjs(settedValue.toDate()).format(format));
|
|
42941
42965
|
setIsInvalid(false);
|
|
42942
42966
|
}, _active: {
|
|
42943
42967
|
backgroundColor: 'white',
|
|
42944
42968
|
color: 'brand.600'
|
|
42945
|
-
}
|
|
42969
|
+
}, isDisabled: (minDate === null
|
|
42970
|
+
? undefined
|
|
42971
|
+
: minDate &&
|
|
42972
|
+
dayjs(value)
|
|
42973
|
+
.set('hours', parseInt(t.slice(0, 2), 10))
|
|
42974
|
+
.set('minutes', parseInt(t.slice(-2), 10))
|
|
42975
|
+
.diff(dayjs(minDate)) < 0) ||
|
|
42976
|
+
(maxDate === null
|
|
42977
|
+
? undefined
|
|
42978
|
+
: maxDate &&
|
|
42979
|
+
dayjs(value)
|
|
42980
|
+
.set('hours', parseInt(t.slice(0, 2), 10))
|
|
42981
|
+
.set('minutes', parseInt(t.slice(-2), 10))
|
|
42982
|
+
.diff(dayjs(maxDate)) > 0) }, t)); })))))),
|
|
42946
42983
|
React__default.createElement(HStack, { w: "full" },
|
|
42947
42984
|
React__default.createElement(InputGroup, { w: "full", size: "sm" },
|
|
42948
42985
|
React__default.createElement(InputLeftElement, { pointerEvents: "none", color: "gray.300", fontSize: "1.2em", children: React__default.createElement(Icon$1, { as: MdCalendarToday }) }),
|
|
@@ -42952,9 +42989,17 @@ var NewDayPicker = function (_a) {
|
|
|
42952
42989
|
containsAnyLetters(e.target.value);
|
|
42953
42990
|
if (!isInvalidFormat &&
|
|
42954
42991
|
((_a = dayjs(e.target.value, format)) === null || _a === void 0 ? void 0 : _a.isValid())) {
|
|
42992
|
+
onChange((_c = (_b = dayjs(e.target.value, format)) === null || _b === void 0 ? void 0 : _b.locale(locale)) === null || _c === void 0 ? void 0 : _c.toISOString());
|
|
42955
42993
|
setInputValue(dayjs(e.target.value, format).locale(locale).format(format));
|
|
42956
42994
|
setValue(dayjs(e.target.value, format).locale(locale).toDate());
|
|
42957
|
-
|
|
42995
|
+
if (minDate &&
|
|
42996
|
+
dayjs(e.target.value, format).diff(dayjs(minDate)) < 0) {
|
|
42997
|
+
onChange(dayjs(minDate).toISOString());
|
|
42998
|
+
}
|
|
42999
|
+
else if (maxDate &&
|
|
43000
|
+
dayjs(e.target.value, format).diff(dayjs(maxDate)) > 0) {
|
|
43001
|
+
onChange(dayjs(maxDate).toISOString());
|
|
43002
|
+
}
|
|
42958
43003
|
setIsInvalid(false);
|
|
42959
43004
|
}
|
|
42960
43005
|
else {
|
|
@@ -42971,7 +43016,7 @@ var NewDayPicker = function (_a) {
|
|
|
42971
43016
|
dayjs.extend(customParseFormat);
|
|
42972
43017
|
dayjs.extend(utc);
|
|
42973
43018
|
var InputDayPicker = function (_a) {
|
|
42974
|
-
var name = _a.name, placeholder = _a.placeholder, value = _a.value, onChange = _a.onChange, _b = _a.locale, locale = _b === void 0 ? 'fr' : _b, _c = _a.variant, variant = _c === void 0 ? 'filled' : _c, _d = _a.format, format = _d === void 0 ? 'DD/MM/YYYY' : _d, _e = _a.withTime, withTime = _e === void 0 ? false : _e, inputProps = __rest$2(_a, ["name", "placeholder", "value", "onChange", "locale", "variant", "format", "withTime"]);
|
|
43019
|
+
var name = _a.name, placeholder = _a.placeholder, value = _a.value, onChange = _a.onChange, _b = _a.locale, locale = _b === void 0 ? 'fr' : _b, _c = _a.variant, variant = _c === void 0 ? 'filled' : _c, _d = _a.format, format = _d === void 0 ? 'DD/MM/YYYY' : _d, _e = _a.withTime, withTime = _e === void 0 ? false : _e, minDate = _a.minDate, maxDate = _a.maxDate, calendarFunc = _a.calendarFunc, inputProps = __rest$2(_a, ["name", "placeholder", "value", "onChange", "locale", "variant", "format", "withTime", "minDate", "maxDate", "calendarFunc"]);
|
|
42975
43020
|
var _f = useDisclosure(), isOpen = _f.isOpen, onClose = _f.onClose, onToggle = _f.onToggle;
|
|
42976
43021
|
var _g = useState(''), prev = _g[0], setPrev = _g[1];
|
|
42977
43022
|
useEffect(function () {
|
|
@@ -42998,7 +43043,9 @@ var InputDayPicker = function (_a) {
|
|
|
42998
43043
|
React__default.createElement(Popover, { closeOnBlur: true, closeOnEsc: true, isOpen: isOpen, onClose: onClose, placement: "bottom", autoFocus: true },
|
|
42999
43044
|
React__default.createElement(PopoverTrigger, null,
|
|
43000
43045
|
React__default.createElement(InputGroup, null,
|
|
43001
|
-
React__default.createElement(Input$4, __assign$2({ as: Button$1, onClick: onToggle, name: name, fontWeight: "normal", justifyContent: "flex-start",
|
|
43046
|
+
React__default.createElement(Input$4, __assign$2({ as: Button$1, onClick: onToggle, name: name, fontWeight: "normal", justifyContent: "flex-start", background: variant === 'filled' ? 'gray.100' : 'white', _hover: {
|
|
43047
|
+
background: variant === 'filled' ? 'gray.200' : 'gray.50'
|
|
43048
|
+
} }, inputProps), value ? dayjs(value).format(format) : placeholder),
|
|
43002
43049
|
value && (React__default.createElement(InputRightElement, { onClick: function () {
|
|
43003
43050
|
onChange(null);
|
|
43004
43051
|
}, _hover: {
|
|
@@ -43009,7 +43056,7 @@ var InputDayPicker = function (_a) {
|
|
|
43009
43056
|
} }))))),
|
|
43010
43057
|
React__default.createElement(PopoverContent, { mx: 1, width: "fit-content" },
|
|
43011
43058
|
React__default.createElement(PopoverArrow, null),
|
|
43012
|
-
isOpen && (React__default.createElement(NewDayPicker, { locale: locale, defaultValue: value, onChange: onChange,
|
|
43059
|
+
isOpen && (React__default.createElement(NewDayPicker, { locale: locale, defaultValue: value, onChange: onChange, withTime: withTime, minDate: minDate, maxDate: maxDate, calendarFunc: calendarFunc }))))));
|
|
43013
43060
|
};
|
|
43014
43061
|
|
|
43015
43062
|
// This file is a workaround for a bug in web browsers' "native"
|
|
@@ -62276,10 +62323,126 @@ var InputPhone = function (_a) {
|
|
|
62276
62323
|
}
|
|
62277
62324
|
}
|
|
62278
62325
|
}, [countryFromLocale, phoneNumber]);
|
|
62279
|
-
return (React__default.createElement(InputGroup, { position: "relative", display: "block" },
|
|
62326
|
+
return (React__default.createElement(InputGroup, { position: "relative", display: "block", sx: { isolation: 'auto' } },
|
|
62280
62327
|
React__default.createElement(PhoneInput, __assign$2({ international: true, inputComponent: Input$4, numberInputProps: { paddingLeft: '4rem' }, value: phoneNumber, labels: locale === 'fr' ? fr : en, defaultCountry: country || 'FR', disabled: isDisabled, onChange: function (val) { return setPhoneNumber(val || ''); }, addInternationalOption: false, countryCallingCodeEditable: false, countryOptionsOrder: ['FR', 'GB', 'BE', 'ES', 'DE', 'IT', 'CH'], countrySelectComponent: function (selectProps) { return (React__default.createElement(SearchOnList, __assign$2({ locale: locale }, selectProps))); } }, props))));
|
|
62281
62328
|
};
|
|
62282
62329
|
|
|
62330
|
+
var isoWeek$1 = {exports: {}};
|
|
62331
|
+
|
|
62332
|
+
(function (module, exports) {
|
|
62333
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e="day";return function(t,i,s){var a=function(t){return t.add(4-t.isoWeekday(),e)},d=i.prototype;d.isoWeekYear=function(){return a(this).year()},d.isoWeek=function(t){if(!this.$utils().u(t))return this.add(7*(t-this.isoWeek()),e);var i,d,n,o,r=a(this),u=(i=this.isoWeekYear(),d=this.$u,n=(d?s.utc:s)().year(i).startOf("year"),o=4-n.isoWeekday(),n.isoWeekday()>4&&(o+=7),n.add(o,e));return r.diff(u,"week")+1},d.isoWeekday=function(e){return this.$utils().u(e)?this.day()||7:this.day(this.day()%7?e:e-7)};var n=d.startOf;d.startOf=function(e,t){var i=this.$utils(),s=!!i.u(t)||t;return "isoweek"===i.p(e)?s?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):n.bind(this)(e,t)};}}));
|
|
62334
|
+
} (isoWeek$1));
|
|
62335
|
+
|
|
62336
|
+
var isoWeek = isoWeek$1.exports;
|
|
62337
|
+
|
|
62338
|
+
dayjs.extend(customParseFormat);
|
|
62339
|
+
dayjs.extend(utc);
|
|
62340
|
+
dayjs.extend(isoWeek);
|
|
62341
|
+
var InputRangePicker = function (_a) {
|
|
62342
|
+
var fromLabel = _a.fromLabel, toLabel = _a.toLabel, value = _a.value, onChange = _a.onChange, minDate = _a.minDate, maxDate = _a.maxDate, _b = _a.withTime, withTime = _b === void 0 ? false : _b, _c = _a.format, format = _c === void 0 ? withTime ? 'DD/MM/YYYY HH:mm' : 'DD/MM/YYYY' : _c, _d = _a.variant, variant = _d === void 0 ? 'unstyled' : _d, props = __rest$2(_a, ["fromLabel", "toLabel", "value", "onChange", "minDate", "maxDate", "withTime", "format", "variant"]);
|
|
62343
|
+
var _e = useState(), fromValue = _e[0], setFromValue = _e[1];
|
|
62344
|
+
var _f = useState(), toValue = _f[0], setToValue = _f[1];
|
|
62345
|
+
var _g = useState(minDate), formatedMinDate = _g[0], setFormatedMinDate = _g[1];
|
|
62346
|
+
var _h = useState(maxDate), formatedMaxDate = _h[0], setFormatedMaxDate = _h[1];
|
|
62347
|
+
useEffect(function () {
|
|
62348
|
+
if (!withTime) {
|
|
62349
|
+
var formatedMin = minDate
|
|
62350
|
+
? dayjs(dayjs(minDate).startOf('day').toISOString()).toDate()
|
|
62351
|
+
: null;
|
|
62352
|
+
var formatedMax = maxDate
|
|
62353
|
+
? dayjs(dayjs(maxDate).endOf('day').toISOString()).toDate()
|
|
62354
|
+
: null;
|
|
62355
|
+
setFormatedMinDate(formatedMin);
|
|
62356
|
+
setFormatedMaxDate(formatedMax);
|
|
62357
|
+
}
|
|
62358
|
+
}, [withTime]);
|
|
62359
|
+
useEffect(function () {
|
|
62360
|
+
onChange({
|
|
62361
|
+
from: fromValue ? dayjs(fromValue).toDate() : null,
|
|
62362
|
+
to: toValue ? dayjs(toValue).toDate() : null
|
|
62363
|
+
});
|
|
62364
|
+
}, [fromValue, toValue]);
|
|
62365
|
+
useEffect(function () {
|
|
62366
|
+
if (!withTime) {
|
|
62367
|
+
if (value === null || value === void 0 ? void 0 : value.from) {
|
|
62368
|
+
if (dayjs(value.from).diff(dayjs(formatedMinDate).utcOffset(0, true)) < 0) {
|
|
62369
|
+
setFromValue(dayjs(formatedMinDate).utcOffset(0, true).toISOString());
|
|
62370
|
+
}
|
|
62371
|
+
}
|
|
62372
|
+
if (value === null || value === void 0 ? void 0 : value.to) {
|
|
62373
|
+
if (dayjs(value.to).diff(dayjs(formatedMaxDate).utcOffset(0, true)) > 0) {
|
|
62374
|
+
setToValue(dayjs(formatedMaxDate).utcOffset(0, true).toISOString());
|
|
62375
|
+
}
|
|
62376
|
+
}
|
|
62377
|
+
}
|
|
62378
|
+
}, [withTime, fromValue, toValue]);
|
|
62379
|
+
var fromFunc = function (_a) {
|
|
62380
|
+
var date = _a.date;
|
|
62381
|
+
if (toValue) {
|
|
62382
|
+
if (dayjs(date)
|
|
62383
|
+
.startOf('day')
|
|
62384
|
+
.utcOffset(0, true)
|
|
62385
|
+
.diff(dayjs(toValue).endOf('day').utcOffset(0, true)) > 0) {
|
|
62386
|
+
return 'after-max-date';
|
|
62387
|
+
}
|
|
62388
|
+
}
|
|
62389
|
+
else {
|
|
62390
|
+
if (formatedMaxDate &&
|
|
62391
|
+
dayjs(date)
|
|
62392
|
+
.startOf('date')
|
|
62393
|
+
.utcOffset(0, true)
|
|
62394
|
+
.diff(dayjs(formatedMaxDate).startOf('date').utcOffset(0, true)) > 0) {
|
|
62395
|
+
return 'after-max-date';
|
|
62396
|
+
}
|
|
62397
|
+
}
|
|
62398
|
+
if (formatedMinDate &&
|
|
62399
|
+
dayjs(date)
|
|
62400
|
+
.startOf('day')
|
|
62401
|
+
.utcOffset(0, true)
|
|
62402
|
+
.diff(dayjs(formatedMinDate).startOf('day').utcOffset(0, true)) < 0) {
|
|
62403
|
+
return 'before-min-date';
|
|
62404
|
+
}
|
|
62405
|
+
};
|
|
62406
|
+
var toFunc = function (_a) {
|
|
62407
|
+
var date = _a.date;
|
|
62408
|
+
if (fromValue) {
|
|
62409
|
+
if (dayjs(date)
|
|
62410
|
+
.startOf('day')
|
|
62411
|
+
.utcOffset(0, true)
|
|
62412
|
+
.diff(dayjs(fromValue).startOf('day').utcOffset(0, true)) < 0) {
|
|
62413
|
+
return 'before-min-date';
|
|
62414
|
+
}
|
|
62415
|
+
}
|
|
62416
|
+
else {
|
|
62417
|
+
if (formatedMinDate &&
|
|
62418
|
+
dayjs(date)
|
|
62419
|
+
.startOf('day')
|
|
62420
|
+
.utcOffset(0, true)
|
|
62421
|
+
.diff(dayjs(formatedMinDate).startOf('date').utcOffset(0, true)) < 0) {
|
|
62422
|
+
return 'before-min-date';
|
|
62423
|
+
}
|
|
62424
|
+
}
|
|
62425
|
+
if (formatedMaxDate &&
|
|
62426
|
+
dayjs(date)
|
|
62427
|
+
.startOf('day')
|
|
62428
|
+
.utcOffset(0, true)
|
|
62429
|
+
.diff(dayjs(formatedMaxDate).startOf('day').utcOffset(0, true)) > 0) {
|
|
62430
|
+
return 'after-max-date';
|
|
62431
|
+
}
|
|
62432
|
+
};
|
|
62433
|
+
return (React__default.createElement(Wrap, __assign$2({ flexWrap: "wrap", w: "full", maxW: "full" }, props),
|
|
62434
|
+
React__default.createElement(WrapItem, { flex: "1", alignItems: "center", minW: "fit-content" },
|
|
62435
|
+
React__default.createElement(Text, { mr: 2, wordBreak: "normal" }, fromLabel),
|
|
62436
|
+
React__default.createElement(InputDayPicker, { name: "from", onChange: function (e) {
|
|
62437
|
+
setFromValue(e);
|
|
62438
|
+
}, value: fromValue, format: format, minDate: formatedMinDate, maxDate: (value === null || value === void 0 ? void 0 : value.to) || maxDate, calendarFunc: fromFunc, withTime: withTime, variant: variant, minW: "11.5rem", w: "full" })),
|
|
62439
|
+
React__default.createElement(WrapItem, { flex: "1", alignItems: "center", minW: "fit-content" },
|
|
62440
|
+
React__default.createElement(Text, { mr: 2, wordBreak: "normal" }, toLabel),
|
|
62441
|
+
React__default.createElement(InputDayPicker, { name: "to", onChange: function (e) {
|
|
62442
|
+
setToValue(e);
|
|
62443
|
+
}, value: toValue, format: format, minDate: (value === null || value === void 0 ? void 0 : value.from) || formatedMinDate, maxDate: formatedMaxDate, calendarFunc: toFunc, withTime: withTime, variant: variant, minW: "11.5rem", w: "full" }))));
|
|
62444
|
+
};
|
|
62445
|
+
|
|
62283
62446
|
var ModalResponsive = function (_a) {
|
|
62284
62447
|
var _b;
|
|
62285
62448
|
var isOpen = _a.isOpen, onClose = _a.onClose, finalFocusRef = _a.finalFocusRef, children = _a.children, rest = __rest$2(_a, ["isOpen", "onClose", "finalFocusRef", "children"]);
|
|
@@ -68038,6 +68201,12 @@ var reactCalendar = function (props) {
|
|
|
68038
68201
|
color: props.theme.colors.gray[400]
|
|
68039
68202
|
}
|
|
68040
68203
|
}
|
|
68204
|
+
},
|
|
68205
|
+
'.before-min-date': {
|
|
68206
|
+
color: props.theme.colors.gray[400]
|
|
68207
|
+
},
|
|
68208
|
+
'.after-max-date': {
|
|
68209
|
+
color: props.theme.colors.gray[400]
|
|
68041
68210
|
}
|
|
68042
68211
|
};
|
|
68043
68212
|
};
|
|
@@ -68107,5 +68276,5 @@ var styles = {
|
|
|
68107
68276
|
|
|
68108
68277
|
var theme = extendTheme(__assign$2(__assign$2({ styles: styles }, foundations), { components: __assign$2({}, components) }));
|
|
68109
68278
|
|
|
68110
|
-
export { ActionsButton, BottomBar, Card, ConfirmMenuItem, DataList, DataListAccordion, DataListAccordionButton, DataListAccordionIcon, DataListAccordionPanel, DataListCell, DataListContext, DataListFooter, DataListHeader, DataListHeaderContext, DataListRow, DayPicker, FormGroup, InputDayPicker, InputPhone, LayoutContainer, MenuItem, ModalResponsive, Pagination, PaginationButtonFirstPage, PaginationButtonLastPage, PaginationButtonNextPage, PaginationButtonPrevPage, PaginationContext, PaginationInfo, SearchInput, Select, SideNav, SideNavBody, SideNavContainer, SideNavFooter, SideNavHeader, SideNavMenu, SideNavMenuItem, TopBar, TopBarBackAction, TopBarFirstElement, TopBarLastElement, dateFormat, formatPhoneIntl, getPaginationInfo, isValidPhone, theme, useIsMobile };
|
|
68279
|
+
export { ActionsButton, BottomBar, Card, ConfirmMenuItem, DataList, DataListAccordion, DataListAccordionButton, DataListAccordionIcon, DataListAccordionPanel, DataListCell, DataListContext, DataListFooter, DataListHeader, DataListHeaderContext, DataListRow, DayPicker, FormGroup, InputDayPicker, InputPhone, InputRangePicker, LayoutContainer, MenuItem, ModalResponsive, Pagination, PaginationButtonFirstPage, PaginationButtonLastPage, PaginationButtonNextPage, PaginationButtonPrevPage, PaginationContext, PaginationInfo, SearchInput, Select, SideNav, SideNavBody, SideNavContainer, SideNavFooter, SideNavHeader, SideNavMenu, SideNavMenuItem, TopBar, TopBarBackAction, TopBarFirstElement, TopBarLastElement, dateFormat, formatPhoneIntl, getPaginationInfo, isValidPhone, theme, useIsMobile };
|
|
68111
68280
|
//# sourceMappingURL=index.js.map
|