@dotss/tictoccroc 0.11.0 → 0.11.2
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/shared/components/Carousel/Carousel.mjs +104 -98
- package/dist/shared/components/Carousel/Carousel.utils.d.ts +8 -0
- package/dist/shared/components/Carousel/Carousel.utils.mjs +12 -0
- package/dist/shared/components/Carousel/Carousel.utils.test.d.ts +1 -0
- package/dist/shared/components/ChatKit/BotMessage/BotMessage.d.ts +2 -2
- package/dist/shared/components/ChatKit/BotMessage/BotMessage.utils.d.ts +1 -1
- package/dist/shared/components/ChatKit/BotMessage/BotMessage.utils.mjs +2 -0
- package/dist/shared/components/Swiper/Swiper.mjs +137 -136
- package/dist/shared/components/Swiper/Swiper.utils.d.ts +10 -0
- package/dist/shared/components/Swiper/Swiper.utils.mjs +13 -2
- package/dist/shared/components/Swiper/Swiper.utils.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
import e from "./
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import l from "@dotss/ui
|
|
5
|
-
import
|
|
1
|
+
import { getCarouselSwipeDelta as e } from "./Carousel.utils.mjs";
|
|
2
|
+
import t from "./CarouselSlide/index.mjs";
|
|
3
|
+
import { Children as n, cloneElement as r, isValidElement as i, useCallback as a, useEffect as o, useRef as s, useState as c } from "react";
|
|
4
|
+
import { Flexbox as l } from "@dotss/ui";
|
|
5
|
+
import u from "@dotss/ui/core/useTheme";
|
|
6
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
6
7
|
//#region shared/components/Carousel/Carousel.tsx
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
let { spacing:
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
if (!
|
|
13
|
-
let e = (
|
|
14
|
-
|
|
15
|
-
let i =
|
|
16
|
-
t ? i =
|
|
17
|
-
},
|
|
18
|
-
if (!
|
|
19
|
-
|
|
20
|
-
let n = e === 1, r = e ===
|
|
21
|
-
n ?
|
|
8
|
+
var p = 5;
|
|
9
|
+
function m({ children: m, spacing: h = 2, edgeSpacing: g = 4, rowCount: _ = 2, step: v = 1, renderPagination: y, ...b }) {
|
|
10
|
+
let { spacing: x } = u(), [S, C] = c(1), [w, T] = c(1), [E, D] = c(0), O = s(null), k = s(null), A = s(null), j = s(0), M = s(0), N = s(0), P = s(!1), F = s(!0), I = s(0), L = x.content(h), R = x.content(g), z = n.toArray(m).filter(i).filter((e) => e.type === t), B = z.length, V = (e, t) => {
|
|
11
|
+
j.current = e, M.current = t;
|
|
12
|
+
}, H = () => {
|
|
13
|
+
if (!k.current || !P.current) return;
|
|
14
|
+
let e = (A.current?.offsetWidth || 0) * .01, t = -N.current >= e && S + 1 <= w, n = -N.current <= -e && S - 1 >= 1, r = Math.abs(N.current) >= p;
|
|
15
|
+
P.current = !1, F.current = !r, N.current = 0;
|
|
16
|
+
let i = S;
|
|
17
|
+
t ? i = S + 1 : n && (i = S - 1), k.current.style.transition = "transform 0.2s", k.current.style.cursor = "grab", U(i);
|
|
18
|
+
}, U = a((e, t = 0) => {
|
|
19
|
+
if (!k.current) return;
|
|
20
|
+
C(e);
|
|
21
|
+
let n = e === 1, r = e === w, i = (O.current?.offsetWidth || 0) - R, a = (A.current?.children[0]?.clientWidth || 0) + L, o = (i - a * Math.floor(i / a) - L) / 2, s = a * (e - 1) - o;
|
|
22
|
+
n ? k.current.style.transform = `translate3d(${t}px, 0, 0)` : r ? k.current.style.transform = `translate3d(${-(s - o) + t}px, 0, 0)` : k.current.style.transform = `translate3d(${-s + t}px, 0, 0)`;
|
|
22
23
|
}, [
|
|
24
|
+
R,
|
|
23
25
|
L,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}, K = (e) => (t) => {
|
|
26
|
+
w
|
|
27
|
+
]), W = (e) => V(e.touches[0].clientX, e.touches[0].clientY), G = (e) => {
|
|
28
|
+
P.current = !0, V(e.clientX, e.clientY);
|
|
29
|
+
}, K = (e) => {
|
|
30
|
+
k.current && (k.current.style.transition = "transform 0.2s", k.current.style.cursor = "grab", U(e));
|
|
31
|
+
}, q = (e) => (t) => {
|
|
31
32
|
t.stopPropagation();
|
|
32
|
-
let n = Array.from(
|
|
33
|
+
let n = Array.from(A.current?.children || []).indexOf(t.currentTarget), r = (O.current?.offsetWidth || 0) - R * 2, i = (A.current?.children[0]?.clientWidth || 0) + L, a = Math.floor(r / (i / v)) * _, o = (S - 1) * a, s = o + a - 1, c = A.current?.children.length || 0, l = n % _, u = Math.floor(n / _), d = n;
|
|
33
34
|
switch (t.key) {
|
|
34
35
|
case "ArrowRight": {
|
|
35
36
|
t.preventDefault();
|
|
36
|
-
let e = (u + 1) *
|
|
37
|
+
let e = (u + 1) * _ + l;
|
|
37
38
|
e < c && (d = e);
|
|
38
39
|
break;
|
|
39
40
|
}
|
|
40
41
|
case "ArrowLeft": {
|
|
41
42
|
t.preventDefault();
|
|
42
|
-
let e = (u - 1) *
|
|
43
|
+
let e = (u - 1) * _ + l;
|
|
43
44
|
e >= 0 && (d = e);
|
|
44
45
|
break;
|
|
45
46
|
}
|
|
46
47
|
case "ArrowDown": {
|
|
47
48
|
t.preventDefault();
|
|
48
49
|
let e = n + 1;
|
|
49
|
-
e < c && e %
|
|
50
|
+
e < c && e % _ > l && (d = e);
|
|
50
51
|
break;
|
|
51
52
|
}
|
|
52
53
|
case "ArrowUp": {
|
|
53
54
|
t.preventDefault();
|
|
54
55
|
let e = n - 1;
|
|
55
|
-
e >= 0 && e %
|
|
56
|
+
e >= 0 && e % _ < l && (d = e);
|
|
56
57
|
break;
|
|
57
58
|
}
|
|
58
59
|
case "Enter":
|
|
@@ -62,124 +63,129 @@ function p({ children: p, spacing: m = 2, edgeSpacing: h = 4, rowCount: g = 2, s
|
|
|
62
63
|
default: return;
|
|
63
64
|
}
|
|
64
65
|
if (d >= o && d <= s) {
|
|
65
|
-
(
|
|
66
|
+
(A.current?.children[d])?.focus();
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
|
-
d >= 0 && d < c && (
|
|
69
|
-
(
|
|
69
|
+
d >= 0 && d < c && (I.current = requestAnimationFrame(() => {
|
|
70
|
+
(A.current?.children[d])?.focus();
|
|
70
71
|
})), e?.(t);
|
|
71
|
-
},
|
|
72
|
-
e.propertyName === "transform" && (
|
|
73
|
-
},
|
|
74
|
-
|
|
72
|
+
}, J = (e) => {
|
|
73
|
+
e.propertyName === "transform" && (F.current = !0);
|
|
74
|
+
}, Y = (e) => (t) => {
|
|
75
|
+
D(Number(t.currentTarget.getAttribute("aria-posinset")) - 1), e?.(t);
|
|
75
76
|
};
|
|
76
|
-
return
|
|
77
|
-
let e = () =>
|
|
77
|
+
return o(() => {
|
|
78
|
+
let e = () => U(S);
|
|
78
79
|
return e(), window.addEventListener("resize", e), () => {
|
|
79
80
|
window.removeEventListener("resize", e);
|
|
80
81
|
};
|
|
81
|
-
}, [
|
|
82
|
+
}, [U, S]), o(() => {
|
|
82
83
|
let e = () => {
|
|
83
|
-
let e = (
|
|
84
|
-
|
|
84
|
+
let e = (O.current?.offsetWidth || 0) - R * 2, t = (A.current?.children[0]?.clientWidth || 0) + L, n = Math.floor(e / (t / v)), r = Math.ceil(B / (_ || 1)), i = Math.max(r - (n - 1), 1);
|
|
85
|
+
C((e) => e > i ? i : e), T(i);
|
|
85
86
|
};
|
|
86
87
|
return e(), window.addEventListener("resize", e), () => {
|
|
87
88
|
window.removeEventListener("resize", e);
|
|
88
89
|
};
|
|
89
90
|
}, [
|
|
91
|
+
R,
|
|
90
92
|
L,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
B,
|
|
94
|
+
v,
|
|
93
95
|
_,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
m
|
|
97
|
+
]), o(() => {
|
|
98
|
+
let t = k.current, n = (n, r, i) => {
|
|
99
|
+
if (!t || w <= 1) return;
|
|
100
|
+
t.style.transition = "none", t.style.cursor = "grabbing", N.current = n - j.current;
|
|
101
|
+
let a = r - M.current;
|
|
102
|
+
P.current = P.current || Math.abs(N.current) > 5 && Math.abs(a) < 10, P.current && (i.cancelable && (i.stopPropagation(), i.preventDefault()), t.style.transition = "none", t.style.cursor = "grabbing", U(S, e({
|
|
103
|
+
fingerDeltaX: N.current,
|
|
104
|
+
page: S,
|
|
105
|
+
totalPages: w,
|
|
106
|
+
width: O.current?.offsetWidth ?? 0
|
|
107
|
+
})));
|
|
108
|
+
}, r = (e) => n(e.touches[0].clientX, e.touches[0].clientY, e), i = (e) => {
|
|
109
|
+
P.current && n(e.clientX, e.clientY, e);
|
|
104
110
|
};
|
|
105
|
-
return
|
|
106
|
-
|
|
111
|
+
return t && (t.addEventListener("mousemove", i), t.addEventListener("touchmove", r)), () => {
|
|
112
|
+
t && (t.removeEventListener("mousemove", i), t.removeEventListener("touchmove", r));
|
|
107
113
|
};
|
|
108
114
|
}, [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
]),
|
|
113
|
-
|
|
114
|
-
}, []),
|
|
115
|
-
let e =
|
|
116
|
-
|
|
115
|
+
U,
|
|
116
|
+
S,
|
|
117
|
+
w
|
|
118
|
+
]), o(() => () => {
|
|
119
|
+
I.current && cancelAnimationFrame(I.current);
|
|
120
|
+
}, []), o(() => {
|
|
121
|
+
let e = A.current, t = (e) => {
|
|
122
|
+
F.current || (e.stopPropagation(), e.preventDefault());
|
|
117
123
|
};
|
|
118
124
|
return e?.addEventListener("click", t), () => {
|
|
119
125
|
e?.removeEventListener("click", t);
|
|
120
126
|
};
|
|
121
|
-
}, []), /* @__PURE__ */
|
|
127
|
+
}, []), /* @__PURE__ */ f(l, {
|
|
122
128
|
flexDirection: "column",
|
|
123
129
|
role: "list",
|
|
124
130
|
"aria-roledescription": "carousel",
|
|
125
131
|
"aria-label": "슬라이더",
|
|
126
132
|
flexGrow: 1,
|
|
127
|
-
...
|
|
133
|
+
...b,
|
|
128
134
|
inlineCSS: {
|
|
129
135
|
width: "100%",
|
|
130
|
-
...
|
|
136
|
+
...b?.inlineCSS
|
|
131
137
|
},
|
|
132
|
-
children: [/* @__PURE__ */
|
|
133
|
-
ref:
|
|
138
|
+
children: [/* @__PURE__ */ d(l, {
|
|
139
|
+
ref: O,
|
|
134
140
|
inlineCSS: { overflow: "hidden" },
|
|
135
|
-
children: /* @__PURE__ */
|
|
136
|
-
ref:
|
|
137
|
-
onMouseDown:
|
|
138
|
-
onMouseUp:
|
|
139
|
-
onMouseLeave:
|
|
140
|
-
onTouchStart:
|
|
141
|
-
onTouchEnd:
|
|
142
|
-
onTouchCancel:
|
|
143
|
-
onTransitionEnd:
|
|
141
|
+
children: /* @__PURE__ */ d(l, {
|
|
142
|
+
ref: k,
|
|
143
|
+
onMouseDown: G,
|
|
144
|
+
onMouseUp: H,
|
|
145
|
+
onMouseLeave: H,
|
|
146
|
+
onTouchStart: W,
|
|
147
|
+
onTouchEnd: H,
|
|
148
|
+
onTouchCancel: H,
|
|
149
|
+
onTransitionEnd: J,
|
|
144
150
|
inlineCSS: {
|
|
145
|
-
gap:
|
|
146
|
-
paddingLeft:
|
|
147
|
-
paddingRight:
|
|
151
|
+
gap: L,
|
|
152
|
+
paddingLeft: R,
|
|
153
|
+
paddingRight: R,
|
|
148
154
|
transition: "transform 0.2s",
|
|
149
155
|
transform: "translate3d(0, 0, 0)",
|
|
150
156
|
cursor: "grab"
|
|
151
157
|
},
|
|
152
|
-
children: /* @__PURE__ */
|
|
153
|
-
ref:
|
|
158
|
+
children: /* @__PURE__ */ d(l, {
|
|
159
|
+
ref: A,
|
|
154
160
|
inlineCSS: {
|
|
155
|
-
gap:
|
|
161
|
+
gap: L,
|
|
156
162
|
display: "grid",
|
|
157
163
|
gridTemplateRows: "min-content",
|
|
158
164
|
transform: "translate3d(0, 0, 0)"
|
|
159
165
|
},
|
|
160
|
-
children:
|
|
166
|
+
children: n.map(z, (e, t) => r(e, {
|
|
161
167
|
role: "listitem",
|
|
162
|
-
tabIndex: t ===
|
|
168
|
+
tabIndex: t === E ? 0 : -1,
|
|
163
169
|
"aria-roledescription": "slide",
|
|
164
|
-
"aria-label": `${
|
|
170
|
+
"aria-label": `${B}개 중 ${t + 1}번째 슬라이드`,
|
|
165
171
|
"aria-posinset": t + 1,
|
|
166
|
-
"aria-setsize":
|
|
167
|
-
onKeyDown:
|
|
168
|
-
onFocus:
|
|
172
|
+
"aria-setsize": B,
|
|
173
|
+
onKeyDown: q(e.props.onKeyDown),
|
|
174
|
+
onFocus: Y(e.props.onFocus),
|
|
169
175
|
...e.props,
|
|
170
176
|
style: {
|
|
171
177
|
...e.props?.style,
|
|
172
|
-
gridRow: `${t %
|
|
178
|
+
gridRow: `${t % _ + 1} / ${t % _ + 1}`
|
|
173
179
|
}
|
|
174
180
|
}))
|
|
175
181
|
})
|
|
176
182
|
})
|
|
177
|
-
}), typeof
|
|
178
|
-
page:
|
|
179
|
-
totalPages:
|
|
180
|
-
onChange:
|
|
183
|
+
}), typeof y == "function" && y({
|
|
184
|
+
page: S,
|
|
185
|
+
totalPages: w,
|
|
186
|
+
onChange: K
|
|
181
187
|
})]
|
|
182
188
|
});
|
|
183
189
|
}
|
|
184
190
|
//#endregion
|
|
185
|
-
export {
|
|
191
|
+
export { m as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const EDGE_RESISTANCE = 0.55;
|
|
2
|
+
export declare function addDamping(distance: number, maxDistance: number, constant?: number): number;
|
|
3
|
+
export declare function getCarouselSwipeDelta({ fingerDeltaX, page, totalPages, width }: {
|
|
4
|
+
fingerDeltaX: number;
|
|
5
|
+
page: number;
|
|
6
|
+
totalPages: number;
|
|
7
|
+
width: number;
|
|
8
|
+
}): number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region shared/components/Carousel/Carousel.utils.tsx
|
|
2
|
+
var e = .55;
|
|
3
|
+
function t(t, n, r = e) {
|
|
4
|
+
if (t === 0 || n <= 0) return 0;
|
|
5
|
+
let i = Math.abs(t), a = i * n * r / (n + r * i);
|
|
6
|
+
return Math.sign(t) * a;
|
|
7
|
+
}
|
|
8
|
+
function n({ fingerDeltaX: e, page: n, totalPages: r, width: i }) {
|
|
9
|
+
return !(n === 1 && e > 0) && !(n === r && e < 0) ? e : t(e, i);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { e as EDGE_RESISTANCE, t as addDamping, n as getCarouselSwipeDelta };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FlexboxProps } from 'node_modules/@dotss/ui/Flexbox/Flexbox';
|
|
2
|
-
export type BotMessageType = 'TEACHER_INQUIRED' | 'PARENT_CHANGED_OFFER_SCHEDULE' | 'PARENT_CHANGED_MATCHING_SCHEDULE' | 'TEACHER_APPLIED' | 'PARENT_SENT_OFFER' | 'KOK_MATCHING_SUCCEEDED' | 'APPLICATION_MATCHING_SUCCEEDED' | 'ASSIGNMENT_MATCHING_SUCCEEDED' | 'PARENT_REJECTED_APPLICATION' | 'TEACHER_REFUSED_OFFER' | 'PARENT_CANCELED_MATCHING' | 'TEACHER_CANCELED_MATCHING' | 'TEACHER_COMPLETED_CARE' | 'ADMIN_CANCELED_MATCHING' | 'AUTO_MATCHING_SUCCEEDED' | 'PLAY_CONTENT_RECOMMENDED' | 'PARENT_REQUESTED_MATCHING_SCHEDULE_CHANGE' | 'TEACHER_ACCEPTED_MATCHING_SCHEDULE_CHANGE' | 'TEACHER_REFUSED_MATCHING_SCHEDULE_CHANGE' | 'MATCHING_SCHEDULE_CHANGE_EXPIRED' | 'ADMIN_CANCELED_OFFER' | 'TEACHER_BECAME_ROOKIE';
|
|
3
|
-
export type BotMessageCtaType = 'MY_CLASS_CHECK' | 'OFFER_CHECK' | 'CHANGE_INFO_CHECK' | 'MY_APPLICATION_INFO_VIEW' | 'CARE_NOTE_CHECK' | 'TEACHER_SELECTION' | 'PLAY_CONTENT_EXPLORE' | 'ACTIVITY_GUIDEBOOK_VIEW';
|
|
2
|
+
export type BotMessageType = 'TEACHER_INQUIRED' | 'PARENT_CHANGED_OFFER_SCHEDULE' | 'PARENT_CHANGED_MATCHING_SCHEDULE' | 'TEACHER_APPLIED' | 'PARENT_SENT_OFFER' | 'KOK_MATCHING_SUCCEEDED' | 'APPLICATION_MATCHING_SUCCEEDED' | 'ASSIGNMENT_MATCHING_SUCCEEDED' | 'PARENT_REJECTED_APPLICATION' | 'TEACHER_REFUSED_OFFER' | 'PARENT_CANCELED_MATCHING' | 'TEACHER_CANCELED_MATCHING' | 'TEACHER_COMPLETED_CARE' | 'ADMIN_CANCELED_MATCHING' | 'AUTO_MATCHING_SUCCEEDED' | 'PLAY_CONTENT_RECOMMENDED' | 'PARENT_REQUESTED_MATCHING_SCHEDULE_CHANGE' | 'TEACHER_ACCEPTED_MATCHING_SCHEDULE_CHANGE' | 'TEACHER_REFUSED_MATCHING_SCHEDULE_CHANGE' | 'MATCHING_SCHEDULE_CHANGE_EXPIRED' | 'ADMIN_CANCELED_OFFER' | 'TEACHER_BECAME_ROOKIE' | 'TEACHER_INTRO_NOT_WRITTEN_1_HOUR' | 'TEACHER_INTRO_NOT_WRITTEN_1_DAY' | 'TEACHER_INTRO_NOT_WRITTEN_3_DAY' | 'TEACHER_CONTRACT_NOT_SIGNED_IMMEDIATE' | 'TEACHER_CONTRACT_NOT_SIGNED_1_HOUR' | 'TEACHER_CONTRACT_NOT_SIGNED_1_DAY' | 'TEACHER_CONTRACT_NOT_SIGNED_3_DAY';
|
|
3
|
+
export type BotMessageCtaType = 'MY_CLASS_CHECK' | 'OFFER_CHECK' | 'CHANGE_INFO_CHECK' | 'MY_APPLICATION_INFO_VIEW' | 'CARE_NOTE_CHECK' | 'TEACHER_SELECTION' | 'PLAY_CONTENT_EXPLORE' | 'ACTIVITY_GUIDEBOOK_VIEW' | 'INTRO_WRITE' | 'CONTRACT_SIGN';
|
|
4
4
|
export type BotMessageCtaTargetTable = 'OFFER' | 'MATCHING';
|
|
5
5
|
export type BotMessageSubCtaTargetTable = 'OFFER' | 'MATCHING';
|
|
6
6
|
export interface BotMessageProps extends Omit<FlexboxProps, 'id' | 'title'> {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BotMessageCtaType, BotMessageProps } from '.';
|
|
2
|
-
export declare function getCtaButtonText(ctaType?: BotMessageCtaType | null): "" | "내 수업 확인하기" | "공고 확인하기" | "변경 내용 확인하기" | "나의 지원 내역 보러가기" | "돌봄노트 확인하기" | "선생님 선택하러 가기" | "놀이콘텐츠 둘러보기" | "활동 가이드북 보기";
|
|
2
|
+
export declare function getCtaButtonText(ctaType?: BotMessageCtaType | null): "" | "내 수업 확인하기" | "공고 확인하기" | "변경 내용 확인하기" | "나의 지원 내역 보러가기" | "돌봄노트 확인하기" | "선생님 선택하러 가기" | "놀이콘텐츠 둘러보기" | "활동 가이드북 보기" | "자기소개 작성하기" | "계약서 서명하기";
|
|
3
3
|
export declare function getBotMessageLabel({ title, content, regDatetime }: Pick<BotMessageProps, 'title' | 'content' | 'regDatetime'>): string;
|
|
@@ -10,6 +10,8 @@ function t(e) {
|
|
|
10
10
|
case "TEACHER_SELECTION": return "선생님 선택하러 가기";
|
|
11
11
|
case "PLAY_CONTENT_EXPLORE": return "놀이콘텐츠 둘러보기";
|
|
12
12
|
case "ACTIVITY_GUIDEBOOK_VIEW": return "활동 가이드북 보기";
|
|
13
|
+
case "INTRO_WRITE": return "자기소개 작성하기";
|
|
14
|
+
case "CONTRACT_SIGN": return "계약서 서명하기";
|
|
13
15
|
default: return "";
|
|
14
16
|
}
|
|
15
17
|
}
|
|
@@ -1,116 +1,117 @@
|
|
|
1
1
|
import e from "./SwiperBlock/index.mjs";
|
|
2
2
|
import t from "../MediaDialog/MediaBlock/index.mjs";
|
|
3
|
-
import { createSwipeEvent as n } from "./Swiper.utils.mjs";
|
|
4
|
-
import { Children as
|
|
5
|
-
import { Flexbox as
|
|
6
|
-
import { jsxs as
|
|
3
|
+
import { createSwipeEvent as n, getSwipingTranslateX as r } from "./Swiper.utils.mjs";
|
|
4
|
+
import { Children as i, cloneElement as a, isValidElement as o, useCallback as s, useEffect as c, useRef as l, useState as u } from "react";
|
|
5
|
+
import { Flexbox as d } from "@dotss/ui";
|
|
6
|
+
import { jsxs as f } from "react/jsx-runtime";
|
|
7
7
|
//#region shared/components/Swiper/Swiper.tsx
|
|
8
|
-
function
|
|
9
|
-
let [
|
|
10
|
-
!
|
|
11
|
-
},
|
|
12
|
-
if (!
|
|
13
|
-
|
|
14
|
-
let o = t ||
|
|
8
|
+
function p({ children: p, initialPage: m = 0, onSwipe: h, onSwiping: g, loop: _ = !1, disableSwipe: v = !1, renderPagination: y, inlineCSS: b, autoSwipe: x = !1, autoSwipeInterval: S = 3e3, autoSwipeDuration: C = 1e3, ...w }) {
|
|
9
|
+
let [T, E] = u(m), [D, O] = u(1), k = l(null), A = l(0), j = l(0), M = l(0), N = l(0), P = l(!1), F = l(!0), I = l(""), L = l(m), R = l(!1), z = l(null), B = i.count(p), V = i.toArray(p).filter(o).filter((n) => n.type === e || n.type === t), H = B > 1 && !v, U = i.toArray(V?.[0]).filter(o).filter((n) => n.type === e || n.type === t), W = i.toArray(V?.[V?.length - 1]).filter(o).filter((n) => n.type === e || n.type === t), G = (e, t, n) => {
|
|
10
|
+
!k.current || !H || (I.current = k.current.style.transform, j.current = e, A.current = e + k.current.offsetWidth * (n + 1), M.current = t);
|
|
11
|
+
}, K = s((e, t, r, { isAutoSwiped: i = !1, shouldFocus: a = !1 } = {}) => {
|
|
12
|
+
if (!k.current || !H || !P.current || !F.current) return;
|
|
13
|
+
F.current = !1, k.current.style.transition = i ? `transform ${C}ms` : "transform 0.2s", k.current.style.cursor = "grab", z.current &&= (k.current.removeEventListener("transitionend", z.current), null);
|
|
14
|
+
let o = t || T, s = r || A.current - k.current.offsetWidth * (o + 1) - e, c = k.current.offsetWidth * .1;
|
|
15
15
|
if (Math.abs(s) < c && !t) {
|
|
16
|
-
|
|
17
|
-
realPage:
|
|
18
|
-
totalPages:
|
|
19
|
-
lastPage:
|
|
16
|
+
k.current.style.transform = I.current, P.current = !1, F.current = !0, h?.(n({
|
|
17
|
+
realPage: L.current,
|
|
18
|
+
totalPages: D,
|
|
19
|
+
lastPage: L.current,
|
|
20
20
|
isLoop: !1
|
|
21
21
|
}));
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
let l = s <= -c && o - 1 < 0, u = s >= c && o + 1 ===
|
|
24
|
+
let l = _ && s <= -c && o - 1 < 0, u = _ && s >= c && o + 1 === D, d = s >= c && o + 1 < D, f = s <= -c && o - 1 >= 0;
|
|
25
25
|
if (l) {
|
|
26
|
-
|
|
27
|
-
realPage:
|
|
28
|
-
totalPages:
|
|
26
|
+
L.current = D - 1, h?.(n({
|
|
27
|
+
realPage: L.current,
|
|
28
|
+
totalPages: D,
|
|
29
29
|
lastPage: 0,
|
|
30
30
|
isLoop: !0
|
|
31
|
-
})),
|
|
31
|
+
})), k.current.style.transform = "translate3d(0, 0, 0)", z.current = (e) => {
|
|
32
32
|
if (e.propertyName === "transform") {
|
|
33
|
-
if (!
|
|
34
|
-
if (
|
|
33
|
+
if (!k.current) return;
|
|
34
|
+
if (k.current.style.transition = "none", k.current.style.transform = `translate3d(calc(-100% * ${D}), 0, 0)`, E(D - 1), P.current = !1, F.current = !0, a) (k.current?.children)?.[D]?.focus();
|
|
35
35
|
else {
|
|
36
36
|
if (i) return;
|
|
37
37
|
document.activeElement?.blur();
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
},
|
|
40
|
+
}, k.current.addEventListener("transitionend", z.current);
|
|
41
41
|
return;
|
|
42
42
|
} else if (u) {
|
|
43
|
-
|
|
44
|
-
realPage:
|
|
45
|
-
totalPages:
|
|
46
|
-
lastPage:
|
|
43
|
+
L.current = 0, h?.(n({
|
|
44
|
+
realPage: L.current,
|
|
45
|
+
totalPages: D,
|
|
46
|
+
lastPage: D - 1,
|
|
47
47
|
isLoop: !0
|
|
48
|
-
})),
|
|
48
|
+
})), k.current.style.transform = `translate3d(calc(-100% * ${o + 2}), 0, 0)`, z.current = (e) => {
|
|
49
49
|
if (e.propertyName === "transform") {
|
|
50
|
-
if (!
|
|
51
|
-
if (
|
|
50
|
+
if (!k.current) return;
|
|
51
|
+
if (k.current.style.transition = "none", k.current.style.transform = "translate3d(-100%, 0, 0)", E(0), P.current = !1, F.current = !0, a) (k.current?.children)?.[1]?.focus();
|
|
52
52
|
else {
|
|
53
53
|
if (i) return;
|
|
54
54
|
document.activeElement?.blur();
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
},
|
|
57
|
+
}, k.current.addEventListener("transitionend", z.current);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
d ? (
|
|
61
|
-
realPage:
|
|
62
|
-
totalPages:
|
|
60
|
+
d ? (L.current = o + 1, h?.(n({
|
|
61
|
+
realPage: L.current,
|
|
62
|
+
totalPages: D,
|
|
63
63
|
lastPage: o,
|
|
64
64
|
isLoop: !0
|
|
65
|
-
})),
|
|
66
|
-
realPage:
|
|
67
|
-
totalPages:
|
|
65
|
+
})), E(L.current), k.current.style.transform = `translate3d(calc(-100% * ${o + 2}), 0, 0)`) : f ? (L.current = o - 1, h?.(n({
|
|
66
|
+
realPage: L.current,
|
|
67
|
+
totalPages: D,
|
|
68
68
|
lastPage: o,
|
|
69
69
|
isLoop: !1
|
|
70
|
-
})),
|
|
71
|
-
realPage:
|
|
72
|
-
totalPages:
|
|
73
|
-
lastPage:
|
|
70
|
+
})), E(L.current), k.current.style.transform = `translate3d(calc(-100% * ${o}), 0, 0)`) : (h?.(n({
|
|
71
|
+
realPage: L.current,
|
|
72
|
+
totalPages: D,
|
|
73
|
+
lastPage: L.current,
|
|
74
74
|
isLoop: !1
|
|
75
|
-
})),
|
|
75
|
+
})), k.current.style.transform = I.current), z.current = (e) => {
|
|
76
76
|
if (e.propertyName === "transform") {
|
|
77
|
-
|
|
78
|
-
let e = Array.from(
|
|
77
|
+
P.current = !1, F.current = !0;
|
|
78
|
+
let e = Array.from(k.current?.children ?? []).find((e) => e.getAttribute("aria-current") === "page");
|
|
79
79
|
if (a && e) e.focus();
|
|
80
80
|
else {
|
|
81
81
|
if (i) return;
|
|
82
82
|
document.activeElement?.blur();
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
},
|
|
85
|
+
}, k.current.addEventListener("transitionend", z.current);
|
|
86
86
|
}, [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
T,
|
|
88
|
+
D,
|
|
89
|
+
h,
|
|
90
|
+
H,
|
|
91
|
+
C,
|
|
92
|
+
_
|
|
93
|
+
]), q = (e) => {
|
|
94
|
+
P.current = !0, G(e.clientX, e.clientY, L.current);
|
|
95
|
+
}, J = (e) => K(e.clientX), Y = (e) => {
|
|
96
|
+
G(e.touches[0].clientX, e.touches[0].clientY, L.current);
|
|
97
|
+
}, X = (e) => K(e.changedTouches[0].clientX), Z = (e) => {
|
|
98
|
+
P.current = !0;
|
|
98
99
|
let t = e - 1;
|
|
99
|
-
|
|
100
|
-
},
|
|
100
|
+
E(t <= 0 ? 0 : t), K(0, e);
|
|
101
|
+
}, Q = (e) => (t) => {
|
|
101
102
|
switch (t.key) {
|
|
102
103
|
case "ArrowRight": {
|
|
103
|
-
if (t.preventDefault(),
|
|
104
|
-
let e =
|
|
105
|
-
if (!
|
|
106
|
-
|
|
104
|
+
if (t.preventDefault(), P.current || !F.current) return;
|
|
105
|
+
let e = L.current === D - 1;
|
|
106
|
+
if (!_ && e) return;
|
|
107
|
+
P.current = !0, K(0, L.current, (k.current?.offsetWidth ?? 0) * .1, { shouldFocus: !0 });
|
|
107
108
|
break;
|
|
108
109
|
}
|
|
109
110
|
case "ArrowLeft": {
|
|
110
|
-
if (t.preventDefault(),
|
|
111
|
-
let e =
|
|
112
|
-
if (!
|
|
113
|
-
|
|
111
|
+
if (t.preventDefault(), P.current || !F.current) return;
|
|
112
|
+
let e = L.current === 0;
|
|
113
|
+
if (!_ && e) return;
|
|
114
|
+
P.current = !0, K(0, L.current, -((k.current?.offsetWidth ?? 0) * .1), { shouldFocus: !0 });
|
|
114
115
|
break;
|
|
115
116
|
}
|
|
116
117
|
case "Enter":
|
|
@@ -122,90 +123,90 @@ function f({ children: f, initialPage: p = 0, onSwipe: m, onSwiping: h, loop: g
|
|
|
122
123
|
}
|
|
123
124
|
e?.(t);
|
|
124
125
|
};
|
|
125
|
-
return
|
|
126
|
-
let e =
|
|
127
|
-
if (!(!
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
if (!g && i && I.current === E - 1) {
|
|
134
|
-
N.current = !1;
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
r.cancelable && r.preventDefault(), h?.(n({
|
|
138
|
-
realPage: I.current,
|
|
139
|
-
totalPages: E,
|
|
140
|
-
lastPage: I.current,
|
|
126
|
+
return c(() => {
|
|
127
|
+
let e = k.current, t = (e, t, i) => {
|
|
128
|
+
if (!(!k.current || !H || !F.current) && (N.current = e - A.current, P.current = P.current || Math.abs(N.current) > 5 && Math.abs(t - M.current) < 5, P.current)) {
|
|
129
|
+
i.cancelable && i.preventDefault(), g?.(n({
|
|
130
|
+
realPage: L.current,
|
|
131
|
+
totalPages: D,
|
|
132
|
+
lastPage: L.current,
|
|
141
133
|
isLoop: !1
|
|
142
|
-
}))
|
|
134
|
+
}));
|
|
135
|
+
let t = r({
|
|
136
|
+
rawTranslateX: N.current,
|
|
137
|
+
fingerDeltaX: e - j.current,
|
|
138
|
+
page: L.current,
|
|
139
|
+
totalPages: D,
|
|
140
|
+
width: k.current.offsetWidth,
|
|
141
|
+
loop: _
|
|
142
|
+
});
|
|
143
|
+
k.current.style.transition = "none", k.current.style.cursor = "grabbing", k.current.style.transform = `translate3d(${t}px, 0, 0)`;
|
|
143
144
|
}
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
},
|
|
147
|
-
return e && (e.addEventListener("mousemove",
|
|
148
|
-
e && (e.removeEventListener("mousemove",
|
|
145
|
+
}, i = (e) => {
|
|
146
|
+
P.current && t(e.clientX, e.clientY, e);
|
|
147
|
+
}, a = (e) => t(e.touches[0].clientX, e.touches[0].clientY, e);
|
|
148
|
+
return e && (e.addEventListener("mousemove", i), e.addEventListener("touchmove", a)), () => {
|
|
149
|
+
e && (e.removeEventListener("mousemove", i), e.removeEventListener("touchmove", a));
|
|
149
150
|
};
|
|
150
151
|
}, [
|
|
151
|
-
|
|
152
|
-
h,
|
|
152
|
+
H,
|
|
153
153
|
g,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
_,
|
|
155
|
+
D
|
|
156
|
+
]), c(() => {
|
|
157
|
+
let e = k.current, t = (e) => {
|
|
158
|
+
F.current || (e.stopPropagation(), e.preventDefault());
|
|
158
159
|
};
|
|
159
160
|
return e?.addEventListener("click", t), () => {
|
|
160
161
|
e?.removeEventListener("click", t);
|
|
161
162
|
};
|
|
162
|
-
}, []),
|
|
163
|
-
let e =
|
|
163
|
+
}, []), c(() => {
|
|
164
|
+
let e = k.current;
|
|
164
165
|
return () => {
|
|
165
|
-
|
|
166
|
+
z.current && e && (e.removeEventListener("transitionend", z.current), z.current = null);
|
|
166
167
|
};
|
|
167
|
-
}, []),
|
|
168
|
-
|
|
169
|
-
}, [
|
|
170
|
-
|
|
171
|
-
}, [
|
|
172
|
-
if (
|
|
168
|
+
}, []), c(() => {
|
|
169
|
+
O(B);
|
|
170
|
+
}, [B]), c(() => {
|
|
171
|
+
k.current && !R.current && (R.current = !0, k.current.style.transition = "none", k.current.style.transform = `translate3d(calc(-100% * ${B < m + 1 ? B : m + 1}), 0, 0)`);
|
|
172
|
+
}, [m, B]), c(() => {
|
|
173
|
+
if (x) {
|
|
173
174
|
let e = setInterval(() => {
|
|
174
|
-
|
|
175
|
-
},
|
|
175
|
+
P.current || !F.current || k.current && (!_ && L.current === D - 1 || document.activeElement && k.current && k.current.contains(document.activeElement) || (P.current = !0, K(0, L.current, (k.current.offsetWidth ?? 0) * .1, { isAutoSwiped: !0 })));
|
|
176
|
+
}, S);
|
|
176
177
|
return () => {
|
|
177
178
|
clearInterval(e);
|
|
178
179
|
};
|
|
179
180
|
}
|
|
180
181
|
}, [
|
|
181
|
-
b,
|
|
182
182
|
x,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
S,
|
|
184
|
+
_,
|
|
185
|
+
D,
|
|
186
|
+
K
|
|
187
|
+
]), /* @__PURE__ */ f(d, {
|
|
187
188
|
flexGrow: 1,
|
|
188
189
|
role: "list",
|
|
189
190
|
"aria-roledescription": "carousel",
|
|
190
191
|
"aria-label": "슬라이더",
|
|
191
|
-
...
|
|
192
|
+
...w,
|
|
192
193
|
inlineCSS: {
|
|
193
194
|
width: "100%",
|
|
194
195
|
position: "relative",
|
|
195
|
-
...
|
|
196
|
+
...b
|
|
196
197
|
},
|
|
197
|
-
children: [/* @__PURE__ */ d
|
|
198
|
-
ref:
|
|
198
|
+
children: [/* @__PURE__ */ f(d, {
|
|
199
|
+
ref: k,
|
|
199
200
|
flexGrow: 1,
|
|
200
|
-
onMouseDown:
|
|
201
|
-
onMouseUp:
|
|
202
|
-
onMouseLeave:
|
|
203
|
-
onTouchStart:
|
|
204
|
-
onTouchEnd:
|
|
205
|
-
onTouchCancel:
|
|
201
|
+
onMouseDown: q,
|
|
202
|
+
onMouseUp: J,
|
|
203
|
+
onMouseLeave: J,
|
|
204
|
+
onTouchStart: Y,
|
|
205
|
+
onTouchEnd: X,
|
|
206
|
+
onTouchCancel: X,
|
|
206
207
|
inlineCSS: {
|
|
207
|
-
"& > div:first-of-type": { visibility:
|
|
208
|
-
"& > div:last-of-type": { visibility:
|
|
208
|
+
"& > div:first-of-type": { visibility: _ ? "visible" : "hidden" },
|
|
209
|
+
"& > div:last-of-type": { visibility: _ ? "visible" : "hidden" }
|
|
209
210
|
},
|
|
210
211
|
style: {
|
|
211
212
|
transition: "transform 0.2s",
|
|
@@ -213,27 +214,27 @@ function f({ children: f, initialPage: p = 0, onSwipe: m, onSwiping: h, loop: g
|
|
|
213
214
|
cursor: "grab"
|
|
214
215
|
},
|
|
215
216
|
children: [
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
W,
|
|
218
|
+
V.map((e, t) => a(e, {
|
|
218
219
|
role: "listitem",
|
|
219
|
-
tabIndex: t ===
|
|
220
|
-
onKeyDown:
|
|
220
|
+
tabIndex: t === T ? 0 : -1,
|
|
221
|
+
onKeyDown: Q(e.props.onKeyDown),
|
|
221
222
|
"aria-roledescription": "slide",
|
|
222
|
-
"aria-hidden": t !==
|
|
223
|
-
"aria-current": t ===
|
|
224
|
-
"aria-label": `${
|
|
223
|
+
"aria-hidden": t !== T,
|
|
224
|
+
"aria-current": t === T ? "page" : void 0,
|
|
225
|
+
"aria-label": `${D}개 중 ${t + 1}번째 슬라이드`,
|
|
225
226
|
"aria-posinset": t + 1,
|
|
226
|
-
"aria-setsize":
|
|
227
|
+
"aria-setsize": D,
|
|
227
228
|
...e.props
|
|
228
229
|
})),
|
|
229
|
-
|
|
230
|
+
U
|
|
230
231
|
]
|
|
231
|
-
}), typeof
|
|
232
|
-
page:
|
|
233
|
-
totalPages:
|
|
234
|
-
onChange:
|
|
232
|
+
}), typeof y == "function" && y({
|
|
233
|
+
page: T,
|
|
234
|
+
totalPages: D,
|
|
235
|
+
onChange: Z
|
|
235
236
|
})]
|
|
236
237
|
});
|
|
237
238
|
}
|
|
238
239
|
//#endregion
|
|
239
|
-
export {
|
|
240
|
+
export { p as default };
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export declare const EDGE_RESISTANCE = 0.35;
|
|
2
|
+
export declare function addDamping(distance: number, maxDistance: number, constant?: number): number;
|
|
3
|
+
export declare function getSwipingTranslateX({ rawTranslateX, fingerDeltaX, page, totalPages, width, loop }: {
|
|
4
|
+
rawTranslateX: number;
|
|
5
|
+
fingerDeltaX: number;
|
|
6
|
+
page: number;
|
|
7
|
+
totalPages: number;
|
|
8
|
+
width: number;
|
|
9
|
+
loop: boolean;
|
|
10
|
+
}): number;
|
|
1
11
|
export declare function createSwipeEvent({ realPage, totalPages, lastPage, isLoop }: {
|
|
2
12
|
realPage: number;
|
|
3
13
|
totalPages: number;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
//#region shared/components/Swiper/Swiper.utils.ts
|
|
2
|
-
|
|
2
|
+
var e = .35;
|
|
3
|
+
function t(t, n, r = e) {
|
|
4
|
+
if (t === 0 || n <= 0) return 0;
|
|
5
|
+
let i = Math.abs(t), a = i * n * r / (n + r * i);
|
|
6
|
+
return Math.sign(t) * a;
|
|
7
|
+
}
|
|
8
|
+
function n({ rawTranslateX: e, fingerDeltaX: n, page: r, totalPages: i, width: a, loop: o }) {
|
|
9
|
+
if (o) return e;
|
|
10
|
+
let s = r === 0 && n > 0, c = r === i - 1 && n < 0;
|
|
11
|
+
return !s && !c ? e : -a * (r + 1) + t(n, a);
|
|
12
|
+
}
|
|
13
|
+
function r({ realPage: e, totalPages: t, lastPage: n, isLoop: r }) {
|
|
3
14
|
return r ? {
|
|
4
15
|
isFirstPage: e === 0,
|
|
5
16
|
isLastPage: e === t - 1,
|
|
@@ -17,4 +28,4 @@ function e({ realPage: e, totalPages: t, lastPage: n, isLoop: r }) {
|
|
|
17
28
|
};
|
|
18
29
|
}
|
|
19
30
|
//#endregion
|
|
20
|
-
export { e as createSwipeEvent };
|
|
31
|
+
export { e as EDGE_RESISTANCE, t as addDamping, r as createSwipeEvent, n as getSwipingTranslateX };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED