@paygreen/pgui 2.14.0 → 2.14.2
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 +61 -92
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/InputDayPicker/index.d.ts +4 -2
- package/dist/cjs/types/components/InputRangePicker/index.d.ts +8 -4
- package/dist/cjs/types/theme/components/input.d.ts +2 -0
- package/dist/cjs/types/theme/components/pin-input.d.ts +2 -0
- package/dist/cjs/types/theme/components/textarea.d.ts +2 -0
- package/dist/esm/index.js +61 -92
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/InputDayPicker/index.d.ts +4 -2
- package/dist/esm/types/components/InputRangePicker/index.d.ts +8 -4
- package/dist/esm/types/theme/components/input.d.ts +2 -0
- package/dist/esm/types/theme/components/pin-input.d.ts +2 -0
- package/dist/esm/types/theme/components/textarea.d.ts +2 -0
- package/dist/index.d.ts +12 -6
- package/package.json +1 -1
|
@@ -7,12 +7,14 @@ export type InputDayPickerProps = {
|
|
|
7
7
|
value: Date | null;
|
|
8
8
|
locale?: 'fr' | 'en';
|
|
9
9
|
variant?: 'filled' | 'outline';
|
|
10
|
-
dateFormat?: string;
|
|
11
10
|
withTime?: boolean;
|
|
12
11
|
minDate?: Date | null | undefined;
|
|
13
12
|
maxDate?: Date | null | undefined;
|
|
14
13
|
isDisabled?: boolean;
|
|
15
14
|
inputProps?: any;
|
|
16
15
|
dayPickerProps?: any;
|
|
16
|
+
isOpen?: boolean;
|
|
17
|
+
onOpen?: () => void;
|
|
18
|
+
onClose?: () => void;
|
|
17
19
|
};
|
|
18
|
-
export declare const InputDayPicker: ({ value, onChange, placeholder, name, isDisabled, withTime, locale, minDate, maxDate,
|
|
20
|
+
export declare const InputDayPicker: ({ value, onChange, placeholder, name, isDisabled, withTime, locale, minDate, maxDate, variant, inputProps, dayPickerProps, isOpen: isOpenProp, onOpen: onOpenProp, onClose: onCloseProp, }: InputDayPickerProps) => React.JSX.Element;
|
|
@@ -12,10 +12,14 @@ export type InputRangePickerProps = {
|
|
|
12
12
|
} | null;
|
|
13
13
|
locale?: 'fr' | 'en';
|
|
14
14
|
variant?: 'filled' | 'outline';
|
|
15
|
-
dateFormat?: string;
|
|
16
15
|
withTime?: boolean;
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
minStartDate?: Date | null | undefined;
|
|
17
|
+
maxStartDate?: Date | null | undefined;
|
|
18
|
+
minEndDate?: Date | null | undefined;
|
|
19
|
+
maxEndDate?: Date | null | undefined;
|
|
19
20
|
isDisabled?: boolean;
|
|
21
|
+
breakpoint?: 'base' | 'sm' | 'md' | 'lg';
|
|
22
|
+
inputProps?: any;
|
|
23
|
+
dayPickerProps?: any;
|
|
20
24
|
};
|
|
21
|
-
export declare const InputRangePicker: ({ value, onChange, placeholder, name, isDisabled, withTime, locale,
|
|
25
|
+
export declare const InputRangePicker: ({ value, onChange, placeholder, name, isDisabled, withTime, locale, minStartDate, maxStartDate, minEndDate, maxEndDate, variant, breakpoint, inputProps, dayPickerProps, }: InputRangePickerProps) => React.JSX.Element;
|
|
@@ -21,6 +21,7 @@ declare const _default: {
|
|
|
21
21
|
};
|
|
22
22
|
_placeholder: {
|
|
23
23
|
color: string;
|
|
24
|
+
opacity: number;
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
addon: {
|
|
@@ -45,6 +46,7 @@ declare const _default: {
|
|
|
45
46
|
};
|
|
46
47
|
_placeholder: {
|
|
47
48
|
color: string;
|
|
49
|
+
opacity: number;
|
|
48
50
|
};
|
|
49
51
|
};
|
|
50
52
|
addon: {
|
|
@@ -14,6 +14,7 @@ declare const _default: {
|
|
|
14
14
|
};
|
|
15
15
|
_placeholder: {
|
|
16
16
|
color: string;
|
|
17
|
+
opacity: number;
|
|
17
18
|
};
|
|
18
19
|
};
|
|
19
20
|
filled: (props: any) => {
|
|
@@ -33,6 +34,7 @@ declare const _default: {
|
|
|
33
34
|
};
|
|
34
35
|
_placeholder: {
|
|
35
36
|
color: string;
|
|
37
|
+
opacity: number;
|
|
36
38
|
};
|
|
37
39
|
};
|
|
38
40
|
};
|
|
@@ -22,6 +22,7 @@ declare const _default: {
|
|
|
22
22
|
};
|
|
23
23
|
_placeholder: {
|
|
24
24
|
color: string;
|
|
25
|
+
opacity: number;
|
|
25
26
|
};
|
|
26
27
|
};
|
|
27
28
|
filled: (props: any) => {
|
|
@@ -41,6 +42,7 @@ declare const _default: {
|
|
|
41
42
|
};
|
|
42
43
|
_placeholder: {
|
|
43
44
|
color: string;
|
|
45
|
+
opacity: number;
|
|
44
46
|
};
|
|
45
47
|
};
|
|
46
48
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -7902,92 +7902,38 @@ function MdCalendarToday (props) {
|
|
|
7902
7902
|
return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 24 24"},"child":[{"tag":"path","attr":{"fill":"none","d":"M0 0h24v24H0z"}},{"tag":"path","attr":{"d":"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}}]})(props);
|
|
7903
7903
|
}
|
|
7904
7904
|
|
|
7905
|
-
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
7906
|
-
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
7907
|
-
// generators (like Math.random()).
|
|
7908
|
-
let getRandomValues;
|
|
7909
|
-
const rnds8 = new Uint8Array(16);
|
|
7910
|
-
function rng() {
|
|
7911
|
-
// lazy load so that environments that need to polyfill have a chance to do so
|
|
7912
|
-
if (!getRandomValues) {
|
|
7913
|
-
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
7914
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
7915
|
-
|
|
7916
|
-
if (!getRandomValues) {
|
|
7917
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
7918
|
-
}
|
|
7919
|
-
}
|
|
7920
|
-
|
|
7921
|
-
return getRandomValues(rnds8);
|
|
7922
|
-
}
|
|
7923
|
-
|
|
7924
|
-
/**
|
|
7925
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
7926
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
7927
|
-
*/
|
|
7928
|
-
|
|
7929
|
-
const byteToHex = [];
|
|
7930
|
-
|
|
7931
|
-
for (let i = 0; i < 256; ++i) {
|
|
7932
|
-
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
7933
|
-
}
|
|
7934
|
-
|
|
7935
|
-
function unsafeStringify(arr, offset = 0) {
|
|
7936
|
-
// Note: Be careful editing this code! It's been tuned for performance
|
|
7937
|
-
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
7938
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
7939
|
-
}
|
|
7940
|
-
|
|
7941
|
-
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
7942
|
-
var native = {
|
|
7943
|
-
randomUUID
|
|
7944
|
-
};
|
|
7945
|
-
|
|
7946
|
-
function v4(options, buf, offset) {
|
|
7947
|
-
if (native.randomUUID && !buf && !options) {
|
|
7948
|
-
return native.randomUUID();
|
|
7949
|
-
}
|
|
7950
|
-
|
|
7951
|
-
options = options || {};
|
|
7952
|
-
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
7953
|
-
|
|
7954
|
-
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
7955
|
-
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
7956
|
-
|
|
7957
|
-
if (buf) {
|
|
7958
|
-
offset = offset || 0;
|
|
7959
|
-
|
|
7960
|
-
for (let i = 0; i < 16; ++i) {
|
|
7961
|
-
buf[offset + i] = rnds[i];
|
|
7962
|
-
}
|
|
7963
|
-
|
|
7964
|
-
return buf;
|
|
7965
|
-
}
|
|
7966
|
-
|
|
7967
|
-
return unsafeStringify(rnds);
|
|
7968
|
-
}
|
|
7969
|
-
|
|
7970
7905
|
dayjs.extend(customParseFormat);
|
|
7971
7906
|
dayjs.extend(utc);
|
|
7972
7907
|
var InputDayPicker = function (_a) {
|
|
7973
|
-
var value = _a.value, onChange = _a.onChange, placeholder = _a.placeholder, name = _a.name, isDisabled = _a.isDisabled, withTime = _a.withTime, _b = _a.locale, locale = _b === void 0 ? 'en' : _b, minDate = _a.minDate, maxDate = _a.maxDate,
|
|
7974
|
-
var
|
|
7908
|
+
var value = _a.value, onChange = _a.onChange, placeholder = _a.placeholder, name = _a.name, isDisabled = _a.isDisabled, withTime = _a.withTime, _b = _a.locale, locale = _b === void 0 ? 'en' : _b, minDate = _a.minDate, maxDate = _a.maxDate, _c = _a.variant, variant = _c === void 0 ? 'filled' : _c, inputProps = _a.inputProps, dayPickerProps = _a.dayPickerProps, isOpenProp = _a.isOpen, onOpenProp = _a.onOpen, onCloseProp = _a.onClose;
|
|
7909
|
+
var disclosure = useDisclosure();
|
|
7910
|
+
var isOpen = isOpenProp || disclosure.isOpen;
|
|
7911
|
+
var onOpen = onOpenProp || disclosure.onOpen;
|
|
7912
|
+
var onClose = onCloseProp || disclosure.onClose;
|
|
7975
7913
|
var inputLeftElementColor = useColorModeValue('gray.400', 'gray.600');
|
|
7976
7914
|
var inputLeftElementDisabledColor = useColorModeValue('gray.600', 'gray.400');
|
|
7977
7915
|
var dialogSheetBg = useColorModeValue('gray.50', 'gray.800');
|
|
7978
|
-
var defaultDateFormat =
|
|
7979
|
-
?
|
|
7980
|
-
: withTime
|
|
7916
|
+
var defaultDateFormat = locale === 'fr'
|
|
7917
|
+
? withTime
|
|
7981
7918
|
? 'DD/MM/YYYY HH:mm'
|
|
7982
|
-
: 'DD/MM/YYYY'
|
|
7983
|
-
|
|
7919
|
+
: 'DD/MM/YYYY'
|
|
7920
|
+
: withTime
|
|
7921
|
+
? 'MM/DD/YYYY HH:mm'
|
|
7922
|
+
: 'MM/DD/YYYY';
|
|
7923
|
+
var _d = useState(value ? dayjs(value).format(defaultDateFormat) : ''), dateValue = _d[0], setDateValue = _d[1];
|
|
7924
|
+
// Update the input value when the value prop changes
|
|
7925
|
+
useEffect(function () {
|
|
7926
|
+
setDateValue(dayjs(value).isValid() ? dayjs(value).format(defaultDateFormat) : '');
|
|
7927
|
+
}, [value]);
|
|
7984
7928
|
// Add new state variables for hours and minutes
|
|
7985
|
-
var
|
|
7986
|
-
var
|
|
7929
|
+
var _e = useState('00'), hours = _e[0], setHours = _e[1];
|
|
7930
|
+
var _f = useState('00'), minutes = _f[0], setMinutes = _f[1];
|
|
7987
7931
|
// Update the input value when the value prop changes
|
|
7988
7932
|
var handleInputChange = function (date) {
|
|
7989
|
-
if (!date)
|
|
7933
|
+
if (!date) {
|
|
7990
7934
|
setDateValue('');
|
|
7935
|
+
onChange(null);
|
|
7936
|
+
}
|
|
7991
7937
|
var dateInput = dayjs(date, defaultDateFormat, true);
|
|
7992
7938
|
if (dateInput.isValid()) {
|
|
7993
7939
|
if (isOpen)
|
|
@@ -7998,9 +7944,6 @@ var InputDayPicker = function (_a) {
|
|
|
7998
7944
|
setMinutes(parseInt(dateInput.format('mm'), 10).toString());
|
|
7999
7945
|
onChange(dateInput.toDate());
|
|
8000
7946
|
}
|
|
8001
|
-
else {
|
|
8002
|
-
onChange(null);
|
|
8003
|
-
}
|
|
8004
7947
|
};
|
|
8005
7948
|
// Update the input value when the value prop changes
|
|
8006
7949
|
var handleDateSelection = function (date) {
|
|
@@ -8026,7 +7969,7 @@ var InputDayPicker = function (_a) {
|
|
|
8026
7969
|
cursor: isDisabled ? 'not-allowed' : 'pointer'
|
|
8027
7970
|
}, onClick: function () { return !isDisabled && (isOpen ? onClose() : onOpen()); } },
|
|
8028
7971
|
React__default.createElement(Icon, { as: MdCalendarToday })),
|
|
8029
|
-
React__default.createElement(Input$4, __assign$2({ width: "full", disabled: isDisabled, name: name || 'date-input', type: "text", variant: variant, placeholder: placeholder || defaultDateFormat, value: dateValue, onChange: function (e) {
|
|
7972
|
+
React__default.createElement(Input$4, __assign$2({ minWidth: withTime ? '13rem' : '10rem', width: "full", disabled: isDisabled, name: name || 'date-input', type: "text", variant: variant, placeholder: placeholder || defaultDateFormat, value: dateValue, onChange: function (e) {
|
|
8030
7973
|
var newValue = e.currentTarget.value
|
|
8031
7974
|
.replace(/[^0-9 /:]/g, '')
|
|
8032
7975
|
.slice(0, withTime ? 16 : 10); // Sanitize the input
|
|
@@ -8042,7 +7985,7 @@ var InputDayPicker = function (_a) {
|
|
|
8042
7985
|
handleInputChange(null);
|
|
8043
7986
|
} },
|
|
8044
7987
|
React__default.createElement(Icon, { as: MdClose })))),
|
|
8045
|
-
isOpen && (React__default.createElement(Box, {
|
|
7988
|
+
isOpen && (React__default.createElement(Box, { position: 'absolute', border: '1px solid', borderColor: 'gray.400', bg: dialogSheetBg, borderRadius: 'md', tabIndex: -1, zIndex: 9999, className: "dialog-sheet", role: "dialog", "aria-label": "DayPicker calendar", mt: 2 },
|
|
8046
7989
|
React__default.createElement(DayPicker, __assign$2({ locale: locale === 'en' ? enUS : fr$1, fromDate: minDate || new Date('1900-01-01'), toDate: maxDate || new Date('2100-12-31'), initialFocus: isOpen, mode: "single", disabled: isDisabled,
|
|
8047
7990
|
// Put the default date or today's date if the value is empty
|
|
8048
7991
|
selected: dayjs(dateValue, defaultDateFormat, true).isValid()
|
|
@@ -19082,19 +19025,43 @@ var InputPhone = function (_a) {
|
|
|
19082
19025
|
};
|
|
19083
19026
|
|
|
19084
19027
|
var InputRangePicker = function (_a) {
|
|
19085
|
-
var
|
|
19086
|
-
var
|
|
19087
|
-
var
|
|
19028
|
+
var _b;
|
|
19029
|
+
var value = _a.value, onChange = _a.onChange, placeholder = _a.placeholder, name = _a.name, isDisabled = _a.isDisabled, withTime = _a.withTime, _c = _a.locale, locale = _c === void 0 ? 'en' : _c, minStartDate = _a.minStartDate, maxStartDate = _a.maxStartDate, minEndDate = _a.minEndDate, maxEndDate = _a.maxEndDate, _d = _a.variant, variant = _d === void 0 ? 'filled' : _d, _e = _a.breakpoint, breakpoint = _e === void 0 ? 'md' : _e, inputProps = _a.inputProps, dayPickerProps = _a.dayPickerProps;
|
|
19030
|
+
var _f = useState((value === null || value === void 0 ? void 0 : value.from) || null), fromValue = _f[0], setFromValue = _f[1];
|
|
19031
|
+
var _g = useState((value === null || value === void 0 ? void 0 : value.to) || null), toValue = _g[0], setToValue = _g[1];
|
|
19032
|
+
var _h = useDisclosure(), isOpenFrom = _h.isOpen, onOpenFrom = _h.onOpen, onCloseFrom = _h.onClose;
|
|
19033
|
+
var _j = useDisclosure(), isOpenTo = _j.isOpen, onOpenTo = _j.onOpen, onCloseTo = _j.onClose;
|
|
19034
|
+
// close the other date picker when one is opened
|
|
19035
|
+
useEffect(function () {
|
|
19036
|
+
if (isOpenFrom) {
|
|
19037
|
+
onCloseTo();
|
|
19038
|
+
}
|
|
19039
|
+
}, [isOpenFrom]);
|
|
19040
|
+
useEffect(function () {
|
|
19041
|
+
if (isOpenTo) {
|
|
19042
|
+
onCloseFrom();
|
|
19043
|
+
}
|
|
19044
|
+
}, [isOpenTo]);
|
|
19045
|
+
// Update the parent state when the local state changes
|
|
19088
19046
|
useEffect(function () {
|
|
19089
|
-
|
|
19047
|
+
var newValue = { from: fromValue, to: toValue };
|
|
19048
|
+
if (JSON.stringify(newValue) !== JSON.stringify(value)) {
|
|
19049
|
+
onChange(newValue);
|
|
19050
|
+
}
|
|
19090
19051
|
}, [fromValue, toValue]);
|
|
19091
|
-
|
|
19092
|
-
|
|
19093
|
-
|
|
19094
|
-
|
|
19052
|
+
// Update the state when the props value changes
|
|
19053
|
+
useEffect(function () {
|
|
19054
|
+
setFromValue((value === null || value === void 0 ? void 0 : value.from) || null);
|
|
19055
|
+
setToValue((value === null || value === void 0 ? void 0 : value.to) || null);
|
|
19056
|
+
}, [value]);
|
|
19057
|
+
var flexDirection = useBreakpointValue((_b = {
|
|
19058
|
+
base: 'column'
|
|
19059
|
+
},
|
|
19060
|
+
_b[breakpoint] = 'row',
|
|
19061
|
+
_b));
|
|
19095
19062
|
return (React__default.createElement(Flex, { flexDirection: flexDirection, gap: 2 },
|
|
19096
|
-
React__default.createElement(InputDayPicker, { value: fromValue, onChange: setFromValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate:
|
|
19097
|
-
React__default.createElement(InputDayPicker, { value: toValue, onChange: setToValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate:
|
|
19063
|
+
React__default.createElement(InputDayPicker, { value: fromValue, onChange: setFromValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate: minStartDate, maxDate: maxStartDate, variant: variant, inputProps: inputProps, dayPickerProps: dayPickerProps, onClose: onCloseFrom, onOpen: onOpenFrom, isOpen: isOpenFrom }),
|
|
19064
|
+
React__default.createElement(InputDayPicker, { value: toValue, onChange: setToValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate: minEndDate, maxDate: maxEndDate, variant: variant, inputProps: inputProps, dayPickerProps: dayPickerProps, onClose: onCloseTo, onOpen: onOpenTo, isOpen: isOpenTo })));
|
|
19098
19065
|
};
|
|
19099
19066
|
|
|
19100
19067
|
var ModalResponsive = function (_a) {
|
|
@@ -59304,7 +59271,8 @@ var Input = {
|
|
|
59304
59271
|
boxShadow: "0 0 0 1px ".concat(props.theme.colors.gray[300])
|
|
59305
59272
|
},
|
|
59306
59273
|
_placeholder: {
|
|
59307
|
-
color: 'gray.500'
|
|
59274
|
+
color: 'gray.500',
|
|
59275
|
+
opacity: 1
|
|
59308
59276
|
}
|
|
59309
59277
|
},
|
|
59310
59278
|
addon: {
|
|
@@ -59328,7 +59296,8 @@ var Input = {
|
|
|
59328
59296
|
boxShadow: "0 0 0 1px ".concat(props.theme.colors.gray[300])
|
|
59329
59297
|
},
|
|
59330
59298
|
_placeholder: {
|
|
59331
|
-
color: 'gray.500'
|
|
59299
|
+
color: 'gray.500',
|
|
59300
|
+
opacity: 1
|
|
59332
59301
|
}
|
|
59333
59302
|
},
|
|
59334
59303
|
addon: {
|