@paygreen/pgui 2.7.0 → 2.8.1
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 +196 -25
- 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 +197 -27
- 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',
|
|
@@ -42919,15 +42934,16 @@ var NewDayPicker = function (_a) {
|
|
|
42919
42934
|
borderRadius: '9999px'
|
|
42920
42935
|
}
|
|
42921
42936
|
};
|
|
42922
|
-
return (React__default.createElement(VStack, __assign$2({ spacing: "2", maxW: "full", p: 2, w: "fit-content", maxWidth: "30rem", borderRadius: "md" }, props),
|
|
42937
|
+
return (React__default.createElement(VStack, __assign$2({ spacing: "2", maxW: "full", p: 2, w: "fit-content", maxWidth: "30rem", borderRadius: "md", minH: "22.75rem" }, props),
|
|
42923
42938
|
React__default.createElement(Stack, { direction: { base: 'column', sm: 'row' }, spacing: 2, w: "full" },
|
|
42924
|
-
React__default.createElement(
|
|
42925
|
-
|
|
42926
|
-
|
|
42927
|
-
|
|
42928
|
-
|
|
42929
|
-
|
|
42930
|
-
|
|
42939
|
+
React__default.createElement(Box, { minH: "19.25rem" },
|
|
42940
|
+
React__default.createElement(Calendar, { locale: locale, minDate: minDate, maxDate: maxDate, tileClassName: calendarFunc, onChange: function (e) {
|
|
42941
|
+
setValue(e);
|
|
42942
|
+
onChange(dayjs(e).toISOString());
|
|
42943
|
+
setTimeValue('00:00');
|
|
42944
|
+
setInputValue(dayjs(e).locale(locale).format(format));
|
|
42945
|
+
setIsInvalid(false);
|
|
42946
|
+
}, value: dayjs(value).toDate() })),
|
|
42931
42947
|
withTime && (React__default.createElement(Flex$1, { backgroundColor: "gray.100", p: "2", borderRadius: "sm", h: { base: '8rem', sm: 'auto' }, w: "full", minW: "8rem", alignItems: "center" },
|
|
42932
42948
|
React__default.createElement(Box, { w: "full", h: "full", maxH: "16rem", overflowY: "auto", sx: customScrollBar },
|
|
42933
42949
|
React__default.createElement(VStack, { w: "full" }, timer.map(function (t) { return (React__default.createElement(Button$1, { key: t, size: "sm", w: "full", isActive: t === timeValue, onClick: function () {
|
|
@@ -42935,15 +42951,37 @@ var NewDayPicker = function (_a) {
|
|
|
42935
42951
|
.set('hours', parseInt(t.slice(0, 2), 10))
|
|
42936
42952
|
.set('minutes', parseInt(t.slice(-2), 10));
|
|
42937
42953
|
setValue(settedValue.toDate());
|
|
42938
|
-
|
|
42954
|
+
if (minDate && settedValue.diff(dayjs(minDate)) < 0) {
|
|
42955
|
+
onChange(dayjs(minDate).toISOString());
|
|
42956
|
+
}
|
|
42957
|
+
else if (maxDate &&
|
|
42958
|
+
settedValue.diff(dayjs(maxDate)) > 0) {
|
|
42959
|
+
onChange(dayjs(maxDate).toISOString());
|
|
42960
|
+
}
|
|
42961
|
+
else {
|
|
42962
|
+
onChange(settedValue.toISOString());
|
|
42963
|
+
}
|
|
42939
42964
|
setTimeValue(t);
|
|
42940
42965
|
setInputValue(dayjs(settedValue.toDate()).format(format));
|
|
42941
42966
|
setIsInvalid(false);
|
|
42942
42967
|
}, _active: {
|
|
42943
42968
|
backgroundColor: 'white',
|
|
42944
42969
|
color: 'brand.600'
|
|
42945
|
-
}
|
|
42946
|
-
|
|
42970
|
+
}, isDisabled: (minDate === null
|
|
42971
|
+
? undefined
|
|
42972
|
+
: minDate &&
|
|
42973
|
+
dayjs(value)
|
|
42974
|
+
.set('hours', parseInt(t.slice(0, 2), 10))
|
|
42975
|
+
.set('minutes', parseInt(t.slice(-2), 10))
|
|
42976
|
+
.diff(dayjs(minDate)) < 0) ||
|
|
42977
|
+
(maxDate === null
|
|
42978
|
+
? undefined
|
|
42979
|
+
: maxDate &&
|
|
42980
|
+
dayjs(value)
|
|
42981
|
+
.set('hours', parseInt(t.slice(0, 2), 10))
|
|
42982
|
+
.set('minutes', parseInt(t.slice(-2), 10))
|
|
42983
|
+
.diff(dayjs(maxDate)) > 0) }, t)); })))))),
|
|
42984
|
+
React__default.createElement(HStack, { flex: "1", w: "full", alignItems: "flex-end" },
|
|
42947
42985
|
React__default.createElement(InputGroup, { w: "full", size: "sm" },
|
|
42948
42986
|
React__default.createElement(InputLeftElement, { pointerEvents: "none", color: "gray.300", fontSize: "1.2em", children: React__default.createElement(Icon$1, { as: MdCalendarToday }) }),
|
|
42949
42987
|
React__default.createElement(Input$4, { as: InputMask, mask: withTime ? '**/**/**** **:**' : '**/**/****', value: inputValue, onChange: function (e) {
|
|
@@ -42952,9 +42990,17 @@ var NewDayPicker = function (_a) {
|
|
|
42952
42990
|
containsAnyLetters(e.target.value);
|
|
42953
42991
|
if (!isInvalidFormat &&
|
|
42954
42992
|
((_a = dayjs(e.target.value, format)) === null || _a === void 0 ? void 0 : _a.isValid())) {
|
|
42993
|
+
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
42994
|
setInputValue(dayjs(e.target.value, format).locale(locale).format(format));
|
|
42956
42995
|
setValue(dayjs(e.target.value, format).locale(locale).toDate());
|
|
42957
|
-
|
|
42996
|
+
if (minDate &&
|
|
42997
|
+
dayjs(e.target.value, format).diff(dayjs(minDate)) < 0) {
|
|
42998
|
+
onChange(dayjs(minDate).toISOString());
|
|
42999
|
+
}
|
|
43000
|
+
else if (maxDate &&
|
|
43001
|
+
dayjs(e.target.value, format).diff(dayjs(maxDate)) > 0) {
|
|
43002
|
+
onChange(dayjs(maxDate).toISOString());
|
|
43003
|
+
}
|
|
42958
43004
|
setIsInvalid(false);
|
|
42959
43005
|
}
|
|
42960
43006
|
else {
|
|
@@ -42971,7 +43017,7 @@ var NewDayPicker = function (_a) {
|
|
|
42971
43017
|
dayjs.extend(customParseFormat);
|
|
42972
43018
|
dayjs.extend(utc);
|
|
42973
43019
|
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"]);
|
|
43020
|
+
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
43021
|
var _f = useDisclosure(), isOpen = _f.isOpen, onClose = _f.onClose, onToggle = _f.onToggle;
|
|
42976
43022
|
var _g = useState(''), prev = _g[0], setPrev = _g[1];
|
|
42977
43023
|
useEffect(function () {
|
|
@@ -42998,7 +43044,9 @@ var InputDayPicker = function (_a) {
|
|
|
42998
43044
|
React__default.createElement(Popover, { closeOnBlur: true, closeOnEsc: true, isOpen: isOpen, onClose: onClose, placement: "bottom", autoFocus: true },
|
|
42999
43045
|
React__default.createElement(PopoverTrigger, null,
|
|
43000
43046
|
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",
|
|
43047
|
+
React__default.createElement(Input$4, __assign$2({ as: Button$1, onClick: onToggle, name: name, fontWeight: "normal", justifyContent: "flex-start", background: variant === 'filled' ? 'gray.50' : 'white', _hover: {
|
|
43048
|
+
background: variant === 'filled' ? 'gray.100' : 'gray.50'
|
|
43049
|
+
} }, inputProps), value ? dayjs(value).format(format) : placeholder),
|
|
43002
43050
|
value && (React__default.createElement(InputRightElement, { onClick: function () {
|
|
43003
43051
|
onChange(null);
|
|
43004
43052
|
}, _hover: {
|
|
@@ -43009,7 +43057,7 @@ var InputDayPicker = function (_a) {
|
|
|
43009
43057
|
} }))))),
|
|
43010
43058
|
React__default.createElement(PopoverContent, { mx: 1, width: "fit-content" },
|
|
43011
43059
|
React__default.createElement(PopoverArrow, null),
|
|
43012
|
-
isOpen && (React__default.createElement(NewDayPicker, { locale: locale, defaultValue: value, onChange: onChange,
|
|
43060
|
+
isOpen && (React__default.createElement(NewDayPicker, { locale: locale, defaultValue: value, onChange: onChange, withTime: withTime, minDate: minDate, maxDate: maxDate, calendarFunc: calendarFunc }))))));
|
|
43013
43061
|
};
|
|
43014
43062
|
|
|
43015
43063
|
// This file is a workaround for a bug in web browsers' "native"
|
|
@@ -62276,10 +62324,126 @@ var InputPhone = function (_a) {
|
|
|
62276
62324
|
}
|
|
62277
62325
|
}
|
|
62278
62326
|
}, [countryFromLocale, phoneNumber]);
|
|
62279
|
-
return (React__default.createElement(InputGroup, { position: "relative", display: "block" },
|
|
62327
|
+
return (React__default.createElement(InputGroup, { position: "relative", display: "block", sx: { isolation: 'auto' } },
|
|
62280
62328
|
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
62329
|
};
|
|
62282
62330
|
|
|
62331
|
+
var isoWeek$1 = {exports: {}};
|
|
62332
|
+
|
|
62333
|
+
(function (module, exports) {
|
|
62334
|
+
!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)};}}));
|
|
62335
|
+
} (isoWeek$1));
|
|
62336
|
+
|
|
62337
|
+
var isoWeek = isoWeek$1.exports;
|
|
62338
|
+
|
|
62339
|
+
dayjs.extend(customParseFormat);
|
|
62340
|
+
dayjs.extend(utc);
|
|
62341
|
+
dayjs.extend(isoWeek);
|
|
62342
|
+
var InputRangePicker = function (_a) {
|
|
62343
|
+
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"]);
|
|
62344
|
+
var _e = useState(), fromValue = _e[0], setFromValue = _e[1];
|
|
62345
|
+
var _f = useState(), toValue = _f[0], setToValue = _f[1];
|
|
62346
|
+
var _g = useState(minDate), formatedMinDate = _g[0], setFormatedMinDate = _g[1];
|
|
62347
|
+
var _h = useState(maxDate), formatedMaxDate = _h[0], setFormatedMaxDate = _h[1];
|
|
62348
|
+
useEffect(function () {
|
|
62349
|
+
if (!withTime) {
|
|
62350
|
+
var formatedMin = minDate
|
|
62351
|
+
? dayjs(dayjs(minDate).startOf('day').toISOString()).toDate()
|
|
62352
|
+
: null;
|
|
62353
|
+
var formatedMax = maxDate
|
|
62354
|
+
? dayjs(dayjs(maxDate).endOf('day').toISOString()).toDate()
|
|
62355
|
+
: null;
|
|
62356
|
+
setFormatedMinDate(formatedMin);
|
|
62357
|
+
setFormatedMaxDate(formatedMax);
|
|
62358
|
+
}
|
|
62359
|
+
}, [withTime]);
|
|
62360
|
+
useEffect(function () {
|
|
62361
|
+
onChange({
|
|
62362
|
+
from: fromValue ? dayjs(fromValue).toDate() : null,
|
|
62363
|
+
to: toValue ? dayjs(toValue).toDate() : null
|
|
62364
|
+
});
|
|
62365
|
+
}, [fromValue, toValue]);
|
|
62366
|
+
useEffect(function () {
|
|
62367
|
+
if (!withTime) {
|
|
62368
|
+
if (value === null || value === void 0 ? void 0 : value.from) {
|
|
62369
|
+
if (dayjs(value.from).diff(dayjs(formatedMinDate).utcOffset(0, true)) < 0) {
|
|
62370
|
+
setFromValue(dayjs(formatedMinDate).utcOffset(0, true).toISOString());
|
|
62371
|
+
}
|
|
62372
|
+
}
|
|
62373
|
+
if (value === null || value === void 0 ? void 0 : value.to) {
|
|
62374
|
+
if (dayjs(value.to).diff(dayjs(formatedMaxDate).utcOffset(0, true)) > 0) {
|
|
62375
|
+
setToValue(dayjs(formatedMaxDate).utcOffset(0, true).toISOString());
|
|
62376
|
+
}
|
|
62377
|
+
}
|
|
62378
|
+
}
|
|
62379
|
+
}, [withTime, fromValue, toValue]);
|
|
62380
|
+
var fromFunc = function (_a) {
|
|
62381
|
+
var date = _a.date;
|
|
62382
|
+
if (toValue) {
|
|
62383
|
+
if (dayjs(date)
|
|
62384
|
+
.startOf('day')
|
|
62385
|
+
.utcOffset(0, true)
|
|
62386
|
+
.diff(dayjs(toValue).endOf('day').utcOffset(0, true)) > 0) {
|
|
62387
|
+
return 'after-max-date';
|
|
62388
|
+
}
|
|
62389
|
+
}
|
|
62390
|
+
else {
|
|
62391
|
+
if (formatedMaxDate &&
|
|
62392
|
+
dayjs(date)
|
|
62393
|
+
.startOf('date')
|
|
62394
|
+
.utcOffset(0, true)
|
|
62395
|
+
.diff(dayjs(formatedMaxDate).startOf('date').utcOffset(0, true)) > 0) {
|
|
62396
|
+
return 'after-max-date';
|
|
62397
|
+
}
|
|
62398
|
+
}
|
|
62399
|
+
if (formatedMinDate &&
|
|
62400
|
+
dayjs(date)
|
|
62401
|
+
.startOf('day')
|
|
62402
|
+
.utcOffset(0, true)
|
|
62403
|
+
.diff(dayjs(formatedMinDate).startOf('day').utcOffset(0, true)) < 0) {
|
|
62404
|
+
return 'before-min-date';
|
|
62405
|
+
}
|
|
62406
|
+
};
|
|
62407
|
+
var toFunc = function (_a) {
|
|
62408
|
+
var date = _a.date;
|
|
62409
|
+
if (fromValue) {
|
|
62410
|
+
if (dayjs(date)
|
|
62411
|
+
.startOf('day')
|
|
62412
|
+
.utcOffset(0, true)
|
|
62413
|
+
.diff(dayjs(fromValue).startOf('day').utcOffset(0, true)) < 0) {
|
|
62414
|
+
return 'before-min-date';
|
|
62415
|
+
}
|
|
62416
|
+
}
|
|
62417
|
+
else {
|
|
62418
|
+
if (formatedMinDate &&
|
|
62419
|
+
dayjs(date)
|
|
62420
|
+
.startOf('day')
|
|
62421
|
+
.utcOffset(0, true)
|
|
62422
|
+
.diff(dayjs(formatedMinDate).startOf('date').utcOffset(0, true)) < 0) {
|
|
62423
|
+
return 'before-min-date';
|
|
62424
|
+
}
|
|
62425
|
+
}
|
|
62426
|
+
if (formatedMaxDate &&
|
|
62427
|
+
dayjs(date)
|
|
62428
|
+
.startOf('day')
|
|
62429
|
+
.utcOffset(0, true)
|
|
62430
|
+
.diff(dayjs(formatedMaxDate).startOf('day').utcOffset(0, true)) > 0) {
|
|
62431
|
+
return 'after-max-date';
|
|
62432
|
+
}
|
|
62433
|
+
};
|
|
62434
|
+
return (React__default.createElement(Wrap, __assign$2({ flexWrap: "wrap", w: "full", maxW: "full" }, props),
|
|
62435
|
+
React__default.createElement(WrapItem, { flex: "1", alignItems: "center", minW: "fit-content" },
|
|
62436
|
+
React__default.createElement(Text, { mr: 2, wordBreak: "normal" }, fromLabel),
|
|
62437
|
+
React__default.createElement(InputDayPicker, { name: "from", onChange: function (e) {
|
|
62438
|
+
setFromValue(e);
|
|
62439
|
+
}, 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" })),
|
|
62440
|
+
React__default.createElement(WrapItem, { flex: "1", alignItems: "center", minW: "fit-content" },
|
|
62441
|
+
React__default.createElement(Text, { mr: 2, wordBreak: "normal" }, toLabel),
|
|
62442
|
+
React__default.createElement(InputDayPicker, { name: "to", onChange: function (e) {
|
|
62443
|
+
setToValue(e);
|
|
62444
|
+
}, 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" }))));
|
|
62445
|
+
};
|
|
62446
|
+
|
|
62283
62447
|
var ModalResponsive = function (_a) {
|
|
62284
62448
|
var _b;
|
|
62285
62449
|
var isOpen = _a.isOpen, onClose = _a.onClose, finalFocusRef = _a.finalFocusRef, children = _a.children, rest = __rest$2(_a, ["isOpen", "onClose", "finalFocusRef", "children"]);
|
|
@@ -68038,6 +68202,12 @@ var reactCalendar = function (props) {
|
|
|
68038
68202
|
color: props.theme.colors.gray[400]
|
|
68039
68203
|
}
|
|
68040
68204
|
}
|
|
68205
|
+
},
|
|
68206
|
+
'.before-min-date': {
|
|
68207
|
+
color: props.theme.colors.gray[400]
|
|
68208
|
+
},
|
|
68209
|
+
'.after-max-date': {
|
|
68210
|
+
color: props.theme.colors.gray[400]
|
|
68041
68211
|
}
|
|
68042
68212
|
};
|
|
68043
68213
|
};
|
|
@@ -68107,5 +68277,5 @@ var styles = {
|
|
|
68107
68277
|
|
|
68108
68278
|
var theme = extendTheme(__assign$2(__assign$2({ styles: styles }, foundations), { components: __assign$2({}, components) }));
|
|
68109
68279
|
|
|
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 };
|
|
68280
|
+
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
68281
|
//# sourceMappingURL=index.js.map
|