@farmzone/fz-react-ui 1.0.11 → 1.0.13

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 CHANGED
@@ -82,7 +82,7 @@ var buttonVariants = classVarianceAuthority.cva(
82
82
  carousel: "bg-white border border-gray-300 hover:bg-gray-100 hover:text-black rounded-full",
83
83
  accent: "btn-grad text-white rounded-full",
84
84
  metal: "btn-metal text-white min-w-22",
85
- ghost: "p-1 h-auto rounded-sm bg-transparent hover:bg-sub-lightgray text-sub-darkgray hover:bg-inherit",
85
+ ghost: "p-1 h-auto rounded-sm bg-transparent text-sub-darkgray transition-colors hover:bg-gray-100",
86
86
  link: "bg-transparent border-none text-main-blue underline-offset-4 hover:underline h-auto p-0"
87
87
  },
88
88
  size: {
@@ -4741,15 +4741,26 @@ function Table(props) {
4741
4741
  if (!isDynamicHeight) return;
4742
4742
  const el = scrollRef.current;
4743
4743
  if (!el) return;
4744
+ const pageContainer = el.parentElement?.parentElement;
4745
+ const isContainerConstrained = (container2) => {
4746
+ if (!container2) return false;
4747
+ const style = window.getComputedStyle(container2);
4748
+ return style.overflow === "hidden" || style.overflowY === "hidden";
4749
+ };
4750
+ const getContainerBottom = () => {
4751
+ if (isContainerConstrained(pageContainer)) {
4752
+ return Math.min(pageContainer.getBoundingClientRect().bottom, window.innerHeight);
4753
+ }
4754
+ return window.innerHeight;
4755
+ };
4744
4756
  const update = () => {
4745
4757
  const top = el.getBoundingClientRect().top;
4746
4758
  const footerH = footerRef.current?.getBoundingClientRect().height ?? 0;
4747
- setTableHeight(window.innerHeight - top - footerH - 24);
4759
+ setTableHeight(getContainerBottom() - top - footerH - 24);
4748
4760
  };
4749
4761
  update();
4750
4762
  window.addEventListener("resize", update);
4751
4763
  const observer = new ResizeObserver(update);
4752
- const pageContainer = el.parentElement?.parentElement;
4753
4764
  if (pageContainer) observer.observe(pageContainer);
4754
4765
  const footer = footerRef.current;
4755
4766
  if (footer) observer.observe(footer);
@@ -4762,9 +4773,15 @@ function Table(props) {
4762
4773
  if (!isDynamicHeight) return;
4763
4774
  const el = scrollRef.current;
4764
4775
  if (!el) return;
4776
+ const pageContainer = el.parentElement?.parentElement;
4765
4777
  const top = el.getBoundingClientRect().top;
4766
4778
  const footerH = footerRef.current?.getBoundingClientRect().height ?? 0;
4767
- setTableHeight(window.innerHeight - top - footerH - 24);
4779
+ const isContainerConstrained = !!pageContainer && (() => {
4780
+ const style = window.getComputedStyle(pageContainer);
4781
+ return style.overflow === "hidden" || style.overflowY === "hidden";
4782
+ })();
4783
+ const containerBottom = isContainerConstrained ? Math.min(pageContainer.getBoundingClientRect().bottom, window.innerHeight) : window.innerHeight;
4784
+ setTableHeight(containerBottom - top - footerH - 24);
4768
4785
  }, [showSkeleton, showEmpty]);
4769
4786
  const selectedKeysRef = React6.useRef(selectedKeys);
4770
4787
  selectedKeysRef.current = selectedKeys;
@@ -7238,9 +7255,13 @@ function SelectWithInputField(props) {
7238
7255
  }, [defaultPrefix, formValue, options]);
7239
7256
  const [selectedPrefix, setSelectedPrefix] = React6.useState(prefix);
7240
7257
  const [prevFormValue, setPrevFormValue] = React6.useState(formValue);
7258
+ const isUserInputChangeRef = React6.useRef(false);
7241
7259
  if (prevFormValue !== formValue) {
7242
7260
  setPrevFormValue(formValue);
7243
- setSelectedPrefix(formValue ? prefix : defaultPrefix);
7261
+ if (!isUserInputChangeRef.current) {
7262
+ setSelectedPrefix(formValue ? prefix : defaultPrefix);
7263
+ }
7264
+ isUserInputChangeRef.current = false;
7244
7265
  }
7245
7266
  React6.useLayoutEffect(() => {
7246
7267
  if (readOnly) return;
@@ -7249,9 +7270,7 @@ function SelectWithInputField(props) {
7249
7270
  }
7250
7271
  }, [formValue, normalizedFormValue, onChange, readOnly]);
7251
7272
  if (readOnly) {
7252
- const prefixLabel = options.find((o) => String(o.value) === prefix)?.label ?? prefix;
7253
- const displayText = inputPart ? `${prefixLabel} ${inputPart}` : prefix ? prefixLabel : "\u2014";
7254
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: fieldControlWrapClass(className), children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: FIELD_READONLY_TEXT_CLASS, children: displayText || "\u2014" }) });
7273
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: fieldControlWrapClass(className), children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: FIELD_READONLY_TEXT_CLASS, children: formValue }) });
7255
7274
  }
7256
7275
  const updateCombined = (nextPrefix, nextInput) => {
7257
7276
  onChange(combineSelectWithInputValue(nextPrefix, nextInput));
@@ -7265,6 +7284,7 @@ function SelectWithInputField(props) {
7265
7284
  if (normalized) {
7266
7285
  validationCtx?.markFieldHadValue(String(config.name));
7267
7286
  }
7287
+ isUserInputChangeRef.current = true;
7268
7288
  updateCombined(selectedPrefix, normalized);
7269
7289
  };
7270
7290
  const selectClass = resolveSelectClassNameProp(selectWithInputClassNames?.selectClassName, {
@@ -7303,6 +7323,7 @@ function SelectWithInputField(props) {
7303
7323
  },
7304
7324
  onBlur: (e) => {
7305
7325
  const normalized = normalizeInput(e.target.value.normalize("NFKC"));
7326
+ isUserInputChangeRef.current = true;
7306
7327
  updateCombined(selectedPrefix, normalized);
7307
7328
  onBlur();
7308
7329
  }