@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 $, 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";
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 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(
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
- ), q = { "application/json": [".json"] };
24
- function G({
23
+ ), G = { "application/json": [".json"] };
24
+ function K({
25
25
  item: t,
26
26
  sortableId: i,
27
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
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 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 });
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
- u || S({ key: l, data: null });
47
+ f || L({ key: n, data: null });
47
48
  }), () => {
48
- u = !0;
49
+ f = !0;
49
50
  };
50
- }, [l, t.file, t.url]), /* @__PURE__ */ o(
51
- dt,
51
+ }, [n, t.file, t.url]), /* @__PURE__ */ o(
52
+ ft,
52
53
  {
53
54
  id: i ?? t.id,
54
55
  totalCount: y,
55
- width: f,
56
- height: a,
57
- readOnly: D,
58
- isLoading: I,
56
+ width: d,
57
+ height: s,
58
+ readOnly: I,
59
+ isLoading: P,
59
60
  itemIsLoading: t.isLoading || C,
60
- canDelete: L,
61
- hasLink: E,
61
+ canDelete: $,
62
+ hasLink: A,
62
63
  linkUrl: t.url,
63
- onLinkClick: P ? () => P(t) : void 0,
64
- onDelete: () => g(t.id),
64
+ onLinkClick: v ? () => v(t) : void 0,
65
+ onDelete: () => E(t.id),
65
66
  deleteAriaLabel: "Lottie 삭제",
66
- children: h ? /* @__PURE__ */ o(nt, { fallback: /* @__PURE__ */ o("div", { style: { width: f, height: a, display: "block" } }), children: /* @__PURE__ */ o(
67
- ut,
67
+ children: /* @__PURE__ */ o(
68
+ "div",
68
69
  {
69
- animationData: h,
70
- loop: !0,
71
- autoplay: !0,
72
- style: { width: f, height: a, display: "block" }
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
- ) }) : /* @__PURE__ */ o("div", { className: x.Empty, style: { width: f, height: a } })
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: 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
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: 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({
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: 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, {
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[N].id,
118
- index: N
126
+ itemId: g[T].id,
127
+ index: T
119
128
  });
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({
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 d = it(t, r, n);
132
- i?.(d, {
140
+ const c = at(t, l, r);
141
+ i?.(c, {
133
142
  action: "create",
134
- itemId: d[d.length - 1].id,
135
- index: n
143
+ itemId: c[c.length - 1].id,
144
+ index: r
136
145
  });
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;
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((r, c) => /* @__PURE__ */ o("span", { children: r }, c));
153
+ `).map((l, a) => /* @__PURE__ */ o("span", { children: l }, a));
145
154
  };
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,
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: c,
153
- sortableId: r,
154
- totalCount: u,
161
+ item: a,
162
+ sortableId: l,
163
+ totalCount: f,
155
164
  width: y,
156
- height: f,
157
- readOnly: s ?? !1,
158
- isLoading: l,
159
- canDelete: h,
160
- hasLink: I,
161
- onLinkClick: L,
162
- onDelete: z
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
- r
165
- ) : !s && /* @__PURE__ */ o(ct, { id: r, children: /* @__PURE__ */ $(
174
+ l
175
+ ) : !n && /* @__PURE__ */ o(dt, { id: l, children: /* @__PURE__ */ N(
166
176
  M,
167
177
  {
168
- onDrop: (d) => Q(e, d),
169
- accept: q,
178
+ onDrop: (c) => W(e, c),
179
+ accept: G,
170
180
  multiple: !1,
171
- isLoading: l,
172
- isError: p,
181
+ isLoading: h,
182
+ isError: m,
173
183
  width: y,
174
- height: f,
184
+ height: d,
175
185
  children: [
176
- D && /* @__PURE__ */ o(_, { size: 36, color: p ? F : R }),
177
- a && /* @__PURE__ */ o(
186
+ I && /* @__PURE__ */ o(F, { size: 36, color: m ? O : R }),
187
+ s && /* @__PURE__ */ o(
178
188
  "div",
179
189
  {
180
- className: `${x.PlaceholderText}${p ? ` ${x.PlaceholderTextError}` : ""}`,
181
- children: J(e)
190
+ className: `${p.PlaceholderText}${m ? ` ${p.PlaceholderTextError}` : ""}`,
191
+ children: k(e)
182
192
  }
183
193
  )
184
194
  ]
185
195
  }
186
- ) }, r);
187
- }) : /* @__PURE__ */ $(W, { children: [
188
- t.map((n) => /* @__PURE__ */ o(
189
- G,
196
+ ) }, l);
197
+ }) : /* @__PURE__ */ N(X, { children: [
198
+ t.map((r) => /* @__PURE__ */ o(
199
+ K,
190
200
  {
191
- item: n,
201
+ item: r,
192
202
  totalCount: t.length,
193
203
  width: y,
194
- height: f,
195
- readOnly: s ?? !1,
196
- isLoading: l,
197
- canDelete: h,
198
- hasLink: I,
199
- onLinkClick: L,
200
- onDelete: z
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
- n.id
213
+ r.id
203
214
  )),
204
- !s && Array.from({ length: k }, (n, e) => /* @__PURE__ */ $(
215
+ !n && Array.from({ length: z }, (r, e) => /* @__PURE__ */ N(
205
216
  M,
206
217
  {
207
- onDrop: H,
208
- accept: q,
209
- multiple: u !== 1,
210
- isLoading: l,
211
- isError: p,
218
+ onDrop: Q,
219
+ accept: G,
220
+ multiple: f !== 1,
221
+ isLoading: h,
222
+ isError: m,
212
223
  width: y,
213
- height: f,
224
+ height: d,
214
225
  children: [
215
- D && /* @__PURE__ */ o(_, { size: 36, color: p ? F : R }),
216
- a && /* @__PURE__ */ o(
226
+ I && /* @__PURE__ */ o(F, { size: 36, color: m ? O : R }),
227
+ s && /* @__PURE__ */ o(
217
228
  "div",
218
229
  {
219
- className: `${x.PlaceholderText}${p ? ` ${x.PlaceholderTextError}` : ""}`,
220
- children: J(e)
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
- p && /* @__PURE__ */ o(tt.Error, { mt: 8, children: A })
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-module__Empty___gexrS", l = "styles-module__PlaceholderText___x2ya0", o = "styles-module__PlaceholderTextError___i8VXv", r = {
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
- Empty: t,
5
- PlaceholderText: l,
4
+ Stage: t,
5
+ Empty: l,
6
+ PlaceholderText: _,
6
7
  PlaceholderTextError: o
7
8
  };
8
9
  export {
9
10
  e as Container,
10
- t as Empty,
11
- l as PlaceholderText,
11
+ l as Empty,
12
+ _ as PlaceholderText,
12
13
  o as PlaceholderTextError,
14
+ t as Stage,
13
15
  r as default
14
16
  };
@@ -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.6",
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.6",
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"