@patternfly/pfe-core 2.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/controllers/cascade-controller.d.ts +6 -0
- package/controllers/cascade-controller.js +5 -3
- package/controllers/cascade-controller.js.map +1 -1
- package/controllers/floating-dom-controller.d.ts +2 -2
- package/controllers/floating-dom-controller.js +84 -81
- package/controllers/floating-dom-controller.js.map +1 -1
- package/controllers/internals-controller.d.ts +86 -41
- package/controllers/internals-controller.js +322 -36
- package/controllers/internals-controller.js.map +1 -1
- package/controllers/light-dom-controller.js.map +1 -1
- package/controllers/listbox-controller.d.ts +58 -0
- package/controllers/listbox-controller.js +250 -0
- package/controllers/listbox-controller.js.map +1 -0
- package/controllers/logger.d.ts +27 -3
- package/controllers/logger.js +50 -9
- package/controllers/logger.js.map +1 -1
- package/controllers/overflow-controller.d.ts +10 -3
- package/controllers/overflow-controller.js +75 -44
- package/controllers/overflow-controller.js.map +1 -1
- package/controllers/perf-controller.js.map +1 -1
- package/controllers/property-observer-controller.js +2 -3
- package/controllers/property-observer-controller.js.map +1 -1
- package/controllers/roving-tabindex-controller.d.ts +42 -24
- package/controllers/roving-tabindex-controller.js +167 -140
- package/controllers/roving-tabindex-controller.js.map +1 -1
- package/controllers/scroll-spy-controller.js +91 -93
- package/controllers/scroll-spy-controller.js.map +1 -1
- package/controllers/slot-controller.d.ts +18 -20
- package/controllers/slot-controller.js +89 -91
- package/controllers/slot-controller.js.map +1 -1
- package/controllers/style-controller.js.map +1 -1
- package/controllers/tabs-aria-controller.d.ts +29 -0
- package/controllers/tabs-aria-controller.js +95 -0
- package/controllers/tabs-aria-controller.js.map +1 -0
- package/controllers/timestamp-controller.js +68 -70
- package/controllers/timestamp-controller.js.map +1 -1
- package/core.d.ts +3 -0
- package/core.js.map +1 -1
- package/custom-elements.json +3245 -1317
- package/decorators/bound.js.map +1 -1
- package/decorators/cascades.d.ts +1 -0
- package/decorators/cascades.js +1 -0
- package/decorators/cascades.js.map +1 -1
- package/decorators/deprecation.js.map +1 -1
- package/decorators/initializer.js.map +1 -1
- package/decorators/observed.js.map +1 -1
- package/decorators/time.js.map +1 -1
- package/decorators/trace.js.map +1 -1
- package/functions/containsDeep.d.ts +6 -0
- package/functions/containsDeep.js +21 -0
- package/functions/containsDeep.js.map +1 -0
- package/functions/context.d.ts +9 -0
- package/functions/context.js +17 -0
- package/functions/context.js.map +1 -0
- package/functions/debounce.js.map +1 -1
- package/functions/isElementInView.js.map +1 -1
- package/package.json +7 -4
- package/functions/deprecatedCustomEvent.d.ts +0 -5
- package/functions/deprecatedCustomEvent.js +0 -12
- package/functions/deprecatedCustomEvent.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { ReactiveController, ReactiveElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated: use context, especially via `@patternfly/pfe-core/functions/context.js`;
|
|
4
|
+
*/
|
|
2
5
|
export interface Options<E extends ReactiveElement> {
|
|
3
6
|
properties: Partial<Record<keyof E, string | string[]>>;
|
|
4
7
|
prefix?: string;
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated: use context, especially via `@patternfly/pfe-core/functions/context.js`;
|
|
11
|
+
*/
|
|
6
12
|
export declare class CascadeController<E extends ReactiveElement> implements ReactiveController {
|
|
7
13
|
host: E;
|
|
8
14
|
options?: Options<E> | undefined;
|
|
@@ -2,8 +2,10 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { bound } from '../decorators/bound.js';
|
|
3
3
|
import { debounce } from '../functions/debounce.js';
|
|
4
4
|
import { Logger } from './logger.js';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated: use context, especially via `@patternfly/pfe-core/functions/context.js`;
|
|
7
|
+
*/
|
|
8
|
+
export class CascadeController {
|
|
7
9
|
constructor(host, options) {
|
|
8
10
|
this.host = host;
|
|
9
11
|
this.options = options;
|
|
@@ -130,8 +132,8 @@ class CascadeController {
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
}
|
|
135
|
+
CascadeController.instances = new WeakMap();
|
|
133
136
|
__decorate([
|
|
134
137
|
bound
|
|
135
138
|
], CascadeController.prototype, "parse", null);
|
|
136
|
-
export { CascadeController };
|
|
137
139
|
//# sourceMappingURL=cascade-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cascade-controller.js","sourceRoot":"","sources":["cascade-controller.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"cascade-controller.js","sourceRoot":"","sources":["cascade-controller.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAW5B,YAAmB,IAAO,EAAS,OAAoB;QAApC,SAAI,GAAJ,IAAI,CAAG;QAAS,YAAO,GAAP,OAAO,CAAa;QAJvD,OAAE,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEtC,UAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;QAGlC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAqC,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,iBAAiB,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAG,IAAI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AAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACjC,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE;SACpD,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;YAC9B,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;;AA3IM,2BAAS,GAAiE,IAAI,OAAO,EAAE,AAA9E,CAA+E;AAwFhF;IAAd,KAAK;8CAUL","sourcesContent":["import type { ReactiveController, ReactiveElement } from 'lit';\n\nimport { bound } from '../decorators/bound.js';\nimport { debounce } from '../functions/debounce.js';\nimport { Logger } from './logger.js';\n\n/**\n * @deprecated: use context, especially via `@patternfly/pfe-core/functions/context.js`;\n */\nexport interface Options<E extends ReactiveElement> {\n properties: Partial<Record<keyof E, string | string[]>>;\n prefix?: string;\n}\n\n/**\n * @deprecated: use context, especially via `@patternfly/pfe-core/functions/context.js`;\n */\nexport class CascadeController<E extends ReactiveElement> implements ReactiveController {\n private class: typeof ReactiveElement;\n\n private logger: Logger;\n\n static instances: WeakMap<ReactiveElement, CascadeController<ReactiveElement>> = new WeakMap();\n\n mo = new MutationObserver(this.parse);\n\n cache = new Map<string, string[]>();\n\n constructor(public host: E, public options?: Options<E>) {\n this.class = host.constructor as typeof ReactiveElement;\n this.logger = new Logger(this.host);\n CascadeController.instances.set(host, this);\n const properties = this.options?.properties ?? {} as Options<E>['properties'];\n for (const [propName, cascade] of Object.entries(properties)) {\n this.initProp(propName, cascade);\n }\n host.addController(this);\n this.cascadeProperties = debounce(this.cascadeProperties, 1);\n }\n\n hostUpdated() {\n this.cascadeProperties();\n }\n\n hostConnected() {\n this.mo.observe(this.host, { attributes: true, childList: true });\n this.cascadeProperties();\n }\n\n hostDisconnected() {\n this.mo.disconnect();\n }\n\n /**\n * Handles the cascading of properties to nested components when new elements are added\n * Attribute updates/additions are handled by the attribute callback\n */\n cascadeProperties(nodeList: HTMLCollection | NodeList = this.host.children) {\n if (this.host.isConnected) {\n const selectors = this.cache.keys();\n\n // Find out if anything in the nodeList matches any of the observed selectors for cacading properties\n if (!nodeList) {\n return this._cascadeAttributes(selectors, this.cache);\n }\n\n\n for (const node of nodeList) {\n // if this node has a match function (i.e., it's an HTMLElement, not a text node),\n if (node instanceof Element) {\n // see if it matches one of the selectors, otherwise drop it (like it's hot).\n for (const selector of selectors) {\n // console.log('_copyAttribute', name, value, el.getAttribute(name));\n if (node.matches(selector)) {\n const attrNames = this.cache.get(selector);\n // each selector can match multiple properties/attributes, so\n // copy each of them\n for (const attrName of attrNames ?? []) {\n this._copyAttribute(attrName, node);\n }\n }\n }\n }\n }\n }\n }\n\n /**\n * Gets the configured attribute name for the decorated property,\n * falling back to the lowercased property name, and caches the attribute name\n * with it's designated child selectors for value-propagation on change\n */\n initProp(propName: string, cascade: string | string[]) {\n for (const nodeItem of [cascade].flat(Infinity).filter(Boolean) as string[]) {\n const { attribute } = this.class.getPropertyOptions(propName);\n\n const attr =\n typeof attribute === 'string' ? attribute\n : propName.toLowerCase();\n\n // Create an object with the node as the key and an array of attributes\n // that are to be cascaded down to it\n if (!this.cache.get(nodeItem)) {\n this.cache.set(nodeItem, [attr]);\n } else {\n this.cache.get(nodeItem)?.push(attr);\n }\n }\n }\n\n @bound private parse(mutations: MutationRecord[]) {\n // Iterate over the mutation list, look for cascade updates\n for (const mutation of mutations ?? []) {\n // If a new node is added, attempt to cascade attributes to it\n if (mutation.type === 'childList' && mutation.addedNodes.length) {\n this.cascadeProperties(mutation.addedNodes);\n } else if (mutation.type === 'attributes') {\n this._cascadeAttributes(this.cache.keys(), this.cache);\n }\n }\n }\n\n /**\n * Copy the named attribute to a target element.\n */\n private async _copyAttribute(name: string, el: Element) {\n this.logger.log(`copying ${name} to ${el}`);\n const value = this.host.getAttribute(name);\n if (el.isConnected) {\n if (value == null) {\n el.removeAttribute(name);\n } else {\n el.setAttribute(name, value);\n }\n }\n }\n\n private _cascadeAttributes(selectors: IterableIterator<string>, set: this['cache']) {\n for (const selector of selectors) {\n for (const attr of set.get(selector) ?? []) {\n this._cascadeAttribute(attr, selector);\n }\n }\n }\n\n /**\n * Trigger a cascade of the named attribute to any child elements that match\n * the `to` selector. The selector can match elements in the light DOM and\n * shadow DOM.\n * @param name The name of the attribute to cascade (not necessarily the same as the property name).\n * @param to A CSS selector that matches the elements that should received the cascaded attribute. The selector will be applied within `this` element's light and shadow DOM trees.\n */\n private _cascadeAttribute(name: string, to: string) {\n const recipients = [\n ...this.host.querySelectorAll(to),\n ...this.host.shadowRoot?.querySelectorAll(to) ?? [],\n ];\n\n for (const node of recipients) {\n this._copyAttribute(name, node);\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Placement } from '@floating-ui/dom';
|
|
2
|
-
import type { ReactiveController,
|
|
2
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
3
3
|
import type { StyleInfo } from 'lit/directives/style-map.js';
|
|
4
4
|
import type { OffsetOptions as Offset } from '@floating-ui/core';
|
|
5
5
|
export type { Placement };
|
|
@@ -42,7 +42,7 @@ export declare class FloatingDOMController implements ReactiveController {
|
|
|
42
42
|
* - `--_floating-content-translate`: translate to apply to floating content.
|
|
43
43
|
*/
|
|
44
44
|
get styles(): StyleInfo;
|
|
45
|
-
constructor(host:
|
|
45
|
+
constructor(host: ReactiveControllerHost, options: FloatingDOMControllerOptions);
|
|
46
46
|
hostDisconnected(): void;
|
|
47
47
|
/** Show the floating DOM */
|
|
48
48
|
show({ offset, placement, flip, fallbackPlacements }?: ShowOptions): Promise<void>;
|
|
@@ -1,45 +1,27 @@
|
|
|
1
|
+
var _FloatingDOMController_instances, _FloatingDOMController_open, _FloatingDOMController_opening, _FloatingDOMController_cleanup, _FloatingDOMController_anchor, _FloatingDOMController_alignment, _FloatingDOMController_styles, _FloatingDOMController_placement, _FloatingDOMController_options, _FloatingDOMController_invoker_get, _FloatingDOMController_content_get, _FloatingDOMController_arrow_get, _FloatingDOMController_update;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
1
3
|
import { autoUpdate, computePosition, offset as offsetMiddleware, shift as shiftMiddleware, flip as flipMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';
|
|
2
4
|
/**
|
|
3
5
|
* Controls floating DOM within a web component, e.g. tooltips and popovers
|
|
4
6
|
*/
|
|
5
7
|
export class FloatingDOMController {
|
|
6
|
-
#open = false;
|
|
7
|
-
#opening = false;
|
|
8
|
-
#cleanup;
|
|
9
|
-
#anchor;
|
|
10
|
-
#alignment;
|
|
11
|
-
#styles;
|
|
12
|
-
#placement;
|
|
13
|
-
#options;
|
|
14
|
-
get #invoker() {
|
|
15
|
-
const { invoker } = this.#options;
|
|
16
|
-
return typeof invoker === 'function' ? invoker() : invoker;
|
|
17
|
-
}
|
|
18
|
-
get #content() {
|
|
19
|
-
const { content } = this.#options;
|
|
20
|
-
return typeof content === 'function' ? content() : content;
|
|
21
|
-
}
|
|
22
|
-
get #arrow() {
|
|
23
|
-
const { arrow } = this.#options;
|
|
24
|
-
return typeof arrow === 'function' ? arrow() : arrow;
|
|
25
|
-
}
|
|
26
8
|
/** The crosswise alignment of the invoker on which to display the floating DOM */
|
|
27
9
|
get alignment() {
|
|
28
|
-
return this
|
|
10
|
+
return __classPrivateFieldGet(this, _FloatingDOMController_alignment, "f") ?? 'center';
|
|
29
11
|
}
|
|
30
12
|
/** The side of the invoker on which to display the floating DOM */
|
|
31
13
|
get anchor() {
|
|
32
|
-
return this
|
|
14
|
+
return __classPrivateFieldGet(this, _FloatingDOMController_anchor, "f") ?? '';
|
|
33
15
|
}
|
|
34
16
|
/**
|
|
35
17
|
* When true, the floating DOM is visible
|
|
36
18
|
*/
|
|
37
19
|
get open() {
|
|
38
|
-
return this
|
|
20
|
+
return __classPrivateFieldGet(this, _FloatingDOMController_open, "f");
|
|
39
21
|
}
|
|
40
22
|
/** The computed placement of the floating DOM */
|
|
41
23
|
get placement() {
|
|
42
|
-
return this
|
|
24
|
+
return __classPrivateFieldGet(this, _FloatingDOMController_placement, "f") ?? 'top';
|
|
43
25
|
}
|
|
44
26
|
/**
|
|
45
27
|
* Styles to apply to your element's container
|
|
@@ -47,86 +29,107 @@ export class FloatingDOMController {
|
|
|
47
29
|
* - `--_floating-content-translate`: translate to apply to floating content.
|
|
48
30
|
*/
|
|
49
31
|
get styles() {
|
|
50
|
-
return this
|
|
32
|
+
return __classPrivateFieldGet(this, _FloatingDOMController_styles, "f") ?? {};
|
|
51
33
|
}
|
|
52
34
|
constructor(host, options) {
|
|
35
|
+
_FloatingDOMController_instances.add(this);
|
|
53
36
|
this.host = host;
|
|
37
|
+
_FloatingDOMController_open.set(this, false);
|
|
38
|
+
_FloatingDOMController_opening.set(this, false);
|
|
39
|
+
_FloatingDOMController_cleanup.set(this, void 0);
|
|
40
|
+
_FloatingDOMController_anchor.set(this, void 0);
|
|
41
|
+
_FloatingDOMController_alignment.set(this, void 0);
|
|
42
|
+
_FloatingDOMController_styles.set(this, void 0);
|
|
43
|
+
_FloatingDOMController_placement.set(this, void 0);
|
|
44
|
+
_FloatingDOMController_options.set(this, void 0);
|
|
54
45
|
host.addController(this);
|
|
55
|
-
this
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
__classPrivateFieldSet(this, _FloatingDOMController_options, {
|
|
47
|
+
invoker: (host instanceof HTMLElement ? () => host : () => undefined),
|
|
48
|
+
shift: true,
|
|
49
|
+
...options,
|
|
50
|
+
}, "f");
|
|
58
51
|
}
|
|
59
52
|
hostDisconnected() {
|
|
60
|
-
this
|
|
61
|
-
}
|
|
62
|
-
async #update(placement = 'top', offset, flip = true, fallbackPlacements) {
|
|
63
|
-
const { padding, shift } = this.#options;
|
|
64
|
-
const invoker = this.#invoker;
|
|
65
|
-
const content = this.#content;
|
|
66
|
-
const arrow = this.#arrow;
|
|
67
|
-
if (!invoker || !content) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const { x, y, placement: _placement, middlewareData } = await computePosition(invoker, content, {
|
|
71
|
-
strategy: 'absolute',
|
|
72
|
-
placement,
|
|
73
|
-
middleware: [
|
|
74
|
-
offsetMiddleware(offset),
|
|
75
|
-
shift && shiftMiddleware({ padding }),
|
|
76
|
-
arrow && arrowMiddleware({ element: arrow, padding: arrow.offsetHeight / 2 }),
|
|
77
|
-
flip && flipMiddleware({ padding, fallbackPlacements }),
|
|
78
|
-
].filter(Boolean)
|
|
79
|
-
});
|
|
80
|
-
if (arrow) {
|
|
81
|
-
const { x: arrowX, y: arrowY } = middlewareData.arrow || {};
|
|
82
|
-
const staticSide = {
|
|
83
|
-
top: 'bottom',
|
|
84
|
-
right: 'left',
|
|
85
|
-
bottom: 'top',
|
|
86
|
-
left: 'right',
|
|
87
|
-
}[_placement.split('-')[0]] || '';
|
|
88
|
-
Object.assign(arrow.style, {
|
|
89
|
-
left: arrowX != null ? `${arrowX}px` : '',
|
|
90
|
-
top: arrowY != null && !['top'].includes(_placement) ? `${arrowY}px` : '',
|
|
91
|
-
right: '',
|
|
92
|
-
bottom: '',
|
|
93
|
-
[staticSide]: `-${arrow.offsetHeight / 2}px`,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
this.#placement = _placement;
|
|
97
|
-
[this.#anchor, this.#alignment] = (this.#placement.split('-') ?? []);
|
|
98
|
-
this.#styles = {
|
|
99
|
-
'--_floating-content-translate': `${x}px ${y}px`,
|
|
100
|
-
};
|
|
101
|
-
this.host.requestUpdate();
|
|
53
|
+
__classPrivateFieldGet(this, _FloatingDOMController_cleanup, "f")?.call(this);
|
|
102
54
|
}
|
|
103
55
|
/** Show the floating DOM */
|
|
104
56
|
async show({ offset, placement, flip, fallbackPlacements } = {}) {
|
|
105
|
-
const invoker = this
|
|
106
|
-
const content = this
|
|
57
|
+
const invoker = __classPrivateFieldGet(this, _FloatingDOMController_instances, "a", _FloatingDOMController_invoker_get);
|
|
58
|
+
const content = __classPrivateFieldGet(this, _FloatingDOMController_instances, "a", _FloatingDOMController_content_get);
|
|
107
59
|
if (!invoker || !content) {
|
|
108
60
|
return;
|
|
109
61
|
}
|
|
110
|
-
if (!this
|
|
111
|
-
this
|
|
112
|
-
const p = this
|
|
113
|
-
this
|
|
62
|
+
if (!__classPrivateFieldGet(this, _FloatingDOMController_opening, "f")) {
|
|
63
|
+
__classPrivateFieldSet(this, _FloatingDOMController_opening, true, "f");
|
|
64
|
+
const p = __classPrivateFieldGet(this, _FloatingDOMController_instances, "m", _FloatingDOMController_update).call(this, placement, offset, flip, fallbackPlacements);
|
|
65
|
+
__classPrivateFieldSet(this, _FloatingDOMController_cleanup, __classPrivateFieldGet(this, _FloatingDOMController_cleanup, "f") ?? autoUpdate(invoker, content, () => __classPrivateFieldGet(this, _FloatingDOMController_instances, "m", _FloatingDOMController_update).call(this, placement, offset, flip, fallbackPlacements)), "f");
|
|
114
66
|
await p;
|
|
115
|
-
this
|
|
67
|
+
__classPrivateFieldSet(this, _FloatingDOMController_opening, false, "f");
|
|
116
68
|
}
|
|
117
|
-
this
|
|
69
|
+
__classPrivateFieldSet(this, _FloatingDOMController_open, true, "f");
|
|
118
70
|
this.host.requestUpdate();
|
|
119
71
|
}
|
|
120
72
|
/** Hide the floating DOM */
|
|
121
73
|
async hide() {
|
|
122
74
|
await this.host.updateComplete;
|
|
123
|
-
while (this
|
|
75
|
+
while (__classPrivateFieldGet(this, _FloatingDOMController_opening, "f") && !this.open) {
|
|
124
76
|
await new Promise(requestAnimationFrame);
|
|
125
77
|
}
|
|
126
|
-
this
|
|
127
|
-
this
|
|
78
|
+
__classPrivateFieldSet(this, _FloatingDOMController_open, false, "f");
|
|
79
|
+
__classPrivateFieldGet(this, _FloatingDOMController_cleanup, "f")?.call(this);
|
|
128
80
|
this.host.requestUpdate();
|
|
129
81
|
await this.host.updateComplete;
|
|
130
82
|
}
|
|
131
83
|
}
|
|
84
|
+
_FloatingDOMController_open = new WeakMap(), _FloatingDOMController_opening = new WeakMap(), _FloatingDOMController_cleanup = new WeakMap(), _FloatingDOMController_anchor = new WeakMap(), _FloatingDOMController_alignment = new WeakMap(), _FloatingDOMController_styles = new WeakMap(), _FloatingDOMController_placement = new WeakMap(), _FloatingDOMController_options = new WeakMap(), _FloatingDOMController_instances = new WeakSet(), _FloatingDOMController_invoker_get = function _FloatingDOMController_invoker_get() {
|
|
85
|
+
const { invoker } = __classPrivateFieldGet(this, _FloatingDOMController_options, "f");
|
|
86
|
+
return typeof invoker === 'function' ? invoker() : invoker;
|
|
87
|
+
}, _FloatingDOMController_content_get = function _FloatingDOMController_content_get() {
|
|
88
|
+
const { content } = __classPrivateFieldGet(this, _FloatingDOMController_options, "f");
|
|
89
|
+
return typeof content === 'function' ? content() : content;
|
|
90
|
+
}, _FloatingDOMController_arrow_get = function _FloatingDOMController_arrow_get() {
|
|
91
|
+
const { arrow } = __classPrivateFieldGet(this, _FloatingDOMController_options, "f");
|
|
92
|
+
return typeof arrow === 'function' ? arrow() : arrow;
|
|
93
|
+
}, _FloatingDOMController_update = async function _FloatingDOMController_update(placement = 'top', offset, flip = true, fallbackPlacements) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
const { padding, shift } = __classPrivateFieldGet(this, _FloatingDOMController_options, "f");
|
|
96
|
+
const invoker = __classPrivateFieldGet(this, _FloatingDOMController_instances, "a", _FloatingDOMController_invoker_get);
|
|
97
|
+
const content = __classPrivateFieldGet(this, _FloatingDOMController_instances, "a", _FloatingDOMController_content_get);
|
|
98
|
+
const arrow = __classPrivateFieldGet(this, _FloatingDOMController_instances, "a", _FloatingDOMController_arrow_get);
|
|
99
|
+
if (!invoker || !content) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const { x, y, placement: _placement, middlewareData } = await computePosition(invoker, content, {
|
|
103
|
+
strategy: 'absolute',
|
|
104
|
+
placement,
|
|
105
|
+
middleware: [
|
|
106
|
+
offsetMiddleware(offset),
|
|
107
|
+
shift && shiftMiddleware({ padding }),
|
|
108
|
+
arrow && arrowMiddleware({ element: arrow, padding: arrow.offsetHeight / 2 }),
|
|
109
|
+
flip && flipMiddleware({ padding, fallbackPlacements }),
|
|
110
|
+
].filter(Boolean)
|
|
111
|
+
});
|
|
112
|
+
if (arrow) {
|
|
113
|
+
const { x: arrowX, y: arrowY } = middlewareData.arrow || {};
|
|
114
|
+
const staticSide = {
|
|
115
|
+
top: 'bottom',
|
|
116
|
+
right: 'left',
|
|
117
|
+
bottom: 'top',
|
|
118
|
+
left: 'right',
|
|
119
|
+
}[_placement.split('-')[0]] || '';
|
|
120
|
+
Object.assign(arrow.style, {
|
|
121
|
+
left: arrowX != null ? `${arrowX}px` : '',
|
|
122
|
+
top: arrowY != null && !['top'].includes(_placement) ? `${arrowY}px` : '',
|
|
123
|
+
right: '',
|
|
124
|
+
bottom: '',
|
|
125
|
+
[staticSide]: `-${arrow.offsetHeight / 2}px`,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
__classPrivateFieldSet(this, _FloatingDOMController_placement, _placement, "f");
|
|
129
|
+
_a = this, _b = this, [({ set value(_c) { __classPrivateFieldSet(_a, _FloatingDOMController_anchor, _c, "f"); } }).value, ({ set value(_c) { __classPrivateFieldSet(_b, _FloatingDOMController_alignment, _c, "f"); } }).value] = (__classPrivateFieldGet(this, _FloatingDOMController_placement, "f").split('-') ?? []);
|
|
130
|
+
__classPrivateFieldSet(this, _FloatingDOMController_styles, {
|
|
131
|
+
'--_floating-content-translate': `${x}px ${y}px`,
|
|
132
|
+
}, "f");
|
|
133
|
+
this.host.requestUpdate();
|
|
134
|
+
};
|
|
132
135
|
//# sourceMappingURL=floating-dom-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floating-dom-controller.js","sourceRoot":"","sources":["floating-dom-controller.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,UAAU,EACV,eAAe,EACf,MAAM,IAAI,gBAAgB,EAC1B,KAAK,IAAI,eAAe,EACxB,IAAI,IAAI,cAAc,EACtB,KAAK,IAAI,eAAe,EACzB,MAAM,kBAAkB,CAAC;AAuB1B;;GAEG;AACH,MAAM,OAAO,qBAAqB;
|
|
1
|
+
{"version":3,"file":"floating-dom-controller.js","sourceRoot":"","sources":["floating-dom-controller.ts"],"names":[],"mappings":";;AAOA,OAAO,EACL,UAAU,EACV,eAAe,EACf,MAAM,IAAI,gBAAgB,EAC1B,KAAK,IAAI,eAAe,EACxB,IAAI,IAAI,cAAc,EACtB,KAAK,IAAI,eAAe,EACzB,MAAM,kBAAkB,CAAC;AAuB1B;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAyBhC,kFAAkF;IAClF,IAAI,SAAS;QACX,OAAO,uBAAA,IAAI,wCAAW,IAAI,QAAQ,CAAC;IACrC,CAAC;IAED,mEAAmE;IACnE,IAAI,MAAM;QACR,OAAO,uBAAA,IAAI,qCAAQ,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,uBAAA,IAAI,mCAAM,CAAC;IACpB,CAAC;IAED,iDAAiD;IACjD,IAAI,SAAS;QACX,OAAO,uBAAA,IAAI,wCAAW,IAAI,KAAK,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,uBAAA,IAAI,qCAAQ,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED,YACU,IAA4B,EACpC,OAAqC;;QAD7B,SAAI,GAAJ,IAAI,CAAwB;QAxDtC,sCAAQ,KAAK,EAAC;QACd,yCAAW,KAAK,EAAC;QACjB,iDAAsB;QACtB,gDAAiB;QACjB,mDAAuB;QACvB,gDAAoB;QACpB,mDAAuB;QACvB,iDAAuC;QAoDrC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACzB,uBAAA,IAAI,kCAAY;YACd,OAAO,EAAE,CAAC,IAAI,YAAY,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,CAA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C,IAAI;SAC7C,CAAC,CAAC;IACL,CAAC;IAED,uBAAA,IAAI,oCAAc,UAAU,MAAA,CAAC;IAC7B,KAAC,IAAI,OAAU,IAAI,EAAnB,yMAA+B,GAAG,CAAC,uBAAA,IAAI,wCAAW,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAwB,CAAC;IAC5F,uBAAA,IAAI,iCAAW;QACb,+BAA+B,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI;KACjD,MAAA,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import type { Placement } from '@floating-ui/dom';\nimport type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport type { StyleInfo } from 'lit/directives/style-map.js';\nimport type { OffsetOptions as Offset } from '@floating-ui/core';\n\nexport type { Placement };\n\nimport {\n autoUpdate,\n computePosition,\n offset as offsetMiddleware,\n shift as shiftMiddleware,\n flip as flipMiddleware,\n arrow as arrowMiddleware\n} from '@floating-ui/dom';\n\ntype Lazy<T> = T | (() => T | null | undefined);\n\ninterface FloatingDOMControllerOptions {\n content: Lazy<HTMLElement>;\n invoker?: Lazy<HTMLElement>;\n arrow?: Lazy<HTMLElement>;\n shift?: boolean;\n padding?: number;\n fallbackPlacements?: Placement[];\n}\n\ninterface ShowOptions {\n offset?: Offset;\n placement?: Placement;\n flip?: boolean;\n fallbackPlacements?: Placement[];\n}\n\nexport type Anchor = '' | 'top' | 'left' | 'bottom' | 'right';\nexport type Alignment = 'center' | 'start' | 'end';\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 #opening = false;\n #cleanup?: () => void;\n #anchor?: Anchor;\n #alignment?: Alignment;\n #styles?: StyleInfo;\n #placement?: Placement;\n #options: FloatingDOMControllerOptions;\n\n get #invoker() {\n const { invoker } = this.#options;\n return typeof invoker === 'function' ? invoker() : invoker;\n }\n\n get #content() {\n const { content } = this.#options;\n return typeof content === 'function' ? content() : content;\n }\n\n get #arrow() {\n const { arrow } = this.#options;\n return typeof arrow === 'function' ? arrow() : arrow;\n }\n\n /** The crosswise alignment of the invoker on which to display the floating DOM */\n get alignment() {\n return this.#alignment ?? 'center';\n }\n\n /** The side of the invoker on which to display the floating DOM */\n get anchor() {\n return this.#anchor ?? '';\n }\n\n /**\n * When true, the floating DOM is visible\n */\n get open() {\n return this.#open;\n }\n\n /** The computed placement of the floating DOM */\n get placement(): Placement {\n return this.#placement ?? 'top';\n }\n\n /**\n * Styles to apply to your element's container\n *\n * - `--_floating-content-translate`: translate to apply to floating content.\n */\n get styles(): StyleInfo {\n return this.#styles ?? {};\n }\n\n constructor(\n private host: ReactiveControllerHost,\n options: FloatingDOMControllerOptions\n ) {\n host.addController(this);\n this.#options = {\n invoker: (host instanceof HTMLElement ? () => host : () => undefined),\n shift: true,\n ...options,\n };\n }\n\n hostDisconnected() {\n this.#cleanup?.();\n }\n\n async #update(placement: Placement = 'top', offset?: Offset, flip = true, fallbackPlacements?: Placement[]) {\n const { padding, shift } = this.#options;\n\n const invoker = this.#invoker;\n const content = this.#content;\n const arrow = this.#arrow;\n if (!invoker || !content) {\n return;\n }\n const { x, y, placement: _placement, middlewareData } = await computePosition(invoker, content, {\n strategy: 'absolute',\n placement,\n middleware: [\n offsetMiddleware(offset),\n shift && shiftMiddleware({ padding }),\n arrow && arrowMiddleware({ element: arrow, padding: arrow.offsetHeight / 2 }),\n flip && flipMiddleware({ padding, fallbackPlacements }),\n ].filter(Boolean)\n });\n\n if (arrow) {\n const { x: arrowX, y: arrowY } = middlewareData.arrow || {};\n\n const staticSide = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n }[_placement.split('-')[0]] || '';\n\n Object.assign(arrow.style, {\n left: arrowX != null ? `${arrowX}px` : '',\n top: arrowY != null && !['top'].includes(_placement) ? `${arrowY}px` : '',\n right: '',\n bottom: '',\n [staticSide]: `-${arrow.offsetHeight / 2}px`,\n });\n }\n\n this.#placement = _placement;\n [this.#anchor, this.#alignment] = (this.#placement.split('-') ?? []) as [Anchor, Alignment];\n this.#styles = {\n '--_floating-content-translate': `${x}px ${y}px`,\n };\n this.host.requestUpdate();\n }\n\n /** Show the floating DOM */\n async show({ offset, placement, flip, fallbackPlacements }: ShowOptions = {}) {\n const invoker = this.#invoker;\n const content = this.#content;\n if (!invoker || !content) {\n return;\n }\n if (!this.#opening) {\n this.#opening = true;\n const p = this.#update(placement, offset, flip, fallbackPlacements);\n this.#cleanup ??= autoUpdate(invoker, content, () =>\n this.#update(placement, offset, flip, fallbackPlacements));\n await p;\n this.#opening = false;\n }\n this.#open = true;\n this.host.requestUpdate();\n }\n\n /** Hide the floating DOM */\n async hide() {\n await this.host.updateComplete;\n while (this.#opening && !this.open) {\n await new Promise(requestAnimationFrame);\n }\n this.#open = false;\n this.#cleanup?.();\n this.host.requestUpdate();\n await this.host.updateComplete;\n }\n}\n"]}
|
|
@@ -1,53 +1,97 @@
|
|
|
1
1
|
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
interface InternalsControllerOptions extends Partial<ARIAMixin> {
|
|
3
|
+
getHTMLElement?(): HTMLElement;
|
|
4
|
+
}
|
|
2
5
|
export declare class InternalsController implements ReactiveController, ARIAMixin {
|
|
3
6
|
#private;
|
|
4
|
-
host: ReactiveControllerHost
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
host: ReactiveControllerHost;
|
|
8
|
+
private options?;
|
|
9
|
+
private static instances;
|
|
10
|
+
readonly form: ElementInternals['form'];
|
|
11
|
+
readonly shadowRoot: ElementInternals['shadowRoot'];
|
|
12
|
+
readonly states: unknown;
|
|
13
|
+
readonly willValidate: ElementInternals['willValidate'];
|
|
14
|
+
readonly validationMessage: ElementInternals['validationMessage'];
|
|
15
|
+
static of(host: ReactiveControllerHost, options?: InternalsControllerOptions): InternalsController;
|
|
16
|
+
role: string | null;
|
|
17
|
+
ariaActivedescendant: string | null;
|
|
18
|
+
ariaAtomic: string | null;
|
|
19
|
+
ariaAutoComplete: string | null;
|
|
20
|
+
ariaBusy: string | null;
|
|
21
|
+
ariaChecked: string | null;
|
|
22
|
+
ariaColCount: string | null;
|
|
23
|
+
ariaColIndex: string | null;
|
|
12
24
|
ariaColIndexText: string | null;
|
|
13
|
-
ariaColSpan:
|
|
14
|
-
ariaCurrent:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
ariaColSpan: string | null;
|
|
26
|
+
ariaCurrent: string | null;
|
|
27
|
+
ariaDescription: string | null;
|
|
28
|
+
ariaDisabled: string | null;
|
|
29
|
+
ariaExpanded: string | null;
|
|
30
|
+
ariaHasPopup: string | null;
|
|
31
|
+
ariaHidden: string | null;
|
|
32
|
+
ariaInvalid: string | null;
|
|
33
|
+
ariaKeyShortcuts: string | null;
|
|
34
|
+
ariaLabel: string | null;
|
|
35
|
+
ariaLevel: string | null;
|
|
36
|
+
ariaLive: string | null;
|
|
37
|
+
ariaModal: string | null;
|
|
38
|
+
ariaMultiLine: string | null;
|
|
39
|
+
ariaMultiSelectable: string | null;
|
|
40
|
+
ariaOrientation: string | null;
|
|
41
|
+
ariaPlaceholder: string | null;
|
|
42
|
+
ariaPosInSet: string | null;
|
|
43
|
+
ariaPressed: string | null;
|
|
44
|
+
ariaReadOnly: string | null;
|
|
45
|
+
ariaRequired: string | null;
|
|
46
|
+
ariaRoleDescription: string | null;
|
|
47
|
+
ariaRowCount: string | null;
|
|
48
|
+
ariaRowIndex: string | null;
|
|
36
49
|
ariaRowIndexText: string | null;
|
|
37
|
-
ariaRowSpan:
|
|
38
|
-
ariaSelected:
|
|
39
|
-
ariaSetSize:
|
|
40
|
-
ariaSort:
|
|
41
|
-
ariaValueMax:
|
|
42
|
-
ariaValueMin:
|
|
43
|
-
ariaValueNow:
|
|
44
|
-
ariaValueText:
|
|
50
|
+
ariaRowSpan: string | null;
|
|
51
|
+
ariaSelected: string | null;
|
|
52
|
+
ariaSetSize: string | null;
|
|
53
|
+
ariaSort: string | null;
|
|
54
|
+
ariaValueMax: string | null;
|
|
55
|
+
ariaValueMin: string | null;
|
|
56
|
+
ariaValueNow: string | null;
|
|
57
|
+
ariaValueText: string | null;
|
|
58
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
59
|
+
ariaActiveDescendantElement: Element | null;
|
|
60
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
61
|
+
ariaControlsElements: Element | null;
|
|
62
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
63
|
+
ariaDescribedByElements: Element | null;
|
|
64
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
65
|
+
ariaDetailsElements: Element | null;
|
|
66
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
67
|
+
ariaErrorMessageElements: Element | null;
|
|
68
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
69
|
+
ariaFlowToElements: Element | null;
|
|
70
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
71
|
+
ariaLabelledByElements: Element | null;
|
|
72
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
73
|
+
ariaOwnsElements: Element | null;
|
|
45
74
|
/** True when the control is disabled via it's containing fieldset element */
|
|
46
75
|
get formDisabled(): boolean;
|
|
47
|
-
static protos: WeakMap<object, any>;
|
|
48
76
|
get labels(): NodeList;
|
|
49
77
|
get validity(): ValidityState;
|
|
50
|
-
|
|
78
|
+
/** A best-attempt based on observed behaviour in FireFox 115 on fedora 38 */
|
|
79
|
+
get computedLabelText(): string;
|
|
80
|
+
private get element();
|
|
81
|
+
private internals;
|
|
82
|
+
private _formDisabled;
|
|
83
|
+
private constructor();
|
|
84
|
+
/**
|
|
85
|
+
* Typescript (with experimental decorators) will compile the class
|
|
86
|
+
* such that the order of operations is:
|
|
87
|
+
* 1. set up constructor parameter fields
|
|
88
|
+
* 2. run decorated field setters with initializers as the value
|
|
89
|
+
* 3. run the rest of the constructor
|
|
90
|
+
* Because of that, `this.internals` may not be available in the decorator setter
|
|
91
|
+
* so we cheat here with nullish coalescing assignment operator `??=`;
|
|
92
|
+
*/
|
|
93
|
+
private attach;
|
|
94
|
+
private initializeOptions;
|
|
51
95
|
hostConnected?(): void;
|
|
52
96
|
setFormValue(...args: Parameters<ElementInternals['setFormValue']>): void;
|
|
53
97
|
setValidity(...args: Parameters<ElementInternals['setValidity']>): void;
|
|
@@ -56,3 +100,4 @@ export declare class InternalsController implements ReactiveController, ARIAMixi
|
|
|
56
100
|
submit(): void;
|
|
57
101
|
reset(): void;
|
|
58
102
|
}
|
|
103
|
+
export {};
|