@aquera/nile-elements 1.5.9 → 1.6.1
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 +6 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +382 -227
- package/dist/nile-floating-panel/index.cjs.js +1 -1
- package/dist/nile-floating-panel/index.esm.js +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.cjs.js +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.cjs.js.map +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.css.cjs.js +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.css.cjs.js.map +1 -1
- package/dist/nile-floating-panel/nile-floating-panel.css.esm.js +137 -21
- package/dist/nile-floating-panel/nile-floating-panel.esm.js +1 -1
- package/dist/nile-lite-tooltip/index.cjs.js +1 -1
- package/dist/nile-lite-tooltip/index.esm.js +1 -1
- package/dist/nile-lite-tooltip/nile-lite-tooltip.cjs.js +1 -1
- package/dist/nile-lite-tooltip/nile-lite-tooltip.cjs.js.map +1 -1
- package/dist/nile-lite-tooltip/nile-lite-tooltip.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.esm.js +24 -0
- package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.esm.js +59 -44
- package/dist/nile-rich-text-editor/utils/inline-utils.cjs.js +1 -1
- package/dist/nile-rich-text-editor/utils/inline-utils.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/utils/inline-utils.esm.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-floating-panel/index.js.map +1 -1
- package/dist/src/nile-floating-panel/nile-floating-panel.css.d.ts +1 -1
- package/dist/src/nile-floating-panel/nile-floating-panel.css.js +147 -20
- package/dist/src/nile-floating-panel/nile-floating-panel.css.js.map +1 -1
- package/dist/src/nile-floating-panel/nile-floating-panel.d.ts +90 -24
- package/dist/src/nile-floating-panel/nile-floating-panel.js +478 -159
- package/dist/src/nile-floating-panel/nile-floating-panel.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +24 -0
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.d.ts +6 -0
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +62 -24
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-link.d.ts +12 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.js +239 -130
- package/dist/src/nile-rich-text-editor/nile-rte-link.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.d.ts +1 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.js +469 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.js.map +1 -0
- package/dist/src/nile-rich-text-editor/utils/inline-utils.js +13 -4
- package/dist/src/nile-rich-text-editor/utils/inline-utils.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tippy.esm-57628c2b.esm.js +1 -0
- package/dist/tippy.esm-78baa8f2.cjs.js +2 -0
- package/dist/tippy.esm-78baa8f2.cjs.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/index.ts +2 -2
- package/src/nile-floating-panel/index.ts +0 -1
- package/src/nile-floating-panel/nile-floating-panel.css.ts +149 -21
- package/src/nile-floating-panel/nile-floating-panel.ts +489 -190
- package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +24 -0
- package/src/nile-rich-text-editor/nile-rich-text-editor.ts +66 -26
- package/src/nile-rich-text-editor/nile-rte-link.test.ts +682 -0
- package/src/nile-rich-text-editor/nile-rte-link.ts +195 -100
- package/src/nile-rich-text-editor/utils/inline-utils.ts +11 -4
- package/vscode-html-custom-data.json +229 -25
- package/dist/nile-floating-panel/anchor-manager.cjs.js +0 -2
- package/dist/nile-floating-panel/anchor-manager.cjs.js.map +0 -1
- package/dist/nile-floating-panel/anchor-manager.esm.js +0 -1
- package/dist/nile-floating-panel/content-manager.cjs.js +0 -2
- package/dist/nile-floating-panel/content-manager.cjs.js.map +0 -1
- package/dist/nile-floating-panel/content-manager.esm.js +0 -1
- package/dist/nile-floating-panel/event-manager.cjs.js +0 -2
- package/dist/nile-floating-panel/event-manager.cjs.js.map +0 -1
- package/dist/nile-floating-panel/event-manager.esm.js +0 -1
- package/dist/nile-floating-panel/position-manager.cjs.js +0 -2
- package/dist/nile-floating-panel/position-manager.cjs.js.map +0 -1
- package/dist/nile-floating-panel/position-manager.esm.js +0 -1
- package/dist/nile-floating-panel/style-manager.cjs.js +0 -2
- package/dist/nile-floating-panel/style-manager.cjs.js.map +0 -1
- package/dist/nile-floating-panel/style-manager.esm.js +0 -1
- package/dist/nile-floating-panel/types.cjs.js +0 -2
- package/dist/nile-floating-panel/types.cjs.js.map +0 -1
- package/dist/nile-floating-panel/types.esm.js +0 -1
- package/dist/src/nile-floating-panel/anchor-manager.d.ts +0 -6
- package/dist/src/nile-floating-panel/anchor-manager.js +0 -27
- package/dist/src/nile-floating-panel/anchor-manager.js.map +0 -1
- package/dist/src/nile-floating-panel/content-manager.d.ts +0 -5
- package/dist/src/nile-floating-panel/content-manager.js +0 -44
- package/dist/src/nile-floating-panel/content-manager.js.map +0 -1
- package/dist/src/nile-floating-panel/event-manager.d.ts +0 -14
- package/dist/src/nile-floating-panel/event-manager.js +0 -52
- package/dist/src/nile-floating-panel/event-manager.js.map +0 -1
- package/dist/src/nile-floating-panel/position-manager.d.ts +0 -17
- package/dist/src/nile-floating-panel/position-manager.js +0 -72
- package/dist/src/nile-floating-panel/position-manager.js.map +0 -1
- package/dist/src/nile-floating-panel/style-manager.d.ts +0 -9
- package/dist/src/nile-floating-panel/style-manager.js +0 -44
- package/dist/src/nile-floating-panel/style-manager.js.map +0 -1
- package/dist/src/nile-floating-panel/types.d.ts +0 -11
- package/dist/src/nile-floating-panel/types.js +0 -2
- package/dist/src/nile-floating-panel/types.js.map +0 -1
- package/src/nile-floating-panel/anchor-manager.ts +0 -33
- package/src/nile-floating-panel/content-manager.ts +0 -54
- package/src/nile-floating-panel/event-manager.ts +0 -74
- package/src/nile-floating-panel/position-manager.ts +0 -102
- package/src/nile-floating-panel/style-manager.ts +0 -54
- package/src/nile-floating-panel/types.ts +0 -15
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export class ContentManager {
|
|
2
|
-
static updatePanelContent(panelContainer, slot, dataContent) {
|
|
3
|
-
panelContainer.innerHTML = '';
|
|
4
|
-
const slotContent = slot ? slot.assignedNodes({ flatten: true }) : [];
|
|
5
|
-
const hasSlotContent = slotContent.length > 0 &&
|
|
6
|
-
slotContent.some(node => {
|
|
7
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
8
|
-
return node.textContent?.trim() !== '';
|
|
9
|
-
}
|
|
10
|
-
return node instanceof HTMLElement;
|
|
11
|
-
});
|
|
12
|
-
if (hasSlotContent) {
|
|
13
|
-
slotContent.forEach(node => {
|
|
14
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
15
|
-
const textNode = document.createTextNode(node.textContent || '');
|
|
16
|
-
panelContainer.appendChild(textNode);
|
|
17
|
-
}
|
|
18
|
-
else if (node instanceof HTMLElement) {
|
|
19
|
-
panelContainer.appendChild(node.cloneNode(true));
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
else if (dataContent) {
|
|
24
|
-
panelContainer.textContent = dataContent;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
static hasSlotContent(slot) {
|
|
28
|
-
if (!slot) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
const slotContent = slot.assignedNodes({ flatten: true });
|
|
32
|
-
return slotContent.length > 0 &&
|
|
33
|
-
slotContent.some(node => {
|
|
34
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
35
|
-
return node.textContent?.trim() !== '';
|
|
36
|
-
}
|
|
37
|
-
return node instanceof HTMLElement;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
static getSlotContent(slot) {
|
|
41
|
-
return slot ? slot.assignedNodes({ flatten: true }) : [];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=content-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-manager.js","sourceRoot":"","sources":["../../../src/nile-floating-panel/content-manager.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;IACzB,MAAM,CAAC,kBAAkB,CACvB,cAA2B,EAC3B,IAA4B,EAC5B,WAAmB;QAEnB,cAAc,CAAC,SAAS,GAAG,EAAE,CAAC;QAE9B,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAEtE,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC;YAC3C,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACtB,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;oBACrC,OAAO,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gBACzC,CAAC;gB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EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,CAAC;CACF","sourcesContent":["import type { FloatingPanelContentConfig } from './types';\n\nexport class ContentManager {\n static updatePanelContent(\n panelContainer: HTMLElement,\n slot: HTMLSlotElement | null,\n dataContent: string\n ): void {\n panelContainer.innerHTML = '';\n\n const slotContent = slot ? slot.assignedNodes({ flatten: true }) : [];\n\n const hasSlotContent = slotContent.length > 0 &&\n slotContent.some(node => {\n if (node.nodeType === Node.TEXT_NODE) {\n return node.textContent?.trim() !== '';\n }\n return node instanceof HTMLElement;\n });\n\n if (hasSlotContent) {\n slotContent.forEach(node => {\n if (node.nodeType === Node.TEXT_NODE) {\n const textNode = document.createTextNode(node.textContent || '');\n panelContainer.appendChild(textNode);\n } else if (node instanceof HTMLElement) {\n panelContainer.appendChild(node.cloneNode(true));\n }\n });\n } else if (dataContent) {\n panelContainer.textContent = dataContent;\n }\n }\n\n static hasSlotContent(slot: HTMLSlotElement | null): boolean {\n if (!slot) {\n return false;\n }\n\n const slotContent = slot.assignedNodes({ flatten: true });\n return slotContent.length > 0 &&\n slotContent.some(node => {\n if (node.nodeType === Node.TEXT_NODE) {\n return node.textContent?.trim() !== '';\n }\n return node instanceof HTMLElement;\n });\n }\n\n static getSlotContent(slot: HTMLSlotElement | null): Node[] {\n return slot ? slot.assignedNodes({ flatten: true }) : [];\n }\n}\n\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare class EventManager {
|
|
2
|
-
private component;
|
|
3
|
-
private panelContainer;
|
|
4
|
-
private closeOnOutsideClick;
|
|
5
|
-
private isOpen;
|
|
6
|
-
private boundHandleDocumentClick;
|
|
7
|
-
private onCloseCallback;
|
|
8
|
-
constructor(component: HTMLElement);
|
|
9
|
-
setupOutsideClickHandler(panelContainer: HTMLElement, closeOnOutsideClick: boolean, isOpen: boolean, onClose: () => void): void;
|
|
10
|
-
updateOutsideClickHandler(panelContainer: HTMLElement | null, closeOnOutsideClick: boolean, isOpen: boolean): void;
|
|
11
|
-
cleanupOutsideClickHandler(): void;
|
|
12
|
-
private handleDocumentClick;
|
|
13
|
-
destroy(): void;
|
|
14
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export class EventManager {
|
|
2
|
-
constructor(component) {
|
|
3
|
-
this.panelContainer = null;
|
|
4
|
-
this.closeOnOutsideClick = true;
|
|
5
|
-
this.isOpen = false;
|
|
6
|
-
this.boundHandleDocumentClick = null;
|
|
7
|
-
this.onCloseCallback = null;
|
|
8
|
-
this.component = component;
|
|
9
|
-
}
|
|
10
|
-
setupOutsideClickHandler(panelContainer, closeOnOutsideClick, isOpen, onClose) {
|
|
11
|
-
this.panelContainer = panelContainer;
|
|
12
|
-
this.closeOnOutsideClick = closeOnOutsideClick;
|
|
13
|
-
this.isOpen = isOpen;
|
|
14
|
-
this.onCloseCallback = onClose;
|
|
15
|
-
if (!this.closeOnOutsideClick || this.boundHandleDocumentClick) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
this.boundHandleDocumentClick = this.handleDocumentClick.bind(this);
|
|
19
|
-
document.addEventListener('mousedown', this.boundHandleDocumentClick, true);
|
|
20
|
-
}
|
|
21
|
-
updateOutsideClickHandler(panelContainer, closeOnOutsideClick, isOpen) {
|
|
22
|
-
this.panelContainer = panelContainer;
|
|
23
|
-
this.closeOnOutsideClick = closeOnOutsideClick;
|
|
24
|
-
this.isOpen = isOpen;
|
|
25
|
-
this.cleanupOutsideClickHandler();
|
|
26
|
-
if (isOpen && closeOnOutsideClick && panelContainer) {
|
|
27
|
-
this.boundHandleDocumentClick = this.handleDocumentClick.bind(this);
|
|
28
|
-
document.addEventListener('mousedown', this.boundHandleDocumentClick, true);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
cleanupOutsideClickHandler() {
|
|
32
|
-
if (this.boundHandleDocumentClick) {
|
|
33
|
-
document.removeEventListener('mousedown', this.boundHandleDocumentClick, true);
|
|
34
|
-
this.boundHandleDocumentClick = null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
handleDocumentClick(event) {
|
|
38
|
-
if (!this.isOpen || !this.closeOnOutsideClick || !this.panelContainer || !this.onCloseCallback) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const target = event.target;
|
|
42
|
-
if (!this.panelContainer.contains(target) && !this.component.contains(target)) {
|
|
43
|
-
this.onCloseCallback();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
destroy() {
|
|
47
|
-
this.cleanupOutsideClickHandler();
|
|
48
|
-
this.panelContainer = null;
|
|
49
|
-
this.onCloseCallback = null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=event-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-manager.js","sourceRoot":"","sources":["../../../src/nile-floating-panel/event-manager.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IAQvB,YAAY,SAAsB;QAN1B,mBAAc,GAAuB,IAAI,CAAC;QAC1C,wBAAmB,GAAY,IAAI,CAAC;QACpC,WAAM,GAAY,KAAK,CAAC;QACxB,6BAAwB,GAAyC,IAAI,CAAC;QACtE,oBAAe,GAAwB,IAAI,CAAC;QAGlD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,wBAAwB,CACtB,cAA2B,EAC3B,mBAA4B,EAC5B,MAAe,EACf,OAAmB;QAEnB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;QAE/B,IAAI,CAAC,IAAI,CAAC,mBAAmB,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAC/D,OAAO;QACT,CAAC;QAED,IAAI,CAAC,wBAAwB,GAAG,I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AAE,CAAC;YAC9E,IAAI,CAAC,eAAe,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAC9B,CAAC;CACF","sourcesContent":["export class EventManager {\n private component: HTMLElement;\n private panelContainer: HTMLElement | null = null;\n private closeOnOutsideClick: boolean = true;\n private isOpen: boolean = false;\n private boundHandleDocumentClick: ((event: MouseEvent) => void) | null = null;\n private onCloseCallback: (() => void) | null = null;\n\n constructor(component: HTMLElement) {\n this.component = component;\n }\n\n setupOutsideClickHandler(\n panelContainer: HTMLElement,\n closeOnOutsideClick: boolean,\n isOpen: boolean,\n onClose: () => void\n ): void {\n this.panelContainer = panelContainer;\n this.closeOnOutsideClick = closeOnOutsideClick;\n this.isOpen = isOpen;\n this.onCloseCallback = onClose;\n\n if (!this.closeOnOutsideClick || this.boundHandleDocumentClick) {\n return;\n }\n\n this.boundHandleDocumentClick = this.handleDocumentClick.bind(this);\n document.addEventListener('mousedown', this.boundHandleDocumentClick, true);\n }\n\n updateOutsideClickHandler(\n panelContainer: HTMLElement | null,\n closeOnOutsideClick: boolean,\n isOpen: boolean\n ): void {\n this.panelContainer = panelContainer;\n this.closeOnOutsideClick = closeOnOutsideClick;\n this.isOpen = isOpen;\n\n this.cleanupOutsideClickHandler();\n\n if (isOpen && closeOnOutsideClick && panelContainer) {\n this.boundHandleDocumentClick = this.handleDocumentClick.bind(this);\n document.addEventListener('mousedown', this.boundHandleDocumentClick, true);\n }\n }\n\n cleanupOutsideClickHandler(): void {\n if (this.boundHandleDocumentClick) {\n document.removeEventListener('mousedown', this.boundHandleDocumentClick, true);\n this.boundHandleDocumentClick = null;\n }\n }\n\n private handleDocumentClick(event: MouseEvent): void {\n if (!this.isOpen || !this.closeOnOutsideClick || !this.panelContainer || !this.onCloseCallback) {\n return;\n }\n\n const target = event.target as Node;\n\n if (!this.panelContainer.contains(target) && !this.component.contains(target)) {\n this.onCloseCallback();\n }\n }\n\n destroy(): void {\n this.cleanupOutsideClickHandler();\n this.panelContainer = null;\n this.onCloseCallback = null;\n }\n}\n\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { FloatingPanelPosition } from './types';
|
|
2
|
-
export declare class PositionManager {
|
|
3
|
-
private cleanup;
|
|
4
|
-
private referenceElement;
|
|
5
|
-
private floatingElement;
|
|
6
|
-
private position;
|
|
7
|
-
private offsetValue;
|
|
8
|
-
private shiftPadding;
|
|
9
|
-
constructor(referenceElement: HTMLElement, floatingElement: HTMLElement, position: FloatingPanelPosition, offsetValue?: number, shiftPadding?: number);
|
|
10
|
-
setupAutoUpdate(): void;
|
|
11
|
-
cleanupAutoUpdate(): void;
|
|
12
|
-
reposition(): void;
|
|
13
|
-
updatePosition(position: FloatingPanelPosition): void;
|
|
14
|
-
updateOffset(offset: number): void;
|
|
15
|
-
updateShiftPadding(padding: number): void;
|
|
16
|
-
destroy(): void;
|
|
17
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { autoUpdate, computePosition, offset, shift, flip } from '@floating-ui/dom';
|
|
2
|
-
export class PositionManager {
|
|
3
|
-
constructor(referenceElement, floatingElement, position, offsetValue = 8, shiftPadding = 8) {
|
|
4
|
-
this.cleanup = null;
|
|
5
|
-
this.referenceElement = referenceElement;
|
|
6
|
-
this.floatingElement = floatingElement;
|
|
7
|
-
this.position = position;
|
|
8
|
-
this.offsetValue = offsetValue;
|
|
9
|
-
this.shiftPadding = shiftPadding;
|
|
10
|
-
}
|
|
11
|
-
setupAutoUpdate() {
|
|
12
|
-
this.cleanupAutoUpdate();
|
|
13
|
-
this.cleanup = autoUpdate(this.referenceElement, this.floatingElement, () => {
|
|
14
|
-
this.reposition();
|
|
15
|
-
}, {
|
|
16
|
-
ancestorScroll: true,
|
|
17
|
-
ancestorResize: true,
|
|
18
|
-
elementResize: true,
|
|
19
|
-
layoutShift: true,
|
|
20
|
-
animationFrame: false,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
cleanupAutoUpdate() {
|
|
24
|
-
if (this.cleanup) {
|
|
25
|
-
this.cleanup();
|
|
26
|
-
this.cleanup = null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
reposition() {
|
|
30
|
-
const placement = this.position;
|
|
31
|
-
computePosition(this.referenceElement, this.floatingElement, {
|
|
32
|
-
placement,
|
|
33
|
-
strategy: 'fixed',
|
|
34
|
-
middleware: [
|
|
35
|
-
offset(this.offsetValue),
|
|
36
|
-
flip(),
|
|
37
|
-
shift({
|
|
38
|
-
padding: this.shiftPadding,
|
|
39
|
-
}),
|
|
40
|
-
],
|
|
41
|
-
}).then(({ x, y, placement: finalPlacement }) => {
|
|
42
|
-
let adjustedY = y;
|
|
43
|
-
if (finalPlacement.startsWith('bottom')) {
|
|
44
|
-
adjustedY = y + 10;
|
|
45
|
-
}
|
|
46
|
-
else if (finalPlacement.startsWith('top')) {
|
|
47
|
-
adjustedY = y - 20;
|
|
48
|
-
}
|
|
49
|
-
Object.assign(this.floatingElement.style, {
|
|
50
|
-
left: `${x}px`,
|
|
51
|
-
top: `${adjustedY}px`,
|
|
52
|
-
position: 'fixed',
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
updatePosition(position) {
|
|
57
|
-
this.position = position;
|
|
58
|
-
this.reposition();
|
|
59
|
-
}
|
|
60
|
-
updateOffset(offset) {
|
|
61
|
-
this.offsetValue = offset;
|
|
62
|
-
this.reposition();
|
|
63
|
-
}
|
|
64
|
-
updateShiftPadding(padding) {
|
|
65
|
-
this.shiftPadding = padding;
|
|
66
|
-
this.reposition();
|
|
67
|
-
}
|
|
68
|
-
destroy() {
|
|
69
|
-
this.cleanupAutoUpdate();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=position-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"position-manager.js","sourceRoot":"","sources":["../../../src/nile-floating-panel/position-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAIpF,MAAM,OAAO,eAAe;IAQ1B,YACE,gBAA6B,EAC7B,eAA4B,EAC5B,QAA+B,EAC/B,cAAsB,CAAC,EACvB,eAAuB,CAAC;QAZlB,YAAO,GAAwB,IAAI,CAAC;QAc1C,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,eAAe;QACb,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAEzB,IAAI,CAAC,OAAO,GAAG,UAAU,CACvB,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,eAAe,EACpB,GAAG,EAAE;YACH,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,CAAC,EACD;YACE,cAAc,EAAE,IAAI;YACpB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;YACnB,WAAW,EAAE,IAAI;YACjB,cAAc,EAAE,KAAK;SACtB,CACF,CAAC;IACJ,CAAC;IAED,iBAAiB;QACf,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;IAED,UAAU;QACR,MAAM,SAAS,GAAc,IAAI,CAAC,QAAQ,CAAC;QAE3C,eAAe,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,eAAe,EAAE;YAC3D,SAAS;YACT,Q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port type { Placement } from '@floating-ui/dom';\nimport type { FloatingPanelPosition } from './types';\n\nexport class PositionManager {\n private cleanup: (() => void) | null = null;\n private referenceElement: HTMLElement;\n private floatingElement: HTMLElement;\n private position: FloatingPanelPosition;\n private offsetValue: number;\n private shiftPadding: number;\n\n constructor(\n referenceElement: HTMLElement,\n floatingElement: HTMLElement,\n position: FloatingPanelPosition,\n offsetValue: number = 8,\n shiftPadding: number = 8\n ) {\n this.referenceElement = referenceElement;\n this.floatingElement = floatingElement;\n this.position = position;\n this.offsetValue = offsetValue;\n this.shiftPadding = shiftPadding;\n }\n\n setupAutoUpdate(): void {\n this.cleanupAutoUpdate();\n\n this.cleanup = autoUpdate(\n this.referenceElement,\n this.floatingElement,\n () => {\n this.reposition();\n },\n {\n ancestorScroll: true,\n ancestorResize: true,\n elementResize: true,\n layoutShift: true,\n animationFrame: false,\n }\n );\n }\n\n cleanupAutoUpdate(): void {\n if (this.cleanup) {\n this.cleanup();\n this.cleanup = null;\n }\n }\n\n reposition(): void {\n const placement: Placement = this.position;\n\n computePosition(this.referenceElement, this.floatingElement, {\n placement,\n strategy: 'fixed',\n middleware: [\n offset(this.offsetValue),\n flip(),\n shift({\n padding: this.shiftPadding,\n }),\n ],\n }).then(({ x, y, placement: finalPlacement }) => {\n let adjustedY = y;\n \n if (finalPlacement.startsWith('bottom')) {\n adjustedY = y + 10;\n } else if (finalPlacement.startsWith('top')) {\n adjustedY = y - 20;\n }\n \n Object.assign(this.floatingElement.style, {\n left: `${x}px`,\n top: `${adjustedY}px`,\n position: 'fixed',\n });\n });\n }\n\n updatePosition(position: FloatingPanelPosition): void {\n this.position = position;\n this.reposition();\n }\n\n updateOffset(offset: number): void {\n this.offsetValue = offset;\n this.reposition();\n }\n\n updateShiftPadding(padding: number): void {\n this.shiftPadding = padding;\n this.reposition();\n }\n\n destroy(): void {\n this.cleanupAutoUpdate();\n }\n}\n\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { CSSResultArray } from 'lit';
|
|
2
|
-
export declare class StyleManager {
|
|
3
|
-
private injectedStyleId;
|
|
4
|
-
private static injectedStyleIds;
|
|
5
|
-
injectStyles(componentStyles: CSSResultArray): void;
|
|
6
|
-
private extractCSSFromStyles;
|
|
7
|
-
cleanupStyles(): void;
|
|
8
|
-
getInjectedStyleId(): string | null;
|
|
9
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { panelContainerStyles } from './nile-floating-panel.css';
|
|
2
|
-
export class StyleManager {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.injectedStyleId = null;
|
|
5
|
-
}
|
|
6
|
-
injectStyles(componentStyles) {
|
|
7
|
-
const globalStyleId = 'nile-floating-panel-styles-global';
|
|
8
|
-
if (StyleManager.injectedStyleIds.has(globalStyleId)) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if (this.injectedStyleId && document.getElementById(this.injectedStyleId)) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
this.injectedStyleId = globalStyleId;
|
|
15
|
-
StyleManager.injectedStyleIds.add(globalStyleId);
|
|
16
|
-
const cssText = this.extractCSSFromStyles(componentStyles);
|
|
17
|
-
const styleElement = document.createElement('style');
|
|
18
|
-
styleElement.id = globalStyleId;
|
|
19
|
-
styleElement.textContent = cssText;
|
|
20
|
-
document.head.appendChild(styleElement);
|
|
21
|
-
}
|
|
22
|
-
extractCSSFromStyles(styles) {
|
|
23
|
-
const containerStyles = panelContainerStyles.cssText || '';
|
|
24
|
-
const componentStyles = styles
|
|
25
|
-
.map(style => {
|
|
26
|
-
if (typeof style === 'string') {
|
|
27
|
-
return style;
|
|
28
|
-
}
|
|
29
|
-
if (style && 'cssText' in style) {
|
|
30
|
-
return style.cssText;
|
|
31
|
-
}
|
|
32
|
-
return '';
|
|
33
|
-
})
|
|
34
|
-
.join('\n');
|
|
35
|
-
return containerStyles + '\n' + componentStyles;
|
|
36
|
-
}
|
|
37
|
-
cleanupStyles() {
|
|
38
|
-
}
|
|
39
|
-
getInjectedStyleId() {
|
|
40
|
-
return this.injectedStyleId;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
StyleManager.injectedStyleIds = new Set();
|
|
44
|
-
//# sourceMappingURL=style-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style-manager.js","sourceRoot":"","sources":["../../../src/nile-floating-panel/style-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,OAAO,YAAY;IAAzB;QACU,oBAAe,GAAkB,IAAI,CAAC;IAgDhD,CAAC;IA7CC,YAAY,CAAC,eAA+B;QAC1C,MAAM,aAAa,GAAG,mCAAmC,CAAC;QAC1D,IAAI,YAAY,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YACrD,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,eAAe,IAAI,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YAC1E,OAAO;QACT,CAAC;QAED,IAAI,CAAC,eAAe,GAAG,aAAa,CAAC;QACrC,YAAY,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAEjD,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC;QAE3D,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACrD,YAAY,CAAC,EAAE,GAAG,aAAa,CAAC;QAChC,YAAY,CAAC,WAAW,GAAG,OAAO,CAAC;QACnC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAEO,oBAAoB,CAAC,MAAsB;QACjD,MAAM,eAAe,GAAG,oBAAoB,CAAC,OAAO,IAAI,EAAE,CAAC;QAE3D,MAAM,eAAe,GAAG,MAAM;aAC3B,GAAG,CAAC,KAAK,CAAC,EAAE;YACX,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;gBAChC,OAAQ,KAAa,CAAC,OAAO,CAAC;YAChC,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,OAAO,eAAe,GAAG,IAAI,GAAG,eAAe,CAAC;IAClD,CAAC;IAED,aAAa;IACb,CAAC;IAED,kBAAkB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;;AA9Cc,6BAAgB,GAAgB,IAAI,GAAG,EAAE,AAAzB,CAA0B","sourcesContent":["import type { CSSResultArray } from 'lit';\nimport { panelContainerStyles } from './nile-floating-panel.css';\n\nexport class StyleManager {\n private injectedStyleId: string | null = null;\n private static injectedStyleIds: Set<string> = new Set();\n\n injectStyles(componentStyles: CSSResultArray): void {\n const globalStyleId = 'nile-floating-panel-styles-global';\n if (StyleManager.injectedStyleIds.has(globalStyleId)) {\n return;\n }\n\n if (this.injectedStyleId && document.getElementById(this.injectedStyleId)) {\n return;\n }\n\n this.injectedStyleId = globalStyleId;\n StyleManager.injectedStyleIds.add(globalStyleId);\n\n const cssText = this.extractCSSFromStyles(componentStyles);\n\n const styleElement = document.createElement('style');\n styleElement.id = globalStyleId;\n styleElement.textContent = cssText;\n document.head.appendChild(styleElement);\n }\n\n private extractCSSFromStyles(styles: CSSResultArray): string {\n const containerStyles = panelContainerStyles.cssText || '';\n\n const componentStyles = styles\n .map(style => {\n if (typeof style === 'string') {\n return style;\n }\n if (style && 'cssText' in style) {\n return (style as any).cssText;\n }\n return '';\n })\n .join('\\n');\n\n return containerStyles + '\\n' + componentStyles;\n }\n\n cleanupStyles(): void {\n }\n\n getInjectedStyleId(): string | null {\n return this.injectedStyleId;\n }\n}\n\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type FloatingPanelPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
2
|
-
export type FloatingPanelAnchor = HTMLElement | string | null;
|
|
3
|
-
export interface FloatingPanelPositionConfig {
|
|
4
|
-
position: FloatingPanelPosition;
|
|
5
|
-
offset?: number;
|
|
6
|
-
shiftPadding?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface FloatingPanelContentConfig {
|
|
9
|
-
slotContent: Node[];
|
|
10
|
-
dataContent: string;
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/nile-floating-panel/types.ts"],"names":[],"mappings":"","sourcesContent":["export type FloatingPanelPosition = 'top' | 'bottom' | 'left' | 'right';\n\nexport type FloatingPanelAnchor = HTMLElement | string | null;\n\nexport interface FloatingPanelPositionConfig {\n position: FloatingPanelPosition;\n offset?: number;\n shiftPadding?: number;\n}\n\nexport interface FloatingPanelContentConfig {\n slotContent: Node[];\n dataContent: string;\n}\n\n"]}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { FloatingPanelAnchor } from './types';
|
|
2
|
-
|
|
3
|
-
export class AnchorManager {
|
|
4
|
-
static resolveAnchor(anchor: FloatingPanelAnchor): HTMLElement {
|
|
5
|
-
if (anchor instanceof HTMLElement) {
|
|
6
|
-
return anchor;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (typeof anchor === 'string') {
|
|
10
|
-
const element = document.querySelector(anchor) as HTMLElement;
|
|
11
|
-
if (element) {
|
|
12
|
-
return element;
|
|
13
|
-
}
|
|
14
|
-
const byId = document.getElementById(anchor);
|
|
15
|
-
if (byId) {
|
|
16
|
-
return byId;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return document.body;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static appendToAnchor(anchor: HTMLElement, panelContainer: HTMLElement): void {
|
|
24
|
-
anchor.appendChild(panelContainer);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static removeFromAnchor(panelContainer: HTMLElement): void {
|
|
28
|
-
if (panelContainer.parentNode) {
|
|
29
|
-
panelContainer.parentNode.removeChild(panelContainer);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { FloatingPanelContentConfig } from './types';
|
|
2
|
-
|
|
3
|
-
export class ContentManager {
|
|
4
|
-
static updatePanelContent(
|
|
5
|
-
panelContainer: HTMLElement,
|
|
6
|
-
slot: HTMLSlotElement | null,
|
|
7
|
-
dataContent: string
|
|
8
|
-
): void {
|
|
9
|
-
panelContainer.innerHTML = '';
|
|
10
|
-
|
|
11
|
-
const slotContent = slot ? slot.assignedNodes({ flatten: true }) : [];
|
|
12
|
-
|
|
13
|
-
const hasSlotContent = slotContent.length > 0 &&
|
|
14
|
-
slotContent.some(node => {
|
|
15
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
16
|
-
return node.textContent?.trim() !== '';
|
|
17
|
-
}
|
|
18
|
-
return node instanceof HTMLElement;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
if (hasSlotContent) {
|
|
22
|
-
slotContent.forEach(node => {
|
|
23
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
24
|
-
const textNode = document.createTextNode(node.textContent || '');
|
|
25
|
-
panelContainer.appendChild(textNode);
|
|
26
|
-
} else if (node instanceof HTMLElement) {
|
|
27
|
-
panelContainer.appendChild(node.cloneNode(true));
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
} else if (dataContent) {
|
|
31
|
-
panelContainer.textContent = dataContent;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static hasSlotContent(slot: HTMLSlotElement | null): boolean {
|
|
36
|
-
if (!slot) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const slotContent = slot.assignedNodes({ flatten: true });
|
|
41
|
-
return slotContent.length > 0 &&
|
|
42
|
-
slotContent.some(node => {
|
|
43
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
44
|
-
return node.textContent?.trim() !== '';
|
|
45
|
-
}
|
|
46
|
-
return node instanceof HTMLElement;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static getSlotContent(slot: HTMLSlotElement | null): Node[] {
|
|
51
|
-
return slot ? slot.assignedNodes({ flatten: true }) : [];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
export class EventManager {
|
|
2
|
-
private component: HTMLElement;
|
|
3
|
-
private panelContainer: HTMLElement | null = null;
|
|
4
|
-
private closeOnOutsideClick: boolean = true;
|
|
5
|
-
private isOpen: boolean = false;
|
|
6
|
-
private boundHandleDocumentClick: ((event: MouseEvent) => void) | null = null;
|
|
7
|
-
private onCloseCallback: (() => void) | null = null;
|
|
8
|
-
|
|
9
|
-
constructor(component: HTMLElement) {
|
|
10
|
-
this.component = component;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
setupOutsideClickHandler(
|
|
14
|
-
panelContainer: HTMLElement,
|
|
15
|
-
closeOnOutsideClick: boolean,
|
|
16
|
-
isOpen: boolean,
|
|
17
|
-
onClose: () => void
|
|
18
|
-
): void {
|
|
19
|
-
this.panelContainer = panelContainer;
|
|
20
|
-
this.closeOnOutsideClick = closeOnOutsideClick;
|
|
21
|
-
this.isOpen = isOpen;
|
|
22
|
-
this.onCloseCallback = onClose;
|
|
23
|
-
|
|
24
|
-
if (!this.closeOnOutsideClick || this.boundHandleDocumentClick) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
this.boundHandleDocumentClick = this.handleDocumentClick.bind(this);
|
|
29
|
-
document.addEventListener('mousedown', this.boundHandleDocumentClick, true);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
updateOutsideClickHandler(
|
|
33
|
-
panelContainer: HTMLElement | null,
|
|
34
|
-
closeOnOutsideClick: boolean,
|
|
35
|
-
isOpen: boolean
|
|
36
|
-
): void {
|
|
37
|
-
this.panelContainer = panelContainer;
|
|
38
|
-
this.closeOnOutsideClick = closeOnOutsideClick;
|
|
39
|
-
this.isOpen = isOpen;
|
|
40
|
-
|
|
41
|
-
this.cleanupOutsideClickHandler();
|
|
42
|
-
|
|
43
|
-
if (isOpen && closeOnOutsideClick && panelContainer) {
|
|
44
|
-
this.boundHandleDocumentClick = this.handleDocumentClick.bind(this);
|
|
45
|
-
document.addEventListener('mousedown', this.boundHandleDocumentClick, true);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
cleanupOutsideClickHandler(): void {
|
|
50
|
-
if (this.boundHandleDocumentClick) {
|
|
51
|
-
document.removeEventListener('mousedown', this.boundHandleDocumentClick, true);
|
|
52
|
-
this.boundHandleDocumentClick = null;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private handleDocumentClick(event: MouseEvent): void {
|
|
57
|
-
if (!this.isOpen || !this.closeOnOutsideClick || !this.panelContainer || !this.onCloseCallback) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const target = event.target as Node;
|
|
62
|
-
|
|
63
|
-
if (!this.panelContainer.contains(target) && !this.component.contains(target)) {
|
|
64
|
-
this.onCloseCallback();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
destroy(): void {
|
|
69
|
-
this.cleanupOutsideClickHandler();
|
|
70
|
-
this.panelContainer = null;
|
|
71
|
-
this.onCloseCallback = null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { autoUpdate, computePosition, offset, shift, flip } from '@floating-ui/dom';
|
|
2
|
-
import type { Placement } from '@floating-ui/dom';
|
|
3
|
-
import type { FloatingPanelPosition } from './types';
|
|
4
|
-
|
|
5
|
-
export class PositionManager {
|
|
6
|
-
private cleanup: (() => void) | null = null;
|
|
7
|
-
private referenceElement: HTMLElement;
|
|
8
|
-
private floatingElement: HTMLElement;
|
|
9
|
-
private position: FloatingPanelPosition;
|
|
10
|
-
private offsetValue: number;
|
|
11
|
-
private shiftPadding: number;
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
referenceElement: HTMLElement,
|
|
15
|
-
floatingElement: HTMLElement,
|
|
16
|
-
position: FloatingPanelPosition,
|
|
17
|
-
offsetValue: number = 8,
|
|
18
|
-
shiftPadding: number = 8
|
|
19
|
-
) {
|
|
20
|
-
this.referenceElement = referenceElement;
|
|
21
|
-
this.floatingElement = floatingElement;
|
|
22
|
-
this.position = position;
|
|
23
|
-
this.offsetValue = offsetValue;
|
|
24
|
-
this.shiftPadding = shiftPadding;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
setupAutoUpdate(): void {
|
|
28
|
-
this.cleanupAutoUpdate();
|
|
29
|
-
|
|
30
|
-
this.cleanup = autoUpdate(
|
|
31
|
-
this.referenceElement,
|
|
32
|
-
this.floatingElement,
|
|
33
|
-
() => {
|
|
34
|
-
this.reposition();
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
ancestorScroll: true,
|
|
38
|
-
ancestorResize: true,
|
|
39
|
-
elementResize: true,
|
|
40
|
-
layoutShift: true,
|
|
41
|
-
animationFrame: false,
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
cleanupAutoUpdate(): void {
|
|
47
|
-
if (this.cleanup) {
|
|
48
|
-
this.cleanup();
|
|
49
|
-
this.cleanup = null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
reposition(): void {
|
|
54
|
-
const placement: Placement = this.position;
|
|
55
|
-
|
|
56
|
-
computePosition(this.referenceElement, this.floatingElement, {
|
|
57
|
-
placement,
|
|
58
|
-
strategy: 'fixed',
|
|
59
|
-
middleware: [
|
|
60
|
-
offset(this.offsetValue),
|
|
61
|
-
flip(),
|
|
62
|
-
shift({
|
|
63
|
-
padding: this.shiftPadding,
|
|
64
|
-
}),
|
|
65
|
-
],
|
|
66
|
-
}).then(({ x, y, placement: finalPlacement }) => {
|
|
67
|
-
let adjustedY = y;
|
|
68
|
-
|
|
69
|
-
if (finalPlacement.startsWith('bottom')) {
|
|
70
|
-
adjustedY = y + 10;
|
|
71
|
-
} else if (finalPlacement.startsWith('top')) {
|
|
72
|
-
adjustedY = y - 20;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
Object.assign(this.floatingElement.style, {
|
|
76
|
-
left: `${x}px`,
|
|
77
|
-
top: `${adjustedY}px`,
|
|
78
|
-
position: 'fixed',
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
updatePosition(position: FloatingPanelPosition): void {
|
|
84
|
-
this.position = position;
|
|
85
|
-
this.reposition();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
updateOffset(offset: number): void {
|
|
89
|
-
this.offsetValue = offset;
|
|
90
|
-
this.reposition();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
updateShiftPadding(padding: number): void {
|
|
94
|
-
this.shiftPadding = padding;
|
|
95
|
-
this.reposition();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
destroy(): void {
|
|
99
|
-
this.cleanupAutoUpdate();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { CSSResultArray } from 'lit';
|
|
2
|
-
import { panelContainerStyles } from './nile-floating-panel.css';
|
|
3
|
-
|
|
4
|
-
export class StyleManager {
|
|
5
|
-
private injectedStyleId: string | null = null;
|
|
6
|
-
private static injectedStyleIds: Set<string> = new Set();
|
|
7
|
-
|
|
8
|
-
injectStyles(componentStyles: CSSResultArray): void {
|
|
9
|
-
const globalStyleId = 'nile-floating-panel-styles-global';
|
|
10
|
-
if (StyleManager.injectedStyleIds.has(globalStyleId)) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (this.injectedStyleId && document.getElementById(this.injectedStyleId)) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
this.injectedStyleId = globalStyleId;
|
|
19
|
-
StyleManager.injectedStyleIds.add(globalStyleId);
|
|
20
|
-
|
|
21
|
-
const cssText = this.extractCSSFromStyles(componentStyles);
|
|
22
|
-
|
|
23
|
-
const styleElement = document.createElement('style');
|
|
24
|
-
styleElement.id = globalStyleId;
|
|
25
|
-
styleElement.textContent = cssText;
|
|
26
|
-
document.head.appendChild(styleElement);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private extractCSSFromStyles(styles: CSSResultArray): string {
|
|
30
|
-
const containerStyles = panelContainerStyles.cssText || '';
|
|
31
|
-
|
|
32
|
-
const componentStyles = styles
|
|
33
|
-
.map(style => {
|
|
34
|
-
if (typeof style === 'string') {
|
|
35
|
-
return style;
|
|
36
|
-
}
|
|
37
|
-
if (style && 'cssText' in style) {
|
|
38
|
-
return (style as any).cssText;
|
|
39
|
-
}
|
|
40
|
-
return '';
|
|
41
|
-
})
|
|
42
|
-
.join('\n');
|
|
43
|
-
|
|
44
|
-
return containerStyles + '\n' + componentStyles;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
cleanupStyles(): void {
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getInjectedStyleId(): string | null {
|
|
51
|
-
return this.injectedStyleId;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type FloatingPanelPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
2
|
-
|
|
3
|
-
export type FloatingPanelAnchor = HTMLElement | string | null;
|
|
4
|
-
|
|
5
|
-
export interface FloatingPanelPositionConfig {
|
|
6
|
-
position: FloatingPanelPosition;
|
|
7
|
-
offset?: number;
|
|
8
|
-
shiftPadding?: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface FloatingPanelContentConfig {
|
|
12
|
-
slotContent: Node[];
|
|
13
|
-
dataContent: string;
|
|
14
|
-
}
|
|
15
|
-
|