@bigtablet/design-system 1.11.2 → 1.11.3

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
@@ -120,16 +120,10 @@ interface TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement
120
120
  leftIcon?: React.ReactNode;
121
121
  rightIcon?: React.ReactNode;
122
122
  fullWidth?: boolean;
123
- /**
124
- * 외부에 최종 값만 전달하는 콜백
125
- * IME 조합 중 값은 내부에서만 관리된다.
126
- */
127
123
  onChangeAction?: (value: string) => void;
128
- /**
129
- * controlled / uncontrolled 모두 지원
130
- */
131
124
  value?: string;
132
125
  defaultValue?: string;
126
+ transformValue?: (value: string) => string;
133
127
  }
134
128
  declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<HTMLInputElement>>;
135
129
 
package/dist/index.js CHANGED
@@ -511,20 +511,21 @@ var TextField = React3.forwardRef(
511
511
  onChangeAction,
512
512
  value,
513
513
  defaultValue,
514
+ transformValue,
514
515
  ...props
515
516
  }, ref) => {
516
517
  const inputId = id ?? React3.useId();
517
518
  const helperId = helperText ? `${inputId}-help` : void 0;
518
519
  const isControlled = value !== void 0;
520
+ const applyTransform = (nextValue) => transformValue ? transformValue(nextValue) : nextValue;
519
521
  const [innerValue, setInnerValue] = React3.useState(
520
- value ?? defaultValue ?? ""
522
+ () => applyTransform(value ?? defaultValue ?? "")
521
523
  );
522
524
  const isComposingRef = React3.useRef(false);
523
525
  React3.useEffect(() => {
524
- if (isControlled) {
525
- setInnerValue(value ?? "");
526
- }
527
- }, [isControlled, value]);
526
+ if (!isControlled) return;
527
+ setInnerValue(applyTransform(value ?? ""));
528
+ }, [isControlled, value, transformValue]);
528
529
  const rootClassName = [
529
530
  "text_field",
530
531
  fullWidth && "text_field_full_width",
@@ -563,14 +564,19 @@ var TextField = React3.forwardRef(
563
564
  },
564
565
  onCompositionEnd: (event) => {
565
566
  isComposingRef.current = false;
566
- const nextValue = event.currentTarget.value;
567
+ const rawValue = event.currentTarget.value;
568
+ const nextValue = applyTransform(rawValue);
567
569
  setInnerValue(nextValue);
568
570
  onChangeAction?.(nextValue);
569
571
  },
570
572
  onChange: (event) => {
571
- const nextValue = event.target.value;
573
+ const rawValue = event.target.value;
574
+ if (isComposingRef.current) {
575
+ setInnerValue(rawValue);
576
+ return;
577
+ }
578
+ const nextValue = applyTransform(rawValue);
572
579
  setInnerValue(nextValue);
573
- if (isComposingRef.current) return;
574
580
  onChangeAction?.(nextValue);
575
581
  }
576
582
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigtablet/design-system",
3
- "version": "1.11.2",
3
+ "version": "1.11.3",
4
4
  "description": "Bigtablet Design System UI Components",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",