@firecms/ui 3.0.0-canary.178 → 3.0.0-canary.179

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.
@@ -20,4 +20,23 @@ export type TextFieldProps<T extends string | number> = {
20
20
  inputStyle?: React.CSSProperties;
21
21
  inputRef?: React.ForwardedRef<any>;
22
22
  } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">;
23
- export declare function TextField<T extends string | number>({ value, onChange, label, type, multiline, invisible, rows, disabled, error, endAdornment, autoFocus, placeholder, size, className, style, inputClassName, inputStyle, inputRef: inputRefProp, ...inputProps }: TextFieldProps<T>): import("react/jsx-runtime").JSX.Element;
23
+ export declare const TextField: React.ForwardRefExoticComponent<{
24
+ type?: InputType;
25
+ value?: string | number | undefined;
26
+ onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
27
+ label?: React.ReactNode;
28
+ multiline?: boolean;
29
+ rows?: number;
30
+ disabled?: boolean;
31
+ invisible?: boolean;
32
+ error?: boolean;
33
+ endAdornment?: React.ReactNode;
34
+ autoFocus?: boolean;
35
+ placeholder?: string;
36
+ size?: "small" | "medium" | "large";
37
+ className?: string;
38
+ style?: React.CSSProperties;
39
+ inputClassName?: string;
40
+ inputStyle?: React.CSSProperties;
41
+ inputRef?: React.ForwardedRef<any>;
42
+ } & Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> & React.RefAttributes<HTMLDivElement>>;
package/dist/index.es.js CHANGED
@@ -31260,7 +31260,7 @@ function setRef(ref, value) {
31260
31260
  ref.current = value;
31261
31261
  }
31262
31262
  }
31263
- function TextField({
31263
+ const TextField = forwardRef(({
31264
31264
  value,
31265
31265
  onChange,
31266
31266
  label,
@@ -31280,7 +31280,7 @@ function TextField({
31280
31280
  inputStyle,
31281
31281
  inputRef: inputRefProp,
31282
31282
  ...inputProps
31283
- }) {
31283
+ }, ref) => {
31284
31284
  const inputRef = inputRefProp ?? useRef(null);
31285
31285
  const [focused, setFocused] = React__default.useState(document.activeElement === inputRef.current);
31286
31286
  const hasValue = value !== void 0 && value !== null && value !== "";
@@ -31290,16 +31290,13 @@ function TextField({
31290
31290
  if (event.target instanceof HTMLElement) event.target.blur();
31291
31291
  };
31292
31292
  const element = "current" in inputRef ? inputRef.current : inputRef;
31293
- element.addEventListener("wheel", handleWheel);
31293
+ element?.addEventListener("wheel", handleWheel);
31294
31294
  return () => {
31295
- element.removeEventListener("wheel", handleWheel);
31295
+ element?.removeEventListener("wheel", handleWheel);
31296
31296
  };
31297
31297
  }, [inputRef, type]);
31298
- const numberInputOnWheelPreventChange = useCallback((e) => {
31299
- e.preventDefault();
31300
- }, []);
31301
- const input = multiline ? /* @__PURE__ */ jsx(TextareaAutosize, { ...inputProps, ref: inputRef, placeholder: focused || hasValue || !label ? placeholder : void 0, autoFocus, rows, value: value ?? "", onChange, style: inputStyle, className: cls(invisible ? focusedInvisibleMixin : "", "rounded-md resize-none w-full outline-none p-[32px] text-base bg-transparent min-h-[64px] px-3 pt-8", disabled && "outline-none opacity-50 text-surface-accent-600 dark:text-surface-accent-500") }) : /* @__PURE__ */ jsx("input", { ...inputProps, ref: inputRef, onWheel: type === "number" ? numberInputOnWheelPreventChange : void 0, disabled, style: inputStyle, className: cls("w-full outline-none bg-transparent leading-normal px-3", "rounded-md", "focused:text-text-primary focused:dark:text-text-primary-dark", invisible ? focusedInvisibleMixin : "", disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin, size === "small" ? "min-h-[32px]" : size === "medium" ? "min-h-[48px]" : "min-h-[64px]", label ? size === "large" ? "pt-8 pb-2" : "pt-4 pb-2" : "py-2", endAdornment ? "pr-10" : "pr-3", disabled && "outline-none opacity-50 dark:opacity-50 text-surface-accent-800 dark:text-white", inputClassName), placeholder: focused || hasValue || !label ? placeholder : void 0, autoFocus, onFocus: () => setFocused(true), onBlur: () => setFocused(false), type, value: Number.isNaN(value) ? "" : value ?? "", onChange });
31302
- return /* @__PURE__ */ jsxs("div", { className: cls("rounded-md relative max-w-full", invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin, disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin, error ? "border border-red-500 dark:border-red-600" : "", {
31298
+ const input = multiline ? /* @__PURE__ */ jsx(TextareaAutosize, { ...inputProps, ref: inputRef, placeholder: focused || hasValue || !label ? placeholder : void 0, autoFocus, rows, value: value ?? "", onChange, style: inputStyle, className: cls(invisible ? focusedInvisibleMixin : "", "rounded-md resize-none w-full outline-none p-[32px] text-base bg-transparent min-h-[64px] px-3 pt-8", disabled && "outline-none opacity-50 text-surface-accent-600 dark:text-surface-accent-500", inputClassName) }) : /* @__PURE__ */ jsx("input", { ...inputProps, ref: inputRef, disabled, style: inputStyle, className: cls("w-full outline-none bg-transparent leading-normal px-3", "rounded-md", "focused:text-text-primary focused:dark:text-text-primary-dark", invisible ? focusedInvisibleMixin : "", disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin, size === "small" ? "min-h-[32px]" : size === "medium" ? "min-h-[48px]" : "min-h-[64px]", label ? size === "large" ? "pt-8 pb-2" : "pt-4 pb-2" : "py-2", endAdornment ? "pr-10" : "pr-3", disabled && "outline-none opacity-50 dark:opacity-50 text-surface-accent-800 dark:text-white", inputClassName), placeholder: focused || hasValue || !label ? placeholder : void 0, autoFocus, onFocus: () => setFocused(true), onBlur: () => setFocused(false), type, value: type === "number" && Number.isNaN(value) ? "" : value ?? "", onChange });
31299
+ return /* @__PURE__ */ jsxs("div", { ref, className: cls("rounded-md relative max-w-full", invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin, disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin, error ? "border border-red-500 dark:border-red-600" : "", {
31303
31300
  "min-h-[32px]": !invisible && size === "small",
31304
31301
  "min-h-[48px]": !invisible && size === "medium",
31305
31302
  "min-h-[64px]": !invisible && size === "large"
@@ -31312,7 +31309,8 @@ function TextField({
31312
31309
  "mr-2": size === "small"
31313
31310
  }), children: endAdornment })
31314
31311
  ] });
31315
- }
31312
+ });
31313
+ TextField.displayName = "TextField";
31316
31314
  const Tooltip = (t0) => {
31317
31315
  const $ = c(28);
31318
31316
  const {