@ehfuse/mui-form-controls 3.1.62 → 3.2.0

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.
@@ -0,0 +1,77 @@
1
+ /**
2
+ * ReadonlyField.tsx
3
+ *
4
+ * mfc 컨트롤들이 readonly / disabled 상태에서 공통으로 쓰는 "박스 표시" 진입점.
5
+ *
6
+ * 설계 규칙 (v3.2.0 부터):
7
+ * - `readonly` : 실제 <input> 대신 {@link ReadonlyDisplay} 박스로 렌더. 글자색은 편집 상태와 동일(흐려지지 않음).
8
+ * - `disabled` : 같은 박스로 렌더하되 글자/라벨/테두리를 흐리게(dimmed) 그린다. 즉 disabled = readonly + 흐림.
9
+ * - `readonlyInput` : 예전처럼 진짜 입력칸을 렌더한다(포커스/선택/커스텀 adornment 가 꼭 필요한 칸의 탈출구).
10
+ * - `readonlyLight` : v3.2.0 에서 기본 동작이 되었으므로 무시된다(@deprecated).
11
+ *
12
+ * 훅 개수 안정성: 박스 분기는 **훅을 가진 Base 컴포넌트 바깥(export 래퍼)** 에서 한다.
13
+ * Base 안에서 early-return 하면 readonly/disabled 플래그가 런타임에 뒤집힐 때 훅 개수가 달라져 React 가 죽는다.
14
+ * 서로 다른 컴포넌트 타입으로 갈라지면 React 가 언마운트/마운트로 처리해 안전하다.
15
+ *
16
+ * @license MIT
17
+ * @copyright 2025 김영진 (Kim Young Jin)
18
+ * @author 김영진 (ehfuse@gmail.com)
19
+ */
20
+ import React from "react";
21
+ import type { ReadonlyDisplayProps } from "./ReadonlyDisplay";
22
+ import type { FormLike } from "../types";
23
+ /** readonly/disabled 판정에 필요한 최소 props. */
24
+ export type ReadonlyBoxFlags = {
25
+ readonly?: boolean;
26
+ disabled?: boolean;
27
+ /** true 면 readonly/disabled 여도 진짜 입력칸을 렌더한다. */
28
+ readonlyInput?: boolean;
29
+ };
30
+ /**
31
+ * 이 컨트롤을 박스(ReadonlyDisplay)로 그려야 하는지.
32
+ * readonly 든 disabled 든 "편집 불가" 이므로 둘 다 박스로 간다. 차이는 흐림(dimmed) 뿐이다.
33
+ */
34
+ export declare function shouldRenderReadonlyBox(props: ReadonlyBoxFlags): boolean;
35
+ /** 컨트롤 props 에서 박스 렌더에 필요한 공통 필드만 뽑는다(컴포넌트마다 반복되는 보일러플레이트 제거). */
36
+ export declare function commonReadonlyBoxProps(props: {
37
+ form?: FormLike | null;
38
+ name?: string;
39
+ value?: unknown;
40
+ label?: React.ReactNode;
41
+ disabled?: boolean;
42
+ size?: "small" | "medium" | string;
43
+ fullWidth?: boolean;
44
+ className?: string;
45
+ id?: string;
46
+ onClick?: unknown;
47
+ sx?: ReadonlyDisplayProps["sx"];
48
+ }): {
49
+ form: FormLike | null | undefined;
50
+ name: string | undefined;
51
+ value: unknown;
52
+ label: React.ReactNode;
53
+ disabled: boolean | undefined;
54
+ size: "small" | "medium";
55
+ fullWidth: boolean | undefined;
56
+ className: string | undefined;
57
+ id: string | undefined;
58
+ onClick: React.MouseEventHandler<HTMLDivElement>;
59
+ sx: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
60
+ };
61
+ type ReadonlyFieldProps = Omit<ReadonlyDisplayProps, "value" | "dimmed"> & {
62
+ /** form 이 있으면 name 으로 값을 구독한다. */
63
+ form?: FormLike | null;
64
+ name?: string;
65
+ /** form 이 없을 때 쓸 값. */
66
+ value?: unknown;
67
+ /** 원시 값을 표시 문자열로 바꾸는 함수(포맷 마스크 등). */
68
+ format?: (value: unknown) => React.ReactNode;
69
+ /** disabled 면 true — 흐리게 그린다. */
70
+ disabled?: boolean;
71
+ };
72
+ /**
73
+ * readonly/disabled 컨트롤의 공통 박스 렌더.
74
+ * form 유무로 컴포넌트 타입이 갈리므로 훅 개수는 각 타입 안에서 고정된다.
75
+ */
76
+ export declare function ReadonlyField(props: ReadonlyFieldProps): import("react/jsx-runtime").JSX.Element;
77
+ export {};
package/dist/index.d.ts CHANGED
@@ -42,5 +42,6 @@ export { CardNumTextField } from "./CardNumTextField";
42
42
  export { useKoreanHolidays, useKoreanHolidaysRange } from "./hooks";
43
43
  export { ReadonlyDisplay } from "./components/ReadonlyDisplay";
44
44
  export type { ReadonlyDisplayProps } from "./components/ReadonlyDisplay";
45
+ export { ReadonlyField, shouldRenderReadonlyBox, } from "./components/ReadonlyField";
45
46
  export { CardIcon, VisaIcon, MastercardIcon, AmexIcon, JcbIcon, DinersIcon, DiscoverIcon, UnionPayIcon, BcIcon, } from "./icons";
46
47
  export type { SearchTextFieldProps, ClearTextFieldProps, TagsTextFieldProps, PasswordTextFieldProps, TextFieldProps, TextAreaProps, CheckboxProps, SwitchProps, RadioGroupProps, RadioOption, DateRangeProps, SliderProps, RatingProps, ToggleButtonProps, ToggleButtonGroupProps, ToggleButtonGroupOption, ButtonGroupProps, StepperProps, AutocompleteProps, AutocompleteOption, SelectProps, SelectOption, LabelSelectProps, LabelSelectOption, AddressTextFieldProps, DaumPostcodeData, PasswordValidationRules, PasswordValidationResult, PhoneTextFieldProps, PhoneFormat, NumberTextFieldProps, JuminTextFieldProps, JuminInfo, VerificationCodeTextFieldProps, VerificationCodeType, EmailTextFieldProps, CustomDomain, DateTextFieldProps, DateFormat, TimeTextFieldProps, TimeFormat, DateTimeTextFieldProps, DateTimeFormat, BizNumTextFieldProps, CorpNumTextFieldProps, CardNumTextFieldProps, CardNumTextFieldHandle, SelectChangeEvent, } from "./types";