@uniai-fe/uds-primitives 0.12.0 → 0.12.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniai-fe/uds-primitives",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "UNIAI Design System; Primitives Components Package",
5
5
  "type": "module",
6
6
  "private": false,
@@ -89,8 +89,8 @@
89
89
  "typescript": "6.0.3",
90
90
  "@uniai-fe/eslint-config": "0.4.2",
91
91
  "@uniai-fe/next-devkit": "0.4.0",
92
- "@uniai-fe/util-functions": "0.4.3",
93
92
  "@uniai-fe/tsconfig": "0.2.0",
93
+ "@uniai-fe/util-functions": "0.4.3",
94
94
  "@uniai-fe/uds-foundation": "0.5.0"
95
95
  },
96
96
  "scripts": {
@@ -3,7 +3,7 @@
3
3
  * @desc
4
4
  * - `Input.Base`, `Input.TextArea`: foundation control
5
5
  * - `Input.Text.*`: text scenario wrappers
6
- * - `Input.Date`, `Input.Address`, `Input.File`: category presets
6
+ * - `Input.Date`, `Input.Time`, `Input.Address`, `Input.File`: category presets
7
7
  * - hooks/utils/types는 별도 배럴로 함께 export한다
8
8
  */
9
9
  import "./index.scss";
@@ -23,20 +23,9 @@ import {
23
23
  toDisplayHour,
24
24
  } from "../../../time-picker/utils";
25
25
  import ClockIcon from "../../img/clock.svg";
26
- import type { InputTimeTemplateProps } from "../../types";
26
+ import type { InputTimeDraft, InputTimeTemplateProps } from "../../types";
27
27
  import InputTimeTrigger from "./Trigger";
28
28
 
29
- interface InputTimeDraftFields {
30
- hours: string;
31
- minutes: string;
32
- seconds: string;
33
- }
34
-
35
- interface InputTimeDraft {
36
- fields: InputTimeDraftFields;
37
- period: TimePickerPeriod;
38
- }
39
-
40
29
  const getInputTimeDraft = (
41
30
  value: string,
42
31
  format: "12h" | "24h",
@@ -1,67 +1,11 @@
1
1
  "use client";
2
2
 
3
3
  import clsx from "clsx";
4
- import type {
5
- ChangeEvent,
6
- ComponentPropsWithoutRef,
7
- FocusEvent,
8
- KeyboardEvent,
9
- MouseEvent,
10
- ReactNode,
11
- } from "react";
4
+ import type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent } from "react";
12
5
  import { forwardRef, useRef } from "react";
13
6
  import { Calendar } from "../../../calendar";
14
- import type {
15
- TimePickerFormat,
16
- TimePickerPeriod,
17
- TimePickerUnit,
18
- } from "../../../time-picker/types";
19
- import type { InputPriority, InputSize, InputState } from "../../types";
20
-
21
- interface InputTimeTriggerFields {
22
- hours: string;
23
- minutes: string;
24
- seconds: string;
25
- }
26
-
27
- interface InputTimeTriggerProps extends Omit<
28
- ComponentPropsWithoutRef<"div">,
29
- "onBlur" | "onFocus"
30
- > {
31
- fields: InputTimeTriggerFields;
32
- period: TimePickerPeriod;
33
- activeUnit: TimePickerUnit | null;
34
- priority: InputPriority;
35
- size: InputSize;
36
- state: InputState;
37
- format: TimePickerFormat;
38
- withSeconds: boolean;
39
- disabled: boolean;
40
- readOnly: boolean;
41
- icon: ReactNode;
42
- iconPosition: "left" | "right";
43
- iconLabel: string;
44
- hoursInputLabel: string;
45
- minutesInputLabel: string;
46
- secondsInputLabel: string;
47
- amPmInputLabel: string;
48
- hoursPlaceholder: string;
49
- minutesPlaceholder: string;
50
- secondsPlaceholder: string;
51
- onFieldChange: (unit: TimePickerUnit, value: string) => void;
52
- onFieldFocus: (
53
- unit: TimePickerUnit,
54
- event: FocusEvent<HTMLInputElement>,
55
- ) => void;
56
- onFieldBlur: (unit: TimePickerUnit) => void;
57
- onFieldKeyDown: (
58
- unit: TimePickerUnit,
59
- event: KeyboardEvent<HTMLInputElement>,
60
- ) => void;
61
- onPeriodChange: (period: TimePickerPeriod) => void;
62
- onStep: (amount: 1 | -1) => void;
63
- onRootBlur: (event: FocusEvent<HTMLDivElement>) => void;
64
- }
7
+ import type { TimePickerUnit } from "../../../time-picker/types";
8
+ import type { InputTimeTriggerProps } from "../../types";
65
9
 
66
10
  /**
67
11
  * Input Time trigger; 시·분·초 field와 focus 단위 stepper를 렌더한다.
@@ -1,6 +1,13 @@
1
1
  import "../../styles/time.scss";
2
2
  import InputTimeTemplate from "./Template";
3
+ import InputTimeTrigger from "./Trigger";
4
+
5
+ export const InputTimeDefault = {
6
+ Template: InputTimeTemplate,
7
+ };
3
8
 
4
9
  export const InputTime = {
5
10
  Template: InputTimeTemplate,
11
+ Default: InputTimeDefault,
12
+ Trigger: InputTimeTrigger,
6
13
  };
@@ -1,7 +1,16 @@
1
- import type { ComponentPropsWithoutRef, FocusEvent, ReactNode } from "react";
1
+ import type {
2
+ ComponentPropsWithoutRef,
3
+ FocusEvent,
4
+ KeyboardEvent,
5
+ ReactNode,
6
+ } from "react";
2
7
  import type { UseFormRegisterReturn } from "react-hook-form";
3
8
  import type { FormFieldWidth } from "../../form/types/props";
4
- import type { TimePickerFormat } from "../../time-picker/types";
9
+ import type {
10
+ TimePickerFormat,
11
+ TimePickerPeriod,
12
+ TimePickerUnit,
13
+ } from "../../time-picker/types";
5
14
  import type { InputPriority, InputSize, InputState } from "./foundation";
6
15
 
7
16
  /**
@@ -18,6 +27,199 @@ export type InputTimeHiddenInputProps = Omit<
18
27
  "type" | "value" | "defaultValue" | "name"
19
28
  >;
20
29
 
30
+ /**
31
+ * Input Time draft field 값.
32
+ * @property {string} hours 시 입력값
33
+ * @property {string} minutes 분 입력값
34
+ * @property {string} seconds 초 입력값
35
+ */
36
+ export interface InputTimeDraftFields {
37
+ /**
38
+ * 시 입력값.
39
+ */
40
+ hours: string;
41
+ /**
42
+ * 분 입력값.
43
+ */
44
+ minutes: string;
45
+ /**
46
+ * 초 입력값.
47
+ */
48
+ seconds: string;
49
+ }
50
+
51
+ /**
52
+ * Input Time 편집 중인 시간 값.
53
+ * @property {InputTimeDraftFields} fields 시·분·초 입력값
54
+ * @property {"am" | "pm"} period 오전·오후 구분
55
+ */
56
+ export interface InputTimeDraft {
57
+ /**
58
+ * 시·분·초 입력값.
59
+ */
60
+ fields: InputTimeDraftFields;
61
+ /**
62
+ * "am" | "pm".
63
+ */
64
+ period: TimePickerPeriod;
65
+ }
66
+
67
+ /**
68
+ * Input Time trigger field 값.
69
+ * @see InputTimeDraftFields
70
+ */
71
+ export type InputTimeTriggerFields = InputTimeDraftFields;
72
+
73
+ /**
74
+ * Input Time Trigger props.
75
+ * @property {InputTimeTriggerFields} fields 시·분·초 입력값
76
+ * @property {"am" | "pm"} period 오전·오후 구분
77
+ * @property {"hours" | "minutes" | "seconds" | null} activeUnit 현재 활성 단위
78
+ * @property {"primary" | "secondary" | "tertiary" | "table"} priority input priority
79
+ * @property {"small" | "medium" | "large"} size input size
80
+ * @property {"default" | "active" | "focused" | "success" | "error" | "disabled" | "loading"} state input state
81
+ * @property {"12h" | "24h"} format 표시 형식
82
+ * @property {boolean} withSeconds 초 field 노출 여부
83
+ * @property {boolean} disabled 비활성화 여부
84
+ * @property {boolean} readOnly 읽기 전용 여부
85
+ * @property {ReactNode} icon clock icon
86
+ * @property {"left" | "right"} iconPosition clock icon 위치
87
+ * @property {string} iconLabel clock icon 접근성 라벨
88
+ * @property {string} hoursInputLabel 시 input 접근성 라벨
89
+ * @property {string} minutesInputLabel 분 input 접근성 라벨
90
+ * @property {string} secondsInputLabel 초 input 접근성 라벨
91
+ * @property {string} amPmInputLabel 오전·오후 input 접근성 라벨
92
+ * @property {string} hoursPlaceholder 시 placeholder
93
+ * @property {string} minutesPlaceholder 분 placeholder
94
+ * @property {string} secondsPlaceholder 초 placeholder
95
+ * @property {(unit: "hours" | "minutes" | "seconds", value: string) => void} onFieldChange field 변경 핸들러
96
+ * @property {(unit: "hours" | "minutes" | "seconds", event: FocusEvent<HTMLInputElement>) => void} onFieldFocus field focus 핸들러
97
+ * @property {(unit: "hours" | "minutes" | "seconds") => void} onFieldBlur field blur 핸들러
98
+ * @property {(unit: "hours" | "minutes" | "seconds", event: KeyboardEvent<HTMLInputElement>) => void} onFieldKeyDown field keyboard 핸들러
99
+ * @property {(period: "am" | "pm") => void} onPeriodChange 오전·오후 변경 핸들러
100
+ * @property {(amount: 1 | -1) => void} onStep 활성 단위 증감 핸들러
101
+ * @property {(event: FocusEvent<HTMLDivElement>) => void} onRootBlur root blur 핸들러
102
+ */
103
+ export interface InputTimeTriggerProps extends Omit<
104
+ ComponentPropsWithoutRef<"div">,
105
+ "onBlur" | "onFocus"
106
+ > {
107
+ /**
108
+ * 시·분·초 입력값.
109
+ */
110
+ fields: InputTimeTriggerFields;
111
+ /**
112
+ * "am" | "pm".
113
+ */
114
+ period: TimePickerPeriod;
115
+ /**
116
+ * "hours" | "minutes" | "seconds" | null.
117
+ */
118
+ activeUnit: TimePickerUnit | null;
119
+ /**
120
+ * "primary" | "secondary" | "tertiary" | "table".
121
+ */
122
+ priority: InputPriority;
123
+ /**
124
+ * "small" | "medium" | "large".
125
+ */
126
+ size: InputSize;
127
+ /**
128
+ * "default" | "active" | "focused" | "success" | "error" | "disabled" | "loading".
129
+ */
130
+ state: InputState;
131
+ /**
132
+ * "12h" | "24h".
133
+ */
134
+ format: TimePickerFormat;
135
+ /**
136
+ * 초 field 노출 여부.
137
+ */
138
+ withSeconds: boolean;
139
+ /**
140
+ * 비활성화 여부.
141
+ */
142
+ disabled: boolean;
143
+ /**
144
+ * 읽기 전용 여부.
145
+ */
146
+ readOnly: boolean;
147
+ /**
148
+ * clock icon.
149
+ */
150
+ icon: ReactNode;
151
+ /**
152
+ * "left" | "right".
153
+ */
154
+ iconPosition: InputTimeIconPosition;
155
+ /**
156
+ * clock icon 접근성 라벨.
157
+ */
158
+ iconLabel: string;
159
+ /**
160
+ * 시 input 접근성 라벨.
161
+ */
162
+ hoursInputLabel: string;
163
+ /**
164
+ * 분 input 접근성 라벨.
165
+ */
166
+ minutesInputLabel: string;
167
+ /**
168
+ * 초 input 접근성 라벨.
169
+ */
170
+ secondsInputLabel: string;
171
+ /**
172
+ * 오전·오후 input 접근성 라벨.
173
+ */
174
+ amPmInputLabel: string;
175
+ /**
176
+ * 시 placeholder.
177
+ */
178
+ hoursPlaceholder: string;
179
+ /**
180
+ * 분 placeholder.
181
+ */
182
+ minutesPlaceholder: string;
183
+ /**
184
+ * 초 placeholder.
185
+ */
186
+ secondsPlaceholder: string;
187
+ /**
188
+ * field 변경 핸들러.
189
+ */
190
+ onFieldChange: (unit: TimePickerUnit, value: string) => void;
191
+ /**
192
+ * field focus 핸들러.
193
+ */
194
+ onFieldFocus: (
195
+ unit: TimePickerUnit,
196
+ event: FocusEvent<HTMLInputElement>,
197
+ ) => void;
198
+ /**
199
+ * field blur 핸들러.
200
+ */
201
+ onFieldBlur: (unit: TimePickerUnit) => void;
202
+ /**
203
+ * field keyboard 핸들러.
204
+ */
205
+ onFieldKeyDown: (
206
+ unit: TimePickerUnit,
207
+ event: KeyboardEvent<HTMLInputElement>,
208
+ ) => void;
209
+ /**
210
+ * 오전·오후 변경 핸들러.
211
+ */
212
+ onPeriodChange: (period: TimePickerPeriod) => void;
213
+ /**
214
+ * 활성 단위 증감 핸들러.
215
+ */
216
+ onStep: (amount: 1 | -1) => void;
217
+ /**
218
+ * root blur 핸들러.
219
+ */
220
+ onRootBlur: (event: FocusEvent<HTMLDivElement>) => void;
221
+ }
222
+
21
223
  /**
22
224
  * Input Time Template props.
23
225
  * 저장값은 24시간 `HH:mm` 또는 `HH:mm:ss` 문자열을 사용한다.
@@ -1,23 +1,5 @@
1
1
  import { Button } from "../../button";
2
-
3
- interface TimePickerFooterProps {
4
- /**
5
- * 삭제 action 노출 여부.
6
- */
7
- clearable: boolean;
8
- /**
9
- * 비활성화 여부.
10
- */
11
- disabled: boolean;
12
- /**
13
- * 삭제 핸들러.
14
- */
15
- onClear: () => void;
16
- /**
17
- * 적용 핸들러.
18
- */
19
- onApply: () => void;
20
- }
2
+ import type { TimePickerFooterProps } from "../types";
21
3
 
