@pop-ui/core 2.2.3 → 2.2.5

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/core.css +1 -1
  3. package/dist/core.js +58 -3110
  4. package/dist/core.umd.cjs +3 -3
  5. package/dist/esm/components/Button/index.js +75 -0
  6. package/dist/esm/components/Button/style.js +9 -0
  7. package/dist/esm/components/Button/styles.module.scss.js +28 -0
  8. package/dist/esm/components/CalendarDatePicker/index.js +119 -0
  9. package/dist/esm/components/CalendarDatePicker/styles.module.scss.js +34 -0
  10. package/dist/esm/components/CalendarDatePicker/utils.js +82 -0
  11. package/dist/esm/components/Checkbox/index.js +32 -0
  12. package/dist/esm/components/Checkbox/styles.module.scss.js +9 -0
  13. package/dist/esm/components/DatePicker/index.js +203 -0
  14. package/dist/esm/components/DatePicker/styles.module.scss.js +57 -0
  15. package/dist/esm/components/Dropdown/index.js +61 -0
  16. package/dist/esm/components/Dropdown/styles.module.scss.js +21 -0
  17. package/dist/esm/components/ImageInput/ImageInputCropModal.js +91 -0
  18. package/dist/esm/components/ImageInput/helpers.js +46 -0
  19. package/dist/esm/components/ImageInput/index.js +379 -0
  20. package/dist/esm/components/ImageInput/styles.module.scss.js +30 -0
  21. package/dist/esm/components/LottieInput/helpers.js +48 -0
  22. package/dist/esm/components/LottieInput/index.js +233 -0
  23. package/dist/esm/components/LottieInput/styles.module.scss.js +14 -0
  24. package/dist/esm/components/Map/Map.js +48 -0
  25. package/dist/esm/components/Map/NaverMapContext.js +78 -0
  26. package/dist/esm/components/Map/markerClustering.js +305 -0
  27. package/dist/esm/components/Map/markerStyles.js +351 -0
  28. package/dist/esm/components/Map/useLocation.js +40 -0
  29. package/dist/esm/components/Map/useMap.js +95 -0
  30. package/dist/esm/components/MapInfo/index.js +120 -0
  31. package/dist/esm/components/MapInfo/styles.module.scss.js +24 -0
  32. package/dist/esm/components/Modal/index.js +52 -0
  33. package/dist/esm/components/Pagination/index.js +45 -0
  34. package/dist/esm/components/Pagination/style.module.scss.js +13 -0
  35. package/dist/esm/components/Radio/index.js +29 -0
  36. package/dist/esm/components/Radio/styles.module.scss.js +9 -0
  37. package/dist/esm/components/SearchBar/index.js +60 -0
  38. package/dist/esm/components/SearchBar/styles.module.scss.js +25 -0
  39. package/dist/esm/components/SegmentButton/index.js +25 -0
  40. package/dist/esm/components/SegmentButton/styles.module.scss.js +9 -0
  41. package/dist/esm/components/Tab/index.js +14 -0
  42. package/dist/esm/components/Tab/styles.module.scss.js +10 -0
  43. package/dist/esm/components/TextField/index.js +99 -0
  44. package/dist/esm/components/TextField/styles.module.scss.js +28 -0
  45. package/dist/esm/components/TimePicker/index.js +33 -0
  46. package/dist/esm/components/TimePicker/styles.module.scss.js +9 -0
  47. package/dist/esm/components/Toast/index.js +35 -0
  48. package/dist/esm/components/Toast/styles.module.scss.js +14 -0
  49. package/dist/esm/components/Toggle/index.js +48 -0
  50. package/dist/esm/components/Toggle/styles.module.scss.js +9 -0
  51. package/dist/esm/components/Tooltip/index.js +25 -0
  52. package/dist/esm/components/Tooltip/styles.module.scss.js +12 -0
  53. package/dist/esm/components/shared/MultiItemInput/Dropzone.js +30 -0
  54. package/dist/esm/components/shared/MultiItemInput/SortableEmptySlot.js +29 -0
  55. package/dist/esm/components/shared/MultiItemInput/TileShell.js +113 -0
  56. package/dist/esm/components/shared/MultiItemInput/helpers.js +23 -0
  57. package/dist/esm/components/shared/MultiItemInput/styles.module.scss.js +30 -0
  58. package/dist/esm/components/shared/MultiItemInput/usePositionGrid.js +49 -0
  59. package/dist/esm/components/shared/MultiItemInput/useSortableGrid.js +20 -0
  60. package/dist/esm/theme/ThemeProvider.js +46 -0
  61. package/dist/esm/theme/cssVariables.js +29 -0
  62. package/dist/esm/theme/mantineTheme.js +36 -0
  63. package/package.json +2 -2
