@paygreen/pgui 2.13.5 → 2.14.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 +37 -87
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/InputDayPicker/index.d.ts +3 -2
- package/dist/cjs/types/components/InputRangePicker/index.d.ts +4 -2
- 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 +37 -87
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/InputDayPicker/index.d.ts +3 -2
- package/dist/esm/types/components/InputRangePicker/index.d.ts +4 -2
- 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 +7 -4
- package/package.json +1 -1
|
@@ -7,10 +7,11 @@ 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;
|
|
14
|
+
inputProps?: any;
|
|
15
|
+
dayPickerProps?: any;
|
|
15
16
|
};
|
|
16
|
-
export declare const InputDayPicker: ({ value, onChange, placeholder, name, isDisabled, withTime, locale, minDate, maxDate,
|
|
17
|
+
export declare const InputDayPicker: ({ value, onChange, placeholder, name, isDisabled, withTime, locale, minDate, maxDate, variant, inputProps, dayPickerProps, }: InputDayPickerProps) => React.JSX.Element;
|
|
@@ -12,10 +12,12 @@ export type InputRangePickerProps = {
|
|
|
12
12
|
} | null;
|
|
13
13
|
locale?: 'fr' | 'en';
|
|
14
14
|
variant?: 'filled' | 'outline';
|
|
15
|
-
dateFormat?: string;
|
|
16
15
|
withTime?: boolean;
|
|
17
16
|
minDate?: Date | null | undefined;
|
|
18
17
|
maxDate?: Date | null | undefined;
|
|
19
18
|
isDisabled?: boolean;
|
|
19
|
+
breakpoint?: 'base' | 'sm' | 'md' | 'lg';
|
|
20
|
+
inputProps?: any;
|
|
21
|
+
dayPickerProps?: any;
|
|
20
22
|
};
|
|
21
|
-
export declare const InputRangePicker: ({ value, onChange, placeholder, name, isDisabled, withTime, locale, minDate, maxDate,
|
|
23
|
+
export declare const InputRangePicker: ({ value, onChange, placeholder, name, isDisabled, withTime, locale, minDate, maxDate, 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,85 +7902,26 @@ 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,
|
|
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;
|
|
7974
7909
|
var _d = useDisclosure(), isOpen = _d.isOpen, onOpen = _d.onOpen, onClose = _d.onClose;
|
|
7975
7910
|
var inputLeftElementColor = useColorModeValue('gray.400', 'gray.600');
|
|
7976
7911
|
var inputLeftElementDisabledColor = useColorModeValue('gray.600', 'gray.400');
|
|
7977
7912
|
var dialogSheetBg = useColorModeValue('gray.50', 'gray.800');
|
|
7978
|
-
var defaultDateFormat =
|
|
7979
|
-
?
|
|
7980
|
-
: withTime
|
|
7913
|
+
var defaultDateFormat = locale === 'fr'
|
|
7914
|
+
? withTime
|
|
7981
7915
|
? 'DD/MM/YYYY HH:mm'
|
|
7982
|
-
: 'DD/MM/YYYY'
|
|
7916
|
+
: 'DD/MM/YYYY'
|
|
7917
|
+
: withTime
|
|
7918
|
+
? 'MM/DD/YYYY HH:mm'
|
|
7919
|
+
: 'MM/DD/YYYY';
|
|
7983
7920
|
var _e = useState(value ? dayjs(value).format(defaultDateFormat) : ''), dateValue = _e[0], setDateValue = _e[1];
|
|
7921
|
+
// Update the input value when the value prop changes
|
|
7922
|
+
useEffect(function () {
|
|
7923
|
+
setDateValue(value ? dayjs(value).format(defaultDateFormat) : '');
|
|
7924
|
+
}, [value]);
|
|
7984
7925
|
// Add new state variables for hours and minutes
|
|
7985
7926
|
var _f = useState('00'), hours = _f[0], setHours = _f[1];
|
|
7986
7927
|
var _g = useState('00'), minutes = _g[0], setMinutes = _g[1];
|
|
@@ -8021,12 +7962,12 @@ var InputDayPicker = function (_a) {
|
|
|
8021
7962
|
handleDateSelection(dayjs(dateValue, defaultDateFormat).toDate());
|
|
8022
7963
|
}, [hours, minutes]);
|
|
8023
7964
|
return (React__default.createElement(Box, null,
|
|
8024
|
-
React__default.createElement(InputGroup,
|
|
7965
|
+
React__default.createElement(InputGroup, null,
|
|
8025
7966
|
React__default.createElement(InputLeftElement, { role: "group", color: isDisabled ? inputLeftElementColor : inputLeftElementDisabledColor, _hover: {
|
|
8026
7967
|
cursor: isDisabled ? 'not-allowed' : 'pointer'
|
|
8027
7968
|
}, onClick: function () { return !isDisabled && (isOpen ? onClose() : onOpen()); } },
|
|
8028
7969
|
React__default.createElement(Icon, { as: MdCalendarToday })),
|
|
8029
|
-
React__default.createElement(Input$4, { disabled: isDisabled, name: name || 'date-input', type: "text", variant: variant, placeholder: placeholder || defaultDateFormat, value: dateValue, onChange: function (e) {
|
|
7970
|
+
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
7971
|
var newValue = e.currentTarget.value
|
|
8031
7972
|
.replace(/[^0-9 /:]/g, '')
|
|
8032
7973
|
.slice(0, withTime ? 16 : 10); // Sanitize the input
|
|
@@ -8035,15 +7976,15 @@ var InputDayPicker = function (_a) {
|
|
|
8035
7976
|
}, onFocus: function () {
|
|
8036
7977
|
if (isOpen)
|
|
8037
7978
|
onClose();
|
|
8038
|
-
} }),
|
|
7979
|
+
} }, inputProps)),
|
|
8039
7980
|
dateValue && !isDisabled && (React__default.createElement(InputRightElement, { role: "group", _hover: {
|
|
8040
7981
|
cursor: 'pointer'
|
|
8041
7982
|
}, onClick: function () {
|
|
8042
7983
|
handleInputChange(null);
|
|
8043
7984
|
} },
|
|
8044
7985
|
React__default.createElement(Icon, { as: MdClose })))),
|
|
8045
|
-
isOpen && (React__default.createElement(Box, {
|
|
8046
|
-
React__default.createElement(DayPicker, { 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,
|
|
7986
|
+
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 },
|
|
7987
|
+
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
7988
|
// Put the default date or today's date if the value is empty
|
|
8048
7989
|
selected: dayjs(dateValue, defaultDateFormat, true).isValid()
|
|
8049
7990
|
? dayjs(dateValue, defaultDateFormat, true).toDate()
|
|
@@ -8055,7 +7996,7 @@ var InputDayPicker = function (_a) {
|
|
|
8055
7996
|
handleDateSelection(date);
|
|
8056
7997
|
if (!withTime)
|
|
8057
7998
|
onClose(); // Close the dialog only when you dont need to select the time
|
|
8058
|
-
}, captionLayout: "dropdown-buttons" }),
|
|
7999
|
+
}, captionLayout: "dropdown-buttons" }, dayPickerProps)),
|
|
8059
8000
|
withTime && (React__default.createElement(React__default.Fragment, null,
|
|
8060
8001
|
React__default.createElement(VStack, { align: "center" },
|
|
8061
8002
|
React__default.createElement(Divider, { mb: 2, w: '90%' })),
|
|
@@ -19082,19 +19023,26 @@ var InputPhone = function (_a) {
|
|
|
19082
19023
|
};
|
|
19083
19024
|
|
|
19084
19025
|
var InputRangePicker = function (_a) {
|
|
19085
|
-
var
|
|
19086
|
-
var
|
|
19087
|
-
var
|
|
19026
|
+
var _b;
|
|
19027
|
+
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, minDate = _a.minDate, maxDate = _a.maxDate, _d = _a.variant, variant = _d === void 0 ? 'filled' : _d, _e = _a.breakpoint, breakpoint = _e === void 0 ? 'md' : _e, inputProps = _a.inputProps, dayPickerProps = _a.dayPickerProps;
|
|
19028
|
+
var _f = useState((value === null || value === void 0 ? void 0 : value.from) || null), fromValue = _f[0], setFromValue = _f[1];
|
|
19029
|
+
var _g = useState((value === null || value === void 0 ? void 0 : value.to) || null), toValue = _g[0], setToValue = _g[1];
|
|
19088
19030
|
useEffect(function () {
|
|
19089
19031
|
onChange({ from: fromValue, to: toValue });
|
|
19090
19032
|
}, [fromValue, toValue]);
|
|
19091
|
-
|
|
19092
|
-
|
|
19093
|
-
|
|
19094
|
-
|
|
19033
|
+
// Update the state when the value changes
|
|
19034
|
+
useEffect(function () {
|
|
19035
|
+
setFromValue((value === null || value === void 0 ? void 0 : value.from) || null);
|
|
19036
|
+
setToValue((value === null || value === void 0 ? void 0 : value.to) || null);
|
|
19037
|
+
}, [value]);
|
|
19038
|
+
var flexDirection = useBreakpointValue((_b = {
|
|
19039
|
+
base: 'column'
|
|
19040
|
+
},
|
|
19041
|
+
_b[breakpoint] = 'row',
|
|
19042
|
+
_b));
|
|
19095
19043
|
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: minDate, maxDate: maxDate,
|
|
19097
|
-
React__default.createElement(InputDayPicker, { value: toValue, onChange: setToValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate: minDate, maxDate: maxDate,
|
|
19044
|
+
React__default.createElement(InputDayPicker, { value: fromValue, onChange: setFromValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate: minDate, maxDate: maxDate, variant: variant, inputProps: inputProps, dayPickerProps: dayPickerProps }),
|
|
19045
|
+
React__default.createElement(InputDayPicker, { value: toValue, onChange: setToValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate: minDate, maxDate: maxDate, variant: variant, inputProps: inputProps, dayPickerProps: dayPickerProps })));
|
|
19098
19046
|
};
|
|
19099
19047
|
|
|
19100
19048
|
var ModalResponsive = function (_a) {
|
|
@@ -59304,7 +59252,8 @@ var Input = {
|
|
|
59304
59252
|
boxShadow: "0 0 0 1px ".concat(props.theme.colors.gray[300])
|
|
59305
59253
|
},
|
|
59306
59254
|
_placeholder: {
|
|
59307
|
-
color: 'gray.500'
|
|
59255
|
+
color: 'gray.500',
|
|
59256
|
+
opacity: 1
|
|
59308
59257
|
}
|
|
59309
59258
|
},
|
|
59310
59259
|
addon: {
|
|
@@ -59328,7 +59277,8 @@ var Input = {
|
|
|
59328
59277
|
boxShadow: "0 0 0 1px ".concat(props.theme.colors.gray[300])
|
|
59329
59278
|
},
|
|
59330
59279
|
_placeholder: {
|
|
59331
|
-
color: 'gray.500'
|
|
59280
|
+
color: 'gray.500',
|
|
59281
|
+
opacity: 1
|
|
59332
59282
|
}
|
|
59333
59283
|
},
|
|
59334
59284
|
addon: {
|