@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.js CHANGED
@@ -12081,6 +12081,7 @@ var checkIfEmpty = ({
12081
12081
  if (value === 0 || defaultValue === 0) return false;
12082
12082
  return !value && !defaultValue;
12083
12083
  };
12084
+ var checkInputValueIfEmpty = (value) => value.length === 0;
12084
12085
  var DashboardInput = React43.forwardRef(
12085
12086
  ({
12086
12087
  value,
@@ -12123,10 +12124,15 @@ var DashboardInput = React43.forwardRef(
12123
12124
  const inputId = id ?? name ?? generatedId;
12124
12125
  const errorId = `${inputId}-error`;
12125
12126
  const { t } = useTranslation26();
12126
- const isEmpty = checkIfEmpty({ empty, value, defaultValue });
12127
+ const isEmptyControlled = typeof empty !== "undefined" || typeof value !== "undefined";
12128
+ const propsAreEmpty = checkIfEmpty({ empty, value, defaultValue });
12129
+ const [uncontrolledIsEmpty, setUncontrolledIsEmpty] = React43.useState(propsAreEmpty);
12130
+ const isEmpty = isEmptyControlled ? propsAreEmpty : uncontrolledIsEmpty;
12127
12131
  const [inputType, setInputType] = React43.useState(type);
12128
12132
  const [isPasswordRevealed, setIsPasswordRevealed] = React43.useState(false);
12129
12133
  const [isFocused, setIsFocused] = React43.useState(false);
12134
+ const inputRef = React43.useRef(null);
12135
+ const combinedInputRef = useCombinedRef(inputRef, ref);
12130
12136
  const prevInputType = usePrevious(inputType);
12131
12137
  const isPasswordReveal = (prevInputType === "password" || type === "password") && !isEmpty;
12132
12138
  const hasInvalidState = Boolean(invalid) || Boolean(error) && error !== "NONE";
@@ -12144,12 +12150,15 @@ var DashboardInput = React43.forwardRef(
12144
12150
  setInputType(type);
12145
12151
  }, [type]);
12146
12152
  const handleChange = (event) => {
12147
- if (readOnly || disabled || !onChange) return;
12148
- onChange(event);
12153
+ if (readOnly || disabled) return;
12154
+ if (!isEmptyControlled) {
12155
+ setUncontrolledIsEmpty(checkInputValueIfEmpty(event.currentTarget.value));
12156
+ }
12157
+ onChange?.(event);
12149
12158
  };
12150
12159
  const handleLabelClick = () => {
12151
- if (readOnly || disabled) return;
12152
- setIsFocused(true);
12160
+ if (readOnly || disabled || loading) return;
12161
+ inputRef.current?.focus();
12153
12162
  };
12154
12163
  const handleFocus = (event) => {
12155
12164
  if (readOnly || disabled) return;
@@ -12217,7 +12226,7 @@ var DashboardInput = React43.forwardRef(
12217
12226
  "input",
12218
12227
  {
12219
12228
  ...props,
12220
- ref,
12229
+ ref: combinedInputRef,
12221
12230
  id: inputId,
12222
12231
  name,
12223
12232
  type: inputType,