22
4
  /**
23
5
  * TimePicker Footer; 삭제와 적용 action을 렌더한다.
@@ -1,5 +1,5 @@
1
1
  import { SegmentedControl } from "../../segmented-control";
2
- import type { TimePickerFormat, TimePickerPeriod } from "../types";
2
+ import type { TimePickerHourSectionProps } from "../types";
3
3
 
4
4
  const HOURS_12 = Array.from({ length: 12 }, (_, index) => index + 1);
5
5
  const HOURS_24 = Array.from({ length: 24 }, (_, index) => index);
@@ -8,33 +8,6 @@ const PERIOD_OPTIONS = [
8
8
  { value: "pm", label: "오후" },
9
9
  ];
10
10
 
11
- interface TimePickerHourSectionProps {
12
- /**
13
- * "12h" | "24h".
14
- */
15
- format: TimePickerFormat;
16
- /**
17
- * 선택한 표시 시.
18
- */
19
- selectedHour: number | null;
20
- /**
21
- * "am" | "pm".
22
- */
23
- period: TimePickerPeriod;
24
- /**
25
- * 비활성화 여부.
26
- */
27
- disabled: boolean;
28
- /**
29
- * 시 선택 핸들러.
30
- */
31
- onHourSelect: (hours: number) => void;
32
- /**
33
- * 오전·오후 변경 핸들러.
34
- */
35
- onPeriodChange: (period: TimePickerPeriod) => void;
36
- }
37
-
38
11
  /**
39
12
  * TimePicker Hour Section; 오전·오후와 시 선택 grid를 렌더한다.
40
13
  * @component
@@ -1,27 +1,9 @@
1
1
  import MinusIcon from "../img/minus.svg";
2
2
  import PlusIcon from "../img/plus.svg";
3
+ import type { TimePickerMinuteSectionProps } from "../types";
3
4
 
4
5
  const MINUTES = Array.from({ length: 12 }, (_, index) => index * 5);
5
6
 
6
- interface TimePickerMinuteSectionProps {
7
- /**
8
- * 선택한 분.
9
- */
10
- selectedMinute: number | null;
11
- /**
12
- * 비활성화 여부.
13
- */
14
- disabled: boolean;
15
- /**
16
- * 1분 증감 핸들러.
17
- */
18
- onMinuteStep: (amount: 1 | -1) => void;
19
- /**
20
- * 분 선택 핸들러.
21
- */
22
- onMinuteSelect: (minutes: number) => void;
23
- }
24
-
25
7
  /**
26
8
  * TimePicker Minute Section; 1분 stepper와 5분 선택 grid를 렌더한다.
27
9
  * @component
@@ -1,9 +1,4 @@
1
- interface TimePickerSummaryProps {
2
- /**
3
- * 선택한 시간 표시값.
4
- */
5
- summary: string;
6
- }
1
+ import type { TimePickerSummaryProps } from "../types";
7
2
 
