ngx-kit 9.2.3 → 9.3.0
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/core/README.md +0 -21
- package/fesm2022/ngx-kit-core.mjs +21 -15
- package/fesm2022/ngx-kit-core.mjs.map +1 -1
- package/fesm2022/ngx-kit-drag-resize.mjs +6 -21
- package/fesm2022/ngx-kit-drag-resize.mjs.map +1 -1
- package/fesm2022/ngx-kit-image-editor.mjs +13 -12
- package/fesm2022/ngx-kit-image-editor.mjs.map +1 -1
- package/fesm2022/ngx-kit-image-viewer.mjs +5 -3
- package/fesm2022/ngx-kit-image-viewer.mjs.map +1 -1
- package/fesm2022/ngx-kit-infinite-scroll.mjs +8 -7
- package/fesm2022/ngx-kit-infinite-scroll.mjs.map +1 -1
- package/fesm2022/ngx-kit-notify.mjs +2 -3
- package/fesm2022/ngx-kit-notify.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ngx-kit-core.d.ts +9 -5
- package/types/ngx-kit-drag-resize.d.ts +1 -2
- package/types/ngx-kit-image-editor.d.ts +4 -3
- package/types/ngx-kit-image-viewer.d.ts +1 -0
- package/types/ngx-kit-infinite-scroll.d.ts +1 -0
package/core/README.md
CHANGED
|
@@ -65,29 +65,8 @@ const browser = inject(BrowserService);
|
|
|
65
65
|
browser.prefersDarkMode; // boolean — read once at service construction time
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
## Utilities
|
|
69
68
|
|
|
70
|
-
### `startDragSession(callbacks)`
|
|
71
69
|
|
|
72
|
-
Replaces the problematic `@HostListener('document:mousemove', ...)` pattern, which keeps a listener attached to `document` for the entire lifetime of the component — even when nothing is being dragged (a real performance issue on pages with many simultaneous instances). This function only adds a listener for the duration of an actual drag and removes it itself; `touchmove` is handled with `{passive: false}`, so dragging on mobile doesn't also scroll the page.
|
|
73
|
-
|
|
74
|
-
```ts
|
|
75
|
-
import { startDragSession } from 'ngx-kit/core';
|
|
76
|
-
|
|
77
|
-
let stop: (() => void) | undefined;
|
|
78
|
-
|
|
79
|
-
function onPointerDown(ev: MouseEvent | TouchEvent) {
|
|
80
|
-
stop?.();
|
|
81
|
-
stop = startDragSession({
|
|
82
|
-
onMove: (ev) => {
|
|
83
|
-
/* update position */
|
|
84
|
-
},
|
|
85
|
-
onEnd: () => {
|
|
86
|
-
stop = undefined;
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
70
|
|
|
92
71
|
> If your component is `OnPush` and uses `startDragSession` (instead of `@HostListener`), make sure to call `ChangeDetectorRef.markForCheck()` inside `onMove`/`onEnd` yourself — unlike `@HostListener`, which automatically marks the view dirty, a manual `addEventListener` does not.
|
|
93
72
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i1 from '@angular/common';
|
|
2
|
-
import { CommonModule, isPlatformBrowser, DOCUMENT } from '@angular/common';
|
|
2
|
+
import { CommonModule, isPlatformBrowser, DOCUMENT as DOCUMENT$1 } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { EventEmitter, forwardRef, HostListener, ViewChild, Output, Input, ChangeDetectionStrategy, Component,
|
|
4
|
+
import { EventEmitter, inject, DOCUMENT, forwardRef, HostListener, ViewChild, Output, Input, ChangeDetectionStrategy, Component, ChangeDetectorRef, InjectionToken, PLATFORM_ID, Inject, Injectable, DestroyRef, signal, computed, ApplicationRef, EnvironmentInjector, Injector, createComponent } from '@angular/core';
|
|
5
5
|
import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormControl, Validators } from '@angular/forms';
|
|
6
6
|
|
|
7
7
|
function getOffsetPosition(evt, parent) {
|
|
@@ -25,7 +25,7 @@ function getOffsetPosition(evt, parent) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/** با فراخوانی این تابع (مثلاً داخل dragStart) یک نشست درگ شروع میشه. */
|
|
28
|
-
function startDragSession({ onMove, onEnd }) {
|
|
28
|
+
function startDragSession({ doc, onMove, onEnd }) {
|
|
29
29
|
const handleMove = (ev) => {
|
|
30
30
|
if (ev.type === 'touchmove') {
|
|
31
31
|
// جلوگیری از اسکرول شدن صفحه همزمان با درگ کردن روی موبایل/تاچ
|
|
@@ -38,17 +38,17 @@ function startDragSession({ onMove, onEnd }) {
|
|
|
38
38
|
onEnd?.(ev);
|
|
39
39
|
};
|
|
40
40
|
const stop = () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
doc.removeEventListener('mousemove', handleMove);
|
|
42
|
+
doc.removeEventListener('touchmove', handleMove);
|
|
43
|
+
doc.removeEventListener('mouseup', handleEnd);
|
|
44
|
+
doc.removeEventListener('touchend', handleEnd);
|
|
45
|
+
doc.removeEventListener('touchcancel', handleEnd);
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
doc.addEventListener('mousemove', handleMove);
|
|
48
|
+
doc.addEventListener('touchmove', handleMove, { passive: false });
|
|
49
|
+
doc.addEventListener('mouseup', handleEnd);
|
|
50
|
+
doc.addEventListener('touchend', handleEnd);
|
|
51
|
+
doc.addEventListener('touchcancel', handleEnd);
|
|
52
52
|
// تابع stop برگردونده میشه تا هم بشه دستی صداش زد (مثلاً در ngOnDestroy،
|
|
53
53
|
// اگه کامپوننت درست وسط یه درگ نابود بشه) و هم بهصورت خودکار روی
|
|
54
54
|
// mouseup/touchend صدا زده میشه.
|
|
@@ -107,6 +107,7 @@ class RangeSliderComponent {
|
|
|
107
107
|
sliderRect;
|
|
108
108
|
thumbRect;
|
|
109
109
|
stopDrag;
|
|
110
|
+
doc = inject(DOCUMENT);
|
|
110
111
|
constructor(changeDetectorRef) {
|
|
111
112
|
this.changeDetectorRef = changeDetectorRef;
|
|
112
113
|
}
|
|
@@ -180,6 +181,7 @@ class RangeSliderComponent {
|
|
|
180
181
|
this.selectedIndexChange.emit(this.selectedIndex);
|
|
181
182
|
this.stopDrag?.();
|
|
182
183
|
this.stopDrag = startDragSession({
|
|
184
|
+
doc: this.doc,
|
|
183
185
|
onMove: (moveEv) => this.updateThumbPosition(moveEv),
|
|
184
186
|
onEnd: () => {
|
|
185
187
|
this.isDragging = false;
|
|
@@ -333,6 +335,7 @@ class SaturationComponent {
|
|
|
333
335
|
saturationRect;
|
|
334
336
|
thumbRect;
|
|
335
337
|
stopDrag;
|
|
338
|
+
doc = inject(DOCUMENT);
|
|
336
339
|
constructor() { }
|
|
337
340
|
ngOnDestroy() {
|
|
338
341
|
// اگه کامپوننت درست وسط یه درگ نابود بشه (مثلاً پیکر بسته بشه)، باید
|
|
@@ -390,6 +393,7 @@ class SaturationComponent {
|
|
|
390
393
|
this.updatePosition(ev);
|
|
391
394
|
this.stopDrag?.();
|
|
392
395
|
this.stopDrag = startDragSession({
|
|
396
|
+
doc: this.doc,
|
|
393
397
|
onMove: (moveEv) => this.updatePosition(moveEv),
|
|
394
398
|
onEnd: () => {
|
|
395
399
|
this.isDragging = false;
|
|
@@ -515,6 +519,7 @@ class SliderComponent {
|
|
|
515
519
|
thumbRect;
|
|
516
520
|
stopDrag;
|
|
517
521
|
cd = inject(ChangeDetectorRef);
|
|
522
|
+
doc = inject(DOCUMENT);
|
|
518
523
|
constructor() { }
|
|
519
524
|
ngOnInit() {
|
|
520
525
|
this.myControl.setValidators([Validators.min(this.min), Validators.max(this.max)]);
|
|
@@ -572,6 +577,7 @@ class SliderComponent {
|
|
|
572
577
|
this.updatePosition(ev);
|
|
573
578
|
this.stopDrag?.();
|
|
574
579
|
this.stopDrag = startDragSession({
|
|
580
|
+
doc: this.doc,
|
|
575
581
|
onMove: (moveEv) => this.updatePosition(moveEv),
|
|
576
582
|
onEnd: () => {
|
|
577
583
|
this.isDragging = false;
|
|
@@ -1146,7 +1152,7 @@ function resolveDirection(doc) {
|
|
|
1146
1152
|
* این سرویس انجام میدهد).
|
|
1147
1153
|
*/
|
|
1148
1154
|
class DirectionService {
|
|
1149
|
-
doc = inject(DOCUMENT);
|
|
1155
|
+
doc = inject(DOCUMENT$1);
|
|
1150
1156
|
destroyRef = inject(DestroyRef);
|
|
1151
1157
|
_direction = signal(resolveDirection(this.doc), /* @ts-ignore */
|
|
1152
1158
|
...(ngDevMode ? [{ debugName: "_direction" }] : /* istanbul ignore next */ []));
|
|
@@ -1209,7 +1215,7 @@ const DIALOG_OVERLAY_CLASSNAME = 'ngx-ui-overlay';
|
|
|
1209
1215
|
const OVERLAY_HOST_CLASSNAME = 'ngx-ui-overlay-host';
|
|
1210
1216
|
const BASE_Z_INDEX = 1000;
|
|
1211
1217
|
class OverlayService {
|
|
1212
|
-
document = inject(DOCUMENT);
|
|
1218
|
+
document = inject(DOCUMENT$1);
|
|
1213
1219
|
directionService = inject(DirectionService);
|
|
1214
1220
|
platformId = inject(PLATFORM_ID);
|
|
1215
1221
|
applicationRef = inject(ApplicationRef);
|