@pop-ui/core 2.2.6 → 2.2.7
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.
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { DndContext as
|
|
4
|
-
import { SortableContext as
|
|
5
|
-
import { Input as
|
|
6
|
-
import { IconPhoto as
|
|
7
|
-
import { useState as
|
|
8
|
-
import { parseLottieFile as
|
|
9
|
-
import
|
|
2
|
+
import { jsxs as N, jsx as o, Fragment as X } from "react/jsx-runtime";
|
|
3
|
+
import { DndContext as Y, closestCenter as Z } from "@dnd-kit/core";
|
|
4
|
+
import { SortableContext as w, rectSortingStrategy as tt } from "@dnd-kit/sortable";
|
|
5
|
+
import { Input as et } from "@mantine/core";
|
|
6
|
+
import { IconPhoto as F, ColorRed700 as O, ColorAqua700 as R } from "@pop-ui/foundation";
|
|
7
|
+
import { useState as ot, useEffect as nt, Suspense as rt, lazy as lt } from "react";
|
|
8
|
+
import { parseLottieFile as J, isValidLottieJSON as it, deleteItem as st, addItemAtPosition as at, addItems as ct } from "./helpers.js";
|
|
9
|
+
import p from "./styles.module.scss.js";
|
|
10
10
|
import { PlaceholderDropzone as M } from "../shared/MultiItemInput/Dropzone.js";
|
|
11
|
-
import { SortableEmptySlot as
|
|
12
|
-
import { TileShell as
|
|
13
|
-
import { usePositionGrid as
|
|
14
|
-
import { toast as
|
|
15
|
-
const
|
|
11
|
+
import { SortableEmptySlot as dt } from "../shared/MultiItemInput/SortableEmptySlot.js";
|
|
12
|
+
import { TileShell as ft } from "../shared/MultiItemInput/TileShell.js";
|
|
13
|
+
import { usePositionGrid as ut } from "../shared/MultiItemInput/usePositionGrid.js";
|
|
14
|
+
import { toast as q } from "../Toast/index.js";
|
|
15
|
+
const mt = lt(
|
|
16
16
|
() => (
|
|
17
17
|
// Node 네이티브 ESM 로더는 CommonJS 인 lottie-react 의 exports 객체 전체를 default 로 넘긴다.
|
|
18
18
|
import("lottie-react").then((t) => {
|
|
@@ -20,58 +20,66 @@ const ut = rt(
|
|
|
20
20
|
return { default: typeof i == "function" ? i : i.default };
|
|
21
21
|
})
|
|
22
22
|
)
|
|
23
|
-
),
|
|
24
|
-
function
|
|
23
|
+
), G = { "application/json": [".json"] };
|
|
24
|
+
function K({
|
|
25
25
|
item: t,
|
|
26
26
|
sortableId: i,
|
|
27
27
|
totalCount: y,
|
|
28
|
-
width:
|
|
29
|
-
height:
|
|
30
|
-
readOnly:
|
|
31
|
-
isLoading:
|
|
32
|
-
canDelete:
|
|
33
|
-
hasLink:
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
width: d,
|
|
29
|
+
height: s,
|
|
30
|
+
readOnly: I,
|
|
31
|
+
isLoading: P,
|
|
32
|
+
canDelete: $,
|
|
33
|
+
hasLink: A,
|
|
34
|
+
backgroundImage: x,
|
|
35
|
+
onLinkClick: v,
|
|
36
|
+
onDelete: E
|
|
36
37
|
}) {
|
|
37
|
-
const
|
|
38
|
-
return
|
|
39
|
-
if (!
|
|
40
|
-
let
|
|
41
|
-
return (t.file ?
|
|
42
|
-
(
|
|
43
|
-
)).then((
|
|
44
|
-
|
|
38
|
+
const n = !t.animationData && !!(t.file || t.url) ? `${t.id}|${t.file ? `${t.file.name}:${t.file.size}` : t.url ?? ""}` : "", [D, L] = ot({ key: "", data: null }), S = t.animationData ?? (D.key === n ? D.data : null), C = !!n && D.key !== n;
|
|
39
|
+
return nt(() => {
|
|
40
|
+
if (!n) return;
|
|
41
|
+
let f = !1;
|
|
42
|
+
return (t.file ? J(t.file) : fetch(t.url).then((u) => u.json()).then(
|
|
43
|
+
(u) => it(u) ? u : null
|
|
44
|
+
)).then((u) => {
|
|
45
|
+
f || L({ key: n, data: u });
|
|
45
46
|
}).catch(() => {
|
|
46
|
-
|
|
47
|
+
f || L({ key: n, data: null });
|
|
47
48
|
}), () => {
|
|
48
|
-
|
|
49
|
+
f = !0;
|
|
49
50
|
};
|
|
50
|
-
}, [
|
|
51
|
-
|
|
51
|
+
}, [n, t.file, t.url]), /* @__PURE__ */ o(
|
|
52
|
+
ft,
|
|
52
53
|
{
|
|
53
54
|
id: i ?? t.id,
|
|
54
55
|
totalCount: y,
|
|
55
|
-
width:
|
|
56
|
-
height:
|
|
57
|
-
readOnly:
|
|
58
|
-
isLoading:
|
|
56
|
+
width: d,
|
|
57
|
+
height: s,
|
|
58
|
+
readOnly: I,
|
|
59
|
+
isLoading: P,
|
|
59
60
|
itemIsLoading: t.isLoading || C,
|
|
60
|
-
canDelete:
|
|
61
|
-
hasLink:
|
|
61
|
+
canDelete: $,
|
|
62
|
+
hasLink: A,
|
|
62
63
|
linkUrl: t.url,
|
|
63
|
-
onLinkClick:
|
|
64
|
-
onDelete: () =>
|
|
64
|
+
onLinkClick: v ? () => v(t) : void 0,
|
|
65
|
+
onDelete: () => E(t.id),
|
|
65
66
|
deleteAriaLabel: "Lottie 삭제",
|
|
66
|
-
children:
|
|
67
|
-
|
|
67
|
+
children: /* @__PURE__ */ o(
|
|
68
|
+
"div",
|
|
68
69
|
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
className: p.Stage,
|
|
71
|
+
style: x ? { backgroundImage: `url(${JSON.stringify(x)})` } : void 0,
|
|
72
|
+
children: S ? /* @__PURE__ */ o(rt, { fallback: /* @__PURE__ */ o("div", { style: { width: d, height: s, display: "block" } }), children: /* @__PURE__ */ o(
|
|
73
|
+
mt,
|
|
74
|
+
{
|
|
75
|
+
animationData: S,
|
|
76
|
+
loop: !0,
|
|
77
|
+
autoplay: !0,
|
|
78
|
+
style: { width: d, height: s, display: "block" }
|
|
79
|
+
}
|
|
80
|
+
) }) : /* @__PURE__ */ o("div", { className: x ? void 0 : p.Empty, style: { width: d, height: s } })
|
|
73
81
|
}
|
|
74
|
-
)
|
|
82
|
+
)
|
|
75
83
|
}
|
|
76
84
|
);
|
|
77
85
|
}
|
|
@@ -79,145 +87,148 @@ const At = ({
|
|
|
79
87
|
value: t = [],
|
|
80
88
|
onChange: i,
|
|
81
89
|
width: y = 160,
|
|
82
|
-
height:
|
|
83
|
-
placeholder:
|
|
84
|
-
hasIcon:
|
|
85
|
-
hasLink:
|
|
86
|
-
onLinkClick:
|
|
87
|
-
length:
|
|
88
|
-
minLength:
|
|
89
|
-
maxLength:
|
|
90
|
-
errorMsg:
|
|
91
|
-
isLoading:
|
|
92
|
-
readOnly:
|
|
93
|
-
gap:
|
|
94
|
-
canDelete:
|
|
90
|
+
height: d = 200,
|
|
91
|
+
placeholder: s = "Lottie JSON 파일을 넣어주세요",
|
|
92
|
+
hasIcon: I = !0,
|
|
93
|
+
hasLink: P = !1,
|
|
94
|
+
onLinkClick: $,
|
|
95
|
+
length: A,
|
|
96
|
+
minLength: x,
|
|
97
|
+
maxLength: v,
|
|
98
|
+
errorMsg: E,
|
|
99
|
+
isLoading: h,
|
|
100
|
+
readOnly: n,
|
|
101
|
+
gap: D = 8,
|
|
102
|
+
canDelete: L = !0,
|
|
103
|
+
backgroundImage: S
|
|
95
104
|
}) => {
|
|
96
105
|
const {
|
|
97
106
|
isPositionMode: C,
|
|
98
|
-
resolvedMaxLength:
|
|
99
|
-
placeholderCount:
|
|
100
|
-
slotIds:
|
|
101
|
-
sortableItems:
|
|
102
|
-
sensors:
|
|
103
|
-
handleDragEnd:
|
|
104
|
-
getMetaIndex:
|
|
105
|
-
} =
|
|
106
|
-
if (
|
|
107
|
-
const e = [...
|
|
108
|
-
let
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
107
|
+
resolvedMaxLength: f,
|
|
108
|
+
placeholderCount: z,
|
|
109
|
+
slotIds: u,
|
|
110
|
+
sortableItems: U,
|
|
111
|
+
sensors: V,
|
|
112
|
+
handleDragEnd: B,
|
|
113
|
+
getMetaIndex: H
|
|
114
|
+
} = ut({ value: t, length: A, minLength: x, maxLength: v, onChange: i }), m = !!E, Q = async (r) => {
|
|
115
|
+
if (n) return;
|
|
116
|
+
const e = [...r].sort((_, b) => _.name.localeCompare(b.name)), l = await Promise.all(e.map(J));
|
|
117
|
+
let a = 0;
|
|
118
|
+
const c = e.filter((_, b) => l[b] !== null ? !0 : (a++, !1));
|
|
119
|
+
if (a > 0 && q({
|
|
111
120
|
id: "invalid-lottie-files",
|
|
112
|
-
message:
|
|
113
|
-
}),
|
|
114
|
-
const
|
|
115
|
-
|
|
121
|
+
message: a === 1 ? "유효하지 않은 Lottie JSON 파일입니다" : `${a}개의 파일이 유효하지 않은 Lottie JSON입니다`
|
|
122
|
+
}), c.length === 0) return;
|
|
123
|
+
const T = t.length, g = ct(t, c, f);
|
|
124
|
+
g.length !== T && i?.(g, {
|
|
116
125
|
action: "create",
|
|
117
|
-
itemId: T
|
|
118
|
-
index:
|
|
126
|
+
itemId: g[T].id,
|
|
127
|
+
index: T
|
|
119
128
|
});
|
|
120
|
-
},
|
|
121
|
-
if (
|
|
122
|
-
const
|
|
123
|
-
if (!
|
|
124
|
-
if (!await
|
|
125
|
-
|
|
129
|
+
}, W = async (r, e) => {
|
|
130
|
+
if (n) return;
|
|
131
|
+
const l = e[0];
|
|
132
|
+
if (!l) return;
|
|
133
|
+
if (!await J(l)) {
|
|
134
|
+
q({
|
|
126
135
|
id: "invalid-lottie-files",
|
|
127
136
|
message: "유효하지 않은 Lottie JSON 파일입니다"
|
|
128
137
|
});
|
|
129
138
|
return;
|
|
130
139
|
}
|
|
131
|
-
const
|
|
132
|
-
i?.(
|
|
140
|
+
const c = at(t, l, r);
|
|
141
|
+
i?.(c, {
|
|
133
142
|
action: "create",
|
|
134
|
-
itemId:
|
|
135
|
-
index:
|
|
143
|
+
itemId: c[c.length - 1].id,
|
|
144
|
+
index: r
|
|
136
145
|
});
|
|
137
|
-
},
|
|
138
|
-
if (
|
|
139
|
-
const e =
|
|
140
|
-
i?.(
|
|
141
|
-
},
|
|
142
|
-
const e = typeof
|
|
146
|
+
}, j = (r) => {
|
|
147
|
+
if (n) return;
|
|
148
|
+
const e = H(r), l = st(t, r);
|
|
149
|
+
i?.(l, { action: "delete", itemId: r, index: e });
|
|
150
|
+
}, k = (r) => {
|
|
151
|
+
const e = typeof s == "function" ? s(r) : s;
|
|
143
152
|
return typeof e != "string" ? e : e.split(`
|
|
144
|
-
`).map((
|
|
153
|
+
`).map((l, a) => /* @__PURE__ */ o("span", { children: l }, a));
|
|
145
154
|
};
|
|
146
|
-
return /* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */ o(
|
|
148
|
-
const
|
|
149
|
-
return
|
|
150
|
-
|
|
155
|
+
return /* @__PURE__ */ N("div", { children: [
|
|
156
|
+
/* @__PURE__ */ o(Y, { sensors: V, collisionDetection: Z, onDragEnd: B, children: /* @__PURE__ */ o(w, { items: U, strategy: tt, children: /* @__PURE__ */ o("div", { className: p.Container, style: { gap: D }, children: C ? Array.from({ length: f }, (r, e) => {
|
|
157
|
+
const l = u[e], a = t.find((c) => c.position === e);
|
|
158
|
+
return a ? /* @__PURE__ */ o(
|
|
159
|
+
K,
|
|
151
160
|
{
|
|
152
|
-
item:
|
|
153
|
-
sortableId:
|
|
154
|
-
totalCount:
|
|
161
|
+
item: a,
|
|
162
|
+
sortableId: l,
|
|
163
|
+
totalCount: f,
|
|
155
164
|
width: y,
|
|
156
|
-
height:
|
|
157
|
-
readOnly:
|
|
158
|
-
isLoading:
|
|
159
|
-
canDelete:
|
|
160
|
-
hasLink:
|
|
161
|
-
|
|
162
|
-
|
|
165
|
+
height: d,
|
|
166
|
+
readOnly: n ?? !1,
|
|
167
|
+
isLoading: h,
|
|
168
|
+
canDelete: L,
|
|
169
|
+
hasLink: P,
|
|
170
|
+
backgroundImage: S,
|
|
171
|
+
onLinkClick: $,
|
|
172
|
+
onDelete: j
|
|
163
173
|
},
|
|
164
|
-
|
|
165
|
-
) : !
|
|
174
|
+
l
|
|
175
|
+
) : !n && /* @__PURE__ */ o(dt, { id: l, children: /* @__PURE__ */ N(
|
|
166
176
|
M,
|
|
167
177
|
{
|
|
168
|
-
onDrop: (
|
|
169
|
-
accept:
|
|
178
|
+
onDrop: (c) => W(e, c),
|
|
179
|
+
accept: G,
|
|
170
180
|
multiple: !1,
|
|
171
|
-
isLoading:
|
|
172
|
-
isError:
|
|
181
|
+
isLoading: h,
|
|
182
|
+
isError: m,
|
|
173
183
|
width: y,
|
|
174
|
-
height:
|
|
184
|
+
height: d,
|
|
175
185
|
children: [
|
|
176
|
-
|
|
177
|
-
|
|
186
|
+
I && /* @__PURE__ */ o(F, { size: 36, color: m ? O : R }),
|
|
187
|
+
s && /* @__PURE__ */ o(
|
|
178
188
|
"div",
|
|
179
189
|
{
|
|
180
|
-
className: `${
|
|
181
|
-
children:
|
|
190
|
+
className: `${p.PlaceholderText}${m ? ` ${p.PlaceholderTextError}` : ""}`,
|
|
191
|
+
children: k(e)
|
|
182
192
|
}
|
|
183
193
|
)
|
|
184
194
|
]
|
|
185
195
|
}
|
|
186
|
-
) },
|
|
187
|
-
}) : /* @__PURE__ */
|
|
188
|
-
t.map((
|
|
189
|
-
|
|
196
|
+
) }, l);
|
|
197
|
+
}) : /* @__PURE__ */ N(X, { children: [
|
|
198
|
+
t.map((r) => /* @__PURE__ */ o(
|
|
199
|
+
K,
|
|
190
200
|
{
|
|
191
|
-
item:
|
|
201
|
+
item: r,
|
|
192
202
|
totalCount: t.length,
|
|
193
203
|
width: y,
|
|
194
|
-
height:
|
|
195
|
-
readOnly:
|
|
196
|
-
isLoading:
|
|
197
|
-
canDelete:
|
|
198
|
-
hasLink:
|
|
199
|
-
|
|
200
|
-
|
|
204
|
+
height: d,
|
|
205
|
+
readOnly: n ?? !1,
|
|
206
|
+
isLoading: h,
|
|
207
|
+
canDelete: L,
|
|
208
|
+
hasLink: P,
|
|
209
|
+
backgroundImage: S,
|
|
210
|
+
onLinkClick: $,
|
|
211
|
+
onDelete: j
|
|
201
212
|
},
|
|
202
|
-
|
|
213
|
+
r.id
|
|
203
214
|
)),
|
|
204
|
-
!
|
|
215
|
+
!n && Array.from({ length: z }, (r, e) => /* @__PURE__ */ N(
|
|
205
216
|
M,
|
|
206
217
|
{
|
|
207
|
-
onDrop:
|
|
208
|
-
accept:
|
|
209
|
-
multiple:
|
|
210
|
-
isLoading:
|
|
211
|
-
isError:
|
|
218
|
+
onDrop: Q,
|
|
219
|
+
accept: G,
|
|
220
|
+
multiple: f !== 1,
|
|
221
|
+
isLoading: h,
|
|
222
|
+
isError: m,
|
|
212
223
|
width: y,
|
|
213
|
-
height:
|
|
224
|
+
height: d,
|
|
214
225
|
children: [
|
|
215
|
-
|
|
216
|
-
|
|
226
|
+
I && /* @__PURE__ */ o(F, { size: 36, color: m ? O : R }),
|
|
227
|
+
s && /* @__PURE__ */ o(
|
|
217
228
|
"div",
|
|
218
229
|
{
|
|
219
|
-
className: `${
|
|
220
|
-
children:
|
|
230
|
+
className: `${p.PlaceholderText}${m ? ` ${p.PlaceholderTextError}` : ""}`,
|
|
231
|
+
children: k(e)
|
|
221
232
|
}
|
|
222
233
|
)
|
|
223
234
|
]
|
|
@@ -225,7 +236,7 @@ const At = ({
|
|
|
225
236
|
`placeholder-${e}`
|
|
226
237
|
))
|
|
227
238
|
] }) }) }) }),
|
|
228
|
-
|
|
239
|
+
m && /* @__PURE__ */ o(et.Error, { mt: 8, children: E })
|
|
229
240
|
] });
|
|
230
241
|
};
|
|
231
242
|
export {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e = "styles-module__Container___cJqG-", t = "styles-
|
|
2
|
+
const e = "styles-module__Container___cJqG-", t = "styles-module__Stage___zAHL-", l = "styles-module__Empty___gexrS", _ = "styles-module__PlaceholderText___x2ya0", o = "styles-module__PlaceholderTextError___i8VXv", r = {
|
|
3
3
|
Container: e,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
Stage: t,
|
|
5
|
+
Empty: l,
|
|
6
|
+
PlaceholderText: _,
|
|
6
7
|
PlaceholderTextError: o
|
|
7
8
|
};
|
|
8
9
|
export {
|
|
9
10
|
e as Container,
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
l as Empty,
|
|
12
|
+
_ as PlaceholderText,
|
|
12
13
|
o as PlaceholderTextError,
|
|
14
|
+
t as Stage,
|
|
13
15
|
r as default
|
|
14
16
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -231,6 +231,8 @@ export declare interface ILottieInputProps {
|
|
|
231
231
|
readOnly?: boolean;
|
|
232
232
|
gap?: number;
|
|
233
233
|
canDelete?: boolean;
|
|
234
|
+
/** 로띠 아래에 깔 이미지 주소. 앱처럼 이미지 위에 로띠를 겹쳐 미리본다. */
|
|
235
|
+
backgroundImage?: string;
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
export declare const ImageInput: ({ value, onChange, accept, length, width, height, placeholder, hasIcon, hasLink, onLinkClick, hasEdit, canDelete, minLength, maxLength, errorMsg, isLoading, readOnly, gap, }: IImageInputProps) => JSX.Element;
|
|
@@ -445,7 +447,7 @@ export declare interface IUseLocationOptions {
|
|
|
445
447
|
errorDescription?: string;
|
|
446
448
|
}
|
|
447
449
|
|
|
448
|
-
export declare const LottieInput: ({ value, onChange, width, height, placeholder, hasIcon, hasLink, onLinkClick, length, minLength, maxLength, errorMsg, isLoading, readOnly, gap, canDelete, }: ILottieInputProps) => JSX.Element;
|
|
450
|
+
export declare const LottieInput: ({ value, onChange, width, height, placeholder, hasIcon, hasLink, onLinkClick, length, minLength, maxLength, errorMsg, isLoading, readOnly, gap, canDelete, backgroundImage, }: ILottieInputProps) => JSX.Element;
|
|
449
451
|
|
|
450
452
|
/**
|
|
451
453
|
* Naver Maps Marker Clustering utility
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pop-ui/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.7",
|
|
5
5
|
"main": "./dist/core.umd.cjs",
|
|
6
6
|
"module": "./dist/core.js",
|
|
7
7
|
"types": "./dist/types/index.d.ts",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@dnd-kit/core": "^6.3.1",
|
|
48
48
|
"@dnd-kit/sortable": "^10.0.0",
|
|
49
49
|
"@dnd-kit/utilities": "^3.2.2",
|
|
50
|
-
"@pop-ui/foundation": "2.2.
|
|
50
|
+
"@pop-ui/foundation": "2.2.7",
|
|
51
51
|
"dayjs": "^1.11.18",
|
|
52
52
|
"lottie-react": "^2.4.1",
|
|
53
53
|
"react-easy-crop": "^5.5.3"
|