@farmzone/fz-react-ui 1.0.11 → 1.0.12

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
@@ -7204,9 +7204,13 @@ function SelectWithInputField(props) {
7204
7204
  }, [defaultPrefix, formValue, options]);
7205
7205
  const [selectedPrefix, setSelectedPrefix] = useState(prefix);
7206
7206
  const [prevFormValue, setPrevFormValue] = useState(formValue);
7207
+ const isUserInputChangeRef = useRef(false);
7207
7208
  if (prevFormValue !== formValue) {
7208
7209
  setPrevFormValue(formValue);
7209
- setSelectedPrefix(formValue ? prefix : defaultPrefix);
7210
+ if (!isUserInputChangeRef.current) {
7211
+ setSelectedPrefix(formValue ? prefix : defaultPrefix);
7212
+ }
7213
+ isUserInputChangeRef.current = false;
7210
7214
  }
7211
7215
  useLayoutEffect(() => {
7212
7216
  if (readOnly) return;
@@ -7215,9 +7219,7 @@ function SelectWithInputField(props) {
7215
7219
  }
7216
7220
  }, [formValue, normalizedFormValue, onChange, readOnly]);
7217
7221
  if (readOnly) {
7218
- const prefixLabel = options.find((o) => String(o.value) === prefix)?.label ?? prefix;
7219
- const displayText = inputPart ? `${prefixLabel} ${inputPart}` : prefix ? prefixLabel : "\u2014";
7220
- return /* @__PURE__ */ jsx("div", { className: fieldControlWrapClass(className), children: /* @__PURE__ */ jsx("span", { className: FIELD_READONLY_TEXT_CLASS, children: displayText || "\u2014" }) });
7222
+ return /* @__PURE__ */ jsx("div", { className: fieldControlWrapClass(className), children: /* @__PURE__ */ jsx("span", { className: FIELD_READONLY_TEXT_CLASS, children: formValue }) });
7221
7223
  }
7222
7224
  const updateCombined = (nextPrefix, nextInput) => {
7223
7225
  onChange(combineSelectWithInputValue(nextPrefix, nextInput));
@@ -7231,6 +7233,7 @@ function SelectWithInputField(props) {
7231
7233
  if (normalized) {
7232
7234
  validationCtx?.markFieldHadValue(String(config.name));
7233
7235
  }
7236
+ isUserInputChangeRef.current = true;
7234
7237
  updateCombined(selectedPrefix, normalized);
7235
7238
  };
7236
7239
  const selectClass = resolveSelectClassNameProp(selectWithInputClassNames?.selectClassName, {
@@ -7269,6 +7272,7 @@ function SelectWithInputField(props) {
7269
7272
  },
7270
7273
  onBlur: (e) => {
7271
7274
  const normalized = normalizeInput(e.target.value.normalize("NFKC"));
7275
+ isUserInputChangeRef.current = true;
7272
7276
  updateCombined(selectedPrefix, normalized);
7273
7277
  onBlur();
7274
7278
  }