@x-plat/design-system 0.16.1 → 0.16.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.
@@ -213,12 +213,33 @@ var Tour = (props) => {
213
213
  );
214
214
  useEscapeKey(open, () => onClose("skip"));
215
215
  useFocusTrap(cardRef, open, { trap: true });
216
+ const stepsRef = import_react3.default.useRef(steps);
217
+ stepsRef.current = steps;
216
218
  import_react3.default.useEffect(() => {
217
- if (!open || !step) return;
218
- const el = resolve(step.target);
219
- setTargetFound(!!el);
220
- el?.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
221
- }, [open, step]);
219
+ if (!open) return;
220
+ const target = stepsRef.current[index]?.target;
221
+ if (!target) return;
222
+ let stop = false;
223
+ let tries = 0;
224
+ const look = () => {
225
+ if (stop) return;
226
+ const el = resolve(target);
227
+ if (el) {
228
+ setTargetFound(true);
229
+ el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
230
+ return;
231
+ }
232
+ setTargetFound(false);
233
+ if (tries < 60) {
234
+ tries += 1;
235
+ requestAnimationFrame(look);
236
+ }
237
+ };
238
+ look();
239
+ return () => {
240
+ stop = true;
241
+ };
242
+ }, [open, index]);
222
243
  const place = import_react3.default.useCallback(() => {
223
244
  const spot = spotRef.current;
224
245
  const card = cardRef.current;
@@ -269,9 +290,20 @@ var Tour = (props) => {
269
290
  import_react3.default.useLayoutEffect(() => {
270
291
  if (!open) return;
271
292
  place();
272
- const t = setTimeout(place, 400);
273
- return () => clearTimeout(t);
274
- }, [open, place]);
293
+ let raf = 0;
294
+ let settled = 0;
295
+ let last = "";
296
+ const follow = () => {
297
+ const el = resolve(stepsRef.current[index]?.target ?? "");
298
+ const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
299
+ settled = now === last ? settled + 1 : 0;
300
+ last = now;
301
+ place();
302
+ if (settled < 3) raf = requestAnimationFrame(follow);
303
+ };
304
+ raf = requestAnimationFrame(follow);
305
+ return () => cancelAnimationFrame(raf);
306
+ }, [open, index, place]);
275
307
  import_react3.default.useEffect(() => {
276
308
  if (!open) return;
277
309
  const onMove = () => place();
@@ -177,12 +177,33 @@ var Tour = (props) => {
177
177
  );
178
178
  useEscapeKey(open, () => onClose("skip"));
179
179
  useFocusTrap(cardRef, open, { trap: true });
180
+ const stepsRef = React3.useRef(steps);
181
+ stepsRef.current = steps;
180
182
  React3.useEffect(() => {
181
- if (!open || !step) return;
182
- const el = resolve(step.target);
183
- setTargetFound(!!el);
184
- el?.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
185
- }, [open, step]);
183
+ if (!open) return;
184
+ const target = stepsRef.current[index]?.target;
185
+ if (!target) return;
186
+ let stop = false;
187
+ let tries = 0;
188
+ const look = () => {
189
+ if (stop) return;
190
+ const el = resolve(target);
191
+ if (el) {
192
+ setTargetFound(true);
193
+ el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
194
+ return;
195
+ }
196
+ setTargetFound(false);
197
+ if (tries < 60) {
198
+ tries += 1;
199
+ requestAnimationFrame(look);
200
+ }
201
+ };
202
+ look();
203
+ return () => {
204
+ stop = true;
205
+ };
206
+ }, [open, index]);
186
207
  const place = React3.useCallback(() => {
187
208
  const spot = spotRef.current;
188
209
  const card = cardRef.current;
@@ -233,9 +254,20 @@ var Tour = (props) => {
233
254
  React3.useLayoutEffect(() => {
234
255
  if (!open) return;
235
256
  place();
236
- const t = setTimeout(place, 400);
237
- return () => clearTimeout(t);
238
- }, [open, place]);
257
+ let raf = 0;
258
+ let settled = 0;
259
+ let last = "";
260
+ const follow = () => {
261
+ const el = resolve(stepsRef.current[index]?.target ?? "");
262
+ const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
263
+ settled = now === last ? settled + 1 : 0;
264
+ last = now;
265
+ place();
266
+ if (settled < 3) raf = requestAnimationFrame(follow);
267
+ };
268
+ raf = requestAnimationFrame(follow);
269
+ return () => cancelAnimationFrame(raf);
270
+ }, [open, index, place]);
239
271
  React3.useEffect(() => {
240
272
  if (!open) return;
241
273
  const onMove = () => place();
@@ -7744,12 +7744,33 @@ var Tour = (props) => {
7744
7744
  );
7745
7745
  useEscapeKey(open, () => onClose("skip"));
7746
7746
  useFocusTrap(cardRef, open, { trap: true });
7747
+ const stepsRef = import_react44.default.useRef(steps);
7748
+ stepsRef.current = steps;
7747
7749
  import_react44.default.useEffect(() => {
7748
- if (!open || !step) return;
7749
- const el = resolve(step.target);
7750
- setTargetFound(!!el);
7751
- el?.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
7752
- }, [open, step]);
7750
+ if (!open) return;
7751
+ const target = stepsRef.current[index]?.target;
7752
+ if (!target) return;
7753
+ let stop = false;
7754
+ let tries = 0;
7755
+ const look = () => {
7756
+ if (stop) return;
7757
+ const el = resolve(target);
7758
+ if (el) {
7759
+ setTargetFound(true);
7760
+ el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
7761
+ return;
7762
+ }
7763
+ setTargetFound(false);
7764
+ if (tries < 60) {
7765
+ tries += 1;
7766
+ requestAnimationFrame(look);
7767
+ }
7768
+ };
7769
+ look();
7770
+ return () => {
7771
+ stop = true;
7772
+ };
7773
+ }, [open, index]);
7753
7774
  const place = import_react44.default.useCallback(() => {
7754
7775
  const spot = spotRef.current;
7755
7776
  const card = cardRef.current;
@@ -7800,9 +7821,20 @@ var Tour = (props) => {
7800
7821
  import_react44.default.useLayoutEffect(() => {
7801
7822
  if (!open) return;
7802
7823
  place();
7803
- const t = setTimeout(place, 400);
7804
- return () => clearTimeout(t);
7805
- }, [open, place]);
7824
+ let raf = 0;
7825
+ let settled = 0;
7826
+ let last = "";
7827
+ const follow = () => {
7828
+ const el = resolve(stepsRef.current[index]?.target ?? "");
7829
+ const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
7830
+ settled = now === last ? settled + 1 : 0;
7831
+ last = now;
7832
+ place();
7833
+ if (settled < 3) raf = requestAnimationFrame(follow);
7834
+ };
7835
+ raf = requestAnimationFrame(follow);
7836
+ return () => cancelAnimationFrame(raf);
7837
+ }, [open, index, place]);
7806
7838
  import_react44.default.useEffect(() => {
7807
7839
  if (!open) return;
7808
7840
  const onMove = () => place();
@@ -7641,12 +7641,33 @@ var Tour = (props) => {
7641
7641
  );
7642
7642
  useEscapeKey(open, () => onClose("skip"));
7643
7643
  useFocusTrap(cardRef, open, { trap: true });
7644
+ const stepsRef = React44.useRef(steps);
7645
+ stepsRef.current = steps;
7644
7646
  React44.useEffect(() => {
7645
- if (!open || !step) return;
7646
- const el = resolve(step.target);
7647
- setTargetFound(!!el);
7648
- el?.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
7649
- }, [open, step]);
7647
+ if (!open) return;
7648
+ const target = stepsRef.current[index]?.target;
7649
+ if (!target) return;
7650
+ let stop = false;
7651
+ let tries = 0;
7652
+ const look = () => {
7653
+ if (stop) return;
7654
+ const el = resolve(target);
7655
+ if (el) {
7656
+ setTargetFound(true);
7657
+ el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
7658
+ return;
7659
+ }
7660
+ setTargetFound(false);
7661
+ if (tries < 60) {
7662
+ tries += 1;
7663
+ requestAnimationFrame(look);
7664
+ }
7665
+ };
7666
+ look();
7667
+ return () => {
7668
+ stop = true;
7669
+ };
7670
+ }, [open, index]);
7650
7671
  const place = React44.useCallback(() => {
7651
7672
  const spot = spotRef.current;
7652
7673
  const card = cardRef.current;
@@ -7697,9 +7718,20 @@ var Tour = (props) => {
7697
7718
  React44.useLayoutEffect(() => {
7698
7719
  if (!open) return;
7699
7720
  place();
7700
- const t = setTimeout(place, 400);
7701
- return () => clearTimeout(t);
7702
- }, [open, place]);
7721
+ let raf = 0;
7722
+ let settled = 0;
7723
+ let last = "";
7724
+ const follow = () => {
7725
+ const el = resolve(stepsRef.current[index]?.target ?? "");
7726
+ const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
7727
+ settled = now === last ? settled + 1 : 0;
7728
+ last = now;
7729
+ place();
7730
+ if (settled < 3) raf = requestAnimationFrame(follow);
7731
+ };
7732
+ raf = requestAnimationFrame(follow);
7733
+ return () => cancelAnimationFrame(raf);
7734
+ }, [open, index, place]);
7703
7735
  React44.useEffect(() => {
7704
7736
  if (!open) return;
7705
7737
  const onMove = () => place();
package/dist/index.cjs CHANGED
@@ -12156,12 +12156,33 @@ var Tour = (props) => {
12156
12156
  );
12157
12157
  useEscapeKey(open, () => onClose("skip"));
12158
12158
  useFocusTrap(cardRef, open, { trap: true });
12159
+ const stepsRef = import_react44.default.useRef(steps);
12160
+ stepsRef.current = steps;
12159
12161
  import_react44.default.useEffect(() => {
12160
- if (!open || !step) return;
12161
- const el = resolve(step.target);
12162
- setTargetFound(!!el);
12163
- el?.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
12164
- }, [open, step]);
12162
+ if (!open) return;
12163
+ const target = stepsRef.current[index]?.target;
12164
+ if (!target) return;
12165
+ let stop = false;
12166
+ let tries = 0;
12167
+ const look = () => {
12168
+ if (stop) return;
12169
+ const el = resolve(target);
12170
+ if (el) {
12171
+ setTargetFound(true);
12172
+ el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
12173
+ return;
12174
+ }
12175
+ setTargetFound(false);
12176
+ if (tries < 60) {
12177
+ tries += 1;
12178
+ requestAnimationFrame(look);
12179
+ }
12180
+ };
12181
+ look();
12182
+ return () => {
12183
+ stop = true;
12184
+ };
12185
+ }, [open, index]);
12165
12186
  const place = import_react44.default.useCallback(() => {
12166
12187
  const spot = spotRef.current;
12167
12188
  const card = cardRef.current;
@@ -12212,9 +12233,20 @@ var Tour = (props) => {
12212
12233
  import_react44.default.useLayoutEffect(() => {
12213
12234
  if (!open) return;
12214
12235
  place();
12215
- const t = setTimeout(place, 400);
12216
- return () => clearTimeout(t);
12217
- }, [open, place]);
12236
+ let raf = 0;
12237
+ let settled = 0;
12238
+ let last = "";
12239
+ const follow = () => {
12240
+ const el = resolve(stepsRef.current[index]?.target ?? "");
12241
+ const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
12242
+ settled = now === last ? settled + 1 : 0;
12243
+ last = now;
12244
+ place();
12245
+ if (settled < 3) raf = requestAnimationFrame(follow);
12246
+ };
12247
+ raf = requestAnimationFrame(follow);
12248
+ return () => cancelAnimationFrame(raf);
12249
+ }, [open, index, place]);
12218
12250
  import_react44.default.useEffect(() => {
12219
12251
  if (!open) return;
12220
12252
  const onMove = () => place();
package/dist/index.js CHANGED
@@ -11744,12 +11744,33 @@ var Tour = (props) => {
11744
11744
  );
11745
11745
  useEscapeKey(open, () => onClose("skip"));
11746
11746
  useFocusTrap(cardRef, open, { trap: true });
11747
+ const stepsRef = React44.useRef(steps);
11748
+ stepsRef.current = steps;
11747
11749
  React44.useEffect(() => {
11748
- if (!open || !step) return;
11749
- const el = resolve(step.target);
11750
- setTargetFound(!!el);
11751
- el?.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
11752
- }, [open, step]);
11750
+ if (!open) return;
11751
+ const target = stepsRef.current[index]?.target;
11752
+ if (!target) return;
11753
+ let stop = false;
11754
+ let tries = 0;
11755
+ const look = () => {
11756
+ if (stop) return;
11757
+ const el = resolve(target);
11758
+ if (el) {
11759
+ setTargetFound(true);
11760
+ el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
11761
+ return;
11762
+ }
11763
+ setTargetFound(false);
11764
+ if (tries < 60) {
11765
+ tries += 1;
11766
+ requestAnimationFrame(look);
11767
+ }
11768
+ };
11769
+ look();
11770
+ return () => {
11771
+ stop = true;
11772
+ };
11773
+ }, [open, index]);
11753
11774
  const place = React44.useCallback(() => {
11754
11775
  const spot = spotRef.current;
11755
11776
  const card = cardRef.current;
@@ -11800,9 +11821,20 @@ var Tour = (props) => {
11800
11821
  React44.useLayoutEffect(() => {
11801
11822
  if (!open) return;
11802
11823
  place();
11803
- const t = setTimeout(place, 400);
11804
- return () => clearTimeout(t);
11805
- }, [open, place]);
11824
+ let raf = 0;
11825
+ let settled = 0;
11826
+ let last = "";
11827
+ const follow = () => {
11828
+ const el = resolve(stepsRef.current[index]?.target ?? "");
11829
+ const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
11830
+ settled = now === last ? settled + 1 : 0;
11831
+ last = now;
11832
+ place();
11833
+ if (settled < 3) raf = requestAnimationFrame(follow);
11834
+ };
11835
+ raf = requestAnimationFrame(follow);
11836
+ return () => cancelAnimationFrame(raf);
11837
+ }, [open, index, place]);
11806
11838
  React44.useEffect(() => {
11807
11839
  if (!open) return;
11808
11840
  const onMove = () => place();
@@ -58,11 +58,18 @@ const [guide, setGuide] = useState(true);
58
58
 
59
59
  ## 스크롤
60
60
 
61
- 대상이 화면 밖이면 데려온다. **페이지가 스크롤하든 안쪽 상자가 스크롤하든**
62
- 브라우저가 알아서 한다.
61
+ **그 단계 차례가 되면 대상을 화면 안으로 데려온다.** 페이지가 스크롤하든 안쪽
62
+ 상자가 스크롤하든 브라우저가 알아서 한다(`scrollIntoView`). 부드럽게 움직이는
63
+ 동안 구멍과 말풍선이 **프레임마다 따라붙고**, 멎으면 따라붙기도 멈춘다.
63
64
 
64
- 그 뒤 사용자가 굴리면 구멍이 **한 프레임 늦게** 따라온다. 화면 전체가 어두운
65
- 상태라 눈에 잘 띄지 않지만, 알고는 있어야 한다.
65
+ 대상이 아직 안 그려졌으면 **1초까지 기다린다.** 앞 단계에서 눌러야 나타나는
66
+ 요소를 가리키는 경우가 있어서다. 그래도 없으면 구멍 없이 말풍선만 띄운다.
67
+
68
+ 안내 중에 사용자가 직접 굴리면 구멍이 **한 프레임 늦게** 따라온다. 화면 전체가
69
+ 어두운 상태라 눈에 잘 띄지 않지만, 알고는 있어야 한다.
70
+
71
+ > `steps` 를 인라인 배열로 넘겨도 된다. 단계 바뀜은 **차례(index)** 로만
72
+ > 판단하므로 배열이 매 렌더 새로 만들어져도 스크롤이 다시 시작되지 않는다.
66
73
 
67
74
  ## 다시 보지 않기
68
75
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-plat/design-system",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "description": "XPLAT UI Design System",
5
5
  "author": "XPLAT WOONG",
6
6
  "main": "dist/index.cjs",