@@ -0,0 +1,379 @@
1
+ "use client";
2
+ import { jsxs as f, jsx as r, Fragment as oe } from "react/jsx-runtime";
3
+ import { DndContext as le, closestCenter as ie } from "@dnd-kit/core";
4
+ import { SortableContext as se, rectSortingStrategy as ae } from "@dnd-kit/sortable";
5
+ import { Input as ce } from "@mantine/core";
6
+ import { IMAGE_MIME_TYPE as j } from "@mantine/dropzone";
7
+ import { IconPhoto as F, ColorRed700 as H, ColorAqua700 as L, IconX as de, ColorGray600 as ue, IconEdit as fe, IconOpenInFull as pe, ColorGray900 as me } from "@pop-ui/foundation";
8
+ import { useState as O, useRef as Y, useEffect as V } from "react";
9
+ import { Button as W } from "../Button/index.js";
10
+ import { Modal as Ie } from "../Modal/index.js";
11
+ import { revokeItemUrls as he, replaceItem as xe, deleteItem as ge, addItemAtPosition as be, addItems as ye, cropItem as Pe } from "./helpers.js";
12
+ import { ImageInputCropModal as ve } from "./ImageInputCropModal.js";
13
+ import s from "./styles.module.scss.js";
14
+ import { PlaceholderDropzone as q } from "../shared/MultiItemInput/Dropzone.js";
15
+ import { SortableEmptySlot as Ce } from "../shared/MultiItemInput/SortableEmptySlot.js";
16
+ import { TileShell as $e } from "../shared/MultiItemInput/TileShell.js";
17
+ import { usePositionGrid as we } from "../shared/MultiItemInput/usePositionGrid.js";
18
+ function J(e) {
19
+ if (!e) return !1;
20
+ try {
21
+ const l = new URL(e).protocol;
22
+ return l === "http:" || l === "https:";
23
+ } catch {
24
+ return !1;
25
+ }
26
+ }
27
+ function Ee(e) {
28
+ J(e) && window.open(e, "_blank", "noopener,noreferrer");
29
+ }
30
+ function Se(e) {
31
+ return e ? e.join(",") : "image/*";
32
+ }
33
+ function X({
34
+ item: e,
35
+ sortableId: l,
36
+ index: d,
37
+ totalCount: A,
38
+ width: h,
39
+ height: x,
40
+ accept: u,
41
+ canDelete: $,
42
+ hasLink: P,
43
+ hasEdit: w,
44
+ readOnly: g,
45
+ isLoading: b,
46
+ onLinkClick: v,
47
+ onDelete: B,
48
+ onReplace: C,
49
+ onEdit: y,
50
+ onPreview: c
51
+ }) {
52
+ const E = Y(null), S = v ? !!e.url : J(e.url);
53
+ return /* @__PURE__ */ f(
54
+ $e,
55
+ {
56
+ id: l ?? e.id,
57
+ totalCount: A,
58
+ width: h,
59
+ height: x,
60
+ readOnly: g,
61
+ isLoading: b,
62
+ itemIsLoading: e.isLoading,
63
+ canDelete: $,
64
+ isDragHandleOverlay: !0,
65
+ hasLink: P && S,
66
+ linkUrl: e.url,
67
+ onLinkClick: P && S ? () => v ? v(e) : e.url && Ee(e.url) : void 0,
68
+ onDelete: () => B(e.id),
69
+ deleteAriaLabel: "이미지 삭제",
70
+ onTileClick: () => E.current?.click(),
71
+ onFileDrop: (i) => {
72
+ if (u) {
73
+ if (!u.includes(i.type)) return;
74
+ } else if (!i.type.startsWith("image/")) return;
75
+ C(e.id, i);
76
+ },
77
+ children: [
78
+ /* @__PURE__ */ r(
79
+ "input",
80
+ {
81
+ ref: E,
82
+ type: "file",
83
+ accept: Se(u),
84
+ style: { display: "none" },
85
+ onChange: (i) => {
86
+ const D = i.target.files?.[0];
87
+ D && C(e.id, D), i.target.value = "";
88
+ }
89
+ }
90
+ ),
91
+ /* @__PURE__ */ f("div", { className: s.TileContent, children: [
92
+ /* @__PURE__ */ r(
93
+ "img",
94
+ {
95
+ src: e.url,
96
+ alt: e.file?.name ?? `이미지 ${d + 1}`,
97
+ className: s.TileImage
98
+ }
99
+ ),
100
+ w && !g && /* @__PURE__ */ r(
101
+ "button",
102
+ {
103
+ type: "button",
104
+ className: `${s.OverlayButton} ${s.OverlayButtonLeft}`,
105
+ "aria-label": "이미지 편집",
106
+ title: "편집",
107
+ disabled: b || e.isLoading,
108
+ onClick: (i) => {
109
+ i.stopPropagation(), y(e);
110
+ },
111
+ children: /* @__PURE__ */ r(fe, { size: 18 })
112
+ }
113
+ ),
114
+ e.url && /* @__PURE__ */ r(
115
+ "button",
116
+ {
117
+ type: "button",
118
+ className: `${s.OverlayButton} ${s.OverlayButtonRight}`,
119
+ "aria-label": "이미지 확대보기",
120
+ title: "크게 보기",
121
+ disabled: b || e.isLoading,
122
+ onClick: (i) => {
123
+ i.stopPropagation(), c(e);
124
+ },
125
+ children: /* @__PURE__ */ r(pe, { size: 18, color: me })
126
+ }
127
+ )
128
+ ] })
129
+ ]
130
+ }
131
+ );
132
+ }
133
+ const Ve = ({
134
+ value: e = [],
135
+ onChange: l,
136
+ accept: d,
137
+ length: A,
138
+ width: h = 160,
139
+ height: x = 200,
140
+ placeholder: u = "이미지를 넣어주세요",
141
+ hasIcon: $ = !0,
142
+ hasLink: P = !1,
143
+ onLinkClick: w,
144
+ hasEdit: g = !1,
145
+ canDelete: b = !0,
146
+ minLength: v,
147
+ maxLength: B,
148
+ errorMsg: C,
149
+ isLoading: y,
150
+ readOnly: c,
151
+ gap: E = 8
152
+ }) => {
153
+ const {
154
+ isPositionMode: S,
155
+ resolvedMaxLength: i,
156
+ placeholderCount: D,
157
+ slotIds: K,
158
+ sortableItems: Q,
159
+ sensors: Z,
160
+ handleDragEnd: ee,
161
+ getMetaIndex: M
162
+ } = we({ value: e, length: A, minLength: v, maxLength: B, onChange: l }), p = !!C, [z, N] = O(null), [T, R] = O(null), m = T ? e.find((n) => n.id === T.id && n.url === T.url) ?? null : null;
163
+ T && !m && R(null);
164
+ const k = Y(e);
165
+ V(() => {
166
+ k.current = e;
167
+ }, [e]), V(() => () => he(k.current), []);
168
+ const te = (n) => {
169
+ if (c) return;
170
+ const t = e.length, o = ye(e, n, i);
171
+ o.length !== t && l?.(o, {
172
+ action: "create",
173
+ itemId: o[t].id,
174
+ index: t
175
+ });
176
+ }, re = (n, t) => {
177
+ if (c) return;
178
+ const o = t[0];
179
+ if (!o) return;
180
+ const a = be(e, o, n);
181
+ l?.(a, {
182
+ action: "create",
183
+ itemId: a[a.length - 1].id,
184
+ index: n
185
+ });
186
+ }, U = (n) => {
187
+ if (c) return;
188
+ const t = M(n), o = ge(e, n);
189
+ l?.(o, { action: "delete", itemId: n, index: t });
190
+ }, _ = (n, t) => {
191
+ if (c) return;
192
+ const o = M(n), a = xe(e, n, t);
193
+ l?.(a, { action: "replace", itemId: n, index: o });
194
+ }, ne = (n) => {
195
+ if (!z) return;
196
+ const t = z.id, o = M(t), a = Pe(e, t, n);
197
+ N(null), l?.(a, { action: "crop", itemId: t, index: o });
198
+ }, G = (n) => {
199
+ const t = typeof u == "function" ? u(n) : u;
200
+ return typeof t != "string" ? t : t.split(`
201
+ `).map((o, a) => /* @__PURE__ */ r("span", { children: o }, a));
202
+ };
203
+ return /* @__PURE__ */ f("div", { children: [
204
+ /* @__PURE__ */ r(le, { sensors: Z, collisionDetection: ie, onDragEnd: ee, children: /* @__PURE__ */ r(se, { items: Q, strategy: ae, children: /* @__PURE__ */ r("div", { className: s.Container, style: { gap: E }, children: S ? Array.from({ length: i }, (n, t) => {
205
+ const o = K[t], a = e.find((I) => I.position === t);
206
+ return a ? /* @__PURE__ */ r(
207
+ X,
208
+ {
209
+ item: a,
210
+ sortableId: o,
211
+ index: t,
212
+ totalCount: i,
213
+ width: h,
214
+ height: x,
215
+ accept: d,
216
+ canDelete: b,
217
+ hasLink: P,
218
+ hasEdit: g,
219
+ readOnly: c ?? !1,
220
+ isLoading: y,
221
+ onLinkClick: w,
222
+ onDelete: U,
223
+ onReplace: _,
224
+ onEdit: N,
225
+ onPreview: (I) => {
226
+ I.url && R({ id: I.id, url: I.url });
227
+ }
228
+ },
229
+ o
230
+ ) : !c && /* @__PURE__ */ r(Ce, { id: o, children: /* @__PURE__ */ f(
231
+ q,
232
+ {
233
+ onDrop: (I) => re(t, I),
234
+ accept: d ?? j,
235
+ multiple: !1,
236
+ isLoading: y,
237
+ isError: p,
238
+ width: h,
239
+ height: x,
240
+ children: [
241
+ $ && /* @__PURE__ */ r(F, { size: 36, color: p ? H : L }),
242
+ u && /* @__PURE__ */ r(
243
+ "div",
244
+ {
245
+ className: `${s.PlaceholderText}${p ? ` ${s.PlaceholderTextError}` : ""}`,
246
+ children: G(t)
247
+ }
248
+ )
249
+ ]
250
+ }
251
+ ) }, o);
252
+ }) : /* @__PURE__ */ f(oe, { children: [
253
+ e.map((n, t) => /* @__PURE__ */ r(
254
+ X,
255
+ {
256
+ item: n,
257
+ index: t,
258
+ totalCount: e.length,
259
+ width: h,
260
+ height: x,
261
+ accept: d,
262
+ canDelete: b,
263
+ hasLink: P,
264
+ hasEdit: g,
265
+ readOnly: c ?? !1,
266
+ isLoading: y,
267
+ onLinkClick: w,
268
+ onDelete: U,
269
+ onReplace: _,
270
+ onEdit: N,
271
+ onPreview: (o) => {
272
+ o.url && R({ id: o.id, url: o.url });
273
+ }
274
+ },
275
+ n.id
276
+ )),
277
+ !c && Array.from({ length: D }, (n, t) => /* @__PURE__ */ f(
278
+ q,
279
+ {
280
+ onDrop: te,
281
+ accept: d ?? j,
282
+ multiple: i !== 1,
283
+ isLoading: y,
284
+ isError: p,
285
+ width: h,
286
+ height: x,
287
+ children: [
288
+ $ && /* @__PURE__ */ r(F, { size: 36, color: p ? H : L }),
289
+ u && /* @__PURE__ */ r(
290
+ "div",
291
+ {
292
+ className: `${s.PlaceholderText}${p ? ` ${s.PlaceholderTextError}` : ""}`,
293
+ children: G(t)
294
+ }
295
+ )
296
+ ]
297
+ },
298
+ `placeholder-${t}`
299
+ ))
300
+ ] }) }) }) }),
301
+ p && /* @__PURE__ */ r(ce.Error, { mt: 8, children: C }),
302
+ g && /* @__PURE__ */ r(
303
+ ve,
304
+ {
305
+ item: z,
306
+ isOpen: !!z,
307
+ onClose: () => N(null),
308
+ onSubmit: ne
309
+ }
310
+ ),
311
+ /* @__PURE__ */ r(
312
+ Ie,
313
+ {
314
+ opened: !!m,
315
+ onClose: () => R(null),
316
+ title: m?.file?.name ?? "이미지 미리보기",
317
+ size: "xl",
318
+ centered: !0,
319
+ xOffset: 16,
320
+ yOffset: 16,
321
+ withCloseButton: !0,
322
+ closeButtonProps: {
323
+ "aria-label": "이미지 미리보기 닫기",
324
+ icon: /* @__PURE__ */ r(de, { size: 18, color: ue })
325
+ },
326
+ styles: {
327
+ content: {
328
+ flex: "0 1 auto",
329
+ width: "fit-content",
330
+ maxWidth: "calc(100vw - 32px)",
331
+ maxHeight: "calc(100dvh - 32px)"
332
+ },
333
+ body: { padding: "16px" }
334
+ },
335
+ children: m && /* @__PURE__ */ r(De, { item: m }, `${m.id}:${m.url}`)
336
+ }
337
+ )
338
+ ] });
339
+ };
340
+ function De({ item: e }) {
341
+ const [l, d] = O(!1);
342
+ return /* @__PURE__ */ f("div", { className: s.PreviewContent, children: [
343
+ /* @__PURE__ */ f("div", { className: s.PreviewControls, role: "group", "aria-label": "이미지 크기 보기", children: [
344
+ /* @__PURE__ */ r(
345
+ W,
346
+ {
347
+ variant: l ? "basic" : "primary",
348
+ size: "sm",
349
+ "aria-label": "화면에 맞춤",
350
+ "aria-pressed": !l,
351
+ onClick: () => d(!1),
352
+ children: "화면에 맞춤"
353
+ }
354
+ ),
355
+ /* @__PURE__ */ r(
356
+ W,
357
+ {
358
+ variant: l ? "primary" : "basic",
359
+ size: "sm",
360
+ "aria-label": "원본 크기 (100%)",
361
+ "aria-pressed": l,
362
+ onClick: () => d(!0),
363
+ children: "원본 크기 (100%)"
364
+ }
365
+ )
366
+ ] }),
367
+ /* @__PURE__ */ r(
368
+ "div",
369
+ {
370
+ "data-size-mode": l ? "original" : "fit",
371
+ className: `${s.PreviewViewport}${l ? ` ${s.PreviewOriginal}` : ""}`,
372
+ children: /* @__PURE__ */ r("img", { src: e.url, alt: e.file?.name ?? "이미지 미리보기" })
373
+ }
374
+ )
375
+ ] });
376
+ }
377
+ export {
378
+ Ve as ImageInput
379
+ };
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ const e = "styles-module__Container___ZyeJM", t = "styles-module__TileContent___Ofq9-", o = "styles-module__TileImage___6aKmW", l = "styles-module__OverlayButton___AYBJ0", _ = "styles-module__OverlayButtonLeft___t8SaP", r = "styles-module__OverlayButtonRight___IOvjw", n = "styles-module__PreviewControls___iu0Yk", s = "styles-module__PreviewContent___8f8d2", i = "styles-module__PreviewViewport___7-I5L", a = "styles-module__PreviewOriginal___PgXTM", u = "styles-module__PlaceholderText___nhLhy", y = "styles-module__PlaceholderTextError___jYZ8j", v = {
3
+ Container: e,
4
+ TileContent: t,
5
+ TileImage: o,
6
+ OverlayButton: l,
7
+ OverlayButtonLeft: _,
8
+ OverlayButtonRight: r,
9
+ PreviewControls: n,
10
+ PreviewContent: s,
11
+ PreviewViewport: i,
12
+ PreviewOriginal: a,
13
+ PlaceholderText: u,
14
+ PlaceholderTextError: y
15
+ };
16
+ export {
17
+ e as Container,
18
+ l as OverlayButton,
19
+ _ as OverlayButtonLeft,
20
+ r as OverlayButtonRight,
21
+ u as PlaceholderText,
22
+ y as PlaceholderTextError,
23
+ s as PreviewContent,
24
+ n as PreviewControls,
25
+ a as PreviewOriginal,
26
+ i as PreviewViewport,
27
+ t as TileContent,
28
+ o as TileImage,
29
+ v as default
30
+ };
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { generateItemId as a } from "../shared/MultiItemInput/helpers.js";
3
+ import { getPlaceholderCount as w, reorderItems as g } from "../shared/MultiItemInput/helpers.js";
4
+ function s(t) {
5
+ if (!t || typeof t != "object" || Array.isArray(t)) return !1;
6
+ const e = t;
7
+ return "v" in e && "fr" in e && "ip" in e && "op" in e && "w" in e && "h" in e && "layers" in e && Array.isArray(e.layers);
8
+ }
9
+ function m(t) {
10
+ return new Promise((e) => {
11
+ const n = new FileReader();
12
+ n.onload = (r) => {
13
+ try {
14
+ const i = JSON.parse(r.target?.result);
15
+ e(s(i) ? i : null);
16
+ } catch {
17
+ e(null);
18
+ }
19
+ }, n.onerror = () => e(null), n.readAsText(t);
20
+ });
21
+ }
22
+ function f(t, e, n) {
23
+ const r = [...e].sort((o, l) => o.name.localeCompare(l.name)), i = n != null ? n - t.length : 1 / 0, c = r.slice(0, i).map((o) => ({
24
+ id: a(),
25
+ file: o
26
+ }));
27
+ return [...t, ...c];
28
+ }
29
+ function p(t, e) {
30
+ return t.filter((n) => n.id !== e);
31
+ }
32
+ function y(t, e, n) {
33
+ const r = {
34
+ id: a(),
35
+ file: e,
36
+ position: n
37
+ };
38
+ return [...t, r];
39
+ }
40
+ export {
41
+ y as addItemAtPosition,
42
+ f as addItems,
43
+ p as deleteItem,
44
+ w as getPlaceholderCount,
45
+ s as isValidLottieJSON,
46
+ m as parseLottieFile,
47
+ g as reorderItems
48
+ };
@@ -0,0 +1,233 @@
1
+ "use client";
2
+ import { jsxs as $, jsx as o, Fragment as W } from "react/jsx-runtime";
3
+ import { DndContext as X, closestCenter as Y } from "@dnd-kit/core";
4
+ import { SortableContext as Z, rectSortingStrategy as w } from "@dnd-kit/sortable";
5
+ import { Input as tt } from "@mantine/core";
6
+ import { IconPhoto as _, ColorRed700 as F, ColorAqua700 as R } from "@pop-ui/foundation";
7
+ import { useState as et, useEffect as ot, Suspense as nt, lazy as rt } from "react";
8
+ import { parseLottieFile as v, isValidLottieJSON as lt, deleteItem as st, addItemAtPosition as it, addItems as at } from "./helpers.js";
9
+ import x from "./styles.module.scss.js";
10
+ import { PlaceholderDropzone as M } from "../shared/MultiItemInput/Dropzone.js";
11
+ import { SortableEmptySlot as ct } from "../shared/MultiItemInput/SortableEmptySlot.js";
12
+ import { TileShell as dt } from "../shared/MultiItemInput/TileShell.js";
13
+ import { usePositionGrid as ft } from "../shared/MultiItemInput/usePositionGrid.js";
14
+ import { toast as O } from "../Toast/index.js";
15
+ const ut = rt(
16
+ () => (
17
+ // Node 네이티브 ESM 로더는 CommonJS 인 lottie-react 의 exports 객체 전체를 default 로 넘긴다.
18
+ import("lottie-react").then((t) => {
19
+ const i = t.default;
20
+ return { default: typeof i == "function" ? i : i.default };
21
+ })
22
+ )
23
+ ), q = { "application/json": [".json"] };
24
+ function G({
25
+ item: t,
26
+ sortableId: i,
27
+ totalCount: y,
28
+ width: f,
29
+ height: a,
30
+ readOnly: D,
31
+ isLoading: I,
32
+ canDelete: L,
33
+ hasLink: E,
34
+ onLinkClick: P,
35
+ onDelete: g
36
+ }) {
37
+ const l = !t.animationData && !!(t.file || t.url) ? `${t.id}|${t.file ? `${t.file.name}:${t.file.size}` : t.url ?? ""}` : "", [s, S] = et({ key: "", data: null }), h = t.animationData ?? (s.key === l ? s.data : null), C = !!l && s.key !== l;
38
+ return ot(() => {
39
+ if (!l) return;
40
+ let u = !1;
41
+ return (t.file ? v(t.file) : fetch(t.url).then((m) => m.json()).then(
42
+ (m) => lt(m) ? m : null
43
+ )).then((m) => {
44
+ u || S({ key: l, data: m });
45
+ }).catch(() => {
46
+ u || S({ key: l, data: null });
47
+ }), () => {
48
+ u = !0;
49
+ };
50
+ }, [l, t.file, t.url]), /* @__PURE__ */ o(
51
+ dt,
52
+ {
53
+ id: i ?? t.id,
54
+ totalCount: y,
55
+ width: f,
56
+ height: a,
57
+ readOnly: D,
58
+ isLoading: I,
59
+ itemIsLoading: t.isLoading || C,
60
+ canDelete: L,
61
+ hasLink: E,
62
+ linkUrl: t.url,
63
+ onLinkClick: P ? () => P(t) : void 0,
64
+ onDelete: () => g(t.id),
65
+ deleteAriaLabel: "Lottie 삭제",
66
+ children: h ? /* @__PURE__ */ o(nt, { fallback: /* @__PURE__ */ o("div", { style: { width: f, height: a, display: "block" } }), children: /* @__PURE__ */ o(
67
+ ut,
68
+ {
69
+ animationData: h,
70
+ loop: !0,
71
+ autoplay: !0,
72
+ style: { width: f, height: a, display: "block" }
73
+ }
74
+ ) }) : /* @__PURE__ */ o("div", { className: x.Empty, style: { width: f, height: a } })
75
+ }
76
+ );
77
+ }
78
+ const At = ({
79
+ value: t = [],
80
+ onChange: i,
81
+ width: y = 160,
82
+ height: f = 200,
83
+ placeholder: a = "Lottie JSON 파일을 넣어주세요",
84
+ hasIcon: D = !0,
85
+ hasLink: I = !1,
86
+ onLinkClick: L,
87
+ length: E,
88
+ minLength: P,
89
+ maxLength: g,
90
+ errorMsg: A,
91
+ isLoading: l,
92
+ readOnly: s,
93
+ gap: S = 8,
94
+ canDelete: h = !0
95
+ }) => {
96
+ const {
97
+ isPositionMode: C,
98
+ resolvedMaxLength: u,
99
+ placeholderCount: k,
100
+ slotIds: m,
101
+ sortableItems: K,
102
+ sensors: U,
103
+ handleDragEnd: V,
104
+ getMetaIndex: B
105
+ } = ft({ value: t, length: E, minLength: P, maxLength: g, onChange: i }), p = !!A, H = async (n) => {
106
+ if (s) return;
107
+ const e = [...n].sort((j, b) => j.name.localeCompare(b.name)), r = await Promise.all(e.map(v));
108
+ let c = 0;
109
+ const d = e.filter((j, b) => r[b] !== null ? !0 : (c++, !1));
110
+ if (c > 0 && O({
111
+ id: "invalid-lottie-files",
112
+ message: c === 1 ? "유효하지 않은 Lottie JSON 파일입니다" : `${c}개의 파일이 유효하지 않은 Lottie JSON입니다`
113
+ }), d.length === 0) return;
114
+ const N = t.length, T = at(t, d, u);
115
+ T.length !== N && i?.(T, {
116
+ action: "create",
117
+ itemId: T[N].id,
118
+ index: N
119
+ });
120
+ }, Q = async (n, e) => {
121
+ if (s) return;
122
+ const r = e[0];
123
+ if (!r) return;
124
+ if (!await v(r)) {
125
+ O({
126
+ id: "invalid-lottie-files",
127
+ message: "유효하지 않은 Lottie JSON 파일입니다"
128
+ });
129
+ return;
130
+ }
131
+ const d = it(t, r, n);
132
+ i?.(d, {
133
+ action: "create",
134
+ itemId: d[d.length - 1].id,
135
+ index: n
136
+ });
137
+ }, z = (n) => {
138
+ if (s) return;
139
+ const e = B(n), r = st(t, n);
140
+ i?.(r, { action: "delete", itemId: n, index: e });
141
+ }, J = (n) => {
142
+ const e = typeof a == "function" ? a(n) : a;
143
+ return typeof e != "string" ? e : e.split(`
144
+ `).map((r, c) => /* @__PURE__ */ o("span", { children: r }, c));
145
+ };
146
+ return /* @__PURE__ */ $("div", { children: [
147
+ /* @__PURE__ */ o(X, { sensors: U, collisionDetection: Y, onDragEnd: V, children: /* @__PURE__ */ o(Z, { items: K, strategy: w, children: /* @__PURE__ */ o("div", { className: x.Container, style: { gap: S }, children: C ? Array.from({ length: u }, (n, e) => {
148
+ const r = m[e], c = t.find((d) => d.position === e);
149
+ return c ? /* @__PURE__ */ o(
150
+ G,
151
+ {
152
+ item: c,
153
+ sortableId: r,
154
+ totalCount: u,
155
+ width: y,
156
+ height: f,
157
+ readOnly: s ?? !1,
158
+ isLoading: l,
159
+ canDelete: h,
160
+ hasLink: I,
161
+ onLinkClick: L,
162
+ onDelete: z
163
+ },
164
+ r
165
+ ) : !s && /* @__PURE__ */ o(ct, { id: r, children: /* @__PURE__ */ $(
166
+ M,
167
+ {
168
+ onDrop: (d) => Q(e, d),
169
+ accept: q,
170
+ multiple: !1,
171
+ isLoading: l,
172
+ isError: p,
173
+ width: y,
174
+ height: f,
175
+ children: [
176
+ D && /* @__PURE__ */ o(_, { size: 36, color: p ? F : R }),
177
+ a && /* @__PURE__ */ o(
178
+ "div",
179
+ {
180
+ className: `${x.PlaceholderText}${p ? ` ${x.PlaceholderTextError}` : ""}`,
181
+ children: J(e)
182
+ }
183
+ )
184
+ ]
185
+ }
186
+ ) }, r);
187
+ }) : /* @__PURE__ */ $(W, { children: [
188
+ t.map((n) => /* @__PURE__ */ o(
189
+ G,
190
+ {
191
+ item: n,
192
+ totalCount: t.length,
193
+ width: y,
194
+ height: f,
195
+ readOnly: s ?? !1,
196
+ isLoading: l,
197
+ canDelete: h,
198
+ hasLink: I,
199
+ onLinkClick: L,
200
+ onDelete: z
201
+ },
202
+ n.id
203
+ )),
204
+ !s && Array.from({ length: k }, (n, e) => /* @__PURE__ */ $(
205
+ M,
206
+ {
207
+ onDrop: H,
208
+ accept: q,
209
+ multiple: u !== 1,
210
+ isLoading: l,
211
+ isError: p,
212
+ width: y,
213
+ height: f,
214
+ children: [
215
+ D && /* @__PURE__ */ o(_, { size: 36, color: p ? F : R }),
216
+ a && /* @__PURE__ */ o(
217
+ "div",
218
+ {
219
+ className: `${x.PlaceholderText}${p ? ` ${x.PlaceholderTextError}` : ""}`,
220
+ children: J(e)
221
+ }
222
+ )
223
+ ]
224
+ },
225
+ `placeholder-${e}`
226
+ ))
227
+ ] }) }) }) }),
228
+ p && /* @__PURE__ */ o(tt.Error, { mt: 8, children: A })
229
+ ] });
230
+ };
231
+ export {
232
+ At as LottieInput
233
+ };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ const e = "styles-module__Container___cJqG-", t = "styles-module__Empty___gexrS", l = "styles-module__PlaceholderText___x2ya0", o = "styles-module__PlaceholderTextError___i8VXv", r = {
3
+ Container: e,
4
+ Empty: t,
5
+ PlaceholderText: l,
6
+ PlaceholderTextError: o
7
+ };
8
+ export {
9
+ e as Container,
10
+ t as Empty,
11
+ l as PlaceholderText,
12
+ o as PlaceholderTextError,
13
+ r as default
14
+ };