@x-plat/design-system 0.10.0 → 0.12.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.
- package/dist/components/AutoResizeTextArea/index.cjs +14 -5
- package/dist/components/AutoResizeTextArea/index.css +15 -0
- package/dist/components/AutoResizeTextArea/index.d.cts +4 -0
- package/dist/components/AutoResizeTextArea/index.d.ts +4 -0
- package/dist/components/AutoResizeTextArea/index.js +14 -5
- package/dist/components/Badge/index.d.cts +1 -1
- package/dist/components/Badge/index.d.ts +1 -1
- package/dist/components/ChatInput/index.cjs +20 -7
- package/dist/components/ChatInput/index.css +15 -0
- package/dist/components/ChatInput/index.d.cts +4 -0
- package/dist/components/ChatInput/index.d.ts +4 -0
- package/dist/components/ChatInput/index.js +20 -7
- package/dist/components/CheckBox/index.cjs +8 -3
- package/dist/components/CheckBox/index.css +15 -0
- package/dist/components/CheckBox/index.d.cts +1 -1
- package/dist/components/CheckBox/index.d.ts +1 -1
- package/dist/components/CheckBox/index.js +8 -3
- package/dist/components/DatePicker/index.cjs +179 -64
- package/dist/components/DatePicker/index.css +19 -0
- package/dist/components/DatePicker/index.js +179 -64
- package/dist/components/Drawer/index.cjs +83 -4
- package/dist/components/Drawer/index.js +83 -4
- package/dist/components/Dropdown/index.cjs +57 -16
- package/dist/components/Dropdown/index.css +3 -0
- package/dist/components/Dropdown/index.js +57 -16
- package/dist/components/Editor/index.cjs +779 -50
- package/dist/components/Editor/index.css +100 -0
- package/dist/components/Editor/index.d.cts +1 -1
- package/dist/components/Editor/index.d.ts +1 -1
- package/dist/components/Editor/index.js +779 -50
- package/dist/components/FieldMessage/index.cjs +8 -3
- package/dist/components/FieldMessage/index.css +15 -0
- package/dist/components/FieldMessage/index.d.cts +11 -4
- package/dist/components/FieldMessage/index.d.ts +11 -4
- package/dist/components/FieldMessage/index.js +8 -3
- package/dist/components/FileUpload/index.cjs +8 -3
- package/dist/components/FileUpload/index.css +15 -0
- package/dist/components/FileUpload/index.js +8 -3
- package/dist/components/ImageSelector/index.cjs +8 -3
- package/dist/components/ImageSelector/index.css +15 -0
- package/dist/components/ImageSelector/index.js +8 -3
- package/dist/components/Input/index.cjs +15 -5
- package/dist/components/Input/index.css +15 -0
- package/dist/components/Input/index.d.cts +4 -0
- package/dist/components/Input/index.d.ts +4 -0
- package/dist/components/Input/index.js +15 -5
- package/dist/components/Modal/index.cjs +84 -5
- package/dist/components/Modal/index.js +84 -5
- package/dist/components/NotificationBadge/index.d.cts +1 -1
- package/dist/components/NotificationBadge/index.d.ts +1 -1
- package/dist/components/Pagination/index.d.cts +1 -1
- package/dist/components/Pagination/index.d.ts +1 -1
- package/dist/components/PopOver/index.cjs +55 -13
- package/dist/components/PopOver/index.css +3 -0
- package/dist/components/PopOver/index.js +55 -13
- package/dist/components/Progress/index.d.cts +1 -1
- package/dist/components/Progress/index.d.ts +1 -1
- package/dist/components/Radio/index.cjs +8 -3
- package/dist/components/Radio/index.css +15 -0
- package/dist/components/Radio/index.d.cts +1 -1
- package/dist/components/Radio/index.d.ts +1 -1
- package/dist/components/Radio/index.js +8 -3
- package/dist/components/Select/index.cjs +120 -39
- package/dist/components/Select/index.css +57 -0
- package/dist/components/Select/index.d.cts +11 -0
- package/dist/components/Select/index.d.ts +11 -0
- package/dist/components/Select/index.js +120 -39
- package/dist/components/Spinner/index.d.cts +1 -1
- package/dist/components/Spinner/index.d.ts +1 -1
- package/dist/components/Stat/index.cjs +84 -0
- package/dist/components/Stat/index.css +96 -0
- package/dist/components/Stat/index.d.cts +37 -0
- package/dist/components/Stat/index.d.ts +37 -0
- package/dist/components/Stat/index.js +57 -0
- package/dist/components/Steps/index.d.cts +1 -1
- package/dist/components/Steps/index.d.ts +1 -1
- package/dist/components/Switch/index.cjs +14 -5
- package/dist/components/Switch/index.css +15 -0
- package/dist/components/Switch/index.d.cts +6 -1
- package/dist/components/Switch/index.d.ts +6 -1
- package/dist/components/Switch/index.js +14 -5
- package/dist/components/Tab/index.cjs +49 -25
- package/dist/components/Tab/index.css +4 -0
- package/dist/components/Tab/index.js +49 -25
- package/dist/components/TextArea/index.cjs +14 -4
- package/dist/components/TextArea/index.css +15 -0
- package/dist/components/TextArea/index.d.cts +4 -0
- package/dist/components/TextArea/index.d.ts +4 -0
- package/dist/components/TextArea/index.js +14 -4
- package/dist/components/TimePicker/index.cjs +461 -0
- package/dist/components/TimePicker/index.css +175 -0
- package/dist/components/TimePicker/index.d.cts +42 -0
- package/dist/components/TimePicker/index.d.ts +42 -0
- package/dist/components/TimePicker/index.js +424 -0
- package/dist/components/index.cjs +1500 -398
- package/dist/components/index.css +385 -0
- package/dist/components/index.d.cts +3 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +1498 -398
- package/dist/index.cjs +1524 -422
- package/dist/index.css +385 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1522 -422
- package/dist/status-njWqQWFV.d.cts +20 -0
- package/dist/status-njWqQWFV.d.ts +20 -0
- package/guidelines/AGENT_PROMPT.md +3 -3
- package/guidelines/Guidelines.md +3 -0
- package/guidelines/components/editor.md +141 -0
- package/guidelines/components/form.md +19 -0
- package/guidelines/components/stat.md +31 -0
- package/guidelines/components/time-picker.md +49 -0
- package/package.json +1 -1
- package/dist/status-g_KP3qT6.d.cts +0 -8
- package/dist/status-g_KP3qT6.d.ts +0 -8
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { V as Validation } from '../../validation-Dqo1zqhT.js';
|
|
4
|
+
|
|
5
|
+
type TimePickerSize = "sm" | "md" | "lg";
|
|
6
|
+
interface TimePickerProps {
|
|
7
|
+
/** `"HH:mm"` 24시간 표기. 비어 있으면 placeholder 가 보인다 */
|
|
8
|
+
value?: string;
|
|
9
|
+
/** 시각을 고르면 `"HH:mm"` 로 준다 */
|
|
10
|
+
onChange?: (value: string) => void;
|
|
11
|
+
/** 목록 간격(분). 기본 30 — 30이면 하루 48개가 나온다 */
|
|
12
|
+
step?: number;
|
|
13
|
+
/** 고를 수 있는 가장 이른 시각 `"HH:mm"` */
|
|
14
|
+
min?: string;
|
|
15
|
+
/** 고를 수 있는 가장 늦은 시각 `"HH:mm"` */
|
|
16
|
+
max?: string;
|
|
17
|
+
/** 오전/오후 12시간 표기로 보여준다. onChange 는 그대로 24시간 `"HH:mm"` */
|
|
18
|
+
use12Hours?: boolean;
|
|
19
|
+
/** 비어 있을 때 표시할 안내 글자 */
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
size?: TimePickerSize;
|
|
23
|
+
/** 컨트롤 위에 붙는 라벨. 클릭하면 컨트롤에 포커스가 간다 */
|
|
24
|
+
label?: React.ReactNode;
|
|
25
|
+
/** 라벨 뒤에 필수 표시(*)를 붙인다 */
|
|
26
|
+
required?: boolean;
|
|
27
|
+
/** 컨트롤 아래에 표시할 검증 메시지. DS 폼 컴포넌트 공통 */
|
|
28
|
+
validations?: Validation[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 시각을 고르는 드롭다운.
|
|
32
|
+
*
|
|
33
|
+
* `DatePicker` 는 날짜 전용이다. 날짜와 시각이 함께 필요하면 둘을 나란히 두고
|
|
34
|
+
* 호출부에서 합친다 — `DatePicker` 에 시간을 끼워 넣으면 하위 4종의 날짜 전용
|
|
35
|
+
* 비교 로직을 전부 건드려야 해서 기존 사용처가 깨질 위험이 크다.
|
|
36
|
+
*/
|
|
37
|
+
declare const TimePicker: {
|
|
38
|
+
(props: TimePickerProps): react_jsx_runtime.JSX.Element;
|
|
39
|
+
displayName: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { TimePicker };
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
// src/components/TimePicker/TimePicker.tsx
|
|
2
|
+
import React4 from "react";
|
|
3
|
+
|
|
4
|
+
// src/tokens/hooks/Portal.tsx
|
|
5
|
+
import ReactDOM from "react-dom";
|
|
6
|
+
var Portal = ({ children }) => {
|
|
7
|
+
if (typeof document === "undefined") return null;
|
|
8
|
+
return ReactDOM.createPortal(children, document.body);
|
|
9
|
+
};
|
|
10
|
+
Portal.displayName = "Portal";
|
|
11
|
+
var Portal_default = Portal;
|
|
12
|
+
|
|
13
|
+
// src/tokens/hooks/useAutoPosition.ts
|
|
14
|
+
import React from "react";
|
|
15
|
+
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
16
|
+
const [position, setPosition] = React.useState({
|
|
17
|
+
position: {},
|
|
18
|
+
direction: "bottom",
|
|
19
|
+
repositioning: false
|
|
20
|
+
});
|
|
21
|
+
const placedRef = React.useRef(false);
|
|
22
|
+
const calculatePosition = React.useCallback(() => {
|
|
23
|
+
if (!triggerRef.current || !popRef.current) return;
|
|
24
|
+
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
25
|
+
const popW = popRef.current.offsetWidth;
|
|
26
|
+
const popH = popRef.current.offsetHeight;
|
|
27
|
+
const viewportHeight = window.innerHeight;
|
|
28
|
+
const viewportWidth = window.innerWidth;
|
|
29
|
+
if (popH === 0 || popW === 0) return;
|
|
30
|
+
let direction = "bottom";
|
|
31
|
+
let top;
|
|
32
|
+
let left;
|
|
33
|
+
if (triggerRect.bottom + popH > viewportHeight && triggerRect.top - popH > 0) {
|
|
34
|
+
direction = "top";
|
|
35
|
+
top = triggerRect.top - popH;
|
|
36
|
+
} else {
|
|
37
|
+
top = triggerRect.bottom;
|
|
38
|
+
}
|
|
39
|
+
left = triggerRect.left;
|
|
40
|
+
if (left + popW > viewportWidth - 8) {
|
|
41
|
+
left = triggerRect.right - popW;
|
|
42
|
+
}
|
|
43
|
+
if (left < 8) left = 8;
|
|
44
|
+
setPosition({
|
|
45
|
+
position: { top, left },
|
|
46
|
+
direction,
|
|
47
|
+
repositioning: placedRef.current
|
|
48
|
+
});
|
|
49
|
+
placedRef.current = true;
|
|
50
|
+
}, [triggerRef, popRef]);
|
|
51
|
+
React.useLayoutEffect(() => {
|
|
52
|
+
if (!enabled) {
|
|
53
|
+
placedRef.current = false;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
calculatePosition();
|
|
57
|
+
const raf = requestAnimationFrame(calculatePosition);
|
|
58
|
+
return () => cancelAnimationFrame(raf);
|
|
59
|
+
}, [calculatePosition, enabled]);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
if (!enabled || !popRef.current) return;
|
|
62
|
+
const observer = new ResizeObserver(() => {
|
|
63
|
+
calculatePosition();
|
|
64
|
+
});
|
|
65
|
+
observer.observe(popRef.current);
|
|
66
|
+
return () => observer.disconnect();
|
|
67
|
+
}, [calculatePosition, enabled, popRef]);
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
if (!enabled) return;
|
|
70
|
+
let raf = 0;
|
|
71
|
+
const onScrollOrResize = () => {
|
|
72
|
+
cancelAnimationFrame(raf);
|
|
73
|
+
raf = requestAnimationFrame(calculatePosition);
|
|
74
|
+
};
|
|
75
|
+
window.addEventListener("resize", onScrollOrResize, { passive: true });
|
|
76
|
+
window.addEventListener("scroll", onScrollOrResize, { passive: true, capture: true });
|
|
77
|
+
return () => {
|
|
78
|
+
cancelAnimationFrame(raf);
|
|
79
|
+
window.removeEventListener("resize", onScrollOrResize);
|
|
80
|
+
window.removeEventListener("scroll", onScrollOrResize, true);
|
|
81
|
+
};
|
|
82
|
+
}, [calculatePosition, enabled]);
|
|
83
|
+
return position;
|
|
84
|
+
};
|
|
85
|
+
var useAutoPosition_default = useAutoPosition;
|
|
86
|
+
|
|
87
|
+
// src/tokens/hooks/useClickOutside.ts
|
|
88
|
+
import React2 from "react";
|
|
89
|
+
var useClickOutside = (refs, handler, enabled = true) => {
|
|
90
|
+
React2.useEffect(() => {
|
|
91
|
+
if (!enabled) return;
|
|
92
|
+
const refArray = Array.isArray(refs) ? refs : [refs];
|
|
93
|
+
const listener = (event) => {
|
|
94
|
+
const target = event.target;
|
|
95
|
+
const isInside = refArray.some(
|
|
96
|
+
(ref) => ref.current && ref.current.contains(target)
|
|
97
|
+
);
|
|
98
|
+
if (!isInside) {
|
|
99
|
+
handler();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
document.addEventListener("mousedown", listener);
|
|
103
|
+
document.addEventListener("touchstart", listener);
|
|
104
|
+
return () => {
|
|
105
|
+
document.removeEventListener("mousedown", listener);
|
|
106
|
+
document.removeEventListener("touchstart", listener);
|
|
107
|
+
};
|
|
108
|
+
}, [refs, handler, enabled]);
|
|
109
|
+
};
|
|
110
|
+
var useClickOutside_default = useClickOutside;
|
|
111
|
+
|
|
112
|
+
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
113
|
+
import React3 from "react";
|
|
114
|
+
var FOCUSABLE = [
|
|
115
|
+
"a[href]",
|
|
116
|
+
"button:not([disabled])",
|
|
117
|
+
"input:not([disabled]):not([type='hidden'])",
|
|
118
|
+
"select:not([disabled])",
|
|
119
|
+
"textarea:not([disabled])",
|
|
120
|
+
"[tabindex]:not([tabindex='-1'])"
|
|
121
|
+
].join(",");
|
|
122
|
+
var useEscapeKey = (enabled, onEscape) => {
|
|
123
|
+
React3.useEffect(() => {
|
|
124
|
+
if (!enabled) return;
|
|
125
|
+
const onKey = (e) => {
|
|
126
|
+
if (e.key !== "Escape") return;
|
|
127
|
+
if (e.defaultPrevented) return;
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
onEscape();
|
|
130
|
+
};
|
|
131
|
+
document.addEventListener("keydown", onKey);
|
|
132
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
133
|
+
}, [enabled, onEscape]);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// ../../node_modules/clsx/dist/clsx.mjs
|
|
137
|
+
function r(e) {
|
|
138
|
+
var t, f, n = "";
|
|
139
|
+
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
140
|
+
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
141
|
+
var o = e.length;
|
|
142
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
143
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
144
|
+
return n;
|
|
145
|
+
}
|
|
146
|
+
function clsx() {
|
|
147
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
148
|
+
return n;
|
|
149
|
+
}
|
|
150
|
+
var clsx_default = clsx;
|
|
151
|
+
|
|
152
|
+
// src/tokens/svg/status/ErrorIcon.tsx
|
|
153
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
154
|
+
var ErrorIcon = () => /* @__PURE__ */ jsxs(
|
|
155
|
+
"svg",
|
|
156
|
+
{
|
|
157
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
158
|
+
width: "1em",
|
|
159
|
+
height: "1em",
|
|
160
|
+
viewBox: "0 0 16 16",
|
|
161
|
+
fill: "none",
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ jsxs("g", { clipPath: "url(#clip0_1196_9603)", children: [
|
|
164
|
+
/* @__PURE__ */ jsx(
|
|
165
|
+
"path",
|
|
166
|
+
{
|
|
167
|
+
d: "M9.57588 5.57559C9.81019 5.34127 10.19 5.34127 10.4243 5.57559C10.6586 5.8099 10.6586 6.18971 10.4243 6.42402L8.84854 7.9998L10.4243 9.57559C10.6586 9.8099 10.6586 10.1897 10.4243 10.424C10.19 10.6583 9.81019 10.6583 9.57588 10.424L8.0001 8.84824L6.42432 10.424C6.19 10.6583 5.81019 10.6583 5.57588 10.424C5.34156 10.1897 5.34156 9.8099 5.57588 9.57559L7.15166 7.9998L5.57588 6.42402C5.34156 6.18971 5.34156 5.8099 5.57588 5.57559C5.81019 5.34127 6.19 5.34127 6.42432 5.57559L8.0001 7.15137L9.57588 5.57559Z",
|
|
168
|
+
fill: "currentColor"
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
/* @__PURE__ */ jsx(
|
|
172
|
+
"path",
|
|
173
|
+
{
|
|
174
|
+
fillRule: "evenodd",
|
|
175
|
+
clipRule: "evenodd",
|
|
176
|
+
d: "M8.0001 0.733398C12.0131 0.73361 15.2671 3.98679 15.2673 7.9998C15.2672 12.0129 12.0131 15.2668 8.0001 15.267C3.98701 15.2669 0.733016 12.0129 0.73291 7.9998C0.733051 3.98674 3.98704 0.733539 8.0001 0.733398ZM8.0001 1.9334C4.64978 1.93354 1.93383 4.64948 1.93369 7.9998C1.9338 11.3502 4.64975 14.0669 8.0001 14.067C11.3504 14.0668 14.0672 11.3501 14.0673 7.9998C14.0671 4.64953 11.3504 1.93361 8.0001 1.9334Z",
|
|
177
|
+
fill: "currentColor"
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] }),
|
|
181
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: "clip0_1196_9603", children: /* @__PURE__ */ jsx("rect", { width: "16", height: "16", fill: "white" }) }) })
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
var ErrorIcon_default = ErrorIcon;
|
|
186
|
+
|
|
187
|
+
// src/tokens/svg/status/InfoIcon.tsx
|
|
188
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
189
|
+
var InfoIcon = () => /* @__PURE__ */ jsxs2(
|
|
190
|
+
"svg",
|
|
191
|
+
{
|
|
192
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
193
|
+
width: "1em",
|
|
194
|
+
height: "1em",
|
|
195
|
+
viewBox: "0 0 16 16",
|
|
196
|
+
fill: "none",
|
|
197
|
+
children: [
|
|
198
|
+
/* @__PURE__ */ jsxs2("g", { clipPath: "url(#clip0_1188_11261)", children: [
|
|
199
|
+
/* @__PURE__ */ jsx2(
|
|
200
|
+
"path",
|
|
201
|
+
{
|
|
202
|
+
d: "M8.00156 7.39999C8.33293 7.39999 8.60156 7.66862 8.60156 7.99999V10.6664C8.60156 10.9978 8.33293 11.2664 8.00156 11.2664C7.67019 11.2664 7.40156 10.9978 7.40156 10.6664V7.99999C7.40156 7.66862 7.67019 7.39999 8.00156 7.39999Z",
|
|
203
|
+
fill: "currentColor"
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
/* @__PURE__ */ jsx2(
|
|
207
|
+
"path",
|
|
208
|
+
{
|
|
209
|
+
d: "M8.00859 4.73358C8.3398 4.73378 8.60859 5.00233 8.60859 5.33358C8.60849 5.66474 8.33973 5.93338 8.00859 5.93358H8.00156C7.67026 5.93358 7.40167 5.66486 7.40156 5.33358C7.40156 5.00221 7.67019 4.73358 8.00156 4.73358H8.00859Z",
|
|
210
|
+
fill: "currentColor"
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
/* @__PURE__ */ jsx2(
|
|
214
|
+
"path",
|
|
215
|
+
{
|
|
216
|
+
fillRule: "evenodd",
|
|
217
|
+
clipRule: "evenodd",
|
|
218
|
+
d: "M8.00156 0.733582C12.0146 0.733793 15.2686 3.98697 15.2688 7.99999C15.2686 12.013 12.0146 15.267 8.00156 15.2672C3.98848 15.267 0.734481 12.0131 0.734375 7.99999C0.734516 3.98693 3.9885 0.733722 8.00156 0.733582ZM8.00156 1.93358C4.65124 1.93372 1.9353 4.64967 1.93516 7.99999C1.93526 11.3503 4.65122 14.067 8.00156 14.0672C11.3518 14.067 14.0686 11.3503 14.0688 7.99999C14.0686 4.64971 11.3518 1.93379 8.00156 1.93358Z",
|
|
219
|
+
fill: "currentColor"
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
] }),
|
|
223
|
+
/* @__PURE__ */ jsx2("defs", { children: /* @__PURE__ */ jsx2("clipPath", { id: "clip0_1188_11261", children: /* @__PURE__ */ jsx2("rect", { width: "16", height: "16", fill: "white" }) }) })
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
var InfoIcon_default = InfoIcon;
|
|
228
|
+
|
|
229
|
+
// src/tokens/svg/status/SuccessIcon.tsx
|
|
230
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
231
|
+
var SuccessIcon = () => /* @__PURE__ */ jsx3(
|
|
232
|
+
"svg",
|
|
233
|
+
{
|
|
234
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
235
|
+
width: "1em",
|
|
236
|
+
height: "1em",
|
|
237
|
+
viewBox: "0 0 16 16",
|
|
238
|
+
fill: "none",
|
|
239
|
+
children: /* @__PURE__ */ jsx3(
|
|
240
|
+
"path",
|
|
241
|
+
{
|
|
242
|
+
d: "M12.9084 3.57597C13.1426 3.34172 13.5225 3.34185 13.7568 3.57597C13.9911 3.81028 13.9911 4.19009 13.7568 4.4244L6.424 11.758C6.31157 11.8703 6.15869 11.9337 5.99978 11.9338C5.8409 11.9337 5.68798 11.8703 5.57556 11.758L2.24197 8.4244C2.00782 8.19018 2.00795 7.81028 2.24197 7.57597C2.47626 7.34167 2.85609 7.34172 3.09041 7.57597L5.999 10.4846L12.9084 3.57597Z",
|
|
243
|
+
fill: "currentColor"
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
var SuccessIcon_default = SuccessIcon;
|
|
249
|
+
|
|
250
|
+
// src/components/FieldMessage/FieldMessage.tsx
|
|
251
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
252
|
+
var ICON = {
|
|
253
|
+
default: /* @__PURE__ */ jsx4(InfoIcon_default, {}),
|
|
254
|
+
success: /* @__PURE__ */ jsx4(SuccessIcon_default, {}),
|
|
255
|
+
warning: /* @__PURE__ */ jsx4(InfoIcon_default, {}),
|
|
256
|
+
error: /* @__PURE__ */ jsx4(ErrorIcon_default, {})
|
|
257
|
+
};
|
|
258
|
+
var FieldMessage = (props) => {
|
|
259
|
+
const { validations } = props;
|
|
260
|
+
if (!validations || validations.length === 0) return null;
|
|
261
|
+
return /* @__PURE__ */ jsx4("div", { className: "lib-xplat-field-message-wrap", children: validations.map((v, idx) => /* @__PURE__ */ jsxs3(
|
|
262
|
+
"div",
|
|
263
|
+
{
|
|
264
|
+
className: clsx_default("lib-xplat-field-message", v.status),
|
|
265
|
+
children: [
|
|
266
|
+
/* @__PURE__ */ jsx4("div", { className: "icon", children: ICON[v.status] }),
|
|
267
|
+
/* @__PURE__ */ jsx4("span", { children: v.message })
|
|
268
|
+
]
|
|
269
|
+
},
|
|
270
|
+
`${v.message}_${idx}`
|
|
271
|
+
)) });
|
|
272
|
+
};
|
|
273
|
+
FieldMessage.displayName = "FieldMessage";
|
|
274
|
+
var Field = (props) => {
|
|
275
|
+
const { label, required = false, htmlFor, validations, children } = props;
|
|
276
|
+
const hasMessages = !!validations && validations.length > 0;
|
|
277
|
+
if (!label && !hasMessages) return /* @__PURE__ */ jsx4(Fragment, { children });
|
|
278
|
+
return /* @__PURE__ */ jsxs3("div", { className: "lib-xplat-field", children: [
|
|
279
|
+
label && /* @__PURE__ */ jsxs3("label", { className: "lib-xplat-field-label", htmlFor, children: [
|
|
280
|
+
label,
|
|
281
|
+
required && /* @__PURE__ */ jsx4("span", { className: "required", "aria-hidden": "true", children: "*" })
|
|
282
|
+
] }),
|
|
283
|
+
children,
|
|
284
|
+
hasMessages && /* @__PURE__ */ jsx4(FieldMessage, { validations })
|
|
285
|
+
] });
|
|
286
|
+
};
|
|
287
|
+
Field.displayName = "Field";
|
|
288
|
+
var hasError = (validations) => !!validations?.some((v) => v.status === "error");
|
|
289
|
+
|
|
290
|
+
// src/components/TimePicker/TimePicker.tsx
|
|
291
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
292
|
+
var ANIMATION_DURATION_MS = 200;
|
|
293
|
+
var toMinutes = (hhmm) => {
|
|
294
|
+
if (!hhmm) return null;
|
|
295
|
+
const m = /^(\d{1,2}):(\d{2})$/.exec(hhmm.trim());
|
|
296
|
+
if (!m) return null;
|
|
297
|
+
const h = Number(m[1]);
|
|
298
|
+
const min = Number(m[2]);
|
|
299
|
+
if (h > 23 || min > 59) return null;
|
|
300
|
+
return h * 60 + min;
|
|
301
|
+
};
|
|
302
|
+
var toHHmm = (minutes) => `${String(Math.floor(minutes / 60)).padStart(2, "0")}:${String(minutes % 60).padStart(2, "0")}`;
|
|
303
|
+
var display = (hhmm, use12Hours) => {
|
|
304
|
+
if (!use12Hours) return hhmm;
|
|
305
|
+
const total = toMinutes(hhmm);
|
|
306
|
+
if (total === null) return hhmm;
|
|
307
|
+
const h24 = Math.floor(total / 60);
|
|
308
|
+
const mm = String(total % 60).padStart(2, "0");
|
|
309
|
+
const period = h24 < 12 ? "\uC624\uC804" : "\uC624\uD6C4";
|
|
310
|
+
const h12 = h24 % 12 === 0 ? 12 : h24 % 12;
|
|
311
|
+
return `${period} ${h12}:${mm}`;
|
|
312
|
+
};
|
|
313
|
+
var TimePicker = (props) => {
|
|
314
|
+
const {
|
|
315
|
+
value,
|
|
316
|
+
onChange,
|
|
317
|
+
step = 30,
|
|
318
|
+
min,
|
|
319
|
+
max,
|
|
320
|
+
use12Hours = false,
|
|
321
|
+
placeholder = "\uC2DC\uAC01 \uC120\uD0DD",
|
|
322
|
+
disabled = false,
|
|
323
|
+
size = "md",
|
|
324
|
+
label,
|
|
325
|
+
required,
|
|
326
|
+
validations
|
|
327
|
+
} = props;
|
|
328
|
+
const fieldId = React4.useId();
|
|
329
|
+
const triggerRef = React4.useRef(null);
|
|
330
|
+
const contentRef = React4.useRef(null);
|
|
331
|
+
const [isOpen, setOpen] = React4.useState(false);
|
|
332
|
+
const [mounted, setMounted] = React4.useState(false);
|
|
333
|
+
const [visible, setVisible] = React4.useState(false);
|
|
334
|
+
const options = React4.useMemo(() => {
|
|
335
|
+
const safeStep = step > 0 && step <= 720 ? step : 30;
|
|
336
|
+
const lo = toMinutes(min) ?? 0;
|
|
337
|
+
const hi = toMinutes(max) ?? 24 * 60 - 1;
|
|
338
|
+
const out = [];
|
|
339
|
+
for (let t = lo; t <= hi; t += safeStep) out.push(toHHmm(t));
|
|
340
|
+
return out;
|
|
341
|
+
}, [step, min, max]);
|
|
342
|
+
const close = React4.useCallback(() => setOpen(false), []);
|
|
343
|
+
useClickOutside_default([triggerRef, contentRef], close, isOpen);
|
|
344
|
+
useEscapeKey(isOpen, () => {
|
|
345
|
+
close();
|
|
346
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
347
|
+
});
|
|
348
|
+
const position = useAutoPosition_default(triggerRef, contentRef, mounted);
|
|
349
|
+
React4.useEffect(() => {
|
|
350
|
+
if (disabled && isOpen) setOpen(false);
|
|
351
|
+
}, [disabled, isOpen]);
|
|
352
|
+
React4.useEffect(() => {
|
|
353
|
+
if (isOpen) {
|
|
354
|
+
setMounted(true);
|
|
355
|
+
const t2 = setTimeout(() => setVisible(true), 1);
|
|
356
|
+
return () => clearTimeout(t2);
|
|
357
|
+
}
|
|
358
|
+
setVisible(false);
|
|
359
|
+
const t = setTimeout(() => setMounted(false), ANIMATION_DURATION_MS);
|
|
360
|
+
return () => clearTimeout(t);
|
|
361
|
+
}, [isOpen]);
|
|
362
|
+
const pick = (hhmm) => {
|
|
363
|
+
onChange?.(hhmm);
|
|
364
|
+
close();
|
|
365
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
366
|
+
};
|
|
367
|
+
const control = /* @__PURE__ */ jsxs4("div", { className: clsx_default("lib-xplat-time-picker", size, disabled && "disabled"), children: [
|
|
368
|
+
/* @__PURE__ */ jsx5(
|
|
369
|
+
"div",
|
|
370
|
+
{
|
|
371
|
+
id: fieldId,
|
|
372
|
+
ref: triggerRef,
|
|
373
|
+
className: clsx_default("time-picker-trigger", hasError(validations) && "error"),
|
|
374
|
+
role: "combobox",
|
|
375
|
+
"aria-expanded": isOpen,
|
|
376
|
+
"aria-haspopup": "listbox",
|
|
377
|
+
"aria-invalid": hasError(validations) || void 0,
|
|
378
|
+
tabIndex: disabled ? void 0 : 0,
|
|
379
|
+
onClick: () => !disabled && setOpen((p) => !p),
|
|
380
|
+
onKeyDown: (e) => {
|
|
381
|
+
if (disabled) return;
|
|
382
|
+
if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
|
|
383
|
+
e.preventDefault();
|
|
384
|
+
setOpen(true);
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
children: /* @__PURE__ */ jsx5("span", { className: clsx_default("time-picker-value", !value && "placeholder"), children: value ? display(value, use12Hours) : placeholder })
|
|
388
|
+
}
|
|
389
|
+
),
|
|
390
|
+
mounted && /* @__PURE__ */ jsx5(Portal_default, { children: /* @__PURE__ */ jsx5(
|
|
391
|
+
"div",
|
|
392
|
+
{
|
|
393
|
+
ref: contentRef,
|
|
394
|
+
className: clsx_default("lib-xplat-time-picker-content", size, visible ? "enter" : "exit", position.repositioning && "repositioning"),
|
|
395
|
+
style: { ...position.position, width: triggerRef.current?.offsetWidth },
|
|
396
|
+
role: "listbox",
|
|
397
|
+
children: options.map((t) => /* @__PURE__ */ jsx5(
|
|
398
|
+
"div",
|
|
399
|
+
{
|
|
400
|
+
className: clsx_default("time-picker-item", t === value && "is-selected"),
|
|
401
|
+
role: "option",
|
|
402
|
+
"aria-selected": t === value,
|
|
403
|
+
tabIndex: 0,
|
|
404
|
+
onClick: () => pick(t),
|
|
405
|
+
onKeyDown: (e) => {
|
|
406
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
407
|
+
e.preventDefault();
|
|
408
|
+
pick(t);
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
children: display(t, use12Hours)
|
|
412
|
+
},
|
|
413
|
+
t
|
|
414
|
+
))
|
|
415
|
+
}
|
|
416
|
+
) })
|
|
417
|
+
] });
|
|
418
|
+
return /* @__PURE__ */ jsx5(Field, { validations, label, required, htmlFor: fieldId, children: control });
|
|
419
|
+
};
|
|
420
|
+
TimePicker.displayName = "TimePicker";
|
|
421
|
+
var TimePicker_default = TimePicker;
|
|
422
|
+
export {
|
|
423
|
+
TimePicker_default as TimePicker
|
|
424
|
+
};
|