8
3
  /**
9
4
  * TimePicker Summary; 현재 선택한 시간을 표시한다.
@@ -92,3 +92,102 @@ export interface TimePickerTemplateProps {
92
92
  */
93
93
  onApply: () => void;
94
94
  }
95
+
96
+ /**
97
+ * TimePicker Summary props.
98
+ * @property {string} summary 선택한 시간 표시값
99
+ */
100
+ export interface TimePickerSummaryProps {
101
+ /**
102
+ * 선택한 시간 표시값.
103
+ */
104
+ summary: string;
105
+ }
106
+
107
+ /**
108
+ * TimePicker Hour Section props.
109
+ * @property {"12h" | "24h"} format 표시 형식
110
+ * @property {number | null} selectedHour 선택한 표시 시
111
+ * @property {"am" | "pm"} period 오전·오후 구분
112
+ * @property {boolean} disabled 비활성화 여부
113
+ * @property {(hours: number) => void} onHourSelect 시 선택 핸들러
114
+ * @property {(period: "am" | "pm") => void} onPeriodChange 오전·오후 변경 핸들러
115
+ */
116
+ export interface TimePickerHourSectionProps {
117
+ /**
118
+ * "12h" | "24h".
119
+ */
120
+ format: TimePickerFormat;
121
+ /**
122
+ * 선택한 표시 시.
123
+ */
124
+ selectedHour: number | null;
125
+ /**
126
+ * "am" | "pm".
127
+ */
128
+ period: TimePickerPeriod;
129
+ /**
130
+ * 비활성화 여부.
131
+ */
132
+ disabled: boolean;
133
+ /**
134
+ * 시 선택 핸들러.
135
+ */
136
+ onHourSelect: (hours: number) => void;
137
+ /**
138
+ * 오전·오후 변경 핸들러.
139
+ */
140
+ onPeriodChange: (period: TimePickerPeriod) => void;
141
+ }
142
+
143
+ /**
144
+ * TimePicker Minute Section props.
145
+ * @property {number | null} selectedMinute 선택한 분
146
+ * @property {boolean} disabled 비활성화 여부
147
+ * @property {(amount: 1 | -1) => void} onMinuteStep 1분 증감 핸들러
148
+ * @property {(minutes: number) => void} onMinuteSelect 분 선택 핸들러
149
+ */
150
+ export interface TimePickerMinuteSectionProps {
151
+ /**
152
+ * 선택한 분.
153
+ */
154
+ selectedMinute: number | null;
155
+ /**
156
+ * 비활성화 여부.
157
+ */
158
+ disabled: boolean;
159
+ /**
160
+ * 1분 증감 핸들러.
161
+ */
162
+ onMinuteStep: (amount: 1 | -1) => void;
163
+ /**
164
+ * 분 선택 핸들러.
165
+ */
166
+ onMinuteSelect: (minutes: number) => void;
167
+ }
168
+
169
+ /**
170
+ * TimePicker Footer props.
171
+ * @property {boolean} clearable 삭제 action 노출 여부
172
+ * @property {boolean} disabled 비활성화 여부
173
+ * @property {() => void} onClear 삭제 핸들러
174
+ * @property {() => void} onApply 적용 핸들러
175
+ */
176
+ export interface TimePickerFooterProps {
177
+ /**
178
+ * 삭제 action 노출 여부.
179
+ */
180
+ clearable: boolean;
181
+ /**
182
+ * 비활성화 여부.
183
+ */
184
+ disabled: boolean;
185
+ /**
186
+ * 삭제 핸들러.
187
+ */
188
+ onClear: () => void;
189
+ /**
190
+ * 적용 핸들러.
191
+ */
192
+ onApply: () => void;
193
+ }