@chekinapp/ui 0.0.106 → 0.0.107
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.cjs +15 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -12429,6 +12429,7 @@ var checkIfEmpty = ({
|
|
|
12429
12429
|
if (value === 0 || defaultValue === 0) return false;
|
|
12430
12430
|
return !value && !defaultValue;
|
|
12431
12431
|
};
|
|
12432
|
+
var checkInputValueIfEmpty = (value) => value.length === 0;
|
|
12432
12433
|
var DashboardInput = React43.forwardRef(
|
|
12433
12434
|
({
|
|
12434
12435
|
value,
|
|
@@ -12471,10 +12472,15 @@ var DashboardInput = React43.forwardRef(
|
|
|
12471
12472
|
const inputId = id ?? name ?? generatedId;
|
|
12472
12473
|
const errorId = `${inputId}-error`;
|
|
12473
12474
|
const { t } = (0, import_react_i18next26.useTranslation)();
|
|
12474
|
-
const
|
|
12475
|
+
const isEmptyControlled = typeof empty !== "undefined" || typeof value !== "undefined";
|
|
12476
|
+
const propsAreEmpty = checkIfEmpty({ empty, value, defaultValue });
|
|
12477
|
+
const [uncontrolledIsEmpty, setUncontrolledIsEmpty] = React43.useState(propsAreEmpty);
|
|
12478
|
+
const isEmpty = isEmptyControlled ? propsAreEmpty : uncontrolledIsEmpty;
|
|
12475
12479
|
const [inputType, setInputType] = React43.useState(type);
|
|
12476
12480
|
const [isPasswordRevealed, setIsPasswordRevealed] = React43.useState(false);
|
|
12477
12481
|
const [isFocused, setIsFocused] = React43.useState(false);
|
|
12482
|
+
const inputRef = React43.useRef(null);
|
|
12483
|
+
const combinedInputRef = useCombinedRef(inputRef, ref);
|
|
12478
12484
|
const prevInputType = usePrevious(inputType);
|
|
12479
12485
|
const isPasswordReveal = (prevInputType === "password" || type === "password") && !isEmpty;
|
|
12480
12486
|
const hasInvalidState = Boolean(invalid) || Boolean(error) && error !== "NONE";
|
|
@@ -12492,12 +12498,15 @@ var DashboardInput = React43.forwardRef(
|
|
|
12492
12498
|
setInputType(type);
|
|
12493
12499
|
}, [type]);
|
|
12494
12500
|
const handleChange = (event) => {
|
|
12495
|
-
if (readOnly || disabled
|
|
12496
|
-
|
|
12501
|
+
if (readOnly || disabled) return;
|
|
12502
|
+
if (!isEmptyControlled) {
|
|
12503
|
+
setUncontrolledIsEmpty(checkInputValueIfEmpty(event.currentTarget.value));
|
|
12504
|
+
}
|
|
12505
|
+
onChange?.(event);
|
|
12497
12506
|
};
|
|
12498
12507
|
const handleLabelClick = () => {
|
|
12499
|
-
if (readOnly || disabled) return;
|
|
12500
|
-
|
|
12508
|
+
if (readOnly || disabled || loading) return;
|
|
12509
|
+
inputRef.current?.focus();
|
|
12501
12510
|
};
|
|
12502
12511
|
const handleFocus = (event) => {
|
|
12503
12512
|
if (readOnly || disabled) return;
|
|
@@ -12565,7 +12574,7 @@ var DashboardInput = React43.forwardRef(
|
|
|
12565
12574
|
"input",
|
|
12566
12575
|
{
|
|
12567
12576
|
...props,
|
|
12568
|
-
ref,
|
|
12577
|
+
ref: combinedInputRef,
|
|
12569
12578
|
id: inputId,
|
|
12570
12579
|
name,
|
|
12571
12580
|
type: inputType,
|