@ballistix.digital/react-components 1.0.0 → 1.0.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/index.esm.js +38 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +37 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import { ArrowPathIcon, ChevronDownIcon, EllipsisVerticalIcon, ExclamationCircleIcon, ChevronDoubleLeftIcon, ChevronLeftIcon, ChevronRightIcon, ChevronDoubleRightIcon, ChevronUpIcon, ChevronUpDownIcon, HomeIcon, ArrowLongLeftIcon, ArrowLongRightIcon } from '@heroicons/react/20/solid';
|
|
3
|
-
import { isArray, map, set, get, noop as noop$1, indexOf, toSafeInteger, pick, isEmpty, some, forEach, assign } from 'lodash';
|
|
3
|
+
import { isArray, map, set, get, noop as noop$1, indexOf, toSafeInteger, pick, isEmpty, some, forEach, assign, intersection } from 'lodash';
|
|
4
4
|
import get$1 from 'lodash/get';
|
|
5
5
|
import React, { useState, useMemo, Children, Fragment, useEffect, useCallback, useRef, forwardRef, useImperativeHandle, useReducer, createElement, PureComponent, Component } from 'react';
|
|
6
6
|
import { library } from '@fortawesome/fontawesome-svg-core';
|
|
@@ -2676,13 +2676,14 @@ var DateMenuForm = function (props) {
|
|
|
2676
2676
|
startDate: null,
|
|
2677
2677
|
endDate: null,
|
|
2678
2678
|
}), state = _p[0], setState = _p[1];
|
|
2679
|
-
var
|
|
2679
|
+
var $datepickerInputRef = useRef(null);
|
|
2680
|
+
var handleValueChange = useCallback(function (newValue) {
|
|
2680
2681
|
setState(newValue);
|
|
2681
2682
|
onChange && onChange(newValue);
|
|
2682
2683
|
setTimeout(function () {
|
|
2683
2684
|
onBlur && onBlur();
|
|
2684
2685
|
}, 50);
|
|
2685
|
-
};
|
|
2686
|
+
}, [onBlur, onChange]);
|
|
2686
2687
|
var handleGenerateStyle = function () {
|
|
2687
2688
|
var result = deepCopyObject(styles$6.base);
|
|
2688
2689
|
var keys = calculateNestedKeys(styles$6.base);
|
|
@@ -2705,7 +2706,40 @@ var DateMenuForm = function (props) {
|
|
|
2705
2706
|
useEffect(function () {
|
|
2706
2707
|
setState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : { startDate: null, endDate: null });
|
|
2707
2708
|
}, [defaultValue]);
|
|
2708
|
-
|
|
2709
|
+
useEffect(function () {
|
|
2710
|
+
var _a;
|
|
2711
|
+
var input = (_a = $datepickerInputRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('input');
|
|
2712
|
+
var allowedCharacters = '0123456789';
|
|
2713
|
+
var separators = "./-".concat(separator);
|
|
2714
|
+
var callback = function (event) {
|
|
2715
|
+
if ((input === null || input === void 0 ? void 0 : input.value) === null ||
|
|
2716
|
+
(input === null || input === void 0 ? void 0 : input.value) === undefined ||
|
|
2717
|
+
intersection(input.value.split(''), separators.split('')).length > 0 ||
|
|
2718
|
+
isRanged) {
|
|
2719
|
+
return;
|
|
2720
|
+
}
|
|
2721
|
+
if (allowedCharacters.includes(event.key) && (input === null || input === void 0 ? void 0 : input.value.length) >= 7) {
|
|
2722
|
+
var newValue = input.value + event.key;
|
|
2723
|
+
var day = newValue.substring(0, 2);
|
|
2724
|
+
var month = newValue.substring(2, 4);
|
|
2725
|
+
var year = newValue.substring(4, 8);
|
|
2726
|
+
var newDate = new Date("".concat(year, "-").concat(month, "-").concat(day));
|
|
2727
|
+
if (isNaN(newDate.getTime()))
|
|
2728
|
+
return;
|
|
2729
|
+
input.blur();
|
|
2730
|
+
handleValueChange({
|
|
2731
|
+
startDate: "".concat(year, "-").concat(month, "-").concat(day),
|
|
2732
|
+
endDate: "".concat(year, "-").concat(month, "-").concat(day),
|
|
2733
|
+
});
|
|
2734
|
+
setTimeout(function () { return input.focus(); }, 100);
|
|
2735
|
+
}
|
|
2736
|
+
};
|
|
2737
|
+
if (input) {
|
|
2738
|
+
input.addEventListener('keydown', callback);
|
|
2739
|
+
}
|
|
2740
|
+
return function () { return removeEventListener('keydown', callback); };
|
|
2741
|
+
}, [handleValueChange, isRanged, separator]);
|
|
2742
|
+
return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: styles.head, children: [label && (jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsxs("div", { className: styles.container, "data-cy": inputDataCy, ref: $datepickerInputRef, children: [jsx(Datepicker, { inputName: name, inputId: name, i18n: i18n, useRange: size === 'expanded', placeholder: placeholder, asSingle: !isRanged, separator: separator, startFrom: startFrom, displayFormat: displayFormat, disabled: isDisabled, popoverDirection: direction, minDate: minDate, maxDate: maxDate, toggleIcon: icon,
|
|
2709
2743
|
//
|
|
2710
2744
|
value: state,
|
|
2711
2745
|
//
|