fis-component 0.2.4 → 0.2.5
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 +10 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +10 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -73115,6 +73115,7 @@ const FISInputDate$1 = forwardRef((props, ref) => {
|
|
|
73115
73115
|
return parseDateText(text, formats);
|
|
73116
73116
|
};
|
|
73117
73117
|
const [open, setOpen] = useState(false);
|
|
73118
|
+
const [hovered, setHovered] = useState(false);
|
|
73118
73119
|
const [inputValue, setInputValue] = useState(value ? dayjs(value).format(finalFormat) : "");
|
|
73119
73120
|
const [dateValue, setDateValue] = useState(value ? dayjs(value) : null);
|
|
73120
73121
|
const inputRef = useRef(null);
|
|
@@ -73202,6 +73203,14 @@ const FISInputDate$1 = forwardRef((props, ref) => {
|
|
|
73202
73203
|
setInputValue("");
|
|
73203
73204
|
}
|
|
73204
73205
|
};
|
|
73206
|
+
const showClear = allowClear && !disabled && inputValue !== "" && hovered;
|
|
73207
|
+
const handleClear = () => {
|
|
73208
|
+
setInputValue("");
|
|
73209
|
+
setDateValue(null);
|
|
73210
|
+
setOpen(false);
|
|
73211
|
+
if (dateValue)
|
|
73212
|
+
onChange?.(null);
|
|
73213
|
+
};
|
|
73205
73214
|
const handleInputKeyDown = (e) => {
|
|
73206
73215
|
if (e.key === "Enter") {
|
|
73207
73216
|
normalizeInput();
|
|
@@ -73209,7 +73218,7 @@ const FISInputDate$1 = forwardRef((props, ref) => {
|
|
|
73209
73218
|
}
|
|
73210
73219
|
originalOnKeyDown?.(e);
|
|
73211
73220
|
};
|
|
73212
|
-
return (jsxs(DivWrapperSC$2, { className: className, children: [(textLabel || iconLabel) && (jsx(FISInputLabel$1, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxs(DivInputWrapperSC$1, { children: [jsx(FISInputField$1, { ...restProps, ref: mergeRef, typeSuffix: "icon", iconSuffix: jsx(DateIcon, {}), value: inputValue, negative: negative, disabled: disabled, placeholder: restProps.placeholder, readOnly: inputReadOnly, autoFocus: autoFocus, onFocus: () => setOpen(true), onChange: handleInputChange, onBlur: handleInputBlur, onKeyDown: handleInputKeyDown, onClickSuffix: () => setOpen(true), autoComplete: "off" }), jsx(HiddenDatePickerSC, { open: open, value: dateValue, onChange: (value) => handleChange(value), onOpenChange: handleOpenChange, format: finalFormat, getPopupContainer: getPopupContainer, minDate: minDate, maxDate: maxDate, picker: picker,
|
|
73221
|
+
return (jsxs(DivWrapperSC$2, { className: className, children: [(textLabel || iconLabel) && (jsx(FISInputLabel$1, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxs(DivInputWrapperSC$1, { onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), children: [jsx(FISInputField$1, { ...restProps, ref: mergeRef, typeSuffix: "icon", iconSuffix: showClear ? jsx(CloseIcon, {}) : jsx(DateIcon, {}), value: inputValue, negative: negative, disabled: disabled, placeholder: restProps.placeholder, readOnly: inputReadOnly, autoFocus: autoFocus, onFocus: () => setOpen(true), onChange: handleInputChange, onBlur: handleInputBlur, onKeyDown: handleInputKeyDown, onClickSuffix: showClear ? handleClear : () => setOpen(true), autoComplete: "off" }), jsx(HiddenDatePickerSC, { open: open, value: dateValue, onChange: (value) => handleChange(value), onOpenChange: handleOpenChange, format: finalFormat, getPopupContainer: getPopupContainer, minDate: minDate, maxDate: maxDate, picker: picker, showToday: showToday, showTime: showTime, disabledDate: disabledDate, disabledTime: disabledTime })] }), message && (jsx(DivHintWrapperSC$1, { children: jsx(SpanHintSC$3, { className: classNames({
|
|
73213
73222
|
disabled,
|
|
73214
73223
|
negative,
|
|
73215
73224
|
positive,
|