@uniai-fe/uds-primitives 0.12.10 → 0.12.12
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/styles.css +11 -0
- package/package.json +4 -4
- package/src/components/input/markup/date/Template.tsx +6 -0
- package/src/components/input/markup/date/range/Template.tsx +11 -0
- package/src/components/input/markup/date/useHiddenDateRegister.ts +39 -0
- package/src/components/input/markup/time/Trigger.tsx +1 -0
- package/src/components/input/styles/time.scss +12 -0
package/dist/styles.css
CHANGED
|
@@ -4657,7 +4657,9 @@ figure.chip {
|
|
|
4657
4657
|
}
|
|
4658
4658
|
|
|
4659
4659
|
.input-time-period-field {
|
|
4660
|
+
flex: 0 1 var(--input-time-period-field-width);
|
|
4660
4661
|
width: var(--input-time-period-field-width);
|
|
4662
|
+
min-width: 0;
|
|
4661
4663
|
height: var(--input-time-field-height);
|
|
4662
4664
|
padding: 0;
|
|
4663
4665
|
border: 0;
|
|
@@ -4728,6 +4730,15 @@ figure.chip {
|
|
|
4728
4730
|
border-radius: var(--input-time-radius) 0 0 var(--input-time-radius);
|
|
4729
4731
|
}
|
|
4730
4732
|
|
|
4733
|
+
.input-time:where([data-active-unit][data-format="12h"])
|
|
4734
|
+
.input-time-trigger-input {
|
|
4735
|
+
padding-inline: var(--spacing-padding-2);
|
|
4736
|
+
}
|
|
4737
|
+
.input-time:where([data-active-unit][data-format="12h"])
|
|
4738
|
+
.input-time-icon-button {
|
|
4739
|
+
margin-left: var(--spacing-gap-2);
|
|
4740
|
+
}
|
|
4741
|
+
|
|
4731
4742
|
.input-time:where([data-size="small"]) {
|
|
4732
4743
|
--input-time-radius: var(--input-default-radius-small);
|
|
4733
4744
|
--input-time-stepper-button-height: calc(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniai-fe/uds-primitives",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.12",
|
|
4
4
|
"description": "UNIAI Design System; Primitives Components Package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"react-hook-form": "^7.86.0",
|
|
88
88
|
"sass": "^1.102.0",
|
|
89
89
|
"typescript": "6.0.3",
|
|
90
|
-
"@uniai-fe/eslint-config": "0.4.
|
|
90
|
+
"@uniai-fe/eslint-config": "0.4.4",
|
|
91
|
+
"@uniai-fe/util-functions": "0.4.3",
|
|
91
92
|
"@uniai-fe/tsconfig": "0.2.0",
|
|
92
|
-
"@uniai-fe/uds-foundation": "0.6.0",
|
|
93
93
|
"@uniai-fe/next-devkit": "0.4.1",
|
|
94
|
-
"@uniai-fe/
|
|
94
|
+
"@uniai-fe/uds-foundation": "0.6.0"
|
|
95
95
|
},
|
|
96
96
|
"scripts": {
|
|
97
97
|
"check:pre-commit": "pnpm --dir ../../.. run check:pre-commit",
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
} from "../../utils/date";
|
|
22
22
|
import InputDateFooterTemplate from "./footer/Template";
|
|
23
23
|
import InputDateTrigger from "./Trigger";
|
|
24
|
+
import useHiddenDateRegister from "./useHiddenDateRegister";
|
|
24
25
|
|
|
25
26
|
const INPUT_DATE_TABLE_FORMAT = "YY-MM-DD";
|
|
26
27
|
|
|
@@ -180,6 +181,10 @@ const InputDateTemplate = forwardRef<HTMLDivElement, InputCalendarProps>(
|
|
|
180
181
|
[calendarValue, priority],
|
|
181
182
|
);
|
|
182
183
|
const serializedCalendarValue = serializeCalendarValue(calendarValue);
|
|
184
|
+
const hiddenInputRef = useHiddenDateRegister(
|
|
185
|
+
serializedCalendarValue,
|
|
186
|
+
register,
|
|
187
|
+
);
|
|
183
188
|
|
|
184
189
|
/**
|
|
185
190
|
* Input Date Template; trigger click 위임 함수.
|
|
@@ -294,6 +299,7 @@ const InputDateTemplate = forwardRef<HTMLDivElement, InputCalendarProps>(
|
|
|
294
299
|
name={register?.name ?? name}
|
|
295
300
|
form={form ?? hiddenInputProps?.form}
|
|
296
301
|
required={required ?? hiddenInputProps?.required}
|
|
302
|
+
ref={hiddenInputRef}
|
|
297
303
|
/>
|
|
298
304
|
)}
|
|
299
305
|
</>
|
|
@@ -26,6 +26,7 @@ import InputDateTodayButton from "../button/TodayButton";
|
|
|
26
26
|
import InputDateFooterTemplateContainer from "../footer/Container";
|
|
27
27
|
import InputDateFooterUtilContainer from "../footer/UtilContainer";
|
|
28
28
|
import InputDateTrigger from "../Trigger";
|
|
29
|
+
import useHiddenDateRegister from "../useHiddenDateRegister";
|
|
29
30
|
|
|
30
31
|
const INPUT_DATE_RANGE_TABLE_FORMAT = "YY-MM-DD";
|
|
31
32
|
|
|
@@ -212,6 +213,14 @@ const InputDateRangeTemplate = forwardRef<HTMLElement, InputCalendarRangeProps>(
|
|
|
212
213
|
);
|
|
213
214
|
const serializedStartValue = serializeCalendarValue(calendarValue[0]);
|
|
214
215
|
const serializedEndValue = serializeCalendarValue(calendarValue[1]);
|
|
216
|
+
const startHiddenInputRef = useHiddenDateRegister(
|
|
217
|
+
serializedStartValue,
|
|
218
|
+
startRegister,
|
|
219
|
+
);
|
|
220
|
+
const endHiddenInputRef = useHiddenDateRegister(
|
|
221
|
+
serializedEndValue,
|
|
222
|
+
endRegister,
|
|
223
|
+
);
|
|
215
224
|
|
|
216
225
|
/**
|
|
217
226
|
* Input Date Range Template; trigger click 위임 함수.
|
|
@@ -348,6 +357,7 @@ const InputDateRangeTemplate = forwardRef<HTMLElement, InputCalendarRangeProps>(
|
|
|
348
357
|
name={startRegister?.name ?? startName}
|
|
349
358
|
form={form ?? startHiddenInputProps?.form}
|
|
350
359
|
required={required ?? startHiddenInputProps?.required}
|
|
360
|
+
ref={startHiddenInputRef}
|
|
351
361
|
/>
|
|
352
362
|
)}
|
|
353
363
|
{(endRegister?.name || endName) && (
|
|
@@ -360,6 +370,7 @@ const InputDateRangeTemplate = forwardRef<HTMLElement, InputCalendarRangeProps>(
|
|
|
360
370
|
name={endRegister?.name ?? endName}
|
|
361
371
|
form={form ?? endHiddenInputProps?.form}
|
|
362
372
|
required={required ?? endHiddenInputProps?.required}
|
|
373
|
+
ref={endHiddenInputRef}
|
|
363
374
|
/>
|
|
364
375
|
)}
|
|
365
376
|
</>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ChangeEvent } from "react";
|
|
2
|
+
import { useLayoutEffect, useRef } from "react";
|
|
3
|
+
import type { UseFormRegisterReturn } from "react-hook-form";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Input.Date hidden input의 RHF 등록과 저장값 동기화.
|
|
7
|
+
* @hook
|
|
8
|
+
* @param {string} value Calendar의 직렬화된 날짜 값
|
|
9
|
+
* @param {UseFormRegisterReturn | undefined} register RHF 필드 등록 결과
|
|
10
|
+
* @desc ref 연결 후 값이나 필드가 바뀔 때만 RHF change를 전달해 재렌더 반복을 막는다.
|
|
11
|
+
* @return {(node: HTMLInputElement | null) => void} hidden input ref callback
|
|
12
|
+
*/
|
|
13
|
+
export default function useHiddenDateRegister(
|
|
14
|
+
value: string,
|
|
15
|
+
register?: UseFormRegisterReturn,
|
|
16
|
+
) {
|
|
17
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
18
|
+
const onChange = register?.onChange;
|
|
19
|
+
const registerName = register?.name;
|
|
20
|
+
|
|
21
|
+
useLayoutEffect(() => {
|
|
22
|
+
const node = inputRef.current;
|
|
23
|
+
if (!node || !onChange) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// RHF ref가 form default를 적용한 뒤 Calendar 값을 저장한다.
|
|
27
|
+
node.value = value;
|
|
28
|
+
void onChange({
|
|
29
|
+
target: node,
|
|
30
|
+
currentTarget: node,
|
|
31
|
+
type: "change",
|
|
32
|
+
} as unknown as ChangeEvent<HTMLInputElement>);
|
|
33
|
+
}, [value, registerName, onChange]);
|
|
34
|
+
|
|
35
|
+
return (node: HTMLInputElement | null) => {
|
|
36
|
+
register?.ref(node);
|
|
37
|
+
inputRef.current = node;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -126,6 +126,7 @@ const InputTimeTrigger = forwardRef<HTMLDivElement, InputTimeTriggerProps>(
|
|
|
126
126
|
data-state={state}
|
|
127
127
|
data-readonly={readOnly ? "true" : undefined}
|
|
128
128
|
data-active-unit={activeUnit ?? undefined}
|
|
129
|
+
data-format={format}
|
|
129
130
|
data-icon-position={iconPosition}
|
|
130
131
|
onBlur={onRootBlur}
|
|
131
132
|
onClick={onRootClick}
|
|
@@ -85,7 +85,9 @@
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
.input-time-period-field {
|
|
88
|
+
flex: 0 1 var(--input-time-period-field-width);
|
|
88
89
|
width: var(--input-time-period-field-width);
|
|
90
|
+
min-width: 0;
|
|
89
91
|
height: var(--input-time-field-height);
|
|
90
92
|
padding: 0;
|
|
91
93
|
border: 0;
|
|
@@ -160,6 +162,16 @@
|
|
|
160
162
|
border-radius: var(--input-time-radius) 0 0 var(--input-time-radius);
|
|
161
163
|
}
|
|
162
164
|
|
|
165
|
+
.input-time:where([data-active-unit][data-format="12h"]) {
|
|
166
|
+
.input-time-trigger-input {
|
|
167
|
+
padding-inline: var(--spacing-padding-2);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.input-time-icon-button {
|
|
171
|
+
margin-left: var(--spacing-gap-2);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
163
175
|
.input-time:where([data-size="small"]) {
|
|
164
176
|
--input-time-radius: var(--input-default-radius-small);
|
|
165
177
|
--input-time-stepper-button-height: calc(
|