@anglr/common 11.2.0-beta.20220228163820 → 11.2.0-beta.20220301090733
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/changelog.md +5 -2
- package/es2015/floating-ui/src/services/floatingUiDomPosition.service.js +140 -28
- package/es2015/floating-ui/src/services/floatingUiDomPosition.service.js.map +1 -1
- package/es2015/src/services/position/position.interface.js.map +1 -1
- package/es2020/floating-ui/src/services/floatingUiDomPosition.service.js +139 -25
- package/es2020/floating-ui/src/services/floatingUiDomPosition.service.js.map +1 -1
- package/es2020/src/services/position/position.interface.js.map +1 -1
- package/floating-ui/src/services/floatingUiDomPosition.service.d.ts +23 -2
- package/floating-ui/src/services/floatingUiDomPosition.service.d.ts.map +1 -1
- package/package.json +9 -1
- package/src/services/position/position.interface.d.ts +2 -5
- package/src/services/position/position.interface.d.ts.map +1 -1
- package/version.bak +1 -1
package/changelog.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## Version 11.2.0 (2022-
|
|
3
|
+
## Version 11.2.0 (2022-03-01)
|
|
4
4
|
|
|
5
5
|
### Features
|
|
6
6
|
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
- property `offset` offset which allows moving target element along the cross axis of placement
|
|
12
12
|
- property `flip` indication whether perform flip in case of collision (with view boundaries)
|
|
13
13
|
- property `autoUpdate` indication whether set up 'auto updating' of position
|
|
14
|
-
- method `autoUpdateProcessor` function that is called when auto updated is called for processing result
|
|
15
14
|
- property `mouseEvent` mouse event that occured when positioning was called
|
|
16
15
|
- new `PositionResult` interface, that represents result of positioning process, storing new coordinates
|
|
17
16
|
- property `target` target element to be positioned
|
|
@@ -26,6 +25,10 @@
|
|
|
26
25
|
- new `PositionPlacement` enum with available positions for placement of target element against its source
|
|
27
26
|
- new `PositionOffset` enum with applied offset to position of target in cross axis relative to placement
|
|
28
27
|
- new `POSITION` *Injection Token* used for injecting service that is used for positioning of one element against another
|
|
28
|
+
- added *subpackage* `@anglr/common/floating-ui`
|
|
29
|
+
- *subpackage* `@anglr/common/floating-ui`
|
|
30
|
+
- new `FloatingUiDomPosition` service that is used for positioning two elements against each other, using floating-ui dom implementation
|
|
31
|
+
- new `FLOATING_UI_POSITION` provider for floating ui position implementation
|
|
29
32
|
|
|
30
33
|
## Version 11.1.0 (2022-02-22)
|
|
31
34
|
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { Injectable } from '@angular/core';
|
|
3
|
+
import { PositionOffset, PositionPlacement, POSITION } from '@anglr/common';
|
|
3
4
|
import { extend } from '@jscrpt/common';
|
|
4
|
-
import { computePosition, autoUpdate } from '@floating-ui/dom';
|
|
5
|
+
import { computePosition, autoUpdate, offset, flip } from '@floating-ui/dom';
|
|
6
|
+
import { Observable } from 'rxjs';
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
5
8
|
/**
|
|
6
9
|
* Default options for `FloatingUiDomPosition` implementation
|
|
7
10
|
*/
|
|
@@ -20,36 +23,133 @@ export class FloatingUiDomPosition {
|
|
|
20
23
|
* @inheritdoc
|
|
21
24
|
*/
|
|
22
25
|
placeElement(target, source, options) {
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
x: result.x,
|
|
34
|
-
y: result.y
|
|
26
|
+
return new Observable(subscriber => {
|
|
27
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const computedOptions = extend({}, defaultOptions, options);
|
|
29
|
+
const middlewares = [];
|
|
30
|
+
this._setOffset(middlewares, computedOptions);
|
|
31
|
+
this._setFlip(middlewares, computedOptions);
|
|
32
|
+
const runComputation = () => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const result = yield computePosition(source, target, {
|
|
34
|
+
placement: this._getPlacement(computedOptions),
|
|
35
|
+
middleware: middlewares
|
|
35
36
|
});
|
|
37
|
+
if (computedOptions.autoUpdate) {
|
|
38
|
+
subscriber.next({
|
|
39
|
+
target,
|
|
40
|
+
dispose,
|
|
41
|
+
x: result.x,
|
|
42
|
+
y: result.y
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
});
|
|
47
|
+
let dispose = () => { };
|
|
48
|
+
if (computedOptions.autoUpdate) {
|
|
49
|
+
let options;
|
|
50
|
+
if (computedOptions.autoUpdate === true) {
|
|
51
|
+
options =
|
|
52
|
+
{
|
|
53
|
+
ancestorResize: true,
|
|
54
|
+
ancestorScroll: true,
|
|
55
|
+
elementResize: true
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
options = computedOptions.autoUpdate;
|
|
60
|
+
}
|
|
61
|
+
dispose = autoUpdate(source, target, runComputation, options);
|
|
36
62
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
y: result.y
|
|
49
|
-
};
|
|
63
|
+
const result = yield runComputation();
|
|
64
|
+
subscriber.next({
|
|
65
|
+
target,
|
|
66
|
+
dispose,
|
|
67
|
+
x: result.x,
|
|
68
|
+
y: result.y
|
|
69
|
+
});
|
|
70
|
+
if (!computedOptions.autoUpdate) {
|
|
71
|
+
subscriber.complete();
|
|
72
|
+
}
|
|
73
|
+
}))();
|
|
50
74
|
});
|
|
51
75
|
}
|
|
52
76
|
//######################### protected methods #########################
|
|
77
|
+
/**
|
|
78
|
+
* Sets flip middleware
|
|
79
|
+
* @param middlewares - Array of middlewares that will set
|
|
80
|
+
* @param options - Options that contains definition of flip
|
|
81
|
+
*/
|
|
82
|
+
_setFlip(middlewares, options) {
|
|
83
|
+
if (options.flip) {
|
|
84
|
+
middlewares.push(flip());
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sets offset middleware
|
|
89
|
+
* @param middlewares - Array of middlewares that will set
|
|
90
|
+
* @param options - Options that contains definition of offset
|
|
91
|
+
*/
|
|
92
|
+
_setOffset(middlewares, options) {
|
|
93
|
+
if (options.offset != PositionOffset.None) {
|
|
94
|
+
if (options.offset == PositionOffset.MouseEnter) {
|
|
95
|
+
//fallback if not supported placement used
|
|
96
|
+
if (options.placement == PositionPlacement.Left ||
|
|
97
|
+
options.placement == PositionPlacement.LeftStart ||
|
|
98
|
+
options.placement == PositionPlacement.LeftEnd ||
|
|
99
|
+
options.placement == PositionPlacement.Right ||
|
|
100
|
+
options.placement == PositionPlacement.RightStart ||
|
|
101
|
+
options.placement == PositionPlacement.RightEnd ||
|
|
102
|
+
options.placement == PositionPlacement.Bottom ||
|
|
103
|
+
options.placement == PositionPlacement.BottomEnd ||
|
|
104
|
+
options.placement == PositionPlacement.Top ||
|
|
105
|
+
options.placement == PositionPlacement.TopEnd) {
|
|
106
|
+
options.placement = PositionPlacement.TopStart;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
middlewares.push(offset(({ floating, placement }) => {
|
|
110
|
+
if (options.offset == PositionOffset.MouseEnter && options.mouseEvent) {
|
|
111
|
+
return options.mouseEvent.offsetX;
|
|
112
|
+
}
|
|
113
|
+
let dimension;
|
|
114
|
+
if (placement == 'bottom' || placement == 'bottom-start' || placement == 'bottom-end' ||
|
|
115
|
+
placement == 'top' || placement == 'top-start' || placement == 'top-end') {
|
|
116
|
+
dimension = floating.width;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
dimension = floating.height;
|
|
120
|
+
}
|
|
121
|
+
switch (options.offset) {
|
|
122
|
+
default:
|
|
123
|
+
{
|
|
124
|
+
dimension = 0;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
case PositionOffset.Full:
|
|
128
|
+
{
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case PositionOffset.Half:
|
|
132
|
+
{
|
|
133
|
+
dimension /= 2;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case PositionOffset.NegativeFull:
|
|
137
|
+
{
|
|
138
|
+
dimension *= -1;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
case PositionOffset.NegativeHalf:
|
|
142
|
+
{
|
|
143
|
+
dimension *= -.5;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
crossAxis: dimension
|
|
149
|
+
};
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
53
153
|
/**
|
|
54
154
|
* Gets floating ui placement from position placement
|
|
55
155
|
* @param options - Options containing position placement
|
|
@@ -59,7 +159,7 @@ export class FloatingUiDomPosition {
|
|
|
59
159
|
default:
|
|
60
160
|
// case PositionPlacement.Top:
|
|
61
161
|
{
|
|
62
|
-
return '
|
|
162
|
+
return 'top';
|
|
63
163
|
}
|
|
64
164
|
case PositionPlacement.TopStart:
|
|
65
165
|
{
|
|
@@ -108,4 +208,16 @@ export class FloatingUiDomPosition {
|
|
|
108
208
|
}
|
|
109
209
|
}
|
|
110
210
|
}
|
|
211
|
+
FloatingUiDomPosition.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: FloatingUiDomPosition, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
212
|
+
FloatingUiDomPosition.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: FloatingUiDomPosition });
|
|
213
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: FloatingUiDomPosition, decorators: [{
|
|
214
|
+
type: Injectable
|
|
215
|
+
}] });
|
|
216
|
+
/**
|
|
217
|
+
* Provider for floating ui position implementation
|
|
218
|
+
*/
|
|
219
|
+
export const FLOATING_UI_POSITION = {
|
|
220
|
+
provide: POSITION,
|
|
221
|
+
useClass: FloatingUiDomPosition
|
|
222
|
+
};
|
|
111
223
|
//# sourceMappingURL=floatingUiDomPosition.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floatingUiDomPosition.service.js","sourceRoot":"","sources":["../../../../floating-ui/src/services/floatingUiDomPosition.service.ts"],"names":[],"mappings":";AAAA,OAAO,EAA4C,cAAc,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,eAAe,EAAa,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAExE;;GAEG;AACH,MAAM,cAAc,GACpB;IACI,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,cAAc,CAAC,IAAI;IAC3B,SAAS,EAAE,iBAAiB,CAAC,GAAG;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAE9B,iGAAiG;IAEjG;;OAEG;IACU,YAAY,CAAC,MAAe,EAAE,MAAe,EAAE,OAAkC;;YAE1F,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;YAE5D,MAAM,cAAc,GAAG,GAAS,EAAE;gBAE9B,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,MAAM,EACN,MAAqB,EACrB;oBACI,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC;iBACjD,CAAC,CAAC;gBAExC,IAAG,eAAe,CAAC,UAAU,IAAI,eAAe,CAAC,mBAAmB,EACpE;oBACI,eAAe,CAAC,mBAAmB,CACnC;wBACI,MAAM;wBACN,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;wBACjB,CAAC,EAAE,MAAM,CAAC,CAAC;wBACX,CAAC,EAAE,MAAM,CAAC,CAAC;q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,CAAC,UAAU;gBACjC;oBACI,OAAO,aAAa,CAAC;iBACxB;YACD,KAAK,iBAAiB,CAAC,QAAQ;gBAC/B;oBACI,OAAO,WAAW,CAAC;iBACtB;SACJ;IACL,CAAC;CACJ","sourcesContent":["import {Position, PositionResult, PositionOptions, PositionOffset, PositionPlacement} from '@anglr/common';\nimport {extend} from '@jscrpt/common';\nimport {computePosition, Placement, autoUpdate} from '@floating-ui/dom';\n\n/**\n * Default options for `FloatingUiDomPosition` implementation\n */\nconst defaultOptions: PositionOptions =\n{\n autoUpdate: false,\n flip: false,\n offset: PositionOffset.None,\n placement: PositionPlacement.Top\n};\n\n/**\n * Service that is used for positioning two elements against each other, using floating-ui dom implementation\n */\nexport class FloatingUiDomPosition implements Position\n{\n //######################### public methods - implementation of Position #########################\n\n /**\n * @inheritdoc\n */\n public async placeElement(target: Element, source: Element, options?: Partial<PositionOptions>): Promise<PositionResult>\n {\n const computedOptions = extend({}, defaultOptions, options);\n\n const runComputation = async () =>\n {\n const result = await computePosition(source,\n target as HTMLElement,\n {\n placement: this._getPlacement(computedOptions)\n });\n\n if(computedOptions.autoUpdate && computedOptions.autoUpdateProcessor)\n {\n computedOptions.autoUpdateProcessor(\n {\n target,\n dispose: () => {},\n x: result.x,\n y: result.y\n });\n }\n\n return result;\n };\n\n const result = await runComputation();\n let dispose = () => {};\n\n if(computedOptions.autoUpdate)\n {\n dispose = autoUpdate(source, target as HTMLElement, runComputation);\n }\n\n return {\n target,\n dispose,\n x: result.x,\n y: result.y\n };\n }\n\n //######################### protected methods #########################\n\n /**\n * Gets floating ui placement from position placement\n * @param options - Options containing position placement\n */\n protected _getPlacement(options: PositionOptions): Placement\n {\n switch(options.placement)\n {\n default:\n // case PositionPlacement.Top:\n {\n return 'bottom';\n }\n case PositionPlacement.TopStart:\n {\n return 'top-start';\n }\n case PositionPlacement.TopEnd:\n {\n return 'top-end';\n }\n case PositionPlacement.Bottom:\n {\n return 'bottom';\n }\n case PositionPlacement.BottomStart:\n {\n return 'bottom-start';\n }\n case PositionPlacement.BottomEnd:\n {\n return 'bottom-end';\n }\n case PositionPlacement.Left:\n {\n return 'left';\n }\n case PositionPlacement.LeftStart:\n {\n return 'left-start';\n }\n case PositionPlacement.LeftEnd:\n {\n return 'left-end';\n }\n case PositionPlacement.Right:\n {\n return 'right';\n }\n case PositionPlacement.RightStart:\n {\n return 'right-start';\n }\n case PositionPlacement.RightEnd:\n {\n return 'right-end';\n }\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"floatingUiDomPosition.service.js","sourceRoot":"","sources":["../../../../floating-ui/src/services/floatingUiDomPosition.service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAgB,UAAU,EAAC,MAAM,eAAe,CAAC;AACxD,OAAO,EAA4C,cAAc,EAAE,iBAAiB,EAAqB,QAAQ,EAAC,MAAM,eAAe,CAAC;AACxI,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,eAAe,EAAa,UAAU,EAAc,MAAM,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;;AAEhC;;GAEG;AACH,MAAM,cAAc,GACpB;IACI,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,cAAc,CAAC,IAAI;IAC3B,SAAS,EAAE,iBAAiB,CAAC,GAAG;CACnC,CAAC;AAEF;;GAEG;AAEH,MAAM,OAAO,qBAAqB;IAE9B,iGAAiG;IAEjG;;OAEG;IACI,YAAY,CAAC,MAAe,EAAE,MAAe,EAAE,OAAkC;QAEpF,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE;YAE/B,CAAC,GAAS,EAAE;gBAER,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;gBAC5D,MAAM,WAAW,GAAiB,EAAE,CAAC;gBAErC,IAAI,CAAC,UAAU,CAAC,WA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ACD,KAAK,iBAAiB,CAAC,WAAW;gBAClC;oBACI,OAAO,cAAc,CAAC;iBACzB;YACD,KAAK,iBAAiB,CAAC,SAAS;gBAChC;oBACI,OAAO,YAAY,CAAC;iBACvB;YACD,KAAK,iBAAiB,CAAC,IAAI;gBAC3B;oBACI,OAAO,MAAM,CAAC;iBACjB;YACD,KAAK,iBAAiB,CAAC,SAAS;gBAChC;oBACI,OAAO,YAAY,CAAC;iBACvB;YACD,KAAK,iBAAiB,CAAC,OAAO;gBAC9B;oBACI,OAAO,UAAU,CAAC;iBACrB;YACD,KAAK,iBAAiB,CAAC,KAAK;gBAC5B;oBACI,OAAO,OAAO,CAAC;iBAClB;YACD,KAAK,iBAAiB,CAAC,UAAU;gBACjC;oBACI,OAAO,aAAa,CAAC;iBACxB;YACD,KAAK,iBAAiB,CAAC,QAAQ;gBAC/B;oBACI,OAAO,WAAW,CAAC;iBACtB;SACJ;IACL,CAAC;;kHApPQ,qBAAqB;sHAArB,qBAAqB;2FAArB,qBAAqB;kBADjC,UAAU;;AAwPX;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GACjC;IACI,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,qBAAqB;CAClC,CAAC","sourcesContent":["import {ClassProvider, Injectable} from '@angular/core';\nimport {Position, PositionResult, PositionOptions, PositionOffset, PositionPlacement, AutoUpdateOptions, POSITION} from '@anglr/common';\nimport {extend} from '@jscrpt/common';\nimport {computePosition, Placement, autoUpdate, Middleware, offset, flip} from '@floating-ui/dom';\nimport {Observable} from 'rxjs';\n\n/**\n * Default options for `FloatingUiDomPosition` implementation\n */\nconst defaultOptions: PositionOptions =\n{\n autoUpdate: false,\n flip: false,\n offset: PositionOffset.None,\n placement: PositionPlacement.Top\n};\n\n/**\n * Service that is used for positioning two elements against each other, using floating-ui dom implementation\n */\n@Injectable()\nexport class FloatingUiDomPosition implements Position\n{\n //######################### public methods - implementation of Position #########################\n\n /**\n * @inheritdoc\n */\n public placeElement(target: Element, source: Element, options?: Partial<PositionOptions>): Observable<PositionResult>\n {\n return new Observable(subscriber =>\n {\n (async () =>\n {\n const computedOptions = extend({}, defaultOptions, options);\n const middlewares: Middleware[] = [];\n\n this._setOffset(middlewares, computedOptions);\n this._setFlip(middlewares, computedOptions);\n\n const runComputation = async () =>\n {\n const result = await computePosition(source,\n target as HTMLElement,\n {\n placement: this._getPlacement(computedOptions),\n middleware: middlewares\n });\n\n if(computedOptions.autoUpdate)\n {\n subscriber.next(\n {\n target,\n dispose,\n x: result.x,\n y: result.y\n });\n }\n\n return result;\n };\n \n let dispose = () => {};\n\n if(computedOptions.autoUpdate)\n {\n let options: AutoUpdateOptions;\n\n if(computedOptions.autoUpdate === true)\n {\n options =\n {\n ancestorResize: true,\n ancestorScroll: true,\n elementResize: true\n };\n }\n else\n {\n options = computedOptions.autoUpdate;\n }\n\n dispose = autoUpdate(source,\n target as HTMLElement,\n runComputation,\n options);\n }\n\n const result = await runComputation();\n\n subscriber.next(\n {\n target,\n dispose,\n x: result.x,\n y: result.y\n });\n\n if(!computedOptions.autoUpdate)\n {\n subscriber.complete();\n }\n })();\n });\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets flip middleware\n * @param middlewares - Array of middlewares that will set\n * @param options - Options that contains definition of flip\n */\n protected _setFlip(middlewares: Middleware[], options: PositionOptions): void\n {\n if(options.flip)\n {\n middlewares.push(flip());\n }\n }\n\n /**\n * Sets offset middleware\n * @param middlewares - Array of middlewares that will set\n * @param options - Options that contains definition of offset\n */\n protected _setOffset(middlewares: Middleware[], options: PositionOptions): void\n {\n if(options.offset != PositionOffset.None)\n {\n if(options.offset == PositionOffset.MouseEnter)\n {\n //fallback if not supported placement used\n if(options.placement == PositionPlacement.Left ||\n options.placement == PositionPlacement.LeftStart ||\n options.placement == PositionPlacement.LeftEnd ||\n options.placement == PositionPlacement.Right ||\n options.placement == PositionPlacement.RightStart ||\n options.placement == PositionPlacement.RightEnd ||\n options.placement == PositionPlacement.Bottom ||\n options.placement == PositionPlacement.BottomEnd ||\n options.placement == PositionPlacement.Top ||\n options.placement == PositionPlacement.TopEnd)\n {\n options.placement = PositionPlacement.TopStart;\n }\n }\n\n middlewares.push(offset(({floating, placement}) =>\n {\n if(options.offset == PositionOffset.MouseEnter && options.mouseEvent)\n {\n return options.mouseEvent.offsetX;\n }\n\n let dimension: number;\n\n if(placement == 'bottom' || placement == 'bottom-start' || placement == 'bottom-end' ||\n placement == 'top' || placement == 'top-start' || placement == 'top-end')\n {\n dimension = floating.width;\n }\n else\n {\n dimension = floating.height;\n }\n\n switch(options.offset)\n {\n default:\n {\n dimension = 0;\n\n break;\n }\n case PositionOffset.Full:\n {\n break;\n }\n case PositionOffset.Half:\n {\n dimension /= 2;\n\n break;\n }\n case PositionOffset.NegativeFull:\n {\n dimension *= -1;\n\n break;\n }\n case PositionOffset.NegativeHalf:\n {\n dimension *= -.5;\n\n break;\n }\n }\n\n return {\n crossAxis: dimension\n };\n }));\n }\n }\n\n /**\n * Gets floating ui placement from position placement\n * @param options - Options containing position placement\n */\n protected _getPlacement(options: PositionOptions): Placement\n {\n switch(options.placement)\n {\n default:\n // case PositionPlacement.Top:\n {\n return 'top';\n }\n case PositionPlacement.TopStart:\n {\n return 'top-start';\n }\n case PositionPlacement.TopEnd:\n {\n return 'top-end';\n }\n case PositionPlacement.Bottom:\n {\n return 'bottom';\n }\n case PositionPlacement.BottomStart:\n {\n return 'bottom-start';\n }\n case PositionPlacement.BottomEnd:\n {\n return 'bottom-end';\n }\n case PositionPlacement.Left:\n {\n return 'left';\n }\n case PositionPlacement.LeftStart:\n {\n return 'left-start';\n }\n case PositionPlacement.LeftEnd:\n {\n return 'left-end';\n }\n case PositionPlacement.Right:\n {\n return 'right';\n }\n case PositionPlacement.RightStart:\n {\n return 'right-start';\n }\n case PositionPlacement.RightEnd:\n {\n return 'right-end';\n }\n }\n }\n}\n\n/**\n * Provider for floating ui position implementation\n */\nexport const FLOATING_UI_POSITION: ClassProvider =\n{\n provide: POSITION,\n useClass: FloatingUiDomPosition\n};"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position.interface.js","sourceRoot":"","sources":["../../../../src/services/position/position.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {PositionOffset, PositionPlacement} from './position.types';\n\n/**\n * Options for autoupdate specific functionality\n */\nexport interface AutoUpdateOptions\n{\n /**\n * Indication whether update position when ancestor scroll changes\n */\n ancestorScroll: boolean;\n\n /**\n * Indication whether update position when ancestor size changes\n */\n ancestorResize: boolean;\n\n /**\n * Indication whether update position when target element changes size\n */\n elementResize: boolean;\n}\n\n/**\n * Options that are passed to position service\n */\nexport interface PositionOptions\n{\n //######################### properties #########################\n\n /**\n * Placement of target element against source element\n */\n placement: PositionPlacement;\n\n /**\n * Offset which allows moving target element along the cross axis of placement\n */\n offset: PositionOffset;\n\n /**\n * Indication whether perform flip in case of collision (with view boundaries)\n */\n flip: boolean;\n\n /**\n * Indication whether set up 'auto updating' of position\n */\n autoUpdate: boolean|AutoUpdateOptions;\n\n /**\n *
|
|
1
|
+
{"version":3,"file":"position.interface.js","sourceRoot":"","sources":["../../../../src/services/position/position.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {Observable} from 'rxjs';\n\nimport {PositionOffset, PositionPlacement} from './position.types';\n\n/**\n * Options for autoupdate specific functionality\n */\nexport interface AutoUpdateOptions\n{\n /**\n * Indication whether update position when ancestor scroll changes\n */\n ancestorScroll: boolean;\n\n /**\n * Indication whether update position when ancestor size changes\n */\n ancestorResize: boolean;\n\n /**\n * Indication whether update position when target element changes size\n */\n elementResize: boolean;\n}\n\n/**\n * Options that are passed to position service\n */\nexport interface PositionOptions\n{\n //######################### properties #########################\n\n /**\n * Placement of target element against source element\n */\n placement: PositionPlacement;\n\n /**\n * Offset which allows moving target element along the cross axis of placement\n */\n offset: PositionOffset;\n\n /**\n * Indication whether perform flip in case of collision (with view boundaries)\n */\n flip: boolean;\n\n /**\n * Indication whether set up 'auto updating' of position\n */\n autoUpdate: boolean|AutoUpdateOptions;\n\n /**\n * Mouse event that occured when positioning was called\n */\n mouseEvent?: MouseEvent;\n}\n\n/**\n * Result of positioning process, storing new coordinates\n */\nexport interface PositionResult<TElement extends Element = any>\n{\n /**\n * Target element to be positioned\n */\n target: TElement;\n\n /**\n * X coordinate of position of target\n */\n x: number;\n\n /**\n * Y coordinate of position of target\n */\n y: number;\n\n /**\n * Disposes instance of engine used for positioning\n */\n dispose(): void;\n}\n\n/**\n * Service that is used for positioning two elements against each other\n */\nexport interface Position\n{\n //######################### methods #########################\n\n /**\n * Places target element relatively to source element according options and returns result storing information about new position\n * @param target - Target element to be placed\n * @param source - Source element to be placed against\n * @param options - Optional options with informations about new position\n */\n placeElement(target: Element, source: Element, options?: Partial<PositionOptions>): Observable<PositionResult>;\n}\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { PositionOffset, PositionPlacement, POSITION } from '@anglr/common';
|
|
2
3
|
import { extend } from '@jscrpt/common';
|
|
3
|
-
import { computePosition, autoUpdate } from '@floating-ui/dom';
|
|
4
|
+
import { computePosition, autoUpdate, offset, flip } from '@floating-ui/dom';
|
|
5
|
+
import { Observable } from 'rxjs';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
4
7
|
/**
|
|
5
8
|
* Default options for `FloatingUiDomPosition` implementation
|
|
6
9
|
*/
|
|
@@ -18,35 +21,134 @@ export class FloatingUiDomPosition {
|
|
|
18
21
|
/**
|
|
19
22
|
* @inheritdoc
|
|
20
23
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
placeElement(target, source, options) {
|
|
25
|
+
return new Observable(subscriber => {
|
|
26
|
+
(async () => {
|
|
27
|
+
const computedOptions = extend({}, defaultOptions, options);
|
|
28
|
+
const middlewares = [];
|
|
29
|
+
this._setOffset(middlewares, computedOptions);
|
|
30
|
+
this._setFlip(middlewares, computedOptions);
|
|
31
|
+
const runComputation = async () => {
|
|
32
|
+
const result = await computePosition(source, target, {
|
|
33
|
+
placement: this._getPlacement(computedOptions),
|
|
34
|
+
middleware: middlewares
|
|
35
|
+
});
|
|
36
|
+
if (computedOptions.autoUpdate) {
|
|
37
|
+
subscriber.next({
|
|
38
|
+
target,
|
|
39
|
+
dispose,
|
|
40
|
+
x: result.x,
|
|
41
|
+
y: result.y
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
let dispose = () => { };
|
|
47
|
+
if (computedOptions.autoUpdate) {
|
|
48
|
+
let options;
|
|
49
|
+
if (computedOptions.autoUpdate === true) {
|
|
50
|
+
options =
|
|
51
|
+
{
|
|
52
|
+
ancestorResize: true,
|
|
53
|
+
ancestorScroll: true,
|
|
54
|
+
elementResize: true
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
options = computedOptions.autoUpdate;
|
|
59
|
+
}
|
|
60
|
+
dispose = autoUpdate(source, target, runComputation, options);
|
|
61
|
+
}
|
|
62
|
+
const result = await runComputation();
|
|
63
|
+
subscriber.next({
|
|
29
64
|
target,
|
|
30
|
-
dispose
|
|
65
|
+
dispose,
|
|
31
66
|
x: result.x,
|
|
32
67
|
y: result.y
|
|
33
68
|
});
|
|
69
|
+
if (!computedOptions.autoUpdate) {
|
|
70
|
+
subscriber.complete();
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//######################### protected methods #########################
|
|
76
|
+
/**
|
|
77
|
+
* Sets flip middleware
|
|
78
|
+
* @param middlewares - Array of middlewares that will set
|
|
79
|
+
* @param options - Options that contains definition of flip
|
|
80
|
+
*/
|
|
81
|
+
_setFlip(middlewares, options) {
|
|
82
|
+
if (options.flip) {
|
|
83
|
+
middlewares.push(flip());
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Sets offset middleware
|
|
88
|
+
* @param middlewares - Array of middlewares that will set
|
|
89
|
+
* @param options - Options that contains definition of offset
|
|
90
|
+
*/
|
|
91
|
+
_setOffset(middlewares, options) {
|
|
92
|
+
if (options.offset != PositionOffset.None) {
|
|
93
|
+
if (options.offset == PositionOffset.MouseEnter) {
|
|
94
|
+
//fallback if not supported placement used
|
|
95
|
+
if (options.placement == PositionPlacement.Left ||
|
|
96
|
+
options.placement == PositionPlacement.LeftStart ||
|
|
97
|
+
options.placement == PositionPlacement.LeftEnd ||
|
|
98
|
+
options.placement == PositionPlacement.Right ||
|
|
99
|
+
options.placement == PositionPlacement.RightStart ||
|
|
100
|
+
options.placement == PositionPlacement.RightEnd ||
|
|
101
|
+
options.placement == PositionPlacement.Bottom ||
|
|
102
|
+
options.placement == PositionPlacement.BottomEnd ||
|
|
103
|
+
options.placement == PositionPlacement.Top ||
|
|
104
|
+
options.placement == PositionPlacement.TopEnd) {
|
|
105
|
+
options.placement = PositionPlacement.TopStart;
|
|
106
|
+
}
|
|
34
107
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
108
|
+
middlewares.push(offset(({ floating, placement }) => {
|
|
109
|
+
if (options.offset == PositionOffset.MouseEnter && options.mouseEvent) {
|
|
110
|
+
return options.mouseEvent.offsetX;
|
|
111
|
+
}
|
|
112
|
+
let dimension;
|
|
113
|
+
if (placement == 'bottom' || placement == 'bottom-start' || placement == 'bottom-end' ||
|
|
114
|
+
placement == 'top' || placement == 'top-start' || placement == 'top-end') {
|
|
115
|
+
dimension = floating.width;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
dimension = floating.height;
|
|
119
|
+
}
|
|
120
|
+
switch (options.offset) {
|
|
121
|
+
default:
|
|
122
|
+
{
|
|
123
|
+
dimension = 0;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case PositionOffset.Full:
|
|
127
|
+
{
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case PositionOffset.Half:
|
|
131
|
+
{
|
|
132
|
+
dimension /= 2;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case PositionOffset.NegativeFull:
|
|
136
|
+
{
|
|
137
|
+
dimension *= -1;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case PositionOffset.NegativeHalf:
|
|
141
|
+
{
|
|
142
|
+
dimension *= -.5;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
crossAxis: dimension
|
|
148
|
+
};
|
|
149
|
+
}));
|
|
41
150
|
}
|
|
42
|
-
return {
|
|
43
|
-
target,
|
|
44
|
-
dispose,
|
|
45
|
-
x: result.x,
|
|
46
|
-
y: result.y
|
|
47
|
-
};
|
|
48
151
|
}
|
|
49
|
-
//######################### protected methods #########################
|
|
50
152
|
/**
|
|
51
153
|
* Gets floating ui placement from position placement
|
|
52
154
|
* @param options - Options containing position placement
|
|
@@ -56,7 +158,7 @@ export class FloatingUiDomPosition {
|
|
|
56
158
|
default:
|
|
57
159
|
// case PositionPlacement.Top:
|
|
58
160
|
{
|
|
59
|
-
return '
|
|
161
|
+
return 'top';
|
|
60
162
|
}
|
|
61
163
|
case PositionPlacement.TopStart:
|
|
62
164
|
{
|
|
@@ -105,4 +207,16 @@ export class FloatingUiDomPosition {
|
|
|
105
207
|
}
|
|
106
208
|
}
|
|
107
209
|
}
|
|
210
|
+
FloatingUiDomPosition.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: FloatingUiDomPosition, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
211
|
+
FloatingUiDomPosition.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: FloatingUiDomPosition });
|
|
212
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: FloatingUiDomPosition, decorators: [{
|
|
213
|
+
type: Injectable
|
|
214
|
+
}] });
|
|
215
|
+
/**
|
|
216
|
+
* Provider for floating ui position implementation
|
|
217
|
+
*/
|
|
218
|
+
export const FLOATING_UI_POSITION = {
|
|
219
|
+
provide: POSITION,
|
|
220
|
+
useClass: FloatingUiDomPosition
|
|
221
|
+
};
|
|
108
222
|
//# sourceMappingURL=floatingUiDomPosition.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floatingUiDomPosition.service.js","sourceRoot":"","sources":["../../../../floating-ui/src/services/floatingUiDomPosition.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,cAAc,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,eAAe,EAAa,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAExE;;GAEG;AACH,MAAM,cAAc,GACpB;IACI,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,cAAc,CAAC,IAAI;IAC3B,SAAS,EAAE,iBAAiB,CAAC,GAAG;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAE9B,iGAAiG;IAEjG;;OAEG;IACI,KAAK,CAAC,YAAY,CAAC,MAAe,EAAE,MAAe,EAAE,OAAkC;QAE1F,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;QAE5D,MAAM,cAAc,GAAG,KAAK,IAAI,EAAE;YAE9B,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,MAAM,EACN,MAAqB,EACrB;gBACI,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC;aACjD,CAAC,CAAC;YAExC,IAAG,eAAe,CAAC,UAAU,IAAI,eAAe,CAAC,mB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AK,iBAAiB,CAAC,OAAO;gBAC9B;oBACI,OAAO,UAAU,CAAC;iBACrB;YACD,KAAK,iBAAiB,CAAC,KAAK;gBAC5B;oBACI,OAAO,OAAO,CAAC;iBAClB;YACD,KAAK,iBAAiB,CAAC,UAAU;gBACjC;oBACI,OAAO,aAAa,CAAC;iBACxB;YACD,KAAK,iBAAiB,CAAC,QAAQ;gBAC/B;oBACI,OAAO,WAAW,CAAC;iBACtB;SACJ;IACL,CAAC;CACJ","sourcesContent":["import {Position, PositionResult, PositionOptions, PositionOffset, PositionPlacement} from '@anglr/common';\nimport {extend} from '@jscrpt/common';\nimport {computePosition, Placement, autoUpdate} from '@floating-ui/dom';\n\n/**\n * Default options for `FloatingUiDomPosition` implementation\n */\nconst defaultOptions: PositionOptions =\n{\n autoUpdate: false,\n flip: false,\n offset: PositionOffset.None,\n placement: PositionPlacement.Top\n};\n\n/**\n * Service that is used for positioning two elements against each other, using floating-ui dom implementation\n */\nexport class FloatingUiDomPosition implements Position\n{\n //######################### public methods - implementation of Position #########################\n\n /**\n * @inheritdoc\n */\n public async placeElement(target: Element, source: Element, options?: Partial<PositionOptions>): Promise<PositionResult>\n {\n const computedOptions = extend({}, defaultOptions, options);\n\n const runComputation = async () =>\n {\n const result = await computePosition(source,\n target as HTMLElement,\n {\n placement: this._getPlacement(computedOptions)\n });\n\n if(computedOptions.autoUpdate && computedOptions.autoUpdateProcessor)\n {\n computedOptions.autoUpdateProcessor(\n {\n target,\n dispose: () => {},\n x: result.x,\n y: result.y\n });\n }\n\n return result;\n };\n\n const result = await runComputation();\n let dispose = () => {};\n\n if(computedOptions.autoUpdate)\n {\n dispose = autoUpdate(source, target as HTMLElement, runComputation);\n }\n\n return {\n target,\n dispose,\n x: result.x,\n y: result.y\n };\n }\n\n //######################### protected methods #########################\n\n /**\n * Gets floating ui placement from position placement\n * @param options - Options containing position placement\n */\n protected _getPlacement(options: PositionOptions): Placement\n {\n switch(options.placement)\n {\n default:\n // case PositionPlacement.Top:\n {\n return 'bottom';\n }\n case PositionPlacement.TopStart:\n {\n return 'top-start';\n }\n case PositionPlacement.TopEnd:\n {\n return 'top-end';\n }\n case PositionPlacement.Bottom:\n {\n return 'bottom';\n }\n case PositionPlacement.BottomStart:\n {\n return 'bottom-start';\n }\n case PositionPlacement.BottomEnd:\n {\n return 'bottom-end';\n }\n case PositionPlacement.Left:\n {\n return 'left';\n }\n case PositionPlacement.LeftStart:\n {\n return 'left-start';\n }\n case PositionPlacement.LeftEnd:\n {\n return 'left-end';\n }\n case PositionPlacement.Right:\n {\n return 'right';\n }\n case PositionPlacement.RightStart:\n {\n return 'right-start';\n }\n case PositionPlacement.RightEnd:\n {\n return 'right-end';\n }\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"floatingUiDomPosition.service.js","sourceRoot":"","sources":["../../../../floating-ui/src/services/floatingUiDomPosition.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAC,MAAM,eAAe,CAAC;AACxD,OAAO,EAA4C,cAAc,EAAE,iBAAiB,EAAqB,QAAQ,EAAC,MAAM,eAAe,CAAC;AACxI,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,eAAe,EAAa,UAAU,EAAc,MAAM,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;;AAEhC;;GAEG;AACH,MAAM,cAAc,GACpB;IACI,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,cAAc,CAAC,IAAI;IAC3B,SAAS,EAAE,iBAAiB,CAAC,GAAG;CACnC,CAAC;AAEF;;GAEG;AAEH,MAAM,OAAO,qBAAqB;IAE9B,iGAAiG;IAEjG;;OAEG;IACI,YAAY,CAAC,MAAe,EAAE,MAAe,EAAE,OAAkC;QAEpF,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE;YAE/B,CAAC,KAAK,IAAI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;iBACtB;YACD,KAAK,iBAAiB,CAAC,MAAM;gBAC7B;oBACI,OAAO,SAAS,CAAC;iBACpB;YACD,KAAK,iBAAiB,CAAC,MAAM;gBAC7B;oBACI,OAAO,QAAQ,CAAC;iBACnB;YACD,KAAK,iBAAiB,CAAC,WAAW;gBAClC;oBACI,OAAO,cAAc,CAAC;iBACzB;YACD,KAAK,iBAAiB,CAAC,SAAS;gBAChC;oBACI,OAAO,YAAY,CAAC;iBACvB;YACD,KAAK,iBAAiB,CAAC,IAAI;gBAC3B;oBACI,OAAO,MAAM,CAAC;iBACjB;YACD,KAAK,iBAAiB,CAAC,SAAS;gBAChC;oBACI,OAAO,YAAY,CAAC;iBACvB;YACD,KAAK,iBAAiB,CAAC,OAAO;gBAC9B;oBACI,OAAO,UAAU,CAAC;iBACrB;YACD,KAAK,iBAAiB,CAAC,KAAK;gBAC5B;oBACI,OAAO,OAAO,CAAC;iBAClB;YACD,KAAK,iBAAiB,CAAC,UAAU;gBACjC;oBACI,OAAO,aAAa,CAAC;iBACxB;YACD,KAAK,iBAAiB,CAAC,QAAQ;gBAC/B;oBACI,OAAO,WAAW,CAAC;iBACtB;SACJ;IACL,CAAC;;kHApPQ,qBAAqB;sHAArB,qBAAqB;2FAArB,qBAAqB;kBADjC,UAAU;;AAwPX;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GACjC;IACI,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,qBAAqB;CAClC,CAAC","sourcesContent":["import {ClassProvider, Injectable} from '@angular/core';\nimport {Position, PositionResult, PositionOptions, PositionOffset, PositionPlacement, AutoUpdateOptions, POSITION} from '@anglr/common';\nimport {extend} from '@jscrpt/common';\nimport {computePosition, Placement, autoUpdate, Middleware, offset, flip} from '@floating-ui/dom';\nimport {Observable} from 'rxjs';\n\n/**\n * Default options for `FloatingUiDomPosition` implementation\n */\nconst defaultOptions: PositionOptions =\n{\n autoUpdate: false,\n flip: false,\n offset: PositionOffset.None,\n placement: PositionPlacement.Top\n};\n\n/**\n * Service that is used for positioning two elements against each other, using floating-ui dom implementation\n */\n@Injectable()\nexport class FloatingUiDomPosition implements Position\n{\n //######################### public methods - implementation of Position #########################\n\n /**\n * @inheritdoc\n */\n public placeElement(target: Element, source: Element, options?: Partial<PositionOptions>): Observable<PositionResult>\n {\n return new Observable(subscriber =>\n {\n (async () =>\n {\n const computedOptions = extend({}, defaultOptions, options);\n const middlewares: Middleware[] = [];\n\n this._setOffset(middlewares, computedOptions);\n this._setFlip(middlewares, computedOptions);\n\n const runComputation = async () =>\n {\n const result = await computePosition(source,\n target as HTMLElement,\n {\n placement: this._getPlacement(computedOptions),\n middleware: middlewares\n });\n\n if(computedOptions.autoUpdate)\n {\n subscriber.next(\n {\n target,\n dispose,\n x: result.x,\n y: result.y\n });\n }\n\n return result;\n };\n \n let dispose = () => {};\n\n if(computedOptions.autoUpdate)\n {\n let options: AutoUpdateOptions;\n\n if(computedOptions.autoUpdate === true)\n {\n options =\n {\n ancestorResize: true,\n ancestorScroll: true,\n elementResize: true\n };\n }\n else\n {\n options = computedOptions.autoUpdate;\n }\n\n dispose = autoUpdate(source,\n target as HTMLElement,\n runComputation,\n options);\n }\n\n const result = await runComputation();\n\n subscriber.next(\n {\n target,\n dispose,\n x: result.x,\n y: result.y\n });\n\n if(!computedOptions.autoUpdate)\n {\n subscriber.complete();\n }\n })();\n });\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets flip middleware\n * @param middlewares - Array of middlewares that will set\n * @param options - Options that contains definition of flip\n */\n protected _setFlip(middlewares: Middleware[], options: PositionOptions): void\n {\n if(options.flip)\n {\n middlewares.push(flip());\n }\n }\n\n /**\n * Sets offset middleware\n * @param middlewares - Array of middlewares that will set\n * @param options - Options that contains definition of offset\n */\n protected _setOffset(middlewares: Middleware[], options: PositionOptions): void\n {\n if(options.offset != PositionOffset.None)\n {\n if(options.offset == PositionOffset.MouseEnter)\n {\n //fallback if not supported placement used\n if(options.placement == PositionPlacement.Left ||\n options.placement == PositionPlacement.LeftStart ||\n options.placement == PositionPlacement.LeftEnd ||\n options.placement == PositionPlacement.Right ||\n options.placement == PositionPlacement.RightStart ||\n options.placement == PositionPlacement.RightEnd ||\n options.placement == PositionPlacement.Bottom ||\n options.placement == PositionPlacement.BottomEnd ||\n options.placement == PositionPlacement.Top ||\n options.placement == PositionPlacement.TopEnd)\n {\n options.placement = PositionPlacement.TopStart;\n }\n }\n\n middlewares.push(offset(({floating, placement}) =>\n {\n if(options.offset == PositionOffset.MouseEnter && options.mouseEvent)\n {\n return options.mouseEvent.offsetX;\n }\n\n let dimension: number;\n\n if(placement == 'bottom' || placement == 'bottom-start' || placement == 'bottom-end' ||\n placement == 'top' || placement == 'top-start' || placement == 'top-end')\n {\n dimension = floating.width;\n }\n else\n {\n dimension = floating.height;\n }\n\n switch(options.offset)\n {\n default:\n {\n dimension = 0;\n\n break;\n }\n case PositionOffset.Full:\n {\n break;\n }\n case PositionOffset.Half:\n {\n dimension /= 2;\n\n break;\n }\n case PositionOffset.NegativeFull:\n {\n dimension *= -1;\n\n break;\n }\n case PositionOffset.NegativeHalf:\n {\n dimension *= -.5;\n\n break;\n }\n }\n\n return {\n crossAxis: dimension\n };\n }));\n }\n }\n\n /**\n * Gets floating ui placement from position placement\n * @param options - Options containing position placement\n */\n protected _getPlacement(options: PositionOptions): Placement\n {\n switch(options.placement)\n {\n default:\n // case PositionPlacement.Top:\n {\n return 'top';\n }\n case PositionPlacement.TopStart:\n {\n return 'top-start';\n }\n case PositionPlacement.TopEnd:\n {\n return 'top-end';\n }\n case PositionPlacement.Bottom:\n {\n return 'bottom';\n }\n case PositionPlacement.BottomStart:\n {\n return 'bottom-start';\n }\n case PositionPlacement.BottomEnd:\n {\n return 'bottom-end';\n }\n case PositionPlacement.Left:\n {\n return 'left';\n }\n case PositionPlacement.LeftStart:\n {\n return 'left-start';\n }\n case PositionPlacement.LeftEnd:\n {\n return 'left-end';\n }\n case PositionPlacement.Right:\n {\n return 'right';\n }\n case PositionPlacement.RightStart:\n {\n return 'right-start';\n }\n case PositionPlacement.RightEnd:\n {\n return 'right-end';\n }\n }\n }\n}\n\n/**\n * Provider for floating ui position implementation\n */\nexport const FLOATING_UI_POSITION: ClassProvider =\n{\n provide: POSITION,\n useClass: FloatingUiDomPosition\n};"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position.interface.js","sourceRoot":"","sources":["../../../../src/services/position/position.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {PositionOffset, PositionPlacement} from './position.types';\n\n/**\n * Options for autoupdate specific functionality\n */\nexport interface AutoUpdateOptions\n{\n /**\n * Indication whether update position when ancestor scroll changes\n */\n ancestorScroll: boolean;\n\n /**\n * Indication whether update position when ancestor size changes\n */\n ancestorResize: boolean;\n\n /**\n * Indication whether update position when target element changes size\n */\n elementResize: boolean;\n}\n\n/**\n * Options that are passed to position service\n */\nexport interface PositionOptions\n{\n //######################### properties #########################\n\n /**\n * Placement of target element against source element\n */\n placement: PositionPlacement;\n\n /**\n * Offset which allows moving target element along the cross axis of placement\n */\n offset: PositionOffset;\n\n /**\n * Indication whether perform flip in case of collision (with view boundaries)\n */\n flip: boolean;\n\n /**\n * Indication whether set up 'auto updating' of position\n */\n autoUpdate: boolean|AutoUpdateOptions;\n\n /**\n *
|
|
1
|
+
{"version":3,"file":"position.interface.js","sourceRoot":"","sources":["../../../../src/services/position/position.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {Observable} from 'rxjs';\n\nimport {PositionOffset, PositionPlacement} from './position.types';\n\n/**\n * Options for autoupdate specific functionality\n */\nexport interface AutoUpdateOptions\n{\n /**\n * Indication whether update position when ancestor scroll changes\n */\n ancestorScroll: boolean;\n\n /**\n * Indication whether update position when ancestor size changes\n */\n ancestorResize: boolean;\n\n /**\n * Indication whether update position when target element changes size\n */\n elementResize: boolean;\n}\n\n/**\n * Options that are passed to position service\n */\nexport interface PositionOptions\n{\n //######################### properties #########################\n\n /**\n * Placement of target element against source element\n */\n placement: PositionPlacement;\n\n /**\n * Offset which allows moving target element along the cross axis of placement\n */\n offset: PositionOffset;\n\n /**\n * Indication whether perform flip in case of collision (with view boundaries)\n */\n flip: boolean;\n\n /**\n * Indication whether set up 'auto updating' of position\n */\n autoUpdate: boolean|AutoUpdateOptions;\n\n /**\n * Mouse event that occured when positioning was called\n */\n mouseEvent?: MouseEvent;\n}\n\n/**\n * Result of positioning process, storing new coordinates\n */\nexport interface PositionResult<TElement extends Element = any>\n{\n /**\n * Target element to be positioned\n */\n target: TElement;\n\n /**\n * X coordinate of position of target\n */\n x: number;\n\n /**\n * Y coordinate of position of target\n */\n y: number;\n\n /**\n * Disposes instance of engine used for positioning\n */\n dispose(): void;\n}\n\n/**\n * Service that is used for positioning two elements against each other\n */\nexport interface Position\n{\n //######################### methods #########################\n\n /**\n * Places target element relatively to source element according options and returns result storing information about new position\n * @param target - Target element to be placed\n * @param source - Source element to be placed against\n * @param options - Optional options with informations about new position\n */\n placeElement(target: Element, source: Element, options?: Partial<PositionOptions>): Observable<PositionResult>;\n}\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { ClassProvider } from '@angular/core';
|
|
1
2
|
import { Position, PositionResult, PositionOptions } from '@anglr/common';
|
|
2
|
-
import { Placement } from '@floating-ui/dom';
|
|
3
|
+
import { Placement, Middleware } from '@floating-ui/dom';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
3
6
|
/**
|
|
4
7
|
* Service that is used for positioning two elements against each other, using floating-ui dom implementation
|
|
5
8
|
*/
|
|
@@ -7,11 +10,29 @@ export declare class FloatingUiDomPosition implements Position {
|
|
|
7
10
|
/**
|
|
8
11
|
* @inheritdoc
|
|
9
12
|
*/
|
|
10
|
-
placeElement(target: Element, source: Element, options?: Partial<PositionOptions>):
|
|
13
|
+
placeElement(target: Element, source: Element, options?: Partial<PositionOptions>): Observable<PositionResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Sets flip middleware
|
|
16
|
+
* @param middlewares - Array of middlewares that will set
|
|
17
|
+
* @param options - Options that contains definition of flip
|
|
18
|
+
*/
|
|
19
|
+
protected _setFlip(middlewares: Middleware[], options: PositionOptions): void;
|
|
20
|
+
/**
|
|
21
|
+
* Sets offset middleware
|
|
22
|
+
* @param middlewares - Array of middlewares that will set
|
|
23
|
+
* @param options - Options that contains definition of offset
|
|
24
|
+
*/
|
|
25
|
+
protected _setOffset(middlewares: Middleware[], options: PositionOptions): void;
|
|
11
26
|
/**
|
|
12
27
|
* Gets floating ui placement from position placement
|
|
13
28
|
* @param options - Options containing position placement
|
|
14
29
|
*/
|
|
15
30
|
protected _getPlacement(options: PositionOptions): Placement;
|
|
31
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FloatingUiDomPosition, never>;
|
|
32
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<FloatingUiDomPosition>;
|
|
16
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Provider for floating ui position implementation
|
|
36
|
+
*/
|
|
37
|
+
export declare const FLOATING_UI_POSITION: ClassProvider;
|
|
17
38
|
//# sourceMappingURL=floatingUiDomPosition.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floatingUiDomPosition.service.d.ts","sourceRoot":"","sources":["floatingUiDomPosition.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"floatingUiDomPosition.service.d.ts","sourceRoot":"","sources":["floatingUiDomPosition.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAa,MAAM,eAAe,CAAC;AACxD,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAiE,MAAM,eAAe,CAAC;AAExI,OAAO,EAAkB,SAAS,EAAc,UAAU,EAAe,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;;AAahC;;GAEG;AACH,qBACa,qBAAsB,YAAW,QAAQ;IAIlD;;OAEG;IACI,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,cAAc,CAAC;IAiFrH;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI;IAQ7E;;;;OAIG;IACH,SAAS,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI;IAgF/E;;;OAGG;IACH,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,SAAS;yCA9LnD,qBAAqB;6CAArB,qBAAqB;CAqPjC;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAIlC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anglr/common",
|
|
3
|
-
"version": "11.2.0-beta.
|
|
3
|
+
"version": "11.2.0-beta.20220301090733",
|
|
4
4
|
"description": "Angular module for common angular stuff",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -186,6 +186,14 @@
|
|
|
186
186
|
"node": "./es2015/date-fns/src/index.js",
|
|
187
187
|
"default": "./es2020/date-fns/src/index.js"
|
|
188
188
|
},
|
|
189
|
+
"./floating-ui": {
|
|
190
|
+
"types": "./floating-ui/src/index.d.ts",
|
|
191
|
+
"esm2020": "./es2020/floating-ui/src/index.js",
|
|
192
|
+
"es2020": "./es2020/floating-ui/src/index.js",
|
|
193
|
+
"es2015": "./es2015/floating-ui/src/index.js",
|
|
194
|
+
"node": "./es2015/floating-ui/src/index.js",
|
|
195
|
+
"default": "./es2020/floating-ui/src/index.js"
|
|
196
|
+
},
|
|
189
197
|
"./forms": {
|
|
190
198
|
"types": "./forms/src/index.d.ts",
|
|
191
199
|
"esm2020": "./es2020/forms/src/index.js",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
1
2
|
import { PositionOffset, PositionPlacement } from './position.types';
|
|
2
3
|
/**
|
|
3
4
|
* Options for autoupdate specific functionality
|
|
@@ -36,10 +37,6 @@ export interface PositionOptions {
|
|
|
36
37
|
* Indication whether set up 'auto updating' of position
|
|
37
38
|
*/
|
|
38
39
|
autoUpdate: boolean | AutoUpdateOptions;
|
|
39
|
-
/**
|
|
40
|
-
* Function that is called when auto updated is called for processing result
|
|
41
|
-
*/
|
|
42
|
-
autoUpdateProcessor?: (result: PositionResult) => void;
|
|
43
40
|
/**
|
|
44
41
|
* Mouse event that occured when positioning was called
|
|
45
42
|
*/
|
|
@@ -76,6 +73,6 @@ export interface Position {
|
|
|
76
73
|
* @param source - Source element to be placed against
|
|
77
74
|
* @param options - Optional options with informations about new position
|
|
78
75
|
*/
|
|
79
|
-
placeElement(target: Element, source: Element, options?: Partial<PositionOptions>):
|
|
76
|
+
placeElement(target: Element, source: Element, options?: Partial<PositionOptions>): Observable<PositionResult>;
|
|
80
77
|
}
|
|
81
78
|
//# sourceMappingURL=position.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position.interface.d.ts","sourceRoot":"","sources":["position.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAE9B;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAI5B;;OAEG;IACH,SAAS,EAAE,iBAAiB,CAAC;IAE7B;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IAEd;;OAEG;IACH,UAAU,EAAE,OAAO,GAAC,iBAAiB,CAAC;IAEtC;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"position.interface.d.ts","sourceRoot":"","sources":["position.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAC,cAAc,EAAE,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAE9B;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAI5B;;OAEG;IACH,SAAS,EAAE,iBAAiB,CAAC;IAE7B;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IAEd;;OAEG;IACH,UAAU,EAAE,OAAO,GAAC,iBAAiB,CAAC;IAEtC;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,QAAQ,SAAS,OAAO,GAAG,GAAG;IAE1D;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEjB;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IAEV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IAEV;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IAIrB;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;CAClH"}
|
package/version.bak
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
11.2.0-beta.
|
|
1
|
+
11.2.0-beta.20220301090733
|