@patternfly/pfe-core 2.0.0-next.6 → 2.0.0-next.7
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.
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
+
declare type Direction = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
declare type Alignment = 'start' | 'end';
|
|
4
|
+
/**
|
|
5
|
+
* Represents the placement of floating DOM
|
|
6
|
+
*/
|
|
7
|
+
export declare type Placement = Direction | `${Direction}-${Alignment}`;
|
|
8
|
+
/**
|
|
9
|
+
* Controls floating DOM within a web component, e.g. tooltips and popovers
|
|
10
|
+
*/
|
|
11
|
+
export declare class FloatingDOMController implements ReactiveController {
|
|
12
|
+
#private;
|
|
13
|
+
private host;
|
|
14
|
+
/**
|
|
15
|
+
* When true, the floating DOM is visible
|
|
16
|
+
*/
|
|
17
|
+
get open(): boolean;
|
|
18
|
+
set open(value: boolean);
|
|
19
|
+
constructor(host: ReactiveElement);
|
|
20
|
+
hostConnected?(): void;
|
|
21
|
+
/** Show the floating DOM */
|
|
22
|
+
show(): void;
|
|
23
|
+
/** Hide the floating DOM */
|
|
24
|
+
hide(): void;
|
|
25
|
+
/** Initialize the floating DOM */
|
|
26
|
+
create(invoker: Element, content: HTMLElement, placement: Placement, offset?: number[]): void;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var a=(t,e,o)=>{if(!e.has(t))throw TypeError("Cannot "+o)};var r=(t,e,o)=>(a(t,e,"read from private field"),o?o.call(t):e.get(t)),s=(t,e,o)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,o)},l=(t,e,o,p)=>(a(t,e,"write to private field"),p?p.call(t,o):e.set(t,o),o);import{applyStyles as f,arrow as d,computeStyles as h,eventListeners as v,flip as u,hide as y,offset as b,popperGenerator as g,popperOffsets as E,preventOverflow as P}from"@popperjs/core";var R=g({defaultModifiers:[v,E,h,f,b,u,P,d,y]}),i,n,m=class{constructor(e){this.host=e;s(this,i,!1);s(this,n,void 0);e.addController(this)}get open(){return r(this,i)}set open(e){l(this,i,e),e&&r(this,n)?.update(),this.host.requestUpdate()}show(){this.open=!0}hide(){this.open=!1}create(e,o,p,c){l(this,n,R(e,o,{placement:p,modifiers:[{name:"offset",options:{offset:c}},{name:"flip",options:{fallbackPlacements:["top","right","left","bottom"]}}]}))}};i=new WeakMap,n=new WeakMap;export{m as FloatingDOMController};
|
|
2
|
+
//# sourceMappingURL=floating-dom-controller.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["floating-dom-controller.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Instance } from '@popperjs/core';\nimport type { ReactiveController, ReactiveElement } from 'lit';\n\nimport {\n applyStyles,\n arrow,\n computeStyles,\n eventListeners,\n flip,\n hide,\n offset,\n popperGenerator,\n popperOffsets,\n preventOverflow,\n} from '@popperjs/core';\n\ntype Direction =\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n\ntype Alignment =\n | 'start'\n | 'end'\n\n/**\n * Represents the placement of floating DOM\n */\nexport type Placement = Direction | `${Direction}-${Alignment}`;\n\nconst createPopper = popperGenerator({\n defaultModifiers: [\n eventListeners,\n popperOffsets,\n computeStyles,\n applyStyles,\n offset,\n flip,\n preventOverflow,\n arrow,\n hide\n ],\n});\n\n/**\n * Controls floating DOM within a web component, e.g. tooltips and popovers\n */\nexport class FloatingDOMController implements ReactiveController {\n #open = false;\n\n /**\n * When true, the floating DOM is visible\n */\n get open() {\n return this.#open;\n }\n\n set open(value: boolean) {\n this.#open = value;\n if (value) {\n this.#popper?.update();\n }\n this.host.requestUpdate();\n }\n\n #popper: Instance | undefined;\n\n constructor(private host: ReactiveElement) {\n host.addController(this);\n }\n\n hostConnected?(): void;\n\n /** Show the floating DOM */\n show(): void {\n this.open = true;\n }\n\n /** Hide the floating DOM */\n hide(): void {\n this.open = false;\n }\n\n /** Initialize the floating DOM */\n create(invoker: Element, content: HTMLElement, placement: Placement, offset?: number[]): void {\n this.#popper = createPopper(invoker, content, {\n placement,\n modifiers: [\n {\n name: 'offset',\n options: {\n offset\n }\n },\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['top', 'right', 'left', 'bottom'],\n },\n }\n ]\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "mVAGA,4LA4BA,GAAM,GAAe,EAAgB,CACnC,iBAAkB,CAChB,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,CACF,CACF,CAAC,EA3CD,IAgDO,OAA0D,CAoB/D,YAAoB,EAAuB,CAAvB,YAnBpB,SAAQ,IAiBR,iBAGE,EAAK,cAAc,IAAI,CACzB,IAhBI,OAAO,CACT,MAAO,QAAK,EACd,IAEI,MAAK,EAAgB,CACvB,OAAK,EAAQ,GACT,GACF,OAAK,IAAS,OAAO,EAEvB,KAAK,KAAK,cAAc,CAC1B,CAWA,MAAa,CACX,KAAK,KAAO,EACd,CAGA,MAAa,CACX,KAAK,KAAO,EACd,CAGA,OAAO,EAAkB,EAAsB,EAAsB,EAAyB,CAC5F,OAAK,EAAU,EAAa,EAAS,EAAS,CAC5C,YACA,UAAW,CACT,CACE,KAAM,SACN,QAAS,CACP,QACF,CACF,EACA,CACE,KAAM,OACN,QAAS,CACP,mBAAoB,CAAC,MAAO,QAAS,OAAQ,QAAQ,CACvD,CACF,CACF,CACF,CAAC,EACH,CACF,EAvDE,cAiBA",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/pfe-core",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "PatternFly Elements Core Library",
|
|
6
6
|
"customElements": "custom-elements.json",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"./controllers/perf-controller.js": "./controllers/perf-controller.js",
|
|
22
22
|
"./controllers/property-observer-controller.js": "./controllers/property-observer-controller.js",
|
|
23
23
|
"./controllers/slot-controller.js": "./controllers/slot-controller.js",
|
|
24
|
+
"./controllers/floating-dom-controller.js": "./controllers/floating-dom-controller.js",
|
|
24
25
|
"./controllers/style-controller.js": "./controllers/style-controller.js",
|
|
25
26
|
"./decorators/bound.js": "./decorators/bound.js",
|
|
26
27
|
"./decorators/cascades.js": "./decorators/cascades.js",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"watch:types": "tsc -w"
|
|
60
61
|
},
|
|
61
62
|
"dependencies": {
|
|
63
|
+
"@popperjs/core": "^2.11.5",
|
|
62
64
|
"lit": "^2.1.2"
|
|
63
65
|
},
|
|
64
66
|
"repository": {
|