@paygreen/pgui 2.14.0 → 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 +33 -83
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/InputDayPicker/index.d.ts +1 -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 +33 -83
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/InputDayPicker/index.d.ts +1 -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 +5 -4
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -7928,85 +7928,26 @@ function MdCalendarToday (props) {
|
|
|
7928
7928
|
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);
|
|
7929
7929
|
}
|
|
7930
7930
|
|
|
7931
|
-
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
7932
|
-
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
7933
|
-
// generators (like Math.random()).
|
|
7934
|
-
let getRandomValues;
|
|
7935
|
-
const rnds8 = new Uint8Array(16);
|
|
7936
|
-
function rng() {
|
|
7937
|
-
// lazy load so that environments that need to polyfill have a chance to do so
|
|
7938
|
-
if (!getRandomValues) {
|
|
7939
|
-
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
7940
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
7941
|
-
|
|
7942
|
-
if (!getRandomValues) {
|
|
7943
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
7944
|
-
}
|
|
7945
|
-
}
|
|
7946
|
-
|
|
7947
|
-
return getRandomValues(rnds8);
|
|
7948
|
-
}
|
|
7949
|
-
|
|
7950
|
-
/**
|
|
7951
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
7952
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
7953
|
-
*/
|
|
7954
|
-
|
|
7955
|
-
const byteToHex = [];
|
|
7956
|
-
|
|
7957
|
-
for (let i = 0; i < 256; ++i) {
|
|
7958
|
-
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
7959
|
-
}
|
|
7960
|
-
|
|
7961
|
-
function unsafeStringify(arr, offset = 0) {
|
|
7962
|
-
// Note: Be careful editing this code! It's been tuned for performance
|
|
7963
|
-
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
7964
|
-
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]];
|
|
7965
|
-
}
|
|
7966
|
-
|
|
7967
|
-
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
7968
|
-
var native = {
|
|
7969
|
-
randomUUID
|
|
7970
|
-
};
|
|
7971
|
-
|
|
7972
|
-
function v4(options, buf, offset) {
|
|
7973
|
-
if (native.randomUUID && !buf && !options) {
|
|
7974
|
-
return native.randomUUID();
|
|
7975
|
-
}
|
|
7976
|
-
|
|
7977
|
-
options = options || {};
|
|
7978
|
-
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
7979
|
-
|
|
7980
|
-
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
7981
|
-
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
7982
|
-
|
|
7983
|
-
if (buf) {
|
|
7984
|
-
offset = offset || 0;
|
|
7985
|
-
|
|
7986
|
-
for (let i = 0; i < 16; ++i) {
|
|
7987
|
-
buf[offset + i] = rnds[i];
|
|
7988
|
-
}
|
|
7989
|
-
|
|
7990
|
-
return buf;
|
|
7991
|
-
}
|
|
7992
|
-
|
|
7993
|
-
return unsafeStringify(rnds);
|
|
7994
|
-
}
|
|
7995
|
-
|
|
7996
7931
|
dayjs.extend(customParseFormat);
|
|
7997
7932
|
dayjs.extend(utc);
|
|
7998
7933
|
var InputDayPicker = function (_a) {
|
|
7999
|
-
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,
|
|
7934
|
+
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;
|
|
8000
7935
|
var _d = react.useDisclosure(), isOpen = _d.isOpen, onOpen = _d.onOpen, onClose = _d.onClose;
|
|
8001
7936
|
var inputLeftElementColor = react.useColorModeValue('gray.400', 'gray.600');
|
|
8002
7937
|
var inputLeftElementDisabledColor = react.useColorModeValue('gray.600', 'gray.400');
|
|
8003
7938
|
var dialogSheetBg = react.useColorModeValue('gray.50', 'gray.800');
|
|
8004
|
-
var defaultDateFormat =
|
|
8005
|
-
?
|
|
8006
|
-
: withTime
|
|
7939
|
+
var defaultDateFormat = locale === 'fr'
|
|
7940
|
+
? withTime
|
|
8007
7941
|
? 'DD/MM/YYYY HH:mm'
|
|
8008
|
-
: 'DD/MM/YYYY'
|
|
7942
|
+
: 'DD/MM/YYYY'
|
|
7943
|
+
: withTime
|
|
7944
|
+
? 'MM/DD/YYYY HH:mm'
|
|
7945
|
+
: 'MM/DD/YYYY';
|
|
8009
7946
|
var _e = React.useState(value ? dayjs(value).format(defaultDateFormat) : ''), dateValue = _e[0], setDateValue = _e[1];
|
|
7947
|
+
// Update the input value when the value prop changes
|
|
7948
|
+
React.useEffect(function () {
|
|
7949
|
+
setDateValue(value ? dayjs(value).format(defaultDateFormat) : '');
|
|
7950
|
+
}, [value]);
|
|
8010
7951
|
// Add new state variables for hours and minutes
|
|
8011
7952
|
var _f = React.useState('00'), hours = _f[0], setHours = _f[1];
|
|
8012
7953
|
var _g = React.useState('00'), minutes = _g[0], setMinutes = _g[1];
|
|
@@ -8052,7 +7993,7 @@ var InputDayPicker = function (_a) {
|
|
|
8052
7993
|
cursor: isDisabled ? 'not-allowed' : 'pointer'
|
|
8053
7994
|
}, onClick: function () { return !isDisabled && (isOpen ? onClose() : onOpen()); } },
|
|
8054
7995
|
React__default["default"].createElement(react.Icon, { as: MdCalendarToday })),
|
|
8055
|
-
React__default["default"].createElement(react.Input, __assign$2({ width: "full", disabled: isDisabled, name: name || 'date-input', type: "text", variant: variant, placeholder: placeholder || defaultDateFormat, value: dateValue, onChange: function (e) {
|
|
7996
|
+
React__default["default"].createElement(react.Input, __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) {
|
|
8056
7997
|
var newValue = e.currentTarget.value
|
|
8057
7998
|
.replace(/[^0-9 /:]/g, '')
|
|
8058
7999
|
.slice(0, withTime ? 16 : 10); // Sanitize the input
|
|
@@ -8068,7 +8009,7 @@ var InputDayPicker = function (_a) {
|
|
|
8068
8009
|
handleInputChange(null);
|
|
8069
8010
|
} },
|
|
8070
8011
|
React__default["default"].createElement(react.Icon, { as: MdClose })))),
|
|
8071
|
-
isOpen && (React__default["default"].createElement(react.Box, {
|
|
8012
|
+
isOpen && (React__default["default"].createElement(react.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 },
|
|
8072
8013
|
React__default["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,
|
|
8073
8014
|
// Put the default date or today's date if the value is empty
|
|
8074
8015
|
selected: dayjs(dateValue, defaultDateFormat, true).isValid()
|
|
@@ -19108,19 +19049,26 @@ var InputPhone = function (_a) {
|
|
|
19108
19049
|
};
|
|
19109
19050
|
|
|
19110
19051
|
var InputRangePicker = function (_a) {
|
|
19111
|
-
var
|
|
19112
|
-
var
|
|
19113
|
-
var
|
|
19052
|
+
var _b;
|
|
19053
|
+
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;
|
|
19054
|
+
var _f = React.useState((value === null || value === void 0 ? void 0 : value.from) || null), fromValue = _f[0], setFromValue = _f[1];
|
|
19055
|
+
var _g = React.useState((value === null || value === void 0 ? void 0 : value.to) || null), toValue = _g[0], setToValue = _g[1];
|
|
19114
19056
|
React.useEffect(function () {
|
|
19115
19057
|
onChange({ from: fromValue, to: toValue });
|
|
19116
19058
|
}, [fromValue, toValue]);
|
|
19117
|
-
|
|
19118
|
-
|
|
19119
|
-
|
|
19120
|
-
|
|
19059
|
+
// Update the state when the value changes
|
|
19060
|
+
React.useEffect(function () {
|
|
19061
|
+
setFromValue((value === null || value === void 0 ? void 0 : value.from) || null);
|
|
19062
|
+
setToValue((value === null || value === void 0 ? void 0 : value.to) || null);
|
|
19063
|
+
}, [value]);
|
|
19064
|
+
var flexDirection = react.useBreakpointValue((_b = {
|
|
19065
|
+
base: 'column'
|
|
19066
|
+
},
|
|
19067
|
+
_b[breakpoint] = 'row',
|
|
19068
|
+
_b));
|
|
19121
19069
|
return (React__default["default"].createElement(react.Flex, { flexDirection: flexDirection, gap: 2 },
|
|
19122
|
-
React__default["default"].createElement(InputDayPicker, { value: fromValue, onChange: setFromValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate: minDate, maxDate: maxDate,
|
|
19123
|
-
React__default["default"].createElement(InputDayPicker, { value: toValue, onChange: setToValue, placeholder: placeholder, name: name, isDisabled: isDisabled, withTime: withTime, locale: locale, minDate: minDate, maxDate: maxDate,
|
|
19070
|
+
React__default["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 }),
|
|
19071
|
+
React__default["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 })));
|
|
19124
19072
|
};
|
|
19125
19073
|
|
|
19126
19074
|
var ModalResponsive = function (_a) {
|
|
@@ -59330,7 +59278,8 @@ var Input = {
|
|
|
59330
59278
|
boxShadow: "0 0 0 1px ".concat(props.theme.colors.gray[300])
|
|
59331
59279
|
},
|
|
59332
59280
|
_placeholder: {
|
|
59333
|
-
color: 'gray.500'
|
|
59281
|
+
color: 'gray.500',
|
|
59282
|
+
opacity: 1
|
|
59334
59283
|
}
|
|
59335
59284
|
},
|
|
59336
59285
|
addon: {
|
|
@@ -59354,7 +59303,8 @@ var Input = {
|
|
|
59354
59303
|
boxShadow: "0 0 0 1px ".concat(props.theme.colors.gray[300])
|
|
59355
59304
|
},
|
|
59356
59305
|
_placeholder: {
|
|
59357
|
-
color: 'gray.500'
|
|
59306
|
+
color: 'gray.500',
|
|
59307
|
+
opacity: 1
|
|
59358
59308
|
}
|
|
59359
59309
|
},
|
|
59360
59310
|
addon: {
|