@uniai-fe/uds-primitives 0.12.4 → 0.12.6
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/README.md +17 -0
- package/dist/styles.css +2 -2
- package/package.json +17 -17
- package/src/components/form/markup/Provider.tsx +7 -3
- package/src/components/form/markup/form-field/Body.tsx +1 -0
- package/src/components/form/markup/form-field/Container.tsx +3 -1
- package/src/components/form/markup/form-field/Footer.tsx +1 -0
- package/src/components/form/markup/form-field/Header.tsx +2 -0
- package/src/components/form/markup/form-field/Template.tsx +3 -2
- package/src/components/form/markup/form-field/index.tsx +1 -1
- package/src/components/form/markup/index.tsx +1 -0
- package/src/components/form/styles/form-field/variables.scss +2 -2
- package/src/components/form/types/props.ts +21 -19
- package/src/components/form/utils/form-field.ts +6 -4
- package/src/components/input/markup/date/Template.tsx +83 -33
- package/src/components/input/markup/date/Trigger.tsx +28 -12
- package/src/components/input/markup/date/range/Template.tsx +94 -35
- package/src/components/input/markup/time/Template.tsx +118 -5
- package/src/components/input/markup/time/Trigger.tsx +35 -2
- package/src/components/input/types/date.ts +176 -33
- package/src/components/input/types/time.ts +10 -4
- package/src/components/slot/index.tsx +3 -6
- package/src/components/slot/markup/Base.tsx +146 -9
- package/src/components/slot/markup/index.tsx +2 -4
- package/src/components/slot/types/props.ts +119 -23
- package/src/components/table/types/foundation.ts +9 -7
- package/src/components/time-picker/markup/Footer.tsx +5 -5
- package/src/components/time-picker/markup/HourSection.tsx +7 -7
- package/src/components/time-picker/markup/MinuteSection.tsx +5 -5
- package/src/components/time-picker/markup/Summary.tsx +2 -2
- package/src/components/time-picker/markup/Template.tsx +11 -11
- package/src/components/time-picker/types/time-picker.ts +6 -0
- package/src/components/time-picker/utils/time.ts +21 -9
- package/src/index.scss +0 -2
- package/src/index.tsx +8 -2
- package/src/types/index.ts +1 -4
- package/src/utils/index.ts +8 -4
- package/src/utils/selected-values.ts +20 -14
- package/src/components/scrollbar/hooks/index.ts +0 -4
- package/src/components/scrollbar/img/.gitkeep +0 -0
- package/src/components/scrollbar/index.scss +0 -1
- package/src/components/scrollbar/index.tsx +0 -4
- package/src/components/scrollbar/markup/index.tsx +0 -4
- package/src/components/scrollbar/styles/index.scss +0 -0
- package/src/components/scrollbar/types/index.ts +0 -4
- package/src/components/scrollbar/utils/index.ts +0 -4
- package/src/components/spinner/hooks/index.ts +0 -4
- package/src/components/spinner/img/.gitkeep +0 -0
- package/src/components/spinner/index.scss +0 -1
- package/src/components/spinner/index.tsx +0 -4
- package/src/components/spinner/markup/index.tsx +0 -4
- package/src/components/spinner/styles/index.scss +0 -0
- package/src/components/spinner/types/index.ts +0 -4
- package/src/components/spinner/utils/index.ts +0 -4
- package/src/hooks/index.ts +0 -4
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ComponentPropsWithoutRef,
|
|
3
|
+
FocusEvent,
|
|
4
|
+
MouseEvent,
|
|
5
|
+
ReactNode,
|
|
6
|
+
} from "react";
|
|
2
7
|
import type { UseFormRegisterReturn } from "react-hook-form";
|
|
3
8
|
import type {
|
|
4
9
|
CalendarColumns,
|
|
@@ -10,7 +15,18 @@ import type {
|
|
|
10
15
|
CalendarRangeValue,
|
|
11
16
|
CalendarValue,
|
|
12
17
|
} from "../../calendar";
|
|
13
|
-
import type {
|
|
18
|
+
import type { FormFieldWidth } from "../../form/types/props";
|
|
19
|
+
import type { InputPriority, InputSize, InputState } from "./foundation";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Input Date hidden input props.
|
|
23
|
+
* @typedef {Omit<ComponentPropsWithoutRef<"input">, "type" | "value" | "defaultValue" | "name">} InputCalendarHiddenInputProps
|
|
24
|
+
* @desc Template이 고정하는 type, value, defaultValue와 name을 제외한 native hidden input 계약
|
|
25
|
+
*/
|
|
26
|
+
export type InputCalendarHiddenInputProps = Omit<
|
|
27
|
+
ComponentPropsWithoutRef<"input">,
|
|
28
|
+
"type" | "value" | "defaultValue" | "name"
|
|
29
|
+
>;
|
|
14
30
|
|
|
15
31
|
/**
|
|
16
32
|
* Calendar trigger(Input) 영역에서 필요한 속성 묶음.
|
|
@@ -22,8 +38,14 @@ import type { InputPriority, InputState } from "./foundation";
|
|
|
22
38
|
* @property {boolean} [disabled] disabled 여부
|
|
23
39
|
* @property {boolean} [readOnly] readOnly 여부
|
|
24
40
|
* @property {string} [placeholder] trigger 내부 placeholder
|
|
25
|
-
* @property {
|
|
26
|
-
* @property {
|
|
41
|
+
* @property {"primary" | "secondary" | "tertiary" | "table"} [priority] trigger input priority
|
|
42
|
+
* @property {"small" | "medium" | "large"} [size] trigger input size
|
|
43
|
+
* @property {"default" | "active" | "focused" | "success" | "error" | "disabled" | "loading"} [state] trigger input state
|
|
44
|
+
* @property {boolean} [block] trigger width 100% 여부
|
|
45
|
+
* @property {"full" | "fit" | "fill" | "auto" | number | string} [width] trigger width preset 또는 custom width
|
|
46
|
+
* @property {(event: FocusEvent<HTMLInputElement>) => void} [onFocus] trigger focus 핸들러
|
|
47
|
+
* @property {(event: FocusEvent<HTMLInputElement>) => void} [onBlur] trigger blur 핸들러
|
|
48
|
+
* @desc Date trigger의 표시·상호작용 입력 계약. Template의 name/register는 hidden input 저장에 사용한다.
|
|
27
49
|
*/
|
|
28
50
|
export interface InputCalendarTriggerProps {
|
|
29
51
|
/**
|
|
@@ -59,16 +81,38 @@ export interface InputCalendarTriggerProps {
|
|
|
59
81
|
* - table일 때 Trigger는 left icon 배치를 사용한다.
|
|
60
82
|
*/
|
|
61
83
|
priority?: InputPriority;
|
|
84
|
+
/**
|
|
85
|
+
* "small" | "medium" | "large".
|
|
86
|
+
*/
|
|
87
|
+
size?: InputSize;
|
|
62
88
|
/**
|
|
63
89
|
* trigger input state
|
|
64
90
|
*/
|
|
65
91
|
state?: InputState;
|
|
92
|
+
/**
|
|
93
|
+
* trigger width 100% 여부.
|
|
94
|
+
*/
|
|
95
|
+
block?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* "full" | "fit" | "fill" | "auto" | number | string.
|
|
98
|
+
*/
|
|
99
|
+
width?: FormFieldWidth;
|
|
100
|
+
/**
|
|
101
|
+
* trigger focus 핸들러.
|
|
102
|
+
*/
|
|
103
|
+
onFocus?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
104
|
+
/**
|
|
105
|
+
* trigger blur 핸들러.
|
|
106
|
+
*/
|
|
107
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
66
108
|
}
|
|
67
109
|
|
|
68
110
|
/**
|
|
69
111
|
* Trigger view에서만 사용하는 부가 props.
|
|
70
112
|
* @property {string} [className] trigger root className
|
|
71
113
|
* @property {string} [displayValue] 표시 값 문자열
|
|
114
|
+
* @see InputCalendarTriggerProps
|
|
115
|
+
* @desc 기본 Date trigger가 InputFoundation.Base에 전달하는 view 계약
|
|
72
116
|
*/
|
|
73
117
|
export interface InputCalendarTriggerViewProps extends InputCalendarTriggerProps {
|
|
74
118
|
/**
|
|
@@ -90,8 +134,14 @@ export interface InputCalendarTriggerViewProps extends InputCalendarTriggerProps
|
|
|
90
134
|
* @property {boolean} [disabled] disabled 여부
|
|
91
135
|
* @property {boolean} [readOnly] readOnly 여부
|
|
92
136
|
* @property {(event: MouseEvent<Element>) => void} [onClick] 트리거 클릭 핸들러
|
|
93
|
-
* @property {
|
|
94
|
-
* @property {
|
|
137
|
+
* @property {"primary" | "secondary" | "tertiary" | "table"} [priority] trigger input priority
|
|
138
|
+
* @property {"small" | "medium" | "large"} [size] trigger input size
|
|
139
|
+
* @property {"default" | "active" | "focused" | "success" | "error" | "disabled" | "loading"} [state] trigger input state
|
|
140
|
+
* @property {boolean} [block] trigger width 100% 여부
|
|
141
|
+
* @property {"full" | "fit" | "fill" | "auto" | number | string} [width] trigger width preset 또는 custom width
|
|
142
|
+
* @property {(event: FocusEvent<HTMLInputElement>) => void} [onFocus] trigger focus 핸들러
|
|
143
|
+
* @property {(event: FocusEvent<HTMLInputElement>) => void} [onBlur] trigger blur 핸들러
|
|
144
|
+
* @desc custom Date trigger에 전달하는 표시·상호작용 계약
|
|
95
145
|
*/
|
|
96
146
|
export interface InputCalendarTriggerRenderProps {
|
|
97
147
|
/**
|
|
@@ -127,57 +177,92 @@ export interface InputCalendarTriggerRenderProps {
|
|
|
127
177
|
* - table일 때 Trigger는 left icon 배치를 사용한다.
|
|
128
178
|
*/
|
|
129
179
|
priority?: InputPriority;
|
|
180
|
+
/**
|
|
181
|
+
* "small" | "medium" | "large".
|
|
182
|
+
*/
|
|
183
|
+
size?: InputSize;
|
|
130
184
|
/**
|
|
131
185
|
* trigger input state
|
|
132
186
|
*/
|
|
133
187
|
state?: InputState;
|
|
188
|
+
/**
|
|
189
|
+
* trigger width 100% 여부.
|
|
190
|
+
*/
|
|
191
|
+
block?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* "full" | "fit" | "fill" | "auto" | number | string.
|
|
194
|
+
*/
|
|
195
|
+
width?: FormFieldWidth;
|
|
196
|
+
/**
|
|
197
|
+
* trigger focus 핸들러.
|
|
198
|
+
*/
|
|
199
|
+
onFocus?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
200
|
+
/**
|
|
201
|
+
* trigger blur 핸들러.
|
|
202
|
+
*/
|
|
203
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
134
204
|
}
|
|
135
205
|
|
|
136
206
|
/**
|
|
137
207
|
* Input Calendar core props.
|
|
138
|
-
* @property {
|
|
139
|
-
* @property {
|
|
140
|
-
* @property {
|
|
141
|
-
* @property {
|
|
142
|
-
* @property {
|
|
143
|
-
* @property {
|
|
208
|
+
* @property {"date" | "date-time" | "time"} [mode="date"] Calendar layout mode. 선택 body는 date로 유지된다.
|
|
209
|
+
* @property {1 | 2} [columns=1] 동시에 노출할 달력 열 수
|
|
210
|
+
* @property {string | null} [value] 제어형 값
|
|
211
|
+
* @property {string | null} [defaultValue] 비제어 초기값
|
|
212
|
+
* @property {(value: string | null) => void} [onChange] 값 변경 핸들러(직렬화 문자열 기준)
|
|
213
|
+
* @property {(value: string | null) => void} [onValueChange] onChange 별칭(추가 파이프라인용)
|
|
144
214
|
* @property {boolean} [readOnly] 읽기 전용 여부
|
|
145
215
|
* @property {boolean} [disabled] disabled 여부
|
|
146
216
|
* @property {CalendarDatePickerProps} [datePickerProps] Mantine DatePicker 직접 옵션
|
|
147
|
-
* @property {
|
|
148
|
-
* @property {
|
|
217
|
+
* @property {string} [id] trigger id
|
|
218
|
+
* @property {string} [name] hidden input form name
|
|
219
|
+
* @property {UseFormRegisterReturn} [register] hidden input react-hook-form register 결과
|
|
220
|
+
* @property {string} [placeholder] trigger 내부 placeholder
|
|
221
|
+
* @property {(event: MouseEvent<Element>) => void} [onClick] trigger 클릭 핸들러
|
|
222
|
+
* @property {"primary" | "secondary" | "tertiary" | "table"} [priority] trigger input priority
|
|
223
|
+
* @property {"small" | "medium" | "large"} [size] trigger input size
|
|
224
|
+
* @property {"default" | "active" | "focused" | "success" | "error" | "disabled" | "loading"} [state] trigger input state
|
|
225
|
+
* @property {boolean} [block] trigger width 100% 여부
|
|
226
|
+
* @property {"full" | "fit" | "fill" | "auto" | number | string} [width] trigger width preset 또는 custom width
|
|
227
|
+
* @property {string} [form] hidden input이 연결될 form id
|
|
228
|
+
* @property {boolean} [required] hidden input required 여부
|
|
229
|
+
* @property {InputCalendarHiddenInputProps} [hiddenInputProps] Template 고정값을 제외한 hidden input native props
|
|
230
|
+
* @property {(event: FocusEvent<HTMLInputElement>) => void} [onFocus] trigger focus 핸들러
|
|
231
|
+
* @property {(event: FocusEvent<HTMLInputElement>) => void} [onBlur] trigger blur 핸들러와 RHF touched 동기화 진입점
|
|
149
232
|
* @property {ReactNode} [header] 커스텀 header 콘텐츠
|
|
150
233
|
* @property {ReactNode} [footer] 커스텀 footer 콘텐츠
|
|
151
234
|
* @property {InputCalendarTexts} [texts] 기본 Date 문구
|
|
152
|
-
* @property {unknown} [timePicker]
|
|
235
|
+
* @property {unknown} [timePicker] 미구현 compatibility prop. 시간 선택에는 Input.Time.Template을 사용한다.
|
|
153
236
|
* @property {boolean} [calendarOpened] calendar 열림 제어 여부
|
|
154
237
|
* @property {(open: boolean) => void} [onCalendarOpen] calendar 열림 변경 이벤트
|
|
155
238
|
* @property {ReactNode} [trigger] 커스텀 trigger 슬롯
|
|
156
239
|
* @property {(props: InputCalendarTriggerRenderProps) => ReactNode} [renderTrigger] 커스텀 trigger 렌더 함수
|
|
240
|
+
* @desc 단일 날짜 trigger, Calendar와 hidden form storage를 조합하는 공개 계약
|
|
157
241
|
*/
|
|
158
242
|
export interface InputCalendarProps extends InputCalendarTriggerProps {
|
|
159
243
|
/**
|
|
160
|
-
*
|
|
244
|
+
* "date" | "date-time" | "time".
|
|
245
|
+
* Calendar layout의 data-mode만 지정하며 선택 body는 date로 유지된다.
|
|
161
246
|
*/
|
|
162
247
|
mode?: CalendarMode;
|
|
163
248
|
/**
|
|
164
|
-
*
|
|
249
|
+
* 1 | 2.
|
|
165
250
|
*/
|
|
166
251
|
columns?: CalendarColumns;
|
|
167
252
|
/**
|
|
168
|
-
*
|
|
253
|
+
* string | null.
|
|
169
254
|
*/
|
|
170
255
|
value?: CalendarValue;
|
|
171
256
|
/**
|
|
172
|
-
*
|
|
257
|
+
* string | null.
|
|
173
258
|
*/
|
|
174
259
|
defaultValue?: CalendarValue;
|
|
175
260
|
/**
|
|
176
|
-
*
|
|
261
|
+
* (value: string | null) => void.
|
|
177
262
|
*/
|
|
178
263
|
onChange?: CalendarOnChange;
|
|
179
264
|
/**
|
|
180
|
-
* onChange
|
|
265
|
+
* (value: string | null) => void. onChange 별칭으로 외부 파이프라인에 사용한다.
|
|
181
266
|
*/
|
|
182
267
|
onValueChange?: CalendarOnChange;
|
|
183
268
|
/**
|
|
@@ -205,8 +290,8 @@ export interface InputCalendarProps extends InputCalendarTriggerProps {
|
|
|
205
290
|
*/
|
|
206
291
|
texts?: InputCalendarTexts;
|
|
207
292
|
/**
|
|
208
|
-
* TimePicker 확장용
|
|
209
|
-
*
|
|
293
|
+
* TimePicker 확장용 미구현 compatibility prop.
|
|
294
|
+
* @deprecated 시간 선택에는 Input.Time.Template을 사용한다.
|
|
210
295
|
*/
|
|
211
296
|
timePicker?: unknown;
|
|
212
297
|
/**
|
|
@@ -226,14 +311,26 @@ export interface InputCalendarProps extends InputCalendarTriggerProps {
|
|
|
226
311
|
* 커스텀 trigger 렌더 함수
|
|
227
312
|
*/
|
|
228
313
|
renderTrigger?: (props: InputCalendarTriggerRenderProps) => ReactNode;
|
|
314
|
+
/**
|
|
315
|
+
* hidden input이 연결될 form id.
|
|
316
|
+
*/
|
|
317
|
+
form?: string;
|
|
318
|
+
/**
|
|
319
|
+
* hidden input required 여부.
|
|
320
|
+
*/
|
|
321
|
+
required?: boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Template 고정값을 제외한 hidden input native props.
|
|
324
|
+
*/
|
|
325
|
+
hiddenInputProps?: InputCalendarHiddenInputProps;
|
|
229
326
|
}
|
|
230
327
|
|
|
231
328
|
/**
|
|
232
329
|
* Input Calendar Range Template props.
|
|
233
|
-
* @property {
|
|
234
|
-
* @property {
|
|
235
|
-
* @property {
|
|
236
|
-
* @property {
|
|
330
|
+
* @property {[string | null, string | null]} [value] 제어형 range 값
|
|
331
|
+
* @property {[string | null, string | null]} [defaultValue] 비제어 range 초기값
|
|
332
|
+
* @property {(value: [string | null, string | null]) => void} [onChange] range 값 변경 핸들러
|
|
333
|
+
* @property {(value: [string | null, string | null]) => void} [onValueChange] onChange 별칭
|
|
237
334
|
* @property {boolean} [readOnly] 읽기 전용 여부
|
|
238
335
|
* @property {boolean} [disabled] disabled 여부
|
|
239
336
|
* @property {CalendarRangeDatePickerProps} [datePickerProps] Mantine range DatePicker 옵션
|
|
@@ -242,8 +339,17 @@ export interface InputCalendarProps extends InputCalendarTriggerProps {
|
|
|
242
339
|
* @property {UseFormRegisterReturn} [startRegister] 시작일 react-hook-form register 결과
|
|
243
340
|
* @property {UseFormRegisterReturn} [endRegister] 종료일 react-hook-form register 결과
|
|
244
341
|
* @property {string} [placeholder] trigger 내부 placeholder
|
|
245
|
-
* @property {
|
|
246
|
-
* @property {
|
|
342
|
+
* @property {"primary" | "secondary" | "tertiary" | "table"} [priority] trigger input priority
|
|
343
|
+
* @property {"small" | "medium" | "large"} [size] trigger input size
|
|
344
|
+
* @property {"default" | "active" | "focused" | "success" | "error" | "disabled" | "loading"} [state] trigger input state
|
|
345
|
+
* @property {boolean} [block] trigger width 100% 여부
|
|
346
|
+
* @property {"full" | "fit" | "fill" | "auto" | number | string} [width] trigger width preset 또는 custom width
|
|
347
|
+
* @property {string} [form] start/end hidden input이 연결될 공통 form id
|
|
348
|
+
* @property {boolean} [required] start/end hidden input required 여부
|
|
349
|
+
* @property {InputCalendarHiddenInputProps} [startHiddenInputProps] 시작일 hidden input native props
|
|
350
|
+
* @property {InputCalendarHiddenInputProps} [endHiddenInputProps] 종료일 hidden input native props
|
|
351
|
+
* @property {(event: FocusEvent<HTMLInputElement>) => void} [onFocus] trigger focus 핸들러
|
|
352
|
+
* @property {(event: FocusEvent<HTMLInputElement>) => void} [onBlur] trigger blur 핸들러와 RHF touched 동기화 진입점
|
|
247
353
|
* @property {ReactNode} [header] 커스텀 header 콘텐츠
|
|
248
354
|
* @property {ReactNode} [footer] 커스텀 footer 콘텐츠
|
|
249
355
|
* @property {InputCalendarTexts} [texts] 기본 Date 문구
|
|
@@ -253,22 +359,23 @@ export interface InputCalendarProps extends InputCalendarTriggerProps {
|
|
|
253
359
|
* @property {ReactNode} [trigger] 커스텀 trigger 슬롯
|
|
254
360
|
* @property {(props: InputCalendarTriggerRenderProps) => ReactNode} [renderTrigger] 커스텀 trigger 렌더 함수
|
|
255
361
|
* @property {(event: MouseEvent<Element>) => void} [onClick] trigger 클릭 핸들러
|
|
362
|
+
* @desc 기간 trigger, Calendar.Range와 start/end hidden form storage를 조합하는 공개 계약
|
|
256
363
|
*/
|
|
257
364
|
export interface InputCalendarRangeProps {
|
|
258
365
|
/**
|
|
259
|
-
*
|
|
366
|
+
* [string | null, string | null].
|
|
260
367
|
*/
|
|
261
368
|
value?: CalendarRangeValue;
|
|
262
369
|
/**
|
|
263
|
-
*
|
|
370
|
+
* [string | null, string | null].
|
|
264
371
|
*/
|
|
265
372
|
defaultValue?: CalendarRangeValue;
|
|
266
373
|
/**
|
|
267
|
-
*
|
|
374
|
+
* (value: [string | null, string | null]) => void.
|
|
268
375
|
*/
|
|
269
376
|
onChange?: CalendarRangeOnChange;
|
|
270
377
|
/**
|
|
271
|
-
* onChange
|
|
378
|
+
* (value: [string | null, string | null]) => void. onChange 별칭으로 외부 파이프라인에 사용한다.
|
|
272
379
|
*/
|
|
273
380
|
onValueChange?: CalendarRangeOnChange;
|
|
274
381
|
/**
|
|
@@ -308,10 +415,46 @@ export interface InputCalendarRangeProps {
|
|
|
308
415
|
* - table일 때 Trigger는 left icon 배치를 사용한다.
|
|
309
416
|
*/
|
|
310
417
|
priority?: InputPriority;
|
|
418
|
+
/**
|
|
419
|
+
* "small" | "medium" | "large".
|
|
420
|
+
*/
|
|
421
|
+
size?: InputSize;
|
|
311
422
|
/**
|
|
312
423
|
* trigger input state
|
|
313
424
|
*/
|
|
314
425
|
state?: InputState;
|
|
426
|
+
/**
|
|
427
|
+
* trigger width 100% 여부.
|
|
428
|
+
*/
|
|
429
|
+
block?: boolean;
|
|
430
|
+
/**
|
|
431
|
+
* "full" | "fit" | "fill" | "auto" | number | string.
|
|
432
|
+
*/
|
|
433
|
+
width?: FormFieldWidth;
|
|
434
|
+
/**
|
|
435
|
+
* start/end hidden input이 연결될 공통 form id.
|
|
436
|
+
*/
|
|
437
|
+
form?: string;
|
|
438
|
+
/**
|
|
439
|
+
* start/end hidden input required 여부.
|
|
440
|
+
*/
|
|
441
|
+
required?: boolean;
|
|
442
|
+
/**
|
|
443
|
+
* 시작일 hidden input native props.
|
|
444
|
+
*/
|
|
445
|
+
startHiddenInputProps?: InputCalendarHiddenInputProps;
|
|
446
|
+
/**
|
|
447
|
+
* 종료일 hidden input native props.
|
|
448
|
+
*/
|
|
449
|
+
endHiddenInputProps?: InputCalendarHiddenInputProps;
|
|
450
|
+
/**
|
|
451
|
+
* trigger focus 핸들러.
|
|
452
|
+
*/
|
|
453
|
+
onFocus?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
454
|
+
/**
|
|
455
|
+
* trigger blur 핸들러.
|
|
456
|
+
*/
|
|
457
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
315
458
|
/**
|
|
316
459
|
* 커스텀 header 콘텐츠
|
|
317
460
|
*/
|
|
@@ -21,6 +21,8 @@ export type InputTimeIconPosition = "left" | "right";
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Input Time hidden input props.
|
|
24
|
+
* @typedef {Omit<ComponentPropsWithoutRef<"input">, "type" | "value" | "defaultValue" | "name">} InputTimeHiddenInputProps
|
|
25
|
+
* @desc Template이 고정하는 type, value, defaultValue와 name을 제외한 native hidden input 계약
|
|
24
26
|
*/
|
|
25
27
|
export type InputTimeHiddenInputProps = Omit<
|
|
26
28
|
ComponentPropsWithoutRef<"input">,
|
|
@@ -32,6 +34,7 @@ export type InputTimeHiddenInputProps = Omit<
|
|
|
32
34
|
* @property {string} hours 시 입력값
|
|
33
35
|
* @property {string} minutes 분 입력값
|
|
34
36
|
* @property {string} seconds 초 입력값
|
|
37
|
+
* @desc 입력 field에 표시하는 시·분·초 draft 문자열
|
|
35
38
|
*/
|
|
36
39
|
export interface InputTimeDraftFields {
|
|
37
40
|
/**
|
|
@@ -52,6 +55,7 @@ export interface InputTimeDraftFields {
|
|
|
52
55
|
* Input Time 편집 중인 시간 값.
|
|
53
56
|
* @property {InputTimeDraftFields} fields 시·분·초 입력값
|
|
54
57
|
* @property {"am" | "pm"} period 오전·오후 구분
|
|
58
|
+
* @desc 저장값 commit 전의 field 문자열과 12시간제 period 상태
|
|
55
59
|
*/
|
|
56
60
|
export interface InputTimeDraft {
|
|
57
61
|
/**
|
|
@@ -99,6 +103,7 @@ export type InputTimeTriggerFields = InputTimeDraftFields;
|
|
|
99
103
|
* @property {(period: "am" | "pm") => void} onPeriodChange 오전·오후 변경 핸들러
|
|
100
104
|
* @property {(amount: 1 | -1) => void} onStep 활성 단위 증감 핸들러
|
|
101
105
|
* @property {(event: FocusEvent<HTMLDivElement>) => void} onRootBlur root blur 핸들러
|
|
106
|
+
* @desc 시·분·초 field, period, stepper와 clock action을 렌더링하기 위한 trigger 계약
|
|
102
107
|
*/
|
|
103
108
|
export interface InputTimeTriggerProps extends Omit<
|
|
104
109
|
ComponentPropsWithoutRef<"div">,
|
|
@@ -225,8 +230,8 @@ export interface InputTimeTriggerProps extends Omit<
|
|
|
225
230
|
* 저장값은 24시간 `HH:mm` 또는 `HH:mm:ss` 문자열을 사용한다.
|
|
226
231
|
* @property {string} [value] 제어형 시간 값
|
|
227
232
|
* @property {string} [defaultValue] 비제어 초기 시간 값
|
|
228
|
-
* @property {(value:string)=>void} [onChange] 값 변경 핸들러
|
|
229
|
-
* @property {(value:string)=>void} [onValueChange] 값 변경 별칭
|
|
233
|
+
* @property {(value: string) => void} [onChange] 값 변경 핸들러
|
|
234
|
+
* @property {(value: string) => void} [onValueChange] 값 변경 별칭
|
|
230
235
|
* @property {string} [name] form name
|
|
231
236
|
* @property {string} [form] form id
|
|
232
237
|
* @property {UseFormRegisterReturn} [register] react-hook-form register 결과
|
|
@@ -257,8 +262,9 @@ export interface InputTimeTriggerProps extends Omit<
|
|
|
257
262
|
* @property {string} [hoursPlaceholder] 시 placeholder
|
|
258
263
|
* @property {string} [minutesPlaceholder] 분 placeholder
|
|
259
264
|
* @property {string} [secondsPlaceholder] 초 placeholder
|
|
260
|
-
* @property {(event:FocusEvent<HTMLInputElement>)=>void} [onFocus] focus 핸들러
|
|
261
|
-
* @property {(event:FocusEvent<HTMLDivElement>)=>void} [onBlur] blur 핸들러
|
|
265
|
+
* @property {(event: FocusEvent<HTMLInputElement>) => void} [onFocus] focus 핸들러
|
|
266
|
+
* @property {(event: FocusEvent<HTMLDivElement>) => void} [onBlur] blur 핸들러
|
|
267
|
+
* @desc 시간 trigger, TimePicker panel과 24시간 문자열 hidden form storage를 조합하는 공개 계약
|
|
262
268
|
*/
|
|
263
269
|
export interface InputTimeTemplateProps {
|
|
264
270
|
/**
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* Slot
|
|
3
|
-
*
|
|
4
|
-
* - `Slot.Base`: as 기반 polymorphic 마크업 래퍼다.
|
|
5
|
-
* - `Slot.Text`: 텍스트 children만 래핑하는 공통 슬롯이다.
|
|
6
|
-
* - `SlotComponentProps`, `SlotTextProps`: public type 계약이다.
|
|
1
|
+
/*
|
|
2
|
+
* Slot public entry. Runtime namespace는 ./markup, public prop type은 ./types의
|
|
3
|
+
* 원본 선언이 계약을 소유한다.
|
|
7
4
|
*/
|
|
8
5
|
export * from "./markup";
|
|
9
6
|
export type * from "./types";
|
|
@@ -1,23 +1,158 @@
|
|
|
1
|
-
import
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import {
|
|
3
|
+
Children,
|
|
4
|
+
cloneElement,
|
|
5
|
+
createElement,
|
|
6
|
+
Fragment,
|
|
7
|
+
forwardRef,
|
|
8
|
+
type ElementType,
|
|
9
|
+
type ReactElement,
|
|
10
|
+
type Ref,
|
|
11
|
+
} from "react";
|
|
2
12
|
import type {
|
|
3
13
|
PolymorphicRef,
|
|
4
14
|
SlotComponentProps,
|
|
5
15
|
SlotComponentType,
|
|
16
|
+
SlotElementProps,
|
|
6
17
|
} from "../types/props";
|
|
7
18
|
|
|
8
19
|
/**
|
|
9
|
-
*
|
|
20
|
+
* Ref utility; callback 또는 object ref에 현재 node를 전달한다.
|
|
21
|
+
* @function
|
|
22
|
+
* @param {React.Ref<unknown> | undefined} ref 갱신할 callback 또는 object ref.
|
|
23
|
+
* @param {unknown} node ref에 전달할 현재 node 또는 null.
|
|
24
|
+
* @desc callback ref가 반환한 React 19 cleanup을 그대로 보존하고 object ref는 current를 직접 갱신한다.
|
|
25
|
+
* @return {void | (() => void)} callback cleanup이 있으면 해당 함수, 그 외에는 void.
|
|
26
|
+
*/
|
|
27
|
+
const setRef = (
|
|
28
|
+
ref: Ref<unknown> | undefined,
|
|
29
|
+
node: unknown,
|
|
30
|
+
): void | (() => void) => {
|
|
31
|
+
if (typeof ref === "function") return ref(node);
|
|
32
|
+
if (ref && typeof ref === "object") {
|
|
33
|
+
(ref as { current: unknown }).current = node;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Ref utility; child ref와 전달된 ref를 하나의 callback ref로 병합한다.
|
|
39
|
+
* @function
|
|
40
|
+
* @param {Array<React.Ref<unknown> | undefined>} refs 함께 갱신할 callback 또는 object ref 목록.
|
|
41
|
+
* @desc React 19 callback cleanup이 있으면 cleanup 없는 나머지 ref도 같은
|
|
42
|
+
* unmount에서 null로 해제한다.
|
|
43
|
+
* @return {React.RefCallback<unknown> | undefined} ref가 없으면 undefined, 있으면 병합된 callback ref.
|
|
44
|
+
*/
|
|
45
|
+
const mergeRefs = (...refs: (Ref<unknown> | undefined)[]) => {
|
|
46
|
+
if (refs.every(ref => ref == null)) return undefined;
|
|
47
|
+
|
|
48
|
+
return (node: unknown) => {
|
|
49
|
+
const cleanups = refs.map(ref => setRef(ref, node));
|
|
50
|
+
|
|
51
|
+
// React 19 callback ref 하나라도 cleanup을 반환하면 나머지 ref도 같은 unmount에서 해제한다.
|
|
52
|
+
if (!cleanups.some(cleanup => typeof cleanup === "function")) return;
|
|
53
|
+
|
|
54
|
+
return () => {
|
|
55
|
+
cleanups.forEach((cleanup, index) => {
|
|
56
|
+
if (typeof cleanup === "function") cleanup();
|
|
57
|
+
else setRef(refs[index], null);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Props utility; Slot과 child가 소유한 props를 asChild 계약에 따라 병합한다.
|
|
65
|
+
* @function
|
|
66
|
+
* @param {SlotElementProps} slotProps Slot.Base에 전달된 props.
|
|
67
|
+
* @param {SlotElementProps} childProps 단일 child element가 소유한 props.
|
|
68
|
+
* @desc
|
|
69
|
+
* - 일반 props와 같은 style property는 child가 우선하고, className은 Slot 다음
|
|
70
|
+
* child 순서로 합친다.
|
|
71
|
+
* - 같은 event handler는 모든 인자를 child, Slot 순서로 전달하고 child 반환값을
|
|
72
|
+
* 보존한다. 첫 번째 인자의 defaultPrevented가 true일 때만 Slot handler를 생략한다.
|
|
73
|
+
* @return {SlotElementProps} child에 전달할 병합 props.
|
|
74
|
+
*/
|
|
75
|
+
const mergeSlotProps = (
|
|
76
|
+
slotProps: SlotElementProps,
|
|
77
|
+
childProps: SlotElementProps,
|
|
78
|
+
): SlotElementProps => {
|
|
79
|
+
const mergedProps: SlotElementProps = { ...slotProps, ...childProps };
|
|
80
|
+
|
|
81
|
+
Object.keys(slotProps).forEach(key => {
|
|
82
|
+
const slotHandler = slotProps[key];
|
|
83
|
+
const childHandler = childProps[key];
|
|
84
|
+
|
|
85
|
+
if (
|
|
86
|
+
/^on[A-Z]/.test(key) &&
|
|
87
|
+
typeof slotHandler === "function" &&
|
|
88
|
+
typeof childHandler === "function"
|
|
89
|
+
) {
|
|
90
|
+
mergedProps[key] = (...args: unknown[]) => {
|
|
91
|
+
const result = childHandler(...args);
|
|
92
|
+
const event = args[0];
|
|
93
|
+
const defaultPrevented =
|
|
94
|
+
typeof event === "object" &&
|
|
95
|
+
event !== null &&
|
|
96
|
+
"defaultPrevented" in event &&
|
|
97
|
+
event.defaultPrevented === true;
|
|
98
|
+
|
|
99
|
+
if (!defaultPrevented) slotHandler(...args);
|
|
100
|
+
return result;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
mergedProps.className =
|
|
106
|
+
clsx(slotProps.className, childProps.className) || undefined;
|
|
107
|
+
if (slotProps.style || childProps.style) {
|
|
108
|
+
mergedProps.style = { ...slotProps.style, ...childProps.style };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return mergedProps;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* SlotComponent; as로 요소를 교체하거나 asChild로 단일 child를 직접 렌더링하는 추상화.
|
|
10
116
|
* @component
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
117
|
+
* @property {ElementType} [as="div"] asChild가 false일 때 교체할 요소.
|
|
118
|
+
* @property {true | false} [asChild=false] true이면 단일 child를 wrapper 없이 렌더링하고, false이면 as 요소를 렌더링한다.
|
|
119
|
+
* @property {React.ReactElement | React.ReactNode} [children] asChild가 true이면 필수인 단일 non-Fragment ReactElement, false이면 선택적인 ReactNode.
|
|
120
|
+
* @property {string} [className] 추가 className.
|
|
121
|
+
* @param {React.Ref<unknown>} [ref] 렌더링된 요소에 병합할 ref.
|
|
122
|
+
* @desc
|
|
123
|
+
* - asChild에서는 child의 일반 props를 우선하고 Slot className 다음에 child className을 합치며, 같은 style property는 child가 우선한다.
|
|
124
|
+
* - 같은 event handler는 모든 인자를 child, Slot 순서로 전달하고 child 반환값을 보존하며, 첫 번째 인자의 defaultPrevented가 true일 때만 Slot handler를 생략한다.
|
|
125
|
+
* - child ref와 전달된 ref를 합치며 React 19 callback cleanup이 있으면 cleanup 없는 나머지 ref는 null로 해제한다.
|
|
126
|
+
* - asChild의 child가 단일 non-Fragment ReactElement가 아니면 예외를 던진다.
|
|
127
|
+
* @return {React.ReactNode} 렌더링된 노드.
|
|
15
128
|
*/
|
|
16
129
|
const SlotComponent = forwardRef(
|
|
17
130
|
(
|
|
18
|
-
{
|
|
131
|
+
{
|
|
132
|
+
as,
|
|
133
|
+
asChild,
|
|
134
|
+
children,
|
|
135
|
+
className,
|
|
136
|
+
...rest
|
|
137
|
+
}: SlotComponentProps<ElementType>,
|
|
19
138
|
ref?: PolymorphicRef<ElementType>,
|
|
20
139
|
) => {
|
|
140
|
+
if (asChild) {
|
|
141
|
+
const child = Children.only(children) as ReactElement<SlotElementProps>;
|
|
142
|
+
|
|
143
|
+
if (child.type === Fragment) {
|
|
144
|
+
throw new TypeError(
|
|
145
|
+
"Slot.Base asChild requires one non-Fragment React element.",
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const childProps = child.props as SlotElementProps;
|
|
150
|
+
return cloneElement(child, {
|
|
151
|
+
...mergeSlotProps({ ...rest, className }, childProps),
|
|
152
|
+
ref: mergeRefs(childProps.ref, ref as Ref<unknown>),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
21
156
|
const Component = (as ?? "div") as ElementType;
|
|
22
157
|
return createElement(
|
|
23
158
|
Component,
|
|
@@ -29,6 +164,8 @@ const SlotComponent = forwardRef(
|
|
|
29
164
|
children,
|
|
30
165
|
);
|
|
31
166
|
},
|
|
32
|
-
)
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
SlotComponent.displayName = "SlotBase";
|
|
33
170
|
|
|
34
|
-
export default SlotComponent;
|
|
171
|
+
export default SlotComponent as unknown as SlotComponentType;
|
|
@@ -2,10 +2,8 @@ import SlotBase from "./Base";
|
|
|
2
2
|
import SlotText from "./Text";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Slot;
|
|
6
|
-
* @desc
|
|
7
|
-
* - `Slot.Base`: as 기반 polymorphic 마크업 래퍼다.
|
|
8
|
-
* - `Slot.Text`: 텍스트 children만 래핑하는 공통 슬롯이다.
|
|
5
|
+
* Slot; public markup namespace
|
|
6
|
+
* @desc Slot markup component의 public entry다.
|
|
9
7
|
*/
|
|
10
8
|
export const Slot = {
|
|
11
9
|
Base: SlotBase,
|