@daracl/dialog 0.0.8 → 0.0.9
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/README.md +1 -1
- package/dist/daracl.dialog.css +4 -1
- package/dist/daracl.dialog.js +100 -68
- package/dist/daracl.dialog.js.map +1 -1
- package/dist/daracl.dialog.min.css +1 -1
- package/dist/daracl.dialog.min.js +3 -3
- package/dist/daracl.dialog.min.umd.js +3 -3
- package/dist/daracl.dialog.umd.js +100 -68
- package/dist/daracl.dialog.umd.js.map +1 -1
- package/dist/dialog.d.ts +24 -1
- package/dist/index.cjs +100 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +4 -1
- package/dist/index.js +100 -68
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +2 -2
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +147 -124
- package/dist/index.min.js.map +1 -1
- package/package.json +3 -3
- package/style/daracl.dialog.scss +6 -1
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ var dialogObj = Daracl.dialog.create({
|
|
|
88
88
|
| zIndex | css z-index | 10000 | |
|
|
89
89
|
| dragOverflow | drag 시 창 밖으로 넘어갈 수 있는지 여부 | true | |
|
|
90
90
|
| buttons | dialog 하단 버튼 | [] | |
|
|
91
|
-
| moveDelay | drag
|
|
91
|
+
| moveDelay | drag / resize 갱신 간격(ms). `requestAnimationFrame` 이 없는 환경에서만 사용하며, 일반 브라우저는 화면 갱신 주기마다 반영한다 | 15 | |
|
|
92
92
|
| afterOpen | 오픈후 발생할 이벤트 (`this` 는 dialog, 인자는 wrapper 요소) | false | |
|
|
93
93
|
|
|
94
94
|
|
package/dist/daracl.dialog.css
CHANGED
|
@@ -350,6 +350,9 @@
|
|
|
350
350
|
.daracl-dialog-wrapper.transform-disable {
|
|
351
351
|
transform: none !important;
|
|
352
352
|
}
|
|
353
|
+
.daracl-dialog-wrapper.draggable > .daracl-dialog > .dialog-header {
|
|
354
|
+
cursor: move;
|
|
355
|
+
}
|
|
353
356
|
.daracl-dialog-wrapper.move-on .dialog-move-overay {
|
|
354
357
|
display: block !important;
|
|
355
358
|
}
|
|
@@ -385,7 +388,7 @@
|
|
|
385
388
|
background: var(--dui-panel-header-bg, #f7f9fc);
|
|
386
389
|
border: var(--dui-border-light-color, #e5e7eb);
|
|
387
390
|
border-radius: 4px 4px 0px 0px;
|
|
388
|
-
cursor:
|
|
391
|
+
cursor: default;
|
|
389
392
|
}
|
|
390
393
|
.daracl-dialog-wrapper > .daracl-dialog > .dialog-header > .btn-area {
|
|
391
394
|
position: absolute;
|
package/dist/daracl.dialog.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
7
|
/*!
|
|
8
|
-
* @daracl/dialog v0.0.
|
|
8
|
+
* @daracl/dialog v0.0.9
|
|
9
9
|
* Copyright 2024-2026 darainfo and other contributors;
|
|
10
10
|
* Licensed MIT
|
|
11
11
|
*/
|
|
@@ -360,6 +360,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
360
360
|
this.eventList = [];
|
|
361
361
|
this.timerSet.forEach((timer) => clearTimeout(timer));
|
|
362
362
|
this.timerSet.clear();
|
|
363
|
+
if (typeof cancelAnimationFrame === "function") {
|
|
364
|
+
this.frameSet.forEach((frame) => cancelAnimationFrame(frame));
|
|
365
|
+
}
|
|
366
|
+
this.frameSet.clear();
|
|
363
367
|
this.removeDialogOverrayElement();
|
|
364
368
|
if (wasOpen) {
|
|
365
369
|
this.restoreFocus(hadFocus);
|
|
@@ -380,6 +384,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
380
384
|
this.idx = DIALOG_IDX += 1;
|
|
381
385
|
this.eventList = [];
|
|
382
386
|
this.timerSet = /* @__PURE__ */ new Set();
|
|
387
|
+
this.frameSet = /* @__PURE__ */ new Set();
|
|
383
388
|
const dialogWrapperElement = document.createElement("div");
|
|
384
389
|
dialogWrapperElement.className = `daracl-dialog-wrapper hide dd-${DIALOG_IDX}`;
|
|
385
390
|
dialogWrapperElement.setAttribute("role", "dialog");
|
|
@@ -399,6 +404,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
399
404
|
this.dialogTemplate();
|
|
400
405
|
this.addEvent(dialogWrapperElement, "keydown", this.onKeydown);
|
|
401
406
|
if (this.options.draggable !== false) {
|
|
407
|
+
dialogWrapperElement.classList.add("draggable");
|
|
402
408
|
this.initDrag();
|
|
403
409
|
}
|
|
404
410
|
if (this.options.resizable === true) {
|
|
@@ -483,6 +489,56 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
483
489
|
clearTimeout(timer);
|
|
484
490
|
this.timerSet.delete(timer);
|
|
485
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* 마우스 / 터치 이동을 화면 갱신 주기(requestAnimationFrame)마다 한 번만 반영한다.
|
|
494
|
+
* 한 프레임 안의 여러 move 이벤트는 마지막 좌표만 쓰고, flush 는 남은 좌표를 바로 반영한다 (놓을 때 마지막 이동 유지).
|
|
495
|
+
* requestAnimationFrame 이 없는 환경에서는 moveDelay(ms) 타이머로 대신한다.
|
|
496
|
+
* @param {(point: {clientX: number, clientY: number, pageX: number, pageY: number}) => void} apply
|
|
497
|
+
*/
|
|
498
|
+
createFrameUpdater(apply) {
|
|
499
|
+
let pending = null;
|
|
500
|
+
let frame = 0;
|
|
501
|
+
let timer;
|
|
502
|
+
const cancel = () => {
|
|
503
|
+
if (frame) {
|
|
504
|
+
cancelAnimationFrame(frame);
|
|
505
|
+
this.frameSet.delete(frame);
|
|
506
|
+
frame = 0;
|
|
507
|
+
}
|
|
508
|
+
this.clearTimer(timer);
|
|
509
|
+
timer = void 0;
|
|
510
|
+
};
|
|
511
|
+
const run = () => {
|
|
512
|
+
cancel();
|
|
513
|
+
const point = pending;
|
|
514
|
+
pending = null;
|
|
515
|
+
if (point && this.dialogWrapperElement) {
|
|
516
|
+
apply(point);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
return {
|
|
520
|
+
/** @param {{clientX: number, clientY: number, pageX: number, pageY: number}} point */
|
|
521
|
+
request: (point) => {
|
|
522
|
+
pending = point;
|
|
523
|
+
if (frame || timer !== void 0) return;
|
|
524
|
+
if (typeof requestAnimationFrame === "function") {
|
|
525
|
+
const id = requestAnimationFrame(() => {
|
|
526
|
+
this.frameSet.delete(id);
|
|
527
|
+
frame = 0;
|
|
528
|
+
run();
|
|
529
|
+
});
|
|
530
|
+
frame = id;
|
|
531
|
+
this.frameSet.add(id);
|
|
532
|
+
} else {
|
|
533
|
+
timer = this.setTimer(() => {
|
|
534
|
+
timer = void 0;
|
|
535
|
+
run();
|
|
536
|
+
}, Math.max(this.options.moveDelay || 0, 0));
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
flush: run
|
|
540
|
+
};
|
|
541
|
+
}
|
|
486
542
|
/** 사이즈 조절 초기화 */
|
|
487
543
|
initResize() {
|
|
488
544
|
const dialogElement = this.dialogWrapperElement;
|
|
@@ -516,61 +572,49 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
516
572
|
this.addEvent(document, "mousemove touchmove", onResizeMouseMove);
|
|
517
573
|
this.addEvent(document, "mouseup touchend touchcancel", onResizeMouseUp);
|
|
518
574
|
});
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
575
|
+
const resizeFrame = this.createFrameUpdater((point) => {
|
|
576
|
+
let moveX = point.pageX - startX, moveY = point.pageY - startY;
|
|
577
|
+
moveY = isResizeTop ? moveY * -1 : moveY;
|
|
578
|
+
moveX = isResizeLeft ? moveX * -1 : moveX;
|
|
579
|
+
let resizeHeight = dialogHeight + moveY, resizeWidth = dialogWidth + moveX;
|
|
580
|
+
if (this.options.minHeight >= resizeHeight) {
|
|
581
|
+
resizeHeight = this.options.minHeight;
|
|
582
|
+
moveY = (dialogHeight - resizeHeight) * -1;
|
|
525
583
|
}
|
|
526
|
-
if (
|
|
527
|
-
this.
|
|
584
|
+
if (this.options.minWidth >= resizeWidth) {
|
|
585
|
+
resizeWidth = this.options.minWidth;
|
|
586
|
+
moveX = (dialogWidth - resizeWidth) * -1;
|
|
528
587
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
if (
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
moveX = isResizeLeft ? moveX * -1 : moveX;
|
|
536
|
-
let resizeHeight = dialogHeight + moveY, resizeWidth = dialogWidth + moveX;
|
|
537
|
-
if (this.options.minHeight >= resizeHeight) {
|
|
538
|
-
resizeHeight = this.options.minHeight;
|
|
539
|
-
moveY = (dialogHeight - resizeHeight) * -1;
|
|
540
|
-
}
|
|
541
|
-
if (this.options.minWidth >= resizeWidth) {
|
|
542
|
-
resizeWidth = this.options.minWidth;
|
|
543
|
-
moveX = (dialogWidth - resizeWidth) * -1;
|
|
588
|
+
let topVal = -1;
|
|
589
|
+
if (isResizeTop) {
|
|
590
|
+
topVal = offsetY - moveY;
|
|
591
|
+
if (topVal <= 0) {
|
|
592
|
+
topVal = 0;
|
|
593
|
+
resizeHeight = dialogHeight + offsetY;
|
|
544
594
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
554
|
-
let leftVal = -1;
|
|
555
|
-
if (isResizeLeft) {
|
|
556
|
-
leftVal = offsetX - moveX;
|
|
557
|
-
if (leftVal <= 0) {
|
|
558
|
-
leftVal = 0;
|
|
559
|
-
resizeWidth = dialogWidth + offsetX;
|
|
560
|
-
}
|
|
561
|
-
dialogElement.style.left = leftVal + "px";
|
|
562
|
-
}
|
|
563
|
-
if (moveMode != "b" && moveMode != "t") {
|
|
564
|
-
dialogElement.style.width = resizeWidth + "px";
|
|
565
|
-
}
|
|
566
|
-
if (moveMode != "r" && moveMode != "l") {
|
|
567
|
-
dialogElement.style.height = resizeHeight + "px";
|
|
595
|
+
dialogElement.style.top = topVal + "px";
|
|
596
|
+
}
|
|
597
|
+
let leftVal = -1;
|
|
598
|
+
if (isResizeLeft) {
|
|
599
|
+
leftVal = offsetX - moveX;
|
|
600
|
+
if (leftVal <= 0) {
|
|
601
|
+
leftVal = 0;
|
|
602
|
+
resizeWidth = dialogWidth + offsetX;
|
|
568
603
|
}
|
|
569
|
-
|
|
604
|
+
dialogElement.style.left = leftVal + "px";
|
|
605
|
+
}
|
|
606
|
+
if (moveMode != "b" && moveMode != "t") {
|
|
607
|
+
dialogElement.style.width = resizeWidth + "px";
|
|
608
|
+
}
|
|
609
|
+
if (moveMode != "r" && moveMode != "l") {
|
|
610
|
+
dialogElement.style.height = resizeHeight + "px";
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
const onResizeMouseMove = (e) => {
|
|
614
|
+
resizeFrame.request(eventPoint(e));
|
|
570
615
|
};
|
|
571
616
|
const onResizeMouseUp = () => {
|
|
572
|
-
|
|
573
|
-
startTime = -1;
|
|
617
|
+
resizeFrame.flush();
|
|
574
618
|
this.removeEvent(document, "mousemove touchmove", onResizeMouseMove);
|
|
575
619
|
this.removeEvent(document, "mouseup touchend touchcancel", onResizeMouseUp);
|
|
576
620
|
};
|
|
@@ -617,29 +661,17 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
617
661
|
this.addEvent(document, "mousemove touchmove", onMouseMove);
|
|
618
662
|
this.addEvent(document, "mouseup touchend touchcancel", onMouseUp);
|
|
619
663
|
});
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
664
|
+
const dragFrame = this.createFrameUpdater((point) => {
|
|
665
|
+
this.setPosition(point, offsetX, offsetY, dialogWidth, dialogHeight);
|
|
666
|
+
});
|
|
623
667
|
const onMouseMove = (e) => {
|
|
624
668
|
if (isDragging) {
|
|
625
|
-
|
|
626
|
-
startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
627
|
-
}
|
|
628
|
-
if ((/* @__PURE__ */ new Date()).getTime() - moveDelay <= startTime) {
|
|
629
|
-
this.clearTimer(moveTimer);
|
|
630
|
-
}
|
|
631
|
-
const point = eventPoint(e);
|
|
632
|
-
moveTimer = this.setTimer(() => {
|
|
633
|
-
startTime = -1;
|
|
634
|
-
if (!this.dialogWrapperElement) return;
|
|
635
|
-
this.setPosition(point, offsetX, offsetY, dialogWidth, dialogHeight);
|
|
636
|
-
}, moveDelay);
|
|
669
|
+
dragFrame.request(eventPoint(e));
|
|
637
670
|
}
|
|
638
671
|
};
|
|
639
672
|
const onMouseUp = () => {
|
|
673
|
+
dragFrame.flush();
|
|
640
674
|
isDragging = false;
|
|
641
|
-
startTime = -1;
|
|
642
|
-
this.clearTimer(moveTimer);
|
|
643
675
|
dialogElement.classList.remove("move-on");
|
|
644
676
|
this.removeEvent(document, "mousemove touchmove", onMouseMove);
|
|
645
677
|
this.removeEvent(document, "mouseup touchend touchcancel", onMouseUp);
|
|
@@ -894,7 +926,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
894
926
|
});
|
|
895
927
|
}
|
|
896
928
|
};
|
|
897
|
-
__publicField(_Dialog, "VERSION", "0.0.
|
|
929
|
+
__publicField(_Dialog, "VERSION", "0.0.9");
|
|
898
930
|
let Dialog = _Dialog;
|
|
899
931
|
if (typeof window !== "undefined") {
|
|
900
932
|
window.Daracl = window.Daracl || {};
|