@bigtablet/design-system 1.11.1 → 1.11.2

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.d.ts CHANGED
@@ -110,7 +110,7 @@ declare const Switch: ({ checked, defaultChecked, onChange, size, disabled, clas
110
110
 
111
111
  type TextFieldVariant = "outline" | "filled" | "ghost";
112
112
  type TextFieldSize = "sm" | "md" | "lg";
113
- interface TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "onChange"> {
113
+ interface TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "onChange" | "value" | "defaultValue"> {
114
114
  label?: string;
115
115
  helperText?: string;
116
116
  error?: boolean;
@@ -120,7 +120,16 @@ interface TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement
120
120
  leftIcon?: React.ReactNode;
121
121
  rightIcon?: React.ReactNode;
122
122
  fullWidth?: boolean;
123
- onChangeAction?: (e: React.ChangeEvent<HTMLInputElement>) => void;
123
+ /**
124
+ * 외부에 최종 값만 전달하는 콜백
125
+ * IME 조합 중 값은 내부에서만 관리된다.
126
+ */
127
+ onChangeAction?: (value: string) => void;
128
+ /**
129
+ * controlled / uncontrolled 모두 지원
130
+ */
131
+ value?: string;
132
+ defaultValue?: string;
124
133
  }
125
134
  declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<HTMLInputElement>>;
126
135
 
package/dist/index.js CHANGED
@@ -509,10 +509,22 @@ var TextField = React3.forwardRef(
509
509
  fullWidth,
510
510
  className,
511
511
  onChangeAction,
512
+ value,
513
+ defaultValue,
512
514
  ...props
513
515
  }, ref) => {
514
516
  const inputId = id ?? React3.useId();
515
517
  const helperId = helperText ? `${inputId}-help` : void 0;
518
+ const isControlled = value !== void 0;
519
+ const [innerValue, setInnerValue] = React3.useState(
520
+ value ?? defaultValue ?? ""
521
+ );
522
+ const isComposingRef = React3.useRef(false);
523
+ React3.useEffect(() => {
524
+ if (isControlled) {
525
+ setInnerValue(value ?? "");
526
+ }
527
+ }, [isControlled, value]);
516
528
  const rootClassName = [
517
529
  "text_field",
518
530
  fullWidth && "text_field_full_width",
@@ -545,7 +557,22 @@ var TextField = React3.forwardRef(
545
557
  "aria-invalid": !!error,
546
558
  "aria-describedby": helperId,
547
559
  ...props,
548
- onChange: onChangeAction
560
+ value: innerValue,
561
+ onCompositionStart: () => {
562
+ isComposingRef.current = true;
563
+ },
564
+ onCompositionEnd: (event) => {
565
+ isComposingRef.current = false;
566
+ const nextValue = event.currentTarget.value;
567
+ setInnerValue(nextValue);
568
+ onChangeAction?.(nextValue);
569
+ },
570
+ onChange: (event) => {
571
+ const nextValue = event.target.value;
572
+ setInnerValue(nextValue);
573
+ if (isComposingRef.current) return;
574
+ onChangeAction?.(nextValue);
575
+ }
549
576
  }
550
577
  ),
551
578
  rightIcon ? /* @__PURE__ */ jsx("span", { className: "text_field_icon text_field_icon_right", children: rightIcon }) : null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigtablet/design-system",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "Bigtablet Design System UI Components",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",